diff options
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r-- | apps/plugins/lib/grey_core.c | 52 |
1 files changed, 2 insertions, 50 deletions
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c index 047e4cc160..bb6823522d 100644 --- a/apps/plugins/lib/grey_core.c +++ b/apps/plugins/lib/grey_core.c | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #include "plugin.h" | 28 | #include "plugin.h" |
29 | #include "grey.h" | 29 | #include "grey.h" |
30 | #include "fixedpoint.h" | ||
30 | 31 | ||
31 | #if defined(HAVE_ADJUSTABLE_CPU_FREQ) && \ | 32 | #if defined(HAVE_ADJUSTABLE_CPU_FREQ) && \ |
32 | (defined(CPU_PP) || (CONFIG_LCD == LCD_TL0350A)) | 33 | (defined(CPU_PP) || (CONFIG_LCD == LCD_TL0350A)) |
@@ -368,8 +369,6 @@ static const unsigned char lcdlinear[256] = { | |||
368 | 369 | ||
369 | /* Prototypes */ | 370 | /* Prototypes */ |
370 | static inline void _deferred_update(void) __attribute__ ((always_inline)); | 371 | static inline void _deferred_update(void) __attribute__ ((always_inline)); |
371 | static int exp_s16p16(int x); | ||
372 | static int log_s16p16(int x); | ||
373 | static void grey_screendump_hook(int fd); | 372 | static void grey_screendump_hook(int fd); |
374 | static void fill_gvalues(void); | 373 | static void fill_gvalues(void); |
375 | #ifdef SIMULATOR | 374 | #ifdef SIMULATOR |
@@ -501,53 +500,6 @@ static void _timer_isr(void) | |||
501 | 500 | ||
502 | #endif /* !SIMULATOR */ | 501 | #endif /* !SIMULATOR */ |
503 | 502 | ||
504 | /* fixed point exp() */ | ||
505 | static int exp_s16p16(int x) | ||
506 | { | ||
507 | int t; | ||
508 | int y = 0x00010000; | ||
509 | |||
510 | if (x < 0) x += 0xb1721, y >>= 16; | ||
511 | t = x - 0x58b91; if (t >= 0) x = t, y <<= 8; | ||
512 | t = x - 0x2c5c8; if (t >= 0) x = t, y <<= 4; | ||
513 | t = x - 0x162e4; if (t >= 0) x = t, y <<= 2; | ||
514 | t = x - 0x0b172; if (t >= 0) x = t, y <<= 1; | ||
515 | t = x - 0x067cd; if (t >= 0) x = t, y += y >> 1; | ||
516 | t = x - 0x03920; if (t >= 0) x = t, y += y >> 2; | ||
517 | t = x - 0x01e27; if (t >= 0) x = t, y += y >> 3; | ||
518 | t = x - 0x00f85; if (t >= 0) x = t, y += y >> 4; | ||
519 | t = x - 0x007e1; if (t >= 0) x = t, y += y >> 5; | ||
520 | t = x - 0x003f8; if (t >= 0) x = t, y += y >> 6; | ||
521 | t = x - 0x001fe; if (t >= 0) x = t, y += y >> 7; | ||
522 | y += ((y >> 8) * x) >> 8; | ||
523 | |||
524 | return y; | ||
525 | } | ||
526 | |||
527 | /* fixed point log() */ | ||
528 | static int log_s16p16(int x) | ||
529 | { | ||
530 | int t; | ||
531 | int y = 0xa65af; | ||
532 | |||
533 | if (x < 0x00008000) x <<=16, y -= 0xb1721; | ||
534 | if (x < 0x00800000) x <<= 8, y -= 0x58b91; | ||
535 | if (x < 0x08000000) x <<= 4, y -= 0x2c5c8; | ||
536 | if (x < 0x20000000) x <<= 2, y -= 0x162e4; | ||
537 | if (x < 0x40000000) x <<= 1, y -= 0x0b172; | ||
538 | t = x + (x >> 1); if ((t & 0x80000000) == 0) x = t, y -= 0x067cd; | ||
539 | t = x + (x >> 2); if ((t & 0x80000000) == 0) x = t, y -= 0x03920; | ||
540 | t = x + (x >> 3); if ((t & 0x80000000) == 0) x = t, y -= 0x01e27; | ||
541 | t = x + (x >> 4); if ((t & 0x80000000) == 0) x = t, y -= 0x00f85; | ||
542 | t = x + (x >> 5); if ((t & 0x80000000) == 0) x = t, y -= 0x007e1; | ||
543 | t = x + (x >> 6); if ((t & 0x80000000) == 0) x = t, y -= 0x003f8; | ||
544 | t = x + (x >> 7); if ((t & 0x80000000) == 0) x = t, y -= 0x001fe; | ||
545 | x = 0x80000000 - x; | ||
546 | y -= x >> 15; | ||
547 | |||
548 | return y; | ||
549 | } | ||
550 | |||
551 | static void fill_gvalues(void) | 503 | static void fill_gvalues(void) |
552 | { | 504 | { |
553 | int i; | 505 | int i; |
@@ -560,7 +512,7 @@ static void fill_gvalues(void) | |||
560 | #endif | 512 | #endif |
561 | for (i = 0; i < 256; i++) | 513 | for (i = 0; i < 256; i++) |
562 | { | 514 | { |
563 | data = exp_s16p16((_GREY_GAMMA * log_s16p16(i * 257 + 1)) >> 8) + 128; | 515 | data = fp16_exp((_GREY_GAMMA * fp16_log(i * 257 + 1)) >> 8) + 128; |
564 | data = (data - (data >> 8)) >> 8; /* approx. data /= 257 */ | 516 | data = (data - (data >> 8)) >> 8; /* approx. data /= 257 */ |
565 | data = ((lcdlinear[data ^ imask] ^ imask) << 7) + 127; | 517 | data = ((lcdlinear[data ^ imask] ^ imask) << 7) + 127; |
566 | _grey_info.gvalue[i] = (data + (data >> 8)) >> 8; | 518 | _grey_info.gvalue[i] = (data + (data >> 8)) >> 8; |