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

Commit da550a99 authored by Banajit Goswami's avatar Banajit Goswami
Browse files

ASoC: msm: q6dspv2: add mixer control to avoid sending DSP calibration



For some use cases like Ultrasound, AFE calibration is not needed
to be sent to DSP. Add a mixer control to set a flag in AFE native
driver for that particular Slimbus port to help avoid sending AFE
calibration data to DSP for those specific use cases. AFE driver
would check for the flag before sending calibration data to DSP.

Change-Id: Idc254224a9b73995f363668e644b2c08f86817e9
Signed-off-by: default avatarBanajit Goswami <bgoswami@codeaurora.org>
parent dec3acb0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -102,6 +102,11 @@ enum afe_mad_type {
	MAD_SW_AUDIO = 0x05,
};

enum afe_cal_mode {
	AFE_CAL_MODE_DEFAULT = 0x00,
	AFE_CAL_MODE_NONE,
};

struct afe_audio_buffer {
	dma_addr_t phys;
	void       *data;
@@ -175,6 +180,7 @@ int afe_rt_proxy_port_write(phys_addr_t buf_addr_p,
			u32 mem_map_handle, int bytes);
int afe_rt_proxy_port_read(phys_addr_t buf_addr_p,
			u32 mem_map_handle, int bytes);
void afe_set_cal_mode(u16 port_id, enum afe_cal_mode afe_cal_mode);
int afe_port_start(u16 port_id, union afe_port_config *afe_config,
	u32 rate);
int afe_spk_prot_feed_back_cfg(int src_port, int dst_port,
+44 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ struct msm_dai_q6_dai_data {
	u32 rate;
	u32 channels;
	u32 bitwidth;
	u32 cal_mode;
	union afe_port_config port_config;
};

@@ -1428,6 +1429,30 @@ static inline void msm_dai_q6_set_dai_id(struct snd_soc_dai *dai)
	return;
}

static int msm_dai_q6_sb_cal_info_put(struct snd_kcontrol *kcontrol,
				    struct snd_ctl_elem_value *ucontrol)
{
	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;
	u16 port_id = ((struct soc_enum *)
					kcontrol->private_value)->reg;

	dai_data->cal_mode = ucontrol->value.integer.value[0];
	pr_debug("%s: setting cal_mode to %d\n",
		__func__, dai_data->cal_mode);
	afe_set_cal_mode(port_id, dai_data->cal_mode);

	return 0;
}

static int msm_dai_q6_sb_cal_info_get(struct snd_kcontrol *kcontrol,
				    struct snd_ctl_elem_value *ucontrol)
{
	struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data;

	ucontrol->value.integer.value[0] = dai_data->cal_mode;
	return 0;
}

static int msm_dai_q6_sb_format_put(struct snd_kcontrol *kcontrol,
				    struct snd_ctl_elem_value *ucontrol)
{
@@ -1454,10 +1479,21 @@ static int msm_dai_q6_sb_format_get(struct snd_kcontrol *kcontrol,
	return 0;
}

static const char * const slim_2_rx_text[] = {
	"CAL_MODE_DEFAULT", "CAL_MODE_NONE"
};

static const struct soc_enum slim_2_rx_enum =
	SOC_ENUM_SINGLE(SLIMBUS_2_RX, 0, ARRAY_SIZE(slim_2_rx_text),
			slim_2_rx_text);

static const struct snd_kcontrol_new sb_config_controls[] = {
	SOC_ENUM_EXT("SLIM_4_TX Format", sb_config_enum[0],
		     msm_dai_q6_sb_format_get,
		     msm_dai_q6_sb_format_put),
	SOC_ENUM_EXT("SLIM_2_RX SetCalMode", slim_2_rx_enum,
		     msm_dai_q6_sb_cal_info_get,
		     msm_dai_q6_sb_cal_info_put)
};

static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
@@ -1494,6 +1530,14 @@ static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai)
				__func__, dai->name);
		}
	}
	if (dai->id == SLIMBUS_2_RX) {
		rc = snd_ctl_add(dai->card->snd_card,
				  snd_ctl_new1(&sb_config_controls[1],
				  dai_data));
		if (IS_ERR_VALUE(rc))
			dev_err(dai->dev, "%s: err add RX Cal ctl, DAI = %s\n",
				__func__, dai->name);
	}
	rc = msm_dai_q6_dai_add_route(dai);
	return rc;
}
+19 −5
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ struct afe_ctl {

	atomic_t mem_map_cal_handles[MAX_AFE_CAL_TYPES];
	atomic_t mem_map_cal_index;
	u32 afe_cal_mode[AFE_MAX_PORTS];

	u16 dtmf_gen_rx_portid;
	struct audio_cal_info_spk_prot_cfg	prot_cfg;
@@ -1967,6 +1968,14 @@ fail_cmd:
	return ret;
}

void afe_set_cal_mode(u16 port_id, enum afe_cal_mode afe_cal_mode)
{
	uint16_t port_index;

	port_index = afe_get_port_index(port_id);
	this_afe.afe_cal_mode[port_index] = afe_cal_mode;
}

int afe_port_start(u16 port_id, union afe_port_config *afe_config,
	u32 rate) /* This function is no blocking */
{
@@ -2026,10 +2035,14 @@ int afe_port_start(u16 port_id, union afe_port_config *afe_config,

	mutex_lock(&this_afe.afe_cmd_lock);
	/* Also send the topology id here: */
	afe_send_custom_topology(); /* One time call: only for first time */
	port_index = afe_get_port_index(port_id);
	if (!(this_afe.afe_cal_mode[port_index] == AFE_CAL_MODE_NONE)) {
		/* One time call: only for first time */
		afe_send_custom_topology();
		afe_send_port_topology_id(port_id);

		afe_send_cal(port_id);
	}
	afe_send_hw_delay(port_id, rate);

	/* Start SW MAD module */
@@ -4995,9 +5008,10 @@ static int __init afe_init(void)
	this_afe.vi_rx_port = -1;
	this_afe.prot_cfg.mode = MSM_SPKR_PROT_DISABLED;
	mutex_init(&this_afe.afe_cmd_lock);
	for (i = 0; i < AFE_MAX_PORTS; i++)
	for (i = 0; i < AFE_MAX_PORTS; i++) {
		this_afe.afe_cal_mode[i] = AFE_CAL_MODE_DEFAULT;
		init_waitqueue_head(&this_afe.wait[i]);

	}
	wakeup_source_init(&wl.ws, "spkr-prot");
	ret = afe_init_cal_data();
	if (ret)