Chameleon

Chameleon Svn Source Tree

Root/branches/valv/AnVAL/i386/libsaio/vbe.h

1/*
2 * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 2.0 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24// Copyright 1997 by Apple Computer, Inc., all rights reserved.
25/* Copyright 1996-1997 NeXT Software, Inc.
26 *
27 * vesa.h - mode info obtained via int10
28 *
29 * Revision History
30 * ----------------
31 * 30 Jul 1996 Doug Mitchell at NeXT
32 * Created.
33 */
34
35#ifndef __LIBSAIO_VBE_H
36#define __LIBSAIO_VBE_H
37
38#define MIN_VESA_VERSION 0x200
39
40#define SEG(address) \
41 ((unsigned short)(((unsigned long)address & 0xffff0000) >> 4))
42
43#define OFF(address) \
44 ((unsigned short)((unsigned long)address & 0x0000ffff))
45
46#define VBEMakeUInt32(x) \
47 (((unsigned long)x##_high << 24) | \
48 ((unsigned long)x##_2 << 16) | \
49 ((unsigned long)x##_1 << 8) | \
50 (unsigned long)x##_low)
51
52#define VBEDecodeFP(t, fp) \
53 ((t)(((fp ## _low) | ((fp ## _1 ) << 8)) + \
54 (((fp ## _2) << 4) | ((fp ## _high ) << 12))))
55
56/*
57 * Functions
58 */
59enum {
60 funcGetControllerInfo = 0x4F00,
61 funcGetModeInfo = 0x4F01,
62 funcSetMode = 0x4F02,
63 funcGetCurrentMode = 0x4F03,
64 funcSaveRestoreState = 0x4F04,
65 funcWindowControl = 0x4F05,
66 funcGetSetScanLineLength = 0x4F06,
67 funcGetSetDisplayStart = 0x4F07,
68 funcGetSetPaletteFormat = 0x4F08,
69 funcGetSetPaletteData = 0x4F09,
70 funcGetProtModeInterdace = 0x4F0A,
71 funcGetSetPixelClock = 0x4F0B,
72funcGetEDID = 0x4f15
73};
74
75enum {
76 subfuncSet = 0x00,
77 subfuncGet = 0x01,
78 subfuncSetSecondary = 0x02,
79 subfuncGetSecondary = 0x03
80};
81
82/*
83 * errors.
84 */
85enum {
86 errSuccess = 0,
87 errFuncFailed = 1,
88 errFuncNotSupported = 2,
89 errFuncInvalid = 3
90};
91
92/*
93 * Per-controller info, returned in function 4f00.
94 */
95typedef struct {
96 unsigned char VESASignature[4];
97 unsigned short VESAVersion;
98 /*
99 * Avoid packing problem...
100 */
101 unsigned char OEMStringPtr_low;
102 unsigned char OEMStringPtr_1;
103 unsigned char OEMStringPtr_2;
104 unsigned char OEMStringPtr_high;
105 unsigned char Capabilities_low;
106 unsigned char Capabilities_1;
107 unsigned char Capabilities_2;
108 unsigned char Capabilities_high;
109 unsigned char VideoModePtr_low;
110 unsigned char VideoModePtr_1;
111 unsigned char VideoModePtr_2;
112 unsigned char VideoModePtr_high;
113 unsigned short TotalMemory;
114 unsigned char Reserved[236];
115 unsigned char OEMData[256];
116} VBEInfoBlock;
117
118/*
119 * Capabilites
120 */
121enum {
122 capDACWidthIsSwitchableBit = (1 << 0), /* 1 = yes; 0 = no */
123 capControllerIsNotVGACompatableBit = (1 << 1), /* 1 = no; 0 = yes */
124 capOldRAMDAC = (1 << 2) /* 1 = yes; 0 = no */
125};
126
127/*
128 * Per-mode info, returned in function 4f02.
129 */
130typedef struct {
131 unsigned short ModeAttributes;
132 unsigned char WinAAttributes;
133 unsigned char WinBAttributes;
134 unsigned short WinGranularity;
135 unsigned short WinSize;
136 unsigned short WinASegment;
137 unsigned short WinABegment;
138 void * WinFuncPtr;
139 unsigned short BytesPerScanline;
140 unsigned short XResolution;
141 unsigned short YResolution;
142 unsigned char XCharSize;
143 unsigned char YCharSize;
144 unsigned char NumberOfPlanes;
145 unsigned char BitsPerPixel;
146 unsigned char NumberOfBanks;
147 unsigned char MemoryModel;
148 unsigned char BankSize;
149 unsigned char NumberOfImagePages;
150 unsigned char Reserved;
151 unsigned char RedMaskSize;
152 unsigned char RedFieldPosition;
153 unsigned char GreenMaskSize;
154 unsigned char GreenFieldPosition;
155 unsigned char BlueMaskSize;
156 unsigned char BlueFieldPosition;
157 unsigned char RsvdMaskSize;
158 unsigned char RsvdFieldPosition;
159 unsigned char DirectColorModeInfo;
160 unsigned char PhysBasePtr_low;
161 unsigned char PhysBasePtr_1;
162 unsigned char PhysBasePtr_2;
163 unsigned char PhysBasePtr_high;
164 void * OffScreenMemOffset;
165 unsigned short OffScreenMemSize;
166 unsigned char Reserved1[206];
167} VBEModeInfoBlock;
168
169/*
170 * ModeAttributes bits
171 */
172enum {
173 maModeIsSupportedBit = (1 << 0), /* mode is supported */
174 maExtendedInfoAvailableBit = (1 << 1), /* extended info available */
175 maOutputFuncSupportedBit = (1 << 2), /* output functions supported */
176 maColorModeBit = (1 << 3), /* 1 = color; 0 = mono */
177 maGraphicsModeBit = (1 << 4), /* 1 = graphics; 0 = text */
178 maModeIsNotVGACompatableBit = (1 << 5), /* 1 = not compat; 0 = compat */
179 maVGAMemoryModeNotAvailBit = (1 << 6), /* 1 = not avail; 0 = avail */
180 maLinearFrameBufferAvailBit = (1 << 7) /* 1 = avail; 0 = not avail */
181};
182
183/*
184 * Modes
185 */
186enum {
187 mode640x400x256 = 0x100,
188 mode640x480x256 = 0x101,
189 mode800x600x16 = 0x102,
190 mode800x600x256 = 0x103,
191 mode1024x768x16 = 0x104,
192 mode1024x768x256 = 0x105,
193 mode1280x1024x16 = 0x106,
194 mode1280x1024x256 = 0x107,
195 mode80Cx60R = 0x108,
196 mode132Cx25R = 0x109,
197 mode132Cx43R = 0x10A,
198 mode132Cx50R = 0x10B,
199 mode132Cx60R = 0x10C,
200 mode320x200x555 = 0x10D,
201 mode320x200x565 = 0x10E,
202 mode320x200x888 = 0x10F,
203 mode640x480x555 = 0x110,
204 mode640x480x565 = 0x111,
205 mode640x480x888 = 0x112,
206 mode800x600x555 = 0x113,
207 mode800x600x565 = 0x114,
208 mode800x600x888 = 0x115,
209 mode1024x768x555 = 0x116,
210 mode1024x768x565 = 0x117,
211 mode1024x768x888 = 0x118,
212 mode1280x1024x555 = 0x119,
213 mode1280x1024x565 = 0x11A,
214 mode1280x1024x888 = 0x11B,
215 modeSpecial = 0x81FF,
216 modeEndOfList = 0xFFFF
217};
218
219/*
220 * Get/Set VBE Mode parameters
221 */
222enum {
223 kCustomRefreshRateBit = (1 << 11),
224 kLinearFrameBufferBit = (1 << 14),
225 kPreserveMemoryBit = (1 << 15)
226};
227
228/*
229 * CRTC information block passed to function 4F02
230 * to override default refresh rate.
231 */
232#pragma pack(1)
233
234typedef struct {
235 unsigned short HTotal;
236 unsigned short HSyncStart;
237 unsigned short HSyncEnd;
238 unsigned short VTotal;
239 unsigned short VSyncStart;
240 unsigned short VSyncEnd;
241 unsigned char Flags;
242 unsigned long PixelClock; /* in Hz */
243 unsigned short RefreshRate; /* units of 0.01 Hz */
244 unsigned char Reserved[40];
245} VBECRTCInfoBlock;
246
247#pragma pack()
248
249/*
250 * Defined flags for 'Flags' field in VBECRTCInfoBlock.
251 */
252enum {
253 kCRTCDoubleScannedMode = (1 << 0),
254 kCRTCInterlacedMode = (1 << 1),
255 kCRTCNegativeHorizontalSync = (1 << 2),
256 kCRTCNegativeVerticalSync = (1 << 3)
257};
258
259/*
260 * The type of paramter passed to generateCRTCTimings().
261 */
262enum {
263 kCRTCParamRefreshRate,
264 kCRTCParamPixelClock
265};
266
267/*
268 * Palette
269 */
270typedef unsigned long VBEPalette[256];
271
272extern int getVBEInfo(void *vinfo_p);
273extern int getEDID(void * edidBlock, UInt8 blocks_left);
274extern int getVBEModeInfo(int mode, void *minfo_p);
275extern int getVBEDACFormat(unsigned char *format);
276extern int setVBEDACFormat(unsigned char format);
277extern int setVBEPalette(void *palette);
278extern int getVBEPalette(void *palette);
279extern int setVBEMode(unsigned short mode, const VBECRTCInfoBlock *timing);
280extern int getVBECurrentMode(unsigned short *mode);
281extern int getVBEPixelClock(unsigned short mode, unsigned long *pixelClock);
282extern int generateCRTCTiming(unsigned short width,
283 unsigned short height,
284 unsigned long paramValue,
285 int paramType,
286 VBECRTCInfoBlock * timing);
287
288#endif /* !__LIBSAIO_VBE_H */
289

Archive Download this file

Revision: 160