Move the parameter validation before buffer space checking
so that we can exit early if it fails.
Also don't reset the G2D context anymore in this situation
(since the buffers are not partially submitted).

Signed-off-by: Tobias Jakobi <[email protected]>
---
 exynos/exynos_fimg2d.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
index 9b7bcce..185aa80 100644
--- a/exynos/exynos_fimg2d.c
+++ b/exynos/exynos_fimg2d.c
@@ -375,17 +375,7 @@ g2d_copy(struct g2d_context *ctx, struct g2d_image *src,
 {
        union g2d_rop4_val rop4;
        union g2d_point_val pt;
-       unsigned int src_w = 0, src_h = 0, dst_w = 0, dst_h = 0;
-
-       g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
-       g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
-       g2d_add_base_addr(ctx, dst, g2d_dst);
-       g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride);
-
-       g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
-       g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode);
-       g2d_add_base_addr(ctx, src, g2d_src);
-       g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride);
+       unsigned int src_w, src_h, dst_w, dst_h;
 
        src_w = w;
        src_h = h;
@@ -406,10 +396,22 @@ g2d_copy(struct g2d_context *ctx, struct g2d_image *src,
 
        if (w <= 0 || h <= 0) {
                fprintf(stderr, "invalid width or height.\n");
-               g2d_reset(ctx);
                return -EINVAL;
        }
 
+       if (g2d_check_space(ctx, 11, 2))
+               return -ENOSPC;
+
+       g2d_add_cmd(ctx, DST_SELECT_REG, G2D_SELECT_MODE_BGCOLOR);
+       g2d_add_cmd(ctx, DST_COLOR_MODE_REG, dst->color_mode);
+       g2d_add_base_addr(ctx, dst, g2d_dst);
+       g2d_add_cmd(ctx, DST_STRIDE_REG, dst->stride);
+
+       g2d_add_cmd(ctx, SRC_SELECT_REG, G2D_SELECT_MODE_NORMAL);
+       g2d_add_cmd(ctx, SRC_COLOR_MODE_REG, src->color_mode);
+       g2d_add_base_addr(ctx, src, g2d_src);
+       g2d_add_cmd(ctx, SRC_STRIDE_REG, src->stride);
+
        pt.val = 0;
        pt.data.x = src_x;
        pt.data.y = src_y;
-- 
2.0.5

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to