diff options
author | Klemens Nanni <kn@cvs.openbsd.org> | 2022-10-28 14:55:47 +0000 |
---|---|---|
committer | Klemens Nanni <kn@cvs.openbsd.org> | 2022-10-28 14:55:47 +0000 |
commit | 01fc3d474b1f39a8e358c57e3d0593667c6d84be (patch) | |
tree | 90e5d6fc4fc5bcdc39a145c3951b60f9b069befe /sys | |
parent | 6b550bd62a2b2114dd26995283cd29f696b36ca5 (diff) |
Replace audio(9) get_props() with duplex check in open() in partial duplex drivers
Make drivers which do *not* adverise AUDIO_PROP_FULLDPLEX return ENXIO
in their open() if full-duplex mode was requested.
This way, sys/dev/audio.c:audio_open() will fail immediately rather than
later through the to-be-removed get_props() check.
This is the first round for drivers with logic in their get_props(), i.e.
those that only support full-duplex mode for specific hardware:
ess(4), gus(4), pas(4) and sb(4)
All of these are i386/GENERIC only and share code through
sys/dev/isa/{ad1848,sbdsp}{.c,var.h} which are not used by any other kernel.
i386/GENERIC.MP builds and boots with this diff.
OK ratchov miod
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/isa/ad1848.c | 14 | ||||
-rw-r--r-- | sys/dev/isa/ad1848var.h | 4 | ||||
-rw-r--r-- | sys/dev/isa/ess.c | 31 | ||||
-rw-r--r-- | sys/dev/isa/gus.c | 22 | ||||
-rw-r--r-- | sys/dev/isa/gusvar.h | 4 | ||||
-rw-r--r-- | sys/dev/isa/pas.c | 3 | ||||
-rw-r--r-- | sys/dev/isa/sb.c | 3 | ||||
-rw-r--r-- | sys/dev/isa/sbdsp.c | 13 | ||||
-rw-r--r-- | sys/dev/isa/sbdspvar.h | 4 |
9 files changed, 33 insertions, 65 deletions
diff --git a/sys/dev/isa/ad1848.c b/sys/dev/isa/ad1848.c index bb2b95277a1..c322a388226 100644 --- a/sys/dev/isa/ad1848.c +++ b/sys/dev/isa/ad1848.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ad1848.c,v 1.47 2022/10/18 08:22:18 kn Exp $ */ +/* $OpenBSD: ad1848.c,v 1.48 2022/10/28 14:55:46 kn Exp $ */ /* $NetBSD: ad1848.c,v 1.45 1998/01/30 02:02:38 augustss Exp $ */ /* @@ -74,6 +74,7 @@ #include <sys/syslog.h> #include <sys/device.h> #include <sys/buf.h> +#include <sys/fcntl.h> #include <machine/cpu.h> #include <machine/bus.h> @@ -1040,6 +1041,9 @@ ad1848_open(void *addr, int flags) DPRINTF(("ad1848_open: sc=%p\n", sc)); + if ((flags & (FWRITE | FREAD)) == (FWRITE | FREAD) && sc->mode != 2) + return ENXIO; + sc->sc_pintr = sc->sc_parg = NULL; sc->sc_rintr = sc->sc_rarg = NULL; @@ -1458,11 +1462,3 @@ ad1848_round(void *addr, int direction, size_t size) size = MAX_ISADMA; return size; } - -int -ad1848_get_props(void *addr) -{ - struct ad1848_softc *sc = addr; - - return (sc->mode == 2 ? AUDIO_PROP_FULLDUPLEX : 0); -} diff --git a/sys/dev/isa/ad1848var.h b/sys/dev/isa/ad1848var.h index 49c199f64fc..cdf2ec03d46 100644 --- a/sys/dev/isa/ad1848var.h +++ b/sys/dev/isa/ad1848var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ad1848var.h,v 1.16 2021/03/07 06:17:03 jsg Exp $ */ +/* $OpenBSD: ad1848var.h,v 1.17 2022/10/28 14:55:46 kn Exp $ */ /* $NetBSD: ad1848var.h,v 1.22 1998/01/19 22:18:26 augustss Exp $ */ /* @@ -210,6 +210,4 @@ void *ad1848_malloc(void *, int, size_t, int, int); void ad1848_free(void *, void *, int); size_t ad1848_round(void *, int, size_t); -int ad1848_get_props(void *); - #endif diff --git a/sys/dev/isa/ess.c b/sys/dev/isa/ess.c index 8989dd94b01..c195a1749d3 100644 --- a/sys/dev/isa/ess.c +++ b/sys/dev/isa/ess.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ess.c,v 1.31 2022/10/19 19:14:16 kn Exp $ */ +/* $OpenBSD: ess.c,v 1.32 2022/10/28 14:55:46 kn Exp $ */ /* $NetBSD: ess.c,v 1.44.4.1 1999/06/21 01:18:00 thorpej Exp $ */ /* @@ -74,6 +74,7 @@ #include <sys/device.h> #include <sys/kernel.h> #include <sys/timeout.h> +#include <sys/fcntl.h> #include <machine/cpu.h> #include <machine/intr.h> @@ -115,6 +116,7 @@ struct audio_params ess_audio_default = int ess_setup_sc(struct ess_softc *, int); +int ess_1788_open(void *, int); int ess_open(void *, int); void ess_1788_close(void *); void ess_1888_close(void *); @@ -148,8 +150,6 @@ size_t ess_round_buffersize(void *, int, size_t); int ess_query_devinfo(void *, mixer_devinfo_t *); -int ess_1788_get_props(void *); -int ess_1888_get_props(void *); void ess_speaker_on(struct ess_softc *); void ess_speaker_off(struct ess_softc *); @@ -198,7 +198,7 @@ static const char *essmodel[] = { */ const struct audio_hw_if ess_1788_hw_if = { - .open = ess_open, + .open = ess_1788_open, .close = ess_1788_close, .set_params = ess_set_params, .round_blocksize = ess_round_blocksize, @@ -211,7 +211,6 @@ const struct audio_hw_if ess_1788_hw_if = { .allocm = ess_malloc, .freem = ess_free, .round_buffersize = ess_round_buffersize, - .get_props = ess_1788_get_props, .trigger_output = ess_audio1_trigger_output, .trigger_input = ess_audio1_trigger_input, }; @@ -230,7 +229,6 @@ const struct audio_hw_if ess_1888_hw_if = { .allocm = ess_malloc, .freem = ess_free, .round_buffersize = ess_round_buffersize, - .get_props = ess_1888_get_props, .trigger_output = ess_audio2_trigger_output, .trigger_input = ess_audio1_trigger_input, }; @@ -983,6 +981,15 @@ essattach(struct ess_softc *sc) */ int +ess_1788_open(void *addr, int flags) +{ + if ((flags & (FWRITE | FREAD)) == (FWRITE | FREAD)) + return ENXIO; + + return ess_open(addr, flags); +} + +int ess_open(void *addr, int flags) { struct ess_softc *sc = addr; @@ -2059,18 +2066,6 @@ ess_round_buffersize(void *addr, int direction, size_t size) return (size); } -int -ess_1788_get_props(void *addr) -{ - return (0); -} - -int -ess_1888_get_props(void *addr) -{ - return (AUDIO_PROP_FULLDUPLEX); -} - /* ============================================ * Generic functions for ess, not used by audio h/w i/f * ============================================= diff --git a/sys/dev/isa/gus.c b/sys/dev/isa/gus.c index 45fe009fc61..f3c92ab20a5 100644 --- a/sys/dev/isa/gus.c +++ b/sys/dev/isa/gus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gus.c,v 1.53 2022/10/19 19:14:16 kn Exp $ */ +/* $OpenBSD: gus.c,v 1.54 2022/10/28 14:55:46 kn Exp $ */ /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ /*- @@ -277,7 +277,6 @@ const struct audio_hw_if gus_hw_if = { .allocm = gus_malloc, .freem = gus_free, .round_buffersize = gus_round, - .get_props = gus_get_props, }; static const struct audio_hw_if gusmax_hw_if = { @@ -297,7 +296,6 @@ static const struct audio_hw_if gusmax_hw_if = { .allocm = ad1848_malloc, .freem = ad1848_free, .round_buffersize = ad1848_round, - .get_props = gusmax_get_props, }; int @@ -307,6 +305,10 @@ gusopen(void *addr, int flags) DPRINTF(("gusopen() called\n")); + if ((flags & (FWRITE | FREAD)) == (FWRITE | FREAD) && + sc->sc_recdrq == sc->sc_drq) + return ENXIO; + if (sc->sc_flags & GUS_OPEN) return EBUSY; @@ -2672,20 +2674,6 @@ gus_mixer_set_port(void *addr, mixer_ctrl_t *cp) } int -gus_get_props(void *addr) -{ - struct gus_softc *sc = addr; - return (sc->sc_recdrq == sc->sc_drq ? 0 : AUDIO_PROP_FULLDUPLEX); -} - -int -gusmax_get_props(void *addr) -{ - struct ad1848_softc *ac = addr; - return gus_get_props(ac->parent); -} - -int gusmax_mixer_query_devinfo(void *addr, mixer_devinfo_t *dip) { DPRINTF(("gusmax_query_devinfo: index=%d\n", dip->index)); diff --git a/sys/dev/isa/gusvar.h b/sys/dev/isa/gusvar.h index e979f53c6ac..f88b2f8fc4e 100644 --- a/sys/dev/isa/gusvar.h +++ b/sys/dev/isa/gusvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: gusvar.h,v 1.11 2022/03/21 19:22:40 miod Exp $ */ +/* $OpenBSD: gusvar.h,v 1.12 2022/10/28 14:55:46 kn Exp $ */ /* $NetBSD: gus.c,v 1.51 1998/01/25 23:48:06 mycroft Exp $ */ /*- @@ -371,8 +371,6 @@ int gusmax_mixer_query_devinfo(void *, mixer_devinfo_t *); void *gus_malloc(void *, int, size_t, int, int); void gus_free(void *, void *, int); size_t gus_round(void *, int, size_t); -int gus_get_props(void *); -int gusmax_get_props(void *); void gusics_master_mute(struct ics2101_softc *, int); void gusics_dac_mute(struct ics2101_softc *, int); diff --git a/sys/dev/isa/pas.c b/sys/dev/isa/pas.c index 2204b1be495..a11a81ff6ff 100644 --- a/sys/dev/isa/pas.c +++ b/sys/dev/isa/pas.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pas.c,v 1.35 2022/10/19 19:14:16 kn Exp $ */ +/* $OpenBSD: pas.c,v 1.36 2022/10/28 14:55:46 kn Exp $ */ /* $NetBSD: pas.c,v 1.37 1998/01/12 09:43:43 thorpej Exp $ */ /* @@ -122,7 +122,6 @@ const struct audio_hw_if pas_hw_if = { .allocm = sb_malloc, .freem = sb_free, .round_buffersize = sb_round, - .get_props = sbdsp_get_props, .trigger_output = sbdsp_trigger_output, .trigger_input = sbdsp_trigger_input, }; diff --git a/sys/dev/isa/sb.c b/sys/dev/isa/sb.c index bf2bb45c5fa..a70b0fc30ae 100644 --- a/sys/dev/isa/sb.c +++ b/sys/dev/isa/sb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sb.c,v 1.33 2022/10/19 19:14:16 kn Exp $ */ +/* $OpenBSD: sb.c,v 1.34 2022/10/28 14:55:46 kn Exp $ */ /* $NetBSD: sb.c,v 1.57 1998/01/12 09:43:46 thorpej Exp $ */ /* @@ -107,7 +107,6 @@ const struct audio_hw_if sb_hw_if = { .allocm = sb_malloc, .freem = sb_free, .round_buffersize = sb_round, - .get_props = sbdsp_get_props, .trigger_output = sbdsp_trigger_output, .trigger_input = sbdsp_trigger_input, }; diff --git a/sys/dev/isa/sbdsp.c b/sys/dev/isa/sbdsp.c index 4ca26c110ef..a785a6e2c47 100644 --- a/sys/dev/isa/sbdsp.c +++ b/sys/dev/isa/sbdsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbdsp.c,v 1.41 2022/10/18 08:22:18 kn Exp $ */ +/* $OpenBSD: sbdsp.c,v 1.42 2022/10/28 14:55:46 kn Exp $ */ /* * Copyright (c) 1991-1993 Regents of the University of California. @@ -53,6 +53,7 @@ #include <sys/syslog.h> #include <sys/device.h> #include <sys/buf.h> +#include <sys/fcntl.h> #include <machine/cpu.h> #include <machine/intr.h> @@ -2112,13 +2113,6 @@ sb_round(void *addr, int direction, size_t size) return size; } -int -sbdsp_get_props(void *addr) -{ - struct sbdsp_softc *sc = addr; - return (sc->sc_fullduplex ? AUDIO_PROP_FULLDUPLEX : 0); -} - #if NMIDI > 0 /* * MIDI related routines. @@ -2132,6 +2126,9 @@ sbdsp_midi_open(void *addr, int flags, void (*iintr)(void *, int), DPRINTF(("sbdsp_midi_open: sc=%p\n", sc)); + if ((flags & (FWRITE | FREAD)) == (FWRITE | FREAD) && + !sc->sc_fullduplex) + return ENXIO; if (sc->sc_open != SB_CLOSED) return EBUSY; if (sbdsp_reset(sc) != 0) diff --git a/sys/dev/isa/sbdspvar.h b/sys/dev/isa/sbdspvar.h index 188cdf205b2..2a43ee46d98 100644 --- a/sys/dev/isa/sbdspvar.h +++ b/sys/dev/isa/sbdspvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sbdspvar.h,v 1.18 2016/09/14 06:12:19 ratchov Exp $ */ +/* $OpenBSD: sbdspvar.h,v 1.19 2022/10/28 14:55:46 kn Exp $ */ /* $NetBSD: sbdspvar.h,v 1.37 1998/08/10 00:20:39 mycroft Exp $ */ /* @@ -243,8 +243,6 @@ void *sb_malloc(void *, int, size_t, int, int); void sb_free(void *, void *, int); size_t sb_round(void *, int, size_t); -int sbdsp_get_props(void *); - int sbdsp_midi_open(void *, int, void (*iintr)(void *, int), |