Merge "agm: Enable standalone compilation using SDK"
diff --git a/plugins/tinyalsa/Makefile.am b/plugins/tinyalsa/Makefile.am
index 4f569b0..c82e5f2 100644
--- a/plugins/tinyalsa/Makefile.am
+++ b/plugins/tinyalsa/Makefile.am
@@ -6,11 +6,10 @@
 
 AM_CFLAGS := -Wno-unused-parameter
 if !BUILDSYSTEM_OPENWRT
-AM_CFLAGS += -I $(top_srcdir)/include -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/agm/
-AM_CFLAGS += $(GLIB_CFLAGS) -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat
+AM_CFLAGS += -I $(top_srcdir)/include @AGM_CFLAGS@
+AM_CFLAGS += @GLIB_CFLAGS@ -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat
 AM_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\) -DLINUX_ENABLED
-AM_CFLAGS += -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/sndparser/
-AM_CFLAGS += -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/
+AM_CFLAGS += @SNDPARSER_CFLAGS@
 AM_CFLAGS += -Wno-unused-parameter
 AM_CFLAGS += -DDYNAMIC_LOG_ENABLED
 
diff --git a/plugins/tinyalsa/configure.ac b/plugins/tinyalsa/configure.ac
index 17dd6e5..079242d 100644
--- a/plugins/tinyalsa/configure.ac
+++ b/plugins/tinyalsa/configure.ac
@@ -40,6 +40,13 @@
 
 AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
 
