Tizen 2.0 Release accepted/tizen_2.0/20130215.201753 submit/tizen_2.0/20130215.192240
authorHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 15:55:28 +0000 (00:55 +0900)
committerHyungKyu Song <hk76.song@samsung.com>
Fri, 15 Feb 2013 15:55:28 +0000 (00:55 +0900)
35 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
LICENSE.APLv2 [new file with mode: 0644]
NOTICE [new file with mode: 0644]
SLP_HAPTIC_PG.h [new file with mode: 0644]
TC/build.sh [new file with mode: 0755]
TC/execute.sh [new file with mode: 0755]
TC/tet_code [new file with mode: 0644]
TC/tet_scen [new file with mode: 0644]
TC/tetbuild.cfg [new file with mode: 0644]
TC/tetclean.cfg [new file with mode: 0644]
TC/tetexec.cfg [new file with mode: 0644]
TC/unit/Makefile [new file with mode: 0644]
TC/unit/tc_gen.sh [new file with mode: 0755]
TC/unit/tslist [new file with mode: 0644]
TC/unit/utc_MODULE_API_func.c.in [new file with mode: 0644]
TC/unit/utc_SystemFW_haptic_close_func.c [new file with mode: 0644]
TC/unit/utc_SystemFW_haptic_get_file_duration_func.c [new file with mode: 0644]
TC/unit/utc_SystemFW_haptic_open_func.c [new file with mode: 0644]
TC/unit/utc_SystemFW_haptic_play_file_func.c [new file with mode: 0644]
TC/unit/utc_SystemFW_haptic_play_monotone_func.c [new file with mode: 0644]
TC/unit/utc_SystemFW_haptic_stop_play_func.c [new file with mode: 0644]
haptic-plugin.pc.in [new file with mode: 0644]
haptic.pc.in [new file with mode: 0644]
image/SLP_devman_PG_haptic_architecture.png [new file with mode: 0644]
include/haptic.h [new file with mode: 0644]
include/haptic_ext_core.h [new file with mode: 0644]
include/haptic_legacy.h [new file with mode: 0644]
include/haptic_log.h [new file with mode: 0644]
include/haptic_module.h [new file with mode: 0644]
include/haptic_plugin_intf.h [new file with mode: 0644]
packaging/libhaptic.manifest [new file with mode: 0644]
packaging/libhaptic.spec [new file with mode: 0644]
src/haptic.c [new file with mode: 0644]
src/haptic_legacy.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..d14debe
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Jiyoung Yun <jy910.yun@samsung.com>\r
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a44f1ac
--- /dev/null
@@ -0,0 +1,59 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(haptic C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
+SET(VERSION 0.1)
+
+SET(SRCS
+       src/haptic.c
+       src/haptic_legacy.c)
+
+SET(HEADERS
+       SLP_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_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_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
+ADD_DEFINITIONS("-DENABLE_DLOG_OUT -DSLP_DEBUG")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+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(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION share/license RENAME ${PROJECT_NAME})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-plugin.pc DESTINATION lib/pkgconfig)
+
+FOREACH(hfile ${HEADERS})
+       INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/${PROJECT_NAME})
+ENDFOREACH(hfile)
diff --git a/LICENSE.APLv2 b/LICENSE.APLv2
new file mode 100644 (file)
index 0000000..9c13a9b
--- /dev/null
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..ccdad52
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
diff --git a/SLP_HAPTIC_PG.h b/SLP_HAPTIC_PG.h
new file mode 100644 (file)
index 0000000..02d20b4
--- /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 SLP_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/TC/build.sh b/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/TC/execute.sh b/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/TC/tet_code b/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/TC/tet_scen b/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/TC/tetbuild.cfg b/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/TC/tetclean.cfg b/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/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100644 (file)
index 0000000..0d9d39a
--- /dev/null
@@ -0,0 +1 @@
+TET_OUTPUT_CAPTURE=False
diff --git a/TC/unit/Makefile b/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/TC/unit/tc_gen.sh b/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/TC/unit/tslist b/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/TC/unit/utc_MODULE_API_func.c.in b/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/TC/unit/utc_SystemFW_haptic_close_func.c b/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/TC/unit/utc_SystemFW_haptic_get_file_duration_func.c b/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/TC/unit/utc_SystemFW_haptic_open_func.c b/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/TC/unit/utc_SystemFW_haptic_play_file_func.c b/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/TC/unit/utc_SystemFW_haptic_play_monotone_func.c b/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/TC/unit/utc_SystemFW_haptic_stop_play_func.c b/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-plugin.pc.in b/haptic-plugin.pc.in
new file mode 100644 (file)
index 0000000..9cfb39b
--- /dev/null
@@ -0,0 +1,13 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires:
+Cflags: -I${includedir}
diff --git a/haptic.pc.in b/haptic.pc.in
new file mode 100644 (file)
index 0000000..58f59cb
--- /dev/null
@@ -0,0 +1,14 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
diff --git a/image/SLP_devman_PG_haptic_architecture.png b/image/SLP_devman_PG_haptic_architecture.png
new file mode 100644 (file)
index 0000000..2d4c3f7
Binary files /dev/null and b/image/SLP_devman_PG_haptic_architecture.png differ
diff --git a/include/haptic.h b/include/haptic.h
new file mode 100644 (file)
index 0000000..eed32e4
--- /dev/null
@@ -0,0 +1,531 @@
+/*
+ * haptic
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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_PLAYING = 0,
+       HAPTIC_STATE_STOP,
+} 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 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_stime;               /**< Start time of the effect element in millisecond */
+       int haptic_duration;            /**< Duration of the effect element in millisecond */
+} 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[ini/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(const 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[ini/out] 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);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif         /* __HAPTIC_H__ */
diff --git a/include/haptic_ext_core.h b/include/haptic_ext_core.h
new file mode 100644 (file)
index 0000000..49f291b
--- /dev/null
@@ -0,0 +1,359 @@
+/*\r
+ * haptic\r
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+\r
+#ifndef __HAPTIC_EXT_CORE_H__\r
+#define __HAPTIC_EXT_CORE_H__\r
+\r
+#include <sys/types.h>\r
+#include <limits.h>\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/**\r
+ * @par Description:\r
+ *      Data types level for haptic extra functions.\r
+ */\r
+#define HAPTIC_MAX_MAGNITUDE                          10000 /*!< Maximum Force Magnitude */\r
+#define HAPTIC_MIN_MAGNITUDE                          0     /*!< Minimum Force Magnitude */\r
+\r
+/**\r
+ * @par Description:\r
+ *      Data types level for haptic extra functions.\r
+ */\r
+#define HAPTIC_MAX_EFFECT_NAME_LENGTH                 128   /*!< Maximum effect name length */\r
+#define HAPTIC_INVALID_INDEX                          -1    /*!< Invalid Index */\r
+\r
+/* DevicePropertyType */\r
+#define HAPTIC_DEVPROPTYPE_PRIORITY                   1 /*!< Property type constant to set device priority */\r
+#define HAPTIC_DEVPROPTYPE_DISABLE_EFFECTS            2 /*!< Property type constant to enable/disable effects on a device */\r
+#define HAPTIC_DEVPROPTYPE_STRENGTH                   3 /*!< Property type constant to set the strength (volume) on a device */\r
+#define HAPTIC_DEVPROPTYPE_MASTERSTRENGTH             4 /*!< Property type constant to set the strength (volume) on ALL devices */\r
+\r
+/* Device type returned by device_haptic_get_device_capability_int32 in 'xxxx' field of\r
+   'yyyy' struct for 'deviceCapabilityType' equal to\r
+   HAPTIC_DEVCAPTYPE_DEVICE_CATEGORY */\r
+#define HAPTIC_DEVICECATEGORY_IFC                     0 /*!< Device category constant for IFC Devices */\r
+#define HAPTIC_DEVICECATEGORY_IMPULSE                 1 /*!< Device category constant for Impulse Devices */\r
+#define HAPTIC_DEVICECATEGORY_VIRTUAL                 2 /*!< Device category constant for Virtual Devices */\r
+#define HAPTIC_DEVICECATEGORY_EMBEDDED                3 /*!< Device category constant for Embedded Devices */\r
+#define HAPTIC_DEVICECATEGORY_TETHERED                4 /*!< Device category constant for Tethered Devices */\r
+#define HAPTIC_DEVICECATEGORY_IMMERSION_USB           5 /*!< Device category constant for Immersion USB Devices */\r
+#define HAPTIC_DEVICECATEGORY_COMPOSITE               6 /*!< Device category constant for Composite Devices */\r
+\r
+/* Effect type returned by device_haptic_get_IVT_effect_type */\r
+#define HAPTIC_EFFECT_TYPE_PERIODIC                   0 /*!< Periodic Effect type constant */\r
+#define HAPTIC_EFFECT_TYPE_MAGSWEEP                   1 /*!< Magsweep Effect type constant */\r
+#define HAPTIC_EFFECT_TYPE_TIMELINE                   2 /*!< Timeline Effect type constant */\r
+#define HAPTIC_EFFECT_TYPE_STREAMING                  3 /*!< Streaming Effect type constant */\r
+#define HAPTIC_EFFECT_TYPE_WAVEFORM                   4 /*!< Waveform Effect type constant */\r
+\r
+/* Device capability type passed as input 'deviceCapabilityType' argument to device_haptic_get_device_capability_... */\r
+#define HAPTIC_DEVCAPTYPE_DEVICE_CATEGORY             0        /*!< Use device_haptic_get_device_capability_int32 >*/\r
+#define HAPTIC_DEVCAPTYPE_MAX_NESTED_REPEATS          1        /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_NUM_ACTUATORS               2        /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_ACTUATOR_TYPE               3        /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_NUM_EFFECT_SLOTS            4        /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_SUPPORTED_STYLES            5        /*!< Use device_haptic_get_device_capability_int32 */\r
+/* HAPTIC_DEVCAPTYPE_SUPPORTED_CONTROL_MODES is deprecated and will not be an available constant\r
+** in future versions of this software.  Please use HAPTIC_DEVCAPTYPE_SUPPORTED_STYLES instead. */\r
+#define HAPTIC_DEVCAPTYPE_SUPPORTED_CONTROL_MODES     HAPTIC_DEVCAPTYPE_SUPPORTED_STYLES\r
+#define HAPTIC_DEVCAPTYPE_MIN_PERIOD                  6  /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_MAX_PERIOD                  7  /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_MAX_EFFECT_DURATION         8  /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_SUPPORTED_EFFECTS           9  /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_DEVICE_NAME                 10 /*!< Use device_haptic_get_device_capability_string */\r
+#define HAPTIC_DEVCAPTYPE_MAX_ENVELOPE_TIME           11 /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_APIVERSIONNUMBER            12 /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_MAX_IVT_SIZE_TETHERED       13 /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_MAX_IVT_SIZE                14 /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_EDITION_LEVEL               15 /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_SUPPORTED_WAVE_TYPES        16 /*!< Use device_haptic_get_device_capability_int32 */\r
+#define HAPTIC_DEVCAPTYPE_HANDSET_INDEX               17 /*!< Use device_haptic_get_device_capability_int32 */\r
+\r
+/* Handles */\r
+#define HAPTIC_INVALID_EFFECT_HANDLE_VALUE            -1 /*!< Invalid Effect Handle */\r
+#define HAPTIC_INVALID_DEVICE_HANDLE_VALUE            -1 /*!< Invalid Device Handle */\r
+\r
+/* Periodic, MagSweep effect Styles are only 4 bits and may be combined with other flags */\r
+#define HAPTIC_STYLE_MASK                             0x0F    /*!< Style mask */\r
+\r
+/* Periodic, MagSweep effect Styles */\r
+#define HAPTIC_STYLE_SMOOTH                           0   /*!< "Smooth" style */\r
+#define HAPTIC_STYLE_STRONG                           1   /*!< "Strong" style */\r
+#define HAPTIC_STYLE_SHARP                            2   /*!< "Sharp" style  */\r
+\r
+#define HAPTIC_DEFAULT_STYLE                          HAPTIC_STYLE_STRONG\r
+\r
+/* HAPTIC_CONTROLMODE_ constants are deprecated and will not be available\r
+** in future versions of this software.  Please use the HAPTIC_STYLE_ constants instead. */\r
+#define HAPTIC_CONTROLMODE_SMOOTH                     HAPTIC_STYLE_SMOOTH\r
+#define HAPTIC_CONTROLMODE_STRONG                     HAPTIC_STYLE_STRONG\r
+#define HAPTIC_CONTROLMODE_SHARP                      HAPTIC_STYLE_SHARP\r
+\r
+#define HAPTIC_DEFAULT_CONTROLMODE                    HAPTIC_DEFAULT_STYLE\r
+\r
+/* Effect period resolution */\r
+#define HAPTIC_PERIOD_RESOLUTION_MICROSECOND          0x80000000\r
+\r
+/* Periodic effect Wave Types are only 4 bits and may be combined with other flags */\r
+#define HAPTIC_WAVETYPE_SHIFT                         4       /*!< Wave type shift */\r
+#define HAPTIC_WAVETYPE_MASK                          0xF0    /*!< Wave type mask */\r
+\r
+/* Periodic effect Wave Types */\r
+#define HAPTIC_WAVETYPE_SQUARE                        (1 << HAPTIC_WAVETYPE_SHIFT)  /*!< "Square" wave type */\r
+#define HAPTIC_WAVETYPE_TRIANGLE                      (2 << HAPTIC_WAVETYPE_SHIFT)  /*!< "Triangle" wave type */\r
+#define HAPTIC_WAVETYPE_SINE                          (3 << HAPTIC_WAVETYPE_SHIFT)  /*!< "Sine" wave type */\r
+#define HAPTIC_WAVETYPE_SAWTOOTHUP                    (4 << HAPTIC_WAVETYPE_SHIFT)  /*!< "Sawtooth Up" wave type */\r
+#define HAPTIC_WAVETYPE_SAWTOOTHDOWN                  (5 << HAPTIC_WAVETYPE_SHIFT)  /*!< "Sawtooth Down" wave type */\r
+\r
+#define HAPTIC_DEFAULT_WAVETYPE                       HAPTIC_WAVETYPE_SQUARE\r
+\r
+/* String length constants */\r
+#define HAPTIC_MAX_DEVICE_NAME_LENGTH                 64 /*!<Maximum device name length */\r
+#define HAPTIC_MAX_CAPABILITY_STRING_LENGTH           64 /*!<Maximum string length use by device_haptic_get_device_capability_string/ device_haptic_set_device_capability_string*/\r
+#define HAPTIC_MAX_PROPERTY_STRING_LENGTH             64 /*!<Maximum string length use by device_haptic_get_device_property_string/ device_haptic_set_device_property_string */\r
+\r
+/* Effect type support bit masks */\r
+#define HAPTIC_PERIODIC_EFFECT_SUPPORT                (1 << HAPTIC_EFFECT_TYPE_PERIODIC)  /*!< Bitmask for Periodic effect support */\r
+#define HAPTIC_MAGSWEEP_EFFECT_SUPPORT                (1 << HAPTIC_EFFECT_TYPE_MAGSWEEP)  /*!< Bitmask for Magsweep effect support */\r
+#define HAPTIC_TIMELINE_EFFECT_SUPPORT                (1 << HAPTIC_EFFECT_TYPE_TIMELINE)  /*!< Bitmask for Timeline effect support */\r
+#define HAPTIC_STREAMING_EFFECT_SUPPORT               (1 << HAPTIC_EFFECT_TYPE_STREAMING) /*!< Bitmask for Streaming effect support */\r
+#define HAPTIC_WAVEFORM_EFFECT_SUPPORT                (1 << HAPTIC_EFFECT_TYPE_WAVEFORM)  /*!< Bitmask for Waveform effect support */\r
+\r
+/* Effect Style support bit masks */\r
+#define HAPTIC_STYLE_SUPPORT_MASK                     0x0000FFFF              /*!< Effect style support mask */\r
+#define HAPTIC_STYLE_SMOOTH_SUPPORT                   (1 << HAPTIC_STYLE_SMOOTH) /*!< Bitmask for "Smooth" style support */\r
+#define HAPTIC_STYLE_STRONG_SUPPORT                   (1 << HAPTIC_STYLE_STRONG) /*!< Bitmask for "Strong" style support */\r
+#define HAPTIC_STYLE_SHARP_SUPPORT                    (1 << HAPTIC_STYLE_SHARP)  /*!< Bitmask for "Sharp" style support  */\r
+\r
+/* Wave type support bit masks */\r
+/* Starts at 0x10000 to allow combining the flag with the supported style (nControlMode) 32 bits flag */\r
+#define HAPTIC_WAVETYPE_SUPPORT_MASK                  0xFFFF0000                                                       /*!< Wave type support mask */\r
+#define HAPTIC_WAVETYPE_SQUARE_SUPPORT                (0x10000 << (HAPTIC_WAVETYPE_SQUARE >> HAPTIC_WAVETYPE_SHIFT))       /*!< Bitmask for "Square" wave type support */\r
+#define HAPTIC_WAVETYPE_TRIANGLE_SUPPORT              (0x10000 << (HAPTIC_WAVETYPE_TRIANGLE >> HAPTIC_WAVETYPE_SHIFT))     /*!< Bitmask for "Triangle" wave type support */\r
+#define HAPTIC_WAVETYPE_SINE_SUPPORT                  (0x10000 << (HAPTIC_WAVETYPE_SINE >> HAPTIC_WAVETYPE_SHIFT))         /*!< Bitmask for "Sine" wave type support  */\r
+#define HAPTIC_WAVETYPE_SAWTOOTHUP_SUPPORT            (0x10000 << (HAPTIC_WAVETYPE_SAWTOOTHUP >> HAPTIC_WAVETYPE_SHIFT))   /*!< Bitmask for "Saw tooth up" wave type support  */\r
+#define HAPTIC_WAVETYPE_SAWTOOTHDOWN_SUPPORT          (0x10000 << (HAPTIC_WAVETYPE_SAWTOOTHDOWN >> HAPTIC_WAVETYPE_SHIFT)) /*!< Bitmask for "Saw tooth down" wave type support  */\r
+\r
+/* HAPTIC_CONTROLMODE_*_SUPPORT constants are deprecated and will not be available\r
+** in future versions of this software.  Please use the HAPTIC_STYLE_*_SUPPORT constants instead. */\r
+#define HAPTIC_CONTROLMODE_SMOOTH_SUPPORT             HAPTIC_STYLE_SMOOTH_SUPPORT\r
+#define HAPTIC_CONTROLMODE_STRONG_SUPPORT             HAPTIC_STYLE_STRONG_SUPPORT\r
+#define HAPTIC_CONTROLMODE_SHARP_SUPPORT              HAPTIC_STYLE_SHARP_SUPPORT\r
+\r
+/* Device State constants */\r
+#define HAPTIC_DEVICESTATE_ATTACHED                   (1 << 0) /*!< Device is attached to the system */\r
+#define HAPTIC_DEVICESTATE_BUSY                       (1 << 1) /*!< Device is busy (playing effects) */\r
+\r
+/* Time in milliseconds */\r
+#define HAPTIC_TIME_INFINITE                          LONG_MAX /*!< Infinite time */\r
+\r
+/* Effect priority */\r
+#define HAPTIC_MIN_DEVICE_PRIORITY                    0x0 /*!< Minimum Effect priority */\r
+#define HAPTIC_MAX_DEV_DEVICE_PRIORITY                0x7 /*!< Maximum Effect priority for developers */\r
+#define HAPTIC_MAX_OEM_DEVICE_PRIORITY                0xF /*!< Maximum Effect priority for OEMs */\r
+#define HAPTIC_MAX_DEVICE_PRIORITY                    HAPTIC_MAX_OEM_DEVICE_PRIORITY    /*!< FOR BACKWARD COMPATIBILITY ONLY;\r
+                                                                                         new applications should use HAPTIC_MAX_DEV_DEVICE_PRIORITY\r
+                                                                                         or HAPTIC_MAX_OEM_DEVICE_PRIORITY */\r
+\r
+\r
+/* Device Actuator Type constants */\r
+#define HAPTIC_DEVACTUATORTYPE_ERM                    0\r
+#define HAPTIC_DEVACTUATORTYPE_BLDC                   1\r
+#define HAPTIC_DEVACTUATORTYPE_LRA                    2\r
+#define HAPTIC_DEVACTUATORTYPE_PIEZO                  4\r
+#define HAPTIC_DEVACTUATORTYPE_PIEZO_WAVE             4\r
+\r
+/* Device Default priority value */\r
+#define HAPTIC_DEVPRIORITY_DEFAULT                    0\r
+\r
+/* Repeat count */\r
+#define HAPTIC_REPEAT_COUNT_INFINITE                  255 /*!< Infinite repeat count */\r
+\r
+/* Streaming Sample */\r
+#define HAPTIC_MAX_STREAMING_SAMPLE_SIZE              255 /*!< Maximum size for streaming sample */\r
+\r
+/* Effect state returned by ImmVibeGetEffectState */\r
+#define HAPTIC_EFFECT_STATE_NOT_PLAYING               0 /*!< Not Playing and not paused */\r
+#define HAPTIC_EFFECT_STATE_PLAYING                   1 /*!< Playing */\r
+#define HAPTIC_EFFECT_STATE_PAUSED                    2 /*!< Paused */\r
+\r
+/* Edition levels */\r
+#define HAPTIC_EDITION_3000                           3000\r
+#define HAPTIC_EDITION_4000                           4000\r
+#define HAPTIC_EDITION_5000                           5000\r
+\r
+/* Element type for IVTElement structure that is used by ImmVibeInsertIVTElement, ImmVibeReadIVTElement and ImmVibeRemoveIVTElement */\r
+#define HAPTIC_ELEMTYPE_PERIODIC                      0\r
+#define HAPTIC_ELEMTYPE_MAGSWEEP                      1\r
+#define HAPTIC_ELEMTYPE_REPEAT                        2\r
+/* New in API v3.4 */\r
+#define HAPTIC_ELEMTYPE_WAVEFORM                      3\r
+\r
+/* Composite device */\r
+#define HAPTIC_MAX_LOGICAL_DEVICE_COUNT               16 /*!< Maximum number of device indices that can be passed to ImmVibeOpenCompositeDevice */\r
+\r
+/****************************************************************************\r
+ *\r
+ *  General macros\r
+ *\r
+ ****************************************************************************/\r
+#define HAPTIC_SUCCEEDED(n)                           ((n) >= 0)\r
+#define HAPTIC_FAILED(n)                              ((n) < 0)\r
+#define HAPTIC_IS_INVALID_DEVICE_HANDLE(n)            (((n) == 0) || ((n) == HAPTIC_INVALID_DEVICE_HANDLE_VALUE))\r
+#define HAPTIC_IS_INVALID_EFFECT_HANDLE(n)            (((n) == 0) || ((n) == HAPTIC_INVALID_EFFECT_HANDLE_VALUE))\r
+#define HAPTIC_IS_VALID_DEVICE_HANDLE(n)              (((n) != 0) && ((n) != HAPTIC_INVALID_DEVICE_HANDLE_VALUE))\r
+#define HAPTIC_IS_VALID_EFFECT_HANDLE(n)              (((n) != 0) && ((n) != HAPTIC_INVALID_EFFECT_HANDLE_VALUE))\r
+\r
+/****************************************************************************\r
+ *\r
+ *  Error and Return value codes.\r
+ *\r
+ ****************************************************************************/\r
+#define HAPTIC_S_SUCCESS                               0  /*!< Success */\r
+#define HAPTIC_S_FALSE                                 0  /*!< False */\r
+#define HAPTIC_S_TRUE                                  1  /*!< True */\r
+#define HAPTIC_W_NOT_PLAYING                           1  /*!< Effect is not playing */\r
+#define HAPTIC_W_INSUFFICIENT_PRIORITY                 2  /*!< Effect doesn't have enough priority to play: higher priority effect is playing on the device */\r
+#define HAPTIC_W_EFFECTS_DISABLED                      3  /*!< Effects are disabled on the device */\r
+#define HAPTIC_W_NOT_PAUSED                            4  /*!< The ImmVibeResumePausedEffect function cannot resume an effect that is not paused */\r
+#define HAPTIC_E_NOT_INITIALIZED                      -2  /*!< The API is already is not initialized */\r
+#define HAPTIC_E_INVALID_ARGUMENT                     -3  /*!< Invalid argument was used in a API function call */\r
+#define HAPTIC_E_FAIL                                 -4  /*!< Generic error */\r
+#define HAPTIC_E_INCOMPATIBLE_EFFECT_TYPE             -5  /*!< Incompatible Effect type has been passed into  API function call */\r
+#define HAPTIC_E_INCOMPATIBLE_CAPABILITY_TYPE         -6  /*!< Incompatible Capability type was used into one of the following functions */\r
+#define HAPTIC_E_INCOMPATIBLE_PROPERTY_TYPE           -7  /*!< Incompatible Property type was used into one of the following functions */\r
+#define HAPTIC_E_DEVICE_NEEDS_LICENSE                 -8  /*!< Access to the instance of the device is locked until a valid license key is provided. */\r
+#define HAPTIC_E_NOT_ENOUGH_MEMORY                    -9  /*!< The API function cannot allocate memory to complete the process */\r
+#define HAPTIC_E_SERVICE_NOT_RUNNING                  -10 /*!< ImmVibeService is not running */\r
+#define HAPTIC_E_INSUFFICIENT_PRIORITY                -11 /*!< Not enough priority to achieve the request (insufficient license key priority) */\r
+#define HAPTIC_E_SERVICE_BUSY                         -12 /*!< ImmVibeService is busy and failed to complete the request */\r
+#define HAPTIC_E_NOT_SUPPORTED                        -13 /*!< The API function is not supported by this version of the API */\r
+\r
+/****************************************************************************\r
+ *\r
+ *  Stuctures\r
+ *\r
+ ****************************************************************************/\r
+typedef struct\r
+{\r
+       int duration;\r
+       int magnitude;\r
+       int period;\r
+       int style;\r
+       int attacktime;\r
+       int attacklevel;\r
+       int fadetime;\r
+       int fadelevel;\r
+} HapticPeriodic;\r
+\r
+typedef struct\r
+{\r
+       int duration;\r
+       int magnitude;\r
+       int period;\r
+       int style;\r
+       int attacktime;\r
+       int attacklevel;\r
+       int fadetime;\r
+       int fadelevel;\r
+       int actuatorindex;\r
+} HapticPeriodic2;\r
+\r
+typedef struct\r
+{\r
+       int duration;\r
+       int magnitude;\r
+       int style;\r
+       int attacktime;\r
+       int attacklevel;\r
+       int fadetime;\r
+       int fadelevel;\r
+} HapticMagSweep;\r
+\r
+typedef struct\r
+{\r
+       int duration;\r
+       int magnitude;\r
+       int style;\r
+       int attacktime;\r
+       int attacklevel;\r
+       int fadetime;\r
+       int fadelevel;\r
+       int actuatorindex;\r
+} HapticMagSweep2;\r
+\r
+typedef struct\r
+{\r
+       int count;\r
+       int duration;\r
+} HapticRepeat;\r
+\r
+typedef struct\r
+{\r
+    const unsigned char *data;\r
+    int datasize;\r
+    int samplingrate;\r
+    int bitdepth;\r
+    int magnitude;\r
+    int actuatorindex;\r
+} HapticWaveform;\r
+\r
+typedef struct\r
+{\r
+    int elementtype;\r
+    int time;\r
+    union\r
+    {\r
+        HapticPeriodic periodic;\r
+        HapticMagSweep magsweep;\r
+        HapticRepeat   repeat;\r
+    } TypeSpecific;\r
+} HapticElement;\r
+\r
+typedef struct\r
+{\r
+    int elementtype;\r
+    int time;\r
+    union\r
+    {\r
+        HapticPeriodic2        periodic;\r
+        HapticMagSweep2        magsweep;\r
+        HapticRepeat   repeat;\r
+    } TypeSpecific;\r
+} HapticElement2;\r
+\r
+typedef struct\r
+{\r
+    int elementtype;\r
+    int time;\r
+    union\r
+    {\r
+        HapticPeriodic2        periodic;\r
+        HapticMagSweep2        magsweep;\r
+        HapticRepeat   repeat;\r
+        HapticWaveform waveform;\r
+    } TypeSpecific;\r
+} HapticElement3;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+#endif /* __HAPTIC_EXT_CORE_H__ */\r
diff --git a/include/haptic_legacy.h b/include/haptic_legacy.h
new file mode 100644 (file)
index 0000000..c7c13d7
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * haptic
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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_LEGACY_H__
+#define __HAPTIC_LEGACY_H__
+
+#include "haptic.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file        haptic_legacy.h
+ * @brief       This file contains the prototypes of the haptic API
+ */
+
+int _haptic_get_count(int *device_number);
+int _haptic_open(haptic_device_e device_index, haptic_device_h *device_handle);
+int _haptic_close(haptic_device_h device_handle);
+int _haptic_vibrate_monotone(haptic_device_h device_handle, int duration, int feedback_level, int priority_level, haptic_effect_h *effect_handle);
+int _haptic_vibrate_file(haptic_device_h device_handle, const char *file_name, int iteration, int feedback_level, int priority_level, haptic_effect_h *effect_handle);
+int _haptic_vibrate_buffer(haptic_device_h device_handle, const unsigned char *vibe_buffer, int iteration, int feedback_level, int priority_level, haptic_effect_h *effect_handle);
+int _haptic_stop_effect(haptic_device_h device_handle, haptic_effect_h effect_handle);
+int _haptic_stop_all_effects(haptic_device_h device_handle);
+int _haptic_get_effect_state(haptic_device_h device_handle, haptic_effect_h effect_handle, haptic_state_e *effect_state);
+int _haptic_create_effect(const unsigned char *vibe_buffer, int max_bufsize, haptic_effect_element_s *elem_arr, int max_elemcnt);
+int _haptic_save_effect(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path);
+int _haptic_get_file_duration(haptic_device_h device_handle, const char *file_path, int *file_duration);
+int _haptic_get_buffer_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int *buffer_duration);
+
+#ifdef __cplusplus
+}
+#endif
+#endif         /* __HAPTIC_LEGACY_H__ */
diff --git a/include/haptic_log.h b/include/haptic_log.h
new file mode 100644 (file)
index 0000000..5273e06
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * haptic
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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("<%s:%4d> " fmt "\n", __func__, __LINE__, ##args)
+    #define HAPTIC_ERROR(fmt, args...)     SLOGE("<%s:%4d> " fmt "\n", __func__, __LINE__, ##args)
+#else
+    #define HAPTIC_LOG(x, ...)
+    #define HAPTIC_ERROR(x, ...)
+#endif
+
+#endif //__HAPTIC_LOG_H__
diff --git a/include/haptic_module.h b/include/haptic_module.h
new file mode 100644 (file)
index 0000000..e91e9e4
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * haptic
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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_stime;           /**< Start time of the effect element in millisecond */
+    int haptic_duration;        /**< Duration of the effect element in millisecond */
+} haptic_module_effect_element;
+
+#endif  /* __HAPTIC_MODULE_H__ */
diff --git a/include/haptic_plugin_intf.h b/include/haptic_plugin_intf.h
new file mode 100644 (file)
index 0000000..c6cbc22
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * haptic
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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) (const 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) (void);
+} haptic_plugin_interface;
+
+const haptic_plugin_interface *get_haptic_plugin_interface();
+
+#endif /* __HAPTIC_PLUGIN_INTF_H__ */
diff --git a/packaging/libhaptic.manifest b/packaging/libhaptic.manifest
new file mode 100644 (file)
index 0000000..3256181
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+<request>
+       <domain name="_"/>
+</request>
+</manifest>
diff --git a/packaging/libhaptic.spec b/packaging/libhaptic.spec
new file mode 100644 (file)
index 0000000..065a743
--- /dev/null
@@ -0,0 +1,85 @@
+#sbs-git:slp/pkgs/d/devman devman 0.1.6 5bf2e95e0bb15c43ff928f7375e1978b0accb0f8
+Name:       libhaptic
+Summary:    Haptic library
+Version:    0.1.0
+Release:    3
+Group:      System/Libraries
+License:    Apache License, Version 2.0
+Source0:    %{name}-%{version}.tar.gz
+Source1:    libhaptic.manifest
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(capi-base-common)
+
+%description
+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)
+
+%prep
+%setup -q
+
+%build
+cp %{SOURCE1} .
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+mkdir -p %{buildroot}%{_datadir}/license
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files -n libhaptic
+%manifest libhaptic.manifest
+%defattr(-,root,root,-)
+%{_libdir}/libhaptic.so.*
+%{_datadir}/license/haptic
+
+%files -n libhaptic-devel
+%defattr(-,root,root,-)
+%{_includedir}/haptic/haptic.h
+%{_includedir}/haptic/SLP_HAPTIC_PG.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
+%{_libdir}/pkgconfig/haptic-plugin.pc
+
+%changelog
+* Mon Jan 07 2013 - Jae-young Hwang <j-zero.hwang@samsung.com>
+- Change libhpatic-module.so file path
+- Tag : libhaptic_0.1.0-3
+
+* Tue Oct 23 2012 - Jiyoung Yun <jy910.yun@samsung.com>
+- remove capi-system-info pkg to fix build break error
+- Tag : libhaptic_0.1.0-1
+
+* Mon Oct 15 2012 - Jiyoung Yun <jy910.yun@samsung.com>
+- Seperate the haptic module from devman
+- Implement source code
+- Tag : libhaptic_0.1.0-0
diff --git a/src/haptic.c b/src/haptic.c
new file mode 100644 (file)
index 0000000..d79fa05
--- /dev/null
@@ -0,0 +1,571 @@
+/*
+ * haptic
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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 <sys/stat.h>
+#include "haptic.h"
+#include "haptic_legacy.h"
+#include "haptic_log.h"
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#define HAPTIC_SUCCEEDED(n)                    ((n) == HAPTIC_ERROR_NONE)
+#define HAPTIC_FAILED(n)                       ((n) != HAPTIC_ERROR_NONE)
+
+API
+int haptic_get_count(int *device_number)
+{
+       int err = -1;
+       int number = -1;
+
+       if (device_number == NULL) {
+               HAPTIC_ERROR("Invalid parameter : device_number(NULL)");
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = _haptic_get_count(&number);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_get_count is failed : %d", err);
+               return err;
+       }
+
+       *device_number = number;
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_open(haptic_device_e device_index, haptic_device_h *device_handle)
+{
+       int err = -1;
+       haptic_device_h handle = NULL;
+
+       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;
+       }
+
+       err = _haptic_open(device_index, &handle);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_open is failed : %d", err);
+               return err;
+       }
+
+       *device_handle = handle;
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_close(haptic_device_h device_handle)
+{
+       int err = -1;
+
+       if (device_handle < 0) {
+               HAPTIC_ERROR("Invalid parameter : device_handle(%d)", device_handle);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = _haptic_close(device_handle);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_close is failed : %d", err);
+               return err;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_vibrate_monotone(haptic_device_h device_handle, int duration, haptic_effect_h *effect_handle)
+{
+       int err = -1;
+       haptic_effect_h handle = NULL;
+
+       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 (effect_handle == NULL) {
+               HAPTIC_LOG("effect_handle is NULL");
+       }
+
+       err = _haptic_vibrate_monotone(device_handle, duration, HAPTIC_FEEDBACK_AUTO, HAPTIC_PRIORITY_MIN, &handle);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_vibrate_monotone is failed : %d", err);
+               return err;
+       }
+
+       if (effect_handle != NULL) {
+               *effect_handle = handle;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+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 err = -1;
+       haptic_effect_h handle = NULL;
+
+       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 (effect_handle == NULL) {
+               HAPTIC_LOG("effect_handle is NULL");
+       }
+
+       err = _haptic_vibrate_monotone(device_handle, duration, feedback, priority, &handle);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_vibrate_monotone is failed : %d", err);
+               return err;
+       }
+
+       if (effect_handle != NULL) {
+               *effect_handle = handle;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_vibrate_file(haptic_device_h device_handle, const char *file_path, haptic_effect_h *effect_handle)
+{
+       int err = -1;
+       haptic_effect_h handle = NULL;
+       struct stat buf;
+
+       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 (effect_handle == NULL) {
+               HAPTIC_LOG("effect_handle is NULL");
+       }
+
+       err = _haptic_vibrate_file(device_handle, file_path, HAPTIC_ITERATION_ONCE, HAPTIC_FEEDBACK_AUTO, HAPTIC_PRIORITY_MIN, &handle);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_vibrate_file is failed : %d", err);
+               return err;
+       }
+
+       if (effect_handle != NULL) {
+               *effect_handle = handle;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+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 err = -1;
+       haptic_effect_h handle = NULL;
+       struct stat buf;
+
+       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 (effect_handle == NULL) {
+               HAPTIC_LOG("effect_handle is NULL");
+       }
+
+       err = _haptic_vibrate_file(device_handle, file_path, iteration, feedback, priority, &handle);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_vibrate_file is failed : %d", err);
+               return err;
+       }
+
+       if (effect_handle != NULL) {
+               *effect_handle = 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)
+{
+       int err = -1;
+       haptic_effect_h handle = NULL;
+
+       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 (effect_handle == NULL) {
+               HAPTIC_LOG("effect_handle is NULL");
+       }
+
+       err = _haptic_vibrate_buffer(device_handle, vibe_buffer, HAPTIC_ITERATION_ONCE, HAPTIC_FEEDBACK_AUTO, HAPTIC_PRIORITY_MIN, &handle);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_vibrate_buffer is failed : %d", err);
+               return err;
+       }
+
+       if (effect_handle != NULL) {
+               *effect_handle = handle;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+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)
+{
+       int err = -1;
+       haptic_effect_h handle = NULL;
+
+       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 (effect_handle == NULL) {
+               HAPTIC_LOG("effect_handle is NULL");
+       }
+
+       err = _haptic_vibrate_buffer(device_handle, vibe_buffer, iteration, feedback, priority, &handle);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_vibrate_buffer is failed : %d", err);
+               return err;
+       }
+
+       if (effect_handle != NULL) {
+               *effect_handle = handle;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_stop_effect(haptic_device_h device_handle, haptic_effect_h effect_handle)
+{
+       int err = -1;
+
+       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;
+       }
+
+       err = _haptic_stop_effect(device_handle, effect_handle);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_stop_effect is failed : %d", err);
+               return err;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_stop_all_effects(haptic_device_h device_handle)
+{
+       int err = -1;
+
+       if (device_handle < 0) {
+               HAPTIC_ERROR("Invalid parameter : device_handle(%d)", device_handle);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = _haptic_stop_all_effects(device_handle);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_stop_all_effects is failed : %d", err);
+               return err;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_get_effect_state(haptic_device_h device_handle, haptic_effect_h effect_handle, haptic_state_e *state)
+{
+       int err = -1;
+
+       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 (state == NULL) {
+               HAPTIC_ERROR("Invalid parameter : state(NULL)", state);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = _haptic_get_effect_state(device_handle, effect_handle, state);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_get_effect_state is failed : %d", err);
+               return err;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_create_effect(const unsigned char *vibe_buffer,
+                         int max_bufsize,
+                         haptic_effect_element_s *elem_arr,
+                         int max_elemcnt)
+{
+       int err = -1;
+
+       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;
+       }
+
+       err = _haptic_create_effect(vibe_buffer, max_bufsize, elem_arr, max_elemcnt);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_create_effect is failed : %d", err);
+               return err;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_save_effect(const unsigned char *vibe_buffer,
+                       int max_bufsize,
+                       const char *file_path)
+{
+       int err = -1;
+       struct stat buf;
+
+       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;
+       }
+
+       err = _haptic_save_effect(vibe_buffer, max_bufsize, file_path);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_save_effect is failed : %d", err);
+               return err;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_get_file_duration(haptic_device_h device_handle, const char *file_path, int *duration)
+{
+       int err = -1;
+       struct stat buf;
+
+       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 (duration == NULL) {
+               HAPTIC_ERROR("Invalid parameter : duration(%d)", duration);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = _haptic_get_file_duration(device_handle, file_path, duration);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_get_file_duration is failed : %d", err);
+               return err;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+API
+int haptic_get_buffer_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int *duration)
+{
+       int err = -1;
+
+       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 (duration == NULL) {
+               HAPTIC_ERROR("Invalid parameter : duration(%d)", duration);
+               return HAPTIC_ERROR_INVALID_PARAMETER;
+       }
+
+       err = _haptic_get_buffer_duration(device_handle, vibe_buffer, duration);
+       if (HAPTIC_FAILED(err)) {
+               HAPTIC_ERROR("_haptic_get_buffer_duration is failed : %d", err);
+               return err;
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
diff --git a/src/haptic_legacy.c b/src/haptic_legacy.c
new file mode 100644 (file)
index 0000000..75e7d44
--- /dev/null
@@ -0,0 +1,454 @@
+/*
+ * haptic
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * 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_legacy.h"
+#include "haptic_plugin_intf.h"
+#include "haptic_log.h"
+
+#define HAPTIC_MODULE_PATH             "/usr/lib/libhaptic-module.so"
+
+static enum {
+       MODULE_NONE = 0,
+       MODULE_EXIST,
+};
+
+static int has_haptic_module = MODULE_NONE;
+
+/* Haptic Plugin Interface */
+static void *dlopen_handle;
+static const haptic_plugin_interface *plugin_intf;
+
+/* START of Static Function Section */
+static haptic_feedback_e __get_setting_feedback_level()
+{
+       int setting_fb_level = -1;
+
+       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;
+}
+
+static haptic_error_e __error_to_haptic_type(int error)
+{
+       switch(error) {
+       case HAPTIC_MODULE_ERROR_NONE          : return HAPTIC_ERROR_NONE;
+       case HAPTIC_MODULE_NOT_INITIALIZED     : return HAPTIC_ERROR_NOT_INITIALIZED;
+       case HAPTIC_MODULE_INVALID_ARGUMENT    : return HAPTIC_ERROR_INVALID_PARAMETER;
+       default:
+               break;
+       }
+       return HAPTIC_ERROR_OPERATION_FAILED;
+}
+/* END of Static Function Section */
+
+/* START: haptic legacy APIs */
+int _haptic_get_count(int *device_number)
+{
+       int ret = -1;
+       int number = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+       ret = plugin_intf->haptic_internal_get_device_count(&number);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_get_device_count is failed : %d", ret);
+               return __error_to_haptic_type(ret);
+       }
+
+       *device_number = number;
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_open(haptic_device_e device_index, haptic_device_h *device_handle)
+{
+       int ret = -1;
+       int handle = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+       ret = plugin_intf->haptic_internal_open_device(device_index, &handle);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_open_device is failed : %d", ret);
+               return __error_to_haptic_type(ret);
+       }
+
+       *device_handle = (haptic_device_h)handle;
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_close(haptic_device_h device_handle)
+{
+       int ret = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+       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 __error_to_haptic_type(ret);
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_vibrate_monotone(haptic_device_h device_handle, int duration, int feedback, int priority, haptic_effect_h *effect_handle)
+{
+       int ret = -1;
+       int handle = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+       if (feedback == HAPTIC_FEEDBACK_AUTO) {
+               HAPTIC_LOG("Auto feedback level, feedback value will be changed");
+               feedback = __get_setting_feedback_level();
+       }
+
+       if (feedback == HAPTIC_FEEDBACK_0) {
+               HAPTIC_LOG("feedback_level is 0, so do not vibe");
+               return HAPTIC_ERROR_NONE;
+       }
+
+       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 __error_to_haptic_type(ret);
+       }
+
+       *effect_handle = (haptic_effect_h)handle;
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_vibrate_file(haptic_device_h device_handle, const char *file_name, int iteration, int feedback, int priority, haptic_effect_h *effect_handle)
+{
+       int ret = -1;
+       int handle = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+       if (feedback == HAPTIC_FEEDBACK_AUTO) {
+               HAPTIC_LOG("Auto feedback level, feedback value will be changed");
+               feedback = __get_setting_feedback_level();
+       }
+
+       if (feedback == HAPTIC_FEEDBACK_0) {
+               HAPTIC_LOG("feedback_level is 0, so do not vibe");
+               return HAPTIC_ERROR_NONE;
+       }
+
+       HAPTIC_LOG("file_name : %s, iteration : %d, feedback : %d, priority : %d", file_name, iteration, feedback, priority);
+       ret = plugin_intf->haptic_internal_vibrate_file((int)device_handle, file_name, iteration, feedback, priority, &handle);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_vibrate_file is failed : %d", ret);
+               return __error_to_haptic_type(ret);
+       }
+
+       *effect_handle = (haptic_effect_h)handle;
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_vibrate_buffer(haptic_device_h device_handle, const unsigned char *vibe_buffer, int iteration, int feedback, int priority, haptic_effect_h *effect_handle)
+{
+       int ret = -1;
+       int handle = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+/*
+       if (device_handle_count == 0) {
+               HAPTIC_ERROR("Haptic device is not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+*/
+
+       if (feedback == HAPTIC_FEEDBACK_AUTO) {
+               HAPTIC_LOG("Auto feedback level, feedback value will be changed");
+               feedback = __get_setting_feedback_level();
+       }
+
+       if (feedback == HAPTIC_FEEDBACK_0) {
+               HAPTIC_LOG("feedback_level is 0, so do not vibe");
+               return HAPTIC_ERROR_NONE;
+       }
+
+       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 __error_to_haptic_type(ret);
+       }
+
+       *effect_handle = (haptic_effect_h)handle;
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_stop_effect(haptic_device_h device_handle, haptic_effect_h effect_handle)
+{
+       int ret = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+       ret = plugin_intf->haptic_internal_stop_effect((int)device_handle, (int)effect_handle);
+       if (ret != HAPTIC_MODULE_ERROR_NONE) {
+               HAPTIC_ERROR("haptic_internal_stop_effect is failed : %d", ret);
+               return __error_to_haptic_type(ret);
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_stop_all_effects(haptic_device_h device_handle)
+{
+       int ret = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+       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 __error_to_haptic_type(ret);
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_get_effect_state(haptic_device_h device_handle, haptic_effect_h effect_handle, haptic_state_e *effect_state)
+{
+       int ret = -1;
+       int state = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+/*
+       if (device_handle_count == 0) {
+               HAPTIC_ERROR("Haptic device is not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+*/
+
+       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 __error_to_haptic_type(ret);
+       }
+
+       *effect_state = state;
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_create_effect(const unsigned char *vibe_buffer, int max_bufsize, haptic_effect_element_s *elem_arr, int max_elemcnt)
+{
+       int ret = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+       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 __error_to_haptic_type(ret);
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_save_effect(const unsigned char *vibe_buffer, int max_bufsize, const char *file_path)
+{
+       int ret = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+/*
+       if (device_handle_count == 0) {
+               HAPTIC_ERROR("Haptic device is not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+*/
+
+       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 __error_to_haptic_type(ret);
+       }
+
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_get_file_duration(haptic_device_h device_handle, const char *file_path, int *file_duration)
+{
+       int ret = -1;
+       int duration = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+/*
+       if (device_handle_count == 0) {
+               HAPTIC_ERROR("Haptic device is not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+*/
+
+       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 __error_to_haptic_type(ret);
+       }
+
+       *file_duration = duration;
+       return HAPTIC_ERROR_NONE;
+}
+
+int _haptic_get_buffer_duration(haptic_device_h device_handle, const unsigned char *vibe_buffer, int *buffer_duration)
+{
+       int ret = -1;
+       int duration = -1;
+
+       if (has_haptic_module == MODULE_NONE) {
+               HAPTIC_ERROR("%s() is not supported without specific haptic module", __func__);
+               return HAPTIC_ERROR_NOT_SUPPORTED_DEVICE;
+       }
+
+/*
+       if (device_handle_count == 0) {
+               HAPTIC_ERROR("Haptic device is not initialized");
+               return HAPTIC_ERROR_NOT_INITIALIZED;
+       }
+*/
+
+       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 __error_to_haptic_type(ret);
+       }
+
+       *buffer_duration = duration;
+       return HAPTIC_ERROR_NONE;
+}
+/* END: haptic legacy APIs */
+
+static void __attribute__ ((constructor)) module_init()
+{
+       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;
+       }
+
+       has_haptic_module = MODULE_EXIST;
+       HAPTIC_LOG("This device can vibe");
+       return;
+
+EXIT:
+       has_haptic_module = MODULE_NONE;
+       HAPTIC_LOG("This device can not vibe");
+       return;
+}
+
+static void __attribute__ ((destructor)) module_fini()
+{
+       if (has_haptic_module == MODULE_NONE)
+               return;
+
+       if (dlopen_handle) {
+               dlclose(dlopen_handle);
+       }
+}