00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <stdlib.h>
00017 #include <string.h>
00018
00019 #include <l4/sys/cache.h>
00020
00021
00022 #include "main.h"
00023 #include "l4con.h"
00024 #include "pslim.h"
00025 #include "con_hw/init.h"
00026 #include "con_yuv2rgb/yuv2rgb.h"
00027
00028
00029
00030 struct pslim_offset
00031 {
00032 l4_uint32_t preskip_x;
00033 l4_uint32_t preskip_y;
00034 l4_uint32_t endskip_x;
00035
00036 };
00037
00038 extern l4_offs_t vis_offs;
00039
00040 static inline void _bmap16msb(l4_uint8_t*, l4_uint8_t*, l4_uint32_t,
00041 l4_uint32_t, l4_uint32_t, l4_uint32_t,
00042 struct pslim_offset*, l4_uint32_t);
00043 static inline void _bmap24msb(l4_uint8_t*, l4_uint8_t*, l4_uint32_t,
00044 l4_uint32_t, l4_uint32_t, l4_uint32_t,
00045 struct pslim_offset*, l4_uint32_t);
00046 static inline void _bmap32msb(l4_uint8_t*, l4_uint8_t*, l4_uint32_t,
00047 l4_uint32_t, l4_uint32_t, l4_uint32_t,
00048 struct pslim_offset*, l4_uint32_t);
00049 static inline void _bmap16lsb(l4_uint8_t*, l4_uint8_t*, l4_uint32_t,
00050 l4_uint32_t, l4_uint32_t, l4_uint32_t,
00051 struct pslim_offset*, l4_uint32_t);
00052 static inline void _bmap24lsb(l4_uint8_t*, l4_uint8_t*, l4_uint32_t,
00053 l4_uint32_t, l4_uint32_t, l4_uint32_t,
00054 struct pslim_offset*, l4_uint32_t);
00055 static inline void _bmap32lsb(l4_uint8_t*, l4_uint8_t*, l4_uint32_t,
00056 l4_uint32_t, l4_uint32_t, l4_uint32_t,
00057 struct pslim_offset*, l4_uint32_t);
00058 static inline void _set16(l4_uint8_t*, l4_uint8_t*, l4_uint32_t,
00059 l4_uint32_t, struct pslim_offset*,
00060 l4_uint32_t, l4_uint32_t);
00061 static inline void _set24(l4_uint8_t*, l4_uint8_t*, l4_uint32_t,
00062 l4_uint32_t, struct pslim_offset*,
00063 l4_uint32_t, l4_uint32_t);
00064 static inline void _set32(l4_uint8_t*, l4_uint8_t*, l4_uint32_t,
00065 l4_uint32_t, struct pslim_offset*,
00066 l4_uint32_t, l4_uint32_t);
00067 static inline void _copy16(l4_uint8_t*, l4_int16_t, l4_int16_t, l4_int16_t,
00068 l4_int16_t, l4_uint32_t, l4_uint32_t, l4_uint32_t);
00069 static inline void _copy24(l4_uint8_t*, l4_int16_t, l4_int16_t, l4_int16_t,
00070 l4_int16_t, l4_uint32_t, l4_uint32_t, l4_uint32_t);
00071 static inline void _copy32(l4_uint8_t*, l4_int16_t, l4_int16_t, l4_int16_t,
00072 l4_int16_t, l4_uint32_t, l4_uint32_t, l4_uint32_t);
00073
00074 static inline void _fill16(l4_uint8_t*, l4_uint32_t, l4_uint32_t,
00075 l4_uint32_t, l4_uint32_t);
00076 static inline void _fill24(l4_uint8_t*, l4_uint32_t, l4_uint32_t,
00077 l4_uint32_t, l4_uint32_t);
00078 static inline void _fill32(l4_uint8_t*, l4_uint32_t, l4_uint32_t,
00079 l4_uint32_t, l4_uint32_t);
00080
00081
00082 static inline void sw_bmap(struct l4con_vc*, l4_int16_t, l4_int16_t,
00083 l4_uint32_t, l4_uint32_t,
00084 l4_uint8_t *bmap, l4_uint32_t fgc, l4_uint32_t bgc,
00085 struct pslim_offset*, l4_uint8_t mode);
00086 static inline void sw_set(struct l4con_vc*, l4_int16_t, l4_int16_t,
00087 l4_uint32_t, l4_uint32_t, l4_uint32_t, l4_uint32_t,
00088 l4_uint8_t *pmap, struct pslim_offset*);
00089 static inline void sw_cscs(struct l4con_vc*, l4_int16_t, l4_int16_t,
00090 l4_uint32_t, l4_uint32_t,
00091 l4_uint8_t *y, l4_uint8_t *u, l4_uint8_t *v,
00092 l4_uint32_t scale, struct pslim_offset*,
00093 l4_uint8_t mode);
00094
00095 static inline l4_uint16_t
00096 set_rgb16(l4_uint32_t r, l4_uint32_t g, l4_uint32_t b)
00097 {
00098 return ((b >> 3) + ((g >> 2) << 5) + ((r >> 3) << 11));
00099
00100 }
00101
00102 static inline l4_uint32_t
00103 set_rgb24(l4_uint32_t r, l4_uint32_t g, l4_uint32_t b)
00104 {
00105 return (b + (g << 8) + (r << 16));
00106
00107 }
00108
00109
00110 #define OFFSET(x, y, ptr, bytepp) ptr += (y) * bwidth + (x) * (bytepp);
00111
00112
00113
00114 static inline int
00115 clip_rect(struct l4con_vc *vc, int from_user, l4con_pslim_rect_t *rect)
00116 {
00117 int max_x = vc->xres;
00118 int max_y = vc->yres;
00119
00120 if (from_user)
00121 {
00122 rect->x += vc->client_xofs;
00123 rect->y += vc->client_yofs;
00124 max_x = vc->client_xres;
00125 max_y = vc->client_yres;
00126 }
00127
00128 if ((rect->x > max_x) || (rect->y > max_y))
00129
00130 return 0;
00131 if (rect->x < 0)
00132 {
00133 if (-rect->x >= rect->w)
00134
00135 return 0;
00136
00137 rect->w += rect->x;
00138 rect->x = 0;
00139 }
00140 if (rect->y < 0)
00141 {
00142 if (-rect->y >= rect->h)
00143
00144 return 0;
00145
00146 rect->h += rect->y;
00147 rect->y = 0;
00148 }
00149 if ((rect->x + rect->w) > max_x)
00150
00151 rect->w = max_x - rect->x;
00152 if ((rect->y + rect->h) > max_y)
00153
00154 rect->h = max_y - rect->y;
00155
00156
00157 return 1;
00158 }
00159
00160 static inline int
00161 clip_rect_offset(struct l4con_vc *vc, int from_user,
00162 l4con_pslim_rect_t *rect, struct pslim_offset *offset)
00163 {
00164 int max_x = vc->xres;
00165 int max_y = vc->yres;
00166
00167 if (from_user)
00168 {
00169 rect->x += vc->client_xofs;
00170 rect->y += vc->client_yofs;
00171 max_x = vc->client_xres;
00172 max_y = vc->client_yres;
00173 }
00174
00175 if ((rect->x > max_x) || (rect->y > max_y))
00176
00177 return 0;
00178 if (rect->x < 0)
00179 {
00180 if (-rect->x > rect->w)
00181
00182 return 0;
00183
00184 rect->w += rect->x;
00185 offset->preskip_x = -rect->x;
00186 rect->x = 0;
00187 }
00188 if (rect->y < 0)
00189 {
00190 if (-rect->y > rect->h)
00191
00192 return 0;
00193
00194 rect->h += rect->y;
00195 offset->preskip_y = -rect->y;
00196 rect->y = 0;
00197 }
00198 if ((rect->x + rect->w) > max_x)
00199 {
00200
00201 offset->endskip_x = rect->x + rect->w - max_x;
00202 rect->w = max_x - rect->x;
00203 }
00204 if ((rect->y + rect->h) > max_y)
00205
00206 rect->h = max_y - rect->y;
00207
00208
00209 return 1;
00210 }
00211
00212 static inline int
00213 clip_rect_dxy(struct l4con_vc *vc, int from_user,
00214 l4con_pslim_rect_t *rect, l4_int16_t *dx, l4_int16_t *dy)
00215 {
00216 int max_x = vc->xres;
00217 int max_y = vc->yres;
00218
00219 if (from_user)
00220 {
00221 rect->x += vc->client_xofs;
00222 rect->y += vc->client_yofs;
00223 max_x = vc->client_xres;
00224 max_y = vc->client_yres;
00225 }
00226
00227
00228 if ((rect->x > max_x) || (rect->y > max_y))
00229
00230 return 0;
00231 if (rect->x < 0)
00232 {
00233 if (-rect->x > rect->w)
00234
00235 return 0;
00236
00237 rect->w += rect->x;
00238 *dx -= rect->x;
00239 rect->x = 0;
00240 }
00241 if (rect->y < 0)
00242 {
00243 if (-rect->y > rect->h)
00244
00245 return 0;
00246
00247 rect->h += rect->y;
00248 *dy -= rect->y;
00249 rect->y = 0;
00250 }
00251 if ((rect->x + rect->w) > max_x)
00252
00253 rect->w = max_x - rect->x;
00254 if ((rect->y + rect->h) > max_y)
00255
00256 rect->h = max_y - rect->y;
00257
00258
00259 if ((*dx > max_x) || (*dy > max_y))
00260
00261 return 0;
00262 if (*dx < 0)
00263 {
00264 if (-*dx > rect->w)
00265
00266 return 0;
00267
00268 rect->w += *dx;
00269 rect->x -= *dx;
00270 *dx = 0;
00271 }
00272 if (*dy < 0)
00273 {
00274 if (-*dy > rect->h)
00275
00276 return 0;
00277
00278 rect->h += *dy;
00279 rect->y -= *dy;
00280 *dy = 0;
00281 }
00282 if ((*dx + rect->w) > max_x)
00283
00284 rect->w = max_x - *dx;
00285 if ((*dy + rect->h) > max_y)
00286
00287 rect->h = max_y - *dy;
00288
00289
00290 return 1;
00291 }
00292
00293 static inline void
00294 _bmap16lsb(l4_uint8_t *vfb,
00295 l4_uint8_t *bmap,
00296 l4_uint32_t fgc,
00297 l4_uint32_t bgc,
00298 l4_uint32_t w, l4_uint32_t h,
00299 struct pslim_offset* offset,
00300 l4_uint32_t bwidth)
00301 {
00302 l4_uint32_t nobits=0;
00303 int i,j, k,kmod;
00304
00305 nobits += offset->preskip_y
00306 * (w + offset->preskip_x + offset->endskip_x);
00307
00308
00309 for (i = 0; i < h; i++) {
00310 nobits += offset->preskip_x;
00311 for (j = 0; j < w; j++, nobits++) {
00312 k = nobits>>3;
00313 kmod = (nobits)%8;
00314 if ( bmap[k] & (0x01 << kmod) )
00315 *(l4_uint16_t*) (&vfb[2*j]) = (l4_uint16_t) (fgc & 0xffff);
00316 else
00317 *(l4_uint16_t*) (&vfb[2*j]) = (l4_uint16_t) (bgc & 0xffff);
00318 }
00319 l4_sys_cache_clean_range((unsigned long)vfb,
00320 (unsigned long)vfb + w*2);
00321 vfb += bwidth;
00322 }
00323 }
00324
00325 static inline void
00326 _bmap16msb(l4_uint8_t *vfb,
00327 l4_uint8_t *bmap,
00328 l4_uint32_t fgc,
00329 l4_uint32_t bgc,
00330 l4_uint32_t w, l4_uint32_t h,
00331 struct pslim_offset* offset,
00332 l4_uint32_t bwidth)
00333 {
00334 int i, j;
00335 l4_uint32_t nobits = offset->preskip_y
00336 * (w + offset->preskip_x + offset->endskip_x);
00337
00338 for (i = 0; i < h; i++)
00339 {
00340 unsigned char mask, *b;
00341 nobits += offset->preskip_x;
00342 mask = 0x80 >> (nobits % 8);
00343 b = bmap + nobits / 8;
00344 for (j = 0; j < w; j++, nobits++)
00345 {
00346
00347
00348 *(l4_uint16_t*) (&vfb[2*j]) = (*b & mask)
00349 ? (l4_uint16_t) (fgc & 0xffff)
00350 : (l4_uint16_t) (bgc & 0xffff);
00351 b += mask & 1;
00352 mask = (mask >> 1) | (mask << 7);
00353 }
00354 l4_sys_cache_clean_range((unsigned long)vfb,
00355 (unsigned long)vfb + w*2);
00356 vfb += bwidth;
00357 nobits += offset->endskip_x;
00358 }
00359 }
00360
00361 static inline void
00362 _bmap24lsb(l4_uint8_t *vfb,
00363 l4_uint8_t *bmap,
00364 l4_uint32_t fgc,
00365 l4_uint32_t bgc,
00366 l4_uint32_t w, l4_uint32_t h,
00367 struct pslim_offset* offset,
00368 l4_uint32_t bwidth)
00369 {
00370 l4_uint32_t nobits=0;
00371 int i,j, k,kmod;
00372
00373 nobits += offset->preskip_y
00374 * (w + offset->preskip_x + offset->endskip_x);
00375
00376
00377 for (i = 0; i < h; i++) {
00378 nobits += offset->preskip_x;
00379 for (j = 0; j < w; j++, nobits++) {
00380 k = nobits>>3;
00381 kmod = (nobits)%8;
00382 if ( bmap[k] & (0x01 << kmod) ) {
00383 *(l4_uint16_t*) (&vfb[3*j]) = (l4_uint16_t) (fgc & 0xffff);
00384 vfb[3*j+2] = (l4_uint8_t) (fgc >> 16);
00385 }
00386 else {
00387 *(l4_uint16_t*) (&vfb[3*j]) = (l4_uint16_t) (bgc & 0xffff);
00388 vfb[3*j+2] = (l4_uint8_t) (bgc >> 16);
00389 }
00390 }
00391 l4_sys_cache_clean_range((unsigned long)vfb,
00392 (unsigned long)vfb + w*3);
00393 vfb += bwidth;
00394 }
00395 }
00396
00397 static inline void
00398 _bmap24msb(l4_uint8_t *vfb,
00399 l4_uint8_t *bmap,
00400 l4_uint32_t fgc,
00401 l4_uint32_t bgc,
00402 l4_uint32_t w, l4_uint32_t h,
00403 struct pslim_offset* offset,
00404 l4_uint32_t bwidth)
00405 {
00406 l4_uint32_t nobits=0;
00407 int i,j, k,kmod;
00408
00409 nobits += offset->preskip_y
00410 * (w + offset->preskip_x + offset->endskip_x);
00411
00412
00413 for (i = 0; i < h; i++) {
00414 nobits += offset->preskip_x;
00415 for (j = 0; j < w; j++, nobits++) {
00416 k = nobits>>3;
00417 kmod = (nobits)%8;
00418 if ( bmap[k] & (0x80 >> kmod) ) {
00419 *(l4_uint16_t*) (&vfb[3*j]) = (l4_uint16_t) (fgc & 0xffff);
00420 vfb[3*j+2] = (l4_uint8_t) (fgc >> 16);
00421 }
00422 else {
00423 *(l4_uint16_t*) (&vfb[3*j]) = (l4_uint16_t) (bgc & 0xffff);
00424 vfb[3*j+2] = (l4_uint8_t) (bgc >> 16);
00425 }
00426 }
00427 l4_sys_cache_clean_range((unsigned long)vfb,
00428 (unsigned long)vfb + w*3);
00429 vfb += bwidth;
00430
00431 nobits += offset->endskip_x;
00432 }
00433 }
00434
00435 static inline void
00436 _bmap32lsb(l4_uint8_t *vfb,
00437 l4_uint8_t *bmap,
00438 l4_uint32_t fgc,
00439 l4_uint32_t bgc,
00440 l4_uint32_t w, l4_uint32_t h,
00441 struct pslim_offset* offset,
00442 l4_uint32_t bwidth)
00443 {
00444 l4_uint32_t nobits=0;
00445 int i,j, k,kmod;
00446
00447 nobits += offset->preskip_y
00448 * (w + offset->preskip_x + offset->endskip_x);
00449
00450
00451 for (i = 0; i < h; i++) {
00452 nobits += offset->preskip_x;
00453 for (j = 0; j < w; j++, nobits++) {
00454 l4_uint32_t *dest = (l4_uint32_t*)&vfb[4*j];
00455 k = nobits>>3;
00456 kmod = (nobits)%8;
00457 *dest = (bmap[k] & (0x01 << kmod))
00458 ? fgc & 0xffffffff
00459 : bgc & 0xffffffff;
00460 }
00461 l4_sys_cache_clean_range((unsigned long)vfb,
00462 (unsigned long)vfb + w*4);
00463 vfb += bwidth;
00464 }
00465 }
00466
00467 static inline void
00468 _bmap32msb(l4_uint8_t *vfb,
00469 l4_uint8_t *bmap,
00470 l4_uint32_t fgc,
00471 l4_uint32_t bgc,
00472 l4_uint32_t w, l4_uint32_t h,
00473 struct pslim_offset* offset,
00474 l4_uint32_t bwidth)
00475 {
00476 l4_uint32_t nobits=0;
00477 int i,j,k,kmod;
00478
00479 nobits += offset->preskip_y
00480 * (w + offset->preskip_x + offset->endskip_x);
00481
00482
00483 for (i = 0; i < h; i++) {
00484 nobits += offset->preskip_x;
00485 for (j = 0; j < w; j++, nobits++) {
00486 k = nobits>>3;
00487 kmod = (nobits)%8;
00488 if ( bmap[k] & (0x80 >> kmod) )
00489 *(l4_uint32_t*) (&vfb[4*j]) = (l4_uint32_t) (fgc & 0x00ffffff);
00490 else
00491 *(l4_uint32_t*) (&vfb[4*j]) = (l4_uint32_t) (bgc & 0x00ffffff);
00492 }
00493 l4_sys_cache_clean_range((unsigned long)vfb,
00494 (unsigned long)vfb + w*4);
00495 vfb += bwidth;
00496
00497 nobits += offset->endskip_x;
00498 }
00499 }
00500
00501 static inline void
00502 _set16(l4_uint8_t *vfb,
00503 l4_uint8_t *pmap,
00504 l4_uint32_t w, l4_uint32_t h,
00505 struct pslim_offset* offset,
00506 l4_uint32_t bwidth,
00507 l4_uint32_t pwidth)
00508 {
00509 int i;
00510
00511 #ifdef ARCH_x86
00512 if (use_fastmemcpy && (w % 4 == 0))
00513 {
00514 asm ("emms");
00515 for (i = 0; i < h; i++)
00516 {
00517 l4_umword_t dummy;
00518 pmap += 2 * offset->preskip_x;
00519 asm volatile("xorl %%edx,%%edx \n\t"
00520 "1: \n\t"
00521 "movq (%%esi,%%edx,8),%%mm0 \n\t"
00522 "movntq %%mm0,(%%edi,%%edx,8) \n\t"
00523 "add $1,%%edx \n\t"
00524 "dec %%ecx \n\t"
00525 "jnz 1b \n\t"
00526 : "=c"(dummy), "=d"(dummy)
00527 : "c"(w/4), "S"(pmap), "D"(vfb));
00528 vfb += bwidth;
00529 pmap += pwidth;
00530 }
00531 asm ("sfence; emms");
00532 }
00533 else
00534 #endif
00535 {
00536 for (i = 0; i < h; i++)
00537 {
00538 pmap += 2 * offset->preskip_x;
00539 memcpy(vfb, pmap, w*2);
00540 l4_sys_cache_clean_range((unsigned long)vfb,
00541 (unsigned long)vfb + w*2);
00542 vfb += bwidth;
00543 pmap += pwidth;
00544 }
00545 }
00546 }
00547
00548 static inline void
00549 _set24(l4_uint8_t *vfb,
00550 l4_uint8_t *pmap,
00551 l4_uint32_t w, l4_uint32_t h,
00552 struct pslim_offset* offset,
00553 l4_uint32_t bwidth,
00554 l4_uint32_t pwidth)
00555 {
00556 int i;
00557
00558 for (i = 0; i < h; i++)
00559 {
00560 pmap += 3 * offset->preskip_x;
00561 memcpy(vfb, pmap, w*3);
00562 l4_sys_cache_clean_range((unsigned long)vfb,
00563 (unsigned long)vfb + w*3);
00564 vfb += bwidth;
00565 pmap += pwidth;
00566 }
00567 }
00568
00569 static inline void
00570 _set32(l4_uint8_t *vfb,
00571 l4_uint8_t *pmap,
00572 l4_uint32_t w, l4_uint32_t h,
00573 struct pslim_offset* offset,
00574 l4_uint32_t bwidth,
00575 l4_uint32_t pwidth)
00576 {
00577 int i;
00578
00579 for (i = 0; i < h; i++)
00580 {
00581 pmap += 4 * offset->preskip_x;
00582 memcpy(vfb, pmap, w*4);
00583 l4_sys_cache_clean_range((unsigned long)vfb,
00584 (unsigned long)vfb + w*4);
00585 vfb += bwidth;
00586 pmap += pwidth;
00587 }
00588 }
00589
00590 static inline void
00591 _copy16(l4_uint8_t *vfb,
00592 l4_int16_t x, l4_int16_t y,
00593 l4_int16_t dx, l4_int16_t dy,
00594 l4_uint32_t w, l4_uint32_t h,
00595 l4_uint32_t bwidth)
00596 {
00597 int i;
00598 l4_uint8_t *src = vfb, *dest = vfb;
00599
00600 if (dy == y && dx == x)
00601 return;
00602
00603 if (y >= dy)
00604 {
00605 OFFSET( x, y, src, 2);
00606 OFFSET(dx, dy, dest, 2);
00607 for (i = 0; i < h; i++)
00608 {
00609
00610 memmove(dest, src, 2*w);
00611 src += bwidth;
00612 dest += bwidth;
00613 }
00614 }
00615 else
00616 {
00617 OFFSET( x, y + h - 1, src, 2);
00618 OFFSET(dx, dy + h - 1, dest, 2);
00619 for (i = 0; i < h; i++)
00620 {
00621
00622 memmove(dest, src, 2*w);
00623 src -= bwidth;
00624 dest -= bwidth;
00625 }
00626 }
00627 }
00628
00629 static inline void
00630 _copy24(l4_uint8_t *vfb,
00631 l4_int16_t x, l4_int16_t y,
00632 l4_int16_t dx, l4_int16_t dy,
00633 l4_uint32_t w, l4_uint32_t h,
00634 l4_uint32_t bwidth)
00635 {
00636 int i,j;
00637 l4_uint8_t *src = vfb, *dest = vfb;
00638
00639 if (y >= dy) {
00640 if (y == dy && dx >= x) {
00641 if (x == dx)
00642 return;
00643
00644 OFFSET( x, y, src, 3);
00645 OFFSET(dx, dy, dest, 3);
00646 for (i = 0; i < h; i++) {
00647 for (j = w; j >= 0; --j) {
00648 *(l4_uint16_t*) (&dest[3*j]) = *(l4_uint16_t*) (&src[3*j]);
00649 dest[3*j+2] = src[3*j+2];
00650 }
00651 src += bwidth;
00652 dest += bwidth;
00653 }
00654
00655 }
00656 else {
00657 OFFSET( x, y, src, 3);
00658 OFFSET(dx, dy, dest, 3);
00659 for (i = 0; i < h; i++) {
00660 for (j = 0; j < w; j++) {
00661 *(l4_uint16_t*) (&dest[3*j]) = *(l4_uint16_t*) (&src[3*j]);
00662 dest[3*j+2] = src[3*j+2];
00663 }
00664 src += bwidth;
00665 dest += bwidth;
00666 }
00667 }
00668 }
00669 else {
00670 OFFSET( x, y + h, src, 3);
00671 OFFSET(dx, dy + h, dest, 3);
00672 for (i = 0; i < h; i++) {
00673 src -= bwidth;
00674 dest -= bwidth;
00675 for (j = 0; j < w; j++) {
00676 *(l4_uint16_t*) (&dest[3*j]) = *(l4_uint16_t*) (&src[3*j]);
00677 dest[3*j+2] = src[3*j+2];
00678 }
00679 }
00680 }
00681 }
00682
00683 static inline void
00684 _copy32(l4_uint8_t *vfb,
00685 l4_int16_t x, l4_int16_t y,
00686 l4_int16_t dx, l4_int16_t dy,
00687 l4_uint32_t w, l4_uint32_t h,
00688 l4_uint32_t bwidth)
00689 {
00690 int i,j;
00691 l4_uint8_t *src = vfb, *dest = vfb;
00692
00693 if (y >= dy) {
00694 if (y == dy && dx >= x) {
00695 if (x == dx)
00696 return;
00697
00698 OFFSET( x, y, src, 4);
00699 OFFSET(dx, dy, dest, 4);
00700 for (i = 0; i < h; i++) {
00701 for (j = w; j >= 0; --j)
00702 *(l4_uint32_t*) (&dest[4*j]) = *(l4_uint32_t*) (&src[4*j]);
00703 src += bwidth;
00704 dest += bwidth;
00705 }
00706
00707 }
00708 else {
00709 OFFSET( x, y, src, 4);
00710 OFFSET(dx, dy, dest, 4);
00711 for (i = 0; i < h; i++) {
00712 for (j = 0; j < w; j++)
00713 *(l4_uint32_t*) (&dest[4*j]) = *(l4_uint32_t*) (&src[4*j]);
00714 src += bwidth;
00715 dest += bwidth;
00716 }
00717 }
00718 }
00719 else {
00720 OFFSET( x, y + h, src, 4);
00721 OFFSET(dx, dy + h, dest, 4);
00722 for (i = 0; i < h; i++) {
00723 src -= bwidth;
00724 dest -= bwidth;
00725 for (j = 0; j < w; j++)
00726 *(l4_uint32_t*) (&dest[4*j]) = *(l4_uint32_t*) (&src[4*j]);
00727 }
00728 }
00729 }
00730
00731 static inline void
00732 _fill16(l4_uint8_t *vfb,
00733 l4_uint32_t w, l4_uint32_t h,
00734 l4_uint32_t color,
00735 l4_uint32_t bwidth)
00736 {
00737 int i,j;
00738
00739 for (i = 0; i < h; i++)
00740 {
00741 for (j = 0; j < w; j++)
00742 *(l4_uint16_t*) (&vfb[2*j]) = (l4_uint16_t)color;
00743 vfb += bwidth;
00744 }
00745 }
00746
00747 static inline void
00748 _fill24(l4_uint8_t *vfb,
00749 l4_uint32_t w, l4_uint32_t h,
00750 l4_uint32_t color,
00751 l4_uint32_t bwidth)
00752 {
00753 int i,j;
00754
00755 for (i = 0; i < h; i++) {
00756 for (j = 0; j < w; j++) {
00757 *(l4_uint16_t*) (&vfb[3*j ]) = (l4_uint16_t)color;
00758 vfb[3*j+2] = (l4_uint8_t) (color >> 16);
00759 }
00760 vfb += bwidth;
00761 }
00762 }
00763
00764 static inline void
00765 _fill32(l4_uint8_t *vfb,
00766 l4_uint32_t w, l4_uint32_t h,
00767 l4_uint32_t color,
00768 l4_uint32_t bwidth)
00769 {
00770 int i,j;
00771
00772 for (i = 0; i < h; i++) {
00773 for (j = 0; j < w; j++)
00774 *(l4_uint32_t*) (&vfb[4*j]) = (l4_uint32_t)color;
00775 vfb += bwidth;
00776 }
00777 }
00778
00779 void
00780 sw_fill(struct l4con_vc *vc, int x, int y, int w, int h, unsigned color)
00781 {
00782 l4_uint8_t *vfb = (l4_uint8_t*) vc->fb;
00783 l4_uint32_t bwidth = vc->bytes_per_line;
00784
00785 OFFSET(x, y, vfb, vc->bytes_per_pixel);
00786
00787
00788 vc->do_sync();
00789
00790 switch(vc->gmode & GRAPH_BPPMASK)
00791 {
00792 case GRAPH_BPP_24:
00793 _fill24(vfb, w, h, color, bwidth);
00794 break;
00795 case GRAPH_BPP_32:
00796 _fill32(vfb, w, h, color, bwidth);
00797 break;
00798 case GRAPH_BPP_16:
00799 default:
00800 _fill16(vfb, w, h, color, bwidth);
00801 }
00802
00803
00804 if (vc->do_drty)
00805 vc->do_drty(x, y, w, h);
00806 }
00807
00808 static inline void
00809 sw_bmap(struct l4con_vc *vc, l4_int16_t x, l4_int16_t y, l4_uint32_t w,
00810 l4_uint32_t h, l4_uint8_t *bmap, l4_uint32_t fgc, l4_uint32_t bgc,
00811 struct pslim_offset* offset, l4_uint8_t mode)
00812 {
00813 l4_uint8_t *vfb = (l4_uint8_t*) vc->fb;
00814 l4_uint32_t bwidth = vc->bytes_per_line;
00815
00816 OFFSET(x, y, vfb, vc->bytes_per_pixel);
00817
00818
00819 vc->do_sync();
00820
00821 switch (mode)
00822 {
00823 case pSLIM_BMAP_START_MSB:
00824 switch(vc->gmode & GRAPH_BPPMASK)
00825 {
00826 case GRAPH_BPP_32:
00827 _bmap32msb(vfb, bmap, fgc, bgc, w, h, offset, bwidth);
00828 break;
00829 case GRAPH_BPP_24:
00830 _bmap24msb(vfb, bmap, fgc, bgc, w, h, offset, bwidth);
00831 break;
00832 case GRAPH_BPP_16:
00833 default:
00834 _bmap16msb(vfb, bmap, fgc, bgc, w, h, offset, bwidth);
00835 }
00836 break;
00837 case pSLIM_BMAP_START_LSB:
00838 default:
00839 switch(vc->gmode & GRAPH_BPPMASK)
00840 {
00841 case GRAPH_BPP_32:
00842 _bmap32lsb(vfb, bmap, fgc, bgc, w, h, offset, bwidth);
00843 break;
00844 case GRAPH_BPP_24:
00845 _bmap24lsb(vfb, bmap, fgc, bgc, w, h, offset, bwidth);
00846 break;
00847 case GRAPH_BPP_16:
00848 default:
00849 _bmap16lsb(vfb, bmap, fgc, bgc, w, h, offset, bwidth);
00850 }
00851 }
00852
00853
00854 if (vc->do_drty)
00855 vc->do_drty(x, y, w, h);
00856 }
00857
00858 static inline void
00859 sw_set(struct l4con_vc *vc, l4_int16_t x, l4_int16_t y, l4_uint32_t w,
00860 l4_uint32_t h, l4_uint32_t xoffs, l4_uint32_t yoffs,
00861 l4_uint8_t *pmap, struct pslim_offset* offset)
00862 {
00863 l4_uint8_t *vfb = (l4_uint8_t*) vc->fb;
00864 l4_uint32_t bytepp = vc->bytes_per_pixel;
00865 l4_uint32_t bwidth = vc->bytes_per_line;
00866 l4_uint32_t pwidth;
00867
00868 OFFSET(x+xoffs, y+yoffs, vfb, bytepp);
00869
00870 if (!pmap)
00871 {
00872
00873
00874 pwidth = vc->xres*bytepp;
00875 pmap = vc->vfb + y*pwidth + x*bytepp;
00876 }
00877 else
00878 {
00879 pwidth = bytepp * (w + offset->endskip_x);
00880 pmap += bytepp * offset->preskip_y *
00881 (w + offset->preskip_x + offset->endskip_x);
00882 }
00883
00884
00885 vc->do_sync();
00886
00887 switch(vc->gmode & GRAPH_BPPMASK)
00888 {
00889 case GRAPH_BPP_32:
00890 _set32(vfb, pmap, w, h, offset, bwidth, pwidth);
00891 break;
00892 case GRAPH_BPP_24:
00893 _set24(vfb, pmap, w, h, offset, bwidth, pwidth);
00894 break;
00895 case GRAPH_BPP_16:
00896 default:
00897 _set16(vfb, pmap, w, h, offset, bwidth, pwidth);
00898 }
00899
00900
00901 if (vc->do_drty)
00902 vc->do_drty(x+xoffs, y+yoffs, w, h);
00903 }
00904
00905 void
00906 sw_copy(struct l4con_vc *vc, int x, int y, int w, int h, int dx, int dy)
00907 {
00908 l4_uint8_t *vfb = (l4_uint8_t*) vc->fb;
00909 l4_uint32_t bwidth = vc->bytes_per_line;
00910
00911
00912 vc->do_sync();
00913
00914 switch(vc->gmode & GRAPH_BPPMASK)
00915 {
00916 case GRAPH_BPP_32:
00917 _copy32(vfb, x, y, dx, dy, w, h, bwidth);
00918 break;
00919 case GRAPH_BPP_24:
00920 _copy24(vfb, x, y, dx, dy, w, h, bwidth);
00921 break;
00922 case GRAPH_BPP_16:
00923 default:
00924 _copy16(vfb, x, y, dx, dy, w, h, bwidth);
00925 }
00926
00927
00928 if (vc->do_drty)
00929 vc->do_drty(dx, dy, w, h);
00930 }
00931
00932 static inline void
00933 sw_cscs(struct l4con_vc *vc, l4_int16_t x, l4_int16_t y, l4_uint32_t w,
00934 l4_uint32_t h, l4_uint8_t *Y, l4_uint8_t *U, l4_uint8_t *V,
00935 l4_uint32_t scale, struct pslim_offset* offset, l4_uint8_t mode)
00936 {
00937
00938 vc->do_sync();
00939
00940
00941 (*yuv2rgb_render)(vc->fb+y*vc->bytes_per_line+x*vc->bytes_per_pixel,
00942 Y, U, V, w, h, vc->bytes_per_line, w, w/2);
00943
00944
00945 if (vc->do_drty)
00946 vc->do_drty(x, y, w, h);
00947 }
00948
00949
00950 void
00951 pslim_fill(struct l4con_vc *vc, int from_user,
00952 l4con_pslim_rect_t *rect, l4con_pslim_color_t color)
00953 {
00954 if (!clip_rect(vc, from_user, rect))
00955
00956 return;
00957
00958 if (!rect->w || !rect->h)
00959
00960 return;
00961
00962 vc->do_fill(vc, rect->x+vc->pan_xofs, rect->y+vc->pan_yofs,
00963 rect->w, rect->h, color);
00964 }
00965
00966
00967
00968 void
00969 pslim_bmap(struct l4con_vc *vc, int from_user, l4con_pslim_rect_t *rect,
00970 l4con_pslim_color_t fgc, l4con_pslim_color_t bgc, void* bmap,
00971 l4_uint8_t mode)
00972 {
00973 struct pslim_offset offset = {0,0,0};
00974
00975 if (!clip_rect_offset(vc, from_user, rect, &offset))
00976
00977 return;
00978
00979 if (!rect->w || !rect->h)
00980
00981 return;
00982
00983 sw_bmap(vc, rect->x+vc->pan_xofs, rect->y+vc->pan_yofs, rect->w, rect->h,
00984 bmap, fgc, bgc, &offset, mode);
00985 }
00986
00987
00988 void
00989 pslim_set(struct l4con_vc *vc, int from_user, l4con_pslim_rect_t *rect,
00990 void* pmap)
00991 {
00992 struct pslim_offset offset = {0,0,0};
00993
00994 if (!clip_rect_offset(vc, from_user, rect, &offset))
00995
00996 return;
00997
00998 if (!rect->w || !rect->h)
00999
01000 return;
01001
01002 sw_set(vc, rect->x, rect->y, rect->w, rect->h,
01003 vc->pan_xofs, vc->pan_yofs, (l4_uint8_t*) pmap, &offset);
01004 }
01005
01006
01007 void
01008 pslim_copy(struct l4con_vc *vc, int from_user, l4con_pslim_rect_t *rect,
01009 l4_int16_t dx, l4_int16_t dy)
01010 {
01011 if (!clip_rect_dxy(vc, from_user, rect, &dx, &dy))
01012
01013 return;
01014
01015 if (!rect->w || !rect->h)
01016
01017 return;
01018
01019 vc->do_copy(vc, rect->x+vc->pan_xofs, rect->y+vc->pan_yofs, rect->w, rect->h,
01020 dx+vc->pan_xofs, dy+vc->pan_yofs);
01021 }
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033 void
01034 pslim_cscs(struct l4con_vc *vc, int from_user, l4con_pslim_rect_t *rect,
01035 void* y, void* u, void *v, l4_uint8_t mode, l4_uint32_t scale)
01036 {
01037 struct pslim_offset offset = {0,0,0};
01038
01039 if (!clip_rect_offset(vc, from_user, rect, &offset))
01040
01041 return;
01042
01043 if (!rect->w || !rect->h)
01044
01045 return;
01046
01047 sw_cscs(vc, rect->x+vc->pan_xofs, rect->y+vc->pan_yofs, rect->w, rect->h,
01048 y, u, v, scale, &offset, mode);
01049 }