aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2021-07-28 11:22:52 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2021-08-06 09:28:44 +0000
commited2196e5df0c8b5b81563d2fffdcb32bb7ebe966 (patch)
treef4a67140e4a7946f4b1a8a7951535c57abfe132c
parent132fca6335939b308f230d4942ba15ba2b56ceb7 (diff)
downloadsrc-ed2196e5df0c8b5b81563d2fffdcb32bb7ebe966.tar.gz
src-ed2196e5df0c8b5b81563d2fffdcb32bb7ebe966.zip
sound(4): Implement playback and recording mode sysctl(8).
The dev.pcm.<N>.mode sysctl(8) gives information if a sound device supports hardware mixing, playback or recording. Submitted by: Christos Margiolis <christos@freebsd.org> Differential Revision: https://reviews.freebsd.org/D31320 MFC after: 1 week Sponsored by: NVIDIA Networking
-rw-r--r--sys/dev/sound/pcm/sound.c23
-rw-r--r--sys/dev/sound/pcm/sound.h4
2 files changed, 27 insertions, 0 deletions
diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c
index e03529f00b78..663ec84f93b6 100644
--- a/sys/dev/sound/pcm/sound.c
+++ b/sys/dev/sound/pcm/sound.c
@@ -1015,10 +1015,28 @@ SYSCTL_PROC(_hw_snd, OID_AUTO, clone_gc,
"global clone garbage collector");
#endif
+static u_int8_t
+pcm_mode_init(struct snddev_info *d)
+{
+ u_int8_t mode = 0;
+
+ if (d->playcount > 0)
+ mode |= PCM_MODE_PLAY;
+ if (d->reccount > 0)
+ mode |= PCM_MODE_REC;
+ if (d->mixer_dev != NULL)
+ mode |= PCM_MODE_MIXER;
+
+ return (mode);
+}
+
static void
pcm_sysinit(device_t dev)
{
struct snddev_info *d = device_get_softc(dev);
+ u_int8_t mode;
+
+ mode = pcm_mode_init(d);
/* XXX: a user should be able to set this with a control tool, the
sysadmin then needs min+max sysctls for this */
@@ -1030,6 +1048,11 @@ pcm_sysinit(device_t dev)
"bitperfect", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NEEDGIANT, d,
sizeof(d), sysctl_dev_pcm_bitperfect, "I",
"bit-perfect playback/recording (0=disable, 1=enable)");
+ SYSCTL_ADD_UINT(device_get_sysctl_ctx(dev),
+ SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+ OID_AUTO, "mode", CTLFLAG_RD, NULL, mode,
+ "mode (1=mixer, 2=play, 4=rec. The values are OR'ed if more than one"
+ "mode is supported)");
#ifdef SND_DEBUG
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h
index 7b4a4d3a46ca..7c664524211a 100644
--- a/sys/dev/sound/pcm/sound.h
+++ b/sys/dev/sound/pcm/sound.h
@@ -412,6 +412,10 @@ struct snddev_info {
void sound_oss_sysinfo(oss_sysinfo *);
int sound_oss_card_info(oss_card_info *);
+#define PCM_MODE_MIXER 0x01
+#define PCM_MODE_PLAY 0x02
+#define PCM_MODE_REC 0x04
+
#define PCM_LOCKOWNED(d) mtx_owned((d)->lock)
#define PCM_LOCK(d) mtx_lock((d)->lock)
#define PCM_UNLOCK(d) mtx_unlock((d)->lock)