Commit 28baae9b authored by Amadeusz Sławiński's avatar Amadeusz Sławiński Committed by Mark Brown

ASoC: Intel: avs: rt298: Refactor jack handling

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: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: default avatarCezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20221125184032.2565979-10-cezary.rojewski@intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1fa675a0
...@@ -61,10 +61,9 @@ static struct snd_soc_jack_pin card_headset_pins[] = { ...@@ -61,10 +61,9 @@ static struct snd_soc_jack_pin card_headset_pins[] = {
static int avs_rt298_codec_init(struct snd_soc_pcm_runtime *runtime) static int avs_rt298_codec_init(struct snd_soc_pcm_runtime *runtime)
{ {
struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component; struct snd_soc_card *card = runtime->card;
struct snd_soc_jack_pin *pins; struct snd_soc_jack_pin *pins;
struct snd_soc_jack *jack; struct snd_soc_jack *jack;
struct snd_soc_card *card = runtime->card;
int num_pins, ret; int num_pins, ret;
jack = snd_soc_card_get_drvdata(card); jack = snd_soc_card_get_drvdata(card);
...@@ -79,9 +78,12 @@ static int avs_rt298_codec_init(struct snd_soc_pcm_runtime *runtime) ...@@ -79,9 +78,12 @@ static int avs_rt298_codec_init(struct snd_soc_pcm_runtime *runtime)
if (ret) if (ret)
return ret; return ret;
snd_soc_component_set_jack(component, jack, NULL); return snd_soc_component_set_jack(asoc_rtd_to_codec(runtime, 0)->component, jack, NULL);
}
return 0; static void avs_rt298_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_rt298_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pcm_hw_params *params) static int avs_rt298_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pcm_hw_params *params)
...@@ -163,6 +165,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in ...@@ -163,6 +165,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
else else
dl->dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS; dl->dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;
dl->init = avs_rt298_codec_init; dl->init = avs_rt298_codec_init;
dl->exit = avs_rt298_codec_exit;
dl->be_hw_params_fixup = avs_rt298_be_fixup; dl->be_hw_params_fixup = avs_rt298_be_fixup;
dl->ops = &avs_rt298_ops; dl->ops = &avs_rt298_ops;
dl->nonatomic = 1; dl->nonatomic = 1;
...@@ -207,30 +210,19 @@ static int avs_create_dapm_routes(struct device *dev, int ssp_port, ...@@ -207,30 +210,19 @@ static int avs_create_dapm_routes(struct device *dev, int ssp_port,
return 0; 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) 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, RT298_CODEC_DAI);
return snd_soc_component_set_jack(codec_dai->component, NULL, NULL);
} }
static int avs_card_resume_post(struct snd_soc_card *card) static int avs_card_resume_post(struct snd_soc_card *card)
{ {
struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, RT298_CODEC_DAI);
struct snd_soc_jack *jack = snd_soc_card_get_drvdata(card); 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_rt298_probe(struct platform_device *pdev) static int avs_rt298_probe(struct platform_device *pdev)
...@@ -268,7 +260,6 @@ static int avs_rt298_probe(struct platform_device *pdev) ...@@ -268,7 +260,6 @@ static int avs_rt298_probe(struct platform_device *pdev)
card->name = "avs_rt298"; card->name = "avs_rt298";
card->dev = dev; card->dev = dev;
card->owner = THIS_MODULE; card->owner = THIS_MODULE;
card->remove = avs_card_remove;
card->suspend_pre = avs_card_suspend_pre; card->suspend_pre = avs_card_suspend_pre;
card->resume_post = avs_card_resume_post; card->resume_post = avs_card_resume_post;
card->dai_link = dai_link; card->dai_link = dai_link;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment