Commit graph

2184 commits

Author SHA1 Message Date
Hans de Goede
ebf60f7019 ply-progress-bar: Redraw on percentage update
All the other plymouth widgets do a (re)draw when one of their
properties get updated. Make ply-progress-bar also do this, this allows
dropping the draw calls directly after the 2 current callers of
ply_progress_bar_set_percent_done.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-02-23 14:56:54 +01:00
Hans de Goede
dfa1dcc621 ply-label: Make sure get_width_of_control / get_height_of_control return correct values
Users of ply_label may want to know the height / width of the text before
calling ply_label_show, so that they can e.g. vertically align it.

This commit adds a size_needs_update bool to the label plugin and uses this
to check if executing size_control is necessary before returning the
width / height and also modifies the ply-label code to load the plugin
from its get_width / get_height methods.

As an added advantage this will also skip unnecessary size_control calls
when calling ply_label_show on an already visible label.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-02-23 14:56:54 +01:00
Ray Strode
e3bb33dea7 Merge branch 'wip/over-allocation-fix' into 'master'
boot-server: fix type confusion when allocating connection object

See merge request plymouth/plymouth!27
2019-02-18 15:24:24 +00:00
Ray Strode
f7d8204198 boot-server: fix type confusion when allocating connection object
Right now we allocate enough room for a whole ply_boot_server_t
object for every connection object.

This commit mops up the over-allocation
2019-02-18 10:23:06 -05:00
Hans de Goede
24a7ee5c5d Merge branch 'drm-hotplug' into 'master'
Drm hotplug

See merge request plymouth/plymouth!23
2019-01-25 09:06:31 +00:00
Hans de Goede
e54f6a4731 ply-device-manager: Handle change events for monitor hotplugging
Not only handle add but also change events for drm-subsys devices,
change events are generated when the hardware detect a new monitor
has been plugged in.

This is esp. important with modern DisplayPort MST docking stations where
discovery / enumeration can take so long that the connected displays
are not enumerated by the kernel yet when the drm plugin first calls
drmModeGetResources(). Causing the monitors on these docks to sometimes
not show plymouth during boot (based on various timing parameters).

Note that if during the add event drm-renderer could not be bound, this
commit tries to re-bind the DRM renderer on change events in case a
monitor got plugged into a GPU which did not have anything connected before.
This often happens with the second GPU in a laptop with a hybrid GPU setup.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1652279
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-21 15:45:00 +01:00
Hans de Goede
f9e376797a ply-device-manager: Consume all events in one go
Drm devices generate a bunch of add and change events when the kms
driver loads, consume these all in one go.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-21 15:45:00 +01:00
Hans de Goede
ccdb1d1fe1 drm: Stop limiting preferred-mode picking to UEFI systems
When the code to pick the preferred-mode for outputs was first added, it
was limited to UEFI systems, since it was necessary there.

It was not enabled everywhere right away because there were some worries
it might cause regressions.

We've been shipping this for a while now and no regressions have been
reported, moreover with the new hotplug support we really want to pick the
preferred-mode rather then falling back to the first mode in the list.

Therefor this commits removes the check for UEFI systems from
should_use_preferred_mode().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-21 15:45:00 +01:00
Hans de Goede
c54870fc66 drm: Reset mode on display-port connected outputs with a bad link-status
With Display-Port links, esp. with DP MST links we may need to reset the
mode if the kernel decides to retrain the link.

If the kernel has retrained the link, the list of available modes may
have changed. If it changed and the mode we picked is no longer available
because of this, we treat this as an unplug + replug.

Since we may want to set another mode, the kernel does not automatically
restore the previous mode. So in case the mode did not change we need to
do an explicit mode-set.

This commits adds support for this, by:

1) Adding a scan_out_buffer_needs_reset member to ply_renderer_head
2) Storing the link-status when going over the connector properties
3) Checking the link-status when adding a connector to a head and setting
   the scan_out_buffer_needs_reset flag when the link-status is bad

This commit also makes ply_renderer_head_map set
scan_out_buffer_needs_reset, avoiding an unnecessary round-trip to the
kernel in the first reset_scan_out_buffer_if_needed call.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-17 14:37:57 +01:00
Hans de Goede
15ebdd6d5b drm: Implement handle_change_event
Now that we can call create_heads_for_active_connectors multiple times
we can implement handle_change_event.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 17:58:33 +01:00
Hans de Goede
475a51d057 drm: Ensure heads are mapped before flushing them
The drm plugin's map_to_device function will return true if mapping of
any of the heads has succeeded, potentially leaving some heads unmapped.

