drm/amd/display: Add HW rotation cursor changes to dcn10
authorJaehyun Chung <jaehyun.chung@amd.com>
Wed, 8 Apr 2020 19:02:58 +0000 (15:02 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 22 Apr 2020 22:11:48 +0000 (18:11 -0400)
[Why]
HW rotation was enabled in DAL3 but hubp cursor calculations for HW roation
were only added to dcn20.

[How]
Add hubp cursor position calculation changes to dcn10.

Signed-off-by: Jaehyun Chung <jaehyun.chung@amd.com>
Reviewed-by: Yongqiang Sun <yongqiang.sun@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c

index 31b64733d693576b23e751616b5be1c8c34fed7e..319366ebb44fe4f8e1521c842e05e1cc5340aae1 100644 (file)
@@ -1139,6 +1139,8 @@ void hubp1_cursor_set_position(
        int src_y_offset = pos->y - pos->y_hotspot - param->viewport.y;
        int x_hotspot = pos->x_hotspot;
        int y_hotspot = pos->y_hotspot;
+       int cursor_height = (int)hubp->curs_attr.height;
+       int cursor_width = (int)hubp->curs_attr.width;
        uint32_t dst_x_offset;
        uint32_t cur_en = pos->enable ? 1 : 0;
 
@@ -1152,10 +1154,16 @@ void hubp1_cursor_set_position(
        if (hubp->curs_attr.address.quad_part == 0)
                return;
 
+       // Rotated cursor width/height and hotspots tweaks for offset calculation
        if (param->rotation == ROTATION_ANGLE_90 || param->rotation == ROTATION_ANGLE_270) {
-               src_x_offset = pos->y - pos->y_hotspot - param->viewport.x;
-               y_hotspot = pos->x_hotspot;
-               x_hotspot = pos->y_hotspot;
+               swap(cursor_height, cursor_width);
+               if (param->rotation == ROTATION_ANGLE_90) {
+                       src_x_offset = pos->x - pos->y_hotspot - param->viewport.x;
+                       src_y_offset = pos->y - pos->x_hotspot - param->viewport.y;
+               }
+       } else if (param->rotation == ROTATION_ANGLE_180) {
+               src_x_offset = pos->x - param->viewport.x;
+               src_y_offset = pos->y - param->viewport.y;
        }
 
        if (param->mirror) {
@@ -1177,13 +1185,13 @@ void hubp1_cursor_set_position(
        if (src_x_offset >= (int)param->viewport.width)
                cur_en = 0;  /* not visible beyond right edge*/
 
-       if (src_x_offset + (int)hubp->curs_attr.width <= 0)
+       if (src_x_offset + cursor_width <= 0)
                cur_en = 0;  /* not visible beyond left edge*/
 
        if (src_y_offset >= (int)param->viewport.height)
                cur_en = 0;  /* not visible beyond bottom edge*/
 
-       if (src_y_offset + (int)hubp->curs_attr.height <= 0)
+       if (src_y_offset + cursor_height <= 0)
                cur_en = 0;  /* not visible beyond top edge*/
 
        if (cur_en && REG_READ(CURSOR_SURFACE_ADDRESS) == 0)