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

Commit 740b4839 authored by Aditya Bavanari's avatar Aditya Bavanari Committed by Meng Wang
Browse files

dsp: afe: Implement get param for excursion logging parameters



Implement get param for AFE_PARAM_ID_SP_RX_TMAX_XMAX_LOGGING
in order to get excursion params from DSP.

Change-Id: I5129938c51c6f6ede9d4703d13be60d04d26f5e3
Signed-off-by: default avatarAditya Bavanari <abavanar@codeaurora.org>
parent 2e13d955
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
@@ -140,6 +140,7 @@ struct afe_ctl {
	struct afe_sp_th_vi_get_param_resp	th_vi_resp;
	struct afe_sp_th_vi_v_vali_get_param_resp	th_vi_v_vali_resp;
	struct afe_sp_ex_vi_get_param_resp	ex_vi_resp;
	struct afe_sp_rx_tmax_xmax_logging_resp	xt_logging_resp;
	struct afe_av_dev_drift_get_param_resp	av_dev_drift_resp;
	struct afe_doa_tracking_mon_get_param_resp	doa_tracking_mon_resp;
	int vi_tx_port;
@@ -385,6 +386,11 @@ static int32_t sp_make_afe_callback(uint32_t opcode, uint32_t *payload,
		expected_size += sizeof(struct afe_sp_ex_vi_ftm_params);
		data_dest = (u32 *) &this_afe.ex_vi_resp;
		break;
	case AFE_PARAM_ID_SP_RX_TMAX_XMAX_LOGGING:
		expected_size += sizeof(
				struct afe_sp_rx_tmax_xmax_logging_param);
		data_dest = (u32 *) &this_afe.xt_logging_resp;
		break;
	default:
		pr_err("%s: Unrecognized param ID %d\n", __func__,
		       param_hdr.param_id);
@@ -7620,6 +7626,57 @@ int afe_get_sp_ex_vi_ftm_data(struct afe_sp_ex_vi_get_param *ex_vi)
	return ret;
}

/**
 * afe_get_sp_rx_tmax_xmax_logging_data -
 *       command to get excursion logging data from DSP
 *
 * @xt_logging: excursion logging params
 * @port: AFE port ID
 *
 * Returns 0 on success or error on failure
 */
int afe_get_sp_rx_tmax_xmax_logging_data(
			struct afe_sp_rx_tmax_xmax_logging_param *xt_logging,
			u16 port_id)
{
	struct param_hdr_v3 param_hdr;
	int ret = -EINVAL;

	if (!xt_logging) {
		pr_err("%s: Invalid params\n", __func__);
		goto done;
	}

	memset(&param_hdr, 0, sizeof(param_hdr));

	param_hdr.module_id = AFE_MODULE_FB_SPKR_PROT_V2_RX;
	param_hdr.instance_id = INSTANCE_ID_0;
	param_hdr.param_id = AFE_PARAM_ID_SP_RX_TMAX_XMAX_LOGGING;
	param_hdr.param_size = sizeof(struct afe_sp_rx_tmax_xmax_logging_param);

	ret = q6afe_get_params(port_id, NULL, &param_hdr);
	if (ret < 0) {
		pr_err("%s: get param port 0x%x param id[0x%x]failed %d\n",
		       __func__, port_id, param_hdr.param_id, ret);
		goto done;
	}

	memcpy(xt_logging, &this_afe.xt_logging_resp.param,
		sizeof(this_afe.xt_logging_resp.param));
	pr_debug("%s: max_excursion %d %d count_exceeded_excursion %d %d max_temperature %d %d count_exceeded_temperature %d %d\n",
		 __func__, xt_logging->max_excursion[SP_V2_SPKR_1],
		 xt_logging->max_excursion[SP_V2_SPKR_2],
		 xt_logging->count_exceeded_excursion[SP_V2_SPKR_1],
		 xt_logging->count_exceeded_excursion[SP_V2_SPKR_2],
		 xt_logging->max_temperature[SP_V2_SPKR_1],
		 xt_logging->max_temperature[SP_V2_SPKR_2],
		 xt_logging->count_exceeded_temperature[SP_V2_SPKR_1],
		 xt_logging->count_exceeded_temperature[SP_V2_SPKR_2]);
done:
	return ret;
}
EXPORT_SYMBOL(afe_get_sp_rx_tmax_xmax_logging_data);

/**
 * afe_get_av_dev_drift -
 *       command to retrieve AV drift
+28 −0
Original line number Diff line number Diff line
@@ -10408,6 +10408,7 @@ struct cmd_set_topologies {
#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
#define AFE_PARAM_ID_SP_RX_TMAX_XMAX_LOGGING 0x000102BC

struct asm_fbsp_mode_rx_cfg {
	uint32_t minor_version;
@@ -10665,6 +10666,33 @@ struct afe_sp_ex_vi_ftm_params {
	 */
} __packed;

struct afe_sp_rx_tmax_xmax_logging_param {
	/*
	 * Maximum excursion since the last grasp of xmax in mm.
	 */
	int32_t max_excursion[SP_V2_NUM_MAX_SPKR];
	/*
	 * Number of periods when the monitored excursion exceeds to and
	 * stays at Xmax during logging_count_period.
	 */
	uint32_t count_exceeded_excursion[SP_V2_NUM_MAX_SPKR];
	/*
	 * Maximum temperature since the last grasp of tmax in C.
	 */
	int32_t max_temperature[SP_V2_NUM_MAX_SPKR];
	/*
	 * Number of periods when the monitored temperature exceeds to and
	 * stays at Tmax during logging_count_period
	 */
	uint32_t count_exceeded_temperature[SP_V2_NUM_MAX_SPKR];
} __packed;

struct afe_sp_rx_tmax_xmax_logging_resp {
	uint32_t status;
	struct param_hdr_v3 pdata;
	struct afe_sp_rx_tmax_xmax_logging_param param;
} __packed;

struct afe_sp_ex_vi_get_param {
	struct param_hdr_v3 pdata;
	struct afe_sp_ex_vi_ftm_params param;
+3 −0
Original line number Diff line number Diff line
@@ -446,6 +446,9 @@ int afe_tdm_port_start(u16 port_id, struct afe_tdm_port_config *tdm_port,
void afe_set_routing_callback(routing_cb cb);
int afe_get_av_dev_drift(struct afe_param_id_dev_timing_stats *timing_stats,
		u16 port);
int afe_get_sp_rx_tmax_xmax_logging_data(
		struct afe_sp_rx_tmax_xmax_logging_param *xt_logging,
		u16 port_id);
int afe_cal_init_hwdep(void *card);
int afe_send_port_island_mode(u16 port_id);
int afe_send_cmd_wakeup_register(void *handle, bool enable);