4 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include "display-misc.h"
21 #include "display-plugin.h"
22 #include "shared/log-macro.h"
24 struct display_plugin g_display_plugin;
26 void* display_plugin_handle(void)
28 return g_display_plugin.handle;
31 int display_plugin_pm_lock_internal(pid_t pid, int s_bits, int flags, int timeout)
33 if (g_display_plugin.pm_lock_internal)
34 return g_display_plugin.pm_lock_internal(pid, s_bits, flags, timeout);
39 int display_plugin_pm_unlock_internal(pid_t pid, int s_bits, int flags)
41 if (g_display_plugin.pm_unlock_internal)
42 return g_display_plugin.pm_unlock_internal(pid, s_bits, flags);
47 int display_plugin_pm_change_internal(pid_t pid, int s_bits)
49 if (g_display_plugin.pm_change_internal)
50 return g_display_plugin.pm_change_internal(pid, s_bits);
55 int display_plugin_update_pm_setting(int key_idx, int val)
57 if (g_display_plugin.update_pm_setting)
58 return g_display_plugin.update_pm_setting(key_idx, val);
63 /* FIXME: return 0 can be value of get_lock_screen_state, it is hard to distinguish error or not */
64 int display_plugin_get_lock_screen_state(void)
66 if (g_display_plugin.get_lock_screen_state)
67 return g_display_plugin.get_lock_screen_state();
72 int display_plugin_get_system_wakeup_flag(bool *flag)
74 *flag = g_display_plugin.system_wakeup_flag;
79 int display_plugin_set_system_wakeup_flag(bool flag)
81 g_display_plugin.system_wakeup_flag = flag;
86 const char* display_plugin_device_flags_to_string(enum device_flags flags)
88 if (g_display_plugin.device_flags_to_string)
89 return g_display_plugin.device_flags_to_string(flags);
94 int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness)
96 if (g_display_plugin.auto_brightness_control)
97 return g_display_plugin.auto_brightness_control(request, set_brightness);
102 int display_plugin_backlight_get_lcd_power(void)
104 if (g_display_plugin.backlight && g_display_plugin.backlight->get_lcd_power)
105 return g_display_plugin.backlight->get_lcd_power();
110 int display_plugin_backlight_set_brightness(int brightness)
112 if (g_display_plugin.backlight && g_display_plugin.backlight->set_brightness)
113 return g_display_plugin.backlight->set_brightness(brightness);
118 int display_plugin_backlight_get_brightness(int *brightness)
120 if (g_display_plugin.backlight && g_display_plugin.backlight->get_brightness)
121 return g_display_plugin.backlight->get_brightness(brightness);
126 int display_plugin_backlight_transit_state(int state)
128 if (g_display_plugin.backlight && g_display_plugin.backlight->transit_state)
129 return g_display_plugin.backlight->transit_state(state);
134 int display_plugin_backlight_transit_brightness(int start, int end, int step)
136 if (g_display_plugin.backlight && g_display_plugin.backlight->transit_brt) {
137 g_display_plugin.backlight->transit_brt(start, end, step);
144 /* FIXME: Below functions are temorary to separtate display state transition functions */
145 int display_plugin_state_do_default_trans(enum state_t state, int evt)
147 if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->trans)
148 return g_display_plugin.display_states[state]->trans(evt);
153 bool display_plugin_state_is_there_default_trans(enum state_t state)
155 if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->trans)
161 int display_plugin_state_do_default_action(enum state_t state, int timeout)
163 if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->action)
164 return g_display_plugin.display_states[state]->action(timeout);
169 /* FIXME: default_action/default_trans naming should be changed after state transition functions are relocated */
170 bool display_plugin_state_is_there_default_action(enum state_t state)
172 if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->action)
178 int display_plugin_state_get_name(enum state_t state, const char **state_name)
183 if (g_display_plugin.display_states[state] && g_display_plugin.display_states[state]->name) {
184 *state_name = g_display_plugin.display_states[state]->name;
192 int display_plugin_state_set_timeout(enum state_t state, int state_timeout)
194 if (g_display_plugin.display_states[state]) {
195 g_display_plugin.display_states[state]->timeout = state_timeout;
202 int display_plugin_state_get_timeout(enum state_t state, int* state_timeout)
207 if (g_display_plugin.display_states[state]) {
208 *state_timeout = g_display_plugin.display_states[state]->timeout;
215 int display_plugin_state_get_state_by_state_index(int state_index, enum state_t *state)
220 if (g_display_plugin.display_states[state_index]) {
221 *state = g_display_plugin.display_states[state_index]->state;
228 int display_plugin_config_get_timeout_enable(bool *timeout_enable)
233 if (g_display_plugin.config) {
234 *timeout_enable = g_display_plugin.config->timeout_enable;
241 int display_plugin_config_get_lcdoff_timeout(int *lcdoff_timeout)
246 if (g_display_plugin.config) {
247 *lcdoff_timeout = g_display_plugin.config->lcdoff_timeout;
254 int display_plugin_config_get_lcd_always_on(int *lcd_always_on)
259 if (g_display_plugin.config) {
260 *lcd_always_on = g_display_plugin.config->lcd_always_on;
267 int display_plugin_config_get_dimming(int *dimming)
272 if (g_display_plugin.config) {
273 *dimming = g_display_plugin.config->dimming;
280 int display_plugin_set_dim_state(bool on)
282 if (g_display_plugin.set_dim_state) {
283 g_display_plugin.set_dim_state(on);
290 int display_plugin_get_device_flags(unsigned long *device_flags)
295 if (g_display_plugin.get_device_flags)
296 return g_display_plugin.get_device_flags(device_flags);
298 *device_flags = NORMAL_MODE;
299 bool lcd_paneloff_mode = false;
300 bool stay_touchscreen_off = false;
301 display_panel_get_lcd_paneloff_mode(&lcd_paneloff_mode);
302 display_misc_get_stay_touchscreen_off(&stay_touchscreen_off);
304 if (lcd_paneloff_mode)
305 *device_flags |= LCD_PANEL_OFF_MODE;
307 if (stay_touchscreen_off)
308 *device_flags |= TOUCH_SCREEN_OFF_MODE;