From 740b4839cbb3a6007ba6f3e4e0ebd676b020485f Mon Sep 17 00:00:00 2001 From: Aditya Bavanari Date: Mon, 24 Dec 2018 18:46:12 +0530 Subject: [PATCH] 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: Aditya Bavanari --- dsp/q6afe.c | 57 ++++++++++++++++++++++++++++++++++++++ include/dsp/apr_audio-v2.h | 28 +++++++++++++++++++ include/dsp/q6afe-v2.h | 3 ++ 3 files changed, 88 insertions(+) diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 5000b9f46477..63057a08bd43 100644 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -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 @@ done: 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(¶m_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, ¶m_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 diff --git a/include/dsp/apr_audio-v2.h b/include/dsp/apr_audio-v2.h index 3f50d1041180..62ff28b17ed0 100644 --- a/include/dsp/apr_audio-v2.h +++ b/include/dsp/apr_audio-v2.h @@ -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; diff --git a/include/dsp/q6afe-v2.h b/include/dsp/q6afe-v2.h index 413edc152af5..2319415917f2 100644 --- a/include/dsp/q6afe-v2.h +++ b/include/dsp/q6afe-v2.h @@ -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);