AHAL: enable audio hal for linux platform

Change-Id: I7de481eb7b04985f232dfe833d76e80907081bdb
Signed-off-by: Hexuan Zhu <hexuzhu@codeaurora.org>
diff --git a/hal/Makefile.am b/hal/Makefile.am
old mode 100644
new mode 100755
index bdf1b9a..b60e4d4
--- a/hal/Makefile.am
+++ b/hal/Makefile.am
@@ -1,24 +1,20 @@
-AM_CFLAGS = -I ${WORKSPACE}/external/tinyalsa/include \
-        -I ${WORKSPACE}/system/media/audio_effects/include \
-        -I ${WORKSPACE}/system/media/audio_utils/include \
-        -I $(top_srcdir)/hal \
+AM_CFLAGS = -I $(top_srcdir)/hal \
         -I $(top_srcdir)/hal/audio_extn \
         -I $(top_srcdir)/hal/voice_extn \
         -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/audio-kernel \
+        -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include \
         -I $(top_srcdir)/hal/${TARGET_PLATFORM}
 
 c_sources = audio_hw.c \
-            voice.c \
             platform_info.c \
+            voice.c \
+            acdb.c \
             ${TARGET_PLATFORM}/platform.c \
-            audio_extn/audio_extn.c \
             audio_extn/utils.c \
-            acdb.c
+            audio_extn/audio_extn.c \
+            audio_extn/device_utils.c \
+            audio_extn/audio_stub.c
 
-if HDMI_EDID
-AM_CFLAGS += -DHDMI_EDID
-c_sources += edid.c
-endif
 
 if FM_POWER_OPT
 AM_CFLAGS += -DFM_POWER_OPT
@@ -30,17 +26,6 @@
 c_sources += audio_extn/usb.c
 endif
 
-if HFP
-AM_CFLAGS += -DHFP_ENABLED
-c_sources += audio_extn/hfp.c
-endif
-
-if SSR
-AM_CFLAGS += -DSSR_ENABLED
-c_sources += audio_extn/ssr.c
-AM_CFLAGS +=  -I ${WORKSPACE}/audio/mm-audio-external-noship/surround_sound_3mic/libsurround_3mic_proc/surround_rec_interface/inc/
-endif
-
 if MULTI_VOICE_SESSIONS
 AM_CFLAGS += -DMULTI_VOICE_SESSION_ENABLED
 c_sources += voice_extn/voice_extn.c
@@ -51,21 +36,15 @@
 c_sources += voice_extn/compress_voip.c
 endif
 
-if SPKR_PROTECTION
-AM_CFLAGS += -DSPKR_PROT_ENABLED
-c_sources += audio_extn/spkr_protection.c
-endif
+
+AM_CFLAGS += -DAUDIO_GKI_ENABLED
+
 
 if HW_VARIANTS
 AM_CFLAGS += -DHW_VARIANTS_ENABLED
 c_sources +=  ${TARGET_PLATFORM}/hw_info.c
 endif
 
-if COMPRESS_CAPTURE
-AM_CFLAGS += -DCOMPRESS_CAPTURE_ENABLED
-c_sources += audio_extn/compress_capture.c
-endif
-
 if DTS_EAGLE
 AM_CFLAGS += -DDTS_EAGLE
 c_sources += audio_extn/dts_eagle.c
@@ -93,36 +72,34 @@
 c_sources += audio_extn/source_track.c
 endif
 
-#if LISTEN
-#AM_CFLAGS += -DAUDIO_LISTEN_ENABLED
-#AM_CFLAGS += -I ${WORKSPACE}/audio/mm-audio-external-noship/audio-listen
-#c_sources += audio_extn/listen.c
-#endif
+if LISTEN
+AM_CFLAGS += -DAUDIO_LISTEN_ENABLED
+c_sources += audio_extn/listen.c
+endif
 
 if SOUND_TRIGGER
 AM_CFLAGS += -DSOUND_TRIGGER_ENABLED
-AM_CFLAGS += -I ${WORKSPACE}/audio/mm-audio/sound_trigger/
 c_sources += audio_extn/soundtrigger.c
 endif
 
 if FLAC_SUPPORT
 AM_CFLAGS += -DFLAC_OFFLOAD_ENABLED
-AM_CFLAGS += -DCOMPRESS_METADATA_NEEDED
+AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
 endif
 
 if ALAC_SUPPORT
 AM_CFLAGS += -DALAC_OFFLOAD_ENABLED
-AM_CFLAGS += -DCOMPRESS_METADATA_NEEDED
+AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
 endif
 
 if VORBIS_SUPPORT
 AM_CFLAGS += -DVORBIS_OFFLOAD_ENABLED
-AM_CFLAGS += -DCOMPRESS_METADATA_NEEDED
+AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
 endif
 
 if WMA_SUPPORT
 AM_CFLAGS += -DWMA_OFFLOAD_ENABLED
-AM_CFLAGS += -DCOMPRESS_METADATA_NEEDED
+AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
 endif
 
 if COMPRESS_INPUT
@@ -136,7 +113,6 @@
 endif
 
 if AUDIO_PARSER
-AM_CFLAGS += -I ${WORKSPACE}/audio/mm-audio/audio-parsers/inc/
 if DTSHD_PARSER
 AM_CFLAGS += -DDTSHD_PARSER_ENABLED
 endif
@@ -170,11 +146,6 @@
 c_sources += audio_extn/adsp_hdlr.c
 endif
 
-if A2DP_OFFLOAD
-AM_CFLAGS += -DA2DP_OFFLOAD_ENABLED
-c_sources += audio_extn/a2dp.c
-endif
-
 if AUDIO_IP_HDLR
 AM_CFLAGS += -DAUDIO_EXTN_IP_HDLR_ENABLED
 c_sources += audio_extn/ip_hdlr_intf.c
@@ -209,6 +180,10 @@
 AM_CFLAGS += -DINSTANCE_ID_ENABLED
 endif
 
+if HFP
+AM_CFLAGS += -DHFP_ENABLED
+endif
+
 if LL_AS_PRIMARY_OUTPUT
 AM_CFLAGS += -DUSE_LL_AS_PRIMARY_OUTPUT
 endif
@@ -225,13 +200,16 @@
 audio_primary_default_la_SOURCES = $(c_sources)
 audio_primary_default_la_LIBADD = $(GLIB_LIBS) -llog -lcutils -ltinyalsa
 audio_primary_default_la_LIBADD += -ltinycompress -laudioroute -ldl -lexpat -laudioutils
+audio_primary_default_la_LIBADD += -lm -lc -lresolv
 if AUDIO_PARSER
 audio_primary_default_la_LIBADD += -laudioparsers
 endif
 audio_primary_default_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
 audio_primary_default_la_CFLAGS += -Dstrlcat=g_strlcat
-audio_primary_default_la_CFLAGS += -DINT_MAX=0x7fffffff
+audio_primary_default_la_CFLAGS += -DINT_MAX=0x7fffffff -Wno-error=deprecated-declarations -DPATH_MAX=1024 -DULONG_MAX=0xFFFFFFFFFFFFFFFFUL
 audio_primary_default_la_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\)
 audio_primary_default_la_CFLAGS += -DLINUX_ENABLED $(TARGET_CFLAGS) -DAUDIO_EXTN_FORMATS_ENABLED
 audio_primary_default_la_CFLAGS += -DNDEBUG
 audio_primary_default_la_LDFLAGS = -module -shared -avoid-version
