Lines Matching refs:codec
416 static int rt5670_headset_detect(struct snd_soc_codec *codec, int jack_insert) in rt5670_headset_detect() argument
419 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_headset_detect()
422 snd_soc_dapm_force_enable_pin(&codec->dapm, in rt5670_headset_detect()
424 snd_soc_dapm_sync(&codec->dapm); in rt5670_headset_detect()
425 snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x0); in rt5670_headset_detect()
426 snd_soc_update_bits(codec, RT5670_CJ_CTRL2, in rt5670_headset_detect()
429 snd_soc_write(codec, RT5670_GPIO_CTRL2, 0x0004); in rt5670_headset_detect()
430 snd_soc_update_bits(codec, RT5670_GPIO_CTRL1, in rt5670_headset_detect()
432 snd_soc_update_bits(codec, RT5670_CJ_CTRL1, in rt5670_headset_detect()
434 snd_soc_write(codec, RT5670_JD_CTRL3, 0x00f0); in rt5670_headset_detect()
435 snd_soc_update_bits(codec, RT5670_CJ_CTRL2, in rt5670_headset_detect()
437 snd_soc_update_bits(codec, RT5670_CJ_CTRL2, in rt5670_headset_detect()
440 val = snd_soc_read(codec, RT5670_CJ_CTRL3) & 0x7; in rt5670_headset_detect()
444 snd_soc_update_bits(codec, RT5670_INT_IRQ_ST, 0x8, 0x8); in rt5670_headset_detect()
445 snd_soc_update_bits(codec, RT5670_IL_CMD, 0x40, 0x40); in rt5670_headset_detect()
446 snd_soc_read(codec, RT5670_IL_CMD); in rt5670_headset_detect()
448 snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x4); in rt5670_headset_detect()
450 snd_soc_dapm_disable_pin(&codec->dapm, "Mic Det Power"); in rt5670_headset_detect()
451 snd_soc_dapm_sync(&codec->dapm); in rt5670_headset_detect()
454 snd_soc_update_bits(codec, RT5670_INT_IRQ_ST, 0x8, 0x0); in rt5670_headset_detect()
455 snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x4); in rt5670_headset_detect()
457 snd_soc_dapm_disable_pin(&codec->dapm, "Mic Det Power"); in rt5670_headset_detect()
458 snd_soc_dapm_sync(&codec->dapm); in rt5670_headset_detect()
464 void rt5670_jack_suspend(struct snd_soc_codec *codec) in rt5670_jack_suspend() argument
466 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_jack_suspend()
469 rt5670_headset_detect(codec, 0); in rt5670_jack_suspend()
473 void rt5670_jack_resume(struct snd_soc_codec *codec) in rt5670_jack_resume() argument
475 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_jack_resume()
478 rt5670_headset_detect(codec, 1); in rt5670_jack_resume()
482 static int rt5670_button_detect(struct snd_soc_codec *codec) in rt5670_button_detect() argument
486 val = snd_soc_read(codec, RT5670_IL_CMD); in rt5670_button_detect()
488 snd_soc_write(codec, RT5670_IL_CMD, val); in rt5670_button_detect()
491 val = snd_soc_read(codec, RT5670_IL_CMD); in rt5670_button_detect()
492 snd_soc_write(codec, RT5670_IL_CMD, val); in rt5670_button_detect()
506 val = snd_soc_read(rt5670->codec, RT5670_A_JD_CTRL1) & 0x0070; in rt5670_irq_detection()
508 val = snd_soc_read(rt5670->codec, RT5670_A_JD_CTRL1) & 0x0020; in rt5670_irq_detection()
515 report = rt5670_headset_detect(rt5670->codec, 1); in rt5670_irq_detection()
521 if (snd_soc_read(rt5670->codec, RT5670_INT_IRQ_ST) & 0x4) { in rt5670_irq_detection()
524 btn_type = rt5670_button_detect(rt5670->codec); in rt5670_irq_detection()
536 dev_err(rt5670->codec->dev, in rt5670_irq_detection()
551 snd_soc_update_bits(rt5670->codec, RT5670_INT_IRQ_ST, 0x1, 0x0); in rt5670_irq_detection()
552 rt5670_headset_detect(rt5670->codec, 0); in rt5670_irq_detection()
562 int rt5670_set_jack_detect(struct snd_soc_codec *codec, in rt5670_set_jack_detect() argument
565 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_set_jack_detect()
569 rt5670->hp_gpio.gpiod_dev = codec->dev; in rt5670_set_jack_detect()
581 dev_err(codec->dev, "Adding jack GPIO failed\n"); in rt5670_set_jack_detect()
685 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in set_dmic_clk() local
686 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in set_dmic_clk()
692 dev_err(codec->dev, "Failed to set DMIC clock\n"); in set_dmic_clk()
694 snd_soc_update_bits(codec, RT5670_DMIC_CTRL1, in set_dmic_clk()
702 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); in is_sys_clk_from_pll() local
703 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in is_sys_clk_from_pll()
714 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); in is_using_asrc() local
750 val = (snd_soc_read(codec, reg) >> shift) & 0xf; in is_using_asrc()
766 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); in can_use_asrc() local
767 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in can_use_asrc()
790 int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, in rt5670_sel_asrc_clk_src() argument
848 snd_soc_update_bits(codec, RT5670_ASRC_2, in rt5670_sel_asrc_clk_src()
852 snd_soc_update_bits(codec, RT5670_ASRC_3, in rt5670_sel_asrc_clk_src()
1416 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in rt5670_hp_power_event() local
1417 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_hp_power_event()
1452 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in rt5670_hp_event() local
1453 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_hp_event()
1502 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in rt5670_bst1_event() local
1506 snd_soc_update_bits(codec, RT5670_PWR_ANLG2, in rt5670_bst1_event()
1511 snd_soc_update_bits(codec, RT5670_PWR_ANLG2, in rt5670_bst1_event()
1525 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); in rt5670_bst2_event() local
1529 snd_soc_update_bits(codec, RT5670_PWR_ANLG2, in rt5670_bst2_event()
1534 snd_soc_update_bits(codec, RT5670_PWR_ANLG2, in rt5670_bst2_event()
2320 struct snd_soc_codec *codec = dai->codec; in rt5670_hw_params() local
2321 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_hw_params()
2328 dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", in rt5670_hw_params()
2334 dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); in rt5670_hw_params()
2366 snd_soc_update_bits(codec, RT5670_I2S1_SDP, in rt5670_hw_params()
2368 snd_soc_update_bits(codec, RT5670_ADDA_CLK1, mask_clk, val_clk); in rt5670_hw_params()
2374 snd_soc_update_bits(codec, RT5670_I2S2_SDP, in rt5670_hw_params()
2376 snd_soc_update_bits(codec, RT5670_ADDA_CLK1, mask_clk, val_clk); in rt5670_hw_params()
2379 dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_hw_params()
2388 struct snd_soc_codec *codec = dai->codec; in rt5670_set_dai_fmt() local
2389 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_set_dai_fmt()
2432 snd_soc_update_bits(codec, RT5670_I2S1_SDP, in rt5670_set_dai_fmt()
2437 snd_soc_update_bits(codec, RT5670_I2S2_SDP, in rt5670_set_dai_fmt()
2442 dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_set_dai_fmt()
2451 struct snd_soc_codec *codec = dai->codec; in rt5670_set_dai_sysclk() local
2452 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_set_dai_sysclk()
2466 dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); in rt5670_set_dai_sysclk()
2469 snd_soc_update_bits(codec, RT5670_GLB_CLK, in rt5670_set_dai_sysclk()
2483 struct snd_soc_codec *codec = dai->codec; in rt5670_set_dai_pll() local
2484 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_set_dai_pll()
2493 dev_dbg(codec->dev, "PLL disabled\n"); in rt5670_set_dai_pll()
2497 snd_soc_update_bits(codec, RT5670_GLB_CLK, in rt5670_set_dai_pll()
2504 snd_soc_update_bits(codec, RT5670_GLB_CLK, in rt5670_set_dai_pll()
2513 snd_soc_update_bits(codec, RT5670_GLB_CLK, in rt5670_set_dai_pll()
2517 snd_soc_update_bits(codec, RT5670_GLB_CLK, in rt5670_set_dai_pll()
2521 dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_set_dai_pll()
2526 dev_err(codec->dev, "Unknown PLL source %d\n", source); in rt5670_set_dai_pll()
2532 dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); in rt5670_set_dai_pll()
2536 dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", in rt5670_set_dai_pll()
2540 snd_soc_write(codec, RT5670_PLL_CTRL1, in rt5670_set_dai_pll()
2542 snd_soc_write(codec, RT5670_PLL_CTRL2, in rt5670_set_dai_pll()
2556 struct snd_soc_codec *codec = dai->codec; in rt5670_set_tdm_slot() local
2594 snd_soc_update_bits(codec, RT5670_TDM_CTRL_1, 0x7c00, val); in rt5670_set_tdm_slot()
2599 static int rt5670_set_bias_level(struct snd_soc_codec *codec, in rt5670_set_bias_level() argument
2602 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_set_bias_level()
2606 if (SND_SOC_BIAS_STANDBY == codec->dapm.bias_level) { in rt5670_set_bias_level()
2607 snd_soc_update_bits(codec, RT5670_PWR_ANLG1, in rt5670_set_bias_level()
2613 snd_soc_update_bits(codec, RT5670_PWR_ANLG1, in rt5670_set_bias_level()
2616 snd_soc_update_bits(codec, RT5670_CHARGE_PUMP, in rt5670_set_bias_level()
2619 snd_soc_update_bits(codec, RT5670_DIG_MISC, 0x1, 0x1); in rt5670_set_bias_level()
2620 snd_soc_update_bits(codec, RT5670_PWR_ANLG1, in rt5670_set_bias_level()
2625 snd_soc_update_bits(codec, RT5670_PWR_ANLG1, in rt5670_set_bias_level()
2628 snd_soc_update_bits(codec, RT5670_PWR_ANLG1, in rt5670_set_bias_level()
2633 snd_soc_update_bits(codec, RT5670_PWR_ANLG1, in rt5670_set_bias_level()
2639 snd_soc_update_bits(codec, RT5670_PWR_ANLG1, in rt5670_set_bias_level()
2644 snd_soc_update_bits(codec, RT5670_DIG_MISC, 0x1, 0x0); in rt5670_set_bias_level()
2650 codec->dapm.bias_level = level; in rt5670_set_bias_level()
2655 static int rt5670_probe(struct snd_soc_codec *codec) in rt5670_probe() argument
2657 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_probe()
2659 switch (snd_soc_read(codec, RT5670_RESET) & RT5670_ID_MASK) { in rt5670_probe()
2662 snd_soc_dapm_new_controls(&codec->dapm, in rt5670_probe()
2665 snd_soc_dapm_add_routes(&codec->dapm, in rt5670_probe()
2670 snd_soc_dapm_new_controls(&codec->dapm, in rt5670_probe()
2673 snd_soc_dapm_add_routes(&codec->dapm, in rt5670_probe()
2678 dev_err(codec->dev, in rt5670_probe()
2682 rt5670->codec = codec; in rt5670_probe()
2687 static int rt5670_remove(struct snd_soc_codec *codec) in rt5670_remove() argument
2689 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_remove()
2697 static int rt5670_suspend(struct snd_soc_codec *codec) in rt5670_suspend() argument
2699 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_suspend()
2706 static int rt5670_resume(struct snd_soc_codec *codec) in rt5670_resume() argument
2708 struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); in rt5670_resume()