dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: ville.syrjala@linux.intel.com
To: intel-gfx@lists.freedesktop.org
Cc: Sagar Kamble <sagar.a.kamble@intel.com>, dri-devel@lists.freedesktop.org
Subject: [PATCH 3/5] drm: Add drm_rotation_chain()
Date: Wed, 12 Feb 2014 23:15:02 +0200	[thread overview]
Message-ID: <1392239704-21776-4-git-send-email-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <1392239704-21776-1-git-send-email-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

drm_rotation_chain() can be used to combine the plane and crtc rotations
to calculate the total rotation for a specific plane.

Cc: Sagar Kamble <sagar.a.kamble@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_crtc.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_crtc.h     |  2 ++
 2 files changed, 44 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 7077676..71d366f 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4065,6 +4065,48 @@ unsigned int drm_rotation_simplify(unsigned int rotation,
 EXPORT_SYMBOL(drm_rotation_simplify);
 
 /**
+ * drm_rotation_chain() - Chain plane and crtc rotations together
+ * @crtc_rotation: rotation for the entire crtc
+ * @plane_rotation: rotation for the plane in relation to the crtc
+ *
+ * Given @crtc_rotation and @plane_rotation, this function will
+ * comptute the total rotation for the plane in relation to 0
+ * degree rotated crtc. This can be used eg. to implement full crtc
+ * rotation using just plane rotation in hardware. Obviously that
+ * requires that all planes must support rotation since the crtc
+ * itself won't rotate the composed scene.
+ */
+unsigned int drm_rotation_chain(unsigned int crtc_rotation,
+				unsigned int plane_rotation)
+{
+	unsigned int rotation;
+
+	/* add up the rotation angles */
+	rotation = 1 << ((ffs(plane_rotation & 0xf) + ffs(crtc_rotation & 0xf) - 2) % 4);
+
+	/* plane reflection before plane rotation */
+	rotation |= plane_rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y));
+
+	/* crtc reflection after plane rotation and before crtc rotation */
+	switch (plane_rotation & 0xf) {
+	case BIT(DRM_ROTATE_0):
+	case BIT(DRM_ROTATE_180):
+		rotation ^= crtc_rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y));
+		break;
+	case BIT(DRM_ROTATE_90):
+	case BIT(DRM_ROTATE_270):
+		if (crtc_rotation & BIT(DRM_REFLECT_X))
+			rotation ^= BIT(DRM_REFLECT_Y);
+		if (crtc_rotation & BIT(DRM_REFLECT_Y))
+			rotation ^= BIT(DRM_REFLECT_X);
+		break;
+	}
+
+	return rotation;
+}
+EXPORT_SYMBOL(drm_rotation_chain);
+
+/**
  * drm_mode_config_init - initialize DRM mode_configuration structure
  * @dev: DRM device
  *
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index ee84a4a..ebb9bf4 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1189,6 +1189,8 @@ extern struct drm_property *drm_mode_create_rotation_property(struct drm_device
 							      unsigned int supported_rotations);
 extern unsigned int drm_rotation_simplify(unsigned int rotation,
 					  unsigned int supported_rotations);
+extern unsigned int drm_rotation_chain(unsigned int crtc_rotation,
+				       unsigned int plane_rotation);
 
 /* Helpers */
 static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
-- 
1.8.3.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2014-02-12 21:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12 21:14 [PATCH 0/5] drm/i915: Full pipe rotation & rotation property name bikeshedding ville.syrjala
2014-02-12 21:15 ` [PATCH 1/5] drm: Pass name to drm_rotation_property_create() ville.syrjala
2014-02-13 10:42   ` Sagar Arun Kamble
2014-02-12 21:15 ` [PATCH 2/5] drm/i915: Rename primary plane rotation property to "plane-rotation" ville.syrjala
2014-02-13 12:37   ` Sagar Arun Kamble
2014-02-13 13:46     ` Ville Syrjälä
2014-02-13 14:06       ` Ville Syrjälä
2014-02-13 14:20         ` [Intel-gfx] " Chris Wilson
2014-02-13 14:40           ` Ville Syrjälä
2014-02-12 21:15 ` ville.syrjala [this message]
2014-02-12 21:15 ` [PATCH 4/5] drm/i915: Add rotation support for the cursor plane ville.syrjala
2014-02-14 11:01   ` Sagar Arun Kamble
2014-02-14 11:39     ` Ville Syrjälä
2014-02-17 17:23       ` Sagar Arun Kamble
2014-02-17 17:51         ` Ville Syrjälä
2014-02-18  7:49           ` Sagar Arun Kamble
2014-02-18  9:23             ` Ville Syrjälä
2014-02-18 10:09               ` Sagar Arun Kamble
2014-02-12 21:15 ` [PATCH 5/5] drm/i915: Add full pipe rotation ville.syrjala
2014-02-19 10:25   ` Sagar Arun Kamble
2014-02-12 23:17 ` [PATCH 0/5] drm/i915: Full pipe rotation & rotation property name bikeshedding Chris Wilson
2014-02-13  8:51   ` Ville Syrjälä
2014-02-13 11:20 ` Chris Wilson
2014-02-13 11:58   ` Ville Syrjälä

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=1392239704-21776-4-git-send-email-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=sagar.a.kamble@intel.com \
    /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