2 * Copyright © 2003 Eric Anholt
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 Eric Anholt not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Eric Anholt 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 * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL ERIC ANHOLT 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.
24 #include <kdrive-config.h>
29 struct pci_id_entry sis_pci_ids
[] = {
30 {0x1039, 0x0300, 0x1, "SiS 300/305"},
31 {0x1039, 0x5300, 0x1, "SiS 540"},
32 {0x1039, 0x6300, 0x1, "SiS 630"},
33 {0x1039, 0x7300, 0x1, "SiS 730"},
38 SiSCardInit(KdCardInfo
*card
)
41 Bool initialized
= FALSE
;
43 sisc
= xcalloc(sizeof(SiSCardInfo
), 1);
48 if (!initialized
&& fbdevInitialize(card
, &sisc
->backend_priv
.fbdev
)) {
49 sisc
->use_fbdev
= TRUE
;
51 sisc
->backend_funcs
.cardfini
= fbdevCardFini
;
52 sisc
->backend_funcs
.scrfini
= fbdevScreenFini
;
53 sisc
->backend_funcs
.initScreen
= fbdevInitScreen
;
54 sisc
->backend_funcs
.finishInitScreen
= fbdevFinishInitScreen
;
55 sisc
->backend_funcs
.createRes
= fbdevCreateResources
;
56 sisc
->backend_funcs
.preserve
= fbdevPreserve
;
57 sisc
->backend_funcs
.restore
= fbdevRestore
;
58 sisc
->backend_funcs
.dpms
= fbdevDPMS
;
59 sisc
->backend_funcs
.enable
= fbdevEnable
;
60 sisc
->backend_funcs
.disable
= fbdevDisable
;
61 sisc
->backend_funcs
.getColors
= fbdevGetColors
;
62 sisc
->backend_funcs
.putColors
= fbdevPutColors
;
66 if (!initialized
&& vesaInitialize(card
, &sisc
->backend_priv
.vesa
)) {
67 sisc
->use_vesa
= TRUE
;
69 sisc
->backend_funcs
.cardfini
= vesaCardFini
;
70 sisc
->backend_funcs
.scrfini
= vesaScreenFini
;
71 sisc
->backend_funcs
.initScreen
= vesaInitScreen
;
72 sisc
->backend_funcs
.finishInitScreen
= vesaFinishInitScreen
;
73 sisc
->backend_funcs
.createRes
= vesaCreateResources
;
74 sisc
->backend_funcs
.preserve
= vesaPreserve
;
75 sisc
->backend_funcs
.restore
= vesaRestore
;
76 sisc
->backend_funcs
.dpms
= vesaDPMS
;
77 sisc
->backend_funcs
.enable
= vesaEnable
;
78 sisc
->backend_funcs
.disable
= vesaDisable
;
79 sisc
->backend_funcs
.getColors
= vesaGetColors
;
80 sisc
->backend_funcs
.putColors
= vesaPutColors
;
84 if (!initialized
|| !SiSMapReg(card
, sisc
)) {
95 SiSCardFini(KdCardInfo
*card
)
97 SiSCardInfo
*sisc
= (SiSCardInfo
*)card
->driver
;
99 SiSUnmapReg(card
, sisc
);
100 sisc
->backend_funcs
.cardfini(card
);
104 SiSScreenInit(KdScreenInfo
*screen
)
110 siss
= xcalloc(sizeof(SiSScreenInfo
), 1);
116 screen
->driver
= siss
;
119 if (sisc
->use_fbdev
) {
120 success
= fbdevScreenInitialize(screen
,
121 &siss
->backend_priv
.fbdev
);
122 screen
->memory_size
= sisc
->backend_priv
.fbdev
.fix
.smem_len
;
123 screen
->off_screen_base
=
124 sisc
->backend_priv
.fbdev
.var
.yres_virtual
*
125 screen
->fb
[0].byteStride
;
129 if (sisc
->use_vesa
) {
130 if (screen
->fb
[0].depth
== 0)
131 screen
->fb
[0].depth
= 16;
132 success
= vesaScreenInitialize(screen
,
133 &siss
->backend_priv
.vesa
);
137 screen
->driver
= NULL
;
146 SiSScreenFini(KdScreenInfo
*screen
)
148 SiSScreenInfo
*siss
= (SiSScreenInfo
*)screen
->driver
;
149 SiSCardInfo
*sisc
= screen
->card
->driver
;
151 sisc
->backend_funcs
.scrfini(screen
);
157 SiSMapReg(KdCardInfo
*card
, SiSCardInfo
*sisc
)
159 sisc
->reg_base
= (CARD8
*)KdMapDevice(SIS_REG_BASE(card
),
162 if (sisc
->reg_base
== NULL
)
165 KdSetMappedMode(SIS_REG_BASE(card
), SIS_REG_SIZE(card
),
166 KD_MAPPED_MODE_REGISTERS
);
172 SiSUnmapReg(KdCardInfo
*card
, SiSCardInfo
*sisc
)
174 if (sisc
->reg_base
) {
175 KdResetMappedMode(SIS_REG_BASE(card
), SIS_REG_SIZE(card
),
176 KD_MAPPED_MODE_REGISTERS
);
177 KdUnmapDevice((void *)sisc
->reg_base
, SIS_REG_SIZE(card
));
183 SiSInitScreen(ScreenPtr pScreen
)
185 KdScreenPriv(pScreen
);
186 SiSCardInfo(pScreenPriv
);
188 return sisc
->backend_funcs
.initScreen(pScreen
);
192 SiSFinishInitScreen(ScreenPtr pScreen
)
194 KdScreenPriv(pScreen
);
195 SiSCardInfo(pScreenPriv
);
197 return sisc
->backend_funcs
.finishInitScreen(pScreen
);
201 SiSCreateResources(ScreenPtr pScreen
)
203 KdScreenPriv(pScreen
);
204 SiSCardInfo(pScreenPriv
);
206 return sisc
->backend_funcs
.createRes(pScreen
);
210 SiSPreserve(KdCardInfo
*card
)
212 SiSCardInfo
*sisc
= card
->driver
;
214 sisc
->backend_funcs
.preserve(card
);
218 SiSRestore(KdCardInfo
*card
)
220 SiSCardInfo
*sisc
= card
->driver
;
222 SiSUnmapReg(card
, sisc
);
224 sisc
->backend_funcs
.restore(card
);
228 SiSDPMS(ScreenPtr pScreen
, int mode
)
230 KdScreenPriv(pScreen
);
231 SiSCardInfo(pScreenPriv
);
233 return sisc
->backend_funcs
.dpms(pScreen
, mode
);
237 SiSEnable(ScreenPtr pScreen
)
239 KdScreenPriv(pScreen
);
240 SiSCardInfo(pScreenPriv
);
242 if (!sisc
->backend_funcs
.enable(pScreen
))
245 if ((sisc
->reg_base
== NULL
) && !SiSMapReg(pScreenPriv
->screen
->card
,
249 SiSDPMS(pScreen
, KD_DPMS_NORMAL
);
255 SiSDisable(ScreenPtr pScreen
)
257 KdScreenPriv(pScreen
);
258 SiSCardInfo(pScreenPriv
);
260 SiSUnmapReg(pScreenPriv
->card
, sisc
);
262 sisc
->backend_funcs
.disable(pScreen
);
266 SiSGetColors(ScreenPtr pScreen
, int fb
, int n
, xColorItem
*pdefs
)
268 KdScreenPriv(pScreen
);
269 SiSCardInfo(pScreenPriv
);
271 sisc
->backend_funcs
.getColors(pScreen
, fb
, n
, pdefs
);
275 SiSPutColors(ScreenPtr pScreen
, int fb
, int n
, xColorItem
*pdefs
)
277 KdScreenPriv(pScreen
);
278 SiSCardInfo(pScreenPriv
);
280 sisc
->backend_funcs
.putColors(pScreen
, fb
, n
, pdefs
);
283 KdCardFuncs SiSFuncs
= {
284 SiSCardInit
, /* cardinit */
285 SiSScreenInit
, /* scrinit */
286 SiSInitScreen
, /* initScreen */
287 SiSFinishInitScreen
, /* finishInitScreen */
288 SiSCreateResources
, /* createRes */
289 SiSPreserve
, /* preserve */
290 SiSEnable
, /* enable */
292 SiSDisable
, /* disable */
293 SiSRestore
, /* restore */
294 SiSScreenFini
, /* scrfini */
295 SiSCardFini
, /* cardfini */
298 0, /* enableCursor */
299 0, /* disableCursor */
301 0, /* recolorCursor */
303 SiSDrawInit
, /* initAccel */
304 SiSDrawEnable
, /* enableAccel */
305 SiSDrawSync
, /* syncAccel */
306 SiSDrawDisable
, /* disableAccel */
307 SiSDrawFini
, /* finiAccel */
309 SiSGetColors
, /* getColors */
310 SiSPutColors
, /* putColors */