display: Move plugin struct display_plugin to core 24/290324/4
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 23 Mar 2023 00:54:16 +0000 (09:54 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 27 Mar 2023 04:51:06 +0000 (13:51 +0900)
The struct display_plugin has been relocated:
 - src/display/plugin-common/display-ops.h
   => src/display/display-plugin.h

Added wrapper for each member variable/function of the structure.
Those wrapper access/invoke matching plugin variable/function if exist.
 - display_plugin_handle()
 - display_plugin_pm_lock_internal()
 - display_plugin_pm_unlock_internal()
 - display_plugin_pm_change_internal()
 - display_plugin_update_pm_setting()
 - display_plugin_get_lock_screen_state()
 - display_plugin_get_system_wakeup_flag()
 - display_plugin_set_system_wakeup_flag()
 - display_plugin_device_flags_to_string()
 - display_plugin_auto_brightness_control()

The structure's member would grow as more plugin code will move to
the display core. Later, this struct display_plugin and wrapper can
be replaced by plugin-api-deviced.

Change-Id: I2ebc6b77b647764cbc1d4ceb55d17fdc2fee6af1
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
24 files changed:
plugins/iot-headed/display/core.c
plugins/mobile/display/core.c
plugins/tv/display/core.c
plugins/wearable/display/core.c
src/battery/battery-time.c
src/battery/lowbat-handler.c
src/battery/power-supply.c
src/display/display-plugin.c [new file with mode: 0644]
src/display/display-plugin.h [new file with mode: 0644]
src/display/display.c
src/display/plugin-common/display-ops.h
src/display/plugin-common/poll.c
src/display/plugin-common/poll.h
src/extcon/cradle.c
src/extcon/earjack.c
src/led/touch-key.c
src/shared/apps.c
src/shared/plugin.c
src/time/time-handler.c
src/touchscreen/touchscreen.c
src/usb-gadget/usb-gadget.c
src/usb-host/usb-host.c
tests/deviced-common-private-test/CMakeLists.txt
tests/deviced-common-private-test/test-mock.c

index a280885..8c68386 100644 (file)
@@ -46,6 +46,7 @@
 #include "ambient-mode.h"
 #include "util.h"
 #include "core.h"
+#include "poll.h"
 #include "lock-detector.h"
 #include "display-ops.h"
 #include "shared/devices.h"
@@ -60,6 +61,7 @@
 #include "power/power-suspend.h"
 #include "power/power-boot.h"
 #include "power/power-doze.h"
+#include "display-plugin.h"
 #include "display-dpms.h"
 #include "display-signal.h"
 #include "display-lock.h"
@@ -87,7 +89,6 @@
 #define PALM_STR               "palm"
 #define UNKNOWN_STR            "unknown"
 
-extern void init_pm_internal();
 extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
@@ -1936,7 +1937,7 @@ static int display_probe(void *data)
                return ret;
 
        /* display_plugin instance initialization */
-       init_pm_internal();
+       init_pm_internal(data);
        disp_plgn->device_flags_to_string = __device_flags_to_string;
 
        if (battery_plgn->handle) {
index 0949e9b..90a7c9b 100644 (file)
@@ -45,6 +45,7 @@
 #include "ambient-mode.h"
 #include "util.h"
 #include "core.h"
+#include "poll.h"
 #include "lock-detector.h"
 #include "display-ops.h"
 #include "shared/devices.h"
@@ -59,6 +60,7 @@
 #include "power/power-suspend.h"
 #include "power/power-boot.h"
 #include "power/power-doze.h"
+#include "display-plugin.h"
 #include "display-dpms.h"
 #include "proximity.h"
 #include "display-info.h"
@@ -88,7 +90,6 @@
 #define PALM_STR               "palm"
 #define UNKNOWN_STR            "unknown"
 
-extern void init_pm_internal();
 extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
@@ -1942,7 +1943,7 @@ static int display_probe(void *data)
                return ret;
 
        /* display_plugin instance initialization */
-       init_pm_internal();
+       init_pm_internal(data);
        disp_plgn->device_flags_to_string = __device_flags_to_string;
 
        if (battery_plgn->handle) {
index c4a34d3..0299f83 100644 (file)
@@ -45,6 +45,7 @@
 #include "ambient-mode.h"
 #include "util.h"
 #include "core.h"
+#include "poll.h"
 #include "lock-detector.h"
 #include "display-ops.h"
 #include "shared/devices.h"
@@ -59,6 +60,7 @@
 #include "power/power-suspend.h"
 #include "power/power-boot.h"
 #include "power/power-doze.h"
+#include "display-plugin.h"
 #include "display-dpms.h"
 #include "display-signal.h"
 #include "display-lock.h"
@@ -86,7 +88,6 @@
 #define PALM_STR               "palm"
 #define UNKNOWN_STR            "unknown"
 
-extern void init_pm_internal();
 extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
@@ -1933,7 +1934,7 @@ static int display_probe(void *data)
                return ret;
 
        /* display_plugin instance initialization */
-       init_pm_internal();
+       init_pm_internal(data);
        disp_plgn->device_flags_to_string = __device_flags_to_string;
 
        if (battery_plgn->handle) {
index cf41068..b692b00 100644 (file)
@@ -46,6 +46,7 @@
 #include "ambient-mode.h"
 #include "util.h"
 #include "core.h"
+#include "poll.h"
 #include "lock-detector.h"
 #include "display-ops.h"
 #include "shared/devices.h"
@@ -60,6 +61,7 @@
 #include "power/power-suspend.h"
 #include "power/power-boot.h"
 #include "power/power-doze.h"
+#include "display-plugin.h"
 #include "display-dpms.h"
 #include "display-info.h"
 #include "battery-monitor.h"
 #define DISPLAY_DETACH_STR  "display_detach"
 #define UNKNOWN_STR         "unknown"
 
-extern void init_pm_internal();
 extern void init_save_userlock(void);
 
 static struct display_plugin *disp_plgn;
@@ -2221,7 +2222,7 @@ static int display_probe(void *data)
                return ret;
 
        /* display_plugin instance initialization */
-       init_pm_internal();
+       init_pm_internal(data);
        disp_plgn->device_flags_to_string = __device_flags_to_string;
 
        if (battery_plgn->handle) {
index 72ff11e..54c8c10 100644 (file)
@@ -28,6 +28,7 @@
 #include "shared/devices.h"
 #include "core/log.h"
 #include "display-ops.h"
+#include "display-plugin.h"
 #include "power-supply.h"
 #include "shared/plugin.h"
 
@@ -61,8 +62,6 @@ enum state_a {
        A_END = 2
 };
 
-static struct display_plugin *disp_plgn;
-
 static guint timeout_id;
 
 static struct Batt_node *batt_head[B_END];
@@ -262,6 +261,7 @@ static int battinfo_calculation(void)
        int capacity = 0;
        int estimated_time = 0;
        int tmp = 0;
+       bool system_wakeup_flag;
        struct battery_status *battery;
 
        battery = get_var_battery_status();
@@ -305,9 +305,10 @@ static int battinfo_calculation(void)
                update_time(A_TIMETOFULL, estimated_time);
        } else {
                del_all_batt_node(B_CHARGING);
-               if (disp_plgn->system_wakeup_flag == true) {
+               display_plugin_get_system_wakeup_flag(&system_wakeup_flag);
+               if (system_wakeup_flag == true) {
                        del_all_batt_node(B_UNCHARGING);
-                       disp_plgn->system_wakeup_flag = false;
+                       display_plugin_set_system_wakeup_flag(false);
                }
                if (batt_head[B_UNCHARGING] == NULL) {
                        add_batt_node(B_UNCHARGING, clock, capacity);
@@ -437,10 +438,3 @@ static const struct device_ops battery_time_device_ops = {
 };
 
 DEVICE_OPS_REGISTER(&battery_time_device_ops)
-
-static void __CONSTRUCTOR__ initialize(void)
-{
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
-}
index 93f4ec8..d4a7b70 100644 (file)
@@ -42,6 +42,7 @@
 #include "setting.h"
 #include "poll.h"
 #include "display-ops.h"
+#include "display-plugin.h"
 #include "power/power.h"
 #include "power/power-off.h"
 #include "power-supply.h"
@@ -66,7 +67,6 @@ struct lowbat_process_entry {
        int (*func) (void *data);
 };
 
-static struct display_plugin *disp_plgn;
 static struct battery_plugin *battery_plgn;
 
 static struct battery_status *battery;
@@ -253,11 +253,9 @@ direct_launch:
                if (lowbat_popup_option == BAT_OPT_ERR_TEMP_LOW ||
                    lowbat_popup_option == BAT_OPT_ERR_TEMP_HIGH ||
                    lowbat_popup_option == BAT_OPT_ERR_CF_OPEN) {
-                       if (disp_plgn->pm_change_internal)
-                               disp_plgn->pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_DIM);
+                       display_plugin_pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_DIM);
                } else {
-                       if (disp_plgn->pm_change_internal)
-                               disp_plgn->pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_NORMAL);
+                       display_plugin_pm_change_internal(INTERNAL_LOCK_LOWBAT, LCD_NORMAL);
                }
                if (lowbat_popup_option == BAT_OPT_ERR_TEMP_LOW ||
                    lowbat_popup_option == BAT_OPT_ERR_TEMP_HIGH ||
@@ -303,15 +301,15 @@ int battery_charge_err_cf_act(void *data)
 
 int battery_charge_err_low_act(void *data)
 {
-       if (disp_plgn->pm_lock_internal)
-               disp_plgn->pm_lock_internal(INTERNAL_LOCK_OVERCOOL, LCD_OFF, STAY_CUR_STATE, 60000);
+       display_plugin_pm_lock_internal(INTERNAL_LOCK_OVERCOOL, LCD_OFF, STAY_CUR_STATE, 60000);
+
        return lowbat_popup(BAT_OPT_ERR_TEMP_LOW);
 }
 
 int battery_charge_err_high_act(void *data)
 {
-       if (disp_plgn->pm_lock_internal)
-               disp_plgn->pm_lock_internal(INTERNAL_LOCK_OVERHEAT, LCD_OFF, STAY_CUR_STATE, 60000);
+       display_plugin_pm_lock_internal(INTERNAL_LOCK_OVERHEAT, LCD_OFF, STAY_CUR_STATE, 60000);
+
        return lowbat_popup(BAT_OPT_ERR_TEMP_HIGH);
 }
 
@@ -535,8 +533,7 @@ static int lowbat_process(int bat_percent, void *ad)
 
        if (status != -1) {
                result = status;
-               if (disp_plgn->update_pm_setting)
-                       disp_plgn->update_pm_setting(SETTING_LOW_BATT, status);
+               display_plugin_update_pm_setting(SETTING_LOW_BATT, status);
        } else
                result = vconf_state;
 
@@ -764,10 +761,6 @@ DEVICE_OPS_REGISTER(&lowbat_device_ops)
 
 static void __CONSTRUCTOR__ initialize(void)
 {
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
-
        battery_plgn = get_var_battery_plugin();
        if (!battery_plgn)
                _E("Failed to get battery plugin variable.");
index 82e1ad8..a91bae0 100644 (file)
@@ -83,7 +83,6 @@
 #define BATTERY_CHECK_TIMER_INTERVAL 500  /* 0.5 second */
 #define LCD_DIM_TIME_IN_BATTERY_HEALTH 10000   /* ms */
 
-static struct display_plugin *disp_plgn;
 static struct battery_plugin *battery_plgn;
 
 static struct battery_status battery;
@@ -372,8 +371,7 @@ static void noti_batt_full(void)
 static void check_power_supply(int state)
 {
        pm_check_and_change(state);
-       if (disp_plgn->update_pm_setting)
-               disp_plgn->update_pm_setting(SETTING_CHARGING, state);
+       display_plugin_update_pm_setting(SETTING_CHARGING, state);
 }
 
 static void charger_state_send_system_event(int state)
@@ -409,13 +407,11 @@ static void update_present(enum battery_noti_status status)
        if (status == DEVICE_NOTI_ON) {
                battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM);
                device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&battery.present);
-               if (disp_plgn->pm_lock_internal)
-                       disp_plgn->pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
+               display_plugin_pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, 0);
        } else {
                battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
                device_notify(DEVICE_NOTIFIER_BATTERY_PRESENT, (void *)&battery.present);
-               if (disp_plgn->pm_unlock_internal)
-                       disp_plgn->pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
+               display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
        }
        if (battery_plgn->changed_battery_cf)
                battery_plgn->changed_battery_cf(battery.present);
@@ -431,10 +427,8 @@ static void launch_health_popup(void)
        device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health);
        battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
        battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_DIM);
-       if (disp_plgn->pm_unlock_internal)
-               disp_plgn->pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN);
-       if (disp_plgn->pm_lock_internal)
-               disp_plgn->pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH);
+       display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN);
+       display_plugin_pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH);
        if (battery.health == HEALTH_LOW)
                battery_charge_err_low_act(NULL);
        else if (battery.health == HEALTH_HIGH)
@@ -465,10 +459,8 @@ static void update_health(enum battery_noti_status status)
        } else {
                battery_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
                device_notify(DEVICE_NOTIFIER_BATTERY_HEALTH, (void *)&battery.health);
-               if (disp_plgn->pm_unlock_internal) {
-                       disp_plgn->pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
-                       disp_plgn->pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN);
-               }
+               display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, PM_SLEEP_MARGIN);
+               display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN);
                health_status_broadcast();
                if (abnormal_health_popup_timer) {
                        CRITICAL_LOG("Battery health returned to normal. Stop abnormal popup.");
@@ -490,10 +482,8 @@ void relaunch_health_popup(void)
        if (abnormal_health_popup_timer)
                g_source_remove(abnormal_health_popup_timer);
 
-       if (disp_plgn->pm_unlock_internal)
-               disp_plgn->pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN);
-       if (disp_plgn->pm_lock_internal)
-               disp_plgn->pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH);
+       display_plugin_pm_unlock_internal(INTERNAL_LOCK_POPUP, LCD_OFF, PM_SLEEP_MARGIN);
+       display_plugin_pm_lock_internal(INTERNAL_LOCK_POPUP, LCD_DIM, STAY_CUR_STATE, LCD_DIM_TIME_IN_BATTERY_HEALTH);
        if (battery.health == HEALTH_LOW)
                battery_charge_err_low_act(NULL);
        else if (battery.health == HEALTH_HIGH)
