aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;