aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/fsl
diff options
context:
space:
mode:
authorShengjiu Wang <b02247@freescale.com>2014-05-13 03:22:10 -0400
committerShengjiu Wang <b02247@freescale.com>2014-05-13 05:47:46 -0400
commitf70599478297a350f4074d2bb1218fb8c42b172a (patch)
tree8bc99a2df626041eb19b93e10ef3d066d19c4328 /sound/soc/fsl
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/soc/fsl')
-rw-r--r--sound/soc/fsl/imx-cs42888.c56
1 files changed, 39 insertions, 17 deletions
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 @@
31 31
32#define CODEC_CLK_EXTER_OSC 1 32#define CODEC_CLK_EXTER_OSC 1
33#define CODEC_CLK_ESAI_HCKT 2 33#define CODEC_CLK_ESAI_HCKT 2
34#define SUPPORT_RATE_NUM 10
34 35
35struct imx_priv { 36struct imx_priv {
36 int fe_p2p_rate; 37 int fe_p2p_rate;
37 int fe_p2p_width; 38 int fe_p2p_width;
38 unsigned int mclk_freq; 39 unsigned int mclk_freq;
39 unsigned int codec_mclk;
40 struct platform_device *pdev; 40 struct platform_device *pdev;
41}; 41};
42 42
@@ -71,10 +71,47 @@ static int imx_cs42888_surround_hw_params(struct snd_pcm_substream *substream,
71 return 0; 71 return 0;
72} 72}
73 73
74static int imx_cs42888_surround_startup(struct snd_pcm_substream *substream)
75{
76 struct snd_pcm_runtime *runtime = substream->runtime;
77 static struct snd_pcm_hw_constraint_list constraint_rates;
78 struct imx_priv *priv = &card_priv;
79 struct device *dev = &priv->pdev->dev;
80 static u32 support_rates[SUPPORT_RATE_NUM];
81 int ret;
82
83 if (priv->mclk_freq == 24576000) {
84 support_rates[0] = 48000;
85 support_rates[1] = 96000;
86 support_rates[2] = 192000;
87 constraint_rates.list = support_rates;
88 constraint_rates.count = 3;
89
90 ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
91 &constraint_rates);
92 if (ret)
93 return ret;
94 } else
95 dev_warn(dev, "mclk may be not supported %d\n", priv->mclk_freq);
96
97 return 0;
98}
99
74static struct snd_soc_ops imx_cs42888_surround_ops = { 100static struct snd_soc_ops imx_cs42888_surround_ops = {
101 .startup = imx_cs42888_surround_startup,
102 .hw_params = imx_cs42888_surround_hw_params,
103};
104
105/**
106 * imx_cs42888_surround_startup() is to set constrain for hw parameter, but
107 * backend use same runtime as frontend, for p2p backend need to use different
108 * parameter, so backend can't use the startup.
109 */
110static struct snd_soc_ops imx_cs42888_surround_ops_be = {
75 .hw_params = imx_cs42888_surround_hw_params, 111 .hw_params = imx_cs42888_surround_hw_params,
76}; 112};
77 113
114
78static const struct snd_soc_dapm_widget imx_cs42888_dapm_widgets[] = { 115static const struct snd_soc_dapm_widget imx_cs42888_dapm_widgets[] = {
79 SND_SOC_DAPM_LINE("Line Out Jack", NULL), 116 SND_SOC_DAPM_LINE("Line Out Jack", NULL),
80 SND_SOC_DAPM_LINE("Line In Jack", NULL), 117 SND_SOC_DAPM_LINE("Line In Jack", NULL),
@@ -137,7 +174,7 @@ static struct snd_soc_dai_link imx_cs42888_dai[] = {
137 .codec_dai_name = "CS42888", 174 .codec_dai_name = "CS42888",
138 .platform_name = "snd-soc-dummy", 175 .platform_name = "snd-soc-dummy",
139 .no_pcm = 1, 176 .no_pcm = 1,
140 .ops = &imx_cs42888_surround_ops, 177 .ops = &imx_cs42888_surround_ops_be,
141 .be_hw_params_fixup = be_hw_params_fixup, 178 .be_hw_params_fixup = be_hw_params_fixup,
142 }, 179 },
143}; 180};
@@ -163,7 +200,6 @@ static int imx_cs42888_probe(struct platform_device *pdev)
163 struct i2c_client *codec_dev; 200 struct i2c_client *codec_dev;
164 struct imx_priv *priv = &card_priv; 201 struct imx_priv *priv = &card_priv;
165 struct clk *codec_clk = NULL; 202 struct clk *codec_clk = NULL;
166 const char *mclk_name;
167 int ret; 203 int ret;
168 204
169 priv->pdev = pdev; 205 priv->pdev = pdev;
@@ -231,20 +267,6 @@ static int imx_cs42888_probe(struct platform_device *pdev)
231 } 267 }
232 priv->mclk_freq = clk_get_rate(codec_clk); 268 priv->mclk_freq = clk_get_rate(codec_clk);
233 269
234 ret = of_property_read_string(codec_np, "clock-names", &mclk_name);
235 if (ret) {
236 dev_err(&pdev->dev, "%s: failed to get mclk source\n", __func__);
237 goto fail;
238 }
239 if (!strcmp(mclk_name, "codec_osc"))
240 priv->codec_mclk = CODEC_CLK_EXTER_OSC;
241 else if (!strcmp(mclk_name, "esai_extal"))
242 priv->codec_mclk = CODEC_CLK_ESAI_HCKT;
243 else {
244 dev_err(&pdev->dev, "mclk source is not correct %s\n", mclk_name);
245 goto fail;
246 }
247
248 snd_soc_card_imx_cs42888.dev = &pdev->dev; 270 snd_soc_card_imx_cs42888.dev = &pdev->dev;
249 271
250 platform_set_drvdata(pdev, &snd_soc_card_imx_cs42888); 272 platform_set_drvdata(pdev, &snd_soc_card_imx_cs42888);