Re: [RFC PATCH 06/11] exynos-gsc: replace v4l2_crop by v4l2_selection

2018-11-02 Thread Sylwester Nawrocki
On Fri, 5 Oct 2018 at 09:49, Hans Verkuil  wrote:
>
> From: Hans Verkuil 
>
> Replace the use of struct v4l2_crop by struct v4l2_selection.
> Also drop the unused gsc_g_crop function.
>
> Signed-off-by: Hans Verkuil 

Reviewed-by: Sylwester Nawrocki 


[RFC PATCH 06/11] exynos-gsc: replace v4l2_crop by v4l2_selection

2018-10-05 Thread Hans Verkuil
From: Hans Verkuil 

Replace the use of struct v4l2_crop by struct v4l2_selection.
Also drop the unused gsc_g_crop function.

Signed-off-by: Hans Verkuil 
---
 drivers/media/platform/exynos-gsc/gsc-core.c | 57 
 drivers/media/platform/exynos-gsc/gsc-core.h |  3 +-
 drivers/media/platform/exynos-gsc/gsc-m2m.c  | 23 
 3 files changed, 33 insertions(+), 50 deletions(-)

diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c 
b/drivers/media/platform/exynos-gsc/gsc-core.c
index 838c5c53de37..0fa3ec04ab7b 100644
--- a/drivers/media/platform/exynos-gsc/gsc-core.c
+++ b/drivers/media/platform/exynos-gsc/gsc-core.c
@@ -541,20 +541,7 @@ void gsc_check_crop_change(u32 tmp_w, u32 tmp_h, u32 *w, 
u32 *h)
}
 }
 
-int gsc_g_crop(struct gsc_ctx *ctx, struct v4l2_crop *cr)
-{
-   struct gsc_frame *frame;
-
-   frame = ctx_get_frame(ctx, cr->type);
-   if (IS_ERR(frame))
-   return PTR_ERR(frame);
-
-   cr->c = frame->crop;
-
-   return 0;
-}
-
-int gsc_try_crop(struct gsc_ctx *ctx, struct v4l2_crop *cr)
+int gsc_try_selection(struct gsc_ctx *ctx, struct v4l2_selection *s)
 {
struct gsc_frame *f;
struct gsc_dev *gsc = ctx->gsc_dev;
@@ -562,25 +549,25 @@ int gsc_try_crop(struct gsc_ctx *ctx, struct v4l2_crop 
*cr)
u32 mod_x = 0, mod_y = 0, tmp_w, tmp_h;
u32 min_w, min_h, max_w, max_h;
 
-   if (cr->c.top < 0 || cr->c.left < 0) {
+   if (s->r.top < 0 || s->r.left < 0) {
pr_err("doesn't support negative values for top & left\n");
return -EINVAL;
}
-   pr_debug("user put w: %d, h: %d", cr->c.width, cr->c.height);
+   pr_debug("user put w: %d, h: %d", s->r.width, s->r.height);
 
-   if (cr->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
+   if (s->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
f = >d_frame;
-   else if (cr->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
+   else if (s->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
f = >s_frame;
else
return -EINVAL;
 
max_w = f->f_width;
max_h = f->f_height;
-   tmp_w = cr->c.width;
-   tmp_h = cr->c.height;
+   tmp_w = s->r.width;
+   tmp_h = s->r.height;
 
-   if (V4L2_TYPE_IS_OUTPUT(cr->type)) {
+   if (V4L2_TYPE_IS_OUTPUT(s->type)) {
if ((is_yuv422(f->fmt->color) && f->fmt->num_comp == 1) ||
is_rgb(f->fmt->color))
min_w = 32;
@@ -602,8 +589,8 @@ int gsc_try_crop(struct gsc_ctx *ctx, struct v4l2_crop *cr)
max_h = f->f_width;
min_w = variant->pix_min->target_rot_en_w;
min_h = variant->pix_min->target_rot_en_h;
-   tmp_w = cr->c.height;
-   tmp_h = cr->c.width;
+   tmp_w = s->r.height;
+   tmp_h = s->r.width;
} else {
min_w = variant->pix_min->target_rot_dis_w;
min_h = variant->pix_min->target_rot_dis_h;
@@ -616,29 +603,29 @@ int gsc_try_crop(struct gsc_ctx *ctx, struct v4l2_crop 
*cr)
v4l_bound_align_image(_w, min_w, max_w, mod_x,
  _h, min_h, max_h, mod_y, 0);
 
-   if (!V4L2_TYPE_IS_OUTPUT(cr->type) &&
-   (ctx->gsc_ctrls.rotate->val == 90 ||
-   ctx->gsc_ctrls.rotate->val == 270))
+   if (!V4L2_TYPE_IS_OUTPUT(s->type) &&
+   (ctx->gsc_ctrls.rotate->val == 90 ||
+ctx->gsc_ctrls.rotate->val == 270))
gsc_check_crop_change(tmp_h, tmp_w,
-   >c.width, >c.height);
+   >r.width, >r.height);
else
gsc_check_crop_change(tmp_w, tmp_h,
-   >c.width, >c.height);
+   >r.width, >r.height);
 
 
/* adjust left/top if cropping rectangle is out of bounds */
/* Need to add code to algin left value with 2's multiple */
-   if (cr->c.left + tmp_w > max_w)
-   cr->c.left = max_w - tmp_w;
-   if (cr->c.top + tmp_h > max_h)
-   cr->c.top = max_h - tmp_h;
+   if (s->r.left + tmp_w > max_w)
+   s->r.left = max_w - tmp_w;
+   if (s->r.top + tmp_h > max_h)
+   s->r.top = max_h - tmp_h;
 
if ((is_yuv420(f->fmt->color) || is_yuv422(f->fmt->color)) &&
-   cr->c.left & 1)
-   cr->c.left -= 1;
+   s->r.left & 1)
+   s->r.left -= 1;
 
pr_debug("Aligned l:%d, t:%d, w:%d, h:%d, f_w: %d, f_h: %d",
-   cr->c.left, cr->c.top, cr->c.width, cr->c.height, max_w, max_h);
+s->r.left, s->r.top, s->r.width, s->r.height, max_w, max_h);
 
return 0;
 }
diff --git a/drivers/media/platform/exynos-gsc/gsc-core.h 
b/drivers/media/platform/exynos-gsc/gsc-core.h
index