Module Name:    src
Committed By:   isaki
Date:           Sun Feb 23 04:02:46 UTC 2020

Modified Files:
        src/share/man/man9: audio.9
        src/sys/arch/arm/iomd: vidcaudio.c
        src/sys/arch/dreamcast/dev/g2: aica.c
        src/sys/arch/hpcmips/vr: vraiu.c
        src/sys/dev/audio: audio.c
        src/sys/dev/ic: pl041.c
        src/sys/dev/pad: pad.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/share/man/man9/audio.9
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/arm/iomd/vidcaudio.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/dreamcast/dev/g2/aica.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/hpcmips/vr/vraiu.c
cvs rdiff -u -r1.53 -r1.54 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/pl041.c
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/pad/pad.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/audio.9
diff -u src/share/man/man9/audio.9:1.56 src/share/man/man9/audio.9:1.57
--- src/share/man/man9/audio.9:1.56	Wed Jun 12 13:53:25 2019
+++ src/share/man/man9/audio.9	Sun Feb 23 04:02:45 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: audio.9,v 1.56 2019/06/12 13:53:25 wiz Exp $
+.\"	$NetBSD: audio.9,v 1.57 2020/02/23 04:02:45 isaki Exp $
 .\"
 .\" Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -395,6 +395,7 @@ Calling
 will normally initiate another call to
 .Va start_output .
 Return 0 on success, otherwise an error code.
