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

Commit d7e8205d authored by Linux Build Service Account's avatar Linux Build Service Account
Browse files

Merge 1c3c1cf2 on remote branch

Change-Id: Ibf557c142ecdc10ad2ef684d77743a3a765cbc66
parents f8b4b87d 1c3c1cf2
Loading
Loading
Loading
Loading
+99 −0
Original line number Diff line number Diff line
@@ -394,6 +394,12 @@ static const struct soc_enum tdm_config_enum[] = {
	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(tdm_header_type), tdm_header_type),
};

static u16 afe_port_logging_port_id;

static bool afe_port_logging_item[IDX_TDM_MAX];

static int afe_port_loggging_control_added;

static DEFINE_MUTEX(tdm_mutex);

static atomic_t tdm_group_ref[IDX_GROUP_TDM_MAX];
@@ -9272,6 +9278,87 @@ static int msm_dai_q6_tdm_set_clk(
	return rc;
}

static int msm_pcm_afe_port_logging_info(struct snd_kcontrol *kcontrol,
	struct snd_ctl_elem_info* ucontrol)
{
	ucontrol->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
	/* two int values: port_id and enable/disable */
	ucontrol->count = 2;
	/* Valid range is all positive values to support above controls */
	ucontrol->value.integer.min = 0;
	ucontrol->value.integer.max = INT_MAX;
	return 0;
}

static int msm_pcm_afe_port_logging_ctl_get(struct snd_kcontrol *kcontrol,
	struct snd_ctl_elem_value *ucontrol)
{
	int port_idx = afe_port_logging_port_id - AFE_PORT_ID_TDM_PORT_RANGE_START;

	ucontrol->value.integer.value[0] = afe_port_logging_port_id;
	ucontrol->value.integer.value[1] = afe_port_logging_item[port_idx];

	return 0;
}

static int msm_pcm_afe_port_logging_ctl_put(struct snd_kcontrol *kcontrol,
	struct snd_ctl_elem_value *ucontrol)
{
	u16 port_id;
	struct afe_param_id_port_data_log_disable_t log_disable;
	struct param_hdr_v3 param_hdr;
	int ret = -EINVAL, port_idx;

	pr_debug("%s: enter\n", __func__);
	memset(&param_hdr, 0, sizeof(param_hdr));

	port_id = ucontrol->value.integer.value[0];
	log_disable.disable_logging_flag = ucontrol->value.integer.value[1];

	ret = afe_port_send_logging_cfg(port_id, &log_disable);
	if (ret)
		pr_err("%s: AFE port logging setting for port 0x%x failed %d\n",
			__func__, port_id, ret);

	afe_port_logging_port_id = port_id;
	port_idx = port_id - AFE_PORT_ID_TDM_PORT_RANGE_START;
	afe_port_logging_item[port_idx] = ucontrol->value.integer.value[1];

	return ret;
}

static int msm_pcm_add_afe_port_logging_control(struct snd_soc_dai *dai)
{
	const char* afe_port_logging_ctl_name = "AFE_port_logging_disable";
	int rc = 0;
	struct snd_kcontrol_new *knew = NULL;
	struct snd_kcontrol* kctl = NULL;

	/* Add AFE port logging controls */
	knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL);
	if (!knew) {
		return -ENOMEM;
	}
	knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
	knew->info = msm_pcm_afe_port_logging_info;
	knew->get = msm_pcm_afe_port_logging_ctl_get;
	knew->put = msm_pcm_afe_port_logging_ctl_put;
	knew->name = afe_port_logging_ctl_name;
	knew->private_value = dai->id;
	kctl = snd_ctl_new1(knew, knew);
	if (!kctl) {
		kfree(knew);
		return -ENOMEM;
	}

	rc = snd_ctl_add(dai->component->card->snd_card, kctl);
	if (rc < 0)
		pr_err("%s: err add AFE port logging disable control, DAI = %s\n",
			__func__, dai->name);

	return rc;
}

