diff options
author | Benoit Cousson <bcousson@baylibre.com> | 2014-07-01 03:47:55 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-07-01 13:20:07 -0400 |
commit | c8dd1fec47d0b1875f292c40bed381b343e38b40 (patch) | |
tree | 1ae3ea4a2057e10fa8cb2a31404ce467b2f953e4 /sound/soc/soc-pcm.c | |
parent | 3f901a028feb916d17d6c01b9010f3f56f675d26 (diff) |
ASoC: pcm: Refactor soc_pcm_apply_msb for multicodecs
Refactor the function to facilitate the migration to
multiple codecs.
Fix a trailing space in the header as well.
No functional change.
Signed-off-by: Benoit Cousson <bcousson@baylibre.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/soc-pcm.c')
-rw-r--r-- | sound/soc/soc-pcm.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 54d18f22a33e..320a904b6b69 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Copyright (C) 2010 Texas Instruments Inc. | 7 | * Copyright (C) 2010 Texas Instruments Inc. |
8 | * | 8 | * |
9 | * Authors: Liam Girdwood <lrg@ti.com> | 9 | * Authors: Liam Girdwood <lrg@ti.com> |
10 | * Mark Brown <broonie@opensource.wolfsonmicro.com> | 10 | * Mark Brown <broonie@opensource.wolfsonmicro.com> |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or modify it | 12 | * This program is free software; you can redistribute it and/or modify it |
13 | * under the terms of the GNU General Public License as published by the | 13 | * under the terms of the GNU General Public License as published by the |
@@ -284,15 +284,10 @@ static int sample_sizes[] = { | |||
284 | 24, 32, | 284 | 24, 32, |
285 | }; | 285 | }; |
286 | 286 | ||
287 | static void soc_pcm_apply_msb(struct snd_pcm_substream *substream, | 287 | static void soc_pcm_set_msb(struct snd_pcm_substream *substream, |
288 | struct snd_soc_dai *dai) | 288 | struct snd_soc_dai *dai, int bits) |
289 | { | 289 | { |
290 | int ret, i, bits; | 290 | int ret, i; |
291 | |||
292 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
293 | bits = dai->driver->playback.sig_bits; | ||
294 | else | ||
295 | bits = dai->driver->capture.sig_bits; | ||
296 | 291 | ||
297 | if (!bits) | 292 | if (!bits) |
298 | return; | 293 | return; |
@@ -310,6 +305,25 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream, | |||
310 | } | 305 | } |
311 | } | 306 | } |
312 | 307 | ||
308 | static void soc_pcm_apply_msb(struct snd_pcm_substream *substream) | ||
309 | { | ||
310 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
311 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
312 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
313 | unsigned int bits = 0, cpu_bits; | ||
314 | |||
315 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
316 | bits = codec_dai->driver->playback.sig_bits; | ||
317 | cpu_bits = cpu_dai->driver->playback.sig_bits; | ||
318 | } else { | ||
319 | bits = codec_dai->driver->capture.sig_bits; | ||
320 | cpu_bits = cpu_dai->driver->capture.sig_bits; | ||
321 | } | ||
322 | |||
323 | soc_pcm_set_msb(substream, codec_dai, bits); | ||
324 | soc_pcm_set_msb(substream, cpu_dai, cpu_bits); | ||
325 | } | ||
326 | |||
313 | static void soc_pcm_init_runtime_hw(struct snd_pcm_runtime *runtime, | 327 | static void soc_pcm_init_runtime_hw(struct snd_pcm_runtime *runtime, |
314 | struct snd_soc_pcm_stream *codec_stream, | 328 | struct snd_soc_pcm_stream *codec_stream, |
315 | struct snd_soc_pcm_stream *cpu_stream) | 329 | struct snd_soc_pcm_stream *cpu_stream) |
@@ -433,8 +447,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
433 | goto config_err; | 447 | goto config_err; |
434 | } | 448 | } |
435 | 449 | ||
436 | soc_pcm_apply_msb(substream, codec_dai); | 450 | soc_pcm_apply_msb(substream); |
437 | soc_pcm_apply_msb(substream, cpu_dai); | ||
438 | 451 | ||
439 | /* Symmetry only applies if we've already got an active stream. */ | 452 | /* Symmetry only applies if we've already got an active stream. */ |
440 | if (cpu_dai->active) { | 453 | if (cpu_dai->active) { |