Skip to content

Commit

Permalink
alsa: use tdm-b on s5 for hbr passthrough
Browse files Browse the repository at this point in the history
SoC does not support spdifb for hbr audio passthrough.
  • Loading branch information
Portisch committed Sep 17, 2024
1 parent a11505b commit 3edd7ed
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
2 changes: 2 additions & 0 deletions xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2649,6 +2649,8 @@ void CActiveAE::LoadSettings(AEAudioFormat *format)

switch (aml_get_cpufamily_id())
{
case AML_S5:
[[fallthrough]];
case AML_T7:
{
// find on NEWSTREAM the matching passthrough device by device type
Expand Down
5 changes: 3 additions & 2 deletions xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ void CActiveAESettings::SettingOptionsAudioDevicesFillerGeneral(
list.emplace_back("Error - no devices found", "error");
else
{
bool filter_passthrough = (aml_get_cpufamily_id() == AML_S5 || aml_get_cpufamily_id() == AML_T7);
for (AEDeviceList::const_iterator sink = sinkList.begin(); sink != sinkList.end(); ++sink)
{
// filter L-PCM device when passthrough on Amlogic T7
if (passthrough && aml_get_cpufamily_id() == AML_T7 &&
// filter L-PCM device when passthrough on Amlogic S5/T7
if (passthrough && filter_passthrough &&
StringUtils::StartsWith(sink->second, "ALSA:surround71"))
continue;

Expand Down
8 changes: 4 additions & 4 deletions xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAESink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ std::string CActiveAESink::ValidateOuputDevice(const std::string& device, bool p
if (!passthrough && d.m_onlyPassthrough)
continue;

// filter L-PCM device when passthrough on Amlogic T7
// filter L-PCM device when passthrough on Amlogic S5/T7
if (passthrough && (d.m_deviceName.substr(0, d.m_deviceName.find(':')) == "surround71"))
continue;

Expand All @@ -777,7 +777,7 @@ std::string CActiveAESink::ValidateOuputDevice(const std::string& device, bool p
if (!passthrough && d.m_onlyPassthrough)
continue;

// filter L-PCM device when passthrough on Amlogic T7
// filter L-PCM device when passthrough on Amlogic S5/T7
if (passthrough && (d.m_deviceName.substr(0, d.m_deviceName.find(':')) == "surround71"))
continue;

Expand Down Expand Up @@ -805,7 +805,7 @@ std::string CActiveAESink::ValidateOuputDevice(const std::string& device, bool p
if (!passthrough && d.m_onlyPassthrough)
continue;

// filter L-PCM device when passthrough on Amlogic T7
// filter L-PCM device when passthrough on Amlogic S5/T7
if (passthrough && (d.m_deviceName.substr(0, d.m_deviceName.find(':')) == "surround71"))
continue;

Expand Down Expand Up @@ -838,7 +838,7 @@ std::string CActiveAESink::ValidateOuputDevice(const std::string& device, bool p
if (!passthrough && d.m_onlyPassthrough)
continue;

// filter L-PCM device when passthrough on Amlogic T7
// filter L-PCM device when passthrough on Amlogic S5/T7
if (passthrough && (d.m_deviceName.substr(0, d.m_deviceName.find(':')) == "surround71"))
continue;

Expand Down
21 changes: 18 additions & 3 deletions xbmc/cores/AudioEngine/Sinks/AESinkALSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ void CAESinkALSA::aml_configure_simple_control(std::string &device, const enum I
"Audio spdif_b format", // set SPDIF-B codec format
"",
"",
"Audio I2S to HDMITX Format" // set TDM-C codec format
"Audio I2S to HDMITX Format" // set TDM codec format
};

int cardNr = 0;
Expand Down Expand Up @@ -639,6 +639,17 @@ void CAESinkALSA::aml_configure_simple_control(std::string &device, const enum I
case AE_DEVTYPE_HDMI:
case AE_DEVTYPE_PCM:
switch (soc_id) {
case AML_S5:
switch (codec) {
case TRUEHD:
case _DTS_HD_MA:
spdif_id = HDMITX_SRC_TDM_B;
break;
default:
spdif_id = HDMITX_SRC_SPDIF_B;
break;
}
break;
case AML_T7:
switch (codec) {
case TRUEHD:
Expand Down Expand Up @@ -1607,8 +1618,9 @@ void CAESinkALSA::EnumerateDevicesEx(AEDeviceInfoList &list, bool force)

AEDeviceType CAESinkALSA::AEDeviceTypeFromName(const std::string &name)
{
bool mark_surround71_as_hdmi = (aml_get_cpufamily_id() == AML_S5 || aml_get_cpufamily_id() == AML_T7);
if (name.substr(0, name.find(':')) == "hdmi" ||
(aml_get_cpufamily_id() == AML_T7 && name.substr(0, name.find(':')) == "surround71"))
(mark_surround71_as_hdmi && name.substr(0, name.find(':')) == "surround71"))
return AE_DEVTYPE_HDMI;
else if (name.substr(0, name.find(':')) == "iec958" || name.substr(0, name.find(':')) == "spdif")
return AE_DEVTYPE_IEC958;
Expand Down Expand Up @@ -1867,6 +1879,7 @@ void CAESinkALSA::EnumerateDevice(AEDeviceInfoList &list, const std::string &dev

if (GetAMLDeviceType(info.m_displayName) != AML_NONE)
{
bool use_surround71_as_lpcm = (aml_get_cpufamily_id() == AML_S5 || aml_get_cpufamily_id() == AML_T7);
if (info.m_deviceType == AE_DEVTYPE_IEC958)
info.m_displayNameExtra = "S/PDIF";
else if (info.m_deviceType != AE_DEVTYPE_HDMI)
Expand All @@ -1876,7 +1889,7 @@ void CAESinkALSA::EnumerateDevice(AEDeviceInfoList &list, const std::string &dev
else
info.m_displayNameExtra = "PCM";
}
else if (aml_get_cpufamily_id() == AML_T7 && info.m_deviceType == AE_DEVTYPE_HDMI)
else if (use_surround71_as_lpcm && info.m_deviceType == AE_DEVTYPE_HDMI)
{
if (device.substr(0, device.find(':')) == "surround71")
info.m_displayNameExtra = "HDMI Multi Ch PCM";
Expand All @@ -1888,6 +1901,8 @@ void CAESinkALSA::EnumerateDevice(AEDeviceInfoList &list, const std::string &dev
{
switch (aml_get_cpufamily_id())
{
case AML_S5:
[[fallthrough]];
case AML_T7:
{
if (device.substr(0, device.find(':')) == "surround71")
Expand Down

0 comments on commit 3edd7ed

Please sign in to comment.