Changeset 7257eea6 in mainline
- Timestamp:
- 2011-10-21T19:01:15Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f14e6ea
- Parents:
- 9f351c8
- Location:
- uspace/drv/audio/sb16
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dma_controller.c
r9f351c8 r7257eea6 67 67 #define DMA_MODE_CHAN_SELECT_MASK (0x3) 68 68 #define DMA_MODE_CHAN_SELECT_SHIFT (0) 69 #define DMA_MODE_CHAN_TO_REG(x) \ 70 (((x % 4) & DMA_MODE_CHAN_SELECT_MASK) << DMA_MODE_CHAN_SELECT_SHIFT) 69 71 #define DMA_MODE_CHAN_TRA_MASK (0x3) 70 72 #define DMA_MODE_CHAN_TRA_SHIFT (2) 71 73 #define DMA_MODE_CHAN_TRA_SELF_TEST (0) 72 #define DMA_MODE_CHAN_TRA_WRITE ( 1)73 #define DMA_MODE_CHAN_TRA_READ ( 2)74 #define DMA_MODE_CHAN_TRA_WRITE (0x1) 75 #define DMA_MODE_CHAN_TRA_READ (0x2) 74 76 #define DMA_MODE_CHAN_AUTO_FLAG (1 << 4) 75 77 #define DMA_MODE_CHAN_DOWN_FLAG (1 << 5) … … 216 218 if (channel == 0 || channel == 4) 217 219 return ENOTSUP; 218 219 220 if (channel > 7) 220 221 return ENOENT; … … 267 268 } 268 269 /*----------------------------------------------------------------------------*/ 269 int dma_prepare_channel(unsigned channel, bool write, transfer_mode_t mode) 270 int dma_prepare_channel( 271 unsigned channel, bool write, bool auto_mode, transfer_mode_t mode) 270 272 { 273 if (channel == 0 || channel == 4) 274 return ENOTSUP; 275 if (channel > 7) 276 return ENOENT; 277 271 278 if (!controller_8237.initialized) 272 279 return EIO; 273 280 274 return ENOTSUP; 281 dma_channel_t dma_channel = controller_8237.channels[channel]; 282 283 /* Mask DMA request */ 284 uint8_t value = DMA_SINGLE_MASK_CHAN_TO_REG(channel) 285 | DMA_SINGLE_MASK_MASKED_FLAG; 286 pio_write_8(dma_channel.single_mask_address, value); 287 288 /* Set DMA mode */ 289 value = DMA_MODE_CHAN_TO_REG(channel) 290 | ((write ? DMA_MODE_CHAN_TRA_WRITE : DMA_MODE_CHAN_TRA_READ) 291 << DMA_MODE_CHAN_TRA_SHIFT) 292 | (auto_mode ? DMA_MODE_CHAN_AUTO_FLAG : 0) 293 | (mode << DMA_MODE_CHAN_MOD_SHIFT); 294 pio_write_8(dma_channel.mode_address, value); 295 296 /* Unmask DMA request */ 297 value = DMA_SINGLE_MASK_CHAN_TO_REG(channel); 298 pio_write_8(dma_channel.single_mask_address, value); 299 300 return EOK; 275 301 } 276 302 /** -
uspace/drv/audio/sb16/dma_controller.h
r9f351c8 r7257eea6 45 45 int dma_setup_channel(unsigned channel, uintptr_t pa, size_t size); 46 46 47 int dma_prepare_channel(unsigned channel, bool write, transfer_mode_t mode); 47 int dma_prepare_channel( 48 unsigned channel, bool write, bool auto_mode, transfer_mode_t mode); 48 49 49 50 #endif -
uspace/drv/audio/sb16/dsp.c
r9f351c8 r7257eea6 99 99 100 100 const uintptr_t pa = addr_to_phys(buffer); 101 /* Set 16 bit channel */ 101 102 const int ret = dma_setup_channel(SB_DMA_CHAN_16, pa, PAGE_SIZE); 102 103 if (ret == EOK) { … … 104 105 dsp->buffer.buffer_position = buffer; 105 106 dsp->buffer.buffer_size = PAGE_SIZE; 107 dma_prepare_channel(SB_DMA_CHAN_16, false, true, BLOCK_DMA); 108 /* Set 8bit channel */ 109 const int ret = dma_setup_channel(SB_DMA_CHAN_8, pa, PAGE_SIZE); 110 if (ret == EOK) { 111 dma_prepare_channel( 112 SB_DMA_CHAN_8, false, true, BLOCK_DMA); 113 } 106 114 } else { 107 115 ddf_log_error("Failed to setup DMA buffer %s.\n", … … 110 118 } 111 119 return ret; 120 } 121 /*----------------------------------------------------------------------------*/ 122 static inline void sb_clear_buffer(sb_dsp_t *dsp) 123 { 124 free24(dsp->buffer.buffer_data); 125 dsp->buffer.buffer_data = NULL; 126 dsp->buffer.buffer_position = NULL; 127 dsp->buffer.buffer_size = 0; 112 128 } 113 129 /*----------------------------------------------------------------------------*/ … … 155 171 /*----------------------------------------------------------------------------*/ 156 172 int sb_dsp_play(sb_dsp_t *dsp, const uint8_t *data, size_t size, 157 u nsignedsampling_rate, unsigned channels, unsigned bit_depth)173 uint16_t sampling_rate, unsigned channels, unsigned bit_depth) 158 174 { 159 175 assert(dsp); -
uspace/drv/audio/sb16/dsp.h
r9f351c8 r7257eea6 57 57 unsigned sample_rate, unsigned channels, unsigned bit_depth); 58 58 int sb_dsp_play(sb_dsp_t *dsp, const uint8_t *data, size_t size, 59 u nsignedsample_rate, unsigned channels, unsigned bit_depth);59 uint16_t sample_rate, unsigned channels, unsigned bit_depth); 60 60 61 61 #endif
Note:
See TracChangeset
for help on using the changeset viewer.