Commit 51ffa12d authored by Maarten Lankhorst's avatar Maarten Lankhorst

drm/atomic: Make drm_atomic_plane_disabling easier to understand.

This function becomes a lot simpler when having passed both the old and
new state to it. Looking at all callers, it seems that old_plane_state
is never NULL so the check can be dropped.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1487256430-7625-3-git-send-email-maarten.lankhorst@linux.intel.comReviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
parent 415c3ac3
...@@ -1764,7 +1764,8 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev, ...@@ -1764,7 +1764,8 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
if (!funcs) if (!funcs)
continue; continue;
disabling = drm_atomic_plane_disabling(plane, old_plane_state); disabling = drm_atomic_plane_disabling(old_plane_state,
new_plane_state);
if (active_only) { if (active_only) {
/* /*
...@@ -1859,11 +1860,11 @@ drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state) ...@@ -1859,11 +1860,11 @@ drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state)
WARN_ON(plane->state->crtc && plane->state->crtc != crtc); WARN_ON(plane->state->crtc && plane->state->crtc != crtc);
if (drm_atomic_plane_disabling(plane, old_plane_state) && if (drm_atomic_plane_disabling(old_plane_state, plane->state) &&
plane_funcs->atomic_disable) plane_funcs->atomic_disable)
plane_funcs->atomic_disable(plane, old_plane_state); plane_funcs->atomic_disable(plane, old_plane_state);
else if (plane->state->crtc || else if (plane->state->crtc ||
drm_atomic_plane_disabling(plane, old_plane_state)) drm_atomic_plane_disabling(old_plane_state, plane->state))
plane_funcs->atomic_update(plane, old_plane_state); plane_funcs->atomic_update(plane, old_plane_state);
} }
......
...@@ -469,7 +469,7 @@ int drm_plane_helper_commit(struct drm_plane *plane, ...@@ -469,7 +469,7 @@ int drm_plane_helper_commit(struct drm_plane *plane,
* Drivers may optionally implement the ->atomic_disable callback, so * Drivers may optionally implement the ->atomic_disable callback, so
* special-case that here. * special-case that here.
*/ */
if (drm_atomic_plane_disabling(plane, plane_state) && if (drm_atomic_plane_disabling(plane_state, plane->state) &&
plane_funcs->atomic_disable) plane_funcs->atomic_disable)
plane_funcs->atomic_disable(plane, plane_state); plane_funcs->atomic_disable(plane, plane_state);
else else
......
...@@ -220,10 +220,10 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc, ...@@ -220,10 +220,10 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
__drm_atomic_get_current_plane_state((crtc_state)->state, \ __drm_atomic_get_current_plane_state((crtc_state)->state, \
plane))) plane)))
/* /**
* drm_atomic_plane_disabling - check whether a plane is being disabled * drm_atomic_plane_disabling - check whether a plane is being disabled
* @plane: plane object * @old_plane_state: old atomic plane state
* @old_state: previous atomic state * @new_plane_state: new atomic plane state
* *
* Checks the atomic state of a plane to determine whether it's being disabled * Checks the atomic state of a plane to determine whether it's being disabled
* or not. This also WARNs if it detects an invalid state (both CRTC and FB * or not. This also WARNs if it detects an invalid state (both CRTC and FB
...@@ -233,28 +233,18 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc, ...@@ -233,28 +233,18 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
* True if the plane is being disabled, false otherwise. * True if the plane is being disabled, false otherwise.
*/ */
static inline bool static inline bool
drm_atomic_plane_disabling(struct drm_plane *plane, drm_atomic_plane_disabling(struct drm_plane_state *old_plane_state,
struct drm_plane_state *old_state) struct drm_plane_state *new_plane_state)
{ {
/* /*
* When disabling a plane, CRTC and FB should always be NULL together. * When disabling a plane, CRTC and FB should always be NULL together.
* Anything else should be considered a bug in the atomic core, so we * Anything else should be considered a bug in the atomic core, so we
* gently warn about it. * gently warn about it.
*/ */
WARN_ON((plane->state->crtc == NULL && plane->state->fb != NULL) || WARN_ON((new_plane_state->crtc == NULL && new_plane_state->fb != NULL) ||
(plane->state->crtc != NULL && plane->state->fb == NULL)); (new_plane_state->crtc != NULL && new_plane_state->fb == NULL));
/* return old_plane_state->crtc && !new_plane_state->crtc;
* When using the transitional helpers, old_state may be NULL. If so,
* we know nothing about the current state and have to assume that it
* might be enabled.
*
* When using the atomic helpers, old_state won't be NULL. Therefore
* this check assumes that either the driver will have reconstructed
* the correct state in ->reset() or that the driver will have taken
* appropriate measures to disable all planes.
*/
return (!old_state || old_state->crtc) && !plane->state->crtc;
} }
#endif /* DRM_ATOMIC_HELPER_H_ */ #endif /* DRM_ATOMIC_HELPER_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment