5a7b3e4c1ef289366f51c567487fdb8e24e2b0b4
[openwrt/staging/pepe2k.git] /
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
5
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
9 thereafter.
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).
14
15 Select TPZ filter for images with source rectangle <=1.
16
17 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
18 ---
19 drivers/gpu/drm/vc4/vc4_plane.c | 21 +++++++++++++++------
20 1 file changed, 15 insertions(+), 6 deletions(-)
21
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
25 {
26 if (dst == src >> 16)
27 return VC4_SCALING_NONE;
28 - if (3 * dst >= 2 * (src >> 16))
29 +
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;
35 else
36 return VC4_SCALING_TPZ;
37 @@ -560,12 +564,17 @@ static void vc4_write_tpz(struct vc4_pla
38
39 WARN_ON_ONCE(vc4->gen > VC4_GEN_6);
40
41 - scale = src / dst;
42 + if ((dst << 16) < src) {
43 + scale = src / dst;
44
45 - /* The specs note that while the reciprocal would be defined
46 - * as (1<<32)/scale, ~0 is close enough.
47 - */
48 - recip = ~0 / scale;
49 + /* The specs note that while the reciprocal would be defined
50 + * as (1<<32)/scale, ~0 is close enough.
51 + */
52 + recip = ~0 / scale;
53 + } else {
54 + scale = (1 << 16) + 1;
55 + recip = (1 << 16) - 1;
56 + }
57
58 vc4_dlist_write(vc4_state,
59 /*