Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Oops, we do have to check ourselves whether a gi...
details: https://anonhg.NetBSD.org/src/rev/b6a3684347f5
branches: trunk
changeset: 476644:b6a3684347f5
user: kleink <kleink%NetBSD.org@localhost>
date: Thu Sep 23 11:46:12 1999 +0000
description:
Oops, we do have to check ourselves whether a given value is valid within an
enumeration.
diffstat:
sys/dev/pci/eso.c | 56 ++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 45 insertions(+), 11 deletions(-)
diffs (89 lines):
diff -r 59f25a981ef6 -r b6a3684347f5 sys/dev/pci/eso.c
--- a/sys/dev/pci/eso.c Thu Sep 23 11:04:29 1999 +0000
+++ b/sys/dev/pci/eso.c Thu Sep 23 11:46:12 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: eso.c,v 1.6 1999/09/02 17:26:15 kleink Exp $ */
+/* $NetBSD: eso.c,v 1.7 1999/09/23 11:46:12 kleink Exp $ */
/*
* Copyright (c) 1999 Klaus J. Klein
@@ -166,6 +166,7 @@
static uint8_t eso_read_rdr __P((struct eso_softc *));
static int eso_reset __P((struct eso_softc *));
static void eso_set_gain __P((struct eso_softc *, unsigned int));
+static int eso_set_monooutsrc __P((struct eso_softc *, unsigned int));
static int eso_set_recsrc __P((struct eso_softc *, unsigned int));
static void eso_write_cmd __P((struct eso_softc *, uint8_t));
static void eso_write_ctlreg __P((struct eso_softc *, uint8_t, uint8_t));
@@ -1000,13 +1001,7 @@
if (cp->type != AUDIO_MIXER_ENUM)
return (EINVAL);
- sc->sc_monooutsrc = cp->un.ord;
-
- tmp = eso_read_mixreg(sc, ESO_MIXREG_MPM);
- tmp &= ~ESO_MIXREG_MPM_MOMASK;
- tmp |= sc->sc_monooutsrc;
- eso_write_mixreg(sc, ESO_MIXREG_MPM, tmp);
- break;
+ return (eso_set_monooutsrc(sc, cp->un.ord));
case ESO_RECORD_MONITOR:
if (cp->type != AUDIO_MIXER_ENUM)
@@ -1724,14 +1719,53 @@
}
static int
+eso_set_monooutsrc(sc, monooutsrc)
+ struct eso_softc *sc;
+ unsigned int monooutsrc;
+{
+ mixer_devinfo_t di;
+ int i;
+ uint8_t mpm;
+
+ di.index = ESO_MONOOUT_SOURCE;
+ if (eso_query_devinfo(sc, &di) != 0)
+ panic("eso_set_monooutsrc: eso_query_devinfo failed");
+
+ for (i = 0; i < di.un.e.num_mem; i++) {
+ if (monooutsrc == di.un.e.member[i].ord) {
+ mpm = eso_read_mixreg(sc, ESO_MIXREG_MPM);
+ mpm &= ~ESO_MIXREG_MPM_MOMASK;
+ mpm |= monooutsrc;
+ eso_write_mixreg(sc, ESO_MIXREG_MPM, mpm);
+ sc->sc_monooutsrc = monooutsrc;
+ return (0);
+ }
+ }
+
+ return (EINVAL);
+}
+
+static int
eso_set_recsrc(sc, recsrc)
struct eso_softc *sc;
unsigned int recsrc;
{
+ mixer_devinfo_t di;
+ int i;
- eso_write_mixreg(sc, ESO_MIXREG_ERS, recsrc);
- sc->sc_recsrc = recsrc;
- return (0);
+ di.index = ESO_RECORD_SOURCE;
+ if (eso_query_devinfo(sc, &di) != 0)
+ panic("eso_set_recsrc: eso_query_devinfo failed");
+
+ for (i = 0; i < di.un.e.num_mem; i++) {
+ if (recsrc == di.un.e.member[i].ord) {
+ eso_write_mixreg(sc, ESO_MIXREG_ERS, recsrc);
+ sc->sc_recsrc = recsrc;
+ return (0);
+ }
+ }
+
+ return (EINVAL);
}
static void
Home |
Main Index |
Thread Index |
Old Index