media: renesas: vsp1: Drop vsp1_entity_get_pad_selection() wrapper
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Sun, 12 Nov 2023 02:14:05 +0000 (04:14 +0200)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Wed, 19 Jun 2024 22:36:46 +0000 (01:36 +0300)
The vsp1_entity_get_pad_selection() function is just a wrapper around
v4l2_subdev_state_get_crop() or v4l2_subdev_state_get_compose() without
any added value. Drop it and call the functions it wraps directly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
drivers/media/platform/renesas/vsp1/vsp1_entity.c
drivers/media/platform/renesas/vsp1/vsp1_entity.h
drivers/media/platform/renesas/vsp1/vsp1_hgo.c
drivers/media/platform/renesas/vsp1/vsp1_hgt.c
drivers/media/platform/renesas/vsp1/vsp1_histo.c
drivers/media/platform/renesas/vsp1/vsp1_rpf.c
drivers/media/platform/renesas/vsp1/vsp1_uif.c

index fa748cf89d44f53a4331449c5782896484164f91..8d39f1ee00ab08d9f53c0123193e16f4affe9249 100644 (file)
@@ -127,32 +127,6 @@ vsp1_entity_get_state(struct vsp1_entity *entity,
        }
 }
 
-/**
- * vsp1_entity_get_pad_selection - Get a pad selection from storage for entity
- * @entity: the entity
- * @sd_state: the state storage
- * @pad: the pad number
- * @target: the selection target
- *
- * Return the selection rectangle stored in the given configuration for an
- * entity's pad. The configuration can be an ACTIVE or TRY configuration. The
- * selection target can be COMPOSE or CROP.
- */
-struct v4l2_rect *
-vsp1_entity_get_pad_selection(struct vsp1_entity *entity,
-                             struct v4l2_subdev_state *sd_state,
-                             unsigned int pad, unsigned int target)
-{
-       switch (target) {
-       case V4L2_SEL_TGT_COMPOSE:
-               return v4l2_subdev_state_get_compose(sd_state, pad);
-       case V4L2_SEL_TGT_CROP:
-               return v4l2_subdev_state_get_crop(sd_state, pad);
-       default:
-               return NULL;
-       }
-}
-
 /*
  * vsp1_subdev_get_pad_format - Subdev pad get_fmt handler
  * @subdev: V4L2 subdevice
@@ -361,15 +335,13 @@ int vsp1_subdev_set_pad_format(struct v4l2_subdev *subdev,
        *format = fmt->format;
 
        /* Reset the crop and compose rectangles. */
-       selection = vsp1_entity_get_pad_selection(entity, state, fmt->pad,
-                                                 V4L2_SEL_TGT_CROP);
+       selection = v4l2_subdev_state_get_crop(state, fmt->pad);
        selection->left = 0;
        selection->top = 0;
        selection->width = format->width;
        selection->height = format->height;
 
-       selection = vsp1_entity_get_pad_selection(entity, state, fmt->pad,
-                                                 V4L2_SEL_TGT_COMPOSE);
+       selection = v4l2_subdev_state_get_compose(state, fmt->pad);
        selection->left = 0;
        selection->top = 0;
        selection->width = format->width;
index e913befe7fc8c2e3c6d597e89f9e6f12c37d91f0..802c0c2acab01863a2159555581173ee3c5c159e 100644 (file)
@@ -138,10 +138,6 @@ struct v4l2_subdev_state *
 vsp1_entity_get_state(struct vsp1_entity *entity,
                      struct v4l2_subdev_state *sd_state,
                      enum v4l2_subdev_format_whence which);
