Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/omap: add sanity plane state check

Call drm_atomic_helper_check_plane_state() from the plane
atomic_check() callback in order to add plane state sanity
checking.

It will permit filtering out totally bad scaling factors, even
if the real check are done later in the atomic commit.

Calling drm_atomic_helper_check_plane_state() also sets
plane_state->visible which will be useful when dynamically
assigning hw overlays to planes.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211117141928.771082-2-narmstrong@baylibre.com

authored by

Neil Armstrong and committed by
Tomi Valkeinen
c21134b0 fe4d0b63

+15
+15
drivers/gpu/drm/omapdrm/omap_plane.c
··· 104 104 dispc_ovl_enable(priv->dispc, omap_plane->id, false); 105 105 } 106 106 107 + #define FRAC_16_16(mult, div) (((mult) << 16) / (div)) 108 + 107 109 static int omap_plane_atomic_check(struct drm_plane *plane, 108 110 struct drm_atomic_state *state) 109 111 { 110 112 struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, 111 113 plane); 112 114 struct drm_crtc_state *crtc_state; 115 + int ret; 113 116 114 117 if (!new_plane_state->fb) 115 118 return 0; ··· 129 126 130 127 if (!crtc_state->enable) 131 128 return 0; 129 + 130 + /* 131 + * Note: these are just sanity checks to filter out totally bad scaling 132 + * factors. The real limits must be calculated case by case, and 133 + * unfortunately we currently do those checks only at the commit 134 + * phase in dispc. 135 + */ 136 + ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state, 137 + FRAC_16_16(1, 8), FRAC_16_16(8, 1), 138 + true, true); 139 + if (ret) 140 + return ret; 132 141 133 142 if (new_plane_state->crtc_x < 0 || new_plane_state->crtc_y < 0) 134 143 return -EINVAL;