Ugoos X4 Pro Amlogic-ne audio device switching

some errors about about alsa lib config (audio specific debugging on)

# grep portisch kodi.log | cut -c 72- | sort | uniq -c | sort -n
      1 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/conf.c:5180:(_snd_config_evaluate) function snd_func_card_inum returned error: No such device
      1 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/conf.c:5180:(_snd_config_evaluate) function snd_func_concat returned error: No such device
      1 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/conf.c:5180:(_snd_config_evaluate) function snd_func_refer returned error: No such device
      1 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/conf.c:5703:(snd_config_expand) Evaluate error: No such device
      1 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/confmisc.c:1334:(snd_func_refer) error evaluating name
      1 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.hdmi.1:CARD=AMLAUGESOUND,AES0=4,AES1=130,AES2=0,AES3=2'
      1 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.iec958.1:CARD=AMLAUGESOUND,AES0=4,AES1=130,AES2=0,AES3=2'
      1 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/confmisc.c:1369:(snd_func_refer) Unable to find definition 'cards.0.pcm.surround71.1:CARD=AMLAUGESOUND'
      1 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/confmisc.c:422:(snd_func_concat) error evaluating strings
      1 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/confmisc.c:855:(parse_card) cannot find card '$CARD'
      2 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/conf.c:5516:(parse_args) Unknown parameter DEV
      3 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/conf.c:5180:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
      3 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/conf.c:5703:(snd_config_expand) Evaluate error: No such file or directory
      8 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/conf.c:5516:(parse_args) Unknown parameter CARD
     10 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/conf.c:5687:(snd_config_expand) Parse arguments error: No such file or directory
     13 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/conf.c:5670:(snd_config_expand) Unknown parameters CARD=AMLAUGESOUND
     13 /home/portisch/CE/CoreELEC/build.CoreELEC-Amlogic-ne.arm-20/build/alsa-lib-1.2.8/src/conf.c:5670:(snd_config_expand) Unknown parameters CARD=AMLAUGESOUND,DEV=0

also if I compare with working NG 20.1-Nexus [S922X] Bee-link GT King it seems NE [S905X4] Ugoos X4 Pro has less output

CoreGT:~ # dmesg | grep -i sound
[    0.513375@2]- Advanced Linux Sound Architecture Driver Initialized.
[    0.972618@2]- asoc-aml-card auge_sound:     link 0:
[    0.972691@2]- asoc-aml-card auge_sound:     name : SPDIF-B-dummy
[    0.972694@2]- asoc-aml-card auge_sound:     format : 4010
[    0.972696@2]- asoc-aml-card auge_sound:     cpu : SPDIF-B / 6144000
[    0.972698@2]- asoc-aml-card auge_sound:     codec : dummy / 0
[    0.972700@2]- asoc-aml-card auge_sound:     link 1:
[    0.972759@2]- asoc-aml-card auge_sound:     name : TDM-B-T9015-audio-hifi
[    0.972761@2]- asoc-aml-card auge_sound:     format : 4011
[    0.972762@2]- asoc-aml-card auge_sound:     cpu : TDM-B / 12288000
[    0.972764@2]- asoc-aml-card auge_sound:     codec : T9015-audio-hifi / 0
[    0.972766@2]- asoc-aml-card auge_sound:     link 2:
[    0.972812@2]- asoc-aml-card auge_sound:     name : SPDIF-A-dummy
[    0.972814@2]- asoc-aml-card auge_sound:     format : 4010
[    0.972816@2]- asoc-aml-card auge_sound:     cpu : SPDIF-A / 6144000
[    0.972818@2]- asoc-aml-card auge_sound:     codec : dummy / 0
[    0.972820@2]- asoc-aml-card auge_sound:     link 3:
[    0.972876@2]- asoc-aml-card auge_sound:     name : TDM-C-dummy
[    0.972878@2]- asoc-aml-card auge_sound:     format : 4011
[    0.972880@2]- asoc-aml-card auge_sound:     cpu : TDM-C / 12288000
[    0.972882@2]- asoc-aml-card auge_sound:     codec : dummy / 0
[    1.178995@2]- asoc-aml-card auge_sound: control 2:0:0:I2SIn CLK:0 is already present
[    1.194805@2]- asoc-aml-card auge_sound: dummy <-> SPDIF-B mapping ok
[    1.194881@2]- asoc-aml-card auge_sound: T9015-audio-hifi <-> TDM-B mapping ok
[    1.194949@2]- asoc-aml-card auge_sound: dummy <-> SPDIF-A mapping ok
[    1.195020@2]- asoc-aml-card auge_sound: dummy <-> TDM-C mapping ok
[    1.380248@3]-   #0: AML-AUGESOUND
  ---
