hal: Add support for dynamic logging

Changes to support dynamic logging in hal

Change-Id: I315c919bd940d8ccdb9103eb06bf67c1e3ff3f4b
diff --git a/hal/audio_extn/a2dp.c b/hal/audio_extn/a2dp.c
index fba7e6c..005badd 100644
--- a/hal/audio_extn/a2dp.c
+++ b/hal/audio_extn/a2dp.c
@@ -41,6 +41,12 @@
 #include <hardware/hardware.h>
 #include <cutils/properties.h>
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_A2DP
+#include <log_utils.h>
+#endif
+
 #ifdef SPLIT_A2DP_ENABLED
 #define AUDIO_PARAMETER_A2DP_STARTED "A2dpStarted"
 #define BT_IPC_LIB_NAME  "libbthost_if.so"
@@ -69,7 +75,6 @@
 #define MIXER_ENC_FMT_APTXHD       "APTXHD"
 #define MIXER_ENC_FMT_NONE         "NONE"
 
-
 typedef int (*audio_stream_open_t)(void);
 typedef int (*audio_stream_close_t)(void);
 typedef int (*audio_start_stream_t)(void);
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 4573ecc..3c9330c 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -55,6 +55,12 @@
 
 #include "sound/compress_params.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_AUDIO_EXTN
+#include <log_utils.h>
+#endif
+
 #define MAX_SLEEP_RETRY 100
 #define WIFI_INIT_WAIT_SLEEP 50
 
diff --git a/hal/audio_extn/bt_hal.c b/hal/audio_extn/bt_hal.c
index 21baa9c..6441bef 100644
--- a/hal/audio_extn/bt_hal.c
+++ b/hal/audio_extn/bt_hal.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, 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
@@ -41,6 +41,12 @@
 #include <../../../../system/bt/audio_a2dp_hw/bthost_ipc.h>
 #include <dlfcn.h>
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_BT_HAL
+#include <log_utils.h>
+#endif
+
 #define DEFAULT_BUF_SIZE 6144
 
 #define UNUSED(x) (void)(x)
diff --git a/hal/audio_extn/compress_capture.c b/hal/audio_extn/compress_capture.c
index 47e6a9d..2d43446 100644
--- a/hal/audio_extn/compress_capture.c
+++ b/hal/audio_extn/compress_capture.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 - 2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013 - 2014, 2017, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -35,6 +35,12 @@
 #include "sound/compress_params.h"
 #include "sound/compress_offload.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_COMPR_CAP
+#include <log_utils.h>
+#endif
+
 #ifdef COMPRESS_CAPTURE_ENABLED
 
 #define COMPRESS_IN_CONFIG_CHANNELS 1
diff --git a/hal/audio_extn/compress_in.c b/hal/audio_extn/compress_in.c
index 6b1f6e4..156e3bc 100644
--- a/hal/audio_extn/compress_in.c
+++ b/hal/audio_extn/compress_in.c
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+* Copyright (c) 2016-2017, 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
@@ -51,6 +51,11 @@
 #include "audio_defs.h"
 #include "sound/compress_params.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_COMPR_IN
+#include <log_utils.h>
+#endif
 /* default timestamp metadata definition if not defined in kernel*/
 #ifndef COMPRESSED_TIMESTAMP_FLAG
 #define COMPRESSED_TIMESTAMP_FLAG 0
diff --git a/hal/audio_extn/dev_arbi.c b/hal/audio_extn/dev_arbi.c
index 69d8568..9c5382a 100644
--- a/hal/audio_extn/dev_arbi.c
+++ b/hal/audio_extn/dev_arbi.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014, 2016-2017 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
@@ -43,6 +43,12 @@
 #include <cutils/properties.h>
 #include "audio_extn.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_DEV_ARBI
+#include <log_utils.h>
+#endif
+
 #ifdef DEV_ARBI_ENABLED
 
 typedef int (init_fn_t)();
diff --git a/hal/audio_extn/dolby.c b/hal/audio_extn/dolby.c
index fee0543..a0f17be 100644
--- a/hal/audio_extn/dolby.c
+++ b/hal/audio_extn/dolby.c
@@ -34,6 +34,12 @@
 #include "sound/compress_params.h"
 #include "sound/devdep_params.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_DOLBY
+#include <log_utils.h>
+#endif
+
 #ifdef DS1_DOLBY_DDP_ENABLED
 
 #define AUDIO_PARAMETER_DDP_DEV          "ddp_device"
