From c0169f2c197d005aff8acfbc618de6e7f6b1ab94 Mon Sep 17 00:00:00 2001
From: Florian Wesch <fw@dividuum.de>
Date: Tue, 5 Mar 2024 15:17:56 +0100
Subject: [PATCH 1285/1295] vc4/hvs: Fix lbm size calculation for yuv (#6012)

The code was reducing the number of components by one when we were not
blending with alpha. But that only makes sense if the components include
alpha.

For YUV, we were reducing the number of components for Y from one to zero
which resulted in no lbm space being allocated.

Fixes: https://github.com/raspberrypi/linux/issues/5912

Signed-off-by: Dom Cobley <popcornmix@gmail.com>
Co-authored-by: Dom Cobley <popcornmix@gmail.com>
---
 drivers/gpu/drm/vc4/vc4_plane.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -733,7 +733,7 @@ static unsigned int vc4_lbm_channel_size
 	if (!components)
 		return 0;
 
-	if (state->alpha != DRM_BLEND_ALPHA_OPAQUE)
+	if (state->alpha != DRM_BLEND_ALPHA_OPAQUE && info->has_alpha)
 		components -= 1;
 
 	words = width * wpc * components;
