Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp719898pxb; Tue, 5 Apr 2022 20:13:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQW2agqh62wTtVrNpLDq+kjJJQ7uGjwu2KdtF1SN1uMkx6tMxxT6fU7ogMwvnZh8vpVD0s X-Received: by 2002:a17:902:6a8a:b0:156:8ff6:daf0 with SMTP id n10-20020a1709026a8a00b001568ff6daf0mr6544931plk.117.1649214816333; Tue, 05 Apr 2022 20:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649214816; cv=none; d=google.com; s=arc-20160816; b=ezZ3Ijvdh5fQK3WKBM/rrgxnALO25Ns2i1aIX+zo/pDj+u1K9MJqfRp6SxRXS3RmbZ /CQXr9373v9f3+PgVgGL2mujmI8IkGJxljk+yll4ihxz5iH9r161LQzHOmslpFlUY2Jc v7qQcag2ABLCLKCOhr0c4B54NMh09J2yvoq17r/uXtfRvPaOI9lnFlkoSV/i8hX/kPnz viunAzHB0EoXJjS1VfWlfj0AHVtQrXxKcfBTiJp0OJ/Psl7rXqBKqD745CLKHVimfOx9 1BUZvyjh9OB2oK9Z4EEiobWBj11BT9rmlnM9l4/oNBHbGZcOv6MTNt1zfjfVh/smmSSb hPRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LLkjrtXPelaoiCwb04e1vVjx9jDBv8VrtviN33Md+f8=; b=wh24ij0RNVQwtTfRyeJEuqIINcZONTkf1st9KrmNWGG3hzb1UT7Z/qUjmjrg4plkz4 mXw0FUUj3/6wWCUDS6BM6AHgDXDfGi6ITf1AXy/pvz2Guin3O96S8Vl1/km5+gipSOj6 zYNKtET/WKfoIZK9PvaCpXOtbppux2WWLFrL0Z90h8JQgEaxFEBtdhG57ERjJXnhMlFE lzLDkH+xoqdl9h9F/bjXyaUstBEUa2nydwS4DmKGOKsqRnhLpyQwLRzVqNmk+yvhcj3P Riuc6IZPgZDYsuzM7ZNYUh+13kgH1TnJaVA4s06ToNsITjkb2eFzOaIROf3HCrjgsbyC pQWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dlzG5vEF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k129-20020a633d87000000b0038217505808si165288pga.119.2022.04.05.20.13.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 20:13:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dlzG5vEF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 167F42F0B19; Tue, 5 Apr 2022 19:53:12 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351365AbiDEKCV (ORCPT + 99 others); Tue, 5 Apr 2022 06:02:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234132AbiDEIYQ (ORCPT ); Tue, 5 Apr 2022 04:24:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 888BC636C; Tue, 5 Apr 2022 01:20:04 -0700 (PDT) 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 EF65260B12; Tue, 5 Apr 2022 08:20:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 047A7C385A0; Tue, 5 Apr 2022 08:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649146803; bh=l3oxgia/AH524WfPDCJYya+1eJReQrdeKfEHcOOgSqc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dlzG5vEFQDlGKnshNMsnk9GHqp4ihxwLdDR9Okt9lP5NdL/IT7YI0HOkJMe9NXlgT xX35vtZ8trGpmtE781vPN8iHEWTEsNgTeJGV+sLOMZ1r0ZDqv8+FjYQPScmNqHxKhb /mnEBeAo5HGEa5RFlPBBkKFn7A5o9VcS8NzTnoJE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Fitzgerald , Mark Brown , Sasha Levin Subject: [PATCH 5.17 0895/1126] ASoC: cs42l42: Report full jack status when plug is detected Date: Tue, 5 Apr 2022 09:27:22 +0200 Message-Id: <20220405070433.794774788@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 43d98bdb5b5b..2c294868008e 100644 --- a/sound/soc/codecs/cs42l42.c +++ b/sound/soc/codecs/cs42l42.c @@ -1637,7 +1637,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); @@ -1645,11 +1649,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