diff options
Diffstat (limited to 'drivers/media/video/uvc/uvc_queue.c')
-rw-r--r-- | drivers/media/video/uvc/uvc_queue.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/drivers/media/video/uvc/uvc_queue.c b/drivers/media/video/uvc/uvc_queue.c index f14581bd707..109a06384a8 100644 --- a/drivers/media/video/uvc/uvc_queue.c +++ b/drivers/media/video/uvc/uvc_queue.c @@ -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. * |