diff options
author | Christian Weisgerber <naddy@cvs.openbsd.org> | 2015-06-18 20:02:58 +0000 |
---|---|---|
committer | Christian Weisgerber <naddy@cvs.openbsd.org> | 2015-06-18 20:02:58 +0000 |
commit | f9cc0f3615b349dbdc3914856c2bedf5c5a5c63b (patch) | |
tree | 93546b45fb67a1eb52907feb981ab868f1388f81 /sys/dev | |
parent | 42c251cf3fcb526dbbd4c92bfa7bbe75288a150b (diff) |
For unsupported sample formats, don't return EINVAL but set the closest
available format. ok ratchov@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/cmpci.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/sys/dev/pci/cmpci.c b/sys/dev/pci/cmpci.c index d4e4d9940ad..c66a12803bb 100644 --- a/sys/dev/pci/cmpci.c +++ b/sys/dev/pci/cmpci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmpci.c,v 1.39 2015/05/11 06:46:21 ratchov Exp $ */ +/* $OpenBSD: cmpci.c,v 1.40 2015/06/18 20:02:57 naddy Exp $ */ /* $NetBSD: cmpci.c,v 1.25 2004/10/26 06:32:20 xtraeme Exp $ */ /* @@ -736,8 +736,6 @@ cmpci_set_params(void *handle, int setmode, int usemode, CMPCI_REG_CHB3D8C); /* format */ - if (p->precision > 16) - p->precision = 16; switch (p->channels) { case 1: md_format = CMPCI_REG_FORMAT_MONO; @@ -809,20 +807,14 @@ cmpci_set_params(void *handle, int setmode, int usemode, default: return (EINVAL); } - switch (p->encoding) { - case AUDIO_ENCODING_SLINEAR_LE: - if (p->precision != 16) - return (EINVAL); + if (p->precision >= 16) { + p->precision = 16; + p->encoding = AUDIO_ENCODING_SLINEAR_LE; md_format |= CMPCI_REG_FORMAT_16BIT; - break; - case AUDIO_ENCODING_ULINEAR_LE: - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision != 8) - return (EINVAL); + } else { + p->precision = 8; + p->encoding = AUDIO_ENCODING_ULINEAR_LE; md_format |= CMPCI_REG_FORMAT_8BIT; - break; - default: - return (EINVAL); } p->bps = AUDIO_BPS(p->precision); p->msb = 1; |