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

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

Merge "ASoC: msm: add support in DS1 module for custom stereo mixing"

parents 696e400f 61e05177
Loading
Loading
Loading
Loading
+94 −3
Original line number Diff line number Diff line
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
@@ -471,9 +471,10 @@ static int dolby_dap_send_cached_params(int port_id, int commit)
		*update_params_value++ = dolby_dap_params_length[i] *
						sizeof(uint32_t);
		index_offset = dolby_dap_params_offset[i];
		for (j = 0; j < dolby_dap_params_length[i]; j++)
		for (j = 0; j < dolby_dap_params_length[i]; j++) {
			*update_params_value++ =
					dolby_dap_params_value[index_offset+j];
		}
		params_length += (DOLBY_PARAM_PAYLOAD_SIZE +
				dolby_dap_params_length[i]) * sizeof(uint32_t);
	}
@@ -544,6 +545,96 @@ void dolby_dap_deinit(int port_id)
		dolby_dap_params_states.port_id = DOLBY_INVALID_PORT_ID;
}

int dolby_dap_set_vspe_vdhe(int port_id, bool is_custom_stereo_enabled)
{
	char *params_value;
	int *update_params_value, rc = 0;
	uint32_t index_offset, i, j;
	uint32_t params_length = (TOTAL_LENGTH_DOLBY_PARAM +
				2 * DOLBY_PARAM_PAYLOAD_SIZE) *
				sizeof(uint32_t);
	if (port_id == DOLBY_INVALID_PORT_ID)
		return -EINVAL;
	params_value = kzalloc(params_length, GFP_KERNEL);
	if (!params_value) {
		pr_err("%s, params memory alloc failed\n", __func__);
		return -ENOMEM;
	}
	update_params_value = (int *)params_value;
	params_length = 0;
	/* for VDHE and VSPE DAP params at index 0 and 1 in table */
	for (i = 0; i < 2; i++) {
		*update_params_value++ = DOLBY_BUNDLE_MODULE_ID;
		*update_params_value++ = dolby_dap_params_id[i];
		*update_params_value++ = dolby_dap_params_length[i] *
					sizeof(uint32_t);
		index_offset = dolby_dap_params_offset[i];
		for (j = 0; j < dolby_dap_params_length[i]; j++) {
			if (is_custom_stereo_enabled)
				*update_params_value++ = 0;
			else
				*update_params_value++ =
					dolby_dap_params_value[index_offset+j];
		}
		params_length += (DOLBY_PARAM_PAYLOAD_SIZE +
				dolby_dap_params_length[i]) * sizeof(uint32_t);
	}
	pr_debug("%s, valid param length: %d", __func__, params_length);
	if (params_length) {
		rc = adm_dolby_dap_send_params(port_id, params_value,
					params_length);
		if (rc) {
			pr_err("%s: send vdhe/vspe params failed\n", __func__);
			kfree(params_value);
			return -EINVAL;
		}
	}
	kfree(params_value);
	return 0;
}

int dolby_dap_set_custom_stereo_onoff(int port_id,
				      bool is_custom_stereo_enabled)
{
	char *params_value;
	int *update_params_value, rc = 0;
	uint32_t params_length = (TOTAL_LENGTH_DOLBY_PARAM +
				DOLBY_PARAM_PAYLOAD_SIZE) *
				sizeof(uint32_t);
	if (port_id == DOLBY_INVALID_PORT_ID)
		return -EINVAL;

	dolby_dap_set_vspe_vdhe(port_id, is_custom_stereo_enabled);
	params_value = kzalloc(params_length, GFP_KERNEL);
	if (!params_value) {
		pr_err("%s, params memory alloc failed\n", __func__);
		return -ENOMEM;
	}
	update_params_value = (int *)params_value;
	params_length = 0;
	*update_params_value++ = DOLBY_BUNDLE_MODULE_ID;
	*update_params_value++ = DOLBY_ENABLE_CUSTOM_STEREO;
	*update_params_value++ = sizeof(uint32_t);
	if (is_custom_stereo_enabled)
		*update_params_value++ = 1;
	else
		*update_params_value++ = 0;
	params_length += (DOLBY_PARAM_PAYLOAD_SIZE + 1) * sizeof(uint32_t);
	pr_debug("%s, valid param length: %d", __func__, params_length);
	if (params_length) {
		rc = adm_dolby_dap_send_params(port_id, params_value,
					params_length);
		if (rc) {
			pr_err("%s: setting ds1 custom stereo param failed\n",
				__func__);
			kfree(params_value);
			return -EINVAL;
		}
	}
	kfree(params_value);
	return 0;
}

static int map_device_to_port_id(int device)
{
	int port_id = SLIMBUS_0_RX;
+12 −1
Original line number Diff line number Diff line
/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
@@ -80,6 +80,8 @@
#define DOLBY_AUTO_ENDP			0x70000004
#define DOLBY_AUTO_ENDDEP_PARAMS		0x70000005

#define DOLBY_ENABLE_CUSTOM_STEREO	0x000108c7

/* DOLBY DAP offsets start */
#define DOLBY_PARAM_VDHE_LENGTH   1
#define DOLBY_PARAM_VDHE_OFFSET   0
@@ -320,7 +322,12 @@ int msm_routing_get_dolby_dap_endpoint_control(
int msm_routing_put_dolby_dap_endpoint_control(
			struct snd_kcontrol *kcontrol,
			struct snd_ctl_elem_value *ucontrol);

void dolby_dap_deinit(int port_id);

int dolby_dap_set_vspe_vdhe(int port_id, bool is_custom_stereo_enabled);
int dolby_dap_set_custom_stereo_onoff(int port_id,
				      bool is_custom_stereo_enabled);
/* Dolby DOLBY end */
#else
int dolby_dap_init(int port_id, int channels) { return 0; }
@@ -349,6 +356,10 @@ int msm_routing_put_dolby_dap_endpoint_control(
			struct snd_kcontrol *kcontrol,
			struct snd_ctl_elem_value *ucontrol) { return 0; }
void dolby_dap_deinit(int port_id) { return; }
int dolby_dap_set_vspe_vdhe(int port_id,
			    bool is_custom_stereo_enabled) { return 0; }
int dolby_dap_set_custom_stereo_onoff(int port_id,
			bool is_custom_stereo_enabled) { return 0; }
#endif

#endif
+57 −11
Original line number Diff line number Diff line
@@ -303,6 +303,7 @@ static int send_stereo_to_custom_stereo_cmd(int port_id,
	int *update_params_value32, rc = 0;
	int16_t *update_params_value16 = 0;
	uint32_t params_length = CUSTOM_STEREO_PAYLOAD_SIZE * sizeof(uint32_t);
	uint32_t avail_length = params_length;
	pr_debug("%s\n", __func__);
	params_value = kzalloc(params_length, GFP_KERNEL);
	if (!params_value) {
@@ -310,10 +311,15 @@ static int send_stereo_to_custom_stereo_cmd(int port_id,
		return -ENOMEM;
	}
	update_params_value32 = (int *)params_value;
	if (avail_length < 2 * sizeof(uint32_t))
		goto skip_send_cmd;
	*update_params_value32++ = MTMX_MODULE_ID_DEFAULT_CHMIXER;
	*update_params_value32++ = DEFAULT_CHMIXER_PARAM_ID_COEFF;
	avail_length = avail_length - (2 * sizeof(uint32_t));

	update_params_value16 = (int16_t *)update_params_value32;
	if (avail_length < 10 * sizeof(uint16_t))
		goto skip_send_cmd;
	*update_params_value16++ = CUSTOM_STEREO_CMD_PARAM_SIZE;
	/*for alignment only*/
	*update_params_value16++ = 0;
@@ -332,14 +338,16 @@ static int send_stereo_to_custom_stereo_cmd(int port_id,
	/* In ch map FL/FR*/
	*update_params_value16++ = PCM_CHANNEL_FL;
	*update_params_value16++ = PCM_CHANNEL_FR;

	avail_length = avail_length - (10 * sizeof(uint16_t));
	/* weighting coefficients as name suggests,
	   mixing will be done according to these coefficients*/
	if (avail_length < 4 * sizeof(uint16_t))
		goto skip_send_cmd;
	*update_params_value16++ = op_FL_ip_FL_weight;
	*update_params_value16++ = op_FL_ip_FR_weight;
	*update_params_value16++ = op_FR_ip_FL_weight;
	*update_params_value16++ = op_FR_ip_FR_weight;

	avail_length = avail_length - (4 * sizeof(uint16_t));
	if (params_length) {
		rc = adm_set_stereo_to_custom_stereo(port_id,
						     session_id,
@@ -353,6 +361,11 @@ static int send_stereo_to_custom_stereo_cmd(int port_id,
	}
	kfree(params_value);
	return 0;
skip_send_cmd:
		pr_err("%s: insufficient memory, send cmd failed\n",
			__func__);
		kfree(params_value);
		return -ENOMEM;
}

/* Track performance mode of all front-end multimedia sessions.
@@ -395,7 +408,10 @@ static void msm_pcm_routing_build_matrix(int fedai_id, int dspst_id,
		if ((path_type == ADM_PATH_PLAYBACK) &&
		     (perf_mode == LEGACY_PCM_MODE) &&
		     is_custom_stereo_on) {
			for (itr = 0; itr < payload.num_copps; itr++)
			for (itr = 0; itr < payload.num_copps; itr++) {
				if ((payload.copp_ids[itr] == SLIMBUS_0_RX) ||
				    (payload.copp_ids[itr] ==
					RT_PROXY_PORT_001_RX)) {
					send_stereo_to_custom_stereo_cmd(
						payload.copp_ids[itr],
						dspst_id,
@@ -406,6 +422,8 @@ static void msm_pcm_routing_build_matrix(int fedai_id, int dspst_id,
				}
			}
		}
	}
}

void msm_pcm_routing_reg_psthr_stream(int fedai_id, int dspst_id,
					int stream_type)
@@ -520,11 +538,17 @@ void msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
			port_id = srs_port_id = msm_bedais[i].port_id;
			srs_send_params(srs_port_id, 1, 0);
			if ((DOLBY_ADM_COPP_TOPOLOGY_ID == topology) &&
			    (perf_mode == LEGACY_PCM_MODE))
			    (perf_mode == LEGACY_PCM_MODE)) {
				if (dolby_dap_init(port_id,
						msm_bedais[i].channel) < 0)
					pr_err("%s: Err init dolby dap\n",
						__func__);
				if (is_custom_stereo_on)
					if (dolby_dap_set_custom_stereo_onoff(
						port_id, true) < 0)
						pr_err("%s: Err setting dap custom stereo\n",
							__func__);
			}
		}
	}
	if (payload.num_copps) {
@@ -533,7 +557,10 @@ void msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
		if ((path_type == ADM_PATH_PLAYBACK) &&
		    (perf_mode == LEGACY_PCM_MODE) &&
		     is_custom_stereo_on) {
			for (itr = 0; itr < payload.num_copps; itr++)
			for (itr = 0; itr < payload.num_copps; itr++) {
				if ((payload.copp_ids[itr] == SLIMBUS_0_RX) ||
				    (payload.copp_ids[itr] ==
						RT_PROXY_PORT_001_RX)) {
					send_stereo_to_custom_stereo_cmd(
						payload.copp_ids[itr],
						dspst_id,
@@ -543,6 +570,8 @@ void msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode,
						Q14_GAIN_ZERO_POINT_FIVE);
				}
			}
		}
	}
	mutex_unlock(&routing_lock);
}

@@ -701,10 +730,16 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set)
			srs_send_params(srs_port_id, 1, 0);
			if ((DOLBY_ADM_COPP_TOPOLOGY_ID == topology) &&
			    (fe_dai_perf_mode[val][session_type] ==
							LEGACY_PCM_MODE))
							LEGACY_PCM_MODE)) {
				if (dolby_dap_init(port_id, channels) < 0)
					pr_err("%s: Err init dolby dap\n",
						__func__);
				if (is_custom_stereo_on)
					if (dolby_dap_set_custom_stereo_onoff(
						port_id, true) < 0)
						pr_err("%s: Err setting dap custom stereo\n",
							__func__);
			}
		}
	} else {
		if (test_bit(val, &msm_bedais[reg].fe_sessions) &&
@@ -3121,9 +3156,14 @@ static int msm_routing_put_stereo_to_custom_stereo_control(
						0,
						Q14_GAIN_UNITY);
				}
				if (dolby_dap_set_custom_stereo_onoff(
					msm_bedais[be_index].port_id,
					is_custom_stereo_on) < 0)
					pr_err("%s: Err setting custom stereo\n",
						__func__);
skip_send_custom_stereo:
				if (rc)
					pr_err("%s custom stero mixing set failed\n",
					pr_err("%s: set MTMX param failed\n",
						__func__);
			}
		}
@@ -4577,10 +4617,16 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream)
			srs_send_params(srs_port_id, 1, 0);
			if ((DOLBY_ADM_COPP_TOPOLOGY_ID == topology) &&
			    (fe_dai_perf_mode[i][session_type] ==
							LEGACY_PCM_MODE))
							LEGACY_PCM_MODE)) {
				if (dolby_dap_init(port_id, channels) < 0)
					pr_err("%s: Err init dolby dap\n",
						__func__);
				if (is_custom_stereo_on)
					if (dolby_dap_set_custom_stereo_onoff(
						port_id, true) < 0)
						pr_err("%s: Err setting dap custom stereo\n",
							__func__);
			}
		}
	}