Friday, October 7, 2011

Enabling HDMI audio-out in Ubuntu 10.04 on GeForce 520GT

Happy Thanksgiving weekend everyone!

Not that long ago, I had a sad day where I booted up my desktop and, despite the whirling of the fan and hard drive, nothing appeared on the screen! Oh noes!

Quickly fearing for my monitor, I plugged in my laptop and was promptly greeting with the laptop's bios booting on the monitor.

No problem with the monitor, then. What else? When turning on the computer, and waiting a few moments, I could clearly hear the Ubuntu start-up noise though the speakers despite having no video.

That would indicate processor, ram, and hard drive were all fine. Only guess remaining was a shot-out video card (or perhaps the PCI slot on the MB). Quite sad really, considering the card was less then a year old.

It also wasn't an easy card to get. Having yet to jump on the High Definition TV band wagon, I was still chucking around with my old, 27 inch, 480i, CRT TV. The only input it had was good old fashioned RCA cables. So, when I went video card shopping, I specifically looked for one with S-video out, having years ago purchased an S-video to RCA adapter for just these occasions.

Alas, I found one! Most cards now-a-days lack S-video, going for the HDMI or DVI connectors instead. But I found one at a local store nonetheless (no having to order on line). Furthermore, it was in fact a 7-pin, S-video cable, meaning that I could use it for not only standard definition S-video, but also for (potentially) high definition component video should I ever decide to upgrade my TV (a 7-pin S-video to component adapter was included with the card).

But I never got the chance to try it. I took my tower down to where I bought the video card and explained the situation. The staff was pretty friendly, they took my tower and let me know what they found. I figured it was either the Video Card (or possibly the MB), so either way I'd probably be getting some new hardware. The called me a short while later.

The video card was toast. Unfortunately, they couldn't tell me much more then that, I figure all they did was either try another card in my tower, or my card in another tower. Good news is, it was still under warranty, so they replaced it for free. Bad news: no more S-video cards.

So I ended up with a new card, a nVidia GeForce 520GX. It had D-Sub, DVI and HDMI outputs. I plugged in the DVI, but alas Ubuntu would only boot in Low-graphics mode. So I went to nVidia's site and downloaded the binary driver for Ubuntu and installed it (a bit of Googling revealed the 520Gx wasn't supported by 10.04 open source driver). My DVI port then worked fine, and I was greeted with the full 1920x1080 Ubuntu desktop on my monitor.

Since my monitor also has HDMI, I tried the HDMI output. It worked! As soon as I plugged it in, nvidia-settings picked it up as another monitor and allowed me to activate it.

But now what? I still couldn't plug it into my TV. So I did the only sane thing a geek would do: upgrade! Yep, I decided it was finally time to get a new TV. I won't bore you with the details, but after a week or two of searching, I ended up with a good deal on a 40-inch Sanyo LCD TV that supported HDMI.

So I plugged in the HDMI and was greeted with yet-another 1920 x 1080 desktop on the TV (I decided to use it as a separate X-session). Alas, I didn't find that resolution was very good for the TV (it looks great on my monitor, but despite the TV's size, things were a little hard to read). So I lowered the resolution to 1280 x 720 (720p) and find it much better and readable.

But what about audio? Sure, I could plug the audio cable from my speakers in, like I used to, but HDMI *is* cable of audio output, was it not? Surely, I could figure out how to activate it!

In fact, nVidia themselves have a guide to do just this. But it's not an easy read and requires some addition steps/research. In the end, it wasn't really that bad. Unfortunately, I was lazy at the time and didn't post any instructions. So when it stopped working the other day (more on that later), I couldn't recall everything I needed to do to get it back! I got everything restored without too much trouble, but decided to turn it into an opportunity to write the steps down and post them.

First, check to see that the audio device is being recognized. Do lspci | grep -i nvidia and you should see:

jason@jason-lucidlynx:~$ lspci | grep -i nvidia
05:00.0 VGA compatible controller: nVidia Corporation Device 1040 (rev a1)
05:00.1 Audio device: nVidia Corporation Device 0e08 (rev a1)

