From: Pawel Osciak Date: Wed, 16 Sep 2015 12:12:40 +0000 (+0900) Subject: CHROMIUM: vb2: Store dma_dir in vb2_queue. X-Git-Tag: firefly_0821_release~2296 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e21bcf16b39e0ca3385505aacd0002dfd0aae049;p=firefly-linux-kernel-4.4.55.git CHROMIUM: vb2: Store dma_dir in vb2_queue. Store dma_dir in struct vb2_queue and reuse it, instead of recalculating it each time. Signed-off-by: Pawel Osciak BUG=chrome-os-partner:45346 TEST=video playback Reviewed-on: https://chromium-review.googlesource.com/300725 Commit-Ready: Pawel Osciak Tested-by: Pawel Osciak Reviewed-by: Tomasz Figa Reviewed-by: Owen Lin Conflicts: drivers/media/v4l2-core/videobuf2-core.c Change-Id: Ia5405cd758ffef0b0319d184a2f32699ebc805ea Signed-off-by: Jeffy Chen Signed-off-by: Yakir Yang --- diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 11f39791ec33..fad3d24c964d 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -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); diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index d4227a8a2a23..f18ac1fe522b 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -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 /*