diff options
| author | isaki <isaki@NetBSD.org> | 2020-02-23 04:02:45 +0000 |
|---|---|---|
| committer | isaki <isaki@NetBSD.org> | 2020-02-23 04:02:45 +0000 |
| commit | 346ca4c0578a860ae61e014ca5a3abfe97ab87fb (patch) | |
| tree | 8b4f8b6d9464c06503f9c895fceac045750c427a /sys/dev/audio | |
| parent | ffb81e7fb248fbf6169db6c91b5643c6d5de79c5 (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/audio')
| -rw-r--r-- | sys/dev/audio/audio.c | 44 |
1 files changed, 27 insertions, 17 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) { |
