Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Make start_input/halt_input optional if the driver has no re...



details:   https://anonhg.NetBSD.org/src/rev/fd1ff549e1c5
branches:  trunk
changeset: 745116:fd1ff549e1c5
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sun Feb 23 04:02:45 2020 +0000

description:
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:

 share/man/man9/audio.9           |   6 ++++-
 sys/arch/arm/iomd/vidcaudio.c    |  24 +--------------------
 sys/arch/dreamcast/dev/g2/aica.c |  24 +--------------------
 sys/arch/hpcmips/vr/vraiu.c      |  29 +------------------------
 sys/dev/audio/audio.c            |  44 ++++++++++++++++++++++++---------------
 sys/dev/ic/pl041.c               |  19 +---------------
 sys/dev/pad/pad.c                |  34 +-----------------------------
 7 files changed, 42 insertions(+), 138 deletions(-)

diffs (truncated from 481 to 300 lines):

diff -r c4d2d1e612e7 -r fd1ff549e1c5 share/man/man9/audio.9
--- a/share/man/man9/audio.9    Sun Feb 23 02:37:53 2020 +0000
+++ b/share/man/man9/audio.9    Sun Feb 23 04:02:45 2020 +0000
@@ -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 @@
 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 @@
 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
diff -r c4d2d1e612e7 -r fd1ff549e1c5 sys/arch/arm/iomd/vidcaudio.c
--- a/sys/arch/arm/iomd/vidcaudio.c     Sun Feb 23 02:37:53 2020 +0000
+++ b/sys/arch/arm/iomd/vidcaudio.c     Sun Feb 23 04:02:45 2020 +0000
@@ -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_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 @@
        .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 @@
 }
 
 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 @@
 }
 
 static int
-vidcaudio_halt_input(void *addr)
-{
-
-       return ENODEV;
-}
-
-static int
 vidcaudio_getdev(void *addr, struct audio_device *retp)
 {
 
diff -r c4d2d1e612e7 -r fd1ff549e1c5 sys/arch/dreamcast/dev/g2/aica.c
--- a/sys/arch/dreamcast/dev/g2/aica.c  Sun Feb 23 02:37:53 2020 +0000
+++ b/sys/arch/dreamcast/dev/g2/aica.c  Sun Feb 23 04:02:45 2020 +0000
@@ -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 <ryo%misakimix.org@localhost>
@@ -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 @@
 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 @@
        .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 @@
        .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 @@
 }
 
 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 @@
 }
 
 int
-aica_halt_input(void *addr)
-{
-
-       return ENODEV;
-}
-
-int
 aica_getdev(void *addr, struct audio_device *ret)
 {
 
diff -r c4d2d1e612e7 -r fd1ff549e1c5 sys/arch/hpcmips/vr/vraiu.c
--- a/sys/arch/hpcmips/vr/vraiu.c       Sun Feb 23 02:37:53 2020 +0000
+++ b/sys/arch/hpcmips/vr/vraiu.c       Sun Feb 23 04:02:45 2020 +0000
@@ -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_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 @@
        .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 @@
 }
 
 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 @@
 }
 
 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)
 {
 
diff -r c4d2d1e612e7 -r fd1ff549e1c5 sys/dev/audio/audio.c
--- a/sys/dev/audio/audio.c     Sun Feb 23 02:37:53 2020 +0000
+++ b/sys/dev/audio/audio.c     Sun Feb 23 04:02:45 2020 +0000
@@ -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 @@
        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



Home | Main Index | Thread Index | Old Index