summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2001-10-28 18:58:13 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2001-10-28 18:58:13 +0000
commitb456d5121dcab829b079bf8aba04b55498eb55c7 (patch)
treea6074d9e9fb5eed016917b4022d6bfb213f6c30d
parent7b80bbac2d7be35a49071a59cf720ae77193c1e3 (diff)
it appears that some non-vra compatible codecs implement part
of vra protocol by rounding all rates to 48kHz, but some return 0. fix this by reporting 48kHz for all codecs w/o vra. problem (finally) identified by hunter@dg.net.ua, diff by me. also, while here a/AC97_SOUND_ENHANCEMENT/AC97_CAPS_ENHANCEMENT/ .
-rw-r--r--sys/dev/ic/ac97.c32
-rw-r--r--sys/dev/ic/ac97.h5
2 files changed, 22 insertions, 15 deletions
diff --git a/sys/dev/ic/ac97.c b/sys/dev/ic/ac97.c
index a2ed297db2c..3ca56a8ca73 100644
--- a/sys/dev/ic/ac97.c
+++ b/sys/dev/ic/ac97.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ac97.c,v 1.24 2001/10/24 16:30:05 mickey Exp $ */
+/* $OpenBSD: ac97.c,v 1.25 2001/10/28 18:58:12 mickey Exp $ */
/*
* Copyright (c) 1999, 2000 Constantine Sapuntzakis
@@ -283,6 +283,7 @@ struct ac97_softc {
struct ac97_source_info source_info[2 * SOURCE_INFO_SIZE];
int num_source_info;
enum ac97_host_flags host_flags;
+ u_int16_t caps, ext_id;
u_int16_t shadow_reg[128];
};
@@ -630,7 +631,7 @@ ac97_attach(host_if)
struct ac97_host_if *host_if;
{
struct ac97_softc *as;
- u_int16_t id1, id2, caps;
+ u_int16_t id1, id2;
u_int32_t id;
mixer_ctrl_t ctl;
int error, i;
@@ -661,7 +662,7 @@ ac97_attach(host_if)
ac97_setup_defaults(as);
ac97_read(as, AC97_REG_VENDOR_ID1, &id1);
ac97_read(as, AC97_REG_VENDOR_ID2, &id2);
- ac97_read(as, AC97_REG_RESET, &caps);
+ ac97_read(as, AC97_REG_RESET, &as->caps);
id = (id1 << 16) | id2;
if (id) {
@@ -693,19 +694,21 @@ ac97_attach(host_if)
} else
printf("ac97: codec id not read\n");
- if (caps) {
+ if (as->caps) {
printf("ac97: codec features ");
for (i = 0; i < 10; i++) {
- if (caps & (1 << i))
+ if (as->caps & (1 << i))
printf("%s, ", ac97feature[i]);
}
- printf("%s\n", ac97enhancement[AC97_SOUND_ENHANCEMENT(caps)]);
+ printf("%s\n",
+ ac97enhancement[AC97_CAPS_ENHANCEMENT(as->caps)]);
}
- ac97_read(as, AC97_REG_EXT_AUDIO_ID, &caps);
- if (caps)
- DPRINTF(("ac97: ext id %b\n", caps, AC97_EXT_AUDIO_BITS));
- if (caps & AC97_EXT_AUDIO_VRA)
+ ac97_read(as, AC97_REG_EXT_AUDIO_ID, &as->ext_id);
+ if (as->ext_id)
+ DPRINTF(("ac97: ext id %b\n", as->ext_id,
+ AC97_EXT_AUDIO_BITS));
+ if (as->ext_id & AC97_EXT_AUDIO_VRA)
ac97_write(as, AC97_REG_EXT_AUDIO_CTRL,
AC97_EXT_AUDIO_VRA | AC97_EXT_AUDIO_VRM);
@@ -948,12 +951,15 @@ ac97_set_rate(codec_if, p, mode)
DPRINTFN(5, ("set_rate(%lu) ", p->sample_rate));
+ if (!(as->ext_id & AC97_EXT_AUDIO_VRA)) {
+ p->sample_rate = AC97_SINGLERATE;
+ return (0);
+ }
+
if (p->sample_rate > 0xffff) {
if (mode != AUMODE_PLAY)
return (EINVAL);
- if (ac97_read(as, AC97_REG_EXT_AUDIO_ID, &id))
- return (EIO);
- if (!(id & AC97_EXT_AUDIO_DRA))
+ if (!(as->ext_id & AC97_EXT_AUDIO_DRA))
return (EINVAL);
if (ac97_read(as, AC97_REG_EXT_AUDIO_CTRL, &id))
return (EIO);
diff --git a/sys/dev/ic/ac97.h b/sys/dev/ic/ac97.h
index 96027ec00a9..c3e65687030 100644
--- a/sys/dev/ic/ac97.h
+++ b/sys/dev/ic/ac97.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ac97.h,v 1.8 2001/05/16 23:34:53 mickey Exp $ */
+/* $OpenBSD: ac97.h,v 1.9 2001/10/28 18:58:12 mickey Exp $ */
/*
* Copyright (c) 1999 Constantine Sapuntzakis
@@ -75,7 +75,7 @@ int ac97_attach __P((struct ac97_host_if *));
int ac97_set_rate __P((struct ac97_codec_if *, struct audio_params *, int));
#define AC97_REG_RESET 0x00
-#define AC97_SOUND_ENHANCEMENT(reg) (((reg) >> 10) & 0x1f)
+#define AC97_CAPS_ENHANCEMENT(reg) (((reg) >> 10) & 0x1f)
#define AC97_REG_MASTER_VOLUME 0x02
#define AC97_REG_HEADPHONE_VOLUME 0x04
#define AC97_REG_MASTER_VOLUME_MONO 0x06
@@ -124,6 +124,7 @@ int ac97_set_rate __P((struct ac97_codec_if *, struct audio_params *, int));
#define AC97_EXT_AUDIO_REV_MASK 0x0c00
#define AC97_EXT_AUDIO_ID 0xc000
#define AC97_EXT_AUDIO_BITS "\020\01vra\02dra\03spdif\04vrm\05dsa0\06dsa1\07cdac\010sdac\011ldac\012amap\013rev0\014rev1\017id0\020id1"
+#define AC97_SINGLERATE 48000
#define AC97_REG_FRONT_DAC_RATE 0x2c
#define AC97_REG_SURROUND_DAC_RATE 0x2e
#define AC97_REG_PCM_DAC_RATE 0x30