1 2#ifdef HAVE_CONFIG_H 3#include "config.h" 4#endif 5 6#include "xf86.h" 7#include "xf86_OSproc.h" 8#include "xf86Pci.h" 9#include "shadowfb.h" 10#include "servermd.h" 11#include "ct_driver.h" 12 13void 14chipsRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 15{ 16 CHIPSPtr cPtr = CHIPSPTR(pScrn); 17 int width, height, Bpp, FBPitch; 18 unsigned char *src, *dst; 19 20 Bpp = pScrn->bitsPerPixel >> 3; 21 FBPitch = BitmapBytePad(pScrn->displayWidth * pScrn->bitsPerPixel); 22 23 while(num--) { 24 width = (pbox->x2 - pbox->x1) * Bpp; 25 height = pbox->y2 - pbox->y1; 26 src = cPtr->ShadowPtr + (pbox->y1 * cPtr->ShadowPitch) + 27 (pbox->x1 * Bpp); 28 dst = cPtr->FbBase + (pbox->y1 * FBPitch) + (pbox->x1 * Bpp); 29 30 while(height--) { 31 memcpy(dst, src, width); 32 dst += FBPitch; 33 src += cPtr->ShadowPitch; 34 } 35 36 pbox++; 37 } 38} 39 40void 41chipsPointerMoved(SCRN_ARG_TYPE arg, int x, int y) 42{ 43 SCRN_INFO_PTR(arg); 44 CHIPSPtr cPtr = CHIPSPTR(pScrn); 45 int newX, newY; 46 47 if(cPtr->Rotate == 1) { 48 newX = pScrn->pScreen->height - y - 1; 49 newY = x; 50 } else { 51 newX = y; 52 newY = pScrn->pScreen->width - x - 1; 53 } 54 55 (*cPtr->PointerMoved)(arg, newX, newY); 56} 57 58void 59chipsRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 60{ 61 CHIPSPtr cPtr = CHIPSPTR(pScrn); 62 int count, width, height, y1, y2, dstPitch, srcPitch; 63 CARD8 *dstPtr, *srcPtr, *src; 64 CARD32 *dst; 65 66 dstPitch = pScrn->displayWidth; 67 srcPitch = -cPtr->Rotate * cPtr->ShadowPitch; 68 69 while(num--) { 70 width = pbox->x2 - pbox->x1; 71 y1 = pbox->y1 & ~3; 72 y2 = (pbox->y2 + 3) & ~3; 73 height = (y2 - y1) >> 2; /* in dwords */ 74 75 if(cPtr->Rotate == 1) { 76 dstPtr = cPtr->FbBase + 77 (pbox->x1 * dstPitch) + pScrn->virtualX - y2; 78 srcPtr = cPtr->ShadowPtr + ((1 - y2) * srcPitch) + pbox->x1; 79 } else { 80 dstPtr = cPtr->FbBase + 81 ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; 82 srcPtr = cPtr->ShadowPtr + (y1 * srcPitch) + pbox->x2 - 1; 83 } 84 85 while(width--) { 86 src = srcPtr; 87 dst = (CARD32*)dstPtr; 88 count = height; 89 while(count--) { 90 *(dst++) = src[0] | (src[srcPitch] << 8) | 91 (src[srcPitch * 2] << 16) | 92 (src[srcPitch * 3] << 24); 93 src += srcPitch * 4; 94 } 95 srcPtr += cPtr->Rotate; 96 dstPtr += dstPitch; 97 } 98 99 pbox++; 100 } 101} 102 103 104void 105chipsRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 106{ 107 CHIPSPtr cPtr = CHIPSPTR(pScrn); 108 int count, width, height, y1, y2, dstPitch, srcPitch; 109 CARD16 *dstPtr, *srcPtr, *src; 110 CARD32 *dst; 111 112 dstPitch = pScrn->displayWidth; 113 srcPitch = -cPtr->Rotate * cPtr->ShadowPitch >> 1; 114 115 while(num--) { 116 width = pbox->x2 - pbox->x1; 117 y1 = pbox->y1 & ~1; 118 y2 = (pbox->y2 + 1) & ~1; 119 height = (y2 - y1) >> 1; /* in dwords */ 120 121 if(cPtr->Rotate == 1) { 122 dstPtr = (CARD16*)cPtr->FbBase + 123 (pbox->x1 * dstPitch) + pScrn->virtualX - y2; 124 srcPtr = (CARD16*)cPtr->ShadowPtr + 125 ((1 - y2) * srcPitch) + pbox->x1; 126 } else { 127 dstPtr = (CARD16*)cPtr->FbBase + 128 ((pScrn->virtualY - pbox->x2) * dstPitch) + y1; 129 srcPtr = (CARD16*)cPtr->ShadowPtr + 130 (y1 * srcPitch) + pbox->x2 - 1; 131/* ErrorF("dst: %x base: %x\n",dstPtr,cPtr->FbBase);*/ 132 } 133 134 while(width--) { 135 src = srcPtr; 136 dst = (CARD32*)dstPtr; 137 count = height; 138 while(count--) { 139 *(dst++) = src[0] | (src[srcPitch] << 16); 140 src += srcPitch * 2; 141 } 142 srcPtr += cPtr->Rotate; 143 dstPtr += dstPitch; 144 } 145 146 pbox++; 147 } 148} 149 150 151/* this one could be faster */ 152void 153chipsRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 154{ 155 CHIPSPtr cPtr = CHIPSPTR(pScrn); 156 int count, width, height, y1, y2, dstPitch, srcPitch; 157 CARD8 *dstPtr, *srcPtr, *src; 158 CARD32 *dst; 159 160 dstPitch = BitmapBytePad(pScrn->displayWidth * 24); 161 srcPitch = -cPtr->Rotate * cPtr->ShadowPitch; 162 163 while(num--) { 164 width = pbox->x2 - pbox->x1; 165 y1 = pbox->y1 & ~3; 166 y2 = (pbox->y2 + 3) & ~3; 167 height = (y2 - y1) >> 2; /* blocks of 3 dwords */ 168 169 if(cPtr->Rotate == 1) { 170 dstPtr = cPtr->FbBase + 171 (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3); 172 srcPtr = cPtr->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3); 173 } else { 174 dstPtr = cPtr->FbBase + 175 ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3); 176 srcPtr = cPtr->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3; 177 } 178 179 while(width--) { 180 src = srcPtr; 181 dst = (CARD32*)dstPtr; 182 count = height; 183 while(count--) { 184 dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) | 185 (src[srcPitch] << 24); 186 dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) | 187 (src[srcPitch * 2] << 16) | 188 (src[(srcPitch * 2) + 1] << 24); 189 dst[2] = src[(srcPitch * 2) + 2] | (src[srcPitch * 3] << 8) | 190 (src[(srcPitch * 3) + 1] << 16) | 191 (src[(srcPitch * 3) + 2] << 24); 192 dst += 3; 193 src += srcPitch * 4; 194 } 195 srcPtr += cPtr->Rotate * 3; 196 dstPtr += dstPitch; 197 } 198 199 pbox++; 200 } 201} 202 203void 204chipsRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox) 205{ 206 CHIPSPtr cPtr = CHIPSPTR(pScrn); 207 int count, width, height, dstPitch, srcPitch; 208 CARD32 *dstPtr, *srcPtr, *src, *dst; 209 210 dstPitch = pScrn->displayWidth; 211 srcPitch = -cPtr->Rotate * cPtr->ShadowPitch >> 2; 212 213 while(num--) { 214 width = pbox->x2 - pbox->x1; 215 height = pbox->y2 - pbox->y1; 216 217 if(cPtr->Rotate == 1) { 218 dstPtr = (CARD32*)cPtr->FbBase + 219 (pbox->x1 * dstPitch) + pScrn->virtualX - pbox->y2; 220 srcPtr = (CARD32*)cPtr->ShadowPtr + 221 ((1 - pbox->y2) * srcPitch) + pbox->x1; 222 } else { 223 dstPtr = (CARD32*)cPtr->FbBase + 224 ((pScrn->virtualY - pbox->x2) * dstPitch) + pbox->y1; 225 srcPtr = (CARD32*)cPtr->ShadowPtr + 226 (pbox->y1 * srcPitch) + pbox->x2 - 1; 227 } 228 229 while(width--) { 230 src = srcPtr; 231 dst = dstPtr; 232 count = height; 233 while(count--) { 234 *(dst++) = *src; 235 src += srcPitch; 236 } 237 srcPtr += cPtr->Rotate; 238 dstPtr += dstPitch; 239 } 240 241 pbox++; 242 } 243} 244