MLK-13975: ASoC: fsl: amix: eliminate unsupported rates

Eliminate unsupported rates for SAI MCLK frequency = 24576000.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
This commit is contained in:
Viorel Suman
2017-08-07 16:56:06 +03:00
committed by Jason Liu
parent 00a21311fd
commit 51400a4f20

View File

@ -23,6 +23,7 @@ struct imx_amix {
struct snd_soc_card card;
struct platform_device *amix_pdev;
struct platform_device *out_pdev;
unsigned int mclk_freq;
int num_dai;
struct snd_soc_dai_link *dai;
int num_dai_conf;
@ -47,6 +48,31 @@ static void imx_amix_be_shutdown(struct snd_pcm_substream *substream)
pm_runtime_put_sync(&priv->out_pdev->dev);
}
static const u32 imx_amix_rates[] = {
8000, 12000, 16000, 24000, 32000, 48000, 64000, 96000,
};
static const struct snd_pcm_hw_constraint_list imx_amix_rate_constraints = {
.count = ARRAY_SIZE(imx_amix_rates),
.list = imx_amix_rates,
};
static int imx_amix_fe_startup(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct imx_amix *priv = snd_soc_card_get_drvdata(rtd->card);
struct snd_pcm_runtime *runtime = substream->runtime;
struct device *dev = rtd->card->dev;
if (priv->mclk_freq == 24576000) {
return snd_pcm_hw_constraint_list(runtime, 0,
SNDRV_PCM_HW_PARAM_RATE, &imx_amix_rate_constraints);
} else
dev_warn(dev, "mclk may be not supported %d\n", priv->mclk_freq);
return 0;
}
static int imx_amix_fe_prepare(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *be_rtd;
@ -137,6 +163,7 @@ static const struct snd_soc_pcm_stream amix_params = {
};
static struct snd_soc_ops imx_amix_fe_ops = {
.startup = imx_amix_fe_startup,
.prepare = imx_amix_fe_prepare,
.shutdown = imx_amix_fe_shutdown,
.hw_params = imx_amix_fe_hw_params,
@ -159,6 +186,7 @@ static int imx_amix_probe(struct platform_device *pdev)
int i, num_dai, ret;
const char *fe_name_pref = "HiFi-AMIX-FE-";
char *dai_name;
struct clk *cpu_mclk;
num_dai = of_count_phandle_with_args(np, "dais", NULL);
if (num_dai != FSL_AMIX_MAX_DAIS) {
@ -265,6 +293,13 @@ static int imx_amix_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to find SAI platform device\n");
return -EINVAL;
}
cpu_mclk = devm_clk_get(&cpu_pdev->dev, "mclk1");
if (IS_ERR(cpu_mclk)) {
ret = PTR_ERR(cpu_mclk);
dev_err(&cpu_pdev->dev, "failed to get DAI mclk1: %d\n", ret);
return -EINVAL;
}
priv->mclk_freq = clk_get_rate(cpu_mclk);
/* Add AMIX Backend */
priv->dai[num_dai].name = "HiFi-AMIX-BE";