hal: add AHAL hidl registration entry
Add AHAL hidl registration entry, and register AHAL extension service
from adev_open().
Change-Id: Idce42ba6da97a26fde6c88d23b7be71b886e376f
diff --git a/configs/msmnile/msmnile.mk b/configs/msmnile/msmnile.mk
index 3830b9c..5544d1f 100644
--- a/configs/msmnile/msmnile.mk
+++ b/configs/msmnile/msmnile.mk
@@ -282,4 +282,7 @@
android.hardware.audio.common@4.0-util \
android.hardware.audio@4.0-impl \
android.hardware.audio.effect@4.0 \
- android.hardware.audio.effect@4.0-impl
+ android.hardware.audio.effect@4.0-impl \
+ vendor.qti.hardware.audiohalext@1.0 \
+ vendor.qti.hardware.audiohalext@1.0-impl \
+ vendor.qti.hardware.audiohalext-utils
diff --git a/hal/Android.mk b/hal/Android.mk
index c39900e..6814e76 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -98,22 +98,22 @@
LOCAL_HEADER_LIBRARIES := libhardware_headers
LOCAL_SRC_FILES := \
- audio_hw.c \
- voice.c \
- platform_info.c \
- $(AUDIO_PLATFORM)/platform.c \
- acdb.c \
- ahal_config_helper.cpp
+ audio_hw.c \
+ voice.c \
+ platform_info.c \
+ $(AUDIO_PLATFORM)/platform.c \
+ acdb.c \
+ ahal_config_helper.cpp
LOCAL_SRC_FILES += audio_extn/audio_extn.c \
audio_extn/audio_feature_manager.c \
+ audio_extn/audio_hidl.cpp \
audio_extn/utils.c \
audio_extn/source_track.c \
voice_extn/voice_extn.c \
audio_extn/fm.c \
voice_extn/compress_voip.c \
audio_extn/keep_alive.c
-
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
@@ -345,7 +345,10 @@
libdl \
libaudioutils \
libexpat \
- libqti_vndfwk_detect
+ libqti_vndfwk_detect \
+ libhwbinder \
+ libhidlbase \
+ libhidltransport
LOCAL_C_INCLUDES += \
external/tinyalsa/include \
@@ -452,8 +455,7 @@
LOCAL_CFLAGS += -DBATTERY_LISTENER_ENABLED
LOCAL_SRC_FILES += audio_extn/battery_listener.cpp
LOCAL_SHARED_LIBRARIES += android.hardware.health@1.0 android.hardware.health@2.0 \
- libhidltransport libbase libhidlbase libhwbinder \
- libutils android.hardware.power@1.2
+ libbase libutils android.hardware.power@1.2
LOCAL_STATIC_LIBRARIES := libhealthhalutils
endif
@@ -467,6 +469,11 @@
LOCAL_SRC_FILES += audio_extn/ffv.c
endif
+ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AHAL_EXT)),true)
+ LOCAL_CFLAGS += -DAHAL_EXT_ENABLED
+ LOCAL_SHARED_LIBRARIES += vendor.qti.hardware.audiohalext@1.0
+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 928bd2c..0c6bee5 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -40,6 +40,7 @@
#include <cutils/str_parms.h>
#include "adsp_hdlr.h"
+#include "audio_hidl.h"
#include "ip_hdlr_intf.h"
#include "battery_listener.h"
#include "platform_api.h"
diff --git a/hal/audio_extn/audio_hidl.cpp b/hal/audio_extn/audio_hidl.cpp
new file mode 100644
index 0000000..4d549db
--- /dev/null
+++ b/hal/audio_extn/audio_hidl.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2019, 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_NDEBUG 0
+#define LOG_TAG "audio_hw_hidl"
+
+#include "audio_hidl.h"
+#include <cutils/properties.h>
+#include <log/log.h>
+#include <hidl/HidlTransportSupport.h>
+#include <hidl/LegacySupport.h>
+
+#ifdef AHAL_EXT_ENABLED
+#include <vendor/qti/hardware/audiohalext/1.0/IAudioHalExt.h>
+using vendor::qti::hardware::audiohalext::V1_0::IAudioHalExt;
+#endif
+
+using namespace android::hardware;
+using android::OK;
+
+extern "C" {
+int audio_extn_hidl_init() {
+
+#ifdef AHAL_EXT_ENABLED
+ if (!property_get_bool("vendor.audio.hal.ext.disabled", false)) {
+ /* register audio HAL extension */
+ bool fail = registerPassthroughServiceImplementation<IAudioHalExt>()!= OK;
+ ALOGW_IF(fail, "Could not register AHAL extension");
+ }
+#endif
+
+ /* to register other hidls */
+
+ return 0;
+}
+}
+
diff --git a/hal/audio_extn/audio_hidl.h b/hal/audio_extn/audio_hidl.h
new file mode 100644
index 0000000..92eb147
--- /dev/null
+++ b/hal/audio_extn/audio_hidl.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2019, 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.
+ */
+
+#ifndef _AUDIO_HIDL_H_
+#define _AUDIO_HIDL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+int audio_extn_hidl_init();
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _AUDIO_HIDL_H_ */
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index e12de67..46a4b98 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -8391,6 +8391,8 @@
pthread_mutex_init(&adev->lock, (const pthread_mutexattr_t *) NULL);
+ // register audio ext hidl at the earliest
+ audio_extn_hidl_init();
#ifdef DYNAMIC_LOG_ENABLED
register_for_dynamic_logging("hal");
#endif