Changeset c5cbc1b7 in mainline
- Timestamp:
- 2012-07-19T17:02:52Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2e01b3f
- Parents:
- 1bebadee
- Location:
- uspace/drv/audio/sb16
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dsp.c
r1bebadee rc5cbc1b7 33 33 */ 34 34 35 #include <as.h> 35 36 #include <bool.h> 37 #include <ddi.h> 36 38 #include <devman.h> 37 39 #include <device/hw_res.h> … … 41 43 #include <audio_pcm_iface.h> 42 44 43 #include "dma.h"44 45 #include "ddf_log.h" 45 46 #include "dsp_commands.h" 46 47 #include "dsp.h" 47 48 48 #define MAX_BUFFER_SIZE (PAGE_SIZE) 49 /* Maximum allowed transfer size for ISA DMA transfers is 64kB */ 50 #define MAX_BUFFER_SIZE (4 * 1024) // use 4kB for now 49 51 50 52 #ifndef DSP_RETRY_COUNT … … 103 105 async_sess_t *sess = devman_parent_device_connect(EXCHANGE_ATOMIC, 104 106 dsp->sb_dev->handle, IPC_FLAG_BLOCKING); 105 if (!sess)106 return ENOMEM;107 107 108 108 const int ret = hw_res_dma_channel_setup(sess, 109 109 dsp->dma16_channel, pa, size, 110 110 DMA_MODE_READ | DMA_MODE_AUTO | DMA_MODE_ON_DEMAND); 111 111 112 async_hangup(sess); 112 113 return ret; … … 118 119 if (size > MAX_BUFFER_SIZE || size == 0 || (size % 2) == 1) 119 120 size = MAX_BUFFER_SIZE; 120 uint8_t *buffer = dma_create_buffer24(size); 121 if (buffer == NULL) { 121 void *buffer = NULL, *pa = NULL; 122 int ret = dmamem_map_anonymous(size, AS_AREA_WRITE | AS_AREA_READ, 123 0, &pa, &buffer); 124 if (ret != EOK) { 122 125 ddf_log_error("Failed to allocate DMA buffer."); 123 126 return ENOMEM; 124 127 } 125 128 126 const uintptr_t pa = addr_to_phys(buffer);127 assert( pa < (1 << 25));128 129 /* Set 16 bit channel */130 const int ret = sb_setup_dma(dsp,pa, size);129 ddf_log_verbose("Setup dma buffer at %p(%p).", buffer, pa, size); 130 assert((uintptr_t)pa < (1 << 25)); 131 132 /* Setup 16 bit channel */ 133 ret = sb_setup_dma(dsp, (uintptr_t)pa, size); 131 134 if (ret == EOK) { 132 135 dsp->buffer.data = buffer; 133 136 dsp->buffer.size = size; 134 bzero(dsp->buffer.data, dsp->buffer.size);135 137 } else { 136 138 ddf_log_error("Failed to setup DMA16 channel: %s.", 137 139 str_error(ret)); 138 dma _destroy_buffer(buffer);140 dmamem_unmap_anonymous(buffer); 139 141 } 140 142 return ret; … … 143 145 static inline void sb_clear_buffer(sb_dsp_t *dsp) 144 146 { 145 dma_destroy_buffer(dsp->buffer.data); 147 assert(dsp); 148 dmamem_unmap_anonymous(dsp->buffer.data); 146 149 dsp->buffer.data = NULL; 147 150 dsp->buffer.size = 0;
Note:
See TracChangeset
for help on using the changeset viewer.