HDMI output with ALSA and Intel

My laptop has an HDMI output which I've never tried because I didn't have a display so far that accepts HDMI signals. But now I used it with a Toshiba LCD TV. Getting an image was easy, just plug in the cable, fire up (l)xrandr and select the HDMI output. Also select the correct HDMI input on the TV and you're set to go.

But alas, playing movies with mplayer was silent. Isn't HDMI supposed to transport audio as well? Yes, it is, but you have to tell mplayer which ALSA device to use. With my Intel-based graphics card this turned out to be surprisingly easy.

First I had to find the right ALSA virtual device for HDMI. The output of "aplay -L" (uppercase L!) helps:

$ aplay -L
    HDA Intel, ALC269 Analog
    Default Audio Device
    HDA Intel, ALC269 Analog
    Front speakers
    HDA Intel, ALC269 Analog
    4.0 Surround output to Front and Rear speakers
    HDA Intel, ALC269 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
    HDA Intel, ALC269 Analog
    5.0 Surround output to Front, Center and Rear speakers
    HDA Intel, ALC269 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
    HDA Intel, ALC269 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
    HDA Intel, ALC269 Digital
    IEC958 (S/PDIF) Digital Audio Output
    HDA Intel, INTEL HDMI 0
    HDMI Audio Output
    Discard all samples (playback) or generate zero samples (capture)

Did you spot the "hdmi" device shown? Yes, that's the one we need. So here's the mplayer command line:

$ mplayer -ao alsa:device=hdmi file.avi

Because I tend to forget mplayer command line options, I've put this into a shell script: ~/bin/hdmiplayer:

mplayer -ao alsa:device=hdmi "$@"

But it still was silent! Turns out, I had to unmute the control named "IEC958 1" in alsamixer. Then I got sound!

If you have a different card or if you want to know more about digital out with ALSA in general, head over to the ALSA wiki: http://alsa.opensrc.org/index.php/DigitalOut

Category: Sound
Tags: linux sound tips tricks alsa