build/patch/kernel/archive/sunxi-6.4/patches.megous/ASoC-sun50i-codec-analog-Move-suspend-resume-to-set_bias_level.patch

73 lines
2.6 KiB
Diff
Raw Permalink Normal View History

From 98b68eb26011a6656390544a924c22558f5d7b79 Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
Date: Sat, 26 Sep 2020 21:39:27 -0500
Subject: [PATCH 255/469] ASoC: sun50i-codec-analog: Move suspend/resume to
set_bias_level
With idle_bias_on and suspend_bias_off, there are bias level transitions
that match the suspend/resume callbacks. However, there are also
transitions during probe (OFF => STANDBY) and removal (STANDBY => OFF).
By using the set_bias_level hook, the driver can have one copy of code
that would otherwise be duplicated between the probe/resume and
suspend/remove hooks.
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
sound/soc/sunxi/sun50i-codec-analog.c | 30 +++++++++++++++++----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/sound/soc/sunxi/sun50i-codec-analog.c b/sound/soc/sunxi/sun50i-codec-analog.c
index c32aa35521e2..45466a51a871 100644
--- a/sound/soc/sunxi/sun50i-codec-analog.c
+++ b/sound/soc/sunxi/sun50i-codec-analog.c
@@ -488,17 +488,24 @@ static int sun50i_a64_codec_probe(struct snd_soc_component *component)
return 0;
}
-static int sun50i_a64_codec_suspend(struct snd_soc_component *component)
+static int sun50i_a64_codec_set_bias_level(struct snd_soc_component *component,
+ enum snd_soc_bias_level level)
{
- return regmap_update_bits(component->regmap, SUN50I_ADDA_HP_CTRL,
- BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE),
- BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE));
-}
+ switch (level) {
+ case SND_SOC_BIAS_OFF:
+ regmap_update_bits(component->regmap, SUN50I_ADDA_HP_CTRL,
+ BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE),
+ BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE));
+ break;
+ case SND_SOC_BIAS_STANDBY:
+ regmap_update_bits(component->regmap, SUN50I_ADDA_HP_CTRL,
+ BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE), 0);
+ break;
+ default:
+ break;
+ }
-static int sun50i_a64_codec_resume(struct snd_soc_component *component)
-{
- return regmap_update_bits(component->regmap, SUN50I_ADDA_HP_CTRL,
- BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE), 0);
+ return 0;
}
static const struct snd_soc_component_driver sun50i_codec_analog_cmpnt_drv = {
@@ -509,8 +516,9 @@ static const struct snd_soc_component_driver sun50i_codec_analog_cmpnt_drv = {
.dapm_routes = sun50i_a64_codec_routes,
.num_dapm_routes = ARRAY_SIZE(sun50i_a64_codec_routes),
.probe = sun50i_a64_codec_probe,
- .suspend = sun50i_a64_codec_suspend,
- .resume = sun50i_a64_codec_resume,
+ .set_bias_level = sun50i_a64_codec_set_bias_level,
+ .idle_bias_on = true,
+ .suspend_bias_off = true,
};
static const struct of_device_id sun50i_codec_analog_of_match[] = {
--
2.34.1