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

Commit f6a0d2e5 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: qdsp6v2: return specific adsp error code in rtac"

parents c79c70fe fe9e8aab
Loading
Loading
Loading
Loading
+70 −16
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@
#include <sound/apr_audio-v2.h>
#include <sound/apr_audio-v2.h>
#include "q6voice.h"
#include "q6voice.h"
#include "msm-pcm-routing-v2.h"
#include "msm-pcm-routing-v2.h"
#include <sound/adsp_err.h>




/* Max size of payload (buf size - apr header) */
/* Max size of payload (buf size - apr header) */
@@ -673,7 +674,7 @@ bool rtac_make_adm_callback(uint32_t *payload, u32 payload_size)
	return true;
	return true;
}
}


u32 send_adm_apr(void *buf, u32 opcode)
int send_adm_apr(void *buf, u32 opcode)
{
{
	s32	result;
	s32	result;
	u32	user_buf_size = 0;
	u32	user_buf_size = 0;
@@ -736,6 +737,7 @@ u32 send_adm_apr(void *buf, u32 opcode)
	mutex_lock(&rtac_adm_apr_mutex);
	mutex_lock(&rtac_adm_apr_mutex);
	if (rtac_adm_apr_data.apr_handle == NULL) {
	if (rtac_adm_apr_data.apr_handle == NULL) {
		pr_err("%s: APR not initialized\n", __func__);
		pr_err("%s: APR not initialized\n", __func__);
		result = -EINVAL;
		goto err;
		goto err;
	}
	}


@@ -746,6 +748,7 @@ u32 send_adm_apr(void *buf, u32 opcode)
		if (data_size > rtac_cal[ADM_RTAC_CAL].map_data.map_size) {
		if (data_size > rtac_cal[ADM_RTAC_CAL].map_data.map_size) {
			pr_err("%s: Invalid data size = %d\n",
			pr_err("%s: Invalid data size = %d\n",
				__func__, data_size);
				__func__, data_size);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
		payload_size = 4 * sizeof(u32);
		payload_size = 4 * sizeof(u32);
@@ -756,6 +759,7 @@ u32 send_adm_apr(void *buf, u32 opcode)
				buf + 7 * sizeof(u32), data_size)) {
				buf + 7 * sizeof(u32), data_size)) {
			pr_err("%s: Could not copy payload from user buffer\n",
			pr_err("%s: Could not copy payload from user buffer\n",
				__func__);
				__func__);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
		/* set payload size in packet */
		/* set payload size in packet */
@@ -764,6 +768,7 @@ u32 send_adm_apr(void *buf, u32 opcode)
		if (payload_size > MAX_PAYLOAD_SIZE) {
		if (payload_size > MAX_PAYLOAD_SIZE) {
			pr_err("%s: Invalid payload size = %d\n",
			pr_err("%s: Invalid payload size = %d\n",
				__func__, payload_size);
				__func__, payload_size);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -773,6 +778,7 @@ u32 send_adm_apr(void *buf, u32 opcode)
				buf + 3 * sizeof(u32), payload_size)) {
				buf + 3 * sizeof(u32), payload_size)) {
			pr_err("%s: Could not copy payload from user buffer\n",
			pr_err("%s: Could not copy payload from user buffer\n",
				__func__);
				__func__);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
	}
	}
@@ -821,9 +827,13 @@ u32 send_adm_apr(void *buf, u32 opcode)
		goto err;
		goto err;
	}
	}
	if (atomic_read(&rtac_common.apr_err_code)) {
	if (atomic_read(&rtac_common.apr_err_code)) {
		pr_err("%s: DSP returned error code = %d, opcode = 0x%x\n",
		pr_err("%s: DSP returned error code = [%s], opcode = 0x%x\n",
			__func__, atomic_read(&rtac_common.apr_err_code),
			__func__, adsp_err_get_err_str(atomic_read(
			&rtac_common.apr_err_code)),
			opcode);
			opcode);
		result = adsp_err_get_lnx_err_code(
					atomic_read(
					&rtac_common.apr_err_code));
		goto err;
		goto err;
	}
	}


@@ -834,6 +844,7 @@ u32 send_adm_apr(void *buf, u32 opcode)
		if (bytes_returned > user_buf_size) {
		if (bytes_returned > user_buf_size) {
			pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
			pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
				__func__, user_buf_size, bytes_returned);
				__func__, user_buf_size, bytes_returned);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -842,15 +853,18 @@ u32 send_adm_apr(void *buf, u32 opcode)
				bytes_returned)) {
				bytes_returned)) {
			pr_err("%s: Could not copy buffer to user,size = %d\n",
			pr_err("%s: Could not copy buffer to user,size = %d\n",
				__func__, bytes_returned);
				__func__, bytes_returned);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
	} else {
	} else {
		bytes_returned = data_size;
		bytes_returned = data_size;
	}
	}
err:
	mutex_unlock(&rtac_adm_apr_mutex);
	mutex_unlock(&rtac_adm_apr_mutex);
done:
done:
	return bytes_returned;
	return bytes_returned;
err:
	mutex_unlock(&rtac_adm_apr_mutex);
	return result;
}
}




@@ -881,7 +895,7 @@ bool rtac_make_asm_callback(u32 session_id, uint32_t *payload,
	return true;
	return true;
}
}


u32 send_rtac_asm_apr(void *buf, u32 opcode)
int send_rtac_asm_apr(void *buf, u32 opcode)
{
{
	s32	result;
	s32	result;
	u32	user_buf_size = 0;
	u32	user_buf_size = 0;
@@ -941,6 +955,7 @@ u32 send_rtac_asm_apr(void *buf, u32 opcode)
	mutex_lock(&rtac_asm_apr_mutex);
	mutex_lock(&rtac_asm_apr_mutex);
	if (rtac_asm_apr_data[session_id].apr_handle == NULL) {
	if (rtac_asm_apr_data[session_id].apr_handle == NULL) {
		pr_err("%s: APR not initialized\n", __func__);
		pr_err("%s: APR not initialized\n", __func__);
		result = -EINVAL;
		goto err;
		goto err;
	}
	}


@@ -951,6 +966,7 @@ u32 send_rtac_asm_apr(void *buf, u32 opcode)
		if (data_size > rtac_cal[ASM_RTAC_CAL].map_data.map_size) {
		if (data_size > rtac_cal[ASM_RTAC_CAL].map_data.map_size) {
			pr_err("%s: Invalid data size = %d\n",
			pr_err("%s: Invalid data size = %d\n",
				__func__, data_size);
				__func__, data_size);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
		payload_size = 4 * sizeof(u32);
		payload_size = 4 * sizeof(u32);
@@ -961,6 +977,7 @@ u32 send_rtac_asm_apr(void *buf, u32 opcode)
				buf + 7 * sizeof(u32), data_size)) {
				buf + 7 * sizeof(u32), data_size)) {
			pr_err("%s: Could not copy payload from user buffer\n",
			pr_err("%s: Could not copy payload from user buffer\n",
				__func__);
				__func__);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
		/* set payload size in packet */
		/* set payload size in packet */
@@ -970,6 +987,7 @@ u32 send_rtac_asm_apr(void *buf, u32 opcode)
		if (payload_size > MAX_PAYLOAD_SIZE) {
		if (payload_size > MAX_PAYLOAD_SIZE) {
			pr_err("%s: Invalid payload size = %d\n",
			pr_err("%s: Invalid payload size = %d\n",
				__func__, payload_size);
				__func__, payload_size);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -979,6 +997,7 @@ u32 send_rtac_asm_apr(void *buf, u32 opcode)
				buf + 3 * sizeof(u32), payload_size)) {
				buf + 3 * sizeof(u32), payload_size)) {
			pr_err("%s: Could not copy payload from user buffer\n",
			pr_err("%s: Could not copy payload from user buffer\n",
				__func__);
				__func__);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
	}
	}
