Commit Graph

6813 Commits

Author SHA1 Message Date
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 acf84fd29f xwm: dnd does not need cairo-util.h
Turns out dnd.c does not actually need cairo-util.h. This was found when
unifying the include directives of all shared/ headers. Removing this makes one
less place to fix.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 15:56:19 +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 03eacfa618 build: shells do not need matrix.c
Do not build matrix.c into the shell plugins. The matrix functions are exported
by libweston.so and the shell plugins links to it.

Found by inspection.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-10-04 15:53:29 +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
Adam Jackson 95efe82982 simple-dmabuf-egl: Allow QueryDmaBufModifiers to report no modifiers
Some drivers expose the extension so they can expose
eglQueryDmaBufFormatsEXT, but don't support any modifiers. Treat this the
same as if the extension wasn't present.
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
Miguel A. Vico 5c5f0272d9 compositor: Do not trigger invalid destructors when hotunplugging
When hotunplugging a display, the compositor will tear the top-level
wet_output object down, freeing its memory.

However, destruction of the backend output might be delayed in certain
situations (e.g. destroying DRM output while in the middle of a page
flip).

When the backend output is finally destroyed, it will trigger a
destruction callback previously added by the compositor, which point to
data belonging to the top-level wet_output object.

In order to avoid access to invalid data when the backend output is
destroyed after the top-level wet_output object, remove the destruction
callback from the corresponding list before freeing the object.

Signed-off-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
2019-09-25 13:25:39 -07:00
Miguel A. Vico 620f68dc4f desktop-shell: Avoid NULL output dereference when getting surface label
When hotunplugging a display, the compositor will tear down the
corresponding output object.

Avoid NULL output dereferences by all surface label getters in
desktop-shell when hotunplugging happens.

Signed-off-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
2019-09-25 13:25:39 -07:00
Pekka Paalanen 1ca4ed2015 clients: fix len-string formatting
All these have the printf format string wrong. "%*s" sets the field width but
does not limit the string to len bytes. You need to set precision instead to
limit to len bytes: "%.*s".

Found by grepping, after wondering why my WIP prints printed garbage at the
end.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2019-09-23 17:27:09 +03: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
Pekka Paalanen b984a158d6 backend-headless: fix comment on use_pixman
The default is no-op, not GL. It doesn't even support GL.

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 fbfcc304a4 man: Declare drm-backend support for HDCP
Modify weston.ini man page to update that drm-backend supports HDCP.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
2019-08-26 16:18:22 +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
Simon Ser 18e0cf85d6
build: reopen master for regular development 2019-08-24 00:14:35 +03:00
Simon Ser 3180fa8a12
build: bump to version 7.0.0 for the official release 2019-08-23 23:58:15 +03:00
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
Manuel Stoeckl 5f592c7855 weston-terminal: Ignore SIGPIPE
This ensures that the default signal action doesn't kill weston-terminal
when the terminal tries to paste into a pipe whose read end has already
been shut down. (For example, a pipe from a misconfigured program or from
one which crashes/exits before the terminal calls write().)

Signed-off-by: Manuel Stoeckl <code@mstoeckl.com>
2019-08-23 11:53:13 +00:00