1706f2543Smrg/*
2706f2543Smrg * Copyright © 2002 David Dawes
3706f2543Smrg *
4706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5706f2543Smrg * copy of this software and associated documentation files (the "Software"),
6706f2543Smrg * to deal in the Software without restriction, including without limitation
7706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the
9706f2543Smrg * Software is furnished to do so, subject to the following conditions:
10706f2543Smrg *
11706f2543Smrg * The above copyright notice and this permission notice shall be included in
12706f2543Smrg * all copies or substantial portions of the Software.
13706f2543Smrg *
14706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15706f2543Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17706f2543Smrg * THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18706f2543Smrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19706f2543Smrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20706f2543Smrg * SOFTWARE.
21706f2543Smrg *
22706f2543Smrg * Except as contained in this notice, the name of the author(s) shall
23706f2543Smrg * not be used in advertising or otherwise to promote the sale, use or other
24706f2543Smrg * dealings in this Software without prior written authorization from
25706f2543Smrg * the author(s).
26706f2543Smrg *
27706f2543Smrg * Authors: David Dawes <dawes@xfree86.org>
28706f2543Smrg *
29706f2543Smrg */
30706f2543Smrg
31706f2543Smrg#ifndef _VBE_MODES_H
32706f2543Smrg
33706f2543Smrg/*
34706f2543Smrg * This is intended to be stored in the DisplayModeRec's private area.
35706f2543Smrg * It includes all the information necessary to VBE information.
36706f2543Smrg */
37706f2543Smrgtypedef struct _VbeModeInfoData {
38706f2543Smrg    int mode;
39706f2543Smrg    VbeModeInfoBlock *data;
40706f2543Smrg    VbeCRTCInfoBlock *block;
41706f2543Smrg} VbeModeInfoData;
42706f2543Smrg
43706f2543Smrg#define V_DEPTH_1	0x001
44706f2543Smrg#define V_DEPTH_4	0x002
45706f2543Smrg#define V_DEPTH_8	0x004
46706f2543Smrg#define V_DEPTH_15	0x008
47706f2543Smrg#define V_DEPTH_16	0x010
48706f2543Smrg#define V_DEPTH_24_24	0x020
49706f2543Smrg#define V_DEPTH_24_32	0x040
50706f2543Smrg#define V_DEPTH_24	(V_DEPTH_24_24 | V_DEPTH_24_32)
51706f2543Smrg#define V_DEPTH_30	0x080
52706f2543Smrg#define V_DEPTH_32	0x100
53706f2543Smrg
54706f2543Smrg#define VBE_MODE_SUPPORTED(m)	(((m)->ModeAttributes & 0x01) != 0)
55706f2543Smrg#define VBE_MODE_COLOR(m)	(((m)->ModeAttributes & 0x08) != 0)
56706f2543Smrg#define VBE_MODE_GRAPHICS(m)	(((m)->ModeAttributes & 0x10) != 0)
57706f2543Smrg#define VBE_MODE_VGA(m)		(((m)->ModeAttributes & 0x40) == 0)
58706f2543Smrg#define VBE_MODE_LINEAR(m)	(((m)->ModeAttributes & 0x80) != 0 && \
59706f2543Smrg				 ((m)->PhysBasePtr != 0))
60706f2543Smrg
61706f2543Smrg#define VBE_MODE_USABLE(m, f)	(VBE_MODE_SUPPORTED(m) || \
62706f2543Smrg				 (f & V_MODETYPE_BAD)) && \
63706f2543Smrg				VBE_MODE_GRAPHICS(m) && \
64706f2543Smrg				(VBE_MODE_VGA(m) || VBE_MODE_LINEAR(m))
65706f2543Smrg
66706f2543Smrg#define V_MODETYPE_VBE		0x01
67706f2543Smrg#define V_MODETYPE_VGA		0x02
68706f2543Smrg#define V_MODETYPE_BAD		0x04
69706f2543Smrg
70706f2543Smrgextern _X_EXPORT int VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock *vbe,
71706f2543Smrg				  int *flags24, int modeTypes);
72706f2543Smrgextern _X_EXPORT DisplayModePtr VBEGetModePool(ScrnInfoPtr pScrn, vbeInfoPtr pVbe,
73706f2543Smrg					VbeInfoBlock *vbe, int modeTypes);
74706f2543Smrgextern _X_EXPORT void VBESetModeNames(DisplayModePtr pMode);
75706f2543Smrgextern _X_EXPORT void VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe);
76706f2543Smrg
77706f2543Smrg
78706f2543Smrg/*
79706f2543Smrg * Note: These are alternatives to the standard helpers.  They should
80706f2543Smrg * usually just wrap the standard helpers.
81706f2543Smrg */
82706f2543Smrgextern _X_EXPORT int VBEValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
8366a34d92Schristos			    const char **modeNames, ClockRangePtr clockRanges,
84706f2543Smrg			    int *linePitches, int minPitch, int maxPitch,
85706f2543Smrg			    int pitchInc, int minHeight, int maxHeight,
86706f2543Smrg			    int virtualX, int virtualY, int apertureSize,
87706f2543Smrg			    LookupModeFlags strategy);
88706f2543Smrgextern _X_EXPORT void VBEPrintModes(ScrnInfoPtr scrp);
89706f2543Smrg
90706f2543Smrg#endif /* VBE_MODES_H */
91