ALSA Names - udev call for help [SOLVED!]

The ALSA developers in their wisdom have changed the naming convention of USB MIDI devices. Previously the alsa device name was likely to be unique (although not guaranteed). Since the change (around a couple of years ago) they seem to concatenate the device name and the endpoint name, e.g. “Launchkey Mini MK3 Launchkey Mini MK3 MIDI” which can result in a name longer than the max. 31 characters. For some devices (like the Launchkey) that results in its ports being indistinguisable, e.g.

Launchkey Mini MK3 Launchkey Mini MK3 MIDI -> Launchkey Mini MK3 Launchkey Mi
Launchkey Mini MK3 Launchkey Mini MK3 DAW -> Launchkey Mini MK3 Launchkey Mi

This is a problem because we cannot distinguish between these interfaces and worse - a2jd (that we use to present these ALSA MIDI ports to jack) fails for the second port so we only see one. Other ways of presenting the ports (e.g. jack options -X raw & -X seq) do not give identifiable names, e.g. “capture 1”.

These changes were made to ALSA about two years ago and the development team there don’t seem to be concerned about it so we may need to find a solution in userspace or recompile the kernel modules. We will try these approaches and also lobby our friends over at ALSA but I would like help from anyone who can manipulate devices, e.g. via udev rules.

I am not an udev expert and have not managed to implement any rules that work. What I would like to do is detect the device endpoint names and use this as the device name before the alsa driver binds the interface so that alsa uses the new name.

Is there anyone who can help with this? Please? :heart:

[Edit] It is actually more likely the linux kenel rather than alsa that is to blame for this. This may limit our ability to use udev but I still hold hope…

3 Likes

For what it’s worth, I did some tests with an Akai LPD8.

Originally it registers as :

$ udevadm monitor -p
UDEV  [2985.173265] change   /devices/platform/axi/1000120000.pcie/1f00200000.usb/xhci-hcd.0/usb1/1-1/1-1:1.0/sound/card0 (sound)
ACTION=change
DEVPATH=/devices/platform/axi/1000120000.pcie/1f00200000.usb/xhci-hcd.0/usb1/1-1/1-1:1.0/sound/card0
SUBSYSTEM=sound
SYNTH_UUID=0
SEQNUM=9004
USEC_INITIALIZED=2985150105
ID_PATH=platform-xhci-hcd.0-usb-0:1:1.0
ID_PATH_TAG=platform-xhci-hcd_0-usb-0_1_1_0
ID_FOR_SEAT=sound-platform-xhci-hcd_0-usb-0_1_1_0
SOUND_INITIALIZED=1
ID_VENDOR_FROM_DATABASE=AKAI  Professional M.I. Corp.
ID_BUS=usb
ID_MODEL=LPD8
ID_MODEL_ENC=LPD8
ID_MODEL_ID=0075
ID_SERIAL=AKAI_professional_LLC_LPD8
ID_VENDOR=AKAI_professional_LLC
ID_VENDOR_ENC=AKAI\x20professional\x20LLC
ID_VENDOR_ID=09e8
ID_REVISION=0100
ID_TYPE=audio
ID_USB_MODEL=LPD8
ID_USB_MODEL_ENC=LPD8
ID_USB_MODEL_ID=0075
ID_USB_SERIAL=AKAI_professional_LLC_LPD8
ID_USB_VENDOR=AKAI_professional_LLC
ID_USB_VENDOR_ENC=AKAI\x20professional\x20LLC
ID_USB_VENDOR_ID=09e8
ID_USB_REVISION=0100
ID_USB_TYPE=audio
ID_USB_INTERFACES=:010100:010300:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=snd-usb-audio
ID_ID=usb-AKAI_professional_LLC_LPD8-00
TAGS=:seat:
CURRENT_TAGS=:seat:

I added a new udev rule to rename attributes:

ENV{ID_VENDOR_ID}=="09e8", ENV{ID_MODEL_ID}=="0075", ENV{ID_MODEL}="toto", ENV{ID_MODEL_ENC}="titi", ENV{ID_USB_MODEL}="tata", ENV{ID_USB_MODEL_ENC}="tutu", ENV{ID_USB_VENDOR_ENC}="bobo", ENV{ID_VENDOR_ENC}="bibi", ENV{ID_SERIAL}="baba", ENV{ID_VENDOR}="bubu", ENV{ID_VENDOR_FROM_DATABASE}="koko"

and now it registers as:

UDEV  [2819.570182] change   /devices/platform/axi/1000120000.pcie/1f00200000.usb/xhci-hcd.0/usb1/1-1/1-1:1.0/sound/card0 (sound)
ACTION=change
DEVPATH=/devices/platform/axi/1000120000.pcie/1f00200000.usb/xhci-hcd.0/usb1/1-1/1-1:1.0/sound/card0
SUBSYSTEM=sound
SYNTH_UUID=0
SEQNUM=8398
USEC_INITIALIZED=2819548238
ID_PATH=platform-xhci-hcd.0-usb-0:1:1.0
ID_PATH_TAG=platform-xhci-hcd_0-usb-0_1_1_0
ID_FOR_SEAT=sound-platform-xhci-hcd_0-usb-0_1_1_0
SOUND_INITIALIZED=1
ID_VENDOR_FROM_DATABASE=koko
ID_BUS=usb
ID_MODEL=toto
ID_MODEL_ENC=titi
ID_MODEL_ID=0075
ID_SERIAL=baba
ID_VENDOR=bubu
ID_VENDOR_ENC=bibi
ID_VENDOR_ID=09e8
ID_REVISION=0100
ID_TYPE=audio
ID_USB_MODEL=tata
ID_USB_MODEL_ENC=tutu
ID_USB_MODEL_ID=0075
ID_USB_SERIAL=AKAI_professional_LLC_LPD8
ID_USB_VENDOR=AKAI_professional_LLC
ID_USB_VENDOR_ENC=bobo
ID_USB_VENDOR_ID=09e8
ID_USB_REVISION=0100
ID_USB_TYPE=audio
ID_USB_INTERFACES=:010100:010300:
ID_USB_INTERFACE_NUM=00
ID_USB_DRIVER=snd-usb-audio
ID_ID=usb-AKAI_professional_LLC_LPD8-00
TAGS=:seat:
CURRENT_TAGS=:seat:

So the rule seems to work, but I’s not sure it has any impact on alsa names:

$ amidi -l
Dir Device    Name
IO  hw:0,0,0  LPD8 MIDI 1

Thanks @hyves42. I think you are right that this isn’t going to help. I have written some code so that Zynthian uses the device name and port number so we have a way to handle this now.

Cheers!

1 Like

Yes, i think that the current code developed by @riban give us a good isolation from the ALSA naming disaster. I’m happy with this solution, @riban !!

3 Likes

Pipewire! it already does all this detection mlarky. No more faffing with Jack lines.

We await a willing volunteer to port to pipewire!

2 Likes

I should at least get the 64 bit image I suppose…