|
@@ -247,6 +247,8 @@ struct afe_ctl {
|
|
|
uint32_t initial_cal;
|
|
|
uint32_t v_vali_flag;
|
|
|
uint32_t num_spkrs;
|
|
|
+ uint32_t cps_ch_mask;
|
|
|
+ struct afe_cps_hw_intf_cfg *cps_config;
|
|
|
};
|
|
|
|
|
|
struct afe_clkinfo_per_port {
|
|
@@ -2240,46 +2242,53 @@ fail_cmd:
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * afe_send_cps_config -
|
|
|
- * to send cps speaker protection configuration
|
|
|
- *
|
|
|
- * @src_port: source port to send configuration to
|
|
|
- * @cps_config: cps speaker protection v4 configuration
|
|
|
- * @param_size: size of payload
|
|
|
- *
|
|
|
- * Returns 0 on success or error value on failure.
|
|
|
- */
|
|
|
-int afe_send_cps_config(int src_port,
|
|
|
- struct afe_cps_hw_intf_cfg *cps_config,
|
|
|
- int param_size)
|
|
|
+static int afe_send_cps_config(int src_port)
|
|
|
{
|
|
|
+ int i = 0;
|
|
|
struct param_hdr_v3 param_info;
|
|
|
int ret = -EINVAL;
|
|
|
u8 *packed_payload = NULL;
|
|
|
int cpy_size = 0;
|
|
|
+ int ch_copied = 0;
|
|
|
+ size_t param_size = 0;
|
|
|
|
|
|
- ret = q6audio_validate_port(src_port);
|
|
|
- if (ret < 0) {
|
|
|
- pr_err("%s: Invalid src port 0x%x ret %d", __func__,
|
|
|
- src_port, ret);
|
|
|
+ if ((-1 == this_afe.vi_tx_port) || (!this_afe.cps_ch_mask) ||
|
|
|
+ (!this_afe.cps_config)) {
|
|
|
+ pr_err("%s: speaker prot not configured for 0x%x\n", __func__,
|
|
|
+ src_port);
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
|
|
|
+ param_size = sizeof(struct afe_cps_hw_intf_cfg) -
|
|
|
+ sizeof(this_afe.cps_config->spkr_dep_cfg) +
|
|
|
+ (sizeof(struct lpass_swr_spkr_dep_cfg_t)
|
|
|
+ * this_afe.num_spkrs);
|
|
|
+
|
|
|
+ this_afe.cps_config->hw_reg_cfg.num_spkr = this_afe.num_spkrs;
|
|
|
packed_payload = kzalloc(param_size, GFP_KERNEL);
|
|
|
if (packed_payload == NULL)
|
|
|
return -ENOMEM;
|
|
|
|
|
|
cpy_size = sizeof(struct afe_cps_hw_intf_cfg) -
|
|
|
- sizeof(cps_config->spkr_dep_cfg);
|
|
|
- memcpy(packed_payload, cps_config, cpy_size);
|
|
|
- memcpy(packed_payload + cpy_size, cps_config->spkr_dep_cfg,
|
|
|
- sizeof(struct lpass_swr_spkr_dep_cfg_t)
|
|
|
- * cps_config->hw_reg_cfg.num_spkr);
|
|
|
+ sizeof(this_afe.cps_config->spkr_dep_cfg);
|
|
|
+ memcpy(packed_payload, this_afe.cps_config, cpy_size);
|
|
|
+
|
|
|
+ while (ch_copied < this_afe.num_spkrs) {
|
|
|
+ if (!(this_afe.cps_ch_mask & (1 << i))) {
|
|
|
+ i++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ memcpy(packed_payload + cpy_size,
|
|
|
+ &this_afe.cps_config->spkr_dep_cfg[i],
|
|
|
+ sizeof(struct lpass_swr_spkr_dep_cfg_t));
|
|
|
+ cpy_size += sizeof(struct lpass_swr_spkr_dep_cfg_t);
|
|
|
+ ch_copied++;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
|
|
|
memset(¶m_info, 0, sizeof(param_info));
|
|
|
|
|
|
- mutex_lock(&this_afe.afe_cmd_lock);
|
|
|
param_info.module_id = AFE_MODULE_SPEAKER_PROTECTION_V4_RX;
|
|
|
param_info.instance_id = INSTANCE_ID_0;
|
|
|
param_info.param_id = AFE_PARAM_ID_CPS_LPASS_HW_INTF_CFG;
|
|
@@ -2292,13 +2301,11 @@ int afe_send_cps_config(int src_port,
|
|
|
pr_err("%s: port = 0x%x param = 0x%x failed %d\n", __func__,
|
|
|
src_port, param_info.param_id, ret);
|
|
|
|
|
|
- mutex_unlock(&this_afe.afe_cmd_lock);
|
|
|
pr_debug("%s: config.pdata.param_id 0x%x status %d 0x%x\n", __func__,
|
|
|
param_info.param_id, ret, src_port);
|
|
|
kfree(packed_payload);
|
|
|
return ret;
|
|
|
}
|
|
|
-EXPORT_SYMBOL(afe_send_cps_config);
|
|
|
|
|
|
static int afe_spk_prot_prepare(int src_port, int dst_port, int param_id,
|
|
|
union afe_spkr_prot_config *prot_config, uint32_t param_size)
|
|
@@ -5648,6 +5655,11 @@ static int __afe_port_start(u16 port_id, union afe_port_config *afe_config,
|
|
|
afe_send_hw_delay(port_id, rate);
|
|
|
}
|
|
|
|
|
|
+ if ((this_afe.cps_config) &&
|
|
|
+ (this_afe.vi_rx_port == port_id)) {
|
|
|
+ afe_send_cps_config(port_id);
|
|
|
+ }
|
|
|
+
|
|
|
/* Start SW MAD module */
|
|
|
mad_type = afe_port_get_mad_type(port_id);
|
|
|
pr_debug("%s: port_id 0x%x, mad_type %d\n", __func__, port_id,
|
|
@@ -11366,3 +11378,34 @@ done:
|
|
|
return ret;
|
|
|
}
|
|
|
EXPORT_SYMBOL(afe_unvote_lpass_core_hw);
|
|
|
+
|
|
|
+/**
|
|
|
+ * afe_set_cps_config -
|
|
|
+ * to set cps speaker protection configuration
|
|
|
+ *
|
|
|
+ * @src_port: source port to send configuration to
|
|
|
+ * @cps_config: cps speaker protection v4 configuration
|
|
|
+ * @ch_mask: channel mask
|
|
|
+ *
|
|
|
+ */
|
|
|
+void afe_set_cps_config(int src_port,
|
|
|
+ struct afe_cps_hw_intf_cfg *cps_config,
|
|
|
+ u32 ch_mask)
|
|
|
+{
|
|
|
+ this_afe.cps_config = NULL;
|
|
|
+ this_afe.cps_ch_mask = 0;
|
|
|
+
|
|
|
+ if (!cps_config) {
|
|
|
+ pr_err("%s: cps config is NULL\n", __func__);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (q6audio_validate_port(src_port) < 0) {
|
|
|
+ pr_err("%s: Invalid src port 0x%x\n", __func__, src_port);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this_afe.cps_ch_mask = ch_mask;
|
|
|
+ this_afe.cps_config = cps_config;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(afe_set_cps_config);
|