hal: Update audio hal to 7.0

Update AUDIO_DEVICE_API_VERSION to 3.2
added audio_port_v7 API support for hal v7.0.

Change-Id: I704825d8966fb2944ab752cb3a521f26f1b26329
Signed-off-by: Shimana P <quic_shimp@quicinc.com>
diff --git a/hal/Android.mk b/hal/Android.mk
index 4eddcf0..ba6c536 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -161,6 +161,10 @@
   LOCAL_HEADER_LIBRARIES += qti_legacy_audio_kernel_uapi
 endif
 
+ifeq ($(AUDIO_FEATURE_ENABLED_HAL_V7), true)
+  LOCAL_CFLAGS += -DANDROID_U_HAL7
+endif
+
 LOCAL_SRC_FILES := \
     audio_hw.c \
     acdb.c \
diff --git a/hal/audio_extn/Android.mk b/hal/audio_extn/Android.mk
index cc73411..ae06d28 100644
--- a/hal/audio_extn/Android.mk
+++ b/hal/audio_extn/Android.mk
@@ -1226,6 +1226,10 @@
   LOCAL_C_INCLUDES += $(AUDIO_KERNEL_INC)
 endif
 
+ifeq ($(AUDIO_FEATURE_ENABLED_HAL_V7), true)
+LOCAL_CFLAGS += -DANDROID_U_HAL7
+endif
+
 LOCAL_HEADER_LIBRARIES += libhardware_headers
 LOCAL_HEADER_LIBRARIES += libsystem_headers
 ifneq ($(filter kona lahaina holi,$(TARGET_BOARD_PLATFORM)),)
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 0795649..61ccfcb 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -6227,9 +6227,15 @@
 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;
 
+#ifdef ANDROID_U_HAL7
+typedef int (*auto_hal_get_audio_port_v7_t)(struct audio_hw_device*,
+                                struct audio_port_v7*);
+static auto_hal_get_audio_port_v7_t auto_hal_get_audio_port_v7;
+#else
 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;
+#endif
 
 typedef int (*auto_hal_set_audio_port_config_t)(struct audio_hw_device*,
                                 const struct audio_port_config*);
@@ -6305,9 +6311,15 @@
             !(auto_hal_is_bus_device_usecase =
                  (auto_hal_is_bus_device_usecase_t)dlsym(
                             auto_hal_lib_handle, "auto_hal_is_bus_device_usecase")) ||
+#ifdef ANDROID_U_HAL7
+	    !(auto_hal_get_audio_port_v7 =
+                 (auto_hal_get_audio_port_v7_t)dlsym(
+                            auto_hal_lib_handle, "auto_hal_get_audio_port_v7")) ||
+#else
             !(auto_hal_get_audio_port =
                  (auto_hal_get_audio_port_t)dlsym(
                             auto_hal_lib_handle, "auto_hal_get_audio_port")) ||
+#endif
             !(auto_hal_set_audio_port_config =
                  (auto_hal_set_audio_port_config_t)dlsym(
                             auto_hal_lib_handle, "auto_hal_set_audio_port_config")) ||
@@ -6354,7 +6366,11 @@
     auto_hal_open_input_stream = NULL;
     auto_hal_open_echo_reference_stream = NULL;
     auto_hal_is_bus_device_usecase = NULL;
+#ifdef ANDROID_U_HAL7
+    auto_hal_get_audio_port_v7 = NULL;
+#else
     auto_hal_get_audio_port = NULL;
+#endif
     auto_hal_set_audio_port_config = NULL;
     auto_hal_set_parameters = NULL;
     auto_hal_start_hfp_downlink = NULL;
@@ -6450,13 +6466,21 @@
                             auto_hal_is_bus_device_usecase(uc_id): false);
 }
 
+#ifdef ANDROID_U_HAL7
+int audio_extn_auto_hal_get_audio_port_v7(struct audio_hw_device *dev,
+                                struct audio_port_v7 *config)
+{
+    return ((auto_hal_get_audio_port_v7) ?
+                            auto_hal_get_audio_port_v7(dev, config): 0);
+}
+#else
 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);
 }
