1ed6184dfSmrg/*
2ed6184dfSmrg * Copyright © 2002 David Dawes
3ed6184dfSmrg *
4ed6184dfSmrg * Permission is hereby granted, free of charge, to any person obtaining a
5ed6184dfSmrg * copy of this software and associated documentation files (the "Software"),
6ed6184dfSmrg * to deal in the Software without restriction, including without limitation
7ed6184dfSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8ed6184dfSmrg * and/or sell copies of the Software, and to permit persons to whom the
9ed6184dfSmrg * Software is furnished to do so, subject to the following conditions:
10ed6184dfSmrg *
11ed6184dfSmrg * The above copyright notice and this permission notice shall be included in
12ed6184dfSmrg * all copies or substantial portions of the Software.
13ed6184dfSmrg *
14ed6184dfSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15ed6184dfSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16ed6184dfSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17ed6184dfSmrg * THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18ed6184dfSmrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19ed6184dfSmrg * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20ed6184dfSmrg * SOFTWARE.
21ed6184dfSmrg *
22ed6184dfSmrg * Except as contained in this notice, the name of the author(s) shall
23ed6184dfSmrg * not be used in advertising or otherwise to promote the sale, use or other
24ed6184dfSmrg * dealings in this Software without prior written authorization from
25ed6184dfSmrg * the author(s).
26ed6184dfSmrg *
27ed6184dfSmrg * Authors: David Dawes <dawes@xfree86.org>
28ed6184dfSmrg *
29ed6184dfSmrg */
30ed6184dfSmrg
31ed6184dfSmrg#ifndef _VBE_MODES_H
32ed6184dfSmrg
33ed6184dfSmrg/*
34ed6184dfSmrg * This is intended to be stored in the DisplayModeRec's private area.
35ed6184dfSmrg * It includes all the information necessary to VBE information.
36ed6184dfSmrg */
37ed6184dfSmrgtypedef struct _VbeModeInfoData {
38ed6184dfSmrg    int mode;
39ed6184dfSmrg    VbeModeInfoBlock *data;
40ed6184dfSmrg    VbeCRTCInfoBlock *block;
41ed6184dfSmrg} VbeModeInfoData;
42ed6184dfSmrg
43ed6184dfSmrg#define V_DEPTH_1	0x001
44ed6184dfSmrg#define V_DEPTH_4	0x002
45ed6184dfSmrg#define V_DEPTH_8	0x004
46ed6184dfSmrg#define V_DEPTH_15	0x008
47ed6184dfSmrg#define V_DEPTH_16	0x010
48ed6184dfSmrg#define V_DEPTH_24_24	0x020
49ed6184dfSmrg#define V_DEPTH_24_32	0x040
50ed6184dfSmrg#define V_DEPTH_24	(V_DEPTH_24_24 | V_DEPTH_24_32)
51ed6184dfSmrg#define V_DEPTH_30	0x080
52ed6184dfSmrg#define V_DEPTH_32	0x100
53ed6184dfSmrg
54ed6184dfSmrg#define VBE_MODE_SUPPORTED(m)	(((m)->ModeAttributes & 0x01) != 0)
55ed6184dfSmrg#define VBE_MODE_COLOR(m)	(((m)->ModeAttributes & 0x08) != 0)
56ed6184dfSmrg#define VBE_MODE_GRAPHICS(m)	(((m)->ModeAttributes & 0x10) != 0)
57ed6184dfSmrg#define VBE_MODE_VGA(m)		(((m)->ModeAttributes & 0x40) == 0)
58ed6184dfSmrg#define VBE_MODE_LINEAR(m)	(((m)->ModeAttributes & 0x80) != 0 && \
59ed6184dfSmrg				 ((m)->PhysBasePtr != 0))
60ed6184dfSmrg
61ed6184dfSmrg#define VBE_MODE_USABLE(m, f)	(VBE_MODE_SUPPORTED(m) || \
62ed6184dfSmrg				 (f & V_MODETYPE_BAD)) && \
63ed6184dfSmrg				VBE_MODE_GRAPHICS(m) && \
64ed6184dfSmrg				(VBE_MODE_VGA(m) || VBE_MODE_LINEAR(m))
65ed6184dfSmrg
66ed6184dfSmrg#define V_MODETYPE_VBE		0x01
67ed6184dfSmrg#define V_MODETYPE_VGA		0x02
68ed6184dfSmrg#define V_MODETYPE_BAD		0x04
69ed6184dfSmrg
70ed6184dfSmrgextern _X_EXPORT int VBEFindSupportedDepths(vbeInfoPtr pVbe, VbeInfoBlock * vbe,
71ed6184dfSmrg                                            int *flags24, int modeTypes);
72ed6184dfSmrgextern _X_EXPORT DisplayModePtr VBEGetModePool(ScrnInfoPtr pScrn,
73ed6184dfSmrg                                               vbeInfoPtr pVbe,
74ed6184dfSmrg                                               VbeInfoBlock * vbe,
75ed6184dfSmrg                                               int modeTypes);
76ed6184dfSmrgextern _X_EXPORT void VBESetModeNames(DisplayModePtr pMode);
77ed6184dfSmrgextern _X_EXPORT void VBESetModeParameters(ScrnInfoPtr pScrn, vbeInfoPtr pVbe);
78ed6184dfSmrg
79ed6184dfSmrg/*
80ed6184dfSmrg * Note: These are alternatives to the standard helpers.  They should
81ed6184dfSmrg * usually just wrap the standard helpers.
82ed6184dfSmrg */
83ed6184dfSmrgextern _X_EXPORT int VBEValidateModes(ScrnInfoPtr scrp,
84ed6184dfSmrg                                      DisplayModePtr availModes,
85ed6184dfSmrg                                      const char **modeNames,
86ed6184dfSmrg                                      ClockRangePtr clockRanges,
87ed6184dfSmrg                                      int *linePitches, int minPitch,
88ed6184dfSmrg                                      int maxPitch, int pitchInc, int minHeight,
89ed6184dfSmrg                                      int maxHeight, int virtualX, int virtualY,
90ed6184dfSmrg                                      int apertureSize,
91ed6184dfSmrg                                      LookupModeFlags strategy);
92ed6184dfSmrgextern _X_EXPORT void VBEPrintModes(ScrnInfoPtr scrp);
93ed6184dfSmrg
94ed6184dfSmrg#endif                          /* VBE_MODES_H */
95