plugin-api: deviced: Add interface for controlling display powersaving mode 15/313315/1
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 17 Jun 2024 09:05:28 +0000 (18:05 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 24 Jun 2024 02:13:19 +0000 (11:13 +0900)
Change-Id: I9f749cb7fe30bfd814de4b12c545554dee1eae2b
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display-interface.h
src/plugin-api/deviced/include/system/syscommon-plugin-deviced-display.h
src/plugin-api/deviced/src/syscommon-plugin-deviced-display.c
tests/plugin-api/deviced/test-plugin-display.c
tests/plugin-api/deviced/test.c

index 21dc8a4fe4bbaeea9abb5f0289cd721b165a0a06..b1c5d7c896cf8b11327de7a53692734dde0bcce6 100644 (file)
@@ -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
index 652d38364856bc879da2b85dcda6adce20bf3908..66866345302327fc1ea4bafd57e75afd465645b5 100644 (file)
@@ -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
index 9f029934fbc410ddcbe102ad4f5441fae420d667..8af2b7199438f8432650d4783e1be5e20aefb9a4 100644 (file)
@@ -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);
+}
index b57b07ca7bc4533e0807de26a1828e2f65309d3a..d11781b5f5ca3db0949a47f86c66893baaf54bea 100644 (file)
@@ -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)
index ad98bc00283832ea783ee63a04f3767a50693e90..4422b6f865033ea9cd3694a15395896a75f99c29 100644 (file)
@@ -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)