summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-color-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-color-common.c')
-rw-r--r--firmware/drivers/lcd-color-common.c189
1 files changed, 0 insertions, 189 deletions
diff --git a/firmware/drivers/lcd-color-common.c b/firmware/drivers/lcd-color-common.c
index 9feba9f894..72ce7c209f 100644
--- a/firmware/drivers/lcd-color-common.c
+++ b/firmware/drivers/lcd-color-common.c
@@ -379,195 +379,6 @@ static inline int clamp(int val, int min, int max)
379 return val; 379 return val;
380} 380}
381 381
382#ifndef _WIN32
383/*
384 * weak attribute doesn't work for win32 as of gcc 4.6.2 and binutils 2.21.52
385 * When building win32 simulators, we won't be using an optimized version of
386 * lcd_blit_yuv(), so just don't use the weak attribute.
387 */
388__attribute__((weak))
389#endif
390void lcd_yuv_set_options(unsigned options)
391{
392 (void)options;
393}
394
395/* Draw a partial YUV colour bitmap */
396#ifndef _WIN32
397__attribute__((weak))
398#endif
399void lcd_blit_yuv(unsigned char * const src[3],
400 int src_x, int src_y, int stride,
401 int x, int y, int width, int height)
402{
403 const unsigned char *ysrc, *usrc, *vsrc;
404 int linecounter;
405 fb_data *dst, *row_end;
406 long z;
407
408 /* width and height must be >= 2 and an even number */
409 width &= ~1;
410 linecounter = height >> 1;
411
412#if LCD_WIDTH >= LCD_HEIGHT
413 dst = FBADDR(x, y);
414 row_end = dst + width;
415#else
416 dst = FBADDR(LCD_WIDTH - y - 1, x);
417 row_end = dst + LCD_WIDTH * width;
418#endif
419
420 z = stride * src_y;
421 ysrc = src[0] + z + src_x;
422 usrc = src[1] + (z >> 2) + (src_x >> 1);
423 vsrc = src[2] + (usrc - src[1]);
424
425 /* stride => amount to jump from end of last row to start of next */
426 stride -= width;
427
428 /* upsampling, YUV->RGB conversion and reduction to RGB565 in one go */
429
430 do
431 {
432 do
433 {
434 int y, cb, cr, rv, guv, bu, r, g, b;
435
436 y = YFAC*(*ysrc++ - 16);
437 cb = *usrc++ - 128;
438 cr = *vsrc++ - 128;
439
440 rv = RVFAC*cr;
441 guv = GUFAC*cb + GVFAC*cr;
442 bu = BUFAC*cb;
443
444 r = y + rv;
445 g = y + guv;
446 b = y + bu;
447
448 if ((unsigned)(r | g | b) > 64*256-1)
449 {
450 r = clamp(r, 0, 64*256-1);
451 g = clamp(g, 0, 64*256-1);
452 b = clamp(b, 0, 64*256-1);
453 }
454
455 *dst = FB_RGBPACK(r >> 6, g >> 6, b >> 6);
456
457#if LCD_WIDTH >= LCD_HEIGHT
458 dst++;
459#else
460 dst += LCD_WIDTH;
461#endif
462
463 y = YFAC*(*ysrc++ - 16);
464 r = y + rv;
465 g = y + guv;
466 b = y + bu;
467
468 if ((unsigned)(r | g | b) > 64*256-1)
469 {
470 r = clamp(r, 0, 64*256-1);
471 g = clamp(g, 0, 64*256-1);
472 b = clamp(b, 0, 64*256-1);
473 }
474
475 *dst = FB_RGBPACK(r >> 6, g >> 6, b >> 6);
476
477#if LCD_WIDTH >= LCD_HEIGHT
478 dst++;
479#else
480 dst += LCD_WIDTH;
481#endif
482 }
483 while (dst < row_end);
484
485 ysrc += stride;
486 usrc -= width >> 1;
487 vsrc -= width >> 1;
488
489#if LCD_WIDTH >= LCD_HEIGHT
490 row_end += LCD_WIDTH;
491 dst += LCD_WIDTH - width;
492#else
493 row_end -= 1;
494 dst -= LCD_WIDTH*width + 1;
495#endif
496
497 do
498 {
499 int y, cb, cr, rv, guv, bu, r, g, b;
500
501 y = YFAC*(*ysrc++ - 16);
502 cb = *usrc++ - 128;
503 cr = *vsrc++ - 128;
504
505 rv = RVFAC*cr;
506 guv = GUFAC*cb + GVFAC*cr;
507 bu = BUFAC*cb;
508
509 r = y + rv;
510 g = y + guv;
511 b = y + bu;
512
513 if ((unsigned)(r | g | b) > 64*256-1)
514 {
515 r = clamp(r, 0, 64*256-1);
516 g = clamp(g, 0, 64*256-1);
517 b = clamp(b, 0, 64*256-1);
518 }
519
520 *dst = FB_RGBPACK(r >> 6, g >> 6, b >> 6);
521
522#if LCD_WIDTH >= LCD_HEIGHT
523 dst++;
524#else
525 dst += LCD_WIDTH;
526#endif
527
528 y = YFAC*(*ysrc++ - 16);
529 r = y + rv;
530 g = y + guv;
531 b = y + bu;
532
533 if ((unsigned)(r | g | b) > 64*256-1)
534 {
535 r = clamp(r, 0, 64*256-1);
536 g = clamp(g, 0, 64*256-1);
537 b = clamp(b, 0, 64*256-1);
538 }
539
540 *dst = FB_RGBPACK(r >> 6, g >> 6, b >> 6);
541
542#if LCD_WIDTH >= LCD_HEIGHT
543 dst++;
544#else
545 dst += LCD_WIDTH;
546#endif
547 }
548 while (dst < row_end);
549
550 ysrc += stride;
551 usrc += stride >> 1;
552 vsrc += stride >> 1;
553
554#if LCD_WIDTH >= LCD_HEIGHT
555 row_end += LCD_WIDTH;
556 dst += LCD_WIDTH - width;
557#else
558 row_end -= 1;
559 dst -= LCD_WIDTH*width + 1;
560#endif
561 }
562 while (--linecounter > 0);
563
564#if LCD_WIDTH >= LCD_HEIGHT
565 lcd_update_rect(x, y, width, height);
566#else
567 lcd_update_rect(LCD_WIDTH - y - height, x, height, width);
568#endif
569}
570
571/* Fill a rectangle with a gradient. This function draws only the partial 382/* Fill a rectangle with a gradient. This function draws only the partial
572 * gradient. It assumes the original gradient is src_height high and skips 383 * gradient. It assumes the original gradient is src_height high and skips
573 * the first few rows. This is useful for drawing only the bottom half of 384 * the first few rows. This is useful for drawing only the bottom half of