fimc-is: Adaptation to V4L2 API changes
authorSylwester Nawrocki <s.nawrocki@samsung.com>
Wed, 21 Mar 2018 16:24:35 +0000 (17:24 +0100)
committerJunghoon Kim <jhoon20.kim@samsung.com>
Thu, 14 Feb 2019 05:57:19 +0000 (14:57 +0900)
Change-Id: Ia944801f9bd161bb4381b679a0d0b6920bb3d35d
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
18 files changed:
drivers/media/platform/exynos/fimc-is/fimc-is-core.h
drivers/media/platform/exynos/fimc-is/fimc-is-device-csi.c
drivers/media/platform/exynos/fimc-is/fimc-is-device-flite.c
drivers/media/platform/exynos/fimc-is/fimc-is-device-sensor.c
drivers/media/platform/exynos/fimc-is/fimc-is-mem.c
drivers/media/platform/exynos/fimc-is/fimc-is-mem.h
drivers/media/platform/exynos/fimc-is/fimc-is-type.h
drivers/media/platform/exynos/fimc-is/fimc-is-video-3aa.c
drivers/media/platform/exynos/fimc-is/fimc-is-video-3aac.c
drivers/media/platform/exynos/fimc-is/fimc-is-video-isp.c
drivers/media/platform/exynos/fimc-is/fimc-is-video-scc.c
drivers/media/platform/exynos/fimc-is/fimc-is-video-scp.c
drivers/media/platform/exynos/fimc-is/fimc-is-video-sensor.c
drivers/media/platform/exynos/fimc-is/fimc-is-video-vdisc.c
drivers/media/platform/exynos/fimc-is/fimc-is-video-vdiso.c
drivers/media/platform/exynos/fimc-is/fimc-is-video.c
drivers/media/platform/exynos/fimc-is/fimc-is-video.h
drivers/media/platform/exynos/fimc-is/sensor/fimc-is-device-6d1.c

index 5925a36..9a74abf 100644 (file)
@@ -78,6 +78,9 @@
 
 #define FIMC_IS_MAX_SENSOR_NAME_LEN            (16)
 
+#define FIMC_IS_IOCTL_S_CTRL                   0x1000
+#define FIMC_IS_IOCTL_G_CTRL                   0x2000
+
 #define FIMC_IS_A5_MEM_SIZE            (0x01400000)
 #define FIMC_IS_REGION_SIZE            (0x00005000)
 #define FIMC_IS_SETFILE_SIZE           (0x00140000)
index afad826..0926689 100644 (file)
@@ -280,20 +280,24 @@ static int csi_s_param(struct v4l2_subdev *subdev, struct v4l2_streamparm *param
        return ret;
 }
 
-static int csi_s_format(struct v4l2_subdev *subdev, struct v4l2_mbus_framefmt *fmt)
+static int csi_set_format(struct v4l2_subdev *sd,
+                         struct v4l2_subdev_pad_config *cfg,
+                         struct v4l2_subdev_format *format)
 {
-       int ret = 0;
        struct fimc_is_device_csi *csi;
+       struct v4l2_mbus_framefmt *fmt;
 
-       BUG_ON(!subdev);
-       BUG_ON(!fmt);
+       BUG_ON(!sd);
+       BUG_ON(!format);
 
-       csi = v4l2_get_subdevdata(subdev);
+       csi = v4l2_get_subdevdata(sd);
        if (!csi) {
                err("csi is NULL");
                return -EINVAL;
        }
 
+       fmt = &format->format;
+
        csi->image.window.offs_h = 0;
        csi->image.window.offs_v = 0;
        csi->image.window.width = fmt->width;
@@ -303,19 +307,24 @@ static int csi_s_format(struct v4l2_subdev *subdev, struct v4l2_mbus_framefmt *f
        csi->image.format.pixelformat = fmt->code;
        csi->image.format.field = fmt->field;
 
-       mdbgd_front("%s(%dx%d, %X)\n", csi, __func__, fmt->width, fmt->height, fmt->code);
-       return ret;
+       mdbgd_front("%s(%dx%d, %X)\n", csi, __func__, fmt->width,fmt->height,
+                   fmt->code);
+       return 0;
 }
 
+static const struct v4l2_subdev_pad_ops pad_ops = {
+       .set_fmt = csi_set_format
+};
+
 static const struct v4l2_subdev_video_ops video_ops = {
        .s_stream = csi_s_stream,
        .s_parm = csi_s_param,
-       .s_mbus_fmt = csi_s_format
 };
 
 static const struct v4l2_subdev_ops subdev_ops = {
        .core = &core_ops,
-       .video = &video_ops
+       .pad = &pad_ops,
+       .video = &video_ops,
 };
 
 #ifdef DBG_CSIISR
index ca45acb..7c28a85 100644 (file)
@@ -1494,26 +1494,48 @@ p_err:
        return ret;
 }
 
