How to prevent white noise in headphones on Dell XPS 13 9350/9360

8,903

Solution 1

Set Headphone Mic Boost gain to 10dB. Any other value seems to cause the irritating background noise in headphones. This can be done with amixer:

amixer -c0 sset 'Headphone Mic Boost' 10dB

To make this happen automatically every time you headphones are connected install acpid.

Start it by running: sudo systemctl start acpid.service

Enable it by running: sudo systemctl enable acpid.service

Create following event script /etc/acpi/headphone-plug

event=jack/headphone HEADPHONE plug
action=/etc/acpi/cancel-white-noise.sh %e

Then create action script /etc/acpi/cancel-white-noise.sh:

#! /bin/bash
amixer -c0 sset 'Headphone Mic Boost' 10dB

Now Headphone Mic Boost will be set to 10dB every time headphones are connected. To make this effective you need to restart your laptop.

Solution 2

How do I prevent it?

This issue was caused by a bug in Linux's HD Audio driver and is now fixed. All kernel versions 5.7 and above will have the fix, and it has additionally been backported into several stable kernels, appearing in versions 5.6.5, 5.5.18, 5.4.33, and 4.19.116 respectively. Upgrading to a kernel with the fix should make the issue disappear without additional configuration or workarounds.

The fix in the kernel is better than the workaround from the other answer in several ways:

  • Audio in headphones is significantly louder and somewhat clearer.
  • There is no longer popping in headphones on codec suspend/resume.
  • The "Headphone Mic Boost" control actually serves its intended purpose—to set the gain when the 3.5mm jack is configured as a microphone input. It no longer has any effect when the jack is configured for headphones or a headset.

What was the problem?

It turns out that some Realtek HD Audio codecs, including the one in the XPS 13 9350 and 9360, can route audio in ways not exposed by the self-documenting "node graph" that is usually used to configure HD Audio codecs. Due to a confluence of several errors, the kernel has been configuring the XPS 13 since at least 2015 to capture the signal from the 3.5mm jack as if a microphone were plugged in, amplify it, and route it back out to the jack.

As you might imagine, this feedback loop caused undesirable effects, most noticeably white noise that varied in character depending on the amount by which the signal was amplified before being fed back (the "Headphone Mic Boost" control). It seems to be a lucky accident that one of the gain levels happened to result in almost no noise. However, because the feedback loop was still there, you'd still hear quieter, lower quality audio than intended as well as popping on codec suspend/resume.

For more information, see my patch series which implemented the fix. The commit messages in that series, along with the reverse-engineered documentation it adds for the Realtek register that controls hidden audio routes, provide a detailed explanation of the issue, its history, and the fix.

Share:
8,903

Related videos on Youtube

Henri Koski
Author by

Henri Koski

Updated on September 18, 2022

Comments

  • Henri Koski
    Henri Koski over 1 year

    Every time time I connect headphones to the 3.5mm audio jack on my Dell XPS 13, I hear continuous white noise in addition to the audio I expect to hear. It's much louder than the typical noise floor for a headphone jack.

    I've found many other reports of this same problem for both the XPS 13 9350 (1, 2) and the XPS 13 9360 (1, 2, 3), so it doesn't seem like I have a faulty unit.

    Is there a way to stop this noise?

    • Admin
      Admin over 7 years
      Why is your microphone enabled when you're not using it?
    • Admin
      Admin over 7 years
      @DmitryGrigoryev It doesn't matter if the headset mic is on or off the white noise is still there.
    • Admin
      Admin over 6 years
      erm why is this unclear? this is very much a legit issue on XPS 13s. classic tryhard stack exchange mods
  • Gaurav
    Gaurav about 6 years
    This works with a slight modification on ubuntu 16.04. The headphone-plug event script should be in /etc/acpi/events instead and this doesn't need a chmod +x The cancel-white-noise.sh path should work as mentioned above, but the file needs a chmod +x After setting them up, run sudo service acpid restart. Worked for me without a restart. Thanks :)
  • Roald
    Roald over 4 years
    Thanks a lot. This solution also worked for me on Ubuntu 18.04.3. Baffling that the question is closed.
  • Tudor
    Tudor over 4 years
    Holy hell.. You are a life saver! Confirmed working on Ubuntu 19.04. The hissing was driving me insane! Thanks!!
  • A.B
    A.B about 4 years
    This patch in kernel 5.6.5: ALSA: hda/realtek - Remove now-unnecessary XPS 13 headphone noise fixups hints that there was a previous also recent fix for some Dell XPS 13 9350/9360 sound issues, maybe making this answer not needed anymore (with a kernel >= 5.6.5)
  • Matt R
    Matt R over 3 years
    Unfortunately, I'm still getting this issue on Dell XPS 15 7590 with kernel 5.7.0
  • Matt R
    Matt R over 3 years
    This has not worked for my Dell XPS 15 7590 with kernel 5.7.0.
  • Tom Hebb
    Tom Hebb over 3 years
    @MattR you're getting the same issue described in the original post, where you hear hissing that gets louder or quieter based on the "Headphone Mic Boost" ALSA control? What's the output of dmesg | grep snd_hda_codec_realtek for you?
  • Tom Hebb
    Tom Hebb over 3 years
    Ah, I just saw your comment on the other answer that adjusting "Headphone Mic Boost" does nothing for you. Unfortunately, that probably means your issue is an entirely different root cause from the one this question is about. I see that your laptop has a different codec (ALC298 instead of ALC256), and I don't think that codec even has the feature that was being improperly configured and causing noise on the 9350/9360.