Only 6.1 LPCM for 7.1 sources with Raspberry Pi

  • I have a Sony STR-DH520 amp, and the Raspberry PI only ever sends 6.1 sound when using LPCM.

    6.1 shows an indicator of a channel in the middle rear, instead of within the two speaker indicators for left/right at the read.

    The amp can receive 7.1 LPCM from a Blu-Ray player (set to send LPCM not DTS /DD etc) - all the speaker indicators light up. Passthrough of 7.1 TrueHD from the PI also works.

    I'm sure that once upon a time 7.1 LPCM used to work from the PI.

    It's quite possibly down the the Raspberry PI OS - this also happens with the speaker-test from the command line, and also from an install of OSMC, but I'd appreciate any help with either configuration or directions to the correct place to report it.

    Many thanks for any help anyone can offer.

  • Can you please more specific?

    - which RPi? 1, 2, 3, 4, 5 ?
    - which LE version?

    The best way to provide the needed details is to enable debug logging (Settings → System → Logging), reboot and paste here the link to the log only:
    https://wiki.libreelec.tv/support/log-files

    If you currently use LE 11.0.6 or earlier, please try a current nightly - because there was important changes regarding EDID data. EDID data is the source for the audio channel information and must be correct.

  • It looks to me that the speakers that are requested not matching the speaker setup reported by your amp. The channels SL and SR are not listed by your amplifier.

    Code
    2024-04-30 11:57:42.244 T:901      info <general>:     Device 4
    2024-04-30 11:57:42.244 T:901      info <general>:         m_deviceName      : hdmi:CARD=vc4hdmi,DEV=0
    2024-04-30 11:57:42.244 T:901      info <general>:         m_displayName     : vc4-hdmi (vc4hdmi)
    2024-04-30 11:57:42.244 T:901      info <general>:         m_displayNameExtra: SNY SONY AVAMP on HDMI
    2024-04-30 11:57:42.244 T:901      info <general>:         m_deviceType      : AE_DEVTYPE_HDMI
    2024-04-30 11:57:42.244 T:901      info <general>:         m_channels        : FL, FR, LFE, FC, BL, BR, BC, BLOC, BROC
    2024-04-30 11:57:42.244 T:901      info <general>:         m_sampleRates     : 32000,44100,48000,88200,96000,176400,192000
    2024-04-30 11:57:42.244 T:901      info <general>:         m_dataFormats     : AE_FMT_RAW,AE_FMT_S24NE3,AE_FMT_S24NE4,AE_FMT_S32NE,AE_FMT_S16NE,AE_FMT_S16LE,AE_FMT_S16BE,AE_FMT_U8,AE_FMT_RAW
    2024-04-30 11:57:42.244 T:901      info <general>:         m_streamTypes     : STREAM_TYPE_AC3,STREAM_TYPE_DTSHD,STREAM_TYPE_DTSHD_MA,STREAM_TYPE_DTSHD_CORE,STREAM_TYPE_DTS_1024,STREAM_TYPE_DTS_2048,STREAM_TYPE_DTS_512,STREAM_TYPE_EAC3,STREAM_TYPE_TRUEHDz

    Requested by the play process:

    Code
    2024-04-30 11:58:26.562 T:902     debug <general>: CAESinkALSA::GetChannelLayout - Requested Layout: FL, FR, FC, LFE, BL, BR, SL, SR
    2024-04-30 11:58:26.562 T:902     debug <general>: CAESinkALSA::GetChannelLayout - Got Layout: FL, FR, LFE, FC, BL, BR, BC, UNKNOWN1 (ALSA: FL FR LFE FC RL RR RC NA)


    I have seen in the manual of the amplifier, that it supports different speaker schemes. How many and which type of speakers do you have? Maybe you should ensure to set it to 3/4.1 and try it again.

    Edit: Some minutes ago I have looked into my kodi.log. With my receiver I get also BLOC and BROC instead of SL/SR reported. I will test it tomorrow with that files if I come to the same result like you:

    GitHub - sfiera/flac-test-files: FLAC test files for multi-channel sound systems
    FLAC test files for multi-channel sound systems. Contribute to sfiera/flac-test-files development by creating an account on GitHub.
    github.com

    Edited 3 times, last by HarryH (April 30, 2024 at 10:15 PM).

  • Quote

    I have seen in the manual of the amplifier, that it supports different speaker schemes. How many and which type of speakers do you have? Maybe you should ensure to set it to 3/4.1 and try it again.

    I've got 3 front speakers, subwoofer, 2 side rear and 2 back rear. The speaker pattern was already set to 3/4.1

    Hopefully you're able to reproduce the problem. When I try those test files I get the following problems:

    • 7.1 is played as 6.1
    • I'm not sure the speaker assignments are right beyond 5.1
    • When going between files, the output layout only changes when a new speaker is addressed (mid-file, not at the start of the file). eg Play the 5.0 test and automatically advance to 5.1, and it continues with a 5.0 layout until the subwoofer part of the file, then the layout changes. This is true with output format optimized or best match. (Fixed uses 6.1 for everything)
  • The AVR advertises BL/BR and BLOC/BROC over HDMI. ALSA refers to BLOC/BROC as RLC/RRC but the media being played uses a normal 7.1 layout with SL/SR side speakers which alsa matches to SL/SR using: https://github.com/xbmc/xbmc/blob…A.cpp#L288-L289.

    If the widest rear speakers are denoted as BL/BR i'd argue that Kodi is doing the right thing when it sees BL/BR with an exact match and then maps the inner rears as a virtual RC channel resulting in a 6.1 layout. It doesn't make sense to me to use inner-rears as BL/BR and the outer-rears as SL/SR. If that's the result you're looking for; reconfigure the positions in the AVR or rewire the speakers to be SL/BL/BR/SR then the ELD presentation should reflect that and Kodi should give you that.

  • Hi chewitt ,

    thank you for the clarifying. But currenly I'm little bit confused and get a node in my head. Do you have a perhaps a link to a sketch about the different positioning of SL/SR vs. BL/BR vs. BLOC/BROC speakers please?

    I'm asking because my DENON 3808 AVR reports this setup via HDMI (EDID decode) and thinking the SONY AVR of _marklam_ behaves the same :

    Code
     Speaker Allocation Data Block:
       FL/FR - Front Left/Right
       LFE1 - Low Frequency Effects 1
       FC - Front Center
       BL/BR - Back Left/Right
       BC - Back Center
       RLC/RRC - Rear Left/Right of Center (Deprecated)

    This 7.1 AVR has 6 terminals for 2x Surround A + 2x optional Surround B and additional 2x Surround Back Left/Right speakers. The Surround A terminals should be used for a 5.1 setup and the speakers placed sideways or little bit behind of the main seating.

    Currently I think BL/BR is mapped to Surround A + B and RLC/RRC is virtual in 5.1 mode. Because I currently haven't a 7.1 speaker setup I can only relies on the reported input signal.

    In that sketch for the 7.1 speaker setup example, it looks to me
    https://www.intel.com/content/dam/support/us/en/images/mini-pcs/7.1.jpg

    • that BL/BR is moved to my assumed RLC/RRC position
    • and SL/SR replaces my assumed BL/BR position

    During my research I found this kind of adapters too: https://www.allaboutadapters.com/au-hcp2.html I'cant see a different positioning for SL/SR vs. BL/BR

    I'm wonder if AESinkALSA should doing the same with LPCM 7.1 media files?

    • map media SL/SR -> HDMI BL/BR channel
    • map media BL/BR -> HDMI RLC /RRC channel

    Being I'm totally wrong with that idea? Or does all others 7.1 receivers advertise SL/SR via HDMI additional?

    EDIT:

      HiassofT Could it be that there is already an option for that, but a condition is wrong (channel replacement looks not executed) :?:

    xbmc/xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp at 7c7f08a545d6011aa05c0ece2b960452b65e3457 · xbmc/xbmc
    Kodi is an award-winning free and open source home theater/media center software and entertainment hub for digital media. With its beautiful interface and…
    github.com

    Edited 9 times, last by HarryH (May 1, 2024 at 9:09 PM).

  • Once Kodi figures out how it wants to output it requests alsa channel maps and then walks the list to find a match. List ordering is involved here so _marklam_ please update to https://chewitt.libreelec.tv/testing/LibreE….arm-12.0.0.tar and see if anything changes for you. It's the LE12 release with some personal cosmetic changes and https://github.com/chewitt/linux/…95c6bb50b5431c3 applied to the kernel. I don't think it will make a difference, but you never know.

  • When you open a HDMI audio device on the RPi the kernel automatically chooses a channel map based on the number of channels (eg 8 in this case) and the speaker allocation from the EDID.

    The hdmi-codec driver has an ordered list, sorted by preference, and will choose the first entry that's supported by HDMI for the given number of channels and is supported by the AVR as well (all channels of that entry must also be present in the EDID speaker allocation block).

    In this table the 6.1 entry with RC comes before the 7.1 entry with the (deprecated) RLC/RRC entries, so if your AVR announces support for both RC and RLC/RRC you'll get the former (6.1) channel map

    linux/sound/soc/codecs/hdmi-codec.c at 3a8b7204348682152b77618eed061e8718db5935 · raspberrypi/linux
    Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at…
    github.com
    Code
    	/* 6.1 */
    	{ .ca_id = 0x0f, .n_ch = 8,
    	  .mask = FL | FR | LFE | FC | RL | RR | RC },
    	/* surround71 */
    	{ .ca_id = 0x13, .n_ch = 8,
    	  .mask = FL | FR | LFE | FC | RL | RR | RLC | RRC },

    It's then up to kodi to decide how to best map the channels of the media file to those channels.

    In general it's best to use passthrough for compressed audio formats as this avoids all the channel mapping shenanigans but that may not be an option on RPi2/3 as they don't support TrueHD or DTS-HD because of hardware limitations/bugs (they also can't output 8ch 192kHz PCM).

    so long,

    Hias

  • Hi HiassofT , chewitt ,

    thank for your both comments/doings. Yesterday night I tested just for a short time window with the sample multichannel FLAC files. But there was some strange behavior, which has looked like the issues that _marklam_ reported.
    Yes, I prefer the passthrough way too. My RPi4 and my AVR are able to support that. But the current use case of multichannel FLAC (7.1 LPCM) files differs a little bit. I’m interpreting this as the only available way to get („passthrough“) the multichannel audio lossless to the speakers.

    chewitt
    I will try the image you provided and give you a feedback. It would be nice, if _marklam_ will test it with real music files and hopefully can confirm that it‘s working now. :)

    EDIT:
    The image chewitt has provided is for RPi2/3 only, so I can't test it with my RPi4. _marklam_ it's now your turn. ;)

    Edited 2 times, last by HarryH (May 2, 2024 at 2:00 PM).

  • I've just checked it, and can confirm it does make the 7.1 files play back with the two separate rear speakers as expected

    Thanks chewitt and HarryH for the work & help!

    The only thing to note, which may be expected, is that playing the 6.1 test file illuminates the amp's indicatators for the two rears, not the rear centre. It's not a problem (on my setup) though because the 'rear center' announcement is played through both rear speakers as I'd expect.

  • Thank you for providing the additional image.

    Only for sureness, I have tested with different KODI LPCM audio and video sample files: https://kodi.wiki/view/Samples

    With the official 12.0.0 image the mapping was wrong (6.1 -> RC)

    and after update to the image with the patch provided by you it's now correct 7.1 (RLC/RRC):

  • I'm going to send a PR to add this patch into LE12 nightlies (and then 12.0.1) and if no issue reports come up I'll send it to the upstream kernel. I'm reasonably confident it doesn't cause issues as it's been included in my Amlogic images for several years already, but those don't have the size of audience that RPi has so a little caution is needed.