aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSumit Semwal <sumit.semwal@ti.com>2012-06-14 09:37:35 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-11-25 14:10:36 -0500
commit051c7788bcb92f2e98ef86e86651e0420765b121 (patch)
tree4ebf8044c62975ff4a0613fcf8ec1aca84910a97 /drivers
parent1323024fd3296537dd34da70fe70b4df12a308ec (diff)
[media] v4l: Add DMABUF as a memory type
Adds DMABUF memory type to v4l framework. Also adds the related file descriptor in v4l2_plane and v4l2_buffer. [original work in the PoC for buffer sharing] Signed-off-by: Tomasz Stanislawski <t.stanislaws@samsung.com> Signed-off-by: Sumit Semwal <sumit.semwal@ti.com> Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/v4l2-core/v4l2-compat-ioctl32.c18
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c1
2 files changed, 19 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 83ffb6436baf..cc5998b31463 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -297,6 +297,7 @@ struct v4l2_plane32 {
297 union { 297 union {
298 __u32 mem_offset; 298 __u32 mem_offset;
299 compat_long_t userptr; 299 compat_long_t userptr;
300 __s32 fd;
300 } m; 301 } m;
301 __u32 data_offset; 302 __u32 data_offset;
302 __u32 reserved[11]; 303 __u32 reserved[11];
@@ -318,6 +319,7 @@ struct v4l2_buffer32 {
318 __u32 offset; 319 __u32 offset;
319 compat_long_t userptr; 320 compat_long_t userptr;
320 compat_caddr_t planes; 321 compat_caddr_t planes;
322 __s32 fd;
321 } m; 323 } m;
322 __u32 length; 324 __u32 length;
323 __u32 reserved2; 325 __u32 reserved2;
@@ -341,6 +343,9 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
341 up_pln = compat_ptr(p); 343 up_pln = compat_ptr(p);
342 if (put_user((unsigned long)up_pln, &up->m.userptr)) 344 if (put_user((unsigned long)up_pln, &up->m.userptr))
343 return -EFAULT; 345 return -EFAULT;
346 } else if (memory == V4L2_MEMORY_DMABUF) {
347 if (copy_in_user(&up->m.fd, &up32->m.fd, sizeof(int)))
348 return -EFAULT;
344 } else { 349 } else {
345 if (copy_in_user(&up->m.mem_offset, &up32->m.mem_offset, 350 if (copy_in_user(&up->m.mem_offset, &up32->m.mem_offset,
346 sizeof(__u32))) 351 sizeof(__u32)))
@@ -364,6 +369,11 @@ static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
364 if (copy_in_user(&up32->m.mem_offset, &up->m.mem_offset, 369 if (copy_in_user(&up32->m.mem_offset, &up->m.mem_offset,
365 sizeof(__u32))) 370 sizeof(__u32)))
366 return -EFAULT; 371 return -EFAULT;
372 /* For DMABUF, driver might've set up the fd, so copy it back. */
373 if (memory == V4L2_MEMORY_DMABUF)
374 if (copy_in_user(&up32->m.fd, &up->m.fd,
375 sizeof(int)))
376 return -EFAULT;
367 377
368 return 0; 378 return 0;
369} 379}
@@ -446,6 +456,10 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
446 if (get_user(kp->m.offset, &up->m.offset)) 456 if (get_user(kp->m.offset, &up->m.offset))
447 return -EFAULT; 457 return -EFAULT;
448 break; 458 break;
459 case V4L2_MEMORY_DMABUF:
460 if (get_user(kp->m.fd, &up->m.fd))
461 return -EFAULT;
462 break;
449 } 463 }
450 } 464 }
451 465
@@ -510,6 +524,10 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
510 if (put_user(kp->m.offset, &up->m.offset)) 524 if (put_user(kp->m.offset, &up->m.offset))
511 return -EFAULT; 525 return -EFAULT;
512 break; 526 break;
527 case V4L2_MEMORY_DMABUF:
528 if (put_user(kp->m.fd, &up->m.fd))
529 return -EFAULT;
530 break;
513 } 531 }
514 } 532 }
515 533
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 8f388ff31ebb..530a67e3fe0e 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -155,6 +155,7 @@ static const char *v4l2_memory_names[] = {
155 [V4L2_MEMORY_MMAP] = "mmap", 155 [V4L2_MEMORY_MMAP] = "mmap",
156 [V4L2_MEMORY_USERPTR] = "userptr", 156 [V4L2_MEMORY_USERPTR] = "userptr",
157 [V4L2_MEMORY_OVERLAY] = "overlay", 157 [V4L2_MEMORY_OVERLAY] = "overlay",
158 [V4L2_MEMORY_DMABUF] = "dmabuf",
158}; 159};
159 160
160#define prt_names(a, arr) (((unsigned)(a)) < ARRAY_SIZE(arr) ? arr[a] : "unknown") 161#define prt_names(a, arr) (((unsigned)(a)) < ARRAY_SIZE(arr) ? arr[a] : "unknown")