summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sound/apr_audio-v2.h3
-rw-r--r--sound/soc/msm/qdsp6v2/msm-pcm-voice-v2.c6
-rw-r--r--sound/soc/msm/qdsp6v2/q6voice.c454
-rw-r--r--sound/soc/msm/qdsp6v2/q6voice.h85
4 files changed, 328 insertions, 220 deletions
diff --git a/include/sound/apr_audio-v2.h b/include/sound/apr_audio-v2.h
index 5e4bd0113884..3360e4eccb44 100644
--- a/include/sound/apr_audio-v2.h
+++ b/include/sound/apr_audio-v2.h
@@ -8791,6 +8791,9 @@ struct asm_eq_params {
#define VSS_ICOMMON_CMD_SET_PARAM_V2 0x0001133D
#define VSS_ICOMMON_CMD_GET_PARAM_V2 0x0001133E
#define VSS_ICOMMON_RSP_GET_PARAM 0x00011008
+#define VSS_ICOMMON_CMD_SET_PARAM_V3 0x00013245
+#define VSS_ICOMMON_CMD_GET_PARAM_V3 0x00013246
+#define VSS_ICOMMON_RSP_GET_PARAM_V3 0x00013247
/** ID of the Bass Boost module.
This module supports the following parameter IDs:
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-voice-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-voice-v2.c
index f3ec45b8f9b1..76d8f8d9e33c 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-voice-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-voice-v2.c
@@ -556,12 +556,14 @@ static int msm_voice_slowtalk_put(struct snd_kcontrol *kcontrol,
{
int st_enable = ucontrol->value.integer.value[0];
uint32_t session_id = ucontrol->value.integer.value[1];
+ struct module_instance_info mod_inst_info = {0};
pr_debug("%s: st enable=%d session_id=%#x\n", __func__, st_enable,
session_id);
- voc_set_pp_enable(session_id,
- MODULE_ID_VOICE_MODULE_ST, st_enable);
+ mod_inst_info.module_id = MODULE_ID_VOICE_MODULE_ST;
+ mod_inst_info.instance_id = INSTANCE_ID_0;
+ voc_set_pp_enable(session_id, mod_inst_info, st_enable);
return 0;
}
diff --git a/sound/soc/msm/qdsp6v2/q6voice.c b/sound/soc/msm/qdsp6v2/q6voice.c
index 01e31578f107..0ee5de66e453 100644
--- a/sound/soc/msm/qdsp6v2/q6voice.c
+++ b/sound/soc/msm/qdsp6v2/q6voice.c
@@ -24,6 +24,7 @@
#include "sound/q6audio-v2.h"
#include "sound/apr_audio-v2.h"
#include "sound/q6afe-v2.h"
+#include <sound/q6common.h>
#include <sound/audio_cal_utils.h>
#include "q6voice.h"
#include <sound/adsp_err.h>
@@ -93,8 +94,9 @@ static int32_t qdsp_mvm_callback(struct apr_client_data *data, void *priv);
static int32_t qdsp_cvs_callback(struct apr_client_data *data, void *priv);
static int32_t qdsp_cvp_callback(struct apr_client_data *data, void *priv);
-static int voice_send_set_pp_enable_cmd(struct voice_data *v,
- uint32_t module_id, int enable);
+static int voice_send_set_pp_enable_cmd(
+ struct voice_data *v, struct module_instance_info mod_inst_info,
+ int enable);
static int is_cal_memory_allocated(void);
static bool is_cvd_version_queried(void);
static int is_voip_memory_allocated(void);
@@ -126,6 +128,12 @@ static int voice_send_get_sound_focus_cmd(struct voice_data *v,
struct sound_focus_param *soundFocusData);
static int voice_send_get_source_tracking_cmd(struct voice_data *v,
struct source_tracking_param *sourceTrackingData);
+static int voice_pack_and_set_cvp_param(struct voice_data *v,
+ struct param_hdr_v3 param_hdr,
+ u8 *param_data);
+static int voice_pack_and_set_cvs_ui_property(struct voice_data *v,
+ struct param_hdr_v3 param_hdr,
+ u8 *param_data);
static void voice_itr_init(struct voice_session_itr *itr,
u32 session_id)
@@ -1451,70 +1459,29 @@ fail:
return ret;
}
-static int voice_send_set_pp_enable_cmd(struct voice_data *v,
- uint32_t module_id, int enable)
+static int voice_send_set_pp_enable_cmd(
+ struct voice_data *v, struct module_instance_info mod_inst_info,
+ int enable)
{
- struct cvs_set_pp_enable_cmd cvs_set_pp_cmd;
+ struct enable_param enable_param = {0};
+ struct param_hdr_v3 param_hdr = {0};
int ret = 0;
- void *apr_cvs;
- u16 cvs_handle;
- if (v == NULL) {
- pr_err("%s: v is NULL\n", __func__);
- return -EINVAL;
- }
- apr_cvs = common.apr_q6_cvs;
+ param_hdr.module_id = mod_inst_info.module_id;
+ param_hdr.instance_id = mod_inst_info.instance_id;
+ param_hdr.param_id = VOICE_PARAM_MOD_ENABLE;
+ param_hdr.param_size = sizeof(enable_param);
+ enable_param.enable = enable ? 1 : 0;
- if (!apr_cvs) {
- pr_err("%s: apr_cvs is NULL.\n", __func__);
- return -EINVAL;
- }
- cvs_handle = voice_get_cvs_handle(v);
+ pr_debug("%s: voice_send_set_pp_enable_cmd, module_id=%d, instance_id=%d, enable=%d\n",
+ __func__, mod_inst_info.module_id, mod_inst_info.instance_id,
+ enable);
- cvs_set_pp_cmd.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
- APR_HDR_LEN(APR_HDR_SIZE),
- APR_PKT_VER);
- cvs_set_pp_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE,
- sizeof(cvs_set_pp_cmd) -
- APR_HDR_SIZE);
- cvs_set_pp_cmd.hdr.src_port = voice_get_idx_for_session(v->session_id);
- cvs_set_pp_cmd.hdr.dest_port = cvs_handle;
- cvs_set_pp_cmd.hdr.token = 0;
- cvs_set_pp_cmd.hdr.opcode = VSS_ICOMMON_CMD_SET_UI_PROPERTY;
-
- cvs_set_pp_cmd.vss_set_pp.module_id = module_id;
- cvs_set_pp_cmd.vss_set_pp.param_id = VOICE_PARAM_MOD_ENABLE;
- cvs_set_pp_cmd.vss_set_pp.param_size = MOD_ENABLE_PARAM_LEN;
- cvs_set_pp_cmd.vss_set_pp.reserved = 0;
- cvs_set_pp_cmd.vss_set_pp.enable = enable;
- cvs_set_pp_cmd.vss_set_pp.reserved_field = 0;
- pr_debug("voice_send_set_pp_enable_cmd, module_id=%d, enable=%d\n",
- module_id, enable);
+ ret = voice_pack_and_set_cvs_ui_property(v, param_hdr,
+ (uint8_t *) &enable_param);
+ if (ret < 0)
+ pr_err("Fail: sending cvs set pp enable\n");
- v->cvs_state = CMD_STATUS_FAIL;
- v->async_err = 0;
- ret = apr_send_pkt(apr_cvs, (uint32_t *) &cvs_set_pp_cmd);
- if (ret < 0) {
- pr_err("Fail: sending cvs set pp enable,\n");
- goto fail;
- }
- ret = wait_event_timeout(v->cvs_wait,
- (v->cvs_state == CMD_STATUS_SUCCESS),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- goto fail;
- }
- if (v->async_err > 0) {
- pr_err("%s: DSP returned error[%s]\n",
- __func__, adsp_err_get_err_str(
- v->async_err));
- ret = adsp_err_get_lnx_err_code(
- v->async_err);
- goto fail;
- }
- return 0;
-fail:
return ret;
}
@@ -3823,6 +3790,7 @@ done:
static int voice_setup_vocproc(struct voice_data *v)
{
+ struct module_instance_info mod_inst_info = {0};
int ret = 0;
ret = voice_send_cvp_create_cmd(v);
@@ -3845,6 +3813,9 @@ static int voice_setup_vocproc(struct voice_data *v)
goto fail;
}
+ mod_inst_info.module_id = MODULE_ID_VOICE_MODULE_ST;
+ mod_inst_info.instance_id = INSTANCE_ID_0;
+
voice_send_cvs_register_cal_cmd(v);
voice_send_cvp_register_dev_cfg_cmd(v);
voice_send_cvp_register_cal_cmd(v);
@@ -3878,9 +3849,7 @@ static int voice_setup_vocproc(struct voice_data *v)
}
if (v->st_enable && !v->tty_mode)
- voice_send_set_pp_enable_cmd(v,
- MODULE_ID_VOICE_MODULE_ST,
- v->st_enable);
+ voice_send_set_pp_enable_cmd(v, mod_inst_info, v->st_enable);
/* Start in-call music delivery if this feature is enabled */
if (v->music_info.play_enable)
voice_cvs_start_playback(v);
@@ -4017,14 +3986,9 @@ done:
static int voice_send_cvp_media_format_cmd(struct voice_data *v,
uint32_t param_type)
{
+ struct vss_param_endpoint_media_format_info media_fmt_info = {0};
+ struct param_hdr_v3 param_hdr = {0};
int ret = 0;
- struct cvp_set_media_format_cmd cvp_set_media_format_cmd;
- void *apr_cvp;
- u16 cvp_handle;
- struct vss_icommon_param_data_t *media_fmt_param_data =
- &cvp_set_media_format_cmd.cvp_set_param_v2.param_data;
- struct vss_param_endpoint_media_format_info_t *media_fmt_info =
- &media_fmt_param_data->media_format_info;
if (v == NULL) {
pr_err("%s: v is NULL\n", __func__);
@@ -4032,75 +3996,41 @@ static int voice_send_cvp_media_format_cmd(struct voice_data *v,
goto done;
}
- apr_cvp = common.apr_q6_cvp;
- if (!apr_cvp) {
- pr_err("%s: apr_cvp is NULL.\n", __func__);
- ret = -EINVAL;
- goto done;
- }
-
- cvp_handle = voice_get_cvp_handle(v);
- memset(&cvp_set_media_format_cmd, 0, sizeof(cvp_set_media_format_cmd));
+ param_hdr.module_id = VSS_MODULE_CVD_GENERIC;
+ param_hdr.instance_id = INSTANCE_ID_0;
+ param_hdr.param_size = sizeof(media_fmt_info);
- /* Fill header data */
- cvp_set_media_format_cmd.hdr.hdr_field =
- APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
- APR_PKT_VER);
- cvp_set_media_format_cmd.hdr.pkt_size =
- APR_PKT_SIZE(APR_HDR_SIZE,
- sizeof(cvp_set_media_format_cmd) - APR_HDR_SIZE);
- cvp_set_media_format_cmd.hdr.src_svc = 0;
- cvp_set_media_format_cmd.hdr.src_domain = APR_DOMAIN_APPS;
- cvp_set_media_format_cmd.hdr.src_port =
- voice_get_idx_for_session(v->session_id);
- cvp_set_media_format_cmd.hdr.dest_svc = 0;
- cvp_set_media_format_cmd.hdr.dest_domain = APR_DOMAIN_ADSP;
- cvp_set_media_format_cmd.hdr.dest_port = cvp_handle;
- cvp_set_media_format_cmd.hdr.token = VOC_SET_MEDIA_FORMAT_PARAM_TOKEN;
- cvp_set_media_format_cmd.hdr.opcode = VSS_ICOMMON_CMD_SET_PARAM_V2;
-
- /* Fill param data */
- cvp_set_media_format_cmd.cvp_set_param_v2.mem_size =
- sizeof(struct vss_icommon_param_data_t);
- media_fmt_param_data->module_id = VSS_MODULE_CVD_GENERIC;
- media_fmt_param_data->param_size =
- sizeof(struct vss_param_endpoint_media_format_info_t);
-
- /* Fill device specific data */
switch (param_type) {
case RX_PATH:
- media_fmt_param_data->param_id =
- VSS_PARAM_RX_PORT_ENDPOINT_MEDIA_INFO;
- media_fmt_info->port_id = v->dev_rx.port_id;
- media_fmt_info->num_channels = v->dev_rx.no_of_channels;
- media_fmt_info->bits_per_sample = v->dev_rx.bits_per_sample;
- media_fmt_info->sample_rate = v->dev_rx.sample_rate;
- memcpy(&media_fmt_info->channel_mapping,
+ param_hdr.param_id = VSS_PARAM_RX_PORT_ENDPOINT_MEDIA_INFO;
+ media_fmt_info.port_id = v->dev_rx.port_id;
+ media_fmt_info.num_channels = v->dev_rx.no_of_channels;
+ media_fmt_info.bits_per_sample = v->dev_rx.bits_per_sample;
+ media_fmt_info.sample_rate = v->dev_rx.sample_rate;
+ memcpy(&media_fmt_info.channel_mapping,
&v->dev_rx.channel_mapping, VSS_CHANNEL_MAPPING_SIZE);
break;
case TX_PATH:
- media_fmt_param_data->param_id =
- VSS_PARAM_TX_PORT_ENDPOINT_MEDIA_INFO;
- media_fmt_info->port_id = v->dev_tx.port_id;
- media_fmt_info->num_channels = v->dev_tx.no_of_channels;
- media_fmt_info->bits_per_sample = v->dev_tx.bits_per_sample;
- media_fmt_info->sample_rate = v->dev_tx.sample_rate;
- memcpy(&media_fmt_info->channel_mapping,
+ param_hdr.param_id = VSS_PARAM_TX_PORT_ENDPOINT_MEDIA_INFO;
+ media_fmt_info.port_id = v->dev_tx.port_id;
+ media_fmt_info.num_channels = v->dev_tx.no_of_channels;
+ media_fmt_info.bits_per_sample = v->dev_tx.bits_per_sample;
+ media_fmt_info.sample_rate = v->dev_tx.sample_rate;
+ memcpy(&media_fmt_info.channel_mapping,
&v->dev_tx.channel_mapping, VSS_CHANNEL_MAPPING_SIZE);
break;
case EC_REF_PATH:
- media_fmt_param_data->param_id =
- VSS_PARAM_EC_REF_PORT_ENDPOINT_MEDIA_INFO;
- media_fmt_info->port_id = common.ec_media_fmt_info.port_id;
- media_fmt_info->num_channels =
+ param_hdr.param_id = VSS_PARAM_EC_REF_PORT_ENDPOINT_MEDIA_INFO;
+ media_fmt_info.port_id = common.ec_media_fmt_info.port_id;
+ media_fmt_info.num_channels =
common.ec_media_fmt_info.num_channels;
- media_fmt_info->bits_per_sample =
+ media_fmt_info.bits_per_sample =
common.ec_media_fmt_info.bits_per_sample;
- media_fmt_info->sample_rate =
+ media_fmt_info.sample_rate =
common.ec_media_fmt_info.sample_rate;
- memcpy(&media_fmt_info->channel_mapping,
+ memcpy(&media_fmt_info.channel_mapping,
&common.ec_media_fmt_info.channel_mapping,
VSS_CHANNEL_MAPPING_SIZE);
break;
@@ -4111,32 +4041,11 @@ static int voice_send_cvp_media_format_cmd(struct voice_data *v,
goto done;
}
- /* Send command */
- v->cvp_state = CMD_STATUS_FAIL;
- v->async_err = 0;
- ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_set_media_format_cmd);
- if (ret < 0) {
- pr_err("%s: Fail in sending VSS_ICOMMON_CMD_SET_PARAM_V2\n",
- __func__);
- ret = -EINVAL;
- goto done;
- }
-
- ret = wait_event_timeout(v->cvp_wait,
- (v->cvp_state == CMD_STATUS_SUCCESS),
- msecs_to_jiffies(TIMEOUT_MS));
- if (!ret) {
- pr_err("%s: wait_event timeout\n", __func__);
- ret = -EINVAL;
- goto done;
- }
-
- if (v->async_err > 0) {
- pr_err("%s: DSP returned error[%s] handle = %d\n", __func__,
- adsp_err_get_err_str(v->async_err), cvp_handle);
- ret = adsp_err_get_lnx_err_code(v->async_err);
- goto done;
- }
+ ret = voice_pack_and_set_cvp_param(v, param_hdr,
+ (u8 *) &media_fmt_info);
+ if (ret)
+ pr_err("%s: Failed to set media format params on CVP, err %d\n",
+ __func__, ret);
done:
return ret;
@@ -4532,6 +4441,7 @@ static int voice_destroy_vocproc(struct voice_data *v)
{
struct mvm_detach_vocproc_cmd mvm_d_vocproc_cmd;
struct apr_hdr cvp_destroy_session_cmd;
+ struct module_instance_info mod_inst_info = {0};
int ret = 0;
void *apr_mvm, *apr_cvp;
u16 mvm_handle, cvp_handle;
@@ -4550,9 +4460,12 @@ static int voice_destroy_vocproc(struct voice_data *v)
mvm_handle = voice_get_mvm_handle(v);
cvp_handle = voice_get_cvp_handle(v);
+ mod_inst_info.module_id = MODULE_ID_VOICE_MODULE_ST;
+ mod_inst_info.instance_id = INSTANCE_ID_0;
+
/* disable slowtalk if st_enable is set */
if (v->st_enable)
- voice_send_set_pp_enable_cmd(v, MODULE_ID_VOICE_MODULE_ST, 0);
+ voice_send_set_pp_enable_cmd(v, mod_inst_info, 0);
/* Disable HD Voice if hd_enable is set */
if (v->hd_enable)
@@ -5789,11 +5702,15 @@ uint8_t voc_get_tty_mode(uint32_t session_id)
return ret;
}
-int voc_set_pp_enable(uint32_t session_id, uint32_t module_id, uint32_t enable)
+int voc_set_pp_enable(uint32_t session_id,
+ struct module_instance_info mod_inst_info,
+ uint32_t enable)
{
struct voice_data *v = NULL;
int ret = 0;
struct voice_session_itr itr;
+ int mid = mod_inst_info.module_id;
+ int iid = mod_inst_info.instance_id;
voice_itr_init(&itr, session_id);
while (voice_itr_get_next_session(&itr, &v)) {
@@ -5802,15 +5719,15 @@ int voc_set_pp_enable(uint32_t session_id, uint32_t module_id, uint32_t enable)
continue;
mutex_lock(&v->lock);
- if (module_id == MODULE_ID_VOICE_MODULE_ST)
+ if (mid == MODULE_ID_VOICE_MODULE_ST &&
+ iid == INSTANCE_ID_0)
v->st_enable = enable;
if (v->voc_state == VOC_RUN) {
- if ((module_id == MODULE_ID_VOICE_MODULE_ST) &&
- (!v->tty_mode))
- ret = voice_send_set_pp_enable_cmd(v,
- MODULE_ID_VOICE_MODULE_ST,
- enable);
+ if ((mid == MODULE_ID_VOICE_MODULE_ST) &&
+ iid == INSTANCE_ID_0 && (!v->tty_mode))
+ ret = voice_send_set_pp_enable_cmd(
+ v, mod_inst_info, enable);
}
mutex_unlock(&v->lock);
} else {
@@ -5893,7 +5810,8 @@ bool voc_get_afe_sidetone(void)
return ret;
}
-int voc_get_pp_enable(uint32_t session_id, uint32_t module_id)
+int voc_get_pp_enable(uint32_t session_id,
+ struct module_instance_info mod_inst_info)
{
struct voice_data *v = voice_get_session(session_id);
int ret = 0;
@@ -5905,7 +5823,8 @@ int voc_get_pp_enable(uint32_t session_id, uint32_t module_id)
}
mutex_lock(&v->lock);
- if (module_id == MODULE_ID_VOICE_MODULE_ST)
+ if (mod_inst_info.module_id == MODULE_ID_VOICE_MODULE_ST &&
+ mod_inst_info.instance_id == INSTANCE_ID_0)
ret = v->st_enable;
mutex_unlock(&v->lock);
@@ -6180,6 +6099,7 @@ done:
int voc_enable_device(uint32_t session_id)
{
struct voice_data *v = voice_get_session(session_id);
+ struct module_instance_info mod_inst_info = {0};
int ret = 0;
if (v == NULL) {
@@ -6197,15 +6117,15 @@ int voc_enable_device(uint32_t session_id)
/* Not a critical error, allow voice call to continue */
}
+ mod_inst_info.module_id = MODULE_ID_VOICE_MODULE_ST;
+ mod_inst_info.instance_id = INSTANCE_ID_0;
+
if (v->tty_mode) {
/* disable slowtalk */
- voice_send_set_pp_enable_cmd(v,
- MODULE_ID_VOICE_MODULE_ST,
- 0);
+ voice_send_set_pp_enable_cmd(v, mod_inst_info, 0);
} else {
/* restore slowtalk */
- voice_send_set_pp_enable_cmd(v,
- MODULE_ID_VOICE_MODULE_ST,
+ voice_send_set_pp_enable_cmd(v, mod_inst_info,
v->st_enable);
}
@@ -6787,6 +6707,7 @@ static int32_t qdsp_cvs_callback(struct apr_client_data *data, void *priv)
case VSS_ICOMMON_CMD_MAP_MEMORY:
case VSS_ICOMMON_CMD_UNMAP_MEMORY:
case VSS_ICOMMON_CMD_SET_UI_PROPERTY:
+ case VSS_ICOMMON_CMD_SET_UI_PROPERTY_V2:
case VSS_IPLAYBACK_CMD_START:
case VSS_IPLAYBACK_CMD_STOP:
case VSS_IRECORD_CMD_START:
@@ -6800,7 +6721,8 @@ static int32_t qdsp_cvs_callback(struct apr_client_data *data, void *priv)
wake_up(&v->cvs_wait);
break;
case VSS_ICOMMON_CMD_SET_PARAM_V2:
- pr_debug("%s: VSS_ICOMMON_CMD_SET_PARAM_V2\n",
+ case VSS_ICOMMON_CMD_SET_PARAM_V3:
+ pr_debug("%s: VSS_ICOMMON_CMD_SET_PARAM\n",
__func__);
rtac_make_voice_callback(RTAC_CVS, ptr,
data->payload_size);
@@ -7081,16 +7003,17 @@ static int32_t qdsp_cvp_callback(struct apr_client_data *data, void *priv)
case VSS_IVPCM_EVT_PUSH_BUFFER_V2:
break;
case VSS_ICOMMON_CMD_SET_PARAM_V2:
+ case VSS_ICOMMON_CMD_SET_PARAM_V3:
switch (data->token) {
case VOC_SET_MEDIA_FORMAT_PARAM_TOKEN:
- pr_debug("%s: VSS_ICOMMON_CMD_SET_PARAM_V2 called by voice_send_cvp_media_format_cmd\n",
+ pr_debug("%s: VSS_ICOMMON_CMD_SET_PARAM called by voice_send_cvp_media_format_cmd\n",
__func__);
v->cvp_state = CMD_STATUS_SUCCESS;
v->async_err = ptr[1];
wake_up(&v->cvp_wait);
break;
case VOC_RTAC_SET_PARAM_TOKEN:
- pr_debug("%s: VSS_ICOMMON_CMD_SET_PARAM_V2 called by rtac\n",
+ pr_debug("%s: VSS_ICOMMON_CMD_SET_PARAM called by rtac\n",
__func__);
rtac_make_voice_callback(
RTAC_CVP, ptr,
@@ -8578,6 +8501,199 @@ int voc_get_source_tracking(struct source_tracking_param *sourceTrackingData)
return ret;
}
+static int voice_set_cvp_param(struct voice_data *v,
+ struct vss_icommon_mem_mapping_hdr *mem_hdr,
+ u32 *param_data, u32 param_size)
+{
+ struct vss_icommon_cmd_set_param *set_param = NULL;
+ uint32_t pkt_size = sizeof(struct vss_icommon_cmd_set_param);
+ void *apr_cvp;
+ int ret = 0;
+
+ apr_cvp = common.apr_q6_cvp;
+ if (!apr_cvp) {
+ pr_err("%s: apr_cvp is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ if (param_data != NULL)
+ pkt_size += param_size;
+ set_param = kzalloc(pkt_size, GFP_KERNEL);
+ if (!set_param)
+ return -ENOMEM;
+
+ set_param->apr_hdr.hdr_field =
+ APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
+ APR_PKT_VER);
+ set_param->apr_hdr.pkt_size =
+ APR_PKT_SIZE(APR_HDR_SIZE, pkt_size - APR_HDR_SIZE);
+ set_param->apr_hdr.src_svc = 0;
+ set_param->apr_hdr.src_domain = APR_DOMAIN_APPS;
+ set_param->apr_hdr.src_port = voice_get_idx_for_session(v->session_id);
+ set_param->apr_hdr.dest_svc = 0;
+ set_param->apr_hdr.dest_domain = APR_DOMAIN_ADSP;
+ set_param->apr_hdr.dest_port = voice_get_cvp_handle(v);
+ set_param->apr_hdr.token = VOC_SET_MEDIA_FORMAT_PARAM_TOKEN;
+ set_param->apr_hdr.opcode = q6common_is_instance_id_supported() ?
+ VSS_ICOMMON_CMD_SET_PARAM_V3 :
+ VSS_ICOMMON_CMD_SET_PARAM_V2;
+
+ set_param->payload_size = param_size;
+
+ if (mem_hdr != NULL) {
+ set_param->mem_hdr = *mem_hdr;
+ } else if (param_data != NULL) {
+ memcpy(set_param->param_data, param_data, param_size);
+ } else {
+ pr_err("%s: Both memory header and param data are NULL\n",
+ __func__);
+ ret = -EINVAL;
+ goto done;
+ }
+
+ v->cvp_state = CMD_STATUS_FAIL;
+ v->async_err = 0;
+ ret = apr_send_pkt(apr_cvp, (u32 *) set_param);
+ if (ret < 0) {
+ pr_err("%s: Failed to send apr packet, error %d\n", __func__,
+ ret);
+ goto done;
+ }
+
+ ret = wait_event_timeout(v->cvp_wait,
+ v->cvp_state == CMD_STATUS_SUCCESS,
+ msecs_to_jiffies(TIMEOUT_MS));
+ if (!ret) {
+ pr_err("%s: wait_event timeout\n", __func__);
+ ret = -ETIMEDOUT;
+ goto done;
+ }
+
+ if (v->async_err > 0) {
+ pr_err("%s: DSP returned error[%s]\n", __func__,
+ adsp_err_get_err_str(v->async_err));
+ ret = adsp_err_get_lnx_err_code(v->async_err);
+ goto done;
+ }
+ ret = 0;
+
+done:
+ kfree(set_param);
+ return ret;
+}
+
+static int voice_pack_and_set_cvp_param(struct voice_data *v,
+ struct param_hdr_v3 param_hdr,
+ u8 *param_data)
+{
+ u8 *packed_data = NULL;
+ u32 total_size = 0;
+ int ret = 0;
+
+ total_size = sizeof(union param_hdrs) + param_hdr.param_size;
+ packed_data = kzalloc(total_size, GFP_KERNEL);
+ if (!packed_data)
+ return -ENOMEM;
+
+ ret = q6common_pack_pp_params(packed_data, &param_hdr, param_data,
+ &total_size);
+ if (ret) {
+ pr_err("%s: Failed to pack params, error %d", __func__, ret);
+ goto done;
+ }
+
+ ret = voice_set_cvp_param(v, NULL, (u32 *) packed_data, total_size);
+
+done:
+ kfree(packed_data);
+ return ret;
+}
+
+/*
+ * Out of band is not supported and there are currently no pre-packed cases,
+ * so pack and set in the same function. When needed, split up.
+ */
+static int voice_pack_and_set_cvs_ui_property(struct voice_data *v,
+ struct param_hdr_v3 param_hdr,
+ u8 *param_data)
+{
+ struct vss_icommon_cmd_set_ui_property *set_ui_property = NULL;
+ u32 total_size = 0;
+ bool iid_supported = q6common_is_instance_id_supported();
+ void *apr_cvs;
+ int ret = 0;
+
+ apr_cvs = common.apr_q6_cvs;
+ if (!apr_cvs) {
+ pr_err("%s: apr_cvs is NULL\n", __func__);
+ return -EINVAL;
+ }
+
+ total_size = sizeof(struct vss_icommon_cmd_set_ui_property) +
+ sizeof(union param_hdrs) + param_hdr.param_size;
+ set_ui_property = kzalloc(total_size, GFP_KERNEL);
+ if (!set_ui_property)
+ return -ENOMEM;
+
+ ret = q6common_pack_pp_params(set_ui_property->param_data, &param_hdr,
+ param_data, &total_size);
+ if (ret) {
+ pr_err("%s: Failed to pack params, error %d", __func__, ret);
+ goto done;
+ }
+
+ /*
+ * Pack the APR header after packing the data so we have the actual
+ * total size of the payload
+ */
+ set_ui_property->apr_hdr.hdr_field =
+ APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
+ APR_PKT_VER);
+ set_ui_property->apr_hdr.pkt_size =
+ APR_PKT_SIZE(APR_HDR_SIZE, total_size - APR_HDR_SIZE);
+ set_ui_property->apr_hdr.src_svc = 0;
+ set_ui_property->apr_hdr.src_domain = APR_DOMAIN_APPS;
+ set_ui_property->apr_hdr.src_port =
+ voice_get_idx_for_session(v->session_id);
+ set_ui_property->apr_hdr.dest_svc = 0;
+ set_ui_property->apr_hdr.dest_domain = APR_DOMAIN_ADSP;
+ set_ui_property->apr_hdr.dest_port = voice_get_cvs_handle(v);
+ set_ui_property->apr_hdr.token = 0;
+
+ set_ui_property->apr_hdr.opcode =
+ iid_supported ? VSS_ICOMMON_CMD_SET_UI_PROPERTY_V2 :
+ VSS_ICOMMON_CMD_SET_UI_PROPERTY;
+
+ v->cvs_state = CMD_STATUS_FAIL;
+ v->async_err = 0;
+ ret = apr_send_pkt(apr_cvs, (u32 *) set_ui_property);
+ if (ret < 0) {
+ pr_err("%s: Failed to send apr packet, error %d\n", __func__,
+ ret);
+ goto done;
+ }
+
+ ret = wait_event_timeout(v->cvs_wait,
+ v->cvs_state == CMD_STATUS_SUCCESS,
+ msecs_to_jiffies(TIMEOUT_MS));
+ if (!ret) {
+ pr_err("%s: wait_event timeout\n", __func__);
+ ret = -ETIMEDOUT;
+ goto done;
+ }
+
+ if (v->async_err > 0) {
+ pr_err("%s: DSP returned error[%s]\n", __func__,
+ adsp_err_get_err_str(v->async_err));
+ ret = adsp_err_get_lnx_err_code(v->async_err);
+ goto done;
+ }
+ ret = 0;
+done:
+ kfree(set_ui_property);
+ return ret;
+}
+
int is_voc_initialized(void)
{
return module_initialized;
diff --git a/sound/soc/msm/qdsp6v2/q6voice.h b/sound/soc/msm/qdsp6v2/q6voice.h
index f7ea650dfda9..f448e701d564 100644
--- a/sound/soc/msm/qdsp6v2/q6voice.h
+++ b/sound/soc/msm/qdsp6v2/q6voice.h
@@ -172,6 +172,7 @@ struct mem_map_table {
/* Common */
#define VSS_ICOMMON_CMD_SET_UI_PROPERTY 0x00011103
+#define VSS_ICOMMON_CMD_SET_UI_PROPERTY_V2 0x00013248
/* Set a UI property */
#define VSS_ICOMMON_CMD_MAP_MEMORY 0x00011025
#define VSS_ICOMMON_CMD_UNMAP_MEMORY 0x00011026
@@ -213,7 +214,7 @@ struct vss_unmap_memory_cmd {
struct vss_icommon_cmd_unmap_memory_t vss_unmap_mem;
} __packed;
-struct vss_param_endpoint_media_format_info_t {
+struct vss_param_endpoint_media_format_info {
/* AFE port ID to which this media format corresponds to. */
uint32_t port_id;
/*
@@ -240,29 +241,7 @@ struct vss_param_endpoint_media_format_info_t {
uint8_t channel_mapping[VSS_NUM_CHANNELS_MAX];
} __packed;
-struct vss_icommon_param_data_t {
- /* Valid ID of the module. */
- uint32_t module_id;
- /* Valid ID of the parameter. */
- uint32_t param_id;
- /*
- * Data size of the structure relating to the param_id/module_id
- * combination in uint8_t bytes.
- */
- uint16_t param_size;
- /* This field must be set to zero. */
- uint16_t reserved;
- /*
- * Parameter data payload when inband. Should have size param_size.
- * Bit size of payload must be a multiple of 4.
- */
- union {
- struct vss_param_endpoint_media_format_info_t media_format_info;
- };
-} __packed;
-
-/* Payload structure for the VSS_ICOMMON_CMD_SET_PARAM_V2 command. */
-struct vss_icommon_cmd_set_param_v2_t {
+struct vss_icommon_mem_mapping_hdr {
/*
* Pointer to the unique identifier for an address (physical/virtual).
*
@@ -275,6 +254,7 @@ struct vss_icommon_cmd_set_param_v2_t {
* data.
*/
uint32_t mem_handle;
+
/*
* Location of the parameter data payload.
*
@@ -282,12 +262,25 @@ struct vss_icommon_cmd_set_param_v2_t {
* mem_handle is 0, this field is ignored.
*/
uint64_t mem_address;
- /* Size of the parameter data payload in bytes. */
- uint32_t mem_size;
- /* Parameter data payload when the data is inband. */
- struct vss_icommon_param_data_t param_data;
+
} __packed;
+struct vss_icommon_cmd_set_param {
+ /* APR Header */
+ struct apr_hdr apr_hdr;
+
+ /* The memory mapping header to be used when sending outband */
+ struct vss_icommon_mem_mapping_hdr mem_hdr;
+
+ /* Size of the parameter data payload in bytes. */
+ uint32_t payload_size;
+
+ /*
+ * Parameter data payload when inband. Should have size param_size.
+ * Bit size of payload must be a multiple of 4.
+ */
+ uint8_t param_data[0];
+} __packed;
/* TO MVM commands */
#define VSS_IMVM_CMD_CREATE_PASSIVE_CONTROL_SESSION 0x000110FF
/**< No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */
@@ -638,7 +631,6 @@ struct vss_imemory_cmd_unmap_t {
#define MODULE_ID_VOICE_MODULE_ST 0x00010EE3
#define VOICE_PARAM_MOD_ENABLE 0x00010E00
-#define MOD_ENABLE_PARAM_LEN 4
#define VSS_IPLAYBACK_CMD_START 0x000112BD
/* Start in-call music delivery on the Tx voice path. */
@@ -907,20 +899,20 @@ struct vss_istream_cmd_register_calibration_data_v2_t {
*/
} __packed;
-struct vss_icommon_cmd_set_ui_property_enable_t {
- uint32_t module_id;
- /* Unique ID of the module. */
- uint32_t param_id;
- /* Unique ID of the parameter. */
- uint16_t param_size;
- /* Size of the parameter in bytes: MOD_ENABLE_PARAM_LEN */
- uint16_t reserved;
- /* Reserved; set to 0. */
+struct enable_param {
uint16_t enable;
uint16_t reserved_field;
/* Reserved, set to 0. */
};
+struct vss_icommon_cmd_set_ui_property {
+ /* APR Header */
+ struct apr_hdr apr_hdr;
+
+ /* The parameter data to be filled when sent inband */
+ u8 param_data[0];
+} __packed;
+
/*
* Event sent by the stream to the client that enables Rx DTMF
* detection whenever DTMF is detected in the Rx path.
@@ -1029,10 +1021,6 @@ struct cvs_deregister_cal_data_cmd {
struct apr_hdr hdr;
} __packed;
-struct cvs_set_pp_enable_cmd {
- struct apr_hdr hdr;
- struct vss_icommon_cmd_set_ui_property_enable_t vss_set_pp;
-} __packed;
struct cvs_start_record_cmd {
struct apr_hdr hdr;
struct vss_irecord_cmd_start_t rec_mode;
@@ -1105,6 +1093,8 @@ struct vss_istream_cmd_set_packet_exchange_mode_t {
*/
#define VSS_IVOCPROC_CMD_DEREGISTER_DEVICE_CONFIG 0x00011372
+#define CVD_CAL_DATA_FORMAT_MINOR_VERSION_V0 0x00000000
+#define CVD_CAL_DATA_FORMAT_MINOR_VERSION_V1 0x00000001
#define VSS_IVOCPROC_CMD_REGISTER_CALIBRATION_DATA_V2 0x00011373
#define VSS_IVOCPROC_CMD_DEREGISTER_CALIBRATION_DATA 0x00011276
@@ -1484,11 +1474,6 @@ struct cvp_set_dev_channels_cmd {
struct vss_ivocproc_cmd_topology_set_dev_channels_t cvp_set_channels;
} __packed;
-struct cvp_set_media_format_cmd {
- struct apr_hdr hdr;
- struct vss_icommon_cmd_set_param_v2_t cvp_set_param_v2;
-} __packed;
-
struct cvp_set_vp3_data_cmd {
struct apr_hdr hdr;
} __packed;
@@ -1836,9 +1821,11 @@ enum {
#define VSID_MAX ALL_SESSION_VSID
/* called by alsa driver */
-int voc_set_pp_enable(uint32_t session_id, uint32_t module_id,
+int voc_set_pp_enable(uint32_t session_id,
+ struct module_instance_info mod_inst_info,
uint32_t enable);
-int voc_get_pp_enable(uint32_t session_id, uint32_t module_id);
+int voc_get_pp_enable(uint32_t session_id,
+ struct module_instance_info mod_inst_info);
int voc_set_hd_enable(uint32_t session_id, uint32_t enable);
uint8_t voc_get_tty_mode(uint32_t session_id);
int voc_set_tty_mode(uint32_t session_id, uint8_t tty_mode);