Jump to content

Recommended Posts

@ag123, @c0rnelius, and anyone else that has interest in sound on these devices.

 

I have been able to put together a patch that enables audio for H161/H618 devices.  So far only audio on HDMI works. Analog audio is still generating an error on startup.

 

The patches were taken from a git repository by warpme:

https://github.com/warpme/minimyth2/tree/master/script/kernel/linux-6.6/files

, and probably came from the Zunlong SDK. A lot of the code was written by Allwinner.

 

@pixdrift generated a version of the patches for Armbian and I continued to work on them.

 

I have built a few images  and have a git repository if anyone would like to test, particularly on boards other than orangpizero3, on which I have tested.

 

zero3 desktop:
https://drive.google.com/file/d/1jIMTIqKc6y_uuG7lRyXXhIWQ_fvo0XgI/view?usp=drive_link

 

zero3 server:
https://drive.google.com/file/d/1r-yn-ooeYoz1yROEJ-yx01_KhErKN_p8/view?usp=drive_link

 

zero2 server:
https://drive.google.com/file/d/1XQ9zzw_Bz-rZancDWuzGwMjHHn_4U8SE/view?usp=drive_link

 

repository:

https://github.com/stephengraf/armbian_build_sg.git

 

There is another repository mentioned in the Armbian Forum:

https://github.com/NickAlilovic/build

 

If anyone has interest and skills to debug the analog audio, the dmesg errors are:

[    7.125509]  ahub_dam-snd-soc-dummy-dai: substream ahub_dam-snd-soc-dummy-dai has no playback, no capture
[    7.125539] sunxi-snd-mach soc:ahub_dam_mach: ASoC: can't create pcm ahub_dam-snd-soc-dummy-dai :-22
[    7.125780] sunxi-snd-mach: probe of soc:ahub_dam_mach failed with error -22

 

Link to comment
Share on other sites

thanks, I'd probably try that some time. if audio for HDMI works, I think many users will be happy, I've read some comments some are looking for that.

currently, I'm using headless as wifi ap, so I did not know if it works.

analog may need to go back into h616 zero 2 to see how it is done there, maybe dts etc.

Link to comment
Share on other sites

 

7 hours ago, robertoj said:

OrangePi has this analog audio figured out:

Yes I have tried the Zunlong images for orangepizero3 and they work.  Unfortunately those images are for a Linux 6.1 kernel and the zero3 and 2w were only officially implemented into linux with 6.6. The challenge is to get the Zunlong code into Armbian with the newer kernels.

Link to comment
Share on other sites

Hi @Stephen Graf, thank you so much for these images. you are correct. Having audio even on HDMI is extremely useful.

Do you perhaps have the kernel headers for this image?

https://drive.google.com/file/d/1jIMTIqKc6y_uuG7lRyXXhIWQ_fvo0XgI/view?usp=drive_link

Also, Could you create an image for armbian jammy, or provide steps so that i can do it.

Armbian_community_24.5.0-trunk.93_Orangepizero3_jammy_current_6.6.18_gnome_desktop.img

Link to comment
Share on other sites

6 hours ago, SUPA said:

provide steps so that i can do it

@SUPA Thank you for testing the patch.  I assume it worked and that you are working with an orangepisero3.

 

If you want to build you own images follow the directions in the Armbian build manual: https://docs.armbian.com/Developer-Guide_Build-Preparation/

and clone my repository. Unfortunately I have limited space on my google drive.

 

git clone https://github.com/stephengraf/armbian_build_sg.git

Link to comment
Share on other sites

@Stephen Graf i see that if i use the original kernel source i want to build patched linux-image and linux-header for armbian jammy 6.6.26.
It seems to include support for analog audio. I compile and install these using .

 

**************** i have already tested all my components on jammy 6.6.26 thats why I would prefer using it =========================
 

Here are my cheat sheets:

 

wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.26.tar.xz

tar -xvf linux-6.6.26.tar.xz
cd ~/src/kernel-source/linux-6.6.26
copy all patches into ~/src/kernel-source/linux-6.6.26

cp /boot/config-$(uname -r) .config

