drm: rcar-du: Move routing configuration
The rcar_du_crtc_setup() currently configures the group routing. This
can now be handled directly by the group. Introduce a new flag
'active_changed' to track if the active state of any CRTC in the group
changes it's active flag, and in the event of a change update the
routing.
The routing will only be updated if there is at least one active CRTC.
This commit changes the sequence of register writes to the DU. The
routing is now configured *before* rcar_du_crtc_setup() is called, and
as such is set before setting the background to black and disabling the
display.
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index ac1ed85..c2c5c7a 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -486,7 +486,6 @@ static void rcar_du_crtc_setup(struct rcar_du_crtc *rcrtc)
/* Configure display timings and output routing */
rcar_du_crtc_set_display_timing(rcrtc);
- rcar_du_group_set_routing(rcrtc->group);
/* Enable the VSP compositor. */
if (rcar_du_has(rcrtc->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c b/drivers/gpu/drm/rcar-du/rcar_du_group.c
index 95b4043..6333931 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
@@ -416,6 +416,9 @@ int rcar_du_group_atomic_check(struct drm_device *dev,
if (crtc_state->active)
rstate->use_count++;
+
+ if (crtc_state->active_changed)
+ rstate->active_changed = true;
}
}
@@ -438,6 +441,16 @@ int rcar_du_group_atomic_pre_commit(struct drm_device *dev,
if (!old_state->use_count && new_state->use_count)
rcar_du_group_setup(rgrp);
+
+ /*
+ * todo: The rcar_du_group_set_routing() is now called before
+ * rcar_du_crtc_setup(), which means that in particular the
+ * display has not been configured to be off with a black
+ * background. This will require some further testing with a
+ * panel display and multiple CRTCs being used simultaneously.
+ */
+ if (new_state->active_changed && new_state->use_count)
+ rcar_du_group_set_routing(rgrp);
}
return 0;
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.h b/drivers/gpu/drm/rcar-du/rcar_du_group.h
index c08064a..3c76c12 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.h
@@ -57,11 +57,13 @@ struct rcar_du_group {
/**
* struct rcar_du_group_state - Driver-specific group state
* @state: base DRM private state
+ * @active_changed: set if the active flag is toggled in any CRTC in the group
* @use_count: number of users of the group
*/
struct rcar_du_group_state {
struct drm_private_state state;
+ bool active_changed;
unsigned int use_count;
};