summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTodd T. Fries <todd@cvs.openbsd.org>2008-10-30 06:12:48 +0000
committerTodd T. Fries <todd@cvs.openbsd.org>2008-10-30 06:12:48 +0000
commita2d593803c75c3ad83adacec01aabd09dc5b5270 (patch)
treecd8cd1dfbc611e1020bb992cfa5ad7f05f2ad822 /sys
parent73d0889b74fdfbc00782b23936cf695ada8cfb0c (diff)
patches for macppc to remove more EINVAL returns in the audio code
tested by me, from ratchov@, please commit ratchov@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/macppc/dev/awacs.c58
-rw-r--r--sys/arch/macppc/dev/i2s.c18
2 files changed, 40 insertions, 36 deletions
diff --git a/sys/arch/macppc/dev/awacs.c b/sys/arch/macppc/dev/awacs.c
index 86b49f5b395..6f6a8215bb0 100644
--- a/sys/arch/macppc/dev/awacs.c
+++ b/sys/arch/macppc/dev/awacs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: awacs.c,v 1.22 2008/04/21 00:32:42 jakemsr Exp $ */
+/* $OpenBSD: awacs.c,v 1.23 2008/10/30 06:12:47 todd Exp $ */
/* $NetBSD: awacs.c,v 1.4 2001/02/26 21:07:51 wiz Exp $ */
/*-
@@ -582,11 +582,15 @@ awacs_set_params(void *h, int setmode, int usemode, struct audio_params *play,
p = mode == AUMODE_PLAY ? play : rec;
- if (p->sample_rate < 4000 || p->sample_rate > 50000 ||
- (p->precision != 8 && p->precision != 16) ||
- (p->channels != 1 && p->channels != 2))
- return EINVAL;
-
+ if (p->sample_rate < 4000)
+ p->sample_rate = 4000;
+ if (p->sample_rate > 50000)
+ p->sample_rate = 50000;
+ if (p->precision > 16)
+ p->precision = 16;
+ if (p->channels > 2)
+ p->channels = 2;
+
p->factor = 1;
p->sw_code = NULL;
awacs_write_reg(sc, AWACS_BYTE_SWAP, 0);
@@ -594,47 +598,43 @@ awacs_set_params(void *h, int setmode, int usemode, struct audio_params *play,
switch (p->encoding) {
case AUDIO_ENCODING_SLINEAR_LE:
- if (p->channels == 2 && p->precision == 16) {
+ if (p->percision != 16)
+ p->precision = 16;
+ if (p->channels == 2)
p->sw_code = swap_bytes;
- break;
- }
- if (p->channels == 1 && p->precision == 16) {
+ else {
p->factor = 2;
p->sw_code = swap_bytes_mts;
- break;
}
- return (EINVAL);
+ break;
case AUDIO_ENCODING_SLINEAR_BE:
- if (p->channels == 2 && p->precision == 16)
- break;
- if (p->channels == 1 && p->precision == 16) {
+ if (p->precision != 16)
+ p->precision = 16;
+ if (p->channels == 1) {
p->factor = 2;
p->sw_code = noswap_bytes_mts;
- break;
}
- return (EINVAL);
+ break;
case AUDIO_ENCODING_ULINEAR_LE:
- if (p->channels == 2 && p->precision == 16) {
+ if (p->precision != 16)
+ p->precision = 16;
+ if (p->channels == 2)
p->sw_code = swap_bytes_change_sign16_be;
- break;
- }
- if (p->channels == 1 && p->precision == 16) {
+ else {
p->factor = 2;
p->sw_code = swap_bytes_change_sign16_be_mts;
- break;
}
- return (EINVAL);
+ break;
case AUDIO_ENCODING_ULINEAR_BE:
- if (p->channels == 2 && p->precision == 16) {
+ if (p->precision != 16)
+ p->precision = 16;
+ if (p->channels == 2)
p->sw_code = change_sign16_be;
- break;
- }
- if (p->channels == 1 && p->precision == 16) {
+ else {
p->factor = 2;
p->sw_code = change_sign16_be_mts;
- break;
}
- return (EINVAL);
+ break;
case AUDIO_ENCODING_ULAW:
if (mode == AUMODE_PLAY) {
p->factor = 2;
diff --git a/sys/arch/macppc/dev/i2s.c b/sys/arch/macppc/dev/i2s.c
index d77ea6b7d8b..e7ccfe87aeb 100644
--- a/sys/arch/macppc/dev/i2s.c
+++ b/sys/arch/macppc/dev/i2s.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i2s.c,v 1.14 2008/10/29 03:00:19 deraadt Exp $ */
+/* $OpenBSD: i2s.c,v 1.15 2008/10/30 06:12:47 todd Exp $ */
/* $NetBSD: i2s.c,v 1.1 2003/12/27 02:19:34 grant Exp $ */
/*-
@@ -389,10 +389,14 @@ i2s_set_params(h, setmode, usemode, play, rec)
p = mode == AUMODE_PLAY ? play : rec;
- if (p->sample_rate < 4000 || p->sample_rate > 50000 ||
- (p->precision != 8 && p->precision != 16) ||
- (p->channels != 1 && p->channels != 2))
- return EINVAL;
+ if (p->sample_rate < 4000)
+ p->sample_rate = 4000;
+ if (p->sample_rate > 50000)
+ p->sample_rate = 50000;
+ if (p->precision > 16)
+ p->precision = 16;
+ if (p->channels > 2)
+ p->channels = 2;
switch (p->encoding) {
case AUDIO_ENCODING_SLINEAR_LE:
@@ -868,9 +872,9 @@ i2s_set_rate(sc, rate)
int timo;
/* sanify */
- if (rate > 48000)
+ if (rate > (48000 + 44100) / 2)
rate = 48000;
- else if (rate < 44100)
+ else
rate = 44100;
switch (rate) {