platform/upstream/weston.git
6 years agotests: add test_seat_release() for symmetry
Pekka Paalanen [Mon, 26 Feb 2018 12:14:14 +0000 (14:14 +0200)]
tests: add test_seat_release() for symmetry

Add test_seat_release() as the counterpart of test_seat_init() instead
of open-coding it. This helps adding more code to test_seat_release()
later.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoman: document WESTON_LIBINPUT_LOG_PRIORITY env
Pekka Paalanen [Mon, 5 Feb 2018 14:20:51 +0000 (16:20 +0200)]
man: document WESTON_LIBINPUT_LOG_PRIORITY env

Commit c81c4241d9c9fc5f60c08177dd8a33ae4e4ddca1 added this environment
variable. Document it.

It applies also to the fbdev-backend but that has no man page.

v2:
- Rewording by Peter Hutterer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibinput: do not switch output associations on disable
Pekka Paalanen [Tue, 20 Mar 2018 12:45:36 +0000 (14:45 +0200)]
libinput: do not switch output associations on disable

If an input device is associated to an output that then gets disabled,
there is no case where associating to a different output would be
correct.

The output association is used for absolute positioned input devices,
and an input device like a touchscreen cannot ever be automatically
valid for more than one possible output - the touchscreen display
device.

Therefore do not automatically reassing implicitly associated input
devices to another output. This removes some log spam on shutdown.

In fact, if there can be more than one output at any time, absolute
input devices must be explicitly configured to associate with the
correct output, or the results are essentially undefined in any case.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibweston: require connected heads for input devices
Pekka Paalanen [Tue, 20 Mar 2018 11:29:40 +0000 (13:29 +0200)]
libweston: require connected heads for input devices

The use case driving this change is a clone mode setup, where the user
is hotplugging or unplugging a cloned touchscreen. Even if the output
and head are force-enabled, the touch device should still follow the
connector connection status. If there is no video signal for the
touchscreen (disconnected connector), then the touch input should be
ignored as well.

When the output is force-enabled, we need to trigger
output_heads_changed from connector status changes. If the head or
output are not force-enabled, the compositor will likely attach and
detach the head as appropriate. In clone mode, the attach or detach
needs to trigger output_heads_changed directly. In other cases, it may
be handled through the output getting enabled or disabled which are
different signals.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibinput: use head names for output matching
Pekka Paalanen [Mon, 19 Mar 2018 12:55:41 +0000 (14:55 +0200)]
libinput: use head names for output matching

Associating input devices with weston_outputs by the output name fails
when one output has several heads. We need to match against head names
instead of output names to be able to find all names.

This fixes touchscreen output association in shared-CRTC clone mode when
outputs or input devices appear or disappear.

Even though notify_output_create() is called only when new outputs
appear, the implementation is prepared to also remove output
associations. This will be handy in the future when this function will
handle also head detaching from an output that remains enabled.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibinput: allow evdev_device_set_output(dev, NULL)
Pekka Paalanen [Thu, 20 Apr 2017 08:38:06 +0000 (11:38 +0300)]
libinput: allow evdev_device_set_output(dev, NULL)

Removing the output association from an evdev_device is more than just
setting the pointer to NULL, one also needs to remove the destroy
listener and flag the destroy listener as unused (notify == NULL).

evdev_device_set_output() can already remove associations, so let it
also handle an assignment to NULL output.

Fix notify_output_destroy() to handle removing an association correctly.
Previously, the listener was left "used", which would mean the next call
to evdev_device_set_output() would have wl_list_remove()'d, accessing
freed memory. This could be triggered by having a touchscreen with a
specified output association, and unplugging then re-plugging the
corresponding output.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibinput: make setting the same output a no-op
Pekka Paalanen [Tue, 18 Apr 2017 09:22:12 +0000 (12:22 +0300)]
libinput: make setting the same output a no-op

In the future evdev_device_set_output() will start getting called more
often, redundantly. Short-circuit the setting if the chosen output is
already set for an input device. This reduces churn in the logs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibinput: log input device to output associations
Pekka Paalanen [Tue, 18 Apr 2017 09:22:12 +0000 (12:22 +0300)]
libinput: log input device to output associations

Helps admins ensure the configuration is correct.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibinput: deprecate WL_CALIBRATION
Pekka Paalanen [Wed, 21 Mar 2018 12:30:04 +0000 (14:30 +0200)]
libinput: deprecate WL_CALIBRATION

The udev property WL_CALIBRATION is an old way of giving Weston a
touchscreen calibration matrix. It is Weston-specific.

The recommended way of setting up a calibration is to use the udev
property LIBINPUT_CALIBRATION_MATRIX, which libinput will load
automatically and therefore applies to all libinput using display
servers and applications.

The syntax of WL_CALIBRATION and LIBINPUT_CALIBRATION_MATRIX is
different as well: WL_CALIBRATION uses pixels as the translation part
units, which makes the values depend on the output resolution.
LIBINPUT_CALIBRATION_MATRIX on the other hand uses normalized units.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibinput: note if calibrating without an output
Pekka Paalanen [Tue, 18 Apr 2017 09:14:32 +0000 (12:14 +0300)]
libinput: note if calibrating without an output

Print a note that calibration got skipped if the input device supports a
calibration matrix but there is no associated output to compute it from.
Helps with debugging touchscreen calibration issues.

The code is reorganized and commented a bit, but this does not change
the behaviour.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agolibinput: remove evdev_device::devnode
Pekka Paalanen [Tue, 18 Apr 2017 11:43:08 +0000 (14:43 +0300)]
libinput: remove evdev_device::devnode

Struct 'evdev_device' has field 'devnode' which is initialized to NULL,
never assigned, and finally free()'d. Therefore it is useless.

Remove the dead field.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agocompositor-drm: no need to clear inherited_mode
Pekka Paalanen [Tue, 28 Nov 2017 12:33:52 +0000 (14:33 +0200)]
compositor-drm: no need to clear inherited_mode

The head was just zalloc()'d, there is no need to memset it to zero.

If a function fails, it is preferable it leaves the output arguments
untouched.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: introduce drm_head_read_current_setup()
Pekka Paalanen [Tue, 28 Nov 2017 12:30:10 +0000 (14:30 +0200)]
compositor-drm: introduce drm_head_read_current_setup()

Rename connector_get_current_mode() because it will be useful for
storing not just the current mode on creating a head.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: update video mode printing
Pekka Paalanen [Wed, 15 Nov 2017 11:37:18 +0000 (13:37 +0200)]
compositor-drm: update video mode printing

Stop using a head for printing the mode list, because there could be
multiple heads. We already gather the mode list from all heads.

No need to print the connector id here, because it is logged with DRM
heads, and core prints the head names on output enable.

The "built-in" flag seemed dead, because it could only be printed if the
kernel provided no modes. If we want more detailed info on where modes
come from, we would need to inspect mode_info or add new flags to
drm_mode or weston_mode.

Add printing the pixel clock, because that is used by the video mode
duplicate removal code.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: backlight control for all heads
Pekka Paalanen [Wed, 15 Nov 2017 10:51:01 +0000 (12:51 +0200)]
compositor-drm: backlight control for all heads

If an output has multiple (cloned) heads, it should be enough for any
head to support backlight control for DRM-backend to expose it.

Inspect all attached heads for backlight control and improve the
logging.

Pick the initial backlight level from whatever happens to be the "first"
head, because it's simple.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: combine mode list from heads
Pekka Paalanen [Fri, 10 Nov 2017 14:34:39 +0000 (16:34 +0200)]
compositor-drm: combine mode list from heads

A single list of modes needs to be combined from the mode lists in each
attached head. We could just concatenate the lists, but that might
introduce duplicates. Try to avoid duplicates instead by using partially
fuzzy matching.

When a duplicate is found, try to figure out which is more suitable to
use in place of both. If one has the preferred flag and the other
doesn't, take the preferred one. Otherwise use the one already in the
list.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: unify head status logging
Pekka Paalanen [Thu, 9 Nov 2017 13:10:11 +0000 (15:10 +0200)]
compositor-drm: unify head status logging

Previously the log contained one line for EDID data and another line for
the head, and you just had to know they belong together. Make it more
obvious to read by putting both head and EDID info on the same line.

We no longer print EDID data every time it is parsed (on every hotplug
event), but only if it changes. I did take a shortcut here and use
weston_head::device_changed as the print condition which relies on the
compositor clearing it, but a failure to do so just means we print stuff
even if it didn't change.

Head info updates also print the head info and not just the EDID data.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: drm_set_backlight heads
Pekka Paalanen [Tue, 12 Sep 2017 13:14:31 +0000 (16:14 +0300)]
compositor-drm: drm_set_backlight heads

Fix this function to support more than one head per output.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: drm_output_apply_state_atomic heads
Pekka Paalanen [Tue, 12 Sep 2017 13:07:32 +0000 (16:07 +0300)]
compositor-drm: drm_output_apply_state_atomic heads

Fix this function to support more than one head per output.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: drm_output_apply_state_legacy heads
Pekka Paalanen [Tue, 12 Sep 2017 13:02:01 +0000 (16:02 +0300)]
compositor-drm: drm_output_apply_state_legacy heads

Fix this function to support more than one head per output.

v9:
- Change { connectors, 0 } to { NULL, 0 } in drmModeSetCrtc() args.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: remove unused_connectors array
Pekka Paalanen [Tue, 12 Sep 2017 10:43:51 +0000 (13:43 +0300)]
compositor-drm: remove unused_connectors array

Replace the unused_connectors array by iterating through the head list
instead. A head that is not enabled (attached to an enabled output) is
basically an unused connector.

All connectors regardless of their status have a drm_head. This has the
nice effect that drm_pending_state_apply_atomic() does not need to
re-query the connector properties every time, they can be simply looked
up in the drm_head.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: create heads for all connectors
Pekka Paalanen [Fri, 8 Sep 2017 12:48:07 +0000 (15:48 +0300)]
compositor-drm: create heads for all connectors

In previous patches, all the appropriate fields from drm_output have
been moved into drm_head, and resource allocation has been moved away
from drm_output creation. It is time to throw the switch: this patch
disconnects the drm_output and drm_head lifetimes.

Previously a drm_output was created for a connected connector and
destroyed on disconnection. A drm_head was tied to the drm_output
lifetime just to accommodate the head-based output configuration API
temporarily.

Now all connectors will get a head created regardless of their
connection status. Heads are created and destroyed as connectors appear
and disappear (MST), not when they get connected or disconnected. This
should allow the compositor to force-enable a disconnected connector.

An "empty" drm_output is created with weston_backend::create_output()
hook. This now follows the intent of the head-based output configuration
API.

On hotplug events, all connectors' information is updated regardless of
their connection status changes. It is theoretically possible for a
monitor to change without going through a disconnected state in between.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: move mode list to set_mode()
Pekka Paalanen [Mon, 11 Sep 2017 12:01:12 +0000 (15:01 +0300)]
compositor-drm: move mode list to set_mode()

Move the initialization of the drm_output mode list to
drm_output_set_mode() time.

Once we stop creating the drm_head with the drm_output, there will not
be a head to get the mode list from at drm_output creation time.

Furthermore, once DRM-backend starts supporting more than one head per
output, the combined mode list to be exposed to clients (and the
compositor?) must be constructed with all heads attached.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: get current mode on head discovery
Pekka Paalanen [Mon, 11 Sep 2017 11:06:11 +0000 (14:06 +0300)]
compositor-drm: get current mode on head discovery

The inherited mode is the video mode on the connector when we have not
yet reconfigured the connector, if set.

Get the inherited mode the moment we create a drm_head, not when we
determine the mode for a drm_output. This way we are sure to read all
inherited modes before we reconfigure a single CRTC. Enabling one output
may grab the CRTC from another connector, overwriting whatever mode that
connector might have had.

The inherited mode is stored in drm_head, where we can keep it for the
lifetime of the head, rather than relying on re-loading it from the
kernel at set_mode() time.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: simplify drm_output_find_special_plane()
Pekka Paalanen [Fri, 27 Oct 2017 11:06:51 +0000 (14:06 +0300)]
compositor-drm: simplify drm_output_find_special_plane()

As these planes are allocated on output enable and freed on output
disable, there cannot be a match in the pending_output_list.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: simplify drm_output_find_by_crtc()
Pekka Paalanen [Fri, 27 Oct 2017 10:52:12 +0000 (13:52 +0300)]
compositor-drm: simplify drm_output_find_by_crtc()

As CRTC is allocated on output enable and deallocated on output disable,
there cannot be any matches in find-by-crtc from the
pending_output_list.

Remove the loop over pending_output_list as never finding anything by
definition.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: allocate CRTC on enable()
Pekka Paalanen [Fri, 8 Sep 2017 10:32:40 +0000 (13:32 +0300)]
compositor-drm: allocate CRTC on enable()

A drm_output needs a CRTC only when it is in use. Allocating a CRTC on
creation of drm_output will reserve the CRTC regardless of whether the
output is actually used or not. This may cause creating other
drm_outputs to fail if there are not enough CRTCs.

Instead, allocate the CRTC on drm_output enable() time. A drm_output
will have a valid CRTC only while it is enabled.

This allows us to create drm_output objects arbitrarily and without a
head assignment, which is required by the head-based output API for the
backends. The assigned heads will be known only at enable() time.

Now drm_output_enable() has to call drmModeGetResources() to be able to
find a suitable CRTC. We might want to cache the resources somewhere,
but that is it topic for another patch.

v4: Force resetting unused CRTCs on fini.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: move connector fields into drm_head
Pekka Paalanen [Thu, 31 Aug 2017 13:18:48 +0000 (16:18 +0300)]
compositor-drm: move connector fields into drm_head

Move the connector related fields from drm_output to the drm_head. A
drm_head represents a connector for now.

The code in drm_head_create() to update connector data, monitor
information, etc. is moved into a new function. This will be useful when
DRM-backend starts creating heads for all connectors regardless of their
connection status and will need to update them on hotplug events.

While incurring the churn to move several fields into struct drm_head,
also refactor out drm_head_assign_connector_info(). This function is
needed later when drm_heads will exist regardless of connected status,
as every hotplug event will need to update the state of all connectors.
At that point we will also start handling connector changes that do not
go through an intermediate disconnected state. This refactoring is
trivial enough to be in this patch to reduce the total amount of changes
to be reviewed.

v6:
- adapt to the new places of updating unused_connectors
- free connector in create_output_for_connector() error path

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: move backlight into drm_head
Pekka Paalanen [Mon, 4 Sep 2017 09:21:24 +0000 (12:21 +0300)]
compositor-drm: move backlight into drm_head

Backlight is driven per connector, hence it belongs in struct drm_head.

weston_output::set_backlight() API is remains per output so far. There
is no UI to control backlights per head and adding one would be
difficult for an output that has multiple cloned heads.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: find disconnects from head_list
Pekka Paalanen [Thu, 31 Aug 2017 12:41:57 +0000 (15:41 +0300)]
compositor-drm: find disconnects from head_list

Instead of iterating output_list and pending_output_list, iterate
head_list to find outputs whose connectors have been disconnected.

This helps a following patch to move connector fields from drm_output to
drm_head.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: use head_find_by_connector in update_unused_outputs
Pekka Paalanen [Tue, 13 Feb 2018 13:02:44 +0000 (15:02 +0200)]
compositor-drm: use head_find_by_connector in update_unused_outputs

Making this function not depend on drm_head::output field through
drm_output_find_by_connector() will later allow to remove the
drm_head::output field before removing the unused_connectors array. This
helps keeping the commit more fine-grained.

drm_backend_update_unused_outputs() was only interested in enabled
outputs. The new code is 100% equivalent to the old code. The
difference is that weston_head::output is only set for attached heads. A
connector cannot be in use if it is not attached to an output.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: drm_output_find_by_connector from head_list
Pekka Paalanen [Thu, 31 Aug 2017 08:58:41 +0000 (11:58 +0300)]
compositor-drm: drm_output_find_by_connector from head_list

Switch drm_output_find_by_connector() to search for the output by
iterating the compositor's head_list. drm_head_find_by_connector() will
be useful later on its own.

As of "compositor-drm: start migration to head-based output API" the
head list is guaranteed to contain all created drm_outputs through the
automatically created drm_head.

This simplifies the code a little, introduces
drm_head_find_by_connector(), and works towards the eventual removal of
drm_output_find_by_connector().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: log head detach on enabled output
Pekka Paalanen [Fri, 8 Dec 2017 14:11:17 +0000 (16:11 +0200)]
libweston: log head detach on enabled output

Helps debugging.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: allow attaching heads to enabled outputs
Pekka Paalanen [Fri, 8 Dec 2017 12:13:34 +0000 (14:13 +0200)]
libweston: allow attaching heads to enabled outputs

Move the responsibility of ensuring the head will work in the enabled
output to the backends.

A compositor cannot enable an output without heads, and removing the
last head from an output automatically disables the output, so attaching
a new head to an enabled output is only possible for clone mode.

Backends headless, rdp, and x11 forbid clone mode by not having an
attach_head hook implemented; fbdev and wayland explicitly deny clone
mode. Only the DRM backend is affected by this change and even that not
yet because MAX_CLONED_CONNECTORS is 1 in the DRM backend.

Also ensure a global is created for the head when attached to an enabled
output, and log it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: support user data on weston_output
Pekka Paalanen [Tue, 7 Nov 2017 08:15:01 +0000 (10:15 +0200)]
libweston: support user data on weston_output

Support attaching custom data to a weston_output by the traditional
destroy listener / wl_signal_get approach.

Needs a new destroy signal, because user data lifetime should be the
lifetime of the weston_output regradless of its enabled status. The old
destroy signal is for output consumers that only care about enabled
outputs in the system and gets emitted on disable, not on destroy.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: create/find output by name
Pekka Paalanen [Thu, 2 Nov 2017 12:11:53 +0000 (14:11 +0200)]
libweston: create/find output by name

To let users pick an arbitrary name for an output, to be used as e.g. a
configuration key, add API to create an output with a given name. For
the same configuration purpose, add a search function as well.

For the search function to be predictable, forbid creating multiple
outputs with the same name. Previously, creating multiple outputs with
the same name would have needed detatching to create outputs from the
same head, now that is forbidden.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: print head names on output enable
Pekka Paalanen [Thu, 2 Nov 2017 12:03:11 +0000 (14:03 +0200)]
libweston: print head names on output enable

This will be interesting to see when testing clone mode.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: remove weston_output::head
Pekka Paalanen [Fri, 27 Oct 2017 09:07:49 +0000 (12:07 +0300)]
libweston: remove weston_output::head

Remove the scaffolding that allowed backends to be converted one by one
to the head-based API. Nothing is using these members anymore.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-drm: start migration to head-based output API
Pekka Paalanen [Mon, 28 Aug 2017 13:27:20 +0000 (16:27 +0300)]
compositor-drm: start migration to head-based output API

Hook up the libweston facing head-based output API by introducing struct
drm_head, but leave it as a fake so that members can be migrated in
pieces in follow-up patches.

The DRM backend continues to create an output for each connected
connector only, and during output creation it also creates a drm_head
for it. This allows it to pretend it supports the head-based output API
as long as there is only one head per output ever attached.

create_output callback is fake, it will only look up the existing
drm_output by the head name.

Clones are not yet supported, hence max is defined to 1.

This unfortunately introduces some temporary code that will be revomed
later, but seems to be necessary to avoid a single big patch.

v6:
- add missing drm_head_destroy() call

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-wayland: migrate to head-based output API
Pekka Paalanen [Wed, 25 Oct 2017 12:51:37 +0000 (15:51 +0300)]
compositor-wayland: migrate to head-based output API

Follow the standard pattern used in the headless and x11 backend
migration, but also cater for the two other backend modes: --sprawl or
fullscreen-shell, and --fullscreen.

Stops relying on the implicit weston_output::head.

Unlike other backends, this uses the attach_head hook to do the
required head setup that is not possible to do without an output, but
must be done before weston_output_enable(). This also requires the
detach_head hook for the one case where the user attaches a --fullscreen
head and then detaches it without enabling the output.

It is a little awkward to fully initialize heads as late as attach, but
aside from the --sprawl/fullscreen-shell case, there is not really a way
to know the head properties without creating the parent wl_surface and
configuring it.

Heads/outputs created for parent outputs now have distinct names instead
of all being called "wlparent".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-wayland: strict surface create/destroy
Pekka Paalanen [Thu, 26 Oct 2017 09:56:00 +0000 (12:56 +0300)]
compositor-wayland: strict surface create/destroy

Add safeguards to make it painfully obvious if we ever get the pairing
of wayland_backend_create_output_surface() and
wayland_backend_destroy_output_surface() wrong. Helps catching bugs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-x11: migrate to head-based output API
Pekka Paalanen [Thu, 12 Oct 2017 12:58:10 +0000 (15:58 +0300)]
compositor-x11: migrate to head-based output API

Follow the standard pattern set by the headless backend which also uses
the the window output API.

Stops relying on the implicit weston_output::head.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-fbdev: migrate to head-based output API
Pekka Paalanen [Thu, 14 Sep 2017 13:50:44 +0000 (16:50 +0300)]
compositor-fbdev: migrate to head-based output API

Implement the head-based output API in this backend, and stop relying on
the implicit weston_output::head.

The split between fbdev_head and fbdev_output is somewhat arbitrary.
There is no hotplug or unplug, and there is always 1:1 relationship.
Struct fbdev_screeninfo could have been split as well, but it would not
have made much difference.

I chose fbdev_output to carry the mmap details (buffer_length is now
duplicated here), and fbdev_head to carry the display parameters and
device node path. The device node identifies the head, similar to a
connector.

The backend init creates a head. The compositor uses it to create an
output. Libweston core attaches the head automatically after creating
the output. The attach hook is a suitable place to set up the video
modes on the output as they are dictated by the head, it would be too
late at enable() time.

v7:
- use name argument instead of hardcoded "fbdev" in
  fbdev_output_create()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-fbdev: make re-enable less drastic
Pekka Paalanen [Wed, 13 Sep 2017 13:19:02 +0000 (16:19 +0300)]
compositor-fbdev: make re-enable less drastic

Destroying the whole output in reenable would cause list walk
corruption: the loop over output_list in session_notify() is not using
wl_list_for_each_safe so output removal would break it.

Creating a new output is also problematic as it needs the compositor to
configure it, but that probably saved us from another list walk failure:
adding the new output to be list while walking the list, possibly
causing it to be destroyed and re-created ad infinitum.

Instead of a complete destroy/create cycle, just do our internal
disable/enable cycle. That will re-open the fbdev, re-read the
parameters, re-create hw_surface, and reinitialize the renderer output.

A problem with this is if fbdev_set_screen_info() fails. We do read the
new parameters, but we don't communicate them to libweston core or old
clients.

However, it is hard to care: to trigger this path, one needs to
VT-switch to another fbdev app which changes the fbdev parameters. That
is quite difficult as VT-switching has been broken for a good while for
fbdev-backend, at least with logind. Also fbdev_set_screen_info() would
have to fail before one should be able to tell something is wrong.

The real reason behind this patch, though, is the migration to the
head-based output API. Destroying and re-creating an output really does
not fit that design. Destroying and re-creating a head would be better,
but again not testable in the current state.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-rdp: migrate to head-based output API
Pekka Paalanen [Thu, 12 Oct 2017 13:21:26 +0000 (16:21 +0300)]
compositor-rdp: migrate to head-based output API

Follow the starndard patttern as the other backends, headless and x11 in
particular, to stop relying on the implicit weston_output::head.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocompositor-headless: migrate to head-based output API
Pekka Paalanen [Thu, 24 Aug 2017 13:40:17 +0000 (16:40 +0300)]
compositor-headless: migrate to head-based output API

Implement the head-based output API in this backend, and stop relying on
the implicit weston_output::head.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: cancel idle_repaint on output destroy
Pekka Paalanen [Thu, 26 Oct 2017 11:33:59 +0000 (14:33 +0300)]
libweston: cancel idle_repaint on output destroy

If the idle_repaint() callback has been scheduled when a weston_output
gets destroyed, the callback will hit use-after-free. I have encountered
this when migrating the wayland backend to the head-based API, using
--sprawl, and closing/disconnecting one of the parent compositor
outputs.

Store the idle_repaint callback source, and destroy it in
weston_output_release(), ensuring we don't get a stale call to
start_repaint_loop later.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: assert current_mode in weston_output_enable()
Pekka Paalanen [Thu, 14 Sep 2017 13:17:59 +0000 (16:17 +0300)]
libweston: assert current_mode in weston_output_enable()

The functions called here, particularly
weston_output_transform_scale_init(), rely on current mode being set.
The current mode must also be found in the mode list, though we don't
explicitly check it here.

current_mode not being set is a programmer error. It could be a backend
bug, but it could also be a libweston user bug not calling a set size
function.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: assert make/model in weston_output_enable()
Pekka Paalanen [Thu, 24 Aug 2017 13:08:49 +0000 (16:08 +0300)]
libweston: assert make/model in weston_output_enable()

Output make and model are not allowed to be NULL in the protocol, so
ensure they are not forgotten when enabling an output.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: stop auto-adding the implicit head
Pekka Paalanen [Wed, 23 Aug 2017 13:00:21 +0000 (16:00 +0300)]
libweston: stop auto-adding the implicit head

All frontends have been converted to the new head-based output
management API, which means that
weston_compositor_create_output_with_head() is calling
weston_output_attach_head(). We will never hit the implicit attach
anymore.

Therefore we can now require that an output has at least one head when
calling weston_output_enable(). An output without heads is useless.

The auto-add code is removed as dead.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: remove output_pending_signal
Pekka Paalanen [Thu, 17 Aug 2017 14:29:36 +0000 (17:29 +0300)]
libweston: remove output_pending_signal

The signal has been replaced with the heads_changed hook and is no
longer useful.

weston_pending_output_coldplug() is renamed to
weston_compositor_flush_heads_changed() for two reasons: it better
describes what it does now, and it serves as an obvious flag that
libweston ABI has been broken.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: change windowed_output_api output_create to create_head
Pekka Paalanen [Thu, 12 Oct 2017 12:03:42 +0000 (15:03 +0300)]
libweston: change windowed_output_api output_create to create_head

Rename the function pointer to create_head() because that is what it
does on backends that are converted to the head-based API. Update the
documentation to match.

Surprisingly this is not an ABI break, as the function behaviour and
signature remain intact. Hence API_NAME is not bumped.

This is only an API break, and main.c is fixed accordingly.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoweston: migrate DRM to head-based output API
Pekka Paalanen [Thu, 17 Aug 2017 14:13:08 +0000 (17:13 +0300)]
weston: migrate DRM to head-based output API

Migrate the DRM frontend to use the simple head-based output
configurator, maintaining the exact same features and semantics as
before.

This is an intermediate step. It is unoptimal to create a weston_output
just to turn it off, but the libweston implementation and the DRM
backend require it for now. In the future, the DRM frontend will get its
own configurator that does not create useless weston_outputs and
supports clone mode by attaching multiple heads to the same
weston_output. Clone mode is not yet supported by libweston/DRM.

Until we remove the need to create a weston_output just to turn it
"off", that is, disable it, we will hit simple_head_enable() for heads
we have already disabled. As long as the DRM-backend conversion to the
head-based API is not complete, attempting to create an output for a
head again would lead to a crash. This problem does not exist right now,
but it will after the patch "compositor-drm: start migration to
head-based output API". Therefore, check if the head we are about to
process is already attached, and do nothing if so. DRM outputs set to
"off" are the only ones legitimately hitting this condition.

This is the last frontend migrated, wet_set_pending_output_handler() is
deleted as dead code.

v9:
- Add the workaround in simple_head_enable().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
v7 Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoweston: migrate RDP to head-based output API
Pekka Paalanen [Thu, 17 Aug 2017 14:09:01 +0000 (17:09 +0300)]
weston: migrate RDP to head-based output API

Migrate the RDP frontend to use the new head-based output configuration
API: listen for heads_changed, and process all heads.

v7:
- remove unnecessary 'goto out' in load_rdp_backend()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoweston: migrate fbdev to head-based output API
Pekka Paalanen [Thu, 17 Aug 2017 14:05:29 +0000 (17:05 +0300)]
weston: migrate fbdev to head-based output API

Migrate the fbdev frontend to use the new head-based output
configuration API: listen for heads_changed, and process all heads.

v7:
- remove unnecessary 'goto out' in load_fbdev_backend()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoweston: migrate wayland to head-based output API
Pekka Paalanen [Thu, 17 Aug 2017 13:59:53 +0000 (16:59 +0300)]
weston: migrate wayland to head-based output API

Migrate the Wayland frontend to use the new head-based output
configuration API: listen for heads_changed, and process all heads.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoweston: migrate x11 to head-based output API
Pekka Paalanen [Thu, 17 Aug 2017 13:54:58 +0000 (16:54 +0300)]
weston: migrate x11 to head-based output API

Migrate the x11 frontend to use the new head-based output configuration
API: listen for heads_changed, and process all heads.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoweston: migrate headless to head-based output API
Pekka Paalanen [Thu, 17 Aug 2017 10:10:28 +0000 (13:10 +0300)]
weston: migrate headless to head-based output API

Migrate the headless frontend to use the new head-based output
configuration API: listen for heads_changed, and process all heads.

The simple_heads_changed() function is written to be able to cater for
all backends. The rest will be migrated individually.

The head destroy listeners are not exactly necessary, for headless
anyway, but this is an example excercising the API. Also
is_device_changed() check is mostly useful with DRM.

v8:
- replace weston_compositor_set_heads_changed_cb() with
  weston_compositor_add_heads_changed_listener()
- fix comment on wet_head_tracker_create()

v3: Print "Detected a monitor change" only for enabled heads.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoweston: move weston_output_enable() into callers
Pekka Paalanen [Thu, 17 Aug 2017 13:39:48 +0000 (16:39 +0300)]
weston: move weston_output_enable() into callers

Move the call out of wet_configure_windowed_output_from_config() and
into its callers.

This allows to migrate each frontend one by one.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: add weston_head_is_device_changed() API
Pekka Paalanen [Mon, 28 Aug 2017 11:11:02 +0000 (14:11 +0300)]
libweston: add weston_head_is_device_changed() API

Reacting to DRM hotplug events is racy. It is theoretically possible to
get hotplug events for a quick swap from one monitor to another and
process both only after the new monitor is connected. Hence it is
possible for display device information to change without going through
a disconnected state for the head.

To support such cases, add API to allow detecting it in the compositor.

v6:
- change str_null_neq() to str_null_eq()
- rename weston_head_condition_device_changed()
- move the condition from weston_head_set_device_changed() to the
callers

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: add weston_head destroy signal
Pekka Paalanen [Tue, 10 Oct 2017 08:21:58 +0000 (11:21 +0300)]
libweston: add weston_head destroy signal

Add support for subscribing to weston_head destruction.

The primary use case for heads being destroyed arbitrarily is the
DRM-backend with MST connectors, which may disappear on unplug. It is
not just the connector becoming disconnected, it is the connector
actually disappearing.

The compositor needs to know about disappearing heads so that it has a
chance to clean up "orphaned" outputs which do get disabled but still
need destroying at run time. Shutdown would destroy them as well.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: new head-based output management API
Pekka Paalanen [Wed, 16 Aug 2017 07:39:17 +0000 (10:39 +0300)]
libweston: new head-based output management API

Introduce the API for users (compositors) to create an output from a
head, attach and detach heads, and destroy outputs created this way.
This also adds the backend-facing API to libweston.

In the new API design, a backend creates heads, and the compositor
chooses one or more heads (clone mode) to be driven by an output.
In the future backends will be converted to not create outputs directly
but only in the new create_output hook.

The user subscribes to a heads_changed hook and arranges heads into
outputs from there.

Adding the API this way will allow frontends (main.c) and backends to be
converted one by one. This adds compatiblity paths in
weston_compositor_create_output_with_head() and weston_output_destroy()
so that frontends can be converted first to call these, and then
backends can be converted one by one to the new design. Afterwards, the
compatibility paths will be removed along with weston_output::head.

Currently heads can be added to a disabled output only. This is less
than ideal for clone mode hotplug and should be improved on later.

v4: Remove the wl_output global on head detach if output is enabled.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: add heads_changed_signal
Pekka Paalanen [Tue, 15 Aug 2017 10:00:02 +0000 (13:00 +0300)]
libweston: add heads_changed_signal

Add a hook for compositors to get a callback when heads are added or
their connection status changes, to which compositors likely want to
react to by enabling or disabling outputs (API for that to be added
later).

As many head changes as possible should be coalesced into a single
heads_changed call. Therefore the callback is made from an idle task.
This anticipates a future atomic output configuration API, where the
global output configuration is tested and set atomically instead of one
by one.

weston_pending_output_coldplug() needs to manually execute the
heads_changed call so that initial outputs are created before any
plugins get their start-up idle tasks ran. This is especially important
for ivi-shell which does not support output hotplug, and for tests to
guarantee the expected outputs.

v8:
- Change the callback function pointer into a wl_signal. The API is
  changed and renamed.

v6:
- fix a typo
- add comment in weston_pending_output_coldplug()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v6 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: add compositor list of heads
Pekka Paalanen [Mon, 14 Aug 2017 13:05:35 +0000 (16:05 +0300)]
libweston: add compositor list of heads

weston_compositor needs to maintain a list of all available heads, so
that a compositor can pick and choose which heads to take into or out of
use at arbitrary times. The heads may be on or off, and connected or
disconnected.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: add weston_head_is_enabled()
Pekka Paalanen [Thu, 15 Feb 2018 13:18:20 +0000 (15:18 +0200)]
libweston: add weston_head_is_enabled()

Enabled is orthogonal from connected. A connected head could be
disabled, or a disconnected head could in the future be enabled.

Compositors quite likely want to check if a head is already enabled
before starting to take it into use.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: add weston_head::connected
Pekka Paalanen [Mon, 14 Aug 2017 12:45:14 +0000 (15:45 +0300)]
libweston: add weston_head::connected

Heads may be disconnected or connected and the compositor needs to be
able to know the state to know which heads to take into use.

Currently a single head is automatically created with an output, and
outputs are only ever created as connected and destroyed on
disconnection, so it suffices to set connected to true. In the future,
backends are expected to create heads for both connected and
disconnected connectors, so that a connector can be forced on without it
being actually connected.

v6:
- split weston_head_is_enabled() to a new patch

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: add name to weston_head
Pekka Paalanen [Mon, 14 Aug 2017 11:43:13 +0000 (14:43 +0300)]
libweston: add name to weston_head

Heads need to be named, so they can be referenced in logs and
configuration sources.

When clone mode is implemented, output and head names may differ.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocms-colord: find a good head
Pekka Paalanen [Tue, 4 Apr 2017 13:36:07 +0000 (16:36 +0300)]
cms-colord: find a good head

The 'head' member of 'struct weston_output' is going to go unused and
then disappear, so stop using it and find a head from the proper list.

However, this leaves a problem in cms-colord: if you have multiple
monitors driver with the same CRTC, what do you say to the color
management system? The monitors could be different, but all the color
LUTs etc. are in the CRTC and are shared, as is the framebuffer.

Do the simple hack here and just use whatever head happens to be the
first in the list.

The warning is printed in get_output_id(), because if heads are added or
removed while the output is enabled, the id could change.

v6:
- add weston_output_get_first_head(), at first use
- add warning message for nr. heads > 1

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: strdup head make, model, serial_number
Pekka Paalanen [Tue, 4 Apr 2017 13:26:23 +0000 (16:26 +0300)]
libweston: strdup head make, model, serial_number

Duplicate these strings to decouple their lifetime from whatever the
backends used. This should prevent hard to catch use after frees and
such problems in the future.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: properly orphan wl_output resources
Pekka Paalanen [Mon, 4 Dec 2017 13:28:13 +0000 (15:28 +0200)]
libweston: properly orphan wl_output resources

Remove the wl_resource in the head's resource list when we are
removing the wl_output global. We sent global removal events to clients,
the resources should become dummies until clients reap them. Reset user
data so that clients triying to use dummy objects don't hit e.g. a freed
head pointer.

This fixes a theoretical issue: if an enabled output is disabled and
then gets enabled again, mode changes and wl_surface.enter/leave would
still attempt to use the dummy objects. If a client destroyed a dummy
object, we don't have the destructor to remove it from the resource
list, and libweston would hit freed memory.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: introduce weston_output::head_list
Pekka Paalanen [Tue, 28 Mar 2017 13:27:25 +0000 (16:27 +0300)]
libweston: introduce weston_output::head_list

The intention is that in the future backends will dynamically allocate
weston_heads based on the resources they have. The lifetime of a
weston_head will be independent of the lifetime of a weston_output it
may be attached to. Backends allocate objects derived from weston_head,
like they currently do for weston_output. Backend will choose when to
destroy a weston_head.

For clone mode, struct weston_output gains head_list member, which is
the list of attached heads that will all show the same framebuffer.
Since heads are growing out of weston_output, management functions are
added.

Detaching a head from an enabled output is allowed to accommodate
disappearing heads. Attaching a head to an enabled output is disallowed
because it may need hardware reconfiguration and testing, and so
requires a weston_output_enable() call.

As a temporary measure, we have one weston_head embedded in
weston_output, so that backends can be migrated individually to the new
allocation scheme.

v8:
- Do not send wp_presentation_feedback.sync_output events for multiple
  wl_output globals in weston_presentation_feedback_present().

v6:
- adapt to upstream changes in weston_output_set_transform()
- use wl_list_for_each_safe in weston_output_release()
- removed weston_output_get_first_head() as it's not needed yet

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
v7 Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: refactor weston_mode_switch_finish
Pekka Paalanen [Tue, 28 Mar 2017 12:27:10 +0000 (15:27 +0300)]
libweston: refactor weston_mode_switch_finish

Split out a new function. This is a pure refactoring, no change in
behaviour.

This helps a following patch that adds a loop over output->head_list.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: make wl_output point to weston_head
Pekka Paalanen [Mon, 27 Mar 2017 13:31:25 +0000 (16:31 +0300)]
libweston: make wl_output point to weston_head

The user data of a wl_resource representing a wl_output protocol object
used to be a pointer to weston_output. Now that weston_output is being
split, wl_output more accurately refers to weston_head which is a single
monitor.

Change the wl_output user data to point to weston_head.
weston_output_from_resource() is replaced with
weston_head_from_resource().

This change is not strictly necessary, but architecturally it is the
right thing to do. In the future there might appear the need to refer to
a specific head of a cloned pair, for instance.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: use head in wl_output global
Pekka Paalanen [Mon, 27 Mar 2017 09:24:34 +0000 (12:24 +0300)]
libweston: use head in wl_output global

As a wl_output represents weston_head, use a weston_head pointer as the
wl_output global's user data.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: move wl_output to weston_head
Pekka Paalanen [Mon, 27 Mar 2017 09:15:38 +0000 (12:15 +0300)]
libweston: move wl_output to weston_head

The wl_output protocol interface exposes things like monitor make,
model, sub-pixel layout and physical dimensions. Obviously wl_output is
meant to represent a monitor.

The abstraction of a monitor is weston_head. Therefore move the wl_output
global and the bound resources list into weston_head.

When clone mode gets implemented in the future, this means that monitors
driven by the same CRTC will still be represented as separate wl_output
globals. This allows to accurately represent the hardware.

Clone mode that used separate, not frame-locked, CRTCs to drive two
monitors as clones would necessarily also be exposed as separate
wl_output since they have different timings.

v6:
- adapt to upstream changes in weston_output_set_transform()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: introduce weston_head
Pekka Paalanen [Fri, 24 Mar 2017 13:39:24 +0000 (15:39 +0200)]
libweston: introduce weston_head

In order to support clone modes, libweston needs the concept of a head
that is separate from weston_output. While weston_output manages buffers
and the repaint state machine, weston_head will represent a single
monitor. In the future it will be possible to have a single
weston_output drive one or more weston_heads for a clone mode that
shares the framebuffers between all cloned heads.

All the fields that are obviously properties of the monitor are moved
from weston_output into weston_head.

As moving the fields requires one to touch all the backends for all the
assingments, introduce setter functions for them while we are here. The
setters are identical to the old assignments, for now.

As a temporary measure, weston_output embeds a single head. Also the
ugly casts in weston_head_set_monitor_strings() will be removed by a
follow-up patch.

Libweston major version is bumped, because weston_output struct layout
is changed.

v7:
- Bump libweston major version.

v6:
- adapt to upstream changes in weston_output_set_transform()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoconfigure.ac: Bump libweston version to match weston version
Derek Foreman [Mon, 9 Apr 2018 21:13:09 +0000 (16:13 -0500)]
configure.ac: Bump libweston version to match weston version

configure won't work if weston's version is higher than libweston's.

6 years agoconfigure.ac: Reopen master for regular development
Derek Foreman [Mon, 9 Apr 2018 18:13:40 +0000 (13:13 -0500)]
configure.ac: Reopen master for regular development

6 years agoconfigure.ac: bump to version 4.0.0 for the official release
Derek Foreman [Mon, 9 Apr 2018 16:55:01 +0000 (11:55 -0500)]
configure.ac: bump to version 4.0.0 for the official release

6 years agoterminal: Fix unintended fallthrough to cursor restore
Daniel Stone [Tue, 3 Apr 2018 18:38:09 +0000 (19:38 +0100)]
terminal: Fix unintended fallthrough to cursor restore

ef57a9b788 added support for window operations such as reporting the
title in escape mode. It implemented this by which-window-op case,
inside the existing which-escape-code case. Whilst it would break out of
the former window-op case, it never broke out of the latter escape-code
case. This would lead to window ops (such as reporting title) falling
through to restoring the saved cursor position.

This doesn't seem at all right, and also fixes a warning with GCC 8.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoconfigure.ac: bump to version 3.0.93 for the RC1 release
Derek Foreman [Mon, 2 Apr 2018 18:00:01 +0000 (13:00 -0500)]
configure.ac: bump to version 3.0.93 for the RC1 release

6 years agoPartially revert "xwm: Add icon support to the frame" and friends
Derek Foreman [Fri, 30 Mar 2018 16:56:22 +0000 (11:56 -0500)]
Partially revert "xwm: Add icon support to the frame" and friends

This (partially) reverts commit bef761796c2ada6344d227142af4a0f40b9760dd.
This (partially) reverts commit 4d1cd36c9ea041688f92cd8981e43b5fe3b52409.
This (partially) reverts commit 44fc1be913ab2faad0414f50e51d58310302d065.
This (partially) reverts commit 6b58ea8c43ac81e519bd418efbf24687a5d731b8.

The new xwm icon code has proven to be leaky and incomplete, and while
we have patches under consideration to fix the rest of its known problems
they still require changes and review cycles.  Currently the known
leaks have been squashed, but it still picks wrong sized icons and
does no scaling, which can lead to very strange rendering.  At window
close time the wrong sized icon appears above the window during fade out.

This patch reverts the mostly solid bits and keeps the unfinished
bits behind in favor of a simpler revert than removing the whole
thing.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
6 years agoRevert "xwm: do not include shadow in input region"
Derek Foreman [Wed, 28 Mar 2018 14:33:56 +0000 (09:33 -0500)]
Revert "xwm: do not include shadow in input region"

This reverts commit 332d1892bbb380b32ff1c9f99d20184b447535dd.
And re-introduces the bug it was intended to fix, see:
https://lists.freedesktop.org/archives/wayland-devel/2017-December/036402.html

Reverting this because it causes harm to all xwayland clients - the
input region no longer gets adjusted when resizing windows.

start an xterm, resize it larger, you can no longer interact with the
new area of the window (including the server side decor).

6 years agoxwm: Fix two more icon related memory leaks
Derek Foreman [Tue, 27 Mar 2018 16:09:32 +0000 (11:09 -0500)]
xwm: Fix two more icon related memory leaks

Hopefully sort the last leaks introduced in commit 6b58ea8c

The window could be destroyed before it had a frame but after it had an icon
(I could trigger this with firefox), and the window could be assigned an icon
twice before it had a frame (I could trigger this with terminology).

The latter leak was
Reported-by: Scott Moreau <oreaus@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoivi-shell: remove dead assignments in layer transition
Emre Ucan [Tue, 20 Mar 2018 14:29:41 +0000 (15:29 +0100)]
ivi-shell: remove dead assignments in layer transition

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor: initialize ret in repaint_timer_handler
Emre Ucan [Tue, 20 Mar 2018 14:29:40 +0000 (15:29 +0100)]
compositor: initialize ret in repaint_timer_handler

If output_list of compositor is empty, value of
ret is read without initialization.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agogl-renderer: set num_images after import_simple_dmabuf
Emre Ucan [Tue, 20 Mar 2018 14:29:39 +0000 (15:29 +0100)]
gl-renderer: set num_images after import_simple_dmabuf

we have to set num_images after import_simple_dmabuf
call. Otherwise, egl_images will not be correctly
referenced in gl_renderer_attach_dmabuf.

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoinput: fix use-after-free issue at pointer_cancel
Emre Ucan [Tue, 20 Mar 2018 14:28:24 +0000 (15:28 +0100)]
input: fix use-after-free issue at pointer_cancel

If the constraint is an one-shot constraint, constraint
is freed in disable_pointer_constraint function.
Therefore, we should not try to read freed memory at
"switch (constraint->lifetime)" statement.

The removed code is anyway superfluous. Because
surface destroy signal is only removed, when constraint
is an one-shot constraint.

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agohmi-controller: remove dead assignments in add_launchers
Emre Ucan [Tue, 20 Mar 2018 14:28:23 +0000 (15:28 +0100)]
hmi-controller: remove dead assignments in add_launchers

assigned values of x, y, ret and layout_surface are
never read.

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: remove dead assigment in drm_fb_create_dumb
Emre Ucan [Tue, 20 Mar 2018 14:28:22 +0000 (15:28 +0100)]
compositor-drm: remove dead assigment in drm_fb_create_dumb

ret is overwritten by drmModeAddFB2 call

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoxwm: Fix memory leak
Scott Moreau [Fri, 23 Mar 2018 19:41:43 +0000 (13:41 -0600)]
xwm: Fix memory leak

A memory leak introduced by 6b58ea8c led to me finding a bigger leak,
which is xwm was calling frame_create() without calling frame_destroy().
This meant that the associated icon_surface was not being destroyed,
leaving the destroy handler for it broken. Here we fix this by calling
frame_destroy() when the window is destroyed and free the reply in
the icon_surface destroy handler.
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoRevert "xwm: Fix memory leak"
Pekka Paalanen [Tue, 20 Mar 2018 08:12:37 +0000 (10:12 +0200)]
Revert "xwm: Fix memory leak"

This reverts commit d2cb711d813e750b1e303e6200c027fd27a21f8e.

I missed the call to cairo_image_surface_create_for_data() which assumes
the data will remain present until the cairo surface is destroyed. It
seems the existence of data depends on the reply not being freed.

This will need a more involved fix.

Sorry, I noticed this just seconds after I pushed the patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoxwm: Fix memory leak
Scott Moreau [Tue, 20 Mar 2018 00:06:03 +0000 (18:06 -0600)]
xwm: Fix memory leak

Fix memory leak introduced by 6b58ea8c. weston_wm_handle_icon() was
calling xcb_get_property_reply() without freeing the reply.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoconfigure.ac: bump to version 3.0.92 for the beta release
Derek Foreman [Mon, 19 Mar 2018 20:41:17 +0000 (15:41 -0500)]
configure.ac: bump to version 3.0.92 for the beta release

6 years agosimple-dmabuf-drm: use appropriately sized buffer (freedreno)
Guido Günther [Mon, 19 Mar 2018 16:45:19 +0000 (17:45 +0100)]
simple-dmabuf-drm: use appropriately sized buffer (freedreno)

Use stride instead of width for buffer calculation.

[Derek Foreman edited the commit log and removed the leftover
initialization of 'size']

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agosimple-dmabuf-drm: Always define ALIGN
Guido Günther [Mon, 19 Mar 2018 16:45:18 +0000 (17:45 +0100)]
simple-dmabuf-drm: Always define ALIGN

Other backends might want to use it.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoFix an uninitialized variable
Dima Ryazanov [Sun, 18 Mar 2018 04:20:29 +0000 (00:20 -0400)]
Fix an uninitialized variable

"has_discrete" gets set to true in if/else if, but gets left unset otherwise.
So let's initialize it to false.

(This was caught by valgrind.)

Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: use getopt_long
Guido Günther [Fri, 16 Mar 2018 17:56:50 +0000 (18:56 +0100)]
simple-dmabuf-drm: use getopt_long

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: use opt bitmask instead of is_immediate
Guido Günther [Fri, 16 Mar 2018 17:56:49 +0000 (18:56 +0100)]
simple-dmabuf-drm: use opt bitmask instead of is_immediate

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoAllow simple-dmabuf-drm to pass y_inverted flag
Guido Günther [Fri, 16 Mar 2018 17:56:48 +0000 (18:56 +0100)]
Allow simple-dmabuf-drm to pass y_inverted flag

This allows to check if ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT is
interpreted correctly by the compositor.

We introduce an OPT_* bitmask to hold this flag and possible future
command line flags.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>