Commit Graph

1008 Commits

Author SHA1 Message Date
Stefan Agner edcab103da backend-rdp: disconnect and free peers on compositor shutdown
Properly disconnect and free all RDP peers on compositor shutdown.
This makes sure that all events are disabled, which should avoid
any race conditions with pending events.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2020-01-13 14:22:30 +00:00
Stefan Agner 163f26f520 backend-rdp: unregister events before shuting down compositor
Like the other backends we should unregister events before
shutting down the compositor.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2020-01-13 14:22:30 +00:00
Leandro Ribeiro db6b141bf0 backend-rdp: report a zero physical size to compositor
The RDP-backend is reporting a non-zero physical size
value, and there are some clients that get the resolution
in pixels directly from the physical size reported. This
leads to a resolution of 25.4 PPI (or 1px/1mm), which is too
small.

But there's no need for that. The physical size is reported
on enabling the output (in the case of RDP-backend we have
no information about it before this), and the resolution is
already set in this moment.

Report a zero physical size to compositor, what makes frontend
and clients use their default values and applications become
readable.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-12-17 12:52:57 -03:00
Emmanuel Gil Peyrot 1b3ad0993b backend-drm: Make boolean fields actually bool
Continues what dd8219b3fb started, also in
the DRM backend.
2019-12-11 19:33:20 +00:00
Emmanuel Gil Peyrot b2f54d9f17 backend-drm: Remove unused variable
Its last usage was removed in 31838bf17e.
2019-12-11 19:33:20 +00:00
Stefan Agner 723c6a1266 backend-drm: Define potentially missing aspect-ratio bit definitions
The aspect ratio definitions for 64:27 and 256:135 have been added with
libdrm 2.4.95. However, Weston currently depends on libdrm 2.4.89 or
higher. Define the definitions in Weston to support libdrm older than
2.4.95.

Fixes: #332
Fixes: 6093772f45 ("backend-drm: Use aspect-ratio bit definitions from libdrm")
Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-12-09 13:08:24 +00:00
Stefan Agner 0bb9447653 renderer: change all frame_signal emission to pass previous_damage
Commit adaf8c7410 ("renderer: change frame_signal emission to pass
previous_damage as data argument") missed updating all frame_signal
emissions. Later commit 2619bfe420 ("move frame_signal emission to
weston_output_repaint()") fixed this deficency along with moving the
location of the emission. Due to an issue of the location change, this
commit had to be reverted again.

This makes sure that the pixman as well as the GL renderer now also
emits the damage region instead of the Weston output.

Fixes: adaf8c7410 ("renderer: change frame_signal emission to pass previous_damage as data argument")
Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-12-09 13:32:07 +01:00
Leandro Ribeiro 2eee164f24 libweston: remove previous_damage from struct weston_output
The member previous_damage from struct weston_output is no longer necessary.
First, stop calling init, fini and copying output_damage to it. Then remove
it from struct weston_output.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-12-04 07:58:26 +00:00
Leandro Ribeiro 914c96c3d2 Revert "move frame_signal emission to weston_output_repaint()"
The emission of frame_signal has to happen before a flip, otherwise
glReadPixels() could read an old frame or even worse an uninitialized buffer.
So move frame_signal emission back to renderers.

This reverts commit 2619bfe420.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-12-03 12:31:53 -03:00
Daniel Stone 6093772f45 backend-drm: Use aspect-ratio bit definitions from libdrm
When the aspect-ratio-aware mode support was added to Weston, it was
done before the libdrm support was finalised and merged. Between it
being added to Weston and being merged, it changed to no longer provide
the offset for the bitmask.

Instead of using the mask and a compatible enum, if we update our
libdrm dependency, we can use the flag definitions directly from libdrm.

In 94e4068ba1, the libdrm dependency was bumped to 2.4.83, which
enabled us to remove a bunch of error-prone ifdefs by making atomic and
modifier support mandatory.

We determined in the discussion of !311 that it was safe to push the
dependency as high as 2.4.91, as that was what was available in major
distributions.

Bumping to 2.4.86 allows us to safely remove the ifdef and go with
upstream flags, as that was added in mesa/drm@0d889201d1.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-11-27 17:52:16 +00:00
Leandro Ribeiro e28e831211 screenshooter: get previous_damage from data argument instead of weston_output
Instead of getting previous_damage from the weston_output struct, get it from
the frame_signal data argument. This will make possible to remove
previous_damage from weston_output after we decide what to do with
output->previous_damage usage in DRM backend.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-11-27 13:47:09 -03:00
Leandro Ribeiro adaf8c7410 renderer: change frame_signal emission to pass previous_damage as data argument
This will make possible to users that are listening to frame_signal to get
previous_damage from the data parameter instead of using
output->previous_damage.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-11-27 13:47:09 -03:00
Leandro Ribeiro dd0d0b0df1 screenshooter: stop using frame_signal void *data parameter to get weston_output
Instead of getting weston_output from the frame_signal argument 'void *data',
add weston_output in the private data struct of the users that are listening
to frame_signal. With this change we are able to pass previous_damage as the
data argument.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-11-27 13:46:51 -03:00
Leandro Ribeiro 2619bfe420 move frame_signal emission to weston_output_repaint()
In order to remove duplication and make the code easier to follow, move
frame_signal emission from renderers to weston_output_repaint(). This should
have no observable effect.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-11-27 13:18:42 -03:00
Vivek Kasireddy 9e7e7fac37 gl-renderer: Add support for XYUV format (v2)
Accept XYUV dmabuf buffers that a client application such as
weston-simple-dmabuf-v4l might submit.

v2 (Daniel):
Add XYUV to yuv_formats array to have the compositor color convert
with a shader if GL_TEXTURE_EXTERNAL_OES does not work.

Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
2019-11-25 17:19:33 -08:00
Vivek Kasireddy ae3175780e gl-renderer: Replace EGL_*_WL macros with locally defined enums
Instead of using the EGL_*_WL macros imported from EGL headers,
start using enums that would be defined locally. This is needed as
there are limited number of macros defined in EGL headers and
adding new ones is not practically feasible when adding a new
texture type. (suggested by Daniel Stone)

Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
2019-11-25 17:13:06 -08:00
Marius Vlad d2dbcd3d7e weston-log-flight-rec: Fix useless comparison when displaying the
contents of the flight recorder

The overlap variable is sufficient to determine from where to start
displaying the contents of the ring buffer. Also redundant to verify
if the position in the buffer went over the maximum size.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-25 20:29:49 +00:00
Marius Vlad 0ba0b8e86f weston-log-flight-rec: Don't allow more than one flight recorder to be
created

Having a (single) global variable which others depend on it implies
having a single flight recorder present. Until we have a reason to
support multiple flight recorders limit the amount to a maximum of one.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-25 20:29:49 +00:00
Marius Vlad b1f5f8076a weston-log-flight-rec: Add a global variable to access the ring buffer
With it add also a function which can be used in an assert()-like
situation to display the contents of the ring buffer. Within gdb
this call also be called if the program is loaded/still loaded into
memory.

The global variable will be used in a later patch to be accessed from a
python gdb script.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-25 20:29:49 +00:00
Pekka Paalanen 531b61c14a libweston: do not include weston.h
Libweston is not allowed to depend on Weston. Fortunately this include is
unnecessary and can be simply removed.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-25 13:11:56 +02:00
Leandro Ribeiro a2e80aca68 backend-drm: remove unnecessary ifdefs
Remove unnecessary ifdefs for DRM_MODE_CONNECTOR_DSI, DRM_MODE_CONNECTOR_DPI.
They are both provided by libdrm and were introduced long before 2.4.83 (the
lowest version we currently support).

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-11-23 13:15:59 -03:00
Leandro Ribeiro 6196b201be backend-drm: remove unecessary ifdef checks
Since commit 28d26483 ("build: bump libdrm requirement to newer version
(2.4.83)"), all supported libdrm versions provide modifier formats,
atomic API and blob formats. Remove ifdef checks (HAVE_DRM_ADDFB2_MODIFIERS,
HAVE_DRM_ATOMIC, HAVE_DRM_FORMATS_BLOB) to improve the code and make it
simpler.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
2019-11-23 09:57:52 +00:00
Marius Vlad 18462e8924 backend-drm: Further checks to skip plane assignment to HW planes
Mode change from mixed-mode to renderer-only means we should no longer
try to place views in HW planes (as we composite everything into the
primary plane) thus we should avoid that whenever that happens.

In the same time we need to be able to place in mixed-mode/renderer-only
mode the cursor view into the cursor plane (if one is available).

This patch adds a further check to skip plane assignment when disabling
overlay support (when we switch to renderer-only mode), when drivers do
not have atomic-modeset or it has been disabled intentionally.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-22 20:25:20 +02:00
Marius Vlad 48bc5efa7c backend-drm: Turn zpos duplicate check into an hard assert
This way we make sure we find out (if we have assigned invalid zpos
values) much faster.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-22 17:11:36 +02:00
Marius Vlad 788e80db77 backend-drm: Skip testing plane state if plane is not enabled
Adds a further assert() to make sure we're not checking against invalid
values. This was seen in the wild when the kernel rejects the commit for
overlay resulting in a check for invalid zpos values.

Fixes: #304

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-22 17:11:36 +02:00
Marius Vlad bd002b9884 backend-drm: Assign the primary plane the lowest zpos value
when switching to mixed-mode of compositing

This way we avoid an (incorrect) duplicate check of zpos values. Also,
this would be needed because the renderer needs have the lowest zpos value
available as we don't (yet) properly support underlays, the primary
plane serves as our renderer.

Adds also a check to see if we try to assign a view to a plane with
a lower zpos value than the one assigned to the primary when switching
to mixed-mode of compositing.

Fixes: #304

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-22 17:11:28 +02:00
Pekka Paalanen f696ee9337 libweston: allow double-loading modules
This is necessary for the test harness to be able to execute the compositor
multiple times in the same process. As we never unload opened modules, the
first compositor iteration will leave them all loaded and following compositor
iterations will then have them already loaded.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-21 16:32:55 +00:00
Pekka Paalanen 6ffbba3ac1 Use weston_compositor_add_destroy_listener_once() in plugins
This introduces a new convention of checking through the compositor destroy
listener if the plugin is already initialized. If the plugin is already
initialized, then the plugin entry function succeeds as a no-op. This makes it
safe to load the same plugin multiple times in a running compositor.

Currently module loading functions return failure if a plugin is already
loaded, but that will change in the future. Therefore we need this other method
of ensuring we do not double-initialize a plugin which would lead to list
corruptions the very least.

All plugins are converted to use the new helper, except:
- those that do not have a destroy listener already, and
- hmi-controller which does the same open-coded as the common code pattern
  did not fit there.

Plugins should always have a compositor destroy listener registered since they
very least allocate a struct to hold their data. Hence omissions are
highlighted in code.

Backends do not need this because weston_compositor_load_backend() already
protects against double-init. GL-renderer does not export a standard module
init function so cannot be initialized the usual way and therefore is not
vulnerable to double-init.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-21 16:32:55 +00:00
Marius Vlad b8987056d4 renderer-gl: Display a solid shader color when direct-display is in use
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-21 14:07:54 +02:00
Marius Vlad 9ad82d5996 renderer-gl: Avoid retrieving the EGL image it direct_display flag was set
As we avoid importing the buffer in the GPU, when attaching the buffer
we'll not have a valid image to retrieve it from, and as such we'll
avoid touching and setting the surface state shader.

This adds also 'direct_display' to the surface state and with it, sets the
surface state 'direct_display' member whenever the imported buffer will
have the direct-display member set.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-21 14:07:54 +02:00
Marius Vlad 81bada58db backend-drm: Add dmabuf scan-out check for DRM-backend
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-21 14:07:54 +02:00
Marius Vlad 5a701547a4 libweston: Add the ability to determine if a dmabuf is scanout-capable
Adds a new callback 'can_scanout_dmabuf' in weston_backend, which
can be set by the back-end do determine if the buffer supplied can be
imported directly by KMS.

This patch adds a wrapper over it, 'weston_compositor_dmabuf_can_scanout'
which is called before importing the dmabuf in the GPU if the
direct_display dmabuf is being set. If that's true and the check
failed, we refuse to create a wl_buffer.

This patch avoids importing in the GPU.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-21 13:54:50 +02:00
Marius Vlad ebd10e512e libweston: Add weston-direct-display server side implementation
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-18 19:33:09 +02:00
Pekka Paalanen 69dcd23c60 libweston: drop a misleading dmabuf comment
This comment was added in 230f3b1bf8 with the
intent that if we had an information table about pixel formats (which we do
have today), we could implement more sanity checks like ensuring that width
pixels fit into stride.

Daniel Vetter said on #dri-devel IRC recently:

	< danvet> since userspace shouldn't look at stride for buffers with
	modifiers, only pass it around unchanged

I asked for clarification. It was expected that userspace would not do any kind
of sanity checks as modifiers could change everything.

Let's remove the misleading code comment so that people don't get the idea of
adding more well-intended but ill-advised sanity checks. If more checks are
added, they must take the modifier into account, which the existing checks do
not do.

After 5 years, it is far too late to remove our existing sanity checks, but we
can attempt to not cause any more damage that would restrict what people can do
in the kernel.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-14 16:31:33 +02:00
Eero Tamminen 58e99de1a8 Add include for missing symbols
Fixes: https://gitlab.freedesktop.org/wayland/weston/issues/303
2019-11-13 11:34:30 +00:00
Nicholas Niro 7aab746b3a backend-drm: Added support for legacy fd_import
This patch reenables the function drm_fb_get_from_dmabuf but with legacy
fd_import support for gbm/mesa < 17.1.
2019-11-12 13:01:02 -05:00
Nicholas Niro 56d1f4e7bc backend-drm: Fix for gbm modifiers when they are not available.
When the HAVE_GBM_MODIFIERS is unset, make the code drop back
to a single plane version like other places in the code.
2019-11-12 12:57:09 -05:00
Marius Vlad 28bb2da0ba backend-drm: Print whenever a view could not placed on the primary due to
invalid size

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 555bfaf617 backend-drm: Print whenever a view will reach the renderer region
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 36f11a53e1 backend-drm: Move plane's availability in drm_output_try_view_on_plane()
It makes much more sense to be there. It adds some additional drm_debug()
statements to provide reason for failing to place the view in the HW
plane. Makes the reason for failing more accurate.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad eef694547d backend-drm: Pass the drm_fb to each prepare_overlay/scanout_view functions
Avoids the need to retrieve the DRM framebuffer in each function and
re-uses the one got before constructing the zpos candidate list.

Takes another reference for the scanout as to live the state, like
there's one for the overlay bit.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 677e4598d9 backend-drm: Pass the plane to prepare_overlay_view
As we already have a potential plane available to use, pass it
over the _prepare_overlay_view instead of trying to find one
from the backend plane list.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 80a62e5873 backend-drm: Allow for views to reach overlays/underlays planes
In this manner we will allow views to reach the overlay (or underlays)
even if the damage tracking will detect that the new view will
occlude the view underneath it.

Renames occluded_region to planes_region, and uses occluded_region
to represent the region where we add each view's visible-and-opaque region.
Sprinkle some comments about each region.

Re-uses the view's clipped region to determine visible-and-opaque region
which is accumulated (for both renderer and HW planes cases) into
occluded_region. The current view's clipped_region is then checked against
occluded_region.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 26dcce06d7 backend-drm: Check pixel format before constructing the zpos candidate list
We can determine if the pixel format used by the clients buffer is
scan-out capable much sooner, so do it when constructing the zpos
candidate list. It also removes the checks in their respective
prepare_ functions.

Avoids the situation where we'd need to retrieve the DRM framebuffer each time
when checking the pixel format.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 3b13f56a1d backend-drm: Place pixel format checks for the cursor plane in its own
function

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 4eeb402553 backend-drm: Place pixel format checks for the overlay plane in its own
function

The idea is to place pixel the format checks in a common part and until
then, to make it available as a function so we can re-use easily.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 2538aaccc7 backend-drm: Construct a zpos candidate list of planes
In order to better optimize view assignment to HW planes, we construct
an intermediary zpos candidate list which is used aggregate all suitable
planes for handling scan-out capable client buffers.

We go over it twice: once to construct it and once to pick-and-choose a
suitable plane based its highest zpos position.

In order to maintain the view order correctly we track current zpos
value being applied to the plane state and use it when trying to place
a view into a plane.

Pass the computed zpos value to be applied to the plane state.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 47e3d1e481 libweston: Add a new helper to check if the view spawns the entire
output

Helpful to determine if the view can go through the scanout or not.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 5f6bee49ed libweston: Add a new helper weston_view_has_valid_buffer
Helper to determine if the buffer attached to the view is valid.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad e83e750183 backend-drm: Hard-code zpos values if HW doesn't exposes them
This is based on the assumption that overlays are in between cursor and
primary plane and it is required to be able to assign views to planes,
even if the driver doesn't not expose such property.

As we hard-code them as immutable the commit part would not need any
further modifications.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 3dea57a9d5 backend-drm: Add a helper to display plane type as a 'string'
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad cdd6fa2717 backend-drm: Add zpos DRM-property
Functional no change, as nobody makes use of it. Only apply the zpos
value if the zpos property is mutable (that is, zpos_max and zpos_min
are not the same).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-11 16:51:48 +00:00
Marius Vlad 1accffe053 backend-drm: Teach drm_property_info_populate() to retrieve range values
Useful for zpos range values.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-11-11 16:51:48 +00:00
Daniel Stone 2cb926c558 Revert "backend-drm: Teach drm_property_info_populate() to retrieve range values"
Due to an error in driving GitLab, this commit erroneously contained the
entirety of !267 (zpos support in the KMS backend) squashed into one
single commit, pushed into master.

In order to keep the history clean, this is being reverted; a rebased
version of !267 with the clear individual commits which were already
present will be applied in its place.

This reverts commit 95e3b0deae.
2019-11-11 16:48:54 +00:00
Marius Vlad 95e3b0deae backend-drm: Teach drm_property_info_populate() to retrieve range values
Useful for zpos range values.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-11-11 15:24:25 +00:00
Stefan Agner 04eebc7f07 weston-launch: use exec to ensure signal delivery
Use exec to make sure the direct child process of weston-launch is
weston. This makes sure that signal delivery (SIGINT/SIGTERM) is
properly forwarded to weston.

Fixes ff3230952a ("weston-launch: Run weston in the user login shell")
Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-11-09 00:56:06 +01:00
Stefan Agner a8b4ddaec2 weston-launch: show when a signal is sent to a child
In verbose mode, print when a signal is sent to the child process.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-11-09 00:50:10 +01:00
Marius Vlad f68ee07880 weston-log: Avoid prefix-matching the scope name when checking for a
pending subscription

It limits to scope name to an exact match.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-11-05 17:08:17 +02:00
Marius Vlad 3a2f829983 libweston: Init weston_output's 'destroy_signal' before timeline has a chance to emit a
timeline subscription

When subscribing over the command line to the 'timeline' scope we hit
the situation where we could emit a timeline message but without the
weston_output object being (fully) enabled.  The timeline subscription
object requires to install its own callback on the 'destroy_signal' but
at that time, the 'destroy_signal' is not initialized.

This moves 'destroy_signal' initialization before timeline has a chance
to emit a timeline subscription message for that weston_output.

While at it, move also 'frame_signal' initialization before any function
call to keep them nicely organized.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-11-05 13:58:36 +02:00
Sebastian Wick abec512883 input: use ro_anonymous_file to minimize duplication of keymap files
Since version 7 clients must use MAP_PRIVATE to map the keymap fd so we
can use memfd_create in os_ro_anonymous_file_get_ref using
RO_ANONYMOUS_FILE_MAPMODE_PRIVATE, for older version we use
RO_ANONYMOUS_FILE_MAPMODE_SHARED to be compatibile with MAP_SHARED.

Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net>
2019-11-04 15:10:05 +01:00
Sebastian Wick da50a2a532 input: bump wl_seat version to 7
Version 7 only restricts how the client can mmap the keymap fd so
bumping this is safe.

Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net>
2019-11-04 15:10:05 +01:00
Sebastian Wick fcc6ff74d4 input: bump wl_seat version to 6
New in version 6 are touch shape, touch orientation and axis source
wheel tilt. Weston doesn't support any of them yet but simply not
sending the new events and new enum value is sufficient to claim to
support this version.

Also bump the Wayland requirement to 1.17 to ensure both version 6 and 7
definitions are in the XML.

The reason for bumping to v6 without implementing the new features is
that we must support v7 to make use of struct ro_anonymous_file
introduced in the previous commit.

Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net>
2019-11-04 15:10:04 +01:00
Stefan Agner ccf24076dd backend-drm: make GBM optional
Make GBM optional in case GL renderer is disabled. This allows to
build Weston with DRM backend without Mesa dependencies.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-10-25 15:32:07 +02:00
Stefan Agner 3654c673f8 backend-drm: separate out DRM virtual support
Move DRM virtual support into a separate file. Use the remoting
compile time option to disable DRM virtual support since this is the
only user of DRM virtual support currently. This will make it easier
to build the DRM backend without GBM support.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-10-25 15:32:07 +02:00
Stefan Agner 4a18f30225 backend-drm: use DRM_ constants everywhere
Use DRM_ constants for pixel formats in all cases.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-10-25 14:30:40 +02:00
Pekka Paalanen d1ace4c97f backend-rdp: work around unresolved symbols
This is preparation for disallowing unresolved symbols project-wide.

This is a temporary fix that should be reverted and fixed properly later.

/usr/bin/ld: libweston/backend-rdp/13a5658@@rdp-backend@sha/rdp.c.o: in function `rdp_peer_context_new':
/home/pq/build/weston-meson/../../git/weston/libweston/backend-rdp/rdp.c:748: undefined reference to `Stream_New'
/usr/bin/ld: libweston/backend-rdp/13a5658@@rdp-backend@sha/rdp.c.o: in function `rdp_peer_context_free':
/home/pq/build/weston-meson/../../git/weston/libweston/backend-rdp/rdp.c:781: undefined reference to `Stream_Free'
/usr/bin/ld: libweston/backend-rdp/13a5658@@rdp-backend@sha/rdp.c.o: in function `xf_input_keyboard_event':
/home/pq/build/weston-meson/../../git/weston/libweston/backend-rdp/rdp.c:1220: undefined reference to `GetVirtualKeyCodeFromVirtualScanCode'
/usr/bin/ld: /home/pq/build/weston-meson/../../git/weston/libweston/backend-rdp/rdp.c:1224: undefined reference to `GetKeycodeFromVirtualKeyCode'
/usr/bin/ld: libweston/backend-rdp/13a5658@@rdp-backend@sha/rdp.c.o: in function `weston_backend_init':
/home/pq/build/weston-meson/../../git/weston/libweston/backend-rdp/rdp.c:1469: undefined reference to `winpr_InitializeSSL'

See also #262

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:40:51 +03:00
Pekka Paalanen 9adfe7b91c build: reduce sub-dependencies of libweston
Make the libweston dependency objects pull in only those secondary dependencies
that are actually used in the API. This way in-tree users of libweston link to
fewer libraries needlessly, and it matches better what external users get via
pkg-config.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:29:33 +03:00
Pekka Paalanen 20b092d8b4 backend-x11: need libdrm headers in build
9ddb3bc315 started using drm_fourcc.h but forgot
to add libdrm headers to the dependencies.

This fixes the build for build-native-meson-no-gl-renderer when a future patch
reduces the dependencies pulled in by the libweston dependency object.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:29:33 +03:00
Pekka Paalanen d2332b8bba build: link libdl explicitly to DRM backend
In the future libweston will stop providing it for its users, since it's not
part of libweston API.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:29:33 +03:00
Pekka Paalanen 5e734ba308 build: link libm explicitly
In the future libweston will stop providing it for its users, since it's not
part of libweston API.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:29:33 +03:00
Pekka Paalanen 71ff95a544 build: separate deps for int and ext libweston users
We have two kinds of libweston users: internal and external. Weston, the
frontend, counts as an external user, and should not have access to libweston
private headers. The shell plugins are external users as well, because we
intend people to be able to write them. Renderers, backends, and some plugins
are internal users who will need access to private headers.

Create two different Meson dependency objects, one for each kind.

This makes it less likely to accidentally use a private header.

Screen-share is a Weston plugin and therefore counts as an external user, but
it needs the backend API to deliver input. Until we are comfortable exposing
public API for that purpose, let it use internal headers.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-24 13:29:33 +03:00
Stefan Agner 70e6356415 backend-headless: fix build issue without gl-renderer
If the gl-renderer is disabled build fails with:
  ../libweston/backend-headless/headless.c:394:9: error:
  ‘EGL_PLATFORM_SURFACELESS_MESA’ undeclared (first use in this function)

Fix this by including shared/weston-egl-ext.h.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-10-24 09:09:33 +00:00
Marius Vlad 23d01c67a3 doc/sphinx: Add some documentation about timeline points
Use doxygen ingroup command as to show the symbols in the sphinx
documentation.

Include some basic comments and document the exported functions from
timeline.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 21:42:25 +03:00
Marius Vlad 5de9297df2 libweston: Notify timeline of object modification
We notify the timeline of the fact that the object suffered
modifications through the 'set_label' function. Remove the old
refresh variable.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 21:42:25 +03:00
Marius Vlad 3203ff68ad libweston: Convert timeline points to use the timeline scope
With the timeline scope being created it is time to convert TL_POINT()
to use the timeline scope through the compositor instance.

This patch removes the global variable allowing to run the new timeline
code.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 21:42:25 +03:00
Marius Vlad da104ebe5b libweston: Create the 'timeline' scope
With everything now in place, it is time to create the timeline scope.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 21:42:25 +03:00
Marius Vlad fb10ed768b libweston: Introduce timeline subscription and timeline subscription object
An object based on 'weston_timeline_subscription' will be created for
each subscription created. It contains the next object ID and list of
'weston_timeline_subscription_object'.

It will automatically be cleaned by the logging framework when the
subscription gets destroyed, or use the object destroy signal to trigger
the destruction of the timeline subscription (@pq), when the object
itself is being destroyed.

This class will hanged-off the subscription, such that we can
retrieve it when going over all the subscriptions.

An object based on 'weston_timeline_subscription_object' will help
maintain the state of the objects seen and will be created when a new
object will be emitted for a particular 'weston_timeline_subscription'.

Adds wrappers for ensuring the timeline subscription object is created
or has to be searched in order to be found, as to avoid duplicated code.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-10-17 21:41:09 +03:00
Marius Vlad 2a1b7865dd libweston: Clean-up timeline to make room for a new approach
With it this removes the parts responsible for creating the file,
timeline_log class, removes the debug key binding when creating the
compositor instace, keeping only what can be re-used.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 19:42:55 +03:00
Marius Vlad d0d89d0d5f weston-log: Add a subscription iterator
Helper to retrieve next available subscription as to avoid exposing the
subscription, which is an opaque (internal) class of the logging
framework.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-10-17 19:42:55 +03:00
Marius Vlad 410d0bc0b2 weston-log-internal: Allow to hang-off data over the subscription
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 19:42:55 +03:00
Marius Vlad 9bb1c3a3c2 weston-log: Add 'destroy_subscription' callback for the subscription
As 'new_subscription' can create additional objects, 'destroy_subscription'
will be needed when cleaning up.

As this requires a libweston_major bump (noticed by @pq), bump it up to
8.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
2019-10-17 19:42:55 +03:00
Marius Vlad 0c7beb0b67 weston-log: 'new_subscriber' is actually 'new_subscription'
The callback is executed when the subscription is created, so it doesn't
really have a proper name.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 19:42:54 +03:00
Marius Vlad 413cda58d6 libweston: Fix rename of weston_compositor_destroy() reference
Commit 284d5345ad introduced a new tear_down function for the
compositor, it seems we missed a comment reference for it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-10-17 19:42:54 +03:00
Adam Jackson 3c3f3b1cc3 libweston: Fix integer underflow in weston_layer_mask_is_infinite
ubsan doesn't like what we were doing here:

../libweston/compositor.c:3021:21: runtime error: signed integer overflow: -2147483648 + -1 cannot be represented in type 'int'

Rather than try to be clever in invoking weston_layer_set_mask, just build the
maximal mask explicitly.
2019-10-16 16:02:59 -04:00
Loïc Yhuel 267b16e8f4 libweston: fix possible crash after a view is removed the layer
weston_compositor_build_view_list can reconstruct the view_list without a view which was
previously in it. The existing pointers in view->link are left unchanged, which could
lead to corruption or access to released memory in wl_list_remove, depending of the
order of destruction of the views.

This can happen at least with the black view created by the desktop shell for fullscreen
surfaces, when it is hidden in lower_fullscreen_layer.

Signed-off-by: Loïc Yhuel <loic.yhuel@softathome.com>
2019-10-16 14:10:35 +00:00
Pekka Paalanen 5104d7b2af headless, gl-renderer: support pbuffer outputs
Use the surfaceless platform in the headless backend to initialize the
GL-renderer and create pbuffer outputs. This allows headless backend to use
GL-renderer, even hardware accelerated.

This paves way for exercising GL-renderer in CI and using the Weston test suite
to test hardware GL ES implementations.

Relates to: https://gitlab.freedesktop.org/wayland/weston/issues/278

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen 209187491b noop-renderer: zero-initialize struct
This ensures that all function pointers we do not fill in will be NULL.

I had a crash in the Xwayland test with
https://gitlab.freedesktop.org/wayland/weston/merge_requests/274 without this,
because import_dmabuf was garbage.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen ecdf50d38e gl-renderer: add EGL surfaceless platform support
This allows passing EGL_PLATFORM_SURFACELESS_MESA to
gl_renderer_display_create(). It is not useful on its own, because the
surfaceless platform has no window surfaces.

This feature will be used by the headless backend.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen 53b7fd70b8 gl-renderer: document output_window_create
Even if it is internal, it is a non-trivial interface and deserves
documentation.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen 0010f8380a gl-renderer: document display_create
Some of this is a little convoluted to figure out from the code.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Pekka Paalanen 411a7cfe67 gl-renderer: display_create needs surface type
In case the base EGLConfig is needed, gl_renderer_display_create() needs to
know it should use EGL_WINDOW_BIT or EGL_PBUFFER_BIT.

The PBUFFER case is added for when the headless backend will grow GL-renderer
support.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-11 12:16:35 +00:00
Stefan Agner 24756a8965 backend-rdp: don't use shadow buffer for the RDP backend
Since the RDP backend allocates regular memory already as hw buffer
anyway, a shadow buffer is not required. The read_pixels interface
anyway renders directly into the hardware buffer, hence this does
not make a performance difference in practise. It avoids allocating
an unnecessary buffer.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-10-09 21:44:58 +00:00
Pekka Paalanen 4f5e360180 build: simplify include_directories
Define common_inc which includes both public_inc and the project root directory.
The project root directory will allow access to config.h and all the shared/
headers.

Replacing all custom '.', '..', '../..', '../shared' etc. include paths with
common_inc reduces clutter in the target definitions and enforces the common
 #include directive style, as e.g. including shared/ headers without the
subdirectory name no longer works.

Unfortunately this does not prevent one from using private libweston headers
with the usual include pattern for public headers.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 17:14:22 +03:00
Pekka Paalanen c232f8d934 Unify the include style of shared/ headers
When all shared/ headers are included in the same way, we can drop unnecessary
include seach paths from the compiler.

This include style was chosen because it is prevalent in the code base. Doing
anything different would have been a bigger patch.

This also means that we need to keep the project root directory in the include
search path, which means that one could accidentally include private headers
with

	#include "libweston/dbus.h"

or even

	#include <libweston/dbus.h>

IMO such problem is smaller than the churn caused by any of the alternatives,
and we should be able to catch those in review. We might even be able to catch
those with grep in CI if necessary.

The "bad" include style was found with:
$ for h in shared/*.h; do git grep -F $(basename $h); done | grep -vF '"shared/'

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 16:04:48 +03:00
Pekka Paalanen b6c7a3020c build: use dependency for matrix.c
matrix.c needs to be built differently for a test program vs. everything else,
so it cannot be in a helper lib. Instead, make a dependency object for it for
easy use which always gets all the paths correct automatically.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 15:55:55 +03:00
Pekka Paalanen 2f83c02e88 gl-renderer: use EGLConfig printer for window outputs
Replace the old config printer with the new fancy one: less duplicate code,
more details logged.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:18:11 +03:00
Pekka Paalanen f2aa6408ea gl-renderer: print detailed EGLConfig list
Print details of all available EGLConfigs in case none match what we are
looking for. This helps debugging.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:18:11 +03:00
Pekka Paalanen 6aadac7144 gl-renderer: improve get_egl_config errors
Listing exactly what we were looking for but did not find should help debugging
failures.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 7ba4c515a3 gl-renderer: prefer the base EGLConfig
If configless_context is not supported, we pick one EGLConfig as the "base
config" because we have just one GL context and different configs between the
context and EGLSurfaces might not work. Until now, we did not actually make
sure to pick the base config.

If the base config matches the requirements, prefer it. Only if it doesn't
match, go looking for another config.

This should give better chances of success on systems where configless_context
is not supported by relying less on eglChooseConfig().

Cc: Madhurkiran Harikrishnan <madhurkiran.harikrishnan@xilinx.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 88e5fcb55a gl-renderer: pbuffer config for non-surfaceless
If we don't have the surfaceless_context extension, we create a pbuffer as a
dummy surface to work with. If we also don't have configless_context, then it
is possible the config used for creating the context does not support pbuffers.
Therefore, if both conditions apply, we need to pick a config that supports
both window and pbuffer surfaces.

This makes the "base" config compatible, but it does not yet guarantee that we
actually pick it again when creating the pbuffer surface. Fixing that is
another patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 5d6d2b10af gl-renderer: configs for pbuffers too
Fold more code into the common config choosing, the pbuffer path this time.
Simplifies code and allows gl_renderer_get_egl_config() to grow smarter in the
future to guarantee config compatility in the absence of configless_context
extension.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 7cb7a6781f gl-renderer: remove EGLConfig attributes from API
Now that all backends pass in a list of acceptable DRM formats, that is used to
determine if the EGLConfig has an alpha channel or not. Therefore the
opaque_attribs and alpha_attribs are now useless, and we can remove the whole
config_attribs argument from the API.

gl_renderer_get_egl_config() uses an internal attrib list that matches at least
the union of the opaque_attribs and alpha_attribs matches.

Overall, behaviour should remain unchanged.

The new attribute array becomes variable in the future, so it is left
non-const.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 9ddb3bc315 backend-x11: use DRM formats for EGLConfig
Define a specific DRM format for the GL-renderer to render in. It goes through
fuzzy matching in egl-glue.c which ensures we get exactly the number of bits
for each channel, but does not require an exact format match.

This ensures we get the bit depth we expect instead of the first arbitrary
EGLConfig.

This should not change the current behaviour, because Mesa EGL takes care to
order the configs as apps expect.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen ed20b4d983 backend-wayland: use DRM formats for EGLConfig
Define a specific DRM format for the GL-renderer to render in. It goes through
fuzzy matching in egl-glue.c which ensures we get exactly the number of bits
for each channel, but does not require an exact format match.

This ensures we get the bit depth we expect instead of the first arbitrary
EGLConfig.

This should not change the current behaviour, because Mesa EGL takes care to
order the configs as apps expect.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 7cbafec8ae gl-renderer: fuzzy EGLConfig matching for non-GBM
Implement fuzzy EGLConfig pixel format matching, where we ensure that R, G, B
and A channels have the expected number of bits exactly. This is used on EGL
platforms where the EGLConfig native visual ID is not a DRM format code. On EGL
GBM platform, the old exact matching of native visual ID is kept.

As only the DRM backend uses a DRM format list for picking a config, this patch
should not change any behaviour.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen c01ba92eb2 gl-renderer: use pixel_format_info internally for EGL
Using arrays of pixel_format_info instead of just DRM format codes is useful
for fuzzy matching of formats with EGLConfigs in the future. The immediate
benefit is that we can easily print format names in log messages.

We should never deal with formats we don't have in our database, so discarding
unknown formats should be ok. Using unknown formats would become hard later,
too.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen abd3f3c3ea pixel-formats: add RGBA bits and type fields
These fields are necessary when looking for an EGLConfig matching a pixel
format, but the configs do not expose a native visual id. Such happens on the
EGL surfaceless platform where one does not actually care about the exact pixel
format, one just cares it has the right number of bits for each channel and the
right component type.

FP16 formats are coming, so this paves way for them too, allowing them to be
described.

The FIXED/FLOAT terminology comes from EGL_EXT_pixel_format_float.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen ad8c7448cd gl-renderer: do not even pick a config with configless_context
If configless context is supported, we can skip choosing the "base" config
completely as it will never be used.

This simplifies the code a little bit.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen d8e851899a gl-renderer: use gl_renderer_get_egl_config() for display_create
Replace a direct call to egl_choose_config() with a higher level function
gl_renderer_get_egl_config(). This will make follow-up work easier when
attribute lists will be generated inside gl_renderer_get_egl_config() instead
of passed in as is.

We explicitly replace visual_id with drm_formats, because that is what they
really are. Only the DRM backend passes in other than NULL/0, and if other
backends start caring about the actual pixel format, drm_format is the lingua
franca.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 8e42af02a6 gl_renderer: introduce gl_renderer_get_egl_config()
In an attempt to pull more of EGLConfig choosing into one place, refactor code
into the new gl_renderer_get_egl_config(). The purpose of this function is to
find an EGL config that not only satisfies the requested attributes and the
pixel formats if given but also makes sure the config is generally compatible
with the single GL context we have.

All this was already checked in gl_renderer_create_window_surface(), but
gl_renderer_create_pbuffer_surface() is still missing it. This patch is
preparation for fixing the pbuffer path.

We explicitly replace visual_id with drm_formats, because that is what they
really are. Only the DRM backend passes in other than NULL/0, and if other
backends start caring about the actual pixel format, drm_format is the lingua
franca.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Pekka Paalanen 5aaf8dc405 gl-renderer: move into egl-glue.c
Start a new source file for EGL glue stuff, for the EGL platform Weston runs
on. gl-renderer.c is getting too long, and I want to add even more boring code
(config pretty-printing etc.).

This pure code move, no changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 12:17:18 +03:00
Daniel Stone d7120032b0 renderer-gl: Assert function presence matches extensions
Some extensions (such as EGL_KHR_partial_update) add functions to EGL.
When the extension is present, GetProcAddress must return usable
function pointers for those entrypoints.

Assert that GetProcAddress returns a non-NULL function pointer in these
cases.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-10-02 11:53:31 +00:00
Adam Jackson 570490cef5 gl-renderer: Fix possible memory leak when no dmabuf modifers are supported
Some drivers support EGL_EXT_image_dma_buf_import_modifiers for format
enumeration, but don't have any modifiers. In this case, on platforms where
malloc(0) returns non-NULL, we would leak that allocation to the caller.

Handle this by noticing when the number of supported modifiers is 0 and
returning early.
2019-10-01 10:24:57 +00:00
Pekka Paalanen 8ba775d96d backend-drm: use format db for fallback too
Replace one more open-coded pixel format translation map with a call to our
central pixel format database, reducing duplication of format information.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-01 09:26:33 +00:00
Pekka Paalanen b766dbe3ac gl-renderer: remove print_egl_error_state
Nothing uses this, but the implementing function is used by gl-renderer
internally.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-01 09:17:10 +00:00
Pekka Paalanen 324e129172 gl-renderer: remove gl_renderer_output_surface
Nothing uses this.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-01 09:17:10 +00:00
Pekka Paalanen c504e83b72 gl-renderer: remove gl_renderer_display
Nothing uses this.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-01 09:17:10 +00:00
Pekka Paalanen 192ce0ae0b gl-renderer: remove platform_attribs
No caller ever used anything but NULL here, so just use NULL to simplify code.

In fact, no EGL platform defined today even defines any platform attributes
except the X11 platform for choosing a non-default SCREEN.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-01 09:17:10 +00:00
Pekka Paalanen b347edcc50 gl-renderer: fix typo native_window to native_display
It is a display, not a window.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-01 09:17:10 +00:00
Pekka Paalanen 7ad2871d75 gl_renderer: remove unused NO_EGL_PLATFORM
This became unused in:

commit e77f8ad79b
Author: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Date:   Wed Jun 8 17:39:37 2016 +0300

    compositor-fbdev: drop EGL support

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-01 09:17:10 +00:00
Pekka Paalanen e62f276a21 backend-headless: make renderer type an enum
Helps adding one more type.

No functional changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-09-19 15:56:06 +03:00
Pekka Paalanen e986de729d backend-headless: refactor into headless_output_disable_pixman
Pure refactoring. Preparing for adding GL-renderer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-09-19 15:56:06 +03:00
Pekka Paalanen 4b0688fd77 backend-headless: refactor into headless_output_enable_pixman
Pure refactoring. Preparing for adding GL-renderer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-09-19 15:56:06 +03:00
sichem b86eb201ba libweston: Bring back 'weston_output_move'
For supporting output layout, compositors need the ability to manually set the
'weston_output' by 'weston_output_move'.

Signed-off-by: sichem <sichem.zh@gmail.com>
2019-09-13 08:57:31 +00:00
Ankit Nautiyal fc2c180926 backend-drm: Check for HDCP Content Type property before setting
Currently, a check is missing for the case if the HDCP Content Type
property is requested, but is not supported by the driver.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-08-30 19:46:04 +05:30
Ankit Nautiyal 4fd38138fa libweston: Notify the client, when output recording is started/stopped
In case of enforced protection mode, the renderer takes care of
censoring the protected content when the output recording is going on.
But in case of relaxed protection mode, the client must be notified to
avoid showing the protected content, if the output recording is on.

This patch handles the case, where the content-protection is enabled
with relaxed protection mode, and notifies the client, whenever the
recording is started or stopped.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-08-26 16:18:22 +05:30
Harish Krupo 57d7883dd5 gl-renderer: Censor protected views when output is recorded
Contents on an ouput are captured when screenshooter/recorder/screen
sharing is enabled. In such cases the protected content must
be censored to ensure that it is not recorded along with unprotected
content. This is a required only when the surface protection is in
enforced mode.

Signed-off-by: Harish Krupo <harishkrupo@gmail.com>
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-08-26 16:18:22 +05:30
Ankit Nautiyal faa5ab4e7b libweston: Add function to schedule idle task for updating surface protection
Currently, the idle task for updating surface protection is scheduled
in case of change in the output mask of a surface or in case of change
in protection status of an output.
This patch adds a function for reusing the code to schedule the
idle-tasks, that can be called whenever there is a chance of a change
in the protection status of a surface.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-08-26 16:18:22 +05:30
Ankit Nautiyal 93dde245ee libweston: Add functions to modify disable_planes counter for an output
The member disable_planes of weston_output signifies the recording
status of the output, and is incremented and decremented from various
places. This patch provides helper functions to increment and decrement
the counter. These functions can then be used to do processing, before
and after the recording has started or stopped.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-08-26 16:18:22 +05:30
Ankit Nautiyal a344fe3245 backend-drm: Add support for content-protection
Currently drm-layer supports HDCP1.4 using connector property:
Content Protection. This property if available for a platform, can be
read and set for requesting content-protection.
Also, the patch series [1] adds HDCP2.2 support in drm, and patch [2]
adds support to send udev events for change in connector properties,
made by the kernel.

This patch adds these HDCP connector properties in weston, and exposes
the content-protection support to the client for drm-backend.

It adds the enums to represent 'Content Protection' and 'Content Type'
connector properties exposed by drm layer. It adds a member
'protection' in drm_output_state, to store the desired protection
from the weston_output in the drm-backend output-repaint cycle. This
is then used to write the HDCP connector properties for the drm_heads
attached to the drm_output.

The kernel sends uevents to the user-space for any change made by it
in the "Content Protection" connector property. No event is sent in
case of change in the property made by the user-space.
It means, when there is a change of the property value from "DESIRED"
to "ENABLE" i.e. successful authentication by the kernel, a uevent
will be generated, but in case of userspace requesting for disabling
the protection by writing "UNDESIRED" into the property, no uevent
will be generated.

This patch also adds support for handling new udev events for HDCP
connector property changes. Any such change, triggers change in the
weston_head's current_protection.

[1] https://patchwork.freedesktop.org/series/57233/#rev7
[2] https://patchwork.freedesktop.org/patch/303903/?series=57233&rev=7

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-08-26 16:18:22 +05:30
Daniel Stone d32dfcf833 backend-drm: Enforce content protection for hardware planes
62626cbfec ensures that the GL render will not render a view's content
to the screen when the surface has requested a higher content-protection
level than the output currently offers.

When the HDCP MR was split into the core content-protection support in !83
and specific DRM support for HDCP in !48 (not yet landed), this opened a
hole where the DRM backend could promote a view to a hardware plane,
even if the output offered a lower protection level than the surface
wanted to enforce.

In the DRM backend, check the desired protection level, and refuse to
promote the view to a hardware plane if the output does not offer
sufficient protection. This will lead to presentation falling back to
the renderer, which may censor the content, reduce quality, etc.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: 4b6e73d617 ("libweston: Add support to set content-protection for a weston_surface")
2019-08-23 20:51:43 +00:00
sichem ec8c876e82 make weston_binding_destroy public 2019-08-23 11:47:44 +00:00
Marius Vlad 843b238551 weston-log: Return bytes written for 'printf()' and 'vprintf()' functions
Information is needed for 'vlog()' and 'vlog_continue()' (others
depend on them).

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-08-19 12:40:42 +03:00
Emmanuel Gil Peyrot 45f5e536ec Fix a crash when closing an X11 window with a selection
This was caused by weston_wm_handle_xfixes_selection_notify() calling
weston_seat_set_selection() with a NULL source, apparently only
sometimes when closing an Xwayland window.
2019-08-15 14:03:48 +02:00
Alexandros Frantzis 3802241c46 libweston: Advertise minor version 2 of zwp_linux_explicit_synchronization_v1
Although we already supported minor version 2 of the explicit sync
protocol, we couldn't advertise it previously, since it was not in any
released version of wayland-protocols. With the release of
wayland-protocols 1.18, which includes minor version 2 of this protocol,
and the recent update in weston to require 1.18, we can now safely
advertise minor version 2.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
2019-08-02 15:00:08 +00:00
Stefan Agner da2e574ca9 pixman: avoid unnecessary y-flip for screen capture
Commit 4fc5dd0099 ("compositor: add capability CAPTURE_YFLIP")
introduced a capability flag which indicates whether y-flipping is
necessary. As already indicated in that commit message, it seems
that pixman flipps the y-axis only due to historic reasons.

Drop y-flipping and use the WESTON_CAP_CAPTURE_YFLIP flag to
indicate that y-flipping is not necessary. This simplifies code
and improves screen share performance (on my test by about 3% down
to 18% CPU load on the sharing instance of Weston).

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-08-01 08:19:15 +00:00
Marius Vlad 35ff4a8de5 libweston/log: Add 'wlog' group for weston_log() related functions
This allows a better integration with the documentation of logging
framework.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad 8b8b803a46 weston-log: Start adding documentation for the logging/debugging framework
Adds initial grouping for sphinx/breathe for the logging/debugging
framework. We add a few groups: log (public API), internal-log (private API,
not exported) and debug-protocol, specific to the weston
debug protocol.

In latest version of breathe, '\memberof' command is recognized as such.
But it conflicts with '\ingroup' command and can't be used in the same
time (leading to duplicate symbols), so we follow a simple rule: object
tagging with '\ingroup' then use '\memberof' command for the functions
that work on that object.

There's also a caveat here: we have objects that are private (opaque)
but the functions are public. For those cases we resort to using
'internal-log' for the object (class) and 'log' for the functions.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad 3d3ba9594e weston-log: Removed compositor_destroy_listener from the log context
Nobody is using it.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad 4e03629f44 libweston: Remove internal weston-log set-up function out of public header
We have dedicated header for the internal parts of the logging
framework, use that for the set-up part instead of the libweston public
API header.

Further more this removes weston_vlog() from public header as well and
moves them to weston-log-internal.h file.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad 3ee9d8e2d2 libweston: Put back weston_compositor_add_debug_binding() as public
The ability to install debug keybinds is useful so bring it back to the
public libweston API.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad 9c3804f8d5 weston-log-flight-rec: Introduce flight recorder stream
Like a black box in an airplane, the flight recorder can be used to
accumulate data and, when needed, to display its contents.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad ef4c268f68 weston-log: Remove weston_log() calls from weston-log
Avoids a potential dependency on the log scope being set-up before
actually creating the scope. Destroy part of the log context could
suffer from the same issue if the log scope is destroyed before.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad 284d5345ad compositor: Destroy the compositor before the log scope
Destroying the compositor after destroying the log scope will not print
out the messages in the tear down/clean-up phase of the compositor, so
add a new tear_down function which allows keeping a valid reference to
the compositor. This way we can destroy the compositor before destroying
the scope and keep the debug messages.

While at it remove the log context destroy part from the clean-up
of the compositor and make it stand on its own.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad 8b3ab3cd9b weston-log-file: Introduce file type of stream
With the logging infrastructure in place this patch add a new user: file
type of stream backed-up by a std file descriptor.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 13:34:04 +03:00
Marius Vlad dad882a12e weston-log: Rename scope's 'begin_cb' callback to 'new_subscriber'
Rather than using 'begin_cb' rename it to a more suitable name.

Further more instead of using the scope use the subscription to pass as
an argument. The source scope is attached to the subscription when
creating it so we can access it that way.

This also adds a _complete and a _printf method for the subscription
such that the callbacks can use to write data to only _that_
subscription and to close/complete it, otherwise writing to a scope
results in writing to all subscriptions for that scope which is not
correct.

In the same time, the scope counter-parts of _write and _complete will
now use the subscription function as well.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniels@collabora.com>
2019-07-18 13:32:23 +03:00
Marius Vlad 5ae0e621be weston-log/weston-log-wayland: Inline private subscription functions
This avoids duplicated bits, by calling the scopes's callback (if any)
and adding the subscription to the scope's subscription list. Further
more, the scope's name when creating the subscription is not needed so
removed that as well.

In mirror, also inline removing of subscription for scope's subscription
list. Fix a potential corner case when the user can request a
subscription to an invalid scope in stream_destroy().

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 10:49:39 +03:00
Marius Vlad 9f71a4ad85 weston-log: Introduce subscribe functionality
As described in e10c9f89826bb: "weston-debug: Introduce...", the
subscriber object need further functionality to make use of it.

Current form of the weston-debug protocol would not need this, as it
creates underneath a new subscriber each time a client connects and
subscriptions are created/destroyed automatically with the help of
wayland protocol. For other types of streams, we require to manually
create a subscriber and to subscribe to log scopes.

This patch introduces the ability to create subscriptions, and
implicitly to subscribe to (previously created) scopes.

In the event the scope(s) are not created we temporary store the
subscription as a pending one: a subscription for which a scope doesn't
exist at the time of the subscription. When the scope for which the
subscription has been created we take care to create the subscription as
well.

While at it the documentation bits are modified accommodate the subscribe
method and its further functionality.

Lastly, it removes an unlikely case when a scope is not created so we
avoid any kind of dandling (pending) subscription in case there is
subscription to it. We can only do something about in the destroy part
of the scope.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-07-18 10:49:39 +03:00
Marius Vlad c901e8913e weston-debug: Rename weston-debug to weston-log to better reflect its purpose
No changes in functionality have been made.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 10:49:39 +03:00
Marius Vlad 967a6c2d4e weston-log-wayland: Rename weston_debug_stream to weston_log_wayland
No changes in functionality have been made.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 10:49:39 +03:00
Marius Vlad 69e7571e63 weston-debug: Migrate weston_debug_stream to weston_log_wayland file
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 10:49:39 +03:00
Marius Vlad 8f329e25f7 weston-debug: Make it easier to separate weston_debug_stream
This way we can split easier weston_debug_stream into a separate file.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 10:49:39 +03:00
Marius Vlad 7814f301d1 weston-debug: Convert weston_debug_stream to use the subscriber base class
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-07-18 10:49:39 +03:00
Marius Vlad e0a858a5f2 weston-debug: Introduce weston_log_subscription and weston_log_subscriber objects
Adds a minimalistic API for managing the subscription object. The
subscribe functionality will be brought in once we re-organize a bit
weston-debug-stream and split it properly. It extends the logging
context with a linked list of potential subscription and adds a linked
list of subscriptions in the log scope.

This patch represents the start of a logging framework for weston. It's
being built around weston-debug, with the intent to superseded it, and
make weston-debug a client of the framework. Further more the logging
framework should replace current logging handler and allow other types
of streams to be used.

Currently present in libweston under weston-debug we have log scopes, debug
streams and a logging context.

With this patch, two (internal) objects are being added: the concept of
a subscriber and the concept of subscription.  The subscription object
is a ephemeral object, implicitly managed which is created each time one
would want to a subscribe to a scope. The scope will maintain a list of
subscriptions and will continue to be explicitly managed.

The streams will use the subscriber object as a base class to extend
upon. By doing so it allows to customize the stream with specific
functions that manipulate the underlaying storage. The subscriber object
will require a subscribe function and specific stream functions and like
the scope, will be explicitly managed.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-07-18 10:49:39 +03:00
Pekka Paalanen e48bfc7c0c libweston: Move 'struct weston_backend' to the internal backend header
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 5d649b611a libweston: Migrate functions that operate on 'weston_seat'
All 'notify_()*' belong in the private backend header file.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 63ef078ada libweston: Migrate functions that operate on 'weston_output' into backend header
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad e41c1bff11 libweston: Introduce backend.h
Introduce a new private header file that only internal backends are
allowed to use. Starts by migrating functions that operate on the
'struct weston_head'.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 0260fed3c7 libweston: Migrate what is left out the libweston public header
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad a9b69b4b2a libweston: Migrate content_protection from public header
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 3ff296e934 libweston: Migrate functions that perform various transformations
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 7e4f58faa3 libweston: Migrate functions that operate on 'weston_view'
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 4e1d0973f5 libweston: Migrate functions that operate on 'weston_spring'
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad f1a6594ad7 libweston: Migrate functions that operate on 'weston_surface'
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 9eb2064b85 libweston: Migrate functions that operate on input objects
This include 'weston_keyboard', 'weston_touch', 'weston_pointer' and
other released classes.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 0bf3f5ac2c libweston: Migrate functions that operate on 'weston_seat'
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 58cac08c22 libweston: Migrate functions that operate on 'weston_plane'
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 56f3a68a01 libweston: Migrate functions that operate on 'weston_compositor'
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad a72e3716e8 libweston: Introduce libweston-internal.h
Introduce a new private header file that only internal parts of the
library are allowed to use and shouldn't be exposed in the public header
of libweston.

Start by adding by adding functions that operate on the 'weston_buffer*'.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Marius Vlad 4d79283248 libweston: Migrate weston_environment_get_fd() to weston-launch header
This is private so it doesn't belong to public libweston API header.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2019-07-18 06:43:38 +00:00
Robert Beckett 49dc32013e backend-drm: dont emit sesion signal if already at same state
logind will send a device changed at start of day, prompting a session
active change, but the session will already be active from compositor
creation.

Avoid unnecessary signal emition and drm state invalidation.

The logind launcher sets the session active when the graphics device is
assigned to weston from systemd. Unfortunately 8d23ab78 didnt check whether the
session was already active before setting it active and emitting the session
active signal.
The handler for that signal then proceeds to invalidate the entire graphics
state, causing the next redraw to reconfigure all outputs (to the same routing
as they were already).
This then massively increases the likelihood of trying to configure a crtc that
has a commit already in flight.

Add the old behaviour of only emitting a signal on a changed state.
This avoids the issue for now by reducing the chances of a clash. Future
work will need to fix the issue properly (better handling of state_invalid e.g.
wait for quiescence, better monitoring for crtc usage clashes etc).

Signed-off-by: Robert Beckett <bob.beckett@collabora.com>
2019-07-18 06:35:41 +00:00
Robert Beckett c569bdc236 libweston: make session_active a bool
compositor->session_active should be a bool as it tracks a boolean
condition.

Signed-off-by: Robert Beckett <bob.beckett@collabora.com>
2019-07-18 06:35:41 +00:00
Antonio Borneo c90fccc256 backend-drm: fix race during system suspend
Depending on system loading, weston-launcher could drop the drm
master access before the compositor and all the clients receive
the notification. In this case, some commit could be sent to the
drm driver too late and get refused with error EACCES.
This error condition is not properly managed and causes weston to
hang.

Change the return type of start_repaint_loop() and repaint_flush()
from void to int, and return 0 on success or -1 if the repaint has
to be cancelled.
In the callers of start_repaint_loop() and repaint_flush() handle
the return value and cancel the repaint when needed.
In backend-drm detect the error EACCES and return -1.
Note: to keep the code cleaner, this change inverts the execution
order between weston_output_schedule_repaint_reset() and
repaint_cancel().

No need to wait for suspend or for any notification; in case the
weston reschedules a repaint, it will get EACCES again.
At resume, damage-all guarantees a complete repaint.

This fix is for atomic modeset only.
Legacy modeset suffers from similar problems, but it is not fixed
by this change. Since drm_pending_state_apply() never returns
error for legacy modeset, this change has no impact on legacy
modeset.

Signed-off-by: Antonio Borneo <antonio.borneo@st.com>
Fixes: https://gitlab.freedesktop.org/wayland/weston/issues/117
2019-07-12 17:16:52 +00:00
Daniel Stone 9c81224eb3 gl-renderer: Don't leak transformed region
Unfortunately, our y_invert helper also forgot to free the region it
transformed to. Clean up our allocation before we exit.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-07-12 17:00:32 +00:00
Daniel Stone 3ebd870487 gl-renderer: Account for offset in output region translation
In 55bcb93fef ("gl-renderer: Use helper for conversion to EGL rects"),
we extracted and lovingly commented the transformation from global to
output co-ordinate space used for EGL_KHR_swap_buffer_with_damage, into
a new helper function.

The commenting correctly noted the steps we need to perform the
transformation: shifting by the output's offset into global space,
followed by applying the output's scale and rotation transformations.

Unfortunately, the code did not live up to the high standards of the
comment, and forgot to translate by the output's offset. This meant that
for multiple outputs, we would probably end up with wildly out-of-bounds
co-ordinates.

Fix the code to first translate by the output's offset in global space,
ensuring that both our swap_buffers_with_damage, and our partial_update
co-ordinate sets, can spark joy for those blessed with more than one
output.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-07-12 17:00:32 +00:00
Stefan Agner 974390a5fa backend-drm: get handle in gbm specific code
Get GBM BO handle in GBM specific code. This allows to compile
drm_output_set_cursor without GBM.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-07-08 23:53:30 +02:00
Stefan Agner 5dd3e9996a backend-drm: drop gbm.h from c files
The header file is anyway included in drm-internal.h, we can safely
drop it from the c files.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-07-08 00:35:06 +02:00
Stefan Agner 0bfebebbdb compositor-drm: use DRM constants
The GBM and DRM constants have the same meaning. In preparation
to make the DRM backend compile without libgbm, prefer the DRM
constants where GBM is not needed.

Signed-off-by: Stefan Agner <stefan@agner.ch>
2019-07-08 00:30:44 +02:00
Harish Krupo 62626cbfec gl-renderer: Obscure protected content on unprotected display
The content protection protocol requires that in enforced mode, parts of the
surfaces which lie on outputs with protection level lower than that of the surface
be censored. This patch uses a solid shader to color such regions with
dark red.

Signed-off-by: Harish Krupo <harishkrupo@gmail.com>
2019-07-05 14:13:30 +05:30
Ankit Nautiyal 2844f8eaaf compositor: Enable HDCP for an output using weston.ini
This patch enables a user to opt for HDCP per output, by writing into
the output section of weston.ini configuration file. HDCP is always
enabled by default for the outputs.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-07-05 14:13:30 +05:30
Ankit Nautiyal f74c35b1f4 libweston: Notify client for change in content-protection status
The change in an output's content-protection may trigger a change in
the surface's content-protection status, and inturn the
content-protection available for the client.

This patch recomputes the content-protection level for a surface,
in case there is a change in content-protection level of an output,
showing the surface. In case of a change in the surface's
content-protection, the client associated with that surface is
notified.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-07-05 14:13:24 +05:30
Ankit Nautiyal 5cfe03c863 libweston: Add content-protection protocol implementation
This patch adds the content-protection protocol implementation, to
enable a weston client application to request for content-protection
for its content via HDCP.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-07-04 14:18:50 +05:30
Ankit Nautiyal 4b6e73d617 libweston: Add support to set content-protection for a weston_surface
The protection requested for a given surface, must reach through the
weston_surface::pending_state, in the commit-cycle for the
weston_surface, so that it gets updated in the next commit.

As some protection is requested for a given weston_surface, it means
protection must be set for each of the outputs which show the surface.

While setting the protection of a weston_output, care must be taken
so as to avoid, degrading the protection of another surfaces, enjoying
the protection. For this purpose, all the weston_surfaces that are
shown on a weston_output are checked for their desired protection.
The highest of all such desired protections must be set for the
weston_output to avoid degrading of existing protected surfaces.
A surface requesting protection for a lower content-type can still be
provided protection for a higher type but the converse cannot be
allowed.

This patch adds support to set content-protection for a suface, which
inturn sets the content-protection for each of the outputs on which
it is shown, provided, none of the existing surface's protection
request is downgraded.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-07-04 14:18:50 +05:30
Ankit Nautiyal 4f64ff8b2f libweston: Compute current protection for weston_output and weston_head
The actual protection status for a given weston_head depends upon the
corresponding drm_head's connector HDCP properties. On the other hand,
the actual protection for a weston_output is the minimum of the
protection status of its attached heads.
As a head's protection changes, the current protection of the output
to which the head is attached is recomputed.

This patch adds the support to keep track of the current
content-protection for heads and the outputs.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-07-04 14:18:50 +05:30
Ankit Nautiyal 2690a77088 libweston: Add support to set content-protection for a weston_output
For making an output secure, the content-protection should be set for
each of head attached to that output. So whenever the protection for
a weston_output is desired, it means that protection is desired for
each of the weston_head attached to that weston_output.

This patch introduces a new enum in libweston to represent the
requested/current protection statuses, equivalent to the type enum
defined by the weston-secure-output protocol. The new enum helps to
extend the content-protection status and requests to libweston and
the backends.
This patch also adds a new member desired_protection to store the
desired protection for an output in weston_output.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-07-04 14:18:50 +05:30
Roman Gilg e97391c49f compositor: Support xdg_output_unstable_v1
The xdg-output resources are listed in each head struct. They become idle when
the respective weston_output has been removed again. The client is supposed to
destroy them explicitly afterwards.

After starting an XWayland client xrandr displays the logical size as expected.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
2019-07-01 08:24:25 +00:00
Tomohito Esaki 29beeafde9 backend-drm: make linear modifier to default
Make the linear modifier to the default of DRM format modifiers if
supported modifiers isn't get from kernel driver.
2019-07-01 10:57:25 +09:00
Daniel Stone e404b72fd5 compositor-drm: Split assign_planes() into separate file
drm_assign_planes() is called to separate views out and decide what will
be taken out for plane composition and what will be left for the
renderer to compose.

It calls drm_output_propose_state() in order to find a good
configuration, which itself has a number of helpers that it calls. Break
these out into a separate file.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 23:08:36 +01:00
Daniel Stone 6b466f25af compositor-drm: Move state helpers to separate file
Most of the state helpers (create, destroy, duplicate, etc) state, are
relatively straightforward and can live in a separate file.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 23:08:36 +01:00
Daniel Stone 7580b3c09e compositor-drm: Move FB handling to a separate file
Move everything to do with creation, destruction, and reference handling
of drm_fbs to a new file.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 23:08:36 +01:00
Daniel Stone 4c2fc7058a compositor-drm: Move KMS API use to separate file
Create a new file which handles most of the actual KMS API use. This
covers the property handling (in which we map between KMS properties and
our internal representations), as well as actually applying state
through atomic modesetting or the legacy SetCrtc/PageFlip/DPMS APIs.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 23:08:36 +01:00
Daniel Stone fbe6c1db7b compositor-drm: Move mode handling to separate file
Create a new file for the DRM backend's handling of output modes, e.g.
resolution, aspect ratio, preferred mode selection, EDID parsing.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 23:08:36 +01:00
Daniel Stone 3448cfce0f compositor-drm: Pull EDID extraction into helper
Create a helper function which populates a drm_head with the information
extracted from its connector's EDID and any other properties we can
find, such as physical size and connection status.

This is currently quite small, but may become more complex in future as
we parse EDID better. It also prepares to move this function into
another file in the next commit.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 23:08:36 +01:00
Daniel Stone dd1bc50ba2 compositor-drm: Create header for backend internals
Create a new header called drm-internal.h, and move many of drm.c's
declarations and helpers to it.

This will allow us to split the DRM backend into multiple files.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 23:08:36 +01:00
Daniel Stone df2095fa35 gl-renderer: Support EGL_KHR_partial_update
partial_update is an EGL extension which allows us to inform the driver
ahead of time the limits of the areas we'll be writing to. This helps
performance for GPU hardware which renders into a local tile buffer:
informing the driver of the rendering extents means it can avoid
fetching unchanged tiles into the tile buffer and subsequently writing
them out.

The extension complements rather than replaces EGL_EXT_buffer_age (used
before partial_update to know which areas we need to update) and
EGL_KHR_swap_buffers_with_damage (used after partial_update to inform
the winsys of the changed region).

Note however that partial_update deals in buffer-damage regions ('what
has changed since the last time I used _this_ buffer?'), whereas
swap_buffers_with_damage deals in surface-damage regions ('what has
changed since the last time I rendered?'). An explanatory diagram can be
found in the specification:
https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_partial_update.txt

Fixes: #134

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 12:28:03 +01:00
Daniel Stone 0a86a81cc2 gl-renderer: Add EGL_EXT_partial_update query
Query for the extension itself and the core entrypoint.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 12:28:03 +01:00
Daniel Stone f1cecef2f8 gl-renderer: Demystify output repaint slightly
Add some comments in the function to make it clear what's going on,
especially as we twist and turn between a lot of things called 'damage'
meaning different things in different co-ordinate spaces.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 12:28:03 +01:00
Daniel Stone 30f5863756 gl-renderer: Rename buffer_damage variable
The buffer_damage variable stores accumulated damage from previous
frames. This is the area that, before considering our current repaint
request, we need to repaint in order to bring the older buffer up to
date with the last buffer we rendered into.

Rename to previous_damage so it's a bit more clear what this refers to.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 12:28:03 +01:00
Daniel Stone dad2f4046d gl-renderer: Rename border_damage variable
Technically it is storing which areas of the border are damaged.
However, we already have damage-region variables which need to be
translated by the border region. Rename the variable to not contain the
word 'damage' to reduce confusion.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 12:28:03 +01:00
Daniel Stone 55bcb93fef gl-renderer: Use helper for conversion to EGL rects
eglSwapBuffersWithDamage has to convert a damage region from Weston's
global co-ordinate space, into the co-ordinate space for EGL rendering
into a buffer for that output.

The conversion from the global co-ordinate space in logical pixels to
the output space in buffer pixels is slightly long and error-prone,
involving translating by the output's offset within the global
co-ordinate space, multiplying by output scale, and also translating to
allow for any borders we paint around the output.

After this is done, we need to flip the co-ordinates in the Y axis to
account for the lower-left-origin co-ordinate space used by EGL.

Since we want to reuse this for partial_update, but using a different
source region, extract this conversion into a well-commented helper we
can reuse.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-26 12:28:03 +01:00