git: 0c0bb4c1401c - main - sound: Make sndstat PVCHAN and RVCHAN nvlist parameters bool

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Fri, 25 Apr 2025 16:56:37 UTC
The branch main has been updated by christos:

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

commit 0c0bb4c1401c9696fbb8d0b1fe88990db0e706c8
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2025-04-25 16:55:16 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2025-04-25 16:55:16 +0000

    sound: Make sndstat PVCHAN and RVCHAN nvlist parameters bool
    
    Prior to 02d4eeabfd73 ("sound: Allocate vchans on-demand"), the
    play.vchans and rec.vchans sysctls corresponded to the value of
    d->pvchancount and d->rvchancount respectively, which is also what we
    are exporting through SNDST_DSPS_SOUND4_PVCHAN and
    SNDST_DSPS_SOUND4_RVCHAN respectively. Since that commit, the sysctls
    mentioned have been modified to show whether play/rec vchans are enabled
    or not. Modify the sndstat nvlist parameters accordingly.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D49980
---
 share/man/man4/sndstat.4    | 8 ++++----
 sys/dev/sound/pcm/sndstat.c | 6 ++++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/share/man/man4/sndstat.4 b/share/man/man4/sndstat.4
index 44c3f3152610..8da705502920 100644
--- a/share/man/man4/sndstat.4
+++ b/share/man/man4/sndstat.4
@@ -76,10 +76,10 @@ dsps (NVLIST ARRAY): 1
 		unit (NUMBER): 0
 		status (STRING): on hdaa0
 		bitperfect (BOOL): FALSE
-		pvchan (NUMBER): 1
+		pvchan (BOOL): TRUE
 		pvchanrate (NUMBER): 48000
 		pvchanformat (NUMBER): 0x00000010
-		rvchan (NUMBER): 0
+		rvchan (BOOL): TRUE
 		rvchanrate (NUMBER): 48000
 		rvchanformat (NUMBER): 0x00000010
 		channel_info (NVLIST_ARRAY): 1
@@ -181,13 +181,13 @@ Usually reports the driver the device is attached on.
 .It Dv bitperfect
 Whether the sound card has bit-perfect mode enabled.
 .It Dv pvchan
-Number of playback virtual channels.
+Playback virtual channels enabled.
 .It Dv pvchanrate
 Playback virtual channel sample rate.
 .It Dv pvchanformat
 Playback virtual channel format.
 .It Dv rvchan
-Number of recording virtual channels.
+Recording virtual channels enabled.
 .It Dv rvchanrate
 Recording virtual channel sample rate.
 .It Dv rvchanformat
diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index 33cde235e070..cafd9aff4bdc 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -440,12 +440,14 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 	nvlist_add_string(sound4di, SNDST_DSPS_SOUND4_STATUS, d->status);
 	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_bool(sound4di, SNDST_DSPS_SOUND4_PVCHAN,
+	    d->flags & SD_F_PVCHANS);
 	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_bool(sound4di, SNDST_DSPS_SOUND4_RVCHAN,
+	    d->flags & SD_F_RVCHANS);
 	nvlist_add_number(sound4di, SNDST_DSPS_SOUND4_RVCHANRATE,
 	    d->rvchanrate);
 	nvlist_add_number(sound4di, SNDST_DSPS_SOUND4_RVCHANFORMAT,