734f94d20481f793a8863fa0a198cd0e6b3bd465
[dosdemo] / src / dos / vbe.h
1 #ifndef VBE_H_
2 #define VBE_H_
3
4 #include <stdio.h>
5 #include "inttypes.h"
6 #include "util.h"
7
8 #pragma pack (push, 1)
9 struct vbe_info {
10         char sig[4];
11         uint16_t ver;
12         char *oem_name;
13         uint32_t caps;
14         uint16_t *modes;
15         uint16_t vmem_blk;      /* video memory size in 64k blocks */
16         uint16_t oem_ver;
17         char *vendor;
18         char *product;
19         char *revstr;
20         uint16_t accel_ver;
21         uint16_t *accel_modes;
22         char reserved[216];
23         char oem_data[256];
24 } PACKED;
25
26 struct vbe_mode_info {
27         uint16_t attr;
28         uint8_t wina_attr, winb_attr;
29         uint16_t win_gran, win_size;
30         uint16_t wina_seg, winb_seg;
31         uint32_t win_func;
32         uint16_t scanline_bytes;
33
34         /* VBE 1.2 and above */
35         uint16_t xres, yres;
36         uint8_t xcharsz, ycharsz;
37         uint8_t num_planes;
38         uint8_t bpp;
39         uint8_t num_banks;
40         uint8_t mem_model;
41         uint8_t bank_size;              /* bank size in KB */
42         uint8_t num_img_pages;
43         uint8_t reserved1;
44
45         /* direct color fields */
46         uint8_t rsize, rpos;
47         uint8_t gsize, gpos;
48         uint8_t bsize, bpos;
49         uint8_t xsize, xpos;
50         uint8_t cmode_info;             /* direct color mode attributes */
51
52         /* VBE 2.0 and above */
53         uint32_t fb_addr;               /* physical address of the linear framebuffer */
54         uint32_t os_addr;               /* phys. address of off-screen memory */
55         uint16_t os_size;               /* size in KB of off-screen memory */
56
57         /* VBE 3.0 and above */
58         uint16_t lfb_scanline_bytes;
59         uint8_t banked_num_img_pages;
60         uint8_t lfb_num_img_pages;
61         uint8_t lfb_rsize, lfb_rpos;
62         uint8_t lfb_gsize, lfb_gpos;
63         uint8_t lfb_bsize, lfb_bpos;
64         uint8_t lfb_xsize, lfb_xpos;
65         uint32_t max_pixel_clock;
66
67         uint8_t reserved2[190];
68 } PACKED;
69 #pragma pack (pop)
70
71 enum {
72         VBE_8BIT_DAC    = 0x01,
73         VBE_NON_VGA             = 0x02,
74         VBE_DAC_BLANK   = 0x04,
75         VBE_STEREO              = 0x08, /* ? */
76         VBE_ACCEL               = 0x08,
77         VBE_STEREO_VESA = 0x10, /* ? */
78         VBE_MUSTLOCK    = 0x10,
79         VBE_HWCURSOR    = 0x20,
80         VBE_HWCLIP              = 0x40,
81         VBE_TRANSP_BLT  = 0x80
82 };
83
84 #define VBE_VER_MAJOR(v)        (((v) >> 8) & 0xff)
85 #define VBE_VER_MINOR(v)        ((v) & 0xff)
86
87 /* VBE mode attribute flags (vbe_mode_info.attr) */
88 enum {
89         VBE_ATTR_AVAIL          = 0x0001,
90         VBE_ATTR_OPTINFO        = 0x0002,
91         VBE_ATTR_TTY            = 0x0004,
92         VBE_ATTR_COLOR          = 0x0008,
93         VBE_ATTR_GFX            = 0x0010,
94         /* VBE 2.0 */
95         VBE_ATTR_NOTVGA         = 0x0020,
96         VBE_ATTR_BANKED         = 0x0040,
97         VBE_ATTR_LFB            = 0x0080,
98         VBE_ATTR_2XSCAN         = 0x0100,
99         /* VBE 3.0 */
100         VBE_ATTR_ILACE          = 0x0200,       /* ! */
101         VBE_ATTR_TRIPLEBUF      = 0x0400,
102         VBE_ATTR_STEREO         = 0x0800,
103         VBE_ATTR_STEREO_2FB     = 0x1000,
104         /* VBE/AF */
105         VBE_ATTR_MUSTLOCK       = 0x0200,       /* ! */
106 };
107
108 /* VBE memory model type (vbe_mode_info.mem_model) */
109 enum {
110         VBE_TYPE_TEXT,
111         VBE_TYPE_CGA,
112         VBE_TYPE_HERCULES,
113         VBE_TYPE_PLANAR,
114         VBE_TYPE_PACKED,
115         VBE_TYPE_UNCHAIN,
116         VBE_TYPE_DIRECT,
117         VBE_TYPE_YUV
118 };
119
120 /* VBE window attribute (vbe_mode_info.win(a|b)_attr) */
121 enum {
122         VBE_WIN_AVAIL   = 0x01,
123         VBE_WIN_RD              = 0x02,
124         VBE_WIN_WR              = 0x04
125 };
126
127 /* mode number flags */
128 enum {
129         VBE_MODE_RATE           = 0x0800,       /* VBE 3.0+ user-specified refresh rate */
130         VBE_MODE_ACCEL          = 0x2000,       /* VBE/AF */
131         VBE_MODE_LFB            = 0x4000,       /* VBE 2.0+ */
132         VBE_MODE_PRESERVE       = 0x8000
133 };
134
135 int vbe_info(struct vbe_info *info);
136 int vbe_num_modes(struct vbe_info *info);
137 int vbe_mode_info(int mode, struct vbe_mode_info *minf);
138
139 void vbe_print_info(FILE *fp, struct vbe_info *info);
140 void vbe_print_mode_info(FILE *fp, struct vbe_mode_info *minf);
141
142 #endif  /* VBE_H_ */