+audio_primary_default_la_CPPFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
+audio_primary_default_la_CPPFLAGS += -DLINUX_ENABLED
diff --git a/hal/audio_extn/Makefile.am b/hal/audio_extn/Makefile.am
new file mode 100755
index 0000000..b8068b0
--- /dev/null
+++ b/hal/audio_extn/Makefile.am
@@ -0,0 +1,234 @@
+AM_CFLAGS = -I $(top_srcdir)/hal \
+        -I $(top_srcdir)/hal/audio_extn \
+        -I $(top_srcdir)/hal/voice_extn \
+        -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/audio-kernel \
+        -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include \
+        -I $(top_srcdir)/hal/${TARGET_PLATFORM}
+
+AM_CFLAGS += -DAUDIO_GKI_ENABLED
+c_sources = $(top_srcdir)/hal/audio_hw.c \
+            $(top_srcdir)/hal/platform_info.c \
+            $(top_srcdir)/hal/voice.c \
+            $(top_srcdir)/hal/acdb.c \
+            $(top_srcdir)/hal/${TARGET_PLATFORM}/platform.c \
+            utils.c \
+            audio_extn.c \
+            device_utils.c \
+            audio_stub.c
+
+
+if FM_POWER_OPT
+AM_CFLAGS += -DFM_POWER_OPT
+c_sources += fm.c
+endif
+
+if USBAUDIO
+AM_CFLAGS += -DUSB_TUNNEL_ENABLED
+c_sources += usb.c
+endif
+
+if SSR
+AM_CFLAGS += -DSSR_ENABLED
+c_sources += ssr.c
+endif
+
+if MULTI_VOICE_SESSIONS
+AM_CFLAGS += -DMULTI_VOICE_SESSION_ENABLED
+c_sources += $(top_srcdir)/hal/voice_extn/voice_extn.c
+endif
+
+if COMPRESS_VOIP
+AM_CFLAGS += -DCOMPRESS_VOIP_ENABLED
+c_sources += $(top_srcdir)/hal/voice_extn/compress_voip.c
+endif
+
+if SPKR_PROTECTION
+AM_CFLAGS += -DSPKR_PROT_ENABLED
+c_sources += spkr_protection.c
+endif
+
+if HW_VARIANTS
+AM_CFLAGS += -DHW_VARIANTS_ENABLED
+c_sources +=  $(top_srcdir)/hal/${TARGET_PLATFORM}/hw_info.c
+endif
+
+if COMPRESS_CAPTURE
+AM_CFLAGS += -DCOMPRESS_CAPTURE_ENABLED
+c_sources += compress_capture.c
+endif
+
+if DTS_EAGLE
+AM_CFLAGS += -DDTS_EAGLE
+c_sources += dts_eagle.c
+endif
+
+if DOLBY_DDP
+AM_CFLAGS += -DDS1_DOLBY_DDP_ENABLED
+c_sources += dolby.c
+endif
+
+if DS1_DOLBY_DAP
+AM_CFLAGS += -DDS1_DOLBY_DAP_ENABLED
+if DOLBY_DDP
+c_sources += dolby.c
+endif
+endif
+
+if DEV_ARBI
+AM_CFLAGS += -DDEV_ARBI_ENABLED
+c_sources += dev_arbi.c
+endif
+
+if SOURCE_TRACKING
+AM_CFLAGS += -DSOURCE_TRACKING_ENABLED
+c_sources += source_track.c
+endif
+
+if LISTEN
+AM_CFLAGS += -DAUDIO_LISTEN_ENABLED
+c_sources += listen.c
+endif
+
+if SOUND_TRIGGER
+AM_CFLAGS += -DSOUND_TRIGGER_ENABLED
+c_sources += soundtrigger.c
+endif
+
+if FLAC_SUPPORT
+AM_CFLAGS += -DFLAC_OFFLOAD_ENABLED
+AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
+endif
+
+if ALAC_SUPPORT
+AM_CFLAGS += -DALAC_OFFLOAD_ENABLED
+AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
+endif
+
+if VORBIS_SUPPORT
+AM_CFLAGS += -DVORBIS_OFFLOAD_ENABLED
+AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
+endif
+
+if WMA_SUPPORT
+AM_CFLAGS += -DWMA_OFFLOAD_ENABLED
+AM_CFLAGS += -DCOMPRESS_METADATA_ENABLED
+endif
+
+if COMPRESS_INPUT
+AM_CFLAGS += -DCOMPRESS_INPUT_ENABLED
+c_sources += compress_in.c
+endif
+
+if COMPRESS_PASSTHROUGH
+AM_CFLAGS += -DHDMI_PASSTHROUGH_ENABLED
+c_sources += passthru.c
+endif
+
+if AUDIO_PARSER
+if DTSHD_PARSER
+AM_CFLAGS += -DDTSHD_PARSER_ENABLED
+endif
+endif
+
+if KEEP_ALIVE
+AM_CFLAGS += -DKEEP_ALIVE_ENABLED
+c_sources += keep_alive.c
+endif
+
+if AUDIO_HW_EXTN_API
+AM_CFLAGS += -DAUDIO_HW_EXTN_API_ENABLED
+c_sources += $(top_srcdir)/hal/audio_hw_extn_api.c
+endif
+
+if GEF
+AM_CFLAGS += -DAUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED
+c_sources += gef.c
+endif
+
+if APTX_DECODER
+AM_CFLAGS += -DAPTX_DECODER_ENABLED
+endif
+
+if AFE_PROXY
+AM_CFLAGS += -DAFE_PROXY_ENABLED
+endif
+
+if ADSP_HDLR
+AM_CFLAGS += -DAUDIO_EXTN_ADSP_HDLR_ENABLED
+c_sources += adsp_hdlr.c
+endif
+
+if AUDIO_IP_HDLR
+AM_CFLAGS += -DAUDIO_EXTN_IP_HDLR_ENABLED
+c_sources += ip_hdlr_intf.c
+endif
+
+if QAF_SUPPORT
+AM_CFLAGS += -DQAF_EXTN_ENABLED
+c_sources += qaf.c
+endif
+
+if AUDIO_HW_LOOPBACK
+AM_CFLAGS += -DAUDIO_HW_LOOPBACK_ENABLED
+AM_CFLAGS += -DCOMPRESS_METADATA_NEEDED
+c_sources += hw_loopback.c
+endif
+
+if RUN_KEEP_ALIVE_IN_ARM_FFV
+AM_CFLAGS += -DRUN_KEEP_ALIVE_IN_ARM_FFV
+endif
+
+if AUDIO_HW_FFV
+AM_CFLAGS += -DFFV_ENABLED \
+             -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/ffv/
+c_sources += ffv.c
+endif
+
+if CUSTOM_STEREO
+AM_CFLAGS += -DCUSTOM_STEREO_ENABLED
+endif
+
+if INSTANCE_ID
+AM_CFLAGS += -DINSTANCE_ID_ENABLED
+endif
+
+if LL_AS_PRIMARY_OUTPUT
+AM_CFLAGS += -DUSE_LL_AS_PRIMARY_OUTPUT
+endif
+
+lib_LTLIBRARIES = libautohal.la
+c_sources += auto_hal.c
+libautohal_la_SOURCES = $(c_sources)
+libautohal_la_LIBADD = $(GLIB_LIBS) -llog -lcutils -ltinyalsa
+libautohal_la_LIBADD += -ltinycompress -laudioroute -ldl -lexpat -laudioutils
+libautohal_la_LIBADD += -lm -lc -lresolv
+libautohal_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
+libautohal_la_CFLAGS += -Dstrlcat=g_strlcat
+libautohal_la_CFLAGS += -DINT_MAX=0x7fffffff -Wno-error=deprecated-declarations -DPATH_MAX=1024 -DULONG_MAX=0xFFFFFFFFFFFFFFFFUL
+libautohal_la_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\)
+libautohal_la_CFLAGS += -DLINUX_ENABLED $(TARGET_CFLAGS) -DAUDIO_EXTN_FORMATS_ENABLED
+libautohal_la_CFLAGS += -DNDEBUG
+libautohal_la_LDFLAGS = -module -shared -avoid-version
+libautohal_la_CPPFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
+libautohal_la_CPPFLAGS += -DLINUX_ENABLED
+
+if HFP
+AM_CFLAGS += -DHFP_ENABLED
+c_sources += hfp.c
+lib_LTLIBRARIES += libhfp.la
+libhfp_la_SOURCES = $(c_sources)
+libhfp_la_LIBADD = $(GLIB_LIBS) -llog -lcutils -ltinyalsa
+libhfp_la_LIBADD += -ltinycompress -laudioroute -ldl -lexpat -laudioutils
+libhfp_la_LIBADD += -lm -lc -lresolv
+
+libhfp_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
+libhfp_la_CFLAGS += -Dstrlcat=g_strlcat
+libhfp_la_CFLAGS += -DINT_MAX=0x7fffffff
+libhfp_la_CFLAGS += -DULONG_MAX=\(__LONG_MAX__*2UL+1UL\)
+libhfp_la_CFLAGS += -DPATH_MAX=4096
+libhfp_la_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\)
+libhfp_la_CFLAGS += -DLINUX_ENABLED $(TARGET_CFLAGS) -DAUDIO_EXTN_FORMATS_ENABLED
+libhfp_la_CFLAGS += -DNDEBUG
+libhfp_la_CFLAGS += -D_GNU_SOURCE
+libhfp_la_LDFLAGS = -module -shared -avoid-version
+endif
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index c24d28f..56731b9 100755
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -67,6 +67,10 @@
 #include <log_utils.h>
 #endif
 
+#ifdef LINUX_ENABLED
+#include "audio_stub.h"
+#endif
+
 #define MAX_SLEEP_RETRY 100
 #define WIFI_INIT_WAIT_SLEEP 50
 #define MAX_NUM_CHANNELS 8
@@ -4871,10 +4875,18 @@
 
 // START: HFP ======================================================================
 #ifdef __LP64__
+#ifdef LINUX_ENABLED
+#define HFP_LIB_PATH "/usr/lib64/libhfp.so"
+#else
 #define HFP_LIB_PATH "/vendor/lib64/libhfp.so"
+#endif
+#else
+#ifdef LINUX_ENABLED
+#define HFP_LIB_PATH "/usr/lib/libhfp.so"
 #else
 #define HFP_LIB_PATH "/vendor/lib/libhfp.so"
 #endif
+#endif
 
 static void *hfp_lib_handle = NULL;
 
@@ -4965,7 +4977,6 @@
     hfp_set_mic_mute = NULL;
     hfp_set_mic_mute2 = NULL;
     hfp_set_parameters = NULL;
-
     ALOGW(":: %s: ---- Feature HFP is disabled ----", __func__);
     return -ENOSYS;
 }
@@ -6066,11 +6077,19 @@
 // END: MAXX_AUDIO =====================================================================
 
 // START: AUTO_HAL ===================================================================
+#ifdef LINUX_ENABLED
+#ifdef __LP64__
+#define AUTO_HAL_LIB_PATH "/usr/lib64/libautohal.so"
+#else
+#define AUTO_HAL_LIB_PATH "/usr/lib/libautohal.so"
+#endif
+#else
 #ifdef __LP64__
 #define AUTO_HAL_LIB_PATH "/vendor/lib64/libautohal.so"
 #else
 #define AUTO_HAL_LIB_PATH "/vendor/lib/libautohal.so"
 #endif
+#endif
 
 static void *auto_hal_lib_handle = NULL;
 
@@ -6147,6 +6166,11 @@
 {
     ALOGD("%s: Called with feature %s", __func__,
                   is_feature_enabled ? "Enabled" : "NOT Enabled");
+
+#ifdef LINUX_ENABLED
+    is_feature_enabled = true;
+#endif
+
     if (is_feature_enabled) {
         // dlopen lib
         auto_hal_lib_handle = dlopen(AUTO_HAL_LIB_PATH, RTLD_NOW);
@@ -6543,7 +6567,6 @@
 void audio_extn_feature_init()
 {
     vendor_enhanced_info = audio_extn_utils_get_vendor_enhanced_info();
-
     // register feature init functions here
     // each feature needs a vendor property
     // default value added is for GSI (non vendor modified images)
@@ -6628,9 +6651,17 @@
     hwdep_cal_feature_init(
         property_get_bool("vendor.audio.feature.hwdep_cal.enable",
                            false));
+    #ifdef LINUX_ENABLED
+    #ifdef HFP_ENABLED
+        hfp_feature_init(true);
+    #else
+        hfp_feature_init(false);
+    #endif
+    #else
     hfp_feature_init(
         property_get_bool("vendor.audio.feature.hfp.enable",
-                           false));
+                            false));
+    #endif
     icc_feature_init(
         property_get_bool("vendor.audio.feature.icc.enable",
                            false));
diff --git a/hal/audio_extn/audio_stub.c b/hal/audio_extn/audio_stub.c
new file mode 100755
index 0000000..c9ec1bf
--- /dev/null
+++ b/hal/audio_extn/audio_stub.c
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2021 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.
+*/
+
+#ifdef LINUX_ENABLED
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+
+#include <ctype.h>
+#include <resolv.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int32_t property_get_int32(const char *key, int32_t default_value) {
+     return 0;
+}
+
+int64_t property_get_int64(const char *key, int64_t default_value) {
+     return 0;
+}
+
+int audio_extn_hidl_init() {
+    return 0;
+}
+
+int audio_streaming_hint_start() {
+    return 0;
+}
+
+int audio_streaming_hint_end() {
+    return 0;
+}
+
+int audio_low_latency_hint_start() {
+    return 0;
+}
+
+int audio_low_latency_hint_end() {
+    return 0;
+}
+#endif
diff --git a/hal/audio_extn/audio_stub.h b/hal/audio_extn/audio_stub.h
new file mode 100755
index 0000000..01137ca
--- /dev/null
+++ b/hal/audio_extn/audio_stub.h
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2021 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.
+*/
+#ifdef LINUX_ENABLED
+
+#ifndef _AUDIO_STUB_H_
+#define _AUDIO_STUB_H_
+
+#ifdef __LP64__
+#define CPU_SETSIZE 1024
+#else
+#define CPU_SETSIZE 32
+#endif
+
+#define CPU_ZERO(cpusetp) \
+   memset((cpusetp), 0, sizeof(cpu_set_t))
+
+#endif
+#endif
diff --git a/hal/platform_info.c b/hal/platform_info.c
old mode 100644
new mode 100755
index 4ad5a5c..e55b91d
--- a/hal/platform_info.c
+++ b/hal/platform_info.c
@@ -42,6 +42,9 @@
 #include "audio_extn.h"
 #include <platform.h>
 #include <math.h>
+#ifdef LINUX_ENABLED
+#include <float.h>
+#endif
 
 #ifdef DYNAMIC_LOG_ENABLED
 #include <log_xml_parser.h>