display: plugin: Add display_plugin_get_device_flags()
[platform/core/system/deviced.git] / src / display / display-plugin.h
1 /*
2  * deviced
3  *
4  * Copyright (c) 2023 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 #ifndef __DISPLAY_PLUGIN_H__
20 #define __DISPLAY_PLUGIN_H__
21
22 #include <unistd.h>
23 #include <sys/types.h>
24
25 #include "core.h"
26 #include "display-config.h"
27 #include "display-backlight.h"
28 #include "shared/devices.h"
29
30 /* FIXME: Currently because of display_plugin.auto_brightness_control(),
31  *        it is here. Please relocate it to proper place later. */
32 enum brightness_request_e {
33         BR_MIN = 0,
34         /* entering request */
35         BR_LBM_ON,
36         BR_HBM_ON,
37         BR_HOLD_BRIGHTNESS,
38         BR_LOWDIM_ON, /* low battery dim */
39
40         /* exiting request */
41         BR_LBM_OFF,
42         BR_HBM_OFF,
43         BR_RELEASE_BRIGHTNESS,
44         BR_LOWDIM_OFF, /* low battery dim off */
45
46         /* special */
47         BR_SET_BRIGHTNESS,
48
49         BR_MAX,
50 };
51
52 /* request for brightness that managed internally.
53  * BR_HOLD_BRIGHTNESS and BR_SET_BRIGHTNESS does not use this implicit brightness
54  * for request, but explicitly request for a brightness value */
55 #define BR_IMPLICIT             (-1)
56
57 struct display_plugin {
58         void *handle;
59         int (*pm_lock_internal) (pid_t pid, int s_bits, int flag, int timeout);
60         int (*pm_unlock_internal) (pid_t pid, int s_bits, int flag);
61         int (*pm_change_internal) (pid_t pid, int s_bits);
62         int (*update_pm_setting) (int key_idx, int val);
63         int (*get_lock_screen_state) (void);
64         bool system_wakeup_flag;
65         const char* (*device_flags_to_string) (enum device_flags flags);
66         int (*auto_brightness_control) (enum brightness_request_e request, int set_brightness);
67         /* FIXME: function names will be redefined */
68         void (*delete_state_cond) (void *data, enum state_t s_state);
69         void (*set_dim_state) (bool on);
70         int (*get_device_flags) (unsigned long *device_flags);
71
72         struct display_config *config;
73         struct display_backlight_ops *backlight;
74         struct state* display_states[S_END];
75 };
76 extern struct display_plugin g_display_plugin;
77
78 void* display_plugin_handle(void);
79 int display_plugin_pm_lock_internal(pid_t pid, int s_bits, int flags, int timeout);
80 int display_plugin_pm_unlock_internal(pid_t pid, int s_bits, int flags);
81 int display_plugin_pm_change_internal(pid_t pid, int s_bits);
82 int display_plugin_update_pm_setting(int key_idx, int val);
83 int display_plugin_get_lock_screen_state(void);
84 int display_plugin_get_system_wakeup_flag(bool *flag);
85 int display_plugin_set_system_wakeup_flag(bool flag);
86 const char* display_plugin_device_flags_to_string(enum device_flags flags);
87 int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness);
88 int display_plugin_set_dim_state(bool on);
89 int display_plugin_get_device_flags(unsigned long *device_flags);
90
91 int display_plugin_backlight_get_lcd_power(void);
92 int display_plugin_backlight_set_brightness(int brightness);
93 int display_plugin_backlight_get_brightness(int *brightness);
94 int display_plugin_backlight_transit_state(int state);
95 int display_plugin_backlight_transit_brightness(int start, int end, int step);
96
97 /* FIXME: function names will be redefined */
98 int display_plugin_state_do_default_trans(enum state_t state, int evt);
99 bool display_plugin_state_is_there_default_trans(enum state_t state);
100 int display_plugin_state_do_default_action(enum state_t state, int timeout);
101 int display_plugin_state_do_default_check(enum state_t state, int curr, int next);
102 int display_plugin_state_delete_state_cond(void *data, enum state_t s_state);
103 int display_plugin_state_get_name(enum state_t state, const char **state_name);
104 int display_plugin_state_set_timeout(enum state_t state, int state_timeout);
105 int display_plugin_state_get_timeout(enum state_t state, int *state_timeout);
106
107 /* FIXME: display config getter/setter is also temporary in this file */
108 int display_plugin_config_get_timeout_enable(bool *timeout_enable);
109
110 #endif //__DISPLAY_PLUGIN_H__