diff options
Diffstat (limited to 'firmware/drivers/lcd-h100.c')
-rw-r--r-- | firmware/drivers/lcd-h100.c | 91 |
1 files changed, 48 insertions, 43 deletions
diff --git a/firmware/drivers/lcd-h100.c b/firmware/drivers/lcd-h100.c index 369833944f..39497cc2ec 100644 --- a/firmware/drivers/lcd-h100.c +++ b/firmware/drivers/lcd-h100.c | |||
@@ -63,7 +63,7 @@ | |||
63 | 63 | ||
64 | /*** globals ***/ | 64 | /*** globals ***/ |
65 | 65 | ||
66 | unsigned char lcd_framebuffer[LCD_HEIGHT/4][LCD_WIDTH] IBSS_ATTR; | 66 | fb_data lcd_framebuffer[LCD_HEIGHT/4][LCD_WIDTH] IBSS_ATTR; |
67 | 67 | ||
68 | static const unsigned char dibits[16] ICONST_ATTR = { | 68 | static const unsigned char dibits[16] ICONST_ATTR = { |
69 | 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F, | 69 | 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F, |
@@ -357,21 +357,28 @@ int lcd_getstringsize(const unsigned char *str, int *w, int *h) | |||
357 | 357 | ||
358 | static void setpixel(int x, int y) | 358 | static void setpixel(int x, int y) |
359 | { | 359 | { |
360 | unsigned char *data = &lcd_framebuffer[y>>2][x]; | ||
361 | unsigned mask = pixmask[y & 3]; | 360 | unsigned mask = pixmask[y & 3]; |
362 | *data = (*data & ~mask) | (fg_pattern & mask); | 361 | fb_data *address = &lcd_framebuffer[y>>2][x]; |
362 | unsigned data = *address; | ||
363 | |||
364 | *address = data ^ ((data ^ fg_pattern) & mask); | ||
363 | } | 365 | } |
364 | 366 | ||
365 | static void clearpixel(int x, int y) | 367 | static void clearpixel(int x, int y) |
366 | { | 368 | { |
367 | unsigned char *data = &lcd_framebuffer[y>>2][x]; | ||
368 | unsigned mask = pixmask[y & 3]; | 369 | unsigned mask = pixmask[y & 3]; |
369 | *data = (*data & ~mask) | (bg_pattern & mask); | 370 | fb_data *address = &lcd_framebuffer[y>>2][x]; |
371 | unsigned data = *address; | ||
372 | |||
373 | *address = data ^ ((data ^ bg_pattern) & mask); | ||
370 | } | 374 | } |
371 | 375 | ||
372 | static void flippixel(int x, int y) | 376 | static void flippixel(int x, int y) |
373 | { | 377 | { |
374 | lcd_framebuffer[y>>2][x] ^= pixmask[y & 3]; | 378 | unsigned mask = pixmask[y & 3]; |
379 | fb_data *address = &lcd_framebuffer[y>>2][x]; | ||
380 | |||
381 | *address ^= mask; | ||
375 | } | 382 | } |
376 | 383 | ||
377 | static void nopixel(int x, int y) | 384 | static void nopixel(int x, int y) |
@@ -386,34 +393,34 @@ lcd_pixelfunc_type* const lcd_pixelfuncs[8] = { | |||
386 | }; | 393 | }; |
387 | 394 | ||
388 | /* 'mask' and 'bits' contain 2 bits per pixel */ | 395 | /* 'mask' and 'bits' contain 2 bits per pixel */ |
389 | static void flipblock(unsigned char *address, unsigned mask, unsigned bits) | 396 | static void flipblock(fb_data *address, unsigned mask, unsigned bits) |
390 | ICODE_ATTR; | 397 | ICODE_ATTR; |
391 | static void flipblock(unsigned char *address, unsigned mask, unsigned bits) | 398 | static void flipblock(fb_data *address, unsigned mask, unsigned bits) |
392 | { | 399 | { |
393 | *address ^= bits & mask; | 400 | *address ^= bits & mask; |
394 | } | 401 | } |
395 | 402 | ||
396 | static void bgblock(unsigned char *address, unsigned mask, unsigned bits) | 403 | static void bgblock(fb_data *address, unsigned mask, unsigned bits) |
397 | ICODE_ATTR; | 404 | ICODE_ATTR; |
398 | static void bgblock(unsigned char *address, unsigned mask, unsigned bits) | 405 | static void bgblock(fb_data *address, unsigned mask, unsigned bits) |
399 | { | 406 | { |
400 | unsigned data = *address; | 407 | unsigned data = *address; |
401 | 408 | ||
402 | *address = data ^ ((data ^ bg_pattern) & mask & ~bits); | 409 | *address = data ^ ((data ^ bg_pattern) & mask & ~bits); |
403 | } | 410 | } |
404 | 411 | ||
405 | static void fgblock(unsigned char *address, unsigned mask, unsigned bits) | 412 | static void fgblock(fb_data *address, unsigned mask, unsigned bits) |
406 | ICODE_ATTR; | 413 | ICODE_ATTR; |
407 | static void fgblock(unsigned char *address, unsigned mask, unsigned bits) | 414 | static void fgblock(fb_data *address, unsigned mask, unsigned bits) |
408 | { | 415 | { |
409 | unsigned data = *address; | 416 | unsigned data = *address; |
410 | 417 | ||
411 | *address = data ^ ((data ^ fg_pattern) & mask & bits); | 418 | *address = data ^ ((data ^ fg_pattern) & mask & bits); |
412 | } | 419 | } |
413 | 420 | ||
414 | static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | 421 | static void solidblock(fb_data *address, unsigned mask, unsigned bits) |
415 | ICODE_ATTR; | 422 | ICODE_ATTR; |
416 | static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | 423 | static void solidblock(fb_data *address, unsigned mask, unsigned bits) |
417 | { | 424 | { |
418 | unsigned data = *address; | 425 | unsigned data = *address; |
419 | unsigned bgp = bg_pattern; | 426 | unsigned bgp = bg_pattern; |
@@ -422,34 +429,34 @@ static void solidblock(unsigned char *address, unsigned mask, unsigned bits) | |||
422 | *address = data ^ ((data ^ bits) & mask); | 429 | *address = data ^ ((data ^ bits) & mask); |
423 | } | 430 | } |
424 | 431 | ||
425 | static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) | 432 | static void flipinvblock(fb_data *address, unsigned mask, unsigned bits) |
426 | ICODE_ATTR; | 433 | ICODE_ATTR; |
427 | static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits) | 434 | static void flipinvblock(fb_data *address, unsigned mask, unsigned bits) |
428 | { | 435 | { |
429 | *address ^= ~bits & mask; | 436 | *address ^= ~bits & mask; |
430 | } | 437 | } |
431 | 438 | ||
432 | static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) | 439 | static void bginvblock(fb_data *address, unsigned mask, unsigned bits) |
433 | ICODE_ATTR; | 440 | ICODE_ATTR; |
434 | static void bginvblock(unsigned char *address, unsigned mask, unsigned bits) | 441 | static void bginvblock(fb_data *address, unsigned mask, unsigned bits) |
435 | { | 442 | { |
436 | unsigned data = *address; | 443 | unsigned data = *address; |
437 | 444 | ||
438 | *address = data ^ ((data ^ bg_pattern) & mask & bits); | 445 | *address = data ^ ((data ^ bg_pattern) & mask & bits); |
439 | } | 446 | } |
440 | 447 | ||
441 | static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) | 448 | static void fginvblock(fb_data *address, unsigned mask, unsigned bits) |
442 | ICODE_ATTR; | 449 | ICODE_ATTR; |
443 | static void fginvblock(unsigned char *address, unsigned mask, unsigned bits) | 450 | static void fginvblock(fb_data *address, unsigned mask, unsigned bits) |
444 | { | 451 | { |
445 | unsigned data = *address; | 452 | unsigned data = *address; |
446 | 453 | ||
447 | *address = data ^ ((data ^ fg_pattern) & mask & ~bits); | 454 | *address = data ^ ((data ^ fg_pattern) & mask & ~bits); |
448 | } | 455 | } |
449 | 456 | ||
450 | static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) | 457 | static void solidinvblock(fb_data *address, unsigned mask, unsigned bits) |
451 | ICODE_ATTR; | 458 | ICODE_ATTR; |
452 | static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits) | 459 | static void solidinvblock(fb_data *address, unsigned mask, unsigned bits) |
453 | { | 460 | { |
454 | unsigned data = *address; | 461 | unsigned data = *address; |
455 | unsigned fgp = fg_pattern; | 462 | unsigned fgp = fg_pattern; |
@@ -463,7 +470,7 @@ lcd_blockfunc_type* const lcd_blockfuncs[8] = { | |||
463 | flipinvblock, bginvblock, fginvblock, solidinvblock | 470 | flipinvblock, bginvblock, fginvblock, solidinvblock |
464 | }; | 471 | }; |
465 | 472 | ||
466 | static inline void setblock(unsigned char *address, unsigned mask, unsigned bits) | 473 | static inline void setblock(fb_data *address, unsigned mask, unsigned bits) |
467 | { | 474 | { |
468 | unsigned data = *address; | 475 | unsigned data = *address; |
469 | 476 | ||
@@ -564,7 +571,7 @@ void lcd_drawline(int x1, int y1, int x2, int y2) | |||
564 | void lcd_hline(int x1, int x2, int y) | 571 | void lcd_hline(int x1, int x2, int y) |
565 | { | 572 | { |
566 | int x; | 573 | int x; |
567 | unsigned char *dst, *dst_end; | 574 | fb_data *dst, *dst_end; |
568 | unsigned mask; | 575 | unsigned mask; |
569 | lcd_blockfunc_type *bfunc; | 576 | lcd_blockfunc_type *bfunc; |
570 | 577 | ||
@@ -600,7 +607,7 @@ void lcd_hline(int x1, int x2, int y) | |||
600 | void lcd_vline(int x, int y1, int y2) | 607 | void lcd_vline(int x, int y1, int y2) |
601 | { | 608 | { |
602 | int ny; | 609 | int ny; |
603 | unsigned char *dst; | 610 | fb_data *dst; |
604 | unsigned mask, mask_bottom; | 611 | unsigned mask, mask_bottom; |
605 | lcd_blockfunc_type *bfunc; | 612 | lcd_blockfunc_type *bfunc; |
606 | 613 | ||
@@ -657,7 +664,7 @@ void lcd_drawrect(int x, int y, int width, int height) | |||
657 | void lcd_fillrect(int x, int y, int width, int height) | 664 | void lcd_fillrect(int x, int y, int width, int height) |
658 | { | 665 | { |
659 | int ny; | 666 | int ny; |
660 | unsigned char *dst, *dst_end; | 667 | fb_data *dst, *dst_end; |
661 | unsigned mask, mask_bottom; | 668 | unsigned mask, mask_bottom; |
662 | unsigned bits = 0; | 669 | unsigned bits = 0; |
663 | lcd_blockfunc_type *bfunc; | 670 | lcd_blockfunc_type *bfunc; |
@@ -712,7 +719,7 @@ void lcd_fillrect(int x, int y, int width, int height) | |||
712 | memset(dst, bits, width); | 719 | memset(dst, bits, width); |
713 | else | 720 | else |
714 | { | 721 | { |
715 | unsigned char *dst_row = dst; | 722 | fb_data *dst_row = dst; |
716 | 723 | ||
717 | dst_end = dst_row + width; | 724 | dst_end = dst_row + width; |
718 | do | 725 | do |
@@ -755,7 +762,7 @@ void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
755 | int stride, int x, int y, int width, int height) | 762 | int stride, int x, int y, int width, int height) |
756 | { | 763 | { |
757 | int shift, ny; | 764 | int shift, ny; |
758 | unsigned char *dst, *dst_end; | 765 | fb_data *dst, *dst_end; |
759 | unsigned mask, mask_bottom; | 766 | unsigned mask, mask_bottom; |
760 | lcd_blockfunc_type *bfunc; | 767 | lcd_blockfunc_type *bfunc; |
761 | 768 | ||
@@ -800,7 +807,7 @@ void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
800 | for (; ny >= 8; ny -= 8) | 807 | for (; ny >= 8; ny -= 8) |
801 | { | 808 | { |
802 | const unsigned char *src_row = src; | 809 | const unsigned char *src_row = src; |
803 | unsigned char *dst_row = dst + LCD_WIDTH; | 810 | fb_data *dst_row = dst + LCD_WIDTH; |
804 | 811 | ||
805 | dmask1 = dibits[mask&0x0F]; | 812 | dmask1 = dibits[mask&0x0F]; |
806 | dmask2 = dibits[(mask>>4)&0x0F]; | 813 | dmask2 = dibits[(mask>>4)&0x0F]; |
@@ -863,7 +870,7 @@ void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
863 | do | 870 | do |
864 | { | 871 | { |
865 | const unsigned char *src_col = src++; | 872 | const unsigned char *src_col = src++; |
866 | unsigned char *dst_col = dst++; | 873 | fb_data *dst_col = dst++; |
867 | unsigned mask_col = mask; | 874 | unsigned mask_col = mask; |
868 | unsigned data = 0; | 875 | unsigned data = 0; |
869 | 876 | ||
@@ -916,14 +923,14 @@ void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, int heig | |||
916 | * This is the same as the internal lcd hw format. */ | 923 | * This is the same as the internal lcd hw format. */ |
917 | 924 | ||
918 | /* Draw a partial native bitmap */ | 925 | /* Draw a partial native bitmap */ |
919 | void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | 926 | void lcd_bitmap_part(const fb_data *src, int src_x, int src_y, |
920 | int stride, int x, int y, int width, int height) | 927 | int stride, int x, int y, int width, int height) |
921 | ICODE_ATTR; | 928 | ICODE_ATTR; |
922 | void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | 929 | void lcd_bitmap_part(const fb_data *src, int src_x, int src_y, |
923 | int stride, int x, int y, int width, int height) | 930 | int stride, int x, int y, int width, int height) |
924 | { | 931 | { |
925 | int shift, ny; | 932 | int shift, ny; |
926 | unsigned char *dst, *dst_end; | 933 | fb_data *dst, *dst_end; |
927 | unsigned mask, mask_bottom; | 934 | unsigned mask, mask_bottom; |
928 | 935 | ||
929 | /* nothing to draw? */ | 936 | /* nothing to draw? */ |
@@ -949,9 +956,9 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
949 | if (y + height > LCD_HEIGHT) | 956 | if (y + height > LCD_HEIGHT) |
950 | height = LCD_HEIGHT - y; | 957 | height = LCD_HEIGHT - y; |
951 | 958 | ||
952 | src += stride * (src_y >> 2) + src_x; /* move starting point */ | 959 | src += stride * (src_y >> 2) + src_x; /* move starting point */ |
953 | src_y &= 3; | 960 | src_y &= 3; |
954 | y -= src_y; | 961 | y -= src_y; |
955 | dst = &lcd_framebuffer[y>>2][x]; | 962 | dst = &lcd_framebuffer[y>>2][x]; |
956 | shift = y & 3; | 963 | shift = y & 3; |
957 | ny = height - 1 + shift + src_y; | 964 | ny = height - 1 + shift + src_y; |
@@ -967,15 +974,14 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
967 | memcpy(dst, src, width); | 974 | memcpy(dst, src, width); |
968 | else | 975 | else |
969 | { | 976 | { |
970 | const unsigned char *src_row = src; | 977 | const fb_data *src_row = src; |
971 | unsigned char *dst_row = dst; | 978 | fb_data *dst_row = dst; |
972 | 979 | ||
973 | dst_end = dst_row + width; | 980 | dst_end = dst_row + width; |
974 | do | 981 | do |
975 | setblock(dst_row++, mask, *src_row++); | 982 | setblock(dst_row++, mask, *src_row++); |
976 | while (dst_row < dst_end); | 983 | while (dst_row < dst_end); |
977 | } | 984 | } |
978 | |||
979 | src += stride; | 985 | src += stride; |
980 | dst += LCD_WIDTH; | 986 | dst += LCD_WIDTH; |
981 | mask = 0xFFu; | 987 | mask = 0xFFu; |
@@ -998,8 +1004,8 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
998 | dst_end = dst + width; | 1004 | dst_end = dst + width; |
999 | do | 1005 | do |
1000 | { | 1006 | { |
1001 | const unsigned char *src_col = src++; | 1007 | const fb_data *src_col = src++; |
1002 | unsigned char *dst_col = dst++; | 1008 | fb_data *dst_col = dst++; |
1003 | unsigned mask_col = mask; | 1009 | unsigned mask_col = mask; |
1004 | unsigned data = 0; | 1010 | unsigned data = 0; |
1005 | 1011 | ||
@@ -1027,7 +1033,7 @@ void lcd_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
1027 | } | 1033 | } |
1028 | 1034 | ||
1029 | /* Draw a full native bitmap */ | 1035 | /* Draw a full native bitmap */ |
1030 | void lcd_bitmap(const unsigned char *src, int x, int y, int width, int height) | 1036 | void lcd_bitmap(const fb_data *src, int x, int y, int width, int height) |
1031 | { | 1037 | { |
1032 | lcd_bitmap_part(src, 0, 0, width, x, y, width, height); | 1038 | lcd_bitmap_part(src, 0, 0, width, x, y, width, height); |
1033 | } | 1039 | } |
@@ -1290,4 +1296,3 @@ static void scroll_thread(void) | |||
1290 | sleep(scroll_ticks); | 1296 | sleep(scroll_ticks); |
1291 | } | 1297 | } |
1292 | } | 1298 | } |
1293 | |||