diff options
Diffstat (limited to 'drivers/media/platform/omap/omap_vout.c')
-rw-r--r-- | drivers/media/platform/omap/omap_vout.c | 69 |
1 files changed, 31 insertions, 38 deletions
diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c index f09c5f17a42f..7feb6394f111 100644 --- a/drivers/media/platform/omap/omap_vout.c +++ b/drivers/media/platform/omap/omap_vout.c | |||
@@ -195,46 +195,34 @@ static int omap_vout_try_format(struct v4l2_pix_format *pix) | |||
195 | } | 195 | } |
196 | 196 | ||
197 | /* | 197 | /* |
198 | * omap_vout_uservirt_to_phys: This inline function is used to convert user | 198 | * omap_vout_get_userptr: Convert user space virtual address to physical |
199 | * space virtual address to physical address. | 199 | * address. |
200 | */ | 200 | */ |
201 | static unsigned long omap_vout_uservirt_to_phys(unsigned long virtp) | 201 | static int omap_vout_get_userptr(struct videobuf_buffer *vb, u32 virtp, |
202 | u32 *physp) | ||
202 | { | 203 | { |
203 | unsigned long physp = 0; | 204 | struct frame_vector *vec; |
204 | struct vm_area_struct *vma; | 205 | int ret; |
205 | struct mm_struct *mm = current->mm; | ||
206 | 206 | ||
207 | /* For kernel direct-mapped memory, take the easy way */ | 207 | /* For kernel direct-mapped memory, take the easy way */ |
208 | if (virtp >= PAGE_OFFSET) | 208 | if (virtp >= PAGE_OFFSET) { |
209 | return virt_to_phys((void *) virtp); | 209 | *physp = virt_to_phys((void *)virtp); |
210 | 210 | return 0; | |
211 | down_read(¤t->mm->mmap_sem); | 211 | } |
212 | vma = find_vma(mm, virtp); | ||
213 | if (vma && (vma->vm_flags & VM_IO) && vma->vm_pgoff) { | ||
214 | /* this will catch, kernel-allocated, mmaped-to-usermode | ||
215 | addresses */ | ||
216 | physp = (vma->vm_pgoff << PAGE_SHIFT) + (virtp - vma->vm_start); | ||
217 | up_read(¤t->mm->mmap_sem); | ||
218 | } else { | ||
219 | /* otherwise, use get_user_pages() for general userland pages */ | ||
220 | int res, nr_pages = 1; | ||
221 | struct page *pages; | ||
222 | 212 | ||
223 | res = get_user_pages(current, current->mm, virtp, nr_pages, 1, | 213 | vec = frame_vector_create(1); |
224 | 0, &pages, NULL); | 214 | if (!vec) |
225 | up_read(¤t->mm->mmap_sem); | 215 | return -ENOMEM; |
226 | 216 | ||
227 | if (res == nr_pages) { | 217 | ret = get_vaddr_frames(virtp, 1, true, false, vec); |
228 | physp = __pa(page_address(&pages[0]) + | 218 | if (ret != 1) { |
229 | (virtp & ~PAGE_MASK)); | 219 | frame_vector_destroy(vec); |
230 | } else { | 220 | return -EINVAL; |
231 | printk(KERN_WARNING VOUT_NAME | ||
232 | "get_user_pages failed\n"); | ||
233 | return 0; | ||
234 | } | ||
235 | } | 221 | } |
222 | *physp = __pfn_to_phys(frame_vector_pfns(vec)[0]); | ||
223 | vb->priv = vec; | ||
236 | 224 | ||
237 | return physp; | 225 | return 0; |
238 | } | 226 | } |
239 | 227 | ||
240 | /* | 228 | /* |
@@ -784,11 +772,15 @@ static int omap_vout_buffer_prepare(struct videobuf_queue *q, | |||
784 | * address of the buffer | 772 | * address of the buffer |
785 | */ | 773 | */ |
786 | if (V4L2_MEMORY_USERPTR == vb->memory) { | 774 | if (V4L2_MEMORY_USERPTR == vb->memory) { |
775 | int ret; | ||
776 | |||
787 | if (0 == vb->baddr) | 777 | if (0 == vb->baddr) |
788 | return -EINVAL; | 778 | return -EINVAL; |
789 | /* Physical address */ | 779 | /* Physical address */ |
790 | vout->queued_buf_addr[vb->i] = (u8 *) | 780 | ret = omap_vout_get_userptr(vb, vb->baddr, |
791 | omap_vout_uservirt_to_phys(vb->baddr); | 781 | (u32 *)&vout->queued_buf_addr[vb->i]); |
782 | if (ret < 0) | ||
783 | return ret; | ||
792 | } else { | 784 | } else { |
793 | unsigned long addr, dma_addr; | 785 | unsigned long addr, dma_addr; |
794 | unsigned long size; | 786 | unsigned long size; |
@@ -834,12 +826,13 @@ static void omap_vout_buffer_queue(struct videobuf_queue *q, | |||
834 | static void omap_vout_buffer_release(struct videobuf_queue *q, | 826 | static void omap_vout_buffer_release(struct videobuf_queue *q, |
835 | struct videobuf_buffer *vb) | 827 | struct videobuf_buffer *vb) |
836 | { | 828 | { |
837 | struct omap_vout_device *vout = q->priv_data; | ||
838 | |||
839 | vb->state = VIDEOBUF_NEEDS_INIT; | 829 | vb->state = VIDEOBUF_NEEDS_INIT; |
830 | if (vb->memory == V4L2_MEMORY_USERPTR && vb->priv) { | ||
831 | struct frame_vector *vec = vb->priv; | ||
840 | 832 | ||
841 | if (V4L2_MEMORY_MMAP != vout->memory) | 833 | put_vaddr_frames(vec); |
842 | return; | 834 | frame_vector_destroy(vec); |
835 | } | ||
843 | } | 836 | } |
844 | 837 | ||
845 | /* | 838 | /* |