[media] v4l: vsp1: Make rwpf operations independent of video device
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Tue, 28 Jul 2015 19:04:47 +0000 (16:04 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 19 Feb 2016 10:55:28 +0000 (08:55 -0200)
The rwpf queue operation doesn't queue a buffer but sets the memory
address for the next run. Rename it to set_memory and pass it a new
structure independent of the video buffer than only contains memory
information.

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_rpf.c
drivers/media/platform/vsp1/vsp1_rwpf.h
drivers/media/platform/vsp1/vsp1_video.c
drivers/media/platform/vsp1/vsp1_video.h
drivers/media/platform/vsp1/vsp1_wpf.c

index 085d100562977d34ad0ac5018d80b3d7e151ac8c..c0b7f76cd0b5cab493062780b809e86e335e8159 100644 (file)
@@ -186,28 +186,28 @@ static struct v4l2_subdev_ops rpf_ops = {
  * Video Device Operations
  */
 
-static void rpf_buf_queue(struct vsp1_rwpf *rpf, struct vsp1_vb2_buffer *buf)
+static void rpf_set_memory(struct vsp1_rwpf *rpf, struct vsp1_rwpf_memory *mem)
 {
        unsigned int i;
 
        for (i = 0; i < 3; ++i)
-               rpf->buf_addr[i] = buf->addr[i];
+               rpf->buf_addr[i] = mem->addr[i];
 
        if (!vsp1_entity_is_streaming(&rpf->entity))
                return;
 
        vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_Y,
-                      buf->addr[0] + rpf->offsets[0]);
-       if (buf->buf.vb2_buf.num_planes > 1)
+                      mem->addr[0] + rpf->offsets[0]);
+       if (mem->num_planes > 1)
                vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_C0,
-                              buf->addr[1] + rpf->offsets[1]);
-       if (buf->buf.vb2_buf.num_planes > 2)
+                              mem->addr[1] + rpf->offsets[1]);
+       if (mem->num_planes > 2)
                vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_C1,
-                              buf->addr[2] + rpf->offsets[1]);
+                              mem->addr[2] + rpf->offsets[1]);
 }
 
 static const struct vsp1_rwpf_operations rpf_vdev_ops = {
-       .queue = rpf_buf_queue,
+       .set_memory = rpf_set_memory,
 };
 
 /* -----------------------------------------------------------------------------
index ee2a8bf269fa0b3bf719b493397b088e62328df5..0076920adb28ce24941841b5b500caa2d99107fa 100644 (file)
 #define RWPF_PAD_SOURCE                                1
 
 struct vsp1_rwpf;
-struct vsp1_vb2_buffer;
+
+struct vsp1_rwpf_memory {
+       unsigned int num_planes;
+       dma_addr_t addr[3];
+       unsigned int length[3];
+};
 
 struct vsp1_rwpf_operations {
-       void (*queue)(struct vsp1_rwpf *rwpf, struct vsp1_vb2_buffer *buf);
+       void (*set_memory)(struct vsp1_rwpf *rwpf,
+                          struct vsp1_rwpf_memory *mem);
 };
 
 struct vsp1_rwpf {
index 2367a07d61496a81a60c940caa932467d416c4f6..26e980da1ed94020b80583bdae1eb3e18db5f0e1 100644 (file)
@@ -628,7 +628,8 @@ vsp1_video_complete_buffer(struct vsp1_video *video)
        done->buf.sequence = video->sequence++;
        done->buf.vb2_buf.timestamp = ktime_get_ns();
        for (i = 0; i < done->buf.vb2_buf.num_planes; ++i)
-               vb2_set_plane_payload(&done->buf.vb2_buf, i, done->length[i]);
+               vb2_set_plane_payload(&done->buf.vb2_buf, i,
+                                     done->mem.length[i]);
        vb2_buffer_done(&done->buf.vb2_buf, VB2_BUF_STATE_DONE);
 
        return next;
@@ -646,7 +647,7 @@ static void vsp1_video_frame_end(struct vsp1_pipeline *pipe,
 
        spin_lock_irqsave(&pipe->irqlock, flags);
 
-       video->rwpf->ops->queue(video->rwpf, buf);
+       video->rwpf->ops->set_memory(video->rwpf, &buf->mem);
        pipe->buffers_ready |= 1 << video->pipe_index;
 
        spin_unlock_irqrestore(&pipe->irqlock, flags);
@@ -843,11 +844,13 @@ static int vsp1_video_buffer_prepare(struct vb2_buffer *vb)
        if (vb->num_planes < format->num_planes)
                return -EINVAL;
 
+       buf->mem.num_planes = vb->num_planes;
+
        for (i = 0; i < vb->num_planes; ++i) {
-               buf->addr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
-               buf->length[i] = vb2_plane_size(vb, i);
+               buf->mem.addr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
+               buf->mem.length[i] = vb2_plane_size(vb, i);
 
-               if (buf->length[i] < format->plane_fmt[i].sizeimage)
+               if (buf->mem.length[i] < format->plane_fmt[i].sizeimage)
                        return -EINVAL;
        }
 
@@ -873,7 +876,7 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb)
 
        spin_lock_irqsave(&pipe->irqlock, flags);
 
-       video->rwpf->ops->queue(video->rwpf, buf);
+       video->rwpf->ops->set_memory(video->rwpf, &buf->mem);
        pipe->buffers_ready |= 1 << video->pipe_index;
 
        if (vb2_is_streaming(&video->queue) &&
index cbd44c33616999291618be8ef05f1f2bca8bea07..21096d82af053e91da69a3c16ad43a115dbe3769 100644 (file)
@@ -20,7 +20,8 @@
 #include <media/media-entity.h>
 #include <media/videobuf2-v4l2.h>
 
-struct vsp1_rwpf;
+#include "vsp1_rwpf.h"
+
 struct vsp1_video;
 
 /*
@@ -97,9 +98,7 @@ static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
 struct vsp1_vb2_buffer {
        struct vb2_v4l2_buffer buf;
        struct list_head queue;
-
-       dma_addr_t addr[3];
-       unsigned int length[3];
+       struct vsp1_rwpf_memory mem;
 };
 
 static inline struct vsp1_vb2_buffer *
index a4c0888a1b46da2403a5ddc9e71caf17c5e85dc8..d2537b46fc469e39ab49c5b1917d676a7e0c215a 100644 (file)
@@ -195,17 +195,17 @@ static struct v4l2_subdev_ops wpf_ops = {
  * Video Device Operations
  */
 
-static void wpf_buf_queue(struct vsp1_rwpf *wpf, struct vsp1_vb2_buffer *buf)
+static void wpf_set_memory(struct vsp1_rwpf *wpf, struct vsp1_rwpf_memory *mem)
 {
-       vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_Y, buf->addr[0]);
-       if (buf->buf.vb2_buf.num_planes > 1)
-               vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C0, buf->addr[1]);
-       if (buf->buf.vb2_buf.num_planes > 2)
-               vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C1, buf->addr[2]);
+       vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_Y, mem->addr[0]);
+       if (mem->num_planes > 1)
+               vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C0, mem->addr[1]);
+       if (mem->num_planes > 2)
+               vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C1, mem->addr[2]);
 }
 
 static const struct vsp1_rwpf_operations wpf_vdev_ops = {
-       .queue = wpf_buf_queue,
+       .set_memory = wpf_set_memory,
 };
 
 /* -----------------------------------------------------------------------------