diff --git a/hal/audio_extn/dts_eagle.c b/hal/audio_extn/dts_eagle.c
index 71bfea6..b8de2ca 100644
--- a/hal/audio_extn/dts_eagle.c
+++ b/hal/audio_extn/dts_eagle.c
@@ -33,6 +33,12 @@
 #include "platform.h"
 #include "platform_api.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_DTS_EAGLE
+#include <log_utils.h>
+#endif
+
 #ifdef DTS_EAGLE
 
 #define AUDIO_PARAMETER_KEY_DTS_EAGLE   "DTS_EAGLE"
diff --git a/hal/audio_extn/fm.c b/hal/audio_extn/fm.c
index a28d52f..5da494d 100644
--- a/hal/audio_extn/fm.c
+++ b/hal/audio_extn/fm.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -31,6 +31,12 @@
 #include <stdlib.h>
 #include <cutils/str_parms.h>
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_FM
+#include <log_utils.h>
+#endif
+
 #ifdef FM_POWER_OPT
 #define AUDIO_PARAMETER_KEY_HANDLE_FM "handle_fm"
 #define AUDIO_PARAMETER_KEY_FM_VOLUME "fm_volume"
diff --git a/hal/audio_extn/gef.c b/hal/audio_extn/gef.c
index d5e090a..19f9dfb 100644
--- a/hal/audio_extn/gef.c
+++ b/hal/audio_extn/gef.c
@@ -47,6 +47,12 @@
 #include "audio_extn.h"
 #include "audio_hw.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_GEF
+#include <log_utils.h>
+#endif
+
 #ifdef AUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED
 
 #if LINUX_ENABLED
diff --git a/hal/audio_extn/hfp.c b/hal/audio_extn/hfp.c
index 3c1d0ef..685078b 100644
--- a/hal/audio_extn/hfp.c
+++ b/hal/audio_extn/hfp.c
@@ -39,6 +39,12 @@
 #include <stdlib.h>
 #include <cutils/str_parms.h>
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_HFP
+#include <log_utils.h>
+#endif
+
 #ifdef HFP_ENABLED
 #define AUDIO_PARAMETER_HFP_ENABLE      "hfp_enable"
 #define AUDIO_PARAMETER_HFP_SET_SAMPLING_RATE "hfp_set_sampling_rate"
diff --git a/hal/audio_extn/keep_alive.c b/hal/audio_extn/keep_alive.c
index bcc12d4..87cb122 100644
--- a/hal/audio_extn/keep_alive.c
+++ b/hal/audio_extn/keep_alive.c
@@ -29,6 +29,7 @@
 
 #define LOG_TAG "keep_alive"
 /*#define LOG_NDEBUG 0*/
+
 #include <stdlib.h>
 #include <cutils/log.h>
 #include "audio_hw.h"
@@ -36,6 +37,12 @@
 #include "platform_api.h"
 #include <platform.h>
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_KEEP_ALIVE
+#include <log_utils.h>
+#endif
+
 #define SILENCE_INTERVAL 2 /*In secs*/
 
 typedef enum {
diff --git a/hal/audio_extn/listen.c b/hal/audio_extn/listen.c
index 4cb2d2d..b98a429 100644
--- a/hal/audio_extn/listen.c
+++ b/hal/audio_extn/listen.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, 2017, 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
@@ -41,6 +41,11 @@
 #include "platform.h"
 #include "platform_api.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_AUDIO_LISTEN
+#include <log_utils.h>
+#endif
 
 #ifdef AUDIO_LISTEN_ENABLED
 
diff --git a/hal/audio_extn/passthru.c b/hal/audio_extn/passthru.c
index dd4d4d4..24208ab 100644
--- a/hal/audio_extn/passthru.c
+++ b/hal/audio_extn/passthru.c
@@ -40,6 +40,11 @@
 #include <cutils/properties.h>
 
 #include "sound/compress_params.h"
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_PASSTH
+#include <log_utils.h>
+#endif
 
 static const audio_format_t audio_passthru_formats[] = {
     AUDIO_FORMAT_AC3,
diff --git a/hal/audio_extn/pm.c b/hal/audio_extn/pm.c
index 69e19cb..65aa1fe 100644
--- a/hal/audio_extn/pm.c
+++ b/hal/audio_extn/pm.c
@@ -34,6 +34,12 @@
 #include <cutils/log.h>
 #include <cutils/str_parms.h>
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_PM
+#include <log_utils.h>
+#endif
+
 /* Device state*/
 #define AUDIO_PARAMETER_KEY_DEV_SHUTDOWN "dev_shutdown"
 
diff --git a/hal/audio_extn/qaf.c b/hal/audio_extn/qaf.c
index caf64ee..fec1a9d 100644
--- a/hal/audio_extn/qaf.c
+++ b/hal/audio_extn/qaf.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, 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
@@ -115,6 +115,12 @@
 #include <qti_audio.h>
 #include "sound/compress_params.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_QAF
+#include <log_utils.h>
+#endif
+
 //TODO: Need to remove this.
 #define QAF_OUTPUT_SAMPLING_RATE 48000
 
diff --git a/hal/audio_extn/sndmonitor.c b/hal/audio_extn/sndmonitor.c
index 89a6670..b560c9d 100644
--- a/hal/audio_extn/sndmonitor.c
+++ b/hal/audio_extn/sndmonitor.c
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+* Copyright (c) 2016-2017, 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
@@ -58,6 +58,12 @@
 #include "audio_hw.h"
 #include "audio_extn.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_SND_MONITOR
+#include <log_utils.h>
+#endif
+
 //#define MONITOR_DEVICE_EVENTS
 #define CPE_MAGIC_NUM 0x2000
 #define MAX_CPE_SLEEP_RETRY 2
diff --git a/hal/audio_extn/soundtrigger.c b/hal/audio_extn/soundtrigger.c
index cecc843..94a8a2b 100644
--- a/hal/audio_extn/soundtrigger.c
+++ b/hal/audio_extn/soundtrigger.c
@@ -41,6 +41,12 @@
 #include "platform_api.h"
 #include "sound_trigger_prop_intf.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_SND_TRIGGER
+#include <log_utils.h>
+#endif
+
 #define XSTR(x) STR(x)
 #define STR(x) #x
 #define MAX_LIBRARY_PATH 100
diff --git a/hal/audio_extn/source_track.c b/hal/audio_extn/source_track.c
index 5bced66..e5e6c06 100644
--- a/hal/audio_extn/source_track.c
+++ b/hal/audio_extn/source_track.c
@@ -41,6 +41,12 @@
 #include <stdlib.h>
 #include <cutils/str_parms.h>
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_SRC_TRACK
+#include <log_utils.h>
+#endif
+
 #ifdef SOURCE_TRACKING_ENABLED
 /* Audio Paramater Key to identify the list of start angles.
  * Starting angle (in degrees) defines the boundary starting angle for each sector.
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index 52bf3a6..710fd31 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 - 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013 - 2017, 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
@@ -47,6 +47,12 @@
 #include "audio_extn.h"
 #include <linux/msm_audio_calibration.h>
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_SPKR_PROT
+#include <log_utils.h>
+#endif
+
 #ifdef SPKR_PROT_ENABLED
 
 /*Range of spkr temparatures -30C to 80C*/
diff --git a/hal/audio_extn/ssr.c b/hal/audio_extn/ssr.c
index f64a861..7467579 100644
--- a/hal/audio_extn/ssr.c
+++ b/hal/audio_extn/ssr.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
  * Not a Contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -38,6 +38,12 @@
 #include "platform_api.h"
 #include "surround_rec_interface.h"
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_SSR
+#include <log_utils.h>
+#endif
+
 #ifdef SSR_ENABLED
 #define COEFF_ARRAY_SIZE            4
 #define FILT_SIZE                   ((512+1)* 6)  /* # ((FFT bins)/2+1)*numOutputs */
diff --git a/hal/audio_extn/usb.c b/hal/audio_extn/usb.c
index 456382e..5c397a7 100644
--- a/hal/audio_extn/usb.c
+++ b/hal/audio_extn/usb.c
@@ -36,6 +36,12 @@
 #include <ctype.h>
 #include <math.h>
 
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_USB
+#include <log_utils.h>
+#endif
+
 #ifdef USB_HEADSET_ENABLED
 #define USB_BUFF_SIZE           2048
 #define CHANNEL_NUMBER_STR      "Channels: "
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 27bbae8..b917039 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -39,6 +39,13 @@
 #include <sound/compress_params.h>
 #include <sound/compress_offload.h>
 #include <tinycompress/tinycompress.h>
+
+#ifdef DYNAMIC_LOG_ENABLED
+#include <log_xml_parser.h>
+#define LOG_MASK HAL_MOD_FILE_UTILS
+#include <log_utils.h>
+#endif
+
 #ifdef AUDIO_EXTERNAL_HDMI_ENABLED
 #ifdef HDMI_PASSTHROUGH_ENABLED
 #include "audio_parsers.h"