drm/sun4i: engine: Add a custom crtc atomic_check
authorMaxime Ripard <maxime.ripard@free-electrons.com>
Mon, 22 Jan 2018 09:25:19 +0000 (10:25 +0100)
committerMaxime Ripard <maxime.ripard@free-electrons.com>
Mon, 22 Jan 2018 14:15:03 +0000 (15:15 +0100)
We have some restrictions on what the planes and CRTC can provide that are
tied to only one generation of display engines.

For example, on the first generation, we can only have one YUV plane or one
plane that uses the frontend output.

Let's allow our engines to provide an atomic_check callback to validate the
current configuration.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Link: https://patchwork.freedesktop.org/patch/msgid/e5f5f144e5c20d348cdb29933ae876c105bec017.1516613040.git-series.maxime.ripard@free-electrons.com
drivers/gpu/drm/sun4i/sun4i_crtc.c
drivers/gpu/drm/sun4i/sunxi_engine.h

index 5decae0069d0bfda0f45a0c78ea033f1186282c6..2a565325714fd23e5b0e34c334a6ebb4cf4d60a3 100644 (file)
@@ -46,6 +46,19 @@ static struct drm_encoder *sun4i_crtc_get_encoder(struct drm_crtc *crtc)
        return NULL;
 }
 
+static int sun4i_crtc_atomic_check(struct drm_crtc *crtc,
+                                   struct drm_crtc_state *state)
+{
+       struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
+       struct sunxi_engine *engine = scrtc->engine;
+       int ret = 0;
+
+       if (engine && engine->ops && engine->ops->atomic_check)
+               ret = engine->ops->atomic_check(engine, state);
+
+       return ret;
+}
+
 static void sun4i_crtc_atomic_begin(struct drm_crtc *crtc,
                                    struct drm_crtc_state *old_state)
 {
@@ -125,6 +138,7 @@ static void sun4i_crtc_mode_set_nofb(struct drm_crtc *crtc)
 }
 
 static const struct drm_crtc_helper_funcs sun4i_crtc_helper_funcs = {
+       .atomic_check   = sun4i_crtc_atomic_check,
        .atomic_begin   = sun4i_crtc_atomic_begin,
        .atomic_flush   = sun4i_crtc_atomic_flush,
        .atomic_enable  = sun4i_crtc_atomic_enable,
index b374e074c7c304382b526f0541f99977c6585c3c..b819d4f9f02f55351d6974474b715a9bb0b96870 100644 (file)
@@ -22,6 +22,23 @@ struct sunxi_engine;
  * implement the proper behaviour.
  */
 struct sunxi_engine_ops {
+       /**
+        * @atomic_check:
+        *
+        * This callback allows to validate plane-update related CRTC
+        * constraints specific to engines. This is mirroring the
+        * &drm_crtc_helper_funcs.atomic_check callback, so any
+        * documentation there applies.
+        *
+        * This function is optional.
+        *
+        * RETURNS:
+        *
+        * 0 on success or a negative error code.
+        */
+       int (*atomic_check)(struct sunxi_engine *engine,
+                           struct drm_crtc_state *state);
+
        /**
         * @commit:
         *