Commit graph

148 commits

Author SHA1 Message Date
Nicolas Dufresne
2e0fb42e86 v4l2bufferpool: Port to bufferpool flush_start/stop method 2014-05-24 15:38:53 -04:00
Sebastian Dröge
32d8eb9f80 v4l2bufferpool: Explicitly cast enum "subtype" to its "supertype"
gstv4l2bufferpool.c:608:18: error: implicit conversion from enumeration type
      'enum _GstV4l2BufferPoolAcquireFlags' to different enumeration type
      'GstBufferPoolAcquireFlags' [-Werror,-Wenum-conversion]
  params.flags = GST_V4L2_POOL_ACQUIRE_FLAG_RESURECT;
               ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2014-05-19 11:26:46 +02:00
Benjamin Gaignard
0d852cf235 v4l2bufferpool: Update pool limit with hardware requiremenst
If the driver need more buffers than requested by the config,
update the pool min/max values. The minimum value for the pool
could be provided either by the driver or by the pool. This is
best effort for drivers that don't support
CID V4L2_CID_MIN_BUFFERS_FOR_CAPTURE.

https://bugzilla.gnome.org/show_bug.cgi?id=730200
2014-05-15 12:55:33 -04:00
Nicolas Dufresne
a4b5811d22 v4l2: Split flush in start/stop_streaming
This allow calling start streaming later for capture device. Currently it breaks
in dmabuf-import because downstream is holding a buffer that will only be
released after stream-start.

https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:21:44 -04:00
Nicolas Dufresne
19608ac85b v4l2bufferpool: Don't deactivate otherpool
We should not stop the otherpool unless we also stop our own
pool, otherwise it will never get restarted.

https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:21:31 -04:00
Nicolas Dufresne
4b2808c310 v4l2bufferpool: Also update num_buffers for import cases
https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:21:12 -04:00
Nicolas Dufresne
de7e5e481d v4l2bufferpool: Use default VideoInfo for frame operation
When doing frame operation, we need to use the default VideoInfo
and let the frame API read the video meta in order to get the stride
and offset right. Currently we where using the specialized VideoInfo
which reflects what the HW is setup to.
2014-05-12 18:08:19 -04:00
Nicolas Dufresne
16f0c253a3 v4l2pool: Fix leak of config structure in error case
CIDs 1212167 and  1212167
2014-05-09 11:56:52 -04:00
Nicolas Dufresne
82a806e63b v4l2: Replace miss-use of crop meta in favour of proper offset
This moves away from copying information and store everything inside
the GstVideoInfo structure. The alignement exposed by v4l2 api
is now handled using proper offset.
2014-05-08 15:56:37 -04:00
Nicolas Dufresne
f3ecbeb577 v4l2bufferpool: Get number of allocated buffers from allocator
The value of num_allocated buffer would get confused when
buffer are being discarded.
2014-05-08 15:56:37 -04:00
Nicolas Dufresne
972cf80957 v4l2bufferpool: Improve debugging 2014-05-08 15:56:37 -04:00
Nicolas Dufresne
c7d735a596 v4l2bufferpool: Ensure we don't re-enqueue buffer during flush 2014-05-08 15:56:37 -04:00
Nicolas Dufresne
cb311d57f5 v4l2bufferpool: Re-enqueue buffer at stream start 2014-05-08 15:56:37 -04:00
Nicolas Dufresne
815c9b7d35 v4l2bufferpool: Acquire cannot return a buffer from another pool
Return a buffer from an otherpool has unwanted side effects that lead to leaks and
prevents deactivating the pool. Instead, we change the _process() API so it can
replace the internal buffer with the buffer from the downstream pool. This implied
moving from _fill() to _create() method in the src.
2014-05-08 15:56:37 -04:00
Nicolas Dufresne
97d0ca853e v4l2bufferpool: Remove unreached acquire code
The acquire is done in _prepare now.
2014-05-08 15:56:37 -04:00
Nicolas Dufresne
f13331e928 v4l2bufferpool: Sanetize buffer refount handling
Buffer refcounting is a bit hard, because of the duality between CAPTURE and
OUTPUT mode. In the long term, we should consider having two seperate pool
instead of this mess. At least state should be better kept this way.
2014-05-08 15:56:37 -04:00
Nicolas Dufresne
62605e11eb v4l2: Fixup USERPTR/DMABUF capture support 2014-05-08 15:56:37 -04:00
Nicolas Dufresne
ba32cf10f3 v4l2bufferpool: Update config if meta is missing
Rather then hard failure, we should update the config with the meta option we
need and return false.
2014-05-08 15:56:37 -04:00
Nicolas Dufresne
92bdd596f2 v4l2: Add DMABUF and USERPTR importation 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
eee61f39e5 v4l2: Introduce DMABUF_IMPORT IO mode 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
1ab90ababa v4l2: Add dmabuf export support
This can be enabled sing io-mode=dmabuf. This will enabled mmap base
drivers to export the buffers as dmabuf.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
cf6c7e9846 v4l2bufferpool: Do not pre-configure the pool
Pre-configuring the pool is error prone, since it may hide a configuration failure and
endup with a pool that is not configured the way it should (e.g. no video meta, wrong
queue size, etc.)
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
fa6cd1d25a v4l2bufferpool: Preserve downstream minimum even in RW 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
7b8bb7188b v4l2bufferpool: Turn cropmeta into a custom option
Turn crop meta into a custom option and make sure it's there is needed.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
2b0ac06ade v4l2bufferpool: Port to use GstV4l2Allocator 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
0028de808b v4l2: Probe for CREATE_BUFS in order to correctly set pool min/max
In order to correctly set the pool min/max, we need to probe for CREATE_BUFS
ioctl. This can be done as soon as the format has been negotiated using a
count of 0.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
8d6e72a299 v4l2: Move capture eos handling in _process()
Now that we might be copying out buffer (e.g. downstream don't support video
meta bug we need it) we need to move the EOS handling inside the process
method.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
403909d873 v4l2: Correctly check if video meta is needed
Correctly check if video meta is needed. In buffer pool, trust need_video_meta
flag in order to decide if configuration should succeed.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
36dfdff84c v4l2object: Ensure video and crop meta are enabled if needed
In certain cases we cannot live without video meta and/or crop meta
being enabled in our internal buffer pool. Ensure this is always the case,
regardless of having support for allocation query.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
6196026c76 v4l2bufferpool: Enforce activation outside of process
Enforce pool being activate from before calling pool process. This should
help catching basic errors in the usage of buffer pool.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
2f00119e3b v4l2bufferpool: Use obj->n_v4l2_planes for correct number of planes
Buffer pool was guessing wrongly the number of planes rather
then reading the value from obj->n_v4l2_planes. This was causing
format YU12 (I420) to fail upon check.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
a7286563ee v4l2: Add initial support for alignment and cropping 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
418a4940a8 v4l2: Use a copy of videodev2.h header
With years the amount of ifdef have grown up and we are not even sure if the
old code path compiles. Each time we need to update the v4l2 framework to add
the new feature, we break compilation on older kernel. With exception of two
controls in the video orientation control, this patch get rid of all ifdef by
including the latest version of videodev2.h inside GStreamer.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=723446
2014-03-15 13:54:47 +01:00
Tim-Philipp Müller
5535a824a4 v4l2src: also unset INTERLACED flag on buffers if frame is not interlaced
https://bugzilla.gnome.org/show_bug.cgi?id=724899
2014-02-21 19:48:42 +00:00
Simon Farnsworth
b4820460d8 v4l2src: Flag interlaced buffers as interlaced.
We correctly indicate the field ordering on interlaced buffers, but fail to
flag them as containing interlaced video, which we need to do here because
we signal interlace-mode=mixed in our caps. This means that downstream
elements (like vaapipostproc from gstreamer-vaapi) don't recognise these
buffers as in need of deinterlacing.

Fix this by setting the interlaced flag on all interlaced buffers.

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>

https://bugzilla.gnome.org/show_bug.cgi?id=724899
2014-02-21 19:48:06 +00:00
Michael Olbrich
3978f6ae6c v4l2: set GST_BUFFER_FLAG_DELTA_UNIT when appropriate
https://bugzilla.gnome.org/show_bug.cgi?id=722394
2014-01-17 10:04:34 -05:00
Michael Olbrich
3d2bd4ff49 v4l2bufferpool: don't ref the newly created allocator
Otherwise the allocator will never be deleted.

https://bugzilla.gnome.org/show_bug.cgi?id=712612
2014-01-17 08:32:28 -05:00
Nicolas Dufresne
4cffae36e3 v4l2: Add NV12_64Z32 support
https://bugzilla.gnome.org/show_bug.cgi?id=722127
2014-01-14 16:51:52 -05:00
Julien Isorce
55da3bc885 v4l2bufferpool: check set_config return value in gst_v4l2_buffer_pool_new
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:20:21 -05:00
Julien Isorce
a54b34121f v4l2bufferpool: do not stop a stream not previously started
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:20:21 -05:00
Julien Isorce
c701dcd16c v4l2bufferpool: add gst_v4l2_buffer_pool_flush
STREAMOFF set all v4l2buffers to DEQUEUE state.

Then for CAPTURE we call QBUF on each buffer.
For OUTPUT the buffers are just push back in the GstBufferPool
base class 's queue.
But the loop actually looks like the same.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:20:21 -05:00
Nicolas Dufresne
86646ce03b v4l2bufferpool: On warn on size change if n_planes > 1
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
994c5d2c93 v4l2bufferpool: Respect the suggested min buffer
https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:23 -05:00
Nicolas Dufresne
5faa20b044 v4l2object: Move the extrapolation of stride at the right place
Now that we have a stride array, we should extrapolate only when
eeded (non multi-planar buffer).

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Nicolas Dufresne
e1be685c34 v4l2bufferpool: Request buffers only once
VIDIOC_REQBUFS allocates buffer, it has no place inside set_config. Also, some driver do
no allow multiple calls to this ioctl.

https://bugzilla.gnome.org/show_bug.cgi?id=720568
2014-01-10 17:13:22 -05:00
Julien Isorce
3c70741e45 v4l2bufferpool: add support for multi-planar V4l2 API in DMABUF mode
Fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=712754
2013-12-04 09:28:25 +00:00
Julien Isorce
303cec48db v4l2: refactor by emulating one v4l2_plane in non-MPLANE mode
so that the buffer informations can be retrieved the same way
in both MPLANE and non-MPLANE mode.

Here "emulating" means "manually fill in the plane".

Fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=712754
2013-12-04 09:28:08 +00:00
Julien Isorce
61ae84b50d v4l2: add support for multi-planar V4L2 API
This api is in linux kernel since version 2.6.39,
and present in all version 3.

The commit that adds the API in master branch of the
linux kernel source is:
f8f3914cf9

v4l2 doc: "Some devices require data for each input
or output video frame to be placed in discontiguous
memory buffers"

There are newer structures 'struct v4l2_pix_format_mplane'
and 'struct v4l2_plane'.
So the pixel format is not setup with the same API when using
multi-planar.

Also for gst-v4l2, one of the difference is that in GstV4l2Meta
there are now one mem pointer for each maped plane.

When not using multi-planar, this commit takes care of keeping
the same code path than previously. So that the 2 cases are
in two different blocks triggered from V4L2_TYPE_IS_MULTIPLANAR.

Fixes bug https://bugzilla.gnome.org/show_bug.cgi?id=712754
2013-12-04 09:27:20 +00:00
Marc Leeman
bc87f39a90 v4l2: init v4l2_buffer to 0x0 before ioctl
https://bugzilla.gnome.org/show_bug.cgi?id=712137
2013-11-12 13:08:33 -05:00
Peter Korsgaard
94f3d6fc07 v4l2bufferpool: O_CLOEXEC needs _GNU_SOURCE
On some systems (E.G. uClibc and older Glibc versions), O_CLOEXEC is only
defined when _GNU_SOURCE is specified, so do so.

_GNU_SOURCE needs to be defined before any system headers are included,
so move the fcntl.h section up.

https://bugzilla.gnome.org/show_bug.cgi?id=709423
2013-10-04 14:33:43 +02:00