Changeset e0f9950 in mainline
- Timestamp:
- 2011-10-21T13:59:19Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1a11a16
- Parents:
- aa5ae788
- Location:
- uspace/drv/audio/sb16
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dma.h
raa5ae788 re0f9950 60 60 } 61 61 /*----------------------------------------------------------------------------*/ 62 /** Physicalmallocator simulator62 /** DMA mallocator simulator 63 63 * 64 64 * @param[in] size Size of the required memory space 65 * @return Address of the al ligned and big enough memory place, NULL on failure.65 * @return Address of the aligned and big enough memory place, NULL on failure. 66 66 */ 67 67 static inline void * malloc24(size_t size) … … 79 79 } 80 80 /*----------------------------------------------------------------------------*/ 81 /** Physicalmallocator simulator81 /** DMA mallocator simulator 82 82 * 83 * @param[in] addr Address of the place allocated by malloc 3283 * @param[in] addr Address of the place allocated by malloc24 84 84 */ 85 85 static inline void free24(void *addr) -
uspace/drv/audio/sb16/dma_controller.c
raa5ae788 re0f9950 157 157 } dma_controller_t; 158 158 159 dma_controller_t controller_8237 = {159 static const dma_controller_t controller_8237 = { 160 160 .channel = { 161 161 { (uint8_t*)0x00, (uint8_t*)0x01, (uint8_t*)0x87 }, … … 172 172 }; 173 173 174 static inline dma_controller_t *dma_controller_init()174 static inline const dma_controller_t *dma_controller_init() 175 175 { 176 176 int ret = pio_enable(DMA_CONTROLLER_PAGE_BASE, sizeof(dma_page_regs_t), … … 193 193 } 194 194 /*----------------------------------------------------------------------------*/ 195 static int dma_setup_channel_8bit( dma_controller_t *controller,195 static int dma_setup_channel_8bit(const dma_controller_t *controller, 196 196 unsigned channel, uint32_t pa, uint16_t size) 197 197 { … … 237 237 } 238 238 /*----------------------------------------------------------------------------*/ 239 static int dma_setup_channel_16bit( dma_controller_t *controller,239 static int dma_setup_channel_16bit(const dma_controller_t *controller, 240 240 unsigned channel, uintptr_t pa, size_t size) 241 241 { … … 283 283 int dma_setup_channel(unsigned channel, uintptr_t pa, size_t size) 284 284 { 285 static dma_controller_t *controller = NULL;285 static const dma_controller_t *controller = NULL; 286 286 if (!controller) 287 287 controller = dma_controller_init(); -
uspace/drv/audio/sb16/main.c
raa5ae788 re0f9950 51 51 static int sb_get_res(const ddf_dev_t *device, uintptr_t *sb_regs, 52 52 size_t *sb_regs_size, uintptr_t *mpu_regs, size_t *mpu_regs_size, int *irq); 53 static int sb_enable_interrupts(ddf_dev_t *device); 53 54 /*----------------------------------------------------------------------------*/ 54 55 static driver_ops_t sb_driver_ops = { … … 89 90 static int sb_add_device(ddf_dev_t *device) 90 91 { 91 #define CHECK_RET_ FREE_RETURN(ret, msg...) \92 #define CHECK_RET_RETURN(ret, msg...) \ 92 93 if (ret != EOK) { \ 93 free(soft_state); \94 94 ddf_log_error(msg); \ 95 95 return ret; \ … … 98 98 assert(device); 99 99 100 sb16_drv_t *soft_state = malloc(sizeof(sb16_drv_t));100 sb16_drv_t *soft_state = ddf_dev_data_alloc(device, sizeof(sb16_drv_t)); 101 101 int ret = soft_state ? EOK : ENOMEM; 102 CHECK_RET_ FREE_RETURN(ret, "Failed to allocate sb16 structure.\n");102 CHECK_RET_RETURN(ret, "Failed to allocate sb16 structure.\n"); 103 103 104 104 uintptr_t sb_regs = 0, mpu_regs = 0; … … 108 108 ret = sb_get_res(device, &sb_regs, &sb_regs_size, &mpu_regs, 109 109 &mpu_regs_size, &irq); 110 CHECK_RET_ FREE_RETURN(ret,110 CHECK_RET_RETURN(ret, 111 111 "Failed to get resources: %s.\n", str_error(ret)); 112 112 113 113 irq_code_t *irq_code = sb16_irq_code(); 114 114 ret = register_interrupt_handler(device, irq, irq_handler, irq_code); 115 CHECK_RET_ FREE_RETURN(ret,115 CHECK_RET_RETURN(ret, 116 116 "Failed to register irq handler: %s.\n", str_error(ret)); 117 117 118 118 119 ddf_fun_t *dsp_fun = NULL, *mixer_fun = NULL; … … 124 125 if (mixer_fun) \ 125 126 ddf_fun_destroy(mixer_fun); \ 126 free(soft_state); \127 127 unregister_interrupt_handler(device, irq); \ 128 128 return ret; \ 129 129 } else (void)0 130 131 ret = sb_enable_interrupts(device); 132 CHECK_RET_UNREG_DEST_RETURN(ret, "Failed to enable interrupts: %s.\n", 133 str_error(ret)); 134 130 135 dsp_fun = ddf_fun_create(device, fun_exposed, "dsp"); 131 136 ret = dsp_fun ? EOK : ENOMEM; … … 144 149 CHECK_RET_UNREG_DEST_RETURN(ret, 145 150 "Failed to bind dsp function: %s.\n", str_error(ret)); 146 dsp_fun->driver_data = soft_state;147 151 148 152 ret = ddf_fun_bind(mixer_fun); 149 153 CHECK_RET_UNREG_DEST_RETURN(ret, 150 154 "Failed to bind mixer function: %s.\n", str_error(ret)); 155 156 /* Everything's OK assign driver_data. */ 151 157 mixer_fun->driver_data = soft_state; 152 158 dsp_fun->driver_data = soft_state; 153 159 154 160 ret = sb16_init_mpu(soft_state, (void*)mpu_regs, mpu_regs_size); … … 224 230 return EOK; 225 231 } 232 /*----------------------------------------------------------------------------*/ 233 int sb_enable_interrupts(ddf_dev_t *device) 234 { 235 async_sess_t *parent_sess = 236 devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle, 237 IPC_FLAG_BLOCKING); 238 if (!parent_sess) 239 return ENOMEM; 240 241 bool enabled = hw_res_enable_interrupt(parent_sess); 242 async_hangup(parent_sess); 243 244 return enabled ? EOK : EIO; 245 } 226 246 /** 227 247 * @} 228 248 */ 229
Note:
See TracChangeset
for help on using the changeset viewer.