Lines Matching full:es8316
3 * es8316.c -- es8316 ALSA SoC audio driver
24 #include "es8316.h"
48 * ES8316 controls
366 struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); in es8316_set_dai_sysclk() local
370 es8316->sysclk = freq; in es8316_set_dai_sysclk()
371 es8316->sysclk_constraints.list = NULL; in es8316_set_dai_sysclk()
372 es8316->sysclk_constraints.count = 0; in es8316_set_dai_sysclk()
377 ret = clk_set_rate(es8316->mclk, freq); in es8316_set_dai_sysclk()
388 es8316->allowed_rates[count++] = freq / ratio; in es8316_set_dai_sysclk()
392 es8316->sysclk_constraints.list = es8316->allowed_rates; in es8316_set_dai_sysclk()
393 es8316->sysclk_constraints.count = count; in es8316_set_dai_sysclk()
452 struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); in es8316_pcm_startup() local
454 if (es8316->sysclk_constraints.list) in es8316_pcm_startup()
457 &es8316->sysclk_constraints); in es8316_pcm_startup()
467 struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); in es8316_pcm_hw_params() local
472 unsigned int clk = es8316->sysclk / 2; in es8316_pcm_hw_params()
493 if (clk == es8316->sysclk) in es8316_pcm_hw_params()
495 clk = es8316->sysclk; in es8316_pcm_hw_params()
501 if (clk != es8316->sysclk) { in es8316_pcm_hw_params()
563 .name = "ES8316 HiFi",
612 struct es8316_priv *es8316 = data; in es8316_irq() local
613 struct snd_soc_component *comp = es8316->component; in es8316_irq()
616 mutex_lock(&es8316->lock); in es8316_irq()
618 regmap_read(es8316->regmap, ES8316_GPIO_FLAG, &flags); in es8316_irq()
623 if (!es8316->jack) in es8316_irq()
626 if (es8316->jd_inverted) in es8316_irq()
632 if (es8316->jack->status & SND_JACK_MICROPHONE) in es8316_irq()
635 if (es8316->jack->status & SND_JACK_HEADPHONE) { in es8316_irq()
636 snd_soc_jack_report(es8316->jack, 0, in es8316_irq()
640 } else if (!(es8316->jack->status & SND_JACK_HEADPHONE)) { in es8316_irq()
643 regmap_read(es8316->regmap, ES8316_GPIO_FLAG, &flags); in es8316_irq()
644 if (es8316->jd_inverted) in es8316_irq()
652 snd_soc_jack_report(es8316->jack, in es8316_irq()
658 snd_soc_jack_report(es8316->jack, in es8316_irq()
664 } else if (es8316->jack->status & SND_JACK_MICROPHONE) { in es8316_irq()
668 snd_soc_jack_report(es8316->jack, 0, SND_JACK_BTN_0); in es8316_irq()
671 snd_soc_jack_report(es8316->jack, in es8316_irq()
678 mutex_unlock(&es8316->lock); in es8316_irq()
685 struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); in es8316_enable_jack_detect() local
688 * Init es8316->jd_inverted here and not in the probe, as we cannot in es8316_enable_jack_detect()
689 * guarantee that the bytchr-es8316 driver, which might set this in es8316_enable_jack_detect()
692 es8316->jd_inverted = device_property_read_bool(component->dev, in es8316_enable_jack_detect()
695 mutex_lock(&es8316->lock); in es8316_enable_jack_detect()
697 es8316->jack = jack; in es8316_enable_jack_detect()
699 if (es8316->jack->status & SND_JACK_MICROPHONE) in es8316_enable_jack_detect()
706 mutex_unlock(&es8316->lock); in es8316_enable_jack_detect()
709 enable_irq(es8316->irq); in es8316_enable_jack_detect()
710 es8316_irq(es8316->irq, es8316); in es8316_enable_jack_detect()
715 struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); in es8316_disable_jack_detect() local
717 if (!es8316->jack) in es8316_disable_jack_detect()
720 disable_irq(es8316->irq); in es8316_disable_jack_detect()
722 mutex_lock(&es8316->lock); in es8316_disable_jack_detect()
727 if (es8316->jack->status & SND_JACK_MICROPHONE) { in es8316_disable_jack_detect()
729 snd_soc_jack_report(es8316->jack, 0, SND_JACK_BTN_0); in es8316_disable_jack_detect()
732 es8316->jack = NULL; in es8316_disable_jack_detect()
734 mutex_unlock(&es8316->lock); in es8316_disable_jack_detect()
750 struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); in es8316_probe() local
753 es8316->component = component; in es8316_probe()
755 es8316->mclk = devm_clk_get_optional(component->dev, "mclk"); in es8316_probe()
756 if (IS_ERR(es8316->mclk)) { in es8316_probe()
758 return PTR_ERR(es8316->mclk); in es8316_probe()
760 if (!es8316->mclk) in es8316_probe()
763 ret = clk_prepare_enable(es8316->mclk); in es8316_probe()
793 struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); in es8316_remove() local
795 clk_disable_unprepare(es8316->mclk); in es8316_remove()
800 struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); in es8316_resume() local
802 regcache_cache_only(es8316->regmap, false); in es8316_resume()
803 regcache_sync(es8316->regmap); in es8316_resume()
810 struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); in es8316_suspend() local
812 regcache_cache_only(es8316->regmap, true); in es8316_suspend()
813 regcache_mark_dirty(es8316->regmap); in es8316_suspend()
857 struct es8316_priv *es8316; in es8316_i2c_probe() local
860 es8316 = devm_kzalloc(&i2c_client->dev, sizeof(struct es8316_priv), in es8316_i2c_probe()
862 if (es8316 == NULL) in es8316_i2c_probe()
865 i2c_set_clientdata(i2c_client, es8316); in es8316_i2c_probe()
867 es8316->regmap = devm_regmap_init_i2c(i2c_client, &es8316_regmap); in es8316_i2c_probe()
868 if (IS_ERR(es8316->regmap)) in es8316_i2c_probe()
869 return PTR_ERR(es8316->regmap); in es8316_i2c_probe()
871 es8316->irq = i2c_client->irq; in es8316_i2c_probe()
872 mutex_init(&es8316->lock); in es8316_i2c_probe()
874 if (es8316->irq > 0) { in es8316_i2c_probe()
875 ret = devm_request_threaded_irq(dev, es8316->irq, NULL, es8316_irq, in es8316_i2c_probe()
877 "es8316", es8316); in es8316_i2c_probe()
879 dev_warn(dev, "Failed to get IRQ %d: %d\n", es8316->irq, ret); in es8316_i2c_probe()
880 es8316->irq = -ENXIO; in es8316_i2c_probe()
890 {"es8316" },
897 { .compatible = "everest,es8316", },
914 .name = "es8316",
923 MODULE_DESCRIPTION("Everest Semi ES8316 ALSA SoC Codec Driver");