Bug 200526

Summary: [snd_hda] hissing/static noise from headphone jack on Dell Precision M4800
Product: Base System Reporter: david
Component: kernAssignee: freebsd-multimedia (Nobody) <multimedia>
Status: Closed FIXED    
Severity: Affects Only Me CC: bsd, crest, eric, felselva, hesitatej, ish, mav, sbruno, terjeloe, vangyzen, vermaden
Priority: ---    
Version: 10.1-STABLE   
Hardware: amd64   
OS: Any   
Attachments:
Description Flags
Verbose dmesg.boot after modifying /boot/device.hints
none
Patch (via Jakob Alvermark) to sys/dev/sound/pci/hda/hdaa.c for head@r339121 none

Description david 2015-05-29 21:15:06 UTC
Several weeks ago, I replaced my Dell Precision M440 laptop with a new M4800.  Sound had "just worked" on the M4400; I was, therefore, rather surprised when I found the hissing/static noise cited in the summary (after swapping the drive from the M4400 into the M4800).

I posted about this on a Dell forum (as I wanted to have some way of determining whether this might be a hardware issue (e.g., flaky ground connection or something similar); ref. <http://en.community.dell.com/support-forums/laptop/f/3517/t/19628711> for that thread.  As noted there, I found that the objectionable sound in question is not present (and sound appears to work OK) when the machine runs MS Windows.  I believe that this implies that the observed problem is not because of a hardware issue.

I also posted about the issue in freebsd-multimedia@; ref. <http://docs.FreeBSD.org/cgi/mid.cgi?20150416173126.GG36163> for the start of that thread.

I have also found that if I boot Fedora 20 or 21, sound works as expected (no hissing); trying Fedora 19, there is no sound at all.

<http://www.catwhisker.org/~david/FreeBSD/m4800/hda.txt> has the "hda" and "pcm" parts of a verbose dmesg.boot; I have placed several other possibly-useful (and -relevant) files in the same directory (<http://www.catwhisker.org/~david/FreeBSD/m4800/>), including dmesg and output from the "ALSA Information Script" from testing Fedora 21.

The effect appears to be the same whether I run i386 or amd64, and whether I run stable/10 or head.  (I track each of those four combinations daily, and capture a verbose dmesg.boot for each.)

I will be happy to hack & test, but I need some guidance.
Comment 1 Sean Bruno freebsd_committer freebsd_triage 2015-06-07 15:51:11 UTC
Exactly the same issue on the Dell E7240.  Audio works 100% great with speakers.

Attaching headphones yeilds nothing but static.

hdac0@pci0:0:3:0:	class=0x040300 card=0x05ca1028 chip=0x0a0c8086 rev=0x0b hdr=0x00
    vendor     = 'Intel Corporation'
    class      = multimedia
    subclass   = HDA


My current device config looks like this:
https://people.freebsd.org/~sbruno/hdaa_haswell.log
Comment 2 Sean Bruno freebsd_committer freebsd_triage 2015-06-07 15:54:28 UTC
(In reply to Sean Bruno from comment #1)

Wait a second.  My Haswell laptop has 2 HDAC devices?

hdac0@pci0:0:3:0:       class=0x040300 card=0x05ca1028 chip=0x0a0c8086 rev=0x0b hdr=0x00
    vendor     = 'Intel Corporation'
    class      = multimedia
    subclass   = HDA

hdac1@pci0:0:27:0:      class=0x040300 card=0x05ca1028 chip=0x9c208086 rev=0x04 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Lynx Point-LP HD Audio Controller'
    class      = multimedia
Comment 3 Sean Bruno freebsd_committer freebsd_triage 2015-06-07 16:09:19 UTC
hdaa1 is sensing that I'm attaching headphones.  I'm unsure if this is the correct ping to be changing though:

pin dump speakers:
https://people.freebsd.org/~sbruno/hdaa_haswell_pindump_speakers.txt

ping dump headphones:
https://people.freebsd.org/~sbruno/hdaa_haswell_pindump_headphones.txt

diff:

19c19
< hdaa1:     Caps:    OUT HP EAPD      Sense: 0x80000000 (connected)
---
> hdaa1:     Caps:    OUT HP EAPD      Sense: 0x00000000 (disconnected)
37a38
>
Comment 4 Sean Bruno freebsd_committer freebsd_triage 2015-06-08 02:06:43 UTC
hrm ... ok, its definitely not hardware.  Fedora Linux live can deal with it just fine and audio switches automagically.

Is there a pindump or something I can get from linux to figure out what's the proper config for this audio device?
Comment 5 Sean Bruno freebsd_committer freebsd_triage 2015-06-08 02:15:01 UTC
Linux sees this (according to its dmesg):

[    9.182156] snd_hda_intel 0000:00:03.0: bound 0000:00:02.0 (ops i915_audio_component_bind_ops [i915])
[    9.196186] uvcvideo: Found UVC 1.00 device Laptop_Integrated_Webcam_HD (0c45:64d2)
[    9.205102] input: HDA Intel HDMI HDMI/DP,pcm=3 as /devices/pci0000:00/0000:00:03.0/sound/card0/input9
[    9.205188] input: HDA Intel HDMI HDMI/DP,pcm=7 as /devices/pci0000:00/0000:00:03.0/sound/card0/input10
[    9.205266] input: HDA Intel HDMI HDMI/DP,pcm=8 as /devices/pci0000:00/0000:00:03.0/sound/card0/input11
[    9.206228] sound hdaudioC1D0: autoconfig for ALC3226: line_outs=1 (0x16/0x0/0x0/0x0/0x0) type:line
[    9.206232] sound hdaudioC1D0:    speaker_outs=1 (0x14/0x0/0x0/0x0/0x0)
[    9.206234] sound hdaudioC1D0:    hp_outs=1 (0x15/0x0/0x0/0x0/0x0)
[    9.206235] sound hdaudioC1D0:    mono: mono_out=0x0
[    9.206237] sound hdaudioC1D0:    inputs:
[    9.206239] sound hdaudioC1D0:      Dock Mic=0x19
[    9.206241] sound hdaudioC1D0:      Headset Mic=0x1a
[    9.206242] sound hdaudioC1D0:      Internal Mic=0x12
[    9.214559] input: HDA Intel PCH Dock Mic as /devices/pci0000:00/0000:00:1b.0/sound/card1/input12
[    9.214641] input: HDA Intel PCH Dock Line Out as /devices/pci0000:00/0000:00:1b.0/sound/card1/input13
[    9.214714] input: HDA Intel PCH Front Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card1/input14
Comment 6 Alexander Motin freebsd_committer freebsd_triage 2015-06-09 00:16:29 UTC
According to what I can see, both headphones (node 21) and speaker (node 20) outputs receive signal from the same node 12. I don't see why one of them would have a noise, while other don't.
Comment 7 hesitatej 2016-02-13 10:14:28 UTC
I have the similar problem on my Dell Latitude E6440, running a FreeBSD 10.1-RELEASE-p26. The built-in speaker works without any further configuration. Upon plugging in the headphone, the speaker will be muted automatically, but there is no sound (only a very low level static noise) coming through to the headphone. 

The original configuration of the GPIO pins set by the operating system (FreeBSD 10.1-RELEASE-p26) is 

hdaa1: <Realtek (0x0292) Audio Function Group> at nid 1 on hdacc1
hdaa1: Subsystem ID: 0x102805bd
hdaa1: NumGPIO=5 NumGPO=0 NumGPI=0 GPIWake=0 GPIUnsol=1
hdaa1:  GPIO0: disabled
hdaa1:  GPIO1: disabled
hdaa1:  GPIO2: disabled
hdaa1:  GPIO3: disabled
hdaa1:  GPIO4: disabled


I have written a script to use sysctl(1) to change the runtime tunable "dev.hdaa.%d.gpio_config" into all possible (5^5=3125) GPIO pin-value combinations, but none was able to make the headphone work.
Comment 8 Sean Bruno freebsd_committer freebsd_triage 2016-03-29 15:11:24 UTC
I think we all need something like the realtek quirks listed here:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/sound/pci/hda/patch_realtek.c#n5423
Comment 9 Masachika ISHIZUKA 2016-04-06 06:59:11 UTC
I'm using dell xps12 9q33.
I also had been suffering for a long time hiss, but was finally resolved.
For headset jack is marked with the microphone terminal, I add the following to the /boot/device.hints as mic jack is recognized.

hint.hdaa.1.nid27.config="as=4 seq=0 device=Mic conn=Jack loc=Left ctype=1/8 color=Black misc=0"
Comment 10 david 2016-04-06 13:52:40 UTC
Created attachment 169036 [details]
Verbose dmesg.boot after modifying /boot/device.hints
Comment 11 Masachika ISHIZUKA 2016-04-06 14:38:02 UTC
(In reply to david from comment #10)
Since 'as = 4' is already used by the internal mic of nid18, what if as of nid27 will try to 5 instead of 4? It is useless because it became a disabled right now.
In audio mixer of nid11 'nid = 27 [pin: Mic (Black Jack)]' adds, 'pcm4: <Realtek ALC269 (Left Analog Mic)> (rec)' it should be added.
Comment 12 Masachika ISHIZUKA 2016-04-07 00:50:53 UTC
'pcm4: <Realtek ALC269 (Left Analog Mic)> (rec)' in Comment 11 is an error of 'pcm4: <Realtek ALC292 (Left Analog Mic)> (rec)'.

My dmesg is http://www17.plala.or.jp/ish-org/dmesg.txt and misc information is http://www17.plala.or.jp/ish-org/misc.txt.
Comment 14 Ivan 2016-09-18 18:10:18 UTC
I have Dell XPS 13 and distorted sound as well. According commit we need to power up nid2 ?
Comment 15 Jan Bramkamp 2016-10-05 15:34:23 UTC
The problem still exists in FreeBSD 11.0-p1 on a Dell M4800.
Comment 16 Jan Bramkamp 2016-10-05 15:34:40 UTC
The problem still exists in FreeBSD 11.0-p1 on a Dell M4800.
Comment 17 hesitatej 2017-01-28 11:29:47 UTC
While it is apparent that this is a driver issue, I have managed to find an elaborated 'workaround'. One can use bhyve to run a linux operating system on FreeBSD, and then pass through the sound devices to the virtual machine. I have tried both Ubuntu Server 16.04.1 LTS and Ubuntu 16.04.1 LTS (destop) and have obtained successful outcomes where I was able to use the headphone socket through the virtual machines normally. So at least now I can use FreeBSD and the headphone socket at the same time.
Comment 18 Slawomir Wojciech Wojtczak 2018-01-25 13:43:20 UTC
Any update on that?

Linux solution is 3 lines of code that send shutdown signal to nid2.

Probably, it should be added here:
https://github.com/freebsd/freebsd/blob/ced875130d74498a2efed66b4800f0a211ad5993/sys/dev/sound/pci/hda/hdaa_patches.c
Comment 19 david 2018-10-03 13:00:06 UTC
Created attachment 197742 [details]
Patch (via Jakob Alvermark) to sys/dev/sound/pci/hda/hdaa.c for head@r339121

Patch was obtained form Jakob Avermark's post to -current, a copy of which is at https://lists.freebsd.org/pipermail/freebsd-current/2018-October/071454.html

Note that I also added

# Test a possible "sound" fix
hint.hdaa.0.nid33.config="as=1 seq=15 device=Headphones"

to /boot/loader.conf.

The fix also applies to stable/11 (@r339120) (possibly with a bit of fuzz): that is what I am running as I type this.
Comment 20 Terje Loe 2018-12-11 09:06:20 UTC
I have a xps 13 9360.

I've added the patch and the line below to my /boot/device.hints and still have noise on my headphone jack.

hint.hdaa.0.nid33.config="as=2 seq=15"
Comment 21 felselva 2018-12-29 05:20:03 UTC
Hi,

I was having the same problem, with the internal analog working fine (Realtek ALC255), and the output of headphones (also Realtek ALC255) with distortion.

This was the solution for me: https://discourse.trueos.org/t/distorted-sound-in-headphones-only/2818/8

I switched to the headphones:
- sysctl hw.snd.default_unit=4

Then I tweaked with the PCM levels with the mixer:
- mixer pcm 50:100

The solution for me was exactly that difference in level between the two outputs (50:100, but other values can be used too).

Hopefully this is the case for everyone, because I've googled around a lot and this problem isn't so uncommon.
Comment 22 commit-hook freebsd_committer freebsd_triage 2019-07-17 04:13:54 UTC
A commit references this bug:

Author: sbruno
Date: Wed Jul 17 04:13:47 UTC 2019
New revision: 350078
URL: https://svnweb.freebsd.org/changeset/base/350078

Log:
  I add the ability to accept the default pin widget configuration to help
  with various laptops using hdaa(4) sound devices.  We don't seem to know
  the "correct" configurations for these devices and the defaults are far
  superiour, e.g. they work if you don't nuke the default configs.

  PR:	200526
  Differential Revision:	https://reviews.freebsd.org/D17772

Changes:
  head/share/man/man4/snd_hda.4
  head/sys/dev/sound/pci/hda/hdaa.c
  head/sys/dev/sound/pci/hda/hdaa.h
Comment 23 david 2020-04-27 13:29:25 UTC
The above commit addresses my concerns, so I believe this bug report should be closed.