From 895f5ac044f3beceaa57497ee2be54e12ed4eda2 Mon Sep 17 00:00:00 2001 From: "qing.zhang" Date: Fri, 28 Mar 2025 11:01:51 +0800 Subject: [PATCH] Regression: suspend twice with internal codec [1/1] PD#SWPL-207769 Problem: 1. pm soc and pm use the same time 2. base:https://scgit.amlogic.com/#/c/501712 Solution: 1. keep the pm soc use for codecs 2. remove cache sync when save in user setting Verify: t5m Change-Id: Iea9ad5ea0f295e06966190f112e353517986b499 Signed-off-by: qing.zhang (cherry picked from commit 12be0fd24f49ebedae9bcfd3be06f49d9c6b21ee) --- sound/soc/amlogic/auge/card.c | 40 ++++--------------- sound/soc/codecs/amlogic/ad82128.c | 18 --------- .../soc/codecs/amlogic/aml_codec_a1_acodec.c | 24 +++++++++++ .../soc/codecs/amlogic/aml_codec_t6d_acodec.c | 3 +- sound/soc/codecs/amlogic/aml_codec_t9015.c | 3 -- .../soc/codecs/amlogic/aml_codec_tl1_acodec.c | 28 ++----------- sound/soc/codecs/amlogic/tas5707.c | 18 --------- sound/soc/codecs/amlogic/tas5805.c | 18 --------- 8 files changed, 36 insertions(+), 116 deletions(-) diff --git a/sound/soc/amlogic/auge/card.c b/sound/soc/amlogic/auge/card.c index beb632b70..154dfa286 100644 --- a/sound/soc/amlogic/auge/card.c +++ b/sound/soc/amlogic/auge/card.c @@ -1131,6 +1131,7 @@ static int aml_card_parse_gpios(struct device_node *node, struct snd_soc_card *soc_card = &priv->snd_card; enum of_gpio_flags flags; int gpio; + int state; bool active_low; unsigned int sleep_time = 500; unsigned int spk_mute_sleep_time = 200; @@ -1191,6 +1192,13 @@ static int aml_card_parse_gpios(struct device_node *node, "high" : "low"); } } + if (gpio_is_valid(priv->hp_jack.gpio.gpio)) { + gpio_direction_input(priv->hp_jack.gpio.gpio); + state = gpiod_set_pull(gpio_to_desc(priv->hp_jack.gpio.gpio), + GPIOD_PULL_DIS); + if (state) + pr_err("set hp_jack gpiod pull failed, ret %d\n", state); + } return 0; } @@ -1649,42 +1657,10 @@ static void aml_card_platform_shutdown(struct platform_device *pdev) } } -#ifdef CONFIG_HIBERNATION -static int aml_card_platform_restore(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct snd_soc_card *card = platform_get_drvdata(pdev); - struct aml_card_data *priv = snd_soc_card_get_drvdata(card); - int state; - - priv->av_mute_enable = 0; - priv->spk_mute_enable = 0; - aml_card_parse_gpios(pdev->dev.of_node, priv); - - gpio_direction_input(priv->hp_jack.gpio.gpio); - state = gpiod_set_pull(gpio_to_desc(priv->hp_jack.gpio.gpio), GPIOD_PULL_DIS); - if (state) - pr_err("set hp_jack gpiod pull failed, ret %d\n", state); - - return 0; -} - -static const struct dev_pm_ops meson_card_pm_ops = { - /* use the same as suspend, because the restore - * will enable the clk and default setting - */ - .restore = aml_card_platform_restore, -}; -#endif - static struct platform_driver aml_card = { .driver = { .name = "asoc-aml-card", -#ifdef CONFIG_HIBERNATION - .pm = &meson_card_pm_ops, -#else .pm = &snd_soc_pm_ops, -#endif .of_match_table = auge_of_match, #if IS_ENABLED(CONFIG_AMLOGIC_BOOT_TIME) .probe_type = PROBE_PREFER_ASYNCHRONOUS, diff --git a/sound/soc/codecs/amlogic/ad82128.c b/sound/soc/codecs/amlogic/ad82128.c index d8e1b1c73..015c78cc3 100644 --- a/sound/soc/codecs/amlogic/ad82128.c +++ b/sound/soc/codecs/amlogic/ad82128.c @@ -1024,22 +1024,6 @@ static void ad82128_i2c_shutdown(struct i2c_client *client) } -static int aml_ad82128_platform_resume(struct device *dev) -{ - struct ad82128_data *data = dev_get_drvdata(dev); - - ad82128_resume(data->component); - return 0; -} - -static int aml_ad82128_platform_suspend(struct device *dev) -{ - struct ad82128_data *data = dev_get_drvdata(dev); - - ad82128_suspend(data->component); - return 0; -} - static int aml_ad82128_platform_restore(struct device *dev) { struct ad82128_data *data = dev_get_drvdata(dev); @@ -1074,8 +1058,6 @@ static const struct dev_pm_ops meson_ad82128_pm_ops = { */ .restore = aml_ad82128_platform_restore, .freeze = aml_ad82128_platform_freeze, - .suspend = aml_ad82128_platform_suspend, - .resume = aml_ad82128_platform_resume, }; static const struct i2c_device_id ad82128_id[] = { diff --git a/sound/soc/codecs/amlogic/aml_codec_a1_acodec.c b/sound/soc/codecs/amlogic/aml_codec_a1_acodec.c index 6bfdbc2a0..15bf05db6 100644 --- a/sound/soc/codecs/amlogic/aml_codec_a1_acodec.c +++ b/sound/soc/codecs/amlogic/aml_codec_a1_acodec.c @@ -647,6 +647,29 @@ static void aml_a1_acodec_shutdown(struct platform_device *pdev) a1_acodec_remove(component); } +static int aml_a1_acodec_restore(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct a1_acodec_priv *aml_acodec = platform_get_drvdata(pdev); + + schedule_work(&aml_acodec->work); + return 0; +} + +static int aml_a1_acodec_freeze(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + struct a1_acodec_priv *aml_acodec = platform_get_drvdata(pdev); + + cancel_work_sync(&aml_acodec->work); + return 0; +} + +static const struct dev_pm_ops meson_a1_acodec_pm_ops = { + .restore = aml_a1_acodec_restore, + .freeze = aml_a1_acodec_freeze, +}; + static const struct of_device_id aml_a1_acodec_dt_match[] = { { .compatible = "amlogic, a1_acodec", @@ -664,6 +687,7 @@ static struct platform_driver aml_a1_acodec_platform_driver = { .name = "a1_acodec", .owner = THIS_MODULE, .of_match_table = aml_a1_acodec_dt_match, + .pm = &meson_a1_acodec_pm_ops, }, .probe = aml_a1_acodec_probe, .remove = aml_a1_acodec_remove, diff --git a/sound/soc/codecs/amlogic/aml_codec_t6d_acodec.c b/sound/soc/codecs/amlogic/aml_codec_t6d_acodec.c index b28f1bbbc..fd665a473 100644 --- a/sound/soc/codecs/amlogic/aml_codec_t6d_acodec.c +++ b/sound/soc/codecs/amlogic/aml_codec_t6d_acodec.c @@ -793,8 +793,7 @@ static int am_acodec_dai_set_bias_level case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (component->dapm.bias_level == SND_SOC_BIAS_OFF) - snd_soc_component_cache_sync(component); + snd_soc_component_cache_sync(component); break; case SND_SOC_BIAS_OFF: diff --git a/sound/soc/codecs/amlogic/aml_codec_t9015.c b/sound/soc/codecs/amlogic/aml_codec_t9015.c index 57425c3fd..d894969d0 100644 --- a/sound/soc/codecs/amlogic/aml_codec_t9015.c +++ b/sound/soc/codecs/amlogic/aml_codec_t9015.c @@ -633,9 +633,6 @@ static int aml_T9015_acodec_platform_freeze(struct device *dev) static const struct dev_pm_ops meson_T9015_pm_ops = { .restore = aml_T9015_acodec_platform_restore, .freeze = aml_T9015_acodec_platform_freeze, - .suspend = aml_T9015_acodec_platform_restore, - .resume = aml_T9015_acodec_platform_freeze, - }; static struct platform_driver aml_T9015_codec_platform_driver = { diff --git a/sound/soc/codecs/amlogic/aml_codec_tl1_acodec.c b/sound/soc/codecs/amlogic/aml_codec_tl1_acodec.c index c8cbfb0aa..613932116 100644 --- a/sound/soc/codecs/amlogic/aml_codec_tl1_acodec.c +++ b/sound/soc/codecs/amlogic/aml_codec_tl1_acodec.c @@ -663,11 +663,9 @@ static int tl1_acodec_dai_set_bias_level break; case SND_SOC_BIAS_STANDBY: - if (component->dapm.bias_level == SND_SOC_BIAS_OFF) { - snd_soc_component_cache_sync(component); - snd_soc_component_write(component, ACODEC_0, tl1_acodec_init_list[0].def); - snd_soc_component_write(component, ACODEC_8, tl1_acodec_init_list[8].def); - } + snd_soc_component_cache_sync(component); + snd_soc_component_write(component, ACODEC_0, tl1_acodec_init_list[0].def); + snd_soc_component_write(component, ACODEC_8, tl1_acodec_init_list[8].def); break; case SND_SOC_BIAS_OFF: @@ -1176,24 +1174,6 @@ static const struct of_device_id aml_tl1_acodec_dt_match[] = { {}, }; -static int aml_acodec_platform_suspend(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct tl1_acodec_priv *aml_acodec = platform_get_drvdata(pdev); - - tl1_acodec_suspend(aml_acodec->component); - return 0; -} - -static int aml_acodec_platform_resume(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct tl1_acodec_priv *aml_acodec = platform_get_drvdata(pdev); - - tl1_acodec_resume(aml_acodec->component); - return 0; -} - static int aml_acodec_platform_restore(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -1220,8 +1200,6 @@ static int aml_acodec_platform_freeze(struct device *dev) static const struct dev_pm_ops meson_acodec_pm_ops = { .restore = aml_acodec_platform_restore, .freeze = aml_acodec_platform_freeze, - .suspend = aml_acodec_platform_suspend, - .resume = aml_acodec_platform_resume, }; static struct platform_driver aml_tl1_acodec_platform_driver = { diff --git a/sound/soc/codecs/amlogic/tas5707.c b/sound/soc/codecs/amlogic/tas5707.c index 5bd0a95ea..9b2908a95 100644 --- a/sound/soc/codecs/amlogic/tas5707.c +++ b/sound/soc/codecs/amlogic/tas5707.c @@ -877,22 +877,6 @@ static int tas5707_i2c_remove(struct i2c_client *client) return 0; } -static int aml_tas5707_platform_suspend(struct device *dev) -{ - struct tas5707_priv *tas5707 = dev_get_drvdata(dev); - - tas5707_resume(tas5707->component); - return 0; -} - -static int aml_tas5707_platform_resume(struct device *dev) -{ - struct tas5707_priv *tas5707 = dev_get_drvdata(dev); - - tas5707_suspend(tas5707->component); - return 0; -} - static int aml_tas5707_platform_restore(struct device *dev) { struct tas5707_priv *tas5707 = dev_get_drvdata(dev); @@ -926,8 +910,6 @@ static const struct dev_pm_ops meson_tas5707_pm_ops = { */ .restore = aml_tas5707_platform_restore, .freeze = aml_tas5707_platform_freeze, - .suspend = aml_tas5707_platform_suspend, - .resume = aml_tas5707_platform_resume, }; static const struct i2c_device_id tas5707_i2c_id[] = { diff --git a/sound/soc/codecs/amlogic/tas5805.c b/sound/soc/codecs/amlogic/tas5805.c index d49b90eb8..db87a5432 100644 --- a/sound/soc/codecs/amlogic/tas5805.c +++ b/sound/soc/codecs/amlogic/tas5805.c @@ -1263,22 +1263,6 @@ static void tas5805m_i2c_shutdown(struct i2c_client *i2c) gpio_direction_output(pdata->reset_pin, GPIOF_OUT_INIT_LOW); } -static int aml_tas5805m_platform_suspend(struct device *dev) -{ - struct tas5805m_priv *data = dev_get_drvdata(dev); - - tas5805m_snd_suspend(data->component); - return 0; -} - -static int aml_tas5805m_platform_resume(struct device *dev) -{ - struct tas5805m_priv *data = dev_get_drvdata(dev); - - tas5805m_snd_resume(data->component); - return 0; -} - static int aml_tas5805m_platform_restore(struct device *dev) { struct tas5805m_priv *data = dev_get_drvdata(dev); @@ -1312,8 +1296,6 @@ static const struct dev_pm_ops meson_tas5805m_pm_ops = { */ .restore = aml_tas5805m_platform_restore, .freeze = aml_tas5805m_platform_freeze, - .suspend = aml_tas5805m_platform_suspend, - .resume = aml_tas5805m_platform_resume, }; static const struct i2c_device_id tas5805m_i2c_id[] = {