CHROMIUM: Fix DMABUF exporting for v4l2-m2m
authorJohn Sheu <sheu@chromium.org>
Mon, 28 Jan 2013 23:36:21 +0000 (15:36 -0800)
committerChromeBot <chrome-bot@google.com>
Thu, 31 Jan 2013 00:36:24 +0000 (16:36 -0800)
<UPSTREAM MERGE NOT REQUIRED>

v4l2-mem2mem uses a constant offset to mmap to distinguish between input
and output queues.  VIDIOC_EXPBUF should take this into account when
exporting a buffer as a DMABUF.

Signed-off-by: John Sheu <sheu@google.com>
BUG=chromium-os:38376
BUG=chromium:167417
TEST=local build, run on snow, unittests

Change-Id: Id7770666775a78c3e11b3d158052a81f67592c8f
Reviewed-on: https://gerrit.chromium.org/gerrit/42179
Commit-Queue: John Sheu <sheu@chromium.org>
Reviewed-by: John Sheu <sheu@chromium.org>
Tested-by: John Sheu <sheu@chromium.org>
Reviewed-by: Pawel Osciak <posciak@chromium.org>
drivers/media/video/v4l2-mem2mem.c

index 3f88199..a8f3cda 100644 (file)
@@ -33,7 +33,6 @@ module_param(debug, bool, 0644);
                        printk(KERN_DEBUG "%s: " fmt, __func__, ## arg);\
        } while (0)
 
-
 /* Instance is already queued on the job_queue */
 #define TRANS_QUEUED           (1 << 0)
 /* Instance is currently running in hardware */
@@ -341,9 +340,12 @@ int v4l2_m2m_expbuf(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
                                                struct v4l2_exportbuffer *eb)
 {
        struct vb2_queue *vq;
-
-       /* Below code is written only for FIMC CAPTURE for now */
-       vq = v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
+       if (eb->mem_offset < DST_QUEUE_OFF_BASE) {
+               vq = v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_OUTPUT);
+       } else {
+               vq = v4l2_m2m_get_vq(m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+               eb->mem_offset -= DST_QUEUE_OFF_BASE;
+       }
        return vb2_expbuf(vq, eb);
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_expbuf);