]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/tidss: Restructure dispc_vp_prepare() and dispc_vp_enable()
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Fri, 5 Sep 2025 13:58:06 +0000 (16:58 +0300)
committerTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Fri, 31 Oct 2025 14:56:05 +0000 (16:56 +0200)
tidss_crtc.c calls dispc_vp_prepare() and dispc_vp_enable() in that
order, next to each other. dispc_vp_prepare() does preparations for
enabling the crtc, by writing some registers, and dispc_vp_enable() does
more preparations. As the last thing, dispc_vp_enable() enables the CRTC
by writing the enable bit.

There might have been a reason at some point in the history for this
split, but I can't find any point to it. They also do a bit of
overlapping work: both call dispc_vp_find_bus_fmt(). They could as well
be a single function.

But instead of combining them, this patch moves everything from
dispc_vp_enable() to dispc_vp_prepare(), except the actual CRTC enable
bit write. The reason for this is that unlike all the preparatory
register writes, CRTC enable has an immediate effect, starting the
timing generator and the CRTC as a whole. Thus it may be important to
time the enable just right (as we do in the next patch).

No functional changes.

Reviewed-by: Devarsh Thakkar <devarsht@ti.com>
Link: https://patch.msgid.link/20250905-tidss-fix-timestamp-v1-1-c2aedf31e2c9@ideasonboard.com
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
drivers/gpu/drm/tidss/tidss_crtc.c
drivers/gpu/drm/tidss/tidss_dispc.c
drivers/gpu/drm/tidss/tidss_dispc.h

index 722b6e7b232cabb3b689fe131a450e24e8cec9af..11807963c941c96e2c34486af4a929a1c71ca4b3 100644 (file)
@@ -243,7 +243,7 @@ static void tidss_crtc_atomic_enable(struct drm_crtc *crtc,
 
        dispc_vp_prepare(tidss->dispc, tcrtc->hw_videoport, crtc->state);
 
-       dispc_vp_enable(tidss->dispc, tcrtc->hw_videoport, crtc->state);
+       dispc_vp_enable(tidss->dispc, tcrtc->hw_videoport);
 
        spin_lock_irqsave(&ddev->event_lock, flags);
 
index 7892168d3f3d722a4f514759f500f3cb9fd15f95..d8e1a1bcd66034948649fa22b6cbb7bca998d183 100644 (file)
@@ -1164,6 +1164,9 @@ void dispc_vp_prepare(struct dispc_device *dispc, u32 hw_videoport,
 {
        const struct tidss_crtc_state *tstate = to_tidss_crtc_state(state);
        const struct dispc_bus_format *fmt;
+       const struct drm_display_mode *mode = &state->adjusted_mode;
+       bool align, onoff, rf, ieo, ipc, ihs, ivs;
+       u32 hsw, hfp, hbp, vsw, vfp, vbp;
 
        fmt = dispc_vp_find_bus_fmt(dispc, hw_videoport, tstate->bus_format,
                                    tstate->bus_flags);
@@ -1176,22 +1179,6 @@ void dispc_vp_prepare(struct dispc_device *dispc, u32 hw_videoport,
 
                dispc_enable_am65x_oldi(dispc, hw_videoport, fmt);
        }
-}
-
-void dispc_vp_enable(struct dispc_device *dispc, u32 hw_videoport,
-                    const struct drm_crtc_state *state)
-{
-       const struct drm_display_mode *mode = &state->adjusted_mode;
-       const struct tidss_crtc_state *tstate = to_tidss_crtc_state(state);
-       bool align, onoff, rf, ieo, ipc, ihs, ivs;
-       const struct dispc_bus_format *fmt;
-       u32 hsw, hfp, hbp, vsw, vfp, vbp;
-
-       fmt = dispc_vp_find_bus_fmt(dispc, hw_videoport, tstate->bus_format,
-                                   tstate->bus_flags);
-
-       if (WARN_ON(!fmt))
-               return;
 
        dispc_set_num_datalines(dispc, hw_videoport, fmt->data_width);
 
@@ -1247,7 +1234,10 @@ void dispc_vp_enable(struct dispc_device *dispc, u32 hw_videoport,
                                  mode->crtc_hdisplay - 1) |
                       FIELD_PREP(DISPC_VP_SIZE_SCREEN_VDISPLAY_MASK,
                                  mode->crtc_vdisplay - 1));
+}
 
+void dispc_vp_enable(struct dispc_device *dispc, u32 hw_videoport)
+{
        VP_REG_FLD_MOD(dispc, hw_videoport, DISPC_VP_CONTROL, 1,
                       DISPC_VP_CONTROL_ENABLE_MASK);
 }
index 60c1b400eb8933dd13efd4ae3d09dc9569eed96f..f38493a70122b4a81bab68c644a58dee949d4d78 100644 (file)
@@ -119,8 +119,7 @@ void dispc_ovr_enable_layer(struct dispc_device *dispc,
 
 void dispc_vp_prepare(struct dispc_device *dispc, u32 hw_videoport,
                      const struct drm_crtc_state *state);
-void dispc_vp_enable(struct dispc_device *dispc, u32 hw_videoport,
-                    const struct drm_crtc_state *state);
+void dispc_vp_enable(struct dispc_device *dispc, u32 hw_videoport);
 void dispc_vp_disable(struct dispc_device *dispc, u32 hw_videoport);
 void dispc_vp_unprepare(struct dispc_device *dispc, u32 hw_videoport);
 bool dispc_vp_go_busy(struct dispc_device *dispc, u32 hw_videoport);