Skip to content

Commit

Permalink
drm/vc4: Use the TPZ scaling filter for 1x1 source images
Browse files Browse the repository at this point in the history
The documentation says that the TPZ filter can not upscale,
and requesting a scaling factor > 1:1 will output the original
image in the top left, and repeat the right/bottom most pixels
thereafter.
That fits perfectly with upscaling a 1x1 image which is done
a fair amount by some compositors to give solid colour, and it
saves a large amount of LBM (TPZ is based on src size, whilst
PPF is based on dest size).

Select TPZ filter for images with source rectangle <=1.

Signed-off-by: Dave Stevenson <[email protected]>
  • Loading branch information
6by9 committed Sep 11, 2024
1 parent e089435 commit b953f4a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions drivers/gpu/drm/vc4/vc4_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ static enum vc4_scaling_mode vc4_get_scaling_mode(u32 src, u32 dst)
{
if (dst == src >> 16)
return VC4_SCALING_NONE;
if (3 * dst >= 2 * (src >> 16))

if (src <= (1 << 16))
/* Source rectangle <= 1 pixel can use TPZ for resize/upscale */
return VC4_SCALING_TPZ;
else if (3 * dst >= 2 * (src >> 16))
return VC4_SCALING_PPF;
else
return VC4_SCALING_TPZ;
Expand Down Expand Up @@ -551,12 +555,17 @@ static void vc4_write_tpz(struct vc4_plane_state *vc4_state, u32 src, u32 dst)

WARN_ON_ONCE(vc4->gen > VC4_GEN_6);

scale = src / dst;
if ((dst << 16) < src) {
scale = src / dst;

/* The specs note that while the reciprocal would be defined
* as (1<<32)/scale, ~0 is close enough.
*/
recip = ~0 / scale;
/* The specs note that while the reciprocal would be defined
* as (1<<32)/scale, ~0 is close enough.
*/
recip = ~0 / scale;
} else {
scale = (1 << 16) + 1;
recip = (1 << 16) - 1;
}

vc4_dlist_write(vc4_state,
/*
Expand Down

0 comments on commit b953f4a

Please sign in to comment.