display: Move get_brightness_by_light_sensor function from plugin to core display... 06/288906/8
authorYunhee Seo <yuni.seo@samsung.com>
Fri, 24 Feb 2023 02:31:19 +0000 (11:31 +0900)
committeryunhee <yuni.seo@samsung.com>
Mon, 20 Mar 2023 08:01:46 +0000 (17:01 +0900)
Remove and redefine get_brightness_by_light_sensor function.
This function is added to below display-backlight.

int display_backlight_get_brightness_by_light_sensor(float lmax, float lmin,
float light, int *brightness)
-> This function replaces get_brightness_by_light_sensor function located in plugins.

Change-Id: Ibe17d746276c2f2ca3ba7b233c88c259471aaebe
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
plugins/iot-headed/display/device-interface.c
plugins/mobile/display/device-interface.c
plugins/tv/display/device-interface.c
plugins/wearable/display/device-interface.c
src/display/auto-brightness.c
src/display/device-interface.h
src/display/display-backlight.c
src/display/display-backlight.h

index 806512a..1648dd2 100644 (file)
@@ -274,33 +274,6 @@ static int get_brightness(int *val)
        return 0;
 }
 
-static int get_brightness_by_light_sensor(float lmax, float lmin, float light, int *brt)
-{
-       int brt_raw;
-       int ret;
-
-       if (!display_dev_available)
-               return -ENOTSUP;
-
-       ret = hal_device_display_get_auto_brightness(lmax, lmin, light, &brt_raw);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Get auto brightness is not supported.");
-               else
-                       _E("Failed to get brightness by light sensor: %d", ret);
-
-               return ret;
-       }
-
-       ret = display_backlight_get_normalized_brightness(brt_raw, brt);
-       if (ret < 0) {
-               _E("Failed to get normalized brightness.");
-               return ret;
-       }
-
-       return 0;
-}
-
 /* It was operated only AOD enter & leave */
 static int backlight_transit_state(int state)
 {
@@ -406,7 +379,6 @@ static struct _backlight_ops backlight_ops = {
        .set_brightness = set_brightness,
        .get_brightness = get_brightness,
        .restore_brightness_func = restore_brightness_func,
-       .get_brightness_by_light_sensor = get_brightness_by_light_sensor,
        .transit_state = backlight_transit_state,
        .transit_brt = change_brightness,
        .blink = blink,
index 6985f4d..0d5ea50 100644 (file)
@@ -273,33 +273,6 @@ static int get_brightness(int *val)
        return 0;
 }
 
-static int get_brightness_by_light_sensor(float lmax, float lmin, float light, int *brt)
-{
-       int brt_raw;
-       int ret;
-
-       if (!display_dev_available)
-               return -ENOTSUP;
-
-       ret = hal_device_display_get_auto_brightness(lmax, lmin, light, &brt_raw);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Get auto brightness is not supported.");
-               else
-                       _E("Failed to get brightness by light sensor: %d", ret);
-
-               return ret;
-       }
-
-       ret = display_backlight_get_normalized_brightness(brt_raw, brt);
-       if (ret < 0) {
-               _E("Failed to get normalized brightness.");
-               return ret;
-       }
-
-       return 0;
-}
-
 /* It was operated only AOD enter & leave */
 static int backlight_transit_state(int state)
 {
@@ -405,7 +378,6 @@ static struct _backlight_ops backlight_ops = {
        .set_brightness = set_brightness,
        .get_brightness = get_brightness,
        .restore_brightness_func = restore_brightness_func,
-       .get_brightness_by_light_sensor = get_brightness_by_light_sensor,
        .transit_state = backlight_transit_state,
        .transit_brt = change_brightness,
        .blink = blink,
index 1fd9534..c4f60e7 100644 (file)
@@ -274,33 +274,6 @@ static int get_brightness(int *val)
        return 0;
 }
 
-static int get_brightness_by_light_sensor(float lmax, float lmin, float light, int *brt)
-{
-       int brt_raw;
-       int ret;
-
-       if (!display_dev_available)
-               return -ENOTSUP;
-
-       ret = hal_device_display_get_auto_brightness(lmax, lmin, light, &brt_raw);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Get auto brightness is not supported.");
-               else
-                       _E("Failed to get brightness by light sensor: %d", ret);
-
-               return ret;
-       }
-
-       ret = display_backlight_get_normalized_brightness(brt_raw, brt);
-       if (ret < 0) {
-               _E("Failed to get normalized brightness.");
-               return ret;
-       }
-
-       return 0;
-}
-
 /* It was operated only AOD enter & leave */
 static int backlight_transit_state(int state)
 {
@@ -406,7 +379,6 @@ static struct _backlight_ops backlight_ops = {
        .set_brightness = set_brightness,
        .get_brightness = get_brightness,
        .restore_brightness_func = restore_brightness_func,
-       .get_brightness_by_light_sensor = get_brightness_by_light_sensor,
        .transit_state = backlight_transit_state,
        .transit_brt = change_brightness,
        .blink = blink,
index 7acfe2a..11a7c4a 100644 (file)
@@ -286,33 +286,6 @@ static int get_brightness(int *val)
        return 0;
 }
 
-static int get_brightness_by_light_sensor(float lmax, float lmin, float light, int *brt)
-{
-       int brt_raw;
-       int ret;
-
-       if (!display_dev_available)
-               return -ENOTSUP;
-
-       ret = hal_device_display_get_auto_brightness(lmax, lmin, light, &brt_raw);
-       if (ret < 0) {
-               if (ret == -ENODEV)
-                       _E("Get auto brightness is not supported.");
-               else
-                       _E("Failed to get brightness by light sensor: %d", ret);
-
-               return ret;
-       }
-
-       ret = display_backlight_get_normalized_brightness(brt_raw, brt);
-       if (ret < 0) {
-               _E("Failed to get normalized brightness.");
-               return ret;
-       }
-
-       return 0;
-}
-
 /* It was operated only AOD enter & leave */
 static int backlight_transit_state(int state)
 {
@@ -471,7 +444,6 @@ static struct _backlight_ops backlight_ops = {
        .set_brightness = set_brightness,
        .get_brightness = get_brightness,
        .restore_brightness_func = restore_brightness_func,
-       .get_brightness_by_light_sensor = get_brightness_by_light_sensor,
        .transit_state = backlight_transit_state,
        .transit_brt = change_brightness,
        .blink = blink,
index cdae274..393794f 100644 (file)
@@ -193,7 +193,7 @@ static bool alc_update_brt(bool setting)
        }
 
        light = light_data.values[index];
-       ret = backlight_ops->get_brightness_by_light_sensor(
+       ret = display_backlight_get_brightness_by_light_sensor(
                        lmax, lmin, light, &value);
        if (ret == -ENOTSUP) {
                _E("Not supported to handle the light data.");
index 389fab7..034f133 100644 (file)
@@ -68,7 +68,6 @@ struct _backlight_ops {
        int (*get_brightness)(int *val);
        int (*get_brightness_raw)(int *val);
        void (*restore_brightness_func)(void);
-       int (*get_brightness_by_light_sensor)(float lmax, float lmin, float light, int *brt);
        int (*transit_state)(int state);
        void (*transit_brt)(int start, int end, int step);
        void (*blink)(int timeout);
index 9271033..a112d16 100644 (file)
@@ -193,6 +193,33 @@ void display_backlight_get_custom_status(bool *on)
        *on = g_custom_status;
 }
 
+/* FIXME: This function is not tested */
+int display_backlight_get_brightness_by_light_sensor(float lmax, float lmin,
+                                                       float light, int *brightness)
+{
+       int raw_brightness, ret = 0;
+
+       if (!display_is_hal_backend_available())
+               return -ENOTSUP;
+
+       ret = hal_device_display_get_auto_brightness(lmax, lmin, light, &raw_brightness);
+       if (ret < 0) {
+               if (ret == -ENODEV)
+                       _E("Get auto brightness is not supported.");
+               else
+                       _E("Failed to get brightness by light sensor: %d", ret);
+               return ret;
+       }
+
+       ret = display_backlight_get_normalized_brightness(raw_brightness, brightness);
+       if (ret < 0) {
+               _E("Failed to get normalized brightness.");
+               return ret;
+       }
+
+       return 0;
+}
+
 /* FIXME: This code structure should be changed to plugin api call, after plugin refactoting*/
 static void __CONSTRUCTOR__ initialize(void)
 {
index 61e315a..9c7e5c3 100644 (file)
@@ -30,5 +30,7 @@ void display_backlight_set_custom_status(bool on);
 void display_backlight_get_custom_status(bool *on);
 void display_backlight_set_custom_brightness(int brightness);
 int display_backlight_update_by_custom_brightness(void);
+int display_backlight_get_brightness_by_light_sensor(float lmax, float lmin,
+                                                       float light, int *brightness);
 
 #endif /* __DISPLAY_BACKLIGHT_H__ */
\ No newline at end of file