summaryrefslogtreecommitdiff
path: root/sound/soc/fsl/imx-ak5558.c
diff options
context:
space:
mode:
authorCosmin-Gabriel Samoila <cosmin.samoila@nxp.com>2018-01-24 10:39:22 +0200
committerDong Aisheng <aisheng.dong@nxp.com>2019-11-25 15:50:28 +0800
commit0caaa1153248d4c67a20fb3abba6cef9de570424 (patch)
tree4ffb88df33c98d4ce2f47c76d981ef325a54ab67 /sound/soc/fsl/imx-ak5558.c
parent512a0da419af390b4c4c7379c7b5e4fc719057a9 (diff)
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 <cosmin.samoila@nxp.com> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Diffstat (limited to 'sound/soc/fsl/imx-ak5558.c')
-rw-r--r--sound/soc/fsl/imx-ak5558.c36
1 files changed, 36 insertions, 0 deletions
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 <linux/of_device.h>
#include <sound/soc.h>
#include <sound/pcm_params.h>
+#include <sound/pcm.h>
#include <sound/soc-dapm.h>
#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 = {