Blame SOURCES/cursor-fix.patch

862bc8
From b96ff001587de11eaf98ace71b196cc5ab4cf007 Mon Sep 17 00:00:00 2001
862bc8
From: Ray Strode <rstrode@redhat.com>
862bc8
Date: Mon, 14 Jul 2014 08:04:54 -0400
862bc8
Subject: [PATCH 1/5] seat: be a little more forgiving in the case there's no
862bc8
 open terminal
862bc8
862bc8
We can end up in a situation where a seat object doesn't have a terminal
862bc8
associated with it.  In that case we shouldn't crash, but continue on
862bc8
with no input available for that seat.
862bc8
862bc8
https://bugs.freedesktop.org/show_bug.cgi?id=80553
862bc8
---
862bc8
 src/libply-splash-core/ply-seat.c | 23 +++++++++++++++++++----
862bc8
 1 file changed, 19 insertions(+), 4 deletions(-)
862bc8
862bc8
diff --git a/src/libply-splash-core/ply-seat.c b/src/libply-splash-core/ply-seat.c
862bc8
index 2ac8bf7..cd7e5bc 100644
862bc8
--- a/src/libply-splash-core/ply-seat.c
862bc8
+++ b/src/libply-splash-core/ply-seat.c
862bc8
@@ -127,68 +127,83 @@ ply_seat_open (ply_seat_t          *seat,
862bc8
   if (renderer_type != PLY_RENDERER_TYPE_NONE)
862bc8
     {
862bc8
       ply_renderer_t *renderer;
862bc8
 
862bc8
       renderer = ply_renderer_new (renderer_type, device, seat->terminal);
862bc8
 
862bc8
       if (!ply_renderer_open (renderer))
862bc8
         {
862bc8
           ply_trace ("could not open renderer for %s", device);
862bc8
           ply_renderer_free (renderer);
862bc8
 
862bc8
           seat->renderer = NULL;
862bc8
           seat->renderer_active = false;
862bc8
 
862bc8
           if (renderer_type != PLY_RENDERER_TYPE_AUTO)
862bc8
             return false;
862bc8
         }
862bc8
       else
862bc8
         {
862bc8
           seat->renderer = renderer;
862bc8
           seat->renderer_active = true;
862bc8
         }
862bc8
     }
862bc8
 
862bc8
   if (seat->renderer != NULL)
862bc8
     {
862bc8
       seat->keyboard = ply_keyboard_new_for_renderer (seat->renderer);
862bc8
       add_pixel_displays (seat);
862bc8
 
862bc8
     }
862bc8
-  else
862bc8
+  else if (seat->terminal != NULL)
862bc8
     {
862bc8
       seat->keyboard = ply_keyboard_new_for_terminal (seat->terminal);
862bc8
     }
862bc8
-  add_text_displays (seat);
862bc8
 
862bc8
-  ply_keyboard_watch_for_input (seat->keyboard);
862bc8
-  seat->keyboard_active = true;
862bc8
+  if (seat->terminal != NULL)
862bc8
+    {
862bc8
+      add_text_displays (seat);
862bc8
+    }
862bc8
+  else
862bc8
+    {
862bc8
+      ply_trace ("not adding text display for seat, since seat has no associated terminal");
862bc8
+    }
862bc8
+
862bc8
+  if (seat->keyboard != NULL)
862bc8
+    {
862bc8
+      ply_keyboard_watch_for_input (seat->keyboard);
862bc8
+      seat->keyboard_active = true;
862bc8
+    }
862bc8
+  else
862bc8
+    {
862bc8
+      ply_trace ("not watching seat for input");
862bc8
+    }
862bc8
 
862bc8
   return true;
862bc8
 }
862bc8
 
862bc8
 bool
862bc8
 ply_seat_is_open (ply_seat_t *seat)
862bc8
 {
862bc8
   return ply_list_get_length (seat->pixel_displays) > 0 ||
862bc8
          ply_list_get_length (seat->text_displays) > 0;
862bc8
 }
862bc8
 
862bc8
 void
862bc8
 ply_seat_deactivate_keyboard (ply_seat_t *seat)
862bc8
 {
862bc8
   if (!seat->keyboard_active)
862bc8
     return;
862bc8
 
862bc8
   seat->keyboard_active = false;
862bc8
 
862bc8
   if (seat->keyboard == NULL)
862bc8
     return;
862bc8
 
862bc8
   ply_trace ("deactivating keybord");
862bc8
   ply_keyboard_stop_watching_for_input (seat->keyboard);
862bc8
 }
862bc8
 
862bc8
 void
862bc8
 ply_seat_deactivate_renderer (ply_seat_t *seat)
862bc8
 {
862bc8
   if (!seat->renderer_active)
862bc8
-- 
862bc8
2.3.7
862bc8
862bc8
862bc8
From b5ed92bc2efd0b52e901a67ea8e5afa809ca3598 Mon Sep 17 00:00:00 2001
862bc8
From: Ray Strode <rstrode@redhat.com>
862bc8
Date: Fri, 3 Jul 2015 09:29:39 -0400
862bc8
Subject: [PATCH 2/5] main: show cursor on crash
862bc8
862bc8
---
862bc8
 src/main.c | 3 +++
862bc8
 1 file changed, 3 insertions(+)
862bc8
862bc8
diff --git a/src/main.c b/src/main.c
862bc8
index 77fa96f..db5c281 100644
862bc8
--- a/src/main.c
862bc8
+++ b/src/main.c
862bc8
@@ -2051,66 +2051,69 @@ on_error_message (ply_buffer_t *debug_buffer,
862bc8
 {
862bc8
   ply_buffer_append_bytes (debug_buffer, bytes, number_of_bytes);
862bc8
 }
862bc8
 
862bc8
 static void
862bc8
 dump_debug_buffer_to_file (void)
862bc8
 {
862bc8
   int fd;
862bc8
   const char *bytes;
862bc8
   size_t size;
862bc8
 
862bc8
   fd = open (debug_buffer_path,
862bc8
              O_WRONLY | O_CREAT | O_TRUNC, 0600);
862bc8
 
862bc8
   if (fd < 0)
862bc8
     return;
862bc8
 
862bc8
   size = ply_buffer_get_size (debug_buffer);
862bc8
   bytes = ply_buffer_get_bytes (debug_buffer);
862bc8
   ply_write (fd, bytes, size);
862bc8
   close (fd);
862bc8
 }
862bc8
 
862bc8
  #include <termios.h>
862bc8
  #include <unistd.h>
862bc8
 static void
862bc8
 on_crash (int signum)
862bc8
 {
862bc8
     struct termios term_attributes;
862bc8
     int fd;
862bc8
+    static const char *show_cursor_sequence = "\033[?25h";
862bc8
 
862bc8
     fd = open ("/dev/tty1", O_RDWR | O_NOCTTY);
862bc8
     if (fd < 0) fd = open ("/dev/hvc0", O_RDWR | O_NOCTTY);
862bc8
 
862bc8
     ioctl (fd, KDSETMODE, KD_TEXT);
862bc8
 
862bc8
+    write (fd, show_cursor_sequence, sizeof (show_cursor_sequence) - 1);
862bc8
+
862bc8
     tcgetattr (fd, &term_attributes);
862bc8
 
862bc8
     term_attributes.c_iflag |= BRKINT | IGNPAR | ICRNL | IXON;
862bc8
     term_attributes.c_oflag |= OPOST;
862bc8
     term_attributes.c_lflag |= ECHO | ICANON | ISIG | IEXTEN;
862bc8
 
862bc8
     tcsetattr (fd, TCSAFLUSH, &term_attributes);
862bc8
 
862bc8
     close (fd);
862bc8
 
862bc8
     if (debug_buffer != NULL)
862bc8
       {
862bc8
         dump_debug_buffer_to_file ();
862bc8
         sleep (30);
862bc8
       }
862bc8
 
862bc8
     if (pid_file != NULL)
862bc8
       {
862bc8
         unlink (pid_file);
862bc8
         free (pid_file);
862bc8
         pid_file = NULL;
862bc8
       }
862bc8
 
862bc8
     signal (signum, SIG_DFL);
862bc8
     raise(signum);
862bc8
 }
862bc8
 
862bc8
 static void
862bc8
 write_pid_file (const char *filename)
862bc8
 {
862bc8
-- 
862bc8
2.3.7
862bc8
862bc8
862bc8
From 4278596f4f5a6856aff50e97b7c0ff05aed67372 Mon Sep 17 00:00:00 2001
862bc8
From: Frederic Crozat <fcrozat@suse.com>
862bc8
Date: Thu, 12 Jun 2014 15:01:37 +0200
862bc8
Subject: [PATCH 3/5] device-manager: only call ply_terminal_free
862bc8
862bc8
ply_terminal_free will call ply_terminal_close anyway and is guarded
862bc8
against NULL terminal (ply_terminal_close is not).
862bc8
---
862bc8
 src/libply-splash-core/ply-device-manager.c | 1 -
862bc8
 1 file changed, 1 deletion(-)
862bc8
862bc8
diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c
862bc8
index 8f5360c..17607f4 100644
862bc8
--- a/src/libply-splash-core/ply-device-manager.c
862bc8
+++ b/src/libply-splash-core/ply-device-manager.c
862bc8
@@ -415,61 +415,60 @@ free_seats (ply_device_manager_t *manager)
862bc8
 {
862bc8
   ply_list_node_t *node;
862bc8
 
862bc8
   ply_trace ("removing seats");
862bc8
   node = ply_list_get_first_node (manager->seats);
862bc8
   while (node != NULL)
862bc8
     {
862bc8
       ply_seat_t *seat;
862bc8
       ply_list_node_t *next_node;
862bc8
 
862bc8
       seat = ply_list_node_get_data (node);
862bc8
       next_node = ply_list_get_next_node (manager->seats, node);
862bc8
 
862bc8
       if (manager->seat_removed_handler != NULL)
862bc8
         manager->seat_removed_handler (manager->seat_event_handler_data, seat);
862bc8
 
862bc8
       ply_seat_free (seat);
862bc8
       ply_list_remove_node (manager->seats, node);
862bc8
 
862bc8
       node = next_node;
862bc8
     }
862bc8
 }
862bc8
 
862bc8
 static void
862bc8
 free_terminal (char                 *device,
862bc8
                ply_terminal_t       *terminal,
862bc8
                ply_device_manager_t *manager)
862bc8
 {
862bc8
   ply_hashtable_remove (manager->terminals, device);
862bc8
 
862bc8
-  ply_terminal_close (terminal);
862bc8
   ply_terminal_free (terminal);
862bc8
 }
862bc8
 
862bc8
 static void
862bc8
 free_terminals (ply_device_manager_t *manager)
862bc8
 {
862bc8
   ply_hashtable_foreach (manager->terminals,
862bc8
                          (ply_hashtable_foreach_func_t *)
862bc8
                          free_terminal,
862bc8
                          manager);
862bc8
 }
862bc8
 
862bc8
 static ply_terminal_t *
862bc8
 get_terminal (ply_device_manager_t *manager,
862bc8
               const char           *device_name)
862bc8
 {
862bc8
   char *full_name = NULL;
862bc8
   ply_terminal_t *terminal;
862bc8
 
862bc8
   if (strncmp (device_name, "/dev/", strlen ("/dev/")) == 0)
862bc8
     full_name = strdup (device_name);
862bc8
   else
862bc8
     asprintf (&full_name, "/dev/%s", device_name);
862bc8
 
862bc8
   if (strcmp (full_name, "/dev/tty0") == 0 ||
862bc8
       strcmp (full_name, "/dev/tty") == 0 ||
862bc8
       strcmp (full_name, ply_terminal_get_name (manager->local_console_terminal)) == 0)
862bc8
     {
862bc8
       terminal = manager->local_console_terminal;
862bc8
 
862bc8
-- 
862bc8
2.3.7
862bc8
862bc8
862bc8
From e7048fdd1a40ed683fc706a40816cc490a693ba9 Mon Sep 17 00:00:00 2001
862bc8
From: Ray Strode <rstrode@redhat.com>
862bc8
Date: Wed, 7 Jan 2015 16:24:57 -0500
862bc8
Subject: [PATCH 4/5] device-manager: try fb device if drm device failed
862bc8
862bc8
If the drm device failed to work, then fall back to the fb device.
862bc8
862bc8
Right now, we ignore fb devices that have associated drm devices.
862bc8
862bc8
This may fix vmwgfx.
862bc8
---
862bc8
 src/libply-splash-core/ply-device-manager.c | 39 ++++++++++++++++++++++++++++-
862bc8
 1 file changed, 38 insertions(+), 1 deletion(-)
862bc8
862bc8
diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c
862bc8
index 17607f4..cc153e2 100644
862bc8
--- a/src/libply-splash-core/ply-device-manager.c
862bc8
+++ b/src/libply-splash-core/ply-device-manager.c
862bc8
@@ -88,95 +88,132 @@ attach_to_event_loop (ply_device_manager_t *manager,
862bc8
 }
862bc8
 
862bc8
 static bool
862bc8
 device_is_for_local_console (ply_device_manager_t *manager,
862bc8
                              struct udev_device   *device)
862bc8
 {
862bc8
   const char *device_path;
862bc8
   struct udev_device *bus_device;
862bc8
   char *bus_device_path;
862bc8
   const char *boot_vga;
862bc8
   bool for_local_console;
862bc8
 
862bc8
   /* Look at the associated bus device to see if this card is the
862bc8
    * card the kernel is using for its console. */
862bc8
   device_path = udev_device_get_syspath (device);
862bc8
   asprintf (&bus_device_path, "%s/device", device_path);
862bc8
   bus_device = udev_device_new_from_syspath (manager->udev_context, bus_device_path);
862bc8
 
862bc8
   boot_vga = udev_device_get_sysattr_value (bus_device, "boot_vga");
862bc8
   free (bus_device_path);
862bc8
 
862bc8
   if (boot_vga != NULL && strcmp (boot_vga, "1") == 0)
862bc8
     for_local_console = true;
862bc8
   else
862bc8
     for_local_console = false;
862bc8
 
862bc8
   return for_local_console;
862bc8
 }
862bc8
 
862bc8
 static bool
862bc8
+drm_device_in_use (ply_device_manager_t *manager,
862bc8
+                   const char           *device_path)
862bc8
+{
862bc8
+  ply_list_node_t *node;
862bc8
+
862bc8
+  node = ply_list_get_first_node (manager->seats);
862bc8
+  while (node != NULL)
862bc8
+    {
862bc8
+      ply_seat_t *seat;
862bc8
+      ply_renderer_t *renderer;
862bc8
+      ply_list_node_t *next_node;
862bc8
+      const char *renderer_device_path;
862bc8
+
862bc8
+      seat = ply_list_node_get_data (node);
862bc8
+      next_node = ply_list_get_next_node (manager->seats, node);
862bc8
+      renderer = ply_seat_get_renderer (seat);
862bc8
+
862bc8
+      if (renderer != NULL)
862bc8
+        {
862bc8
+          renderer_device_path = ply_renderer_get_device_name (renderer);
862bc8
+
862bc8
+          if (renderer_device_path != NULL)
862bc8
+            {
862bc8
+              if (strcmp (device_path, renderer_device_path) == 0)
862bc8
+                {
862bc8
+                  return true;
862bc8
+                }
862bc8
+            }
862bc8
+        }
862bc8
+
862bc8
+      node = next_node;
862bc8
+    }
862bc8
+
862bc8
+  return false;
862bc8
+}
862bc8
+
862bc8
+static bool
862bc8
 fb_device_has_drm_device (ply_device_manager_t *manager,
862bc8
                           struct udev_device   *fb_device)
862bc8
 {
862bc8
   struct udev_enumerate *card_matches;
862bc8
   struct udev_list_entry *card_entry;
862bc8
   const char *id_path;
862bc8
   bool has_drm_device = false;
862bc8
 
862bc8
   /* We want to see if the framebuffer is associated with a DRM-capable
862bc8
    * graphics card, if it is, we'll use the DRM device */
862bc8
   card_matches = udev_enumerate_new (manager->udev_context);
862bc8
   udev_enumerate_add_match_is_initialized(card_matches);
862bc8
   udev_enumerate_add_match_parent (card_matches, udev_device_get_parent (fb_device));
862bc8
   udev_enumerate_add_match_subsystem (card_matches, "drm");
862bc8
   id_path = udev_device_get_property_value (fb_device, "ID_PATH");
862bc8
   udev_enumerate_add_match_property (card_matches, "ID_PATH", id_path);
862bc8
 
862bc8
   ply_trace ("trying to find associated drm node for fb device (path: %s)", id_path);
862bc8
 
862bc8
   udev_enumerate_scan_devices (card_matches);
862bc8
 
862bc8
   /* there should only ever be at most one match so we don't iterate through
862bc8
    * the list, but just look at the first entry */
862bc8
   card_entry = udev_enumerate_get_list_entry (card_matches);
862bc8
 
862bc8
   if (card_entry != NULL)
862bc8
     {
862bc8
       struct udev_device *card_device = NULL;
862bc8
       const char *card_node;
862bc8
       const char *card_path;
862bc8
 
862bc8
       card_path = udev_list_entry_get_name (card_entry);
862bc8
       card_device = udev_device_new_from_syspath (manager->udev_context, card_path);
862bc8
       card_node = udev_device_get_devnode (card_device);
862bc8
-      if (card_node != NULL)
862bc8
+      if (card_node != NULL && drm_device_in_use (manager, card_node))
862bc8
         has_drm_device = true;
862bc8
       else
862bc8
         ply_trace ("no card node!");
862bc8
 
862bc8
       udev_device_unref (card_device);
862bc8
     }
862bc8
   else
862bc8
     {
862bc8
       ply_trace ("no card entry!");
862bc8
     }
862bc8
 
862bc8
   udev_enumerate_unref (card_matches);
862bc8
   return has_drm_device;
862bc8
 }
862bc8
 
862bc8
 static void
862bc8
 create_seat_for_udev_device (ply_device_manager_t *manager,
862bc8
                              struct udev_device   *device)
862bc8
 {
862bc8
   bool for_local_console;
862bc8
   const char *device_path;
862bc8
   ply_terminal_t *terminal = NULL;
862bc8
 
862bc8
   for_local_console = device_is_for_local_console (manager, device);
862bc8
 
862bc8
   ply_trace ("device is for local console: %s", for_local_console? "yes" : "no");
862bc8
 
862bc8
   if (for_local_console)
862bc8
     terminal = manager->local_console_terminal;
862bc8
 
862bc8
-- 
862bc8
2.3.7
862bc8
862bc8
862bc8
From b9989b912fb394c00d3d4740eb72a25f80a8bc71 Mon Sep 17 00:00:00 2001
862bc8
From: Ray Strode <rstrode@redhat.com>
862bc8
Date: Fri, 3 Jul 2015 10:38:47 -0400
862bc8
Subject: [PATCH 5/5] device-manager: don't try to load graphical splash after
862bc8
 using text splash
862bc8
862bc8
We only support loading one splash at a time at the moment, so this
862bc8
commit makes sure we don't load a graphical splash after already loading
862bc8
a text splash
862bc8
---
862bc8
 src/libply-splash-core/ply-device-manager.c | 10 +++++++++-
862bc8
 1 file changed, 9 insertions(+), 1 deletion(-)
862bc8
862bc8
diff --git a/src/libply-splash-core/ply-device-manager.c b/src/libply-splash-core/ply-device-manager.c
862bc8
index cc153e2..a7890d0 100644
862bc8
--- a/src/libply-splash-core/ply-device-manager.c
862bc8
+++ b/src/libply-splash-core/ply-device-manager.c
862bc8
@@ -379,61 +379,69 @@ create_seats_for_subsystem (ply_device_manager_t *manager,
862bc8
   return found_device;
862bc8
 }
862bc8
 
862bc8
 static void
862bc8
 on_udev_event (ply_device_manager_t *manager)
862bc8
 {
862bc8
   struct udev_device *device;
862bc8
   const char *action;
862bc8
 
862bc8
   device = udev_monitor_receive_device (manager->udev_monitor);
862bc8
   if (device == NULL)
862bc8
     return;
862bc8
 
862bc8
   action = udev_device_get_action (device);
862bc8
 
862bc8
   ply_trace ("got %s event for device %s", action, udev_device_get_sysname (device));
862bc8
 
862bc8
   if (action == NULL)
862bc8
     return;
862bc8
 
862bc8
   if (strcmp (action, "add") == 0)
862bc8
     {
862bc8
       const char *subsystem;
862bc8
       bool coldplug_complete = manager->udev_queue_fd_watch == NULL;
862bc8
 
862bc8
       subsystem = udev_device_get_subsystem (device);
862bc8
 
862bc8
       if (strcmp (subsystem, SUBSYSTEM_DRM) == 0 ||
862bc8
           coldplug_complete)
862bc8
         {
862bc8
-          create_seat_for_udev_device (manager, device);
862bc8
+          ply_list_t *local_pixel_displays = NULL;
862bc8
+
862bc8
+          if (manager->local_console_seat != NULL)
862bc8
+            local_pixel_displays = ply_seat_get_pixel_displays (manager->local_console_seat);
862bc8
+
862bc8
+          if (coldplug_complete && manager->local_console_seat != NULL && local_pixel_displays == NULL)
862bc8
+            ply_trace ("ignoring since we're already using text splash for local console");
862bc8
+          else
862bc8
+            create_seat_for_udev_device (manager, device);
862bc8
         }
862bc8
       else
862bc8
         {
862bc8
           ply_trace ("ignoring since we only handle subsystem %s devices after coldplug completes", subsystem);
862bc8
         }
862bc8
     }
862bc8
   else if (strcmp (action, "remove") == 0)
862bc8
     {
862bc8
       free_seat_for_udev_device (manager, device);
862bc8
     }
862bc8
 
862bc8
   udev_device_unref (device);
862bc8
 }
862bc8
 
862bc8
 static void
862bc8
 watch_for_udev_events (ply_device_manager_t *manager)
862bc8
 {
862bc8
   int fd;
862bc8
   assert (manager != NULL);
862bc8
   assert (manager->udev_monitor == NULL);
862bc8
 
862bc8
   ply_trace ("watching for udev graphics device add and remove events");
862bc8
 
862bc8
   manager->udev_monitor = udev_monitor_new_from_netlink (manager->udev_context, "udev");
862bc8
 
862bc8
   udev_monitor_filter_add_match_subsystem_devtype (manager->udev_monitor, SUBSYSTEM_DRM, NULL);
862bc8
   udev_monitor_filter_add_match_subsystem_devtype (manager->udev_monitor, SUBSYSTEM_FRAME_BUFFER, NULL);
862bc8
   udev_monitor_filter_add_match_tag (manager->udev_monitor, "seat");
862bc8
   udev_monitor_enable_receiving (manager->udev_monitor);
862bc8
 
862bc8
-- 
862bc8
2.3.7
862bc8