manjaro-pinephone / phosh

Manjaro Phosh
164 stars 20 forks source link

HDMI audio not working (PP) #76

Open 1sra3l opened 1 year ago

1sra3l commented 1 year ago

When I connect the Pinephone to the convergence dock that came with it, and connect it to a television via HDMI cable the video automatically changes, but the audio does not. I installed pavucontrol and cannot find HDMI as an output. I have looked online for solutions, but it seems that it is fixed for most people on most distros. I have been updating via pacman but have not gotten an update that makes the audio functional.

ghost commented 1 year ago

I think it only passes the video signal, first the A64 HDMI output is converted to USB by the ANX chip and then the dock does the opposite. You could check the board schematics to see if the A64 audio output goes through the ANX but I don't think so.

1sra3l commented 1 year ago

@mouffa That is strange, from what I read PostmarketOS was able to get audio working. What is so different about manjaro that I would need to read the schematics to redo their entire thread of effort? Or are you saying it is not possible in manjaro, or witth the official dock?

ghost commented 1 year ago

I currently don't know how the sound is routed to the HDMI but it seems it happens inside the SoC,

here it says that at least up to that time HDMI audio was not supported by the mainline kernel but he patched it for kernel 5.9 and you need a specific type of audio to work

https://xnux.eu/devices/pine64-pinephone.html

maybe Postmarketos kernel has a specific patch that makes it work

1sra3l commented 1 year ago

After looking through those pages, I wonder, could it be the firmware for the anx7688? Do you think flashing that version would make it work correctly? I think all the changes from 5.9 should be included by now, though perhaps that is wishful thinking. Thanks for your help on this!

ghost commented 1 year ago

if you get a video signal then the firmware is working, only the initial firmware is for testing

I checked the PostmarketOS website and indeed the kernel uses Megi's patches which may take much time to pass into the mainline kernel that Manjaro uses or they may even never pass at all. This can be checked in Manjaro's gitlab source code repository to see where it draws the source code from and the patches it applies.

I am still studying the A64 user manual to understand how the audio goes to the HDMI which appears as a device inside the SoC

if the problem is related to the kernel patches and other tuning tricks then it may takes a lot of effort to work on Manjaro but it may also be some simple setting

maybe the best way is to run Postmarket on a SD card to see if the audio works and then try to find what they have done and what are the differences in the case of Manjaro, the kernel is a difference for sure

ghost commented 1 year ago

the system works in the following way

inside A64 there is a HDMI controller, the Synopsys DesignWare, so the audio stream should be routed there

the controller is attached on the i2c bus and it's the device i2c-4

the data streams of the HDMI follow the i2s communication protocol

the controller's audio channel can be found in /sys/class/drm/card1-HDMI-A-1/ddc/device/dw-hdmi-i2s-audio.3.auto

after that the HDMI signal exits the SoC and goes to the ANX7688 and then to the USB

ghost commented 1 year ago

the command dmesg | grep hdmi will output all the kernel messages regarding the HDMI, the controller is registered as /dev/i2c-4 and maybe the sound should be sent there with the appropriate format 48kHz/16-bit, it could just be a simple script used by Postmarket that does the work

1sra3l commented 1 year ago

Wow, thanks for all the information! I downloaded PostmarketOS, but my computer is broken so the SD card slot isn't working today. I will try rebooting to see if I can write the image to the SD card and test stuff out. Thank you again!

ghost commented 1 year ago

you can flash it in the phone, download it, insert the SD and run the command

xzcat [image].raw.xz | sudo dd bs=4M of=/dev/mmcblk0 iflag=fullblock oflag=direct status=progress; sync

the inxi -A shows 3 devices, the sound card, hdmi and hdmi-audio, you probably have to send the audio to the hdmi-audio

alsactl info does not show any hdmi devices but I don't know whether it should

here you can see how the audio is routed, it seems complicated until you master it

https://xnux.eu/devices/feature/audio-pp.html#toc-audio-on-pinephone

the HDMI controller audio is attached on AIF1 as far as I remember

all the information related to the AllWinner SoCs is here

https://linux-sunxi.org/

for example

https://linux-sunxi.org/DWC_HDMI_Controller

1sra3l commented 1 year ago

Rebooting allowed me to use the slot again, so I am currently writing the PostmarketOS image to my SD card. I will test things later today and report back what I find. Thanks again for all the information, I have some reading to do :smile: