[PATCH v2 1/2] ASoC: intel: atom: Add period size constraint
Brent Lu
brent.lu at intel.com
Thu Jul 30 10:13:34 CEST 2020
Use constraint to enforce the period sizes which are validated in
Android BSP.
Signed-off-by: Brent Lu <brent.lu at intel.com>
---
sound/soc/intel/atom/sst-mfld-platform-pcm.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
index 49b9f18..70100ef 100644
--- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
@@ -300,6 +300,16 @@ static void power_down_sst(struct sst_runtime_stream *stream)
stream->ops->power(sst->dev, false);
}
+static const unsigned int media_period_size[] = {
+ /* sizes validated on Android platform */
+ 240, 320, 960, 3072,
+};
+
+static const struct snd_pcm_hw_constraint_list constraints_media_period_size = {
+ .count = ARRAY_SIZE(media_period_size),
+ .list = media_period_size,
+};
+
static int sst_media_open(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
@@ -333,6 +343,11 @@ static int sst_media_open(struct snd_pcm_substream *substream,
if (ret_val < 0)
return ret_val;
+ /* Avoid using period size which is not validated */
+ snd_pcm_hw_constraint_list(substream->runtime, 0,
+ SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
+ &constraints_media_period_size);
+
/* Make sure, that the period size is always even */
snd_pcm_hw_constraint_step(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_PERIODS, 2);
--
2.7.4
More information about the Alsa-devel
mailing list