Monday, November 24, 2008

HDMI audio in Linux running on Apple TV

Very long time I wanted to open my blog to share my experience with community but have no time for this. Now I'm opening my blog with some info about HDMI audio support in Linux on Apple TV. There was the patch that makes RCA outputs to work, but HDMI audio was still not working. After digging alsa code and inspecting AppleTV internals I've discovered that AppleTV uses Silicon Image SI 1390 for HDMI audio and there is support for it in ATI-HDMI module. The solution was as simple as adding one line of code in alsa-kernel/pci/hda/patch_atihdmi.c file (now, alsa-driver 1.0.18a has this patch):
struct hda_codec_preset snd_hda_preset_atihdmi[] = {
...............................
{ .id = 0x10951390, .name = "AppleTV HDMI", .patch = patch_atihdmi },
{ .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_atihdmi },
...............................
};
After recompiling and installing patched alsa new IEC958 1 output was added. That is our HDMI audio output.
There is also interesting fact, that you need to boot your Apple TV with HDMI cable plugged in and TV turned on. Otherwise you will not hear any sound.
However sound have disappeared after upgrading NVidia driver from 100.14.19 to 173.14.12. So, this needs further investigation.

14 comments:

Justin said...

Would you be able to elaborate. I have tried the new 1.0.18a alsa-driver and 177.80 nvidia, but I am not able to get audio out the hdmi. Unfortunately, it didn't "just work". The device is listed under aplay -L, but no audio comes out when I send something to plughw:0,3. Any further help posted would be much appreciated.

Unknown said...

First of all check that corresponding audio output is unmuted. Secondly, pull out all RCA cables from Apple TV, turn on your TV, plug your HDMI cable and reboot. And at last
try to downgrade NVidia video driver to version 100.14.19 - that's only works for me.

Justin said...

I've pulled all cables except hdmi and reboot with tv on to no avail.

Unfortunately, I am running mythbuntu 8.10, and it looks like 100.14.19 won't compile with that version of the kernel. I don't suppose you'd be able to try 177.80 would you? Besides, I'm surprised it worked with 100.14.19 since I didn't think they added hdmi audio support in later versions of the driver.

What alsa device did you use to test the audio? plughw:0,3?

Unknown said...

I've tried the most recent 180.06 driver and have no sound. Than I made experiment: play sound before video driver start and after that. As expected before driver start sound plays, and after - stops. So now I know that the problem is exactly in NVidia's video driver. I'm not so familiar with alsa, but I've discovered that file /proc/asound/card0/codec#1 contains such string for third node before video driver start:
Pin-ctls: 0x40: OUT
And after start I have
Pin-ctls: 0x00:
Maybe that's the problem. I don't know if this is side effect of expected behaviour but I'll ask that on NVidia's forum.

Unknown said...

I can't wait to hear what you find out because it would be great to get this working!

Justin said...

I noticed my codec#1 is 0 all the time. But then again I patched the nvhdmi alsa file so that the aplay listing said it was a NVIDIA HDMI as opposed to ATI HDMI. I don't think that would have broken it given the fact that the meat in both patch files are nearly identical, but I'll try going back to the original 18a source.

I don't know enough about the codec files, would you be able to save off a functioning one and just overwrite the non-functional one once nvidia driver starts?

Plus could you link to the nvidia forum if you start one?

Justin said...

I can confirm that that hdmi audio works on the appletv with the latest alsa 1.0.18a! BUT, not once xorg starts up. If I start X (doesn't matter if it is nvidia binary or the nv driver) the audio stops working.

I tried to do an "alsa reload" and that didn't fix it. So I dropped back down out of X and the audio was still broken. But once I did another "alsa reload" it came back.

And I take back what I said earlier, I am seeing the same thing on the pin out in the hdmi codec.

What could this be?

Justin said...

Ooops, I need to stop sticking my foot in my mouth. I got hdmi audio working with the nv driver, but when I use the nvidia driver:
Pin-ctls goes from 0x40 to 0x0
Amp-out vals goes from 0x0 to 0x80

Justin said...

looks like the interrupt might be getting disabled?

When I start with nv driver I don't get any message about disabling the interrupt, but when I start with the nvidia driver I get the following message:

HDA Intel 0000:00:1b.0: PCI INT A disabled

Unknown said...

I've started a new thread on NVidia forums at http://www.nvnews.net/vbulletin/showthread.php?t=124536.

Anonymous said...

Will a regular HDMI cable from www.cabledealz.com work with the new Mac Book pro to hookup my laptop to my 1080p HDTV?

Unknown said...

Sorry, I don't have Mac Book pro, but if your laptop and HDTV both have HDMI sockets and you use MacOS, there shouldn't be any problems.

Unknown said...

I am working on getting HDMI audio running with the newer nvidia drivers. I am posting my results to the forum thread

http://www.nvnews.net/vbulletin/showthread.php?t=124536

But I am starting to run out of ideas....

Bobby Bucur said...

has anyone made progress here? thank you for the effort :)