merge 'libhaptic' into system-server 02/14302/2
authorjy910.yun <jy910.yun@samsung.com>
Fri, 21 Jun 2013 07:21:47 +0000 (16:21 +0900)
committerKrzysztof Sasiak <k.sasiak@samsung.com>
Tue, 7 Jan 2014 11:06:15 +0000 (12:06 +0100)
all of the haptic code was simply copied to system-server

Change-Id: Icc3420de80662d135bd9d8d1fdcdc8195a2b80e9
Signed-off-by: Krzysztof Sasiak <k.sasiak@samsung.com>
37 files changed:
CMakeLists.txt
haptic/CMakeLists.txt [new file with mode: 0644]
haptic/TC/build.sh [new file with mode: 0755]
haptic/TC/execute.sh [new file with mode: 0755]
haptic/TC/tet_code [new file with mode: 0644]
haptic/TC/tet_scen [new file with mode: 0644]
haptic/TC/tetbuild.cfg [new file with mode: 0644]
haptic/TC/tetclean.cfg [new file with mode: 0644]
haptic/TC/tetexec.cfg [new file with mode: 0644]
haptic/TC/unit/Makefile [new file with mode: 0644]
haptic/TC/unit/tc_gen.sh [new file with mode: 0755]
haptic/TC/unit/tslist [new file with mode: 0644]
haptic/TC/unit/utc_MODULE_API_func.c.in [new file with mode: 0644]
haptic/TC/unit/utc_SystemFW_haptic_close_func.c [new file with mode: 0644]
haptic/TC/unit/utc_SystemFW_haptic_get_file_duration_func.c [new file with mode: 0644]
haptic/TC/unit/utc_SystemFW_haptic_open_func.c [new file with mode: 0644]
haptic/TC/unit/utc_SystemFW_haptic_play_file_func.c [new file with mode: 0644]
haptic/TC/unit/utc_SystemFW_haptic_play_monotone_func.c [new file with mode: 0644]
haptic/TC/unit/utc_SystemFW_haptic_stop_play_func.c [new file with mode: 0644]
haptic/haptic-plugin.pc.in [new file with mode: 0644]
haptic/haptic.pc.in [new file with mode: 0644]
haptic/haptic_PG.h [new file with mode: 0644]
haptic/image/devman_PG_haptic_architecture.png [new file with mode: 0644]
haptic/include/haptic.h [new file with mode: 0644]
haptic/include/haptic_log.h [new file with mode: 0644]
haptic/include/haptic_module.h [new file with mode: 0644]
haptic/include/haptic_plugin_intf.h [new file with mode: 0644]
haptic/src/device_convert.c [new file with mode: 0644]
haptic/src/haptic.c [new file with mode: 0644]
libslp-pm/CMakeLists.txt
libslp-pm/image/pm_PG_architecture.png [moved from libslp-pm/image/SLP_pm_PG_architecture.png with 100% similarity]
libslp-pm/image/pm_PG_state_diagram.png [moved from libslp-pm/image/SLP_pm_PG_state_diagram.png with 100% similarity]
libslp-pm/pm_PG.h [moved from libslp-pm/SLP_pm_PG.h with 98% similarity]
packaging/haptic.manifest [new file with mode: 0644]
packaging/system-server.spec
sysman/CMakeLists.txt
sysman/sysman_PG.h [moved from sysman/SLP_sysman_PG.h with 100% similarity]

index 90f3192..68a0a25 100755 (executable)
@@ -139,3 +139,4 @@ ADD_SUBDIRECTORY(pm_event)
 ADD_SUBDIRECTORY(sys_pci_noti)
 ADD_SUBDIRECTORY(sysman)
 ADD_SUBDIRECTORY(libslp-pm)
