From d2467d2361cef8465b4483d1756fb9831b0b12b4 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 12 Sep 2010 01:45:58 +0200 Subject: [PATCH] Add Hercules, Planar and YUV to videoinfo (not tested) --- grub-core/commands/videoinfo.c | 15 +++++++++++++- grub-core/video/i386/pc/vbe.c | 36 ++++++++++++++++++++++++++++++---- include/grub/video.h | 4 ++++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/grub-core/commands/videoinfo.c b/grub-core/commands/videoinfo.c index febb56aba..9ee3f1af5 100644 --- a/grub-core/commands/videoinfo.c +++ b/grub-core/commands/videoinfo.c @@ -34,6 +34,8 @@ hook (const struct grub_video_mode_info *info) 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", @@ -46,7 +48,18 @@ hook (const struct grub_video_mode_info *info) info->blue_field_pos, info->reserved_field_pos); if (info->mode_type & GRUB_VIDEO_MODE_TYPE_INDEX_COLOR) - grub_printf ("Packed"); + 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_1BIT_BITMAP) + grub_printf ("Monochrome "); + if (info->mode_type & GRUB_VIDEO_MODE_TYPE_UNKNOWN) + grub_printf ("Unknown "); + grub_printf ("\n"); return 0; diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c index 1d2a9ac76..be266d238 100644 --- a/grub-core/video/i386/pc/vbe.c +++ b/grub-core/video/i386/pc/vbe.c @@ -555,14 +555,39 @@ vbe2videoinfo (grub_uint32_t 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_PACKED_PIXEL: - mode_info->mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; + 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: + 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: + case GRUB_VBE_MEMORY_MODEL_PLANAR: + mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_PLANAR; + 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; + mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_RGB; + break; + default: + mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_UNKNOWN; break; } @@ -585,6 +610,9 @@ vbe2videoinfo (grub_uint32_t mode, case 8: mode_info->bytes_per_pixel = 1; break; + case 4: + mode_info->bytes_per_pixel = 0; + break; } if (controller_info.version >= 0x300) diff --git a/include/grub/video.h b/include/grub/video.h index 1c1bf16ab..6381efe64 100644 --- a/include/grub/video.h +++ b/include/grub/video.h @@ -38,6 +38,10 @@ 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_YUV 0x00000800 +#define GRUB_VIDEO_MODE_TYPE_PLANAR 0x00000400 +#define GRUB_VIDEO_MODE_TYPE_HERCULES 0x00000200 +#define GRUB_VIDEO_MODE_TYPE_UNKNOWN 0x00000100 #define GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP 0x00000080 #define GRUB_VIDEO_MODE_TYPE_PURE_TEXT 0x00000040 #define GRUB_VIDEO_MODE_TYPE_ALPHA 0x00000020