diff options
author | Steve Bavin <pondlife@pondlife.me> | 2008-11-26 08:26:13 +0000 |
---|---|---|
committer | Steve Bavin <pondlife@pondlife.me> | 2008-11-26 08:26:13 +0000 |
commit | f6847265804b650b007eb8ecdc86876214ee7302 (patch) | |
tree | 5f92d0097167f2e5c257b42427fd182e704ae4c1 /firmware | |
parent | 756bcc4bd53b34371c073c8468cbd8c01ffe094a (diff) | |
download | rockbox-f6847265804b650b007eb8ecdc86876214ee7302.tar.gz rockbox-f6847265804b650b007eb8ecdc86876214ee7302.zip |
Add software backlight fading for E100/H300/X5/D2, by Thomas Martitz and others - see FS#6800 for credits.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19221 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 4 | ||||
-rw-r--r-- | firmware/backlight-thread-fading.c | 87 | ||||
-rw-r--r-- | firmware/backlight.c | 126 | ||||
-rw-r--r-- | firmware/export/backlight-thread-fading.h | 46 | ||||
-rw-r--r-- | firmware/export/backlight.h | 8 | ||||
-rw-r--r-- | firmware/export/config-c200.h | 4 | ||||
-rw-r--r-- | firmware/export/config-cowond2.h | 4 | ||||
-rw-r--r-- | firmware/export/config-e200.h | 4 | ||||
-rw-r--r-- | firmware/export/config-h300.h | 5 | ||||
-rw-r--r-- | firmware/export/config-iaudiox5.h | 3 | ||||
-rw-r--r-- | firmware/target/arm/sandisk/backlight-c200_e200.c | 14 | ||||
-rw-r--r-- | firmware/target/arm/sandisk/backlight-target.h | 1 | ||||
-rw-r--r-- | firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c | 13 |
13 files changed, 286 insertions, 33 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 4e40d11cf7..47dcfe5c86 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -96,6 +96,10 @@ drivers/lcd-remote-2bit-vi.c | |||
96 | #endif /* LCD_REMOTE_DEPTH */ | 96 | #endif /* LCD_REMOTE_DEPTH */ |
97 | #endif /* HAVE_REMOTE_LCD */ | 97 | #endif /* HAVE_REMOTE_LCD */ |
98 | 98 | ||
99 | #ifdef USE_BACKLIGHT_SW_FADING | ||
100 | backlight-thread-fading.c | ||
101 | #endif /* USE_BACKLIGHT_SW_FADING */ | ||
102 | |||
99 | /* Misc. */ | 103 | /* Misc. */ |
100 | drivers/led.c | 104 | drivers/led.c |
101 | drivers/button.c | 105 | drivers/button.c |
diff --git a/firmware/backlight-thread-fading.c b/firmware/backlight-thread-fading.c new file mode 100644 index 0000000000..30778a9912 --- /dev/null +++ b/firmware/backlight-thread-fading.c | |||
@@ -0,0 +1,87 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Thomas Martitz | ||
11 | * Copyright (C) 2008 by Martin Ritter | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include <stdbool.h> | ||
24 | #include "backlight-target.h" | ||
25 | #include "config.h" | ||
26 | #include "system.h" | ||
27 | #include "backlight.h" | ||
28 | #include "backlight-thread-fading.h" | ||
29 | |||
30 | /* To adapt a target do: | ||
31 | * - make sure _backlight_on doesn't set the brightness to something other than | ||
32 | * the previous value (lowest brightness in most cases) | ||
33 | * - #define USE_BACKLIGHT_SW_FADING in config-<target>.h | ||
34 | */ | ||
35 | |||
36 | /* can be MIN_BRIGHTNESS_SETTING-1 */ | ||
37 | static int current_brightness = DEFAULT_BRIGHTNESS_SETTING; | ||
38 | |||
39 | void _backlight_fade_update_state(int brightness) | ||
40 | { | ||
41 | current_brightness = brightness; | ||
42 | } | ||
43 | |||
44 | /* returns true if fade is finished */ | ||
45 | static bool _backlight_fade_up(void) | ||
46 | { | ||
47 | if (LIKELY(current_brightness < backlight_brightness)) | ||
48 | { | ||
49 | _backlight_set_brightness(++current_brightness); | ||
50 | } | ||
51 | return(current_brightness >= backlight_brightness); | ||
52 | } | ||
53 | |||
54 | /* returns true if fade is finished */ | ||
55 | static bool _backlight_fade_down(void) | ||
56 | { | ||
57 | if (LIKELY(current_brightness > MIN_BRIGHTNESS_SETTING)) | ||
58 | { | ||
59 | _backlight_set_brightness(--current_brightness); | ||
60 | return false; | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | /* decrement once more, since backlight is off */ | ||
65 | current_brightness--; | ||
66 | _backlight_off(); | ||
67 | return true; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | bool _backlight_fade_step(int direction) | ||
72 | { | ||
73 | bool done; | ||
74 | switch(direction) | ||
75 | { | ||
76 | case FADING_UP: | ||
77 | done = _backlight_fade_up(); | ||
78 | break; | ||
79 | case FADING_DOWN: | ||
80 | done = _backlight_fade_down(); | ||
81 | break; | ||
82 | default: | ||
83 | done = true; | ||
84 | break; | ||
85 | } | ||
86 | return(done); | ||
87 | } | ||
diff --git a/firmware/backlight.c b/firmware/backlight.c index b8becfa69f..fe9c215af5 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | 10 | * Copyright (C) 2002 by Linus Nielsen Feltzing |
11 | * Additional work by Martin Ritter (2007) and Thomas Martitz (2008) | ||
12 | * for backlight thread fading | ||
11 | * | 13 | * |
12 | * This program is free software; you can redistribute it and/or | 14 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 15 | * modify it under the terms of the GNU General Public License |
@@ -46,6 +48,9 @@ | |||
46 | #define BACKLIGHT_FULL_INIT | 48 | #define BACKLIGHT_FULL_INIT |
47 | #endif | 49 | #endif |
48 | 50 | ||
51 | #ifdef USE_BACKLIGHT_SW_FADING | ||
52 | #include "backlight-thread-fading.h" | ||
53 | #endif | ||
49 | #ifdef SIMULATOR | 54 | #ifdef SIMULATOR |
50 | /* TODO: find a better way to do it but we need a kernel thread somewhere to | 55 | /* TODO: find a better way to do it but we need a kernel thread somewhere to |
51 | handle this */ | 56 | handle this */ |
@@ -134,6 +139,10 @@ static int backlight_timeout_plugged = 5*HZ; | |||
134 | static int backlight_on_button_hold = 0; | 139 | static int backlight_on_button_hold = 0; |
135 | #endif | 140 | #endif |
136 | 141 | ||
142 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
143 | int backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; | ||
144 | #endif | ||
145 | |||
137 | #ifdef HAVE_BUTTON_LIGHT | 146 | #ifdef HAVE_BUTTON_LIGHT |
138 | static int buttonlight_timer; | 147 | static int buttonlight_timer; |
139 | int _buttonlight_timeout = 5*HZ; | 148 | int _buttonlight_timeout = 5*HZ; |
@@ -221,6 +230,12 @@ void backlight_lcd_sleep_countdown(bool start) | |||
221 | } | 230 | } |
222 | #endif /* HAVE_LCD_SLEEP */ | 231 | #endif /* HAVE_LCD_SLEEP */ |
223 | 232 | ||
233 | #ifdef USE_BACKLIGHT_SW_FADING | ||
234 | static int backlight_fading_type = (FADING_UP|FADING_DOWN); | ||
235 | static int backlight_fading_state = NOT_FADING; | ||
236 | #endif | ||
237 | |||
238 | |||
224 | #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) | 239 | #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) |
225 | /* backlight fading */ | 240 | /* backlight fading */ |
226 | #define BL_PWM_INTERVAL 5 /* Cycle interval in ms */ | 241 | #define BL_PWM_INTERVAL 5 /* Cycle interval in ms */ |
@@ -397,6 +412,66 @@ void backlight_set_fade_out(int value) | |||
397 | } | 412 | } |
398 | #endif /* defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) */ | 413 | #endif /* defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) */ |
399 | 414 | ||
415 | #ifdef USE_BACKLIGHT_SW_FADING | ||
416 | |||
417 | void backlight_set_fade_out(bool value) | ||
418 | { | ||
419 | if(value) /* on */ | ||
420 | backlight_fading_type |= FADING_DOWN; | ||
421 | else | ||
422 | backlight_fading_type &= FADING_UP; | ||
423 | } | ||
424 | |||
425 | void backlight_set_fade_in(bool value) | ||
426 | { | ||
427 | if(value) /* on */ | ||
428 | backlight_fading_type |= FADING_UP; | ||
429 | else | ||
430 | backlight_fading_type &= FADING_DOWN; | ||
431 | } | ||
432 | |||
433 | static void backlight_set_up_fade_up(void) | ||
434 | { | ||
435 | if (backlight_fading_type & FADING_UP) | ||
436 | { | ||
437 | if (backlight_fading_state == NOT_FADING) | ||
438 | { | ||
439 | /* make sure the backlight is at lowest level */ | ||
440 | _backlight_on(); | ||
441 | } | ||
442 | backlight_fading_state = FADING_UP; | ||
443 | } | ||
444 | else | ||
445 | { | ||
446 | backlight_fading_state = NOT_FADING; | ||
447 | _backlight_fade_update_state(backlight_brightness); | ||
448 | _backlight_on(); | ||
449 | _backlight_set_brightness(backlight_brightness); | ||
450 | } | ||
451 | } | ||
452 | |||
453 | static void backlight_set_up_fade_down(void) | ||
454 | { | ||
455 | if (backlight_fading_type & FADING_DOWN) | ||
456 | { | ||
457 | backlight_fading_state = FADING_DOWN; | ||
458 | } | ||
459 | else | ||
460 | { | ||
461 | backlight_fading_state = NOT_FADING; | ||
462 | _backlight_fade_update_state(MIN_BRIGHTNESS_SETTING-1); | ||
463 | _backlight_off(); | ||
464 | /* h300/x5/d2 go to the last known brightness level at backight_on(),which | ||
465 | * should be the lowest level to keep fading up glitch free | ||
466 | * sansa e200/c200 make the backlight on only by setting the brightness, | ||
467 | * so this step would be noticeable */ | ||
468 | #if !defined(SANSA_E200) && !defined(SANSA_C200) | ||
469 | _backlight_set_brightness(MIN_BRIGHTNESS_SETTING); | ||
470 | #endif | ||
471 | } | ||
472 | } | ||
473 | #endif /* USE_BACKLIGHT_SW_FADING */ | ||
474 | |||
400 | /* Update state of backlight according to timeout setting */ | 475 | /* Update state of backlight according to timeout setting */ |
401 | static void backlight_update_state(void) | 476 | static void backlight_update_state(void) |
402 | { | 477 | { |
@@ -424,15 +499,25 @@ static void backlight_update_state(void) | |||
424 | backlight_timeout = backlight_timeout_normal; | 499 | backlight_timeout = backlight_timeout_normal; |
425 | 500 | ||
426 | /* Backlight == OFF in the setting? */ | 501 | /* Backlight == OFF in the setting? */ |
427 | if (backlight_timeout < 0) | 502 | if (UNLIKELY(backlight_timeout < 0)) |
428 | { | 503 | { |
429 | backlight_timer = 0; /* Disable the timeout */ | 504 | backlight_timer = 0; /* Disable the timeout */ |
505 | #ifdef USE_BACKLIGHT_SW_FADING | ||
506 | backlight_set_up_fade_down(); | ||
507 | /* necessary step to issue fading down when the setting is selected */ | ||
508 | queue_post(&backlight_queue, SYS_TIMEOUT, 0); | ||
509 | #else | ||
430 | _backlight_off(); | 510 | _backlight_off(); |
511 | #endif | ||
431 | } | 512 | } |
432 | else | 513 | else |
433 | { | 514 | { |
434 | backlight_timer = backlight_timeout; | 515 | backlight_timer = backlight_timeout; |
516 | #if defined(USE_BACKLIGHT_SW_FADING) | ||
517 | backlight_set_up_fade_up(); | ||
518 | #else | ||
435 | _backlight_on(); | 519 | _backlight_on(); |
520 | #endif | ||
436 | } | 521 | } |
437 | } | 522 | } |
438 | 523 | ||
@@ -478,7 +563,15 @@ void backlight_thread(void) | |||
478 | 563 | ||
479 | while(1) | 564 | while(1) |
480 | { | 565 | { |
481 | queue_wait(&backlight_queue, &ev); | 566 | #if defined(USE_BACKLIGHT_SW_FADING) |
567 | if (backlight_fading_state) | ||
568 | queue_wait_w_tmo(&backlight_queue, &ev, FADE_DELAY); | ||
569 | else | ||
570 | #endif | ||
571 | queue_wait(&backlight_queue, &ev); | ||
572 | /* | ||
573 | #endif | ||
574 | */ | ||
482 | switch(ev.id) | 575 | switch(ev.id) |
483 | { /* These events must always be processed */ | 576 | { /* These events must always be processed */ |
484 | #ifdef _BACKLIGHT_FADE_BOOST | 577 | #ifdef _BACKLIGHT_FADE_BOOST |
@@ -558,9 +651,12 @@ void backlight_thread(void) | |||
558 | 651 | ||
559 | case BACKLIGHT_OFF: | 652 | case BACKLIGHT_OFF: |
560 | backlight_timer = 0; /* Disable the timeout */ | 653 | backlight_timer = 0; /* Disable the timeout */ |
654 | #ifndef USE_BACKLIGHT_SW_FADING | ||
561 | _backlight_off(); | 655 | _backlight_off(); |
656 | #else | ||
657 | backlight_set_up_fade_down(); | ||
658 | #endif /* USE_BACKLIGHT_SW_FADING */ | ||
562 | break; | 659 | break; |
563 | |||
564 | #ifdef HAVE_LCD_SLEEP | 660 | #ifdef HAVE_LCD_SLEEP |
565 | case LCD_SLEEP: | 661 | case LCD_SLEEP: |
566 | lcd_sleep(); | 662 | lcd_sleep(); |
@@ -589,6 +685,12 @@ void backlight_thread(void) | |||
589 | remote_backlight_update_state(); | 685 | remote_backlight_update_state(); |
590 | #endif | 686 | #endif |
591 | break; | 687 | break; |
688 | #if defined(USE_BACKLIGHT_SW_FADING) | ||
689 | case SYS_TIMEOUT: | ||
690 | if ((_backlight_fade_step(backlight_fading_state))) | ||
691 | backlight_fading_state = NOT_FADING; | ||
692 | break; | ||
693 | #endif /* USE_BACKLIGHT_SW_FADING */ | ||
592 | } | 694 | } |
593 | } /* end while */ | 695 | } /* end while */ |
594 | } | 696 | } |
@@ -597,8 +699,7 @@ static void backlight_tick(void) | |||
597 | { | 699 | { |
598 | if(backlight_timer) | 700 | if(backlight_timer) |
599 | { | 701 | { |
600 | backlight_timer--; | 702 | if(--backlight_timer == 0) |
601 | if(backlight_timer == 0) | ||
602 | { | 703 | { |
603 | backlight_off(); | 704 | backlight_off(); |
604 | } | 705 | } |
@@ -606,20 +707,17 @@ static void backlight_tick(void) | |||
606 | #ifdef HAVE_LCD_SLEEP | 707 | #ifdef HAVE_LCD_SLEEP |
607 | else if(lcd_sleep_timer) | 708 | else if(lcd_sleep_timer) |
608 | { | 709 | { |
609 | lcd_sleep_timer--; | 710 | if(--lcd_sleep_timer == 0) |
610 | if(lcd_sleep_timer == 0) | ||
611 | { | 711 | { |
612 | /* Queue on bl thread or freeze! */ | 712 | /* Queue on bl thread or freeze! */ |
613 | queue_post(&backlight_queue, LCD_SLEEP, 0); | 713 | queue_post(&backlight_queue, LCD_SLEEP, 0); |
614 | } | 714 | } |
615 | } | 715 | } |
616 | #endif /* HAVE_LCD_SLEEP */ | 716 | #endif /* HAVE_LCD_SLEEP */ |
617 | |||
618 | #ifdef HAVE_REMOTE_LCD | 717 | #ifdef HAVE_REMOTE_LCD |
619 | if(remote_backlight_timer) | 718 | if(remote_backlight_timer) |
620 | { | 719 | { |
621 | remote_backlight_timer--; | 720 | if(--remote_backlight_timer == 0) |
622 | if(remote_backlight_timer == 0) | ||
623 | { | 721 | { |
624 | remote_backlight_off(); | 722 | remote_backlight_off(); |
625 | } | 723 | } |
@@ -628,8 +726,7 @@ static void backlight_tick(void) | |||
628 | #ifdef HAVE_BUTTON_LIGHT | 726 | #ifdef HAVE_BUTTON_LIGHT |
629 | if (buttonlight_timer) | 727 | if (buttonlight_timer) |
630 | { | 728 | { |
631 | buttonlight_timer--; | 729 | if (--buttonlight_timer == 0) |
632 | if (buttonlight_timer == 0) | ||
633 | { | 730 | { |
634 | buttonlight_off(); | 731 | buttonlight_off(); |
635 | } | 732 | } |
@@ -832,6 +929,11 @@ void backlight_set_brightness(int val) | |||
832 | val = MAX_BRIGHTNESS_SETTING; | 929 | val = MAX_BRIGHTNESS_SETTING; |
833 | 930 | ||
834 | _backlight_set_brightness(val); | 931 | _backlight_set_brightness(val); |
932 | backlight_brightness = val; | ||
933 | #ifdef USE_BACKLIGHT_SW_FADING | ||
934 | /* receive backlight brightness */ | ||
935 | _backlight_fade_update_state(val); | ||
936 | #endif | ||
835 | } | 937 | } |
836 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ | 938 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ |
837 | 939 | ||
diff --git a/firmware/export/backlight-thread-fading.h b/firmware/export/backlight-thread-fading.h new file mode 100644 index 0000000000..ca9c195480 --- /dev/null +++ b/firmware/export/backlight-thread-fading.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id:$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Will Robertson | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef BACKLIGHT_THREAD_FADING_H | ||
23 | #define BACKLIGHT_THREAD_FADING_H | ||
24 | |||
25 | #include "config.h" | ||
26 | |||
27 | #ifdef USE_BACKLIGHT_SW_FADING | ||
28 | |||
29 | /* delay supposed to be MAX_BRIGHTNESS_SETTING*2 rounded to the next multiple | ||
30 | * of 5, however not more than 40 */ | ||
31 | #define _FADE_DELAY (((MAX_BRIGHTNESS_SETTING*2+4)/5)*5) | ||
32 | #define FADE_DELAY (HZ/(MIN(_FADE_DELAY, 40))) | ||
33 | |||
34 | void _backlight_fade_update_state(int brightness); | ||
35 | bool _backlight_fade_step(int direction); | ||
36 | |||
37 | /* enum used for both, fading state and fading type selected through the settings */ | ||
38 | |||
39 | enum { | ||
40 | NOT_FADING = 0, | ||
41 | FADING_UP, | ||
42 | FADING_DOWN, | ||
43 | }; | ||
44 | #endif /* USE_BACKLIGHT_SW_FADING */ | ||
45 | |||
46 | #endif /* _BACKLIGHT_THREAD_FADING_ */ | ||
diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h index e0980658dc..a177fe740f 100644 --- a/firmware/export/backlight.h +++ b/firmware/export/backlight.h | |||
@@ -34,10 +34,16 @@ void backlight_close(void); | |||
34 | 34 | ||
35 | int backlight_get_current_timeout(void); | 35 | int backlight_get_current_timeout(void); |
36 | 36 | ||
37 | #ifdef HAVE_BACKLIGHT_PWM_FADING | 37 | #if defined(HAVE_BACKLIGHT_PWM_FADING) |
38 | void backlight_set_fade_in(int value); | 38 | void backlight_set_fade_in(int value); |
39 | void backlight_set_fade_out(int value); | 39 | void backlight_set_fade_out(int value); |
40 | #endif | 40 | #endif |
41 | #ifdef USE_BACKLIGHT_SW_FADING | ||
42 | void backlight_set_fade_in(bool value); | ||
43 | void backlight_set_fade_out(bool value); | ||
44 | #endif | ||
45 | |||
46 | extern int backlight_brightness; | ||
41 | 47 | ||
42 | void backlight_set_timeout_plugged(int value); | 48 | void backlight_set_timeout_plugged(int value); |
43 | 49 | ||
diff --git a/firmware/export/config-c200.h b/firmware/export/config-c200.h index a96b9c7ef8..8e26585e94 100644 --- a/firmware/export/config-c200.h +++ b/firmware/export/config-c200.h | |||
@@ -132,6 +132,10 @@ | |||
132 | /** Non-simulator section **/ | 132 | /** Non-simulator section **/ |
133 | #ifndef SIMULATOR | 133 | #ifndef SIMULATOR |
134 | 134 | ||
135 | /* define this if the backlight thread is used for fade, not for sim, needs | ||
136 | * HAVE_BACKLIGHT_BRIGHTNESS */ | ||
137 | #define USE_BACKLIGHT_SW_FADING | ||
138 | |||
135 | /* Define this if you have a PortalPlayer PP5024 */ | 139 | /* Define this if you have a PortalPlayer PP5024 */ |
136 | #define CONFIG_CPU PP5022 | 140 | #define CONFIG_CPU PP5022 |
137 | 141 | ||
diff --git a/firmware/export/config-cowond2.h b/firmware/export/config-cowond2.h index fd696aae66..b723201340 100644 --- a/firmware/export/config-cowond2.h +++ b/firmware/export/config-cowond2.h | |||
@@ -122,6 +122,10 @@ | |||
122 | 122 | ||
123 | #ifndef SIMULATOR | 123 | #ifndef SIMULATOR |
124 | 124 | ||
125 | /* define this if the backlight thread is used for fade, not for sim, needs | ||
126 | * HAVE_BACKLIGHT_BRIGHTNESS */ | ||
127 | #define USE_BACKLIGHT_SW_FADING | ||
128 | |||
125 | /* Define this if you have a TCC7801 */ | 129 | /* Define this if you have a TCC7801 */ |
126 | #define CONFIG_CPU TCC7801 | 130 | #define CONFIG_CPU TCC7801 |
127 | 131 | ||
diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h index 075f490ee4..d9bebef9bc 100644 --- a/firmware/export/config-e200.h +++ b/firmware/export/config-e200.h | |||
@@ -129,6 +129,10 @@ | |||
129 | /** Non-simulator section **/ | 129 | /** Non-simulator section **/ |
130 | #ifndef SIMULATOR | 130 | #ifndef SIMULATOR |
131 | 131 | ||
132 | /* define this if the backlight thread is used for fade, not for sim, needs | ||
133 | * HAVE_BACKLIGHT_BRIGHTNESS */ | ||
134 | #define USE_BACKLIGHT_SW_FADING | ||
135 | |||
132 | /* Define this if you have a PortalPlayer PP5024 */ | 136 | /* Define this if you have a PortalPlayer PP5024 */ |
133 | #define CONFIG_CPU PP5024 | 137 | #define CONFIG_CPU PP5024 |
134 | 138 | ||
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h index f45b694fe0..2af426f048 100644 --- a/firmware/export/config-h300.h +++ b/firmware/export/config-h300.h | |||
@@ -114,6 +114,11 @@ | |||
114 | 114 | ||
115 | #ifndef SIMULATOR | 115 | #ifndef SIMULATOR |
116 | 116 | ||
117 | /* define this if the backlight thread is used for fade, not for sim, needs | ||
118 | * HAVE_BACKLIGHT_BRIGHTNESS */ | ||
119 | #define USE_BACKLIGHT_SW_FADING | ||
120 | |||
121 | |||
117 | /* Define this if your LCD can be enabled/disabled */ | 122 | /* Define this if your LCD can be enabled/disabled */ |
118 | #define HAVE_LCD_ENABLE | 123 | #define HAVE_LCD_ENABLE |
119 | 124 | ||
diff --git a/firmware/export/config-iaudiox5.h b/firmware/export/config-iaudiox5.h index cdae55af4f..089d219534 100644 --- a/firmware/export/config-iaudiox5.h +++ b/firmware/export/config-iaudiox5.h | |||
@@ -124,6 +124,9 @@ | |||
124 | 124 | ||
125 | #ifndef SIMULATOR | 125 | #ifndef SIMULATOR |
126 | 126 | ||
127 | /* define this if the backlight thread is used for fade, not for sim */ | ||
128 | #define USE_BACKLIGHT_SW_FADING | ||
129 | |||
127 | /* Define this if your LCD can set contrast */ | 130 | /* Define this if your LCD can set contrast */ |
128 | #define HAVE_LCD_CONTRAST | 131 | #define HAVE_LCD_CONTRAST |
129 | 132 | ||
diff --git a/firmware/target/arm/sandisk/backlight-c200_e200.c b/firmware/target/arm/sandisk/backlight-c200_e200.c index b3984ca9ad..67e0cddac9 100644 --- a/firmware/target/arm/sandisk/backlight-c200_e200.c +++ b/firmware/target/arm/sandisk/backlight-c200_e200.c | |||
@@ -26,16 +26,9 @@ | |||
26 | #include "ascodec.h" | 26 | #include "ascodec.h" |
27 | #include "as3514.h" | 27 | #include "as3514.h" |
28 | 28 | ||
29 | static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; | ||
30 | |||
31 | void _backlight_set_brightness(int brightness) | 29 | void _backlight_set_brightness(int brightness) |
32 | { | 30 | { |
33 | backlight_brightness = brightness; | 31 | ascodec_write(AS3514_DCDC15, brightness); |
34 | |||
35 | if (brightness > 0) | ||
36 | _backlight_on(); | ||
37 | else | ||
38 | _backlight_off(); | ||
39 | } | 32 | } |
40 | 33 | ||
41 | void _backlight_on(void) | 34 | void _backlight_on(void) |
@@ -46,7 +39,10 @@ void _backlight_on(void) | |||
46 | #ifdef HAVE_LCD_ENABLE | 39 | #ifdef HAVE_LCD_ENABLE |
47 | lcd_enable(true); /* power on lcd + visible display */ | 40 | lcd_enable(true); /* power on lcd + visible display */ |
48 | #endif | 41 | #endif |
49 | ascodec_write(AS3514_DCDC15, backlight_brightness); | 42 | #ifndef USE_BACKLIGHT_SW_FADING |
43 | /* that part ain't useful when fading */ | ||
44 | _backlight_set_brightness(backlight_brightness); | ||
45 | #endif | ||
50 | } | 46 | } |
51 | 47 | ||
52 | void _backlight_off(void) | 48 | void _backlight_off(void) |
diff --git a/firmware/target/arm/sandisk/backlight-target.h b/firmware/target/arm/sandisk/backlight-target.h index 21fad6d22e..1f5e475a42 100644 --- a/firmware/target/arm/sandisk/backlight-target.h +++ b/firmware/target/arm/sandisk/backlight-target.h | |||
@@ -25,7 +25,6 @@ | |||
25 | void _backlight_on(void); | 25 | void _backlight_on(void); |
26 | void _backlight_off(void); | 26 | void _backlight_off(void); |
27 | void _backlight_set_brightness(int brightness); | 27 | void _backlight_set_brightness(int brightness); |
28 | int __backlight_is_on(void); | ||
29 | 28 | ||
30 | void _buttonlight_on(void); | 29 | void _buttonlight_on(void); |
31 | void _buttonlight_off(void); | 30 | void _buttonlight_off(void); |
diff --git a/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c b/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c index 6d286aee8f..39a9abf073 100644 --- a/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c +++ b/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c | |||
@@ -24,27 +24,20 @@ | |||
24 | #include "pcf50606.h" | 24 | #include "pcf50606.h" |
25 | #include "tcc780x.h" | 25 | #include "tcc780x.h" |
26 | 26 | ||
27 | static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; | ||
28 | |||
29 | int _backlight_init(void) | 27 | int _backlight_init(void) |
30 | { | 28 | { |
31 | _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING); | 29 | _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING); |
30 | /* set backlight on by default, since the screen is unreadable without it */ | ||
31 | _backlight_on(); | ||
32 | return true; | 32 | return true; |
33 | } | 33 | } |
34 | 34 | ||
35 | void _backlight_set_brightness(int brightness) | 35 | void _backlight_set_brightness(int brightness) |
36 | { | 36 | { |
37 | backlight_brightness = brightness; | ||
38 | |||
39 | int level = disable_irq_save(); | 37 | int level = disable_irq_save(); |
40 | pcf50606_write(PCF5060X_PWMC1, 0xe1 | (14-backlight_brightness)<<1); | 38 | pcf50606_write(PCF5060X_PWMC1, 0xe1 | (MAX_BRIGHTNESS_SETTING-brightness)<<1); |
41 | pcf50606_write(PCF5060X_GPOC1, 0x3); | 39 | pcf50606_write(PCF5060X_GPOC1, 0x3); |
42 | restore_irq(level); | 40 | restore_irq(level); |
43 | |||
44 | if (brightness > 0) | ||
45 | _backlight_on(); | ||
46 | else | ||
47 | _backlight_off(); | ||
48 | } | 41 | } |
49 | 42 | ||
50 | void _backlight_on(void) | 43 | void _backlight_on(void) |