Commit 4e624d06 authored by Olaya, Margarita's avatar Olaya, Margarita Committed by Liam Girdwood

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: default avatarMargarita Olaya Cabrera <magi.olaya@ti.com>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent 6c311041
......@@ -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,
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment