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

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

Merge "dsp: q6afe: Add support to control AANC noise level"

parents ef28a470 af431ad7
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
@@ -899,6 +899,61 @@ static int q6afe_pack_and_set_param_in_band(u16 port_id, int index,
	return ret;
}

static int q6afe_set_aanc_level(void)
{
	struct param_hdr_v3 param_hdr;
	struct afe_param_id_aanc_noise_reduction aanc_noise_level;
	int ret = 0;
	uint16_t tx_port = 0;

	if (!this_afe.aanc_info.aanc_active)
		return -EINVAL;

	pr_debug("%s: level: %d\n", __func__, this_afe.aanc_info.level);
	memset(&aanc_noise_level, 0, sizeof(aanc_noise_level));
	aanc_noise_level.minor_version = 1;
	aanc_noise_level.ad_beta = this_afe.aanc_info.level;

	memset(&param_hdr, 0, sizeof(param_hdr));
	param_hdr.module_id = AFE_MODULE_AANC;
	param_hdr.instance_id = INSTANCE_ID_0;
	param_hdr.param_id = AFE_PARAM_ID_AANC_NOISE_REDUCTION;
	param_hdr.param_size = sizeof(struct afe_param_id_aanc_noise_reduction);

	tx_port = this_afe.aanc_info.aanc_tx_port;
	ret = q6afe_pack_and_set_param_in_band(tx_port,
					       q6audio_get_port_index(tx_port),
					       param_hdr,
					       (u8 *) &aanc_noise_level);
	if (ret)
		pr_err("%s: AANC noise level enable failed for tx_port 0x%x ret %d\n",
			__func__, tx_port, ret);
	return ret;
}

/**
 * afe_set_aanc_noise_level - controls aanc noise reduction strength
 *
 * @level: Noise level to be controlled
 *
 * Returns 0 on success or error on failure.
 */
int afe_set_aanc_noise_level(int level)
{
	int ret = 0;

	if (this_afe.aanc_info.level == level)
		return ret;

	mutex_lock(&this_afe.afe_cmd_lock);
	this_afe.aanc_info.level = level;
	ret = q6afe_set_aanc_level();
	mutex_unlock(&this_afe.afe_cmd_lock);

	return ret;
}
EXPORT_SYMBOL(afe_set_aanc_noise_level);

/* This function shouldn't be called directly. Instead call q6afe_get_param. */
static int q6afe_get_params_v2(u16 port_id, int index,
			       struct mem_mapping_hdr *mem_hdr,
@@ -2336,6 +2391,8 @@ static int afe_aanc_port_cfg(void *apr, uint16_t tx_port, uint16_t rx_port)
	if (ret)
		pr_err("%s: AFE AANC port config failed for tx_port 0x%x, rx_port 0x%x ret %d\n",
		       __func__, tx_port, rx_port, ret);
	else
		q6afe_set_aanc_level();

	return ret;
}
+11 −0
Original line number Diff line number Diff line
@@ -10053,6 +10053,17 @@ struct afe_param_id_cdc_aanc_version {
	uint32_t aanc_hw_version;
} __packed;

#define AFE_PARAM_ID_AANC_NOISE_REDUCTION    0x000102AB
struct afe_param_id_aanc_noise_reduction {
	/* Minor version used for tracking the version of the module's
	 * hw version
	 */
	uint32_t minor_version;

	/* Target noise level */
	int32_t ad_beta;
} __packed;

struct afe_param_id_clip_bank_sel {
	/* Minor version used for tracking the version of the module's
	 * hw version
+2 −0
Original line number Diff line number Diff line
@@ -303,6 +303,7 @@ struct aanc_data {
	uint16_t aanc_tx_port;
	uint32_t aanc_rx_port_sample_rate;
	uint32_t aanc_tx_port_sample_rate;
	int level;
};

int afe_open(u16 port_id, union afe_port_config *afe_config, int rate);
@@ -397,6 +398,7 @@ void afe_clear_config(enum afe_config_type config);
bool afe_has_config(enum afe_config_type config);

void afe_set_aanc_info(struct aanc_data *aanc_info);
int afe_set_aanc_noise_level(int val);
int afe_port_group_set_param(u16 group_id,
	union afe_port_group_config *afe_group_config);
int afe_port_group_enable(u16 group_id,