Static Sound Card Names for IC-9700 / IC-7300

After managing to have named symlinks for serial devices for ICOM IC-9700, IC-7300 and IC-705 there was the next challenge to have something similar for sound card device names as at least for the ones in 9700 and 7300 they have the same name that get appended a number. But same as with the serial devices this depends on when and in which order the two (or three) devices are plugged to the computer. Apparently there is no udev/USB option which allows to map a name to a serial number as done for the serial ports.

ALSA

But as at least my 7300 / 9700 are statically connected to my computer and every time on the same port I managed to implement an udev rule that allows for modification of the ALSA short name. The basics for that were found on [1]. The udev rule basically filters the USB device path and changes the id attribute (which is normally something like CODEC1, CODEC2 etc.) if the USB device path matches.

In order to find the USB device path you can simply start:

udevadm monitor --subsystem=sound

and watch the output while you (re-)plug the IC-9700 / IC-7300. This path is to be added to the udev rule. In my case the /etc/udev/rules.d/65-hamradio-trx.rules contains the following lines for my IC-7300 / IC-9700:

# IC-9700 Sound Card
SUBSYSTEM!="sound", GOTO="ic9700_alsa_naming_end"
ACTION!="add", GOTO="ic9700_alsa_naming_end"
DEVPATH=="/devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6.4/1-6.4:1.0/sound/card?", ATTR{id}="IC-9700"
LABEL="ic9700_alsa_naming_end"

# IC-7300 Sound Card
SUBSYSTEM!="sound", GOTO="ic7300_alsa_naming_end"
ACTION!="add", GOTO="ic7300_alsa_naming_end"
DEVPATH=="/devices/pci0000:00/0000:00:14.0/usb1/1-11/1-11.4/1-11.4:1.0/sound/card?", ATTR{id}="IC-7300"
LABEL="ic7300_alsa_naming_end"

After triggering udev to reload the rules or a reboot these ALSA device names are visible. In my case I use ALSA’s sound interface in WSJT-X and can benefit from the ALSA short names while configuring the sound interfaces.

Static ALSA Device Names for IC-7300 / IC-9700
Static ALSA Device Names for IC-7300 / IC-9700

Pulseaudio

Now that ALSA was fixed and I am able to distinguish the various sound devices I needed a similar solution for pulseaudio as both sound system coexist on a running Ubuntu Linux. On [[2]] I found a solution how this could be done with a simple bash/shell command. I tried to implement this to be executed by udev once the sound device is detected but failed as root obviously could not communicate with the pulseaudio daemon running under user rights.

But in [[1]] there was a hint about a second attribute that udev could modify. It needs a separate set of udev rules because this should trigger on cahnge instead of add. The first attempt didn’t work until I discovered that the attribute name has to be SOUND_DESCRIPTION instead of PULSE_NAME. The DEVPATH is the same as used for the ALSA part. These are my rules for IC-9700 and IC-7300. You will likely need to put in the correct device path:

SUBSYSTEM!="sound", GOTO="ic9700_pa_naming_end"
ACTION!="change", GOTO="ic9700_pa_naming_end"
KERNEL!="card*", GOTO="ic9700_pa_naming_end"
DEVPATH=="/devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6.4/1-6.4:1.0/sound/card?", ENV{SOUND_DESCRIPTION}="IC-9700"
LABEL="ic9700_pa_naming_end"

SUBSYSTEM!="sound", GOTO="ic7300_pa_naming_end"
ACTION!="change", GOTO="ic7300_pa_naming_end"
KERNEL!="card*", GOTO="ic7300_pa_naming_end"
DEVPATH=="/devices/pci0000:00/0000:00:14.0/usb1/1-11/1-11.4/1-11.4:1.0/sound/card?", ENV{SOUND_DESCRIPTION}="IC-7300"
LABEL="ic7300_pa_naming_end"

This way for example qsstv can be used with pulseaudio sound devices and the input can be selected by using pavucontrol.

Pavucontrol with Static Device Names for IC-7300 / IC-9700
Pavucontrol with Static Device Names for IC-7300 / IC-9700

Nomally ModemManager probes all /dev/ttyACMx devices for modems. In my case it triggers the PTT of the IC-705 for several seconds after the device is plugged. As today probably nobody needs the ModemManager any more I stopped and disabled it with:

$ systemctl disable ModemManager.service
$ systemctl stop ModemManager.service

That prevents the PTT from being triggered after plugging.

References:

[1] https://gist.github.com/Aishou/f39c2f970c6db20e1845925c5cc0890e
[2] https://x8x.net/2019/04/04/icom-ic-9700-and-ic-7300-coexisting-in-linux/
[3] https://www.gitmemory.com/issue/raspberrypi/linux/3652/817189332