git: a62837175770 - main - sound: Add *vchanrate and *vchanformat to sndstat nvlist

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Sat, 27 Jul 2024 11:56:15 UTC
The branch main has been updated by christos:

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

commit a6283717577066b0ff6c62053145470ff4134051
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-07-27 11:54:21 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-07-27 11:54:21 +0000

    sound: Add *vchanrate and *vchanformat to sndstat nvlist
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 days
    Reviewed by:    dev_submerge.ch
    Differential Revision:  https://reviews.freebsd.org/D46164
---
 share/man/man4/sndstat.4    | 12 ++++++++++++
 sys/dev/sound/pcm/sndstat.c |  8 ++++++++
 sys/sys/sndstat.h           |  4 ++++
 3 files changed, 24 insertions(+)

diff --git a/share/man/man4/sndstat.4 b/share/man/man4/sndstat.4
index eca1e391f130..2f745f418b79 100644
--- a/share/man/man4/sndstat.4
+++ b/share/man/man4/sndstat.4
@@ -77,7 +77,11 @@ dsps (NVLIST ARRAY): 1
 		status (STRING): on hdaa0
 		bitperfect (BOOL): FALSE
 		pvchan (NUMBER): 1
+		pvchanrate (NUMBER): 48000
+		pvchanformat (NUMBER): 0x00000010
 		rvchan (NUMBER): 0
+		rvchanrate (NUMBER): 48000
+		rvchanformat (NUMBER): 0x00000010
 		channel_info (NVLIST_ARRAY): 1
 			name (STRING): pcm0:virtual_play:dsp0.vp0
 			parentchan (STRING): pcm0:play:dsp0.p0
@@ -177,8 +181,16 @@ Usually reports the driver the device is attached on.
 Whether the sound card has bit-perfect mode enabled.
 .It Dv pvchan
 Number of playback virtual channels.
+.It Dv pvchanrate
+Playback virtual channel sample rate.
+.It Dv pvchanformat
+Playback virtual channel format.
 .It Dv rvchan
 Number of recording virtual channels.
+.It Dv rvchanrate
+Recording virtual channel sample rate.
+.It Dv rvchanformat
+Recording virtual channel format.
 .It Dv channel_info
 Channel information.
 There are a number of name/value pairs inside this field:
diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index fda7a2ad6d48..b0d2c5b6ca21 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -444,7 +444,15 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 	nvlist_add_bool(
 	    sound4di, SNDST_DSPS_SOUND4_BITPERFECT, d->flags & SD_F_BITPERFECT);
 	nvlist_add_number(sound4di, SNDST_DSPS_SOUND4_PVCHAN, d->pvchancount);
+	nvlist_add_number(sound4di, SNDST_DSPS_SOUND4_PVCHANRATE,
+	    d->pvchanrate);
+	nvlist_add_number(sound4di, SNDST_DSPS_SOUND4_PVCHANFORMAT,
+	    d->pvchanformat);
 	nvlist_add_number(sound4di, SNDST_DSPS_SOUND4_RVCHAN, d->rvchancount);
+	nvlist_add_number(sound4di, SNDST_DSPS_SOUND4_RVCHANRATE,
+	    d->rvchanrate);
+	nvlist_add_number(sound4di, SNDST_DSPS_SOUND4_RVCHANFORMAT,
+	    d->rvchanformat);
 
 	nchan = 0;
 	CHN_FOREACH(c, d, channels.pcm) {
diff --git a/sys/sys/sndstat.h b/sys/sys/sndstat.h
index 2f2965bb3d05..f7d0b2f29bd5 100644
--- a/sys/sys/sndstat.h
+++ b/sys/sys/sndstat.h
@@ -73,7 +73,11 @@ struct sndstioc_nv_arg {
 #define SNDST_DSPS_SOUND4_STATUS		"status"
 #define SNDST_DSPS_SOUND4_BITPERFECT		"bitperfect"
 #define SNDST_DSPS_SOUND4_PVCHAN		"pvchan"
+#define SNDST_DSPS_SOUND4_PVCHANRATE		"pvchanrate"
+#define SNDST_DSPS_SOUND4_PVCHANFORMAT		"pvchanformat"
 #define SNDST_DSPS_SOUND4_RVCHAN		"rvchan"
+#define SNDST_DSPS_SOUND4_RVCHANRATE		"rvchanrate"
+#define SNDST_DSPS_SOUND4_RVCHANFORMAT		"rvchanformat"
 #define SNDST_DSPS_SOUND4_CHAN_INFO		"channel_info"
 #define SNDST_DSPS_SOUND4_CHAN_NAME		"name"
 #define SNDST_DSPS_SOUND4_CHAN_PARENTCHAN	"parentchan"