Commit eee61f39 authored by Nicolas Dufresne's avatar Nicolas Dufresne

v4l2: Introduce DMABUF_IMPORT IO mode

parent 1ab90aba
...@@ -115,6 +115,7 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer, ...@@ -115,6 +115,7 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
pool->allocator); pool->allocator);
break; break;
case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_USERPTR:
case GST_V4L2_IO_DMABUF_IMPORT:
default: default:
newbuf = NULL; newbuf = NULL;
g_assert_not_reached (); g_assert_not_reached ();
...@@ -265,12 +266,15 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config) ...@@ -265,12 +266,15 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
GST_V4L2_ALLOCATOR_CAN_ALLOCATE (pool->vallocator, USERPTR); GST_V4L2_ALLOCATOR_CAN_ALLOCATE (pool->vallocator, USERPTR);
break; break;
case GST_V4L2_IO_RW: case GST_V4L2_IO_RW:
default:
pool->allocator = g_object_ref (allocator); pool->allocator = g_object_ref (allocator);
pool->params = params; pool->params = params;
/* No need to change the configuration */ /* No need to change the configuration */
goto done; goto done;
break; break;
case GST_V4L2_IO_DMABUF_IMPORT:
default:
g_assert_not_reached ();
break;
} }
if (min_buffers < GST_V4L2_MIN_BUFFERS) { if (min_buffers < GST_V4L2_MIN_BUFFERS) {
...@@ -336,6 +340,7 @@ start_streaming (GstV4l2BufferPool * pool) ...@@ -336,6 +340,7 @@ start_streaming (GstV4l2BufferPool * pool)
case GST_V4L2_IO_MMAP: case GST_V4L2_IO_MMAP:
case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_USERPTR:
case GST_V4L2_IO_DMABUF: case GST_V4L2_IO_DMABUF:
case GST_V4L2_IO_DMABUF_IMPORT:
GST_DEBUG_OBJECT (pool, "STREAMON"); GST_DEBUG_OBJECT (pool, "STREAMON");
if (v4l2_ioctl (pool->video_fd, VIDIOC_STREAMON, &obj->type) < 0) if (v4l2_ioctl (pool->video_fd, VIDIOC_STREAMON, &obj->type) < 0)
goto start_failed; goto start_failed;
...@@ -438,6 +443,7 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool) ...@@ -438,6 +443,7 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool)
break; break;
} }
case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_USERPTR:
case GST_V4L2_IO_DMABUF_IMPORT:
default: default:
num_buffers = 0; num_buffers = 0;
copy_threshold = 0; copy_threshold = 0;
...@@ -519,6 +525,7 @@ stop_streaming (GstV4l2BufferPool * pool) ...@@ -519,6 +525,7 @@ stop_streaming (GstV4l2BufferPool * pool)
case GST_V4L2_IO_MMAP: case GST_V4L2_IO_MMAP:
case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_USERPTR:
case GST_V4L2_IO_DMABUF: case GST_V4L2_IO_DMABUF:
case GST_V4L2_IO_DMABUF_IMPORT:
GST_DEBUG_OBJECT (pool, "STREAMOFF"); GST_DEBUG_OBJECT (pool, "STREAMOFF");
if (v4l2_ioctl (pool->video_fd, VIDIOC_STREAMOFF, &obj->type) < 0) if (v4l2_ioctl (pool->video_fd, VIDIOC_STREAMOFF, &obj->type) < 0)
goto stop_failed; goto stop_failed;
...@@ -836,6 +843,7 @@ gst_v4l2_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer, ...@@ -836,6 +843,7 @@ gst_v4l2_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
break; break;
case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_USERPTR:
case GST_V4L2_IO_DMABUF_IMPORT:
default: default:
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;
g_assert_not_reached (); g_assert_not_reached ();
...@@ -861,6 +869,7 @@ gst_v4l2_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer, ...@@ -861,6 +869,7 @@ gst_v4l2_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
break; break;
case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_USERPTR:
case GST_V4L2_IO_DMABUF_IMPORT:
default: default:
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;
g_assert_not_reached (); g_assert_not_reached ();
...@@ -919,6 +928,7 @@ gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer) ...@@ -919,6 +928,7 @@ gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer)
break; break;
} }
case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_USERPTR:
case GST_V4L2_IO_DMABUF_IMPORT:
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
...@@ -970,6 +980,7 @@ gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer) ...@@ -970,6 +980,7 @@ gst_v4l2_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer)
} }
case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_USERPTR:
case GST_V4L2_IO_DMABUF_IMPORT:
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
...@@ -1210,6 +1221,7 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer * buf) ...@@ -1210,6 +1221,7 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer * buf)
} }
case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_USERPTR:
case GST_V4L2_IO_DMABUF_IMPORT:
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
...@@ -1281,6 +1293,7 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer * buf) ...@@ -1281,6 +1293,7 @@ gst_v4l2_buffer_pool_process (GstV4l2BufferPool * pool, GstBuffer * buf)
} }
case GST_V4L2_IO_USERPTR: case GST_V4L2_IO_USERPTR:
case GST_V4L2_IO_DMABUF_IMPORT:
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
......
...@@ -238,6 +238,8 @@ gst_v4l2_io_mode_get_type (void) ...@@ -238,6 +238,8 @@ gst_v4l2_io_mode_get_type (void)
{GST_V4L2_IO_MMAP, "GST_V4L2_IO_MMAP", "mmap"}, {GST_V4L2_IO_MMAP, "GST_V4L2_IO_MMAP", "mmap"},
{GST_V4L2_IO_USERPTR, "GST_V4L2_IO_USERPTR", "userptr"}, {GST_V4L2_IO_USERPTR, "GST_V4L2_IO_USERPTR", "userptr"},
{GST_V4L2_IO_DMABUF, "GST_V4L2_IO_DMABUF", "dmabuf"}, {GST_V4L2_IO_DMABUF, "GST_V4L2_IO_DMABUF", "dmabuf"},
{GST_V4L2_IO_DMABUF_IMPORT, "GST_V4L2_IO_DMABUF_IMPORT",
"dmabuf-import"},
{0, NULL, NULL} {0, NULL, NULL}
}; };
...@@ -3123,8 +3125,10 @@ gst_v4l2_object_decide_allocation (GstV4l2Object * obj, GstQuery * query) ...@@ -3123,8 +3125,10 @@ gst_v4l2_object_decide_allocation (GstV4l2Object * obj, GstQuery * query)
} }
break; break;
case GST_V4L2_IO_MMAP: case GST_V4L2_IO_MMAP:
case GST_V4L2_IO_USERPTR:
case GST_V4L2_IO_DMABUF: 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 */ /* in streaming mode, prefer our own pool */
/* Check if we can use it ... */ /* Check if we can use it ... */
if (can_use_own_pool) { if (can_use_own_pool) {
......
...@@ -51,11 +51,12 @@ GType gst_v4l2_io_mode_get_type (void); ...@@ -51,11 +51,12 @@ GType gst_v4l2_io_mode_get_type (void);
#define GST_V4L2_OBJECT(obj) (GstV4l2Object *)(obj) #define GST_V4L2_OBJECT(obj) (GstV4l2Object *)(obj)
typedef enum { typedef enum {
GST_V4L2_IO_AUTO = 0, GST_V4L2_IO_AUTO = 0,
GST_V4L2_IO_RW = 1, GST_V4L2_IO_RW = 1,
GST_V4L2_IO_MMAP = 2, GST_V4L2_IO_MMAP = 2,
GST_V4L2_IO_USERPTR = 3, GST_V4L2_IO_USERPTR = 3,
GST_V4L2_IO_DMABUF = 4 GST_V4L2_IO_DMABUF = 4,
GST_V4L2_IO_DMABUF_IMPORT = 5
} GstV4l2IOMode; } GstV4l2IOMode;
typedef gboolean (*GstV4l2GetInOutFunction) (GstV4l2Object * v4l2object, gint * input); typedef gboolean (*GstV4l2GetInOutFunction) (GstV4l2Object * v4l2object, gint * input);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment