Commit 72969447 authored by Bob Liu's avatar Bob Liu Committed by Mauro Carvalho Chehab

[media] uvcvideo: 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.
Signed-off-by: default avatarBob Liu <lliubbo@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent ecc6517d
...@@ -424,7 +424,7 @@ int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma) ...@@ -424,7 +424,7 @@ int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
break; break;
} }
if (i == queue->count || size != queue->buf_size) { if (i == queue->count || PAGE_ALIGN(size) != queue->buf_size) {
ret = -EINVAL; ret = -EINVAL;
goto done; goto done;
} }
...@@ -436,6 +436,7 @@ int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma) ...@@ -436,6 +436,7 @@ int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
vma->vm_flags |= VM_IO; vma->vm_flags |= VM_IO;
addr = (unsigned long)queue->mem + buffer->buf.m.offset; addr = (unsigned long)queue->mem + buffer->buf.m.offset;
#ifdef CONFIG_MMU
while (size > 0) { while (size > 0) {
page = vmalloc_to_page((void *)addr); page = vmalloc_to_page((void *)addr);
if ((ret = vm_insert_page(vma, start, page)) < 0) 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) ...@@ -445,6 +446,7 @@ int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma)
addr += PAGE_SIZE; addr += PAGE_SIZE;
size -= PAGE_SIZE; size -= PAGE_SIZE;
} }
#endif
vma->vm_ops = &uvc_vm_ops; vma->vm_ops = &uvc_vm_ops;
vma->vm_private_data = buffer; vma->vm_private_data = buffer;
...@@ -488,6 +490,36 @@ unsigned int uvc_queue_poll(struct uvc_video_queue *queue, struct file *file, ...@@ -488,6 +490,36 @@ unsigned int uvc_queue_poll(struct uvc_video_queue *queue, struct file *file,
return mask; 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. * Enable or disable the video buffers queue.
* *
......
...@@ -1114,6 +1114,20 @@ static unsigned int uvc_v4l2_poll(struct file *file, poll_table *wait) ...@@ -1114,6 +1114,20 @@ static unsigned int uvc_v4l2_poll(struct file *file, poll_table *wait)
return uvc_queue_poll(&stream->queue, file, 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 = { const struct v4l2_file_operations uvc_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = uvc_v4l2_open, .open = uvc_v4l2_open,
...@@ -1122,5 +1136,8 @@ const struct v4l2_file_operations uvc_fops = { ...@@ -1122,5 +1136,8 @@ const struct v4l2_file_operations uvc_fops = {
.read = uvc_v4l2_read, .read = uvc_v4l2_read,
.mmap = uvc_v4l2_mmap, .mmap = uvc_v4l2_mmap,
.poll = uvc_v4l2_poll, .poll = uvc_v4l2_poll,
#ifndef CONFIG_MMU
.get_unmapped_area = uvc_v4l2_get_unmapped_area,
#endif
}; };
...@@ -600,6 +600,10 @@ extern int uvc_queue_mmap(struct uvc_video_queue *queue, ...@@ -600,6 +600,10 @@ extern int uvc_queue_mmap(struct uvc_video_queue *queue,
struct vm_area_struct *vma); struct vm_area_struct *vma);
extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue, extern unsigned int uvc_queue_poll(struct uvc_video_queue *queue,
struct file *file, poll_table *wait); 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); extern int uvc_queue_allocated(struct uvc_video_queue *queue);
static inline int uvc_queue_streaming(struct uvc_video_queue *queue) static inline int uvc_queue_streaming(struct uvc_video_queue *queue)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment