From: Paul Cercueil <paul@crapouillou.net>
To: David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>
Cc: Sam Ravnborg <sam@ravnborg.org>,
od@zcrc.me, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Paul Cercueil <paul@crapouillou.net>
Subject: [PATCH] drm/ingenic: ipu: Search for scaling coefs up to 102% of the screen
Date: Thu, 5 Nov 2020 08:39:05 +0000 [thread overview]
Message-ID: <20201105083905.8780-1-paul@crapouillou.net> (raw)
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.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
drivers/gpu/drm/ingenic/ingenic-ipu.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/ingenic/ingenic-ipu.c b/drivers/gpu/drm/ingenic/ingenic-ipu.c
index fc8c6e970ee3..e52777ef85fd 100644
--- a/drivers/gpu/drm/ingenic/ingenic-ipu.c
+++ b/drivers/gpu/drm/ingenic/ingenic-ipu.c
@@ -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;
--
2.28.0
next reply other threads:[~2020-11-05 8:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 8:39 Paul Cercueil [this message]
2020-11-07 19:33 ` [PATCH] drm/ingenic: ipu: Search for scaling coefs up to 102% of the screen Sam Ravnborg
2020-11-10 8:50 ` Paul Cercueil
2020-11-10 8:56 ` [PATCH] drm/ingenic: ipu: Search for scaling coefs up to 102% of?? " Sam Ravnborg
2020-11-10 9:00 ` Paul Cercueil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201105083905.8780-1-paul@crapouillou.net \
--to=paul@crapouillou.net \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=od@zcrc.me \
--cc=sam@ravnborg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).