From a4039120651af1eb6f6b9525e6b872bda4063401 Mon Sep 17 00:00:00 2001 From: Adam Samalik Date: Wed, 21 Jun 2023 14:51:05 +0200 Subject: [PATCH] import sources --- .gitignore | 13 +- ...on-t-watch-for-udev-events-when-deac.patch | 489 +++++++++++++++ ...rop-superfluous-create_pixel_display.patch | 32 + ...all-back-to-text-mode-if-graphical-d.patch | 113 ++++ ...kip-graphical-renderer-setup-when-de.patch | 117 ++++ ...eparator-between-different-boot-logs.patch | 181 ++++++ ...te-initrd-drop-unused-local-variable.patch | 83 +++ ...splash-fix-memory-leak-in-error-path.patch | 86 +++ ...te-the-display-on-backspace-when-the.patch | 45 ++ 0003-event-loop-fix-leak-in-error-path.patch | 86 +++ ...r-Add-the-concept-of-device-rotation.patch | 249 ++++++++ ...panel-orientation-connector-property.patch | 102 ++++ ..._file_get_value-returns-duplicated-m.patch | 216 +++++++ ...y-plane-rotation-to-DRM_MODE_ROTATE_.patch | 148 +++++ 0005-script-fix-various-memory-leaks.patch | 556 ++++++++++++++++++ ...erver-free-the-argument-and-triggers.patch | 351 +++++++++++ ...er-switch-device-rotation-to-an-enum.patch | 80 +++ ...terminal-add-include-for-sysmacros.h.patch | 27 + plymouth-update-initrd | 0 19 files changed, 2973 insertions(+), 1 deletion(-) create mode 100644 0001-device-manager-don-t-watch-for-udev-events-when-deac.patch create mode 100644 0001-device-manager-drop-superfluous-create_pixel_display.patch create mode 100644 0001-device-manager-fall-back-to-text-mode-if-graphical-d.patch create mode 100644 0001-device-manager-skip-graphical-renderer-setup-when-de.patch create mode 100644 0001-logger-Add-a-separator-between-different-boot-logs.patch create mode 100644 0001-populate-initrd-drop-unused-local-variable.patch create mode 100644 0002-boot-splash-fix-memory-leak-in-error-path.patch create mode 100644 0002-main-Do-not-update-the-display-on-backspace-when-the.patch create mode 100644 0003-event-loop-fix-leak-in-error-path.patch create mode 100644 0003-pixel-buffer-Add-the-concept-of-device-rotation.patch create mode 100644 0004-drm-Check-for-panel-orientation-connector-property.patch create mode 100644 0004-key-file-ply_key_file_get_value-returns-duplicated-m.patch create mode 100644 0005-drm-Reset-primary-plane-rotation-to-DRM_MODE_ROTATE_.patch create mode 100644 0005-script-fix-various-memory-leaks.patch create mode 100644 0006-boot-server-free-the-argument-and-triggers.patch create mode 100644 0006-pixel-buffer-switch-device-rotation-to-an-enum.patch create mode 100644 0007-terminal-add-include-for-sysmacros.h.patch mode change 100755 => 100644 plymouth-update-initrd diff --git a/.gitignore b/.gitignore index 69b2064..732bb5e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,13 @@ -SOURCES/plymouth-1e36e303e08ba425fecbcff4dde22c8ee936638c.tar.bz2 +plymouth-0.8.4.tar.bz2 +/plymouth-0.8.4.tar.bz2 +/plymouth-0.8.5.tar.bz2 +/plymouth-0.8.5.1.tar.bz2 +/plymouth-0.8.6.tar.bz2 +/plymouth-0.8.6.1.tar.bz2 +/plymouth-0.8.6.2.tar.bz2 +/plymouth-0.8.7.tar.bz2 +/plymouth-0.8.8.tar.bz2 +/plymouth-0.8.9.tar.bz2 +/plymouth-0.9.3.tar.bz2 +/plymouth-0.9.3.tar.xz /plymouth-1e36e303e08ba425fecbcff4dde22c8ee936638c.tar.bz2 diff --git a/0001-device-manager-don-t-watch-for-udev-events-when-deac.patch b/0001-device-manager-don-t-watch-for-udev-events-when-deac.patch new file mode 100644 index 0000000..5072cf1 --- /dev/null +++ b/0001-device-manager-don-t-watch-for-udev-events-when-deac.patch @@ -0,0 +1,489 @@ +From b5bacf2b5e5d9e58cbe96fda0a56baf5dfa11358 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Wed, 10 Oct 2018 20:07:37 +0100 +Subject: [PATCH] device-manager: don't watch for udev events when deactivated + +If a device gets added when we're already deactivated, plymouth shouldn't +process the device, since processing it effectively activates plymouth. + +This commit pulls the udev monitor fd out of the event loop while +plymouth is deactivated so new events are deferred until reactivation. + +Modified by Iain Lane : Also deactivate the +timer that finds all devices known to udev after an interval, when +paused. +--- + src/libply-splash-core/ply-device-manager.c | 74 +++++++++++++++++---- + src/libply-splash-core/ply-device-manager.h | 2 + + src/main.c | 3 + + 3 files changed, 67 insertions(+), 12 deletions(-) + +diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c +index b637fb8..82f0137 100644 +--- a/src/libply-splash-core/ply-device-manager.c ++++ b/src/libply-splash-core/ply-device-manager.c +@@ -36,74 +36,78 @@ + + #include "ply-logger.h" + #include "ply-event-loop.h" + #include "ply-hashtable.h" + #include "ply-list.h" + #include "ply-utils.h" + + #define SUBSYSTEM_DRM "drm" + #define SUBSYSTEM_FRAME_BUFFER "graphics" + + #ifdef HAVE_UDEV + static void create_devices_from_udev (ply_device_manager_t *manager); + #endif + + static bool create_devices_for_terminal_and_renderer_type (ply_device_manager_t *manager, + const char *device_path, + ply_terminal_t *terminal, + ply_renderer_type_t renderer_type); + struct _ply_device_manager + { + ply_device_manager_flags_t flags; + ply_event_loop_t *loop; + ply_hashtable_t *terminals; + ply_hashtable_t *renderers; + ply_terminal_t *local_console_terminal; + ply_list_t *keyboards; + ply_list_t *text_displays; + ply_list_t *pixel_displays; + struct udev *udev_context; + struct udev_monitor *udev_monitor; ++ ply_fd_watch_t *fd_watch; + + ply_keyboard_added_handler_t keyboard_added_handler; + ply_keyboard_removed_handler_t keyboard_removed_handler; + ply_pixel_display_added_handler_t pixel_display_added_handler; + ply_pixel_display_removed_handler_t pixel_display_removed_handler; + ply_text_display_added_handler_t text_display_added_handler; + ply_text_display_removed_handler_t text_display_removed_handler; + void *event_handler_data; + + uint32_t local_console_managed : 1; + uint32_t local_console_is_text : 1; + uint32_t serial_consoles_detected : 1; + uint32_t renderers_activated : 1; + uint32_t keyboards_activated : 1; ++ ++ uint32_t paused : 1; ++ uint32_t device_timeout_elapsed : 1; + }; + + static void + detach_from_event_loop (ply_device_manager_t *manager) + { + assert (manager != NULL); + + manager->loop = NULL; + } + + static void + attach_to_event_loop (ply_device_manager_t *manager, + ply_event_loop_t *loop) + { + assert (manager != NULL); + assert (loop != NULL); + assert (manager->loop == NULL); + + manager->loop = loop; + + ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t) + detach_from_event_loop, + manager); + } + + static void + free_displays_for_renderer (ply_device_manager_t *manager, + ply_renderer_t *renderer) + { + ply_list_node_t *node; +@@ -348,77 +352,92 @@ on_udev_event (ply_device_manager_t *manager) + return; + + if (strcmp (action, "add") == 0) { + const char *subsystem; + + subsystem = udev_device_get_subsystem (device); + + if (strcmp (subsystem, SUBSYSTEM_DRM) == 0) { + if (manager->local_console_managed && manager->local_console_is_text) + ply_trace ("ignoring since we're already using text splash for local console"); + else + create_devices_for_udev_device (manager, device); + } else { + ply_trace ("ignoring since we only handle subsystem %s devices after timeout", subsystem); + } + } else if (strcmp (action, "remove") == 0) { + free_devices_for_udev_device (manager, device); + } + + udev_device_unref (device); + } + + static void + watch_for_udev_events (ply_device_manager_t *manager) + { + int fd; + + assert (manager != NULL); + assert (manager->udev_monitor == NULL); + ++ if (manager->fd_watch != NULL) ++ return; ++ + ply_trace ("watching for udev graphics device add and remove events"); + +- manager->udev_monitor = udev_monitor_new_from_netlink (manager->udev_context, "udev"); ++ if (manager->udev_monitor == NULL) { ++ manager->udev_monitor = udev_monitor_new_from_netlink (manager->udev_context, "udev"); + +- udev_monitor_filter_add_match_subsystem_devtype (manager->udev_monitor, SUBSYSTEM_DRM, NULL); +- udev_monitor_filter_add_match_subsystem_devtype (manager->udev_monitor, SUBSYSTEM_FRAME_BUFFER, NULL); +- udev_monitor_filter_add_match_tag (manager->udev_monitor, "seat"); +- udev_monitor_enable_receiving (manager->udev_monitor); ++ udev_monitor_filter_add_match_subsystem_devtype (manager->udev_monitor, SUBSYSTEM_DRM, NULL); ++ udev_monitor_filter_add_match_subsystem_devtype (manager->udev_monitor, SUBSYSTEM_FRAME_BUFFER, NULL); ++ udev_monitor_filter_add_match_tag (manager->udev_monitor, "seat"); ++ udev_monitor_enable_receiving (manager->udev_monitor); ++ } + + fd = udev_monitor_get_fd (manager->udev_monitor); +- ply_event_loop_watch_fd (manager->loop, +- fd, +- PLY_EVENT_LOOP_FD_STATUS_HAS_DATA, +- (ply_event_handler_t) +- on_udev_event, +- NULL, +- manager); ++ manager->fd_watch = ply_event_loop_watch_fd (manager->loop, ++ fd, ++ PLY_EVENT_LOOP_FD_STATUS_HAS_DATA, ++ (ply_event_handler_t) ++ on_udev_event, ++ NULL, ++ manager); ++} ++ ++static void ++stop_watching_for_udev_events (ply_device_manager_t *manager) ++{ ++ if (manager->fd_watch == NULL) ++ return; ++ ++ ply_event_loop_stop_watching_fd (manager->loop, manager->fd_watch); ++ manager->fd_watch = NULL; + } + #endif + + static void + free_terminal (char *device, + ply_terminal_t *terminal, + ply_device_manager_t *manager) + { + ply_hashtable_remove (manager->terminals, device); + + ply_terminal_free (terminal); + } + + static void + free_terminals (ply_device_manager_t *manager) + { + ply_hashtable_foreach (manager->terminals, + (ply_hashtable_foreach_func_t *) + free_terminal, + manager); + } + + static ply_terminal_t * + get_terminal (ply_device_manager_t *manager, + const char *device_name) + { + char *full_name = NULL; + ply_terminal_t *terminal; + + if (strncmp (device_name, "/dev/", strlen ("/dev/")) == 0) +@@ -774,60 +793,67 @@ create_devices_from_terminals (ply_device_manager_t *manager) + + if (has_serial_consoles) { + ply_trace ("serial consoles detected, managing them with details forced"); + manager->serial_consoles_detected = true; + + ply_hashtable_foreach (manager->terminals, + (ply_hashtable_foreach_func_t *) + create_devices_for_terminal, + manager); + return true; + } + + return false; + } + + static void + create_non_graphical_devices (ply_device_manager_t *manager) + { + create_devices_for_terminal_and_renderer_type (manager, + NULL, + manager->local_console_terminal, + PLY_RENDERER_TYPE_NONE); + } + + #ifdef HAVE_UDEV + static void + create_devices_from_udev (ply_device_manager_t *manager) + { + bool found_drm_device, found_fb_device; + ++ manager->device_timeout_elapsed = true; ++ ++ if (manager->paused) { ++ ply_trace ("create_devices_from_udev timeout elapsed while paused, deferring execution"); ++ return; ++ } ++ + ply_trace ("Timeout elapsed, looking for devices from udev"); + + found_drm_device = create_devices_for_subsystem (manager, SUBSYSTEM_DRM); + found_fb_device = create_devices_for_subsystem (manager, SUBSYSTEM_FRAME_BUFFER); + + if (found_drm_device || found_fb_device) + return; + + ply_trace ("Creating non-graphical devices, since there's no suitable graphics hardware"); + create_non_graphical_devices (manager); + } + #endif + + static void + create_fallback_devices (ply_device_manager_t *manager) + { + create_devices_for_terminal_and_renderer_type (manager, + NULL, + manager->local_console_terminal, + PLY_RENDERER_TYPE_AUTO); + } + + void + ply_device_manager_watch_devices (ply_device_manager_t *manager, + double device_timeout, + ply_keyboard_added_handler_t keyboard_added_handler, + ply_keyboard_removed_handler_t keyboard_removed_handler, + ply_pixel_display_added_handler_t pixel_display_added_handler, + ply_pixel_display_removed_handler_t pixel_display_removed_handler, + ply_text_display_added_handler_t text_display_added_handler, +@@ -965,30 +991,54 @@ ply_device_manager_activate_keyboards (ply_device_manager_t *manager) + + ply_keyboard_watch_for_input (keyboard); + + node = next_node; + } + + manager->keyboards_activated = true; + } + + void + ply_device_manager_deactivate_keyboards (ply_device_manager_t *manager) + { + ply_list_node_t *node; + + ply_trace ("deactivating keyboards"); + node = ply_list_get_first_node (manager->keyboards); + while (node != NULL) { + ply_keyboard_t *keyboard; + ply_list_node_t *next_node; + + keyboard = ply_list_node_get_data (node); + next_node = ply_list_get_next_node (manager->keyboards, node); + + ply_keyboard_stop_watching_for_input (keyboard); + + node = next_node; + } + + manager->keyboards_activated = false; + } ++ ++void ++ply_device_manager_pause (ply_device_manager_t *manager) ++{ ++ ply_trace ("ply_device_manager_pause() called, stopping watching for udev events"); ++ manager->paused = true; ++#ifdef HAVE_UDEV ++ stop_watching_for_udev_events (manager); ++#endif ++} ++ ++void ++ply_device_manager_unpause (ply_device_manager_t *manager) ++{ ++ ply_trace ("ply_device_manager_unpause() called, resuming watching for udev events"); ++ manager->paused = false; ++#ifdef HAVE_UDEV ++ if (manager->device_timeout_elapsed) { ++ ply_trace ("ply_device_manager_unpause(): timeout elapsed while paused, looking for udev devices"); ++ create_devices_from_udev (manager); ++ } ++ watch_for_udev_events (manager); ++#endif ++} +diff --git a/src/libply-splash-core/ply-device-manager.h b/src/libply-splash-core/ply-device-manager.h +index ad05897..389b636 100644 +--- a/src/libply-splash-core/ply-device-manager.h ++++ b/src/libply-splash-core/ply-device-manager.h +@@ -28,46 +28,48 @@ + #include "ply-text-display.h" + + typedef enum + { + PLY_DEVICE_MANAGER_FLAGS_NONE = 0, + PLY_DEVICE_MANAGER_FLAGS_IGNORE_SERIAL_CONSOLES = 1 << 0, + PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV = 1 << 1, + PLY_DEVICE_MANAGER_FLAGS_SKIP_RENDERERS = 1 << 2 + } ply_device_manager_flags_t; + + typedef struct _ply_device_manager ply_device_manager_t; + typedef void (* ply_keyboard_added_handler_t) (void *, ply_keyboard_t *); + typedef void (* ply_keyboard_removed_handler_t) (void *, ply_keyboard_t *); + typedef void (* ply_pixel_display_added_handler_t) (void *, ply_pixel_display_t *); + typedef void (* ply_pixel_display_removed_handler_t) (void *, ply_pixel_display_t *); + typedef void (* ply_text_display_added_handler_t) (void *, ply_text_display_t *); + typedef void (* ply_text_display_removed_handler_t) (void *, ply_text_display_t *); + + #ifndef PLY_HIDE_FUNCTION_DECLARATIONS + ply_device_manager_t *ply_device_manager_new (const char *default_tty, + ply_device_manager_flags_t flags); + void ply_device_manager_watch_devices (ply_device_manager_t *manager, + double device_timeout, + ply_keyboard_added_handler_t keyboard_added_handler, + ply_keyboard_removed_handler_t keyboard_removed_handler, + ply_pixel_display_added_handler_t pixel_display_added_handler, + ply_pixel_display_removed_handler_t pixel_display_removed_handler, + ply_text_display_added_handler_t text_display_added_handler, + ply_text_display_removed_handler_t text_display_removed_handler, + void *data); ++void ply_device_manager_pause (ply_device_manager_t *manager); ++void ply_device_manager_unpause (ply_device_manager_t *manager); + bool ply_device_manager_has_serial_consoles (ply_device_manager_t *manager); + bool ply_device_manager_has_displays (ply_device_manager_t *manager); + ply_list_t *ply_device_manager_get_keyboards (ply_device_manager_t *manager); + ply_list_t *ply_device_manager_get_pixel_displays (ply_device_manager_t *manager); + ply_list_t *ply_device_manager_get_text_displays (ply_device_manager_t *manager); + void ply_device_manager_free (ply_device_manager_t *manager); + void ply_device_manager_activate_keyboards (ply_device_manager_t *manager); + void ply_device_manager_deactivate_keyboards (ply_device_manager_t *manager); + void ply_device_manager_activate_renderers (ply_device_manager_t *manager); + void ply_device_manager_deactivate_renderers (ply_device_manager_t *manager); + ply_terminal_t *ply_device_manager_get_default_terminal (ply_device_manager_t *manager); + + #endif + + #endif + /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */ +diff --git a/src/main.c b/src/main.c +index e44de7b..3253aa9 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -1305,94 +1305,97 @@ on_boot_splash_idle (state_t *state) + ply_trace ("quitting program"); + quit_program (state); + } else if (state->deactivate_trigger != NULL) { + ply_trace ("deactivating splash"); + deactivate_splash (state); + } + } + + static void + on_deactivate (state_t *state, + ply_trigger_t *deactivate_trigger) + { + if (state->is_inactive) { + ply_trigger_pull (deactivate_trigger, NULL); + return; + } + + if (state->deactivate_trigger != NULL) { + ply_trigger_add_handler (state->deactivate_trigger, + (ply_trigger_handler_t) + ply_trigger_pull, + deactivate_trigger); + return; + } + + state->deactivate_trigger = deactivate_trigger; + + ply_trace ("deactivating"); + cancel_pending_delayed_show (state); + ++ ply_device_manager_pause (state->device_manager); + ply_device_manager_deactivate_keyboards (state->device_manager); + + if (state->boot_splash != NULL) { + ply_boot_splash_become_idle (state->boot_splash, + (ply_boot_splash_on_idle_handler_t) + on_boot_splash_idle, + state); + } else { + ply_trace ("deactivating splash"); + deactivate_splash (state); + } + } + + static void + on_reactivate (state_t *state) + { + if (!state->is_inactive) + return; + + if (state->local_console_terminal != NULL) { + ply_terminal_open (state->local_console_terminal); + ply_terminal_watch_for_vt_changes (state->local_console_terminal); + ply_terminal_set_unbuffered_input (state->local_console_terminal); + ply_terminal_ignore_mode_changes (state->local_console_terminal, false); + } + + if ((state->session != NULL) && state->should_be_attached) { + ply_trace ("reactivating terminal session"); + attach_to_running_session (state); + } + + ply_device_manager_activate_keyboards (state->device_manager); + ply_device_manager_activate_renderers (state->device_manager); + ++ ply_device_manager_unpause (state->device_manager); ++ + state->is_inactive = false; + + update_display (state); + } + + static void + on_quit (state_t *state, + bool retain_splash, + ply_trigger_t *quit_trigger) + { + ply_trace ("quitting (retain splash: %s)", retain_splash ? "true" : "false"); + + if (state->quit_trigger != NULL) { + ply_trace ("quit trigger already pending, so chaining to it"); + ply_trigger_add_handler (state->quit_trigger, + (ply_trigger_handler_t) + ply_trigger_pull, + quit_trigger); + return; + } + + if (state->system_initialized) { + ply_trace ("system initialized so saving boot-duration file"); + ply_create_directory (PLYMOUTH_TIME_DIRECTORY); + ply_progress_save_cache (state->progress, + get_cache_file_for_mode (state->mode)); + } else { + ply_trace ("system not initialized so skipping saving boot-duration file"); + } + state->quit_trigger = quit_trigger; +-- +2.21.0 + diff --git a/0001-device-manager-drop-superfluous-create_pixel_display.patch b/0001-device-manager-drop-superfluous-create_pixel_display.patch new file mode 100644 index 0000000..92ec6ce --- /dev/null +++ b/0001-device-manager-drop-superfluous-create_pixel_display.patch @@ -0,0 +1,32 @@ +From 6e9e95dc0fe89a3c52f50e44ff0096a6e65e46a6 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Wed, 20 Dec 2017 10:49:19 -0500 +Subject: [PATCH 1/6] device-manager: drop superfluous + create_pixel_displays_for_renderer call + +commit 29e27637694eefc962d53333c729e6cac1c66518 tried to move +create_pixel_displays_for_renderer down a couple of lines, but it +inadvertently copied it instead of moved it. + +This commit fixes that. + +https://bugs.freedesktop.org/show_bug.cgi?id=104353 +--- + src/libply-splash-core/ply-device-manager.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c +index cf56f4e..fbf4723 100644 +--- a/src/libply-splash-core/ply-device-manager.c ++++ b/src/libply-splash-core/ply-device-manager.c +@@ -713,7 +713,6 @@ create_devices_for_terminal_and_renderer_type (ply_device_manager_t *manager, + if (manager->keyboard_added_handler != NULL) + manager->keyboard_added_handler (manager->event_handler_data, keyboard); + +- create_pixel_displays_for_renderer (manager, renderer); + ply_hashtable_insert (manager->renderers, strdup (ply_renderer_get_device_name (renderer)), renderer); + create_pixel_displays_for_renderer (manager, renderer); + +-- +2.17.0 + diff --git a/0001-device-manager-fall-back-to-text-mode-if-graphical-d.patch b/0001-device-manager-fall-back-to-text-mode-if-graphical-d.patch new file mode 100644 index 0000000..84e3924 --- /dev/null +++ b/0001-device-manager-fall-back-to-text-mode-if-graphical-d.patch @@ -0,0 +1,113 @@ +From bdfcf889f8cda47190d98fa8a3e401a1db38074c Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Tue, 7 Nov 2017 13:49:30 -0500 +Subject: [PATCH] device-manager: fall back to text mode if graphical devices + fail + +Right now we assume if we find a /dev/dri/card0 that it will work. +That may not be true. The proprietary nvidia driver, for instance, +provides /dev/dri/card0 but disables modesetting by default. + +This commit makes sure we fall back to text mode if /dev/dri/card0 +is insufficient for our needs. + +https://bugs.freedesktop.org/show_bug.cgi?id=103612 +--- + src/libply-splash-core/ply-device-manager.c | 26 ++++++++++++--------- + 1 file changed, 15 insertions(+), 11 deletions(-) + +diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c +index b4c33d4..cf56f4e 100644 +--- a/src/libply-splash-core/ply-device-manager.c ++++ b/src/libply-splash-core/ply-device-manager.c +@@ -47,7 +47,7 @@ + static void create_devices_from_udev (ply_device_manager_t *manager); + #endif + +-static void create_devices_for_terminal_and_renderer_type (ply_device_manager_t *manager, ++static bool create_devices_for_terminal_and_renderer_type (ply_device_manager_t *manager, + const char *device_path, + ply_terminal_t *terminal, + ply_renderer_type_t renderer_type); +@@ -212,11 +212,12 @@ fb_device_has_drm_device (ply_device_manager_t *manager, + return has_drm_device; + } + +-static void ++static bool + create_devices_for_udev_device (ply_device_manager_t *manager, + struct udev_device *device) + { + const char *device_path; ++ bool created = false; + + device_path = udev_device_get_devnode (device); + +@@ -245,12 +246,14 @@ create_devices_for_udev_device (ply_device_manager_t *manager, + terminal = manager->local_console_terminal; + } + +- create_devices_for_terminal_and_renderer_type (manager, +- device_path, +- terminal, +- renderer_type); ++ created = create_devices_for_terminal_and_renderer_type (manager, ++ device_path, ++ terminal, ++ renderer_type); + } + } ++ ++ return created; + } + + static void +@@ -310,8 +313,7 @@ create_devices_for_subsystem (ply_device_manager_t *manager, + node = udev_device_get_devnode (device); + if (node != NULL) { + ply_trace ("found node %s", node); +- found_device = true; +- create_devices_for_udev_device (manager, device); ++ found_device = create_devices_for_udev_device (manager, device); + } + } else { + ply_trace ("device doesn't have a devices tag"); +@@ -656,7 +658,7 @@ create_text_displays_for_terminal (ply_device_manager_t *manager, + manager->text_display_added_handler (manager->event_handler_data, display); + } + +-static void ++static bool + create_devices_for_terminal_and_renderer_type (ply_device_manager_t *manager, + const char *device_path, + ply_terminal_t *terminal, +@@ -670,7 +672,7 @@ create_devices_for_terminal_and_renderer_type (ply_device_manager_t *manager, + + if (renderer != NULL) { + ply_trace ("ignoring device %s since it's already managed", device_path); +- return; ++ return true; + } + + ply_trace ("creating devices for %s (renderer type: %u) (terminal: %s)", +@@ -686,7 +688,7 @@ create_devices_for_terminal_and_renderer_type (ply_device_manager_t *manager, + renderer = NULL; + + if (renderer_type != PLY_RENDERER_TYPE_AUTO) +- return; ++ return false; + } + + if (renderer != NULL) { +@@ -743,6 +745,8 @@ create_devices_for_terminal_and_renderer_type (ply_device_manager_t *manager, + ply_trace ("activating keyboards"); + ply_keyboard_watch_for_input (keyboard); + } ++ ++ return true; + } + + static void +-- +2.17.1 + diff --git a/0001-device-manager-skip-graphical-renderer-setup-when-de.patch b/0001-device-manager-skip-graphical-renderer-setup-when-de.patch new file mode 100644 index 0000000..0795c49 --- /dev/null +++ b/0001-device-manager-skip-graphical-renderer-setup-when-de.patch @@ -0,0 +1,117 @@ +From 014c2158898067176738ec36c9c90cc266a7e35b Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Wed, 6 Jun 2018 17:06:14 -0700 +Subject: [PATCH] device-manager: skip graphical renderer setup when details + forced + +If neither "rhgb" nor "splash" is on the kernel cmdline, then +plymouth forces the "details" splash. This splash is merely +a passthrough plugin, where it makes boot looks like plymouth +isn't even running. + +In this case, the code sets PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV. +The idea is to not bother waiting for udev events notifying +plymouth when graphics devices show up, since it doesn't need +to use the grpahics devices directly anyway. + +Unfortunately, it does still erroneously try to setup graphical +renderers in this case, including the /dev/fb renderer. + +Before commit e4f86e3c, these graphical renderers failed because +they were given the wrong device name, but since that fix, they're +suceeding. We definitely don't want the /dev/fb renderer to +load if we're ignoring udev on efi systems, since during very +early boot /dev/fb is backed by efifb, something we never want to +use. efifb is supposed to get replaced during the boot process +by other fb implementations like say radeondrmfb, virtiodrmfb or +bochsdrmfb, and some of those implementations can't handle the +transition if /dev/fb is open at switchover time. + +This commit adds a new flag to tell the device manager to +not bother trying to setup graphical renderers when details are +forced. + +http://bugzilla.redhat.com/1518464 +--- + src/libply-splash-core/ply-device-manager.c | 20 ++++++++++++++++---- + src/libply-splash-core/ply-device-manager.h | 3 ++- + src/main.c | 4 +++- + 3 files changed, 21 insertions(+), 6 deletions(-) + +diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c +index fbf4723..b637fb8 100644 +--- a/src/libply-splash-core/ply-device-manager.c ++++ b/src/libply-splash-core/ply-device-manager.c +@@ -786,6 +786,15 @@ create_devices_from_terminals (ply_device_manager_t *manager) + return false; + } + ++static void ++create_non_graphical_devices (ply_device_manager_t *manager) ++{ ++ create_devices_for_terminal_and_renderer_type (manager, ++ NULL, ++ manager->local_console_terminal, ++ PLY_RENDERER_TYPE_NONE); ++} ++ + #ifdef HAVE_UDEV + static void + create_devices_from_udev (ply_device_manager_t *manager) +@@ -801,10 +810,7 @@ create_devices_from_udev (ply_device_manager_t *manager) + return; + + ply_trace ("Creating non-graphical devices, since there's no suitable graphics hardware"); +- create_devices_for_terminal_and_renderer_type (manager, +- NULL, +- manager->local_console_terminal, +- PLY_RENDERER_TYPE_NONE); ++ create_non_graphical_devices (manager); + } + #endif + +@@ -845,6 +851,12 @@ ply_device_manager_watch_devices (ply_device_manager_t *manager, + if (done_with_initial_devices_setup) + return; + ++ if ((manager->flags & PLY_DEVICE_MANAGER_FLAGS_SKIP_RENDERERS)) { ++ ply_trace ("Creating non-graphical devices, since renderers are being explicitly skipped"); ++ create_non_graphical_devices (manager); ++ return; ++ } ++ + if ((manager->flags & PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV)) { + ply_trace ("udev support disabled, creating fallback devices"); + create_fallback_devices (manager); +diff --git a/src/libply-splash-core/ply-device-manager.h b/src/libply-splash-core/ply-device-manager.h +index 058f6e8..ad05897 100644 +--- a/src/libply-splash-core/ply-device-manager.h ++++ b/src/libply-splash-core/ply-device-manager.h +@@ -31,7 +31,8 @@ typedef enum + { + PLY_DEVICE_MANAGER_FLAGS_NONE = 0, + PLY_DEVICE_MANAGER_FLAGS_IGNORE_SERIAL_CONSOLES = 1 << 0, +- PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV = 1 << 1 ++ PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV = 1 << 1, ++ PLY_DEVICE_MANAGER_FLAGS_SKIP_RENDERERS = 1 << 2 + } ply_device_manager_flags_t; + + typedef struct _ply_device_manager ply_device_manager_t; +diff --git a/src/main.c b/src/main.c +index f1e0fa7..841fe6b 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -2358,7 +2358,9 @@ main (int argc, + device_manager_flags |= PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV; + + if (!plymouth_should_show_default_splash (&state)) { +- /* don't bother listening for udev events if we're forcing details */ ++ /* don't bother listening for udev events or setting up a graphical renderer ++ * if we're forcing details */ ++ device_manager_flags |= PLY_DEVICE_MANAGER_FLAGS_SKIP_RENDERERS; + device_manager_flags |= PLY_DEVICE_MANAGER_FLAGS_IGNORE_UDEV; + + /* don't ever delay showing the detailed splash */ +-- +2.17.1 + diff --git a/0001-logger-Add-a-separator-between-different-boot-logs.patch b/0001-logger-Add-a-separator-between-different-boot-logs.patch new file mode 100644 index 0000000..8d890d1 --- /dev/null +++ b/0001-logger-Add-a-separator-between-different-boot-logs.patch @@ -0,0 +1,181 @@ +From 5fc9f555176bbbc354d651e6e31f618aea0b2b7d Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Tue, 17 Jul 2018 09:46:12 +0200 +Subject: [PATCH] logger: Add a separator between different boot logs + +Since we concatenate boot logs one after the other in /var/log/boot.log +it is hard to tell where the logs from one boot end the next boot starts. + +This commit makes plymouth write out a separator including a time + date +of the date, when the log file gets opened to add new boot messages to it. + +Note ply_logger_open_file() is only called from ply_terminal_session_open_log() +which in turn is only used for /var/log/boot.log, so this only effects +/var/log/boot.log. + +Closes #29 + +Signed-off-by: Hans de Goede +--- + src/libply/ply-logger.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/src/libply/ply-logger.c b/src/libply/ply-logger.c +index 1b56ea8..3dbc3ca 100644 +--- a/src/libply/ply-logger.c ++++ b/src/libply/ply-logger.c +@@ -7,60 +7,61 @@ + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * Written by: Ray Strode + */ + #include "config.h" + #include "ply-logger.h" + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include ++#include + #include + + #include "ply-utils.h" + #include "ply-list.h" + + #ifndef PLY_LOGGER_OPEN_FLAGS + #define PLY_LOGGER_OPEN_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_NOFOLLOW | O_CLOEXEC) + #endif + + #ifndef PLY_LOGGER_MAX_INJECTION_SIZE + #define PLY_LOGGER_MAX_INJECTION_SIZE 4096 + #endif + + #ifndef PLY_LOGGER_MAX_BUFFER_CAPACITY + #define PLY_LOGGER_MAX_BUFFER_CAPACITY (8 * 4096) + #endif + + typedef struct + { + ply_logger_filter_handler_t handler; + void *user_data; + } ply_logger_filter_t; + + struct _ply_logger + { + int output_fd; + char *filename; + + char *buffer; + size_t buffer_size; +@@ -285,77 +286,89 @@ ply_logger_free_filters (ply_logger_t *logger) + free (filter); + node = next_node; + } + + ply_list_free (logger->filters); + } + + void + ply_logger_free (ply_logger_t *logger) + { + if (logger == NULL) + return; + + if (logger->output_fd >= 0) { + if (ply_logger_is_logging (logger)) + ply_logger_flush (logger); + close (logger->output_fd); + } + + ply_logger_free_filters (logger); + + free (logger->filename); + free (logger->buffer); + free (logger); + } + + bool + ply_logger_open_file (ply_logger_t *logger, + const char *filename) + { ++ char header[80]; ++ struct tm* tm; ++ time_t t; + int fd; + mode_t mode; + + assert (logger != NULL); + assert (filename != NULL); + + fd = open (filename, PLY_LOGGER_OPEN_FLAGS, 0600); + + if (fd < 0) + return false; + + ply_logger_set_output_fd (logger, fd); + + free (logger->filename); + + logger->filename = strdup (filename); + ++ time (&t); ++ tm = localtime (&t); ++ if (tm) { ++ /* This uses uname -v date format */ ++ strftime (header, sizeof(header), ++ "------------ %a %b %d %T %Z %Y ------------\n", tm); ++ ply_logger_write (logger, header, strlen(header), true); ++ } ++ + return true; + } + + void + ply_logger_close_file (ply_logger_t *logger) + { + assert (logger != NULL); + + if (logger->output_fd < 0) + return; + + close (logger->output_fd); + ply_logger_set_output_fd (logger, -1); + } + + void + ply_logger_set_output_fd (ply_logger_t *logger, + int fd) + { + assert (logger != NULL); + + logger->output_fd = fd; + } + + int + ply_logger_get_output_fd (ply_logger_t *logger) + { + assert (logger != NULL); + + return logger->output_fd; +-- +2.18.1 + diff --git a/0001-populate-initrd-drop-unused-local-variable.patch b/0001-populate-initrd-drop-unused-local-variable.patch new file mode 100644 index 0000000..d463294 --- /dev/null +++ b/0001-populate-initrd-drop-unused-local-variable.patch @@ -0,0 +1,83 @@ +From f31312257094b3336c38cc8bdce1ded9188d37c3 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Mon, 15 Oct 2018 21:02:50 -0400 +Subject: [PATCH 1/6] populate-initrd: drop unused local variable + +the inst_library function declares a variable `_lib` +that's completely unused. + +This commit removes the declaration. +--- + scripts/plymouth-populate-initrd.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scripts/plymouth-populate-initrd.in b/scripts/plymouth-populate-initrd.in +index e3326e9..5f3bb85 100755 +--- a/scripts/plymouth-populate-initrd.in ++++ b/scripts/plymouth-populate-initrd.in +@@ -141,61 +141,61 @@ inst_simple() { + + # find symlinks linked to given library file + # $1 = library file + # Function searches for symlinks by stripping version numbers appended to + # library filename, checks if it points to the same target and finally + # prints the list of symlinks to stdout. + # + # Example: + # rev_lib_symlinks libfoo.so.8.1 + # output: libfoo.so.8 libfoo.so + # (Only if libfoo.so.8 and libfoo.so exists on host system.) + rev_lib_symlinks() { + [[ ! $1 ]] && return 0 + + local fn="$1" orig="$(readlink -f "$1")" links='' + + [[ ${fn} =~ .*\.so\..* ]] || return 1 + + until [[ ${fn##*.} == so ]]; do + fn="${fn%.*}" + [[ -L ${fn} && $(readlink -f "${fn}") == ${orig} ]] && links+=" ${fn}" + done + + echo "${links}" + } + + # Same as above, but specialized to handle dynamic libraries. + # It handles making symlinks according to how the original library + # is referenced. + inst_library() { +- local _src="$1" _dest=${2:-$1} _lib _reallib _symlink ++ local _src="$1" _dest=${2:-$1} _reallib _symlink + strstr "$1" "/" || return 1 + [[ -e $initdir/$_dest ]] && return 0 + if [[ -L $_src ]]; then + # install checksum files also + if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then + inst "${_src%/*}/.${_src##*/}.hmac" "${_dest%/*}/.${_dest##*/}.hmac" + fi + _reallib=$(readlink -f "$_src") + inst_simple "$_reallib" "$_reallib" + inst_dir "${_dest%/*}" + [[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/} + ln -sfn $(convert_abs_rel "${_dest}" "${_reallib}") "${initdir}/${_dest}" + else + inst_simple "$_src" "$_dest" + fi + + # Create additional symlinks. See rev_symlinks description. + for _symlink in $(rev_lib_symlinks $_src) $(rev_lib_symlinks $_reallib); do + [[ ! -e $initdir/$_symlink ]] && { + ddebug "Creating extra symlink: $_symlink" + inst_symlink $_symlink + } + done + } + + # find a binary. If we were not passed the full path directly, + # search in the usual places to find the binary. + find_binary() { + if [[ -z ${1##/*} ]]; then + if [[ -x $1 ]] || { strstr "$1" ".so" && ldd $1 &>/dev/null; }; then +-- +2.17.1 + diff --git a/0002-boot-splash-fix-memory-leak-in-error-path.patch b/0002-boot-splash-fix-memory-leak-in-error-path.patch new file mode 100644 index 0000000..f745719 --- /dev/null +++ b/0002-boot-splash-fix-memory-leak-in-error-path.patch @@ -0,0 +1,86 @@ +From c9a698d7840fca23cbaa205262a094e4f8648bb3 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Mon, 15 Oct 2018 21:04:47 -0400 +Subject: [PATCH 2/6] boot-splash: fix memory leak in error path + +If the splash key file fails to load, we don't free +the associated key file object. + +This commit fixes that. +--- + src/libply-splash-core/ply-boot-splash.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/libply-splash-core/ply-boot-splash.c b/src/libply-splash-core/ply-boot-splash.c +index 87a7a0c..54f8585 100644 +--- a/src/libply-splash-core/ply-boot-splash.c ++++ b/src/libply-splash-core/ply-boot-splash.c +@@ -181,62 +181,64 @@ void + ply_boot_splash_remove_text_display (ply_boot_splash_t *splash, + ply_text_display_t *display) + { + int number_of_columns, number_of_rows; + + if (splash->plugin_interface->remove_text_display == NULL) + return; + + number_of_columns = ply_text_display_get_number_of_columns (display); + number_of_rows = ply_text_display_get_number_of_rows (display); + + ply_trace ("removing %dx%d text display", number_of_columns, number_of_rows); + + splash->plugin_interface->remove_text_display (splash->plugin, display); + ply_list_remove_data (splash->text_displays, display); + } + + bool + ply_boot_splash_load (ply_boot_splash_t *splash) + { + ply_key_file_t *key_file; + char *module_name; + char *module_path; + + assert (splash != NULL); + + get_plugin_interface_function_t get_boot_splash_plugin_interface; + + key_file = ply_key_file_new (splash->theme_path); + +- if (!ply_key_file_load (key_file)) ++ if (!ply_key_file_load (key_file)) { ++ ply_key_file_free (key_file); + return false; ++ } + + module_name = ply_key_file_get_value (key_file, "Plymouth Theme", "ModuleName"); + + asprintf (&module_path, "%s%s.so", + splash->plugin_dir, module_name); + free (module_name); + + splash->module_handle = ply_open_module (module_path); + + free (module_path); + + if (splash->module_handle == NULL) { + ply_key_file_free (key_file); + return false; + } + + get_boot_splash_plugin_interface = (get_plugin_interface_function_t) + ply_module_look_up_function (splash->module_handle, + "ply_boot_splash_plugin_get_interface"); + + if (get_boot_splash_plugin_interface == NULL) { + ply_save_errno (); + ply_close_module (splash->module_handle); + splash->module_handle = NULL; + ply_key_file_free (key_file); + ply_restore_errno (); + return false; + } + + splash->plugin_interface = get_boot_splash_plugin_interface (); +-- +2.17.1 + diff --git a/0002-main-Do-not-update-the-display-on-backspace-when-the.patch b/0002-main-Do-not-update-the-display-on-backspace-when-the.patch new file mode 100644 index 0000000..d92621a --- /dev/null +++ b/0002-main-Do-not-update-the-display-on-backspace-when-the.patch @@ -0,0 +1,45 @@ +From da27e42316962be6f6b8ba2afb49760d9704d070 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Sun, 21 Jan 2018 14:07:39 +0100 +Subject: [PATCH 2/6] main: Do not update the display on backspace when there + is no input to remove + +On machines with a slow CPU (Atom) and a highres screen drawing the +diskcrypt dialog may take longer then the keyrepeat speed, this leads to +a long delay before showing keypresses when doing the following: + +1) Type long password +2) Realize it is wrong, press + hold backspace + the key-repeat will now generate backspace key presses faster then we + process them as main.c does an update_display for each press +3) Users releases backspace when we've processed input-length backspace + key-presses, but since we were drawing slower then key-presses were + coming in many more backspace keypresses are in the keyboard buffer +4) User types first character of the right password, this shows up up to + a couple of seconds later because first we are still processing all + the queued up backspace presses and doing a redraw for each. + +This commit fixes this by skipping the redraws in on_backspace when there +is no more input left in the input buffer. + +https://bugs.freedesktop.org/show_bug.cgi?id=104714 +--- + src/main.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/main.c b/src/main.c +index 08c7fe1..f1e0fa7 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -1570,6 +1570,8 @@ on_backspace (state_t *state) + + bytes = ply_buffer_get_bytes (state->entry_buffer); + size = ply_buffer_get_size (state->entry_buffer); ++ if (size == 0) ++ return; + + bytes_to_remove = MIN (size, PLY_UTF8_CHARACTER_SIZE_MAX); + while ((previous_character_size = ply_utf8_character_get_size (bytes + size - bytes_to_remove, bytes_to_remove)) < bytes_to_remove) { +-- +2.17.0 + diff --git a/0003-event-loop-fix-leak-in-error-path.patch b/0003-event-loop-fix-leak-in-error-path.patch new file mode 100644 index 0000000..da447b7 --- /dev/null +++ b/0003-event-loop-fix-leak-in-error-path.patch @@ -0,0 +1,86 @@ +From 9f335750af9e46d6597de0cea5b8a2f7db951dc1 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Mon, 15 Oct 2018 21:07:01 -0400 +Subject: [PATCH 3/6] event-loop: fix leak in error path + +ply_event_loop_new fails to clean itself up if it's unable to +create a pipe for dispatching signals. + +This commit fixes that. +--- + src/libply/ply-event-loop.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/libply/ply-event-loop.c b/src/libply/ply-event-loop.c +index 9736dae..0e8ad7c 100644 +--- a/src/libply/ply-event-loop.c ++++ b/src/libply/ply-event-loop.c +@@ -469,62 +469,64 @@ ply_event_loop_remove_destination_by_fd_watch (ply_event_loop_t *loop, + source = destination->source; + assert (source != NULL); + + ply_list_remove_data (source->destinations, destination); + ply_event_source_drop_reference (source); + assert (ply_list_find_node (source->destinations, destination) == NULL); + ply_event_loop_update_source_event_mask (loop, source); + } + + ply_event_loop_t * + ply_event_loop_new (void) + { + ply_event_loop_t *loop; + + loop = calloc (1, sizeof(ply_event_loop_t)); + + loop->epoll_fd = epoll_create1 (EPOLL_CLOEXEC); + loop->wakeup_time = PLY_EVENT_LOOP_NO_TIMED_WAKEUP; + + assert (loop->epoll_fd >= 0); + + loop->should_exit = false; + loop->exit_code = 0; + + loop->sources = ply_list_new (); + loop->exit_closures = ply_list_new (); + loop->timeout_watches = ply_list_new (); + + loop->signal_dispatcher = ply_signal_dispatcher_new (); + +- if (loop->signal_dispatcher == NULL) ++ if (loop->signal_dispatcher == NULL) { ++ ply_event_loop_free (loop); + return NULL; ++ } + + ply_event_loop_watch_fd (loop, + ply_signal_dispatcher_receiver_fd, + PLY_EVENT_LOOP_FD_STATUS_HAS_DATA, + (ply_event_handler_t) + ply_signal_dispatcher_dispatch_signal, + (ply_event_handler_t) + ply_signal_dispatcher_reset_signal_sources, + loop->signal_dispatcher); + + return loop; + } + + ply_event_loop_t * + ply_event_loop_get_default (void) + { + static ply_event_loop_t *loop = NULL; + + if (loop == NULL) + loop = ply_event_loop_new (); + + return loop; + } + + static void + ply_event_loop_free_exit_closures (ply_event_loop_t *loop) + { + ply_list_node_t *node; + + node = ply_list_get_first_node (loop->exit_closures); +-- +2.17.1 + diff --git a/0003-pixel-buffer-Add-the-concept-of-device-rotation.patch b/0003-pixel-buffer-Add-the-concept-of-device-rotation.patch new file mode 100644 index 0000000..0317509 --- /dev/null +++ b/0003-pixel-buffer-Add-the-concept-of-device-rotation.patch @@ -0,0 +1,249 @@ +From 0e4e268844ea38075535eb5b233dda325da4481d Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Wed, 6 Dec 2017 17:37:12 +0100 +Subject: [PATCH 3/6] pixel-buffer: Add the concept of device rotation + +On some devices the LCD panel is mounted in the casing in such a way +that the up/top side of the panel does not match with the top side of +the device (e.g. it is mounted upside-down). + +This commit adds support to the ply-pixel-buffer code to create +buffers which take device rotation into account and which will rotate +the picture to compensate. + +https://bugs.freedesktop.org/show_bug.cgi?id=104714 +--- + src/libply-splash-core/ply-pixel-buffer.c | 109 ++++++++++++++++++++-- + src/libply-splash-core/ply-pixel-buffer.h | 9 ++ + 2 files changed, 110 insertions(+), 8 deletions(-) + +diff --git a/src/libply-splash-core/ply-pixel-buffer.c b/src/libply-splash-core/ply-pixel-buffer.c +index 52a3f86..a337407 100644 +--- a/src/libply-splash-core/ply-pixel-buffer.c ++++ b/src/libply-splash-core/ply-pixel-buffer.c +@@ -50,6 +50,7 @@ struct _ply_pixel_buffer + ply_region_t *updated_areas; /* in device pixels */ + uint32_t is_opaque : 1; + int device_scale; ++ int device_rotation; + }; + + static inline void ply_pixel_buffer_blend_value_at_pixel (ply_pixel_buffer_t *buffer, +@@ -153,6 +154,52 @@ make_pixel_value_translucent (uint32_t pixel_value, + return (alpha << 24) | (red << 16) | (green << 8) | blue; + } + ++static inline void ply_pixel_buffer_set_pixel (ply_pixel_buffer_t *buffer, ++ int x, ++ int y, ++ uint32_t pixel_value) ++{ ++ switch (buffer->device_rotation) { ++ case PLY_PIXEL_BUFFER_ROTATE_UPRIGHT: ++ buffer->bytes[y * buffer->area.width + x] = pixel_value; ++ break; ++ case PLY_PIXEL_BUFFER_ROTATE_UPSIDE_DOWN: ++ x = (buffer->area.width - 1) - x; ++ y = (buffer->area.height - 1) - y; ++ buffer->bytes[y * buffer->area.width + x] = pixel_value; ++ break; ++ case PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE: ++ y = (buffer->area.height - 1) - y; ++ buffer->bytes[x * buffer->area.height + y] = pixel_value; ++ break; ++ case PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE: ++ x = (buffer->area.width - 1) - x; ++ buffer->bytes[x * buffer->area.height + y] = pixel_value; ++ break; ++ } ++} ++ ++static inline uint32_t ply_pixel_buffer_get_pixel (ply_pixel_buffer_t *buffer, ++ int x, ++ int y) ++{ ++ switch (buffer->device_rotation) { ++ case PLY_PIXEL_BUFFER_ROTATE_UPRIGHT: ++ return buffer->bytes[y * buffer->area.width + x]; ++ case PLY_PIXEL_BUFFER_ROTATE_UPSIDE_DOWN: ++ x = (buffer->area.width - 1) - x; ++ y = (buffer->area.height - 1) - y; ++ return buffer->bytes[y * buffer->area.width + x]; ++ case PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE: ++ y = (buffer->area.height - 1) - y; ++ return buffer->bytes[x * buffer->area.height + y]; ++ case PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE: ++ x = (buffer->area.width - 1) - x; ++ return buffer->bytes[x * buffer->area.height + y]; ++ } ++ return 0; ++} ++ + static inline void + ply_pixel_buffer_blend_value_at_pixel (ply_pixel_buffer_t *buffer, + int x, +@@ -162,12 +209,12 @@ ply_pixel_buffer_blend_value_at_pixel (ply_pixel_buffer_t *buffer, + uint32_t old_pixel_value; + + if ((pixel_value >> 24) != 0xff) { +- old_pixel_value = buffer->bytes[y * buffer->area.width + x]; ++ old_pixel_value = ply_pixel_buffer_get_pixel (buffer, x, y); + + pixel_value = blend_two_pixel_values (pixel_value, old_pixel_value); + } + +- buffer->bytes[y * buffer->area.width + x] = pixel_value; ++ ply_pixel_buffer_set_pixel (buffer, x, y, pixel_value); + } + + static void +@@ -222,6 +269,35 @@ ply_pixel_buffer_crop_area_to_clip_area (ply_pixel_buffer_t *buffer, + } + } + ++static void ply_pixel_buffer_add_updated_area (ply_pixel_buffer_t *buffer, ++ ply_rectangle_t *area) ++{ ++ ply_rectangle_t updated_area = *area; ++ ++ switch (buffer->device_rotation) { ++ case PLY_PIXEL_BUFFER_ROTATE_UPRIGHT: ++ break; ++ case PLY_PIXEL_BUFFER_ROTATE_UPSIDE_DOWN: ++ updated_area.x = buffer->area.width - area->width - area->x; ++ updated_area.y = buffer->area.height - area->height - area->y; ++ break; ++ case PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE: ++ updated_area.x = buffer->area.height - area->height - area->y; ++ updated_area.y = area->x; ++ updated_area.height = area->width; ++ updated_area.width = area->height; ++ break; ++ case PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE: ++ updated_area.x = area->y; ++ updated_area.y = buffer->area.width - area->width - area->x; ++ updated_area.height = area->width; ++ updated_area.width = area->height; ++ break; ++ } ++ ++ ply_region_add_rectangle (buffer->updated_areas, &updated_area); ++} ++ + static void + ply_pixel_buffer_fill_area_with_pixel_value (ply_pixel_buffer_t *buffer, + ply_rectangle_t *fill_area, +@@ -251,7 +327,7 @@ ply_pixel_buffer_fill_area_with_pixel_value (ply_pixel_buffer_t *buffer, + } + } + +- ply_region_add_rectangle (buffer->updated_areas, &cropped_area); ++ ply_pixel_buffer_add_updated_area (buffer, &cropped_area); + } + + void +@@ -281,9 +357,24 @@ ply_pixel_buffer_pop_clip_area (ply_pixel_buffer_t *buffer) + ply_pixel_buffer_t * + ply_pixel_buffer_new (unsigned long width, + unsigned long height) ++{ ++ return ply_pixel_buffer_new_with_device_rotation ( ++ width, height, PLY_PIXEL_BUFFER_ROTATE_UPRIGHT); ++} ++ ++ply_pixel_buffer_t * ++ply_pixel_buffer_new_with_device_rotation (unsigned long width, ++ unsigned long height, ++ int device_rotation) + { + ply_pixel_buffer_t *buffer; + ++ if (device_rotation >= PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE) { ++ unsigned long tmp = width; ++ width = height; ++ height = tmp; ++ } ++ + buffer = calloc (1, sizeof(ply_pixel_buffer_t)); + + buffer->updated_areas = ply_region_new (); +@@ -292,6 +383,7 @@ ply_pixel_buffer_new (unsigned long width, + buffer->area.height = height; + buffer->logical_area = buffer->area; + buffer->device_scale = 1; ++ buffer->device_rotation = device_rotation; + + buffer->clip_areas = ply_list_new (); + ply_pixel_buffer_push_clip_area (buffer, &buffer->area); +@@ -447,7 +539,7 @@ ply_pixel_buffer_fill_with_gradient (ply_pixel_buffer_t *buffer, + + for (y = buffer->area.y; y < buffer->area.y + buffer->area.height; y++) { + if (cropped_area.y <= y && y < cropped_area.y + cropped_area.height) { +- if (cropped_area.width < UNROLLED_PIXEL_COUNT) { ++ if (cropped_area.width < UNROLLED_PIXEL_COUNT || buffer->device_rotation) { + for (x = cropped_area.x; x < cropped_area.x + cropped_area.width; x++) { + pixel = 0xff000000; + RANDOMIZE (noise); +@@ -457,7 +549,7 @@ ply_pixel_buffer_fill_with_gradient (ply_pixel_buffer_t *buffer, + RANDOMIZE (noise); + pixel |= (((blue + noise) & COLOR_MASK) >> BLUE_SHIFT); + +- buffer->bytes[y * buffer->area.width + x] = pixel; ++ ply_pixel_buffer_set_pixel (buffer, x, y, pixel); + } + } else { + uint32_t shaded_set[UNROLLED_PIXEL_COUNT]; +@@ -485,7 +577,7 @@ ply_pixel_buffer_fill_with_gradient (ply_pixel_buffer_t *buffer, + blue += blue_step; + } + +- ply_region_add_rectangle (buffer->updated_areas, &cropped_area); ++ ply_pixel_buffer_add_updated_area (buffer, &cropped_area); + } + + void +@@ -671,7 +763,7 @@ ply_pixel_buffer_fill_with_argb32_data_at_opacity_with_clip_and_scale (ply_pixel + } + } + +- ply_region_add_rectangle (buffer->updated_areas, &cropped_area); ++ ply_pixel_buffer_add_updated_area (buffer, &cropped_area); + } + + void +@@ -756,7 +848,8 @@ ply_pixel_buffer_fill_with_buffer_at_opacity_with_clip (ply_pixel_buffer_t *canv + + /* Fast path to memcpy if we need no blending or scaling */ + if (opacity == 1.0 && ply_pixel_buffer_is_opaque (source) && +- canvas->device_scale == source->device_scale) { ++ canvas->device_scale == source->device_scale && ++ canvas->device_rotation == PLY_PIXEL_BUFFER_ROTATE_UPRIGHT) { + ply_rectangle_t cropped_area; + + cropped_area.x = x_offset; +diff --git a/src/libply-splash-core/ply-pixel-buffer.h b/src/libply-splash-core/ply-pixel-buffer.h +index 595e9bd..7736dd3 100644 +--- a/src/libply-splash-core/ply-pixel-buffer.h ++++ b/src/libply-splash-core/ply-pixel-buffer.h +@@ -37,9 +37,18 @@ typedef struct _ply_pixel_buffer ply_pixel_buffer_t; + | ((uint8_t) (CLAMP (g * 255.0, 0.0, 255.0)) << 8) \ + | ((uint8_t) (CLAMP (b * 255.0, 0.0, 255.0)))) + ++#define PLY_PIXEL_BUFFER_ROTATE_UPRIGHT 0 ++#define PLY_PIXEL_BUFFER_ROTATE_UPSIDE_DOWN 1 ++#define PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE 2 ++#define PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE 3 ++ + #ifndef PLY_HIDE_FUNCTION_DECLARATIONS + ply_pixel_buffer_t *ply_pixel_buffer_new (unsigned long width, + unsigned long height); ++ply_pixel_buffer_t * ++ply_pixel_buffer_new_with_device_rotation (unsigned long width, ++ unsigned long height, ++ int device_rotation); + void ply_pixel_buffer_free (ply_pixel_buffer_t *buffer); + void ply_pixel_buffer_get_size (ply_pixel_buffer_t *buffer, + ply_rectangle_t *size); +-- +2.17.0 + diff --git a/0004-drm-Check-for-panel-orientation-connector-property.patch b/0004-drm-Check-for-panel-orientation-connector-property.patch new file mode 100644 index 0000000..f953c8b --- /dev/null +++ b/0004-drm-Check-for-panel-orientation-connector-property.patch @@ -0,0 +1,102 @@ +From a6f25b727698a2382e332ab566ed39ee30f8efdc Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Tue, 12 Dec 2017 19:47:26 +0100 +Subject: [PATCH 4/6] drm: Check for "panel orientation" connector property + +On some devices the LCD panel is mounted in the casing in such a way +that the up/top side of the panel does not match with the top side of +the device (e.g. it is mounted upside-down). + +Kernel 4.16 introduces a new "panel-orientation" property on the drm +connector which allows modesetting applications / code to check for +such LCD panels. + +This commit adds support for this new property and passes this to the +pixel_buffer code using the new ply_pixel_buffer_new_with_device_rotation +method, so that the pixel_buffer code will automatically rotate the +image to correct for the panel orientation. + +https://bugs.freedesktop.org/show_bug.cgi?id=104714 +--- + src/plugins/renderers/drm/plugin.c | 51 +++++++++++++++++++++++++++++- + 1 file changed, 50 insertions(+), 1 deletion(-) + +diff --git a/src/plugins/renderers/drm/plugin.c b/src/plugins/renderers/drm/plugin.c +index b93e8e4..f495854 100644 +--- a/src/plugins/renderers/drm/plugin.c ++++ b/src/plugins/renderers/drm/plugin.c +@@ -367,6 +367,53 @@ destroy_output_buffer (ply_renderer_backend_t *backend, + ply_renderer_buffer_free (backend, buffer); + } + ++static int ++connector_orientation_prop_to_rotation (drmModePropertyPtr prop, ++ int orientation) ++{ ++ const char *name = prop->enums[orientation].name; ++ ++ if (strcmp (name, "Upside Down") == 0) ++ return PLY_PIXEL_BUFFER_ROTATE_UPSIDE_DOWN; ++ ++ if (strcmp (name, "Left Side Up") == 0) { ++ /* Left side up, rotate counter clockwise to correct */ ++ return PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE; ++ } ++ ++ if (strcmp (name, "Right Side Up") == 0) { ++ /* Left side up, rotate clockwise to correct */ ++ return PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE; ++ } ++ ++ return PLY_PIXEL_BUFFER_ROTATE_UPRIGHT; ++} ++ ++static int ++ply_renderer_connector_get_rotation (ply_renderer_backend_t *backend, ++ drmModeConnector *connector) ++{ ++ drmModePropertyPtr prop; ++ int i, rotation; ++ ++ for (i = 0; i < connector->count_props; i++) { ++ prop = drmModeGetProperty (backend->device_fd, connector->props[i]); ++ if (!prop) ++ continue; ++ ++ if ((prop->flags & DRM_MODE_PROP_ENUM) && ++ strcmp (prop->name, "panel orientation") == 0) { ++ rotation = connector_orientation_prop_to_rotation (prop, connector->prop_values[i]); ++ drmModeFreeProperty (prop); ++ return rotation; ++ } ++ ++ drmModeFreeProperty (prop); ++ } ++ ++ return PLY_PIXEL_BUFFER_ROTATE_UPRIGHT; ++} ++ + static bool + ply_renderer_head_add_connector (ply_renderer_head_t *head, + drmModeConnector *connector, +@@ -402,6 +449,7 @@ ply_renderer_head_new (ply_renderer_backend_t *backend, + { + ply_renderer_head_t *head; + drmModeModeInfo *mode; ++ int rotation; + + head = calloc (1, sizeof(ply_renderer_head_t)); + +@@ -425,7 +473,8 @@ ply_renderer_head_new (ply_renderer_backend_t *backend, + ply_renderer_head_add_connector (head, connector, connector_mode_index); + assert (ply_array_get_size (head->connector_ids) > 0); + +- head->pixel_buffer = ply_pixel_buffer_new (head->area.width, head->area.height); ++ rotation = ply_renderer_connector_get_rotation (backend, connector); ++ head->pixel_buffer = ply_pixel_buffer_new_with_device_rotation (head->area.width, head->area.height, rotation); + ply_pixel_buffer_set_device_scale (head->pixel_buffer, + ply_get_device_scale (head->area.width, + head->area.height, +-- +2.17.0 + diff --git a/0004-key-file-ply_key_file_get_value-returns-duplicated-m.patch b/0004-key-file-ply_key_file_get_value-returns-duplicated-m.patch new file mode 100644 index 0000000..b3fafcd --- /dev/null +++ b/0004-key-file-ply_key_file_get_value-returns-duplicated-m.patch @@ -0,0 +1,216 @@ +From b8d406161ee95ad4fa1a478d262993090404608f Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Mon, 15 Oct 2018 21:13:58 -0400 +Subject: [PATCH 4/6] key-file: ply_key_file_get_value returns duplicated + memory, don't leak + +For some reason I made the same api misdesign with ply_key_file_t +that I made when writing GKeyFile...it returns duplicated memory for +no good reason. + +This commit sprinkles frees around. +--- + src/main.c | 13 +++++++++---- + src/plugins/splash/two-step/plugin.c | 2 ++ + 2 files changed, 11 insertions(+), 4 deletions(-) + +diff --git a/src/main.c b/src/main.c +index 841fe6b..e44de7b 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -268,116 +268,121 @@ on_system_update (state_t *state, + } + + static void + show_messages (state_t *state) + { + if (state->boot_splash == NULL) { + ply_trace ("not displaying messages, since no boot splash"); + return; + } + + ply_list_node_t *node = ply_list_get_first_node (state->messages); + while (node != NULL) { + ply_list_node_t *next_node; + char *message = ply_list_node_get_data (node); + + ply_trace ("displaying messages"); + + ply_boot_splash_display_message (state->boot_splash, message); + next_node = ply_list_get_next_node (state->messages, node); + node = next_node; + } + } + + static bool + load_settings (state_t *state, + const char *path, + char **theme_path) + { + ply_key_file_t *key_file = NULL; + bool settings_loaded = false; +- const char *scale_string; +- const char *splash_string; ++ char *scale_string = NULL; ++ char *splash_string = NULL; + + ply_trace ("Trying to load %s", path); + key_file = ply_key_file_new (path); + + if (!ply_key_file_load (key_file)) + goto out; + + splash_string = ply_key_file_get_value (key_file, "Daemon", "Theme"); + + if (splash_string == NULL) + goto out; + + asprintf (theme_path, + PLYMOUTH_RUNTIME_THEME_PATH "%s/%s.plymouth", + splash_string, splash_string); + ply_trace ("Checking if %s exists", *theme_path); + if (!ply_file_exists (*theme_path)) { + ply_trace ("%s not found, fallbacking to " PLYMOUTH_THEME_PATH, + *theme_path); + asprintf (theme_path, + PLYMOUTH_THEME_PATH "%s/%s.plymouth", + splash_string, splash_string); + } + + if (isnan (state->splash_delay)) { +- const char *delay_string; ++ char *delay_string; + + delay_string = ply_key_file_get_value (key_file, "Daemon", "ShowDelay"); + + if (delay_string != NULL) { + state->splash_delay = atof (delay_string); + ply_trace ("Splash delay is set to %lf", state->splash_delay); ++ free (delay_string); + } + } + + if (isnan (state->device_timeout)) { +- const char *timeout_string; ++ char *timeout_string; + + timeout_string = ply_key_file_get_value (key_file, "Daemon", "DeviceTimeout"); + + if (timeout_string != NULL) { + state->device_timeout = atof (timeout_string); + ply_trace ("Device timeout is set to %lf", state->device_timeout); ++ ++ free (timeout_string); + } + } + + scale_string = ply_key_file_get_value (key_file, "Daemon", "DeviceScale"); + + if (scale_string != NULL) { + ply_set_device_scale (strtoul (scale_string, NULL, 0)); ++ free (scale_string); + } + + settings_loaded = true; + out: ++ free (splash_string); + ply_key_file_free (key_file); + + return settings_loaded; + } + + static void + show_detailed_splash (state_t *state) + { + ply_boot_splash_t *splash; + + if (state->boot_splash != NULL) + return; + + ply_trace ("Showing detailed splash screen"); + splash = show_theme (state, NULL); + + if (splash == NULL) { + ply_trace ("Could not start detailed splash screen, this could be a problem."); + return; + } + + state->boot_splash = splash; + + show_messages (state); + update_display (state); + } + + static const char * + command_line_get_string_after_prefix (const char *command_line, + const char *prefix) +diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c +index 070741d..52986d2 100644 +--- a/src/plugins/splash/two-step/plugin.c ++++ b/src/plugins/splash/two-step/plugin.c +@@ -631,60 +631,62 @@ create_plugin (ply_key_file_t *key_file) + + if (color != NULL) + plugin->background_start_color = strtol (color, NULL, 0); + else + plugin->background_start_color = PLYMOUTH_BACKGROUND_START_COLOR; + + free (color); + + color = ply_key_file_get_value (key_file, "two-step", "BackgroundEndColor"); + + if (color != NULL) + plugin->background_end_color = strtol (color, NULL, 0); + else + plugin->background_end_color = PLYMOUTH_BACKGROUND_END_COLOR; + + free (color); + + progress_function = ply_key_file_get_value (key_file, "two-step", "ProgressFunction"); + + if (progress_function != NULL) { + if (strcmp (progress_function, "wwoods") == 0) { + ply_trace ("Using wwoods progress function"); + plugin->progress_function = PROGRESS_FUNCTION_TYPE_WWOODS; + } else if (strcmp (progress_function, "linear") == 0) { + ply_trace ("Using linear progress function"); + plugin->progress_function = PROGRESS_FUNCTION_TYPE_LINEAR; + } else { + ply_trace ("unknown progress function %s, defaulting to linear", progress_function); + plugin->progress_function = PROGRESS_FUNCTION_TYPE_LINEAR; + } ++ ++ free (progress_function); + } + + plugin->views = ply_list_new (); + + return plugin; + } + + static void + free_views (ply_boot_splash_plugin_t *plugin) + { + ply_list_node_t *node; + + ply_trace ("freeing views"); + + node = ply_list_get_first_node (plugin->views); + + while (node != NULL) { + ply_list_node_t *next_node; + view_t *view; + + view = ply_list_node_get_data (node); + next_node = ply_list_get_next_node (plugin->views, node); + + view_free (view); + ply_list_remove_node (plugin->views, node); + + node = next_node; + } + + ply_list_free (plugin->views); +-- +2.17.1 + diff --git a/0005-drm-Reset-primary-plane-rotation-to-DRM_MODE_ROTATE_.patch b/0005-drm-Reset-primary-plane-rotation-to-DRM_MODE_ROTATE_.patch new file mode 100644 index 0000000..0602bad --- /dev/null +++ b/0005-drm-Reset-primary-plane-rotation-to-DRM_MODE_ROTATE_.patch @@ -0,0 +1,148 @@ +From d769f1194c934ed4ff7ce6bfc502ba485d461c12 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Sat, 20 Jan 2018 12:20:29 +0100 +Subject: [PATCH 5/6] drm: Reset primary plane rotation to DRM_MODE_ROTATE_0 + +On devices where the (LCD) panel is mounted upside-down in the case +the kernel's drm_fb_helper code may have set up rotation on the primary +plane to make the text-console (and other fbdev using apps) show the right +way up. + +We inherit this rotation from the text-mode and since we do our own rotation +where necessary we end up rotating twice and showing the boot-splash +upside-down again. + +Dealing with hardware rotation may require using a specific framebuffer +tiling which we do not support, so we should just disable the hardware +rotation and keep using our own software rotation. + +This commit adds code to find the primary plane and its rotation property +and if it is not DRM_MODE_ROTATE_0 then sets it to DRM_MODE_ROTATE_0. fixing +the double rotation issue. + +https://bugs.freedesktop.org/show_bug.cgi?id=104714 +--- + src/plugins/renderers/drm/plugin.c | 86 ++++++++++++++++++++++++++++++ + 1 file changed, 86 insertions(+) + +diff --git a/src/plugins/renderers/drm/plugin.c b/src/plugins/renderers/drm/plugin.c +index f495854..fb79aa6 100644 +--- a/src/plugins/renderers/drm/plugin.c ++++ b/src/plugins/renderers/drm/plugin.c +@@ -43,6 +43,7 @@ + #include + + #include ++#include + #include + #include + +@@ -62,6 +63,11 @@ + + #define BYTES_PER_PIXEL (4) + ++/* For builds with libdrm < 2.4.89 */ ++#ifndef DRM_MODE_ROTATE_0 ++#define DRM_MODE_ROTATE_0 (1<<0) ++#endif ++ + struct _ply_renderer_head + { + ply_renderer_backend_t *backend; +@@ -499,6 +505,85 @@ ply_renderer_head_free (ply_renderer_head_t *head) + free (head); + } + ++static void ++ply_renderer_head_clear_plane_rotation (ply_renderer_backend_t *backend, ++ ply_renderer_head_t *head) ++{ ++ drmModeObjectPropertiesPtr plane_props; ++ drmModePlaneResPtr plane_resources; ++ drmModePropertyPtr prop; ++ drmModePlanePtr plane; ++ uint64_t rotation; ++ uint32_t i, j; ++ int rotation_prop_id = -1; ++ int primary_id = -1; ++ int err; ++ ++ err = drmSetClientCap (backend->device_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); ++ if (err) ++ return; ++ ++ plane_resources = drmModeGetPlaneResources (backend->device_fd); ++ if (!plane_resources) ++ return; ++ ++ for (i = 0; i < plane_resources->count_planes; i++) { ++ plane = drmModeGetPlane (backend->device_fd, ++ plane_resources->planes[i]); ++ if (!plane) ++ continue; ++ ++ if (plane->crtc_id != head->controller_id) { ++ drmModeFreePlane (plane); ++ continue; ++ } ++ ++ plane_props = drmModeObjectGetProperties (backend->device_fd, ++ plane->plane_id, ++ DRM_MODE_OBJECT_PLANE); ++ ++ for (j = 0; plane_props && (j < plane_props->count_props); j++) { ++ prop = drmModeGetProperty (backend->device_fd, ++ plane_props->props[j]); ++ if (!prop) ++ continue; ++ ++ if (strcmp (prop->name, "type") == 0 && ++ plane_props->prop_values[j] == DRM_PLANE_TYPE_PRIMARY) { ++ primary_id = plane->plane_id; ++ } ++ ++ if (strcmp (prop->name, "rotation") == 0) { ++ rotation_prop_id = plane_props->props[j]; ++ rotation = plane_props->prop_values[j]; ++ } ++ ++ drmModeFreeProperty (prop); ++ } ++ ++ drmModeFreeObjectProperties (plane_props); ++ drmModeFreePlane (plane); ++ ++ if (primary_id != -1) ++ break; ++ ++ /* Not primary -> clear any found rotation property */ ++ rotation_prop_id = -1; ++ } ++ ++ if (primary_id != -1 && rotation_prop_id != -1 && rotation != DRM_MODE_ROTATE_0) { ++ err = drmModeObjectSetProperty (backend->device_fd, ++ primary_id, ++ DRM_MODE_OBJECT_PLANE, ++ rotation_prop_id, ++ DRM_MODE_ROTATE_0); ++ ply_trace ("Cleared rotation on primary plane %d result %d", ++ primary_id, err); ++ } ++ ++ drmModeFreePlaneResources (plane_resources); ++} ++ + static bool + ply_renderer_head_set_scan_out_buffer (ply_renderer_backend_t *backend, + ply_renderer_head_t *head, +@@ -525,6 +610,7 @@ ply_renderer_head_set_scan_out_buffer (ply_renderer_backend_t *backend, + return false; + } + ++ ply_renderer_head_clear_plane_rotation (backend, head); + return true; + } + +-- +2.17.0 + diff --git a/0005-script-fix-various-memory-leaks.patch b/0005-script-fix-various-memory-leaks.patch new file mode 100644 index 0000000..4a6a59a --- /dev/null +++ b/0005-script-fix-various-memory-leaks.patch @@ -0,0 +1,556 @@ +From 6980c2cdf003f5963695809b3a278ff53ad51832 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Mon, 15 Oct 2018 21:44:10 -0400 +Subject: [PATCH 5/6] script: fix various memory leaks + +coverity found a few leaks. + +this commit mops them up. +--- + src/plugins/splash/script/script-lib-image.c | 5 +- + src/plugins/splash/script/script-lib-sprite.c | 4 +- + src/plugins/splash/script/script-parse.c | 61 +++++++++++++++++-- + 3 files changed, 62 insertions(+), 8 deletions(-) + +diff --git a/src/plugins/splash/script/script-lib-image.c b/src/plugins/splash/script/script-lib-image.c +index a202702..748e6d1 100644 +--- a/src/plugins/splash/script/script-lib-image.c ++++ b/src/plugins/splash/script/script-lib-image.c +@@ -173,61 +173,64 @@ static script_return_t image_text (script_state_t *state, + script_obj_unref (alpha_obj); + + font_obj = script_obj_hash_peek_element (state->local, "font"); + + if (script_obj_is_string (font_obj)) + font = script_obj_as_string (font_obj); + else + font = NULL; + + script_obj_unref (font_obj); + + align_obj = script_obj_hash_peek_element (state->local, "align"); + + if (script_obj_is_string (align_obj)) { + char *align_str = script_obj_as_string (align_obj); + + if (!strcmp ("left", align_str)) + align = PLY_LABEL_ALIGN_LEFT; + else if (!strcmp ("center", align_str)) + align = PLY_LABEL_ALIGN_CENTER; + else if (!strcmp ("right", align_str)) + align = PLY_LABEL_ALIGN_RIGHT; + else + ply_error ("Unrecognized Image.Text alignment string '%s'. " + "Expecting 'left', 'center', or 'right'\n", + align_str); + free (align_str); + } + script_obj_unref (align_obj); + +- if (!text) return script_return_obj_null (); ++ if (!text) { ++ free (font); ++ return script_return_obj_null (); ++ } + + label = ply_label_new (); + ply_label_set_text (label, text); + if (font) + ply_label_set_font (label, font); + ply_label_set_alignment (label, align); + ply_label_set_color (label, red, green, blue, alpha); + ply_label_show (label, NULL, 0, 0); + + width = ply_label_get_width (label); + height = ply_label_get_height (label); + + image = ply_pixel_buffer_new (width, height); + ply_label_draw_area (label, image, 0, 0, width, height); + + free (text); + free (font); + ply_label_free (label); + + return script_return_obj (script_obj_new_native (image, data->class)); + } + + script_lib_image_data_t *script_lib_image_setup (script_state_t *state, + char *image_dir) + { + script_lib_image_data_t *data = malloc (sizeof(script_lib_image_data_t)); + + data->class = script_obj_native_class_new (image_free, "image", data); + data->image_dir = strdup (image_dir); + +diff --git a/src/plugins/splash/script/script-lib-sprite.c b/src/plugins/splash/script/script-lib-sprite.c +index c49297d..b119f05 100644 +--- a/src/plugins/splash/script/script-lib-sprite.c ++++ b/src/plugins/splash/script/script-lib-sprite.c +@@ -714,66 +714,68 @@ region_add_area (ply_region_t *region, + ply_region_add_rectangle (region, &rectangle); + } + + void script_lib_sprite_pixel_display_removed (script_lib_sprite_data_t *data, ply_pixel_display_t *pixel_display) + { + ply_list_node_t *node; + ply_list_node_t *next_node; + script_lib_display_t* display; + + if (!data) + return; + + node = ply_list_get_first_node (data->displays); + while (node) + { + next_node = ply_list_get_next_node (data->displays, node); + display = ply_list_node_get_data (node); + + if (display->pixel_display == pixel_display) + { + ply_list_remove_node (data->displays, node); + } + node = next_node; + } + } + + void + script_lib_sprite_refresh (script_lib_sprite_data_t *data) + { + ply_list_node_t *node; +- ply_region_t *region = ply_region_new (); ++ ply_region_t *region; + ply_list_t *rectable_list; + + if (!data) + return; + ++ region = ply_region_new (); ++ + ply_list_sort_stable (data->sprite_list, &sprite_compare_z); + + node = ply_list_get_first_node (data->sprite_list); + + + if (data->full_refresh) { + for (node = ply_list_get_first_node (data->displays); + node; + node = ply_list_get_next_node (data->displays, node)) { + script_lib_display_t *display = ply_list_node_get_data (node); + region_add_area (region, + display->x, + display->y, + ply_pixel_display_get_width (display->pixel_display), + ply_pixel_display_get_height (display->pixel_display)); + } + + data->full_refresh = false; + } + + while (node) { + sprite_t *sprite = ply_list_node_get_data (node); + ply_list_node_t *next_node = ply_list_get_next_node (data->sprite_list, + node); + if (sprite->remove_me) { + if (sprite->image) { + region_add_area (region, + sprite->old_x, + sprite->old_y, + sprite->old_width, +diff --git a/src/plugins/splash/script/script-parse.c b/src/plugins/splash/script/script-parse.c +index a4c7656..ea5fdd2 100644 +--- a/src/plugins/splash/script/script-parse.c ++++ b/src/plugins/splash/script/script-parse.c +@@ -27,60 +27,61 @@ + #include "ply-hashtable.h" + #include "ply-list.h" + #include "ply-bitarray.h" + #include "ply-logger.h" + #include + #include + #include + #include + #include + #include + #include + #include + + #include "script-debug.h" + #include "script-scan.h" + #include "script-parse.h" + + #define WITH_SEMIES + + typedef struct + { + const char *symbol; + script_exp_type_t exp_type; + int presedence; + }script_parse_operator_table_entry_t; + + static script_op_t *script_parse_op (script_scan_t *scan); + static script_exp_t *script_parse_exp (script_scan_t *scan); + static ply_list_t *script_parse_op_list (script_scan_t *scan); + static void script_parse_op_list_free (ply_list_t *op_list); ++static void script_parse_exp_free (script_exp_t *exp); + + static script_exp_t *script_parse_new_exp (script_exp_type_t type, + script_debug_location_t *location) + { + script_exp_t *exp = malloc (sizeof(script_exp_t)); + + exp->type = type; + script_debug_add_element (exp, location); + return exp; + } + + static script_exp_t *script_parse_new_exp_single (script_exp_type_t type, + script_exp_t *sub, + script_debug_location_t *location) + { + script_exp_t *exp = script_parse_new_exp (type, location); + + exp->data.sub = sub; + return exp; + } + + static script_exp_t *script_parse_new_exp_dual (script_exp_type_t type, + script_exp_t *sub_a, + script_exp_t *sub_b, + script_debug_location_t *location) + { + script_exp_t *exp = script_parse_new_exp (type, location); + + exp->data.dual.sub_a = sub_a; + exp->data.dual.sub_b = sub_b; +@@ -198,101 +199,127 @@ static void script_parse_error (script_debug_location_t *location, + static const script_parse_operator_table_entry_t * /* Only allows 1 or 2 character symbols */ + script_parse_operator_table_entry_lookup (script_scan_t *scan, + const script_parse_operator_table_entry_t *table) + { + int entry_index; + script_scan_token_t *curtoken = script_scan_get_current_token (scan); + script_scan_token_t *peektoken = script_scan_peek_next_token (scan); + + for (entry_index = 0; table[entry_index].symbol; entry_index++) { + if (!script_scan_token_is_symbol (curtoken)) continue; + if (curtoken->data.symbol != table[entry_index].symbol[0]) continue; + if (table[entry_index].symbol[1]) { + if (!script_scan_token_is_symbol (peektoken)) continue; + if (peektoken->data.symbol != table[entry_index].symbol[1]) continue; + if (peektoken->whitespace) continue; + } + break; + } + return &table[entry_index]; + } + + static void script_parse_advance_scan_by_string (script_scan_t *scan, + const char *string) + { + while (*string) { + script_scan_get_next_token (scan); + string++; + } + } + ++static void ++free_parameter_list (script_scan_t *scan, ++ ply_list_t *parameter_list) ++{ ++ if (parameter_list != NULL) { ++ ply_list_node_t *node; ++ ++ node = ply_list_get_first_node (parameter_list); ++ while (node != NULL) { ++ ply_list_node_t *next_node; ++ char *parameter; ++ ++ parameter = ply_list_node_get_data (node); ++ next_node = ply_list_get_next_node (parameter_list, node); ++ free (parameter); ++ ply_list_remove_node (parameter_list, node); ++ ++ node = next_node; ++ } ++ } ++} ++ + static script_function_t *script_parse_function_def (script_scan_t *scan) + { + script_scan_token_t *curtoken = script_scan_get_current_token (scan); +- ply_list_t *parameter_list; ++ script_function_t *function = NULL; ++ ply_list_t *parameter_list = NULL; + + if (!script_scan_token_is_symbol_of_value (curtoken, '(')) { + script_parse_error (&curtoken->location, + "Function declaration requires parameters to be declared within '(' brackets"); + return NULL; + } + curtoken = script_scan_get_next_token (scan); + parameter_list = ply_list_new (); + + while (true) { + if (script_scan_token_is_symbol_of_value (curtoken, ')')) break; + if (!script_scan_token_is_identifier (curtoken)) { + script_parse_error (&curtoken->location, + "Function declaration parameters must be valid identifiers"); +- return NULL; ++ goto out; + } + char *parameter = strdup (curtoken->data.string); + ply_list_append_data (parameter_list, parameter); + + curtoken = script_scan_get_next_token (scan); + + if (script_scan_token_is_symbol_of_value (curtoken, ')')) break; + if (!script_scan_token_is_symbol_of_value (curtoken, ',')) { + script_parse_error (&curtoken->location, + "Function declaration parameters must separated with ',' and terminated with a ')'"); +- return NULL; ++ goto out; + } + curtoken = script_scan_get_next_token (scan); + } + + curtoken = script_scan_get_next_token (scan); + + script_op_t *func_op = script_parse_op (scan); + +- script_function_t *function = script_function_script_new (func_op, +- NULL, +- parameter_list); ++ function = script_function_script_new (func_op, ++ NULL, ++ parameter_list); ++ parameter_list = NULL; ++out: ++ free_parameter_list (scan, parameter_list); + return function; + } + + static script_exp_t *script_parse_exp_tm (script_scan_t *scan) + { + script_scan_token_t *curtoken = script_scan_get_current_token (scan); + script_exp_t *exp = NULL; + + if (script_scan_token_is_integer (curtoken)) { + exp = script_parse_new_exp_number (curtoken->data.integer, &curtoken->location); + script_scan_get_next_token (scan); + return exp; + } + if (script_scan_token_is_float (curtoken)) { + exp = script_parse_new_exp_number (curtoken->data.floatpoint, &curtoken->location); + script_scan_get_next_token (scan); + return exp; + } + if (script_scan_token_is_identifier (curtoken)) { + if (script_scan_token_is_identifier_of_value (curtoken, "NULL")) { + exp = script_parse_new_exp (SCRIPT_EXP_TYPE_TERM_NULL, &curtoken->location); + } else if (script_scan_token_is_identifier_of_value (curtoken, "INFINITY")) { + exp = script_parse_new_exp_number (INFINITY, &curtoken->location); + } else if (script_scan_token_is_identifier_of_value (curtoken, "NAN")) { + exp = script_parse_new_exp_number (NAN, &curtoken->location); + } else if (script_scan_token_is_identifier_of_value (curtoken, "global")) { + exp = script_parse_new_exp (SCRIPT_EXP_TYPE_TERM_GLOBAL, &curtoken->location); + } else if (script_scan_token_is_identifier_of_value (curtoken, "local")) { + exp = script_parse_new_exp (SCRIPT_EXP_TYPE_TERM_LOCAL, &curtoken->location); + } else if (script_scan_token_is_identifier_of_value (curtoken, "this")) { +@@ -300,112 +327,132 @@ static script_exp_t *script_parse_exp_tm (script_scan_t *scan) + } else if (script_scan_token_is_identifier_of_value (curtoken, "fun")) { + script_debug_location_t location = curtoken->location; + script_scan_get_next_token (scan); + exp = script_parse_new_exp_function_def (script_parse_function_def (scan), &location); + return exp; + } else { + exp = script_parse_new_exp_var (curtoken->data.string, &curtoken->location); + } + curtoken = script_scan_get_next_token (scan); + return exp; + } + if (script_scan_token_is_string (curtoken)) { + exp = script_parse_new_exp_string (curtoken->data.string, &curtoken->location); + script_scan_get_next_token (scan); + return exp; + } + + if (script_scan_token_is_symbol_of_value (curtoken, '[')) { + ply_list_t *parameters = ply_list_new (); + script_debug_location_t location = curtoken->location; + script_scan_get_next_token (scan); + while (true) { + if (script_scan_token_is_symbol_of_value (curtoken, ']')) break; + script_exp_t *parameter = script_parse_exp (scan); + + ply_list_append_data (parameters, parameter); + + curtoken = script_scan_get_current_token (scan); + if (script_scan_token_is_symbol_of_value (curtoken, ']')) break; + if (!script_scan_token_is_symbol_of_value (curtoken, ',')) { ++ ply_list_node_t *node; + script_parse_error (&curtoken->location, + "Set parameters should be separated with a ',' and terminated with a ']'"); ++ ++ ++ for (node = ply_list_get_first_node (parameters); ++ node; ++ node = ply_list_get_next_node (parameters, node)) { ++ script_exp_t *sub = ply_list_node_get_data (node); ++ script_parse_exp_free (sub); ++ } ++ ply_list_free (parameters); + return NULL; + } + curtoken = script_scan_get_next_token (scan); + } + script_scan_get_next_token (scan); + exp = script_parse_new_exp_set (parameters, &location); + return exp; + } + if (script_scan_token_is_symbol_of_value (curtoken, '(')) { + script_scan_get_next_token (scan); + exp = script_parse_exp (scan); + curtoken = script_scan_get_current_token (scan); + if (!exp) { + script_parse_error (&curtoken->location, + "Expected valid contents of bracketed expression"); + return NULL; + } + if (!script_scan_token_is_symbol_of_value (curtoken, ')')) { + script_parse_error (&curtoken->location, + "Expected bracketed block to be terminated with a ')'"); + return NULL; + } + script_scan_get_next_token (scan); + return exp; + } + return NULL; + } + + static script_exp_t *script_parse_exp_pi (script_scan_t *scan) + { + script_exp_t *exp = script_parse_exp_tm (scan); + script_scan_token_t *curtoken = script_scan_get_current_token (scan); + + while (true) { + script_debug_location_t location = curtoken->location; + if (!script_scan_token_is_symbol (curtoken)) break; + if (script_scan_token_is_symbol_of_value (curtoken, '(')) { + ply_list_t *parameters = ply_list_new (); + script_scan_get_next_token (scan); + while (true) { + if (script_scan_token_is_symbol_of_value (curtoken, ')')) break; + script_exp_t *parameter = script_parse_exp (scan); + + ply_list_append_data (parameters, parameter); + + curtoken = script_scan_get_current_token (scan); + if (script_scan_token_is_symbol_of_value (curtoken, ')')) break; + if (!script_scan_token_is_symbol_of_value (curtoken, ',')) { ++ ply_list_node_t *node; ++ + script_parse_error (&curtoken->location, + "Function parameters should be separated with a ',' and terminated with a ')'"); ++ ++ for (node = ply_list_get_first_node (parameters); ++ node; ++ node = ply_list_get_next_node (parameters, node)) { ++ script_exp_t *sub = ply_list_node_get_data (node); ++ script_parse_exp_free (sub); ++ } ++ ply_list_free (parameters); + return NULL; + } + curtoken = script_scan_get_next_token (scan); + } + script_scan_get_next_token (scan); + exp = script_parse_new_exp_function_exe (exp, parameters, &location); + continue; + } + script_exp_t *key; + + if (script_scan_token_is_symbol_of_value (curtoken, '.')) { + script_scan_get_next_token (scan); + if (script_scan_token_is_identifier (curtoken)) { + key = script_parse_new_exp_string (curtoken->data.string, &curtoken->location); + } else { + script_parse_error (&curtoken->location, + "A dot based hash index must be an identifier"); + return NULL; + } + curtoken = script_scan_get_next_token (scan); + } else if (script_scan_token_is_symbol_of_value (curtoken, '[')) { + script_scan_get_next_token (scan); + key = script_parse_exp (scan); + if (!key) { + script_parse_error (&curtoken->location, + "Expected a valid index expression"); + return NULL; + } + curtoken = script_scan_get_current_token (scan); + if (!script_scan_token_is_symbol_of_value (curtoken, ']')) { +@@ -965,59 +1012,61 @@ void script_parse_op_free (script_op_t *op) + + static void script_parse_op_list_free (ply_list_t *op_list) + { + ply_list_node_t *node; + + for (node = ply_list_get_first_node (op_list); + node; + node = ply_list_get_next_node (op_list, node)) { + script_op_t *op = ply_list_node_get_data (node); + script_parse_op_free (op); + } + ply_list_free (op_list); + return; + } + + script_op_t *script_parse_file (const char *filename) + { + script_scan_t *scan = script_scan_file (filename); + + if (!scan) { + ply_error ("Parser error : Error opening file %s\n", filename); + return NULL; + } + script_scan_token_t *curtoken = script_scan_get_current_token (scan); + script_debug_location_t location = curtoken->location; + ply_list_t *list = script_parse_op_list (scan); + + curtoken = script_scan_get_current_token (scan); + if (curtoken->type != SCRIPT_SCAN_TOKEN_TYPE_EOF) { + script_parse_error (&curtoken->location, "Unparsed characters at end of file"); ++ script_parse_op_list_free (list); + return NULL; + } + script_op_t *op = script_parse_new_op_block (list, &location); + script_scan_free (scan); + return op; + } + + script_op_t *script_parse_string (const char *string, + const char *name) + { + script_scan_t *scan = script_scan_string (string, name); + + if (!scan) { + ply_error ("Parser error : Error creating a parser with a string"); + return NULL; + } + script_scan_token_t *curtoken = script_scan_get_current_token (scan); + script_debug_location_t location = curtoken->location; + ply_list_t *list = script_parse_op_list (scan); + + curtoken = script_scan_get_current_token (scan); + if (curtoken->type != SCRIPT_SCAN_TOKEN_TYPE_EOF) { + script_parse_error (&curtoken->location, "Unparsed characters at end of file"); ++ script_parse_op_list_free (list); + return NULL; + } + script_op_t *op = script_parse_new_op_block (list, &location); + script_scan_free (scan); + return op; + } +-- +2.17.1 + diff --git a/0006-boot-server-free-the-argument-and-triggers.patch b/0006-boot-server-free-the-argument-and-triggers.patch new file mode 100644 index 0000000..26fb57b --- /dev/null +++ b/0006-boot-server-free-the-argument-and-triggers.patch @@ -0,0 +1,351 @@ +From ebb1c642cd62592afc1ece9e0cf5d2ec9dfb84c0 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Mon, 15 Oct 2018 21:56:03 -0400 +Subject: [PATCH 6/6] boot-server: free the argument and triggers + +coverity found some pervasive leaking of the argument +and triggers. + +This commit mops them up. +--- + src/ply-boot-server.c | 17 +++++++++++++++++ + 1 file changed, 17 insertions(+) + +diff --git a/src/ply-boot-server.c b/src/ply-boot-server.c +index 3c1a268..ff0e6fd 100644 +--- a/src/ply-boot-server.c ++++ b/src/ply-boot-server.c +@@ -359,60 +359,61 @@ print_connection_process_identity (ply_boot_connection_t *connection) + + static void + ply_boot_connection_on_request (ply_boot_connection_t *connection) + { + ply_boot_server_t *server; + char *command, *argument; + + assert (connection != NULL); + assert (connection->fd >= 0); + + server = connection->server; + assert (server != NULL); + + if (!ply_boot_connection_read_request (connection, + &command, &argument)) { + ply_trace ("could not read connection request"); + return; + } + + if (ply_is_tracing ()) + print_connection_process_identity (connection); + + if (!ply_boot_connection_is_from_root (connection)) { + ply_error ("request came from non-root user"); + + if (!ply_write (connection->fd, + PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NAK, + strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NAK))) + ply_trace ("could not finish writing is-not-root nak: %m"); + ++ free (argument); + free (command); + return; + } + + if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_UPDATE) == 0) { + if (!ply_write (connection->fd, + PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK, + strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK)) && + errno != EPIPE) + ply_trace ("could not finish writing update reply: %m"); + + ply_trace ("got update request"); + if (server->update_handler != NULL) + server->update_handler (server->user_data, argument, server); + free (argument); + free (command); + return; + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_CHANGE_MODE) == 0) { + if (!ply_write (connection->fd, + PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK, + strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK))) + ply_trace ("could not finish writing update reply: %m"); + + ply_trace ("got change mode notification"); + if (server->change_mode_handler != NULL) + server->change_mode_handler (server->user_data, argument, server); + free (argument); + free (command); + return; + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_SYSTEM_UPDATE) == 0) { +@@ -439,105 +440,112 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_SYSTEM_INITIALIZED) == 0) { + ply_trace ("got system initialized notification"); + if (server->system_initialized_handler != NULL) + server->system_initialized_handler (server->user_data, server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_ERROR) == 0) { + ply_trace ("got error notification"); + if (server->error_handler != NULL) + server->error_handler (server->user_data, server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_SHOW_SPLASH) == 0) { + ply_trace ("got show splash request"); + if (server->show_splash_handler != NULL) + server->show_splash_handler (server->user_data, server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_HIDE_SPLASH) == 0) { + ply_trace ("got hide splash request"); + if (server->hide_splash_handler != NULL) + server->hide_splash_handler (server->user_data, server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_DEACTIVATE) == 0) { + ply_trigger_t *deactivate_trigger; + + ply_trace ("got deactivate request"); + + deactivate_trigger = ply_trigger_new (NULL); + + ply_trigger_add_handler (deactivate_trigger, + (ply_trigger_handler_t) + ply_boot_connection_on_deactivated, + connection); + + if (server->deactivate_handler != NULL) + server->deactivate_handler (server->user_data, deactivate_trigger, server); ++ else ++ ply_trigger_free (deactivate_trigger); + + free (argument); + free (command); + return; + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_REACTIVATE) == 0) { + ply_trace ("got reactivate request"); + if (server->reactivate_handler != NULL) + server->reactivate_handler (server->user_data, server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUIT) == 0) { + bool retain_splash; + ply_trigger_t *quit_trigger; + + retain_splash = (bool) argument[0]; + + ply_trace ("got quit %srequest", retain_splash ? "--retain-splash " : ""); + + quit_trigger = ply_trigger_new (NULL); + + ply_trigger_add_handler (quit_trigger, + (ply_trigger_handler_t) + ply_boot_connection_on_quit_complete, + connection); + + if (server->quit_handler != NULL) + server->quit_handler (server->user_data, retain_splash, quit_trigger, server); ++ else ++ ply_trigger_free (quit_trigger); + + free (argument); + free (command); + return; + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PASSWORD) == 0) { + ply_trigger_t *answer; + + ply_trace ("got password request"); + + answer = ply_trigger_new (NULL); + ply_trigger_add_handler (answer, + (ply_trigger_handler_t) + ply_boot_connection_on_password_answer, + connection); + + if (server->ask_for_password_handler != NULL) { + server->ask_for_password_handler (server->user_data, + argument, + answer, + server); ++ } else { ++ ply_trigger_free (answer); ++ free (argument); + } + /* will reply later + */ + free (command); + return; + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_CACHED_PASSWORD) == 0) { + ply_list_node_t *node; + ply_buffer_t *buffer; + size_t buffer_size; + uint32_t size; + + ply_trace ("got cached password request"); + + buffer = ply_buffer_new (); + + node = ply_list_get_first_node (server->cached_passwords); + + ply_trace ("There are %d cached passwords", + ply_list_get_length (server->cached_passwords)); + + /* Add each answer separated by their NUL terminators into + * a buffer that we write out to the client + */ + while (node != NULL) { + ply_list_node_t *next_node; + const char *password; + + next_node = ply_list_get_next_node (server->cached_passwords, node); + password = (const char *) ply_list_node_get_data (node); + +@@ -565,146 +573,155 @@ ply_boot_connection_on_request (ply_boot_connection_t *connection) + ply_list_get_length (server->cached_passwords)); + if (!ply_write (connection->fd, + PLY_BOOT_PROTOCOL_RESPONSE_TYPE_MULTIPLE_ANSWERS, + strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_MULTIPLE_ANSWERS)) || + !ply_write_uint32 (connection->fd, + size) || + !ply_write (connection->fd, + ply_buffer_get_bytes (buffer), size)) + ply_trace ("could not finish writing cached answer reply: %m"); + } + + ply_buffer_free (buffer); + free (command); + return; + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_QUESTION) == 0) { + ply_trigger_t *answer; + + ply_trace ("got question request"); + + answer = ply_trigger_new (NULL); + ply_trigger_add_handler (answer, + (ply_trigger_handler_t) + ply_boot_connection_on_question_answer, + connection); + + if (server->ask_question_handler != NULL) { + server->ask_question_handler (server->user_data, + argument, + answer, + server); ++ } else { ++ ply_trigger_free (answer); ++ free (argument); + } + /* will reply later + */ + free (command); + return; + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_SHOW_MESSAGE) == 0) { + ply_trace ("got show message request"); + if (server->display_message_handler != NULL) + server->display_message_handler (server->user_data, argument, server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_HIDE_MESSAGE) == 0) { + ply_trace ("got hide message request"); + if (server->hide_message_handler != NULL) + server->hide_message_handler (server->user_data, argument, server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_KEYSTROKE) == 0) { + ply_trigger_t *answer; + + ply_trace ("got keystroke request"); + + answer = ply_trigger_new (NULL); + ply_trigger_add_handler (answer, + (ply_trigger_handler_t) + ply_boot_connection_on_keystroke_answer, + connection); + + if (server->watch_for_keystroke_handler != NULL) { + server->watch_for_keystroke_handler (server->user_data, + argument, + answer, + server); ++ } else { ++ ply_trigger_free (answer); ++ free (argument); + } + /* will reply later + */ + free (command); + return; + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_KEYSTROKE_REMOVE) == 0) { + ply_trace ("got keystroke remove request"); + if (server->ignore_keystroke_handler != NULL) + server->ignore_keystroke_handler (server->user_data, + argument, + server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PROGRESS_PAUSE) == 0) { + ply_trace ("got progress pause request"); + if (server->progress_pause_handler != NULL) + server->progress_pause_handler (server->user_data, + server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PROGRESS_UNPAUSE) == 0) { + ply_trace ("got progress unpause request"); + if (server->progress_unpause_handler != NULL) + server->progress_unpause_handler (server->user_data, + server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_NEWROOT) == 0) { + ply_trace ("got newroot request"); + if (server->newroot_handler != NULL) + server->newroot_handler (server->user_data, argument, server); + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_HAS_ACTIVE_VT) == 0) { + bool answer = false; + + ply_trace ("got has_active vt? request"); + if (server->has_active_vt_handler != NULL) + answer = server->has_active_vt_handler (server->user_data, server); + + if (!answer) { + if (!ply_write (connection->fd, + PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NAK, + strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NAK))) + ply_trace ("could not finish writing nak: %m"); + ++ free (argument); + free (command); + return; + } + } else if (strcmp (command, PLY_BOOT_PROTOCOL_REQUEST_TYPE_PING) != 0) { + ply_error ("received unknown command '%s' from client", command); + + if (!ply_write (connection->fd, + PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NAK, + strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_NAK))) + ply_trace ("could not finish writing ping reply: %m"); + ++ free (argument); + free (command); + return; + } + + if (!ply_write (connection->fd, + PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK, + strlen (PLY_BOOT_PROTOCOL_RESPONSE_TYPE_ACK))) + ply_trace ("could not finish writing ack: %m"); ++ free (argument); + free (command); + } + + static void + ply_boot_connection_on_hangup (ply_boot_connection_t *connection) + { + ply_list_node_t *node; + ply_boot_server_t *server; + + assert (connection != NULL); + assert (connection->server != NULL); + + server = connection->server; + + node = ply_list_find_node (server->connections, connection); + + assert (node != NULL); + + ply_boot_connection_free (connection); + ply_list_remove_node (server->connections, node); + } + + static void + ply_boot_server_on_new_connection (ply_boot_server_t *server) + { + ply_boot_connection_t *connection; + int fd; + + assert (server != NULL); + +-- +2.17.1 + diff --git a/0006-pixel-buffer-switch-device-rotation-to-an-enum.patch b/0006-pixel-buffer-switch-device-rotation-to-an-enum.patch new file mode 100644 index 0000000..bd94acc --- /dev/null +++ b/0006-pixel-buffer-switch-device-rotation-to-an-enum.patch @@ -0,0 +1,80 @@ +From 555257c74f75bbb1086155fca52c29d71399b305 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Tue, 10 Apr 2018 16:40:06 -0400 +Subject: [PATCH 6/6] pixel-buffer: switch device rotation to an enum + +Right now device rotation is stored in a bare integer. + +For clarity, switch that to an enum. +--- + src/libply-splash-core/ply-pixel-buffer.c | 12 +++++++----- + src/libply-splash-core/ply-pixel-buffer.h | 13 ++++++++----- + 2 files changed, 15 insertions(+), 10 deletions(-) + +diff --git a/src/libply-splash-core/ply-pixel-buffer.c b/src/libply-splash-core/ply-pixel-buffer.c +index a337407..de3b107 100644 +--- a/src/libply-splash-core/ply-pixel-buffer.c ++++ b/src/libply-splash-core/ply-pixel-buffer.c +@@ -50,7 +50,8 @@ struct _ply_pixel_buffer + ply_region_t *updated_areas; /* in device pixels */ + uint32_t is_opaque : 1; + int device_scale; +- int device_rotation; ++ ++ ply_pixel_buffer_rotation_t device_rotation; + }; + + static inline void ply_pixel_buffer_blend_value_at_pixel (ply_pixel_buffer_t *buffer, +@@ -363,13 +364,14 @@ ply_pixel_buffer_new (unsigned long width, + } + + ply_pixel_buffer_t * +-ply_pixel_buffer_new_with_device_rotation (unsigned long width, +- unsigned long height, +- int device_rotation) ++ply_pixel_buffer_new_with_device_rotation (unsigned long width, ++ unsigned long height, ++ ply_pixel_buffer_rotation_t device_rotation) + { + ply_pixel_buffer_t *buffer; + +- if (device_rotation >= PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE) { ++ if (device_rotation == PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE || ++ device_rotation == PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE) { + unsigned long tmp = width; + width = height; + height = tmp; +diff --git a/src/libply-splash-core/ply-pixel-buffer.h b/src/libply-splash-core/ply-pixel-buffer.h +index 7736dd3..ea7f833 100644 +--- a/src/libply-splash-core/ply-pixel-buffer.h ++++ b/src/libply-splash-core/ply-pixel-buffer.h +@@ -37,10 +37,13 @@ typedef struct _ply_pixel_buffer ply_pixel_buffer_t; + | ((uint8_t) (CLAMP (g * 255.0, 0.0, 255.0)) << 8) \ + | ((uint8_t) (CLAMP (b * 255.0, 0.0, 255.0)))) + +-#define PLY_PIXEL_BUFFER_ROTATE_UPRIGHT 0 +-#define PLY_PIXEL_BUFFER_ROTATE_UPSIDE_DOWN 1 +-#define PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE 2 +-#define PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE 3 ++typedef enum ++{ ++ PLY_PIXEL_BUFFER_ROTATE_UPRIGHT = 0, ++ PLY_PIXEL_BUFFER_ROTATE_UPSIDE_DOWN, ++ PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE, ++ PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE ++} ply_pixel_buffer_rotation_t; + + #ifndef PLY_HIDE_FUNCTION_DECLARATIONS + ply_pixel_buffer_t *ply_pixel_buffer_new (unsigned long width, +@@ -48,7 +51,7 @@ ply_pixel_buffer_t *ply_pixel_buffer_new (unsigned long width, + ply_pixel_buffer_t * + ply_pixel_buffer_new_with_device_rotation (unsigned long width, + unsigned long height, +- int device_rotation); ++ ply_pixel_buffer_rotation_t device_rotation); + void ply_pixel_buffer_free (ply_pixel_buffer_t *buffer); + void ply_pixel_buffer_get_size (ply_pixel_buffer_t *buffer, + ply_rectangle_t *size); +-- +2.17.0 + diff --git a/0007-terminal-add-include-for-sysmacros.h.patch b/0007-terminal-add-include-for-sysmacros.h.patch new file mode 100644 index 0000000..41b9311 --- /dev/null +++ b/0007-terminal-add-include-for-sysmacros.h.patch @@ -0,0 +1,27 @@ +From e12b5ee34c619e88509f59424068417790b69e04 Mon Sep 17 00:00:00 2001 +From: Sakaki +Date: Fri, 18 Aug 2017 10:08:23 -0400 +Subject: [PATCH] terminal: add include for sysmacros.h + +That file is, in some cases, not included implicitly by sys/types.h. + +This commit explicitly includes it. +--- + src/libply-splash-core/ply-terminal.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/libply-splash-core/ply-terminal.c b/src/libply-splash-core/ply-terminal.c +index a0954f2..f3b32fe 100644 +--- a/src/libply-splash-core/ply-terminal.c ++++ b/src/libply-splash-core/ply-terminal.c +@@ -32,6 +32,7 @@ + #include + #include + #include ++#include + #include + #include + #include +-- +2.17.0 + diff --git a/plymouth-update-initrd b/plymouth-update-initrd old mode 100755 new mode 100644