• Home
  • Raw
  • Download

Lines Matching +full:pga +full:- +full:gain

18  * 02110-1301 USA
42 #include <linux/mfd/twl4030-audio.h>
73 u8 ctl_cache[TWL4030_REG_PRECKR_CTL - TWL4030_REG_EAR_CTL + 1];
85 twl4030->ctl_cache[i - TWL4030_REG_EAR_CTL] = byte; in tw4030_init_ctl_cache()
95 return -EIO; in twl4030_read()
104 value = twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL]; in twl4030_read()
122 if (twl4030->earpiece_enabled) in twl4030_can_write_to_chip()
126 if (twl4030->predrivel_enabled) in twl4030_can_write_to_chip()
130 if (twl4030->predriver_enabled) in twl4030_can_write_to_chip()
134 if (twl4030->carkitl_enabled) in twl4030_can_write_to_chip()
138 if (twl4030->carkitr_enabled) in twl4030_can_write_to_chip()
142 if (twl4030->hsl_enabled || twl4030->hsr_enabled) in twl4030_can_write_to_chip()
167 twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL] = value; in twl4030_write()
194 if (enable == twl4030->codec_powered) in twl4030_codec_enable()
203 twl4030->codec_powered = enable; in twl4030_codec_enable()
216 &pdata->digimic_delay); in twl4030_setup_pdata_of()
218 &pdata->ramp_delay_value); in twl4030_setup_pdata_of()
220 &pdata->offset_cncl_path); in twl4030_setup_pdata_of()
222 pdata->hs_extmute = value; in twl4030_setup_pdata_of()
224 pdata->hs_extmute_gpio = of_get_named_gpio(node, in twl4030_setup_pdata_of()
226 if (gpio_is_valid(pdata->hs_extmute_gpio)) in twl4030_setup_pdata_of()
227 pdata->hs_extmute = 1; in twl4030_setup_pdata_of()
232 struct twl4030_codec_data *pdata = dev_get_platdata(component->dev); in twl4030_get_pdata()
235 twl4030_codec_node = of_get_child_by_name(component->dev->parent->of_node, in twl4030_get_pdata()
239 pdata = devm_kzalloc(component->dev, in twl4030_get_pdata()
262 if (pdata && pdata->hs_extmute) { in twl4030_init_chip()
263 if (gpio_is_valid(pdata->hs_extmute_gpio)) { in twl4030_init_chip()
266 if (!pdata->hs_extmute_gpio) in twl4030_init_chip()
267 dev_warn(component->dev, in twl4030_init_chip()
270 ret = gpio_request_one(pdata->hs_extmute_gpio, in twl4030_init_chip()
274 dev_err(component->dev, in twl4030_init_chip()
276 pdata->hs_extmute_gpio = -1; in twl4030_init_chip()
294 /* anti-pop when changing analog gain */ in twl4030_init_chip()
310 twl4030->pdata = pdata; in twl4030_init_chip()
314 reg |= (pdata->ramp_delay_value << 2); in twl4030_init_chip()
322 reg |= pdata->offset_cncl_path; in twl4030_init_chip()
350 twl4030->apll_enabled++; in twl4030_apll_enable()
351 if (twl4030->apll_enabled == 1) in twl4030_apll_enable()
355 twl4030->apll_enabled--; in twl4030_apll_enable()
356 if (!twl4030->apll_enabled) in twl4030_apll_enable()
527 /* Digital bypass gain, mute instead of -30dB */
529 0, 1, TLV_DB_SCALE_ITEM(-3000, 600, 1),
530 2, 3, TLV_DB_SCALE_ITEM(-2400, 0, 0),
531 4, 7, TLV_DB_SCALE_ITEM(-1800, 600, 0)
534 /* Digital bypass left (TX1L -> RX2L) */
540 /* Digital bypass right (TX1R -> RX2R) */
547 * Voice Sidetone GAIN volume control:
548 * from -51 to -10 dB in 1 dB steps (mute instead of -51 dB)
550 static DECLARE_TLV_DB_SCALE(twl4030_dapm_dbypassv_tlv, -5100, 100, 1);
552 /* Digital bypass voice: sidetone (VUL -> VDL)*/
559 * Output PGA builder:
570 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); \
575 twl4030->pin_name##_enabled = 1; \
579 twl4030->pin_name##_enabled = 0; \
599 /* HF ramp-up */ in handsfree_ramp()
610 /* HF ramp-down */ in handsfree_ramp()
625 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in handsfreelpga_event()
641 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in handsfreerpga_event()
657 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in vibramux_event()
666 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in apll_event()
682 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in aif_event()
709 struct twl4030_codec_data *pdata = twl4030->pdata; in headset_ramp()
710 /* Base values for ramp delay calculation: 2^19 - 2^26 */ in headset_ramp()
718 twl4030->sysclk) + 1; in headset_ramp()
721 * the pop-noise */ in headset_ramp()
722 if (pdata && pdata->hs_extmute) { in headset_ramp()
723 if (gpio_is_valid(pdata->hs_extmute_gpio)) { in headset_ramp()
724 gpio_set_value(pdata->hs_extmute_gpio, 1); in headset_ramp()
732 /* Headset ramp-up according to the TRM */ in headset_ramp()
743 /* Headset ramp-down _not_ according to in headset_ramp()
758 if (pdata && pdata->hs_extmute) { in headset_ramp()
759 if (gpio_is_valid(pdata->hs_extmute_gpio)) { in headset_ramp()
760 gpio_set_value(pdata->hs_extmute_gpio, 0); in headset_ramp()
771 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in headsetlpga_event()
776 /* Do the ramp-up only once */ in headsetlpga_event()
777 if (!twl4030->hsr_enabled) in headsetlpga_event()
780 twl4030->hsl_enabled = 1; in headsetlpga_event()
783 /* Do the ramp-down only if both headsetL/R is disabled */ in headsetlpga_event()
784 if (!twl4030->hsr_enabled) in headsetlpga_event()
787 twl4030->hsl_enabled = 0; in headsetlpga_event()
796 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in headsetrpga_event()
801 /* Do the ramp-up only once */ in headsetrpga_event()
802 if (!twl4030->hsl_enabled) in headsetrpga_event()
805 twl4030->hsr_enabled = 1; in headsetrpga_event()
808 /* Do the ramp-down only if both headsetL/R is disabled */ in headsetrpga_event()
809 if (!twl4030->hsl_enabled) in headsetrpga_event()
812 twl4030->hsr_enabled = 0; in headsetrpga_event()
821 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in digimic_event()
823 struct twl4030_codec_data *pdata = twl4030->pdata; in digimic_event()
825 if (pdata && pdata->digimic_delay) in digimic_event()
826 twl4030_wait_ms(pdata->digimic_delay); in digimic_event()
831 * Some of the gain controls in TWL (mostly those which are associated with
836 * 0x3 : -6 dB
838 * Custom volsw and volsw_2r get/put functions to handle these gain bits.
844 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_get_volsw_twl4030()
846 unsigned int reg = mc->reg; in snd_soc_get_volsw_twl4030()
847 unsigned int shift = mc->shift; in snd_soc_get_volsw_twl4030()
848 unsigned int rshift = mc->rshift; in snd_soc_get_volsw_twl4030()
849 int max = mc->max; in snd_soc_get_volsw_twl4030()
850 int mask = (1 << fls(max)) - 1; in snd_soc_get_volsw_twl4030()
852 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_twl4030()
854 if (ucontrol->value.integer.value[0]) in snd_soc_get_volsw_twl4030()
855 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_twl4030()
856 max + 1 - ucontrol->value.integer.value[0]; in snd_soc_get_volsw_twl4030()
859 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_twl4030()
861 if (ucontrol->value.integer.value[1]) in snd_soc_get_volsw_twl4030()
862 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_twl4030()
863 max + 1 - ucontrol->value.integer.value[1]; in snd_soc_get_volsw_twl4030()
873 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_put_volsw_twl4030()
875 unsigned int reg = mc->reg; in snd_soc_put_volsw_twl4030()
876 unsigned int shift = mc->shift; in snd_soc_put_volsw_twl4030()
877 unsigned int rshift = mc->rshift; in snd_soc_put_volsw_twl4030()
878 int max = mc->max; in snd_soc_put_volsw_twl4030()
879 int mask = (1 << fls(max)) - 1; in snd_soc_put_volsw_twl4030()
882 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_put_volsw_twl4030()
886 val = max + 1 - val; in snd_soc_put_volsw_twl4030()
889 val2 = (ucontrol->value.integer.value[1] & mask); in snd_soc_put_volsw_twl4030()
892 val2 = max + 1 - val2; in snd_soc_put_volsw_twl4030()
902 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_get_volsw_r2_twl4030()
904 unsigned int reg = mc->reg; in snd_soc_get_volsw_r2_twl4030()
905 unsigned int reg2 = mc->rreg; in snd_soc_get_volsw_r2_twl4030()
906 unsigned int shift = mc->shift; in snd_soc_get_volsw_r2_twl4030()
907 int max = mc->max; in snd_soc_get_volsw_r2_twl4030()
908 int mask = (1<<fls(max))-1; in snd_soc_get_volsw_r2_twl4030()
910 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_r2_twl4030()
912 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_r2_twl4030()
915 if (ucontrol->value.integer.value[0]) in snd_soc_get_volsw_r2_twl4030()
916 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_r2_twl4030()
917 max + 1 - ucontrol->value.integer.value[0]; in snd_soc_get_volsw_r2_twl4030()
918 if (ucontrol->value.integer.value[1]) in snd_soc_get_volsw_r2_twl4030()
919 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_r2_twl4030()
920 max + 1 - ucontrol->value.integer.value[1]; in snd_soc_get_volsw_r2_twl4030()
929 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_put_volsw_r2_twl4030()
931 unsigned int reg = mc->reg; in snd_soc_put_volsw_r2_twl4030()
932 unsigned int reg2 = mc->rreg; in snd_soc_put_volsw_r2_twl4030()
933 unsigned int shift = mc->shift; in snd_soc_put_volsw_r2_twl4030()
934 int max = mc->max; in snd_soc_put_volsw_r2_twl4030()
935 int mask = (1 << fls(max)) - 1; in snd_soc_put_volsw_r2_twl4030()
940 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_put_volsw_r2_twl4030()
941 val2 = (ucontrol->value.integer.value[1] & mask); in snd_soc_put_volsw_r2_twl4030()
944 val = max + 1 - val; in snd_soc_put_volsw_r2_twl4030()
946 val2 = max + 1 - val2; in snd_soc_put_volsw_r2_twl4030()
974 if (twl4030->configured) { in snd_soc_put_twl4030_opmode_enum_double()
975 dev_err(component->dev, in snd_soc_put_twl4030_opmode_enum_double()
976 "operation mode cannot be changed on-the-fly\n"); in snd_soc_put_twl4030_opmode_enum_double()
977 return -EBUSY; in snd_soc_put_twl4030_opmode_enum_double()
985 * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB)
987 static DECLARE_TLV_DB_SCALE(digital_fine_tlv, -6300, 100, 1);
997 * Voice Downlink GAIN volume control:
998 * from -37 to 12 dB in 1 dB steps (mute instead of -37 dB)
1000 static DECLARE_TLV_DB_SCALE(digital_voice_downlink_tlv, -3700, 100, 1);
1003 * Analog playback gain
1004 * -24 dB to 12 dB in 2 dB steps
1006 static DECLARE_TLV_DB_SCALE(analog_tlv, -2400, 200, 0);
1009 * Gain controls tied to outputs
1010 * -6 dB to 6 dB in 6 dB steps (mute instead of -12)
1012 static DECLARE_TLV_DB_SCALE(output_tvl, -1200, 600, 1);
1015 * Gain control for earpiece amplifier
1016 * 0 dB to 12 dB in 6 dB steps (mute instead of -6)
1018 static DECLARE_TLV_DB_SCALE(output_ear_tvl, -600, 600, 1);
1021 * Capture gain after the ADCs
1027 * Gain control for input amplifiers
1051 /* Vibra H-bridge direction mode */
1053 "Vibra H-bridge direction", "Audio data MSB",
1060 /* Vibra H-bridge direction */
1084 /* Common playback gain controls */
1112 /* Common voice downlink gain controls */
1122 /* Separate output gain controls */
1141 /* Common capture gain controls */
1156 SOC_ENUM("Vibra H-bridge mode", twl4030_vibradirmode_enum),
1157 SOC_ENUM("Vibra H-bridge direction", twl4030_vibradir_enum),
1261 SND_SOC_DAPM_PGA_E("Earpiece PGA", SND_SOC_NOPM,
1268 SND_SOC_DAPM_PGA_E("PredriveL PGA", SND_SOC_NOPM,
1274 SND_SOC_DAPM_PGA_E("PredriveR PGA", SND_SOC_NOPM,
1281 SND_SOC_DAPM_PGA_E("HeadsetL PGA", SND_SOC_NOPM,
1287 SND_SOC_DAPM_PGA_E("HeadsetR PGA", SND_SOC_NOPM,
1294 SND_SOC_DAPM_PGA_E("CarkitL PGA", SND_SOC_NOPM,
1300 SND_SOC_DAPM_PGA_E("CarkitR PGA", SND_SOC_NOPM,
1310 SND_SOC_DAPM_PGA_E("HandsfreeL PGA", SND_SOC_NOPM,
1317 SND_SOC_DAPM_PGA_E("HandsfreeR PGA", SND_SOC_NOPM,
1384 /* Stream -> DAC mapping */
1391 /* ADC -> Stream mapping */
1430 {"Earpiece PGA", NULL, "Earpiece Mixer"},
1436 {"PredriveL PGA", NULL, "PredriveL Mixer"},
1442 {"PredriveR PGA", NULL, "PredriveR Mixer"},
1447 {"HeadsetL PGA", NULL, "HeadsetL Mixer"},
1452 {"HeadsetR PGA", NULL, "HeadsetR Mixer"},
1457 {"CarkitL PGA", NULL, "CarkitL Mixer"},
1462 {"CarkitR PGA", NULL, "CarkitR Mixer"},
1469 {"HandsfreeL PGA", NULL, "HandsfreeL"},
1476 {"HandsfreeR PGA", NULL, "HandsfreeR"},
1492 {"EARPIECE", NULL, "Earpiece PGA"},
1493 {"PREDRIVEL", NULL, "PredriveL PGA"},
1494 {"PREDRIVER", NULL, "PredriveR PGA"},
1495 {"HSOL", NULL, "HeadsetL PGA"},
1496 {"HSOR", NULL, "HeadsetR PGA"},
1497 {"CARKITL", NULL, "CarkitL PGA"},
1498 {"CARKITR", NULL, "CarkitR PGA"},
1499 {"HFL", NULL, "HandsfreeL PGA"},
1500 {"HFR", NULL, "HandsfreeR PGA"},
1608 if (mst_substream == twl4030->master_substream) in twl4030_constraints()
1609 slv_substream = twl4030->slave_substream; in twl4030_constraints()
1610 else if (mst_substream == twl4030->slave_substream) in twl4030_constraints()
1611 slv_substream = twl4030->master_substream; in twl4030_constraints()
1616 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1618 twl4030->rate); in twl4030_constraints()
1620 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1622 twl4030->sample_bits); in twl4030_constraints()
1624 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1626 twl4030->channels); in twl4030_constraints()
1654 struct snd_soc_component *component = dai->component; in twl4030_startup()
1657 if (twl4030->master_substream) { in twl4030_startup()
1658 twl4030->slave_substream = substream; in twl4030_startup()
1662 if (twl4030->configured) in twl4030_startup()
1663 twl4030_constraints(twl4030, twl4030->master_substream); in twl4030_startup()
1670 snd_pcm_hw_constraint_single(substream->runtime, in twl4030_startup()
1674 twl4030->master_substream = substream; in twl4030_startup()
1683 struct snd_soc_component *component = dai->component; in twl4030_shutdown()
1686 if (twl4030->master_substream == substream) in twl4030_shutdown()
1687 twl4030->master_substream = twl4030->slave_substream; in twl4030_shutdown()
1689 twl4030->slave_substream = NULL; in twl4030_shutdown()
1693 if (!twl4030->master_substream) in twl4030_shutdown()
1694 twl4030->configured = 0; in twl4030_shutdown()
1695 else if (!twl4030->master_substream->runtime->channels) in twl4030_shutdown()
1696 twl4030->configured = 0; in twl4030_shutdown()
1699 if (substream->runtime->channels == 4) in twl4030_shutdown()
1700 twl4030_tdm_enable(component, substream->stream, 0); in twl4030_shutdown()
1707 struct snd_soc_component *component = dai->component; in twl4030_hw_params()
1720 twl4030_tdm_enable(component, substream->stream, 1); in twl4030_hw_params()
1722 return -EINVAL; in twl4030_hw_params()
1725 if (twl4030->configured) in twl4030_hw_params()
1766 dev_err(component->dev, "%s: unknown rate %d\n", __func__, in twl4030_hw_params()
1768 return -EINVAL; in twl4030_hw_params()
1783 dev_err(component->dev, "%s: unsupported bits/sample %d\n", in twl4030_hw_params()
1785 return -EINVAL; in twl4030_hw_params()
1789 if (twl4030->codec_powered) { in twl4030_hw_params()
1806 twl4030->configured = 1; in twl4030_hw_params()
1807 twl4030->rate = params_rate(params); in twl4030_hw_params()
1808 twl4030->sample_bits = hw_param_interval(params, in twl4030_hw_params()
1809 SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min; in twl4030_hw_params()
1810 twl4030->channels = params_channels(params); in twl4030_hw_params()
1815 if (twl4030->slave_substream) in twl4030_hw_params()
1824 struct snd_soc_component *component = codec_dai->component; in twl4030_set_dai_sysclk()
1833 dev_err(component->dev, "Unsupported HFCLKIN: %u\n", freq); in twl4030_set_dai_sysclk()
1834 return -EINVAL; in twl4030_set_dai_sysclk()
1837 if ((freq / 1000) != twl4030->sysclk) { in twl4030_set_dai_sysclk()
1838 dev_err(component->dev, in twl4030_set_dai_sysclk()
1840 freq, twl4030->sysclk * 1000); in twl4030_set_dai_sysclk()
1841 return -EINVAL; in twl4030_set_dai_sysclk()
1849 struct snd_soc_component *component = codec_dai->component; in twl4030_set_dai_fmt()
1868 return -EINVAL; in twl4030_set_dai_fmt()
1881 return -EINVAL; in twl4030_set_dai_fmt()
1885 if (twl4030->codec_powered) { in twl4030_set_dai_fmt()
1903 struct snd_soc_component *component = dai->component; in twl4030_set_tristate()
1939 struct snd_soc_component *component = dai->component; in twl4030_voice_startup()
1946 if (twl4030->sysclk != 26000) { in twl4030_voice_startup()
1947 dev_err(component->dev, in twl4030_voice_startup()
1949 __func__, twl4030->sysclk); in twl4030_voice_startup()
1950 return -EINVAL; in twl4030_voice_startup()
1960 dev_err(component->dev, "%s: the codec mode is not option2\n", in twl4030_voice_startup()
1962 return -EINVAL; in twl4030_voice_startup()
1971 struct snd_soc_component *component = dai->component; in twl4030_voice_shutdown()
1974 twl4030_voice_enable(component, substream->stream, 0); in twl4030_voice_shutdown()
1981 struct snd_soc_component *component = dai->component; in twl4030_voice_hw_params()
1986 twl4030_voice_enable(component, substream->stream, 1); in twl4030_voice_hw_params()
2001 dev_err(component->dev, "%s: unknown rate %d\n", __func__, in twl4030_voice_hw_params()
2003 return -EINVAL; in twl4030_voice_hw_params()
2007 if (twl4030->codec_powered) { in twl4030_voice_hw_params()
2026 struct snd_soc_component *component = codec_dai->component; in twl4030_voice_set_dai_sysclk()
2030 dev_err(component->dev, in twl4030_voice_set_dai_sysclk()
2033 return -EINVAL; in twl4030_voice_set_dai_sysclk()
2035 if ((freq / 1000) != twl4030->sysclk) { in twl4030_voice_set_dai_sysclk()
2036 dev_err(component->dev, in twl4030_voice_set_dai_sysclk()
2038 freq, twl4030->sysclk * 1000); in twl4030_voice_set_dai_sysclk()
2039 return -EINVAL; in twl4030_voice_set_dai_sysclk()
2047 struct snd_soc_component *component = codec_dai->component; in twl4030_voice_set_dai_fmt()
2064 return -EINVAL; in twl4030_voice_set_dai_fmt()
2076 return -EINVAL; in twl4030_voice_set_dai_fmt()
2080 if (twl4030->codec_powered) { in twl4030_voice_set_dai_fmt()
2098 struct snd_soc_component *component = dai->component; in twl4030_voice_set_tristate()
2132 .name = "twl4030-hifi",
2150 .name = "twl4030-voice",
2171 twl4030 = devm_kzalloc(component->dev, sizeof(struct twl4030_priv), in twl4030_soc_probe()
2174 return -ENOMEM; in twl4030_soc_probe()
2177 twl4030->sysclk = twl4030_audio_get_mclk() / 1000; in twl4030_soc_probe()
2187 struct twl4030_codec_data *pdata = twl4030->pdata; in twl4030_soc_remove()
2189 if (pdata && pdata->hs_extmute && gpio_is_valid(pdata->hs_extmute_gpio)) in twl4030_soc_remove()
2190 gpio_free(pdata->hs_extmute_gpio); in twl4030_soc_remove()
2212 return devm_snd_soc_register_component(&pdev->dev, in twl4030_codec_probe()
2217 MODULE_ALIAS("platform:twl4030-codec");
2222 .name = "twl4030-codec",