summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorisaki <isaki@NetBSD.org>2020-02-23 04:02:45 +0000
committerisaki <isaki@NetBSD.org>2020-02-23 04:02:45 +0000
commit346ca4c0578a860ae61e014ca5a3abfe97ab87fb (patch)
tree8b4f8b6d9464c06503f9c895fceac045750c427a /sys/dev
parentffb81e7fb248fbf6169db6c91b5643c6d5de79c5 (diff)
Make start_input/halt_input optional if the driver has no recording,
make start_output/halt_output optional if the driver has no playback. And remove such never called functions.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/audio/audio.c44
-rw-r--r--sys/dev/ic/pl041.c19
-rw-r--r--sys/dev/pad/pad.c34
3 files changed, 31 insertions, 66 deletions
diff --git a/sys/dev/audio/audio.c b/sys/dev/audio/audio.c
index 429c430e453..7745022ab5f 100644
--- a/sys/dev/audio/audio.c
+++ b/sys/dev/audio/audio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.53 2020/02/22 19:49:11 chs Exp $ */
+/* $NetBSD: audio.c,v 1.54 2020/02/23 04:02:46 isaki Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.53 2020/02/22 19:49:11 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.54 2020/02/23 04:02:46 isaki Exp $");
#ifdef _KERNEL_OPT
#include "audio.h"
@@ -852,27 +852,44 @@ audioattach(device_t parent, device_t self, void *aux)
hw_if = sa->hwif;
hdlp = sa->hdl;
- if (hw_if == NULL || hw_if->get_locks == NULL) {
+ if (hw_if == NULL) {
panic("audioattach: missing hw_if method");
}
+ if (hw_if->get_locks == NULL || hw_if->get_props == NULL) {
+ aprint_error(": missing mandatory method\n");
+ return;
+ }
hw_if->get_locks(hdlp, &sc->sc_intr_lock, &sc->sc_lock);
+ sc->sc_props = hw_if->get_props(hdlp);
+
+ has_playback = (sc->sc_props & AUDIO_PROP_PLAYBACK);
+ has_capture = (sc->sc_props & AUDIO_PROP_CAPTURE);
+ has_indep = (sc->sc_props & AUDIO_PROP_INDEPENDENT);
+ has_fulldup = (sc->sc_props & AUDIO_PROP_FULLDUPLEX);
#ifdef DIAGNOSTIC
if (hw_if->query_format == NULL ||
hw_if->set_format == NULL ||
- (hw_if->start_output == NULL && hw_if->trigger_output == NULL) ||
- (hw_if->start_input == NULL && hw_if->trigger_input == NULL) ||
- hw_if->halt_output == NULL ||
- hw_if->halt_input == NULL ||
hw_if->getdev == NULL ||
hw_if->set_port == NULL ||
hw_if->get_port == NULL ||
- hw_if->query_devinfo == NULL ||
- hw_if->get_props == NULL) {
- aprint_error(": missing method\n");
+ hw_if->query_devinfo == NULL) {
+ aprint_error(": missing mandatory method\n");
return;
}
+ if (has_playback) {
+ if ((hw_if->start_output == NULL && hw_if->trigger_output == NULL) ||
+ hw_if->halt_output == NULL) {
+ aprint_error(": missing playback method\n");
+ }
+ }
+ if (has_capture) {
+ if ((hw_if->start_input == NULL && hw_if->trigger_input == NULL) ||
+ hw_if->halt_input == NULL) {
+ aprint_error(": missing capture method\n");
+ }
+ }
#endif
sc->hw_if = hw_if;
@@ -886,16 +903,9 @@ audioattach(device_t parent, device_t self, void *aux)
sc->sc_am_used = 0;
sc->sc_am = NULL;
- sc->sc_props = hw_if->get_props(sc->hw_hdl);
-
/* MMAP is now supported by upper layer. */
sc->sc_props |= AUDIO_PROP_MMAP;
- has_playback = (sc->sc_props & AUDIO_PROP_PLAYBACK);
- has_capture = (sc->sc_props & AUDIO_PROP_CAPTURE);
- has_indep = (sc->sc_props & AUDIO_PROP_INDEPENDENT);
- has_fulldup = (sc->sc_props & AUDIO_PROP_FULLDUPLEX);
-
KASSERT(has_playback || has_capture);
/* Unidirectional device must have neither FULLDUP nor INDEPENDENT. */
if (!has_playback || !has_capture) {
diff --git a/sys/dev/ic/pl041.c b/sys/dev/ic/pl041.c
index 39a0a4500a4..d6cec46d286 100644
--- a/sys/dev/ic/pl041.c
+++ b/sys/dev/ic/pl041.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pl041.c,v 1.6 2019/05/08 13:40:18 isaki Exp $ */
+/* $NetBSD: pl041.c,v 1.7 2020/02/23 04:02:46 isaki Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pl041.c,v 1.6 2019/05/08 13:40:18 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pl041.c,v 1.7 2020/02/23 04:02:46 isaki Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -200,13 +200,6 @@ aaci_trigger_output(void *priv, void *start, void *end, int blksize,
}
static int
-aaci_trigger_input(void *priv, void *start, void *end, int blksize,
- void (*intr)(void *), void *intrarg, const audio_params_t *params)
-{
- return ENXIO;
-}
-
-static int
aaci_halt_output(void *priv)
{
struct aaci_softc * const sc = priv;
@@ -220,12 +213,6 @@ aaci_halt_output(void *priv)
}
static int
-aaci_halt_input(void *priv)
-{
- return ENXIO;
-}
-
-static int
aaci_round_blocksize(void *priv, int bs, int mode, const audio_params_t *params)
{
return roundup(bs, AACI_BLOCK_ALIGN);
@@ -249,9 +236,7 @@ static const struct audio_hw_if aaci_hw_if = {
.query_devinfo = aaci_query_devinfo,
.get_props = aaci_get_props,
.trigger_output = aaci_trigger_output,
- .trigger_input = aaci_trigger_input,
.halt_output = aaci_halt_output,
- .halt_input = aaci_halt_input,
.round_blocksize = aaci_round_blocksize,
.get_locks = aaci_get_locks,
};
diff --git a/sys/dev/pad/pad.c b/sys/dev/pad/pad.c
index 0585d12a307..c7bee924b6f 100644
--- a/sys/dev/pad/pad.c
+++ b/sys/dev/pad/pad.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.64 2020/02/22 08:15:09 isaki Exp $ */
+/* $NetBSD: pad.c,v 1.65 2020/02/23 04:02:46 isaki Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.64 2020/02/22 08:15:09 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.65 2020/02/23 04:02:46 isaki Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -95,10 +95,7 @@ static int pad_set_format(void *, int,
audio_filter_reg_t *, audio_filter_reg_t *);
static int pad_start_output(void *, void *, int,
void (*)(void *), void *);
-static int pad_start_input(void *, void *, int,
- void (*)(void *), void *);
static int pad_halt_output(void *);
-static int pad_halt_input(void *);
static int pad_getdev(void *, struct audio_device *);
static int pad_set_port(void *, mixer_ctrl_t *);
static int pad_get_port(void *, mixer_ctrl_t *);
@@ -129,9 +126,7 @@ static const struct audio_hw_if pad_hw_if = {
.query_format = pad_query_format,
.set_format = pad_set_format,
.start_output = pad_start_output,
- .start_input = pad_start_input,
.halt_output = pad_halt_output,
- .halt_input = pad_halt_input,
.getdev = pad_getdev,
.set_port = pad_set_port,
.get_port = pad_get_port,
@@ -638,19 +633,6 @@ pad_start_output(void *opaque, void *block, int blksize,
}
static int
-pad_start_input(void *opaque, void *block, int blksize,
- void (*intr)(void *), void *intrarg)
-{
- struct pad_softc *sc __diagused;
-
- sc = (struct pad_softc *)opaque;
-
- KASSERT(mutex_owned(&sc->sc_intr_lock));
-
- return EOPNOTSUPP;
-}
-
-static int
pad_halt_output(void *opaque)
{
struct pad_softc *sc;
@@ -670,18 +652,6 @@ pad_halt_output(void *opaque)
return 0;
}
-static int
-pad_halt_input(void *opaque)
-{
- struct pad_softc *sc __diagused;
-
- sc = (struct pad_softc *)opaque;
-
- KASSERT(mutex_owned(&sc->sc_intr_lock));
-
- return 0;
-}
-
static void
pad_done_output(void *arg)
{