ASoC: mediatek: mt8183-da7219: use SND_SOC_DAPM_PINCTRL
Subsystems (3)
cover ASoC: mediatek: mt8183-da7219: use SND_SOC_DAPM_PINCTRL
In previous discussion[1], Mark thinks we should have something general pinctrl integration with DAPM. SND_SOC_DAPM_PINCTRL is exactly what we want but I failed to find existing usage (maybe in topology files?).
To be equivalent to mt8183-da7219's original implementation, the 1st patch selects sleep-state at the beginning. The 2nd patch attaches the DAPM widget to playback stream. When the stream is about to start, the power on sequence selects the active-state. When the stream is about to stop, the power off sequence selects the sleep-state.
Note: the DAI links will connect to hdmi-codec, that's why the playback
stream name is "I2S Playback".
Note: this is a RFC series. If it makes sense, will also apply to
mt8183-mt6358.
[1]: https://patchwork.kernel.org/patch/11379735/
Tzung-Bi Shih (2):
ASoC: dapm: select sleep_state when initializing PINCTRL widget
ASoC: mediatek: mt8183-da7219: use SND_SOC_DAPM_PINCTRL in TDM out
.../mediatek/mt8183/mt8183-da7219-max98357.c | 98 ++----------------- sound/soc/soc-dapm.c | 3 + 2 files changed, 13 insertions(+), 88 deletions(-)
Signature · 1 line
2.25.0.265.gbab2e86ba0-goog
RFC PATCH 1/2 ASoC: dapm: select sleep_state when initializing PINCTRL widget
Selects sleep_state when initializing PINCTRL widget.
--- sound/soc/soc-dapm.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/soc-dapm.c +3 -0
@@ -3600,6 +3600,9 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, ret =PTR_ERR (w->pinctrl); goto request_failed; } + +/* set to sleep_state when initializing */ +dapm_pinctrl_event (w,NULL ,SND_SOC_DAPM_POST_PMD );break ;case snd_soc_dapm_clock_supply: w->clk =devm_clk_get (dapm->dev, w->name);
Signature · 1 line
2.25.0.265.gbab2e86ba0-goog
Mark Brown
maintainerApplied "ASoC: dapm: select sleep_state when initializing PINCTRL widget" to the asoc tree
The patch
ASoC: dapm: select sleep_state when initializing PINCTRL widget
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
From ec06dc15c358d3f41e9fd05872d772ed0f9fa32a Mon Sep 17 00:00:00 2001
From: Tzung-Bi Shih <[email protected]>
Date: Wed, 19 Feb 2020 17:38:38 +0800
Subject: [PATCH] ASoC: dapm: select sleep_state when initializing PINCTRL
widget
Selects sleep_state when initializing PINCTRL widget.
--- sound/soc/soc-dapm.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/soc-dapm.c +3 -0
@@ -3628,6 +3628,9 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, ret =PTR_ERR (w->pinctrl); goto request_failed; } + +/* set to sleep_state when initializing */ +dapm_pinctrl_event (w,NULL ,SND_SOC_DAPM_POST_PMD );break ;case snd_soc_dapm_clock_supply: w->clk =devm_clk_get (dapm->dev, w->name);
Signature · 1 line
2.20.1
RFC PATCH 2/2 ASoC: mediatek: mt8183-da7219: use SND_SOC_DAPM_PINCTRL in TDM out
In reply to Tzung-Bi ShihUses SND_SOC_DAPM_PINCTRL in TDM out to simplify code.
--- .../mediatek/mt8183/mt8183-da7219-max98357.c | 98 ++----------------- 1 file changed, 10 insertions(+), 88 deletions(-)
sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +10 -88
@@ -16,20 +16,7 @@#include "../../codecs/da7219-aad.h" #include "../../codecs/da7219.h" -enum PINCTRL_PIN_STATE { -PIN_STATE_DEFAULT =0 , -PIN_TDM_OUT_ON , -PIN_TDM_OUT_OFF , -PIN_STATE_MAX -}; - -static const char *const mt8183_pin_str[PIN_STATE_MAX ] = { -"default" ,"aud_tdm_out_on" ,"aud_tdm_out_off" , -}; -struct mt8183_da7219_max98357_priv { -struct pinctrl *pinctrl; -struct pinctrl_state *pin_states[PIN_STATE_MAX ];struct snd_soc_jack headset_jack; };
@@ -259,47 +246,6 @@ SND_SOC_DAILINK_DEFS(tdm,DAILINK_COMP_ARRAY (COMP_DUMMY ()), DAILINK_COMP_ARRAY(COMP_EMPTY())); -static int mt8183_da7219_tdm_startup (struct snd_pcm_substream *substream) -{ -struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct mt8183_da7219_max98357_priv *priv = -snd_soc_card_get_drvdata (rtd->card); -int ret; - -if (IS_ERR (priv->pin_states[PIN_TDM_OUT_ON ])) -return PTR_ERR (priv->pin_states[PIN_TDM_OUT_ON ]); - - ret =pinctrl_select_state (priv->pinctrl, - priv->pin_states[PIN_TDM_OUT_ON ]); -if (ret) -dev_err (rtd->card->dev,"%s failed to select state %d\n" , - __func__, ret); - -return ret; -} - -static void mt8183_da7219_tdm_shutdown (struct snd_pcm_substream *substream) -{ -struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct mt8183_da7219_max98357_priv *priv = -snd_soc_card_get_drvdata (rtd->card); -int ret; - -if (IS_ERR (priv->pin_states[PIN_TDM_OUT_OFF ])) -return ; - - ret =pinctrl_select_state (priv->pinctrl, - priv->pin_states[PIN_TDM_OUT_OFF ]); -if (ret) -dev_err (rtd->card->dev,"%s failed to select state %d\n" , - __func__, ret); -} - -static struct snd_soc_ops mt8183_da7219_tdm_ops = { - .startup = mt8183_da7219_tdm_startup, - .shutdown = mt8183_da7219_tdm_shutdown, -}; -static struct snd_soc_dai_link mt8183_da7219_max98357_dai_links[] = {/* FE */ {
@@ -455,7 +401,6 @@ static struct snd_soc_dai_link mt8183_da7219_max98357_dai_links[] = { .dpcm_playback = 1, .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, - .ops = &mt8183_da7219_tdm_ops, SND_SOC_DAILINK_REG(tdm), }, };
@@ -482,10 +427,13 @@ static const struct snd_kcontrol_new mt8183_da7219_max98357_snd_controls[] = {static const struct snd_soc_dapm_widget mt8183_da7219_max98357_dapm_widgets[] = {SND_SOC_DAPM_SPK ("Speakers" ,NULL ), +SND_SOC_DAPM_PINCTRL ("TDM_OUT_PINCTRL" , +"aud_tdm_out_on" ,"aud_tdm_out_off" ), };static const struct snd_soc_dapm_route mt8183_da7219_max98357_dapm_routes[] = { {"Speakers" ,NULL ,"Speaker" }, + {"I2S Playback" ,NULL ,"TDM_OUT_PINCTRL" }, };static struct snd_soc_card mt8183_da7219_max98357_card = {
@@ -534,6 +482,7 @@ static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev)struct device_node *platform_node;struct snd_soc_dai_link *dai_link;struct mt8183_da7219_max98357_priv *priv; +struct pinctrl *pinctrl;int ret, i; card->dev = &pdev->dev;
@@ -566,39 +515,12 @@ static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev)snd_soc_card_set_drvdata (card, priv); - priv->pinctrl =devm_pinctrl_get (&pdev->dev); -if (IS_ERR (priv->pinctrl)) { -dev_err (&pdev->dev,"%s devm_pinctrl_get failed\n" , - __func__); -return PTR_ERR (priv->pinctrl); - } - -for (i =0 ; i <PIN_STATE_MAX ; i++) { - priv->pin_states[i] =pinctrl_lookup_state (priv->pinctrl, - mt8183_pin_str[i]); -if (IS_ERR (priv->pin_states[i])) { - ret =PTR_ERR (priv->pin_states[i]); -dev_info (&pdev->dev,"%s Can't find pin state %s %d\n" , - __func__, mt8183_pin_str[i], ret); - } - } - -if (!IS_ERR (priv->pin_states[PIN_TDM_OUT_OFF ])) { - ret =pinctrl_select_state (priv->pinctrl, - priv->pin_states[PIN_TDM_OUT_OFF ]); -if (ret) -dev_info (&pdev->dev, -"%s failed to select state %d\n" , - __func__, ret); - } - -if (!IS_ERR (priv->pin_states[PIN_STATE_DEFAULT ])) { - ret =pinctrl_select_state (priv->pinctrl, - priv->pin_states[PIN_STATE_DEFAULT ]); -if (ret) -dev_info (&pdev->dev, -"%s failed to select state %d\n" , - __func__, ret); + pinctrl =devm_pinctrl_get_select (&pdev->dev,PINCTRL_STATE_DEFAULT ); +if (IS_ERR (pinctrl)) { + ret =PTR_ERR (pinctrl); +dev_err (&pdev->dev,"%s failed to select default state %d\n" , + __func__, ret); +return ret; }return devm_snd_soc_register_card (&pdev->dev, card);
Signature · 1 line
2.25.0.265.gbab2e86ba0-goog
Mark Brown
maintainerApplied "ASoC: mediatek: mt8183-da7219: use SND_SOC_DAPM_PINCTRL in TDM out" to the asoc tree
The patch
ASoC: mediatek: mt8183-da7219: use SND_SOC_DAPM_PINCTRL in TDM out
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
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
From c77b8317ee3ab43634421afb73fdb1ea253d3d47 Mon Sep 17 00:00:00 2001
From: Tzung-Bi Shih <[email protected]>
Date: Wed, 19 Feb 2020 17:38:39 +0800
Subject: [PATCH] ASoC: mediatek: mt8183-da7219: use SND_SOC_DAPM_PINCTRL in
TDM out
Uses SND_SOC_DAPM_PINCTRL in TDM out to simplify code.
--- .../mediatek/mt8183/mt8183-da7219-max98357.c | 98 ++----------------- 1 file changed, 10 insertions(+), 88 deletions(-)
sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +10 -88
@@ -16,20 +16,7 @@#include "../../codecs/da7219-aad.h" #include "../../codecs/da7219.h" -enum PINCTRL_PIN_STATE { -PIN_STATE_DEFAULT =0 , -PIN_TDM_OUT_ON , -PIN_TDM_OUT_OFF , -PIN_STATE_MAX -}; - -static const char *const mt8183_pin_str[PIN_STATE_MAX ] = { -"default" ,"aud_tdm_out_on" ,"aud_tdm_out_off" , -}; -struct mt8183_da7219_max98357_priv { -struct pinctrl *pinctrl; -struct pinctrl_state *pin_states[PIN_STATE_MAX ];struct snd_soc_jack headset_jack; };
@@ -259,47 +246,6 @@ SND_SOC_DAILINK_DEFS(tdm,DAILINK_COMP_ARRAY (COMP_DUMMY ()), DAILINK_COMP_ARRAY(COMP_EMPTY())); -static int mt8183_da7219_tdm_startup (struct snd_pcm_substream *substream) -{ -struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct mt8183_da7219_max98357_priv *priv = -snd_soc_card_get_drvdata (rtd->card); -int ret; - -if (IS_ERR (priv->pin_states[PIN_TDM_OUT_ON ])) -return PTR_ERR (priv->pin_states[PIN_TDM_OUT_ON ]); - - ret =pinctrl_select_state (priv->pinctrl, - priv->pin_states[PIN_TDM_OUT_ON ]); -if (ret) -dev_err (rtd->card->dev,"%s failed to select state %d\n" , - __func__, ret); - -return ret; -} - -static void mt8183_da7219_tdm_shutdown (struct snd_pcm_substream *substream) -{ -struct snd_soc_pcm_runtime *rtd = substream->private_data; -struct mt8183_da7219_max98357_priv *priv = -snd_soc_card_get_drvdata (rtd->card); -int ret; - -if (IS_ERR (priv->pin_states[PIN_TDM_OUT_OFF ])) -return ; - - ret =pinctrl_select_state (priv->pinctrl, - priv->pin_states[PIN_TDM_OUT_OFF ]); -if (ret) -dev_err (rtd->card->dev,"%s failed to select state %d\n" , - __func__, ret); -} - -static struct snd_soc_ops mt8183_da7219_tdm_ops = { - .startup = mt8183_da7219_tdm_startup, - .shutdown = mt8183_da7219_tdm_shutdown, -}; -static struct snd_soc_dai_link mt8183_da7219_max98357_dai_links[] = {/* FE */ {
@@ -455,7 +401,6 @@ static struct snd_soc_dai_link mt8183_da7219_max98357_dai_links[] = { .dpcm_playback = 1, .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, - .ops = &mt8183_da7219_tdm_ops, SND_SOC_DAILINK_REG(tdm), }, };
@@ -482,10 +427,13 @@ static const struct snd_kcontrol_new mt8183_da7219_max98357_snd_controls[] = {static const struct snd_soc_dapm_widget mt8183_da7219_max98357_dapm_widgets[] = {SND_SOC_DAPM_SPK ("Speakers" ,NULL ), +SND_SOC_DAPM_PINCTRL ("TDM_OUT_PINCTRL" , +"aud_tdm_out_on" ,"aud_tdm_out_off" ), };static const struct snd_soc_dapm_route mt8183_da7219_max98357_dapm_routes[] = { {"Speakers" ,NULL ,"Speaker" }, + {"I2S Playback" ,NULL ,"TDM_OUT_PINCTRL" }, };static struct snd_soc_card mt8183_da7219_max98357_card = {
@@ -534,6 +482,7 @@ static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev)struct device_node *platform_node;struct snd_soc_dai_link *dai_link;struct mt8183_da7219_max98357_priv *priv; +struct pinctrl *pinctrl;int ret, i; card->dev = &pdev->dev;
@@ -566,39 +515,12 @@ static int mt8183_da7219_max98357_dev_probe(struct platform_device *pdev)snd_soc_card_set_drvdata (card, priv); - priv->pinctrl =devm_pinctrl_get (&pdev->dev); -if (IS_ERR (priv->pinctrl)) { -dev_err (&pdev->dev,"%s devm_pinctrl_get failed\n" , - __func__); -return PTR_ERR (priv->pinctrl); - } - -for (i =0 ; i <PIN_STATE_MAX ; i++) { - priv->pin_states[i] =pinctrl_lookup_state (priv->pinctrl, - mt8183_pin_str[i]); -if (IS_ERR (priv->pin_states[i])) { - ret =PTR_ERR (priv->pin_states[i]); -dev_info (&pdev->dev,"%s Can't find pin state %s %d\n" , - __func__, mt8183_pin_str[i], ret); - } - } - -if (!IS_ERR (priv->pin_states[PIN_TDM_OUT_OFF ])) { - ret =pinctrl_select_state (priv->pinctrl, - priv->pin_states[PIN_TDM_OUT_OFF ]); -if (ret) -dev_info (&pdev->dev, -"%s failed to select state %d\n" , - __func__, ret); - } - -if (!IS_ERR (priv->pin_states[PIN_STATE_DEFAULT ])) { - ret =pinctrl_select_state (priv->pinctrl, - priv->pin_states[PIN_STATE_DEFAULT ]); -if (ret) -dev_info (&pdev->dev, -"%s failed to select state %d\n" , - __func__, ret); + pinctrl =devm_pinctrl_get_select (&pdev->dev,PINCTRL_STATE_DEFAULT ); +if (IS_ERR (pinctrl)) { + ret =PTR_ERR (pinctrl); +dev_err (&pdev->dev,"%s failed to select default state %d\n" , + __func__, ret); +return ret; }return devm_snd_soc_register_card (&pdev->dev, card);
Signature · 1 line
2.20.1