+This field is optional only if the driver doesn't support playback.
 It is called in the Opened phase.
 .It Dv int start_input(void *hdl, void *block, int blksize,
 .Dv "void (*intr)(void*), void *intrarg)"
@@ -415,18 +416,21 @@ Calling
 will normally initiate another call to
 .Va start_input .
 Return 0 on success, otherwise an error code.
+This field is optional only if the driver doesn't support recording.
 It is called in the Opened phase.
 .It Dv int halt_output(void *hdl)
 is called to abort the output transfer (started by
 .Va start_output )
 in progress.
 Return 0 on success, otherwise an error code.
+This field is optional only if the driver doesn't support playback.
 It is called in the Opened phase.
 .It Dv int halt_input(void *hdl)
 is called to abort the input transfer (started by
 .Va start_input )
 in progress.
 Return 0 on success, otherwise an error code.
+This field is optional only if the driver doesn't support recording,
 It is called in the Opened phase.
 .It Dv int speaker_ctl(void *hdl, int on)
 optional, is called when a half duplex device changes between

Index: src/sys/arch/arm/iomd/vidcaudio.c
diff -u src/sys/arch/arm/iomd/vidcaudio.c:1.59 src/sys/arch/arm/iomd/vidcaudio.c:1.60
--- src/sys/arch/arm/iomd/vidcaudio.c:1.59	Sat Jun  8 08:02:36 2019
+++ src/sys/arch/arm/iomd/vidcaudio.c	Sun Feb 23 04:02:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vidcaudio.c,v 1.59 2019/06/08 08:02:36 isaki Exp $	*/
+/*	$NetBSD: vidcaudio.c,v 1.60 2020/02/23 04:02:45 isaki Exp $	*/
 
 /*
  * Copyright (c) 1995 Melvin Tang-Richardson
@@ -65,7 +65,7 @@
 
 #include <sys/param.h>	/* proc.h */
 
-__KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,v 1.59 2019/06/08 08:02:36 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vidcaudio.c,v 1.60 2020/02/23 04:02:45 isaki Exp $");
 
 #include <sys/audioio.h>
 #include <sys/conf.h>   /* autoconfig functions */
@@ -148,10 +148,7 @@ static int    vidcaudio_set_format(void 
 static int    vidcaudio_round_blocksize(void *, int, int, const audio_params_t *);
 static int    vidcaudio_trigger_output(void *, void *, void *, int,
     void (*)(void *), void *, const audio_params_t *);
-static int    vidcaudio_trigger_input(void *, void *, void *, int,
-    void (*)(void *), void *, const audio_params_t *);
 static int    vidcaudio_halt_output(void *);
-static int    vidcaudio_halt_input(void *);
 static int    vidcaudio_getdev(void *, struct audio_device *);
 static int    vidcaudio_set_port(void *, mixer_ctrl_t *);
 static int    vidcaudio_get_port(void *, mixer_ctrl_t *);
@@ -171,14 +168,12 @@ static const struct audio_hw_if vidcaudi
 	.set_format		= vidcaudio_set_format,
 	.round_blocksize	= vidcaudio_round_blocksize,
 	.halt_output		= vidcaudio_halt_output,
-	.halt_input		= vidcaudio_halt_input,
 	.getdev			= vidcaudio_getdev,
 	.set_port		= vidcaudio_set_port,
 	.get_port		= vidcaudio_get_port,
 	.query_devinfo		= vidcaudio_query_devinfo,
 	.get_props		= vidcaudio_get_props,
 	.trigger_output		= vidcaudio_trigger_output,
-	.trigger_input		= vidcaudio_trigger_input,
 	.get_locks		= vidcaudio_get_locks,
 };
 
@@ -427,14 +422,6 @@ vidcaudio_trigger_output(void *addr, voi
 }
 
 static int
-vidcaudio_trigger_input(void *addr, void *start, void *end, int blksize,
-    void (*intr)(void *), void *arg, const audio_params_t *params)
-{
-
-	return ENODEV;
-}
-
-static int
 vidcaudio_halt_output(void *addr)
 {
 	struct vidcaudio_softc *sc;
@@ -447,13 +434,6 @@ vidcaudio_halt_output(void *addr)
 }
 
 static int
-vidcaudio_halt_input(void *addr)
-{
-
-	return ENODEV;
-}
-
-static int
 vidcaudio_getdev(void *addr, struct audio_device *retp)
 {
 

Index: src/sys/arch/dreamcast/dev/g2/aica.c
diff -u src/sys/arch/dreamcast/dev/g2/aica.c:1.27 src/sys/arch/dreamcast/dev/g2/aica.c:1.28
--- src/sys/arch/dreamcast/dev/g2/aica.c:1.27	Wed May  8 13:40:14 2019
+++ src/sys/arch/dreamcast/dev/g2/aica.c	Sun Feb 23 04:02:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: aica.c,v 1.27 2019/05/08 13:40:14 isaki Exp $	*/
+/*	$NetBSD: aica.c,v 1.28 2020/02/23 04:02:45 isaki Exp $	*/
 
 /*
  * Copyright (c) 2003 SHIMIZU Ryo <r...@misakimix.org>
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aica.c,v 1.27 2019/05/08 13:40:14 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aica.c,v 1.28 2020/02/23 04:02:45 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -135,10 +135,7 @@ int aica_round_blocksize(void *, int, in
 size_t aica_round_buffersize(void *, int, size_t);
 int aica_trigger_output(void *, void *, void *, int, void (*)(void *), void *,
     const audio_params_t *);
-int aica_trigger_input(void *, void *, void *, int, void (*)(void *), void *,
-    const audio_params_t *);
 int aica_halt_output(void *);
-int aica_halt_input(void *);
 int aica_getdev(void *, struct audio_device *);
 int aica_set_port(void *, mixer_ctrl_t *);
 int aica_get_port(void *, mixer_ctrl_t *);
@@ -154,7 +151,6 @@ const struct audio_hw_if aica_hw_if = {
 	.set_format		= aica_set_format,
 	.round_blocksize	= aica_round_blocksize,
 	.halt_output		= aica_halt_output,
-	.halt_input		= aica_halt_input,
 	.getdev			= aica_getdev,
 	.set_port		= aica_set_port,
 	.get_port		= aica_get_port,
@@ -162,7 +158,6 @@ const struct audio_hw_if aica_hw_if = {
 	.round_buffersize	= aica_round_buffersize,
 	.get_props		= aica_get_props,
 	.trigger_output		= aica_trigger_output,
-	.trigger_input		= aica_trigger_input,
 	.get_locks		= aica_get_locks,
 };
 
@@ -609,14 +604,6 @@ aica_trigger_output(void *addr, void *st
 }
 
 int
-aica_trigger_input(void *addr, void *start, void *end, int blksize,
-    void (*intr)(void *), void *arg, const audio_params_t *param)
-{
-
-	return ENODEV;
-}
-
-int
 aica_halt_output(void *addr)
 {
 	struct aica_softc *sc;
@@ -627,13 +614,6 @@ aica_halt_output(void *addr)
 }
 
 int
-aica_halt_input(void *addr)
-{
-
-	return ENODEV;
-}
-
-int
 aica_getdev(void *addr, struct audio_device *ret)
 {
 

Index: src/sys/arch/hpcmips/vr/vraiu.c
diff -u src/sys/arch/hpcmips/vr/vraiu.c:1.18 src/sys/arch/hpcmips/vr/vraiu.c:1.19
--- src/sys/arch/hpcmips/vr/vraiu.c:1.18	Sat Jun  8 08:02:37 2019
+++ src/sys/arch/hpcmips/vr/vraiu.c	Sun Feb 23 04:02:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vraiu.c,v 1.18 2019/06/08 08:02:37 isaki Exp $	*/
+/*	$NetBSD: vraiu.c,v 1.19 2020/02/23 04:02:46 isaki Exp $	*/
 
 /*
  * Copyright (c) 2001 HAMAJIMA Katsuomi. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vraiu.c,v 1.18 2019/06/08 08:02:37 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vraiu.c,v 1.19 2020/02/23 04:02:46 isaki Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -110,9 +110,7 @@ int vraiu_round_blocksize(void *, int, i
 int vraiu_commit_settings(void *);
 int vraiu_init_output(void *, void*, int);
 int vraiu_start_output(void *, void *, int, void (*)(void *), void *);
-int vraiu_start_input(void *, void *, int, void (*)(void *), void *);
 int vraiu_halt_output(void *);
-int vraiu_halt_input(void *);
 int vraiu_getdev(void *, struct audio_device *);
 int vraiu_set_port(void *, mixer_ctrl_t *);
 int vraiu_get_port(void *, mixer_ctrl_t *);
@@ -129,11 +127,8 @@ const struct audio_hw_if vraiu_hw_if = {
 	.round_blocksize	= vraiu_round_blocksize,
 	.commit_settings	= vraiu_commit_settings,
 	.init_output		= vraiu_init_output,
-	.init_input		= NULL,
 	.start_output		= vraiu_start_output,
-	.start_input		= vraiu_start_input,
 	.halt_output		= vraiu_halt_output,
-	.halt_input		= vraiu_halt_input,
 	.getdev			= vraiu_getdev,
 	.set_port		= vraiu_set_port,
 	.get_port		= vraiu_get_port,
@@ -367,16 +362,6 @@ vraiu_start_output(void *self, void *blo
 }
 
 int
-vraiu_start_input(void *self, void *block, int bsize,
-		  void (*intr)(void *), void *intrarg)
-{
-
-	DPRINTFN(3, ("vraiu_start_input\n"));
-	/* no input */
-	return ENXIO;
-}
-
-int
 vraiu_intr(void* self)
 {
 	struct vraiu_softc *sc;
@@ -431,16 +416,6 @@ vraiu_halt_output(void *self)
 }
 
 int
-vraiu_halt_input(void *self)
-{
-
-	DPRINTFN(3, ("vraiu_halt_input\n"));
-	/* no input */
-	return ENXIO;
-}
-
-
-int
 vraiu_getdev(void *self, struct audio_device *ret)
 {
 

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.53 src/sys/dev/audio/audio.c:1.54
--- src/sys/dev/audio/audio.c:1.53	Sat Feb 22 19:49:11 2020
+++ src/sys/dev/audio/audio.c	Sun Feb 23 04:02:46 2020
@@ -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 se
 	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 se
 	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) {

Index: src/sys/dev/ic/pl041.c
diff -u src/sys/dev/ic/pl041.c:1.6 src/sys/dev/ic/pl041.c:1.7
--- src/sys/dev/ic/pl041.c:1.6	Wed May  8 13:40:18 2019
+++ src/sys/dev/ic/pl041.c	Sun Feb 23 04:02:46 2020
@@ -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 <jmcne...@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 *st
 }
 
 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_
 	.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,
 };

Index: src/sys/dev/pad/pad.c
diff -u src/sys/dev/pad/pad.c:1.64 src/sys/dev/pad/pad.c:1.65
--- src/sys/dev/pad/pad.c:1.64	Sat Feb 22 08:15:09 2020
+++ src/sys/dev/pad/pad.c	Sun Feb 23 04:02:46 2020
@@ -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 <jmcne...@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_i
 	.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 *blo
 }
 
 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)
 {

Reply via email to