CHROMIUM: vb2: Store dma_dir in vb2_queue.
authorPawel Osciak <posciak@chromium.org>
Wed, 16 Sep 2015 12:12:40 +0000 (21:12 +0900)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 30 Jun 2016 11:58:08 +0000 (19:58 +0800)
Store dma_dir in struct vb2_queue and reuse it, instead of recalculating
it each time.

Signed-off-by: Pawel Osciak <posciak@chromium.org>
BUG=chrome-os-partner:45346
TEST=video playback

Reviewed-on: https://chromium-review.googlesource.com/300725
Commit-Ready: Pawel Osciak <posciak@chromium.org>
Tested-by: Pawel Osciak <posciak@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Owen Lin <owenlin@chromium.org>
Conflicts:
drivers/media/v4l2-core/videobuf2-core.c

Change-Id: Ia5405cd758ffef0b0319d184a2f32699ebc805ea
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Yakir Yang <ykk@rock-chips.com>
drivers/media/v4l2-core/videobuf2-core.c
include/media/videobuf2-core.h

index 11f39791ec3391f349ee5a0a008daa69166ad409..fad3d24c964dd22a03f4b26b865c156d220c9daf 100644 (file)
@@ -43,8 +43,6 @@ static void __enqueue_in_driver(struct vb2_buffer *vb);
 static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
 {
        struct vb2_queue *q = vb->vb2_queue;
-       enum dma_data_direction dma_dir =
-               q->is_output ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
        void *mem_priv;
        int plane;
 
@@ -56,7 +54,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb)
                unsigned long size = PAGE_ALIGN(q->plane_sizes[plane]);
 
                mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane],
-                                     size, dma_dir, q->gfp_flags);
+                                     size, q->dma_dir, q->gfp_flags);
                if (IS_ERR_OR_NULL(mem_priv))
                        goto free;
 
@@ -943,8 +941,6 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const void *pb)
        void *mem_priv;
        unsigned int plane;
        int ret;
-       enum dma_data_direction dma_dir =
-               q->is_output ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
        bool reacquired = vb->planes[0].mem_priv == NULL;
 
        memset(planes, 0, sizeof(planes[0]) * vb->num_planes);
@@ -991,7 +987,7 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const void *pb)
                /* Acquire each plane's memory */
                mem_priv = call_ptr_memop(vb, get_userptr, q->alloc_ctx[plane],
                                      planes[plane].m.userptr,
-                                     planes[plane].length, dma_dir);
+                                     planes[plane].length, q->dma_dir);
                if (IS_ERR_OR_NULL(mem_priv)) {
                        dprintk(1, "failed acquiring userspace "
                                                "memory for plane %d\n", plane);
@@ -1057,8 +1053,6 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const void *pb)
        void *mem_priv;
        unsigned int plane;
        int ret;
-       enum dma_data_direction dma_dir =
-               q->is_output ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
        bool reacquired = vb->planes[0].mem_priv == NULL;
 
        memset(planes, 0, sizeof(planes[0]) * vb->num_planes);
@@ -1112,7 +1106,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const void *pb)
                /* Acquire each plane's memory */
                mem_priv = call_ptr_memop(vb, attach_dmabuf,
                        q->alloc_ctx[plane], dbuf, planes[plane].length,
-                       dma_dir);
+                       q->dma_dir);
                if (IS_ERR(mem_priv)) {
                        dprintk(1, "failed to attach dmabuf\n");
                        ret = PTR_ERR(mem_priv);
@@ -2069,6 +2063,8 @@ int vb2_core_queue_init(struct vb2_queue *q)
        if (q->buf_struct_size == 0)
                q->buf_struct_size = sizeof(struct vb2_buffer);
 
+       q->dma_dir = q->is_output
+                  ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
        return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_core_queue_init);
index d4227a8a2a23c1894f4e64b52140e82d895ea434..f18ac1fe522b69a7414561a692407864fde80bb4 100644 (file)
@@ -435,6 +435,7 @@ struct vb2_buf_ops {
  *             when a buffer with the V4L2_BUF_FLAG_LAST is dequeued.
  * @fileio:    file io emulator internal data, used only if emulator is active
  * @threadio:  thread io internal data, used only if thread is active
+ * @dma_dir:   DMA direction to use for buffers on this queue
  */
 struct vb2_queue {
        unsigned int                    type;
@@ -483,6 +484,7 @@ struct vb2_queue {
 
        struct vb2_fileio_data          *fileio;
        struct vb2_threadio_data        *threadio;
+       enum dma_data_direction         dma_dir;
 
 #ifdef CONFIG_VIDEO_ADV_DEBUG
        /*