Changeset a3ab774 in mainline
- Timestamp:
- 2012-07-07T21:26:04Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e1b7e36
- Parents:
- ef246b9
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dsp.c
ref246b9 ra3ab774 196 196 } 197 197 #ifndef AUTO_DMA_MODE 198 sb_dsp_write(dsp, SINGLE_DMA_16B_DA); 199 sb_dsp_write(dsp, dsp->playing.mode); 200 sb_dsp_write(dsp, (dsp->playing.samples - 1) & 0xff); 201 sb_dsp_write(dsp, (dsp->playing.samples - 1) >> 8); 198 if (dsp->active.playing) 199 sb_dsp_write(dsp, SINGLE_DMA_16B_DA); 200 else 201 sb_dsp_write(dsp, SINGLE_DMA_16B_AD); 202 203 sb_dsp_write(dsp, dsp->active.mode); 204 sb_dsp_write(dsp, (dsp->active.samples - 1) & 0xff); 205 sb_dsp_write(dsp, (dsp->active.samples - 1) >> 8); 202 206 #endif 203 207 } … … 271 275 272 276 /* Check supported parameters */ 273 ddf_log_debug("Requested playbackon buffer \"%u\" (%u parts): %uHz, "277 ddf_log_debug("Requested recording on buffer \"%u\" (%u parts): %uHz, " 274 278 "%ssinged %u bit, %u channel(s).", id, parts, sampling_rate, 275 279 sign ? "" : "un", sample_size, channels); … … 300 304 #endif 301 305 302 dsp-> playing.mode = 0 |306 dsp->active.mode = 0 | 303 307 (sign ? DSP_MODE_SIGNED : 0) | (channels == 2 ? DSP_MODE_STEREO : 0); 304 sb_dsp_write(dsp, dsp-> playing.mode);305 306 dsp-> playing.samples = sample_count(sample_size, play_block_size);307 sb_dsp_write(dsp, (dsp-> playing.samples - 1) & 0xff);308 sb_dsp_write(dsp, (dsp-> playing.samples - 1) >> 8);308 sb_dsp_write(dsp, dsp->active.mode); 309 310 dsp->active.samples = sample_count(sample_size, play_block_size); 311 sb_dsp_write(dsp, (dsp->active.samples - 1) & 0xff); 312 sb_dsp_write(dsp, (dsp->active.samples - 1) >> 8); 309 313 310 314 ddf_log_verbose("Playback started, interrupt every %u samples " 311 "(~1/%u sec)", dsp->playing.samples, 312 sampling_rate / dsp->playing.samples); 315 "(~1/%u sec)", dsp->active.samples, 316 sampling_rate / dsp->active.samples); 317 318 dsp->active.playing = true; 313 319 314 320 return EOK; … … 325 331 } 326 332 327 int sb_dsp_start_record(sb_dsp_t *dsp, unsigned id, unsigned sample_rate, 328 unsigned sample_size, unsigned channels, bool sign) 329 { 330 return ENOTSUP; 333 int sb_dsp_start_record(sb_dsp_t *dsp, unsigned id, unsigned parts, 334 unsigned sampling_rate, unsigned sample_size, unsigned channels, bool sign) 335 { 336 assert(dsp); 337 338 if (!dsp->event_session) 339 return EINVAL; 340 341 /* Play block size must be even number (we use DMA 16)*/ 342 if (dsp->buffer.size % (parts * 2)) 343 return EINVAL; 344 345 const unsigned play_block_size = dsp->buffer.size / parts; 346 347 /* Check supported parameters */ 348 ddf_log_debug("Requested playback on buffer \"%u\" (%u parts): %uHz, " 349 "%ssinged %u bit, %u channel(s).", id, parts, sampling_rate, 350 sign ? "" : "un", sample_size, channels); 351 if (id != BUFFER_ID) 352 return ENOENT; 353 if (sample_size != 16) // FIXME We only support 16 bit playback 354 return ENOTSUP; 355 if (channels != 1 && channels != 2) 356 return ENOTSUP; 357 if (sampling_rate > 44100) 358 return ENOTSUP; 359 360 dsp->event_exchange = async_exchange_begin(dsp->event_session); 361 if (!dsp->event_exchange) 362 return ENOMEM; 363 364 sb_dsp_write(dsp, SET_SAMPLING_RATE_OUTPUT); 365 sb_dsp_write(dsp, sampling_rate >> 8); 366 sb_dsp_write(dsp, sampling_rate & 0xff); 367 368 ddf_log_verbose("Sampling rate: %hhx:%hhx.", 369 sampling_rate >> 8, sampling_rate & 0xff); 370 371 #ifdef AUTO_DMA_MODE 372 sb_dsp_write(dsp, AUTO_DMA_16B_AD_FIFO); 373 #else 374 sb_dsp_write(dsp, SINGLE_DMA_16B_AD_FIFO); 375 #endif 376 377 dsp->active.mode = 0 | 378 (sign ? DSP_MODE_SIGNED : 0) | (channels == 2 ? DSP_MODE_STEREO : 0); 379 sb_dsp_write(dsp, dsp->active.mode); 380 381 dsp->active.samples = sample_count(sample_size, play_block_size); 382 sb_dsp_write(dsp, (dsp->active.samples - 1) & 0xff); 383 sb_dsp_write(dsp, (dsp->active.samples - 1) >> 8); 384 385 ddf_log_verbose("Recording started started, interrupt every %u samples " 386 "(~1/%u sec)", dsp->active.samples, 387 sampling_rate / dsp->active.samples); 388 dsp->active.playing = false; 389 390 return EOK; 331 391 } 332 392 333 393 int sb_dsp_stop_record(sb_dsp_t *dsp, unsigned id) 334 394 { 335 return ENOTSUP; 395 assert(dsp); 396 if (id != BUFFER_ID) 397 return ENOENT; 398 async_exchange_end(dsp->event_exchange); 399 sb_dsp_write(dsp, DMA_16B_EXIT); 400 return EOK; 336 401 } 337 402 /** -
uspace/drv/audio/sb16/dsp.h
ref246b9 ra3ab774 56 56 uint8_t mode; 57 57 uint16_t samples; 58 } playing; 58 bool playing; 59 } active; 59 60 async_sess_t *event_session; 60 61 async_exch_t *event_exchange; … … 72 73 unsigned sample_rate, unsigned sample_size, unsigned channels, bool sign); 73 74 int sb_dsp_stop_playback(sb_dsp_t *dsp, unsigned id); 74 int sb_dsp_start_record(sb_dsp_t *dsp, unsigned id, unsigned sample_rate,75 unsigned sample_ size, unsigned channels, bool sign);75 int sb_dsp_start_record(sb_dsp_t *dsp, unsigned id, unsigned parts, 76 unsigned sample_rate, unsigned sample_size, unsigned channels, bool sign); 76 77 int sb_dsp_stop_record(sb_dsp_t *dsp, unsigned id); 77 78 -
uspace/drv/audio/sb16/pcm_iface.c
ref246b9 ra3ab774 88 88 } 89 89 90 static int sb_start_record(ddf_fun_t *fun, unsigned id, 90 static int sb_start_record(ddf_fun_t *fun, unsigned id, unsigned parts, 91 91 unsigned sample_rate, unsigned sample_size, unsigned channels, bool sign) 92 92 { … … 95 95 sb_dsp_t *dsp = fun->driver_data; 96 96 return sb_dsp_start_record( 97 dsp, id, sample_rate, sample_size, channels, sign);97 dsp, id, parts, sample_rate, sample_size, channels, sign); 98 98 } 99 99 -
uspace/lib/drv/generic/remote_audio_pcm_buffer.c
ref246b9 ra3ab774 140 140 141 141 int audio_pcm_buffer_start_record(async_exch_t *exch, unsigned id, 142 unsigned sample_rate, unsigned sample_size, unsigned channels, bool sign) 143 { 144 if (!exch || sample_size > UINT16_MAX || channels > (UINT16_MAX >> 1)) 145 return EINVAL; 146 sysarg_t packed = sample_size << 16 | channels << 1 | sign ? 1 : 0; 142 unsigned parts, unsigned sample_rate, uint16_t sample_size, 143 uint8_t channels, bool sign) 144 { 145 if (!exch) 146 return EINVAL; 147 sysarg_t packed = 148 (sample_size << 16) | (channels << 8) | 149 ((parts & 0x7f) << 1) | (sign ? 1 : 0); 147 150 return async_req_4_0(exch, DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE), 148 151 IPC_M_AUDIO_PCM_START_RECORD, id, sample_rate, packed); … … 336 339 const unsigned rate = DEV_IPC_GET_ARG2(*call); 337 340 const unsigned size = DEV_IPC_GET_ARG3(*call) >> 16; 338 const unsigned channels = (DEV_IPC_GET_ARG3(*call) & UINT16_MAX) >> 1; 341 const unsigned channels = (DEV_IPC_GET_ARG3(*call) >> 8) & UINT8_MAX; 342 const unsigned parts = (DEV_IPC_GET_ARG3(*call) >> 1) & 0x7f; 339 343 const bool sign = (bool)(DEV_IPC_GET_ARG3(*call) & 1); 340 344 341 345 const int ret = pcm_iface->start_record 342 ? pcm_iface->start_record(fun, id, rate, size, channels, sign)346 ? pcm_iface->start_record(fun, id, parts, rate, size, channels, sign) 343 347 : ENOTSUP; 344 348 async_answer_0(callid, ret); -
uspace/lib/drv/include/audio_pcm_buffer_iface.h
ref246b9 ra3ab774 51 51 int audio_pcm_buffer_stop_playback(async_exch_t *, unsigned); 52 52 53 int audio_pcm_buffer_start_record(async_exch_t *, unsigned, 54 unsigned, u nsigned, unsigned, bool);53 int audio_pcm_buffer_start_record(async_exch_t *, unsigned, unsigned, 54 unsigned, uint16_t, uint8_t, bool); 55 55 int audio_pcm_buffer_stop_record(async_exch_t *, unsigned); 56 56 … … 64 64 unsigned, unsigned, unsigned, bool); 65 65 int (*stop_playback)(ddf_fun_t *, unsigned); 66 int (*start_record)(ddf_fun_t *, unsigned, 66 int (*start_record)(ddf_fun_t *, unsigned, unsigned, 67 67 unsigned, unsigned, unsigned, bool); 68 68 int (*stop_record)(ddf_fun_t *, unsigned);
Note:
See TracChangeset
for help on using the changeset viewer.