From: kn Date: Wed, 2 Nov 2022 10:41:34 +0000 (+0000) Subject: Remove audio(9) speaker_ctl(), let open() handle speakers where needed X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c8819f5db69635e0013fbb92bd980ff98e8cde15;p=openbsd Remove audio(9) speaker_ctl(), let open() handle speakers where needed 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. Builds fine on i386. OK ratchov --- diff --git a/share/man/man9/audio.9 b/share/man/man9/audio.9 index f03bd74c8b8..95a4495ae8c 100644 --- a/share/man/man9/audio.9 +++ b/share/man/man9/audio.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: audio.9,v 1.33 2022/10/28 15:13:59 kn Exp $ +.\" $OpenBSD: audio.9,v 1.34 2022/11/02 10:41:34 kn Exp $ .\" $NetBSD: audio.9,v 1.14 2000/02/11 22:56:15 kleink Exp $ .\" .\" Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: October 28 2022 $ +.Dd $Mdocdate: November 2 2022 $ .Dt AUDIO 9 .Os .Sh NAME @@ -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..2ba37154437 100644 --- a/sys/arch/luna88k/cbus/nec86.c +++ b/sys/arch/luna88k/cbus/nec86.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nec86.c,v 1.8 2022/10/28 15:09:45 kn Exp $ */ +/* $OpenBSD: nec86.c,v 1.9 2022/11/02 10:41:34 kn Exp $ */ /* $NecBSD: nec86.c,v 1.11 1999/07/23 11:04:39 honda Exp $ */ /* $NetBSD$ */ @@ -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..e0b85142a49 100644 --- a/sys/arch/luna88k/cbus/nec86hw.c +++ b/sys/arch/luna88k/cbus/nec86hw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nec86hw.c,v 1.8 2022/10/28 15:09:45 kn Exp $ */ +/* $OpenBSD: nec86hw.c,v 1.9 2022/11/02 10:41:34 kn Exp $ */ /* $NecBSD: nec86hw.c,v 1.13 1998/03/14 07:04:54 kmatsuda Exp $ */ /* $NetBSD$ */ @@ -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..afe41327c43 100644 --- a/sys/dev/audio.c +++ b/sys/dev/audio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: audio.c,v 1.203 2022/10/28 15:13:59 kn Exp $ */ +/* $OpenBSD: audio.c,v 1.204 2022/11/02 10:41:34 kn Exp $ */ /* * Copyright (c) 2015 Alexandre Ratchov * @@ -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..c8cca95d970 100644 --- a/sys/dev/audio_if.h +++ b/sys/dev/audio_if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: audio_if.h,v 1.41 2022/10/28 15:13:59 kn Exp $ */ +/* $OpenBSD: audio_if.h,v 1.42 2022/11/02 10:41:34 kn Exp $ */ /* $NetBSD: audio_if.h,v 1.24 1998/01/10 14:07:25 tv Exp $ */ /* @@ -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..217d9db7fed 100644 --- a/sys/dev/isa/ess.c +++ b/sys/dev/isa/ess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ess.c,v 1.32 2022/10/28 14:55:46 kn Exp $ */ +/* $OpenBSD: ess.c,v 1.33 2022/11/02 10:41:34 kn Exp $ */ /* $NetBSD: ess.c,v 1.44.4.1 1999/06/21 01:18:00 thorpej Exp $ */ /* @@ -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..487bff53ab3 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gus.c,v 1.54 2022/10/28 14:55:46 kn Exp $ */ +/* $OpenBSD: gus.c,v 1.55 2022/11/02 10:41:34 kn Exp $ */ /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ /*- @@ -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..1d186dee40f 100644 --- a/sys/dev/isa/gusvar.h +++ b/sys/dev/isa/gusvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: gusvar.h,v 1.12 2022/10/28 14:55:46 kn Exp $ */ +/* $OpenBSD: gusvar.h,v 1.13 2022/11/02 10:41:34 kn Exp $ */ /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ /*- @@ -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..906326fce25 100644 --- a/sys/dev/isa/pas.c +++ b/sys/dev/isa/pas.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pas.c,v 1.36 2022/10/28 14:55:46 kn Exp $ */ +/* $OpenBSD: pas.c,v 1.37 2022/11/02 10:41:34 kn Exp $ */ /* $NetBSD: pas.c,v 1.37 1998/01/12 09:43:43 thorpej Exp $ */ /* @@ -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..6bef5bda989 100644 --- a/sys/dev/isa/sb.c +++ b/sys/dev/isa/sb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sb.c,v 1.34 2022/10/28 14:55:46 kn Exp $ */ +/* $OpenBSD: sb.c,v 1.35 2022/11/02 10:41:34 kn Exp $ */ /* $NetBSD: sb.c,v 1.57 1998/01/12 09:43:46 thorpej Exp $ */ /* @@ -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 23b213c8e57..19c823a2c50 100644 --- a/sys/dev/isa/sbdsp.c +++ b/sys/dev/isa/sbdsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbdsp.c,v 1.43 2022/10/30 10:55:52 kn Exp $ */ +/* $OpenBSD: sbdsp.c,v 1.44 2022/11/02 10:41:34 kn Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -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;