• Thomas Hebb's avatar
    ALSA: hda/realtek - Set principled PC Beep configuration for ALC256 · c4473744
    Thomas Hebb authored
    The Realtek PC Beep Hidden Register[1] is currently set by
    patch_realtek.c in two different places:
    
    In alc_fill_eapd_coef(), it's set to the value 0x5757, corresponding to
    non-beep input on 1Ah and no 1Ah loopback to either headphones or
    speakers. (Although, curiously, the loopback amp is still enabled.) This
    write was added fairly recently by commit e3743f431143 ("ALSA:
    hda/realtek - Dell headphone has noise on unmute for ALC236") and is a
    safe default. However, it happens in the wrong place:
    alc_fill_eapd_coef() runs on module load and cold boot but not on S3
    resume, meaning the register loses its value after suspend.
    
    Conversely, in alc256_init(), the register is updated to unset bit 13
    (disable speaker loopback) and set bit 5 (set non-beep input on 1Ah).
    Although this write does run on S3 resume, it's not quite enough to fix
    up the register's default value of 0x3717. What's missing is a set of
    bit 14 to disable headphone loopback. Without that, we end up with a
    feedback loop where the headphone jack is being driven by amplified
    samples of itself[2].
    
    This change eliminates the update in alc256_init() and replaces it with
    the 0x5757 write from alc_fill_eapd_coef(). Kailang says that 0x5757 is
    supposed to be the codec's default value, so using it will make
    debugging easier for Realtek.
    
    Affects the ALC255, ALC256, ALC257, ALC235, and ALC236 codecs.
    
    [1] Newly documented in Documentation/sound/hd-audio/realtek-pc-beep.rst
    
    [2] Setting the "Headphone Mic Boost" control from userspace changes
    this feedback loop and has been a widely-shared workaround for headphone
    noise on laptops like the Dell XPS 13 9350. This commit eliminates the
    feedback loop and makes the workaround unnecessary.
    
    Fixes: e1e8c1fd ("ALSA: hda/realtek - Dell headphone has noise on unmute for ALC236")
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarThomas Hebb <tommyhebb@gmail.com>
    Link: https://lore.kernel.org/r/bf22b417d1f2474b12011c2a39ed6cf8b06d3bf5.1585584498.git.tommyhebb@gmail.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
    c4473744
patch_realtek.c 287 KB