-struct v4l2_rect *
-vsp1_entity_get_pad_selection(struct vsp1_entity *entity,
-                             struct v4l2_subdev_state *sd_state,
-                             unsigned int pad, unsigned int target);
 
 void vsp1_entity_route_setup(struct vsp1_entity *entity,
                             struct vsp1_pipeline *pipe,
index 40c571a987ef90d44ae0f6d41e4b93c9ed902df1..4ee5f0e5e9c343ae466ca31e86d468721f3b3c18 100644 (file)
@@ -140,11 +140,8 @@ static void hgo_configure_stream(struct vsp1_entity *entity,
        unsigned int hratio;
        unsigned int vratio;
 
-       crop = vsp1_entity_get_pad_selection(entity, entity->state,
-                                            HISTO_PAD_SINK, V4L2_SEL_TGT_CROP);
-       compose = vsp1_entity_get_pad_selection(entity, entity->state,
-                                               HISTO_PAD_SINK,
-                                               V4L2_SEL_TGT_COMPOSE);
+       crop = v4l2_subdev_state_get_crop(entity->state, HISTO_PAD_SINK);
+       compose = v4l2_subdev_state_get_compose(entity->state, HISTO_PAD_SINK);
 
        vsp1_hgo_write(hgo, dlb, VI6_HGO_REGRST, VI6_HGO_REGRST_RCLEA);
 
index 8281b86874abade7924da0a5945d2c796129fbd2..b739d80455760e4b5eec850caafeb9bd61b3221b 100644 (file)
@@ -139,11 +139,8 @@ static void hgt_configure_stream(struct vsp1_entity *entity,
        u8 upper;
        unsigned int i;
 
-       crop = vsp1_entity_get_pad_selection(entity, entity->state,
-                                            HISTO_PAD_SINK, V4L2_SEL_TGT_CROP);
-       compose = vsp1_entity_get_pad_selection(entity, entity->state,
-                                               HISTO_PAD_SINK,
-                                               V4L2_SEL_TGT_COMPOSE);
+       crop = v4l2_subdev_state_get_crop(entity->state, HISTO_PAD_SINK);
+       compose = v4l2_subdev_state_get_compose(entity->state, HISTO_PAD_SINK);
 
        vsp1_hgt_write(hgt, dlb, VI6_HGT_REGRST, VI6_HGT_REGRST_RCLEA);
 
index 0d7e4afae0f84650f8e1f07d844463e0cdb4fb26..85d2fc538327dca88f8b583509013e7b27a2e860 100644 (file)
@@ -218,9 +218,7 @@ static int histo_get_selection(struct v4l2_subdev *subdev,
        switch (sel->target) {
        case V4L2_SEL_TGT_COMPOSE_BOUNDS:
        case V4L2_SEL_TGT_COMPOSE_DEFAULT:
-               crop = vsp1_entity_get_pad_selection(&histo->entity, state,
-                                                    HISTO_PAD_SINK,
-                                                    V4L2_SEL_TGT_CROP);
+               crop = v4l2_subdev_state_get_crop(state, HISTO_PAD_SINK);
                sel->r.left = 0;
                sel->r.top = 0;
                sel->r.width = crop->width;
@@ -237,9 +235,11 @@ static int histo_get_selection(struct v4l2_subdev *subdev,
                break;
 
        case V4L2_SEL_TGT_COMPOSE:
+               sel->r = *v4l2_subdev_state_get_compose(state, sel->pad);
+               break;
+
        case V4L2_SEL_TGT_CROP:
-               sel->r = *vsp1_entity_get_pad_selection(&histo->entity, state,
-                                                       sel->pad, sel->target);
+               sel->r = *v4l2_subdev_state_get_crop(state, sel->pad);
                break;
 
        default:
@@ -256,9 +256,7 @@ static int histo_set_crop(struct v4l2_subdev *subdev,
                          struct v4l2_subdev_state *sd_state,
                          struct v4l2_subdev_selection *sel)
 {
-       struct vsp1_histogram *histo = subdev_to_histo(subdev);
        struct v4l2_mbus_framefmt *format;
-       struct v4l2_rect *selection;
 
        /* The crop rectangle must be inside the input frame. */
        format = v4l2_subdev_state_get_format(sd_state, HISTO_PAD_SINK);
@@ -270,14 +268,8 @@ static int histo_set_crop(struct v4l2_subdev *subdev,
                                format->height - sel->r.top);
 
        /* Set the crop rectangle and reset the compose rectangle. */
-       selection = vsp1_entity_get_pad_selection(&histo->entity, sd_state,
-                                                 sel->pad, V4L2_SEL_TGT_CROP);
-       *selection = sel->r;
-
-       selection = vsp1_entity_get_pad_selection(&histo->entity, sd_state,
-                                                 sel->pad,
-                                                 V4L2_SEL_TGT_COMPOSE);
-       *selection = sel->r;
+       *v4l2_subdev_state_get_crop(sd_state, sel->pad) = sel->r;
+       *v4l2_subdev_state_get_compose(sd_state, sel->pad) = sel->r;
 
        return 0;
 }
@@ -286,7 +278,6 @@ static int histo_set_compose(struct v4l2_subdev *subdev,
                             struct v4l2_subdev_state *sd_state,
                             struct v4l2_subdev_selection *sel)
 {
-       struct vsp1_histogram *histo = subdev_to_histo(subdev);
        struct v4l2_rect *compose;
        struct v4l2_rect *crop;
        unsigned int ratio;
@@ -299,9 +290,7 @@ static int histo_set_compose(struct v4l2_subdev *subdev,
        sel->r.left = 0;
        sel->r.top = 0;
 
-       crop = vsp1_entity_get_pad_selection(&histo->entity, sd_state,
-                                            sel->pad,
-                                            V4L2_SEL_TGT_CROP);
+       crop = v4l2_subdev_state_get_crop(sd_state, sel->pad);
 
        /*
         * Clamp the width and height to acceptable values first and then
@@ -326,9 +315,7 @@ static int histo_set_compose(struct v4l2_subdev *subdev,
        ratio = 1 << (crop->height * 2 / sel->r.height / 3);
        sel->r.height = crop->height / ratio;
 
-       compose = vsp1_entity_get_pad_selection(&histo->entity, sd_state,
-                                               sel->pad,
-                                               V4L2_SEL_TGT_COMPOSE);
+       compose = v4l2_subdev_state_get_compose(sd_state, sel->pad);
        *compose = sel->r;
 
        return 0;
index 19d9f078748ce612c25cac1603e2e7b3d4f7d797..4efcec5253d60f1c3065e1fba94faaae3ab51fe3 100644 (file)
@@ -155,10 +155,8 @@ static void rpf_configure_stream(struct vsp1_entity *entity,
        if (pipe->brx) {
                const struct v4l2_rect *compose;
 
-               compose = vsp1_entity_get_pad_selection(pipe->brx,
-                                                       pipe->brx->state,
-                                                       rpf->brx_input,
-                                                       V4L2_SEL_TGT_COMPOSE);
+               compose = v4l2_subdev_state_get_compose(pipe->brx->state,
+                                                       rpf->brx_input);
                left = compose->left;
                top = compose->top;
        }
index ee5b6ba228981c4a0a4ce9a7a663e9ffcf35e1b8..cecd2f7024f40a4f40a76449d6ce97ed6090ad89 100644 (file)
@@ -112,8 +112,7 @@ static int uif_get_selection(struct v4l2_subdev *subdev,
                break;
 
        case V4L2_SEL_TGT_CROP:
-               sel->r = *vsp1_entity_get_pad_selection(&uif->entity, state,
-                                                       sel->pad, sel->target);
+               sel->r = *v4l2_subdev_state_get_crop(state, sel->pad);
                break;
 
        default:
@@ -159,8 +158,7 @@ static int uif_set_selection(struct v4l2_subdev *subdev,
                                format->height - sel->r.top);
 
        /* Store the crop rectangle. */
-       selection = vsp1_entity_get_pad_selection(&uif->entity, state,
-                                                 sel->pad, V4L2_SEL_TGT_CROP);
+       selection = v4l2_subdev_state_get_crop(state, sel->pad);
        *selection = sel->r;
 
 done:
@@ -202,8 +200,7 @@ static void uif_configure_stream(struct vsp1_entity *entity,
        vsp1_uif_write(uif, dlb, VI6_UIF_DISCOM_DOCMPMR,
                       VI6_UIF_DISCOM_DOCMPMR_SEL(9));
 
-       crop = vsp1_entity_get_pad_selection(entity, entity->state,
-                                            UIF_PAD_SINK, V4L2_SEL_TGT_CROP);
+       crop = v4l2_subdev_state_get_crop(entity->state, UIF_PAD_SINK);
 
        left = crop->left;
        width = crop->width;