-
+#endif
 int audio_extn_auto_hal_set_audio_port_config(struct audio_hw_device *dev,
                                 const struct audio_port_config *config)
 {
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 256382c..175715f 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -1275,11 +1275,19 @@
 {
     return 0;
 }
+#ifdef ANDROID_U_HAL7
+static int __unused audio_extn_hw_loopback_get_audio_port_v7(struct audio_hw_device *dev __unused,
+                                    struct audio_port_v7 *port_in __unused)
+{
+    return 0;
+}
+#else
 static int __unused audio_extn_hw_loopback_get_audio_port(struct audio_hw_device *dev __unused,
                                     struct audio_port *port_in __unused)
 {
     return 0;
 }
+#endif
 static int __unused audio_extn_hw_loopback_set_param_data(audio_patch_handle_t handle __unused,
                                                audio_extn_loopback_param_id param_id __unused,
                                                audio_extn_loopback_param_payload *payload __unused)
@@ -1393,8 +1401,13 @@
 int audio_extn_auto_hal_open_echo_reference_stream(struct stream_in *in);
 bool audio_extn_auto_hal_overwrite_priority_for_auto(struct stream_in *in);
 bool audio_extn_auto_hal_is_bus_device_usecase(audio_usecase_t uc_id);
+#ifdef ANDROID_U_HAL7
+int audio_extn_auto_hal_get_audio_port_v7(struct audio_hw_device *dev,
+                                struct audio_port_v7 *config);
+#else
 int audio_extn_auto_hal_get_audio_port(struct audio_hw_device *dev,
                                 struct audio_port *config);
+#endif
 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,
diff --git a/hal/audio_extn/auto_hal.c b/hal/audio_extn/auto_hal.c
index 2f70fc5..544ad34 100644
--- a/hal/audio_extn/auto_hal.c
+++ b/hal/audio_extn/auto_hal.c
@@ -663,11 +663,19 @@
     return (in->source == AUDIO_SOURCE_ECHO_REFERENCE);
 }
 
+#ifdef ANDROID_U_HAL7
+int auto_hal_get_audio_port_v7(struct audio_hw_device *dev __unused,
+                        struct audio_port_v7 *config __unused)
+{
+    return -ENOSYS;
+}
+#else
 int auto_hal_get_audio_port(struct audio_hw_device *dev __unused,
                         struct audio_port *config __unused)
 {
     return -ENOSYS;
 }
+#endif
 
 int auto_hal_set_audio_port_config(struct audio_hw_device *dev,
                         const struct audio_port_config *config)
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index e7352ed..cb2791c 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -10932,6 +10932,16 @@
     return ret;
 }
 
+#ifdef ANDROID_U_HAL7
+int adev_get_audio_port_v7(struct audio_hw_device *dev, struct audio_port_v7 *config)
+{
+    int ret = 0;
+
+    ret = audio_extn_hw_loopback_get_audio_port_v7(dev, config);
+    ret |= audio_extn_auto_hal_get_audio_port_v7(dev, config);
+    return ret;
+}
+#else
 int adev_get_audio_port(struct audio_hw_device *dev, struct audio_port *config)
 {
     int ret = 0;
@@ -10940,6 +10950,7 @@
     ret |= audio_extn_auto_hal_get_audio_port(dev, config);
     return ret;
 }
+#endif
 
 int adev_set_audio_port_config(struct audio_hw_device *dev,
                         const struct audio_port_config *config)
@@ -11212,9 +11223,13 @@
         maj_version = atoi(value);
 
     adev->device.common.tag = HARDWARE_DEVICE_TAG;
-    adev->device.common.version = HARDWARE_DEVICE_API_VERSION(maj_version, 0);
     adev->device.common.module = (struct hw_module_t *)module;
     adev->device.common.close = adev_close;
+#ifdef ANDROID_U_HAL7
+   adev->device.common.version = HARDWARE_DEVICE_API_VERSION(maj_version, 2);
+#else
+   adev->device.common.version = HARDWARE_DEVICE_API_VERSION(maj_version, 0);
+#endif
 
     adev->device.init_check = adev_init_check;
     adev->device.set_voice_volume = adev_set_voice_volume;
@@ -11234,11 +11249,16 @@
     adev->device.close_input_stream = adev_close_input_stream;
     adev->device.create_audio_patch = adev_create_audio_patch;
     adev->device.release_audio_patch = adev_release_audio_patch;
-    adev->device.get_audio_port = adev_get_audio_port;
     adev->device.set_audio_port_config = adev_set_audio_port_config;
     adev->device.dump = adev_dump;
     adev->device.get_microphones = adev_get_microphones;
 
+#ifdef ANDROID_U_HAL7
+    adev->device.get_audio_port_v7 = adev_get_audio_port_v7;
+#else
+    adev->device.get_audio_port = adev_get_audio_port;
+#endif
+
     /* Set the default route before the PCM stream is opened */
     adev->mode = AUDIO_MODE_NORMAL;
     adev->primary_output = NULL;