drm/exynos: fix clipping when scaling is enabled
authorMarek Szyprowski <m.szyprowski@samsung.com>
Mon, 30 Nov 2015 13:53:28 +0000 (14:53 +0100)
committerInki Dae <daeinki@gmail.com>
Sun, 13 Dec 2015 13:22:58 +0000 (22:22 +0900)
This patch fixes calculation of src x/y offset for negative crtc x/y
values when scaling is enabled. This fixes possible IOMMU fault when
scaling is enabled.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
drivers/gpu/drm/exynos/exynos_drm_plane.c

index 9eaa8627175f7ff49ee4ac05c4042a8b7a9c03f3..427aeec78a28ac3e1f25b850e289a8fb365fc837 100644 (file)
@@ -85,25 +85,26 @@ static void exynos_plane_mode_set(struct exynos_drm_plane_state *exynos_state)
        src_w = state->src_w >> 16;
        src_h = state->src_h >> 16;
 
+       /* set ratio */
+       exynos_state->h_ratio = (src_w << 16) / crtc_w;
+       exynos_state->v_ratio = (src_h << 16) / crtc_h;
+
+       /* clip to visible area */
        actual_w = exynos_plane_get_size(crtc_x, crtc_w, mode->hdisplay);
        actual_h = exynos_plane_get_size(crtc_y, crtc_h, mode->vdisplay);
 
        if (crtc_x < 0) {
                if (actual_w)
-                       src_x -= crtc_x;
+                       src_x += ((-crtc_x) * exynos_state->h_ratio) >> 16;
                crtc_x = 0;
        }
 
        if (crtc_y < 0) {
                if (actual_h)
-                       src_y -= crtc_y;
+                       src_y += ((-crtc_y) * exynos_state->v_ratio) >> 16;
                crtc_y = 0;
        }
 
-       /* set ratio */
-       exynos_state->h_ratio = (src_w << 16) / crtc_w;
-       exynos_state->v_ratio = (src_h << 16) / crtc_h;
-
        /* set drm framebuffer data. */
        exynos_state->src.x = src_x;
        exynos_state->src.y = src_y;
This page took 0.025833 seconds and 5 git commands to generate.