1
/* $XFree86: xc/programs/Xserver/hw/xfree86/vbe/vbe.h,v 1.4 2004/01/07 04:28:06 dawes Exp $ */
5
* Copyright 2000 Egbert Eich
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 <pcpa@conectiva.com.br>
15
#include "xf86int10.h"
28
xf86Int10InfoPtr pInt10;
36
} vbeInfoRec, *vbeInfoPtr;
38
#define VBE_VERSION_MAJOR(x) *((CARD8*)(&x) + 1)
39
#define VBE_VERSION_MINOR(x) (CARD8)(x)
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);
48
typedef struct vbeControllerInfoBlock {
49
CARD8 VbeSignature[4];
52
CARD8 Capabilities[4];
55
CARD16 OemSoftwareRev;
56
CARD32 OemVendorNamePtr;
57
CARD32 OemProductNamePtr;
58
CARD32 OemProductRevPtr;
61
} vbeControllerInfoRec, *vbeControllerInfoPtr;
63
#if defined(__GNUC__) || defined(__USLC__) || defined(__SUNPRO_C)
64
#pragma pack() /* All GCC versions recognise this syntax */
70
#define __attribute__(a)
73
typedef struct _VbeInfoBlock VbeInfoBlock;
74
typedef struct _VbeModeInfoBlock VbeModeInfoBlock;
75
typedef struct _VbeCRTCInfoBlock VbeCRTCInfoBlock;
81
struct _VbeInfoBlock {
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 */
88
/*CARD32*/CARD16 *VideoModePtr; /* pointer to supported Super VGA modes */
90
CARD16 TotalMemory; /* Number of 64kb memory blocks on board */
91
/* if not VESA 2, 236 scratch bytes follow (256 bytes total size) */
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));
102
/* Return Super VGA Information */
103
VbeInfoBlock *VBEGetVBEInfo(vbeInfoPtr pVbe);
104
void VBEFreeVBEInfo(VbeInfoBlock *block);
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 */
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 */
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 */
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 */
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));
166
/* Return VBE Mode Information */
167
VbeModeInfoBlock *VBEGetModeInfo(vbeInfoPtr pVbe, int mode);
168
void VBEFreeModeInfo(VbeModeInfoBlock *block);
174
#define CRTC_DBLSCAN (1<<0)
175
#define CRTC_INTERLACE (1<<1)
176
#define CRTC_NHSYNC (1<<2)
177
#define CRTC_NVSYNC (1<<3)
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 */
193
Bool VBESetVBEMode(vbeInfoPtr pVbe, int mode, VbeCRTCInfoBlock *crtc);
199
Bool VBEGetVBEMode(vbeInfoPtr pVbe, int *mode);
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
211
* function 0 called automatically if function 1 called without
212
* a previous call to function 0.
219
} vbeSaveRestoreFunction;
222
VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction fuction,
223
pointer *memory, int *size, int *real_mode_pages);
230
VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window);
241
} vbeScanwidthCommand;
243
#define VBESetLogicalScanline(pVbe, width) \
244
VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET, width, \
246
#define VBESetLogicalScanlineBytes(pVbe, width) \
247
VBESetGetLogicalScanlineLength(pVbe, SCANWID_SET_BYTES, width, \
249
#define VBEGetLogicalScanline(pVbe, pixels, bytes, max) \
250
VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET, 0, \
252
#define VBEGetMaxLogicalScanline(pVbe, pixels, bytes, max) \
253
VBESetGetLogicalScanlineLength(pVbe, SCANWID_GET_MAX, 0, \
255
Bool VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe,
256
vbeScanwidthCommand command, int width,
257
int *pixels, int *bytes, int *max);
264
Bool VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace);
265
Bool VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y);
271
/* if bits is 0, then it is a GET */
272
int VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits);
279
* If getting a palette, the data argument is not used. It will return
281
* If setting a palette, it will return the pointer received on success,
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)
292
typedef struct _VBEpmi {
298
VBEpmi *VBEGetVBEpmi(vbeInfoPtr pVbe);
299
#define VESAFreeVBEpmi(pmi) xfree(pmi)
301
/* high level helper functions */
303
typedef struct _vbeModeInfoRec {
308
struct _vbeModeInfoRec *next;
309
} vbeModeInfoRec, *vbeModeInfoPtr;
311
vbeModeInfoPtr VBEBuildVbeModeList(vbeInfoPtr pVbe,
314
unsigned short VBECalcVbeModeIndex(vbeModeInfoPtr m,
315
DisplayModePtr mode, int bpp);
323
} vbeSaveRestoreRec, *vbeSaveRestorePtr;
326
VBEVesaSaveRestore(vbeInfoPtr pVbe, vbeSaveRestorePtr vbe_sr,
327
vbeSaveRestoreFunction function);
329
int VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int Clock);
330
Bool VBEDPMSSet(vbeInfoPtr pVbe, int mode);