st-hal: Copy capi headers into opensource directory

The capi headers will be put into a new subdirectory within the
st-hal directory. The makefile is adjusted accordingly.

Change-Id: Ib603b9ca3cf85e62e0c420bfb352fad75d2a466f
diff --git a/Android.mk b/Android.mk
index 1cfed18..cdc86e4 100644
--- a/Android.mk
+++ b/Android.mk
@@ -39,7 +39,7 @@
 
 ifeq ($(strip $(AUDIO_FEATURE_ENABLED_SVA_MULTI_STAGE)),true)
     LOCAL_CFLAGS += -DST_MULTI_STAGE_ENABLED
-    LOCAL_HEADER_LIBRARIES += capi_v2_headers
+    LOCAL_C_INCLUDES += $(LOCAL_PATH)/ext_headers
     LOCAL_SRC_FILES += st_second_stage.c
 endif
 
diff --git a/ext_headers/capi_v2.h b/ext_headers/capi_v2.h
new file mode 100644
index 0000000..a85d7c5
--- /dev/null
+++ b/ext_headers/capi_v2.h
@@ -0,0 +1,388 @@
+#ifndef CAPI_V2_H
+#define CAPI_V2_H
+
+/*
+ * This file contrains the functions for controlling the
+ * internal circular buffer within the sound trigger HAL.
+ * The purpose is to keep all the different read and write
+ * commands from different threads synchronized.
+ *
+ * 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.
+ */
+/*
+ @file capi_v2.h
+ Common Audio Processing Interface v2 header file
+
+ This file defines a generalized C interface that can wrap a wide
+ variety of audio processing modules, so that they can be treated the
+ same way by control code.
+ */
+/*=========================================================================*/
+
+#include "capi_v2_types.h"
+#include "capi_v2_events.h"
+#include "capi_v2_properties.h"
+
+typedef struct capi_v2_t capi_v2_t;
+
+typedef struct capi_v2_vtbl_t capi_v2_vtbl_t;
+
+/** @ingroup capiv2_virt_func_table
+    Function table for plain C implementations of CAPIv2-compliant objects.
+
+    Objects must have a pointer to a function table as the first element in
+    their instance structure. This structure is the function table type for all
+    such objects.
+*/
+struct capi_v2_vtbl_t {
+    /**
+    Processes input data on all input ports and provides output on all output
+    ports.
+
+    @datatypes
+    capi_v2_t \n
+    capi_v2_stream_data_t
+
+    @param[in,out] _pif   Pointer to the module object.
+    @param[in,out] input  Array of pointers to the input data for each input
+                          port. \n
+                          The length of the array is the number of input ports.
+                          The client sets the number of input ports using the
+                          #CAPI_V2_PORT_NUM_INFO property. \n
+                          The function must modify the actual_data_len field
+                          to indicate how many bytes were consumed.
+    @param[out] output    Array of pointers to the output data for each output
+                          port. \n
+                          The client sets the number of output ports using the
+                          #CAPI_V2_PORT_NUM_INFO property. \n
+                          The function sets the actual_data_len field to
+                          indicate how many bytes were generated.
+
+    @detdesc
+    This is a generic processing function.
+    @par
+    On each call to capi_v2_vtbl_t::process(), the behavior of the module
+    depends on the value it returned for the #CAPI_V2_REQUIRES_DATA_BUFFERING
+    property. For a description of the behavior, refer to the comments for
+    CAPI_V2_REQUIRES_DATA_BUFFERING.
+    @par
+    No debug messages are allowed in this function.
+
+    @return
+    Indication of success or failure.
+
+    @dependencies
+    A valid input media type must have been set on each input port using the
+    #CAPI_V2_INPUT_MEDIA_FORMAT property. @newpage
+    */
+    capi_v2_err_t (*process)(capi_v2_t *_pif,
+                             capi_v2_stream_data_t *input[],
+                             capi_v2_stream_data_t *output[]);
+
+    /**
+     Frees any memory allocated by the module.
+
+     @datatypes
+     capi_v2_t
+
+     @param[in,out] _pif    Pointer to the module object.
+
+     @note1hang After calling this function, _pif is no longer a valid CAPIv2
+                object. Do not call any CAPIv2 functions after using it.
+
+     @return
+     Indication of success or failure.
+
+     @dependencies
+     None. @newpage
+     */
+    capi_v2_err_t (*end)(capi_v2_t *_pif);
+
+    /**
+    Sets a parameter value based on a unique parameter ID.
+
+    @datatypes
+    capi_v2_t \n
+    capi_v2_port_info_t \n
+    capi_v2_buf_t
+
+    @param[in,out] _pif      Pointer to the module object.
+    @param[in] param_id      ID of the parameter whose value is to be set.
+    @param[in] port_info_ptr Pointer to the information about the port on
+                             which this function must operate. \n
+                             If a valid port ID is not provided, either the
+                             port index does not matter for the param_id or
+                             the param_id is applicable to all ports.
+    @param[in] params_ptr    Pointer to the buffer containing the value of the
+                             parameter.
+                             The format of the data in the buffer depends on
+                             the implementation.
+
+    @detdesc
+    In the event of a failure, the appropriate error code is to be returned.
+    @par
+    The actual_data_len field of the parameter pointer is to be at least the
+    size of the parameter structure. Therefore, the following check must be
+    exercised for each tuning parameter ID:
+    @par
+    @code
+    if (params_ptr->actual_data_len >= sizeof(asm_gain_struct_t))
+    {
+    :
+    :
+    }
+    else
+    {
+    MSG_1(MSG_SSID_QDSP6, DBG_ERROR_PRIO,"CAPI_V2 Libname Set, Bad param size
+    %lu",params_ptr->actual_data_len);
+    return ADSP_ENEEDMORE;
+    }
+
+    @endcode
+    @par
+    Optionally, some parameter values can be printed for tuning verification.
+    @par
+    @note1 In this code sample, asm_gain_struct is an example only.
+           Use the correct structure based on the parameter ID.
+
+    @return
+    None.
+
+    @dependencies
+    None. @newpage
+    */
+    capi_v2_err_t (*set_param)(capi_v2_t *_pif,
+                               uint32_t param_id,
+                               const capi_v2_port_info_t *port_info_ptr,
+                               capi_v2_buf_t *params_ptr);
+
+    /**
+    Gets a parameter value based on a unique parameter ID.
+
+    @datatypes
+    capi_v2_t \n
+    capi_v2_port_info_t \n
+    capi_v2_buf_t
+
+    @param[in,out] _pif      Pointer to the module object.
+    @param[in]     param_id  Parameter ID of the parameter whose value is
+                             being passed in this function. For example:\n
+                             - CAPI_V2_LIBNAME_ENABLE
+                             - CAPI_V2_LIBNAME_FILTER_COEFF @tablebulletend
+    @param[in] port_info_ptr Pointer to the information about the port on which
+                             this function must operate. \n
+                             If the port is invalid, either the port index does
+                             not matter for the param_id or or the param_id
+                             is applicable to all ports.
+    @param[out] params_ptr   Pointer to the buffer that is to be filled with
+                             the value of the parameter. The format depends on
+                             the implementation.
+
+    @detdesc
+    In the event of a failure, the appropriate error code is to be returned.
+    @par
+    The max_data_len field of the parameter pointer must be at least the size
+    of the parameter structure. Therefore, the following check must be
+    exercised for each tuning parameter ID.
+    @par
+    @code
+    if (params_ptr->max_data_len >= sizeof(asm_gain_struct_t))
+    {
+    :
+    :
+    }
+    else
+    {
+    MSG_1(MSG_SSID_QDSP6, DBG_ERROR_PRIO,"CAPI_V2 Libname Get, Bad param size
+    %lu",params_ptr->max_data_len);
+    return ADSP_ENEEDMORE;
+    }
+
+    @endcode
+    @par
+    Before returning, the actual_data_len field must be filled with the number
+    of bytes written into the buffer.
+    @par
+    Optionally, some parameter values can be printed for tuning verification.
+    @par
+    @note1 In this code sample, asm_gain_struct is an example only.
+           Use the correct structure based on the parameter ID.
+
+    @newpage
+    @return
+    Indication of success or failure.
+
+    @dependencies
+    None. @newpage
+    */
+    capi_v2_err_t (*get_param)(capi_v2_t *_pif,
+                               uint32_t param_id,
+                               const capi_v2_port_info_t *port_info_ptr,
+                               capi_v2_buf_t *params_ptr);
+
+    /**
+    Sets a list of property values.
+
+    @datatypes
+    capi_v2_t \n
+    capi_v2_proplist_t
+
+    @param[in,out] _pif      Pointer to the module object.
+    @param[in] proplist_ptr  Pointer to the list of property values.
+
+    @detdesc
+    In the event of a failure, the appropriate error code is to be returned.
+    @par
+    Optionally, some property values can be printed for debugging.
+
+    @return
+    None.
+
+    @dependencies
+    None. @newpage
+    */
+    capi_v2_err_t (*set_properties)(capi_v2_t *_pif,
+                                    capi_v2_proplist_t *proplist_ptr);
+
+    /**
+    Gets a list of property values.
+
+    @datatypes
+    capi_v2_t \n
+    capi_v2_proplist_t
+
+    @param[in,out] _pif       Pointer to the module object.
+    @param[out] proplist_ptr  Pointer to the list of empty structures that
+                              must be filled with the appropriate property
+                              values, which are based on the property IDs
+                              provided. \n \n
+                              The client must fill some elements
+                              of the structures as input to the module. These
+                              elements must be explicitly indicated in the
+                              structure definition.
+
+    @detdesc
+    In the event of a failure, the appropriate error code is to be returned.
+
+    @return
+    Indication of success or failure.
+
+    @dependencies
+    None.
+    */
+    capi_v2_err_t (*get_properties)(capi_v2_t *_pif,
+                                    capi_v2_proplist_t *proplist_ptr);
+};
+
+/** @ingroup capiv2_func_wrapper
+  Plain C interface wrapper for the virtual function table, capi_v2_vtbl_t.
+
+  This capi_v2_t structure appears to the caller as a virtual function table.
+  The virtual function table in the instance structure is followed by other
+  structure elements, but those are invisible to the users of the CAPI_V2
+  object. This capi_v2_t structure is all that is publicly visible.
+ */
+struct capi_v2_t {
+    const capi_v2_vtbl_t *vtbl_ptr; /**< Pointer to the virtual function table. */
+};
+
+/** @ingroup capiv2_func_get_static_prop
+  Queries for properties as follows:
+  - Static properties of the module that are independent of the instance
+  - Any property that is part of the set of properties that can be statically
+    queried
+
+  @datatypes
+  capi_v2_proplist_t
+
+  @param[in] init_set_proplist Pointer to the same properties that are sent in
+                               the call to capi_v2_init_f().
+  @param[out] static_proplist  Pointer to the property list structure. \n
+                               The client fills in the property IDs for which
+                               it needs property values. The client also
+                               allocates the memory for the payloads.
+                               The module must fill in the information in this
+                               memory.
+
+  @detdesc
+  This function is used to query the memory requirements of the module to
+  create an instance. The function must fill in the data for the properties in
+  the static_proplist.
+  @par
+  As an input to this function, the client must pass in the property list that
+  it passes to capi_v2_init_f(). The module can use the property
+  values in init_set_proplist to calculate its memory requirements.
+  @par
+  The same properties that are sent to the module in the call to
+  %capi_v2_init_f() are also sent to this function to enable the module to
+  calculate the memory requirement.
+
+  @return
+  Indication of success or failure.
+
+  @dependencies
+  None.
+ */
+typedef capi_v2_err_t (*capi_v2_get_static_properties_f)(
+    capi_v2_proplist_t *init_set_proplist,
+    capi_v2_proplist_t *static_proplist);
+
+/** @ingroup capiv2_func_init
+  Instantiates the module to set up the virtual function table, and also
+  allocates any memory required by the module.
+
+  @datatypes
+  capi_v2_t \n
+  capi_v2_proplist_t
+
+  @param[in,out] _pif          Pointer to the module object. \n
+                               The memory has been allocated by the client
+                               based on the size returned in the
+                               #CAPI_V2_INIT_MEMORY_REQUIREMENT property.
+  @param[in] init_set_proplist Pointer to the properties set by the service
+                               to be used while initializing.
+
+  @detdesc
+  States within the module must be initialized at the same time.
+  @par
+  All return codes returned by this function, except #CAPI_V2_EOK, are
+  considered to be FATAL.
+  @par
+  For any unsupported property ID passed in the init_set_proplist parameter,
+  the function prints a message and continues processing other property IDs.
+
+  @return
+  Indication of success or failure.
+
+  @dependencies
+  */
+typedef capi_v2_err_t (*capi_v2_init_f)(
+    capi_v2_t *_pif,
+    capi_v2_proplist_t *init_set_proplist);
+
+#endif /* #ifndef CAPI_V2_H */
diff --git a/ext_headers/capi_v2_events.h b/ext_headers/capi_v2_events.h
new file mode 100644
index 0000000..046fddb
--- /dev/null
+++ b/ext_headers/capi_v2_events.h
@@ -0,0 +1,478 @@
+#ifndef CAPI_V2_EVENTS_H
+#define CAPI_V2_EVENTS_H
+
+/*
+ * This file contrains the functions for controlling the
+ * internal circular buffer within the sound trigger HAL.
+ * The purpose is to keep all the different read and write
+ * commands from different threads synchronized.
+ *
+ * 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.
+ */
+/*
+ @file capi_v2_events.h
+ Common Audio Processing Interface v2 header file
+
+ This file defines the events that can be raised by a module using
+ the CAPI_V2 interface.
+ */
+/* ========================================================================*/
+
+#include "capi_v2_types.h"
+
+/** @weakgroup weakf_capiv2_event_info
+  Modules use events to send asynchronous notifications to the framework.
+  During initialization, the framework provides a callback function and a
+  context pointer. The module can call this function any time to raise an
+  event. The appropriate payload must be sent based on the event ID.
+
+  The callback is not thread safe, so it must be called from the same thread
+  context as the interface functions unless mentioned otherwise in the event
+  description. The payload data is copied before the function returns.
+
+  For example, raising the kilo packets per second (KPPS) change event:
+  @code
+   capi_v2_event_KPPS_t payload;
+   payload.KPPS = 10000;
+
+   capi_v2_event_info_t payload_buffer;
+   payload_buffer.port_info.is_valid = FALSE;
+   payload_buffer.payload.data_ptr = (int8_t*)(&payload);
+   payload_buffer.payload.actual_data_len = payload_buffer.payload.max_data_len = sizeof(payload);
+
+   capi_v2_err_t result = event_cb_ptr(context_ptr, CAPI_V2_EVENT_KPPS, &payload_buffer);
+
+  @endcode
+ */
+
+/** @ingroup capiv2_events
+  Valid IDs for the events that can be raised by a module.
+*/
+enum capi_v2_event_id_t {
+    CAPI_V2_EVENT_KPPS,
+    /**< Indicates the KPPS requirement of the module.
+         This value must be calculated assuming zero cache miss. @vertspace{4}
+
+         Payload structure: capi_v2_event_KPPS_t @vertspace{4}
+
+         This event must be raised when the module is enabled and when the KPPS
+         requirement changes. @vertspace{6} */
+
+    CAPI_V2_EVENT_BANDWIDTH,
+    /**< Indicates the bandwidth requirement of the module (in bytes per
+         second). @vertspace{4}
+
+         Payload structure: capi_v2_event_bandwidth_t @vertspace{4}
+
+         The bandwidth must be specified separately for code and data. The
+         bandwidth must be calculated assuming no cache. @vertspace{4}
+
+         This event must be raised when the module is enabled and when the
+         bandwidth requirement changes. @vertspace{6} */
+
+    CAPI_V2_EVENT_DATA_TO_DSP_CLIENT,
+    /**< Sends data to the client aDSP. @vertspace{4}
+
+         Payload structure: capi_v2_event_data_to_dsp_client_t @vertspace{6}
+
+         The module must specify a parameter ID to indicate the type of data
+         that is present in the payload. The module can also specify an
+         optional token to indicate additional information such as an instance
+         identifier. @vertspace{4}
+
+         The module must provide the payload in a buffer. The buffer can be
+         safely destroyed or reused once the callback returns. @vertspace{6} */
+
+    CAPI_V2_EVENT_DATA_TO_OTHER_MODULE,
+    /**< Currently not supported. @vertspace{6} @newpage*/
+
+    CAPI_V2_EVENT_OUTPUT_MEDIA_FORMAT_UPDATED,
+    /**< Indicates that the output media format from the module has changed.
+         @vertspace{4}
+
+         Payload structure: capi_v2_set_get_media_format_t @vertspace{4}
+
+         If this event is raised during a call to capi_v2_vtbl_t::process(),
+         any data output from this process function is assumed to use
+         the old media type. @vertspace{4}
+
+         Subsequent calls to the process function output the data of the new
+         media type. If the module is to immediately output the data of the
+         new media type, it must exit the process function with zero output
+         and wait for the process function to be called again. @vertspace{6} */
+
+    CAPI_V2_EVENT_PROCESS_STATE,
+    /**< Sent to the client to specify whether the module is enabled or
+         disabled. The module is considered enabled by default. @vertspace{4}
+
+         Payload structure: capi_v2_event_process_state_t @vertspace{4}
+
+         We recommend that the module disable itself if it is not doing any
+         processing. The capi_v2_vtbl_t::process() function of the module is
+         not called until it raises this event again to enable itself.
+         @vertspace{6} */
+
+    CAPI_V2_EVENT_ALGORITHMIC_DELAY,
+    /**< Indicates the algorithmic delay (in microseconds) caused by the
+         module. This value must include any buffering delay. @vertspace{4}
+
+         Payload structure: capi_v2_event_algorithmic_delay_t @vertspace{4}
+
+         This event must be raised when the delay changes. @vertspace{6} */
+
+    CAPI_V2_EVENT_HEADROOM,
+    /**< Indicates the head room requirement (in millibels) of the module (the
+         default is zero). @vertspace{4}
+
+         Payload structure: capi_v2_event_headroom_t @vertspace{6} */
+
+    CAPI_V2_EVENT_PORT_DATA_THRESHOLD_CHANGE,
+    /**< Indicates to the client that the threshold for a port has changed.
+         @vertspace{4}
+
+         Payload structure: capi_v2_port_data_threshold_change_t @vertspace{4}
+
+         One event must be raised for each port whose threshold has changed.
+         For more information on port thresholds, see
+         #CAPI_V2_REQUIRES_DATA_BUFFERING. @vertspace{6} */
+
+    CAPI_V2_EVENT_METADATA_AVAILABLE,
+    /**< Indicates to the client that metadata is available for an output port.
+         @vertspace{4}
+
+         Payload structure: None @vertspace{4}
+
+         One event must be raised for each port whose threshold has changed.
+         For more information, see #CAPI_V2_METADATA. @vertspace{6} */
+
+    CAPI_V2_EVENT_DATA_TO_DSP_SERVICE,
+    /**< Sends data to the aDSP service. @vertspace{4}
+
+         Payload structure: capi_v2_event_data_to_dsp_service_t @vertspace{4}
+
+         The module must specify a parameter ID to indicate the type of data
+         that is present in the payload. It can also specify an optional token
+         to indicate additional information such as an instance identifier.
+         It must then provide the payload in a buffer. The buffer can be
+         safely destroyed or reused once the callback returns. @vertspace{6} */
+
+    CAPI_V2_EVENT_GET_LIBRARY_INSTANCE,
+    /**< Queries for an instance of a supporting library. @vertspace{4}
+
+         Payload structure: capi_v2_event_get_library_instance_t @vertspace{4}
+
+         The module must provide the ID of the library. The service returns a
+         pointer to an instance of the library. The instance contains a pointer
+         to the virtual function table of the library interface as the first
+         element. Every library virtual function table has
+         capi_v2_library_base_t as its first element. @vertspace{4}
+
+         For example, the following definitions are in the library header file:
+         @vertspace{4}
+   @code
+   #define LIB_GUID 0xABCD
+
+   struct lib_obj;
+
+   struct lib_vtable
+   {
+      capi_v2_library_base_t b; // Should be the first element of every library vtable
+      capi_v2_err_t lib_func1(lib_obj *obj, uint32_t param);
+      capi_v2_err_t lib_func2(lib_obj *obj, uint32_t param);
+      capi_v2_err_t lib_func3(lib_obj *obj, uint32_t param);
+   };
+
+   struct lib_obj
+   {
+      lib_vtable *vtble;
+   };
+
+   @endcode
+   @vertspace{12}
+
+   The following code is in the module: @vertspace{4}
+   @code
+    capi_v2_event_get_library_instance_t payload;
+    payload.id = LIB_GUID;
+    payload.ptr = NULL;
+
+    capi_v2_event_info_t payload_buffer;
+    payload_buffer.port_info.is_valid = FALSE; // May be a valid value based on the use case.
+    payload_buffer.payload.data_ptr = (int8_t*)(&payload);
+    payload_buffer.payload.actual_data_len = payload_buffer.payload.max_data_len = sizeof(payload);
+
+    capi_v2_err_t result = event_cb_ptr(context_ptr, CAPI_V2_EVENT_GET_LIBRARY_INSTANCE, &payload_buffer);
+
+    lib_obj *lib_ptr = (lib_obj*)payload.ptr;
+
+    lib_ptr->vtbl.lib_func1(lib_ptr, param);
+    ...
+    lib_ptr->vtbl.lib_func2(lib_ptr, param);
+    ...
+    lib_ptr->vtbl.lib_func3(lib_ptr, param);
+    ...
+
+    lib_ptr->vtbl.b.end(lib_ptr); // The pointer is freed here.
+    lib_ptr = NULL;
+
+    //The GUID can be queried from the lib object itself. This allows the code to determine the type of the object if it is not known:
+    void *unknown_lib_ptr = get_lib(); // Some function that returns a stored lib pointer whose type is unknown.
+    uint32_t interface_id = ((capi_v2_library_base_t**)unknown_lib_ptr)->get_interface_id();
+    switch(interface_id)
+    {
+    case LIB_GUID:
+       lib_obj *lib_ptr = (lib_obj*)unknown_lib_ptr;
+       ...
+    ...
+    }
+
+    @endcode @vertspace{6} @newpage */
+
+    CAPI_V2_EVENT_GET_DLINFO,
+    /**< Queries for dynamic load information if a module is available as an SO
+         file. @vertspace{4}
+
+         Payload structure: capi_v2_event_dlinfo_t @vertspace{6} */
+
+    CAPI_V2_MAX_EVENT = 0x7FFFFFFF
+    /**< Maximum value that an event ID can take. */
+
+};
+
+typedef enum capi_v2_event_id_t capi_v2_event_id_t;
+
+typedef struct capi_v2_event_info_t capi_v2_event_info_t;
+
+/** @ingroup capiv2_data_types
+  Contains information about an event.
+ */
+struct capi_v2_event_info_t {
+    capi_v2_port_info_t port_info;
+    /**< Port for which this event is raised.
+
+         Set this field to an invalid value for events that are not specific
+         to any port. */
+
+    capi_v2_buf_t payload;
+    /**< Buffer that holds the payload for the event. */
+
+};
+
+/** @ingroup capiv2_func_event_callback
+  Signature of the callback function that is used to raise an event to the
+  client.
+  The pointer to this function and the context_ptr are provided by the client
+  in the call to capi_v2_init_f().
+
+  @datatypes
+  #capi_v2_event_id_t \n
+  capi_v2_event_info_t
+
+  @param [in] context_ptr    Context pointer value provided by the framework
+                             when the callback function was passed.
+  @param [in] id             ID for the event being raised.
+  @param [in] event_info_ptr Information about the event being raised.
+
+  @returns
+  CAPI_V2_EOK -- The event was processed successfully.
+  @par
+  Error code -- Otherwise.
+
+  @dependencies
+  This function must be called from the same thread context as the interface
+  functions.
+ */
+typedef capi_v2_err_t (*capi_v2_event_cb_f)(void *context_ptr, capi_v2_event_id_t id, capi_v2_event_info_t *event_info_ptr);
+
+// Payloads for the events
+typedef struct capi_v2_event_KPPS_t capi_v2_event_KPPS_t;
+
+/** @addtogroup capiv2_payload_structs
+@{ */
+/** Payload of the #CAPI_V2_EVENT_KPPS event, which indicates the KPPS
+  requirement of a module.
+ */
+struct capi_v2_event_KPPS_t {
+    uint32_t KPPS;  /**< Kilo packets per second requirement of the module. */
+};
+
+typedef struct capi_v2_event_bandwidth_t capi_v2_event_bandwidth_t;
+
+/** Payload of the #CAPI_V2_EVENT_BANDWIDTH event, which indicates the
+  bandwidth requirement of a module.
+ */
+struct capi_v2_event_bandwidth_t {
+    uint32_t code_bandwidth;
+    /**< Code bandwidth of the module (in bytes per second). */
+
+    uint32_t data_bandwidth;
+    /**< Data bandwidth of the module (in bytes per second). */
+};
+
+typedef struct capi_v2_event_data_to_dsp_client_t capi_v2_event_data_to_dsp_client_t;
+
+/** Payload of the #CAPI_V2_EVENT_DATA_TO_DSP_CLIENT event.
+  (Currently not supported).
+ */
+struct capi_v2_event_data_to_dsp_client_t {
+    uint32_t param_id;
+    /**< Indicates the type of data that is present in the payload. */
+
+    uint32_t token;
+    /**< Optional token that indicates additional information, such as an
+         instance identifier. */
+
+    capi_v2_buf_t payload;
+    /**< Buffer containing the payload.
+
+         This buffer can be safely destroyed or reused once the callback
+         returns. */
+};
+
+typedef struct capi_v2_event_data_to_dsp_service_t capi_v2_event_data_to_dsp_service_t;
+
+/** Payload of the #CAPI_V2_EVENT_DATA_TO_DSP_SERVICE event, which sends data
+  to the aDSP service.
+ */
+struct capi_v2_event_data_to_dsp_service_t {
+    uint32_t param_id;
+    /**< Indicates the type of data that is present in the payload. */
+
+    uint32_t token;
+    /**< Optional token that indicates additional information, such as an
+         instance identifier. */
+
+    capi_v2_buf_t payload;
+    /**< Buffer containing the payload.
+
+         This buffer can be safely destroyed or reused once the callback
+         returns. */
+};
+
+typedef struct capi_v2_event_process_state_t capi_v2_event_process_state_t;
+
+/** Payload of the #CAPI_V2_EVENT_PROCESS_STATE event, which specifies whether
+  a module is enabled or disabled.
+ */
+struct capi_v2_event_process_state_t {
+    bool_t is_enabled;
+    /**< Specifies whether the module is enabled. If a module is disabled, its
+         capi_v2_vtbl_t::process() function is not called.
+
+         @values
+         - 0 -- Disabled
+         - 1 -- Enabled (Default) @tablebulletend */
+};
+
+typedef struct capi_v2_event_algorithmic_delay_t capi_v2_event_algorithmic_delay_t;
+
+/** Payload of the #CAPI_V2_EVENT_ALGORITHMIC_DELAY event, which indicates the
+  algorithmic delay caused by a module.
+ */
+struct capi_v2_event_algorithmic_delay_t {
+    uint32_t delay_in_us;
+    /**< Algorithmic delay in microseconds caused by the module.
+         This value must include any buffering delay. */
+};
+
+typedef struct capi_v2_event_headroom_t capi_v2_event_headroom_t;
+
+/** Payload of the #CAPI_V2_EVENT_HEADROOM event, which indicates the head room
+  requirement of a module.
+ */
+struct capi_v2_event_headroom_t {
+    uint32_t headroom_in_millibels;
+    /**< Headroom requirement of the module. The default is zero. */
+};
+
+typedef struct capi_v2_port_data_threshold_change_t capi_v2_port_data_threshold_change_t;
+
+/** Payload of the #CAPI_V2_EVENT_PORT_DATA_THRESHOLD_CHANGE event, which
+  indicates that the threshold for a port has changed.
+ */
+struct capi_v2_port_data_threshold_change_t {
+    uint32_t new_threshold_in_bytes;  /**< Value of the threshold for a port.
+                                           @newpagetable */
+};
+/** @} *//* end_addtogroup capiv2_payload_structs */
+
+typedef struct capi_v2_library_base_t capi_v2_library_base_t;
+
+/** @ingroup capiv2_data_types
+  First element of every library virtual function table.
+*/
+struct capi_v2_library_base_t {
+    uint32_t (*get_interface_id)(void *obj_ptr);
+    /**< Returns the ID associated with the interface that this object
+         implements. */
+
+    void (*end)(void *obj_ptr);
+    /**< De-initializes the object and frees the memory associated with it. The
+         object pointer is not valid after this call. */
+};
+
+typedef struct capi_v2_event_get_library_instance_t capi_v2_event_get_library_instance_t;
+
+/** @ingroup capiv2_payload_structs
+  Payload of the #CAPI_V2_EVENT_GET_LIBRARY_INSTANCE event, which queries
+  for an instance of a supporting library.
+*/
+struct capi_v2_event_get_library_instance_t {
+    uint32_t id;   /**< ID of the library. */
+    void *ptr;     /**< Pointer to the instance of the library. */
+};
+
+/** @ingroup capiv2_payload_structs
+  Payload of the #CAPI_V2_EVENT_GET_DLINFO event, which queries for
+  dynamic load information of an SO file.
+*/
+struct capi_v2_event_dlinfo_t {
+    uint32_t is_dl;
+    /**< Indicates whether the SO file is dynamically loaded.
+
+         @values
+         - TRUE -- File is dynamically loaded
+         - FALSE -- Otherwise
+
+         The rest of this payload is applicable only if the SO file is loaded. */
+
+    uint32_t load_addr_lsw;
+    /**< Lower 32 bits of the physical address where the SO file is loaded. */
+
+    uint32_t load_addr_msw;
+    /**< Upper 32 bits of the physical address where the SO file is loaded.
+
+         The 64-bit number formed by load_addr_lsw and load_addr_msw must
+         be 32-byte aligned and must have been previously mapped. */
+
+    uint32_t load_size;
+    /**< Size (in bytes) of the loaded SO file. */
+
+};
+
+#endif /* #ifndef CAPI_V2_EVENTS_H */
diff --git a/ext_headers/capi_v2_extn.h b/ext_headers/capi_v2_extn.h
new file mode 100644
index 0000000..012d2ea
--- /dev/null
+++ b/ext_headers/capi_v2_extn.h
@@ -0,0 +1,232 @@
+#ifndef CAPI_V2_EXTN_H
+#define CAPI_V2_EXTN_H
+
+/*
+ * This file contrains the functions for controlling the
+ * internal circular buffer within the sound trigger HAL.
+ * The purpose is to keep all the different read and write
+ * commands from different threads synchronized.
+ *
+ * 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.
+ */
+/*
+ @file capi_v2_extn.h
+ Common Audio Processing Interface v2 header file
+
+ This file defines the types and structures that are used by the capi wrappers
+ using the CAPI_V2 interface.
+ */
+/* ========================================================================*/
+
+
+typedef enum PDK_STAGE2_STRUCT_ID {
+    SVA_ID_CONFIG,
+    SVA_ID_VERSION,
+    SVA_ID_MEM_CONFIG,
+    SVA_ID_SCRATCH_PARAM,
+    SVA_ID_THRESHOLD_CONFIG,  /** threshold configuration */
+    SVA_ID_REINIT_ALL,        /** initialize all internal variables */
+    SVA_ID_REINIT_NETWORK,    /** initialize network layers */
+    SVA_ID_RESULT,            /** retrieve detection result */
+    SVA_ID_RMS_THRESHOLD_CONFIG,  /** RMS threshold configuration */
+    SVA_ID_END_DETECTION_CONFIG,  /** keyword end detection configuration */
+    SVA_ID_THRESHOLD_TABLE_CONFIG, /** threshold table */
+} SVA_STRUCT_ID;
+
+typedef struct pdk_stage2_threshold_config {
+    uint32_t struct_size;
+    int32_t smm_threshold;
+} sva_threshold_config_t;
+
+
+typedef struct pdk_stage2_rms_threshold_config {
+    uint32_t struct_size;
+    int32_t rms_threshold;
+} sva_rms_threshold_config_t;
+
+typedef struct pdk_stage2_result {
+    uint32_t struct_size;
+    uint32_t reserved;
+    int32_t is_detected;
+    int32_t best_confidence;
+    int32_t start_position;
+    int32_t end_position;  // relative position from current frame
+    int32_t current_confidence;
+} sva_result_t;
+
+typedef struct pdk_stage2_config {
+    uint32_t struct_size;
+    uint32_t sample_rate;
+    uint32_t frame_samples;
+} sva_config_t;
+
+typedef struct pdk_stage2_memory_config {
+    uint32_t struct_size;
+    uint32_t lib_static_mem_size;
+    uint32_t lib_scratch_mem_size;
+    uint32_t lib_stack_mem_size;
+} sva_memory_config_t;
+
+typedef struct pdk_stage2_end_detection_frames_config {
+    uint32_t struct_size;
+    int32_t num_ending_frames;
+} sva_end_detection_frames_config_t;
+
+
+typedef enum VOICEPRINT2_STRUCT_IDS {
+    VOICEPRINT2_ID_VERSION = 0, // refers to voiceprint2_ver_param_t in voiceprint2_calibration_api.h
+    VOICEPRINT2_ID_MEMORY,
+    VOICEPRINT2_ID_ENGINE_CONFIG,    // refer to voiceprint2_config_t
+    VOICEPRINT2_ID_REINIT,
+    VOICEPRINT2_ID_INPUT_DATA,    // refer to voiceprint2_input_data_t
+    VOICEPRINT2_ID_RESULT,    // refers to voiceprint2_result_t in voiceprint2_calibration_api.h
+    VOICEPRINT2_ID_SVA_UV_SCORE,    // refer to voiceprint2_sva_uv_score_t
+    VOICEPRINT2_ID_THRESHOLD_CONFIG,
+    VOICEPRINT2_STRUCT_IDS_END,
+}VOICEPRINT2_STRUCT_IDS;
+
+/*
+voiceprint2_result_t
+
+voiceprint2_result_t is used to get result of voiceprint processing.
+
+is_detected:            [OUT]: detection result
+
+vop2_user_score:        [OUT]: User verification vop_score
+
+combined_user_score:    [OUT]: combined user score with SVA UV score
+
+antispoofing_score:     [OUT]: Antispoofing score
+
+is_antispoofing_passed: [OUT]: decision for antispoofing for debugging purposes
+
+is_user_verification_passed: [OUT]: decision for user verification for debugging purposes
+*/
+typedef struct voiceprint2_result {
+    int32_t is_detected;
+    float vop2_user_score;
+    float combined_user_score;
+    int32_t is_user_verification_passed;
+} voiceprint2_result_t;
+
+typedef int8_t voiceprint2_t;
+
+
+/* voiceprint2_ver_param_t
+
+This structure defines the parameters associated with VOICEPRINT2_ID_VERSION in enum VOICEPRINT2_STRUCT_IDS
+
+Supported only for get_param(...) api
+
+size: [IN/OUT]: IN : Caller fills size  for the size of the payload structure, expects size >= sizeof(voiceprint2_ver_param_t)
+                OUT: Callee fills the appropriate size of the buffer filled which is sizeof(voiceprint2_ver_param_t)
+
+   */
+typedef struct voiceprint2_ver_param {
+    uint32_t version_msb;
+    uint32_t version_lsb;
+} voiceprint2_ver_param_t;
+
+
+/* voiceprint2_sva_uv_score_t
+
+This structure defines the parameters associated with VOICEPRINT2_SVA_UV_SCORE in enum VOICEPRINT2_STRUCT_IDS
+
+Supported only for set_param(...) api
+
+sva_uv_confidence_score: [IN]: IN : Caller fills the value of sva_uv_confidence_score
+
+   */
+typedef struct voiceprint2_sva_uv_score {
+    float sva_uv_confidence_score;
+} voiceprint2_sva_uv_score_t;
+
+
+/* voiceprint2_threshold_config_t
+
+This structure defines the parameters associated with VOICEPRINT2_THRESHOLD_CONFIG in enum VOICEPRINT2_STRUCT_IDS
+
+Supported only for set_param(...) api
+
+user_verification_enabled:      [IN]: Caller fills whether user_verification enable / disable (1/0)
+anti_spoofing_enabled:          [IN]: Caller fills whether anti_spoofing enable / disable (1/0)
+user_verification_threshold:    [IN]: Caller fills user verification threshold
+anti_spoofing_threshold:        [IN]: Caller fills anti spoofing threshold
+ */
+typedef struct voiceprint2_threshold_config {
+    float user_verification_threshold;
+} voiceprint2_threshold_config_t;
+
+
+/*
+voiceprint2_memory_t
+
+voiceprint2_memory_t is the library structure encapsulating memory details of the library.
+Memory for this structure has to be allocated by Callee before calling any of the library apis
+
+Note: each structure definition should have a specific id in VOICEPRINT2_STRUCT_IDS
+
+struct_size:               [IN]: Filled by the caller, shows the size of the structure
+
+lib_static_mem_size:   [IN/OUT]: Size of library static memory required in bytes, this memory
+                        --[OUT]: Calle fills for api voiceprint2_api_get_req, [IN]: Caller fills for api voiceprint2_api_init
+
+lib_scratch_mem_size:  [IN/OUT]: Size of library Scratch memory required in bytes, this memory
+                        --[OUT]: Calle fills for api voiceprint2_api_get_req, [IN]: Caller fills for api voiceprint2_api_init
+
+lib_stack_size:           [OUT]: Size of the stack needed by library. [out]: for api voiceprint2_api_get_req, Don't care for api voiceprint2_api_init
+
+   */
+typedef struct voiceprint2_memory {
+    uint32_t lib_static_mem_size;
+    uint32_t lib_scratch_mem_size;
+    uint32_t lib_mem_size;
+    uint32_t lib_stack_mem_size;
+} voiceprint2_memory_t;
+
+
+/*
+voiceprint2_config_t
+
+voiceprint2_config_t is the library structure encapsulating library engine configuration
+
+struct_size:     [IN]: size of the structure, filled by the caller
+
+sample_rate:     [IN]: sampling rate of input audio signal, filled by the caller
+
+user_model_size: [IN]: size of user model size, filled by the caller
+
+p_user_model:    [IN]: pointer to user model buffer, filled by the caller
+   */
+typedef struct voiceprint2_config {
+    uint32_t sample_rate;
+    uint32_t user_model_size;
+    uint8_t *p_user_model;
+} voiceprint2_config_t;
+
+#endif /* #ifndef CAPI_V2_EXTN_H */
diff --git a/ext_headers/capi_v2_properties.h b/ext_headers/capi_v2_properties.h
new file mode 100644
index 0000000..99ce68a
--- /dev/null
+++ b/ext_headers/capi_v2_properties.h
@@ -0,0 +1,629 @@
+#ifndef CAPI_V2_PROPERTIES_H
+#define CAPI_V2_PROPERTIES_H
+
+/*
+ * This file contrains the functions for controlling the
+ * internal circular buffer within the sound trigger HAL.
+ * The purpose is to keep all the different read and write
+ * commands from different threads synchronized.
+ *
+ * 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.
+ */
+/*
+ @file capi_v2_properties.h
+ Common Audio Processing Interface v2 header file
+
+ This file defines the data structures and ids for getting and setting
+ properties in the Common Audio Processing Interface.
+ */
+/* ========================================================================*/
+
+#include "capi_v2_types.h"
+#include "capi_v2_events.h"
+
+/** @weakgroup weakf_capiv2_property_info
+  Properties are used to set and get information to and from the module.
+  Properties are identified by IDs and have corresponding payloads. Their usage
+  is similar to parameters, but parameters are module specific:
+  - Parameters are defined by the implementor of the module
+  - Parameters are used to control aspects that are specific to the underlying
+    algorithm
+  - Properties are generic and are defined in the CAPIv2 interface. @vertspace{-6}
+
+  @par Categories of properties
+   - Properties that can be queried statically using
+     capi_v2_get_static_properties_f(): @vertspace{2}
+      - #CAPI_V2_INIT_MEMORY_REQUIREMENT
+      - #CAPI_V2_STACK_SIZE
+      - #CAPI_V2_MAX_METADATA_SIZE
+      - #CAPI_V2_IS_INPLACE
+      - #CAPI_V2_REQUIRES_DATA_BUFFERING
+      - #CAPI_V2_NUM_NEEDED_FRAMEWORK_EXTENSIONS
+      - #CAPI_V2_NEEDED_FRAMEWORK_EXTENSIONS
+      - #CAPI_V2_MAX_STATIC_PROPERTIES
+  @par
+    - Properties that can be set at initialization and at any time after
+      initialization: @vertspace{2}
+      - #CAPI_V2_EVENT_CALLBACK_INFO
+      - #CAPI_V2_PORT_NUM_INFO
+      - #CAPI_V2_HEAP_ID
+      - #CAPI_V2_INPUT_MEDIA_FORMAT
+      - #CAPI_V2_LOG_CODE
+      - #CAPI_V2_CUSTOM_INIT_DATA
+      - #CAPI_V2_MAX_INIT_PROPERTIES
+  @par
+    - Properties that can be set only after initialization: @vertspace{2}
+      - #CAPI_V2_ALGORITHMIC_RESET
+      - #CAPI_V2_EXTERNAL_SERVICE_ID
+      - #CAPI_V2_MAX_SET_PROPERTIES
+  @par
+    - Properties that can be queried using capi_v2_vtbl_t::get_properties():
+      @vertspace{2}
+      - #CAPI_V2_METADATA
+      - #CAPI_V2_PORT_DATA_THRESHOLD
+      - #CAPI_V2_OUTPUT_MEDIA_FORMAT_SIZE
+      - #CAPI_V2_MAX_GET_PROPERTIES @newpage
+  @par
+    - Properties that can be set using capi_v2_vtbl_t::set_properties() and
+      queried using capi_v2_vtbl_t::get_properties(): @vertspace{2}
+      - #CAPI_V2_OUTPUT_MEDIA_FORMAT
+      - #CAPI_V2_MAX_SET_GET_PROPERTIES
+      - #CAPI_V2_MAX_PROPERTY
+*/
+
+/** @ingroup capiv2_property_ids
+  Valid property IDs.
+ */
+enum capi_v2_property_id_t {
+    //----------- Properties that can be queried statically using get_static_properties ---------------------------------
+    CAPI_V2_INIT_MEMORY_REQUIREMENT,
+    /**< Amount of memory (in bytes) to be passed into the capi_v2_init()
+         function. @vertspace{4}
+
+         Payload structure: capi_v2_init_memory_requirement_t @vertspace{6} */
+
+    CAPI_V2_STACK_SIZE,
+    /**< Stack size required by this module (in bytes). @vertspace{4}
+
+         Payload structure: capi_v2_stack_size_t @vertspace{6} */
+
+    CAPI_V2_MAX_METADATA_SIZE,
+    /**< Maximum size of metadata generated by this module after each call
+         to capi_v2_vtbl_t::process(). @vertspace{4}
+
+         Payload structure: capi_v2_max_metadata_size_t @vertspace{4}
+
+         If this value is zero, the module does not generate any metadata.
+         The value includes the sizes of different structures used to pack
+         metadata (see #CAPI_V2_METADATA). @vertspace{6} */
+
+    CAPI_V2_IS_INPLACE,
+    /**< Indicates whether the module can perform in-place computation.
+         @vertspace{4}
+
+         Payload structure: capi_v2_is_inplace_t @vertspace{4}
+
+         If this value is TRUE, the caller can provide the same pointers for
+         input and output (but this is not guaranteed). In this case, the input
+         and output data format be the same, and the requires_data_buffering
+         property be set to FALSE. @vertspace{6} */
+
+    CAPI_V2_REQUIRES_DATA_BUFFERING,
+    /**< Specifies whether data buffering is TRUE or FALSE. @vertspace{4}
+
+         Payload structure: capi_v2_requires_data_buffering_t @vertspace{4}
+
+         If this value is FALSE and the module does not require a port data
+         threshold (#CAPI_V2_PORT_DATA_THRESHOLD), the module must behave as
+         follows:
+         @vertspace{6}
+         - The number of output samples on all output ports must always be the
+           same as the number of input samples. The caller must ensure that
+           the number of input samples is the same on all input ports.
+         - All of the input must be consumed. The caller must ensure that the
+           output buffers have enough space.
+         - The module must be able to handle any number of samples. @vertspace{6}
+         @newpage
+
+         If this value is FALSE and the module requires a port data threshold
+          (#CAPI_V2_PORT_DATA_THRESHOLD), the module must behave as follows:
+         @vertspace{6}
+         - The number of samples per buffer on all input and output ports
+           must be the same as the threshold.
+         - The caller must call the module with the required number of samples.
+         - All of the input must be consumed. The caller must ensure that the
+           output buffers have enough space. @vertspace{6}
+
+         If this value is TRUE, the module must behave as follows:
+         @vertspace{6}
+         - The module must define a threshold in number of bytes for each
+           input port and each output port.
+         - The module must consume data on its input ports and fill data on its
+           output ports until one of the following occurs: @vertspace{4}
+             - The amount of remaining data in each buffer of at least one
+               input port is less than its threshold @vertspace{-2}
+             - Or the amount of free space in each buffer of at least one
+               output port is less than its threshold. @vertspace{6}
+
+         When this value is set to TRUE, significant overhead is added. Use the
+         TRUE setting only under the following circumstances: @vertspace{6}
+         - The module performs encoding/decoding of data.
+         - The module performs rate conversion between the input and output.
+         @vertspace{6} */
+
+    CAPI_V2_NUM_NEEDED_FRAMEWORK_EXTENSIONS,
+    /**< Number of framework extensions required by this module. @vertspace{4}
+
+         Payload structure: capi_v2_num_needed_framework_extensions_t
+         @vertspace{6} */
+
+    CAPI_V2_NEEDED_FRAMEWORK_EXTENSIONS,
+    /**< List of framework extensions that are required by the module.
+         @vertspace{4}
+
+         Payload structure: An array of capi_v2_framework_extension_id_t
+         structures @vertspace{6}
+         - Each value is the ID of a framework extension.
+         - The number of elements of the array is the number returned in the
+           query for the #CAPI_V2_NUM_NEEDED_FRAMEWORK_EXTENSIONS property.
+           @vertspace{6} */
+
+    CAPI_V2_INTERFACE_EXTENSIONS,
+    /**< List of interface extensions provided by the client.
+         @vertspace{4}
+
+         The module must set the is_supported flag to TRUE or FALSE to indicate
+         whether the module supports this extension.
+         Additional data can also be exchanged using an optional buffer per
+         extension. @vertspace{4}
+
+         Payload structure: capi_v2_interface_extns_list_t @vertspace{6} */
+
+    CAPI_V2_MAX_STATIC_PROPERTIES = 0x10000,
+    /**< Dummy value that indicates the range of properties.
+         @vertspace{6} */
+
+    //------------ End of properties that can be queried statically -------------------------
+
+    //-------------- Properties that can be set at init and at any time after init ----------------------------
+    CAPI_V2_EVENT_CALLBACK_INFO,
+    /**< Function pointer and state required for raising events to the
+         framework. @vertspace{4}
+
+         Payload structure: capi_v2_event_callback_info_t @vertspace{6} */
+
+    CAPI_V2_PORT_NUM_INFO,
+    /**< Sets the number of input and output ports for the module.
+         @vertspace{4}
+
+         Payload structure: capi_v2_port_num_info_t @vertspace{6} */
+
+    CAPI_V2_HEAP_ID,
+    /**< Provides the heap IDs for allocating memory. @vertspace{4}
+
+         Payload structure: capi_v2_heap_id_t @vertspace{6} */
+
+    CAPI_V2_INPUT_MEDIA_FORMAT,
+    /**< Sets the media format for an input port.
+         The caller must set the port ID in the payload. @vertspace{4}
+
+         Payload structure: capi_v2_set_get_media_format_t @vertspace{6} */
+
+    CAPI_V2_LOG_CODE,
+    /**< Provides the logging code to the module for logging module data.
+         @vertspace{4}
+
+         Payload structure: capi_v2_log_code_t @vertspace{6} */
+
+    CAPI_V2_CUSTOM_INIT_DATA,
+    /**< Provides module-specific initialization data.
+         This property ID is typically set only at initialization time.
+         @vertspace{4}
+
+         Payload structure: Module-specific @vertspace{6} */
+
+    CAPI_V2_SESSION_IDENTIFIER,
+    /**< Provides values that allow the module to uniquely identify its
+         placement and session.
+
+         Payload structure: capi_v2_session_identifier_t @vertspace{6} */
+
+    CAPI_V2_MAX_INIT_PROPERTIES = 0x20000,
+    /**< Dummy value that indicates the range of properties.
+         @vertspace{6} */
+
+    //-------------- End of properties that can be set at init and at any time after init ----------------------
+
+    //-------------- Properties that can only be set after init -------------
+    CAPI_V2_ALGORITHMIC_RESET,
+    /**< Specifies whether the module is to reset any internal buffers and the
+         algorithm state to zero. @vertspace{4}
+
+         Payload structure: Empty buffer @vertspace{4}
+
+         Settings do not need to be reset, and memory allocated by the module
+         does not need to be freed. @vertspace{6} */
+
+    CAPI_V2_EXTERNAL_SERVICE_ID,
+    /**< Currently not used. @vertspace{6} */
+
+    CAPI_V2_REGISTER_EVENT_DATA_TO_DSP_CLIENT,
+    /**< Specifies the registration information for an event of type
+         #CAPI_V2_EVENT_DATA_TO_DSP_CLIENT. @vertspace{4}
+
+         Payload structure: capi_v2_register_event_to_dsp_client_t @vertspace{6} */
+
+    CAPI_V2_MAX_SET_PROPERTIES = 0x30000,
+    /**< Dummy value that indicates the range of properties. @vertspace{6} */
+
+    //-------------- End of properties that can be set any time -------------
+
+    //-------------- Properties that can only be queried only using get properties ---------------
+    CAPI_V2_METADATA,
+    /**< Specifies that the module must fill in any metadata that it generated
+         during a capi_v2_vtbl_t::process() call when the caller queries this
+         parameter. The query is typically done after the module raises
+         #CAPI_V2_EVENT_METADATA_AVAILABLE. @vertspace{4}
+
+         Payload structure: capi_v2_metadata_t @vertspace{4}
+
+         Metadata is put in the payload of capi_v2_metadata_t.
+         The module must pack the payload of metadata as groups of
+         asm_stream_param_data_t (defined in
+         @xrefcond{Q3,80-NF774-1,80-NA610-1}). @vertspace{4}
+
+         The buffer is structured as follows: @vertspace{6}
+         - First asm_stream_param_data_v2_t
+         - First metadata
+         - Second asm_stream_param_data_v2_t
+         - Second metadata
+         - Etc. @vertspace{6} */
+    /* asm_stream_param_data_t is in adsp_asm_stream_commands.h */
+
+    CAPI_V2_PORT_DATA_THRESHOLD,
+    /**< Threshold of an input or output port (in bytes). @vertspace{4}
+
+         Payload structure: capi_v2_port_data_threshold_t @vertspace{4}
+
+         This property ID is used only for modules that require a specific
+         amount of data on any port. The module behavior depends on whether
+         the module requires data buffering.
+         For more information, see #CAPI_V2_REQUIRES_DATA_BUFFERING.
+         @vertspace{6} */
+
+    CAPI_V2_OUTPUT_MEDIA_FORMAT_SIZE,
+    /**< Size of the media format payload for an output port.
+         The size excludes the size of capi_v2_data_format_header_t.
+         @vertspace{4}
+
+         Payload structure: capi_v2_output_media_format_size_t @vertspace{6} */
+
+    CAPI_V2_MAX_GET_PROPERTIES = 0x40000,
+    /**< Dummy value that indicates the range of properties.
+         @vertspace{6} */
+    //------------ End of properties that can only be queried using get properties -------------------------
+
+    //-------------- Properties that can be set or queried using set/get properties only ------------
+    CAPI_V2_OUTPUT_MEDIA_FORMAT,
+    /**< Queries the media format for a specified output port. @vertspace{4}
+
+         Payload structure: capi_v2_set_get_media_format_t @vertspace{4}
+
+         This property ID can also be used to set the output media format for
+         modules that support control of the output media format. @vertspace{4}
+
+         If a module supports control of some aspects such as the sample rate
+         only, all other fields can be set to #CAPI_V2_DATA_FORMAT_INVALID_VAL.
+         The caller must set the port ID in the payload. @vertspace{6} */
+
+    CAPI_V2_CUSTOM_PROPERTY,
+    /**< Sets and gets a property that is specific to a framework
+          extension. This property ID can also be used to statically get a
+          module-specific property. @vertspace{4}
+
+          Payload structure: capi_v2_custom_property_t @vertspace{4}
+
+          The framework extension must define a secondary property ID and
+          corresponding payload structure (capi_v2_custom_property_t) that are
+          specific to the information the property is to set or get.
+          @vertspace{6} */
+
+    CAPI_V2_MAX_SET_GET_PROPERTIES = 0x50000,
+    /**< Dummy value that indicates the range of properties.
+         @vertspace{6} */
+
+    CAPI_V2_MAX_PROPERTY = 0x7FFFFFFF
+    /**< Maximum value that a property ID can take. */
+
+};
+
+typedef enum capi_v2_property_id_t capi_v2_property_id_t;
+
+typedef struct capi_v2_prop_t capi_v2_prop_t;
+
+/** @addtogroup capiv2_data_types
+@{ */
+/** Contains properties that can be sent to a module.
+
+  Properties are used for generic set and get commands, which are independent
+  of the underlying module.
+ */
+struct capi_v2_prop_t {
+    capi_v2_property_id_t id;
+    /**< Unique identifier of the property that is being sent. */
+
+    capi_v2_buf_t payload;
+    /**< Payload buffer.
+
+         The buffer must contain the payload corresponding to the property value
+         for the set_property call, and it must be sufficiently large to contain
+         the payload for a get_property call. */
+
+    capi_v2_port_info_t port_info;
+    /**< Information about the port for which the property is applicable.
+
+         If the property is is applicable to any port, the is_valid flag must be
+         set to FALSE in the port information. */
+};
+
+typedef struct capi_v2_proplist_t capi_v2_proplist_t;
+
+/** Contains a list of CAPI_V2 properties. This structure can be used to send
+  a list of properties to the module or query for the properties.
+ */
+struct capi_v2_proplist_t {
+    uint32_t props_num;       /**< Number of elements in the array. */
+    capi_v2_prop_t *prop_ptr; /**< Array of CAPI_V2 property elements. */
+};
+/** @} *//* end_addtogroup capiv2_data_types */
+
+// Payloads for the properties
+typedef struct capi_v2_init_memory_requirement_t capi_v2_init_memory_requirement_t;
+
+/** @addtogroup capiv2_payload_structs
+@{ */
+/** Payload of the #CAPI_V2_INIT_MEMORY_REQUIREMENT property.
+*/
+struct capi_v2_init_memory_requirement_t {
+    uint32_t size_in_bytes;  /**< Amount of memory. */
+};
+
+typedef struct capi_v2_stack_size_t capi_v2_stack_size_t;
+
+/** Payload of the #CAPI_V2_STACK_SIZE property.
+*/
+struct capi_v2_stack_size_t {
+    uint32_t size_in_bytes;  /**< Size of the stack. @newpagetable */
+};
+
+typedef struct capi_v2_max_metadata_size_t capi_v2_max_metadata_size_t;
+
+/** Payload of the #CAPI_V2_MAX_METADATA_SIZE property.
+*/
+struct capi_v2_max_metadata_size_t {
+    uint32_t output_port_index;  /**< Index of the output port for which this
+                                      property applies. */
+    uint32_t size_in_bytes;     /**< Size of the metadata. */
+};
+
+typedef struct capi_v2_is_inplace_t capi_v2_is_inplace_t;
+
+/** Payload of the #CAPI_V2_IS_INPLACE property.
+*/
+struct capi_v2_is_inplace_t {
+    bool_t is_inplace;
+    /**< Indicates whether a module is capable of doing in-place processing.
+
+         @values
+         - 0 -- Does not support in-place processing
+         - 1 -- Supports in-place processing @tablebulletend */
+};
+
+typedef struct capi_v2_requires_data_buffering_t capi_v2_requires_data_buffering_t;
+
+/** Payload of the #CAPI_V2_REQUIRES_DATA_BUFFERING property.
+*/
+struct capi_v2_requires_data_buffering_t {
+    bool_t requires_data_buffering;  /**< Specifies whether data buffering
+                                          is set to TRUE. */
+};
+
+typedef struct capi_v2_event_callback_info_t capi_v2_event_callback_info_t;
+
+/** Payload of the #CAPI_V2_EVENT_CALLBACK_INFO property.
+*/
+struct capi_v2_event_callback_info_t {
+    capi_v2_event_cb_f event_cb; /**< Callback function used to raise an
+                                      event. */
+    void *event_context;         /**< Opaque pointer value used as the context
+                                      for this callback function. */
+};
+
+typedef struct capi_v2_port_num_info_t capi_v2_port_num_info_t;
+
+/** Payload of the #CAPI_V2_PORT_NUM_INFO property.
+*/
+struct capi_v2_port_num_info_t {
+    uint32_t num_input_ports;   /**< Number of input ports. */
+    uint32_t num_output_ports;  /**< Number of output ports. */
+};
+
+typedef struct capi_v2_heap_id_t capi_v2_heap_id_t;
+
+/** Payload of the #CAPI_V2_HEAP_ID property.
+*/
+struct capi_v2_heap_id_t {
+    uint32_t heap_id;  /**< Heap ID for allocating memory. */
+};
+
+typedef struct capi_v2_metadata_t capi_v2_metadata_t;
+
+/** Payload of the #CAPI_V2_METADATA property.
+*/
+struct capi_v2_metadata_t {
+    capi_v2_buf_t payload;  /**< For details, see #CAPI_V2_METADATA. */
+};
+
+typedef struct capi_v2_port_data_threshold_t capi_v2_port_data_threshold_t;
+
+/** Payload of the #CAPI_V2_PORT_DATA_THRESHOLD property.
+*/
+struct capi_v2_port_data_threshold_t {
+    uint32_t threshold_in_bytes;  /**< Threshold of an input or output port.
+                                       */
+};
+
+typedef struct capi_v2_output_media_format_size_t capi_v2_output_media_format_size_t;
+
+/** Payload of the #CAPI_V2_OUTPUT_MEDIA_FORMAT_SIZE property.
+*/
+struct capi_v2_output_media_format_size_t {
+    uint32_t size_in_bytes;  /**< Size of the media format payload for an
+                                  output port. */
+};
+
+typedef struct capi_v2_num_needed_framework_extensions_t capi_v2_num_needed_framework_extensions_t;
+
+/** Payload of the #CAPI_V2_NUM_NEEDED_FRAMEWORK_EXTENSIONS property.
+*/
+struct capi_v2_num_needed_framework_extensions_t {
+    uint32_t num_extensions;  /**< Number of framework extensions. */
+};
+
+typedef struct capi_v2_framework_extension_id_t capi_v2_framework_extension_id_t;
+
+/** Payload of the #CAPI_V2_NEEDED_FRAMEWORK_EXTENSIONS property.
+*/
+struct capi_v2_framework_extension_id_t {
+    uint32_t id;  /**< ID of the framework extension. */
+};
+
+typedef struct capi_v2_log_code_t capi_v2_log_code_t;
+
+/** Payload of the #CAPI_V2_LOG_CODE property.
+*/
+struct capi_v2_log_code_t {
+    uint32_t code;  /**< Code for logging module data. */
+};
+
+typedef struct capi_v2_session_identifier_t capi_v2_session_identifier_t;
+
+/** Payload of the #CAPI_V2_SESSION_IDENTIFIER property.
+ */
+struct capi_v2_session_identifier_t {
+    uint16_t service_id;
+    /**< Unique identifier of the service in which the module is contained.
+
+         This ID is an opaque value that is not guaranteed to be
+         backward-compatible. As such, modules are not to determine their
+         behavior based on this value. */
+
+    uint16_t session_id;
+    /**< Unique identifier of the session within the service as indicated by
+         service_id.
+
+         Modules can use this value together with service_id to generate unique
+         IDs for setting up intermodule communication within the same service
+         session or for debug messaging. */
+};
+
+typedef struct capi_v2_custom_property_t capi_v2_custom_property_t;
+
+/** Payload of the #CAPI_V2_CUSTOM_PROPERTY property.
+*/
+struct capi_v2_custom_property_t {
+    uint32_t secondary_prop_id;
+    /**< Secondary property ID that indicates the format of the rest of the
+         payload.
+
+         Following this ID is the custom payload defined by the service. If a
+         module does not support a custom property or a secondary property ID,
+         it must return 0 in payload.actual_data_len of capi_v2_prop_t. */
+};
+
+typedef struct capi_v2_interface_extns_list_t capi_v2_interface_extns_list_t;
+
+/** Payload of the #CAPI_V2_INTERFACE_EXTENSIONS property.
+
+  Following this structure is an array of capi_v2_interface_extn_desc_t
+  structures with num_extensions elements.
+ */
+struct capi_v2_interface_extns_list_t {
+    uint32_t num_extensions;
+    /**< Number of interface extensions for which the client is querying.
+         The client must provide this value. */
+};
+
+typedef struct capi_v2_interface_extn_desc_t capi_v2_interface_extn_desc_t;
+
+/** Data type of each element in an array of
+    capi_v2_interface_extns_list_t::num_extensions elements (for the
+    #CAPI_V2_INTERFACE_EXTENSIONS property).
+ */
+struct capi_v2_interface_extn_desc_t {
+    uint32_t id;
+    /**< ID of the interface extension being queried. The client must provide
+         this value. */
+
+    bool_t is_supported;
+    /**< Indicates whether this extension is supported.
+
+         @values
+         - 0 -- Not supported
+         - 1 -- Supported
+
+         The module must provide this value. */
+
+    capi_v2_buf_t capabilities;
+    /**< Optional buffer containing a structure that can be used for further
+         negotiation of capabilities related to this extension.
+
+         The structure is defined in the interface extension file. If it is not
+         defined in this file, the interface extension does not have a
+         capabilities structure. */
+};
+
+typedef struct capi_v2_register_event_to_dsp_client_t capi_v2_register_event_to_dsp_client_t;
+
+/** Payload of #CAPI_V2_REGISTER_EVENT_DATA_TO_DSP_CLIENT, which provides
+    registration information for a #CAPI_V2_EVENT_DATA_TO_DSP_CLIENT event.
+ */
+struct capi_v2_register_event_to_dsp_client_t {
+    uint32_t event_id;
+    /**< ID of the event to be registered. */
+
+    bool_t is_registered;
+    /**< Indicates whether a client is registered for the event.
+
+         @values
+         - TRUE --  Client is registered
+         - FALSE -- Client is not registered @tablebulletend */
+};
+/** @} *//* end_addtogroup capiv2_payload_structs */
+
+#endif /* #ifndef CAPI_V2_PROPERTIES_H */
diff --git a/ext_headers/capi_v2_types.h b/ext_headers/capi_v2_types.h
new file mode 100644
index 0000000..d51d53b
--- /dev/null
+++ b/ext_headers/capi_v2_types.h
@@ -0,0 +1,412 @@
+#ifndef CAPI_V2_TYPES_H
+#define CAPI_V2_TYPES_H
+
+/*
+ * This file contrains the functions for controlling the
+ * internal circular buffer within the sound trigger HAL.
+ * The purpose is to keep all the different read and write
+ * commands from different threads synchronized.
+ *
+ * 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.
+ */
+/*
+ @file capi_v2_types.h
+ Common Audio Processing Interface v2 common types.
+
+ This file defines the basic data types for the Common Audio Processing
+ Interface.
+ */
+/*=========================================================================*/
+
+#include "mmdefs.h"
+
+/** @addtogroup capiv2_error_codes
+@{ */
+
+/** Error code type for CAPIv2. */
+typedef uint32_t capi_v2_err_t;
+
+/** Success. The operation completed with no errors. */
+#define CAPI_V2_EOK 0
+
+/** General failure. */
+#define CAPI_V2_EFAILED             ((uint32_t)1)
+
+/** Invalid parameter value set. */
+#define CAPI_V2_EBADPARAM           (((uint32_t)1) << 1)
+
+/** Unsupported routine or operation. */
+#define CAPI_V2_EUNSUPPORTED        (((uint32_t)1) << 2)
+
+/** Operation does not have memory. */
+#define CAPI_V2_ENOMEMORY           (((uint32_t)1) << 3)
+
+/** Operation needs more data or buffer space. */
+#define CAPI_V2_ENEEDMORE           (((uint32_t)1) << 4)
+
+/** Macro that checks whether a CAPIv2 error code has any error bits set. */
+#define CAPI_V2_FAILED(x) (CAPI_V2_EOK != (x))
+
+/** Macro that checks whether a CAPIv2 error code represents a success case. */
+#define CAPI_V2_SUCCEEDED(x) (CAPI_V2_EOK == (x))
+
+/** Macro that sets an error flag in a CAPIv2 error code. */
+#define CAPI_V2_SET_ERROR(error_flags, return_code) ((error_flags) |= (return_code))
+
+/** Macro that checks whether a specific error flag is set in a CAPIv2 error
+    code. */
+#define CAPI_V2_IS_ERROR_CODE_SET(error_flags, error_code) (((error_flags) & (error_code)) != CAPI_V2_EOK)
+
+/** @} *//* end_addtogroup capiv2_error_codes */
+
+
+typedef struct capi_v2_buf_t capi_v2_buf_t;
+
+/** @addtogroup capiv2_data_types
+@{ */
+/** Contains input buffers, output buffers, property payloads, event payloads,
+  and parameters that are passed into the CAPIv2 functions.
+*/
+struct capi_v2_buf_t {
+    int8_t *data_ptr;
+    /**< Data pointer to the raw data. The alignment depends on the format
+         of the raw data. */
+
+    uint32_t actual_data_len;
+    /**< Length of the valid data (in bytes).
+
+         For input buffers:
+         - The caller fills this field with the number of bytes of valid data in
+           the buffer.
+         - The callee fills this field with the number of bytes of data it read.
+
+         For output buffers:
+         - The caller leaves this field uninitialized.
+         - The callee fills it with the number of bytes of data it filled.
+         @tablebulletend */
+
+    uint32_t max_data_len;
+    /**< Total allocated size of the buffer (in bytes).
+
+         This value is always filled by the caller, and it is not modified by
+         the callee. */
+};
+
+typedef struct capi_v2_stream_flags_t capi_v2_stream_flags_t;
+
+/** Flags that are passed with every input buffer and must be filled by the
+  module for every output buffer. These flags apply only to the buffer with
+  which they are associated.
+*/
+struct capi_v2_stream_flags_t {
+    uint32_t is_timestamp_valid :1;
+    /**< Specifies whether the timestamp is valid.
+
+         @values
+         - 0 -- Not valid
+         - 1 -- Valid @tablebulletend */
+
+    uint32_t end_of_frame :1;
+    /**< Specifies whether the buffer ends with the end of an encoded frame.
+
+         @values
+         - 0 -- The buffer might have an incomplete frame (relevant for
+           compressed data only)
+         - 1 --The buffer ends with the end of a frame. This allows the module
+           to start processing without scanning for the end of frame.
+          @tablebulletend */
+
+    uint32_t marker_eos :1;
+    /**< Indicates that this data is the last valid data from the upstream
+         port. */
+
+    uint32_t marker_1 :1;
+    /**< Data marker 1 used by the service to track data.
+
+         The module must propagate this marker from the input port to any output
+         port that gets input from this port. */
+
+    uint32_t marker_2 :1;
+    /**< Data marker 2 used by the service to track data.
+
+         The module must propagate this marker from the input port to any output
+         port that gets input from this port. */
+
+    uint32_t marker_3 :1;
+    /**< Data marker 3 used by the service to track data.
+
+         The module must propagate this marker from the input port to any output
+         port that gets input from this port. */
+
+    uint32_t reserved :26;
+    /**< Reserved for future use. The client must ignore this value for input
+         ports and set it to zero for output ports. */
+};
+
+typedef struct capi_v2_stream_data_t capi_v2_stream_data_t;
+
+/** Data structure for one stream.
+ */
+struct capi_v2_stream_data_t {
+    capi_v2_stream_flags_t flags;
+    /**< Flags that indicate the stream properties. For more information on
+         the flags, see the capi_v2_stream_flags_t structure. */
+
+    int64_t timestamp;
+    /**< Timestamp of the first data sample, in microseconds.
+
+         The time origin is not fixed; it must be inferred from the timestamp of
+         the first buffer. Negative values are allowed. */
+
+    capi_v2_buf_t *buf_ptr;
+    /**< Array of CAPI_V2 buffer elements.
+
+         For deinterleaved unpacked uncompressed data, one buffer is to be
+         used per channel. For all other cases, only one buffer is to be
+         used. */
+
+    uint32_t bufs_num;
+    /**< Number of buffer elements in the buf_ptr array.
+
+         For deinterleaved unpacked uncompressed data, this is equal to the
+         number of channels in the stream. For all other cases, all the data
+         is put in one buffer, so this field is set to 1. */
+};
+
+/** Maximum number of channels supported in a stream. */
+#define CAPI_V2_MAX_CHANNELS 16
+
+/** Valid values for data formats of the inputs and outputs of a module.
+*/
+enum data_format_t {
+    CAPI_V2_FIXED_POINT,
+    /**< Fixed point PCM data.
+
+         Payload structure: capi_v2_standard_data_format_t @vertspace{6} */
+
+    CAPI_V2_FLOATING_POINT,
+    /**< Floating point PCM data.
+
+         Payload structure: capi_v2_standard_data_format_t @vertspace{6} */
+
+    CAPI_V2_RAW_COMPRESSED,
+    /**< Compressed audio data bitstream in an unpacketized form.
+
+         Payload structure: capi_v2_raw_compressed_data_format_t @vertspace{6} */
+
+    CAPI_V2_IEC61937_PACKETIZED,
+    /**< Compressed audio data bitstream packetized according to
+         @xhyperref{S1,IEC~61937}.
+
+         Payload structure: capi_v2_standard_data_format_t @vertspace{6} */
+
+    CAPI_V2_DSD_DOP_PACKETIZED,
+    /**< Compressed audio data bitstream packetized in QTI DSD-over-PCM
+         (DSD_DOP) format (16 bit, MSB first, word interleaved).
+
+         Payload structure: capi_v2_standard_data_format_t @vertspace{6} */
+
+    CAPI_V2_COMPR_OVER_PCM_PACKETIZED,
+    /**< Compressed bitstreams packetized like PCM using a QTI-designed
+         packetizer.
+
+         Payload structure: capi_v2_standard_data_format_t @vertspace{6} */
+
+    CAPI_V2_GENERIC_COMPRESSED,
+    /**< Compressed audio data bitstream that will be passed through as is,
+         without knowing or modifying the underlying structure.
+
+         Payload structure: capi_v2_standard_data_format_t @vertspace{6} */
+
+    CAPI_V2_MAX_FORMAT_TYPE = 0x7FFFFFFF
+    /**< Maximum value that a data format can take. */
+};
+
+typedef enum data_format_t data_format_t;
+
+/** Used in any field of capi_v2_data_format_t to indicate that the value is
+    unspecified. */
+#define CAPI_V2_DATA_FORMAT_INVALID_VAL 0xFFFFFFFF
+
+/** Valid values for data interleaving or deinterleaving.
+ */
+enum capi_v2_interleaving_t {
+    CAPI_V2_INTERLEAVED,
+    /**< Data for all channels is present in one buffer. The samples are
+         interleaved per channel. */
+
+    CAPI_V2_DEINTERLEAVED_PACKED,
+    /**< Data for all channels is present in one buffer. All of the samples of
+         one channel are present, followed by all of the samples of
+         the next channel, etc. */
+
+    CAPI_V2_DEINTERLEAVED_UNPACKED,
+    /**< Data for each channel is present in a different buffer. In this case,
+         the capi_v2_stream_data_t::buf_ptr field points to an array of buffer
+         structures with the number of elements equal to the number of channels.
+         The bufs_num field must be set to the number of channels. */
+
+    CAPI_V2_INVALID_INTERLEAVING = CAPI_V2_DATA_FORMAT_INVALID_VAL
+    /**< Interleaving is not valid. */
+};
+
+typedef enum capi_v2_interleaving_t capi_v2_interleaving_t;
+
+/** @} *//* end_addtogroup capiv2_data_types */
+
+typedef struct capi_v2_data_format_header_t capi_v2_data_format_header_t;
+
+/** @addtogroup capiv2_payload_structs
+@{ */
+/** Header structure for a data format that is passed into the module.
+    Following this header is the appropriate media format payload.
+ */
+struct capi_v2_data_format_header_t {
+    data_format_t data_format;
+    /**< Indicates the format in which the data is represented.
+         The rest of the payload depends on the data format. @newpagetable */
+};
+
+typedef struct capi_v2_set_get_media_format_t capi_v2_set_get_media_format_t;
+
+/** Header structure used to set and get a media format.
+    Following this header is the appropriate media format payload.
+ */
+struct capi_v2_set_get_media_format_t {
+    capi_v2_data_format_header_t format_header;
+    /**< Header of the media format. */
+};
+
+typedef struct capi_v2_standard_data_format_t capi_v2_standard_data_format_t;
+
+/** Payload structure for FIXED_POINT, FLOATING_POINT, and
+    IEC61937_PACKETIZED data formats.
+ */
+struct capi_v2_standard_data_format_t {
+    uint32_t bitstream_format;
+    /**< Valid types are ADSP_MEDIA_FMT_* as defined in
+         @xrefcond{Q3,80-NF774-1,80-NA610-1}. */
+    /* adsp_media_fmt.h */
+
+    uint32_t num_channels;
+    /**< Number of channels. */
+
+    uint32_t bits_per_sample;
+    /**< Number of bits used to store each sample.
+
+         For example, if the data is 24-bit audio packed in 24 bits,
+         this value is 24. If it is 24-bit audio packed in 32 bits,
+         this value is 32. */
+
+    uint32_t q_factor;
+    /**< Number of fractional bits in the fixed point representation of the
+         data.
+
+         If the data is floating point, this field must be set to
+         #CAPI_V2_DATA_FORMAT_INVALID_VAL. */
+
+    uint32_t sampling_rate;
+    /**< Sampling rate in samples per second. */
+
+    uint32_t data_is_signed;
+    /**< Specifies whether data is signed.
+
+         @values
+         - 1 -- Signed
+         - 0 -- Unsigned @tablebulletend */
+
+    capi_v2_interleaving_t data_interleaving;
+    /**< Indicates whether the data is interleaved. This value is not relevant
+         for packetized data.
+
+         @values
+         - #CAPI_V2_INTERLEAVED
+         - #CAPI_V2_DEINTERLEAVED_PACKED
+         - #CAPI_V2_DEINTERLEAVED_UNPACKED @tablebulletend */
+
+    uint16_t channel_type[CAPI_V2_MAX_CHANNELS];
+    /**< Channel types for each of the num_channels. Valid channel types are
+         the PCM_CHANNEL_* types defined in @xrefcond{Q3,80-NF774-1,80-NA610-1}.
+         @newpagetable */
+    /* adsp_media_fmt.h */
+};
+
+typedef struct capi_v2_raw_compressed_data_format_t capi_v2_raw_compressed_data_format_t;
+
+/** Payload structure header for the RAW_COMPRESSED data format.
+  Following this structure is the media format structure for the specific data
+  format as defined in adsp_media_fmt.h.
+ */
+struct capi_v2_raw_compressed_data_format_t {
+    uint32_t bitstream_format;
+    /**< Valid types are ADSP_MEDIA_FMT_* as defined in
+         @xrefcond{Q3,80-NF774-1,80-NA610-1}. */
+    /* adsp_media_fmt.h */
+};
+
+/** @} *//* end_addtogroup capiv2_payload_structs */
+
+typedef struct capi_v2_port_info_t capi_v2_port_info_t;
+
+/** @ingroup capiv2_data_types
+  Port information payload structure.
+ */
+struct capi_v2_port_info_t {
+    bool_t is_valid;
+    /**< Indicates whether port_index is valid.
+
+         @values
+         - 0 -- Not valid
+         - 1 -- Valid @tablebulletend */
+
+    bool_t is_input_port;
+    /**< Indicates the type of port.
+
+         @values
+         - TRUE -- Input port
+         - FALSE -- Output port @tablebulletend */
+
+    uint32_t port_index;
+    /**< Identifies the port.
+
+         Index values must be sequential numbers starting from zero. There are
+         separate sequences for input and output ports. For example, if a
+         module has three input ports and two output ports:
+         - The input ports have index values of 0, 1, and 2.
+         - The output ports have index values of 0 and 1.
+
+         When capi_v2_vtbl_t::process() is called:
+         - The data in input[0] is for input port 0.
+         - The data in input[1] is for input port 1.
+         - Etc.
+         - Output port 0 must fill data into output[0].
+         - Output port 1 must fill data into output[1].
+         - Etc. @tablebulletend @newpagetable */
+};
+
+#endif /* #ifndef CAPI_V2_TYPES_H */
diff --git a/ext_headers/mmdefs.h b/ext_headers/mmdefs.h
new file mode 100644
index 0000000..9e63a75
--- /dev/null
+++ b/ext_headers/mmdefs.h
@@ -0,0 +1,106 @@
+#ifndef _MMDEFS_H
+#define _MMDEFS_H
+
+/*
+ * This file contrains the functions for controlling the
+ * internal circular buffer within the sound trigger HAL.
+ * The purpose is to keep all the different read and write
+ * commands from different threads synchronized.
+ *
+ * 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.
+ */
+/*
+ *                   S T A N D A R D    D E C L A R A T I O N S
+ *
+ *  Defines common types used within Multimedia Subsystem. Attempt is made to
+ *  align to C99 standard and intention is to keep the list of commonly used
+ *  types small.
+*/
+/*===========================================================================*/
+
+#if /* Supported Compilers */ \
+    defined(__ARMCC_VERSION) || \
+    defined(__GNUC__)
+
+/* If we're hosted, fall back to the system's stdint.h, which might have
+ * additional definitions.
+ */
+
+#include "stdint.h"
+
+#else /* Unsupported Compilers */
+
+/* The following definitions are the same accross platforms.  This first
+ * group are the sanctioned types.
+ */
+
+typedef unsigned long long uint64_t;  /**< Unsigned 64-bit integer type. */
+typedef unsigned long int uint32_t;  /**< Unsigned 32-bit integer type. */
+typedef unsigned short uint16_t;  /**< Unsigned 16-bit integer type. */
+typedef unsigned char uint8_t;   /**< Unsigned  8-bit integer type. */
+
+typedef signed long long int64_t;   /**< Signed 64-bit integer type. */
+typedef signed long int int32_t;   /**< Signed 32-bit integer type. */
+typedef signed short int16_t;   /**< Signed 16-bit integer type. */
+typedef signed char int8_t;    /**< Signed  8-bit integer type. */
+
+#endif /* Supported Compilers */
+
+/** @} */ /* end_name Standard Integer Types */
+/** @} */ /* end_addtogroup apr_core_data_types */
+
+/** @addtogroup apr_core_constants_macros
+@{ */
+/* ------------------------------------------------------------------------
+** Constants
+** ------------------------------------------------------------------------ */
+#undef TRUE
+#undef FALSE
+
+#define TRUE   (1)  /**< Boolean value for TRUE. */
+#define FALSE  (0)  /**< Boolean value for FALSE. */
+
+#ifndef NULL
+#define NULL (0)  /**< NULL value. */
+#endif
+
+/** @} */ /* end_addtogroup apr_core_constants_macros */
+
+/** @addtogroup apr_core_data_types
+@{ */
+/* ------------------------------------------------------------------------*/
+/** @name Character and Boolean Types
+@{ */
+/* ------------------------------------------------------------------------ */
+typedef char char_t;           /**< Eight-bit character type. */
+typedef unsigned char bool_t;  /**< Eight-bit Boolean type. */
+
+/** @} */ /* end_name Character and Boolean */
+/** @} */ /* end_addtogroup apr_core_data_types */
+
+#endif /* _MMDEFS_H */