ASoC: rt1015: Flush DAC data before playback.
authorJack Yu <jack.yu@realtek.com>
Tue, 16 Jun 2020 02:36:44 +0000 (10:36 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 16 Jun 2020 11:39:33 +0000 (12:39 +0100)
Flush DAC data before playback.

Signed-off-by: Jack Yu <jack.yu@realtek.com>
Link: https://lore.kernel.org/r/20200616023644.4523-1-jack.yu@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/rt1015.c
sound/soc/codecs/rt1015.h

index 2cccb310fa968adaa19c22c4e549fd91764a615f..1f61b4aa43539dafeed2f12d569cd7f36145867d 100644 (file)
@@ -493,7 +493,7 @@ static int rt1015_bypass_boost_put(struct snd_kcontrol *kcontrol,
 
        if (!rt1015->dac_is_used) {
                rt1015->bypass_boost = ucontrol->value.integer.value[0];
-               if (rt1015->bypass_boost == 1) {
+               if (rt1015->bypass_boost == RT1015_Bypass_Boost) {
                        snd_soc_component_write(component,
                                RT1015_PWR4, 0x00b2);
                        snd_soc_component_write(component,
@@ -549,7 +549,7 @@ static int r1015_dac_event(struct snd_soc_dapm_widget *w,
        switch (event) {
        case SND_SOC_DAPM_PRE_PMU:
                rt1015->dac_is_used = 1;
-               if (rt1015->bypass_boost == 0) {
+               if (rt1015->bypass_boost == RT1015_Enable_Boost) {
                        snd_soc_component_write(component,
                                RT1015_SYS_RST1, 0x05f7);
                        snd_soc_component_write(component,
@@ -566,8 +566,17 @@ static int r1015_dac_event(struct snd_soc_dapm_widget *w,
                }
                break;
 
+       case SND_SOC_DAPM_POST_PMU:
+               if (rt1015->bypass_boost == RT1015_Bypass_Boost) {
+                       regmap_write(rt1015->regmap, RT1015_MAN_I2C, 0x00a8);
+                       regmap_write(rt1015->regmap, RT1015_SYS_RST1, 0x0597);
+                       regmap_write(rt1015->regmap, RT1015_SYS_RST1, 0x05f7);
+                       regmap_write(rt1015->regmap, RT1015_MAN_I2C, 0x0028);
+               }
+               break;
+
        case SND_SOC_DAPM_POST_PMD:
-               if (rt1015->bypass_boost == 0) {
+               if (rt1015->bypass_boost == RT1015_Enable_Boost) {
                        snd_soc_component_write(component,
                                RT1015_PWR9, 0xa800);
                        snd_soc_component_write(component,
@@ -617,7 +626,8 @@ static const struct snd_soc_dapm_widget rt1015_dapm_widgets[] = {
 
        SND_SOC_DAPM_AIF_IN("AIFRX", "AIF Playback", 0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_DAC_E("DAC", NULL, RT1015_PWR1, RT1015_PWR_DAC_BIT, 0,
-               r1015_dac_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
+               r1015_dac_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
+               SND_SOC_DAPM_POST_PMD),
 
        SND_SOC_DAPM_OUTPUT("SPO"),
 };
index 8169962935a56a5c75769044dcf6034f066feb04..7bd159e8f9587b133c746ea8a8f6bc2d98864394 100644 (file)
@@ -368,6 +368,11 @@ enum {
        FIXED_ADAPTIVE,
 };
 
+enum {
+       RT1015_Enable_Boost = 0,
+       RT1015_Bypass_Boost,
+};
+
 struct rt1015_priv {
        struct snd_soc_component *component;
        struct regmap *regmap;