From 9a2e7a541105c6f5153d6d544b20ad076cfef7fe Mon Sep 17 00:00:00 2001 From: naddy Date: Thu, 18 Jun 2015 20:02:57 +0000 Subject: [PATCH] For unsupported sample formats, don't return EINVAL but set the closest available format. ok ratchov@ --- sys/dev/pci/cmpci.c | 22 +++++++--------------- 1 file 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; -- 2.20.1