alaurie / rpms / plymouth

Forked from rpms/plymouth 4 days ago
Clone

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

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