hal: support dynamic feature enablement for auto hal
Support dynamic feature enablement for auto hal
driver compilation.
Update fp for ext_hw_plugin driver.
Change-Id: Id534530875068b9641df103a3b58aaac06c7578e
diff --git a/hal/Android.mk b/hal/Android.mk
index 6e47039..595e0c6 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -347,11 +347,6 @@
LOCAL_STATIC_LIBRARIES += libprofile_rt
endif
-#ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AUTO_HAL)),true)
-# LOCAL_CFLAGS += -DAUDIO_EXTN_AUTO_HAL_ENABLED
-# LOCAL_SRC_FILES += audio_extn/auto_hal.c
-#endif
-
LOCAL_SHARED_LIBRARIES += libbase libhidlbase libhwbinder libutils android.hardware.power@1.2 liblog
LOCAL_SRC_FILES += audio_perf.cpp
diff --git a/hal/audio_extn/Android.mk b/hal/audio_extn/Android.mk
index 2aba6e1..a8667fe 100644
--- a/hal/audio_extn/Android.mk
+++ b/hal/audio_extn/Android.mk
@@ -823,4 +823,60 @@
LOCAL_HEADER_LIBRARIES += libsystem_headers
include $(BUILD_SHARED_LIBRARY)
+#-------------------------------------------
+# Build AUTO_HAL LIB
+#-------------------------------------------
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libautohal
+
+LOCAL_VENDOR_MODULE := true
+
+PRIMARY_HAL_PATH := vendor/qcom/opensource/audio-hal/primary-hal/hal
+AUDIO_PLATFORM := $(TARGET_BOARD_PLATFORM)
+
+ifneq ($(filter sdm845 sdm710 sdmshrike msmnile kona lito atoll sdm660 msm8937 msm8998 $(MSMSTEPPE) $(TRINKET),$(TARGET_BOARD_PLATFORM)),)
+ # B-family platform uses msm8974 code base
+ AUDIO_PLATFORM := msm8974
+ MULTIPLE_HW_VARIANTS_ENABLED := true
+endif
+
+LOCAL_SRC_FILES:= \
+ auto_hal.c
+
+LOCAL_CFLAGS += \
+ -Wall \
+ -Werror \
+ -Wno-unused-function \
+ -Wno-unused-variable
+
+LOCAL_SHARED_LIBRARIES := \
+ libaudioutils \
+ libcutils \
+ libdl \
+ libexpat \
+ liblog
+
+LOCAL_C_INCLUDES := \
+ $(PRIMARY_HAL_PATH) \
+ $(PRIMARY_HAL_PATH)/$(AUDIO_PLATFORM) \
+ external/tinyalsa/include \
+ external/tinycompress/include \
+ external/expat/lib \
+ system/media/audio_utils/include \
+ $(call include-path-for, audio-route) \
+
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
+LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/techpack/audio/include
+LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
+
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_DLKM)),true)
+ LOCAL_HEADER_LIBRARIES += audio_kernel_headers
+ LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/vendor/qcom/opensource/audio-kernel/include
+ LOCAL_ADDITIONAL_DEPENDENCIES += $(BOARD_VENDOR_KERNEL_MODULES)
+endif
+
+LOCAL_HEADER_LIBRARIES += libhardware_headers
+LOCAL_HEADER_LIBRARIES += libsystem_headers
+include $(BUILD_SHARED_LIBRARY)
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 8e65471..c2e1349 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -4639,8 +4639,8 @@
{
if(ext_hw_plugin_init) {
ext_hw_plugin_init_config_t ext_hw_plugin_init_config;
- ext_hw_plugin_init_config.fp_audio_route_apply_and_update_path =
- audio_route_apply_and_update_path;
+ ext_hw_plugin_init_config.fp_b64decode = b64decode;
+ ext_hw_plugin_init_config.fp_b64encode = b64encode;
return ext_hw_plugin_init(adev, ext_hw_plugin_init_config);
}
else
@@ -5391,6 +5391,224 @@
}
// END: MAXX_AUDIO =====================================================================
+// START: AUTO_HAL ===================================================================
+#ifdef __LP64__
+#define AUTO_HAL_LIB_PATH "/vendor/lib64/libautohal.so"
+#else
+#define AUTO_HAL_LIB_PATH "/vendor/lib/libautohal.so"
+#endif
+
+static void *auto_hal_lib_handle = NULL;
+
+typedef int (*auto_hal_init_t)(struct audio_device*,
+ auto_hal_init_config_t);
+static auto_hal_init_t auto_hal_init;
+
+typedef void (*auto_hal_deinit_t)();
+static auto_hal_deinit_t auto_hal_deinit;
+
+typedef int (*auto_hal_create_audio_patch_t)(struct audio_hw_device*,
+ unsigned int,
+ const struct audio_port_config*,
+ unsigned int,
+ const struct audio_port_config*,
+ audio_patch_handle_t*);
+static auto_hal_create_audio_patch_t auto_hal_create_audio_patch;
+
+typedef int (*auto_hal_release_audio_patch_t)(struct audio_hw_device*,
+ audio_patch_handle_t);
+static auto_hal_release_audio_patch_t auto_hal_release_audio_patch;
+
+typedef int (*auto_hal_get_car_audio_stream_from_address_t)(const char*);
+static auto_hal_get_car_audio_stream_from_address_t auto_hal_get_car_audio_stream_from_address;
+
+typedef int (*auto_hal_open_output_stream_t)(struct stream_out*);
+static auto_hal_open_output_stream_t auto_hal_open_output_stream;
+
+typedef bool (*auto_hal_is_bus_device_usecase_t)(audio_usecase_t);
+static auto_hal_is_bus_device_usecase_t auto_hal_is_bus_device_usecase;
+
+typedef snd_device_t (*auto_hal_get_snd_device_for_car_audio_stream_t)(
+ struct stream_out*);
+static auto_hal_get_snd_device_for_car_audio_stream_t auto_hal_get_snd_device_for_car_audio_stream;
+
+typedef int (*auto_hal_get_audio_port_t)(struct audio_hw_device*,
+ struct audio_port*);
+static auto_hal_get_audio_port_t auto_hal_get_audio_port;
+
+typedef int (*auto_hal_set_audio_port_config_t)(struct audio_hw_device*,
+ const struct audio_port_config*);
+static auto_hal_set_audio_port_config_t auto_hal_set_audio_port_config;
+
+typedef void (*auto_hal_set_parameters_t)(struct audio_device*,
+ struct str_parms*);
+static auto_hal_set_parameters_t auto_hal_set_parameters;
+
+int auto_hal_feature_init(bool is_feature_enabled)
+{
+ ALOGD("%s: Called with feature %s", __func__,
+ is_feature_enabled ? "Enabled" : "NOT Enabled");
+ if (is_feature_enabled) {
+ // dlopen lib
+ auto_hal_lib_handle = dlopen(AUTO_HAL_LIB_PATH, RTLD_NOW);
+
+ if (!auto_hal_lib_handle) {
+ ALOGE("%s: dlopen failed", __func__);
+ goto feature_disabled;
+ }
+ if (!(auto_hal_init = (auto_hal_init_t)dlsym(
+ auto_hal_lib_handle, "auto_hal_init")) ||
+ !(auto_hal_deinit =
+ (auto_hal_deinit_t)dlsym(
+ auto_hal_lib_handle, "auto_hal_deinit")) ||
+ !(auto_hal_create_audio_patch =
+ (auto_hal_create_audio_patch_t)dlsym(
+ auto_hal_lib_handle, "auto_hal_create_audio_patch")) ||
+ !(auto_hal_release_audio_patch =
+ (auto_hal_release_audio_patch_t)dlsym(
+ auto_hal_lib_handle, "auto_hal_release_audio_patch")) ||
+ !(auto_hal_get_car_audio_stream_from_address =
+ (auto_hal_get_car_audio_stream_from_address_t)dlsym(
+ auto_hal_lib_handle, "auto_hal_get_car_audio_stream_from_address")) ||
+ !(auto_hal_open_output_stream =
+ (auto_hal_open_output_stream_t)dlsym(
+ auto_hal_lib_handle, "auto_hal_open_output_stream")) ||
+ !(auto_hal_is_bus_device_usecase =
+ (auto_hal_is_bus_device_usecase_t)dlsym(
+ auto_hal_lib_handle, "auto_hal_is_bus_device_usecase")) ||
+ !(auto_hal_get_snd_device_for_car_audio_stream =
+ (auto_hal_get_snd_device_for_car_audio_stream_t)dlsym(
+ auto_hal_lib_handle, "auto_hal_get_snd_device_for_car_audio_stream")) ||
+ !(auto_hal_get_audio_port =
+ (auto_hal_get_audio_port_t)dlsym(
+ auto_hal_lib_handle, "auto_hal_get_audio_port")) ||
+ !(auto_hal_set_audio_port_config =
+ (auto_hal_set_audio_port_config_t)dlsym(
+ auto_hal_lib_handle, "auto_hal_set_audio_port_config")) ||
+ !(auto_hal_set_parameters =
+ (auto_hal_set_parameters_t)dlsym(
+ auto_hal_lib_handle, "auto_hal_set_parameters"))) {
+ ALOGE("%s: dlsym failed", __func__);
+ goto feature_disabled;
+ }
+ ALOGD("%s:: ---- Feature AUTO_HAL is Enabled ----", __func__);
+ return 0;
+ }
+
+feature_disabled:
+ if (auto_hal_lib_handle) {
+ dlclose(auto_hal_lib_handle);
+ auto_hal_lib_handle = NULL;
+ }
+
+ auto_hal_init = NULL;
+ auto_hal_deinit = NULL;
+ auto_hal_create_audio_patch = NULL;
+ auto_hal_release_audio_patch = NULL;
+ auto_hal_get_car_audio_stream_from_address = NULL;
+ auto_hal_open_output_stream = NULL;
+ auto_hal_is_bus_device_usecase = NULL;
+ auto_hal_get_snd_device_for_car_audio_stream = NULL;
+ auto_hal_get_audio_port = NULL;
+ auto_hal_set_audio_port_config = NULL;
+ auto_hal_set_parameters = NULL;
+
+ ALOGW(":: %s: ---- Feature AUTO_HAL is disabled ----", __func__);
+ return -ENOSYS;
+}
+
+int audio_extn_auto_hal_init(struct audio_device *adev)
+{
+ if(auto_hal_init) {
+ auto_hal_init_config_t auto_hal_init_config;
+ auto_hal_init_config.fp_in_get_stream = in_get_stream;
+ auto_hal_init_config.fp_out_get_stream = out_get_stream;
+ auto_hal_init_config.fp_audio_extn_ext_hw_plugin_usecase_start = audio_extn_ext_hw_plugin_usecase_start;
+ auto_hal_init_config.fp_audio_extn_ext_hw_plugin_usecase_stop = audio_extn_ext_hw_plugin_usecase_stop;
+ auto_hal_init_config.fp_get_usecase_from_list = get_usecase_from_list;
+ auto_hal_init_config.fp_get_output_period_size = get_output_period_size;
+ auto_hal_init_config.fp_audio_extn_ext_hw_plugin_set_audio_gain = audio_extn_ext_hw_plugin_set_audio_gain;
+ return auto_hal_init(adev, auto_hal_init_config);
+ }
+ else
+ return 0;
+}
+
+void audio_extn_auto_hal_deinit()
+{
+ if (auto_hal_deinit)
+ auto_hal_deinit();
+}
+
+int audio_extn_auto_hal_create_audio_patch(struct audio_hw_device *dev,
+ unsigned int num_sources,
+ const struct audio_port_config *sources,
+ unsigned int num_sinks,
+ const struct audio_port_config *sinks,
+ audio_patch_handle_t *handle)
+{
+ return ((auto_hal_create_audio_patch) ?
+ auto_hal_create_audio_patch(dev,
+ num_sources,
+ sources,
+ num_sinks,
+ sinks,
+ handle): 0);
+}
+
+int audio_extn_auto_hal_release_audio_patch(struct audio_hw_device *dev,
+ audio_patch_handle_t handle)
+{
+ return ((auto_hal_release_audio_patch) ?
+ auto_hal_release_audio_patch(dev, handle): 0);
+}
+
+int audio_extn_auto_hal_get_car_audio_stream_from_address(const char *address)
+{
+ return ((auto_hal_get_car_audio_stream_from_address) ?
+ auto_hal_get_car_audio_stream_from_address(address): 0);
+}
+
+int audio_extn_auto_hal_open_output_stream(struct stream_out *out)
+{
+ return ((auto_hal_open_output_stream) ?
+ auto_hal_open_output_stream(out): 0);
+}
+
+bool audio_extn_auto_hal_is_bus_device_usecase(audio_usecase_t uc_id)
+{
+ return ((auto_hal_is_bus_device_usecase) ?
+ auto_hal_is_bus_device_usecase(uc_id): 0);
+}
+
+snd_device_t audio_extn_auto_hal_get_snd_device_for_car_audio_stream(struct stream_out *out)
+{
+ return ((auto_hal_get_snd_device_for_car_audio_stream) ?
+ auto_hal_get_snd_device_for_car_audio_stream(out): 0);
+}
+
+int audio_extn_auto_hal_get_audio_port(struct audio_hw_device *dev,
+ struct audio_port *config)
+{
+ return ((auto_hal_get_audio_port) ?
+ auto_hal_get_audio_port(dev, config): 0);
+}
+
+int audio_extn_auto_hal_set_audio_port_config(struct audio_hw_device *dev,
+ const struct audio_port_config *config)
+{
+ return ((auto_hal_set_audio_port_config) ?
+ auto_hal_set_audio_port_config(dev, config): 0);
+}
+
+void audio_extn_auto_hal_set_parameters(struct audio_device *adev,
+ struct str_parms *parms)
+{
+ if (auto_hal_set_parameters)
+ auto_hal_set_parameters(adev, parms);
+}
+// END: AUTO_HAL ===================================================================
+
void audio_extn_feature_init()
{
is_running_vendor_enhanced_fwk = audio_extn_utils_is_vendor_enhanced_fwk();
@@ -5506,6 +5724,9 @@
audiozoom_feature_init(
property_get_bool("vendor.audio.feature.audiozoom.enable",
true));
+ auto_hal_feature_init(
+ property_get_bool("vendor.audio.feature.auto_hal.enable",
+ false));
}
void audio_extn_set_parameters(struct audio_device *adev,
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 581b802..f75fe8d 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -706,10 +706,12 @@
int audio_extn_ext_hw_plugin_set_audio_gain(void *plugin,
struct audio_usecase *usecase, uint32_t gain);
-typedef int (*fp_audio_route_apply_and_update_path_t)(struct audio_route*, const char*);
+typedef int (*fp_b64decode_t)(char *inp, int ilen, uint8_t* outp);
+typedef int (*fp_b64encode_t)(uint8_t *inp, int ilen, char* outp);
typedef struct ext_hw_plugin_init_config {
- fp_audio_route_apply_and_update_path_t fp_audio_route_apply_and_update_path;
+ fp_b64decode_t fp_b64decode;
+ fp_b64encode_t fp_b64encode;
} ext_hw_plugin_init_config_t;
// END: EXT_HW_PLUGIN FEATURE ==================================================
@@ -1270,28 +1272,20 @@
int audio_extn_utils_get_license_params(const struct audio_device *adev, struct audio_license_params *lic_params);
-/*
- * TODO: AUTO TEAM to convert following feature flag to runtime flag enable
-*/
-#ifndef AUDIO_EXTN_AUTO_HAL_ENABLED
-#define audio_extn_auto_hal_init(adev) (0)
-#define audio_extn_auto_hal_deinit() (0)
-#define audio_extn_auto_hal_create_audio_patch(dev, num_sources,\
- sources, num_sinks, sinks, handle) (0)
-#define audio_extn_auto_hal_release_audio_patch(dev, handle) (0)
-#define audio_extn_auto_hal_get_car_audio_stream_from_address(address) (-1)
-#define audio_extn_auto_hal_open_output_stream(out) (0)
-#define audio_extn_auto_hal_is_bus_device_usecase(uc_id) (0)
-#define audio_extn_auto_hal_get_snd_device_for_car_audio_stream(out) (0)
-#define audio_extn_auto_hal_get_audio_port(dev, config) (0)
-#define audio_extn_auto_hal_set_audio_port_config(dev, config) (0)
-#define audio_extn_auto_hal_set_parameters(adev, parms) (0)
-#else
+// START: AUTO_HAL FEATURE ==================================================
+#ifndef AUDIO_OUTPUT_FLAG_MEDIA
#define AUDIO_OUTPUT_FLAG_MEDIA 0x100000
+#endif
+#ifndef AUDIO_OUTPUT_FLAG_SYS_NOTIFICATION
#define AUDIO_OUTPUT_FLAG_SYS_NOTIFICATION 0x200000
+#endif
+#ifndef AUDIO_OUTPUT_FLAG_NAV_GUIDANCE
#define AUDIO_OUTPUT_FLAG_NAV_GUIDANCE 0x400000
+#endif
+#ifndef AUDIO_OUTPUT_FLAG_PHONE
#define AUDIO_OUTPUT_FLAG_PHONE 0x800000
-int32_t audio_extn_auto_hal_init(struct audio_device *adev);
+#endif
+int audio_extn_auto_hal_init(struct audio_device *adev);
void audio_extn_auto_hal_deinit(void);
int audio_extn_auto_hal_create_audio_patch(struct audio_hw_device *dev,
unsigned int num_sources,
@@ -1301,8 +1295,8 @@
audio_patch_handle_t *handle);
int audio_extn_auto_hal_release_audio_patch(struct audio_hw_device *dev,
audio_patch_handle_t handle);
-int32_t audio_extn_auto_hal_get_car_audio_stream_from_address(const char *address);
-int32_t audio_extn_auto_hal_open_output_stream(struct stream_out *out);
+int audio_extn_auto_hal_get_car_audio_stream_from_address(const char *address);
+int audio_extn_auto_hal_open_output_stream(struct stream_out *out);
bool audio_extn_auto_hal_is_bus_device_usecase(audio_usecase_t uc_id);
snd_device_t audio_extn_auto_hal_get_snd_device_for_car_audio_stream(struct stream_out *out);
int audio_extn_auto_hal_get_audio_port(struct audio_hw_device *dev,
@@ -1310,8 +1304,23 @@
int audio_extn_auto_hal_set_audio_port_config(struct audio_hw_device *dev,
const struct audio_port_config *config);
void audio_extn_auto_hal_set_parameters(struct audio_device *adev,
- struct str_parms *parms);
-#endif
+ struct str_parms *parms);
+
+typedef streams_input_ctxt_t* (*fp_in_get_stream_t)(struct audio_device*, audio_io_handle_t);
+typedef streams_output_ctxt_t* (*fp_out_get_stream_t)(struct audio_device*, audio_io_handle_t);
+typedef size_t (*fp_get_output_period_size_t)(uint32_t, audio_format_t, int, int);
+typedef int (*fp_audio_extn_ext_hw_plugin_set_audio_gain_t)(void*, struct audio_usecase*, uint32_t);
+
+typedef struct auto_hal_init_config {
+ fp_in_get_stream_t fp_in_get_stream;
+ fp_out_get_stream_t fp_out_get_stream;
+ fp_audio_extn_ext_hw_plugin_usecase_start_t fp_audio_extn_ext_hw_plugin_usecase_start;
+ fp_audio_extn_ext_hw_plugin_usecase_stop_t fp_audio_extn_ext_hw_plugin_usecase_stop;
+ fp_get_usecase_from_list_t fp_get_usecase_from_list;
+ fp_get_output_period_size_t fp_get_output_period_size;
+ fp_audio_extn_ext_hw_plugin_set_audio_gain_t fp_audio_extn_ext_hw_plugin_set_audio_gain;
+} auto_hal_init_config_t;
+// END: AUTO_HAL FEATURE ==================================================
bool audio_extn_edid_is_supported_sr(edid_audio_info* info, int sr);
bool audio_extn_edid_is_supported_bps(edid_audio_info* info, int bps);
diff --git a/hal/audio_extn/audio_feature_manager.c b/hal/audio_extn/audio_feature_manager.c
index 441071d..76b5ac6 100644
--- a/hal/audio_extn/audio_feature_manager.c
+++ b/hal/audio_extn/audio_feature_manager.c
@@ -150,6 +150,8 @@
return confValues->dynamic_ecns_enabled;
case AUDIO_ZOOM:
return confValues->audio_zoom_enabled;
+ case AUTO_HAL:
+ return confValues->auto_hal_enabled;
default:
return false;
}
diff --git a/hal/audio_extn/audio_feature_manager.h b/hal/audio_extn/audio_feature_manager.h
index 908b0cb..3ffe996 100644
--- a/hal/audio_extn/audio_feature_manager.h
+++ b/hal/audio_extn/audio_feature_manager.h
@@ -73,6 +73,7 @@
COMPRESS_METADATA_NEEDED,
MAXX_AUDIO,
AUDIO_ZOOM,
+ AUTO_HAL,
// End Audio feature flags
// Start Voice feature flags
COMPRESS_VOIP,
diff --git a/hal/audio_extn/auto_hal.c b/hal/audio_extn/auto_hal.c
index 304c117..81ef46c 100644
--- a/hal/audio_extn/auto_hal.c
+++ b/hal/audio_extn/auto_hal.c
@@ -45,7 +45,14 @@
#include <log_utils.h>
#endif
-#ifdef AUDIO_EXTN_AUTO_HAL_ENABLED
+//external feature dependency
+static fp_in_get_stream_t fp_in_get_stream;
+static fp_out_get_stream_t fp_out_get_stream;
+static fp_audio_extn_ext_hw_plugin_usecase_start_t fp_audio_extn_ext_hw_plugin_usecase_start;
+static fp_audio_extn_ext_hw_plugin_usecase_stop_t fp_audio_extn_ext_hw_plugin_usecase_stop;
+static fp_get_usecase_from_list_t fp_get_usecase_from_list;
+static fp_get_output_period_size_t fp_get_output_period_size;
+static fp_audio_extn_ext_hw_plugin_set_audio_gain_t fp_audio_extn_ext_hw_plugin_set_audio_gain;
typedef struct auto_hal_module {
struct audio_device *adev;
@@ -55,8 +62,27 @@
/* Auto hal module struct */
static struct auto_hal_module *auto_hal = NULL;
-extern struct pcm_config pcm_config_deep_buffer;
-extern struct pcm_config pcm_config_low_latency;
+struct pcm_config pcm_config_deep_buffer = {
+ .channels = 2,
+ .rate = DEFAULT_OUTPUT_SAMPLING_RATE,
+ .period_size = DEEP_BUFFER_OUTPUT_PERIOD_SIZE,
+ .period_count = DEEP_BUFFER_OUTPUT_PERIOD_COUNT,
+ .format = PCM_FORMAT_S16_LE,
+ .start_threshold = DEEP_BUFFER_OUTPUT_PERIOD_SIZE / 4,
+ .stop_threshold = INT_MAX,
+ .avail_min = DEEP_BUFFER_OUTPUT_PERIOD_SIZE / 4,
+};
+
+struct pcm_config pcm_config_low_latency = {
+ .channels = 2,
+ .rate = DEFAULT_OUTPUT_SAMPLING_RATE,
+ .period_size = LOW_LATENCY_OUTPUT_PERIOD_SIZE,
+ .period_count = LOW_LATENCY_OUTPUT_PERIOD_COUNT,
+ .format = PCM_FORMAT_S16_LE,
+ .start_threshold = LOW_LATENCY_OUTPUT_PERIOD_SIZE / 4,
+ .stop_threshold = INT_MAX,
+ .avail_min = LOW_LATENCY_OUTPUT_PERIOD_SIZE / 4,
+};
static const audio_usecase_t bus_device_usecases[] = {
USECASE_AUDIO_PLAYBACK_MEDIA,
@@ -65,6 +91,9 @@
USECASE_AUDIO_PLAYBACK_PHONE,
};
+int auto_hal_release_audio_patch(struct audio_hw_device *dev,
+ audio_patch_handle_t handle);
+
static struct audio_patch_record *get_patch_from_list(struct audio_device *adev,
audio_patch_handle_t patch_id)
{
@@ -81,7 +110,7 @@
#define MAX_SOURCE_PORTS_PER_PATCH 1
#define MAX_SINK_PORTS_PER_PATCH 1
-int audio_extn_auto_hal_create_audio_patch(struct audio_hw_device *dev,
+int auto_hal_create_audio_patch(struct audio_hw_device *dev,
unsigned int num_sources,
const struct audio_port_config *sources,
unsigned int num_sinks,
@@ -116,7 +145,7 @@
/* Release patch if valid handle */
if (*handle != AUDIO_PATCH_HANDLE_NONE) {
- ret = audio_extn_auto_hal_release_audio_patch(dev,
+ ret = auto_hal_release_audio_patch(dev,
*handle);
if (ret) {
ALOGE("%s: failed to release audio patch 0x%x", __func__, *handle);
@@ -141,7 +170,7 @@
if ((sources->type == AUDIO_PORT_TYPE_DEVICE) &&
(sinks->type == AUDIO_PORT_TYPE_MIX)) {
pthread_mutex_lock(&adev->lock);
- streams_input_ctxt_t *in_ctxt = in_get_stream(adev,
+ streams_input_ctxt_t *in_ctxt = fp_in_get_stream(adev,
sinks->ext.mix.handle);
if (!in_ctxt) {
ALOGE("%s, failed to find input stream", __func__);
@@ -175,7 +204,7 @@
} else if ((sources->type == AUDIO_PORT_TYPE_MIX) &&
(sinks->type == AUDIO_PORT_TYPE_DEVICE)) {
pthread_mutex_lock(&adev->lock);
- streams_output_ctxt_t *out_ctxt = out_get_stream(adev,
+ streams_output_ctxt_t *out_ctxt = fp_out_get_stream(adev,
sources->ext.mix.handle);
if (!out_ctxt) {
ALOGE("%s, failed to find output stream", __func__);
@@ -233,7 +262,7 @@
ALOGD("%s: Starting ext hw plugin use case (%d) in_snd_device (%d) out_snd_device (%d)",
__func__, uc_info->id, uc_info->in_snd_device, uc_info->out_snd_device);
- ret = audio_extn_ext_hw_plugin_usecase_start(adev->ext_hw_plugin, uc_info);
+ ret = fp_audio_extn_ext_hw_plugin_usecase_start(adev->ext_hw_plugin, uc_info);
if (ret) {
ALOGE("%s: failed to start ext hw plugin use case (%d)",
__func__, uc_info->id);
@@ -290,7 +319,7 @@
return ret;
}
-int audio_extn_auto_hal_release_audio_patch(struct audio_hw_device *dev,
+int auto_hal_release_audio_patch(struct audio_hw_device *dev,
audio_patch_handle_t handle)
{
int ret = 0;
@@ -328,7 +357,7 @@
if (patch_record->input_io_handle) {
pthread_mutex_lock(&adev->lock);
- in_ctxt = in_get_stream(adev, patch_record->input_io_handle);
+ in_ctxt = fp_in_get_stream(adev, patch_record->input_io_handle);
if (!in_ctxt) {
ALOGE("%s, Could not find input stream", __func__);
ret = -EINVAL;
@@ -346,7 +375,7 @@
if (patch_record->output_io_handle) {
pthread_mutex_lock(&adev->lock);
- out_ctxt = out_get_stream(adev, patch_record->output_io_handle);
+ out_ctxt = fp_out_get_stream(adev, patch_record->output_io_handle);
if (!out_ctxt) {
ALOGE("%s, Could not find output stream", __func__);
ret = -EINVAL;
@@ -364,14 +393,14 @@
if (patch_record->usecase != USECASE_INVALID) {
pthread_mutex_lock(&adev->lock);
- uc_info = get_usecase_from_list(adev, patch_record->usecase);
+ uc_info = fp_get_usecase_from_list(adev, patch_record->usecase);
if (!uc_info) {
ALOGE("%s: failed to find the usecase (%d)",
__func__, patch_record->usecase);
ret = -EINVAL;
} else {
/* call to plugin to stop the usecase */
- ret = audio_extn_ext_hw_plugin_usecase_stop(adev->ext_hw_plugin, uc_info);
+ ret = fp_audio_extn_ext_hw_plugin_usecase_stop(adev->ext_hw_plugin, uc_info);
if (ret) {
ALOGE("%s: failed to stop ext hw plugin use case (%d)",
__func__, uc_info->id);
@@ -399,9 +428,9 @@
return ret;
}
-int32_t audio_extn_auto_hal_get_car_audio_stream_from_address(const char *address)
+int auto_hal_get_car_audio_stream_from_address(const char *address)
{
- int32_t bus_num = -1;
+ int bus_num = -1;
char *str = NULL;
char *last_r = NULL;
char local_address[AUDIO_DEVICE_MAX_ADDRESS_LEN];
@@ -418,7 +447,7 @@
/* extract bus number from address */
str = strtok_r(local_address, "BUS_",&last_r);
if (str != NULL)
- bus_num = (int32_t)strtol(str, (char **)NULL, 10);
+ bus_num = (int)strtol(str, (char **)NULL, 10);
/* validate bus number */
if ((bus_num < 0) || (bus_num >= MAX_CAR_AUDIO_STREAMS)) {
@@ -429,7 +458,7 @@
return (0x1 << bus_num);
}
-int32_t audio_extn_auto_hal_open_output_stream(struct stream_out *out)
+int auto_hal_open_output_stream(struct stream_out *out)
{
int ret = 0;
unsigned int channels = audio_channel_count_from_out_mask(out->channel_mask);
@@ -439,7 +468,7 @@
/* media bus stream shares pcm device with deep-buffer */
out->usecase = USECASE_AUDIO_PLAYBACK_MEDIA;
out->config = pcm_config_deep_buffer;
- out->config.period_size = get_output_period_size(out->sample_rate, out->format,
+ out->config.period_size = fp_get_output_period_size(out->sample_rate, out->format,
channels, DEEP_BUFFER_OUTPUT_PERIOD_DURATION);
if (out->config.period_size <= 0) {
ALOGE("Invalid configuration period size is not valid");
@@ -460,7 +489,7 @@
case CAR_AUDIO_STREAM_NAV_GUIDANCE:
out->usecase = USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE;
out->config = pcm_config_deep_buffer;
- out->config.period_size = get_output_period_size(out->sample_rate, out->format,
+ out->config.period_size = fp_get_output_period_size(out->sample_rate, out->format,
channels, DEEP_BUFFER_OUTPUT_PERIOD_DURATION);
if (out->config.period_size <= 0) {
ALOGE("Invalid configuration period size is not valid");
@@ -487,7 +516,7 @@
return ret;
}
-bool audio_extn_auto_hal_is_bus_device_usecase(audio_usecase_t uc_id)
+bool auto_hal_is_bus_device_usecase(audio_usecase_t uc_id)
{
unsigned int i;
for (i = 0; i < sizeof(bus_device_usecases)/sizeof(bus_device_usecases[0]); i++) {
@@ -497,7 +526,7 @@
return false;
}
-snd_device_t audio_extn_auto_hal_get_snd_device_for_car_audio_stream(struct stream_out *out)
+snd_device_t auto_hal_get_snd_device_for_car_audio_stream(struct stream_out *out)
{
snd_device_t snd_device = SND_DEVICE_NONE;
@@ -521,7 +550,7 @@
return snd_device;
}
-int audio_extn_auto_hal_get_audio_port(struct audio_hw_device *dev __unused,
+int auto_hal_get_audio_port(struct audio_hw_device *dev __unused,
struct audio_port *config __unused)
{
return -ENOSYS;
@@ -533,7 +562,7 @@
#define MIN_VOLUME_VALUE_MB -6000
#define MAX_VOLUME_VALUE_MB 600
#define STEP_VALUE_MB 100
-int audio_extn_auto_hal_set_audio_port_config(struct audio_hw_device *dev,
+int auto_hal_set_audio_port_config(struct audio_hw_device *dev,
const struct audio_port_config *config)
{
struct audio_device *adev = (struct audio_device *)dev;
@@ -621,7 +650,7 @@
memcpy((void *)&patch_record->sink, (void *)config,
sizeof(struct audio_port_config));
- struct audio_usecase *uc_info = get_usecase_from_list(adev,
+ struct audio_usecase *uc_info = fp_get_usecase_from_list(adev,
patch_record->usecase);
if (!uc_info) {
ALOGE("%s: failed to find the usecase %d",
@@ -634,7 +663,7 @@
(MAX_VOLUME_VALUE_MB - MIN_VOLUME_VALUE_MB)) * 40);
ALOGV("%s: set volume to patch %x", __func__,
patch_record->handle);
- ret = audio_extn_ext_hw_plugin_set_audio_gain(adev,
+ ret = fp_audio_extn_ext_hw_plugin_set_audio_gain(adev,
uc_info, vol_level);
}
}
@@ -651,7 +680,7 @@
return ret;
}
-void audio_extn_auto_hal_set_parameters(struct audio_device *adev __unused,
+void auto_hal_set_parameters(struct audio_device *adev __unused,
struct str_parms *parms)
{
int ret = 0;
@@ -674,9 +703,9 @@
ALOGV("%s: exit", __func__);
}
-int32_t audio_extn_auto_hal_init(struct audio_device *adev)
+int auto_hal_init(struct audio_device *adev, auto_hal_init_config_t init_config)
{
- int32_t ret = 0;
+ int ret = 0;
if (auto_hal != NULL) {
ALOGD("%s: Auto hal module already exists",
@@ -694,10 +723,18 @@
auto_hal->adev = adev;
+ fp_in_get_stream = init_config.fp_in_get_stream;
+ fp_out_get_stream = init_config.fp_out_get_stream;
+ fp_audio_extn_ext_hw_plugin_usecase_start = init_config.fp_audio_extn_ext_hw_plugin_usecase_start;
+ fp_audio_extn_ext_hw_plugin_usecase_stop = init_config.fp_audio_extn_ext_hw_plugin_usecase_stop;
+ fp_get_usecase_from_list = init_config.fp_get_usecase_from_list;
+ fp_get_output_period_size = init_config.fp_get_output_period_size;
+ fp_audio_extn_ext_hw_plugin_set_audio_gain = init_config.fp_audio_extn_ext_hw_plugin_set_audio_gain;
+
return ret;
}
-void audio_extn_auto_hal_deinit(void)
+void auto_hal_deinit(void)
{
if (auto_hal == NULL) {
ALOGE("%s: Auto hal module is NULL, cannot deinitialize",
@@ -709,4 +746,3 @@
return;
}
-#endif /* AUDIO_EXTN_AUTO_HAL_ENABLED */
diff --git a/hal/audio_extn/ext_hw_plugin.c b/hal/audio_extn/ext_hw_plugin.c
index 41faf03..1ede1a8 100644
--- a/hal/audio_extn/ext_hw_plugin.c
+++ b/hal/audio_extn/ext_hw_plugin.c
@@ -40,22 +40,9 @@
#include "platform.h"
#include "audio_hal_plugin.h"
-
-// - external function dependency -
-static fp_read_line_from_file_t fp_read_line_from_file;
-static fp_get_usecase_from_list_t fp_get_usecase_from_list;
-static fp_enable_disable_snd_device_t fp_disable_snd_device;
-static fp_enable_disable_snd_device_t fp_enable_snd_device;
-static fp_enable_disable_audio_route_t fp_disable_audio_route;
-static fp_enable_disable_audio_route_t fp_enable_audio_route;
-static fp_platform_set_snd_device_backend_t fp_platform_set_snd_device_backend;
-static fp_platform_get_snd_device_name_extn_t fp_platform_get_snd_device_name_extn;
-static fp_platform_get_default_app_type_v2_t fp_platform_get_default_app_type_v2;
-static fp_platform_send_audio_calibration_t fp_platform_send_audio_calibration;
-
-fp_audio_route_apply_and_update_path_t fp_audio_route_apply_and_update_path;
-
-#ifdef EXT_HW_PLUGIN_ENABLED
+//external feature dependency
+static fp_b64decode_t fp_b64decode;
+static fp_b64encode_t fp_b64encode;
typedef int32_t (*audio_hal_plugin_init_t)(void);
typedef int32_t (*audio_hal_plugin_deinit_t)(void);
@@ -90,7 +77,9 @@
}
my_plugin->adev = adev;
- fp_audio_route_apply_and_update_path = init_config.fp_audio_route_apply_and_update_path;
+
+ fp_b64decode = init_config.fp_b64decode;
+ fp_b64encode = init_config.fp_b64encode;
my_plugin->plugin_handle = dlopen(LIB_PLUGIN_DRIVER, RTLD_NOW);
if (my_plugin->plugin_handle == NULL) {
@@ -469,7 +458,7 @@
ALOGE("%s: memory allocation failed", __func__);
return -ENOMEM;
}
- dlen = b64decode(string_value, strlen(string_value), dptr);
+ dlen = fp_b64decode(string_value, strlen(string_value), dptr);
if ((dlen <= 0) || ((uint32_t)dlen != 4*dword_len)){
ALOGE("%s: data decoding failed", __func__);
ret = -EINVAL;
@@ -536,7 +525,7 @@
goto done_dword_to_string;
}
- ret = b64encode(dptr, dlen, outptr);
+ ret = fp_b64encode(dptr, dlen, outptr);
if(ret < 0) {
ALOGE("[%s] failed to convert data to string ret = %d", __func__, ret);
free(outptr);
@@ -1568,4 +1557,3 @@
}
return ret;
}
-#endif /* EXT_HW_PLUGIN_ENABLED */
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 4f37ac3..999560e 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -146,12 +146,10 @@
STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_VOIP_RX),
STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_BD),
STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_INTERACTIVE),
-#ifdef AUDIO_EXTN_AUTO_HAL_ENABLED
STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_MEDIA),
STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_SYS_NOTIFICATION),
STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_NAV_GUIDANCE),
STRING_TO_ENUM(AUDIO_OUTPUT_FLAG_PHONE),
-#endif
STRING_TO_ENUM(AUDIO_INPUT_FLAG_NONE),
STRING_TO_ENUM(AUDIO_INPUT_FLAG_FAST),
STRING_TO_ENUM(AUDIO_INPUT_FLAG_HW_HOTWORD),
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 9b7bf5b..9981c63 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -298,7 +298,6 @@
RENDER_MODE_AUDIO_STC_MASTER,
} render_mode_t;
-#ifdef AUDIO_EXTN_AUTO_HAL_ENABLED
/* This defines the physical car streams supported in audio HAL,
* limited by the available frontend PCM driver.
* Max number of physical streams supported is currently 8 and is
@@ -311,7 +310,6 @@
CAR_AUDIO_STREAM_NAV_GUIDANCE = 0x4,
CAR_AUDIO_STREAM_PHONE = 0x8,
};
-#endif
struct stream_app_type_cfg {
int sample_rate;