This clarifies what is supposed to be the libweston code.
v2: screen-share.c is already in compositor/ instead.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
Acked-by: Benoit Gschwind <gschwind@gnu-log.net>
[Pekka: rebased]
At the moment only XRGB8888 is supported when using pixman renderer.
This patch adds support also for RGB565.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Backends do not have access to command line elements nor weston_config
anymore. They use the backend-specific config APIs now.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Instead add callbacks to the drm and fbdev backends and pass that to
the input backens so that when a new device needs to be configured
that is called and the compositor can configure it.
Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
When pixman is used and no connector could be found (or any other
error), drm_backend_create() tried to destroy a gbm_device that would
only be created in init_egl(), resulting in a segfault.
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
The current behaviour leaves the name empty, making it somewhat harder
to determine the characteristics of this mode from a debugger.
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
[Pekka: wrap long line (ybakos)]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Preparing for libweston and for the separation of the code base into
libweston vs. weston the compositor, we must remove all uses
weston_config structures from the backends. We have decided that all
option and config input happens in the compositor (main.c), and
configuration is passed in for the backends as structs.
Most other backends have already converted, and this patch converts the
DRM-backend to the libweston-style init API.
The libweston-style init API includes a header for each backend (here
compositor-drm.h) defining the configuration interface. The compositor
(main.c) prepares a configuration struct to be passed through libweston
core to the backend during initialization.
A complication with the DRM-backend is that outputs can be hotplugged,
and their configuration needs to be fetched from the compositor
(main.c). For this, the config struct contains a callback member. The
output configuration API is subject to change later, this is just a
temporary API to get libweston forward.
As weston_compositor's user_data was not previously used for anything,
and the output configuration callback needs data, the user_data is set
to the 'config' pointer. This pointer is only used in
drm_configure_output() in main.c.
[Bryce: lots of stuff and rebasing]
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
[Pekka: write commit message]
[Pekka: squash in "drm: Don't hang onto the backend config object
post-backend_init" from Bryce Harrington]
[Pekka: drop the compositor.h hunk]
[Pekka: do not #include inside extern "C"]
[Pekka: remove incorrect comment about weston_drm_backend_config
ownership.]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
In preparation for follow-on changes to support frame presentation
through EGLDevice+EGLOutput, this change includes the following:
- Rename drm_backend::format to gbm_format
- Rename drm_output::format to gbm_format
- Rename drm_output::surface to gbm_surface
- Rename drm_output::cursor_bo to gbm_cursor_bo
Signed-off-by: Miguel A Vico Moya <mvicomoya@nvidia.com>
Reviewed-by: Andy Ritger <aritger@nvidia.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
[Pekka: trivial rebase out of the series]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
current_mode is already the pointer, taking the address of it is wrong.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94562
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
[Pekka: rewrote the patch]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Remove the unstable presentation_timing.xml file, and use
presentation-time.xml from wayland-protocols instead to generate all the
Presentation extension bindings.
The following renames are done according to the XML changes:
- generated header includes
- enum constants and macros prefixed with WP_
- interface symbol names prefixed with wp_
- protocol API calls prefixed with wp_
Clients use wp_presentation_interface.name rather than hardcoding the
global interface name: presentation-shm, weston-info, presentation-test.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
[Pekka: updated wayland-protocols dependency to 1.2]
Keep XRGB apps out of the cursor plane, only ARGB is supported.
This prevents programs like weston-simple-shm from landing in the cursor
plane and being misrendered.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
When the cursor plane is disabled the kernel can lose its location.
If we don't update our internal idea of where the plane is at that time,
the next time we set a cursor it can show up at 0,0.
This can show up when an application is put in the cursor plane, removed
from the plane, then put back at the same location. It might show up at
0,0 when it's reinstated.
We now use INT32_MIN as a location for disabled cursors so enabling the
plane will always cause an update.
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Add a new boolean weston.ini option, "vt-switching" to enable or
disable Ctrl-Alt-Fn key combinations.
Signed-off-by: Bob Ham <bob.ham@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
(Derek Foreman changed the prototype for switch_vt_binding to
have a weston_keyboard * instead of weston_seat *. The pointer
wasn't used, so this is just a warning fix.)
This allows renderers to use that struct to create their own dmabufs,
in case they can’t import the one provided by the client directly but
know how to convert it into a format they can render.
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Differential Revision: https://phabricator.freedesktop.org/D332
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Fix a regression introduced by be428b3825
which accidentally removed the global-to-output space conversion.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Derek Foreman <derekf@osg.samsung.com>
Cc: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Derek Foreman <derekf@osg.samsung.com>
Make sure a view's transform is viable for a cursor plane and
then actually apply it before setting the cursor plane location.
Now if a subsurface ends up in the cursor plane, the plane will be
properly positioned.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
mmap() function expects to be passed a void pointer as the address
here. Passing NULL is technically more correct than passing 0.
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
commit e76f185 stopped using visuals with "native visual id" == 0
This broke some systems, so we now try 0 as a worst case fallback if
everything else has failed.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Add new configuration argument to the backend_init() function, which
will replace the current argc, argv, and config arguments.
After each backend is converted individually the unused parameters
will be removed.
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
In commit 70d337dfd we changed one cursor size test from a hard coded 64,64
to the actual device provided width, height.
The test in drm_assign_planes remained fixed at 64, 64.
The simple-shm test ended up being small enough to fit into a cursor plane
by one test, but too large by the test in drm_assign_planes. We'd assign
to the cursor plane but not keep a reference.
weston-simple-shm would disappear and be replaced with the previous
cursor image.
This partially "fixes" T3361.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
strncpy only adds null terminating bytes if the source string is smaller
than the destination string. Since this function relies on the string
being null terminated when checking its contents, we better make sure
there is at least a \0 as the last character.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
This reverts commit 6858383d51.
The main reason for the original patch was a regression on the Intel
drivers causing compositor framerate to drop to half during cursor
updates or motion. The Intel problem was fixed in
2e7f43c41c
The fix is included in Linux 4.1-rc6 and 4.0.5.
The comment in the original patch is still true, but arguably the
possible minor glitches with cursor updates are less bad than not using
cursor planes at all.
Cc: nerdopolis <bluescreen_avenger@verizon.net>
Cc: Daniel Stone <daniel@fooishbar.org>
Cc: Giulio Camuffo <giuliocamuffo@gmail.com>
Cc: David FORT <contact@hardening-consulting.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Tested-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Bumping libdrm requirement by 3 years just for output connector name
constants was a bit much. Fix the problem introduced in
89c49b3060 by conditionally using the new
additions.
Both VIRTUAL and DSI came in the same libdrm commit
566c3ce877a4be72697e15cdfc421ce965f7c37d, so we check only for DSI.
This patch also reverts faee330c5e.
Reported-by: Eugen Friedrich <friedrix@gmail.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Bryce Harrington <bryce@osg.samsung.com>
The problem with the old table of names is that it contains duplicates.
It is possible to end up with multiple outputs with the same name. In
that case you cannot write individual configurations for these outputs
in weston.ini, because they are matched by the name.
Change all names to follow the kernel naming scheme set in
drivers/gpu/drm/drm_crtc.c. The snprintf format now follows the kernel
style, too. Use the DRM_MODE_CONNECTOR_* macros rather than implicit
table ordering.
Completely new entries in the table are "Virtual" and "DSI".
There should not be any gaps in the macro values, but if there are, deal
with a NULL entry.
Also change "UNKNOWN" to "UNNAMED" so it's easier to distinguish from
"Unknown" by the kernel.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89361
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Tested-by: Drew DeVault <sir@cmpwn.com>
gl_renderer_output_create expects `window_for_legacy' variable to be of
type EGLNativeWindowType, not EGLNativeDisplayType. This variable is
used later in eglCreateWindowSurface().
Signed-off-by: Dawid Gajownik <gajownik@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
The buildbots discovered this issue on Ubuntu 14.04, which carries
libgbm 10.1.3-0ubuntu0.4. The dmabuf changes need gbm 10.2, so it fails
during build like this:
src/compositor-drm.c: In function ‘drm_output_prepare_overlay_view’:
src/compositor-drm.c:984:10: error: variable ‘gbm_dmabuf’ has
initializer but incomplete type
struct gbm_import_fd_data gbm_dmabuf = {
^
etc.
Proposed fix is to conditionalize the gbm fd import feature in
compositor-drm.
This fix was suggested by daniels. I set up a synthetic test
environment to reproduce the issue as found by the buildbots and tweaked
the patch to get it to build both with and without gbm 10.2.
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
v2:
- add TODO note about multi-planar import and how we should do it
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
v2 changes:
- only initialize linux_dmabuf if renderer supports it
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Keyboards and pointers aren't freed when devices are removed, so we should
really be testing keyboard_device_count and pointer_device_count in most
cases, not the actual pointers. Otherwise we end up with different
behaviour after removing a device than we had before it was inserted.
This commit renames the touch/keyboard/pointer pointers and adds helper
functions to get them that hide this complexity and return NULL when
*_device_count is 0.
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Normally we need to check if a seat's [device_type]_count is > 0 before
we can use the associated pointer. However, in a binding you're
guaranteed that the seat has a device of that type. If we pass in
that type instead of the seat, it's obvious we don't have to test it.
The bindings can still get the seat pointer via whatever->seat if they
need it.
This is preparation for a follow up patch that prevents direct access
to seat->device_type pointers, and this will save us a few tests at
that point.
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Cut a chunk of code out from drm_output_set_cursor() and form a new
function for writing a cursor bo data from a weston_view with a wl_shm
buffer.
Add more asserts to verify the assumptions in there.
v2: Use drm_compositor::cursor_{width,height} instead of hard-coded 64.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Instead of testing against a hardcoded 64x64 pixel size to see if a view
is suitable for promotion to a cursor plane, use our cursor_width and
cursor_height variables.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Track the current DPMS level for any given output, and track failure (or
otherwise) of the DPMS-setting property call.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Makes create_output_for_connector() slightly easier to read.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Refactor the code constructing the connector name into a new function.
This makes create_output_for_connector() slightly easier to read.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Refactor the code for choosing the initial mode for an output from
create_output_for_connector() to drm_output_choose_initial_mode().
This makes create_output_for_connector() slightly easier to read.
v2: Document everything.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
drm_output_start_repaint_loop() incurred a delay of
one refresh cycle by using a no-op page-flip to get
an accurate vblank timestamp as reference. This causes
unwanted lag whenever Weston exited its repaint loop, e.g.,
whenever an application wants to repaint with less than
full video refresh rate but still minimum lag.
Try to use the drmWaitVblank ioctl to get a proper
timestamp instantaneously without lag. If that does
not work, fall back to the old method of idle page-flip.
This optimization will work on any drm/kms driver
which supports high precision vblank timestamping.
As of Linux 4.0 these would be intel, radeon and
nouveau on all their supported gpu's.
On kms drivers without instant high precision timestamping
support, the kernel is supposed to return a timestamp
of zero when calling drmWaitVblank() to query the current
vblank count and time iff vblank irqs are currently
disabled, because the only way to get a valid timestamp
on such kms drivers is to enable vblank interrupts and
then wait a bit for the next vblank irq to take a new valid
timestamp. The caller is supposed to poll until at next
vblank irq it gets a valid non-zero timestamp if it needs
a timestamp.
This zero-timestamp signalling works up to Linux 3.17, but
got broken due to a regression in Linux 3.18 and later. On
Linux 3.18+ with kms drivers that don't have high precision
timestamping, the kernel erroneously returns a stale timestamp
from an earlier vblank, ie. the vblank count and timestamp are
mismatched. A patch is under way to fix this, but to deal with
broken kernels, we also check non-zero timestamps if they are
more than one refresh duration in the past, as this indicates
a stale/invalid timestamp, so we need to take the page-flip
fallback for restarting the repaint loop.
v2: Implement review suggestions by Pekka Paalanen, especially
extend the commit message to describe when and why the
instant restart won't work due to missing Linux kernel
functionality or a Linux kernel regression.
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
v3: Fix timespec_to_nsec() which was computing picoseconds,
use the new timespec-util.h helpers.
v4: Rebased to master, split long lines.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit adds three new exported functions:
- weston_compositor_create() returns a new weston_compositor instance,
initializing it as the now removed weston_compositor_init() did.
- weston_compositor_exit(compositor) asks the compositor to tear
down by calling the compositor's exit vfunc which is set by the
libweston application.
- weston_compositor_destroy(compositor) is called by the libweston
application when tearing down the compositor. The compositor is destroyed
and the memory freed.
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This is a preliminary change for libweston, with no functional modifications.
Separate the backends and the core weston_compositor struct, by creating
the weston_compositor in the main(), and having the various backends extend
the weston_backend struct, an instance of which is returned by the backend
entry point.
This enable us to logically separate the compositor core from the backend,
allowing the core to be extended without messing with the backends.
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Allow proper handling of output->pipe > 1 to support
triple-head graphics cards etc. by using the "high-crtc"
support introduced in Linux 2.6.39 and libdrm 2.4.25
around May 2011.
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
Initialize output->native_mode with the initially chosen
mode for an output, so weston_output_mode_switch_to_native()
has something to work with and can switch back from temporary
selected modes to the outputs native mode. Before, this was a
no-op.
This allows an output to switch back to its default mode if
a former toplevel fullscreen shell surface created via method
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER gets destroyed, or
it gets demoted to non-fullscreen, or if modesetting on the
output failed for some reason.
v2: Modified and split into a separate patch from original
patch "Allow restore_output_mode() to work properly.",
as suggested by Derek Foreman.
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
The matching logic in choose_mode() compared refresh rate
of a drm_mode candidate mode expressed in Hz against the
requested refresh rate of the target weston_mode expressed
in milliHz, so the match always failed and the logic always
ended up the mode with the highest refresh rate for a given
resolution, instead of the one matching the requested rate.
Match proper fields to fix this.
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
To help reduce code duplication and also 'kitchen-sink' includes
the ARRAY_LENGTH macro was moved to a stand-alone file and
referenced from the sources consuming it. Other macros will be
added in subsequent passes.
Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>