Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UCM for Behringer UMC204HD broken #177

Closed
gregory112 opened this issue Jun 24, 2022 · 40 comments
Closed

UCM for Behringer UMC204HD broken #177

gregory112 opened this issue Jun 24, 2022 · 40 comments

Comments

@gregory112
Copy link

gregory112 commented Jun 24, 2022

This is related: #128.
I came from this issue I filed in Pipewire: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2471.

So previously a while back, Behringer UMC204HD was detected as a single stereo input channel. This sound card has two inputs. However, just recently, the channel was separated into two mono channels, which was perfect. However, with the most recent update (I don't know if it's pipewire, pipewire-alsa, alsa-card-profiles, or alsa-ucm), it reverted back into the stereo single input (left/right) mode. What can I do to bring back the previous correct settings (apart from the bugs I filed in Pipewire)? I did not modify any ALSA UCM files.

Previously, a while back: it is detected as UMC204HD 192k (stereo input).
Then: UMC204HD 192k Line 1 (mono) and UMC204HD 192k Line 2 (mono) (this is how it's supposed to be, I think it's from the pull request above).
Now: Back to UMC204HD 192k (stereo input).

Might also be helpful but I am using pipewire. This is the output of alsaucm listcards:

ALSA lib ucm_subs.c:799:(uc_mgr_get_substituted_value) variable '${var:DirectCardName}' is not defined in this context!
ALSA lib main.c:1541:(snd_use_case_mgr_open) error: failed to import hw:2 use case configuration -22
ALSA lib parser.c:2957:(uc_mgr_scan_master_configs) Unable to open '-hw:2': Invalid argument
alsaucm: error failed to get card list: Invalid argument

There is an error for hw:2, which I assume is the Behringer. Here is the result of alsaucm -chw:2 dump text.

ALSA lib ucm_subs.c:799:(uc_mgr_get_substituted_value) variable '${var:DirectCardName}' is not defined in this context!
ALSA lib main.c:1541:(snd_use_case_mgr_open) error: failed to import hw:2 use case configuration -22
alsaucm: error failed to open sound card hw:2: Invalid argument
@gregory112
Copy link
Author

I tested using the newest ALSA UCM from master branch and everything went back to normal. I guess the issue is fixed in this commit 2cc5a68

@maru-sama
Copy link

Hello,

I seem to have the same issue but in my case using the master branch does not solve the issue. While it fixed the error mentioned above I now get no mixer for this device and init fails. I am running libasound version 1.2.7 and ucm HEAD from git.

The error I get is the following..

un 24 14:55:49 arthur kernel: usb 1-4: clock source 41 is not valid, cannot use
Jun 24 14:55:49 arthur wireplumber[2077]: Unable to load mixer: No such file or directory
Jun 24 14:55:49 arthur wireplumber[2077]: Failed to find a working mixer device (_ucm000D.default:U192k).
Jun 24 14:55:49 arthur wireplumber[2077]: Unable to load mixer: No such file or directory
Jun 24 14:55:49 arthur wireplumber[2077]: Failed to find a working mixer device (_ucm000D.default:U192k).
Jun 24 14:55:49 arthur wireplumber[2077]: Unable to load mixer: No such file or directory
Jun 24 14:55:49 arthur wireplumber[2077]: Failed to find a working mixer device (_ucm000D.default:U192k).
Jun 24 14:55:49 arthur wireplumber[2077]: Unable to load mixer: No such file or directory
Jun 24 14:55:49 arthur wireplumber[2077]: Failed to find a working mixer device (_ucm000D.default:U192k).
Jun 24 14:55:49 arthur wireplumber[2077]: Unable to load mixer: No such file or directory
Jun 24 14:55:49 arthur wireplumber[2077]: Unable to load mixer: No such file or directory
Jun 24 14:55:49 arthur wireplumber[2077]: Unable to load mixer: No such file or directory
Jun 24 14:55:49 arthur wireplumber[2077]: Unable to load mixer: No such file or directory
Jun 24 14:55:49 arthur pipewire[2074]: ALSA lib pcm_direct.c:1332:(snd1_pcm_direct_initialize_slave) unable to install hw params
Jun 24 14:55:49 arthur pipewire[2074]: ALSA lib pcm_dshare.c:711:(snd_pcm_dshare_open) unable to initialize slave
Jun 24 14:55:49 arthur pipewire[2074]: spa.alsa: '_ucm000D.umc204hd_stereo_out:U192k,0,0,1': playback open failed: No such device or address
Jun 24 14:55:49 arthur pipewire[2074]: mod.adapter: 0x5621ac5a9b10: can't get format: No such device or address
Jun 24 14:55:49 arthur pipewire[2074]: mod.adapter: usage: node.name=<string>
Jun 24 14:55:49 arthur kernel: usb 1-4: clock source 41 is not valid, cannot use
Jun 24 14:55:49 arthur kernel: usb 1-4: clock source 41 is not valid, cannot use

amixer also does not show any mixer device

@maru-sama
Copy link

alsaucm dump text seems to show the mixer though...

Verb.HiFi {
	Comment Default
	Device.Line1 {
		Comment "Line A"
		Values {
			CaptureCTL "_ucm0001.hw:U192k"
			PlaybackCTL "_ucm0001.hw:U192k"
			PlaybackChannels 2
			PlaybackMixer "_ucm0001.default:U192k"
			PlaybackMixerElem "Line A"
			PlaybackPCM "_ucm0001.umc204hd_stereo_out:U192k,0,0,1"
			PlaybackPriority 200
		}
	}
	Device.Line2 {
		Comment "Line B"
		Values {
			CaptureCTL "_ucm0001.hw:U192k"
			PlaybackCTL "_ucm0001.hw:U192k"
			PlaybackChannels 2
			PlaybackMixer "_ucm0001.default:U192k"
			PlaybackMixerElem "Line B"
			PlaybackPCM "_ucm0001.umc204hd_stereo_out:U192k,0,2,3"
			PlaybackPriority 100
		}
	}
	Device.Mic1 {
		Comment "Input 1"
		Values {
			CaptureCTL "_ucm0001.hw:U192k"
			CaptureChannels 1
			CaptureMixer "_ucm0001.default:U192k"
			CaptureMixerElem "Input 1"
			CapturePCM "_ucm0001.umc204hd_mono_in:U192k,0,0"
			CapturePriority 200
			PlaybackCTL "_ucm0001.hw:U192k"
		}
	}
	Device.Mic2 {
		Comment "Input 2"
		Values {
			CaptureCTL "_ucm0001.hw:U192k"
			CaptureChannels 1
			CaptureMixer "_ucm0001.default:U192k"
			CaptureMixerElem "Input 2"
			CapturePCM "_ucm0001.umc204hd_mono_in:U192k,0,1"
			CapturePriority 100
			PlaybackCTL "_ucm0001.hw:U192k"
		}
	}
}
Verb.Direct {
	Comment "Direct UMC204HD 192k"
	Device.Direct {
		Comment "Direct UMC204HD 192k"
		Values {
			CaptureCTL "_ucm0001.hw:U192k"
			CaptureChannels 2
			CapturePCM "_ucm0001.hw:U192k"
			CapturePriority 1000
			PlaybackCTL "_ucm0001.hw:U192k"
			PlaybackChannels 4
			PlaybackPCM "_ucm0001.hw:U192k"
			PlaybackPriority 1000
		}
	}
}

@perexg
Copy link
Member

perexg commented Jun 24, 2022

