From: Youngjae Cho Date: Fri, 4 Aug 2023 05:23:53 +0000 (+0900) Subject: display: Add resource attribute representing max brightness X-Git-Tag: accepted/tizen/unified/20230818.183532~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=179dce05bc7faecfc68248e97c208ceabd35142a;p=platform%2Fcore%2Fsystem%2Fdeviced.git display: Add resource attribute representing max brightness 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 --- diff --git a/plugins/wearable/display/device-interface.c b/plugins/wearable/display/device-interface.c index 1128f10..ef892bf 100644 --- a/plugins/wearable/display/device-interface.c +++ b/plugins/wearable/display/device-interface.c @@ -31,6 +31,9 @@ #include #include #include +#include +#include +#include #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; diff --git a/src/display/resource-display.c b/src/display/resource-display.c index 520605a..2523b69 100644 --- a/src/display/resource-display.c +++ b/src/display/resource-display.c @@ -25,8 +25,38 @@ #include #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 = {