diff options
-rw-r--r-- | apps/menus/display_menu.c | 4 | ||||
-rw-r--r-- | apps/settings.c | 2 | ||||
-rw-r--r-- | apps/settings.h | 2 | ||||
-rw-r--r-- | apps/settings_list.c | 4 | ||||
-rw-r--r-- | firmware/backlight.c | 62 | ||||
-rw-r--r-- | firmware/export/backlight.h | 8 | ||||
-rw-r--r-- | firmware/export/config-c200.h | 1 | ||||
-rw-r--r-- | firmware/export/config-e200.h | 1 | ||||
-rw-r--r-- | firmware/export/config-gigabeat.h | 7 | ||||
-rw-r--r-- | firmware/export/config-h10.h | 1 | ||||
-rw-r--r-- | firmware/export/config-iaudiox5.h | 1 | ||||
-rw-r--r-- | firmware/export/config-mrobe100.h | 1 | ||||
-rw-r--r-- | firmware/target/arm/iriver/h10/backlight-h10.c | 19 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c | 16 | ||||
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c | 38 | ||||
-rw-r--r-- | firmware/target/arm/sandisk/backlight-c200_e200.c | 21 |
16 files changed, 118 insertions, 70 deletions
diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c index 57d2f72be5..5ba8c2ecb1 100644 --- a/apps/menus/display_menu.c +++ b/apps/menus/display_menu.c | |||
@@ -94,7 +94,7 @@ MENUITEM_SETTING(backlight_fade_out, &global_settings.backlight_fade_out, NULL); | |||
94 | MENUITEM_SETTING(bl_filter_first_keypress, | 94 | MENUITEM_SETTING(bl_filter_first_keypress, |
95 | &global_settings.bl_filter_first_keypress, | 95 | &global_settings.bl_filter_first_keypress, |
96 | filterfirstkeypress_callback); | 96 | filterfirstkeypress_callback); |
97 | #ifdef HAVE_LCD_SLEEP | 97 | #ifdef HAVE_LCD_SLEEP_SETTING |
98 | MENUITEM_SETTING(lcd_sleep_after_backlight_off, | 98 | MENUITEM_SETTING(lcd_sleep_after_backlight_off, |
99 | &global_settings.lcd_sleep_after_backlight_off, NULL); | 99 | &global_settings.lcd_sleep_after_backlight_off, NULL); |
100 | #endif | 100 | #endif |
@@ -130,7 +130,7 @@ MAKE_MENU(lcd_settings,ID2P(LANG_LCD_MENU), | |||
130 | ,&backlight_fade_in, &backlight_fade_out | 130 | ,&backlight_fade_in, &backlight_fade_out |
131 | # endif | 131 | # endif |
132 | ,&bl_filter_first_keypress | 132 | ,&bl_filter_first_keypress |
133 | # ifdef HAVE_LCD_SLEEP | 133 | # ifdef HAVE_LCD_SLEEP_SETTING |
134 | ,&lcd_sleep_after_backlight_off | 134 | ,&lcd_sleep_after_backlight_off |
135 | # endif | 135 | # endif |
136 | # ifdef HAVE_BACKLIGHT_BRIGHTNESS | 136 | # ifdef HAVE_BACKLIGHT_BRIGHTNESS |
diff --git a/apps/settings.c b/apps/settings.c index 9fb1f12d0d..1a857eacd8 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -924,7 +924,7 @@ void settings_apply(bool read_disk) | |||
924 | #ifdef HAS_BUTTON_HOLD | 924 | #ifdef HAS_BUTTON_HOLD |
925 | backlight_set_on_button_hold(global_settings.backlight_on_button_hold); | 925 | backlight_set_on_button_hold(global_settings.backlight_on_button_hold); |
926 | #endif | 926 | #endif |
927 | #ifdef HAVE_LCD_SLEEP | 927 | #ifdef HAVE_LCD_SLEEP_SETTING |
928 | lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off); | 928 | lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off); |
929 | #endif | 929 | #endif |
930 | #endif /* HAVE_BACKLIGHT */ | 930 | #endif /* HAVE_BACKLIGHT */ |
diff --git a/apps/settings.h b/apps/settings.h index 4ade11b11d..9a9169a74f 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -646,7 +646,7 @@ struct user_settings | |||
646 | int backlight_on_button_hold; /* what to do with backlight when hold | 646 | int backlight_on_button_hold; /* what to do with backlight when hold |
647 | switch is on */ | 647 | switch is on */ |
648 | #endif | 648 | #endif |
649 | #ifdef HAVE_LCD_SLEEP | 649 | #ifdef HAVE_LCD_SLEEP_SETTING |
650 | int lcd_sleep_after_backlight_off; /* when to put lcd to sleep after backlight | 650 | int lcd_sleep_after_backlight_off; /* when to put lcd to sleep after backlight |
651 | has turned off */ | 651 | has turned off */ |
652 | #endif | 652 | #endif |
diff --git a/apps/settings_list.c b/apps/settings_list.c index 2ef90afc94..a08639996c 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c | |||
@@ -1126,7 +1126,7 @@ const struct settings_list settings[] = { | |||
1126 | ID2P(LANG_NORMAL), ID2P(LANG_OFF), ID2P(LANG_ON)), | 1126 | ID2P(LANG_NORMAL), ID2P(LANG_OFF), ID2P(LANG_ON)), |
1127 | #endif | 1127 | #endif |
1128 | 1128 | ||
1129 | #ifdef HAVE_LCD_SLEEP | 1129 | #ifdef HAVE_LCD_SLEEP_SETTING |
1130 | STRINGCHOICE_SETTING(0, lcd_sleep_after_backlight_off, | 1130 | STRINGCHOICE_SETTING(0, lcd_sleep_after_backlight_off, |
1131 | LANG_LCD_SLEEP_AFTER_BACKLIGHT_OFF, 3, | 1131 | LANG_LCD_SLEEP_AFTER_BACKLIGHT_OFF, 3, |
1132 | "lcd sleep after backlight off", | 1132 | "lcd sleep after backlight off", |
@@ -1137,7 +1137,7 @@ const struct settings_list settings[] = { | |||
1137 | TALK_ID(20, UNIT_SEC), TALK_ID(30, UNIT_SEC), | 1137 | TALK_ID(20, UNIT_SEC), TALK_ID(30, UNIT_SEC), |
1138 | TALK_ID(45, UNIT_SEC),TALK_ID(60, UNIT_SEC), | 1138 | TALK_ID(45, UNIT_SEC),TALK_ID(60, UNIT_SEC), |
1139 | TALK_ID(90, UNIT_SEC)), | 1139 | TALK_ID(90, UNIT_SEC)), |
1140 | #endif | 1140 | #endif /* HAVE_LCD_SLEEP_SETTING */ |
1141 | #endif /* HAVE_BACKLIGHT */ | 1141 | #endif /* HAVE_BACKLIGHT */ |
1142 | 1142 | ||
1143 | OFFON_SETTING(0, hold_lr_for_scroll_in_list, -1, true, | 1143 | OFFON_SETTING(0, hold_lr_for_scroll_in_list, -1, true, |
diff --git a/firmware/backlight.c b/firmware/backlight.c index 74cdee1205..edd78ec7ef 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c | |||
@@ -184,14 +184,41 @@ static int remote_backlight_on_button_hold = 0; | |||
184 | #endif /* HAVE_REMOTE_LCD */ | 184 | #endif /* HAVE_REMOTE_LCD */ |
185 | 185 | ||
186 | #ifdef HAVE_LCD_SLEEP | 186 | #ifdef HAVE_LCD_SLEEP |
187 | #ifdef HAVE_LCD_SLEEP_SETTING | ||
187 | const signed char lcd_sleep_timeout_value[10] = | 188 | const signed char lcd_sleep_timeout_value[10] = |
188 | { | 189 | { |
189 | -1, 0, 5, 10, 15, 20, 30, 45, 60, 90 | 190 | -1, 0, 5, 10, 15, 20, 30, 45, 60, 90 |
190 | }; | 191 | }; |
191 | int _lcd_sleep_timer; | 192 | static int lcd_sleep_timeout = 10*HZ; |
192 | int _lcd_sleep_timeout = 10*HZ; | 193 | #else |
194 | /* Target defines needed value */ | ||
195 | static const int lcd_sleep_timeout = LCD_SLEEP_TIMEOUT; | ||
193 | #endif | 196 | #endif |
194 | 197 | ||
198 | static int lcd_sleep_timer = 0; | ||
199 | |||
200 | void backlight_lcd_sleep_countdown(bool start) | ||
201 | { | ||
202 | if (!start) | ||
203 | { | ||
204 | /* Cancel the LCD sleep countdown */ | ||
205 | lcd_sleep_timer = 0; | ||
206 | return; | ||
207 | } | ||
208 | |||
209 | /* Start LCD sleep countdown */ | ||
210 | if (lcd_sleep_timeout < 0) | ||
211 | { | ||
212 | lcd_sleep_timer = 0; /* Setting == Always */ | ||
213 | lcd_sleep(); | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | lcd_sleep_timer = lcd_sleep_timeout; | ||
218 | } | ||
219 | } | ||
220 | #endif /* HAVE_LCD_SLEEP */ | ||
221 | |||
195 | #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) | 222 | #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) |
196 | /* backlight fading */ | 223 | /* backlight fading */ |
197 | #define BL_PWM_INTERVAL 5 /* Cycle interval in ms */ | 224 | #define BL_PWM_INTERVAL 5 /* Cycle interval in ms */ |
@@ -328,8 +355,9 @@ static void _backlight_on(void) | |||
328 | bl_dim_fraction = (BL_PWM_COUNT<<16); | 355 | bl_dim_fraction = (BL_PWM_COUNT<<16); |
329 | _backlight_on_normal(); | 356 | _backlight_on_normal(); |
330 | } | 357 | } |
358 | |||
331 | #ifdef HAVE_LCD_SLEEP | 359 | #ifdef HAVE_LCD_SLEEP |
332 | _lcd_sleep_timer = 0; /* LCD should be awake already */ | 360 | backlight_lcd_sleep(false); |
333 | #endif | 361 | #endif |
334 | } | 362 | } |
335 | 363 | ||
@@ -344,15 +372,9 @@ static void _backlight_off(void) | |||
344 | bl_dim_target = bl_dim_fraction = 0; | 372 | bl_dim_target = bl_dim_fraction = 0; |
345 | _backlight_off_normal(); | 373 | _backlight_off_normal(); |
346 | } | 374 | } |
375 | |||
347 | #ifdef HAVE_LCD_SLEEP | 376 | #ifdef HAVE_LCD_SLEEP |
348 | /* Start LCD sleep countdown */ | 377 | backlight_start_lcd_sleep_counter(false); |
349 | if (_lcd_sleep_timeout < 0) | ||
350 | { | ||
351 | _lcd_sleep_timer = 0; /* Setting == Always */ | ||
352 | lcd_sleep(); | ||
353 | } | ||
354 | else | ||
355 | _lcd_sleep_timer = _lcd_sleep_timeout; | ||
356 | #endif | 378 | #endif |
357 | } | 379 | } |
358 | 380 | ||
@@ -580,10 +602,10 @@ static void backlight_tick(void) | |||
580 | } | 602 | } |
581 | } | 603 | } |
582 | #ifdef HAVE_LCD_SLEEP | 604 | #ifdef HAVE_LCD_SLEEP |
583 | else if(_lcd_sleep_timer) | 605 | else if(lcd_sleep_timer) |
584 | { | 606 | { |
585 | _lcd_sleep_timer--; | 607 | lcd_sleep_timer--; |
586 | if(_lcd_sleep_timer == 0) | 608 | if(lcd_sleep_timer == 0) |
587 | { | 609 | { |
588 | /* Queue on bl thread or freeze! */ | 610 | /* Queue on bl thread or freeze! */ |
589 | queue_post(&backlight_queue, LCD_SLEEP, 0); | 611 | queue_post(&backlight_queue, LCD_SLEEP, 0); |
@@ -716,26 +738,26 @@ void backlight_set_on_button_hold(int index) | |||
716 | } | 738 | } |
717 | #endif /* HAS_BUTTON_HOLD */ | 739 | #endif /* HAS_BUTTON_HOLD */ |
718 | 740 | ||
719 | #ifdef HAVE_LCD_SLEEP | 741 | #ifdef HAVE_LCD_SLEEP_SETTING |
720 | void lcd_set_sleep_after_backlight_off(int index) | 742 | void lcd_set_sleep_after_backlight_off(int index) |
721 | { | 743 | { |
722 | if ((unsigned)index >= sizeof(lcd_sleep_timeout_value)) | 744 | if ((unsigned)index >= sizeof(lcd_sleep_timeout_value)) |
723 | /* if given a weird value, use default */ | 745 | /* if given a weird value, use default */ |
724 | index = 3; | 746 | index = 3; |
725 | 747 | ||
726 | _lcd_sleep_timeout = HZ * lcd_sleep_timeout_value[index]; | 748 | lcd_sleep_timeout = HZ * lcd_sleep_timeout_value[index]; |
727 | 749 | ||
728 | if (backlight_timer > 0 || backlight_get_current_timeout() == 0) | 750 | if (backlight_timer > 0 || backlight_get_current_timeout() == 0) |
729 | /* Timer will be set when bl turns off or bl set to on. */ | 751 | /* Timer will be set when bl turns off or bl set to on. */ |
730 | return; | 752 | return; |
731 | 753 | ||
732 | /* Backlight is Off */ | 754 | /* Backlight is Off */ |
733 | if (_lcd_sleep_timeout < 0) | 755 | if (lcd_sleep_timeout < 0) |
734 | _lcd_sleep_timer = 1; /* Always - sleep next tick */ | 756 | lcd_sleep_timer = 1; /* Always - sleep next tick */ |
735 | else | 757 | else |
736 | _lcd_sleep_timer = _lcd_sleep_timeout; /* Never, other */ | 758 | lcd_sleep_timer = lcd_sleep_timeout; /* Never, other */ |
737 | } | 759 | } |
738 | #endif /* HAVE_LCD_SLEEP */ | 760 | #endif /* HAVE_LCD_SLEEP_SETTING */ |
739 | 761 | ||
740 | #ifdef HAVE_REMOTE_LCD | 762 | #ifdef HAVE_REMOTE_LCD |
741 | void remote_backlight_on(void) | 763 | void remote_backlight_on(void) |
diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h index 895328d98e..b09c98e7d2 100644 --- a/firmware/export/backlight.h +++ b/firmware/export/backlight.h | |||
@@ -45,8 +45,10 @@ void backlight_set_on_button_hold(int index); | |||
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #ifdef HAVE_LCD_SLEEP | 47 | #ifdef HAVE_LCD_SLEEP |
48 | void backlight_lcd_sleep_countdown(bool start); | ||
49 | #ifdef HAVE_LCD_SLEEP_SETTING | ||
48 | void lcd_set_sleep_after_backlight_off(int index); | 50 | void lcd_set_sleep_after_backlight_off(int index); |
49 | extern const signed char lcd_sleep_timeout_value[]; | 51 | #endif |
50 | #endif | 52 | #endif |
51 | 53 | ||
52 | #else /* !HAVE_BACKLIGHT */ | 54 | #else /* !HAVE_BACKLIGHT */ |
@@ -89,9 +91,5 @@ void buttonlight_set_timeout(int value); | |||
89 | #ifdef HAVE_BUTTON_LIGHT | 91 | #ifdef HAVE_BUTTON_LIGHT |
90 | extern int _buttonlight_timeout; | 92 | extern int _buttonlight_timeout; |
91 | #endif | 93 | #endif |
92 | #ifdef HAVE_LCD_SLEEP | ||
93 | extern int _lcd_sleep_timer; | ||
94 | extern int _lcd_sleep_timeout; | ||
95 | #endif | ||
96 | 94 | ||
97 | #endif /* BACKLIGHT_H */ | 95 | #endif /* BACKLIGHT_H */ |
diff --git a/firmware/export/config-c200.h b/firmware/export/config-c200.h index 9f3e78f611..81b79373e4 100644 --- a/firmware/export/config-c200.h +++ b/firmware/export/config-c200.h | |||
@@ -53,6 +53,7 @@ | |||
53 | /* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE | 53 | /* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE |
54 | should be defined as well. */ | 54 | should be defined as well. */ |
55 | /* TODO: #define HAVE_LCD_SLEEP */ | 55 | /* TODO: #define HAVE_LCD_SLEEP */ |
56 | /* TODO: #define HAVE_LCD_SLEEP_SETTING <= optional */ | ||
56 | 57 | ||
57 | /* define this if you can flip your LCD */ | 58 | /* define this if you can flip your LCD */ |
58 | #define HAVE_LCD_FLIP | 59 | #define HAVE_LCD_FLIP |
diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h index 8d42dd2618..58b736e27c 100644 --- a/firmware/export/config-e200.h +++ b/firmware/export/config-e200.h | |||
@@ -53,6 +53,7 @@ | |||
53 | /* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE | 53 | /* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE |
54 | should be defined as well. */ | 54 | should be defined as well. */ |
55 | #define HAVE_LCD_SLEEP | 55 | #define HAVE_LCD_SLEEP |
56 | #define HAVE_LCD_SLEEP_SETTING | ||
56 | 57 | ||
57 | /* define this if you can flip your LCD */ | 58 | /* define this if you can flip your LCD */ |
58 | #define HAVE_LCD_FLIP | 59 | #define HAVE_LCD_FLIP |
diff --git a/firmware/export/config-gigabeat.h b/firmware/export/config-gigabeat.h index a100a6a724..816796b706 100644 --- a/firmware/export/config-gigabeat.h +++ b/firmware/export/config-gigabeat.h | |||
@@ -41,6 +41,13 @@ | |||
41 | /* Define this if your LCD can be enabled/disabled */ | 41 | /* Define this if your LCD can be enabled/disabled */ |
42 | #define HAVE_LCD_ENABLE | 42 | #define HAVE_LCD_ENABLE |
43 | 43 | ||
44 | /* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE | ||
45 | should be defined as well. */ | ||
46 | #define HAVE_LCD_SLEEP | ||
47 | /* We don't use a setting but a fixed delay after the backlight has | ||
48 | * turned off */ | ||
49 | #define LCD_SLEEP_TIMEOUT (5*HZ) | ||
50 | |||
44 | #define CONFIG_KEYPAD GIGABEAT_PAD | 51 | #define CONFIG_KEYPAD GIGABEAT_PAD |
45 | 52 | ||
46 | /* Define this if you do software codec */ | 53 | /* Define this if you do software codec */ |
diff --git a/firmware/export/config-h10.h b/firmware/export/config-h10.h index f46eb76b5a..7e64494061 100644 --- a/firmware/export/config-h10.h +++ b/firmware/export/config-h10.h | |||
@@ -54,6 +54,7 @@ | |||
54 | * should be defined as well. | 54 | * should be defined as well. |
55 | * We can currently put the lcd to sleep but it won't wake up properly */ | 55 | * We can currently put the lcd to sleep but it won't wake up properly */ |
56 | #define HAVE_LCD_SLEEP | 56 | #define HAVE_LCD_SLEEP |
57 | #define HAVE_LCD_SLEEP_SETTING | ||
57 | 58 | ||
58 | /* define this if you can flip your LCD */ | 59 | /* define this if you can flip your LCD */ |
59 | #define HAVE_LCD_FLIP | 60 | #define HAVE_LCD_FLIP |
diff --git a/firmware/export/config-iaudiox5.h b/firmware/export/config-iaudiox5.h index 370d4fcd9a..d0a107b28d 100644 --- a/firmware/export/config-iaudiox5.h +++ b/firmware/export/config-iaudiox5.h | |||
@@ -65,6 +65,7 @@ | |||
65 | /* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE | 65 | /* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE |
66 | should be defined as well. */ | 66 | should be defined as well. */ |
67 | #define HAVE_LCD_SLEEP | 67 | #define HAVE_LCD_SLEEP |
68 | #define HAVE_LCD_SLEEP_SETTING | ||
68 | 69 | ||
69 | #define CONFIG_KEYPAD IAUDIO_X5M5_PAD | 70 | #define CONFIG_KEYPAD IAUDIO_X5M5_PAD |
70 | 71 | ||
diff --git a/firmware/export/config-mrobe100.h b/firmware/export/config-mrobe100.h index dd8b170f9e..6aaa2b005a 100644 --- a/firmware/export/config-mrobe100.h +++ b/firmware/export/config-mrobe100.h | |||
@@ -126,6 +126,7 @@ | |||
126 | * should be defined as well. | 126 | * should be defined as well. |
127 | * We can currently put the lcd to sleep but it won't wake up properly */ | 127 | * We can currently put the lcd to sleep but it won't wake up properly */ |
128 | /*TODO: #define HAVE_LCD_SLEEP*/ | 128 | /*TODO: #define HAVE_LCD_SLEEP*/ |
129 | /*TODO: #define HAVE_LCD_SLEEP_SETTING <= optional */ | ||
129 | 130 | ||
130 | /* We're able to shut off power to the HDD */ | 131 | /* We're able to shut off power to the HDD */ |
131 | #define HAVE_ATA_POWER_OFF | 132 | #define HAVE_ATA_POWER_OFF |
diff --git a/firmware/target/arm/iriver/h10/backlight-h10.c b/firmware/target/arm/iriver/h10/backlight-h10.c index 8033aebf71..5d211d26bf 100644 --- a/firmware/target/arm/iriver/h10/backlight-h10.c +++ b/firmware/target/arm/iriver/h10/backlight-h10.c | |||
@@ -25,8 +25,10 @@ | |||
25 | void _backlight_on(void) | 25 | void _backlight_on(void) |
26 | { | 26 | { |
27 | #ifdef HAVE_LCD_SLEEP | 27 | #ifdef HAVE_LCD_SLEEP |
28 | lcd_enable(true); | 28 | backlight_lcd_sleep_countdown(false); /* stop counter */ |
29 | _lcd_sleep_timer = 0; | 29 | #endif |
30 | #ifdef HAVE_LCD_ENABLE | ||
31 | lcd_enable(true); /* power on lcd + visible display */ | ||
30 | #endif | 32 | #endif |
31 | GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x20); | 33 | GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x20); |
32 | } | 34 | } |
@@ -34,15 +36,10 @@ void _backlight_on(void) | |||
34 | void _backlight_off(void) | 36 | void _backlight_off(void) |
35 | { | 37 | { |
36 | GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x20); | 38 | GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x20); |
39 | #ifdef HAVE_LCD_ENABLE | ||
40 | lcd_enable(false); /* power off visible display */ | ||
41 | #endif | ||
37 | #ifdef HAVE_LCD_SLEEP | 42 | #ifdef HAVE_LCD_SLEEP |
38 | lcd_enable(false); | 43 | backlight_lcd_sleep_countdown(true); /* start countdown */ |
39 | /* Start LCD sleep countdown */ | ||
40 | if (_lcd_sleep_timeout < 0) | ||
41 | { | ||
42 | _lcd_sleep_timer = 0; /* Setting == Always */ | ||
43 | lcd_sleep(); | ||
44 | } | ||
45 | else | ||
46 | _lcd_sleep_timer = _lcd_sleep_timeout; | ||
47 | #endif | 44 | #endif |
48 | } | 45 | } |
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c index 076c06b0d8..4fb66549cc 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c | |||
@@ -314,11 +314,6 @@ static void led_control_service(void) | |||
314 | sc606_control=SC606_CONTROL_IDLE; | 314 | sc606_control=SC606_CONTROL_IDLE; |
315 | break; | 315 | break; |
316 | } | 316 | } |
317 | |||
318 | if(sc606regCONFval&0x03) | ||
319 | lcd_enable(true); | ||
320 | else | ||
321 | lcd_enable(false); | ||
322 | } | 317 | } |
323 | #endif /* BOOTLOADER */ | 318 | #endif /* BOOTLOADER */ |
324 | 319 | ||
@@ -340,13 +335,22 @@ static void __backlight_dim(bool dim_now) | |||
340 | 335 | ||
341 | void _backlight_on(void) | 336 | void _backlight_on(void) |
342 | { | 337 | { |
343 | lcd_enable(true); | 338 | #ifdef HAVE_LCD_SLEEP |
339 | backlight_lcd_sleep_countdown(false); /* stop counter */ | ||
340 | #endif | ||
341 | #ifdef HAVE_LCD_ENABLE | ||
342 | lcd_enable(true); /* power on lcd + visible display */ | ||
343 | #endif | ||
344 | __backlight_dim(false); | 344 | __backlight_dim(false); |
345 | } | 345 | } |
346 | 346 | ||
347 | void _backlight_off(void) | 347 | void _backlight_off(void) |
348 | { | 348 | { |
349 | __backlight_dim(true); | 349 | __backlight_dim(true); |
350 | #ifdef HAVE_LCD_SLEEP | ||
351 | /* Disable lcd after fade completes (when lcd_sleep timeout expires) */ | ||
352 | backlight_lcd_sleep_countdown(true); /* start countdown */ | ||
353 | #endif | ||
350 | } | 354 | } |
351 | 355 | ||
352 | static inline void __buttonlight_on(void) | 356 | static inline void __buttonlight_on(void) |
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c index 37ac903418..5c268f42b8 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c | |||
@@ -26,7 +26,8 @@ | |||
26 | 26 | ||
27 | #define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)]) | 27 | #define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)]) |
28 | 28 | ||
29 | static volatile bool lcd_on = true; | 29 | static bool lcd_on = true; |
30 | static bool lcd_powered = true; | ||
30 | static unsigned lcd_yuv_options = 0; | 31 | static unsigned lcd_yuv_options = 0; |
31 | /* | 32 | /* |
32 | ** This is imported from lcd-16bit.c | 33 | ** This is imported from lcd-16bit.c |
@@ -174,6 +175,8 @@ void LCD_SPI_powerdown(void) | |||
174 | 0,0x04,1,0x00 | 175 | 0,0x04,1,0x00 |
175 | }; | 176 | }; |
176 | 177 | ||
178 | lcd_powered = false; | ||
179 | |||
177 | LCD_SPI_start(); | 180 | LCD_SPI_start(); |
178 | 181 | ||
179 | LCD_SPI_send(powerdncmd, sizeof(powerdncmd)); | 182 | LCD_SPI_send(powerdncmd, sizeof(powerdncmd)); |
@@ -198,6 +201,8 @@ void LCD_SPI_powerup(void) | |||
198 | LCD_SPI_send(powerupcmd, sizeof(powerupcmd)); | 201 | LCD_SPI_send(powerupcmd, sizeof(powerupcmd)); |
199 | 202 | ||
200 | LCD_SPI_stop(); | 203 | LCD_SPI_stop(); |
204 | |||
205 | lcd_powered = true; | ||
201 | } | 206 | } |
202 | 207 | ||
203 | void LCD_SPI_init(void) | 208 | void LCD_SPI_init(void) |
@@ -266,23 +271,40 @@ void lcd_init_device(void) | |||
266 | LCD_SPI_init(); | 271 | LCD_SPI_init(); |
267 | } | 272 | } |
268 | 273 | ||
274 | void lcd_sleep(void) | ||
275 | { | ||
276 | if (lcd_powered) | ||
277 | { | ||
278 | /* "not powered" implies "disabled" */ | ||
279 | if (lcd_on) | ||
280 | lcd_enable(false); | ||
281 | |||
282 | LCD_SPI_powerdown(); | ||
283 | } | ||
284 | } | ||
285 | |||
269 | void lcd_enable(bool state) | 286 | void lcd_enable(bool state) |
270 | { | 287 | { |
288 | if (state == lcd_on) | ||
289 | return; | ||
290 | |||
271 | if(state) | 291 | if(state) |
272 | { | 292 | { |
273 | if(!lcd_on) | 293 | /* "enabled" implies "powered" */ |
294 | if (!lcd_powered) | ||
274 | { | 295 | { |
275 | lcd_on = true; | ||
276 | lcd_update(); | ||
277 | LCD_SPI_powerup(); | 296 | LCD_SPI_powerup(); |
297 | /* Wait long enough for a frame to be written - yes, it | ||
298 | * takes awhile. */ | ||
299 | sleep(HZ/5); | ||
278 | } | 300 | } |
301 | |||
302 | lcd_on = true; | ||
303 | lcd_update(); | ||
279 | } | 304 | } |
280 | else | 305 | else |
281 | { | 306 | { |
282 | if(lcd_on) { | 307 | lcd_on = false; |
283 | lcd_on = false; | ||
284 | LCD_SPI_powerdown(); | ||
285 | } | ||
286 | } | 308 | } |
287 | } | 309 | } |
288 | 310 | ||
diff --git a/firmware/target/arm/sandisk/backlight-c200_e200.c b/firmware/target/arm/sandisk/backlight-c200_e200.c index 016751121e..aaec8cf007 100644 --- a/firmware/target/arm/sandisk/backlight-c200_e200.c +++ b/firmware/target/arm/sandisk/backlight-c200_e200.c | |||
@@ -38,11 +38,11 @@ void _backlight_set_brightness(int brightness) | |||
38 | 38 | ||
39 | void _backlight_on(void) | 39 | void _backlight_on(void) |
40 | { | 40 | { |
41 | #ifdef HAVE_LCD_ENABLE | 41 | #ifdef HAVE_LCD_SLEEP |
42 | lcd_enable(true); /* power on lcd */ | 42 | backlight_lcd_sleep_countdown(false); /* stop counter */ |
43 | #endif | 43 | #endif |
44 | #if defined(HAVE_LCD_SLEEP) && !defined(BOOTLOADER) | 44 | #ifdef HAVE_LCD_ENABLE |
45 | _lcd_sleep_timer = 0; /* LCD should be awake already */ | 45 | lcd_enable(true); /* power on lcd + visible display */ |
46 | #endif | 46 | #endif |
47 | pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, backlight_brightness); | 47 | pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, backlight_brightness); |
48 | } | 48 | } |
@@ -51,17 +51,10 @@ void _backlight_off(void) | |||
51 | { | 51 | { |
52 | pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, 0x0); | 52 | pp_i2c_send(AS3514_I2C_ADDR, AS3514_DCDC15, 0x0); |
53 | #ifdef HAVE_LCD_ENABLE | 53 | #ifdef HAVE_LCD_ENABLE |
54 | lcd_enable(false); /* power off lcd */ | 54 | lcd_enable(false); /* power off visible display */ |
55 | #endif | 55 | #endif |
56 | #if defined(HAVE_LCD_SLEEP) && !defined(BOOTLOADER) | 56 | #ifdef HAVE_LCD_SLEEP |
57 | /* Start LCD sleep countdown */ | 57 | backlight_lcd_sleep_countdown(true); /* start countdown */ |
58 | if (_lcd_sleep_timeout < 0) | ||
59 | { | ||
60 | _lcd_sleep_timer = 0; /* Setting == Always */ | ||
61 | lcd_sleep(); | ||
62 | } | ||
63 | else | ||
64 | _lcd_sleep_timer = _lcd_sleep_timeout; | ||
65 | #endif | 58 | #endif |
66 | } | 59 | } |
67 | 60 | ||