]> Pileus Git - ~andy/linux/commitdiff
ASoC: twl6040: Custom caching for sensitive DL1/2 path registers
authorPeter Ujfalusi <peter.ujfalusi@ti.com>
Fri, 29 Nov 2013 14:03:44 +0000 (16:03 +0200)
committerMark Brown <broonie@linaro.org>
Thu, 19 Dec 2013 18:37:06 +0000 (18:37 +0000)
Introduce a small register cache for registers which needs special caching
to reduce pop noise:
TWL6040_REG_HSLCTL, TWL6040_REG_HSRCTL, TWL6040_REG_EARCTL, TWL6040_REG_HFLCTL
and TWL6040_REG_HFRCTL.
Switch over and use the new small cache for these registers instead of the
main reg_cache.
This is in preparation to remove the local ASoC reg_cache from the driver.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
sound/soc/codecs/twl6040.c

index ef13a501a7b454ce95164e9cd5582a4e7a432a6c..fb8c65bd6e5d40715a93a9e580931eabf17585cc 100644 (file)
@@ -72,6 +72,7 @@ struct twl6040_data {
        int hs_power_mode_locked;
        bool dl1_unmuted;
        bool dl2_unmuted;
+       u8 dl12_cache[TWL6040_REG_HFRCTL - TWL6040_REG_HSLCTL + 1];
        unsigned int clk_in;
        unsigned int sysclk;
        struct twl6040_jack_data hs_jack;
@@ -174,18 +175,62 @@ static struct snd_pcm_hw_constraint_list sysclk_constraints[] = {
        { .count = ARRAY_SIZE(hp_rates), .list = hp_rates, },
 };
 
+static inline int twl6040_read_dl12_cache(struct snd_soc_codec *codec,
+                                          u8 reg, u8 *value)
+{
+       struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
+       int ret = 0;
+
+       switch (reg) {
+       case TWL6040_REG_HSLCTL:
+       case TWL6040_REG_HSRCTL:
+       case TWL6040_REG_EARCTL:
+       case TWL6040_REG_HFLCTL:
+       case TWL6040_REG_HFRCTL:
+               *value = priv->dl12_cache[reg - TWL6040_REG_HSLCTL];
+               break;
+       default:
+               ret = -EINVAL;
+               break;
+       }
+
+       return ret;
+}
+
 /*
  * read twl6040 register cache
  */
 static inline unsigned int twl6040_read_reg_cache(struct snd_soc_codec *codec,
-                                               unsigned int reg)
+                                                 unsigned int reg)
 {
        u8 *cache = codec->reg_cache;
+       u8 value;
 
        if (reg >= TWL6040_CACHEREGNUM)
                return -EIO;
 
-       return cache[reg];
+       if (twl6040_read_dl12_cache(codec, reg, &value))
+               value = cache[reg];
+
+       return value;
+}
+
+static inline void twl6040_update_dl12_cache(struct snd_soc_codec *codec,
+                                            u8 reg, u8 value)
+{
+       struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
+
+       switch (reg) {
+       case TWL6040_REG_HSLCTL:
+       case TWL6040_REG_HSRCTL:
+       case TWL6040_REG_EARCTL:
+       case TWL6040_REG_HFLCTL:
+       case TWL6040_REG_HFRCTL:
+               priv->dl12_cache[reg - TWL6040_REG_HSLCTL] = value;
+               break;
+       default:
+               break;
+       }
 }
 
 /*
@@ -199,6 +244,8 @@ static inline void twl6040_write_reg_cache(struct snd_soc_codec *codec,
        if (reg >= TWL6040_CACHEREGNUM)
                return;
        cache[reg] = value;
+
+       twl6040_update_dl12_cache(codec, reg, value);
 }
 
 /*