Lines Matching refs:codec

58 	struct snd_soc_codec *codec;  member
1479 static int wm8962_dsp2_write_config(struct snd_soc_codec *codec) in wm8962_dsp2_write_config() argument
1481 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_dsp2_write_config()
1487 static int wm8962_dsp2_set_enable(struct snd_soc_codec *codec, u16 val) in wm8962_dsp2_set_enable() argument
1489 u16 adcl = snd_soc_read(codec, WM8962_LEFT_ADC_VOLUME); in wm8962_dsp2_set_enable()
1490 u16 adcr = snd_soc_read(codec, WM8962_RIGHT_ADC_VOLUME); in wm8962_dsp2_set_enable()
1491 u16 dac = snd_soc_read(codec, WM8962_ADC_DAC_CONTROL_1); in wm8962_dsp2_set_enable()
1494 snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, 0); in wm8962_dsp2_set_enable()
1495 snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, WM8962_ADC_VU); in wm8962_dsp2_set_enable()
1496 snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, in wm8962_dsp2_set_enable()
1499 snd_soc_write(codec, WM8962_SOUNDSTAGE_ENABLES_0, val); in wm8962_dsp2_set_enable()
1502 snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, adcl); in wm8962_dsp2_set_enable()
1503 snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, adcr); in wm8962_dsp2_set_enable()
1504 snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, in wm8962_dsp2_set_enable()
1510 static int wm8962_dsp2_start(struct snd_soc_codec *codec) in wm8962_dsp2_start() argument
1512 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_dsp2_start()
1514 wm8962_dsp2_write_config(codec); in wm8962_dsp2_start()
1516 snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_RUNR); in wm8962_dsp2_start()
1518 wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena); in wm8962_dsp2_start()
1523 static int wm8962_dsp2_stop(struct snd_soc_codec *codec) in wm8962_dsp2_stop() argument
1525 wm8962_dsp2_set_enable(codec, 0); in wm8962_dsp2_stop()
1527 snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_STOP); in wm8962_dsp2_stop()
1554 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); in wm8962_dsp2_ena_get() local
1555 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_dsp2_ena_get()
1566 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); in wm8962_dsp2_ena_put() local
1567 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_dsp2_ena_put()
1570 int dsp2_running = snd_soc_read(codec, WM8962_DSP2_POWER_MANAGEMENT) & in wm8962_dsp2_ena_put()
1587 wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena); in wm8962_dsp2_ena_put()
1589 wm8962_dsp2_stop(codec); in wm8962_dsp2_ena_put()
1604 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); in wm8962_put_hp_sw() local
1613 ret = snd_soc_read(codec, WM8962_PWR_MGMT_2); in wm8962_put_hp_sw()
1615 snd_soc_write(codec, WM8962_HPOUTL_VOLUME, in wm8962_put_hp_sw()
1616 snd_soc_read(codec, WM8962_HPOUTL_VOLUME)); in wm8962_put_hp_sw()
1622 snd_soc_write(codec, WM8962_HPOUTR_VOLUME, in wm8962_put_hp_sw()
1623 snd_soc_read(codec, WM8962_HPOUTR_VOLUME)); in wm8962_put_hp_sw()
1634 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); in wm8962_put_spk_sw() local
1643 ret = snd_soc_read(codec, WM8962_PWR_MGMT_2); in wm8962_put_spk_sw()
1645 snd_soc_write(codec, WM8962_SPKOUTL_VOLUME, in wm8962_put_spk_sw()
1646 snd_soc_read(codec, WM8962_SPKOUTL_VOLUME)); in wm8962_put_spk_sw()
1652 snd_soc_write(codec, WM8962_SPKOUTR_VOLUME, in wm8962_put_spk_sw()
1653 snd_soc_read(codec, WM8962_SPKOUTR_VOLUME)); in wm8962_put_spk_sw()
1867 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in hp_event() local
1875 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1880 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1885 snd_soc_update_bits(codec, WM8962_DC_SERVO_1, in hp_event()
1897 reg = snd_soc_read(codec, WM8962_DC_SERVO_6); in hp_event()
1899 dev_err(codec->dev, in hp_event()
1904 dev_dbg(codec->dev, "DCS status: %x\n", reg); in hp_event()
1908 dev_err(codec->dev, "DC servo timed out\n"); in hp_event()
1910 dev_dbg(codec->dev, "DC servo complete after %dms\n", in hp_event()
1913 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1920 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1928 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1934 snd_soc_update_bits(codec, WM8962_DC_SERVO_1, in hp_event()
1940 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1961 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in out_pga_event() local
1984 return snd_soc_write(codec, reg, snd_soc_read(codec, reg)); in out_pga_event()
1994 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in dsp2_event() local
1995 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in dsp2_event()
2000 wm8962_dsp2_start(codec); in dsp2_event()
2005 wm8962_dsp2_stop(codec); in dsp2_event()
2358 static int wm8962_add_widgets(struct snd_soc_codec *codec) in wm8962_add_widgets() argument
2360 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_add_widgets()
2362 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); in wm8962_add_widgets()
2364 snd_soc_add_codec_controls(codec, wm8962_snd_controls, in wm8962_add_widgets()
2367 snd_soc_add_codec_controls(codec, wm8962_spk_mono_controls, in wm8962_add_widgets()
2370 snd_soc_add_codec_controls(codec, wm8962_spk_stereo_controls, in wm8962_add_widgets()
2407 static void wm8962_configure_bclk(struct snd_soc_codec *codec) in wm8962_configure_bclk() argument
2409 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_configure_bclk()
2416 dev_dbg(codec->dev, "No SYSCLK configured\n"); in wm8962_configure_bclk()
2421 dev_dbg(codec->dev, "No audio clocks configured\n"); in wm8962_configure_bclk()
2433 dev_err(codec->dev, "Unsupported sysclk ratio %d\n", in wm8962_configure_bclk()
2438 dev_dbg(codec->dev, "Selected sysclk ratio %d\n", sysclk_rates[i]); in wm8962_configure_bclk()
2440 snd_soc_update_bits(codec, WM8962_CLOCKING_4, in wm8962_configure_bclk()
2447 if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_ON) in wm8962_configure_bclk()
2448 snd_soc_update_bits(codec, WM8962_CLOCKING2, in wm8962_configure_bclk()
2451 dspclk = snd_soc_read(codec, WM8962_CLOCKING1); in wm8962_configure_bclk()
2453 if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_ON) in wm8962_configure_bclk()
2454 snd_soc_update_bits(codec, WM8962_CLOCKING2, in wm8962_configure_bclk()
2458 dev_err(codec->dev, "Failed to read DSPCLK: %d\n", dspclk); in wm8962_configure_bclk()
2474 dev_warn(codec->dev, "Unknown DSPCLK divisor read back\n"); in wm8962_configure_bclk()
2478 dev_dbg(codec->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk); in wm8962_configure_bclk()
2486 dev_dbg(codec->dev, "Selected BCLK_DIV %d for %dHz\n", in wm8962_configure_bclk()
2493 dev_err(codec->dev, "Unsupported BCLK ratio %d\n", in wm8962_configure_bclk()
2499 dev_dbg(codec->dev, "Selected LRCLK divisor %d for %dHz\n", in wm8962_configure_bclk()
2502 snd_soc_update_bits(codec, WM8962_CLOCKING2, in wm8962_configure_bclk()
2504 snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_2, in wm8962_configure_bclk()
2508 static int wm8962_set_bias_level(struct snd_soc_codec *codec, in wm8962_set_bias_level() argument
2517 snd_soc_update_bits(codec, WM8962_PWR_MGMT_1, in wm8962_set_bias_level()
2520 wm8962_configure_bclk(codec); in wm8962_set_bias_level()
2525 snd_soc_update_bits(codec, WM8962_PWR_MGMT_1, in wm8962_set_bias_level()
2528 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) in wm8962_set_bias_level()
2560 struct snd_soc_codec *codec = dai->codec; in wm8962_hw_params() local
2561 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_hw_params()
2579 dev_err(codec->dev, "Unsupported rate %dHz\n", wm8962->lrclk); in wm8962_hw_params()
2602 snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0, in wm8962_hw_params()
2604 snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_3, in wm8962_hw_params()
2608 dev_dbg(codec->dev, "hw_params set BCLK %dHz LRCLK %dHz\n", in wm8962_hw_params()
2611 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) in wm8962_hw_params()
2612 wm8962_configure_bclk(codec); in wm8962_hw_params()
2620 struct snd_soc_codec *codec = dai->codec; in wm8962_set_dai_sysclk() local
2621 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_set_dai_sysclk()
2637 snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_SRC_MASK, in wm8962_set_dai_sysclk()
2647 struct snd_soc_codec *codec = dai->codec; in wm8962_set_dai_fmt() local
2703 snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0, in wm8962_set_dai_fmt()
2813 static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, in wm8962_set_fll() argument
2816 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_set_fll()
2828 dev_dbg(codec->dev, "FLL disabled\n"); in wm8962_set_fll()
2833 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, in wm8962_set_fll()
2836 pm_runtime_put(codec->dev); in wm8962_set_fll()
2846 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); in wm8962_set_fll()
2855 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, in wm8962_set_fll()
2857 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_5, in wm8962_set_fll()
2861 dev_err(codec->dev, "Unknown FLL source %d\n", ret); in wm8962_set_fll()
2869 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); in wm8962_set_fll()
2871 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_2, in wm8962_set_fll()
2877 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_3, in wm8962_set_fll()
2880 snd_soc_write(codec, WM8962_FLL_CONTROL_6, fll_div.theta); in wm8962_set_fll()
2881 snd_soc_write(codec, WM8962_FLL_CONTROL_7, fll_div.lambda); in wm8962_set_fll()
2882 snd_soc_write(codec, WM8962_FLL_CONTROL_8, fll_div.n); in wm8962_set_fll()
2886 ret = pm_runtime_get_sync(codec->dev); in wm8962_set_fll()
2888 dev_err(codec->dev, "Failed to resume device: %d\n", ret); in wm8962_set_fll()
2892 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, in wm8962_set_fll()
2896 dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); in wm8962_set_fll()
2910 dev_err(codec->dev, "FLL lock timed out"); in wm8962_set_fll()
2911 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, in wm8962_set_fll()
2913 pm_runtime_put(codec->dev); in wm8962_set_fll()
2926 struct snd_soc_codec *codec = dai->codec; in wm8962_mute() local
2938 ret = snd_soc_update_bits(codec, WM8962_CLASS_D_CONTROL_1, in wm8962_mute()
2943 return snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, in wm8962_mute()
2985 struct snd_soc_codec *codec = wm8962->codec; in wm8962_mic_work() local
2990 reg = snd_soc_read(codec, WM8962_ADDITIONAL_CONTROL_4); in wm8962_mic_work()
3005 snd_soc_update_bits(codec, WM8962_MICINT_SOURCE_POL, in wm8962_mic_work()
3113 int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) in wm8962_mic_detect() argument
3115 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_mic_detect()
3116 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); in wm8962_mic_detect()
3128 snd_soc_update_bits(codec, WM8962_INTERRUPT_STATUS_2_MASK, in wm8962_mic_detect()
3130 snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_4, in wm8962_mic_detect()
3161 struct snd_soc_codec *codec = wm8962->codec; in wm8962_beep_work() local
3162 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); in wm8962_beep_work()
3174 dev_dbg(codec->dev, "Set beep rate %dHz for requested %dHz\n", in wm8962_beep_work()
3181 dev_dbg(codec->dev, "Disabling beep\n"); in wm8962_beep_work()
3185 snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, in wm8962_beep_work()
3197 struct snd_soc_codec *codec = input_get_drvdata(dev); in wm8962_beep_event() local
3198 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_beep_event()
3200 dev_dbg(codec->dev, "Beep event %x %x\n", code, hz); in wm8962_beep_event()
3237 static void wm8962_init_beep(struct snd_soc_codec *codec) in wm8962_init_beep() argument
3239 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_init_beep()
3242 wm8962->beep = devm_input_allocate_device(codec->dev); in wm8962_init_beep()
3244 dev_err(codec->dev, "Failed to allocate beep device\n"); in wm8962_init_beep()
3252 wm8962->beep->phys = dev_name(codec->dev); in wm8962_init_beep()
3258 wm8962->beep->dev.parent = codec->dev; in wm8962_init_beep()
3259 input_set_drvdata(wm8962->beep, codec); in wm8962_init_beep()
3264 dev_err(codec->dev, "Failed to register beep device\n"); in wm8962_init_beep()
3267 ret = device_create_file(codec->dev, &dev_attr_beep); in wm8962_init_beep()
3269 dev_err(codec->dev, "Failed to create keyclick file: %d\n", in wm8962_init_beep()
3274 static void wm8962_free_beep(struct snd_soc_codec *codec) in wm8962_free_beep() argument
3276 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_free_beep()
3278 device_remove_file(codec->dev, &dev_attr_beep); in wm8962_free_beep()
3282 snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA,0); in wm8962_free_beep()
3342 struct snd_soc_codec *codec = wm8962->codec; in wm8962_gpio_set() local
3344 snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, in wm8962_gpio_set()
3352 struct snd_soc_codec *codec = wm8962->codec; in wm8962_gpio_direction_out() local
3358 ret = snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, in wm8962_gpio_direction_out()
3375 static void wm8962_init_gpio(struct snd_soc_codec *codec) in wm8962_init_gpio() argument
3377 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_init_gpio()
3383 wm8962->gpio_chip.dev = codec->dev; in wm8962_init_gpio()
3392 dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); in wm8962_init_gpio()
3395 static void wm8962_free_gpio(struct snd_soc_codec *codec) in wm8962_free_gpio() argument
3397 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_free_gpio()
3402 static void wm8962_init_gpio(struct snd_soc_codec *codec) in wm8962_init_gpio() argument
3406 static void wm8962_free_gpio(struct snd_soc_codec *codec) in wm8962_free_gpio() argument
3411 static int wm8962_probe(struct snd_soc_codec *codec) in wm8962_probe() argument
3413 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); in wm8962_probe()
3415 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_probe()
3419 wm8962->codec = codec; in wm8962_probe()
3435 dev_err(codec->dev, in wm8962_probe()
3441 wm8962_add_widgets(codec); in wm8962_probe()
3447 switch (snd_soc_read(codec, WM8962_GPIO_BASE + i) in wm8962_probe()
3460 dev_dbg(codec->dev, "DMIC not in use, disabling\n"); in wm8962_probe()
3464 dev_warn(codec->dev, "DMIC GPIOs partially configured\n"); in wm8962_probe()
3466 wm8962_init_beep(codec); in wm8962_probe()
3467 wm8962_init_gpio(codec); in wm8962_probe()
3472 static int wm8962_remove(struct snd_soc_codec *codec) in wm8962_remove() argument
3474 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_remove()
3479 wm8962_free_gpio(codec); in wm8962_remove()
3480 wm8962_free_beep(codec); in wm8962_remove()