Only five legacy half-duplex hardware drivers require this function to
change between playing and recording:
i386: ess(4), gus(4), pas(4), sb(4)
luna88k: nec86(4)
If defined, it is always called early in audio_open(), so just move the
call from audio(4) to each hardware driver's open() handler.
SPKR_ON/OFF remain defined to leave driver-specific code unchanged.
Further cleanup (unchecked speaker_ctl() return values,
FWRITE -> AUMODE_PLAY -> SPKR_ON dances, etc.) can happen later.
i386/GENERIC.MP builds fine.
Feedback? Objection? OK?
---
share/man/man9/audio.9 | 10 ----------
sys/arch/luna88k/cbus/nec86.c | 1 -
sys/arch/luna88k/cbus/nec86hw.c | 2 ++
sys/dev/audio.c | 8 --------
sys/dev/audio_if.h | 1 -
sys/dev/isa/ess.c | 4 ++--
sys/dev/isa/gus.c | 13 +++----------
sys/dev/isa/gusvar.h | 1 -
sys/dev/isa/pas.c | 1 -
sys/dev/isa/sb.c | 1 -
sys/dev/isa/sbdsp.c | 2 ++
11 files changed, 9 insertions(+), 35 deletions(-)
diff --git a/share/man/man9/audio.9 b/share/man/man9/audio.9
index f03bd74c8b8..50cf1197fa9 100644
--- a/share/man/man9/audio.9
+++ b/share/man/man9/audio.9
@@ -60,10 +60,6 @@ struct audio_hw_if {
int (*halt_output)(void *);
int (*halt_input)(void *);
- int (*speaker_ctl)(void *, int);
-#define SPKR_ON 1
-#define SPKR_OFF 0
-
int (*set_port)(void *, struct mixer_ctrl *);
int (*get_port)(void *, struct mixer_ctrl *);
@@ -275,12 +271,6 @@ This function is called to abort the input transfer
(started by
.Fn start_input )
in progress.
This function returns 0 on success, otherwise an error code.
-.It Ft int Fn (*speaker_ctl) "void *hdl" "int on"
-This function is optional.
-If supplied, it is called when a half duplex device changes between
-playing and recording.
-It can, e.g., be used to turn the speaker on and off.
-This function returns 0 on success, otherwise an error code.
.It Ft int Fn (*set_port) "void *hdl" "struct mixer_ctrl *mc"
This function is called when the
.Dv AUDIO_MIXER_WRITE
diff --git a/sys/arch/luna88k/cbus/nec86.c b/sys/arch/luna88k/cbus/nec86.c
index 49e31c52d46..36d34fa50bf 100644
--- a/sys/arch/luna88k/cbus/nec86.c
+++ b/sys/arch/luna88k/cbus/nec86.c
@@ -79,7 +79,6 @@ const struct audio_hw_if nec86_hw_if = {
.start_input = nec86hw_pdma_input,
.halt_output = nec86hw_halt_pdma,
.halt_input = nec86hw_halt_pdma,
- .speaker_ctl = nec86hw_speaker_ctl,
.set_port = nec86hw_mixer_set_port,
.get_port = nec86hw_mixer_get_port,
.query_devinfo = nec86hw_mixer_query_devinfo,
diff --git a/sys/arch/luna88k/cbus/nec86hw.c b/sys/arch/luna88k/cbus/nec86hw.c
index 070c7f57344..7a4740f781c 100644
--- a/sys/arch/luna88k/cbus/nec86hw.c
+++ b/sys/arch/luna88k/cbus/nec86hw.c
@@ -176,6 +176,8 @@ nec86hw_open(void *arg, int flags)
if (sc->sc_open != 0 || nec86hw_reset(sc) != 0)
return ENXIO;
+ nec86hw_speaker_ctl(sc, (flags & FWRITE) ? SPKR_ON : SPKR_OFF);
+
sc->sc_open = 1;
sc->sc_intr = NULL;
sc->sc_arg = NULL;
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index d57a743460a..06ddb17de32 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1492,14 +1492,6 @@ audio_open(struct audio_softc *sc, int flags)
if (flags & FREAD)
sc->mode |= AUMODE_RECORD;
- if (sc->ops->speaker_ctl) {
- /*
- * XXX: what is this used for?
- */
- sc->ops->speaker_ctl(sc->arg,
- (sc->mode & AUMODE_PLAY) ? SPKR_ON : SPKR_OFF);
- }
-
error = audio_setpar(sc);
if (error)
goto bad;
diff --git a/sys/dev/audio_if.h b/sys/dev/audio_if.h
index 564139271bb..a3c1e6f307b 100644
--- a/sys/dev/audio_if.h
+++ b/sys/dev/audio_if.h
@@ -99,7 +99,6 @@ struct audio_hw_if {
int (*halt_output)(void *);
int (*halt_input)(void *);
- int (*speaker_ctl)(void *, int);
#define SPKR_ON 1
#define SPKR_OFF 0
diff --git a/sys/dev/isa/ess.c b/sys/dev/isa/ess.c
index c195a1749d3..90c48be7d6a 100644
--- a/sys/dev/isa/ess.c
+++ b/sys/dev/isa/ess.c
@@ -204,7 +204,6 @@ const struct audio_hw_if ess_1788_hw_if = {
.round_blocksize = ess_round_blocksize,
.halt_output = ess_audio1_halt,
.halt_input = ess_audio1_halt,
- .speaker_ctl = ess_speaker_ctl,
.set_port = ess_set_port,
.get_port = ess_get_port,
.query_devinfo = ess_query_devinfo,
@@ -222,7 +221,6 @@ const struct audio_hw_if ess_1888_hw_if = {
.round_blocksize = ess_round_blocksize,
.halt_output = ess_audio2_halt,
.halt_input = ess_audio1_halt,
- .speaker_ctl = ess_speaker_ctl,
.set_port = ess_set_port,
.get_port = ess_get_port,
.query_devinfo = ess_query_devinfo,
@@ -1001,6 +999,8 @@ ess_open(void *addr, int flags)
ess_setup(sc); /* because we did a reset */
+ ess_speaker_ctl(sc, (flags & FWRITE) ? SPKR_ON : SPKR_OFF);
+
sc->sc_open = 1;
DPRINTF(("ess_open: opened\n"));
diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c
index f3c92ab20a5..7516414d2ac 100644
--- a/sys/dev/isa/gus.c
+++ b/sys/dev/isa/gus.c
@@ -270,7 +270,6 @@ const struct audio_hw_if gus_hw_if = {
.start_input = gus_dma_input,
.halt_output = gus_halt_out_dma,
.halt_input = gus_halt_in_dma,
- .speaker_ctl = gus_speaker_ctl,
.set_port = gus_mixer_set_port,
.get_port = gus_mixer_get_port,
.query_devinfo = gus_mixer_query_devinfo,
@@ -289,7 +288,6 @@ static const struct audio_hw_if gusmax_hw_if = {
.start_input = gusmax_dma_input,
.halt_output = gusmax_halt_out_dma,
.halt_input = gusmax_halt_in_dma,
- .speaker_ctl = gusmax_speaker_ctl,
.set_port = gusmax_mixer_set_port,
.get_port = gusmax_mixer_get_port,
.query_devinfo = gusmax_mixer_query_devinfo,
@@ -312,6 +310,8 @@ gusopen(void *addr, int flags)
if (sc->sc_flags & GUS_OPEN)
return EBUSY;
+ gus_speaker_ctl(sc, (flags & FWRITE) ? SPKR_ON : SPKR_OFF);
+
/*
* Some initialization
*/
@@ -1679,17 +1679,10 @@ gus_set_recrate(struct gus_softc *sc, u_long rate)
}
/*
- * Interface to the audio layer - turn the output on or off. Note that some
+ * Turn the output on or off. Note that some
* of these bits are flipped in the register
*/
-int
-gusmax_speaker_ctl(void *addr, int newstate)
-{
- struct ad1848_softc *sc = addr;
- return gus_speaker_ctl(sc->parent, newstate);
-}
-
int
gus_speaker_ctl(void *addr, int newstate)
{
diff --git a/sys/dev/isa/gusvar.h b/sys/dev/isa/gusvar.h
index f88b2f8fc4e..74b37a033ec 100644
--- a/sys/dev/isa/gusvar.h
+++ b/sys/dev/isa/gusvar.h
@@ -328,7 +328,6 @@ int gusmax_dma_output(void *, void *, int, void (*)(void
*), void *);
int gusmax_dma_input(void *, void *, int, void (*)(void *), void *);
int gusmax_halt_out_dma(void *);
int gusmax_halt_in_dma(void *);
-int gusmax_speaker_ctl(void *, int);
void gus_deinterleave(struct gus_softc *, void *, int);
diff --git a/sys/dev/isa/pas.c b/sys/dev/isa/pas.c
index a11a81ff6ff..d7dc4d2466b 100644
--- a/sys/dev/isa/pas.c
+++ b/sys/dev/isa/pas.c
@@ -115,7 +115,6 @@ const struct audio_hw_if pas_hw_if = {
.round_blocksize = sbdsp_round_blocksize,
.halt_output = sbdsp_haltdma,
.halt_input = sbdsp_haltdma,
- .speaker_ctl = sbdsp_speaker_ctl,
.set_port = sbdsp_mixer_set_port,
.get_port = sbdsp_mixer_get_port,
.query_devinfo = sbdsp_mixer_query_devinfo,
diff --git a/sys/dev/isa/sb.c b/sys/dev/isa/sb.c
index a70b0fc30ae..153bc8f5740 100644
--- a/sys/dev/isa/sb.c
+++ b/sys/dev/isa/sb.c
@@ -100,7 +100,6 @@ const struct audio_hw_if sb_hw_if = {
.round_blocksize = sbdsp_round_blocksize,
.halt_output = sbdsp_haltdma,
.halt_input = sbdsp_haltdma,
- .speaker_ctl = sbdsp_speaker_ctl,
.set_port = sbdsp_mixer_set_port,
.get_port = sbdsp_mixer_get_port,
.query_devinfo = sbdsp_mixer_query_devinfo,
diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c
index 4245be62760..55adec76de8 100644
--- a/sys/dev/isa/sbdsp.c
+++ b/sys/dev/isa/sbdsp.c
@@ -769,6 +769,8 @@ sbdsp_open(void *addr, int flags)
if (sbdsp_reset(sc) != 0)
return EIO;
+ sbdsp_speaker_ctl(sc, (flags & FWRITE) ? SPKR_ON : SPKR_OFF);
+
sc->sc_open = SB_OPEN_AUDIO;
sc->sc_openflags = flags;
sc->sc_intrm = 0;
--
2.38.1