1 From ca621585c573cae54dc1235d90822e8bcef2f73d Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Wed, 11 Sep 2024 15:23:33 +0100
4 Subject: [PATCH] drm/vc4: Use the TPZ scaling filter for 1x1 source images
6 The documentation says that the TPZ filter can not upscale,
7 and requesting a scaling factor > 1:1 will output the original
8 image in the top left, and repeat the right/bottom most pixels
10 That fits perfectly with upscaling a 1x1 image which is done
11 a fair amount by some compositors to give solid colour, and it
12 saves a large amount of LBM (TPZ is based on src size, whilst
13 PPF is based on dest size).
15 Select TPZ filter for images with source rectangle <=1.
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
19 drivers/gpu/drm/vc4/vc4_plane.c | 21 +++++++++++++++------
20 1 file changed, 15 insertions(+), 6 deletions(-)
22 --- a/drivers/gpu/drm/vc4/vc4_plane.c
23 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
24 @@ -265,7 +265,11 @@ static enum vc4_scaling_mode vc4_get_sca
27 return VC4_SCALING_NONE;
28 - if (3 * dst >= 2 * (src >> 16))
30 + if (src <= (1 << 16))
31 + /* Source rectangle <= 1 pixel can use TPZ for resize/upscale */
32 + return VC4_SCALING_TPZ;
33 + else if (3 * dst >= 2 * (src >> 16))
34 return VC4_SCALING_PPF;
36 return VC4_SCALING_TPZ;
37 @@ -560,12 +564,17 @@ static void vc4_write_tpz(struct vc4_pla
39 WARN_ON_ONCE(vc4->gen > VC4_GEN_6);
42 + if ((dst << 16) < src) {
45 - /* The specs note that while the reciprocal would be defined
46 - * as (1<<32)/scale, ~0 is close enough.
49 + /* The specs note that while the reciprocal would be defined
50 + * as (1<<32)/scale, ~0 is close enough.
54 + scale = (1 << 16) + 1;
55 + recip = (1 << 16) - 1;
58 vc4_dlist_write(vc4_state,