Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12120ab1 authored by Xiaojun Sang's avatar Xiaojun Sang Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: add support for speaker protection 3.0



Add a new AFE API to send limiter threshold to ADSP.

Change-Id: Ibcd795d7c0edb4f081636c621e51e5a1eaa036b1
Signed-off-by: default avatarXiaojun Sang <xsang@codeaurora.org>
parent b5321975
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -1045,6 +1045,7 @@ static int afe_spk_prot_prepare(int src_port, int dst_port, int param_id,
	}
	switch (param_id) {
	case AFE_PARAM_ID_FBSP_MODE_RX_CFG:
	case AFE_PARAM_ID_SP_RX_LIMITER_TH:
		config.pdata.module_id = AFE_MODULE_FB_SPKR_PROT_V2_RX;
		break;
	case AFE_PARAM_ID_FEEDBACK_PATH_CFG:
@@ -1229,6 +1230,7 @@ static void afe_send_cal_spkr_prot_tx(int port_id)
static void afe_send_cal_spkr_prot_rx(int port_id)
{
	union afe_spkr_prot_config afe_spk_config;
	union afe_spkr_prot_config afe_spk_limiter_config;

	if (this_afe.cal_data[AFE_FB_SPKR_PROT_CAL] == NULL)
		goto done;
@@ -1250,6 +1252,30 @@ static void afe_send_cal_spkr_prot_rx(int port_id)
			&afe_spk_config))
			pr_err("%s: RX MODE_VI_PROC_CFG failed\n",
				   __func__);

		if (afe_spk_config.mode_rx_cfg.mode ==
			Q6AFE_MSM_SPKR_PROCESSING) {
			if (this_afe.prot_cfg.sp_version >=
				AFE_API_VERSION_SUPPORT_SPV3) {
				afe_spk_limiter_config.limiter_th_cfg.
					minor_version = 1;
				afe_spk_limiter_config.limiter_th_cfg.
				lim_thr_per_calib_q27[SP_V2_SPKR_1] =
				this_afe.prot_cfg.limiter_th[SP_V2_SPKR_1];
				afe_spk_limiter_config.limiter_th_cfg.
				lim_thr_per_calib_q27[SP_V2_SPKR_2] =
				this_afe.prot_cfg.limiter_th[SP_V2_SPKR_2];
				if (afe_spk_prot_prepare(port_id, 0,
					AFE_PARAM_ID_SP_RX_LIMITER_TH,
					&afe_spk_limiter_config))
					pr_err("%s: SP_RX_LIMITER_TH failed.\n",
						__func__);
			} else {
				pr_debug("%s: SPv3 failed to apply on AFE API version=%d.\n",
					__func__,
					this_afe.prot_cfg.sp_version);
			}
		}
	}
	mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock);
done:
+7 −1
Original line number Diff line number Diff line
@@ -8895,7 +8895,7 @@ struct cmd_set_topologies {

#define AFE_MODULE_FB_SPKR_PROT_RX 0x0001021C
#define AFE_MODULE_FB_SPKR_PROT_V2_RX 0x0001025F

#define AFE_PARAM_ID_SP_RX_LIMITER_TH 0x000102B1
#define AFE_PARAM_ID_FBSP_MODE_RX_CFG 0x0001021D
#define AFE_PARAM_ID_FBSP_PTONE_RAMP_CFG 0x00010260

@@ -9123,6 +9123,11 @@ struct afe_sp_ex_vi_get_param_resp {
	struct afe_sp_ex_vi_ftm_params param;
} __packed;

struct afe_sp_rx_limiter_th_param {
	uint32_t minor_version;
	uint32_t lim_thr_per_calib_q27[SP_V2_NUM_MAX_SPKR];
} __packed;

union afe_spkr_prot_config {
	struct asm_fbsp_mode_rx_cfg mode_rx_cfg;
	struct asm_spkr_calib_vi_proc_cfg vi_proc_cfg;
@@ -9132,6 +9137,7 @@ union afe_spkr_prot_config {
	struct afe_sp_th_vi_ftm_cfg th_vi_ftm_cfg;
	struct afe_sp_ex_vi_mode_cfg ex_vi_mode_cfg;
	struct afe_sp_ex_vi_ftm_cfg ex_vi_ftm_cfg;
	struct afe_sp_rx_limiter_th_param limiter_th_cfg;
} __packed;

struct afe_spkr_prot_config_command {
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@

#define AFE_CLK_VERSION_V1    1
#define AFE_CLK_VERSION_V2    2

#define AFE_API_VERSION_SUPPORT_SPV3	2
typedef int (*routing_cb)(int port);

enum {