diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c index ac238578c64e..580335691b1a 100644 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "msm-dai-q6-v2.h" #include @@ -10538,6 +10539,17 @@ static void msm_dai_q6_cdc_dma_shutdown(struct snd_pcm_substream *substream, clear_bit(STATUS_PORT_STARTED, dai_data->hwfree_status); } +/* all ports with same WSA requirement can use this digital mute API */ +static int msm_dai_q6_spk_digital_mute(struct snd_soc_dai *dai, + int mute) +{ + int port_id = dai->id; + + if (mute) + afe_get_sp_xt_logging_data(port_id); + + return 0; +} static struct snd_soc_dai_ops msm_dai_q6_cdc_dma_ops = { .prepare = msm_dai_q6_cdc_dma_prepare, @@ -10546,6 +10558,14 @@ static struct snd_soc_dai_ops msm_dai_q6_cdc_dma_ops = { .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map, }; +static struct snd_soc_dai_ops msm_dai_q6_cdc_wsa_dma_ops = { + .prepare = msm_dai_q6_cdc_dma_prepare, + .hw_params = msm_dai_q6_cdc_dma_hw_params, + .shutdown = msm_dai_q6_cdc_dma_shutdown, + .set_channel_map = msm_dai_q6_cdc_dma_set_channel_map, + .digital_mute = msm_dai_q6_spk_digital_mute, +}; + static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = { { .playback = { @@ -10568,7 +10588,7 @@ static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = { .rate_max = 384000, }, .name = "WSA_CDC_DMA_RX_0", - .ops = &msm_dai_q6_cdc_dma_ops, + .ops = &msm_dai_q6_cdc_wsa_dma_ops, .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_0, .probe = msm_dai_q6_dai_cdc_dma_probe, .remove = msm_dai_q6_dai_cdc_dma_remove, @@ -10620,7 +10640,7 @@ static struct snd_soc_dai_driver msm_dai_q6_cdc_dma_dai[] = { .rate_max = 384000, }, .name = "WSA_CDC_DMA_RX_1", - .ops = &msm_dai_q6_cdc_dma_ops, + .ops = &msm_dai_q6_cdc_wsa_dma_ops, .id = AFE_PORT_ID_WSA_CODEC_DMA_RX_1, .probe = msm_dai_q6_dai_cdc_dma_probe, .remove = msm_dai_q6_dai_cdc_dma_remove, diff --git a/dsp/Kbuild b/dsp/Kbuild index 195502a7e210..daf0b303aa0e 100644 --- a/dsp/Kbuild +++ b/dsp/Kbuild @@ -91,11 +91,16 @@ ifdef CONFIG_SND_SOC_MSM_QDSP6V2_INTF Q6_OBJS += msm_audio_ion.o Q6_OBJS += avtimer.o Q6_OBJS += q6_init.o - endif + +ifdef CONFIG_XT_LOGGING + Q6_OBJS += sp_params.o +endif + ifdef CONFIG_WCD9XXX_CODEC_CORE Q6_OBJS += audio_slimslave.o endif + ifdef CONFIG_DTS_SRS_TM Q6_OBJS += msm-dts-srs-tm-config.o endif diff --git a/dsp/q6_init.c b/dsp/q6_init.c index 1078c5761c2b..fb18741d3838 100644 --- a/dsp/q6_init.c +++ b/dsp/q6_init.c @@ -14,6 +14,7 @@ static int __init audio_q6_init(void) rtac_init(); adm_init(); afe_init(); + spk_params_init(); q6asm_init(); q6lsm_init(); voice_init(); @@ -37,6 +38,7 @@ static void __exit audio_q6_exit(void) q6lsm_exit(); q6asm_exit(); afe_exit(); + spk_params_exit(); adm_exit(); rtac_exit(); audio_cal_exit(); diff --git a/dsp/q6_init.h b/dsp/q6_init.h index e7ad19b074b5..4df2e032700f 100644 --- a/dsp/q6_init.h +++ b/dsp/q6_init.h @@ -30,6 +30,18 @@ static inline void msm_mdf_exit(void) return; } #endif +#ifdef CONFIG_XT_LOGGING +int spk_params_init(void); +void spk_params_exit(void); +#else +static inline int spk_params_init(void) +{ + return 0; +} +static inline void spk_params_exit(void) +{ +} +#endif void avtimer_exit(void); void msm_audio_ion_exit(void); diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 63057a08bd43..3d5f5e8315c6 100644 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -158,6 +158,9 @@ struct afe_ctl { struct vad_config vad_cfg[AFE_MAX_PORTS]; struct work_struct afe_dc_work; struct notifier_block event_notifier; + /* FTM spk params */ + uint32_t initial_cal; + uint32_t v_vali_flag; }; static atomic_t afe_ports_mad_type[SLIMBUS_PORT_LAST - SLIMBUS_0_RX]; @@ -179,6 +182,51 @@ static int afe_get_cal_hw_delay(int32_t path, struct audio_cal_hw_delay_entry *entry); static int remap_cal_data(struct cal_block_data *cal_block, int cal_index); +int afe_get_spk_initial_cal(void) +{ + return this_afe.initial_cal; +} + +void afe_get_spk_r0(int *spk_r0) +{ + uint16_t i = 0; + + for (; i < SP_V2_NUM_MAX_SPKRS; i++) + spk_r0[i] = this_afe.prot_cfg.r0[i]; +} + +void afe_get_spk_t0(int *spk_t0) +{ + uint16_t i = 0; + + for (; i < SP_V2_NUM_MAX_SPKRS; i++) + spk_t0[i] = this_afe.prot_cfg.t0[i]; +} + +int afe_get_spk_v_vali_flag(void) +{ + return this_afe.v_vali_flag; +} + +void afe_get_spk_v_vali_sts(int *spk_v_vali_sts) +{ + uint16_t i = 0; + + for (; i < SP_V2_NUM_MAX_SPKRS; i++) + spk_v_vali_sts[i] = + this_afe.th_vi_v_vali_resp.param.status[i]; +} + +void afe_set_spk_initial_cal(int initial_cal) +{ + this_afe.initial_cal = initial_cal; +} + +void afe_set_spk_v_vali_flag(int v_vali_flag) +{ + this_afe.v_vali_flag = v_vali_flag; +} + int afe_get_topology(int port_id) { int topology; @@ -7793,9 +7841,9 @@ int afe_spk_prot_get_calib_data(struct afe_spkr_prot_get_vi_calib *calib_resp) memcpy(&calib_resp->res_cfg, &this_afe.calib_data.res_cfg, sizeof(this_afe.calib_data.res_cfg)); pr_info("%s: state %s resistance %d %d\n", __func__, - fbsp_state[calib_resp->res_cfg.th_vi_ca_state], - calib_resp->res_cfg.r0_cali_q24[SP_V2_SPKR_1], - calib_resp->res_cfg.r0_cali_q24[SP_V2_SPKR_2]); + fbsp_state[calib_resp->res_cfg.th_vi_ca_state], + calib_resp->res_cfg.r0_cali_q24[SP_V2_SPKR_1], + calib_resp->res_cfg.r0_cali_q24[SP_V2_SPKR_2]); ret = 0; fail_cmd: return ret; @@ -8223,6 +8271,7 @@ static int afe_get_cal_sp_th_vi_v_vali_param(int32_t cal_type, size_t data_size, } } } + this_afe.v_vali_flag = 0; done: return ret; } @@ -8385,6 +8434,7 @@ static int afe_get_cal_fb_spkr_prot(int32_t cal_type, size_t data_size, cal_data->cal_info.r0[SP_V2_SPKR_1] = -1; cal_data->cal_info.r0[SP_V2_SPKR_2] = -1; } + this_afe.initial_cal = 0; mutex_unlock(&this_afe.cal_data[AFE_FB_SPKR_PROT_CAL]->lock); __pm_relax(&wl.ws); done: diff --git a/dsp/sp_params.c b/dsp/sp_params.c new file mode 100644 index 000000000000..ed6d2ebb05d5 --- /dev/null +++ b/dsp/sp_params.c @@ -0,0 +1,424 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include + +/* export or show spk params at /sys/class/spk_params/cal_data */ +#define SPK_PARAMS "spk_params" +#define CLASS_NAME "cal_data" +#define BUF_SZ 20 +#define Q27 (1<<27) +#define Q22 (1<<22) + +struct afe_spk_ctl { + struct class *p_class; + struct device *p_dev; + struct afe_sp_rx_tmax_xmax_logging_param xt_logging; + int32_t max_temperature_rd[SP_V2_NUM_MAX_SPKR]; +}; +struct afe_spk_ctl this_afe_spk; + +static ssize_t sp_count_exceeded_temperature_l_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + ssize_t ret = 0; + + ret = snprintf(buf, BUF_SZ, "%d\n", + this_afe_spk.xt_logging.count_exceeded_temperature[SP_V2_SPKR_1]); + this_afe_spk.xt_logging.count_exceeded_temperature[SP_V2_SPKR_1] = 0; + return ret; +} +static DEVICE_ATTR(count_exceeded_temperature, 0644, + sp_count_exceeded_temperature_l_show, NULL); + +static ssize_t sp_count_exceeded_temperature_r_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + ssize_t ret = 0; + + ret = snprintf(buf, BUF_SZ, "%d\n", + this_afe_spk.xt_logging.count_exceeded_temperature[SP_V2_SPKR_2]); + this_afe_spk.xt_logging.count_exceeded_temperature[SP_V2_SPKR_2] = 0; + return ret; +} +static DEVICE_ATTR(count_exceeded_temperature_r, 0644, + sp_count_exceeded_temperature_r_show, NULL); + +static ssize_t sp_count_exceeded_excursion_l_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + ssize_t ret = 0; + + ret = snprintf(buf, BUF_SZ, "%d\n", + this_afe_spk.xt_logging.count_exceeded_excursion[SP_V2_SPKR_1]); + this_afe_spk.xt_logging.count_exceeded_excursion[SP_V2_SPKR_1] = 0; + return ret; +} +static DEVICE_ATTR(count_exceeded_excursion, 0644, + sp_count_exceeded_excursion_l_show, NULL); + +static ssize_t sp_count_exceeded_excursion_r_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + ssize_t ret = 0; + + ret = snprintf(buf, BUF_SZ, "%d\n", + this_afe_spk.xt_logging.count_exceeded_excursion[SP_V2_SPKR_2]); + this_afe_spk.xt_logging.count_exceeded_excursion[SP_V2_SPKR_2] = 0; + return ret; +} +static DEVICE_ATTR(count_exceeded_excursion_r, 0644, + sp_count_exceeded_excursion_r_show, NULL); + +static ssize_t sp_max_excursion_l_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + ssize_t ret = 0; + int32_t ex_val_frac; + float ex_val; + int32_t ex_q27 = this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_1]; + + ex_val = (ex_q27 * 1.0)/Q27; + ex_val_frac = ex_val * 100; + ret = snprintf(buf, BUF_SZ, "%d.%02d\n", 0, ex_val_frac); + this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_1] = 0; + return ret; +} +static DEVICE_ATTR(max_excursion, 0644, sp_max_excursion_l_show, NULL); + +static ssize_t sp_max_excursion_r_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + ssize_t ret = 0; + int32_t ex_val_frac; + float ex_val; + int32_t ex_q27 = this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_2]; + + ex_val = (ex_q27 * 1.0)/Q27; + ex_val_frac = ex_val * 100; + ret = snprintf(buf, BUF_SZ, "%d.%02d\n", 0, ex_val_frac); + this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_2] = 0; + return ret; +} +static DEVICE_ATTR(max_excursion_r, 0644, sp_max_excursion_r_show, NULL); + +static ssize_t sp_max_temperature_l_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + ssize_t ret = 0; + + ret = snprintf(buf, BUF_SZ, "%d\n", + this_afe_spk.xt_logging.max_temperature[SP_V2_SPKR_1]/Q22); + this_afe_spk.xt_logging.max_temperature[SP_V2_SPKR_1] = 0; + return ret; +} +static DEVICE_ATTR(max_temperature, 0644, sp_max_temperature_l_show, NULL); + +static ssize_t sp_max_temperature_r_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + ssize_t ret = 0; + + ret = snprintf(buf, BUF_SZ, "%d\n", + this_afe_spk.xt_logging.max_temperature[SP_V2_SPKR_2]/Q22); + this_afe_spk.xt_logging.max_temperature[SP_V2_SPKR_2] = 0; + return ret; +} +static DEVICE_ATTR(max_temperature_r, 0644, sp_max_temperature_r_show, NULL); + +static ssize_t sp_max_temperature_rd_l_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return snprintf(buf, BUF_SZ, "%d\n", + this_afe_spk.max_temperature_rd[SP_V2_SPKR_1]/Q22); +} +static DEVICE_ATTR(max_temperature_rd, 0644, + sp_max_temperature_rd_l_show, NULL); + +static ssize_t sp_max_temperature_rd_r_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return snprintf(buf, BUF_SZ, "%d\n", + this_afe_spk.max_temperature_rd[SP_V2_SPKR_2]/Q22); +} +static DEVICE_ATTR(max_temperature_rd_r, 0644, + sp_max_temperature_rd_r_show, NULL); + +static ssize_t q6afe_initial_cal_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return snprintf(buf, BUF_SZ, "%d\n", afe_get_spk_initial_cal()); +} + +static ssize_t q6afe_initial_cal_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + int initial_cal = 0; + + if (!kstrtou32(buf, 0, &initial_cal)) { + initial_cal = initial_cal > 0 ? 1 : 0; + if (initial_cal == afe_get_spk_initial_cal()) + dev_dbg(dev, "%s: same value already present\n", + __func__); + else + afe_set_spk_initial_cal(initial_cal); + } + return size; +} + +static DEVICE_ATTR(initial_cal, 0644, + q6afe_initial_cal_show, q6afe_initial_cal_store); + +static ssize_t q6afe_v_vali_flag_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return snprintf(buf, BUF_SZ, "%d\n", afe_get_spk_v_vali_flag()); +} + +static ssize_t q6afe_v_vali_flag_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + int v_vali_flag = 0; + + if (!kstrtou32(buf, 0, &v_vali_flag)) { + v_vali_flag = v_vali_flag > 0 ? 1 : 0; + if (v_vali_flag == afe_get_spk_v_vali_flag()) + dev_dbg(dev, "%s: same value already present\n", + __func__); + else + afe_set_spk_v_vali_flag(v_vali_flag); + } + return size; +} + +static DEVICE_ATTR(v_vali_flag, 0644, + q6afe_v_vali_flag_show, q6afe_v_vali_flag_store); + +static ssize_t q6afe_spk_r0_l_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int r0[SP_V2_NUM_MAX_SPKRS]; + + afe_get_spk_r0(r0); + return snprintf(buf, BUF_SZ, "%d\n", r0[SP_V2_SPKR_1]); +} + +static DEVICE_ATTR(spk_r0, 0644, q6afe_spk_r0_l_show, NULL); + +static ssize_t q6afe_spk_t0_l_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int t0[SP_V2_NUM_MAX_SPKRS]; + + afe_get_spk_t0(t0); + return snprintf(buf, BUF_SZ, "%d\n", t0[SP_V2_SPKR_1]); +} + +static DEVICE_ATTR(spk_t0, 0644, q6afe_spk_t0_l_show, NULL); + +static ssize_t q6afe_spk_r0_r_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int r0[SP_V2_NUM_MAX_SPKRS]; + + afe_get_spk_r0(r0); + return snprintf(buf, BUF_SZ, "%d\n", r0[SP_V2_SPKR_2]); +} + +static DEVICE_ATTR(spk_r0_r, 0644, q6afe_spk_r0_r_show, NULL); + +static ssize_t q6afe_spk_t0_r_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int t0[SP_V2_NUM_MAX_SPKRS]; + + afe_get_spk_t0(t0); + return snprintf(buf, BUF_SZ, "%d\n", t0[SP_V2_SPKR_2]); +} + +static DEVICE_ATTR(spk_t0_r, 0644, q6afe_spk_t0_r_show, NULL); + +static ssize_t q6afe_spk_v_vali_l_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int v_vali_sts[SP_V2_NUM_MAX_SPKRS]; + + afe_get_spk_v_vali_sts(v_vali_sts); + return snprintf(buf, BUF_SZ, "%d\n", v_vali_sts[SP_V2_SPKR_1]); +} + +static DEVICE_ATTR(spk_v_vali_status, 0644, q6afe_spk_v_vali_l_show, NULL); + +static ssize_t q6afe_spk_v_vali_r_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int v_vali_sts[SP_V2_NUM_MAX_SPKRS]; + + afe_get_spk_v_vali_sts(v_vali_sts); + return snprintf(buf, BUF_SZ, "%d\n", v_vali_sts[SP_V2_SPKR_2]); +} + +static DEVICE_ATTR(spk_v_vali_r_status, 0644, q6afe_spk_v_vali_r_show, NULL); + +static struct attribute *afe_spk_cal_attr[] = { + &dev_attr_max_excursion.attr, + &dev_attr_max_excursion_r.attr, + &dev_attr_max_temperature.attr, + &dev_attr_max_temperature_r.attr, + &dev_attr_count_exceeded_excursion.attr, + &dev_attr_count_exceeded_excursion_r.attr, + &dev_attr_count_exceeded_temperature.attr, + &dev_attr_count_exceeded_temperature_r.attr, + &dev_attr_max_temperature_rd.attr, + &dev_attr_max_temperature_rd_r.attr, + &dev_attr_initial_cal.attr, + &dev_attr_spk_r0.attr, + &dev_attr_spk_t0.attr, + &dev_attr_spk_r0_r.attr, + &dev_attr_spk_t0_r.attr, + &dev_attr_v_vali_flag.attr, + &dev_attr_spk_v_vali_status.attr, + &dev_attr_spk_v_vali_r_status.attr, + NULL, +}; + +static struct attribute_group afe_spk_cal_attr_grp = { + .attrs = afe_spk_cal_attr, +}; + + +/** + * afe_get_sp_xt_logging_data - + * to get excursion logging data from DSP + * + * @port: AFE port ID + * + * Returns 0 on success or error on failure + */ +int afe_get_sp_xt_logging_data(u16 port_id) +{ + int ret = 0; + struct afe_sp_rx_tmax_xmax_logging_param xt_logging_data; + + ret = afe_get_sp_rx_tmax_xmax_logging_data(&xt_logging_data, port_id); + if (ret) { + pr_err("%s Excursion logging fail\n", __func__); + return ret; + } + /* storing max sp param value */ + if (this_afe_spk.xt_logging.max_temperature[SP_V2_SPKR_1] < + xt_logging_data.max_temperature[SP_V2_SPKR_1]) + this_afe_spk.xt_logging.max_temperature[SP_V2_SPKR_1] = + xt_logging_data.max_temperature[SP_V2_SPKR_1]; + + + if (this_afe_spk.xt_logging.max_temperature[SP_V2_SPKR_2] < + xt_logging_data.max_temperature[SP_V2_SPKR_2]) + this_afe_spk.xt_logging.max_temperature[SP_V2_SPKR_2] = + xt_logging_data.max_temperature[SP_V2_SPKR_2]; + + + /* update temp for max_temperature_rd node */ + if (this_afe_spk.max_temperature_rd[SP_V2_SPKR_1] < + xt_logging_data.max_temperature[SP_V2_SPKR_1]) + this_afe_spk.max_temperature_rd[SP_V2_SPKR_1] = + xt_logging_data.max_temperature[SP_V2_SPKR_1]; + + if (this_afe_spk.max_temperature_rd[SP_V2_SPKR_2] < + xt_logging_data.max_temperature[SP_V2_SPKR_2]) + this_afe_spk.max_temperature_rd[SP_V2_SPKR_2] = + xt_logging_data.max_temperature[SP_V2_SPKR_2]; + + + if (this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_1] < + xt_logging_data.max_excursion[SP_V2_SPKR_1]) + this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_1] = + xt_logging_data.max_excursion[SP_V2_SPKR_1]; + + if (this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_2] < + xt_logging_data.max_excursion[SP_V2_SPKR_2]) + this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_2] = + xt_logging_data.max_excursion[SP_V2_SPKR_2]; + + if (this_afe_spk.xt_logging.count_exceeded_temperature[SP_V2_SPKR_1] < + xt_logging_data.count_exceeded_temperature[SP_V2_SPKR_1]) + this_afe_spk.xt_logging.count_exceeded_temperature[SP_V2_SPKR_1] + += xt_logging_data.count_exceeded_temperature[SP_V2_SPKR_1]; + + if (this_afe_spk.xt_logging.count_exceeded_temperature[SP_V2_SPKR_2] < + xt_logging_data.count_exceeded_temperature[SP_V2_SPKR_2]) + this_afe_spk.xt_logging.count_exceeded_temperature[SP_V2_SPKR_2] + += xt_logging_data.count_exceeded_temperature[SP_V2_SPKR_2]; + + if (this_afe_spk.xt_logging.count_exceeded_excursion[SP_V2_SPKR_1] < + xt_logging_data.count_exceeded_excursion[SP_V2_SPKR_1]) + this_afe_spk.xt_logging.count_exceeded_excursion[SP_V2_SPKR_1] + += xt_logging_data.count_exceeded_excursion[SP_V2_SPKR_1]; + + if (this_afe_spk.xt_logging.count_exceeded_excursion[SP_V2_SPKR_2] < + xt_logging_data.count_exceeded_excursion[SP_V2_SPKR_2]) + this_afe_spk.xt_logging.count_exceeded_excursion[SP_V2_SPKR_2] + += xt_logging_data.count_exceeded_excursion[SP_V2_SPKR_2]; + + return ret; +} +EXPORT_SYMBOL(afe_get_sp_xt_logging_data); + +int __init spk_params_init(void) +{ + /* initialize xt param value with 0 */ + this_afe_spk.xt_logging.max_temperature[SP_V2_SPKR_1] = 0; + this_afe_spk.xt_logging.max_temperature[SP_V2_SPKR_2] = 0; + this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_1] = 0; + this_afe_spk.xt_logging.max_excursion[SP_V2_SPKR_2] = 0; + this_afe_spk.xt_logging.count_exceeded_temperature[SP_V2_SPKR_1] = 0; + this_afe_spk.xt_logging.count_exceeded_temperature[SP_V2_SPKR_2] = 0; + this_afe_spk.xt_logging.count_exceeded_excursion[SP_V2_SPKR_1] = 0; + this_afe_spk.xt_logging.count_exceeded_excursion[SP_V2_SPKR_2] = 0; + + this_afe_spk.p_class = class_create(THIS_MODULE, SPK_PARAMS); + if (this_afe_spk.p_class) { + this_afe_spk.p_dev = device_create(this_afe_spk.p_class, NULL, + 1, NULL, CLASS_NAME); + if (!IS_ERR(this_afe_spk.p_dev)) { + if (sysfs_create_group(&this_afe_spk.p_dev->kobj, + &afe_spk_cal_attr_grp)) + pr_err("%s: Failed to create sysfs group\n", + __func__); + } + } + return 0; +} + +void spk_params_exit(void) +{ + pr_debug("%s\n", __func__); +} diff --git a/include/dsp/q6afe-v2.h b/include/dsp/q6afe-v2.h index 2319415917f2..c5b7e3e65292 100644 --- a/include/dsp/q6afe-v2.h +++ b/include/dsp/q6afe-v2.h @@ -494,4 +494,11 @@ struct afe_cmd_remote_lpass_core_hw_devote_request { int afe_vote_lpass_core_hw(uint32_t hw_block_id, char *client_name, uint32_t *client_handle); int afe_unvote_lpass_core_hw(uint32_t hw_block_id, uint32_t client_handle); +int afe_get_spk_initial_cal(void); +void afe_get_spk_r0(int *spk_r0); +void afe_get_spk_t0(int *spk_t0); +int afe_get_spk_v_vali_flag(void); +void afe_get_spk_v_vali_sts(int *spk_v_vali_sts); +void afe_set_spk_initial_cal(int initial_cal); +void afe_set_spk_v_vali_flag(int v_vali_flag); #endif /* __Q6AFE_V2_H__ */ diff --git a/include/dsp/sp_params.h b/include/dsp/sp_params.h new file mode 100644 index 000000000000..ddc756ee8c9d --- /dev/null +++ b/include/dsp/sp_params.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + */ + +#ifndef __SP_PARAMS_H__ +#define __SP_PARAMS_H__ + +#if IS_ENABLED(CONFIG_XT_LOGGING) +int afe_get_sp_xt_logging_data(u16 port_id); +#else +static inline int afe_get_sp_xt_logging_data(u16 port_id) +{ + return 0; +} +#endif + +#endif /* __SP_PARAMS_H__ */ +