drm/atomic: Add ->atomic_check() to encoder helpers
authorThierry Reding <treding@nvidia.com>
Wed, 3 Dec 2014 15:44:34 +0000 (16:44 +0100)
committerThierry Reding <treding@nvidia.com>
Tue, 27 Jan 2015 09:14:42 +0000 (10:14 +0100)
This callback can be used instead of the legacy ->mode_fixup() and is
passed the CRTC and connector states. It can thus use these states to
validate the modeset and cache values in the state to be used during
the actual modeset.

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/drm/drm_atomic_helper.c
include/drm/drm_crtc_helper.h

index af5f539ed1474d9735a9a6f53bb1695734271d6b..24c44c24dabe6de55830838109dc65b534411b14 100644 (file)
@@ -297,13 +297,22 @@ mode_fixup(struct drm_atomic_state *state)
                        }
                }
 
-
-               ret = funcs->mode_fixup(encoder, &crtc_state->mode,
-                                       &crtc_state->adjusted_mode);
-               if (!ret) {
-                       DRM_DEBUG_KMS("[ENCODER:%d:%s] fixup failed\n",
-                                     encoder->base.id, encoder->name);
-                       return -EINVAL;
+               if (funcs->atomic_check) {
+                       ret = funcs->atomic_check(encoder, crtc_state,
+                                                 conn_state);
+                       if (ret) {
+                               DRM_DEBUG_KMS("[ENCODER:%d:%s] check failed\n",
+                                             encoder->base.id, encoder->name);
+                               return ret;
+                       }
+               } else {
+                       ret = funcs->mode_fixup(encoder, &crtc_state->mode,
+                                               &crtc_state->adjusted_mode);
+                       if (!ret) {
+                               DRM_DEBUG_KMS("[ENCODER:%d:%s] fixup failed\n",
+                                             encoder->base.id, encoder->name);
+                               return -EINVAL;
+                       }
                }
        }
 
index e76828d81a8bfab4c9c2fe0c3eb9c0323af2957c..5810c027acdcf4b35e5dd312e856c9d6846ed134 100644 (file)
@@ -115,6 +115,7 @@ struct drm_crtc_helper_funcs {
  * @get_crtc: return CRTC that the encoder is currently attached to
  * @detect: connection status detection
  * @disable: disable encoder when not in use (overrides DPMS off)
+ * @atomic_check: check for validity of an atomic update
  *
  * The helper operations are called by the mid-layer CRTC helper.
  */
@@ -137,6 +138,11 @@ struct drm_encoder_helper_funcs {
                                            struct drm_connector *connector);
        /* disable encoder when not in use - more explicit than dpms off */
        void (*disable)(struct drm_encoder *encoder);
+
+       /* atomic helpers */
+       int (*atomic_check)(struct drm_encoder *encoder,
+                           struct drm_crtc_state *crtc_state,
+                           struct drm_connector_state *conn_state);
 };
 
 /**