drm/atomic: Extract needs_modeset function
diff mbox

Message ID 1434619527-8736-1-git-send-email-daniel.vetter@ffwll.ch
State New
Headers show

Commit Message

Daniel Vetter June 18, 2015, 9:25 a.m. UTC
We use the same check already in the atomic core, so might as well
make this official. And it's also reused in e.g. i915.

Motivated by Maarten's idea to extract a connector_changed state out
of mode_changed.

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_atomic.c        |  3 +--
 drivers/gpu/drm/drm_atomic_helper.c | 16 +++++-----------
 include/drm/drm_atomic.h            |  6 ++++++
 3 files changed, 12 insertions(+), 13 deletions(-)

Comments

Maarten Lankhorst June 19, 2015, 4:08 a.m. UTC | #1
Op 18-06-15 om 11:25 schreef Daniel Vetter:
> We use the same check already in the atomic core, so might as well
> make this official. And it's also reused in e.g. i915.
>
> Motivated by Maarten's idea to extract a connector_changed state out
> of mode_changed.
>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
>
Reviewed-By: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Daniel Vetter June 19, 2015, 3:26 p.m. UTC | #2
On Fri, Jun 19, 2015 at 06:08:08AM +0200, Maarten Lankhorst wrote:
> Op 18-06-15 om 11:25 schreef Daniel Vetter:
> > We use the same check already in the atomic core, so might as well
> > make this official. And it's also reused in e.g. i915.
> >
> > Motivated by Maarten's idea to extract a connector_changed state out
> > of mode_changed.
> >
> > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> >
> Reviewed-By: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

Thanks for the review, applied. For i915 I guess we could switch if we
want to, but perhaps only once we look into the connector_changed idea to
implement fastboot. Just to avoid needless churn.
-Daniel

Patch
diff mbox

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index c7e59b074e62..f6f2fb58eb37 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1216,8 +1216,7 @@  int drm_atomic_check_only(struct drm_atomic_state *state)
 
 	if (!state->allow_modeset) {
 		for_each_crtc_in_state(state, crtc, crtc_state, i) {
-			if (crtc_state->mode_changed ||
-			    crtc_state->active_changed) {
+			if (drm_atomic_crtc_needs_modeset(crtc_state)) {
 				DRM_DEBUG_ATOMIC("[CRTC:%d] requires full modeset\n",
 						 crtc->base.id);
 				return -EINVAL;
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 536ae4da4665..b06a607db6c2 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -331,12 +331,6 @@  mode_fixup(struct drm_atomic_state *state)
 	return 0;
 }
 
-static bool
-needs_modeset(struct drm_crtc_state *state)
-{
-	return state->mode_changed || state->active_changed;
-}
-
 /**
  * drm_atomic_helper_check_modeset - validate state object for modeset changes
  * @dev: DRM device
@@ -414,7 +408,7 @@  drm_atomic_helper_check_modeset(struct drm_device *dev,
 			crtc_state->active_changed = true;
 		}
 
-		if (!needs_modeset(crtc_state))
+		if (!drm_atomic_crtc_needs_modeset(crtc_state))
 			continue;
 
 		DRM_DEBUG_ATOMIC("[CRTC:%d] needs all connectors, enable: %c, active: %c\n",
@@ -564,7 +558,7 @@  disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 		old_crtc_state = old_state->crtc_states[drm_crtc_index(old_conn_state->crtc)];
 
 		if (!old_crtc_state->active ||
-		    !needs_modeset(old_conn_state->crtc->state))
+		    !drm_atomic_crtc_needs_modeset(old_conn_state->crtc->state))
 			continue;
 
 		encoder = old_conn_state->best_encoder;
@@ -601,7 +595,7 @@  disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
 		const struct drm_crtc_helper_funcs *funcs;
 
 		/* Shut down everything that needs a full modeset. */
-		if (!needs_modeset(crtc->state))
+		if (!drm_atomic_crtc_needs_modeset(crtc->state))
 			continue;
 
 		if (!old_crtc_state->active)
@@ -792,7 +786,7 @@  void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
 		const struct drm_crtc_helper_funcs *funcs;
 
 		/* Need to filter out CRTCs where only planes change. */
-		if (!needs_modeset(crtc->state))
+		if (!drm_atomic_crtc_needs_modeset(crtc->state))
 			continue;
 
 		if (!crtc->state->active)
@@ -819,7 +813,7 @@  void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
 			continue;
 
 		if (!connector->state->crtc->state->active ||
-		    !needs_modeset(connector->state->crtc->state))
+		    !drm_atomic_crtc_needs_modeset(connector->state->crtc->state))
 			continue;
 
 		encoder = connector->state->best_encoder;
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 1bbfedf466b9..8a3a913320eb 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -163,5 +163,11 @@  int __must_check drm_atomic_async_commit(struct drm_atomic_state *state);
 	     (plane_state) = (state)->plane_states[__i], 1);		\
 	     (__i)++)							\
 		if (plane_state)
+static inline bool
+drm_atomic_crtc_needs_modeset(struct drm_crtc_state *state)
+{
+	return state->mode_changed || state->active_changed;
+}
+
 
 #endif /* DRM_ATOMIC_H_ */