aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/fsl
diff options
context:
space:
mode:
authorShengjiu Wang <b02247@freescale.com>2014-05-07 06:02:15 -0400
committerShengjiu Wang <b02247@freescale.com>2014-05-07 06:35:16 -0400
commit84babc7fa0a56f6620f8b04a86baece620297dda (patch)
tree8208a064be324c37d2d53efddb90dd218f3719ba /sound/soc/fsl
parent45a269edfe110f6f23b272eac2b0a20b18d584de (diff)
ENGR00312217-1 ASoC: fsl: pop noise with wm8962
The reason of pop noise is that we change the sysclk in hw_free, which is for another wm8962 issue. So in currently the pop noise can't be resolved with no confliction. So for Android, because the samplerate is fixed. we can use other workaround for this issue: change the sysclk in the set_bias(). Signed-off-by: Shengjiu Wang <b02247@freescale.com>
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r--sound/soc/fsl/Kconfig7
-rw-r--r--sound/soc/fsl/imx-wm8962.c110
2 files changed, 117 insertions, 0 deletions
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 2b9f4bf0ae86..4a5063bf9882 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -215,6 +215,13 @@ config SND_SOC_IMX_WM8962
215 Say Y if you want to add support for SoC audio on an i.MX board with 215 Say Y if you want to add support for SoC audio on an i.MX board with
216 a wm8962 codec. 216 a wm8962 codec.
217 217
218config SND_SOC_IMX_WM8962_ANDROID
219 tristate "SoC Audio support for i.MX boards with wm8962 in android"
220 depends on SND_SOC_IMX_WM8962=y
221 help
222 Say Y if you want to add support for SoC audio on an i.MX board with
223 a wm8962 codec in android.
224
218config SND_SOC_IMX_SGTL5000 225config SND_SOC_IMX_SGTL5000
219 tristate "SoC Audio support for i.MX boards with sgtl5000" 226 tristate "SoC Audio support for i.MX boards with sgtl5000"
220 depends on OF && I2C 227 depends on OF && I2C
diff --git a/sound/soc/fsl/imx-wm8962.c b/sound/soc/fsl/imx-wm8962.c
index 66cb2df64032..c8345704df6f 100644
--- a/sound/soc/fsl/imx-wm8962.c
+++ b/sound/soc/fsl/imx-wm8962.c
@@ -56,6 +56,11 @@ struct imx_priv {
56}; 56};
57static struct imx_priv card_priv; 57static struct imx_priv card_priv;
58 58
59#ifdef CONFIG_SND_SOC_IMX_WM8962_ANDROID
60static int sample_rate = 44100;
61static snd_pcm_format_t sample_format = SNDRV_PCM_FORMAT_S16_LE;
62#endif
63
59static struct snd_soc_jack imx_hp_jack; 64static struct snd_soc_jack imx_hp_jack;
60static struct snd_soc_jack_pin imx_hp_jack_pins[] = { 65static struct snd_soc_jack_pin imx_hp_jack_pins[] = {
61 { 66 {
@@ -176,6 +181,107 @@ static const struct snd_soc_dapm_widget imx_wm8962_dapm_widgets[] = {
176 SND_SOC_DAPM_MIC("DMIC", NULL), 181 SND_SOC_DAPM_MIC("DMIC", NULL),
177}; 182};
178 183
184#ifdef CONFIG_SND_SOC_IMX_WM8962_ANDROID
185static int imx_hifi_hw_params(struct snd_pcm_substream *substream,
186 struct snd_pcm_hw_params *params)
187{
188 struct snd_soc_pcm_runtime *rtd = substream->private_data;
189 struct snd_soc_dai *codec_dai = rtd->codec_dai;
190 struct imx_priv *priv = &card_priv;
191 struct device *dev = &priv->pdev->dev;
192 u32 dai_format;
193 int ret = 0;
194
195 sample_rate = params_rate(params);
196 sample_format = params_format(params);
197
198 dai_format = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
199 SND_SOC_DAIFMT_CBM_CFM;
200
201 /* set codec DAI configuration */
202 ret = snd_soc_dai_set_fmt(codec_dai, dai_format);
203 if (ret) {
204 dev_err(dev, "failed to set codec dai fmt: %d\n", ret);
205 return ret;
206 }
207
208 return 0;
209}
210
211static struct snd_soc_ops imx_hifi_ops = {
212 .hw_params = imx_hifi_hw_params,
213};
214
215static int imx_wm8962_set_bias_level(struct snd_soc_card *card,
216 struct snd_soc_dapm_context *dapm,
217 enum snd_soc_bias_level level)
218{
219 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai;
220 struct imx_priv *priv = &card_priv;
221 struct imx_wm8962_data *data = snd_soc_card_get_drvdata(card);
222 struct device *dev = &priv->pdev->dev;
223 unsigned int pll_out;
224 int ret;
225
226 if (dapm->dev != codec_dai->dev)
227 return 0;
228
229 switch (level) {
230 case SND_SOC_BIAS_PREPARE:
231 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) {
232 if (sample_format == SNDRV_PCM_FORMAT_S24_LE)
233 pll_out = sample_rate * 384;
234 else
235 pll_out = sample_rate * 256;
236
237 ret = snd_soc_dai_set_pll(codec_dai, WM8962_FLL,
238 WM8962_FLL_MCLK, data->clk_frequency,
239 pll_out);
240 if (ret < 0) {
241 dev_err(dev, "failed to start FLL: %d\n", ret);
242 return ret;
243 }
244
245 ret = snd_soc_dai_set_sysclk(codec_dai,
246 WM8962_SYSCLK_FLL, pll_out,
247 SND_SOC_CLOCK_IN);
248 if (ret < 0) {
249 dev_err(dev, "failed to set SYSCLK: %d\n", ret);
250 return ret;
251 }
252 }
253 break;
254
255 case SND_SOC_BIAS_STANDBY:
256 if (dapm->bias_level == SND_SOC_BIAS_PREPARE) {
257 ret = snd_soc_dai_set_sysclk(codec_dai,
258 WM8962_SYSCLK_MCLK, data->clk_frequency,
259 SND_SOC_CLOCK_IN);
260 if (ret < 0) {
261 dev_err(dev,
262 "failed to switch away from FLL: %d\n",
263 ret);
264 return ret;
265 }
266
267 ret = snd_soc_dai_set_pll(codec_dai, WM8962_FLL,
268 0, 0, 0);
269 if (ret < 0) {
270 dev_err(dev, "failed to stop FLL: %d\n", ret);
271 return ret;
272 }
273 }
274 break;
275
276 default:
277 break;
278 }
279
280 return 0;
281}
282
283#else
284
179static int imx_hifi_hw_params(struct snd_pcm_substream *substream, 285static int imx_hifi_hw_params(struct snd_pcm_substream *substream,
180 struct snd_pcm_hw_params *params) 286 struct snd_pcm_hw_params *params)
181{ 287{
@@ -282,6 +388,7 @@ static struct snd_soc_ops imx_hifi_ops = {
282 .hw_params = imx_hifi_hw_params, 388 .hw_params = imx_hifi_hw_params,
283 .hw_free = imx_hifi_hw_free, 389 .hw_free = imx_hifi_hw_free,
284}; 390};
391#endif /* CONFIG_SND_SOC_IMX_WM8962_ANDROID */
285 392
286static int imx_wm8962_gpio_init(struct snd_soc_card *card) 393static int imx_wm8962_gpio_init(struct snd_soc_card *card)
287{ 394{
@@ -514,6 +621,9 @@ audmux_bypass:
514 621
515 data->card.late_probe = imx_wm8962_late_probe; 622 data->card.late_probe = imx_wm8962_late_probe;
516 623
624#ifdef CONFIG_SND_SOC_IMX_WM8962_ANDROID
625 data->card.set_bias_level = imx_wm8962_set_bias_level;
626#endif
517 platform_set_drvdata(pdev, &data->card); 627 platform_set_drvdata(pdev, &data->card);
518 snd_soc_card_set_drvdata(&data->card, data); 628 snd_soc_card_set_drvdata(&data->card, data);
519 629