This causes the "assert (buffer != NULL)" in begin_flush to trigger when
flushing the heads as head->scan_out_buffer_id is 0.

It seems that even though this is a pre-existing problem we sofar have
not hit this, likely because ply_renderer_head_map in pratice never fails.

However with the new monitor hotplug support, a head may be added after
map_to_device is called, triggering the assert.

This commit fixes both the theoretical pre-existing problem and the
actual problem triggered by hotplug support by ensuring that the head
is mapped before flushing it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 17:02:46 +01:00
Hans de Goede
7774bd5e51 drm: Allow calling create_heads_for_active_connectors multiple times
To support hotplugging monitors while plymouth is running, we must
rebuild our outputs list and create and/or remove heads as necessary
on every change event.

This commit adds support for removing single outputs (rather then
tearing down the whole backend) and adds a new first step to
create_heads_for_active_connectors which goes over our view of the
outputs before the change and removes any changed outputs from the
heads they belong to, destroying the head if the last output/connector
is removed.

On the first call backend->output_len is 0, so this new first step
is a no-op.

On subsequent calls we can simply build the list as we do on the first
call, changed outputs will already be removed by the new first step
and for unchanged outputs we end up in ply_renderer_head_add_connector
which will ignore the already added connector.

Note this drops the "couldn't connect monitor to existing head" message,
this is confusing when create_heads_for_active_connectors is called more
then once and is unnecessary as ply_renderer_head_add_connector already
logs a message on both failure exit paths.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 17:02:45 +01:00
Hans de Goede
cd0479675e drm: Allow calling ply_renderer_head_add_connector with existing connector_id
Allow calling ply_renderer_head_add_connector with an existing
connector_id and ignore this call.

This allows calling create_heads_for_active_connectors multiple times,
only creating/adding heads for new connectors.

This is a preparation patch for adding support for hotplugging
monitors while plymouth is running.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 16:57:07 +01:00
Hans de Goede
7cb2eb1489 drm: Limit backend->resources lifetime to within query_device
We do not need / use backend->resources anywhere outside of the query_device
function and with the upcoming hotplug support we need to get a fresh set
of resources on change events, so limit the resources lifetime to
query_device.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 16:57:07 +01:00
Hans de Goede
d68fd78ae1 drm: Store and keep all the outputs in the backend
Put all outputs in the outputs array instead of just the connected ones
and store the outputs array and the controller_id-to-head hashtable in the
backend object instead of temporarily allocating them during enumeration.

Also add new heads to the heads list and to the controller_id-to-head
hashtable in ply_renderer_head_new where this really belongs. This
allows nicely balancing these 2 with removing the head from the list
and hash_table in the ply_renderer_head_remove function which is added
in a follow-up commit.

This is a preparation patch for adding support for hotplugging
monitors while plymouth is running.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 16:56:52 +01:00
Hans de Goede
4ba6d4f4a2 drm: Add get_output_info helper function
Add a new get_output_info helper function, which fill a ply_output_t with
all info related to the connecter based on a connector-id.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 09:43:00 +01:00
Hans de Goede
b3f1c7683d drm: Stop storing a pointer to drmModeConnector in ply_output_t
This is a preparation patch for hotplug support, for hotplug support we
want to keep the ply_output_t for connectors around, this change decouples
the lifetime of the drmModeConnector from the ply_output_t lifetime.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 09:43:00 +01:00
Hans de Goede
9b5d4df9f9 drm: Stop keeing a drmModeConnector instance around
Before this commit we were storing a pointer to the drmModeConnector
in struct _ply_renderer_head, solely so that we can free it when
destroying the head. This was necessary because we also stored a pointer
to the mode we picked, which comes from insided the drmModeConnector.

The drmModeModeInfo struct has no pointers, so we can simply store a copy
of it instead of a pointer, which removes the need to keep the
drmModeConnector around after probing the connectors.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 09:43:00 +01:00
Hans de Goede
80acc33ab3 drm: Refactor ply_renderer_head_add_connector and ply_renderer_head_new
Both these function take a bunch of info coming from the ply_output_t
struct and with upcoming changes they are going to be using even more
ply_output_t fields. Instead of passing all these fields one by one,
simply directly pass a pointer to ply_output_t.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 09:43:00 +01:00
Hans de Goede
88f1b1dc0e ply-renderer: Add ply_renderer_handle_change_event function
This function can be called to notify the renderer of udev change-events.

This is a preparation patch for adding support for hotplugging
monitors while plymouth is running.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 09:43:00 +01:00
Hans de Goede
0a6ddf4dc2 ply-array: Add ply_array_contains_uint32_element function
Add a new ply_array_contains_uint32_element which checks if the queried
ply-array contains an element with the passed in uint32_t value.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 09:43:00 +01:00
Hans de Goede
3497dccf3b Merge branch 'spinner-bgrt-theme-update' into 'master'
Spinner bgrt theme update

See merge request plymouth/plymouth!22
2019-01-16 08:32:25 +00:00
Hans de Goede
203fe586bb themes: Update spinner and bgrt diskcrypt dialog
Update the spinner and bgrt themses diskcrypt dialog to match the dialog
from the "Disk decrypt" mockup from:

https://wiki.gnome.org/Design/OS/BootProgress

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 09:29:32 +01:00
Hans de Goede
a7ab82171f themes: spinner: Add watermark alignment settings
Add watermark alignment settings, so that distros can simply drop
a watermark.png into the theme dir from another package and then have it
show up in the right place.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 09:29:32 +01:00
Hans de Goede
ee2025824a themes: bgrt: Remove duplicate images
The bgrt theme is using the exact same images as the spinner theme,
remove these and point ImageDir to the spinner theme dir instead.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 09:29:32 +01:00
Hans de Goede
6117fe683b plymouth-populate-initrd: Don't assume the ImageDir is the theme-dir
Before this commit plymouth-populate-initrd was only recursively copying the
/usr/share/plymouth/themes/$PLYMOUTH_THEME_NAME to the initrd, assuming
that ImageDir will point there.

This makes it impossible for 2 themes to share their ImageDir, which is
desirable for example for the spinner and bgrt themes, which use the same
images with slightly different settings.

This commit also makes plymouth-populate-initrd also copy the ImageDir
if it is different from the theme-dir, making it possible for ImageDir
to point to a different dir.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-16 09:29:32 +01:00
Hans de Goede
a9aaad0d62 Merge branch 'two-step-dialog-options' into 'master'
Two step dialog options

See merge request plymouth/plymouth!21
2019-01-16 08:28:27 +00:00
Hans de Goede
d62be07815 two-step: Make clearing the dialog-background when using the firmware background optional
Since the ask-for-password or ask-question dialog and the firmware background
may intersect so far we've been clearing the screen to black when showing a
dialog and using the firmware background.

This is not always desirable, this commit adds a new
"DialogClearsFirmwareBackground" option to the two-step based theme config
file, which enables this behavior when set.

The new default is to keep using the initial (firmware) background when
showing a dialog, which matches the non firmware-background paths.

Also update the bgrt theme to use the "DialogClearsFirmwareBackground"
option, keeping the current behavior for that theme.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-09 12:29:42 +01:00
Hans de Goede
27e671bff7 two-step: Add support for non center alignment of the (diskcrypt) dialog
Add DialogHorizontalAlignment and DialogVerticalAlignment options which
allow placing the (diskcrypt) dialog aligned at another place then the
center of the screen.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-09 12:03:55 +01:00
Hans de Goede
410ba63c81 two-step: Make the box image surrounding the unlock dialog optional
In some themes we want a simple style text entry without a dialog like
box around it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-09 12:03:55 +01:00
Hans de Goede
6cf1bb3e37 two-step: Rename UseBGRT to UseFirmwareBackground
Rename the UseBGRT theme configfile option to UseFirmwareBackground,
to make it clear what this does using language which most users will be
able to understand, rather then using the cryptic BGRT ACPI table reference.

While at it also switch to using the new ply_key_file_get_bool function, so
that users can edit an existing configfile with "UseFirmwareBackground=true"
in there and change it to "=false" and actually have that work as expected.

The switch to ply_key_file_get_bool also fixes a memleak as
ply_key_file_get_value returns a strdup-ed value which we were not free-ing.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-09 12:03:55 +01:00
Hans de Goede
e111ba8baf libply: Add ply_key_file_get_bool function
Add a function to read a boolean value from a ply-key-file.

This function will return true if the key exists and it has a value of "1",
"y", "yes" or "true" (case-insensitive). In all other cases it returns
false.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-01-09 11:42:34 +01:00
Hans de Goede
c8f12565fb Merge branch 'strtod-locale-fix' into 'master'
Strtod locale fix

See merge request plymouth/plymouth!20
2018-12-19 18:28:37 +00:00
Hans de Goede
fb6d4b4983 two-step: Use plymouth_strtod
Use the locale agnostic plymouth_strtod helper which always uses a "."
as decimal seperator. This fixes the various Alignment options not working
with some locales.

While at it also add a ply_trace to log the size and chosen centering for
the watermark image.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-12-19 12:37:40 +01:00
Hans de Goede
2dc81adb0f libply: Add ply_strtod helper
Add a ply_strtod helper which always uses "." as decimal separator
independent of the locale.

Using this fixes e.g. HorizontalAlignment in the two-step plugin
not working with some locales.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-12-19 12:37:40 +01:00
Hans de Goede
f7d5bb122f Merge branch 'ply-keyb-compiler-warning' into 'master'
ply-keyboard: Fix compiler warning

See merge request plymouth/plymouth!18
2018-12-09 14:25:16 +00:00
Hans de Goede
bac628cd05 ply-keyboard: Fix compiler warning
Fix: "warning: enumeration value ‘PLY_KEYBOARD_PROVIDER_TYPE_TERMINAL’
not handled in switch [-Wswitch-enum]" compiler warning.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-12-09 15:23:21 +01:00
Hans de Goede
5e1adec230 Merge branch 'plugin-iface' into 'master'
When a renderer goes away on a udev remove event, free keyboards associated with the renderer, before freeing the renderer. This avoids a null pointer dereference when ply_device_manager_deactivate_keyboards gets called later on:
https://bugs.launchpad.net/ubuntu/+source/plymouth/+bug/1794292

See merge request plymouth/plymouth!10
2018-12-09 14:19:08 +00:00
Mathieu Trudel-Lapierre
c46f446fe4 device-manager: free keyboards when deactivating a renderer
Based on an original patch by Gert van de Kraats, on Ubuntu Launchpad bug:
https://bugs.launchpad.net/ubuntu/+source/plymouth/+bug/1794292

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2018-12-04 15:15:28 -05:00
Mathieu Trudel-Lapierre
b082f42494 keyboard: add helper to get the keyboard's renderer, if applicable
Based on an original patch from Gert van de Kraats on Ubuntu's Launchpad:
https://bugs.launchpad.net/ubuntu/+source/plymouth/+bug/1794292

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
2018-12-04 15:15:19 -05:00
Hans de Goede
0cd0613759 Merge branch 'drm-pick-crtcs' into 'master'
Drm pick crtcs

See merge request plymouth/plymouth!16
2018-12-04 11:36:54 +00:00
Hans de Goede
d67e729739 drm: Pick a controller for unconfigured connectors
So far we've been relying on the kernel fbcon code to set up all outputs,
now that distros have started using deferred fbcon takeover for flickerfree
booting, we can no longer rely on this and in some cases we must pick
our own controllers.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-12-04 09:45:52 +01:00
Hans de Goede
76b37d5072 drm: Drop crtcs for clones for which we've picked different modes
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-12-04 09:44:06 +01:00
Hans de Goede
ef55ed99e7 drm: More connector enumeration refactoring
Some further refactoring to prepare for adding code to picking crtcs
for unconfigured connectors.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-12-04 09:41:51 +01:00
Hans de Goede
52bf6e3e95 drm: Store tiled and rotation in ply_output_t
This avoids the need to call ply_renderer_connector_get_rotation_and_tiled
twice and thus also the need to call drmModeGetProperty twice for all
properties.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-12-04 09:41:50 +01:00
Hans de Goede
bf8a2e893e drm: Refactor create_heads_for_active_connectors
Refactor create_heads_for_active_connectors to prepare it for adding a
step where we assign controllers to connected outputs which do not have
a controller assigned yet.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-12-04 09:41:31 +01:00
Hans de Goede
42bbee8c38 drm: Directly store the mode instead of the mode_index
The only way we use mode_index is to get the mode, so its easier to
directly store the mode when we create a head.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-12-03 16:52:08 +01:00
Hans de Goede
534aa0cfd5 drm: Drop unused encoder_id
We cache the encoder-id, but we never use it, so stop caching it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-12-03 16:52:08 +01:00
Hans de Goede
b24e5f38a4 Merge branch 'two-step-bgrt-upside-down-fix' into 'master'
two-step: Do not rotate bgrt background image for upside-down panels

See merge request plymouth/plymouth!17
2018-12-03 15:51:41 +00:00
Hans de Goede
10fddacd1e two-step: Do not rotate bgrt background image for upside-down panels
Upside-down LCD panels are fixed up in HW by the GOP, so the bgrt image is
not rotated in this case and we should not rotate it to compensate.

While at it also fixup the wrong indentation of the
ply_pixel_buffer_set_device_scale() call.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2018-12-03 16:50:18 +01:00