videoinfo on non-vbe.
* grub-core/Makefile.core.def (vbeinfo): Removed. (vbetest): Removed. (videoinfo): New module. * grub-core/commands/i386/pc/vbeinfo.c: Removed. * grub-core/commands/i386/pc/vbetest.c: Removed. * grub-core/commands/videoinfo.c: New file. * grub-core/commands/videotest.c (grub_cmd_videotest): Support mode specification. (grub_cmd_videotest) [GRUB_MACHINE_PCBIOS]: Load vbe.mod when invoked as vbetest. (GRUB_MOD_INIT) [GRUB_MACHINE_PCBIOS]: New command vbetest. (GRUB_MOD_FINI) [GRUB_MACHINE_PCBIOS]: Unregister vbetest. * grub-core/video/efi_gop.c (grub_video_gop_fill_mode_info): Fill mode_number. New parameter mode. All users updated. (grub_video_gop_iterate): New function. (grub_video_efi_gop): New member iterate. * grub-core/video/i386/pc/vbe.c (framebuffer): Removed leftover fields. (grub_vbe_set_video_mode): Remove setting useless fields. (vbe2videoinfo): New function. (grub_video_vbe_iterate): Likewise. (grub_video_vbe_setup): Use vbe2videoinfo. (grub_video_vbe_print_adapter_specific_info): New function. (grub_video_vbe_adapter): New fields iterate and print_adapter_specific_info. * include/grub/video.h (GRUB_VIDEO_MODE_*): Transform into enum. All users updated. (grub_video_mode_info): New field mode_number. (grub_video_adapter): New fields iterate and print_adapter_specific_info.
This commit is contained in:
commit
9d2be652d4
9 changed files with 448 additions and 472 deletions
34
ChangeLog
34
ChangeLog
|
@ -1,3 +1,37 @@
|
|||
2010-09-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
videoinfo on non-vbe.
|
||||
|
||||
* grub-core/Makefile.core.def (vbeinfo): Removed.
|
||||
(vbetest): Removed.
|
||||
(videoinfo): New module.
|
||||
* grub-core/commands/i386/pc/vbeinfo.c: Removed.
|
||||
* grub-core/commands/i386/pc/vbetest.c: Removed.
|
||||
* grub-core/commands/videoinfo.c: New file.
|
||||
* grub-core/commands/videotest.c (grub_cmd_videotest): Support mode
|
||||
specification.
|
||||
(grub_cmd_videotest) [GRUB_MACHINE_PCBIOS]: Load vbe.mod when invoked
|
||||
as vbetest.
|
||||
(GRUB_MOD_INIT) [GRUB_MACHINE_PCBIOS]: New command vbetest.
|
||||
(GRUB_MOD_FINI) [GRUB_MACHINE_PCBIOS]: Unregister vbetest.
|
||||
* grub-core/video/efi_gop.c (grub_video_gop_fill_mode_info): Fill
|
||||
mode_number. New parameter mode. All users updated.
|
||||
(grub_video_gop_iterate): New function.
|
||||
(grub_video_efi_gop): New member iterate.
|
||||
* grub-core/video/i386/pc/vbe.c (framebuffer): Removed leftover fields.
|
||||
(grub_vbe_set_video_mode): Remove setting useless fields.
|
||||
(vbe2videoinfo): New function.
|
||||
(grub_video_vbe_iterate): Likewise.
|
||||
(grub_video_vbe_setup): Use vbe2videoinfo.
|
||||
(grub_video_vbe_print_adapter_specific_info): New function.
|
||||
(grub_video_vbe_adapter): New fields iterate and
|
||||
print_adapter_specific_info.
|
||||
* include/grub/video.h (GRUB_VIDEO_MODE_*): Transform into enum.
|
||||
All users updated.
|
||||
(grub_video_mode_info): New field mode_number.
|
||||
(grub_video_adapter): New fields iterate and
|
||||
print_adapter_specific_info.
|
||||
|
||||
2010-09-13 Tristan Gingold <gingold@free.fr>
|
||||
2010-09-13 Robert Millan <rmh.grub@aybabtu.com>
|
||||
2010-09-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
|
|
@ -701,15 +701,8 @@ module = {
|
|||
};
|
||||
|
||||
module = {
|
||||
name = vbeinfo;
|
||||
i386_pc = commands/i386/pc/vbeinfo.c;
|
||||
enable = i386_pc;
|
||||
};
|
||||
|
||||
module = {
|
||||
name = vbetest;
|
||||
i386_pc = commands/i386/pc/vbetest.c;
|
||||
enable = i386_pc;
|
||||
name = videoinfo;
|
||||
common = commands/videoinfo.c;
|
||||
};
|
||||
|
||||
module = {
|
||||
|
|
|
@ -1,185 +0,0 @@
|
|||
/* vbeinfo.c - command to list compatible VBE video modes. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/dl.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/machine/vbe.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
static void *
|
||||
real2pm (grub_vbe_farptr_t ptr)
|
||||
{
|
||||
return (void *) ((((unsigned long) ptr & 0xFFFF0000) >> 12UL)
|
||||
+ ((unsigned long) ptr & 0x0000FFFF));
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_vbeinfo (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
struct grub_vbe_info_block controller_info;
|
||||
struct grub_vbe_mode_info_block mode_info_tmp;
|
||||
grub_uint32_t use_mode = GRUB_VBE_DEFAULT_VIDEO_MODE;
|
||||
grub_uint16_t *video_mode_list;
|
||||
grub_uint16_t *p;
|
||||
grub_uint16_t *saved_video_mode_list;
|
||||
grub_size_t video_mode_list_size;
|
||||
grub_err_t err;
|
||||
char *modevar;
|
||||
|
||||
err = grub_vbe_probe (&controller_info);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
grub_printf ("VBE info: version: %d.%d OEM software rev: %d.%d\n",
|
||||
controller_info.version >> 8,
|
||||
controller_info.version & 0xFF,
|
||||
controller_info.oem_software_rev >> 8,
|
||||
controller_info.oem_software_rev & 0xFF);
|
||||
|
||||
/* The total_memory field is in 64 KiB units. */
|
||||
grub_printf (" total memory: %d KiB\n",
|
||||
(controller_info.total_memory << 16) / 1024);
|
||||
|
||||
/* Because the information on video modes is stored in a temporary place,
|
||||
it is better to copy it to somewhere safe. */
|
||||
p = video_mode_list = real2pm (controller_info.video_mode_ptr);
|
||||
while (*p++ != 0xFFFF)
|
||||
;
|
||||
|
||||
video_mode_list_size = (grub_addr_t) p - (grub_addr_t) video_mode_list;
|
||||
saved_video_mode_list = grub_malloc (video_mode_list_size);
|
||||
if (! saved_video_mode_list)
|
||||
return grub_errno;
|
||||
|
||||
grub_memcpy (saved_video_mode_list, video_mode_list, video_mode_list_size);
|
||||
|
||||
grub_printf ("List of compatible video modes:\n");
|
||||
grub_printf ("Legend: P=Packed pixel, D=Direct color, "
|
||||
"mask/pos=R/G/B/reserved\n");
|
||||
|
||||
/* Walk through all video modes listed. */
|
||||
for (p = saved_video_mode_list; *p != 0xFFFF; p++)
|
||||
{
|
||||
const char *memory_model = 0;
|
||||
grub_uint32_t mode = (grub_uint32_t) *p;
|
||||
|
||||
err = grub_vbe_get_video_mode_info (mode, &mode_info_tmp);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & GRUB_VBE_MODEATTR_SUPPORTED) == 0)
|
||||
/* If not available, skip it. */
|
||||
continue;
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & GRUB_VBE_MODEATTR_RESERVED_1) == 0)
|
||||
/* Not enough information. */
|
||||
continue;
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & GRUB_VBE_MODEATTR_COLOR) == 0)
|
||||
/* Monochrome is unusable. */
|
||||
continue;
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & GRUB_VBE_MODEATTR_LFB_AVAIL) == 0)
|
||||
/* We support only linear frame buffer modes. */
|
||||
continue;
|
||||
|
||||
if ((mode_info_tmp.mode_attributes & GRUB_VBE_MODEATTR_GRAPHICS) == 0)
|
||||
/* We allow only graphical modes. */
|
||||
continue;
|
||||
|
||||
switch (mode_info_tmp.memory_model)
|
||||
{
|
||||
case GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL:
|
||||
memory_model = "Packed";
|
||||
break;
|
||||
case GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR:
|
||||
memory_model = "Direct";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (! memory_model)
|
||||
continue;
|
||||
|
||||
grub_printf ("0x%03x: %4d x %4d x %2d %s",
|
||||
mode,
|
||||
mode_info_tmp.x_resolution,
|
||||
mode_info_tmp.y_resolution,
|
||||
mode_info_tmp.bits_per_pixel,
|
||||
memory_model);
|
||||
|
||||
/* Show mask and position details for direct color modes. */
|
||||
if (mode_info_tmp.memory_model == GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR)
|
||||
grub_printf (", mask: %d/%d/%d/%d pos: %d/%d/%d/%d",
|
||||
mode_info_tmp.red_mask_size,
|
||||
mode_info_tmp.green_mask_size,
|
||||
mode_info_tmp.blue_mask_size,
|
||||
mode_info_tmp.rsvd_mask_size,
|
||||
mode_info_tmp.red_field_position,
|
||||
mode_info_tmp.green_field_position,
|
||||
mode_info_tmp.blue_field_position,
|
||||
mode_info_tmp.rsvd_field_position);
|
||||
grub_printf ("\n");
|
||||
}
|
||||
|
||||
grub_free (saved_video_mode_list);
|
||||
|
||||
/* Check existence of vbe_mode environment variable. */
|
||||
modevar = grub_env_get ("vbe_mode");
|
||||
|
||||
if (modevar != 0)
|
||||
{
|
||||
unsigned long value;
|
||||
|
||||
value = grub_strtoul (modevar, 0, 0);
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
use_mode = value;
|
||||
else
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_printf ("Configured VBE mode (vbe_mode) = 0x%03x\n", use_mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(vbeinfo)
|
||||
{
|
||||
cmd =
|
||||
grub_register_command ("vbeinfo", grub_cmd_vbeinfo, 0,
|
||||
N_("List compatible VESA BIOS extension video modes."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(vbeinfo)
|
||||
{
|
||||
grub_unregister_command (cmd);
|
||||
}
|
|
@ -1,179 +0,0 @@
|
|||
/* vbetest.c - command to test VESA BIOS Extension 2.0+ support. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2007 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/normal.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/machine/init.h>
|
||||
#include <grub/machine/vbe.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_vbetest (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
grub_err_t err;
|
||||
char *modevar;
|
||||
struct grub_vbe_mode_info_block mode_info;
|
||||
struct grub_vbe_info_block controller_info;
|
||||
grub_uint32_t use_mode = GRUB_VBE_DEFAULT_VIDEO_MODE;
|
||||
grub_uint32_t old_mode;
|
||||
grub_uint8_t *framebuffer = 0;
|
||||
grub_uint32_t bytes_per_scan_line = 0;
|
||||
unsigned char *ptr;
|
||||
int i;
|
||||
|
||||
grub_printf ("Probing for VESA BIOS Extension ... ");
|
||||
|
||||
/* Check if VESA BIOS exists. */
|
||||
err = grub_vbe_probe (&controller_info);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
grub_printf ("found!\n");
|
||||
|
||||
/* Dump out controller information. */
|
||||
grub_printf ("VBE signature = %c%c%c%c\n",
|
||||
controller_info.signature[0],
|
||||
controller_info.signature[1],
|
||||
controller_info.signature[2],
|
||||
controller_info.signature[3]);
|
||||
|
||||
grub_printf ("VBE version = %d.%d\n",
|
||||
controller_info.version >> 8,
|
||||
controller_info.version & 0xFF);
|
||||
grub_printf ("OEM string ptr = %08x\n",
|
||||
controller_info.oem_string_ptr);
|
||||
grub_printf ("Total memory = %d\n",
|
||||
controller_info.total_memory);
|
||||
|
||||
err = grub_vbe_get_video_mode (&old_mode);
|
||||
grub_printf ("Get video mode err = %04x\n", err);
|
||||
|
||||
if (err == GRUB_ERR_NONE)
|
||||
grub_printf ("Old video mode = %04x\n", old_mode);
|
||||
else
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
/* Check existence of vbe_mode environment variable. */
|
||||
modevar = grub_env_get ("vbe_mode");
|
||||
if (modevar != 0)
|
||||
{
|
||||
unsigned long value;
|
||||
|
||||
value = grub_strtoul (modevar, 0, 0);
|
||||
if (grub_errno == GRUB_ERR_NONE)
|
||||
use_mode = value;
|
||||
else
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
err = grub_vbe_get_video_mode_info (use_mode, &mode_info);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
/* Dump out details about the mode being tested. */
|
||||
grub_printf ("mode: 0x%03x\n",
|
||||
use_mode);
|
||||
grub_printf ("width : %d\n",
|
||||
mode_info.x_resolution);
|
||||
grub_printf ("height: %d\n",
|
||||
mode_info.y_resolution);
|
||||
grub_printf ("memory model: %02x\n",
|
||||
mode_info.memory_model);
|
||||
grub_printf ("bytes/scanline: %d\n",
|
||||
mode_info.bytes_per_scan_line);
|
||||
grub_printf ("bytes/scanline (lin): %d\n",
|
||||
mode_info.lin_bytes_per_scan_line);
|
||||
grub_printf ("base address: %08x\n",
|
||||
mode_info.phys_base_addr);
|
||||
grub_printf ("red mask/pos: %d/%d\n",
|
||||
mode_info.red_mask_size,
|
||||
mode_info.red_field_position);
|
||||
grub_printf ("green mask/pos: %d/%d\n",
|
||||
mode_info.green_mask_size,
|
||||
mode_info.green_field_position);
|
||||
grub_printf ("blue mask/pos: %d/%d\n",
|
||||
mode_info.blue_mask_size,
|
||||
mode_info.blue_field_position);
|
||||
|
||||
grub_printf ("Press any key to continue.\n");
|
||||
|
||||
grub_getkey ();
|
||||
|
||||
/* Setup GFX mode. */
|
||||
err = grub_vbe_set_video_mode (use_mode, &mode_info);
|
||||
if (err != GRUB_ERR_NONE)
|
||||
return err;
|
||||
|
||||
/* Determine framebuffer address and how many bytes are in scan line. */
|
||||
framebuffer = (grub_uint8_t *) mode_info.phys_base_addr;
|
||||
ptr = framebuffer;
|
||||
|
||||
if (controller_info.version >= 0x300)
|
||||
{
|
||||
bytes_per_scan_line = mode_info.lin_bytes_per_scan_line;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes_per_scan_line = mode_info.bytes_per_scan_line;
|
||||
}
|
||||
|
||||
/* Draw some random data to screen. */
|
||||
for (i = 0; i < 256 * 256; i++)
|
||||
{
|
||||
ptr[i] = i & 0x0F;
|
||||
}
|
||||
|
||||
/* Draw white line to screen. */
|
||||
for (i = 0; i < 100; i++)
|
||||
{
|
||||
ptr[mode_info.bytes_per_scan_line * 50 + i] = 0x0F;
|
||||
}
|
||||
|
||||
/* Draw another white line to screen. */
|
||||
grub_memset (ptr + bytes_per_scan_line * 51, 0x0f, bytes_per_scan_line);
|
||||
|
||||
grub_getkey ();
|
||||
|
||||
grub_video_restore ();
|
||||
|
||||
/* Restore old video mode. */
|
||||
grub_vbe_set_video_mode (old_mode, 0);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
|
||||
GRUB_MOD_INIT(vbetest)
|
||||
{
|
||||
cmd = grub_register_command ("vbetest", grub_cmd_vbetest,
|
||||
0, N_("Test VESA BIOS Extension 2.0+ support."));
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(vbetest)
|
||||
{
|
||||
grub_unregister_command (cmd);
|
||||
}
|
150
grub-core/commands/videoinfo.c
Normal file
150
grub-core/commands/videoinfo.c
Normal file
|
@ -0,0 +1,150 @@
|
|||
/* videoinfo.c - command to list video modes. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2005,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/video.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/env.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
|
||||
static int
|
||||
hook (const struct grub_video_mode_info *info)
|
||||
{
|
||||
if (info->mode_number == GRUB_VIDEO_MODE_NUMBER_INVALID)
|
||||
grub_printf (" ");
|
||||
else
|
||||
grub_printf (" 0x%03x ", info->mode_number);
|
||||
grub_printf ("%4d x %4d x %2d ", info->width, info->height, info->bpp);
|
||||
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PURE_TEXT)
|
||||
grub_printf ("Text-only ");
|
||||
/* Show mask and position details for direct color modes. */
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_RGB)
|
||||
grub_printf ("Direct, mask: %d/%d/%d/%d pos: %d/%d/%d/%d",
|
||||
info->red_mask_size,
|
||||
info->green_mask_size,
|
||||
info->blue_mask_size,
|
||||
info->reserved_mask_size,
|
||||
info->red_field_pos,
|
||||
info->green_field_pos,
|
||||
info->blue_field_pos,
|
||||
info->reserved_field_pos);
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
|
||||
grub_printf ("Packed ");
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_YUV)
|
||||
grub_printf ("YUV ");
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_PLANAR)
|
||||
grub_printf ("Planar ");
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_HERCULES)
|
||||
grub_printf ("Hercules ");
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_CGA)
|
||||
grub_printf ("CGA ");
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_NONCHAIN4)
|
||||
grub_printf ("Non-chain 4 ");
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP)
|
||||
grub_printf ("Monochrome ");
|
||||
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_UNKNOWN)
|
||||
grub_printf ("Unknown ");
|
||||
|
||||
grub_printf ("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_videoinfo (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
{
|
||||
grub_video_adapter_t adapter;
|
||||
grub_video_driver_id_t id;
|
||||
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
if (grub_strcmp (cmd->name, "vbeinfo") == 0)
|
||||
grub_dl_load ("vbe");
|
||||
#endif
|
||||
|
||||
id = grub_video_get_driver_id ();
|
||||
|
||||
grub_printf ("List of supported video modes:\n");
|
||||
grub_printf ("Legend: P=Packed pixel, D=Direct color, "
|
||||
"mask/pos=R/G/B/reserved\n");
|
||||
|
||||
FOR_VIDEO_ADAPTERS (adapter)
|
||||
{
|
||||
grub_printf ("Adapter '%s':\n", adapter->name);
|
||||
|
||||
if (!adapter->iterate)
|
||||
{
|
||||
grub_printf (" No info available\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (adapter->id != id)
|
||||
{
|
||||
if (adapter->init ())
|
||||
{
|
||||
grub_printf (" Failed\n");
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (adapter->print_adapter_specific_info)
|
||||
adapter->print_adapter_specific_info ();
|
||||
|
||||
adapter->iterate (hook);
|
||||
|
||||
if (adapter->id != id)
|
||||
{
|
||||
if (adapter->fini ())
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
static grub_command_t cmd_vbe;
|
||||
#endif
|
||||
|
||||
GRUB_MOD_INIT(videoinfo)
|
||||
{
|
||||
cmd = grub_register_command ("videoinfo", grub_cmd_videoinfo, 0,
|
||||
N_("List available video modes."));
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
cmd_vbe = grub_register_command ("vbeinfo", grub_cmd_videoinfo, 0,
|
||||
N_("List available video modes."));
|
||||
#endif
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(videoinfo)
|
||||
{
|
||||
grub_unregister_command (cmd);
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
grub_unregister_command (cmd_vbe);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -26,11 +26,11 @@
|
|||
#include <grub/command.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/gfxmenu_view.h>
|
||||
#include <grub/env.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
||||
int argc __attribute__ ((unused)),
|
||||
char **args __attribute__ ((unused)))
|
||||
int argc, char **args)
|
||||
{
|
||||
grub_err_t err;
|
||||
grub_video_color_t color;
|
||||
|
@ -41,8 +41,20 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
|||
int i;
|
||||
struct grub_video_render_target *text_layer;
|
||||
grub_video_color_t palette[16];
|
||||
const char *mode = NULL;
|
||||
|
||||
err = grub_video_set_mode ("auto", GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
if (grub_strcmp (cmd->name, "vbetest") == 0)
|
||||
grub_dl_load ("vbe");
|
||||
#endif
|
||||
|
||||
mode = grub_env_get ("gfxmode");
|
||||
if (argc)
|
||||
mode = args[0];
|
||||
if (!mode)
|
||||
mode = "auto";
|
||||
|
||||
err = grub_video_set_mode (mode, GRUB_VIDEO_MODE_TYPE_PURE_TEXT, 0);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
@ -180,14 +192,25 @@ grub_cmd_videotest (grub_command_t cmd __attribute__ ((unused)),
|
|||
}
|
||||
|
||||
static grub_command_t cmd;
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
static grub_command_t cmd_vbe;
|
||||
#endif
|
||||
|
||||
GRUB_MOD_INIT(videotest)
|
||||
{
|
||||
cmd = grub_register_command ("videotest", grub_cmd_videotest,
|
||||
"[WxH]",
|
||||
N_("Test video subsystem in mode WxH."));
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
cmd_vbe = grub_register_command ("vbetest", grub_cmd_videotest,
|
||||
0, N_("Test video subsystem."));
|
||||
#endif
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(videotest)
|
||||
{
|
||||
grub_unregister_command (cmd);
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
grub_unregister_command (cmd_vbe);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -127,9 +127,11 @@ grub_video_gop_get_bitmask (grub_uint32_t mask, unsigned int *mask_size,
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_gop_fill_mode_info (struct grub_efi_gop_mode_info *in,
|
||||
grub_video_gop_fill_mode_info (unsigned mode,
|
||||
struct grub_efi_gop_mode_info *in,
|
||||
struct grub_video_mode_info *out)
|
||||
{
|
||||
out->mode_number = mode;
|
||||
out->number_of_colors = 256;
|
||||
out->width = in->width;
|
||||
out->height = in->height;
|
||||
|
@ -183,6 +185,39 @@ grub_video_gop_fill_mode_info (struct grub_efi_gop_mode_info *in,
|
|||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static int
|
||||
grub_video_gop_iterate (int (*hook) (const struct grub_video_mode_info *info))
|
||||
{
|
||||
unsigned mode;
|
||||
|
||||
for (mode = 0; mode < gop->mode->max_mode; mode++)
|
||||
{
|
||||
grub_efi_uintn_t size;
|
||||
grub_efi_status_t status;
|
||||
struct grub_efi_gop_mode_info *info = NULL;
|
||||
grub_err_t err;
|
||||
struct grub_video_mode_info mode_info;
|
||||
|
||||
status = efi_call_4 (gop->query_mode, gop, mode, &size, &info);
|
||||
|
||||
if (status)
|
||||
{
|
||||
info = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
err = grub_video_gop_fill_mode_info (mode, info, &mode_info);
|
||||
if (err)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
continue;
|
||||
}
|
||||
if (hook (&mode_info))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_gop_setup (unsigned int width, unsigned int height,
|
||||
unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
|
||||
|
@ -226,7 +261,7 @@ grub_video_gop_setup (unsigned int width, unsigned int height,
|
|||
if (status)
|
||||
{
|
||||
info = 0;
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
grub_dprintf ("video", "GOP: mode %d: %dx%d\n", mode, info->width,
|
||||
|
@ -281,7 +316,8 @@ grub_video_gop_setup (unsigned int width, unsigned int height,
|
|||
|
||||
info = gop->mode->info;
|
||||
|
||||
err = grub_video_gop_fill_mode_info (info, &framebuffer.mode_info);
|
||||
err = grub_video_gop_fill_mode_info (gop->mode->mode, info,
|
||||
&framebuffer.mode_info);
|
||||
if (err)
|
||||
{
|
||||
grub_dprintf ("video", "GOP: couldn't fill mode info\n");
|
||||
|
@ -379,6 +415,7 @@ static struct grub_video_adapter grub_video_gop_adapter =
|
|||
.delete_render_target = grub_video_fb_delete_render_target,
|
||||
.set_active_render_target = grub_video_gop_set_active_render_target,
|
||||
.get_active_render_target = grub_video_fb_get_active_render_target,
|
||||
.iterate = grub_video_gop_iterate,
|
||||
|
||||
.next = 0
|
||||
};
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
static int vbe_detected = -1;
|
||||
|
||||
static struct grub_vbe_info_block controller_info;
|
||||
static struct grub_vbe_mode_info_block active_vbe_mode_info;
|
||||
|
||||
/* Track last mode to support cards which fail on get_mode. */
|
||||
static grub_uint32_t last_set_mode = 3;
|
||||
|
@ -42,11 +41,7 @@ static struct
|
|||
{
|
||||
struct grub_video_mode_info mode_info;
|
||||
|
||||
unsigned int bytes_per_scan_line;
|
||||
unsigned int bytes_per_pixel;
|
||||
grub_uint32_t active_vbe_mode;
|
||||
grub_uint8_t *ptr;
|
||||
int index_color_mode;
|
||||
} framebuffer;
|
||||
|
||||
static grub_uint32_t initial_vbe_mode;
|
||||
|
@ -332,22 +327,13 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode,
|
|||
vbe_mode |= 1 << 14;
|
||||
|
||||
/* Determine frame buffer pixel format. */
|
||||
switch (new_vbe_mode_info.memory_model)
|
||||
{
|
||||
case GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL:
|
||||
framebuffer.index_color_mode = 1;
|
||||
break;
|
||||
|
||||
case GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR:
|
||||
framebuffer.index_color_mode = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (new_vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL
|
||||
&& new_vbe_mode_info.memory_model
|
||||
!= GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR)
|
||||
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||
"unsupported pixel format 0x%x",
|
||||
new_vbe_mode_info.memory_model);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get current mode. */
|
||||
grub_vbe_get_video_mode (&old_vbe_mode);
|
||||
|
@ -360,24 +346,14 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode,
|
|||
return grub_error (GRUB_ERR_BAD_DEVICE, "cannot set VBE mode %x", vbe_mode);
|
||||
last_set_mode = vbe_mode;
|
||||
|
||||
/* Save information for later usage. */
|
||||
framebuffer.active_vbe_mode = vbe_mode;
|
||||
grub_memcpy (&active_vbe_mode_info, &new_vbe_mode_info, sizeof (active_vbe_mode_info));
|
||||
|
||||
if (vbe_mode < 0x100)
|
||||
{
|
||||
/* If this is not a VESA mode, guess address. */
|
||||
framebuffer.ptr = (grub_uint8_t *) GRUB_MEMORY_MACHINE_VGA_ADDR;
|
||||
framebuffer.index_color_mode = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
framebuffer.ptr = (grub_uint8_t *) new_vbe_mode_info.phys_base_addr;
|
||||
|
||||
if (controller_info.version >= 0x300)
|
||||
framebuffer.bytes_per_scan_line = new_vbe_mode_info.lin_bytes_per_scan_line;
|
||||
else
|
||||
framebuffer.bytes_per_scan_line = new_vbe_mode_info.bytes_per_scan_line;
|
||||
}
|
||||
|
||||
/* Check whether mode is text mode or graphics mode. */
|
||||
|
@ -392,25 +368,9 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode,
|
|||
{
|
||||
/* Graphics mode. */
|
||||
|
||||
/* Calculate bytes_per_pixel value. */
|
||||
switch(new_vbe_mode_info.bits_per_pixel)
|
||||
{
|
||||
case 32: framebuffer.bytes_per_pixel = 4; break;
|
||||
case 24: framebuffer.bytes_per_pixel = 3; break;
|
||||
case 16: framebuffer.bytes_per_pixel = 2; break;
|
||||
case 15: framebuffer.bytes_per_pixel = 2; break;
|
||||
case 8: framebuffer.bytes_per_pixel = 1; break;
|
||||
default:
|
||||
grub_vbe_bios_set_mode (old_vbe_mode, 0);
|
||||
last_set_mode = old_vbe_mode;
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
"cannot set VBE mode %x",
|
||||
vbe_mode);
|
||||
break;
|
||||
}
|
||||
|
||||
/* If video mode is in indexed color, setup default VGA palette. */
|
||||
if (framebuffer.index_color_mode)
|
||||
if (vbe_mode < 0x100 || new_vbe_mode_info.memory_model
|
||||
== GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL)
|
||||
{
|
||||
struct grub_vbe_palette_data *palette
|
||||
= (struct grub_vbe_palette_data *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
|
@ -548,10 +508,13 @@ grub_video_vbe_fini (void)
|
|||
grub_err_t err;
|
||||
|
||||
/* Restore old video mode. */
|
||||
if (last_set_mode != initial_vbe_mode)
|
||||
{
|
||||
status = grub_vbe_bios_set_mode (initial_vbe_mode, 0);
|
||||
if (status != GRUB_VBE_STATUS_OK)
|
||||
/* TODO: Decide, is this something we want to do. */
|
||||
return grub_errno;
|
||||
}
|
||||
last_set_mode = initial_vbe_mode;
|
||||
|
||||
/* TODO: Free any resources allocated by driver. */
|
||||
|
@ -583,6 +546,120 @@ doublebuf_pageflipping_set_page (int page)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
vbe2videoinfo (grub_uint32_t mode,
|
||||
const struct grub_vbe_mode_info_block *vbeinfo,
|
||||
struct grub_video_mode_info *mode_info)
|
||||
{
|
||||
mode_info->mode_number = mode;
|
||||
|
||||
mode_info->width = vbeinfo->x_resolution;
|
||||
mode_info->height = vbeinfo->y_resolution;
|
||||
mode_info->mode_type = 0;
|
||||
switch (vbeinfo->memory_model)
|
||||
{
|
||||
case GRUB_VBE_MEMORY_MODEL_TEXT:
|
||||
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_PURE_TEXT;
|
||||
break;
|
||||
|
||||
/* CGA is basically 4-bit packed pixel. */
|
||||
case GRUB_VBE_MEMORY_MODEL_CGA:
|
||||
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_CGA;
|
||||
case GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL:
|
||||
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||
break;
|
||||
|
||||
case GRUB_VBE_MEMORY_MODEL_HERCULES:
|
||||
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_HERCULES
|
||||
| GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP;
|
||||
break;
|
||||
|
||||
/* Non chain 4 is a special case of planar. */
|
||||
case GRUB_VBE_MEMORY_MODEL_NONCHAIN4_256:
|
||||
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_NONCHAIN4;
|
||||
case GRUB_VBE_MEMORY_MODEL_PLANAR:
|
||||
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_PLANAR
|
||||
| GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||
break;
|
||||
|
||||
case GRUB_VBE_MEMORY_MODEL_YUV:
|
||||
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_YUV;
|
||||
break;
|
||||
|
||||
case GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR:
|
||||
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_RGB;
|
||||
break;
|
||||
default:
|
||||
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
mode_info->bpp = vbeinfo->bits_per_pixel;
|
||||
/* Calculate bytes_per_pixel value. */
|
||||
switch(vbeinfo->bits_per_pixel)
|
||||
{
|
||||
case 32:
|
||||
mode_info->bytes_per_pixel = 4;
|
||||
break;
|
||||
case 24:
|
||||
mode_info->bytes_per_pixel = 3;
|
||||
break;
|
||||
case 16:
|
||||
mode_info->bytes_per_pixel = 2;
|
||||
break;
|
||||
case 15:
|
||||
mode_info->bytes_per_pixel = 2;
|
||||
break;
|
||||
case 8:
|
||||
mode_info->bytes_per_pixel = 1;
|
||||
break;
|
||||
case 4:
|
||||
mode_info->bytes_per_pixel = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (controller_info.version >= 0x300)
|
||||
mode_info->pitch = vbeinfo->lin_bytes_per_scan_line;
|
||||
else
|
||||
mode_info->pitch = vbeinfo->bytes_per_scan_line;
|
||||
|
||||
mode_info->number_of_colors = 256; /* TODO: fix me. */
|
||||
mode_info->red_mask_size = vbeinfo->red_mask_size;
|
||||
mode_info->red_field_pos = vbeinfo->red_field_position;
|
||||
mode_info->green_mask_size = vbeinfo->green_mask_size;
|
||||
mode_info->green_field_pos = vbeinfo->green_field_position;
|
||||
mode_info->blue_mask_size = vbeinfo->blue_mask_size;
|
||||
mode_info->blue_field_pos = vbeinfo->blue_field_position;
|
||||
mode_info->reserved_mask_size = vbeinfo->rsvd_mask_size;
|
||||
mode_info->reserved_field_pos = vbeinfo->rsvd_field_position;
|
||||
|
||||
mode_info->blit_format = grub_video_get_blit_format (mode_info);
|
||||
}
|
||||
|
||||
static int
|
||||
grub_video_vbe_iterate (int (*hook) (const struct grub_video_mode_info *info))
|
||||
{
|
||||
grub_uint16_t *p;
|
||||
struct grub_vbe_mode_info_block vbe_mode_info;
|
||||
struct grub_video_mode_info mode_info;
|
||||
|
||||
for (p = vbe_mode_list; *p != 0xFFFF; p++)
|
||||
{
|
||||
grub_vbe_get_video_mode_info (*p, &vbe_mode_info);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
/* Could not retrieve mode info, retreat. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
vbe2videoinfo (*p, &vbe_mode_info, &mode_info);
|
||||
if (hook (&mode_info))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_vbe_setup (unsigned int width, unsigned int height,
|
||||
unsigned int mode_type, unsigned int mode_mask)
|
||||
|
@ -631,6 +708,14 @@ grub_video_vbe_setup (unsigned int width, unsigned int height,
|
|||
/* Not compatible memory model. */
|
||||
continue;
|
||||
|
||||
if (vbe_mode_info.bits_per_pixel != 8
|
||||
&& vbe_mode_info.bits_per_pixel != 15
|
||||
&& vbe_mode_info.bits_per_pixel != 16
|
||||
&& vbe_mode_info.bits_per_pixel != 24
|
||||
&& vbe_mode_info.bits_per_pixel != 32)
|
||||
/* Unsupported bitdepth . */
|
||||
continue;
|
||||
|
||||
if (((vbe_mode_info.x_resolution != width)
|
||||
|| (vbe_mode_info.y_resolution != height)) && width != 0 && height != 0)
|
||||
/* Non matching resolution. */
|
||||
|
@ -676,36 +761,16 @@ grub_video_vbe_setup (unsigned int width, unsigned int height,
|
|||
if (best_vbe_mode != 0)
|
||||
{
|
||||
grub_err_t err;
|
||||
static struct grub_vbe_mode_info_block active_vbe_mode_info;
|
||||
/* If this fails, then we have mode selection heuristics problem,
|
||||
or adapter failure. */
|
||||
/* grub_vbe_set_video_mode already sets active_vbe_mode_info. */
|
||||
grub_vbe_set_video_mode (best_vbe_mode, NULL);
|
||||
grub_vbe_set_video_mode (best_vbe_mode, &active_vbe_mode_info);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
/* Fill mode info details. */
|
||||
framebuffer.mode_info.width = active_vbe_mode_info.x_resolution;
|
||||
framebuffer.mode_info.height = active_vbe_mode_info.y_resolution;
|
||||
|
||||
if (framebuffer.index_color_mode)
|
||||
framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||
else
|
||||
framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
|
||||
|
||||
framebuffer.mode_info.bpp = active_vbe_mode_info.bits_per_pixel;
|
||||
framebuffer.mode_info.bytes_per_pixel = framebuffer.bytes_per_pixel;
|
||||
framebuffer.mode_info.pitch = framebuffer.bytes_per_scan_line;
|
||||
framebuffer.mode_info.number_of_colors = 256; /* TODO: fix me. */
|
||||
framebuffer.mode_info.red_mask_size = active_vbe_mode_info.red_mask_size;
|
||||
framebuffer.mode_info.red_field_pos = active_vbe_mode_info.red_field_position;
|
||||
framebuffer.mode_info.green_mask_size = active_vbe_mode_info.green_mask_size;
|
||||
framebuffer.mode_info.green_field_pos = active_vbe_mode_info.green_field_position;
|
||||
framebuffer.mode_info.blue_mask_size = active_vbe_mode_info.blue_mask_size;
|
||||
framebuffer.mode_info.blue_field_pos = active_vbe_mode_info.blue_field_position;
|
||||
framebuffer.mode_info.reserved_mask_size = active_vbe_mode_info.rsvd_mask_size;
|
||||
framebuffer.mode_info.reserved_field_pos = active_vbe_mode_info.rsvd_field_position;
|
||||
|
||||
framebuffer.mode_info.blit_format = grub_video_get_blit_format (&framebuffer.mode_info);
|
||||
vbe2videoinfo (best_vbe_mode, &active_vbe_mode_info,
|
||||
&framebuffer.mode_info);
|
||||
|
||||
{
|
||||
/* Get video RAM size in bytes. */
|
||||
|
@ -740,7 +805,7 @@ static grub_err_t
|
|||
grub_video_vbe_set_palette (unsigned int start, unsigned int count,
|
||||
struct grub_video_palette_data *palette_data)
|
||||
{
|
||||
if (framebuffer.index_color_mode)
|
||||
if (framebuffer.mode_info.mode_type == GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)
|
||||
{
|
||||
/* TODO: Implement setting indexed color mode palette to hardware. */
|
||||
//status = grub_vbe_bios_set_palette_data (sizeof (vga_colors)
|
||||
|
@ -764,6 +829,20 @@ grub_video_vbe_get_info_and_fini (struct grub_video_mode_info *mode_info,
|
|||
return grub_video_fb_get_info_and_fini (mode_info, framebuf);
|
||||
}
|
||||
|
||||
static void
|
||||
grub_video_vbe_print_adapter_specific_info (void)
|
||||
{
|
||||
grub_printf (" VBE info: version: %d.%d OEM software rev: %d.%d\n",
|
||||
controller_info.version >> 8,
|
||||
controller_info.version & 0xFF,
|
||||
controller_info.oem_software_rev >> 8,
|
||||
controller_info.oem_software_rev & 0xFF);
|
||||
|
||||
/* The total_memory field is in 64 KiB units. */
|
||||
grub_printf (" total memory: %d KiB\n",
|
||||
(controller_info.total_memory << 16) / 1024);
|
||||
}
|
||||
|
||||
static struct grub_video_adapter grub_video_vbe_adapter =
|
||||
{
|
||||
.name = "VESA BIOS Extension Video Driver",
|
||||
|
@ -793,6 +872,8 @@ static struct grub_video_adapter grub_video_vbe_adapter =
|
|||
.delete_render_target = grub_video_fb_delete_render_target,
|
||||
.set_active_render_target = grub_video_fb_set_active_render_target,
|
||||
.get_active_render_target = grub_video_fb_get_active_render_target,
|
||||
.iterate = grub_video_vbe_iterate,
|
||||
.print_adapter_specific_info = grub_video_vbe_print_adapter_specific_info,
|
||||
|
||||
.next = 0
|
||||
};
|
||||
|
|
|
@ -38,21 +38,34 @@ struct grub_video_bitmap;
|
|||
/* If following is set render target contains currenly displayed image
|
||||
after swapping buffers (otherwise it contains previously displayed image).
|
||||
*/
|
||||
#define GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP 0x00000080
|
||||
#define GRUB_VIDEO_MODE_TYPE_PURE_TEXT 0x00000040
|
||||
#define GRUB_VIDEO_MODE_TYPE_ALPHA 0x00000020
|
||||
#define GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED 0x00000010
|
||||
#define GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP 0x00000004
|
||||
#define GRUB_VIDEO_MODE_TYPE_INDEX_COLOR 0x00000002
|
||||
#define GRUB_VIDEO_MODE_TYPE_RGB 0x00000001
|
||||
typedef enum grub_video_mode_type
|
||||
{
|
||||
GRUB_VIDEO_MODE_TYPE_RGB = 0x00000001,
|
||||
GRUB_VIDEO_MODE_TYPE_INDEX_COLOR = 0x00000002,
|
||||
GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP = 0x00000004,
|
||||
GRUB_VIDEO_MODE_TYPE_YUV = 0x00000008,
|
||||
|
||||
/* Defines used to mask flags. */
|
||||
#define GRUB_VIDEO_MODE_TYPE_COLOR_MASK 0x0000000F
|
||||
GRUB_VIDEO_MODE_TYPE_COLOR_MASK = 0x0000000F,
|
||||
|
||||
GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED = 0x00000010,
|
||||
GRUB_VIDEO_MODE_TYPE_ALPHA = 0x00000020,
|
||||
GRUB_VIDEO_MODE_TYPE_PURE_TEXT = 0x00000040,
|
||||
GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP = 0x00000080,
|
||||
GRUB_VIDEO_MODE_TYPE_OPERATIONAL_MASK = 0x000000F0,
|
||||
|
||||
/* Defines used to specify requested bit depth. */
|
||||
#define GRUB_VIDEO_MODE_TYPE_DEPTH_MASK 0x0000ff00
|
||||
GRUB_VIDEO_MODE_TYPE_DEPTH_MASK = 0x0000FF00,
|
||||
#define GRUB_VIDEO_MODE_TYPE_DEPTH_POS 8
|
||||
|
||||
GRUB_VIDEO_MODE_TYPE_UNKNOWN = 0x00010000,
|
||||
GRUB_VIDEO_MODE_TYPE_HERCULES = 0x00020000,
|
||||
GRUB_VIDEO_MODE_TYPE_PLANAR = 0x00040000,
|
||||
GRUB_VIDEO_MODE_TYPE_NONCHAIN4 = 0x00080000,
|
||||
GRUB_VIDEO_MODE_TYPE_CGA = 0x00100000,
|
||||
GRUB_VIDEO_MODE_TYPE_INFO_MASK = 0x00FF0000,
|
||||
} grub_video_mode_type_t;
|
||||
|
||||
/* The basic render target representing the whole display. This always
|
||||
renders to the back buffer when double-buffering is in use. */
|
||||
#define GRUB_VIDEO_RENDER_TARGET_DISPLAY \
|
||||
|
@ -103,7 +116,7 @@ struct grub_video_mode_info
|
|||
|
||||
/* Mode type bitmask. Contains information like is it Index color or
|
||||
RGB mode. */
|
||||
unsigned int mode_type;
|
||||
grub_video_mode_type_t mode_type;
|
||||
|
||||
/* Bits per pixel. */
|
||||
unsigned int bpp;
|
||||
|
@ -117,6 +130,9 @@ struct grub_video_mode_info
|
|||
/* In index color mode, number of colors. In RGB mode this is 256. */
|
||||
unsigned int number_of_colors;
|
||||
|
||||
unsigned int mode_number;
|
||||
#define GRUB_VIDEO_MODE_NUMBER_INVALID 0xffffffff
|
||||
|
||||
/* Optimization hint how binary data is coded. */
|
||||
enum grub_video_blit_format blit_format;
|
||||
|
||||
|
@ -225,7 +241,8 @@ struct grub_video_adapter
|
|||
grub_err_t (*fini) (void);
|
||||
|
||||
grub_err_t (*setup) (unsigned int width, unsigned int height,
|
||||
unsigned int mode_type, unsigned int mode_mask);
|
||||
grub_video_mode_type_t mode_type,
|
||||
grub_video_mode_type_t mode_mask);
|
||||
|
||||
grub_err_t (*get_info) (struct grub_video_mode_info *mode_info);
|
||||
|
||||
|
@ -282,6 +299,10 @@ struct grub_video_adapter
|
|||
grub_err_t (*set_active_render_target) (struct grub_video_render_target *target);
|
||||
|
||||
grub_err_t (*get_active_render_target) (struct grub_video_render_target **target);
|
||||
|
||||
int (*iterate) (int (*hook) (const struct grub_video_mode_info *info));
|
||||
|
||||
void (*print_adapter_specific_info) (void);
|
||||
};
|
||||
typedef struct grub_video_adapter *grub_video_adapter_t;
|
||||
|
||||
|
@ -398,8 +419,9 @@ grub_err_t EXPORT_FUNC (grub_video_set_mode) (const char *modestring,
|
|||
unsigned int modevalue);
|
||||
|
||||
static inline int
|
||||
grub_video_check_mode_flag (unsigned int flags, unsigned int mask,
|
||||
unsigned int flag, int def)
|
||||
grub_video_check_mode_flag (grub_video_mode_type_t flags,
|
||||
grub_video_mode_type_t mask,
|
||||
grub_video_mode_type_t flag, int def)
|
||||
{
|
||||
return (flag & mask) ? !! (flags & flag) : def;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue