ASoC: Intel: avs: rt5682: Refactor jack handling
Subsystems (3)
Cezary Rojewski
maintainerv2 cover ASoC: Intel: avs: rt5682: Refactor jack handling
Leftover from recent series [1].
Following changes are proposed for the rt5682 sound card driver:
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
Changes in v2:
- fixed compilation of the first patch in the series by moving offending pieces to the second patch
[1]: https://lore.kernel.org/alsa-devel/[email protected]/
Amadeusz Sławiński (2):
ASoC: Intel: avs: rt5682: Add define for codec DAI name
ASoC: Intel: avs: rt5682: Refactor jack handling
sound/soc/intel/avs/boards/rt5682.c | 31 ++++++++++++----------------- 1 file changed, 13 insertions(+), 18 deletions(-)
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 1/2 ASoC: Intel: avs: rt5682: Add define for codec DAI name
From: Amadeusz Sławiński <[email protected]>
Following commits will make use of it to find codec DAI, define it first.
--- sound/soc/intel/avs/boards/rt5682.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/intel/avs/boards/rt5682.c +2 -1
@@ -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 ;
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH v2 2/2 ASoC: Intel: avs: rt5682: Refactor jack handling
In reply to Cezary RojewskiFrom: Amadeusz Sławiński <[email protected]>
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.
--- sound/soc/intel/avs/boards/rt5682.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
sound/soc/intel/avs/boards/rt5682.c +11 -17
@@ -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) {
@@ -195,6 +200,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 ;
@@ -238,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)
@@ -305,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;
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 11 lines · Cezary Rojewski
Leftover from recent series [1].
Following changes are proposed for the rt5682 sound card driver:1) Move jack unassignment from
platform_device->remove()todai_link->exit(). This is done to make jack init and deinit flows symmetric
2) Removeplatform_device->remove()function
3) Simplifycard->suspend_pre()andcard->resume_post()by making use ofsnd_soc_card_get_codec_dai()helper[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: Intel: avs: rt5682: Add define for codec DAI name
commit: 19bb7c3053ee54fd7fa7635f680fba3969f4a026
[2/2] ASoC: Intel: avs: rt5682: Refactor jack handling
commit: 93d519a12a83baa19dae59d121439b04fb9dfdedAll 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