[media] v4l: vsp1: Store active selection rectangles in a pad config structure
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Sun, 15 Nov 2015 21:14:22 +0000 (19:14 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Wed, 13 Apr 2016 21:53:22 +0000 (18:53 -0300)
Use the pad config structure part of the vsp1_entity to store all active
pad selection rectangles. This generalizes the code to operate on pad
config structures.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/vsp1/vsp1_bru.c
drivers/media/platform/vsp1/vsp1_bru.h
drivers/media/platform/vsp1/vsp1_drm.c
drivers/media/platform/vsp1/vsp1_entity.c
drivers/media/platform/vsp1/vsp1_entity.h
drivers/media/platform/vsp1/vsp1_rpf.c
drivers/media/platform/vsp1/vsp1_rwpf.c
drivers/media/platform/vsp1/vsp1_rwpf.h
drivers/media/platform/vsp1/vsp1_video.c
drivers/media/platform/vsp1/vsp1_wpf.c

index a0aa0fb2a5e1926f8d07dcb825d084b003fe1c03..c1848a3ac010a50ff9f490fdc2b0928aec33e72e 100644 (file)
@@ -231,17 +231,9 @@ static int bru_enum_frame_size(struct v4l2_subdev *subdev,
 
 static struct v4l2_rect *bru_get_compose(struct vsp1_bru *bru,
                                         struct v4l2_subdev_pad_config *cfg,
-                                        unsigned int pad, u32 which)
+                                        unsigned int pad)
 {
-       switch (which) {
-       case V4L2_SUBDEV_FORMAT_TRY:
-               return v4l2_subdev_get_try_compose(&bru->entity.subdev, cfg,
-                                                  pad);
-       case V4L2_SUBDEV_FORMAT_ACTIVE:
-               return &bru->inputs[pad].compose;
-       default:
-               return NULL;
-       }
+       return v4l2_subdev_get_try_compose(&bru->entity.subdev, cfg, pad);
 }
 
 static int bru_get_format(struct v4l2_subdev *subdev,
@@ -310,7 +302,7 @@ static int bru_set_format(struct v4l2_subdev *subdev,
        if (fmt->pad != bru->entity.source_pad) {
                struct v4l2_rect *compose;
 
-               compose = bru_get_compose(bru, cfg, fmt->pad, fmt->which);
+               compose = bru_get_compose(bru, config, fmt->pad);
                compose->left = 0;
                compose->top = 0;
                compose->width = format->width;
@@ -336,6 +328,7 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
                             struct v4l2_subdev_selection *sel)
 {
        struct vsp1_bru *bru = to_bru(subdev);
+       struct v4l2_subdev_pad_config *config;
 
        if (sel->pad == bru->entity.source_pad)
                return -EINVAL;
@@ -349,7 +342,12 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
                return 0;
 
        case V4L2_SEL_TGT_COMPOSE:
-               sel->r = *bru_get_compose(bru, cfg, sel->pad, sel->which);
+               config = vsp1_entity_get_pad_config(&bru->entity, cfg,
+                                                   sel->which);
+               if (!config)
+                       return -EINVAL;
+
+               sel->r = *bru_get_compose(bru, config, sel->pad);
                return 0;
 
        default:
@@ -391,7 +389,7 @@ static int bru_set_selection(struct v4l2_subdev *subdev,
        sel->r.width = format->width;
        sel->r.height = format->height;
 
-       compose = bru_get_compose(bru, cfg, sel->pad, sel->which);
+       compose = bru_get_compose(bru, config, sel->pad);
        *compose = sel->r;
 
        return 0;
index 4e7d2e79b9404db863e902af95ce2ab8bfd7cfd9..828a3fcadea8b7d073f6a6724ff32f4ed5ea80c5 100644 (file)
@@ -31,7 +31,6 @@ struct vsp1_bru {
 
        struct {
                struct vsp1_rwpf *rpf;
-               struct v4l2_rect compose;
        } inputs[VSP1_MAX_RPF];
 
        u32 bgcolor;
index a73018c9e8b56d5da181c33dba40e8edd590788e..acbf36d315b9ba85faabf08312eefc35def75298 100644 (file)
@@ -410,9 +410,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
                __func__, sel.r.left, sel.r.top, sel.r.width, sel.r.height,
                sel.pad);
 
-       /* Store the compose rectangle coordinates in the RPF. */
-       rpf->location.left = dst->left;
-       rpf->location.top = dst->top;
+       /* Store the BRU input pad number in the RPF. */
+       rpf->bru_input = rpf->entity.index;
 
        /* Cache the memory buffer address but don't apply the values to the
         * hardware as the crop offsets haven't been computed yet.
index 5185a1f5d3b8babdbaa8b654221e82b652cb78d2..09c9a1b86e3aa7f935a12faf0851b91916e26ec1 100644 (file)
@@ -88,6 +88,14 @@ vsp1_entity_get_pad_format(struct vsp1_entity *entity,
        return v4l2_subdev_get_try_format(&entity->subdev, cfg, pad);
 }
 
+struct v4l2_rect *
+vsp1_entity_get_pad_compose(struct vsp1_entity *entity,
+                           struct v4l2_subdev_pad_config *cfg,
+                           unsigned int pad)
+{
+       return v4l2_subdev_get_try_compose(&entity->subdev, cfg, pad);
+}
+
 /*
  * vsp1_entity_init_cfg - Initialize formats on all pads
  * @subdev: V4L2 subdevice
index 7b2081aff8696ed7b8e3545c8b7dd2dcc4ff9a6e..f7a360823373c721424b0181cee17dc5d980a92b 100644 (file)
@@ -111,6 +111,10 @@ struct v4l2_mbus_framefmt *
 vsp1_entity_get_pad_format(struct vsp1_entity *entity,
                           struct v4l2_subdev_pad_config *cfg,
                           unsigned int pad);
+struct v4l2_rect *
+vsp1_entity_get_pad_compose(struct vsp1_entity *entity,
+                           struct v4l2_subdev_pad_config *cfg,
+                           unsigned int pad);
 int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
                         struct v4l2_subdev_pad_config *cfg);
 
index 3b55cd93983fbaaa7a92db5a476723c4eb3a3371..cb3d5ed148cc57f0381f21777e216585368d394e 100644 (file)
@@ -44,7 +44,9 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
        const struct v4l2_pix_format_mplane *format = &rpf->format;
        const struct v4l2_mbus_framefmt *source_format;
        const struct v4l2_mbus_framefmt *sink_format;
-       const struct v4l2_rect *crop = &rpf->crop;
+       const struct v4l2_rect *crop;
+       unsigned int left = 0;
+       unsigned int top = 0;
        u32 pstride;
        u32 infmt;
 
@@ -57,6 +59,8 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
         * left corner in the plane buffer. Only two offsets are needed, as
         * planes 2 and 3 always have identical strides.
         */
+       crop = vsp1_rwpf_get_crop(rpf, rpf->entity.config);
+
        vsp1_rpf_write(rpf, VI6_RPF_SRC_BSIZE,
                       (crop->width << VI6_RPF_SRC_BSIZE_BHSIZE_SHIFT) |
                       (crop->height << VI6_RPF_SRC_BSIZE_BVSIZE_SHIFT));
@@ -103,9 +107,19 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
        vsp1_rpf_write(rpf, VI6_RPF_DSWAP, fmtinfo->swap);
 
        /* Output location */
+       if (pipe->bru) {
+               const struct v4l2_rect *compose;
+
+               compose = vsp1_entity_get_pad_compose(pipe->bru,
+                                                     pipe->bru->config,
+                                                     rpf->bru_input);
+               left = compose->left;
+               top = compose->top;
+       }
+
        vsp1_rpf_write(rpf, VI6_RPF_LOC,
-                      (rpf->location.left << VI6_RPF_LOC_HCOORD_SHIFT) |
-                      (rpf->location.top << VI6_RPF_LOC_VCOORD_SHIFT));
+                      (left << VI6_RPF_LOC_HCOORD_SHIFT) |
+                      (top << VI6_RPF_LOC_VCOORD_SHIFT));
 
        /* Use the alpha channel (extended to 8 bits) when available or an
         * alpha value set through the V4L2_CID_ALPHA_COMPONENT control
index e5216d39723e9837b948a9546671a2f6b19903b4..0c5ad023adfbf677480dc211a0889c2c80ebb193 100644 (file)
@@ -76,19 +76,11 @@ int vsp1_rwpf_enum_frame_size(struct v4l2_subdev *subdev,
        return 0;
 }
 
-static struct v4l2_rect *
-vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf, struct v4l2_subdev_pad_config *cfg,
-                  u32 which)
+struct v4l2_rect *vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf,
+                                    struct v4l2_subdev_pad_config *config)
 {
-       switch (which) {
-       case V4L2_SUBDEV_FORMAT_TRY:
-               return v4l2_subdev_get_try_crop(&rwpf->entity.subdev, cfg,
-                                               RWPF_PAD_SINK);
-       case V4L2_SUBDEV_FORMAT_ACTIVE:
-               return &rwpf->crop;
-       default:
-               return NULL;
-       }
+       return v4l2_subdev_get_try_crop(&rwpf->entity.subdev, config,
+                                       RWPF_PAD_SINK);
 }
 
 int vsp1_rwpf_get_format(struct v4l2_subdev *subdev,
@@ -148,7 +140,7 @@ int vsp1_rwpf_set_format(struct v4l2_subdev *subdev,
        fmt->format = *format;
 
        /* Update the sink crop rectangle. */
-       crop = vsp1_rwpf_get_crop(rwpf, cfg, fmt->which);
+       crop = vsp1_rwpf_get_crop(rwpf, config);
        crop->left = 0;
        crop->top = 0;
        crop->width = fmt->format.width;
@@ -180,7 +172,7 @@ int vsp1_rwpf_get_selection(struct v4l2_subdev *subdev,
 
        switch (sel->target) {
        case V4L2_SEL_TGT_CROP:
-               sel->r = *vsp1_rwpf_get_crop(rwpf, cfg, sel->which);
+               sel->r = *vsp1_rwpf_get_crop(rwpf, config);
                break;
 
        case V4L2_SEL_TGT_CROP_BOUNDS:
@@ -246,7 +238,7 @@ int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
        sel->r.height = min_t(unsigned int, sel->r.height,
                              format->height - sel->r.top);
 
-       crop = vsp1_rwpf_get_crop(rwpf, cfg, sel->which);
+       crop = vsp1_rwpf_get_crop(rwpf, config);
        *crop = sel->r;
 
        /* Propagate the format to the source pad. */
index e8ca9b6ee689ccd4a3ff19fb95428425254b2702..4ebfab61e0ef2aa2d4cbe9aa597cae46d7d18d1d 100644 (file)
@@ -43,11 +43,7 @@ struct vsp1_rwpf {
 
        struct v4l2_pix_format_mplane format;
        const struct vsp1_format_info *fmtinfo;
-       struct {
-               unsigned int left;
-               unsigned int top;
-       } location;
-       struct v4l2_rect crop;
+       unsigned int bru_input;
 
        unsigned int alpha;
 
@@ -91,6 +87,8 @@ int vsp1_rwpf_set_selection(struct v4l2_subdev *subdev,
                            struct v4l2_subdev_pad_config *cfg,
                            struct v4l2_subdev_selection *sel);
 
+struct v4l2_rect *vsp1_rwpf_get_crop(struct vsp1_rwpf *rwpf,
+                                    struct v4l2_subdev_pad_config *config);
 /**
  * vsp1_rwpf_set_memory - Configure DMA addresses for a [RW]PF
  * @rwpf: the [RW]PF instance
index 102977ae1daa9c25a78a04ed5dc0515b40b4780e..d4a092c8ece3db400365abcba546fa001c36f942 100644 (file)
@@ -182,9 +182,6 @@ static int vsp1_video_pipeline_validate_branch(struct vsp1_pipeline *pipe,
        bool bru_found = false;
        int ret;
 
-       input->location.left = 0;
-       input->location.top = 0;
-
        ret = media_entity_enum_init(&ent_enum, &input->entity.vsp1->media_dev);
        if (ret < 0)
                return ret;
@@ -206,18 +203,14 @@ static int vsp1_video_pipeline_validate_branch(struct vsp1_pipeline *pipe,
                entity = to_vsp1_entity(
                        media_entity_to_v4l2_subdev(pad->entity));
 
-               /* A BRU is present in the pipeline, store the compose rectangle
-                * location in the input RPF for use when configuring the RPF.
+               /* A BRU is present in the pipeline, store the BRU input pad
+                * number in the input RPF for use when configuring the RPF.
                 */
                if (entity->type == VSP1_ENTITY_BRU) {
                        struct vsp1_bru *bru = to_bru(&entity->subdev);
-                       struct v4l2_rect *rect =
-                               &bru->inputs[pad->index].compose;
 
                        bru->inputs[pad->index].rpf = input;
-
-                       input->location.left = rect->left;
-                       input->location.top = rect->top;
+                       input->bru_input = pad->index;
 
                        bru_found = true;
                }
index c86d31f274bf7bea1337e71c5acdc3b4fe03d5ec..0797927d14cff482f631be98d4cf4875389aaa7b 100644 (file)
@@ -44,7 +44,7 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
        struct vsp1_device *vsp1 = wpf->entity.vsp1;
        const struct v4l2_mbus_framefmt *source_format;
        const struct v4l2_mbus_framefmt *sink_format;
-       const struct v4l2_rect *crop = &wpf->crop;
+       const struct v4l2_rect *crop;
        unsigned int i;
        u32 srcrpf = 0;
        u32 outfmt = 0;
@@ -88,6 +88,8 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
                                       format->plane_fmt[1].bytesperline);
        }
 
+       crop = vsp1_rwpf_get_crop(wpf, wpf->entity.config);
+
        vsp1_wpf_write(wpf, VI6_WPF_HSZCLIP, VI6_WPF_SZCLIP_EN |
                       (crop->left << VI6_WPF_SZCLIP_OFST_SHIFT) |
                       (crop->width << VI6_WPF_SZCLIP_SIZE_SHIFT));
This page took 0.033905 seconds and 5 git commands to generate.