-/* value : csi ch */
-static long flite_init(struct v4l2_subdev *subdev, unsigned int cmd,
-                      void *value)
+/* cmd: 0, value : csi ch */
+static long flite_subdev_ioctl(struct v4l2_subdev *subdev, unsigned int cmd,
+                              void *value)
 {
-       int ret = 0;
        struct fimc_is_device_flite *flite;
+       struct v4l2_control *ctrl;
+       u32 width, height, ratio;
 
        BUG_ON(!subdev);
 
        flite = v4l2_get_subdevdata(subdev);
        if (!flite) {
                err("flite is NULL");
-               ret = -EINVAL;
-               goto p_err;
+               return -EINVAL;
        }
 
-       flite->csi = (long)value;
+       switch (cmd) {
+       case 0:
+               flite->csi = (long)value;
+               break;
 
-p_err:
-       return ret;
+       case FIMC_IS_IOCTL_S_CTRL:
+               ctrl = value;
+               if (ctrl->id == V4L2_CID_IS_S_BNS) {
+                       width = flite->image.window.width;
+                       height = flite->image.window.height;
+                       ratio = ctrl->value;
+
+                       flite->image.window.otf_width
+                               = rounddown((width * 1000 / ratio), 4);
+                       flite->image.window.otf_height
+                               = rounddown((height * 1000 / ratio), 2);
+               } else {
+                       err("Unsupported ctrl->id: %#x", ctrl->id);
+               }
+               break;
+       default:
+               err("Unsupported ioctl: %#x", cmd);
+               return -EINVAL;
+       }
+
+       return 0;
 }
 
 static int flite_stream_on(struct v4l2_subdev *subdev,
@@ -1774,15 +1796,20 @@ p_err:
        return 0;
 }
 
-static int flite_s_format(struct v4l2_subdev *subdev, struct v4l2_mbus_framefmt *fmt)
+static int flite_set_format(struct v4l2_subdev *sd,
+                           struct v4l2_subdev_pad_config *cfg,
+                           struct v4l2_subdev_format *format)
 {
        int ret = 0;
        struct fimc_is_device_flite *flite;
+       struct v4l2_mbus_framefmt *fmt;
 
-       BUG_ON(!subdev);
-       BUG_ON(!fmt);
+       BUG_ON(!sd);
+       BUG_ON(!format);
 
-       flite = v4l2_get_subdevdata(subdev);
+       fmt = &format->format;
+
+       flite = v4l2_get_subdevdata(sd);
        if (!flite) {
                err("flite is NULL");
                ret = -EINVAL;
@@ -1802,58 +1829,21 @@ p_err:
        return ret;
 }
 
-static int flite_s_ctrl(struct v4l2_subdev *subdev, struct v4l2_control *ctrl)
-{
-       int ret = 0;
-       struct fimc_is_device_flite *flite;
-
-       BUG_ON(!subdev);
-       BUG_ON(!ctrl);
-
-       flite = v4l2_get_subdevdata(subdev);
-       if (!flite) {
-               err("flite is NULL");
-               ret = -EINVAL;
-               goto p_err;
-       }
-
-       switch (ctrl->id) {
-       case V4L2_CID_IS_S_BNS:
-               {
-                       u32 width, height, ratio;
-
-                       width = flite->image.window.width;
-                       height = flite->image.window.height;
-                       ratio = ctrl->value;
-
-                       flite->image.window.otf_width
-                               = rounddown((width * 1000 / ratio), 4);
-                       flite->image.window.otf_height
-                               = rounddown((height * 1000 / ratio), 2);
-               }
-               break;
-       default:
-               err("unsupported ioctl(%d)\n", ctrl->id);
-               ret = -EINVAL;
-               break;
-       }
-
-p_err:
-       return ret;
-}
-
 static const struct v4l2_subdev_core_ops core_ops = {
-       .ioctl = flite_init,
-       .s_ctrl = flite_s_ctrl,
+       .ioctl = flite_subdev_ioctl,
+};
+
+static const struct v4l2_subdev_pad_ops pad_ops = {
+       .set_fmt = flite_set_format
 };
 
 static const struct v4l2_subdev_video_ops video_ops = {
        .s_stream = flite_s_stream,
-       .s_mbus_fmt = flite_s_format
 };
 
 static const struct v4l2_subdev_ops subdev_ops = {
        .core = &core_ops,
+       .pad = &pad_ops,
        .video = &video_ops
 };
 
index 1af7553..1eb12cb 100644 (file)
@@ -1176,7 +1176,7 @@ int fimc_is_sensor_s_format(struct fimc_is_device_sensor *device,
        struct v4l2_subdev *subdev_csi;
        struct v4l2_subdev *subdev_flite;
        struct fimc_is_module_enum *module;
-       struct v4l2_mbus_framefmt subdev_format;
+       struct v4l2_subdev_format subdev_format;
 
        BUG_ON(!device);
        BUG_ON(!device->subdev_module);
@@ -1209,26 +1209,27 @@ int fimc_is_sensor_s_format(struct fimc_is_device_sensor *device,
        device->image.window.height = height;
        device->image.window.o_height = height;
 
-       subdev_format.code = format->pixelformat;
-       subdev_format.field = format->field;
-       subdev_format.width = width;
-       subdev_format.height = height;
+       subdev_format.format.code = format->pixelformat;
+       subdev_format.format.field = format->field;
+       subdev_format.format.width = width;
+       subdev_format.format.height = height;
 
        if (test_bit(FIMC_IS_SENSOR_DRIVING, &device->state)) {
-               ret = v4l2_subdev_call(subdev_module, video, s_mbus_fmt, &subdev_format);
+               ret = v4l2_subdev_call(subdev_module, pad, set_fmt, NULL,
+                                      &subdev_format);
                if (ret) {
                        merr("v4l2_module_call(s_format) failed(%d)", device, ret);
                        goto p_err;
                }
        }
 
-       ret = v4l2_subdev_call(subdev_csi, video, s_mbus_fmt, &subdev_format);
+       ret = v4l2_subdev_call(subdev_csi, pad, set_fmt, NULL, &subdev_format);
        if (ret) {
                merr("v4l2_csi_call(s_format) failed(%d)", device, ret);
                goto p_err;
        }
 
-       ret = v4l2_subdev_call(subdev_flite, video, s_mbus_fmt, &subdev_format);
+       ret = v4l2_subdev_call(subdev_flite, pad, set_fmt, NULL, &subdev_format);
        if (ret) {
                merr("v4l2_flite_call(s_format) failed(%d)", device, ret);
                goto p_err;
@@ -1340,23 +1341,18 @@ p_err:
 int fimc_is_sensor_s_ctrl(struct fimc_is_device_sensor *device,
        struct v4l2_control *ctrl)
 {
-       int ret = 0;
-       struct v4l2_subdev *subdev_module;
+       int ret;
 
        BUG_ON(!device);
        BUG_ON(!device->subdev_module);
        BUG_ON(!device->subdev_csi);
        BUG_ON(!ctrl);
 
-       subdev_module = device->subdev_module;
-
-       ret = v4l2_subdev_call(subdev_module, core, s_ctrl, ctrl);
-       if (ret) {
-               err("s_ctrl failed(%d)", ret);
-               goto p_err;
-       }
+       ret = v4l2_subdev_call(device->subdev_module, core, ioctl,
+                              FIMC_IS_IOCTL_S_CTRL, ctrl);
+       if (ret)
+               err("FIMC_IS_IOCTL_S_CTRL failed: %d", ret);
 
-p_err:
        return ret;
 }
 
@@ -1468,25 +1464,20 @@ p_err:
 }
 
 int fimc_is_sensor_g_ctrl(struct fimc_is_device_sensor *device,
-       struct v4l2_control *ctrl)
+                         struct v4l2_control *ctrl)
 {
-       int ret = 0;
-       struct v4l2_subdev *subdev_module;
+       int ret;
 
        BUG_ON(!device);
        BUG_ON(!device->subdev_module);
        BUG_ON(!device->subdev_csi);
        BUG_ON(!ctrl);
 
-       subdev_module = device->subdev_module;
-
-       ret = v4l2_subdev_call(subdev_module, core, g_ctrl, ctrl);
-       if (ret) {
-               err("g_ctrl failed(%d)", ret);
-               goto p_err;
-       }
+       ret = v4l2_subdev_call(device->subdev_module, core, ioctl,
+                              FIMC_IS_IOCTL_G_CTRL, ctrl);
+       if (ret)
+               err("FIMC_IS_IOCTL_G_CTRL failed: %d", ret);
 
-p_err:
        return ret;
 }
 
index 0186ba0..e3f2f1f 100644 (file)
@@ -47,12 +47,6 @@ static void * plane_kvaddr(struct vb2_buffer *vb, u32 plane_no)
        return kvaddr;
 }
 
-
-static void *fimc_is_dma_contig_init(struct platform_device *pdev)
-{
-       return vb2_dma_contig_init_ctx(&pdev->dev);
-}
-
 int vb2_null_attach_iommu(void *alloc_ctx)
 {
        return 0;
@@ -73,9 +67,8 @@ void vb2_null_destroy_context(void *ctx)
 
 }
 
-const struct fimc_is_vb2 fimc_is_vb2_dc = {
+static const struct fimc_is_vb2 fimc_is_vb2_dc = {
        .ops            = &vb2_dma_contig_memops,
-       .init           = fimc_is_dma_contig_init,
        .cleanup        = vb2_null_destroy_context,
        .plane_addr     = plane_addr,
        .plane_kvaddr   = plane_kvaddr,
@@ -83,21 +76,11 @@ const struct fimc_is_vb2 fimc_is_vb2_dc = {
        .suspend        = vb2_null_detach_iommu,
        .set_cacheable  = vb2_null_set_cached,
 };
-#define fimc_is_vb2_allocator (&fimc_is_vb2_dc)
 
-int fimc_is_mem_probe(struct fimc_is_mem *this,
-       struct platform_device *pdev)
+int fimc_is_mem_probe(struct fimc_is_mem *this, struct platform_device *pdev)
 {
-       u32 ret = 0;
+       this->vb2 = &fimc_is_vb2_dc;
 
-       this->vb2 = fimc_is_vb2_allocator;
-
-       this->alloc_ctx = this->vb2->init(pdev);
-       if (IS_ERR(this->alloc_ctx)) {
-               ret = PTR_ERR(this->alloc_ctx);
-               goto p_err;
-       }
-
-p_err:
-       return ret;
+       this->pdev = pdev;
+       return 0;
 }
index 3da243f..6de1417 100644 (file)
@@ -55,8 +55,6 @@ struct fimc_is_vb2 {
 
 struct fimc_is_mem {
        struct platform_device          *pdev;
-       struct vb2_alloc_ctx            *alloc_ctx;
-
        const struct fimc_is_vb2        *vb2;
 };
 
index 89aef2a..d6955a5 100644 (file)
@@ -22,7 +22,7 @@ struct fimc_is_window {
 
 struct fimc_is_fmt {
        char                            *name;
-       enum v4l2_mbus_pixelcode        mbus_code;
+       u32                             mbus_code;
        u32                             pixelformat;
        u32                             field;
        u32                             num_planes;
index 37df891..0143c1d 100644 (file)
@@ -777,11 +777,10 @@ const struct v4l2_ioctl_ops fimc_is_3aa_video_ioctl_ops = {
 };
 
 static int fimc_is_3aa_queue_setup(struct vb2_queue *vbq,
-       const struct v4l2_format *fmt,
        unsigned int *num_buffers,
        unsigned int *num_planes,
        unsigned int sizes[],
-       void *allocators[])
+       struct device *alloc_devs[])
 {
        int ret = 0;
        struct fimc_is_video_ctx *vctx = vbq->drv_priv;
@@ -796,11 +795,8 @@ static int fimc_is_3aa_queue_setup(struct vb2_queue *vbq,
        queue = GET_VCTX_QUEUE(vctx, vbq);
        video = vctx->video;
 
-       ret = fimc_is_queue_setup(queue,
-               video->alloc_ctx,
-               num_planes,
-               sizes,
-               allocators);
+       ret = fimc_is_queue_setup(queue, video->alloc_dev,
+                                 num_planes, sizes, alloc_devs);
        if (ret)
                merr("fimc_is_queue_setup failed(%d)", vctx, ret);
 
@@ -893,17 +889,17 @@ static void fimc_is_3aa_buffer_queue(struct vb2_buffer *vb)
        struct fimc_is_queue *queue;
 
        BUG_ON(!vctx);
-       index = vb->v4l2_buf.index;
+       index = vb->index;
 
 #ifdef DBG_STREAMING
-       mdbgv_3aa("%s(%02d:%d)\n", vctx, __func__, vb->v4l2_buf.type, index);
+       mdbgv_3aa("%s(%02d:%d)\n", vctx, __func__, vb->type, index);
 #endif
 
        video = vctx->video;
        device = vctx->device;
        leader = &device->group_3aa.leader;
 
-       if (V4L2_TYPE_IS_OUTPUT(vb->v4l2_buf.type)) {
+       if (V4L2_TYPE_IS_OUTPUT(vb->type)) {
                queue = GET_SRC_QUEUE(vctx);
                ret = fimc_is_queue_buffer_queue(queue, video->vb2, vb);
                if (ret) {
@@ -934,7 +930,7 @@ static void fimc_is_3aa_buffer_queue(struct vb2_buffer *vb)
 
 static void fimc_is_3aa_buffer_finish(struct vb2_buffer *vb)
 {
-       u32 index = vb->v4l2_buf.index;
+       u32 index = vb->index;
        struct fimc_is_video_ctx *vctx = vb->vb2_queue->drv_priv;
        struct fimc_is_device_ischain *device = vctx->device;
        struct fimc_is_group *group = &device->group_3aa;
@@ -945,10 +941,10 @@ static void fimc_is_3aa_buffer_finish(struct vb2_buffer *vb)
        BUG_ON(!device);
 
 #ifdef DBG_STREAMING
-       mdbgv_3aa("%s(%02d:%d)\n", vctx, __func__, vb->v4l2_buf.type, index);
+       mdbgv_3aa("%s(%02d:%d)\n", vctx, __func__, vb->type, index);
 #endif
 
-       if (V4L2_TYPE_IS_OUTPUT(vb->v4l2_buf.type)) {
+       if (V4L2_TYPE_IS_OUTPUT(vb->type)) {
                queue = vctx->q_src;
                fimc_is_ischain_3aa_buffer_finish(device, index);
        } else {
index 6964e21..9ed4be4 100644 (file)
@@ -560,11 +560,10 @@ const struct v4l2_ioctl_ops fimc_is_3aac_video_ioctl_ops = {
 };
 
 static int fimc_is_3aac_queue_setup(struct vb2_queue *vbq,
-       const struct v4l2_format *fmt,
        unsigned int *num_buffers,
        unsigned int *num_planes,
        unsigned int sizes[],
-       void *allocators[])
+       struct device *alloc_devs[])
 {
        int ret = 0;
        struct fimc_is_video_ctx *vctx = vbq->drv_priv;
@@ -579,11 +578,8 @@ static int fimc_is_3aac_queue_setup(struct vb2_queue *vbq,
        queue = GET_VCTX_QUEUE(vctx, vbq);
        video = vctx->video;
 
-       ret = fimc_is_queue_setup(queue,
-               video->alloc_ctx,
-               num_planes,
-               sizes,
-               allocators);
+       ret = fimc_is_queue_setup(queue, video->alloc_dev,
+                                 num_planes, sizes, alloc_devs);
        if (ret)
                merr("fimc_is_queue_setup failed(%d)", vctx, ret);
 
@@ -664,7 +660,7 @@ static void fimc_is_3aac_buffer_queue(struct vb2_buffer *vb)
        BUG_ON(!vctx);
 
 #ifdef DBG_STREAMING
-       mdbgv_3aac("%s(%d)\n", vctx, __func__, vb->v4l2_buf.index);
+       mdbgv_3aac("%s(%d)\n", vctx, __func__, vb->index);
 #endif
 
        queue = GET_DST_QUEUE(vctx);
@@ -678,7 +674,7 @@ static void fimc_is_3aac_buffer_queue(struct vb2_buffer *vb)
                return;
        }
 
-       ret = fimc_is_subdev_buffer_queue(subdev, vb->v4l2_buf.index);
+       ret = fimc_is_subdev_buffer_queue(subdev, vb->index);
        if (ret) {
                merr("fimc_is_subdev_buffer_queue failed(%d)", vctx, ret);
                return;
@@ -692,10 +688,10 @@ static void fimc_is_3aac_buffer_finish(struct vb2_buffer *vb)
        struct fimc_is_subdev *subdev = &ischain->taac;
 
 #ifdef DBG_STREAMING
-       mdbgv_3aac("%s(%d)\n", vctx, __func__, vb->v4l2_buf.index);
+       mdbgv_3aac("%s(%d)\n", vctx, __func__, vb->index);
 #endif
 
-       fimc_is_subdev_buffer_finish(subdev, vb->v4l2_buf.index);
+       fimc_is_subdev_buffer_finish(subdev, vb->index);
 }
 
 const struct vb2_ops fimc_is_3aac_qops = {
index 6d8ede2..9bc3716 100644 (file)
@@ -805,10 +805,9 @@ const struct v4l2_ioctl_ops fimc_is_isp_video_ioctl_ops = {
 };
 
 static int fimc_is_isp_queue_setup(struct vb2_queue *vbq,
-       const struct v4l2_format *fmt,
        unsigned int *num_buffers, unsigned int *num_planes,
        unsigned int sizes[],
-       void *allocators[])
+       struct device *alloc_devs[])
 {
        int ret = 0;
        struct fimc_is_video_ctx *vctx = vbq->drv_priv;
@@ -823,11 +822,8 @@ static int fimc_is_isp_queue_setup(struct vb2_queue *vbq,
        queue = GET_SRC_QUEUE(vctx);
        video = vctx->video;
 
-       ret = fimc_is_queue_setup(queue,
-               video->alloc_ctx,
-               num_planes,
-               sizes,
-               allocators);
+       ret = fimc_is_queue_setup(queue, video->alloc_dev,
+                                 num_planes, sizes, alloc_devs);
        if (ret)
                merr("fimc_is_queue_setup failed(%d)", vctx, ret);
 
@@ -909,7 +905,7 @@ static void fimc_is_isp_buffer_queue(struct vb2_buffer *vb)
        struct fimc_is_device_ischain *device;
 
        BUG_ON(!vctx);
-       index = vb->v4l2_buf.index;
+       index = vb->index;
 
 #ifdef DBG_STREAMING
        mdbgv_isp("%s(%d)\n", vctx, __func__, index);
@@ -943,10 +939,10 @@ static void fimc_is_isp_buffer_finish(struct vb2_buffer *vb)
        }
 
 #ifdef DBG_STREAMING
-       mdbgv_isp("%s(%d)\n", vctx, __func__, vb->v4l2_buf.index);
+       mdbgv_isp("%s(%d)\n", vctx, __func__, vb->index);
 #endif
 
-       fimc_is_ischain_isp_buffer_finish(device, vb->v4l2_buf.index);
+       fimc_is_ischain_isp_buffer_finish(device, vb->index);
 }
 
 const struct vb2_ops fimc_is_isp_qops = {
index 994bf39..015f4c5 100644 (file)
@@ -549,10 +549,9 @@ const struct v4l2_ioctl_ops fimc_is_scc_video_ioctl_ops = {
 };
 
 static int fimc_is_scc_queue_setup(struct vb2_queue *vbq,
-       const struct v4l2_format *fmt,
        unsigned int *num_buffers,
        unsigned int *num_planes, unsigned int sizes[],
-       void *allocators[])
+       struct device *alloc_devs[])
 {
        int ret = 0;
        struct fimc_is_video_ctx *vctx = vbq->drv_priv;
@@ -567,11 +566,8 @@ static int fimc_is_scc_queue_setup(struct vb2_queue *vbq,
        queue = GET_DST_QUEUE(vctx);
        video = vctx->video;
 
-       ret = fimc_is_queue_setup(queue,
-               video->alloc_ctx,
-               num_planes,
-               sizes,
-               allocators);
+       ret = fimc_is_queue_setup(queue, video->alloc_dev,
+                                 num_planes, sizes, alloc_devs);
        if (ret)
                merr("fimc_is_queue_setup failed(%d)", vctx, ret);
 
@@ -658,7 +654,7 @@ static void fimc_is_scc_buffer_queue(struct vb2_buffer *vb)
                return;
        }
 
-       ret = fimc_is_subdev_buffer_queue(scc, vb->v4l2_buf.index);
+       ret = fimc_is_subdev_buffer_queue(scc, vb->index);
        if (ret) {
                merr("fimc_is_subdev_buffer_queue failed(%d)", vctx, ret);
                return;
@@ -674,13 +670,13 @@ static void fimc_is_scc_buffer_finish(struct vb2_buffer *vb)
        BUG_ON(!vctx);
 
 #ifdef DBG_STREAMING
-       mdbgv_scc("%s(%d)\n", vctx, __func__, vb->v4l2_buf.index);
+       mdbgv_scc("%s(%d)\n", vctx, __func__, vb->index);
 #endif
 
        device = vctx->device;
        subdev = &device->scc;
 
-       fimc_is_subdev_buffer_finish(subdev, vb->v4l2_buf.index);
+       fimc_is_subdev_buffer_finish(subdev, vb->index);
 }
 
 const struct vb2_ops fimc_is_scc_qops = {
index 751bd68..87220a0 100644 (file)
@@ -604,11 +604,10 @@ const struct v4l2_ioctl_ops fimc_is_scp_video_ioctl_ops = {
 };
 
 static int fimc_is_scp_queue_setup(struct vb2_queue *vbq,
-       const struct v4l2_format *fmt,
        unsigned int *num_buffers,
        unsigned int *num_planes,
        unsigned int sizes[],
-       void *allocators[])
+       struct device *alloc_devs[])
 {
        int ret = 0;
        struct fimc_is_video_ctx *vctx = vbq->drv_priv;
@@ -623,11 +622,8 @@ static int fimc_is_scp_queue_setup(struct vb2_queue *vbq,
        queue = GET_DST_QUEUE(vctx);
        video = vctx->video;
 
-       ret = fimc_is_queue_setup(queue,
-               video->alloc_ctx,
-               num_planes,
-               sizes,
-               allocators);
+       ret = fimc_is_queue_setup(queue, video->alloc_dev,
+                                 num_planes, sizes, alloc_devs);
        if (ret)
                merr("fimc_is_queue_setup failed(%d)", vctx, ret);
 
@@ -724,7 +720,7 @@ static void fimc_is_scp_buffer_queue(struct vb2_buffer *vb)
                return;
        }
 
-       ret = fimc_is_subdev_buffer_queue(subdev, vb->v4l2_buf.index);
+       ret = fimc_is_subdev_buffer_queue(subdev, vb->index);
        if (ret) {
                merr("fimc_is_subdev_buffer_queue failed(%d)", vctx, ret);
                return;
@@ -738,10 +734,10 @@ static void fimc_is_scp_buffer_finish(struct vb2_buffer *vb)
        struct fimc_is_subdev *scp = &ischain->scp;
 
 #ifdef DBG_STREAMING
-       dbg_scp("%s(%d)\n", __func__, vb->v4l2_buf.index);
+       dbg_scp("%s(%d)\n", __func__, vb->index);
 #endif
 
-       fimc_is_subdev_buffer_finish(scp, vb->v4l2_buf.index);
+       fimc_is_subdev_buffer_finish(scp, vb->index);
 }
 
 const struct vb2_ops fimc_is_scp_qops = {
index 5451a4f..e474c49 100644 (file)
@@ -530,7 +530,8 @@ static int fimc_is_sen_video_s_ctrl(struct file *file, void *priv,
                        goto p_err;
                }
 
-               ret = v4l2_subdev_call(subdev_flite, core, s_ctrl, ctrl);
+               ret = v4l2_subdev_call(subdev_flite, core, ioctl,
+                                      FIMC_IS_IOCTL_S_CTRL, ctrl);
                if (ret) {
                        merr("v4l2_flite_call(s_ctrl) failed(%d)", device, ret);
                        goto p_err;
@@ -720,10 +721,8 @@ const struct v4l2_ioctl_ops fimc_is_sen_video_ioctl_ops = {
 };
 
 static int fimc_is_sen_queue_setup(struct vb2_queue *vbq,
-       const struct v4l2_format *fmt,
        unsigned int *num_buffers, unsigned int *num_planes,
-       unsigned int sizes[],
-       void *allocators[])
+       unsigned int sizes[], struct device *alloc_devs[])
 {
        int ret = 0;
        struct fimc_is_video_ctx *vctx = vbq->drv_priv;
@@ -738,11 +737,8 @@ static int fimc_is_sen_queue_setup(struct vb2_queue *vbq,
        queue = GET_DST_QUEUE(vctx);
        video = vctx->video;
 
-       ret = fimc_is_queue_setup(queue,
-               video->alloc_ctx,
-               num_planes,
-               sizes,
-               allocators);
+       ret = fimc_is_queue_setup(queue, video->alloc_dev, num_planes,
+                                 sizes, alloc_devs);
        if (ret)
                merr("fimc_is_queue_setup failed(%d)", vctx, ret);
 
@@ -828,7 +824,7 @@ static void fimc_is_sen_buffer_queue(struct vb2_buffer *vb)
        struct fimc_is_device_sensor *device;
 
 #ifdef DBG_STREAMING
-       mdbgv_sensor("%s(%d)\n", vctx, __func__, vb->v4l2_buf.index);
+       mdbgv_sensor("%s(%d)\n", vctx, __func__, vb->index);
 #endif
 
        queue = GET_DST_QUEUE(vctx);
@@ -845,7 +841,7 @@ static void fimc_is_sen_buffer_queue(struct vb2_buffer *vb)
                return;
        }
 
-       ret = fimc_is_sensor_buffer_queue(device, vb->v4l2_buf.index);
+       ret = fimc_is_sensor_buffer_queue(device, vb->index);
        if (ret) {
                merr("fimc_is_sensor_buffer_queue failed(%d)", device, ret);
                return;
@@ -859,13 +855,11 @@ static void fimc_is_sen_buffer_finish(struct vb2_buffer *vb)
        struct fimc_is_device_sensor *device;
 
 #ifdef DBG_STREAMING
-       mdbgv_sensor("%s(%d)\n", vctx, __func__, vb->v4l2_buf.index);
+       mdbgv_sensor("%s(%d)\n", vctx, __func__, vb->index);
 #endif
        device = vctx->device;
 
-       ret = fimc_is_sensor_buffer_finish(
-               device,
-               vb->v4l2_buf.index);
+       ret = fimc_is_sensor_buffer_finish(device, vb->index);
        if (ret)
                merr("fimc_is_sensor_buffer_finish failed(%d)", device, ret);
 }
index 29631bc..1ded9df 100644 (file)
@@ -522,11 +522,10 @@ const struct v4l2_ioctl_ops fimc_is_vdc_video_ioctl_ops = {
 };
 
 static int fimc_is_vdc_queue_setup(struct vb2_queue *vbq,
-       const struct v4l2_format *fmt,
        unsigned int *num_buffers,
        unsigned int *num_planes,
        unsigned int sizes[],
-       void *allocators[])
+       struct device *alloc_devs[])
 {
        int ret = 0;
        struct fimc_is_video_ctx *vctx = vbq->drv_priv;
@@ -541,11 +540,8 @@ static int fimc_is_vdc_queue_setup(struct vb2_queue *vbq,
        queue = GET_DST_QUEUE(vctx);
        video = vctx->video;
 
-       ret = fimc_is_queue_setup(queue,
-               video->alloc_ctx,
-               num_planes,
-               sizes,
-               allocators);
+       ret = fimc_is_queue_setup(queue, video->alloc_dev,
+                                 num_planes, sizes, alloc_devs);
        if (ret)
                merr("fimc_is_queue_setup failed(%d)", vctx, ret);
 
@@ -636,7 +632,7 @@ static void fimc_is_vdc_buffer_queue(struct vb2_buffer *vb)
                return;
        }
 
-       ret = fimc_is_subdev_buffer_queue(subdev, vb->v4l2_buf.index);
+       ret = fimc_is_subdev_buffer_queue(subdev, vb->index);
        if (ret) {
                merr("fimc_is_subdev_buffer_queue failed(%d)", vctx, ret);
                return;
@@ -650,10 +646,10 @@ static void fimc_is_vdc_buffer_finish(struct vb2_buffer *vb)
        struct fimc_is_subdev *dis = &ischain->dis;
 
 #ifdef DBG_STREAMING
-       dbg_vdisc("%s(%d)\n", __func__, vb->v4l2_buf.index);
+       dbg_vdisc("%s(%d)\n", __func__, vb->index);
 #endif
 
-       fimc_is_subdev_buffer_finish(dis, vb->v4l2_buf.index);
+       fimc_is_subdev_buffer_finish(dis, vb->index);
 }
 
 const struct vb2_ops fimc_is_vdc_qops = {
index 4e618b1..13f8ce0 100644 (file)
@@ -427,10 +427,9 @@ const struct v4l2_ioctl_ops fimc_is_vdo_video_ioctl_ops = {
 };
 
 static int fimc_is_vdo_queue_setup(struct vb2_queue *vbq,
-       const struct v4l2_format *fmt,
        unsigned int *num_buffers, unsigned int *num_planes,
        unsigned int sizes[],
-       void *allocators[])
+       struct device *alloc_devs[])
 {
        int ret = 0;
        struct fimc_is_video_ctx *vctx = vbq->drv_priv;
@@ -445,11 +444,8 @@ static int fimc_is_vdo_queue_setup(struct vb2_queue *vbq,
        queue = GET_SRC_QUEUE(vctx);
        video = vctx->video;
 
-       ret = fimc_is_queue_setup(queue,
-               video->alloc_ctx,
-               num_planes,
-               sizes,
-               allocators);
+       ret = fimc_is_queue_setup(queue, video->alloc_dev,
+                                 num_planes, sizes, alloc_devs);
        if (ret)
                merr("fimc_is_queue_setup failed(%d)", vctx, ret);
 
@@ -531,7 +527,7 @@ static void fimc_is_vdo_buffer_queue(struct vb2_buffer *vb)
        struct fimc_is_device_ischain *device;
 
        BUG_ON(!vctx);
-       index = vb->v4l2_buf.index;
+       index = vb->index;
 
 #ifdef DBG_STREAMING
        dbg_vdiso("%s(%d)\n", __func__, index);
@@ -560,10 +556,10 @@ static void fimc_is_vdo_buffer_finish(struct vb2_buffer *vb)
        struct fimc_is_device_ischain *device = vctx->device;
 
 #ifdef DBG_STREAMING
-       mdbgv_vdo("%s(%d)\n", vctx, __func__, vb->v4l2_buf.index);
+       mdbgv_vdo("%s(%d)\n", vctx, __func__, vb->index);
 #endif
 
-       fimc_is_ischain_vdo_buffer_finish(device, vb->v4l2_buf.index);
+       fimc_is_ischain_vdo_buffer_finish(device, vb->index);
 }
 
 const struct vb2_ops fimc_is_vdo_qops = {
index 8bf058f..54ae15c 100644 (file)
@@ -48,12 +48,12 @@ struct fimc_is_fmt fimc_is_formats[] = {
                .name           = "YUV 4:2:2 packed, YCbYCr",
                .pixelformat    = V4L2_PIX_FMT_YUYV,
                .num_planes     = 1 + SPARE_PLANE,
-               .mbus_code      = V4L2_MBUS_FMT_YUYV8_2X8,
+               .mbus_code      = MEDIA_BUS_FMT_YUYV8_2X8,
        }, {
                .name           = "YUV 4:2:2 packed, CbYCrY",
                .pixelformat    = V4L2_PIX_FMT_UYVY,
                .num_planes     = 1 + SPARE_PLANE,
-               .mbus_code      = V4L2_MBUS_FMT_UYVY8_2X8,
+               .mbus_code      = MEDIA_BUS_FMT_UYVY8_2X8,
        }, {
                .name           = "YUV 4:2:2 planar, Y/Cb/Cr",
                .pixelformat    = V4L2_PIX_FMT_YUV422P,
@@ -110,7 +110,7 @@ struct fimc_is_fmt fimc_is_formats[] = {
                .name           = "JPEG",
                .pixelformat    = V4L2_PIX_FMT_JPEG,
                .num_planes     = 1 + SPARE_PLANE,
-               .mbus_code      = V4L2_MBUS_FMT_JPEG_1X8,
+               .mbus_code      = MEDIA_BUS_FMT_JPEG_1X8,
        }
 };
 
@@ -300,6 +300,7 @@ static int queue_init(void *priv, struct vb2_queue *vbq_src,
                vbq_src->drv_priv       = vctx;
                vbq_src->ops            = vctx->vb2_ops;
                vbq_src->mem_ops        = vctx->mem_ops;
+               vbq_src->dev            = vctx->video->alloc_dev;
                vbq_src->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
                vbq_src->allow_zero_bytesused = 1;
 
@@ -317,6 +318,7 @@ static int queue_init(void *priv, struct vb2_queue *vbq_src,
                vbq_dst->drv_priv       = vctx;
                vbq_dst->ops            = vctx->vb2_ops;
                vbq_dst->mem_ops        = vctx->mem_ops;
+               vbq_dst->dev            = vctx->video->alloc_dev;
                vbq_dst->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
 
                ret = vb2_queue_init(vbq_dst);
@@ -510,31 +512,28 @@ p_err:
        return ret;
 }
 
-int fimc_is_queue_setup(struct fimc_is_queue *queue,
-       void *alloc_ctx,
-       unsigned int *num_planes,
-       unsigned int sizes[],
-       void *allocators[])
+int fimc_is_queue_setup(struct fimc_is_queue *queue, void *alloc_dev,
+                       unsigned int *num_planes, unsigned int sizes[],
+                       struct device *alloc_devs[])
 {
-       u32 ret = 0;
        u32 plane;
 
        BUG_ON(!queue);
-       BUG_ON(!alloc_ctx);
+       BUG_ON(!alloc_dev);
        BUG_ON(!num_planes);
        BUG_ON(!sizes);
-       BUG_ON(!allocators);
+       BUG_ON(!alloc_devs);
 
        *num_planes = (queue->framecfg.format.num_planes);
        fimc_is_set_plane_size(&queue->framecfg, sizes);
 
        for (plane = 0; plane < *num_planes; plane++) {
-               allocators[plane] = alloc_ctx;
+               alloc_devs[plane] = alloc_dev;
                queue->framecfg.size[plane] = sizes[plane];
                mdbgv_vid("queue[%d] size : %d\n", plane, sizes[plane]);
        }
 
-       return ret;
+       return 0;
 }
 
 int fimc_is_queue_buffer_queue(struct fimc_is_queue *queue,
@@ -548,7 +547,7 @@ int fimc_is_queue_buffer_queue(struct fimc_is_queue *queue,
        struct fimc_is_framemgr *framemgr;
        struct fimc_is_frame *frame;
 
-       index = vb->v4l2_buf.index;
+       index = vb->index;
        framemgr = &queue->framemgr;
 
        BUG_ON(framemgr->id == FRAMEMGR_ID_INVALID);
@@ -777,7 +776,7 @@ int fimc_is_video_probe(struct fimc_is_video *video,
        snprintf(video->vd.name, sizeof(video->vd.name), "%s", video_name);
        video->id               = video_number;
        video->vb2              = mem->vb2;
-       video->alloc_ctx        = mem->alloc_ctx;
+       video->alloc_dev        = &mem->pdev->dev;
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
        video->vd.vfl_dir       = vfl_dir;
 #endif
index 8e6f46c..68d23ad 100644 (file)
@@ -40,6 +40,7 @@
 #define FIMC_IS_VIDEO_VDC_NAME                 FIMC_IS_VIDEO_NAME("vdisc")
 #define FIMC_IS_VIDEO_VDO_NAME                 FIMC_IS_VIDEO_NAME("vdiso")
 
+struct device;
 struct fimc_is_device_ischain;
 struct fimc_is_subdev;
 struct fimc_is_queue;
@@ -132,7 +133,7 @@ struct fimc_is_video {
        struct video_device             vd;
        struct media_pad                pads;
        const struct fimc_is_vb2        *vb2;
-       void                            *alloc_ctx;
+       struct device                   *alloc_dev;
 };
 
 struct fimc_is_core *fimc_is_video_ctx_2_core(struct fimc_is_video_ctx *vctx);
@@ -147,11 +148,10 @@ int close_vctx(struct file *file,
        struct fimc_is_video_ctx *vctx);
 
 /* queue operation */
-int fimc_is_queue_setup(struct fimc_is_queue *queue,
-       void *alloc_ctx,
-       unsigned int *num_planes,
-       unsigned int sizes[],
-       void *allocators[]);
+int fimc_is_queue_setup(struct fimc_is_queue *queue, void *alloc_ctx,
+                       unsigned int *num_planes, unsigned int sizes[],
+                       struct device *alloc_devs[]);
+
 int fimc_is_queue_buffer_queue(struct fimc_is_queue *queue,
        const struct fimc_is_vb2 *vb2,
        struct vb2_buffer *vb);
index dce6d45..c814ed7 100644 (file)
@@ -352,20 +352,26 @@ p_err:
        return ret;
 }
 
-static int sensor_6d1_s_format(struct v4l2_subdev *subdev, struct v4l2_mbus_framefmt *fmt)
+static int sensor_6d1_set_format(struct v4l2_subdev *sd,
+                                struct v4l2_subdev_pad_config *cfg,
+                                struct v4l2_subdev_format *format)
 {
        /* TODO */
        return 0;
 }
 
+static const struct v4l2_subdev_pad_ops pad_ops = {
+       .set_fmt = sensor_6d1_set_format
+};
+
 static const struct v4l2_subdev_video_ops video_ops = {
        .s_stream = sensor_6d1_s_stream,
        .s_parm = sensor_6d1_s_param,
-       .s_mbus_fmt = sensor_6d1_s_format
 };
 
 static const struct v4l2_subdev_ops subdev_ops = {
        .core = &core_ops,
+       .pad = &pad_ops,
        .video = &video_ops
 };