Lines Matching +full:jd +full:- +full:invert

1 // SPDX-License-Identifier: GPL-2.0-only
3 // rt712-sdca.c -- rt712 SDCA ALSA SoC audio driver
23 #include <sound/soc-dapm.h>
25 #include "rt712-sdca.h"
31 struct regmap *regmap = rt712->mbq_regmap; in rt712_sdca_index_write()
36 dev_err(&rt712->slave->dev, in rt712_sdca_index_write()
47 struct regmap *regmap = rt712->mbq_regmap; in rt712_sdca_index_read()
52 dev_err(&rt712->slave->dev, in rt712_sdca_index_read()
77 struct regmap *regmap = rt712->regmap; in rt712_sdca_calibration()
81 mutex_lock(&rt712->calibrate_mutex); in rt712_sdca_calibration()
84 /* Set HP-JD source from JD1 */ in rt712_sdca_calibration()
85 if (rt712->version_id == RT712_VA) in rt712_sdca_calibration()
94 /* W1C Trigger DC calibration (HP & Class-D) */ in rt712_sdca_calibration()
110 dev_err(dev, "%s, calibration time-out!\n", __func__); in rt712_sdca_calibration()
113 ret = -ETIMEDOUT; in rt712_sdca_calibration()
125 /* Release HP-JD, EN_CBJ_TIE_GL/R open, en_osw gating auto done bit */ in rt712_sdca_calibration()
128 mutex_unlock(&rt712->calibrate_mutex); in rt712_sdca_calibration()
140 ret = regmap_read(rt712->regmap, in rt712_sdca_button_detect()
151 ret = regmap_read(rt712->regmap, in rt712_sdca_button_detect()
158 ret = regmap_read(rt712->regmap, in rt712_sdca_button_detect()
204 if (rt712->version_id == RT712_VA) in rt712_sdca_button_detect()
205 regmap_write(rt712->regmap, in rt712_sdca_button_detect()
209 regmap_write(rt712->regmap, in rt712_sdca_button_detect()
223 ret = regmap_read(rt712->regmap, in rt712_sdca_headset_detect()
231 rt712->jack_type = 0; in rt712_sdca_headset_detect()
234 rt712->jack_type = SND_JACK_HEADPHONE; in rt712_sdca_headset_detect()
237 rt712->jack_type = SND_JACK_HEADSET; in rt712_sdca_headset_detect()
243 ret = regmap_write(rt712->regmap, in rt712_sdca_headset_detect()
250 dev_dbg(&rt712->slave->dev, in rt712_sdca_headset_detect()
266 if (!rt712->hs_jack) in rt712_sdca_jack_detect_handler()
269 if (!rt712->component->card || !rt712->component->card->instantiated) in rt712_sdca_jack_detect_handler()
273 if (rt712->scp_sdca_stat1 & SDW_SCP_SDCA_INT_SDCA_0) { in rt712_sdca_jack_detect_handler()
280 if (rt712->scp_sdca_stat2 & SDW_SCP_SDCA_INT_SDCA_8) in rt712_sdca_jack_detect_handler()
283 if (rt712->jack_type == 0) in rt712_sdca_jack_detect_handler()
286 dev_dbg(&rt712->slave->dev, in rt712_sdca_jack_detect_handler()
287 "in %s, jack_type=0x%x\n", __func__, rt712->jack_type); in rt712_sdca_jack_detect_handler()
288 dev_dbg(&rt712->slave->dev, in rt712_sdca_jack_detect_handler()
290 dev_dbg(&rt712->slave->dev, in rt712_sdca_jack_detect_handler()
292 rt712->scp_sdca_stat1, rt712->scp_sdca_stat2); in rt712_sdca_jack_detect_handler()
294 snd_soc_jack_report(rt712->hs_jack, rt712->jack_type | btn_type, in rt712_sdca_jack_detect_handler()
301 snd_soc_jack_report(rt712->hs_jack, rt712->jack_type, in rt712_sdca_jack_detect_handler()
307 &rt712->jack_btn_check_work, msecs_to_jiffies(200)); in rt712_sdca_jack_detect_handler()
319 ret = regmap_read(rt712->regmap, in rt712_sdca_btn_check_handler()
328 ret = regmap_read(rt712->regmap, in rt712_sdca_btn_check_handler()
335 ret = regmap_read(rt712->regmap, in rt712_sdca_btn_check_handler()
377 rt712->jack_type = 0; in rt712_sdca_btn_check_handler()
380 dev_dbg(&rt712->slave->dev, "%s, btn_type=0x%x\n", __func__, btn_type); in rt712_sdca_btn_check_handler()
381 snd_soc_jack_report(rt712->hs_jack, rt712->jack_type | btn_type, in rt712_sdca_btn_check_handler()
388 snd_soc_jack_report(rt712->hs_jack, rt712->jack_type, in rt712_sdca_btn_check_handler()
394 &rt712->jack_btn_check_work, msecs_to_jiffies(200)); in rt712_sdca_btn_check_handler()
405 mutex_lock(&rt712->calibrate_mutex); in rt712_sdca_jack_init()
407 if (rt712->hs_jack) { in rt712_sdca_jack_init()
423 switch (rt712->jd_src) { in rt712_sdca_jack_init()
425 /* Set HP-JD source from JD1, VB uses JD1 in default */ in rt712_sdca_jack_init()
426 if (rt712->version_id == RT712_VA) in rt712_sdca_jack_init()
430 dev_warn(rt712->component->dev, "Wrong JD source\n"); in rt712_sdca_jack_init()
435 sdw_write_no_pm(rt712->slave, SDW_SCP_SDCA_INTMASK1, SDW_SCP_SDCA_INTMASK_SDCA_0); in rt712_sdca_jack_init()
437 sdw_write_no_pm(rt712->slave, SDW_SCP_SDCA_INTMASK2, SDW_SCP_SDCA_INTMASK_SDCA_8); in rt712_sdca_jack_init()
438 dev_dbg(&rt712->slave->dev, "in %s enable\n", __func__); in rt712_sdca_jack_init()
450 dev_dbg(&rt712->slave->dev, "in %s disable\n", __func__); in rt712_sdca_jack_init()
453 mutex_unlock(&rt712->calibrate_mutex); in rt712_sdca_jack_init()
462 rt712->hs_jack = hs_jack; in rt712_sdca_set_jack_detect()
464 if (!rt712->first_hw_init) in rt712_sdca_set_jack_detect()
467 ret = pm_runtime_resume_and_get(component->dev); in rt712_sdca_set_jack_detect()
469 if (ret != -EACCES) { in rt712_sdca_set_jack_detect()
470 dev_err(component->dev, "%s: failed to resume %d\n", __func__, ret); in rt712_sdca_set_jack_detect()
475 dev_dbg(component->dev, "%s: skipping jack init for now\n", __func__); in rt712_sdca_set_jack_detect()
481 pm_runtime_mark_last_busy(component->dev); in rt712_sdca_set_jack_detect()
482 pm_runtime_put_autosuspend(component->dev); in rt712_sdca_set_jack_detect()
493 (struct soc_mixer_control *)kcontrol->private_value; in rt712_sdca_set_gain_put()
501 if (strstr(ucontrol->id.name, "FU0F Capture Volume")) in rt712_sdca_set_gain_put()
504 regmap_read(rt712->mbq_regmap, mc->reg, &lvalue); in rt712_sdca_set_gain_put()
505 regmap_read(rt712->mbq_regmap, mc->rreg, &rvalue); in rt712_sdca_set_gain_put()
508 gain_l_val = ucontrol->value.integer.value[0]; in rt712_sdca_set_gain_put()
509 if (gain_l_val > mc->max) in rt712_sdca_set_gain_put()
510 gain_l_val = mc->max; in rt712_sdca_set_gain_put()
512 if (mc->shift == 8) /* boost gain */ in rt712_sdca_set_gain_put()
517 gain_l_val = 0x1e00 - ((mc->max - gain_l_val) * interval_offset); in rt712_sdca_set_gain_put()
519 gain_l_val = 0 - ((mc->max - gain_l_val) * interval_offset); in rt712_sdca_set_gain_put()
524 gain_r_val = ucontrol->value.integer.value[1]; in rt712_sdca_set_gain_put()
525 if (gain_r_val > mc->max) in rt712_sdca_set_gain_put()
526 gain_r_val = mc->max; in rt712_sdca_set_gain_put()
528 if (mc->shift == 8) /* boost gain */ in rt712_sdca_set_gain_put()
533 gain_r_val = 0x1e00 - ((mc->max - gain_r_val) * interval_offset); in rt712_sdca_set_gain_put()
535 gain_r_val = 0 - ((mc->max - gain_r_val) * interval_offset); in rt712_sdca_set_gain_put()
543 regmap_write(rt712->mbq_regmap, mc->reg, gain_l_val); in rt712_sdca_set_gain_put()
545 regmap_write(rt712->mbq_regmap, mc->rreg, gain_r_val); in rt712_sdca_set_gain_put()
547 regmap_read(rt712->mbq_regmap, mc->reg, &read_l); in rt712_sdca_set_gain_put()
548 regmap_read(rt712->mbq_regmap, mc->rreg, &read_r); in rt712_sdca_set_gain_put()
552 return -EIO; in rt712_sdca_set_gain_put()
561 (struct soc_mixer_control *)kcontrol->private_value; in rt712_sdca_set_gain_get()
567 if (strstr(ucontrol->id.name, "FU0F Capture Volume")) in rt712_sdca_set_gain_get()
570 regmap_read(rt712->mbq_regmap, mc->reg, &read_l); in rt712_sdca_set_gain_get()
571 regmap_read(rt712->mbq_regmap, mc->rreg, &read_r); in rt712_sdca_set_gain_get()
573 if (mc->shift == 8) /* boost gain */ in rt712_sdca_set_gain_get()
577 ctl_l = mc->max - (((0x1e00 - read_l) & 0xffff) / interval_offset); in rt712_sdca_set_gain_get()
579 ctl_l = mc->max - (((0 - read_l) & 0xffff) / interval_offset); in rt712_sdca_set_gain_get()
583 if (mc->shift == 8) /* boost gain */ in rt712_sdca_set_gain_get()
587 ctl_r = mc->max - (((0x1e00 - read_r) & 0xffff) / interval_offset); in rt712_sdca_set_gain_get()
589 ctl_r = mc->max - (((0 - read_r) & 0xffff) / interval_offset); in rt712_sdca_set_gain_get()
594 ucontrol->value.integer.value[0] = ctl_l; in rt712_sdca_set_gain_get()
595 ucontrol->value.integer.value[1] = ctl_r; in rt712_sdca_set_gain_get()
605 ch_01 = (rt712->fu0f_dapm_mute || rt712->fu0f_mixer_l_mute) ? 0x01 : 0x00; in rt712_sdca_set_fu0f_capture_ctl()
606 ch_02 = (rt712->fu0f_dapm_mute || rt712->fu0f_mixer_r_mute) ? 0x01 : 0x00; in rt712_sdca_set_fu0f_capture_ctl()
608 err = regmap_write(rt712->regmap, in rt712_sdca_set_fu0f_capture_ctl()
614 err = regmap_write(rt712->regmap, in rt712_sdca_set_fu0f_capture_ctl()
629 ucontrol->value.integer.value[0] = !rt712->fu0f_mixer_l_mute; in rt712_sdca_fu0f_capture_get()
630 ucontrol->value.integer.value[1] = !rt712->fu0f_mixer_r_mute; in rt712_sdca_fu0f_capture_get()
641 if (rt712->fu0f_mixer_l_mute == !ucontrol->value.integer.value[0] && in rt712_sdca_fu0f_capture_put()
642 rt712->fu0f_mixer_r_mute == !ucontrol->value.integer.value[1]) in rt712_sdca_fu0f_capture_put()
645 rt712->fu0f_mixer_l_mute = !ucontrol->value.integer.value[0]; in rt712_sdca_fu0f_capture_put()
646 rt712->fu0f_mixer_r_mute = !ucontrol->value.integer.value[1]; in rt712_sdca_fu0f_capture_put()
654 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6525, 75, 0);
655 static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -1725, 75, 0);
706 ucontrol->value.enumerated.item[0] = val; in rt712_sdca_mux_get()
719 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in rt712_sdca_mux_put()
720 unsigned int *item = ucontrol->value.enumerated.item; in rt712_sdca_mux_put()
724 if (item[0] >= e->items) in rt712_sdca_mux_put()
725 return -EINVAL; in rt712_sdca_mux_put()
727 if (ucontrol->value.enumerated.item[0] == 0) in rt712_sdca_mux_put()
729 else if (ucontrol->value.enumerated.item[0] == 1) in rt712_sdca_mux_put()
732 return -EINVAL; in rt712_sdca_mux_put()
766 snd_soc_dapm_to_component(w->dapm); in rt712_sdca_fu05_event()
772 regmap_write(rt712->regmap, in rt712_sdca_fu05_event()
776 regmap_write(rt712->regmap, in rt712_sdca_fu05_event()
782 regmap_write(rt712->regmap, in rt712_sdca_fu05_event()
786 regmap_write(rt712->regmap, in rt712_sdca_fu05_event()
799 snd_soc_dapm_to_component(w->dapm); in rt712_sdca_fu0f_event()
804 rt712->fu0f_dapm_mute = false; in rt712_sdca_fu0f_event()
808 rt712->fu0f_dapm_mute = true; in rt712_sdca_fu0f_event()
819 snd_soc_dapm_to_component(w->dapm); in rt712_sdca_pde40_event()
825 regmap_write(rt712->regmap, in rt712_sdca_pde40_event()
831 regmap_write(rt712->regmap, in rt712_sdca_pde40_event()
844 snd_soc_dapm_to_component(w->dapm); in rt712_sdca_pde12_event()
850 regmap_write(rt712->regmap, in rt712_sdca_pde12_event()
856 regmap_write(rt712->regmap, in rt712_sdca_pde12_event()
869 snd_soc_dapm_to_component(w->dapm); in rt712_sdca_pde23_event()
875 regmap_write(rt712->regmap, in rt712_sdca_pde23_event()
881 regmap_write(rt712->regmap, in rt712_sdca_pde23_event()
969 device_property_read_u32(dev, "realtek,jd-src", &rt712->jd_src); in rt712_sdca_parse_dt()
980 rt712_sdca_parse_dt(rt712, &rt712->slave->dev); in rt712_sdca_probe()
981 rt712->component = component; in rt712_sdca_probe()
984 if (rt712->hw_id != RT712_DEV_ID_713) { in rt712_sdca_probe()
993 if (!rt712->first_hw_init) in rt712_sdca_probe()
996 ret = pm_runtime_resume(component->dev); in rt712_sdca_probe()
997 if (ret < 0 && ret != -EACCES) in rt712_sdca_probe()
1009 (struct rt712_dmic_kctrl_priv *)kcontrol->private_value; in rt712_sdca_dmic_set_gain_get()
1014 if (strstr(ucontrol->id.name, "FU1E Capture Volume")) in rt712_sdca_dmic_set_gain_get()
1018 for (i = 0; i < p->count; i++) { in rt712_sdca_dmic_set_gain_get()
1019 regmap_read(rt712->mbq_regmap, p->reg_base + i, &regvalue); in rt712_sdca_dmic_set_gain_get()
1025 ctl = p->max - (((0x1e00 - regvalue) & 0xffff) / interval_offset); in rt712_sdca_dmic_set_gain_get()
1027 ctl = p->max - (((0 - regvalue) & 0xffff) / interval_offset); in rt712_sdca_dmic_set_gain_get()
1030 ucontrol->value.integer.value[i] = ctl; in rt712_sdca_dmic_set_gain_get()
1041 (struct rt712_dmic_kctrl_priv *)kcontrol->private_value; in rt712_sdca_dmic_set_gain_put()
1049 if (strstr(ucontrol->id.name, "FU1E Capture Volume")) in rt712_sdca_dmic_set_gain_put()
1053 for (i = 0; i < p->count; i++) { in rt712_sdca_dmic_set_gain_put()
1054 regmap_read(rt712->mbq_regmap, p->reg_base + i, &regvalue[i]); in rt712_sdca_dmic_set_gain_put()
1056 gain_val[i] = ucontrol->value.integer.value[i]; in rt712_sdca_dmic_set_gain_put()
1057 if (gain_val[i] > p->max) in rt712_sdca_dmic_set_gain_put()
1058 gain_val[i] = p->max; in rt712_sdca_dmic_set_gain_put()
1063 gain_val[i] = 0x1e00 - ((p->max - gain_val[i]) * interval_offset); in rt712_sdca_dmic_set_gain_put()
1074 for (i = 0; i < p->count; i++) { in rt712_sdca_dmic_set_gain_put()
1075 err = regmap_write(rt712->mbq_regmap, p->reg_base + i, gain_val[i]); in rt712_sdca_dmic_set_gain_put()
1077 dev_err(&rt712->slave->dev, "0x%08x can't be set\n", p->reg_base + i); in rt712_sdca_dmic_set_gain_put()
1088 for (i = 0; i < ARRAY_SIZE(rt712->fu1e_mixer_mute); i++) { in rt712_sdca_set_fu1e_capture_ctl()
1089 ch_mute = (rt712->fu1e_dapm_mute || rt712->fu1e_mixer_mute[i]) ? 0x01 : 0x00; in rt712_sdca_set_fu1e_capture_ctl()
1090 err = regmap_write(rt712->regmap, in rt712_sdca_set_fu1e_capture_ctl()
1106 (struct rt712_dmic_kctrl_priv *)kcontrol->private_value; in rt712_sdca_dmic_fu1e_capture_get()
1109 for (i = 0; i < p->count; i++) in rt712_sdca_dmic_fu1e_capture_get()
1110 ucontrol->value.integer.value[i] = !rt712->fu1e_mixer_mute[i]; in rt712_sdca_dmic_fu1e_capture_get()
1121 (struct rt712_dmic_kctrl_priv *)kcontrol->private_value; in rt712_sdca_dmic_fu1e_capture_put()
1124 for (i = 0; i < p->count; i++) { in rt712_sdca_dmic_fu1e_capture_put()
1125 if (rt712->fu1e_mixer_mute[i] != !ucontrol->value.integer.value[i]) in rt712_sdca_dmic_fu1e_capture_put()
1127 rt712->fu1e_mixer_mute[i] = !ucontrol->value.integer.value[i]; in rt712_sdca_dmic_fu1e_capture_put()
1141 (struct rt712_dmic_kctrl_priv *)kcontrol->private_value; in rt712_sdca_fu_info()
1143 if (p->max == 1) in rt712_sdca_fu_info()
1144 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in rt712_sdca_fu_info()
1146 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in rt712_sdca_fu_info()
1147 uinfo->count = p->count; in rt712_sdca_fu_info()
1148 uinfo->value.integer.min = 0; in rt712_sdca_fu_info()
1149 uinfo->value.integer.max = p->max; in rt712_sdca_fu_info()
1156 .invert = xinvert})
1175 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -1725, 75, 0);
1198 if (strstr(ucontrol->id.name, "ADC 0A Mux")) in rt712_sdca_dmic_mux_get()
1200 else if (strstr(ucontrol->id.name, "ADC 0B Mux")) in rt712_sdca_dmic_mux_get()
1203 return -EINVAL; in rt712_sdca_dmic_mux_get()
1208 ucontrol->value.enumerated.item[0] = (((val >> mask_sft) & 0xf) == 0x4) ? 0 : 1; in rt712_sdca_dmic_mux_get()
1221 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in rt712_sdca_dmic_mux_put()
1222 unsigned int *item = ucontrol->value.enumerated.item; in rt712_sdca_dmic_mux_put()
1225 if (item[0] >= e->items) in rt712_sdca_dmic_mux_put()
1226 return -EINVAL; in rt712_sdca_dmic_mux_put()
1228 if (strstr(ucontrol->id.name, "ADC 0A Mux")) in rt712_sdca_dmic_mux_put()
1230 else if (strstr(ucontrol->id.name, "ADC 0B Mux")) in rt712_sdca_dmic_mux_put()
1233 return -EINVAL; in rt712_sdca_dmic_mux_put()
1235 val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; in rt712_sdca_dmic_mux_put()
1284 snd_soc_dapm_to_component(w->dapm); in rt712_sdca_dmic_fu1e_event()
1289 rt712->fu1e_dapm_mute = false; in rt712_sdca_dmic_fu1e_event()
1293 rt712->fu1e_dapm_mute = true; in rt712_sdca_dmic_fu1e_event()
1304 snd_soc_dapm_to_component(w->dapm); in rt712_sdca_dmic_pde11_event()
1310 regmap_write(rt712->regmap, in rt712_sdca_dmic_pde11_event()
1316 regmap_write(rt712->regmap, in rt712_sdca_dmic_pde11_event()
1361 rt712->dmic_component = component; in rt712_sdca_dmic_probe()
1363 if (!rt712->first_hw_init) in rt712_sdca_dmic_probe()
1366 ret = pm_runtime_resume(component->dev); in rt712_sdca_dmic_probe()
1367 if (ret < 0 && ret != -EACCES) in rt712_sdca_dmic_probe()
1417 struct snd_soc_component *component = dai->component; in rt712_sdca_pcm_hw_params()
1426 dev_dbg(dai->dev, "%s %s id %d", __func__, dai->name, dai->id); in rt712_sdca_pcm_hw_params()
1430 return -EINVAL; in rt712_sdca_pcm_hw_params()
1432 if (!rt712->slave) in rt712_sdca_pcm_hw_params()
1433 return -EINVAL; in rt712_sdca_pcm_hw_params()
1436 if (dai->id == RT712_AIF3 && rt712->version_id == RT712_VA) in rt712_sdca_pcm_hw_params()
1437 return -EINVAL; in rt712_sdca_pcm_hw_params()
1440 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in rt712_sdca_pcm_hw_params()
1442 if (dai->id == RT712_AIF1) in rt712_sdca_pcm_hw_params()
1444 else if (dai->id == RT712_AIF2) in rt712_sdca_pcm_hw_params()
1447 return -EINVAL; in rt712_sdca_pcm_hw_params()
1450 if (dai->id == RT712_AIF1) in rt712_sdca_pcm_hw_params()
1452 else if (dai->id == RT712_AIF3) in rt712_sdca_pcm_hw_params()
1455 return -EINVAL; in rt712_sdca_pcm_hw_params()
1464 port_config.ch_mask = GENMASK(num_channels - 1, 0); in rt712_sdca_pcm_hw_params()
1467 retval = sdw_stream_add_slave(rt712->slave, &stream_config, in rt712_sdca_pcm_hw_params()
1470 dev_err(dai->dev, "%s: Unable to configure port\n", __func__); in rt712_sdca_pcm_hw_params()
1475 dev_err(component->dev, "%s: Unsupported channels %d\n", in rt712_sdca_pcm_hw_params()
1477 return -EINVAL; in rt712_sdca_pcm_hw_params()
1495 dev_err(component->dev, "%s: Rate %d is not supported\n", in rt712_sdca_pcm_hw_params()
1497 return -EINVAL; in rt712_sdca_pcm_hw_params()
1501 switch (dai->id) { in rt712_sdca_pcm_hw_params()
1503 regmap_write(rt712->regmap, in rt712_sdca_pcm_hw_params()
1506 regmap_write(rt712->regmap, in rt712_sdca_pcm_hw_params()
1511 regmap_write(rt712->regmap, in rt712_sdca_pcm_hw_params()
1516 regmap_write(rt712->regmap, in rt712_sdca_pcm_hw_params()
1519 regmap_write(rt712->regmap, in rt712_sdca_pcm_hw_params()
1524 dev_err(component->dev, "%s: Wrong DAI id\n", __func__); in rt712_sdca_pcm_hw_params()
1525 return -EINVAL; in rt712_sdca_pcm_hw_params()
1534 struct snd_soc_component *component = dai->component; in rt712_sdca_pcm_hw_free()
1539 if (!rt712->slave) in rt712_sdca_pcm_hw_free()
1540 return -EINVAL; in rt712_sdca_pcm_hw_free()
1542 sdw_stream_remove_slave(rt712->slave, sdw_stream); in rt712_sdca_pcm_hw_free()
1560 .name = "rt712-sdca-aif1",
1579 .name = "rt712-sdca-aif2",
1594 .name = "rt712-sdca-aif3",
1615 return -ENOMEM; in rt712_sdca_init()
1618 rt712->slave = slave; in rt712_sdca_init()
1619 rt712->regmap = regmap; in rt712_sdca_init()
1620 rt712->mbq_regmap = mbq_regmap; in rt712_sdca_init()
1622 regcache_cache_only(rt712->regmap, true); in rt712_sdca_init()
1623 regcache_cache_only(rt712->mbq_regmap, true); in rt712_sdca_init()
1625 mutex_init(&rt712->calibrate_mutex); in rt712_sdca_init()
1626 mutex_init(&rt712->disable_irq_lock); in rt712_sdca_init()
1628 INIT_DELAYED_WORK(&rt712->jack_detect_work, rt712_sdca_jack_detect_handler); in rt712_sdca_init()
1629 INIT_DELAYED_WORK(&rt712->jack_btn_check_work, rt712_sdca_btn_check_handler); in rt712_sdca_init()
1635 rt712->hw_init = false; in rt712_sdca_init()
1636 rt712->first_hw_init = false; in rt712_sdca_init()
1637 rt712->fu0f_dapm_mute = true; in rt712_sdca_init()
1638 rt712->fu0f_mixer_l_mute = rt712->fu0f_mixer_r_mute = true; in rt712_sdca_init()
1639 rt712->fu1e_dapm_mute = true; in rt712_sdca_init()
1640 rt712->fu1e_mixer_mute[0] = rt712->fu1e_mixer_mute[1] = in rt712_sdca_init()
1641 rt712->fu1e_mixer_mute[2] = rt712->fu1e_mixer_mute[3] = true; in rt712_sdca_init()
1643 /* JD source uses JD1 in default */ in rt712_sdca_init()
1644 rt712->jd_src = RT712_JD1; in rt712_sdca_init()
1646 if (slave->id.part_id != RT712_PART_ID_713) in rt712_sdca_init()
1667 * fail with -EACCESS because of race conditions between card creation and enumeration in rt712_sdca_init()
1679 struct device *dev = &rt712->slave->dev; in rt712_sdca_va_io_init()
1686 regmap_write(rt712->regmap, RT712_RC_CAL, 0x23); in rt712_sdca_va_io_init()
1707 regmap_write(rt712->regmap, 0x2f50, 0x00); in rt712_sdca_va_io_init()
1708 regmap_write(rt712->regmap, 0x2f54, 0x00); in rt712_sdca_va_io_init()
1709 regmap_write(rt712->regmap, in rt712_sdca_va_io_init()
1713 if (rt712->hw_id != RT712_DEV_ID_713) { in rt712_sdca_va_io_init()
1716 regmap_write(rt712->regmap, in rt712_sdca_va_io_init()
1725 struct device *dev = &rt712->slave->dev; in rt712_sdca_vb_io_init()
1727 regmap_read(rt712->regmap, in rt712_sdca_vb_io_init()
1729 regmap_read(rt712->regmap, in rt712_sdca_vb_io_init()
1731 regmap_read(rt712->regmap, in rt712_sdca_vb_io_init()
1737 if ((mic_func_status & FUNCTION_NEEDS_INITIALIZATION) || (!rt712->first_hw_init)) { in rt712_sdca_vb_io_init()
1743 regmap_write(rt712->regmap, in rt712_sdca_vb_io_init()
1746 regmap_write(rt712->regmap, RT712_RC_CAL, 0x23); in rt712_sdca_vb_io_init()
1749 regmap_write(rt712->regmap, in rt712_sdca_vb_io_init()
1755 if ((jack_func_status & FUNCTION_NEEDS_INITIALIZATION) || (!rt712->first_hw_init)) { in rt712_sdca_vb_io_init()
1763 regmap_write(rt712->regmap, RT712_RC_CAL, 0x23); in rt712_sdca_vb_io_init()
1773 regmap_write(rt712->regmap, in rt712_sdca_vb_io_init()
1778 regmap_write(rt712->regmap, in rt712_sdca_vb_io_init()
1784 if ((amp_func_status & FUNCTION_NEEDS_INITIALIZATION) || (!rt712->first_hw_init)) { in rt712_sdca_vb_io_init()
1785 if (rt712->hw_id != RT712_DEV_ID_713) { in rt712_sdca_vb_io_init()
1789 regmap_write(rt712->regmap, in rt712_sdca_vb_io_init()
1793 regmap_write(rt712->regmap, in rt712_sdca_vb_io_init()
1804 struct sdw_slave_prop *prop = &slave->prop; in rt712_sdca_io_init()
1806 rt712->disable_irq = false; in rt712_sdca_io_init()
1808 if (rt712->hw_init) in rt712_sdca_io_init()
1811 regcache_cache_only(rt712->regmap, false); in rt712_sdca_io_init()
1812 regcache_cache_only(rt712->mbq_regmap, false); in rt712_sdca_io_init()
1813 if (rt712->first_hw_init) { in rt712_sdca_io_init()
1814 regcache_cache_bypass(rt712->regmap, true); in rt712_sdca_io_init()
1815 regcache_cache_bypass(rt712->mbq_regmap, true); in rt712_sdca_io_init()
1822 pm_runtime_set_active(&slave->dev); in rt712_sdca_io_init()
1825 pm_runtime_get_noresume(&slave->dev); in rt712_sdca_io_init()
1828 rt712->hw_id = (val & 0xf000) >> 12; in rt712_sdca_io_init()
1829 rt712->version_id = (val & 0x0f00) >> 8; in rt712_sdca_io_init()
1830 …dev_dbg(&slave->dev, "%s hw_id=0x%x, version_id=0x%x\n", __func__, rt712->hw_id, rt712->version_id… in rt712_sdca_io_init()
1832 if (rt712->version_id == RT712_VA) in rt712_sdca_io_init()
1841 prop->lane_control_support = true; in rt712_sdca_io_init()
1849 if (rt712->hs_jack) in rt712_sdca_io_init()
1854 if (rt712->first_hw_init) { in rt712_sdca_io_init()
1855 regcache_cache_bypass(rt712->regmap, false); in rt712_sdca_io_init()
1856 regcache_mark_dirty(rt712->regmap); in rt712_sdca_io_init()
1857 regcache_cache_bypass(rt712->mbq_regmap, false); in rt712_sdca_io_init()
1858 regcache_mark_dirty(rt712->mbq_regmap); in rt712_sdca_io_init()
1860 rt712->first_hw_init = true; in rt712_sdca_io_init()
1863 rt712->hw_init = true; in rt712_sdca_io_init()
1865 pm_runtime_mark_last_busy(&slave->dev); in rt712_sdca_io_init()
1866 pm_runtime_put_autosuspend(&slave->dev); in rt712_sdca_io_init()
1868 dev_dbg(&slave->dev, "%s hw_init complete\n", __func__); in rt712_sdca_io_init()