display: Add resource attribute representing max brightness 87/296887/4
authorYoungjae Cho <y0.cho@samsung.com>
Fri, 4 Aug 2023 05:23:53 +0000 (14:23 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Wed, 9 Aug 2023 09:18:47 +0000 (18:18 +0900)
New attribute:
 - id: DEVICED_DISPLAY_ATTR_INT_GET_MAX_BRIGHTNESS
 - type: SYSCOMMON_RESMAN_DATA_TYPE_INT
 - setter: O
 - getter: X

 The previous operations, display_backlight_get_max_brightness(),
has been replaced with operation that accessing the attribute
DEVICED_DISPLAY_ATTR_INT_BRIGHTNESS via resource-manager API.

Change-Id: I6966cbdf4a75795c9f566611424095a04c133bbc
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
plugins/wearable/display/device-interface.c
src/display/resource-display.c

index 1128f10..ef892bf 100644 (file)
@@ -31,6 +31,9 @@
 #include <errno.h>
 #include <dlfcn.h>
 #include <hal/device/hal-display.h>
+#include <libsyscommon/resource-manager.h>
+#include <system/syscommon-plugin-deviced-display-interface.h>
+#include <system/syscommon-plugin-deviced-common-interface.h>
 
 #include "ambient-mode.h"
 #include "core/log.h"
@@ -77,7 +80,8 @@ static int set_brightness(int val)
                return -ENOENT;
        }
 
-       ret = display_backlight_get_max_brightness(&max);
+       ret = syscommon_resman_get_resource_attr_int(SYSCOMMON_RESOURCE_ID(DEVICED_RESOURCE_TYPE_DISPLAY),
+               DEVICED_DISPLAY_ATTR_INT_GET_MAX_BRIGHTNESS, &max);
        if (ret < 0) {
                _E("Failed to get max brightness.");
                return ret;
index 520605a..2523b69 100644 (file)
 #include <system/syscommon-plugin-deviced-display.h>
 
 #include "shared/common.h"
+#include "display-backlight.h"
+
+static int get_max_brightness(int resource_id,
+       const struct syscommon_resman_resource_attribute *attr, void *data)
+{
+       int brightness = 0;
+       int ret = 0;
+
+       if (!data)
+               return -EINVAL;
+
+       ret = display_backlight_get_max_brightness(&brightness);
+       if (ret < 0)
+               return ret;
+
+       *(int *) data = brightness;
+
+       return 0;
+
+}
 
 static const struct syscommon_resman_resource_attribute display_attrs[] = {
+       {
+               .name = "DEVICED_DISPLAY_ATTR_INT_GET_MAX_BRIGHTNESS",
+               .id = DEVICED_DISPLAY_ATTR_INT_GET_MAX_BRIGHTNESS,
+               .type = SYSCOMMON_RESMAN_DATA_TYPE_INT,
+               .flag = SYSCOMMON_RESMAN_RESOURCE_FLAG_PUBLIC,
+               .ops = {
+                       .get = get_max_brightness,
+                       .is_supported = syscommon_resman_resource_attr_supported_always
+               },
+       },
 };
 
 static const struct syscommon_resman_resource_driver deviced_display_driver = {