Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci - Enable in-kernel sampling rate conversion for ...
details: https://anonhg.NetBSD.org/src/rev/b8baeaf561dd
branches: trunk
changeset: 537922:b8baeaf561dd
user: kent <kent%NetBSD.org@localhost>
date: Tue Oct 08 13:10:24 2002 +0000
description:
- Enable in-kernel sampling rate conversion for fixed-rate codec
- Remove VRA/VRM enabling in auvia_attach()
- Use ac97_codec_if::set_rate()
- Return no AUDIO_PROPS_MMAP for fixed-rate codec
- Remove unused variables in auvia_softc
diffstat:
sys/dev/pci/auvia.c | 58 +++++++++++++++++++++----------------------------
sys/dev/pci/auviavar.h | 13 ++++------
2 files changed, 30 insertions(+), 41 deletions(-)
diffs (159 lines):
diff -r f1ac95d6bc6b -r b8baeaf561dd sys/dev/pci/auvia.c
--- a/sys/dev/pci/auvia.c Tue Oct 08 13:09:18 2002 +0000
+++ b/sys/dev/pci/auvia.c Tue Oct 08 13:10:24 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auvia.c,v 1.25 2002/10/07 16:28:24 kent Exp $ */
+/* $NetBSD: auvia.c,v 1.26 2002/10/08 13:10:24 kent Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvia.c,v 1.25 2002/10/07 16:28:24 kent Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvia.c,v 1.26 2002/10/08 13:10:24 kent Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -86,9 +86,6 @@
#define AUVIA_DMAOP_COUNT(x) ((x)&0x00FFFFFF)
};
-/* rev. H and later seem to support only fixed rate 48 kHz */
-#define AUVIA_FIXED_RATE 48000
-
int auvia_match(struct device *, struct cfdata *, void *);
void auvia_attach(struct device *, struct device *, void *);
int auvia_open(void *, int);
@@ -237,7 +234,6 @@
pci_intr_handle_t ih;
bus_size_t iosize;
pcireg_t pr;
- u_int16_t v;
int r, i;
if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_VIATECH_VT8233_AC97)
@@ -323,22 +319,6 @@
return;
}
- /*
- * Print a warning if the codec doesn't support hardware variable
- * rate audio.
- */
- if (auvia_read_codec(sc, AC97_REG_EXT_AUDIO_ID, &v)
- || !(v & AC97_EXT_AUDIO_VRA)) {
- printf("%s: warning: codec doesn't support hardware AC'97 2.0 Variable Rate Audio\n",
- sc->sc_dev.dv_xname);
- sc->sc_fixed_rate = AUVIA_FIXED_RATE; /* XXX wrong value */
- } else {
- /* enable VRA */
- auvia_write_codec(sc, AC97_REG_EXT_AUDIO_CTRL,
- AC97_EXT_AUDIO_VRA | AC97_EXT_AUDIO_VRM);
- sc->sc_fixed_rate = 0;
- }
-
/* disable mutes */
for (i = 0; i < 4; i++) {
static struct {
@@ -589,8 +569,8 @@
base + VIA8233_RP_RATEFMT) & ~(VIA8233_RATEFMT_48K
| VIA8233_RATEFMT_STEREO | VIA8233_RATEFMT_16BIT);
- v |= VIA8233_RATEFMT_48K *
- (p->sample_rate / 20) / (48000 / 20);
+ v |= VIA8233_RATEFMT_48K * (p->sample_rate / 20)
+ / (48000 / 20);
if (p->channels == 2)
v |= VIA8233_RATEFMT_STEREO;
@@ -609,12 +589,14 @@
reg = mode == AUMODE_PLAY ?
AC97_REG_PCM_FRONT_DAC_RATE : AC97_REG_PCM_LR_ADC_RATE;
- if (!sc->sc_fixed_rate) {
- auvia_write_codec(sc, reg, (u_int16_t) p->sample_rate);
- auvia_read_codec(sc, reg, ®val);
- p->sample_rate = regval;
- } else
- p->sample_rate = sc->sc_fixed_rate;
+ if (IS_FIXED_RATE(sc->codec_if)) {
+ /* Enable aurateconv */
+ p->hw_sample_rate = AC97_SINGLE_RATE;
+ } else {
+ if (sc->codec_if->vtbl->set_rate(sc->codec_if, reg,
+ &p->sample_rate))
+ return (EINVAL);
+ }
p->factor = 1;
p->sw_code = 0;
@@ -714,7 +696,7 @@
if (retp) {
if (sc->sc_flags & AUVIA_FLAGS_VT8233) {
- strncpy(retp->name, "VIA VT8233/VT8235",
+ strncpy(retp->name, "VIA VT8233/8235",
sizeof(retp->name));
} else {
strncpy(retp->name, "VIA VT82C686A",
@@ -866,8 +848,18 @@
int
auvia_get_props(void *addr)
{
- return AUDIO_PROP_MMAP | AUDIO_PROP_INDEPENDENT
- | AUDIO_PROP_FULLDUPLEX;
+ struct auvia_softc *sc = addr;
+ int props;
+
+ props = AUDIO_PROP_INDEPENDENT | AUDIO_PROP_FULLDUPLEX;
+ /*
+ * Even if the codec is fixed-rate, set_param() succeeds for any sample
+ * rate because of aurateconv. Applications can't know what rate the
+ * device can process in the case of mmap().
+ */
+ if (!IS_FIXED_RATE(sc->codec_if))
+ props |= AUDIO_PROP_MMAP;
+ return props;
}
diff -r f1ac95d6bc6b -r b8baeaf561dd sys/dev/pci/auviavar.h
--- a/sys/dev/pci/auviavar.h Tue Oct 08 13:09:18 2002 +0000
+++ b/sys/dev/pci/auviavar.h Tue Oct 08 13:10:24 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auviavar.h,v 1.3 2002/10/05 18:08:30 kent Exp $ */
+/* $NetBSD: auviavar.h,v 1.4 2002/10/08 13:10:24 kent Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -57,10 +57,6 @@
u_int sc_flags;
#define AUVIA_FLAGS_VT8233 0x0001
- u_long sc_fixed_rate; /* if codec doesn't support variable
- * rate audio, set to the fixed rate
- * it uses */
-
void *sc_ih; /* interrupt handle */
pci_chipset_tag_t sc_pc;
@@ -68,8 +64,6 @@
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
- bus_addr_t sc_ioaddr;
- bus_size_t sc_iosize;
bus_dma_tag_t sc_dmat;
struct ac97_host_if host_if;
@@ -80,4 +74,7 @@
struct auvia_softc_chan sc_play, sc_record;
};
-#endif
+#define IS_FIXED_RATE(codec) !((codec)->vtbl->get_extcaps(codec) \
+ & AC97_EXT_AUDIO_VRA)
+
+#endif /* !_DEV_PCI_AUVIAVAR_H_ */
Home |
Main Index |
Thread Index |
Old Index