mirror of
https://github.com/tbsdtv/media_build.git
synced 2025-07-23 04:13:02 +02:00
75 lines
2.3 KiB
Diff
75 lines
2.3 KiB
Diff
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
|
|
index 2266bbd239ab..8b34af369f0b 100644
|
|
--- a/drivers/media/common/videobuf2/videobuf2-core.c
|
|
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
|
|
@@ -2319,13 +2319,6 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma)
|
|
goto unlock;
|
|
}
|
|
|
|
- /*
|
|
- * vm_pgoff is treated in V4L2 API as a 'cookie' to select a buffer,
|
|
- * not as a in-buffer offset. We always want to mmap a whole buffer
|
|
- * from its beginning.
|
|
- */
|
|
- vma->vm_pgoff = 0;
|
|
-
|
|
ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma);
|
|
|
|
unlock:
|
|
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
|
|
index 765541840a35..89b5f5cc8a00 100644
|
|
--- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c
|
|
+++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c
|
|
@@ -277,6 +277,12 @@ static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma)
|
|
return -EINVAL;
|
|
}
|
|
|
|
+ /*
|
|
+ * dma_mmap_* uses vm_pgoff as in-buffer offset, but we want to
|
|
+ * map whole buffer
|
|
+ */
|
|
+ vma->vm_pgoff = 0;
|
|
+
|
|
if (buf->non_coherent_mem)
|
|
ret = dma_mmap_noncontiguous(buf->dev, vma, buf->size,
|
|
buf->dma_sgt);
|
|
diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
|
|
index b28475af5702..9865736dd7d7 100644
|
|
--- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c
|
|
+++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c
|
|
@@ -327,18 +327,28 @@ static unsigned int vb2_dma_sg_num_users(void *buf_priv)
|
|
static int vb2_dma_sg_mmap(void *buf_priv, struct vm_area_struct *vma)
|
|
{
|
|
struct vb2_dma_sg_buf *buf = buf_priv;
|
|
- int err;
|
|
+ unsigned long uaddr = vma->vm_start;
|
|
+ unsigned long usize = vma->vm_end - vma->vm_start;
|
|
+ int i = 0;
|
|
|
|
if (!buf) {
|
|
printk(KERN_ERR "No memory to map\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
- err = vm_map_pages(vma, buf->pages, buf->num_pages);
|
|
- if (err) {
|
|
- printk(KERN_ERR "Remapping memory, error: %d\n", err);
|
|
- return err;
|
|
- }
|
|
+ do {
|
|
+ int ret;
|
|
+
|
|
+ ret = vm_insert_page(vma, uaddr, buf->pages[i++]);
|
|
+ if (ret) {
|
|
+ printk(KERN_ERR "Remapping memory, error: %d\n", ret);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ uaddr += PAGE_SIZE;
|
|
+ usize -= PAGE_SIZE;
|
|
+ } while (usize > 0);
|
|
+
|
|
|
|
/*
|
|
* Use common vm_area operations to track buffer refcount.
|