[PATCH 00/11] ASoC: Intel: avs: Refactor jack handling
For all the boards included in this patchset, a similar set of changes is proposed:
1) Move jack unassignment from platform_device->remove() to dai_link->exit(). This is done to make jack init and deinit flows symmetric 2) Remove platform_device->remove() function 3) Simplify card->suspend_pre() and card->resume_post() by making use of snd_soc_card_get_codec_dai() helper
While bdw_rt286 board - which is utilized by the catpt-driver - is definitely not part of "avs", same treatment applies. And thus decided to make it part of this series instead of sending it separately.
Amadeusz Sławiński (10): ASoC: Intel: avs: da7219: Refactor jack handling ASoC: Intel: avs: nau8825: Refactor jack handling ASoC: Intel: avs: rt274: Refer to DAI name through a constant ASoC: Intel: avs: rt274: Refactor jack handling ASoC: Intel: avs: rt286: Add define for codec DAI name ASoC: Intel: avs: rt286: Refactor jack handling ASoC: Intel: avs: rt298: Add define for codec DAI name ASoC: Intel: avs: rt298: Refactor jack handling ASoC: Intel: avs: rt5682: Add define for codec DAI name ASoC: Intel: avs: rt5682: Refactor jack handling
Cezary Rojewski (1): ASoC: Intel: bdw_rt286: Refactor jack handling
sound/soc/intel/avs/boards/da7219.c | 34 +++++++---------- sound/soc/intel/avs/boards/nau8825.c | 35 ++++++------------ sound/soc/intel/avs/boards/rt274.c | 30 ++++++--------- sound/soc/intel/avs/boards/rt286.c | 37 ++++++++----------- sound/soc/intel/avs/boards/rt298.c | 37 ++++++++----------- sound/soc/intel/avs/boards/rt5682.c | 31 +++++++--------- sound/soc/intel/boards/bdw_rt286.c | 55 ++++++++-------------------- 7 files changed, 95 insertions(+), 164 deletions(-)
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: Cezary Rojewski cezary.rojewski@intel.com --- sound/soc/intel/boards/bdw_rt286.c | 55 +++++++++--------------------- 1 file changed, 16 insertions(+), 39 deletions(-)
diff --git a/sound/soc/intel/boards/bdw_rt286.c b/sound/soc/intel/boards/bdw_rt286.c index 6b76df0e7c9b..b7687a93a923 100644 --- a/sound/soc/intel/boards/bdw_rt286.c +++ b/sound/soc/intel/boards/bdw_rt286.c @@ -73,6 +73,13 @@ static int codec_link_init(struct snd_soc_pcm_runtime *rtd) return snd_soc_component_set_jack(codec, &card_headset, NULL); }
+static void codec_link_exit(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_component *codec = asoc_rtd_to_codec(rtd, 0)->component; + + snd_soc_component_set_jack(codec, NULL, NULL); +} + static int codec_link_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { @@ -165,6 +172,7 @@ static struct snd_soc_dai_link card_dai_links[] = { .nonatomic = 1, .no_pcm = 1, .init = codec_link_init, + .exit = codec_link_exit, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC, .ignore_pmdown_time = 1, .be_hw_params_fixup = codec_link_hw_params_fixup, @@ -175,43 +183,24 @@ static struct snd_soc_dai_link card_dai_links[] = { }, };
-static void bdw_rt286_disable_jack(struct snd_soc_card *card) -{ - struct snd_soc_component *component; - - for_each_card_components(card, component) { - if (!strcmp(component->name, "i2c-INT343A:00")) { - dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); - snd_soc_component_set_jack(component, NULL, NULL); - break; - } - } -} - -static int bdw_rt286_suspend(struct snd_soc_card *card) +static int card_suspend_pre(struct snd_soc_card *card) { - bdw_rt286_disable_jack(card); + struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, "rt286-aif1");
- return 0; + return snd_soc_component_set_jack(codec_dai->component, NULL, NULL); }
-static int bdw_rt286_resume(struct snd_soc_card *card) +static int card_resume_post(struct snd_soc_card *card) { - struct snd_soc_component *component; - - for_each_card_components(card, component) { - if (!strcmp(component->name, "i2c-INT343A:00")) { - dev_dbg(component->dev, "enabling jack detect for resume.\n"); - snd_soc_component_set_jack(component, &card_headset, NULL); - break; - } - } + struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, "rt286-aif1");
- return 0; + return snd_soc_component_set_jack(codec_dai->component, &card_headset, NULL); }
static struct snd_soc_card bdw_rt286_card = { .owner = THIS_MODULE, + .suspend_pre = card_suspend_pre, + .resume_post = card_resume_post, .dai_link = card_dai_links, .num_links = ARRAY_SIZE(card_dai_links), .controls = card_controls, @@ -221,8 +210,6 @@ static struct snd_soc_card bdw_rt286_card = { .dapm_routes = card_routes, .num_dapm_routes = ARRAY_SIZE(card_routes), .fully_routed = true, - .suspend_pre = bdw_rt286_suspend, - .resume_post = bdw_rt286_resume, };
/* Use space before codec name to simplify card ID, and simplify driver name. */ @@ -254,18 +241,8 @@ static int bdw_rt286_probe(struct platform_device *pdev) return devm_snd_soc_register_card(dev, &bdw_rt286_card); }
-static int bdw_rt286_remove(struct platform_device *pdev) -{ - struct snd_soc_card *card = platform_get_drvdata(pdev); - - bdw_rt286_disable_jack(card); - - return 0; -} - static struct platform_driver bdw_rt286_driver = { .probe = bdw_rt286_probe, - .remove = bdw_rt286_remove, .driver = { .name = "bdw_rt286", .pm = &snd_soc_pm_ops
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;
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/nau8825.c | 35 +++++++++------------------- 1 file changed, 11 insertions(+), 24 deletions(-)
diff --git a/sound/soc/intel/avs/boards/nau8825.c b/sound/soc/intel/avs/boards/nau8825.c index f76909e9f990..6731d8a49076 100644 --- a/sound/soc/intel/avs/boards/nau8825.c +++ b/sound/soc/intel/avs/boards/nau8825.c @@ -79,11 +79,9 @@ static struct snd_soc_jack_pin card_headset_pins[] = {
static int avs_nau8825_codec_init(struct snd_soc_pcm_runtime *runtime) { - 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_pin *pins; struct snd_soc_jack *jack; - struct snd_soc_card *card = runtime->card; int num_pins, ret;
jack = snd_soc_card_get_drvdata(card); @@ -108,11 +106,12 @@ static int avs_nau8825_codec_init(struct snd_soc_pcm_runtime *runtime) snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
- //snd_soc_component_set_jack(component, jack, NULL); - // TODO: Fix nau8825 codec to use .set_jack, like everyone else - nau8825_enable_jack_detect(component, jack); + return snd_soc_component_set_jack(asoc_rtd_to_codec(runtime, 0)->component, jack, NULL); +}
- return 0; +static void avs_nau8825_codec_exit(struct snd_soc_pcm_runtime *rtd) +{ + snd_soc_component_set_jack(asoc_rtd_to_codec(rtd, 0)->component, NULL, NULL); }
static int @@ -203,6 +202,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_nau8825_codec_init; + dl->exit = avs_nau8825_codec_exit; dl->be_hw_params_fixup = avs_nau8825_be_fixup; dl->ops = &avs_nau8825_ops; dl->nonatomic = 1; @@ -247,23 +247,11 @@ 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, SKL_NUVOTON_CODEC_DAI); + + return snd_soc_component_set_jack(codec_dai->component, NULL, NULL); }
static int avs_card_resume_post(struct snd_soc_card *card) @@ -280,7 +268,7 @@ static int avs_card_resume_post(struct snd_soc_card *card) codec_dai->playback_widget->active) snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_FLL_FS, 0, SND_SOC_CLOCK_IN);
- return avs_card_set_jack(card, jack); + return snd_soc_component_set_jack(codec_dai->component, jack, NULL); }
static int avs_nau8825_probe(struct platform_device *pdev) @@ -318,7 +306,6 @@ static int avs_nau8825_probe(struct platform_device *pdev) card->name = "avs_nau8825"; 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;
From: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com
There is existing define for codec DAI name, make use of it when setting codec DAI name.
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/rt274.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/rt274.c b/sound/soc/intel/avs/boards/rt274.c index afef5a3ca60b..9937cfe9996e 100644 --- a/sound/soc/intel/avs/boards/rt274.c +++ b/sound/soc/intel/avs/boards/rt274.c @@ -160,7 +160,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT34C2:00"); - dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, "rt274-aif1"); + dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, RT274_CODEC_DAI); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) return -ENOMEM;
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/rt274.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
diff --git a/sound/soc/intel/avs/boards/rt274.c b/sound/soc/intel/avs/boards/rt274.c index 9937cfe9996e..6a1e121f082f 100644 --- a/sound/soc/intel/avs/boards/rt274.c +++ b/sound/soc/intel/avs/boards/rt274.c @@ -119,6 +119,11 @@ static int avs_rt274_codec_init(struct snd_soc_pcm_runtime *runtime) return 0; }
+static void avs_rt274_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_rt274_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pcm_hw_params *params) { struct snd_interval *rate, *channels; @@ -171,6 +176,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in dl->id = 0; dl->dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS; dl->init = avs_rt274_codec_init; + dl->exit = avs_rt274_codec_exit; dl->be_hw_params_fixup = avs_rt274_be_fixup; dl->nonatomic = 1; dl->no_pcm = 1; @@ -214,30 +220,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, RT274_CODEC_DAI); + + 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, RT274_CODEC_DAI); 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_rt274_probe(struct platform_device *pdev) @@ -275,7 +270,6 @@ static int avs_rt274_probe(struct platform_device *pdev) card->name = "avs_rt274"; 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;
From: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com
Following commits will make use of it to find codec DAI, define it first.
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/rt286.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/rt286.c b/sound/soc/intel/avs/boards/rt286.c index e51d4e181274..7868a2d10cac 100644 --- a/sound/soc/intel/avs/boards/rt286.c +++ b/sound/soc/intel/avs/boards/rt286.c @@ -14,6 +14,8 @@ #include <sound/soc-acpi.h> #include "../../../codecs/rt286.h"
+#define RT286_CODEC_DAI "rt286-aif1" + static const struct snd_kcontrol_new card_controls[] = { SOC_DAPM_PIN_SWITCH("Headphone Jack"), SOC_DAPM_PIN_SWITCH("Mic Jack"), @@ -130,7 +132,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343A:00"); - dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, "rt286-aif1"); + dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, RT286_CODEC_DAI); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) return -ENOMEM;
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/rt286.c | 33 +++++++++++------------------- 1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/sound/soc/intel/avs/boards/rt286.c b/sound/soc/intel/avs/boards/rt286.c index 7868a2d10cac..8447b37a2a41 100644 --- a/sound/soc/intel/avs/boards/rt286.c +++ b/sound/soc/intel/avs/boards/rt286.c @@ -50,10 +50,9 @@ static struct snd_soc_jack_pin card_headset_pins[] = {
static int avs_rt286_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 *jack; - struct snd_soc_card *card = runtime->card; int num_pins, ret;
jack = snd_soc_card_get_drvdata(card); @@ -68,9 +67,12 @@ static int avs_rt286_codec_init(struct snd_soc_pcm_runtime *runtime) if (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_rt286_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_rt286_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pcm_hw_params *params) @@ -143,6 +145,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_rt286_codec_init; + dl->exit = avs_rt286_codec_exit; dl->be_hw_params_fixup = avs_rt286_be_fixup; dl->ops = &avs_rt286_ops; dl->nonatomic = 1; @@ -187,30 +190,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, RT286_CODEC_DAI); + + 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, RT286_CODEC_DAI); 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_rt286_probe(struct platform_device *pdev) @@ -248,7 +240,6 @@ static int avs_rt286_probe(struct platform_device *pdev) card->name = "avs_rt286"; 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;
From: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com
Following commits will make use of it to find codec DAI, define it first.
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/rt298.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/rt298.c b/sound/soc/intel/avs/boards/rt298.c index 58c9d9edecf0..5570949bad8a 100644 --- a/sound/soc/intel/avs/boards/rt298.c +++ b/sound/soc/intel/avs/boards/rt298.c @@ -15,6 +15,8 @@ #include <sound/soc-acpi.h> #include "../../../codecs/rt298.h"
+#define RT298_CODEC_DAI "rt298-aif1" + static const struct dmi_system_id kblr_dmi_table[] = { { .matches = { @@ -147,7 +149,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343A:00"); - dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, "rt298-aif1"); + dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, RT298_CODEC_DAI); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) return -ENOMEM;
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/rt298.c | 33 +++++++++++------------------- 1 file changed, 12 insertions(+), 21 deletions(-)
diff --git a/sound/soc/intel/avs/boards/rt298.c b/sound/soc/intel/avs/boards/rt298.c index 5570949bad8a..bd25f0fde35e 100644 --- a/sound/soc/intel/avs/boards/rt298.c +++ b/sound/soc/intel/avs/boards/rt298.c @@ -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) { - 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 *jack; - struct snd_soc_card *card = runtime->card; int num_pins, ret;
jack = snd_soc_card_get_drvdata(card); @@ -79,9 +78,12 @@ static int avs_rt298_codec_init(struct snd_soc_pcm_runtime *runtime) if (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) @@ -163,6 +165,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in else 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->exit = avs_rt298_codec_exit; dl->be_hw_params_fixup = avs_rt298_be_fixup; dl->ops = &avs_rt298_ops; dl->nonatomic = 1; @@ -207,30 +210,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, 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) { + 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);
- 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) @@ -268,7 +260,6 @@ static int avs_rt298_probe(struct platform_device *pdev) card->name = "avs_rt298"; 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;
From: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com
Following commits will make use of it to find codec DAI, define it first.
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/rt5682.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/soc/intel/avs/boards/rt5682.c b/sound/soc/intel/avs/boards/rt5682.c index 01f9b9f0c12b..7f9edf4cbd04 100644 --- a/sound/soc/intel/avs/boards/rt5682.c +++ b/sound/soc/intel/avs/boards/rt5682.c @@ -26,6 +26,7 @@ #define AVS_RT5682_SSP_CODEC_MASK (GENMASK(2, 0)) #define AVS_RT5682_MCLK_EN BIT(3) #define AVS_RT5682_MCLK_24MHZ BIT(4) +#define AVS_RT5682_CODEC_DAI_NAME "rt5682-aif1"
/* Default: MCLK on, MCLK 19.2M, SSP0 */ static unsigned long avs_rt5682_quirk = AVS_RT5682_MCLK_EN | AVS_RT5682_SSP_CODEC(0); @@ -184,7 +185,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port); dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-10EC5682:00"); - dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, "rt5682-aif1"); + dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, AVS_RT5682_CODEC_DAI_NAME); if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name) return -ENOMEM;
@@ -194,6 +195,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in dl->num_platforms = 1; dl->id = 0; dl->init = avs_rt5682_codec_init; + dl->exit = avs_rt5682_codec_exit; dl->ops = &avs_rt5682_ops; dl->nonatomic = 1; dl->no_pcm = 1;
On Fri, Nov 25, 2022 at 07:40:31PM +0100, Cezary Rojewski wrote:
From: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com
Following commits will make use of it to find codec DAI, define it first.
This breaks an x86 allmodconfig build:
/build/stage/linux/sound/soc/intel/avs/boards/rt5682.c: In function ‘avs_create_dai_link’: /build/stage/linux/sound/soc/intel/avs/boards/rt5682.c:198:20: error: ‘avs_rt5682_codec_exit’ undeclared (first use in this function); did you mean ‘avs_rt5682_codec_init’? 198 | dl->exit = avs_rt5682_codec_exit; | ^~~~~~~~~~~~~~~~~~~~~ | avs_rt5682_codec_init
and looks out of place in this commit, it at least deserves calling out in the commit log?
On 11/29/2022 5:24 PM, Mark Brown wrote:
On Fri, Nov 25, 2022 at 07:40:31PM +0100, Cezary Rojewski wrote:
From: Amadeusz Sławiński amadeuszx.slawinski@linux.intel.com
Following commits will make use of it to find codec DAI, define it first.
This breaks an x86 allmodconfig build:
/build/stage/linux/sound/soc/intel/avs/boards/rt5682.c: In function ‘avs_create_dai_link’: /build/stage/linux/sound/soc/intel/avs/boards/rt5682.c:198:20: error: ‘avs_rt5682_codec_exit’ undeclared (first use in this function); did you mean ‘avs_rt5682_codec_init’? 198 | dl->exit = avs_rt5682_codec_exit; | ^~~~~~~~~~~~~~~~~~~~~ | avs_rt5682_codec_init
and looks out of place in this commit, it at least deserves calling out in the commit log?
Oops.. that seems like patch split gone wrong, it is added in following commit. Other patches add dl->exit in the "second" patch, so this chunk should be part of patch 11, instead of this one.
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/rt5682.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/sound/soc/intel/avs/boards/rt5682.c b/sound/soc/intel/avs/boards/rt5682.c index 7f9edf4cbd04..473e9fe5d0bf 100644 --- a/sound/soc/intel/avs/boards/rt5682.c +++ b/sound/soc/intel/avs/boards/rt5682.c @@ -120,6 +120,11 @@ static int avs_rt5682_codec_init(struct snd_soc_pcm_runtime *runtime) return 0; };
+static void avs_rt5682_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_rt5682_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -239,30 +244,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, AVS_RT5682_CODEC_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, AVS_RT5682_CODEC_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_rt5682_probe(struct platform_device *pdev) @@ -306,7 +300,6 @@ static int avs_rt5682_probe(struct platform_device *pdev) card->name = "avs_rt5682"; 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;
On Fri, 25 Nov 2022 19:40:21 +0100, Cezary Rojewski wrote:
For all the boards included in this patchset, a similar set of changes is proposed:
- Move jack unassignment from platform_device->remove() to dai_link->exit(). This is done to make jack init and deinit flows symmetric
- Remove platform_device->remove() function
- Simplify card->suspend_pre() and card->resume_post() by making use of snd_soc_card_get_codec_dai() helper
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/11] ASoC: Intel: bdw_rt286: Refactor jack handling commit: d60a197e50eca5017076b3867c1a49cb5118d597 [02/11] ASoC: Intel: avs: da7219: Refactor jack handling commit: 833e250ef592c3c02dda400c1c44306f74241d33 [03/11] ASoC: Intel: avs: nau8825: Refactor jack handling commit: 9febcd7a0180b1ea5b49cda1838aef49ef936805 [04/11] ASoC: Intel: avs: rt274: Refer to DAI name through a constant commit: 58391e7ca04be3960579a51d9a47d0fbc1b1607e [05/11] ASoC: Intel: avs: rt274: Refactor jack handling commit: a08797afc1f9792b16356f59ba047114dd06a25e [06/11] ASoC: Intel: avs: rt286: Add define for codec DAI name commit: af8ced412d6ee680faca06700fa784bbef6de702 [07/11] ASoC: Intel: avs: rt286: Refactor jack handling commit: 2f292443b4c88ccd469e724d022c669349abcbb5 [08/11] ASoC: Intel: avs: rt298: Add define for codec DAI name commit: 1fa675a00a5028f4f49bd19eaab016ea2d765ba8 [09/11] ASoC: Intel: avs: rt298: Refactor jack handling commit: 28baae9bfc1fb9fdaff2e8bd328b2a5b12a14273 [10/11] ASoC: Intel: avs: rt5682: Add define for codec DAI name (no commit info) [11/11] ASoC: Intel: avs: rt5682: Refactor jack handling (no commit info)
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
participants (3)
-
Amadeusz Sławiński
-
Cezary Rojewski
-
Mark Brown