summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Sham <tsham@codeaurora.org>2018-06-15 13:34:44 -0400
committerTimothy Sham <tsham@codeaurora.org>2018-09-25 13:42:26 -0400
commitaef8b38fdd280a4c8890df4f5172c400d3762866 (patch)
tree4559e3a756a17118fa9be5372496eed5ad4679d0
parentaa0ebdfe2d12829d8ee6dde5e841e1c67c9141c2 (diff)
soc: msm: add sensor dsp dynamic calibration support for anc
Add Sensor DSP dynamic calibration support for Active Engine Noise Cancellation (ANC). Change-Id: Ibca0b039a80fde890f43116aaa646104e8ab9b6e Signed-off-by: Timothy Sham <tsham@codeaurora.org>
-rw-r--r--drivers/soc/qcom/qdsp6v2/audio-anc-dev-mgr.c69
-rw-r--r--drivers/soc/qcom/qdsp6v2/audio_anc.c17
-rw-r--r--drivers/soc/qcom/qdsp6v2/sdsp-anc.c243
-rw-r--r--include/linux/qdsp6v2/audio-anc-dev-mgr.h2
-rw-r--r--include/linux/qdsp6v2/sdsp_anc.h97
-rw-r--r--include/uapi/linux/msm_audio_anc.h17
6 files changed, 235 insertions, 210 deletions
diff --git a/drivers/soc/qcom/qdsp6v2/audio-anc-dev-mgr.c b/drivers/soc/qcom/qdsp6v2/audio-anc-dev-mgr.c
index 75b114e6905c..95562d2cbfad 100644
--- a/drivers/soc/qcom/qdsp6v2/audio-anc-dev-mgr.c
+++ b/drivers/soc/qcom/qdsp6v2/audio-anc-dev-mgr.c
@@ -53,8 +53,6 @@ struct anc_tdm_group_set_info {
struct anc_dev_drv_info {
uint32_t state;
- uint32_t rpm;
- uint32_t bypass_mode;
uint32_t algo_module_id;
};
@@ -311,52 +309,68 @@ static int anc_dev_port_stop(int32_t which_port)
int msm_anc_dev_set_info(void *info_p, int32_t anc_cmd)
{
- int rc = 0;
+ int rc = -EINVAL;
switch (anc_cmd) {
- case ANC_CMD_RPM: {
- struct audio_anc_rpm_info *rpm_info_p =
- (struct audio_anc_rpm_info *)info_p;
+ case ANC_CMD_ALGO_MODULE: {
+ struct audio_anc_algo_module_info *module_info_p =
+ (struct audio_anc_algo_module_info *)info_p;
+
+ rc = 0;
if (this_anc_dev_info.state)
- rc = anc_if_set_rpm(
+ rc = anc_if_set_algo_module_id(
anc_port_cfg[ANC_DEV_PORT_ANC_SPKR].port_id,
- rpm_info_p->rpm);
+ module_info_p->module_id);
else
- this_anc_dev_info.rpm = 0;
+ this_anc_dev_info.algo_module_id =
+ module_info_p->module_id;
break;
}
- case ANC_CMD_BYPASS_MODE: {
- struct audio_anc_bypass_mode *bypass_mode_p =
- (struct audio_anc_bypass_mode *)info_p;
-
+ case ANC_CMD_ALGO_CALIBRATION: {
+ rc = -EINVAL;
if (this_anc_dev_info.state)
- rc = anc_if_set_bypass_mode(
+ rc = anc_if_set_algo_module_cali_data(
anc_port_cfg[ANC_DEV_PORT_ANC_SPKR].port_id,
- bypass_mode_p->mode);
+ info_p);
else
- this_anc_dev_info.bypass_mode = bypass_mode_p->mode;
+ pr_err("%s: ANC is not running yet\n",
+ __func__);
+ break;
+ }
+ default:
+ pr_err("%s: ANC cmd wrong\n",
+ __func__);
break;
}
- case ANC_CMD_ALGO_MODULE: {
- struct audio_anc_algo_module_info *module_info_p =
- (struct audio_anc_algo_module_info *)info_p;
+ return rc;
+}
+
+int msm_anc_dev_get_info(void *info_p, int32_t anc_cmd)
+{
+ int rc = -EINVAL;
+
+ switch (anc_cmd) {
+ case ANC_CMD_ALGO_CALIBRATION: {
if (this_anc_dev_info.state)
- rc = anc_if_set_algo_module_id(
+ rc = anc_if_get_algo_module_cali_data(
anc_port_cfg[ANC_DEV_PORT_ANC_SPKR].port_id,
- module_info_p->module_id);
+ info_p);
else
- this_anc_dev_info.algo_module_id =
- module_info_p->module_id;
+ pr_err("%s: ANC is not running yet\n",
+ __func__);
break;
}
+ default:
+ pr_err("%s: ANC cmd wrong\n",
+ __func__);
+ break;
}
return rc;
}
-
int msm_anc_dev_start(void)
{
int rc = 0;
@@ -514,11 +528,6 @@ int msm_anc_dev_start(void)
anc_port_cfg[ANC_DEV_PORT_ANC_SPKR].port_id,
this_anc_dev_info.algo_module_id);
- if (this_anc_dev_info.bypass_mode != 0)
- rc = anc_if_set_bypass_mode(
- anc_port_cfg[ANC_DEV_PORT_ANC_SPKR].port_id,
- this_anc_dev_info.bypass_mode);
-
group_id = get_group_id_from_port_id(
anc_port_cfg[ANC_DEV_PORT_ANC_SPKR].port_id);
@@ -612,8 +621,6 @@ int msm_anc_dev_stop(void)
this_anc_dev_info.state = 0;
this_anc_dev_info.algo_module_id = 0;
- this_anc_dev_info.rpm = 0;
- this_anc_dev_info.bypass_mode = 0;
pr_debug("%s: ANC devices stop successfully!\n", __func__);
diff --git a/drivers/soc/qcom/qdsp6v2/audio_anc.c b/drivers/soc/qcom/qdsp6v2/audio_anc.c
index 65c585886453..50cc255043df 100644
--- a/drivers/soc/qcom/qdsp6v2/audio_anc.c
+++ b/drivers/soc/qcom/qdsp6v2/audio_anc.c
@@ -44,17 +44,11 @@ static size_t get_user_anc_cmd_size(int32_t anc_cmd)
case ANC_CMD_STOP:
size = 0;
break;
- case ANC_CMD_RPM:
- size = sizeof(struct audio_anc_rpm_info);
- break;
- case ANC_CMD_BYPASS_MODE:
- size = sizeof(struct audio_anc_bypass_mode);
- break;
case ANC_CMD_ALGO_MODULE:
size = sizeof(struct audio_anc_algo_module_info);
break;
case ANC_CMD_ALGO_CALIBRATION:
- size = sizeof(struct audio_anc_algo_calibration_info);
+ size = sizeof(struct audio_anc_algo_calibration_header);
break;
default:
pr_err("%s:Invalid anc cmd %d!",
@@ -77,8 +71,6 @@ static int call_set_anc(int32_t anc_cmd,
case ANC_CMD_STOP:
ret = msm_anc_dev_stop();
break;
- case ANC_CMD_RPM:
- case ANC_CMD_BYPASS_MODE:
case ANC_CMD_ALGO_MODULE:
case ANC_CMD_ALGO_CALIBRATION:
ret = msm_anc_dev_set_info(data, anc_cmd);
@@ -98,7 +90,8 @@ static int call_get_anc(int32_t anc_cmd,
int ret = 0;
switch (anc_cmd) {
- case ANC_CMD_RPM:
+ case ANC_CMD_ALGO_CALIBRATION:
+ ret = msm_anc_dev_get_info(data, anc_cmd);
break;
default:
break;
@@ -146,9 +139,9 @@ static long audio_anc_shared_ioctl(struct file *file, unsigned int cmd,
pr_err("%s: Could not copy size value from user\n", __func__);
ret = -EFAULT;
goto done;
- } else if (size < sizeof(struct audio_anc_packet)) {
+ } else if (size < sizeof(struct audio_anc_header)) {
pr_err("%s: Invalid size sent to driver: %d, min size is %zd\n",
- __func__, size, sizeof(struct audio_anc_packet));
+ __func__, size, sizeof(struct audio_anc_header));
ret = -EINVAL;
goto done;
}
diff --git a/drivers/soc/qcom/qdsp6v2/sdsp-anc.c b/drivers/soc/qcom/qdsp6v2/sdsp-anc.c
index 9294485f7ff2..4e75bc89aa8f 100644
--- a/drivers/soc/qcom/qdsp6v2/sdsp-anc.c
+++ b/drivers/soc/qcom/qdsp6v2/sdsp-anc.c
@@ -38,7 +38,7 @@ struct anc_if_ctl {
atomic_t status;
wait_queue_head_t wait[AFE_MAX_PORTS];
struct task_struct *task;
- struct anc_get_rpm_resp rpm_calib_data;
+ struct anc_get_algo_module_cali_data_resp cali_data_resp;
uint32_t mmap_handle;
struct mutex afe_cmd_lock;
};
@@ -48,33 +48,23 @@ static struct anc_if_ctl this_anc_if;
static int32_t anc_get_param_callback(uint32_t *payload,
uint32_t payload_size)
{
- u32 param_id;
- struct anc_get_rpm_resp *resp =
- (struct anc_get_rpm_resp *) payload;
-
- if (!(&(resp->pdata))) {
- pr_err("%s: Error: resp pdata is NULL\n", __func__);
+ if ((payload_size < (sizeof(uint32_t) +
+ sizeof(this_anc_if.cali_data_resp.pdata))) ||
+ (payload_size > sizeof(this_anc_if.cali_data_resp))) {
+ pr_err("%s: Error: received size %d, calib_data size %zu\n",
+ __func__, payload_size,
+ sizeof(this_anc_if.cali_data_resp));
return -EINVAL;
}
- param_id = resp->pdata.param_id;
- if (param_id == AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_RPM) {
- if (payload_size < sizeof(this_anc_if.rpm_calib_data)) {
- pr_err("%s: Error: received size %d, calib_data size %zu\n",
- __func__, payload_size,
- sizeof(this_anc_if.rpm_calib_data));
- return -EINVAL;
- }
-
- memcpy(&this_anc_if.rpm_calib_data, payload,
- sizeof(this_anc_if.rpm_calib_data));
- if (!this_anc_if.rpm_calib_data.status) {
- atomic_set(&this_anc_if.state, 0);
- } else {
- pr_debug("%s: calib resp status: %d", __func__,
- this_anc_if.rpm_calib_data.status);
- atomic_set(&this_anc_if.state, -1);
- }
+ memcpy(&this_anc_if.cali_data_resp, payload,
+ payload_size);
+ if (!this_anc_if.cali_data_resp.status) {
+ atomic_set(&this_anc_if.state, 0);
+ } else {
+ pr_debug("%s: calib resp status: %d", __func__,
+ this_anc_if.cali_data_resp.status);
+ atomic_set(&this_anc_if.state, -1);
}
return 0;
@@ -465,7 +455,7 @@ int anc_if_tdm_port_stop(u16 port_id)
return anc_if_send_cmd_port_stop(port_id);
}
-int anc_if_set_rpm(u16 port_id, u32 rpm)
+int anc_if_set_algo_module_id(u16 port_id, u32 module_id)
{
int ret = 0;
int index;
@@ -479,7 +469,7 @@ int anc_if_set_rpm(u16 port_id, u32 rpm)
index = q6audio_get_port_index(port_id);
{
- struct anc_set_rpm_command config;
+ struct anc_set_algo_module_id_command config;
memset(&config, 0, sizeof(config));
config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
@@ -496,16 +486,16 @@ int anc_if_set_rpm(u16 port_id, u32 rpm)
config.param.payload_address_lsw = 0x00;
config.param.payload_address_msw = 0x00;
config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AUD_MSVC_MODULE_AUDIO_DEV_ANC_ALGO;
- config.pdata.param_id = AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_RPM;
- config.pdata.param_size = sizeof(config.set_rpm);
- config.set_rpm.minor_version =
- AUD_MSVC_API_VERSION_DEV_ANC_ALGO_RPM;
- config.set_rpm.rpm = rpm;
+ config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
+ config.pdata.param_id =
+ AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_MODULE_ID;
+ config.pdata.param_size = sizeof(config.set_algo_module_id);
+ config.set_algo_module_id.minor_version = 1;
+ config.set_algo_module_id.module_id = module_id;
ret = anc_if_apr_send_pkt(&config, &this_anc_if.wait[index]);
if (ret) {
- pr_err("%s: share resource for port 0x%x failed ret = %d\n",
+ pr_err("%s: anc algo module ID for port 0x%x failed ret = %d\n",
__func__, port_id, ret);
}
}
@@ -513,10 +503,10 @@ int anc_if_set_rpm(u16 port_id, u32 rpm)
return ret;
}
-int anc_if_set_bypass_mode(u16 port_id, u32 bypass_mode)
+int anc_if_set_anc_mic_spkr_layout(u16 port_id,
+struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info *set_mic_spkr_layout_p)
{
int ret = 0;
-
int index;
ret = anc_sdsp_interface_prepare();
@@ -528,7 +518,7 @@ int anc_if_set_bypass_mode(u16 port_id, u32 bypass_mode)
index = q6audio_get_port_index(port_id);
{
- struct anc_set_bypass_mode_command config;
+ struct anc_set_mic_spkr_layout_info_command config;
memset(&config, 0, sizeof(config));
config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
@@ -545,17 +535,16 @@ int anc_if_set_bypass_mode(u16 port_id, u32 bypass_mode)
config.param.payload_address_lsw = 0x00;
config.param.payload_address_msw = 0x00;
config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AUD_MSVC_MODULE_AUDIO_DEV_ANC_ALGO;
+ config.pdata.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE;
config.pdata.param_id =
- AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_BYPASS_MODE;
- config.pdata.param_size = sizeof(config.set_bypass_mode);
- config.set_bypass_mode.minor_version =
- AUD_MSVC_API_VERSION_DEV_ANC_ALGO_BYPASS_MODE;
- config.set_bypass_mode.bypass_mode = bypass_mode;
+ AUD_MSVC_PARAM_ID_PORT_ANC_MIC_SPKR_LAYOUT_INFO;
+ config.pdata.param_size = sizeof(config.set_mic_spkr_layout);
+ memcpy(&config.set_mic_spkr_layout, set_mic_spkr_layout_p,
+ sizeof(config.set_mic_spkr_layout));
ret = anc_if_apr_send_pkt(&config, &this_anc_if.wait[index]);
if (ret) {
- pr_err("%s: share resource for port 0x%x failed ret = %d\n",
+ pr_err("%s: anc algo module ID for port 0x%x failed ret = %d\n",
__func__, port_id, ret);
}
}
@@ -563,10 +552,10 @@ int anc_if_set_bypass_mode(u16 port_id, u32 bypass_mode)
return ret;
}
-int anc_if_set_algo_module_id(u16 port_id, u32 module_id)
+
+int anc_if_set_algo_module_cali_data(u16 port_id, void *data_p)
{
int ret = 0;
-
int index;
ret = anc_sdsp_interface_prepare();
@@ -578,45 +567,67 @@ int anc_if_set_algo_module_id(u16 port_id, u32 module_id)
index = q6audio_get_port_index(port_id);
{
- struct anc_set_algo_module_id_command config;
+ struct anc_set_algo_module_cali_data_command *cali_data_cfg_p;
+ void *config_p = NULL;
+ int cmd_size = 0;
+ void *out_payload_p = NULL;
+ uint32_t *in_payload_p = (uint32_t *)data_p;
+
+ uint32_t module_id = *in_payload_p;
+ uint32_t param_id = *(in_payload_p + 1);
+ uint32_t payload_size = *(in_payload_p + 2);
+
+ cmd_size = sizeof(struct anc_set_algo_module_cali_data_command)
+ + payload_size;
+ config_p = kzalloc(cmd_size, GFP_KERNEL);
+ if (!config_p) {
+ ret = -ENOMEM;
+ return ret;
+ }
- memset(&config, 0, sizeof(config));
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
+ memset(config_p, 0, cmd_size);
+ out_payload_p = config_p
+ + sizeof(struct anc_set_algo_module_cali_data_command);
+
+ cali_data_cfg_p =
+ (struct anc_set_algo_module_cali_data_command *)config_p;
+
+ cali_data_cfg_p->hdr.hdr_field =
+ APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = sizeof(config) -
+ cali_data_cfg_p->hdr.pkt_size = cmd_size;
+ cali_data_cfg_p->hdr.src_port = 0;
+ cali_data_cfg_p->hdr.dest_port = 0;
+ cali_data_cfg_p->hdr.token = index;
+ cali_data_cfg_p->hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
+ cali_data_cfg_p->param.port_id = q6audio_get_port_id(port_id);
+ cali_data_cfg_p->param.payload_size = cmd_size -
sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AUD_MSVC_MODULE_AUDIO_DEV_ANC_ALGO;
- config.pdata.param_id =
- AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_MODULE_ID;
- config.pdata.param_size = sizeof(config.set_algo_module_id);
- config.set_algo_module_id.minor_version = 1;
- config.set_algo_module_id.module_id = module_id;
+ sizeof(struct aud_msvc_port_cmd_set_param_v2);
+ cali_data_cfg_p->param.payload_address_lsw = 0x00;
+ cali_data_cfg_p->param.payload_address_msw = 0x00;
+ cali_data_cfg_p->param.mem_map_handle = 0x00;
+ cali_data_cfg_p->pdata.module_id = module_id;
+ cali_data_cfg_p->pdata.param_id = param_id;
+ cali_data_cfg_p->pdata.param_size = payload_size;
+
+ memcpy(out_payload_p, (in_payload_p + 3), payload_size);
+
+ ret = anc_if_apr_send_pkt(cali_data_cfg_p,
+ &this_anc_if.wait[index]);
+ if (ret)
+ pr_err("%s: anc algo module calibration data for port 0x%x failed ret = %d\n",
+ __func__, port_id, ret);
- ret = anc_if_apr_send_pkt(&config, &this_anc_if.wait[index]);
- if (ret) {
- pr_err("%s: anc algo module ID for port 0x%x failed ret = %d\n",
- __func__, port_id, ret);
- }
+ kfree(config_p);
}
return ret;
}
-int anc_if_set_anc_mic_spkr_layout(u16 port_id,
-struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info *set_mic_spkr_layout_p)
+int anc_if_get_algo_module_cali_data(u16 port_id, void *data_p)
{
int ret = 0;
-
int index;
ret = anc_sdsp_interface_prepare();
@@ -628,35 +639,68 @@ struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info *set_mic_spkr_layout_p)
index = q6audio_get_port_index(port_id);
{
- struct anc_set_mic_spkr_layout_info_command config;
+ struct anc_get_algo_module_cali_data_command *cali_data_cfg_p;
+ void *config_p = NULL;
+ int cmd_size = 0;
+ void *out_payload_p = NULL;
+ uint32_t *in_payload_p = (uint32_t *)data_p;
+
+ uint32_t module_id = *in_payload_p;
+ uint32_t param_id = *(in_payload_p + 1);
+ uint32_t payload_size = *(in_payload_p + 2);
+
+ cmd_size = sizeof(struct anc_get_algo_module_cali_data_command)
+ + payload_size;
+ config_p = kzalloc(cmd_size, GFP_KERNEL);
+ if (!config_p) {
+ ret = -ENOMEM;
+ return ret;
+ }
- memset(&config, 0, sizeof(config));
- config.hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
+ memset(config_p, 0, cmd_size);
+ out_payload_p = config_p +
+ sizeof(struct anc_set_algo_module_cali_data_command);
+
+ cali_data_cfg_p =
+ (struct anc_get_algo_module_cali_data_command *)config_p;
+
+ cali_data_cfg_p->hdr.hdr_field =
+ APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER);
- config.hdr.pkt_size = sizeof(config);
- config.hdr.src_port = 0;
- config.hdr.dest_port = 0;
- config.hdr.token = index;
- config.hdr.opcode = AFE_PORT_CMD_SET_PARAM_V2;
- config.param.port_id = q6audio_get_port_id(port_id);
- config.param.payload_size = sizeof(config) -
+ cali_data_cfg_p->hdr.pkt_size = cmd_size;
+ cali_data_cfg_p->hdr.src_port = 0;
+ cali_data_cfg_p->hdr.dest_port = 0;
+ cali_data_cfg_p->hdr.token = index;
+ cali_data_cfg_p->hdr.opcode = AFE_PORT_CMD_GET_PARAM_V2;
+ cali_data_cfg_p->param.port_id = q6audio_get_port_id(port_id);
+ cali_data_cfg_p->param.payload_size = cmd_size -
sizeof(struct apr_hdr) -
- sizeof(config.param);
- config.param.payload_address_lsw = 0x00;
- config.param.payload_address_msw = 0x00;
- config.param.mem_map_handle = 0x00;
- config.pdata.module_id = AUD_MSVC_MODULE_AUDIO_DEV_ANC_ALGO;
- config.pdata.param_id =
- AUD_MSVC_PARAM_ID_PORT_ANC_MIC_SPKR_LAYOUT_INFO;
- config.pdata.param_size = sizeof(config.set_mic_spkr_layout);
-
- memcpy(&config.set_mic_spkr_layout, set_mic_spkr_layout_p,
- sizeof(config.set_mic_spkr_layout));
- ret = anc_if_apr_send_pkt(&config, &this_anc_if.wait[index]);
- if (ret) {
- pr_err("%s: anc algo module ID for port 0x%x failed ret = %d\n",
+ sizeof(struct aud_msvc_port_cmd_get_param_v2);
+ cali_data_cfg_p->param.payload_address_lsw = 0x00;
+ cali_data_cfg_p->param.payload_address_msw = 0x00;
+ cali_data_cfg_p->param.mem_map_handle = 0x00;
+ cali_data_cfg_p->param.module_id = module_id;
+ cali_data_cfg_p->param.param_id = param_id;
+ cali_data_cfg_p->pdata.param_size = 0;
+ cali_data_cfg_p->pdata.module_id = 0;
+ cali_data_cfg_p->pdata.param_id = 0;
+
+ ret = anc_if_apr_send_pkt(cali_data_cfg_p,
+ &this_anc_if.wait[index]);
+ if (ret)
+ pr_err("%s: anc algo module calibration data for port 0x%x failed ret = %d\n",
__func__, port_id, ret);
- }
+
+ memcpy((in_payload_p + 3),
+ &this_anc_if.cali_data_resp.payload[0], payload_size);
+
+ *in_payload_p = this_anc_if.cali_data_resp.pdata.module_id;
+ *(in_payload_p + 1) =
+ this_anc_if.cali_data_resp.pdata.param_id;
+ *(in_payload_p + 2) =
+ this_anc_if.cali_data_resp.pdata.param_size;
+
+ kfree(config_p);
}
return ret;
@@ -700,7 +744,6 @@ int anc_if_cmd_memory_map(int port_id, phys_addr_t dma_addr_p,
mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL);
if (!mmap_region_cmd) {
ret = -ENOMEM;
- pr_err("%s: allocate mmap_region_cmd failed\n", __func__);
return ret;
}
diff --git a/include/linux/qdsp6v2/audio-anc-dev-mgr.h b/include/linux/qdsp6v2/audio-anc-dev-mgr.h
index dfa6752bc31b..b0ece2dbb239 100644
--- a/include/linux/qdsp6v2/audio-anc-dev-mgr.h
+++ b/include/linux/qdsp6v2/audio-anc-dev-mgr.h
@@ -39,6 +39,8 @@ int msm_anc_dev_stop(void);
int msm_anc_dev_set_info(void *info_p, int32_t anc_cmd);
+int msm_anc_dev_get_info(void *info_p, int32_t anc_cmd);
+
int msm_anc_dev_create(struct platform_device *pdev);
int msm_anc_dev_destroy(struct platform_device *pdev);
diff --git a/include/linux/qdsp6v2/sdsp_anc.h b/include/linux/qdsp6v2/sdsp_anc.h
index 3b236e827e3d..5c1b7055c1d5 100644
--- a/include/linux/qdsp6v2/sdsp_anc.h
+++ b/include/linux/qdsp6v2/sdsp_anc.h
@@ -15,7 +15,6 @@
#include <sound/q6afe-v2.h>
#include <sound/apr_audio-v2.h>
-
#define AUD_MSVC_MODULE_AUDIO_DEV_RESOURCE_SHARE 0x0001028A
#define AUD_MSVC_PARAM_ID_PORT_SHARE_RESOURCE_CONFIG 0x00010297
#define AUD_MSVC_API_VERSION_SHARE_RESOURCE_CONFIG 0x1
@@ -23,8 +22,6 @@
#define AUD_MSVC_PARAM_ID_DEV_ANC_REFS_CONFIG 0x00010286
#define AUD_MSVC_API_VERSION_DEV_ANC_REFS_CONFIG 0x1
#define AUD_MSVC_MODULE_AUDIO_DEV_ANC_ALGO 0x00010234
-#define AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_RPM 0x00010235
-#define AUD_MSVC_API_VERSION_DEV_ANC_ALGO_RPM 0x1
struct aud_msvc_port_param_data_v2 {
/* ID of the module to be configured.
@@ -148,7 +145,7 @@ struct aud_msvc_port_cmd_get_param_v2 {
} __packed;
struct aud_audioif_config_command {
- struct apr_hdr hdr;
+ struct apr_hdr hdr;
struct aud_msvc_port_cmd_set_param_v2 param;
struct aud_msvc_port_param_data_v2 pdata;
union afe_port_config port;
@@ -162,13 +159,6 @@ struct aud_msvc_param_id_dev_share_resource_cfg {
u32 lpm_length;
} __packed;
-
-struct aud_msvc_param_id_dev_anc_algo_rpm {
- u32 minor_version;
- u32 rpm;
-} __packed;
-
-
struct aud_msvc_param_id_dev_anc_refs_cfg {
u32 minor_version;
u16 port_id;
@@ -177,65 +167,20 @@ struct aud_msvc_param_id_dev_anc_refs_cfg {
u32 bit_width;
} __packed;
-
struct anc_share_resource_command {
- struct apr_hdr hdr;
+ struct apr_hdr hdr;
struct aud_msvc_port_cmd_set_param_v2 param;
struct aud_msvc_port_param_data_v2 pdata;
struct aud_msvc_param_id_dev_share_resource_cfg resource;
} __packed;
-
struct anc_config_ref_command {
- struct apr_hdr hdr;
+ struct apr_hdr hdr;
struct aud_msvc_port_cmd_set_param_v2 param;
struct aud_msvc_port_param_data_v2 pdata;
struct aud_msvc_param_id_dev_anc_refs_cfg refs;
} __packed;
-
-
-struct anc_set_rpm_command {
- struct apr_hdr hdr;
- struct aud_msvc_port_cmd_set_param_v2 param;
- struct aud_msvc_port_param_data_v2 pdata;
- struct aud_msvc_param_id_dev_anc_algo_rpm set_rpm;
-} __packed;
-
-struct anc_get_rpm_command {
- struct apr_hdr hdr;
- struct aud_msvc_port_cmd_get_param_v2 param;
- struct aud_msvc_port_param_data_v2 pdata;
- struct aud_msvc_param_id_dev_anc_algo_rpm get_rpm;
-} __packed;
-
-struct anc_get_rpm_resp {
- uint32_t status;
- struct aud_msvc_port_param_data_v2 pdata;
- struct aud_msvc_param_id_dev_anc_algo_rpm res_rpm;
-} __packed;
-
-#define AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_BYPASS_MODE 0x0001029B
-
-#define AUD_MSVC_API_VERSION_DEV_ANC_ALGO_BYPASS_MODE 0x1
-
-#define AUD_MSVC_ANC_ALGO_BYPASS_MODE_NO 0x0
-#define AUD_MSVC_ANC_ALGO_BYPASS_MODE_REFS_TO_ANC_SPKR 0x1
-#define AUD_MSVC_ANC_ALGO_BYPASS_MODE_ANC_MIC_TO_ANC_SPKR 0x2
-#define AUD_MSVC_ANC_ALGO_BYPASS_MODE_REFS_MIXED_ANC_MIC_TO_ANC_SPKR 0x3
-
-struct aud_msvc_param_id_dev_anc_algo_bypass_mode {
- uint32_t minor_version;
- uint32_t bypass_mode;
-} __packed;
-
-struct anc_set_bypass_mode_command {
- struct apr_hdr hdr;
- struct aud_msvc_port_cmd_set_param_v2 param;
- struct aud_msvc_port_param_data_v2 pdata;
- struct aud_msvc_param_id_dev_anc_algo_bypass_mode set_bypass_mode;
-} __packed;
-
#define AUD_MSVC_PARAM_ID_PORT_ANC_ALGO_MODULE_ID 0x0001023A
struct aud_msvc_param_id_dev_anc_algo_module_id {
@@ -244,7 +189,7 @@ struct aud_msvc_param_id_dev_anc_algo_module_id {
} __packed;
struct anc_set_algo_module_id_command {
- struct apr_hdr hdr;
+ struct apr_hdr hdr;
struct aud_msvc_port_cmd_set_param_v2 param;
struct aud_msvc_port_param_data_v2 pdata;
struct aud_msvc_param_id_dev_anc_algo_module_id set_algo_module_id;
@@ -269,13 +214,37 @@ struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info {
} __packed;
struct anc_set_mic_spkr_layout_info_command {
- struct apr_hdr hdr;
+ struct apr_hdr hdr;
struct aud_msvc_port_cmd_set_param_v2 param;
struct aud_msvc_port_param_data_v2 pdata;
struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info
set_mic_spkr_layout;
} __packed;
+struct anc_set_algo_module_cali_data_command {
+ struct apr_hdr hdr;
+ struct aud_msvc_port_cmd_set_param_v2 param;
+ struct aud_msvc_port_param_data_v2 pdata;
+ /*
+ * calibration data payload followed
+ */
+} __packed;
+
+struct anc_get_algo_module_cali_data_command {
+ struct apr_hdr hdr;
+ struct aud_msvc_port_cmd_get_param_v2 param;
+ struct aud_msvc_port_param_data_v2 pdata;
+ /*
+ * calibration data payload followed
+ */
+} __packed;
+
+struct anc_get_algo_module_cali_data_resp {
+ uint32_t status;
+ struct aud_msvc_port_param_data_v2 pdata;
+ uint32_t payload[128];
+} __packed;
+
int anc_if_tdm_port_start(u16 port_id, struct afe_tdm_port_config *tdm_port);
int anc_if_tdm_port_stop(u16 port_id);
@@ -286,15 +255,15 @@ int anc_if_share_resource(u16 port_id, u16 rddma_idx, u16 wrdma_idx,
int anc_if_config_ref(u16 port_id, u32 sample_rate, u32 bit_width,
u16 num_channel);
-int anc_if_set_rpm(u16 port_id, u32 rpm);
-
-int anc_if_set_bypass_mode(u16 port_id, u32 bypass_mode);
-
int anc_if_set_algo_module_id(u16 port_id, u32 module_id);
int anc_if_set_anc_mic_spkr_layout(u16 port_id,
struct aud_msvc_param_id_dev_anc_mic_spkr_layout_info *set_mic_spkr_layout_p);
+int anc_if_set_algo_module_cali_data(u16 port_id, void *data_p);
+
+int anc_if_get_algo_module_cali_data(u16 port_id, void *data_p);
+
int anc_if_shared_mem_map(void);
int anc_if_shared_mem_unmap(void);
diff --git a/include/uapi/linux/msm_audio_anc.h b/include/uapi/linux/msm_audio_anc.h
index d628f7ce9267..87701fd8ee3a 100644
--- a/include/uapi/linux/msm_audio_anc.h
+++ b/include/uapi/linux/msm_audio_anc.h
@@ -21,6 +21,8 @@
/* room for ANC_CMD define extend */
#define ANC_CMD_MAX 0xFF
+#define ANC_CALIBRATION_PAYLOAD_SIZE_MAX 100
+
struct audio_anc_header {
int32_t data_size;
int32_t version;
@@ -35,14 +37,23 @@ struct audio_anc_rpm_info {
struct audio_anc_bypass_mode {
int32_t mode;
};
-
struct audio_anc_algo_module_info {
int32_t module_id;
};
+struct audio_anc_algo_calibration_header {
+ uint32_t module_id;
+ uint32_t param_id;
+ uint32_t payload_size;
+};
+
+struct audio_anc_algo_calibration_body {
+ int32_t payload[ANC_CALIBRATION_PAYLOAD_SIZE_MAX];
+};
+
struct audio_anc_algo_calibration_info {
- int32_t payload_size;
- /* num bytes of payload specificed in payload_size followed */
+ struct audio_anc_algo_calibration_header cali_header;
+ struct audio_anc_algo_calibration_body cali_body;
};
union audio_anc_data {