summaryrefslogtreecommitdiff
path: root/sys/dev/pci/esa.c
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2008-10-25 22:30:44 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2008-10-25 22:30:44 +0000
commitfe8114f730e5473eba5ee55c81c541e29edbeea8 (patch)
tree545de71dde8d0a2e03bc8556eeaa4beb581824dd /sys/dev/pci/esa.c
parentd54880b2f6a9ada7238d4417b82adb8ce1f2ae77 (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/esa.c')
-rw-r--r--sys/dev/pci/esa.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/dev/pci/esa.c b/sys/dev/pci/esa.c
index c549cd9d09b..798aa358a1c 100644
--- a/sys/dev/pci/esa.c
+++ b/sys/dev/pci/esa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: esa.c,v 1.15 2008/05/29 02:10:01 jakemsr Exp $ */
+/* $OpenBSD: esa.c,v 1.16 2008/10/25 22:30:43 jakemsr Exp $ */
/* $NetBSD: esa.c,v 1.12 2002/03/24 14:17:35 jmcneill Exp $ */
/*
@@ -282,11 +282,14 @@ esa_set_params(void *hdl, int setmode, int usemode, struct audio_params *play,
break;
}
- if (p->sample_rate < ESA_MINRATE ||
- p->sample_rate > ESA_MAXRATE ||
- (p->precision != 8 && p->precision != 16) ||
- (p->channels < 1 || p->channels > 2))
- return (EINVAL);
+ if (p->sample_rate < ESA_MINRATE)
+ p->sample_rate = ESA_MINRATE;
+ if (p->sample_rate > ESA_MAXRATE)
+ p->sample_rate = ESA_MAXRATE;
+ if (p->precision > 16)
+ p->precision = 16;
+ if (p->channels > 2)
+ p->channels = 2;
p->factor = 1;
p->sw_code = 0;