2 * Copyright © 1999 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of Keith Packard not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Keith Packard makes no
11 * representations about the suitability of this software for any purpose. It
12 * is provided "as is" without express or implied warranty.
14 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
26 typedef unsigned long VGA32
;
27 typedef unsigned short VGA16
;
28 typedef unsigned char VGA8
;
30 typedef volatile VGA8 VGAVOL8
;
35 typedef struct _vgaReg
{
41 #define VGA_REG_NONE 0xffff
42 #define VGA_REG_END VGA_REG_NONE, 0, 0
44 typedef struct _vgaValue
{
50 #define VGA_VALUE_VALID 1 /* value ever fetched */
51 #define VGA_VALUE_MODIFIED 2 /* value ever changed */
52 #define VGA_VALUE_DIRTY 4 /* value needs syncing */
53 #define VGA_VALUE_SAVED 8 /* value preserved */
55 typedef enum _vgaAccess
{
56 VgaAccessMem
, VgaAccessIo
, VgaAccessIndMem
, VgaAccessIndIo
,
60 typedef struct _vgaMap
{
63 VGA8 addr
; /* for Ind access; addr offset from port */
64 VGA8 value
; /* for Ind access; value offset from port */
65 VGA8 index
; /* for Ind access; index value */
68 #define VGA_UNLOCK_FIXED 1 /* dont save current value */
69 #define VGA_UNLOCK_LOCK 2 /* execute only on relock */
70 #define VGA_UNLOCK_UNLOCK 4 /* execute only on unlock */
72 typedef struct _vgaSave
{
77 #define VGA_SAVE_END VGA_REG_NONE, VGA_REG_NONE
79 typedef struct _vgaCard
{
80 void (*map
) (struct _vgaCard
*card
, VGA16 reg
, VgaMap
*map
, VGABOOL write
);
91 VgaOutb (VGA8 v
, VGA16 r
);
94 VgaReadMemb (VGA32 addr
);
97 VgaWriteMemb (VGA8 v
, VGA32 addr
);
100 VgaSetImm (VgaCard
*card
, VgaReg
*reg
, VGA32 value
);
103 VgaGetImm (VgaCard
*card
, VgaReg
*reg
);
106 VgaSet (VgaCard
*card
, VgaReg
*reg
, VGA32 value
);
109 VgaGet (VgaCard
*card
, VgaReg
*reg
);
112 VgaFlush (VgaCard
*card
);
115 VgaFill (VgaCard
*card
, VGA16 low
, VGA16 high
);
118 VgaPreserve (VgaCard
*card
);
121 VgaInvalidate (VgaCard
*card
);
124 VgaRestore (VgaCard
*card
);
127 VgaFinish (VgaCard
*card
);
130 VgaFlushReg (VgaCard
*card
, VgaReg
*reg
);
133 VgaFetch (VgaCard
*card
, VGA16 id
);
136 VgaStore (VgaCard
*card
, VGA16 id
, VGA8 value
);
139 _VgaFetchInd (VGA16 port
, VGA8 reg
);
142 _VgaStoreInd (VGA16 port
, VGA8 reg
, VGA8 value
);