@@ -624,8 +614,7 @@ static void process_power_supply(void *data)
        int ret_lock = -1;
        int ret_val;
 
-       if (disp_plgn->pm_lock_internal)
-               ret_lock = disp_plgn->pm_lock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, STAY_CUR_STATE, 0);
+       ret_lock = display_plugin_pm_lock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, STAY_CUR_STATE, 0);
 
        if (old_battery.charge_now != battery.charge_now || battery.charge_now == CHARGER_ABNORMAL) {
                ret_val = vconf_set_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, battery.charge_now);
@@ -734,10 +723,8 @@ static void process_power_supply(void *data)
                old_battery.charge_now = battery.charge_now;
        }
 
-       if (disp_plgn->pm_unlock_internal) {
-               if (ret_lock == 0) {
-                       disp_plgn->pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN);
-               }
+       if (ret_lock == 0) {
+               display_plugin_pm_unlock_internal(INTERNAL_LOCK_BATTERY, LCD_OFF, PM_SLEEP_MARGIN);
        }
 }
 
@@ -1312,8 +1299,7 @@ int battery_pm_change_internal(int pid, int s_bits)
        if (battery_do_not_disturb())
                return 0;
 
-       if (disp_plgn->pm_change_internal)
-               disp_plgn->pm_change_internal(pid, s_bits);
+       display_plugin_pm_change_internal(pid, s_bits);
 
        return 0;
 }
