diff options
author | Marek Szyprowski <m.szyprowski@samsung.com> | 2012-06-14 10:32:21 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-11-25 14:20:25 -0500 |
commit | c60520fa50cd86d64bc8ebb34300ddc4ca91393d (patch) | |
tree | 2f90c8d36f9ed166e6747fb2bd05444b350f1217 /drivers/media/v4l2-core | |
parent | 9bd09fd7385739bf571a6ea848bee425327ce34e (diff) |
[media] v4l: vb2-dma-contig: let mmap method to use dma_mmap_coherent call
Let mmap method to use dma_mmap_coherent call. Moreover, this patch removes
vb2_mmap_pfn_range from videobuf2 helpers as it was suggested by Laurent
Pinchart. The function is no longer used in vb2 code.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-dma-contig.c | 28 | ||||
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-memops.c | 40 |
2 files changed, 26 insertions, 42 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c index a5804cf12c7c..7fc71a0906db 100644 --- a/drivers/media/v4l2-core/videobuf2-dma-contig.c +++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c | |||
@@ -178,14 +178,38 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size) | |||
178 | static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma) | 178 | static int vb2_dc_mmap(void *buf_priv, struct vm_area_struct *vma) |
179 | { | 179 | { |
180 | struct vb2_dc_buf *buf = buf_priv; | 180 | struct vb2_dc_buf *buf = buf_priv; |
181 | int ret; | ||
181 | 182 | ||
182 | if (!buf) { | 183 | if (!buf) { |
183 | printk(KERN_ERR "No buffer to map\n"); | 184 | printk(KERN_ERR "No buffer to map\n"); |
184 | return -EINVAL; | 185 | return -EINVAL; |
185 | } | 186 | } |
186 | 187 | ||
187 | return vb2_mmap_pfn_range(vma, buf->dma_addr, buf->size, | 188 | /* |
188 | &vb2_common_vm_ops, &buf->handler); | 189 | * dma_mmap_* uses vm_pgoff as in-buffer offset, but we want to |
190 | * map whole buffer | ||
191 | */ | ||
192 | vma->vm_pgoff = 0; | ||
193 | |||
194 | ret = dma_mmap_coherent(buf->dev, vma, buf->vaddr, | ||
195 | buf->dma_addr, buf->size); | ||
196 | |||
197 | if (ret) { | ||
198 | pr_err("Remapping memory failed, error: %d\n", ret); | ||
199 | return ret; | ||
200 | } | ||
201 | |||
202 | vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; | ||
203 | vma->vm_private_data = &buf->handler; | ||
204 | vma->vm_ops = &vb2_common_vm_ops; | ||
205 | |||
206 | vma->vm_ops->open(vma); | ||
207 | |||
208 | pr_debug("%s: mapped dma addr 0x%08lx at 0x%08lx, size %ld\n", | ||
209 | __func__, (unsigned long)buf->dma_addr, vma->vm_start, | ||
210 | buf->size); | ||
211 | |||
212 | return 0; | ||
189 | } | 213 | } |
190 | 214 | ||
191 | /*********************************************/ | 215 | /*********************************************/ |
diff --git a/drivers/media/v4l2-core/videobuf2-memops.c b/drivers/media/v4l2-core/videobuf2-memops.c index 051ea3571b20..81c1ad8b2cf1 100644 --- a/drivers/media/v4l2-core/videobuf2-memops.c +++ b/drivers/media/v4l2-core/videobuf2-memops.c | |||
@@ -137,46 +137,6 @@ int vb2_get_contig_userptr(unsigned long vaddr, unsigned long size, | |||
137 | EXPORT_SYMBOL_GPL(vb2_get_contig_userptr); | 137 | EXPORT_SYMBOL_GPL(vb2_get_contig_userptr); |
138 | 138 | ||
139 | /** | 139 | /** |
140 | * vb2_mmap_pfn_range() - map physical pages to userspace | ||
141 | * @vma: virtual memory region for the mapping | ||
142 | * @paddr: starting physical address of the memory to be mapped | ||
143 | * @size: size of the memory to be mapped | ||
144 | * @vm_ops: vm operations to be assigned to the created area | ||
145 | * @priv: private data to be associated with the area | ||
146 | * | ||
147 | * Returns 0 on success. | ||
148 | */ | ||
149 | int vb2_mmap_pfn_range(struct vm_area_struct *vma, unsigned long paddr, | ||
150 | unsigned long size, | ||
151 | const struct vm_operations_struct *vm_ops, | ||
152 | void *priv) | ||
153 | { | ||
154 | int ret; | ||
155 | |||
156 | size = min_t(unsigned long, vma->vm_end - vma->vm_start, size); | ||
157 | |||
158 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); | ||
159 | ret = remap_pfn_range(vma, vma->vm_start, paddr >> PAGE_SHIFT, | ||
160 | size, vma->vm_page_prot); | ||
161 | if (ret) { | ||
162 | printk(KERN_ERR "Remapping memory failed, error: %d\n", ret); | ||
163 | return ret; | ||
164 | } | ||
165 | |||
166 | vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; | ||
167 | vma->vm_private_data = priv; | ||
168 | vma->vm_ops = vm_ops; | ||
169 | |||
170 | vma->vm_ops->open(vma); | ||
171 | |||
172 | pr_debug("%s: mapped paddr 0x%08lx at 0x%08lx, size %ld\n", | ||
173 | __func__, paddr, vma->vm_start, size); | ||
174 | |||
175 | return 0; | ||
176 | } | ||
177 | EXPORT_SYMBOL_GPL(vb2_mmap_pfn_range); | ||
178 | |||
179 | /** | ||
180 | * vb2_common_vm_open() - increase refcount of the vma | 140 | * vb2_common_vm_open() - increase refcount of the vma |
181 | * @vma: virtual memory region for the mapping | 141 | * @vma: virtual memory region for the mapping |
182 | * | 142 | * |