diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2008-10-25 22:30:44 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2008-10-25 22:30:44 +0000 |
commit | fe8114f730e5473eba5ee55c81c541e29edbeea8 (patch) | |
tree | 545de71dde8d0a2e03bc8556eeaa4beb581824dd /sys/dev/pci/cs4280.c | |
parent | d54880b2f6a9ada7238d4417b82adb8ce1f2ae77 (diff) |
audio(9) says low level drivers are allowed to change the requested
values of the audio_params structure during AUDIO_SETINFO if the
hardware cannot be set to exactly the requested mode.
some drivers do this sometimes. others always return EINVAL if there
isn't an exact match.
be more consistent. only return EINVAL if an absurd parameter was
requested, otherwise return a supported set of parameters, as close
as possible to what was requested.
with/ok ratchov@
Diffstat (limited to 'sys/dev/pci/cs4280.c')
-rw-r--r-- | sys/dev/pci/cs4280.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/sys/dev/pci/cs4280.c b/sys/dev/pci/cs4280.c index 29d9ce9d995..a17ccf3d66a 100644 --- a/sys/dev/pci/cs4280.c +++ b/sys/dev/pci/cs4280.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cs4280.c,v 1.31 2008/05/29 02:10:01 jakemsr Exp $ */ +/* $OpenBSD: cs4280.c,v 1.32 2008/10/25 22:30:43 jakemsr Exp $ */ /* $NetBSD: cs4280.c,v 1.5 2000/06/26 04:56:23 simonb Exp $ */ /* @@ -1117,37 +1117,33 @@ cs4280_set_params(addr, setmode, usemode, play, rec) if ((setmode & mode) == 0) continue; - p = mode == AUMODE_PLAY ? play : rec; - + p = mode == AUMODE_PLAY ? play : rec; if (p == play) { DPRINTFN(5,("play: sample=%ld precision=%d channels=%d\n", p->sample_rate, p->precision, p->channels)); - /* play back data format may be 8- or 16-bit and - * either stereo or mono. - * playback rate may range from 8000Hz to 48000Hz - */ - if (p->sample_rate < 8000 || p->sample_rate > 48000 || - (p->precision != 8 && p->precision != 16) || - (p->channels != 1 && p->channels != 2) ) { - return (EINVAL); - } } else { DPRINTFN(5,("rec: sample=%ld precision=%d channels=%d\n", p->sample_rate, p->precision, p->channels)); - /* capture data format must be 16bit stereo - * and sample rate range from 11025Hz to 48000Hz. - * - * XXX: it looks like to work with 8000Hz, - * although data sheets say lower limit is - * 11025 Hz. - */ - - if (p->sample_rate < 8000 || p->sample_rate > 48000 || - (p->precision != 8 && p->precision != 16) || - (p->channels != 1 && p->channels != 2) ) { - return (EINVAL); - } } + /* play back data format may be 8- or 16-bit and + * either stereo or mono. + * playback rate may range from 8000Hz to 48000Hz + * + * capture data format must be 16bit stereo + * and sample rate range from 11025Hz to 48000Hz. + * + * XXX: it looks like to work with 8000Hz, + * although data sheets say lower limit is + * 11025 Hz. + */ + if (p->sample_rate < 8000) + p->sample_rate = 8000; + if (p->sample_rate > 48000) + p->sample_rate = 48000; + if (p->precision > 16) + p->precision = 16; + if (p->channels > 2) + p->channels = 2; p->factor = 1; p->sw_code = 0; |