@@ -1470,10 +1456,6 @@ DEVICE_OPS_REGISTER(&power_supply_ops)
 
 static void __CONSTRUCTOR__ initialize(void)
 {
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
-
        battery_plgn = get_var_battery_plugin();
        if (!battery_plgn)
                _E("Failed to get battery plugin variable.");
diff --git a/src/display/display-plugin.c b/src/display/display-plugin.c
new file mode 100644 (file)
index 0000000..06055d1
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * deviced
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "display-plugin.h"
+
+struct display_plugin g_display_plugin;
+
+void* display_plugin_handle(void)
+{
+       return g_display_plugin.handle;
+}
+
+int display_plugin_pm_lock_internal(pid_t pid, int s_bits, int flags, int timeout)
+{
+       if (g_display_plugin.pm_lock_internal)
+               return g_display_plugin.pm_lock_internal(pid, s_bits, flags, timeout);
+
+       return 0;
+}
+
+int display_plugin_pm_unlock_internal(pid_t pid, int s_bits, int flags)
+{
+       if (g_display_plugin.pm_unlock_internal)
+               return g_display_plugin.pm_unlock_internal(pid, s_bits, flags);
+
+       return 0;
+}
+
+int display_plugin_pm_change_internal(pid_t pid, int s_bits)
+{
+       if (g_display_plugin.pm_change_internal)
+               return g_display_plugin.pm_change_internal(pid, s_bits);
+
+       return 0;
+}
+
+int display_plugin_update_pm_setting(int key_idx, int val)
+{
+       if (g_display_plugin.update_pm_setting)
+               return g_display_plugin.update_pm_setting(key_idx, val);
+
+       return 0;
+}
+
+int display_plugin_get_lock_screen_state(void)
+{
+       if (g_display_plugin.get_lock_screen_state)
+               return g_display_plugin.get_lock_screen_state();
+
+       return 0;
+}
+
+int display_plugin_get_system_wakeup_flag(bool *flag)
+{
+       *flag = g_display_plugin.system_wakeup_flag;
+
+       return 0;
+}
+
+int display_plugin_set_system_wakeup_flag(bool flag)
+{
+       g_display_plugin.system_wakeup_flag = flag;
+
+       return 0;
+}
+
+const char* display_plugin_device_flags_to_string(enum device_flags flags)
+{
+       if (g_display_plugin.device_flags_to_string)
+               return g_display_plugin.device_flags_to_string(flags);
+
+       return NULL;
+}
+
+int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness)
+{
+       if (g_display_plugin.auto_brightness_control)
+               return g_display_plugin.auto_brightness_control(request, set_brightness);
+
+       return 0;
+}
diff --git a/src/display/display-plugin.h b/src/display/display-plugin.h
new file mode 100644 (file)
index 0000000..28411bb
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * deviced
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __DISPLAY_PLUGIN_H__
+#define __DISPLAY_PLUGIN_H__
+
+#include <unistd.h>
+#include <sys/types.h>
+
+#include "shared/devices.h"
+
+/* FIXME: Currently because of display_plugin.auto_brightness_control(),
+ *        it is here. Please relocate it to proper place later. */
+enum brightness_request_e {
+       BR_MIN = 0,
+       /* entering request */
+       BR_LBM_ON,
+       BR_HBM_ON,
+       BR_HOLD_BRIGHTNESS,
+       BR_LOWDIM_ON, /* low battery dim */
+
+       /* exiting request */
+       BR_LBM_OFF,
+       BR_HBM_OFF,
+       BR_RELEASE_BRIGHTNESS,
+       BR_LOWDIM_OFF, /* low battery dim off */
+
+       /* special */
+       BR_SET_BRIGHTNESS,
+
+       BR_MAX,
+};
+
+/* request for brightness that managed internally.
+ * BR_HOLD_BRIGHTNESS and BR_SET_BRIGHTNESS does not use this implicit brightness
+ * for request, but explicitly request for a brightness value */
+#define BR_IMPLICIT            (-1)
+
+struct display_plugin {
+       void *handle;
+       int (*pm_lock_internal) (pid_t pid, int s_bits, int flag, int timeout);
+       int (*pm_unlock_internal) (pid_t pid, int s_bits, int flag);
+       int (*pm_change_internal) (pid_t pid, int s_bits);
+       int (*update_pm_setting) (int key_idx, int val);
+       int (*get_lock_screen_state) (void);
+       bool system_wakeup_flag;
+       const char* (*device_flags_to_string) (enum device_flags flags);
+       int (*auto_brightness_control) (enum brightness_request_e request, int set_brightness);
+};
+
+void* display_plugin_handle(void);
+int display_plugin_pm_lock_internal(pid_t pid, int s_bits, int flags, int timeout);
+int display_plugin_pm_unlock_internal(pid_t pid, int s_bits, int flags);
+int display_plugin_pm_change_internal(pid_t pid, int s_bits);
+int display_plugin_update_pm_setting(int key_idx, int val);
+int display_plugin_get_lock_screen_state(void);
+int display_plugin_get_system_wakeup_flag(bool *flag);
+int display_plugin_set_system_wakeup_flag(bool flag);
+const char* display_plugin_device_flags_to_string(enum device_flags flags);
+int display_plugin_auto_brightness_control(enum brightness_request_e request, int set_brightness);
+
+#endif //__DISPLAY_PLUGIN_H__
index 9bb1789..def14e7 100644 (file)
 #include <libsyscommon/list.h>
 #include <shared/devices.h>
 
+#include "display-plugin.h"
 #include "display/display.h"
 #include "shared/log.h"
 
 static const struct device_ops *display_plugin_device_ops;
+extern struct display_plugin g_display_plugin;
 static int pm_cur_state;
 static int pm_old_state;
 static unsigned int pm_status_flag;
@@ -161,7 +163,7 @@ static int display_probe(void *data)
        if (!display_plugin_device_ops || !display_plugin_device_ops->probe)
                return 0;
 
-       return display_plugin_device_ops->probe(data);
+       return display_plugin_device_ops->probe(&g_display_plugin);
 }
 
 static void display_init(void *data)
index 70eba16..119c72d 100644 (file)
@@ -21,6 +21,7 @@
 #define __DISPLAY_OPS_H__
 
 #include <errno.h>
+#include "display-plugin.h"
 #include "shared/common.h"
 #include "shared/devices.h"
 //#include "display.h"
@@ -59,41 +60,4 @@ const struct display_ops *find_display_feature(const char *name);
 
 #define DISPLAY_FUNC(a, b)     (((a) << 16) | (b))
 
-enum brightness_request_e {
-       BR_MIN = 0,
-       /* entering request */
-       BR_LBM_ON,
-       BR_HBM_ON,
-       BR_HOLD_BRIGHTNESS,
-       BR_LOWDIM_ON, /* low battery dim */
-
-       /* exiting request */
-       BR_LBM_OFF,
-       BR_HBM_OFF,
-       BR_RELEASE_BRIGHTNESS,
-       BR_LOWDIM_OFF, /* low battery dim off */
-
-       /* special */
-       BR_SET_BRIGHTNESS,
-
-       BR_MAX,
-};
-
-/* request for brightness that managed internally.
- * BR_HOLD_BRIGHTNESS and BR_SET_BRIGHTNESS does not use this implicit brightness
- * for request, but explicitly request for a brightness value */
-#define BR_IMPLICIT            (-1)
-
-struct display_plugin {
-       void *handle;
-       int (*pm_lock_internal) (pid_t pid, int s_bits, int flag, int timeout);
-       int (*pm_unlock_internal) (pid_t pid, int s_bits, int flag);
-       int (*pm_change_internal) (pid_t pid, int s_bits);
-       int (*update_pm_setting) (int key_idx, int val);
-       int (*get_lock_screen_state) ();
-       bool system_wakeup_flag;
-       const char* (*device_flags_to_string) (enum device_flags flags);
-       int (*auto_brightness_control) (enum brightness_request_e request, int set_brightness);
-};
-
 #endif
index 9a82c4c..17d1114 100644 (file)
@@ -28,6 +28,7 @@
 #include "core.h"
 #include "poll.h"
 #include "display-ops.h"
+#include "display-plugin.h"
 #include "shared/plugin.h"
 
 #define SHIFT_UNLOCK                    4
@@ -38,7 +39,6 @@
 #define __HOLDKEY_BLOCK_BIT              0x1
 #define HOLDKEY_BLOCK_BIT               (__HOLDKEY_BLOCK_BIT << LOCK_FLAG_SHIFT)
 
-static struct display_plugin *disp_plgn;
 static PMMsg recv_data;
 
 int check_dimstay(int next_state, int flag)
@@ -166,16 +166,11 @@ static int __pm_change_internal(pid_t pid, int s_bits)
        return 0;
 }
 
-void init_pm_internal()
+void init_pm_internal(void *data)
 {
-       disp_plgn->pm_lock_internal = __pm_lock_internal;
-       disp_plgn->pm_unlock_internal = __pm_unlock_internal;
-       disp_plgn->pm_change_internal = __pm_change_internal;
-}
+       struct display_plugin *dp = (struct display_plugin *) data;
 
-static void __CONSTRUCTOR__ initialize(void)
-{
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
+       dp->pm_lock_internal = __pm_lock_internal;
+       dp->pm_unlock_internal = __pm_unlock_internal;
+       dp->pm_change_internal = __pm_change_internal;
 }
index 5e03f6a..2b9bda2 100644 (file)
@@ -141,6 +141,8 @@ enum cond_flags_e {
 #define RESET_TIMER_STR  "resettimer"
 #define KEEP_TIMER_STR   "keeptimer"
 
+void init_pm_internal(void *data);
+
 /**
  * @}
  */
index b1ca644..ee1c5f4 100644 (file)
 #include "core/udev.h"
 #include "core.h"
 #include "display-ops.h"
+#include "display-plugin.h"
 #include "extcon/extcon.h"
 #include "shared/plugin.h"
 
 #define METHOD_GET_CRADLE      "GetCradle"
 #define SIGNAL_CRADLE_STATE    "ChangedCradle"
 
-static struct display_plugin *disp_plgn;
 static struct extcon_ops cradle_extcon_ops;
 
 static void cradle_send_broadcast(int status)
@@ -60,8 +60,7 @@ static int cradle_update(const char *index, int status)
        int ret;
 
        _I("Cradle changed. status=%d", status);
-       if (disp_plgn->pm_change_internal)
-               disp_plgn->pm_change_internal(INTERNAL_LOCK_CRADLE, LCD_NORMAL);
+       display_plugin_pm_change_internal(INTERNAL_LOCK_CRADLE, LCD_NORMAL);
        cradle_send_broadcast(status);
        ret = vconf_set_int(VCONFKEY_SYSMAN_CRADLE_STATUS, status);
        if (ret < 0) {
@@ -70,11 +69,9 @@ static int cradle_update(const char *index, int status)
        }
 
        if (status == DOCK_SOUND) {
-               if (disp_plgn->pm_lock_internal)
-                       disp_plgn->pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0);
+               display_plugin_pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0);
        } else if (status == DOCK_NONE) {
-               if (disp_plgn->pm_unlock_internal)
-                       disp_plgn->pm_unlock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, PM_SLEEP_MARGIN);
+               display_plugin_pm_unlock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, PM_SLEEP_MARGIN);
        }
 
        return 0;
@@ -94,8 +91,7 @@ static int display_changed(void *data)
 
        cradle = cradle_extcon_ops.status;
        if (cradle == DOCK_SOUND) {
-               if (disp_plgn->pm_lock_internal)
-                       disp_plgn->pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0);
+               display_plugin_pm_lock_internal(INTERNAL_LOCK_CRADLE, LCD_DIM, STAY_CUR_STATE, 0);
                _I("Sound dock is connected. Dim lock is on.");
        }
 
@@ -145,10 +141,3 @@ static struct extcon_ops cradle_extcon_ops = {
 };
 
 EXTCON_OPS_REGISTER(cradle_extcon_ops)
-
-static void __CONSTRUCTOR__ initialize(void)
-{
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
-}
index 3cc6bdb..ae44eaa 100644 (file)
 #include "core/log.h"
 #include "poll.h"
 #include "display-ops.h"
+#include "display-plugin.h"
 #include "extcon/extcon.h"
 #include "shared/plugin.h"
 
 #define SIGNAL_EARJACK_STATE   "ChangedEarjack"
 #define GET_EARJACK_STATE      "Earjack"
 
-static struct display_plugin *disp_plgn;
 static void earjack_send_broadcast(int status)
 {
        static int old = 0;
@@ -79,8 +79,7 @@ static int earjack_update(const char *index, int status)
        earjack_send_broadcast(status);
        earjack_send_system_event(status);
        if (status != EARJACK_DICONNECTED) {
-               if (disp_plgn->pm_change_internal)
-                       disp_plgn->pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL);
+               display_plugin_pm_change_internal(INTERNAL_LOCK_EARJACK, LCD_NORMAL);
        }
 
        return 0;
@@ -92,10 +91,3 @@ static struct extcon_ops earjack_extcon_ops = {
 };
 
 EXTCON_OPS_REGISTER(earjack_extcon_ops)
-
-static void __CONSTRUCTOR__ initialize(void)
-{
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
-}
index 7727ac3..ff9db34 100644 (file)
@@ -28,6 +28,7 @@
 #include "core.h"
 #include "setting.h"
 #include "display-ops.h"
+#include "display-plugin.h"
 #include "touch-key.h"
 #include "shared/plugin.h"
 
@@ -45,7 +46,6 @@
 #define GET_BRIGHTNESS(val)     (((val) >> 24) & 0xFF)
 #define SET_BRIGHTNESS(val)     (((val) & 0xFF) << 24)
 
-static struct display_plugin *disp_plgn;
 static bool touchkey_dev_available = false;
 static guint hardkey_timeout_id;
 static int hardkey_duration;
@@ -141,7 +141,7 @@ static void process_touchkey_enable(bool enable)
                touchled_set_state(true);
 
                /* do not create turnoff timer in case of idle lock state */
-               if (disp_plgn->get_lock_screen_state && disp_plgn->get_lock_screen_state() == VCONFKEY_IDLE_LOCK)
+               if (display_plugin_get_lock_screen_state() == VCONFKEY_IDLE_LOCK)
                        return;
 
                /* start timer */
@@ -307,10 +307,3 @@ static const struct device_ops touchled_device_ops = {
 };
 
 DEVICE_OPS_REGISTER(&touchled_device_ops)
-
-static void __CONSTRUCTOR__ initialize(void)
-{
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
-}
index 10e53a0..caa6155 100644 (file)
 #include "core/log.h"
 #include "shared/common.h"
 #include "apps.h"
-#include "shared/plugin.h"
+#include "display-plugin.h"
 #include "shared/bitmap.h"
 
 #define POPUP_METHOD "PopupLaunch"
 #define BUFF_MAX        255
 
-static struct display_plugin *disp_plgn;
 static struct dd_bitmap *bm_background;
 static int pid_max;
 
@@ -104,8 +103,7 @@ int launch_system_app(char *type, int num, ...)
 
        va_end(args);
 
-       if (disp_plgn->pm_change_internal)
-               disp_plgn->pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
+       display_plugin_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
 
        return ret;
 }
@@ -124,8 +122,8 @@ int launch_message_post(char *type)
                        g_variant_new("(s)", type),
                        __cb, -1, NULL);
 
-       if (disp_plgn->pm_change_internal)
-               disp_plgn->pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
+       display_plugin_pm_change_internal(INTERNAL_LOCK_POPUP, LCD_NORMAL);
+
        return ret;
 }
 
@@ -197,10 +195,6 @@ void set_app_state(pid_t pid, enum application_state as)
 
 static void __CONSTRUCTOR__ initialize(void)
 {
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
-
        init_bm_background();
 }
 
index db8725c..aff5f8f 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "plugin.h"
 #include "common.h"
+#include "display-plugin.h"
 #include "core/log.h"
 
 #ifndef LIBPATH
 #endif
 #define MODULE_PATH            LIBPATH"/deviced/"
 
-static struct display_plugin disp_plgn;
+extern struct display_plugin g_display_plugin;
 static struct battery_plugin battery_plgn;
 static GList *plgn_list;
 
 inline struct display_plugin *get_var_display_plugin(void)
 {
-       return &disp_plgn;
+       return &g_display_plugin;
 }
 
 inline struct battery_plugin *get_var_battery_plugin(void)
