hal: Add support for generic effect framework
Base changes for supporting generic effect framework
in HAL
Change-Id: I1f5a8d7748848cd5981b86017e6a4466d6b27be7
CRs-Fixed: 1043932
diff --git a/configs/msm8996/msm8996.mk b/configs/msm8996/msm8996.mk
index 71705cb..4f29b53 100644
--- a/configs/msm8996/msm8996.mk
+++ b/configs/msm8996/msm8996.mk
@@ -50,6 +50,7 @@
#DOLBY_DDP := true
AUDIO_FEATURE_ENABLED_SOURCE_TRACKING := true
AUDIO_FEATURE_ENABLED_AUDIOSPHERE := true
+AUDIO_FEATURE_ENABLED_GEF_SUPPORT := true
##AUDIO_FEATURE_FLAGS
#Audio Specific device overlays
diff --git a/hal/Android.mk b/hal/Android.mk
index 812ed99..f457c7b 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -314,6 +314,11 @@
LOCAL_CFLAGS += -DDISPLAY_PORT_ENABLED
endif
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_GEF_SUPPORT)),true)
+ LOCAL_CFLAGS += -DAUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED
+ LOCAL_SRC_FILES += audio_extn/gef.c
+endif
+
LOCAL_CFLAGS += -Wall -Werror
LOCAL_COPY_HEADERS_TO := mm-audio
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index ce2cb46..92fb592 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -596,6 +596,41 @@
struct str_parms *parms);
#endif
+#ifndef AUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED
+
+#define audio_extn_gef_init(adev) (0)
+#define audio_extn_gef_deinit() (0)
+#define audio_extn_gef_notify_device_config(devices, cmask, acdb_id) (0)
+#define audio_extn_gef_send_audio_cal(dev, acdb_dev_id, acdb_device_type,\
+ app_type, topology_id, sample_rate, module_id, param_id, data, length, persist) (0)
+#define audio_extn_gef_get_audio_cal(adev, acdb_dev_id, acdb_device_type,\
+ app_type, topology_id, sample_rate, module_id, param_id, data, length, persist) (0)
+#define audio_extn_gef_store_audio_cal(adev, acdb_dev_id, acdb_device_type,\
+ app_type, topology_id, sample_rate, module_id, param_id, data, length) (0)
+#define audio_extn_gef_retrieve_audio_cal(adev, acdb_dev_id, acdb_device_type,\
+ app_type, topology_id, sample_rate, module_id, param_id, data, length) (0)
+
+#else
+
+void audio_extn_gef_init(struct audio_device *adev);
+void audio_extn_gef_deinit();
+
+void audio_extn_gef_notify_device_config(audio_devices_t audio_device,
+ audio_channel_mask_t channel_mask, int acdb_id);
+int audio_extn_gef_send_audio_cal(void* adev, int acdb_dev_id, int acdb_device_type,
+ int app_type, int topology_id, int sample_rate, uint32_t module_id, uint32_t param_id,
+ void* data, int length, bool persist);
+int audio_extn_gef_get_audio_cal(void* adev, int acdb_dev_id, int acdb_device_type,
+ int app_type, int topology_id, int sample_rate, uint32_t module_id, uint32_t param_id,
+ void* data, int* length, bool persist);
+int audio_extn_gef_store_audio_cal(void* adev, int acdb_dev_id, int acdb_device_type,
+ int app_type, int topology_id, int sample_rate, uint32_t module_id, uint32_t param_id,
+ void* data, int length);
+int audio_extn_gef_retrieve_audio_cal(void* adev, int acdb_dev_id, int acdb_device_type,
+ int app_type, int topology_id, int sample_rate, uint32_t module_id, uint32_t param_id,
+ void* data, int* length);
+
+#endif /* AUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED */
typedef void (* snd_mon_cb)(void * stream, struct str_parms * parms);
#ifndef SND_MONITOR_ENABLED
diff --git a/hal/audio_extn/gef.c b/hal/audio_extn/gef.c
new file mode 100644
index 0000000..d0ccd8c
--- /dev/null
+++ b/hal/audio_extn/gef.c
@@ -0,0 +1,290 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#define LOG_TAG "audio_hw_generic_effect"
+//#define LOG_NDEBUG 0
+#define LOG_NDDEBUG 0
+
+#include <errno.h>
+#include <math.h>
+#include <cutils/log.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include "audio_hw.h"
+#include "platform.h"
+#include "platform_api.h"
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <math.h>
+#include <cutils/properties.h>
+#include "audio_extn.h"
+#include "audio_hw.h"
+
+#ifdef AUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED
+
+#define GEF_LIBRARY "/system/vendor/lib/libqtigef.so"
+
+typedef void* (*gef_init_t)(void*);
+typedef void (*gef_device_config_cb_t)(void*, audio_devices_t,
+ audio_channel_mask_t, int);
+
+typedef struct {
+ void* handle;
+ void* gef_ptr;
+ gef_init_t init;
+ gef_device_config_cb_t device_config_cb;
+} gef_data;
+
+static gef_data gef_hal_handle;
+
+typedef enum {
+ ASM = 0,
+ ADM
+} gef_calibration_type;
+
+typedef enum {
+ AUDIO_DEVICE_CAL_TYPE = 0,
+ AUDIO_STREAM_CAL_TYPE,
+} acdb_device_type;
+
+
+static acdb_device_type make_acdb_device_type_from_gef_cal_type
+ (gef_calibration_type gef_cal_type)
+{
+ int acdb_device_type = 0;
+
+ switch (gef_cal_type) {
+ case ASM:
+ acdb_device_type = AUDIO_STREAM_CAL_TYPE;
+ break;
+ case ADM:
+ acdb_device_type = AUDIO_DEVICE_CAL_TYPE;
+ break;
+ default:
+ acdb_device_type = -1;
+ break;
+ }
+
+ return ((int)acdb_device_type);
+}
+
+void audio_extn_gef_init(struct audio_device *adev)
+{
+ int ret = 0;
+ const char* error = NULL;
+
+ ALOGV("%s: Enter with error", __func__);
+
+ memset(&gef_hal_handle, 0, sizeof(gef_data));
+
+ ret = access(GEF_LIBRARY, R_OK);
+ if (ret == 0) {
+ //: check error for dlopen
+ gef_hal_handle.handle = dlopen(GEF_LIBRARY, RTLD_LAZY);
+ if (gef_hal_handle.handle == NULL) {
+ ALOGE("%s: DLOPEN failed for %s with error %s",
+ __func__, GEF_LIBRARY, dlerror());
+ goto ERROR_RETURN;
+ } else {
+ ALOGV("%s: DLOPEN successful for %s", __func__, GEF_LIBRARY);
+
+ //call dlerror to clear the error
+ dlerror();
+ gef_hal_handle.init =
+ (gef_init_t)dlsym(gef_hal_handle.handle, "gef_init");
+ error = dlerror();
+
+ if(error != NULL) {
+ ALOGE("%s: dlsym of %s failed with error %s",
+ __func__, "gef_init", error);
+ goto ERROR_RETURN;
+ }
+
+ //call dlerror to clear the error
+ error = dlerror();
+ gef_hal_handle.device_config_cb =
+ (gef_device_config_cb_t)dlsym(gef_hal_handle.handle,
+ "gef_device_config_cb");
+ error = dlerror();
+
+ if(error != NULL) {
+ ALOGE("%s: dlsym of %s failed with error %s",
+ __func__, "gef_device_config_cb", error);
+ goto ERROR_RETURN;
+ }
+
+ gef_hal_handle.gef_ptr = gef_hal_handle.init((void*)adev);
+ }
+ } else {
+ ALOGE("%s: %s access failed", __func__, GEF_LIBRARY);
+ }
+
+ERROR_RETURN:
+ ALOGV("%s: Exit with error %d", __func__, ret);
+ return;
+}
+
+
+//this will be called from GEF to exchange calibration using acdb
+int audio_extn_gef_send_audio_cal(void* dev, int acdb_dev_id,
+ int gef_cal_type, int app_type, int topology_id, int sample_rate,
+ uint32_t module_id, uint32_t param_id, void* data, int length, bool persist)
+{
+ int ret = 0;
+ struct audio_device *adev = (struct audio_device*)dev;
+ int acdb_device_type =
+ make_acdb_device_type_from_gef_cal_type(gef_cal_type);
+
+ ALOGV("%s: Enter", __func__);
+
+ //lock adev
+ pthread_mutex_lock(&adev->lock);
+
+ //send cal
+ ret = platform_send_audio_cal(adev->platform, acdb_dev_id,
+ acdb_device_type, app_type, topology_id, sample_rate,
+ module_id, param_id, data, length, persist);
+
+ pthread_mutex_unlock(&adev->lock);
+
+ ALOGV("%s: Exit with error %d", __func__, ret);
+
+ return ret;
+}
+
+//this will be called from GEF to exchange calibration using acdb
+int audio_extn_gef_get_audio_cal(void* dev, int acdb_dev_id,
+ int gef_cal_type, int app_type, int topology_id, int sample_rate,
+ uint32_t module_id, uint32_t param_id, void* data, int* length, bool persist)
+{
+ int ret = 0;
+ struct audio_device *adev = (struct audio_device*)dev;
+ int acdb_device_type =
+ make_acdb_device_type_from_gef_cal_type(gef_cal_type);
+
+ ALOGV("%s: Enter", __func__);
+
+ //lock adev
+ pthread_mutex_lock(&adev->lock);
+
+ ret = platform_get_audio_cal(adev->platform, acdb_dev_id,
+ acdb_device_type, app_type, topology_id, sample_rate,
+ module_id, param_id, data, length, persist);
+
+ pthread_mutex_unlock(&adev->lock);
+
+ ALOGV("%s: Exit with error %d", __func__, ret);
+
+ return ret;
+}
+
+//this will be called from GEF to store into acdb
+int audio_extn_gef_store_audio_cal(void* dev, int acdb_dev_id,
+ int gef_cal_type, int app_type, int topology_id, int sample_rate,
+ uint32_t module_id, uint32_t param_id, void* data, int length)
+{
+ int ret = 0;
+ struct audio_device *adev = (struct audio_device*)dev;
+ int acdb_device_type =
+ make_acdb_device_type_from_gef_cal_type(gef_cal_type);
+
+ ALOGV("%s: Enter", __func__);
+
+ //lock adev
+ pthread_mutex_lock(&adev->lock);
+
+ ret = platform_store_audio_cal(adev->platform, acdb_dev_id,
+ acdb_device_type, app_type, topology_id, sample_rate,
+ module_id, param_id, data, length);
+
+ pthread_mutex_unlock(&adev->lock);
+
+ ALOGV("%s: Exit with error %d", __func__, ret);
+
+ return ret;
+}
+
+//this will be called from GEF to retrieve calibration using acdb
+int audio_extn_gef_retrieve_audio_cal(void* dev, int acdb_dev_id,
+ int gef_cal_type, int app_type, int topology_id, int sample_rate,
+ uint32_t module_id, uint32_t param_id, void* data, int* length)
+{
+ int ret = 0;
+ struct audio_device *adev = (struct audio_device*)dev;
+ int acdb_device_type =
+ make_acdb_device_type_from_gef_cal_type(gef_cal_type);
+
+ ALOGV("%s: Enter", __func__);
+
+ //lock adev
+ pthread_mutex_lock(&adev->lock);
+
+ ret = platform_retrieve_audio_cal(adev->platform, acdb_dev_id,
+ acdb_device_type, app_type, topology_id, sample_rate,
+ module_id, param_id, data, length);
+
+ pthread_mutex_unlock(&adev->lock);
+
+ ALOGV("%s: Exit with error %d", __func__, ret);
+
+ return ret;
+}
+
+//this will be called from HAL to notify GEF of new device configuration
+void audio_extn_gef_notify_device_config(audio_devices_t audio_device,
+ audio_channel_mask_t channel_mask, int acdb_id)
+{
+ ALOGV("%s: Enter", __func__);
+
+ //call into GEF to share channel mask and device info
+ if (gef_hal_handle.handle && gef_hal_handle.device_config_cb) {
+ gef_hal_handle.device_config_cb(gef_hal_handle.gef_ptr, audio_device, channel_mask,
+ acdb_id);
+ }
+
+ ALOGV("%s: Exit", __func__);
+
+ return;
+}
+
+void audio_extn_gef_deinit()
+{
+ ALOGV("%s: Enter", __func__);
+
+ if (gef_hal_handle.handle) {
+ dlclose(gef_hal_handle.handle);
+ }
+
+ memset(&gef_hal_handle, 0, sizeof(gef_data));
+
+ ALOGV("%s: Exit", __func__);
+}
+
+#endif
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 3077f89..df78f83 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1450,6 +1450,12 @@
usecase->stream.out->channel_mask,
&usecase->stream.out->app_type_cfg);
ALOGI("%s Selected apptype: %d", __func__, usecase->stream.out->app_type_cfg.app_type);
+
+ /* Notify device change info to effect clients registered */
+ audio_extn_gef_notify_device_config(
+ usecase->stream.out->devices,
+ usecase->stream.out->channel_mask,
+ platform_get_snd_device_acdb_id(usecase->out_snd_device));
}
enable_audio_route(adev, usecase);
@@ -4570,6 +4576,7 @@
audio_extn_listen_deinit(adev);
audio_extn_utils_release_streams_output_cfg_list(&adev->streams_output_cfg_list);
audio_route_free(adev->audio_route);
+ audio_extn_gef_deinit();
free(adev->snd_dev_ref_cnt);
platform_deinit(adev->platform);
if (adev->adm_deinit)
@@ -4698,6 +4705,7 @@
}
audio_extn_listen_init(adev, adev->snd_card);
audio_extn_sound_trigger_init(adev);
+ audio_extn_gef_init(adev);
if (access(OFFLOAD_EFFECTS_BUNDLE_LIBRARY_PATH, R_OK) == 0) {
adev->offload_effects_lib = dlopen(OFFLOAD_EFFECTS_BUNDLE_LIBRARY_PATH, RTLD_NOW);
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 2540184..25f862e 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -5639,3 +5639,43 @@
{
return false;
}
+
+int platform_send_audio_cal(void* platform __unused,
+ int acdb_dev_id __unused, int acdb_device_type __unused,
+ int app_type __unused, int topology_id __unused,
+ int sample_rate __unused, uint32_t module_id __unused,
+ uint32_t param_id __unused, void* data __unused,
+ int length __unused, bool persist __unused)
+{
+ return -ENOSYS;
+}
+
+int platform_get_audio_cal(void* platform __unused,
+ int acdb_dev_id __unused, int acdb_device_type __unused,
+ int app_type __unused, int topology_id __unused,
+ int sample_rate __unused, uint32_t module_id __unused,
+ uint32_t param_id __unused, void* data __unused,
+ int* length __unused, bool persist __unused)
+{
+ return -ENOSYS;
+}
+
+int platform_store_audio_cal(void* platform __unused,
+ int acdb_dev_id __unused, int acdb_device_type __unused,
+ int app_type __unused, int topology_id __unused,
+ int sample_rate __unused, uint32_t module_id __unused,
+ uint32_t param_id __unused, void* data __unused,
+ int length __unused)
+{
+ return -ENOSYS;
+}
+
+int platform_retrieve_audio_cal(void* platform __unused,
+ int acdb_dev_id __unused, int acdb_device_type __unused,
+ int app_type __unused, int topology_id __unused,
+ int sample_rate __unused, uint32_t module_id __unused,
+ uint32_t param_id __unused, void* data __unused,
+ int* length __unused)
+{
+ return -ENOSYS;
+}
diff --git a/hal/msm8960/platform.c b/hal/msm8960/platform.c
index f3c4d28..c1e8e7f 100644
--- a/hal/msm8960/platform.c
+++ b/hal/msm8960/platform.c
@@ -1237,7 +1237,48 @@
bool platform_check_backends_match(snd_device_t snd_device1 __unused,
snd_device_t snd_device2 __unused)
{
- return true;
+ return -ENOSYS;
+}
+
+int platform_send_audio_cal(void* platform __unused,
+ int acdb_dev_id __unused, int acdb_device_type __unused,
+ int app_type __unused, int topology_id __unused,
+ int sample_rate __unused, uint32_t module_id,
+ uint32_t param_id, void* data __unused,
+ int length __unused, bool persist __unused)
+{
+ return -ENOSYS;
+}
+
+int platform_get_audio_cal(void* platform __unused,
+ int acdb_dev_id __unused, int acdb_device_type __unused,
+ int app_type __unused, int topology_id __unused,
+ int sample_rate __unused, uint32_t module_id,
+ uint32_t param_id, void* data __unused,
+ int* length __unused, bool persist __unused)
+{
+ return -ENOSYS;
+}
+
+int platform_store_audio_cal(void* platform __unused,
+ int acdb_dev_id __unused, int acdb_device_type __unused,
+ int app_type __unused, int topology_id __unused,
+ int sample_rate __unused, uint32_t module_id,
+ uint32_t param_id, void* data __unused,
+ int length __unused)
+{
+ return -ENOSYS;
+}
+
+
+int platform_retrieve_audio_cal(void* platform __unused,
+ int acdb_dev_id __unused, int acdb_device_type __unused,
+ int app_type __unused, int topology_id __unused,
+ int sample_rate __unused, uint32_t module_id,
+ uint32_t param_id, void* data __unused,
+ int* length __unused)
+{
+ return -ENOSYS;
}
int platform_set_sidetone(struct audio_device *adev,
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 91e7235..2dd1d13 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -5625,3 +5625,153 @@
}
return 0;
}
+
+static void make_cal_cfg(acdb_audio_cal_cfg_t* cal, int acdb_dev_id,
+ int acdb_device_type, int app_type, int topology_id,
+ int sample_rate, uint32_t module_id, uint32_t param_id, bool persist)
+{
+ int persist_send_flags = 1;
+
+ if (!cal) {
+ return;
+ }
+
+ if (persist)
+ persist_send_flags |= 0x2;
+
+ memset(cal, 0, sizeof(acdb_audio_cal_cfg_t));
+
+ cal->persist = persist;
+ cal->app_type = app_type;
+ cal->acdb_dev_id = acdb_dev_id;
+ cal->sampling_rate = sample_rate;
+ cal->topo_id = topology_id;
+ //if module and param id is set to 0, the whole blob will be stored
+ //or sent to the DSP
+ cal->module_id = module_id;
+ cal->param_id = param_id;
+ cal->cal_type = acdb_device_type;
+ cal->persist = persist;
+
+}
+
+int platform_send_audio_cal(void* platform, int acdb_dev_id,
+ int acdb_device_type, int app_type, int topology_id, int sample_rate,
+ uint32_t module_id, uint32_t param_id, void* data, int length, bool persist)
+{
+ int ret = 0;
+ struct platform_data *my_data = (struct platform_data *)platform;
+ acdb_audio_cal_cfg_t cal;
+ memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));
+
+ if (!my_data) {
+ ret = -EINVAL;
+ goto ERROR_RETURN;
+ }
+
+ make_cal_cfg(&cal, acdb_dev_id, acdb_device_type, app_type, topology_id,
+ sample_rate, module_id, param_id, true);
+
+ if (my_data->acdb_set_audio_cal) {
+ // persist audio cal in local cache
+ if (persist) {
+ ret = my_data->acdb_set_audio_cal((void*)&cal, data, (uint32_t)length);
+ }
+ // send audio cal to dsp
+ if (ret == 0) {
+ cal.persist = false;
+ ret = my_data->acdb_set_audio_cal((void*)&cal, data, (uint32_t)length);
+ if (persist && (ret != 0)) {
+ ALOGV("[%s] audio cal stored with success, ignore set cal failure", __func__);
+ ret = 0;
+ }
+ }
+ }
+
+ERROR_RETURN:
+ return ret;
+}
+
+int platform_get_audio_cal(void* platform, int acdb_dev_id,
+ int acdb_device_type, int app_type, int topology_id,
+ int sample_rate, uint32_t module_id, uint32_t param_id,
+ void* data, int* length, bool persist)
+{
+ int ret = 0;
+ struct platform_data *my_data = (struct platform_data *)platform;
+ acdb_audio_cal_cfg_t cal;
+ memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));
+
+ if (!my_data) {
+ ret = -EINVAL;
+ goto ERROR_RETURN;
+ }
+
+ make_cal_cfg(&cal, acdb_dev_id, acdb_device_type, app_type, topology_id,
+ sample_rate, module_id, param_id, false);
+
+ if (my_data->acdb_get_audio_cal) {
+ // get cal from dsp
+ ret = my_data->acdb_get_audio_cal((void*)&cal, data, (uint32_t*)length);
+ // get cached cal if prevoius attempt fails and persist flag is set
+ if ((ret != 0) && persist) {
+ cal.persist = true;
+ ret = my_data->acdb_get_audio_cal((void*)&cal, data, (uint32_t*)length);
+ }
+ }
+
+ERROR_RETURN:
+ return ret;
+}
+
+int platform_store_audio_cal(void* platform, int acdb_dev_id,
+ int acdb_device_type, int app_type, int topology_id,
+ int sample_rate, uint32_t module_id, uint32_t param_id,
+ void* data, int length)
+{
+ int ret = 0;
+ struct platform_data *my_data = (struct platform_data *)platform;
+ acdb_audio_cal_cfg_t cal;
+ memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));
+
+ if (!my_data) {
+ ret = -EINVAL;
+ goto ERROR_RETURN;
+ }
+
+ make_cal_cfg(&cal, acdb_dev_id, acdb_device_type, app_type, topology_id,
+ sample_rate, module_id, param_id, true);
+
+ if (my_data->acdb_set_audio_cal) {
+ ret = my_data->acdb_set_audio_cal((void*)&cal, data, (uint32_t)length);
+ }
+
+ERROR_RETURN:
+ return ret;
+}
+
+int platform_retrieve_audio_cal(void* platform, int acdb_dev_id,
+ int acdb_device_type, int app_type, int topology_id,
+ int sample_rate, uint32_t module_id, uint32_t param_id,
+ void* data, int* length)
+{
+ int ret = 0;
+ struct platform_data *my_data = (struct platform_data *)platform;
+ acdb_audio_cal_cfg_t cal;
+ memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));
+
+ if (!my_data) {
+ ret = -EINVAL;
+ goto ERROR_RETURN;
+ }
+
+ make_cal_cfg(&cal, acdb_dev_id, acdb_device_type, app_type, topology_id,
+ sample_rate, module_id, param_id, true);
+
+ if (my_data->acdb_get_audio_cal) {
+ ret = my_data->acdb_get_audio_cal((void*)&cal, data, (uint32_t*)length);
+ }
+
+ERROR_RETURN:
+ return ret;
+}
diff --git a/hal/platform_api.h b/hal/platform_api.h
index 6ca95db..e5f8f8a 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -160,4 +160,21 @@
bool platform_check_codec_asrc_support(void *platform);
int platform_get_backend_index(snd_device_t snd_device);
int platform_get_ext_disp_type(void *platform);
+
+int platform_send_audio_cal(void* platform, int acdb_dev_id, int acdb_device_type,
+ int app_type, int topology_id, int sample_rate, uint32_t module_id, uint32_t param_id,
+ void* data, int length, bool persist);
+
+int platform_get_audio_cal(void* platform, int acdb_dev_id, int acdb_device_type,
+ int app_type, int topology_id, int sample_rate, uint32_t module_id, uint32_t param_id,
+ void* data, int* length, bool persist);
+
+int platform_store_audio_cal(void* platform, int acdb_dev_id, int acdb_device_type,
+ int app_type, int topology_id, int sample_rate, uint32_t module_id, uint32_t param_id,
+ void* data, int length);
+
+int platform_retrieve_audio_cal(void* platform, int acdb_dev_id, int acdb_device_type,
+ int app_type, int topology_id, int sample_rate, uint32_t module_id, uint32_t param_id,
+ void* data, int* length);
+
#endif // AUDIO_PLATFORM_API_H