Ugoos-X4-Pro:~ # dmesg | grep -i sound
[    0.740131@2]  Advanced Linux Sound Architecture Driver Initialized.
[    2.994196@0]  asoc-aml-card auge_sound: IRQ audio_exception64 not found
[    2.995675@0]  asoc-aml-card auge_sound: SPDIF-B <-> SPDIF-B mapping ok
[    2.995760@0]  asoc-aml-card auge_sound: TDM-B <-> TDM-B mapping ok
[    2.995821@0]  asoc-aml-card auge_sound: SPDIF <-> SPDIF mapping ok
[    2.995888@0]  asoc-aml-card auge_sound: soc:dummy <-> TDM-C mapping ok
[    3.137100@1]    #0: AML-AUGESOUND
  ---

Note “IRQ audio_exception64 not found”

I am not ALSA expert but it seems auge_sound on X4 Pro acts not well

Quick question:

I built image myself and now I want to try a change to the ugoos x4 dts.

But if I do

make -j31 release
make -j31 image

the dtb is not rebuilt …

Any hint to rebuild the updated ugoos x4 dtb?

./scripts/clean linux
./scripts/unpack linux
# change something in folder build.CoreELEC...../build/linux-...../
./scripts/build linux
# new dtb build as build.CoreELEC...../build/linux-...../arch/arm64/boot/dts/amlogic/sc2_s905x4_ugoos_x4.dtb
1 Like

Perfect ! I guess these are generic clean/unpack/build steps for any ingredient …
Let me go from here and keep you informed.
My guess is that avout_mute-gpios may affect the AV-OUT functionality so I am setting it to default value.

setting dts value from

avout_mute-gpios = <&gpio GPIOD_2 GPIO_ACTIVE_HIGH>;

to

avout_mute-gpios = <&gpio GPIOH_5 GPIO_ACTIVE_HIGH>;

did change /sys/firmware/devicetree/base/auge_sound/avout_mute-gpios
but did not fix problem …

Ugoos-X4-Pro:~ # cat /sys/firmware/devicetree/base/auge_sound/avout_mute-gpios
.Ugoos-X4-Pro:~ # 
Ugoos-X4-Pro:~ # od /sys/firmware/devicetree/base/auge_sound/avout_mute-gpios
0000000  000000 013400 000000 027000 000000 000000              
0000014
Ugoos-X4-Pro:~ # od tmp/avout_mute-gpios
0000000  000000 013400 000000 017400 000000 000000              
0000014

here is same on working ng GT King

CoreGT:~ # cat /sys/firmware/devicetree/base/auge_sound/avout_mute-gpios
YCoreGT:~ # od /sys/firmware/devicetree/base/auge_sound/avout_mute-gpios
0000000  000000 054400 000000 001000 000000 000000              
0000014

The human readable Y perhaps gives more confidence as well …

But again: I am no expert.

update: default GPIOH_5 was not a good choice to begin with as it is taken by regulator-vbus_usb in dts.

Ugoos-X4-Pro:~ # cat /sys/kernel/debug/gpio | grep GPIOH_5
 gpio-471 (GPIOH_5             |regulator-vbus_usb  ) out hi 

similar posts:

I decompiled Android 11 X4_1.1.4 ROM sc2_s905x4_X4 dtb image and CoreELEC Amlogic-ne Ugoos X4 sc2_s905x4_ugoos_x4 dtb image, both are for 5.4.125 linux kernel, and there are some differences in auge_sound section, but, I do not have the knowledge to sufficiently understand.

Also: /proc/interrupts on Android shows ‘31 … fe330000.audiobus:tdm@1’ but no such audiobus interrupt on CoreELEC (despite audiobus@0xFE330000 section in CoreELEC dts).

Finally, some CONFIG_AMLOGIC_SND_SOC _ are not in CoreELEC kernel .config (but I kind of doubt if that matters).

And, if I am right, as shown with ‘uname -a’: CoreELEC ne kernel is 64bit aarch64 whereas Android 11 kernel is 32bit armv8l.

Question: does CoreELEC team have the Ugoos X4 Pro 5.4.125 linux kernel source and .config?

This?

GPIOD_2 is what we saw in DTS from Ugoos.

1 Like

@vpeter

Thanks for kind attention. Note that I am only thinking aloud with no concrete path to solution. So I apologize.

