Commit graph

1522 commits

Author SHA1 Message Date
Peter Korsgaard
d3eea8f606 v4l2allocator: O_CLOEXEC needs _GNU_SOURCE
Similar to 94f3d6fc / bz 709423

On some systems (E.G. uClibc and older Glibc versions), O_CLOEXEC is only
defined when _GNU_SOURCE is specified, so do so.

https://bugzilla.gnome.org/show_bug.cgi?id=736670
2014-09-16 10:20:22 +03:00
Ognyan Tonchev
b417c3409b v4l2sink: Unref pool after usage
https://bugzilla.gnome.org/show_bug.cgi?id=736384
2014-09-10 08:26:18 -04:00
Nicolas Dufresne
de6db03b53 v4l2transform: Don't rank it for now
This will prevent the converter to be picked automatically in case
someone implement dynamic converter selection support. I'd like this
to be ranked only for known device, as it's hard to be sure a device is
a converter suited for general purpose. Re-negotiation is also needed
before we can rank it.

https://bugzilla.gnome.org/show_bug.cgi?id=733607
2014-09-09 19:03:50 -04:00
Nicolas Dufresne
b706103fab v4l2: Detect bad drivers timestamps
Even though the UVC driver do a great deal of effort to prevent bad
timestamp to be sent to userspace, there still exist UVC hardware that
are so buggy that the timestamp endup nearly random. This code detect
and ignore timestamp from these drivers, making these camera usable.
This has been tested on both invalid and valid cameras, making sure it
does not trigger for valid cameras.

https://bugzilla.gnome.org/show_bug.cgi?id=732910
2014-09-09 18:50:59 -04:00
Nicolas Dufresne
5c933fa781 v4l2allocator: Workaround driver that don't support REQBUFS(0)
There is still around 18 drivers not yet ported to videobuf2. These driver
don't support freeing buffetrs through REQBUFS(0) hence for these the
memory type probing fails. In order to gain back our previous behaviour in
presence of these, we implement a workaround that assuming MMAP is
supported. Note that an allocator is only created for device with
STREAMING support in the device capabilities. In such case one of MMAP,
USERPTR and DMABUF is required. Though DMABUF came afterward, so is
not an option and in practice none of these drivers will only do USERPTR.

https://bugzilla.gnome.org/show_bug.cgi?id=735660

Also-by: Hans de Goede <hdegoede@redhat.com>
2014-09-09 18:45:34 -04:00
Nicolas Dufresne
743c6a4475 v4l2: Merge min_buffers_for* variable into one
Reuse the same min_buffers variable for both capture and output, this
reduce the length of lines and make the code more readable.

https://bugzilla.gnome.org/show_bug.cgi?id=736072
2014-09-09 18:39:23 -04:00
Aurélien Zanelli
3afec4dd01 v4l2: set min_latency for output device according to required minimum number of buffers
Since we can get the minimum number of buffers needed by an output
device to work, use it to set min_latency which will determine how many
buffers are queued.

https://bugzilla.gnome.org/show_bug.cgi?id=736072
2014-09-09 18:39:23 -04:00
Hans de Goede
116649371e v4l2: get_nearest_size: Fix "Unsupported field type" errors
Most V4L2 ioctls like try_fmt will adjust input fields to match what the
hardware can do rather then returning -EINVAL. As is docmented here:
http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-g-fmt.html

EINVAL is only returned if the buffer type field is invalid or not supported.

So upon requesting V4L2_FIELD_NONE devices which can only do interlaced
mode will change the field value to e.g. V4L2_FIELD_BOTTOM as only returning
half the lines is the closest they can do to progressive modes.

In essence this means that we've failed to get a (usable) progessive mode
and should fall back to interlaced mode.

This commit adds a check for having gotten a usable field value after the first
try_fmt, to force fallback to interlaced mode even if the try_fmt succeeded,
thereby fixing get_nearest_size failing on these devices.

https://bugzilla.gnome.org/show_bug.cgi?id=735660
2014-08-29 16:15:11 -04:00
Hans de Goede
8ad0509a1c v4l2: get_nearest_size: Always reinit all struct fields on retry
They may have been modified by the ioctl even if it failed. This also makes
the S_FMT fallback path try progressive first, making it consistent with the
preferred TRY_FMT path.

https://bugzilla.gnome.org/show_bug.cgi?id=735660
2014-08-29 16:14:56 -04:00
Nicolas Dufresne
2c870ff167 ximagesrc: Fix warning about missing return value 2014-07-31 09:53:53 -04:00
Nicolas Dufresne
c82052e723 ximagesrc: Add missing return value to Buffer dispose function
Depending ont he build, the method could return FALSE, hence never
free the buffers, or already TRUE and lead to a crash:

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=733695
2014-07-31 09:14:10 -04:00
Thiago Santos
550be3e51b v4l2bufferpool: clear gcond 2014-07-26 12:19:18 -03:00
Nicolas Dufresne
287517d6a9 Revert "v4l2bufferpool: Workaround elements not requesting any buffers"
This was a tempory workaround, we should fix the encoders that do not
negotatiate the amount of buffers they need.

This reverts commit d03bcba3db.
2014-07-25 14:30:33 -04:00
Nicolas Dufresne
3df949c745 v4l2object: Don't share own pool if min exceed V4L2 capacity
If the minimum required buffer exceed V4L2 capacity, don't share down
pool. This allow support very high latency, like with x264enc default
encoding settings.

https://bugzilla.gnome.org/show_bug.cgi?id=732288
2014-07-25 14:18:47 -04:00
Aurélien Zanelli
010272a796 v4l2object: query minimum required buffers for output
Some v4l2 devices could require a minimum buffers different from default
values. Rather than blindly propose a pool with min-buffers set to the
default value, it ask the device using control ioctl.

https://bugzilla.gnome.org/show_bug.cgi?id=733750
2014-07-25 13:43:09 -04:00
Aurélien Zanelli
de799f4d84 v4l2sink: use directly 'obj' instead of 'v4l2sink->v4l2object'
https://bugzilla.gnome.org/show_bug.cgi?id=733616
2014-07-25 13:42:33 -04:00
Aurélien Zanelli
57ae11ac6f v4l2: set debug messages according to device type and IO mode
https://bugzilla.gnome.org/show_bug.cgi?id=733616
2014-07-25 13:42:00 -04:00
Nicolas Dufresne
e196906b99 v4l2object: Remove is_active checks
These checks are no longer required with recent change to the bufferpool. This
should allow changing the configuartion, hence the way forward renegotiation
support.

https://bugzilla.gnome.org/show_bug.cgi?id=728268
2014-07-25 13:39:50 -04:00
Nicolas Dufresne
d7876e5597 v4l2bufferpool: Fix copy threshold implementation
We cannot allocate new buffer in acquire, otherwise the base class
is not aware and get confused. Instead, copy in _process(). This leads
to crash on finalize.

Fixes regression, see https://bugzilla.gnome.org/show_bug.cgi?id=732912
2014-07-11 13:45:30 -04:00
Nicolas Dufresne
0ac0cbcc0e v4l2allocator: Use qdata instead of parenting to DmabufMemory
Parenting V4l2Memory to DmabufMemory was in conflict with recent
optimization in DmabufMemory to avoid dup(), and didn't work with
memory sharing. Instead, use a qdata and it's destroy notify.

https://bugzilla.gnome.org/show_bug.cgi?id=730441
2014-07-11 09:49:27 +02:00
Nicolas Dufresne
d03bcba3db v4l2bufferpool: Workaround elements not requesting any buffers
This is a workaround for element that don't request buffers when
they should.

https://bugzilla.gnome.org/show_bug.cgi?id=732288
2014-07-10 18:22:10 -04:00
Nicolas Dufresne
12a3bdbd09 v4l2src: Ensure internal pool activation
Before we would hit an assertion "'gst_buffer_pool_is_active (bpool)' failed"
if the internal pool was not used to push buffer downstrea, hence not
given to the baseclass.

https://bugzilla.gnome.org/show_bug.cgi?id=732912
2014-07-09 15:26:12 -04:00
Nicolas Dufresne
0126e75676 v4l2object: Pool might be NULL in decide allocation
If special stride is needed and downstream don't support VideoMeta,
pool might be NULL in order to let the baseclass create a generic
pool­. This would lead to assertion with on Exynos with:

gst-launch-1.0 -v filesrc location=mov ! qtdemux ! h264parse ! \
                    v4l2video8dec ! fakesink

https://bugzilla.gnome.org/show_bug.cgi?id=732707
2014-07-03 15:30:01 -04:00
Nicolas Dufresne
3f15e67923 v4l2bufferpool: Handle FD error during poll
This will ensure we fail earlier if something unrecoverable
happens.
2014-07-03 15:29:54 -04:00
Nicolas Dufresne
652ed3bceb v4l2bufferpool: Wait before polling if queue is empty
In kernel before 3.17, polling during queue underrun would unblock right
away and trigger POLLERR. As we are not handling POLLERR, we would endup
blocking in DQBUF call, which won't be unblocked correctly when going
to NULL state. A deadlock at start caused by locking error in libv4l2 was
also seen before this patch. Instead, we wait until the queue is no longer
empty before polling.

https://bugzilla.gnome.org/show_bug.cgi?id=731015
2014-07-03 15:28:45 -04:00
Tim-Philipp Müller
a016f19de8 v4l2: fix probing and enumeration of stepwise frame sizes
The code enumerating STEPWISE framesizes would start from
(min_w, min_h) and then add (step_w, step_h) to get the
next framesize. However, it should really allow any width
from min_w to max_w with step_w and same for heights.
Secondly, we would add and probe each individual stepped
frame size to the caps as separate structure, which would
lead to hundreds if not thousands of structs ending up in
the probed caps. Use integer ranges with steps instead.

This was particularly noticable with the Raspberry Pi Cam.

https://bugzilla.gnome.org/show_bug.cgi?id=724521
https://bugzilla.gnome.org/show_bug.cgi?id=732458
https://bugzilla.gnome.org/show_bug.cgi?id=726521
2014-07-01 20:23:58 +01:00
Daniel Drake
f9eb4dd206 v4l2object: drop workaround for misbehaving TRY_FMT
This workaround from 2011 was causing 25 S_FMT ioctls to be sent
to my UVC webcam from under gst_v4l2_object_get_caps as it probes
all the formats. In total, this adds up to about 5 seconds of
execution time, or a 10 second delay while starting up cheese.

These ioctls come from a workaround from 2011 where TRY_FMT might
make changes to hardware settings, so S_FMT was used to restore
the original config:
https://bugzilla.gnome.org/show_bug.cgi?id=649067

The driver bug is now assumed fixed. Remove the workaround to fix the
long startup delay.

https://bugzilla.gnome.org/show_bug.cgi?id=732326
2014-07-01 12:36:27 -04:00
Tim-Philipp Müller
f79de9a420 v4l2: fix compiler warnings when compiling with -DG_DISABLE_ASSERT
Compiler complains about uninitialised variables in the impossible
'default' code path in device provider source/sink switch-case.
2014-06-29 17:06:11 +01:00
Olivier Crête
a9c385686a Rename GstDeviceMonitor to GstDeviceProvider 2014-06-26 14:57:36 -04:00
Andoni Morales Alastruey
93653ae5f9 osxvideosink: remove legacy code for passing a window handle
"have-ns-view" and the "embed" property was kept in 0.10 for
backwards compatibility but it's no longer used in favor of
the GstVideoOverlay interface

https://bugzilla.gnome.org/show_bug.cgi?id=703753
2014-06-23 20:40:09 +02:00
Tim-Philipp Müller
dd165a4b1a pulse, v4l2: update for device "klass" -> "device-class" rename 2014-06-21 01:32:03 +01:00
Tim-Philipp Müller
d5b344ba74 oss: simplify probed caps before returning them
Exposes all formats in the first structure if the
rest is the same for all of them.
2014-06-13 09:52:03 +01:00
Tim-Philipp Müller
ffcb884551 oss: make sure 16-bit formats are before 8-bit formats in probed caps
Probe supported formats in order of desirability rather than in
what order they may happen to be in the formats bitmask. Fixes
accidentally exposure of 8-bit formats in caps before 16-bit formats
(in case where U16 was not supported S8 might be listed before S16).

https://bugzilla.gnome.org/show_bug.cgi?id=706884
2014-06-13 09:49:38 +01:00
Nicolas Dufresne
0fb59dbdba v4l2bufferpool: Cleanly handle v4l2_allocator_new failure 2014-06-12 16:41:09 -04:00
Nicolas Dufresne
1648e46f86 v4l2bufferpool: Cleanup poll method and retry on EINTR/EAGAIN
https://bugzilla.gnome.org/show_bug.cgi?id=731015
2014-06-04 15:15:56 -04:00
Julien Isorce
5c07e6b45c v4l2sink: implement gstvideosink.show_frame instead of gstbasesink.render
It allows to show preroll frame. Especially it allows to update the
frame when seeking in PAUSED state.

https://bugzilla.gnome.org/show_bug.cgi?id=722303
2014-05-26 14:07:42 -04:00
Nicolas Dufresne
ea340455ae v4l2sink: Cleanup old pad alloc declaration 2014-05-26 13:43:30 -04:00
Nicolas Dufresne
b3bf4e33d0 v4l2bufferpool: Copy already queued buffer
This is required as during preroll we pass the first buffer twice, hence already
queued. It is also useful, to allow filters replaying a previous rendered buffers.
This will require 1 more buffer in sink if last-sample is enabled, since the last
sample will not be the same as the currently queued buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=722303
2014-05-26 13:43:30 -04:00
Nicolas Dufresne
e2fd7e274e v4l2bufferpool: Port to bufferpool flush_start/stop method
Port the buffer pool to use the new flush_start/flush_stop virtual
methods added to GstBufferPool.

https://bugzilla.gnome.org/show_bug.cgi?id=727611
2014-05-26 13:43:30 -04:00
Nicolas Dufresne
bc002d579f v4l2bufferpool: Don't queue all the buffers before dequeueing first
For output device, we where queuing all the buffers, and then we would
dequeue one. This means we only have 1 buffer for the pipeline, no matter
the size of the queue. Instead, start dequeued when min_latency is reached.
Eventually, this the min_latency should also be affected by control
MIN_BUFFERS_FOR_OUTPUT (use by encoders).
2014-05-25 00:05:56 -04:00
Nicolas Dufresne
ffb7a78798 v4l2object: Simply read back the config to update the query
It's easy to get the min/max outdate when hacking decide allocation. In
order to avoid this, simply read back the choosen value from the config.
2014-05-25 00:05:56 -04:00
Nicolas Dufresne
66519d08b0 v4l2: Cleanup and fix calculation of latency
Calculation of num_buffers (the max latency in buffers) was
up-side-down.  If we can allcoate, then our maximum latency match
pool maximum number of buffers. Also renamed it to max latency. Finally
introduced a min_latency for clarity.
2014-05-25 00:04:44 -04:00
Nicolas Dufresne
2e89f4ecff Revert "v4l2bufferpool: Port to bufferpool flush_start/stop method"
This reverts commit 2e0fb42e86.

Conflicts:
	sys/v4l2/gstv4l2allocator.c
	sys/v4l2/gstv4l2bufferpool.c
	sys/v4l2/gstv4l2videodec.c
2014-05-24 20:00:14 -04:00
Nicolas Dufresne
ba10cb14ea v4l2object: Fix configuration of other_pool and importation case
Fix the choice of min/max, don't override the min/max with own pool selected
size, correct other_pool is_active check, start from other_pool config when
configuring the other pool and finally validate the configuration.
2014-05-24 18:56:32 -04:00
Nicolas Dufresne
4aa5d42184 v4l2object: Use proposed allocator as default 2014-05-24 18:45:30 -04:00
Nicolas Dufresne
aff64af8ad v4l2bufferpool: Fix USERPTR map flags
We need to map READ only for output and write only for capture, we where
doing the opposite. This fixing USERPTR with glimagesink

