alaurie / rpms / plymouth

Forked from rpms/plymouth 4 days ago
Clone

Blame SOURCES/0003-ply-device-manager-Move-verify_drm_device-higher-up-.patch

01bb59
From 7fbd59d04e971d327c3aaba417765f25c3168447 Mon Sep 17 00:00:00 2001
01bb59
From: Hans de Goede <hdegoede@redhat.com>
01bb59
Date: Wed, 28 Sep 2022 15:14:00 +0200
01bb59
Subject: [PATCH 3/6] ply-device-manager: Move verify_drm_device() higher up in
01bb59
 the file
01bb59
01bb59
Move verify_drm_device() higher up in ply-device-manager.c, this is
01bb59
a preparation patch for the next patch in this series.
01bb59
01bb59
This is a pure move without any changes to the moved block.
01bb59
01bb59
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
01bb59
---
01bb59
 src/libply-splash-core/ply-device-manager.c | 68 ++++++++++-----------
01bb59
 1 file changed, 34 insertions(+), 34 deletions(-)
01bb59
01bb59
diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c
01bb59
index b2484b4..015bd70 100644
01bb59
--- a/src/libply-splash-core/ply-device-manager.c
01bb59
+++ b/src/libply-splash-core/ply-device-manager.c
01bb59
@@ -236,60 +236,94 @@ fb_device_has_drm_device (ply_device_manager_t *manager,
01bb59
         ply_trace ("trying to find associated drm node for fb device (path: %s)", id_path);
01bb59
 
01bb59
         udev_enumerate_scan_devices (card_matches);
01bb59
 
01bb59
         /* there should only ever be at most one match so we don't iterate through
01bb59
          * the list, but just look at the first entry */
01bb59
         card_entry = udev_enumerate_get_list_entry (card_matches);
01bb59
 
01bb59
         if (card_entry != NULL) {
01bb59
                 struct udev_device *card_device = NULL;
01bb59
                 const char *card_node;
01bb59
                 const char *card_path;
01bb59
 
01bb59
                 card_path = udev_list_entry_get_name (card_entry);
01bb59
                 card_device = udev_device_new_from_syspath (manager->udev_context, card_path);
01bb59
                 card_node = udev_device_get_devnode (card_device);
01bb59
                 if (card_node != NULL && drm_device_in_use (manager, card_node))
01bb59
                         has_drm_device = true;
01bb59
                 else
01bb59
                         ply_trace ("no card node!");
01bb59
 
01bb59
                 udev_device_unref (card_device);
01bb59
         } else {
01bb59
                 ply_trace ("no card entry!");
01bb59
         }
01bb59
 
01bb59
         udev_enumerate_unref (card_matches);
01bb59
         return has_drm_device;
01bb59
 }
01bb59
 
01bb59
+static bool
01bb59
+verify_drm_device (struct udev_device *device)
01bb59
+{
01bb59
+        const char *id_path;
01bb59
+
01bb59
+        /*
01bb59
+         * Simple-framebuffer devices driven by simpledrm lack information
01bb59
+         * like panel-rotation info and physical size, causing the splash
01bb59
+         * to briefly render on its side / without HiDPI scaling, switching
01bb59
+         * to the correct rendering when the native driver loads.
01bb59
+         * To avoid this treat simpledrm devices as fbdev devices and only
01bb59
+         * use them after the timeout.
01bb59
+         */
01bb59
+        id_path = udev_device_get_property_value (device, "ID_PATH");
01bb59
+        if (!ply_string_has_prefix (id_path, "platform-simple-framebuffer"))
01bb59
+                return true; /* Not a SimpleDRM device */
01bb59
+
01bb59
+        /*
01bb59
+         * With nomodeset, no native drivers will load, so SimpleDRM devices
01bb59
+         * should be used immediately.
01bb59
+         */
01bb59
+        if (ply_kernel_command_line_has_argument ("nomodeset"))
01bb59
+                return true;
01bb59
+
01bb59
+        /*
01bb59
+         * Some firmwares leave the panel black at boot. Allow enabling SimpleDRM
01bb59
+         * use from the cmdline to show something to the user ASAP.
01bb59
+         */
01bb59
+        if (ply_kernel_command_line_has_argument ("plymouth.use-simpledrm"))
01bb59
+                return true;
01bb59
+
01bb59
+        return false;
01bb59
+}
01bb59
+
01bb59
 static bool
01bb59
 create_devices_for_udev_device (ply_device_manager_t *manager,
01bb59
                                 struct udev_device   *device)
01bb59
 {
01bb59
         const char *device_path;
01bb59
         bool created = false;
01bb59
 
01bb59
         device_path = udev_device_get_devnode (device);
01bb59
 
01bb59
         if (device_path != NULL) {
01bb59
                 const char *subsystem;
01bb59
                 ply_renderer_type_t renderer_type = PLY_RENDERER_TYPE_NONE;
01bb59
 
01bb59
                 subsystem = udev_device_get_subsystem (device);
01bb59
                 ply_trace ("device subsystem is %s", subsystem);
01bb59
 
01bb59
                 if (subsystem != NULL && strcmp (subsystem, SUBSYSTEM_DRM) == 0) {
01bb59
                         ply_trace ("found DRM device %s", device_path);
01bb59
                         renderer_type = PLY_RENDERER_TYPE_DRM;
01bb59
                 } else if (strcmp (subsystem, SUBSYSTEM_FRAME_BUFFER) == 0) {
01bb59
                         ply_trace ("found frame buffer device %s", device_path);
01bb59
                         if (!fb_device_has_drm_device (manager, device))
01bb59
                                 renderer_type = PLY_RENDERER_TYPE_FRAME_BUFFER;
01bb59
                         else
01bb59
                                 ply_trace ("ignoring, since there's a DRM device associated with it");
01bb59
                 }
01bb59
 
01bb59
                 if (renderer_type != PLY_RENDERER_TYPE_NONE) {
01bb59
                         ply_terminal_t *terminal = NULL;
01bb59
 
01bb59
@@ -378,94 +412,60 @@ create_devices_for_subsystem (ply_device_manager_t *manager,
01bb59
 static void
01bb59
 on_drm_udev_add_or_change (ply_device_manager_t *manager,
01bb59
                            const char           *action,
01bb59
                            const char           *device_path,
01bb59
                            struct udev_device   *device)
01bb59
 {
01bb59
         ply_renderer_t *renderer;
01bb59
         bool changed;
01bb59
 
01bb59
         renderer = ply_hashtable_lookup (manager->renderers, (void *) device_path);
01bb59
         if (renderer == NULL) {
01bb59
                 /* We also try to create the renderer again on change events,
01bb59
                  * renderer creation fails when no outputs are connected and
01bb59
                  * this may have changed.
01bb59
                  */
01bb59
                 create_devices_for_udev_device (manager, device);
01bb59
                 return;
01bb59
         }
01bb59
 
01bb59
         /* Renderer exists, bail if this is not a change event */
01bb59
         if (strcmp (action, "change"))
01bb59
                 return;
01bb59
 
01bb59
         changed = ply_renderer_handle_change_event (renderer);
01bb59
         if (changed) {
01bb59
                 free_displays_for_renderer (manager, renderer);
01bb59
                 create_pixel_displays_for_renderer (manager, renderer);
01bb59
         }
01bb59
 }
01bb59
 
01bb59
-static bool
01bb59
-verify_drm_device (struct udev_device *device)
01bb59
-{
01bb59
-        const char *id_path;
01bb59
-
01bb59
-        /*
01bb59
-         * Simple-framebuffer devices driven by simpledrm lack information
01bb59
-         * like panel-rotation info and physical size, causing the splash
01bb59
-         * to briefly render on its side / without HiDPI scaling, switching
01bb59
-         * to the correct rendering when the native driver loads.
01bb59
-         * To avoid this treat simpledrm devices as fbdev devices and only
01bb59
-         * use them after the timeout.
01bb59
-         */
01bb59
-        id_path = udev_device_get_property_value (device, "ID_PATH");
01bb59
-        if (!ply_string_has_prefix (id_path, "platform-simple-framebuffer"))
01bb59
-                return true; /* Not a SimpleDRM device */
01bb59
-
01bb59
-        /*
01bb59
-         * With nomodeset, no native drivers will load, so SimpleDRM devices
01bb59
-         * should be used immediately.
01bb59
-         */
01bb59
-        if (ply_kernel_command_line_has_argument ("nomodeset"))
01bb59
-                return true;
01bb59
-
01bb59
-        /*
01bb59
-         * Some firmwares leave the panel black at boot. Allow enabling SimpleDRM
01bb59
-         * use from the cmdline to show something to the user ASAP.
01bb59
-         */
01bb59
-        if (ply_kernel_command_line_has_argument ("plymouth.use-simpledrm"))
01bb59
-                return true;
01bb59
-
01bb59
-        return false;
01bb59
-}
01bb59
-
01bb59
 static bool
01bb59
 verify_add_or_change (ply_device_manager_t *manager,
01bb59
                       const char           *action,
01bb59
                       const char           *device_path,
01bb59
                       struct udev_device   *device)
01bb59
 {
01bb59
         const char *subsystem = udev_device_get_subsystem (device);
01bb59
 
01bb59
         if (strcmp (action, "add") && strcmp (action, "change"))
01bb59
                 return false;
01bb59
 
01bb59
         subsystem = udev_device_get_subsystem (device);
01bb59
 
01bb59
         if (strcmp (subsystem, SUBSYSTEM_DRM) == 0) {
01bb59
                 if (manager->local_console_managed && manager->local_console_is_text) {
01bb59
                         ply_trace ("ignoring since we're already using text splash for local console");
01bb59
                         return false;
01bb59
                 }
01bb59
 
01bb59
                 if (!verify_drm_device (device)) {
01bb59
                         ply_trace ("ignoring since we only handle SimpleDRM devices after timeout");
01bb59
                         return false;
01bb59
                 }
01bb59
         } else {
01bb59
                 ply_trace ("ignoring since we only handle subsystem %s devices after timeout", subsystem);
01bb59
                 return false;
01bb59
         }
01bb59
 
01bb59
         return true;
01bb59
 }
01bb59
-- 
01bb59
2.37.0.rc1
01bb59