the situation on my laptop (dell e7240) is more difficult...
Until recently I was only able to get it to work through the laptop speakers about one boot in ten and to make things worse, hdmi sound is the default: $ lspci
...
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b)
00:03.0 Audio device: Intel Corporation Haswell-ULT HD Audio Controller (rev 0b)
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
Subdevices: 0/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: ALC3226 Analog [ALC3226 Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
Eventually I noticed that the sound worked almost every time with corepure64/gnome-session and used the "sudo alsactl store" command to save asound.state.
After restoring asound.state with my usual wm (flwm) and loading the alsa extension, I was able to use alsamixer and F6 to chose device 1, adjust the settings to my liking and save asound.state again.
Now things appear to be working every boot after first restoring asound.state, then loading only the alsa extension (and deps) and without issuing any commands.
With my hardware, to test sound (requires the alsa-config extension): $ speaker-test -Ddefault:1 -c2 -t wav -l1
or, with xmms use the following settings (<ctrl-p>): output plugin: ALSA 1.2.11 out plugin [libALSA.so]
configure:
Audio device: hw:1,0
Mixer card: HDA Intel PCH
Mixer device: PCM