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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7314C4167B for ; Wed, 30 Mar 2022 11:55:40 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id ECEE518C1; Wed, 30 Mar 2022 13:54:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ECEE518C1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1648641339; bh=e/QTXOR4IKo2wWU/0hmkkw381mCDHN8YxiKFRH0zEm0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=AKjwQNWjLvhtEUjkc7DD+VaCHnY1MmszqbKRsNs3u3MnQvliVcSTaYg3JgdR9ZFGp zQG2+fI8MfvgNVs2KCy8ntztQDajaaSW9HTdsHdqDKbFDTrvkku79QpsM+Nt6PZFzy yOwu2EYRADs22l51pjM85FpNNgZxv1jmOqzH5Vuc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 93AC8F805D8; Wed, 30 Mar 2022 13:48:52 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 67EEBF804E4; Wed, 30 Mar 2022 13:48:51 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0466CF804E4 for ; Wed, 30 Mar 2022 13:48:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0466CF804E4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="okgVZxXE" Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EB1E16137A; Wed, 30 Mar 2022 11:48:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EE07C36AE7; Wed, 30 Mar 2022 11:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648640923; bh=e/QTXOR4IKo2wWU/0hmkkw381mCDHN8YxiKFRH0zEm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=okgVZxXE9nccnCBJT40YVOpIqYwA6p2KzE6n3bk01UWM8bE4M1Lp670yG7nfgGIxf Imf2X9w5uL6FtlGtu2/uUi5OW4F0VFB20d/M7qzUZH8rio9TeMN0d3dEMtBg+X7sPr zMEg7HGAGLpLzpRT4DPgz8p8PTVS3EqN9LUEd7vqB7kCVNg9LrMAdVuPQV4XPrY99p zQCICkKV/a1aFJts81ALqMJ1rVunj3NKxzedYHImbmG7IpetZjv44SPOtmlTi8Q1wz /qhJyUsyQPfaukSqU2f8YSne1uQ2c7GAoCkRIxj1R7vFr/+aS+O7tqv5xS92sgBeba ACXQo5BZSxOYQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.16 07/59] ASoC: cs42l42: Report full jack status when plug is detected Date: Wed, 30 Mar 2022 07:47:39 -0400 Message-Id: <20220330114831.1670235-7-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220330114831.1670235-1-sashal@kernel.org> References: <20220330114831.1670235-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Cc: Sasha Levin , brian.austin@cirrus.com, alsa-devel@alsa-project.org, tiwai@suse.com, lgirdwood@gmail.com, Paul.Handrigan@cirrus.com, Richard Fitzgerald , Mark Brown X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Richard Fitzgerald [ Upstream commit 8d06f797f844d04a961f201f886f7f9985edc9bf ] When a plug event is detect report the full state of all status bits, don't assume that there will have been a previous unplug event to clear all the bits. Report the state of both HEADPHONE and MICROPHONE bits according to detected type, and clear all the button status bits. The current button status is already checked and reported at the end of the function. During a system suspend the jack could be unplugged and plugged, possibly changing the jack type. On resume the interrupt status will indicate a plug event - there will not be an unplug event to clear the bits. Signed-off-by: Richard Fitzgerald Link: https://lore.kernel.org/r/20220121120412.672284-2-rf@opensource.cirrus.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/cs42l42.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c index a63fba4e6c9c..eb170d106396 100644 --- a/sound/soc/codecs/cs42l42.c +++ b/sound/soc/codecs/cs42l42.c @@ -1630,7 +1630,11 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) mutex_lock(&cs42l42->jack_detect_mutex); - /* Check auto-detect status */ + /* + * Check auto-detect status. Don't assume a previous unplug event has + * cleared the flags. If the jack is unplugged and plugged during + * system suspend there won't have been an unplug event. + */ if ((~masks[5]) & irq_params_table[5].mask) { if (stickies[5] & CS42L42_HSDET_AUTO_DONE_MASK) { cs42l42_process_hs_type_detect(cs42l42); @@ -1638,11 +1642,15 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) case CS42L42_PLUG_CTIA: case CS42L42_PLUG_OMTP: snd_soc_jack_report(cs42l42->jack, SND_JACK_HEADSET, - SND_JACK_HEADSET); + SND_JACK_HEADSET | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3); break; case CS42L42_PLUG_HEADPHONE: snd_soc_jack_report(cs42l42->jack, SND_JACK_HEADPHONE, - SND_JACK_HEADPHONE); + SND_JACK_HEADSET | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3); break; default: break; -- 2.34.1