hal: add support to set custom channel configs
Add generic implementation to set custom channel configs
as per usecase config present in platform info xml.
Each usecase identified by usecase id, input channels,
output channels, snd_device and feature id can have
a separate channel config.
Change-Id: I957b5b06adbcd17f65ed49b839327bf8e9e8b318
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 690f771..d79f5a5 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -309,6 +309,7 @@
struct snd_device_to_mic_map mic_map[SND_DEVICE_MAX];
struct spkr_device_chmap *spkr_ch_map;
bool use_sprk_default_sample_rate;
+ struct listnode custom_mtmx_params_list;
};
struct spkr_device_chmap {
@@ -2399,6 +2400,7 @@
my_data->hifi_audio = true;
list_init(&my_data->acdb_meta_key_list);
+ list_init(&my_data->custom_mtmx_params_list);
set_platform_defaults(my_data);
@@ -2769,6 +2771,75 @@
return my_data;
}
+struct audio_custom_mtmx_params *
+ platform_get_custom_mtmx_params(void *platform,
+ struct audio_custom_mtmx_params_info *info)
+{
+ struct platform_data *my_data = (struct platform_data *)platform;
+ struct listnode *node = NULL;
+ struct audio_custom_mtmx_params *params = NULL;
+
+ list_for_each(node, &my_data->custom_mtmx_params_list) {
+ params = node_to_item(node, struct audio_custom_mtmx_params, list);
+ if (params &&
+ params->info.id == info->id &&
+ params->info.ip_channels == info->ip_channels &&
+ params->info.op_channels == info->op_channels &&
+ params->info.usecase_id == info->usecase_id &&
+ params->info.snd_device == info->snd_device) {
+ ALOGV("%s: found params with ip_ch %d op_ch %d uc_id %d snd_dev %d",
+ __func__, info->ip_channels, info->op_channels,
+ info->usecase_id, info->snd_device);
+ return params;
+ }
+ }
+ ALOGI("%s: no matching param with id %d ip_ch %d op_ch %d uc_id %d snd_dev %d",
+ __func__, info->id, info->ip_channels, info->op_channels,
+ info->usecase_id, info->snd_device);
+ return NULL;
+}
+
+int platform_add_custom_mtmx_params(void *platform,
+ struct audio_custom_mtmx_params_info *info)
+{
+ struct platform_data *my_data = (struct platform_data *)platform;
+ struct audio_custom_mtmx_params *params = NULL;
+ uint32_t size = sizeof(*params);
+
+ if (info->ip_channels > AUDIO_CHANNEL_COUNT_MAX ||
+ info->op_channels > AUDIO_CHANNEL_COUNT_MAX) {
+ ALOGE("%s: unusupported channels in %d, out %d",
+ __func__, info->ip_channels, info->op_channels);
+ return -EINVAL;
+ }
+
+ size += sizeof(params->coeffs[0]) * info->ip_channels * info->op_channels;
+ params = (struct audio_custom_mtmx_params *) calloc(1, size);
+ if (!params) {
+ ALOGE("%s: failed to add custom mtmx params", __func__);
+ return -ENOMEM;
+ }
+
+ ALOGI("%s: adding mtmx params with id %d ip_ch %d op_ch %d uc_id %d snd_dev %d",
+ __func__, info->id, info->ip_channels, info->op_channels,
+ info->usecase_id, info->snd_device);
+
+ params->info = *info;
+ list_add_tail(&my_data->custom_mtmx_params_list, ¶ms->list);
+ return 0;
+}
+
+static void platform_release_custom_mtmx_params(void *platform)
+{
+ struct platform_data *my_data = (struct platform_data *)platform;
+ struct listnode *node = NULL, *tempnode = NULL;
+
+ list_for_each_safe(node, tempnode, &my_data->custom_mtmx_params_list) {
+ list_remove(node);
+ free(node_to_item(node, struct audio_custom_mtmx_params, list));
+ }
+}
+
void platform_release_acdb_metainfo_key(void *platform)
{
struct platform_data *my_data = (struct platform_data *)platform;
@@ -2854,6 +2925,7 @@
/* free acdb_meta_key_list */
platform_release_acdb_metainfo_key(platform);
+ platform_release_custom_mtmx_params(platform);
if (my_data->acdb_deallocate)
my_data->acdb_deallocate();