Could you attach stderr output from `strace amixer -D hw:U192k contents' ?

@gregory112 gregory112 reopened this Jun 24, 2022
@maru-sama
Copy link

Here is the output, hope it helps.
out.txt
t

@maru-sama
Copy link

please note this is with the ucm2 profile enabled

@maru-sama
Copy link

Please note I use pipewire and wireplumber in my setup here.

@maru-sama
Copy link

Ok, I think I found something...

When opening without ucm2

newfstatat(AT_FDCWD, "/usr/share/alsa/alsa.conf", {st_mode=S_IFREG|0644, st_size=10117, ...}, 0) = 0
openat(AT_FDCWD, "/dev/snd/controlC1", O_RDONLY|O_CLOEXEC) = 3
ioctl(3, SNDRV_CTL_IOCTL_CARD_INFO, 0x7ffed9ee1550) = 0
close(3)                                = 0

In this case controlC1 gets opened..

with ucm

enat(AT_FDCWD, "/var/lib/alsa/card1.conf.d/ctl-remap.conf", O_RDONLY) = 13
newfstatat(13, "", {st_mode=S_IFREG|0644, st_size=894, ...}, AT_EMPTY_PATH) = 0
read(13, "ctl.default {\n\t@args.0 CARD\n\t@ar"..., 4096) = 894                                     
read(13, "", 4096)                      = 0
close(13)                               = 0
openat(AT_FDCWD, "/dev/snd/controlC2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/dev/aloadC2", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/dev/snd/controlC3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/dev/aloadC3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

In this case controlC1 is not even tried it is starting from C2 which obviously does not exist.

@perexg
Copy link
Member

perexg commented Jun 24, 2022

Could you show the full strace ?

@maru-sama
Copy link

Hi,
Attached you will find a working strace without UCM and a broken strace with UCM
broken.txt
working.txt

@maru-sama
Copy link

Ok, I guess that's not the issue, there is something else happening in the UCM case.

@perexg
Copy link
Member

perexg commented Jun 24, 2022

openat(AT_FDCWD, "/dev/snd/controlC1", O_RDWR|O_CLOEXEC) = 3
ioctl(3, SNDRV_CTL_IOCTL_PVERSION, 0x7ffdc51caa8c) = 0
fcntl(3, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK|O_LARGEFILE) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_LIST, 0x7ffdc51cae90) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_LIST, 0x7ffdc51cae90) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_INFO, 0x7ffdc51cab50) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_READ, 0x7ffdc51c9ee0) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_INFO, 0x7ffdc51cab50) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_READ, 0x7ffdc51c9ee0) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_INFO, 0x7ffdc51cab50) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_READ, 0x7ffdc51c9ed0) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_READ, 0x7ffdc51c9ee0) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_INFO, 0x7ffdc51cab50) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_READ, 0x7ffdc51c9ed0) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_READ, 0x7ffdc51c9ee0) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_INFO, 0x7ffdc51cab50) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_READ, 0x7ffdc51c9ee0) = 0
ioctl(3, SNDRV_CTL_IOCTL_ELEM_INFO, 0x7ffdc51ca970) = -1 ENOENT (No such file or directory)

This is the issue. Could you attach the /var/lib/alsa/card1.conf.d/ctl-remap.conf file ?

@maru-sama
Copy link

Here the ctl_remap file that's generated for the device
ctl-remap.conf.txt

@perexg
Copy link
Member

perexg commented Jun 24, 2022

It seems that the driver offers different control names:

  • "PCM Playback Volume" instead "UMC204HD 192k Output Playback Volume"
  • "PCM Playback Switch" instead "UMC204HD 192k Output Playback Switch"

Could you change those names in configuration (UMC204HD-HiFi.conf file) if things will work?

@maru-sama
Copy link

I am not finding this in the conf file, could you explain this in more detail?

@maru-sama
Copy link

Ok, I made the change to the file and the ctl file now looks like this....
ctl-remap.conf.txt

but I still get the same error

@maru-sama
Copy link

I do not understand this...
amixer -D hw:U192k controls shows

numid=7,iface=CARD,name='Internal Validity'
numid=3,iface=MIXER,name='PCM Playback Switch'
numid=4,iface=MIXER,name='PCM Playback Switch',index=1
numid=5,iface=MIXER,name='PCM Playback Volume'
numid=6,iface=MIXER,name='PCM Playback Volume',index=1
numid=8,iface=MIXER,name='Mic Capture Switch'
numid=9,iface=MIXER,name='Mic Capture Switch',index=1
numid=10,iface=MIXER,name='Mic Capture Volume'
numid=11,iface=MIXER,name='Mic Capture Volume',index=1
numid=2,iface=PCM,name='Capture Channel Map'
numid=1,iface=PCM,name='Playback Channel Map'

So yes "PCM Playback" is correct, but for whatever reason this still does not work

@maru-sama
Copy link

Ok,

I made it work by switching around the SRC and DST in the file. I can now select between the outputs and inputs. Please see the attached file as an example. Why do I need to switch this around though?
ctl-remap.conf.txt

perexg added a commit that referenced this issue Jun 25, 2022
The Dst and Src macro arguments were improperly used. Switch them.

BugLink: #177
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
perexg added a commit that referenced this issue Jun 25, 2022
The USB driver has two variants for the PCM control
names:

  UMC204HD 192k Output Playback Switch / Volume
    and
  PCM Playback Switch / Volume

BugLink: #177
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
@perexg
Copy link
Member

perexg commented Jun 25, 2022

Oops, it's my fault. I switched the argument use in common/ctl/remap.conf macro. Thank you for tests. Could you retest with the current master tree (above two commits) ?

@maru-sama
Copy link

Hello,

I tested it with this and it works better. alsamixer now no longer fails, BUT I have a different issue now. When I initially connect the device I see the following errors...

un 25 09:28:11 arthur pipewire[4627]: ALSA lib pcm_direct.c:1332:(snd1_pcm_direct_initialize_slave) unable to install hw params
Jun 25 09:28:11 arthur pipewire[4627]: ALSA lib pcm_dshare.c:711:(snd_pcm_dshare_open) unable to initialize slave
Jun 25 09:28:11 arthur kernel: usb 1-4: clock source 41 is not valid, cannot use
Jun 25 09:28:11 arthur pipewire[4627]: spa.alsa: '_ucm0008.umc204hd_stereo_out:U192k,0,2,3': playback open failed: No such device or address
Jun 25 09:28:11 arthur pipewire[4627]: mod.adapter: 0x55a690762300: can't get format: No such device or address
Jun 25 09:28:11 arthur pipewire[4627]: mod.adapter: usage: node.name=<string>
Jun 25 09:28:11 arthur kernel: usb 1-4: clock source 41 is not valid, cannot use
Jun 25 09:28:11 arthur pipewire[4627]: ALSA lib pcm_direct.c:1332:(snd1_pcm_direct_initialize_slave) unable to install hw params
Jun 25 09:28:11 arthur pipewire[4627]: ALSA lib pcm_dshare.c:711:(snd_pcm_dshare_open) unable to initialize slave
Jun 25 09:28:11 arthur pipewire[4627]: spa.alsa: '_ucm0009.umc204hd_stereo_out:U192k,0,0,1': playback open failed: No such device or address
Jun 25 09:28:11 arthur pipewire[4627]: mod.adapter: 0x55a690762300: can't get format: No such device or address
Jun 25 09:28:11 arthur pipewire[4627]: mod.adapter: usage: node.name=<string>
...

As a result I am not seeing the outputs. If I then change the profile of the card in pavucontrol to "off" and back to "default" the outputs and inputs appear. Could this be a race during init?

@gregory112
Copy link
Author

I haven't got to test it with my own UMC204HD but I did a while back at times see 41 clock source is not valid error, which seems to be a USB issue, as the device is not recognized as audio device. I did some unplug and plugging though (or replacing the USB cable) and it went away. I will see after this if I see those errors with these new commits.

@maru-sama
Copy link

@gregory112 That's a different issue and is driver related, the clock source error is just a warning, but there have been fixes released yesterday for some other issues.
Out of curiosity with the device attached is your computer able to suspend? In my case the device prohibits my notebook from going to standby and I have to unplug it before closing the lid.

@perexg
Copy link
Member

perexg commented Jun 25, 2022

The hw_params issue seems that the driver does not allow to set the requested parameters by the dshare alsa-lib plugin. Could you get some debug logs (more verbose) from pipewire to check which params cannot be installed ?

@maru-sama
Copy link

I am not seeing this issue, the problem apparently seems that pipewire is trying to open the device but then fails for some reason...

[I][00897.994096] spa.alsa     | [      alsa-pcm.c:  514 spa_alsa_open()] 0x562f18dca058: ALSA device open '_ucm0003.umc204hd_stereo_out:U192k,0,2,3' playback
ALSA lib pcm_direct.c:1332:(snd1_pcm_direct_initialize_slave) unable to install hw params
ALSA lib pcm_dshare.c:711:(snd_pcm_dshare_open) unable to initialize slave
[E][00897.995988] spa.alsa     | [      alsa-pcm.c:  516 spa_alsa_open()] '_ucm0003.umc204hd_stereo_out:U192k,0,2,3': playback open failed: No such device or address
[W][00897.996026] mod.adapter  | [       adapter.c:  219 find_format()] 0x562f18dca070: can't get format: No such device or address
[E][00897.996051] mod.adapter  | [module-adapter.c:  283 create_object()] usage: node.name=<string> 
[D][00897.996071] default      | [       private.h:  367 pw_core_resource_errorv()] resource 0x562f18b64460: id:9 seq:265 res:-22 (Invalid argument) msg:"usage: node.name=<string> "
[T][00897.996097] mod.protocol-native | [module-protocol-:  504 on_server_need_flush()] need flush

@gregory112
Copy link
Author

@maru-sama Yes, just like you, I cannot suspend my laptop if the sound card is still connected.

@gregory112
Copy link
Author

@maru-sama I actually did see your issue for a while, in which plugging the interface result in output being not detected, which I thought was related with the clock errors. I thought it was related to the USB connection, as I don't really see this issue anymore. I did actually change my USB cable, and try to just plug and unplug the interface. I really haven't seen this issue for a while, plugging the interface directly I can use it immediately without having to change profiles.

I haven't updated my UCM to the latest commits created by this issue though, did this issue happen after the latest commit, or happen even before?

@maru-sama
Copy link

@gregory112 I just got my device this friday so I never tried with an older version. That said my firmware is more recent than yours so I am also facing other issues. My main pet peeve is that I cannot turn the device OFF and with my setup (cabling) and the notebook not sleeping with it connected I have to find an alternative for now.
To work around the UCM configuration not working every time I now changed the configuration in pipewire and do all the configuration there. But in the end I would also like go get UCM working.

@gregory112
Copy link
Author

Any way to look for the current version of the firmware that I am using? I haven't used this for a long time actually, few months only, so I cannot say that this one is particularly new or old.

I wonder what "No such device" error mean. I also see it often in pipewire.
spa.alsa: umc204hd_mono_in:U192k,0,0: snd_pcm_drop No such device.

@gregory112
Copy link
Author

Never mind I think it's the bcdDevice parameter that I can look for in dmesg when the device is connected.

[ 4502.947064] usb 3-2: new high-speed USB device number 11 using xhci_hcd
[ 4503.147473] usb 3-2: New USB device found, idVendor=1397, idProduct=0508, bcdDevice= 1.12
[ 4503.147479] usb 3-2: New USB device strings: Mfr=1, Product=3, SerialNumber=0
[ 4503.147482] usb 3-2: Product: UMC204HD 192k
[ 4503.147483] usb 3-2: Manufacturer: BEHRINGER

@maru-sama
Copy link

Yep correct, I was about the reply that as well. I have a new version of the firmware which requires some usb quirks for proper playback but the sleeping issue is there as well. Your firmware should not have any issues with playback cutting out.
@perexg I did a short test regarding the UCM issue yesterday. For testing purposes I added a timeout timeout during the initialization like other audio devices do.
As a result:

  • alsa correctly applied the UCM,
  • I saw no error messages in the logs from pipewire,
  • BUT pavucontrol did not allow me to select any profile for the card

I will test this some more this evening, but could this really be a timing/interaction issue?

@gregory112
Copy link
Author

You are using the 1.35 then? The patch for that has not been merged to upstream it seems, it is tracked in this issue, no? https://bugzilla.kernel.org/show_bug.cgi?id=215934.

@maru-sama
Copy link

Correct, I applied it myself for my current kernel.

@perexg
Copy link
Member

perexg commented Jul 1, 2022

I cannot judge anything without logs. Maybe spa-acp-tool -vvv -c 0 list-profilles may print something. Replace zero number with your alsa card number (aplay -l).

@maru-sama
Copy link

@perexg I forgot to update the issue here. I tried this command two days ago WITHOUT pipewire or wireplumber running and the result was different every time. I saw either one profile or three profiles.
I also saw this in the logs "clock source 41 not valid". To get this interface running without any issues I had to apply https://bugzilla.kernel.org/show_bug.cgi?id=215934 first, which also mentions this.

In the end I changed the audio interface to a motu m4 and I do not have any issues, so I guess it is a driver/firmware related issue with this device.

@gregory112
Copy link
Author

@maru-sama The patches there did not help you then? Do you have any issues with the 204 in Windows?

@maru-sama
Copy link

The quirks For the Poppinga worked fine. The Others For the click source did Not.

@gregory112
Copy link
Author

As this seems to be driver/firmware issue should we close this issue then?

@maru-sama
Copy link

From my Site yes since the Last commits fixes the ucm Case.

@dyskette
Copy link

dyskette commented Jul 8, 2022

@perexg Hi. Is it possible the fix could be included in Fedora? The latest release 1.2.7.1 has the UMC204HD broken.

@gregory112
Copy link
Author

@perexg You submitted two fixes, the direct card name and the mixer, and the direct card name one I think affects multiple soundcards. This might justify creating release 1.2.7.2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants