summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorViorel Suman <viorel.suman@nxp.com>2018-06-27 13:07:35 +0300
committerDong Aisheng <aisheng.dong@nxp.com>2019-11-25 15:50:38 +0800
commit7b9d5a62771eea52a13a875019b4a06818c1d718 (patch)
treecf135990951dabacf17db89d997e688397e59c11 /sound
parente5c4922c52e9f2254d97da0d16ac9141b185633d (diff)
MLK-18682-3: ASoC: imx-ak: enable both 8k and 11k range of rates
SAI interface now is able to change at runtime the pll parent of the master clock, so enable both 8k and 11k range of rates for AK codecs. Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/fsl/imx-ak4458.c25
-rw-r--r--sound/soc/fsl/imx-ak4497.c29
-rw-r--r--sound/soc/fsl/imx-ak5558.c31
3 files changed, 24 insertions, 61 deletions
diff --git a/sound/soc/fsl/imx-ak4458.c b/sound/soc/fsl/imx-ak4458.c
index 2c8c55dac408..83086fb61e62 100644
--- a/sound/soc/fsl/imx-ak4458.c
+++ b/sound/soc/fsl/imx-ak4458.c
@@ -31,7 +31,6 @@ struct imx_ak4458_data {
struct snd_soc_codec_conf *codec_conf;
bool tdm_mode;
int pdn_gpio;
- unsigned long freq;
unsigned int slots;
unsigned int slot_width;
};
@@ -54,8 +53,8 @@ static const struct imx_ak4458_fs_mul fs_mul[] = {
{ .min = 8000, .max = 48000, .mul = 1024 }, /* Normal */
{ .min = 88200, .max = 96000, .mul = 512 }, /* Double */
{ .min = 176400, .max = 192000, .mul = 256 }, /* Quad */
- { .min = 384000, .max = 384000, .mul = 128 }, /* Oct */
- { .min = 768000, .max = 768000, .mul = 64 }, /* Hex */
+ { .min = 352800, .max = 384000, .mul = 128 }, /* Oct */
+ { .min = 705600, .max = 768000, .mul = 64 }, /* Hex */
};
static const struct imx_ak4458_fs_mul fs_mul_tdm[] = {
@@ -70,9 +69,10 @@ static const struct imx_ak4458_fs_mul fs_mul_tdm[] = {
};
static const u32 ak4458_rates[] = {
- 8000, 16000, 32000,
- 48000, 96000, 192000,
- 384000, 768000,
+ 8000, 11025, 16000, 22050,
+ 32000, 44100, 48000, 88200,
+ 96000, 176400, 192000, 352800,
+ 384000, 705600, 768000,
};
static const u32 ak4458_rates_tdm[] = {
@@ -96,7 +96,7 @@ static unsigned long ak4458_get_mclk_rate(struct snd_pcm_substream *substream,
unsigned int rate = params_rate(params);
int i;
int mode;
- unsigned int freq = data->freq;
+ unsigned int freq = 0; /* Let DAI manage clk frequency by default */
if (data->tdm_mode) {
/* can be 128, 256 or 512 */
@@ -263,10 +263,8 @@ static int imx_ak4458_probe(struct platform_device *pdev)
struct imx_ak4458_data *priv;
struct device_node *cpu_np, *codec_np_0 = NULL, *codec_np_1 = NULL;
struct platform_device *cpu_pdev;
- struct clk *mclk;
int ret;
-
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
@@ -346,15 +344,6 @@ static int imx_ak4458_probe(struct platform_device *pdev)
usleep_range(1000, 2000);
}
- mclk = devm_clk_get(&cpu_pdev->dev, "mclk1");
- if (IS_ERR(mclk)) {
- ret = PTR_ERR(mclk);
- dev_err(&pdev->dev, "failed to get DAI mclk1: %d\n", ret);
- return -EINVAL;
- }
-
- priv->freq = clk_get_rate(mclk);
-
ret = snd_soc_of_parse_card_name(&priv->card, "model");
if (ret)
goto fail;
diff --git a/sound/soc/fsl/imx-ak4497.c b/sound/soc/fsl/imx-ak4497.c
index 71dee45ce40f..2d098dc0cddf 100644
--- a/sound/soc/fsl/imx-ak4497.c
+++ b/sound/soc/fsl/imx-ak4497.c
@@ -25,7 +25,6 @@
struct imx_ak4497_data {
struct snd_soc_card card;
- unsigned long freq;
};
static struct snd_soc_dapm_widget imx_ak4497_dapm_widgets[] = {
@@ -68,22 +67,17 @@ static bool imx_ak4497_is_dsd(struct snd_pcm_hw_params *params)
static unsigned long imx_ak4497_compute_freq(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct imx_ak4497_data *priv = snd_soc_card_get_drvdata(rtd->card);
unsigned int rate = params_rate(params);
int i;
- if (imx_ak4497_is_dsd(params))
- return priv->freq;
-
/* Find the appropriate MCLK freq */
for (i = 0; i < ARRAY_SIZE(fs_mul); i++) {
if (rate >= fs_mul[i].min && rate <= fs_mul[i].max)
- return params_rate(params) * fs_mul[i].mul;
+ return rate * fs_mul[i].mul;
}
- /* Return default MCLK frequency */
- return priv->freq;
+ /* Let DAI manage MCLK frequency */
+ return 0;
}
static int imx_aif_hw_params(struct snd_pcm_substream *substream,
@@ -139,9 +133,10 @@ static int imx_aif_hw_params(struct snd_pcm_substream *substream,
}
static const u32 support_rates[] = {
- 11025, 22050, 44100,
- 88200, 176400, 352800,
- 705600, 1411200, 2822400,
+ 8000, 11025, 16000, 22050,
+ 32000, 44100, 48000, 88200,
+ 96000, 176400, 192000, 352800,
+ 384000, 705600, 768000,
};
static int imx_aif_startup(struct snd_pcm_substream *substream)
@@ -179,7 +174,6 @@ static int imx_ak4497_probe(struct platform_device *pdev)
struct imx_ak4497_data *priv;
struct device_node *cpu_np, *codec_np = NULL;
struct platform_device *cpu_pdev;
- struct clk *mclk;
int ret;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
@@ -219,15 +213,6 @@ static int imx_ak4497_probe(struct platform_device *pdev)
priv->card.dapm_widgets = imx_ak4497_dapm_widgets;
priv->card.num_dapm_widgets = ARRAY_SIZE(imx_ak4497_dapm_widgets);
- mclk = devm_clk_get(&cpu_pdev->dev, "mclk1");
- if (IS_ERR_OR_NULL(mclk)) {
- dev_err(&pdev->dev, "failed to get DAI mclk1\n");
- ret = -EINVAL;
- goto fail;
- }
-
- priv->freq = clk_get_rate(mclk);
-
ret = snd_soc_of_parse_card_name(&priv->card, "model");
if (ret)
goto fail;
diff --git a/sound/soc/fsl/imx-ak5558.c b/sound/soc/fsl/imx-ak5558.c
index 84cd2e92a5c7..2c4e974a1b4c 100644
--- a/sound/soc/fsl/imx-ak5558.c
+++ b/sound/soc/fsl/imx-ak5558.c
@@ -28,7 +28,6 @@
struct imx_ak5558_data {
struct snd_soc_card card;
bool tdm_mode;
- unsigned long freq;
unsigned long slots;
unsigned long slot_width;
};
@@ -50,11 +49,11 @@ struct imx_ak5558_fs_mul {
*/
static const struct imx_ak5558_fs_mul fs_mul[] = {
{ .min = 8000, .max = 32000, .mul = 1024 },
- { .min = 48000, .max = 48000, .mul = 512 },
- { .min = 96000, .max = 96000, .mul = 256 },
- { .min = 192000, .max = 192000, .mul = 128 },
- { .min = 384000, .max = 384000, .mul = 2 * 64 },
- { .min = 768000, .max = 768000, .mul = 2 * 32 },
+ { .min = 44100, .max = 48000, .mul = 512 },
+ { .min = 88200, .max = 96000, .mul = 256 },
+ { .min = 176400, .max = 192000, .mul = 128 },
+ { .min = 352800, .max = 384000, .mul = 2*64 },
+ { .min = 705600, .max = 768000, .mul = 2*32 },
};
/*
@@ -73,9 +72,10 @@ static struct snd_soc_dapm_widget imx_ak5558_dapm_widgets[] = {
};
static const u32 ak5558_rates[] = {
- 8000, 16000, 32000,
- 48000, 96000, 192000,
- 384000, 768000,
+ 8000, 11025, 16000, 22050,
+ 32000, 44100, 48000, 88200,
+ 96000, 176400, 192000, 352800,
+ 384000, 705600, 768000,
};
static const u32 ak5558_tdm_rates[] = {
@@ -93,7 +93,7 @@ static unsigned long ak5558_get_mclk_rate(struct snd_pcm_substream *substream,
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct imx_ak5558_data *data = snd_soc_card_get_drvdata(rtd->card);
unsigned int rate = params_rate(params);
- unsigned int freq = data->freq;
+ unsigned int freq = 0; /* Let DAI manage clk frequency by default */
int mode;
int i;
@@ -248,10 +248,8 @@ static int imx_ak5558_probe(struct platform_device *pdev)
struct imx_ak5558_data *priv;
struct device_node *cpu_np, *codec_np = NULL;
struct platform_device *cpu_pdev;
- struct clk *mclk;
int ret;
-
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
@@ -292,15 +290,6 @@ static int imx_ak5558_probe(struct platform_device *pdev)
priv->card.dapm_widgets = imx_ak5558_dapm_widgets;
priv->card.num_dapm_widgets = ARRAY_SIZE(imx_ak5558_dapm_widgets);
- mclk = devm_clk_get(&cpu_pdev->dev, "mclk1");
- if (IS_ERR(mclk)) {
- ret = PTR_ERR(mclk);
- dev_err(&pdev->dev, "failed to get DAI mclk1: %d\n", ret);
- return -EINVAL;
- }
-
- priv->freq = clk_get_rate(mclk);
-
ret = snd_soc_of_parse_card_name(&priv->card, "model");
if (ret)
goto fail;