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

(cherry picked from commit 18d87fe4fe3b310796e138855016678453140423)
This commit is contained in:
Christos Margiolis 2024-01-16 18:46:49 +02:00
parent 8e471fbc7d
commit 626d9b8553
2 changed files with 9 additions and 3 deletions

View file

@ -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,

View file

@ -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);
}