drm/ingenic: ipu: Search for scaling coefs up to 102% of the screen
Subsystems (3)
Paul Cercueil
maintainerPATCH 1/1 drm/ingenic: ipu: Search for scaling coefs up to 102% of the screen
Increase the scaled image's theorical width/height until we find a configuration that has valid scaling coefficients, up to 102% of the screen's resolution. This makes sure that we can scale from almost every resolution possible at the cost of a very small distorsion. The CRTC_W / CRTC_H are not modified.
This algorithm was already in place but would not try to go above the screen's resolution, and as a result would only work if the CRTC_W / CRTC_H were smaller than the screen resolution. It will now try until it reaches 102% of the screen's resolution.
--- drivers/gpu/drm/ingenic/ingenic-ipu.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/ingenic/ingenic-ipu.c +15 -8
@@ -516,7 +516,7 @@ static void ingenic_ipu_plane_atomic_update(struct drm_plane *plane,static int ingenic_ipu_plane_atomic_check (struct drm_plane *plane,struct drm_plane_state *state) { -unsigned int num_w, denom_w, num_h, denom_h, xres, yres; +unsigned int num_w, denom_w, num_h, denom_h, xres, yres, max_w, max_h;struct ingenic_ipu *ipu =plane_to_ingenic_ipu (plane);struct drm_crtc *crtc = state->crtc ?: plane->state->crtc;struct drm_crtc_state *crtc_state;
@@ -558,19 +558,26 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane, xres = state->src_w >>16 ; yres = state->src_h >>16 ; -/* Adjust the coefficients until we find a valid configuration */ -for (denom_w = xres, num_w = state->crtc_w; - num_w <= crtc_state->mode.hdisplay; num_w++) +/* +* Increase the scaled image's theorical width/height until we find a +* configuration that has valid scaling coefficients, up to 102% of the +* screen's resolution. This makes sure that we can scale from almost +* every resolution possible at the cost of a very small distorsion. +* The CRTC_W / CRTC_H are not modified. +*/ + max_w = crtc_state->mode.hdisplay *102 /100 ; + max_h = crtc_state->mode.vdisplay *102 /100 ; + +for (denom_w = xres, num_w = state->crtc_w; num_w <= max_w; num_w++)if (!reduce_fraction (&num_w, &denom_w))break ; -if (num_w > crtc_state->mode.hdisplay) +if (num_w > max_w)return -EINVAL ; -for (denom_h = yres, num_h = state->crtc_h; - num_h <= crtc_state->mode.vdisplay; num_h++) +for (denom_h = yres, num_h = state->crtc_h; num_h <= max_h; num_h++)if (!reduce_fraction (&num_h, &denom_h))break ; -if (num_h > crtc_state->mode.vdisplay) +if (num_h > max_h)return -EINVAL ; ipu->num_w = num_w;
Signature · 1 line
2.28.0
Hi Paul.
Quoted 6 lines · Paul Cercueil
Increase the scaled image's theorical width/height until we find a configuration that has valid scaling coefficients, up to 102% of the screen's resolution. This makes sure that we can scale from almost every resolution possible at the cost of a very small distorsion. The
CRTC_W/CRTC_Hare not modified.
Quoted 6 lines
This algorithm was already in place but would not try to go above the screen's resolution, and as a result would only work if the
CRTC_W/CRTC_Hwere smaller than the screen resolution. It will now try until it reaches 102% of the screen's resolution.Signed-off-by Paul Cercueil <[email protected]>
Looks like the patch does what the descriptions says.
So in other words - look OK to me. I am not confident enogh for a r-b but my code reading is enough to warrant an a-b:
Paul Cercueil
maintainerHi,
Quoted 16 lines · Sam Ravnborg
Hi Paul.
Quoted 13 lines · Paul Cercueil
Increase the scaled image's theorical width/height until we find a configuration that has valid scaling coefficients, up to 102% of the screen's resolution. This makes sure that we can scale from almost every resolution possible at the cost of a very small distorsion. The
CRTC_W/CRTC_Hare not modified.This algorithm was already in place but would not try to go above
the
screen's resolution, and as a result would only work if theCRTC_W/CRTC_Hwere smaller than the screen resolution. It will now try
until it
reaches 102% of the screen's resolution.
Quoted 6 lines
Quoted 1 line
Signed-off-by Paul Cercueil <[email protected]>Looks like the patch does what the descriptions says.
So in other words - look OK to me. I am not confident enogh for a r-b but my code reading is enough to warrant an a-b:Acked-by Sam Ravnborg <[email protected]>
Note that this algorithm exists mostly as a band-aid for a missing functionality: it is not possible for userspace to request the closest mode that would encapsulate the provided one, because the GEM buffer is created beforehand. If there was a way to let the kernel tweak the mode, I could write a better algorithm that would result in a better looking picture.
Cheers,
-Paul
Re: [PATCH] drm/ingenic: ipu: Search for scaling coefs up to 102% of?? the screen
Hi Paul,
Quoted 26 lines · Paul Cercueil
Hi,
Quoted 16 lines · Sam Ravnborg
Hi Paul.
Quoted 13 lines · Paul Cercueil
Increase the scaled image's theorical width/height until we find a configuration that has valid scaling coefficients, up to 102% of the screen's resolution. This makes sure that we can scale from almost every resolution possible at the cost of a very small distorsion. The
CRTC_W/CRTC_Hare not modified.This algorithm was already in place but would not try to go above
the
screen's resolution, and as a result would only work if theCRTC_W/CRTC_Hwere smaller than the screen resolution. It will now try
until it
reaches 102% of the screen's resolution.Quoted 6 lines
Quoted 1 line
Signed-off-by Paul Cercueil <[email protected]>Looks like the patch does what the descriptions says.
So in other words - look OK to me. I am not confident enogh for a r-b but my code reading is enough to warrant an a-b:Acked-by Sam Ravnborg <[email protected]>
Quoted 5 lines
Note that this algorithm exists mostly as a band-aid for a missing
functionality: it is not possible for userspace to request the closest mode that would encapsulate the provided one, because the GEM buffer is created beforehand. If there was a way to let the kernel tweak the mode, I could write a better algorithm that would result in a better looking picture.
Could you add this nice explanation to the changelog so when we wonder why this was done in some years we can dig up this from git history.
Sam
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Paul Cercueil
maintainerRe: [PATCH] drm/ingenic: ipu: Search for scaling coefs up to 102% of?? the screen
Quoted 46 lines · Sam Ravnborg
Hi Paul,
Quoted 34 lines · Paul Cercueil
Hi,
Le sam. 7 nov. 2020 à 20:33, Sam Ravnborg <[email protected]> a
écrit :Quoted 4 lines
Hi Paul.
Quoted 1 line · Paul Cercueil
Increase the scaled image's theorical width/height until we
find a
Quoted 1 line
Quoted 1 line
configuration that has valid scaling coefficients, up to 102%
of the
Quoted 1 line
Quoted 1 line
screen's resolution. This makes sure that we can scale from
almost
Quoted 1 line
Quoted 1 line
every resolution possible at the cost of a very small
distorsion.
Quoted 3 lines
Quoted 3 lines
The
CRTC_W/CRTC_Hare not modified.This algorithm was already in place but would not try to go
above
Quoted 2 lines
Quoted 2 lines
the
screen's resolution, and as a result would only work if the
CRTC_W/Quoted 8 lines
Quoted 5 lines
CRTC_Hwere smaller than the screen resolution. It will now try
until it
reaches 102% of the screen's resolution.Signed-off-by Paul Cercueil <[email protected]>Looks like the patch does what the descriptions says. So in other words - look OK to me. I am not confident enogh for a
r-b
Quoted 2 lines
but my code reading is enough to warrant an a-b:
Acked-by Sam Ravnborg <[email protected]>Quoted 9 lines
Note that this algorithm exists mostly as a band-aid for a missing
functionality: it is not possible for userspace to request the
closest mode
that would encapsulate the provided one, because the GEM buffer is
created
beforehand. If there was a way to let the kernel tweak the mode, I
could
write a better algorithm that would result in a better looking
picture.
Quoted 2 lines
Could you add this nice explanation to the changelog so when we wonder why this was done in some years we can dig up this from git history.
Sure!
-Paul