+ADD_SUBDIRECTORY(haptic)
diff --git a/haptic/CMakeLists.txt b/haptic/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b409586
--- /dev/null
@@ -0,0 +1,52 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(haptic C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
+SET(VERSION 0.1)
+
+SET(SRCS
+       src/haptic.c)
+
+SET(HEADERS
+       haptic_PG.h
+       include/haptic.h
+       include/haptic_module.h
+       include/haptic_plugin_intf.h)
+
+SET(DEPENDENTS "dlog vconf")
+SET(PC_DEPENDENTS "capi-base-common")
+
+SET(PC_NAME ${PROJECT_NAME})
+SET(PC_REQUIRED ${PC_DEPENDENTS})
+SET(PC_LDFLAGS -l${PROJECT_NAME})
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED ${DEPENDENTS})
+
+FOREACH(flag ${pkgs_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-ldl")
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION})
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+CONFIGURE_FILE(${PROJECT_NAME}-plugin.pc.in ${PROJECT_NAME}-plugin.pc @ONLY)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-plugin.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+FOREACH(hfile ${HEADERS})
+       INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME})
+ENDFOREACH(hfile)
diff --git a/haptic/TC/build.sh b/haptic/TC/build.sh
new file mode 100755 (executable)
index 0000000..98ebeff
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export TET_INSTALL_PATH=/scratchbox/tetware  # local tetware path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/haptic/TC/execute.sh b/haptic/TC/execute.sh
new file mode 100755 (executable)
index 0000000..6720da0
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+export TET_INSTALL_PATH=/mnt/nfs/tetware
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/haptic/TC/tet_code b/haptic/TC/tet_code
new file mode 100644 (file)
index 0000000..a2cf6c1
--- /dev/null
@@ -0,0 +1,12 @@
+# TET reserved codes
+0 "PASS"
+1 "FAIL"
+2 "UNRESOLVED"
+3 "NOTINUSE"
+4 "UNSUPPORTED"
+5 "UNTESTED"
+6 "UNINITIATED"
+7 "NORESULT"
+
+# Test suite additional codes
+33 "INSPECT"
diff --git a/haptic/TC/tet_scen b/haptic/TC/tet_scen
new file mode 100644 (file)
index 0000000..43cbc9b
--- /dev/null
@@ -0,0 +1,7 @@
+all
+       ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+       :include:/unit/tslist
diff --git a/haptic/TC/tetbuild.cfg b/haptic/TC/tetbuild.cfg
new file mode 100644 (file)
index 0000000..6192c78
--- /dev/null
@@ -0,0 +1,3 @@
+TET_OUTPUT_CAPTURE=False
+TET_BUILD_TOOL=make
+TET_PASS_TC_NAME=True
diff --git a/haptic/TC/tetclean.cfg b/haptic/TC/tetclean.cfg
new file mode 100644 (file)
index 0000000..c66eda4
--- /dev/null
@@ -0,0 +1,2 @@
+TET_OUTPUT_CAPTURE=False
+TET_CLEAN_TOOL=make clean
diff --git a/haptic/TC/tetexec.cfg b/haptic/TC/tetexec.cfg
new file mode 100644 (file)
index 0000000..0d9d39a
--- /dev/null
@@ -0,0 +1 @@
+TET_OUTPUT_CAPTURE=False
diff --git a/haptic/TC/unit/Makefile b/haptic/TC/unit/Makefile
new file mode 100644 (file)
index 0000000..c4e7497
--- /dev/null
@@ -0,0 +1,28 @@
+CC ?= gcc
+
+TARGETS = utc_SystemFW_haptic_open_func                \
+         utc_SystemFW_haptic_close_func                \
+         utc_SystemFW_haptic_play_monotone_func                \
+         utc_SystemFW_haptic_play_file_func            \
+         utc_SystemFW_haptic_stop_play_func            \
+         utc_SystemFW_haptic_get_file_duration_func    \
+
+
+PKGS = haptic
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+all: $(TARGETS)
+
+$(TARGETS): %: %.c
+       $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+       rm -f $(TARGETS)
diff --git a/haptic/TC/unit/tc_gen.sh b/haptic/TC/unit/tc_gen.sh
new file mode 100755 (executable)
index 0000000..54f482d
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+TMPSTR=$0
+SCRIPT=${TMPSTR##*/}
+
+if [ $# -lt 2 ]; then
+       echo "Usage) $SCRIPT module_name api_name"
+       exit 1
+fi
+
+MODULE=$1
+API=$2
+TEMPLATE=utc_MODULE_API_func.c.in
+TESTCASE=utc_${MODULE}_${API}_func
+
+sed -e '
+       s^@API@^'"$API"'^g
+       s^@MODULE@^'"$MODULE"'^g
+       ' $TEMPLATE > $TESTCASE.c
+
+if [ ! -e "$TESTCASE.c" ]; then
+       echo "Failed"
+       exit 1
+fi
+echo "Testcase file is $TESTCASE.c"
+echo "Done"
+echo "please put \"$TESTCASE\" as Target in Makefile"
+echo "please put \"/unit/$TESTCASE\" in tslist"
diff --git a/haptic/TC/unit/tslist b/haptic/TC/unit/tslist
new file mode 100644 (file)
index 0000000..2772296
--- /dev/null
@@ -0,0 +1,6 @@
+/unit/utc_SystemFW_haptic_open_func
+/unit/utc_SystemFW_haptic_close_func
+/unit/utc_SystemFW_haptic_play_monotone_func
+/unit/utc_SystemFW_haptic_play_file_func
+/unit/utc_SystemFW_haptic_stop_play_func
+/unit/utc_SystemFW_haptic_get_file_duration_func
diff --git a/haptic/TC/unit/utc_MODULE_API_func.c.in b/haptic/TC/unit/utc_MODULE_API_func.c.in
new file mode 100644 (file)
index 0000000..b235fa3
--- /dev/null
@@ -0,0 +1,64 @@
+#include <tet_api.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_@MODULE@_@API@_func_01(void);
+static void utc_@MODULE@_@API@_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_@MODULE@_@API@_func_01, POSITIVE_TC_IDX },
+       { utc_@MODULE@_@API@_func_02, NEGATIVE_TC_IDX },
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of @API@()
+ */
+static void utc_@MODULE@_@API@_func_01(void)
+{
+       int r = 0;
+
+/*
+       r = @API@(...);
+*/
+       if (r) {
+               tet_infoline("@API@() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init @API@()
+ */
+static void utc_@MODULE@_@API@_func_02(void)
+{
+       int r = 0;
+
+/*
+       r = @API@(...);
+*/
+       if (r) {
+               tet_infoline("@API@() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/haptic/TC/unit/utc_SystemFW_haptic_close_func.c b/haptic/TC/unit/utc_SystemFW_haptic_close_func.c
new file mode 100644 (file)
index 0000000..6f2e243
--- /dev/null
@@ -0,0 +1,78 @@
+#include <tet_api.h>
+#include <devman.h>
+#include <devman_haptic.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_SystemFW_device_haptic_close_func_01(void);
+static void utc_SystemFW_device_haptic_close_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_SystemFW_device_haptic_close_func_01, POSITIVE_TC_IDX },
+       { utc_SystemFW_device_haptic_close_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of device_haptic_close()
+ */
+static void utc_SystemFW_device_haptic_close_func_01(void)
+{
+       int r = 0;
+       unsigned int mode =0;
+       haptic_dev_idx dev_idx = DEV_IDX_0;
+       int dev_handle;
+
+       dev_handle = device_haptic_open(dev_idx,mode);
+       if(dev_handle < 0)
+       {
+               tet_infoline("device_haptic_close() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       r = device_haptic_close(dev_handle);
+       if(r < 0)
+       {
+               tet_infoline("device_haptic_close() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init device_haptic_close()
+ */
+static void utc_SystemFW_device_haptic_close_func_02(void)
+{
+       int r = 0;
+       int invalid_handle = -1;
+
+       r = device_haptic_close(invalid_handle);
+
+       if (r >= 0) {
+               tet_infoline("device_haptic_close() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/haptic/TC/unit/utc_SystemFW_haptic_get_file_duration_func.c b/haptic/TC/unit/utc_SystemFW_haptic_get_file_duration_func.c
new file mode 100644 (file)
index 0000000..a9089b4
--- /dev/null
@@ -0,0 +1,84 @@
+#include <tet_api.h>
+#include <devman.h>
+#include <devman_haptic.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_SystemFW_device_haptic_get_file_duration_func_01(void);
+static void utc_SystemFW_device_haptic_get_file_duration_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_SystemFW_device_haptic_get_file_duration_func_01, POSITIVE_TC_IDX },
+       { utc_SystemFW_device_haptic_get_file_duration_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of device_haptic_get_file_duration()
+ */
+static void utc_SystemFW_device_haptic_get_file_duration_func_01(void)
+{
+       int duration = 0;
+       int ret_val = 0;
+       unsigned int mode =0;
+       char* haptic_file = "/usr/share/immersion/01_Touch/touch_20ms_sharp.ivt";
+       haptic_dev_idx dev_idx = DEV_IDX_0;
+       int dev_handle;
+
+       dev_handle = device_haptic_open(dev_idx,mode);
+       if(dev_handle < 0)
+       {
+               tet_infoline("device_haptic_get_file_duration() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       ret_val = device_haptic_get_file_duration(dev_handle, haptic_file,&duration);
+       if((ret_val < 0) || (duration<0))
+       {
+               tet_infoline("device_haptic_get_file_duration() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       device_haptic_close(dev_handle);
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init device_haptic_get_file_duration()
+ */
+static void utc_SystemFW_device_haptic_get_file_duration_func_02(void)
+{
+       int duration = 0;
+       int invalid_handle = -1;
+       int ret_val = 0;
+       char* haptic_file = "test.ivt";
+
+       //Get duration from attern file 
+       ret_val = device_haptic_get_file_duration(invalid_handle, haptic_file, &duration);
+       if(ret_val >= 0)
+       {
+               tet_infoline("device_haptic_get_file_duration() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/haptic/TC/unit/utc_SystemFW_haptic_open_func.c b/haptic/TC/unit/utc_SystemFW_haptic_open_func.c
new file mode 100644 (file)
index 0000000..c8776b1
--- /dev/null
@@ -0,0 +1,71 @@
+#include <tet_api.h>
+#include <devman.h>
+#include <devman_haptic.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_SystemFW_device_haptic_open_func_01(void);
+static void utc_SystemFW_device_haptic_open_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_SystemFW_device_haptic_open_func_01, POSITIVE_TC_IDX },
+       { utc_SystemFW_device_haptic_open_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of device_haptic_open()
+ */
+static void utc_SystemFW_device_haptic_open_func_01(void)
+{
+       int r = 0;
+       unsigned int mode =0;
+       haptic_dev_idx dev_idx = DEV_IDX_0;
+
+       r = device_haptic_open(dev_idx,mode);
+       
+       if (r < 0) {
+               tet_infoline("device_haptic_open() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+       device_haptic_close(r);
+}
+
+/**
+ * @brief Negative test case of ug_init device_haptic_open()
+ */
+static void utc_SystemFW_device_haptic_open_func_02(void)
+{
+       int r = 0;
+       unsigned int mode =0;
+       haptic_dev_idx dev_idx = 1000;
+       
+       r = device_haptic_open(dev_idx,mode);
+       
+       if (r >= 0) {
+               tet_infoline("device_haptic_open() failed in negative test case");
+               tet_result(TET_FAIL);
+               device_haptic_close(r);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/haptic/TC/unit/utc_SystemFW_haptic_play_file_func.c b/haptic/TC/unit/utc_SystemFW_haptic_play_file_func.c
new file mode 100644 (file)
index 0000000..52f5659
--- /dev/null
@@ -0,0 +1,82 @@
+#include <tet_api.h>
+#include <devman.h>
+#include <devman_haptic.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_SystemFW_device_haptic_play_file_func_01(void);
+static void utc_SystemFW_device_haptic_play_file_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_SystemFW_device_haptic_play_file_func_01, POSITIVE_TC_IDX },
+       { utc_SystemFW_device_haptic_play_file_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of device_haptic_play_file()
+ */
+static void utc_SystemFW_device_haptic_play_file_func_01(void)
+{
+       int ret_val = 0;
+       haptic_dev_idx dev_idx = DEV_IDX_0;
+       unsigned int mode =0;
+       char* haptic_file = "/usr/share/immersion/01_Touch/touch_20ms_sharp.ivt";
+       int dev_handle;
+
+       dev_handle = device_haptic_open(dev_idx,mode);
+       if(dev_handle < 0)
+       {
+               tet_infoline("device_haptic_play_file() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       ret_val = device_haptic_play_file(dev_handle, haptic_file, 1, 1);
+       if(ret_val < 0)
+       {
+               tet_infoline("device_haptic_play_file() failed in positive test case");
+               tet_result(TET_FAIL);
+               device_haptic_close(dev_handle);
+               return;
+       }
+
+       device_haptic_close(dev_handle);
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init device_haptic_play_file()
+ */
+static void utc_SystemFW_device_haptic_play_file_func_02(void)
+{
+       int ret_val = 0;
+       int invalid_handle = -1;
+       char* haptic_file = "/usr/share/immersion/01_Touch/touch_20ms_sharp.ivt";
+
+       ret_val = device_haptic_play_file(invalid_handle, haptic_file, 1, 1);
+       if(ret_val >= 0)
+       {
+               tet_infoline("device_haptic_play_file() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/haptic/TC/unit/utc_SystemFW_haptic_play_monotone_func.c b/haptic/TC/unit/utc_SystemFW_haptic_play_monotone_func.c
new file mode 100644 (file)
index 0000000..ded5a33
--- /dev/null
@@ -0,0 +1,79 @@
+#include <tet_api.h>
+#include <devman.h>
+#include <devman_haptic.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_SystemFW_device_haptic_play_monotone_func_01(void);
+static void utc_SystemFW_device_haptic_play_monotone_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_SystemFW_device_haptic_play_monotone_func_01, POSITIVE_TC_IDX },
+       { utc_SystemFW_device_haptic_play_monotone_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of device_haptic_play_monotone()
+ */
+static void utc_SystemFW_device_haptic_play_monotone_func_01(void)
+{
+       int ret_val = 0;
+       haptic_dev_idx dev_idx = DEV_IDX_0;
+       unsigned int mode =0;
+       int dev_handle;
+
+       dev_handle = device_haptic_open(dev_idx,mode);
+       if(dev_handle < 0)
+       {
+               tet_infoline("device_haptic_play_monotone() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       ret_val = device_haptic_play_monotone(dev_handle ,1); 
+       if(ret_val < 0)
+       {
+               tet_infoline("device_haptic_play_monotone() failed in positive test case");
+               tet_result(TET_FAIL);
+               device_haptic_close(dev_handle);
+               return;
+       }
+
+       device_haptic_close(dev_handle);
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init device_haptic_play_monotone()
+ */
+static void utc_SystemFW_device_haptic_play_monotone_func_02(void)
+{
+       int ret_val = 0;
+       int invalid_handle = -1;
+
+       ret_val = device_haptic_play_monotone(invalid_handle ,1);
+       if(ret_val >= 0) {
+               tet_infoline("device_haptic_play_monotone() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/haptic/TC/unit/utc_SystemFW_haptic_stop_play_func.c b/haptic/TC/unit/utc_SystemFW_haptic_stop_play_func.c
new file mode 100644 (file)
index 0000000..aef795c
--- /dev/null
@@ -0,0 +1,101 @@
+#include <tet_api.h>
+#include <devman.h>
+#include <devman_haptic.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_SystemFW_device_haptic_stop_play_func_01(void);
+static void utc_SystemFW_device_haptic_stop_play_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_SystemFW_device_haptic_stop_play_func_01, POSITIVE_TC_IDX },
+       { utc_SystemFW_device_haptic_stop_play_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 },
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of device_haptic_stop_play()
+ */
+static void utc_SystemFW_device_haptic_stop_play_func_01(void)
+{
+       int ret_val = 0;
+       haptic_dev_idx dev_idx = DEV_IDX_0;
+       unsigned int mode =0;
+       int dev_handle = 0;
+
+       dev_handle = device_haptic_open(dev_idx,mode);
+       if(dev_handle < 0)
+       {
+               tet_infoline("device_haptic_stop_play() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+
+       ret_val = device_haptic_play_monotone(dev_handle ,100);                    
+       if(ret_val < 0)
+       {
+               tet_infoline("device_haptic_stop_play() failed in positive test case");
+               tet_result(TET_FAIL);
+               device_haptic_close(dev_handle);
+               return;
+       }
+
+        ret_val = device_haptic_stop_play(dev_handle);
+        if(ret_val < 0)
+        {
+                tet_infoline("device_haptic_stop_play() failed in positive test case");
+                tet_result(TET_FAIL);
+                device_haptic_close(dev_handle);
+                return;
+        }
+                                        
+
+       device_haptic_close(dev_handle);
+       tet_result(TET_PASS);
+       int r = 0;
+
+/*
+       r = device_haptic_stop_play(...);
+*/
+       if (r) {
+               tet_infoline("device_haptic_stop_play() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init device_haptic_stop_play()
+ */
+static void utc_SystemFW_device_haptic_stop_play_func_02(void)
+{
+       int r = 0;
+
+
+       r = device_haptic_stop_play(-1);
+
+       if (r>=0) {
+               tet_infoline("device_haptic_stop_play() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/haptic/haptic-plugin.pc.in b/haptic/haptic-plugin.pc.in
new file mode 100644 (file)
index 0000000..e90fc89
--- /dev/null
@@ -0,0 +1,13 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDEDIR@
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires:
+Cflags: -I${includedir}
diff --git a/haptic/haptic.pc.in b/haptic/haptic.pc.in
new file mode 100644 (file)
index 0000000..477601d
--- /dev/null
@@ -0,0 +1,14 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIB_INSTALL_DIR@
+includedir=@INCLUDEDIR@
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
diff --git a/haptic/haptic_PG.h b/haptic/haptic_PG.h
new file mode 100644 (file)
index 0000000..08a1e86
--- /dev/null
@@ -0,0 +1,247 @@
+/*
+ *  haptic
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: DongGi Jang <dg0402.jang@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+
+/**
+ *
+ * @ingroup SLP_PG
+ * @defgroup SLP_HAPTIC_PG Haptic Library
+ * @{
+
+<h1 class="pg">Introduction</h1>
+
+<h2 class="pg">Purpose</h2>
+The purpose of this document is to describe how applications can use Haptic Library APIs. This document gives programming guidelines to application engineers.
+
+<h2 class="pg">Scope</h2>
+The scope of this document is limited to Haptic Library API usage.
+
+<br>
+<h1 class="pg">Device Manager Library Overview</h1>
+<h2 class="pg">Haptic Device Manager</h2>
+<h3 class="pg" align="center">Haptic Vibration Functional Level Architecture</h3>
+@image html devman_PG_haptic_architecture.png
+
+The client side is available in the form of a shared library to all the processes, whereas the server is a daemon.
+As shown in the diagram applications/middleware frameworks can have the haptic vibration client library in the process context.
+<br><br>
+The haptic vibration client is available in form of a shared library. This library has APIs which support various features.
+These features are playing a rhythmical vibration pattern, playing a monotonous vibration pattern, etc.
+Applications can call these APIs to give vibration feedback on any event. This could also be used to indicate any events or changes of a state to the user.
+<br><br>
+The server interacts with the device driver interfaces and generates vibration feedback.
+<br><br>
+<h3 class="pg">Haptic Vibration Features</h3>
+<b>Haptic client features</b>
+-#     Available in shared library form.<br>
+-#     Provides set of APIs to play haptic vibration patterns.<br>
+-#     Provide unique access control mechanism through client server architecture.<br>
+-#     Provision to play rhythmical vibration patterns.<br>
+-#     Provides functionality for application to play a different vibration pattern for a different event.<br>
+-#     Provides support for user defined duration for monotone playing or iteration for pattern playing.<br>
+-#     Provides immediate stop control over the vibrations played.<br><br>
+
+<b>Haptic server features</b>
+-#     The actual implementation of the functionality supported by haptic-vibration library has been implemented through haptic-server.<br>
+-#     Haptic-server processes the vibration pattern's play/stop requests sent by application through the haptic client library.<br>
+-#     There is an internal database maintained for different patterns and their specification.<br>
+-#     When application requests a particular pattern, haptic server checks this database for the specification of that pattern.<br>
+-#     After getting data from database, server sends these specific details to device driver which plays the pattern.<br>
+-#     Server can maintain multiple requests at a time on a priority basis.<br><br>
+
+<h1 class="pg">Device Manager Funtions</h1>
+<h2 class="pg">Haptic Device Manager APIs</h2>
+<i><b>API : device_haptic_open</b></i>
+<br><b>Parameter In :</b> haptic_dev_idx dev_idx , unsigned int mode
+<br><b>Return :</b> int
+<br><b>Functionality :</b> This API opens a Haptic-vibration device. On success it returns a dev_handle value.
+In case of failure it returns a negative value. If the device is already open it returns (-1). <br>
+The first in parameter dev_idx should be from a predefined haptic-device-index which is available in the typedef enum haptic_dev_idx.
+The DEV_IDX_0 means first haptic-device-index of target , the DEV_IDX_1 means second haptic-device-index of target and the DEV_IDX_ALL means both of them.
+The availability of the dev_idx value is dependent on the real target. Normally, set a DEV_IDX_0 value to the first haptic-device.<br>
+The second in parameter mode is reserved for future so just set a 0 value<br>
+<b>Note:</b> The device_haptic_open() must be called before all other haptic APIs are called.
+The device_haptic_open() should have a matching call to device_haptic_close().
+Applications call the device_haptic_open() only once if possible during application startup and call the device_haptic_close() during application shutdown.
+
+<b>Enumerate values:</b>
+@code
+//Haptic_dev_idx ;
+typedef enum haptic_dev_idx_t {
+       DEV_IDX_0               =       0x01,
+       DEV_IDX_1               =       0x02,
+       DEV_IDX_ALL            =        0x04,
+};
+@endcode
+
+<i><b>API : device_haptic_close</b></i>
+<br><b>Parameter In :</b> int dev_handle
+<br><b>Parameter Return :</b> int
+<br><b>Functionality :</b> This API closes a Haptic-vibration device. On success it returns a zero value.
+In case of failure it returns a negative value. If the device is already closed it returns (-1).  <br>
+The first in parameter dev_handle should be from the return value of device_haptic_open().
+<br><br>
+<i><b>API : device_haptic_play_pattern</b></i>
+<br><b>Parameter In :</b> int dev_handle , int pattern , int iteration , int feedback_level
+<br><b>Parameter Return :</b> int
+<br><b>Functionality :</b> This API plays a predefined rhythmic haptic-vibration pattern. <br>
+The first in parameter dev_handle should be from the return value of device_haptic_open().<br>
+The second in parameter pattern should be from a predefined pattern list which is available in an enumeration (effectvibe_pattern_list).
+These patterns are rhythmic vibration patterns. <br>
+The third in parameter iteration sets the number of iterations to be played. This should be less than the maximum iteration range set for the device (currently its 255).  <br>
+The fourth in parameter is the vibration feedback intensity level. This level is already predefined by enumeration type value from HAPTIC _FEEDBACK_LEVEL_1
+to HAPTIC _FEEDBACK_LEVEL_5. If you want to use the value selected by the user in the Setting application menu, just set -1 value.<br>
+On success it returns a zero value. In case of failure it returns a negative value. <br>
+<b>Note:</b> The actual behavior of the feedback play pattern and the intensity depends on the target hardware.
+
+<b>Enumerate values:</b>
+@code
+//Effectvibe_pattern_list
+enum effectvibe_pattern_list {
+       EFFCTVIBE_TOUCH = 0,
+       EFFCTVIBE_HW_TOUCH,
+       EFFCTVIBE_NOTIFICATION,
+       EFFCTVIBE_INCOMING_CALL01,
+       EFFCTVIBE_INCOMING_CALL02,
+       EFFCTVIBE_INCOMONG_CALL03,
+       EFFCTVIBE_ALERTS_CALL,
+       EFFCTVIBE_OPERATION,
+       EFFCTVIBE_SILENT_MODE,
+       EFFCTVIBE_PATTERN_END
+};
+
+//Feedback Level ;
+enum {
+       HAPTIC_FEEDBACK_LEVEL_AUTO = -1,
+       HAPTIC_FEEDBACK_LEVEL_1 = 1,
+       HAPTIC_FEEDBACK_LEVEL_2 = 2,
+       HAPTIC_FEEDBACK_LEVEL_3 = 3,
+       HAPTIC_FEEDBACK_LEVEL_4 = 4,
+       HAPTIC_FEEDBACK_LEVEL_5 = 5,
+};
+
+//definition for infinite iteration ;
+#define HAPTIC_INFINITE_ITERATION      256
+@endcode
+
+<i><b>API : device_haptic_play_file</b></i>
+<br><b>Parameter In :</b> int dev_handle , const char *file_name , int iteration , int feedback_level
+<br><b>Parameter Return :</b> int
+<br><b>Functionality :</b>This API plays a predefined rhythmic haptic-vibration pattern file (only supports .ivt type file, Immersion VibeTonz).<br>
+The first in parameter dev_handle should be from the return value of device_haptic_open().<br>
+The second in parameter file_name sets rhythmic vibration pattern file with path. It only supports .ivt type pattern file. <br>
+The third in parameter iteration sets the number of iterations to be played. This should be less than the maximum iteration range set for the device (currently its 255).
+If you want to play indefinitely, use HAPTIC_INFINITE_ITERATION defined value. But it depends on the target hardware.<br>
+The fourth in parameter is the vibration feedback intensity level. This level is already predefined by enumeration type value from HAPTIC _FEEDBACK_LEVEL_1
+to HAPTIC _FEEDBACK_LEVEL_5. If you want to use the value selected by the user in the Setting application menu, just set HAPTIC_FEEDBACK_LEVEL_AUTO value.
+(But the application must have a main loop to use the HAPTIC_FEEDBACK_LEVEL_AUTO value ) <br>
+On success it returns a zero value. In case of failure it returns a negative value. <br>
+<b>Note:</b> The actual behavior of the feedback play pattern and the intensity depends on the target hardware.
+<br><br>
+<i><b>API : device_haptic_play_monotone</b></i>
+<br><b>Parameter In :</b> int dev_handle ,  int duration
+<br><b>Parameter Return :</b> int
+<br><b>Functionality :</b>This API plays a monotonous haptic-vibration pattern with a constant intensity.
+In this monotone play, the intensity used is the value that the user has selected in the Setting application menu.<br>
+The first in parameter dev_handle should be from the return value of device_haptic_open().<br>
+The second in parameter duration defines the length of time this vibration should be played. This duration is in milliseconds.  <br>
+On success it returns a zero value. In case of failure it returns a negative value. <br>
+<b>Note:</b> The actual behavior of the feedback played and the intensity depends on the target hardware.
+<br><br>
+<i><b>API : device_haptic_stop_play</b></i>
+<br><b>Parameter In :</b> int dev_handle
+<br><b>Parameter Return :</b> int
+<br><b>Functionality :</b> This API stops the current vibration being played.<br>
+The first in parameter dev_handle should be from the return value of device_haptic_open().<br>
+On success it returns a zero value. In case of failure it returns a negative value.
+<br><br>
+<i><b>API : device_haptic_get_pattern_duration</b></i>
+<br><b>Parameter In :</b> int dev_handle ,  int pattern
+<br><b>Parameter Out :</b> int *duration
+<br><b>Parameter Return :</b> int
+<br><b>Functionality :</b>This API gets a duration time value from a predefined rhythmic vibration pattern.<br>
+The first in parameter dev_handle should be from the return value of device_haptic_open().<br>
+The second in parameter pattern should be from a predefined pattern list which is available in an enumeration (effectvibe_pattern_list).<br>
+The application can get a duration time value from the third out parameter duration when this API succeeds. The unit of duration is ms (millisecond)<br>
+On success it returns a zero value. In case of failure it returns a negative value. <br>
+<b>Note:</b> The actual behavior of the feedback played and the intensity depends on the target hardware.
+<br><br>
+<i><b>API : device_haptic_get_file_duration</b></i>
+<br><b>Parameter In :</b> int dev_handle ,  const char *file_name
+<br><b>Parameter Out :</b> int *duration
+<br><b>Parameter Return :</b> int
+<br><b>Functionality :</b>This API gets a duration time value from a predefined rhythmic vibration pattern file (only supports .ivt type file).<br>
+The first in parameter dev_handle should be from the return value of device_haptic_open().<br>
+The second in parameter file_name sets rhythmic vibration pattern file with path. It only supports .ivt type pattern file.<br>
+The application can get a duration time value from the third out parameter duration when this API succeeds. The unit of duration is ms (millisecond)<br>
+On success it returns a zero value. In case of failure it returns a negative value. <br>
+<b>Note:</b>The actual behavior of the feedback played and the intensity depends on the target hardware.<br>
+
+<br><b>Sample Code <Simple program showing how to use haptic-vibration APIs></b>
+@code
+#include <stdio.h>
+#include <devman_haptic.h>
+#define HAPTIC_TEST_ITERATION 10
+
+int main()
+{
+       int ret_val=0;
+       int dev_handle;
+
+       printf("\n Haptic vibration test : Start of the program \n");
+
+       //Open the haptic device
+       dev_handle = device_haptic_open(DEV_IDX_0,0);
+       if(dev_handle < 0)
+               return -1;
+
+       //Play a rhythmic pattern
+       ret_val = device_haptic_play_pattern(dev_handle, EFFCTVIBE_NOTIFICATION,
+                       HAPTIC_TEST_ITERATION , HAPTIC_FEEDBACK_LEVEL_3);
+       if(ret_val !=0)
+               return -1;
+
+       //Play a monotone pattern for 1s == 1000ms
+       ret_val = device_haptic_play_monotone(dev_handle, 1000);
+       if(ret_val !=0)
+               return -1;
+
+       //Demo for a stop pattern API, playing a monotone for 10s
+       ret_val = device_haptic_play_monotone(dev_handle, 10000);
+       if(ret_val !=0)
+               return -1;
+
+       sleep(1);
+
+       //Stop the pattern immediately
+       ret_val = device_haptic_stop_play(dev_handle);
+       if(ret_val !=0)
+               return -1;
+
+       //Close the device
+       ret_val = device_haptic_close(dev_handle);
+       if(ret_val !=0)
+               return -1;
+}
+@endcode
+
+ @}
+**/
diff --git a/haptic/image/devman_PG_haptic_architecture.png b/haptic/image/devman_PG_haptic_architecture.png
new file mode 100644 (file)
index 0000000..2d4c3f7
Binary files /dev/null and b/haptic/image/devman_PG_haptic_architecture.png differ
diff --git a/haptic/include/haptic.h b/haptic/include/haptic.h
new file mode 100644 (file)
index 0000000..adad7a2
--- /dev/null
@@ -0,0 +1,648 @@
+/*
+ *  haptic
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jiyoung Yun <jy910.yun@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+
+#ifndef __HAPTIC_H__
+#define __HAPTIC_H__
+
+#include <tizen_error.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file        haptic.h
+ * @brief       This file contains the prototypes of the haptic API
+ */
+
+/**
+ * @addtogroup CAPI_SYSTEM_HAPTIC_MODULE
+ * @{
+ */
+
+/**
+ * @brief The handle of haptic device
+ */
+typedef void* haptic_device_h;
+
+/**
+ * @brief The handle of haptic effect
+ */
+typedef void* haptic_effect_h;
+
+/**
+ * @brief Enumerations of device id for the Haptic API.
+ * @details We support two motors now.
+ */
+typedef enum {
+       HAPTIC_DEVICE_0 = 0x0,                  /**< 1st motor */
+       HAPTIC_DEVICE_1 = 0x1,                  /**< 2nd motor */
+       HAPTIC_DEVICE_ALL = 0x4,                /**< both of them */
+} haptic_device_e;
+
+/**
+ * @brief Enumerations of priority level for the Haptic API.
+ */
+typedef enum
+{
+       HAPTIC_PRIORITY_MIN = 0,                /**< Minimum effect priority for developers (default) */
+       HAPTIC_PRIORITY_MIDDLE,                 /**< Maximum effect priority for developers */
+       HAPTIC_PRIORITY_HIGH,                   /**< Maximum effect priority for OEMs */
+} haptic_priority_e;
+
+/**
+ * @brief Enumerations of feedback level for the Haptic API.
+ * @details Haptic level means vibration power (intensity).
+ */
+typedef enum
+{
+       HAPTIC_FEEDBACK_0 = 0,                          /**< feedback level 0 */
+       HAPTIC_FEEDBACK_1 = 20,                         /**< feedback level 1 */
+       HAPTIC_FEEDBACK_2 = 40,                         /**< feedback level 2 */
+       HAPTIC_FEEDBACK_3 = 60,                         /**< feedback level 3 */
+       HAPTIC_FEEDBACK_4 = 80,                         /**< feedback level 4 */
+       HAPTIC_FEEDBACK_5 = 100,                        /**< feedback level 5 */
+       HAPTIC_FEEDBACK_AUTO,                           /**< feedback level auto */
+} haptic_feedback_e;
+
+/**
+ * @brief Enumerations of iteration count for the Haptic API.
+ */
+typedef enum
+{
+       HAPTIC_ITERATION_ONCE = 1,
+       HAPTIC_ITERATION_INFINITE = 256,
+} haptic_iteration_e;
+
+/**
+ * @brief Enumerations of effect or device state for the Haptic API.
+ */
+typedef enum
+{
+       HAPTIC_STATE_STOP = 0,
+       HAPTIC_STATE_PLAYING,
+} haptic_state_e;
+
+/**
+ * @brief Enumerations of error codes for the Haptic API.
+ */
+typedef enum
+{
+       HAPTIC_ERROR_NONE                 = TIZEN_ERROR_NONE,                   /**< Successful */
+       HAPTIC_ERROR_INVALID_PARAMETER    = TIZEN_ERROR_INVALID_PARAMETER,      /**< Invalid parameter */
+       HAPTIC_ERROR_FILE_EXISTS          = TIZEN_ERROR_FILE_EXISTS,            /**< File exists */
+       HAPTIC_ERROR_NOT_INITIALIZED      = TIZEN_ERROR_SYSTEM_CLASS | 0x26,    /**< Not initialized */
+       HAPTIC_ERROR_OPERATION_FAILED     = TIZEN_ERROR_SYSTEM_CLASS | 0x28,    /**< Operation failed */
+       HAPTIC_ERROR_NOT_SUPPORTED_DEVICE = TIZEN_ERROR_SYSTEM_CLASS | 0x30,    /**< Not supported device */
+} haptic_error_e;
+
+/**
+ * @brief Gets the number of the vibrators.
+ *
+ * @remarks The index HAPTIC_DEVICE_ALL is reserved meaning for all vibrators at a time.
+ *
+ * @param[out] vibrator_number A number of vibrators
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                   Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ */
+int haptic_get_count(int *device_number);
+
+/**
+ * @brief Opens a haptic-vibration device.
+ *
+ * @details Internally, it makes a connection to the vibrator.
+ *
+ * @remarks If this function is not called in advance, other functions will return #HAPTIC_ERROR_NOT_INITIALIZED.
+ * @remarks Haptic API must be closed by haptic_close().
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_close()
+ */
+int haptic_open(haptic_device_e device, haptic_device_h *device_handle);
+
+/**
+ * @brief Closes a haptic-vibration device.
+ *
+ * @details Internally, it disconnects the connection to vibrator.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_open()
+ */
+int haptic_close(haptic_device_h device_handle);
+
+/**
+ * @brief Vibrates during the specified time with a constant intensity.
+ * @details
+ * This function can be used to start monotonous vibration for specified time.
+ *
+ * @remark
+ * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.\n
+ * And default value of feedback and priority is used.\n
+ * feedback level is reserved for auto chaning to save variable in the settings.\n
+ * priority level uses HAPTIC_PRIORITY_MIN.
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] duration         The play duration in milliseconds
+ * @param[out] effect_handle   Pointer to the variable that will receive a handle to the playing effect
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_vibrate_monotone_with_detail()
+ * @see haptic_vibrate_file()
+ * @see haptic_vibrate_buffer()
+ * @see haptic_get_count()
+ */
+int haptic_vibrate_monotone(haptic_device_h device_handle, int duration, haptic_effect_h *effect_handle);
+
+/**
+ * @brief Vibrates during the specified time with a constant intensity.
+ * @details
+ * This function can be used to start monotonous vibration for specified time.
+ *
+ * @remark
+ * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] duration         The play duration in milliseconds
+ * @param[in] feedback         The amount of the intensity variation
+ * @param[in] priority         The priority from HAPTIC_PRIORITY_MIN to HAPTIC_PRIORITY_HIGH
+ * @param[out] effect_handle   Pointer to the variable that will receive a handle to the playing effect
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_vibrate_monotone()
+ * @see haptic_vibrate_file_with_detail()
+ * @see haptic_vibrate_buffer_with_detail()
+ * @see haptic_get_count()
+ */
+int haptic_vibrate_monotone_with_detail(haptic_device_h device_handle,
+                                                                               int duration,
+                                                                               haptic_feedback_e feedback,
+                                                                               haptic_priority_e priority,
+                                                                               haptic_effect_h *effect_handle);
+
+/**
+ * @brief Vibrates a predefined rhythmic haptic-vibration pattern file.
+ * @details
+ * This function can be used to play a haptic-vibration pattern file.
+ *
+ * @remark
+ * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.\n
+ * And default value of feedback and priority is used.\n
+ * feedback level is reserved for auto chaning to save variable in the settings.\n
+ * priority level uses HAPTIC_PRIORITY_MIN.
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] file_path        Vibration pattern file with path
+ * @param[out] effect_handle   Pointer to the variable that will receive a handle to the playing effect
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_vibrate_file_with_detail()
+ * @see haptic_vibrate_monotone()
+ * @see haptic_vibrate_buffer()
+ * @see haptic_get_count()
+ */
+int haptic_vibrate_file(haptic_device_h device_handle, const char *file_path, haptic_effect_h *effect_handle);
+
+/**
+ * @brief Vibrates a predefined rhythmic haptic-vibration pattern file.
+ * @details
+ * This function can be used to play a haptic-vibration pattern file.
+ *
+ * @remark
+ * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] file_path        Vibration pattern file with path
+ * @param[in] iteration        The number of times to repeat the effect
+ * @param[in] feedback         The amount of the intensity variation
+ * @param[in] priority         The priority from HAPTIC_PRIORITY_MIN to HAPTIC_PRIORITY_HIGH
+ * @param[out] effect_handle   Pointer to the variable that will receive a handle to the playing effect
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_vibrate_file()
+ * @see haptic_vibrate_monotone_with_detail()
+ * @see haptic_vibrate_buffer_with_detail()
+ * @see haptic_get_count()
+ */
+int haptic_vibrate_file_with_detail(haptic_device_h device_handle,
+                                                                       const char *file_path,
+                                                                       haptic_iteration_e iteration,
+                                                                       haptic_feedback_e feedback,
+                                                                       haptic_priority_e priority,
+                                                                       haptic_effect_h *effect_handle);
+
+/**
+ * @brief Vibrates a predefined rhythmic haptic-vibration pattern buffer.
+ * @details
+ * This function can be used to play a haptic-vibration pattern buffer.
+ *
+ * @remark
+ * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.\n
+ * And default value of feedback and priority is used.\n
+ * feedback level is reserved for auto chaning to save variable in the settings.\n
+ * priority level uses HAPTIC_PRIORITY_MIN.
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] vibe_buffer              Pointer to the vibration pattern
+ * @param[out] effect_handle   Pointer to the variable that will receive a handle to the playing effect
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_vibrate_buffer_with_detail()
+ * @see haptic_vibrate_monotone()
+ * @see haptic_vibrate_file()
+ * @see haptic_get_count()
+ */
+int haptic_vibrate_buffer(haptic_device_h device_handle, const unsigned char *vibe_buffer, haptic_effect_h *effect_handle);
+
+/**
+ * @brief Vibrates a predefined rhythmic haptic-vibration pattern buffer.
+ * @details
+ * This function can be used to play a haptic-vibration pattern buffer.
+ *
+ * @remark
+ * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] vibe_buffer      Pointer to the vibration pattern
+ * @param[in] iteration        The number of times to repeat the effect
+ * @param[in] feedback         The amount of the intensity variation
+ * @param[in] priority         The priority from HAPTIC_PRIORITY_MIN to HAPTIC_PRIORITY_HIGH
+ * @param[out] effect_handle   Pointer to the variable that will receive a handle to the playing effect
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_vibrate_buffer()
+ * @see haptic_vibrate_monotone_with_detail()
+ * @see haptic_vibrate_file_with_detail()
+ * @see haptic_get_count()
+ */
+int haptic_vibrate_buffer_with_detail(haptic_device_h device_handle,
+                                                                         const unsigned char *vibe_buffer,
+                                                                         haptic_iteration_e iteration,
+                                                                         haptic_feedback_e feedback,
+                                                                         haptic_priority_e priority,
+                                                                         haptic_effect_h *effect_handle);
+
+/**
+ * @brief Vibrates a predefined rhythmic haptic-vibration pattern buffer.
+ * @details
+ * This function can be used to play a haptic-vibration pattern buffer.
+ *
+ * @remark
+ * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.\n
+ * And default value of feedback and priority is used.\n
+ * feedback level is reserved for auto chaning to save variable in the settings.\n
+ * priority level uses HAPTIC_PRIORITY_MIN.
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] vibe_buffer              Pointer to the vibration pattern
+ * @param[in] size                     Size to the vibration pattern
+ * @param[out] effect_handle   [DEPRECATED] Pointer to the variable that will receive a handle to the playing effect
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_vibrate_buffer_with_detail()
+ * @see haptic_vibrate_monotone()
+ * @see haptic_vibrate_file()
+ * @see haptic_get_count()
+ */
+int haptic_vibrate_buffers(haptic_device_h device_handle,
+                                                       const unsigned char *vibe_buffer,
+                                                       int size,
+                                                       haptic_effect_h *effect_handle);
+
+/**
+ * @brief Vibrates a predefined rhythmic haptic-vibration pattern buffer.
+ * @details
+ * This function can be used to play a haptic-vibration pattern buffer.
+ *
+ * @remark
+ * If you don't use th api regarding effect_handle, you can pass in a NULL value to last parameter.
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] vibe_buffer      Pointer to the vibration pattern
+ * @param[in] size              Size to the vibration pattern
+ * @param[in] iteration        The number of times to repeat the effect
+ * @param[in] feedback         The amount of the intensity variation
+ * @param[in] priority         The priority from HAPTIC_PRIORITY_MIN to HAPTIC_PRIORITY_HIGH
+ * @param[out] effect_handle   [DEPRECATED] Pointer to the variable that will receive a handle to the playing effect
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_vibrate_buffer()
+ * @see haptic_vibrate_monotone_with_detail()
+ * @see haptic_vibrate_file_with_detail()
+ * @see haptic_get_count()
+ */
+int haptic_vibrate_buffers_with_detail(haptic_device_h device_handle,
+                                      const unsigned char *vibe_buffer,
+                                                                         int size,
+                                      haptic_iteration_e iteration,
+                                      haptic_feedback_e feedback,
+                                      haptic_priority_e priority,
+                                      haptic_effect_h *effect_handle);
+
+/**
+ * @brief Stops the current vibration effect which is being played.
+ * @details This function can be used to stop each effect started by haptic_vibrate_xxx().
+ *
+ * @remark
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] effect_handle    The effect handle from haptic_vibrate_xxx()
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_vibrate_buffer()
+ * @see haptic_vibrate_monotone()
+ * @see haptic_vibrate_file()
+ * @see haptic_get_count()
+ * @see haptic_stop_all_effects()
+ */
+int haptic_stop_effect(haptic_device_h device_handle, haptic_effect_h effect_handle);
+
+/**
+ * @brief Stops all vibration effects which are being played.
+ * @details This function can be used to stop all effects started by haptic_vibrate_xxx().
+ *
+ * @remark
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_vibrate_buffer()
+ * @see haptic_vibrate_monotone()
+ * @see haptic_vibrate_file()
+ * @see haptic_get_count()
+ * @see haptic_stop_effect()
+ */
+int haptic_stop_all_effects(haptic_device_h device_handle);
+
+/**
+ * @brief Gets the status of the effect.
+ * @details This function can be used to get the status of the effect wheter the effect are playing or not.
+ *
+ * @remark
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] effect_handle    The effect handle from haptic_vibrate_xxx()
+ * @param[out] state           The pointer to variable that will receive the status of the effect.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_vibrate_buffer()
+ * @see haptic_vibrate_monotone()
+ * @see haptic_vibrate_file()
+ * @see haptic_get_count()
+ * @see haptic_stop_effect()
+ * @see haptic_stop_all_effects()
+ */
+int haptic_get_effect_state(haptic_device_h device_handle, haptic_effect_h effect_handle, haptic_state_e *state);
+
+/**
+ * @par Description:
+ *      effect element for haptic.
+ */
+typedef struct {
+       int haptic_duration;                    /**< Duration of the effect element in millisecond */
+       haptic_feedback_e haptic_level; /**< Level of the effect element (0 ~ 100) */
+} haptic_effect_element_s;
+
+/**
+ * @brief Creates an effect buffer.
+ * @details This function can be used to create an effect buffer using effeclt_element variable.
+ *
+ * @remark
+ *
+ * @param[out] vibe_buffer     Pointer to the vibration pattern
+ * @param[in] max_bufsize              The size of the buffer pointed to by vibe_buffer
+ * @param[in] elem_arr                 Pointer to an haptic_effect_element_s structure
+ * @param[in] max_elemcnt              The size fo the buffer pointed to by elem_arr
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_save_effect()
+ */
+int haptic_create_effect(unsigned char *vibe_buffer,
+                                                int max_bufsize,
+                                                haptic_effect_element_s *elem_arr,
+                                                int max_elemcnt);
+
+/**
+ * @brief Save an effect buffer to the file.
+ * @details This function can be used to save an effect buffer to the file using third parameter.
+ *
+ * @remark
+ *
+ * @param[in] vibe_buffer      Pointer to the vibration pattern
+ * @param[in] max_bufsize              The size of the buffer pointed to by vibe_buffer
+ * @param[in] file_path                The pointer to the character buffer containing the path to save
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_FILE_EXISTS           File exists
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_create_effect()
+ */
+int haptic_save_effect(const unsigned char *vibe_buffer,
+                                          int max_bufsize,
+                                          const char *file_path);
+
+/**
+ * @brief Gets a duration time value from file.
+ * @details This function can be used to get a duration time value from the file using second parameter.
+ *
+ * @remark
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] file_path                The pointer to the character buffer containing the path to save
+ * @param[out] duration                The pointer to the duration time value
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_get_buffer_duration()
+ */
+int haptic_get_file_duration(haptic_device_h device_handle, const char *file_path, int *duration);
+
+/**
+ * @brief Gets a duration time value from buffer.
+ * @details This function can be used to get a duration time value from the buffer using second parameter.
+ *
+ * @remark
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] vibe_buffer              Pointer to the vibration pattern buffer
+ * @param[out] duration                The pointer to the duration time value
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_get_file_duration()
+ */
+int haptic_get_buffer_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int *duration);
+
+/**
+ * @brief Gets a duration time value from buffer.
+ * @details This function can be used to get a duration time value from the buffer using second parameter.
+ *
+ * @remark
+ *
+ * @param[in] device_handle    The device handle from haptic_open()
+ * @param[in] vibe_buffer              Pointer to the vibration pattern buffer
+ * @param[in] size                     Size to the vibration pattern buffer
+ * @param[out] duration                The pointer to the duration time value
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_get_file_duration()
+ */
+int haptic_get_buffers_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int size, int *buffer_duration);
+
+/**
+ * @brief Save an effect buffer to the led file.
+ * @details This function can be used to save an effect buffer to the led file which name is third parameter.
+ *
+ * @remark
+ * Third parameter should be compatible with ledplayer file.
+ *
+ * @param[in] vibe_buffer              Pointer to the vibration pattern
+ * @param[in] max_bufsize              The size of the buffer pointed to by vibe_buffer
+ * @param[in] file_path                The pointer to the character buffer containing the path to save
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #HAPTIC_ERROR_NONE                  Successful
+ * @retval #HAPTIC_ERROR_INVALID_PARAMETER     Invalid parameter
+ * @retval #HAPTIC_ERROR_NOT_INITIALIZED       Not initialized
+ * @retval #HAPTIC_ERROR_FILE_EXISTS           File exists
+ * @retval #HAPTIC_ERROR_OPERATION_FAILED      Operation failed
+ * @retval #HAPTIC_ERROR_NOT_SUPPORTED_DEVICE  Not supported device
+ *
+ * @see haptic_save_effect()
+ */
+int haptic_save_led(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif         /* __HAPTIC_H__ */
diff --git a/haptic/include/haptic_log.h b/haptic/include/haptic_log.h
new file mode 100644 (file)
index 0000000..1cee54b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  haptic
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jiyoung Yun <jy910.yun@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#ifndef __HAPTIC_LOG_H__
+#define __HAPTIC_LOG_H__
+
+#define FEATURE_HAPTIC_DLOG
+
+#ifdef FEATURE_HAPTIC_DLOG
+    #define LOG_TAG "HAPTIC"
+    #include <dlog.h>
+    #define HAPTIC_LOG(fmt, args...)       SLOGD(fmt, ##args)
+    #define HAPTIC_ERROR(fmt, args...)     SLOGE(fmt, ##args)
+#else
+    #define HAPTIC_LOG(x, ...)
+    #define HAPTIC_ERROR(x, ...)
+#endif
+
+#endif //__HAPTIC_LOG_H__
diff --git a/haptic/include/haptic_module.h b/haptic/include/haptic_module.h
new file mode 100644 (file)
index 0000000..3a86354
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ *  haptic
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jiyoung Yun <jy910.yun@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+
+#ifndef __HAPTIC_MODULE_H__
+#define __HAPTIC_MODULE_H__
+
+
+/**
+ * @brief Enumerations of device id for the Haptic Module API.
+ * @details We support two motors now.
+ */
+typedef enum {
+    HAPTIC_MODULE_DEVICE_0 = 0x0,             /**< 1st motor */
+    HAPTIC_MODULE_DEVICE_1 = 0x1,             /**< 2nd motor */
+    HAPTIC_MODULE_DEVICE_ALL = 0x4,           /**< both of them */
+} haptic_module_device;
+
+/**
+ * @brief Enumerations of priority level for the Haptic Module API.
+ */
+typedef enum
+{
+    HAPTIC_MODULE_PRIORITY_MIN = 0,        /**< Minimum effect priority for developers (default) */
+    HAPTIC_MODULE_PRIORITY_MIDDLE,         /**< Maximum effect priority for developers */
+    HAPTIC_MODULE_PRIORITY_HIGH,           /**< Maximum effect priority for OEMs */
+} haptic_module_priority;
+
+/**
+ * @brief Enumerations of feedback level for the Haptic Module API.
+ * @details Haptic level means vibration power (intensity).
+ */
+typedef enum
+{
+    HAPTIC_MODULE_FEEDBACK_MIN = 0,
+    HAPTIC_MODULE_FEEDBACK_MAX = 100,
+} haptic_module_feedback;
+
+/**
+ * @brief Enumerations of iteration count for the Haptic Module API.
+ */
+typedef enum
+{
+    HAPTIC_MODULE_ITERATION_ONCE = 1,
+    HAPTIC_MODULE_ITERATION_INFINITE = 256,
+} haptic_module_iteration;
+
+/**
+ * @brief Enumerations of effect or device state for the Haptic Module API.
+ */
+typedef enum
+{
+    HAPTIC_MODULE_STATE_PLAYING = 0,
+    HAPTIC_MODULE_STATE_STOP,
+} haptic_module_state;
+
+/* Error and Return value codes */
+#define HAPTIC_MODULE_ERROR_NONE                                                        0
+#define HAPTIC_MODULE_NOT_INITIALIZED                                                  -1
+#define HAPTIC_MODULE_ALREADY_INITIALIZED                                              -2
+#define HAPTIC_MODULE_INVALID_ARGUMENT                                                 -3
+#define HAPTIC_MODULE_OPERATION_FAILED                                                 -4
+#define HAPTIC_MODULE_NOT_SUPPORTED                                                            -5
+
+/**
+ * @par Description:
+ *      effect element for haptic module.
+ */
+typedef struct {
+    int haptic_duration; /**< Duration of the effect element in millisecond */
+       int haptic_level;        /**< Level of the effect element (0 ~ 100) */
+} haptic_module_effect_element;
+
+#endif  /* __HAPTIC_MODULE_H__ */
diff --git a/haptic/include/haptic_plugin_intf.h b/haptic/include/haptic_plugin_intf.h
new file mode 100644 (file)
index 0000000..f2338de
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  haptic
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jiyoung Yun <jy910.yun@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+
+#ifndef __HAPTIC_PLUGIN_INTF_H__
+#define __HAPTIC_PLUGIN_INTF_H__
+
+#include "haptic_module.h"
+
+typedef struct {
+       int (*haptic_internal_get_device_count) (int*);
+       int (*haptic_internal_open_device) (int, int*);
+       int (*haptic_internal_close_device) (int);
+       int (*haptic_internal_vibrate_monotone) (int, int, int, int, int*);
+       int (*haptic_internal_vibrate_file) (int, const char*, int, int, int, int*);
+       int (*haptic_internal_vibrate_buffer) (int, const unsigned char*, int, int, int, int*);
+       int (*haptic_internal_stop_effect) (int, int);
+       int (*haptic_internal_stop_all_effects) (int);
+       int (*haptic_internal_pause_effect) (int, int);
+       int (*haptic_internal_resume_effect) (int, int);
+       int (*haptic_internal_get_effect_state) (int, int, int*);
+       int (*haptic_internal_create_effect) (unsigned char*, int, haptic_module_effect_element*, int);
+       int (*haptic_internal_save_effect) (const unsigned char*, int, const char*);
+       int (*haptic_internal_get_file_duration) (int, const char*, int*);
+       int (*haptic_internal_get_buffer_duration) (int, const unsigned char*, int*);
+       int (*haptic_internal_convert_binary) (const unsigned char*, int, const char*);
+} haptic_plugin_interface;
+
+const haptic_plugin_interface *get_haptic_plugin_interface();
+
+#endif /* __HAPTIC_PLUGIN_INTF_H__ */
diff --git a/haptic/src/device_convert.c b/haptic/src/device_convert.c
new file mode 100644 (file)
index 0000000..c527ea7
--- /dev/null
@@ -0,0 +1,553 @@
+/*
+ *  devman
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jiyoung Yun <jy910.yun@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "devlog.h"
+#include <devman_haptic.h>
+#include <devman_haptic_ext.h>
+#include <devman_haptic_ext_core.h>
+
+#ifndef EXTAPI
+#define EXTAPI __attribute__ ((visibility("default")))
+#endif /* EXTAPI */
+
+#ifdef PERFORM_CHECK
+static long long ms = 0;
+
+#define MICROSECONDS(tv)        ((tv.tv_sec * 1000000ll) + tv.tv_usec)
+
+#define ESTIMATE_PERFORMANCE() \
+       do { \
+               struct timeval tv; \
+               if (ms == 0) { \
+                       gettimeofday(&tv, NULL); \
+                       ms = MICROSECONDS(tv); \
+                       fDBG(stderr, "%s start time : %lld\n", __func__, ms); \
+               } else { \
+                       gettimeofday(&tv, NULL); \
+                       fDBG(stderr, "%s elapsed time : %lld\n", __func__, MICROSECONDS(tv) - ms); \
+                       ms = 0; \
+               } \
+       } while(0)
+#else
+#define ESTIMATE_PERFORMANCE()
+#endif
+
+#define MAX_FILE_PATH       256                /* Maximum file path length */
+#define SAMPLE_INTERVAL        10.0    /* Sample calculation interval in milliseconds */
+#define IVT_BUFFER_SIZE     4096       /* IVT buffer size */
+#define BASE                           5
+#define FOLDER_MASK                    664
+
+typedef enum {
+    WAVETYPE_SQUARE = 1,
+    WAVETYPE_TRIANGLE,
+    WAVETYPE_SINE,
+    WAVETYPE_SAWTOOTHUP,
+    WAVETYPE_SAWTOOTHDOWN
+} effect_wave_type;
+
+/* This functions loads the IVT file into memory */
+static unsigned char *_load_ivt_file(const char *filepath)
+{
+    FILE *pFile;
+    long cbyFileSize;
+    unsigned char *p_ivt_data = NULL;
+    /* open the IVT file */
+    /* IMPORTANT: open the IVT file as a binary file to avoid translation */
+    pFile = fopen(filepath, "rb");
+    if (!pFile)
+    {
+        /* handle error, application-specific */
+        return p_ivt_data;
+    }
+    /* determine the file size */
+    /* fseek returns zero on success, non-zero on failure */
+    if (fseek(pFile, 0, SEEK_END))
+    {
+        /* handle error, application-specific */
+        fclose(pFile);
+        return p_ivt_data;
+    }
+    cbyFileSize = ftell(pFile);
+    if (fseek(pFile, 0, SEEK_SET))
+    {
+        /* handle error, application-specific */
+        fclose(pFile);
+        return p_ivt_data;
+    }
+    /* allocate a buffer for the IVT data */
+    p_ivt_data = (unsigned char *)malloc(cbyFileSize);
+    if (!p_ivt_data)
+    {
+        /* handle error, application-specific */
+        fclose(pFile);
+        return p_ivt_data;
+    }
+    /* read the IVT data from the IVT file */
+    if (fread(p_ivt_data, 1, cbyFileSize, pFile) != cbyFileSize)
+    {
+        /* handle error, application-specific */
+        free(p_ivt_data);
+        p_ivt_data = 0;
+        fclose(pFile);
+        return p_ivt_data;
+    }
+    /* close the IVT file */
+    if (0 != fclose(pFile))
+    {
+        /* handle error, application-specific */
+        return p_ivt_data;
+    }
+    /* you can now play effects from the IVT data that was loaded into g_pIVTData */
+    return p_ivt_data;
+}
+
+/* converts effect type to string*/
+static char *_convert_effect_type_to_string(int effect_type)
+{
+    switch (effect_type) {
+        case HAPTIC_EFFECT_TYPE_PERIODIC:
+            return "HAPTIC_EFFECT_TYPE_PERIODIC";
+        case HAPTIC_EFFECT_TYPE_MAGSWEEP:
+            return "HAPTIC_EFFECT_TYPE_MAGSWEEP";
+        case HAPTIC_EFFECT_TYPE_TIMELINE:
+            return "HAPTIC_EFFECT_TYPE_TIMELINE";
+        case HAPTIC_EFFECT_TYPE_STREAMING:
+            return "HAPTIC_EFFECT_TYPE_STREAMING";
+        case HAPTIC_EFFECT_TYPE_WAVEFORM:
+            return "HAPTIC_EFFECT_TYPE_WAVEFORM";
+    }
+       return NULL;
+}
+
+/*This functions gets Periodic effect details using devman API*/
+static int _get_periodic_effect_details(const unsigned char *pivt_data, int index, HapticPeriodic *periodic_effect)
+{
+    int result = -1;
+    result = device_haptic_get_periodic_effect_definition(pivt_data, index,
+                        &periodic_effect->duration, &periodic_effect->magnitude,
+                        &periodic_effect->period, &periodic_effect->style,
+                        &periodic_effect->attacktime, &periodic_effect->attacklevel,
+                        &periodic_effect->fadetime, &periodic_effect->fadelevel);
+    if (result == 0) {
+        DBG("device_haptic_get_periodic_effect_definition() Success");
+        DBG("Duration      : %d", periodic_effect->duration);
+        DBG("Magnitude     : %d", periodic_effect->magnitude);
+        DBG("Period        : %d", periodic_effect->period);
+        DBG("Style & Wave Type : %d", periodic_effect->style);
+        DBG("Attacktime    : %d", periodic_effect->attacktime);
+        DBG("Attacklevel   : %d", periodic_effect->attacklevel);
+        DBG("Fadetime      : %d", periodic_effect->fadetime);
+        DBG("Fadelevel     : %d", periodic_effect->fadelevel);
+    }  else {
+        DBG("device_haptic_get_periodic_effect_definition() failed. Reason:%d", result);
+    }
+    return result;
+}
+
+/*This functions gets MagSweep effect details using devman API*/
+static int _get_magsweep_effect_details(const unsigned char *p_ivt_data, int index, HapticMagSweep *magsweep_effect)
+{
+    int result = -1;
+    result = device_haptic_get_magsweep_effect_definition(p_ivt_data, index,
+                        &magsweep_effect->duration, &magsweep_effect->magnitude,
+                        &magsweep_effect->style,
+                        &magsweep_effect->attacktime, &magsweep_effect->attacklevel,
+                        &magsweep_effect->fadetime, &magsweep_effect->fadelevel);
+    if (result == 0) {
+        DBG("device_haptic_get_magsweep_effect_definition() Success");
+        DBG("Duration      : %d", magsweep_effect->duration);
+        DBG("Magnitude     : %d", magsweep_effect->magnitude);
+        DBG("Style         : %d", magsweep_effect->style);
+        DBG("Attacktime    : %d", magsweep_effect->attacktime);
+        DBG("Attacklevel   : %d", magsweep_effect->attacklevel);
+        DBG("Fadetime      : %d", magsweep_effect->fadetime);
+        DBG("Fadelevel     : %d", magsweep_effect->fadelevel);
+    }  else {
+        DBG("device_haptic_get_magsweep_effect_definition() failed. Reason:%d", result);
+    }
+    return result;
+}
+
+/*This functions gets Timeline effect details using devman API*/
+static int _get_timeline_effect_details(const unsigned char *p_ivt_data, int index, HapticElement *timeline_effect)
+{
+    unsigned char ivt_buffer[IVT_BUFFER_SIZE+1] = {0,};
+    int result = -1;
+
+       result = device_haptic_initialize_buffer(ivt_buffer, sizeof(ivt_buffer));
+    if (result ==0) {
+        result = device_haptic_read_element(ivt_buffer, IVT_BUFFER_SIZE, 0, 0, timeline_effect);
+        if (result == 0) {
+            DBG("Element type:%d", timeline_effect->elementtype);
+        } else {
+            DBG("device_haptic_read_element() failed. Reason :%d", result);
+        }
+    } else {
+        DBG("device_haptic_initialize_buffer() failed. Reason:%d", result);
+    }
+    return result;
+}
+
+/* This function parses the Periodic effect received and generates
+ * corresponding LED pattern for it */
+static char *_parse_periodic_effect_and_generate_led_pattern(HapticPeriodic periodic, int *buffer_size)
+{
+       char *led_pattern = NULL;
+    int unit = periodic.magnitude/10;
+    int i = 0;
+    int sample_index = 0;
+    int value = 0;
+    int style = 0;
+    int wave_type = 0;
+    int mid = periodic.period/2;
+    int j = 0;
+    int step = 0;
+    int delta = 0;
+    int base = BASE*unit;
+    char const_value ='0';
+
+       led_pattern = (char*)calloc(((periodic.duration/SAMPLE_INTERVAL)+1), sizeof(char));
+       if (led_pattern == NULL) {
+               DBG("Memory allocation failure");
+               return NULL;
+       }
+
+    if (periodic.magnitude >0)
+        const_value = '1';
+
+    if (periodic.attacktime == 0 && periodic.attacklevel == 0
+        && periodic.fadetime == 0 && periodic.fadelevel == 0) {
+        DBG("Periodic effect");
+
+        if (periodic.style <=0) {
+            DBG("Unknown periodic effect");
+            free(led_pattern);
+            return NULL;
+        } else {
+            /* Extract Style and wave type*/
+            DBG("Style and wave type: %d", periodic.style);
+            style = periodic.style && HAPTIC_STYLE_SUPPORT_MASK;
+            wave_type = periodic.style && HAPTIC_WAVETYPE_SUPPORT_MASK;
+            DBG("Style     : %d", style);
+            DBG("Wave type : %d", wave_type);
+
+            /* Generate pattern based on Wave type. Ignore Style*/
+            switch (wave_type) {
+            case WAVETYPE_SQUARE:
+            case WAVETYPE_SAWTOOTHDOWN:
+            {
+                for (i = 0; i<periodic.duration; i =i+periodic.period) {
+                    for (j =SAMPLE_INTERVAL; j<=periodic.period; j = j+SAMPLE_INTERVAL) {
+                        if (j <= mid)
+                            led_pattern[sample_index++] = '1';
+                        else
+                            led_pattern[sample_index++] = '0';
+                    }
+                }
+                break;
+            }
+            case WAVETYPE_TRIANGLE:
+            case WAVETYPE_SINE:
+            {
+                step = periodic.magnitude/mid;
+                delta = step * SAMPLE_INTERVAL;
+                for (i = 0; i<periodic.duration; i =i+periodic.period) {
+                    value = 0;
+                    for (j =SAMPLE_INTERVAL; j<=periodic.period; j = j+SAMPLE_INTERVAL) {
+                        if (j <= mid)
+                            value = value + delta;
+                        else
+                            value = value - delta;
+                        if (value>= base)
+                            led_pattern[sample_index++] = '1';
+                        else
+                            led_pattern[sample_index++] = '0';
+                    }
+                }
+                break;
+            }
+            case WAVETYPE_SAWTOOTHUP:
+            {
+                for (i = 0; i<periodic.duration; i =i+periodic.period) {
+                    for (j =SAMPLE_INTERVAL; j<=periodic.period; j = j+SAMPLE_INTERVAL) {
+                        if (j > mid)
+                            led_pattern[sample_index++] = '1';
+                        else
+                            led_pattern[sample_index++] = '0';
+                    }
+                }
+                break;
+            }
+            default: DBG("Unknown wave type\n");
+                break;
+            }
+         }
+    } else {
+        /*TODO*/
+        /* handling periodic effect if attacktime and fade time less than period*/
+        /* Need to keep repeating the pattern with attack and fade effectes within period till duration is reached*/
+        if (periodic.attacktime>periodic.period || periodic.fadetime>periodic.period) {
+            if (periodic.attacktime >0) {
+                DBG("Attack time present\n");
+
+                if (periodic.attacklevel >periodic.magnitude) { /* Decrementing effect */
+                    step = (periodic.attacklevel - periodic.magnitude)/periodic.attacktime;
+                } else if (periodic.attacklevel <periodic.magnitude) { /* Incrementing effect */
+                    step = ( periodic.magnitude - periodic.attacklevel)/periodic.attacktime;
+                }
+                delta = step * SAMPLE_INTERVAL;
+
+                for (i=SAMPLE_INTERVAL; i<= periodic.attacktime; i = i+SAMPLE_INTERVAL) {
+                    value = value+delta;
+                    if (value>base)
+                        led_pattern[sample_index++] = '1';
+                    else
+                        led_pattern[sample_index++] = '0';
+                }
+            }
+
+            for (i = periodic.attacktime+SAMPLE_INTERVAL; i<= (periodic.duration-periodic.fadetime); i = i+ SAMPLE_INTERVAL) {
+                led_pattern[sample_index++] = const_value;
+            }
+            if (periodic.fadetime >0) {
+                step = (periodic.magnitude - periodic.fadelevel)/periodic.fadetime;
+                delta = step* SAMPLE_INTERVAL;
+                value = periodic.magnitude;
+                for (i = (periodic.duration-periodic.fadetime+SAMPLE_INTERVAL); i<= periodic.duration; i = i+ SAMPLE_INTERVAL) {
+                    value = value - delta;
+                    if (value>base)
+                        led_pattern[sample_index++] = '1';
+                    else
+                        led_pattern[sample_index++] = '0';
+                }
+            }
+        }
+    }
+    /*To mark end of effect*/
+    led_pattern[sample_index++] = '0';
+    *buffer_size = sample_index;
+    DBG("LED Pattern for Periodic effect: %s", led_pattern);
+    return led_pattern;
+}
+
+/* This function parses the MagSweep effect received and generates
+ * corresponding LED pattern for it */
+static char *_parse_magsweep_effect_and_generate_led_pattern(HapticMagSweep mag_sweep, int *buffer_size)
+{
+    int unit = mag_sweep.magnitude/10;
+    int i =0;
+    int sample_index = 0;
+    int step = 0;
+    int delta = 0;
+    int value =0;
+    int base = BASE*unit;
+    char const_value ='0';
+    char *led_pattern = NULL;
+
+       led_pattern = (char*)calloc(((mag_sweep.duration/SAMPLE_INTERVAL)+1), sizeof(char));
+    if (led_pattern == NULL) {
+        DBG("Memory allocation failure");
+        return NULL;
+    }
+
+    if (mag_sweep.magnitude >0)
+        const_value = '1';
+
+    if (mag_sweep.attacktime == 0 && mag_sweep.attacklevel == 0
+        && mag_sweep.fadetime == 0 && mag_sweep.fadelevel == 0) {
+        /* Constant effect with maximum magnitude*/
+        DBG("Constant effect");
+
+        for (i = 0; i<=mag_sweep.duration; i=i+SAMPLE_INTERVAL) {
+            led_pattern[sample_index++] = const_value;
+        }
+    } else {
+        DBG("Varying effect");
+        /* Handling Attack effect*/
+        if (mag_sweep.attacktime >0) {
+            DBG("Attack time present");
+
+            if (mag_sweep.attacklevel >mag_sweep.magnitude) { /* Decrementing effect */
+                step = (mag_sweep.attacklevel - mag_sweep.magnitude)/mag_sweep.attacktime;
+            } else if (mag_sweep.attacklevel <mag_sweep.magnitude) { /* Incrementing effect */
+                step = ( mag_sweep.magnitude - mag_sweep.attacklevel)/mag_sweep.attacktime;
+            }
+            delta = step * SAMPLE_INTERVAL;
+
+            for (i=SAMPLE_INTERVAL; i<= mag_sweep.attacktime; i = i+SAMPLE_INTERVAL) {
+                value = value+delta;
+                if (value>base)
+                    led_pattern[sample_index++] = '1';
+                else
+                    led_pattern[sample_index++] = '0';
+            }
+        }
+        /* For Handling constant effect between attacktime and fade time*/
+        for (i = mag_sweep.attacktime+SAMPLE_INTERVAL; i<= (mag_sweep.duration-mag_sweep.fadetime); i = i+ SAMPLE_INTERVAL) {
+            led_pattern[sample_index++] = const_value;
+        }
+        /* Handling fading effect*/
+        if (mag_sweep.fadetime >0) {
+            step = (mag_sweep.magnitude - mag_sweep.fadelevel)/mag_sweep.fadetime;
+            delta = step* SAMPLE_INTERVAL;
+            value = mag_sweep.magnitude;
+            for (i = (mag_sweep.duration-mag_sweep.fadetime+ SAMPLE_INTERVAL); i<= mag_sweep.duration; i = i+ SAMPLE_INTERVAL) {
+                value = value - delta;
+                if (value>base)
+                    led_pattern[sample_index++] = '1';
+                else
+                    led_pattern[sample_index++] = '0';
+            }
+        }
+
+    }
+    /*To mark end of effect*/
+    led_pattern[sample_index++] = '0';
+    *buffer_size = sample_index;
+    DBG("Appending 0 at the end");
+    DBG("LED Pattern for MagSweep effect: %s", led_pattern);
+    return led_pattern;
+}
+
+static int _write_pattern_to_file(const char *binary_path, char *pled_dat, int buf_size, int *opened_flag)
+{
+       FILE *ptr_myfile = NULL;
+
+    DBG("LED file name:%s", binary_path);
+       /* Open file for the FIRST time */
+       if (*opened_flag) {
+        ptr_myfile = fopen(binary_path, "wb+");
+        if (!ptr_myfile) {
+            DBG("Unable to open file!");
+            return -1;
+        }
+               *opened_flag = 0;
+    } else {
+        ptr_myfile = fopen(binary_path, "ab+");
+        if (!ptr_myfile) {
+            DBG("Unable to open file!");
+            return -1;
+        }
+    }
+
+    DBG("Buffer: %s", pled_dat);
+    if (fwrite(pled_dat, 1, buf_size, ptr_myfile) <= 0) {
+        DBG("fwrite() failed");
+    } else {
+        DBG("fwrite() success");
+    }
+
+    fclose(ptr_myfile);
+       return 0;
+}
+
+static int _convert_ivt_to_binary(const char *haptic_path, const char *binary_path)
+{
+       unsigned char *pivt_dat = NULL;
+       char *pled_dat = NULL;
+       int result = -1;
+       int effect_cnt = -1;
+       int effect_type = -1;
+       int effect_duration = -1;
+       int buf_size = -1;
+       int opened_flag = 1;    // 1 : Not opened, 0 : Opened
+       HapticPeriodic periodic_effect;
+       HapticMagSweep magsweep_effect;
+       HapticElement element;
+       int i;
+
+       /* Load IVT file into memory */
+       pivt_dat = _load_ivt_file(haptic_path);
+       if (!pivt_dat) {
+               DBG("Loading IVT failed");
+               return -1;
+       }
+
+       /* Get total number of effects in IVT file */
+       effect_cnt = device_haptic_get_effect_count(pivt_dat);
+       DBG("device_haptic_get_effect_count() Return:%d", effect_cnt);
+
+    /* Parse effects in IVT */
+       for (i = 0; i < effect_cnt; i++) {
+               /* Get effect type*/
+               result = device_haptic_get_effect_type(pivt_dat, i, &effect_type);
+               if (result < 0) {
+                       DBG("EffectNo:%d Getting Effect Type Failed. Reason:%d", (i+1), result);
+                       continue;
+               }
+
+               DBG("EffectNo:%d EffectType:%s\n", (i+1), _convert_effect_type_to_string(effect_type));
+               switch (effect_type) {
+               case HAPTIC_EFFECT_TYPE_PERIODIC:
+                       memset(&periodic_effect, 0x00, sizeof(HapticPeriodic));
+                       if (_get_periodic_effect_details(pivt_dat, i, &periodic_effect) == 0) {
+                               /* Parse periodic effect type*/
+                               pled_dat = _parse_periodic_effect_and_generate_led_pattern(periodic_effect, &buf_size);
+                               if (pled_dat) {
+                                       _write_pattern_to_file(binary_path, pled_dat, buf_size, &opened_flag);
+                                       free(pled_dat);
+                               }
+                       }
+                       break;
+               case HAPTIC_EFFECT_TYPE_MAGSWEEP:
+                       memset(&magsweep_effect, 0x00, sizeof(HapticMagSweep));
+                       if (_get_magsweep_effect_details(pivt_dat, i, &magsweep_effect) == 0) {
+                               /* Parse magsweep effect type*/
+                               pled_dat = _parse_magsweep_effect_and_generate_led_pattern(magsweep_effect, &buf_size);
+                               if (pled_dat) {
+                                       _write_pattern_to_file(binary_path, pled_dat, buf_size, &opened_flag);
+                                       free(pled_dat);
+                               }
+                       }
+                       break;
+               case HAPTIC_EFFECT_TYPE_TIMELINE:
+                       memset(&element, 0x00, sizeof(HapticElement));
+                       if (_get_timeline_effect_details(pivt_dat, i, &element) > 0) {
+                               device_haptic_get_effect_duration(pivt_dat, i, &effect_duration);
+                               DBG("Timeline effect duration:%d", effect_duration);
+                       }
+                       break;
+               case HAPTIC_EFFECT_TYPE_STREAMING:
+               case HAPTIC_EFFECT_TYPE_WAVEFORM:
+               default:
+                       DBG("Unsupported effect type");
+                       break;
+               }
+       }
+
+       free(pivt_dat);
+       return 0;
+}
+
+EXTAPI int device_haptic_convert_to_binary(const char *haptic_name)
+{
+       DBG("this api is not implementation yet");
+       return -1;
+}
diff --git a/haptic/src/haptic.c b/haptic/src/haptic.c
new file mode 100644 (file)
index 0000000..560ccef
--- /dev/null
@@ -0,0 +1,810 @@
+/*
+ *  haptic
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jiyoung Yun <jy910.yun@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <vconf.h>
+
+#include "haptic.h"
+#include "haptic_plugin_intf.h"
+#include "haptic_log.h"
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#define HAPTIC_MODULE_PATH             "/usr/lib/libhaptic-module.so"
+
+/* Haptic Handle Control */
+static unsigned int __handle_cnt;
+
+/* Haptic Plugin Interface */
+static void *dlopen_handle;
+static const haptic_plugin_interface *plugin_intf;
+
+/* START of Static Function Section */
+static int __module_init(void)
+{
+       struct stat buf;
+
+       if (stat(HAPTIC_MODULE_PATH, &buf)) {
+               HAPTIC_ERROR("file(%s) is not presents", HAPTIC_MODULE_PATH);
+               goto EXIT;
+       }
+
+       dlopen_handle = dlopen(HAPTIC_MODULE_PATH, RTLD_NOW);
+       if (!dlopen_handle) {
+               HAPTIC_ERROR("dlopen failed: %s", dlerror());
+               goto EXIT;
+       }
+
+       const haptic_plugin_interface *(*get_haptic_plugin_interface) () = NULL;
+       get_haptic_plugin_interface = dlsym(dlopen_handle, "get_haptic_plugin_interface");
+       if (!get_haptic_plugin_interface) {
+               HAPTIC_ERROR("dlsym failed : %s", dlerror());
+               goto EXIT;
+       }
+
+       plugin_intf = get_haptic_plugin_interface();
+       if (!plugin_intf) {
+               HAPTIC_ERROR("get_haptic_plugin_interface() failed");
+               goto EXIT;
+       }
+
+       HAPTIC_LOG("This device can vibe");
+       return 0;
+
+EXIT:
+       if (dlopen_handle) {
+               dlclose(dlopen_handle);
+               dlopen_handle = NULL;
+       }
+
+       HAPTIC_LOG("This device can not vibe");
+       return -1;
+}
+
+static int __module_fini(void)
+{
+       if (dlopen_handle) {
+               dlclose(dlopen_handle);
+               dlopen_handle = NULL;
+       }
+
+       HAPTIC_LOG("haptic module is released");
+       return 0;
+}
+
+static haptic_feedback_e __get_setting_feedback_level(void)
+{
+       int setting_fb_level;
+
+       if (vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &setting_fb_level) < 0) {
+               setting_fb_level = SETTING_VIB_FEEDBACK_LEVEL3;
+       }
+
+       switch (setting_fb_level) {
+       case SETTING_VIB_FEEDBACK_LEVEL0 : return HAPTIC_FEEDBACK_0;
+       case SETTING_VIB_FEEDBACK_LEVEL1 : return HAPTIC_FEEDBACK_1;
+       case SETTING_VIB_FEEDBACK_LEVEL2 : return HAPTIC_FEEDBACK_2;
+       case SETTING_VIB_FEEDBACK_LEVEL3 : return HAPTIC_FEEDBACK_3;
+       case SETTING_VIB_FEEDBACK_LEVEL4 : return HAPTIC_FEEDBACK_4;
+       case SETTING_VIB_FEEDBACK_LEVEL5 : return HAPTIC_FEEDBACK_5;
+       default:
+               break;
+       }
+       return -1;
+}
+/* END of Static Function Section */
+
+API
+int haptic_get_count(int *device_number)
+{
+       int ret;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (device_number == NULL) {
+               HAPTIC_ERROR("Invalid parameter : device_number(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_get_device_count) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_get_device_count == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       ret = plugin_intf->haptic_internal_get_device_count(device_number);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_get_device_count is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_open(haptic_device_e device_index, haptic_device_h *device_handle)
+{
+       int ret;
+       int handle;
+
+       if (!(device_index == HAPTIC_DEVICE_0 || device_index == HAPTIC_DEVICE_1 || device_index == HAPTIC_DEVICE_ALL)) {
+               HAPTIC_ERROR("Invalid parameter : device_index(%d)", device_index);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (device_handle == NULL) {
+               HAPTIC_ERROR("Invalid parameter : device_handle(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (__handle_cnt == 0) {
+               ret = __module_init();
+               if (ret < 0) {
+                       HAPTIC_ERROR("__module_init failed");
+                       return HAPTIC_ERROR_OPERATION_FAILED;
+               }
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_open_device) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_open_device == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       ret = plugin_intf->haptic_internal_open_device((int)device_index, &handle);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_open_device is failed : %d", ret);
+               __module_fini();
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       __handle_cnt++;
+       *device_handle = (haptic_device_h)handle;
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_close(haptic_device_h device_handle)
+{
+       int ret;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (device_handle < 0) {
+               HAPTIC_ERROR("Invalid parameter : device_handle(%d)", device_handle);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_close_device) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_close_device == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       ret = plugin_intf->haptic_internal_close_device((int)device_handle);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_close_device is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       __handle_cnt--;
+       if (__handle_cnt == 0) {
+               __module_fini();
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_vibrate_monotone(haptic_device_h device_handle, int duration, haptic_effect_h *effect_handle)
+{
+       return haptic_vibrate_monotone_with_detail(device_handle,
+                                                                                          duration,
+                                                                                          HAPTIC_FEEDBACK_AUTO,
+                                                                                          HAPTIC_PRIORITY_MIN,
+                                                                                          effect_handle);
+}
+
+API
+int haptic_vibrate_monotone_with_detail(haptic_device_h device_handle,
+                                        int duration,
+                                        haptic_feedback_e feedback,
+                                        haptic_priority_e priority,
+                                        haptic_effect_h *effect_handle)
+{
+       int ret;
+       int handle;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (device_handle < 0) {
+               HAPTIC_ERROR("Invalid parameter : device_handle(%d)", device_handle);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (duration < 0) {
+               HAPTIC_ERROR("Invalid parameter : duration(%d)", duration);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (feedback < HAPTIC_FEEDBACK_0 || feedback > HAPTIC_FEEDBACK_AUTO) {
+               HAPTIC_ERROR("Invalid parameter : feedback(%d)", feedback);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (priority < HAPTIC_PRIORITY_MIN || priority > HAPTIC_PRIORITY_HIGH) {
+               HAPTIC_ERROR("Invalid parameter : priority(%d)", priority);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_vibrate_monotone) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_vibrate_monotone == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       if (feedback == HAPTIC_FEEDBACK_AUTO) {
+               HAPTIC_LOG("Auto feedback level, feedback value will be changed");
+               feedback = __get_setting_feedback_level();
+       }
+
+       HAPTIC_LOG("duration : %d, feedback : %d, priority : %d", duration, feedback, priority);
+       ret = plugin_intf->haptic_internal_vibrate_monotone((int)device_handle, duration, feedback, priority, &handle);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_vibrate_monotone is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       if (effect_handle != NULL) {
+               *effect_handle = (haptic_effect_h)handle;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_vibrate_file(haptic_device_h device_handle, const char *file_path, haptic_effect_h *effect_handle)
+{
+       return haptic_vibrate_file_with_detail(device_handle,
+                                                                                  file_path,
+                                                                                  HAPTIC_ITERATION_ONCE,
+                                                                                  HAPTIC_FEEDBACK_AUTO,
+                                                                                  HAPTIC_PRIORITY_MIN,
+                                                                                  effect_handle);
+}
+
+API
+int haptic_vibrate_file_with_detail(haptic_device_h device_handle,
+                                    const char *file_path,
+                                    haptic_iteration_e iteration,
+                                    haptic_feedback_e feedback,
+                                    haptic_priority_e priority,
+                                    haptic_effect_h *effect_handle)
+{
+       int ret;
+       int handle;
+       struct stat buf;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (device_handle < 0) {
+               HAPTIC_ERROR("Invalid parameter : device_handle(%d)", device_handle);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (file_path == NULL) {
+               HAPTIC_ERROR("Invalid parameter : file_path(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (stat(file_path, &buf)) {
+               HAPTIC_ERROR("Invalid parameter : (%s) is not presents", file_path);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (iteration < HAPTIC_ITERATION_ONCE || iteration > HAPTIC_ITERATION_INFINITE) {
+               HAPTIC_ERROR("Invalid parameter : iteration(%d)", iteration);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (feedback < HAPTIC_FEEDBACK_0 || feedback > HAPTIC_FEEDBACK_AUTO) {
+               HAPTIC_ERROR("Invalid parameter : feedback(%d)", feedback);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (priority < HAPTIC_PRIORITY_MIN || priority > HAPTIC_PRIORITY_HIGH) {
+               HAPTIC_ERROR("Invalid parameter : priority(%d)", priority);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_vibrate_file) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_vibrate_file == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       if (feedback == HAPTIC_FEEDBACK_AUTO) {
+               HAPTIC_LOG("Auto feedback level, feedback value will be changed");
+               feedback = __get_setting_feedback_level();
+       }
+
+       HAPTIC_LOG("file_path : %s, iteration : %d, feedback : %d, priority : %d", file_path, iteration, feedback, priority);
+       ret = plugin_intf->haptic_internal_vibrate_file((int)device_handle, file_path, iteration, feedback, priority, &handle);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_vibrate_file is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       if (effect_handle != NULL) {
+               *effect_handle = (haptic_effect_h)handle;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_vibrate_buffer(haptic_device_h device_handle, const unsigned char *vibe_buffer, haptic_effect_h *effect_handle)
+{
+       return haptic_vibrate_buffers_with_detail(device_handle,
+                                                                                        vibe_buffer,
+                                                                                        0,
+                                                                                        HAPTIC_ITERATION_ONCE,
+                                                                                        HAPTIC_FEEDBACK_AUTO,
+                                                                                        HAPTIC_PRIORITY_MIN,
+                                                                                        effect_handle);
+}
+
+API
+int haptic_vibrate_buffer_with_detail(haptic_device_h device_handle,
+                                      const unsigned char *vibe_buffer,
+                                      haptic_iteration_e iteration,
+                                      haptic_feedback_e feedback,
+                                      haptic_priority_e priority,
+                                      haptic_effect_h *effect_handle)
+{
+       return haptic_vibrate_buffers_with_detail(device_handle,
+                                                                                        vibe_buffer,
+                                                                                        0,
+                                                                                        iteration,
+                                                                                        feedback,
+                                                                                        priority,
+                                                                                        effect_handle);
+}
+
+API
+int haptic_vibrate_buffers(haptic_device_h device_handle,
+                                                       const unsigned char *vibe_buffer,
+                                                       int size,
+                                                       haptic_effect_h *effect_handle)
+{
+       return haptic_vibrate_buffers_with_detail(device_handle,
+                                                                                        vibe_buffer,
+                                                                                        size,
+                                                                                        HAPTIC_ITERATION_ONCE,
+                                                                                        HAPTIC_FEEDBACK_AUTO,
+                                                                                        HAPTIC_PRIORITY_MIN,
+                                                                                        effect_handle);
+}
+
+API
+int haptic_vibrate_buffers_with_detail(haptic_device_h device_handle,
+                                      const unsigned char *vibe_buffer,
+                                                                         int size,
+                                      haptic_iteration_e iteration,
+                                      haptic_feedback_e feedback,
+                                      haptic_priority_e priority,
+                                      haptic_effect_h *effect_handle)
+{
+       int ret;
+       int handle;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (device_handle < 0) {
+               HAPTIC_ERROR("Invalid parameter : device_handle(%d)", device_handle);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (vibe_buffer == NULL) {
+               HAPTIC_ERROR("Invalid parameter : vibe_buffer(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (iteration < HAPTIC_ITERATION_ONCE || iteration > HAPTIC_ITERATION_INFINITE) {
+               HAPTIC_ERROR("Invalid parameter : iteration(%d)", iteration);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (feedback < HAPTIC_FEEDBACK_0 || feedback > HAPTIC_FEEDBACK_AUTO) {
+               HAPTIC_ERROR("Invalid parameter : feedback(%d)", feedback);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (priority < HAPTIC_PRIORITY_MIN || priority > HAPTIC_PRIORITY_HIGH) {
+               HAPTIC_ERROR("Invalid parameter : priority(%d)", priority);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_vibrate_buffer) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_vibrate_buffer == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       if (feedback == HAPTIC_FEEDBACK_AUTO) {
+               HAPTIC_LOG("Auto feedback level, feedback value will be changed");
+               feedback = __get_setting_feedback_level();
+       }
+
+       HAPTIC_LOG("iteration : %d, feedback : %d, priority : %d", iteration, feedback, priority);
+       ret = plugin_intf->haptic_internal_vibrate_buffer((int)device_handle, vibe_buffer, iteration, feedback, priority, &handle);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_vibrate_buffer is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       if (effect_handle != NULL) {
+               *effect_handle = (haptic_effect_h)handle;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_stop_effect(haptic_device_h device_handle, haptic_effect_h effect_handle)
+{
+       return haptic_stop_all_effects(device_handle);
+}
+
+API
+int haptic_stop_all_effects(haptic_device_h device_handle)
+{
+       int ret;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (device_handle < 0) {
+               HAPTIC_ERROR("Invalid parameter : device_handle(%d)", device_handle);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_stop_all_effects) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_stop_all_effects == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       ret = plugin_intf->haptic_internal_stop_all_effects((int)device_handle);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_stop_all_effects is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_get_effect_state(haptic_device_h device_handle, haptic_effect_h effect_handle, haptic_state_e *effect_state)
+{
+       int ret;
+       int state;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (device_handle < 0) {
+               HAPTIC_ERROR("Invalid parameter : device_handle(%d)", device_handle);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (effect_handle < 0) {
+               HAPTIC_ERROR("Invalid parameter : effect_handle(%d)", effect_handle);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (effect_state == NULL) {
+               HAPTIC_ERROR("Invalid parameter : effect_state(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_get_effect_state) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_get_effect_state == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       ret = plugin_intf->haptic_internal_get_effect_state((int)device_handle, (int)effect_handle, &state);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_get_effect_state is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       *effect_state = (haptic_state_e)state;
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_create_effect(unsigned char *vibe_buffer,
+                         int max_bufsize,
+                         haptic_effect_element_s *elem_arr,
+                         int max_elemcnt)
+{
+       int ret;
+       int i;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (vibe_buffer == NULL) {
+               HAPTIC_ERROR("Invalid parameter : vibe_buffer(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (max_bufsize <= 0) {
+               HAPTIC_ERROR("Invalid parameter : max_bufsize(%d)", max_bufsize);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (elem_arr == NULL) {
+               HAPTIC_ERROR("Invalid parameter : elem_arr(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (max_elemcnt <= 0) {
+               HAPTIC_ERROR("Invalid parameter : max_elemcnt(%d)", max_elemcnt);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_create_effect) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_create_effect == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       for (i = 0; i < max_elemcnt; i++) {
+               if (elem_arr[i].haptic_level == HAPTIC_FEEDBACK_AUTO) {
+                       vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &elem_arr[i].haptic_level);
+            elem_arr[i].haptic_level = elem_arr[i].haptic_level*20;
+               }
+       }
+
+       ret = plugin_intf->haptic_internal_create_effect(vibe_buffer, max_bufsize, (haptic_module_effect_element*)elem_arr, max_elemcnt);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_create_effect is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_save_effect(const unsigned char *vibe_buffer,
+                       int max_bufsize,
+                       const char *file_path)
+{
+       int ret;
+       struct stat buf;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (vibe_buffer == NULL) {
+               HAPTIC_ERROR("Invalid parameter : vibe_buffer(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (max_bufsize <= 0) {
+               HAPTIC_ERROR("Invalid parameter : max_bufsize(%d)", max_bufsize);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (file_path == NULL) {
+               HAPTIC_ERROR("Invalid parameter : file_path(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!stat(file_path, &buf)) {
+               HAPTIC_ERROR("Already exist : file_path(%s)", file_path);
+               return HAPTIC_ERROR_FILE_EXISTS;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_save_effect) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_save_effect == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       HAPTIC_LOG("file path : %s", file_path);
+       ret = plugin_intf->haptic_internal_save_effect(vibe_buffer, max_bufsize, file_path);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_save_effect is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_get_file_duration(haptic_device_h device_handle, const char *file_path, int *file_duration)
+{
+       int ret;
+       struct stat buf;
+       int duration;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (device_handle < 0) {
+               HAPTIC_ERROR("Invalid parameter : device_handle(%d)", device_handle);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (file_path == NULL) {
+               HAPTIC_ERROR("Invalid parameter : file_path(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (stat(file_path, &buf)) {
+               HAPTIC_ERROR("Invalid parameter : (%s) is not presents", file_path);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (file_duration == NULL) {
+               HAPTIC_ERROR("Invalid parameter : file_duration(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_get_file_duration) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_get_file_duration == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       ret = plugin_intf->haptic_internal_get_file_duration((int)device_handle, file_path, &duration);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_stop_get_file_duration is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       *file_duration = duration;
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_get_buffer_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int *buffer_duration)
+{
+       return haptic_get_buffers_duration(device_handle,
+                                                                       vibe_buffer,
+                                                                       0,
+                                                                       buffer_duration);
+}
+
+API
+API int haptic_get_buffers_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int size, int *buffer_duration)
+{
+       int ret;
+       int duration;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (device_handle < 0) {
+               HAPTIC_ERROR("Invalid parameter : device_handle(%d)", device_handle);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (vibe_buffer == NULL) {
+               HAPTIC_ERROR("Invalid parameter : vibe_buffer(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (buffer_duration == NULL) {
+               HAPTIC_ERROR("Invalid parameter : buffer_duration(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_get_buffer_duration) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_get_buffer_duration == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       ret = plugin_intf->haptic_internal_get_buffer_duration((int)device_handle, vibe_buffer, &duration);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_stop_get_buffer_duration is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       *buffer_duration = duration;
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_save_led(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path)
+{
+       int ret;
+       struct stat buf;
+
+       if (__handle_cnt == 0) {
+               HAPTIC_ERROR("Not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+
+       if (vibe_buffer == NULL) {
+               HAPTIC_ERROR("Invalid parameter : vibe_buffer(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (max_bufsize <= 0) {
+               HAPTIC_ERROR("Invalid parameter : max_bufsize(%d)", max_bufsize);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (file_path == NULL) {
+               HAPTIC_ERROR("Invalid parameter : file_path(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!stat(file_path, &buf)) {
+               HAPTIC_ERROR("Already exist : file_path(%s)", file_path);
+               return HAPTIC_ERROR_FILE_EXISTS;
+       }
+
+       if (!plugin_intf || !plugin_intf->haptic_internal_convert_binary) {
+               HAPTIC_ERROR("plugin_intf == NULL || plugin_intf->haptic_internal_convert_binary == NULL");
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       HAPTIC_LOG("file path : %s", file_path);
+       ret = plugin_intf->haptic_internal_convert_binary(vibe_buffer, max_bufsize, file_path);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_save_effect is failed : %d", ret);
+               return HAPTIC_ERROR_OPERATION_FAILED;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
index 53dfd4e..6667365 100644 (file)
@@ -2,7 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(pmapi C)
 
 SET(SRCS pm.c)
-SET(HEADERS pmapi.h pmapi_managed.h SLP_pm_PG.h)
+SET(HEADERS pmapi.h pmapi_managed.h pm_PG.h)
 
 SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(EXEC_PREFIX "\${prefix}")
similarity index 98%
rename from libslp-pm/SLP_pm_PG.h
rename to libslp-pm/pm_PG.h
index 2dfd57c..a0ad1d2 100644 (file)
@@ -40,14 +40,14 @@ The scope of this document is limited to Power Manager API usage.
 The Power Manager (PM) consists of a client API library and a Power Manager daemon.
 
 <h3 class="pg" align="center">Power Manager Architecture</h3>
-@image html SLP_pm_PG_architecture.png
+@image html pm_PG_architecture.png
 <br>
 Power Manager daemon controls a kernel power management module and peripheral device drivers to save system power consumption. 
 It manages the system power states and makes state transitions according to the events. <br>
 There are four power states ? Normal (i.e. LCD on), LCD dimming, LCD off and Sleep.
 
 <h3 class="pg" align="center">Power Manager State Diagram</h3>
-@image html SLP_pm_PG_state_diagram.png
+@image html pm_PG_state_diagram.png
 
 Applications can put conditions on specific state transitions. For example, Video Player applications do not want the Power Manager 
 to allow the LCD to be in a dimming state or to turn off the LCD backlight. 
diff --git a/packaging/haptic.manifest b/packaging/haptic.manifest
new file mode 100644 (file)
index 0000000..3256181
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+<request>
+       <domain name="_"/>
+</request>
+</manifest>
index 6938da1..2a89b6f 100755 (executable)
@@ -10,6 +10,7 @@ Source1:    system-server.manifest
 Source2:    deviced.manifest
 Source3:    sysman.manifest
 Source4:    libslp-pm.manifest
+Source5:    haptic.manifest
 BuildRequires:  cmake
 BuildRequires:  libattr-devel
 BuildRequires:  pkgconfig(ecore)
@@ -28,6 +29,7 @@ BuildRequires:  pkgconfig(libsmack)
 BuildRequires:  gettext
 BuildRequires:  pkgconfig(sensor)
 BuildRequires:  pkgconfig(libsystemd-daemon)
+BuildRequires:  pkgconfig(capi-base-common)
 %{?systemd_requires}
 Requires(preun): /usr/bin/systemctl
 Requires(post): /usr/bin/systemctl
@@ -73,7 +75,7 @@ Requires:   %{name} = %{version}-%{release}
 sysman internal devel library.
 
 %package -n libslp-pm
-Summary:    SLP power manager client
+Summary:    power manager client
 Group:      System/Libraries
 Requires:   %{name} = %{version}-%{release}
 
@@ -81,7 +83,7 @@ Requires:   %{name} = %{version}-%{release}
 power-manager library.
 
 %package -n libslp-pm-devel
-Summary:    SLP power manager client (devel)
+Summary:    power manager client (devel)
 Group:      System/Development
 Requires:   %{name} = %{version}-%{release}
 #Requires:   libslp-pm
@@ -89,6 +91,28 @@ Requires:   %{name} = %{version}-%{release}
 %description -n libslp-pm-devel
 power-manager devel library.
 
+%package -n libhaptic
+Summary:    Haptic library
+Group:      Development/Libraries
+
+%description -n libhaptic
+Haptic library for device control
+
+%package -n libhaptic-devel
+Summary:    Haptic library for (devel)
+Group:      Development/Libraries
+Requires:   libhaptic = %{version}-%{release}
+
+%description -n libhaptic-devel
+Haptic library for device control (devel)
+
+%package -n libhaptic-plugin-devel
+Summary:    Haptic plugin library for (devel)
+Group:      Development/Libraries
+
+%description -n libhaptic-plugin-devel
+Haptic plugin library for device control (devel)
+
 %package -n libdeviced
 Summary:    Deviced library
 Group:      System/Libraries
@@ -113,6 +137,7 @@ cp %{SOURCE1} .
 cp %{SOURCE2} .
 cp %{SOURCE3} .
 cp %{SOURCE4} .
+cp %{SOURCE5} .
 %cmake .
 
 %install
@@ -249,7 +274,7 @@ systemctl daemon-reload
 %defattr(-,root,root,-)
 %{_includedir}/sysman/sysman.h
 %{_includedir}/sysman/sysman_managed.h
-%{_includedir}/sysman/SLP_sysman_PG.h
+%{_includedir}/sysman/sysman_PG.h
 %{_libdir}/pkgconfig/sysman.pc
 %{_libdir}/libsysman.so
 
@@ -266,10 +291,28 @@ systemctl daemon-reload
 %defattr(-,root,root,-)
 %{_includedir}/pmapi/pmapi.h
 %{_includedir}/pmapi/pmapi_managed.h
-%{_includedir}/pmapi/SLP_pm_PG.h
+%{_includedir}/pmapi/pm_PG.h
 %{_libdir}/pkgconfig/pmapi.pc
 %{_libdir}/libpmapi.so
 
+%files -n libhaptic
+%defattr(-,root,root,-)
+%{_libdir}/libhaptic.so.*
+%manifest haptic.manifest
+
+%files -n libhaptic-devel
+%defattr(-,root,root,-)
+%{_includedir}/haptic/haptic.h
+%{_libdir}/libhaptic.so
+%{_libdir}/pkgconfig/haptic.pc
+
+%files -n libhaptic-plugin-devel
+%defattr(-,root,root,-)
+%{_includedir}/haptic/haptic_module.h
+%{_includedir}/haptic/haptic_plugin_intf.h
+%{_includedir}/haptic/haptic_PG.h
+%{_libdir}/pkgconfig/haptic-plugin.pc
+
 %files -n libdeviced
 %defattr(-,root,root,-)
 %{_libdir}/libdeviced.so.*
index 1b49768..afedccc 100755 (executable)
@@ -40,7 +40,7 @@ INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT Runtime
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sysman.h DESTINATION include/${PROJECT_NAME})
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sysman_managed.h DESTINATION include/${PROJECT_NAME})
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sysman-internal.h DESTINATION include/${PROJECT_NAME})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/SLP_sysman_PG.h DESTINATION include/${PROJECT_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/sysman_PG.h DESTINATION include/${PROJECT_NAME})
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 ADD_SUBDIRECTORY(set_pmon)
 
similarity index 100%
rename from sysman/SLP_sysman_PG.h
rename to sysman/sysman_PG.h