aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/pcm512x.c
diff options
context:
space:
mode:
authorPeter Rosin <peda@axentia.se>2015-01-29 06:21:56 -0500
committerMark Brown <broonie@kernel.org>2015-01-29 07:02:29 -0500
commit9c7da1a57bb5938f1d874c8cd5e50d2494830d08 (patch)
tree25e1571b1ef651f9132a84ad68d22c3ade4ffa5d /sound/soc/codecs/pcm512x.c
parent2599a9609c588d040c53e7eaed00e696effd28bf (diff)
ASoC: pcm512x: Use the correct range constraints for S24_LE
This was overlooked in the late change to remove the I2S padding bits from S24_LE mode. The patch also limits S32_LE mode to 384kHz, the maximum according to the datasheets. Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/pcm512x.c')
-rw-r--r--sound/soc/codecs/pcm512x.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 067d11743c31..884784fb1566 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -356,36 +356,37 @@ static const struct snd_pcm_hw_constraint_list constraints_slave = {
356 .list = pcm512x_dai_rates, 356 .list = pcm512x_dai_rates,
357}; 357};
358 358
359static const struct snd_interval pcm512x_dai_ranges_64bpf[] = {
360 {
361 .min = 8000,
362 .max = 195312,
363 }, {
364 .min = 250000,
365 .max = 390625,
366 },
367};
368
369static struct snd_pcm_hw_constraint_ranges constraints_64bpf = {
370 .count = ARRAY_SIZE(pcm512x_dai_ranges_64bpf),
371 .ranges = pcm512x_dai_ranges_64bpf,
372};
373
374static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params, 359static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params,
375 struct snd_pcm_hw_rule *rule) 360 struct snd_pcm_hw_rule *rule)
376{ 361{
377 struct snd_pcm_hw_constraint_ranges *r = rule->private; 362 struct snd_interval ranges[2];
378 int frame_size; 363 int frame_size;
379 364
380 frame_size = snd_soc_params_to_frame_size(params); 365 frame_size = snd_soc_params_to_frame_size(params);
381 if (frame_size < 0) 366 if (frame_size < 0)
382 return frame_size; 367 return frame_size;
383 368
384 if (frame_size != 64) 369 switch (frame_size) {
370 case 32:
371 /* No hole when the frame size is 32. */
385 return 0; 372 return 0;
373 case 48:
374 case 64:
375 /* There is only one hole in the range of supported
376 * rates, but it moves with the frame size.
377 */
378 memset(ranges, 0, sizeof(ranges));
379 ranges[0].min = 8000;
380 ranges[0].max = 25000000 / frame_size / 2;
381 ranges[1].min = DIV_ROUND_UP(16000000, frame_size);
382 ranges[1].max = 384000;
383 break;
384 default:
385 return -EINVAL;
386 }
386 387
387 return snd_interval_ranges(hw_param_interval(params, rule->var), 388 return snd_interval_ranges(hw_param_interval(params, rule->var),
388 r->count, r->ranges, r->mask); 389 ARRAY_SIZE(ranges), ranges, 0);
389} 390}
390 391
391static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream, 392static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream,
@@ -407,7 +408,7 @@ static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream,
407 return snd_pcm_hw_rule_add(substream->runtime, 0, 408 return snd_pcm_hw_rule_add(substream->runtime, 0,
408 SNDRV_PCM_HW_PARAM_RATE, 409 SNDRV_PCM_HW_PARAM_RATE,
409 pcm512x_hw_rule_rate, 410 pcm512x_hw_rule_rate,
410 (void *)&constraints_64bpf, 411 NULL,
411 SNDRV_PCM_HW_PARAM_FRAME_BITS, 412 SNDRV_PCM_HW_PARAM_FRAME_BITS,
412 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 413 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
413 414