Bug 279787 - Can't select SPDIF input of USB sound card with 14.x
Summary: Can't select SPDIF input of USB sound card with 14.x
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 14.1-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Christos Margiolis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-16 12:10 UTC by Felix J. Ogris
Modified: 2025-02-25 11:55 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Felix J. Ogris 2024-06-16 12:10:20 UTC
I am no longer able to select "pcm2" (which is SPDIF input on my USB sound card) nor "line2" as recording source on 14.1-R (nor 14.0-R). mixer(8) does not report these input sources anymore:

# mixer
pcm0:mixer: <vendor 0x0d8c USB Sound Device> on uaudio0 (play/rec) (default)
    vol       = 0.75:0.75     pbk
    pcm       = 0.75:0.75     pbk
    line      = 0.75:0.75     rec
    mic       = 0.25:0.25     rec src

Trying to set pcm as recsrc:

# mixer pcm.recsrc=set
mixer: pcm.recsrc=set: Operation not supported by device

usbconfig and /dev/sndstat:

# usbconfig 
...
ugen0.3: <CM106 Like Sound Device C-Media Electronics, Inc.> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (500mA)

# cat /dev/sndstat
Installed devices:
pcm0: <vendor 0x0d8c USB Sound Device> (play/rec) default
No devices installed from userspace.

I already tried setting usb quirk UQ_AU_SET_SPDIF_CM6206 during runtime and in loader.conf as suggested on the forum.
Various external USB sound cards from different vendors show that same behaviour.


On another host running 13.3 from memstick:

# mixer -h
usage: mixer [-f device] [-s | -S] [dev [+|-][voll[:[+|-]volr]] ...
       mixer [-f device] [-s | -S] recsrc ...
       mixer [-f device] [-s | -S] {^|+|-|=}rec rdev ...
 devices: vol, pcm, line, mic
 rec devices: line, mic, pcm2, line1
# mixer =rec pcm2
# mixer recsrc
Recording source: pcm2

# usbconfig
...
ugen0.10: <vendor 0x0d8c USB Sound Device> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (500mA)

# cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC257 (Analog 2.0+HP/2.0)> (play/rec) default
pcm1: <Realtek ALC257 (Right Analog Mic)> (rec)
pcm2: <Intel Kaby Lake (HDMI/DP 8ch)> (play)
pcm3: <USB audio> (play/rec)
No devices installed from userspace.

# sysctl hw.snd.default_unit
hw.snd.default_unit: 3
Comment 1 Christos Margiolis freebsd_committer freebsd_triage 2025-01-17 18:47:11 UTC
So, we first need to figure out whether that's a regression in mixer(8). On the 14.* machine, could you install the pre-FreeBSD-14 mixer(8) from the ports and post its output?

# pkg install freebsd-13-mixer
$ /usr/local/sbin/mixer
Comment 2 Felix J. Ogris 2025-01-17 20:08:44 UTC
Thank a lot! freebsd-13-mixer works as expected:

# /usr/local/sbin/mixer
Mixer vol      is currently set to  80:80
Mixer pcm      is currently set to  80:80
Mixer line     is currently set to  80:80
Mixer mic      is currently set to  80:80
Recording source: line

# /usr/local/sbin/mixer -h
usage: mixer [-f device] [-s | -S] [dev [+|-][voll[:[+|-]volr]] ...
       mixer [-f device] [-s | -S] recsrc ...
       mixer [-f device] [-s | -S] {^|+|-|=}rec rdev ...
 devices: vol, pcm, line, mic
 rec devices: line, mic, pcm2, line1

# /usr/local/sbin/mixer =rec pcm2
Recording source: pcm2

# /usr/local/sbin/mixer
Mixer vol      is currently set to  80:80
Mixer pcm      is currently set to  80:80
Mixer line     is currently set to  80:80
Mixer mic      is currently set to  80:80
Recording source: pcm2
Comment 3 Christos Margiolis freebsd_committer freebsd_triage 2025-01-19 10:46:02 UTC
(In reply to Felix J. Ogris from comment #2)
Hmm, new mixer(8)'s behavior definitely isn't correct, but the old one's doesn't seem correct either. I think we should be printing the recording sources in the default output as well.

I'll write on a patch to address this.
Comment 4 Christos Margiolis freebsd_committer freebsd_triage 2025-01-19 10:47:03 UTC
(In reply to Christos Margiolis from comment #3)
I meant that I do not quite understand why "line1" and "pcm2" are not printed.
Comment 5 Christos Margiolis freebsd_committer freebsd_triage 2025-01-30 17:59:05 UTC
Could you apply the following patch to mixer(3), re-compile it, and test whether you get the desired behavior?

https://reviews.freebsd.org/D48730
Comment 6 Felix J. Ogris 2025-02-01 06:39:27 UTC
I can select pcm2 or line1 as recording source now:

# /usr/sbin/mixer lin1.recsrc=set
mixer: lin1: no such device
pcm0:mixer: <vendor 0x0d8c USB Sound Device> on uaudio0 (play/rec) (default)
    vol       = 0.00:0.00     pbk
    pcm       = 0.00:0.00     pbk
    line      = 0.80:0.80     rec
    mic       = 0.80:0.80     rec
    pcm2      = 0.00:0.00     rec src
    line1     = 0.00:0.00     rec

# /usr/sbin/mixer pcm2.recsrc=set
pcm2.recsrc: remove -> add
pcm0:mixer: <vendor 0x0d8c USB Sound Device> on uaudio0 (play/rec) (default)
    vol       = 0.00:0.00     pbk
    pcm       = 0.00:0.00     pbk
    line      = 0.80:0.80     rec
    mic       = 0.80:0.80     rec
    pcm2      = 0.00:0.00     rec src
    line1     = 0.00:0.00     rec

# /usr/sbin/mixer -o
vol.volume=0.00:0.00
vol.mute=off
pcm.volume=0.00:0.00
pcm.mute=off
line.volume=0.80:0.80
line.mute=off
mic.volume=0.80:0.80
mic.mute=off
pcm2.volume=0.00:0.00
pcm2.mute=off
pcm2.recsrc=add
line1.volume=0.00:0.00
line1.mute=off

But I can't adjust the volume for pcm2 nor line1, but for line:

# /usr/sbin/mixer line1.volume=0.8
mixer: line1.volume=0.80:0.80: Device not configured
pcm0:mixer: <vendor 0x0d8c USB Sound Device> on uaudio0 (play/rec) (default)
    vol       = 0.00:0.00     pbk
    pcm       = 0.00:0.00     pbk
    line      = 0.80:0.80     rec
    mic       = 0.80:0.80     rec
    pcm2      = 0.00:0.00     rec src
    line1     = 0.00:0.00     rec
# /usr/sbin/mixer pcm2.volume=0.8
mixer: pcm2.volume=0.80:0.80: Device not configured
pcm0:mixer: <vendor 0x0d8c USB Sound Device> on uaudio0 (play/rec) (default)
    vol       = 0.00:0.00     pbk
    pcm       = 0.00:0.00     pbk
    line      = 0.80:0.80     rec
    mic       = 0.80:0.80     rec
    pcm2      = 0.00:0.00     rec src
    line1     = 0.00:0.00     rec
# /usr/sbin/mixer line.volume=0.5
line.volume: 0.80:0.80 -> 0.50:0.50
pcm0:mixer: <vendor 0x0d8c USB Sound Device> on uaudio0 (play/rec) (default)
    vol       = 0.00:0.00     pbk
    pcm       = 0.00:0.00     pbk
    line      = 0.50:0.50     rec
    mic       = 0.80:0.80     rec
    pcm2      = 0.00:0.00     rec src
    line1     = 0.00:0.00     rec


Binary and libraries:

# ldd /usr/sbin/mixer
/usr/sbin/mixer:
        libmixer.so.5 => /usr/lib/libmixer.so.5 (0x2bafeff6a000)
        libc.so.7 => /lib/libc.so.7 (0x2baff1b6f000)
        [vdso] (0x2bafeea1f000)
# ls -la /usr/lib/libmixer*
-r--r--r--  1 root wheel 26410 Dec  7 15:37 /usr/lib/libmixer.a
lrwxr-xr-x  1 root wheel    13 Feb 24  2024 /usr/lib/libmixer.so -> libmixer.so.5
-rwxr-xr-x  1 root wheel 14232 Feb  1 07:14 /usr/lib/libmixer.so.5
-r--r--r--  1 root wheel 11992 Dec  7 15:36 /usr/lib/libmixer.so.5.orig
Comment 7 Christos Margiolis freebsd_committer freebsd_triage 2025-02-01 09:59:43 UTC
Volume setting on these devices is not possible because these devices are detected as recording-only. Does it work with the old mixer?
Comment 8 Christos Margiolis freebsd_committer freebsd_triage 2025-02-01 10:02:10 UTC
(In reply to Christos Margiolis from comment #7)
Sorry, I worded that poorly: these devices actually are _not_ provided with a volume control, from the kernel module itself.
Comment 9 Felix J. Ogris 2025-02-01 13:40:05 UTC
freebsd-13-mixer doesn't display the volume level for the recording sources. I am not sure if this has always been the case, and I don't have a box running 13 anymore. But besides this, it works:

# /usr/local/sbin/mixer 
Mixer vol      is currently set to   0:0
Mixer pcm      is currently set to   0:0
Mixer line     is currently set to  50:50
Mixer mic      is currently set to  80:80
Recording source: line1

# /usr/local/sbin/mixer =rec pcm2
Recording source: pcm2

# /usr/local/sbin/mixer
Mixer vol      is currently set to   0:0
Mixer pcm      is currently set to   0:0
Mixer line     is currently set to  50:50
Mixer mic      is currently set to  80:80
Recording source: pcm2

Verification with mixer from base:

# /usr/sbin/mixer 
pcm0:mixer: <vendor 0x0d8c USB Sound Device> on uaudio0 (play/rec) (default)
    vol       = 0.00:0.00     pbk
    pcm       = 0.00:0.00     pbk
    line      = 0.50:0.50     rec
    mic       = 0.80:0.80     rec
    pcm2      = 0.00:0.00     rec src
    line1     = 0.00:0.00     rec

Thanks a lot.
Comment 10 Christos Margiolis freebsd_committer freebsd_triage 2025-02-01 13:46:12 UTC
The old mixer works essentially the same way as the new one, in that it lists the devices which have a software volume control, hence why you see "line1" separately. This has always been the case indeed, and my guess is that trying to change the volume of "line1" will also result in an error with the old mixer as well. I don't think there's something wrong here necessarily.
Comment 11 Christos Margiolis freebsd_committer freebsd_triage 2025-02-01 13:48:13 UTC
To add to this: the mixer _does_ display the volume of recording sources, again, if they have a software control. It just so happens that this is not the case with your particular device. For example, mine does come with a volume control:

pcm0:mixer: <Realtek ALC257 (Analog 2.0+HP/2.0)> on hdaa0 (play/rec) (default)
    vol       = 0.82:0.82     pbk
    pcm       = 1.00:1.00     pbk
    speaker   = 1.00:1.00     pbk
    rec       = 0.70:0.70     pbk
    ogain     = 1.00:1.00     pbk
    monitor   = 0.50:0.50     rec src

In other words, I think the patch should solve the issue. I will close the report once it's committed.
Comment 12 Felix J. Ogris 2025-02-01 13:52:25 UTC
You're totally right:

# /usr/local/sbin/mixer line 60
Setting the mixer line from 50:50 to 60:60.

# /usr/local/sbin/mixer line1 60
mixer: unknown device: line1

Same for pcm2.
Comment 13 Christos Margiolis freebsd_committer freebsd_triage 2025-02-01 13:53:07 UTC
(In reply to Felix J. Ogris from comment #12)
Great. :-)
Comment 14 commit-hook freebsd_committer freebsd_triage 2025-02-25 11:49:03 UTC
A commit in branch main references this bug:

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

commit f121de8fbcbc8aa82f9fb59039c502406b7c88b6
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2025-02-25 11:44:49 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2025-02-25 11:44:49 +0000

    mixer(3): Do not skip devices with no volume control

    Some devices might not have a software volume control, but still be
    able to be set as recording sources.

    PR:             279787
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Reviewed by:    emaste
    Differential Revision:  https://reviews.freebsd.org/D48730

 lib/libmixer/mixer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)