Change video_mode_type to an enum, fix collisions and add a bit more info

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-09-12 02:09:09 +02:00
parent d2467d2361
commit 4dd58a6edd
3 changed files with 39 additions and 21 deletions

View file

@ -55,6 +55,10 @@ hook (const struct grub_video_mode_info *info)
grub_printf ("Planar "); grub_printf ("Planar ");
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_HERCULES) if (info->mode_type & GRUB_VIDEO_MODE_TYPE_HERCULES)
grub_printf ("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) if (info->mode_type & GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP)
grub_printf ("Monochrome "); grub_printf ("Monochrome ");
if (info->mode_type & GRUB_VIDEO_MODE_TYPE_UNKNOWN) if (info->mode_type & GRUB_VIDEO_MODE_TYPE_UNKNOWN)

View file

@ -564,6 +564,7 @@ vbe2videoinfo (grub_uint32_t mode,
/* CGA is basically 4-bit packed pixel. */ /* CGA is basically 4-bit packed pixel. */
case GRUB_VBE_MEMORY_MODEL_CGA: case GRUB_VBE_MEMORY_MODEL_CGA:
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_CGA;
case GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL: case GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL:
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
break; break;
@ -575,8 +576,10 @@ vbe2videoinfo (grub_uint32_t mode,
/* Non chain 4 is a special case of planar. */ /* Non chain 4 is a special case of planar. */
case GRUB_VBE_MEMORY_MODEL_NONCHAIN4_256: case GRUB_VBE_MEMORY_MODEL_NONCHAIN4_256:
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_NONCHAIN4;
case GRUB_VBE_MEMORY_MODEL_PLANAR: case GRUB_VBE_MEMORY_MODEL_PLANAR:
mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_PLANAR; mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_PLANAR
| GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
break; break;
case GRUB_VBE_MEMORY_MODEL_YUV: case GRUB_VBE_MEMORY_MODEL_YUV:

View file

@ -38,25 +38,34 @@ struct grub_video_bitmap;
/* If following is set render target contains currenly displayed image /* If following is set render target contains currenly displayed image
after swapping buffers (otherwise it contains previously displayed image). after swapping buffers (otherwise it contains previously displayed image).
*/ */
#define GRUB_VIDEO_MODE_TYPE_YUV 0x00000800 typedef enum grub_video_mode_type
#define GRUB_VIDEO_MODE_TYPE_PLANAR 0x00000400 {
#define GRUB_VIDEO_MODE_TYPE_HERCULES 0x00000200 GRUB_VIDEO_MODE_TYPE_RGB = 0x00000001,
#define GRUB_VIDEO_MODE_TYPE_UNKNOWN 0x00000100 GRUB_VIDEO_MODE_TYPE_INDEX_COLOR = 0x00000002,
#define GRUB_VIDEO_MODE_TYPE_UPDATING_SWAP 0x00000080 GRUB_VIDEO_MODE_TYPE_1BIT_BITMAP = 0x00000004,
#define GRUB_VIDEO_MODE_TYPE_PURE_TEXT 0x00000040 GRUB_VIDEO_MODE_TYPE_YUV = 0x00000008,
#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
/* Defines used to mask flags. */ /* Defines used to mask flags. */
#define GRUB_VIDEO_MODE_TYPE_COLOR_MASK 0x0000000F GRUB_VIDEO_MODE_TYPE_COLOR_MASK = 0x0000000F,
/* Defines used to specify requested bit depth. */ GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED = 0x00000010,
#define GRUB_VIDEO_MODE_TYPE_DEPTH_MASK 0x0000ff00 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. */
GRUB_VIDEO_MODE_TYPE_DEPTH_MASK = 0x0000FF00,
#define GRUB_VIDEO_MODE_TYPE_DEPTH_POS 8 #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 /* The basic render target representing the whole display. This always
renders to the back buffer when double-buffering is in use. */ renders to the back buffer when double-buffering is in use. */
#define GRUB_VIDEO_RENDER_TARGET_DISPLAY \ #define GRUB_VIDEO_RENDER_TARGET_DISPLAY \
@ -107,7 +116,7 @@ struct grub_video_mode_info
/* Mode type bitmask. Contains information like is it Index color or /* Mode type bitmask. Contains information like is it Index color or
RGB mode. */ RGB mode. */
unsigned int mode_type; grub_video_mode_type_t mode_type;
/* Bits per pixel. */ /* Bits per pixel. */
unsigned int bpp; unsigned int bpp;
@ -232,7 +241,8 @@ struct grub_video_adapter
grub_err_t (*fini) (void); grub_err_t (*fini) (void);
grub_err_t (*setup) (unsigned int width, unsigned int height, 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); grub_err_t (*get_info) (struct grub_video_mode_info *mode_info);
@ -409,8 +419,9 @@ grub_err_t EXPORT_FUNC (grub_video_set_mode) (const char *modestring,
unsigned int modevalue); unsigned int modevalue);
static inline int static inline int
grub_video_check_mode_flag (unsigned int flags, unsigned int mask, grub_video_check_mode_flag (grub_video_mode_type_t flags,
unsigned int flag, int def) grub_video_mode_type_t mask,
grub_video_mode_type_t flag, int def)
{ {
return (flag & mask) ? !! (flags & flag) : def; return (flag & mask) ? !! (flags & flag) : def;
} }