Lines Matching refs:wm8904
2 * wm8904.c -- WM8904 ALSA SoC Audio driver
30 #include <sound/wm8904.h>
32 #include "wm8904.h"
616 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
625 switch (wm8904->sysclk_src) {
627 dev_dbg(codec->dev, "Using %dHz MCLK\n", wm8904->mclk_rate);
630 rate = wm8904->mclk_rate;
639 wm8904->fll_fout);
642 rate = wm8904->fll_fout;
653 wm8904->sysclk_rate = rate / 2;
656 wm8904->sysclk_rate = rate;
665 dev_dbg(codec->dev, "CLK_SYS is %dHz\n", wm8904->sysclk_rate);
672 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
673 struct wm8904_pdata *pdata = wm8904->pdata;
681 pdata->drc_cfgs[wm8904->drc_cfg].regs[i]);
692 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
693 struct wm8904_pdata *pdata = wm8904->pdata;
699 wm8904->drc_cfg = value;
710 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
712 ucontrol->value.enumerated.item[0] = wm8904->drc_cfg;
719 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
720 struct wm8904_pdata *pdata = wm8904->pdata;
723 if (!pdata || !wm8904->num_retune_mobile_texts)
728 cfg = wm8904->retune_mobile_cfg;
733 wm8904->retune_mobile_texts[cfg]) == 0 &&
735 - wm8904->fs) < best_val) {
738 - wm8904->fs);
745 wm8904->fs);
763 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
764 struct wm8904_pdata *pdata = wm8904->pdata;
770 wm8904->retune_mobile_cfg = value;
781 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
783 ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg;
792 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
798 if (wm8904->deemph) {
801 if (abs(deemph_settings[i] - wm8904->fs) <
802 abs(deemph_settings[best] - wm8904->fs))
821 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
823 ucontrol->value.enumerated.item[0] = wm8904->deemph;
831 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
837 wm8904->deemph = deemph;
947 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
956 switch (wm8904->sysclk_src) {
985 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
1046 if (wm8904->dcs_state[dcs_l] || wm8904->dcs_state[dcs_r]) {
1050 wm8904->dcs_state[dcs_l]);
1052 wm8904->dcs_state[dcs_r]);
1107 wm8904->dcs_state[dcs_l] = snd_soc_read(codec, dcs_l_reg);
1108 wm8904->dcs_state[dcs_r] = snd_soc_read(codec, dcs_r_reg);
1433 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
1440 switch (wm8904->devtype) {
1547 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
1556 wm8904->fs = params_rate(params);
1557 if (wm8904->tdm_slots) {
1559 wm8904->tdm_slots, wm8904->tdm_width);
1560 wm8904->bclk = snd_soc_calc_bclk(wm8904->fs,
1561 wm8904->tdm_width, 2,
1562 wm8904->tdm_slots);
1564 wm8904->bclk = snd_soc_params_to_bclk(params);
1584 dev_dbg(codec->dev, "Target BCLK is %dHz\n", wm8904->bclk);
1592 best_val = abs((wm8904->sysclk_rate / clk_sys_rates[0].ratio)
1593 - wm8904->fs);
1595 cur_val = abs((wm8904->sysclk_rate /
1596 clk_sys_rates[i].ratio) - wm8904->fs);;
1609 best_val = abs(wm8904->fs - sample_rates[0].rate);
1612 cur_val = abs(wm8904->fs - sample_rates[i].rate);
1624 if (wm8904->fs <= 24000)
1631 cur_val = ((wm8904->sysclk_rate * 10) / bclk_divs[i].div)
1632 - wm8904->bclk;
1640 wm8904->bclk = (wm8904->sysclk_rate * 10) / bclk_divs[best].div;
1642 bclk_divs[best].div, wm8904->bclk);
1646 dev_dbg(codec->dev, "LRCLK_RATE is %d\n", wm8904->bclk / wm8904->fs);
1647 aif3 |= wm8904->bclk / wm8904->fs;
1790 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
1825 wm8904->tdm_width = slot_width;
1826 wm8904->tdm_slots = slots / 2;
1947 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
1953 if (source == wm8904->fll_src && Fref == wm8904->fll_fref &&
1954 Fout == wm8904->fll_fout)
1962 wm8904->fll_fref = 0;
1963 wm8904->fll_fout = 0;
2064 wm8904->fll_fref = Fref;
2065 wm8904->fll_fout = Fout;
2066 wm8904->fll_src = source;
2099 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
2110 for (i = 1; i < ARRAY_SIZE(wm8904->reg_cache); i++) {
2114 if (wm8904->reg_cache[i] == wm8904_reg[i])
2117 snd_soc_write(codec, i, wm8904->reg_cache[i]);
2126 struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
2146 ret = regulator_bulk_enable(ARRAY_SIZE(wm8904->supplies),
2147 wm8904->supplies);
2200 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies),
2201 wm8904->supplies);
2268 static void wm8904_handle_retune_mobile_pdata(struct wm8904_priv *wm8904)
2270 struct snd_soc_codec *codec = &wm8904->codec;
2271 struct wm8904_pdata *pdata = wm8904->pdata;
2274 wm8904->retune_mobile_enum,
2284 wm8904->num_retune_mobile_texts = 0;
2285 wm8904->retune_mobile_texts = NULL;
2287 for (j = 0; j < wm8904->num_retune_mobile_texts; j++) {
2289 wm8904->retune_mobile_texts[j]) == 0)
2293 if (j != wm8904->num_retune_mobile_texts)
2297 t = krealloc(wm8904->retune_mobile_texts,
2299 (wm8904->num_retune_mobile_texts + 1),
2305 t[wm8904->num_retune_mobile_texts] =
2309 wm8904->num_retune_mobile_texts++;
2310 wm8904->retune_mobile_texts = t;
2314 wm8904->num_retune_mobile_texts);
2316 wm8904->retune_mobile_enum.max = wm8904->num_retune_mobile_texts;
2317 wm8904->retune_mobile_enum.texts = wm8904->retune_mobile_texts;
2319 ret = snd_soc_add_controls(&wm8904->codec, &control, 1);
2321 dev_err(wm8904->codec.dev,
2325 static void wm8904_handle_pdata(struct wm8904_priv *wm8904)
2327 struct snd_soc_codec *codec = &wm8904->codec;
2328 struct wm8904_pdata *pdata = wm8904->pdata;
2332 snd_soc_add_controls(&wm8904->codec, wm8904_eq_controls,
2341 SOC_ENUM_EXT("DRC Mode", wm8904->drc_enum,
2345 wm8904->drc_texts = kmalloc(sizeof(char *)
2347 if (!wm8904->drc_texts) {
2348 dev_err(wm8904->codec.dev,
2355 wm8904->drc_texts[i] = pdata->drc_cfgs[i].name;
2357 wm8904->drc_enum.max = pdata->num_drc_cfgs;
2358 wm8904->drc_enum.texts = wm8904->drc_texts;
2360 ret = snd_soc_add_controls(&wm8904->codec, &control, 1);
2362 dev_err(wm8904->codec.dev,
2372 wm8904_handle_retune_mobile_pdata(wm8904);
2374 snd_soc_add_controls(&wm8904->codec, wm8904_eq_controls,
2427 static int wm8904_register(struct wm8904_priv *wm8904,
2430 struct wm8904_pdata *pdata = wm8904->pdata;
2432 struct snd_soc_codec *codec = &wm8904->codec;
2445 snd_soc_codec_set_drvdata(codec, wm8904);
2453 codec->reg_cache = &wm8904->reg_cache;
2458 switch (wm8904->devtype) {
2466 wm8904->devtype);
2479 for (i = 0; i < ARRAY_SIZE(wm8904->supplies); i++)
2480 wm8904->supplies[i].supply = wm8904_supply_names[i];
2482 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8904->supplies),
2483 wm8904->supplies);
2489 ret = regulator_bulk_enable(ARRAY_SIZE(wm8904->supplies),
2490 wm8904->supplies);
2524 wm8904->reg_cache[WM8904_ADC_DIGITAL_VOLUME_LEFT] |= WM8904_ADC_VU;
2525 wm8904->reg_cache[WM8904_ADC_DIGITAL_VOLUME_RIGHT] |= WM8904_ADC_VU;
2526 wm8904->reg_cache[WM8904_DAC_DIGITAL_VOLUME_LEFT] |= WM8904_DAC_VU;
2527 wm8904->reg_cache[WM8904_DAC_DIGITAL_VOLUME_RIGHT] |= WM8904_DAC_VU;
2528 wm8904->reg_cache[WM8904_ANALOGUE_OUT1_LEFT] |= WM8904_HPOUT_VU |
2530 wm8904->reg_cache[WM8904_ANALOGUE_OUT1_RIGHT] |= WM8904_HPOUT_VU |
2532 wm8904->reg_cache[WM8904_ANALOGUE_OUT2_LEFT] |= WM8904_LINEOUT_VU |
2534 wm8904->reg_cache[WM8904_ANALOGUE_OUT2_RIGHT] |= WM8904_LINEOUT_VU |
2536 wm8904->reg_cache[WM8904_CLOCK_RATES_0] &= ~WM8904_SR_MODE;
2539 if (wm8904->pdata) {
2544 wm8904->reg_cache[WM8904_GPIO_CONTROL_1 + i]
2550 wm8904->reg_cache[WM8904_MIC_BIAS_CONTROL_0 + i]
2557 wm8904->reg_cache[WM8904_CLASS_W_0] |= WM8904_CP_DYN_PWR;
2560 wm8904->reg_cache[WM8904_BIAS_CONTROL_0] &= ~WM8904_POBCTRL;
2565 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies);
2586 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies);
2588 regulator_bulk_free(ARRAY_SIZE(wm8904->supplies), wm8904->supplies);
2590 kfree(wm8904);
2594 static void wm8904_unregister(struct wm8904_priv *wm8904)
2596 wm8904_set_bias_level(&wm8904->codec, SND_SOC_BIAS_OFF);
2597 regulator_bulk_free(ARRAY_SIZE(wm8904->supplies), wm8904->supplies);
2599 snd_soc_unregister_codec(&wm8904->codec);
2600 kfree(wm8904);
2608 struct wm8904_priv *wm8904;
2611 wm8904 = kzalloc(sizeof(struct wm8904_priv), GFP_KERNEL);
2612 if (wm8904 == NULL)
2615 codec = &wm8904->codec;
2618 wm8904->devtype = id->driver_data;
2620 i2c_set_clientdata(i2c, wm8904);
2622 wm8904->pdata = i2c->dev.platform_data;
2626 return wm8904_register(wm8904, SND_SOC_I2C);
2631 struct wm8904_priv *wm8904 = i2c_get_clientdata(client);
2632 wm8904_unregister(wm8904);
2637 { "wm8904", WM8904 },