@@ -1029,9 +1048,13 @@ u32 send_rtac_asm_apr(void *buf, u32 opcode)
		goto err;
		goto err;
	}
	}
	if (atomic_read(&rtac_common.apr_err_code)) {
	if (atomic_read(&rtac_common.apr_err_code)) {
		pr_err("%s: DSP returned error code = %d, opcode = 0x%x\n",
		pr_err("%s: DSP returned error code = [%s], opcode = 0x%x\n",
			__func__, atomic_read(&rtac_common.apr_err_code),
			__func__, adsp_err_get_err_str(atomic_read(
			&rtac_common.apr_err_code)),
			opcode);
			opcode);
		result = adsp_err_get_lnx_err_code(
					atomic_read(
					&rtac_common.apr_err_code));
		goto err;
		goto err;
	}
	}


@@ -1042,6 +1065,7 @@ u32 send_rtac_asm_apr(void *buf, u32 opcode)
		if (bytes_returned > user_buf_size) {
		if (bytes_returned > user_buf_size) {
			pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
			pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
				__func__, user_buf_size, bytes_returned);
				__func__, user_buf_size, bytes_returned);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -1050,15 +1074,18 @@ u32 send_rtac_asm_apr(void *buf, u32 opcode)
				bytes_returned)) {
				bytes_returned)) {
			pr_err("%s: Could not copy buffer to user,size = %d\n",
			pr_err("%s: Could not copy buffer to user,size = %d\n",
				 __func__, bytes_returned);
				 __func__, bytes_returned);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
	} else {
	} else {
		bytes_returned = data_size;
		bytes_returned = data_size;
	}
	}
err:
	mutex_unlock(&rtac_asm_apr_mutex);
	mutex_unlock(&rtac_asm_apr_mutex);
done:
done:
	return bytes_returned;
	return bytes_returned;
err:
	mutex_unlock(&rtac_asm_apr_mutex);
	return result;
}
}


/* AFE APR */
/* AFE APR */
@@ -1109,7 +1136,7 @@ static int fill_afe_apr_hdr(struct apr_hdr *apr_hdr, uint32_t port,
	return 0;
	return 0;


}
}
static u32 send_rtac_afe_apr(void *buf, uint32_t opcode)
static int send_rtac_afe_apr(void *buf, uint32_t opcode)
{
{
	int32_t result;
	int32_t result;
	uint32_t bytes_returned = 0;
	uint32_t bytes_returned = 0;
@@ -1160,6 +1187,7 @@ static u32 send_rtac_afe_apr(void *buf, uint32_t opcode)
	mutex_lock(&rtac_afe_apr_mutex);
	mutex_lock(&rtac_afe_apr_mutex);
	if (rtac_afe_apr_data.apr_handle == NULL) {
	if (rtac_afe_apr_data.apr_handle == NULL) {
		pr_err("%s: APR not initialized\n", __func__);
		pr_err("%s: APR not initialized\n", __func__);
		result = -EINVAL;
		goto err;
		goto err;
	}
	}
	if (opcode == AFE_PORT_CMD_SET_PARAM_V2) {
	if (opcode == AFE_PORT_CMD_SET_PARAM_V2) {
@@ -1171,6 +1199,7 @@ static u32 send_rtac_afe_apr(void *buf, uint32_t opcode)
			pr_err("%s: Invalid data size = %d\n",
			pr_err("%s: Invalid data size = %d\n",
				   __func__,
				   __func__,
				   user_afe_buf.rtac_afe_set.cmd.payload_size);
				   user_afe_buf.rtac_afe_set.cmd.payload_size);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -1182,6 +1211,7 @@ static u32 send_rtac_afe_apr(void *buf, uint32_t opcode)
				user_afe_buf.rtac_afe_set.cmd.payload_size)) {
				user_afe_buf.rtac_afe_set.cmd.payload_size)) {
			pr_err("%s: Could not copy payload from user buffer\n",
			pr_err("%s: Could not copy payload from user buffer\n",
				__func__);
				__func__);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -1196,6 +1226,7 @@ static u32 send_rtac_afe_apr(void *buf, uint32_t opcode)
				sizeof(struct afe_port_cmd_set_param_v2))) {
				sizeof(struct afe_port_cmd_set_param_v2))) {
			pr_err("%s: Could not copy payload from user buffer\n",
			pr_err("%s: Could not copy payload from user buffer\n",
				__func__);
				__func__);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -1215,6 +1246,7 @@ static u32 send_rtac_afe_apr(void *buf, uint32_t opcode)
		if (user_afe_buf.cmd_size > MAX_PAYLOAD_SIZE) {
		if (user_afe_buf.cmd_size > MAX_PAYLOAD_SIZE) {
			pr_err("%s: Invalid payload size = %d\n",
			pr_err("%s: Invalid payload size = %d\n",
				__func__, user_afe_buf.cmd_size);
				__func__, user_afe_buf.cmd_size);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -1228,6 +1260,7 @@ static u32 send_rtac_afe_apr(void *buf, uint32_t opcode)
			sizeof(struct afe_port_cmd_get_param_v2))) {
			sizeof(struct afe_port_cmd_get_param_v2))) {
			pr_err("%s: Could not copy payload from user buffer\n",
			pr_err("%s: Could not copy payload from user buffer\n",
				__func__);
				__func__);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -1268,9 +1301,13 @@ static u32 send_rtac_afe_apr(void *buf, uint32_t opcode)
		goto err;
		goto err;
	}
	}
	if (atomic_read(&rtac_common.apr_err_code)) {
	if (atomic_read(&rtac_common.apr_err_code)) {
		pr_err("%s: DSP returned error code = %d, opcode = 0x%x\n",
		pr_err("%s: DSP returned error code = [%s], opcode = 0x%x\n",
			__func__, atomic_read(&rtac_common.apr_err_code),
			__func__, adsp_err_get_err_str(atomic_read(
			&rtac_common.apr_err_code)),
			opcode);
			opcode);
		result = adsp_err_get_lnx_err_code(
					atomic_read(
					&rtac_common.apr_err_code));
		goto err;
		goto err;
	}
	}


