Changeset 3bacee1 in mainline for uspace/drv/audio/sb16
- Timestamp:
- 2018-04-12T16:27:17Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3cf22f9
- Parents:
- 76d0981d
- git-author:
- Jiri Svoboda <jiri@…> (2018-04-11 19:25:33)
- git-committer:
- Jiri Svoboda <jiri@…> (2018-04-12 16:27:17)
- Location:
- uspace/drv/audio/sb16
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dsp.c
r76d0981d r3bacee1 63 63 #define AUTO_DMA_MODE 64 64 65 static inline const char * dsp_state_to_str(dsp_state_t state)66 { 67 static const char *state_names[] = {65 static inline const char *dsp_state_to_str(dsp_state_t state) 66 { 67 static const char *state_names[] = { 68 68 [DSP_PLAYBACK_ACTIVE_EVENTS] = "PLAYBACK w/ EVENTS", 69 69 [DSP_CAPTURE_ACTIVE_EVENTS] = "CAPTURE w/ EVENTS", … … 240 240 dsp->active.samples / ((dsp->active.mode & DSP_MODE_STEREO) ? 2 : 1); 241 241 242 switch (dsp->state) 243 { 242 switch (dsp->state) { 244 243 case DSP_PLAYBACK_ACTIVE_EVENTS: 245 244 dsp_report_event(dsp, PCM_EVENT_FRAMES_PLAYED); … … 277 276 { 278 277 ddf_log_verbose("Querying cap %s", audio_pcm_cap_str(cap)); 279 switch (cap) {278 switch (cap) { 280 279 case AUDIO_CAP_CAPTURE: 281 280 case AUDIO_CAP_PLAYBACK: … … 312 311 313 312 errno_t sb_dsp_test_format(sb_dsp_t *dsp, unsigned *channels, unsigned *rate, 314 pcm_sample_format_t *format)313 pcm_sample_format_t *format) 315 314 { 316 315 errno_t ret = EOK; … … 346 345 } 347 346 348 async_sess_t * sb_dsp_get_event_session(sb_dsp_t *dsp)347 async_sess_t *sb_dsp_get_event_session(sb_dsp_t *dsp) 349 348 { 350 349 assert(dsp); … … 416 415 } 417 416 418 dsp->active.mode = 0 419 | (pcm_sample_format_is_signed(format) ? DSP_MODE_SIGNED : 0)420 |(channels == 2 ? DSP_MODE_STEREO : 0);417 dsp->active.mode = 0 | 418 (pcm_sample_format_is_signed(format) ? DSP_MODE_SIGNED : 0) | 419 (channels == 2 ? DSP_MODE_STEREO : 0); 421 420 dsp->active.samples = frames * channels; 422 421 dsp->active.frame_count = 0; … … 446 445 if ((dsp->state == DSP_PLAYBACK_NOEVENTS || 447 446 dsp->state == DSP_PLAYBACK_ACTIVE_EVENTS) && 448 immediate) 449 { 447 immediate) { 450 448 dsp_write(dsp, DMA_16B_PAUSE); 451 449 dsp_reset(dsp); … … 459 457 return EOK; 460 458 } 461 if (dsp->state == DSP_PLAYBACK_ACTIVE_EVENTS) 462 { 459 if (dsp->state == DSP_PLAYBACK_ACTIVE_EVENTS) { 463 460 /* Stop after current fragment */ 464 461 assert(!immediate); … … 494 491 } 495 492 496 dsp->active.mode = 0 497 | (pcm_sample_format_is_signed(format) ? DSP_MODE_SIGNED : 0)498 |(channels == 2 ? DSP_MODE_STEREO : 0);493 dsp->active.mode = 0 | 494 (pcm_sample_format_is_signed(format) ? DSP_MODE_SIGNED : 0) | 495 (channels == 2 ? DSP_MODE_STEREO : 0); 499 496 dsp->active.samples = frames * channels; 500 497 dsp->active.frame_count = 0; … … 522 519 if ((dsp->state == DSP_CAPTURE_NOEVENTS || 523 520 dsp->state == DSP_CAPTURE_ACTIVE_EVENTS) && 524 immediate) 525 { 521 immediate) { 526 522 dsp_write(dsp, DMA_16B_PAUSE); 527 523 dsp_reset(dsp); … … 535 531 return EOK; 536 532 } 537 if (dsp->state == DSP_CAPTURE_ACTIVE_EVENTS) 538 { 533 if (dsp->state == DSP_CAPTURE_ACTIVE_EVENTS) { 539 534 /* Stop after current fragment */ 540 535 assert(!immediate); -
uspace/drv/audio/sb16/main.c
r76d0981d r3bacee1 71 71 int main(int argc, char *argv[]) 72 72 { 73 printf(NAME ": HelenOS SB16 audio driver.\n");73 printf(NAME ": HelenOS SB16 audio driver.\n"); 74 74 ddf_log_init(NAME); 75 75 return ddf_driver_main(&sb_driver); … … 191 191 /* 1x IRQ, 1-2x DMA(8,16), 1-2x IO (MPU is separate). */ 192 192 if (hw_res.irqs.count != 1 || 193 (hw_res.io_ranges.count != 1 && hw_res.io_ranges.count != 2) ||194 (hw_res.dma_channels.count != 1 && hw_res.dma_channels.count != 2)) {193 (hw_res.io_ranges.count != 1 && hw_res.io_ranges.count != 2) || 194 (hw_res.dma_channels.count != 1 && hw_res.dma_channels.count != 2)) { 195 195 hw_res_list_parsed_clean(&hw_res); 196 196 return EINVAL; … … 229 229 } else { 230 230 const int sb = 231 (hw_res.io_ranges.ranges[0].size >= sizeof(sb16_regs_t)) 232 ?0 : 1;231 (hw_res.io_ranges.ranges[0].size >= sizeof(sb16_regs_t)) ? 232 0 : 1; 233 233 const int mpu = 1 - sb; 234 234 if (pp_sb_regs && *pp_sb_regs) -
uspace/drv/audio/sb16/mixer.c
r76d0981d r3bacee1 98 98 [SB_MIXER_UNKNOWN] = { NULL, 0 }, 99 99 [SB_MIXER_CT1335] = { 100 channels_table_ct1335,101 ARRAY_SIZE(channels_table_ct1335),100 channels_table_ct1335, 101 ARRAY_SIZE(channels_table_ct1335), 102 102 }, 103 103 [SB_MIXER_CT1345] = { 104 channels_table_ct1345,105 ARRAY_SIZE(channels_table_ct1345),104 channels_table_ct1345, 105 ARRAY_SIZE(channels_table_ct1345), 106 106 }, 107 107 [SB_MIXER_CT1745] = { 108 channels_table_ct1745,109 ARRAY_SIZE(channels_table_ct1745),108 channels_table_ct1745, 109 ARRAY_SIZE(channels_table_ct1745), 110 110 }, 111 111 }; 112 112 113 const char * sb_mixer_type_str(sb_mixer_type_t type)113 const char *sb_mixer_type_str(sb_mixer_type_t type) 114 114 { 115 115 static const char *names[] = { … … 150 150 151 151 errno_t sb_mixer_get_control_item_info(const sb_mixer_t *mixer, unsigned item, 152 const char **name, unsigned *levels)152 const char **name, unsigned *levels) 153 153 { 154 154 assert(mixer); … … 182 182 const channel_t *chan = &volume_table[mixer->type].table[item]; 183 183 pio_write_8(&mixer->regs->mixer_address, chan->address); 184 *value = (pio_read_8(&mixer->regs->mixer_data) >> chan->shift) 185 &(chan->volume_levels - 1);184 *value = (pio_read_8(&mixer->regs->mixer_data) >> chan->shift) & 185 (chan->volume_levels - 1); 186 186 return EOK; 187 187 }
Note:
See TracChangeset
for help on using the changeset viewer.
