Commit graph

66 commits

Author SHA1 Message Date
Nicolas Dufresne
f272ddf9c7 kmssink: Fix crash on NULL dmabuf allocator pointer
Now that we are doing lazy allocation, we may endup calling _stop()
before the allocator was created. As a side effect, we need to nul-check
the pointer before calling it's method (_clear_cache()).

https://bugzilla.gnome.org/show_bug.cgi?id=787593
2017-10-06 15:10:26 -04:00
U. Artie Eoff
ddba9e40f2 kms: Fix compilation error when libdrm < 2.4.68
DRM_RDWR was not defined until libdrm 2.4.68.  However,
in configure.ac we only require libdrm >= 2.4.55.

Seems silly to to bump minimum libdrm version for a simple
define.  Thus, define DRM_RDWR if it's not defined.

This fixes compilation error introduced in:

commit 922031b0f9
Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date:   Tue Sep 12 12:07:13 2017 -0400

    kms: Export DMABuf from Dumb buffer when possible

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

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2017-10-05 20:50:37 -04:00
Nicolas Dufresne
2057a36d04 kmsallocator: Update GstVideoInfo.size when extrapolating
When we guess the strides, we need to also update the GstVideoInfo.size
otherwise the memory size will be set to something smaller then needed.
This was causing crash with the DMABuf exportation, since we would not
mmap() a large enough buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=787593
2017-10-05 16:19:15 -04:00
Nicolas Dufresne
922031b0f9 kms: Export DMABuf from Dumb buffer when possible
https://bugzilla.gnome.org/show_bug.cgi?id=787593
2017-10-05 16:16:16 -04:00
Nicolas Dufresne
9d5a524547 kmssink: Move the mem cache into the allocator
No functional change, the cache will be later reused by the buffer
pool to keep track of the kmssink memory when exporting dmabuf.

https://bugzilla.gnome.org/show_bug.cgi?id=787593
2017-10-05 16:16:16 -04:00
Nicolas Dufresne
119294f3fc kmsbufferpool: Don't check allocator pointer twice
https://bugzilla.gnome.org/show_bug.cgi?id=787593
2017-10-05 16:16:16 -04:00
Nicolas Dufresne
0a25ca893d kmsbufferpool: Removed unused member fd
https://bugzilla.gnome.org/show_bug.cgi?id=787593
2017-10-05 16:16:16 -04:00
Nicolas Dufresne
045a91922c kmssink: Check if we can prime export
This will be used later to decide if a DMABuf allocator should be
exposed.

https://bugzilla.gnome.org/show_bug.cgi?id=787593
2017-10-05 16:16:16 -04:00
Nicolas Dufresne
ee021c0418 kmssink: Don't leak the dumb buffer on drain 2017-09-08 10:16:12 -04:00
Nicolas Dufresne
22ce257f1c kmssink: Don't assume buffer pool won't touch buf pointer
Just for extra safety, let's not assume that gst_buffer_pool_acquire()
won't ever touch the buf pointer.
2017-09-08 09:28:19 -04:00
Guillaume Desmottes
7e38fb5422 kms: fix crash if bo allocation failed when copying to dumb buffer
If bo allocation failed we destroy the buffer and return GST_FLOW_ERROR,
but the @buffer pointer was still pointing to the address of the
destroyed buffer. gst_kms_sink_copy_to_dumb_buffer() was then trying to
unref it when bailing out causing a crash.

Leave @buffer untouched if allocation failed to fix the crash.
Also remove the check on *buffer being not NULL as gst_buffer_new()
will abort if it failed.

https://bugzilla.gnome.org/show_bug.cgi?id=787442
2017-09-08 09:26:21 -04:00
Nicolas Dufresne
9b2e28d91d Request minimum buffer even if need_pool is FALSE
When tee is used, it will not request a pool, but still it wants to
know how many buffers are required.

https://bugzilla.gnome.org/show_bug.cgi?id=730758
2017-09-06 14:19:37 -04:00
Nicolas Dufresne
a5229c3098 kmssink: Add bus-id property
https://bugzilla.gnome.org/show_bug.cgi?id=786112
2017-08-11 09:32:08 -04:00
Nicolas Dufresne
b7b7948e5f kmssink: Free devname before setting it
This avoids leaking the devname if the property is set twice.
2017-08-09 15:00:17 -04:00
Nicolas Dufresne
1ec081f96d Revert "kmssink: support videooverlay interface"
This is causing hard failure for non-squared pixel. The fix isn't
trivial so taking offline by reverting.

This reverts commit db07f4507d.
2017-08-07 16:00:59 -04:00
Haihua Hu
db07f4507d kmssink: support videooverlay interface
Implement videooverlay interface in kmssink, divided into two cases:
when driver supports scale, then we do refresh in show_frame(); if
not, send a reconfigure event to upstream and re-negotiate, using the
new size.

https://bugzilla.gnome.org/show_bug.cgi?id=784599
2017-07-31 20:04:15 +02:00
Guillaume Desmottes
2d67189073 kmsallocator: add driver pitch support for planar formats
We used to to handle the driver pitch only for single plan video format.
Add support for multi planes format by re-using the extrapolate function
from the v4l2 element.
Also use this pitch to calculate the proper offsets.

Prevent DRM drivers to pick a slow path if the pitches/offsets don't
match the ones it reported.

https://bugzilla.gnome.org/show_bug.cgi?id=785029
2017-07-25 09:21:16 -04:00
Guillaume Desmottes
f9379b51b6 kmsallocator: inline gst_kms_allocator_alloc_empty()
No semantic change, just renamed the 'tmp' variable to a more meaningful
name and to use the same structure as in gst_kms_allocator_bo_alloc().

Needed as I'm going to move the gst_memory_init() call after the
allocation of the DUMB buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=785029
2017-07-25 09:21:16 -04:00
Víctor Manuel Jáquez Leal
c538942b0d kmssink: initialize variable
Otherwise clang complains:

gstkmssink.c:1192:7: warning: variable 'buf' is used uninitialized
whenever 'if' condition is true [-Wsometimes-uninitialized]
2017-07-10 13:32:49 +02:00
Nicolas Dufresne
0a0bc8ab94 kmssink: Track cached kmsmem and clear them on drain
In this patch we keep track of the cached kmsmem in a way
that we can clear the cache during the drain process. This
release the framebuffer before waiting for the next vblank,
hence add support for DRM driver (like Intel one) that release
the associated DMABuf reference asynchronously.

https://bugzilla.gnome.org/show_bug.cgi?id=782774
2017-07-07 14:36:38 -04:00
Nicolas Dufresne
98b91d09c2 kmssink: Move kmsmem cache code higher
This will be needed as this API will be used elsewhere to clear
the cache.

https://bugzilla.gnome.org/show_bug.cgi?id=782774
2017-07-07 14:36:38 -04:00
Nicolas Dufresne
b8c5a4c9ed kmssink: drop last rendered buffer on ALLOCATION and DRAIN queries
kmssink keeps a reference on the last rendered buffer. If this buffer
refers to an upstream buffer, it should be should be released on DRAIN
and ALLOCATION queries so all upstream buffers can be returned to the
pool if needed. As the buffer may be used for scanout, we copy this
buffer into a dumb buffer prior to let it go.

Based on patch from Guillaume Desmottes <guillaume.desmottes@collabora.com>

https://bugzilla.gnome.org/show_bug.cgi?id=782774
2017-07-07 14:36:38 -04:00
Nicolas Dufresne
cfadd5a936 kmssink: Don't leak GEM primed from DMABuf
This otherwise breaks DMABuf reclaiming. This is not visible from
userspace, but inside the kernel, the DRM driver will hold a ref to the
DMABuf object. With a V4L2 driver allocating those DMABuf, it then
prevent changing the resolution and re-allocation new buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=782774
2017-07-07 14:36:38 -04:00
Nicolas Dufresne
6e3fe4eaab kmssink: Factor out copying to dump buffer
This will be used to copy any upstream memory in order to return it on
resolution change, allocation query or drain query.

https://bugzilla.gnome.org/show_bug.cgi?id=782774
2017-07-07 14:36:38 -04:00
Guillaume Desmottes
d373c4478b kmssink: Add xilinx_drm to the list of drivers
This prevent having to set the driver-name explicitly when running on
Zynq UltraScale+ boards.

https://bugzilla.gnome.org/show_bug.cgi?id=783188
2017-06-05 12:56:03 +02:00
Sebastian Dröge
634cd87c76 gst: Clear floating flag in constructor of all GstObject subclasses that are not owned by any parent
https://bugzilla.gnome.org/show_bug.cgi?id=743062
2017-05-17 10:40:23 +03:00
Nicolas Dufresne
4261692187 Remove plugin specific static build option
Static and dynamic plugins now have the same interface. The standard
--enable-static/--enable-shared toggle are sufficient.
2017-05-16 14:05:52 -04:00
Nicolas Dufresne
99755badbe kmssink: Add msm to the list of drivers
This prevent having to set the driver-name explicitly when running on
Qualcomm/MSM boards.
2017-04-21 21:30:10 -04:00
Philipp Zabel
9ed9c14eb5 kmssink: if the plane can not scale, retry without scaling and remember
Retry the drmModeSetPlane call without scaling if the first try fails,
and remember not to scale anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=781188
2017-04-12 19:31:47 +02:00
Thibault Saunier
78022a6e0c docs: Port all docstring to gtk-doc markdown 2017-04-12 12:57:57 -03:00
Sebastian Dröge
40a2deef80 kmssink: Fix compiler warning with gcc 7
gstkmssink.c: In function ‘gst_kms_sink_get_input_buffer’:
gstkmssink.c:1102:29: error: ‘mems[0]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   kmsmem = (GstKMSMemory *) get_cached_kmsmem (mems[0]);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
2017-03-22 17:38:37 +02:00
George Kiagiadakis
4757ec8860 kmssink: adjust memory offset calculation for dmabuf buffers
The data in the dmabuf fd may not start from byte 0, therefore
we need to inform DRM about this additional offset.

https://bugzilla.gnome.org/show_bug.cgi?id=779790
2017-03-14 17:07:41 +02:00
Nicolas Dufresne
eb2dae8fd6 Rename plugin filesnames to match plugin names
- libgstgtksink.so -> libgstgtk.so
- libgstteletextdec.so -> libgstteletex.so
- libgstcamerabin2.so -> libgstcamerabin.so
- libgstonvif.so -> libgstrtponvif.so (meson only)
- sdp -> sdpelem (avoid clash with libgstsdp)
- gstsiren -> siren
- libgstkmssink.so -> libgstkms.so

https://bugzilla.gnome.org/show_bug.cgi?id=779344
2017-03-08 20:04:23 -05:00
Víctor Manuel Jáquez Leal
4b3baab40a kmssink: post error message if start() fails
It is expected to post an error message in the bus if the device cannot
be started.
2016-11-30 20:13:55 +01:00
Michael Tretter
649364b923 kmssink: configure display mode during set_caps
Configure the display mode when setting the negotiated caps instead of
during showing the first frame.

A framebuffer is required to set the mode. Allocate a buffer object
according to the negotiated caps and use it to set the mode. This buffer
object cannot be freed until another page flip happened on the crtc
(i.e., until the first frame is rendered).

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2016-11-30 20:13:55 +01:00
Michael Tretter
dff77fd15f kmssink: add parameter force-modesetting
The force-modesetting parameter forces the kmssink to ignore already
configured display modes, to configure the display mode itself and use
the base plane for output.

https://bugzilla.gnome.org/show_bug.cgi?id=773473
2016-11-30 20:13:55 +01:00
Michael Tretter
3d0c5dd58e kmssink: allow only supported resolutions
If the input buffers have a different size than the display, the frames
would have to be scaled or positioned on the display. The kmssink cannot
decide which behaviour would be appropriate for which use case.

In order to avoid scaling or positioning of the input stream, allow only
the supported connector resolutions in the sink caps.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2016-11-30 20:13:55 +01:00
Michael Tretter
ca96cc6083 kmssink: set mode based on framebuffer configuration
Displays usually support multiple modes. Therefore, the kmssink should
not only support the preferred mode, but any mode that is supported by
the display.

https://bugzilla.gnome.org/show_bug.cgi?id=773473
2016-11-30 20:13:55 +01:00
Michael Tretter
f52baadd1e kmssink: add mode setting and base plane rendering
The kmssink assumed that the mode was already set by another application
and used an overlay plane for displaying the frames.

Use the preferred mode of the monitor and render to the base plane if
the crtc does not have a valid mode.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2016-11-30 20:13:55 +01:00
Víctor Manuel Jáquez Leal
88dbae3ab9 kmssink: include drm.h after stdlib.h
As drm.h is internal to libdrm, it expects to have already included
stdlib.h.
2016-11-23 20:13:59 +01:00
Víctor Manuel Jáquez Leal
79cd4bb44b kms: include stdlib.h
drm.h does not include all what it needs to compile, in particular
stdlib.h which defines size_t
2016-11-23 19:44:49 +01:00
Michael Tretter
12e82aac28 kmssink: remove dependency on libkms
libkms should not be used, because it imposes limitations on the DRM
API, especially regarding bpp and stride. Instead the DRM IOCTL should
be used directly.

Switch from libkms to the IOCTL interface. Set bpp and height for
framebuffer allocation to properly handle planar video formats.

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

Signed-off-by: Víctor Jáquez <vjaquez@igalia.com>
2016-11-23 16:43:28 +01:00
Arun Raghavan
3e1a230337 kmssink: Trivial naming fix in meson for consistency 2016-11-14 23:11:11 +05:30
Arun Raghavan
9f6ffdf348 kmssink: Enable in meson build 2016-11-14 22:35:10 +05:30
Philipp Zabel
4f19d5d20a kmssink: do not get kms bo pitch for planar formats
The API is ill defined for planar formats in case of dumb BOs,
do not use the reported stride in those cases.

https://bugzilla.gnome.org/show_bug.cgi?id=773473
2016-11-10 15:57:24 +01:00
Michael Tretter
b52c39e1c7 kmssink: remove custom gst_kms_sink_get_times
The default get_times() function of the base sink is just fine.

Remove the custom get_times() function, because the default function
already reads the timestamps from the buffers.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>

https://bugzilla.gnome.org/show_bug.cgi?id=773473
2016-11-10 15:57:24 +01:00
Tim-Philipp Müller
bdcc9d1704 kms: rename variable used
Since this includes kms.
2016-11-04 09:27:06 +00:00
Nicolas Dufresne
753c423784 kmssink: Scale up to the screen dimension
In most display sink, the logic is to use as much as possible
of the given window. In this case, the window is the screen,
hence it's logical to scale up.

https://bugzilla.gnome.org/show_bug.cgi?id=767422
2016-09-08 13:23:35 -04:00
Nicolas Dufresne
37c670e235 kmssink: Fix selection of source region
The source region was scaled for display before being passed
to drmModeSetPlane, which resulted in a portion of the video
being cropped. While when crop meta was present, the rectangle
was not centered since we where using unscaled width/height.

https://bugzilla.gnome.org/show_bug.cgi?id=767422
2016-09-08 13:23:35 -04:00
Víctor Manuel Jáquez Leal
c117165f7b kmssink: override stride if defined in driver
Some kms drivers demands specific pitches over the ones calculated by
GstVideoInfo. For example, intel driver demands strides round up 64.

This patch queries the driver for the prefered pitch and overwrites it
in the pool's GstVideoInfo structure.

https://bugzilla.gnome.org/show_bug.cgi?id=768446
2016-09-07 16:18:48 +02:00