drm/amd/display: Make cursor source translation adjustment optional
authorNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Sun, 5 Apr 2020 20:41:08 +0000 (16:41 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 9 Apr 2020 14:43:17 +0000 (10:43 -0400)
[Why]
In some usecases, like tiled display, the stream and plane configuration
can be setup in a way where the caller expects DAL to perform the
clipping, eg:

P0:
src_rect(0, 0, w, h)
dst_rect(0, 0, w, h)

P1:
src_rect(w, 0, w, h)
dst_rect(0, 0, w, h)

Cursor is enabled on both streams with the same position.

This can result in double cursor on tiled display, even though this
behavior is technically correct from the DC interface point of view.

We need a mechanism to control this dynamically.

[How]
This is something that should live in the DM layer based on detection
of the specified configuration but it's not something that we really
have enough information to deal with today.

Add a flag to the cursor position state that specifies whether we
want DC to do the translation or not and make it opt-in and let
the DM decide when to do it.

Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/dc/dc_hw_types.h
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c

index da7830294fdd3b077c81921470182083c328df1e..548a12836c72987a03088c5597a0738b1ff9c530 100644 (file)
@@ -6282,6 +6282,7 @@ static int get_cursor_position(struct drm_plane *plane, struct drm_crtc *crtc,
                y = 0;
        }
        position->enable = true;
+       position->translate_by_source = true;
        position->x = x;
        position->y = y;
        position->x_hotspot = xorigin;
index 25c50bcab9e962d43bd65ca2866f8d438c9b46c8..a8dc3082e3e1e891d09d2b61e2037e1c6bf681c3 100644 (file)
@@ -385,6 +385,8 @@ struct dc_cursor_position {
         */
        bool enable;
 
+       /* Translate cursor x/y by the source rectangle for each plane. */
+       bool translate_by_source;
 };
 
 struct dc_cursor_mi_param {
index 67f7ca3466965c6045d423521b402d880c2ce644..c279982947e10ae7cb020485ae850f531a81a1dd 100644 (file)
@@ -2692,9 +2692,15 @@ void dce110_set_cursor_position(struct pipe_ctx *pipe_ctx)
         *
         * This translation isn't affected by scaling so it needs to be
         * done *after* we adjust the position for the scale factor.
+        *
+        * This is only done by opt-in for now since there are still
+        * some usecases like tiled display that might enable the
+        * cursor on both streams while expecting dc to clip it.
         */
-       pos_cpy.x += pipe_ctx->plane_state->src_rect.x;
-       pos_cpy.y += pipe_ctx->plane_state->src_rect.y;
+       if (pos_cpy.translate_by_source) {
+               pos_cpy.x += pipe_ctx->plane_state->src_rect.x;
+               pos_cpy.y += pipe_ctx->plane_state->src_rect.y;
+       }
 
        if (pipe_ctx->plane_state->address.type
                        == PLN_ADDR_TYPE_VIDEO_PROGRESSIVE)
index 9ef5747e5077f4e13fafe9f675f001d43d01f6f4..9f41efddc9bc5b817eec6653cc7ed1da3768495d 100644 (file)
@@ -3095,9 +3095,15 @@ void dcn10_set_cursor_position(struct pipe_ctx *pipe_ctx)
         *
         * This translation isn't affected by scaling so it needs to be
         * done *after* we adjust the position for the scale factor.
+        *
+        * This is only done by opt-in for now since there are still
+        * some usecases like tiled display that might enable the
+        * cursor on both streams while expecting dc to clip it.
         */
-       x_pos += pipe_ctx->plane_state->src_rect.x;
-       y_pos += pipe_ctx->plane_state->src_rect.y;
+       if (pos_cpy.translate_by_source) {
+               x_pos += pipe_ctx->plane_state->src_rect.x;
+               y_pos += pipe_ctx->plane_state->src_rect.y;
+       }
 
        /**
         * If the position is negative then we need to add to the hotspot