# Mapping USB device to PCM device



## jbo (Jan 19, 2022)

How does one map a USB device (showing up via `usbconfig`) to the corresponding PCM device (showing up under `cat /dev/sndstat`)?

I have several USB audio devices plugged into my machine and I am having troubles figuring out which PCM device maps to which USB device. What is the appropriate way of deducing this?


----------



## Logicien (Jan 19, 2022)

I have one usb audio device, it's a Logitech wireless dongle. In /dev/sndstat it is named pcm3 at the end after my integrated analog audio devices. In dmesg it is named uaudio0. If I had an other Usb audio device I suppose it will be named pcm4 and uaudio1 depending on the Usb connector it is plugged to and how the FreeBSD kernel detect Usb devices.

'dmesg | grep -i audio' give me the informations about my Logitech Usb audio receiver and tell me it is pcm3.


----------



## Zare (Jan 19, 2022)

The mapping is available from dmesg.


```
ugen0.2: <Focusrite Scarlett Solo USB> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)
.
.
uaudio0: <Scarlett Solo USB> on usbus0
.
.
pcm4: <USB audio> numa-domain 0 on uaudio0
```


----------



## grahamperrin@ (Feb 12, 2022)

jbodenmann said:


> … (showing up under `cat /dev/sndstat`)?
> 
> I have several USB audio devices plugged into my machine …



For a GUI, I use GTK-Mixer, also known as Audio Mixer, pictured at <https://forums.freebsd.org/posts/556010>.

At the command line, I sometimes run this before connecting a device: 

`tail -f -n 0 /var/log/messages`

Alternatively, tail the log after the event. Headphones plugged in at 02:58, for example: 