static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
{
	int rc = 0;
@@ -9348,6 +9435,18 @@ static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai)
		}
	}

	/* add AFE port logging controls */
	if (!afe_port_loggging_control_added) {
		rc = msm_pcm_add_afe_port_logging_control(dai);
		if (rc < 0) {
			dev_err(dai->dev, "%s: add AFE port logging control failed DAI: %s\n",
				__func__, dai->name);
			goto rtn;
		}

		afe_port_loggging_control_added = 1;
	}

	if (tdm_dai_data->is_island_dai)
		rc = msm_dai_q6_add_island_mx_ctls(
						dai->component->card->snd_card,
+1 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
 */

#include <linux/init.h>
@@ -44,8 +44,6 @@
#define APP_TYPE_CONFIG_IDX_SAMPLE_RATE 2
#define APP_TYPE_CONFIG_IDX_BE_ID 3

static DEFINE_MUTEX(transcode_loopback_session_lock);

struct msm_transcode_audio_effects {
	struct bass_boost_params bass_boost;
	struct pbe_params pbe;
+19 −21
Original line number Diff line number Diff line
@@ -2314,7 +2314,7 @@ static void send_adm_cal_type(int cal_index, int path, int port_id,
			      int acdb_id, int sample_rate)
{
	struct cal_block_data		*cal_block = NULL;
	int ret, port_idx, topology;
	int ret;
	int dest_perms[2] = {PERM_READ | PERM_WRITE, PERM_READ | PERM_WRITE};
	int source_vm[1] = {VMID_HLOS};
	int dest_vm[2] = {VMID_LPASS, VMID_ADSP_HEAP};
@@ -2327,21 +2327,13 @@ static void send_adm_cal_type(int cal_index, int path, int port_id,
		goto done;
	}

	port_idx = adm_validate_and_get_port_index(port_id);
	if (port_idx < 0) {
		pr_err("%s: Invalid port id: 0x%x", __func__, port_id);
		goto done;
	}

	mutex_lock(&this_adm.cal_data[cal_index]->lock);
	cal_block = adm_find_cal(cal_index, path, app_type, acdb_id,
				sample_rate);
	if (cal_block == NULL)
		goto unlock;

	topology = atomic_read(&this_adm.copp.topology[port_idx][copp_idx]);
	if (cal_block->cma_mem &&
	    topology == VPM_TX_VOICE_FLUENCE_NN_COPP_TOPOLOGY) {
	if (cal_block->cma_mem) {
		if (cal_block->cal_data.paddr == 0 ||
		    cal_block->map_data.map_size <= 0) {
			pr_err("%s: No address to map!\n", __func__);
@@ -3130,7 +3122,8 @@ int adm_open(int port_id, int path, int rate, int channel_mode, int topology,
	}

	if ((topology == VPM_TX_SM_ECNS_V2_COPP_TOPOLOGY) ||
	    (topology == VPM_TX_DM_FLUENCE_EF_COPP_TOPOLOGY)) {
	    (topology == VPM_TX_DM_FLUENCE_EF_COPP_TOPOLOGY) ||
	    (topology == VPM_TX_VOICE_FLUENCE_NN_COPP_TOPOLOGY)) {
		if ((rate != ADM_CMD_COPP_OPEN_SAMPLE_RATE_8K) &&
		    (rate != ADM_CMD_COPP_OPEN_SAMPLE_RATE_16K) &&
		    (rate != ADM_CMD_COPP_OPEN_SAMPLE_RATE_32K) &&
@@ -3887,13 +3880,14 @@ int adm_close(int port_id, int perf_mode, int copp_idx)
{
	struct apr_hdr close;

	int ret = 0, port_idx, app_type, topology;
	int ret = 0, port_idx, app_type;
	int copp_id = RESET_COPP_ID;
	bool result = false;
	int dest_perms[1] = {PERM_READ | PERM_WRITE | PERM_EXEC};
	int source_vm[2] = {VMID_LPASS, VMID_ADSP_HEAP};
	int dest_vm[1] = {VMID_HLOS};
	struct cal_block_data *cal_block = NULL;
	struct audio_cal_info_audproc *audproc_cal_info = NULL;
	int cal_index = ADM_AUDPROC_PERSISTENT_CAL;

	pr_debug("%s: port_id=0x%x perf_mode: %d copp_idx: %d\n", __func__,
@@ -3913,7 +3907,6 @@ int adm_close(int port_id, int perf_mode, int copp_idx)
	}

	port_channel_map[port_idx].set_channel_map = false;
	topology = atomic_read(&this_adm.copp.topology[port_idx][copp_idx]);
	app_type = atomic_read(&this_adm.copp.app_type[port_idx][copp_idx]);
	if (this_adm.copp.adm_delay[port_idx][copp_idx] && perf_mode
		== LEGACY_PCM_MODE) {
@@ -3996,9 +3989,7 @@ int adm_close(int port_id, int perf_mode, int copp_idx)
		ret = apr_send_pkt(this_adm.apr, (uint32_t *)&close);
		if (ret < 0) {
			pr_err("%s: ADM close failed %d\n", __func__, ret);
			if (this_adm.tx_port_id == port_id &&
			    this_adm.fnn_app_type == app_type &&
			    topology == VPM_TX_VOICE_FLUENCE_NN_COPP_TOPOLOGY) {
			if (this_adm.tx_port_id == port_id) {
				mutex_lock(&this_adm.cal_data[cal_index]->lock);
				cal_block = cal_utils_get_only_cal_block(
						this_adm.cal_data[cal_index]);
@@ -4007,7 +3998,12 @@ int adm_close(int port_id, int perf_mode, int copp_idx)
					pr_debug("%s: cma_alloc %d\n",
						 __func__, cal_block->cma_mem);
				}
				if (result) {
				if (app_type == 0) {
					audproc_cal_info = cal_block->cal_info;
					app_type = audproc_cal_info->app_type;
				}

				if (result && this_adm.fnn_app_type == app_type) {
					pr_debug("%s: use hyp assigned %d, use buffer %d\n",
						 __func__, this_adm.hyp_assigned,
						cal_block->buffer_number);
@@ -4083,9 +4079,7 @@ int adm_close(int port_id, int perf_mode, int copp_idx)
		rtac_remove_adm_device(port_id, copp_id);
	}

	if (this_adm.tx_port_id == port_id &&
	    this_adm.fnn_app_type == app_type &&
	    topology == VPM_TX_VOICE_FLUENCE_NN_COPP_TOPOLOGY) {
	if (this_adm.tx_port_id == port_id) {
		mutex_lock(&this_adm.cal_data[cal_index]->lock);
		cal_block = cal_utils_get_only_cal_block(
				this_adm.cal_data[cal_index]);
@@ -4094,8 +4088,12 @@ int adm_close(int port_id, int perf_mode, int copp_idx)
			pr_debug("%s: cma_alloc %d\n",
				 __func__, cal_block->cma_mem);
		}
		if (app_type == 0) {
			audproc_cal_info = cal_block->cal_info;
			app_type = audproc_cal_info->app_type;
		}

		if (result) {
		if (result && this_adm.fnn_app_type == app_type) {
			pr_debug("%s: use hyp assigned %d, use buffer %d\n",
				  __func__, this_adm.hyp_assigned,
				  cal_block->buffer_number);
+34 −0
Original line number Diff line number Diff line
@@ -4800,6 +4800,40 @@ void afe_set_routing_callback(routing_cb cb)
}
EXPORT_SYMBOL(afe_set_routing_callback);

/**
 * afe_port_send_logging_cfg -
 *         set AFE port logging status
 *
 * @port_id: AFE port id number
 * @log_disable: logging payload
 *
 * Returns 0 on success or error value on set param failure
 */
int afe_port_send_logging_cfg(u16 port_id,
	struct afe_param_id_port_data_log_disable_t *log_disable)
{
	struct param_hdr_v3 param_hdr;
	int ret = -EINVAL;

	pr_debug("%s: enter, port: 0x%x logging flag: %x\n", __func__, port_id,
		log_disable->disable_logging_flag);
	memset(&param_hdr, 0, sizeof(param_hdr));

	param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
	param_hdr.instance_id = INSTANCE_ID_0;
	param_hdr.param_id = AFE_PARAM_ID_PORT_DATA_LOGGING_DISABLE;
	param_hdr.param_size = sizeof(&log_disable);

	ret = q6afe_pack_and_set_param_in_band(port_id,
		q6audio_get_port_index(port_id), param_hdr, (u8*)log_disable);
	if (ret)
		pr_err("%s: AFE port logging setting for port 0x%x failed %d\n",
			__func__, port_id, ret);

	return ret;
}
EXPORT_SYMBOL(afe_port_send_logging_cfg);

int afe_port_send_usb_dev_param(u16 port_id, union afe_port_config *afe_config)
{
	struct afe_param_id_usb_audio_dev_params usb_dev;
+40 −0
Original line number Diff line number Diff line
@@ -13414,4 +13414,44 @@ struct afe_param_id_tdm_lane_cfg {
	 */
};

/** ID of the parameter used to set the AFE port data logging to enable or disable state.
 * For non-group device use cases, #AFE_MODULE_AUDIO_DEV_INTERFACE uses this
 * parameter to configure the flag used for data logging in afe_data_logging_t
 * of the respective port to enabled or disabled state.
 * The HLOS client can use this parameter to configure the data logging
 * disable flag for it's respective port.
 * The reason for this parameter addition is if a number of ports are
 * configured and running, Upon enabling logging through 0x1586 tap point,
 * we will get input/output logs for all the enabled ports.
 * In order to disabled logging for a specific port for which data logging
 * is not needed, the HLOS client can make use of AFE_PORT_DATA_LOGGING_DISABLE flag.
 * This flag will set to AFE_PORT_DATA_LOGGING_ENABLE during port initialization and also
 * during port stop. If port is restarted, the set param should be called again
 * by the HLOS client if needed to disable data logging.
 * @par
 * If HLOS client doesn't set this paramter, by default the disable flag = AFE_PORT_DATA_LOGGING_ENABLE.
 * If HLOS client sets the flag = AFE_PORT_DATA_LOGGING_DISABLE, the respective port will be disabled for data logging.
 */
#define AFE_PARAM_ID_PORT_DATA_LOGGING_DISABLE            0x000102E9

 /** Enable flag for port data logging. */
#define AFE_PORT_DATA_LOGGING_ENABLE    0

/** Disable flag for port data logging. */
#define AFE_PORT_DATA_LOGGING_DISABLE   1

/*
 * Payload of the AFE_PARAM_ID_PORT_DATA_LOGGING_DISABLE parameter used by
 * AFE_MODULE_AUDIO_DEV_INTERFACE
 */
struct afe_param_id_port_data_log_disable_t
{
	uint32_t           disable_logging_flag;
	/** Flag for enabling or disabling data logging.
	 * @values
	 * - AFE_PORT_DATA_LOGGING_ENABLE  - enable data logging.
	 * - AFE_PORT_DATA_LOGGING_DISABLE - disable data logging.
	 */
} __packed;

#endif /*_APR_AUDIO_V2_H_ */
Loading