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