]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ASoC: twl6040: Fix PCM error handling ops
authorOlaya, Margarita <magi.olaya@ti.com>
Sat, 11 Dec 2010 03:05:54 +0000 (21:05 -0600)
committerLiam Girdwood <lrg@slimlogic.co.uk>
Tue, 14 Dec 2010 20:36:37 +0000 (20:36 +0000)
This patch moves all the PCM error handling for clock config
out of trigger() and startup() and into prepare().

Signed-off-by: Margarita Olaya Cabrera <magi.olaya@ti.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
sound/soc/codecs/twl6040.c

index 3973bf6889c0ff2ed31ffd24deda76fb84626921..fd9a3ab91a19726264cfdb6fbc49f295b09b7090 100644 (file)
@@ -865,23 +865,6 @@ static int twl6040_startup(struct snd_pcm_substream *substream,
        struct snd_soc_codec *codec = rtd->codec;
        struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
 
-       if (!priv->sysclk) {
-               dev_err(codec->dev,
-                       "no mclk configured, call set_sysclk() on init\n");
-               return -EINVAL;
-       }
-
-       /*
-        * capture is not supported at 17.64 MHz,
-        * it's reserved for headset low-power playback scenario
-        */
-       if ((priv->sysclk == 17640000) && substream->stream) {
-               dev_err(codec->dev,
-                       "capture mode is not supported at %dHz\n",
-                       priv->sysclk);
-               return -EINVAL;
-       }
-
        snd_pcm_hw_constraint_list(substream->runtime, 0,
                                SNDRV_PCM_HW_PARAM_RATE,
                                priv->sysclk_constraints);
@@ -925,31 +908,37 @@ static int twl6040_hw_params(struct snd_pcm_substream *substream,
        return 0;
 }
 
-static int twl6040_trigger(struct snd_pcm_substream *substream,
-                       int cmd, struct snd_soc_dai *dai)
+static int twl6040_prepare(struct snd_pcm_substream *substream,
+                       struct snd_soc_dai *dai)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct snd_soc_codec *codec = rtd->codec;
        struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
 
-       switch (cmd) {
-       case SNDRV_PCM_TRIGGER_START:
-       case SNDRV_PCM_TRIGGER_RESUME:
-               /*
-                * low-power playback mode is restricted
-                * for headset path only
-                */
-               if ((priv->sysclk == 17640000) && priv->non_lp) {
+       if (!priv->sysclk) {
+               dev_err(codec->dev,
+                       "no mclk configured, call set_sysclk() on init\n");
+               return -EINVAL;
+       }
+
+       /*
+        * capture is not supported at 17.64 MHz,
+        * it's reserved for headset low-power playback scenario
+        */
+       if ((priv->sysclk == 17640000) &&
+                       substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
+               dev_err(codec->dev,
+                       "capture mode is not supported at %dHz\n",
+                       priv->sysclk);
+               return -EINVAL;
+       }
+
+       if ((priv->sysclk == 17640000) && priv->non_lp) {
                        dev_err(codec->dev,
                                "some enabled paths aren't supported at %dHz\n",
                                priv->sysclk);
                        return -EPERM;
-               }
-               break;
-       default:
-               break;
        }
-
        return 0;
 }
 
@@ -1063,7 +1052,7 @@ static int twl6040_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 static struct snd_soc_dai_ops twl6040_dai_ops = {
        .startup        = twl6040_startup,
        .hw_params      = twl6040_hw_params,
-       .trigger        = twl6040_trigger,
+       .prepare        = twl6040_prepare,
        .set_sysclk     = twl6040_set_dai_sysclk,
 };