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

From Official Kodi Wiki
Jump to navigation Jump to search
(→‎ALSA Configuration: update to fix dmix errors when using Steam in-home streaming client on XBMCBuntu; TODO: test bindings settings in place of ttable)
mNo edit summary
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Some early Nvidia ION based motherboards have their HDMI audio channels mapped incorrectly. There are two relatively simple methods to remap HDMI audio 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.
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.
It should be noted that whenever editing config files, it's best to backup the original.
 
==Remapping Surround Channels (ALSA)==


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


Line 15: Line 14:
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)
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)


===For 7.1: Eden===
=== 11.x Eden with 7.1 speakers ===
====ALSA Configuration====
==== ALSA Configuration ====
Untested in Frodo.
Untested in Frodo.
<pre>
<pre>
Line 40: Line 39:
Hopefully the channels will now be mapped correctly.
Hopefully the channels will now be mapped correctly.


====XBMC Configuration====
==== Kodi Configuration ====
Within Settings -> System -> Audio Output, I set the following values:
Within Settings -> System -> Audio Output, I set the following values:


Line 52: Line 51:
* Passthrough output device : '''hdmi(ALSA)'''
* Passthrough output device : '''hdmi(ALSA)'''


====Menu Sounds====
==== Menu Sounds ====
:{{Note|Not needed in Frodo.}}
:{{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:
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:
Line 61: Line 60:
}</pre>
}</pre>


===For 5.1: Frodo and Later===
=== 12.x Frodo / 13.x Gotham with 5.1 speakers (simple fix) ===
====ALSA Configuration====
==== ALSA Configuration ====
<pre>
<pre>
pcm.!default {
pcm.!default {
Line 70: Line 69:
     }
     }
}
}
pcm.both {
pcm.both {
     type route
     type route
Line 88: Line 86:
<pre>speaker-test -D hdmi -c 6</pre>
<pre>speaker-test -D hdmi -c 6</pre>


====XBMC Configuration====
==== Kodi Configuration ====
Within Settings -> System -> Audio Output, I set the following values:
Within Settings -> System -> Audio Output, I set the following values:


Line 103: Line 101:
{{forum link2|[[forum:147733|'''Linux''' Frodo HDMI audio channel remap discussion]]}}
{{forum link2|[[forum:147733|'''Linux''' Frodo HDMI audio channel remap discussion]]}}


===For 5.1 with desktop application support on XBMCbuntu Frodo===
=== 12.x Frodo / 13.x Gotham with 5.1 speakers (including desktop application fix) ===
====ALSA Configuration====
==== ALSA Configuration ====
The following .asoundrc settings will allow XBMC to use exclusive HDMI passthrough, while defaulting to a dmix plugin for the XBMCbuntu desktop mode (so that multiple applications can share HDMI access):
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):


<pre>pcm.hdmi_hw {
<pre>pcm.hdmi_hw {
Line 164: Line 162:
;It may also be worth testing each with -c 2 instead of -c 6 to ensure that 2-channel inputs will work.
;It may also be worth testing each with -c 2 instead of -c 6 to ensure that 2-channel inputs will work.


====XBMC Configuration====
==== Kodi Configuration ====
Within Settings -> System -> Audio Output, I set the following values:
Within Settings -> System -> Audio Output, I set the following values:


Line 177: Line 175:
* 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")''
* 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 XBMC and in XBMCbuntu desktop applications. Feel free to update this information as needed.
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.


{{forum link2|[[forum:90910|Problem with 5.1 channel mapping, help configuring asound.conf]]}}
{{forum link2|[[forum:90910|Problem with 5.1 channel mapping, help configuring asound.conf]]}}


==Remapping Surround Channels (Pulseaudio)==
=== 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.
 
=== 15.x Isengard with 5.1 speakers (including desktop application fix) ===
Remapping is definitely still needed for me for all forms of non-pass-through 5.1 audio.
 
For some reason, my ALSA config for 12.x/13.x above no longer works for Kodibuntu 15.2 in desktop mode logins (no sound at all), so here's an updated .asoundrc that works as before:
<pre># --auto-generated-- by /etc/xbmc/live.d/01-make-asoundrc.sh
# AUTOUPDATE=False  # change this to disable updating of this file
pcm.hdmi_hw {
type hw
card=0
device=3
}
 
pcm.hdmi_dmix {
        type dmix
        ipc_key 5678293
        ipc_key_add_uid true
        ipc_perm 0660
ipc_gid audio
        slave {
channels 6
pcm {
format S16_LE
rate 48000
nonblock true
type hw
card 0
device 3
}
period_size 1024
buffer_size 8192
        }
}
 
pcm.hdmi_direct {
type plug
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 plug
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.!default {
type plug
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
}
</pre>
 
== 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 [http://askubuntu.com/questions/48406/inverted-surround-channels/142942#142942 here.]
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 [http://askubuntu.com/questions/48406/inverted-surround-channels/142942#142942 here.]


===Configure Pulseaudio===
=== Configure Pulseaudio ===
1. Run from the command-line: <pre>speaker-test -c6 -twav</pre>
1. Run from the command-line: <pre>speaker-test -c6 -twav</pre>


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


===Configure XBMC===
=== Configure Kodi ===
Within Settings -> System -> Audio Output, set:
Within Settings -> System -> Audio Output, set:


Line 234: Line 310:
* Passthrough output device : '''hdmi(ALSA)''' (won't be used, you can set it to whatever you'd like)
* Passthrough output device : '''hdmi(ALSA)''' (won't be used, you can set it to whatever you'd like)


{{note|Pulseaudio and XBMC do not work with passthrough as of Eden (not tested in Frodo, but likely the same). That is why we are telling XBMC 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.}}
{{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, XBMC Eden, on an ASRock ION330 motherboard
Tested with Xubuntu 12.04, Eden, on an ASRock ION330 motherboard


{{forum link2|[[forum:150806|Linux: Remapping Pulseaudio Channels]]}}
{{forum link2|[[forum:150806|Linux: Remapping Pulseaudio Channels]]}}
[[Category:How-to]]
[[Category:Linux]]

Latest revision as of 05:50, 23 July 2020

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.

15.x Isengard with 5.1 speakers (including desktop application fix)

Remapping is definitely still needed for me for all forms of non-pass-through 5.1 audio.

For some reason, my ALSA config for 12.x/13.x above no longer works for Kodibuntu 15.2 in desktop mode logins (no sound at all), so here's an updated .asoundrc that works as before:

# --auto-generated-- by /etc/xbmc/live.d/01-make-asoundrc.sh
# AUTOUPDATE=False  # change this to disable updating of this file
pcm.hdmi_hw {
	type hw
	card=0
	device=3
}

pcm.hdmi_dmix {
        type dmix
        ipc_key 5678293
        ipc_key_add_uid true
        ipc_perm 0660
	ipc_gid audio
        slave {
		channels 6
		pcm {
			format S16_LE
			rate 48000
			nonblock true
			type hw
			card 0
			device 3
		}
		period_size 1024
		buffer_size 8192
        }
}

pcm.hdmi_direct {
	type plug
	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 plug
	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.!default {
	type plug
	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
}

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