aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-01-06 08:19:06 -0500
committerMark Brown <broonie@linaro.org>2014-01-06 12:36:48 -0500
commit08ae9b456d393dfd1bbe7619b994189be6a26449 (patch)
tree39590b477151db6577274947972754074ed9e9e3
parente41975edc73d2c16d0784e5fa87a6162e2fcab80 (diff)
ASoC: dpcm: Add helper function for initializing runtime pcm
We have the same code for initializing the runtime pcm on both the playback and the capture path. Factor this out into a common helper function. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/soc-pcm.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 10f29a0ad5a6..b649e32791df 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -1228,6 +1228,17 @@ unwind:
1228 return err; 1228 return err;
1229} 1229}
1230 1230
1231static void dpcm_init_runtime_hw(struct snd_pcm_runtime *runtime,
1232 struct snd_soc_pcm_stream *stream)
1233{
1234 runtime->hw.rate_min = stream->rate_min;
1235 runtime->hw.rate_max = stream->rate_max;
1236 runtime->hw.channels_min = stream->channels_min;
1237 runtime->hw.channels_max = stream->channels_max;
1238 runtime->hw.formats &= stream->formats;
1239 runtime->hw.rates = stream->rates;
1240}
1241
1231static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream) 1242static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream)
1232{ 1243{
1233 struct snd_pcm_runtime *runtime = substream->runtime; 1244 struct snd_pcm_runtime *runtime = substream->runtime;
@@ -1235,21 +1246,10 @@ static void dpcm_set_fe_runtime(struct snd_pcm_substream *substream)
1235 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 1246 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
1236 struct snd_soc_dai_driver *cpu_dai_drv = cpu_dai->driver; 1247 struct snd_soc_dai_driver *cpu_dai_drv = cpu_dai->driver;
1237 1248
1238 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 1249 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
1239 runtime->hw.rate_min = cpu_dai_drv->playback.rate_min; 1250 dpcm_init_runtime_hw(runtime, &cpu_dai_drv->playback);
1240 runtime->hw.rate_max = cpu_dai_drv->playback.rate_max; 1251 else
1241 runtime->hw.channels_min = cpu_dai_drv->playback.channels_min; 1252 dpcm_init_runtime_hw(runtime, &cpu_dai_drv->capture);
1242 runtime->hw.channels_max = cpu_dai_drv->playback.channels_max;
1243 runtime->hw.formats &= cpu_dai_drv->playback.formats;
1244 runtime->hw.rates = cpu_dai_drv->playback.rates;
1245 } else {
1246 runtime->hw.rate_min = cpu_dai_drv->capture.rate_min;
1247 runtime->hw.rate_max = cpu_dai_drv->capture.rate_max;
1248 runtime->hw.channels_min = cpu_dai_drv->capture.channels_min;
1249 runtime->hw.channels_max = cpu_dai_drv->capture.channels_max;
1250 runtime->hw.formats &= cpu_dai_drv->capture.formats;
1251 runtime->hw.rates = cpu_dai_drv->capture.rates;
1252 }
1253} 1253}
1254 1254
1255static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream) 1255static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream)