display: Add attribute for display actor capability 11/297611/3
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 21 Aug 2023 11:47:51 +0000 (20:47 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 22 Aug 2023 01:21:00 +0000 (10:21 +0900)
New attribute:
 - id: DEVICED_DISPLAY_ATTR_UINT64_GET_ACTOR_CAPABILITY
 - type: SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_2_USER_DATA
 - setter: X
 - getter: O
 - 1st param: syscommon_deviced_display_actor_id
 - 2nd param: syscommon_deviced_display_capability
 It finds whether an actor id has an capability.

New attribute:
 - id: DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY
 - type: SYSCOMMON_RESMAN_DATA_TYPE_UINT64_UINT64_UINT64
 - setter: O
 - getter: X
 - 1st param: syscommon_deviced_display_actor_id
 - 2nd param: syscommon_deviced_display_capability
 - 3rd param: 0: reset,  1: set
 It sets/resets capability of an actor id.

Additionally, replaces all enum and struct related to display actor
with the libsyscommon one.

Change-Id: Icd8cedfaf8edb315ba1f960470cb46c98e519357
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/iot-headed/display/key-filter.c
plugins/mobile/display/key-filter.c
plugins/tv/display/key-filter.c
plugins/wearable/display/key-filter.c
src/display/display-actor.c
src/display/display-actor.h
src/display/display-dbus.c
src/display/resource-display.c

index 9b467c88b0cc499debe56d227bdc00736f9d1839..1575fbb0ffc37064c1334622c32a5be9a306092d 100644 (file)
@@ -32,7 +32,6 @@
 #include <system/syscommon-plugin-deviced-power-interface.h>
 #include <linux/input.h>
 
-#include "display-actor.h"
 #include "display-config.h"
 #include "display-misc.h"
 #include <libsyscommon/log.h>
@@ -150,23 +149,36 @@ static void pwroff_popup(void)
                _E("Failed to launch power off popup.");
 }
 
-static void longkey_pressed(void)
+static int check_actor_caps(int actor_id, unsigned int caps)
 {
-       unsigned int caps;
+       int ret = 0;
+       u_int64_t capability = 0;
 
-       _I("Power key long pressed!");
-       cancel_lcdoff = 1;
+       ret = syscommon_resman_get_resource_attr_uint64_with_2_user_data(
+               SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+               DEVICED_DISPLAY_ATTR_UINT64_GET_ACTOR_CAPABILITY,
+               (u_int64_t *) &actor_id,
+               (u_int64_t *) &caps,
+               &capability);
 
-       caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);
+       if (ret < 0)
+               return 0; /* no capability */
+
+       return capability;
+}
 
-       if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+static void longkey_pressed(void)
+{
+       _I("Power key long pressed!");
+       cancel_lcdoff = 1;
+       if (check_actor_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                /* change state - LCD on */
                syscommon_resman_set_resource_attr_uint64_2(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
                        DEVICED_DISPLAY_ATTR_TUPLE2_SET_CURRENT_STATE,
                        SYSCOMMON_DEVICED_DISPLAY_STATE_ON, DEVICED_EVENT_INPUT_POWERKEY);
        }
 
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) {
+       if (!check_actor_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF)) {
                _D("No poweroff capability!");
                return;
        }
@@ -375,11 +387,7 @@ static void process_combination_key(struct input_event *pinput)
 
 static int process_menu_key(struct input_event *pinput)
 {
-       int caps;
-
-       caps = display_get_caps(DISPLAY_ACTOR_MENU_KEY);
-
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+       if (!check_actor_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_MENU_KEY, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                if (current_state_in_on())
                        return false;
                _D("No lcd-on capability!");
@@ -470,28 +478,25 @@ static int process_power_key(struct input_event *pinput)
 {
        int ignore = true;
        static int value = KEY_RELEASED;
-       unsigned int caps;
        const struct syscommon_deviced_display_config *display_conf = get_var_display_config();
        if (!display_conf) {
                _E("Failed to get display configuration variable.");
                return ignore;
        }
 
-       caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);
-
        switch (pinput->value) {
        case KEY_RELEASED:
                check_key_pair(pinput->code, pinput->value, &value);
 
                if (!display_conf->powerkey_doublepress) {
-                       if (display_has_caps(caps, DISPLAY_CAPA_LCDOFF))
+                       if (check_actor_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF))
                                lcdoff_powerkey();
                        else
                                _D("No lcdoff capability!");
                } else if (skip_lcd_off)
                        ignore = false;
 
-               if (!display_has_caps(caps, DISPLAY_CAPA_LCDON))
+               if (!check_actor_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON))
                        ignore = true;
 
                if (longkey_timeout_id > 0) {
@@ -506,7 +511,7 @@ static int process_power_key(struct input_event *pinput)
 
                break;
        case KEY_PRESSED:
-               if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+               if (check_actor_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                        skip_lcd_off = switch_on_lcd(LCD_ON_BY_POWER_KEY);
                } else {
                        _D("No lcdon capability!");
@@ -789,27 +794,23 @@ static int bezel_wakeup_cb(void *data)
        return 0;
 }
 
-/*
- * Default capability
- * powerkey := LCDON | LCDOFF | POWEROFF
- * homekey  := LCDON
- */
-static struct display_actor_ops display_powerkey_actor = {
-       .id     = DISPLAY_ACTOR_POWER_KEY,
-       .caps   = DISPLAY_CAPA_LCDON |
-                 DISPLAY_CAPA_LCDOFF |
-                 DISPLAY_CAPA_POWEROFF,
-};
-
-static struct display_actor_ops display_menukey_actor = {
-       .id     = DISPLAY_ACTOR_MENU_KEY,
-       .caps   = DISPLAY_CAPA_LCDON,
-};
-
 static void __CONSTRUCTOR__ initialize(void)
 {
-       display_add_actor(&display_powerkey_actor);
-       display_add_actor(&display_menukey_actor);
+       /*
+        * Default capability
+        * powerkey := LCDON | LCDOFF | POWEROFF
+        * homekey  := LCDON
+        */
+       syscommon_resman_set_resource_attr_uint64_3(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+               DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY,
+               SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY,
+               (SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON | SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF | SYSCOMMON_DEVICED_DISPLAY_CAPA_POWEROFF),
+               1);
+       syscommon_resman_set_resource_attr_uint64_3(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+               DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY,
+               SYSCOMMON_DEVICED_DISPLAY_ACTOR_MENU_KEY,
+               SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON,
+               1);
 
        syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_DELAYED_INIT, delayed_init_done);
        syscommon_notifier_subscribe_notify(DEVICED_NOTIFIER_BEZEL_WAKEUP, bezel_wakeup_cb);
index 6548727bc0d1c834071d2c63213bdc4f00459d2f..a4e79ae7b4e4325e59fd08c6ca886e4c43786834 100644 (file)
@@ -141,16 +141,16 @@ static void longkey_pressed(void)
        _I("Power key long pressed!");
        cancel_lcdoff = 1;
 
-       caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY);
 
-       if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+       if (display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                /* change state - LCD on */
                syscommon_resman_set_resource_attr_uint64_2(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
                        DEVICED_DISPLAY_ATTR_TUPLE2_SET_CURRENT_STATE,
                        SYSCOMMON_DEVICED_DISPLAY_STATE_ON, DEVICED_EVENT_INPUT_POWERKEY);
        }
 
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) {
+       if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF)) {
                _D("No poweroff capability!");
                return;
        }
@@ -343,9 +343,9 @@ static int process_menu_key(struct input_event *pinput)
 {
        int caps;
 
-       caps = display_get_caps(DISPLAY_ACTOR_MENU_KEY);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_MENU_KEY);
 
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+       if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                if (current_state_in_on())
                        return false;
                _D("No lcd-on capability!");
@@ -464,21 +464,21 @@ static int process_power_key(struct input_event *pinput)
                return ignore;
        }
 
-       caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY);
 
        switch (pinput->value) {
        case KEY_RELEASED:
                check_key_pair(pinput->code, pinput->value, &value);
 
                if (!display_conf->powerkey_doublepress) {
-                       if (display_has_caps(caps, DISPLAY_CAPA_LCDOFF))
+                       if (display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF))
                                lcdoff_powerkey();
                        else
                                _D("No lcdoff capability!");
                } else if (skip_lcd_off)
                        ignore = false;
 
-               if (!display_has_caps(caps, DISPLAY_CAPA_LCDON))
+               if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON))
                        ignore = true;
 
                if (longkey_timeout_id > 0) {
@@ -493,7 +493,7 @@ static int process_power_key(struct input_event *pinput)
 
                break;
        case KEY_PRESSED:
-               if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+               if (display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                        /*
                         * LCD does not turn on immediately at mobile.
                         * It will be turned on after 0.1 second because of torch concept.
@@ -786,16 +786,16 @@ static int bezel_wakeup_cb(void *data)
  * powerkey := LCDON | LCDOFF | POWEROFF
  * homekey  := LCDON
  */
-static struct display_actor_ops display_powerkey_actor = {
-       .id     = DISPLAY_ACTOR_POWER_KEY,
-       .caps   = DISPLAY_CAPA_LCDON |
-                 DISPLAY_CAPA_LCDOFF |
-                 DISPLAY_CAPA_POWEROFF,
+static struct syscommon_deviced_display_actor_ops display_powerkey_actor = {
+       .id     = SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY,
+       .caps   = SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON |
+                 SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF |
+                 SYSCOMMON_DEVICED_DISPLAY_CAPA_POWEROFF,
 };
 
-static struct display_actor_ops display_menukey_actor = {
-       .id     = DISPLAY_ACTOR_MENU_KEY,
-       .caps   = DISPLAY_CAPA_LCDON,
+static struct syscommon_deviced_display_actor_ops display_menukey_actor = {
+       .id     = SYSCOMMON_DEVICED_DISPLAY_ACTOR_MENU_KEY,
+       .caps   = SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON,
 };
 
 static void __CONSTRUCTOR__ initialize(void)
index aac5ef9d848f92064e8ff68a11883f91578bf3da..f9aed5f334421905ead964cad2b1498540862e2d 100644 (file)
@@ -149,16 +149,16 @@ static void longkey_pressed(void)
        _I("Power key long pressed!");
        cancel_lcdoff = 1;
 
-       caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY);
 
-       if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+       if (display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                /* change state - LCD on */
                syscommon_resman_set_resource_attr_uint64_2(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
                        DEVICED_DISPLAY_ATTR_TUPLE2_SET_CURRENT_STATE,
                        SYSCOMMON_DEVICED_DISPLAY_STATE_ON, DEVICED_EVENT_INPUT_POWERKEY);
        }
 
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) {
+       if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF)) {
                _D("No poweroff capability!");
                return;
        }
@@ -353,9 +353,9 @@ static int process_menu_key(struct input_event *pinput)
 {
        int caps;
 
-       caps = display_get_caps(DISPLAY_ACTOR_MENU_KEY);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_MENU_KEY);
 
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+       if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                if (current_state_in_on())
                        return false;
                _D("No lcd-on capability!");
@@ -445,21 +445,21 @@ static int process_power_key(struct input_event *pinput)
                return ignore;
        }
 
-       caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY);
 
        switch (pinput->value) {
        case KEY_RELEASED:
                check_key_pair(pinput->code, pinput->value, &value);
 
                if (!display_conf->powerkey_doublepress) {
-                       if (display_has_caps(caps, DISPLAY_CAPA_LCDOFF))
+                       if (display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF))
                                lcdoff_powerkey();
                        else
                                _D("No lcdoff capability!");
                } else if (skip_lcd_off)
                        ignore = false;
 
-               if (!display_has_caps(caps, DISPLAY_CAPA_LCDON))
+               if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON))
                        ignore = true;
 
                if (longkey_timeout_id > 0) {
@@ -474,7 +474,7 @@ static int process_power_key(struct input_event *pinput)
 
                break;
        case KEY_PRESSED:
-               if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+               if (display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                        skip_lcd_off = switch_on_lcd(LCD_ON_BY_POWER_KEY);
                } else {
                        _D("No lcdon capability!");
@@ -754,16 +754,16 @@ static int bezel_wakeup_cb(void *data)
  * powerkey := LCDON | LCDOFF | POWEROFF
  * homekey  := LCDON
  */
-static struct display_actor_ops display_powerkey_actor = {
-       .id     = DISPLAY_ACTOR_POWER_KEY,
-       .caps   = DISPLAY_CAPA_LCDON |
-                 DISPLAY_CAPA_LCDOFF |
-                 DISPLAY_CAPA_POWEROFF,
+static struct syscommon_deviced_display_actor_ops display_powerkey_actor = {
+       .id     = SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY,
+       .caps   = SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON |
+                 SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF |
+                 SYSCOMMON_DEVICED_DISPLAY_CAPA_POWEROFF,
 };
 
-static struct display_actor_ops display_menukey_actor = {
-       .id     = DISPLAY_ACTOR_MENU_KEY,
-       .caps   = DISPLAY_CAPA_LCDON,
+static struct syscommon_deviced_display_actor_ops display_menukey_actor = {
+       .id     = SYSCOMMON_DEVICED_DISPLAY_ACTOR_MENU_KEY,
+       .caps   = SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON,
 };
 
 static void __CONSTRUCTOR__ initialize(void)
index 078b32356ca13308f025e8ef3f667ee5be7c843e..8700061ab1ab606622c9c697102165b40ec81218 100644 (file)
@@ -125,15 +125,15 @@ static void longkey_pressed(void)
        _I("Power key long pressed!");
        cancel_lcdoff = 1;
 
-       caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY);
 
-       if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+       if (display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                /* change state - LCD on */
                display_state_transition_request_state_transition_with_option(DEVICED_EVENT_INPUT_POWERKEY, LCD_NORMAL);
                display_state_transition_do_state_transition_by_input_poll_event();
        }
 
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF)) {
+       if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF)) {
                _D("No poweroff capability!");
                return;
        }
@@ -334,9 +334,9 @@ static int process_menu_key(struct input_event *pinput)
 {
        int caps;
 
-       caps = display_get_caps(DISPLAY_ACTOR_MENU_KEY);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_MENU_KEY);
 
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+       if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                if (current_state_in_on())
                        return false;
                _D("No lcd-on capability!");
@@ -425,21 +425,21 @@ static int process_power_key(struct input_event *pinput)
                return ignore;
        }
 
-       caps = display_get_caps(DISPLAY_ACTOR_POWER_KEY);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY);
 
        switch (pinput->value) {
        case KEY_RELEASED:
                check_key_pair(pinput->code, pinput->value, &value);
 
                if (!display_conf->powerkey_doublepress) {
-                       if (display_has_caps(caps, DISPLAY_CAPA_LCDOFF))
+                       if (display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF))
                                lcdoff_powerkey();
                        else
                                _D("No lcdoff capability!");
                } else if (skip_lcd_off)
                        ignore = false;
 
-               if (!display_has_caps(caps, DISPLAY_CAPA_LCDON))
+               if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON))
                        ignore = true;
 
                if (longkey_timeout_id > 0) {
@@ -454,7 +454,7 @@ static int process_power_key(struct input_event *pinput)
 
                break;
        case KEY_PRESSED:
-               if (display_has_caps(caps, DISPLAY_CAPA_LCDON)) {
+               if (display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON)) {
                        skip_lcd_off = switch_on_lcd(LCD_ON_BY_POWER_KEY);
                } else {
                        _D("No lcdon capability!");
@@ -688,16 +688,16 @@ static int bezel_wakeup_cb(void *data)
  * powerkey := LCDON | LCDOFF | POWEROFF
  * homekey  := LCDON
  */
-static struct display_actor_ops display_powerkey_actor = {
-       .id     = DISPLAY_ACTOR_POWER_KEY,
-       .caps   = DISPLAY_CAPA_LCDON |
-                 DISPLAY_CAPA_LCDOFF |
-                 DISPLAY_CAPA_POWEROFF,
+static struct syscommon_deviced_display_actor_ops display_powerkey_actor = {
+       .id     = SYSCOMMON_DEVICED_DISPLAY_ACTOR_POWER_KEY,
+       .caps   = SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON |
+                 SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF |
+                 SYSCOMMON_DEVICED_DISPLAY_CAPA_POWEROFF,
 };
 
-static struct display_actor_ops display_menukey_actor = {
-       .id     = DISPLAY_ACTOR_MENU_KEY,
-       .caps   = DISPLAY_CAPA_LCDON,
+static struct syscommon_deviced_display_actor_ops display_menukey_actor = {
+       .id     = SYSCOMMON_DEVICED_DISPLAY_ACTOR_MENU_KEY,
+       .caps   = SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON,
 };
 
 static void __CONSTRUCTOR__ initialize(void)
index 47ecfdc0e5feeb756e7007102a893500ee5fcc63..cd87f6dbecd9983887ae224917734747b20a6569 100644 (file)
 
 static GList *actor_head;
 
-void display_add_actor(struct display_actor_ops *actor)
+void display_add_actor(struct syscommon_deviced_display_actor_ops *actor)
 {
        SYS_G_LIST_APPEND(actor_head, actor);
 }
 
-static struct display_actor_ops *display_find_actor(enum display_actor_id id)
+struct syscommon_deviced_display_actor_ops *display_find_actor(enum syscommon_deviced_display_actor_id id)
 {
        GList *elem;
-       struct display_actor_ops *actor;
+       struct syscommon_deviced_display_actor_ops *actor;
 
        SYS_G_LIST_FOREACH(actor_head, elem, actor) {
                if (actor->id == id)
@@ -42,9 +42,9 @@ static struct display_actor_ops *display_find_actor(enum display_actor_id id)
        return NULL;
 }
 
-int display_set_caps(enum display_actor_id id, unsigned int caps)
+int display_set_caps(enum syscommon_deviced_display_actor_id id, unsigned int caps)
 {
-       struct display_actor_ops *actor;
+       struct syscommon_deviced_display_actor_ops *actor;
 
        if (id <= 0 || !caps)
                return -EINVAL;
@@ -58,9 +58,9 @@ int display_set_caps(enum display_actor_id id, unsigned int caps)
        return 0;
 }
 
-int display_reset_caps(enum display_actor_id id, unsigned int caps)
+int display_reset_caps(enum syscommon_deviced_display_actor_id id, unsigned int caps)
 {
-       struct display_actor_ops *actor;
+       struct syscommon_deviced_display_actor_ops *actor;
 
        if (id <= 0 || !caps)
                return -EINVAL;
@@ -74,9 +74,9 @@ int display_reset_caps(enum display_actor_id id, unsigned int caps)
        return 0;
 }
 
-unsigned int display_get_caps(enum display_actor_id id)
+unsigned int display_get_caps(enum syscommon_deviced_display_actor_id id)
 {
-       struct display_actor_ops *actor;
+       struct syscommon_deviced_display_actor_ops *actor;
 
        if (id <= 0)
                return 0;
index 17f1be6d551557c3241d0d5872332a07c8be61f5..a5a7f58fb25b8d2ac6f1572a94c2ea0a523447cf 100644 (file)
 #define __DISPLAY_ACTOR_H__
 
 #include <errno.h>
+#include <system/syscommon-plugin-deviced-display-interface.h>
 #include "shared/common.h"
 
-enum display_actor_id {
-       DISPLAY_ACTOR_POWER_KEY = 1,
-       DISPLAY_ACTOR_MENU_KEY,
-       DISPLAY_ACTOR_API,
-       DISPLAY_ACTOR_GESTURE,
-};
-
-struct display_actor_ops {
-       enum display_actor_id id;
-       unsigned int caps;
-};
-
-enum display_capability {
-       DISPLAY_CAPA_BRIGHTNESS         = 1 << 0,
-       DISPLAY_CAPA_LCDON              = 1 << 1,
-       DISPLAY_CAPA_LCDOFF             = 1 << 2,
-       DISPLAY_CAPA_POWEROFF           = 1 << 3,
-};
-
-void display_add_actor(struct display_actor_ops *actor);
-int display_set_caps(enum display_actor_id id, unsigned int caps);
-int display_reset_caps(enum display_actor_id id, unsigned int caps);
-unsigned int display_get_caps(enum display_actor_id id);
+struct syscommon_deviced_display_actor_ops *display_find_actor(enum syscommon_deviced_display_actor_id id);
+void display_add_actor(struct syscommon_deviced_display_actor_ops *actor);
+int display_set_caps(enum syscommon_deviced_display_actor_id id, unsigned int caps);
+int display_reset_caps(enum syscommon_deviced_display_actor_id id, unsigned int caps);
+unsigned int display_get_caps(enum syscommon_deviced_display_actor_id id);
 int display_has_caps(unsigned int total_caps, unsigned int caps);
 
 #endif
index ac2779bf380b32895151d6a010168a9ed7eb7b62..babe49a855f2424a9e4415dcfc76bfb890b6f976 100644 (file)
@@ -187,15 +187,15 @@ static GVariant *dbus_lockstate(GDBusConnection *conn,
        }
 
        if (flag & GOTO_STATE_NOW) {
-               caps = display_get_caps(DISPLAY_ACTOR_API);
+               caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_API);
 
-               if (!display_has_caps(caps, DISPLAY_CAPA_LCDON) &&
+               if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON) &&
                    state == LCD_NORMAL) {
                        _D("No lcdon capability!");
                        ret = -EPERM;
                        goto out;
                }
-               if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF) &&
+               if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF) &&
                    state == LCD_OFF) {
                        _D("No lcdoff capability!");
                        ret = -EPERM;
@@ -340,15 +340,15 @@ static GVariant *dbus_changestate(GDBusConnection *conn,
                goto out;
        }
 
-       caps = display_get_caps(DISPLAY_ACTOR_API);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_API);
 
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDON) &&
+       if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON) &&
            state == LCD_NORMAL) {
                _D("No lcdon capability!");
                ret = -EPERM;
                goto out;
        }
-       if (!display_has_caps(caps, DISPLAY_CAPA_LCDOFF) &&
+       if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF) &&
            state == LCD_OFF) {
                _D("No lcdoff capability!");
                ret = -EPERM;
@@ -462,9 +462,9 @@ static GVariant *dbus_setbrightness(GDBusConnection *conn,
        int state, brt, autobrt, ret = 0, caps;
        pid_t pid;
 
-       caps = display_get_caps(DISPLAY_ACTOR_API);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_API);
 
-       if (!display_has_caps(caps, DISPLAY_CAPA_BRIGHTNESS)) {
+       if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_BRIGHTNESS)) {
                _D("No brightness changing capability!");
                ret = -EPERM;
                goto error;
@@ -536,9 +536,9 @@ static GVariant *dbus_holdbrightness(GDBusConnection *conn,
        int brt, autobrt, ret, caps;
        pid_t pid;
 
-       caps = display_get_caps(DISPLAY_ACTOR_API);
+       caps = display_get_caps(SYSCOMMON_DEVICED_DISPLAY_ACTOR_API);
 
-       if (!display_has_caps(caps, DISPLAY_CAPA_BRIGHTNESS)) {
+       if (!display_has_caps(caps, SYSCOMMON_DEVICED_DISPLAY_CAPA_BRIGHTNESS)) {
                _D("No brightness changing capability!");
                ret = -EPERM;
                goto error;
@@ -1520,16 +1520,16 @@ static void app_terminate_signal_handler(GDBusConnection  *conn,
  * api      := LCDON | LCDOFF | BRIGHTNESS
  * gesture  := LCDON
  */
-static struct display_actor_ops display_api_actor = {
-       .id     = DISPLAY_ACTOR_API,
-       .caps   = DISPLAY_CAPA_LCDON |
-                 DISPLAY_CAPA_LCDOFF |
-                 DISPLAY_CAPA_BRIGHTNESS,
+static struct syscommon_deviced_display_actor_ops display_api_actor = {
+       .id     = SYSCOMMON_DEVICED_DISPLAY_ACTOR_API,
+       .caps   = SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON |
+                 SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDOFF |
+                 SYSCOMMON_DEVICED_DISPLAY_CAPA_BRIGHTNESS,
 };
 
-static struct display_actor_ops display_gesture_actor = {
-       .id     = DISPLAY_ACTOR_GESTURE,
-       .caps   = DISPLAY_CAPA_LCDON,
+static struct syscommon_deviced_display_actor_ops display_gesture_actor = {
+       .id     = SYSCOMMON_DEVICED_DISPLAY_ACTOR_GESTURE,
+       .caps   = SYSCOMMON_DEVICED_DISPLAY_CAPA_LCDON,
 };
 
 int init_pm_dbus(void)
index fe1405f11b43ccbffd0e042abfc2e8be8e502c8d..40e7fb24481b7b32a3c1bb79a0f9732bfb63c415 100644 (file)
@@ -27,6 +27,7 @@
 #include "shared/common.h"
 #include "display-state-transition.h"
 #include "display-backlight.h"
+#include "display-actor.h"
 #include "device-interface.h"
 
 typedef union {
@@ -127,6 +128,41 @@ static int set_tuple2_display_attr_data(int resource_id,
                        return 0;
                }
                break;
+       }
+
+       return 0;
+}
+
+static int set_tuple3_display_attr_data(int resource_id,
+       const struct syscommon_resman_resource_attribute *attr,
+       const void *data1, const void *data2, const void *data3, int count1, int count2, int count3)
+{
+       if (!data1 || !data2 || !data3)
+               return -EINVAL;
+
+       switch (attr->id) {
+       case DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY:
+               {
+                       enum syscommon_deviced_display_actor_id id = *(enum syscommon_deviced_display_actor_id *) data1;
+                       unsigned int caps = *(unsigned int *) data2;
+                       int set = *(int *) data3;
+
+                       struct syscommon_deviced_display_actor_ops *actor;
+
+                       actor = display_find_actor(id);
+                       if (!actor) {
+                               actor = calloc(1, sizeof(struct syscommon_deviced_display_actor_ops));
+                               if (!actor)
+                                       return -ENOMEM;
+                               display_add_actor(actor);
+                       }
+
+                       if (set)
+                               actor->caps |= caps;
+                       else
+                               actor->caps &= ~caps;
+               }
+               break;
        default:
                return -EINVAL;
        }
@@ -193,6 +229,73 @@ static int get_display_attr_data(int resource_id,
        return 0;
 }
 
+static int get_display_attr_data_with_2_user_data(int resource_id,
+       const struct syscommon_resman_resource_attribute *attr,
+       void *user_data1, void *user_data2, int user_count1, int user_count2, void *data)
+{
+       int ret = 0;
+       resource_attr_data_t attr_data = { 0, };
+
+       if (!data)
+               return -EINVAL;
+
+       switch (attr->id) {
+       case DEVICED_DISPLAY_ATTR_UINT64_GET_ACTOR_CAPABILITY:
+               {
+                       enum syscommon_deviced_display_actor_id id;
+                       unsigned int caps;
+                       struct syscommon_deviced_display_actor_ops *actor;
+
+                       if (!user_data1 || !user_data2)
+                               return -EINVAL;
+
+                        id = *(enum syscommon_deviced_display_actor_id *) user_data1;
+                        caps = *(unsigned int *) user_data2;
+
+                        actor = display_find_actor(id);
+                        if (!actor)
+                                return -EINVAL;
+
+                        attr_data.u64 = display_has_caps(actor->caps, caps);
+               }
+               break;
+       default:
+               ret = -EINVAL;
+               break;
+       }
+
+       if (ret < 0)
+               return ret;
+
+       switch (attr->type) {
+       case SYSCOMMON_RESMAN_DATA_TYPE_INT:
+               *(int32_t *) data = attr_data.i32;
+               break;
+       case SYSCOMMON_RESMAN_DATA_TYPE_INT64:
+               *(int64_t *) data = attr_data.i64;
+               break;
+       case SYSCOMMON_RESMAN_DATA_TYPE_UINT:
+               *(uint32_t *) data = attr_data.u32;
+               break;
+       case SYSCOMMON_RESMAN_DATA_TYPE_UINT64:
+               *(uint64_t *) data = attr_data.u64;
+               break;
+       case SYSCOMMON_RESMAN_DATA_TYPE_DOUBLE:
+               *(double *) data = attr_data.d;
+               break;
+       case SYSCOMMON_RESMAN_DATA_TYPE_PTR:
+               *(void **) data = attr_data.p;
+               break;
+       case SYSCOMMON_RESMAN_DATA_TYPE_BOOLEAN:
+               *(bool *) data = attr_data.b;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static const struct syscommon_resman_resource_attribute display_attrs[] = {
        {
                .name = "DEVICED_DISPLAY_ATTR_INT_GET_MAX_BRIGHTNESS",
@@ -250,6 +353,24 @@ static const struct syscommon_resman_resource_attribute display_attrs[] = {
                        .get = get_display_attr_data,
                        .is_supported = syscommon_resman_resource_attr_supported_always,
                },
+       }, {
+               .name = "DEVICED_DISPLAY_ATTR_UINT64_GET_ACTOR_CAPABILITY",
+               .id = DEVICED_DISPLAY_ATTR_UINT64_GET_ACTOR_CAPABILITY,
+               .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64_WITH_2_USER_DATA,
+               .flag = SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC,
+               .ops = {
+                       .get_with_2_user_data = get_display_attr_data_with_2_user_data,
+                       .is_supported = syscommon_resman_resource_attr_supported_always,
+               },
+       }, {
+               .name = "DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY",
+               .id = DEVICED_DISPLAY_ATTR_TUPLE3_SET_ACTOR_CAPABILITY,
+               .type = SYSCOMMON_RESMAN_DATA_TYPE_UINT64_UINT64_UINT64,
+               .flag = SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC,
+               .ops = {
+                       .set_3_tuple = set_tuple3_display_attr_data,
+                       .is_supported = syscommon_resman_resource_attr_supported_always,
+               },
        }
 };