Bug 237340

Summary: Unable to make HDMI sound works with HD630
Product: Base System Reporter: Emrion <kmachine>
Component: miscAssignee: freebsd-multimedia (Nobody) <multimedia>
Status: Open ---    
Severity: Affects Some People CC: Alexander88207, Steven.E.Friedrich, alfredovogel, brtastic.dev, cukierski.lukasz, damjan.jov, danfe, evfbsd, freebsd, grahamperrin, hselasky, ian.cheong, kmachine, pr, swills, xliiv
Priority: ---    
Version: 12.0-RELEASE   
Hardware: amd64   
OS: Any   
URL: https://forums.freebsd.org/threads/no-sound-via-hdmi.70391/

Description Emrion 2019-04-17 17:14:19 UTC
I can't make the sound pass thru HDMI port. The involved hardware is: motherboard Asus H170I-PRO with embedded sound card Realtek ALC887 + processor i3 7100T (Kabylake). The graphic card used is the HD630 from the i3.

Two hdaa devices are detected (ALC887: hdaa0 and Intel Kabylake audio: hdaa1). At the base, there isn't any listed HDMI device:

------------------
$ cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC887 (Rear Analog)> (play/rec) default
pcm1: <Realtek ALC887 (Front Analog)> (play/rec)
pcm2: <Realtek ALC887 (Internal Digital)> (play)
pcm3: <Realtek ALC887 (Rear Digital)> (play)
------------------

I tried to select each of the pcm devices (hw.snd.default_unit=...) but I got no sound from HDMI.

It's possible to make an HDMI device appear by adding hint.hdaa.1.nid3.config="conn=jack" (or "conn=Fixed") in /boot/device.hints:

------------------
$ cat /dev/sndstat
FreeBSD Audio Driver (64bit 2009061500/amd64)
Installed devices:
pcm0: <Realtek ALC887 (Rear Analog)> on hdaa0 (1p:1v/1r:1v)
pcm1: <Realtek ALC887 (Front Analog)> on hdaa0 (1p:1v/1r:1v)
pcm2: <Realtek ALC887 (Internal Digital)> on hdaa0 (1p:1v/0r:0v)
pcm3: <Realtek ALC887 (Rear Digital)> on hdaa0 (1p:1v/0r:0v)
pcm4: <Intel Kabylake (HDMI/DP 8ch)> on hdaa1 (1p:1v/0r:0v) default
------------------

But selecting this device does not bring sound to HDMI.

I ain't sure this is a bug but I don't see what I can do more to make it works. I tried many things and now I wonder if it's not a driver bug.

In the BIOS setting, there is a "SDIF out type" parameter which can be set either at "SPDIF" or "HDMI". In both cases, there is no change.

For information:

------------------
$ sysctl dev.hdaa.1
dev.hdaa.1.reconfig: 0
dev.hdaa.1.gpo_config: 
dev.hdaa.1.gpo_state: 
dev.hdaa.1.gpio_config: 
dev.hdaa.1.gpio_state: 
dev.hdaa.1.gpi_state: 
dev.hdaa.1.config: forcestereo,ivref50,ivref80,ivref100,ivref,vref
dev.hdaa.1.nid3_original: 0x58560010 as=1 seq=0 device=Digital-out conn=None ctype=Digital loc=0x18 color=Unknown misc=0
dev.hdaa.1.nid3_config: 0x98560010 as=1 seq=0 device=Digital-out conn=Fixed ctype=Digital loc=0x18 color=Unknown misc=0
dev.hdaa.1.nid3: pin: Digital-out (Fixed)
     Widget cap: 0x0040778d PWR DIGITAL UNSOL 8CH
    Association: 0 (0x0001)
        Pin cap: 0x09000094 PDC OUT HDMI DP HBR
     Pin config: 0x98560010 as=1 seq=0 device=Digital-out conn=Fixed ctype=Digital loc=0x18 color=Unknown misc=0
    Pin control: 0x00000040 OUT
     Output amp: 0x80000000 mute=1 step=0 size=0 offset=0 (0/0dB)
    Connections: 1
          + <- nid=2 [audio output]

dev.hdaa.1.nid2: audio output
     Widget cap: 0x00006611 PWR DIGITAL 8CH
    Association: 0 (0x0001)
            OSS: pcm (pcm)
     Stream cap: 0x00000005 AC3 PCM
        PCM cap: 0x001a07f0 16 24 32 bits, 32 44 48 88 96 176 192 KHz

dev.hdaa.1.%parent: hdacc1
dev.hdaa.1.%pnpinfo: type=0x01 subsystem=0x80860101
dev.hdaa.1.%location: nid=1
dev.hdaa.1.%driver: hdaa
dev.hdaa.1.%desc: Intel Kabylake Audio Function Group
------------------

Note: the conn of nid3 has been changed in device.hints. Normally, it's conn=None.
Comment 1 Emrion 2019-04-27 09:49:49 UTC
Noone is interested with this issue? Noone is experiencing the same?
Comment 2 Hans Petter Selasky freebsd_committer freebsd_triage 2019-04-27 10:21:11 UTC
With my computer HDMI needed to be connected during boot, before it would allow me to playback audio through HDMI.
Comment 3 Emrion 2019-04-27 10:41:18 UTC
(In reply to Hans Petter Selasky from comment #2)
Thanks for your reply. What do you mean by "during boot"? You have to plug the hmdi cord after the power on?

I always started the PC while the HDMI is already pluged. As it should be, no?
Comment 4 Hans Petter Selasky freebsd_committer freebsd_triage 2019-04-27 11:05:37 UTC
What graphics driver are you using?

--HPS
Comment 5 Emrion 2019-04-27 13:09:27 UTC
(In reply to Hans Petter Selasky from comment #4)
The drm drivers:

-----
$ pkg info | grep drm
drm-fbsd12.0-kmod-4.16.g20190305 DRM modules for the linuxkpi-based KMS components
drm-kmod-g20181126             Metaport of DRM modules for the linuxkpi-based KMS components
libdrm-2.4.96,1                Userspace interface to kernel Direct Rendering Module services
-----

There are some errors in dmesg:

-----
[drm] Unable to create a private tmpfs mount, hugepage support will be disabled(-19).                                                                             
Failed to add WC MTRR for [0xe0000000-0xefffffff]: -22; performance may suffer
-----

And sometimes:

-----
hdacc1: Unexpected unsolicited response with tag 63: ffffffff
-----
Comment 6 Emrion 2019-05-01 09:52:17 UTC
By the way, I just realised that the video rendering is somewhat bad (tearing). I think that the drm-kmod drivers aren't up to date enough to well use the HD630.
Comment 7 Steve Wills freebsd_committer freebsd_triage 2019-05-01 11:20:58 UTC
(In reply to Emrion from comment #6)

The tearing may be due to the driver setting, you might want to try:

   Option "TearFree" "true"
Comment 8 Emrion 2019-05-01 13:40:15 UTC
(In reply to Steve Wills from comment #7)
I tried that (from X -configure and added in xorg.conf.d folder):
----
Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
        ### <percent>: "<f>%"
        ### [arg]: arg optional
        #Option     "SWcursor"                  # [<bool>]
        #Option     "kmsdev"                    # <str>
        #Option     "ShadowFB"                  # [<bool>]
        #Option     "AccelMethod"               # <str>
        #Option     "PageFlip"                  # [<bool>]
        #Option     "ZaphodHeads"               # <str>
        Identifier  "Card0"                                     
        Driver      "modesetting"
        BusID       "PCI:0:2:0"
        Option "TearFree" "true"
EndSection
----
It doesn't work.
Comment 9 alfredoFALK 2019-08-20 07:56:19 UTC
Hi,
I also have this problem/bug on my ASUS H110T. I run 4 operating systems on different hdd/sdd on this machine: Manjaro,Win10,macOS and freeBSD as TridentOS.
All OS have a working HDMI sound connection except freeBSD.
Here are the two outputs from the standard commands requested by other websites or forums :
--------------------------------------------------------
cat /dev/sndstat:trident-3675% cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC887 (Analog)> (play/rec)
pcm1: <Realtek ALC887 (Analog)> (play/rec)
pcm2: <Intel Kaby Lake (HDMI/DP 8ch)> (play) default
No devices installed from userspace.
-----------------------------------------------------------------------------
sysctl -a | grep snd.default: hw.snd.default_unit: 2
hw.snd.default_auto: 0
------------------------------------------------------------------------------
mixer
Mixer vol      is currently set to 100:100
Mixer pcm      is currently set to 100:100
Mixer speaker  is currently set to  74:74
Mixer line     is currently set to   1:1
Mixer mic      is currently set to  67:67
Mixer mix      is currently set to  74:74
Mixer rec      is currently set to  35:35
Mixer igain    is currently set to   0:0
----------------------------------------------------------------------------


  To get to this situation I did exactly the devices.hints line mentioned by @Emrion on this bug report.
Nobody has a solution and it looks to me that the BSD community of developers has no intention to find a solution! openBSD has definitely stated they are not developing HDMI and freeBSD seems to feel the same!
Maybe somebody can prove me wrong! 
This bug has been dormant since May 2019, so my feeling is nobody is dealing with it.
Thanks to anybody who can give some help with this issue!
Comment 10 alfredoFALK 2019-08-24 17:55:21 UTC
Hi, I gather that nobody is following or looking after this bug.
Here is my latest attempt to get it to work:
 sysctl hw.snd.default_unit=2
hw.snd.default_unit: 0 -> 2

 # sysctl dev.hdaa.1.nid3
dev.hdaa.1.nid3: pin: Digital-out (Fixed)
     Widget cap: 0x0040778d PWR DIGITAL UNSOL 8CH
    Association: 0 (0x0001)
        Pin cap: 0x09000094 PDC OUT HDMI DP HBR
     Pin config: 0x98560010 as=1 seq=0 device=Digital-out conn=Fixed ctype=Digital loc=0x18 color=Unknown misc=0
    Pin control: 0x00000040 OUT
     Output amp: 0x80000000 mute=1 step=0 size=0 offset=0 (0/0dB)
    Connections: 1
          + <- nid=2 [audio output]

 # sysctl dev.hdaa.1.nid2
dev.hdaa.1.nid2: audio output
     Widget cap: 0x00006611 PWR DIGITAL 8CH
    Association: 0 (0x0001)
            OSS: pcm (pcm)
     Stream cap: 0x00000005 AC3 PCM
        PCM cap: 0x001a07f0 16 24 32 bits, 32 44 48 88 96 176 192 KHz


In /boots/devices.hints I added 
hint.hdaa.1.nid3.config="conn=Fixed"
hint.hdaa.1.nid2.config="mute=0"
hint.hdaa.1.nid1.config="conn=jack"


No sound through HDMI at all. Useless effort.
I wonder how many users of freebsd actually use a TV with HDMI as monitor. It seems that nobody cares!!
Comment 11 Damjan Jovanovic 2019-12-29 12:23:53 UTC
(In reply to alfredoFALK from comment #10)

I have the same problem and I care.
Comment 12 Damjan Jovanovic 2019-12-29 14:02:43 UTC
On one of my previous motherboard/CPU, sound over HDMI worked with FreeBSD 9.x, but regressed on a later version (possibly a later 9.x or 10.x). I cannot remember whether I still have those components, and a regression test is particularly difficult to perform as that also involved a change from GCC to Clang.
Comment 13 Alexey Dokuchaev freebsd_committer freebsd_triage 2020-01-28 04:36:22 UTC
I'm having the same problem on Lenovo L470 laptop with Intel HD Graphics 620 (Kaby Lake GT2).  When plugging HDMI cable, only image appears on the TV, but no sound, although HDMI sound output device is apparently detected correctly:

% cat /dev/sndstat 
Installed devices:
pcm0: <Realtek ALC298 (Analog 2.0+HP/2.0)> (play/rec)
pcm1: <Intel Kaby Lake (HDMI/DP 8ch)> (play) default

% mixer
Mixer vol      is currently set to  85:85
Mixer pcm      is currently set to  85:85

However, neither setting hw.snd.default_unit=1 nor passing -ao oss:/dev/dsp1 to mplayer (or corresponding settings for other players) did not help.

Needless to say, sound is correctly routed to the TV under Fedora Linux, on this very laptop.
Comment 14 alfredoFALK 2020-04-04 16:30:51 UTC
(In reply to Damjan Jovanovic from comment #11)

Well, it is a long time ago since I posted here. Just installed NomadBSD and the HDMI audio issue is still very much unsolved.
The few people who have posted here prove that FreeBSD guys are not interested in getting HDMI audio working.
So, that's it folks: nobody is interested
Comment 15 Łukasz 2020-07-10 14:44:03 UTC
I have problem with Radeon 570 (no sound with HDMI) in FREEBSD but in Ubuntu 20.04 everything OK
Comment 16 ev 2020-12-29 13:27:03 UTC
# cat /dev/sndstat
Installed devices:
pcm0: <Realtek ALC255 (Front Analog Line-out)> (play)
pcm1: <Intel Kaby Lake (HDMI/DP 8ch)> (play) default
No devices installed from userspace.

FreeBSD 12.2 - no sound :(
Comment 17 pr 2020-12-30 11:30:56 UTC
Hi,
this is a documentation bug: FreeBSD does not support HDMI audio with Radeon devices:
/usr/src/sys/dev/drm2/radeon/radeon_drv.c
int radeon_audio = 0;

Sorry.
Comment 18 ev 2020-12-30 17:49:05 UTC
Intel KabyLake is not Radeon
Comment 19 Alexey Dokuchaev freebsd_committer freebsd_triage 2021-03-19 11:22:45 UTC
*** Bug 254200 has been marked as a duplicate of this bug. ***
Comment 20 Steven Friedrich 2021-03-20 23:58:26 UTC
My bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254200
got closed as a duplicate.
I have an HP Slimline with an Intel i7 processor, using embedded UHD 630 graphics.
Comment 21 Steven Friedrich 2021-03-21 00:04:47 UTC
(In reply to Steven Friedrich from comment #20)
BTW, I also boot KDE Neon, Kubuntu 20.10, and Linux Mint Cinnamon, all up to date and they all support HDMI sound, only FreeBSD doesn't.
Comment 22 Alexey Dokuchaev freebsd_committer freebsd_triage 2021-03-21 14:06:32 UTC
(In reply to Steven Friedrich from comment #20)
> My bug: bug #254200 got closed as a duplicate.
Support of HDMI sound in currently broken on FreeBSD across lots of Intel's cards, regardless of desktop vs. mobile, particular model number, etc.  As it is not hardware-specific (at the very least, it applies to a vast range of popular consumer CPUs and graphic chips), it's better and easier to track all such reports in one place.
Comment 23 ev 2021-03-21 14:23:47 UTC
(In reply to Alexey Dokuchaev from comment #22)

It may be known - are there any prospects for changing the state of this direction?
Comment 24 Łukasz 2021-03-22 17:29:29 UTC
(In reply to Łukasz from comment #15)
I install FreeBSD 13.0-RC3 and I have HDMI sound on pcm5 output
Comment 25 Bluey 2022-03-29 03:22:47 UTC
I'm confused. Trying to figure why sound not working. But only system sound and system info not working. Web audio working. HDMI Nvidia.

FreeBSD-13.1BETA3
Cinnamon
Comment 26 brtastic.dev 2022-06-09 18:00:28 UTC
Having this issue on Thinkpad T480 (with HD Graphics 620) on FreeBSD 12.3.

Installed devices:
pcm0: <Realtek ALC257 (Analog 2.0+HP/2.0)> (play/rec) default
pcm1: <Realtek ALC257 (Right Analog Mic)> (rec)
pcm2: <Intel Kaby Lake (HDMI/DP 8ch)> (play)
No devices installed from userspace.

Sound is not sent over HDMI when using pcm2. However, this laptop also has an USB-C port capable of video output. I purchased USB-C -> HDMI adpater cable and use that instead (labelled DP-1 in xrandr). Audio goes through without problems on pcm2 in this setup.

I wonder if there should be more output options (separate devices for HDMI / USB-C) or if the system would select the actual port depending on what I have attached, same as with audio jack port (headphones)?

Anyway, would be nice to be able to just use HDMI instead of buying extra cables.
Comment 27 Richard Russo 2023-10-18 20:38:05 UTC
I put together a bit towards the beginnings of getting this to work better on a github issue https://github.com/freebsd/drm-kmod/issues/187

That patch would need a lot of polishing to be ready, but on the system I was working with, sending the codec an intel specific command enabled the audio outputs to be detected and used.

At least for Haswell/Broadwell, there's cross linked audio and video clocks, and the patch just has what worked for me in terms of making the audio sound right; at least for those two cores, audio and video drivers need to communicate, and I don't know how to accomplish that.

This patch also would need to tailored to only apply on specific cards, not just generally like I did for expediency.

Finally, at least on my hardware, I was seeing the audio output stop responding after some amount of idle time --- that would hopefully get debugged at some point, but it worked enough for me so I stopped.