FreeBSDDesktop / kms-drm

the DRM part of the linuxkpi-based KMS
63 stars 26 forks source link

No sound via HDMI with radeonkms from ports #19

Open MATPOCKuH opened 6 years ago

MATPOCKuH commented 6 years ago

I have no sound via HDMI on AMD Radeon HD 6200 Sound device is presented and activated:

# more /dev/sndstat 
Installed devices:
pcm0: <ATI R6xx (HDMI)> (play) default
pcm1: <Realtek ALC269 (Analog 2.0+HP/2.0)> (play/rec)
# sysctl hw.snd.default_unit=0
hw.snd.default_unit: 1 -> 0

To make sound works on freebsd 10 I patched radeon_drv.c:

--- sys/dev/drm2/radeon/radeon_drv.c    (revision 317489)
+++ sys/dev/drm2/radeon/radeon_drv.c    (working copy)
@@ -120,7 +120,7 @@
 int radeon_testing = 0;
 int radeon_connector_table = 0;
 int radeon_tv = 1;
-int radeon_audio = 0;
+int radeon_audio = 1;
 int radeon_disp_priority = 0;
 int radeon_hw_i2c = 0;
 int radeon_pcie_gen2 = -1;

I tried to make same think on radeon/radeon_drv.c from port graphics/drm-next-kmod without any result. Also I tried to add something to /boot/loader.conf:

compat.linuxkpi.audio="1"
radeon.audio="1"
radeonkms.audio="1"
hint.radeon.audio="1"
hint.radeonkms.audio="1"

But still does not have working sound via HDMI. What is correct way to force enable sound via HDMI with drm-next? How I can check sound status on HDMI port ? (for example, via sysctl?)

iotamudelta commented 6 years ago

I will be honest, I am not sure we have ever tried sound via HDMI in the new DRM. Odds are, there may be something missing from the linuxkpi, so it could be interesting to check dmesg and see if there is debug output.

MATPOCKuH commented 6 years ago

I'm not found any messages related to sound via hdmi. Can You provide how to collect debug output?

johalun commented 6 years ago

I just tested with drm-next 4.9 and not getting any sound through DP -> HDMI output on Skylake with iGPU. I am getting a lot of errors regarding the sound chip though (generally, not only when trying to use it)

hdacc1: Unexpected unsolicited response with tag 63: ffffffff

I don't think this is something that has ever been prioritized on drm-next but would be nice if we can get it to work.

hselasky commented 6 years ago

Yes, but you might need to boot with HDMI plugged in.

johalun commented 6 years ago

Still same for me.

hselasky commented 6 years ago

The value "ffffffff" might indicate some GPIO is not properly configured.

MATPOCKuH commented 6 years ago

I updated FreeBSD to r328273 and port to drm-next-kmod-g20180117, but problem still exists.

PS. Just FYI: on my i915 box (Celeron N3160) sound via HDMI works properly.

papertigers commented 6 years ago

I also have no audio over Displayport using pcm3: <Intel Skylake (HDMI/DP 8ch)> at nid 3 on hdaa1 on my hardware.

I will try and do some digging and see if something is missing in linuxkpi, or if things need to be wired up. I would love to have audio of DP. If anyone knows the best place to start, I can start looking there, thanks!

johalun commented 6 years ago

Same here. I usually use DP but have no sound in either HDMI or DP outputs. @papertigers Do you get any error output to dmesg like I do? (see above) If so that might be a place to start.

MATPOCKuH commented 6 years ago

@papertigers, @iotamudelta and @johalun , please check sysctl dev.hdac.0.polling I'm got working sound (via 3.5mm jack too) only after I set dev.hdac.0.polling to 1.

johalun commented 6 years ago