@@ -1286,6 +1323,7 @@ static u32 send_rtac_afe_apr(void *buf, uint32_t opcode)
			pr_err("%s: user size = 0x%x, returned size = 0x%x\n",
			pr_err("%s: user size = 0x%x, returned size = 0x%x\n",
				__func__, user_afe_buf.buf_size,
				__func__, user_afe_buf.buf_size,
				bytes_returned);
				bytes_returned);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -1294,15 +1332,18 @@ static u32 send_rtac_afe_apr(void *buf, uint32_t opcode)
				bytes_returned)) {
				bytes_returned)) {
			pr_err("%s: Could not copy buffer to user,size = %d\n",
			pr_err("%s: Could not copy buffer to user,size = %d\n",
				__func__, bytes_returned);
				__func__, bytes_returned);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
	} else {
	} else {
		bytes_returned = user_afe_buf.rtac_afe_set.cmd.payload_size;
		bytes_returned = user_afe_buf.rtac_afe_set.cmd.payload_size;
	}
	}
err:
	mutex_unlock(&rtac_afe_apr_mutex);
	mutex_unlock(&rtac_afe_apr_mutex);
done:
done:
	return bytes_returned;
	return bytes_returned;
err:
	mutex_unlock(&rtac_afe_apr_mutex);
	return result;
}
}


/* Voice APR */
/* Voice APR */
@@ -1332,7 +1373,7 @@ bool rtac_make_voice_callback(u32 mode, uint32_t *payload, u32 payload_size)
	return true;
	return true;
}
}


u32 send_voice_apr(u32 mode, void *buf, u32 opcode)
int send_voice_apr(u32 mode, void *buf, u32 opcode)
{
{
	s32	result;
	s32	result;
	u32	user_buf_size = 0;
	u32	user_buf_size = 0;
@@ -1394,6 +1435,7 @@ u32 send_voice_apr(u32 mode, void *buf, u32 opcode)
	mutex_lock(&rtac_voice_apr_mutex);
	mutex_lock(&rtac_voice_apr_mutex);
	if (rtac_voice_apr_data[mode].apr_handle == NULL) {
	if (rtac_voice_apr_data[mode].apr_handle == NULL) {
		pr_err("%s: APR not initialized\n", __func__);
		pr_err("%s: APR not initialized\n", __func__);
		result = -EINVAL;
		goto err;
		goto err;
	}
	}


@@ -1404,6 +1446,7 @@ u32 send_voice_apr(u32 mode, void *buf, u32 opcode)
		if (data_size > rtac_cal[VOICE_RTAC_CAL].map_data.map_size) {
		if (data_size > rtac_cal[VOICE_RTAC_CAL].map_data.map_size) {
			pr_err("%s: Invalid data size = %d\n",
			pr_err("%s: Invalid data size = %d\n",
				__func__, data_size);
				__func__, data_size);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
		payload_size = 4 * sizeof(u32);
		payload_size = 4 * sizeof(u32);
@@ -1414,6 +1457,7 @@ u32 send_voice_apr(u32 mode, void *buf, u32 opcode)
				buf + 7 * sizeof(u32), data_size)) {
				buf + 7 * sizeof(u32), data_size)) {
			pr_err("%s: Could not copy payload from user buffer\n",
			pr_err("%s: Could not copy payload from user buffer\n",
				__func__);
				__func__);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
		/* set payload size in packet */
		/* set payload size in packet */
@@ -1422,6 +1466,7 @@ u32 send_voice_apr(u32 mode, void *buf, u32 opcode)
		if (payload_size > MAX_PAYLOAD_SIZE) {
		if (payload_size > MAX_PAYLOAD_SIZE) {
			pr_err("%s: Invalid payload size = %d\n",
			pr_err("%s: Invalid payload size = %d\n",
					__func__, payload_size);
					__func__, payload_size);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -1431,6 +1476,7 @@ u32 send_voice_apr(u32 mode, void *buf, u32 opcode)
				buf + 3 * sizeof(u32), payload_size)) {
				buf + 3 * sizeof(u32), payload_size)) {
			pr_err("%s: Could not copy payload from user buffer\n",
			pr_err("%s: Could not copy payload from user buffer\n",
				__func__);
				__func__);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
	}
	}
@@ -1480,9 +1526,13 @@ u32 send_voice_apr(u32 mode, void *buf, u32 opcode)
		goto err;
		goto err;
	}
	}
	if (atomic_read(&rtac_common.apr_err_code)) {
	if (atomic_read(&rtac_common.apr_err_code)) {
		pr_err("%s: DSP returned error code = %d, opcode = 0x%x\n",
		pr_err("%s: DSP returned error code = [%s], opcode = 0x%x\n",
			__func__, atomic_read(&rtac_common.apr_err_code),
			__func__, adsp_err_get_err_str(atomic_read(
			&rtac_common.apr_err_code)),
			opcode);
			opcode);
		result = adsp_err_get_lnx_err_code(
					atomic_read(
					&rtac_common.apr_err_code));
		goto err;
		goto err;
	}
	}


@@ -1493,6 +1543,7 @@ u32 send_voice_apr(u32 mode, void *buf, u32 opcode)
		if (bytes_returned > user_buf_size) {
		if (bytes_returned > user_buf_size) {
			pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
			pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
				__func__, user_buf_size, bytes_returned);
				__func__, user_buf_size, bytes_returned);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}


@@ -1501,15 +1552,18 @@ u32 send_voice_apr(u32 mode, void *buf, u32 opcode)
				bytes_returned)) {
				bytes_returned)) {
			pr_err("%s: Could not copy buffer to user, size = %d\n",
			pr_err("%s: Could not copy buffer to user, size = %d\n",
				 __func__, bytes_returned);
				 __func__, bytes_returned);
			result = -EINVAL;
			goto err;
			goto err;
		}
		}
	} else {
	} else {
		bytes_returned = data_size;
		bytes_returned = data_size;
	}
	}
err:
	mutex_unlock(&rtac_voice_apr_mutex);
	mutex_unlock(&rtac_voice_apr_mutex);
done:
done:
	return bytes_returned;
	return bytes_returned;
err:
	mutex_unlock(&rtac_voice_apr_mutex);
	return result;
}
}


void get_rtac_adm_data(struct rtac_adm *adm_data)
void get_rtac_adm_data(struct rtac_adm *adm_data)