aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/videobuf-dma-contig.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-03-28 08:22:53 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:57:53 -0400
commit37111039c9521c751ce0597c129fe6d45ba72818 (patch)
tree00e6d6e75a4604a95d1062e6a2846196fd2054e8 /drivers/media/video/videobuf-dma-contig.c
parentf4fce60e8b1559306fa1112287bc8765f6977de3 (diff)
V4L/DVB: v4l videobuf: move video_copy_to_user and copy_stream to core
The video_copy_to_user and copy_stream ops are almost identical for all videobuf memtype variants. All that is needed is to use the new vaddr op and these functions can be moved into the core, ensuring we have just one single implementation instead of three. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/videobuf-dma-contig.c')
-rw-r--r--drivers/media/video/videobuf-dma-contig.c55
1 files changed, 0 insertions, 55 deletions
diff --git a/drivers/media/video/videobuf-dma-contig.c b/drivers/media/video/videobuf-dma-contig.c
index 7226ca47cbf5..0a0ff85140b7 100644
--- a/drivers/media/video/videobuf-dma-contig.c
+++ b/drivers/media/video/videobuf-dma-contig.c
@@ -353,67 +353,12 @@ error:
353 return -ENOMEM; 353 return -ENOMEM;
354} 354}
355 355
356static int __videobuf_copy_to_user(struct videobuf_queue *q,
357 char __user *data, size_t count,
358 int nonblocking)
359{
360 struct videobuf_dma_contig_memory *mem = q->read_buf->priv;
361 void *vaddr;
362
363 BUG_ON(!mem);
364 MAGIC_CHECK(mem->magic, MAGIC_DC_MEM);
365 BUG_ON(!mem->vaddr);
366
367 /* copy to userspace */
368 if (count > q->read_buf->size - q->read_off)
369 count = q->read_buf->size - q->read_off;
370
371 vaddr = mem->vaddr;
372
373 if (copy_to_user(data, vaddr + q->read_off, count))
374 return -EFAULT;
375
376 return count;
377}
378
379static int __videobuf_copy_stream(struct videobuf_queue *q,
380 char __user *data, size_t count, size_t pos,
381 int vbihack, int nonblocking)
382{
383 unsigned int *fc;
384 struct videobuf_dma_contig_memory *mem = q->read_buf->priv;
385
386 BUG_ON(!mem);
387 MAGIC_CHECK(mem->magic, MAGIC_DC_MEM);
388
389 if (vbihack) {
390 /* dirty, undocumented hack -- pass the frame counter
391 * within the last four bytes of each vbi data block.
392 * We need that one to maintain backward compatibility
393 * to all vbi decoding software out there ... */
394 fc = (unsigned int *)mem->vaddr;
395 fc += (q->read_buf->size >> 2) - 1;
396 *fc = q->read_buf->field_count >> 1;
397 dev_dbg(q->dev, "vbihack: %d\n", *fc);
398 }
399
400 /* copy stuff using the common method */
401 count = __videobuf_copy_to_user(q, data, count, nonblocking);
402
403 if ((count == -EFAULT) && (pos == 0))
404 return -EFAULT;
405
406 return count;
407}
408
409static struct videobuf_qtype_ops qops = { 356static struct videobuf_qtype_ops qops = {
410 .magic = MAGIC_QTYPE_OPS, 357 .magic = MAGIC_QTYPE_OPS,
411 358
412 .alloc = __videobuf_alloc, 359 .alloc = __videobuf_alloc,
413 .iolock = __videobuf_iolock, 360 .iolock = __videobuf_iolock,
414 .mmap_mapper = __videobuf_mmap_mapper, 361 .mmap_mapper = __videobuf_mmap_mapper,
415 .video_copy_to_user = __videobuf_copy_to_user,
416 .copy_stream = __videobuf_copy_stream,
417 .vaddr = __videobuf_to_vaddr, 362 .vaddr = __videobuf_to_vaddr,
418}; 363};
419 364