diff options
author | Olaya, Margarita <magi.olaya@ti.com> | 2010-12-10 22:05:54 -0500 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-12-14 15:36:37 -0500 |
commit | 4e624d0609081e4394695fba3d7c3b7ebb6171ce (patch) | |
tree | 22ff69e8f40744a14173a75227607bb6bdc5f519 | |
parent | 6c311041c1d3d0b9d1fc6ddacd49e50d83ba158a (diff) |
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>
-rw-r--r-- | sound/soc/codecs/twl6040.c | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 3973bf6889c0..fd9a3ab91a19 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c | |||
@@ -865,23 +865,6 @@ static int twl6040_startup(struct snd_pcm_substream *substream, | |||
865 | struct snd_soc_codec *codec = rtd->codec; | 865 | struct snd_soc_codec *codec = rtd->codec; |
866 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); | 866 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); |
867 | 867 | ||
868 | if (!priv->sysclk) { | ||
869 | dev_err(codec->dev, | ||
870 | "no mclk configured, call set_sysclk() on init\n"); | ||
871 | return -EINVAL; | ||
872 | } | ||
873 | |||
874 | /* | ||
875 | * capture is not supported at 17.64 MHz, | ||
876 | * it's reserved for headset low-power playback scenario | ||
877 | */ | ||
878 | if ((priv->sysclk == 17640000) && substream->stream) { | ||
879 | dev_err(codec->dev, | ||
880 | "capture mode is not supported at %dHz\n", | ||
881 | priv->sysclk); | ||
882 | return -EINVAL; | ||
883 | } | ||
884 | |||
885 | snd_pcm_hw_constraint_list(substream->runtime, 0, | 868 | snd_pcm_hw_constraint_list(substream->runtime, 0, |
886 | SNDRV_PCM_HW_PARAM_RATE, | 869 | SNDRV_PCM_HW_PARAM_RATE, |
887 | priv->sysclk_constraints); | 870 | priv->sysclk_constraints); |
@@ -925,31 +908,37 @@ static int twl6040_hw_params(struct snd_pcm_substream *substream, | |||
925 | return 0; | 908 | return 0; |
926 | } | 909 | } |
927 | 910 | ||
928 | static int twl6040_trigger(struct snd_pcm_substream *substream, | 911 | static int twl6040_prepare(struct snd_pcm_substream *substream, |
929 | int cmd, struct snd_soc_dai *dai) | 912 | struct snd_soc_dai *dai) |
930 | { | 913 | { |
931 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 914 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
932 | struct snd_soc_codec *codec = rtd->codec; | 915 | struct snd_soc_codec *codec = rtd->codec; |
933 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); | 916 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); |
934 | 917 | ||
935 | switch (cmd) { | 918 | if (!priv->sysclk) { |
936 | case SNDRV_PCM_TRIGGER_START: | 919 | dev_err(codec->dev, |
937 | case SNDRV_PCM_TRIGGER_RESUME: | 920 | "no mclk configured, call set_sysclk() on init\n"); |
938 | /* | 921 | return -EINVAL; |
939 | * low-power playback mode is restricted | 922 | } |
940 | * for headset path only | 923 | |
941 | */ | 924 | /* |
942 | if ((priv->sysclk == 17640000) && priv->non_lp) { | 925 | * capture is not supported at 17.64 MHz, |
926 | * it's reserved for headset low-power playback scenario | ||
927 | */ | ||
928 | if ((priv->sysclk == 17640000) && | ||
929 | substream->stream == SNDRV_PCM_STREAM_CAPTURE) { | ||
930 | dev_err(codec->dev, | ||
931 | "capture mode is not supported at %dHz\n", | ||
932 | priv->sysclk); | ||
933 | return -EINVAL; | ||
934 | } | ||
935 | |||
936 | if ((priv->sysclk == 17640000) && priv->non_lp) { | ||
943 | dev_err(codec->dev, | 937 | dev_err(codec->dev, |
944 | "some enabled paths aren't supported at %dHz\n", | 938 | "some enabled paths aren't supported at %dHz\n", |
945 | priv->sysclk); | 939 | priv->sysclk); |
946 | return -EPERM; | 940 | return -EPERM; |
947 | } | ||
948 | break; | ||
949 | default: | ||
950 | break; | ||
951 | } | 941 | } |
952 | |||
953 | return 0; | 942 | return 0; |
954 | } | 943 | } |
955 | 944 | ||
@@ -1063,7 +1052,7 @@ static int twl6040_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
1063 | static struct snd_soc_dai_ops twl6040_dai_ops = { | 1052 | static struct snd_soc_dai_ops twl6040_dai_ops = { |
1064 | .startup = twl6040_startup, | 1053 | .startup = twl6040_startup, |
1065 | .hw_params = twl6040_hw_params, | 1054 | .hw_params = twl6040_hw_params, |
1066 | .trigger = twl6040_trigger, | 1055 | .prepare = twl6040_prepare, |
1067 | .set_sysclk = twl6040_set_dai_sysclk, | 1056 | .set_sysclk = twl6040_set_dai_sysclk, |
1068 | }; | 1057 | }; |
1069 | 1058 | ||