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>
This commit is contained in:

committed by
Mark Brown

parent
3f901a028f
commit
c8dd1fec47
@@ -284,15 +284,10 @@ static int sample_sizes[] = {
|
|||||||
24, 32,
|
24, 32,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void soc_pcm_apply_msb(struct snd_pcm_substream *substream,
|
static void soc_pcm_set_msb(struct snd_pcm_substream *substream,
|
||||||
struct snd_soc_dai *dai)
|
struct snd_soc_dai *dai, int bits)
|
||||||
{
|
{
|
||||||
int ret, i, bits;
|
int ret, i;
|
||||||
|
|
||||||
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
|
|
||||||
bits = dai->driver->playback.sig_bits;
|
|
||||||
else
|
|
||||||
bits = dai->driver->capture.sig_bits;
|
|
||||||
|
|
||||||
if (!bits)
|
if (!bits)
|
||||||
return;
|
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,
|
static void soc_pcm_init_runtime_hw(struct snd_pcm_runtime *runtime,
|
||||||
struct snd_soc_pcm_stream *codec_stream,
|
struct snd_soc_pcm_stream *codec_stream,
|
||||||
struct snd_soc_pcm_stream *cpu_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;
|
goto config_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
soc_pcm_apply_msb(substream, codec_dai);
|
soc_pcm_apply_msb(substream);
|
||||||
soc_pcm_apply_msb(substream, cpu_dai);
|
|
||||||
|
|
||||||
/* Symmetry only applies if we've already got an active stream. */
|
/* Symmetry only applies if we've already got an active stream. */
|
||||||
if (cpu_dai->active) {
|
if (cpu_dai->active) {
|
||||||
|
Reference in New Issue
Block a user