[alsa-devel] [RFC/RFT PATCH] ALSA: hda - hdmi: Add ATI/AMD multi-channel audio support

Anssi Hannula anssi.hannula at iki.fi
Wed Sep 25 16:10:28 CEST 2013

25.09.2013 07:22, Olivier Langlois kirjoitti:
> Hi,


> This is just to let you know that I have applied your patch on my linux
> 3.11 setup and
> speaker-test -D hdmi:CARD=Generic,DEV=0 -c8 -r192000 -F S16_LE
> did work as expected on my 7.1 receiver with:
> lano1106 at whippet2 /proc/asound/card0 :( $ cat codec#0 
> Codec: ATI R6xx HDMI
> Address: 0
> AFG Function Id: 0x1 (unsol 0)
> Vendor Id: 0x1002aa01
> Subsystem Id: 0x00aa0100
> Revision Id: 0x100300
> No Modem Function Group found
> Default PCM:
>     rates [0x70]: 32000 44100 48000
>     bits [0x2]: 16
>     formats [0x5]: PCM AC3

Great to hear that, thanks. So Revision Id 3+ works :)

I forgot to ask for it explicitely, but I guess you checked that
channels seemed to mapped correctly (at least for each speaker you
actually have)?

Also, could you paste the whole /proc/asound/card0/codec#0, for the record?

> From dmesg:
> lano1106 at whippet2 /etc $ dmesg | grep hdmi
> Correct me if I am wrong but this codec should be able to output 24 bits
> PCM. How one could go to test that?

Just use -F S32_LE for speaker-test.

Why S32 and not S24? This is because there are three formats for 24-bit

If each sample has exactly 24 bits and next sample follows immediately,
it is S24_3LE (/BE).
If each sample has a space of 32 bits but only 24 bits are used, there
are two ways to place those 24 bits to 32 bits. Either the most
significant 24 bits are used, or the least significant 24 bits are used.

If the most significant bits are used (and 8 least significant bits not
used), the format is actually exactly the same as 32 bit (except that
the least significant bits are simply ignored), and hence the format is
S32_LE (/BE). The other format (least significant bits used) is S24_LE

> Good work Anssi!
> On Sun, 2013-09-22 at 20:50 +0300, Anssi Hannula wrote:
>> Request for comments and testing.
>> AMD just released the documentation needed for multi-channel HDMI
>> support, so here is the initial patch adding such support.
>> This has been tested on codec 0x1002aa01, revision 0x100200 with the
>> exception of custom channel maps, which I intend to test later.
>> I'm especially interested in testers with:
>> - Older codecs other than 0x1002aa01. My best guess is that the new code
>>   should work on them as well, but I'm not really 100% sure.
>> - Codec 0x1002aa01 revisions 0x100300 (Rev ID 3) or later (see
>>   /proc/asound/cardX/codec#Y). These support individual channel
>>   remapping and that code is entirely untested (even for regular
>>   5.1/7.1).
>> I decided it was best to get this out there early even though major
>> parts of it are still untested, for comments and for other people to
>> test :)
>> Note that this recent commit is probably required for multi-channel to
>> work with the open-source radeon driver:
>> ALSA: hda - hdmi: Fallback to ALSA allocation when selecting CA
>> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/sound/pci/hda/patch_hdmi.c?id=18e391862cceaf43ddb8eb5cca05e1a83abdebaa
>> Easiest way to test basic multichannel is by speaker-test, e.g.
>> speaker-test -D hdmi:CARD=Generic,DEV=0 -c8 -r192000 -F S16_LE
>> for 7.1 16-bit 192kHz
>> Detailed discussion below:
>> ATI/AMD codecs do not support all the standard HDA HDMI/DP functions. In
>> particular, these are missing:
>> - ELD support
>> - standard channel mapping support
>> - standard infoframe configuration support
>> In place of them, custom HDA pin verbs are included, that allow:
>> - getting speaker mask from EDID
>> - getting SADs from EDID
>> - getting connection type from EDID (HDMI, DisplayPort)
>> - setting CA for infoframe
>> - setting down-mix information for infoframe
>> - channel pair remapping
>> - individual channel remapping (revision ID 3+)
>> The documentation for the verbs has now been released by AMD:
>> http://www.x.org/docs/AMD/AMD_HDA_verbs.pdf
>> Also, converted nodes do not have all their supported rates, formats and
>> channel counts listed.
>> Add support for the ATI/AMD specific verbs and use them instead of the
>> generic methods on ATI/AMD codecs. This allows multi-channel audio to
>> work.
>> Is the way it is done OK, or should something more generic be put into
>> place (custom callbacks and/or flags in struct hdmi_spec maybe)?
>> On the older ATI/AMD codecs that do not support individual remapping,
>> channel remapping is restricted to pair remapping. This does not affect
>> the standard multi-channel configurations.
>> Since there is no ELD support (unless out-of-band communication with the
>> graphics driver is added so that they can provide it to us directly),
>> ELD is currently emulated with only the basic information populated
>> (speaker mask, SADs, connection type). There are some bits missing on
>> the radeon driver side (the SADs etc are not populated) so currently
>> the ELD emulation only works on fglrx. ELD emulation is not needed for
>> multi-channel playback.
>> Rafał, are you interested in implementing the missing bits in the radeon
>> driver, as I see you have looked into this before?
>> The ELD emulation was quite quickly hacked together and hasn't been
>> cleaned up yet, since I'm not sure how we want to ultimately handle
>> this. Is ELD emulation the way to go? If so, where does the code belong
>> (the ATI specific code is in patch_hdmi.c, but the ELD parsing/defines
>> etc are in hda_eld.c)?
>> Codec 0x1002aa01 is switched back to patch_atihdmi to support the
>> ATI/AMD specific features.
>> HBR mode (needed for DTS-HD/TrueHD passthrough) is not working yet, and
>> the released documentation does not mention it.
>> Signed-off-by: Anssi Hannula <anssi.hannula at iki.fi>
>> Tested-by: Peter Frühberger <fritsch at xbmc.org>
>> Cc: Rafał Miłecki <zajec5 at gmail.com>
>> ---
>>  sound/pci/hda/patch_hdmi.c | 418 ++++++++++++++++++++++++++++++++++++++++-----
>>  1 file changed, 374 insertions(+), 44 deletions(-)

Anssi Hannula

More information about the Alsa-devel mailing list