summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorShengjiu Wang <b02247@freescale.com>2014-05-13 15:22:10 +0800
committerShengjiu Wang <b02247@freescale.com>2014-05-13 17:47:46 +0800
commitf70599478297a350f4074d2bb1218fb8c42b172a (patch)
tree8bc99a2df626041eb19b93e10ef3d066d19c4328 /sound
parentb9d8007b7b1b32f386c82958d5740ed9424b013a (diff)
ENGR00313280-1 ASoC: fsl: refine cs42888 machine driver
Move rate constraint from codec driver to machine driver. Because fe and be use same runtime structure, so be needn't startup function. Signed-off-by: Shengjiu Wang <b02247@freescale.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/cs42888.c23
-rw-r--r--sound/soc/fsl/imx-cs42888.c56
2 files changed, 40 insertions, 39 deletions
diff --git a/sound/soc/codecs/cs42888.c b/sound/soc/codecs/cs42888.c
index f64591bac681..24b68a4de234 100644
--- a/sound/soc/codecs/cs42888.c
+++ b/sound/soc/codecs/cs42888.c
@@ -1,6 +1,6 @@
/*
* cs42888.c -- CS42888 ALSA SoC Audio Driver
- * Copyright (C) 2010-2013 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2010-2014 Freescale Semiconductor, Inc. All Rights Reserved.
*/
/*
* The code contained herein is licensed under the GNU General Public
@@ -802,27 +802,6 @@ static int cs42888_i2c_probe(struct i2c_client *i2c_client,
}
cs42888->mclk = clk_get_rate(cs42888->clk);
- switch (cs42888->mclk) {
- case 24576000:
- cs42888_dai.playback.rates = SNDRV_PCM_RATE_48000 |
- SNDRV_PCM_RATE_96000 |
- SNDRV_PCM_RATE_192000;
- cs42888_dai.capture.rates = SNDRV_PCM_RATE_48000 |
- SNDRV_PCM_RATE_96000 |
- SNDRV_PCM_RATE_192000;
- break;
- case 16934400:
- cs42888_dai.playback.rates = SNDRV_PCM_RATE_44100 |
- SNDRV_PCM_RATE_88200 |
- SNDRV_PCM_RATE_176400;
- cs42888_dai.capture.rates = SNDRV_PCM_RATE_44100 |
- SNDRV_PCM_RATE_88200 |
- SNDRV_PCM_RATE_176400;
- break;
- default:
- dev_err(&i2c_client->dev, "codec mclk is not supported %d\n", cs42888->mclk);
- break;
- }
ret = snd_soc_register_codec(&i2c_client->dev,
&cs42888_driver, &cs42888_dai, 1);
diff --git a/sound/soc/fsl/imx-cs42888.c b/sound/soc/fsl/imx-cs42888.c
index b8d7b747ba5f..3750cd917465 100644
--- a/sound/soc/fsl/imx-cs42888.c
+++ b/sound/soc/fsl/imx-cs42888.c
@@ -31,12 +31,12 @@
#define CODEC_CLK_EXTER_OSC 1
#define CODEC_CLK_ESAI_HCKT 2
+#define SUPPORT_RATE_NUM 10
struct imx_priv {
int fe_p2p_rate;
int fe_p2p_width;
unsigned int mclk_freq;
- unsigned int codec_mclk;
struct platform_device *pdev;
};
@@ -71,10 +71,47 @@ static int imx_cs42888_surround_hw_params(struct snd_pcm_substream *substream,
return 0;
}
+static int imx_cs42888_surround_startup(struct snd_pcm_substream *substream)
+{
+ struct snd_pcm_runtime *runtime = substream->runtime;
+ static struct snd_pcm_hw_constraint_list constraint_rates;
+ struct imx_priv *priv = &card_priv;
+ struct device *dev = &priv->pdev->dev;
+ static u32 support_rates[SUPPORT_RATE_NUM];
+ int ret;
+
+ if (priv->mclk_freq == 24576000) {
+ support_rates[0] = 48000;
+ support_rates[1] = 96000;
+ support_rates[2] = 192000;
+ constraint_rates.list = support_rates;
+ constraint_rates.count = 3;
+
+ ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
+ &constraint_rates);
+ if (ret)
+ return ret;
+ } else
+ dev_warn(dev, "mclk may be not supported %d\n", priv->mclk_freq);
+
+ return 0;
+}
+
static struct snd_soc_ops imx_cs42888_surround_ops = {
+ .startup = imx_cs42888_surround_startup,
+ .hw_params = imx_cs42888_surround_hw_params,
+};
+
+/**
+ * imx_cs42888_surround_startup() is to set constrain for hw parameter, but
+ * backend use same runtime as frontend, for p2p backend need to use different
+ * parameter, so backend can't use the startup.
+ */
+static struct snd_soc_ops imx_cs42888_surround_ops_be = {
.hw_params = imx_cs42888_surround_hw_params,
};
+
static const struct snd_soc_dapm_widget imx_cs42888_dapm_widgets[] = {
SND_SOC_DAPM_LINE("Line Out Jack", NULL),
SND_SOC_DAPM_LINE("Line In Jack", NULL),
@@ -137,7 +174,7 @@ static struct snd_soc_dai_link imx_cs42888_dai[] = {
.codec_dai_name = "CS42888",
.platform_name = "snd-soc-dummy",
.no_pcm = 1,
- .ops = &imx_cs42888_surround_ops,
+ .ops = &imx_cs42888_surround_ops_be,
.be_hw_params_fixup = be_hw_params_fixup,
},
};
@@ -163,7 +200,6 @@ static int imx_cs42888_probe(struct platform_device *pdev)
struct i2c_client *codec_dev;
struct imx_priv *priv = &card_priv;
struct clk *codec_clk = NULL;
- const char *mclk_name;
int ret;
priv->pdev = pdev;
@@ -231,20 +267,6 @@ static int imx_cs42888_probe(struct platform_device *pdev)
}
priv->mclk_freq = clk_get_rate(codec_clk);
- ret = of_property_read_string(codec_np, "clock-names", &mclk_name);
- if (ret) {
- dev_err(&pdev->dev, "%s: failed to get mclk source\n", __func__);
- goto fail;
- }
- if (!strcmp(mclk_name, "codec_osc"))
- priv->codec_mclk = CODEC_CLK_EXTER_OSC;
- else if (!strcmp(mclk_name, "esai_extal"))
- priv->codec_mclk = CODEC_CLK_ESAI_HCKT;
- else {
- dev_err(&pdev->dev, "mclk source is not correct %s\n", mclk_name);
- goto fail;
- }
-
snd_soc_card_imx_cs42888.dev = &pdev->dev;
platform_set_drvdata(pdev, &snd_soc_card_imx_cs42888);