Merge "[Feature][ZXW-147][IRQ]add IRQ demo"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/LICENSE b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/LICENSE
new file mode 100755
index 0000000..88a1e9c
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("Mobiletek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to Mobiletek Inc. and/or its licensors. Without
+the prior written permission of Mobiletek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of Mobiletek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+Mobiletek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MOBILIETEK SOFTWARE")
+RECEIVED FROM MOBILIETEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MOBILIETEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MOBILIETEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MOBILIETEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MOBILIETEK
+SOFTWARE. MOBILIETEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MOBILIETEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MOBILIETEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MOBILIETEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MOBILIETEK'S OPTION, TO REVISE OR REPLACE THE
+MOBILIETEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MOBILIETEK FOR SUCH MOBILIETEK SOFTWARE AT ISSUE.
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/lynq-irq-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/lynq-irq-demo.cpp
new file mode 100755
index 0000000..537273e
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/lynq-irq-demo.cpp
@@ -0,0 +1,113 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <include/lynq-irq.h>
+
+
+
+static void irq_test_handler(void)
+{
+    printf("this is irq_test_handler\n");
+}
+
+
+int main(int argc, char** argv)
+{
+    int ret;
+    int irq;
+    int trig_type;
+    int en;
+
+    if(argc < 2)
+    {
+        printf("wrong input format, please -h \n");
+        return -1;
+    }
+
+    if(strcmp(argv[1],"-h") == 0)
+    {
+        printf("        -h                                        --help\n");
+        printf("        -t   [irq][trig_type]                    --lynq_irq_set_type\n");
+        printf("        -sw  [irq][en]                           --lynq_irq_set_wake\n");
+        printf("        -gw  [irq]                               --lynq_irq_get_wake\n");
+        return 0;
+    }
+
+    if(argv[2] == NULL)
+    {
+        printf("wrong input format, please -h \n");
+        return -1;
+    }
+
+    irq = atoi(argv[2]);
+    ret = lynq_irq_install(irq, irq_test_handler, 1);
+    if(ret != 0)
+    {
+        printf("lynq_irq_install fail\n");
+    }
+    else
+    {
+        printf("lynq_irq_install success\n");
+    }
+
+    if(strcmp(argv[1],"-t") == 0)
+    {
+        if(argv[3] != NULL)
+        {
+            trig_type = atoi(argv[3]);
+            ret = lynq_irq_set_type(irq, trig_type);
+            if(ret < 0)
+            {
+                printf("lynq_irq_set_type fail\n");
+            }
+            else
+            {
+                printf("lynq_irq_set_type success\n");
+            }
+        }
+    }
+    else if (strcmp(argv[1],"-sw") == 0)
+    {
+        if(argv[3] != NULL)
+        {
+            en = atoi(argv[3]);
+            ret = lynq_irq_set_wake(irq, en);
+            if(ret < 0)
+            {
+                printf("lynq_irq_set_wake fail\n");
+                printf("ret=%d\n", ret);
+            }
+            else
+            {
+                printf("lynq_irq_set_wake success\n");
+                printf("ret=%d\n", ret);
+            }
+        }
+    }
+    else if (strcmp(argv[1],"-gw") == 0)
+    {
+        ret = lynq_irq_get_wake(irq);
+        printf("lynq_irq_get_wake ret %d\n", ret);
+    }
+    else
+    {
+        printf("wrong input format, please -h \n");
+        return -1;
+    }
+
+    ret = lynq_irq_uninstall(irq);
+    if(ret != 0)
+    {
+        printf("lynq_irq_uninstall fail\n");
+    }
+    else
+    {
+        printf("lynq_irq_uninstall success\n");
+    }
+        
+    return 0;
+
+}
+
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/makefile b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/makefile
new file mode 100755
index 0000000..02f0f0c
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/makefile
@@ -0,0 +1,53 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -std=gnu++14 \
+                -g -Os \
+                -flto \
+                -fpermissive \
+
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0
+endif
+
+LOCAL_CFLAGS += -Werror=format-security
+
+$(warning ################# rock ROOT: $(ROOT),includedir:$(includedir),)
+
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH)/include/ \
+  -I$(ROOT)$(includedir)/ \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -lpthread \
+    -llynq-irq \
+
+
+
+SOURCES = lynq-irq-demo.cpp
+
+EXECUTABLE = lynq-irq-demo
+
+OBJECTS=$(SOURCES:.cpp=.o)
+
+all: $(EXECUTABLE) 
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
+	$(RM) $(OBJECTS_TOOL) $(EXECUTABLE)
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/lynq-irq-demo.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/lynq-irq-demo.bb
new file mode 100644
index 0000000..7d180f6
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/lynq-irq-demo.bb
@@ -0,0 +1,31 @@
+#inherit externalsrc package
+#inherit externalsrc package systemd
+DESCRIPTION = "lynq-girq-demo"
+LICENSE = "CLOSED"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=b1e07e8d88e26263e71d3a9e2aa9a2ff"
+SRC_URI = "file://lynq-irq-demo.cpp \
+           file://makefile \
+"
+DEPENDS += "liblynq-irq"
+
+SRC-DIR = "${S}/../lynq-irq-demo"
+FILES_${PN} += "${bindir}/"
+TARGET_CC_ARCH += "${LDFLAGS}"
+SYSTEMD_PACKAGES = "${PN}"
+S = "${WORKDIR}"
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+	if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+	else
+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+	fi
+}
+
+
+do_install() {
+
+	install -d ${D}${bindir}/
+	install -m 0755 ${S}/lynq-irq-demo ${D}${bindir}/
+}