Archive:Remap HDMI audio on Gen 1 ION - Linux: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
No edit summary
(→‎14.x Helix: Add warning that it can cause Kodi to crash)
Line 181: Line 181:
=== 14.x Helix ===
=== 14.x Helix ===
It appears that remapping may no longer be necessary in Helix for the benefit of Kodi itself, as Kodi appears to perform the remapping itself in software. If remapping is needed for other Linux apps, it should be possible to still use the Frodo/Gotham .asoundrc above but configure Kodi itself to use an output that is not remapped.
It appears that remapping may no longer be necessary in Helix for the benefit of Kodi itself, as Kodi appears to perform the remapping itself in software. If remapping is needed for other Linux apps, it should be possible to still use the Frodo/Gotham .asoundrc above but configure Kodi itself to use an output that is not remapped.
Indeed the remapping can even cause Kodi to crash with AESink recording a segfault in libasound.


== Pulseaudio ==
== Pulseaudio ==

Revision as of 20:32, 10 November 2015

Some early nVidia ION-based motherboards have their HDMI audio channels mapped incorrectly. There are two relatively simple methods to remap HDMI audio at the OS-level on nVidia ION-based systems; which one you use depends on your setup. If you require passthrough, disabling Pulseaudio (if your distribution uses it by default) is necessary to configure ALSA to remap the channels. Configuring Pulseaudio to remap the channels is another option if you don't require passthrough.

It should be noted that whenever editing config files, it's best to backup the original.

ALSA

The following steps require the removal of Pulseaudio if your distribution uses it by default.

HDMI audio output requires several steps to configure properly. My requirements were passthrough, non-passthrough and menu sounds all coming over HDMI to my receiver (fairly common). Some challenges were that the Gen 1 ION had incorrect channel mappings (e.g. Center came out of Left Rear) and menu sounds do not default to HDMI.

I first noticed the audio channels were mis-mapped while watching a movie - all the voices were coming out of the left rear channel, not center. To verify this, I ran the following command:

speaker-test -D hdmi -c 6

To correct the output, I created the following channel mapping in ~/.asoundrc or /etc/asound.conf(.asoundrc overrides the default alsa settings per user, while /etc/asound.conf is a global settings override)

11.x Eden with 7.1 speakers

ALSA Configuration

Untested in Frodo.

pcm.hdmi-remap {
       type route
       slave.pcm hdmi
       ttable.0.0 1
       ttable.1.1 1
       ttable.2.4 1
       ttable.3.5 1
       ttable.4.2 1
       ttable.5.3 1
       ttable.6.6 1 
       ttable.7.7 1 
}
Note: There is intentionally no slave.channels line in the configuration file since it seems to corrupt the digital stream and prevented proper DTS and DD passthrough to my receiver. If you hear static when using passthrough, this might be the reason why!
To test our new configuration, we can run
speaker-test -D hdmi-remap -c 6

Hopefully the channels will now be mapped correctly.

Kodi Configuration

Within Settings -> System -> Audio Output, I set the following values:

  • Audio Output : HDMI
  • Speaker Configuration : 7.1
  • Boost volume level on downmix : No
  • Dolby Digital (AC3) capable receiver : Yes
  • DTS capable receiver : Yes
  • Audio output device : Custom
  • Custom audio device : hdmi-remap
  • Passthrough output device : hdmi(ALSA)

Menu Sounds

Note: Not needed in Frodo.

To configure menu sounds, I told alsa to use the hdmi-remap device as default. I did this by adding the following section to my ~/.asoundrc file:

pcm.!default {
	type plug
	slave.pcm hdmi-remap
}

12.x Frodo / 13.x Gotham with 5.1 speakers (simple fix)

ALSA Configuration

pcm.!default {
    type plug
    slave {
        pcm both
    }
}
pcm.both {
    type route
    slave {
        pcm hdmi
    }
       ttable.0.0 1
       ttable.1.1 1
       ttable.2.4 1
       ttable.3.5 1
       ttable.4.2 1
       ttable.5.3 1
}
To test our new configuration, we can run
speaker-test -D hdmi -c 6

Kodi Configuration

Within Settings -> System -> Audio Output, I set the following values:

  • Audio Output : HDMI
  • Speaker Configuration : 5.1
  • Boost volume level on downmix : No
  • Dolby Digital (AC3) capable receiver : Yes
  • DTS capable receiver : Yes
  • Audio output device : HDA NVidia HDMI 0
  • Passthrough output device : HDA NVidia HDMI 0

After a reboot, sound should be working as expected. Feel free to update this information as needed.

Attention talk.png Linux Frodo HDMI audio channel remap discussion

12.x Frodo / 13.x Gotham with 5.1 speakers (including desktop application fix)

ALSA Configuration

The following .asoundrc settings will allow Kodi to use exclusive HDMI passthrough, while defaulting to a dmix plugin for the Kodibuntu desktop mode (so that multiple applications can share HDMI access):

pcm.hdmi_hw {
        type hw
        card=0
        device=3
}

pcm.hdmi_direct {
        type route
        slave {
                pcm hdmi_hw
        }
        ttable.0.0 1
        ttable.1.1 1
        ttable.2.4 1
        ttable.3.5 1
        ttable.4.2 1
        ttable.5.3 1
}

