git: 810530aa2648 - main - sound: Add device status string to sndstat nvlist

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

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

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

    sound: Add device status string to sndstat nvlist
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 days
    Reviewed by:    dev_submerge.ch
    Differential Revision:  https://reviews.freebsd.org/D46163
---
 share/man/man4/sndstat.4    | 6 +++++-
 sys/dev/sound/pcm/sndstat.c | 1 +
 sys/sys/sndstat.h           | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/share/man/man4/sndstat.4 b/share/man/man4/sndstat.4
index 2af0619961d8..eca1e391f130 100644
--- a/share/man/man4/sndstat.4
+++ b/share/man/man4/sndstat.4
@@ -29,7 +29,7 @@
 .\"
 .\" Note: The date here should be updated whenever a non-trivial
 .\" change is made to the manual page.
-.Dd June 5, 2024
+.Dd July 26, 2024
 .Dt SNDSTAT 4
 .Os
 .Sh NAME
@@ -74,6 +74,7 @@ dsps (NVLIST ARRAY): 1
 		max_chn (NUMBER): 2
 	provider_info (NVLIST):
 		unit (NUMBER): 0
+		status (STRING): on hdaa0
 		bitperfect (BOOL): FALSE
 		pvchan (NUMBER): 1
 		rvchan (NUMBER): 0
@@ -169,6 +170,9 @@ provider, there are a number of name/value pairs inside this field:
 .Bl -tag -width ".Dv channel_info"
 .It Dv unit
 Sound card unit.
+.It Dv status
+Status string.
+Usually reports the driver the device is attached on.
 .It Dv bitperfect
 Whether the sound card has bit-perfect mode enabled.
 .It Dv pvchan
diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index 753531f3694e..fda7a2ad6d48 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -440,6 +440,7 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 
 	nvlist_add_number(sound4di, SNDST_DSPS_SOUND4_UNIT,
 			device_get_unit(d->dev)); // XXX: I want signed integer here
+	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);
diff --git a/sys/sys/sndstat.h b/sys/sys/sndstat.h
index 6fef6502ec89..2f2965bb3d05 100644
--- a/sys/sys/sndstat.h
+++ b/sys/sys/sndstat.h
@@ -70,6 +70,7 @@ struct sndstioc_nv_arg {
  */
 #define SNDST_DSPS_SOUND4_PROVIDER		"sound(4)"
 #define SNDST_DSPS_SOUND4_UNIT			"unit"
+#define SNDST_DSPS_SOUND4_STATUS		"status"
 #define SNDST_DSPS_SOUND4_BITPERFECT		"bitperfect"
 #define SNDST_DSPS_SOUND4_PVCHAN		"pvchan"
 #define SNDST_DSPS_SOUND4_RVCHAN		"rvchan"