Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b7c080c in mainline


Ignore:
Timestamp:
2012-07-15T18:55:48Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial
Children:
a9aae16e
Parents:
63c34d7
Message:

sb16: Implement test_format call.

Location:
uspace/drv/audio/sb16
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/sb16/dsp.c

    r63c34d7 rb7c080c  
    5353
    5454#define DSP_RESET_RESPONSE 0xaa
     55#define DSP_RATE_LIMIT 45000
    5556
    5657#define AUTO_DMA_MODE
     
    223224}
    224225
     226int sb_dsp_test_format(sb_dsp_t *dsp, unsigned *channels, unsigned *rate,
     227  pcm_sample_format_t *format)
     228{
     229        int ret = EOK;
     230        if (*channels == 0 || *channels > 2) {
     231                *channels = 2;
     232                ret = ELIMIT;
     233        }
     234        if (*rate > DSP_RATE_LIMIT) {
     235                *rate = DSP_RATE_LIMIT;
     236                ret = ELIMIT;
     237        }
     238        //TODO 8bit DMA supports 8bit formats
     239        if (*format != PCM_SAMPLE_SINT16_LE && *format != PCM_SAMPLE_UINT16_LE) {
     240                *format = pcm_sample_format_is_signed(*format) ?
     241                    PCM_SAMPLE_SINT16_LE : PCM_SAMPLE_UINT16_LE;
     242                ret = ELIMIT;
     243        }
     244        return ret;
     245}
     246
    225247int sb_dsp_get_buffer(sb_dsp_t *dsp, void **buffer, size_t *size)
    226248{
     
    283305        if (channels != 1 && channels != 2)
    284306                return ENOTSUP;
    285         if (sampling_rate > 44100)
     307        if (sampling_rate > DSP_RATE_LIMIT)
    286308                return ENOTSUP;
    287309        // FIXME We only support 16 bit playback
     
    351373        if (channels != 1 && channels != 2)
    352374                return ENOTSUP;
    353         if (sampling_rate > 44100)
     375        if (sampling_rate > DSP_RATE_LIMIT)
    354376                return ENOTSUP;
    355377        // FIXME We only support 16 bit recording
  • uspace/drv/audio/sb16/dsp.h

    r63c34d7 rb7c080c  
    7373void sb_dsp_interrupt(sb_dsp_t *dsp);
    7474
     75int sb_dsp_test_format(sb_dsp_t *dsp, unsigned *channels, unsigned *rate,
     76  pcm_sample_format_t *format);
    7577int sb_dsp_get_buffer(sb_dsp_t *dsp, void **buffer, size_t *size);
    7678int sb_dsp_set_event_session(sb_dsp_t *dsp, async_sess_t *session);
  • uspace/drv/audio/sb16/pcm_iface.c

    r63c34d7 rb7c080c  
    4646        return EOK;
    4747}
    48 
     48static int sb_test_format(ddf_fun_t *fun, unsigned *channels, unsigned *rate,
     49    pcm_sample_format_t *format)
     50{
     51        assert(fun);
     52        assert(fun->driver_data);
     53        sb_dsp_t *dsp = fun->driver_data;
     54        return sb_dsp_test_format(dsp, channels, rate, format);
     55}
    4956static int sb_get_buffer(ddf_fun_t *fun, void **buffer, size_t *size)
    5057{
     
    108115audio_pcm_iface_t sb_pcm_iface = {
    109116        .get_info_str = sb_get_info_str,
     117        .test_format = sb_test_format,
    110118
    111119        .get_buffer = sb_get_buffer,
Note: See TracChangeset for help on using the changeset viewer.