Initialize Tizen 2.3
[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         snprintf(str_enable, sizeof(str_enable), "%d", enable);
481         arr[0] = str_enable;
482         snprintf(str_red, sizeof(str_red), "%llu", BLIND_COLOR(info->RrCr, info->RgCg, info->RbCb));
483         arr[1] = str_red;
484         snprintf(str_grn, sizeof(str_grn), "%llu", BLIND_COLOR(info->GrMr, info->GgMg, info->GbMb));
485         arr[2] = str_grn;
486         snprintf(str_blu, sizeof(str_blu), "%llu", BLIND_COLOR(info->BrYr, info->BgYg, info->BbYb));
487         arr[3] = str_blu;
488
489         _D("red : %s, grn : %s, blu : %s", str_red, str_grn, str_blu);
490
491         msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME,
492                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
493                         METHOD_SET_COLOR_BLIND, "uttt", arr);
494         if (!msg)
495                 return -EBADMSG;
496
497         dbus_error_init(&err);
498
499         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &ret_val, DBUS_TYPE_INVALID);
500         if (!ret) {
501                 _E("no message : [%s:%s]", err.name, err.message);
502                 dbus_error_free(&err);
503                 ret_val = -EBADMSG;
504         }
505
506         dbus_message_unref(msg);
507         return ret_val;
508 }
509
510 static inline char *get_lcd_str(unsigned int val)
511 {
512         switch (val) {
513         case LCD_NORMAL:
514                 return STR_LCD_ON;
515         case LCD_DIM:
516                 return STR_LCD_DIM;
517         case LCD_OFF:
518                 return STR_LCD_OFF;
519         case SUSPEND:
520                 return STR_SUSPEND;
521         default:
522                 return NULL;
523         }
524 }
525
526 static void display_change_cb(void *data, DBusMessage *msg, DBusError *unused)
527 {
528         DBusError err;
529         int ret, val;
530
531         if (!msg)
532                 return;
533
534         dbus_error_init(&err);
535         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
536         if (!ret) {
537                 _E("no message [%s:%s]", err.name, err.message);
538                 dbus_error_free(&err);
539                 return;
540         }
541         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE, val);
542 }
543
544 API int display_change_state(unsigned int s_bits)
545 {
546         char *p, *pa[1];
547         int ret;
548
549         p = get_lcd_str(s_bits);
550         if (!p)
551                 return -EINVAL;
552         pa[0] = p;
553
554         ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
555                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
556                         METHOD_CHANGE_STATE, "s", pa, display_change_cb, -1, NULL);
557         if (ret < 0)
558                 _E("no message : failed to change state");
559
560         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_CHANGE_STATE, ret);
561
562         return ret;
563 }
564
565 static void display_lock_cb(void *data, DBusMessage *msg, DBusError *unused)
566 {
567         DBusError err;
568         int ret, val;
569
570         if (!msg)
571                 return;
572
573         dbus_error_init(&err);
574         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
575         if (!ret) {
576                 _E("no message [%s:%s]", err.name, err.message);
577                 dbus_error_free(&err);
578                 return;
579         }
580         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_LOCK_STATE, val);
581 }
582
583 API int display_lock_state(unsigned int s_bits, unsigned int flag,
584                       unsigned int timeout)
585 {
586         char *p, *pa[4];
587         char str_timeout[32];
588         int ret;
589
590         p = get_lcd_str(s_bits);
591         if (!p)
592                 return -EINVAL;
593         pa[0] = p;
594
595         if (flag & GOTO_STATE_NOW)
596                 /* if the flag is true, go to the locking state directly */
597                 p = STR_GOTOSTATENOW;
598         else
599                 p = STR_STAYCURSTATE;
600         pa[1] = p;
601
602         if (flag & HOLD_KEY_BLOCK)
603                 p = STR_HOLDKEYBLOCK;
604         else if (flag & STANDBY_MODE)
605                 p = STR_STANDBYMODE;
606         else
607                 p = STR_NULL;
608         pa[2] = p;
609
610         if (timeout < 0)
611                 return -EINVAL;
612
613         snprintf(str_timeout, sizeof(str_timeout), "%d", timeout);
614         pa[3] = str_timeout;
615
616         ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
617                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
618                         METHOD_LOCK_STATE, "sssi", pa, display_lock_cb, -1, NULL);
619         if (ret < 0)
620                 _E("no message : failed to lock state");
621
622         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_LOCK_STATE, ret);
623
624         return ret;
625 }
626
627 static void display_unlock_cb(void *data, DBusMessage *msg, DBusError *unused)
628 {
629         DBusError err;
630         int ret, val;
631
632         if (!msg)
633                 return;
634
635         dbus_error_init(&err);
636         ret = dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID);
637         if (!ret) {
638                 _E("no message [%s:%s]", err.name, err.message);
639                 dbus_error_free(&err);
640                 return;
641         }
642         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_UNLOCK_STATE, val);
643 }
644
645 API int display_unlock_state(unsigned int s_bits, unsigned int flag)
646 {
647         char *p, *pa[2];
648         int ret;
649
650         p = get_lcd_str(s_bits);
651         if (!p)
652                 return -EINVAL;
653         pa[0] = p;
654
655         switch (flag) {
656         case PM_SLEEP_MARGIN:
657                 p = STR_SLEEP_MARGIN;
658                 break;
659         case PM_RESET_TIMER:
660                 p = STR_RESET_TIMER;
661                 break;
662         case PM_KEEP_TIMER:
663                 p = STR_KEEP_TIMER;
664                 break;
665         default:
666                 return -EINVAL;
667         }
668         pa[1] = p;
669
670         ret = dbus_method_async_with_reply(DEVICED_BUS_NAME,
671                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
672                         METHOD_UNLOCK_STATE, "ss", pa, display_unlock_cb, -1, NULL);
673         if (ret < 0)
674                 _E("no message : failed to unlock state");
675
676         _D("%s-%s : %d", DEVICED_INTERFACE_DISPLAY, METHOD_UNLOCK_STATE, ret);
677
678         return ret;
679 }
680
681 API int display_get_enhanced_touch(void)
682 {
683         return dbus_method_sync(DEVICED_BUS_NAME,
684                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
685                         METHOD_GET_ENHANCED_TOUCH, NULL, NULL);
686 }
687
688 API int display_set_enhanced_touch(int enable)
689 {
690         char *arr[1];
691         char str_enable[32];
692
693         snprintf(str_enable, sizeof(str_enable), "%d", enable);
694         arr[0] = str_enable;
695
696         return dbus_method_sync(DEVICED_BUS_NAME,
697                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
698                         METHOD_SET_ENHANCED_TOUCH, "i", arr);
699 }
700
701 API int display_get_hbm(void)
702 {
703         return dbus_method_sync(DEVICED_BUS_NAME,
704                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
705                         METHOD_GET_HBM, NULL, NULL);
706 }
707
708 API int display_set_hbm(int enable)
709 {
710         char *arr[1];
711         char str_enable[2];
712
713         if (enable != 0 && enable != 1)
714                 return -EINVAL;
715
716         snprintf(str_enable, sizeof(str_enable), "%d", enable);
717         arr[0] = str_enable;
718
719         return dbus_method_sync(DEVICED_BUS_NAME,
720                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
721                         METHOD_SET_HBM, "i", arr);
722 }
723
724 API int display_enable_hbm(int enable, int timeout)
725 {
726         char *arr[2];
727         char str_enable[2];
728         char str_timeout[32];
729
730         if (enable != 0 && enable != 1)
731                 return -EINVAL;
732
733         if (timeout < 0)
734                 return -EINVAL;
735
736         snprintf(str_enable, sizeof(str_enable), "%d", enable);
737         arr[0] = str_enable;
738
739         snprintf(str_timeout, sizeof(str_timeout), "%d", timeout);
740         arr[1] = str_timeout;
741
742         return dbus_method_sync(DEVICED_BUS_NAME,
743                         DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
744                         METHOD_SET_HBM_TIMEOUT, "ii", arr);
745 }
746