Lines Matching +full:hs +full:- +full:bias +full:- +full:ramp +full:- +full:rate

1 // SPDX-License-Identifier: GPL-2.0-only
21 #include <sound/soc-dapm.h>
61 u8 dl12_cache[TWL6040_REG_HFRCTL - TWL6040_REG_HSLCTL + 1];
69 /* set of rates for each pll: low-power and high-performance */
95 #define to_twl6040(component) dev_get_drvdata((component)->dev->parent)
104 return -EIO; in twl6040_read()
112 value = priv->dl12_cache[reg - TWL6040_REG_HSLCTL]; in twl6040_read()
132 return priv->dl1_unmuted; in twl6040_can_write_to_chip()
135 return priv->dl2_unmuted; in twl6040_can_write_to_chip()
152 priv->dl12_cache[reg - TWL6040_REG_HSLCTL] = value; in twl6040_update_dl12_cache()
165 return -EIO; in twl6040_write()
188 * We need to lower the default gain values, so the ramp code in twl6040_init_chip()
225 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in twl6040_hs_dac_event()
230 * Both HS DAC need to be turned on (before the HS driver) and off at in twl6040_hs_dac_event()
252 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in twl6040_ep_drv_event()
258 priv->hs_power_mode_locked = 1; in twl6040_ep_drv_event()
261 priv->hs_power_mode_locked = 0; in twl6040_ep_drv_event()
262 ret = headset_power_mode(component, priv->hs_power_mode); in twl6040_ep_drv_event()
276 mutex_lock(&priv->mutex); in twl6040_hs_jack_report()
285 mutex_unlock(&priv->mutex); in twl6040_hs_jack_report()
292 struct twl6040_jack_data *hs_jack = &priv->hs_jack; in twl6040_hs_jack_detect()
294 hs_jack->jack = jack; in twl6040_hs_jack_detect()
295 hs_jack->report = report; in twl6040_hs_jack_detect()
297 twl6040_hs_jack_report(component, hs_jack->jack, hs_jack->report); in twl6040_hs_jack_detect()
305 struct snd_soc_component *component = priv->component; in twl6040_accessory_work()
306 struct twl6040_jack_data *hs_jack = &priv->hs_jack; in twl6040_accessory_work()
308 twl6040_hs_jack_report(component, hs_jack->jack, hs_jack->report); in twl6040_accessory_work()
318 &priv->hs_jack.work, msecs_to_jiffies(200)); in twl6040_audio_handler()
327 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in twl6040_soc_dapm_put_vibra_enum()
331 val = twl6040_read(component, e->reg); in twl6040_soc_dapm_put_vibra_enum()
333 return -EBUSY; in twl6040_soc_dapm_put_vibra_enum()
340 * from -6 to 0 dB in 6 dB steps
342 static DECLARE_TLV_DB_SCALE(mic_preamp_tlv, -600, 600, 0);
352 * from -18 to 24 dB in 6 dB steps
354 static DECLARE_TLV_DB_SCALE(afm_amp_tlv, -1800, 600, 0);
358 * from -30 to 0 dB in 2 dB steps
360 static DECLARE_TLV_DB_SCALE(hs_tlv, -3000, 200, 0);
364 * from -52 to 6 dB in 2 dB steps
366 static DECLARE_TLV_DB_SCALE(hf_tlv, -5200, 200, 0);
370 * from -24 to 6 dB in 2 dB steps
372 static DECLARE_TLV_DB_SCALE(ep_tlv, -2400, 200, 0);
390 "Off", "HS DAC", "Line-In amp"
401 "Off", "HF DAC", "Line-In amp"
466 "Low-Power", "High-Performance",
478 ucontrol->value.enumerated.item[0] = priv->hs_power_mode; in twl6040_headset_power_get_enum()
488 int high_perf = ucontrol->value.enumerated.item[0]; in twl6040_headset_power_put_enum()
491 if (!priv->hs_power_mode_locked) in twl6040_headset_power_put_enum()
495 priv->hs_power_mode = high_perf; in twl6040_headset_power_put_enum()
506 ucontrol->value.enumerated.item[0] = priv->pll_power_mode; in twl6040_pll_get_enum()
517 priv->pll_power_mode = ucontrol->value.enumerated.item[0]; in twl6040_pll_put_enum()
527 return -1; /* -1dB */ in twl6040_get_dl1_gain()
535 return -8; /* -8dB */ in twl6040_get_dl1_gain()
538 return -1; /* -1dB */ in twl6040_get_dl1_gain()
548 return priv->pll_power_mode; in twl6040_get_clk_id()
555 return -EINVAL; in twl6040_get_trim_value()
566 /* For ES under ES_1.3 HS step is 2 mV */ in twl6040_get_hs_step_size()
569 /* For ES_1.3 HS step is 1 mV */ in twl6040_get_hs_step_size()
597 /* Left HS PDM data routed to Right HSDAC */
650 /* Microphone bias */
651 SND_SOC_DAPM_SUPPLY("Headset Mic Bias",
653 SND_SOC_DAPM_SUPPLY("Main Mic Bias",
655 SND_SOC_DAPM_SUPPLY("Digital Mic1 Bias",
657 SND_SOC_DAPM_SUPPLY("Digital Mic2 Bias",
695 SND_SOC_DAPM_OUT_DRV("HS Left Driver",
697 SND_SOC_DAPM_OUT_DRV("HS Right Driver",
725 /* Stream -> DAC mapping */
739 /* ADC -> Stream mapping */
767 {"Headset Left Playback", "HS DAC", "HSDAC Left"},
768 {"Headset Left Playback", "Line-In amp", "AFMAmpL"},
770 {"Headset Right Playback", "HS DAC", "HSDAC Right"},
771 {"Headset Right Playback", "Line-In amp", "AFMAmpR"},
773 {"HS Left Driver", NULL, "Headset Left Playback"},
774 {"HS Right Driver", NULL, "Headset Right Playback"},
776 {"HSOL", NULL, "HS Left Driver"},
777 {"HSOR", NULL, "HS Right Driver"},
785 {"Handsfree Left Playback", "Line-In amp", "AFMAmpL"},
788 {"Handsfree Right Playback", "Line-In amp", "AFMAmpR"},
831 if (priv->codec_powered) { in twl6040_set_bias_level()
842 priv->codec_powered = 1; in twl6040_set_bias_level()
848 if (!priv->codec_powered) in twl6040_set_bias_level()
852 priv->codec_powered = 0; in twl6040_set_bias_level()
862 struct snd_soc_component *component = dai->component; in twl6040_startup()
865 snd_pcm_hw_constraint_list(substream->runtime, 0, in twl6040_startup()
867 &sysclk_constraints[priv->pll_power_mode]); in twl6040_startup()
876 struct snd_soc_component *component = dai->component; in twl6040_hw_params()
878 int rate; in twl6040_hw_params() local
880 rate = params_rate(params); in twl6040_hw_params()
881 switch (rate) { in twl6040_hw_params()
887 if (unlikely(priv->pll == TWL6040_SYSCLK_SEL_HPPLL)) { in twl6040_hw_params()
888 dev_err(component->dev, "HPPLL does not support rate %d\n", in twl6040_hw_params()
889 rate); in twl6040_hw_params()
890 return -EINVAL; in twl6040_hw_params()
892 priv->sysclk = 17640000; in twl6040_hw_params()
899 priv->sysclk = 19200000; in twl6040_hw_params()
902 dev_err(component->dev, "unsupported rate %d\n", rate); in twl6040_hw_params()
903 return -EINVAL; in twl6040_hw_params()
912 struct snd_soc_component *component = dai->component; in twl6040_prepare()
917 if (!priv->sysclk) { in twl6040_prepare()
918 dev_err(component->dev, in twl6040_prepare()
920 return -EINVAL; in twl6040_prepare()
923 ret = twl6040_set_pll(twl6040, priv->pll, priv->clk_in, priv->sysclk); in twl6040_prepare()
925 dev_err(component->dev, "Can not set PLL (%d)\n", ret); in twl6040_prepare()
926 return -EPERM; in twl6040_prepare()
935 struct snd_soc_component *component = codec_dai->component; in twl6040_set_dai_sysclk()
941 priv->pll = clk_id; in twl6040_set_dai_sysclk()
942 priv->clk_in = freq; in twl6040_set_dai_sysclk()
945 dev_err(component->dev, "unknown clk_id %d\n", clk_id); in twl6040_set_dai_sysclk()
946 return -EINVAL; in twl6040_set_dai_sysclk()
977 priv->dl1_unmuted = !mute; in twl6040_mute_path()
993 priv->dl2_unmuted = !mute; in twl6040_mute_path()
1002 switch (dai->id) { in twl6040_mute_stream()
1004 twl6040_mute_path(dai->component, TWL6040_DAI_DL1, mute); in twl6040_mute_stream()
1005 twl6040_mute_path(dai->component, TWL6040_DAI_DL2, mute); in twl6040_mute_stream()
1009 twl6040_mute_path(dai->component, dai->id, mute); in twl6040_mute_stream()
1029 .name = "twl6040-legacy",
1048 .name = "twl6040-ul",
1060 .name = "twl6040-dl1",
1072 .name = "twl6040-dl2",
1084 .name = "twl6040-vib",
1100 struct platform_device *pdev = to_platform_device(component->dev); in twl6040_probe()
1103 priv = devm_kzalloc(component->dev, sizeof(*priv), GFP_KERNEL); in twl6040_probe()
1105 return -ENOMEM; in twl6040_probe()
1109 priv->component = component; in twl6040_probe()
1111 priv->plug_irq = platform_get_irq(pdev, 0); in twl6040_probe()
1112 if (priv->plug_irq < 0) in twl6040_probe()
1113 return priv->plug_irq; in twl6040_probe()
1115 INIT_DELAYED_WORK(&priv->hs_jack.work, twl6040_accessory_work); in twl6040_probe()
1117 mutex_init(&priv->mutex); in twl6040_probe()
1119 ret = request_threaded_irq(priv->plug_irq, NULL, in twl6040_probe()
1124 dev_err(component->dev, "PLUG IRQ request failed: %d\n", ret); in twl6040_probe()
1138 free_irq(priv->plug_irq, component); in twl6040_remove()
1160 return devm_snd_soc_register_component(&pdev->dev, in twl6040_codec_probe()
1167 .name = "twl6040-codec",