git: 188d619e4569 - stable/14 - sound: Add OSS channel capabilities to sndstat nvlist

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Mon, 29 Jul 2024 15:35:14 UTC
The branch stable/14 has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=188d619e45692c491158c63cdb468a8ad6912224

commit 188d619e45692c491158c63cdb468a8ad6912224
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-07-27 11:54:27 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-07-29 15:34:54 +0000

    sound: Add OSS channel capabilities to sndstat nvlist
    
    Assignment taken from dsp_oss_engineinfo().
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 days
    Reviewed by:    dev_submerge.ch
    Differential Revision:  https://reviews.freebsd.org/D46166
    
    (cherry picked from commit bd5bcc848c5764229926ad27a4bd77af4f87d189)
---
 share/man/man4/sndstat.4    | 3 +++
 sys/dev/sound/pcm/sndstat.c | 7 ++++++-
 sys/sys/sndstat.h           | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/share/man/man4/sndstat.4 b/share/man/man4/sndstat.4
index 7c2813356dae..bef444529e5f 100644
--- a/share/man/man4/sndstat.4
+++ b/share/man/man4/sndstat.4
@@ -86,6 +86,7 @@ dsps (NVLIST ARRAY): 1
 			name (STRING): pcm0:virtual_play:dsp0.vp0
 			parentchan (STRING): pcm0:play:dsp0.p0
 			unit (NUMBER): 1
+			caps (NUMBER): 0x073200
 			latency (NUMBER): 2
 			rate (NUMBER): 48000
 			format (NUMBER): 0x201000
@@ -201,6 +202,8 @@ Channel name.
 Parent channel name (e.g., in the case of virtual channels).
 .It Dv unit
 Channel unit.
+.It Dv caps
+OSS capabilities.
 .It Dv latency
 Latency.
 .It Dv rate
diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index b0d2c5b6ca21..f09fa7139884 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -385,7 +385,7 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 	struct pcm_channel *c;
 	struct pcm_feeder *f;
 	struct sbuf sb;
-	uint32_t maxrate, minrate, fmts, minchn, maxchn;
+	uint32_t maxrate, minrate, fmts, minchn, maxchn, caps;
 	nvlist_t *di = NULL, *sound4di = NULL, *diinfo = NULL, *cdi = NULL;
 	int err, nchan;
 
@@ -467,10 +467,15 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 
 		CHN_LOCK(c);
 
+		caps = PCM_CAP_REALTIME | PCM_CAP_MMAP | PCM_CAP_TRIGGER |
+		    ((c->flags & CHN_F_VIRTUAL) ? PCM_CAP_VIRTUAL : 0) |
+		    ((c->direction == PCMDIR_PLAY) ? PCM_CAP_OUTPUT : PCM_CAP_INPUT);
+
 		nvlist_add_string(cdi, SNDST_DSPS_SOUND4_CHAN_NAME, c->name);
 		nvlist_add_string(cdi, SNDST_DSPS_SOUND4_CHAN_PARENTCHAN,
 		    c->parentchannel != NULL ? c->parentchannel->name : "");
 		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_UNIT, nchan++);
+		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_CAPS, caps);
 		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_LATENCY,
 		    c->latency);
 		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_RATE, c->speed);
diff --git a/sys/sys/sndstat.h b/sys/sys/sndstat.h
index f7d0b2f29bd5..6fd2e06ac483 100644
--- a/sys/sys/sndstat.h
+++ b/sys/sys/sndstat.h
@@ -82,6 +82,7 @@ struct sndstioc_nv_arg {
 #define SNDST_DSPS_SOUND4_CHAN_NAME		"name"
 #define SNDST_DSPS_SOUND4_CHAN_PARENTCHAN	"parentchan"
 #define SNDST_DSPS_SOUND4_CHAN_UNIT		"unit"
+#define SNDST_DSPS_SOUND4_CHAN_CAPS		"caps"
 #define SNDST_DSPS_SOUND4_CHAN_LATENCY		"latency"
 #define SNDST_DSPS_SOUND4_CHAN_RATE		"rate"
 #define SNDST_DSPS_SOUND4_CHAN_FORMAT		"format"