@@ -111,7 +112,7 @@ void load_plugins(void)
                        _I("Plugin(%s) is loaded. handle=%#x", ent->d_name, (unsigned int)((intptr_t)handle));
                        plgn_list = g_list_append(plgn_list, handle);
                        if (!strcmp(ent->d_name, "display.so"))
-                               disp_plgn.handle = handle;
+                               g_display_plugin.handle = handle;
                        else if (!strcmp(ent->d_name, "battery.so"))
                                battery_plgn.handle = handle;
                }
index 7daa9ed..46b80ec 100644 (file)
@@ -38,6 +38,7 @@
 #include "poll.h"
 #include "core.h"
 #include "display-ops.h"
+#include "display-plugin.h"
 #include "shared/common.h"
 #include "shared/device-notifier.h"
 #include "shared/plugin.h"
@@ -66,7 +67,6 @@
 
 #define TIME_CHANGE_SIGNAL     "STimeChanged"
 
-static struct display_plugin *disp_plgn;
 static const time_t default_time = 2147483645; /* max(32bit) -3sec */
 static guint tfdh; /* tfd change noti */
 static int tfd = -1;
@@ -191,13 +191,11 @@ int set_datetime_action(int argc, char **argv)
        else
                pm_state = 0x4;
 
-       if (disp_plgn->pm_lock_internal)
-               disp_plgn->pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0);
+       display_plugin_pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0);
 
        ret = handle_date(argv[0]);
 
-       if (disp_plgn->pm_unlock_internal)
-               disp_plgn->pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE);
+       display_plugin_pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE);
 
        return ret;
 }
@@ -220,13 +218,11 @@ int set_timezone_action(int argc, char **argv)
        else
                pm_state = 0x4;
 
-       if (disp_plgn->pm_lock_internal)
-               disp_plgn->pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0);
+       display_plugin_pm_lock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE, 0);
 
        ret = handle_timezone(argv[0]);
 
-       if (disp_plgn->pm_unlock_internal)
-               disp_plgn->pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE);
+       display_plugin_pm_unlock_internal(INTERNAL_LOCK_TIME, pm_state, STAY_CUR_STATE);
 
        return ret;
 }
@@ -399,7 +395,7 @@ static void time_init(void *data)
                _E("Failed system time change detector init.");
        register_notifier(DEVICE_NOTIFIER_LCD, time_lcd_changed_cb);
 
-       get_cond_head = dlsym(disp_plgn->handle, "get_cond_head");
+       get_cond_head = dlsym(display_plugin_handle(), "get_cond_head");
        if (!get_cond_head)
                _E("Failed to load symbol get_cond_head(), %s.", dlerror());
 }
@@ -410,10 +406,3 @@ static const struct device_ops time_device_ops = {
 };
 
 DEVICE_OPS_REGISTER(&time_device_ops)
-
-static void __CONSTRUCTOR__ initialize(void)
-{
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
-}
index 5f334cf..4b9d5bb 100644 (file)
@@ -29,6 +29,7 @@
 #include "battery/power-supply.h"
 #include "core.h"
 #include "display-ops.h"
+#include "display-plugin.h"
 #include "power/power-boot.h"
 #include "shared/plugin.h"
 
@@ -37,7 +38,6 @@ enum ps_mode {
        POWERSAVING_ON,
 };
 
-static struct display_plugin *disp_plgn;
 static struct battery_plugin *battery_plgn;
 static bool touchscreen_dev_available = false;
 static int touchscreen_enable = DEVICE_OPS_STATUS_START;
