Linux Samsung SOC development
 help / color / mirror / Atom feed
From: Inki Dae <inki.dae@samsung.com>
To: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>,
	linux-samsung-soc@vger.kernel.org
Cc: gustavo.padovan@collabora.co.uk, emil.l.velikov@gmail.com,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 08/14] exynos/fimg2d: check buffer space in g2d_blend()
Date: Mon, 31 Aug 2015 22:19:50 +0900	[thread overview]
Message-ID: <55E45476.6030008@samsung.com> (raw)
In-Reply-To: <1440425649-9768-9-git-send-email-tjakobi@math.uni-bielefeld.de>

On 2015년 08월 24일 23:14, Tobias Jakobi wrote:
> Move parameter validation to the top and also validate
> the select mode of the source image and the requested
> blending operation before starting command submission.
> 
> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> ---
>  exynos/exynos_fimg2d.c | 66 +++++++++++++++++++++++++++++---------------------
>  1 file changed, 39 insertions(+), 27 deletions(-)
> 
> diff --git a/exynos/exynos_fimg2d.c b/exynos/exynos_fimg2d.c
> index 781aff5..5acccf8 100644
> --- a/exynos/exynos_fimg2d.c
> +++ b/exynos/exynos_fimg2d.c
> @@ -623,7 +623,45 @@ g2d_blend(struct g2d_context *ctx, struct g2d_image *src,
>  	union g2d_point_val pt;
>  	union g2d_bitblt_cmd_val bitblt;
>  	union g2d_blend_func_val blend;
> -	unsigned int src_w = 0, src_h = 0, dst_w = 0, dst_h = 0;
> +	unsigned int gem_space;
> +	unsigned int src_w, src_h, dst_w, dst_h;
> +
> +	src_w = w;
> +	src_h = h;
> +	if (src_x + w > src->width)
> +		src_w = src->width - src_x;
> +	if (src_y + h > src->height)
> +		src_h = src->height - src_y;
> +
> +	dst_w = w;
> +	dst_h = h;
> +	if (dst_x + w > dst->width)
> +		dst_w = dst->width - dst_x;
> +	if (dst_y + h > dst->height)
> +		dst_h = dst->height - dst_y;
> +
> +	w = MIN(src_w, dst_w);
> +	h = MIN(src_h, dst_h);
> +
> +	if (w <= 0 || h <= 0) {
> +		fprintf(stderr, "invalid width or height.\n");
> +		return -EINVAL;
> +	}
> +
> +	if (g2d_validate_select_mode(src->select_mode)) {
> +		fprintf(stderr , "invalid select mode for source.\n");
> +		return -EINVAL;
> +	}
> +
> +	if (g2d_validate_blending_op(op)) {
> +		fprintf(stderr , "unsupported blending operation.\n");
> +		return -EINVAL;
> +	}
> +
> +	gem_space = src->select_mode == G2D_SELECT_MODE_NORMAL ? 2 : 1;
> +
> +	if (g2d_check_space(ctx, 12, gem_space))
> +		return -ENOSPC;

As I mentioned before, above two lines could be integrated with other
patches.

Thanks,
Inki Dae

>  
>  	bitblt.val = 0;
>  	blend.val = 0;
> @@ -651,32 +689,6 @@ g2d_blend(struct g2d_context *ctx, struct g2d_image *src,
>  	case G2D_SELECT_MODE_BGCOLOR:
>  		g2d_add_cmd(ctx, BG_COLOR_REG, src->color);
>  		break;
> -	default:
> -		fprintf(stderr , "failed to set src.\n");
> -		return -EINVAL;
> -	}
> -
> -	src_w = w;
> -	src_h = h;
> -	if (src_x + w > src->width)
> -		src_w = src->width - src_x;
> -	if (src_y + h > src->height)
> -		src_h = src->height - src_y;
> -
> -	dst_w = w;
> -	dst_h = h;
> -	if (dst_x + w > dst->width)
> -		dst_w = dst->width - dst_x;
> -	if (dst_y + h > dst->height)
> -		dst_h = dst->height - dst_y;
> -
> -	w = MIN(src_w, dst_w);
> -	h = MIN(src_h, dst_h);
> -
> -	if (w <= 0 || h <= 0) {
> -		fprintf(stderr, "invalid width or height.\n");
> -		g2d_reset(ctx);
> -		return -EINVAL;
>  	}
>  
>  	bitblt.data.alpha_blend_mode = G2D_ALPHA_BLEND_MODE_ENABLE;
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-08-31 13:19 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-24 14:13 [PATCH 00/14] drm/exynos: rewrite fimg2d error handling Tobias Jakobi
2015-08-24 14:13 ` [PATCH 01/14] exynos/fimg2d: fix empty buffer handling in g2d_flush() Tobias Jakobi
2015-08-24 14:13 ` [PATCH 02/14] exynos/fimg2d: simplify base address submission in g2d_scale_and_blend() Tobias Jakobi
2015-08-24 14:13 ` [PATCH 03/14] exynos/fimg2d: add g2d_check_space() Tobias Jakobi
2015-08-24 14:13 ` [PATCH 04/14] exynos/fimg2d: check buffer space in g2d_solid_fill() Tobias Jakobi
2015-08-31 13:01   ` Inki Dae
2015-08-31 19:27     ` Tobias Jakobi
2015-08-31 19:57       ` Emil Velikov
2015-09-01  0:41         ` Inki Dae
2015-08-24 14:14 ` [PATCH 05/14] exynos/fimg2d: check buffer space in g2d_copy() Tobias Jakobi
2015-08-31 13:06   ` Inki Dae
2015-08-24 14:14 ` [PATCH 06/14] exynos/fimg2d: check buffer space in g2d_copy_with_scale() Tobias Jakobi
2015-08-24 14:14 ` [PATCH 07/14] exynos/fimg2d: add g2d_validate_xyz() functions Tobias Jakobi
2015-08-31 13:18   ` Inki Dae
2015-08-31 18:45     ` Emil Velikov
2015-08-31 19:31       ` Tobias Jakobi
2015-08-24 14:14 ` [PATCH 08/14] exynos/fimg2d: check buffer space in g2d_blend() Tobias Jakobi
2015-08-31 13:19   ` Inki Dae [this message]
2015-08-24 14:14 ` [PATCH 09/14] exynos/fimg2d: check buffer space in g2d_scale_and_blend() Tobias Jakobi
2015-08-31 13:20   ` Inki Dae
2015-08-24 14:14 ` [PATCH 10/14] exynos/fimg2d: remove default case from g2d_get_blend_op() Tobias Jakobi
2015-08-31 13:25   ` Inki Dae
2015-08-31 18:53     ` Emil Velikov
2015-09-01  0:39       ` Inki Dae
2015-09-02 19:35         ` Tobias Jakobi
2015-08-24 14:14 ` [PATCH 11/14] exynos/fimg2d: remove superfluous initialization of g2d_point_val Tobias Jakobi
2015-08-24 14:14 ` [PATCH 12/14] exynos/fimg2d: make g2d_add_cmd() less heavy Tobias Jakobi
2015-08-24 14:14 ` [PATCH 13/14] exynos/fimg2d: add message prefix Tobias Jakobi
2015-08-27 17:21 ` [PATCH 00/14] drm/exynos: rewrite fimg2d error handling Emil Velikov
2015-08-27 20:46   ` Tobias Jakobi
2015-09-01  0:47     ` Inki Dae

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55E45476.6030008@samsung.com \
    --to=inki.dae@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=tjakobi@math.uni-bielefeld.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox