diff mbox series

[2/2] venus: venc: fix handlig of S_SELECTION and G_SELECTION

Message ID 1600968674-11559-3-git-send-email-dikshita@codeaurora.org
State New
Headers show
Series Venus: fix handling of crop and s_fmt | expand

Commit Message

Dikshita Agarwal Sept. 24, 2020, 5:31 p.m. UTC
From: Stanimir Varbanov <stanimir.varbanov@linaro.org>

- return correct width and height for G_SELECTION
- if requested rectangle wxh doesn't match with capture port wxh
  adjust the rectangle to supported wxh.

Signed-off-by: Dikshita Agarwal <dikshita@codeaurora.org>
---
 drivers/media/platform/qcom/venus/venc.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

Comments

Stanimir Varbanov Sept. 24, 2020, 11:09 p.m. UTC | #1
On 9/24/20 8:31 PM, Dikshita Agarwal wrote:
> From: Stanimir Varbanov <stanimir.varbanov@linaro.org>

> 

> - return correct width and height for G_SELECTION

> - if requested rectangle wxh doesn't match with capture port wxh

>   adjust the rectangle to supported wxh.

> 

> Signed-off-by: Dikshita Agarwal <dikshita@codeaurora.org>

> ---

>  drivers/media/platform/qcom/venus/venc.c | 20 ++++++++++++--------

>  1 file changed, 12 insertions(+), 8 deletions(-)

> 

> diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c

> index 7d2aaa8..a2cc12d 100644

> --- a/drivers/media/platform/qcom/venus/venc.c

> +++ b/drivers/media/platform/qcom/venus/venc.c

> @@ -463,13 +463,13 @@ static int venc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)

>  	switch (s->target) {

>  	case V4L2_SEL_TGT_CROP_DEFAULT:

>  	case V4L2_SEL_TGT_CROP_BOUNDS:

> -		s->r.width = inst->width;

> -		s->r.height = inst->height;

> -		break;

> -	case V4L2_SEL_TGT_CROP:

>  		s->r.width = inst->out_width;

>  		s->r.height = inst->out_height;

>  		break;

> +	case V4L2_SEL_TGT_CROP:

> +		s->r.width = inst->width;

> +		s->r.height = inst->height;

> +		break;

>  	default:

>  		return -EINVAL;

>  	}

> @@ -490,10 +490,14 @@ static int venc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)

>  

>  	switch (s->target) {

>  	case V4L2_SEL_TGT_CROP:

> -		if (s->r.width != inst->out_width ||

> -		    s->r.height != inst->out_height ||

> -		    s->r.top != 0 || s->r.left != 0)

> -			return -EINVAL;

> +		if (s->r.width != inst->width ||

> +		    s->r.height != inst->height ||

> +		    s->r.top != 0 || s->r.left != 0) {


In fact the 'if' statement is not needed. Just fill s->r.

> +			s->r.top = 0;

> +			s->r.left = 0;

> +			s->r.width = inst->width;

> +			s->r.height = inst->height;

> +		}

>  		break;

>  	default:

>  		return -EINVAL;

> 


-- 
regards,
Stan
Tomasz Figa Sept. 25, 2020, 8:55 p.m. UTC | #2
Hi Dikshita, Stanimir,

On Thu, Sep 24, 2020 at 7:31 PM Dikshita Agarwal
<dikshita@codeaurora.org> wrote:
>

> From: Stanimir Varbanov <stanimir.varbanov@linaro.org>

>

> - return correct width and height for G_SELECTION

> - if requested rectangle wxh doesn't match with capture port wxh

>   adjust the rectangle to supported wxh.

>

> Signed-off-by: Dikshita Agarwal <dikshita@codeaurora.org>

> ---

>  drivers/media/platform/qcom/venus/venc.c | 20 ++++++++++++--------

>  1 file changed, 12 insertions(+), 8 deletions(-)

>

> diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c

> index 7d2aaa8..a2cc12d 100644

> --- a/drivers/media/platform/qcom/venus/venc.c

> +++ b/drivers/media/platform/qcom/venus/venc.c

> @@ -463,13 +463,13 @@ static int venc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)

>         switch (s->target) {

>         case V4L2_SEL_TGT_CROP_DEFAULT:

>         case V4L2_SEL_TGT_CROP_BOUNDS:

> -               s->r.width = inst->width;

> -               s->r.height = inst->height;

> -               break;

> -       case V4L2_SEL_TGT_CROP:

>                 s->r.width = inst->out_width;

>                 s->r.height = inst->out_height;

>                 break;

> +       case V4L2_SEL_TGT_CROP:

> +               s->r.width = inst->width;

> +               s->r.height = inst->height;

> +               break;

>         default:

>                 return -EINVAL;

>         }

> @@ -490,10 +490,14 @@ static int venc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)

>

>         switch (s->target) {

>         case V4L2_SEL_TGT_CROP:

> -               if (s->r.width != inst->out_width ||

> -                   s->r.height != inst->out_height ||

> -                   s->r.top != 0 || s->r.left != 0)

> -                       return -EINVAL;

> +               if (s->r.width != inst->width ||

> +                   s->r.height != inst->height ||

> +                   s->r.top != 0 || s->r.left != 0) {

> +                       s->r.top = 0;

> +                       s->r.left = 0;

> +                       s->r.width = inst->width;

> +                       s->r.height = inst->height;


What's the point of exposing the selection API if no selection can
actually be done?

Best regards,
Tomasz
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 7d2aaa8..a2cc12d 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -463,13 +463,13 @@  static int venc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
 	switch (s->target) {
 	case V4L2_SEL_TGT_CROP_DEFAULT:
 	case V4L2_SEL_TGT_CROP_BOUNDS:
-		s->r.width = inst->width;
-		s->r.height = inst->height;
-		break;
-	case V4L2_SEL_TGT_CROP:
 		s->r.width = inst->out_width;
 		s->r.height = inst->out_height;
 		break;
+	case V4L2_SEL_TGT_CROP:
+		s->r.width = inst->width;
+		s->r.height = inst->height;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -490,10 +490,14 @@  static int venc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
 
 	switch (s->target) {
 	case V4L2_SEL_TGT_CROP:
-		if (s->r.width != inst->out_width ||
-		    s->r.height != inst->out_height ||
-		    s->r.top != 0 || s->r.left != 0)
-			return -EINVAL;
+		if (s->r.width != inst->width ||
+		    s->r.height != inst->height ||
+		    s->r.top != 0 || s->r.left != 0) {
+			s->r.top = 0;
+			s->r.left = 0;
+			s->r.width = inst->width;
+			s->r.height = inst->height;
+		}
 		break;
 	default:
 		return -EINVAL;