2 /* $XdotOrg: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_shadow.c,v 1.3 2004/06/17 13:20:14 twini Exp $ */
4 * Copyright (C) 1999-2004 by The XFree86 Project, Inc.
5 * based on code written by Mark Vojkovich
7 * Licensed under the following terms:
9 * Permission to use, copy, modify, distribute, and sell this software and its
10 * documentation for any purpose is hereby granted without fee, provided that
11 * the above copyright notice appears in all copies and that both that copyright
12 * notice and this permission notice appear in supporting documentation, and
13 * and that the name of the copyright holder not be used in advertising
14 * or publicity pertaining to distribution of the software without specific,
15 * written prior permission. The copyright holder makes no representations
16 * about the suitability of this software for any purpose. It is provided
17 * "as is" without expressed or implied warranty.
19 * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
20 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
21 * EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
22 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
23 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
24 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25 * PERFORMANCE OF THIS SOFTWARE.
27 * TW: This module doesn't use CurrentLayout, because it is never
28 * active when DGA is active and vice versa.
32 #include "xf86_OSproc.h"
33 #include "xf86Resources.h"
34 #include "xf86_ansic.h"
35 #include "xf86PciInfo.h"
40 #include "sis_shadow.h"
43 SISPointerMoved(int index
, int x
, int y
)
45 ScrnInfoPtr pScrn
= xf86Screens
[index
];
46 SISPtr pSiS
= SISPTR(pScrn
);
48 if(pSiS
->Rotate
== 1) {
49 (*pSiS
->PointerMoved
)(index
, pScrn
->pScreen
->height
- y
- 1, x
);
51 (*pSiS
->PointerMoved
)(index
, y
, pScrn
->pScreen
->width
- x
- 1);
56 SISRefreshArea(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
)
58 SISPtr pSiS
= SISPTR(pScrn
);
59 int width
, height
, Bpp
, FBPitch
;
62 Bpp
= pScrn
->bitsPerPixel
>> 3;
63 FBPitch
= BitmapBytePad(pScrn
->displayWidth
* pScrn
->bitsPerPixel
);
66 width
= (pbox
->x2
- pbox
->x1
) * Bpp
;
67 height
= pbox
->y2
- pbox
->y1
;
68 src
= pSiS
->ShadowPtr
+ (pbox
->y1
* pSiS
->ShadowPitch
) + (pbox
->x1
* Bpp
);
69 dst
= pSiS
->FbBase
+ (pbox
->y1
* FBPitch
) + (pbox
->x1
* Bpp
);
72 memcpy(dst
, src
, width
);
74 src
+= pSiS
->ShadowPitch
;
82 SISRefreshArea8(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
)
84 SISPtr pSiS
= SISPTR(pScrn
);
85 int count
, width
, height
, y1
, y2
, dstPitch
, srcPitch
;
86 CARD8
*dstPtr
, *srcPtr
, *src
;
89 dstPitch
= pScrn
->displayWidth
;
90 srcPitch
= -pSiS
->Rotate
* pSiS
->ShadowPitch
;
93 width
= pbox
->x2
- pbox
->x1
;
95 y2
= (pbox
->y2
+ 3) & ~3;
96 height
= (y2
- y1
) >> 2; /* in dwords */
98 if(pSiS
->Rotate
== 1) {
99 dstPtr
= pSiS
->FbBase
+ (pbox
->x1
* dstPitch
) + pScrn
->virtualX
- y2
;
100 srcPtr
= pSiS
->ShadowPtr
+ ((1 - y2
) * srcPitch
) + pbox
->x1
;
102 dstPtr
= pSiS
->FbBase
+ ((pScrn
->virtualY
- pbox
->x2
) * dstPitch
) + y1
;
103 srcPtr
= pSiS
->ShadowPtr
+ (y1
* srcPitch
) + pbox
->x2
- 1;
108 dst
= (CARD32
*)dstPtr
;
112 (src
[srcPitch
] << 8) |
113 (src
[srcPitch
* 2] << 16) |
114 (src
[srcPitch
* 3] << 24);
115 src
+= (srcPitch
* 4);
117 srcPtr
+= pSiS
->Rotate
;
126 SISRefreshArea16(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
)
128 SISPtr pSiS
= SISPTR(pScrn
);
129 int count
, width
, height
, y1
, y2
, dstPitch
, srcPitch
;
130 CARD16
*dstPtr
, *srcPtr
, *src
;
133 dstPitch
= pScrn
->displayWidth
;
134 srcPitch
= -pSiS
->Rotate
* pSiS
->ShadowPitch
>> 1;
137 width
= pbox
->x2
- pbox
->x1
;
139 y2
= (pbox
->y2
+ 1) & ~1;
140 height
= (y2
- y1
) >> 1; /* in dwords */
142 if(pSiS
->Rotate
== 1) {
143 dstPtr
= (CARD16
*)pSiS
->FbBase
+ (pbox
->x1
* dstPitch
) + pScrn
->virtualX
- y2
;
144 srcPtr
= (CARD16
*)pSiS
->ShadowPtr
+ ((1 - y2
) * srcPitch
) + pbox
->x1
;
146 dstPtr
= (CARD16
*)pSiS
->FbBase
+ ((pScrn
->virtualY
- pbox
->x2
) * dstPitch
) + y1
;
147 srcPtr
= (CARD16
*)pSiS
->ShadowPtr
+ (y1
* srcPitch
) + pbox
->x2
- 1;
152 dst
= (CARD32
*)dstPtr
;
155 *(dst
++) = src
[0] | (src
[srcPitch
] << 16);
156 src
+= (srcPitch
* 2);
158 srcPtr
+= pSiS
->Rotate
;
166 /* this one could be faster */
168 SISRefreshArea24(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
)
170 SISPtr pSiS
= SISPTR(pScrn
);
171 int count
, width
, height
, y1
, y2
, dstPitch
, srcPitch
;
172 CARD8
*dstPtr
, *srcPtr
, *src
;
175 dstPitch
= BitmapBytePad(pScrn
->displayWidth
* 24);
176 srcPitch
= -pSiS
->Rotate
* pSiS
->ShadowPitch
;
179 width
= pbox
->x2
- pbox
->x1
;
181 y2
= (pbox
->y2
+ 3) & ~3;
182 height
= (y2
- y1
) >> 2; /* blocks of 3 dwords */
184 if(pSiS
->Rotate
== 1) {
185 dstPtr
= pSiS
->FbBase
+ (pbox
->x1
* dstPitch
) + ((pScrn
->virtualX
- y2
) * 3);
186 srcPtr
= pSiS
->ShadowPtr
+ ((1 - y2
) * srcPitch
) + (pbox
->x1
* 3);
188 dstPtr
= pSiS
->FbBase
+ ((pScrn
->virtualY
- pbox
->x2
) * dstPitch
) + (y1
* 3);
189 srcPtr
= pSiS
->ShadowPtr
+ (y1
* srcPitch
) + (pbox
->x2
* 3) - 3;
194 dst
= (CARD32
*)dstPtr
;
200 (src
[srcPitch
] << 24);
201 dst
[1] = src
[srcPitch
+ 1] |
202 (src
[srcPitch
+ 2] << 8) |
203 (src
[srcPitch
* 2] << 16) |
204 (src
[(srcPitch
* 2) + 1] << 24);
205 dst
[2] = src
[(srcPitch
* 2) + 2] |
206 (src
[srcPitch
* 3] << 8) |
207 (src
[(srcPitch
* 3) + 1] << 16) |
208 (src
[(srcPitch
* 3) + 2] << 24);
210 src
+= (srcPitch
<< 2);
212 srcPtr
+= pSiS
->Rotate
* 3;
221 SISRefreshArea32(ScrnInfoPtr pScrn
, int num
, BoxPtr pbox
)
223 SISPtr pSiS
= SISPTR(pScrn
);
224 int count
, width
, height
, dstPitch
, srcPitch
;
225 CARD32
*dstPtr
, *srcPtr
, *src
, *dst
;
227 dstPitch
= pScrn
->displayWidth
;
228 srcPitch
= -pSiS
->Rotate
* pSiS
->ShadowPitch
>> 2;
231 width
= pbox
->x2
- pbox
->x1
;
232 height
= pbox
->y2
- pbox
->y1
;
234 if(pSiS
->Rotate
== 1) {
235 dstPtr
= (CARD32
*)pSiS
->FbBase
+ (pbox
->x1
* dstPitch
) + pScrn
->virtualX
- pbox
->y2
;
236 srcPtr
= (CARD32
*)pSiS
->ShadowPtr
+ ((1 - pbox
->y2
) * srcPitch
) + pbox
->x1
;
238 dstPtr
= (CARD32
*)pSiS
->FbBase
+ ((pScrn
->virtualY
- pbox
->x2
) * dstPitch
) + pbox
->y1
;
239 srcPtr
= (CARD32
*)pSiS
->ShadowPtr
+ (pbox
->y1
* srcPitch
) + pbox
->x2
- 1;
250 srcPtr
+= pSiS
->Rotate
;