2 * Copyright (C) 1999-2004 by The XFree86 Project, Inc.
3 * based on code written by Mark Vojkovich
4 * Copyright (C) 2003-2005 Thomas Winischhofer
6 * Licensed under the following terms:
8 * Permission to use, copy, modify, distribute, and sell this software and its
9 * documentation for any purpose is hereby granted without fee, provided that
10 * the above copyright notice appears in all copies and that both that copyright
11 * notice and this permission notice appear in supporting documentation, and
12 * and that the name of the copyright holder not be used in advertising
13 * or publicity pertaining to distribution of the software without specific,
14 * written prior permission. The copyright holder makes no representations
15 * about the suitability of this software for any purpose. It is provided
16 * "as is" without expressed or implied warranty.
18 * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
19 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
20 * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
21 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
22 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
23 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24 * PERFORMANCE OF THIS SOFTWARE.
26 * This module doesn't use CurrentLayout, because it is never
27 * active when DGA is active and vice versa.
37 void SISPointerMoved(SCRN_ARG_TYPE arg
, int x
, int y
);
38 void SISPointerMovedReflect(SCRN_ARG_TYPE arg
, int x
, int y
);
39 void SISRefreshArea(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
);
40 void SISRefreshAreaReflect(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
);
41 void SISRefreshArea8(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
);
42 void SISRefreshArea16(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
);
43 void SISRefreshArea24(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
);
44 void SISRefreshArea32(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
);
47 SISPointerMoved(SCRN_ARG_TYPE arg
, int x
, int y
)
50 SISPtr pSiS
= SISPTR(pScrn
);
52 if(pSiS
->Rotate
== 1) {
53 (*pSiS
->PointerMoved
)(arg
, pScrn
->pScreen
->height
- y
- 1, x
);
55 (*pSiS
->PointerMoved
)(arg
, y
, pScrn
->pScreen
->width
- x
- 1);
60 SISPointerMovedReflect(SCRN_ARG_TYPE arg
, int x
, int y
)
63 SISPtr pSiS
= SISPTR(pScrn
);
65 switch(pSiS
->Reflect
) {
67 (*pSiS
->PointerMoved
)(arg
, pScrn
->pScreen
->width
- x
- 1, y
);
70 (*pSiS
->PointerMoved
)(arg
, x
, pScrn
->pScreen
->height
- y
- 1);
73 (*pSiS
->PointerMoved
)(arg
, pScrn
->pScreen
->width
- x
- 1, pScrn
->pScreen
->height
- y
- 1);
77 /* Refresh area (unreflected, unrotated) */
80 SISRefreshArea(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
)
82 SISPtr pSiS
= SISPTR(pScrn
);
83 int width
, height
, Bpp
, FBPitch
;
86 Bpp
= pScrn
->bitsPerPixel
>> 3;
87 FBPitch
= BitmapBytePad(pScrn
->displayWidth
* pScrn
->bitsPerPixel
);
91 width
= (pbox
->x2
- pbox
->x1
) * Bpp
;
92 height
= pbox
->y2
- pbox
->y1
;
93 src
= pSiS
->ShadowPtr
+ (pbox
->y1
* pSiS
->ShadowPitch
) + (pbox
->x1
* Bpp
);
94 dst
= pSiS
->FbBase
+ (pbox
->y1
* FBPitch
) + (pbox
->x1
* Bpp
);
97 SiSMemCopyToVideoRam(pSiS
, dst
, src
, width
);
99 src
+= pSiS
->ShadowPitch
;
106 /* RefreshArea for reflection */
109 SISRefreshAreaReflect(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
)
111 SISPtr pSiS
= SISPTR(pScrn
);
112 int width
, height
, Bpp
, FBPitch
, twidth
;
113 CARD8
*src
, *dst
, *tdst
, *tsrc
;
114 CARD16
*tdst16
, *tsrc16
;
115 CARD32
*tdst32
, *tsrc32
;
117 Bpp
= pScrn
->bitsPerPixel
>> 3;
118 FBPitch
= BitmapBytePad(pScrn
->displayWidth
* pScrn
->bitsPerPixel
);
121 width
= (pbox
->x2
- pbox
->x1
) * Bpp
;
122 height
= pbox
->y2
- pbox
->y1
;
123 src
= pSiS
->ShadowPtr
+ (pbox
->y1
* pSiS
->ShadowPitch
) + (pbox
->x1
* Bpp
);
125 switch(pSiS
->Reflect
) {
127 dst
+= (pbox
->y1
* FBPitch
) + ((pScrn
->displayWidth
- pbox
->x1
- 1) * Bpp
);
134 while(twidth
--) *tdst
-- = *tsrc
++;
136 src
+= pSiS
->ShadowPitch
;
142 tdst16
= (CARD16
*)dst
;
143 tsrc16
= (CARD16
*)src
;
145 while(twidth
--) *tdst16
-- = *tsrc16
++;
147 src
+= pSiS
->ShadowPitch
;
153 tdst32
= (CARD32
*)dst
;
154 tsrc32
= (CARD32
*)src
;
156 while(twidth
--) *tdst32
-- = *tsrc32
++;
158 src
+= pSiS
->ShadowPitch
;
163 dst
+= ((pScrn
->virtualY
- pbox
->y1
- 1) * FBPitch
) + (pbox
->x1
* Bpp
);
165 SiSMemCopyToVideoRam(pSiS
, dst
, src
, width
);
167 src
+= pSiS
->ShadowPitch
;
171 dst
+= ((pScrn
->virtualY
- pbox
->y1
- 1) * FBPitch
) + ((pScrn
->displayWidth
- pbox
->x1
- 1) * Bpp
);
178 while(twidth
--) *tdst
-- = *tsrc
++;
180 src
+= pSiS
->ShadowPitch
;
186 tdst16
= (CARD16
*)dst
;
187 tsrc16
= (CARD16
*)src
;
189 while(twidth
--) *tdst16
-- = *tsrc16
++;
191 src
+= pSiS
->ShadowPitch
;
197 tdst32
= (CARD32
*)dst
;
198 tsrc32
= (CARD32
*)src
;
200 while(twidth
--) *tdst32
-- = *tsrc32
++;
202 src
+= pSiS
->ShadowPitch
;
211 /* RefreshArea()s for rotation */
214 SISRefreshArea8(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
)
216 SISPtr pSiS
= SISPTR(pScrn
);
217 int count
, width
, height
, y1
, y2
, dstPitch
, srcPitch
;
218 CARD8
*dstPtr
, *srcPtr
, *src
;
221 dstPitch
= pScrn
->displayWidth
;
222 srcPitch
= -pSiS
->Rotate
* pSiS
->ShadowPitch
;
225 width
= pbox
->x2
- pbox
->x1
;
227 y2
= (pbox
->y2
+ 3) & ~3;
228 height
= (y2
- y1
) >> 2; /* in dwords */
230 if(pSiS
->Rotate
== 1) {
231 dstPtr
= pSiS
->FbBase
+ (pbox
->x1
* dstPitch
) + pScrn
->virtualX
- y2
;
232 srcPtr
= pSiS
->ShadowPtr
+ ((1 - y2
) * srcPitch
) + pbox
->x1
;
234 dstPtr
= pSiS
->FbBase
+ ((pScrn
->virtualY
- pbox
->x2
) * dstPitch
) + y1
;
235 srcPtr
= pSiS
->ShadowPtr
+ (y1
* srcPitch
) + pbox
->x2
- 1;
240 dst
= (CARD32
*)dstPtr
;
244 (src
[srcPitch
] << 8) |
245 (src
[srcPitch
* 2] << 16) |
246 (src
[srcPitch
* 3] << 24);
247 src
+= (srcPitch
* 4);
249 srcPtr
+= pSiS
->Rotate
;
258 SISRefreshArea16(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
)
260 SISPtr pSiS
= SISPTR(pScrn
);
261 int count
, width
, height
, y1
, y2
, dstPitch
, srcPitch
;
262 CARD16
*dstPtr
, *srcPtr
, *src
;
265 dstPitch
= pScrn
->displayWidth
;
266 srcPitch
= -pSiS
->Rotate
* pSiS
->ShadowPitch
>> 1;
269 width
= pbox
->x2
- pbox
->x1
;
271 y2
= (pbox
->y2
+ 1) & ~1;
272 height
= (y2
- y1
) >> 1; /* in dwords */
274 if(pSiS
->Rotate
== 1) {
275 dstPtr
= (CARD16
*)pSiS
->FbBase
+ (pbox
->x1
* dstPitch
) + pScrn
->virtualX
- y2
;
276 srcPtr
= (CARD16
*)pSiS
->ShadowPtr
+ ((1 - y2
) * srcPitch
) + pbox
->x1
;
278 dstPtr
= (CARD16
*)pSiS
->FbBase
+ ((pScrn
->virtualY
- pbox
->x2
) * dstPitch
) + y1
;
279 srcPtr
= (CARD16
*)pSiS
->ShadowPtr
+ (y1
* srcPitch
) + pbox
->x2
- 1;
284 dst
= (CARD32
*)dstPtr
;
287 *(dst
++) = src
[0] | (src
[srcPitch
] << 16);
288 src
+= (srcPitch
* 2);
290 srcPtr
+= pSiS
->Rotate
;
298 /* this one could be faster */
300 SISRefreshArea24(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
)
302 SISPtr pSiS
= SISPTR(pScrn
);
303 int count
, width
, height
, y1
, y2
, dstPitch
, srcPitch
;
304 CARD8
*dstPtr
, *srcPtr
, *src
;
307 dstPitch
= BitmapBytePad(pScrn
->displayWidth
* 24);
308 srcPitch
= -pSiS
->Rotate
* pSiS
->ShadowPitch
;
311 width
= pbox
->x2
- pbox
->x1
;
313 y2
= (pbox
->y2
+ 3) & ~3;
314 height
= (y2
- y1
) >> 2; /* blocks of 3 dwords */
316 if(pSiS
->Rotate
== 1) {
317 dstPtr
= pSiS
->FbBase
+ (pbox
->x1
* dstPitch
) + ((pScrn
->virtualX
- y2
) * 3);
318 srcPtr
= pSiS
->ShadowPtr
+ ((1 - y2
) * srcPitch
) + (pbox
->x1
* 3);
320 dstPtr
= pSiS
->FbBase
+ ((pScrn
->virtualY
- pbox
->x2
) * dstPitch
) + (y1
* 3);
321 srcPtr
= pSiS
->ShadowPtr
+ (y1
* srcPitch
) + (pbox
->x2
* 3) - 3;
326 dst
= (CARD32
*)dstPtr
;
332 (src
[srcPitch
] << 24);
333 dst
[1] = src
[srcPitch
+ 1] |
334 (src
[srcPitch
+ 2] << 8) |
335 (src
[srcPitch
* 2] << 16) |
336 (src
[(srcPitch
* 2) + 1] << 24);
337 dst
[2] = src
[(srcPitch
* 2) + 2] |
338 (src
[srcPitch
* 3] << 8) |
339 (src
[(srcPitch
* 3) + 1] << 16) |
340 (src
[(srcPitch
* 3) + 2] << 24);
342 src
+= (srcPitch
<< 2);
344 srcPtr
+= pSiS
->Rotate
* 3;
353 SISRefreshArea32(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
)
355 SISPtr pSiS
= SISPTR(pScrn
);
356 int count
, width
, height
, dstPitch
, srcPitch
;
357 CARD32
*dstPtr
, *srcPtr
, *src
, *dst
;
359 dstPitch
= pScrn
->displayWidth
;
360 srcPitch
= -pSiS
->Rotate
* pSiS
->ShadowPitch
>> 2;
363 width
= pbox
->x2
- pbox
->x1
;
364 height
= pbox
->y2
- pbox
->y1
;
366 if(pSiS
->Rotate
== 1) {
367 dstPtr
= (CARD32
*)pSiS
->FbBase
+ (pbox
->x1
* dstPitch
) + pScrn
->virtualX
- pbox
->y2
;
368 srcPtr
= (CARD32
*)pSiS
->ShadowPtr
+ ((1 - pbox
->y2
) * srcPitch
) + pbox
->x1
;
370 dstPtr
= (CARD32
*)pSiS
->FbBase
+ ((pScrn
->virtualY
- pbox
->x2
) * dstPitch
) + pbox
->y1
;
371 srcPtr
= (CARD32
*)pSiS
->ShadowPtr
+ (pbox
->y1
* srcPitch
) + pbox
->x2
- 1;
382 srcPtr
+= pSiS
->Rotate
;