Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRM source rectangle fixes #6350

Draft
wants to merge 2 commits into
base: rpi-6.6.y
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 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 Expand Up @@ -1129,7 +1138,8 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
width = vc4_state->src_w[0] >> 16;
height = vc4_state->src_h[0] >> 16;

if (!width || !height || !vc4_state->crtc_w || !vc4_state->crtc_h) {
if (!vc4_state->src_w[0] || !vc4_state->src_h[0] ||
!vc4_state->crtc_w || !vc4_state->crtc_h) {
/* 0 source size probably means the plane is offscreen */
vc4_state->dlist_initialized = 1;
return 0;
Expand Down Expand Up @@ -1656,7 +1666,8 @@ static int vc6_plane_mode_set(struct drm_plane *plane,
width = vc4_state->src_w[0] >> 16;
height = vc4_state->src_h[0] >> 16;

if (!width || !height || !vc4_state->crtc_w || !vc4_state->crtc_h) {
if (!vc4_state->src_w[0] || !vc4_state->src_h[0] ||
!vc4_state->crtc_w || !vc4_state->crtc_h) {
/* 0 source size probably means the plane is offscreen.
* 0 destination size is a redundant plane.
*/
Expand Down
Loading