Skip to content

Commit c21134b

Browse files
superna9999tomba
authored andcommitted
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 <[email protected]> Signed-off-by: Neil Armstrong <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Signed-off-by: Tomi Valkeinen <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent fe4d0b6 commit c21134b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/gpu/drm/omapdrm/omap_plane.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@ static void omap_plane_atomic_disable(struct drm_plane *plane,
104104
dispc_ovl_enable(priv->dispc, omap_plane->id, false);
105105
}
106106

107+
#define FRAC_16_16(mult, div) (((mult) << 16) / (div))
108+
107109
static int omap_plane_atomic_check(struct drm_plane *plane,
108110
struct drm_atomic_state *state)
109111
{
110112
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
111113
plane);
112114
struct drm_crtc_state *crtc_state;
115+
int ret;
113116

114117
if (!new_plane_state->fb)
115118
return 0;
@@ -127,6 +130,18 @@ static int omap_plane_atomic_check(struct drm_plane *plane,
127130
if (!crtc_state->enable)
128131
return 0;
129132

133+
/*
134+
* Note: these are just sanity checks to filter out totally bad scaling
135+
* factors. The real limits must be calculated case by case, and
136+
* unfortunately we currently do those checks only at the commit
137+
* phase in dispc.
138+
*/
139+
ret = drm_atomic_helper_check_plane_state(new_plane_state, crtc_state,
140+
FRAC_16_16(1, 8), FRAC_16_16(8, 1),
141+
true, true);
142+
if (ret)
143+
return ret;
144+
130145
if (new_plane_state->crtc_x < 0 || new_plane_state->crtc_y < 0)
131146
return -EINVAL;
132147

0 commit comments

Comments
 (0)