drm/msm/sde: fix atomic check for crtc driver
Current crtc module checks the number of planes
against the number of z order supported. This is not
a valid check because hardware may support less
z order stages compared to number of planes. This patch
fixes those checks and adds additional bound check
like plane is within crtc boundary, two planes do not
request for same z order, etc during atomic check.
Change-Id: If571888ec02f8aa94972543c76e8c5895751089a
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
diff --git a/drivers/gpu/drm/msm/sde/sde_kms.h b/drivers/gpu/drm/msm/sde/sde_kms.h
index f115d43..3e2d18f 100644
--- a/drivers/gpu/drm/msm/sde/sde_kms.h
+++ b/drivers/gpu/drm/msm/sde/sde_kms.h
@@ -52,6 +52,17 @@
#define SDE_ERROR(fmt, ...) pr_err(fmt, ##__VA_ARGS__)
+#define POPULATE_RECT(rect, a, b, c, d, Q16_flag) \
+ do { \
+ (rect)->x = (Q16_flag) ? (a) >> 16 : (a); \
+ (rect)->y = (Q16_flag) ? (b) >> 16 : (b); \
+ (rect)->w = (Q16_flag) ? (c) >> 16 : (c); \
+ (rect)->h = (Q16_flag) ? (d) >> 16 : (d); \
+ } while (0)
+
+#define CHECK_LAYER_BOUNDS(offset, size, max_size) \
+ (((size) > (max_size)) || ((offset) > ((max_size) - (size))))
+
/*
* struct sde_irq_callback - IRQ callback handlers
* @func: intr handler