+# Checks for libraries
+PKG_CHECK_MODULES([AGM], [agm])
+AC_SUBST([AGM_CFLAGS])
+
+PKG_CHECK_MODULES([SNDPARSER], [sndparser])
+AC_SUBST([SNDPARSER_CFLAGS])
+
 AC_ARG_WITH([openwrt],
     AS_HELP_STRING([use openwrt (default is no)]),
     [with_openwrt=$withval],
diff --git a/plugins/tinyalsa/test/Makefile.am b/plugins/tinyalsa/test/Makefile.am
index 6055d92..0b22057 100644
--- a/plugins/tinyalsa/test/Makefile.am
+++ b/plugins/tinyalsa/test/Makefile.am
@@ -6,8 +6,8 @@
 if !BUILDSYSTEM_OPENWRT
 AM_CFLAGS += -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/
 endif
-AM_CFLAGS += $(GLIB_CFLAGS) -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat -include glib.h
-AM_CFLAGS += -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/acdbdata
+AM_CFLAGS += @GLIB_CFLAGS@ -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat -include glib.h
+AM_CFLAGS += @MMHEADERS_CFLAGS@
 
 AM_CFLAGS += -DBACKEND_CONF_FILE=\"/etc/backend_conf.xml\"
 
@@ -53,3 +53,8 @@
 
 agmvoiceui_la_CFLAGS := $(AM_CFLAGS)
 agmvoiceui_LDADD    := -lpthread -ltinyalsa libagmmixer.la
+# install xml files under /etc
+root_etcdir      = "/etc"
+root_etc_SCRIPTS = backend_conf.xml
+install-data-hook:
+	chmod  go-x $(DESTDIR)$(root_etcdir)/backend_conf.xml
diff --git a/plugins/tinyalsa/test/agmtest.pc.in b/plugins/tinyalsa/test/agmtest.pc.in
index c489de4..f7c36f8 100644
--- a/plugins/tinyalsa/test/agmtest.pc.in
+++ b/plugins/tinyalsa/test/agmtest.pc.in
@@ -7,4 +7,4 @@
 Description: agm test tool
 Version: @VERSION@
 Libs: -L${libdir}
-Cflags: -I${includedir}
+Cflags: -I${includedir}/agmtest
diff --git a/plugins/tinyalsa/test/configure.ac b/plugins/tinyalsa/test/configure.ac
index 8b1e241..058e8ad 100644
--- a/plugins/tinyalsa/test/configure.ac
+++ b/plugins/tinyalsa/test/configure.ac
@@ -39,6 +39,10 @@
 
 AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
 
+# Checks for libraries
+PKG_CHECK_MODULES([MMHEADERS], [mm-audio-headers])
+AC_SUBST([MMHEADERS_CFLAGS])
+
 AC_ARG_WITH([openwrt],
     AS_HELP_STRING([use openwrt (default is no)]),
     [with_openwrt=$withval],
diff --git a/service/Makefile.am b/service/Makefile.am
index fffecd1..1e7458a 100644
--- a/service/Makefile.am
+++ b/service/Makefile.am
@@ -31,10 +31,10 @@
             ${top_srcdir}/inc/private/agm/session_obj.h \
             ${top_srcdir}/inc/private/agm/device.h
 
-AM_CFLAGS = -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/spf
+AM_CFLAGS = @SPF_CFLAGS@
 AM_CFLAGS += -I ${top_srcdir}/inc/public
 AM_CFLAGS += -I ${top_srcdir}/inc/private
-AM_CFLAGS += -I $(PKG_CONFIG_SYSROOT_DIR)/usr/include/acdbdata
+AM_CFLAGS += @MMHEADERS_CFLAGS@
 AM_CFLAGS += -DDYNAMIC_LOG_ENABLED
 
 library_include_HEADERS = $(h_sources)
@@ -64,5 +64,5 @@
 libagm_la_LIBADD += -lglib-2.0
 endif
 libagm_la_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\)
-libagm_la_CFLAGS += $(GLIB_CFLAGS) -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat -include glib.h
+libagm_la_CFLAGS += @GLIB_CFLAGS@ -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat -include glib.h
 libagm_la_LDFLAGS = -module -shared -avoid-version
diff --git a/service/agm.pc.in b/service/agm.pc.in
index fa42c75..eeded6d 100644
--- a/service/agm.pc.in
+++ b/service/agm.pc.in
@@ -6,3 +6,5 @@
 Name: agm
 Description: agm library
 Version: @VERSION@
+Libs: -L${libdir}
+Cflags: -I${includedir}/agm
diff --git a/service/configure.ac b/service/configure.ac
index 4434dc6..921f025 100644
--- a/service/configure.ac
+++ b/service/configure.ac
@@ -39,6 +39,13 @@
 
 AM_CONDITIONAL(USE_GLIB, test "x${with_glib}" = "xyes")
 
+# Checks for libraries
+PKG_CHECK_MODULES([SPF], [spf])
+AC_SUBST([SPF_CFLAGS])
+
+PKG_CHECK_MODULES([MMHEADERS], [mm-audio-headers])
+AC_SUBST([MMHEADERS_CFLAGS])
+
 AC_ARG_WITH([openwrt],
     AS_HELP_STRING([use openwrt (default is no)]),
     [with_openwrt=$withval],
diff --git a/snd_parser/Makefile.am b/snd_parser/Makefile.am
index f9d9bb2..da05f67 100644
--- a/snd_parser/Makefile.am
+++ b/snd_parser/Makefile.am
@@ -19,7 +19,13 @@
 
 lib_LTLIBRARIES      = libsndcardparser.la
 libsndcardparser_la_SOURCES   = src/snd-card-parser.c
-libsndcardparser_la_LIBADD = $(GLIB_LIBS) -lexpat -lpthread
+libsndcardparser_la_LIBADD = @GLIB_LIBS@ -lexpat -lpthread
 libsndcardparser_la_CFLAGS := $(AM_CFLAGS)
-libsndcardparser_la_CFLAGS += $(GLIB_CFLAGS) -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat -include glib.h
+libsndcardparser_la_CFLAGS += @GLIB_CFLAGS@ -Dstrlcpy=g_strlcpy -Dstrlcat=g_strlcat -include glib.h
 libsndcardparser_la_LDFLAGS   = -avoid-version -shared
+libsndcardparser_la_list   = $(top_srcdir)/configs/$(MACHINE_ENABLED)/card-defs.xml
+#install xml files under /etc
+root_etcdir = "/etc"
+root_etc_SCRIPTS = $(libsndcardparser_la_list)
+install-data-hook:
+	chmod  go+r $(DESTDIR)$(root_etcdir)/card-defs.xml
diff --git a/snd_parser/configs/neo/card-defs.xml b/snd_parser/configs/neo/card-defs.xml
new file mode 100644
index 0000000..d59e669
--- /dev/null
+++ b/snd_parser/configs/neo/card-defs.xml
@@ -0,0 +1,104 @@
+<!--  Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.     -->
+<!--                                                                          -->
+<!--  Redistribution and use in source and binary forms, with or without      -->
+<!--  modification, are permitted provided that the following conditions are  -->
+<!--  met:                                                                    -->
+<!--      * Redistributions of source code must retain the above copyright    -->
+<!--        notice, this list of conditions and the following disclaimer.     -->
+<!--      * Redistributions in binary form must reproduce the above           -->
+<!--        copyright notice, this list of conditions and the following       -->
+<!--        disclaimer in the documentation and/or other materials provided   -->
+<!--        with the distribution.                                            -->
+<!--      * Neither the name of The Linux Foundation nor the names of its     -->
+<!--        contributors may be used to endorse or promote products derived   -->
+<!--        from this software without specific prior written permission.     -->
+<!--                                                                          -->
+<!--  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED            -->
+<!--  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF    -->
+<!--  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT  -->
+<!--  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS  -->
+<!--  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  -->
+<!--  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF    -->
+<!--  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR         -->
+<!--  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,   -->
+<!--  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE    -->
+<!--  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN  -->
+<!--  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           -->
+<defs>
+<card>
+    <id>0</id>
+    <name>auroravirtualsndcard</name>
+
+    <pcm-device>
+        <id>100</id>
+        <name>PCM100</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_passthrough_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>1</playback>
+            <capture>0</capture>
+        </props>
+    </pcm-device>
+
+    <pcm-device>
+        <id>101</id>
+        <name>PCM101</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_passthrough_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>0</playback>
+            <capture>1</capture>
+        </props>
+    </pcm-device>
+
+    <pcm-device>
+        <id>103</id>
+        <name>PCM103</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_passthrough_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>1</playback>
+            <capture>0</capture>
+            <hostless>1</hostless>
+        </props>
+    </pcm-device>
+
+    <pcm-device>
+        <id>104</id>
+        <name>PCM104</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_passthrough_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>0</playback>
+            <capture>1</capture>
+            <hostless>1</hostless>
+        </props>
+    </pcm-device>
+
+    <compress-device>
+        <id>105</id>
+        <name>COMPRESS105</name>
+        <compress_plugin>
+            <so-name>libagm_compress_passthrough_plugin.so</so-name>
+        </compress_plugin>
+        <props>
+            <playback>1</playback>
+            <capture>0</capture>
+            <hostless>0</hostless>
+        </props>
+    </compress-device>
+
+    <mixer>
+        <id>1</id>
+        <name>agm_mixer</name>
+        <mixer_plugin>
+            <so-name>libagm_mixer_passthrough_plugin.so</so-name>
+        </mixer_plugin>
+    </mixer>
+
+</card>
+</defs>
diff --git a/snd_parser/configs/qcs40x/card-defs.xml b/snd_parser/configs/qcs40x/card-defs.xml
new file mode 100644
index 0000000..7002713
--- /dev/null
+++ b/snd_parser/configs/qcs40x/card-defs.xml
@@ -0,0 +1,104 @@
+<!--  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.                           -->
+<defs>
+<card>
+    <id>100</id>
+    <name>qcs405wsasndcard</name>
+
+    <pcm-device>
+        <id>100</id>
+        <name>PCM100</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>1</playback>
+            <capture>0</capture>
+        </props>
+    </pcm-device>
+
+    <pcm-device>
+        <id>101</id>
+        <name>PCM101</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>0</playback>
+            <capture>1</capture>
+        </props>
+    </pcm-device>
+
+    <pcm-device>
+        <id>103</id>
+        <name>PCM103</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>1</playback>
+            <capture>0</capture>
+            <hostless>1</hostless>
+        </props>
+    </pcm-device>
+
+    <pcm-device>
+        <id>104</id>
+        <name>PCM104</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>0</playback>
+            <capture>1</capture>
+            <hostless>1</hostless>
+        </props>
+    </pcm-device>
+
+    <compress-device>
+        <id>105</id>
+        <name>COMPRESS105</name>
+        <compress_plugin>
+            <so-name>libagm_compress_plugin.so</so-name>
+        </compress_plugin>
+        <props>
+            <playback>1</playback>
+            <capture>0</capture>
+            <hostless>0</hostless>
+        </props>
+    </compress-device>
+
+    <mixer>
+        <id>1</id>
+        <name>agm_mixer</name>
+        <mixer_plugin>
+            <so-name>libagm_mixer_plugin.so</so-name>
+        </mixer_plugin>
+    </mixer>
+
+</card>
+</defs>
diff --git a/snd_parser/configs/sxr2130/card-defs.xml b/snd_parser/configs/sxr2130/card-defs.xml
new file mode 100644
index 0000000..f4ab036
--- /dev/null
+++ b/snd_parser/configs/sxr2130/card-defs.xml
@@ -0,0 +1,104 @@
+<!--  Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.     -->
+<!--                                                                          -->
+<!--  Redistribution and use in source and binary forms, with or without      -->
+<!--  modification, are permitted provided that the following conditions are  -->
+<!--  met:                                                                    -->
+<!--      * Redistributions of source code must retain the above copyright    -->
+<!--        notice, this list of conditions and the following disclaimer.     -->
+<!--      * Redistributions in binary form must reproduce the above           -->
+<!--        copyright notice, this list of conditions and the following       -->
+<!--        disclaimer in the documentation and/or other materials provided   -->
+<!--        with the distribution.                                            -->
+<!--      * Neither the name of The Linux Foundation nor the names of its     -->
+<!--        contributors may be used to endorse or promote products derived   -->
+<!--        from this software without specific prior written permission.     -->
+<!--                                                                          -->
+<!--  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED            -->
+<!--  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF    -->
+<!--  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT  -->
+<!--  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS  -->
+<!--  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  -->
+<!--  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF    -->
+<!--  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR         -->
+<!--  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,   -->
+<!--  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE    -->
+<!--  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN  -->
+<!--  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           -->
+<defs>
+<card>
+    <id>0</id>
+    <name>konamtpsndcard</name>
+
+    <pcm-device>
+        <id>100</id>
+        <name>PCM100</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>1</playback>
+            <capture>0</capture>
+        </props>
+    </pcm-device>
+
+    <pcm-device>
+        <id>101</id>
+        <name>PCM101</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>0</playback>
+            <capture>1</capture>
+        </props>
+    </pcm-device>
+
+    <pcm-device>
+        <id>103</id>
+        <name>PCM103</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>1</playback>
+            <capture>0</capture>
+            <hostless>1</hostless>
+        </props>
+    </pcm-device>
+
+    <pcm-device>
+        <id>104</id>
+        <name>PCM104</name>
+        <pcm_plugin>
+            <so-name>libagm_pcm_plugin.so</so-name>
+        </pcm_plugin>
+        <props>
+            <playback>0</playback>
+            <capture>1</capture>
+            <hostless>1</hostless>
+        </props>
+    </pcm-device>
+
+    <compress-device>
+        <id>105</id>
+        <name>COMPRESS105</name>
+        <compress_plugin>
+            <so-name>libagm_compress_plugin.so</so-name>
+        </compress_plugin>
+        <props>
+            <playback>1</playback>
+            <capture>0</capture>
+            <hostless>0</hostless>
+        </props>
+    </compress-device>
+
+    <mixer>
+        <id>1</id>
+        <name>agm_mixer</name>
+        <mixer_plugin>
+            <so-name>libagm_mixer_plugin.so</so-name>
+        </mixer_plugin>
+    </mixer>
+
+</card>
+</defs>
diff --git a/snd_parser/configure.ac b/snd_parser/configure.ac
index 8c4196d..5314aea 100644
--- a/snd_parser/configure.ac
+++ b/snd_parser/configure.ac
@@ -17,6 +17,17 @@
 # defines some macros variable to be included by source
 AC_CONFIG_MACRO_DIR([m4])
 
+#basemachine
+AC_MSG_CHECKING([which base machine to use])
+AC_ARG_WITH([basemachine],
+            [AS_HELP_STRING([--with-basemachine],
+            [Specify the base machine])],
+            [machine_selected="$withval"],
+            [machine_selected=none])
+
+AC_MSG_RESULT([$machine_selected])
+AC_SUBST([MACHINE_ENABLED],[$machine_selected])
+
 # Checks for programs.
 AC_PROG_CC
 AM_PROG_CC_C_O
diff --git a/snd_parser/sndparser.pc.in b/snd_parser/sndparser.pc.in
index 7e0d6fa..7f9277d 100644
--- a/snd_parser/sndparser.pc.in
+++ b/snd_parser/sndparser.pc.in
@@ -7,4 +7,4 @@
 Description: sndparser library
 Version: @VERSION@
 Libs: -L${libdir}
-Cflags: -I${includedir}
+Cflags: -I${includedir}/sndparser