Right, GPIOD_2 has value 31=0x1f from
avout_mute-gpios = <0x1b 0x1f 0x00>;
as in
include/dt-bindings/gpio/meson-sc2-gpio.h:43:#define GPIOD_2 31

Here are full decompiled dtb-android.img and dtb-coreelec.img:
dtb-android.dts https://paste.c-net.org/FeministSpied
dtb-coreelec.dts https://paste.c-net.org/JacksonWharton

The auge_sound section for android seems different from and longer than the coreelec one.

Here are android and coreelec interrupts:
Android.interrupts https://paste.c-net.org/SingleSpanking
CoreELEC.interrupts https://paste.c-net.org/DreidelBryce

The coreelec interrupt 31 seems to have no name.

Also recall:

platform_get_irq_byname(pdev, "audio_exception64");

gave:

“IRQ audio_exception64 not found”

And there are also the alsa lib config errors in provided kodi.log.

Then also there are a few:

# CONFIG_AMLOGIC_SND_SOC_XYX is not set

in CoreELEC .config (which is why I wonder if CoreELEC team has Ugoos X4 Android kernel source and .config, note that it has no /proc/config.gz)

I am a bit looking into the dark on how to search. But I am very happy to help. I only found a few indications that may or may not correlate to av-out disfunctionality.

Question: does anyone from CoreELEC dev team have a Ugoos X4 (Cube|Pro|Plus)? Perhaps my hardware deviates?

I have meanwhile also tested NG (CoreELEC-Amlogic-ng.arm-20.1-Nexus-Generic) both with sc2_s905x4_ugoos_x4.dtb and sc2_s905x4_4g_1gbit.dtb and the exact same (dis)functionality is observed as with NE : AV-OUT does not give PCM sound no matter what ALSA device is choosen.

One will always have HDMI sound though.

For me personally it is not a severe issue because I can choose Pulseaudio bluetooth (albeit not all my BT audio devices give non stuttering sound, but that aside is a totally separate observation), and, fortunately, my HDMI input monitor has AV-OUT audio jack output, so: that serves as simple AV-OUT workaround for me.

Still, I stay happy to be available for any testing or source code change diff hints to build and try.

Again : big congratulations and big thanks for bringing CoreELEC to the community.

If anyone else has a supported Ugoos X4 (Cube|Pro|Plus) please feel free to comment and raise an appropriate hand.

update: I also tested NE O α CoreELEC-Amlogic-ne.aarch64-21.0-Omega_alpha1-Generic with sc2_s905x4_ugoos_x4.dtb in order to eliminate potential 64bit kernel versus 32|64bit userland mismatches, but, again, I see exact same (mis)behavior for what the AV-OUT audio matters. So, in terms of basic testing purpose, I hope I have provided sufficient evidence. I should repeat: the box and software does not disappoint me as it does what I need. But if I can help to improve CE, perhaps for others, I am ready and would be delighted to try to do so and proud to contribute.

I do have Ugoos X4 Cube but on none device I did any analog out testing. But will check it out in next days.

And no, we do not have Ugoos X4 Android kernel source and .config.

1 Like

I did some testing but sadly no sound comes from it. Need to find one device to make comparison but sound is not my area of work.

Not much help from my side.

1 Like

Thanks @vpeter to confirm and for your valuable time.

It does help in that finally I now realize my hardware does not differ from any other Ugoos X4 (Pro) for sure.

I may try myself to fix the ALSA AV-OUT, and, I guess, but I cannot test, also the ALSA S/PDIF-OUT.

I asked Ugoos support for some assistance as well.
In theory they should provide their Linux source and .config.

As said: the specific limitation does not hurt me at all, but, I would be happy if one could reach 100% CE functionality, if not for myself, then probably for some or few others.

Have a nice day and thanks for contributing to CE!

They are not needed to provide their Linux, no.
Only the base Linux what is used and under GPL.

So vendor kernel - vendor changes - Amlogic modifications → mainline Linux.
You can dump your Android Linux config by terminal somehow. But they use arm, we use arm64.

The Alsa config is a generic one for all devices so I don’t think the error is located there.
You will need to search a driver for the analog audio amp SoC.
Open the device and find by the amp marking what driver is needed for the assembled amp.

1 Like

@Portisch

Thanks for explaining the relevant aspects of Linux source code licence. It now seems I have never fully and correctly understood these.

The Android Ugoos kernel has no support for /proc/config.gz (as I could verify via adb and being root). But there may be another way to dump it.

