Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add infrastructure for modularization of audio, midi, an...
details: https://anonhg.NetBSD.org/src/rev/c0ac0a95f5b7
branches: trunk
changeset: 354019:c0ac0a95f5b7
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Thu Jun 01 09:44:30 2017 +0000
description:
Add infrastructure for modularization of audio, midi, and sequencer
diffstat:
sys/dev/auconv.c | 6 +-
sys/dev/audio.c | 62 ++++++++++++++++++++++++++--
sys/dev/midi.c | 52 +++++++++++++++++++++++-
sys/dev/pad/pad.c | 13 ++++-
sys/dev/sequencer.c | 56 ++++++++++++++++++++++++-
sys/dev/spkr.c | 6 +-
sys/rump/dev/lib/libaudio/Makefile | 4 +-
sys/rump/dev/lib/libaudio/audio_component.c | 25 ++++-------
8 files changed, 190 insertions(+), 34 deletions(-)
diffs (truncated from 476 to 300 lines):
diff -r 396fe7a28dc5 -r c0ac0a95f5b7 sys/dev/auconv.c
--- a/sys/dev/auconv.c Thu Jun 01 08:49:35 2017 +0000
+++ b/sys/dev/auconv.c Thu Jun 01 09:44:30 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: auconv.c,v 1.25 2011/11/23 23:07:31 jmcneill Exp $ */
+/* $NetBSD: auconv.c,v 1.26 2017/06/01 09:44:30 pgoyette Exp $ */
/*
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.25 2011/11/23 23:07:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auconv.c,v 1.26 2017/06/01 09:44:30 pgoyette Exp $");
#include <sys/types.h>
#include <sys/audioio.h>
@@ -56,8 +56,10 @@
#include <stdbool.h>
#endif
+#ifdef _KERNEL_OPT
#include <aurateconv.h> /* generated by config(8) */
#include <mulaw.h> /* generated by config(8) */
+#endif
/* #define AUCONV_DEBUG */
#ifdef AUCONV_DEBUG
diff -r 396fe7a28dc5 -r c0ac0a95f5b7 sys/dev/audio.c
--- a/sys/dev/audio.c Thu Jun 01 08:49:35 2017 +0000
+++ b/sys/dev/audio.c Thu Jun 01 09:44:30 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: audio.c,v 1.356 2017/06/01 02:45:08 chs Exp $ */
+/* $NetBSD: audio.c,v 1.357 2017/06/01 09:44:30 pgoyette Exp $ */
/*-
* Copyright (c) 2016 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
@@ -148,9 +148,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.356 2017/06/01 02:45:08 chs Exp $");
-
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.357 2017/06/01 09:44:30 pgoyette Exp $");
+
+#ifdef _KERNEL_OPT
#include "audio.h"
+#include "midi.h"
+#endif
+
#if NAUDIO > 0
#include <sys/types.h>
@@ -165,6 +169,7 @@
#include <sys/kauth.h>
#include <sys/kmem.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/stat.h>
@@ -309,6 +314,8 @@
static void audiochilddet(device_t, device_t);
static int audiorescan(device_t, const char *, const int *);
+static int audio_modcmd(modcmd_t, void *);
+
#ifdef AUDIO_PM_IDLE
static void audio_idle(void *);
static void audio_activity(device_t, devactive_t);
@@ -5136,8 +5143,6 @@
}
#endif /* NAUDIO > 0 */
-#include "midi.h"
-
#if NAUDIO == 0 && (NMIDI > 0 || NMIDIBUS > 0)
#include <sys/param.h>
#include <sys/systm.h>
@@ -6130,3 +6135,50 @@
}
#endif /* NAUDIO > 0 */
+
+#ifdef _MODULE
+
+extern struct cfdriver audio_cd;
+devmajor_t audio_bmajor = -1, audio_cmajor = -1;
+
+#include "ioconf.c"
+
+#endif
+
+MODULE(MODULE_CLASS_DRIVER, audio, NULL);
+
+static int
+audio_modcmd(modcmd_t cmd, void *arg)
+{
+ int error = 0;
+
+#ifdef _MODULE
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ error = devsw_attach(audio_cd.cd_name, NULL, &audio_bmajor,
+ &audio_cdevsw, &audio_cmajor);
+ if (error)
+ break;
+
+ error = config_init_component(cfdriver_ioconf_audio,
+ cfattach_ioconf_audio, cfdata_ioconf_audio);
+ if (error) {
+ devsw_detach(NULL, &audio_cdevsw);
+ }
+ break;
+ case MODULE_CMD_FINI:
+ devsw_detach(NULL, &audio_cdevsw);
+ error = config_fini_component(cfdriver_ioconf_audio,
+ cfattach_ioconf_audio, cfdata_ioconf_audio);
+ if (error)
+ devsw_attach(audio_cd.cd_name, NULL, &audio_bmajor,
+ &audio_cdevsw, &audio_cmajor);
+ break;
+ default:
+ error = ENOTTY;
+ break;
+ }
+#endif
+
+ return error;
+}
diff -r 396fe7a28dc5 -r c0ac0a95f5b7 sys/dev/midi.c
--- a/sys/dev/midi.c Thu Jun 01 08:49:35 2017 +0000
+++ b/sys/dev/midi.c Thu Jun 01 09:44:30 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: midi.c,v 1.85 2016/07/14 10:19:05 msaitoh Exp $ */
+/* $NetBSD: midi.c,v 1.86 2017/06/01 09:44:30 pgoyette Exp $ */
/*
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -31,10 +31,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.85 2016/07/14 10:19:05 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: midi.c,v 1.86 2017/06/01 09:44:30 pgoyette Exp $");
+#ifdef _KERNEL_OPT
#include "midi.h"
#include "sequencer.h"
+#endif
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -53,6 +55,7 @@
#include <sys/midiio.h>
#include <sys/device.h>
#include <sys/intr.h>
+#include <sys/module.h>
#include <dev/audio_if.h>
#include <dev/midi_if.h>
@@ -1887,3 +1890,48 @@
}
#endif /* NMIDI > 0 || NMIDIBUS > 0 */
+
+#ifdef _MODULE
+extern struct cfdriver midi_cd;
+#include "ioconf.c"
+
+devmajor_t midi_bmajor = -1, midi_cmajor = -1;
+#endif
+
+MODULE(MODULE_CLASS_DRIVER, midi, "audio");
+
+static int
+midi_modcmd(modcmd_t cmd, void *arg)
+{
+ int error = 0;
+
+#ifdef _MODULE
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ error = devsw_attach(midi_cd.cd_name, NULL, &midi_bmajor,
+ &midi_cdevsw, &midi_cmajor);
+ if (error)
+ break;
+
+ error = config_init_component(cfdriver_ioconf_midi,
+ cfattach_ioconf_midi, cfdata_ioconf_midi);
+ if (error) {
+ devsw_detach(NULL, &midi_cdevsw);
+ }
+ break;
+ case MODULE_CMD_FINI:
+ devsw_detach(NULL, &midi_cdevsw);
+ error = config_fini_component(cfdriver_ioconf_midi,
+ cfattach_ioconf_midi, cfdata_ioconf_midi);
+ if (error)
+ devsw_attach(midi_cd.cd_name, NULL, &midi_bmajor,
+ &midi_cdevsw, &midi_cmajor);
+ break;
+ default:
+ error = ENOTTY;
+ break;
+ }
+#endif
+
+ return error;
+}
diff -r 396fe7a28dc5 -r c0ac0a95f5b7 sys/dev/pad/pad.c
--- a/sys/dev/pad/pad.c Thu Jun 01 08:49:35 2017 +0000
+++ b/sys/dev/pad/pad.c Thu Jun 01 09:44:30 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.31 2017/06/01 02:45:10 chs Exp $ */
+/* $NetBSD: pad.c,v 1.32 2017/06/01 09:44:30 pgoyette Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.31 2017/06/01 02:45:10 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.32 2017/06/01 09:44:30 pgoyette Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -99,6 +99,8 @@
const audio_params_t *, const audio_params_t *);
static void pad_swvol_dtor(stream_filter_t *);
+static bool pad_is_attached; /* Do we have an audio* child? */
+
static const struct audio_hw_if pad_hw_if = {
.open = pad_audio_open,
.query_encoding = pad_query_encoding,
@@ -275,6 +277,7 @@
if (!pmf_device_register(self, NULL, NULL))
aprint_error_dev(self, "couldn't establish power handler\n");
+ pad_is_attached = true;
return;
}
@@ -284,6 +287,9 @@
pad_softc_t *sc = device_private(self);
int cmaj, mn, rc;
+ if (!pad_is_attached)
+ return ENXIO;
+
cmaj = cdevsw_lookup_major(&pad_cdevsw);
mn = device_unit(self);
vdevgone(cmaj, mn, mn, VCHR);
@@ -299,6 +305,7 @@
auconv_delete_encodings(sc->sc_encodings);
+ pad_is_attached = false;
return 0;
}
@@ -721,7 +728,7 @@
#ifdef _MODULE
-MODULE(MODULE_CLASS_DRIVER, pad, NULL);
+MODULE(MODULE_CLASS_DRIVER, pad, "audio");
static const struct cfiattrdata audiobuscf_iattrdata = {
"audiobus", 0, { { NULL, NULL, 0 }, }
diff -r 396fe7a28dc5 -r c0ac0a95f5b7 sys/dev/sequencer.c
--- a/sys/dev/sequencer.c Thu Jun 01 08:49:35 2017 +0000
+++ b/sys/dev/sequencer.c Thu Jun 01 09:44:30 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sequencer.c,v 1.65 2017/06/01 02:45:09 chs Exp $ */
+/* $NetBSD: sequencer.c,v 1.66 2017/06/01 09:44:30 pgoyette Exp $ */
/*
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -55,9 +55,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sequencer.c,v 1.65 2017/06/01 02:45:09 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sequencer.c,v 1.66 2017/06/01 09:44:30 pgoyette Exp $");
+#ifdef _KERNEL_OPT
#include "sequencer.h"
+#include "midi.h"
+#endif
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -80,6 +83,7 @@
#include <sys/pcq.h>
#include <sys/vnode.h>
#include <sys/kauth.h>
Home |
Main Index |
Thread Index |
Old Index