No luck with that :( Maybe it's some pin configuration. Realtek sound works great (built in speaker and jack, with auto switching).

papertigers commented 6 years ago

@johalun yeah when I boot with verbose I see those log lines as well.

@MATPOCKuH I tried changing polling to 1 and I still have no sound.

avg-I commented 6 years ago

I also experience the same problem with radeonkms. I suspect that, at least in my case, the problem could be caused by incorrect retrieval of EDID:

[  9616.484] (II) RADEON(0):    00ffffffffffff004c2d090501000000                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    30120103801009780aee91a3544c9926                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    0f5054bdef80714f8100814081809500                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    950fb3000101023a801871382d40582c                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    4500a05a0000001e662150b051001b30                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    40703600a05a0000001e000000fd0018                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    4b1a5117000a202020202020000000fc                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    0053414d53554e470a2020202020016f                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    00ffffffffffff004c2d090501000000                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    30120103801009780aee91a3544c9926                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    0f5054bdef80714f8100814081809500                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    950fb3000101023a801871382d40582c                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    4500a05a0000001e662150b051001b30                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    40703600a05a0000001e000000fd0018                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    4b1a5117000a202020202020000000fc                                                                                                                                                                       
[  9616.484] (II) RADEON(0):    0053414d53554e470a2020202020016f

Please note how the reported EDID consists of two parts with the same data. If I understand correctly, the standard EDID has 128 bytes and the byte next to the last specifies the number of extensions. In this case it is one. But instead of the extension the following block has the same bytes as the first block. I guess that the extension block, if read correctly, would describe HDMI audio capabilities.

papertigers commented 6 years ago

Just to add some data on the intel side. I swapped my intel NUC to Linux and still had no sound. However, a bios update that went from a 2016->2018 build fixed things. I have not gone back and tested on FreeBSD again.

avg-I commented 6 years ago

Same information with the in-tree driver:

[    82.356] (II) RADEON(0):    00ffffffffffff004c2d090501000000                                                                                                                                                                       
[    82.356] (II) RADEON(0):    30120103801009780aee91a3544c9926                                                                                                                                                                       
[    82.356] (II) RADEON(0):    0f5054bdef80714f8100814081809500                                                                                                                                                                       
[    82.356] (II) RADEON(0):    950fb3000101023a801871382d40582c                                                                                                                                                                       
[    82.356] (II) RADEON(0):    4500a05a0000001e662150b051001b30                                                                                                                                                                       
[    82.356] (II) RADEON(0):    40703600a05a0000001e000000fd0018                                                                                                                                                                       
[    82.356] (II) RADEON(0):    4b1a5117000a202020202020000000fc                                                                                                                                                                       
[    82.356] (II) RADEON(0):    0053414d53554e470a2020202020016f                                                                                                                                                                       
[    82.356] (II) RADEON(0):    020327f14b901f041305140312202122                                                                                                                                                                       
[    82.356] (II) RADEON(0):    2309070783010000e2000fe305030167                                                                                                                                                                       
[    82.356] (II) RADEON(0):    030c001000b82d011d007251d01e206e                                                                                                                                                                       
[    82.357] (II) RADEON(0):    285500a05a0000001e011d00bc52d01e                                                                                                                                                                       
[    82.357] (II) RADEON(0):    20b8285540a05a0000001e011d801871                                                                                                                                                                       
[    82.357] (II) RADEON(0):    1c1620582c2500a05a0000009e011d80                                                                                                                                                                       
[    82.357] (II) RADEON(0):    d0721c1620102c2580a05a0000009e00                                                                                                                                                                       
[    82.357] (II) RADEON(0):    0000000000000000000000000000001d
avg-I commented 6 years ago

And just to clarify what I said earlier. HDMI audio does work with the in-tree driver and drm.radeon.audio=1 in loader.conf. So, I do believe that this is a problem with EDID.

Another evidence is that with drm-next I see the following message when KMS debug trace is enabled:

[drm:drm_edid_to_eld] ELD: no CEA Extension found

With the in-tree driver I see more pleasant messages:

hdaa0: Pin sense: nid=3 sense=0xffffffff (connected, ELD valid)
hdaa0: Pin sense: nid=3 sense=0xffffffff (connected, ELD valid)

Is this a problem with the i2c code in linuxkpi? Any thoughts?

avg-I commented 6 years ago

Another bit. I noticed that the in-tree driver uses the bit-banging I²C driver while with this driver I see atom_hw_i2c being used. This seems to be because radeon_hw_i2c is set to one unlike the in-tree driver. So, I set compat.linuxkpi.hw_i2c to zero (by the way, @MATPOCKuH, this is where the tunables now live) and after that I see that:

So, I see two possibilities. Either the code that supports atom_i2c algorithm has a bug. Or my hardware (its video firmware, etc) does not properly support Atom I²C interface.

valpackett commented 6 years ago

Seems like hw_i2c was necessary for some cards, it was enabled in https://github.com/FreeBSDDesktop/freebsd-base-graphics/pull/172

avg-I commented 6 years ago

@myfreeweb thank you for the pointer! I think that maybe that change was wrong, I left a comment there. Meanwhile, I forgot to mention that in addition to disabling radeon_hw_i2c I also had to make a change in the bit-bang I²C algorithm. I have created a PR for that change now: #51.

juikim commented 6 years ago

@avg-I I was able to get correct EDID information for Aruba after applying #51 and reverting FreeBSDDesktop/freebsd-base-graphics#172. Thanks!

I'll test it on Pitcairn when I get home.

juikim commented 6 years ago

@avg-I Both amdgpu and radeon work fine on Pitcairn with #51 and without FreeBSDDesktop/freebsd-base-graphics#172.

daviddpd commented 5 years ago

Know this is an older thread, and nearly ancient AMD A4-6300 APU with Radeon HD Graphics - Richland Radeon HD 8370D - and finally, with these drivers ... and 12-alpha7, (and a little bit older) - I can play Full HD H.264 video, hardware accelerated, via VLC.

However - no HDMI audio device. I know the

[ pts/0 dpdtech amd:~ ]
[ dpd ] > cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC887 (Rear Analog)> (play/rec) default
pcm1: <Realtek ALC887 (Front Analog)> (play/rec)
No devices installed from userspace.

I've attached my dmesg and Xorg log, but it looks like this is the error:

hdac1: <ATI (0x9902) HDA Controller> mem 0xfeb44000-0xfeb47fff irq 18 at device 1.1 on pci0
hdac1: hdac_get_capabilities: Invalid corb size (0)
device_attach: hdac1 attach returned 6

compat.linuxkpi.audio and i2c tunable are set to 1.

[ pts/0 dpdtech amd:~ ]
[ dpd ] > pkg info | grep drm
drm-devel-kmod-4.16.g20180824  DRM modules for the linuxkpi-based KMS components (development version)
libdrm-2.4.93,1                Userspace interface to kernel Direct Rendering Module services

Let me know, I have this setup entirely for play/testing Desktop stuff.

Xorg.0.log

dmesg.boot.txt

amotin commented 5 years ago

@daviddpd , I have a patch for snd_hda from Dmitry Luhtionov dmitryluhtionov@gmail.com, which I never decided to commit, but that may help here: hdac.c.txt

daviddpd commented 5 years ago

@daviddpd , I have a patch for snd_hda from Dmitry Luhtionov dmitryluhtionov@gmail.com, which I never decided to commit, but that may help here: hdac.c.txt

Thanks Alexander - I applied this last night, and can confirm it does now detect the HDMI output as pcm0, however I was unable to make any desktop - mate or kde5 - and vlc or Kodi to be able to output any audio at all - even in non-passthur. I am using the 4.16-devel DRM kmods ... will attempt to DRM -next and -stable tonight and see if there are different results.

Juanitou commented 5 years ago

@daviddpd , I have a patch for snd_hda from Dmitry Luhtionov dmitryluhtionov@gmail.com, which I never decided to commit, but that may help here: hdac.c.txt

For what is worth, I’ve tested this hdac patch in a HD Graphics 4400 (Haswell) and at least it did not broke anything: HDMI sound is still not working with the latest DRM (drm-current-kmod-4.16.g20181210). Video is as good and stable as before. Thanks!

daviddpd commented 5 years ago

@daviddpd , I have a patch for snd_hda from Dmitry Luhtionov dmitryluhtionov@gmail.com, which I never decided to commit, but that may help here: hdac.c.txt

For what is worth, I’ve tested this hdac patch in a HD Graphics 4400 (Haswell) and at least it did not broke anything: HDMI sound is still not working with the latest DRM (drm-current-kmod-4.16.g20181210). Video is as good and stable as before. Thanks!

Same, however I hadn't said anything, because I was still running down a suspected BIOS issue with my ASUS H110T/CSM - to be clear - still no working HDMI sound.