Lines Matching refs:codec
55 struct snd_soc_codec *codec; member
337 static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) in wm8996_set_retune_mobile() argument
339 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_set_retune_mobile()
349 if (snd_soc_read(codec, WM8996_POWER_MANAGEMENT_8) & in wm8996_set_retune_mobile()
357 if (snd_soc_read(codec, WM8996_POWER_MANAGEMENT_8) & in wm8996_set_retune_mobile()
383 dev_dbg(codec->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n", in wm8996_set_retune_mobile()
392 save = snd_soc_read(codec, base); in wm8996_set_retune_mobile()
396 snd_soc_update_bits(codec, base + i, 0xffff, in wm8996_set_retune_mobile()
399 snd_soc_update_bits(codec, base, WM8996_DSP1RX_EQ_ENA, save); in wm8996_set_retune_mobile()
415 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); in wm8996_put_retune_mobile_enum() local
416 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_put_retune_mobile_enum()
429 wm8996_set_retune_mobile(codec, block); in wm8996_put_retune_mobile_enum()
437 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); in wm8996_get_retune_mobile_enum() local
438 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_get_retune_mobile_enum()
577 static void wm8996_bg_enable(struct snd_soc_codec *codec) in wm8996_bg_enable() argument
579 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_bg_enable()
583 snd_soc_update_bits(codec, WM8996_POWER_MANAGEMENT_1, in wm8996_bg_enable()
589 static void wm8996_bg_disable(struct snd_soc_codec *codec) in wm8996_bg_disable() argument
591 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_bg_disable()
595 snd_soc_update_bits(codec, WM8996_POWER_MANAGEMENT_1, in wm8996_bg_disable()
602 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in bg_event() local
607 wm8996_bg_enable(codec); in bg_event()
610 wm8996_bg_disable(codec); in bg_event()
637 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in rmv_short_event() local
638 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in rmv_short_event()
656 static void wait_for_dc_servo(struct snd_soc_codec *codec, u16 mask) in wait_for_dc_servo() argument
658 struct i2c_client *i2c = to_i2c_client(codec->dev); in wait_for_dc_servo()
659 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wait_for_dc_servo()
663 snd_soc_write(codec, WM8996_DC_SERVO_2, mask); in wait_for_dc_servo()
671 dev_err(codec->dev, "DC servo timed out\n"); in wait_for_dc_servo()
678 ret = snd_soc_read(codec, WM8996_DC_SERVO_2); in wait_for_dc_servo()
679 dev_dbg(codec->dev, "DC servo state: %x\n", ret); in wait_for_dc_servo()
683 dev_err(codec->dev, "DC servo timed out for %x\n", mask); in wait_for_dc_servo()
685 dev_dbg(codec->dev, "DC servo complete for %x\n", mask); in wait_for_dc_servo()
691 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); in wm8996_seq_notifier() local
692 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_seq_notifier()
697 dev_dbg(codec->dev, "Starting DC servo for %x\n", in wm8996_seq_notifier()
701 wait_for_dc_servo(codec, wm8996->dcs_pending in wm8996_seq_notifier()
708 dev_dbg(codec->dev, "Applying RMV_SHORTs %x->%x\n", in wm8996_seq_notifier()
731 snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, mask, val); in wm8996_seq_notifier()
753 snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_2, mask, val); in wm8996_seq_notifier()
762 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in dcs_start() local
763 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in dcs_start()
1535 static void wm8996_update_bclk(struct snd_soc_codec *codec) in wm8996_update_bclk() argument
1537 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_update_bclk()
1567 dev_dbg(codec->dev, "Using BCLK_DIV %d for actual BCLK %dHz\n", in wm8996_update_bclk()
1570 snd_soc_update_bits(codec, bclk_reg, in wm8996_update_bclk()
1575 static int wm8996_set_bias_level(struct snd_soc_codec *codec, in wm8996_set_bias_level() argument
1578 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_set_bias_level()
1586 snd_soc_update_bits(codec, WM8996_MICBIAS_1, in wm8996_set_bias_level()
1588 snd_soc_update_bits(codec, WM8996_MICBIAS_2, in wm8996_set_bias_level()
1593 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { in wm8996_set_bias_level()
1597 dev_err(codec->dev, in wm8996_set_bias_level()
1614 snd_soc_update_bits(codec, WM8996_MICBIAS_1, in wm8996_set_bias_level()
1616 snd_soc_update_bits(codec, WM8996_MICBIAS_2, in wm8996_set_bias_level()
1631 codec->dapm.bias_level = level; in wm8996_set_bias_level()
1638 struct snd_soc_codec *codec = dai->codec; in wm8996_set_fmt() local
1715 snd_soc_update_bits(codec, aifctrl_reg, WM8996_AIF1_FMT_MASK, aifctrl); in wm8996_set_fmt()
1716 snd_soc_update_bits(codec, bclk_reg, in wm8996_set_fmt()
1719 snd_soc_update_bits(codec, lrclk_tx_reg, in wm8996_set_fmt()
1723 snd_soc_update_bits(codec, lrclk_rx_reg, in wm8996_set_fmt()
1739 struct snd_soc_codec *codec = dai->codec; in wm8996_hw_params() local
1740 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_hw_params()
1750 (snd_soc_read(codec, WM8996_GPIO_1)) & WM8996_GP1_FN_MASK) { in wm8996_hw_params()
1761 (snd_soc_read(codec, WM8996_GPIO_2)) & WM8996_GP2_FN_MASK) { in wm8996_hw_params()
1777 dev_err(codec->dev, "Unsupported BCLK rate: %d\n", bclk_rate); in wm8996_hw_params()
1798 wm8996_update_bclk(codec); in wm8996_hw_params()
1804 snd_soc_update_bits(codec, aifdata_reg, in wm8996_hw_params()
1808 snd_soc_update_bits(codec, lrclk_reg, WM8996_AIF1RX_RATE_MASK, in wm8996_hw_params()
1810 snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_2, in wm8996_hw_params()
1819 struct snd_soc_codec *codec = dai->codec; in wm8996_set_sysclk() local
1820 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_set_sysclk()
1831 old = snd_soc_read(codec, WM8996_AIF_CLOCKING_1) & WM8996_SYSCLK_ENA; in wm8996_set_sysclk()
1832 snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, in wm8996_set_sysclk()
1849 dev_err(codec->dev, "Unsupported clock source %d\n", clk_id); in wm8996_set_sysclk()
1856 snd_soc_update_bits(codec, WM8996_AIF_RATE, in wm8996_set_sysclk()
1865 snd_soc_update_bits(codec, WM8996_AIF_RATE, in wm8996_set_sysclk()
1874 dev_warn(codec->dev, "Unsupported clock rate %dHz\n", in wm8996_set_sysclk()
1879 wm8996_update_bclk(codec); in wm8996_set_sysclk()
1881 snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, in wm8996_set_sysclk()
1884 snd_soc_update_bits(codec, WM8996_CLOCKING_1, WM8996_LFCLK_ENA, lfclk); in wm8996_set_sysclk()
1885 snd_soc_update_bits(codec, WM8996_CONTROL_INTERFACE_1, in wm8996_set_sysclk()
1887 snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, in wm8996_set_sysclk()
2006 static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, in wm8996_set_fll() argument
2009 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_set_fll()
2010 struct i2c_client *i2c = to_i2c_client(codec->dev); in wm8996_set_fll()
2021 dev_dbg(codec->dev, "FLL disabled\n"); in wm8996_set_fll()
2026 snd_soc_update_bits(codec, WM8996_FLL_CONTROL_1, in wm8996_set_fll()
2029 wm8996_bg_disable(codec); in wm8996_set_fll()
2052 dev_err(codec->dev, "Unknown FLL source %d\n", ret); in wm8996_set_fll()
2059 snd_soc_update_bits(codec, WM8996_FLL_CONTROL_5, in wm8996_set_fll()
2068 snd_soc_write(codec, WM8996_FLL_EFS_2, reg); in wm8996_set_fll()
2070 snd_soc_update_bits(codec, WM8996_FLL_CONTROL_2, in wm8996_set_fll()
2076 snd_soc_write(codec, WM8996_FLL_CONTROL_3, fll_div.theta); in wm8996_set_fll()
2078 snd_soc_update_bits(codec, WM8996_FLL_CONTROL_4, in wm8996_set_fll()
2083 snd_soc_write(codec, WM8996_FLL_EFS_1, fll_div.lambda); in wm8996_set_fll()
2086 ret = snd_soc_read(codec, WM8996_FLL_CONTROL_1); in wm8996_set_fll()
2088 wm8996_bg_enable(codec); in wm8996_set_fll()
2093 snd_soc_update_bits(codec, WM8996_FLL_CONTROL_1, in wm8996_set_fll()
2099 snd_soc_write(codec, WM8996_FLL_CONTROL_6, WM8996_FLL_SWITCH_CLK); in wm8996_set_fll()
2125 ret = snd_soc_read(codec, WM8996_INTERRUPT_RAW_STATUS_2); in wm8996_set_fll()
2130 dev_err(codec->dev, "Timed out waiting for FLL\n"); in wm8996_set_fll()
2134 dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); in wm8996_set_fll()
2246 int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, in wm8996_detect() argument
2249 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_detect()
2250 struct snd_soc_dapm_context *dapm = &codec->dapm; in wm8996_detect()
2258 wm8996->polarity_cb(codec, 0); in wm8996_detect()
2261 snd_soc_update_bits(codec, WM8996_MICBIAS_1, in wm8996_detect()
2263 snd_soc_update_bits(codec, WM8996_MICBIAS_2, in wm8996_detect()
2277 snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, in wm8996_detect()
2281 snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, in wm8996_detect()
2286 snd_soc_update_bits(codec, WM8996_INTERRUPT_STATUS_2_MASK, in wm8996_detect()
2293 static void wm8996_hpdet_irq(struct snd_soc_codec *codec) in wm8996_hpdet_irq() argument
2295 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_hpdet_irq()
2303 reg = snd_soc_read(codec, WM8996_HEADPHONE_DETECT_2); in wm8996_hpdet_irq()
2305 dev_err(codec->dev, "Failed to read HPDET status\n"); in wm8996_hpdet_irq()
2310 dev_err(codec->dev, "Got HPDET IRQ but HPDET is busy\n"); in wm8996_hpdet_irq()
2316 dev_dbg(codec->dev, "HPDET measured %d ohms\n", val); in wm8996_hpdet_irq()
2336 if (!(snd_soc_read(codec, WM8996_POWER_MANAGEMENT_1) & in wm8996_hpdet_irq()
2338 snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, in wm8996_hpdet_irq()
2343 snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_1, in wm8996_hpdet_irq()
2345 snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, in wm8996_hpdet_irq()
2348 snd_soc_dapm_disable_pin(&codec->dapm, "Bandgap"); in wm8996_hpdet_irq()
2349 snd_soc_dapm_sync(&codec->dapm); in wm8996_hpdet_irq()
2352 static void wm8996_hpdet_start(struct snd_soc_codec *codec) in wm8996_hpdet_start() argument
2355 snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, in wm8996_hpdet_start()
2362 snd_soc_dapm_force_enable_pin(&codec->dapm, "Bandgap"); in wm8996_hpdet_start()
2363 snd_soc_dapm_sync(&codec->dapm); in wm8996_hpdet_start()
2366 snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, 0); in wm8996_hpdet_start()
2367 snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_1, in wm8996_hpdet_start()
2371 snd_soc_update_bits(codec, WM8996_HEADPHONE_DETECT_1, in wm8996_hpdet_start()
2375 static void wm8996_report_headphone(struct snd_soc_codec *codec) in wm8996_report_headphone() argument
2377 dev_dbg(codec->dev, "Headphone detected\n"); in wm8996_report_headphone()
2378 wm8996_hpdet_start(codec); in wm8996_report_headphone()
2381 snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, in wm8996_report_headphone()
2388 static void wm8996_micd(struct snd_soc_codec *codec) in wm8996_micd() argument
2390 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_micd()
2393 val = snd_soc_read(codec, WM8996_MIC_DETECT_3); in wm8996_micd()
2395 dev_dbg(codec->dev, "Microphone event: %x\n", val); in wm8996_micd()
2398 dev_warn(codec->dev, "Microphone detection state invalid\n"); in wm8996_micd()
2404 dev_dbg(codec->dev, "Jack removal detected\n"); in wm8996_micd()
2412 snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, in wm8996_micd()
2426 dev_dbg(codec->dev, "Microphone detected\n"); in wm8996_micd()
2428 wm8996_hpdet_start(codec); in wm8996_micd()
2432 snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, in wm8996_micd()
2438 dev_dbg(codec->dev, "Mic button up\n"); in wm8996_micd()
2455 wm8996_report_headphone(codec); in wm8996_micd()
2459 reg = snd_soc_read(codec, WM8996_ACCESSORY_DETECT_MODE_2); in wm8996_micd()
2462 snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_2, in wm8996_micd()
2467 wm8996->polarity_cb(codec, in wm8996_micd()
2470 dev_dbg(codec->dev, "Set microphone polarity to %d\n", in wm8996_micd()
2481 dev_dbg(codec->dev, "Mic button detected\n"); in wm8996_micd()
2485 wm8996_report_headphone(codec); in wm8996_micd()
2492 struct snd_soc_codec *codec = data; in wm8996_irq() local
2493 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_irq()
2496 irq_val = snd_soc_read(codec, WM8996_INTERRUPT_STATUS_2); in wm8996_irq()
2498 dev_err(codec->dev, "Failed to read IRQ status: %d\n", in wm8996_irq()
2502 irq_val &= ~snd_soc_read(codec, WM8996_INTERRUPT_STATUS_2_MASK); in wm8996_irq()
2507 snd_soc_write(codec, WM8996_INTERRUPT_STATUS_2, irq_val); in wm8996_irq()
2510 dev_dbg(codec->dev, "DC servo IRQ\n"); in wm8996_irq()
2515 dev_err(codec->dev, "Digital core FIFO error\n"); in wm8996_irq()
2518 dev_dbg(codec->dev, "FLL locked\n"); in wm8996_irq()
2523 wm8996_micd(codec); in wm8996_irq()
2526 wm8996_hpdet_irq(codec); in wm8996_irq()
2545 static void wm8996_retune_mobile_pdata(struct snd_soc_codec *codec) in wm8996_retune_mobile_pdata() argument
2547 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_retune_mobile_pdata()
2596 dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n", in wm8996_retune_mobile_pdata()
2602 ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls)); in wm8996_retune_mobile_pdata()
2604 dev_err(codec->dev, in wm8996_retune_mobile_pdata()
2620 static int wm8996_probe(struct snd_soc_codec *codec) in wm8996_probe() argument
2623 struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); in wm8996_probe()
2624 struct i2c_client *i2c = to_i2c_client(codec->dev); in wm8996_probe()
2627 wm8996->codec = codec; in wm8996_probe()
2633 wm8996_retune_mobile_pdata(codec); in wm8996_probe()
2635 snd_soc_add_codec_controls(codec, wm8996_eq_controls, in wm8996_probe()
2649 irq_flags, "wm8996", codec); in wm8996_probe()
2652 irq_flags, "wm8996", codec); in wm8996_probe()
2656 snd_soc_update_bits(codec, WM8996_INTERRUPT_CONTROL, in wm8996_probe()
2660 snd_soc_update_bits(codec, in wm8996_probe()
2668 dev_err(codec->dev, "Failed to request IRQ: %d\n", in wm8996_probe()
2677 static int wm8996_remove(struct snd_soc_codec *codec) in wm8996_remove() argument
2679 struct i2c_client *i2c = to_i2c_client(codec->dev); in wm8996_remove()
2681 snd_soc_update_bits(codec, WM8996_INTERRUPT_CONTROL, in wm8996_remove()
2685 free_irq(i2c->irq, codec); in wm8996_remove()