```
% cat /dev/sndstat
Installed devices:
pcm0: <ATI R6xx (HDMI)> (play)
pcm1: <IDT 92HD81B1X (Analog 2.0+HP/2.0)> (play/rec) default
pcm2: <IDT 92HD81B1X (Analog)> (play/rec)
pcm3: <USB audio> (rec)
pcm4: <USB audio> (play/rec)
No devices installed from userspace.
% tail -n 44 /var/log/messages
Feb 12 00:20:07 mowa219-gjp4-8570p-freebsd gnome-keyring-daemon[9758]: couldn't allocate secure memory to keep passwords and or keys from being written to the disk
Feb 12 00:35:59 mowa219-gjp4-8570p-freebsd kernel: pid 7403 (VirtualBoxVM), jid 0, uid 1002: exited on signal 5
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: ugen0.10: <SteelSeries SteelSeries Siberia 350> at usbus0
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1 on uhub4
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: <SteelSeries SteelSeries Siberia 350, class 0/0, rev 1.10/2.08, addr 9> on usbus0
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Play[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Play[0]: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Play[0]: 22050 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Play[0]: 16000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Play[0]: 11025 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Play[0]: 8000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Record[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Record[0]: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Record[0]: 22050 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Record[0]: 16000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Record[0]: 11025 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: Record[0]: 8000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: No MIDI sequencer.
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: pcm4: <USB audio> on uaudio1
Feb 12 02:58:52 mowa219-gjp4-8570p-freebsd kernel: uaudio1: HID volume keys found.
Feb 12 07:07:36 mowa219-gjp4-8570p-freebsd kernel: Limiting closed port RST response from 228 to 200 packets/sec
Feb 12 07:12:18 mowa219-gjp4-8570p-freebsd kernel: Limiting closed port RST response from 225 to 200 packets/sec
Feb 12 07:19:52 mowa219-gjp4-8570p-freebsd kernel: Limiting closed port RST response from 288 to 200 packets/sec
Feb 12 07:21:09 mowa219-gjp4-8570p-freebsd kernel: Limiting closed port RST response from 292 to 200 packets/sec
Feb 12 09:14:19 mowa219-gjp4-8570p-freebsd su[42522]: grahamperrin to root on /dev/pts/6
Feb 12 09:41:40 mowa219-gjp4-8570p-freebsd kernel: linux: jid 0 pid 90157 (wfica): unsupported socket(AF_NETLINK, 3, NETLINK_ROUTE)
Feb 12 09:41:40 mowa219-gjp4-8570p-freebsd syslogd: last message repeated 1 times
Feb 12 09:42:26 mowa219-gjp4-8570p-freebsd kernel: linux: jid 0 pid 90007 (wfica): unsupported socket(AF_NETLINK, 3, NETLINK_ROUTE)
Feb 12 09:42:26 mowa219-gjp4-8570p-freebsd syslogd: last message repeated 1 times
Feb 12 09:44:17 mowa219-gjp4-8570p-freebsd kernel: linux: jid 0 pid 98415 (wfica): unsupported socket(AF_NETLINK, 3, NETLINK_ROUTE)
Feb 12 09:44:17 mowa219-gjp4-8570p-freebsd syslogd: last message repeated 1 times
Feb 12 14:41:22 mowa219-gjp4-8570p-freebsd kernel: vboxdrv: XXXXXXXXXXXXXXXX VMMR0.r0
Feb 12 14:41:22 mowa219-gjp4-8570p-freebsd kernel: vboxdrv: XXXXXXXXXXXXXXXX VBoxDDR0.r0
Feb 12 14:41:22 mowa219-gjp4-8570p-freebsd kernel: VMMR0InitVM: eflags=246 fKernelFeatures=0x0 (SUPKERNELFEATURES_SMAP=0)
Feb 12 14:42:38 mowa219-gjp4-8570p-freebsd kernel: pid 94509 (VirtualBoxVM), jid 0, uid 1002: exited on signal 5
Feb 12 14:42:44 mowa219-gjp4-8570p-freebsd kernel: vboxdrv: XXXXXXXXXXXXXXXX VMMR0.r0
Feb 12 14:42:44 mowa219-gjp4-8570p-freebsd kernel: vboxdrv: XXXXXXXXXXXXXXXX VBoxDDR0.r0
Feb 12 14:42:45 mowa219-gjp4-8570p-freebsd kernel: VMMR0InitVM: eflags=246 fKernelFeatures=0x0 (SUPKERNELFEATURES_SMAP=0)
Feb 12 14:45:24 mowa219-gjp4-8570p-freebsd kernel: GEOM_ELI: Crypto request failed (ENOMEM). ada0p3.eli[WRITE(offset=138279436288, length=8192)]
Feb 12 14:45:24 mowa219-gjp4-8570p-freebsd syslogd: last message repeated 1 times
Feb 12 14:45:24 mowa219-gjp4-8570p-freebsd kernel: GEOM_ELI: Crypto request failed (ENOMEM). ada0p3.eli[WRITE(offset=387968700416, length=110592)]
Feb 12 14:45:24 mowa219-gjp4-8570p-freebsd syslogd: last message repeated 1 times
Feb 12 14:45:24 mowa219-gjp4-8570p-freebsd kernel: GEOM_ELI: Crypto request failed (ENOMEM). ada0p3.eli[WRITE(offset=418556280832, length=172032)]
Feb 12 14:45:24 mowa219-gjp4-8570p-freebsd syslogd: last message repeated 625 times
% dmesg | grep -i audio
hdaa0: <ATI R6xx Audio Function Group> at nid 1 on hdacc0
hdaa1: <IDT 92HD81B1X Audio Function Group> at nid 1 on hdacc1
uaudio0 on uhub8
uaudio0: <C-Media Electronics Inc. JPL-500S-USB, class 0/0, rev 1.10/1.00, addr 8> on usbus1
uaudio0: Play[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Play[0]: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 48000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 44100 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: No MIDI sequencer.
pcm3: <USB audio> on uaudio0
uaudio0: HID volume keys found.
uaudio0: at uhub8, port 3, addr 8 (disconnected)
uaudio0: detached
uaudio0 on uhub2
uaudio0: <Realtek USB2.0 MIC> on usbus0
uaudio0: No playback.
uaudio0: Record[0]: 48000 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 44100 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 16000 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 8000 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: No MIDI sequencer.
pcm3: <USB audio> on uaudio0
uaudio0: No HID volume keys found.
hdaa0: <ATI R6xx Audio Function Group> at nid 1 on hdacc0
hdaa1: <IDT 92HD81B1X Audio Function Group> at nid 1 on hdacc1
uaudio0 on uhub4
uaudio0: <Realtek USB2.0 MIC> on usbus0
uaudio0: No playback.
uaudio0: Record[0]: 48000 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 44100 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 16000 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record[0]: 8000 Hz, 2 ch, 24-bit S-LE PCM format, 2x8ms buffer.
uaudio0: No MIDI sequencer.
pcm3: <USB audio> on uaudio0
uaudio0: No HID volume keys found.
uaudio1 on uhub4
uaudio1: <SteelSeries SteelSeries Siberia 350, class 0/0, rev 1.10/2.08, addr 9> on usbus0
uaudio1: Play[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Play[0]: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Play[0]: 22050 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Play[0]: 16000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Play[0]: 11025 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Play[0]: 8000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 22050 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 16000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 11025 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: Record[0]: 8000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio1: No MIDI sequencer.
pcm4: <USB audio> on uaudio1
uaudio1: HID volume keys found.
%
```


----------

