Lines Matching +full:digital +full:- +full:to +full:- +full:analog
1 // SPDX-License-Identifier: GPL-2.0-only
28 #include <linux/mfd/twl4030-audio.h>
67 u8 ctl_cache[TWL4030_REG_PRECKR_CTL - TWL4030_REG_EAR_CTL + 1];
79 twl4030->ctl_cache[i - TWL4030_REG_EAR_CTL] = byte; in tw4030_init_ctl_cache()
89 return -EIO; in twl4030_read()
98 value = twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL]; in twl4030_read()
116 if (twl4030->earpiece_enabled) in twl4030_can_write_to_chip()
120 if (twl4030->predrivel_enabled) in twl4030_can_write_to_chip()
124 if (twl4030->predriver_enabled) in twl4030_can_write_to_chip()
128 if (twl4030->carkitl_enabled) in twl4030_can_write_to_chip()
132 if (twl4030->carkitr_enabled) in twl4030_can_write_to_chip()
136 if (twl4030->hsl_enabled || twl4030->hsr_enabled) in twl4030_can_write_to_chip()
161 twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL] = value; in twl4030_write()
188 if (enable == twl4030->codec_powered) in twl4030_codec_enable()
197 twl4030->codec_powered = enable; in twl4030_codec_enable()
200 /* but there seems to be no TRM requirement for it */ in twl4030_codec_enable()
210 of_property_read_u32(node, "ti,digimic_delay", &board_params->digimic_delay); in twl4030_get_board_param_values()
211 of_property_read_u32(node, "ti,ramp_delay_value", &board_params->ramp_delay_value); in twl4030_get_board_param_values()
212 of_property_read_u32(node, "ti,offset_cncl_path", &board_params->offset_cncl_path); in twl4030_get_board_param_values()
214 board_params->hs_extmute = value; in twl4030_get_board_param_values()
216 board_params->hs_extmute_gpio = of_get_named_gpio(node, "ti,hs_extmute_gpio", 0); in twl4030_get_board_param_values()
217 if (gpio_is_valid(board_params->hs_extmute_gpio)) in twl4030_get_board_param_values()
218 board_params->hs_extmute = 1; in twl4030_get_board_param_values()
227 twl4030_codec_node = of_get_child_by_name(component->dev->parent->of_node, in twl4030_get_board_params()
231 board_params = devm_kzalloc(component->dev, in twl4030_get_board_params()
254 if (board_params && board_params->hs_extmute) { in twl4030_init_chip()
255 if (gpio_is_valid(board_params->hs_extmute_gpio)) { in twl4030_init_chip()
258 if (!board_params->hs_extmute_gpio) in twl4030_init_chip()
259 dev_warn(component->dev, in twl4030_init_chip()
262 ret = gpio_request_one(board_params->hs_extmute_gpio, in twl4030_init_chip()
266 dev_err(component->dev, in twl4030_init_chip()
267 "Failed to get hs_extmute GPIO\n"); in twl4030_init_chip()
268 board_params->hs_extmute_gpio = -1; in twl4030_init_chip()
286 /* anti-pop when changing analog gain */ in twl4030_init_chip()
295 /* REG_ARXR2_APGA_CTL reset according to the TRM: 0dB, DA_EN */ in twl4030_init_chip()
302 twl4030->board_params = board_params; in twl4030_init_chip()
306 reg |= (board_params->ramp_delay_value << 2); in twl4030_init_chip()
314 reg |= board_params->offset_cncl_path; in twl4030_init_chip()
319 * Wait for offset cancellation to complete. in twl4030_init_chip()
342 twl4030->apll_enabled++; in twl4030_apll_enable()
343 if (twl4030->apll_enabled == 1) in twl4030_apll_enable()
347 twl4030->apll_enabled--; in twl4030_apll_enable()
348 if (!twl4030->apll_enabled) in twl4030_apll_enable()
459 /* Left analog microphone selection */
471 /* Right analog microphone selection */
477 /* TX1 L/R Analog/Digital microphone selection */
479 {"Analog", "Digimic0"};
488 /* TX2 L/R Analog/Digital microphone selection */
490 {"Analog", "Digimic1"};
499 /* Analog bypass for AudioR1 */
503 /* Analog bypass for AudioL1 */
507 /* Analog bypass for AudioR2 */
511 /* Analog bypass for AudioL2 */
515 /* Analog bypass for Voice */
519 /* Digital bypass gain, mute instead of -30dB */
521 0, 1, TLV_DB_SCALE_ITEM(-3000, 600, 1),
522 2, 3, TLV_DB_SCALE_ITEM(-2400, 0, 0),
523 4, 7, TLV_DB_SCALE_ITEM(-1800, 600, 0)
526 /* Digital bypass left (TX1L -> RX2L) */
532 /* Digital bypass right (TX1R -> RX2R) */
540 * from -51 to -10 dB in 1 dB steps (mute instead of -51 dB)
542 static DECLARE_TLV_DB_SCALE(twl4030_dapm_dbypassv_tlv, -5100, 100, 1);
544 /* Digital bypass voice: sidetone (VUL -> VDL)*/
554 * On mute bypass the reg_cache and write 0 to the register
562 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); \
567 twl4030->pin_name##_enabled = 1; \
571 twl4030->pin_name##_enabled = 0; \
591 /* HF ramp-up */ in handsfree_ramp()
602 /* HF ramp-down */ in handsfree_ramp()
617 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in handsfreelpga_event()
633 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in handsfreerpga_event()
649 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in vibramux_event()
658 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in apll_event()
674 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in aif_event()
681 /* enable the PLL before we use it to clock the DAI */ in aif_event()
701 struct twl4030_board_params *board_params = twl4030->board_params; in headset_ramp()
702 /* Base values for ramp delay calculation: 2^19 - 2^26 */ in headset_ramp()
712 twl4030->sysclk) + 1; in headset_ramp()
715 * the pop-noise */ in headset_ramp()
716 if (board_params && board_params->hs_extmute) { in headset_ramp()
717 if (gpio_is_valid(board_params->hs_extmute_gpio)) { in headset_ramp()
718 gpio_set_value(board_params->hs_extmute_gpio, 1); in headset_ramp()
726 /* Headset ramp-up according to the TRM */ in headset_ramp()
729 /* Actually write to the register */ in headset_ramp()
737 /* Headset ramp-down _not_ according to in headset_ramp()
743 /* Bypass the reg_cache to mute the headset */ in headset_ramp()
752 if (board_params && board_params->hs_extmute) { in headset_ramp()
753 if (gpio_is_valid(board_params->hs_extmute_gpio)) { in headset_ramp()
754 gpio_set_value(board_params->hs_extmute_gpio, 0); in headset_ramp()
765 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in headsetlpga_event()
770 /* Do the ramp-up only once */ in headsetlpga_event()
771 if (!twl4030->hsr_enabled) in headsetlpga_event()
774 twl4030->hsl_enabled = 1; in headsetlpga_event()
777 /* Do the ramp-down only if both headsetL/R is disabled */ in headsetlpga_event()
778 if (!twl4030->hsr_enabled) in headsetlpga_event()
781 twl4030->hsl_enabled = 0; in headsetlpga_event()
790 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in headsetrpga_event()
795 /* Do the ramp-up only once */ in headsetrpga_event()
796 if (!twl4030->hsl_enabled) in headsetrpga_event()
799 twl4030->hsr_enabled = 1; in headsetrpga_event()
802 /* Do the ramp-down only if both headsetL/R is disabled */ in headsetrpga_event()
803 if (!twl4030->hsl_enabled) in headsetrpga_event()
806 twl4030->hsr_enabled = 0; in headsetrpga_event()
815 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in digimic_event()
817 struct twl4030_board_params *board_params = twl4030->board_params; in digimic_event()
819 if (board_params && board_params->digimic_delay) in digimic_event()
820 twl4030_wait_ms(board_params->digimic_delay); in digimic_event()
830 * 0x3 : -6 dB
831 * Inverting not going to help with these.
832 * Custom volsw and volsw_2r get/put functions to handle these gain bits.
838 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_get_volsw_twl4030()
840 unsigned int reg = mc->reg; in snd_soc_get_volsw_twl4030()
841 unsigned int shift = mc->shift; in snd_soc_get_volsw_twl4030()
842 unsigned int rshift = mc->rshift; in snd_soc_get_volsw_twl4030()
843 int max = mc->max; in snd_soc_get_volsw_twl4030()
844 int mask = (1 << fls(max)) - 1; in snd_soc_get_volsw_twl4030()
846 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_twl4030()
848 if (ucontrol->value.integer.value[0]) in snd_soc_get_volsw_twl4030()
849 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_twl4030()
850 max + 1 - ucontrol->value.integer.value[0]; in snd_soc_get_volsw_twl4030()
853 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_twl4030()
855 if (ucontrol->value.integer.value[1]) in snd_soc_get_volsw_twl4030()
856 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_twl4030()
857 max + 1 - ucontrol->value.integer.value[1]; in snd_soc_get_volsw_twl4030()
867 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_put_volsw_twl4030()
869 unsigned int reg = mc->reg; in snd_soc_put_volsw_twl4030()
870 unsigned int shift = mc->shift; in snd_soc_put_volsw_twl4030()
871 unsigned int rshift = mc->rshift; in snd_soc_put_volsw_twl4030()
872 int max = mc->max; in snd_soc_put_volsw_twl4030()
873 int mask = (1 << fls(max)) - 1; in snd_soc_put_volsw_twl4030()
876 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_put_volsw_twl4030()
880 val = max + 1 - val; in snd_soc_put_volsw_twl4030()
883 val2 = (ucontrol->value.integer.value[1] & mask); in snd_soc_put_volsw_twl4030()
886 val2 = max + 1 - val2; in snd_soc_put_volsw_twl4030()
896 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_get_volsw_r2_twl4030()
898 unsigned int reg = mc->reg; in snd_soc_get_volsw_r2_twl4030()
899 unsigned int reg2 = mc->rreg; in snd_soc_get_volsw_r2_twl4030()
900 unsigned int shift = mc->shift; in snd_soc_get_volsw_r2_twl4030()
901 int max = mc->max; in snd_soc_get_volsw_r2_twl4030()
902 int mask = (1<<fls(max))-1; in snd_soc_get_volsw_r2_twl4030()
904 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_r2_twl4030()
906 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_r2_twl4030()
909 if (ucontrol->value.integer.value[0]) in snd_soc_get_volsw_r2_twl4030()
910 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_r2_twl4030()
911 max + 1 - ucontrol->value.integer.value[0]; in snd_soc_get_volsw_r2_twl4030()
912 if (ucontrol->value.integer.value[1]) in snd_soc_get_volsw_r2_twl4030()
913 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_r2_twl4030()
914 max + 1 - ucontrol->value.integer.value[1]; in snd_soc_get_volsw_r2_twl4030()
923 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_put_volsw_r2_twl4030()
925 unsigned int reg = mc->reg; in snd_soc_put_volsw_r2_twl4030()
926 unsigned int reg2 = mc->rreg; in snd_soc_put_volsw_r2_twl4030()
927 unsigned int shift = mc->shift; in snd_soc_put_volsw_r2_twl4030()
928 int max = mc->max; in snd_soc_put_volsw_r2_twl4030()
929 int mask = (1 << fls(max)) - 1; in snd_soc_put_volsw_r2_twl4030()
934 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_put_volsw_r2_twl4030()
935 val2 = (ucontrol->value.integer.value[1] & mask); in snd_soc_put_volsw_r2_twl4030()
938 val = max + 1 - val; in snd_soc_put_volsw_r2_twl4030()
940 val2 = max + 1 - val2; in snd_soc_put_volsw_r2_twl4030()
968 if (twl4030->configured) { in snd_soc_put_twl4030_opmode_enum_double()
969 dev_err(component->dev, in snd_soc_put_twl4030_opmode_enum_double()
970 "operation mode cannot be changed on-the-fly\n"); in snd_soc_put_twl4030_opmode_enum_double()
971 return -EBUSY; in snd_soc_put_twl4030_opmode_enum_double()
979 * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB)
981 static DECLARE_TLV_DB_SCALE(digital_fine_tlv, -6300, 100, 1);
985 * 0 dB to 12 dB in 6 dB steps
992 * from -37 to 12 dB in 1 dB steps (mute instead of -37 dB)
994 static DECLARE_TLV_DB_SCALE(digital_voice_downlink_tlv, -3700, 100, 1);
997 * Analog playback gain
998 * -24 dB to 12 dB in 2 dB steps
1000 static DECLARE_TLV_DB_SCALE(analog_tlv, -2400, 200, 0);
1003 * Gain controls tied to outputs
1004 * -6 dB to 6 dB in 6 dB steps (mute instead of -12)
1006 static DECLARE_TLV_DB_SCALE(output_tvl, -1200, 600, 1);
1010 * 0 dB to 12 dB in 6 dB steps (mute instead of -6)
1012 static DECLARE_TLV_DB_SCALE(output_ear_tvl, -600, 600, 1);
1016 * from 0 dB to 31 dB in 1 dB steps
1022 * 0 dB to 30 dB in 6 dB steps
1045 /* Vibra H-bridge direction mode */
1047 "Vibra H-bridge direction", "Audio data MSB",
1054 /* Vibra H-bridge direction */
1079 SOC_DOUBLE_R_TLV("DAC1 Digital Fine Playback Volume",
1082 SOC_DOUBLE_R_TLV("DAC2 Digital Fine Playback Volume",
1086 SOC_DOUBLE_R_TLV("DAC1 Digital Coarse Playback Volume",
1089 SOC_DOUBLE_R_TLV("DAC2 Digital Coarse Playback Volume",
1093 SOC_DOUBLE_R_TLV("DAC1 Analog Playback Volume",
1096 SOC_DOUBLE_R_TLV("DAC2 Analog Playback Volume",
1099 SOC_DOUBLE_R("DAC1 Analog Playback Switch",
1102 SOC_DOUBLE_R("DAC2 Analog Playback Switch",
1107 SOC_SINGLE_TLV("DAC Voice Digital Downlink Volume",
1110 SOC_SINGLE_TLV("DAC Voice Analog Downlink Volume",
1113 SOC_SINGLE("DAC Voice Analog Downlink Switch",
1136 SOC_DOUBLE_R_TLV("TX1 Digital Capture Volume",
1139 SOC_DOUBLE_R_TLV("TX2 Digital Capture Volume",
1143 SOC_DOUBLE_TLV("Analog Capture Volume", TWL4030_REG_ANAMIC_GAIN,
1150 SOC_ENUM("Vibra H-bridge mode", twl4030_vibradirmode_enum),
1151 SOC_ENUM("Vibra H-bridge direction", twl4030_vibradir_enum),
1165 /* Digital microphones (Stereo) */
1196 /* Analog bypasses */
1197 SND_SOC_DAPM_SWITCH("Right1 Analog Loopback", SND_SOC_NOPM, 0, 0,
1199 SND_SOC_DAPM_SWITCH("Left1 Analog Loopback", SND_SOC_NOPM, 0, 0,
1201 SND_SOC_DAPM_SWITCH("Right2 Analog Loopback", SND_SOC_NOPM, 0, 0,
1203 SND_SOC_DAPM_SWITCH("Left2 Analog Loopback", SND_SOC_NOPM, 0, 0,
1205 SND_SOC_DAPM_SWITCH("Voice Analog Loopback", SND_SOC_NOPM, 0, 0,
1208 /* Master analog loopback switch */
1212 /* Digital bypasses */
1213 SND_SOC_DAPM_SWITCH("Left Digital Loopback", SND_SOC_NOPM, 0, 0,
1215 SND_SOC_DAPM_SWITCH("Right Digital Loopback", SND_SOC_NOPM, 0, 0,
1217 SND_SOC_DAPM_SWITCH("Voice Digital Loopback", SND_SOC_NOPM, 0, 0,
1220 /* Digital mixers, power control for the physical DACs */
1221 SND_SOC_DAPM_MIXER("Digital R1 Playback Mixer",
1223 SND_SOC_DAPM_MIXER("Digital L1 Playback Mixer",
1225 SND_SOC_DAPM_MIXER("Digital R2 Playback Mixer",
1227 SND_SOC_DAPM_MIXER("Digital L2 Playback Mixer",
1229 SND_SOC_DAPM_MIXER("Digital Voice Playback Mixer",
1232 /* Analog mixers, power control for the physical PGAs */
1233 SND_SOC_DAPM_MIXER("Analog R1 Playback Mixer",
1235 SND_SOC_DAPM_MIXER("Analog L1 Playback Mixer",
1237 SND_SOC_DAPM_MIXER("Analog R2 Playback Mixer",
1239 SND_SOC_DAPM_MIXER("Analog L2 Playback Mixer",
1241 SND_SOC_DAPM_MIXER("Analog Voice Playback Mixer",
1331 /* Analog/Digital mic path selection.
1332 TX1 Left/Right: either analog Left/Right or Digimic0
1333 TX2 Left/Right: either analog Left/Right or Digimic1 */
1339 /* Analog input mixers for the capture amplifiers */
1340 SND_SOC_DAPM_MIXER("Analog Left",
1344 SND_SOC_DAPM_MIXER("Analog Right",
1378 /* Stream -> DAC mapping */
1385 /* ADC -> Stream mapping */
1394 {"Digital L1 Playback Mixer", NULL, "DAC Left1"},
1395 {"Digital R1 Playback Mixer", NULL, "DAC Right1"},
1396 {"Digital L2 Playback Mixer", NULL, "DAC Left2"},
1397 {"Digital R2 Playback Mixer", NULL, "DAC Right2"},
1398 {"Digital Voice Playback Mixer", NULL, "DAC Voice"},
1400 /* Supply for the digital part (APLL) */
1401 {"Digital Voice Playback Mixer", NULL, "APLL Enable"},
1409 {"Digital R2 Playback Mixer", NULL, "AIF Enable"},
1410 {"Digital L2 Playback Mixer", NULL, "AIF Enable"},
1412 {"Analog L1 Playback Mixer", NULL, "Digital L1 Playback Mixer"},
1413 {"Analog R1 Playback Mixer", NULL, "Digital R1 Playback Mixer"},
1414 {"Analog L2 Playback Mixer", NULL, "Digital L2 Playback Mixer"},
1415 {"Analog R2 Playback Mixer", NULL, "Digital R2 Playback Mixer"},
1416 {"Analog Voice Playback Mixer", NULL, "Digital Voice Playback Mixer"},
1420 {"Earpiece Mixer", "Voice", "Analog Voice Playback Mixer"},
1421 {"Earpiece Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1422 {"Earpiece Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1423 {"Earpiece Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1426 {"PredriveL Mixer", "Voice", "Analog Voice Playback Mixer"},
1427 {"PredriveL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1428 {"PredriveL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1429 {"PredriveL Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1432 {"PredriveR Mixer", "Voice", "Analog Voice Playback Mixer"},
1433 {"PredriveR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1434 {"PredriveR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1435 {"PredriveR Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1438 {"HeadsetL Mixer", "Voice", "Analog Voice Playback Mixer"},
1439 {"HeadsetL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1440 {"HeadsetL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1443 {"HeadsetR Mixer", "Voice", "Analog Voice Playback Mixer"},
1444 {"HeadsetR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1445 {"HeadsetR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1448 {"CarkitL Mixer", "Voice", "Analog Voice Playback Mixer"},
1449 {"CarkitL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1450 {"CarkitL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1453 {"CarkitR Mixer", "Voice", "Analog Voice Playback Mixer"},
1454 {"CarkitR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1455 {"CarkitR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1458 {"HandsfreeL Mux", "Voice", "Analog Voice Playback Mixer"},
1459 {"HandsfreeL Mux", "AudioL1", "Analog L1 Playback Mixer"},
1460 {"HandsfreeL Mux", "AudioL2", "Analog L2 Playback Mixer"},
1461 {"HandsfreeL Mux", "AudioR2", "Analog R2 Playback Mixer"},
1465 {"HandsfreeR Mux", "Voice", "Analog Voice Playback Mixer"},
1466 {"HandsfreeR Mux", "AudioR1", "Analog R1 Playback Mixer"},
1467 {"HandsfreeR Mux", "AudioR2", "Analog R2 Playback Mixer"},
1468 {"HandsfreeR Mux", "AudioL2", "Analog L2 Playback Mixer"},
1484 {"Virtual Voice OUT", NULL, "Digital Voice Playback Mixer"},
1505 {"Analog Left", "Main Mic Capture Switch", "MAINMIC"},
1506 {"Analog Left", "Headset Mic Capture Switch", "HSMIC"},
1507 {"Analog Left", "AUXL Capture Switch", "AUXL"},
1508 {"Analog Left", "Carkit Mic Capture Switch", "CARKITMIC"},
1510 {"Analog Right", "Sub Mic Capture Switch", "SUBMIC"},
1511 {"Analog Right", "AUXR Capture Switch", "AUXR"},
1513 {"ADC Physical Left", NULL, "Analog Left"},
1514 {"ADC Physical Right", NULL, "Analog Right"},
1523 {"TX1 Capture Route", "Analog", "ADC Physical Left"},
1526 {"TX1 Capture Route", "Analog", "ADC Physical Right"},
1529 {"TX2 Capture Route", "Analog", "ADC Physical Left"},
1532 {"TX2 Capture Route", "Analog", "ADC Physical Right"},
1545 /* Analog bypass routes */
1546 {"Right1 Analog Loopback", "Switch", "Analog Right"},
1547 {"Left1 Analog Loopback", "Switch", "Analog Left"},
1548 {"Right2 Analog Loopback", "Switch", "Analog Right"},
1549 {"Left2 Analog Loopback", "Switch", "Analog Left"},
1550 {"Voice Analog Loopback", "Switch", "Analog Left"},
1552 /* Supply for the Analog loopbacks */
1553 {"Right1 Analog Loopback", NULL, "FM Loop Enable"},
1554 {"Left1 Analog Loopback", NULL, "FM Loop Enable"},
1555 {"Right2 Analog Loopback", NULL, "FM Loop Enable"},
1556 {"Left2 Analog Loopback", NULL, "FM Loop Enable"},
1557 {"Voice Analog Loopback", NULL, "FM Loop Enable"},
1559 {"Analog R1 Playback Mixer", NULL, "Right1 Analog Loopback"},
1560 {"Analog L1 Playback Mixer", NULL, "Left1 Analog Loopback"},
1561 {"Analog R2 Playback Mixer", NULL, "Right2 Analog Loopback"},
1562 {"Analog L2 Playback Mixer", NULL, "Left2 Analog Loopback"},
1563 {"Analog Voice Playback Mixer", NULL, "Voice Analog Loopback"},
1565 /* Digital bypass routes */
1566 {"Right Digital Loopback", "Volume", "TX1 Capture Route"},
1567 {"Left Digital Loopback", "Volume", "TX1 Capture Route"},
1568 {"Voice Digital Loopback", "Volume", "TX2 Capture Route"},
1570 {"Digital R2 Playback Mixer", NULL, "Right Digital Loopback"},
1571 {"Digital L2 Playback Mixer", NULL, "Left Digital Loopback"},
1572 {"Digital Voice Playback Mixer", NULL, "Voice Digital Loopback"},
1601 /* Pick the stream, which need to be constrained */ in twl4030_constraints()
1602 if (mst_substream == twl4030->master_substream) in twl4030_constraints()
1603 slv_substream = twl4030->slave_substream; in twl4030_constraints()
1604 else if (mst_substream == twl4030->slave_substream) in twl4030_constraints()
1605 slv_substream = twl4030->master_substream; in twl4030_constraints()
1609 /* Set the constraints according to the already configured stream */ in twl4030_constraints()
1610 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1612 twl4030->rate); in twl4030_constraints()
1614 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1616 twl4030->sample_bits); in twl4030_constraints()
1618 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1620 twl4030->channels); in twl4030_constraints()
1624 * capture has to be enabled/disabled. */
1648 struct snd_soc_component *component = dai->component; in twl4030_startup()
1651 if (twl4030->master_substream) { in twl4030_startup()
1652 twl4030->slave_substream = substream; in twl4030_startup()
1655 * substream to match it. */ in twl4030_startup()
1656 if (twl4030->configured) in twl4030_startup()
1657 twl4030_constraints(twl4030, twl4030->master_substream); in twl4030_startup()
1664 snd_pcm_hw_constraint_single(substream->runtime, in twl4030_startup()
1668 twl4030->master_substream = substream; in twl4030_startup()
1677 struct snd_soc_component *component = dai->component; in twl4030_shutdown()
1680 if (twl4030->master_substream == substream) in twl4030_shutdown()
1681 twl4030->master_substream = twl4030->slave_substream; in twl4030_shutdown()
1683 twl4030->slave_substream = NULL; in twl4030_shutdown()
1687 if (!twl4030->master_substream) in twl4030_shutdown()
1688 twl4030->configured = 0; in twl4030_shutdown()
1689 else if (!twl4030->master_substream->runtime->channels) in twl4030_shutdown()
1690 twl4030->configured = 0; in twl4030_shutdown()
1693 if (substream->runtime->channels == 4) in twl4030_shutdown()
1694 twl4030_tdm_enable(component, substream->stream, 0); in twl4030_shutdown()
1701 struct snd_soc_component *component = dai->component; in twl4030_hw_params()
1714 twl4030_tdm_enable(component, substream->stream, 1); in twl4030_hw_params()
1716 return -EINVAL; in twl4030_hw_params()
1719 if (twl4030->configured) in twl4030_hw_params()
1760 dev_err(component->dev, "%s: unknown rate %d\n", __func__, in twl4030_hw_params()
1762 return -EINVAL; in twl4030_hw_params()
1777 dev_err(component->dev, "%s: unsupported bits/sample %d\n", in twl4030_hw_params()
1779 return -EINVAL; in twl4030_hw_params()
1783 if (twl4030->codec_powered) { in twl4030_hw_params()
1785 * If the codec is powered, than we need to toggle the in twl4030_hw_params()
1800 twl4030->configured = 1; in twl4030_hw_params()
1801 twl4030->rate = params_rate(params); in twl4030_hw_params()
1802 twl4030->sample_bits = hw_param_interval(params, in twl4030_hw_params()
1803 SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min; in twl4030_hw_params()
1804 twl4030->channels = params_channels(params); in twl4030_hw_params()
1808 * constraints to the other stream to match the current one. */ in twl4030_hw_params()
1809 if (twl4030->slave_substream) in twl4030_hw_params()
1818 struct snd_soc_component *component = codec_dai->component; in twl4030_set_dai_sysclk()
1827 dev_err(component->dev, "Unsupported HFCLKIN: %u\n", freq); in twl4030_set_dai_sysclk()
1828 return -EINVAL; in twl4030_set_dai_sysclk()
1831 if ((freq / 1000) != twl4030->sysclk) { in twl4030_set_dai_sysclk()
1832 dev_err(component->dev, in twl4030_set_dai_sysclk()
1834 freq, twl4030->sysclk * 1000); in twl4030_set_dai_sysclk()
1835 return -EINVAL; in twl4030_set_dai_sysclk()
1843 struct snd_soc_component *component = codec_dai->component; in twl4030_set_dai_fmt()
1861 return -EINVAL; in twl4030_set_dai_fmt()
1874 return -EINVAL; in twl4030_set_dai_fmt()
1878 if (twl4030->codec_powered) { in twl4030_set_dai_fmt()
1880 * If the codec is powered, than we need to toggle the in twl4030_set_dai_fmt()
1896 struct snd_soc_component *component = dai->component; in twl4030_set_tristate()
1908 * (VTXL, VTXR) for uplink has to be enabled/disabled. */
1932 struct snd_soc_component *component = dai->component; in twl4030_voice_startup()
1939 if (twl4030->sysclk != 26000) { in twl4030_voice_startup()
1940 dev_err(component->dev, in twl4030_voice_startup()
1942 __func__, twl4030->sysclk); in twl4030_voice_startup()
1943 return -EINVAL; in twl4030_voice_startup()
1953 dev_err(component->dev, "%s: the codec mode is not option2\n", in twl4030_voice_startup()
1955 return -EINVAL; in twl4030_voice_startup()
1964 struct snd_soc_component *component = dai->component; in twl4030_voice_shutdown()
1966 /* Enable voice digital filters */ in twl4030_voice_shutdown()
1967 twl4030_voice_enable(component, substream->stream, 0); in twl4030_voice_shutdown()
1974 struct snd_soc_component *component = dai->component; in twl4030_voice_hw_params()
1978 /* Enable voice digital filters */ in twl4030_voice_hw_params()
1979 twl4030_voice_enable(component, substream->stream, 1); in twl4030_voice_hw_params()
1994 dev_err(component->dev, "%s: unknown rate %d\n", __func__, in twl4030_voice_hw_params()
1996 return -EINVAL; in twl4030_voice_hw_params()
2000 if (twl4030->codec_powered) { in twl4030_voice_hw_params()
2002 * If the codec is powered, than we need to toggle the in twl4030_voice_hw_params()
2019 struct snd_soc_component *component = codec_dai->component; in twl4030_voice_set_dai_sysclk()
2023 dev_err(component->dev, in twl4030_voice_set_dai_sysclk()
2026 return -EINVAL; in twl4030_voice_set_dai_sysclk()
2028 if ((freq / 1000) != twl4030->sysclk) { in twl4030_voice_set_dai_sysclk()
2029 dev_err(component->dev, in twl4030_voice_set_dai_sysclk()
2031 freq, twl4030->sysclk * 1000); in twl4030_voice_set_dai_sysclk()
2032 return -EINVAL; in twl4030_voice_set_dai_sysclk()
2040 struct snd_soc_component *component = codec_dai->component; in twl4030_voice_set_dai_fmt()
2056 return -EINVAL; in twl4030_voice_set_dai_fmt()
2068 return -EINVAL; in twl4030_voice_set_dai_fmt()
2072 if (twl4030->codec_powered) { in twl4030_voice_set_dai_fmt()
2074 * If the codec is powered, than we need to toggle the in twl4030_voice_set_dai_fmt()
2090 struct snd_soc_component *component = dai->component; in twl4030_voice_set_tristate()
2124 .name = "twl4030-hifi",
2142 .name = "twl4030-voice",
2163 twl4030 = devm_kzalloc(component->dev, sizeof(struct twl4030_priv), in twl4030_soc_probe()
2166 return -ENOMEM; in twl4030_soc_probe()
2169 twl4030->sysclk = twl4030_audio_get_mclk() / 1000; in twl4030_soc_probe()
2179 struct twl4030_board_params *board_params = twl4030->board_params; in twl4030_soc_remove()
2181 if (board_params && board_params->hs_extmute && in twl4030_soc_remove()
2182 gpio_is_valid(board_params->hs_extmute_gpio)) in twl4030_soc_remove()
2183 gpio_free(board_params->hs_extmute_gpio); in twl4030_soc_remove()
2204 return devm_snd_soc_register_component(&pdev->dev, in twl4030_codec_probe()
2209 MODULE_ALIAS("platform:twl4030-codec");
2214 .name = "twl4030-codec",