Prohibit turning on display when display has been detached
[platform/core/system/deviced.git] / src / display / device-interface.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
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 /**
21  * @file        device-interface.h
22  * @brief       backlight, touch, power devices interface module header
23  */
24 #ifndef __DEVICE_INTERFACE_H__
25 #define __DEVICE_INTERFACE_H__
26
27 #include <stdbool.h>
28 #include <hw/display.h>
29 #include "core/devices.h"
30
31 #define FLAG_X_DPMS             0x2
32
33 #define DEFAULT_DISPLAY 0
34
35 #define PM_MAX_BRIGHTNESS       100
36 #define PM_MIN_BRIGHTNESS       1
37 #define PM_DEFAULT_BRIGHTNESS   80
38 #define PM_DIM_BRIGHTNESS       0
39
40 #define DISP_INDEX_SHIFT        16
41 #define DISP_CMD(prop, index)   ((index << DISP_INDEX_SHIFT) | prop)
42
43 #define DEFAULT_DISPLAY_COUNT           1
44 #define DEFAULT_DISPLAY_MAX_BRIGHTNESS  100
45 #define DEFAULT_DISPLAY_MAX_DIM_BRIGHTNESS  50
46
47 #define DPMS_SETTING_DONE       -1
48
49 /*
50  * Event type enumeration
51  */
52 enum {
53         EVENT_TIMEOUT = 0,      /*< time out event from timer */
54         EVENT_DEVICE = EVENT_TIMEOUT,   /*< wake up by devices except input devices */
55         EVENT_INPUT,            /*< input event from noti service */
56         EVENT_END,
57 };
58
59
60 /*
61  * Vital state enumeration
62  */
63 enum vital_state {
64         VITAL_SLEEP,    /* suspend state */
65         VITAL_WAKEUP,   /* resume state */
66         VITAL_DISPLAY_WAKEUP,
67         VITAL_EXIT,
68 };
69
70 int init_sysfs(unsigned int);
71 int exit_sysfs(void);
72 int display_service_load(void);
73 int display_service_free(void);
74 bool vital_mode(void);
75
76 struct _backlight_ops {
77         int (*off)(enum device_flags);
78         int (*dim)(void);
79         int (*on)(enum device_flags);
80         int (*update)(void);
81         int (*standby)(int);
82         int (*set_default_brt)(int level);
83         int (*get_default_brt)(void);
84         int (*get_lcd_power)(void);
85         int (*set_custom_status)(bool on);
86         bool (*get_custom_status)(void);
87         int (*save_custom_brightness)(void);
88         int (*custom_update)(void);
89         int (*set_force_brightness)(int level);
90         int (*set_brightness)(int val);
91         int (*get_brightness)(int *val);
92         void (*restore_brightness_func)(void);
93         int (*get_brightness_by_light_sensor)(float lmax, float lmin, float light, int *brt);
94         int (*get_image_effect)(enum display_image_effect *effect);
95         int (*set_image_effect)(enum display_image_effect effect);
96         int (*get_panel_mode)(enum display_panel_mode *mode);
97         int (*set_panel_mode)(enum display_panel_mode mode);
98         int (*get_frame_rate)(int *rate);
99         int (*set_frame_rate)(int rate);
100         int (*transit_state)(int state);
101         void (*transit_brt)(int start, int end, int step);
102         void (*blink)(int timeout);
103         void (*release_blink)(void);
104 };
105
106 struct _power_ops {
107         int (*suspend)(void);
108         int (*enable_autosleep)(void);
109         int (*power_lock)(void);
110         int (*power_unlock)(void);
111         int (*get_power_lock)(void);
112         int (*get_power_lock_support)(void);
113         int (*check_wakeup_src)(void);
114         int (*get_wakeup_count)(int *cnt);
115         int (*set_wakeup_count)(int cnt);
116 };
117
118 extern struct _backlight_ops backlight_ops;
119 extern struct _power_ops power_ops;
120
121 enum dpms_state {
122         DPMS_ON,       /* In use */
123         DPMS_STANDBY,  /* Blanked, low power */
124         DPMS_SUSPEND,  /* Blanked, lower power */
125         DPMS_OFF,      /* Shut off, awaiting activity */
126         DPMS_FORCE_OFF,/* Force Shut off */
127         DPMS_DETACH,   /* Display detached */
128 };
129
130 enum mainlock_state {
131         POWER_UNLOCK = 0,
132         POWER_LOCK,
133 };
134
135 struct display_device *display_dev_get(void);
136 bool display_dimstay_check(void);
137 void dpms_set_running_state(int val);
138 bool is_display_detached(void);
139
140 #endif
141