summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvijeth.po2020-09-01 09:34:14 -0500
committerPeeyush Gupta2020-09-05 22:53:57 -0500
commit56b66005fbb310e15b913bf5dc17e76ed8e5090b (patch)
treef76bfc30631f84a4028bd4230604c675caba08c9
parentba3a246c898d48e6f98b127a1bf317885c8da9f0 (diff)
downloadtas256x-stereo-driver-56b66005fbb310e15b913bf5dc17e76ed8e5090b.tar.gz
tas256x-stereo-driver-56b66005fbb310e15b913bf5dc17e76ed8e5090b.tar.xz
tas256x-stereo-driver-56b66005fbb310e15b913bf5dc17e76ed8e5090b.zip
Add Digital Gain Mixer Control Interface to Algorithm(Receiver Mode)SAMSUNG_A72_1.3.6.2
-rw-r--r--tas256x_driver/algo/inc/tas_smart_amp_v2.h7
-rw-r--r--tas256x_driver/algo/src/tas25xx-algo-common.c99
-rw-r--r--tas256x_driver/logical_layer/src/tas256x-logic.c8
3 files changed, 111 insertions, 3 deletions
diff --git a/tas256x_driver/algo/inc/tas_smart_amp_v2.h b/tas256x_driver/algo/inc/tas_smart_amp_v2.h
index 35b3f57..950e66b 100644
--- a/tas256x_driver/algo/inc/tas_smart_amp_v2.h
+++ b/tas256x_driver/algo/inc/tas_smart_amp_v2.h
@@ -98,6 +98,7 @@ typedef enum {
98#define TAS_SA_SET_INTERFACE_MODE 3836 98#define TAS_SA_SET_INTERFACE_MODE 3836
99#define TAS_PCM_CHANNEL_MAPPING 3837 99#define TAS_PCM_CHANNEL_MAPPING 3837
100#define TAS_SA_GET_RE_RANGE 3838 100#define TAS_SA_GET_RE_RANGE 3838
101#define TAS_SA_DIGITAL_GAIN 3839
101 102
102/*Added for DC Detection*/ 103/*Added for DC Detection*/
103#define CAPI_V2_TAS_SA_DC_DETECT 0x40404040 104#define CAPI_V2_TAS_SA_DC_DETECT 0x40404040
@@ -152,6 +153,7 @@ bool tas25xx_set_iv_bit_fomat(int iv_data_with, int vbat, int update_now);
152int get_iv_vbat_format(void); 153int get_iv_vbat_format(void);
153 154
154void tas25xx_send_channel_mapping(void); 155void tas25xx_send_channel_mapping(void);
156void tas25xx_algo_enable_common_controls(int value);
155 157
156#if IS_ENABLED(CONFIG_TISA_KBIN_INTF) 158#if IS_ENABLED(CONFIG_TISA_KBIN_INTF)
157void tas25xx_algo_set_active(void); 159void tas25xx_algo_set_active(void);
@@ -159,8 +161,11 @@ void tas25xx_algo_set_inactive(void);
159void tas_smartamp_kbin_deinitalize(void); 161void tas_smartamp_kbin_deinitalize(void);
160#endif /* CONFIG_TISA_KBIN_INTF */ 162#endif /* CONFIG_TISA_KBIN_INTF */
161 163
162#if IS_ENABLED(CONFIG_TAS25XX_CALIB_VAL_BIG) 164#if IS_ENABLED(CONFIG_TAS25XX_CALIB_VAL_BIG) || IS_ENABLED(CONFIG_TISA_DEBUGFS_INTF)
163void tas25xx_send_algo_calibration(void); 165void tas25xx_send_algo_calibration(void);
166#endif
167
168#if IS_ENABLED(CONFIG_TAS25XX_CALIB_VAL_BIG)
164void tas25xx_update_big_data(void); 169void tas25xx_update_big_data(void);
165#endif 170#endif
166 171
diff --git a/tas256x_driver/algo/src/tas25xx-algo-common.c b/tas256x_driver/algo/src/tas25xx-algo-common.c
index 0ca2bb0..9639694 100644
--- a/tas256x_driver/algo/src/tas25xx-algo-common.c
+++ b/tas256x_driver/algo/src/tas25xx-algo-common.c
@@ -55,6 +55,12 @@ void tas_smartamp_remove_algo_controls_debugfs(struct snd_soc_codec *codec);
55static int32_t g_fmt; 55static int32_t g_fmt;
56static struct device *s_device; 56static struct device *s_device;
57static char s_channel_map[TDM_MAX_CHANNELS] = {0, 1, 2, 3}; 57static char s_channel_map[TDM_MAX_CHANNELS] = {0, 1, 2, 3};
58static int s_allow_algo_controls;
59
60void tas25xx_algo_enable_common_controls(int value)
61{
62 s_allow_algo_controls = value;
63}
58 64
59struct soc_multi_control_ch_map { 65struct soc_multi_control_ch_map {
60 int min, max, platform_max, count; 66 int min, max, platform_max, count;
@@ -181,6 +187,93 @@ int tas25xx_algo_channel_map_info(struct snd_kcontrol *kcontrol,
181 return 0; 187 return 0;
182} 188}
183 189
190static int tas25xx_get_digital_gain_common(int channel)
191{
192 int ret = 0;
193 int digital_gain = 0;
194 int param_id = 0;
195
196 if (s_allow_algo_controls) {
197 param_id = TAS_CALC_PARAM_IDX(TAS_SA_DIGITAL_GAIN, 1, channel);
198 ret = tas25xx_smartamp_algo_ctrl((u8 *)&digital_gain, param_id,
199 TAS_GET_PARAM, sizeof(uint32_t),
200 TISA_MOD_RX);
201 if (ret < 0)
202 pr_err("TI-SmartPA: %s: failed to get digital gain\n",
203 __func__);
204 else
205 ret = digital_gain;
206 } else {
207 pr_info("TI-SmartPA: %s: Not calling algo. Playback inactive\n",
208 __func__);
209 ret = 0;
210 }
211
212 return ret;
213}
214
215static int tas25xx_get_digital_gain_left(struct snd_kcontrol *pKcontrol,
216 struct snd_ctl_elem_value *pUcontrol)
217{
218 int ret = tas25xx_get_digital_gain_common(CHANNEL0);
219
220 pUcontrol->value.integer.value[0] = ret;
221 pr_info("TI-SmartPA: %s: got digital gain for left ch %d\n",
222 __func__, ret);
223
224 return 0;
225}
226
227static int tas25xx_get_digital_gain_right(struct snd_kcontrol *pKcontrol,
228 struct snd_ctl_elem_value *pUcontrol)
229{
230 int ret = tas25xx_get_digital_gain_common(CHANNEL1);
231
232 pUcontrol->value.integer.value[0] = ret;
233 pr_info("TI-SmartPA: %s: Getting digital gain right ch %d\n",
234 __func__, ret);
235
236 return 0;
237}
238
239static int tas25xx_set_digital_gain_common(int digital_gain, int channel)
240{
241 int ret;
242 int param_id = 0;
243 int gain = digital_gain;
244
245 pr_info("TI-SmartPA: %s: set gain =%d =>(gain - 108)dB=%d, ch=%d\n",
246 __func__, gain, (gain - 108), channel);
247
248 if (s_allow_algo_controls) {
249 param_id = TAS_CALC_PARAM_IDX(TAS_SA_DIGITAL_GAIN, 1, channel);
250 ret = tas25xx_smartamp_algo_ctrl((u8 *)&gain, param_id,
251 TAS_SET_PARAM, sizeof(uint32_t), TISA_MOD_RX);
252 } else {
253 pr_info("TI-SmartPA: %s: Not calling algo.Playback inactive\n",
254 __func__);
255 ret = -EAGAIN;
256 }
257
258 return ret;
259}
260
261static int tas25xx_set_digital_gain_left(struct snd_kcontrol *kcontrol,
262 struct snd_ctl_elem_value *pUcontrol)
263{
264 int digital_gain = pUcontrol->value.integer.value[0];
265
266 return tas25xx_set_digital_gain_common(digital_gain, CHANNEL0);
267}
268
269static int tas25xx_set_digital_gain_right(struct snd_kcontrol *kcontrol,
270 struct snd_ctl_elem_value *pUcontrol)
271{
272 int digital_gain = pUcontrol->value.integer.value[0];
273
274 return tas25xx_set_digital_gain_common(digital_gain, CHANNEL1);
275}
276
184static const struct snd_kcontrol_new tas25xx_algo_common_controls[] = { 277static const struct snd_kcontrol_new tas25xx_algo_common_controls[] = {
185 { 278 {
186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 279 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
@@ -198,7 +291,11 @@ static const struct snd_kcontrol_new tas25xx_algo_common_controls[] = {
198 .platform_max = 16, 291 .platform_max = 16,
199 .invert = 0, 292 .invert = 0,
200 } 293 }
201 } 294 },
295 SOC_SINGLE_EXT("TAS25XX_ALGO_DIGITAL_GAIN_A", SND_SOC_NOPM, 0, 126, 0,
296 tas25xx_get_digital_gain_left, tas25xx_set_digital_gain_left),
297 SOC_SINGLE_EXT("TAS25XX_ALGO_DIGITAL_GAIN_B", SND_SOC_NOPM, 0, 126, 0,
298 tas25xx_get_digital_gain_right, tas25xx_set_digital_gain_right),
202}; 299};
203 300
204void tas25xx_parse_algo_dt(struct device_node *np) 301void tas25xx_parse_algo_dt(struct device_node *np)
diff --git a/tas256x_driver/logical_layer/src/tas256x-logic.c b/tas256x_driver/logical_layer/src/tas256x-logic.c
index e428a4c..7eedbde 100644
--- a/tas256x_driver/logical_layer/src/tas256x-logic.c
+++ b/tas256x_driver/logical_layer/src/tas256x-logic.c
@@ -1046,12 +1046,15 @@ int tas256x_set_power_state(struct tas256x_priv *p_tas256x,
1046 switch (state) { 1046 switch (state) {
1047 case TAS256X_POWER_ACTIVE: 1047 case TAS256X_POWER_ACTIVE:
1048 n_result = tas256x_iv_sense_enable_set(p_tas256x, 1, chn); 1048 n_result = tas256x_iv_sense_enable_set(p_tas256x, 1, chn);
1049#if IS_ENABLED(CONFIG_TAS25XX_CALIB_VAL_BIG) 1049#if IS_ENABLED(CONFIG_TAS25XX_CALIB_VAL_BIG) || IS_ENABLED(CONFIG_TISA_DEBUGFS_INTF)
1050 tas25xx_send_channel_mapping(); 1050 tas25xx_send_channel_mapping();
1051 tas25xx_send_algo_calibration(); 1051 tas25xx_send_algo_calibration();
1052 tas25xx_set_iv_bit_fomat(p_tas256x->mn_iv_width, 1052 tas25xx_set_iv_bit_fomat(p_tas256x->mn_iv_width,
1053 p_tas256x->mn_vbat, 1); 1053 p_tas256x->mn_vbat, 1);
1054#endif 1054#endif
1055#if IS_ENABLED(CONFIG_TAS25XX_ALGO)
1056 tas25xx_algo_enable_common_controls(1);
1057#endif
1055 /* Clear latched IRQ before power on */ 1058 /* Clear latched IRQ before power on */
1056 tas256x_interrupt_clear(p_tas256x, chn); 1059 tas256x_interrupt_clear(p_tas256x, chn);
1057 1060
@@ -1130,6 +1133,9 @@ int tas256x_set_power_state(struct tas256x_priv *p_tas256x,
1130#if IS_ENABLED(CONFIG_TISA_KBIN_INTF) 1133#if IS_ENABLED(CONFIG_TISA_KBIN_INTF)
1131 tas25xx_algo_set_inactive(); 1134 tas25xx_algo_set_inactive();
1132#endif 1135#endif
1136#if IS_ENABLED(CONFIG_TAS25XX_ALGO)
1137 tas25xx_algo_enable_common_controls(0);
1138#endif
1133 break; 1139 break;
1134 default: 1140 default:
1135 pr_err("wrong power state setting %d\n", 1141 pr_err("wrong power state setting %d\n",