Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Hardware] How to stop Debian from randomly assigning numbers to my PCI-e soundcards after reboot?

Need help with peripherals or devices?
Post Reply
Message
Author
sg5412
Posts: 2
Joined: 2023-03-29 18:09
Has thanked: 1 time

[Hardware] How to stop Debian from randomly assigning numbers to my PCI-e soundcards after reboot?

#1 Post by sg5412 »

Hello,

How can I assign fixed numbers to my 4 identical PCI-e soundcards in Debian so that they retain the same number after a reboot?
...Or at least get a predictable enumeration after boot.

They are the CMI8738 cards below:

Code: Select all

# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: HDMI [HDA Intel HDMI], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC3220 Analog [ALC3220 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: CMI8738 [C-Media CMI8738], device 0: CMI8738-MC6 [C-Media PCI DAC/ADC]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: CMI8738 [C-Media CMI8738], device 1: CMI8738-MC6 [C-Media PCI 2nd DAC]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: CMI8738 [C-Media CMI8738], device 2: CMI8738-MC6 [C-Media PCI IEC958]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: CMI8738_1 [C-Media CMI8738], device 0: CMI8738-MC6 [C-Media PCI DAC/ADC]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: CMI8738_1 [C-Media CMI8738], device 1: CMI8738-MC6 [C-Media PCI 2nd DAC]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: CMI8738_1 [C-Media CMI8738], device 2: CMI8738-MC6 [C-Media PCI IEC958]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 4: CMI8738_2 [C-Media CMI8738], device 0: CMI8738-MC6 [C-Media PCI DAC/ADC]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 4: CMI8738_2 [C-Media CMI8738], device 1: CMI8738-MC6 [C-Media PCI 2nd DAC]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 4: CMI8738_2 [C-Media CMI8738], device 2: CMI8738-MC6 [C-Media PCI IEC958]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 5: CMI8738_3 [C-Media CMI8738], device 0: CMI8738-MC6 [C-Media PCI DAC/ADC]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 5: CMI8738_3 [C-Media CMI8738], device 1: CMI8738-MC6 [C-Media PCI 2nd DAC]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 5: CMI8738_3 [C-Media CMI8738], device 2: CMI8738-MC6 [C-Media PCI IEC958]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
#uname -a
Linux deb-cbc 4.19.0-22-amd64 #1 SMP Debian 4.19.260-1 (2022-09-29) x86_64 GNU/Linux
I'm trying to record 4 specific audio channels but I need to keep the computer on a UPS to avoid recording in the wrong file, and that's not a smart workaround.
Thanks for your input!

CwF
Global Moderator
Global Moderator
Posts: 2638
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: [Hardware] How to stop Debian from randomly assigning numbers to my PCI-e soundcards after reboot?

#2 Post by CwF »

Preferably there is a way through a udev or systemd I don't know about to assign 'friendly' names. Look at 'man systemd.device' and 'man udev'

Can the commands of the cards according to slot address (/dev/snd/by-path/) and not id?

Code: Select all

$ cat /sys/class/pci_bus/0000:03/device/0000:03:00.1/sound/card1/number
1
So if you know the slot this cat as a script variable would return the current assigned number that I assume is the device #.

The 'friendly'

Code: Select all

$ cat/sys/class/pci_bus/0000:03/device/0000:03:00.1/sound/card1/id
HDMI

User avatar
NorthEast
Posts: 349
Joined: 2018-11-18 04:35
Has thanked: 12 times
Been thanked: 30 times

Re: [Hardware] How to stop Debian from randomly assigning numbers to my PCI-e soundcards after reboot?

#3 Post by NorthEast »

Perhaps have a look at: /usr/lib/udev/rules.d/78-sound-card.rules, and note the DEVPATH options to see what can be configured there, after CwF's suggestions. Another means to identify bus info:

Code: Select all

lspci -nnkd ::403

sg5412
Posts: 2
Joined: 2023-03-29 18:09
Has thanked: 1 time

Re: [Hardware] How to stop Debian from randomly assigning numbers to my PCI-e soundcards after reboot?

#4 Post by sg5412 »

@CwF made me change my perspective on the problem and instead of changing Debian's behaviour, I changed my code to be independent of the card number using variables:

Code: Select all

CARD_A=$(cat /sys/class/pci_bus/0000\:02/device/0000\:02\:00.0/sound/card?/number)
CARD_B=$(cat /sys/class/pci_bus/0000\:05/device/0000\:05\:00.0/sound/card?/number)
CARD_C=$(cat /sys/class/pci_bus/0000\:08/device/0000\:08\:00.0/sound/card?/number)
CARD_D=$(cat /sys/class/pci_bus/0000\:0a/device/0000\:0a\:00.0/sound/card?/number)
Now every time the computer reboots, the card numbers shuffle, but the CARD_ variable allows me to follow the physical position of the card, so the card number doesn't matter anymore.

Thank you @CwF, now I can reboot this computer without going through the grind of changing my script.
Last edited by sg5412 on 2023-03-30 20:36, edited 3 times in total.

CwF
Global Moderator
Global Moderator
Posts: 2638
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: [Hardware] How to stop Debian from randomly assigning numbers to my PCI-e soundcards after reboot?

#5 Post by CwF »

Random note;
I was looking into building a line in volume control widget and ran across this from man amixer
amixer -c 2 cset numid=34 40%
will set the 34th soundcard element to 40%

Post Reply