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