Thanks for explaining most probably a driver needs to be added for the specific audio hardware.

Unfortunately I cannot figure out how to open this box (I have opened some boxes in the past though).

I will perhaps ask Ugoos support which analog audio amp SoC is used in the device.

Inside X4 Cube is only see TPF632C near the connector.

3-VRMS Audio Line Driver with Integrated Charge Pump

https://static6.arrow.com/aropdfconversion/3711a2c3dd70eaf1f86de013136d910d8f129302/tpf632c-tpf605c-tpf607c.pdf

1 Like

The same line driver is used on X4 Pro according here

So SOC internal DAC is used, with ext. line driver, which needs to be enabled.
The question left (to UGOOS): which GPIO is used for ENABLE?

1 Like

Hi @rho-bot @Portisch @vpeter

X4 online spec mentions

Built-in serial digital audio SPDIF/IEC958 output and PCM input/output

FYI : I built image with kernel having all CONFIG_SND_SOC_XYZ_SPI=m and CONFIG_SND_SOC_XYY_I2C=m hoping maybe one of them fits the 3PEAK TPF632C audio.

I did modprobe all modules but I get no different (i.e. no working av) audio behavior.
So my hope was not correct or appropriate.

I guess perhaps we need specific hardware or vendor driver code for TPF632C?

Sorry for my somewhat wet finger guessing

here is diff with official .config

CONFIG_SND_SOC_ADAU1761_I2C=m
CONFIG_SND_SOC_ADAU1761=m
CONFIG_SND_SOC_ADAU1761_SPI=m
CONFIG_SND_SOC_ADAU17X1=m
CONFIG_SND_SOC_ADAU_UTILS=m
CONFIG_SND_SOC_CS4270=m
CONFIG_SND_SOC_CS4271_I2C=m
CONFIG_SND_SOC_CS4271=m
CONFIG_SND_SOC_CS4271_SPI=m
CONFIG_SND_SOC_ES8328_I2C=m
CONFIG_SND_SOC_ES8328=m
CONFIG_SND_SOC_ES8328_SPI=m
CONFIG_SND_SOC_PCM179X_I2C=m
CONFIG_SND_SOC_PCM179X=m
CONFIG_SND_SOC_PCM179X_SPI=m
CONFIG_SND_SOC_PCM186X_I2C=m
CONFIG_SND_SOC_PCM186X=m
CONFIG_SND_SOC_PCM186X_SPI=m
CONFIG_SND_SOC_PCM3060_I2C=m
CONFIG_SND_SOC_PCM3060=m
CONFIG_SND_SOC_PCM3060_SPI=m
CONFIG_SND_SOC_PCM3168A_I2C=m
CONFIG_SND_SOC_PCM3168A=m
CONFIG_SND_SOC_PCM3168A_SPI=m
CONFIG_SND_SOC_PCM512x_I2C=m
CONFIG_SND_SOC_PCM512x=m
CONFIG_SND_SOC_PCM512x_SPI=m
CONFIG_SND_SOC_SIGMADSP=m
CONFIG_SND_SOC_SIGMADSP_REGMAP=m
CONFIG_SND_SOC_SSM2602_I2C=m
CONFIG_SND_SOC_SSM2602=m
CONFIG_SND_SOC_SSM2602_SPI=m
CONFIG_SND_SOC_TLV320AIC23_I2C=m
CONFIG_SND_SOC_TLV320AIC23=m
CONFIG_SND_SOC_TLV320AIC23_SPI=m
CONFIG_SND_SOC_TLV320AIC32X4_I2C=m
CONFIG_SND_SOC_TLV320AIC32X4=m
CONFIG_SND_SOC_TLV320AIC32X4_SPI=m
CONFIG_SND_SOC_WM8804_I2C=m
CONFIG_SND_SOC_WM8804=m
CONFIG_SND_SOC_WM8804_SPI=m

3PEAK TPF632C is just amplifier with enable/disable pin (with I assume controlled by avout_mute-gpios). No driver is needed for it.

But this doesn’t get us any closer to the sound :slight_smile:

1 Like

Thanks @vpeter

As said : the avout_mute-gpios lines in auge_sound section are same for decompiled Android and CoreELEC dtbs.
Namely:

avout_mute-gpios = <0x1b 0x1f 0x00>;

with 0x1f corresponding to GPIOD_2. So that seems correct.

Then maybe something else deviates or is missing or maybe there is a bug somewhere.

Not sure if the deviation in IRQ 31 matters.