]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
drm: xlnx: pl_disp: Added plane atomic check function
authorVenkateshwar Rao Gannavarapu <venkateshwar.rao.gannavarapu@xilinx.com>
Tue, 9 Apr 2019 19:17:57 +0000 (12:17 -0700)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 10 Apr 2019 09:06:59 +0000 (11:06 +0200)
This patch adds the atomic check helper function to update mode
changed flag and returns error when framebuffer remove functionality
forces to commit without disable crtc.

Without this patch, new DRM framework commits without disable crtc
which leads image corruption and delay in consecutive runs.

Signed-off-by: Venkateshwar Rao Gannavarapu <venkateshwar.rao.gannavarapu@xilinx.com>
Reviewed-by: Hyun Kwon <hyun.kwon@xilinx.com>
drivers/gpu/drm/xlnx/xlnx_pl_disp.c

index cf3f4cbe45b93e4d76362e626320a42c12816eb3..a4de9b31a717e8f10c35c043e59a54d5af872cd5 100644 (file)
@@ -284,9 +284,43 @@ static void xlnx_pl_disp_plane_atomic_update(struct drm_plane *plane,
        xlnx_pl_disp_plane_enable(plane);
 }
 
+static int
+xlnx_pl_disp_plane_atomic_check(struct drm_plane *plane,
+                               struct drm_plane_state *new_plane_state)
+{
+       struct drm_atomic_state *state = new_plane_state->state;
+       const struct drm_plane_state *old_plane_state =
+               drm_atomic_get_old_plane_state(state, plane);
+       struct drm_crtc *crtc = new_plane_state->crtc ?: old_plane_state->crtc;
+       const struct drm_crtc_state *old_crtc_state;
+       struct drm_crtc_state *new_crtc_state;
+
+       if (!crtc)
+               return 0;
+
+       old_crtc_state = drm_atomic_get_old_crtc_state(state, crtc);
+       new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
+
+       /* plane must be enabled when state is active */
+       if (new_crtc_state->active && !new_plane_state->crtc)
+               return -EINVAL;
+
+       /*
+        * This check is required to call modeset if there is a change in color
+        * format
+        */
+       if (new_plane_state->fb && old_plane_state->fb &&
+           new_plane_state->fb->format->format !=
+           old_plane_state->fb->format->format)
+               new_crtc_state->mode_changed = true;
+
+       return 0;
+}
+
 static const struct drm_plane_helper_funcs xlnx_pl_disp_plane_helper_funcs = {
        .atomic_update = xlnx_pl_disp_plane_atomic_update,
        .atomic_disable = xlnx_pl_disp_plane_atomic_disable,
+       .atomic_check = xlnx_pl_disp_plane_atomic_check,
 };
 
 static struct drm_plane_funcs xlnx_pl_disp_plane_funcs = {