4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: DongGi Jang <dg0402.jang@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 #include <sys/types.h>
32 #include <iniparser.h>
35 #include "device_haptic.h"
37 #include "devman_haptic.h"
38 #include "devman_haptic_ext.h"
39 #include "devman_haptic_plugin_intf.h"
40 /* START: Will be excluded by removing pattern */
41 #include "device_haptic_tsp4000_pattern.h"
42 /* END: Will be excluded */
45 #define EXTAPI __attribute__ ((visibility("default")))
48 #define HAPTIC_DEVICE_NODE_PATH "/dev/tspdrv"
49 #define HAPTIC_MODULE_PATH "/usr/lib/devman/libdevman_haptic.so"
51 #define __STR_EMUL "emul"
52 #define __LEN_STR_EMUL 4
53 #define BIN_INFO_FILE_PATH "/etc/info.ini"
55 /* START: Will be supported by kernel */
56 //#define NEED_THE_SUPPORT_OF_KERNEL
57 /* END: Will be supported */
59 /* START: Will be removed by removing pattern */
62 unsigned char *ivt_pt;
66 struct g_pivt_list_t g_haptic_internal_pattern_list[EFFCTVIBE_PATTERN_END] = {
68 [EFFCTVIBE_TOUCH] = { touch_ivt, 15},
69 [EFFCTVIBE_HW_TOUCH] = { hw_touch_ivt, 15},
71 [EFFCTVIBE_NOTIFICATION] = { noti_ivt, 7},
72 [EFFCTVIBE_INCOMING_CALL01] = { incomming_01_ivt, 7},
73 [EFFCTVIBE_INCOMING_CALL02] = { incomming_02_ivt, 7},
74 [EFFCTVIBE_INCOMING_CALL03] = { incomming_03_ivt, 7},
76 [EFFCTVIBE_ALERTS_CALL] = { alerts_call_ivt, 15},
77 [EFFCTVIBE_OPERATION] = { operation_ivt, 7},
78 [EFFCTVIBE_SILENT_MODE] = { silent_ivt, 7},
80 /* END: Will be removed */
89 static int has_haptic_module = MODULE_NONE;
90 static int feedback_mode = 0;
91 static int device_handle_count = 0;
93 /* Device Manager Haptic Plugin Interface */
94 static void *dlopen_handle;
95 static const devman_haptic_plugin_interface *plugin_intf;
98 MODE_DEFAULT = 0x0000,
99 MODE_FEEDBACK_LEVEL_CHECK_DISABLE = 0x0001,
102 /* START of Static Function Section */
103 static int __get_master_strength_value()
105 int setting_fb_level = -1;
108 return VIBE_FEEDBACK_LEVEL_3;
110 if (vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &setting_fb_level) < 0) {
111 setting_fb_level = SETTING_VIB_FEEDBACK_LEVEL3;
114 switch (setting_fb_level) {
115 case SETTING_VIB_FEEDBACK_LEVEL0:
117 case SETTING_VIB_FEEDBACK_LEVEL1:
118 return VIBE_FEEDBACK_LEVEL_1;
119 case SETTING_VIB_FEEDBACK_LEVEL2:
120 return VIBE_FEEDBACK_LEVEL_2;
121 case SETTING_VIB_FEEDBACK_LEVEL3:
122 return VIBE_FEEDBACK_LEVEL_3;
123 case SETTING_VIB_FEEDBACK_LEVEL4:
124 return VIBE_FEEDBACK_LEVEL_4;
125 case SETTING_VIB_FEEDBACK_LEVEL5:
126 return VIBE_FEEDBACK_LEVEL_5;
128 ERR("error get VCONF_SETAPPL_VIB_FEEDBACK_INT value (= %d) invalid", setting_fb_level);
132 static int __convert_strength_level(int base_level)
134 switch (base_level) {
135 case HAPTIC_FEEDBACK_LEVEL_0:
136 return VIBE_FEEDBACK_LEVEL_0;
137 case HAPTIC_FEEDBACK_LEVEL_1:
138 return VIBE_FEEDBACK_LEVEL_1;
139 case HAPTIC_FEEDBACK_LEVEL_2:
140 return VIBE_FEEDBACK_LEVEL_2;
141 case HAPTIC_FEEDBACK_LEVEL_3:
142 return VIBE_FEEDBACK_LEVEL_3;
143 case HAPTIC_FEEDBACK_LEVEL_4:
144 return VIBE_FEEDBACK_LEVEL_4;
145 case HAPTIC_FEEDBACK_LEVEL_5:
146 return VIBE_FEEDBACK_LEVEL_5;
148 ERR("error invalid convertable value (%d)", base_level);
152 static int __convert_priority_level(int base_level)
154 switch (base_level) {
155 case HAPTIC_PRIORITY_LEVEL_MIN:
156 return HAPTIC_MIN_DEVICE_PRIORITY;
157 case HAPTIC_PRIORITY_LEVEL_MAX_DEV:
158 return HAPTIC_MAX_DEV_DEVICE_PRIORITY;
159 case HAPTIC_PRIORITY_LEVEL_MAX_OEM:
160 return HAPTIC_MAX_OEM_DEVICE_PRIORITY;
162 ERR("error invalid convertable value (%d)", base_level);
166 static int __is_emulator_binary()
168 char szEmul[__LEN_STR_EMUL+1];
169 const char* szBinVer = NULL;
171 dictionary* dic = iniparser_load(BIN_INFO_FILE_PATH);
172 // when failed to get the info, let's regard the binary as an emulator one
176 szBinVer = (const char*)iniparser_getstr(dic, "Version:Build");
178 char* str = g_strdup(szBinVer);
185 sscanf(str, "%*s %4s", szEmul);
191 iniparser_freedict(dic);
195 if (!strncmp(szEmul, __STR_EMUL, __LEN_STR_EMUL))
200 /* END of Static Function Section */
202 /* START: devman_haptic APIs */
204 int device_haptic_open(haptic_dev_idx dev_idx, unsigned int mode)
207 int device_index = dev_idx >> 1;
210 if (!(dev_idx == DEV_IDX_0 || dev_idx == DEV_IDX_1 || dev_idx == DEV_IDX_ALL)) {
211 ERR("Invalid parameter - dev_idx(%d)", dev_idx);
212 return HAPTIC_INVALID_ARGUMENT;
215 DBG("handle count : %d, haptic module : %d\n", device_handle_count, has_haptic_module);
217 if (has_haptic_module == MODULE_NONE) {
218 ERR("%s() is not supported without specific haptic module", __func__);
219 return HAPTIC_NOT_SUPPORTED;
222 if (device_handle_count == 0) {
223 if (has_haptic_module == MODULE_TSP) {
224 plugin_intf->haptic_internal_prepare_node();
226 if (plugin_intf->haptic_internal_initialize() < 0) {
227 ERR("plugin_intf->haptic_internal_initialize() failed");
232 if (mode & MODE_FEEDBACK_LEVEL_CHECK_DISABLE) {
235 DBG("NOT USE MAIN VIB_FEEDBACK_CHECK ROUTINE !!, at pid : %d", cpid);
240 if (has_haptic_module == MODULE_TSP) {
241 if (dev_idx == DEV_IDX_ALL) {
242 status = plugin_intf->haptic_internal_open_composite_device(NULL, device_index, &device_handle);
243 if(HAPTIC_FAILED(status)) {
244 ERR("plugin_intf->haptic_internal_open_composite_device() Failed: %d", status);
248 status = plugin_intf->haptic_internal_open_device(device_index, &device_handle);
249 if(HAPTIC_FAILED(status)) {
250 ERR("plugin_intf->haptic_internal_open_device() Failed: %d", status);
255 ++device_handle_count;
256 return device_handle;
259 ++device_handle_count;
260 return DEFAULT_DEVICE_HANDLE;
264 int device_haptic_close(int device_handle)
268 if (has_haptic_module == MODULE_EMUL)
269 return HAPTIC_SUCCESS;
271 if (has_haptic_module == MODULE_NONE) {
272 ERR("%s() is not supported without specific haptic module", __func__);
273 return HAPTIC_NOT_SUPPORTED;
276 if (device_handle_count == 0) {
277 ERR("Haptic device already closed");
278 return HAPTIC_NOT_OPENED;
281 if (has_haptic_module == MODULE_TSP) {
282 status = plugin_intf->haptic_internal_close_device(device_handle);
283 if(HAPTIC_FAILED(status)) {
284 ERR("plugin_intf->haptic_internal_close_device(0) fail: %d", status);
289 --device_handle_count;
290 if (device_handle_count == 0) {
291 if (has_haptic_module == MODULE_TSP) {
292 status = plugin_intf->haptic_internal_terminate();
293 if(HAPTIC_FAILED(status)) {
294 ERR("plugin_intf->haptic_internal_terminate(0) fail: %d", status);
298 status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ENABLE, 0);
300 ERR("Haptic device close failed: %d", status);
307 return HAPTIC_SUCCESS;
311 int device_haptic_play_buffer(int device_handle, const unsigned char *vibe_buffer, int iteration, int feedback_level)
313 int input_feedback_level;
315 if (vibe_buffer == NULL || iteration < 0) {
316 ERR("Invalid parameter - vibe_buffer(NULL) or iteration(%d)", iteration);
317 return HAPTIC_INVALID_ARGUMENT;
320 if (feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || feedback_level > HAPTIC_FEEDBACK_LEVEL_END-1) {
321 ERR("feedback_level is wrong : %d", feedback_level);
322 return HAPTIC_INVALID_ARGUMENT;
325 if (has_haptic_module == MODULE_EMUL)
326 return HAPTIC_SUCCESS;
328 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
329 ERR("%s() is not supported without specific haptic module", __func__);
330 return HAPTIC_NOT_SUPPORTED;
333 if (device_handle_count == 0) {
334 ERR("Haptic device is not opened yet");
335 return HAPTIC_NOT_OPENED;
338 if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) {
339 input_feedback_level = __get_master_strength_value();
341 input_feedback_level = __convert_strength_level(feedback_level);
344 if (input_feedback_level == VIBE_FEEDBACK_LEVEL_0) {
345 DBG("feedback_level is 0, so can not vibe");
346 return HAPTIC_SUCCESS;
349 DBG("iteration : %d, feedback_level : %d, priority : %d", iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY);
350 return plugin_intf->haptic_internal_play_buffer(device_handle, vibe_buffer, iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY);
354 int device_haptic_play_file(int device_handle, const char *file_name, int iteration, int feedback_level)
356 int input_feedback_level;
358 if (file_name == NULL || iteration < 0) {
359 ERR("Invalid parameter - file_name(NULL) or iteration(%d)", iteration);
360 return HAPTIC_INVALID_ARGUMENT;
363 if (feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || feedback_level > HAPTIC_FEEDBACK_LEVEL_END-1) {
364 ERR("feedback_level is wrong : %d", feedback_level);
365 return HAPTIC_INVALID_ARGUMENT;
368 if (has_haptic_module == MODULE_EMUL)
369 return HAPTIC_SUCCESS;
371 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
372 ERR("%s() is not supported without specific haptic module", __func__);
373 return HAPTIC_NOT_SUPPORTED;
376 if (device_handle_count == 0) {
377 ERR("Haptic device is not opened yet");
378 return HAPTIC_NOT_OPENED;
381 if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) {
382 input_feedback_level = __get_master_strength_value();
384 input_feedback_level = __convert_strength_level(feedback_level);
387 if (input_feedback_level == VIBE_FEEDBACK_LEVEL_0) {
388 DBG("feedback_level is 0, so can not vibe");
389 return HAPTIC_SUCCESS;
392 DBG("iteration : %d, feedback_level : %d, priority : %d", iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY);
393 return plugin_intf->haptic_internal_play_file(device_handle, file_name, iteration, input_feedback_level, HAPTIC_MIN_DEVICE_PRIORITY);
397 int device_haptic_play_file_with_priority(int device_handle, const char *file_name, int priority_level, int iteration, int feedback_level)
399 int input_feedback_level;
400 int input_priority_level;
402 if (file_name == NULL || iteration < 0) {
403 ERR("Invalid parameter - file_name(NULL) or iteration(%d)", iteration);
404 return HAPTIC_INVALID_ARGUMENT;
407 if (priority_level < HAPTIC_PRIORITY_LEVEL_MIN || priority_level > HAPTIC_PRIORITY_LEVEL_MAX_OEM) {
408 ERR("priority_level is wrong : %d", priority_level);
409 return HAPTIC_INVALID_ARGUMENT;
412 if (feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || feedback_level > HAPTIC_FEEDBACK_LEVEL_END-1) {
413 ERR("feedback_level is wrong : %d", feedback_level);
414 return HAPTIC_INVALID_ARGUMENT;
417 if (has_haptic_module == MODULE_EMUL)
418 return HAPTIC_SUCCESS;
420 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
421 ERR("%s() is not supported without specific haptic module", __func__);
422 return HAPTIC_NOT_SUPPORTED;
425 if (device_handle_count == 0) {
426 ERR("Haptic device is not opened yet");
427 return HAPTIC_NOT_OPENED;
430 input_priority_level = __convert_priority_level(priority_level);
432 if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) {
433 input_feedback_level = __get_master_strength_value();
435 input_feedback_level = __convert_strength_level(feedback_level);
438 if (input_feedback_level == VIBE_FEEDBACK_LEVEL_0) {
439 DBG("feedback_level is 0, so can not vibe");
440 return HAPTIC_SUCCESS;
443 DBG("iteration : %d, feedback_level : %d, priority : %d", iteration, input_feedback_level, input_priority_level);
444 return plugin_intf->haptic_internal_play_file(device_handle, file_name, iteration, input_feedback_level, input_priority_level);
448 int device_haptic_play_pattern(int device_handle, int pattern, int iteration, int feedback_level)
450 int input_priority_level = -1;
451 int input_feedback_level;
453 if (pattern < EFFCTVIBE_TOUCH || pattern > EFFCTVIBE_PATTERN_END-1) {
454 ERR("Pattern value(%d) is not valid", pattern);
455 return HAPTIC_INVALID_ARGUMENT;
458 if (!g_haptic_internal_pattern_list[pattern].ivt_pt) {
459 ERR("This pattern value(%d) doesn't have a pattern buffer", pattern);
460 return HAPTIC_INVALID_ARGUMENT;
463 if (feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || feedback_level > HAPTIC_FEEDBACK_LEVEL_END-1) {
464 ERR("feedback_level is wrong : %d", feedback_level);
465 return HAPTIC_INVALID_ARGUMENT;
468 if (has_haptic_module == MODULE_EMUL)
469 return HAPTIC_SUCCESS;
471 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
472 ERR("%s() is not supported without specific haptic module", __func__);
473 return HAPTIC_NOT_SUPPORTED;
476 if (device_handle_count == 0) {
477 ERR("Haptic device is not opened yet");
478 return HAPTIC_NOT_OPENED;
481 if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) {
482 input_feedback_level = __get_master_strength_value();
484 input_feedback_level = __convert_strength_level(feedback_level);
487 if (input_feedback_level == VIBE_FEEDBACK_LEVEL_0) {
488 DBG("feedback_level is 0, so can not vibe");
489 return HAPTIC_SUCCESS;
493 if (!g_haptic_internal_pattern_list[pattern].priority) {
494 input_priority_level = HAPTIC_MIN_DEVICE_PRIORITY;
496 input_priority_level = g_haptic_internal_pattern_list[pattern].priority;
499 DBG("iteration : %d, feedback_level : %d, priority : %d", iteration, input_feedback_level, input_priority_level);
500 return plugin_intf->haptic_internal_play_buffer(device_handle, g_haptic_internal_pattern_list[pattern].ivt_pt, iteration, input_feedback_level, input_priority_level);
504 int device_haptic_stop_play(int device_handle)
508 if (has_haptic_module == MODULE_EMUL)
509 return HAPTIC_SUCCESS;
511 if (has_haptic_module == MODULE_NONE) {
512 ERR("%s() is not supported without specific haptic module", __func__);
513 return HAPTIC_NOT_SUPPORTED;
516 if (device_handle_count == 0) {
517 ERR("Haptic device is not opened yet");
518 return HAPTIC_NOT_OPENED;
521 if (has_haptic_module == MODULE_TSP) {
522 status = plugin_intf->haptic_internal_stop_all_playing_effects(device_handle);
523 if(HAPTIC_FAILED(status)) {
524 ERR("plugin_intf->haptic_internal_stop_all_playing_effects(0) fail: %d", status);
528 status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ENABLE, 0);
530 ERR("Haptic device stop failed: %d", status);
535 return HAPTIC_SUCCESS;
539 int device_haptic_play_monotone(int device_handle, int duration)
541 return device_haptic_play_monotone_with_feedback_level(device_handle, duration, HAPTIC_FEEDBACK_LEVEL_AUTO);
545 int device_haptic_play_monotone_with_feedback_level(int device_handle, int duration, int feedback_level)
549 int input_feedback_level;
552 ERR("Invalid parameter - duration(%d)", duration);
553 return HAPTIC_INVALID_ARGUMENT;
556 if (feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || feedback_level > HAPTIC_FEEDBACK_LEVEL_END-1) {
557 ERR("feedback_level is wrong : %d", feedback_level);
558 return HAPTIC_INVALID_ARGUMENT;
561 if (has_haptic_module == MODULE_EMUL)
562 return HAPTIC_SUCCESS;
564 if (has_haptic_module == MODULE_NONE) {
565 ERR("%s() is not supported without specific haptic module", __func__);
566 return HAPTIC_NOT_SUPPORTED;
569 if (device_handle_count == 0) {
570 ERR("Haptic device is not opened yet");
571 return HAPTIC_NOT_OPENED;
574 if (feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) {
575 input_feedback_level = __get_master_strength_value();
577 input_feedback_level = __convert_strength_level(feedback_level);
580 if (input_feedback_level == VIBE_FEEDBACK_LEVEL_0) {
581 DBG("feedback_level is 0, so can not vibe");
582 return HAPTIC_SUCCESS;
585 DBG("duration : %d, feedback_level : %d, priority : %d", duration, input_feedback_level, 0x05);
586 if (has_haptic_module == MODULE_TSP) {
587 status = plugin_intf->haptic_internal_play_monotone(device_handle, duration, input_feedback_level, 0x05);
588 if(HAPTIC_FAILED(status)) {
589 ERR("plugin_intf->haptic_internal_play_monotone(0) fail: %d", status);
593 status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_LEVEL, (input_feedback_level-1)/100);
595 ERR(" haptic_set_level for strength:%d (error:%d) \n", input_strength, status);
599 status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ONESHOT, duration);
601 ERR(" haptic_oneshot for duration:%d (error:%d) \n", duration, status);
606 return HAPTIC_SUCCESS;
610 int device_haptic_play_monotone_with_detail_feedback_level(int device_handle, int duration, int detail_feedback_level)
614 int input_feedback_level;
617 ERR("Invalid parameter - duration(%d)", duration);
618 return HAPTIC_INVALID_ARGUMENT;
621 if (detail_feedback_level < HAPTIC_FEEDBACK_LEVEL_AUTO || detail_feedback_level > 100) {
622 ERR("detail_feedback_level is wrong : %d", detail_feedback_level);
623 return HAPTIC_INVALID_ARGUMENT;
626 if (has_haptic_module == MODULE_EMUL)
627 return HAPTIC_SUCCESS;
629 if (has_haptic_module == MODULE_NONE) {
630 ERR("%s() is not supported without specific haptic module", __func__);
631 return HAPTIC_NOT_SUPPORTED;
634 if (device_handle_count == 0) {
635 ERR("Haptic device is not opened yet");
636 return HAPTIC_NOT_OPENED;
639 if (detail_feedback_level == HAPTIC_FEEDBACK_LEVEL_AUTO) {
640 input_feedback_level = __get_master_strength_value();
642 input_feedback_level = detail_feedback_level * 100;
645 if (input_feedback_level == 0) {
646 DBG("feedback_level is 0, so can not vibe");
647 return HAPTIC_SUCCESS;
650 DBG("duration : %d, feedback_level : %d, priority : %d", duration, input_feedback_level, 0x05);
651 if (has_haptic_module == MODULE_TSP) {
652 status = plugin_intf->haptic_internal_play_monotone(device_handle, duration, input_feedback_level, 0x05);
653 if(HAPTIC_FAILED(status)) {
654 ERR("plugin_intf->haptic_internal_play_monotone(0) fail: %d", status);
658 status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_LEVEL, (input_feedback_level-1)/100);
660 ERR(" haptic_set_level for strength:%d (error:%d) \n", input_strength, status);
664 status = device_set_property(DEVTYPE_HAPTIC, HAPTIC_PROP_ONESHOT, duration);
666 ERR(" haptic_oneshot for duration:%d (error:%d) \n", duration, status);
671 return HAPTIC_SUCCESS;
675 int device_haptic_get_buffer_duration(int device_handle, const unsigned char *vibe_buffer, int *duration)
677 if (vibe_buffer == NULL || duration == NULL) {
678 ERR("Invalid parameter - vibe_buffer(NULL) or duration(NULL)");
679 return HAPTIC_INVALID_ARGUMENT;
682 if (has_haptic_module == MODULE_EMUL) {
683 *duration = DEFAULT_DURATION_VALUE;
684 return HAPTIC_SUCCESS;
687 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
688 ERR("%s() is not supported without specific haptic module", __func__);
689 return HAPTIC_NOT_SUPPORTED;
692 if (device_handle_count == 0) {
693 ERR("Haptic device is not opened yet");
694 return HAPTIC_NOT_OPENED;
697 return plugin_intf->haptic_internal_get_buffer_duration(device_handle, vibe_buffer, duration);
701 int device_haptic_get_file_duration(int device_handle, const char *file_name, int *duration)
703 if (file_name == NULL || duration == NULL) {
704 ERR("Invalid parameter - file_name(NULL) or duration(NULL)");
705 return HAPTIC_INVALID_ARGUMENT;
708 if (has_haptic_module == MODULE_EMUL) {
709 *duration = DEFAULT_DURATION_VALUE;
710 return HAPTIC_SUCCESS;
713 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
714 ERR("%s() is not supported without specific haptic module", __func__);
715 return HAPTIC_NOT_SUPPORTED;
718 if (device_handle_count == 0) {
719 ERR("Haptic device is not opened yet");
720 return HAPTIC_NOT_OPENED;
723 return plugin_intf->haptic_internal_get_file_duration(device_handle, file_name, duration);
727 int device_haptic_get_pattern_duration(int device_handle, int pattern, int *duration)
729 if (duration == NULL) {
730 ERR("Invalid parameter - duration(NULL)");
731 return HAPTIC_INVALID_ARGUMENT;
734 if (pattern < EFFCTVIBE_TOUCH || pattern > EFFCTVIBE_PATTERN_END-1) {
735 ERR("Pattern value(%d) is not valid", pattern);
736 return HAPTIC_INVALID_ARGUMENT;
739 if (!g_haptic_internal_pattern_list[pattern].ivt_pt) {
740 ERR("This pattern value(%d) doesn't have a pattern buffer", pattern);
741 return HAPTIC_INVALID_ARGUMENT;
744 if (has_haptic_module == MODULE_EMUL) {
745 *duration = DEFAULT_DURATION_VALUE;
746 return HAPTIC_SUCCESS;
749 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
750 ERR("%s() is not supported without specific haptic module", __func__);
751 return HAPTIC_NOT_SUPPORTED;
754 if (device_handle_count == 0) {
755 ERR("Haptic device is not opened yet");
756 return HAPTIC_NOT_OPENED;
759 return plugin_intf->haptic_internal_get_buffer_duration(device_handle, g_haptic_internal_pattern_list[pattern].ivt_pt, duration);
763 int device_haptic_get_device_count()
766 int device_count = -1;
768 if (has_haptic_module == MODULE_NONE) {
769 return HAPTIC_NOT_SUPPORTED;
772 if (has_haptic_module == MODULE_TSP) {
773 if (device_handle_count == 0) {
774 plugin_intf->haptic_internal_prepare_node();
776 status = plugin_intf->haptic_internal_initialize();
780 /* Get device count */
781 device_count = plugin_intf->haptic_internal_get_device_count();
782 if(HAPTIC_FAILED(device_count)) {
783 ERR("plugin_intf->haptic_internal_get_device_count(0) fail: %d",status);
787 status = plugin_intf->haptic_internal_terminate();
792 device_count = plugin_intf->haptic_internal_get_device_count();
793 if(HAPTIC_FAILED(device_count)) {
794 ERR("plugin_intf->haptic_internal_get_device_count(0) fail: %d",status);
802 return DEFAULT_MOTOR_COUNT;
804 /* END: devman_haptic APIs */
807 /* START: devman_haptic_ext APIs */
809 int device_haptic_get_device_state(int device_index, int *state)
811 int index = device_index >> 1;
813 if (!(device_index == DEV_IDX_0 || device_index == DEV_IDX_1 || device_index == DEV_IDX_ALL)) {
814 ERR("Invalid parameter - device_index(%d)", device_index);
815 return HAPTIC_INVALID_ARGUMENT;
819 ERR("Invalid parameter - state(NULL)");
820 return HAPTIC_INVALID_ARGUMENT;
823 if (has_haptic_module == MODULE_EMUL)
824 return HAPTIC_SUCCESS;
826 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
827 ERR("%s() is not supported without specific haptic module", __func__);
828 return HAPTIC_NOT_SUPPORTED;
831 if (device_handle_count == 0) {
832 ERR("Haptic device is not opened yet");
833 return HAPTIC_NOT_OPENED;
836 return plugin_intf->haptic_internal_get_device_state(index, state);
840 int device_haptic_get_device_capability_bool(int device_index, int device_cap_type, unsigned char *device_cap_value)
842 int index = device_index >> 1;
844 if (!(device_index == DEV_IDX_0 || device_index == DEV_IDX_1 || device_index == DEV_IDX_ALL)) {
845 ERR("Invalid parameter - device_index(%d)", device_index);
846 return HAPTIC_INVALID_ARGUMENT;
849 if (device_cap_value == NULL) {
850 ERR("Invalid parameter - device_cap_value(NULL)");
851 return HAPTIC_INVALID_ARGUMENT;
854 if (device_cap_type < HAPTIC_DEVCAPTYPE_DEVICE_CATEGORY || device_cap_type > HAPTIC_DEVCAPTYPE_HANDSET_INDEX) {
855 ERR("Invalid parameter - device_cap_type(%d)", device_cap_type);
856 return HAPTIC_INVALID_ARGUMENT;
859 if (has_haptic_module == MODULE_EMUL)
860 return HAPTIC_SUCCESS;
862 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
863 ERR("%s() is not supported without specific haptic module", __func__);
864 return HAPTIC_NOT_SUPPORTED;
867 if (device_handle_count == 0) {
868 ERR("Haptic device is not opened yet");
869 return HAPTIC_NOT_OPENED;
872 return plugin_intf->haptic_internal_get_device_capability_bool(index, device_cap_type, device_cap_value);
876 int device_haptic_get_device_capability_int32(int device_index, int device_cap_type, int *device_cap_value)
878 int index = device_index >> 1;
880 if (!(device_index == DEV_IDX_0 || device_index == DEV_IDX_1 || device_index == DEV_IDX_ALL)) {
881 ERR("Invalid parameter - device_index(%d)", device_index);
882 return HAPTIC_INVALID_ARGUMENT;
885 if (device_cap_value == NULL) {
886 ERR("Invalid parameter - device_cap_value(NULL)");
887 return HAPTIC_INVALID_ARGUMENT;
890 if (device_cap_type < HAPTIC_DEVCAPTYPE_DEVICE_CATEGORY || device_cap_type > HAPTIC_DEVCAPTYPE_HANDSET_INDEX) {
891 ERR("Invalid parameter - device_cap_type(%d)", device_cap_type);
892 return HAPTIC_INVALID_ARGUMENT;
895 if (has_haptic_module == MODULE_EMUL)
896 return HAPTIC_SUCCESS;
898 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
899 ERR("%s() is not supported without specific haptic module", __func__);
900 return HAPTIC_NOT_SUPPORTED;
903 if (device_handle_count == 0) {
904 ERR("Haptic device is not opened yet");
905 return HAPTIC_NOT_OPENED;
908 return plugin_intf->haptic_internal_get_device_capability_int32(index, device_cap_type, device_cap_value);
912 int device_haptic_get_device_capability_string(int device_index, int device_cap_type, int size, char *device_cap_value)
914 int index = device_index >> 1;
916 if (!(device_index == DEV_IDX_0 || device_index == DEV_IDX_1 || device_index == DEV_IDX_ALL)) {
917 ERR("Invalid parameter - device_index(%d)", device_index);
918 return HAPTIC_INVALID_ARGUMENT;
921 if (device_cap_value == NULL) {
922 ERR("Invalid parameter - device_cap_value(NULL)");
923 return HAPTIC_INVALID_ARGUMENT;
926 if (device_cap_type < HAPTIC_DEVCAPTYPE_DEVICE_CATEGORY || device_cap_type > HAPTIC_DEVCAPTYPE_HANDSET_INDEX) {
927 ERR("Invalid parameter - device_cap_type(%d)", device_cap_type);
928 return HAPTIC_INVALID_ARGUMENT;
931 if (has_haptic_module == MODULE_EMUL)
932 return HAPTIC_SUCCESS;
934 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
935 ERR("%s() is not supported without specific haptic module", __func__);
936 return HAPTIC_NOT_SUPPORTED;
939 if (device_handle_count == 0) {
940 ERR("Haptic device is not opened yet");
941 return HAPTIC_NOT_OPENED;
944 return plugin_intf->haptic_internal_get_device_capability_string(index, device_cap_type, size, device_cap_value);
948 int device_haptic_get_device_property_bool(int device_handle, int device_prop_type, unsigned char *device_prop_value)
950 if (device_prop_value == NULL) {
951 ERR("Invalid parameter - device_prop_value(NULL)");
952 return HAPTIC_INVALID_ARGUMENT;
955 if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) {
956 ERR("Invalid parameter - device_prop_type(%d)", device_prop_type);
957 return HAPTIC_INVALID_ARGUMENT;
960 if (has_haptic_module == MODULE_EMUL)
961 return HAPTIC_SUCCESS;
963 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
964 ERR("%s() is not supported without specific haptic module", __func__);
965 return HAPTIC_NOT_SUPPORTED;
968 if (device_handle_count == 0) {
969 ERR("Haptic device is not opened yet");
970 return HAPTIC_NOT_OPENED;
973 return plugin_intf->haptic_internal_get_device_property_bool(device_handle, device_prop_type, device_prop_value);
977 int device_haptic_set_device_property_bool(int device_handle, int device_prop_type, unsigned char device_prop_value)
979 if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) {
980 ERR("Invalid parameter - device_prop_type(%d)", device_prop_type);
981 return HAPTIC_INVALID_ARGUMENT;
984 if (has_haptic_module == MODULE_EMUL)
985 return HAPTIC_SUCCESS;
987 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
988 ERR("%s() is not supported without specific haptic module", __func__);
989 return HAPTIC_NOT_SUPPORTED;
992 if (device_handle_count == 0) {
993 ERR("Haptic device is not opened yet");
994 return HAPTIC_NOT_OPENED;
997 return plugin_intf->haptic_internal_set_device_property_bool(device_handle, device_prop_type, device_prop_value);
1001 int device_haptic_get_device_property_int32(int device_handle, int device_prop_type, int *device_prop_value)
1003 if (device_prop_value == NULL) {
1004 ERR("Invalid parameter - device_prop_value(NULL)");
1005 return HAPTIC_INVALID_ARGUMENT;
1008 if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) {
1009 ERR("Invalid parameter - device_prop_type(%d)", device_prop_type);
1010 return HAPTIC_INVALID_ARGUMENT;
1013 if (has_haptic_module == MODULE_EMUL)
1014 return HAPTIC_SUCCESS;
1016 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1017 ERR("%s() is not supported without specific haptic module", __func__);
1018 return HAPTIC_NOT_SUPPORTED;
1021 if (device_handle_count == 0) {
1022 ERR("Haptic device is not opened yet");
1023 return HAPTIC_NOT_OPENED;
1026 return plugin_intf->haptic_internal_get_device_property_int32(device_handle, device_prop_type, device_prop_value);
1030 int device_haptic_set_device_property_int32(int device_handle, int device_prop_type, int device_prop_value)
1032 if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) {
1033 ERR("Invalid parameter - device_prop_type(%d)", device_prop_type);
1034 return HAPTIC_INVALID_ARGUMENT;
1037 if (has_haptic_module == MODULE_EMUL)
1038 return HAPTIC_SUCCESS;
1040 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1041 ERR("%s() is not supported without specific haptic module", __func__);
1042 return HAPTIC_NOT_SUPPORTED;
1045 if (device_handle_count == 0) {
1046 ERR("Haptic device is not opened yet");
1047 return HAPTIC_NOT_OPENED;
1050 return plugin_intf->haptic_internal_set_device_property_int32(device_handle, device_prop_type, device_prop_value);
1054 int device_haptic_get_device_property_string(int device_handle, int device_prop_type, int size, char *device_prop_value)
1056 if (size <= 0 || device_prop_value == NULL) {
1057 ERR("Invalid parameter - size(%d) or device_prop_value(NULL)", size);
1058 return HAPTIC_INVALID_ARGUMENT;
1061 if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) {
1062 ERR("Invalid parameter - device_prop_type(%d)", device_prop_type);
1063 return HAPTIC_INVALID_ARGUMENT;
1066 if (has_haptic_module == MODULE_EMUL)
1067 return HAPTIC_SUCCESS;
1069 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1070 ERR("%s() is not supported without specific haptic module", __func__);
1071 return HAPTIC_NOT_SUPPORTED;
1074 if (device_handle_count == 0) {
1075 ERR("Haptic device is not opened yet");
1076 return HAPTIC_NOT_OPENED;
1079 return plugin_intf->haptic_internal_get_device_property_string(device_handle, device_prop_type, size, device_prop_value);
1083 int device_haptic_set_device_property_string(int device_handle, int device_prop_type, const char *device_prop_value)
1085 if (device_prop_value == NULL) {
1086 ERR("Invalid parameter - device_prop_value(NULL)");
1087 return HAPTIC_INVALID_ARGUMENT;
1090 if (device_prop_type < HAPTIC_DEVPROPTYPE_PRIORITY || device_prop_type > HAPTIC_DEVPROPTYPE_MASTERSTRENGTH) {
1091 ERR("Invalid parameter - device_prop_type(%d)", device_prop_type);
1092 return HAPTIC_INVALID_ARGUMENT;
1095 if (has_haptic_module == MODULE_EMUL)
1096 return HAPTIC_SUCCESS;
1098 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1099 ERR("%s() is not supported without specific haptic module", __func__);
1100 return HAPTIC_NOT_SUPPORTED;
1103 if (device_handle_count == 0) {
1104 ERR("Haptic device is not opened yet");
1105 return HAPTIC_NOT_OPENED;
1108 return plugin_intf->haptic_internal_set_device_property_string(device_handle, device_prop_type, device_prop_value);
1112 int device_haptic_get_effect_count(const unsigned char *haptic_buffer)
1114 if (haptic_buffer == NULL) {
1115 ERR("Invalid parameter - haptic_buffer(NULL)");
1116 return HAPTIC_INVALID_ARGUMENT;
1119 if (has_haptic_module == MODULE_EMUL)
1120 return HAPTIC_SUCCESS;
1122 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1123 ERR("%s() is not supported without specific haptic module", __func__);
1124 return HAPTIC_NOT_SUPPORTED;
1127 if (device_handle_count == 0) {
1128 ERR("Haptic device is not opened yet");
1129 return HAPTIC_NOT_OPENED;
1132 return plugin_intf->haptic_internal_get_IVT_effect_count(haptic_buffer);
1136 int device_haptic_get_effect_name(const unsigned char *haptic_buffer, int effect_index, int size, char *effect_name)
1138 if (haptic_buffer == NULL || effect_index < 0 || size <= 0 || effect_name == NULL) {
1139 ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or size(%d) or effect_name(NULL)", effect_index, size);
1140 return HAPTIC_INVALID_ARGUMENT;
1143 if (has_haptic_module == MODULE_EMUL)
1144 return HAPTIC_SUCCESS;
1146 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1147 ERR("%s() is not supported without specific haptic module", __func__);
1148 return HAPTIC_NOT_SUPPORTED;
1151 if (device_handle_count == 0) {
1152 ERR("Haptic device is not opened yet");
1153 return HAPTIC_NOT_OPENED;
1156 return plugin_intf->haptic_internal_get_IVT_effect_name(haptic_buffer, effect_index, size, effect_name);
1160 int device_haptic_get_effect_name_u(const unsigned char *haptic_buffer, int effect_index, int size, unsigned short *effect_name)
1162 if (haptic_buffer == NULL || effect_index < 0 || size <= 0 || effect_name == NULL) {
1163 ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or size(%d) or effect_name(NULL)", effect_index, size);
1164 return HAPTIC_INVALID_ARGUMENT;
1167 if (has_haptic_module == MODULE_EMUL)
1168 return HAPTIC_SUCCESS;
1170 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1171 ERR("%s() is not supported without specific haptic module", __func__);
1172 return HAPTIC_NOT_SUPPORTED;
1175 if (device_handle_count == 0) {
1176 ERR("Haptic device is not opened yet");
1177 return HAPTIC_NOT_OPENED;
1180 return plugin_intf->haptic_internal_get_IVT_effect_name_u(haptic_buffer, effect_index, size, effect_name);
1184 int device_haptic_get_effect_index_from_name(const unsigned char *haptic_buffer, char const *effect_name, int *effect_index)
1186 if (haptic_buffer == NULL || effect_name == NULL || effect_index == NULL) {
1187 ERR("Invalid parameter - haptic_buffer(NULL) or effect_name(NULL) or effect_index(NULL)");
1188 return HAPTIC_INVALID_ARGUMENT;
1191 if (has_haptic_module == MODULE_EMUL)
1192 return HAPTIC_SUCCESS;
1194 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1195 ERR("%s() is not supported without specific haptic module", __func__);
1196 return HAPTIC_NOT_SUPPORTED;
1199 if (device_handle_count == 0) {
1200 ERR("Haptic device is not opened yet");
1201 return HAPTIC_NOT_OPENED;
1204 return plugin_intf->haptic_internal_get_IVT_effect_index_from_name(haptic_buffer, effect_name, effect_index);
1208 int device_haptic_get_effect_index_from_name_u(const unsigned char *haptic_buffer, const unsigned short *effect_name, int *effect_index)
1210 if (haptic_buffer == NULL || effect_name == NULL || effect_index == NULL) {
1211 ERR("Invalid parameter - haptic_buffer(NULL) or effect_name(NULL) or effect_index(NULL)");
1212 return HAPTIC_INVALID_ARGUMENT;
1215 if (has_haptic_module == MODULE_EMUL)
1216 return HAPTIC_SUCCESS;
1218 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1219 ERR("%s() is not supported without specific haptic module", __func__);
1220 return HAPTIC_NOT_SUPPORTED;
1223 if (device_handle_count == 0) {
1224 ERR("Haptic device is not opened yet");
1225 return HAPTIC_NOT_OPENED;
1228 return plugin_intf->haptic_internal_get_IVT_effect_index_from_name_u(haptic_buffer, effect_name, effect_index);
1232 int device_haptic_play_effect(int device_handle, const unsigned char *haptic_buffer, int effect_index, int *effect_handle)
1234 if (haptic_buffer == NULL || effect_index < 0 || effect_handle == NULL) {
1235 ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or effect_handle(NULL)", effect_index);
1236 return HAPTIC_INVALID_ARGUMENT;
1239 if (has_haptic_module == MODULE_EMUL)
1240 return HAPTIC_SUCCESS;
1242 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1243 ERR("%s() is not supported without specific haptic module", __func__);
1244 return HAPTIC_NOT_SUPPORTED;
1247 if (device_handle_count == 0) {
1248 ERR("Haptic device is not opened yet");
1249 return HAPTIC_NOT_OPENED;
1252 return plugin_intf->haptic_internal_play_IVT_effect(device_handle, haptic_buffer, effect_index, effect_handle);
1256 int device_haptic_play_effect_repeat(int device_handle, const unsigned char *haptic_buffer, int effect_index, unsigned char repeat, int *effect_handle)
1258 if (haptic_buffer == NULL || effect_index < 0 || effect_handle == NULL) {
1259 ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or effect_handle(NULL)", effect_index);
1260 return HAPTIC_INVALID_ARGUMENT;
1263 if (has_haptic_module == MODULE_EMUL)
1264 return HAPTIC_SUCCESS;
1266 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1267 ERR("%s() is not supported without specific haptic module", __func__);
1268 return HAPTIC_NOT_SUPPORTED;
1271 if (device_handle_count == 0) {
1272 ERR("Haptic device is not opened yet");
1273 return HAPTIC_NOT_OPENED;
1276 return plugin_intf->haptic_internal_play_IVT_effect_repeat(device_handle, haptic_buffer, effect_index, repeat, effect_handle);
1280 int device_haptic_stop_playing_effect(int device_handle, int effect_handle)
1282 if (has_haptic_module == MODULE_EMUL)
1283 return HAPTIC_SUCCESS;
1285 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1286 ERR("%s() is not supported without specific haptic module", __func__);
1287 return HAPTIC_NOT_SUPPORTED;
1290 if (device_handle_count == 0) {
1291 ERR("Haptic device is not opened yet");
1292 return HAPTIC_NOT_OPENED;
1295 return plugin_intf->haptic_internal_stop_playing_effect(device_handle, effect_handle);
1299 int device_haptic_get_effect_type(const unsigned char *haptic_buffer, int effect_index, int *effect_type)
1301 if (haptic_buffer == NULL || effect_index < 0 || effect_type == NULL) {
1302 ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or effect_type(NULL)", effect_index);
1303 return HAPTIC_INVALID_ARGUMENT;
1305 if (has_haptic_module == MODULE_EMUL)
1306 return HAPTIC_SUCCESS;
1308 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1309 ERR("%s() is not supported without specific haptic module", __func__);
1310 return HAPTIC_NOT_SUPPORTED;
1313 if (device_handle_count == 0) {
1314 ERR("Haptic device is not opened yet");
1315 return HAPTIC_NOT_OPENED;
1318 return plugin_intf->haptic_internal_get_IVT_effect_type(haptic_buffer, effect_index, effect_type);
1322 int device_haptic_get_magsweep_effect_definition(const unsigned char *haptic_buffer, int effect_index,
1323 int *duration, int *magnitude, int *style, int *attacktime, int *attacklevel,
1324 int *fadetime, int *fadelevel)
1326 if (haptic_buffer == NULL || effect_index < 0 || duration == NULL || magnitude == NULL || style == NULL
1327 || attacktime == NULL || attacklevel == NULL || fadetime == NULL || fadelevel == NULL) {
1328 ERR("Invalid parameter");
1329 return HAPTIC_INVALID_ARGUMENT;
1332 if (has_haptic_module == MODULE_EMUL)
1333 return HAPTIC_SUCCESS;
1335 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1336 ERR("%s() is not supported without specific haptic module", __func__);
1337 return HAPTIC_NOT_SUPPORTED;
1340 if (device_handle_count == 0) {
1341 ERR("Haptic device is not opened yet");
1342 return HAPTIC_NOT_OPENED;
1345 return plugin_intf->haptic_internal_get_IVT_magsweep_effect_definition(haptic_buffer, effect_index, duration, magnitude, style, attacktime, attacklevel, fadetime, fadelevel);
1349 int device_haptic_get_periodic_effect_definition(const unsigned char *haptic_buffer, int effect_index,
1350 int *duration, int *magnitude, int *period, int *style_and_wave_type, int *attacktime, int *attacklevel,
1351 int *fadetime, int *fadelevel)
1353 if (haptic_buffer == NULL || effect_index < 0 || duration == NULL || magnitude == NULL
1354 || period == NULL || style_and_wave_type == NULL || attacktime == NULL || attacklevel == NULL
1355 || fadetime == NULL || fadelevel == NULL) {
1356 ERR("Invalid parameter");
1357 return HAPTIC_INVALID_ARGUMENT;
1360 if (has_haptic_module == MODULE_EMUL)
1361 return HAPTIC_SUCCESS;
1363 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1364 ERR("%s() is not supported without specific haptic module", __func__);
1365 return HAPTIC_NOT_SUPPORTED;
1368 if (device_handle_count == 0) {
1369 ERR("Haptic device is not opened yet");
1370 return HAPTIC_NOT_OPENED;
1373 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);
1377 int device_haptic_get_effect_duration(const unsigned char *haptic_buffer, int effect_index, int *effect_duration)
1379 if (haptic_buffer == NULL || effect_index < 0 || effect_duration == NULL) {
1380 ERR("Invalid parameter - haptic_buffer(NULL) or effect_index(%d) or effect_duration(NULL)", effect_index);
1381 return HAPTIC_INVALID_ARGUMENT;
1384 if (has_haptic_module == MODULE_EMUL)
1385 return HAPTIC_SUCCESS;
1387 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1388 ERR("%s() is not supported without specific haptic module", __func__);
1389 return HAPTIC_NOT_SUPPORTED;
1392 if (device_handle_count == 0) {
1393 ERR("Haptic device is not opened yet");
1394 return HAPTIC_NOT_OPENED;
1397 return plugin_intf->haptic_internal_get_IVT_effect_duration(haptic_buffer, effect_index, effect_duration);
1401 int device_haptic_play_magsweep_effect(int device_handle,
1402 int duration, int magnitude, int style, int attacktime, int attacklevel,
1403 int fadetime, int fadelevel, int *effect_handle)
1405 if (duration < 0 || magnitude < 0 || style < 0 || attacktime < 0 || attacklevel < 0
1406 || fadetime < 0 || fadelevel < 0 || effect_handle == NULL) {
1407 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);
1408 return HAPTIC_INVALID_ARGUMENT;
1411 if (has_haptic_module == MODULE_EMUL)
1412 return HAPTIC_SUCCESS;
1414 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1415 ERR("%s() is not supported without specific haptic module", __func__);
1416 return HAPTIC_NOT_SUPPORTED;
1419 if (device_handle_count == 0) {
1420 ERR("Haptic device is not opened yet");
1421 return HAPTIC_NOT_OPENED;
1424 return plugin_intf->haptic_internal_play_magsweep_effect(device_handle, duration, magnitude, style, attacktime, attacklevel, fadetime, fadelevel, effect_handle);
1428 int device_haptic_play_periodic_effect(int device_handle,
1429 int duration, int magnitude, int period, int style_and_wave_type, int attacktime, int attacklevel,
1430 int fadetime, int fadelevel, int *effect_handle)
1432 if (duration < 0 || magnitude < 0 || period < 0 || style_and_wave_type < 0 || attacktime < 0
1433 || attacklevel < 0 || fadetime < 0 || fadelevel < 0 || effect_handle == NULL) {
1434 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);
1435 return HAPTIC_INVALID_ARGUMENT;
1438 if (has_haptic_module == MODULE_EMUL)
1439 return HAPTIC_SUCCESS;
1441 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1442 ERR("%s() is not supported without specific haptic module", __func__);
1443 return HAPTIC_NOT_SUPPORTED;
1446 if (device_handle_count == 0) {
1447 ERR("Haptic device is not opened yet");
1448 return HAPTIC_NOT_OPENED;
1451 return plugin_intf->haptic_internal_play_periodic_effect(device_handle, duration, magnitude, period, style_and_wave_type, attacktime, attacklevel, fadetime, fadelevel, effect_handle);
1455 int device_haptic_modify_playing_magsweep_effect(int device_handle, int effect_handle,
1456 int duration, int magnitude, int style, int attacktime, int attacklevel, int fadetime, int fadelevel)
1458 if (effect_handle < 0 || duration < 0 || magnitude < 0 || style < 0
1459 || attacktime < 0 || attacklevel < 0 || fadetime < 0 || fadelevel < 0) {
1460 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);
1461 return HAPTIC_INVALID_ARGUMENT;
1464 if (has_haptic_module == MODULE_EMUL)
1465 return HAPTIC_SUCCESS;
1467 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1468 ERR("%s() is not supported without specific haptic module", __func__);
1469 return HAPTIC_NOT_SUPPORTED;
1472 if (device_handle_count == 0) {
1473 ERR("Haptic device is not opened yet");
1474 return HAPTIC_NOT_OPENED;
1477 return plugin_intf->haptic_internal_modify_playing_magsweep_effect(device_handle, effect_handle, duration, magnitude, style, attacktime, attacklevel, fadetime, fadelevel);
1481 int device_haptic_modify_playing_periodic_effect(int device_handle, int effect_handle,
1482 int duration, int magnitude, int period, int style_and_wave_type, int attacktime, int attacklevel, int fadetime, int fadelevel)
1484 if (effect_handle < 0 || duration < 0 || magnitude < 0 || period < 0 || style_and_wave_type < 0
1485 || attacktime < 0 || attacklevel < 0 || fadetime < 0 || fadelevel < 0) {
1486 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);
1487 return HAPTIC_INVALID_ARGUMENT;
1490 if (has_haptic_module == MODULE_EMUL)
1491 return HAPTIC_SUCCESS;
1493 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1494 ERR("%s() is not supported without specific haptic module", __func__);
1495 return HAPTIC_NOT_SUPPORTED;
1498 if (device_handle_count == 0) {
1499 ERR("Haptic device is not opened yet");
1500 return HAPTIC_NOT_OPENED;
1503 return plugin_intf->haptic_internal_modify_playing_periodic_effect(device_handle, effect_handle, duration, magnitude, period, style_and_wave_type, attacktime, attacklevel, fadetime, fadelevel);
1507 int device_haptic_create_streaming_effect(int device_handle, int *effect_handle)
1509 if (effect_handle == NULL) {
1510 ERR("Invalid parameter - effect_handle(NULL)");
1511 return HAPTIC_INVALID_ARGUMENT;
1514 if (has_haptic_module == MODULE_EMUL)
1515 return HAPTIC_SUCCESS;
1517 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1518 ERR("%s() is not supported without specific haptic module", __func__);
1521 if (device_handle_count == 0) {
1522 ERR("Haptic device is not opened yet");
1523 return HAPTIC_NOT_OPENED;
1526 return plugin_intf->haptic_internal_create_streaming_effect(device_handle, effect_handle);
1530 int device_haptic_destroy_streaming_effect(int device_handle, int effect_handle)
1532 if (effect_handle < 0) {
1533 ERR("Invalid parameter - effect_handle(%d)", effect_handle);
1534 return HAPTIC_INVALID_ARGUMENT;
1537 if (has_haptic_module == MODULE_EMUL)
1538 return HAPTIC_SUCCESS;
1540 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1541 ERR("%s() is not supported without specific haptic module", __func__);
1542 return HAPTIC_NOT_SUPPORTED;
1545 if (device_handle_count == 0) {
1546 ERR("Haptic device is not opened yet");
1547 return HAPTIC_NOT_OPENED;
1550 return plugin_intf->haptic_internal_destroy_streaming_effect(device_handle, effect_handle);
1554 int device_haptic_play_streaming_sample(int device_handle, int effect_handle, const unsigned char *streaming_sample, int size)
1556 if (effect_handle < 0 || streaming_sample == NULL) {
1557 ERR("Invalid parameter - effect_handle(%d) or streaming_sample(NULL)", effect_handle);
1558 return HAPTIC_INVALID_ARGUMENT;
1561 if (has_haptic_module == MODULE_EMUL)
1562 return HAPTIC_SUCCESS;
1564 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1565 ERR("%s() is not supported without specific haptic module", __func__);
1566 return HAPTIC_NOT_SUPPORTED;
1569 if (device_handle_count == 0) {
1570 ERR("Haptic device is not opened yet");
1571 return HAPTIC_NOT_OPENED;
1574 return plugin_intf->haptic_internal_play_streaming_sample(device_handle, effect_handle, streaming_sample, size);
1578 int device_haptic_play_streaming_sample_with_offset(int device_handle, int effect_handle, const unsigned char *streaming_sample, int size, int offset_time)
1580 if (effect_handle < 0 || streaming_sample == NULL || size <= 0 || offset_time < 0) {
1581 ERR("Invalid parameter - effect_handle(%d) or streaming_sample(NULL) or size(%d) or offset_time(%d)", effect_handle, size, offset_time);
1582 return HAPTIC_INVALID_ARGUMENT;
1585 if (has_haptic_module == MODULE_EMUL)
1586 return HAPTIC_SUCCESS;
1588 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1589 ERR("%s() is not supported without specific haptic module", __func__);
1590 return HAPTIC_NOT_SUPPORTED;
1593 if (device_handle_count == 0) {
1594 ERR("Haptic device is not opened yet");
1595 return HAPTIC_NOT_OPENED;
1598 return plugin_intf->haptic_internal_play_streaming_sample_with_offset(device_handle, effect_handle, streaming_sample, size, offset_time);
1602 int device_haptic_stop_all_playing_effects(int device_handle)
1604 if (has_haptic_module == MODULE_EMUL)
1605 return HAPTIC_SUCCESS;
1607 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1608 ERR("%s() is not supported without specific haptic module", __func__);
1609 return HAPTIC_NOT_SUPPORTED;
1612 if (device_handle_count == 0) {
1613 ERR("Haptic device is not opened yet");
1614 return HAPTIC_NOT_OPENED;
1617 return plugin_intf->haptic_internal_stop_all_playing_effects(device_handle);
1621 int device_haptic_save_file(const unsigned char *ivt_buffer, int max_bufsize, const char *path_name)
1623 if (ivt_buffer == NULL || max_bufsize <= 0 || path_name == NULL) {
1624 ERR("Invalid parameter - ivt_buffer(NULL) or max_bufsize(%d) or path_name(NULL)", max_bufsize);
1625 return HAPTIC_INVALID_ARGUMENT;
1628 if (has_haptic_module == MODULE_EMUL)
1629 return HAPTIC_SUCCESS;
1631 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1632 ERR("%s() is not supported without specific haptic module", __func__);
1633 return HAPTIC_NOT_SUPPORTED;
1636 if (device_handle_count == 0) {
1637 ERR("Haptic device is not opened yet");
1638 return HAPTIC_NOT_OPENED;
1641 return plugin_intf->haptic_internal_save_IVT_file(ivt_buffer, max_bufsize, path_name);
1645 int device_haptic_delete_file(const char *path_name)
1647 if (path_name == NULL) {
1648 ERR("Invalid parameter - path_name(NULL)", path_name);
1649 return HAPTIC_INVALID_ARGUMENT;
1652 if (has_haptic_module == MODULE_EMUL)
1653 return HAPTIC_SUCCESS;
1655 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1656 ERR("%s() is not supported without specific haptic module", __func__);
1657 return HAPTIC_NOT_SUPPORTED;
1660 if (device_handle_count == 0) {
1661 ERR("Haptic device is not opened yet");
1662 return HAPTIC_NOT_OPENED;
1665 return plugin_intf->haptic_internal_delete_IVT_file(path_name);
1669 int device_haptic_pause_playing_effect(int device_handle, int effect_handle)
1671 if (effect_handle < 0) {
1672 ERR("Invalid parameter - effect_handle(%d)", effect_handle);
1673 return HAPTIC_INVALID_ARGUMENT;
1676 if (has_haptic_module == MODULE_EMUL)
1677 return HAPTIC_SUCCESS;
1679 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1680 ERR("%s() is not supported without specific haptic module", __func__);
1681 return HAPTIC_NOT_SUPPORTED;
1684 if (device_handle_count == 0) {
1685 ERR("Haptic device is not opened yet");
1686 return HAPTIC_NOT_OPENED;
1689 return plugin_intf->haptic_internal_pause_playing_effect(device_handle, effect_handle);
1693 int device_haptic_resume_paused_effect(int device_handle, int effect_handle)
1695 if (effect_handle < 0) {
1696 ERR("Invalid parameter - effect_handle(%d)", effect_handle);
1697 return HAPTIC_INVALID_ARGUMENT;
1700 if (has_haptic_module == MODULE_EMUL)
1701 return HAPTIC_SUCCESS;
1703 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1704 ERR("%s() is not supported without specific haptic module", __func__);
1705 return HAPTIC_NOT_SUPPORTED;
1708 if (device_handle_count == 0) {
1709 ERR("Haptic device is not opened yet");
1710 return HAPTIC_NOT_OPENED;
1713 return plugin_intf->haptic_internal_resume_paused_effect(device_handle, effect_handle);
1717 int device_haptic_get_effect_state(int device_handle, int effect_handle, int *effect_state)
1719 if (effect_handle < 0 || effect_state == NULL) {
1720 ERR("Invalid parameter - effect_handle(%d) or effect_state(NULL)", effect_handle);
1721 return HAPTIC_INVALID_ARGUMENT;
1724 if (has_haptic_module == MODULE_EMUL)
1725 return HAPTIC_SUCCESS;
1727 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1728 ERR("%s() is not supported without specific haptic module", __func__);
1729 return HAPTIC_NOT_SUPPORTED;
1732 if (device_handle_count == 0) {
1733 ERR("Haptic device is not opened yet");
1734 return HAPTIC_NOT_OPENED;
1737 return plugin_intf->haptic_internal_get_effect_state(device_handle, effect_handle, effect_state);
1741 int device_haptic_get_size(const unsigned char *haptic_buffer, int size)
1743 if (haptic_buffer == NULL || size <= 0) {
1744 ERR("Invalid parameter - haptic_buffer(NULL) or size(%d)", size);
1745 return HAPTIC_INVALID_ARGUMENT;
1748 if (has_haptic_module == MODULE_EMUL)
1749 return HAPTIC_SUCCESS;
1751 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1752 ERR("%s() is not supported without specific haptic module", __func__);
1753 return HAPTIC_NOT_SUPPORTED;
1756 if (device_handle_count == 0) {
1757 ERR("Haptic device is not opened yet");
1758 return HAPTIC_NOT_OPENED;
1761 return plugin_intf->haptic_internal_get_IVT_size(haptic_buffer, size);
1765 int device_haptic_initialize_buffer(unsigned char *haptic_buffer, int size)
1767 if (haptic_buffer == NULL || size <= 0) {
1768 ERR("Invalid parameter - haptic_buffer(NULL) or size(%d)", size);
1769 return HAPTIC_INVALID_ARGUMENT;
1772 if (has_haptic_module == MODULE_EMUL)
1773 return HAPTIC_SUCCESS;
1775 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1776 ERR("%s() is not supported without specific haptic module", __func__);
1777 return HAPTIC_NOT_SUPPORTED;
1780 if (device_handle_count == 0) {
1781 ERR("Haptic device is not opened yet");
1782 return HAPTIC_NOT_OPENED;
1785 return plugin_intf->haptic_internal_initialize_IVT_buffer(haptic_buffer, size);
1789 int device_haptic_insert_element(unsigned char *haptic_buffer, int size, int timeline_index, const HapticElement *element)
1791 if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element == NULL) {
1792 ERR("Invalid parameter - haptic_buffer(NULL) or size(%d) or timeline_index(%d) or element(NULL)", size, timeline_index);
1793 return HAPTIC_INVALID_ARGUMENT;
1796 if (has_haptic_module == MODULE_EMUL)
1797 return HAPTIC_SUCCESS;
1799 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1800 ERR("%s() is not supported without specific haptic module", __func__);
1801 return HAPTIC_NOT_SUPPORTED;
1804 if (device_handle_count == 0) {
1805 ERR("Haptic device is not opened yet");
1806 return HAPTIC_NOT_OPENED;
1809 return plugin_intf->haptic_internal_insert_IVT_element(haptic_buffer, size, timeline_index, element);
1813 int device_haptic_insert_element2(unsigned char *haptic_buffer, int size, int timeline_index, const HapticElement2 *element)
1815 if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element == NULL) {
1816 ERR("Invalid parameter - haptic_buffer(NULL) or size(%d) or timeline_index(%d) or element(NULL)", size, timeline_index);
1817 return HAPTIC_INVALID_ARGUMENT;
1820 if (has_haptic_module == MODULE_EMUL)
1821 return HAPTIC_SUCCESS;
1823 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1824 ERR("%s() is not supported without specific haptic module", __func__);
1825 return HAPTIC_NOT_SUPPORTED;
1828 if (device_handle_count == 0) {
1829 ERR("Haptic device is not opened yet");
1830 return HAPTIC_NOT_OPENED;
1833 return plugin_intf->haptic_internal_insert_IVT_element2(haptic_buffer, size, timeline_index, element);
1837 int device_haptic_insert_element3(unsigned char *haptic_buffer, int size, int timeline_index, const HapticElement3 *element)
1839 if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element == NULL) {
1840 ERR("Invalid parameter - haptic_buffer(NULL) or size(%d) or timeline_index(%d) or element(NULL)", size, timeline_index);
1841 return HAPTIC_INVALID_ARGUMENT;
1844 if (has_haptic_module == MODULE_EMUL)
1845 return HAPTIC_SUCCESS;
1847 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1848 ERR("%s() is not supported without specific haptic module", __func__);
1849 return HAPTIC_NOT_SUPPORTED;
1852 if (device_handle_count == 0) {
1853 ERR("Haptic device is not opened yet");
1854 return HAPTIC_NOT_OPENED;
1857 return plugin_intf->haptic_internal_insert_IVT_element3(haptic_buffer, size, timeline_index, element);
1861 int device_haptic_read_element(const unsigned char *haptic_buffer, int size, int timeline_index, int element_index, HapticElement *element)
1863 if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element_index < 0 || element == NULL) {
1864 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);
1865 return HAPTIC_INVALID_ARGUMENT;
1868 if (has_haptic_module == MODULE_EMUL)
1869 return HAPTIC_SUCCESS;
1871 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1872 ERR("%s() is not supported without specific haptic module", __func__);
1873 return HAPTIC_NOT_SUPPORTED;
1876 if (device_handle_count == 0) {
1877 ERR("Haptic device is not opened yet");
1878 return HAPTIC_NOT_OPENED;
1881 return plugin_intf->haptic_internal_read_IVT_element(haptic_buffer, size, timeline_index, element_index, element);
1885 int device_haptic_read_element2(const unsigned char *haptic_buffer, int size, int timeline_index, int element_index, HapticElement2 *element)
1887 if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element_index < 0 || element == NULL) {
1888 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);
1889 return HAPTIC_INVALID_ARGUMENT;
1892 if (has_haptic_module == MODULE_EMUL)
1893 return HAPTIC_SUCCESS;
1895 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1896 ERR("%s() is not supported without specific haptic module", __func__);
1897 return HAPTIC_NOT_SUPPORTED;
1900 if (device_handle_count == 0) {
1901 ERR("Haptic device is not opened yet");
1902 return HAPTIC_NOT_OPENED;
1905 return plugin_intf->haptic_internal_read_IVT_element2(haptic_buffer, size, timeline_index, element_index, element);
1909 int device_haptic_read_element3(const unsigned char *haptic_buffer, int size, int timeline_index, int element_index, HapticElement3 *element)
1911 if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element_index < 0 || element == NULL) {
1912 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);
1913 return HAPTIC_INVALID_ARGUMENT;
1916 if (has_haptic_module == MODULE_EMUL)
1917 return HAPTIC_SUCCESS;
1919 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1920 ERR("%s() is not supported without specific haptic module", __func__);
1921 return HAPTIC_NOT_SUPPORTED;
1924 if (device_handle_count == 0) {
1925 ERR("Haptic device is not opened yet");
1926 return HAPTIC_NOT_OPENED;
1929 return plugin_intf->haptic_internal_read_IVT_element3(haptic_buffer, size, timeline_index, element_index, element);
1933 int device_haptic_remove_element(unsigned char *haptic_buffer, int size, int timeline_index, int element_index)
1935 if (haptic_buffer == NULL || size <= 0 || timeline_index < 0 || element_index < 0) {
1936 ERR("Invalid parameter - haptic_buffer(NULL) or size(%d) or timeline_index(%d) or element_index(%d)", size, timeline_index, element_index);
1937 return HAPTIC_INVALID_ARGUMENT;
1940 if (has_haptic_module == MODULE_EMUL)
1941 return HAPTIC_SUCCESS;
1943 if (has_haptic_module == MODULE_NONE || has_haptic_module == MODULE_BASIC) {
1944 ERR("%s() is not supported without specific haptic module", __func__);
1945 return HAPTIC_NOT_SUPPORTED;
1948 if (device_handle_count == 0) {
1949 ERR("Haptic device is not opened yet");
1950 return HAPTIC_NOT_OPENED;
1953 return plugin_intf->haptic_internal_remove_IVT_element(haptic_buffer, size, timeline_index, element_index);
1955 /* END: devman_haptic_ext APIs */
1957 static void __attribute__ ((constructor)) module_init()
1961 if (__is_emulator_binary()) {
1962 has_haptic_module = MODULE_EMUL;
1963 /* START: Will be supported by kernel */
1964 #ifdef NEED_THE_SUPPORT_OF_KERNEL
1965 } else if (__is_supported_other()) {
1966 if (access(HAPTIC_DEVICE_NODE_PATH, F_OK) < 0) {
1967 has_haptic_module = MODULE_NONE;
1971 dlopen_handle = dlopen(HAPTIC_MODULE_PATH, RTLD_NOW);
1972 if (!dlopen_handle) {
1973 ERR("dlopen failed: %s", dlerror());
1974 has_haptic_module = MODULE_NONE;
1978 const devman_haptic_plugin_interface *(*get_devman_haptic_plugin_interface) ();
1979 get_devman_haptic_plugin_interface = dlsym(dlopen_handle, "get_devman_haptic_plugin_interface");
1980 if ((error = dlerror()) != NULL) {
1981 ERR("dlsym failed : %s", error);
1982 has_haptic_module = MODULE_NONE;
1983 dlclose(dlopen_handle);
1987 plugin_intf = get_devman_haptic_plugin_interface();
1989 ERR("get_devman_haptic_plugin_interface() failed");
1990 has_haptic_module = MODULE_NONE;
1991 dlclose(dlopen_handle);
1995 has_haptic_module = MODULE_TSP;
1997 /* END: Will be supported */
1999 has_haptic_module = MODULE_BASIC;
2003 static void __attribute__ ((destructor)) module_fini()
2005 if (has_haptic_module != MODULE_TSP)
2008 if (dlopen_handle) {
2009 dlclose(dlopen_handle);