Lines Matching +full:boost +full:- +full:converter

1 // SPDX-License-Identifier: GPL-2.0
3 * rt715.c -- rt715 ALSA SoC audio driver
32 #include <sound/soc-dapm.h>
61 ret = regmap_read(rt715->regmap, addr_l, r_val); in rt715_get_gain()
68 ret = regmap_read(rt715->regmap, addr_h, l_val); in rt715_get_gain()
73 /* For Verb-Set Amplifier Gain (Verb ID = 3h) */
81 (struct soc_mixer_control *)kcontrol->private_value; in rt715_set_amp_gain_put()
88 if (ucontrol->value.integer.value[i] != rt715->kctl_2ch_vol_ori[i]) { in rt715_set_amp_gain_put()
95 addr_h = mc->reg; in rt715_set_amp_gain_put()
96 addr_l = mc->rreg; in rt715_set_amp_gain_put()
98 if (mc->shift == RT715_DIR_OUT_SFT) /* output */ in rt715_set_amp_gain_put()
105 if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) in rt715_set_amp_gain_put()
106 regmap_write(rt715->regmap, in rt715_set_amp_gain_put()
110 rt715->kctl_2ch_vol_ori[0] = ucontrol->value.integer.value[0]; in rt715_set_amp_gain_put()
112 val_ll = ((ucontrol->value.integer.value[0]) & 0x7f); in rt715_set_amp_gain_put()
113 if (val_ll > mc->max) in rt715_set_amp_gain_put()
114 val_ll = mc->max; in rt715_set_amp_gain_put()
119 rt715->kctl_2ch_vol_ori[1] = ucontrol->value.integer.value[1]; in rt715_set_amp_gain_put()
121 val_lr = ((ucontrol->value.integer.value[1]) & 0x7f); in rt715_set_amp_gain_put()
122 if (val_lr > mc->max) in rt715_set_amp_gain_put()
123 val_lr = mc->max; in rt715_set_amp_gain_put()
131 val_h = (1 << mc->shift) | (3 << 4); in rt715_set_amp_gain_put()
132 regmap_write(rt715->regmap, addr_h, in rt715_set_amp_gain_put()
134 regmap_write(rt715->regmap, addr_l, in rt715_set_amp_gain_put()
138 val_h = (1 << mc->shift) | (1 << 5); in rt715_set_amp_gain_put()
139 regmap_write(rt715->regmap, addr_h, in rt715_set_amp_gain_put()
142 val_h = (1 << mc->shift) | (1 << 4); in rt715_set_amp_gain_put()
143 regmap_write(rt715->regmap, addr_l, in rt715_set_amp_gain_put()
147 if (mc->shift == RT715_DIR_OUT_SFT) /* output */ in rt715_set_amp_gain_put()
159 if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) in rt715_set_amp_gain_put()
160 regmap_write(rt715->regmap, in rt715_set_amp_gain_put()
171 (struct soc_mixer_control *)kcontrol->private_value; in rt715_set_amp_gain_get()
175 addr_h = mc->reg; in rt715_set_amp_gain_get()
176 addr_l = mc->rreg; in rt715_set_amp_gain_get()
177 if (mc->shift == RT715_DIR_OUT_SFT) /* output */ in rt715_set_amp_gain_get()
184 if (mc->invert) { in rt715_set_amp_gain_get()
193 ucontrol->value.integer.value[0] = read_ll; in rt715_set_amp_gain_get()
194 ucontrol->value.integer.value[1] = read_rl; in rt715_set_amp_gain_get()
217 if (ucontrol->value.integer.value[i] != rt715->kctl_8ch_switch_ori[i]) in rt715_set_main_switch_put()
227 if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) in rt715_set_main_switch_put()
228 regmap_write(rt715->regmap, in rt715_set_main_switch_put()
233 rt715->kctl_8ch_switch_ori[j * 2] = in rt715_set_main_switch_put()
234 ucontrol->value.integer.value[j * 2]; in rt715_set_main_switch_put()
235 val_ll = (!ucontrol->value.integer.value[j * 2]) << 7; in rt715_set_main_switch_put()
241 rt715->kctl_8ch_switch_ori[j * 2 + 1] = in rt715_set_main_switch_put()
242 ucontrol->value.integer.value[j * 2 + 1]; in rt715_set_main_switch_put()
243 val_lr = (!ucontrol->value.integer.value[j * 2 + 1]) << 7; in rt715_set_main_switch_put()
252 regmap_write(rt715->regmap, addr_h, in rt715_set_main_switch_put()
254 regmap_write(rt715->regmap, addr_l, in rt715_set_main_switch_put()
259 regmap_write(rt715->regmap, addr_h, in rt715_set_main_switch_put()
263 regmap_write(rt715->regmap, addr_l, in rt715_set_main_switch_put()
275 if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) in rt715_set_main_switch_put()
276 regmap_write(rt715->regmap, in rt715_set_main_switch_put()
300 ucontrol->value.integer.value[i * 2] = !(read_ll & 0x80); in rt715_set_main_switch_get()
301 ucontrol->value.integer.value[i * 2 + 1] = !(read_rl & 0x80); in rt715_set_main_switch_get()
325 if (ucontrol->value.integer.value[i] != rt715->kctl_8ch_vol_ori[i]) in rt715_set_main_vol_put()
334 if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) in rt715_set_main_vol_put()
335 regmap_write(rt715->regmap, in rt715_set_main_vol_put()
340 rt715->kctl_8ch_vol_ori[j * 2] = ucontrol->value.integer.value[j * 2]; in rt715_set_main_vol_put()
341 val_ll = ((ucontrol->value.integer.value[j * 2]) & 0x7f); in rt715_set_main_vol_put()
349 rt715->kctl_8ch_vol_ori[j * 2 + 1] = in rt715_set_main_vol_put()
350 ucontrol->value.integer.value[j * 2 + 1]; in rt715_set_main_vol_put()
351 val_lr = ((ucontrol->value.integer.value[j * 2 + 1]) & 0x7f); in rt715_set_main_vol_put()
361 regmap_write(rt715->regmap, addr_h, in rt715_set_main_vol_put()
363 regmap_write(rt715->regmap, addr_l, in rt715_set_main_vol_put()
368 regmap_write(rt715->regmap, addr_h, in rt715_set_main_vol_put()
372 regmap_write(rt715->regmap, addr_l, in rt715_set_main_vol_put()
384 if (dapm->bias_level <= SND_SOC_BIAS_STANDBY) in rt715_set_main_vol_put()
385 regmap_write(rt715->regmap, in rt715_set_main_vol_put()
409 ucontrol->value.integer.value[i * 2] = read_ll & 0x7f; in rt715_set_main_vol_get()
410 ucontrol->value.integer.value[i * 2 + 1] = read_rl & 0x7f; in rt715_set_main_vol_get()
416 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -1725, 75, 0);
422 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; in rt715_switch_info()
423 uinfo->count = 8; in rt715_switch_info()
424 uinfo->value.integer.min = 0; in rt715_switch_info()
425 uinfo->value.integer.max = 1; in rt715_switch_info()
432 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in rt715_vol_info()
433 uinfo->count = 8; in rt715_vol_info()
434 uinfo->value.integer.min = 0; in rt715_vol_info()
435 uinfo->value.integer.max = 0x3f; in rt715_vol_info()
469 /* MIC Boost Control */
470 SOC_DOUBLE_R_EXT_TLV("DMIC1 Boost", RT715_SET_GAIN_DMIC1_H,
474 SOC_DOUBLE_R_EXT_TLV("DMIC2 Boost", RT715_SET_GAIN_DMIC2_H,
478 SOC_DOUBLE_R_EXT_TLV("DMIC3 Boost", RT715_SET_GAIN_DMIC3_H,
482 SOC_DOUBLE_R_EXT_TLV("DMIC4 Boost", RT715_SET_GAIN_DMIC4_H,
486 SOC_DOUBLE_R_EXT_TLV("MIC1 Boost", RT715_SET_GAIN_MIC1_H,
490 SOC_DOUBLE_R_EXT_TLV("MIC2 Boost", RT715_SET_GAIN_MIC2_H,
494 SOC_DOUBLE_R_EXT_TLV("LINE1 Boost", RT715_SET_GAIN_LINE1_H,
498 SOC_DOUBLE_R_EXT_TLV("LINE2 Boost", RT715_SET_GAIN_LINE2_H,
510 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in rt715_mux_get()
514 /* nid = e->reg, vid = 0xf01 */ in rt715_mux_get()
515 reg = RT715_VERB_SET_CONNECT_SEL | e->reg; in rt715_mux_get()
516 ret = regmap_read(rt715->regmap, reg, &val); in rt715_mux_get()
518 dev_err(component->dev, "%s: sdw read failed: %d\n", in rt715_mux_get()
528 if ((e->reg == RT715_MUX_IN3 || e->reg == RT715_MUX_IN4) && (val > 0)) in rt715_mux_get()
529 val -= 1; in rt715_mux_get()
530 ucontrol->value.enumerated.item[0] = val; in rt715_mux_get()
543 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in rt715_mux_put()
544 unsigned int *item = ucontrol->value.enumerated.item; in rt715_mux_put()
548 if (item[0] >= e->items) in rt715_mux_put()
549 return -EINVAL; in rt715_mux_put()
551 /* Verb ID = 0x701h, nid = e->reg */ in rt715_mux_put()
552 val = snd_soc_enum_item_to_val(e, item[0]) << e->shift_l; in rt715_mux_put()
554 reg = RT715_VERB_SET_CONNECT_SEL | e->reg; in rt715_mux_put()
555 ret = regmap_read(rt715->regmap, reg, &val2); in rt715_mux_put()
557 dev_err(component->dev, "%s: sdw read failed: %d\n", in rt715_mux_put()
568 reg = RT715_VERB_SET_CONNECT_SEL | e->reg; in rt715_mux_put()
569 regmap_write(rt715->regmap, reg, val); in rt715_mux_put()
719 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { in rt715_set_bias_level()
720 regmap_write(rt715->regmap, in rt715_set_bias_level()
728 regmap_write(rt715->regmap, in rt715_set_bias_level()
736 dapm->bias_level = level; in rt715_set_bias_level()
744 ret = pm_runtime_resume(component->dev); in rt715_probe()
745 if (ret < 0 && ret != -EACCES) in rt715_probe()
774 return -ENOMEM; in rt715_set_sdw_stream()
776 stream->sdw_stream = sdw_stream; in rt715_set_sdw_stream()
780 dai->playback_dma_data = stream; in rt715_set_sdw_stream()
782 dai->capture_dma_data = stream; in rt715_set_sdw_stream()
802 struct snd_soc_component *component = dai->component; in rt715_pcm_hw_params()
814 return -EINVAL; in rt715_pcm_hw_params()
816 if (!rt715->slave) in rt715_pcm_hw_params()
817 return -EINVAL; in rt715_pcm_hw_params()
819 switch (dai->id) { in rt715_pcm_hw_params()
823 rt715_index_write(rt715->regmap, RT715_SDW_INPUT_SEL, 0xa500); in rt715_pcm_hw_params()
828 rt715_index_write(rt715->regmap, RT715_SDW_INPUT_SEL, 0xa000); in rt715_pcm_hw_params()
831 dev_err(component->dev, "Invalid DAI id %d\n", dai->id); in rt715_pcm_hw_params()
832 return -EINVAL; in rt715_pcm_hw_params()
841 port_config.ch_mask = (1 << (num_channels)) - 1; in rt715_pcm_hw_params()
844 retval = sdw_stream_add_slave(rt715->slave, &stream_config, in rt715_pcm_hw_params()
845 &port_config, 1, stream->sdw_stream); in rt715_pcm_hw_params()
847 dev_err(dai->dev, "Unable to configure port\n"); in rt715_pcm_hw_params()
853 /* bit 15 Stream Type 0:PCM 1:Non-PCM, should always be PCM */ in rt715_pcm_hw_params()
861 dev_err(component->dev, "Unsupported sample rate %d\n", in rt715_pcm_hw_params()
863 return -EINVAL; in rt715_pcm_hw_params()
868 val |= (params_channels(params) - 1); in rt715_pcm_hw_params()
870 dev_err(component->dev, "Unsupported channels %d\n", in rt715_pcm_hw_params()
872 return -EINVAL; in rt715_pcm_hw_params()
892 return -EINVAL; in rt715_pcm_hw_params()
895 regmap_write(rt715->regmap, RT715_MIC_ADC_FORMAT_H, val); in rt715_pcm_hw_params()
896 regmap_write(rt715->regmap, RT715_MIC_LINE_FORMAT_H, val); in rt715_pcm_hw_params()
897 regmap_write(rt715->regmap, RT715_MIX_ADC_FORMAT_H, val); in rt715_pcm_hw_params()
898 regmap_write(rt715->regmap, RT715_MIX_ADC2_FORMAT_H, val); in rt715_pcm_hw_params()
906 struct snd_soc_component *component = dai->component; in rt715_pcm_hw_free()
911 if (!rt715->slave) in rt715_pcm_hw_free()
912 return -EINVAL; in rt715_pcm_hw_free()
914 sdw_stream_remove_slave(rt715->slave, stream->sdw_stream); in rt715_pcm_hw_free()
931 .name = "rt715-aif1",
943 .name = "rt715-aif2",
969 clk_freq = (rt715->params.curr_dr_freq >> 1); in rt715_clock_config()
991 return -EINVAL; in rt715_clock_config()
994 regmap_write(rt715->regmap, 0xe0, value); in rt715_clock_config()
995 regmap_write(rt715->regmap, 0xf0, value); in rt715_clock_config()
1008 return -ENOMEM; in rt715_init()
1011 rt715->slave = slave; in rt715_init()
1012 rt715->regmap = regmap; in rt715_init()
1013 rt715->sdw_regmap = sdw_regmap; in rt715_init()
1019 rt715->hw_init = false; in rt715_init()
1020 rt715->first_hw_init = false; in rt715_init()
1034 if (rt715->hw_init) in rt715_io_init()
1040 if (!rt715->first_hw_init) { in rt715_io_init()
1042 pm_runtime_set_autosuspend_delay(&slave->dev, 3000); in rt715_io_init()
1043 pm_runtime_use_autosuspend(&slave->dev); in rt715_io_init()
1046 pm_runtime_set_active(&slave->dev); in rt715_io_init()
1049 pm_runtime_mark_last_busy(&slave->dev); in rt715_io_init()
1051 pm_runtime_enable(&slave->dev); in rt715_io_init()
1054 pm_runtime_get_noresume(&slave->dev); in rt715_io_init()
1057 regmap_write(rt715->regmap, RT715_SET_GAIN_LINE_ADC_H, 0xb080); in rt715_io_init()
1058 regmap_write(rt715->regmap, RT715_SET_GAIN_MIX_ADC_H, 0xb080); in rt715_io_init()
1060 regmap_write(rt715->regmap, RT715_SET_GAIN_MIC_ADC_H, 0xb080); in rt715_io_init()
1061 regmap_write(rt715->regmap, RT715_SET_GAIN_MIX_ADC2_H, 0xb080); in rt715_io_init()
1064 regmap_write(rt715->regmap, RT715_SET_PIN_DMIC1, 0x20); in rt715_io_init()
1065 regmap_write(rt715->regmap, RT715_SET_PIN_DMIC2, 0x20); in rt715_io_init()
1066 regmap_write(rt715->regmap, RT715_SET_PIN_DMIC3, 0x20); in rt715_io_init()
1067 regmap_write(rt715->regmap, RT715_SET_PIN_DMIC4, 0x20); in rt715_io_init()
1068 /* Set Converter Stream */ in rt715_io_init()
1069 regmap_write(rt715->regmap, RT715_SET_STREAMID_LINE_ADC, 0x10); in rt715_io_init()
1070 regmap_write(rt715->regmap, RT715_SET_STREAMID_MIX_ADC, 0x10); in rt715_io_init()
1071 regmap_write(rt715->regmap, RT715_SET_STREAMID_MIC_ADC, 0x10); in rt715_io_init()
1072 regmap_write(rt715->regmap, RT715_SET_STREAMID_MIX_ADC2, 0x10); in rt715_io_init()
1074 regmap_write(rt715->regmap, RT715_SET_DMIC1_CONFIG_DEFAULT1, 0xd0); in rt715_io_init()
1075 regmap_write(rt715->regmap, RT715_SET_DMIC1_CONFIG_DEFAULT2, 0x11); in rt715_io_init()
1076 regmap_write(rt715->regmap, RT715_SET_DMIC1_CONFIG_DEFAULT3, 0xa1); in rt715_io_init()
1077 regmap_write(rt715->regmap, RT715_SET_DMIC1_CONFIG_DEFAULT4, 0x81); in rt715_io_init()
1078 regmap_write(rt715->regmap, RT715_SET_DMIC2_CONFIG_DEFAULT1, 0xd1); in rt715_io_init()
1079 regmap_write(rt715->regmap, RT715_SET_DMIC2_CONFIG_DEFAULT2, 0x11); in rt715_io_init()
1080 regmap_write(rt715->regmap, RT715_SET_DMIC2_CONFIG_DEFAULT3, 0xa1); in rt715_io_init()
1081 regmap_write(rt715->regmap, RT715_SET_DMIC2_CONFIG_DEFAULT4, 0x81); in rt715_io_init()
1082 regmap_write(rt715->regmap, RT715_SET_DMIC3_CONFIG_DEFAULT1, 0xd0); in rt715_io_init()
1083 regmap_write(rt715->regmap, RT715_SET_DMIC3_CONFIG_DEFAULT2, 0x11); in rt715_io_init()
1084 regmap_write(rt715->regmap, RT715_SET_DMIC3_CONFIG_DEFAULT3, 0xa1); in rt715_io_init()
1085 regmap_write(rt715->regmap, RT715_SET_DMIC3_CONFIG_DEFAULT4, 0x81); in rt715_io_init()
1086 regmap_write(rt715->regmap, RT715_SET_DMIC4_CONFIG_DEFAULT1, 0xd1); in rt715_io_init()
1087 regmap_write(rt715->regmap, RT715_SET_DMIC4_CONFIG_DEFAULT2, 0x11); in rt715_io_init()
1088 regmap_write(rt715->regmap, RT715_SET_DMIC4_CONFIG_DEFAULT3, 0xa1); in rt715_io_init()
1089 regmap_write(rt715->regmap, RT715_SET_DMIC4_CONFIG_DEFAULT4, 0x81); in rt715_io_init()
1092 regmap_write(rt715->regmap, RT715_SET_AUDIO_POWER_STATE, AC_PWRST_D3); in rt715_io_init()
1094 if (rt715->first_hw_init) in rt715_io_init()
1095 regcache_mark_dirty(rt715->regmap); in rt715_io_init()
1097 rt715->first_hw_init = true; in rt715_io_init()
1100 rt715->hw_init = true; in rt715_io_init()
1102 pm_runtime_mark_last_busy(&slave->dev); in rt715_io_init()
1103 pm_runtime_put_autosuspend(&slave->dev); in rt715_io_init()