From b73d3ae8ca548b59ee711ae4a6e793dafc744428 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Tue, 28 Sep 2021 18:17:20 +0900 Subject: [PATCH] display: remove pm_callback function pointer Instead, invoke poll_callback() function, which is identical to the pm_callback function pointer. Change-Id: Ic7a4bc2ea5a5729a39b6333d572621303a00fc95 Signed-off-by: Youngjae Cho --- plugins/iot-headed/display/core.c | 3 +-- plugins/iot-headed/display/key-filter.c | 2 +- plugins/mobile/display/core.c | 3 +-- plugins/mobile/display/key-filter.c | 5 ++--- plugins/tv/display/core.c | 3 +-- plugins/tv/display/key-filter.c | 2 +- plugins/wearable/display/core.c | 3 +-- plugins/wearable/display/key-filter.c | 2 +- src/display/core.h | 8 ++++++++ src/display/display-input.c | 7 +------ src/display/poll.c | 15 +++------------ src/display/poll.h | 9 --------- 12 files changed, 21 insertions(+), 41 deletions(-) diff --git a/plugins/iot-headed/display/core.c b/plugins/iot-headed/display/core.c index 45e0f64..c4e6f18 100644 --- a/plugins/iot-headed/display/core.c +++ b/plugins/iot-headed/display/core.c @@ -1609,7 +1609,7 @@ static void default_saving_mode(int onoff) backlight_ops->update(); } -static int poll_callback(int condition, PMMsg *data) +int poll_callback(int condition, PMMsg *data) { static time_t last_t; time_t now; @@ -2129,7 +2129,6 @@ static void display_init(void *data) break; case INIT_POLL: _I("input init"); - pm_callback = poll_callback; ret = input_init_handler(); pm_lock_detector_init(); diff --git a/plugins/iot-headed/display/key-filter.c b/plugins/iot-headed/display/key-filter.c index 470b513..ccfb22f 100644 --- a/plugins/iot-headed/display/key-filter.c +++ b/plugins/iot-headed/display/key-filter.c @@ -139,7 +139,7 @@ static void longkey_pressed(void) /* change state - LCD on */ if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); - (*pm_callback)(INPUT_POLL_EVENT, NULL); + poll_callback(INPUT_POLL_EVENT, NULL); } if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) { diff --git a/plugins/mobile/display/core.c b/plugins/mobile/display/core.c index fde1087..62b1a9a 100644 --- a/plugins/mobile/display/core.c +++ b/plugins/mobile/display/core.c @@ -1619,7 +1619,7 @@ static void default_saving_mode(int onoff) backlight_ops->update(); } -static int poll_callback(int condition, PMMsg *data) +int poll_callback(int condition, PMMsg *data) { static time_t last_t; time_t now; @@ -2135,7 +2135,6 @@ static void display_init(void *data) break; case INIT_POLL: _I("input init"); - pm_callback = poll_callback; ret = input_init_handler(); pm_lock_detector_init(); diff --git a/plugins/mobile/display/key-filter.c b/plugins/mobile/display/key-filter.c index 17bca2c..2054adb 100644 --- a/plugins/mobile/display/key-filter.c +++ b/plugins/mobile/display/key-filter.c @@ -130,7 +130,7 @@ static void longkey_pressed(void) /* change state - LCD on */ if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); - (*pm_callback)(INPUT_POLL_EVENT, NULL); + poll_callback(INPUT_POLL_EVENT, NULL); } if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) { @@ -425,8 +425,7 @@ static gboolean display_on_cb(void *data) broadcast_lcdon_by_powerkey(); lcd_on_direct(LCD_ON_BY_POWER_KEY); - if (pm_callback) - (*pm_callback) (INPUT_POLL_EVENT, NULL); + poll_callback(INPUT_POLL_EVENT, NULL); } return G_SOURCE_REMOVE; diff --git a/plugins/tv/display/core.c b/plugins/tv/display/core.c index 8120d15..21af9f5 100644 --- a/plugins/tv/display/core.c +++ b/plugins/tv/display/core.c @@ -1609,7 +1609,7 @@ static void default_saving_mode(int onoff) backlight_ops->update(); } -static int poll_callback(int condition, PMMsg *data) +int poll_callback(int condition, PMMsg *data) { static time_t last_t; time_t now; @@ -2126,7 +2126,6 @@ static void display_init(void *data) break; case INIT_POLL: _I("input init"); - pm_callback = poll_callback; ret = input_init_handler(); pm_lock_detector_init(); diff --git a/plugins/tv/display/key-filter.c b/plugins/tv/display/key-filter.c index b0667ec..33214b1 100644 --- a/plugins/tv/display/key-filter.c +++ b/plugins/tv/display/key-filter.c @@ -139,7 +139,7 @@ static void longkey_pressed(void) /* change state - LCD on */ if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); - (*pm_callback)(INPUT_POLL_EVENT, NULL); + poll_callback(INPUT_POLL_EVENT, NULL); } if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) { diff --git a/plugins/wearable/display/core.c b/plugins/wearable/display/core.c index 1326e6c..8d27e91 100644 --- a/plugins/wearable/display/core.c +++ b/plugins/wearable/display/core.c @@ -1885,7 +1885,7 @@ static void default_saving_mode(int onoff) } } -static int poll_callback(int condition, PMMsg *data) +int poll_callback(int condition, PMMsg *data) { static time_t last_t; time_t now; @@ -2456,7 +2456,6 @@ static void display_init(void *data) break; case INIT_POLL: _I("input init"); - pm_callback = poll_callback; ret = input_init_handler(); pm_lock_detector_init(); diff --git a/plugins/wearable/display/key-filter.c b/plugins/wearable/display/key-filter.c index cc9a56b..5b1cf9d 100644 --- a/plugins/wearable/display/key-filter.c +++ b/plugins/wearable/display/key-filter.c @@ -129,7 +129,7 @@ static void longkey_pressed(void) /* change state - LCD on */ if (disp_plgn->pm_change_internal) disp_plgn->pm_change_internal(INTERNAL_LOCK_POWERKEY, LCD_NORMAL); - (*pm_callback)(INPUT_POLL_EVENT, NULL); + poll_callback(INPUT_POLL_EVENT, NULL); } if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) { diff --git a/src/display/core.h b/src/display/core.h index 43d71f0..e001f65 100644 --- a/src/display/core.h +++ b/src/display/core.h @@ -173,6 +173,14 @@ struct display_keyfilter_ops { extern const struct display_keyfilter_ops *keyfilter_ops; extern GList *lcdon_ops; +typedef struct { + pid_t pid; + unsigned int cond; + unsigned int timeout; + unsigned int timeout2; +} PMMsg; +extern int poll_callback(int condition, PMMsg *data); + /* If the bit in a condition variable is set, * we cannot transit the state until clear this bit. */ int check_processes(enum state_t prohibit_state); diff --git a/src/display/display-input.c b/src/display/display-input.c index a43db2d..9b86aff 100644 --- a/src/display/display-input.c +++ b/src/display/display-input.c @@ -30,8 +30,6 @@ #define SEAT_NAME "seat0" -int (*pm_callback) (int, PMMsg *); - static void process_event(struct libinput_event *ev) { static const struct device_ops *display_device_ops; @@ -46,9 +44,6 @@ static void process_event(struct libinput_event *ev) return; } - if (!pm_callback) - return; - if (!display_device_ops) { display_device_ops = find_device("display"); if (!display_device_ops) @@ -107,7 +102,7 @@ static void process_event(struct libinput_event *ev) return; /* lcd on or update lcd timeout */ - (*pm_callback) (INPUT_POLL_EVENT, NULL); + poll_callback(INPUT_POLL_EVENT, NULL); } gboolean display_input_init(gpointer data) diff --git a/src/display/poll.c b/src/display/poll.c index 0e3ab28..600c2ef 100644 --- a/src/display/poll.c +++ b/src/display/poll.c @@ -84,9 +84,6 @@ static int __pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout) { int cond; - if (!pm_callback) - return -1; - cond = get_state(s_bits); if (cond < 0) return cond; @@ -107,7 +104,7 @@ static int __pm_lock_internal(pid_t pid, int s_bits, int flag, int timeout) recv_data.cond = cond; recv_data.timeout = timeout; - (*pm_callback)(PM_CONTROL_EVENT, &recv_data); + poll_callback(PM_CONTROL_EVENT, &recv_data); return 0; } @@ -116,9 +113,6 @@ static int __pm_unlock_internal(pid_t pid, int s_bits, int flag) { int cond; - if (!pm_callback) - return -1; - cond = get_state(s_bits); if (cond < 0) return cond; @@ -138,7 +132,7 @@ static int __pm_unlock_internal(pid_t pid, int s_bits, int flag) recv_data.cond = cond; recv_data.timeout = 0; - (*pm_callback)(PM_CONTROL_EVENT, &recv_data); + poll_callback(PM_CONTROL_EVENT, &recv_data); return 0; } @@ -148,9 +142,6 @@ static int __pm_change_internal(pid_t pid, int s_bits) int cond, ret; const int display_on = LCD_NORMAL | LCD_DIM; - if (!pm_callback) - return -1; - cond = get_state(s_bits); if (cond < 0) return cond; @@ -170,7 +161,7 @@ static int __pm_change_internal(pid_t pid, int s_bits) recv_data.cond = cond; recv_data.timeout = 0; - (*pm_callback)(PM_CONTROL_EVENT, &recv_data); + poll_callback(PM_CONTROL_EVENT, &recv_data); return 0; } diff --git a/src/display/poll.h b/src/display/poll.h index 83bba86..096316d 100644 --- a/src/display/poll.h +++ b/src/display/poll.h @@ -143,15 +143,6 @@ enum cond_flags_e { #define RESET_TIMER_STR "resettimer" #define KEEP_TIMER_STR "keeptimer" -typedef struct { - pid_t pid; - unsigned int cond; - unsigned int timeout; - unsigned int timeout2; -} PMMsg; - -extern int (*pm_callback) (int, PMMsg *); - gboolean display_input_init(gpointer data); int display_input_exit(void); -- 2.7.4