git: 18d87fe4fe3b - main - snd_uaudio: provide information about the device name and attached driver
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 16 Jan 2024 16:50:04 UTC
The branch main has been updated by christos:
URL: https://cgit.FreeBSD.org/src/commit/?id=18d87fe4fe3b310796e138855016678453140423
commit 18d87fe4fe3b310796e138855016678453140423
Author: Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-01-16 16:46:49 +0000
Commit: Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-01-16 16:46:49 +0000
snd_uaudio: provide information about the device name and attached driver
Unlike the other sound drivers, snd_uaudio(4) doesn't provide
information about the device's description and the driver it's attached
to. A side-effect of this is that applications such as mixer(8), that
fetch these strings through the OSS API's SNDCTL_CARDINFO ioctl will
show a USB audio device as:
pcm0:mixer: <USB Audio> at ? kld snd_uaudio
This patch replaces the generic "USB Audio" description with the
device's actual manufacturer and product strings, and the "at ?" string
with the driver it's attached to:
pcm0:mixer: <Focusrite Scarlett Solo USB> at uaudio0 kld snd_uaudio
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D43347
---
sys/dev/sound/usb/uaudio.c | 11 +++++++++--
sys/dev/sound/usb/uaudio_pcm.c | 1 -
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c
index a14cdf805353..3237093bcbfa 100644
--- a/sys/dev/sound/usb/uaudio.c
+++ b/sys/dev/sound/usb/uaudio.c
@@ -1171,7 +1171,7 @@ uaudio_attach_sub(device_t dev, kobj_class_t mixer_class, kobj_class_t chan_clas
{
struct uaudio_softc *sc = device_get_softc(device_get_parent(dev));
unsigned i = uaudio_get_child_index_by_dev(sc, dev);
- char status[SND_STATUSLEN];
+ char status[SND_STATUSLEN], desc[128];
uaudio_mixer_init(sc, i);
@@ -1199,7 +1199,14 @@ uaudio_attach_sub(device_t dev, kobj_class_t mixer_class, kobj_class_t chan_clas
mixer_hwvol_init(dev);
- snprintf(status, sizeof(status), "at ? %s", PCM_KLDSTRING(snd_uaudio));
+ snprintf(desc, sizeof(desc), "%s %s",
+ usb_get_manufacturer(sc->sc_udev),
+ usb_get_product(sc->sc_udev));
+ device_set_desc_copy(dev, desc);
+
+ snprintf(status, sizeof(status), "at %s %s",
+ device_get_nameunit(device_get_parent(dev)),
+ PCM_KLDSTRING(snd_uaudio));
if (pcm_register(dev, sc,
(sc->sc_play_chan[i].num_alt > 0) ? 1 : 0,
diff --git a/sys/dev/sound/usb/uaudio_pcm.c b/sys/dev/sound/usb/uaudio_pcm.c
index 3236e1bd2e5c..bf1f2ebb5e33 100644
--- a/sys/dev/sound/usb/uaudio_pcm.c
+++ b/sys/dev/sound/usb/uaudio_pcm.c
@@ -201,7 +201,6 @@ ua_probe(device_t dev)
(func->func != SCF_PCM)) {
return (ENXIO);
}
- device_set_desc(dev, "USB audio");
return (BUS_PROBE_DEFAULT);
}