]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
drm/tilcdc: Add tilcdc_crtc_atomic_check()
authorJyri Sarha <jsarha@ti.com>
Thu, 7 Apr 2016 12:10:23 +0000 (15:10 +0300)
committerJyri Sarha <jsarha@ti.com>
Mon, 8 Aug 2016 20:05:04 +0000 (23:05 +0300)
Add tilcdc_crtc_atomic_check(). Checks the display mode validity and
the presence of the mandatory primary plane.

The drm_crtc_helper_funcs mode_fixup() callback is left untouched and
the check function does no try to do its job on purpose, despite what
the mode_fixup() callback's documentations suggests.

The plane's check() callback needs to set drm_crtc_state's
->mode_changed to true if the pixel format for the framebuffer
changes. Because of this drm_mode_config_funcs atomic_check() callback
needs to call drm_atomic_helper_check_modeset() once more after it has
called drm_atomic_helper_check_planes(). If the fixing of the
adjusted_mode would be done in drm_crtc_helper_funcs atomic_check()
callback, it would get over written by the extra
drm_atomic_helper_check_modeset() call.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
drivers/gpu/drm/tilcdc/tilcdc_crtc.c

index eae002050f8016be931de4c6010d3c22f0217f7c..3e272f97392943f878fee2a09dc9f4c0eb538d12 100644 (file)
@@ -474,6 +474,32 @@ static void tilcdc_crtc_mode_set_nofb(struct drm_crtc *crtc)
        crtc->hwmode = crtc->state->adjusted_mode;
 }
 
+static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
+                                   struct drm_crtc_state *state)
+{
+       struct drm_display_mode *mode = &state->mode;
+       int ret;
+
+       /* If we are not active we don't care */
+       if (!state->active)
+               return 0;
+
+       if (state->state->planes[0].ptr != crtc->primary ||
+           state->state->planes[0].state == NULL ||
+           state->state->planes[0].state->crtc != crtc) {
+               dev_dbg(crtc->dev->dev, "CRTC primary plane must be present");
+               return -EINVAL;
+       }
+
+       ret = tilcdc_crtc_mode_valid(crtc, mode);
+       if (ret) {
+               dev_dbg(crtc->dev->dev, "Mode \"%s\" not valid", mode->name);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static int tilcdc_crtc_mode_set(struct drm_crtc *crtc,
                struct drm_display_mode *mode,
                struct drm_display_mode *adjusted_mode,
@@ -690,6 +716,7 @@ static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
                .commit         = tilcdc_crtc_commit,
                .mode_set       = tilcdc_crtc_mode_set,
                .mode_set_base  = tilcdc_crtc_mode_set_base,
+               .atomic_check   = tilcdc_crtc_atomic_check,
                .mode_set_nofb  = tilcdc_crtc_mode_set_nofb,
 };