From: Sonika Jindal <sonika.jindal@intel.com>
To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: [PATCH 1/2] drm: Adding rotation to drm_plane_helper_check_update
Date: Tue, 13 Jan 2015 18:03:39 +0530 [thread overview]
Message-ID: <1421152420-20375-2-git-send-email-sonika.jindal@intel.com> (raw)
In-Reply-To: <1421152420-20375-1-git-send-email-sonika.jindal@intel.com>
Taking rotation into account while checking the plane
and adjusting the sizes accordingly.
Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
---
drivers/gpu/drm/drm_plane_helper.c | 79 ++++++++++++++++++++++++++++++++++--
include/drm/drm_plane_helper.h | 3 +-
2 files changed, 77 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
index f24c4cf..4badd69 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -138,9 +138,13 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
int max_scale,
bool can_position,
bool can_update_disabled,
- bool *visible)
+ bool *visible,
+ unsigned int rotation)
{
int hscale, vscale;
+ int crtc_x, crtc_y;
+ unsigned int crtc_w, crtc_h;
+ uint32_t src_x, src_y, src_w, src_h;
if (!fb) {
*visible = false;
@@ -158,9 +162,13 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
return -EINVAL;
}
+ if (fb)
+ drm_rect_rotate(src, fb->width << 16, fb->height << 16,
+ rotation);
+
/* Check scaling */
- hscale = drm_rect_calc_hscale(src, dest, min_scale, max_scale);
- vscale = drm_rect_calc_vscale(src, dest, min_scale, max_scale);
+ hscale = drm_rect_calc_hscale_relaxed(src, dest, min_scale, max_scale);
+ vscale = drm_rect_calc_vscale_relaxed(src, dest, min_scale, max_scale);
if (hscale < 0 || vscale < 0) {
DRM_DEBUG_KMS("Invalid scaling of plane\n");
return -ERANGE;
@@ -182,6 +190,68 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
return -EINVAL;
}
+ crtc_x = dest->x1;
+ crtc_y = dest->y1;
+ crtc_w = drm_rect_width(dest);
+ crtc_h = drm_rect_height(dest);
+
+ if (*visible) {
+ /* check again in case clipping clamped the results */
+ hscale = drm_rect_calc_hscale(src, dest,
+ DRM_PLANE_HELPER_NO_SCALING,
+ DRM_PLANE_HELPER_NO_SCALING);
+ if (hscale < 0) {
+ DRM_DEBUG_KMS("Horizontal scaling factor out of limits\n");
+ drm_rect_debug_print(src, true);
+ drm_rect_debug_print(dest, false);
+
+ return hscale;
+ }
+
+ vscale = drm_rect_calc_vscale(src, dest,
+ DRM_PLANE_HELPER_NO_SCALING,
+ DRM_PLANE_HELPER_NO_SCALING);
+ if (vscale < 0) {
+ DRM_DEBUG_KMS("Vertical scaling factor out of limits\n");
+ drm_rect_debug_print(src, true);
+ drm_rect_debug_print(dest, false);
+
+ return vscale;
+ }
+
+ /* Make the source viewport size an exact multiple of the scaling factors. */
+ drm_rect_adjust_size(src,
+ drm_rect_width(dest) * hscale - drm_rect_width(src),
+ drm_rect_height(dest) * vscale - drm_rect_height(src));
+
+ drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16,
+ rotation);
+
+ /*
+ * Hardware doesn't handle subpixel coordinates.
+ * Adjust to (macro)pixel boundary, but be careful not to
+ * increase the source viewport size, because that could
+ * push the downscaling factor out of bounds.
+ */
+ src_x = src->x1 >> 16;
+ src_w = drm_rect_width(src) >> 16;
+ src_y = src->y1 >> 16;
+ src_h = drm_rect_height(src) >> 16;
+ }
+
+ if (*visible) {
+ src->x1 = src_x;
+ src->x2 = src_x + src_w;
+ src->y1 = src_y;
+ src->y2 = src_y + src_h;
+ }
+
+ dest->x1 = crtc_x;
+ dest->x2 = crtc_x + crtc_w;
+ dest->y1 = crtc_y;
+ dest->y2 = crtc_y + crtc_h;
+
+
return 0;
}
EXPORT_SYMBOL(drm_plane_helper_check_update);
@@ -258,7 +328,8 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
&src, &dest, &clip,
DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING,
- false, false, &visible);
+ false, false, &visible,
+ DRM_ROTATE_0);
if (ret)
return ret;
diff --git a/include/drm/drm_plane_helper.h b/include/drm/drm_plane_helper.h
index a185392..ef9eb04 100644
--- a/include/drm/drm_plane_helper.h
+++ b/include/drm/drm_plane_helper.h
@@ -84,7 +84,8 @@ extern int drm_plane_helper_check_update(struct drm_plane *plane,
int max_scale,
bool can_position,
bool can_update_disabled,
- bool *visible);
+ bool *visible,
+ unsigned int rotation);
extern int drm_primary_helper_update(struct drm_plane *plane,
struct drm_crtc *crtc,
struct drm_framebuffer *fb,
--
1.7.10.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-01-13 12:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-13 12:33 [PATCH 0/2] Adding rotattion to drm_plane_helper_check_update Sonika Jindal
2015-01-13 12:33 ` Sonika Jindal [this message]
2015-01-13 13:32 ` [Intel-gfx] [PATCH 1/2] drm: Adding rotation " Ville Syrjälä
2015-01-14 4:35 ` sonika
2015-01-14 9:27 ` Ville Syrjälä
2015-01-14 9:35 ` [Intel-gfx] " Jindal, Sonika
2015-01-14 9:49 ` Jindal, Sonika
2015-01-14 11:43 ` Ville Syrjälä
2015-01-14 13:54 ` Jindal, Sonika
2015-01-14 18:08 ` Ville Syrjälä
2015-01-15 2:04 ` [Intel-gfx] " Jindal, Sonika
2015-01-15 9:28 ` Ville Syrjälä
2015-01-14 5:40 ` [PATCH] " Sonika Jindal
2015-01-14 16:32 ` Matt Roper
2015-01-15 10:39 ` shuang.he
2015-01-13 12:33 ` [PATCH 2/2] drm/i915: Passing " Sonika Jindal
2015-01-13 19:36 ` shuang.he
2015-01-13 18:12 ` [PATCH 0/2] Adding rotattion " Matt Roper
2015-01-14 4:24 ` sonika
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=1421152420-20375-2-git-send-email-sonika.jindal@intel.com \
--to=sonika.jindal@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.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