All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: <alsa-devel@alsa-project.org>, <linux-kernel@vger.kernel.org>,
	<patches@opensource.cirrus.com>,
	Richard Fitzgerald <rf@opensource.cirrus.com>
Subject: [PATCH 3/4] ASoC: cs42l42: Simplify reporting of jack unplug
Date: Tue, 16 Nov 2021 16:26:50 +0000	[thread overview]
Message-ID: <20211116162652.45225-7-rf@opensource.cirrus.com> (raw)
In-Reply-To: <20211116162652.45225-1-rf@opensource.cirrus.com>

When reporting a jack unplug there's no need to make the reported
flags conditional on which flags were reported during the plug
event. It's perfectly safe to report all flags and buttons as
not-present and let the higher code filter for changes.

There's also no need to make two separate snd_soc_jack_report()
calls for presence flags and button flags. It can all be done in
one report.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l42.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index 3674f73301dc..8efcee3e60d3 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -1657,18 +1657,8 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data)
 				cs42l42->plug_state = CS42L42_TS_UNPLUG;
 				cs42l42_cancel_hs_type_detect(cs42l42);
 
-				switch (cs42l42->hs_type) {
-				case CS42L42_PLUG_CTIA:
-				case CS42L42_PLUG_OMTP:
-					snd_soc_jack_report(cs42l42->jack, 0, SND_JACK_HEADSET);
-					break;
-				case CS42L42_PLUG_HEADPHONE:
-					snd_soc_jack_report(cs42l42->jack, 0, SND_JACK_HEADPHONE);
-					break;
-				default:
-					break;
-				}
 				snd_soc_jack_report(cs42l42->jack, 0,
+						    SND_JACK_HEADSET |
 						    SND_JACK_BTN_0 | SND_JACK_BTN_1 |
 						    SND_JACK_BTN_2 | SND_JACK_BTN_3);
 
-- 
2.11.0


WARNING: multiple messages have this Message-ID (diff)
From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org,
	Richard Fitzgerald <rf@opensource.cirrus.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 3/4] ASoC: cs42l42: Simplify reporting of jack unplug
Date: Tue, 16 Nov 2021 16:26:50 +0000	[thread overview]
Message-ID: <20211116162652.45225-7-rf@opensource.cirrus.com> (raw)
In-Reply-To: <20211116162652.45225-1-rf@opensource.cirrus.com>

When reporting a jack unplug there's no need to make the reported
flags conditional on which flags were reported during the plug
event. It's perfectly safe to report all flags and buttons as
not-present and let the higher code filter for changes.

There's also no need to make two separate snd_soc_jack_report()
calls for presence flags and button flags. It can all be done in
one report.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l42.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
index 3674f73301dc..8efcee3e60d3 100644
--- a/sound/soc/codecs/cs42l42.c
+++ b/sound/soc/codecs/cs42l42.c
@@ -1657,18 +1657,8 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data)
 				cs42l42->plug_state = CS42L42_TS_UNPLUG;
 				cs42l42_cancel_hs_type_detect(cs42l42);
 
-				switch (cs42l42->hs_type) {
-				case CS42L42_PLUG_CTIA:
-				case CS42L42_PLUG_OMTP:
-					snd_soc_jack_report(cs42l42->jack, 0, SND_JACK_HEADSET);
-					break;
-				case CS42L42_PLUG_HEADPHONE:
-					snd_soc_jack_report(cs42l42->jack, 0, SND_JACK_HEADPHONE);
-					break;
-				default:
-					break;
-				}
 				snd_soc_jack_report(cs42l42->jack, 0,
+						    SND_JACK_HEADSET |
 						    SND_JACK_BTN_0 | SND_JACK_BTN_1 |
 						    SND_JACK_BTN_2 | SND_JACK_BTN_3);
 
-- 
2.11.0


  parent reply	other threads:[~2021-11-16 16:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-16 16:26 [PATCH 0/4] ASoC: cs42l42: Remove redundant code Richard Fitzgerald
2021-11-16 16:26 ` Richard Fitzgerald
2021-11-16 16:26 ` [PATCH v2] ASoC: cs42l42: Add control for audio slow-start switch Richard Fitzgerald
2021-11-16 16:26   ` Richard Fitzgerald
2021-11-16 16:26 ` [PATCH 1/4] ASoC: cs42l42: Remove redundant writes to DETECT_MODE Richard Fitzgerald
2021-11-16 16:26   ` Richard Fitzgerald
2021-11-16 16:26 ` [PATCH 1/3] ASoC: dt-bindings: cs42l42: Correct description of ts-inv Richard Fitzgerald
2021-11-16 16:26   ` Richard Fitzgerald
2021-11-16 16:26 ` [PATCH 2/3] ASoC: cs42l42: Correct configuring of switch inversion from ts-inv Richard Fitzgerald
2021-11-16 16:26   ` Richard Fitzgerald
2021-11-16 16:26 ` [PATCH 2/4] ASoC: cs42l42: Remove redundant writes to RS_PLUG/RS_UNPLUG masks Richard Fitzgerald
2021-11-16 16:26   ` Richard Fitzgerald
2021-11-16 16:26 ` Richard Fitzgerald [this message]
2021-11-16 16:26   ` [PATCH 3/4] ASoC: cs42l42: Simplify reporting of jack unplug Richard Fitzgerald
2021-11-16 16:26 ` [PATCH 3/3] ASoC: dt-bindings: cs42l42: Convert binding to yaml Richard Fitzgerald
2021-11-16 16:26   ` Richard Fitzgerald
2021-11-16 16:26 ` [PATCH 4/4] ASoC: cs42l42: Remove redundant pll_divout member Richard Fitzgerald
2021-11-16 16:26   ` Richard Fitzgerald
2021-11-16 16:29 ` [PATCH 0/4] ASoC: cs42l42: Remove redundant code Richard Fitzgerald
2021-11-16 16:29   ` Richard Fitzgerald

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211116162652.45225-7-rf@opensource.cirrus.com \
    --to=rf@opensource.cirrus.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.