Changeset b497018 in mainline for uspace/drv/audio/sb16/dsp.c
- Timestamp:
- 2012-07-15T15:13:34Z (10 years ago)
- Branches:
- lfn, master, serial
- Children:
- 2cc5c835
- Parents:
- 44d1311
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dsp.c
r44d1311 rb497018 46 46 #include "dsp.h" 47 47 48 #define BUFFER_ID 149 48 #define MAX_BUFFER_SIZE (PAGE_SIZE) 50 49 … … 221 220 } 222 221 223 int sb_dsp_get_buffer(sb_dsp_t *dsp, void **buffer, size_t *size , unsigned *id)222 int sb_dsp_get_buffer(sb_dsp_t *dsp, void **buffer, size_t *size) 224 223 { 225 224 assert(dsp); … … 233 232 const int ret = sb_setup_buffer(dsp, *size); 234 233 if (ret == EOK) { 235 ddf_log_debug("Providing buffer (%u): %p, %zu B.",236 BUFFER_ID,dsp->buffer.data, dsp->buffer.size);234 ddf_log_debug("Providing buffer: %p, %zu B.", 235 dsp->buffer.data, dsp->buffer.size); 237 236 238 237 if (buffer) … … 240 239 if (size) 241 240 *size = dsp->buffer.size; 242 if (id)243 *id = BUFFER_ID;244 241 } 245 242 return ret; 246 243 } 247 244 248 int sb_dsp_set_event_session(sb_dsp_t *dsp, unsigned id,async_sess_t *session)245 int sb_dsp_set_event_session(sb_dsp_t *dsp, async_sess_t *session) 249 246 { 250 247 assert(dsp); 251 248 assert(session); 252 if (id != BUFFER_ID)253 return ENOENT;254 249 if (dsp->event_session) 255 250 return EBUSY; … … 259 254 } 260 255 261 int sb_dsp_release_buffer(sb_dsp_t *dsp, unsigned id) 262 { 263 assert(dsp); 264 if (id != BUFFER_ID) 265 return ENOENT; 256 int sb_dsp_release_buffer(sb_dsp_t *dsp) 257 { 258 assert(dsp); 266 259 sb_clear_buffer(dsp); 267 260 async_exchange_end(dsp->event_exchange); … … 274 267 } 275 268 276 int sb_dsp_start_playback(sb_dsp_t *dsp, unsigned id, unsignedparts,269 int sb_dsp_start_playback(sb_dsp_t *dsp, unsigned parts, 277 270 unsigned channels, unsigned sampling_rate, pcm_sample_format_t format) 278 271 { … … 289 282 290 283 /* Check supported parameters */ 291 ddf_log_debug("Requested playback on buffer \"%u\" (%u parts): %uHz, " 292 "%s, %u channel(s).", id, parts, sampling_rate, 293 pcm_sample_format_str(format), channels); 294 if (id != BUFFER_ID) 295 return ENOENT; 284 ddf_log_debug("Requested playback (%u parts): %uHz, %s, %u channel(s).", 285 parts, sampling_rate, pcm_sample_format_str(format), channels); 296 286 if (channels != 1 && channels != 2) 297 287 return ENOTSUP; … … 338 328 } 339 329 340 int sb_dsp_stop_playback(sb_dsp_t *dsp, unsigned id) 341 { 342 assert(dsp); 343 if (id != BUFFER_ID) 344 return ENOENT; 330 int sb_dsp_stop_playback(sb_dsp_t *dsp) 331 { 332 assert(dsp); 345 333 sb_dsp_write(dsp, DMA_16B_EXIT); 346 ddf_log_debug("Stopping playback on buffer %u.", id);334 ddf_log_debug("Stopping playback on buffer."); 347 335 async_msg_0(dsp->event_exchange, PCM_EVENT_PLAYBACK_TERMINATED); 348 336 async_exchange_end(dsp->event_exchange); … … 351 339 } 352 340 353 int sb_dsp_start_record(sb_dsp_t *dsp, unsigned id, unsignedparts,341 int sb_dsp_start_record(sb_dsp_t *dsp, unsigned parts, 354 342 unsigned channels, unsigned sampling_rate, pcm_sample_format_t format) 355 343 { … … 366 354 367 355 /* Check supported parameters */ 368 ddf_log_debug("Requested recording on buffer \"%u\" (%u parts): %uHz, " 369 "%s, %u channel(s).", id, parts, sampling_rate, 370 pcm_sample_format_str(format), channels); 371 if (id != BUFFER_ID) 372 return ENOENT; 356 ddf_log_debug("Requested record (%u parts): %uHz, %s, %u channel(s).", 357 parts, sampling_rate, pcm_sample_format_str(format), channels); 373 358 if (channels != 1 && channels != 2) 374 359 return ENOTSUP; … … 414 399 } 415 400 416 int sb_dsp_stop_record(sb_dsp_t *dsp, unsigned id) 417 { 418 assert(dsp); 419 if (id != BUFFER_ID) 420 return ENOENT; 401 int sb_dsp_stop_record(sb_dsp_t *dsp) 402 { 403 assert(dsp); 421 404 sb_dsp_write(dsp, DMA_16B_EXIT); 422 ddf_log_debug("Stopp ing playback on buffer %u.", id);405 ddf_log_debug("Stopped recording"); 423 406 async_msg_0(dsp->event_exchange, PCM_EVENT_RECORDING_TERMINATED); 424 407 async_exchange_end(dsp->event_exchange);
Note: See TracChangeset
for help on using the changeset viewer.