https://bugzilla.gnome.org/show_bug.cgi?id=730698
2014-05-24 18:43:28 -04:00
Nicolas Dufresne
3a7bd8d479 v4l2bufferpool: Prevent num_queued from going negative 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
57726911f8 v4l2videodec: don't stop if loop returned FLUSHING
The decodeing thread returning flushing isn't an error, we should simply
try starting the task again. If it's actually flushing, it will stop again by itself.
2014-05-24 15:38:53 -04:00
Nicolas Dufresne
3acbd9cb99 v4l2videodec: Handle early task stop 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
a65ab6378d v4l2videodec: Handle gst_pad_start_task() failure 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
1e48ad8fa8 v4l2videodec: Add trace for FLUSH_START/STOP handling 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
c9dcc63eb8 v4l2videodec: Fix use of atomic value 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
45b322c2db v4l2bufferpool: Improve debugging
No need to use obj->element, the pool now have a significant name. Also don't
warn if flushing.
2014-05-24 15:38:53 -04:00
Nicolas Dufresne
03ed348d95 v4l2videodec: Fix handle_frame error handling 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
e70173e28a v4l2bufferpool: Add a trace when _start() is called 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
2cb6b9775c v4l2allocator: Add debug assert to detect calls in the wrong state 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
1f70b21926 v4l2allocator: Reset count when stopped 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
6a07e96734 v4l2allocator: Return a GstFlowReturn instead of boolean in alloc 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
43643b8e26 v4l2object: Don't leak config structure 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
2e0fb42e86 v4l2bufferpool: Port to bufferpool flush_start/stop method 2014-05-24 15:38:53 -04:00
Nicolas Dufresne
0746bca190 ximagesrc: Fix ximage leaks when buffer has more then one ximage
From time to time, when the image_pool list has more then 1 element
and I suppose at start, all but 1 pooled ximage are leaked. This is
due to broken algorithm in gst_ximagesink_src_ximage_get(). There was
also a risk of use after free for the case where the ximage size has
changed.

https://bugzilla.gnome.org/show_bug.cgi?id=728502
2014-05-21 12:18:01 -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
Nicolas Dufresne
7df99f7469 v4l2videodec: Handle flush while in start_streaming
We need to handle the case where a flush occure while the streaming
thread is being brought up. In this case, the flushing state of the poll
object is cleared. To solve this, we simply set the capture poll to flushing
again, this way we know the thread will exit. The decoder streamlock
is used to synchronize with handle frame.
2014-05-16 21:49:00 -04:00
Nicolas Dufresne
58716e054f v4l2allocator: Don't trace twice the same message 2014-05-16 21:48:29 -04:00
Nicolas Dufresne
077fcbcf15 v4l2: Cleanup M2M properties
M2M devices were sharing the same properties as src and sink. Most of
these made no sense. This patch reduces the number of propeties and
makes io-mode clearer by having capture-io-mode and output-io-mode. This
also accidently fixed a bug in gstv4l2transform io-mode code, where the
capture io-mode could not be set.

https://bugzilla.gnome.org/show_bug.cgi?id=729591
2014-05-15 19:06:52 -04: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
541a9670d2 v4l2videodec: Handle start_streaming error
https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:22:04 -04:00
Nicolas Dufresne
bff156bc57 v4l2videodec: Print the flow return causing the loop to leave
https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:21:59 -04:00
Nicolas Dufresne
f384047be3 v4l2videodec: Don't lock the decoder when stopping task
That src pad task may need to take the lock when being pulled
down. takeing that lock can lead to a deadlock.

https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:21:54 -04:00
Nicolas Dufresne
5f10d2b4e2 v4l2transform: Don't leak pool if activation failed
https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:21:48 -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
c1792de95e v4l2transform: Flush buffer pools on flush stop
https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:21:40 -04:00
Nicolas Dufresne
7986c55dcb v4l2allocator: Fix use of atomic active marker
https://bugzilla.gnome.org/show_bug.cgi?id=730207
2014-05-15 12:21:35 -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
cff050884c v4l2object: Fix regression in offset extrapolation
When extrapolating the offset, we need to use the extrapolate
stride rather then the base stride. This should fix support for format
with more then two planes (I420, Y42B, etc).
2014-05-13 13:44:20 -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
Tim-Philipp Müller
2e5daf15e7 v4l2src: minor GValue handling optimisation in probing code 2014-05-12 17:23:19 +01:00
Tim-Philipp Müller
f63bdd0483 v4l2src: avoid lists with one single framerate in probed caps
Simplify framerate field if possible, so we don't end up with
e.g. framerate = (fraction) { 30/1 }. Maybe the helper function
should be moved to core, but we can do this later.
2014-05-12 17:21:43 +01:00
Nicolas Dufresne
a270dc79d9 v4l2transform: Fix NULL check copy paste error
CID 1212129
2014-05-09 12:14:23 -04:00
Nicolas Dufresne
bf1918481d v4l2transform: Fix potential deadlock due to missing break
CID 1212131
2014-05-09 12:12:12 -04:00
Nicolas Dufresne
e45b1fd9e6 v4l2object: Don't leak config structure
this fixes a leak of the config structure and take care of making sure
caps can't reach ref 0 before we are done doing our check.

CID 1212144
2014-05-09 12:10:04 -04:00
Nicolas Dufresne
5284aca559 v4l2object: Remove uneeded cast for code clarity 2014-05-09 12:08:11 -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
68953d8026 v4l2object: Fix use of unitilized pool pointer
CID #1212173
2014-05-09 11:52:11 -04:00
Nicolas Dufresne
ab465bd162 v4l2object: Readback pool config if used within the baseclass 2014-05-08 15:56:37 -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
3e4ed47956 v4l2object: Style fix 2014-05-08 15:56:37 -04:00
Nicolas Dufresne
dfdd1ba9d9 v4l2allocator: Reset imported buffer size with expected size
This ensure that the buffer pool won't always discard buffer with these
memory when they are released.
2014-05-08 15:56:37 -04:00
Nicolas Dufresne
1304c74c6a v4l2allocator: Reset flushed group
This ensure that a flushed group memory are the same size as when they
where originally allocated / imported.
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
7aed4a9806 v4l2allocator: Add a method to read number of allocated group 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
01feadc2e7 v4l2transform: Initilialize debug category 2014-05-08 15:56:37 -04:00
Nicolas Dufresne
b2dab42ce8 v4l2allocator: Fix libv4l2 support
Need to include config.h, otherwise we endup directly using the
ioct/mmap/munmap calls and need to vall v4l2_munmap.
2014-05-08 15:56:37 -04:00
Nicolas Dufresne
428d63c2e5 v4l2allocator: Set the flags on the object
We where not setting the probed flags on the allocator, which mean even if
CREATE_BUFS was supported on some driver, it would endup being ignored.
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
a946a7cde6 v4l2allocator: There is not group on error 2014-05-08 15:56:37 -04:00
Nicolas Dufresne
6f5edb3b4b v4l2transform: Handle FLUSH_STOP event 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
deb40de4b8 v4l2transform: Add more traces 2014-05-08 15:56:37 -04:00
Nicolas Dufresne
74a64be001 v4l2-allocator: Add S to REQBUFS/CREATE_BUFS enum
All enum that has REQBUFS and CREATE_BUFS where missing S, which was
confusing since they are supposed to match with associcated ioctl name. This
also fixes the yet unused CAN_REQUEST flag check.
2014-05-08 15:56:37 -04:00
Nicolas Dufresne
3500e44f17 v4l2transform: Enabled QoS 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
7f8eff7845 v4l2object: Improve selecton of min/max in decide allocation 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
a114a32d22 v4l2allocator: Valid FD are bigger or equal to zero 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
d3383f9d4c v4l2object: Don't leak downstream pool in propose_allocation
parse_nth_allocation_pool() give a ref on the pool, we need to unref it
when done.
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
7b00d7ac46 v4l2allocator: Guaranty queued state integrety
Because of the buf in videobuf2, dqbuf may leave the DONE flag being,
which would implied that the buffer is queued. As this has been broken
for 4 years, simply guaranty the state flags integrity when doing
qbuf/dqbuf.

See https://patchwork.linuxtv.org/patch/23641/
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
783417ee9f v4l2transform: Implement open/close 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
23e273acb2 v4l2transform: Ensure output pool is configured 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
026f79b5bd v4l2transform: Check if caps have changes before asserting
In set_caps, now checks if caps actually changed and succeed if they didn't
change.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
a89986ebd5 v4l2videodec: Ensure pool is configured 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
83f053e980 v4l2object: Always set a size when deciding allocation 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
acebdd86da v4l2object: Improved decide allocation
Improve decide allocation so it properly configure both local and downstream
buffer pools. Also read back the pool config if it was changed to to driver
limitations.
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
db3d2f35f0 v4l2bufferpool: Early catch short allocation
Catch short allocation after saving the format. This is not a catch all, but should catch
most of the miss-behaving drivers when doing S_FMT/G_FMT and avoid potential crash.
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
fd13e9e96d Implement V4l2 Allocator
This goal of this allocator is mainly to allow tracking the memory.
Currently, when a buffer memory has been modified, the buffer and it's
memory is disposed and lost until the stream is restarted.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
1b4561cf35 v4l2object: Don't advertise crop meta
Currently we advertise crop meta, but not element handle support this meta.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
a721e54922 v4l2object: Setup pool already send element error 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
409cccb477 v4l2object: Workaround decoder that set num_planes to 0 in the format
Some well known decoder wrongly set num_planes to 0 in their format instead of
one. In this case we would endup with no size when deciding buffer allocation.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
46ffef798c v4l2object: Ensure size before configuring the pool 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
5a61fb7f25 v4l2object: Set minimum buffers to 2
All the element requires at least two buffers. This is not used for RW mode.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
3393083497 v4l2object: Remove unused MAX_BUFFERS define 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
8f6bd0dbc0 v4l2object: Don't hardcode min/max use default instead 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
f6d425bf0f v4l2transform: Install PROP_CAPTURE_IO_MODE with right ID 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
1635697f7e v4l2transform: decide_allocation returns a boolean 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
cf788c9ec7 v4l2videodec: Install PROP_CAPTURE_IO_MODE with right ID 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
527df8b888 v4l2transform: Add propose_allocation
This should remove 1 copy between the decoder and the transform.
2014-05-08 15:56:36 -04:00
Nicolas Dufresne
0488984f82 v4l2: Move propose allocation to v4l2object 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
f810196b3e v4l2transform: Fixup caps query 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
d4c24cc52f v4l2transform: Setup cropping if needed 2014-05-08 15:56:36 -04:00
Nicolas Dufresne
2676ac9075 v4l2transform: Expose BGRA and ARGB formats 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
10b67e9913 v4l2transform: Ensure output pool is activated
That pool may be different then the internal pool.
2014-05-08 15:56:35 -04:00
Nicolas Dufresne
91efa79ed9 v4l2transform: Ensure internal buffer pools actication 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
7a4b076099 v4l2transform: Move subinstance subclass init near other init 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
6d5ffe8da2 v4l2transform: Stop stream before closing the devices. 2014-05-08 15:56:35 -04:00
Víctor Manuel Jáquez Leal
4f7ee5c130 v4l2transform: copy metdata 2014-05-08 15:56:35 -04:00
Nicolas Dufresne
b781156625 Implement GstV4l2Transform
Implement a v4l2 element that wraps HW video converters.
2014-05-08 15:56:35 -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