From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HtIEb-0006U0-W7 for mharc-grub-devel@gnu.org; Wed, 30 May 2007 03:04:42 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HtIEa-0006TM-DD for grub-devel@gnu.org; Wed, 30 May 2007 03:04:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HtIEY-0006Si-DG for grub-devel@gnu.org; Wed, 30 May 2007 03:04:39 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HtIEY-0006Sd-6N for grub-devel@gnu.org; Wed, 30 May 2007 03:04:38 -0400 Received: from gw01.mail.saunalahti.fi ([195.197.172.115]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HtIEV-00074t-Vv for grub-devel@gnu.org; Wed, 30 May 2007 03:04:37 -0400 Received: from saimaza.webmail.saunalahti.fi (saimaza.webmail.saunalahti.fi [195.197.55.116]) by gw01.mail.saunalahti.fi (Postfix) with ESMTP id C5AB615179C for ; Wed, 30 May 2007 10:04:26 +0300 (EEST) Date: Wed, 30 May 2007 10:04:26 +0300 (EEST) From: chaac@nic.fi To: grub-devel@gnu.org Message-ID: <9513677.619671180508666760.JavaMail.chaac@nic.fi> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_17605_21847781.1180508666759" X-Mailer: Saunalahti webmail - http://saunalahti.fi X-Originating-IP: 195.16.210.229 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) Subject: patch to allow modelist for gfxterm X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 May 2007 07:04:40 -0000 ------=_Part_17605_21847781.1180508666759 Content-Type: text/plain; Charset=iso-8859-1; Format=Flowed Content-Transfer-Encoding: quoted-printable Hi All, I am on the road at the moment so this is not polished, but I would like to= get comments from you, how it works and what you think about integrating i= t to cvs. Example: set gfxmode=3D"1024x768;800x600;640x480" And when gfxterm is initialized it would first try out first mode and then = second and so on... In order to support wide screens I think those modes wo= uld be need to be listed first or otherwise they will fallback to "standard= " aspect ratio. Patch should be attached in this message. Thanks, Vesa J=E4=E4skel=E4inen ------=_Part_17605_21847781.1180508666759 Content-Type: text/x-patch; charset=us-ascii; name=grub2-gfxterm.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=grub2-gfxterm.patch Index: ChangeLog =================================================================== RCS file: /sources/grub/grub2/ChangeLog,v retrieving revision 1.375 diff -u -r1.375 ChangeLog --- ChangeLog 20 May 2007 09:10:05 -0000 1.375 +++ ChangeLog 30 May 2007 06:00:57 -0000 @@ -1,3 +1,8 @@ +2007-05-30 Vesa Jaaskelainen + + * term/gfxterm.c (grub_gfxterm_init): Added support for specifying + list of video modes. + 2007-05-20 Robert Millan * util/update-grub_lib.in: New file. Index: term/gfxterm.c =================================================================== RCS file: /sources/grub/grub2/term/gfxterm.c,v retrieving revision 1.3 diff -u -r1.3 gfxterm.c --- term/gfxterm.c 31 Jul 2006 14:21:35 -0000 1.3 +++ term/gfxterm.c 30 May 2007 06:00:58 -0000 @@ -202,8 +202,11 @@ if (modevar) { char *tmp; + char *next_mode; + char *current_mode; char *param; char *value; + int mode_found = 0; /* Take copy of env.var. as we don't want to modify that. */ tmp = grub_strdup (modevar); @@ -211,110 +214,216 @@ if (grub_errno != GRUB_ERR_NONE) return grub_errno; - - /* Skip whitespace. */ - while (grub_isspace (*tmp)) - tmp++; - - /* Initialize token holders. */ - param = tmp; - value = NULL; - - /* Parse x[x]*/ - - /* Find width value. */ - value = param; - param = grub_strchr(param, 'x'); - if (param == NULL) + + /* Initialize next mode. */ + next_mode = modevar; + + /* Loop until all modes has been tested out. */ + while (next_mode != NULL) { - /* Free memory before returning. */ - grub_free (modevar); - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Invalid argument: %s\n", - param); - } + /* Use last next_mode as current mode. */ + tmp = next_mode; + + /* Reset video mode settings. */ + width = DEFAULT_VIDEO_WIDTH; + height = DEFAULT_VIDEO_HEIGHT; + depth = -1; + flags = DEFAULT_VIDEO_FLAGS; + + /* Save position of next mode and separate modes. */ + next_mode = grub_strchr(next_mode, ';'); + if (next_mode) + { + *next_mode = 0; + next_mode++; + } - *param = 0; - param++; + /* Skip whitespace. */ + while (grub_isspace (*tmp)) + tmp++; + + /* Initialize token holders. */ + current_mode = tmp; + param = tmp; + value = NULL; - width = grub_strtoul (value, 0, 0); - if (grub_errno != GRUB_ERR_NONE) - { - /* Free memory before returning. */ - grub_free (modevar); - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Invalid argument: %s\n", - param); - } + /* Parse x[x]*/ - /* Find height value. */ - value = param; - param = grub_strchr(param, 'x'); - if (param == NULL) - { - height = grub_strtoul (value, 0, 0); - if (grub_errno != GRUB_ERR_NONE) + /* Find width value. */ + value = param; + param = grub_strchr(param, 'x'); + if (param == NULL) { + grub_err_t rc; + + /* First setup error message. */ + rc = grub_error (GRUB_ERR_BAD_ARGUMENT, + "Invalid mode: %s\n", + current_mode); + /* Free memory before returning. */ grub_free (modevar); - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Invalid argument: %s\n", - param); + + return rc; } - } - else - { - /* We have optional color depth value. */ + *param = 0; param++; - height = grub_strtoul (value, 0, 0); + width = grub_strtoul (value, 0, 0); if (grub_errno != GRUB_ERR_NONE) { + grub_err_t rc; + + /* First setup error message. */ + rc = grub_error (GRUB_ERR_BAD_ARGUMENT, + "Invalid mode: %s\n", + current_mode); + /* Free memory before returning. */ grub_free (modevar); - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Invalid argument: %s\n", - param); + + return rc; } - /* Convert color depth value. */ + /* Find height value. */ value = param; - depth = grub_strtoul (value, 0, 0); - if (grub_errno != GRUB_ERR_NONE) + param = grub_strchr(param, 'x'); + if (param == NULL) { - /* Free memory before returning. */ - grub_free (modevar); - return grub_error (GRUB_ERR_BAD_ARGUMENT, - "Invalid argument: %s\n", - param); + height = grub_strtoul (value, 0, 0); + if (grub_errno != GRUB_ERR_NONE) + { + grub_err_t rc; + + /* First setup error message. */ + rc = grub_error (GRUB_ERR_BAD_ARGUMENT, + "Invalid mode: %s\n", + current_mode); + + /* Free memory before returning. */ + grub_free (modevar); + + return rc; + } + } + else + { + /* We have optional color depth value. */ + *param = 0; + param++; + + height = grub_strtoul (value, 0, 0); + if (grub_errno != GRUB_ERR_NONE) + { + grub_err_t rc; + + /* First setup error message. */ + rc = grub_error (GRUB_ERR_BAD_ARGUMENT, + "Invalid mode: %s\n", + current_mode); + + /* Free memory before returning. */ + grub_free (modevar); + + return rc; + } + + /* Convert color depth value. */ + value = param; + depth = grub_strtoul (value, 0, 0); + if (grub_errno != GRUB_ERR_NONE) + { + grub_err_t rc; + + /* First setup error message. */ + rc = grub_error (GRUB_ERR_BAD_ARGUMENT, + "Invalid mode: %s\n", + current_mode); + + /* Free memory before returning. */ + grub_free (modevar); + + return rc; + } + } + + /* Try out video mode. */ + + /* If we have 8 or less bits, then assuem that it is indexed color mode. */ + if ((depth <= 8) && (depth != -1)) + flags |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; + + /* We have more than 8 bits, then assume that it is RGB color mode. */ + if (depth > 8) + flags |= GRUB_VIDEO_MODE_TYPE_RGB; + + /* If user requested specific depth, forward that information to driver. */ + if (depth != -1) + flags |= (depth << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) + & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK; + + /* Try to initialize requested mode. Ignore any errors. */ + grub_error_push (); + if (grub_video_setup (width, height, flags) != GRUB_ERR_NONE) + { + grub_error_pop (); + continue; + } + + /* Figure out what mode we ended up. */ + if (grub_video_get_info (&mode_info) != GRUB_ERR_NONE) + { + /* Couldn't get video mode info, restore old mode and continue to next one. */ + grub_error_pop (); + + grub_video_restore (); + continue; } + + /* Restore state of error stack. */ + grub_error_pop (); + + /* Mode found! Exit loop. */ + mode_found = 1; + break; } /* Free memory. */ grub_free (modevar); + + if (!mode_found) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + "No suitable mode found."); } + else + { + /* No gfxmode variable set, use defaults. */ + + /* If we have 8 or less bits, then assuem that it is indexed color mode. */ + if ((depth <= 8) && (depth != -1)) + flags |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; + + /* We have more than 8 bits, then assume that it is RGB color mode. */ + if (depth > 8) + flags |= GRUB_VIDEO_MODE_TYPE_RGB; + + /* If user requested specific depth, forward that information to driver. */ + if (depth != -1) + flags |= (depth << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) + & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK; + + /* Initialize user requested mode. */ + if (grub_video_setup (width, height, flags) != GRUB_ERR_NONE) + return grub_errno; - /* If we have 8 or less bits, then assuem that it is indexed color mode. */ - if ((depth <= 8) && (depth != -1)) - flags |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; - - /* We have more than 8 bits, then assume that it is RGB color mode. */ - if (depth > 8) - flags |= GRUB_VIDEO_MODE_TYPE_RGB; - - /* If user requested specific depth, forward that information to driver. */ - if (depth != -1) - flags |= (depth << GRUB_VIDEO_MODE_TYPE_DEPTH_POS) - & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK; - - /* Initialize user requested mode. */ - if (grub_video_setup (width, height, flags) != GRUB_ERR_NONE) - return grub_errno; - - /* Figure out what mode we ended up. */ - if (grub_video_get_info (&mode_info) != GRUB_ERR_NONE) - return grub_errno; + /* Figure out what mode we ended up. */ + if (grub_video_get_info (&mode_info) != GRUB_ERR_NONE) + { + grub_video_restore (); + return grub_errno; + } + } /* Make sure screen is black. */ color = grub_video_map_rgb (0, 0, 0); ------=_Part_17605_21847781.1180508666759--