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

This commit is contained in:
Linux Build Service Account 2018-03-05 14:10:08 -08:00 • committed by Gerrit - the friendly Code Review server
commit 7f1bb371ec
8 changed files with 1481 additions and 2057 deletions

View file

@ -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);

View file

@ -1,4 +1,4 @@
/* 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,64 +699,83 @@ 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);
__func__, port_id, copp_idx, force, param_count);
pr_debug("%s: enable prev:%u cur:%u, strength prev:%u cur:%u\n",
__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;
}

File diff suppressed because it is too large Load diff

View file

@ -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,13 +2085,13 @@ 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,
data->src_port, data->dest_port);
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",
__func__, payload[0]);
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;
if (generic_get_data->is_inband) {

View file

@ -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) {

View file

@ -27,6 +27,7 @@
#include <dsp/q6afe-v2.h>
#include <dsp/q6adm-v2.h>
#include <dsp/apr_audio-v2.h>
#include <dsp/q6common.h>
#include <dsp/q6voice.h>
#include "adsp_err.h"
@ -103,14 +104,10 @@ struct rtac_afe_user_data {
uint32_t cmd_size;
uint32_t port_id;
union {
struct rtac_afe_set {
struct afe_rtac_set_param_v2 cmd;
struct param_hdr_v1 data;
} rtac_afe_set;
struct rtac_afe_get {
struct afe_rtac_get_param_v2 cmd;
struct param_hdr_v1 data;
} rtac_afe_get;
struct afe_rtac_user_data_set_v2 v2_set;
struct afe_rtac_user_data_set_v3 v3_set;
struct afe_rtac_user_data_get_v2 v2_get;
struct afe_rtac_user_data_get_v3 v3_get;
};
} __packed;
@ -804,7 +801,9 @@ int send_adm_apr(void *buf, u32 opcode)
goto err;
}
if (opcode == ADM_CMD_SET_PP_PARAMS_V5) {
switch (opcode) {
case ADM_CMD_SET_PP_PARAMS_V5:
case ADM_CMD_SET_PP_PARAMS_V6:
/* set payload size to in-band payload */
/* set data size to actual out of band payload size */
data_size = payload_size - 4 * sizeof(u32);
@ -822,12 +821,15 @@ int send_adm_apr(void *buf, u32 opcode)
buf + 7 * sizeof(u32), data_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
result = -EINVAL;
result = -EFAULT;
goto err;
}
/* set payload size in packet */
rtac_adm_buffer[8] = data_size;
} else {
break;
case ADM_CMD_GET_PP_PARAMS_V5:
case ADM_CMD_GET_PP_PARAMS_V6:
if (payload_size > MAX_PAYLOAD_SIZE) {
pr_err("%s: Invalid payload size = %d\n",
__func__, payload_size);
@ -841,9 +843,14 @@ int send_adm_apr(void *buf, u32 opcode)
buf + 3 * sizeof(u32), payload_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
result = -EINVAL;
result = -EFAULT;
goto err;
}
break;
default:
pr_err("%s: Invalid opcode %d\n", __func__, opcode);
result = -EINVAL;
goto err;
}
/* Pack header */
@ -904,33 +911,39 @@ int send_adm_apr(void *buf, u32 opcode)
if (opcode == ADM_CMD_GET_PP_PARAMS_V5) {
bytes_returned = ((u32 *)rtac_cal[ADM_RTAC_CAL].cal_data.
kvaddr)[2] + 3 * sizeof(u32);
if (bytes_returned > rtac_cal[ADM_RTAC_CAL].
map_data.map_size) {
pr_err("%s: Invalid data size = %d\n",
__func__, bytes_returned);
result = -EINVAL;
goto err;
}
if (bytes_returned > user_buf_size) {
pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
__func__, user_buf_size, bytes_returned);
result = -EINVAL;
goto err;
}
if (copy_to_user(buf, (void *)
rtac_cal[ADM_RTAC_CAL].cal_data.kvaddr,
bytes_returned)) {
pr_err("%s: Could not copy buffer to user,size = %d\n",
__func__, bytes_returned);
result = -EINVAL;
goto err;
}
} else if (opcode == ADM_CMD_GET_PP_PARAMS_V6) {
bytes_returned =
((u32 *) rtac_cal[ADM_RTAC_CAL].cal_data.kvaddr)[3] +
4 * sizeof(u32);
} else {
bytes_returned = data_size;
goto unlock;
}
if (bytes_returned > rtac_cal[ADM_RTAC_CAL].map_data.map_size) {
pr_err("%s: Invalid data size = %d\n", __func__,
bytes_returned);
result = -EINVAL;
goto err;
}
if (bytes_returned > user_buf_size) {
pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
__func__, user_buf_size, bytes_returned);
result = -EINVAL;
goto err;
}
if (copy_to_user((void __user *) buf,
rtac_cal[ADM_RTAC_CAL].cal_data.kvaddr,
bytes_returned)) {
pr_err("%s: Could not copy buffer to user,size = %d\n",
__func__, bytes_returned);
result = -EFAULT;
goto err;
}
unlock:
mutex_unlock(&rtac_adm_apr_mutex);
done:
return bytes_returned;
@ -1032,7 +1045,9 @@ int send_rtac_asm_apr(void *buf, u32 opcode)
goto err;
}
if (opcode == ASM_STREAM_CMD_SET_PP_PARAMS_V2) {
switch (opcode) {
case ASM_STREAM_CMD_SET_PP_PARAMS_V2:
case ASM_STREAM_CMD_SET_PP_PARAMS_V3:
/* set payload size to in-band payload */
/* set data size to actual out of band payload size */
data_size = payload_size - 4 * sizeof(u32);
@ -1050,13 +1065,14 @@ int send_rtac_asm_apr(void *buf, u32 opcode)
buf + 7 * sizeof(u32), data_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
result = -EINVAL;
result = -EFAULT;
goto err;
}
/* set payload size in packet */
rtac_asm_buffer[8] = data_size;
} else {
break;
case ASM_STREAM_CMD_GET_PP_PARAMS_V2:
case ASM_STREAM_CMD_GET_PP_PARAMS_V3:
if (payload_size > MAX_PAYLOAD_SIZE) {
pr_err("%s: Invalid payload size = %d\n",
__func__, payload_size);
@ -1070,9 +1086,15 @@ int send_rtac_asm_apr(void *buf, u32 opcode)
buf + 3 * sizeof(u32), payload_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
result = -EINVAL;
result = -EFAULT;
goto err;
}
break;
default:
pr_err("%s: Invalid opcode %d\n", __func__, opcode);
result = -EINVAL;
goto err;
}
/* Pack header */
@ -1135,33 +1157,39 @@ int send_rtac_asm_apr(void *buf, u32 opcode)
if (opcode == ASM_STREAM_CMD_GET_PP_PARAMS_V2) {
bytes_returned = ((u32 *)rtac_cal[ASM_RTAC_CAL].cal_data.
kvaddr)[2] + 3 * sizeof(u32);
if (bytes_returned > rtac_cal[ASM_RTAC_CAL].
map_data.map_size) {
pr_err("%s: Invalid data size = %d\n",
__func__, bytes_returned);
result = -EINVAL;
goto err;
}
if (bytes_returned > user_buf_size) {
pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
__func__, user_buf_size, bytes_returned);
result = -EINVAL;
goto err;
}
if (copy_to_user(buf, (void *)
rtac_cal[ASM_RTAC_CAL].cal_data.kvaddr,
bytes_returned)) {
pr_err("%s: Could not copy buffer to user,size = %d\n",
__func__, bytes_returned);
result = -EINVAL;
goto err;
}
} else if (opcode == ASM_STREAM_CMD_GET_PP_PARAMS_V3) {
bytes_returned =
((u32 *) rtac_cal[ASM_RTAC_CAL].cal_data.kvaddr)[3] +
4 * sizeof(u32);
} else {
bytes_returned = data_size;
goto unlock;
}
if (bytes_returned > rtac_cal[ASM_RTAC_CAL].map_data.map_size) {
pr_err("%s: Invalid data size = %d\n", __func__,
bytes_returned);
result = -EINVAL;
goto err;
}
if (bytes_returned > user_buf_size) {
pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
__func__, user_buf_size, bytes_returned);
result = -EINVAL;
goto err;
}
if (copy_to_user((void __user *) buf,
rtac_cal[ASM_RTAC_CAL].cal_data.kvaddr,
bytes_returned)) {
pr_err("%s: Could not copy buffer to user,size = %d\n",
__func__, bytes_returned);
result = -EFAULT;
goto err;
}
unlock:
mutex_unlock(&rtac_asm_apr_mutex);
done:
return bytes_returned;
@ -1218,13 +1246,18 @@ static int fill_afe_apr_hdr(struct apr_hdr *apr_hdr, uint32_t port,
return 0;
}
static int send_rtac_afe_apr(void *buf, uint32_t opcode)
static int send_rtac_afe_apr(void __user *buf, uint32_t opcode)
{
int32_t result;
uint32_t bytes_returned = 0;
uint32_t payload_size = 0;
uint32_t port_index = 0;
uint32_t *afe_cmd = NULL;
uint32_t apr_msg_size = 0;
struct rtac_afe_user_data user_afe_buf;
struct mem_mapping_hdr *mem_hdr = NULL;
struct param_hdr_v1 *get_resp_v2;
struct param_hdr_v3 *get_resp_v3;
pr_debug("%s\n", __func__);
@ -1272,95 +1305,126 @@ static int send_rtac_afe_apr(void *buf, uint32_t opcode)
result = -EINVAL;
goto err;
}
if (opcode == AFE_PORT_CMD_SET_PARAM_V2) {
struct afe_rtac_set_param_v2 *afe_set_apr_msg;
/* set data size to actual out of band payload size */
if (user_afe_buf.rtac_afe_set.cmd.payload_size >
rtac_cal[AFE_RTAC_CAL].map_data.map_size) {
pr_err("%s: Invalid data size = %d\n",
__func__,
user_afe_buf.rtac_afe_set.cmd.payload_size);
afe_cmd =
(u32 *) rtac_afe_buffer + sizeof(struct apr_hdr) / sizeof(u32);
switch (opcode) {
case AFE_PORT_CMD_SET_PARAM_V2:
apr_msg_size = sizeof(struct afe_port_cmd_set_param_v2);
payload_size = user_afe_buf.v2_set.payload_size;
if (payload_size > rtac_cal[AFE_RTAC_CAL].map_data.map_size) {
pr_err("%s: Invalid payload size = %d\n", __func__,
payload_size);
result = -EINVAL;
goto err;
}
/* Copy buffer to out-of-band payload */
if (copy_from_user(
(void *) rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
(void __user *) buf +
offsetof(struct rtac_afe_user_data,
rtac_afe_set.data),
user_afe_buf.rtac_afe_set.cmd.payload_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
result = -EINVAL;
goto err;
}
/* Copy the command to the rtac buffer */
memcpy(afe_cmd, &user_afe_buf.v2_set,
sizeof(user_afe_buf.v2_set));
/* Copy AFE APR Message */
afe_set_apr_msg = (struct afe_rtac_set_param_v2
*) ((u8 *) rtac_afe_buffer +
sizeof(struct apr_hdr));
if (copy_from_user((void *) afe_set_apr_msg,
/* Copy the param data to the out-of-band location */
if (copy_from_user(rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
(void __user *) buf +
offsetof(struct rtac_afe_user_data,
rtac_afe_set.cmd),
sizeof(struct afe_rtac_set_param_v2))) {
v2_set.param_hdr),
payload_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
result = -EFAULT;
goto err;
}
break;
case AFE_PORT_CMD_SET_PARAM_V3:
apr_msg_size = sizeof(struct afe_port_cmd_set_param_v3);
payload_size = user_afe_buf.v3_set.payload_size;
if (payload_size > rtac_cal[AFE_RTAC_CAL].map_data.map_size) {
pr_err("%s: Invalid payload size = %d\n", __func__,
payload_size);
result = -EINVAL;
goto err;
}
afe_set_apr_msg->payload_address_lsw =
lower_32_bits(rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
afe_set_apr_msg->payload_address_msw =
msm_audio_populate_upper_32_bits(
rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
afe_set_apr_msg->mem_map_handle =
rtac_cal[AFE_RTAC_CAL].map_data.map_handle;
/* Copy the command to the rtac buffer */
memcpy(afe_cmd, &user_afe_buf.v3_set,
sizeof(user_afe_buf.v3_set));
apr_msg_size = sizeof(struct apr_hdr) +
sizeof(struct afe_rtac_set_param_v2);
} else {
struct afe_rtac_get_param_v2 *afe_get_apr_msg;
/* Copy the param data to the out-of-band location */
if (copy_from_user(rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
(void __user *) buf +
offsetof(struct rtac_afe_user_data,
v3_get.param_hdr),
payload_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
result = -EFAULT;
goto err;
}
break;
case AFE_PORT_CMD_GET_PARAM_V2:
apr_msg_size = sizeof(struct afe_port_cmd_get_param_v2);
if (user_afe_buf.cmd_size > MAX_PAYLOAD_SIZE) {
pr_err("%s: Invalid payload size = %d\n",
__func__, user_afe_buf.cmd_size);
pr_err("%s: Invalid payload size = %d\n", __func__,
user_afe_buf.cmd_size);
result = -EINVAL;
goto err;
}
/* Copy buffer to in-band payload */
afe_get_apr_msg = (struct afe_rtac_get_param_v2
*) ((u8 *) rtac_afe_buffer +
sizeof(struct apr_hdr));
if (copy_from_user((void *) afe_get_apr_msg,
/* Copy the command and param data in-band */
if (copy_from_user(afe_cmd,
(void __user *) buf +
offsetof(struct rtac_afe_user_data,
rtac_afe_get.cmd),
sizeof(struct afe_rtac_get_param_v2))) {
v2_get),
user_afe_buf.cmd_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
__func__);
result = -EFAULT;
goto err;
}
break;
case AFE_PORT_CMD_GET_PARAM_V3:
apr_msg_size = sizeof(struct afe_port_cmd_get_param_v3);
if (user_afe_buf.cmd_size > MAX_PAYLOAD_SIZE) {
pr_err("%s: Invalid payload size = %d\n", __func__,
user_afe_buf.cmd_size);
result = -EINVAL;
goto err;
}
afe_get_apr_msg->payload_address_lsw =
lower_32_bits(rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
afe_get_apr_msg->payload_address_msw =
msm_audio_populate_upper_32_bits(
rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
afe_get_apr_msg->mem_map_handle =
rtac_cal[AFE_RTAC_CAL].map_data.map_handle;
afe_get_apr_msg->payload_size -= sizeof(struct apr_hdr);
apr_msg_size = sizeof(struct apr_hdr) +
sizeof(struct afe_rtac_get_param_v2);
/* Copy the command and param data in-band */
if (copy_from_user(afe_cmd,
(void __user *) buf +
offsetof(struct rtac_afe_user_data,
v3_get),
user_afe_buf.cmd_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
result = -EFAULT;
goto err;
}
break;
default:
pr_err("%s: Invalid opcode %d\n", __func__, opcode);
result = -EINVAL;
goto err;
}
/*
* The memory header is in the same location in all commands. Therefore,
* it doesn't matter what command the buffer is cast into.
*/
mem_hdr = &((struct afe_port_cmd_set_param_v3 *) rtac_afe_buffer)
->mem_hdr;
mem_hdr->data_payload_addr_lsw =
lower_32_bits(rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
mem_hdr->data_payload_addr_msw = msm_audio_populate_upper_32_bits(
rtac_cal[AFE_RTAC_CAL].cal_data.paddr);
mem_hdr->mem_map_handle = rtac_cal[AFE_RTAC_CAL].map_data.map_handle;
/* Fill the APR header at the end so we have the correct message size */
fill_afe_apr_hdr((struct apr_hdr *) rtac_afe_buffer,
port_index, opcode, apr_msg_size);
@ -1398,41 +1462,44 @@ static int send_rtac_afe_apr(void *buf, uint32_t opcode)
}
if (opcode == AFE_PORT_CMD_GET_PARAM_V2) {
struct param_hdr_v1 *get_resp;
get_resp = (struct param_hdr_v1 *) rtac_cal[AFE_RTAC_CAL]
.cal_data.kvaddr;
get_resp_v2 = (struct param_hdr_v1 *) rtac_cal[AFE_RTAC_CAL]
.cal_data.kvaddr;
bytes_returned =
get_resp->param_size + sizeof(struct param_hdr_v1);
if (bytes_returned > rtac_cal[AFE_RTAC_CAL].
map_data.map_size) {
pr_err("%s: Invalid data size = %d\n",
__func__, bytes_returned);
result = -EINVAL;
goto err;
}
if (bytes_returned > user_afe_buf.buf_size) {
pr_err("%s: user size = 0x%x, returned size = 0x%x\n",
__func__, user_afe_buf.buf_size,
bytes_returned);
result = -EINVAL;
goto err;
}
if (copy_to_user(buf, (void *)
rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
bytes_returned)) {
pr_err("%s: Could not copy buffer to user,size = %d\n",
__func__, bytes_returned);
result = -EINVAL;
goto err;
}
get_resp_v2->param_size + sizeof(struct param_hdr_v1);
} else if (opcode == AFE_PORT_CMD_GET_PARAM_V3) {
get_resp_v3 = (struct param_hdr_v3 *) rtac_cal[AFE_RTAC_CAL]
.cal_data.kvaddr;
bytes_returned =
get_resp_v3->param_size + sizeof(struct param_hdr_v3);
} else {
bytes_returned = user_afe_buf.rtac_afe_set.cmd.payload_size;
bytes_returned = payload_size;
goto unlock;
}
if (bytes_returned > rtac_cal[AFE_RTAC_CAL].map_data.map_size) {
pr_err("%s: Invalid data size = %d\n", __func__,
bytes_returned);
result = -EINVAL;
goto err;
}
if (bytes_returned > user_afe_buf.buf_size) {
pr_err("%s: user size = 0x%x, returned size = 0x%x\n", __func__,
user_afe_buf.buf_size, bytes_returned);
result = -EINVAL;
goto err;
}
if (copy_to_user((void __user *) buf,
rtac_cal[AFE_RTAC_CAL].cal_data.kvaddr,
bytes_returned)) {
pr_err("%s: Could not copy buffer to user,size = %d\n",
__func__, bytes_returned);
result = -EFAULT;
goto err;
}
unlock:
mutex_unlock(&rtac_afe_apr_mutex);
done:
return bytes_returned;
@ -1535,7 +1602,9 @@ int send_voice_apr(u32 mode, void *buf, u32 opcode)
goto err;
}
if (opcode == VSS_ICOMMON_CMD_SET_PARAM_V2) {
switch (opcode) {
case VSS_ICOMMON_CMD_SET_PARAM_V2:
case VSS_ICOMMON_CMD_SET_PARAM_V3:
/* set payload size to in-band payload */
/* set data size to actual out of band payload size */
data_size = payload_size - 4 * sizeof(u32);
@ -1553,12 +1622,16 @@ int send_voice_apr(u32 mode, void *buf, u32 opcode)
buf + 7 * sizeof(u32), data_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
result = -EINVAL;
result = -EFAULT;
goto err;
}
/* set payload size in packet */
rtac_voice_buffer[8] = data_size;
} else {
/* set token for set param case */
voice_params.token = VOC_RTAC_SET_PARAM_TOKEN;
break;
case VSS_ICOMMON_CMD_GET_PARAM_V2:
case VSS_ICOMMON_CMD_GET_PARAM_V3:
if (payload_size > MAX_PAYLOAD_SIZE) {
pr_err("%s: Invalid payload size = %d\n",
__func__, payload_size);
@ -1572,9 +1645,16 @@ int send_voice_apr(u32 mode, void *buf, u32 opcode)
buf + 3 * sizeof(u32), payload_size)) {
pr_err("%s: Could not copy payload from user buffer\n",
__func__);
result = -EINVAL;
result = -EFAULT;
goto err;
}
/* set token for get param case */
voice_params.token = 0;
break;
default:
pr_err("%s: Invalid opcode %d\n", __func__, opcode);
result = -EINVAL;
goto err;
}
/* Pack header */
@ -1588,18 +1668,14 @@ int send_voice_apr(u32 mode, void *buf, u32 opcode)
voice_params.dest_svc = 0;
voice_params.dest_domain = APR_DOMAIN_MODEM;
voice_params.dest_port = (u16)dest_port;
voice_params.token = (opcode == VSS_ICOMMON_CMD_SET_PARAM_V2) ?
VOC_RTAC_SET_PARAM_TOKEN :
0;
voice_params.opcode = opcode;
/* fill for out-of-band */
rtac_voice_buffer[5] = rtac_cal[VOICE_RTAC_CAL].map_data.map_handle;
rtac_voice_buffer[6] =
lower_32_bits(rtac_cal[VOICE_RTAC_CAL].cal_data.paddr);
rtac_voice_buffer[7] =
msm_audio_populate_upper_32_bits(
rtac_cal[VOICE_RTAC_CAL].cal_data.paddr);
rtac_voice_buffer[7] = msm_audio_populate_upper_32_bits(
rtac_cal[VOICE_RTAC_CAL].cal_data.paddr);
memcpy(rtac_voice_buffer, &voice_params, sizeof(voice_params));
atomic_set(&rtac_voice_apr_data[mode].cmd_state, 1);
@ -1638,33 +1714,39 @@ int send_voice_apr(u32 mode, void *buf, u32 opcode)
if (opcode == VSS_ICOMMON_CMD_GET_PARAM_V2) {
bytes_returned = ((u32 *)rtac_cal[VOICE_RTAC_CAL].cal_data.
kvaddr)[2] + 3 * sizeof(u32);
if (bytes_returned > rtac_cal[VOICE_RTAC_CAL].
map_data.map_size) {
pr_err("%s: Invalid data size = %d\n",
__func__, bytes_returned);
result = -EINVAL;
goto err;
}
if (bytes_returned > user_buf_size) {
pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
__func__, user_buf_size, bytes_returned);
result = -EINVAL;
goto err;
}
if (copy_to_user(buf, (void *)
rtac_cal[VOICE_RTAC_CAL].cal_data.kvaddr,
bytes_returned)) {
pr_err("%s: Could not copy buffer to user, size = %d\n",
__func__, bytes_returned);
result = -EINVAL;
goto err;
}
} else if (opcode == VSS_ICOMMON_CMD_GET_PARAM_V3) {
bytes_returned =
((u32 *) rtac_cal[VOICE_RTAC_CAL].cal_data.kvaddr)[3] +
4 * sizeof(u32);
} else {
bytes_returned = data_size;
goto unlock;
}
if (bytes_returned > rtac_cal[VOICE_RTAC_CAL].map_data.map_size) {
pr_err("%s: Invalid data size = %d\n", __func__,
bytes_returned);
result = -EINVAL;
goto err;
}
if (bytes_returned > user_buf_size) {
pr_err("%s: User buf not big enough, size = 0x%x, returned size = 0x%x\n",
__func__, user_buf_size, bytes_returned);
result = -EINVAL;
goto err;
}
if (copy_to_user((void __user *) buf,
rtac_cal[VOICE_RTAC_CAL].cal_data.kvaddr,
bytes_returned)) {
pr_err("%s: Could not copy buffer to user, size = %d\n",
__func__, bytes_returned);
result = -EFAULT;
goto err;
}
unlock:
mutex_unlock(&rtac_voice_apr_mutex);
done:
return bytes_returned;
@ -1684,8 +1766,8 @@ void get_rtac_adm_data(struct rtac_adm *adm_data)
static long rtac_ioctl_shared(struct file *f,
unsigned int cmd, void *arg)
{
u32 opcode;
int result = 0;
if (!arg) {
pr_err("%s: No data sent to driver!\n", __func__);
result = -EFAULT;
@ -1721,42 +1803,64 @@ static long rtac_ioctl_shared(struct file *f,
}
case AUDIO_GET_RTAC_ADM_CAL:
result = send_adm_apr((void *)arg, ADM_CMD_GET_PP_PARAMS_V5);
opcode = q6common_is_instance_id_supported() ?
ADM_CMD_GET_PP_PARAMS_V6 :
ADM_CMD_GET_PP_PARAMS_V5;
result = send_adm_apr((void *) arg, opcode);
break;
case AUDIO_SET_RTAC_ADM_CAL:
result = send_adm_apr((void *)arg, ADM_CMD_SET_PP_PARAMS_V5);
opcode = q6common_is_instance_id_supported() ?
ADM_CMD_SET_PP_PARAMS_V6 :
ADM_CMD_SET_PP_PARAMS_V5;
result = send_adm_apr((void *) arg, opcode);
break;
case AUDIO_GET_RTAC_ASM_CAL:
result = send_rtac_asm_apr((void *)arg,
ASM_STREAM_CMD_GET_PP_PARAMS_V2);
opcode = q6common_is_instance_id_supported() ?
ASM_STREAM_CMD_GET_PP_PARAMS_V3 :
ASM_STREAM_CMD_GET_PP_PARAMS_V2;
result = send_rtac_asm_apr((void *) arg, opcode);
break;
case AUDIO_SET_RTAC_ASM_CAL:
result = send_rtac_asm_apr((void *)arg,
ASM_STREAM_CMD_SET_PP_PARAMS_V2);
opcode = q6common_is_instance_id_supported() ?
ASM_STREAM_CMD_SET_PP_PARAMS_V3 :
ASM_STREAM_CMD_SET_PP_PARAMS_V2;
result = send_rtac_asm_apr((void *) arg, opcode);
break;
case AUDIO_GET_RTAC_CVS_CAL:
result = send_voice_apr(RTAC_CVS, (void *) arg,
VSS_ICOMMON_CMD_GET_PARAM_V2);
opcode = q6common_is_instance_id_supported() ?
VSS_ICOMMON_CMD_GET_PARAM_V3 :
VSS_ICOMMON_CMD_GET_PARAM_V2;
result = send_voice_apr(RTAC_CVS, (void *) arg, opcode);
break;
case AUDIO_SET_RTAC_CVS_CAL:
result = send_voice_apr(RTAC_CVS, (void *) arg,
VSS_ICOMMON_CMD_SET_PARAM_V2);
opcode = q6common_is_instance_id_supported() ?
VSS_ICOMMON_CMD_SET_PARAM_V3 :
VSS_ICOMMON_CMD_SET_PARAM_V2;
result = send_voice_apr(RTAC_CVS, (void *) arg, opcode);
break;
case AUDIO_GET_RTAC_CVP_CAL:
result = send_voice_apr(RTAC_CVP, (void *) arg,
VSS_ICOMMON_CMD_GET_PARAM_V2);
opcode = q6common_is_instance_id_supported() ?
VSS_ICOMMON_CMD_GET_PARAM_V3 :
VSS_ICOMMON_CMD_GET_PARAM_V2;
result = send_voice_apr(RTAC_CVP, (void *) arg, opcode);
break;
case AUDIO_SET_RTAC_CVP_CAL:
result = send_voice_apr(RTAC_CVP, (void *) arg,
VSS_ICOMMON_CMD_SET_PARAM_V2);
opcode = q6common_is_instance_id_supported() ?
VSS_ICOMMON_CMD_SET_PARAM_V3 :
VSS_ICOMMON_CMD_SET_PARAM_V2;
result = send_voice_apr(RTAC_CVP, (void *) arg, opcode);
break;
case AUDIO_GET_RTAC_AFE_CAL:
result = send_rtac_afe_apr((void *)arg,
AFE_PORT_CMD_GET_PARAM_V2);
opcode = q6common_is_instance_id_supported() ?
AFE_PORT_CMD_GET_PARAM_V3 :
AFE_PORT_CMD_GET_PARAM_V2;
result = send_rtac_afe_apr((void __user *) arg, opcode);
break;
case AUDIO_SET_RTAC_AFE_CAL:
result = send_rtac_afe_apr((void *)arg,
AFE_PORT_CMD_SET_PARAM_V2);
opcode = q6common_is_instance_id_supported() ?
AFE_PORT_CMD_SET_PARAM_V3 :
AFE_PORT_CMD_SET_PARAM_V2;
result = send_rtac_afe_apr((void __user *) arg, opcode);
break;
default:
pr_err("%s: Invalid IOCTL, command = %d!\n",

View file

@ -498,55 +498,40 @@ struct adm_cmd_device_open_v6 {
/* Sets one or more parameters to a COPP. */
#define ADM_CMD_SET_PP_PARAMS_V5 0x00010328
#define ADM_CMD_SET_PP_PARAMS_V6 0x0001035D
/* Payload of the #ADM_CMD_SET_PP_PARAMS_V5 command.
* If the data_payload_addr_lsw and data_payload_addr_msw element
* are NULL, a series of adm_param_datastructures immediately
* follows, whose total size is data_payload_size bytes.
/*
* Structure of the ADM Set PP Params command. Parameter data must be
* pre-packed with correct header for either V2 or V3 when sent in-band.
* Use q6core_pack_pp_params to pack the header and data correctly depending on
* Instance ID support.
*/
struct adm_cmd_set_pp_params_v5 {
struct apr_hdr hdr;
u32 payload_addr_lsw;
/* LSW of parameter data payload address. */
u32 payload_addr_msw;
/* MSW of parameter data payload address. */
struct adm_cmd_set_pp_params {
/* APR Header */
struct apr_hdr apr_hdr;
u32 mem_map_handle;
/* Memory map handle returned by ADM_CMD_SHARED_MEM_MAP_REGIONS
* command
*
* If mem_map_handle is zero implies the message is in
* the payload
*/
/* The memory mapping header to be used when sending out of band */
struct mem_mapping_hdr mem_hdr;
u32 payload_size;
/* Size in bytes of the variable payload accompanying this
* message or
* in shared memory. This is used for parsing the parameter
* payload.
*/
/*
* Size in bytes of the variable payload accompanying this
* message or
* in shared memory. This is used for parsing the parameter
* payload.
*/
u32 payload_size;
/*
* Parameter data for in band payload. This should be structured as the
* parameter header immediately followed by the parameter data. Multiple
* parameters can be set in one command by repeating the header followed
* by the data for as many parameters as need to be set.
* Use q6core_pack_pp_params to pack the header and data correctly
* depending on Instance ID support.
*/
u8 param_data[0];
} __packed;
/* Payload format for COPP parameter data.
* Immediately following this structure are param_size bytes
* of parameter
* data.
*/
struct adm_param_data_v5 {
u32 module_id;
/* Unique ID of the module. */
u32 param_id;
/* Unique ID of the parameter. */
u16 param_size;
/* Data size of the param_id/module_id combination.
* This value is a
* multiple of 4 bytes.
*/
u16 reserved;
/* Reserved for future enhancements.
* This field must be set to zero.
*/
} __packed;
#define ASM_STREAM_CMD_REGISTER_PP_EVENTS 0x00013213
#define ASM_STREAM_PP_EVENT 0x00013214
@ -590,25 +575,6 @@ struct adm_cmd_set_pspd_mtmx_strtr_params_v5 {
u16 reserved;
} __packed;
/* Defined specifically for in-band use, includes params */
struct adm_cmd_set_pp_params_inband_v5 {
struct apr_hdr hdr;
/* LSW of parameter data payload address.*/
u32 payload_addr_lsw;
/* MSW of parameter data payload address.*/
u32 payload_addr_msw;
/* Memory map handle returned by ADM_CMD_SHARED_MEM_MAP_REGIONS */
/* command. If mem_map_handle is zero implies the message is in */
/* the payload */
u32 mem_map_handle;
/* Size in bytes of the variable payload accompanying this */
/* message or in shared memory. This is used for parsing the */
/* parameter payload. */
u32 payload_size;
/* Parameters passed for in band payload */
struct adm_param_data_v5 params;
} __packed;
/* Returns the status and COPP ID to an #ADM_CMD_DEVICE_OPEN_V5 command.
*/
#define ADM_CMDRSP_DEVICE_OPEN_V5 0x00010329
@ -639,43 +605,21 @@ struct adm_cmd_rsp_device_open_v5 {
/* This command allows a query of one COPP parameter. */
#define ADM_CMD_GET_PP_PARAMS_V5 0x0001032A
#define ADM_CMD_GET_PP_PARAMS_V6 0x0001035E
/* Payload an #ADM_CMD_GET_PP_PARAMS_V5 command. */
struct adm_cmd_get_pp_params_v5 {
struct apr_hdr hdr;
u32 data_payload_addr_lsw;
/* LSW of parameter data payload address.*/
/*
* Structure of the ADM Get PP Params command. Parameter header must be
* packed correctly for either V2 or V3. Use q6core_pack_pp_params to pack the
* header correctly depending on Instance ID support.
*/
struct adm_cmd_get_pp_params {
struct apr_hdr apr_hdr;
u32 data_payload_addr_msw;
/* MSW of parameter data payload address.*/
/* The memory mapping header to be used when requesting outband */
struct mem_mapping_hdr mem_hdr;
/* If the mem_map_handle is non zero,
* on ACK, the ParamData payloads begin at
* the address specified (out-of-band).
*/
u32 mem_map_handle;
/* Memory map handle returned
* by ADM_CMD_SHARED_MEM_MAP_REGIONS command.
* If the mem_map_handle is 0, it implies that
* the ACK's payload will contain the ParamData (in-band).
*/
u32 module_id;
/* Unique ID of the module. */
u32 param_id;
/* Unique ID of the parameter. */
u16 param_max_size;
/* Maximum data size of the parameter
*ID/module ID combination. This
* field is a multiple of 4 bytes.
*/
u16 reserved;
/* Reserved for future enhancements.
* This field must be set to zero.
*/
/* Parameter header for in band payload. */
union param_hdrs param_hdr;
} __packed;
/* Returns parameter values
@ -687,15 +631,49 @@ struct adm_cmd_get_pp_params_v5 {
* which returns parameter values in response
* to an #ADM_CMD_GET_PP_PARAMS_V5 command.
* Immediately following this
* structure is the adm_param_data_v5
* structure is the param_hdr_v1
* structure containing the pre/postprocessing
* parameter data. For an in-band
* scenario, the variable payload depends
* on the size of the parameter.
*/
struct adm_cmd_rsp_get_pp_params_v5 {
u32 status;
/* Status message (error code).*/
u32 status;
/* The header that identifies the subsequent parameter data */
struct param_hdr_v1 param_hdr;
/* The parameter data returned */
u32 param_data[0];
} __packed;
/*
* Returns parameter values in response to an #ADM_CMD_GET_PP_PARAMS_V5/6
* command.
*/
#define ADM_CMDRSP_GET_PP_PARAMS_V6 0x0001035F
/*
* Payload of the #ADM_CMDRSP_GET_PP_PARAMS_V6 message,
* which returns parameter values in response
* to an #ADM_CMD_GET_PP_PARAMS_V6 command.
* Immediately following this
* structure is the param_hdr_v3
* structure containing the pre/postprocessing
* parameter data. For an in-band
* scenario, the variable payload depends
* on the size of the parameter.
*/
struct adm_cmd_rsp_get_pp_params_v6 {
/* Status message (error code).*/
u32 status;
/* The header that identifies the subsequent parameter data */
struct param_hdr_v3 param_hdr;
/* The parameter data returned */
u32 param_data[0];
} __packed;
/* Structure for holding soft stepping volume parameters. */
@ -728,9 +706,40 @@ struct audproc_softvolume_params {
#define AUDPROC_CHMIXER_PARAM_ID_COEFF 0x00010342
struct adm_cmd_set_pp_params_v5 {
struct apr_hdr hdr;
u32 payload_addr_lsw;
/* LSW of parameter data payload address.*/
u32 payload_addr_msw;
/* MSW of parameter data payload address.*/
u32 mem_map_handle;
/*
* Memory map handle returned by ADM_CMD_SHARED_MEM_MAP_REGIONS
* command.
* If mem_map_handle is zero implies the message is in
* the payload
*/
u32 payload_size;
/*
* Size in bytes of the variable payload accompanying this
* message or
* in shared memory. This is used for parsing the parameter
* payload.
*/
} __packed;
struct audproc_mfc_output_media_fmt {
struct adm_cmd_set_pp_params_v5 params;
struct adm_param_data_v5 data;
struct param_hdr_v1 data;
uint32_t sampling_rate;
uint16_t bits_per_sample;
uint16_t num_channels;
uint16_t channel_type[8];
} __packed;
struct audproc_mfc_param_media_fmt {
uint32_t sampling_rate;
uint16_t bits_per_sample;
uint16_t num_channels;
@ -738,8 +747,6 @@ struct audproc_mfc_output_media_fmt {
} __packed;
struct audproc_volume_ctrl_master_gain {
struct adm_cmd_set_pp_params_v5 params;
struct adm_param_data_v5 data;
/* Linear gain in Q13 format. */
uint16_t master_gain;
/* Clients must set this field to zero. */
@ -747,8 +754,6 @@ struct audproc_volume_ctrl_master_gain {
} __packed;
struct audproc_soft_step_volume_params {
struct adm_cmd_set_pp_params_v5 params;
struct adm_param_data_v5 data;
/*
* Period in milliseconds.
* Supported values: 0 to 15000
@ -770,7 +775,6 @@ struct audproc_soft_step_volume_params {
} __packed;
struct audproc_enable_param_t {
struct adm_cmd_set_pp_params_inband_v5 pp_params;
/*
* Specifies whether the Audio processing module is enabled.
* This parameter is generic/common parameter to configure or
@ -1534,46 +1538,79 @@ struct afe_sidetone_iir_filter_config_params {
#define AFE_PARAM_ID_LOOPBACK_GAIN_PER_PATH 0x00010206
/* Used by RTAC */
struct afe_rtac_set_param_v2 {
struct afe_rtac_user_data_set_v2 {
/* Port interface and direction (Rx or Tx) to start. */
u16 port_id;
/* Port interface and direction (Rx or Tx) to start. */
/* Actual size of the payload in bytes.
* This is used for parsing the parameter payload.
* Supported values: > 0
*/
u16 payload_size;
/* Actual size of the payload in bytes.
* This is used for parsing the parameter payload.
* Supported values: > 0
*/
u32 payload_address_lsw;
/* LSW of 64 bit Payload address.
* Address should be 32-byte,
* 4kbyte aligned and must be contiguous memory.
*/
/* The header detailing the memory mapping for out of band. */
struct mem_mapping_hdr mem_hdr;
u32 payload_address_msw;
/* MSW of 64 bit Payload address.
* In case of 32-bit shared memory address,
* this field must be set to zero.
* In case of 36-bit shared memory address,
* bit-4 to bit-31 must be set to zero.
* Address should be 32-byte, 4kbyte aligned
* and must be contiguous memory.
*/
/* The parameter header for the parameter data to set */
struct param_hdr_v1 param_hdr;
u32 mem_map_handle;
/* Memory map handle returned by
* AFE_SERVICE_CMD_SHARED_MEM_MAP_REGIONS commands.
* Supported Values:
* - NULL -- Message. The parameter data is in-band.
* - Non-NULL -- The parameter data is Out-band.Pointer to
* the physical address
* in shared memory of the payload data.
* An optional field is available if parameter
* data is in-band:
* afe_param_data_v2 param_data[...].
* For detailed payload content, see the
* afe_port_param_data_v2 structure.
*/
/* The parameter data to be filled when sent inband */
u32 *param_data;
} __packed;
struct afe_rtac_user_data_set_v3 {
/* Port interface and direction (Rx or Tx) to start. */
u16 port_id;
/* Reserved for future enhancements. Must be 0. */
u16 reserved;
/* The header detailing the memory mapping for out of band. */
struct mem_mapping_hdr mem_hdr;
/* The size of the parameter header and parameter data */
u32 payload_size;
/* The parameter header for the parameter data to set */
struct param_hdr_v3 param_hdr;
/* The parameter data to be filled when sent inband */
u32 *param_data;
} __packed;
struct afe_rtac_user_data_get_v2 {
/* Port interface and direction (Rx or Tx) to start. */
u16 port_id;
/* Actual size of the payload in bytes.
* This is used for parsing the parameter payload.
* Supported values: > 0
*/
u16 payload_size;
/* The header detailing the memory mapping for out of band. */
struct mem_mapping_hdr mem_hdr;
/* The module ID of the parameter to get */
u32 module_id;
/* The parameter ID of the parameter to get */
u32 param_id;
/* The parameter data to be filled when sent inband */
struct param_hdr_v1 param_hdr;
} __packed;
struct afe_rtac_user_data_get_v3 {
/* Port interface and direction (Rx or Tx) to start. */
u16 port_id;
/* Reserved for future enhancements. Must be 0. */
u16 reserved;
/* The header detailing the memory mapping for out of band. */
struct mem_mapping_hdr mem_hdr;
/* The parameter data to be filled when sent inband */
struct param_hdr_v3 param_hdr;
} __packed;
#define AFE_PORT_CMD_SET_PARAM_V2 0x000100EF
@ -6571,6 +6608,7 @@ struct asm_stream_cmd_open_transcode_loopback_t {
#define ASM_STREAM_CMD_FLUSH_READBUFS 0x00010C09
#define ASM_STREAM_CMD_SET_PP_PARAMS_V2 0x00010DA1
#define ASM_STREAM_CMD_SET_PP_PARAMS_V3 0x0001320D
struct asm_stream_cmd_set_pp_params_v2 {
u32 data_payload_addr_lsw;
@ -6624,6 +6662,7 @@ struct asm_stream_param_data_v2 {
} __packed;
#define ASM_STREAM_CMD_GET_PP_PARAMS_V2 0x00010DA2
#define ASM_STREAM_CMD_GET_PP_PARAMS_V3 0x0001320E
struct asm_stream_cmd_get_pp_params_v2 {
u32 data_payload_addr_lsw;
@ -6801,6 +6840,7 @@ struct asm_aac_dual_mono_mapping_param {
} __packed;
#define ASM_STREAM_CMDRSP_GET_PP_PARAMS_V2 0x00010DA4
#define ASM_STREAM_CMDRSP_GET_PP_PARAMS_V3 0x0001320F
struct asm_stream_cmdrsp_get_pp_params_v2 {
u32 status;
@ -7576,12 +7616,6 @@ struct admx_mic_gain {
/*< Clients must set this field to zero. */
} __packed;
struct adm_set_mic_gain_params {
struct adm_cmd_set_pp_params_v5 params;
struct adm_param_data_v5 data;
struct admx_mic_gain mic_gain_data;
} __packed;
/* end_addtogroup audio_pp_param_ids */
/* @ingroup audio_pp_module_ids
@ -7939,56 +7973,23 @@ struct adm_qensemble_param_set_new_angle {
#define ADM_CMD_GET_PP_TOPO_MODULE_LIST 0x00010349
#define ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST 0x00010350
#define ADM_CMD_GET_PP_TOPO_MODULE_LIST_V2 0x00010360
#define ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST_V2 0x00010361
#define AUDPROC_PARAM_ID_ENABLE 0x00010904
/*
* Payload of the ADM_CMD_GET_PP_TOPO_MODULE_LIST command.
*/
struct adm_cmd_get_pp_topo_module_list_t {
struct apr_hdr hdr;
/* Lower 32 bits of the 64-bit parameter data payload address. */
uint32_t data_payload_addr_lsw;
/*
* Upper 32 bits of the 64-bit parameter data payload address.
*
*
* The size of the shared memory, if specified, must be large enough to
* contain the entire parameter data payload, including the module ID,
* parameter ID, parameter size, and parameter values.
*/
uint32_t data_payload_addr_msw;
/*
* Unique identifier for an address.
*
* This memory map handle is returned by the aDSP through the
* #ADM_CMD_SHARED_MEM_MAP_REGIONS command.
*
* @values
* - Non-NULL -- On acknowledgment, the parameter data payloads begin at
* the address specified (out-of-band)
* - NULL -- The acknowledgment's payload contains the parameter data
* (in-band) @tablebulletend
*/
uint32_t mem_map_handle;
/*
* Payload of the ADM_CMD_GET_PP_TOPO_MODULE_LIST command.
*/
struct adm_cmd_get_pp_topo_module_list {
struct apr_hdr apr_hdr;
/* The memory mapping header to be used when requesting out of band */
struct mem_mapping_hdr mem_hdr;
/*
* Maximum data size of the list of modules. This
* field is a multiple of 4 bytes.
*/
uint16_t param_max_size;
/* This field must be set to zero. */
uint16_t reserved;
} __packed;
/*
* Payload of the ADM_CMDRSP_GET_PP_TOPO_MODULE_LIST message, which returns
* module ids in response to an ADM_CMD_GET_PP_TOPO_MODULE_LIST command.
* Immediately following this structure is the acknowledgment <b>module id
* data variable payload</b> containing the pre/postprocessing module id
* values. For an in-band scenario, the variable payload depends on the size
* of the parameter.
*/
struct adm_cmd_rsp_get_pp_topo_module_list_t {
/* Status message (error code). */
uint32_t status;
uint32_t param_max_size;
} __packed;
struct audproc_topology_module_id_info_t {
@ -10888,18 +10889,14 @@ enum {
#define AUDPROC_PARAM_ID_COMPRESSED_MUTE 0x00010771
struct adm_set_compressed_device_mute {
struct adm_cmd_set_pp_params_v5 command;
struct adm_param_data_v5 params;
u32 mute_on;
u32 mute_on;
} __packed;
#define AUDPROC_MODULE_ID_COMPRESSED_LATENCY 0x0001076E
#define AUDPROC_PARAM_ID_COMPRESSED_LATENCY 0x0001076F
struct adm_set_compressed_device_latency {
struct adm_cmd_set_pp_params_v5 command;
struct adm_param_data_v5 params;
u32 latency;
u32 latency;
} __packed;
#define VOICEPROC_MODULE_ID_GENERIC_TX 0x00010EF6
@ -10929,12 +10926,6 @@ struct adm_param_fluence_soundfocus_t {
uint16_t reserved;
} __packed;
struct adm_set_fluence_soundfocus_param {
struct adm_cmd_set_pp_params_v5 params;
struct adm_param_data_v5 data;
struct adm_param_fluence_soundfocus_t soundfocus_data;
} __packed;
struct adm_param_fluence_sourcetracking_t {
uint8_t vad[MAX_SECTORS];
uint16_t doa_speech;
@ -10964,10 +10955,4 @@ struct admx_sec_primary_mic_ch {
uint16_t reserved1;
} __packed;
struct adm_set_sec_primary_ch_params {
struct adm_cmd_set_pp_params_v5 params;
struct adm_param_data_v5 data;
struct admx_sec_primary_mic_ch sec_primary_mic_ch_data;
} __packed;
#endif /*_APR_AUDIO_V2_H_ */

View file

@ -25,6 +25,8 @@
#define MAX_MODULES_IN_TOPO 16
#define ADM_GET_TOPO_MODULE_LIST_LENGTH\
((MAX_MODULES_IN_TOPO + 1) * sizeof(uint32_t))
#define ADM_GET_TOPO_MODULE_INSTANCE_LIST_LENGTH \
((MAX_MODULES_IN_TOPO + 1) * 2 * sizeof(uint32_t))
#define AUD_PROC_BLOCK_SIZE 4096
#define AUD_VOL_BLOCK_SIZE 4096
#define AUDIO_RX_CALIBRATION_SIZE (AUD_PROC_BLOCK_SIZE + \
@ -94,12 +96,24 @@ void adm_copp_mfc_cfg(int port_id, int copp_idx, int dst_sample_rate);
int adm_get_params(int port_id, int copp_idx, uint32_t module_id,
uint32_t param_id, uint32_t params_length, char *params);
int adm_get_pp_params(int port_id, int copp_idx, uint32_t client_id,
struct mem_mapping_hdr *mem_hdr,
struct param_hdr_v3 *param_hdr, u8 *returned_param_data);
int adm_send_params_v5(int port_id, int copp_idx, char *params,
uint32_t params_length);
int adm_dolby_dap_send_params(int port_id, int copp_idx, char *params,
uint32_t params_length);
int adm_set_pp_params(int port_id, int copp_idx,
struct mem_mapping_hdr *mem_hdr, u8 *param_data,
u32 params_size);
int adm_pack_and_set_one_pp_param(int port_id, int copp_idx,
struct param_hdr_v3 param_hdr,
u8 *param_data);
int adm_open(int port, int path, int rate, int mode, int topology,
int perf_mode, uint16_t bits_per_sample,
int app_type, int acdbdev_id);
@ -146,6 +160,10 @@ int adm_set_stereo_to_custom_stereo(int port_id, int copp_idx,
int adm_get_pp_topo_module_list(int port_id, int copp_idx, int32_t param_length,
char *params);
int adm_get_pp_topo_module_list_v2(int port_id, int copp_idx,
int32_t param_length,
int32_t *returned_params);
int adm_set_volume(int port_id, int copp_idx, int volume);
int adm_set_softvolume(int port_id, int copp_idx,
@ -158,6 +176,9 @@ int adm_send_set_multichannel_ec_primary_mic_ch(int port_id, int copp_idx,
int adm_param_enable(int port_id, int copp_idx, int module_id, int enable);
int adm_param_enable_v2(int port_id, int copp_idx,
struct module_instance_info mod_inst_info, int enable);
int adm_send_calibration(int port_id, int copp_idx, int path, int perf_mode,
int cal_type, char *params, int size);