2 #include <kdrive-config.h>
9 #define PARTPROD(a,b,c) (((a)<<6) | ((b)<<3) | (c))
11 char bppand
[4] = { 0x03, /* 8bpp */
16 int partprodPermedia
[] = {
18 PARTPROD(0,0,1), PARTPROD(0,1,1), PARTPROD(1,1,1), PARTPROD(1,1,2),
19 PARTPROD(1,2,2), PARTPROD(2,2,2), PARTPROD(1,2,3), PARTPROD(2,2,3),
20 PARTPROD(1,3,3), PARTPROD(2,3,3), PARTPROD(1,2,4), PARTPROD(3,3,3),
21 PARTPROD(1,3,4), PARTPROD(2,3,4), -1, PARTPROD(3,3,4),
22 PARTPROD(1,4,4), PARTPROD(2,4,4), -1, PARTPROD(3,4,4),
23 -1, PARTPROD(2,3,5), -1, PARTPROD(4,4,4),
24 PARTPROD(1,4,5), PARTPROD(2,4,5), PARTPROD(3,4,5), -1,
25 -1, -1, -1, PARTPROD(4,4,5),
26 PARTPROD(1,5,5), PARTPROD(2,5,5), -1, PARTPROD(3,5,5),
27 -1, -1, -1, PARTPROD(4,5,5),
28 -1, -1, -1, PARTPROD(3,4,6),
29 -1, -1, -1, PARTPROD(5,5,5),
30 PARTPROD(1,5,6), PARTPROD(2,5,6), -1, PARTPROD(3,5,6),
31 -1, -1, -1, PARTPROD(4,5,6),
33 -1, -1, -1, PARTPROD(5,5,6),
53 pmMapReg(KdCardInfo
*card
, PM2CardInfo
*pm2c
)
55 pm2c
->reg_base
= (CARD8
*)KdMapDevice(PM2_REG_BASE(card
),
58 if (pm2c
->reg_base
== NULL
)
61 KdSetMappedMode(PM2_REG_BASE(card
), PM2_REG_SIZE(card
),
62 KD_MAPPED_MODE_REGISTERS
);
68 pmUnmapReg(KdCardInfo
*card
, PM2CardInfo
*pm2c
)
71 KdResetMappedMode(PM2_REG_BASE(card
), PM2_REG_SIZE(card
),
72 KD_MAPPED_MODE_REGISTERS
);
73 KdUnmapDevice((void *)pm2c
->reg_base
, PM2_REG_SIZE(card
));
79 pmCardInit (KdCardInfo
*card
)
83 pm2c
= (PM2CardInfo
*) xalloc (sizeof (PM2CardInfo
));
86 memset (pm2c
, '\0', sizeof (PM2CardInfo
));
88 (void) pmMapReg (card
, pm2c
);
90 if (!vesaInitialize (card
, &pm2c
->vesa
))
96 pm2c
->InFifoSpace
= 0;
104 pmCardFini (KdCardInfo
*card
)
106 PM2CardInfo
*pm2c
= (PM2CardInfo
*) card
->driver
;
108 pmUnmapReg (card
, pm2c
);
113 pmScreenInit (KdScreenInfo
*screen
)
115 PM2CardInfo
*pm2c
= screen
->card
->driver
;
117 int screen_size
, memory
;
119 pm2s
= (PM2ScreenInfo
*) xalloc (sizeof (PM2ScreenInfo
));
122 memset (pm2s
, '\0', sizeof (PM2ScreenInfo
));
124 if (!vesaScreenInitialize (screen
, &pm2s
->vesa
))
130 pm2c
->pprod
= partprodPermedia
[screen
->width
>> 5];
131 pm2c
->bppalign
= bppand
[(screen
->fb
[0].bitsPerPixel
>>3)-1];
133 pm2s
->screen
= pm2s
->vesa
.fb
;
134 memory
= pm2s
->vesa
.fb_size
;
136 screen_size
= screen
->fb
[0].byteStride
* screen
->height
;
138 if (pm2s
->screen
&& memory
>= screen_size
+ 2048)
141 pm2s
->cursor_base
= pm2s
->screen
+ memory
- 2048;
144 pm2s
->cursor_base
= 0;
145 memory
-= screen_size
;
146 if (memory
> screen
->fb
[0].byteStride
)
148 pm2s
->off_screen
= pm2s
->screen
+ screen_size
;
149 pm2s
->off_screen_size
= memory
;
153 pm2s
->off_screen
= 0;
154 pm2s
->off_screen_size
= 0;
157 switch (screen
->fb
[0].bitsPerPixel
) {
172 screen
->driver
= pm2s
;
178 pmScreenFini (KdScreenInfo
*screen
)
180 PM2ScreenInfo
*pm2s
= (PM2ScreenInfo
*) screen
->driver
;
182 vesaScreenFini (screen
);
188 pmInitScreen (ScreenPtr pScreen
)
190 return vesaInitScreen (pScreen
);
195 pmRandRSetConfig (ScreenPtr pScreen
,
198 RRScreenSizePtr pSize
)
200 kaaWaitSync (pScreen
);
202 if (!vesaRandRSetConfig (pScreen
, rotation
, rate
, pSize
))
209 pmRandRInit (ScreenPtr pScreen
)
213 pScrPriv
->rrSetConfig
= pmRandRSetConfig
;
218 pmFinishInitScreen (ScreenPtr pScreen
)
221 ret
= vesaFinishInitScreen (pScreen
);
223 pmRandRInit (pScreen
);
229 pmPreserve(KdCardInfo
*card
)
235 pmRestore(KdCardInfo
*card
)
241 pmEnable (ScreenPtr pScreen
)
243 if (!vesaEnable (pScreen
))
247 KdXVEnable (pScreen
);
254 pmDisable(ScreenPtr pScreen
)
257 KdXVDisable (pScreen
);
259 vesaDisable (pScreen
);
263 pmDPMS(ScreenPtr pScreen
, int mode
)
265 return vesaDPMS (pScreen
, mode
);
268 KdCardFuncs PM2Funcs
= {
269 pmCardInit
, /* cardinit */
270 pmScreenInit
, /* scrinit */
271 pmInitScreen
, /* initScreen */
272 pmFinishInitScreen
, /* finishInitScreen */
273 vesaCreateResources
, /* createRes */
274 pmPreserve
, /* preserve */
275 pmEnable
, /* enable */
277 pmDisable
, /* disable */
278 pmRestore
, /* restore */
279 pmScreenFini
, /* scrfini */
280 pmCardFini
, /* cardfini */
283 0, /* enableCursor */
284 0, /* disableCursor */
286 NULL
, /* recolorCursor */
288 pmDrawInit
, /* initAccel */
289 pmDrawEnable
, /* enableAccel */
290 pmDrawDisable
, /* disableAccel */
291 pmDrawFini
, /* finiAccel */
293 vesaGetColors
, /* getColors */
294 vesaPutColors
, /* putColors */