Change default alsamixer card permanently?

Hey everyone,

I’m using the Framework 13 (AMD edition) with Debian 12 Bookworm.

I have noticed a small, minor thing that I was wondering about. When I launch alsamixer there are two sound cards detected: The first one has… 3 HDMI audio devices??? And also the second one (Card 1) is the actual main sound card for the laptop, including headphones, microphone, etc…

The output of aplay -l shows this:

**** List of PLAYBACK Hardware Devices ****
card 0: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Generic [HD-Audio Generic], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 0: ALC295 Analog [ALC295 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I was wondering what that means, in terms of technical aspects? Why are 3 HDMI outputs being detected, and why are they not on Card 1?

When I launch alsamixer it will default to the 3 HDMI outputs on Card 0, which is annoying. I have to press F6 to change sound cards each time. Can I swap the order permanently (not by aliasing alsamixer to alsamixer -c 1), like using an asound.conf file?

And if I were to guess, these “HDMI” outputs are really meant to be used for the outputs on the USB-C modules on the laptop, correct?

In case anyone was wondering, yes, I did replace Pulseaudio with Pipewire and Wireplumber. But I do not remember if that changed the order, or not.

Fwiw most people use pipewire with various frontends. Due to the use of UCM configuration files make all this presents a lot more logically than straight alsa-utils does.

As for the why there are two cards it’s because “HDMI” audio sources come off the PCI audio endpoint from the graphics device. The realtek audio is its own separate codec.

2 Likes

Yeah, both of them are listed as “Generic” and “Generic_1”, so I’m guessing one was renamed to “Generic_1”.

Using lspci | grep -i audio shows this:

$ lspci | grep -i audio
c1:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Rembrandt Radeon High Definition Audio Controller
c1:00.5 Multimedia controller: Advanced Micro Devices, Inc. [AMD] ACP/ACP3X/ACP6x Audio Coprocessor (rev 63)
c1:00.6 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h/19h HD Audio Controller

There is nothing listed with Realtek. Are you sure one of them is Realtek? Could be that one of them was detected improperly by the kernel.

AMD provides a PCI endpoint for HD audio. The realtek controller (ALC295) is connected to this HD audio bus.

The other device listed in PCI output above is for the audio coprocessor. This is optionally used for connecting to a DMIC in some designs and as a DSP in some other designs.

1 Like

Okay, so I decided that I would change the ordering of the cards with modprobe params, because I’ve heard that there could be a potential problem changing it by index value, because the system could always throw the cards in the reverse order when booting the system, kind of similar to the old /dev/sda can become /dev/sdb problem back in the day.

In that case, this solution is out - Setting the default device - AlsaProject

So I want to make sure I use unique identifiers for these cards. Haven’t figured out how to rename them yet.

Here’s /etc/modprobe.d/alsa-base.conf:

# Fix framework 13 sound card order
options snd-hda-intel id=Generic_1 index=0
options snd-hda-intel id=Gneeric   index=1

But after I do this, the audio no longer works. Both pulsemixer and Pavucontrol use “Dummy Output”. How do I fix this?

Oh wait, I’m sorry, I misspelled “Generic”. Okay, so I’m a bit confused here, when I use aplay -l it showed the ID the way I had SET them. I thought that the id=<name> part was supposed to MATCH the ID and then SET the index, not set BOTH the ID and index ITSELF. Oh, interesting…

But I guess that’s not going to solve the problem long term if the indexes get switched around then. Still looking for the best solution. I’m now trying to figure out what output device I should set each of these two cards to… I guess the HDMI card one can remain off.

EDIT: Okay, so I guess I really don’t understand how the snd-hda-intel module works. I should dig up some kernel docs. Because when I set id=Laptop, that didn’t work, it just defaulted to “Generic” but id=HDMI actually did work! There’s also another modparam setting that confuses me called model=, so what is the difference between id= and model=? They seem to take the same kind of entries. Guess I’ll have to find out…

Okay, so after screwing around with audio settings and trying to restore them back to the defaults by commenting everything in /etc/modprobe.d/alsa-base.conf, I can’t get the audio to work anymore, no matter what configuration I set for the audio controllers. I still don’t know which one is the laptop audio. Is it “Family 17h/19h HD Audio Controller” or is it “Rembrandt Radeon High Definition Audio Controller”?

Setting it to “Pro Audio” doesn’t output anything, I made sure everything was unmuted. My laptop no longer has any audio.

I could really use some help on this. I don’t understand what I’m doing wrong here.

I would suspect that the stored values from the systemd unit which saves and restores mixer levels are wrong with reassigning.

I would mask that unit until you’re happy with your configuration.

But IMO you shouldn’t bother with this stuff in ALSA, you should be configuring at Pipewire or UCM levels and leave lower level ALSA alone.

Okay, if you say so…

Honestly, when I was making changes to modprobe, I had to keep restarting anyway. So I give up now since I’ve been at this for hours. I’ll just let ALSA set the order it wants, but I can still change the default selected card at least.

So for anyone else wanting to solve this problem, here’s the steps:

  1. Disable anything in /etc/modprobe.d/ changing the snd_hda_intel options.
  2. Run sudo alsactl init which will reinitialize audio levels and mute state, but fix some things.
  3. Add a file to /etc/alsa/conf.d/99-local-pw-default.conf with the following content:
    defaults.pcm.card 1
    defaults.ctl.card 1
    
  4. In Pavucontol, make sure that in the Profile configuration, “Family 17h/19h HD Audio Controller” is set to one of the following: “Analog Stereo Output”, “Analog Stereo Duplex”, or “Pro Audio”. That one is the laptop audio. And “Rembrandt Radeon High Definition Audio” is the HDMI audio. That can be turned off, or set to one of the HDMI profiles.
  5. Reboot.

I’m going to keep testing the audio. Will reply if I have any more problems.

Okay, so it didn’t survive a reboot. Still getting “Dummy Output”. You said to mask the unit files for some reason. When exactly should I mask them, and when exactly should I unmask them?

Trying this also is not helping

systemctl --user restart pipewire.service
systemctl --user restart pipewire-pulse.service

Not sure what else to do. It’s weird. I get it working temporarily, then after a reboot it just breaks again… Maybe it didn’t even like that ALSA config file either…

The reason to mask them was to avoid conflicts with restoring the wrong values since you re-ordered the cards. If you’ve got them back how you want you can unmask them and it will save/restore values again.

1 Like

Hmm… I’m trying to do it, but it’s not working.

I decided to change the order again by using /etc/alsa/conf.d/99-local-pw-default.conf (mentioned above). For some reason the “Family 17h/19h HD Audio Controller” entry has disappeared from it, so I can’t set it as the sink. Here’s what wpctl status shows now:

PipeWire 'pipewire-0' [0.3.65, me@host, cookie:3540354339]
 └─ Clients:
        31. WirePlumber                         [0.3.65, me@host, pid:2762]
        32. WirePlumber [export]                [0.3.65, me@host, pid:2762]
        44. pipewire                            [0.3.65, me@host, pid:2810]
        50. pulsemixer                          [0.3.65, me@host, pid:2849]
        51. xdg-desktop-portal                  [0.3.65, me@host, pid:3338]
        52. Firefox                             [0.3.65, me@host, pid:3230]
        53. wpctl                               [0.3.65, me@host, pid:7908]

Audio
 ├─ Devices:
 │      41. Rembrandt Radeon High Definition Audio Controller [alsa]
 │  
 ├─ Sinks:
 │  *   45. Dummy Output                        [vol: 1.00]
 │  
 ├─ Sink endpoints:
 │  
 ├─ Sources:
 │  
 ├─ Source endpoints:
 │  
 └─ Streams:

Video
 ├─ Devices:
 │      39. Laptop Webcam Module (2nd Gen)      [v4l2]
 │      40. Laptop Webcam Module (2nd Gen)      [v4l2]
 │  
 ├─ Sinks:
 │  
 ├─ Sink endpoints:
 │  
 ├─ Sources:
 │  *   42. Laptop Webcam Module (2nd Gen) (V4L2)
 │  
 ├─ Source endpoints:
 │  
 └─ Streams:

Settings
 └─ Default Configured Node Names:

Alright, everyone!

After literal hours of troubleshooting back then, one day I read up about something I could do, which is set the $ALSA_CARD environment variable. And guess what, this actually worked!

Some step-by-step instructions of what to do. And please, to whomever is reading, let us know if this works for you as well.

  1. Add a file in /etc/profile.d/,
    such as /etc/profile.d/alsa-default-card.sh, very important that the extension ends in *.sh so it will get sourced properly by /etc/profile. Also, make sure permissions are set as 644 (the default).

  2. Put the following content in the file:

export ALSA_CARD=Generic_1

If the card is not “Generic_1”, check which card by listing aplay -l.

  1. Save the file and log out, then log back in again.

Again, I’m sure it is possible by using an asound.rc file. But this is the only thing that has worked for me so far, and now I can just alias alsamixer -V all without having to add an extra parameter, since it will use $ALSA_CARD properly, and I can also configure colors and minor stuff with ~/.config/alsamixer.rc. It’s great.