@@ -313,8 +313,9 @@ static int delayed_init_done(void *data)
 static void touchscreen_init(void *data)
 {
        int ret, val;
+       void *handle = display_plugin_handle();
 
-       fp_get_var_display_config = dlsym(disp_plgn->handle, "get_var_display_config");
+       fp_get_var_display_config = dlsym(handle, "get_var_display_config");
        if (fp_get_var_display_config) {
                display_conf = fp_get_var_display_config();
                if (!display_conf)
@@ -326,7 +327,7 @@ static void touchscreen_init(void *data)
         * So it fails that fetching symbol directly with name 'backlight_ops'.
         * To avoid this, fetches getter function 'get_var_backlight_ops' instead, and
         * retrieve the 'backlight_ops' by using it */
-       fp_get_var_backlight_ops = dlsym(disp_plgn->handle, "get_var_backlight_ops");
+       fp_get_var_backlight_ops = dlsym(handle, "get_var_backlight_ops");
        if (fp_get_var_backlight_ops) {
                backlight_ops = fp_get_var_backlight_ops();
                if (!backlight_ops)
@@ -384,10 +385,6 @@ DEVICE_OPS_REGISTER(&touchscreen_device_ops)
 
 static void __CONSTRUCTOR__ initialize(void)
 {
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
-
        battery_plgn = get_var_battery_plugin();
        if (!battery_plgn)
                _E("Failed to get battery plugin variable.");
index 341d934..009fa59 100644 (file)
@@ -24,6 +24,7 @@
 #include "core/udev.h"
 #include "poll.h"
 #include "display-ops.h"
+#include "display-plugin.h"
 #include "shared/plugin.h"
 
 #include "usb-gadget.h"
@@ -33,8 +34,6 @@
 
 static int usb_change_gadget(unsigned mode);
 
-static struct display_plugin *disp_plgn;
-
 static int usb_config_init(void)
 {
        unsigned int mode = usb_state_get_selected_mode();
@@ -105,8 +104,7 @@ static int usb_connected(void)
        int ret;
        unsigned int mode = usb_state_get_selected_mode();
 
-       if (disp_plgn->pm_lock_internal)
-               disp_plgn->pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0);
+       display_plugin_pm_lock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE, 0);
 
        usb_state_set_connection(USB_CONNECTED);
        send_usb_state_changed_event(VCONFKEY_SYSMAN_USB_CONNECTED);
@@ -131,11 +129,10 @@ static int usb_disconnected(void)
        ret = usb_disable();
        if(ret < 0) {
                _E("Failed to disable USB gadget: %d", ret);
-               /* Important: You have to keep going to unlock disp_plgn->pm_unlock_internal */
+               /* Important: You have to keep going to unlock display_plugin_pm_unlock_internal */
        }
 
-       if (disp_plgn->pm_unlock_internal)
-               disp_plgn->pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE);
+       display_plugin_pm_unlock_internal(INTERNAL_LOCK_USB, LCD_OFF, STAY_CUR_STATE);
 
        return ret;
 }
@@ -344,10 +341,3 @@ static struct extcon_ops extcon_usb_ops = {
 };
 
 EXTCON_OPS_REGISTER(extcon_usb_ops)
-
-static void __CONSTRUCTOR__ initialize(void)
-{
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
-}
index f4057ef..c5c8668 100644 (file)
@@ -32,6 +32,7 @@
 #include "core/udev.h"
 #include "extcon/extcon.h"
 #include "display-ops.h"
+#include "display-plugin.h"
 #include "core.h"
 #include "dd-usbhost.h"
 #include "shared/plugin.h"
@@ -53,7 +54,6 @@
 #define ROOTPATH tzplatform_getenv(TZ_SYS_VAR)
 #define POLICY_FILENAME "usbhost-policy"
 
-static struct display_plugin *disp_plgn;
 static struct display_config *disp_conf;
 static struct display_config* (*fp_get_var_display_config)(void);
 static bool display_on_usb_conn_changed = true;
@@ -244,8 +244,8 @@ static int add_usbhost_list(struct udev_device *dev, const char *devpath)
 
        broadcast_usbhost_signal(USB_HOST_ADDED, usbhost);
 
-       if (display_on_usb_conn_changed && disp_plgn->pm_change_internal)
-               disp_plgn->pm_change_internal(INTERNAL_LOCK_USB_HOST, LCD_NORMAL);
+       if (display_on_usb_conn_changed)
+               display_plugin_pm_change_internal(INTERNAL_LOCK_USB_HOST, LCD_NORMAL);
 
        /* for debugging */
        _I("USB HOST Added.");
@@ -273,8 +273,8 @@ static int remove_usbhost_list(const char *devpath)
 
        broadcast_usbhost_signal(USB_HOST_REMOVED, usbhost);
 
-       if (display_on_usb_conn_changed && disp_plgn->pm_change_internal)
-               disp_plgn->pm_change_internal(INTERNAL_LOCK_USB_HOST, LCD_NORMAL);
+       if (display_on_usb_conn_changed)
+               display_plugin_pm_change_internal(INTERNAL_LOCK_USB_HOST, LCD_NORMAL);
 
        /* for debugging */
        _I("USB HOST Removed.");
@@ -1132,7 +1132,7 @@ static void usbhost_init(void *data)
 {
        int ret;
 
-       fp_get_var_display_config = dlsym(disp_plgn->handle, "get_var_display_config");
+       fp_get_var_display_config = dlsym(display_plugin_handle(), "get_var_display_config");
        if (fp_get_var_display_config) {
                disp_conf = fp_get_var_display_config();
                if (!disp_conf)
@@ -1215,10 +1215,3 @@ static struct extcon_ops extcon_usbhost_ops = {
 };
 
 EXTCON_OPS_REGISTER(extcon_usbhost_ops)
-
-static void __CONSTRUCTOR__ initialize(void)
-{
-       disp_plgn = get_var_display_plugin();
-       if (!disp_plgn)
-               _E("Failed to get display plugin variable.");
-}
index 7c3323d..212a7f3 100644 (file)
@@ -14,6 +14,7 @@ PKG_CHECK_MODULES(ORIG_REQUIRED_PKGS REQUIRED
 
 SET(WRAP_FLAGS "-Wl,--wrap=dlopen")
 SET(WRAP_FLAGS "${WRAP_FLAGS} -Wl,--wrap=access")
+SET(WRAP_FLAGS "${WRAP_FLAGS} -Wl,--wrap=display_plugin_pm_change_internal")
 
 FILE(GLOB ORIG_SRCS "${CMAKE_SOURCE_DIR}/src/shared/*.c")
 ADD_LIBRARY(test-shared SHARED ${ORIG_SRCS})
index 63ea2cd..c3eba7e 100644 (file)
@@ -1,8 +1,15 @@
 #include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+/* FIXME: This would be replaced to plugin-api-deviced */
+#include "display-plugin.h"
 
 #include "test-main.h"
 #include "test-mock.h"
 
+struct display_plugin g_display_plugin;
+
 int __wrap_access(const char *pathname, int mode)
 {
        return mock_type(int);
@@ -18,3 +25,8 @@ void *__wrap_dlopen(const char *filename, int flags)
 
        return ret;
 }
+
+int __wrap_display_plugin_pm_change_internal(pid_t pid, int s_bits)
+{
+       return 0;
+}