Changeset 5984107 in mainline for uspace/drv/audio/sb16/dsp.c
- Timestamp:
- 2011-10-22T09:47:12Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ac149d5
- Parents:
- 962ef67
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dsp.c
r962ef67 r5984107 53 53 #define SB_DMA_CHAN_8 1 54 54 55 #define AUTO_DMA_MODE 56 57 #ifdef AUTO_DMA_MODE 58 #undef AUTO_DMA_MODE 59 #define AUTO_DMA_MODE true 60 #else 61 #define AUTO_DMA_MODE false 62 #endif 63 55 64 static inline int sb_dsp_read(sb_dsp_t *dsp, uint8_t *data) 56 65 { … … 103 112 return ENOMEM; 104 113 } 105 106 114 107 115 const uintptr_t pa = addr_to_phys(buffer); … … 115 123 dsp->buffer.size = BUFFER_SIZE; 116 124 bzero(buffer, BUFFER_SIZE); 117 dma_prepare_channel(SB_DMA_CHAN_16, false, true, BLOCK_DMA); 125 dma_prepare_channel( 126 SB_DMA_CHAN_16, false, AUTO_DMA_MODE, BLOCK_DMA); 118 127 /* Set 8bit channel */ 119 128 const int ret = dma_setup_channel(SB_DMA_CHAN_8, pa, BUFFER_SIZE); 120 129 if (ret == EOK) { 121 130 dma_prepare_channel( 122 SB_DMA_CHAN_8, false, true, BLOCK_DMA); 131 SB_DMA_CHAN_8, false, AUTO_DMA_MODE, BLOCK_DMA); 132 } else { 133 ddf_log_warning("Failed to setup DMA8 channel: %s.\n", 134 str_error(ret)); 123 135 } 124 136 } else { 125 ddf_log_error("Failed to setup DMA buffer%s.\n",137 ddf_log_error("Failed to setup DMA16 channel %s.\n", 126 138 str_error(ret)); 127 139 free24(buffer); … … 207 219 if (dsp->buffer.position == (dsp->buffer.data + dsp->buffer.size)) 208 220 dsp->buffer.position = dsp->buffer.data; 221 if (!AUTO_DMA_MODE) { 222 sb_dsp_write(dsp, SINGLE_DMA_16B_DA_FIFO); 223 sb_dsp_write(dsp, dsp->playing.mode); 224 sb_dsp_write(dsp, (PLAY_BLOCK_SIZE - 1) & 0xff); 225 sb_dsp_write(dsp, (PLAY_BLOCK_SIZE - 1) >> 8); 226 } 209 227 210 228 } … … 239 257 return ENOTSUP; 240 258 241 ddf_log_ fatal("Buffer prepare.\n");259 ddf_log_debug("Buffer prepare.\n"); 242 260 const int ret = sb_setup_buffer(dsp); 243 261 if (ret != EOK) … … 248 266 memcpy(dsp->buffer.data, dsp->playing.data, play_size); 249 267 250 ddf_log_ note("Playing sound: %zu(%zu) bytes.\n", play_size, size);268 ddf_log_debug("Playing sound: %zu(%zu) bytes.\n", play_size, size); 251 269 252 270 dsp->playing.data = data; … … 256 274 (bit_depth == 16 ? 0x10 : 0) | (channels == 2 ? 0x20 : 0); 257 275 276 ddf_log_debug("Setting mode %hhx.\n", dsp->playing.mode); 258 277 sb_dsp_write(dsp, SET_SAMPLING_RATE_OUTPUT); 259 278 sb_dsp_write(dsp, sampling_rate >> 8); 260 279 sb_dsp_write(dsp, sampling_rate & 0xff); 261 280 262 sb_dsp_write(dsp, AUTO_DMA_16B_DA_FIFO); 281 ddf_log_debug("Set sampling rate %hhx:%hhx.\n", 282 sampling_rate >> 8, sampling_rate & 0xff); 283 284 if (AUTO_DMA_MODE) { 285 sb_dsp_write(dsp, AUTO_DMA_16B_DA_FIFO); 286 } else { 287 sb_dsp_write(dsp, SINGLE_DMA_16B_DA_FIFO); 288 } 263 289 sb_dsp_write(dsp, dsp->playing.mode); 264 290 sb_dsp_write(dsp, (play_size - 1) & 0xff);
Note:
See TracChangeset
for help on using the changeset viewer.