1 | /* $XFree86: xc/programs/Xserver/hw/xfree86/vbe/vbe.h,v 1.4 2004/01/07 04:28:06 dawes Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * XFree86 vbe module
|
---|
5 | * Copyright 2000 Egbert Eich
|
---|
6 | *
|
---|
7 | * The mode query/save/set/restore functions from the vesa driver
|
---|
8 | * have been moved here.
|
---|
9 | * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
|
---|
10 | * Authors: Paulo César Pereira de Andrade <[email protected]>
|
---|
11 | */
|
---|
12 |
|
---|
13 | #ifndef _VBE_H
|
---|
14 | #define _VBE_H
|
---|
15 | #include "xf86int10.h"
|
---|
16 | #include "xf86DDC.h"
|
---|
17 |
|
---|
18 | typedef enum {
|
---|
19 | DDC_UNCHECKED,
|
---|
20 | DDC_NONE,
|
---|
21 | DDC_1,
|
---|
22 | DDC_2,
|
---|
23 | DDC_1_2
|
---|
24 | }
|
---|
25 | ddc_lvl;
|
---|
26 |
|
---|
27 | typedef struct {
|
---|
28 | xf86Int10InfoPtr pInt10;
|
---|
29 | int version;
|
---|
30 | pointer memory;
|
---|
31 | int real_mode_base;
|
---|
32 | int num_pages;
|
---|
33 | Bool init_int10;
|
---|
34 | ddc_lvl ddc;
|
---|
35 | Bool ddc_blank;
|
---|
36 | } vbeInfoRec, *vbeInfoPtr;
|
---|
37 |
|
---|
38 | #define VBE_VERSION_MAJOR(x) *((CARD8*)(&x) + 1)
|
---|
39 | #define VBE_VERSION_MINOR(x) (CARD8)(x)
|
---|
40 |
|
---|
41 | vbeInfoPtr VBEInit(xf86Int10InfoPtr pInt, int entityIndex);
|
---|
42 | vbeInfoPtr VBEExtendedInit(xf86Int10InfoPtr pInt, int entityIndex, int Flags);
|
---|
43 | void vbeFree(vbeInfoPtr pVbe);
|
---|
44 | xf86MonPtr vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule);
|
---|
45 |
|
---|
46 | #pragma pack(1)
|
---|
47 |
|
---|
48 | typedef struct vbeControllerInfoBlock {
|
---|
49 | CARD8 VbeSignature[4];
|
---|
50 | CARD16 VbeVersion;
|
---|
51 | CARD32 OemStringPtr;
|
---|
52 | CARD8 Capabilities[4];
|
---|
53 | CARD32 VideoModePtr;
|
---|
54 | CARD16 TotalMem;
|
---|
55 | CARD16 OemSoftwareRev;
|
---|
56 | CARD32 OemVendorNamePtr;
|
---|
57 | CARD32 OemProductNamePtr;
|
---|
58 | CARD32 OemProductRevPtr;
|
---|
59 | CARD8 Scratch[222];
|
---|
60 | CARD8 OemData[256];
|
---|
61 | } vbeControllerInfoRec, *vbeControllerInfoPtr;
|
---|
62 |
|
---|
63 | #if defined(__GNUC__) || defined(__USLC__) || defined(__SUNPRO_C)
|
---|
64 | #pragma pack() /* All GCC versions recognise this syntax */
|
---|
65 | #else
|
---|
66 | #pragma pack(0)
|
---|
67 | #endif
|
---|
68 |
|
---|
69 | #ifndef __GNUC__
|
---|
70 | #define __attribute__(a)
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | typedef struct _VbeInfoBlock VbeInfoBlock;
|
---|
74 | typedef struct _VbeModeInfoBlock VbeModeInfoBlock;
|
---|
75 | typedef struct _VbeCRTCInfoBlock VbeCRTCInfoBlock;
|
---|
76 |
|
---|
77 | /*
|
---|
78 | * INT 0
|
---|
79 | */
|
---|
80 |
|
---|
81 | struct _VbeInfoBlock {
|
---|
82 | /* VESA 1.2 fields */
|
---|
83 | CARD8 VESASignature[4]; /* VESA */
|
---|
84 | CARD16 VESAVersion; /* Higher byte major, lower byte minor */
|
---|
85 | /*CARD32*/char *OEMStringPtr; /* Pointer to OEM string */
|
---|
86 | CARD8 Capabilities[4]; /* Capabilities of the video environment */
|
---|
87 |
|
---|
88 | /*CARD32*/CARD16 *VideoModePtr; /* pointer to supported Super VGA modes */
|
---|
89 |
|
---|
90 | CARD16 TotalMemory; /* Number of 64kb memory blocks on board */
|
---|
91 | /* if not VESA 2, 236 scratch bytes follow (256 bytes total size) */
|
---|
92 |
|
---|
93 | /* VESA 2 fields */
|
---|
94 | CARD16 OemSoftwareRev; /* VBE implementation Software revision */
|
---|
95 | /*CARD32*/char *OemVendorNamePtr; /* Pointer to Vendor Name String */
|
---|
96 | /*CARD32*/char *OemProductNamePtr; /* Pointer to Product Name String */
|
---|
97 | /*CARD32*/char *OemProductRevPtr; /* Pointer to Product Revision String */
|
---|
98 | CARD8 Reserved[222]; /* Reserved for VBE implementation */
|
---|
99 | CARD8 OemData[256]; /* Data Area for OEM Strings */
|
---|
100 | } __attribute__((packed));
|
---|
101 |
|
---|
102 | /* Return Super VGA Information */
|
---|
103 | VbeInfoBlock *VBEGetVBEInfo(vbeInfoPtr pVbe);
|
---|
104 | void VBEFreeVBEInfo(VbeInfoBlock *block);
|
---|
105 |
|
---|
106 | /*
|
---|
107 | * INT 1
|
---|
108 | */
|
---|
109 |
|
---|
110 | struct _VbeModeInfoBlock {
|
---|
111 | CARD16 ModeAttributes; /* mode attributes */
|
---|
112 | CARD8 WinAAttributes; /* window A attributes */
|
---|
113 | CARD8 WinBAttributes; /* window B attributes */
|
---|
114 | CARD16 WinGranularity; /* window granularity */
|
---|
115 | CARD16 WinSize; /* window size */
|
---|
116 | CARD16 WinASegment; /* window A start segment */
|
---|
117 | CARD16 WinBSegment; /* window B start segment */
|
---|
118 | CARD32 WinFuncPtr; /* real mode pointer to window function */
|
---|
119 | CARD16 BytesPerScanline; /* bytes per scanline */
|
---|
120 |
|
---|
121 | /* Mandatory information for VBE 1.2 and above */
|
---|
122 | CARD16 XResolution; /* horizontal resolution in pixels or characters */
|
---|
123 | CARD16 YResolution; /* vertical resolution in pixels or characters */
|
---|
124 | CARD8 XCharSize; /* character cell width in pixels */
|
---|
125 | CARD8 YCharSize; /* character cell height in pixels */
|
---|
126 | CARD8 NumberOfPlanes; /* number of memory planes */
|
---|
127 | CARD8 BitsPerPixel; /* bits per pixel */
|
---|
128 | CARD8 NumberOfBanks; /* number of banks */
|
---|
129 | CARD8 MemoryModel; /* memory model type */
|
---|
130 | CARD8 BankSize; /* bank size in KB */
|
---|
131 | CARD8 NumberOfImages; /* number of images */
|
---|
132 | CARD8 Reserved; /* 1 */ /* reserved for page function */
|
---|
133 |
|
---|
134 | /* Direct color fields (required for direct/6 and YUV/7 memory models) */
|
---|
135 | CARD8 RedMaskSize; /* size of direct color red mask in bits */
|
---|
136 | CARD8 RedFieldPosition; /* bit position of lsb of red mask */
|
---|
137 | CARD8 GreenMaskSize; /* size of direct color green mask in bits */
|
---|
138 | CARD8 GreenFieldPosition; /* bit position of lsb of green mask */
|
---|
139 | CARD8 BlueMaskSize; /* size of direct color blue mask in bits */
|
---|
140 | CARD8 BlueFieldPosition; /* bit position of lsb of blue mask */
|
---|
141 | CARD8 RsvdMaskSize; /* size of direct color reserved mask in bits */
|
---|
142 | CARD8 RsvdFieldPosition; /* bit position of lsb of reserved mask */
|
---|
143 | CARD8 DirectColorModeInfo; /* direct color mode attributes */
|
---|
144 |
|
---|
145 | /* Mandatory information for VBE 2.0 and above */
|
---|
146 | CARD32 PhysBasePtr; /* physical address for flat memory frame buffer */
|
---|
147 | CARD32 Reserved32; /* 0 */ /* Reserved - always set to 0 */
|
---|
148 | CARD16 Reserved16; /* 0 */ /* Reserved - always set to 0 */
|
---|
149 |
|
---|
150 | /* Mandatory information for VBE 3.0 and above */
|
---|
151 | CARD16 LinBytesPerScanLine; /* bytes per scan line for linear modes */
|
---|
152 | CARD8 BnkNumberOfImagePages; /* number of images for banked modes */
|
---|
153 | CARD8 LinNumberOfImagePages; /* number of images for linear modes */
|
---|
154 | CARD8 LinRedMaskSize; /* size of direct color red mask (linear modes) */
|
---|
155 | CARD8 LinRedFieldPosition; /* bit position of lsb of red mask (linear modes) */
|
---|
156 | CARD8 LinGreenMaskSize; /* size of direct color green mask (linear modes) */
|
---|
157 | CARD8 LinGreenFieldPosition; /* bit position of lsb of green mask (linear modes) */
|
---|
158 | CARD8 LinBlueMaskSize; /* size of direct color blue mask (linear modes) */
|
---|
159 | CARD8 LinBlueFieldPosition; /* bit position of lsb of blue mask (linear modes) */
|
---|
160 | CARD8 LinRsvdMaskSize; /* size of direct color reserved mask (linear modes) */
|
---|
161 | CARD8 LinRsvdFieldPosition; /* bit position of lsb of reserved mask (linear modes) */
|
---|
162 | CARD32 MaxPixelClock; /* maximum pixel clock (in Hz) for graphics mode */
|
---|
163 | CARD8 Reserved2[189]; /* remainder of VbeModeInfoBlock */
|
---|
164 | } __attribute__((packed));
|
---|
165 |
|
---|
166 | /* Return VBE Mode Information */
|
---|
167 | VbeModeInfoBlock *VBEGetModeInfo(vbeInfoPtr pVbe, int mode);
|
---|
168 | void VBEFreeModeInfo(VbeModeInfoBlock *block);
|
---|
169 |
|
---|
170 | /*
|
---|
171 | * INT2
|
---|
172 | */
|
---|
173 |
|
---|
174 | #define CRTC_DBLSCAN (1<<0)
|
---|
175 | #define CRTC_INTERLACE (1<<1)
|
---|
176 | #define CRTC_NHSYNC (1<<2)
|
---|
177 | #define CRTC_NVSYNC (1<<3)
|
---|
178 |
|
---|
179 | struct _VbeCRTCInfoBlock {
|
---|
180 | CARD16 HorizontalTotal; /* Horizontal total in pixels */
|
---|
181 | CARD16 HorizontalSyncStart; /* Horizontal sync start in pixels */
|
---|
182 | CARD16 HorizontalSyncEnd; /* Horizontal sync end in pixels */
|
---|
183 | CARD16 VerticalTotal; /* Vertical total in lines */
|
---|
184 | CARD16 VerticalSyncStart; /* Vertical sync start in lines */
|
---|
185 | CARD16 VerticalSyncEnd; /* Vertical sync end in lines */
|
---|
186 | CARD8 Flags; /* Flags (Interlaced, Double Scan etc) */
|
---|
187 | CARD32 PixelClock; /* Pixel clock in units of Hz */
|
---|
188 | CARD16 RefreshRate; /* Refresh rate in units of 0.01 Hz */
|
---|
189 | CARD8 Reserved[40]; /* remainder of ModeInfoBlock */
|
---|
190 | } __attribute__((packed));
|
---|
191 | /* VbeCRTCInfoBlock is in the VESA 3.0 specs */
|
---|
192 |
|
---|
193 | Bool VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock *crtc);
|
---|
194 |
|
---|
195 | /*
|
---|
196 | * INT 3
|
---|
197 | */
|
---|
198 |
|
---|
199 | Bool VBEGetVBEMode(vbeInfoPtr pVbe, int *mode);
|
---|
200 |
|
---|
201 | /*
|
---|
202 | * INT 4
|
---|
203 | */
|
---|
204 |
|
---|
205 | /* Save/Restore Super VGA video state */
|
---|
206 | /* function values are (values stored in VESAPtr):
|
---|
207 | * 0 := query & allocate amount of memory to save state
|
---|
208 | * 1 := save state
|
---|
209 | * 2 := restore state
|
---|
210 | *
|
---|
211 | * function 0 called automatically if function 1 called without
|
---|
212 | * a previous call to function 0.
|
---|
213 | */
|
---|
214 |
|
---|
215 | typedef enum {
|
---|
216 | MODE_QUERY,
|
---|
217 | MODE_SAVE,
|
---|
218 | MODE_RESTORE
|
---|
219 | } vbeSaveRestoreFunction;
|
---|
220 |
|
---|
221 | Bool
|
---|
222 | VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction fuction,
|
---|
223 | pointer *memory, int *size, int *real_mode_pages);
|
---|
224 |
|
---|
225 | /*
|
---|
226 | * INT 5
|
---|
227 | */
|
---|
228 |
|
---|
229 | Bool
|
---|
230 | VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window);
|
---|
231 |
|
---|
232 | /*
|
---|
233 | * INT 6
|
---|
234 | */
|
---|
235 |
|
---|
236 | typedef enum {
|
---|
237 | SCANWID_SET,
|
---|
238 | SCANWID_GET,
|
---|
239 | SCANWID_SET_BYTES,
|
---|
240 | SCANWID_GET_MAX
|
---|
241 | } vbeScanwidthCommand;
|
---|
242 |
|
---|
243 | #define VBESetLogicalScanline(pVbe, width) \
|
---|
244 | VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET, width, \
|
---|
245 | NULL, NULL, NULL)
|
---|
246 | #define VBESetLogicalScanlineBytes(pVbe, width) \
|
---|
247 | VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET_BYTES, width, \
|
---|
248 | NULL, NULL, NULL)
|
---|
249 | #define VBEGetLogicalScanline(pVbe, pixels, bytes, max) \
|
---|
250 | VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET, 0, \
|
---|
251 | pixels, bytes, max)
|
---|
252 | #define VBEGetMaxLogicalScanline(pVbe, pixels, bytes, max) \
|
---|
253 | VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET_MAX, 0, \
|
---|
254 | pixels, bytes, max)
|
---|
255 | Bool VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe,
|
---|
256 | vbeScanwidthCommand command, int width,
|
---|
257 | int *pixels, int *bytes, int *max);
|
---|
258 |
|
---|
259 | /*
|
---|
260 | * INT 7
|
---|
261 | */
|
---|
262 |
|
---|
263 | /* 16 bit code */
|
---|
264 | Bool VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace);
|
---|
265 | Bool VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y);
|
---|
266 |
|
---|
267 | /*
|
---|
268 | * INT 8
|
---|
269 | */
|
---|
270 |
|
---|
271 | /* if bits is 0, then it is a GET */
|
---|
272 | int VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits);
|
---|
273 |
|
---|
274 | /*
|
---|
275 | * INT 9
|
---|
276 | */
|
---|
277 |
|
---|
278 | /*
|
---|
279 | * If getting a palette, the data argument is not used. It will return
|
---|
280 | * the data.
|
---|
281 | * If setting a palette, it will return the pointer received on success,
|
---|
282 | * NULL on failure.
|
---|
283 | */
|
---|
284 | CARD32 *VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
|
---|
285 | CARD32 *data, Bool secondary, Bool wait_retrace);
|
---|
286 | #define VBEFreePaletteData(data) xfree(data)
|
---|
287 |
|
---|
288 | /*
|
---|
289 | * INT A
|
---|
290 | */
|
---|
291 |
|
---|
292 | typedef struct _VBEpmi {
|
---|
293 | int seg_tbl;
|
---|
294 | int tbl_off;
|
---|
295 | int tbl_len;
|
---|
296 | } VBEpmi;
|
---|
297 |
|
---|
298 | VBEpmi *VBEGetVBEpmi(vbeInfoPtr pVbe);
|
---|
299 | #define VESAFreeVBEpmi(pmi) xfree(pmi)
|
---|
300 |
|
---|
301 | /* high level helper functions */
|
---|
302 |
|
---|
303 | typedef struct _vbeModeInfoRec {
|
---|
304 | int width;
|
---|
305 | int height;
|
---|
306 | int bpp;
|
---|
307 | int n;
|
---|
308 | struct _vbeModeInfoRec *next;
|
---|
309 | } vbeModeInfoRec, *vbeModeInfoPtr;
|
---|
310 |
|
---|
311 | vbeModeInfoPtr VBEBuildVbeModeList(vbeInfoPtr pVbe,
|
---|
312 | VbeInfoBlock *vbe);
|
---|
313 |
|
---|
314 | unsigned short VBECalcVbeModeIndex(vbeModeInfoPtr m,
|
---|
315 | DisplayModePtr mode, int bpp);
|
---|
316 |
|
---|
317 | typedef struct {
|
---|
318 | CARD8 *state;
|
---|
319 | CARD8 *pstate;
|
---|
320 | int statePage;
|
---|
321 | int stateSize;
|
---|
322 | int stateMode;
|
---|
323 | } vbeSaveRestoreRec, *vbeSaveRestorePtr;
|
---|
324 |
|
---|
325 | void
|
---|
326 | VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr,
|
---|
327 | vbeSaveRestoreFunction function);
|
---|
328 |
|
---|
329 | int VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int Clock);
|
---|
330 | Bool VBEDPMSSet(vbeInfoPtr pVbe, int mode);
|
---|
331 |
|
---|
332 | #endif
|
---|