patch -p1 < 0606-dma-sun6i-dma-add-h616-support.patch
patch -p1 < 0608-sound-soc-sunxi-add-codec-driver-for-h616.patch
patch -p1 < 0609-sound-soc-add-sunxi_v2-for-h616-ahub.patch
patch -p1 < 0630-arm64-dts-allwinner-h616.dtsi-add-ths-audio-hdmi.patch
patch -p1 < 0631-arm64-dts-allwinner-h616-OrangePI-Zero23-enable-ths-hdmi-audio.patch
patch -p1 < 0639-arm64-dts-allwinner-h616.dtsi-add-spdif.patch


yes "y" | make oldconfig
sudo make prepare
sudo make clean

cd ~/src/kernel-source/linux-6.6.26

sudo make -j$(nproc) bindeb-pkg LOCALVERSION=-custom
 

cd ~/src/kernel-source/
sudo dpkg -i linux-image-6.6.26-custom_6.6.26-gbbc005ee4185-6_arm64.deb
sudo dpkg -i linux-headers-6.6.26-custom_6.6.26-gbbc005ee4185-6_arm64.deb
sudo dpkg -i linux-libc-dev_6.6.26-gbbc005ee4185-6_arm64.deb


ls -l /boot/Image
ls -l /boot/uInitrd


ln -sf /boot/vmlinuz-6.6.26-custom /boot/Image
ln -sf /boot/initrd.img-6.6.26-custom /boot/uInitrd

cd ~/src/kernel-source/linux-6.6.26

make dtbs


