CHROMIUM: vb2: Add a new "use_dma_bidirectional" queue flag.
authorPawel Osciak <posciak@chromium.org>
Wed, 16 Sep 2015 12:21:49 +0000 (21:21 +0900)
committerHuang, Tao <huangtao@rock-chips.com>
Thu, 30 Jun 2016 11:58:12 +0000 (19:58 +0800)
When set to 1 for CAPTURE queues by the driver on calling vb2_queue_init(),
forces the buffers on the queue to be allocated/mapped with
DMA_BIDIRECTIONAL DMA direction flag, instead of DMA_FROM_DEVICE. This
allows the device not only to write to the buffers, but also read out from
them. This may be useful e.g. for codec hardware, which may be using
CAPTURE buffers as reference to decode other buffers.

This flag is ignored for OUTPUT queues, as we don't want to allow HW to
be able to write to OUTPUT buffers.

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

Reviewed-on: https://chromium-review.googlesource.com/300726
Commit-Ready: Pawel Osciak <posciak@chromium.org>
Tested-by: Pawel Osciak <posciak@chromium.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Change-Id: Ifba955eef75ac23c9a13edab04bc1fe7f5375c70
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 fad3d24c964dd22a03f4b26b865c156d220c9daf..40dc1dd3292b91eda889596030991e1e0b197bb9 100644 (file)
@@ -2063,8 +2063,12 @@ 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;
+       if (q->is_output)
+               q->dma_dir = DMA_TO_DEVICE;
+       else
+               q->dma_dir = q->use_dma_bidirectional
+                          ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE;
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_core_queue_init);
index f18ac1fe522b69a7414561a692407864fde80bb4..8c4e172b80ca577c725d679bd23c53ad80b023cd 100644 (file)
@@ -380,6 +380,9 @@ struct vb2_buf_ops {
  * @fileio_read_once:          report EOF after reading the first buffer
  * @fileio_write_immediately:  queue buffer after each write() call
  * @allow_zero_bytesused:      allow bytesused == 0 to be passed to the driver
+ * @use_dma_bidirectional:     use DMA_BIDIRECTIONAL for CAPTURE buffers; this
+ *                             allows HW to read from the CAPTURE buffers in
+ *                             addition to writing; ignored for OUTPUT queues
  * @lock:      pointer to a mutex that protects the vb2_queue struct. The
  *             driver can set this to a mutex to let the v4l2 core serialize
  *             the queuing ioctls. If the driver wants to handle locking
@@ -443,6 +446,7 @@ struct vb2_queue {
        unsigned                        fileio_read_once:1;
        unsigned                        fileio_write_immediately:1;
        unsigned                        allow_zero_bytesused:1;
+       unsigned                        use_dma_bidirectional:1;
 
        struct mutex                    *lock;
        void                            *owner;