Browse Source

asoc: fix offload PBE failure in sending calibration to lpass

PBE values are misinterpreted when transferring from userspace to kernel
via mixer ctl interface. Config values have to be copied one by one rather
than copying through continuous memory.

CRs-Fixed: 2458428
Change-Id: I375498f0f511d21bd14873cc9394305acbc25e50
Signed-off-by: Weiyin Jiang <[email protected]>
Weiyin Jiang 5 years ago
parent
commit
fce04f7563
1 changed files with 67 additions and 1 deletions
  1. 67 1
      asoc/msm-audio-effects-q6-v2.c

+ 67 - 1
asoc/msm-audio-effects-q6-v2.c

@@ -890,6 +890,9 @@ int msm_audio_effects_pbe_handler(struct audio_client *ac,
 	struct param_hdr_v3 param_hdr;
 	u8 *param_data = NULL;
 	u32 packed_data_size = 0;
+	int32_t *p_coeffs = NULL;
+	uint32_t lpf_len = 0, hpf_len = 0, bpf_len = 0;
+	uint32_t bsf_len = 0, tsf_len = 0, total_coeffs_len = 0;
 
 	pr_debug("%s\n", __func__);
 	if (!ac || (devices == -EINVAL) || (num_commands == -EINVAL)) {
@@ -949,8 +952,71 @@ int msm_audio_effects_pbe_handler(struct audio_client *ac,
 				rc = -EINVAL;
 				goto invalid_config;
 			}
+
+			pbe->config.real_bass_mix =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.bass_color_control =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.main_chain_delay =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.xover_filter_order =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.bandpass_filter_order =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.drc_delay =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.rms_tav =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.exp_threshold =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.exp_slope =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.comp_threshold =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.comp_slope =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.makeup_gain =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.comp_attack =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.comp_release =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.exp_attack =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.exp_release =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.limiter_bass_threshold =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.limiter_high_threshold =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.limiter_bass_makeup_gain =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.limiter_high_makeup_gain =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.limiter_bass_gc =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.limiter_high_gc =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.limiter_delay =
+				GET_NEXT(values, param_max_offset, rc);
+			pbe->config.reserved =
+				GET_NEXT(values, param_max_offset, rc);
+
+			p_coeffs = &pbe->config.p1LowPassCoeffs[0];
+			lpf_len = (pbe->config.xover_filter_order == 3) ? 10 : 5;
+			hpf_len = (pbe->config.xover_filter_order == 3) ? 10 : 5;
+			bpf_len = pbe->config.bandpass_filter_order * 5;
+			bsf_len = 5;
+			tsf_len = 5;
+			total_coeffs_len = lpf_len + hpf_len + bpf_len + bsf_len + tsf_len;
+
+			for (i = 0; i < total_coeffs_len; i++) {
+				*p_coeffs++ = GET_NEXT(values, param_max_offset, rc);
+			}
+
 			if (command_config_state != CONFIG_SET)
 				break;
+
 			max_params_length =
 				params_length + COMMAND_IID_PAYLOAD_SZ + length;
 			CHECK_PARAM_LEN(max_params_length, MAX_INBAND_PARAM_SZ,
@@ -959,7 +1025,7 @@ int msm_audio_effects_pbe_handler(struct audio_client *ac,
 				break;
 			param_hdr.param_id = AUDPROC_PARAM_ID_PBE_PARAM_CONFIG;
 			param_hdr.param_size = length;
-			param_data = (u8 *) values;
+			param_data = (u8 *) &pbe->config;
 			break;
 		default:
 			pr_err_ratelimited("%s: Invalid command to set config\n",