diff options
author | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-04-03 23:22:43 +0000 |
---|---|---|
committer | Jacob Meuser <jakemsr@cvs.openbsd.org> | 2010-04-03 23:22:43 +0000 |
commit | 8ccbe956b8a4d66f0f2ebfe01c66ead5de71b7e9 (patch) | |
tree | 0291f1461bef1b3cd16daaa29636bfe897ac520f /sys/dev | |
parent | 8f4c75570e0ee9e957f6242d6c732f26bfb59d96 (diff) |
instead of returning EINVAL if an unsupported sample rate was
requested, just use a supported sample rate. makes paramter
negotiation much easier. problem noted and patch tested on
several sb(4) devices by J.C Roberts, thanks.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/isa/sbdsp.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c index a3dce96e779..e2f0176e97b 100644 --- a/sys/dev/isa/sbdsp.c +++ b/sys/dev/isa/sbdsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbdsp.c,v 1.29 2009/07/31 22:53:04 sthen Exp $ */ +/* $OpenBSD: sbdsp.c,v 1.30 2010/04/03 23:22:42 jakemsr Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -562,6 +562,57 @@ sbdsp_set_params(addr, setmode, usemode, play, rec) continue; p = mode == AUMODE_PLAY ? play : rec; + + switch (model) { + case SB_1: + case SB_20: + if (mode == AUMODE_PLAY) { + if (p->sample_rate < 4000) + p->sample_rate = 4000; + else if (p->sample_rate > 22727) + p->sample_rate = 22727; /* 22050 ? */ + } else { + if (p->sample_rate < 4000) + p->sample_rate = 4000; + else if (p->sample_rate > 12987) + p->sample_rate = 12987; + } + break; + case SB_2x: + if (mode == AUMODE_PLAY) { + if (p->sample_rate < 4000) + p->sample_rate = 4000; + else if (p->sample_rate > 45454) + p->sample_rate = 45454; /* 44100 ? */ + } else { + if (p->sample_rate < 4000) + p->sample_rate = 4000; + else if (p->sample_rate > 14925) + p->sample_rate = 14925; /* ??? */ + } + break; + case SB_PRO: + case SB_JAZZ: + if (p->channels == 2) { + if (p->sample_rate < 11025) + p->sample_rate = 11025; + else if (p->sample_rate > 22727) + p->sample_rate = 22727; /* 22050 ? */ + } else { + if (p->sample_rate < 4000) + p->sample_rate = 4000; + else if (p->sample_rate > 45454) + p->sample_rate = 45454; /* 44100 ? */ + } + break; + case SB_16: + if (p->sample_rate < 5000) + p->sample_rate = 5000; + else if (p->sample_rate > 45000) + p->sample_rate = 45000; /* 44100 ? */ + break; + } + /* Locate proper commands */ for(m = mode == AUMODE_PLAY ? sbpmodes : sbrmodes; m->model != -1; m++) { |