All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
	pierre-louis.bossart@linux.intel.com, tiwai@suse.com,
	hdegoede@redhat.com, amadeuszx.slawinski@linux.intel.com
Subject: [PATCH 02/11] ASoC: Intel: avs: da7219: Refactor jack handling
Date: Fri, 25 Nov 2022 19:40:23 +0100	[thread overview]
Message-ID: <20221125184032.2565979-3-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20221125184032.2565979-1-cezary.rojewski@intel.com>

From: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>

Use link->exit() rather than pdev->remove() to unassign jack during card
unbind procedure so codec link initialization and exit procedures are
symmetrical.

Also, there is no need to perform search for codec dai in suspend_pre()
and resume_post() ourselves. Use snd_soc_card_get_codec_dai() instead.

Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/avs/boards/da7219.c | 34 +++++++++++------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/sound/soc/intel/avs/boards/da7219.c b/sound/soc/intel/avs/boards/da7219.c
index ad86cef101cc..acd43b6108e9 100644
--- a/sound/soc/intel/avs/boards/da7219.c
+++ b/sound/soc/intel/avs/boards/da7219.c
@@ -72,10 +72,10 @@ static const struct snd_soc_dapm_route card_base_routes[] = {
 
 static int avs_da7219_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
-	struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
+	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(runtime, 0);
+	struct snd_soc_component *component = codec_dai->component;
 	struct snd_soc_card *card = runtime->card;
 	struct snd_soc_jack *jack;
-	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(runtime, 0);
 	int clk_freq;
 	int ret;
 
@@ -109,9 +109,12 @@ static int avs_da7219_codec_init(struct snd_soc_pcm_runtime *runtime)
 	snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
 	snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
 
-	snd_soc_component_set_jack(component, jack, NULL);
+	return snd_soc_component_set_jack(component, jack, NULL);
+}
 
-	return 0;
+static void avs_da7219_codec_exit(struct snd_soc_pcm_runtime *rtd)
+{
+	snd_soc_component_set_jack(asoc_rtd_to_codec(rtd, 0)->component, NULL, NULL);
 }
 
 static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port,
@@ -146,6 +149,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
 	dl->id = 0;
 	dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;
 	dl->init = avs_da7219_codec_init;
+	dl->exit = avs_da7219_codec_exit;
 	dl->nonatomic = 1;
 	dl->no_pcm = 1;
 	dl->dpcm_capture = 1;
@@ -188,30 +192,19 @@ static int avs_create_dapm_routes(struct device *dev, int ssp_port,
 	return 0;
 }
 
-static int avs_card_set_jack(struct snd_soc_card *card, struct snd_soc_jack *jack)
-{
-	struct snd_soc_component *component;
-
-	for_each_card_components(card, component)
-		snd_soc_component_set_jack(component, jack, NULL);
-	return 0;
-}
-
-static int avs_card_remove(struct snd_soc_card *card)
-{
-	return avs_card_set_jack(card, NULL);
-}
-
 static int avs_card_suspend_pre(struct snd_soc_card *card)
 {
-	return avs_card_set_jack(card, NULL);
+	struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, DA7219_DAI_NAME);
+
+	return snd_soc_component_set_jack(codec_dai->component, NULL, NULL);
 }
 
 static int avs_card_resume_post(struct snd_soc_card *card)
 {
+	struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, DA7219_DAI_NAME);
 	struct snd_soc_jack *jack = snd_soc_card_get_drvdata(card);
 
-	return avs_card_set_jack(card, jack);
+	return snd_soc_component_set_jack(codec_dai->component, jack, NULL);
 }
 
 static int avs_da7219_probe(struct platform_device *pdev)
@@ -249,7 +242,6 @@ static int avs_da7219_probe(struct platform_device *pdev)
 	card->name = "avs_da7219";
 	card->dev = dev;
 	card->owner = THIS_MODULE;
-	card->remove = avs_card_remove;
 	card->suspend_pre = avs_card_suspend_pre;
 	card->resume_post = avs_card_resume_post;
 	card->dai_link = dai_link;
-- 
2.25.1


  parent reply	other threads:[~2022-11-25 18:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-25 18:40 [PATCH 00/11] ASoC: Intel: avs: Refactor jack handling Cezary Rojewski
2022-11-25 18:40 ` [PATCH 01/11] ASoC: Intel: bdw_rt286: " Cezary Rojewski
2022-11-25 18:40 ` Cezary Rojewski [this message]
2022-11-25 18:40 ` [PATCH 03/11] ASoC: Intel: avs: nau8825: " Cezary Rojewski
2022-11-25 18:40 ` [PATCH 04/11] ASoC: Intel: avs: rt274: Refer to DAI name through a constant Cezary Rojewski
2022-11-25 18:40 ` [PATCH 05/11] ASoC: Intel: avs: rt274: Refactor jack handling Cezary Rojewski
2022-11-25 18:40 ` [PATCH 06/11] ASoC: Intel: avs: rt286: Add define for codec DAI name Cezary Rojewski
2022-11-25 18:40 ` [PATCH 07/11] ASoC: Intel: avs: rt286: Refactor jack handling Cezary Rojewski
2022-11-25 18:40 ` [PATCH 08/11] ASoC: Intel: avs: rt298: Add define for codec DAI name Cezary Rojewski
2022-11-25 18:40 ` [PATCH 09/11] ASoC: Intel: avs: rt298: Refactor jack handling Cezary Rojewski
2022-11-25 18:40 ` [PATCH 10/11] ASoC: Intel: avs: rt5682: Add define for codec DAI name Cezary Rojewski
2022-11-29 16:24   ` Mark Brown
2022-11-29 16:31     ` Amadeusz Sławiński
2022-11-25 18:40 ` [PATCH 11/11] ASoC: Intel: avs: rt5682: Refactor jack handling Cezary Rojewski
2022-11-29 16:57 ` [PATCH 00/11] ASoC: Intel: avs: " 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=20221125184032.2565979-3-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=hdegoede@redhat.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.