pcm.hdmi_shared {
        type route
        slave {
                pcm hdmi_dmix
        }
        ttable.0.0 1
        ttable.1.1 1
        ttable.2.4 1
        ttable.3.5 1
        ttable.4.2 1
        ttable.5.3 1
}

pcm.hdmi_dmix {
        type dmix
        ipc_key 1024
        ipc_key_add_uid false
        ipc_perm 0666
        slave {
                pcm hdmi_hw
        }
}

pcm.!default {
        type plug
        slave.pcm "hdmi_shared"
}
Test passthrough mode with
speaker-test -D hdmi_direct -c 6
And default/shared mode with
speaker-test -c 6
It may also be worth testing each with -c 2 instead of -c 6 to ensure that 2-channel inputs will work.

Kodi Configuration

Within Settings -> System -> Audio Output, I set the following values:

  • Audio Output : HDMI
  • Speaker Configuration : 5.1
  • Boost volume level on downmix : No
  • Dolby Digital (AC3) capable receiver : Yes
  • DTS capable receiver : Yes
  • AAC capable receiver : Yes (note that AAC appears to reach my receiver as 5.1 LPCM, regardless of this setting)
  • MultiChannel LPCM capable receiver : Yes
  • Audio output device : HDA NVidia HDMI(hdmi_direct)
  • Passthrough output device : HDA NVidia HDMI(hdmi_direct) (note that this setting apparently doesn't matter, as Frodo seems to use the "Audio output device" setting for both passthrough and non-passthrough modes when "Audio Output" is set to "HDMI")

After a reboot, sound should be working as expected in both Kodi and in Kodibuntu desktop applications. Feel free to update this information as needed.

Attention talk.png Problem with 5.1 channel mapping, help configuring asound.conf

14.x Helix

It appears that remapping may no longer be necessary in Helix for the benefit of Kodi itself, as Kodi appears to perform the remapping itself in software. If remapping is needed for other Linux apps, it should be possible to still use the Frodo/Gotham .asoundrc above but configure Kodi itself to use an output that is not remapped.

Indeed the remapping can even cause Kodi to crash with AESink recording a segfault in libasound.

Pulseaudio

Some may find that removing Pulseaudio breaks other programs and causes problems. If your setup does not require passthrough and your receiver supports multichannel PCM, you may want to configure Pulseaudio instead. These directions were adapted from here.

Configure Pulseaudio

1. Run from the command-line:

speaker-test -c6 -twav

2. Note which channels need to be remapped, I just wrote them down like so:

  SOUND                      SPEAKER
Left Front          ————-> Left Front
Center Front        ————-> Left Rear
Right Front         ————-> Right Front
Left Rear           ————-> Center Front
Subwoofer (lfe)     ————-> Right Rear
Right Rear          ————-> Subwoofer (lfe)

3. Edit "/usr/share/pulseaudio/alsa-mixer/profile-sets/extra-hdmi.conf" with your favorite text editor as root. I'm using xubuntu 12.04, so I'll be using leafpad:

sudo leafpad /usr/share/pulseaudio/alsa-mixer/profile-sets/extra-hdmi.conf

4. This file contains the Pulseaudio profiles for your HDMI audio outputs. There should be a few entries that say something about 5.1 or 7.1 audio over HDMI. Like this:

[Mapping hdmi-surround]
description = Digital Surround 5.1 (HDMI)
device-strings = hdmi:%f
paths-output = hdmi-output-0
channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe
priority = 3
direction = output

Edit them to fit your needs based on the channel map you wrote down earlier. I edited all of them (except the 7.1 ones, as I only have a 5.1 setup, I would assume things would be similar for 7.1) like so:

[Mapping hdmi-surround]
description = Digital Surround 5.1 (HDMI)
device-strings = hdmi:%f
paths-output = hdmi-output-0
channel-map = front-left,front-right,front-center,lfe,rear-left,rear-right
priority = 3
direction = output

5. Restart Pulseaudio to load your new channel maps and run a speaker test:

pulseaudio -k
pulseaudio --start
speaker-test -c6 -twav

If everything is coming out of the right channel then you're all set!

Configure Kodi

Within Settings -> System -> Audio Output, set:

  • Audio Output : HDMI
  • Speaker Configuration : 5.1 (or 7.1 depeding on your setup)
  • Boost volume level on downmix : Yes
  • Dolby Digital (AC3) capable receiver : No
  • DTS capable receiver : No
  • Audio output device : defaults(Pulseaudio)
  • Passthrough output device : hdmi(ALSA) (won't be used, you can set it to whatever you'd like)

Note: Pulseaudio and Kodi do not work with passthrough as of Eden (not tested in Frodo, but likely the same). That is why we are telling Kodi the receiver can't decode AC3 and DTS. Theoretically speaking, there is no difference between decoding in software or on your receiver. Some may disagree, however the receiver tells me that it is indeed receiving 5.1 multichannel PCM. Sounds seem to be mapped correctly. Tested with Xubuntu 12.04, Eden, on an ASRock ION330 motherboard

Attention talk.png Linux: Remapping Pulseaudio Channels