From 0caaa1153248d4c67a20fb3abba6cef9de570424 Mon Sep 17 00:00:00 2001 From: Cosmin-Gabriel Samoila Date: Wed, 24 Jan 2018 10:39:22 +0200 Subject: MLK-15071: ASoC: codecs: AK5558: Remove unsuported rates and channels Support only even number of channels greater than 2 and rates multiple of 8000. Signed-off-by: Cosmin-Gabriel Samoila Reviewed-by: Daniel Baluta --- sound/soc/fsl/imx-ak5558.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'sound/soc/fsl/imx-ak5558.c') diff --git a/sound/soc/fsl/imx-ak5558.c b/sound/soc/fsl/imx-ak5558.c index 9d936e25d6a3..b436c8908be7 100644 --- a/sound/soc/fsl/imx-ak5558.c +++ b/sound/soc/fsl/imx-ak5558.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "../codecs/ak5558.h" @@ -30,6 +31,15 @@ static struct snd_soc_dapm_widget imx_ak5558_dapm_widgets[] = { SND_SOC_DAPM_LINE("Line In", NULL), }; +static const u32 ak5558_rates[] = { + 8000, 16000, 32000, + 48000, 96000, 192000, +}; + +static const u32 ak5558_channels[] = { + 1, 2, 4, 6, 8, +}; + static int imx_aif_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -68,8 +78,34 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream, return ret; } +static int imx_aif_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + static struct snd_pcm_hw_constraint_list constraint_rates; + static struct snd_pcm_hw_constraint_list constraint_channels; + int ret; + + constraint_rates.list = ak5558_rates; + constraint_rates.count = ARRAY_SIZE(ak5558_rates); + + ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + &constraint_rates); + if (ret) + return ret; + + constraint_channels.list = ak5558_channels; + constraint_channels.count = ARRAY_SIZE(ak5558_channels); + ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraint_channels); + if (ret) + return ret; + + return 0; +} + static struct snd_soc_ops imx_aif_ops = { .hw_params = imx_aif_hw_params, + .startup = imx_aif_startup, }; static struct snd_soc_dai_link imx_ak5558_dai = { -- cgit v1.2.3