diff options
| author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-06-16 07:54:51 -0400 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2015-07-02 08:57:58 -0400 |
| commit | c423bc85097327fba71f9a831280d09b64bb62b6 (patch) | |
| tree | 859cc24c100d643fc462e309b5de88eb3f83cf7e | |
| parent | a903e3b64adfc2e126237f06e0b3ea7d2d8d13b5 (diff) | |
drm/omap: check that plane is inside crtc
DRM allows planes to be partially off-screen, but DSS hardware does not.
This patch adds the necessary check to reject plane configs if the plane
is not fully inside the crtc.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
| -rw-r--r-- | drivers/gpu/drm/omapdrm/omap_plane.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_plane.c b/drivers/gpu/drm/omapdrm/omap_plane.c index cfa8276c4deb..098904696a5c 100644 --- a/drivers/gpu/drm/omapdrm/omap_plane.c +++ b/drivers/gpu/drm/omapdrm/omap_plane.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | * this program. If not, see <http://www.gnu.org/licenses/>. | 17 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | #include <drm/drm_atomic.h> | ||
| 20 | #include <drm/drm_atomic_helper.h> | 21 | #include <drm/drm_atomic_helper.h> |
| 21 | #include <drm/drm_plane_helper.h> | 22 | #include <drm/drm_plane_helper.h> |
| 22 | 23 | ||
| @@ -153,9 +154,34 @@ static void omap_plane_atomic_disable(struct drm_plane *plane, | |||
| 153 | dispc_ovl_enable(omap_plane->id, false); | 154 | dispc_ovl_enable(omap_plane->id, false); |
| 154 | } | 155 | } |
| 155 | 156 | ||
| 157 | static int omap_plane_atomic_check(struct drm_plane *plane, | ||
| 158 | struct drm_plane_state *state) | ||
| 159 | { | ||
| 160 | struct drm_crtc_state *crtc_state; | ||
| 161 | |||
| 162 | if (!state->crtc) | ||
| 163 | return 0; | ||
| 164 | |||
| 165 | crtc_state = drm_atomic_get_crtc_state(state->state, state->crtc); | ||
| 166 | if (IS_ERR(crtc_state)) | ||
| 167 | return PTR_ERR(crtc_state); | ||
| 168 | |||
| 169 | if (state->crtc_x < 0 || state->crtc_y < 0) | ||
| 170 | return -EINVAL; | ||
| 171 | |||
| 172 | if (state->crtc_x + state->crtc_w > crtc_state->adjusted_mode.hdisplay) | ||
| 173 | return -EINVAL; | ||
| 174 | |||
| 175 | if (state->crtc_y + state->crtc_h > crtc_state->adjusted_mode.vdisplay) | ||
| 176 | return -EINVAL; | ||
| 177 | |||
| 178 | return 0; | ||
| 179 | } | ||
| 180 | |||
| 156 | static const struct drm_plane_helper_funcs omap_plane_helper_funcs = { | 181 | static const struct drm_plane_helper_funcs omap_plane_helper_funcs = { |
| 157 | .prepare_fb = omap_plane_prepare_fb, | 182 | .prepare_fb = omap_plane_prepare_fb, |
| 158 | .cleanup_fb = omap_plane_cleanup_fb, | 183 | .cleanup_fb = omap_plane_cleanup_fb, |
| 184 | .atomic_check = omap_plane_atomic_check, | ||
| 159 | .atomic_update = omap_plane_atomic_update, | 185 | .atomic_update = omap_plane_atomic_update, |
| 160 | .atomic_disable = omap_plane_atomic_disable, | 186 | .atomic_disable = omap_plane_atomic_disable, |
| 161 | }; | 187 | }; |
