[media] vb2: add vb2_get_unmapped_area in vb2 core
authorScott Jiang <[scott.jiang.linux@gmail.com]>
Wed, 21 Sep 2011 12:25:23 +0000 (09:25 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 3 Nov 2011 20:29:13 +0000 (18:29 -0200)
no mmu system needs get_unmapped_area file operations to do mmap

Signed-off-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/videobuf2-core.c
include/media/videobuf2-core.h

index 9005dc9991abbe471b5dcebbf916e80780b789e9..979e544388cbfbdea4efa2ea1c1bb321e1d37897 100644 (file)
@@ -1567,6 +1567,37 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
 }
 EXPORT_SYMBOL_GPL(vb2_mmap);
 
+#ifndef CONFIG_MMU
+unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
+                                   unsigned long addr,
+                                   unsigned long len,
+                                   unsigned long pgoff,
+                                   unsigned long flags)
+{
+       unsigned long off = pgoff << PAGE_SHIFT;
+       struct vb2_buffer *vb;
+       unsigned int buffer, plane;
+       int ret;
+
+       if (q->memory != V4L2_MEMORY_MMAP) {
+               dprintk(1, "Queue is not currently set up for mmap\n");
+               return -EINVAL;
+       }
+
+       /*
+        * Find the plane corresponding to the offset passed by userspace.
+        */
+       ret = __find_plane_by_offset(q, off, &buffer, &plane);
+       if (ret)
+               return ret;
+
+       vb = q->bufs[buffer];
+
+       return (unsigned long)vb2_plane_vaddr(vb, plane);
+}
+EXPORT_SYMBOL_GPL(vb2_get_unmapped_area);
+#endif
+
 static int __vb2_init_fileio(struct vb2_queue *q, int read);
 static int __vb2_cleanup_fileio(struct vb2_queue *q);
 
index 55c57d3d3e63bda99cf467d83aeb5da0136ec124..a15d1f1b319effd43a404af98bcff323bfa798e5 100644 (file)
@@ -322,6 +322,13 @@ int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type);
 int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
 
 int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma);
+#ifndef CONFIG_MMU
+unsigned long vb2_get_unmapped_area(struct vb2_queue *q,
+                                   unsigned long addr,
+                                   unsigned long len,
+                                   unsigned long pgoff,
+                                   unsigned long flags);
+#endif
 unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait);
 size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count,
                loff_t *ppos, int nonblock);