Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/isa - Unmuting an external input source (CD playback...
details: https://anonhg.NetBSD.org/src/rev/ce8dbf8e4854
branches: trunk
changeset: 479920:ce8dbf8e4854
user: itohy <itohy%NetBSD.org@localhost>
date: Mon Dec 27 03:21:56 1999 +0000
description:
- Unmuting an external input source (CD playback, line input, and speaker)
now prevents power down/save the device.
The external input sources are muted by default at initialization.
- Change "power.power.*" to "power.save.*". Sorry, spec change....
- Shorten tsleep(9) ident string for "ps l".
diffstat:
sys/dev/isa/ym.c | 50 ++++++++++++++++++++++++++++++++++++++++++++------
sys/dev/isa/ymvar.h | 20 +++++++++++++++++---
2 files changed, 61 insertions(+), 9 deletions(-)
diffs (168 lines):
diff -r ea2656a491d7 -r ce8dbf8e4854 sys/dev/isa/ym.c
--- a/sys/dev/isa/ym.c Mon Dec 27 01:56:18 1999 +0000
+++ b/sys/dev/isa/ym.c Mon Dec 27 03:21:56 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ym.c,v 1.12 1999/10/07 08:16:51 itohy Exp $ */
+/* $NetBSD: ym.c,v 1.13 1999/12/27 03:21:56 itohy Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -232,6 +232,17 @@
ad1848_set_channel_gain(ac, AD1848_DAC_CHANNEL, &vol_dac);
ad1848_set_channel_gain(ac, AD1848_AUX2_CHANNEL, &vol_opl3);
+ /*
+ * Mute all external sources. If you change this, you must
+ * also change the initial value of sc->sc_external_sources
+ * (currently 0 --- no external source is active).
+ */
+ ad1848_mute_channel(ac, AD1848_AUX1_CHANNEL, MUTE_ALL); /* CD */
+ ad1848_mute_channel(ac, AD1848_LINE_CHANNEL, MUTE_ALL); /* line */
+ ac->mute[AD1848_AUX1_CHANNEL] = MUTE_ALL;
+ ac->mute[AD1848_LINE_CHANNEL] = MUTE_ALL;
+ /* speaker is muted by default */
+
sc->sc_version = ym_read(sc, SA3_MISC) & SA3_MISC_VER;
/* We use only one IRQ (IRQ-A). */
@@ -489,6 +500,7 @@
struct ym_softc *sc = ac->parent;
struct ad1848_volume vol;
int error = 0;
+ u_int8_t extsources;
DPRINTF(("%s: ym_mixer_set_port: dev 0x%x, type 0x%x, 0x%x (%d; %d, %d)\n",
DVNAME(sc), cp->dev, cp->type, cp->un.ord,
@@ -555,6 +567,32 @@
goto out;
/*
+ * Needs power-up to hear external sources.
+ */
+ case YM_CD_MUTE:
+ case YM_LINE_MUTE:
+ case YM_SPEAKER_MUTE:
+ extsources = YM_MIXER_TO_XS(cp->dev);
+ if (cp->un.ord) {
+ if ((sc->sc_external_sources &= ~extsources) == 0) {
+ /*
+ * All the external sources are muted
+ * --- no need to keep the chip on.
+ */
+ ym_power_ctl(sc, YM_POWER_EXT_SRC, 0);
+ DPRINTF(("%s: ym_mixer_set_port: off for ext\n",
+ DVNAME(sc)));
+ }
+ } else {
+ /* mute off - power-up the chip */
+ sc->sc_external_sources |= extsources;
+ ym_power_ctl(sc, YM_POWER_EXT_SRC, 1);
+ DPRINTF(("%s: ym_mixer_set_port: on for ext\n",
+ DVNAME(sc)));
+ }
+ break; /* fall to ad1848_mixer_set_port() */
+
+ /*
* Power on/off the playback part for monitoring.
*/
case YM_MONITOR_MUTE:
@@ -838,7 +876,7 @@
dip->type = AUDIO_MIXER_ENUM;
dip->mixer_class = YM_PWR_CLASS;
dip->next = YM_PWR_TIMEOUT;
- strcpy(dip->label.name, AudioNpower);
+ strcpy(dip->label.name, AudioNsave);
dip->un.e.num_mem = 3;
strcpy(dip->un.e.member[0].label.name, AudioNpowerdown);
dip->un.e.member[0].ord = YM_POWER_POWERDOWN;
@@ -1116,7 +1154,7 @@
if (nosleep)
delay(100000);
else
- tsleep(&wchan, PWAIT, "ym_pwu1", hz / 10);
+ tsleep(&wchan, PWAIT, "ym_pu1", hz / 10);
pw &= ~(SA3_PWR_MNG_PSV | SA3_PWR_MNG_PDN);
ym_write(sc, SA3_PWR_MNG, pw);
@@ -1125,7 +1163,7 @@
if (nosleep)
delay(70000);
else
- tsleep(&wchan, PWAIT, "ym_pwu2", hz / 14);
+ tsleep(&wchan, PWAIT, "ym_pu2", hz / 14);
/* The chip is muted automatically --- unmute it now. */
ym_mute(sc, SA3_VOL_L, sc->master_mute);
@@ -1162,8 +1200,8 @@
parts |= YM_POWER_CODEC_P;
if ((on_blocks & YM_POWER_CODEC_R) == 0)
parts |= YM_POWER_CODEC_R;
- parts &= ~YM_POWER_CODEC_CTL;
}
+ parts &= ~YM_POWER_CODEC_PSEUDO;
/* If CODEC is being off, save the state. */
if ((sc->sc_on_blocks & YM_POWER_CODEC_DIGITAL) &&
@@ -1207,7 +1245,7 @@
while (sc->sc_in_power_ctl & YM_POWER_CTL_INUSE) {
sc->sc_in_power_ctl |= YM_POWER_CTL_WANTED;
DPRINTF(("%s: ym_power_ctl: sleeping\n", DVNAME(sc)));
- tsleep(&sc->sc_in_power_ctl, PWAIT, "ym_pwc", 0);
+ tsleep(&sc->sc_in_power_ctl, PWAIT, "ym_pc", 0);
DPRINTF(("%s: ym_power_ctl: awaken\n", DVNAME(sc)));
}
sc->sc_in_power_ctl |= YM_POWER_CTL_INUSE;
diff -r ea2656a491d7 -r ce8dbf8e4854 sys/dev/isa/ymvar.h
--- a/sys/dev/isa/ymvar.h Mon Dec 27 01:56:18 1999 +0000
+++ b/sys/dev/isa/ymvar.h Mon Dec 27 03:21:56 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ymvar.h,v 1.4 1999/10/05 03:46:08 itohy Exp $ */
+/* $NetBSD: ymvar.h,v 1.5 1999/12/27 03:21:56 itohy Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
#ifndef AUDIO_NO_POWER_CTL
#define AudioCpower "power"
-#define AudioNpower "power"
+#define AudioNsave "save"
#define AudioNtimeout "timeout"
#define AudioNpowerdown "powerdown"
#define AudioNpowersave "powersave"
@@ -159,6 +159,8 @@
struct ad1848_volume master_gain;
u_int8_t mic_gain;
+ u_int8_t sc_external_sources; /* non-zero value prevents power down */
+
u_int8_t sc_version; /* hardware version */
/* 3D encehamcement */
@@ -207,13 +209,25 @@
#define YM_POWER_CODEC_AD (SA3_APWRDWN_AD << 8)
#define YM_POWER_OPL3_DA (SA3_APWRDWN_FMDAC << 8)
/* pseudo */
-#define YM_POWER_CODEC_CTL 0x8000
+#define YM_POWER_CODEC_CTL 0x4000
+#define YM_POWER_EXT_SRC 0x8000
+#define YM_POWER_CODEC_PSEUDO (YM_POWER_CODEC_CTL | YM_POWER_EXT_SRC)
#define YM_POWER_CODEC_DIGITAL \
(YM_POWER_CODEC_P | YM_POWER_CODEC_R | YM_POWER_CODEC_CTL)
/* 3D enhance is passive */
#define YM_POWER_ACTIVE (0xffff & ~YM_POWER_3D)
+/* external input sources */
+#define YM_XS_CD 1
+#define YM_XS_LINE 2
+#define YM_XS_SPEAKER 4
+
+#if YM_CD_MUTE + 1 != YM_LINE_MUTE || YM_CD_MUTE + 2 != YM_SPEAKER_MUTE
+ #error YM_CD_MUTE, YM_LINE_MUTE and YM_SPEAKER_MUTE should be contiguous
+#endif
+#define YM_MIXER_TO_XS(m) (1 << ((m) - YM_CD_MUTE))
+
#ifdef _KERNEL
void ym_power_ctl __P((struct ym_softc *, int, int));
#endif
Home |
Main Index |
Thread Index |
Old Index