From b0a6cd7d6417ed337c041aec967c234266ce2ebf Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Jan 2012 18:38:51 +0000 Subject: [PATCH] --- yaml --- r: 293196 b: refs/heads/master c: 58ba9b25454fe9b6ded804f69cb7ed4500b685fc h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/sound/soc.h | 1 + trunk/sound/soc/soc-pcm.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 2ddbbff490a9..576abc8e8065 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 5f52ee48751e63ed555b56a82db446745f60bc82 +refs/heads/master: 58ba9b25454fe9b6ded804f69cb7ed4500b685fc diff --git a/trunk/include/sound/soc.h b/trunk/include/sound/soc.h index 0992dff55959..55381fca6e0d 100644 --- a/trunk/include/sound/soc.h +++ b/trunk/include/sound/soc.h @@ -505,6 +505,7 @@ struct snd_soc_pcm_stream { unsigned int rate_max; /* max rate */ unsigned int channels_min; /* min channels */ unsigned int channels_max; /* max channels */ + unsigned int sig_bits; /* number of bits of content */ }; /* SoC audio ops */ diff --git a/trunk/sound/soc/soc-pcm.c b/trunk/sound/soc/soc-pcm.c index cdc860a5ff37..8bb17937d59a 100644 --- a/trunk/sound/soc/soc-pcm.c +++ b/trunk/sound/soc/soc-pcm.c @@ -62,6 +62,39 @@ static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream, return 0; } +/* + * List of sample sizes that might go over the bus for parameter + * application. There ought to be a wildcard sample size for things + * like the DAC/ADC resolution to use but there isn't right now. + */ +static int sample_sizes[] = { + 8, 16, 24, 32, +}; + +static void soc_pcm_apply_msb(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + int ret, i, bits; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + bits = dai->driver->playback.sig_bits; + else + bits = dai->driver->capture.sig_bits; + + if (!bits) + return; + + for (i = 0; i < ARRAY_SIZE(sample_sizes); i++) { + ret = snd_pcm_hw_constraint_msbits(substream->runtime, + 0, sample_sizes[i], + bits); + if (ret != 0) + dev_warn(dai->dev, + "Failed to set MSB %d/%d: %d\n", + bits, sample_sizes[i], ret); + } +} + /* * Called by ALSA when a PCM substream is opened, the runtime->hw record is * then initialized and any private data can be allocated. This also calls @@ -187,6 +220,9 @@ 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); + /* Symmetry only applies if we've already got an active stream. */ if (cpu_dai->active) { ret = soc_pcm_apply_symmetry(substream, cpu_dai);