Merge tag 'LA.UM.9.14.r1-20700-LAHAINA.QSSI13.0' into staging/lineage-20.0_merge-LA.UM.9.14.r1-20700-LAHAINA.QSSI13.0

"LA.UM.9.14.r1-20700-LAHAINA.QSSI13.0"

# By Krishna Kishor Jha (2) and others
# Via Gerrit - the friendly Code Review server (5) and Linux Build Service Account (1)
* tag 'LA.UM.9.14.r1-20700-LAHAINA.QSSI13.0':
  audio-hal: add missing modules in audio_effects.xml
  hal: changing mtmx coeffs variable type to uint32_t
  audio-hal: automotive LL capture usecase changes blocking with flag
  config: added audio effects config for elite architecture
  config: added audio effect libraries and helpers.
  audio-hal: Fix build error with VA and AOSP tinycompress

Change-Id: Ie3ffa03eb089db4a2baebfdca2b78bef5b47fede
diff --git a/configs/audio_vendor_product.mk b/configs/audio_vendor_product.mk
index b8836a0..a28ff20 100644
--- a/configs/audio_vendor_product.mk
+++ b/configs/audio_vendor_product.mk
@@ -163,6 +163,7 @@
 MM_AUDIO += autoeffects
 MM_AUDIO += autoeffects.xml
 MM_AUDIO += audcalparam_commands.cfg
+MM_AUDIO += audcalparam_commands_elite.cfg
 MM_AUDIO += libsynth
 MM_AUDIO += libicc
 
diff --git a/configs/msmnile_au/audio_effects.conf b/configs/msmnile_au/audio_effects.conf
index edb9814..c8b20b7 100755
--- a/configs/msmnile_au/audio_effects.conf
+++ b/configs/msmnile_au/audio_effects.conf
@@ -45,12 +45,6 @@
   audio_pre_processing {
     path /vendor/lib/soundfx/libqcomvoiceprocessing.so
   }
-  audiosphere {
-    path /vendor/lib/soundfx/libasphere.so
-  }
-  shoebox {
-    path /vendor/lib/soundfx/libshoebox.so
-  }
   audio_bmt {
     path /vendor/lib/soundfx/libqtiautobundle.so
   }
@@ -259,14 +253,6 @@
     library audio_pre_processing
     uuid 1d97bb0b-9e2f-4403-9ae3-58c2554306f8
   }
-  audiosphere {
-    library audiosphere
-    uuid 184e62ab-2d19-4364-9d1b-c0a40733866c
-  }
-  shoebox {
-    library shoebox
-    uuid 1eab784c-1a36-4b2a-b7fc-e34c44cab89e
-  }
   auto_bmt {
     library auto_bmt
     uuid e039757b-a367-44e9-9bbb-634af0c51cb7
@@ -300,30 +286,6 @@
 # additional effect from vendor
 # UUID generated using version 1
 
-output_session_processing {
-    music {
-        music_helper {
-        }
-    }
-    ring {
-        ring_helper {
-        }
-    }
-    alarm {
-        alarm_helper {
-        }
-    }
-    # stream type voice_call is used for VoIP call
-    voice_call {
-        voice_helper {
-        }
-    }
-    notification {
-        notification_helper {
-        }
-    }
-}
-
 # Added aec, ns effects for voice_communication, which are supported by the board
 
 pre_processing {
diff --git a/configs/msmnile_au/audio_effects.xml b/configs/msmnile_au/audio_effects.xml
index c3751a0..0f6f25d 100644
--- a/configs/msmnile_au/audio_effects.xml
+++ b/configs/msmnile_au/audio_effects.xml
@@ -32,10 +32,14 @@
         <library name="reverb" path="libreverbwrapper.so"/>
         <library name="visualizer_sw" path="libvisualizer.so"/>
         <library name="visualizer_hw" path="libqcomvisualizer.so"/>
+        <library name="downmix" path="libdownmix.so"/>
         <library name="loudness_enhancer" path="libldnhncr.so"/>
+        <library name="dynamics_processing" path="libdynproc.so"/>
         <library name="proxy" path="libeffectproxy.so"/>
         <library name="offload_bundle" path="libqcompostprocbundle.so"/>
         <library name="audio_pre_processing" path="libqcomvoiceprocessing.so"/>
+        <library name="audiosphere" path="libasphere.so"/>
+        <library name="shoebox" path="libshoebox.so"/>
         <library name="audio_bmt" path="libqtiautobundle.so"/>
         <library name="audio_fnb" path="libqtiautobundle.so"/>
         <library name="audio_delay" path="libqtiautobundle.so"/>
@@ -78,14 +82,11 @@
             <libsw library="visualizer_sw" uuid="d069d9e0-8329-11df-9168-0002a5d5c51b"/>
             <libhw library="visualizer_hw" uuid="7a8044a0-1a71-11e3-a184-0002a5d5c51b"/>
         </effectProxy>
-        <effect name="downmix" library="downmix" uuid="93f04452-e4fe-41cc-91f9-e475b6d1d69f"/>
         <effect name="hw_acc" library="offload_bundle" uuid="7d1580bd-297f-4683-9239-e475b6d1d69f"/>
         <effect name="loudness_enhancer" library="loudness_enhancer" uuid="fa415329-2034-4bea-b5dc-5b381c8d1e2c"/>
         <effect name="dynamics_processing" library="dynamics_processing" uuid="e0e6539b-1781-7261-676f-6d7573696340"/>
         <effect name="aec" library="audio_pre_processing" uuid="0f8d0d2a-59e5-45fe-b6e4-248c8a799109"/>
         <effect name="ns" library="audio_pre_processing" uuid="1d97bb0b-9e2f-4403-9ae3-58c2554306f8"/>
-        <effect name="audiosphere" library="audiosphere" uuid="184e62ab-2d19-4364-9d1b-c0a40733866c"/>
-        <effect name="shoebox" library="shoebox" uuid="1eab784c-1a36-4b2a-b7fc-e34c44cab89e"/>
         <effect name="audio_bmt" library="audio_bmt" uuid="e039757b-a367-44e9-9bbb-634af0c51cb7"/>
         <effect name="audio_fnb" library="audio_fnb" uuid="6bc88c84-a544-11e8-98d0-529269fb1459"/>
         <effect name="audio_delay" library="audio_delay" uuid="a31574a6-a5e7-11e8-98d0-529269fb1459"/>
diff --git a/hal/Android.mk b/hal/Android.mk
old mode 100755
new mode 100644
index b2a9bdd..6d1412e
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -134,6 +134,12 @@
   LOCAL_CFLAGS += -DPLATFORM_AUTO
 endif
 
+ifeq ($(ENABLE_AUDIO_LEGACY_TECHPACK),true)
+  LIBRARY_TINYCOMPRESS := libtinycompress
+  LIBRARY_TINYCOMPRESS_INC := external/tinycompress/include
+  LOCAL_CFLAGS += -DENABLE_AUDIO_LEGACY_PURE
+endif
+
 ifeq ($(TARGET_SUPPORTS_WEARABLES),true)
    LOCAL_CFLAGS += -DENABLE_HFP_CALIBRATION
 endif
@@ -147,7 +153,7 @@
 LOCAL_HEADER_LIBRARIES := libhardware_headers
 
 ifeq ($(ENABLE_AUDIO_LEGACY_TECHPACK),true)
-LOCAL_HEADER_LIBRARIES += qti_legacy_audio_kernel_uapi
+  LOCAL_HEADER_LIBRARIES += qti_legacy_audio_kernel_uapi
 endif
 
 LOCAL_SRC_FILES := \
diff --git a/hal/audio_extn/Android.mk b/hal/audio_extn/Android.mk
index 81ce0e8..446eece 100644
--- a/hal/audio_extn/Android.mk
+++ b/hal/audio_extn/Android.mk
@@ -8,13 +8,18 @@
 endif # BOARD_OPENSOURCE_DIR
 
 ifneq ($(TARGET_BOARD_AUTO),true)
-LIBRARY_TINYCOMPRESS := libtinycompress
-LIBRARY_TINYCOMPRESS_INC := external/tinycompress/include
+  LIBRARY_TINYCOMPRESS := libtinycompress
+  LIBRARY_TINYCOMPRESS_INC := external/tinycompress/include
 else
-LIBRARY_TINYCOMPRESS := libqti-tinycompress
-LIBRARY_TINYCOMPRESS_INC := $(TOP)/vendor/qcom/opensource/tinycompress/include
+  LIBRARY_TINYCOMPRESS := libqti-tinycompress
+  LIBRARY_TINYCOMPRESS_INC := $(TOP)/vendor/qcom/opensource/tinycompress/include
 endif
 
+ifeq ($(ENABLE_AUDIO_LEGACY_TECHPACK),true)
+  LIBRARY_TINYCOMPRESS := libtinycompress
+  LIBRARY_TINYCOMPRESS_INC := external/tinycompress/include
+  LOCAL_CFLAGS += -DENABLE_AUDIO_LEGACY_PURE
+endif
 #--------------------------------------------
 #          Build SND_MONITOR LIB
 #--------------------------------------------
diff --git a/hal/audio_extn/audio_extn.c b/hal/audio_extn/audio_extn.c
index 45e8fe6..7127bf0 100644
--- a/hal/audio_extn/audio_extn.c
+++ b/hal/audio_extn/audio_extn.c
@@ -635,7 +635,7 @@
     struct mixer_ctl *ctl = NULL;
     char mixer_ctl_name[128] = {0};
     int ret = 0;
-    long channel_map[AUDIO_MAX_DSP_CHANNELS] = {0};
+    int channel_map[AUDIO_MAX_DSP_CHANNELS] = {0};
 
     ALOGV("%s channel_count %d", __func__, ch_count);
 
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 75ef7f2..f35a9d6 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -112,7 +112,7 @@
 #define AUDIO_OUTPUT_BIT_WIDTH ((config->offload_info.bit_width == 32) ? 24\
                                    :config->offload_info.bit_width)
 
-#ifndef ENABLE_EXTENDED_COMPRESS_FORMAT
+#if !defined(ENABLE_EXTENDED_COMPRESS_FORMAT) || defined(ENABLE_AUDIO_LEGACY_PURE)
 #define compress_set_metadata(compress, metadata) (0)
 #define compress_get_metadata(compress, metadata) (0)
 #define compress_set_next_track_param(compress, codec_options) (0)
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 6c97447..174e43f 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -111,10 +111,12 @@
 #define VNDK_FWK_LIB_PATH "/vendor/lib/libqti_vndfwk_detect.so"
 #endif
 
+#ifdef PLATFORM_AUTO
 /* 24 KHz ECNR support */
 #define ECNS_USE_CASE_ACDB_DEV_ID 95
 #define ECNS_UNSUPPORTED_CAPTURE_SAMPLE_RATE_FOR_ADM 24000
 #define ECNS_SUPPORTED_CAPTURE_SAMPLE_RATE_FOR_ADM 48000
+#endif
 
 typedef struct vndkfwk_s {
     void *lib_handle;
@@ -756,12 +758,14 @@
     app_type_cfg->app_type = platform_get_default_app_type_v2(platform, PCM_CAPTURE);
     app_type_cfg->sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
     app_type_cfg->bit_width = 16;
+#ifdef PLATFORM_AUTO
     if ((flags & AUDIO_INPUT_FLAG_TIMESTAMP) == 0 &&
         (flags & AUDIO_INPUT_FLAG_COMPRESS) == 0 &&
         (flags & AUDIO_INPUT_FLAG_FAST) != 0) {
         // Support low latency record for different sample rates
         app_type_cfg->sample_rate = sample_rate;
     }
+#endif
 }
 
 void audio_extn_utils_update_stream_output_app_type_cfg(void *platform,
@@ -1321,7 +1325,9 @@
 {
     char value[PROPERTY_VALUE_MAX] = {0};
     int sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
+#ifdef PLATFORM_AUTO
     int acdb_dev_id;
+#endif
 
     if ((usecase->type == PCM_PLAYBACK) && (usecase->stream.out != NULL)) {
         property_get("vendor.audio.playback.mch.downsample",value,"");
@@ -1404,11 +1410,13 @@
         /* ECNR module in DSP does not support 24 KHz sample rate. As a workaround,
            run ADM at 48 KHz when ECNR is enabled in ACDB topology (e.g. device id = 95)
         */
+#ifdef PLATFORM_AUTO
         acdb_dev_id = platform_get_snd_device_acdb_id(snd_device);
         if (sample_rate == ECNS_UNSUPPORTED_CAPTURE_SAMPLE_RATE_FOR_ADM && acdb_dev_id == ECNS_USE_CASE_ACDB_DEV_ID) {
             sample_rate = ECNS_SUPPORTED_CAPTURE_SAMPLE_RATE_FOR_ADM;
             ALOGD("%s: update sample rate from 24K to 48K to support ECNR in PCM_CAPTURE, sample_rate=%d",__func__,sample_rate);
         }
+#endif
     } else if (usecase->type == TRANSCODE_LOOPBACK_RX) {
         sample_rate = usecase->stream.inout->out_config.sample_rate;
     }
@@ -2817,6 +2825,7 @@
     int ret = -EINVAL;
     uint64_t time = 0;
     struct snd_pcm_prsnt_position prsnt_position;
+    memset(&prsnt_position, 0, sizeof(struct snd_pcm_prsnt_position));
 
     ALOGV("%s:: Quering DSP position with clock id %d",__func__, clock_id);
     prsnt_position.clock_id = clock_id;
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 9e192cf..3ddadf0 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -717,11 +717,17 @@
 
     if (!adev->adm_set_config)
         return;
-
+#ifdef PLATFORM_AUTO
     if (out->realtime || (out->flags & AUDIO_OUTPUT_FLAG_SYS_NOTIFICATION))
        adev->adm_set_config(adev->adm_data,
                              out->handle,
                              out->pcm, &out->config);
+#else
+    if (out->realtime)
+       adev->adm_set_config(adev->adm_data,
+                             out->handle,
+                             out->pcm, &out->config);
+#endif
 }
 
 static void register_in_stream(struct stream_in *in)
@@ -3275,11 +3281,15 @@
                      !audio_is_true_native_stream_active(adev)) &&
                     usecase->stream.out->sample_rate == OUTPUT_SAMPLING_RATE_44100) ||
                     (usecase->stream.out->sample_rate < OUTPUT_SAMPLING_RATE_44100)) {
+#ifdef PLATFORM_AUTO
             if (!(compare_device_type(&usecase->device_list, AUDIO_DEVICE_OUT_BUS) && ((usecase->stream.out->flags &
                 (audio_output_flags_t)AUDIO_OUTPUT_FLAG_SYS_NOTIFICATION) || (usecase->stream.out->flags &
                 (audio_output_flags_t)AUDIO_OUTPUT_FLAG_PHONE)))) {
                 usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
             }
+#else
+                usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
+#endif
         }
     }
     enable_audio_route(adev, usecase);
@@ -4702,6 +4712,9 @@
 
     size = (sample_rate * duration_ms) / 1000;
     if (is_low_latency){
+#ifndef PLATFORM_AUTO
+         size = configured_low_latency_capture_period_size;
+#else
         switch(sample_rate) {
             case 48000:
                 size = 240;
@@ -4721,6 +4734,7 @@
             default:
                 size = 240;
         }
+#endif
     }
 
     bytes_per_period_sample = audio_bytes_per_sample(format) * channel_count;
@@ -9948,7 +9962,7 @@
             goto err_open;
         }
     }
-
+#ifdef PLATFORM_AUTO
     if ((config->sample_rate == 48000 ||
         config->sample_rate == 32000 ||
         config->sample_rate == 24000 ||
@@ -9956,7 +9970,14 @@
         config->sample_rate == 8000)&&
             (flags & AUDIO_INPUT_FLAG_TIMESTAMP) == 0 &&
             (flags & AUDIO_INPUT_FLAG_COMPRESS) == 0 &&
-            (flags & AUDIO_INPUT_FLAG_FAST) != 0) {
+            (flags & AUDIO_INPUT_FLAG_FAST) != 0)
+#else
+    if (config->sample_rate == LOW_LATENCY_CAPTURE_SAMPLE_RATE &&
+            (flags & AUDIO_INPUT_FLAG_TIMESTAMP) == 0 &&
+            (flags & AUDIO_INPUT_FLAG_COMPRESS) == 0 &&
+            (flags & AUDIO_INPUT_FLAG_FAST) != 0)
+#endif
+{
         is_low_latency = true;
 #if LOW_LATENCY_CAPTURE_USE_CASE
         if ((flags & AUDIO_INPUT_FLAG_VOIP_TX) != 0)
@@ -9977,6 +9998,7 @@
             in->af_period_multiplier = 1;
         } else {
             // period size is left untouched for rt mode playback
+#ifdef PLATFORM_AUTO
             switch(config->sample_rate)
             {
                 case 48000:
@@ -9997,6 +10019,9 @@
                 default:
                     in->config = pcm_config_audio_capture_rt_48KHz;
             }
+#else
+            in->config = pcm_config_audio_capture_rt_48KHz;
+#endif
             in->af_period_multiplier = af_period_multiplier;
         }
     }
@@ -10090,6 +10115,7 @@
         in->config.rate = config->sample_rate;
         in->af_period_multiplier = 1;
     } else if (in->realtime) {
+#ifdef PLATFORM_AUTO
         switch(config->sample_rate)
         {
             case 48000:
@@ -10112,7 +10138,10 @@
         }
         in->config.format = pcm_format_from_audio_format(config->format);
         in->af_period_multiplier = af_period_multiplier;
-    } else {
+#else
+        in->config = pcm_config_audio_capture_rt_48KHz;
+#endif
+} else {
         int ret_val;
         pthread_mutex_lock(&adev->lock);
         ret_val = audio_extn_check_and_set_multichannel_usecase(adev,
diff --git a/hal/platform_api.h b/hal/platform_api.h
index 9663372..1d40a86 100755
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -149,7 +149,7 @@
 struct audio_custom_mtmx_params {
     struct listnode list;
     struct audio_custom_mtmx_params_info info;
-    uint64_t coeffs[0];
+    uint32_t coeffs[0];
 };
 
 struct audio_custom_mtmx_in_params_info {