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 r128CardInit (KdCardInfo
*card
)
32 r128c
= (R128CardInfo
*) xalloc (sizeof (R128CardInfo
));
36 r128MapReg (card
, r128c
);
38 if (!vesaInitialize (card
, &r128c
->vesa
))
52 r128ScreenInit (KdScreenInfo
*screen
)
54 R128ScreenInfo
*r128s
;
55 int screen_size
, memory
;
57 r128s
= (R128ScreenInfo
*) xalloc (sizeof (R128ScreenInfo
));
60 memset (r128s
, '\0', sizeof (R128ScreenInfo
));
61 if (!vesaScreenInitialize (screen
, &r128s
->vesa
))
68 screen->dumb = TRUE; */
70 if (r128s
->vesa
.mapping
!= VESA_LINEAR
)
73 fprintf (stderr
, "vesa mapping is %d\n", r128s
->vesa
.mapping
);
75 r128s
->screen
= r128s
->vesa
.fb
;
77 memory
= r128s
->vesa
.fb_size
;
78 screen_size
= screen
->fb
[0].byteStride
* screen
->height
;
80 memory
-= screen_size
;
81 if (memory
> screen
->fb
[0].byteStride
)
83 r128s
->off_screen
= r128s
->screen
+ screen_size
;
84 r128s
->off_screen_size
= memory
;
88 r128s
->off_screen
= 0;
89 r128s
->off_screen_size
= 0;
91 screen
->driver
= r128s
;
96 r128InitScreen (ScreenPtr pScreen
)
98 return vesaInitScreen (pScreen
);
102 r128FinishInitScreen (ScreenPtr pScreen
)
106 ret
= vesaFinishInitScreen (pScreen
);
112 r128Preserve (KdCardInfo
*card
)
118 r128MapReg (KdCardInfo
*card
, R128CardInfo
*r128c
)
120 r128c
->reg_base
= (CARD8
*) KdMapDevice (R128_REG_BASE (card
),
121 R128_REG_SIZE (card
));
123 if (!r128c
->reg_base
)
128 KdSetMappedMode (R128_REG_BASE (card
),
129 R128_REG_SIZE (card
),
130 KD_MAPPED_MODE_REGISTERS
);
136 r128UnmapReg (KdCardInfo
*card
, R128CardInfo
*r128c
)
140 KdResetMappedMode (R128_REG_BASE (card
),
141 R128_REG_SIZE (card
),
142 KD_MAPPED_MODE_REGISTERS
);
143 KdUnmapDevice ((void *) r128c
->reg_base
, R128_REG_SIZE (card
));
149 r128SetMMIO (KdCardInfo
*card
, R128CardInfo
*r128c
)
151 if (!r128c
->reg_base
)
152 r128MapReg (card
, r128c
);
156 r128ResetMMIO (KdCardInfo
*card
, R128CardInfo
*r128c
)
158 r128UnmapReg (card
, r128c
);
163 r128DPMS (ScreenPtr pScreen
, int mode
)
170 r128Enable (ScreenPtr pScreen
)
172 KdScreenPriv (pScreen
);
173 R128CardInfo
*r128c
= pScreenPriv
->card
->driver
;
175 if (!vesaEnable (pScreen
))
178 r128SetMMIO (pScreenPriv
->card
, r128c
);
179 r128DPMS (pScreen
, KD_DPMS_NORMAL
);
185 r128Disable (ScreenPtr pScreen
)
187 KdScreenPriv (pScreen
);
188 R128CardInfo
*r128c
= pScreenPriv
->card
->driver
;
190 r128ResetMMIO (pScreenPriv
->card
, r128c
);
191 vesaDisable (pScreen
);
195 r128Restore (KdCardInfo
*card
)
197 R128CardInfo
*r128c
= card
->driver
;
199 r128ResetMMIO (card
, r128c
);
204 r128ScreenFini (KdScreenInfo
*screen
)
206 R128ScreenInfo
*r128s
= (R128ScreenInfo
*) screen
->driver
;
208 vesaScreenFini (screen
);
214 r128CardFini (KdCardInfo
*card
)
216 R128CardInfo
*r128c
= (R128CardInfo
*)card
->driver
;
218 r128UnmapReg (card
, r128c
);
222 KdCardFuncs r128Funcs
= {
223 r128CardInit
, /* cardinit */
224 r128ScreenInit
, /* scrinit */
225 r128InitScreen
, /* initScreen */
226 r128FinishInitScreen
, /* finishInitScreen */
227 vesaCreateResources
,/* createRes */
228 r128Preserve
, /* preserve */
229 r128Enable
, /* enable */
231 r128Disable
, /* disable */
232 r128Restore
, /* restore */
233 r128ScreenFini
, /* scrfini */
234 r128CardFini
, /* cardfini */
237 0, /* enableCursor */
238 0, /* disableCursor */
240 0, /* recolorCursor */
242 r128DrawInit
, /* initAccel */
243 r128DrawEnable
, /* enableAccel */
244 r128DrawDisable
, /* disableAccel */
245 r128DrawFini
, /* finiAccel */
247 vesaGetColors
, /* getColors */
248 vesaPutColors
, /* putColors */