Skip to content

Commit 1d49f2e

Browse files
stschakeanholt
authored andcommitted
drm/vc4: Enable background color fill when necessary
Using the hint from the plane state, we turn on the background color to avoid display corruption from planes blending with the background. Changes from v1: - Use needs_bg_fill from plane state Signed-off-by: Stefan Schake <[email protected]> Signed-off-by: Eric Anholt <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 8236469 commit 1d49f2e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,9 +643,12 @@ static void vc4_crtc_atomic_flush(struct drm_crtc *crtc,
643643
{
644644
struct drm_device *dev = crtc->dev;
645645
struct vc4_dev *vc4 = to_vc4_dev(dev);
646+
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
646647
struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc->state);
647648
struct drm_plane *plane;
649+
struct vc4_plane_state *vc4_plane_state;
648650
bool debug_dump_regs = false;
651+
bool enable_bg_fill = false;
649652
u32 __iomem *dlist_start = vc4->hvs->dlist + vc4_state->mm.start;
650653
u32 __iomem *dlist_next = dlist_start;
651654

@@ -656,6 +659,20 @@ static void vc4_crtc_atomic_flush(struct drm_crtc *crtc,
656659

657660
/* Copy all the active planes' dlist contents to the hardware dlist. */
658661
drm_atomic_crtc_for_each_plane(plane, crtc) {
662+
/* Is this the first active plane? */
663+
if (dlist_next == dlist_start) {
664+
/* We need to enable background fill when a plane
665+
* could be alpha blending from the background, i.e.
666+
* where no other plane is underneath. It suffices to
667+
* consider the first active plane here since we set
668+
* needs_bg_fill such that either the first plane
669+
* already needs it or all planes on top blend from
670+
* the first or a lower plane.
671+
*/
672+
vc4_plane_state = to_vc4_plane_state(plane->state);
673+
enable_bg_fill = vc4_plane_state->needs_bg_fill;
674+
}
675+
659676
dlist_next += vc4_plane_write_dlist(plane, dlist_next);
660677
}
661678

@@ -664,6 +681,14 @@ static void vc4_crtc_atomic_flush(struct drm_crtc *crtc,
664681

665682
WARN_ON_ONCE(dlist_next - dlist_start != vc4_state->mm.size);
666683

684+
if (enable_bg_fill)
685+
/* This sets a black background color fill, as is the case
686+
* with other DRM drivers.
687+
*/
688+
HVS_WRITE(SCALER_DISPBKGNDX(vc4_crtc->channel),
689+
HVS_READ(SCALER_DISPBKGNDX(vc4_crtc->channel)) |
690+
SCALER_DISPBKGND_FILL);
691+
667692
/* Only update DISPLIST if the CRTC was already running and is not
668693
* being disabled.
669694
* vc4_crtc_enable() takes care of updating the dlist just after

0 commit comments

Comments
 (0)