]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/simple-kms: Support custom CRTC state
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 14 Jul 2021 14:22:38 +0000 (16:22 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Sun, 8 Aug 2021 18:14:08 +0000 (20:14 +0200)
Simple KMS helpers already support custom state for planes. Extend the
helpers to support custom CRTC state as well. Drivers can set the reset,
duplicate and destroy callbacks for the display pipeline's CRTC state
and inherit from struct drm_crtc_state by embedding an instance.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210714142240.21979-12-tzimmermann@suse.de
drivers/gpu/drm/drm_simple_kms_helper.c
include/drm/drm_simple_kms_helper.h

index 735f4f34bcc439dad5e1ada4d625d46ba99f1b3c..72989ed1babae5cd37556b72c739156e1c12d70c 100644 (file)
@@ -145,6 +145,39 @@ static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = {
        .atomic_disable = drm_simple_kms_crtc_disable,
 };
 
+static void drm_simple_kms_crtc_reset(struct drm_crtc *crtc)
+{
+       struct drm_simple_display_pipe *pipe;
+
+       pipe = container_of(crtc, struct drm_simple_display_pipe, crtc);
+       if (!pipe->funcs || !pipe->funcs->reset_crtc)
+               return drm_atomic_helper_crtc_reset(crtc);
+
+       return pipe->funcs->reset_crtc(pipe);
+}
+
+static struct drm_crtc_state *drm_simple_kms_crtc_duplicate_state(struct drm_crtc *crtc)
+{
+       struct drm_simple_display_pipe *pipe;
+
+       pipe = container_of(crtc, struct drm_simple_display_pipe, crtc);
+       if (!pipe->funcs || !pipe->funcs->duplicate_crtc_state)
+               return drm_atomic_helper_crtc_duplicate_state(crtc);
+
+       return pipe->funcs->duplicate_crtc_state(pipe);
+}
+
+static void drm_simple_kms_crtc_destroy_state(struct drm_crtc *crtc, struct drm_crtc_state *state)
+{
+       struct drm_simple_display_pipe *pipe;
+
+       pipe = container_of(crtc, struct drm_simple_display_pipe, crtc);
+       if (!pipe->funcs || !pipe->funcs->destroy_crtc_state)
+               drm_atomic_helper_crtc_destroy_state(crtc, state);
+       else
+               pipe->funcs->destroy_crtc_state(pipe, state);
+}
+
 static int drm_simple_kms_crtc_enable_vblank(struct drm_crtc *crtc)
 {
        struct drm_simple_display_pipe *pipe;
@@ -168,12 +201,12 @@ static void drm_simple_kms_crtc_disable_vblank(struct drm_crtc *crtc)
 }
 
 static const struct drm_crtc_funcs drm_simple_kms_crtc_funcs = {
-       .reset = drm_atomic_helper_crtc_reset,
+       .reset = drm_simple_kms_crtc_reset,
        .destroy = drm_crtc_cleanup,
        .set_config = drm_atomic_helper_set_config,
        .page_flip = drm_atomic_helper_page_flip,
-       .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
-       .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+       .atomic_duplicate_state = drm_simple_kms_crtc_duplicate_state,
+       .atomic_destroy_state = drm_simple_kms_crtc_destroy_state,
        .enable_vblank = drm_simple_kms_crtc_enable_vblank,
        .disable_vblank = drm_simple_kms_crtc_disable_vblank,
 };
index cf07132d4ee8657d264fe621d94d8ea658e6ecfd..0b3647e614dd39fb6e7e91810a69d6f90f904bcf 100644 (file)
@@ -153,6 +153,33 @@ struct drm_simple_display_pipe_funcs {
         */
        void (*disable_vblank)(struct drm_simple_display_pipe *pipe);
 
+       /**
+        * @reset_crtc:
+        *
+        * Optional, called by &drm_crtc_funcs.reset. Please read the
+        * documentation for the &drm_crtc_funcs.reset hook for more details.
+        */
+       void (*reset_crtc)(struct drm_simple_display_pipe *pipe);
+
+       /**
+        * @duplicate_crtc_state:
+        *
+        * Optional, called by &drm_crtc_funcs.atomic_duplicate_state. Please
+        * read the documentation for the &drm_crtc_funcs.atomic_duplicate_state
+        * hook for more details.
+        */
+       struct drm_crtc_state * (*duplicate_crtc_state)(struct drm_simple_display_pipe *pipe);
+
+       /**
+        * @destroy_crtc_state:
+        *
+        * Optional, called by &drm_crtc_funcs.atomic_destroy_state. Please
+        * read the documentation for the &drm_crtc_funcs.atomic_destroy_state
+        * hook for more details.
+        */
+       void (*destroy_crtc_state)(struct drm_simple_display_pipe *pipe,
+                                  struct drm_crtc_state *crtc_state);
+
        /**
         * @reset_plane:
         *