Lines Matching +full:codec +full:- +full:analog +full:- +full:controls
1 // SPDX-License-Identifier: GPL-2.0-only
3 * ALSA SoC TWL4030 codec driver
13 #include <linux/mfd/twl4030-audio.h>
42 /* codec private data */
64 u8 ctl_cache[TWL4030_REG_PRECKR_CTL - TWL4030_REG_EAR_CTL + 1];
76 twl4030->ctl_cache[i - TWL4030_REG_EAR_CTL] = byte; in tw4030_init_ctl_cache()
86 return -EIO; in twl4030_read()
95 value = twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL]; in twl4030_read()
113 if (twl4030->earpiece_enabled) in twl4030_can_write_to_chip()
117 if (twl4030->predrivel_enabled) in twl4030_can_write_to_chip()
121 if (twl4030->predriver_enabled) in twl4030_can_write_to_chip()
125 if (twl4030->carkitl_enabled) in twl4030_can_write_to_chip()
129 if (twl4030->carkitr_enabled) in twl4030_can_write_to_chip()
133 if (twl4030->hsl_enabled || twl4030->hsr_enabled) in twl4030_can_write_to_chip()
158 twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL] = value; in twl4030_write()
185 if (enable == twl4030->codec_powered) in twl4030_codec_enable()
194 twl4030->codec_powered = enable; in twl4030_codec_enable()
207 of_property_read_u32(node, "ti,digimic_delay", &board_params->digimic_delay); in twl4030_get_board_param_values()
208 of_property_read_u32(node, "ti,ramp_delay_value", &board_params->ramp_delay_value); in twl4030_get_board_param_values()
209 of_property_read_u32(node, "ti,offset_cncl_path", &board_params->offset_cncl_path); in twl4030_get_board_param_values()
211 board_params->hs_extmute = value; in twl4030_get_board_param_values()
214 board_params->hs_extmute = 1; in twl4030_get_board_param_values()
223 twl4030_codec_node = of_get_child_by_name(component->dev->parent->of_node, in twl4030_get_board_params()
224 "codec"); in twl4030_get_board_params()
227 board_params = devm_kzalloc(component->dev, in twl4030_get_board_params()
250 if (board_params && board_params->hs_extmute) { in twl4030_init_chip()
251 board_params->hs_extmute_gpio = devm_gpiod_get_optional(component->dev, in twl4030_init_chip()
254 if (IS_ERR(board_params->hs_extmute_gpio)) in twl4030_init_chip()
255 return dev_err_probe(component->dev, PTR_ERR(board_params->hs_extmute_gpio), in twl4030_init_chip()
258 if (board_params->hs_extmute_gpio) { in twl4030_init_chip()
259 gpiod_set_consumer_name(board_params->hs_extmute_gpio, "hs_extmute"); in twl4030_init_chip()
263 dev_info(component->dev, "use TWL4030 GPIO6\n"); in twl4030_init_chip()
278 /* anti-pop when changing analog gain */ in twl4030_init_chip()
294 twl4030->board_params = board_params; in twl4030_init_chip()
298 reg |= (board_params->ramp_delay_value << 2); in twl4030_init_chip()
306 reg |= board_params->offset_cncl_path; in twl4030_init_chip()
336 twl4030->apll_enabled++; in twl4030_apll_enable()
337 if (twl4030->apll_enabled == 1) in twl4030_apll_enable()
341 twl4030->apll_enabled--; in twl4030_apll_enable()
342 if (!twl4030->apll_enabled) in twl4030_apll_enable()
453 /* Left analog microphone selection */
465 /* Right analog microphone selection */
471 /* TX1 L/R Analog/Digital microphone selection */
473 {"Analog", "Digimic0"};
482 /* TX2 L/R Analog/Digital microphone selection */
484 {"Analog", "Digimic1"};
493 /* Analog bypass for AudioR1 */
497 /* Analog bypass for AudioL1 */
501 /* Analog bypass for AudioR2 */
505 /* Analog bypass for AudioL2 */
509 /* Analog bypass for Voice */
513 /* Digital bypass gain, mute instead of -30dB */
515 0, 1, TLV_DB_SCALE_ITEM(-3000, 600, 1),
516 2, 3, TLV_DB_SCALE_ITEM(-2400, 0, 0),
517 4, 7, TLV_DB_SCALE_ITEM(-1800, 600, 0)
520 /* Digital bypass left (TX1L -> RX2L) */
526 /* Digital bypass right (TX1R -> RX2R) */
534 * from -51 to -10 dB in 1 dB steps (mute instead of -51 dB)
536 static DECLARE_TLV_DB_SCALE(twl4030_dapm_dbypassv_tlv, -5100, 100, 1);
538 /* Digital bypass voice: sidetone (VUL -> VDL)*/
556 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); \
561 twl4030->pin_name##_enabled = 1; \
565 twl4030->pin_name##_enabled = 0; \
585 /* HF ramp-up */ in handsfree_ramp()
596 /* HF ramp-down */ in handsfree_ramp()
611 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in handsfreelpga_event()
627 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in handsfreerpga_event()
643 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in vibramux_event()
652 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in apll_event()
668 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in aif_event()
695 struct twl4030_board_params *board_params = twl4030->board_params; in headset_ramp()
696 /* Base values for ramp delay calculation: 2^19 - 2^26 */ in headset_ramp()
706 twl4030->sysclk) + 1; in headset_ramp()
709 * the pop-noise */ in headset_ramp()
710 if (board_params && board_params->hs_extmute) { in headset_ramp()
711 if (board_params->hs_extmute_gpio) { in headset_ramp()
712 gpiod_set_value(board_params->hs_extmute_gpio, 1); in headset_ramp()
720 /* Headset ramp-up according to the TRM */ in headset_ramp()
731 /* Headset ramp-down _not_ according to in headset_ramp()
746 if (board_params && board_params->hs_extmute) { in headset_ramp()
747 if (board_params->hs_extmute_gpio) { in headset_ramp()
748 gpiod_set_value(board_params->hs_extmute_gpio, 0); in headset_ramp()
759 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in headsetlpga_event()
764 /* Do the ramp-up only once */ in headsetlpga_event()
765 if (!twl4030->hsr_enabled) in headsetlpga_event()
768 twl4030->hsl_enabled = 1; in headsetlpga_event()
771 /* Do the ramp-down only if both headsetL/R is disabled */ in headsetlpga_event()
772 if (!twl4030->hsr_enabled) in headsetlpga_event()
775 twl4030->hsl_enabled = 0; in headsetlpga_event()
784 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in headsetrpga_event()
789 /* Do the ramp-up only once */ in headsetrpga_event()
790 if (!twl4030->hsl_enabled) in headsetrpga_event()
793 twl4030->hsr_enabled = 1; in headsetrpga_event()
796 /* Do the ramp-down only if both headsetL/R is disabled */ in headsetrpga_event()
797 if (!twl4030->hsl_enabled) in headsetrpga_event()
800 twl4030->hsr_enabled = 0; in headsetrpga_event()
809 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in digimic_event()
811 struct twl4030_board_params *board_params = twl4030->board_params; in digimic_event()
813 if (board_params && board_params->digimic_delay) in digimic_event()
814 twl4030_wait_ms(board_params->digimic_delay); in digimic_event()
819 * Some of the gain controls in TWL (mostly those which are associated with
824 * 0x3 : -6 dB
832 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_get_volsw_twl4030()
834 unsigned int reg = mc->reg; in snd_soc_get_volsw_twl4030()
835 unsigned int shift = mc->shift; in snd_soc_get_volsw_twl4030()
836 unsigned int rshift = mc->rshift; in snd_soc_get_volsw_twl4030()
837 int max = mc->max; in snd_soc_get_volsw_twl4030()
838 int mask = (1 << fls(max)) - 1; in snd_soc_get_volsw_twl4030()
840 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_twl4030()
842 if (ucontrol->value.integer.value[0]) in snd_soc_get_volsw_twl4030()
843 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_twl4030()
844 max + 1 - ucontrol->value.integer.value[0]; in snd_soc_get_volsw_twl4030()
847 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_twl4030()
849 if (ucontrol->value.integer.value[1]) in snd_soc_get_volsw_twl4030()
850 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_twl4030()
851 max + 1 - ucontrol->value.integer.value[1]; in snd_soc_get_volsw_twl4030()
861 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_put_volsw_twl4030()
863 unsigned int reg = mc->reg; in snd_soc_put_volsw_twl4030()
864 unsigned int shift = mc->shift; in snd_soc_put_volsw_twl4030()
865 unsigned int rshift = mc->rshift; in snd_soc_put_volsw_twl4030()
866 int max = mc->max; in snd_soc_put_volsw_twl4030()
867 int mask = (1 << fls(max)) - 1; in snd_soc_put_volsw_twl4030()
870 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_put_volsw_twl4030()
874 val = max + 1 - val; in snd_soc_put_volsw_twl4030()
877 val2 = (ucontrol->value.integer.value[1] & mask); in snd_soc_put_volsw_twl4030()
880 val2 = max + 1 - val2; in snd_soc_put_volsw_twl4030()
890 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_get_volsw_r2_twl4030()
892 unsigned int reg = mc->reg; in snd_soc_get_volsw_r2_twl4030()
893 unsigned int reg2 = mc->rreg; in snd_soc_get_volsw_r2_twl4030()
894 unsigned int shift = mc->shift; in snd_soc_get_volsw_r2_twl4030()
895 int max = mc->max; in snd_soc_get_volsw_r2_twl4030()
896 int mask = (1<<fls(max))-1; in snd_soc_get_volsw_r2_twl4030()
898 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_r2_twl4030()
900 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_r2_twl4030()
903 if (ucontrol->value.integer.value[0]) in snd_soc_get_volsw_r2_twl4030()
904 ucontrol->value.integer.value[0] = in snd_soc_get_volsw_r2_twl4030()
905 max + 1 - ucontrol->value.integer.value[0]; in snd_soc_get_volsw_r2_twl4030()
906 if (ucontrol->value.integer.value[1]) in snd_soc_get_volsw_r2_twl4030()
907 ucontrol->value.integer.value[1] = in snd_soc_get_volsw_r2_twl4030()
908 max + 1 - ucontrol->value.integer.value[1]; in snd_soc_get_volsw_r2_twl4030()
917 (struct soc_mixer_control *)kcontrol->private_value; in snd_soc_put_volsw_r2_twl4030()
919 unsigned int reg = mc->reg; in snd_soc_put_volsw_r2_twl4030()
920 unsigned int reg2 = mc->rreg; in snd_soc_put_volsw_r2_twl4030()
921 unsigned int shift = mc->shift; in snd_soc_put_volsw_r2_twl4030()
922 int max = mc->max; in snd_soc_put_volsw_r2_twl4030()
923 int mask = (1 << fls(max)) - 1; in snd_soc_put_volsw_r2_twl4030()
928 val = (ucontrol->value.integer.value[0] & mask); in snd_soc_put_volsw_r2_twl4030()
929 val2 = (ucontrol->value.integer.value[1] & mask); in snd_soc_put_volsw_r2_twl4030()
932 val = max + 1 - val; in snd_soc_put_volsw_r2_twl4030()
934 val2 = max + 1 - val2; in snd_soc_put_volsw_r2_twl4030()
947 /* Codec operation modes */
962 if (twl4030->configured) { in snd_soc_put_twl4030_opmode_enum_double()
963 dev_err(component->dev, in snd_soc_put_twl4030_opmode_enum_double()
964 "operation mode cannot be changed on-the-fly\n"); in snd_soc_put_twl4030_opmode_enum_double()
965 return -EBUSY; in snd_soc_put_twl4030_opmode_enum_double()
973 * from -62 to 0 dB in 1 dB steps (mute instead of -63 dB)
975 static DECLARE_TLV_DB_SCALE(digital_fine_tlv, -6300, 100, 1);
986 * from -37 to 12 dB in 1 dB steps (mute instead of -37 dB)
988 static DECLARE_TLV_DB_SCALE(digital_voice_downlink_tlv, -3700, 100, 1);
991 * Analog playback gain
992 * -24 dB to 12 dB in 2 dB steps
994 static DECLARE_TLV_DB_SCALE(analog_tlv, -2400, 200, 0);
997 * Gain controls tied to outputs
998 * -6 dB to 6 dB in 6 dB steps (mute instead of -12)
1000 static DECLARE_TLV_DB_SCALE(output_tvl, -1200, 600, 1);
1004 * 0 dB to 12 dB in 6 dB steps (mute instead of -6)
1006 static DECLARE_TLV_DB_SCALE(output_ear_tvl, -600, 600, 1);
1039 /* Vibra H-bridge direction mode */
1041 "Vibra H-bridge direction", "Audio data MSB",
1048 /* Vibra H-bridge direction */
1067 /* Codec operation mode control */
1068 SOC_ENUM_EXT("Codec Operation Mode", twl4030_op_modes_enum,
1072 /* Common playback gain controls */
1087 SOC_DOUBLE_R_TLV("DAC1 Analog Playback Volume",
1090 SOC_DOUBLE_R_TLV("DAC2 Analog Playback Volume",
1093 SOC_DOUBLE_R("DAC1 Analog Playback Switch",
1096 SOC_DOUBLE_R("DAC2 Analog Playback Switch",
1100 /* Common voice downlink gain controls */
1104 SOC_SINGLE_TLV("DAC Voice Analog Downlink Volume",
1107 SOC_SINGLE("DAC Voice Analog Downlink Switch",
1110 /* Separate output gain controls */
1129 /* Common capture gain controls */
1137 SOC_DOUBLE_TLV("Analog Capture Volume", TWL4030_REG_ANAMIC_GAIN,
1144 SOC_ENUM("Vibra H-bridge mode", twl4030_vibradirmode_enum),
1145 SOC_ENUM("Vibra H-bridge direction", twl4030_vibradir_enum),
1190 /* Analog bypasses */
1191 SND_SOC_DAPM_SWITCH("Right1 Analog Loopback", SND_SOC_NOPM, 0, 0,
1193 SND_SOC_DAPM_SWITCH("Left1 Analog Loopback", SND_SOC_NOPM, 0, 0,
1195 SND_SOC_DAPM_SWITCH("Right2 Analog Loopback", SND_SOC_NOPM, 0, 0,
1197 SND_SOC_DAPM_SWITCH("Left2 Analog Loopback", SND_SOC_NOPM, 0, 0,
1199 SND_SOC_DAPM_SWITCH("Voice Analog Loopback", SND_SOC_NOPM, 0, 0,
1202 /* Master analog loopback switch */
1226 /* Analog mixers, power control for the physical PGAs */
1227 SND_SOC_DAPM_MIXER("Analog R1 Playback Mixer",
1229 SND_SOC_DAPM_MIXER("Analog L1 Playback Mixer",
1231 SND_SOC_DAPM_MIXER("Analog R2 Playback Mixer",
1233 SND_SOC_DAPM_MIXER("Analog L2 Playback Mixer",
1235 SND_SOC_DAPM_MIXER("Analog Voice Playback Mixer",
1244 /* Output MIXER controls */
1292 /* Output MUX controls */
1325 /* Analog/Digital mic path selection.
1326 TX1 Left/Right: either analog Left/Right or Digimic0
1327 TX2 Left/Right: either analog Left/Right or Digimic1 */
1333 /* Analog input mixers for the capture amplifiers */
1334 SND_SOC_DAPM_MIXER("Analog Left",
1338 SND_SOC_DAPM_MIXER("Analog Right",
1372 /* Stream -> DAC mapping */
1379 /* ADC -> Stream mapping */
1406 {"Analog L1 Playback Mixer", NULL, "Digital L1 Playback Mixer"},
1407 {"Analog R1 Playback Mixer", NULL, "Digital R1 Playback Mixer"},
1408 {"Analog L2 Playback Mixer", NULL, "Digital L2 Playback Mixer"},
1409 {"Analog R2 Playback Mixer", NULL, "Digital R2 Playback Mixer"},
1410 {"Analog Voice Playback Mixer", NULL, "Digital Voice Playback Mixer"},
1414 {"Earpiece Mixer", "Voice", "Analog Voice Playback Mixer"},
1415 {"Earpiece Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1416 {"Earpiece Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1417 {"Earpiece Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1420 {"PredriveL Mixer", "Voice", "Analog Voice Playback Mixer"},
1421 {"PredriveL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1422 {"PredriveL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1423 {"PredriveL Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1426 {"PredriveR Mixer", "Voice", "Analog Voice Playback Mixer"},
1427 {"PredriveR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1428 {"PredriveR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1429 {"PredriveR Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1432 {"HeadsetL Mixer", "Voice", "Analog Voice Playback Mixer"},
1433 {"HeadsetL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1434 {"HeadsetL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1437 {"HeadsetR Mixer", "Voice", "Analog Voice Playback Mixer"},
1438 {"HeadsetR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1439 {"HeadsetR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1442 {"CarkitL Mixer", "Voice", "Analog Voice Playback Mixer"},
1443 {"CarkitL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
1444 {"CarkitL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
1447 {"CarkitR Mixer", "Voice", "Analog Voice Playback Mixer"},
1448 {"CarkitR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
1449 {"CarkitR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
1452 {"HandsfreeL Mux", "Voice", "Analog Voice Playback Mixer"},
1453 {"HandsfreeL Mux", "AudioL1", "Analog L1 Playback Mixer"},
1454 {"HandsfreeL Mux", "AudioL2", "Analog L2 Playback Mixer"},
1455 {"HandsfreeL Mux", "AudioR2", "Analog R2 Playback Mixer"},
1459 {"HandsfreeR Mux", "Voice", "Analog Voice Playback Mixer"},
1460 {"HandsfreeR Mux", "AudioR1", "Analog R1 Playback Mixer"},
1461 {"HandsfreeR Mux", "AudioR2", "Analog R2 Playback Mixer"},
1462 {"HandsfreeR Mux", "AudioL2", "Analog L2 Playback Mixer"},
1499 {"Analog Left", "Main Mic Capture Switch", "MAINMIC"},
1500 {"Analog Left", "Headset Mic Capture Switch", "HSMIC"},
1501 {"Analog Left", "AUXL Capture Switch", "AUXL"},
1502 {"Analog Left", "Carkit Mic Capture Switch", "CARKITMIC"},
1504 {"Analog Right", "Sub Mic Capture Switch", "SUBMIC"},
1505 {"Analog Right", "AUXR Capture Switch", "AUXR"},
1507 {"ADC Physical Left", NULL, "Analog Left"},
1508 {"ADC Physical Right", NULL, "Analog Right"},
1517 {"TX1 Capture Route", "Analog", "ADC Physical Left"},
1520 {"TX1 Capture Route", "Analog", "ADC Physical Right"},
1523 {"TX2 Capture Route", "Analog", "ADC Physical Left"},
1526 {"TX2 Capture Route", "Analog", "ADC Physical Right"},
1539 /* Analog bypass routes */
1540 {"Right1 Analog Loopback", "Switch", "Analog Right"},
1541 {"Left1 Analog Loopback", "Switch", "Analog Left"},
1542 {"Right2 Analog Loopback", "Switch", "Analog Right"},
1543 {"Left2 Analog Loopback", "Switch", "Analog Left"},
1544 {"Voice Analog Loopback", "Switch", "Analog Left"},
1546 /* Supply for the Analog loopbacks */
1547 {"Right1 Analog Loopback", NULL, "FM Loop Enable"},
1548 {"Left1 Analog Loopback", NULL, "FM Loop Enable"},
1549 {"Right2 Analog Loopback", NULL, "FM Loop Enable"},
1550 {"Left2 Analog Loopback", NULL, "FM Loop Enable"},
1551 {"Voice Analog Loopback", NULL, "FM Loop Enable"},
1553 {"Analog R1 Playback Mixer", NULL, "Right1 Analog Loopback"},
1554 {"Analog L1 Playback Mixer", NULL, "Left1 Analog Loopback"},
1555 {"Analog R2 Playback Mixer", NULL, "Right2 Analog Loopback"},
1556 {"Analog L2 Playback Mixer", NULL, "Left2 Analog Loopback"},
1557 {"Analog Voice Playback Mixer", NULL, "Voice Analog Loopback"},
1596 if (mst_substream == twl4030->master_substream) in twl4030_constraints()
1597 slv_substream = twl4030->slave_substream; in twl4030_constraints()
1598 else if (mst_substream == twl4030->slave_substream) in twl4030_constraints()
1599 slv_substream = twl4030->master_substream; in twl4030_constraints()
1604 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1606 twl4030->rate); in twl4030_constraints()
1608 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1610 twl4030->sample_bits); in twl4030_constraints()
1612 snd_pcm_hw_constraint_single(slv_substream->runtime, in twl4030_constraints()
1614 twl4030->channels); in twl4030_constraints()
1642 struct snd_soc_component *component = dai->component; in twl4030_startup()
1645 if (twl4030->master_substream) { in twl4030_startup()
1646 twl4030->slave_substream = substream; in twl4030_startup()
1650 if (twl4030->configured) in twl4030_startup()
1651 twl4030_constraints(twl4030, twl4030->master_substream); in twl4030_startup()
1658 snd_pcm_hw_constraint_single(substream->runtime, in twl4030_startup()
1662 twl4030->master_substream = substream; in twl4030_startup()
1671 struct snd_soc_component *component = dai->component; in twl4030_shutdown()
1674 if (twl4030->master_substream == substream) in twl4030_shutdown()
1675 twl4030->master_substream = twl4030->slave_substream; in twl4030_shutdown()
1677 twl4030->slave_substream = NULL; in twl4030_shutdown()
1681 if (!twl4030->master_substream) in twl4030_shutdown()
1682 twl4030->configured = 0; in twl4030_shutdown()
1683 else if (!twl4030->master_substream->runtime->channels) in twl4030_shutdown()
1684 twl4030->configured = 0; in twl4030_shutdown()
1687 if (substream->runtime->channels == 4) in twl4030_shutdown()
1688 twl4030_tdm_enable(component, substream->stream, 0); in twl4030_shutdown()
1695 struct snd_soc_component *component = dai->component; in twl4030_hw_params()
1708 twl4030_tdm_enable(component, substream->stream, 1); in twl4030_hw_params()
1710 return -EINVAL; in twl4030_hw_params()
1713 if (twl4030->configured) in twl4030_hw_params()
1754 dev_err(component->dev, "%s: unknown rate %d\n", __func__, in twl4030_hw_params()
1756 return -EINVAL; in twl4030_hw_params()
1771 dev_err(component->dev, "%s: unsupported bits/sample %d\n", in twl4030_hw_params()
1773 return -EINVAL; in twl4030_hw_params()
1777 if (twl4030->codec_powered) { in twl4030_hw_params()
1779 * If the codec is powered, than we need to toggle the in twl4030_hw_params()
1780 * codec power. in twl4030_hw_params()
1794 twl4030->configured = 1; in twl4030_hw_params()
1795 twl4030->rate = params_rate(params); in twl4030_hw_params()
1796 twl4030->sample_bits = hw_param_interval(params, in twl4030_hw_params()
1797 SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min; in twl4030_hw_params()
1798 twl4030->channels = params_channels(params); in twl4030_hw_params()
1803 if (twl4030->slave_substream) in twl4030_hw_params()
1812 struct snd_soc_component *component = codec_dai->component; in twl4030_set_dai_sysclk()
1821 dev_err(component->dev, "Unsupported HFCLKIN: %u\n", freq); in twl4030_set_dai_sysclk()
1822 return -EINVAL; in twl4030_set_dai_sysclk()
1825 if ((freq / 1000) != twl4030->sysclk) { in twl4030_set_dai_sysclk()
1826 dev_err(component->dev, in twl4030_set_dai_sysclk()
1828 freq, twl4030->sysclk * 1000); in twl4030_set_dai_sysclk()
1829 return -EINVAL; in twl4030_set_dai_sysclk()
1837 struct snd_soc_component *component = codec_dai->component; in twl4030_set_dai_fmt()
1855 return -EINVAL; in twl4030_set_dai_fmt()
1868 return -EINVAL; in twl4030_set_dai_fmt()
1872 if (twl4030->codec_powered) { in twl4030_set_dai_fmt()
1874 * If the codec is powered, than we need to toggle the in twl4030_set_dai_fmt()
1875 * codec power. in twl4030_set_dai_fmt()
1890 struct snd_soc_component *component = dai->component; in twl4030_set_tristate()
1926 struct snd_soc_component *component = dai->component; in twl4030_voice_startup()
1933 if (twl4030->sysclk != 26000) { in twl4030_voice_startup()
1934 dev_err(component->dev, in twl4030_voice_startup()
1936 __func__, twl4030->sysclk); in twl4030_voice_startup()
1937 return -EINVAL; in twl4030_voice_startup()
1940 /* If the codec mode is not option2, the voice PCM interface is not in twl4030_voice_startup()
1947 dev_err(component->dev, "%s: the codec mode is not option2\n", in twl4030_voice_startup()
1949 return -EINVAL; in twl4030_voice_startup()
1958 struct snd_soc_component *component = dai->component; in twl4030_voice_shutdown()
1961 twl4030_voice_enable(component, substream->stream, 0); in twl4030_voice_shutdown()
1968 struct snd_soc_component *component = dai->component; in twl4030_voice_hw_params()
1973 twl4030_voice_enable(component, substream->stream, 1); in twl4030_voice_hw_params()
1988 dev_err(component->dev, "%s: unknown rate %d\n", __func__, in twl4030_voice_hw_params()
1990 return -EINVAL; in twl4030_voice_hw_params()
1994 if (twl4030->codec_powered) { in twl4030_voice_hw_params()
1996 * If the codec is powered, than we need to toggle the in twl4030_voice_hw_params()
1997 * codec power. in twl4030_voice_hw_params()
2013 struct snd_soc_component *component = codec_dai->component; in twl4030_voice_set_dai_sysclk()
2017 dev_err(component->dev, in twl4030_voice_set_dai_sysclk()
2020 return -EINVAL; in twl4030_voice_set_dai_sysclk()
2022 if ((freq / 1000) != twl4030->sysclk) { in twl4030_voice_set_dai_sysclk()
2023 dev_err(component->dev, in twl4030_voice_set_dai_sysclk()
2025 freq, twl4030->sysclk * 1000); in twl4030_voice_set_dai_sysclk()
2026 return -EINVAL; in twl4030_voice_set_dai_sysclk()
2034 struct snd_soc_component *component = codec_dai->component; in twl4030_voice_set_dai_fmt()
2050 return -EINVAL; in twl4030_voice_set_dai_fmt()
2062 return -EINVAL; in twl4030_voice_set_dai_fmt()
2066 if (twl4030->codec_powered) { in twl4030_voice_set_dai_fmt()
2068 * If the codec is powered, than we need to toggle the in twl4030_voice_set_dai_fmt()
2069 * codec power. in twl4030_voice_set_dai_fmt()
2084 struct snd_soc_component *component = dai->component; in twl4030_voice_set_tristate()
2118 .name = "twl4030-hifi",
2136 .name = "twl4030-voice",
2157 twl4030 = devm_kzalloc(component->dev, sizeof(struct twl4030_priv), in twl4030_soc_probe()
2160 return -ENOMEM; in twl4030_soc_probe()
2162 /* Set the defaults, and power up the codec */ in twl4030_soc_probe()
2163 twl4030->sysclk = twl4030_audio_get_mclk() / 1000; in twl4030_soc_probe()
2173 .controls = twl4030_snd_controls,
2185 return devm_snd_soc_register_component(&pdev->dev, in twl4030_codec_probe()
2190 MODULE_ALIAS("platform:twl4030-codec");
2195 .name = "twl4030-codec",
2201 MODULE_DESCRIPTION("ASoC TWL4030 codec driver");