2010-01-17 Vladimir Serbinenko <phcoder@gmail.com>
Use flag-based instead of hook-based video mode selection and "auto" keyword. * include/grub/video.h (grub_video_adapter): Changed 'setup' member. (grub_video_set_mode): Changed prototype. All users updated. (grub_video_check_mode_flag): New inline function. * video/video.c (parse_modespec): New function. (grub_video_set_mode): Parse flags and keywords.
This commit is contained in:
commit
b0b139075e
14 changed files with 187 additions and 189 deletions
|
@ -369,7 +369,7 @@ grub_video_vbe_fini (void)
|
|||
|
||||
static grub_err_t
|
||||
grub_video_vbe_setup (unsigned int width, unsigned int height,
|
||||
unsigned int mode_type)
|
||||
unsigned int mode_type, unsigned int mode_mask)
|
||||
{
|
||||
grub_uint16_t *p;
|
||||
struct grub_vbe_mode_info_block vbe_mode_info;
|
||||
|
@ -415,32 +415,40 @@ grub_video_vbe_setup (unsigned int width, unsigned int height,
|
|||
/* Not compatible memory model. */
|
||||
continue;
|
||||
|
||||
if ((vbe_mode_info.x_resolution != width)
|
||||
|| (vbe_mode_info.y_resolution != height))
|
||||
if (((vbe_mode_info.x_resolution != width)
|
||||
|| (vbe_mode_info.y_resolution != height)) && width != 0 && height != 0)
|
||||
/* Non matching resolution. */
|
||||
continue;
|
||||
|
||||
/* Check if user requested RGB or index color mode. */
|
||||
if ((mode_type & GRUB_VIDEO_MODE_TYPE_COLOR_MASK) != 0)
|
||||
if ((mode_mask & GRUB_VIDEO_MODE_TYPE_COLOR_MASK) != 0)
|
||||
{
|
||||
if (((mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) != 0)
|
||||
&& (vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL))
|
||||
/* Requested only index color modes. */
|
||||
continue;
|
||||
unsigned my_mode_type = 0;
|
||||
|
||||
if (((mode_type & GRUB_VIDEO_MODE_TYPE_RGB) != 0)
|
||||
&& (vbe_mode_info.memory_model != GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR))
|
||||
/* Requested only RGB modes. */
|
||||
continue;
|
||||
if (vbe_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL)
|
||||
my_mode_type |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||
|
||||
if (vbe_mode_info.memory_model == GRUB_VBE_MEMORY_MODEL_DIRECT_COLOR)
|
||||
my_mode_type |= GRUB_VIDEO_MODE_TYPE_RGB;
|
||||
|
||||
if ((my_mode_type & mode_mask
|
||||
& (GRUB_VIDEO_MODE_TYPE_RGB | GRUB_VIDEO_MODE_TYPE_INDEX_COLOR))
|
||||
!= (mode_type & mode_mask
|
||||
& (GRUB_VIDEO_MODE_TYPE_RGB
|
||||
| GRUB_VIDEO_MODE_TYPE_INDEX_COLOR)))
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If there is a request for specific depth, ignore others. */
|
||||
if ((depth != 0) && (vbe_mode_info.bits_per_pixel != depth))
|
||||
continue;
|
||||
|
||||
/* Select mode with most number of bits per pixel. */
|
||||
/* Select mode with most of "volume" (size of framebuffer in bits). */
|
||||
if (best_vbe_mode != 0)
|
||||
if (vbe_mode_info.bits_per_pixel < best_vbe_mode_info.bits_per_pixel)
|
||||
if ((grub_uint64_t) vbe_mode_info.bits_per_pixel
|
||||
* vbe_mode_info.x_resolution * vbe_mode_info.y_resolution
|
||||
< (grub_uint64_t) best_vbe_mode_info.bits_per_pixel
|
||||
* best_vbe_mode_info.x_resolution * best_vbe_mode_info.y_resolution)
|
||||
continue;
|
||||
|
||||
/* Save so far best mode information for later use. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue