From d7924dddf4ede186e79adeb9de9769514640c2cd Mon Sep 17 00:00:00 2001 From: Seongho Jeong Date: Thu, 20 Sep 2012 23:46:24 +0900 Subject: [PATCH] 2.0 alpha Change-Id: I77bb92a46f58638571aa6e31d5a7aa06584be410 Signed-off-by: Seongho Jeong --- CMakeLists.txt | 40 +- TC/tet_code | 0 TC/tet_scen | 0 TC/tetbuild.cfg | 0 TC/tetclean.cfg | 0 TC/tetexec.cfg | 0 debian/changelog | 32 +- debian/control | 0 debian/libdevman-0.postinst.in | 0 debian/libdevman-0.postrm.in | 0 debian/libdevman-dev.install.in | 4 + debian/libdevman-haptic-dev.install.in | 1 - debian/rules | 2 - device_haptic.c | 1494 --------------- devices/CMakeLists.txt | 0 devices/haptic.c | 20 +- devices/jack_35pi.c | 16 +- devices/jack_microusb.c | 34 +- devices/led.c | 12 +- devices/mmc.c | 73 +- devices/power.c | 14 +- devices/power_supply_battery.c | 6 +- devices/power_supply_pmic.c | 12 +- devices/uart.c | 24 +- devices/video.c | 103 +- devman.pc.in | 2 +- devman_haptic.pc.in | 2 +- devman_plugin.pc.in | 2 +- image/SLP_devman_PG_architecture.png | Bin image/SLP_devman_PG_haptic_architecture.png | Bin SLP_devman_PG.h => include/SLP_devman_PG.h | 132 +- device_engine.h => include/device_engine.h | 4 +- device_haptic.h => include/device_haptic.h | 10 +- .../device_haptic_tsp4000_pattern.h | 6 +- device_plugin.h => include/device_plugin.h | 0 devlog.h => include/devlog.h | 12 +- devman.h => include/devman.h | 389 ++-- include/devman_error.h | 65 + devman_haptic.h => include/devman_haptic.h | 133 +- devman_haptic_ext.h => include/devman_haptic_ext.h | 12 +- .../devman_haptic_ext_core.h | 6 +- .../devman_haptic_plugin_intf.h | 3 +- include/devman_image.h | 245 +++ devman_internal.h => include/devman_internal.h | 6 +- include/devman_managed.h | 42 + .../devman_plugin_intf.h | 15 +- packaging/devman.manifest | 5 - packaging/devman.spec | 29 +- packaging/devman.yaml | 4 +- src/device_convert.c | 553 ++++++ device_engine.c => src/device_engine.c | 7 +- src/device_haptic.c | 2012 ++++++++++++++++++++ device_plugin.c => src/device_plugin.c | 0 devman_internal.c => src/devman_internal.c | 8 +- display_wd.c => src/display_wd.c | 29 +- if_generic.c => src/if_generic.c | 54 +- if_legacy.c => src/if_legacy.c | 136 +- 57 files changed, 3632 insertions(+), 2178 deletions(-) mode change 100755 => 100644 CMakeLists.txt mode change 100755 => 100644 TC/tet_code mode change 100755 => 100644 TC/tet_scen mode change 100755 => 100644 TC/tetbuild.cfg mode change 100755 => 100644 TC/tetclean.cfg mode change 100755 => 100644 TC/tetexec.cfg mode change 100755 => 100644 debian/changelog mode change 100755 => 100644 debian/control mode change 100755 => 100644 debian/libdevman-0.postinst.in mode change 100755 => 100644 debian/libdevman-0.postrm.in mode change 100755 => 100644 debian/libdevman-haptic-dev.install.in delete mode 100644 device_haptic.c mode change 100755 => 100644 devices/CMakeLists.txt mode change 100755 => 100644 devices/haptic.c mode change 100755 => 100644 devices/jack_35pi.c mode change 100755 => 100644 devices/jack_microusb.c mode change 100755 => 100644 devices/led.c mode change 100755 => 100644 devices/mmc.c mode change 100755 => 100644 devices/power_supply_battery.c mode change 100755 => 100644 devices/power_supply_pmic.c mode change 100755 => 100644 devices/uart.c mode change 100755 => 100644 devices/video.c mode change 100755 => 100644 image/SLP_devman_PG_architecture.png mode change 100755 => 100644 image/SLP_devman_PG_haptic_architecture.png rename SLP_devman_PG.h => include/SLP_devman_PG.h (87%) rename device_engine.h => include/device_engine.h (99%) mode change 100755 => 100644 rename device_haptic.h => include/device_haptic.h (91%) mode change 100755 => 100644 rename device_haptic_tsp4000_pattern.h => include/device_haptic_tsp4000_pattern.h (99%) rename device_plugin.h => include/device_plugin.h (100%) rename devlog.h => include/devlog.h (96%) rename devman.h => include/devman.h (68%) mode change 100755 => 100644 create mode 100644 include/devman_error.h rename devman_haptic.h => include/devman_haptic.h (80%) mode change 100755 => 100644 rename devman_haptic_ext.h => include/devman_haptic_ext.h (99%) rename devman_haptic_ext_core.h => include/devman_haptic_ext_core.h (98%) mode change 100755 => 100644 rename devman_haptic_plugin_intf.h => include/devman_haptic_plugin_intf.h (96%) create mode 100644 include/devman_image.h rename devman_internal.h => include/devman_internal.h (94%) create mode 100644 include/devman_managed.h rename devman_plugin_intf.h => include/devman_plugin_intf.h (88%) mode change 100755 => 100644 delete mode 100644 packaging/devman.manifest mode change 100755 => 100644 packaging/devman.yaml create mode 100644 src/device_convert.c rename device_engine.c => src/device_engine.c (95%) mode change 100755 => 100644 create mode 100644 src/device_haptic.c rename device_plugin.c => src/device_plugin.c (100%) rename devman_internal.c => src/devman_internal.c (96%) rename display_wd.c => src/display_wd.c (83%) mode change 100755 => 100644 rename if_generic.c => src/if_generic.c (67%) mode change 100755 => 100644 rename if_legacy.c => src/if_legacy.c (67%) mode change 100755 => 100644 diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100755 new mode 100644 index 8d667ec..c794fed --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,30 +5,38 @@ INCLUDE(FindPkgConfig) pkg_check_modules(rpkgs REQUIRED vconf dlog - heynoti) + heynoti + iniparser) ADD_DEFINITIONS(${rpkgs_CFLAGS}) SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRAINTS true) SET(SRCS - device_plugin.c - device_engine.c - device_haptic.c - if_legacy.c - if_generic.c - devman_internal.c) + src/device_plugin.c + src/device_engine.c + src/device_haptic.c + src/device_convert.c + src/if_legacy.c + src/if_generic.c + src/devman_internal.c) SET(HEADERS - devman.h - devman_haptic.h - devman_haptic_ext.h - devman_haptic_ext_core.h - devman_haptic_plugin_intf.h - devman_plugin_intf.h - SLP_devman_PG.h) + include/devman.h + include/devman_managed.h + include/devman_image.h + include/devman_error.h + include/devman_haptic.h + include/devman_haptic_ext.h + include/devman_haptic_ext_core.h + include/devman_haptic_plugin_intf.h + include/devman_plugin_intf.h + include/SLP_devman_PG.h) INCLUDE(devices/CMakeLists.txt) +SET(INC_DIR include) +INCLUDE_DIRECTORIES(${INC_DIR}) + SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "\${prefix}") SET(LIBDIR "\${prefix}/lib") @@ -40,8 +48,6 @@ SET(UDEV_RULES_PATH ${CMAKE_DEVMAN_RSRC_PREFIX}/udev-rules) SET(UDEV_RULES udev-files/91-devman.rules) SET(RC_LOCAL_SCRIPT devman) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g") @@ -56,7 +62,7 @@ ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} ${TARGET_SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${rpkgs_LDFLAGS} "-ldl") SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION}) -ADD_EXECUTABLE(display_wd display_wd.c) +ADD_EXECUTABLE(display_wd src/display_wd.c) TARGET_LINK_LIBRARIES(display_wd ${pkgs_LDFLAGS} ${PROJECT_NAME}) INSTALL(TARGETS display_wd DESTINATION bin) diff --git a/TC/tet_code b/TC/tet_code old mode 100755 new mode 100644 diff --git a/TC/tet_scen b/TC/tet_scen old mode 100755 new mode 100644 diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg old mode 100755 new mode 100644 diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg old mode 100755 new mode 100644 diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg old mode 100755 new mode 100644 diff --git a/debian/changelog b/debian/changelog old mode 100755 new mode 100644 index 456bec9..9645ddc --- a/debian/changelog +++ b/debian/changelog @@ -1,31 +1,7 @@ -devman (0.1.6-90) unstable; urgency=low +devman (0.1.8-1) unstable; urgency=low - * support mDNIe, battery health & sliding keyboard + * Tizen 2.0 release * Git: slp/pkgs/d/devman - * Tag: devman_0.1.6-90 + * Tag: devman_0.1.8-1 - -- Jinkun Jang Mon, 09 Apr 2012 14:35:44 +0900 - -devman (0.1.6-77) unstable; urgency=low - - * Fix JIRA Issue - * Git: pkgs/d/devman - * Tag: devman_0.1.6-77 - - -- DongGi Jang Thu, 22 Dec 2011 17:52:51 +0900 - -devman (0.1.6-76) unstable; urgency=low - - * sync version - * Git: pkgs/d/devman - * Tag: devman_0.1.6-76 - - -- Jinkun Jang Thu, 15 Dec 2011 10:50:49 +0900 - -devman (0.0.1-1) unstable; urgency=low - - * initial release - * Git: pkgs/d/devman - * Tag: devman_0.0.1-1 - - -- Jinkun Jang Wed, 07 Dec 2011 12:50:49 +0900 + -- Jiyoung Yun Mon, 30 Jul 2012 21:36:10 +0900 diff --git a/debian/control b/debian/control old mode 100755 new mode 100644 diff --git a/debian/libdevman-0.postinst.in b/debian/libdevman-0.postinst.in old mode 100755 new mode 100644 diff --git a/debian/libdevman-0.postrm.in b/debian/libdevman-0.postrm.in old mode 100755 new mode 100644 diff --git a/debian/libdevman-dev.install.in b/debian/libdevman-dev.install.in index 84457c6..6b248b0 100644 --- a/debian/libdevman-dev.install.in +++ b/debian/libdevman-dev.install.in @@ -1,3 +1,7 @@ @PREFIX@/include/devman/devman.h +@PREFIX@/include/devman/devman_managed.h +@PREFIX@/include/devman/devman_image.h +@PREFIX@/include/devman/devman_error.h +@PREFIX@/include/devman/devman_haptic.h @PREFIX@/include/devman/SLP_devman_PG.h @PREFIX@/lib/pkgconfig/devman.pc diff --git a/debian/libdevman-haptic-dev.install.in b/debian/libdevman-haptic-dev.install.in old mode 100755 new mode 100644 index a9c61d5..f52b9b6 --- a/debian/libdevman-haptic-dev.install.in +++ b/debian/libdevman-haptic-dev.install.in @@ -1,4 +1,3 @@ -@PREFIX@/include/devman/devman_haptic.h @PREFIX@/include/devman/devman_haptic_ext.h @PREFIX@/include/devman/devman_haptic_ext_core.h @PREFIX@/lib/pkgconfig/devman_haptic.pc diff --git a/debian/rules b/debian/rules index 8dbe0f8..e197e08 100755 --- a/debian/rules +++ b/debian/rules @@ -87,8 +87,6 @@ install: build $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc4.d/ - ln -s ../init.d/devman $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S10devman - ln -s ../init.d/devman $(CURDIR)/debian/tmp/etc/rc.d/rc4.d/S10devman diff --git a/device_haptic.c b/device_haptic.c deleted file mode 100644 index f14c62a..0000000 --- a/device_haptic.c +++ /dev/null @@ -1,1494 +0,0 @@ -/* - * devman - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: DongGi Jang - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include - -#include "devlog.h" -#include "device_haptic.h" -#include "devman.h" -#include "devman_haptic.h" -#include "devman_haptic_ext.h" -#include "devman_haptic_plugin_intf.h" -/* START: Will be excluded by removing pattern */ -#include "device_haptic_tsp4000_pattern.h" -/* END: Will be excluded */ - -#ifndef EXTAPI -#define EXTAPI __attribute__ ((visibility("default"))) -#endif /* EXTAPI */ - -#define HAPTIC_DEVICE_NODE_PATH "/dev/tspdrv" -#define HAPTIC_MODULE_PATH "/usr/lib/devman/libdevman_haptic.so" - -/* START: Will be removed by removing pattern */ -#define HAPTIC_PLAY_FILE_EXT ".ivt" -#define HAPTIC_BUILT_IN_FILE_PATH "/usr/share/immersion" - -struct g_pivt_list_t -{ - char file_name[NAME_MAX]; - unsigned char *ivt_pt; - int priority; -}; - -struct g_pivt_list_t g_haptic_internal_pattern_list[EFFCTVIBE_PATTERN_END] = { - /*for BeatUX*/ - [EFFCTVIBE_TOUCH] = { "/01_Touch/touch_20ms_sharp", touch_ivt, 15}, - [EFFCTVIBE_HW_TOUCH] = { "/01_Touch/HW_touch_30ms_sharp", hw_touch_ivt, 15}, - - [EFFCTVIBE_NOTIFICATION] = { "/02_Notification/Notification", noti_ivt, 7}, - [EFFCTVIBE_INCOMING_CALL01] = { "/02_Notification/Incoming call_01", incomming_01_ivt, 7}, - [EFFCTVIBE_INCOMING_CALL02] = { "/02_Notification/Incoming call_02", incomming_02_ivt, 7}, - [EFFCTVIBE_INCOMING_CALL03] = { "/02_Notification/Incoming call_03", incomming_03_ivt, 7}, - - [EFFCTVIBE_ALERTS_CALL] = { "/03_Operation/Alerts on Call", alerts_call_ivt, 15}, - [EFFCTVIBE_OPERATION] = { "/03_Operation/Operation", operation_ivt, 7}, - [EFFCTVIBE_SILENT_MODE] = { "/03_Operation/Silent mode", silent_ivt, 7}, -}; -/* END: Will be removed */ - -static int has_haptic_module = -1; -static int master_callback_enable = 0; -static int setting_fb_level = -1; -static int device_handle_count = 0; - -/* Device Manager Haptic Plugin Interface */ -static void *dlopen_handle; -static const devman_haptic_plugin_interface *plugin_intf; - -enum { - MODE_DEFAULT = 0x0000, - MODE_FEEDBACK_LEVEL_CHECK_DISABLE = 0x0001, -}; - -/* START of Static Function Section */ -static int __get_master_strength_value() -{ - int input_strength = 0; - - switch (setting_fb_level) { - case SETTING_VIB_FEEDBACK_LEVEL0: - DBG("get setting value = 0 , so can not vibe"); - return 0; - break; - case SETTING_VIB_FEEDBACK_LEVEL1: - input_strength = VIBE_FEEDBACK_LEVEL_1; - break; - - case SETTING_VIB_FEEDBACK_LEVEL2: - input_strength = VIBE_FEEDBACK_LEVEL_2; - break; - - case SETTING_VIB_FEEDBACK_LEVEL3: - input_strength = VIBE_FEEDBACK_LEVEL_3; - break; - - case SETTING_VIB_FEEDBACK_LEVEL4: - input_strength = VIBE_FEEDBACK_LEVEL_4; - break; - - case SETTING_VIB_FEEDBACK_LEVEL5: - input_strength = VIBE_FEEDBACK_LEVEL_5; - break; - - default: - ERR("error get VCONF_SETAPPL_VIB_FEEDBACK_INT value (= %d) invalid", setting_fb_level); - return -2; - break; - } - - return input_strength; -} - -static int __convert_strength_level(int base_level) -{ - int convert_strength = 0; - - switch (base_level) { - case 0: - ERR("Input base_level == 0(:%d)\n", base_level); - break; - - case HAPTIC_FEEDBACK_LEVEL_1: - convert_strength = VIBE_FEEDBACK_LEVEL_1; - break; - - case HAPTIC_FEEDBACK_LEVEL_2: - convert_strength = VIBE_FEEDBACK_LEVEL_2; - break; - - case HAPTIC_FEEDBACK_LEVEL_3: - convert_strength = VIBE_FEEDBACK_LEVEL_3; - break; - - case HAPTIC_FEEDBACK_LEVEL_4: - convert_strength = VIBE_FEEDBACK_LEVEL_4; - break; - - case HAPTIC_FEEDBACK_LEVEL_5: - convert_strength = VIBE_FEEDBACK_LEVEL_5; - break; - - default: - ERR("error invalid convertable value (%d)", base_level); - return -2; - } - - return convert_strength; -} - -static void __haptic_changed_cb(keynode_t *node, void *data) -{ - int feedback_level; - - DBG("[haptic_changed_cb] changed key = %s\n", - vconf_keynode_get_name(node)); - - if (vconf_keynode_get_type(node) == VCONF_TYPE_INT) { - - feedback_level = vconf_keynode_get_int(node); - - if (feedback_level == -1) { - ERR(" [haptic_changed_cb] Err vconf_keynode_get_int fail from key in haptic_changed_cb : %s , fail state : %d ,so set default level", vconf_keynode_get_name(node), feedback_level); - return; - } - DBG("[haptic_changed_cb] get value : %d , from key : %s", - feedback_level, vconf_keynode_get_name(node)); - - setting_fb_level = feedback_level; - } else { - ERR("[haptic_changed_cb] Err changed key_type miss-match!! read_type : %d", vconf_keynode_get_type(node)); - } -} -/* END of Static Function Section */ - - -/* START: devman_haptic APIs */ - EXTAPI -int device_haptic_open(haptic_dev_idx dev_idx, unsigned int mode) -{ - int status; - int device_index = dev_idx >> 1; - int device_handle; - - if (device_handle_count == 0) { - if (has_haptic_module == 1) { - plugin_intf->haptic_internal_prepare_node(); - - if (plugin_intf->haptic_internal_initialize() < 0) { - ERR("plugin_intf->haptic_internal_initialize() failed"); - return HAPTIC_FAIL; - } - } - - if (mode & MODE_FEEDBACK_LEVEL_CHECK_DISABLE) { - pid_t cpid; - cpid = getpid(); - DBG("NOT USE MAIN VIB_FEEDBACK_CHECK ROUTINE !!, at pid : %d", cpid); - setting_fb_level = SETTING_VIB_FEEDBACK_LEVEL3; - } else if (master_callback_enable == 0) { - status = vconf_get_int(VCONFKEY_SETAPPL_VIB_FEEDBACK_INT, &setting_fb_level); - if (status < 0) { - DBG(" vconf_get_int fail from key : %s , fail state : %d ,so set default level", VCONFKEY_SETAPPL_VIB_FEEDBACK_INT, status); - setting_fb_level = SETTING_VIB_FEEDBACK_LEVEL3; - } - DBG("get value : %d , from key : %s", setting_fb_level, VCONFKEY_SETAPPL_VIB_FEEDBACK_INT); - - status = vconf_notify_key_changed (VCONFKEY_SETAPPL_VIB_FEEDBACK_INT, __haptic_changed_cb, NULL); - if (status < 0) { - ERR("Device_haptic_open vconf_notify_key_changed fail\n"); - return HAPTIC_FAIL; - } - - master_callback_enable = 1; - } - } - - if (has_haptic_module == 1) { - if (dev_idx == DEV_IDX_ALL) { - status = plugin_intf->haptic_internal_open_composite_device(NULL, device_index, &device_handle); - if(HAPTIC_FAILED(status)) { - ERR("plugin_intf->haptic_internal_open_composite_device() Failed: %d", status); - return HAPTIC_FAIL; - } - } else { - status = plugin_intf->haptic_internal_open_device(device_index, &device_handle); - if(HAPTIC_FAILED(status)) { - ERR("plugin_intf->haptic_internal_open_device() Failed: %d", status); - return HAPTIC_FAIL; - } - } - - ++device_handle_count; - return device_handle; - } - - ++device_handle_count; - return DEFAULT_DEVICE_HANDLE; -} - - EXTAPI -int device_haptic_close(int device_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device already closed"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 1) { - status = plugin_intf->haptic_internal_close_device(device_handle); - if(HAPTIC_FAILED(status)) { - ERR("plugin_intf->haptic_internal_close_device(0) fail: %d", status); - return HAPTIC_FAIL; - } - } - - --device_handle_count; - if (device_handle_count == 0) { - if (has_haptic_module == 1) { - status = plugin_intf->haptic_internal_terminate(); - if(HAPTIC_FAILED(status)) { - ERR("plugin_intf->haptic_internal_terminate(0) fail: %d", status); - return HAPTIC_FAIL; - } - } - - if (master_callback_enable == 1) { - status = vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIB_FEEDBACK_INT, __haptic_changed_cb); - if (status < 0) { - ERR("Device_haptic_close vconf_ignore_key_changed fail\n"); - return HAPTIC_FAIL; - } - master_callback_enable = 0; - } - } - - return HAPTIC_SUCCESS; -} - - EXTAPI -int device_haptic_play_buffer(int device_handle, const unsigned char *vibe_buffer, int iteration, int feedback_level) -{ - int input_feedback_level; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) { - input_feedback_level = __get_master_strength_value(); - } else { - input_feedback_level = __convert_strength_level(feedback_level); - } - - return plugin_intf->haptic_internal_play_buffer(device_handle, vibe_buffer, iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY); -} - - EXTAPI -int device_haptic_play_file(int device_handle, const char *file_name, int iteration, int feedback_level) -{ - int input_feedback_level; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) { - input_feedback_level = __get_master_strength_value(); - } else { - input_feedback_level = __convert_strength_level(feedback_level); - } - - return plugin_intf->haptic_internal_play_file(device_handle, file_name, iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY); -} - - EXTAPI -int device_haptic_play_pattern(int device_handle, int pattern, int iteration, int feedback_level) -{ - char file_name[NAME_MAX]; - int priority = -1; - int input_feedback_level; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) { - input_feedback_level = __get_master_strength_value(); - } else { - input_feedback_level = __convert_strength_level(feedback_level); - } - - /* Set Priority */ - if (!g_haptic_internal_pattern_list[pattern].priority) { - priority = HAPTIC_MIN_DEVICE_PRIORITY; - } else { - priority = g_haptic_internal_pattern_list[pattern].priority; - } - - if (!g_haptic_internal_pattern_list[pattern].ivt_pt) { - /* Pass filename insted of buffer pointer */ - if (0 > snprintf(file_name, NAME_MAX, "%s%s%s", HAPTIC_BUILT_IN_FILE_PATH, g_haptic_internal_pattern_list[pattern].file_name, HAPTIC_PLAY_FILE_EXT)) - { - ERR("snprintf fail in EFFCTVIBE_SET_EFFECT_TYPE"); - return HAPTIC_FAIL; - } - - return plugin_intf->haptic_internal_play_file(device_handle, file_name, iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY); - } - - return plugin_intf->haptic_internal_play_buffer(device_handle, g_haptic_internal_pattern_list[pattern].ivt_pt, iteration, input_feedback_level, priority); -} - - EXTAPI -int device_haptic_stop_play(int device_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 1) { - status = plugin_intf->haptic_internal_stop_all_playing_effects(device_handle); - if(HAPTIC_FAILED(status)) { - ERR("plugin_intf->haptic_internal_stop_all_playing_effects(0) fail: %d", status); - return HAPTIC_FAIL; - } - } else { - status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ENABLE, 0); - if (status < 0) { - ERR("Haptic device stop failed: %d", status); - return HAPTIC_FAIL; - } - } - - return HAPTIC_SUCCESS; -} - - EXTAPI -int device_haptic_play_monotone(int device_handle, int duration) -{ - return device_haptic_play_monotone_with_feedback_level(device_handle, duration, HAPTIC_FEEDBACK_LEVEL_AUTO); -} - - EXTAPI -int device_haptic_play_monotone_with_feedback_level(int device_handle, int duration, int feedback_level) -{ - int status; - int input_strength; - int input_feedback_level; - int effect_handle; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (duration < 0) { - ERR("Invalid parameter: duration < 0"); - return HAPTIC_FAIL; - } - - if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) { - input_feedback_level = __get_master_strength_value(); - } else { - input_feedback_level = __convert_strength_level(feedback_level); - } - - if (has_haptic_module == 1) { - status = plugin_intf->haptic_internal_play_monotone(device_handle, duration, input_feedback_level, 0x05); - if(HAPTIC_FAILED(status)) { - ERR("plugin_intf->haptic_internal_play_monotone(0) fail: %d", status); - return HAPTIC_FAIL; - } - } else { - status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_LEVEL, input_feedback_level); - if (status < 0) { - ERR(" haptic_set_level for strength:%d (error:%d) \n", input_strength, status); - return HAPTIC_FAIL; - } - - status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ONESHOT, duration); - if (status < 0) { - ERR(" haptic_oneshot for duration:%d (error:%d) \n", duration, status); - return HAPTIC_FAIL; - } - } - - return HAPTIC_SUCCESS; -} - - EXTAPI -int device_haptic_play_monotone_with_detail_feedback_level(int device_handle, int duration, int detail_feedback_level) -{ - int status; - int input_strength; - int input_feedback_level; - int effect_handle; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (duration < 0) { - ERR("Invalid parameter: duration < 0"); - return HAPTIC_FAIL; - } - - if (detail_feedback_level < 0 && detail_feedback_level > 100) { - ERR("detail_feedback_level is wrong: %d", detail_feedback_level); - return HAPTIC_FAIL; - } else { - if (detail_feedback_level == 0) { - input_feedback_level = __get_master_strength_value(); - } else { - input_feedback_level = detail_feedback_level * 100; - } - } - - if (has_haptic_module == 1) { - status = plugin_intf->haptic_internal_play_monotone(device_handle, duration, input_feedback_level, 0x05); - if(HAPTIC_FAILED(status)) { - ERR("plugin_intf->haptic_internal_play_monotone(0) fail: %d", status); - return HAPTIC_FAIL; - } - } else { - status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_LEVEL, input_feedback_level); - if (status < 0) { - ERR(" haptic_set_level for strength:%d (error:%d) \n", input_strength, status); - return HAPTIC_FAIL; - } - - status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ONESHOT, duration); - if (status < 0) { - ERR(" haptic_oneshot for duration:%d (error:%d) \n", duration, status); - return HAPTIC_FAIL; - } - } - - return HAPTIC_SUCCESS; -} - - EXTAPI -int device_haptic_get_buffer_duration(int device_handle, const unsigned char *vibe_buffer, int *duration) -{ - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_buffer_duration(device_handle, vibe_buffer, duration); -} - - EXTAPI -int device_haptic_get_file_duration(int device_handle, const char *file_name, int *duration) -{ - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_file_duration(device_handle, file_name, duration); -} - - EXTAPI -int device_haptic_get_pattern_duration(int device_handle, int pattern, int *duration) -{ - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - int status; - char file_name[NAME_MAX]; - - if (!g_haptic_internal_pattern_list[pattern].ivt_pt) { - /* Pass filename insted of buffer pointer */ - if (0 > snprintf(file_name, NAME_MAX, "%s%s%s", HAPTIC_BUILT_IN_FILE_PATH, g_haptic_internal_pattern_list[pattern].file_name, HAPTIC_PLAY_FILE_EXT)) - { - ERR("snprintf fail in EFFCTVIBE_SET_EFFECT_TYPE"); - return HAPTIC_FAIL; - } - - return plugin_intf->haptic_internal_get_file_duration(device_handle, file_name, duration); - } - - return plugin_intf->haptic_internal_get_buffer_duration(device_handle, g_haptic_internal_pattern_list[pattern].ivt_pt, duration); -} - - EXTAPI -int device_haptic_get_device_count() -{ - int status; - int device_count = -1; - - if (has_haptic_module == 0) { - return DEFAULT_MOTOR_COUNT; - } - - if (device_handle_count == 0) { - plugin_intf->haptic_internal_prepare_node(); - - status = plugin_intf->haptic_internal_initialize(); - if (status < 0) { - return HAPTIC_FAIL; - } - /* Get device count */ - device_count = plugin_intf->haptic_internal_get_device_count(); - if(HAPTIC_FAILED(device_count)) { - ERR("plugin_intf->haptic_internal_get_device_count(0) fail: %d",status); - return HAPTIC_FAIL; - } - - status = plugin_intf->haptic_internal_terminate(); - if (status < 0) { - return HAPTIC_FAIL; - } - } else { - device_count = plugin_intf->haptic_internal_get_device_count(); - if(HAPTIC_FAILED(device_count)) { - ERR("plugin_intf->haptic_internal_get_device_count(0) fail: %d",status); - return HAPTIC_FAIL; - } - } - - return device_count; -} -/* END: devman_haptic APIs */ - - -/* START: devman_haptic_ext APIs */ - EXTAPI -int device_haptic_get_device_state(int device_index, int *state) -{ - int status; - int index = device_index >> 1; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_device_state(index, state); -} - - EXTAPI -int device_haptic_get_device_capability_bool(int device_index, int device_cap_type, unsigned char *device_cap_value) -{ - int status; - int index = device_index >> 1; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_device_capability_bool(index, device_cap_type, device_cap_value); -} - - EXTAPI -int device_haptic_get_device_capability_int32(int device_index, int device_cap_type, int *device_cap_value) -{ - int status; - int index = device_index >> 1; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_device_capability_int32(index, device_cap_type, device_cap_value); -} - - EXTAPI -int device_haptic_get_device_capability_string(int device_index, int device_cap_type, int size, char *device_cap_value) -{ - int status; - int index = device_index >> 1; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_device_capability_string(index, device_cap_type, size, device_cap_value); -} - - EXTAPI -int device_haptic_get_device_property_bool(int device_handle, int device_prop_type, unsigned char *device_prop_value) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_device_property_bool(device_handle, device_prop_type, device_prop_value); -} - - EXTAPI -int device_haptic_set_device_property_bool(int device_handle, int device_prop_type, unsigned char device_prop_value) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_set_device_property_bool(device_handle, device_prop_type, device_prop_value); -} - - EXTAPI -int device_haptic_get_device_property_int32(int device_handle, int device_prop_type, int *device_prop_value) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_device_property_int32(device_handle, device_prop_type, device_prop_value); -} - - EXTAPI -int device_haptic_set_device_property_int32(int device_handle, int device_prop_type, int device_prop_value) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_set_device_property_int32(device_handle, device_prop_type, device_prop_value); -} - - EXTAPI -int device_haptic_get_device_property_string(int device_handle, int device_prop_type, int size, char *device_prop_value) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_device_property_string(device_handle, device_prop_type, size, device_prop_value); -} - - EXTAPI -int device_haptic_set_device_property_string(int device_handle, int device_prop_type, const char *device_prop_value) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_set_device_property_string(device_handle, device_prop_type, device_prop_value); -} - - EXTAPI -int device_haptic_get_effect_count(const unsigned char *haptic_buffer) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_IVT_effect_count(haptic_buffer); -} - - EXTAPI -int device_haptic_get_effect_name(const unsigned char *haptic_buffer, int effect_index, int size, char *effect_name) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_IVT_effect_name(haptic_buffer, effect_index, size, effect_name); -} - - EXTAPI -int device_haptic_get_effect_name_u(const unsigned char *haptic_buffer, int effect_index, int size, unsigned short *effect_name) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_IVT_effect_name_u(haptic_buffer, effect_index, size, effect_name); -} - - EXTAPI -int device_haptic_get_effect_index_from_name(const unsigned char *haptic_buffer, char const *effect_name, int *effect_index) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_IVT_effect_index_from_name(haptic_buffer, effect_name, effect_index); -} - - EXTAPI -int device_haptic_get_effect_index_from_name_u(const unsigned char *haptic_buffer, const unsigned short *effect_name, int *effect_index) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_IVT_effect_index_from_name_u(haptic_buffer, effect_name, effect_index); -} - - EXTAPI -int device_haptic_play_effect(int device_handle, const unsigned char *haptic_buffer, int effect_index, int *effect_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_play_IVT_effect(device_handle, haptic_buffer, effect_index, effect_handle); -} - - EXTAPI -int device_haptic_play_effect_repeat(int device_handle, const unsigned char *haptic_buffer, int effect_index, unsigned char repeat, int *effect_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_play_IVT_effect_repeat(device_handle, haptic_buffer, effect_index, repeat, effect_handle); -} - - EXTAPI -int device_haptic_stop_playing_effect(int device_handle, int effect_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_stop_playing_effect(device_handle, effect_handle); -} - - EXTAPI -int device_haptic_get_effect_type(const unsigned char *haptic_buffer, int effect_index, int *effect_type) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_IVT_effect_type(haptic_buffer, effect_index, effect_type); -} - - EXTAPI -int device_haptic_get_magsweep_effect_definition(const unsigned char *haptic_buffer, int effect_index, - int *duration, int *magnitude, int *style, int *attacktime, int *attacklevel, - int *fadetime, int *fadelevel) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_IVT_magsweep_effect_definition(haptic_buffer, effect_index, duration, magnitude, style, attacktime, attacklevel, fadetime, fadelevel); -} - - EXTAPI -int device_haptic_get_periodic_effect_definition(const unsigned char *haptic_buffer, int effect_index, - int *duration, int *magnitude, int *period, int *style_and_wave_type, int *attacktime, int *attacklevel, - int *fadetime, int *fadelevel) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_IVT_periodic_effect_definition(haptic_buffer, effect_index, duration, magnitude, period, style_and_wave_type, attacktime, attacklevel, fadetime, fadelevel); -} - - EXTAPI -int device_haptic_get_effect_duration(const unsigned char *haptic_buffer, int effect_index, int *effect_duration) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_IVT_effect_duration(haptic_buffer, effect_index, effect_duration); -} - - EXTAPI -int device_haptic_play_magsweep_effect(int device_handle, - int duration, int magnitude, int style, int attacktime, int attacklevel, - int fadetime, int fadelevel, int *effect_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_play_magsweep_effect(device_handle, duration, magnitude, style, attacktime, attacklevel, fadetime, fadelevel, effect_handle); -} - - EXTAPI -int device_haptic_play_periodic_effect(int device_handle, - int duration, int magnitude, int period, int style_and_wave_type, int attacktime, int attacklevel, - int fadetime, int fadelevel, int *effect_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_play_periodic_effect(device_handle, duration, magnitude, period, style_and_wave_type, attacktime, attacklevel, fadetime, fadelevel, effect_handle); -} - - EXTAPI -int device_haptic_modify_playing_magsweep_effect(int device_handle, int effect_handle, - int duration, int magnitude, int style, int attacktime, int attacklevel, int fadetime, int fadelevel) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_modify_playing_magsweep_effect(device_handle, effect_handle, duration, magnitude, style, attacktime, attacklevel, fadetime, fadelevel); -} - - EXTAPI -int device_haptic_modify_playing_periodic_effect(int device_handle, int effect_handle, - int duration, int magnitude, int period, int style_and_wave_type, int attacktime, int attacklevel, int fadetime, int fadelevel) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_modify_playing_periodic_effect(device_handle, effect_handle, duration, magnitude, period, style_and_wave_type, attacktime, attacklevel, fadetime, fadelevel); -} - - EXTAPI -int device_haptic_create_streaming_effect(int device_handle, int *effect_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - } - - return plugin_intf->haptic_internal_create_streaming_effect(device_handle, effect_handle); -} - - EXTAPI -int device_haptic_destroy_streaming_effect(int device_handle, int effect_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_destroy_streaming_effect(device_handle, effect_handle); -} - - EXTAPI -int device_haptic_play_streaming_sample(int device_handle, int effect_handle, const unsigned char *streaming_sample, int size) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_play_streaming_sample(device_handle, effect_handle, streaming_sample, size); -} - - EXTAPI -int device_haptic_play_streaming_sample_with_offset(int device_handle, int effect_handle, const unsigned char *streaming_sample, int size, int offset_time) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_play_streaming_sample_with_offset(device_handle, effect_handle, streaming_sample, size, offset_time); -} - - EXTAPI -int device_haptic_stop_all_playing_effects(int device_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_stop_all_playing_effects(device_handle); -} - - EXTAPI -int device_haptic_save_file(const unsigned char *haptic_buffer, const char *path_name) -{ - ERR("%s() is not supported without specific haptic module", __func__); - return -2; - - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return -1; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return -2; - } - - return plugin_intf->haptic_internal_save_IVT_file(haptic_buffer, path_name); -} - - EXTAPI -int device_haptic_delete_file(const char *path_name) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_delete_IVT_file(path_name); -} - - EXTAPI -int device_haptic_pause_playing_effect(int device_handle, int effect_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_pause_playing_effect(device_handle, effect_handle); -} - - EXTAPI -int device_haptic_resume_paused_effect(int device_handle, int effect_handle) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_resume_paused_effect(device_handle, effect_handle); -} - - EXTAPI -int device_haptic_get_effect_state(int device_handle, int effect_handle, int *effect_state) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_effect_state(device_handle, effect_handle, effect_state); -} - - EXTAPI -int device_haptic_get_size(const unsigned char *haptic_buffer, int size) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_get_IVT_size(haptic_buffer, size); -} - - EXTAPI -int device_haptic_initialize_buffer(unsigned char *haptic_buffer, int size) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_initialize_IVT_buffer(haptic_buffer, size); -} - - EXTAPI -int device_haptic_insert_element(unsigned char *haptic_buffer, int size, int timeline_index, const HapticElement *element) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_insert_IVT_element(haptic_buffer, size, timeline_index, element); -} - - EXTAPI -int device_haptic_insert_element2(unsigned char *haptic_buffer, int size, int timeline_index, const HapticElement2 *element) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_insert_IVT_element2(haptic_buffer, size, timeline_index, element); -} - - EXTAPI -int device_haptic_insert_element3(unsigned char *haptic_buffer, int size, int timeline_index, const HapticElement3 *element) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_insert_IVT_element3(haptic_buffer, size, timeline_index, element); -} - - EXTAPI -int device_haptic_read_element(const unsigned char *haptic_buffer, int size, int timeline_index, int element_index, HapticElement *element) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_read_IVT_element(haptic_buffer, size, timeline_index, element_index, element); -} - - EXTAPI -int device_haptic_read_element2(const unsigned char *haptic_buffer, int size, int timeline_index, int element_index, HapticElement2 *element) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_read_IVT_element2(haptic_buffer, size, timeline_index, element_index, element); -} - - EXTAPI -int device_haptic_read_element3(const unsigned char *haptic_buffer, int size, int timeline_index, int element_index, HapticElement3 *element) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_read_IVT_element3(haptic_buffer, size, timeline_index, element_index, element); -} - - EXTAPI -int device_haptic_remove_element(unsigned char *haptic_buffer, int size, int timeline_index, int element_index) -{ - int status; - - if (device_handle_count == 0) { - ERR("Haptic device is not opened yet"); - return HAPTIC_NOT_OPENED; - } - - if (has_haptic_module == 0) { - ERR("%s() is not supported without specific haptic module", __func__); - return HAPTIC_NOT_SUPPORTED; - } - - return plugin_intf->haptic_internal_remove_IVT_element(haptic_buffer, size, timeline_index, element_index); -} -/* END: devman_haptic_ext APIs */ - -static void __attribute__ ((constructor)) module_init() -{ - char *error; - - if (access(HAPTIC_DEVICE_NODE_PATH, F_OK) < 0) { - has_haptic_module = 0; - return; - } else { - has_haptic_module = 1; - } - - dlopen_handle = dlopen(HAPTIC_MODULE_PATH, RTLD_NOW); - if (!dlopen_handle) { - ERR("dlopen failed: %s", dlerror()); - has_haptic_module = 0; - return; - } - - const devman_haptic_plugin_interface *(*get_devman_haptic_plugin_interface) (); - get_devman_haptic_plugin_interface = dlsym(dlopen_handle, "get_devman_haptic_plugin_interface"); - if ((error = dlerror()) != NULL) { - ERR("dlsym failed : %s", error); - has_haptic_module = 0; - dlclose(dlopen_handle); - return; - } - - plugin_intf = get_devman_haptic_plugin_interface(); - if (!plugin_intf) { - ERR("get_devman_haptic_plugin_interface() failed"); - has_haptic_module = 0; - dlclose(dlopen_handle); - return; - } -} - -static void __attribute__ ((destructor)) module_fini() -{ - if (dlopen_handle) { - dlclose(dlopen_handle); - } -} - diff --git a/devices/CMakeLists.txt b/devices/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/devices/haptic.c b/devices/haptic.c old mode 100755 new mode 100644 index 703ae28..ad44593 --- a/devices/haptic.c +++ b/devices/haptic.c @@ -26,10 +26,10 @@ static int get_haptic(int prop, int *val) { switch (prop) { - case HAPTIC_PROP_LEVEL: - return plugin_intf->OEM_sys_get_haptic_vibetones_level(val); - case HAPTIC_PROP_LEVEL_MAX: - return plugin_intf->OEM_sys_get_haptic_vibetones_level_max(val); + case HAPTIC_PROP_LEVEL: + return plugin_intf->OEM_sys_get_haptic_vibetones_level(val); + case HAPTIC_PROP_LEVEL_MAX: + return plugin_intf->OEM_sys_get_haptic_vibetones_level_max(val); } return -1; @@ -38,12 +38,12 @@ static int get_haptic(int prop, int *val) static int set_haptic(int prop, int val) { switch (prop) { - case HAPTIC_PROP_ENABLE: - return plugin_intf->OEM_sys_set_haptic_vibetones_enable(val); - case HAPTIC_PROP_LEVEL: - return plugin_intf->OEM_sys_set_haptic_vibetones_level(val); - case HAPTIC_PROP_ONESHOT: - return plugin_intf->OEM_sys_set_haptic_vibetones_oneshot(val); + case HAPTIC_PROP_ENABLE: + return plugin_intf->OEM_sys_set_haptic_vibetones_enable(val); + case HAPTIC_PROP_LEVEL: + return plugin_intf->OEM_sys_set_haptic_vibetones_level(val); + case HAPTIC_PROP_ONESHOT: + return plugin_intf->OEM_sys_set_haptic_vibetones_oneshot(val); } return -1; diff --git a/devices/jack_35pi.c b/devices/jack_35pi.c old mode 100755 new mode 100644 index ba1dc6c..2e985b2 --- a/devices/jack_35pi.c +++ b/devices/jack_35pi.c @@ -27,14 +27,14 @@ static int get_35pi(int prop, int *val) { switch (prop) { - case JACK_PROP_MIC_ONLINE: - return -1; - case JACK_PROP_EARKEY_PRESS: - return plugin_intf->OEM_sys_get_jack_earkey_online(val); - case JACK_PROP_EARJACK_ONLINE: - return plugin_intf->OEM_sys_get_jack_earjack_online(val); - case JACK_PROP_TVOUT_ONLINE: - return plugin_intf->OEM_sys_get_jack_tvout_online(val); + case JACK_PROP_MIC_ONLINE: + return -1; + case JACK_PROP_EARKEY_PRESS: + return plugin_intf->OEM_sys_get_jack_earkey_online(val); + case JACK_PROP_EARJACK_ONLINE: + return plugin_intf->OEM_sys_get_jack_earjack_online(val); + case JACK_PROP_TVOUT_ONLINE: + return plugin_intf->OEM_sys_get_jack_tvout_online(val); } return -1; diff --git a/devices/jack_microusb.c b/devices/jack_microusb.c old mode 100755 new mode 100644 index c65de46..569b413 --- a/devices/jack_microusb.c +++ b/devices/jack_microusb.c @@ -26,14 +26,14 @@ static int get_microusb_status(int prop, int *val) { switch (prop) { - case JACK_PROP_USB_ONLINE: - return plugin_intf->OEM_sys_get_jack_usb_online(val); - case JACK_PROP_TA_ONLINE: - return plugin_intf->OEM_sys_get_jack_charger_online(val); - case JACK_PROP_HDMI_ONLINE: - return plugin_intf->OEM_sys_get_jack_hdmi_online(val); - case JACK_PROP_USB_PATH: - return plugin_intf->OEM_sys_get_usb_path(val); + case JACK_PROP_USB_ONLINE: + return plugin_intf->OEM_sys_get_jack_usb_online(val); + case JACK_PROP_TA_ONLINE: + return plugin_intf->OEM_sys_get_jack_charger_online(val); + case JACK_PROP_HDMI_ONLINE: + return plugin_intf->OEM_sys_get_jack_hdmi_online(val); + case JACK_PROP_USB_PATH: + return plugin_intf->OEM_sys_get_usb_path(val); } return -1; @@ -43,15 +43,15 @@ static int set_microusb_path(int prop, int val) { int ret = -1; switch (prop) { - case JACK_PROP_USB_PATH: - ret = plugin_intf->OEM_sys_set_usb_path(val); - if(ret == 0){ - if(val == PATH_CP) - system("/usr/bin/save_blenv usbpath CP"); - else - system("/usr/bin/save_blenv usbpath AP"); - } - return ret; + case JACK_PROP_USB_PATH: + ret = plugin_intf->OEM_sys_set_usb_path(val); + if(ret == 0){ + if(val == PATH_CP) + system("/usr/bin/save_blenv usbpath CP"); + else + system("/usr/bin/save_blenv usbpath AP"); + } + return ret; } return -1; diff --git a/devices/led.c b/devices/led.c old mode 100755 new mode 100644 index 69992f1..378665d --- a/devices/led.c +++ b/devices/led.c @@ -26,10 +26,10 @@ static int get_led_prop(int prop, int *val) { switch (prop) { - case LED_PROP_BRIGHTNESS: - return plugin_intf->OEM_sys_get_leds_torch_brightness(val); - case LED_PROP_MAX_BRIGHTNESS: - return plugin_intf->OEM_sys_get_leds_torch_max_brightness(val); + case LED_PROP_BRIGHTNESS: + return plugin_intf->OEM_sys_get_leds_torch_brightness(val); + case LED_PROP_MAX_BRIGHTNESS: + return plugin_intf->OEM_sys_get_leds_torch_max_brightness(val); } return -1; } @@ -37,8 +37,8 @@ static int get_led_prop(int prop, int *val) static int set_led_prop(int prop, int val) { switch (prop) { - case LED_PROP_BRIGHTNESS: - return plugin_intf->OEM_sys_set_leds_torch_brightness(val); + case LED_PROP_BRIGHTNESS: + return plugin_intf->OEM_sys_set_leds_torch_brightness(val); } return -1; } diff --git a/devices/mmc.c b/devices/mmc.c old mode 100755 new mode 100644 index 8141315..6652092 --- a/devices/mmc.c +++ b/devices/mmc.c @@ -33,19 +33,13 @@ #include #include #include +#include #include "device_engine.h" #define MMC_DEV "/dev/mmcblk" #define MMC_MOUNT_PATH "/opt/storage/sdcard" -#define VCONFKEY_SYSMAN_MMC_FORMAT "memory/Device/mmc_format" -enum { - VCONFKEY_SYSMAN_MMC_FORMAT_COMPLETED = 0, - VCONFKEY_SYSMAN_MMC_FORMAT_FAILED -}; - - static int exec_process(char *name, const char *arg1) { int ret, pid; @@ -56,20 +50,20 @@ static int exec_process(char *name, const char *arg1) pid = fork(); switch (pid) { - case -1: - ERR("Fork error"); - ret = -1; - break; - case 0: - for (i = 0; i < _NSIG; i++) - signal(i, SIG_DFL); - execl(name, name, arg1, NULL); - ERR("execlp() error : %s\n", strerror(errno)); - exit(-1); - break; - default: - ret = pid; - break; + case -1: + ERR("Fork error"); + ret = -1; + break; + case 0: + for (i = 0; i < _NSIG; i++) + signal(i, SIG_DFL); + execl(name, name, arg1, NULL); + ERR("execlp() error : %s\n", strerror(errno)); + exit(-1); + break; + default: + ret = pid; + break; } return ret; } @@ -102,9 +96,8 @@ int format_mmc(int blknum) int mkfs_pid = 0; if (blknum < 0) { - vconf_set_int("memory/mmc/format", 2); vconf_set_int(VCONFKEY_SYSMAN_MMC_FORMAT, - VCONFKEY_SYSMAN_MMC_FORMAT_FAILED); + VCONFKEY_SYSMAN_MMC_FORMAT_FAILED); return -1; } else snprintf(dev_mmcblk, NAME_MAX, "%s%d", MMC_DEV, blknum); @@ -131,9 +124,8 @@ int format_mmc(int blknum) if (umount2(MMC_MOUNT_PATH, MNT_FORCE) == -1) { ERR("devman mmc_format umount fail\n"); if (umount2(MMC_MOUNT_PATH, MNT_FORCE) == -1) { - vconf_set_int("memory/mmc/format", 2); vconf_set_int(VCONFKEY_SYSMAN_MMC_FORMAT, - VCONFKEY_SYSMAN_MMC_FORMAT_FAILED); + VCONFKEY_SYSMAN_MMC_FORMAT_FAILED); ERR("devman mmc_format umount retry fail\n"); return -1; } @@ -164,7 +156,7 @@ int format_mmc(int blknum) sync(); mkfs_pid = - exec_process("/sbin/mkfs.vfat", dev_mmcblk); + exec_process("/sbin/mkfs.vfat", dev_mmcblk); if (mkfs_pid == -1) { ERR("devman mmc_format mkfs.vfat fail\n"); ret_s = -4; @@ -183,32 +175,29 @@ int format_mmc(int blknum) if (ret_f == 0 && ret_s == 0) { if (mount - (dev_mmcblk, MMC_MOUNT_PATH, "vfat", 0, - "uid=0,gid=0,dmask=0000,fmask=0111,iocharset=iso8859-1,utf8,shortname=mixed") - != 0) { + (dev_mmcblk, MMC_MOUNT_PATH, "vfat", 0, + "uid=0,gid=0,dmask=0000,fmask=0111,iocharset=iso8859-1,utf8,shortname=mixed") + != 0) { ERR("Failed to mount mmc card, %s,%s\n", dev_mmcblk, - MMC_MOUNT_PATH); - vconf_set_int("memory/mmc/format", 2); + MMC_MOUNT_PATH); vconf_set_int(VCONFKEY_SYSMAN_MMC_FORMAT, - VCONFKEY_SYSMAN_MMC_FORMAT_FAILED); + VCONFKEY_SYSMAN_MMC_FORMAT_FAILED); heynoti_publish("mmcblk_remove"); return -1; } else - if (heynoti_publish("mmcblk_add") == -1 - && ret_s == 0) - ERR("notification failed for new MMC\n"); + if (heynoti_publish("mmcblk_add") == -1 + && ret_s == 0) + ERR("notification failed for new MMC\n"); } else { - vconf_set_int("memory/mmc/format", 2); vconf_set_int(VCONFKEY_SYSMAN_MMC_FORMAT, - VCONFKEY_SYSMAN_MMC_FORMAT_FAILED); + VCONFKEY_SYSMAN_MMC_FORMAT_FAILED); ERR("result format process fail\n"); heynoti_publish("mmcblk_remove"); return -1; } - vconf_set_int("memory/mmc/format", 0); vconf_set_int(VCONFKEY_SYSMAN_MMC_FORMAT, - VCONFKEY_SYSMAN_MMC_FORMAT_COMPLETED); + VCONFKEY_SYSMAN_MMC_FORMAT_COMPLETED); return 0; } @@ -216,9 +205,9 @@ static int set_mmc_int(int prop, int val) { int ret = -1; switch (prop) { - case MMC_PROP_FORMAT: - ret = format_mmc(get_mmcblk_num()); - return ret; + case MMC_PROP_FORMAT: + ret = format_mmc(get_mmcblk_num()); + return ret; } return -1; diff --git a/devices/power.c b/devices/power.c index 832653f..b215e36 100644 --- a/devices/power.c +++ b/devices/power.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -26,8 +26,8 @@ static int get_power(int prop, int *val) { switch (prop) { - case POWER_PROP_WAKEUP_COUNT: - return plugin_intf->OEM_sys_get_power_wakeup_count(val); + case POWER_PROP_WAKEUP_COUNT: + return plugin_intf->OEM_sys_get_power_wakeup_count(val); } return -1; @@ -36,10 +36,10 @@ static int get_power(int prop, int *val) static int set_power(int prop, int val) { switch (prop) { - case POWER_PROP_STATE: - return plugin_intf->OEM_sys_set_power_state(val); - case POWER_PROP_WAKEUP_COUNT: - return plugin_intf->OEM_sys_set_power_wakeup_count(val); + case POWER_PROP_STATE: + return plugin_intf->OEM_sys_set_power_state(val); + case POWER_PROP_WAKEUP_COUNT: + return plugin_intf->OEM_sys_set_power_wakeup_count(val); } return -1; diff --git a/devices/power_supply_battery.c b/devices/power_supply_battery.c old mode 100755 new mode 100644 index c3c8769..b551196 --- a/devices/power_supply_battery.c +++ b/devices/power_supply_battery.c @@ -26,8 +26,10 @@ static int get_battery(int prop, int *val) { switch (prop) { - case POWER_SUPPLY_PROP_CAPACITY: - return plugin_intf->OEM_sys_get_battery_capacity(val); + case POWER_SUPPLY_PROP_CAPACITY: + return plugin_intf->OEM_sys_get_battery_capacity(val); + case POWER_SUPPLY_PROP_CAPACITY_RAW: + return plugin_intf->OEM_sys_get_battery_capacity_raw(val); } return -1; diff --git a/devices/power_supply_pmic.c b/devices/power_supply_pmic.c old mode 100755 new mode 100644 index a13a5d0..8c8ff6e --- a/devices/power_supply_pmic.c +++ b/devices/power_supply_pmic.c @@ -26,12 +26,12 @@ static int get_pmic(int prop, int *val) { switch (prop) { - case POWER_SUPPLY_PROP_CHARGE_NOW: - return plugin_intf->OEM_sys_get_battery_charge_now(val); - case POWER_SUPPLY_PROP_CHARGE_FULL: - return plugin_intf->OEM_sys_get_battery_charge_full(val); - case POWER_SUPPLY_PROP_BATTERY_HEALTH: - return plugin_intf->OEM_sys_get_battery_health(val); + case POWER_SUPPLY_PROP_CHARGE_NOW: + return plugin_intf->OEM_sys_get_battery_charge_now(val); + case POWER_SUPPLY_PROP_CHARGE_FULL: + return plugin_intf->OEM_sys_get_battery_charge_full(val); + case POWER_SUPPLY_PROP_BATTERY_HEALTH: + return plugin_intf->OEM_sys_get_battery_health(val); } return -1; diff --git a/devices/uart.c b/devices/uart.c old mode 100755 new mode 100644 index 92c5d4f..f27bd65 --- a/devices/uart.c +++ b/devices/uart.c @@ -26,8 +26,8 @@ static int uart_get(int prop, int *val) { switch (prop) { - case UART_PROP_SELECT_PATH: - return plugin_intf->OEM_sys_get_uart_path(val); + case UART_PROP_SELECT_PATH: + return plugin_intf->OEM_sys_get_uart_path(val); } return -1; @@ -35,17 +35,17 @@ static int uart_get(int prop, int *val) static int uart_set(int prop, int val) { - int ret = -1; + int ret = -1 ; switch (prop) { - case UART_PROP_SELECT_PATH: - ret = plugin_intf->OEM_sys_set_uart_path(val); - if(ret == 0) { - if(val == PATH_CP) - system("/usr/bin/save_blenv uartpath CP"); - else - system("/usr/bin/save_blenv uartpath AP"); - } - return ret; + case UART_PROP_SELECT_PATH: + ret = plugin_intf->OEM_sys_set_uart_path(val); + if(ret == 0){ + if(val == PATH_CP) + system("/usr/bin/save_blenv uartpath CP"); + else + system("/usr/bin/save_blenv uartpath AP"); + } + return ret; } return -1; diff --git a/devices/video.c b/devices/video.c old mode 100755 new mode 100644 index 30b0e03..7d57a36 --- a/devices/video.c +++ b/devices/video.c @@ -22,6 +22,7 @@ #include "device_engine.h" #include "device_plugin.h" +#include "vconf.h" #define PROPERTY_MASK 0x0F #define INDEX_SHIFT_CNT 4 @@ -31,6 +32,8 @@ static int get_video_prop(int prop, int *val) int _prop = prop & PROPERTY_MASK; int _index = prop >> 4; int _max_disp_cnt = -1; + int power_saving_stat = -1; + int power_saving_display_stat = -1; DBG("Property: %d, Index: %d", _prop, _index); if (0 > plugin_intf->OEM_sys_get_display_count(&_max_disp_cnt)) { @@ -44,29 +47,39 @@ static int get_video_prop(int prop, int *val) } switch (_prop) { - case DISPLAY_PROP_BRIGHTNESS: - return plugin_intf->OEM_sys_get_backlight_brightness(_index, val); - case DISPLAY_PROP_MAX_BRIGHTNESS: - return plugin_intf->OEM_sys_get_backlight_max_brightness(_index, val); - case DISPLAY_PROP_ONOFF: - return plugin_intf->OEM_sys_get_lcd_power(_index, val); - case DISPLAY_PROP_GAMMA: - /* TODO: not supported yet */ - DBG("Gamma is not supported"); - return 0; - case DISPLAY_PROP_DISPLAY_COUNT: - *val = _max_disp_cnt; - return 0; - case DISPLAY_PROP_ACL_CONTROL: - return plugin_intf->OEM_sys_get_backlight_acl_control(_index, val); - case DISPLAY_PROP_IMAGE_ENHANCE_MODE: - return plugin_intf->OEM_sys_get_image_enhance_mode(val); - case DISPLAY_PROP_IMAGE_ENHANCE_SCENARIO: - return plugin_intf->OEM_sys_get_image_enhance_scenario(val); - case DISPLAY_PROP_IMAGE_ENHANCE_TONE: - return plugin_intf->OEM_sys_get_image_enhance_tone(val); - case DISPLAY_PROP_IMAGE_ENHANCE_OUTDOOR: - return plugin_intf->OEM_sys_get_image_enhance_outdoor(val); + case DISPLAY_PROP_BRIGHTNESS: + /* check power saving */ + vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &power_saving_stat); + if (power_saving_stat == 1) + vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY, &power_saving_display_stat); + if (power_saving_display_stat != 1) + power_saving_display_stat = 0; + return plugin_intf->OEM_sys_get_backlight_brightness(_index, val, power_saving_display_stat); + case DISPLAY_PROP_MIN_BRIGHTNESS: + return plugin_intf->OEM_sys_get_backlight_min_brightness(_index, val); + case DISPLAY_PROP_MAX_BRIGHTNESS: + return plugin_intf->OEM_sys_get_backlight_max_brightness(_index, val); + case DISPLAY_PROP_ONOFF: + return plugin_intf->OEM_sys_get_lcd_power(_index, val); + case DISPLAY_PROP_GAMMA: + /* TODO: not supported yet */ + DBG("Gamma is not supported"); + return 0; + case DISPLAY_PROP_DISPLAY_COUNT: + *val = _max_disp_cnt; + return 0; + case DISPLAY_PROP_ACL_CONTROL: + return plugin_intf->OEM_sys_get_backlight_acl_control(_index, val); + case DISPLAY_PROP_IMAGE_ENHANCE_MODE: + return plugin_intf->OEM_sys_get_image_enhance_mode(val); + case DISPLAY_PROP_IMAGE_ENHANCE_SCENARIO: + return plugin_intf->OEM_sys_get_image_enhance_scenario(val); + case DISPLAY_PROP_IMAGE_ENHANCE_TONE: + return plugin_intf->OEM_sys_get_image_enhance_tone(val); + case DISPLAY_PROP_IMAGE_ENHANCE_OUTDOOR: + return plugin_intf->OEM_sys_get_image_enhance_outdoor(val); + case DISPLAY_PROP_IMAGE_ENHANCE_INFO: + return plugin_intf->OEM_sys_image_enhance_info(val); } return -1; @@ -77,6 +90,8 @@ static int set_video_prop(int prop, int val) int _prop = prop & PROPERTY_MASK; int _index = prop >> 4; int _max_disp_cnt = -1; + int power_saving_stat = -1; + int power_saving_display_stat = -1; DBG("Property: %d, Index: %d", _prop, _index); if (0 > plugin_intf->OEM_sys_get_display_count(&_max_disp_cnt)) { @@ -90,24 +105,30 @@ static int set_video_prop(int prop, int val) } switch (_prop) { - case DISPLAY_PROP_BRIGHTNESS: - return plugin_intf->OEM_sys_set_backlight_brightness(_index, val); - case DISPLAY_PROP_ONOFF: - return plugin_intf->OEM_sys_set_lcd_power(_index, val); - case DISPLAY_PROP_GAMMA: - /* TODO:not supported yet */ - DBG("Gamma is not supported"); - return 0; - case DISPLAY_PROP_ACL_CONTROL: - return plugin_intf->OEM_sys_set_backlight_acl_control(_index, val); - case DISPLAY_PROP_IMAGE_ENHANCE_MODE: - return plugin_intf->OEM_sys_set_image_enhance_mode(val); - case DISPLAY_PROP_IMAGE_ENHANCE_SCENARIO: - return plugin_intf->OEM_sys_set_image_enhance_scenario(val); - case DISPLAY_PROP_IMAGE_ENHANCE_TONE: - return plugin_intf->OEM_sys_set_image_enhance_tone(val); - case DISPLAY_PROP_IMAGE_ENHANCE_OUTDOOR: - return plugin_intf->OEM_sys_set_image_enhance_outdoor(val); + case DISPLAY_PROP_BRIGHTNESS: + /* check power saving */ + vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_SYSMODE_STATUS, &power_saving_stat); + if (power_saving_stat == 1) + vconf_get_bool(VCONFKEY_SETAPPL_PWRSV_CUSTMODE_DISPLAY, &power_saving_display_stat); + if (power_saving_display_stat != 1) + power_saving_display_stat = 0; + return plugin_intf->OEM_sys_set_backlight_brightness(_index, val, power_saving_display_stat); + case DISPLAY_PROP_ONOFF: + return plugin_intf->OEM_sys_set_lcd_power(_index, val); + case DISPLAY_PROP_GAMMA: + /* TODO:not supported yet */ + DBG("Gamma is not supported"); + return 0; + case DISPLAY_PROP_ACL_CONTROL: + return plugin_intf->OEM_sys_set_backlight_acl_control(_index, val); + case DISPLAY_PROP_IMAGE_ENHANCE_MODE: + return plugin_intf->OEM_sys_set_image_enhance_mode(val); + case DISPLAY_PROP_IMAGE_ENHANCE_SCENARIO: + return plugin_intf->OEM_sys_set_image_enhance_scenario(val); + case DISPLAY_PROP_IMAGE_ENHANCE_TONE: + return plugin_intf->OEM_sys_set_image_enhance_tone(val); + case DISPLAY_PROP_IMAGE_ENHANCE_OUTDOOR: + return plugin_intf->OEM_sys_set_image_enhance_outdoor(val); } return -1; diff --git a/devman.pc.in b/devman.pc.in index fa263eb..b99a872 100644 --- a/devman.pc.in +++ b/devman.pc.in @@ -6,7 +6,7 @@ libdir=@LIBDIR@ includedir=@INCLUDEDIR@ Name: device manager -Description: SLP device control library +Description: SAMSUNG Linux platform device control library Version: @VERSION@ Requires: Libs: -L${libdir} -ldevman -ldl diff --git a/devman_haptic.pc.in b/devman_haptic.pc.in index 5cb1018..5683085 100644 --- a/devman_haptic.pc.in +++ b/devman_haptic.pc.in @@ -6,7 +6,7 @@ libdir=@LIBDIR@ includedir=@INCLUDEDIR@ Name: devman_haptic -Description: SLP devman haptic library +Description: SAMSUNG Linux platform motor devman_haptic library Version: @VERSION@ Requires: Libs: -L${libdir} -ldevman diff --git a/devman_plugin.pc.in b/devman_plugin.pc.in index fedd355..0ce74e9 100644 --- a/devman_plugin.pc.in +++ b/devman_plugin.pc.in @@ -6,7 +6,7 @@ libdir=@LIBDIR@ includedir=@INCLUDEDIR@ Name: devman_plugin -Description: SLP devman plugin library +Description: SAMSUNG Linux platform devman plugin library Version: @VERSION@ Requires: Cflags: -I${includedir} diff --git a/image/SLP_devman_PG_architecture.png b/image/SLP_devman_PG_architecture.png old mode 100755 new mode 100644 diff --git a/image/SLP_devman_PG_haptic_architecture.png b/image/SLP_devman_PG_haptic_architecture.png old mode 100755 new mode 100644 diff --git a/SLP_devman_PG.h b/include/SLP_devman_PG.h similarity index 87% rename from SLP_devman_PG.h rename to include/SLP_devman_PG.h index 0c92c17..774ae15 100644 --- a/SLP_devman_PG.h +++ b/include/SLP_devman_PG.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ /** @@ -25,7 +25,7 @@ * @ingroup SLP_PG * @defgroup SLP_PG_DEVMAN Device Manager * @{ - +

Introduction

Purpose

@@ -38,7 +38,7 @@ The scope of this document is limited to Device Manager API usage.

Device Manager Library Overview

General Device Manager

Device Manager library is provided to control the device and to get data about several devices. You can get the data about battery, charger, display and so on.
-Devman library uses sysfs for interfaces with device drivers and kernel. sysfs is a virtual file system provided by Linux 2.6 or above. Please refer to the web site, +Devman library uses sysfs for interfaces with device drivers and kernel. sysfs is a virtual file system provided by Linux 2.6 or above. Please refer to the web site, http://www.kernel.org/pub/linux/kernel/people/mochel/doc/papers/ols-2005/mochel.pdf for more information about sysfs. The following figure shows the basic architecture of devman library @@ -49,14 +49,14 @@ The following figure shows the basic architecture of devman library

Haptic Vibration Functional Level Architecture

@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. +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.

-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. +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.

-The server interacts with the device driver interfaces and generates vibration feedback. +The server interacts with the device driver interfaces and generates vibration feedback.

Haptic Vibration Features

Haptic client features @@ -82,18 +82,18 @@ The server interacts with the device driver interfaces and generates vibration f API : device_get_battery_pct
Parameter : void
Return : int
-Functionality : This API is used to get the remaining battery percentage. On success, integer value(0~100) that indicate remaining battery percentage is returned. +Functionality : This API is used to get the remaining battery percentage. On success, integer value(0~100) that indicate remaining battery percentage is returned. Or a negative value (-1) is returned on failure.

API : device_is_battery_full
Parameter : void
Return : int
-Functionality : This API is used to get the fully charged status of battery. On fully charged, the integer value (1) is returned, +Functionality : This API is used to get the fully charged status of battery. On fully charged, the integer value (1) is returned, (0) is returned if battery is not fully charged, a negative value (-1) is returned on failure.

API : device_get_display_brt
Parameter In : display_num_t num -
Return : int +
Return : int
Functionality : This API is used to get the current brightness of the display from sysfs. The function returns the current brightness value on success and a negative value (-1) on failure.

@@ -110,28 +110,28 @@ typedef enum { API : device_set_display_brt
Parameter In : display_num_t num
Parameter In : int val -
Return : int -
Functionality : This API is used to set the current brightness of the display using sysfs. +
Return : int +
Functionality : This API is used to set the current brightness of the display using sysfs. The parameter val should be set as a brightnesss value of your target. The function returns the current brightness value on success and a negative value (-1) on failure.

API : device_get_display_gamma
Parameter In : display_num_t num -
Return : int +
Return : int
Functionality : This API is used to get the current gamma value of the display from sysfs. The function returns the current brightness value on success and a negative value (-1) on failure.

API : device_set_display_brt
Parameter In : display_num_t num
Parameter In : int val -
Return : int -
Functionality : This API is used to set the current brightness of the display using sysfs. +
Return : int +
Functionality : This API is used to set the current brightness of the display using sysfs. The parameter val should be set as a brightnesss value of your target. The function returns the current brightness value on success and a negative value (-1) on failure.

API : device_get_display_gamma
Parameter In : display_num_t num -
Return : int +
Return : int
Functionality : This API is used to get the current gamma value of the display from sysfs. The function returns the current brightness value on success and a negative value (-1) on failure. Enumerate values: @@ -141,51 +141,51 @@ typedef enum { LCD_GAMMA_22 = 1, // 8500K , 2.2 GAMMA LCD_GAMMA_19 = 2, // 8500K , 1.9 GAMMA LCD_GAMMA_17 = 3, // 8500K , 1.7 GAMMA - LCD_GAMMA_NORMAL = LCD_GAMMA_22, // Normal screen - LCD_GAMMA_PLAY_RECORD = LCD_GAMMA_19, // Playing or recording cam - LCD_GAMMA_PREVIEW = LCD_GAMMA_17, // Preview - LCD_GAMMA_MOVIE = LCD_GAMMA_19, // Movie - LCD_GAMMA_CAMERA = 11, // Camera + LCD_GAMMA_NORMAL = LCD_GAMMA_22, // Normal screen + LCD_GAMMA_PLAY_RECORD = LCD_GAMMA_19, // Playing or recording cam + LCD_GAMMA_PREVIEW = LCD_GAMMA_17, // Preview + LCD_GAMMA_MOVIE = LCD_GAMMA_19, // Movie + LCD_GAMMA_CAMERA = 11, // Camera } display_gamma_t; @endcode API : device_power_suspend
Parameter : void -
Return : int -
Functionality : This API is used to make the phone go to a suspend (sleep) state. +
Return : int +
Functionality : This API is used to make the phone go to a suspend (sleep) state. The suspend state consumes little battery power. If the caller process does not have the permission which is root, it returns failure. The function returns 0 on success and a negative value (-1) on failure.

API : device_get_property
Parameter In : devtype_t devtype -
Parameter In : int property +
Parameter In : int property
Parameter Out : int *value -
Return : int -
Functionality :This generic API is used to get the property values of supported devices. +
Return : int +
Functionality :This generic API is used to get the property values of supported devices. If the caller process does not have permission, it returns failure. The function returns 0 on success and a negative value (-1) on failure.

API : device_set_property
Parameter In : devtype_t devtype -
Parameter In : int property +
Parameter In : int property
Parameter In : int value -
Return : int -
Functionality :This generic API is used to set the property values of supported devices. +
Return : int +
Functionality :This generic API is used to set the property values of supported devices. If the caller process does not have permission, it returns failure. The function returns 0 on success and a negative value (-1) on failure.

Haptic Device Manager APIs

API : device_haptic_open
Parameter In : haptic_dev_idx dev_idx , unsigned int mode -
Return : int -
Functionality : This API opens a Haptic-vibration device. On success it returns a dev_handle value. +
Return : int +
Functionality : 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).
-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 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.
The second in parameter mode is reserved for future so just set a 0 value
-Note: 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(). +Note: 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. Enumerate values: @@ -200,23 +200,23 @@ typedef enum haptic_dev_idx_t { API : device_haptic_close
Parameter In : int dev_handle -
Parameter Return : int -
Functionality : This API closes a Haptic-vibration device. On success it returns a zero value. +
Parameter Return : int +
Functionality : 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).
The first in parameter dev_handle should be from the return value of device_haptic_open().

API : device_haptic_play_pattern
Parameter In : int dev_handle , int pattern , int iteration , int feedback_level -
Parameter Return : int +
Parameter Return : int
Functionality : This API plays a predefined rhythmic haptic-vibration pattern.
The first in parameter dev_handle should be from the return value of device_haptic_open().
-The second in parameter pattern should be from a predefined pattern list which is available in an enumeration (effectvibe_pattern_list). +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.
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).
-The fourth in parameter is the vibration feedback intensity level. This level is already predefined by enumeration type value from HAPTIC _FEEDBACK_LEVEL_1 +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.
On success it returns a zero value. In case of failure it returns a negative value.
-Note: The actual behavior of the feedback play pattern and the intensity depends on the target hardware. +Note: The actual behavior of the feedback play pattern and the intensity depends on the target hardware. Enumerate values: @code @@ -227,11 +227,11 @@ enum effectvibe_pattern_list { EFFCTVIBE_NOTIFICATION, EFFCTVIBE_INCOMING_CALL01, EFFCTVIBE_INCOMING_CALL02, - EFFCTVIBE_INCOMONG_CALL03, + EFFCTVIBE_INCOMONG_CALL03, EFFCTVIBE_ALERTS_CALL, EFFCTVIBE_OPERATION, EFFCTVIBE_SILENT_MODE, - EFFCTVIBE_PATTERN_END + EFFCTVIBE_PATTERN_END }; //Feedback Level ; @@ -250,22 +250,22 @@ enum { API : device_haptic_play_file
Parameter In : int dev_handle , const char *file_name , int iteration , int feedback_level -
Parameter Return : int +
Parameter Return : int
Functionality :This API plays a predefined rhythmic haptic-vibration pattern file (only supports .ivt type file, Immersion VibeTonz).
The first in parameter dev_handle should be from the return value of device_haptic_open().
The second in parameter file_name sets rhythmic vibration pattern file with path. It only supports .ivt type pattern file.
-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). +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.
-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. +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 )
On success it returns a zero value. In case of failure it returns a negative value.
Note: The actual behavior of the feedback play pattern and the intensity depends on the target hardware.

API : device_haptic_play_monotone -
Parameter In : int dev_handle , int duration -
Parameter Return : int -
Functionality :This API plays a monotonous haptic-vibration pattern with a constant intensity. +
Parameter In : int dev_handle , int duration +
Parameter Return : int +
Functionality :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.
The first in parameter dev_handle should be from the return value of device_haptic_open().
The second in parameter duration defines the length of time this vibration should be played. This duration is in milliseconds.
@@ -274,15 +274,15 @@ On success it returns a zero value. In case of failure it returns a negative val

API : device_haptic_stop_play
Parameter In : int dev_handle -
Parameter Return : int +
Parameter Return : int
Functionality : This API stops the current vibration being played.
The first in parameter dev_handle should be from the return value of device_haptic_open().
-On success it returns a zero value. In case of failure it returns a negative value. +On success it returns a zero value. In case of failure it returns a negative value.

API : device_haptic_get_pattern_duration -
Parameter In : int dev_handle , int pattern -
Parameter Out : int *duration -
Parameter Return : int +
Parameter In : int dev_handle , int pattern +
Parameter Out : int *duration +
Parameter Return : int
Functionality :This API gets a duration time value from a predefined rhythmic vibration pattern.
The first in parameter dev_handle should be from the return value of device_haptic_open().
The second in parameter pattern should be from a predefined pattern list which is available in an enumeration (effectvibe_pattern_list).
@@ -291,9 +291,9 @@ On success it returns a zero value. In case of failure it returns a negative val Note: The actual behavior of the feedback played and the intensity depends on the target hardware.

API : device_haptic_get_file_duration -
Parameter In : int dev_handle , const char *file_name -
Parameter Out : int *duration -
Parameter Return : int +
Parameter In : int dev_handle , const char *file_name +
Parameter Out : int *duration +
Parameter Return : int
Functionality :This API gets a duration time value from a predefined rhythmic vibration pattern file (only supports .ivt type file).
The first in parameter dev_handle should be from the return value of device_haptic_open().
The second in parameter file_name sets rhythmic vibration pattern file with path. It only supports .ivt type pattern file.
@@ -310,7 +310,7 @@ On success it returns a zero value. In case of failure it returns a negative val int main() { int ret_val=0; - int dev_handle; + int dev_handle; printf("\n Haptic vibration test : Start of the program \n"); @@ -320,24 +320,24 @@ int main() return -1; //Play a rhythmic pattern - ret_val = device_haptic_play_pattern(dev_handle, EFFCTVIBE_NOTIFICATION, - HAPTIC_TEST_ITERATION , HAPTIC_FEEDBACK_LEVEL_3); + 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); + 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); + ret_val = device_haptic_play_monotone(dev_handle, 10000); if(ret_val !=0) return -1; sleep(1); - //Stop the pattern immediately + //Stop the pattern immediately ret_val = device_haptic_stop_play(dev_handle); if(ret_val !=0) return -1; diff --git a/device_engine.h b/include/device_engine.h old mode 100755 new mode 100644 similarity index 99% rename from device_engine.h rename to include/device_engine.h index 7e857d2..1c58ad3 --- a/device_engine.h +++ b/include/device_engine.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ diff --git a/device_haptic.h b/include/device_haptic.h old mode 100755 new mode 100644 similarity index 91% rename from device_haptic.h rename to include/device_haptic.h index 8d0c3fc..b0587e6 --- a/device_haptic.h +++ b/include/device_haptic.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #ifndef __DEVICE_HAPTIC_H__ @@ -38,6 +38,11 @@ extern "C" { #define DEFAULT_DEVICE_HANDLE 1 /* + * Default duration value + */ +#define DEFAULT_DURATION_VALUE 30 + +/* * Motor property for generic APIs */ enum { @@ -51,6 +56,7 @@ extern "C" { * Feedback level for generic APIs */ enum { + VIBE_FEEDBACK_LEVEL_0 = 0, /* HAPTIC FEEDBACK LEVEL 0 */ VIBE_FEEDBACK_LEVEL_1 = 2000, /* HAPTIC_FEEDBACK_LEVEL_1 */ VIBE_FEEDBACK_LEVEL_2 = 4000, /* HAPTIC_FEEDBACK_LEVEL_2 */ VIBE_FEEDBACK_LEVEL_3 = 6000, /* HAPTIC_FEEDBACK_LEVEL_3 */ diff --git a/device_haptic_tsp4000_pattern.h b/include/device_haptic_tsp4000_pattern.h similarity index 99% rename from device_haptic_tsp4000_pattern.h rename to include/device_haptic_tsp4000_pattern.h index 7a7f253..d96cc12 100644 --- a/device_haptic_tsp4000_pattern.h +++ b/include/device_haptic_tsp4000_pattern.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,14 +17,12 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #ifndef __DEVICE_HAPTIC_TSP4000_PATTERN_H__ #define __DEVICE_HAPTIC_TSP4000_PATTERN_H__ -#include "devman_haptic_ext.h" - ///////////////// // for Beat UX // diff --git a/device_plugin.h b/include/device_plugin.h similarity index 100% rename from device_plugin.h rename to include/device_plugin.h diff --git a/devlog.h b/include/devlog.h similarity index 96% rename from devlog.h rename to include/devlog.h index a96779c..b44b1be 100644 --- a/devlog.h +++ b/include/devlog.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #ifndef __DEVLOG_H__ @@ -29,7 +29,7 @@ * * If SLP_DEBUG is not defined, SYSLOG_DBG() and PRT_DBG() is ignored. * - * IF SLP_SYSLOG_OUT is defined, + * IF SLP_SYSLOG_OUT is defined, * INFO(), ERR(), DBG() are SYSLOG_XXX() * IF ENABLE_DLOG_OUT is defined, * INFO(), ERR(), DBG() are SLOGI(), SLOGE(), SLOGD() @@ -39,9 +39,9 @@ * * warn_if(exrp, fmt, ...) * If expr is true, The fmt string is printed using ERR(). - * - * ret_if(), retv_if(), retm_if(), retvm_if() - * If expr is true, current function return. + * + * ret_if(), retv_if(), retm_if(), retvm_if() + * If expr is true, current function return. * Postfix 'v' means that it has a return value and 'm' means that it has output message. * */ diff --git a/devman.h b/include/devman.h old mode 100755 new mode 100644 similarity index 68% rename from devman.h rename to include/devman.h index 57e802b..d2e3f33 --- a/devman.h +++ b/include/devman.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #ifndef __DEVMAN_H__ @@ -27,11 +27,16 @@ #define DEPRECATED __attribute__((deprecated)) #endif +#include "devman_error.h" +/** START: This code related to the opensource api will be removed */ +#include "devman_managed.h" +/** END: Will be remved */ + #ifdef __cplusplus extern "C" { #endif -/** +/** * @file devman.h * @ingroup DEVICE_MANAGER * @brief This file contains the API for the status of devices @@ -57,24 +62,24 @@ extern "C" { * device type enum */ typedef enum devtype_list { - DEVTYPE_POWERSUPPLY, /**< battery, PMIC, etc about power */ + DEVTYPE_POWERSUPPLY, /**< battery, PMIC, etc about power */ DEVTYPE_DISPLAY0, /**< main screen */ DEVTYPE_DISPLAY1, /**< sub screen */ DEVTYPE_HAPTIC, /**< motor */ DEVTYPE_LED, /**< LED */ DEVTYPE_JACK, /**< jack - Micro USB, 3.5 pi jack etc */ - DEVTYPE_TOUCHSCREEN, /**< main touch screen */ + DEVTYPE_TOUCHSCREEN, /**< main touch screen */ DEVTYPE_TOUCHKEY, /**< touchkey */ DEVTYPE_GPS, DEVTYPE_UART, DEVTYPE_MMC, /**< MMC card(Micro SD) */ - DEVTYPE_EFFECT_HAPTIC, /**< extended touchsense */ + DEVTYPE_EFFECT_HAPTIC, /**< extended touchsense */ DEVTYPE_POWER, DEVTYPE_MAX } devtype_t; -/** +/** * @par Description: * DEVTYPE_POWER property for generic APIs */ @@ -83,7 +88,7 @@ extern "C" { POWER_PROP_WAKEUP_COUNT, }; -/** +/** * @par Description: * DEVTYPE_POWERSUPPLY property for generic APIs */ @@ -96,6 +101,8 @@ extern "C" { POWER_SUPPLY_PROP_CAPACITY, /**< iBattery status about cahrge */ POWER_SUPPLY_PROP_BATTERY_HEALTH, + /**< Current remaining battery expressed 1/10000 */ + POWER_SUPPLY_PROP_CAPACITY_RAW, }; /** @@ -105,6 +112,7 @@ extern "C" { enum { DISPLAY_PROP_ONOFF, DISPLAY_PROP_BRIGHTNESS, + DISPLAY_PROP_MIN_BRIGHTNESS, DISPLAY_PROP_MAX_BRIGHTNESS, DISPLAY_PROP_GAMMA, DISPLAY_PROP_DISPLAY_COUNT, @@ -113,6 +121,7 @@ extern "C" { DISPLAY_PROP_IMAGE_ENHANCE_SCENARIO, DISPLAY_PROP_IMAGE_ENHANCE_TONE, DISPLAY_PROP_IMAGE_ENHANCE_OUTDOOR, + DISPLAY_PROP_IMAGE_ENHANCE_INFO, }; /** @@ -175,7 +184,7 @@ extern "C" { * @par Description: * This generic API is used to get the property values of supported devices.\n * If the caller process does not have permission, it returns failure. - * @param[in] devtype device type that you want to get the value + * @param[in] devtype device type that you want to get the value * @param[in] property value property that you want to get the value * @param[out] *value current value of device property * @return 0 on success, -1 if failed @@ -185,7 +194,7 @@ extern "C" { * ... * if( device_get_property(DEVTYPE_POWERSUPPLY, POWER_SUPPLY_PROP_CAPACITY, &val) < 0 ) * printf("Fail to get property\n"); - * else + * else * printf("Property is %d\n", val); * ... * @endcode @@ -195,7 +204,7 @@ extern "C" { /** * @fn int device_set_property(devtype_t devtype, int property, int value) * @par Description: - * This generic API is used to set the property values of supported devices.\n + * This generic API is used to set the property values of supported devices.\n * If the caller process does not have permission, it returns failure. * @param[in] devtype device type that you want to set the value * @param[in] property value property that you want to set the value @@ -222,9 +231,9 @@ extern "C" { * It gets the Battery percentage by calling device_get_property() function.\n * It returns integer value(0~100) that indicate remaining batterty percentage on success.\n * Or a negative value(-1) is returned on failure. - * @return On success, integer value(0~100) is returned. - * Or a negative value(-1) is returned on failure. - * @see device_is_battery_full() + * @return On success, integer value(0~100) is returned. + * Or a negative value(-1) is returned on failure. + * @see device_is_battery_full(), device_get_battery_pct_raw() * @par Example * @code * ... @@ -234,15 +243,38 @@ extern "C" { * printf("Fail to get the remaining battery percentage.\n"); * else * printf("remaining battery percentage : %d\n", battery); - * ... + * ... * @endcode */ int device_get_battery_pct(void); /** * @par Description: + * This API is used to get the remaining battery percentage expressed 1/10000.\n + * It gets the Battery percentage by calling device_get_property() function.\n + * It returns integer value(0~10000) that indicate remaining batterty percentage on success.\n + * Or a negative value(-1) is returned on failure. + * @return On success, integer value(0~10000) is returned. + * Or a negative value(-1) is returned on failure. + * @see device_is_battery_full(), device_get_battery_pct() + * @par Example + * @code + * ... + * int battery; + * battery = device_get_battery_pct_raw(); + * if( battery < 0 ) + * printf("Fail to get the remaining battery percentage.\n"); + * else + * printf("remaining battery percentage expressed 1/10000 : %d\n", battery); + * ... + * @endcode + */ + int device_get_battery_pct_raw(void); + +/** + * @par Description: * This API is used to get the fully charged status of battery.\n - * It gets the fully charged status of Battery by calling device_get_property() function.\n + * It gets the fully charged status of Battery by calling device_get_property() function.\n * If the status of battery is full, it returns 1.\n * Or a negative value(-1) is returned, if the status of battery is not full. * @return 1 with battery full, or 0 on not full-charged, -1 if failed @@ -252,7 +284,7 @@ extern "C" { * ... * if ( device_is_battery_full() > 0 ) * printf("battery fully chared\n"); - * ... + * ... * @endcode */ int device_is_battery_full(void); @@ -287,7 +319,7 @@ extern "C" { * bat_health =device_get_battery_health(); * if(bat_health != BAT_GOOD) * printf("battery health is not good\n"); - * ... + * ... * @endcode */ int device_get_battery_health(void); @@ -327,11 +359,11 @@ extern "C" { /** * @par Description: - * This API is used to set the current brightness of the display.\n - * It sets the current brightness of the display by calling device_set_property() function.\n + * This API is used to set the current brightness of the display.\n + * It sets the current brightness of the display by calling device_set_property() function.\n * MUST use this API very carefully. \n - * you MUST set original brightness by device_release_brt_ctrl(), - * after you finish your job using this API. + * you MUST set original brightness by device_release_brt_ctrl(), + * after you finish your job using this API. * @param[in] num display number that you want to set the brightness value * @param[in] val brightness value that you want to set * @return 0 on success, -1 if failed @@ -340,9 +372,9 @@ extern "C" { * @code * ... * if( device_set_display_brt(0,6) < 0 ) - * printf("Fail to set the current brightness of the display0\n"); + * printf("Fail to set the current brightness of the display0\n"); * else - * printf("The current brightness of the display0 is set 6\n"); + * printf("The current brightness of the display0 is set 6\n"); * ... * @endcode */ @@ -351,7 +383,7 @@ extern "C" { /** * @par Description: * This API is used to release brightness control.\n - * It sets the current brightness of the display by calling device_set_property() function.\n + * It sets the current brightness of the display by calling device_set_property() function.\n * MUST call this API after you finished the job which need to change the brightness. * @param[in] num display number * @return 0 on success, -1 if failed @@ -372,27 +404,49 @@ extern "C" { /** * @par Description: - * This API is used to get the max brightness of the display.\n - * It gets the current brightness of the display by calling device_get_property() function.\n - * It returns integer value which is the max brightness on success.\n - * Or a negative value(-1) is returned on failure + * This API is used to get the min brightness of the display.\n + * It gets the current brightness of the display by calling device_get_property() function.\n + * It returns integer value which is the min brightness on success.\n + * Or a negative value(-1) is returned on failure + * @param[in] num display number + * @return min brightness value on success, -1 if failed + * @par Example + * @code + * ... + * int min_brt; + * min_brt = device_get_min_brt(0); + * if( min_brt < 0 ) + * printf("Fail to get the min brightness of the display.\n"); + * else + * printf("Min brightness of the display is %d\n", min_brt); + * ... + * @endcode + */ + int device_get_min_brt(display_num_t num); + +/** + * @par Description: + * This API is used to get the max brightness of the display.\n + * It gets the current brightness of the display by calling device_get_property() function.\n + * It returns integer value which is the max brightness on success.\n + * Or a negative value(-1) is returned on failure * @param[in] num display number * @return max brightness value on success, -1 if failed * @par Example * @code - * ... - * int max_brt; - * max_brt = device_get_max_brt(0); - * if( max_brt < 0 ) - * printf("Fail to get the max brightness of the display.\n"); - * else - * printf("Max brightness of the display is %d\n", max_brt); - * ... + * ... + * int max_brt; + * max_brt = device_get_max_brt(0); + * if( max_brt < 0 ) + * printf("Fail to get the max brightness of the display.\n"); + * else + * printf("Max brightness of the display is %d\n", max_brt); + * ... * @endcode */ int device_get_max_brt(display_num_t num); -/** +/** * @par Description: * LCD gamma values */ @@ -410,264 +464,91 @@ extern "C" { /** * @par Description: * This API is used to get the current gamma of the display.\n - * It gets the current gamma of the display by calling device_get_property() function.\n - * It returns enum value which is the current gamma on success.\n - * Or a negative value(-1) is returned on failure. + * It gets the current gamma of the display by calling device_get_property() function.\n + * It returns enum value which is the current gamma on success.\n + * Or a negative value(-1) is returned on failure. * @param[in] num display number that you want to get the gamma value * @return current gamma enum value on success, -1 if failed * @see device_set_diplay_gamma() * @par Example * @code - * ... - * int cur_brt; - * cur_brt = device_get_display_gamma(0); - * if( cur_brt < 0 ) - * printf("Fail to get the current gamma of the display.\n"); - * else - * printf("Current gamma of the display is %d\n", cer_brt); - * ... + * ... + * int cur_brt; + * cur_brt = device_get_display_gamma(0); + * if( cur_brt < 0 ) + * printf("Fail to get the current gamma of the display.\n"); + * else + * printf("Current gamma of the display is %d\n", cer_brt); + * ... * @endcode */ int device_get_display_gamma(display_num_t num); /** * @par Description: - * This API is used to set the specific gamma value of the display .\n - * It sets the specific gamma value of the display by calling device_set_property() function.\n - * MUST use this API very carefully. \n - * you MUST set original gamma by device_release_gamma_ctrl(), - * after you finish your job using this API. + * This API is used to set the specific gamma value of the display .\n + * It sets the specific gamma value of the display by calling device_set_property() function.\n + * MUST use this API very carefully. \n + * you MUST set original gamma by device_release_gamma_ctrl(), + * after you finish your job using this API. * @param[in] num display number that you want to set the gamma value * @param[in] new_val lcd gamma enum value that you want to set * @return 0 on success, -1 if failed * @see device_get_diplay_gammat(), device_release_gamma_ctrl() * @par Example * @code - * ... - * if( device_set_display_gamma(0,1) < 0 ) - * printf("Fail to set the specific gamma of the display0\n"); - * else - * printf("The gamma of the display0 is set 1(LCD_GAMMA_22)\n"); - * ... + * ... + * if( device_set_display_gamma(0,1) < 0 ) + * printf("Fail to set the specific gamma of the display0\n"); + * else + * printf("The gamma of the display0 is set 1(LCD_GAMMA_22)\n"); + * ... * @endcode */ int device_set_display_gamma(display_num_t num, - display_gamma_t new_val); + display_gamma_t new_val); /** * @par Description: * This API is used to release gamma control.\n - * It sets the gamma of the display by calling device_set_property() function.\n - * MUST call this API after you finished the job which need to change the gamma. + * It sets the gamma of the display by calling device_set_property() function.\n + * MUST call this API after you finished the job which need to change the gamma. * @param[in] num display number * @param[in] org_val original gamma enums value before you control the gamma * @return 0 on success, -1 if failed * @see device_set_display_gamma() * @par Example * @code - * ... - * org_val = device_get_display_gamma(0); - * device_set_display_gamma(0,2); - * ... - * ret = device_release_gamma_ctrl(0, org_val); - * if( ret < 0 ) - * printf("Fail to release gamma control\n"); - * ... - * @endcode - */ - int device_release_gamma_ctrl(display_num_t num, - display_gamma_t org_val); - -/** - * @par Description: - * This API is used to get number of displays on the phone.\n - * It gets the current number of displays by calling device_get_display_count() function.\n - * It returns enum value which is the current number on success.\n - * Or a negative value(-1) is returned on failure. - * @return 0 on success, -1 if failed - * @par Example - * @code - * ... - * ret = device_get_display_count(); - * if( ret < 0 ) - * printf("Fail to get number of displays\n"); - * ... - * @endcode - */ - int device_get_display_count(void); - -/** - * @par Description: - * mode - dynamic, standard, natural, movie - */ - enum image_enhance_mode { - MODE_DYNAMIC = 0, - MODE_STANDARD, - MODE_NATURAL, - MODE_MOVIE, - }; - -/** - * @par Description: - * This API is used to get image enhance mode.\n - * It returns enum value which is the current mode on success.\n - * Or a negative value(-1) is returned on failure. - * @return enum value for current mode on success, -1 if failed - * @par Example - * @code * ... - * ret = device_get_image_enhance_mode(); - * if( ret < 0 ) - * printf("Fail to get current image enhance mode\n"); - * ... - * @endcode - */ - int device_get_image_enhance_mode(void); - -/** - * @par Description: - * This API is used to set image enhance mode.\n - * @param[in] val mode enum vlaue - * @return 0 on success, -1 if failed - * @par Example - * @code - * ... - * if( device_set_image_enhance_mode(MODE_DYNAMIC) < 0 ) - * printf("Fail to set the image enhance mode\n"); - * ... - * @endcode - */ - int device_set_image_enhance_mode(int val); - -/** - * @par Description: - * scenario - ui, gallery, video, vtcall, camera, browser, negative, bypass - */ - enum image_enhance_scenario { - SCENARIO_UI = 0, - SCENARIO_GALLERY, - SCENARIO_VIDEO, - SCENARIO_VTCALL, - SCENARIO_CAMERA, - SCENARIO_BROWSER, - SCENARIO_NEGATIVE, - SCENARIO_BYPASS, - }; - -/** - * @par Description: - * This API is used to get image enhance scenario.\n - * It returns enum value which is the current scenario on success.\n - * Or a negative value(-1) is returned on failure. - * @return enum value for current wcenario on success, -1 if failed - * @par Example - * @code - * ... - * ret = device_get_image_enhance_scenario(); - * if( ret < 0 ) - * printf("Fail to get current image enhance scenarioe\n"); - * ... - * @endcode - */ - int device_get_image_enhance_scenario(void); - -/** - * @par Description: - * This API is used to set image enhance scenario.\n - * @param[in] val scenario enum vlaue - * @return 0 on success, -1 if failed - * @par Example - * @code - * ... - * if( device_set_image_enhance_scenario(SCENARIO_UI) < 0 ) - * printf("Fail to set the image enhance scenario\n"); - * ... - * @endcode - */ - int device_set_image_enhance_scenario(int val); - -/** - * @par Description: - * tone - normal, warm, cold - */ - enum image_enhance_tone { - TONE_NORMAL = 0, - TONE_WARM, - TONE_COLD, - }; - -/** - * @par Description: - * This API is used to get image enhance tone.\n - * It returns enum value which is the current mode on success.\n - * Or a negative value(-1) is returned on failure. - * @return enum value for current tone on success, -1 if failed - * @par Example - * @code + * org_val = device_get_display_gamma(0); + * device_set_display_gamma(0,2); * ... - * ret = device_get_image_enhance_tone(); + * ret = device_release_gamma_ctrl(0, org_val); * if( ret < 0 ) - * printf("Fail to get current image enhance tone\n"); - * ... - * @endcode - */ - int device_get_image_enhance_tone(void); - -/** - * @par Description: - * This API is used to set image enhance tone.\n - * @param[in] val tone vlaue - * @return 0 on success, -1 if failed - * @par Example - * @code - * ... - * if( device_set_image_enhance_tone(TONE_NORMAL) < 0 ) - * printf("Fail to set the image enhance tone\n"); + * printf("Fail to release gamma control\n"); * ... * @endcode */ - int device_set_image_enhance_tone(int val); - -/** - * @par Description: - * outdoor - off, on - */ - enum image_enhance_outdoor { - OUTDOOR_OFF = 0, - OUTDOOR_ON, - }; + int device_release_gamma_ctrl(display_num_t num, + display_gamma_t org_val); /** * @par Description: - * This API is used to get image enhance outdoor.\n - * It returns enum value which is the current outdoor on success.\n + * This API is used to get number of displays on the phone.\n + * It gets the current number of displays by calling device_get_display_count() function.\n + * It returns enum value which is the current number on success.\n * Or a negative value(-1) is returned on failure. - * @return enum value for current outdoor on success, -1 if failed - * @par Example - * @code - * ... - * ret = device_get_image_enhance_ourdoor(); - * if( ret < 0 ) - * printf("Fail to get current image enhance outdoor\n"); - * ... - * @endcode - */ - int device_get_image_enhance_outdoor(void); - -/** - * @par Description: - * This API is used to set image enhance outdoor.\n - * @param[in] val outdoor vlaue * @return 0 on success, -1 if failed * @par Example * @code - * ... - * if( device_set_image_enhance_outdoor(TONE_NORMAL) < 0 ) - * printf("Fail to set the image enhance outdoor\n"); + * ... + * ret = device_get_display_count(); + * if( ret < 0 ) + * printf("Fail to get number of displays\n"); * ... * @endcode */ - int device_set_image_enhance_outdoor(int val); + int device_get_display_count(void); /** * @par Description: @@ -680,8 +561,8 @@ extern "C" { * ... * ret = device_power_suspend(); * if( ret < 0 ) - * printf("Fail to make the phone go to a suspend (sleep) state\n"); - * ... + * printf("Fail to make the phone go to a suspend (sleep) state\n"); + * ... * @endcode */ int device_power_suspend(void); @@ -710,7 +591,7 @@ extern "C" { /** * @par Description: - * This API is used to set the current brightness of the led.\n + * This API is used to set the current brightness of the led.\n * It sets the current brightness of the led by calling device_set_property() function.\n * @param[in] val brightness value that you want to set * @return 0 on success, -1 if failed @@ -766,7 +647,7 @@ extern "C" { /** * @par Description: - * This API is used to set the current status for acl.\n + * This API is used to set the current status for acl.\n * It sets the current status for acl by calling device_set_property() function.\n * @param[in] num display number that you want to set the brightness value * @param[in] val status for acl(1 on, 0 off) that you want to set diff --git a/include/devman_error.h b/include/devman_error.h new file mode 100644 index 0000000..31a0b11 --- /dev/null +++ b/include/devman_error.h @@ -0,0 +1,65 @@ +/* + * devman + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jiyoung Yun + * + * 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 __DEVMAN_ERROR_H__ +#define __DEVMAN_ERROR_H__ + +#ifndef DEPRECATED +#define DEPRECATED __attribute__((deprecated)) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file devman_error.h + * @ingroup DEVICE_MANAGER + * @brief This file contains error state for devman + * @author SLP2.0 + * @date 2012-08-10 + * @version 0.1 + */ + +/** + * @addtogroup DEVICE_MANAGER + * @{ + */ + +/** + * @brief Enumerations of error code for Devman + */ +typedef enum +{ + DEVMAN_ERROR_NONE = 0, /**< Successful */ + DEVMAN_ERROR_OPERATION_FAILED = -1, /**< Operation failed */ + DEVMAN_ERROR_NOT_SUPPORTED = -2, /**< Not supported in this device */ +} devman_error_e; + +/** + * @} // end of internal APIs + */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/devman_haptic.h b/include/devman_haptic.h old mode 100755 new mode 100644 similarity index 80% rename from devman_haptic.h rename to include/devman_haptic.h index 66d3cb4..05c055f --- a/devman_haptic.h +++ b/include/devman_haptic.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #ifndef __DEVMAN_HAPTIC_H__ @@ -27,7 +27,7 @@ extern "C" { #endif -/** +/** * @file devman_haptic.h * @ingroup DEVICE_MANAGER * @brief This file contains the prototypes of the haptic API @@ -63,15 +63,28 @@ extern "C" { /** * @par Description: + * priority level for haptic. + */ + enum haptic_priority_level { + HAPTIC_PRIORITY_LEVEL_MIN = 0, /**< Minimum effect priority for developers */ + HAPTIC_PRIORITY_LEVEL_MAX_DEV, /**< Maximum effect priority for developers */ + HAPTIC_PRIORITY_LEVEL_MAX_OEM, /**< Maximum effect priority for OEMs */ + }; + +/** + * @par Description: * feedback level for haptic. */ enum haptic_feedback_level { - HAPTIC_FEEDBACK_LEVEL_AUTO = -1, /**< auto feedback level */ - HAPTIC_FEEDBACK_LEVEL_1 = 1, /**< feedback level 1 */ - HAPTIC_FEEDBACK_LEVEL_2 = 2, /**< feedback level 2 */ - HAPTIC_FEEDBACK_LEVEL_3 = 3, /**< feedback level 3 */ - HAPTIC_FEEDBACK_LEVEL_4 = 4, /**< feedback level 4 */ - HAPTIC_FEEDBACK_LEVEL_5 = 5, /**< feedback level 5 */ + HAPTIC_FEEDBACK_LEVEL_AUTO = -1, /**< auto feedback level */ + HAPTIC_FEEDBACK_LEVEL_0, /**< feedback level 0 */ + HAPTIC_FEEDBACK_LEVEL_1, /**< feedback level 1 */ + HAPTIC_FEEDBACK_LEVEL_2, /**< feedback level 2 */ + HAPTIC_FEEDBACK_LEVEL_3, /**< feedback level 3 */ + HAPTIC_FEEDBACK_LEVEL_4, /**< feedback level 4 */ + HAPTIC_FEEDBACK_LEVEL_5, /**< feedback level 5 */ + + HAPTIC_FEEDBACK_LEVEL_END, }; /** @@ -84,10 +97,13 @@ extern "C" { * @par Description: * Return Values */ -#define HAPTIC_SUCCESS 0 -#define HAPTIC_NOT_OPENED -2 -#define HAPTIC_FAIL -4 -#define HAPTIC_NOT_SUPPORTED -13 +#define HAPTIC_SUCCESS 0 +#define HAPTIC_ALREADY_INITIALIZED -1 +#define HAPTIC_NOT_OPENED -2 +#define HAPTIC_INVALID_ARGUMENT -3 +#define HAPTIC_FAIL -4 +#define HAPTIC_NOT_SUPPORTED -13 +#define HAPTIC_ALREADY_EXIST -14 /** * @par Description: @@ -111,7 +127,7 @@ extern "C" { * 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.\n * The second in parameter mode is reserved for future so just set a 0 value\n * Note: The device_haptic_open() must be called before all other haptic APIs are called. \n - * The device_haptic_open() should have a matching call to device_haptic_close().\n + * The device_haptic_open() should have a matching call to device_haptic_close().\n * Applications call the device_haptic_open() only once if possible during application startup and call the device_haptic_close() during application shutdown. * @param[in] dev_idx set a device index (predefined enum value by haptic_dev_idx) * @param[in] mode just set a "0" value (not support current , reserved for future) @@ -121,7 +137,7 @@ extern "C" { * @code * ... * int ret_val=0; - * int dev_handle; + * int dev_handle; * * //Open the haptic device * dev_handle = device_haptic_open(DEV_IDX_0,0); @@ -162,12 +178,12 @@ extern "C" { * @par Description: * This API plays a predefined rhythmic haptic-vibration pattern. \n * The first in parameter dev_handle should be from the return value of device_haptic_open().\n - * The second in parameter pattern should be from a predefined pattern list which is available in an enumeration (effectvibe_pattern_list). + * 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. \n - * The third in parameter iteration sets the number of iterations to be played. + * 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). \n - * 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. + * 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.\n * On success it returns a zero value. In case of failure it returns a negative value. \n * Note: The actual behavior of the feedback play pattern and the intensity depends on the target hardware. @@ -181,11 +197,11 @@ extern "C" { * @code * ... * //Play a rhythmic pattern - * ret_val = device_haptic_play_pattern(dev_handle, EFFCTVIBE_POPUP, HAPTIC_TEST_ITERATION , HAPTIC_FEEDBACK_LEVEL_3); + * ret_val = device_haptic_play_pattern(dev_handle, EFFCTVIBE_POPUP, HAPTIC_TEST_ITERATION , HAPTIC_FEEDBACK_LEVEL_3); * if(ret_val !=0) * return -1; * ... - * @endcode + * @endcode */ int device_haptic_play_pattern(int dev_handle, int pattern, @@ -196,14 +212,14 @@ extern "C" { * @par Description: * This API plays a predefined rhythmic haptic-vibration pattern file (only supports .ivt type file, Immersion VibeTonz).\n * The first in parameter dev_handle should be from the return value of device_haptic_open().\n - * The second in parameter file_name sets rhythmic vibration pattern file with path. + * The second in parameter file_name sets rhythmic vibration pattern file with path. * It only supports *.ivt type pattern file. \n - * The third in parameter iteration sets the number of iterations to be played. + * 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.\n - * 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. + * 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 ) \n * On success it returns a zero value. In case of failure it returns a negative value. \n * Note: The actual behavior of the feedback play pattern and the intensity depends on the target hardware. @@ -216,7 +232,7 @@ extern "C" { * @par Example * @code * ... - * ret_val = device_haptic_play_file(dev_handle, "test.ivt", HAPTIC_TEST_ITERATION , HAPTIC_FEEDBACK_LEVEL_3); + * ret_val = device_haptic_play_file(dev_handle, "test.ivt", HAPTIC_TEST_ITERATION , HAPTIC_FEEDBACK_LEVEL_3); * if(ret_val !=0) * return -1; * ... @@ -227,6 +243,45 @@ extern "C" { int iteration, int feedback_level); /** + * @fn int device_haptic_play_file_with_priority(int device_handle, const char *file_name, int priority_level, int iteration, int feedback_level) + * @par Description: + * This API plays a predefined rhythmic haptic-vibration pattern file with priority(only supports .ivt type file, Immersion VibeTonz).\n + * The first in parameter dev_handle should be from the return value of device_haptic_open().\n + * The second in parameter file_name sets rhythmic vibration pattern file with path. + * It only supports *.ivt type pattern file. \n + * The third in parameter prioritizes between the different effect. \n + * This level is already predefined by enumeration type value from hantpic_priority_level. + * This value must be between HAPTIC_PRIORITY_LEVEL_MIN and HAPTIC_PRIORITY_LEVEL_MAX_OEM. + * The fourth 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.\n + * The fifth 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 ) \n + * On success it returns a zero value. In case of failure it returns a negative value. \n + * Note: The actual behavior of the feedback play pattern and the intensity depends on the target hardware. + * @param[in] dev_handle set received dev_handle value from device_haptic_open() + * @param[in] file_name set file name with path + * @param[in] priority_level set priority value + * @param[in] iteration set iteration count + * @param[in] feedback_level set feed_back level value ( it is dependent on target's hardware ) + * @return if it succeed, it return zero value , otherwise negative value return + * @see device_haptic_play_file(), device_haptic_play_monotone(), device_haptic_stop_play() + * @par Example + * @code + * ... + * ret_val = device_haptic_play_file_with_priority(dev_handle, "test.ivt", HAPTIC_PRIORITY_LEVEL_MAX_DEV, HAPTIC_TEST_ITERATION , HAPTIC_FEEDBACK_LEVEL_3); + * if(ret_val !=0) + * return -1; + * ... + * @endcode + */ + + int device_haptic_play_file_with_priority(int device_handle, const char *file_name, + int priority, int iteration, int feedback_level); + +/** * @fn int device_haptic_play_buffer(int dev_handle, const unsigned char *vibe_buffer, int iteration , int feedback_level ) * @par Description: * This API plays a predefined rhythmic haptic-vibration pattern file (only supports .ivt type file, Immersion VibeTonz).\n @@ -235,7 +290,7 @@ extern "C" { * 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.\n - * The fourth in parameter is the vibration feedback intensity level. + * 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 ) \n @@ -361,11 +416,11 @@ extern "C" { * @par Example * @code * ... - * //Stop the pattern immediately + * //Stop the pattern immediately * ret_val = device_haptic_stop_play(dev_handle); * if(ret_val !=0) * return -1; - * ... + * ... * @endcode */ @@ -418,7 +473,7 @@ extern "C" { * This API gets a duration time value from a predefined rhythmic vibration pattern file (only supports .ivt type file).\n * The first in parameter ?dev_handle? should be from the return value of device_haptic_open().\n * The second in parameter ?file_name? sets rhythmic vibration pattern file with path. It only supports *.ivt type pattern file.\n - * The application can get a duration time value from the third out parameter duration when this API succeeds. + * 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)\n * On success it returns a zero value. In case of failure it returns a negative value. \n * Note: The actual behavior of the feedback played and the intensity depends on the target hardware. @@ -437,14 +492,26 @@ extern "C" { * @fn int device_haptic_get_device_count(void) * @par Description: * This API gets a numer of devices.\n - * The application can get a number of devices from the return value this API succeeds. + * The application can get a number of devices from the return value this API succeeds. * On success it returns a number of devices. In case of failure it returns a negative value. \n * @return if it succeed, it return number of devices, otherwise negative value return */ int device_haptic_get_device_count(void); /** - * @} + * @fn int device_haptic_convert_to_binary(const char *haptic_name) + * @par Description: + * This API convert ivt file to binary file.\n + * If the haptic file is not located predefined position, this api can't work and returns a negative value.\n + * And also binary file is located predefined position and name according to rules.\n + * The first in parameter sets source file name which should be ".ivt" file.\n + * On success it returns 0. In case of failure it returns a negative value.\n + * @return if it succeed, it return 0, otherwise negative value return + */ + int device_haptic_convert_to_binary(const char *haptic_name); + +/** + * @} */ #ifdef __cplusplus diff --git a/devman_haptic_ext.h b/include/devman_haptic_ext.h similarity index 99% rename from devman_haptic_ext.h rename to include/devman_haptic_ext.h index 669bfa0..fcc3194 100644 --- a/devman_haptic_ext.h +++ b/include/devman_haptic_ext.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #ifndef __DEVMAN_HAPTIC_EXT_H__ @@ -919,10 +919,11 @@ extern "C" { int device_haptic_stop_all_playing_effects(int device_handle); /** - * @fn int device_haptic_save_file(const unsigned char *ivt_buffer, const char *path_name) + * @fn int device_haptic_save_file(const unsigned char *ivt_buffer, int max_bufsize, const char *path_name) * @par Description: * This API saves an IVT file to persistent storage.\n * @param[in] ivt_buffer is a pointer to IVT data + * @param[in] max_bufsize is a max size of ivt_buffer * @param[in] path_name is a pointer to the character buffer containing the path name of the file to save * @return if it succeed, it return HAPTIC_S_SUCCESS, otherwise negative value return * @par Example: @@ -931,15 +932,16 @@ extern "C" { * int status; * unsigned char *ivt_buffer = { ... }; * char *path_name = "test.ivt"; + * int size = MAX_IVT_SIZE; * - * status = device_haptic_save_file(ivt_buffer, path_name); + * status = device_haptic_save_file(ivt_buffer, size, path_name); * if(staus < 0) * return -1; * ... * @endcode */ - int device_haptic_save_file(const unsigned char *ivt_buffer, const char *path_name); + int device_haptic_save_file(const unsigned char *ivt_buffer, int max_bufsize, const char *path_name); /** * @fn int device_haptic_delete_file(const char *path_name) diff --git a/devman_haptic_ext_core.h b/include/devman_haptic_ext_core.h old mode 100755 new mode 100644 similarity index 98% rename from devman_haptic_ext_core.h rename to include/devman_haptic_ext_core.h index e3fb204..020ebd5 --- a/devman_haptic_ext_core.h +++ b/include/devman_haptic_ext_core.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #ifndef __DEVMAN_HAPTIC_EXT_CORE_H__ @@ -30,7 +30,7 @@ extern "C" { #endif -/** +/** * @file devman_haptic_ext_core.h * @ingroup DEVICE_MANAGER * @brief This file contains the data type, structure and definitions of the haptic extra API diff --git a/devman_haptic_plugin_intf.h b/include/devman_haptic_plugin_intf.h similarity index 96% rename from devman_haptic_plugin_intf.h rename to include/devman_haptic_plugin_intf.h index a0108dd..84e3270 100644 --- a/devman_haptic_plugin_intf.h +++ b/include/devman_haptic_plugin_intf.h @@ -63,13 +63,14 @@ typedef struct { int (*haptic_internal_get_IVT_effect_duration) (const unsigned char *, int, int *); int (*haptic_internal_play_magsweep_effect) (int, int, int, int, int, int, int, int, int *); int (*haptic_internal_play_periodic_effect) (int, int, int, int, int, int, int, int, int, int *); + int (*haptic_internal_play_wave_from_effect) (int, const unsigned char *, int, int, int, int, int *); int (*haptic_internal_modify_playing_magsweep_effect) (int, int, int, int, int, int, int, int, int); int (*haptic_internal_modify_playing_periodic_effect) (int, int, int, int, int, int, int, int, int, int); int (*haptic_internal_create_streaming_effect) (int, int *); int (*haptic_internal_destroy_streaming_effect) (int, int); int (*haptic_internal_play_streaming_sample) (int, int, const unsigned char *, int); int (*haptic_internal_play_streaming_sample_with_offset) (int, int, const unsigned char *, int, int); - int (*haptic_internal_save_IVT_file) (const unsigned char *, const char *); + int (*haptic_internal_save_IVT_file) (const unsigned char *, int, const char *); int (*haptic_internal_delete_IVT_file) (const char *); int (*haptic_internal_pause_playing_effect) (int, int); int (*haptic_internal_resume_paused_effect) (int, int); diff --git a/include/devman_image.h b/include/devman_image.h new file mode 100644 index 0000000..a026fb2 --- /dev/null +++ b/include/devman_image.h @@ -0,0 +1,245 @@ +/* + * devman + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: DongGi Jang + * + * 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 __DEVMAN_IMAGE_H__ +#define __DEVMAN_IMAGE_H__ + +#ifndef DEPRECATED +#define DEPRECATED __attribute__((deprecated)) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file devman_image.h + * @ingroup DEVICE_MANAGER + * @brief This file contains the prototypes of API to control image enhance mode + * @author SLP2.0 + * @date 2010-06-26 + * @version 0.1 + */ + +/** + * @addtogroup DEVICE_MANAGER + * @{ + */ + +/** + * @par Description: + * mode - dynamic, standard, natural, movie + */ + enum image_enhance_mode { + MODE_DYNAMIC = 0, + MODE_STANDARD, + MODE_NATURAL, + MODE_MOVIE, + }; + +/** + * @par Description: + * This API is used to get image enhance mode.\n + * It returns enum value which is the current mode on success.\n + * Or a negative value(-1) is returned on failure. + * @return enum value for current mode on success, -1 if failed + * @par Example + * @code + * ... + * ret = device_get_image_enhance_mode(); + * if( ret < 0 ) + * printf("Fail to get current image enhance mode\n"); + * ... + * @endcode + */ + int device_get_image_enhance_mode(void); + +/** + * @par Description: + * This API is used to set image enhance mode.\n + * @param[in] val mode enum vlaue + * @return 0 on success, -1 if failed + * @par Example + * @code + * ... + * if( device_set_image_enhance_mode(MODE_DYNAMIC) < 0 ) + * printf("Fail to set the image enhance mode\n"); + * ... + * @endcode + */ + int device_set_image_enhance_mode(int val); + +/** + * @par Description: + * scenario - ui, gallery, video, vtcall, camera, browser, negative, bypass + */ + enum image_enhance_scenario { + SCENARIO_UI = 0, + SCENARIO_GALLERY, + SCENARIO_VIDEO, + SCENARIO_VTCALL, + SCENARIO_CAMERA, + SCENARIO_BROWSER, + SCENARIO_NEGATIVE, + SCENARIO_BYPASS, + }; + +/** + * @par Description: + * This API is used to get image enhance scenario.\n + * It returns enum value which is the current scenario on success.\n + * Or a negative value(-1) is returned on failure. + * @return enum value for current wcenario on success, -1 if failed + * @par Example + * @code + * ... + * ret = device_get_image_enhance_scenario(); + * if( ret < 0 ) + * printf("Fail to get current image enhance scenarioe\n"); + * ... + * @endcode + */ + int device_get_image_enhance_scenario(void); + +/** + * @par Description: + * This API is used to set image enhance scenario.\n + * @param[in] val scenario enum vlaue + * @return 0 on success, -1 if failed + * @par Example + * @code + * ... + * if( device_set_image_enhance_scenario(SCENARIO_UI) < 0 ) + * printf("Fail to set the image enhance scenario\n"); + * ... + * @endcode + */ + int device_set_image_enhance_scenario(int val); + +/** + * @par Description: + * tone - normal, warm, cold + */ + enum image_enhance_tone { + TONE_NORMAL = 0, + TONE_WARM, + TONE_COLD, + }; + +/** + * @par Description: + * This API is used to get image enhance tone.\n + * It returns enum value which is the current mode on success.\n + * Or a negative value(-1) is returned on failure. + * @return enum value for current tone on success, -1 if failed + * @par Example + * @code + * ... + * ret = device_get_image_enhance_tone(); + * if( ret < 0 ) + * printf("Fail to get current image enhance tone\n"); + * ... + * @endcode + */ + int device_get_image_enhance_tone(void); + +/** + * @par Description: + * This API is used to set image enhance tone.\n + * @param[in] val tone vlaue + * @return 0 on success, -1 if failed + * @par Example + * @code + * ... + * if( device_set_image_enhance_tone(TONE_NORMAL) < 0 ) + * printf("Fail to set the image enhance tone\n"); + * ... + * @endcode + */ + int device_set_image_enhance_tone(int val); + +/** + * @par Description: + * outdoor - off, on + */ + enum image_enhance_outdoor { + OUTDOOR_OFF = 0, + OUTDOOR_ON, + }; + +/** + * @par Description: + * This API is used to get image enhance outdoor.\n + * It returns enum value which is the current outdoor on success.\n + * Or a negative value(-1) is returned on failure. + * @return enum value for current outdoor on success, -1 if failed + * @par Example + * @code + * ... + * ret = device_get_image_enhance_ourdoor(); + * if( ret < 0 ) + * printf("Fail to get current image enhance outdoor\n"); + * ... + * @endcode + */ + int device_get_image_enhance_outdoor(void); + +/** + * @par Description: + * This API is used to set image enhance outdoor.\n + * @param[in] val outdoor vlaue + * @return 0 on success, -1 if failed + * @par Example + * @code + * ... + * if( device_set_image_enhance_outdoor(TONE_NORMAL) < 0 ) + * printf("Fail to set the image enhance outdoor\n"); + * ... + * @endcode + */ + int device_set_image_enhance_outdoor(int val); + +/** + * @par Description: + * This API is used to get information about image enhance function.\n + * It returns 1, this device can use enhance mode.\n + * Or a negative value(-1) is returned, it doesn't support enhance mode. + * @return 1 is returned on support for enhance mode, -1 if not. + * @par Example + * @code + * ... + * ret = device_get_image_enhance_info(); + * if( ret < 0 ) + * printf("Not support image enhance mode on this device\n"); + * ... + * @endcode + */ + int device_get_image_enhance_info(void); + +/** + * @} // end of image enhance APIs + */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/devman_internal.h b/include/devman_internal.h similarity index 94% rename from devman_internal.h rename to include/devman_internal.h index b197bee..a4ed063 100644 --- a/devman_internal.h +++ b/include/devman_internal.h @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,14 +17,14 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #ifndef API #define API __attribute__ ((visibility("default"))) #endif -#define DISPLAY_WD_FIFO "/tmp/.display_wd" +#define DISPLAY_WD_FIFO "/tmp/.display_wd" #define DISPLAY_WD_CANCEL 226235 int display_register_postjob(void); diff --git a/include/devman_managed.h b/include/devman_managed.h new file mode 100644 index 0000000..22a72d8 --- /dev/null +++ b/include/devman_managed.h @@ -0,0 +1,42 @@ +/* + * devman + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: DongGi Jang + * + * 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 __DEVMAN_MANAGED_H__ +#define __DEVMAN_MANAGED_H__ + +/** + * @file devman_managed.h + * @defgroup devman_managed Definitions of managed api set + * @ingroup DEVICE_MANAGER_MANAGED + * @author Jiyoung Yun (jy910.yun@samsung.com) + * @brief This file contains the definitions of managed API for devices + * @details define functions that control enhance mode and haptic device + * @author SLP2.0 + * @date 2010-06-26 + * @version 0.1 + */ + +#include "devman_error.h" +#include "devman_image.h" +#include "devman_haptic.h" + +#endif /* __DEVMAN_MANAGED_H__ */ diff --git a/devman_plugin_intf.h b/include/devman_plugin_intf.h old mode 100755 new mode 100644 similarity index 88% rename from devman_plugin_intf.h rename to include/devman_plugin_intf.h index 3f4a069..785adaa --- a/devman_plugin_intf.h +++ b/include/devman_plugin_intf.h @@ -56,14 +56,19 @@ enum { enum { POWER_STATE_SUSPEND = 0, + POWER_STATE_PRE_SUSPEND, + POWER_STATE_POST_RESUME, }; typedef struct { int (*OEM_sys_get_display_count) (int *value); + int (*OEM_sys_get_backlight_min_brightness) (int index, int *value); int (*OEM_sys_get_backlight_max_brightness) (int index, int *value); - int (*OEM_sys_get_backlight_brightness) (int index, int *value); - int (*OEM_sys_set_backlight_brightness) (int index, int value); + int (*OEM_sys_get_backlight_brightness) (int index, int *value, int power_saving); + int (*OEM_sys_set_backlight_brightness) (int index, int value, int power_saving); + + int (*OEM_sys_set_backlight_dimming) (int index, int *value); int (*OEM_sys_get_backlight_acl_control) (int index, int *value); int (*OEM_sys_set_backlight_acl_control) (int index, int value); @@ -83,6 +88,10 @@ typedef struct { int (*OEM_sys_get_image_enhance_tune) (int *value); int (*OEM_sys_set_image_enhance_tune) (int value); + int (*OEM_sys_image_enhance_info) (int *value); + + int (*OEM_sys_set_display_frame_rate) (int value); + int (*OEM_sys_get_uart_path) (int *value); int (*OEM_sys_set_uart_path) (int value); @@ -96,10 +105,12 @@ typedef struct { int (*OEM_sys_set_haptic_vibetones_oneshot) (int value); int (*OEM_sys_get_battery_capacity) (int *value); + int (*OEM_sys_get_battery_capacity_raw) (int *value); int (*OEM_sys_get_battery_charge_full) (int *value); int (*OEM_sys_get_battery_charge_now) (int *value); int (*OEM_sys_get_battery_present) (int *value); int (*OEM_sys_get_battery_health) (int *value); + int (*OEM_sys_get_battery_polling_required) (int *value); int (*OEM_sys_get_jack_charger_online) (int *value); int (*OEM_sys_get_jack_earjack_online) (int *value); diff --git a/packaging/devman.manifest b/packaging/devman.manifest deleted file mode 100644 index 017d22d..0000000 --- a/packaging/devman.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/devman.spec b/packaging/devman.spec index 857e14f..2574032 100644 --- a/packaging/devman.spec +++ b/packaging/devman.spec @@ -1,17 +1,18 @@ +#sbs-git:slp/pkgs/d/devman devman 0.1.6 5bf2e95e0bb15c43ff928f7375e1978b0accb0f8 Name: devman Summary: Device manager library -Version: 0.1.7 -Release: 1 +Version: 0.1.8 +Release: 11 Group: TO_BE/FILLED_IN License: LGPL 2.1 Source0: %{name}-%{version}.tar.gz -Source1001: packaging/devman.manifest Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig BuildRequires: cmake BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(heynoti) +BuildRequires: pkgconfig(iniparser) %description Device manager library for device control @@ -52,7 +53,6 @@ Haptic Device manager library for device control (devel) %setup -q %build -cp %{SOURCE1001} . CFLAGS="$CFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_DEVMAN_RSRC_PREFIX=share/devman -DCMAKE_DATADIR=/opt make %{?jobs:-j%jobs} @@ -63,45 +63,40 @@ rm -rf %{buildroot} mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc3.d mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc4.d -ln -s %{_sysconfdir}/init.d/devman %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S10devman -ln -s %{_sysconfdir}/init.d/devman %{buildroot}%{_sysconfdir}/rc.d/rc4.d/S10devman -%post +%post -n libdevman /sbin/ldconfig mkdir -p /etc/udev/rules.d if ! [ -L /etc/udev/rules.d/91-devman.rules ]; then -ln -s /usr/share/devman/udev-rules/91-devman.rules /etc/udev/rules.d/91-devman.rules + ln -s %{_datadir}/devman/udev-rules/91-devman.rules /etc/udev/rules.d/91-devman.rules fi -%postun +%postun -n libdevman /sbin/ldconfig rm -f /etc/udev/rules.d/91-X1.rules %files -n libdevman -%manifest devman.manifest -/etc/rc.d/init.d/devman +%{_sysconfdir}/rc.d/init.d/devman %{_bindir}/display_wd %{_libdir}/libdevman.so.* %{_datadir}/devman/udev-rules/91-devman.rules -%{_sysconfdir}/rc.d/rc3.d/S10devman -%{_sysconfdir}/rc.d/rc4.d/S10devman %files -n libdevman-devel -%manifest devman.manifest %{_includedir}/devman/devman.h +%{_includedir}/devman/devman_managed.h +%{_includedir}/devman/devman_image.h +%{_includedir}/devman/devman_error.h +%{_includedir}/devman/devman_haptic.h %{_includedir}/devman/SLP_devman_PG.h %{_libdir}/pkgconfig/devman.pc %{_libdir}/libdevman.so %files -n libdevman-plugin-devel -%manifest devman.manifest %{_includedir}/devman/devman_haptic_plugin_intf.h %{_includedir}/devman/devman_plugin_intf.h %{_libdir}/pkgconfig/devman_plugin.pc %files -n libdevman-haptic-devel -%manifest devman.manifest -%{_includedir}/devman/devman_haptic.h %{_libdir}/pkgconfig/devman_haptic.pc %{_includedir}/devman/devman_haptic_ext.h %{_includedir}/devman/devman_haptic_ext_core.h diff --git a/packaging/devman.yaml b/packaging/devman.yaml old mode 100755 new mode 100644 index 4da03ee..4021e07 --- a/packaging/devman.yaml +++ b/packaging/devman.yaml @@ -31,6 +31,9 @@ SubPackages : Group: Development/Libraries Files: - "%{_includedir}/devman/devman.h" + - "%{_includedir}/devman/devman_managed.h" + - "%{_includedir}/devman/devman_image.h" + - "%{_includedir}/devman/devman_haptic.h" - "%{_includedir}/devman/SLP_devman_PG.h" - "%{_libdir}/pkgconfig/devman.pc" - "%{_libdir}/libdevman.so" @@ -40,7 +43,6 @@ SubPackages : Description: Haptic Device manager library for device control (devel) Group: Development/Libraries Files: - - "%{_includedir}/devman/devman_haptic.h" - "%{_includedir}/devman/devman_haptic_ext.h" - "%{_includedir}/devman/devman_haptic_ext_core.h" - "%{_libdir}/pkgconfig/devman_haptic.pc" diff --git a/src/device_convert.c b/src/device_convert.c new file mode 100644 index 0000000..c527ea7 --- /dev/null +++ b/src/device_convert.c @@ -0,0 +1,553 @@ +/* + * devman + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Jiyoung Yun + * + * 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 +#include +#include +#include +#include +#include + +#include "devlog.h" +#include +#include +#include + +#ifndef EXTAPI +#define EXTAPI __attribute__ ((visibility("default"))) +#endif /* EXTAPI */ + +#ifdef PERFORM_CHECK +static long long ms = 0; + +#define MICROSECONDS(tv) ((tv.tv_sec * 1000000ll) + tv.tv_usec) + +#define ESTIMATE_PERFORMANCE() \ + do { \ + struct timeval tv; \ + if (ms == 0) { \ + gettimeofday(&tv, NULL); \ + ms = MICROSECONDS(tv); \ + fDBG(stderr, "%s start time : %lld\n", __func__, ms); \ + } else { \ + gettimeofday(&tv, NULL); \ + fDBG(stderr, "%s elapsed time : %lld\n", __func__, MICROSECONDS(tv) - ms); \ + ms = 0; \ + } \ + } while(0) +#else +#define ESTIMATE_PERFORMANCE() +#endif + +#define MAX_FILE_PATH 256 /* Maximum file path length */ +#define SAMPLE_INTERVAL 10.0 /* Sample calculation interval in milliseconds */ +#define IVT_BUFFER_SIZE 4096 /* IVT buffer size */ +#define BASE 5 +#define FOLDER_MASK 664 + +typedef enum { + WAVETYPE_SQUARE = 1, + WAVETYPE_TRIANGLE, + WAVETYPE_SINE, + WAVETYPE_SAWTOOTHUP, + WAVETYPE_SAWTOOTHDOWN +} effect_wave_type; + +/* This functions loads the IVT file into memory */ +static unsigned char *_load_ivt_file(const char *filepath) +{ + FILE *pFile; + long cbyFileSize; + unsigned char *p_ivt_data = NULL; + /* open the IVT file */ + /* IMPORTANT: open the IVT file as a binary file to avoid translation */ + pFile = fopen(filepath, "rb"); + if (!pFile) + { + /* handle error, application-specific */ + return p_ivt_data; + } + /* determine the file size */ + /* fseek returns zero on success, non-zero on failure */ + if (fseek(pFile, 0, SEEK_END)) + { + /* handle error, application-specific */ + fclose(pFile); + return p_ivt_data; + } + cbyFileSize = ftell(pFile); + if (fseek(pFile, 0, SEEK_SET)) + { + /* handle error, application-specific */ + fclose(pFile); + return p_ivt_data; + } + /* allocate a buffer for the IVT data */ + p_ivt_data = (unsigned char *)malloc(cbyFileSize); + if (!p_ivt_data) + { + /* handle error, application-specific */ + fclose(pFile); + return p_ivt_data; + } + /* read the IVT data from the IVT file */ + if (fread(p_ivt_data, 1, cbyFileSize, pFile) != cbyFileSize) + { + /* handle error, application-specific */ + free(p_ivt_data); + p_ivt_data = 0; + fclose(pFile); + return p_ivt_data; + } + /* close the IVT file */ + if (0 != fclose(pFile)) + { + /* handle error, application-specific */ + return p_ivt_data; + } + /* you can now play effects from the IVT data that was loaded into g_pIVTData */ + return p_ivt_data; +} + +/* converts effect type to string*/ +static char *_convert_effect_type_to_string(int effect_type) +{ + switch (effect_type) { + case HAPTIC_EFFECT_TYPE_PERIODIC: + return "HAPTIC_EFFECT_TYPE_PERIODIC"; + case HAPTIC_EFFECT_TYPE_MAGSWEEP: + return "HAPTIC_EFFECT_TYPE_MAGSWEEP"; + case HAPTIC_EFFECT_TYPE_TIMELINE: + return "HAPTIC_EFFECT_TYPE_TIMELINE"; + case HAPTIC_EFFECT_TYPE_STREAMING: + return "HAPTIC_EFFECT_TYPE_STREAMING"; + case HAPTIC_EFFECT_TYPE_WAVEFORM: + return "HAPTIC_EFFECT_TYPE_WAVEFORM"; + } + return NULL; +} + +/*This functions gets Periodic effect details using devman API*/ +static int _get_periodic_effect_details(const unsigned char *pivt_data, int index, HapticPeriodic *periodic_effect) +{ + int result = -1; + result = device_haptic_get_periodic_effect_definition(pivt_data, index, + &periodic_effect->duration, &periodic_effect->magnitude, + &periodic_effect->period, &periodic_effect->style, + &periodic_effect->attacktime, &periodic_effect->attacklevel, + &periodic_effect->fadetime, &periodic_effect->fadelevel); + if (result == 0) { + DBG("device_haptic_get_periodic_effect_definition() Success"); + DBG("Duration : %d", periodic_effect->duration); + DBG("Magnitude : %d", periodic_effect->magnitude); + DBG("Period : %d", periodic_effect->period); + DBG("Style & Wave Type : %d", periodic_effect->style); + DBG("Attacktime : %d", periodic_effect->attacktime); + DBG("Attacklevel : %d", periodic_effect->attacklevel); + DBG("Fadetime : %d", periodic_effect->fadetime); + DBG("Fadelevel : %d", periodic_effect->fadelevel); + } else { + DBG("device_haptic_get_periodic_effect_definition() failed. Reason:%d", result); + } + return result; +} + +/*This functions gets MagSweep effect details using devman API*/ +static int _get_magsweep_effect_details(const unsigned char *p_ivt_data, int index, HapticMagSweep *magsweep_effect) +{ + int result = -1; + result = device_haptic_get_magsweep_effect_definition(p_ivt_data, index, + &magsweep_effect->duration, &magsweep_effect->magnitude, + &magsweep_effect->style, + &magsweep_effect->attacktime, &magsweep_effect->attacklevel, + &magsweep_effect->fadetime, &magsweep_effect->fadelevel); + if (result == 0) { + DBG("device_haptic_get_magsweep_effect_definition() Success"); + DBG("Duration : %d", magsweep_effect->duration); + DBG("Magnitude : %d", magsweep_effect->magnitude); + DBG("Style : %d", magsweep_effect->style); + DBG("Attacktime : %d", magsweep_effect->attacktime); + DBG("Attacklevel : %d", magsweep_effect->attacklevel); + DBG("Fadetime : %d", magsweep_effect->fadetime); + DBG("Fadelevel : %d", magsweep_effect->fadelevel); + } else { + DBG("device_haptic_get_magsweep_effect_definition() failed. Reason:%d", result); + } + return result; +} + +/*This functions gets Timeline effect details using devman API*/ +static int _get_timeline_effect_details(const unsigned char *p_ivt_data, int index, HapticElement *timeline_effect) +{ + unsigned char ivt_buffer[IVT_BUFFER_SIZE+1] = {0,}; + int result = -1; + + result = device_haptic_initialize_buffer(ivt_buffer, sizeof(ivt_buffer)); + if (result ==0) { + result = device_haptic_read_element(ivt_buffer, IVT_BUFFER_SIZE, 0, 0, timeline_effect); + if (result == 0) { + DBG("Element type:%d", timeline_effect->elementtype); + } else { + DBG("device_haptic_read_element() failed. Reason :%d", result); + } + } else { + DBG("device_haptic_initialize_buffer() failed. Reason:%d", result); + } + return result; +} + +/* This function parses the Periodic effect received and generates + * corresponding LED pattern for it */ +static char *_parse_periodic_effect_and_generate_led_pattern(HapticPeriodic periodic, int *buffer_size) +{ + char *led_pattern = NULL; + int unit = periodic.magnitude/10; + int i = 0; + int sample_index = 0; + int value = 0; + int style = 0; + int wave_type = 0; + int mid = periodic.period/2; + int j = 0; + int step = 0; + int delta = 0; + int base = BASE*unit; + char const_value ='0'; + + led_pattern = (char*)calloc(((periodic.duration/SAMPLE_INTERVAL)+1), sizeof(char)); + if (led_pattern == NULL) { + DBG("Memory allocation failure"); + return NULL; + } + + if (periodic.magnitude >0) + const_value = '1'; + + if (periodic.attacktime == 0 && periodic.attacklevel == 0 + && periodic.fadetime == 0 && periodic.fadelevel == 0) { + DBG("Periodic effect"); + + if (periodic.style <=0) { + DBG("Unknown periodic effect"); + free(led_pattern); + return NULL; + } else { + /* Extract Style and wave type*/ + DBG("Style and wave type: %d", periodic.style); + style = periodic.style && HAPTIC_STYLE_SUPPORT_MASK; + wave_type = periodic.style && HAPTIC_WAVETYPE_SUPPORT_MASK; + DBG("Style : %d", style); + DBG("Wave type : %d", wave_type); + + /* Generate pattern based on Wave type. Ignore Style*/ + switch (wave_type) { + case WAVETYPE_SQUARE: + case WAVETYPE_SAWTOOTHDOWN: + { + for (i = 0; i= base) + led_pattern[sample_index++] = '1'; + else + led_pattern[sample_index++] = '0'; + } + } + break; + } + case WAVETYPE_SAWTOOTHUP: + { + for (i = 0; i mid) + led_pattern[sample_index++] = '1'; + else + led_pattern[sample_index++] = '0'; + } + } + break; + } + default: DBG("Unknown wave type\n"); + break; + } + } + } else { + /*TODO*/ + /* handling periodic effect if attacktime and fade time less than period*/ + /* Need to keep repeating the pattern with attack and fade effectes within period till duration is reached*/ + if (periodic.attacktime>periodic.period || periodic.fadetime>periodic.period) { + if (periodic.attacktime >0) { + DBG("Attack time present\n"); + + if (periodic.attacklevel >periodic.magnitude) { /* Decrementing effect */ + step = (periodic.attacklevel - periodic.magnitude)/periodic.attacktime; + } else if (periodic.attacklevel base) + led_pattern[sample_index++] = '1'; + else + led_pattern[sample_index++] = '0'; + } + } + + for (i = periodic.attacktime+SAMPLE_INTERVAL; i<= (periodic.duration-periodic.fadetime); i = i+ SAMPLE_INTERVAL) { + led_pattern[sample_index++] = const_value; + } + if (periodic.fadetime >0) { + step = (periodic.magnitude - periodic.fadelevel)/periodic.fadetime; + delta = step* SAMPLE_INTERVAL; + value = periodic.magnitude; + for (i = (periodic.duration-periodic.fadetime+SAMPLE_INTERVAL); i<= periodic.duration; i = i+ SAMPLE_INTERVAL) { + value = value - delta; + if (value>base) + led_pattern[sample_index++] = '1'; + else + led_pattern[sample_index++] = '0'; + } + } + } + } + /*To mark end of effect*/ + led_pattern[sample_index++] = '0'; + *buffer_size = sample_index; + DBG("LED Pattern for Periodic effect: %s", led_pattern); + return led_pattern; +} + +/* This function parses the MagSweep effect received and generates + * corresponding LED pattern for it */ +static char *_parse_magsweep_effect_and_generate_led_pattern(HapticMagSweep mag_sweep, int *buffer_size) +{ + int unit = mag_sweep.magnitude/10; + int i =0; + int sample_index = 0; + int step = 0; + int delta = 0; + int value =0; + int base = BASE*unit; + char const_value ='0'; + char *led_pattern = NULL; + + led_pattern = (char*)calloc(((mag_sweep.duration/SAMPLE_INTERVAL)+1), sizeof(char)); + if (led_pattern == NULL) { + DBG("Memory allocation failure"); + return NULL; + } + + if (mag_sweep.magnitude >0) + const_value = '1'; + + if (mag_sweep.attacktime == 0 && mag_sweep.attacklevel == 0 + && mag_sweep.fadetime == 0 && mag_sweep.fadelevel == 0) { + /* Constant effect with maximum magnitude*/ + DBG("Constant effect"); + + for (i = 0; i<=mag_sweep.duration; i=i+SAMPLE_INTERVAL) { + led_pattern[sample_index++] = const_value; + } + } else { + DBG("Varying effect"); + /* Handling Attack effect*/ + if (mag_sweep.attacktime >0) { + DBG("Attack time present"); + + if (mag_sweep.attacklevel >mag_sweep.magnitude) { /* Decrementing effect */ + step = (mag_sweep.attacklevel - mag_sweep.magnitude)/mag_sweep.attacktime; + } else if (mag_sweep.attacklevel base) + led_pattern[sample_index++] = '1'; + else + led_pattern[sample_index++] = '0'; + } + } + /* For Handling constant effect between attacktime and fade time*/ + for (i = mag_sweep.attacktime+SAMPLE_INTERVAL; i<= (mag_sweep.duration-mag_sweep.fadetime); i = i+ SAMPLE_INTERVAL) { + led_pattern[sample_index++] = const_value; + } + /* Handling fading effect*/ + if (mag_sweep.fadetime >0) { + step = (mag_sweep.magnitude - mag_sweep.fadelevel)/mag_sweep.fadetime; + delta = step* SAMPLE_INTERVAL; + value = mag_sweep.magnitude; + for (i = (mag_sweep.duration-mag_sweep.fadetime+ SAMPLE_INTERVAL); i<= mag_sweep.duration; i = i+ SAMPLE_INTERVAL) { + value = value - delta; + if (value>base) + led_pattern[sample_index++] = '1'; + else + led_pattern[sample_index++] = '0'; + } + } + + } + /*To mark end of effect*/ + led_pattern[sample_index++] = '0'; + *buffer_size = sample_index; + DBG("Appending 0 at the end"); + DBG("LED Pattern for MagSweep effect: %s", led_pattern); + return led_pattern; +} + +static int _write_pattern_to_file(const char *binary_path, char *pled_dat, int buf_size, int *opened_flag) +{ + FILE *ptr_myfile = NULL; + + DBG("LED file name:%s", binary_path); + /* Open file for the FIRST time */ + if (*opened_flag) { + ptr_myfile = fopen(binary_path, "wb+"); + if (!ptr_myfile) { + DBG("Unable to open file!"); + return -1; + } + *opened_flag = 0; + } else { + ptr_myfile = fopen(binary_path, "ab+"); + if (!ptr_myfile) { + DBG("Unable to open file!"); + return -1; + } + } + + DBG("Buffer: %s", pled_dat); + if (fwrite(pled_dat, 1, buf_size, ptr_myfile) <= 0) { + DBG("fwrite() failed"); + } else { + DBG("fwrite() success"); + } + + fclose(ptr_myfile); + return 0; +} + +static int _convert_ivt_to_binary(const char *haptic_path, const char *binary_path) +{ + unsigned char *pivt_dat = NULL; + char *pled_dat = NULL; + int result = -1; + int effect_cnt = -1; + int effect_type = -1; + int effect_duration = -1; + int buf_size = -1; + int opened_flag = 1; // 1 : Not opened, 0 : Opened + HapticPeriodic periodic_effect; + HapticMagSweep magsweep_effect; + HapticElement element; + int i; + + /* Load IVT file into memory */ + pivt_dat = _load_ivt_file(haptic_path); + if (!pivt_dat) { + DBG("Loading IVT failed"); + return -1; + } + + /* Get total number of effects in IVT file */ + effect_cnt = device_haptic_get_effect_count(pivt_dat); + DBG("device_haptic_get_effect_count() Return:%d", effect_cnt); + + /* Parse effects in IVT */ + for (i = 0; i < effect_cnt; i++) { + /* Get effect type*/ + result = device_haptic_get_effect_type(pivt_dat, i, &effect_type); + if (result < 0) { + DBG("EffectNo:%d Getting Effect Type Failed. Reason:%d", (i+1), result); + continue; + } + + DBG("EffectNo:%d EffectType:%s\n", (i+1), _convert_effect_type_to_string(effect_type)); + switch (effect_type) { + case HAPTIC_EFFECT_TYPE_PERIODIC: + memset(&periodic_effect, 0x00, sizeof(HapticPeriodic)); + if (_get_periodic_effect_details(pivt_dat, i, &periodic_effect) == 0) { + /* Parse periodic effect type*/ + pled_dat = _parse_periodic_effect_and_generate_led_pattern(periodic_effect, &buf_size); + if (pled_dat) { + _write_pattern_to_file(binary_path, pled_dat, buf_size, &opened_flag); + free(pled_dat); + } + } + break; + case HAPTIC_EFFECT_TYPE_MAGSWEEP: + memset(&magsweep_effect, 0x00, sizeof(HapticMagSweep)); + if (_get_magsweep_effect_details(pivt_dat, i, &magsweep_effect) == 0) { + /* Parse magsweep effect type*/ + pled_dat = _parse_magsweep_effect_and_generate_led_pattern(magsweep_effect, &buf_size); + if (pled_dat) { + _write_pattern_to_file(binary_path, pled_dat, buf_size, &opened_flag); + free(pled_dat); + } + } + break; + case HAPTIC_EFFECT_TYPE_TIMELINE: + memset(&element, 0x00, sizeof(HapticElement)); + if (_get_timeline_effect_details(pivt_dat, i, &element) > 0) { + device_haptic_get_effect_duration(pivt_dat, i, &effect_duration); + DBG("Timeline effect duration:%d", effect_duration); + } + break; + case HAPTIC_EFFECT_TYPE_STREAMING: + case HAPTIC_EFFECT_TYPE_WAVEFORM: + default: + DBG("Unsupported effect type"); + break; + } + } + + free(pivt_dat); + return 0; +} + +EXTAPI int device_haptic_convert_to_binary(const char *haptic_name) +{ + DBG("this api is not implementation yet"); + return -1; +} diff --git a/device_engine.c b/src/device_engine.c old mode 100755 new mode 100644 similarity index 95% rename from device_engine.c rename to src/device_engine.c index 3b709e7..acd4d41 --- a/device_engine.c +++ b/src/device_engine.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #include @@ -77,7 +77,6 @@ struct device *find_device(struct device *root_dev, devtype_t devtype) dev = root_dev; while (dev) { - DBG("devname = %s %d %d", dev->devname, dev->devtype, devtype); if (dev->devtype == devtype) return dev; dev = dev->next; @@ -95,7 +94,7 @@ int set_devtype(char *devname, devtype_t devtype) while (dev) { if (strstr(dev->devname, devname)) { if ((strstr(dev->devname, "auto") != NULL) && - (dev->probe != NULL)) { + (dev->probe != NULL)) { ret = dev->probe(); if (ret < 0) { DBG("auto probe failed"); diff --git a/src/device_haptic.c b/src/device_haptic.c new file mode 100644 index 0000000..14e28d5 --- /dev/null +++ b/src/device_haptic.c @@ -0,0 +1,2012 @@ +/* + * devman + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: DongGi Jang + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "devlog.h" +#include "device_haptic.h" +#include "devman.h" +#include "devman_haptic.h" +#include "devman_haptic_ext.h" +#include "devman_haptic_plugin_intf.h" +/* START: Will be excluded by removing pattern */ +#include "device_haptic_tsp4000_pattern.h" +/* END: Will be excluded */ + +#ifndef EXTAPI +#define EXTAPI __attribute__ ((visibility("default"))) +#endif /* EXTAPI */ + +#define HAPTIC_DEVICE_NODE_PATH "/dev/tspdrv" +#define HAPTIC_MODULE_PATH "/usr/lib/devman/libdevman_haptic.so" + +#define __STR_EMUL "emul" +#define __LEN_STR_EMUL 4 +#define BIN_INFO_FILE_PATH "/etc/info.ini" + +/* START: Will be supported by kernel */ +//#define NEED_THE_SUPPORT_OF_KERNEL +/* END: Will be supported */ + +/* START: Will be removed by removing pattern */ +struct g_pivt_list_t +{ + unsigned char *ivt_pt; + int priority; +}; + +struct g_pivt_list_t g_haptic_internal_pattern_list[EFFCTVIBE_PATTERN_END] = { + /*for BeatUX*/ + [EFFCTVIBE_TOUCH] = { touch_ivt, 15}, + [EFFCTVIBE_HW_TOUCH] = { hw_touch_ivt, 15}, + + [EFFCTVIBE_NOTIFICATION] = { noti_ivt, 7}, + [EFFCTVIBE_INCOMING_CALL01] = { incomming_01_ivt, 7}, + [EFFCTVIBE_INCOMING_CALL02] = { incomming_02_ivt, 7}, + [EFFCTVIBE_INCOMING_CALL03] = { incomming_03_ivt, 7}, + + [EFFCTVIBE_ALERTS_CALL] = { alerts_call_ivt, 15}, + [EFFCTVIBE_OPERATION] = { operation_ivt, 7}, + [EFFCTVIBE_SILENT_MODE] = { silent_ivt, 7}, +}; +/* END: Will be removed */ + +static enum { + MODULE_NONE = 0, + MODULE_BASIC, + MODULE_TSP, + MODULE_EMUL, +}; + +static int has_haptic_module = MODULE_NONE; +static int feedback_mode = 0; +static int device_handle_count = 0; + +/* Device Manager Haptic Plugin Interface */ +static void *dlopen_handle; +static const devman_haptic_plugin_interface *plugin_intf; + +enum { + MODE_DEFAULT = 0x0000, + MODE_FEEDBACK_LEVEL_CHECK_DISABLE = 0x0001, +}; + +/* START of Static Function Section */ +static int __get_master_strength_value() +{ + int setting_fb_level = -1; + + if (feedback_mode) + return VIBE_FEEDBACK_LEVEL_3; + + 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 0; + case SETTING_VIB_FEEDBACK_LEVEL1: + return VIBE_FEEDBACK_LEVEL_1; + case SETTING_VIB_FEEDBACK_LEVEL2: + return VIBE_FEEDBACK_LEVEL_2; + case SETTING_VIB_FEEDBACK_LEVEL3: + return VIBE_FEEDBACK_LEVEL_3; + case SETTING_VIB_FEEDBACK_LEVEL4: + return VIBE_FEEDBACK_LEVEL_4; + case SETTING_VIB_FEEDBACK_LEVEL5: + return VIBE_FEEDBACK_LEVEL_5; + } + ERR("error get VCONF_SETAPPL_VIB_FEEDBACK_INT value (= %d) invalid", setting_fb_level); + return -1; +} + +static int __convert_strength_level(int base_level) +{ + switch (base_level) { + case HAPTIC_FEEDBACK_LEVEL_0: + return VIBE_FEEDBACK_LEVEL_0; + case HAPTIC_FEEDBACK_LEVEL_1: + return VIBE_FEEDBACK_LEVEL_1; + case HAPTIC_FEEDBACK_LEVEL_2: + return VIBE_FEEDBACK_LEVEL_2; + case HAPTIC_FEEDBACK_LEVEL_3: + return VIBE_FEEDBACK_LEVEL_3; + case HAPTIC_FEEDBACK_LEVEL_4: + return VIBE_FEEDBACK_LEVEL_4; + case HAPTIC_FEEDBACK_LEVEL_5: + return VIBE_FEEDBACK_LEVEL_5; + } + ERR("error invalid convertable value (%d)", base_level); + return -1; +} + +static int __convert_priority_level(int base_level) +{ + switch (base_level) { + case HAPTIC_PRIORITY_LEVEL_MIN: + return HAPTIC_MIN_DEVICE_PRIORITY; + case HAPTIC_PRIORITY_LEVEL_MAX_DEV: + return HAPTIC_MAX_DEV_DEVICE_PRIORITY; + case HAPTIC_PRIORITY_LEVEL_MAX_OEM: + return HAPTIC_MAX_OEM_DEVICE_PRIORITY; + } + ERR("error invalid convertable value (%d)", base_level); + return -1; +} + +static int __is_emulator_binary() +{ + char szEmul[__LEN_STR_EMUL+1]; + const char* szBinVer = NULL; + + dictionary* dic = iniparser_load(BIN_INFO_FILE_PATH); + // when failed to get the info, let's regard the binary as an emulator one + if (!dic) + return 1; + + szBinVer = (const char*)iniparser_getstr(dic, "Version:Build"); + if (szBinVer) { + char* str = g_strdup(szBinVer); + if (str) { + char* pPos = str; + while (*pPos++) { + if ('_' == *pPos) + *pPos = ' '; + } + sscanf(str, "%*s %4s", szEmul); + } + g_free(str); + } + + if (dic) { + iniparser_freedict(dic); + dic = NULL; + } + + if (!strncmp(szEmul, __STR_EMUL, __LEN_STR_EMUL)) + return 1; + + return 0; +} +/* END of Static Function Section */ + +/* START: devman_haptic APIs */ +EXTAPI +int device_haptic_open(haptic_dev_idx dev_idx, unsigned int mode) +{ + int status; + int device_index = dev_idx >> 1; + int device_handle; + + if (!(dev_idx == DEV_IDX_0 || dev_idx == DEV_IDX_1 || dev_idx == DEV_IDX_ALL)) { + ERR("Invalid parameter - dev_idx(%d)", dev_idx); + return HAPTIC_INVALID_ARGUMENT; + } + + DBG("handle count : %d, haptic module : %d\n", device_handle_count, has_haptic_module); + + if (has_haptic_module == MODULE_NONE) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + if (has_haptic_module == MODULE_TSP) { + plugin_intf->haptic_internal_prepare_node(); + + if (plugin_intf->haptic_internal_initialize() < 0) { + ERR("plugin_intf->haptic_internal_initialize() failed"); + return HAPTIC_FAIL; + } + } + + if (mode & MODE_FEEDBACK_LEVEL_CHECK_DISABLE) { + pid_t cpid; + cpid = getpid(); + DBG("NOT USE MAIN VIB_FEEDBACK_CHECK ROUTINE !!, at pid : %d", cpid); + feedback_mode = 1; + } + } + + if (has_haptic_module == MODULE_TSP) { + if (dev_idx == DEV_IDX_ALL) { + status = plugin_intf->haptic_internal_open_composite_device(NULL, device_index, &device_handle); + if(HAPTIC_FAILED(status)) { + ERR("plugin_intf->haptic_internal_open_composite_device() Failed: %d", status); + return HAPTIC_FAIL; + } + } else { + status = plugin_intf->haptic_internal_open_device(device_index, &device_handle); + if(HAPTIC_FAILED(status)) { + ERR("plugin_intf->haptic_internal_open_device() Failed: %d", status); + return HAPTIC_FAIL; + } + } + + ++device_handle_count; + return device_handle; + } + + ++device_handle_count; + return DEFAULT_DEVICE_HANDLE; +} + +EXTAPI +int device_haptic_close(int device_handle) +{ + int status; + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device already closed"); + return HAPTIC_NOT_OPENED; + } + + if (has_haptic_module == MODULE_TSP) { + status = plugin_intf->haptic_internal_close_device(device_handle); + if(HAPTIC_FAILED(status)) { + ERR("plugin_intf->haptic_internal_close_device(0) fail: %d", status); + return HAPTIC_FAIL; + } + } + + --device_handle_count; + if (device_handle_count == 0) { + if (has_haptic_module == MODULE_TSP) { + status = plugin_intf->haptic_internal_terminate(); + if(HAPTIC_FAILED(status)) { + ERR("plugin_intf->haptic_internal_terminate(0) fail: %d", status); + return HAPTIC_FAIL; + } + } else { + status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ENABLE, 0); + if (status < 0) { + ERR("Haptic device close failed: %d", status); + return HAPTIC_FAIL; + } + } + feedback_mode = 0; + } + + return HAPTIC_SUCCESS; +} + +EXTAPI +int device_haptic_play_buffer(int device_handle, const unsigned char *vibe_buffer, int iteration, int feedback_level) +{ + int input_feedback_level; + + if (vibe_buffer == NULL || iteration < 0) { + ERR("Invalid parameter - vibe_buffer(NULL) or iteration(%d)", iteration); + return HAPTIC_INVALID_ARGUMENT; + } + + if (feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || feedback_level > HAPTIC_FEEDBACK_LEVEL_END-1) { + ERR("feedback_level is wrong : %d", feedback_level); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) { + input_feedback_level = __get_master_strength_value(); + } else { + input_feedback_level = __convert_strength_level(feedback_level); + } + + if (input_feedback_level == VIBE_FEEDBACK_LEVEL_0) { + DBG("feedback_level is 0, so can not vibe"); + return HAPTIC_SUCCESS; + } + + DBG("iteration : %d, feedback_level : %d, priority : %d", iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY); + return plugin_intf->haptic_internal_play_buffer(device_handle, vibe_buffer, iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY); +} + +EXTAPI +int device_haptic_play_file(int device_handle, const char *file_name, int iteration, int feedback_level) +{ + int input_feedback_level; + + if (file_name == NULL || iteration < 0) { + ERR("Invalid parameter - file_name(NULL) or iteration(%d)", iteration); + return HAPTIC_INVALID_ARGUMENT; + } + + if (feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || feedback_level > HAPTIC_FEEDBACK_LEVEL_END-1) { + ERR("feedback_level is wrong : %d", feedback_level); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) { + input_feedback_level = __get_master_strength_value(); + } else { + input_feedback_level = __convert_strength_level(feedback_level); + } + + if (input_feedback_level == VIBE_FEEDBACK_LEVEL_0) { + DBG("feedback_level is 0, so can not vibe"); + return HAPTIC_SUCCESS; + } + + DBG("iteration : %d, feedback_level : %d, priority : %d", iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY); + return plugin_intf->haptic_internal_play_file(device_handle, file_name, iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY); +} + +EXTAPI +int device_haptic_play_file_with_priority(int device_handle, const char *file_name, int priority_level, int iteration, int feedback_level) +{ + int input_feedback_level; + int input_priority_level; + + if (file_name == NULL || iteration < 0) { + ERR("Invalid parameter - file_name(NULL) or iteration(%d)", iteration); + return HAPTIC_INVALID_ARGUMENT; + } + + if (priority_level < HAPTIC_PRIORITY_LEVEL_MIN || priority_level > HAPTIC_PRIORITY_LEVEL_MAX_OEM) { + ERR("priority_level is wrong : %d", priority_level); + return HAPTIC_INVALID_ARGUMENT; + } + + if (feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || feedback_level > HAPTIC_FEEDBACK_LEVEL_END-1) { + ERR("feedback_level is wrong : %d", feedback_level); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + input_priority_level = __convert_priority_level(priority_level); + + if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) { + input_feedback_level = __get_master_strength_value(); + } else { + input_feedback_level = __convert_strength_level(feedback_level); + } + + if (input_feedback_level == VIBE_FEEDBACK_LEVEL_0) { + DBG("feedback_level is 0, so can not vibe"); + return HAPTIC_SUCCESS; + } + + DBG("iteration : %d, feedback_level : %d, priority : %d", iteration, input_feedback_level, input_priority_level); + return plugin_intf->haptic_internal_play_file(device_handle, file_name, iteration, input_feedback_level, input_priority_level); +} + +EXTAPI +int device_haptic_play_pattern(int device_handle, int pattern, int iteration, int feedback_level) +{ + int input_priority_level = -1; + int input_feedback_level; + + if (pattern < EFFCTVIBE_TOUCH || pattern > EFFCTVIBE_PATTERN_END-1) { + ERR("Pattern value(%d) is not valid", pattern); + return HAPTIC_INVALID_ARGUMENT; + } + + if (!g_haptic_internal_pattern_list[pattern].ivt_pt) { + ERR("This pattern value(%d) doesn't have a pattern buffer", pattern); + return HAPTIC_INVALID_ARGUMENT; + } + + if (feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || feedback_level > HAPTIC_FEEDBACK_LEVEL_END-1) { + ERR("feedback_level is wrong : %d", feedback_level); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) { + input_feedback_level = __get_master_strength_value(); + } else { + input_feedback_level = __convert_strength_level(feedback_level); + } + + if (input_feedback_level == VIBE_FEEDBACK_LEVEL_0) { + DBG("feedback_level is 0, so can not vibe"); + return HAPTIC_SUCCESS; + } + + /* Set Priority */ + if (!g_haptic_internal_pattern_list[pattern].priority) { + input_priority_level = HAPTIC_MIN_DEVICE_PRIORITY; + } else { + input_priority_level = g_haptic_internal_pattern_list[pattern].priority; + } + + DBG("iteration : %d, feedback_level : %d, priority : %d", iteration, input_feedback_level, input_priority_level); + return plugin_intf->haptic_internal_play_buffer(device_handle, g_haptic_internal_pattern_list[pattern].ivt_pt, iteration, input_feedback_level, input_priority_level); +} + +EXTAPI +int device_haptic_stop_play(int device_handle) +{ + int status; + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + if (has_haptic_module == MODULE_TSP) { + status = plugin_intf->haptic_internal_stop_all_playing_effects(device_handle); + if(HAPTIC_FAILED(status)) { + ERR("plugin_intf->haptic_internal_stop_all_playing_effects(0) fail: %d", status); + return HAPTIC_FAIL; + } + } else { + status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ENABLE, 0); + if (status < 0) { + ERR("Haptic device stop failed: %d", status); + return HAPTIC_FAIL; + } + } + + return HAPTIC_SUCCESS; +} + +EXTAPI +int device_haptic_play_monotone(int device_handle, int duration) +{ + return device_haptic_play_monotone_with_feedback_level(device_handle, duration, HAPTIC_FEEDBACK_LEVEL_AUTO); +} + +EXTAPI +int device_haptic_play_monotone_with_feedback_level(int device_handle, int duration, int feedback_level) +{ + int status; + int input_strength; + int input_feedback_level; + + if (duration < 0) { + ERR("Invalid parameter - duration(%d)", duration); + return HAPTIC_INVALID_ARGUMENT; + } + + if (feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || feedback_level > HAPTIC_FEEDBACK_LEVEL_END-1) { + ERR("feedback_level is wrong : %d", feedback_level); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) { + input_feedback_level = __get_master_strength_value(); + } else { + input_feedback_level = __convert_strength_level(feedback_level); + } + + if (input_feedback_level == VIBE_FEEDBACK_LEVEL_0) { + DBG("feedback_level is 0, so can not vibe"); + return HAPTIC_SUCCESS; + } + + DBG("duration : %d, feedback_level : %d, priority : %d", duration, input_feedback_level, 0x05); + if (has_haptic_module == MODULE_TSP) { + status = plugin_intf->haptic_internal_play_monotone(device_handle, duration, input_feedback_level, 0x05); + if(HAPTIC_FAILED(status)) { + ERR("plugin_intf->haptic_internal_play_monotone(0) fail: %d", status); + return HAPTIC_FAIL; + } + } else { + status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_LEVEL, (input_feedback_level-1)/100); + if (status < 0) { + ERR(" haptic_set_level for strength:%d (error:%d) \n", input_strength, status); + return HAPTIC_FAIL; + } + + status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ONESHOT, duration); + if (status < 0) { + ERR(" haptic_oneshot for duration:%d (error:%d) \n", duration, status); + return HAPTIC_FAIL; + } + } + + return HAPTIC_SUCCESS; +} + +EXTAPI +int device_haptic_play_monotone_with_detail_feedback_level(int device_handle, int duration, int detail_feedback_level) +{ + int status; + int input_strength; + int input_feedback_level; + + if (duration < 0) { + ERR("Invalid parameter - duration(%d)", duration); + return HAPTIC_INVALID_ARGUMENT; + } + + if (detail_feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || detail_feedback_level > 100) { + ERR("detail_feedback_level is wrong : %d", detail_feedback_level); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + if (detail_feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) { + input_feedback_level = __get_master_strength_value(); + } else { + input_feedback_level = detail_feedback_level * 100; + } + + if (input_feedback_level == 0) { + DBG("feedback_level is 0, so can not vibe"); + return HAPTIC_SUCCESS; + } + + DBG("duration : %d, feedback_level : %d, priority : %d", duration, input_feedback_level, 0x05); + if (has_haptic_module == MODULE_TSP) { + status = plugin_intf->haptic_internal_play_monotone(device_handle, duration, input_feedback_level, 0x05); + if(HAPTIC_FAILED(status)) { + ERR("plugin_intf->haptic_internal_play_monotone(0) fail: %d", status); + return HAPTIC_FAIL; + } + } else { + status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_LEVEL, (input_feedback_level-1)/100); + if (status < 0) { + ERR(" haptic_set_level for strength:%d (error:%d) \n", input_strength, status); + return HAPTIC_FAIL; + } + + status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ONESHOT, duration); + if (status < 0) { + ERR(" haptic_oneshot for duration:%d (error:%d) \n", duration, status); + return HAPTIC_FAIL; + } + } + + return HAPTIC_SUCCESS; +} + +EXTAPI +int device_haptic_get_buffer_duration(int device_handle, const unsigned char *vibe_buffer, int *duration) +{ + if (vibe_buffer == NULL || duration == NULL) { + ERR("Invalid parameter - vibe_buffer(NULL) or duration(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) { + *duration = DEFAULT_DURATION_VALUE; + return HAPTIC_SUCCESS; + } + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_buffer_duration(device_handle, vibe_buffer, duration); +} + +EXTAPI +int device_haptic_get_file_duration(int device_handle, const char *file_name, int *duration) +{ + if (file_name == NULL || duration == NULL) { + ERR("Invalid parameter - file_name(NULL) or duration(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) { + *duration = DEFAULT_DURATION_VALUE; + return HAPTIC_SUCCESS; + } + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_file_duration(device_handle, file_name, duration); +} + +EXTAPI +int device_haptic_get_pattern_duration(int device_handle, int pattern, int *duration) +{ + if (duration == NULL) { + ERR("Invalid parameter - duration(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (pattern < EFFCTVIBE_TOUCH || pattern > EFFCTVIBE_PATTERN_END-1) { + ERR("Pattern value(%d) is not valid", pattern); + return HAPTIC_INVALID_ARGUMENT; + } + + if (!g_haptic_internal_pattern_list[pattern].ivt_pt) { + ERR("This pattern value(%d) doesn't have a pattern buffer", pattern); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) { + *duration = DEFAULT_DURATION_VALUE; + return HAPTIC_SUCCESS; + } + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_buffer_duration(device_handle, g_haptic_internal_pattern_list[pattern].ivt_pt, duration); +} + +EXTAPI +int device_haptic_get_device_count() +{ + int status; + int device_count = -1; + + if (has_haptic_module == MODULE_NONE) { + return HAPTIC_NOT_SUPPORTED; + } + + if (has_haptic_module == MODULE_TSP) { + if (device_handle_count == 0) { + plugin_intf->haptic_internal_prepare_node(); + + status = plugin_intf->haptic_internal_initialize(); + if (status < 0) { + return HAPTIC_FAIL; + } + /* Get device count */ + device_count = plugin_intf->haptic_internal_get_device_count(); + if(HAPTIC_FAILED(device_count)) { + ERR("plugin_intf->haptic_internal_get_device_count(0) fail: %d",status); + return HAPTIC_FAIL; + } + + status = plugin_intf->haptic_internal_terminate(); + if (status < 0) { + return HAPTIC_FAIL; + } + } else { + device_count = plugin_intf->haptic_internal_get_device_count(); + if(HAPTIC_FAILED(device_count)) { + ERR("plugin_intf->haptic_internal_get_device_count(0) fail: %d",status); + return HAPTIC_FAIL; + } + } + + return device_count; + } + + return DEFAULT_MOTOR_COUNT; +} +/* END: devman_haptic APIs */ + + +/* START: devman_haptic_ext APIs */ +EXTAPI +int device_haptic_get_device_state(int device_index, int *state) +{ + int index = device_index >> 1; + + if (!(device_index == DEV_IDX_0 || device_index == DEV_IDX_1 || device_index == DEV_IDX_ALL)) { + ERR("Invalid parameter - device_index(%d)", device_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (state == NULL) { + ERR("Invalid parameter - state(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_device_state(index, state); +} + +EXTAPI +int device_haptic_get_device_capability_bool(int device_index, int device_cap_type, unsigned char *device_cap_value) +{ + int index = device_index >> 1; + + if (!(device_index == DEV_IDX_0 || device_index == DEV_IDX_1 || device_index == DEV_IDX_ALL)) { + ERR("Invalid parameter - device_index(%d)", device_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (device_cap_value == NULL) { + ERR("Invalid parameter - device_cap_value(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (device_cap_type < HAPTIC_DEVCAPTYPE_DEVICE_CATEGORY || device_cap_type > HAPTIC_DEVCAPTYPE_HANDSET_INDEX) { + ERR("Invalid parameter - device_cap_type(%d)", device_cap_type); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_device_capability_bool(index, device_cap_type, device_cap_value); +} + +EXTAPI +int device_haptic_get_device_capability_int32(int device_index, int device_cap_type, int *device_cap_value) +{ + int index = device_index >> 1; + + if (!(device_index == DEV_IDX_0 || device_index == DEV_IDX_1 || device_index == DEV_IDX_ALL)) { + ERR("Invalid parameter - device_index(%d)", device_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (device_cap_value == NULL) { + ERR("Invalid parameter - device_cap_value(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (device_cap_type < HAPTIC_DEVCAPTYPE_DEVICE_CATEGORY || device_cap_type > HAPTIC_DEVCAPTYPE_HANDSET_INDEX) { + ERR("Invalid parameter - device_cap_type(%d)", device_cap_type); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_device_capability_int32(index, device_cap_type, device_cap_value); +} + +EXTAPI +int device_haptic_get_device_capability_string(int device_index, int device_cap_type, int size, char *device_cap_value) +{ + int index = device_index >> 1; + + if (!(device_index == DEV_IDX_0 || device_index == DEV_IDX_1 || device_index == DEV_IDX_ALL)) { + ERR("Invalid parameter - device_index(%d)", device_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (device_cap_value == NULL) { + ERR("Invalid parameter - device_cap_value(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (device_cap_type < HAPTIC_DEVCAPTYPE_DEVICE_CATEGORY || device_cap_type > HAPTIC_DEVCAPTYPE_HANDSET_INDEX) { + ERR("Invalid parameter - device_cap_type(%d)", device_cap_type); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_device_capability_string(index, device_cap_type, size, device_cap_value); +} + +EXTAPI +int device_haptic_get_device_property_bool(int device_handle, int device_prop_type, unsigned char *device_prop_value) +{ + if (device_prop_value == NULL) { + ERR("Invalid parameter - device_prop_value(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) { + ERR("Invalid parameter - device_prop_type(%d)", device_prop_type); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_device_property_bool(device_handle, device_prop_type, device_prop_value); +} + +EXTAPI +int device_haptic_set_device_property_bool(int device_handle, int device_prop_type, unsigned char device_prop_value) +{ + if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) { + ERR("Invalid parameter - device_prop_type(%d)", device_prop_type); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_set_device_property_bool(device_handle, device_prop_type, device_prop_value); +} + +EXTAPI +int device_haptic_get_device_property_int32(int device_handle, int device_prop_type, int *device_prop_value) +{ + if (device_prop_value == NULL) { + ERR("Invalid parameter - device_prop_value(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) { + ERR("Invalid parameter - device_prop_type(%d)", device_prop_type); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_device_property_int32(device_handle, device_prop_type, device_prop_value); +} + +EXTAPI +int device_haptic_set_device_property_int32(int device_handle, int device_prop_type, int device_prop_value) +{ + if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) { + ERR("Invalid parameter - device_prop_type(%d)", device_prop_type); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_set_device_property_int32(device_handle, device_prop_type, device_prop_value); +} + +EXTAPI +int device_haptic_get_device_property_string(int device_handle, int device_prop_type, int size, char *device_prop_value) +{ + if (size <= 0 || device_prop_value == NULL) { + ERR("Invalid parameter - size(%d) or device_prop_value(NULL)", size); + return HAPTIC_INVALID_ARGUMENT; + } + + if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) { + ERR("Invalid parameter - device_prop_type(%d)", device_prop_type); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_device_property_string(device_handle, device_prop_type, size, device_prop_value); +} + +EXTAPI +int device_haptic_set_device_property_string(int device_handle, int device_prop_type, const char *device_prop_value) +{ + if (device_prop_value == NULL) { + ERR("Invalid parameter - device_prop_value(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) { + ERR("Invalid parameter - device_prop_type(%d)", device_prop_type); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_set_device_property_string(device_handle, device_prop_type, device_prop_value); +} + +EXTAPI +int device_haptic_get_effect_count(const unsigned char *haptic_buffer) +{ + if (haptic_buffer == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_IVT_effect_count(haptic_buffer); +} + +EXTAPI +int device_haptic_get_effect_name(const unsigned char *haptic_buffer, int effect_index, int size, char *effect_name) +{ + if (haptic_buffer == NULL || effect_index < 0 || size <= 0 || effect_name == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or size(%d) or effect_name(NULL)", effect_index, size); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_IVT_effect_name(haptic_buffer, effect_index, size, effect_name); +} + +EXTAPI +int device_haptic_get_effect_name_u(const unsigned char *haptic_buffer, int effect_index, int size, unsigned short *effect_name) +{ + if (haptic_buffer == NULL || effect_index < 0 || size <= 0 || effect_name == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or size(%d) or effect_name(NULL)", effect_index, size); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_IVT_effect_name_u(haptic_buffer, effect_index, size, effect_name); +} + +EXTAPI +int device_haptic_get_effect_index_from_name(const unsigned char *haptic_buffer, char const *effect_name, int *effect_index) +{ + if (haptic_buffer == NULL || effect_name == NULL || effect_index == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or effect_name(NULL) or effect_index(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_IVT_effect_index_from_name(haptic_buffer, effect_name, effect_index); +} + +EXTAPI +int device_haptic_get_effect_index_from_name_u(const unsigned char *haptic_buffer, const unsigned short *effect_name, int *effect_index) +{ + if (haptic_buffer == NULL || effect_name == NULL || effect_index == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or effect_name(NULL) or effect_index(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_IVT_effect_index_from_name_u(haptic_buffer, effect_name, effect_index); +} + +EXTAPI +int device_haptic_play_effect(int device_handle, const unsigned char *haptic_buffer, int effect_index, int *effect_handle) +{ + if (haptic_buffer == NULL || effect_index < 0 || effect_handle == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or effect_handle(NULL)", effect_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_play_IVT_effect(device_handle, haptic_buffer, effect_index, effect_handle); +} + +EXTAPI +int device_haptic_play_effect_repeat(int device_handle, const unsigned char *haptic_buffer, int effect_index, unsigned char repeat, int *effect_handle) +{ + if (haptic_buffer == NULL || effect_index < 0 || effect_handle == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or effect_handle(NULL)", effect_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_play_IVT_effect_repeat(device_handle, haptic_buffer, effect_index, repeat, effect_handle); +} + +EXTAPI +int device_haptic_stop_playing_effect(int device_handle, int effect_handle) +{ + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_stop_playing_effect(device_handle, effect_handle); +} + +EXTAPI +int device_haptic_get_effect_type(const unsigned char *haptic_buffer, int effect_index, int *effect_type) +{ + if (haptic_buffer == NULL || effect_index < 0 || effect_type == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or effect_type(NULL)", effect_index); + return HAPTIC_INVALID_ARGUMENT; + } + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_IVT_effect_type(haptic_buffer, effect_index, effect_type); +} + +EXTAPI +int device_haptic_get_magsweep_effect_definition(const unsigned char *haptic_buffer, int effect_index, + int *duration, int *magnitude, int *style, int *attacktime, int *attacklevel, + int *fadetime, int *fadelevel) +{ + if (haptic_buffer == NULL || effect_index < 0 || duration == NULL || magnitude == NULL || style == NULL + || attacktime == NULL || attacklevel == NULL || fadetime == NULL || fadelevel == NULL) { + ERR("Invalid parameter"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_IVT_magsweep_effect_definition(haptic_buffer, effect_index, duration, magnitude, style, attacktime, attacklevel, fadetime, fadelevel); +} + +EXTAPI +int device_haptic_get_periodic_effect_definition(const unsigned char *haptic_buffer, int effect_index, + int *duration, int *magnitude, int *period, int *style_and_wave_type, int *attacktime, int *attacklevel, + int *fadetime, int *fadelevel) +{ + if (haptic_buffer == NULL || effect_index < 0 || duration == NULL || magnitude == NULL + || period == NULL || style_and_wave_type == NULL || attacktime == NULL || attacklevel == NULL + || fadetime == NULL || fadelevel == NULL) { + ERR("Invalid parameter"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_IVT_periodic_effect_definition(haptic_buffer, effect_index, duration, magnitude, period, style_and_wave_type, attacktime, attacklevel, fadetime, fadelevel); +} + +EXTAPI +int device_haptic_get_effect_duration(const unsigned char *haptic_buffer, int effect_index, int *effect_duration) +{ + if (haptic_buffer == NULL || effect_index < 0 || effect_duration == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or effect_duration(NULL)", effect_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_IVT_effect_duration(haptic_buffer, effect_index, effect_duration); +} + +EXTAPI +int device_haptic_play_magsweep_effect(int device_handle, + int duration, int magnitude, int style, int attacktime, int attacklevel, + int fadetime, int fadelevel, int *effect_handle) +{ + if (duration < 0 || magnitude < 0 || style < 0 || attacktime < 0 || attacklevel < 0 + || fadetime < 0 || fadelevel < 0 || effect_handle == NULL) { + ERR("Invalid parameter - duration(%d) or magnitude(%d) or style(%d) or attacktime(%d) or attacklevel(%d) or fadetime(%d) or fadelevel(%d) or effect_handle(NULL)", duration, magnitude, style, attacktime, attacklevel, fadetime, fadelevel); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_play_magsweep_effect(device_handle, duration, magnitude, style, attacktime, attacklevel, fadetime, fadelevel, effect_handle); +} + +EXTAPI +int device_haptic_play_periodic_effect(int device_handle, + int duration, int magnitude, int period, int style_and_wave_type, int attacktime, int attacklevel, + int fadetime, int fadelevel, int *effect_handle) +{ + if (duration < 0 || magnitude < 0 || period < 0 || style_and_wave_type < 0 || attacktime < 0 + || attacklevel < 0 || fadetime < 0 || fadelevel < 0 || effect_handle == NULL) { + ERR("Invalid parameter - duration(%d) or magnitude(%d) or period(%d) or style_and_wave_type(%d) or attacktime(%d) or attacklevel(%d) or fadetime(%d) or fadelevel(%d) or effect_handle(NULL)", duration, magnitude, period, style_and_wave_type, attacktime, attacklevel, fadetime, fadelevel); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_play_periodic_effect(device_handle, duration, magnitude, period, style_and_wave_type, attacktime, attacklevel, fadetime, fadelevel, effect_handle); +} + +EXTAPI +int device_haptic_modify_playing_magsweep_effect(int device_handle, int effect_handle, + int duration, int magnitude, int style, int attacktime, int attacklevel, int fadetime, int fadelevel) +{ + if (effect_handle < 0 || duration < 0 || magnitude < 0 || style < 0 + || attacktime < 0 || attacklevel < 0 || fadetime < 0 || fadelevel < 0) { + ERR("Invalid parameter - effect_handle(%d) or duration(%d) or magnitude(%d) or style(%d) or attacktime(%d) or attacklevel(%d) or fadetime(%d) or fadelevel(%d)", effect_handle, duration, magnitude, style, attacktime, attacklevel, fadetime, fadelevel); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_modify_playing_magsweep_effect(device_handle, effect_handle, duration, magnitude, style, attacktime, attacklevel, fadetime, fadelevel); +} + +EXTAPI +int device_haptic_modify_playing_periodic_effect(int device_handle, int effect_handle, + int duration, int magnitude, int period, int style_and_wave_type, int attacktime, int attacklevel, int fadetime, int fadelevel) +{ + if (effect_handle < 0 || duration < 0 || magnitude < 0 || period < 0 || style_and_wave_type < 0 + || attacktime < 0 || attacklevel < 0 || fadetime < 0 || fadelevel < 0) { + ERR("Invalid parameter - effect_handle(%d) or duration(%d) or magnitude(%d) or period(%d) or style_and_wave_type(%d) or attacktime(%d) or attacklevel(%d) or fadetime(%d) or fadelevel(%d)", effect_handle, duration, magnitude, period, style_and_wave_type, attacktime, attacklevel, fadetime, fadelevel); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_modify_playing_periodic_effect(device_handle, effect_handle, duration, magnitude, period, style_and_wave_type, attacktime, attacklevel, fadetime, fadelevel); +} + +EXTAPI +int device_haptic_create_streaming_effect(int device_handle, int *effect_handle) +{ + if (effect_handle == NULL) { + ERR("Invalid parameter - effect_handle(NULL)"); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_create_streaming_effect(device_handle, effect_handle); +} + +EXTAPI +int device_haptic_destroy_streaming_effect(int device_handle, int effect_handle) +{ + if (effect_handle < 0) { + ERR("Invalid parameter - effect_handle(%d)", effect_handle); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_destroy_streaming_effect(device_handle, effect_handle); +} + +EXTAPI +int device_haptic_play_streaming_sample(int device_handle, int effect_handle, const unsigned char *streaming_sample, int size) +{ + if (effect_handle < 0 || streaming_sample == NULL) { + ERR("Invalid parameter - effect_handle(%d) or streaming_sample(NULL)", effect_handle); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_play_streaming_sample(device_handle, effect_handle, streaming_sample, size); +} + +EXTAPI +int device_haptic_play_streaming_sample_with_offset(int device_handle, int effect_handle, const unsigned char *streaming_sample, int size, int offset_time) +{ + if (effect_handle < 0 || streaming_sample == NULL || size <= 0 || offset_time < 0) { + ERR("Invalid parameter - effect_handle(%d) or streaming_sample(NULL) or size(%d) or offset_time(%d)", effect_handle, size, offset_time); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_play_streaming_sample_with_offset(device_handle, effect_handle, streaming_sample, size, offset_time); +} + +EXTAPI +int device_haptic_stop_all_playing_effects(int device_handle) +{ + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_stop_all_playing_effects(device_handle); +} + +EXTAPI +int device_haptic_save_file(const unsigned char *ivt_buffer, int max_bufsize, const char *path_name) +{ + if (ivt_buffer == NULL || max_bufsize <= 0 || path_name == NULL) { + ERR("Invalid parameter - ivt_buffer(NULL) or max_bufsize(%d) or path_name(NULL)", max_bufsize); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_save_IVT_file(ivt_buffer, max_bufsize, path_name); +} + +EXTAPI +int device_haptic_delete_file(const char *path_name) +{ + if (path_name == NULL) { + ERR("Invalid parameter - path_name(NULL)", path_name); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_delete_IVT_file(path_name); +} + +EXTAPI +int device_haptic_pause_playing_effect(int device_handle, int effect_handle) +{ + if (effect_handle < 0) { + ERR("Invalid parameter - effect_handle(%d)", effect_handle); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_pause_playing_effect(device_handle, effect_handle); +} + +EXTAPI +int device_haptic_resume_paused_effect(int device_handle, int effect_handle) +{ + if (effect_handle < 0) { + ERR("Invalid parameter - effect_handle(%d)", effect_handle); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_resume_paused_effect(device_handle, effect_handle); +} + +EXTAPI +int device_haptic_get_effect_state(int device_handle, int effect_handle, int *effect_state) +{ + if (effect_handle < 0 || effect_state == NULL) { + ERR("Invalid parameter - effect_handle(%d) or effect_state(NULL)", effect_handle); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_effect_state(device_handle, effect_handle, effect_state); +} + +EXTAPI +int device_haptic_get_size(const unsigned char *haptic_buffer, int size) +{ + if (haptic_buffer == NULL || size <= 0) { + ERR("Invalid parameter - haptic_buffer(NULL) or size(%d)", size); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_get_IVT_size(haptic_buffer, size); +} + +EXTAPI +int device_haptic_initialize_buffer(unsigned char *haptic_buffer, int size) +{ + if (haptic_buffer == NULL || size <= 0) { + ERR("Invalid parameter - haptic_buffer(NULL) or size(%d)", size); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_initialize_IVT_buffer(haptic_buffer, size); +} + +EXTAPI +int device_haptic_insert_element(unsigned char *haptic_buffer, int size, int timeline_index, const HapticElement *element) +{ + if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or size(%d) or timeline_index(%d) or element(NULL)", size, timeline_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_insert_IVT_element(haptic_buffer, size, timeline_index, element); +} + +EXTAPI +int device_haptic_insert_element2(unsigned char *haptic_buffer, int size, int timeline_index, const HapticElement2 *element) +{ + if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or size(%d) or timeline_index(%d) or element(NULL)", size, timeline_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_insert_IVT_element2(haptic_buffer, size, timeline_index, element); +} + +EXTAPI +int device_haptic_insert_element3(unsigned char *haptic_buffer, int size, int timeline_index, const HapticElement3 *element) +{ + if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or size(%d) or timeline_index(%d) or element(NULL)", size, timeline_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_insert_IVT_element3(haptic_buffer, size, timeline_index, element); +} + +EXTAPI +int device_haptic_read_element(const unsigned char *haptic_buffer, int size, int timeline_index, int element_index, HapticElement *element) +{ + if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element_index < 0 || element == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or size(%d) or timeline_index(%d) or element_index(%d) or element(NULL)", size, timeline_index, element_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_read_IVT_element(haptic_buffer, size, timeline_index, element_index, element); +} + +EXTAPI +int device_haptic_read_element2(const unsigned char *haptic_buffer, int size, int timeline_index, int element_index, HapticElement2 *element) +{ + if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element_index < 0 || element == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or size(%d) or timeline_index(%d) or element_index(%d) or element(NULL)", size, timeline_index, element_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_read_IVT_element2(haptic_buffer, size, timeline_index, element_index, element); +} + +EXTAPI +int device_haptic_read_element3(const unsigned char *haptic_buffer, int size, int timeline_index, int element_index, HapticElement3 *element) +{ + if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element_index < 0 || element == NULL) { + ERR("Invalid parameter - haptic_buffer(NULL) or size(%d) or timeline_index(%d) or element_index(%d) or element(NULL)", size, timeline_index, element_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_read_IVT_element3(haptic_buffer, size, timeline_index, element_index, element); +} + +EXTAPI +int device_haptic_remove_element(unsigned char *haptic_buffer, int size, int timeline_index, int element_index) +{ + if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element_index < 0) { + ERR("Invalid parameter - haptic_buffer(NULL) or size(%d) or timeline_index(%d) or element_index(%d)", size, timeline_index, element_index); + return HAPTIC_INVALID_ARGUMENT; + } + + if (has_haptic_module == MODULE_EMUL) + return HAPTIC_SUCCESS; + + if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) { + ERR("%s() is not supported without specific haptic module", __func__); + return HAPTIC_NOT_SUPPORTED; + } + + if (device_handle_count == 0) { + ERR("Haptic device is not opened yet"); + return HAPTIC_NOT_OPENED; + } + + return plugin_intf->haptic_internal_remove_IVT_element(haptic_buffer, size, timeline_index, element_index); +} +/* END: devman_haptic_ext APIs */ + +static void __attribute__ ((constructor)) module_init() +{ + char *error; + + if (__is_emulator_binary()) { + has_haptic_module = MODULE_EMUL; +/* START: Will be supported by kernel */ +#ifdef NEED_THE_SUPPORT_OF_KERNEL + } else if (__is_supported_other()) { + if (access(HAPTIC_DEVICE_NODE_PATH, F_OK) < 0) { + has_haptic_module = MODULE_NONE; + return; + } + + dlopen_handle = dlopen(HAPTIC_MODULE_PATH, RTLD_NOW); + if (!dlopen_handle) { + ERR("dlopen failed: %s", dlerror()); + has_haptic_module = MODULE_NONE; + return; + } + + const devman_haptic_plugin_interface *(*get_devman_haptic_plugin_interface) (); + get_devman_haptic_plugin_interface = dlsym(dlopen_handle, "get_devman_haptic_plugin_interface"); + if ((error = dlerror()) != NULL) { + ERR("dlsym failed : %s", error); + has_haptic_module = MODULE_NONE; + dlclose(dlopen_handle); + return; + } + + plugin_intf = get_devman_haptic_plugin_interface(); + if (!plugin_intf) { + ERR("get_devman_haptic_plugin_interface() failed"); + has_haptic_module = MODULE_NONE; + dlclose(dlopen_handle); + return; + } + + has_haptic_module = MODULE_TSP; +#endif +/* END: Will be supported */ + } else { + has_haptic_module = MODULE_BASIC; + } +} + +static void __attribute__ ((destructor)) module_fini() +{ + if (has_haptic_module != MODULE_TSP) + return; + + if (dlopen_handle) { + dlclose(dlopen_handle); + } +} + diff --git a/device_plugin.c b/src/device_plugin.c similarity index 100% rename from device_plugin.c rename to src/device_plugin.c diff --git a/devman_internal.c b/src/devman_internal.c similarity index 96% rename from devman_internal.c rename to src/devman_internal.c index 94f484b..96747cf 100644 --- a/devman_internal.c +++ b/src/devman_internal.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #include @@ -38,7 +38,7 @@ #include "devlog.h" #include "devman_internal.h" -#define WD_RESPONSE_TIMEOUT 100 /* 0.1 seconds */ +#define WD_RESPONSE_TIMEOUT 100 /* 0.1 seconds */ #define DISPLAY_WD_PATH "/usr/bin/display_wd" static int fifo_fd; @@ -115,7 +115,7 @@ API int display_cancel_postjob(void) DBG("fifo file path is %s", buf); return -1; } - ret = DISPLAY_WD_CANCEL; + ret = DISPLAY_WD_CANCEL; write(fifo_fd, &ret, sizeof(int)); close(fifo_fd); unlink(buf); diff --git a/display_wd.c b/src/display_wd.c old mode 100755 new mode 100644 similarity index 83% rename from display_wd.c rename to src/display_wd.c index 9b179bc..3745221 --- a/display_wd.c +++ b/src/display_wd.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #include @@ -45,13 +45,16 @@ static void sig_quit(int signo) fprintf(stderr, "[DISPLAY_WD] display_wd will be exit for signal %d\n", signo); if(fifo_pollfd.fd >= 0) close(fifo_pollfd.fd); - if (access(fifo_path, F_OK) == 0) + if (access(fifo_path, F_OK) == 0) unlink(fifo_path); } int main(void) { - int fd, ret, val = -1; + int fd = -1; + int ret = -1; + int val = -1; + int auto_brightness_state = -1; fifo_pollfd.fd = -1; setsid(); @@ -61,7 +64,7 @@ int main(void) fifo_pollfd.fd = open(fifo_path, O_WRONLY); if (fifo_pollfd.fd < 0) { fprintf(stderr, "[DISPLAY_WD] Cannot open the fifo file - %s.\n", - fifo_path); + fifo_path); return -1; } @@ -74,7 +77,7 @@ int main(void) fifo_pollfd.fd = open(fifo_path, O_RDONLY); if (fifo_pollfd.fd < 0) { fprintf(stderr, "[DISPLAY_WD] Cannot open the fifo file - %s.\n", - fifo_path); + fifo_path); return -1; } @@ -83,8 +86,8 @@ int main(void) while (ret != DISPLAY_WD_CANCEL) { if (poll(&fifo_pollfd, 1, -1) < 0) { fprintf(stderr, - "[DISPLAY_WD] Cannot poll the fifo file - %s\n", - fifo_path); + "[DISPLAY_WD] Cannot poll the fifo file - %s\n", + fifo_path); close(fifo_pollfd.fd); return -1; } @@ -92,8 +95,8 @@ int main(void) read(fifo_pollfd.fd, &ret, sizeof(int)); if (ret == DISPLAY_WD_CANCEL) { fprintf(stderr, - "[DISPLAY_WD] Canceled. - %s, %d\n", - fifo_path, ret); + "[DISPLAY_WD] Canceled. - %s, %d\n", + fifo_path, ret); close(fifo_pollfd.fd); return -1; } @@ -111,5 +114,11 @@ int main(void) device_set_property(DEVTYPE_LED, LED_PROP_BRIGHTNESS, 0); } + if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &auto_brightness_state) == 0) { + if (auto_brightness_state == SETTING_BRIGHTNESS_AUTOMATIC_PAUSE) { + vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_ON); + } + } + return 0; } diff --git a/if_generic.c b/src/if_generic.c old mode 100755 new mode 100644 similarity index 67% rename from if_generic.c rename to src/if_generic.c index 36851e3..810d663 --- a/if_generic.c +++ b/src/if_generic.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,74 +17,94 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #include #include +#include "devman_error.h" #include "devlog.h" #include "device_engine.h" API int device_get_property(devtype_t devtype, int property, int *value) { struct device *dev = NULL; -retry: + int ret = -1; + + retry: if (dev != NULL) { dev = dev->next; if (dev == NULL) { - errno = ENODEV; - return -1; + DBG("devtype cannot find"); + errno = EPERM; + return DEVMAN_ERROR_OPERATION_FAILED; } } dev = find_device(dev, devtype); if (dev == NULL) { DBG("devtype cannot find"); - errno = ENODEV; - return -1; + errno = EPERM; + return DEVMAN_ERROR_OPERATION_FAILED; } if (dev->get_int == NULL) { DBG("get_int of %s is null", dev->devname); goto retry; } - if (dev->get_int(property, value) == -1) { + ret = dev->get_int(property, value); + if (ret == -ENODEV) { + DBG("not support driver"); + errno = ENODEV; + return DEVMAN_ERROR_NOT_SUPPORTED; + } + if (ret == -1) { DBG("get_int of %s return fails", dev->devname); goto retry; } errno = 0; - return 0; + return ret; } API int device_set_property(devtype_t devtype, int property, int value) { struct device *dev = NULL; -retry: + int ret = -1; + + retry: if (dev != NULL) { dev = dev->next; if (dev == NULL) { - return -1; + DBG("devtype cannot find"); + errno = EPERM; + return DEVMAN_ERROR_OPERATION_FAILED; } } dev = find_device(dev, devtype); if (dev == NULL) { DBG("devtype cannot find"); - errno = ENODEV; - return -1; + errno = EPERM; + return DEVMAN_ERROR_OPERATION_FAILED; } if (dev->set_int == NULL) { - errno = EPERM; + DBG("set_int of %s is null", dev->devname); goto retry; } - if (dev->set_int(property, value) == -1) { - errno = EACCES; + ret = dev->set_int(property, value); + if (ret == -ENODEV) { + DBG("not support driver"); + errno = ENODEV; + return DEVMAN_ERROR_NOT_SUPPORTED; + } + if (ret == -1) { + DBG("set_int of %s return fails", dev->devname); goto retry; } errno = 0; - return 0; + return ret; } diff --git a/if_legacy.c b/src/if_legacy.c old mode 100755 new mode 100644 similarity index 67% rename from if_legacy.c rename to src/if_legacy.c index 18311ce..9eaccf9 --- a/if_legacy.c +++ b/src/if_legacy.c @@ -4,7 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang - * + * * 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 @@ -17,10 +17,11 @@ * See the License for the specific language governing permissions and * limitations under the License. * -*/ +*/ #include +#include #include "devman_internal.h" #include "device_engine.h" @@ -29,19 +30,18 @@ #define DISP_INDEX_BIT 4 #define COMBINE_DISP_CMD(cmd, prop, index) (cmd = (prop | (index << DISP_INDEX_BIT))) -#define SET_FLAG(var, bit) (var |= (1< 100) { ERR("capacity value is wrong"); @@ -53,28 +53,24 @@ API int device_get_battery_pct(void) API int device_is_battery_full(void) { - int capacity = 0, charge_state = 0; - if(device_get_property(DEVTYPE_POWERSUPPLY, POWER_SUPPLY_PROP_CAPACITY, &capacity) < 0) + int charge_full = 0; + if (device_get_property(DEVTYPE_POWERSUPPLY, POWER_SUPPLY_PROP_CHARGE_FULL, &charge_full) < 0) return -1; - /* If the capacity is 100 and charge state is 1, battery is not full */ - device_get_property(DEVTYPE_POWERSUPPLY, POWER_SUPPLY_PROP_CHARGE_NOW, &charge_state); - if(capacity < 0 || capacity > 100) { - ERR("capacity value is wrong"); + if (charge_full != 0 && charge_full != 1) { + ERR("charge_full value is wrong"); return -1; - } else if(capacity == 100 && charge_state < 1) { - return 1; - } else { - return 0; } + + return charge_full; } API int device_get_battery_health(void) { int health = -1; - if(device_get_property(DEVTYPE_POWERSUPPLY, POWER_SUPPLY_PROP_BATTERY_HEALTH, &health) < 0) + if (device_get_property(DEVTYPE_POWERSUPPLY, POWER_SUPPLY_PROP_BATTERY_HEALTH, &health) < 0) return -1; - if(health < BAT_UNKNOWN || health > BAT_COLD) { + if (health < BAT_UNKNOWN || health > BAT_COLD) { ERR("battery health value is wrong"); return -1; } @@ -82,6 +78,20 @@ API int device_get_battery_health(void) return health; } +API int device_get_battery_pct_raw(void) +{ + int val; + int ret = -1; + + ret = device_get_property(DEVTYPE_POWERSUPPLY, POWER_SUPPLY_PROP_CAPACITY_RAW, &val); + if (ret < 0) + return ret; + + if (val > 10000) + return 10000; + return val; +} + API int device_get_display_brt(display_num_t lcdnum) { int val; @@ -97,10 +107,11 @@ API int device_get_display_brt(display_num_t lcdnum) API int device_set_display_brt(display_num_t lcdnum, int val) { int bat_state = -1; + int auto_brightness_state = -1; int ret = -1; int cmd; - if(vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state) != 0 || bat_state >= VCONFKEY_SYSMAN_BAT_WARNING_LOW ) { + if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state) != 0 || bat_state >= VCONFKEY_SYSMAN_BAT_WARNING_LOW ) { COMBINE_DISP_CMD(cmd, DISPLAY_PROP_BRIGHTNESS, lcdnum); if (device_set_property(DEVTYPE_DISPLAY0, cmd, val) < 0) return -1; @@ -109,6 +120,13 @@ API int device_set_display_brt(display_num_t lcdnum, int val) return -1; } + if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &auto_brightness_state) == 0) { + if (auto_brightness_state == SETTING_BRIGHTNESS_AUTOMATIC_ON) { + DBG("Auto brightness is paused"); + vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_PAUSE); + } + } + if (!disp_flag) ret = display_register_postjob(); if (ret == 0) @@ -120,30 +138,47 @@ API int device_release_brt_ctrl(display_num_t lcdnum) { int setting_val=0; int bat_state=-1; + int auto_brightness_state = -1; int cmd; - if(vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state) != 0 || bat_state >= VCONFKEY_SYSMAN_BAT_WARNING_LOW ) { - if(vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &setting_val) != 0){ - COMBINE_DISP_CMD(cmd, DISPLAY_PROP_MAX_BRIGHTNESS, lcdnum); + if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, &bat_state) != 0 || bat_state >= VCONFKEY_SYSMAN_BAT_WARNING_LOW ) { + if(vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &setting_val) != 0) { + COMBINE_DISP_CMD(cmd, DISPLAY_PROP_MAX_BRIGHTNESS, lcdnum); if (device_get_property(DEVTYPE_DISPLAY0, cmd, &setting_val) < 0) return -1; - setting_val=setting_val*0.7; + setting_val = setting_val * 0.7; } COMBINE_DISP_CMD(cmd, DISPLAY_PROP_BRIGHTNESS, lcdnum); if (device_set_property(DEVTYPE_DISPLAY0, cmd, setting_val) < 0) return -1; - } else { - ERR("can not set brightness for low battery"); - return -1; + } + + if (vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &auto_brightness_state) == 0) { + if (auto_brightness_state == SETTING_BRIGHTNESS_AUTOMATIC_PAUSE) { + DBG("Auto brightness is enable"); + vconf_set_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, SETTING_BRIGHTNESS_AUTOMATIC_ON); + } } UNSET_FLAG(disp_flag, BRT_BIT); - if (!disp_flag) + if (!disp_flag) display_cancel_postjob(); return 0; } +API int device_get_min_brt(display_num_t lcdnum) +{ + int val = -1; + int cmd; + + COMBINE_DISP_CMD(cmd, DISPLAY_PROP_MIN_BRIGHTNESS, lcdnum); + if (device_get_property(DEVTYPE_DISPLAY0, cmd, &val) < 0) + return -1; + + return val; +} + API int device_get_max_brt(display_num_t lcdnum) { int val = -1; @@ -205,7 +240,7 @@ API int device_get_display_count(void) int val = -1; if (device_get_property - (DEVTYPE_DISPLAY0, DISPLAY_PROP_DISPLAY_COUNT, &val) < 0) + (DEVTYPE_DISPLAY0, DISPLAY_PROP_DISPLAY_COUNT, &val) < 0) return -1; return val; @@ -222,9 +257,9 @@ API int device_get_image_enhance_mode(void) } API int device_set_image_enhance_mode(int val) -{ +{ if (device_set_property(DEVTYPE_DISPLAY0, DISPLAY_PROP_IMAGE_ENHANCE_MODE, val) < 0) - return -1; + return -1; return 0; } @@ -283,6 +318,16 @@ API int device_set_image_enhance_outdoor(int val) return 0; } +API int device_get_image_enhance_info(void) +{ + int val = -1; + + if (device_get_property(DEVTYPE_DISPLAY0, DISPLAY_PROP_IMAGE_ENHANCE_INFO, &val) < 0) + return -1; + + return val; +} + API int device_power_suspend(void) { if (device_set_property(DEVTYPE_POWER, POWER_PROP_STATE, 0) < 0) @@ -294,18 +339,22 @@ API int device_power_suspend(void) API int device_get_led_brt(void) { int val; + int ret = -1; - if (device_get_property(DEVTYPE_LED, LED_PROP_BRIGHTNESS, &val) < 0) - return -1; + ret = device_get_property(DEVTYPE_LED, LED_PROP_BRIGHTNESS, &val); + if (ret < 0) + return ret; return val; } API int device_set_led_brt(int val) { - int ret=-1; - if (device_set_property(DEVTYPE_LED, LED_PROP_BRIGHTNESS, val) < 0) - return -1; + int ret = -1; + + ret = device_set_property(DEVTYPE_LED, LED_PROP_BRIGHTNESS, val); + if (ret < 0) + return ret; if (val == 0) { UNSET_FLAG(disp_flag, LED_BIT); @@ -323,15 +372,16 @@ API int device_set_led_brt(int val) API int device_get_max_led(void) { int val = -1; + int ret = -1; - if (device_get_property(DEVTYPE_LED, LED_PROP_MAX_BRIGHTNESS, &val) < 0) - return -1; + ret = device_get_property(DEVTYPE_LED, LED_PROP_MAX_BRIGHTNESS, &val); + if (ret < 0) + return ret; return val; } - -int device_get_acl_control_status(display_num_t num) +API int device_get_acl_control_status(display_num_t num) { int val = -1; int cmd; @@ -343,7 +393,7 @@ int device_get_acl_control_status(display_num_t num) return val; } -int device_set_acl_control_status(display_num_t num, int val) +API int device_set_acl_control_status(display_num_t num, int val) { int cmd; -- 2.7.4