]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
renderer: provide way to override renderer plugin
authorRay Strode <rstrode@redhat.com>
Thu, 31 Mar 2011 03:14:05 +0000 (23:14 -0400)
committerRay Strode <rstrode@redhat.com>
Thu, 31 Mar 2011 03:14:05 +0000 (23:14 -0400)
This will allow us to force e.g. frame-buffer even
if drm would work.

src/libply-splash-core/ply-renderer.c
src/libply-splash-core/ply-renderer.h
src/main.c

index ab2012d8c1f7fa9518d87fccea15954a16fbde41..3559e0135cfc2b8d0c4d6666685059639a7599ef 100644 (file)
@@ -49,6 +49,7 @@ struct _ply_renderer
   const ply_renderer_plugin_interface_t *plugin_interface;
   ply_renderer_backend_t *backend;
 
+  char *plugin_path;
   char *device_name;
   ply_terminal_t *terminal;
 
@@ -62,13 +63,17 @@ typedef const ply_renderer_plugin_interface_t *
 static void ply_renderer_unload_plugin (ply_renderer_t *renderer);
 
 ply_renderer_t *
-ply_renderer_new (const char    * device_name,
+ply_renderer_new (const char     *plugin_path,
+                  const char     *device_name,
                   ply_terminal_t *terminal)
 {
   ply_renderer_t *renderer;
 
   renderer = calloc (1, sizeof (struct _ply_renderer));
 
+  if (plugin_path != NULL)
+    renderer->plugin_path = strdup (plugin_path);
+
   if (device_name != NULL)
     renderer->device_name = strdup (device_name);
 
@@ -90,6 +95,7 @@ ply_renderer_free (ply_renderer_t *renderer)
     }
 
   free (renderer->device_name);
+  free (renderer->plugin_path);
   free (renderer);
 }
 
@@ -217,6 +223,36 @@ ply_renderer_unmap_from_device (ply_renderer_t *renderer)
   renderer->is_mapped = false;
 }
 
+static bool
+ply_renderer_open_plugin (ply_renderer_t *renderer,
+                          const char     *plugin_path)
+{
+  ply_trace ("trying to open renderer plugin %s", plugin_path);
+
+  if (!ply_renderer_load_plugin (renderer, plugin_path))
+    return false;
+
+  if (!ply_renderer_open_device (renderer))
+    {
+      ply_trace ("could not open rendering device for plugin %s",
+                 plugin_path);
+      ply_renderer_unload_plugin (renderer);
+      return false;
+    }
+
+  if (!ply_renderer_query_device (renderer))
+    {
+      ply_trace ("could not query rendering device for plugin %s",
+                 plugin_path);
+      ply_renderer_close_device (renderer);
+      ply_renderer_unload_plugin (renderer);
+      return false;
+    }
+
+  ply_trace ("opened renderer plugin %s", plugin_path);
+  return true;
+}
+
 bool
 ply_renderer_open (ply_renderer_t *renderer)
 {
@@ -234,33 +270,15 @@ ply_renderer_open (ply_renderer_t *renderer)
       NULL
     };
 
+  if (renderer->plugin_path != NULL)
+    {
+      return ply_renderer_open_plugin (renderer, renderer->plugin_path);
+    }
+
   for (i = 0; known_plugins[i] != NULL; i++)
     {
-      const char *plugin_path;
-
-      plugin_path = known_plugins[i];
-
-      if (!ply_renderer_load_plugin (renderer, plugin_path))
-        continue;
-
-      if (!ply_renderer_open_device (renderer))
-        {
-          ply_trace ("could not open rendering device for plugin %s",
-                     plugin_path);
-          ply_renderer_unload_plugin (renderer);
-          continue;
-        }
-
-      if (!ply_renderer_query_device (renderer))
-        {
-          ply_trace ("could not query rendering device for plugin %s",
-                     plugin_path);
-          ply_renderer_close_device (renderer);
-          ply_renderer_unload_plugin (renderer);
-          continue;
-        }
-
-      return true;
+      if (ply_renderer_open_plugin (renderer, known_plugins[i]))
+        return true;
   }
 
   ply_trace ("could not find suitable rendering plugin");
index ff5d5b9a28f2b0b2caa4c1ef9125574c367e3c5c..4b3bd1a3cc578361b2f4ddfe6f98ebdb72fdf894 100644 (file)
@@ -40,7 +40,8 @@ typedef void (* ply_renderer_input_source_handler_t) (void
                                                       ply_renderer_input_source_t *input_source);
 
 #ifndef PLY_HIDE_FUNCTION_DECLARATIONS
-ply_renderer_t *ply_renderer_new (const char    * device_name,
+ply_renderer_t *ply_renderer_new (const char     *plugin_path,
+                                  const char     *device_name,
                                   ply_terminal_t *terminal);
 void ply_renderer_free (ply_renderer_t *renderer);
 bool ply_renderer_open (ply_renderer_t *renderer);
index 25ccf2c0790aabd6ba6122e9ffb314683d79a4e3..e950ab08085af4f7c774d6f01fe175c7b1e54577 100644 (file)
@@ -1443,7 +1443,7 @@ add_default_displays_and_keyboard (state_t *state)
 
   terminal = ply_terminal_new (state->default_tty);
 
-  renderer = ply_renderer_new (NULL, terminal);
+  renderer = ply_renderer_new (NULL, NULL, terminal);
 
   if (!ply_renderer_open (renderer))
     {