2 * Copyright © 2003 Anders Carlsson
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 Anders Carlsson not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Anders Carlsson 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 * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL ANDERS CARLSSON 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.
23 #include <kdrive-config.h>
28 mgaCardInit (KdCardInfo
*card
)
32 mgac
= (MgaCardInfo
*) xalloc (sizeof (MgaCardInfo
));
36 mgaMapReg (card
, mgac
);
38 if (!vesaInitialize (card
, &mgac
->vesa
))
52 mgaScreenInit (KdScreenInfo
*screen
)
56 mgas
= (MgaScreenInfo
*) xalloc (sizeof (MgaScreenInfo
));
59 memset (mgas
, '\0', sizeof (MgaScreenInfo
));
60 if (!vesaScreenInitialize (screen
, &mgas
->vesa
))
67 screen->dumb = TRUE; */
69 if (mgas
->vesa
.mapping
!= VESA_LINEAR
)
72 fprintf (stderr
, "vesa mapping is %d\n", mgas
->vesa
.mapping
);
74 screen
->driver
= mgas
;
79 mgaInitScreen (ScreenPtr pScreen
)
81 return vesaInitScreen (pScreen
);
85 mgaFinishInitScreen (ScreenPtr pScreen
)
89 ret
= vesaFinishInitScreen (pScreen
);
95 mgaCreateResources (ScreenPtr pScreen
)
97 return vesaCreateResources (pScreen
);
101 mgaPreserve (KdCardInfo
*card
)
107 mgaMapReg (KdCardInfo
*card
, MgaCardInfo
*mgac
)
109 mgac
->reg_base
= (CARD8
*) KdMapDevice (MGA_REG_BASE (card
),
110 MGA_REG_SIZE (card
));
117 KdSetMappedMode (MGA_REG_BASE (card
),
119 KD_MAPPED_MODE_REGISTERS
);
125 mgaUnmapReg (KdCardInfo
*card
, MgaCardInfo
*mgac
)
129 KdResetMappedMode (MGA_REG_BASE (card
),
131 KD_MAPPED_MODE_REGISTERS
);
132 KdUnmapDevice ((void *) mgac
->reg_base
, MGA_REG_SIZE (card
));
139 mgaSetMMIO (KdCardInfo
*card
, MgaCardInfo
*mgac
)
142 mgaMapReg (card
, mgac
);
146 mgaResetMMIO (KdCardInfo
*card
, MgaCardInfo
*mgac
)
148 mgaUnmapReg (card
, mgac
);
152 mgaDPMS (ScreenPtr pScreen
, int mode
)
159 mgaEnable (ScreenPtr pScreen
)
161 KdScreenPriv (pScreen
);
162 MgaCardInfo
*mgac
= pScreenPriv
->card
->driver
;
164 if (!vesaEnable (pScreen
))
167 mgaSetMMIO (pScreenPriv
->card
, mgac
);
168 mgaDPMS (pScreen
, KD_DPMS_NORMAL
);
174 mgaDisable (ScreenPtr pScreen
)
176 KdScreenPriv (pScreen
);
177 MgaCardInfo
*mgac
= pScreenPriv
->card
->driver
;
179 mgaResetMMIO (pScreenPriv
->card
, mgac
);
181 vesaDisable (pScreen
);
185 mgaRestore (KdCardInfo
*card
)
187 MgaCardInfo
*mgac
= card
->driver
;
189 mgaResetMMIO (card
, mgac
);
194 mgaScreenFini (KdScreenInfo
*screen
)
196 MgaScreenInfo
*mgas
= (MgaScreenInfo
*) screen
->driver
;
198 vesaScreenFini (screen
);
204 mgaCardFini (KdCardInfo
*card
)
206 MgaCardInfo
*mgac
= (MgaCardInfo
*)card
->driver
;
208 mgaUnmapReg (card
, mgac
);
212 KdCardFuncs mgaFuncs
= {
213 mgaCardInit
, /* cardinit */
214 mgaScreenInit
, /* scrinit */
215 mgaInitScreen
, /* initScreen */
216 mgaFinishInitScreen
, /* finishInitScreen */
217 mgaCreateResources
, /* createRes */
218 mgaPreserve
, /* preserve */
219 mgaEnable
, /* enable */
221 mgaDisable
, /* disable */
222 mgaRestore
, /* restore */
223 mgaScreenFini
, /* scrfini */
224 mgaCardFini
, /* cardfini */
227 0, /* enableCursor */
228 0, /* disableCursor */
230 0, /* recolorCursor */
232 mgaDrawInit
, /* initAccel */
233 mgaDrawEnable
, /* enableAccel */
234 mgaDrawDisable
, /* disableAccel */
235 mgaDrawFini
, /* finiAccel */
237 vesaGetColors
, /* getColors */
238 vesaPutColors
, /* putColors */