From 476f31eee9a84b204e8146efeedc1ef9b0c1f6f5 Mon Sep 17 00:00:00 2001 From: Dom Cobley Date: Wed, 3 Dec 2025 17:56:40 +0000 Subject: [PATCH 1/2] drm/vc4: plane: Remove dead channels_scaled code This code can never do anything, as channels_scaled can only be 0 or 2. I suspect that the index was intended to be i rather than channel, but that would trigger for scaled RGB planes, and halving lines is not wanted there. Just remove it. Signed-off-by: Dom Cobley --- drivers/gpu/drm/vc4/vc4_plane.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 7b136e9b9114ae..58c1f2b4bc68c1 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -812,11 +812,8 @@ static unsigned int vc4_lbm_channel_size(const struct drm_plane_state *state, unsigned int channel) { const struct drm_format_info *info = state->fb->format; - const struct vc4_plane_state *vc4_state = to_vc4_plane_state(state); - unsigned int channels_scaled = 0; unsigned int components, words, wpc; unsigned int width, lines; - unsigned int i; /* LBM is meant to use the smaller of source or dest width, but there * is a issue with UV scaling that the size required for the second @@ -843,13 +840,6 @@ static unsigned int vc4_lbm_channel_size(const struct drm_plane_state *state, lines = DIV_ROUND_UP(words, 128 / info->hsub); - for (i = 0; i < 2; i++) - if (vc4_state->y_scaling[channel] != VC4_SCALING_NONE) - channels_scaled++; - - if (channels_scaled == 1) - lines = lines / 2; - return lines; } From 3b8d6704a1c69230b303f68d88880c0aae7c45d3 Mon Sep 17 00:00:00 2001 From: Dom Cobley Date: Wed, 3 Dec 2025 17:59:49 +0000 Subject: [PATCH 2/2] drm/vc4: plane: TPZ scaling modes cannot reduce lbm size when alpha-less spec says "Note that there is not an extra mode to save memory for alpha-less formats" in the TPZ section. Currently, if first plane is RGB888 and scaled down (TPZ) a second plane will corrupt the LBM and result in garbage I've also folded in the modification to components to the function as it seems misplaced Signed-off-by: Dom Cobley --- drivers/gpu/drm/vc4/vc4_plane.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 58c1f2b4bc68c1..9e9946d9cf6d74 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -802,7 +802,10 @@ static unsigned int vc4_lbm_components(const struct drm_plane_state *state, if (info->is_yuv) return channel ? 2 : 1; - if (info->has_alpha) + if (vc4_state->y_scaling[channel] == VC4_SCALING_TPZ) + return 4; + + if (info->has_alpha && state->alpha == DRM_BLEND_ALPHA_OPAQUE) return 4; return 3; @@ -833,9 +836,6 @@ static unsigned int vc4_lbm_channel_size(const struct drm_plane_state *state, if (!components) return 0; - if (state->alpha != DRM_BLEND_ALPHA_OPAQUE && info->has_alpha) - components -= 1; - words = width * wpc * components; lines = DIV_ROUND_UP(words, 128 / info->hsub);