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

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

Merge "ASoC: dsp: Update ADM driver to support Instance ID"

parents ec5e473d 60cc0351
Loading
Loading
Loading
Loading
+39 −24
Original line number Diff line number Diff line
@@ -11517,10 +11517,11 @@ static int msm_routing_put_module_cfg_control(struct snd_kcontrol *kcontrol,
	int ret = 0;
	unsigned long copp;
	struct msm_pcm_routing_bdai_data *bedai;
	char *param_data = NULL;
	uint32_t *update_param_data = NULL;
	uint32_t param_size = sizeof(uint32_t) +
			sizeof(struct adm_param_data_v5);
	u8 *packed_params = NULL;
	struct param_hdr_v3 param_hdr;
	u32 packed_param_size = (sizeof(struct param_hdr_v3) +
				 sizeof(uint32_t));
	int dir = ucontrol->value.integer.value[0] ? SESSION_TYPE_TX :
						     SESSION_TYPE_RX;
	int app_type = ucontrol->value.integer.value[1];
@@ -11535,15 +11536,17 @@ static int msm_routing_put_module_cfg_control(struct snd_kcontrol *kcontrol,
		  __func__, app_type, module_id,
		  instance_id, param_id, param_value);
	param_data = kzalloc(param_size, GFP_KERNEL);
	if (!param_data)
	packed_params = kzalloc(packed_param_size, GFP_KERNEL);
	if (!packed_params)
		return -ENOMEM;
	update_param_data = (uint32_t *)param_data;
	*update_param_data++ = module_id;
	*update_param_data++ = param_id;
	*update_param_data++ = sizeof(uint32_t);
	*update_param_data++ = param_value;
	memset(&param_hdr, 0, sizeof(param_hdr));
	param_hdr.module_id = module_id;
	param_hdr.instance_id = instance_id;
	param_hdr.param_id = param_id;
	param_hdr.param_size = sizeof(uint32_t);
	packed_param_size = 0;
	mutex_lock(&routing_lock);
	for (be_id = 0; be_id < MSM_BACKEND_DAI_MAX; be_id++) {
@@ -11571,10 +11574,20 @@ static int msm_routing_put_module_cfg_control(struct snd_kcontrol *kcontrol,
				if (!test_bit(copp_idx, &copp))
					continue;
				ret = adm_send_params_v5(bedai->port_id,
							 copp_idx,
							 param_data,
							 param_size);
				ret = q6common_pack_pp_params(packed_params,
							&param_hdr,
							(u8 *) &param_value,
							&packed_param_size);
				if (ret) {
					pr_err("%s: Failed to pack params, error %d\n",
					       __func__, ret);
					goto done;
				}
				ret = adm_set_pp_params(bedai->port_id,
							 copp_idx, NULL,
							 packed_params,
							 packed_param_size);
				if (ret) {
					pr_err("%s: Setting param failed with err=%d\n",
						__func__, ret);
@@ -11586,7 +11599,7 @@ static int msm_routing_put_module_cfg_control(struct snd_kcontrol *kcontrol,
	}
done:
	mutex_unlock(&routing_lock);
	kfree(param_data);
	kfree(packed_params);
	return ret;
}
@@ -11662,22 +11675,24 @@ int msm_routing_get_rms_value_control(struct snd_kcontrol *kcontrol,
	int be_idx = 0;
	char *param_value;
	int *update_param_value;
	uint32_t param_length = sizeof(uint32_t);
	uint32_t param_payload_len = RMS_PAYLOAD_LEN * sizeof(uint32_t);
	uint32_t param_size = (RMS_PAYLOAD_LEN + 1) * sizeof(uint32_t);
	struct param_hdr_v3 param_hdr;
	param_value = kzalloc(param_length + param_payload_len, GFP_KERNEL);
	param_value = kzalloc(param_size, GFP_KERNEL);
	if (!param_value)
		return -ENOMEM;
	memset(&param_hdr, 0, sizeof(param_hdr));
	for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++)
		if (msm_bedais[be_idx].port_id == SLIMBUS_0_TX)
			break;
	if ((be_idx < MSM_BACKEND_DAI_MAX) && msm_bedais[be_idx].active) {
		rc = adm_get_params(SLIMBUS_0_TX, 0,
				RMS_MODULEID_APPI_PASSTHRU,
				RMS_PARAM_FIRST_SAMPLE,
				param_length + param_payload_len,
				param_value);
		param_hdr.module_id = RMS_MODULEID_APPI_PASSTHRU;
		param_hdr.instance_id = INSTANCE_ID_0;
		param_hdr.param_id = RMS_PARAM_FIRST_SAMPLE;
		param_hdr.param_size = param_size;
		rc = adm_get_pp_params(SLIMBUS_0_TX, 0, ADM_CLIENT_ID_DEFAULT,
				       NULL, &param_hdr, (u8 *) param_value);
		if (rc) {
			pr_err("%s: get parameters failed:%d\n", __func__, rc);
			kfree(param_value);
+70 −44
Original line number Diff line number Diff line
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, 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
@@ -21,6 +21,7 @@
#include <dsp/q6asm-v2.h>
#include <dsp/q6afe-v2.h>
#include <dsp/q6audio-v2.h>
#include <dsp/q6common.h>

#include "msm-qti-pp-config.h"
#include "msm-pcm-routing-v2.h"
@@ -263,6 +264,11 @@ int msm_qti_pp_send_stereo_to_custom_stereo_cmd(int port_id, int copp_idx,
	update_params_value32 = (int *)params_value;
	if (avail_length < 2 * sizeof(uint32_t))
		goto skip_send_cmd;

	/*
	 * This module is internal to ADSP and cannot be configured with
	 * an instance id
	 */
	*update_params_value32++ = MTMX_MODULE_ID_DEFAULT_CHMIXER;
	*update_params_value32++ = DEFAULT_CHMIXER_PARAM_ID_COEFF;
	avail_length = avail_length - (2 * sizeof(uint32_t));
@@ -329,14 +335,13 @@ static int msm_qti_pp_get_rms_value_control(struct snd_kcontrol *kcontrol,
	int be_idx = 0, copp_idx;
	char *param_value;
	int *update_param_value;
	uint32_t param_length = sizeof(uint32_t);
	uint32_t param_payload_len = RMS_PAYLOAD_LEN * sizeof(uint32_t);
	uint32_t param_size = (RMS_PAYLOAD_LEN + 1) * sizeof(uint32_t);
	struct msm_pcm_routing_bdai_data msm_bedai;
	struct param_hdr_v3 param_hdr;

	param_value = kzalloc(param_length + param_payload_len, GFP_KERNEL);
	param_value = kzalloc(param_size, GFP_KERNEL);
	if (!param_value)
		return -ENOMEM;

	msm_pcm_routing_acquire_lock();
	for (be_idx = 0; be_idx < MSM_BACKEND_DAI_MAX; be_idx++) {
		msm_pcm_routing_get_bedai_info(be_idx, &msm_bedai);
@@ -356,11 +361,13 @@ static int msm_qti_pp_get_rms_value_control(struct snd_kcontrol *kcontrol,
		rc = -EINVAL;
		goto get_rms_value_err;
	}
	rc = adm_get_params(SLIMBUS_0_TX, copp_idx,
			RMS_MODULEID_APPI_PASSTHRU,
			RMS_PARAM_FIRST_SAMPLE,
			param_length + param_payload_len,
			param_value);
	memset(&param_hdr, 0, sizeof(param_hdr));
	param_hdr.module_id = RMS_MODULEID_APPI_PASSTHRU;
	param_hdr.instance_id = INSTANCE_ID_0;
	param_hdr.param_id = RMS_PARAM_FIRST_SAMPLE;
	param_hdr.param_size = param_size;
	rc = adm_get_pp_params(SLIMBUS_0_TX, copp_idx, ADM_CLIENT_ID_DEFAULT,
			       NULL, &param_hdr, param_value);
	if (rc) {
		pr_err("%s: get parameters failed rc=%d\n", __func__, rc);
		rc = -EINVAL;
@@ -692,21 +699,26 @@ static void msm_qti_pp_asphere_init_state(void)

static int msm_qti_pp_asphere_send_params(int port_id, int copp_idx, bool force)
{
	char *params_value = NULL;
	uint32_t *update_params_value = NULL;
	uint32_t param_size = sizeof(uint32_t) +
			sizeof(struct adm_param_data_v5);
	int params_length = 0, param_count = 0, ret = 0;
	u8 *packed_params = NULL;
	u32 packed_params_size = 0;
	u32 param_size = 0;
	struct param_hdr_v3 param_hdr;
	bool set_enable = force ||
			(asphere_state.enabled != asphere_state.enabled_prev);
	bool set_strength = asphere_state.enabled == 1 && (set_enable ||
		(asphere_state.strength != asphere_state.strength_prev));
	int param_count = 0;
	int ret = 0;

	if (set_enable)
		param_count++;
	if (set_strength)
		param_count++;
	params_length = param_count * param_size;

	if (param_count == 0) {
		pr_debug("%s: Nothing to send, exiting\n", __func__);
		return 0;
	}

	pr_debug("%s: port_id %d, copp_id %d, forced %d, param_count %d\n",
		 __func__, port_id, copp_idx, force, param_count);
@@ -714,42 +726,56 @@ static int msm_qti_pp_asphere_send_params(int port_id, int copp_idx, bool force)
		__func__, asphere_state.enabled_prev, asphere_state.enabled,
		asphere_state.strength_prev, asphere_state.strength);

	if (params_length > 0)
		params_value = kzalloc(params_length, GFP_KERNEL);
	if (!params_value) {
		pr_err("%s, params memory alloc failed\n", __func__);
	packed_params_size =
		param_count * (sizeof(struct param_hdr_v3) + sizeof(uint32_t));
	packed_params = kzalloc(packed_params_size, GFP_KERNEL);
	if (!packed_params)
		return -ENOMEM;
	}
	update_params_value = (uint32_t *)params_value;
	params_length = 0;

	memset(&param_hdr, 0, sizeof(param_hdr));
	packed_params_size = 0;
	param_hdr.module_id = AUDPROC_MODULE_ID_AUDIOSPHERE;
	param_hdr.instance_id = INSTANCE_ID_0;
	if (set_strength) {
		/* add strength command */
		*update_params_value++ = AUDPROC_MODULE_ID_AUDIOSPHERE;
		*update_params_value++ = AUDPROC_PARAM_ID_AUDIOSPHERE_STRENGTH;
		*update_params_value++ = sizeof(uint32_t);
		*update_params_value++ = asphere_state.strength;
		params_length += param_size;
		param_hdr.param_id = AUDPROC_PARAM_ID_AUDIOSPHERE_STRENGTH;
		param_hdr.param_size = sizeof(asphere_state.strength);
		ret = q6common_pack_pp_params(packed_params +
						      packed_params_size,
					      &param_hdr,
					      (u8 *) &asphere_state.strength,
					      &param_size);
		if (ret) {
			pr_err("%s: Failed to pack params for audio sphere"
				" strength, error %d\n", __func__, ret);
			goto done;
		}
		packed_params_size += param_size;
	}
	if (set_enable) {
		/* add enable command */
		*update_params_value++ = AUDPROC_MODULE_ID_AUDIOSPHERE;
		*update_params_value++ = AUDPROC_PARAM_ID_AUDIOSPHERE_ENABLE;
		*update_params_value++ = sizeof(uint32_t);
		*update_params_value++ = asphere_state.enabled;
		params_length += param_size;
	}
	pr_debug("%s, param length: %d\n", __func__, params_length);
	if (params_length) {
		ret = adm_send_params_v5(port_id, copp_idx,
					params_value, params_length);
		param_hdr.param_id = AUDPROC_PARAM_ID_AUDIOSPHERE_ENABLE;
		param_hdr.param_size = sizeof(asphere_state.enabled);
		q6common_pack_pp_params(packed_params + packed_params_size,
					&param_hdr,
					(u8 *) &asphere_state.enabled,
					&param_size);
		if (ret) {
			pr_err("%s: setting param failed with err=%d\n",
				__func__, ret);
			kfree(params_value);
			return -EINVAL;
			pr_err("%s: Failed to pack params for audio sphere"
				" enable, error %d\n", __func__, ret);
			goto done;
		}
		packed_params_size += param_size;
	}
	kfree(params_value);

	pr_debug("%s: packed data size: %d\n", __func__, packed_params_size);
	ret = adm_set_pp_params(port_id, copp_idx, NULL, packed_params,
				packed_params_size);
	if (ret)
		pr_err("%s: set param failed with err=%d\n", __func__, ret);

done:
	kfree(packed_params);
	return 0;
}

+837 −1568

File changed.

Preview size limit exceeded, changes collapsed.

+10 −10
Original line number Diff line number Diff line
@@ -2005,10 +2005,10 @@ static int32_t q6asm_callback(struct apr_client_data *data, void *priv)
			break;
		}
		case ASM_STREAM_CMD_GET_PP_PARAMS_V2:
			pr_debug("%s: ASM_STREAM_CMD_GET_PP_PARAMS_V2 session %d opcode 0x%x token 0x%x src %d dest %d\n",
				__func__, ac->session,
				data->opcode, data->token,
				data->src_port, data->dest_port);
		case ASM_STREAM_CMD_GET_PP_PARAMS_V3:
			pr_debug("%s: ASM_STREAM_CMD_GET_PP_PARAMS session %d opcode 0x%x token 0x%x src %d dest %d\n",
				__func__, ac->session, data->opcode,
				data->token, data->src_port, data->dest_port);
			/* Should only come here if there is an APR */
			/* error or malformed APR packet. Otherwise */
			/* response will be returned as */
@@ -2085,12 +2085,12 @@ static int32_t q6asm_callback(struct apr_client_data *data, void *priv)
		break;
	}
	case ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2:
		pr_debug("%s: ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2 session %d opcode 0x%x token 0x%x src %d dest %d\n",
				__func__, ac->session, data->opcode,
				data->token,
	case ASM_STREAM_CMDRSP_GET_PP_PARAMS_V3:
		pr_debug("%s: ASM_STREAM_CMDRSP_GET_PP_PARAMS session %d opcode 0x%x token 0x%x src %d dest %d\n",
			__func__, ac->session, data->opcode, data->token,
			data->src_port, data->dest_port);
		if (payload[0] != 0) {
			pr_err("%s: ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2 returned error = 0x%x\n",
			pr_err("%s: ASM_STREAM_CMDRSP_GET_PP_PARAMS returned error = 0x%x\n",
			       __func__, payload[0]);
		} else if (generic_get_data) {
			generic_get_data->valid = 1;
+7 −3
Original line number Diff line number Diff line
@@ -7456,6 +7456,7 @@ static int32_t qdsp_cvs_callback(struct apr_client_data *data, void *priv)
							data->payload_size);
				break;
			case VSS_ICOMMON_CMD_GET_PARAM_V2:
			case VSS_ICOMMON_CMD_GET_PARAM_V3:
				pr_debug("%s: VSS_ICOMMON_CMD_GET_PARAM_V2\n",
					 __func__);
				/* Should only come here if there is an APR */
@@ -7589,7 +7590,8 @@ static int32_t qdsp_cvs_callback(struct apr_client_data *data, void *priv)
		pr_debug("Recd VSS_ISTREAM_EVT_NOT_READY\n");
	} else if (data->opcode == VSS_ISTREAM_EVT_READY) {
		pr_debug("Recd VSS_ISTREAM_EVT_READY\n");
	} else if (data->opcode == VSS_ICOMMON_RSP_GET_PARAM) {
	} else if (data->opcode == VSS_ICOMMON_RSP_GET_PARAM ||
		   VSS_ICOMMON_RSP_GET_PARAM_V3) {
		pr_debug("%s: VSS_ICOMMON_RSP_GET_PARAM\n", __func__);
		ptr = data->payload;
		if (ptr[0] != 0) {
@@ -7747,12 +7749,13 @@ static int32_t qdsp_cvp_callback(struct apr_client_data *data, void *priv)
						data->payload_size);
					break;
				default:
					pr_debug("%s: invalid token for command VSS_ICOMMON_CMD_SET_PARAM_V2: %d\n",
					pr_debug("%s: invalid token for command VSS_ICOMMON_CMD_SET_PARAM: %d\n",
						__func__, data->token);
					break;
				}
				break;
			case VSS_ICOMMON_CMD_GET_PARAM_V2:
			case VSS_ICOMMON_CMD_GET_PARAM_V3:
				pr_debug("%s: VSS_ICOMMON_CMD_GET_PARAM_V2\n",
					 __func__);
				/* Should only come here if there is an APR */
@@ -7819,7 +7822,8 @@ static int32_t qdsp_cvp_callback(struct apr_client_data *data, void *priv)
				break;
			}
		}
	} else if (data->opcode == VSS_ICOMMON_RSP_GET_PARAM) {
	} else if (data->opcode == VSS_ICOMMON_RSP_GET_PARAM ||
		   VSS_ICOMMON_RSP_GET_PARAM_V3) {
		pr_debug("%s: VSS_ICOMMON_RSP_GET_PARAM\n", __func__);
		ptr = data->payload;
		if (ptr[0] != 0) {
Loading