The audio device is what you're looking for. I didn't run into a problem with this, so if you don't see it show up, google-is-your-friend. My thinking though is that it's necessary to install the nVidia binary drivers (at the link I pointed out above) before you can get this far.

Once you confirm the hardware is recognized, you *must* make sure your Alsa is up-to-date. Default Alsa with 10.04 is 1.0.21, which is not sufficient for the GeForce 520GX.

Before you upgrade Alsa, you can note your old version:

jason@jason-lucidlynx:~$ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.21.

Also, aplay -L won't list your HDMI audio output.

jason@jason-lucidlynx:~$ aplay -L
pulse
Playback/recording through the PulseAudio sound server
front:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
Front speakers
surround40:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers

Upgrading Alsa is simple. Just follow the instructions here: https://wiki.ubuntu.com/Audio/InstallingLinuxAlsaDriverModules

After that (don't forget to restart after installing alsa!), you should get:

jason@jason-lucidlynx:~$ cat /proc/asound/version
Advanced Linux Sound Architecture Driver Version 1.0.24.
Compiled on Oct 6 2011 for kernel 2.6.32-34-generic (SMP).

and

jason@jason-lucidlynx:~$ aplay -L
pulse
Playback/recording through the PulseAudio sound server
front:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
Front speakers
surround40:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=SB,DEV=0
HDA ATI SB, VT1818S Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=SB,DEV=0
HDA ATI SB, VT1818S Digital
IEC958 (S/PDIF) Digital Audio Output
hdmi:CARD=NVidia
HDA NVidia, HDMI 0
HDMI Audio Output

which will make the HDMI Audio output show up! Cool, eh?

Next thing to do is see if you can get sound out of it, and figure out what hardware audio device it's enumerated as.

This is where the speaker-test utility comes in handy:

speaker-test -c 2 -r 48000 -D hw:0,0

This should cause some static to come out of your left and right main speakers.

After that, I just tried different values for the hw device.

Each audio card you have is numbered. 0 is typically your main one...I happen to have a USB audio device which shows up as device 1.

But eventually, I found it:

speaker-test -c 2 -r 48000 -D hw:2,7

This caused static to come out of my TV's speakers over the HDMI. Horray!

You might not have 2,7. In fact, 2,3 appeared to work for me, but didn't produce any sound. However, 2.3 *might* work for you.

At this point, you can go into your Gnome audio configuration (or whatever the equivalent might be in KDE/xfce/etc) and under output, you might be lucky enough to see "HDA NVidia..." in addition to your Internal Audio Analog Stereo. Great!

Play a sound file and try it out. If it works, you're done! If not, read on....

This unfortunately did *not* work for me. But I was closer then I realized.

The problem is called under-enumeration. It's pretty simply really, the video card (for whatever reason) made two devices available to the system: (2,3) and (2,7). But only the second mapped to the HDMI audio output. However, the Linux audio utils, by default, pick the first one (2.3). As far as I know, there's no way to change this.

But, you can add more audio devices, and select among those. To do this, open up the following file:

/etc/pulse/default.pa

and add the following line at the end:

load-module module-alsa-sink device=hw:2,7.

Restart. Now, you'll actually get three output devices. The regular internal stereo one, the HDA NVidia one, and a second HDA NVidia one (the text might look a little different).

So now, trying playing some audio and selecting the new audio device and voilà! Hopefully, you should have audio coming through your TV. To be fair, I believe this is only stereo sound, I haven't done any research on getting a digital, surround-sound signal through, but I imagine it's possible.

Strangely, when I booted up a few days ago after doing a system update, Ubuntu once again kicked me into Low-graphics mode.

Investigating, I found that my nVidia binary driver was no longer being loaded. I was going to reinstall the driver, when I decided to check nVidia's site. Even stranger, nVidia *just* released a new driver for my card yesterday! Not sure if they two things are related or not, but hey, I got a new driver.

Installing the new driver restored all my video functionality. But my HDMI audio wasn't working again. It seemed my Alsa had kicked back to 1.0.21, so the device was no longer being picked. So I started doing the motions necessary to restore it and decided to write them down this time (which you've just finished reading). Afterwards, my HDMI audio is working fine again!

