[media] v4l: vsp1: Fix BRU try compose rectangle storage
[deliverable/linux.git] / drivers / media / platform / vsp1 / vsp1_bru.c
index cb0dbc15ddadfa67270158158242171856c92681..d8b7bdeb5af5c33459e02e6e4197a2ed9437b08b 100644 (file)
@@ -42,13 +42,9 @@ static int bru_s_ctrl(struct v4l2_ctrl *ctrl)
        struct vsp1_bru *bru =
                container_of(ctrl->handler, struct vsp1_bru, ctrls);
 
-       if (!vsp1_entity_is_streaming(&bru->entity))
-               return 0;
-
        switch (ctrl->id) {
        case V4L2_CID_BG_COLOR:
-               vsp1_bru_write(bru, VI6_BRU_VIRRPF_COL, ctrl->val |
-                              (0xff << VI6_BRU_VIRRPF_COL_A_SHIFT));
+               bru->bgcolor = ctrl->val;
                break;
        }
 
@@ -70,11 +66,6 @@ static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
        struct v4l2_mbus_framefmt *format;
        unsigned int flags;
        unsigned int i;
-       int ret;
-
-       ret = vsp1_entity_set_streaming(&bru->entity, enable);
-       if (ret < 0)
-               return ret;
 
        if (!enable)
                return 0;
@@ -95,12 +86,17 @@ static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
                       flags & V4L2_PIX_FMT_FLAG_PREMUL_ALPHA ?
                       0 : VI6_BRU_INCTRL_NRM);
 
-       /* Set the background position to cover the whole output image. */
+       /* Set the background position to cover the whole output image and
+        * configure its color.
+        */
        vsp1_bru_write(bru, VI6_BRU_VIRRPF_SIZE,
                       (format->width << VI6_BRU_VIRRPF_SIZE_HSIZE_SHIFT) |
                       (format->height << VI6_BRU_VIRRPF_SIZE_VSIZE_SHIFT));
        vsp1_bru_write(bru, VI6_BRU_VIRRPF_LOC, 0);
 
+       vsp1_bru_write(bru, VI6_BRU_VIRRPF_COL, bru->bgcolor |
+                      (0xff << VI6_BRU_VIRRPF_COL_A_SHIFT));
+
        /* Route BRU input 1 as SRC input to the ROP unit and configure the ROP
         * unit with a NOP operation to make BRU input 1 available as the
         * Blend/ROP unit B SRC input.
@@ -199,7 +195,8 @@ static int bru_enum_mbus_code(struct v4l2_subdev *subdev,
                        return -EINVAL;
 
                format = vsp1_entity_get_pad_format(&bru->entity, cfg,
-                                                   BRU_PAD_SINK(0), code->which);
+                                                   BRU_PAD_SINK(0),
+                                                   code->which);
                code->code = format->code;
        }
 
@@ -231,7 +228,8 @@ static struct v4l2_rect *bru_get_compose(struct vsp1_bru *bru,
 {
        switch (which) {
        case V4L2_SUBDEV_FORMAT_TRY:
-               return v4l2_subdev_get_try_crop(&bru->entity.subdev, cfg, pad);
+               return v4l2_subdev_get_try_compose(&bru->entity.subdev, cfg,
+                                                  pad);
        case V4L2_SUBDEV_FORMAT_ACTIVE:
                return &bru->inputs[pad].compose;
        default:
@@ -239,7 +237,8 @@ static struct v4l2_rect *bru_get_compose(struct vsp1_bru *bru,
        }
 }
 
-static int bru_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
+static int bru_get_format(struct v4l2_subdev *subdev,
+                         struct v4l2_subdev_pad_config *cfg,
                          struct v4l2_subdev_format *fmt)
 {
        struct vsp1_bru *bru = to_bru(subdev);
@@ -250,7 +249,8 @@ static int bru_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_con
        return 0;
 }
 
-static void bru_try_format(struct vsp1_bru *bru, struct v4l2_subdev_pad_config *cfg,
+static void bru_try_format(struct vsp1_bru *bru,
+                          struct v4l2_subdev_pad_config *cfg,
                           unsigned int pad, struct v4l2_mbus_framefmt *fmt,
                           enum v4l2_subdev_format_whence which)
 {
@@ -278,7 +278,8 @@ static void bru_try_format(struct vsp1_bru *bru, struct v4l2_subdev_pad_config *
        fmt->colorspace = V4L2_COLORSPACE_SRGB;
 }
 
-static int bru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg,
+static int bru_set_format(struct v4l2_subdev *subdev,
+                         struct v4l2_subdev_pad_config *cfg,
                          struct v4l2_subdev_format *fmt)
 {
        struct vsp1_bru *bru = to_bru(subdev);
@@ -405,7 +406,6 @@ static struct v4l2_subdev_ops bru_ops = {
 
 struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1)
 {
-       struct v4l2_subdev *subdev;
        struct vsp1_bru *bru;
        int ret;
 
@@ -415,29 +415,18 @@ struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1)
 
        bru->entity.type = VSP1_ENTITY_BRU;
 
-       ret = vsp1_entity_init(vsp1, &bru->entity,
-                              vsp1->info->num_bru_inputs + 1);
+       ret = vsp1_entity_init(vsp1, &bru->entity, "bru",
+                              vsp1->info->num_bru_inputs + 1, &bru_ops);
        if (ret < 0)
                return ERR_PTR(ret);
 
-       /* Initialize the V4L2 subdev. */
-       subdev = &bru->entity.subdev;
-       v4l2_subdev_init(subdev, &bru_ops);
-
-       subdev->entity.ops = &vsp1->media_ops;
-       subdev->internal_ops = &vsp1_subdev_internal_ops;
-       snprintf(subdev->name, sizeof(subdev->name), "%s bru",
-                dev_name(vsp1->dev));
-       v4l2_set_subdevdata(subdev, bru);
-       subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-
-       vsp1_entity_init_formats(subdev, NULL);
-
        /* Initialize the control handler. */
        v4l2_ctrl_handler_init(&bru->ctrls, 1);
        v4l2_ctrl_new_std(&bru->ctrls, &bru_ctrl_ops, V4L2_CID_BG_COLOR,
                          0, 0xffffff, 1, 0);
 
+       bru->bgcolor = 0;
+
        bru->entity.subdev.ctrl_handler = &bru->ctrls;
 
        if (bru->ctrls.error) {
This page took 0.039755 seconds and 5 git commands to generate.