]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Support vbeprobe MODE
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 15 Sep 2010 12:37:28 +0000 (14:37 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 15 Sep 2010 12:37:28 +0000 (14:37 +0200)
grub-core/commands/videoinfo.c
grub-core/lib/legacy_parse.c

index 15f677e14b0cf7fc95fbe9c8f0c6bb4628377974..10f77915bf7bc020f6375d890fcebe57f2d20211 100644 (file)
 #include <grub/command.h>
 #include <grub/i18n.h>
 
+static unsigned height, width, depth; 
+
 static int
 hook (const struct grub_video_mode_info *info)
 {
+  if (height && width && (info->width != width || info->height != height))
+    return 0;
+
+  if (depth && info->bpp != depth)
+    return 0;
+
   if (info->mode_number == GRUB_VIDEO_MODE_NUMBER_INVALID)
     grub_printf ("        ");
   else
@@ -71,12 +79,34 @@ hook (const struct grub_video_mode_info *info)
 
 static grub_err_t
 grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)),
-                   int argc __attribute__ ((unused)),
-                   char **args __attribute__ ((unused)))
+                   int argc, char **args)
 {
   grub_video_adapter_t adapter;
   grub_video_driver_id_t id;
 
+  height = width = depth = 0;
+  if (argc)
+    {
+      char *ptr;
+      ptr = args[0];
+      width = grub_strtoul (ptr, &ptr, 0);
+      if (grub_errno)
+       return grub_errno;
+      if (*ptr != 'x')
+       return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid mode specification");
+      ptr++;
+      height = grub_strtoul (ptr, &ptr, 0);
+      if (grub_errno)
+       return grub_errno;
+      if (*ptr == 'x')
+       {
+         ptr++;
+         depth = grub_strtoul (ptr, &ptr, 0);
+         if (grub_errno)
+           return grub_errno;
+       }
+    }
+
 #ifdef GRUB_MACHINE_PCBIOS
   if (grub_strcmp (cmd->name, "vbeinfo") == 0)
     grub_dl_load ("vbe");
@@ -132,11 +162,15 @@ static grub_command_t cmd_vbe;
 
 GRUB_MOD_INIT(videoinfo)
 {
-  cmd = grub_register_command ("videoinfo", grub_cmd_videoinfo, 0,
-                              N_("List available video modes."));
+  cmd = grub_register_command ("videoinfo", grub_cmd_videoinfo, "[WxH[xD]]",
+                              N_("List available video modes. If "
+                                    "resolution is given show only modes"
+                                    " matching it."));
 #ifdef GRUB_MACHINE_PCBIOS
-  cmd_vbe = grub_register_command ("vbeinfo", grub_cmd_videoinfo, 0,
-                                  N_("List available video modes."));
+  cmd_vbe = grub_register_command ("vbeinfo", grub_cmd_videoinfo, "[WxH[xD]]",
+                                  N_("List available video modes. If "
+                                     "resolution is given show only modes"
+                                     " matching it."));
 #endif
 }
 
index a0be27d60fbdf24f60741f7ccb0dd79e078cd585..6ad15dc4937fbc40b94101e96149bccb6887e1ed 100644 (file)
@@ -292,10 +292,12 @@ struct legacy_command legacy_commands[] =
     /* FIXME: uppermem unsupported.  */
     {"uuid", "search --set=root --fs-uuid '%s'\n", NULL, 0, 1, {TYPE_VERBATIM},
      0, "UUID", "Find root by UUID"},
-    /* FIXME: support MODE.  */
-    {"vbeprobe", "insmod vbe; videoinfo\n", NULL, 0, 0, {}, 0, "[MODE]",
+    {"vbeprobe", "insmod vbe; videoinfo '%s'\n", NULL, 0, 1, {TYPE_VBE_MODE},
+     FLAG_FALLBACK_AVAILABLE, "[MODE]",
      "Probe VBE information. If the mode number MODE is specified, show only"
-     " the information about only the mode."}
+     " the information about only the mode."},
+    {"vbeprobe", "insmod vbe; videoinfo\n", NULL, 0, 0, {},
+     FLAG_FALLBACK, NULL, NULL}
   };
 
 char *