Changeset ad42844 in mainline for uspace/drv/audio/sb16/dsp.c
- Timestamp:
- 2012-08-19T14:17:16Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d86c9736
- Parents:
- d758301
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dsp.c
rd758301 rad42844 101 101 } 102 102 103 static inline void sb_dsp_start_active(sb_dsp_t *dsp, uint8_t command) 104 { 105 sb_dsp_write(dsp, command); 106 sb_dsp_write(dsp, dsp->active.mode); 107 sb_dsp_write(dsp, (dsp->active.samples - 1) & 0xff); 108 sb_dsp_write(dsp, (dsp->active.samples - 1) >> 8); 109 } 110 111 static inline void sb_dsp_set_sampling_rate(sb_dsp_t *dsp, unsigned rate) 112 { 113 sb_dsp_write(dsp, SET_SAMPLING_RATE_OUTPUT); 114 sb_dsp_write(dsp, rate >> 8); 115 sb_dsp_write(dsp, rate & 0xff); 116 ddf_log_verbose("Sampling rate: %hhx:%hhx.", rate >> 8, rate & 0xff); 117 } 118 103 119 static inline int sb_setup_dma(sb_dsp_t *dsp, uintptr_t pa, size_t size) 104 120 { … … 196 212 #ifndef AUTO_DMA_MODE 197 213 if (dsp->status == DSP_PLAYBACK) { 198 sb_dsp_write(dsp, SINGLE_DMA_16B_DA); 199 sb_dsp_write(dsp, dsp->active.mode); 200 sb_dsp_write(dsp, (dsp->active.samples - 1) & 0xff); 201 sb_dsp_write(dsp, (dsp->active.samples - 1) >> 8); 214 sb_dsp_start_active(dsp, SINGLE_DMA_16B_DA); 202 215 } 203 216 204 217 if (dsp->status == DSP_RECORDING) { 205 sb_dsp_write(dsp, SINGLE_DMA_16B_AD); 206 sb_dsp_write(dsp, dsp->active.mode); 207 sb_dsp_write(dsp, (dsp->active.samples - 1) & 0xff); 208 sb_dsp_write(dsp, (dsp->active.samples - 1) >> 8); 218 sb_dsp_start_active(dsp, SINGLE_DMA_16B_AD); 209 219 } 210 220 #endif … … 349 359 } 350 360 351 const bool sign = (format == PCM_SAMPLE_SINT16_LE);352 353 sb_dsp_write(dsp, SET_SAMPLING_RATE_OUTPUT);354 sb_dsp_write(dsp, sampling_rate >> 8);355 sb_dsp_write(dsp, sampling_rate & 0xff);356 357 ddf_log_verbose("Sample rate: %hhx:%hhx.",358 sampling_rate >> 8, sampling_rate & 0xff);359 360 #ifdef AUTO_DMA_MODE361 sb_dsp_write(dsp, AUTO_DMA_16B_DA_FIFO);362 #else363 sb_dsp_write(dsp, SINGLE_DMA_16B_DA);364 #endif365 366 361 dsp->active.mode = 0 367 | ( sign? DSP_MODE_SIGNED : 0)362 | (pcm_sample_format_is_signed(format) ? DSP_MODE_SIGNED : 0) 368 363 | (channels == 2 ? DSP_MODE_STEREO : 0); 369 364 dsp->active.samples = frames * channels; 370 365 dsp->active.frame_count = 0; 371 366 372 sb_dsp_write(dsp, dsp->active.mode); 373 sb_dsp_write(dsp, (dsp->active.samples - 1) & 0xff); 374 sb_dsp_write(dsp, (dsp->active.samples - 1) >> 8); 367 sb_dsp_set_sampling_rate(dsp, sampling_rate); 368 369 #ifdef AUTO_DMA_MODE 370 sb_dsp_start_active(dsp, AUTO_DMA_16B_DA_FIFO); 371 #else 372 sb_dsp_start_active(dsp, SINGLE_DMA_16B_DA); 373 #endif 375 374 376 375 ddf_log_verbose("Playback started, interrupt every %u samples " … … 417 416 } 418 417 419 const bool sign = (format == PCM_SAMPLE_SINT16_LE); 420 421 sb_dsp_write(dsp, SET_SAMPLING_RATE_OUTPUT); 422 sb_dsp_write(dsp, sampling_rate >> 8); 423 sb_dsp_write(dsp, sampling_rate & 0xff); 424 425 ddf_log_verbose("Sampling rate: %hhx:%hhx.", 426 sampling_rate >> 8, sampling_rate & 0xff); 427 428 #ifdef AUTO_DMA_MODE 429 sb_dsp_write(dsp, AUTO_DMA_16B_AD_FIFO); 430 #else 431 sb_dsp_write(dsp, SINGLE_DMA_16B_AD); 432 #endif 433 434 dsp->active.mode = 0 | 435 (sign ? DSP_MODE_SIGNED : 0) | 436 (channels == 2 ? DSP_MODE_STEREO : 0); 418 dsp->active.mode = 0 419 | (pcm_sample_format_is_signed(format) ? DSP_MODE_SIGNED : 0) 420 | (channels == 2 ? DSP_MODE_STEREO : 0); 437 421 dsp->active.samples = frames * channels; 438 422 dsp->active.frame_count = 0; 439 423 440 sb_dsp_write(dsp, dsp->active.mode); 441 sb_dsp_write(dsp, (dsp->active.samples - 1) & 0xff); 442 sb_dsp_write(dsp, (dsp->active.samples - 1) >> 8); 424 sb_dsp_set_sampling_rate(dsp, sampling_rate); 425 426 #ifdef AUTO_DMA_MODE 427 sb_dsp_start_active(dsp, AUTO_DMA_16B_AD_FIFO); 428 #else 429 sb_dsp_start_active(dsp, SINGLE_DMA_16B_AD); 430 #endif 443 431 444 432 ddf_log_verbose("Recording started started, interrupt every %u samples "
Note:
See TracChangeset
for help on using the changeset viewer.