It turns out that getting a sound output from a HDMI connected display when using Alsa is actually really simple. Here is the outline of the process.
1. Install alsa-utils (we need a tool called aplay). For example: sudo apt-get install alsa-utils
2. Open a terminal client and type aplay -l to list all your sound devices.
You will get something like this:
**** List of PLAYBACK Hardware Devices ****
card 0: HDMI_1 [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 0: ALC887-VD Analog [ALC887-VD Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 1: ALC887-VD Digital [ALC887-VD Digital]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0
3. Next you will need to create a file called .asoundrc inside your home directory. The final step is to add some lines to the .asoundrc file like below:
pcm.!pcm {
type hw
card 0
device 3
}
pcm.!default {
type plug
slave {
pcm “pcm”
}
}
Notice that you need to modify your setup according to your values, so be sure to check that you input your soundcard number and device number correctly.
After you are done with all the modifications I do recommend that you reboot your computer completely. The reboot is a good idea due to the fact that you do not need to manually shutdown and re-enable every running service/program, which might have used your previous sound settings.
When the reboot is done and you open up alsamixer (or a similar program) you might still not see any sound levels but instead you could have something like this:
Your sound device should work if you have a situation similar to the screenshot. What is happening on the above is typical to the integrated sound devices, In my case, my integrated HDMI sound device (Intel Hasswell) failed to show any sound levels but still worked. My non-integrated Ati card did however show sound levels from the start. Given that I had many other problems with my Ati card I opted to use my integrated device instead.
Note 1. Even when the sound levels are not visible within alsamixer and your keyboard volume keys might not work you can still adjust your sound levels within individual programs. Also, many displays do have volume buttons, which more than likely raise the volume coming from the display if everything else fails. In my tests the buttons found within my display were the ones, which saved the day and raised the volume levels from silent to clear and audible.
Note 2. Mixer programs (like volumeicon-alsa or wmmixer) generally failed to start when I used my integrated device. This was because the mixer programs could not fetch the sound device information correctly from the HDMI device. If you are using your laptop’s HDMI device you might experience this problem depending on your hardware.
I will continue my trials with Alsa and HDMI and make a new post if something new is discovered.