[2/4] drm/rect: Add drm_rect_init()
diff mbox series

Message ID 20190930134214.24702-2-ville.syrjala@linux.intel.com
State New
Headers show
Series
  • [1/4] drm/rect: Add drm_rect_translate_to()
Related show

Commit Message

Ville Syrjälä Sept. 30, 2019, 1:42 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Add a helper to initialize a rectangle from x/y/w/h information.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 include/drm/drm_rect.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Patch
diff mbox series

diff --git a/include/drm/drm_rect.h b/include/drm/drm_rect.h
index fc7c14627ee2..cd0106135b6a 100644
--- a/include/drm/drm_rect.h
+++ b/include/drm/drm_rect.h
@@ -69,6 +69,23 @@  struct drm_rect {
 		(r)->x1 >> 16, (((r)->x1 & 0xffff) * 15625) >> 10, \
 		(r)->y1 >> 16, (((r)->y1 & 0xffff) * 15625) >> 10
 
+/**
+ * drm_rect_init - initialize the rectangle from x/y/w/h
+ * @r: rectangle
+ * @x: x coordinate
+ * @y: y coordinate
+ * @width: width
+ * @height: height
+ */
+static inline void drm_rect_init(struct drm_rect *r, int x, int y,
+				 int width, int height)
+{
+	r->x1 = x;
+	r->y1 = y;
+	r->x2 = x + width;
+	r->y2 = y + height;
+}
+
 /**
  * drm_rect_adjust_size - adjust the size of the rectangle
  * @r: rectangle to be adjusted