ASoC: twl6040: Fix PCM error handling ops

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>
This commit is contained in:
Olaya, Margarita 2010-12-10 21:05:54 -06:00 committed by Liam Girdwood
parent 6c311041c1
commit 4e624d0609
1 changed files with 22 additions and 33 deletions

View 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,
};