From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B5CEC433F5 for ; Tue, 4 Jan 2022 15:33:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234935AbiADPdk (ORCPT ); Tue, 4 Jan 2022 10:33:40 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:48594 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234893AbiADPde (ORCPT ); Tue, 4 Jan 2022 10:33:34 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 784EF1F37B; Tue, 4 Jan 2022 15:33:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1641310413; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=60BYL3IyCCHgn10kblzQUeOpevFWFC51SeO5PeeNMHk=; b=d3Gk9zHisNrEH8Qt9IQoeJ3Pt7KqRdOf2SwNqtX3WbqFYSx2IFDYJmgBkLF06nOgRdyaeh SqhlYmVIj5HS+wSNg6ySSgLM0ayjKaPsRUx0DyDbty+bE5UixP57FOli926s6dPMs2K3sf YvB3H4Iw4HYPNUZZanVcpg5iJ3codZg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1641310413; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=60BYL3IyCCHgn10kblzQUeOpevFWFC51SeO5PeeNMHk=; b=V3zRJOlvGwsmVWXOpNiLDS5Tw0V0nhPyVs5aijreMx8cP7T9qFZtpfTpxib3B1WVw0kRUt 4F6tdoofjKrvVkBg== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id 6BD49A3B83; Tue, 4 Jan 2022 15:33:33 +0000 (UTC) Date: Tue, 04 Jan 2022 16:33:33 +0100 Message-ID: From: Takashi Iwai To: "Christian A. Ehrhardt" Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Lucas Tanure , Stefan Binding , Vitaly Rodionov , Takashi Iwai , Jaroslav Kysela Subject: Re: hda/cs8904: Fix jack detection after resume In-Reply-To: <20211231134432.atwmuzeceqiklcoa@cae.in-ulm.de> References: <20211231134432.atwmuzeceqiklcoa@cae.in-ulm.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 31 Dec 2021 14:44:32 +0100, Christian A. Ehrhardt wrote: > > > Hi, > > while debugging something different, I found the following > jack detection related bug in the cs8904 driver on my DELL > Inspirion 3501: > - Plug in a headset, play some sound to make sure that > the headset is detected. > - Stop the sound, wait for the codec to go into suspend (30s > should be plenty enough time) > - Unplug the headset while the codec is in suspend. > - Try to play sound on the internal speakers. Notice that > the the driver still thinks the headset is connected. As a result > there is no sound on the internal speakers. > > AFAICS the bug was introduced by the following commit: > | commit 424e531b47f83da87490464c5bf633dfb624fe6a > | Author: Stefan Binding > | Date: Fri Aug 27 12:02:51 2021 +0100 > | > | ALSA: hda/cs8409: Ensure Type Detection is only run on startup when > | necessary > > The bug is with the hp_jack_in and mic_jack_in flags that are used > to determine if jack detection should be run etc. These flags > are cleared in the suspend path. This prevents a status change from > being detected after resume as hp_jack_in is cleared by suspend and > there is no jack due to the unplug of the headset. > > This status change was never reported to the HDA core, though. > On suspend this is not done, only hd_jack_in is cleared and on > resume the driver thinks that there is no change the needs reporting. > > Proposed fix below, please consider inclusion. > > regards Christian > > >From 1dcf34c1d1c6c4852a86ec3ae189afa5d90ea09c Mon Sep 17 00:00:00 2001 > From: "Christian A. Ehrhardt" > Date: Fri, 31 Dec 2021 12:13:48 +0100 > Subject: [PATCH 2/2] ALSA: hda/cs8409: Fix Jack detection after resume > > The suspend code unconditionally sets ->hp_jack_in and ->mic_jack_in > to zero but without reporting this status change to the HDA core. > To compensate for this, always assume a status change on the > first unsol event after boot or resume. > > Fixes: 424e531b47f8 ("ALSA: hda/cs8409: Ensure Type Detection is only run on startup when necessary") > Signed-off-by: Christian A. Ehrhardt Thanks, applied now. Takashi