SYNOPSYS

Here are the basis of alsa + pulseaudio configuration.

PROCEDURE

First I try to control the kernel module loading and initilasation order. alsa.opensrc.org

/etc/modprobe.d/alsa.conf

1
2
options snd_usb_audio index=-2
options snd-hda-intel id=PCH,HDMI index=0,1

but this produces weird results
aplay -l

1
2
3
4
5
6
card 0: PCH [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA Intel PCH], device 0: ALC3220 Analog [ALC3220 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

what I can do in a reliable way is to disable the HDMI.

/etc/modprobe.d/alsa.conf

1
2
3
4
# no usb as first card
options snd_usb_audio index=-2
# disable HDMI that shows up first, enable PCH
options snd_hda_intel enable=0,1

aplay -l

1
2
3
card 0: PCH [HDA Intel PCH], device 0: ALC3220 Analog [ALC3220 Analog]
  Subdevices: 1/1
    Subdevice #0: subdevice #0

Whatever, to correctly setup pulseaudio defaults.
pulseaudio perfect setup
man pulse-cli-syntax.

Identify your preferred card and profile.

pacmd list-cards (shortened)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
2 card(s) available.
index: 0
	name: <alsa_card.pci-0000_00_03.0>
	driver: <module-alsa-card.c>
	profiles:
		output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 5400, available: unknown)
		output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 300, available: unknown)
		off: Off (priority 0, available: unknown)
	active profile: <output:hdmi-stereo>
index: 1
	name: <alsa_card.pci-0000_00_1b.0>
	driver: <module-alsa-card.c>
	profiles:
		input:analog-stereo: Analog Stereo Input (priority 60, available: unknown)
		output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
		output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 6060, available: unknown)
		off: Off (priority 0, available: unknown)
	active profile: <output:analog-stereo+input:analog-stereo>

Then your preferred port.

pacmd list-sinks (shortened)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
2 sink(s) available.
index: 0
	name: <alsa_output.pci-0000_00_03.0.hdmi-stereo>
	driver: <module-alsa-card.c>
	card: 0 <alsa_card.pci-0000_00_03.0>
	ports:
		hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: no)
	active port: <hdmi-output-0>
index: 1
	name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
	driver: <module-alsa-card.c>
	card: 1 <alsa_card.pci-0000_00_1b.0>
	ports:
		analog-output: Analog Output (priority 9900, latency offset 0 usec, available: unknown)
		analog-output-lineout: Line Out (priority 9900, latency offset 0 usec, available: yes)
		analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
		analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: no)
	active port: <analog-output>

try pulse config using pacmd

1
2
echo "set-card-profile alsa_card.pci-0000_00_1b.0 output:analog-stereo+input:analog-stereo" | pacmd
echo "set-sink-port alsa_output.pci-0000_00_1b.0.analog-stereo analog-output-headphones" | pacmd

set pulse config permanently

/etc/pulse/default.conf

1
2
3
...
set-card-profile alsa_card.pci-0000_00_1b.0 output:analog-stereo+input:analog-stereo
set-sink-port alsa_output.pci-0000_00_1b.0.analog-stereo analog-output-headphones