All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
To: Oder Chiou <oder_chiou@realtek.com>, Mark Brown <broonie@kernel.org>
Cc: "Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	"Cezary Rojewski" <cezary.rojewski@intel.com>,
	alsa-devel@alsa-project.org, "Takashi Iwai" <tiwai@suse.com>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
Subject: [PATCH 02/11] ASoC: codecs: rt286: Reorganize jack detect handling
Date: Thu,  9 Jun 2022 15:35:32 +0200	[thread overview]
Message-ID: <20220609133541.3984886-3-amadeuszx.slawinski@linux.intel.com> (raw)
In-Reply-To: <20220609133541.3984886-1-amadeuszx.slawinski@linux.intel.com>

From: Cezary Rojewski <cezary.rojewski@intel.com>

Clean up in order to use and expose .set_jack callback.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
---
 sound/soc/codecs/rt286.c           | 17 ++++++-----------
 sound/soc/codecs/rt286.h           |  2 --
 sound/soc/intel/boards/broadwell.c |  6 +++---
 sound/soc/intel/boards/skl_rt286.c |  2 +-
 4 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index ad8ea1fa7c23..0534a073ee69 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -311,7 +311,8 @@ static void rt286_jack_detect_work(struct work_struct *work)
 		SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
 }
 
-int rt286_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack)
+static int rt286_mic_detect(struct snd_soc_component *component,
+			    struct snd_soc_jack *jack, void *data)
 {
 	struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
 	struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component);
@@ -335,7 +336,6 @@ int rt286_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *j
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(rt286_mic_detect);
 
 static int is_mclk_mode(struct snd_soc_dapm_widget *source,
 			 struct snd_soc_dapm_widget *sink)
@@ -947,17 +947,11 @@ static int rt286_probe(struct snd_soc_component *component)
 	struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component);
 
 	rt286->component = component;
+	INIT_DELAYED_WORK(&rt286->jack_detect_work, rt286_jack_detect_work);
 
-	if (rt286->i2c->irq) {
-		regmap_update_bits(rt286->regmap,
-					RT286_IRQ_CTRL, 0x2, 0x2);
-
-		INIT_DELAYED_WORK(&rt286->jack_detect_work,
-					rt286_jack_detect_work);
+	if (rt286->i2c->irq)
 		schedule_delayed_work(&rt286->jack_detect_work,
-					msecs_to_jiffies(1250));
-	}
-
+				      msecs_to_jiffies(50));
 	return 0;
 }
 
@@ -1055,6 +1049,7 @@ static const struct snd_soc_component_driver soc_component_dev_rt286 = {
 	.suspend		= rt286_suspend,
 	.resume			= rt286_resume,
 	.set_bias_level		= rt286_set_bias_level,
+	.set_jack		= rt286_mic_detect,
 	.controls		= rt286_snd_controls,
 	.num_controls		= ARRAY_SIZE(rt286_snd_controls),
 	.dapm_widgets		= rt286_dapm_widgets,
diff --git a/sound/soc/codecs/rt286.h b/sound/soc/codecs/rt286.h
index f27a4e71d5b6..4b7a3bd6043d 100644
--- a/sound/soc/codecs/rt286.h
+++ b/sound/soc/codecs/rt286.h
@@ -196,7 +196,5 @@ enum {
 	RT286_AIFS,
 };
 
-int rt286_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack);
-
 #endif /* __RT286_H__ */
 
diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c
index b29d77dfb281..48bf3241b3e6 100644
--- a/sound/soc/intel/boards/broadwell.c
+++ b/sound/soc/intel/boards/broadwell.c
@@ -75,7 +75,7 @@ static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd)
 	if (ret)
 		return ret;
 
-	rt286_mic_detect(component, &broadwell_headset);
+	snd_soc_component_set_jack(component, &broadwell_headset, NULL);
 	return 0;
 }
 
@@ -235,7 +235,7 @@ static void broadwell_disable_jack(struct snd_soc_card *card)
 		if (!strcmp(component->name, "i2c-INT343A:00")) {
 
 			dev_dbg(component->dev, "disabling jack detect before going to suspend.\n");
-			rt286_mic_detect(component, NULL);
+			snd_soc_component_set_jack(component, NULL, NULL);
 			break;
 		}
 	}
@@ -255,7 +255,7 @@ static int broadwell_resume(struct snd_soc_card *card){
 		if (!strcmp(component->name, "i2c-INT343A:00")) {
 
 			dev_dbg(component->dev, "enabling jack detect for resume.\n");
-			rt286_mic_detect(component, &broadwell_headset);
+			snd_soc_component_set_jack(component, &broadwell_headset, NULL);
 			break;
 		}
 	}
diff --git a/sound/soc/intel/boards/skl_rt286.c b/sound/soc/intel/boards/skl_rt286.c
index e9f9520dcea4..4f3d655e2bfa 100644
--- a/sound/soc/intel/boards/skl_rt286.c
+++ b/sound/soc/intel/boards/skl_rt286.c
@@ -133,7 +133,7 @@ static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd)
 	if (ret)
 		return ret;
 
-	rt286_mic_detect(component, &skylake_headset);
+	snd_soc_component_set_jack(component, &skylake_headset, NULL);
 
 	snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
 
-- 
2.25.1


  parent reply	other threads:[~2022-06-09 13:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09 13:35 [PATCH 00/11] ASoC: codecs: Series of fixes for realtek codecs used on RVPs Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 01/11] ASoC: codecs: rt274: Always init jack_detect_work Amadeusz Sławiński
2022-06-09 13:35 ` Amadeusz Sławiński [this message]
2022-06-09 13:35 ` [PATCH 03/11] ASoC: codecs: rt298: Reorganize jack detect handling Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 04/11] ASoC: codecs: rt274: Move irq registration and cleanup Amadeusz Sławiński
2022-06-09 14:17   ` Mark Brown
2022-06-09 13:35 ` [PATCH 05/11] ASoC: codecs: rt286: " Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 06/11] ASoC: codecs: rt298: " Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 07/11] ASoC: codecs: rt274: Enable irq only when needed Amadeusz Sławiński
2022-06-09 14:18   ` Mark Brown
2022-06-10  9:33     ` Amadeusz Sławiński
2022-06-10 10:38       ` Mark Brown
2022-06-23 13:53     ` Amadeusz Sławiński
2022-06-23 14:23       ` Mark Brown
2022-06-09 13:35 ` [PATCH 08/11] ASoC: codecs: rt286: " Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 09/11] ASoC: codecs: rt298: " Amadeusz Sławiński
2022-06-09 13:35 ` [PATCH 10/11] ASoC: codecs: rt298: Fix NULL jack in interrupt Amadeusz Sławiński
2022-06-09 14:19   ` Mark Brown
2022-06-09 13:35 ` [PATCH 11/11] ASoC: codecs: rt298: Fix jack detection Amadeusz Sławiński
2022-06-09 14:55   ` Mark Brown
2022-06-10  9:46     ` Amadeusz Sławiński
2022-06-10 12:25       ` Mark Brown
2022-06-10 15:58 ` (subset) [PATCH 00/11] ASoC: codecs: Series of fixes for realtek codecs used on RVPs Mark Brown

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=20220609133541.3984886-3-amadeuszx.slawinski@linux.intel.com \
    --to=amadeuszx.slawinski@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=oder_chiou@realtek.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.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.