Changeset b7c080c in mainline for uspace/drv/audio/sb16/dsp.c


Ignore:
Timestamp:
2012-07-15T18:55:48Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a9aae16e
Parents:
63c34d7
Message:

sb16: Implement test_format call.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.