Bug 108081

Summary: White static noise through headphones on dell xps 13 9350 late 2015 model
Product: Drivers Reporter: frank604 (frankshin82)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: RESOLVED CODE_FIX    
Severity: normal CC: frankshin82, jyc, max, tiwai, trashcan, vvisaev
Priority: P1    
Hardware: Intel   
OS: Linux   
Kernel Version: 4.3 Subsystem:
Regression: No Bisected commit-id:
Attachments: dmesg
alsa info
Fix patch (found in sound.git tree for-linus branch)
alsa-info.sh

Description frank604 2015-11-17 21:01:34 UTC
Created attachment 194721 [details]
dmesg

There is a white static noise that is heard through headphone.  The severity differs between headphones.  This also occurs on alsa only as well as alsa + pulse.

On a fresh boot, this noise can be fixed by opening alsamixer and raising 'headphone mic boost' 1 step up to a db of 10.0 for both channels.  Anything more or less will rever back to the static noise.  After a suspend/resume, the static noise returns regardless of the 'headphone mic boost'.

I have looked at http://mailman.alsa-project.org/pipermail/alsa-devel/2015-August/095923.html
and have tried to patch patch_realtek.c to no avail.

This device quirk seems to be from /sys/class/sound/card0/device/ :
subsystem_device= 0x0704
subsystem_vendor= 0x1028

What I tried to patch:
SND_PCI_QUIRK(0x1028, 0x0704, "Dell", ALC292_FIXUP_DISABLE_AAMIX), -> didn't fix
and then:
SND_PCI_QUIRK(0x1028, 0x0704, "Dell", ALC_FIXUP_DELL1_MIC_NO_PRESCENCE), -> didn't fix


00:00.0 Host bridge: Intel Corporation Sky Lake Host Bridge/DRAM Registers (rev 08)
	Subsystem: Dell Device 0704
00:02.0 VGA compatible controller: Intel Corporation Sky Lake Integrated Graphics (rev 07)
	DeviceName:  Onboard IGD
	Subsystem: Dell Device 0704
	Kernel driver in use: i915
	Kernel modules: i915
00:04.0 Signal processing controller: Intel Corporation Device 1903 (rev 08)
	Subsystem: Dell Device 0704
	Kernel driver in use: proc_thermal
	Kernel modules: processor_thermal_device
00:14.0 USB controller: Intel Corporation Device 9d2f (rev 21)
	Subsystem: Dell Device 0704
	Kernel driver in use: xhci_hcd
	Kernel modules: xhci_pci
00:14.2 Signal processing controller: Intel Corporation Device 9d31 (rev 21)
	Subsystem: Dell Device 0704
00:15.0 Signal processing controller: Intel Corporation Device 9d60 (rev 21)
	Subsystem: Dell Device 0704
00:15.1 Signal processing controller: Intel Corporation Device 9d61 (rev 21)
	Subsystem: Dell Device 0704
00:16.0 Communication controller: Intel Corporation Device 9d3a (rev 21)
	Subsystem: Dell Device 0704
00:1c.0 PCI bridge: Intel Corporation Device 9d10 (rev f1)
	Kernel driver in use: pcieport
	Kernel modules: shpchp
00:1c.4 PCI bridge: Intel Corporation Device 9d14 (rev f1)
	Kernel driver in use: pcieport
	Kernel modules: shpchp
00:1c.5 PCI bridge: Intel Corporation Device 9d15 (rev f1)
	Kernel driver in use: pcieport
	Kernel modules: shpchp
00:1d.0 PCI bridge: Intel Corporation Device 9d18 (rev f1)
	Kernel driver in use: pcieport
	Kernel modules: shpchp
00:1f.0 ISA bridge: Intel Corporation Device 9d48 (rev 21)
	Subsystem: Dell Device 0704
00:1f.2 Memory controller: Intel Corporation Device 9d21 (rev 21)
	Subsystem: Dell Device 0704
00:1f.3 Audio device: Intel Corporation Device 9d70 (rev 21)
	Subsystem: Dell Device 0704
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel
00:1f.4 SMBus: Intel Corporation Device 9d23 (rev 21)
	Subsystem: Dell Device 0704
	Kernel modules: i2c_i801
3a:00.0 Network controller: Broadcom Corporation Device 43a3 (rev 08)
	Subsystem: Dell Device 0023
	Kernel driver in use: brcmfmac
	Kernel modules: brcmfmac
3b:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device 525a (rev 01)
	Subsystem: Dell Device 0704
	Kernel driver in use: rtsx_pci
	Kernel modules: rtsx_pci
3c:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd Device a802 (rev 01)
	Subsystem: Samsung Electronics Co Ltd Device a801
	Kernel driver in use: nvme
	Kernel modules: nvme



Alsa version:
local/alsa-lib 1.1.0-1
    An alternative implementation of Linux sound support
local/alsa-plugins 1.1.0-1
    Extra alsa plugins
local/alsa-tools 1.1.0-1
    Advanced tools for certain sound cards
local/alsa-utils 1.1.0-1
    An alternative implementation of Linux sound support
local/lib32-alsa-lib 1.1.0-1
    An alternative implementation of Linux sound support (32 bit)
local/lib32-alsa-plugins 1.0.29-2
    Extra alsa plugins (32-bit)
local/pulseaudio-alsa 2-3
    ALSA Configuration for PulseAudio
local/zita-alsa-pcmi 0.2.0-2
    The successor of clalsadrv, provides easy access to ALSA PCM devices.
Comment 1 Jonathan Chan 2015-11-20 03:25:51 UTC
I have the same behavior, also on an XPS 9350.

Just to experiment, I tried comparing the outputs of `amix` before and after suspending, and nothing changed. However, the section of `lspci -nnv` for the audio driver did change.

The output before:

00:1f.3 Audio device [0403]: Intel Corporation Device [8086:9d70] (rev 21) (prog-if 80)
        Subsystem: Dell Device [1028:0704]
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 32
        Interrupt: pin A routed to IRQ 283
        Region 0: Memory at dc328000 (64-bit, non-prefetchable) [size=16K]
        Region 4: Memory at dc300000 (64-bit, non-prefetchable) [size=64K]
        Capabilities: [50] Power Management version 3
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0-,D1-,D2-,D3hot+,D3cold+)
                Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
                Address: 00000000fee00338  Data: 0000
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel, snd_soc_skl

The output after:

00:1f.3 Audio device [0403]: Intel Corporation Device [8086:9d70] (rev 21) (prog-if 80)
        Subsystem: Dell Device [1028:0704]
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 32
        Interrupt: pin A routed to IRQ 16
        Region 0: Memory at dc328000 (64-bit, non-prefetchable) [size=16K]
        Region 4: Memory at dc300000 (64-bit, non-prefetchable) [size=64K]
        Capabilities: [50] Power Management version 3
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=55mA PME(D0-,D1-,D2-,D3hot+,D3cold+)
                Status: D0 NoSoftRst+ PME-Enable- DSel=0 DScale=0 PME-
        Capabilities: [60] MSI: Enable- Count=1/1 Maskable- 64bit+
                Address: 0000000000000000  Data: 0000
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel, snd_soc_skl

The change between the two is:

3c3
<         Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
---
>         Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr-
>         Stepping- SERR- FastB2B- DisINTx-
6c6
<         Interrupt: pin A routed to IRQ 283
---
>         Interrupt: pin A routed to IRQ 16
12,13c12,13
<         Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
<                 Address: 00000000fee00338  Data: 0000
---
>         Capabilities: [60] MSI: Enable- Count=1/1 Maskable- 64bit+
>                 Address: 0000000000000000  Data: 0000

I'm not sure if this is relevant or not, but I thought I'd post it in case it might help.
Comment 2 Jonathan Chan 2015-11-20 03:31:19 UTC
In addition, removing the module with `sudo modprobe -rf snd_hda_intel` and then reloading it with `sudo modprobe snd_hda_intel` restores correct behavior.
Comment 3 Takashi Iwai 2015-11-20 16:05:31 UTC
Could you give alsa-info.sh output?  Run it with --no-upload option and attach (don't paste) to bugzilla.
Comment 4 frank604 2015-11-20 16:47:51 UTC
Created attachment 195061 [details]
alsa info
Comment 5 Takashi Iwai 2015-11-20 16:55:25 UTC
How about applying the fixup for Dell E7x?  This is for recent models, and might match better:

--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5205,6 +5205,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
 	SND_PCI_QUIRK(0x1028, 0x06de, "Dell", ALC292_FIXUP_DISABLE_AAMIX),
 	SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC292_FIXUP_DISABLE_AAMIX),
 	SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC292_FIXUP_DISABLE_AAMIX),
+	SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13", ALC292_FIXUP_DELL_E7X),
 	SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
 	SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
 	SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
Comment 6 frank604 2015-11-20 17:05:32 UTC
I'm on it.  Brb let me test.  Thank you Takashi for the fast responses.
Comment 7 frank604 2015-11-20 17:23:52 UTC
Fixup for dell e7x does not work.  Same behavior is seen after suspend/resume.
Comment 8 Takashi Iwai 2015-11-20 18:26:33 UTC
(In reply to frank604 from comment #7)
> Fixup for dell e7x does not work.  Same behavior is seen after
> suspend/resume.

Do you mean that the behavior isn't seen *at all* before suspend/resume when the fixup is applied?  Then it's interesting.

Many existing fixups are serving for multiple issues:
- Disabling aamix: it often helps the wrong loopback from the mic or the dead input.

- Disabling power-save-node: it's the cause of click noise at runtime power up/down.

- Headset mode detection and change: I guess this is the culprit in your case.
  It's a TRRS headset jack, right?

For the former two, you can enable in the hint via patch option.  See Documentation/sound/alsa/HD-Audio.txt.  For example, create a file /lib/firmware/alsa/dell-fw containing

[codec]
0x10ec0256 (In reply to frank604 from comment #7)
> Fixup for dell e7x does not work.  Same behavior is seen after
> suspend/resume.

Do you mean that the behavior isn't seen *at all* before suspend/resume when the fixup is applied?  Then it's interesting.

Many existing fixups are serving for multiple issues:
- Disabling aamix: it often helps the wrong loopback from the mic or the dead input.

- Disabling power-save-node: it's the cause of click noise at runtime power up/down.

- Headset mode detection and change: I guess this is the culprit in your case.
  It's a TRRS headset jack, right?

For the former two, you can enable in the hint via patch option.  See Documentation/sound/alsa/HD-Audio.txt.  For example, create a file /lib/firmware/alsa/dell-fw containing

[codec]
0x10ec0256 0x10280704 0
[hint]
mixer_nid = 0
power_save_node = 0

Then, add a module option to snd-hda-intel in a /etc/modprobe.d/* file like

options snd-hda-intel patch=alsa/dell-fw

About the headset mode, you really need trial-and-error.  There are lots of quirk entries regarding this.  Your codec is supposed to be ALC256-compatible, so ALC255_* ones should be usable.  But other codec quirks are also worth to try.
Comment 9 frank604 2015-11-20 20:39:53 UTC
The fixup for dell e7x does not have any positive effect.  White noise is still present before suspend which is gone after increasing 'headphone mic boost' 1 step up to a db of 10.0 for both channels.  Then after suspend, the white noise plus static is heard.

I'll give the dell-fw a try as well as go down the list of compiling in different quirks.  Is there a faster way to do the trial and error?  How I do this is boot into stock kernel and patch patch_realtek.c while I recompile a test kernel.  Then boot into test kernel to see if it worked.  Each try takes about 20 minutes.
Comment 10 Takashi Iwai 2015-11-23 13:53:12 UTC
You don't have to rebuild the whole kernel tree from scratch at each time you patch the code.  You just need to run "make module" after patching patch_realtek.c.  Then install it via "make modules_install" as root, and reboot/retest.  That's all.  It'd take only a few minutes at each cycle.
Comment 11 Takashi Iwai 2015-11-24 06:42:06 UTC
We received a new fix patch for (supposedly) this Dell laptop.  It's described for fixing the noise after resume, but this seems applied generically at boot, so this might help.  Give it a try.
Comment 12 Takashi Iwai 2015-11-24 06:42:34 UTC
Created attachment 195291 [details]
Fix patch (found in sound.git tree for-linus branch)
Comment 13 frank604 2015-11-24 08:57:37 UTC
Patch fixes the issue.  Thank you so much for your time.  Do we know which kernel this will be merged into?
Comment 14 Takashi Iwai 2015-11-24 09:12:43 UTC
Good to hear.  It'll be included in 4.4-rc3 unless anything wrong happens.
Comment 15 vvisaev 2015-12-09 21:06:08 UTC
I have same issue on dell xps 13 9350, but in either 4.2.6, 4.4rc3 and 4.4rc4 kernels.

This quirk applied, but doesn't work for me:
# cat  /sys/class/sound/card0/device/subsystem_*
0x0704
0x1028

00:1f.3 Audio device: Intel Corporation Device 9d70 (rev 21) (prog-if 80)
	Subsystem: Dell Device 0704
	Flags: bus master, fast devsel, latency 32, IRQ 282
	Memory at dc728000 (64-bit, non-prefetchable) [size=16K]
	Memory at dc700000 (64-bit, non-prefetchable) [size=64K]
	Capabilities: [50] Power Management version 3
	Capabilities: [60] MSI: Enable+ Count=1/1 Maskable- 64bit+
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel, snd_soc_skl

Alsa version: 1.0.29.

Fix with dell-fw also does not work.
Comment 16 Carl 2015-12-19 02:47:28 UTC
Hey,

the issue with the white noise from the headphones is also still present for me in the kernel 4.4rc-5 on my XPS 13 (9350)

Raising the "Headphone Mic Boost" in alsamixer one step up to +10 on both channels fixes it.

cat  /sys/class/sound/card0/device/subsystem_*
0x0704
0x1028

lshw output:

*-multimedia
             Beschreibung: Audio device
             Produkt: Intel Corporation
             Hersteller: Intel Corporation
             Physische ID: 1f.3
             Bus-Informationen: pci@0000:00:1f.3
             Version: 21
             Breite: 64 bits
             Takt: 33MHz
             Fähigkeiten: pm msi bus_master cap_list
             Konfiguration: driver=snd_hda_intel latency=32
             Ressourcen: irq:282 memory:dc728000-dc72bfff memory:dc700000-dc70ffff
Comment 17 Carl 2015-12-19 02:53:47 UTC
Created attachment 197741 [details]
alsa-info.sh

my output of alsa-info.sh in kernel 4.4rc5
Comment 18 Takashi Iwai 2015-12-19 20:05:04 UTC
(In reply to Carl from comment #16)
> Hey,
> 
> the issue with the white noise from the headphones is also still present for
> me in the kernel 4.4rc-5 on my XPS 13 (9350)
> 
> Raising the "Headphone Mic Boost" in alsamixer one step up to +10 on both
> channels fixes it.

That's interesting.  Maybe there is some hardware bug there (not meant as a hardware detect).  Do you have the latest BIOS?  I thought Canonical has tested this (that's why I received the patch), and wonder why they didn't notice it...

We may fix it to this level if this workaround is really applied to all people.
So, test by any other people with this model are appreciated.
Comment 19 vvisaev 2015-12-19 22:06:51 UTC
Fix "Headphone Mic Boost" in alsamixer one step works for me, thank you. 
db gain on "Headphone Mic Boost" must be equal "10, 10", on other values noise (little different noise for either value) returned.

I have latest BIOS 1.1.7 and without this fix I still have noise on 4.4rc5.
Comment 20 Takashi Iwai 2015-12-21 08:53:46 UTC
OK, thanks.  Then how about the patch below?  This will stop handling the headphone mic but using only the headset mic.  Just change the chain_id for ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE to ALC255_FIXUP_DELL2_MIC_NO_PRESENCE.

--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5185,7 +5185,7 @@ static const struct hda_fixup alc269_fixups[] = {
                        {}
                },
                .chained = true,
-               .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
+               .chain_id = ALC255_FIXUP_DELL2_MIC_NO_PRESENCE
        },
 };
Comment 21 vvisaev 2015-12-23 06:38:26 UTC
Thanks for reply!

No, this patch does not work for me.

With this patch I can't change "Headphone Mic Boost" in alsamixer, and workaround also not work.
Comment 22 Takashi Iwai 2015-12-23 07:44:06 UTC
OK, then a slightly more changes are needed.
Comment 23 vvisaev 2015-12-31 10:47:51 UTC
Can you mark this bug as REOPENED?
Comment 24 Max Ammann 2017-01-23 20:49:38 UTC
Is there a new report for this bug? Still have a static noise if I do not change "Headphone Mic Boost" to 22.