Re: uaudio device re-attach and persisting dev.pcm.$pcm.bitperfect sysctl

From: Christos Margiolis <christos_at_freebsd.org>
Date: Wed, 02 Oct 2024 21:53:45 UTC
Alban Hertroys wrote:
> Meanwhile, several people here suggested that devd is the way to go
> about this. I had actually looked into that a bit, but that seemed to
> require a related device node in /dev, and there’s neither one for pcm
> nor for uaudio, so I discarded that as not being a viable option.
> Perhaps too soon.

Audio device nodes are /dev/dspX, where X is the unit number, which has
a 1-1 relation with the pcmX unit number, so pcm2's device node is
/dev/dsp2.

To clarify some more things, the sound subsystem roughly consists of the
following layers:
- The sound(4) layer, which is the highest-level layer, and among other
  things, is responsible for mixing channels, doing conversions,
  providing some generic functions for sound drivers to use, as well as
  providing a uniform device interface (i.e pcmX).
- The device driver (e.g snd_uaudio(4), snd_hda(4), ...) layer, which is
  responsible for actually communicating with the sound card.

You could visualize it as follows:

some usb card		-> uaudio0	-> pcm0
some other usb card	-> uaudio1	-> pcm1
some intel card		-> hdaa0	-> pcm2

>
> [...]
>
> I can see devd looking to match uaudio0 and pcm2 devices to several
> names it knows (probably from other devd confs?), but it doesn’t seem
> to match my attempt. Let alone that it got around to attempting to
> parse my sh tidbit.

So in your case, "pcm2" is a generic name given to the device by
sound(4) and "uaudio0" is the name of the driver this device is using,
but the actual device node is /dev/dsp2.

What I think is confusing is that sound(4) names devices as "pcm", but
creates the nodes as "dsp"... Maybe I should propose a patch to get rid
of this scheme, and simply name them everywhere as either "pcm", "dsp",
or something else like "snd".

Christos