diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2010-03-28 08:09:05 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-19 11:57:54 -0400 |
commit | 0b62b73778554cd47480ea465f0b255cc63b4336 (patch) | |
tree | 880c3c5fc9b9ba75c65902da9dc77e8c97d3967d /drivers/media/video/videobuf-vmalloc.c | |
parent | 37111039c9521c751ce0597c129fe6d45ba72818 (diff) |
V4L/DVB: v4l videobuf: add videobuf_buffer *buf as argument to mmap_mapper
mmap_mapper should operate on a buffer, not on a complete queue. So let
the videobuf-core find the correct buffer instead of duplicating that
code in each mmap_mapper implementation.
The dma-sg implementation has backwards compatibility code for handling
the V4L1_COMPAT layer. This code is now under the v4L1_COMPAT config option.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/videobuf-vmalloc.c')
-rw-r--r-- | drivers/media/video/videobuf-vmalloc.c | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/drivers/media/video/videobuf-vmalloc.c b/drivers/media/video/videobuf-vmalloc.c index ad655839827b..f8b5b5635113 100644 --- a/drivers/media/video/videobuf-vmalloc.c +++ b/drivers/media/video/videobuf-vmalloc.c | |||
@@ -236,47 +236,28 @@ static int __videobuf_sync(struct videobuf_queue *q, | |||
236 | } | 236 | } |
237 | 237 | ||
238 | static int __videobuf_mmap_mapper(struct videobuf_queue *q, | 238 | static int __videobuf_mmap_mapper(struct videobuf_queue *q, |
239 | struct vm_area_struct *vma) | 239 | struct videobuf_buffer *buf, |
240 | struct vm_area_struct *vma) | ||
240 | { | 241 | { |
241 | struct videobuf_vmalloc_memory *mem; | 242 | struct videobuf_vmalloc_memory *mem; |
242 | struct videobuf_mapping *map; | 243 | struct videobuf_mapping *map; |
243 | unsigned int first; | ||
244 | int retval, pages; | 244 | int retval, pages; |
245 | unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; | ||
246 | 245 | ||
247 | dprintk(1, "%s\n", __func__); | 246 | dprintk(1, "%s\n", __func__); |
248 | if (!(vma->vm_flags & VM_WRITE) || !(vma->vm_flags & VM_SHARED)) | ||
249 | return -EINVAL; | ||
250 | |||
251 | /* look for first buffer to map */ | ||
252 | for (first = 0; first < VIDEO_MAX_FRAME; first++) { | ||
253 | if (NULL == q->bufs[first]) | ||
254 | continue; | ||
255 | |||
256 | if (V4L2_MEMORY_MMAP != q->bufs[first]->memory) | ||
257 | continue; | ||
258 | if (q->bufs[first]->boff == offset) | ||
259 | break; | ||
260 | } | ||
261 | if (VIDEO_MAX_FRAME == first) { | ||
262 | dprintk(1, "mmap app bug: offset invalid [offset=0x%lx]\n", | ||
263 | (vma->vm_pgoff << PAGE_SHIFT)); | ||
264 | return -EINVAL; | ||
265 | } | ||
266 | 247 | ||
267 | /* create mapping + update buffer list */ | 248 | /* create mapping + update buffer list */ |
268 | map = kzalloc(sizeof(struct videobuf_mapping), GFP_KERNEL); | 249 | map = kzalloc(sizeof(struct videobuf_mapping), GFP_KERNEL); |
269 | if (NULL == map) | 250 | if (NULL == map) |
270 | return -ENOMEM; | 251 | return -ENOMEM; |
271 | 252 | ||
272 | q->bufs[first]->map = map; | 253 | buf->map = map; |
273 | map->start = vma->vm_start; | 254 | map->start = vma->vm_start; |
274 | map->end = vma->vm_end; | 255 | map->end = vma->vm_end; |
275 | map->q = q; | 256 | map->q = q; |
276 | 257 | ||
277 | q->bufs[first]->baddr = vma->vm_start; | 258 | buf->baddr = vma->vm_start; |
278 | 259 | ||
279 | mem = q->bufs[first]->priv; | 260 | mem = buf->priv; |
280 | BUG_ON(!mem); | 261 | BUG_ON(!mem); |
281 | MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); | 262 | MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); |
282 | 263 | ||
@@ -302,8 +283,8 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, | |||
302 | 283 | ||
303 | dprintk(1, "mmap %p: q=%p %08lx-%08lx (%lx) pgoff %08lx buf %d\n", | 284 | dprintk(1, "mmap %p: q=%p %08lx-%08lx (%lx) pgoff %08lx buf %d\n", |
304 | map, q, vma->vm_start, vma->vm_end, | 285 | map, q, vma->vm_start, vma->vm_end, |
305 | (long int) q->bufs[first]->bsize, | 286 | (long int)buf->bsize, |
306 | vma->vm_pgoff, first); | 287 | vma->vm_pgoff, buf->i); |
307 | 288 | ||
308 | videobuf_vm_open(vma); | 289 | videobuf_vm_open(vma); |
309 | 290 | ||