[PATCH 1/3] drm/arm: hdlcd: properly validate plane state
Russell King
rmk+kernel at armlinux.org.uk
Fri Mar 31 02:51:41 PDT 2017
The hdlcd crtc is unable to place planes in arbitary positions and sizes
within the active area. Use drm_plane_helper_check_state() to validate
the requested state.
Suggested-by: Daniel Vetter <daniel at ffwll.ch>
Signed-off-by: Russell King <rmk+kernel at armlinux.org.uk>
---
drivers/gpu/drm/arm/hdlcd_crtc.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 7d4e5aa77195..ba68fa2b5701 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -10,6 +10,7 @@
*/
#include <drm/drmP.h>
+#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_crtc.h>
#include <drm/drm_crtc_helper.h>
@@ -205,13 +206,30 @@ static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = {
static int hdlcd_plane_atomic_check(struct drm_plane *plane,
struct drm_plane_state *state)
{
- u32 src_w, src_h;
+ struct drm_crtc_state *crtc_state;
+ struct drm_crtc *crtc;
+ struct drm_rect clip = { 0 };
+ int ret;
+
+ crtc = state->crtc;
+ if (!crtc)
+ return 0;
- src_w = state->src_w >> 16;
- src_h = state->src_h >> 16;
+ crtc_state = drm_atomic_get_existing_crtc_state(state->state, crtc);
+ if (!crtc_state->enable)
+ return -EINVAL;
+
+ clip.x2 = crtc_state->adjusted_mode.hdisplay;
+ clip.y2 = crtc_state->adjusted_mode.vdisplay;
+
+ ret = drm_plane_helper_check_state(state, &clip,
+ DRM_PLANE_HELPER_NO_SCALING,
+ DRM_PLANE_HELPER_NO_SCALING,
+ false, true);
+ if (ret)
+ return ret;
- /* we can't do any scaling of the plane source */
- if ((src_w != state->crtc_w) || (src_h != state->crtc_h))
+ if (!state->visible)
return -EINVAL;
return 0;
--
2.7.4
More information about the linux-arm-kernel
mailing list