Lines Matching refs:codec

58 	struct snd_soc_codec *codec;  member
1481 static int wm8962_dsp2_write_config(struct snd_soc_codec *codec) in wm8962_dsp2_write_config() argument
1483 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_dsp2_write_config()
1489 static int wm8962_dsp2_set_enable(struct snd_soc_codec *codec, u16 val) in wm8962_dsp2_set_enable() argument
1491 u16 adcl = snd_soc_read(codec, WM8962_LEFT_ADC_VOLUME); in wm8962_dsp2_set_enable()
1492 u16 adcr = snd_soc_read(codec, WM8962_RIGHT_ADC_VOLUME); in wm8962_dsp2_set_enable()
1493 u16 dac = snd_soc_read(codec, WM8962_ADC_DAC_CONTROL_1); in wm8962_dsp2_set_enable()
1496 snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, 0); in wm8962_dsp2_set_enable()
1497 snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, WM8962_ADC_VU); in wm8962_dsp2_set_enable()
1498 snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, in wm8962_dsp2_set_enable()
1501 snd_soc_write(codec, WM8962_SOUNDSTAGE_ENABLES_0, val); in wm8962_dsp2_set_enable()
1504 snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, adcl); in wm8962_dsp2_set_enable()
1505 snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, adcr); in wm8962_dsp2_set_enable()
1506 snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, in wm8962_dsp2_set_enable()
1512 static int wm8962_dsp2_start(struct snd_soc_codec *codec) in wm8962_dsp2_start() argument
1514 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_dsp2_start()
1516 wm8962_dsp2_write_config(codec); in wm8962_dsp2_start()
1518 snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_RUNR); in wm8962_dsp2_start()
1520 wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena); in wm8962_dsp2_start()
1525 static int wm8962_dsp2_stop(struct snd_soc_codec *codec) in wm8962_dsp2_stop() argument
1527 wm8962_dsp2_set_enable(codec, 0); in wm8962_dsp2_stop()
1529 snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_STOP); in wm8962_dsp2_stop()
1556 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); in wm8962_dsp2_ena_get() local
1557 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_dsp2_ena_get()
1568 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); in wm8962_dsp2_ena_put() local
1569 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_dsp2_ena_put()
1572 int dsp2_running = snd_soc_read(codec, WM8962_DSP2_POWER_MANAGEMENT) & in wm8962_dsp2_ena_put()
1589 wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena); in wm8962_dsp2_ena_put()
1591 wm8962_dsp2_stop(codec); in wm8962_dsp2_ena_put()
1606 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); in wm8962_put_hp_sw() local
1615 ret = snd_soc_read(codec, WM8962_PWR_MGMT_2); in wm8962_put_hp_sw()
1617 snd_soc_write(codec, WM8962_HPOUTL_VOLUME, in wm8962_put_hp_sw()
1618 snd_soc_read(codec, WM8962_HPOUTL_VOLUME)); in wm8962_put_hp_sw()
1624 snd_soc_write(codec, WM8962_HPOUTR_VOLUME, in wm8962_put_hp_sw()
1625 snd_soc_read(codec, WM8962_HPOUTR_VOLUME)); in wm8962_put_hp_sw()
1636 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); in wm8962_put_spk_sw() local
1645 ret = snd_soc_read(codec, WM8962_PWR_MGMT_2); in wm8962_put_spk_sw()
1647 snd_soc_write(codec, WM8962_SPKOUTL_VOLUME, in wm8962_put_spk_sw()
1648 snd_soc_read(codec, WM8962_SPKOUTL_VOLUME)); in wm8962_put_spk_sw()
1654 snd_soc_write(codec, WM8962_SPKOUTR_VOLUME, in wm8962_put_spk_sw()
1655 snd_soc_read(codec, WM8962_SPKOUTR_VOLUME)); in wm8962_put_spk_sw()
1869 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in hp_event() local
1877 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1882 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1887 snd_soc_update_bits(codec, WM8962_DC_SERVO_1, in hp_event()
1899 reg = snd_soc_read(codec, WM8962_DC_SERVO_6); in hp_event()
1901 dev_err(codec->dev, in hp_event()
1906 dev_dbg(codec->dev, "DCS status: %x\n", reg); in hp_event()
1910 dev_err(codec->dev, "DC servo timed out\n"); in hp_event()
1912 dev_dbg(codec->dev, "DC servo complete after %dms\n", in hp_event()
1915 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1922 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1930 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1936 snd_soc_update_bits(codec, WM8962_DC_SERVO_1, in hp_event()
1942 snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, in hp_event()
1963 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in out_pga_event() local
1986 return snd_soc_write(codec, reg, snd_soc_read(codec, reg)); in out_pga_event()
1996 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in dsp2_event() local
1997 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in dsp2_event()
2002 wm8962_dsp2_start(codec); in dsp2_event()
2007 wm8962_dsp2_stop(codec); in dsp2_event()
2360 static int wm8962_add_widgets(struct snd_soc_codec *codec) in wm8962_add_widgets() argument
2362 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_add_widgets()
2364 struct snd_soc_dapm_context *dapm = &codec->dapm; in wm8962_add_widgets()
2366 snd_soc_add_codec_controls(codec, wm8962_snd_controls, in wm8962_add_widgets()
2369 snd_soc_add_codec_controls(codec, wm8962_spk_mono_controls, in wm8962_add_widgets()
2372 snd_soc_add_codec_controls(codec, wm8962_spk_stereo_controls, in wm8962_add_widgets()
2409 static void wm8962_configure_bclk(struct snd_soc_codec *codec) in wm8962_configure_bclk() argument
2411 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_configure_bclk()
2418 dev_dbg(codec->dev, "No SYSCLK configured\n"); in wm8962_configure_bclk()
2423 dev_dbg(codec->dev, "No audio clocks configured\n"); in wm8962_configure_bclk()
2435 dev_err(codec->dev, "Unsupported sysclk ratio %d\n", in wm8962_configure_bclk()
2440 dev_dbg(codec->dev, "Selected sysclk ratio %d\n", sysclk_rates[i]); in wm8962_configure_bclk()
2442 snd_soc_update_bits(codec, WM8962_CLOCKING_4, in wm8962_configure_bclk()
2449 if (codec->dapm.bias_level != SND_SOC_BIAS_ON) in wm8962_configure_bclk()
2450 snd_soc_update_bits(codec, WM8962_CLOCKING2, in wm8962_configure_bclk()
2453 dspclk = snd_soc_read(codec, WM8962_CLOCKING1); in wm8962_configure_bclk()
2455 if (codec->dapm.bias_level != SND_SOC_BIAS_ON) in wm8962_configure_bclk()
2456 snd_soc_update_bits(codec, WM8962_CLOCKING2, in wm8962_configure_bclk()
2460 dev_err(codec->dev, "Failed to read DSPCLK: %d\n", dspclk); in wm8962_configure_bclk()
2476 dev_warn(codec->dev, "Unknown DSPCLK divisor read back\n"); in wm8962_configure_bclk()
2480 dev_dbg(codec->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk); in wm8962_configure_bclk()
2488 dev_dbg(codec->dev, "Selected BCLK_DIV %d for %dHz\n", in wm8962_configure_bclk()
2495 dev_err(codec->dev, "Unsupported BCLK ratio %d\n", in wm8962_configure_bclk()
2501 dev_dbg(codec->dev, "Selected LRCLK divisor %d for %dHz\n", in wm8962_configure_bclk()
2504 snd_soc_update_bits(codec, WM8962_CLOCKING2, in wm8962_configure_bclk()
2506 snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_2, in wm8962_configure_bclk()
2510 static int wm8962_set_bias_level(struct snd_soc_codec *codec, in wm8962_set_bias_level() argument
2513 if (level == codec->dapm.bias_level) in wm8962_set_bias_level()
2522 snd_soc_update_bits(codec, WM8962_PWR_MGMT_1, in wm8962_set_bias_level()
2525 wm8962_configure_bclk(codec); in wm8962_set_bias_level()
2530 snd_soc_update_bits(codec, WM8962_PWR_MGMT_1, in wm8962_set_bias_level()
2533 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) in wm8962_set_bias_level()
2541 codec->dapm.bias_level = level; in wm8962_set_bias_level()
2566 struct snd_soc_codec *codec = dai->codec; in wm8962_hw_params() local
2567 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_hw_params()
2585 dev_err(codec->dev, "Unsupported rate %dHz\n", wm8962->lrclk); in wm8962_hw_params()
2608 snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0, in wm8962_hw_params()
2610 snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_3, in wm8962_hw_params()
2614 dev_dbg(codec->dev, "hw_params set BCLK %dHz LRCLK %dHz\n", in wm8962_hw_params()
2617 if (codec->dapm.bias_level == SND_SOC_BIAS_ON) in wm8962_hw_params()
2618 wm8962_configure_bclk(codec); in wm8962_hw_params()
2626 struct snd_soc_codec *codec = dai->codec; in wm8962_set_dai_sysclk() local
2627 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_set_dai_sysclk()
2643 snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_SRC_MASK, in wm8962_set_dai_sysclk()
2653 struct snd_soc_codec *codec = dai->codec; in wm8962_set_dai_fmt() local
2709 snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0, in wm8962_set_dai_fmt()
2819 static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, in wm8962_set_fll() argument
2822 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_set_fll()
2834 dev_dbg(codec->dev, "FLL disabled\n"); in wm8962_set_fll()
2839 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, in wm8962_set_fll()
2842 pm_runtime_put(codec->dev); in wm8962_set_fll()
2852 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); in wm8962_set_fll()
2861 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, in wm8962_set_fll()
2863 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_5, in wm8962_set_fll()
2867 dev_err(codec->dev, "Unknown FLL source %d\n", ret); in wm8962_set_fll()
2875 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); in wm8962_set_fll()
2877 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_2, in wm8962_set_fll()
2883 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_3, in wm8962_set_fll()
2886 snd_soc_write(codec, WM8962_FLL_CONTROL_6, fll_div.theta); in wm8962_set_fll()
2887 snd_soc_write(codec, WM8962_FLL_CONTROL_7, fll_div.lambda); in wm8962_set_fll()
2888 snd_soc_write(codec, WM8962_FLL_CONTROL_8, fll_div.n); in wm8962_set_fll()
2892 ret = pm_runtime_get_sync(codec->dev); in wm8962_set_fll()
2894 dev_err(codec->dev, "Failed to resume device: %d\n", ret); in wm8962_set_fll()
2898 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, in wm8962_set_fll()
2902 dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); in wm8962_set_fll()
2916 dev_err(codec->dev, "FLL lock timed out"); in wm8962_set_fll()
2917 snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, in wm8962_set_fll()
2919 pm_runtime_put(codec->dev); in wm8962_set_fll()
2932 struct snd_soc_codec *codec = dai->codec; in wm8962_mute() local
2944 ret = snd_soc_update_bits(codec, WM8962_CLASS_D_CONTROL_1, in wm8962_mute()
2949 return snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, in wm8962_mute()
2990 struct snd_soc_codec *codec = wm8962->codec; in wm8962_mic_work() local
2995 reg = snd_soc_read(codec, WM8962_ADDITIONAL_CONTROL_4); in wm8962_mic_work()
3010 snd_soc_update_bits(codec, WM8962_MICINT_SOURCE_POL, in wm8962_mic_work()
3118 int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) in wm8962_mic_detect() argument
3120 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_mic_detect()
3121 struct snd_soc_dapm_context *dapm = &codec->dapm; in wm8962_mic_detect()
3133 snd_soc_update_bits(codec, WM8962_INTERRUPT_STATUS_2_MASK, in wm8962_mic_detect()
3135 snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_4, in wm8962_mic_detect()
3166 struct snd_soc_codec *codec = wm8962->codec; in wm8962_beep_work() local
3167 struct snd_soc_dapm_context *dapm = &codec->dapm; in wm8962_beep_work()
3179 dev_dbg(codec->dev, "Set beep rate %dHz for requested %dHz\n", in wm8962_beep_work()
3186 dev_dbg(codec->dev, "Disabling beep\n"); in wm8962_beep_work()
3190 snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, in wm8962_beep_work()
3202 struct snd_soc_codec *codec = input_get_drvdata(dev); in wm8962_beep_event() local
3203 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_beep_event()
3205 dev_dbg(codec->dev, "Beep event %x %x\n", code, hz); in wm8962_beep_event()
3242 static void wm8962_init_beep(struct snd_soc_codec *codec) in wm8962_init_beep() argument
3244 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_init_beep()
3247 wm8962->beep = devm_input_allocate_device(codec->dev); in wm8962_init_beep()
3249 dev_err(codec->dev, "Failed to allocate beep device\n"); in wm8962_init_beep()
3257 wm8962->beep->phys = dev_name(codec->dev); in wm8962_init_beep()
3263 wm8962->beep->dev.parent = codec->dev; in wm8962_init_beep()
3264 input_set_drvdata(wm8962->beep, codec); in wm8962_init_beep()
3269 dev_err(codec->dev, "Failed to register beep device\n"); in wm8962_init_beep()
3272 ret = device_create_file(codec->dev, &dev_attr_beep); in wm8962_init_beep()
3274 dev_err(codec->dev, "Failed to create keyclick file: %d\n", in wm8962_init_beep()
3279 static void wm8962_free_beep(struct snd_soc_codec *codec) in wm8962_free_beep() argument
3281 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_free_beep()
3283 device_remove_file(codec->dev, &dev_attr_beep); in wm8962_free_beep()
3287 snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA,0); in wm8962_free_beep()
3347 struct snd_soc_codec *codec = wm8962->codec; in wm8962_gpio_set() local
3349 snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, in wm8962_gpio_set()
3357 struct snd_soc_codec *codec = wm8962->codec; in wm8962_gpio_direction_out() local
3363 ret = snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, in wm8962_gpio_direction_out()
3380 static void wm8962_init_gpio(struct snd_soc_codec *codec) in wm8962_init_gpio() argument
3382 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_init_gpio()
3388 wm8962->gpio_chip.dev = codec->dev; in wm8962_init_gpio()
3397 dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); in wm8962_init_gpio()
3400 static void wm8962_free_gpio(struct snd_soc_codec *codec) in wm8962_free_gpio() argument
3402 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_free_gpio()
3407 static void wm8962_init_gpio(struct snd_soc_codec *codec) in wm8962_init_gpio() argument
3411 static void wm8962_free_gpio(struct snd_soc_codec *codec) in wm8962_free_gpio() argument
3416 static int wm8962_probe(struct snd_soc_codec *codec) in wm8962_probe() argument
3419 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_probe()
3423 wm8962->codec = codec; in wm8962_probe()
3439 dev_err(codec->dev, in wm8962_probe()
3445 wm8962_add_widgets(codec); in wm8962_probe()
3451 switch (snd_soc_read(codec, WM8962_GPIO_BASE + i) in wm8962_probe()
3464 dev_dbg(codec->dev, "DMIC not in use, disabling\n"); in wm8962_probe()
3465 snd_soc_dapm_nc_pin(&codec->dapm, "DMICDAT"); in wm8962_probe()
3468 dev_warn(codec->dev, "DMIC GPIOs partially configured\n"); in wm8962_probe()
3470 wm8962_init_beep(codec); in wm8962_probe()
3471 wm8962_init_gpio(codec); in wm8962_probe()
3476 static int wm8962_remove(struct snd_soc_codec *codec) in wm8962_remove() argument
3478 struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); in wm8962_remove()
3483 wm8962_free_gpio(codec); in wm8962_remove()
3484 wm8962_free_beep(codec); in wm8962_remove()