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

Commit 37b51a17 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "dsp: get excursion logging at afe close for wsa and log data"

parents ec911669 8944f4b9
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <sound/pcm_params.h>
#include <dsp/apr_audio-v2.h>
#include <dsp/q6afe-v2.h>
#include <dsp/sp_params.h>
#include <dsp/q6core.h>
#include "msm-dai-q6-v2.h"
#include "codecs/core.h"
@@ -10442,6 +10443,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,
@@ -10450,6 +10462,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 = {
@@ -10472,7 +10492,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,
@@ -10524,7 +10544,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,
+4 −0
Original line number Diff line number Diff line
@@ -102,8 +102,12 @@ 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_DTS_SRS_TM
	Q6_OBJS += msm-dts-srs-tm-config.o
endif
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ static int __init audio_q6_init(void)
	rtac_init();
	adm_init();
	afe_init();
	spk_params_init();
	q6asm_init();
	q6lsm_init();
	voice_init();
@@ -46,6 +47,7 @@ static void __exit audio_q6_exit(void)
	q6lsm_exit();
	q6asm_exit();
	afe_exit();
	spk_params_exit();
	adm_exit();
	rtac_exit();
	audio_cal_exit();
+12 −0
Original line number Diff line number Diff line
@@ -40,6 +40,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 audio_slimslave_exit(void);
+111 −3
Original line number Diff line number Diff line
@@ -142,6 +142,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;
	int vi_tx_port;
	int vi_rx_port;
@@ -158,6 +159,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 +183,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;
@@ -338,6 +387,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);
@@ -7497,6 +7551,58 @@ 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]);
	ret = 0;
done:
	return ret;
}
EXPORT_SYMBOL(afe_get_sp_rx_tmax_xmax_logging_data);

/**
 * afe_get_av_dev_drift -
 *       command to retrieve AV drift
@@ -7996,6 +8102,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;
}
@@ -8158,6 +8265,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:
Loading