Lines Matching +full:digital +full:- +full:to +full:- +full:analog
16 * along with this program; if not, write to the Free Software
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()
206 /* but there seems to be no TRM requirement for it */ 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()
275 "Failed to get hs_extmute GPIO\n"); 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()
303 /* REG_ARXR2_APGA_CTL reset according to the TRM: 0dB, DA_EN */ 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()
327 * Wait for offset cancellation to complete. 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()
467 /* Left analog microphone selection */
479 /* Right analog microphone selection */
485 /* TX1 L/R Analog/Digital microphone selection */
487 {"Analog", "Digimic0"};
496 /* TX2 L/R Analog/Digital microphone selection */
498 {"Analog", "Digimic1"};
507 /* Analog bypass for AudioR1 */
511 /* Analog bypass for AudioL1 */
515 /* Analog bypass for AudioR2 */
519 /* Analog bypass for AudioL2 */
523 /* Analog bypass for Voice */
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) */
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)*/
562 * On mute bypass the reg_cache and write 0 to the register
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()
689 /* enable the PLL before we use it to clock the DAI */ 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()
735 /* Actually write to the register */ in headset_ramp()
743 /* Headset ramp-down _not_ according to in headset_ramp()
749 /* Bypass the reg_cache to mute the headset */ 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()
836 * 0x3 : -6 dB
837 * Inverting not going to help with these.
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);
991 * 0 dB to 12 dB in 6 dB steps
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);
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);
1022 * from 0 dB to 31 dB in 1 dB steps
1028 * 0 dB to 30 dB in 6 dB steps
1051 /* Vibra H-bridge direction mode */
1053 "Vibra H-bridge direction", "Audio data MSB",
1060 /* Vibra H-bridge direction */
1085 SOC_DOUBLE_R_TLV("DAC1 Digital Fine Playback Volume",
1088 SOC_DOUBLE_R_TLV("DAC2 Digital Fine Playback Volume",
1092 SOC_DOUBLE_R_TLV("DAC1 Digital Coarse Playback Volume",
1095 SOC_DOUBLE_R_TLV("DAC2 Digital Coarse Playback Volume",
1099 SOC_DOUBLE_R_TLV("DAC1 Analog Playback Volume",
1102 SOC_DOUBLE_R_TLV("DAC2 Analog Playback Volume",
1105 SOC_DOUBLE_R("DAC1 Analog Playback Switch",
1108 SOC_DOUBLE_R("DAC2 Analog Playback Switch",
1113 SOC_SINGLE_TLV("DAC Voice Digital Downlink Volume",
1116 SOC_SINGLE_TLV("DAC Voice Analog Downlink Volume",
1119 SOC_SINGLE("DAC Voice Analog Downlink Switch",
1142 SOC_DOUBLE_R_TLV("TX1 Digital Capture Volume",
1145 SOC_DOUBLE_R_TLV("TX2 Digital Capture Volume",
1149 SOC_DOUBLE_TLV("Analog Capture Volume", TWL4030_REG_ANAMIC_GAIN,
1156 SOC_ENUM("Vibra H-bridge mode", twl4030_vibradirmode_enum),
1157 SOC_ENUM("Vibra H-bridge direction", twl4030_vibradir_enum),
1171 /* Digital microphones (Stereo) */
1202 /* Analog bypasses */
1203 SND_SOC_DAPM_SWITCH("Right1 Analog Loopback", SND_SOC_NOPM, 0, 0,
1205 SND_SOC_DAPM_SWITCH("Left1 Analog Loopback", SND_SOC_NOPM, 0, 0,
1207 SND_SOC_DAPM_SWITCH("Right2 Analog Loopback", SND_SOC_NOPM, 0, 0,
1209 SND_SOC_DAPM_SWITCH("Left2 Analog Loopback", SND_SOC_NOPM, 0, 0,
1211 SND_SOC_DAPM_SWITCH("Voice Analog Loopback", SND_SOC_NOPM, 0, 0,
1214 /* Master analog loopback switch */
1218 /* Digital bypasses */
1219 SND_SOC_DAPM_SWITCH("Left Digital Loopback", SND_SOC_NOPM, 0, 0,
1221 SND_SOC_DAPM_SWITCH("Right Digital Loopback", SND_SOC_NOPM, 0, 0,
1223 SND_SOC_DAPM_SWITCH("Voice Digital Loopback", SND_SOC_NOPM, 0, 0,
1226 /* Digital mixers, power control for the physical DACs */
1227 SND_SOC_DAPM_MIXER("Digital R1 Playback Mixer",
1229 SND_SOC_DAPM_MIXER("Digital L1 Playback Mixer",
1231 SND_SOC_DAPM_MIXER("Digital R2 Playback Mixer",
1233 SND_SOC_DAPM_MIXER("Digital L2 Playback Mixer",
1235 SND_SOC_DAPM_MIXER("Digital Voice Playback Mixer",
1238 /* Analog mixers, power control for the physical PGAs */
1239 SND_SOC_DAPM_MIXER("Analog R1 Playback Mixer",
1241 SND_SOC_DAPM_MIXER("Analog L1 Playback Mixer",
1243 SND_SOC_DAPM_MIXER("Analog R2 Playback Mixer",
1245 SND_SOC_DAPM_MIXER("Analog L2 Playback Mixer",
1247 SND_SOC_DAPM_MIXER("Analog Voice Playback Mixer",
1337 /* Analog/Digital mic path selection.
1338 TX1 Left/Right: either analog Left/Right or Digimic0
1339 TX2 Left/Right: either analog Left/Right or Digimic1 */
1345 /* Analog input mixers for the capture amplifiers */
1346 SND_SOC_DAPM_MIXER("Analog Left",
1350 SND_SOC_DAPM_MIXER("Analog Right",
1384 /* Stream -> DAC mapping */
1391 /* ADC -> Stream mapping */
1400 {"Digital L1 Playback Mixer", NULL, "DAC Left1"},
1401 {"Digital R1 Playback Mixer", NULL, "DAC Right1"},
1402 {"Digital L2 Playback Mixer", NULL, "DAC Left2"},
1403 {"Digital R2 Playback Mixer", NULL, "DAC Right2"},
1404 {"Digital Voice Playback Mixer", NULL, "DAC Voice"},
1406 /* Supply for the digital part (APLL) */
1407 {"Digital Voice Playback Mixer", NULL, "APLL Enable"},
1415 {"Digital R2 Playback Mixer", NULL, "AIF Enable"},
1416 {"Digital L2 Playback Mixer", NULL, "AIF Enable"},
1418 {"Analog L1 Playback Mixer", NULL, "Digital L1 Playback Mixer"},
1419 {"Analog R1 Playback Mixer", NULL, "Digital R1 Playback Mixer"},
1420 {"Analog L2 Playback Mixer", NULL, "Digital L2 Playback Mixer"},
1421 {"Analog R2 Playback Mixer", NULL, "Digital R2 Playback Mixer"},
1422 {"Analog Voice Playback Mixer", NULL, "Digital Voice Playback Mixer"},
1426 {"Earpiece Mixer", "Voice", "Analog Voice Playback Mixer"},
1427 {"Earpiece Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1428 {"Earpiece Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1429 {"Earpiece Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1432 {"PredriveL Mixer", "Voice", "Analog Voice Playback Mixer"},
1433 {"PredriveL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1434 {"PredriveL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1435 {"PredriveL Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1438 {"PredriveR Mixer", "Voice", "Analog Voice Playback Mixer"},
1439 {"PredriveR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1440 {"PredriveR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1441 {"PredriveR Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1444 {"HeadsetL Mixer", "Voice", "Analog Voice Playback Mixer"},
1445 {"HeadsetL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1446 {"HeadsetL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1449 {"HeadsetR Mixer", "Voice", "Analog Voice Playback Mixer"},
1450 {"HeadsetR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1451 {"HeadsetR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1454 {"CarkitL Mixer", "Voice", "Analog Voice Playback Mixer"},
1455 {"CarkitL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1456 {"CarkitL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1459 {"CarkitR Mixer", "Voice", "Analog Voice Playback Mixer"},
1460 {"CarkitR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1461 {"CarkitR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1464 {"HandsfreeL Mux", "Voice", "Analog Voice Playback Mixer"},
1465 {"HandsfreeL Mux", "AudioL1", "Analog L1 Playback Mixer"},
1466 {"HandsfreeL Mux", "AudioL2", "Analog L2 Playback Mixer"},
1467 {"HandsfreeL Mux", "AudioR2", "Analog R2 Playback Mixer"},
1471 {"HandsfreeR Mux", "Voice", "Analog Voice Playback Mixer"},
1472 {"HandsfreeR Mux", "AudioR1", "Analog R1 Playback Mixer"},
1473 {"HandsfreeR Mux", "AudioR2", "Analog R2 Playback Mixer"},
1474 {"HandsfreeR Mux", "AudioL2", "Analog L2 Playback Mixer"},
1490 {"Virtual Voice OUT", NULL, "Digital Voice Playback Mixer"},
1511 {"Analog Left", "Main Mic Capture Switch", "MAINMIC"},
1512 {"Analog Left", "Headset Mic Capture Switch", "HSMIC"},
1513 {"Analog Left", "AUXL Capture Switch", "AUXL"},
1514 {"Analog Left", "Carkit Mic Capture Switch", "CARKITMIC"},
1516 {"Analog Right", "Sub Mic Capture Switch", "SUBMIC"},
1517 {"Analog Right", "AUXR Capture Switch", "AUXR"},
1519 {"ADC Physical Left", NULL, "Analog Left"},
1520 {"ADC Physical Right", NULL, "Analog Right"},
1529 {"TX1 Capture Route", "Analog", "ADC Physical Left"},
1532 {"TX1 Capture Route", "Analog", "ADC Physical Right"},
1535 {"TX2 Capture Route", "Analog", "ADC Physical Left"},
1538 {"TX2 Capture Route", "Analog", "ADC Physical Right"},
1551 /* Analog bypass routes */
1552 {"Right1 Analog Loopback", "Switch", "Analog Right"},
1553 {"Left1 Analog Loopback", "Switch", "Analog Left"},
1554 {"Right2 Analog Loopback", "Switch", "Analog Right"},
1555 {"Left2 Analog Loopback", "Switch", "Analog Left"},
1556 {"Voice Analog Loopback", "Switch", "Analog Left"},
1558 /* Supply for the Analog loopbacks */
1559 {"Right1 Analog Loopback", NULL, "FM Loop Enable"},
1560 {"Left1 Analog Loopback", NULL, "FM Loop Enable"},
1561 {"Right2 Analog Loopback", NULL, "FM Loop Enable"},
1562 {"Left2 Analog Loopback", NULL, "FM Loop Enable"},
1563 {"Voice Analog Loopback", NULL, "FM Loop Enable"},
1565 {"Analog R1 Playback Mixer", NULL, "Right1 Analog Loopback"},
1566 {"Analog L1 Playback Mixer", NULL, "Left1 Analog Loopback"},
1567 {"Analog R2 Playback Mixer", NULL, "Right2 Analog Loopback"},
1568 {"Analog L2 Playback Mixer", NULL, "Left2 Analog Loopback"},
1569 {"Analog Voice Playback Mixer", NULL, "Voice Analog Loopback"},
1571 /* Digital bypass routes */
1572 {"Right Digital Loopback", "Volume", "TX1 Capture Route"},
1573 {"Left Digital Loopback", "Volume", "TX1 Capture Route"},
1574 {"Voice Digital Loopback", "Volume", "TX2 Capture Route"},
1576 {"Digital R2 Playback Mixer", NULL, "Right Digital Loopback"},
1577 {"Digital L2 Playback Mixer", NULL, "Left Digital Loopback"},
1578 {"Digital Voice Playback Mixer", NULL, "Voice Digital Loopback"},
1607 /* Pick the stream, which need to be constrained */ in twl4030_constraints()
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()
1615 /* Set the constraints according to the already configured stream */ 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()
1630 * capture has to be enabled/disabled. */
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()
1661 * substream to match it. */ 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()
1791 * If the codec is powered, than we need to toggle the 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()
1814 * constraints to the other stream to match the current one. */ 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()
1887 * If the codec is powered, than we need to toggle the in twl4030_set_dai_fmt()
1903 struct snd_soc_component *component = dai->component; in twl4030_set_tristate()
1915 * (VTXL, VTXR) for uplink has to be enabled/disabled. */
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()
1973 /* Enable voice digital filters */ 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()
1985 /* Enable voice digital filters */ 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()
2009 * If the codec is powered, than we need to toggle the 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()
2082 * If the codec is powered, than we need to toggle the 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",