From: Youngjae Cho Date: Mon, 17 Jun 2024 09:05:28 +0000 (+0900) Subject: plugin-api: deviced: Add interface for controlling display powersaving mode X-Git-Tag: accepted/tizen/8.0/unified/20240710.161335~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F313085%2F1;p=platform%2Fcore%2Fsystem%2Flibsyscommon.git plugin-api: deviced: Add interface for controlling display powersaving mode Change-Id: I9f749cb7fe30bfd814de4b12c545554dee1eae2b Signed-off-by: Youngjae Cho --- diff --git a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h index 21dc8a4..b1c5d7c 100644 --- a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h +++ b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h @@ -154,6 +154,7 @@ typedef struct _syscommon_plugin_backend_deviced_display_funcs { int (*get_brightness) (int *brightness); int (*set_brightness) (int brightness); int (*set_brightness_smooth) (int start_brightness, int end_brightness, int step); + int (*set_powersaving_mode) (int enable); } syscommon_plugin_backend_deviced_display_funcs; #ifdef __cplusplus diff --git a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h index 652d383..6686634 100644 --- a/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h +++ b/src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h @@ -126,6 +126,13 @@ int syscommon_plugin_deviced_display_set_brightness(int brightness); int syscommon_plugin_deviced_display_set_brightness_smooth(int start_brightness, int end_brightness, int step); +/** + * @breif Plugin implementation for setting powersaving mode + * @param[in] enable Value for enabling or disabling powersaving mode + * @return @c 0 on success, otherwise a negative error value + */ +int syscommon_plugin_deviced_display_set_powersaving_mode(int enable); + #ifdef __cplusplus } #endif diff --git a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c index 9f02993..8af2b71 100644 --- a/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c +++ b/src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c @@ -290,3 +290,22 @@ int syscommon_plugin_deviced_display_set_brightness_smooth(int start_brightness, return g_display_funcs->set_brightness_smooth(start_brightness, end_brightness, step); } + +EXPORT +int syscommon_plugin_deviced_display_set_powersaving_mode(int enable) +{ + int ret = 0; + + if (!g_display_funcs) { + ret = syscommon_plugin_deviced_display_get_backend(); + if (ret < 0) + return -ENOTSUP; + } + + assert(g_display_funcs); + + if (!g_display_funcs->set_powersaving_mode) + return -EOPNOTSUPP; + + return g_display_funcs->set_powersaving_mode(enable); +} diff --git a/tests/plugin-api/deviced/test-plugin-display.c b/tests/plugin-api/deviced/test-plugin-display.c index b57b07c..d11781b 100644 --- a/tests/plugin-api/deviced/test-plugin-display.c +++ b/tests/plugin-api/deviced/test-plugin-display.c @@ -107,6 +107,13 @@ static int set_brightness_smooth(int start_brightness, int end_brightness, int s return 0; } +static int set_powersaving_mode(int enable) +{ + check_expected(enable); + + return 0; +} + static syscommon_plugin_backend_deviced_display_funcs g_display_funcs = { .load_display_config = load_display_config, .on_changed_setting_value = on_changed_setting_value, @@ -119,6 +126,7 @@ static syscommon_plugin_backend_deviced_display_funcs g_display_funcs = { .get_brightness = get_brightness, .set_brightness = set_brightness, .set_brightness_smooth = set_brightness_smooth, + .set_powersaving_mode = set_powersaving_mode, }; static int deviced_display_init(void **data) diff --git a/tests/plugin-api/deviced/test.c b/tests/plugin-api/deviced/test.c index ad98bc0..4422b6f 100644 --- a/tests/plugin-api/deviced/test.c +++ b/tests/plugin-api/deviced/test.c @@ -140,6 +140,16 @@ static void test_set_brightness_smooth(void **data) assert_int_equal(ret, 0); } +static void test_set_powersaving_mode(void **state) +{ + int ret; + + expect_value(set_powersaving_mode, enable, true); + + ret = syscommon_plugin_deviced_display_set_powersaving_mode(true); + assert_int_equal(ret, 0); +} + static const struct CMUnitTest testsuite_plugin_api_deviced[] = { cmocka_unit_test(test_notify_setting_value_changed), cmocka_unit_test(test_lcd_on_procedure), @@ -151,5 +161,6 @@ static const struct CMUnitTest testsuite_plugin_api_deviced[] = { cmocka_unit_test(test_get_brightness), cmocka_unit_test(test_set_brightness), cmocka_unit_test(test_set_brightness_smooth), + cmocka_unit_test(test_set_powersaving_mode), }; TESTSUITE_FIXTURE(testsuite_plugin_api_deviced, setup_plugin_deviced, teardown_plugin_deviced)