[PATCH v2 3/6] drm: rcar-du: Add pre/post commit CRTC helpers

From: Kieran Bingham
Date: Fri Mar 15 2019 - 13:01:35 EST


Provide helpers to allow CRTC configuration to be separated from the power
state handling. rcar_du_crtc_atomic_post_commit() is a no-op, but maintained
for API symmetry.

---
drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 25 +++++++++++++++++++++++--
drivers/gpu/drm/rcar-du/rcar_du_crtc.h | 5 +++++
drivers/gpu/drm/rcar-du/rcar_du_kms.c | 2 ++
3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index 6109a97b0bb9..2606de788688 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -515,8 +515,6 @@ static int rcar_du_crtc_enable(struct rcar_du_crtc *rcrtc)
if (ret < 0)
goto error_group;

- rcar_du_crtc_setup(rcrtc);
-
return 0;

error_group:
@@ -683,6 +681,29 @@ int rcar_du_crtc_atomic_enter_standby(struct drm_device *dev,
return 0;
}

+int rcar_du_crtc_atomic_pre_commit(struct drm_device *dev,
+ struct drm_atomic_state *state)
+{
+ struct drm_crtc *crtc;
+ struct drm_crtc_state *crtc_state;
+ unsigned int i;
+
+ for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
+ struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
+
+ if (crtc_state->active_changed && crtc_state->active)
+ rcar_du_crtc_setup(rcrtc);
+ }
+
+ return 0;
+}
+
+int rcar_du_crtc_atomic_post_commit(struct drm_device *dev,
+ struct drm_atomic_state *state)
+{
+ return 0;
+}
+
static void rcar_du_crtc_atomic_enable(struct drm_crtc *crtc,
struct drm_crtc_state *old_state)
{
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
index d12d4a788e9f..0b60a6e0b753 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
@@ -105,6 +105,11 @@ int rcar_du_crtc_atomic_exit_standby(struct drm_device *dev,
int rcar_du_crtc_atomic_enter_standby(struct drm_device *dev,
struct drm_atomic_state *state);

+int rcar_du_crtc_atomic_pre_commit(struct drm_device *dev,
+ struct drm_atomic_state *state);
+int rcar_du_crtc_atomic_post_commit(struct drm_device *dev,
+ struct drm_atomic_state *state);
+
void rcar_du_crtc_dsysr_clr_set(struct rcar_du_crtc *rcrtc, u32 clr, u32 set);

#endif /* __RCAR_DU_CRTC_H__ */
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index b8da4dfc79d2..e4befb1937f8 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -304,12 +304,14 @@ static void rcar_du_atomic_commit_tail(struct drm_atomic_state *old_state)

/* Apply the atomic update. */
rcar_du_crtc_atomic_exit_standby(dev, old_state);
+ rcar_du_crtc_atomic_pre_commit(dev, old_state);

drm_atomic_helper_commit_modeset_disables(dev, old_state);
drm_atomic_helper_commit_planes(dev, old_state,
DRM_PLANE_COMMIT_ACTIVE_ONLY);
drm_atomic_helper_commit_modeset_enables(dev, old_state);

+ rcar_du_crtc_atomic_post_commit(dev, old_state);
rcar_du_crtc_atomic_enter_standby(dev, old_state);

drm_atomic_helper_commit_hw_done(old_state);
--
2.19.1