• Hui Wang's avatar
    ALSA: hda/realtek - a fake key event is triggered by running shutup · 476c02e0
    Hui Wang authored
    On the Lenovo X1C7 machines, after we plug the headset, the rt_resume()
    and rt_suspend() of the codec driver will be called periodically, the
    driver can't stay in the rt_suspend state even users doen't use the
    sound card.
    
    Through debugging, I found  when running rt_suspend(), it will call
    alc225_shutup(), in this function, it will change 3k pull down control
    by alc_update_coef_idx(codec, 0x4a, 0, 3 << 10), this will trigger a
    fake key event and that event will resume the codec, when codec
    suspend agin, it will trigger the fake key event one more time, this
    process will repeat.
    
    If disable the key event before changing the pull down control, it
    will not trigger fake key event. It also needs to restore the pull
    down control and re-enable the key event, otherwise the system can't
    get key event when codec is in rt_suspend state.
    
    Also move some functions ahead of alc225_shutup(), this can save the
    function declaration.
    
    Fixes: 76f7dec0
    
     (ALSA: hda/realtek - Add Headset Button supported for ThinkPad X1)
    Cc: Kailang Yang <kailang@realtek.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: default avatarHui Wang <hui.wang@canonical.com>
    Link: https://lore.kernel.org/r/20200329082018.20486-1-hui.wang@canonical.com
    
    Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
    476c02e0
patch_realtek.c 287 KB