drm/vc4: kms: Don't disable the muxing of an active CRTC 41/245641/1
authorMaxime Ripard <maxime@cerno.tech>
Thu, 8 Oct 2020 11:25:18 +0000 (13:25 +0200)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Tue, 13 Oct 2020 09:01:44 +0000 (18:01 +0900)
The current HVS muxing code will consider the CRTCs in a given state to
setup their muxing in the HVS, and disable the other CRTCs muxes.

However, it's valid to only update a single CRTC with a state, and in this
situation we would mux out a CRTC that was enabled but left untouched by
the new state.

Fix this by considering all the CRTCs in the state and the ones with a
state and active.

Fixes: 87ebcd42fb7b ("drm/vc4: crtc: Assign output to channel automatically")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Idb6e79214f52e470e9fcf5a0579873402c631eb2

drivers/gpu/drm/vc4/vc4_kms.c

index 367cead..06b291f 100644 (file)
@@ -191,6 +191,23 @@ static void vc4_hvs_pv_muxing_commit(struct vc4_dev *vc4,
        }
 }
 
+static struct drm_crtc_state *
+drm_atomic_get_new_or_current_crtc_state(struct drm_atomic_state *state,
+                                        struct drm_crtc *crtc)
+{
+       struct drm_crtc_state *crtc_state;
+
+       crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
+       if (crtc_state)
+               return crtc_state;
+
+       return crtc->state;
+}
+
+#define for_each_new_or_current_crtc_state(__state, crtc, crtc_state)  \
+       list_for_each_entry(crtc, &__state->dev->mode_config.crtc_list, head) \
+               for_each_if(crtc_state = drm_atomic_get_new_or_current_crtc_state(__state, crtc))
+
 static void vc5_hvs_pv_muxing_commit(struct vc4_dev *vc4,
                                     struct drm_atomic_state *state)
 {
@@ -200,16 +217,16 @@ static void vc5_hvs_pv_muxing_commit(struct vc4_dev *vc4,
        unsigned char dsp3_mux = 3;
        unsigned char dsp4_mux = 3;
        unsigned char dsp5_mux = 3;
-       unsigned int i;
        u32 reg;
 
-       for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
-               struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc_state);
+       for_each_new_or_current_crtc_state(state, crtc, crtc_state) {
                struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
+               struct vc4_crtc_state *vc4_state;
 
                if (!crtc_state->active)
                        continue;
 
+               vc4_state = to_vc4_crtc_state(crtc_state);
                switch (vc4_crtc->data->hvs_output) {
                case 2:
                        dsp2_mux = (vc4_state->assigned_channel == 2) ? 0 : 1;