Mercurial > mplayer.hg
annotate osdep/vbelib.h @ 14128:d109c494f444
synced to 1.57
author | gabrov |
---|---|
date | Tue, 07 Dec 2004 13:05:31 +0000 |
parents | 430a71a762b4 |
children |
rev | line source |
---|---|
2243 | 1 /* |
2 VESA VBE 2.0 compatible structures and definitions. | |
3 You can redistribute this file under terms and conditions | |
2632 | 4 of GNU General Public licence v2. |
2243 | 5 Written by Nick Kurshev <nickols_k@mail.ru> |
6 */ | |
7 #ifndef __VESA_VBELIB_INCLUDED__ | |
8 #define __VESA_VBELIB_INCLUDED__ 1 | |
9 | |
10 /* Note: every pointer within structures is 32-bit protected mode pointer. | |
11 So you don't need to convert it from real mode. */ | |
12 | |
13 typedef struct tagFarPtr | |
14 { | |
15 unsigned short off; | |
16 unsigned short seg; | |
17 }FarPtr; | |
18 | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
19 #define VBE_DAC_8BIT (1 << 0) |
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
20 #define VBE_NONVGA_CRTC (1 << 1) |
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
21 #define VBE_SNOWED_RAMDAC (1 << 2) |
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
22 #define VBE_STEREOSCOPIC (1 << 3) |
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
23 #define VBE_STEREO_EVC (1 << 4) |
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
24 |
2243 | 25 struct VbeInfoBlock { |
26 char VESASignature[4]; /* 'VESA' 4 byte signature */ | |
27 short VESAVersion; /* VBE version number */ | |
28 char * OemStringPtr; /* Pointer to OEM string */ | |
29 long Capabilities; /* Capabilities of video card */ | |
30 unsigned short* VideoModePtr; /* Pointer to supported modes */ | |
31 short TotalMemory; /* Number of 64kb memory blocks */ | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
32 /* VBE 2.0 and above */ |
2243 | 33 short OemSoftwareRev; |
34 char * OemVendorNamePtr; | |
35 char * OemProductNamePtr; | |
36 char * OemProductRevPtr; | |
37 char reserved[222]; | |
38 char OemData[256]; /* Pad to 512 byte block size */ | |
39 }__attribute__ ((packed)); | |
40 | |
41 static inline FarPtr VirtToPhys(void *ptr) | |
42 { | |
43 FarPtr retval; | |
44 retval.seg = ((unsigned long)ptr) >> 4; | |
45 retval.off = ((unsigned long)ptr) & 0x0f; | |
46 return retval; | |
47 } | |
48 | |
49 static inline unsigned short VirtToPhysSeg(void *ptr) | |
50 { | |
51 return ((unsigned long)ptr) >> 4; | |
52 } | |
53 | |
54 static inline unsigned short VirtToPhysOff(void *ptr) | |
55 { | |
56 return ((unsigned long)ptr) & 0x0f; | |
57 } | |
58 | |
59 static inline void * PhysToVirt(FarPtr ptr) | |
60 { | |
61 return (void *)((ptr.seg << 4) | ptr.off); | |
62 } | |
63 | |
64 static inline void * PhysToVirtSO(unsigned short seg,unsigned short off) | |
65 { | |
66 return (void *)((seg << 4) | off); | |
67 } | |
68 | |
69 #define MODE_ATTR_MODE_SUPPORTED (1 << 0) | |
70 #define MODE_ATTR_TTY (1 << 2) | |
71 #define MODE_ATTR_COLOR (1 << 3) | |
72 #define MODE_ATTR_GRAPHICS (1 << 4) | |
73 #define MODE_ATTR_NOT_VGA (1 << 5) | |
74 #define MODE_ATTR_NOT_WINDOWED (1 << 6) | |
75 #define MODE_ATTR_LINEAR (1 << 7) | |
76 #define MODE_ATTR_DOUBLESCAN (1 << 8) | |
77 #define MODE_ATTR_INTERLACE (1 << 9) | |
78 #define MODE_ATTR_TRIPLEBUFFER (1 << 10) | |
79 #define MODE_ATTR_STEREOSCOPIC (1 << 11) | |
80 #define MODE_ATTR_DUALDISPLAY (1 << 12) | |
81 | |
82 #define MODE_WIN_RELOCATABLE (1 << 0) | |
83 #define MODE_WIN_READABLE (1 << 1) | |
84 #define MODE_WIN_WRITEABLE (1 << 2) | |
12660
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
9380
diff
changeset
|
85 #define NEO_PAL 0 |
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
9380
diff
changeset
|
86 #define NEO_NTSC 1 |
2243 | 87 |
88 /* SuperVGA mode information block */ | |
89 struct VesaModeInfoBlock { | |
2608 | 90 unsigned short ModeAttributes; /* 00: Mode attributes */ |
91 unsigned char WinAAttributes; /* 02: Window A attributes */ | |
92 unsigned char WinBAttributes; /* 03: Window B attributes */ | |
93 unsigned short WinGranularity; /* 04: Window granularity in k */ | |
94 unsigned short WinSize; /* 06: Window size in k */ | |
95 unsigned short WinASegment; /* 08: Window A segment */ | |
96 unsigned short WinBSegment; /* 0A: Window B segment */ | |
97 FarPtr WinFuncPtr; /* 0C: 16-bit far pointer to window function */ | |
98 unsigned short BytesPerScanLine; /* 10: Bytes per scanline */ | |
2243 | 99 /* VBE 1.2 and above */ |
2608 | 100 unsigned short XResolution; /* 12: Horizontal resolution */ |
101 unsigned short YResolution; /* 14: Vertical resolution */ | |
102 unsigned char XCharSize; /* 16: Character cell width */ | |
103 unsigned char YCharSize; /* 17: Character cell height */ | |
104 unsigned char NumberOfPlanes; /* 18: Number of memory planes */ | |
105 unsigned char BitsPerPixel; /* 19: Bits per pixel */ | |
106 unsigned char NumberOfBanks; /* 1A: Number of CGA style banks */ | |
107 unsigned char MemoryModel; /* 1B: Memory model type */ | |
108 unsigned char BankSize; /* 1C: Size of CGA style banks */ | |
109 unsigned char NumberOfImagePages; /* 1D: Number of images pages */ | |
110 unsigned char res1; /* 1E: Reserved */ | |
2243 | 111 /* Direct Color fields (required for direct/6 and YUV/7 memory models) */ |
2608 | 112 unsigned char RedMaskSize; /* 1F: Size of direct color red mask */ |
113 unsigned char RedFieldPosition; /* 20: Bit posn of lsb of red mask */ | |
114 unsigned char GreenMaskSize; /* 21: Size of direct color green mask */ | |
115 unsigned char GreenFieldPosition; /* 22: Bit posn of lsb of green mask */ | |
116 unsigned char BlueMaskSize; /* 23: Size of direct color blue mask */ | |
117 unsigned char BlueFieldPosition; /* 24: Bit posn of lsb of blue mask */ | |
118 unsigned char RsvdMaskSize; /* 25: Size of direct color res mask */ | |
119 unsigned char RsvdFieldPosition; /* 26: Bit posn of lsb of res mask */ | |
120 unsigned char DirectColorModeInfo; /* 27: Direct color mode attributes */ | |
2243 | 121 /* VBE 2.0 and above */ |
2608 | 122 unsigned long PhysBasePtr; /* 28: physical address for flat memory frame buffer. (Should be converted to linear before using) */ |
123 unsigned short res3[3]; /* 2C: Reserved - always set to 0 */ | |
2243 | 124 /* VBE 3.0 and above */ |
2608 | 125 unsigned short LinBytesPerScanLine; /* 32: bytes per scan line for linear modes */ |
126 unsigned char BnkNumberOfImagePages;/* 34: number of images for banked modes */ | |
127 unsigned char LinNumberOfImagePages;/* 35: number of images for linear modes */ | |
128 unsigned char LinRedMaskSize; /* 36: size of direct color red mask (linear modes) */ | |
129 unsigned char LinRedFieldPosition; /* 37: bit position of lsb of red mask (linear modes) */ | |
130 unsigned char LinGreenMaskSize; /* 38: size of direct color green mask (linear modes) */ | |
131 unsigned char LinGreenFieldPosition;/* 39: bit position of lsb of green mask (linear modes) */ | |
132 unsigned char LinBlueMaskSize; /* 40: size of direct color blue mask (linear modes) */ | |
133 unsigned char LinBlueFieldPosition; /* 41: bit position of lsb of blue mask (linear modes) */ | |
134 unsigned char LinRsvdMaskSize; /* 42: size of direct color reserved mask (linear modes) */ | |
135 unsigned char LinRsvdFieldPosition; /* 43: bit position of lsb of reserved mask (linear modes) */ | |
136 unsigned long MaxPixelClock; /* 44: maximum pixel clock (in Hz) for graphics mode */ | |
137 char res4[189]; /* 48: remainder of ModeInfoBlock */ | |
2243 | 138 }__attribute__ ((packed)); |
139 | |
140 typedef enum { | |
141 memText= 0, | |
142 memCGA = 1, | |
143 memHercules = 2, | |
144 memPL = 3, /* Planar memory model */ | |
145 memPK = 4, /* Packed pixel memory model */ | |
146 mem256 = 5, | |
147 memRGB = 6, /* Direct color RGB memory model */ | |
148 memYUV = 7, /* Direct color YUV memory model */ | |
149 } memModels; | |
150 | |
151 struct VesaCRTCInfoBlock { | |
152 unsigned short hTotal; /* Horizontal total in pixels */ | |
153 unsigned short hSyncStart; /* Horizontal sync start in pixels */ | |
154 unsigned short hSyncEnd; /* Horizontal sync end in pixels */ | |
155 unsigned short vTotal; /* Vertical total in lines */ | |
156 unsigned short vSyncStart; /* Vertical sync start in lines */ | |
157 unsigned short vSyncEnd; /* Vertical sync end in lines */ | |
158 unsigned char Flags; /* Flags (Interlaced, Double Scan etc) */ | |
159 unsigned long PixelClock; /* Pixel clock in units of Hz */ | |
160 unsigned short RefreshRate;/* Refresh rate in units of 0.01 Hz*/ | |
161 unsigned char Reserved[40];/* remainder of CRTCInfoBlock*/ | |
162 }__attribute__ ((packed)); | |
163 | |
164 #define VESA_CRTC_DOUBLESCAN 0x01 | |
165 #define VESA_CRTC_INTERLACED 0x02 | |
166 #define VESA_CRTC_HSYNC_NEG 0x04 | |
167 #define VESA_CRTC_VSYNC_NEG 0x08 | |
168 | |
169 #define VESA_MODE_CRTC_REFRESH (1 << 11) | |
170 #define VESA_MODE_USE_LINEAR (1 << 14) | |
171 #define VESA_MODE_NOT_CLEAR (1 << 15) | |
172 | |
173 /* This will contain accesible 32-bit protmode pointers */ | |
174 struct VesaProtModeInterface | |
175 { | |
176 void (*SetWindowCall)(void); | |
177 void (*SetDisplayStart)(void); | |
178 void (*SetPaletteData)(void); | |
179 unsigned short * iopl_ports; | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
180 }; |
2243 | 181 |
182 /* | |
183 All functions below return: | |
184 0 if succesful | |
185 0xffff if vm86 syscall error occurs | |
186 0x4fxx if VESA error occurs | |
187 */ | |
188 | |
189 #define VBE_OK 0 | |
190 #define VBE_VM86_FAIL -1 | |
191 #define VBE_OUT_OF_DOS_MEM -2 | |
192 #define VBE_OUT_OF_MEM -3 | |
2359 | 193 #define VBE_BROKEN_BIOS -4 |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
194 #define VBE_VESA_ERROR_MASK 0x004f |
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
195 #define VBE_VESA_ERRCODE_MASK 0xff00 |
2243 | 196 |
197 extern int vbeInit( void ); | |
2446 | 198 extern int vbeDestroy( void ); |
2243 | 199 |
200 extern int vbeGetControllerInfo(struct VbeInfoBlock *); | |
201 extern int vbeGetModeInfo(unsigned mode,struct VesaModeInfoBlock *); | |
202 extern int vbeSetMode(unsigned mode,struct VesaCRTCInfoBlock *); | |
203 extern int vbeGetMode(unsigned *mode); | |
7069 | 204 extern int vbeGetPixelClock(unsigned *mode,unsigned *pixel_clock); |
2243 | 205 extern int vbeSaveState(void **data); /* note never copy this data */ |
206 extern int vbeRestoreState(void *data); | |
207 extern int vbeGetWindow(unsigned *win_num); /* win_A=0 or win_B=1 */ | |
208 extern int vbeSetWindow(unsigned win_num,unsigned win_gran); | |
2632 | 209 extern int vbeGetScanLineLength(unsigned *num_pixels,unsigned *num_bytes); |
210 extern int vbeGetMaxScanLines(unsigned *num_pixels,unsigned *num_bytes, unsigned *num_lines); | |
211 extern int vbeSetScanLineLength(unsigned num_pixels); | |
212 extern int vbeSetScanLineLengthB(unsigned num_bytes); | |
213 extern int vbeGetDisplayStart(unsigned *pixel_num,unsigned *scan_line); | |
214 extern int vbeSetDisplayStart(unsigned long offset, int vsync); | |
2693 | 215 extern int vbeSetScheduledDisplayStart(unsigned long offset, int vsync); |
12660
430a71a762b4
neomagic tv out support throught vesa vbe, patch by Rudolf Marek
alex
parents:
9380
diff
changeset
|
216 extern int vbeSetTV(unsigned int vesa_mode,unsigned int TV_mode); |
2243 | 217 /* |
218 Func 0x08-0x09: | |
219 Support of palette currently is not implemented. | |
220 */ | |
221 extern int vbeGetProtModeInfo(struct VesaProtModeInterface *); | |
2410 | 222 |
223 /* Standard VGA stuff */ | |
224 int vbeWriteString(int x, int y, int attr, char *str); | |
225 | |
2610 | 226 /* Misc stuff (For portability only) */ |
227 void * vbeMapVideoBuffer(unsigned long phys_addr,unsigned long size); | |
228 void vbeUnmapVideoBuffer(unsigned long linear_addr,unsigned long size); | |
229 | |
2460 | 230 #endif |