CHROMIUM: ALSA: ASoC: max98095 - Disable codec while loading EQ coefficients.
authorDylan Reid <dgreid@chromium.org>
Tue, 18 Sep 2012 16:17:27 +0000 (09:17 -0700)
committerGerrit <chrome-bot@google.com>
Tue, 25 Sep 2012 23:02:05 +0000 (16:02 -0700)
According to Evan from Maxim:
"It is mandatory to use codec shutdown when changing the EQ parameters.
Also, depending on the current device settings, it may take some time
for the codec to actually shut down (due to volume ramping).  Please be
sure to account for this delay after CODEC_SHDN is asserted and before
any EQ coefficients are written.  A 20ms delay should be fine."

Assert codec shutdown around EQ coefficients loads.

BUG=chrome-os-partner:12039
TEST=enable/disable EQ, set EQ mode while playing music.

Change-Id: Iae41bdaf97fb8594cd8893ddbe1bbfa2477a01af
Reviewed-on: https://gerrit.chromium.org/gerrit/33576
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Doug Anderson <dianders@chromium.org>
sound/soc/codecs/max98095.c
sound/soc/codecs/max98095.h

index a217282..2a48c0d 100644 (file)
@@ -1907,6 +1907,14 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
        snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, 0);
 
        mutex_lock(&codec->mutex);
+
+       /* Codec must be shutdown during EQ loading, and it may take up to 20mS
+        * to shut down.
+        */
+       snd_soc_update_bits(codec, M98095_097_PWR_SYS, M98095_CODECSHDN,
+                           M98095_CODECSHDN);
+       msleep(20);
+
        snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG);
        m98095_eq_band(codec, channel, 0, coef_set->band1);
        m98095_eq_band(codec, channel, 1, coef_set->band2);
@@ -1914,6 +1922,8 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
        m98095_eq_band(codec, channel, 3, coef_set->band4);
        m98095_eq_band(codec, channel, 4, coef_set->band5);
        snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, 0);
+       snd_soc_update_bits(codec, M98095_097_PWR_SYS, M98095_CODECSHDN, 0);
+
        mutex_unlock(&codec->mutex);
 
        /* Restore the original on/off state */
index 891584a..5e9ff0f 100644 (file)
 
 /* M98095_097_PWR_SYS */
        #define M98095_SHDNRUN                  (1<<7)
+       #define M98095_CODECSHDN                (1<<6)
        #define M98095_PERFMODE                 (1<<3)
        #define M98095_HPPLYBACK                (1<<2)
        #define M98095_PWRSV8K                  (1<<1)