aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2010-01-15 11:36:48 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-01-15 12:28:41 -0500
commit6aababdf20bb8892023bb8df136514d7679e4959 (patch)
tree4919145129a8b76b5bd94046da3b2a73beab4fdb /sound
parent738ada47cf60830d37bb70ffb0b0281d19fc4c7f (diff)
ASoC: cs4270: allow passing freq=0 in set_dai_sysclk()
For setups with variable MCLKs, the current logic of limiting the available sampling rates at startup time is not sufficient. We need to be able to change the setting at a later point, and so the codec must offer all possible rates until the hw_params are given. This patches allows that by passing 0 as 'freq' argument to cs4270_set_dai_sysclk(). Signed-off-by: Daniel Mack <daniel@caiaq.de> Acked-by: Timur Tabi <timur@freescale.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/cs4270.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index 8b5457542a0e..593bfc7a6986 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -200,6 +200,11 @@ static struct cs4270_mode_ratios cs4270_mode_ratios[] = {
200 * This function must be called by the machine driver's 'startup' function, 200 * This function must be called by the machine driver's 'startup' function,
201 * otherwise the list of supported sample rates will not be available in 201 * otherwise the list of supported sample rates will not be available in
202 * time for ALSA. 202 * time for ALSA.
203 *
204 * For setups with variable MCLKs, pass 0 as 'freq' argument. This will cause
205 * theoretically possible sample rates to be enabled. Call it again with a
206 * proper value set one the external clock is set (most probably you would do
207 * that from a machine's driver 'hw_param' hook.
203 */ 208 */
204static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai, 209static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai,
205 int clk_id, unsigned int freq, int dir) 210 int clk_id, unsigned int freq, int dir)
@@ -213,20 +218,27 @@ static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai,
213 218
214 cs4270->mclk = freq; 219 cs4270->mclk = freq;
215 220
216 for (i = 0; i < NUM_MCLK_RATIOS; i++) { 221 if (cs4270->mclk) {
217 unsigned int rate = freq / cs4270_mode_ratios[i].ratio; 222 for (i = 0; i < NUM_MCLK_RATIOS; i++) {
218 rates |= snd_pcm_rate_to_rate_bit(rate); 223 unsigned int rate = freq / cs4270_mode_ratios[i].ratio;
219 if (rate < rate_min) 224 rates |= snd_pcm_rate_to_rate_bit(rate);
220 rate_min = rate; 225 if (rate < rate_min)
221 if (rate > rate_max) 226 rate_min = rate;
222 rate_max = rate; 227 if (rate > rate_max)
223 } 228 rate_max = rate;
224 /* FIXME: soc should support a rate list */ 229 }
225 rates &= ~SNDRV_PCM_RATE_KNOT; 230 /* FIXME: soc should support a rate list */
231 rates &= ~SNDRV_PCM_RATE_KNOT;
226 232
227 if (!rates) { 233 if (!rates) {
228 dev_err(codec->dev, "could not find a valid sample rate\n"); 234 dev_err(codec->dev, "could not find a valid sample rate\n");
229 return -EINVAL; 235 return -EINVAL;
236 }
237 } else {
238 /* enable all possible rates */
239 rates = SNDRV_PCM_RATE_8000_192000;
240 rate_min = 8000;
241 rate_max = 192000;
230 } 242 }
231 243
232 codec_dai->playback.rates = rates; 244 codec_dai->playback.rates = rates;