Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Sep 2021 13:02:35 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 1483b121d028 - stable/13 - sound(4): Implement playback and recording mode sysctl(8).
Message-ID:  <202109221302.18MD2ZaC013132@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=1483b121d0285bda728833e9690570ec6dbe3982

commit 1483b121d0285bda728833e9690570ec6dbe3982
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2021-07-28 11:22:52 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2021-09-22 12:59:31 +0000

    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
    
    (cherry picked from commit ed2196e5df0c8b5b81563d2fffdcb32bb7ebe966)
---
 sys/dev/sound/pcm/sound.c | 23 +++++++++++++++++++++++
 sys/dev/sound/pcm/sound.h |  4 ++++
 2 files changed, 27 insertions(+)

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 cdae5e837cdc..62787a3e689c 100644
--- a/sys/dev/sound/pcm/sound.h
+++ b/sys/dev/sound/pcm/sound.h
@@ -411,6 +411,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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109221302.18MD2ZaC013132>