display: Add rotation angle API 49/285949/1 accepted/tizen/7.0/unified/20221226.131619 accepted/tizen/7.0/unified/20221226.172023 accepted/tizen/7.0/unified/20221227.024852
authorTaeminYeom <taemin.yeom@samsung.com>
Thu, 29 Sep 2022 04:52:00 +0000 (13:52 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 23 Dec 2022 02:44:16 +0000 (11:44 +0900)
rotation angle means "physical display" angle.
Clients can rotate display or check current display angle.

API
-hal_device_display_get_rotation_angle
-hal_device_display_set_rotation_angle

enum
-hal_device_display_rotation_angle
HAL_DEVICE_DISPLAY_ROTATION_ANGLE_UNKNOWN : It can be seen in laid device
HAL_DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_0 : Initial display rotation angle
HAL_DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_90 : 90° rotation angle
HAL_DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_180 : 180° rotation angle
HAL_DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_270 : 270° rotation angle
HAL_DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_360 : 360° rotation angle

-hal_device_display_rotation_direction
HAL_DEVICE_DISPLAY_ROTATION_DIRECTION_CLOCKWISE : Rotate clockwise direction
HAL_DEVICE_DISPLAY_ROTATION_DIRECTION_COUNTER_CLOCKWISE : Rotate counter clockwise direction

Change-Id: I617f42466218a0a7f579c5d331a818e534cf173c
Signed-off-by: TaeminYeom <taemin.yeom@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
include/backend/hal-display-interface.h
include/hal-display.h
src/display.c

index b297d10..cc4bc3a 100644 (file)
@@ -59,6 +59,20 @@ enum hal_display_white_balance {
        HAL_DISPLAY_WHITE_BALANCE_B_OFFSET,
 };
 
+enum hal_device_display_rotation_angle {
+       HAL_DEVICE_DISPLAY_ROTATION_ANGLE_UNKNOWN = -1,
+       HAL_DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_0 = 0,
+       HAL_DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_90 = 90,
+       HAL_DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_180 = 180,
+       HAL_DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_270 = 270,
+       HAL_DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_360 = 360,
+};
+
+enum hal_device_display_rotation_direction {
+       HAL_DEVICE_DISPLAY_ROTATION_DIRECTION_CLOCKWISE,
+       HAL_DEVICE_DISPLAY_ROTATION_DIRECTION_COUNTER_CLOCKWISE,
+};
+
 typedef struct _hal_backend_display_funcs {
        /* Control display brightness */
        int (*get_max_brightness)(int *brightness);
@@ -96,6 +110,10 @@ typedef struct _hal_backend_display_funcs {
        /* Control display white balance */
        int (*set_white_balance)(enum hal_display_white_balance, int value);
        int (*get_white_balance)(enum hal_display_white_balance, int *value);
+
+       /* Control display rotation angle */
+       int (*get_rotation_angle)(int display_index, enum hal_device_display_rotation_angle *angle);
+       int (*set_rotation_angle)(int display_index, enum hal_device_display_rotation_angle angle, enum hal_device_display_rotation_direction direction);
 } hal_backend_display_funcs;
 
 #ifdef __cplusplus
index 3f8dede..2f49bff 100644 (file)
@@ -45,6 +45,9 @@ int hal_device_display_get_frame_rate(int *rate);
 int hal_device_display_set_frame_rate(int rate);
 int hal_device_display_set_white_balance(enum hal_display_white_balance, int value);
 int hal_device_display_get_white_balance(enum hal_display_white_balance, int* value);
+int hal_device_display_get_rotation_angle(int display_index, enum hal_device_display_rotation_angle *angle);
+int hal_device_display_set_rotation_angle(int display_index, enum hal_device_display_rotation_angle angle,
+                                       enum hal_device_display_rotation_direction direction);
 
 #ifdef __cplusplus
 }
index ebb69fd..a2b311d 100644 (file)
@@ -359,4 +359,38 @@ int hal_device_display_get_white_balance(enum hal_display_white_balance white_ba
                return -ENODEV;
 
        return hal_display_funcs->get_white_balance(white_balance_type, value);
-}
\ No newline at end of file
+}
+
+int hal_device_display_get_rotation_angle(int display_index, enum hal_device_display_rotation_angle *angle)
+{
+       int ret;
+
+       if (!hal_display_funcs && !hal_initialized) {
+               if ((ret = hal_device_display_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_display_funcs ||
+           !hal_display_funcs->get_rotation_angle)
+               return -ENODEV;
+
+       return hal_display_funcs->get_rotation_angle(display_index, angle);
+}
+
+int hal_device_display_set_rotation_angle(int display_index,
+                                       enum hal_device_display_rotation_angle angle,
+                                       enum hal_device_display_rotation_direction direction)
+{
+       int ret;
+
+       if (!hal_display_funcs && !hal_initialized) {
+               if ((ret = hal_device_display_get_backend()) < 0)
+                       return ret;
+       }
+
+       if (!hal_display_funcs ||
+           !hal_display_funcs->set_rotation_angle)
+               return -ENODEV;
+
+       return hal_display_funcs->set_rotation_angle(display_index, angle, direction);
+}