References:

http://www.nvidia.com/Download/index.aspx?lang=en-us
https://wiki.ubuntu.com/Audio/InstallingLinuxAlsaDriverModules
ftp://download.nvidia.com/XFree86/gpu-hdmi-audio-document/gpu-hdmi-audio.html

43 comments:

  1. This was tremendously helpful. Messing with linux audio/display drivers is my least favorite thing in the world.

    ReplyDelete
  2. FYI, there should be a way to determine what device is what: in a terminal, cd to /proc/asound, go to the directory for your card (mine are all helpfully symlinked, so I just had to cd NVidia), and look through the contents of the subdirectories. Each should have a file called info which lists the hardware address and the description of the device.

    ReplyDelete
  3. Thank you for your "HAPPY THANKSGIVING"
    I am so deeply warmed.

    Does the USA have thanxgiving in March?

    In any event I have A HDMI monitor I just hooked up to my Ubuntu 11.10 system, and I have NO SOUND.
    Your long SELF-INDULGENT explanation is a "tad too long" for me to... uhh, indulge in.

    I just want a simple answer as to why my HDMI MONITOR DOES NOT HAVE SOUND IN UBUNTU 11.10 !!
    Got it?
    BTW, the sound works quite well (out of the box) with Win-7.
    Unless you can provide a 4-sentence explanation, please stop being so self-indulgent,

    ReplyDelete
  4. Bunny HDMI-lady,

    Thank you very much for your comment, however, since this is my blog and not yours, I will be precisely as self indulgent or not self indulgent as I wish to be. Although I'm always happy to hear someone found the information in my blog useful, the purpose of my blog is to document my thoughts, experiences, and things I generally find interesting, not to provide "stream-lined" technical support.

    If you cannot be bothered to read the entire post, or at least skim it for the relevant portions (I'll give you a hint, they start near the terminal commands), then you are most welcome to seek advice from another source.

    I am not an American, but as far as I know, Americans celebrate Thanksgiving in November, and not March. This post was made in October. Have a great day!

    ReplyDelete
  5. lol Bunny HDMI-lady, you make me laugh ;=)

    Jay,
    big thanks for this post, specially the lines talking about /etc/pulse/default.pa, The sound works for me now.

    you make my day!

    ReplyDelete
  6. Thank you! I had looked a literally dozens of web pages with all sorts of nonsensical (and sensible) suggestions. I had almost given up before I somehow stumbled on your page. It made sense and best of all - it worked.

    ReplyDelete
  7. I have a ThinkPad P50 with an Nvidia graphics card. I got to the point where I ran `lspci | grep -i nvidia` and I didn't see an audio device. However, I fixed it by switching from hybrid to discrete graphics in the BIOS. Hope this helps someone else!

    ReplyDelete
  8. Awesome and interesting article. Great things you've always shared with us. Thanks. Just continue composing this kind of post. google meet extension

    ReplyDelete
  9. What a sensational blog! This blog is too much amazing in all aspects. Especially, it looks awesome and the content available on it is utmost qualitative. ทางเข้าเล่นjoker

    ReplyDelete
  10. The content is utmost interesting! I have completely enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great, and your efforts are outstanding! biuro nieruchomosci wloclawek

    ReplyDelete
  11. Your blog has piqued a lot of real interest. I can see why since you have done such a good job of making it interesting. I appreciate your efforts very much. New mp3,

    ReplyDelete
  12. I love visiting sites in my free time. I have visited many sites but did not find any site more efficient than yours. Thanks for the nudge! Superslot

    ReplyDelete
  13. I really thank you for the valuable info on this great subject and look forward to more great posts. Thanks a lot for enjoying this beauty article with me. I am appreciating it very much! Looking forward to another great article. Good luck to the author! All the best! ethical hacker salary per month

    ReplyDelete
  14. Howdy, i read your blog occasionally and i own a similar one and i was just curious if you get a lot of spam feedback? If so how do you protect against it, any plugin or anything you can suggest? I get so much lately it’s driving me mad so any support is very much appreciated. danske casinoer

    ReplyDelete
  15. WHAT IS DANKWOODS? this product was created to quicken the process of smoking weed for even the most experienced roller. So throw your Swishers in the trash. Our product is made from an all-natural Meduro backwood. dankwoods

    ReplyDelete
  16. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. casino portugal

    ReplyDelete
  17. Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. casino portugal

    ReplyDelete
  18. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. 파워볼

    ReplyDelete
  19. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. Kanadan turistiviisumi

    ReplyDelete
  20. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work... Индијска-туристичка-виза

    ReplyDelete
  21. it was a wonderful chance to visit this kind of site and I am happy to know. thank you so much for giving us a chance to have this opportunity.. Kanada turismiviisa

    ReplyDelete
  22. I would like to say that this blog really convinced me to do it! Thanks, very good post. 바둑이게임

    ReplyDelete
  23. There is so much in this article that I would never have thought of on my own. Your content gives readers things to think about in an interesting way. Thank you for your clear information. hotmail

    ReplyDelete
  24. I read that Post and got it fine and informative. 토토사이트

    ReplyDelete
  25. It is the kind of information I have been trying to find. Thank you for writing this information. It has proved utmost beneficial for me. ทดลองเล่นสล็อต

    ReplyDelete
  26. Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information. สมัครเล่น จีคลับ

    ReplyDelete
  27. Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information. 출장안마

    ReplyDelete
  28. Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. 소액결제 현금화

    ReplyDelete
  29. Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. 셔츠룸

    ReplyDelete
  30. Really I enjoy your site with effective and useful information. It is included very nice post with a lot of our resources.thanks for share. i enjoy this post. 토토사이트

    ReplyDelete
  31. The content is utmost interesting! I have completely enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great, and your efforts are outstanding! 가라오케

    ReplyDelete
  32. Superior post, keep up with this exceptional work. It's nice to know that this topic is being also covered on this web site so cheers for taking the time to discuss this! Thanks again and again! 소액결제 현금화

    ReplyDelete
  33. i am for the first time here. I found this board and I in finding It truly helpful & it helped me out a lot. I hope to present something back and help others such as you helped me. 레깅스룸

    ReplyDelete
  34. Pretty good post. I have just stumbled upon your blog and enjoyed reading your blog posts very much. I am looking for new posts to get more precious info. Big thanks for the useful info. 소액결제 현금화

    ReplyDelete
  35. Best work you have done, this online website is cool with great facts and looks. I have stopped at this blog after viewing the excellent content. I will be back for more qualitative work. เว็บพนัน jumboslot

    ReplyDelete
  36. Thank you for taking the time to publish this information very useful! visa ya India mkondoni

    ReplyDelete
  37. Pretty good post. I have just stumbled upon your blog and enjoyed reading your blog posts very much. I am looking for new posts to get more precious info. Big thanks for the useful info. คาสิโน

    ReplyDelete
  38. The article looks magnificent, but it would be beneficial if you can share more about the suchlike subjects in the future. Keep posting. baccarat

    ReplyDelete
  39. Pretty good post. I have just stumbled upon your blog and enjoyed reading your blog posts very much. I am looking for new posts to get more precious info. Big thanks for the useful info. ดูหนัง

    ReplyDelete
  40. This will be a terrific blog, would you be interested in doing an interview about just how you developed it? If so e-mail me! slot

    ReplyDelete
  41. hi was just seeing if you minded a comment. i like your website and the thme you picked is super. I will be back. สล็อตออนไลน์

    ReplyDelete
  42. Good website! I truly love how it is easy on my eyes it is. I am wondering how I might be notified whenever a new post has been made. I have subscribed to your RSS which may do the trick? Have a great day! 출장안마

    ReplyDelete