sudo mkdir /boot/dtb-6.6.26-custom/allwinner
sudo cp /root/src/kernel-source/linux-6.6.26/arch/arm64/boot/dts/allwinner/*.dtb /boot/dtb-6.6.26-custom/allwinner/

sudo ln -sfn /boot/dtb-6.6.26-custom /boot/dtb

sudo reboot now



however my board doesnt boot. 

Do you have any suggestions? maybe u-boot?

I have created the needed symlink which I though would be enough for u-boot.

Maybe my approach is completely wrong

Link to comment
Share on other sites

5 hours ago, SUPA said:

i have already tested all my components on jammy 6.6.26 thats why I would prefer using it

@SUPAThere is a lot more to building a system than just the kernel.  That is what Armbian tries to do for you. I recommend that you use the Armbian build system. You should be able to build the system that you want.

The audio patches do include analog audio, but to date there is still a problem and it does not start up.

 

The armbian-config procedure has options to load kernel headers and also source.

 

Link to comment
Share on other sites

Posted (edited)
21.04.2024 в 02:07, Stephen Graf сказал:

If anyone has interest and skills to debug the analog audio, the dmesg errors are:

[    7.125509]  ahub_dam-snd-soc-dummy-dai: substream ahub_dam-snd-soc-dummy-dai has no playback, no capture
[    7.125539] sunxi-snd-mach soc:ahub_dam_mach: ASoC: can't create pcm ahub_dam-snd-soc-dummy-dai :-22
[    7.125780] sunxi-snd-mach: probe of soc:ahub_dam_mach failed with error -22

 

Hi, I think these messages are not related to analog audio, at least on my custom board with t507 processor, analog audio works with this error.
You can simply disable them as it was in the linux kernel 6.1

 

Цитата

--- 6.7__sunxi64__arm64-6.7.9/sound/soc/soc-pcm.c    2024-02-21 00:16:07.645017846 +0300
+++ linux-6.7.9-sk/sound/soc/soc-pcm.c    2024-03-16 13:34:42.000000000 +0300
@@ -2867,14 +2867,14 @@ static int soc_get_playback_capture(stru
 
     if (dai_link->capture_only)
         has_playback = 0;
-
+#if 0
     if (!has_playback && !has_capture) {
         dev_err(rtd->dev, "substream %s has no playback, no capture\n",
             dai_link->stream_name);
 
         return -EINVAL;
     }
-
+#endif


The sound works for me if I turn it on in the mixer

 

Цитата

    /usr/bin/amixer -c 0 set 'Left Output Mixer DACL' 100% unmute
    /usr/bin/amixer -c 0 set 'Left Output Mixer DACR' 100% unmute
    /usr/bin/amixer -c 0 set 'Right Output Mixer DACL' 100% unmute
    /usr/bin/amixer -c 0 set 'Right Output Mixer DACR' 100% unmute

 

It’s strange, but I have another problem - the sound does not work through HDMI and there is also a problem with reading EDID through the DDC interface. I would be grateful if you could tell me whether automatic detection of monitor or TV resolution via HDMI works for you.

Edited by sasa
Link to comment
Share on other sites

5 hours ago, sasa said:

whether automatic detection of monitor or TV resolution via HDMI works for you

@sasa Many thanks for pointing out that analog sound just has to be enabled!  I just tested and it works. I was dreading trying to debug kernel code when I should have been looking at the fundamental "is it turned on?"

I will try the patch to remove the other sound error.

 

As to automatic detection, yes on my orangepizero3 with H618 Allwinner SOC, HDMI detects the monitor and sets the proper resolution.

Link to comment
Share on other sites

Posted (edited)
6 часов назад, Stephen Graf сказал:

yes on my orangepizero3 with H618 Allwinner SOC, HDMI detects the monitor and sets the proper resolution

 

Thanks for confirming.

 

Цитата

I will try the patch to remove the other sound error.


In fact, my patch does not solve the problem and can only be considered as a temporary solution.
I think we need a new driver for the audio multiplexer, for example, as is implemented for NXP processors.
https://elixir.bootlin.com/linux/v6.6.30/source/sound/soc/fsl/imx-audmux.c
For these processors, the audio multiplexer configuration is described via DT
https://elixir.bootlin.com/linux/v6.6.30/source/arch/arm/boot/dts/nxp/imx/imx6qdl-kontron-samx6i.dtsi#L176

Edited by sasa
Link to comment
Share on other sites

@Stephen Graf I successfully compiled using armbian build. But not sure if i successfully integrated the patches. and also don't know if I used all the correct patches. Could you review and advise please:

Here are my steps:

 

sudo apt-get -y -qq install git  

mkdir ~/src

cd ~/src

======================= git hdmi audio patches =======================

git clone https://github.com/warpme/minimyth2.git

 

git clone --depth=1 --branch=main https://github.com/armbian/build

 

mkdir -p ~/src/build/userpatches/kernel/sunxi-current

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0600-drivers-h616-wip-add-usb-emac2-support.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0601-drivers-thermal-allwinner-add-h616-ths-support.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0602-media-cedrus-add-H616-variant.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0603-soc-sunxi-sram-Add-SRAM-C1-H616-handling.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0606-dma-sun6i-dma-add-h616-support.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0607-drivers-drm-wip-add-h616-hdmi-jernejsk-24102023.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0608-sound-soc-sunxi-add-codec-driver-for-h616.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0609-sound-soc-add-sunxi_v2-for-h616-ahub.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0615-drivers-iommu-sun50i-iommu-fix-iommu-on-h616.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0630-arm64-dts-allwinner-h616.dtsi-add-ths-audio-hdmi.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0631-arm64-dts-allwinner-h616-OrangePI-Zero23-enable-ths-hdmi-audio.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0639-arm64-dts-allwinner-h616.dtsi-add-spdif.patch ~/src/build/userpatches/kernel/sunxi-current/

 

cp ~/src/minimyth2/script/kernel/linux-6.6/files/0640-arm64-dts-allwinner-h618-enable-spdif-opi23-tanix-tx6s.patch ~/src/build/userpatches/kernel/sunxi-current/

 

ls ~/src/build/userpatches/kernel/sunxi-current

 

=========================  armbian build ===========================

cd ~/src/build  

./compile.sh

 

 

Link to comment
Share on other sites

Okay I noted the file path should be ~/src/build/userpatches/kernel/archive/sunxi-6.6.

Then it includes them... Nut now I see the patches are not setup correctly for the correct changes. They work when i build from source. But how do I add them patches from https://github.com/warpme/minimyth2/tree/master/script/kernel/linux-6.6/files so they work in Armbian build tool?


Sorry if my questions are noob.

 

 

 

Link to comment
Share on other sites

9 hours ago, SUPA said:

But not sure if i successfully integrated the patches.

@SUPA The warpme patches need work to implement into Armbian.  That is what I have been trying to do.  When and if we get it right, they should be included into the Armbian system.

 

In the meantime clone my repository, which has the patches implemented, and build your flavour of system from there.

cd ~/

git clone https://github.com/stephengraf/armbian_build_sg.git

cd armbian_build_sg

./compile.sh

 

The HDMI sound should work immediately.

The analog needs to be enabled as @sasa suggested:

 

    /usr/bin/amixer -c 0 set 'Left Output Mixer DACL' 100% unmute
    /usr/bin/amixer -c 0 set 'Left Output Mixer DACR' 100% unmute
    /usr/bin/amixer -c 0 set 'Right Output Mixer DACL' 100% unmute
    /usr/bin/amixer -c 0 set 'Right Output Mixer DACR' 100% unmute

Link to comment
Share on other sites

15 hours ago, sasa said:

In fact, my patch does not solve the problem and can only be considered as a temporary solution.

@sasa  I tested with your patch and it gets rid of the error but also creates a new sound device. ahubdam, that has no input or output.

 

I then just took the device creation out of the dtb and then there is no error even without the patch.  Analog and HDMI audio still work.

 

This is the piece removed from the dtb.

 

              ahub_dam_mach {
                        compatible = "allwinner,sunxi-snd-mach";
                        soundcard-mach,name = "ahubdam";
                        status = "okay";
                        phandle = <0x3f>;

                        soundcard-mach,cpu {
                                sound-dai = <0x0e>;
                        };

                        soundcard-mach,codec {
                        };
                };

Link to comment
Share on other sites

11 hours ago, Stephen Graf said:

@SUPA The warpme patches need work to implement into Armbian.  That is what I have been trying to do.  When and if we get it right, they should be included into the Armbian system.

 

In the meantime clone my repository, which has the patches implemented, and build your flavour of system from there.

cd ~/

git clone https://github.com/stephengraf/armbian_build_sg.git

cd armbian_build_sg

./compile.sh

 

The HDMI sound should work immediately.

The analog needs to be enabled as @sasa suggested:

 

    /usr/bin/amixer -c 0 set 'Left Output Mixer DACL' 100% unmute
    /usr/bin/amixer -c 0 set 'Left Output Mixer DACR' 100% unmute
    /usr/bin/amixer -c 0 set 'Right Output Mixer DACL' 100% unmute
    /usr/bin/amixer -c 0 set 'Right Output Mixer DACR' 100% unmute

Thank you soooo much Stephan. I realized my error. 

I had to add the patches with the expected root path. Which was linux6.6. 

So I had to add my patches here:

~/src/build/userpatches/kernel/sunxi-6.6/linux-6.6/

@sasa Thank you for showing us how to enable audio through the mixer.

 

Link to comment
Share on other sites

Hello, everyone

I used your patch @Stephen Graf

https://github.com/stephengraf/armbian_build_sg/blob/main/patch/kernel/archive/sunxi-6.6/patches.armbian/sound-soc-h616.patch

I found a bug when using it. If I turned on Volume Control in the middle of playing video or audio, the video or audio would suddenly speed up playing, even if I just turned on Volume Control without doing anything,very crazy😂

Link to comment
Share on other sites

29 minutes ago, sakesm said:

I found a bug

@sakesm Yes i came across that also.  Can you confirm that it only happens on analog audio and not on HDMI and when using pulseaudio.

I also tested with mpg123 and did not have problems using the mpg123 built in volume controls.

Link to comment
Share on other sites

2 hours ago, Stephen Graf said:

Can you confirm that it only happens on analog audio and not on HDMI and when using pulseaudio.

Sorry, I don't have a device that supports hdmi audio

 

2 hours ago, Stephen Graf said:

I also tested with mpg123 and did not have problems using the mpg123 built in volume controls.

I tried to use mpg123 to play audio, but as long as the Volume Control is turned on, the bug also appeared

 

I'm still new to audio and video, so I don't know how to solve it

Link to comment
Share on other sites

In pavucontrol, which is the Configuration in Volume Control, set the second Audio to off and exit. After playing the audio and opening the Volume Control at the same time, this problem will not occur and can be adjusted normally

 

My understanding is that two Audio may have output conflict?

Link to comment
Share on other sites

09.05.2024 в 01:40, sasa сказал:

the sound does not work through HDMI and there is also a problem with reading EDID through the DDC interface

Perhaps it will be interesting to someone - audio on hdmi and edid reading work on the t507 too, there was a problem in our DDC connection scheme.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines