Mercurial > mplayer.hg
annotate linux/vbelib.h @ 7275:fb25090e525d
1000l - planar YUV support fixed (indeo 3,4,5, i263 etc)
we shouldn't do planes[1]==NULL for formats like planar yuv
author | arpi |
---|---|
date | Wed, 04 Sep 2002 23:17:53 +0000 |
parents | 21e1ab99cb21 |
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) | |
85 | |
86 /* SuperVGA mode information block */ | |
87 struct VesaModeInfoBlock { | |
2608 | 88 unsigned short ModeAttributes; /* 00: Mode attributes */ |
89 unsigned char WinAAttributes; /* 02: Window A attributes */ | |
90 unsigned char WinBAttributes; /* 03: Window B attributes */ | |
91 unsigned short WinGranularity; /* 04: Window granularity in k */ | |
92 unsigned short WinSize; /* 06: Window size in k */ | |
93 unsigned short WinASegment; /* 08: Window A segment */ | |
94 unsigned short WinBSegment; /* 0A: Window B segment */ | |
95 FarPtr WinFuncPtr; /* 0C: 16-bit far pointer to window function */ | |
96 unsigned short BytesPerScanLine; /* 10: Bytes per scanline */ | |
2243 | 97 /* VBE 1.2 and above */ |
2608 | 98 unsigned short XResolution; /* 12: Horizontal resolution */ |
99 unsigned short YResolution; /* 14: Vertical resolution */ | |
100 unsigned char XCharSize; /* 16: Character cell width */ | |
101 unsigned char YCharSize; /* 17: Character cell height */ | |
102 unsigned char NumberOfPlanes; /* 18: Number of memory planes */ | |
103 unsigned char BitsPerPixel; /* 19: Bits per pixel */ | |
104 unsigned char NumberOfBanks; /* 1A: Number of CGA style banks */ | |
105 unsigned char MemoryModel; /* 1B: Memory model type */ | |
106 unsigned char BankSize; /* 1C: Size of CGA style banks */ | |
107 unsigned char NumberOfImagePages; /* 1D: Number of images pages */ | |
108 unsigned char res1; /* 1E: Reserved */ | |
2243 | 109 /* Direct Color fields (required for direct/6 and YUV/7 memory models) */ |
2608 | 110 unsigned char RedMaskSize; /* 1F: Size of direct color red mask */ |
111 unsigned char RedFieldPosition; /* 20: Bit posn of lsb of red mask */ | |
112 unsigned char GreenMaskSize; /* 21: Size of direct color green mask */ | |
113 unsigned char GreenFieldPosition; /* 22: Bit posn of lsb of green mask */ | |
114 unsigned char BlueMaskSize; /* 23: Size of direct color blue mask */ | |
115 unsigned char BlueFieldPosition; /* 24: Bit posn of lsb of blue mask */ | |
116 unsigned char RsvdMaskSize; /* 25: Size of direct color res mask */ | |
117 unsigned char RsvdFieldPosition; /* 26: Bit posn of lsb of res mask */ | |
118 unsigned char DirectColorModeInfo; /* 27: Direct color mode attributes */ | |
2243 | 119 /* VBE 2.0 and above */ |
2608 | 120 unsigned long PhysBasePtr; /* 28: physical address for flat memory frame buffer. (Should be converted to linear before using) */ |
121 unsigned short res3[3]; /* 2C: Reserved - always set to 0 */ | |
2243 | 122 /* VBE 3.0 and above */ |
2608 | 123 unsigned short LinBytesPerScanLine; /* 32: bytes per scan line for linear modes */ |
124 unsigned char BnkNumberOfImagePages;/* 34: number of images for banked modes */ | |
125 unsigned char LinNumberOfImagePages;/* 35: number of images for linear modes */ | |
126 unsigned char LinRedMaskSize; /* 36: size of direct color red mask (linear modes) */ | |
127 unsigned char LinRedFieldPosition; /* 37: bit position of lsb of red mask (linear modes) */ | |
128 unsigned char LinGreenMaskSize; /* 38: size of direct color green mask (linear modes) */ | |
129 unsigned char LinGreenFieldPosition;/* 39: bit position of lsb of green mask (linear modes) */ | |
130 unsigned char LinBlueMaskSize; /* 40: size of direct color blue mask (linear modes) */ | |
131 unsigned char LinBlueFieldPosition; /* 41: bit position of lsb of blue mask (linear modes) */ | |
132 unsigned char LinRsvdMaskSize; /* 42: size of direct color reserved mask (linear modes) */ | |
133 unsigned char LinRsvdFieldPosition; /* 43: bit position of lsb of reserved mask (linear modes) */ | |
134 unsigned long MaxPixelClock; /* 44: maximum pixel clock (in Hz) for graphics mode */ | |
135 char res4[189]; /* 48: remainder of ModeInfoBlock */ | |
2243 | 136 }__attribute__ ((packed)); |
137 | |
138 typedef enum { | |
139 memText= 0, | |
140 memCGA = 1, | |
141 memHercules = 2, | |
142 memPL = 3, /* Planar memory model */ | |
143 memPK = 4, /* Packed pixel memory model */ | |
144 mem256 = 5, | |
145 memRGB = 6, /* Direct color RGB memory model */ | |
146 memYUV = 7, /* Direct color YUV memory model */ | |
147 } memModels; | |
148 | |
149 struct VesaCRTCInfoBlock { | |
150 unsigned short hTotal; /* Horizontal total in pixels */ | |
151 unsigned short hSyncStart; /* Horizontal sync start in pixels */ | |
152 unsigned short hSyncEnd; /* Horizontal sync end in pixels */ | |
153 unsigned short vTotal; /* Vertical total in lines */ | |
154 unsigned short vSyncStart; /* Vertical sync start in lines */ | |
155 unsigned short vSyncEnd; /* Vertical sync end in lines */ | |
156 unsigned char Flags; /* Flags (Interlaced, Double Scan etc) */ | |
157 unsigned long PixelClock; /* Pixel clock in units of Hz */ | |
158 unsigned short RefreshRate;/* Refresh rate in units of 0.01 Hz*/ | |
159 unsigned char Reserved[40];/* remainder of CRTCInfoBlock*/ | |
160 }__attribute__ ((packed)); | |
161 | |
162 #define VESA_CRTC_DOUBLESCAN 0x01 | |
163 #define VESA_CRTC_INTERLACED 0x02 | |
164 #define VESA_CRTC_HSYNC_NEG 0x04 | |
165 #define VESA_CRTC_VSYNC_NEG 0x08 | |
166 | |
167 #define VESA_MODE_CRTC_REFRESH (1 << 11) | |
168 #define VESA_MODE_USE_LINEAR (1 << 14) | |
169 #define VESA_MODE_NOT_CLEAR (1 << 15) | |
170 | |
171 /* This will contain accesible 32-bit protmode pointers */ | |
172 struct VesaProtModeInterface | |
173 { | |
174 void (*SetWindowCall)(void); | |
175 void (*SetDisplayStart)(void); | |
176 void (*SetPaletteData)(void); | |
177 unsigned short * iopl_ports; | |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
178 }; |
2243 | 179 |
180 /* | |
181 All functions below return: | |
182 0 if succesful | |
183 0xffff if vm86 syscall error occurs | |
184 0x4fxx if VESA error occurs | |
185 */ | |
186 | |
187 #define VBE_OK 0 | |
188 #define VBE_VM86_FAIL -1 | |
189 #define VBE_OUT_OF_DOS_MEM -2 | |
190 #define VBE_OUT_OF_MEM -3 | |
2359 | 191 #define VBE_BROKEN_BIOS -4 |
2254
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
192 #define VBE_VESA_ERROR_MASK 0x004f |
6e5b548790c9
Fixed bug of 32-bit mode interface detection and save-restore mechanism
nick
parents:
2243
diff
changeset
|
193 #define VBE_VESA_ERRCODE_MASK 0xff00 |
2243 | 194 |
195 extern int vbeInit( void ); | |
2446 | 196 extern int vbeDestroy( void ); |
2243 | 197 |
198 extern int vbeGetControllerInfo(struct VbeInfoBlock *); | |
199 extern int vbeGetModeInfo(unsigned mode,struct VesaModeInfoBlock *); | |
200 extern int vbeSetMode(unsigned mode,struct VesaCRTCInfoBlock *); | |
201 extern int vbeGetMode(unsigned *mode); | |
7069 | 202 extern int vbeGetPixelClock(unsigned *mode,unsigned *pixel_clock); |
2243 | 203 extern int vbeSaveState(void **data); /* note never copy this data */ |
204 extern int vbeRestoreState(void *data); | |
205 extern int vbeGetWindow(unsigned *win_num); /* win_A=0 or win_B=1 */ | |
206 extern int vbeSetWindow(unsigned win_num,unsigned win_gran); | |
2632 | 207 extern int vbeGetScanLineLength(unsigned *num_pixels,unsigned *num_bytes); |
208 extern int vbeGetMaxScanLines(unsigned *num_pixels,unsigned *num_bytes, unsigned *num_lines); | |
209 extern int vbeSetScanLineLength(unsigned num_pixels); | |
210 extern int vbeSetScanLineLengthB(unsigned num_bytes); | |
211 extern int vbeGetDisplayStart(unsigned *pixel_num,unsigned *scan_line); | |
212 extern int vbeSetDisplayStart(unsigned long offset, int vsync); | |
2693 | 213 extern int vbeSetScheduledDisplayStart(unsigned long offset, int vsync); |
2243 | 214 /* |
215 Func 0x08-0x09: | |
216 Support of palette currently is not implemented. | |
217 */ | |
218 extern int vbeGetProtModeInfo(struct VesaProtModeInterface *); | |
2410 | 219 |
220 /* Standard VGA stuff */ | |
221 int vbeWriteString(int x, int y, int attr, char *str); | |
222 | |
2610 | 223 /* Misc stuff (For portability only) */ |
224 void * vbeMapVideoBuffer(unsigned long phys_addr,unsigned long size); | |
225 void vbeUnmapVideoBuffer(unsigned long linear_addr,unsigned long size); | |
226 | |
2460 | 227 #endif |