aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-pcm.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-11-27 03:58:18 -0500
committerMark Brown <broonie@linaro.org>2013-11-27 11:43:12 -0500
commit78e45c99f6d470e6069c8669ee533c97cc5fd296 (patch)
tree5169621088303663b48e8841b67bb3f75b84b8bd /sound/soc/soc-pcm.c
parent17b6c19b34b43a6a8dd5936b3cdbc63d7d1ae186 (diff)
ASoC: pcm: Always honor DAI min and max sample rate constraints
snd_pcm_limit_hw_rates() will initialize the minimum and maximum sample rate for the PCM stream based on the rates specified in the rates field. Since we call snd_pcm_limit_hw_rates() after soc_pcm_init_runtime_hw() it will essentially overwrite the min and max rate set in soc_pcm_init_runtime_hw(). This may cause the minimum or maximum rate to be set to a value outside the range of one of the components if one of the components sets either SNDRV_PCM_RATE_CONTINUOUS or SNDRV_PCM_RATE_KNOT and the other component specified a discrete rate via SNDRV_PCM_RATE_[0-9]* that is outside of the first component's rate range. To fix this first calculate the minimum and maximum rates using snd_pcm_limit_hw_rates() and then on top of that apply the contraints specified in the snd_soc_pcm_stream structs. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Takashi iwai <tiwai@suse.de> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/soc-pcm.c')
-rw-r--r--sound/soc/soc-pcm.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 9441e17d1147..11a90cd027fa 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -148,12 +148,12 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream,
148 } 148 }
149} 149}
150 150
151static void soc_pcm_init_runtime_hw(struct snd_pcm_hardware *hw, 151static void soc_pcm_init_runtime_hw(struct snd_pcm_runtime *runtime,
152 struct snd_soc_pcm_stream *codec_stream, 152 struct snd_soc_pcm_stream *codec_stream,
153 struct snd_soc_pcm_stream *cpu_stream) 153 struct snd_soc_pcm_stream *cpu_stream)
154{ 154{
155 hw->rate_min = max(codec_stream->rate_min, cpu_stream->rate_min); 155 struct snd_pcm_hardware *hw = &runtime->hw;
156 hw->rate_max = min_not_zero(codec_stream->rate_max, cpu_stream->rate_max); 156
157 hw->channels_min = max(codec_stream->channels_min, 157 hw->channels_min = max(codec_stream->channels_min,
158 cpu_stream->channels_min); 158 cpu_stream->channels_min);
159 hw->channels_max = min(codec_stream->channels_max, 159 hw->channels_max = min(codec_stream->channels_max,
@@ -166,6 +166,13 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_hardware *hw,
166 if (cpu_stream->rates 166 if (cpu_stream->rates
167 & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS)) 167 & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))
168 hw->rates |= codec_stream->rates; 168 hw->rates |= codec_stream->rates;
169
170 snd_pcm_limit_hw_rates(runtime);
171
172 hw->rate_min = max(hw->rate_min, cpu_stream->rate_min);
173 hw->rate_min = max(hw->rate_min, codec_stream->rate_min);
174 hw->rate_max = min_not_zero(hw->rate_max, cpu_stream->rate_max);
175 hw->rate_max = min_not_zero(hw->rate_max, codec_stream->rate_max);
169} 176}
170 177
171/* 178/*
@@ -235,15 +242,14 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
235 242
236 /* Check that the codec and cpu DAIs are compatible */ 243 /* Check that the codec and cpu DAIs are compatible */
237 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 244 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
238 soc_pcm_init_runtime_hw(&runtime->hw, &codec_dai_drv->playback, 245 soc_pcm_init_runtime_hw(runtime, &codec_dai_drv->playback,
239 &cpu_dai_drv->playback); 246 &cpu_dai_drv->playback);
240 } else { 247 } else {
241 soc_pcm_init_runtime_hw(&runtime->hw, &codec_dai_drv->capture, 248 soc_pcm_init_runtime_hw(runtime, &codec_dai_drv->capture,
242 &cpu_dai_drv->capture); 249 &cpu_dai_drv->capture);
243 } 250 }
244 251
245 ret = -EINVAL; 252 ret = -EINVAL;
246 snd_pcm_limit_hw_rates(runtime);
247 if (!runtime->hw.rates) { 253 if (!runtime->hw.rates) {
248 printk(KERN_ERR "ASoC: %s <-> %s No matching rates\n", 254 printk(KERN_ERR "ASoC: %s <-> %s No matching rates\n",
249 codec_dai->name, cpu_dai->name); 255 codec_dai->name, cpu_dai->name);