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: Xiaojun Sang <xsang@codeaurora.org>
diff --git a/dsp/q6afe.c b/dsp/q6afe.c
index 631a123..864ae4a 100644
--- a/dsp/q6afe.c
+++ b/dsp/q6afe.c
@@ -1045,6 +1045,7 @@
}
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_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 @@
&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: