tizen 2.3 release
[framework/system/deviced.git] / src / libdeviced / display.c
1 /*
2  * deviced
3  *
4  * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the License);
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19
20 #include <stdio.h>
21 #include <errno.h>
22
23 #include "log.h"
24 #include "dbus.h"
25 #include "common.h"
26 #include "dd-display.h"
27
28 #define DISPLAY_MAX_BRIGHTNESS  100
29 #define DISPLAY_MIN_BRIGHTNESS  1
30 #define DISPLAY_DIM_BRIGHTNESS  0
31
32 #define HOLDKEY_BLOCK_BIT               0x1
33 #define STANDBY_MODE_BIT                0x2
34
35 #define BLIND_MASK(val)                 ((val) & 0xFFFF)
36 #define BLIND_COLOR(a,b,c)              ((BLIND_MASK((unsigned long long)(a)) << 32) |   \
37                                                                 (BLIND_MASK(b) << 16) | BLIND_MASK(c))
38
39 #define METHOD_GET_ENHANCE_SUPPORTED    "GetEnhanceSupported"
40 #define METHOD_GET_IMAGE_ENHANCE        "GetImageEnhance"
41 #define METHOD_SET_IMAGE_ENHANCE        "SetImageEnhance"
42 #define METHOD_SET_REFRESH_RATE         "SetRefreshRate"
43 #define METHOD_GET_COLOR_BLIND          "GetColorBlind"
44 #define METHOD_SET_COLOR_BLIND          "SetColorBlind"
45 #define METHOD_LOCK_STATE               "lockstate"
46 #define METHOD_UNLOCK_STATE             "unlockstate"
47 #define METHOD_CHANGE_STATE             "changestate"
48 #define METHOD_GET_DISPLAY_COUNT        "GetDisplayCount"
49 #define METHOD_GET_MAX_BRIGHTNESS       "GetMaxBrightness"
50 #define METHOD_GET_BRIGHTNESS   "GetBrightness"
51 #define METHOD_SET_BRIGHTNESS   "SetBrightness"
52 #define METHOD_HOLD_BRIGHTNESS  "HoldBrightness"
53 #define METHOD_RELEASE_BRIGHTNESS       "ReleaseBrightness"
54 #define METHOD_GET_ACL_STATUS   "GetAclStatus"
55 #define METHOD_SET_ACL_STATUS   "SetAclStatus"
56 #define METHOD_GET_AUTO_TONE    "GetAutoTone"
57 #define METHOD_SET_AUTO_TONE    "SetAutoTone"
58 #define METHOD_GET_ENHANCED_TOUCH       "GetEnhancedTouch"
59 #define METHOD_SET_ENHANCED_TOUCH       "SetEnhancedTouch"
60 #define METHOD_GET_HBM                  "GetHBM"
61 #define METHOD_SET_HBM                  "SetHBM"
62 #define METHOD_SET_HBM_TIMEOUT          "SetHBMTimeout"
63
64 #define STR_LCD_OFF   "lcdoff"
65 #define STR_LCD_DIM   "lcddim"
66 #define STR_LCD_ON    "lcdon"
67 #define STR_SUSPEND   "suspend"
68
69 #define STR_STAYCURSTATE "staycurstate"
70 #define STR_GOTOSTATENOW "gotostatenow"
71
72 #define STR_HOLDKEYBLOCK "holdkeyblock"
73 #define STR_STANDBYMODE  "standbymode"
74 #define STR_NULL         "NULL"
75
76 #define STR_SLEEP_MARGIN "sleepmargin"
77 #define STR_RESET_TIMER  "resettimer"
78 #define STR_KEEP_TIMER   "keeptimer"
79
80 API int display_get_count(void)
81 {
82         DBusError err;
83         DBusMessage *msg;
84         int ret, ret_val;
85
86         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
87                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
88                         METHOD_GET_DISPLAY_COUNT, NULL, NULL);
89         if (!msg)
90                 return -EBADMSG;
91
92         dbus_error_init(&err);
93
94         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
95         if (!ret) {
96                 _E("no message : [%s:%s]", err.name, err.message);
97                 dbus_error_free(&err);
98                 ret_val = -EBADMSG;
99         }
100
101         dbus_message_unref(msg);
102         return ret_val;
103 }
104
105 API int display_get_max_brightness(void)
106 {
107         int ret;
108
109         ret = dbus_method_sync(DEVICED_BUS_NAME,
110                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
111                         METHOD_GET_MAX_BRIGHTNESS, NULL, NULL);
112         if (ret < 0)
113                 return DISPLAY_MAX_BRIGHTNESS;
114
115         _D("get max brightness : %d", ret);
116         return ret;
117 }
118
119 API int display_get_min_brightness(void)
120 {
121         return DISPLAY_MIN_BRIGHTNESS;
122 }
123
124 API int display_get_brightness(void)
125 {
126         DBusError err;
127         DBusMessage *msg;
128         int ret, ret_val;
129
130         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
131                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
132                         METHOD_GET_BRIGHTNESS, NULL, NULL);
133         if (!msg)
134                 return -EBADMSG;
135
136         dbus_error_init(&err);
137
138         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
139         if (!ret) {
140                 _E("no message : [%s:%s]", err.name, err.message);
141                 dbus_error_free(&err);
142                 ret_val = -EBADMSG;
143         }
144
145         dbus_message_unref(msg);
146         return ret_val;
147 }
148
149 API int display_set_brightness_with_setting(int val)
150 {
151         char str_val[32];
152         char *arr[1];
153         int ret;
154
155         if (val < 0 || val > 100)
156                 return -EINVAL;
157
158         snprintf(str_val, sizeof(str_val), "%d", val);
159         arr[0] = str_val;
160
161         ret = dbus_method_async(DEVICED_BUS_NAME,
162                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
163                         METHOD_SET_BRIGHTNESS, "i", arr);
164         if (ret < 0)
165                 _E("no message : failed to setting");
166
167         return ret;
168 }
169
170 API int display_set_brightness(int val)
171 {
172         DBusError err;
173         DBusMessage *msg;
174         char str_val[32];
175         char *arr[1];
176         int ret, ret_val;
177
178         snprintf(str_val, sizeof(str_val), "%d", val);
179         arr[0] = str_val;
180
181         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
182                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
183                         METHOD_HOLD_BRIGHTNESS, "i", arr);
184         if (!msg)
185                 return -EBADMSG;
186
187         dbus_error_init(&err);
188
189         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
190         if (!ret) {
191                 _E("no message : [%s:%s]", err.name, err.message);
192                 dbus_error_free(&err);
193                 ret_val = -EBADMSG;
194         }
195
196         dbus_message_unref(msg);
197         return ret_val;
198 }
199
200 API int display_release_brightness(void)
201 {
202         DBusError err;
203         DBusMessage *msg;
204         int ret, ret_val;
205
206         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
207                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
208                         METHOD_RELEASE_BRIGHTNESS, NULL, NULL);
209         if (!msg)
210                 return -EBADMSG;
211
212         dbus_error_init(&err);
213
214         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
215         if (!ret) {
216                 _E("no message : [%s:%s]", err.name, err.message);
217                 dbus_error_free(&err);
218                 ret_val = -EBADMSG;
219         }
220
221         dbus_message_unref(msg);
222         return ret_val;
223 }
224
225 API int display_get_acl_status(void)
226 {
227         DBusError err;
228         DBusMessage *msg;
229         int ret, ret_val;
230
231         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
232                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
233                         METHOD_GET_ACL_STATUS, NULL, NULL);
234         if (!msg)
235                 return -EBADMSG;
236
237         dbus_error_init(&err);
238
239         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
240         if (!ret) {
241                 _E("no message : [%s:%s]", err.name, err.message);
242                 dbus_error_free(&err);
243                 ret_val = -EBADMSG;
244         }
245
246         dbus_message_unref(msg);
247         return ret_val;
248 }
249
250 API int display_set_acl_status(int val)
251 {
252         DBusError err;
253         DBusMessage *msg;
254         char str_val[32];
255         char *arr[1];
256         int ret, ret_val;
257
258         snprintf(str_val, sizeof(str_val), "%d", val);
259         arr[0] = str_val;
260
261         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
262                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
263                         METHOD_SET_ACL_STATUS, "i", arr);
264         if (!msg)
265                 return -EBADMSG;
266
267         dbus_error_init(&err);
268
269         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
270         if (!ret) {
271                 _E("no message : [%s:%s]", err.name, err.message);
272                 dbus_error_free(&err);
273                 ret_val = -EBADMSG;
274         }
275
276         dbus_message_unref(msg);
277         return ret_val;
278 }
279
280 API int display_get_auto_screen_tone(void)
281 {
282         DBusError err;
283         DBusMessage *msg;
284         int ret, ret_val;
285
286         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
287                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
288                         METHOD_GET_AUTO_TONE, NULL, NULL);
289         if (!msg)
290                 return -EBADMSG;
291
292         dbus_error_init(&err);
293
294         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
295         if (!ret) {
296                 _E("no message : [%s:%s]", err.name, err.message);
297                 dbus_error_free(&err);
298                 ret_val = -EBADMSG;
299         }
300
301         dbus_message_unref(msg);
302         return ret_val;
303 }
304
305 API int display_set_auto_screen_tone(int val)
306 {
307         DBusError err;
308         DBusMessage *msg;
309         char str_val[32];
310         char *arr[1];
311         int ret, ret_val;
312
313         snprintf(str_val, sizeof(str_val), "%d", val);
314         arr[0] = str_val;
315
316         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
317                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
318                         METHOD_SET_AUTO_TONE, "i", arr);
319         if (!msg)
320                 return -EBADMSG;
321
322         dbus_error_init(&err);
323
324         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
325         if (!ret) {
326                 _E("no message : [%s:%s]", err.name, err.message);
327                 dbus_error_free(&err);
328                 ret_val = -EBADMSG;
329         }
330
331         dbus_message_unref(msg);
332         return ret_val;
333 }
334
335 API int display_get_image_enhance_info(void)
336 {
337         DBusError err;
338         DBusMessage *msg;
339         int ret, ret_val;
340
341         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
342                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
343                         METHOD_GET_ENHANCE_SUPPORTED, NULL, NULL);
344         if (!msg)
345                 return -EBADMSG;
346
347         dbus_error_init(&err);
348
349         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
350         if (!ret) {
351                 _E("no message : [%s:%s]", err.name, err.message);
352                 dbus_error_free(&err);
353                 ret_val = -EBADMSG;
354         }
355
356         dbus_message_unref(msg);
357         return ret_val;
358 }
359
360 API int display_get_image_enhance(int type)
361 {
362         DBusError err;
363         DBusMessage *msg;
364         char str_type[32];
365         char *arr[1];
366         int ret, ret_val;
367
368         snprintf(str_type, sizeof(str_type), "%d", type);
369         arr[0] = str_type;
370
371         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
372                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
373                         METHOD_GET_IMAGE_ENHANCE, "i", arr);
374         if (!msg)
375                 return -EBADMSG;
376
377         dbus_error_init(&err);
378
379         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
380         if (!ret) {
381                 _E("no message : [%s:%s]", err.name, err.message);
382                 dbus_error_free(&err);
383                 ret_val = -EBADMSG;
384         }
385
386         dbus_message_unref(msg);
387         return ret_val;
388 }
389
390 API int display_set_image_enhance(int type, int val)
391 {
392         DBusError err;
393         DBusMessage *msg;
394         char str_type[32];
395         char str_val[32];
396         char *arr[2];
397         int ret, ret_val;
398
399         snprintf(str_type, sizeof(str_type), "%d", type);
400         arr[0] = str_type;
401         snprintf(str_val, sizeof(str_val), "%d", val);
402         arr[1] = str_val;
403
404         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
405                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
406                         METHOD_SET_IMAGE_ENHANCE, "ii", arr);
407         if (!msg)
408                 return -EBADMSG;
409
410         dbus_error_init(&err);
411
412         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
413         if (!ret) {
414                 _E("no message : [%s:%s]", err.name, err.message);
415                 dbus_error_free(&err);
416                 ret_val = -EBADMSG;
417         }
418
419         dbus_message_unref(msg);
420         return ret_val;
421 }
422
423 API int display_set_frame_rate(int val)
424 {
425         return display_set_refresh_rate(REFRESH_SETTING, val);
426 }
427
428 API int display_set_refresh_rate(enum refresh_app app, int val)
429 {
430         char str_app[32];
431         char str_val[32];
432         char *arr[2];
433
434         snprintf(str_app, sizeof(str_app), "%d", app);
435         arr[0] = str_app;
436         snprintf(str_val, sizeof(str_val), "%d", val);
437         arr[1] = str_val;
438
439         return dbus_method_sync(DEVICED_BUS_NAME,
440                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
441                         METHOD_SET_REFRESH_RATE, "ii", arr);
442 }
443
444 API int display_get_color_blind(void)
445 {
446         DBusError err;
447         DBusMessage *msg;
448         int ret, ret_val;
449
450         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
451                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
452                         METHOD_GET_COLOR_BLIND, NULL, NULL);
453         if (!msg)
454                 return -EBADMSG;
455
456         dbus_error_init(&err);
457
458         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
459         if (!ret) {
460                 _E("no message : [%s:%s]", err.name, err.message);
461                 dbus_error_free(&err);
462                 ret_val = -EBADMSG;
463         }
464
465         dbus_message_unref(msg);
466         return ret_val;
467 }
468
469 API int display_set_color_blind(int enable, struct blind_color_info *info)
470 {
471         DBusError err;
472         DBusMessage *msg;
473         char str_enable[32];
474         char str_red[32];
475         char str_grn[32];
476         char str_blu[32];
477         char *arr[4];
478         int ret, ret_val;
479
480         if (!info)
481                 return -EINVAL;
482
483         if (!!enable != enable)
484                 return -EINVAL;
485
486         snprintf(str_enable, sizeof(str_enable), "%d", enable);
487         arr[0] = str_enable;
488         snprintf(str_red, sizeof(str_red), "%llu", BLIND_COLOR(info->RrCr, info->RgCg, info->RbCb));
489         arr[1] = str_red;
490         snprintf(str_grn, sizeof(str_grn), "%llu", BLIND_COLOR(info->GrMr, info->GgMg, info->GbMb));
491         arr[2] = str_grn;
492         snprintf(str_blu, sizeof(str_blu), "%llu", BLIND_COLOR(info->BrYr, info->BgYg, info->BbYb));
493         arr[3] = str_blu;
494
495         _D("red : %s, grn : %s, blu : %s", str_red, str_grn, str_blu);
496
497         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
498                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
499                         METHOD_SET_COLOR_BLIND, "uttt", arr);
500         if (!msg)
501                 return -EBADMSG;
502
503         dbus_error_init(&err);
504
505         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
506         if (!ret) {
507                 _E("no message : [%s:%s]", err.name, err.message);
508                 dbus_error_free(&err);
509                 ret_val = -EBADMSG;
510         }
511
512         dbus_message_unref(msg);
513         return ret_val;
514 }
515
516 static inline char *get_lcd_str(unsigned int val)
517 {
518         switch (val) {
519         case LCD_NORMAL:
520                 return STR_LCD_ON;
521         case LCD_DIM:
522                 return STR_LCD_DIM;
523         case LCD_OFF:
524                 return STR_LCD_OFF;
525         case SUSPEND:
526                 return STR_SUSPEND;
527         default:
528                 return NULL;
529         }
530 }
531
532 static void display_change_cb(void *data, DBusMessage *msg, DBusError *unused)
533 {
534         DBusError err;
535         int ret, val;
536
537         if (!msg)
538                 return;
539
540         dbus_error_init(&err);
541         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
542         if (!ret) {
543                 _E("no message [%s:%s]", err.name, err.message);
544                 dbus_error_free(&err);
545                 return;
546         }
547         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE, val);
548 }
549
550 API int display_change_state(unsigned int s_bits)
551 {
552         char *p, *pa[1];
553         int ret;
554
555         p = get_lcd_str(s_bits);
556         if (!p)
557                 return -EINVAL;
558         pa[0] = p;
559
560         ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
561                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
562                         METHOD_CHANGE_STATE, "s", pa, display_change_cb, -1, NULL);
563         if (ret < 0)
564                 _E("no message : failed to change state");
565
566         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE, ret);
567
568         return ret;
569 }
570
571 static void display_lock_cb(void *data, DBusMessage *msg, DBusError *unused)
572 {
573         DBusError err;
574         int ret, val;
575
576         if (!msg)
577                 return;
578
579         dbus_error_init(&err);
580         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
581         if (!ret) {
582                 _E("no message [%s:%s]", err.name, err.message);
583                 dbus_error_free(&err);
584                 return;
585         }
586         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_LOCK_STATE, val);
587 }
588
589 API int display_lock_state(unsigned int s_bits, unsigned int flag,
590                       unsigned int timeout)
591 {
592         char *p, *pa[4];
593         char str_timeout[32];
594         int ret;
595
596         p = get_lcd_str(s_bits);
597         if (!p)
598                 return -EINVAL;
599         pa[0] = p;
600
601         if (flag & GOTO_STATE_NOW)
602                 /* if the flag is true, go to the locking state directly */
603                 p = STR_GOTOSTATENOW;
604         else
605                 p = STR_STAYCURSTATE;
606         pa[1] = p;
607
608         if (flag & HOLD_KEY_BLOCK)
609                 p = STR_HOLDKEYBLOCK;
610         else if (flag & STANDBY_MODE)
611                 p = STR_STANDBYMODE;
612         else
613                 p = STR_NULL;
614         pa[2] = p;
615
616         snprintf(str_timeout, sizeof(str_timeout), "%d", timeout);
617         pa[3] = str_timeout;
618
619         ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
620                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
621                         METHOD_LOCK_STATE, "sssi", pa, display_lock_cb, -1, NULL);
622         if (ret < 0)
623                 _E("no message : failed to lock state");
624
625         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_LOCK_STATE, ret);
626
627         return ret;
628 }
629
630 static void display_unlock_cb(void *data, DBusMessage *msg, DBusError *unused)
631 {
632         DBusError err;
633         int ret, val;
634
635         if (!msg)
636                 return;
637
638         dbus_error_init(&err);
639         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
640         if (!ret) {
641                 _E("no message [%s:%s]", err.name, err.message);
642                 dbus_error_free(&err);
643                 return;
644         }
645         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_UNLOCK_STATE, val);
646 }
647
648 API int display_unlock_state(unsigned int s_bits, unsigned int flag)
649 {
650         char *p, *pa[2];
651         int ret;
652
653         p = get_lcd_str(s_bits);
654         if (!p)
655                 return -EINVAL;
656         pa[0] = p;
657
658         switch (flag) {
659         case PM_SLEEP_MARGIN:
660                 p = STR_SLEEP_MARGIN;
661                 break;
662         case PM_RESET_TIMER:
663                 p = STR_RESET_TIMER;
664                 break;
665         case PM_KEEP_TIMER:
666                 p = STR_KEEP_TIMER;
667                 break;
668         default:
669                 return -EINVAL;
670         }
671         pa[1] = p;
672
673         ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
674                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
675                         METHOD_UNLOCK_STATE, "ss", pa, display_unlock_cb, -1, NULL);
676         if (ret < 0)
677                 _E("no message : failed to unlock state");
678
679         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_UNLOCK_STATE, ret);
680
681         return ret;
682 }
683
684 API int display_get_enhanced_touch(void)
685 {
686         return dbus_method_sync(DEVICED_BUS_NAME,
687                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
688                         METHOD_GET_ENHANCED_TOUCH, NULL, NULL);
689 }
690
691 API int display_set_enhanced_touch(int enable)
692 {
693         char *arr[1];
694         char str_enable[32];
695
696         snprintf(str_enable, sizeof(str_enable), "%d", enable);
697         arr[0] = str_enable;
698
699         return dbus_method_sync(DEVICED_BUS_NAME,
700                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
701                         METHOD_SET_ENHANCED_TOUCH, "i", arr);
702 }
703
704 API int display_get_hbm(void)
705 {
706         return dbus_method_sync(DEVICED_BUS_NAME,
707                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
708                         METHOD_GET_HBM, NULL, NULL);
709 }
710
711 API int display_set_hbm(int enable)
712 {
713         char *arr[1];
714         char str_enable[2];
715
716         if (enable != 0 && enable != 1)
717                 return -EINVAL;
718
719         snprintf(str_enable, sizeof(str_enable), "%d", enable);
720         arr[0] = str_enable;
721
722         return dbus_method_sync(DEVICED_BUS_NAME,
723                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
724                         METHOD_SET_HBM, "i", arr);
725 }
726
727 API int display_enable_hbm(int enable, int timeout)
728 {
729         char *arr[2];
730         char str_enable[2];
731         char str_timeout[32];
732
733         if (enable != 0 && enable != 1)
734                 return -EINVAL;
735
736         if (timeout < 0)
737                 return -EINVAL;
738
739         snprintf(str_enable, sizeof(str_enable), "%d", enable);
740         arr[0] = str_enable;
741
742         snprintf(str_timeout, sizeof(str_timeout), "%d", timeout);
743         arr[1] = str_timeout;
744
745         return dbus_method_sync(DEVICED_BUS_NAME,
746                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
747                         METHOD_SET_HBM_TIMEOUT, "ii", arr);
748 }
749