diff mbox

[v4,2/8] ASoC: pcm: Refactor soc_pcm_apply_msb for multicodecs

Message ID 1404200881-32253-3-git-send-email-bcousson@baylibre.com (mailing list archive)
State Accepted
Commit c8dd1fec47d0b1875f292c40bed381b343e38b40
Headers show

Commit Message

Benoit Cousson July 1, 2014, 7:47 a.m. UTC
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>
---
 sound/soc/soc-pcm.c | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

Comments

Mark Brown July 1, 2014, 5:20 p.m. UTC | #1
On Tue, Jul 01, 2014 at 09:47:55AM +0200, Benoit Cousson wrote:
> Refactor the function to facilitate the migration to
> multiple codecs.

Applied, thanks.

> Fix a trailing space in the header as well.

Please don't do things like this if they're not in a part of the code
being changed, it makes review a bit harder.  A separate patch would be
fine.
Benoit Cousson July 1, 2014, 5:31 p.m. UTC | #2
On 01/07/2014 19:20, Mark Brown wrote:
> On Tue, Jul 01, 2014 at 09:47:55AM +0200, Benoit Cousson wrote:
>> Refactor the function to facilitate the migration to
>> multiple codecs.
>
> Applied, thanks.
>
>> Fix a trailing space in the header as well.
>
> Please don't do things like this if they're not in a part of the code
> being changed, it makes review a bit harder.  A separate patch would be
> fine.

OK, sorry about that. I'll not do it again.

Thanks,
Benoit
diff mbox

Patch

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 094676a..ab0712e 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -7,7 +7,7 @@ 
  * Copyright (C) 2010 Texas Instruments Inc.
  *
  * Authors: Liam Girdwood <lrg@ti.com>
- *          Mark Brown <broonie@opensource.wolfsonmicro.com>       
+ *          Mark Brown <broonie@opensource.wolfsonmicro.com>
  *
  *  This program is free software; you can redistribute  it and/or modify it
  *  under  the terms of  the GNU General  Public License as published by the
@@ -284,15 +284,10 @@  static int sample_sizes[] = {
 	24, 32,
 };
 
-static void soc_pcm_apply_msb(struct snd_pcm_substream *substream,
-			      struct snd_soc_dai *dai)
+static void soc_pcm_set_msb(struct snd_pcm_substream *substream,
+			    struct snd_soc_dai *dai, int bits)
 {
-	int ret, i, bits;
-
-	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-		bits = dai->driver->playback.sig_bits;
-	else
-		bits = dai->driver->capture.sig_bits;
+	int ret, i;
 
 	if (!bits)
 		return;
@@ -310,6 +305,25 @@  static void soc_pcm_apply_msb(struct snd_pcm_substream *substream,
 	}
 }
 
+static void soc_pcm_apply_msb(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	unsigned int bits = 0, cpu_bits;
+
+	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+		bits = codec_dai->driver->playback.sig_bits;
+		cpu_bits = cpu_dai->driver->playback.sig_bits;
+	} else {
+		bits = codec_dai->driver->capture.sig_bits;
+		cpu_bits = cpu_dai->driver->capture.sig_bits;
+	}
+
+	soc_pcm_set_msb(substream, codec_dai, bits);
+	soc_pcm_set_msb(substream, cpu_dai, cpu_bits);
+}
+
 static void soc_pcm_init_runtime_hw(struct snd_pcm_runtime *runtime,
 	struct snd_soc_pcm_stream *codec_stream,
 	struct snd_soc_pcm_stream *cpu_stream)
@@ -433,8 +447,7 @@  static int soc_pcm_open(struct snd_pcm_substream *substream)
 		goto config_err;
 	}
 
-	soc_pcm_apply_msb(substream, codec_dai);
-	soc_pcm_apply_msb(substream, cpu_dai);
+	soc_pcm_apply_msb(substream);
 
 	/* Symmetry only applies if we've already got an active stream. */
 	if (cpu_dai->active) {