From eee61f39e5f1e6a536c15331bd8a11d27cfb241b Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Mon, 14 Apr 2014 12:19:39 -0400 Subject: [PATCH] v4l2: Introduce DMABUF_IMPORT IO mode --- sys/v4l2/gstv4l2bufferpool.c | 15 ++++++++++++++- sys/v4l2/gstv4l2object.c | 6 +++++- sys/v4l2/gstv4l2object.h | 11 ++++++----- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index 088e3d5dbf..adf52cd494 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -115,6 +115,7 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer, pool->allocator); break; case GST_V4L2_IO_USERPTR: + case GST_V4L2_IO_DMABUF_IMPORT: default: newbuf = NULL; g_assert_not_reached (); @@ -265,12 +266,15 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config) GST_V4L2_ALLOCATOR_CAN_ALLOCATE (pool->vallocator, USERPTR); break; case GST_V4L2_IO_RW: - default: pool->allocator = g_object_ref (allocator); pool->params = params; /* No need to change the configuration */ goto done; break; + case GST_V4L2_IO_DMABUF_IMPORT: + default: + g_assert_not_reached (); + break; } if (min_buffers < GST_V4L2_MIN_BUFFERS) { @@ -336,6 +340,7 @@ start_streaming (GstV4l2BufferPool * pool) case GST_V4L2_IO_MMAP: case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_DMABUF: + case GST_V4L2_IO_DMABUF_IMPORT: GST_DEBUG_OBJECT (pool, "STREAMON"); if (v4l2_ioctl (pool->video_fd, VIDIOC_STREAMON, &obj->type) < 0) goto start_failed; @@ -438,6 +443,7 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool) break; } case GST_V4L2_IO_USERPTR: + case GST_V4L2_IO_DMABUF_IMPORT: default: num_buffers = 0; copy_threshold = 0; @@ -519,6 +525,7 @@ stop_streaming (GstV4l2BufferPool * pool) case GST_V4L2_IO_MMAP: case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_DMABUF: + case GST_V4L2_IO_DMABUF_IMPORT: GST_DEBUG_OBJECT (pool, "STREAMOFF"); if (v4l2_ioctl (pool->video_fd, VIDIOC_STREAMOFF, &obj->type) < 0) goto stop_failed; @@ -836,6 +843,7 @@ gst_v4l2_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer, break; case GST_V4L2_IO_USERPTR: + case GST_V4L2_IO_DMABUF_IMPORT: default: ret = GST_FLOW_ERROR; g_assert_not_reached (); @@ -861,6 +869,7 @@ gst_v4l2_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer, break; case GST_V4L2_IO_USERPTR: + case GST_V4L2_IO_DMABUF_IMPORT: default: ret = GST_FLOW_ERROR; g_assert_not_reached (); @@ -919,6 +928,7 @@ gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer) break; } case GST_V4L2_IO_USERPTR: + case GST_V4L2_IO_DMABUF_IMPORT: default: g_assert_not_reached (); break; @@ -970,6 +980,7 @@ gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer) } case GST_V4L2_IO_USERPTR: + case GST_V4L2_IO_DMABUF_IMPORT: default: g_assert_not_reached (); break; @@ -1210,6 +1221,7 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer * buf) } case GST_V4L2_IO_USERPTR: + case GST_V4L2_IO_DMABUF_IMPORT: default: g_assert_not_reached (); break; @@ -1281,6 +1293,7 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer * buf) } case GST_V4L2_IO_USERPTR: + case GST_V4L2_IO_DMABUF_IMPORT: default: g_assert_not_reached (); break; diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 3c70ec53c5..f70e666a0e 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -238,6 +238,8 @@ gst_v4l2_io_mode_get_type (void) {GST_V4L2_IO_MMAP, "GST_V4L2_IO_MMAP", "mmap"}, {GST_V4L2_IO_USERPTR, "GST_V4L2_IO_USERPTR", "userptr"}, {GST_V4L2_IO_DMABUF, "GST_V4L2_IO_DMABUF", "dmabuf"}, + {GST_V4L2_IO_DMABUF_IMPORT, "GST_V4L2_IO_DMABUF_IMPORT", + "dmabuf-import"}, {0, NULL, NULL} }; @@ -3123,8 +3125,10 @@ gst_v4l2_object_decide_allocation (GstV4l2Object * obj, GstQuery * query) } break; case GST_V4L2_IO_MMAP: - case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_DMABUF: + /* FIXME in these case we actually prefer/need a downstream pool */ + case GST_V4L2_IO_USERPTR: + case GST_V4L2_IO_DMABUF_IMPORT: /* in streaming mode, prefer our own pool */ /* Check if we can use it ... */ if (can_use_own_pool) { diff --git a/sys/v4l2/gstv4l2object.h b/sys/v4l2/gstv4l2object.h index 07723fc913..4500d315b2 100644 --- a/sys/v4l2/gstv4l2object.h +++ b/sys/v4l2/gstv4l2object.h @@ -51,11 +51,12 @@ GType gst_v4l2_io_mode_get_type (void); #define GST_V4L2_OBJECT(obj) (GstV4l2Object *)(obj) typedef enum { - GST_V4L2_IO_AUTO = 0, - GST_V4L2_IO_RW = 1, - GST_V4L2_IO_MMAP = 2, - GST_V4L2_IO_USERPTR = 3, - GST_V4L2_IO_DMABUF = 4 + GST_V4L2_IO_AUTO = 0, + GST_V4L2_IO_RW = 1, + GST_V4L2_IO_MMAP = 2, + GST_V4L2_IO_USERPTR = 3, + GST_V4L2_IO_DMABUF = 4, + GST_V4L2_IO_DMABUF_IMPORT = 5 } GstV4l2IOMode; typedef gboolean (*GstV4l2GetInOutFunction) (GstV4l2Object * v4l2object, gint * input); -- 2.34.1