Merge "dsp: add support for new ADM LSM cal types"

这个提交包含在:
Linux Build Service Account
2017-12-16 03:09:26 -08:00
提交者 Gerrit - the friendly Code Review server
当前提交 9c81253780
修改 7 个文件,包含 169 行新增45 行删除

查看文件

@@ -57,7 +57,7 @@
static struct mutex routing_lock;
static struct cal_type_data *cal_data;
static struct cal_type_data *cal_data[MAX_ROUTING_CAL_TYPES];
static int fm_switch_enable;
static int hfp_switch_enable;
@@ -883,21 +883,21 @@ done:
}
EXPORT_SYMBOL(msm_pcm_routing_get_stream_app_type_cfg);
static struct cal_block_data *msm_routing_find_topology_by_path(int path)
static struct cal_block_data *msm_routing_find_topology_by_path(int path,
int cal_index)
{
struct list_head *ptr, *next;
struct cal_block_data *cal_block = NULL;
struct list_head *ptr, *next;
struct cal_block_data *cal_block = NULL;
pr_debug("%s\n", __func__);
list_for_each_safe(ptr, next,
&cal_data->cal_blocks) {
&cal_data[cal_index]->cal_blocks) {
cal_block = list_entry(ptr,
struct cal_block_data, list);
if (((struct audio_cal_info_adm_top *)cal_block->cal_info)
->path == path) {
if (((struct audio_cal_info_adm_top *)cal_block
->cal_info)->path == path) {
return cal_block;
}
}
@@ -907,7 +907,8 @@ static struct cal_block_data *msm_routing_find_topology_by_path(int path)
static struct cal_block_data *msm_routing_find_topology(int path,
int app_type,
int acdb_id)
int acdb_id,
int cal_index)
{
struct list_head *ptr, *next;
struct cal_block_data *cal_block = NULL;
@@ -916,7 +917,7 @@ static struct cal_block_data *msm_routing_find_topology(int path,
pr_debug("%s\n", __func__);
list_for_each_safe(ptr, next,
&cal_data->cal_blocks) {
&cal_data[cal_index]->cal_blocks) {
cal_block = list_entry(ptr,
struct cal_block_data, list);
@@ -931,7 +932,7 @@ static struct cal_block_data *msm_routing_find_topology(int path,
}
pr_debug("%s: Can't find topology for path %d, app %d, acdb_id %d defaulting to search by path\n",
__func__, path, app_type, acdb_id);
return msm_routing_find_topology_by_path(path);
return msm_routing_find_topology_by_path(cal_index, path);
}
static int msm_routing_get_adm_topology(int fedai_id, int session_type,
@@ -941,28 +942,37 @@ static int msm_routing_get_adm_topology(int fedai_id, int session_type,
struct cal_block_data *cal_block = NULL;
int app_type = 0, acdb_dev_id = 0;
pr_debug("%s: fedai_id %d, session_type %d, be_id %d\n",
__func__, fedai_id, session_type, be_id);
if (cal_data == NULL)
goto done;
mutex_lock(&cal_data->lock);
app_type = fe_dai_app_type_cfg[fedai_id][session_type][be_id].app_type;
acdb_dev_id =
fe_dai_app_type_cfg[fedai_id][session_type][be_id].acdb_dev_id;
mutex_lock(&cal_data[ADM_TOPOLOGY_CAL_TYPE_IDX]->lock);
cal_block = msm_routing_find_topology(session_type, app_type,
acdb_dev_id);
if (cal_block == NULL)
goto unlock;
acdb_dev_id,
ADM_TOPOLOGY_CAL_TYPE_IDX);
if (cal_block != NULL)
topology = ((struct audio_cal_info_adm_top *)
cal_block->cal_info)->topology;
mutex_unlock(&cal_data[ADM_TOPOLOGY_CAL_TYPE_IDX]->lock);
if (cal_block == NULL) {
pr_debug("%s: Check for LSM topology\n", __func__);
mutex_lock(&cal_data[ADM_LSM_TOPOLOGY_CAL_TYPE_IDX]->lock);
cal_block = msm_routing_find_topology(session_type, app_type,
acdb_dev_id,
ADM_LSM_TOPOLOGY_CAL_TYPE_IDX);
if (cal_block != NULL)
topology = ((struct audio_cal_info_adm_top *)
cal_block->cal_info)->topology;
mutex_unlock(&cal_data[ADM_LSM_TOPOLOGY_CAL_TYPE_IDX]->lock);
}
topology = ((struct audio_cal_info_adm_top *)
cal_block->cal_info)->topology;
unlock:
mutex_unlock(&cal_data->lock);
done:
pr_debug("%s: Using topology %d\n", __func__, topology);
return topology;
@@ -2562,6 +2572,7 @@ static int msm_routing_lsm_func_put(struct snd_kcontrol *kcontrol,
pr_debug("%s: port_id 0x%x, mad_type %d\n", __func__, port_id,
mad_type);
adm_set_lsm_port_id(port_id);
return afe_port_set_mad_type(port_id, mad_type);
}
@@ -16936,14 +16947,39 @@ int msm_routing_check_backend_enabled(int fedai_id)
return 0;
}
static int get_cal_type_index(int32_t cal_type)
{
int ret = -EINVAL;
switch (cal_type) {
case ADM_TOPOLOGY_CAL_TYPE:
ret = ADM_TOPOLOGY_CAL_TYPE_IDX;
break;
case ADM_LSM_TOPOLOGY_CAL_TYPE:
ret = ADM_LSM_TOPOLOGY_CAL_TYPE_IDX;
break;
default:
pr_err("%s: Invalid cal type %d\n", __func__, cal_type);
}
return ret;
}
static int msm_routing_set_cal(int32_t cal_type,
size_t data_size, void *data)
{
int ret = 0;
int cal_index;
pr_debug("%s\n", __func__);
ret = cal_utils_set_cal(data_size, data, cal_data, 0, NULL);
cal_index = get_cal_type_index(cal_type);
if (cal_index < 0) {
pr_err("%s: Could not get cal index %d\n",
__func__, cal_index);
ret = -EINVAL;
goto done;
}
ret = cal_utils_set_cal(data_size, data, cal_data[cal_index], 0, NULL);
if (ret < 0) {
pr_err("%s: cal_utils_set_cal failed, ret = %d, cal type = %d!\n",
__func__, ret, cal_type);
@@ -16958,22 +16994,27 @@ static void msm_routing_delete_cal_data(void)
{
pr_debug("%s\n", __func__);
cal_utils_destroy_cal_types(1, &cal_data);
cal_utils_destroy_cal_types(MAX_ROUTING_CAL_TYPES, &cal_data[0]);
}
static int msm_routing_init_cal_data(void)
{
int ret = 0;
struct cal_type_info cal_type_info = {
{ADM_TOPOLOGY_CAL_TYPE,
struct cal_type_info cal_type_info[] = {
{{ADM_TOPOLOGY_CAL_TYPE,
{NULL, NULL, NULL,
msm_routing_set_cal, NULL, NULL} },
{NULL, NULL, cal_utils_match_buf_num}
{NULL, NULL, cal_utils_match_buf_num} },
{{ADM_LSM_TOPOLOGY_CAL_TYPE,
{NULL, NULL, NULL,
msm_routing_set_cal, NULL, NULL} },
{NULL, NULL, cal_utils_match_buf_num} },
};
pr_debug("%s\n", __func__);
ret = cal_utils_create_cal_types(1, &cal_data,
&cal_type_info);
ret = cal_utils_create_cal_types(MAX_ROUTING_CAL_TYPES, &cal_data[0],
&cal_type_info[0]);
if (ret < 0) {
pr_err("%s: could not create cal type!\n",
__func__);