Skip to contentSkip to conversation

V4L/DVB: v4l2-dev: revert commit c29fcff3daafbf46d64a543c1950bbd206ad8c1c

PATCH In review Bob Liu 2 participants 4 messages Apr 29, 2011 – May 6, 2011 Media (V4L/DVB)

lore
Share & tools
lore

Bob Liu

author
#0 lore raw

PATCH 1/2 V4L/DVB: v4l2-dev: revert commit c29fcff3daafbf46d64a543c1950bbd206ad8c1c

Revert commit:
V4L/DVB: v4l2-dev: remove get_unmapped_area(c29fcff3daafbf46d64a543c1950bb) to restore NOMMU arch supporting.

---
 drivers/media/video/v4l2-dev.c |   18 ++++++++++++++++++
 include/media/v4l2-dev.h       |    2 ++
 2 files changed, 20 insertions(+), 0 deletions(-)
drivers/media/video/v4l2-dev.c +18 -0
index 6dc7196..19d5ae2 100644
@@ -352,6 +352,23 @@ static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	return ret;
 }
 
+#ifdef CONFIG_MMU
+#define v4l2_get_unmapped_area NULL
+#else
+static unsigned long v4l2_get_unmapped_area(struct file *filp,
+		unsigned long addr, unsigned long len, unsigned long pgoff,
+		unsigned long flags)
+{
+	struct video_device *vdev = video_devdata(filp);
+
+	if (!vdev->fops->get_unmapped_area)
+		return -ENOSYS;
+	if (!video_is_registered(vdev))
+		return -ENODEV;
+	return vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags);
+}
+#endif
+
 static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
 {
 	struct video_device *vdev = video_devdata(filp);
@@ -454,6 +471,7 @@ static const struct file_operations v4l2_fops = {
 	.read = v4l2_read,
 	.write = v4l2_write,
 	.open = v4l2_open,
+	.get_unmapped_area = v4l2_get_unmapped_area,
 	.mmap = v4l2_mmap,
 	.unlocked_ioctl = v4l2_ioctl,
 #ifdef CONFIG_COMPAT
include/media/v4l2-dev.h +2 -0
index 8266d5a..93e96fb 100644
@@ -62,6 +62,8 @@ struct v4l2_file_operations {
 	unsigned int (*poll) (struct file *, struct poll_table_struct *);
 	long (*ioctl) (struct file *, unsigned int, unsigned long);
 	long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
+	unsigned long (*get_unmapped_area) (struct file *, unsigned long,
+				unsigned long, unsigned long, unsigned long);
 	int (*mmap) (struct file *, struct vm_area_struct *);
 	int (*open) (struct file *);
 	int (*release) (struct file *);
Signature · 1 line
1.6.3.3
author
#1 lore raw

PATCH 2/2 media:uvc_driver: Add support for NOMMU arch

Add support to uvc driver for NOMMU arch including add function uvc_queue_get_unmapped_area() and make some changes in uvc_queue_mmap(). So that uvc camera can be used on nommu arch like blackfin.

---
 drivers/media/video/uvc/uvc_queue.c |   34 +++++++++++++++++++++++++++++++++-
 drivers/media/video/uvc/uvc_v4l2.c  |   17 +++++++++++++++++
 drivers/media/video/uvc/uvcvideo.h  |    4 ++++
 3 files changed, 54 insertions(+), 1 deletions(-)
drivers/media/video/uvc/uvc_queue.c +33 -1
index f14581b..109a063 100644
@@ -424,7 +424,7 @@ int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
 			break;
 	}
 
-	if (i == queue->count || size != queue->buf_size) {
+	if (i == queue->count || PAGE_ALIGN(size) != queue->buf_size) {
 		ret = -EINVAL;
 		goto done;
 	}
@@ -436,6 +436,7 @@ int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
 	vma->vm_flags |= VM_IO;
 
 	addr = (unsigned long)queue->mem + buffer->buf.m.offset;
+#ifdef CONFIG_MMU
 	while (size > 0) {
 		page = vmalloc_to_page((void *)addr);
 		if ((ret = vm_insert_page(vma, start, page)) < 0)
@@ -445,6 +446,7 @@ int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
 		addr += PAGE_SIZE;
 		size -= PAGE_SIZE;
 	}
+#endif
 
 	vma->vm_ops = &uvc_vm_ops;
 	vma->vm_private_data = buffer;
@@ -488,6 +490,36 @@ done:
 	return mask;
 }
 
+#ifndef CONFIG_MMU
+/*
+ * Get unmapped area.
+ *
+ * NO-MMU arch need this function to make mmap() work correctly.
+ */
+unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue,
+		unsigned long pgoff)
+{
+	struct uvc_buffer *buffer;
+	unsigned int i;
+	unsigned long ret;
+
+	mutex_lock(&queue->mutex);
+	for (i = 0; i < queue->count; ++i) {
+		buffer = &queue->buffer[i];
+		if ((buffer->buf.m.offset >> PAGE_SHIFT) == pgoff)
+			break;
+	}
+	if (i == queue->count) {
+		ret = -EINVAL;
+		goto done;
+	}
+	ret = (unsigned long)queue->mem + buffer->buf.m.offset;
+done:
+	mutex_unlock(&queue->mutex);
+	return ret;
+}
+#endif
+
 /*
  * Enable or disable the video buffers queue.
  *
drivers/media/video/uvc/uvc_v4l2.c +17 -0
index 9005a8d..d0da5d0 100644
@@ -1081,6 +1081,20 @@ static unsigned int uvc_v4l2_poll(struct file *file, poll_table *wait)
 	return uvc_queue_poll(&stream->queue, file, wait);
 }
 
+#ifndef CONFIG_MMU
+static unsigned long uvc_v4l2_get_unmapped_area(struct file *file,
+		unsigned long addr, unsigned long len, unsigned long pgoff,
+		unsigned long flags)
+{
+	struct uvc_fh *handle = file->private_data;
+	struct uvc_streaming *stream = handle->stream;
+
+	uvc_trace(UVC_TRACE_CALLS, "uvc_v4l2_get_unmapped_area\n");
+
+	return uvc_queue_get_unmapped_area(&stream->queue, pgoff);
+}
+#endif
+
 const struct v4l2_file_operations uvc_fops = {
 	.owner		= THIS_MODULE,
 	.open		= uvc_v4l2_open,
@@ -1089,5 +1103,8 @@ const struct v4l2_file_operations uvc_fops = {
 	.read		= uvc_v4l2_read,
 	.mmap		= uvc_v4l2_mmap,
 	.poll		= uvc_v4l2_poll,
+#ifndef CONFIG_MMU
+	.get_unmapped_area = uvc_v4l2_get_unmapped_area,
+#endif
 };
 
drivers/media/video/uvc/uvcvideo.h +4 -0
index 45f01e7..6aa63c0 100644
@@ -580,6 +580,10 @@ extern int uvc_queue_mmap(struct uvc_video_queue *queue,
 		struct vm_area_struct *vma);
 extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
 		struct file *file, poll_table *wait);
+#ifndef CONFIG_MMU
+extern unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue,
+		unsigned long pgoff);
+#endif
 extern int uvc_queue_allocated(struct uvc_video_queue *queue);
 static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
 {
Signature · 1 line
1.6.3.3
#2 lore raw
In reply to Bob Liu

Hi Bob,

Quoted 5 lines · On Friday 29 April 2011 12:11:34 Bob Liu wrote:

Revert commit:
V4L/DVB: v4l2-dev: remove get_unmapped_area(c29fcff3daafbf46d64a543c1950bb) to restore NOMMU arch supporting.

git provides a 'git revert' command to revert patches. It formats the commit message in a standard way. I'll use it instead of applying this patch to my tree and I'll keep your SoB line (unless you object to that).

Quoted 54 lines
---
 drivers/media/video/v4l2-dev.c |   18 ++++++++++++++++++
 include/media/v4l2-dev.h       |    2 ++
 2 files changed, 20 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/drivers/media/video/v4l2-dev.c index 6dc7196..19d5ae2 100644

drivers/media/video/v4l2-dev.c +18 -0
@@ -352,6 +352,23 @@ static long v4l2_ioctl(struct file *filp, unsigned int
 cmd, unsigned long arg) return ret;
 }
 
+#ifdef CONFIG_MMU
+#define v4l2_get_unmapped_area NULL
+#else
+static unsigned long v4l2_get_unmapped_area(struct file *filp,
+		unsigned long addr, unsigned long len, unsigned long pgoff,
+		unsigned long flags)
+{
+	struct video_device *vdev = video_devdata(filp);
+
+	if (!vdev->fops->get_unmapped_area)
+		return -ENOSYS;
+	if (!video_is_registered(vdev))
+		return -ENODEV;
+	return vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags);
+}
+#endif
+
 static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
 {
 	struct video_device *vdev = video_devdata(filp);
@@ -454,6 +471,7 @@ static const struct file_operations v4l2_fops = {
 	.read = v4l2_read,
 	.write = v4l2_write,
 	.open = v4l2_open,
+	.get_unmapped_area = v4l2_get_unmapped_area,
 	.mmap = v4l2_mmap,
 	.unlocked_ioctl = v4l2_ioctl,
 #ifdef CONFIG_COMPAT
include/media/v4l2-dev.h +2 -0
index 8266d5a..93e96fb 100644
@@ -62,6 +62,8 @@ struct v4l2_file_operations {
 	unsigned int (*poll) (struct file *, struct poll_table_struct *);
 	long (*ioctl) (struct file *, unsigned int, unsigned long);
 	long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
+	unsigned long (*get_unmapped_area) (struct file *, unsigned long,
+				unsigned long, unsigned long, unsigned long);
 	int (*mmap) (struct file *, struct vm_area_struct *);
 	int (*open) (struct file *);
 	int (*release) (struct file *);
Signature · 3 lines
Regards,

Laurent Pinchart
author
#3 lore raw
Quoted 10 lines · Laurent Pinchart

Hi Bob,

Quoted 5 lines · On Friday 29 April 2011 12:11:34 Bob Liu wrote:

Revert commit:
V4L/DVB: v4l2-dev: remove get_unmapped_area(c29fcff3daafbf46d64a543c1950bb) to restore NOMMU arch supporting.

git provides a 'git revert' command to revert patches. It formats the commit

Sorry, I haven't use 'git revert' before.

Quoted 3 lines

message in a standard way. I'll use it instead of applying this patch to my tree and I'll keep your SoB line (unless you object to that).

Okay, Thanks a lot.

Quoted 60 lines
Quoted 46 lines

---
 drivers/media/video/v4l2-dev.c |   18 ++++++++++++++++++ include/media/v4l2-dev.h       |    2 ++

 2 files changed, 20 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/drivers/media/video/v4l2-dev.c index 6dc7196..19d5ae2 100644

drivers/media/video/v4l2-dev.c +18 -0
@@ -352,6 +352,23 @@ static long v4l2_ioctl(struct file *filp, unsigned int
 cmd, unsigned long arg) return ret;
  }
 
+#ifdef CONFIG_MMU
+#define v4l2_get_unmapped_area NULL
+#else
+static unsigned long v4l2_get_unmapped_area(struct file *filp,
+             unsigned long addr, unsigned long len, unsigned long pgoff,
+             unsigned long flags)
+{
+     struct video_device *vdev = video_devdata(filp);
+
+     if (!vdev->fops->get_unmapped_area)
+             return -ENOSYS;
+     if (!video_is_registered(vdev))
+             return -ENODEV;
+     return vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags);
+}
+#endif
+
  static int v4l2_mmap(struct file *filp, struct vm_area_struct *vm)
  {
       struct video_device *vdev = video_devdata(filp);
@@ -454,6 +471,7 @@ static const struct file_operations v4l2_fops = {
       .read = v4l2_read,
       .write = v4l2_write,
       .open = v4l2_open,
+     .get_unmapped_area = v4l2_get_unmapped_area,
       .mmap = v4l2_mmap,
       .unlocked_ioctl = v4l2_ioctl,
  #ifdef CONFIG_COMPAT
include/media/v4l2-dev.h +0 -0
index 8266d5a..93e96fb 100644

include/media/v4l2-dev.h struct v4l2_file_operations { · line 69

Quoted 8 lines
include/media/v4l2-dev.h +2 -0
@@ -62,6 +62,8 @@ struct v4l2_file_operations {
       unsigned int (*poll) (struct file *, struct poll_table_struct *);
       long (*ioctl) (struct file *, unsigned int, unsigned long);
       long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
+     unsigned long (*get_unmapped_area) (struct file *, unsigned long,
+                             unsigned long, unsigned long, unsigned long);
       int (*mmap) (struct file *, struct vm_area_struct *);
       int (*open) (struct file *);
       int (*release) (struct file *);

--
Regards,

Laurent Pinchart

Signature · 2 lines
Regards,
--Bob