summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-04-28 08:57:38 +0000
committerThomas Martitz <kugel@rockbox.org>2009-04-28 08:57:38 +0000
commit14731bc3e2760139d8086fa742fd5fca61924c6a (patch)
tree39c7d978b243a9c72066f16da6f3d07c16e45650
parentbee99e496f816792014d02f4eca3a33d3ed8db2b (diff)
downloadrockbox-14731bc3e2760139d8086fa742fd5fca61924c6a.tar.gz
rockbox-14731bc3e2760139d8086fa742fd5fca61924c6a.zip
Hopefully fix lcd_sleep() from not be being called for targets without fading at all and being and being called too early for backlight always of on PWM fading targets. Also, clean up the code a bit by renaming the function that initiates fading on PWM.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20820 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/backlight.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 375da655f7..b8370deaa1 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -53,6 +53,11 @@
53 53
54#if defined(HAVE_BACKLIGHT) && defined(BACKLIGHT_FULL_INIT) 54#if defined(HAVE_BACKLIGHT) && defined(BACKLIGHT_FULL_INIT)
55 55
56#define BACKLIGHT_FADE_IN_THREAD \
57 (CONFIG_BACKLIGHT_FADING & (BACKLIGHT_FADING_SW_SETTING \
58 |BACKLIGHT_FADING_SW_HW_REG \
59 |BACKLIGHT_FADING_PWM) )
60
56#define BACKLIGHT_THREAD_TIMEOUT HZ 61#define BACKLIGHT_THREAD_TIMEOUT HZ
57 62
58enum { 63enum {
@@ -334,7 +339,7 @@ static void backlight_dim(int value)
334 backlight_switch(); 339 backlight_switch();
335} 340}
336 341
337static void _backlight_on(void) 342static void backlight_setup_fade_up(void)
338{ 343{
339 if (bl_fade_in_step > 0) 344 if (bl_fade_in_step > 0)
340 { 345 {
@@ -351,7 +356,7 @@ static void _backlight_on(void)
351 } 356 }
352} 357}
353 358
354static void _backlight_off(void) 359static void backlight_setup_fade_down(void)
355{ 360{
356 if (bl_fade_out_step > 0) 361 if (bl_fade_out_step > 0)
357 { 362 {
@@ -361,6 +366,9 @@ static void _backlight_off(void)
361 { 366 {
362 bl_dim_target = bl_dim_fraction = 0; 367 bl_dim_target = bl_dim_fraction = 0;
363 _backlight_off_normal(); 368 _backlight_off_normal();
369#ifdef HAVE_LCD_SLEEP
370 backlight_lcd_sleep_countdown(true);
371#endif
364 } 372 }
365} 373}
366 374
@@ -435,10 +443,28 @@ static void backlight_setup_fade_down(void)
435 * fading up is glitch free */ 443 * fading up is glitch free */
436 _backlight_set_brightness(MIN_BRIGHTNESS_SETTING); 444 _backlight_set_brightness(MIN_BRIGHTNESS_SETTING);
437#endif 445#endif
446#ifdef HAVE_LCD_SLEEP
447 backlight_lcd_sleep_countdown(true);
448#endif
438 } 449 }
439} 450}
440#endif /* CONFIG_BACKLIGHT_FADING */ 451#endif /* CONFIG_BACKLIGHT_FADING */
441 452
453static inline void do_backlight_off(void)
454{
455 backlight_timer = 0;
456#if BACKLIGHT_FADE_IN_THREAD
457 backlight_setup_fade_down();
458#else
459 _backlight_off();
460 /* targets that have fading need to start the countdown when done with
461 * fading */
462#ifdef HAVE_LCD_SLEEP
463 backlight_lcd_sleep_countdown(true);
464#endif
465#endif
466}
467
442/* Update state of backlight according to timeout setting */ 468/* Update state of backlight according to timeout setting */
443static void backlight_update_state(void) 469static void backlight_update_state(void)
444{ 470{
@@ -448,17 +474,11 @@ static void backlight_update_state(void)
448 /* Backlight == OFF in the setting? */ 474 /* Backlight == OFF in the setting? */
449 if (UNLIKELY(timeout < 0)) 475 if (UNLIKELY(timeout < 0))
450 { 476 {
451 backlight_timer = 0; /* Disable the timeout */ 477 do_backlight_off();
452#if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \ 478#if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \
453 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG) 479 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
454 backlight_setup_fade_down(); 480 /* necessary step to issue fading down when the setting is selected */
455 /* necessary step to issue fading down when the setting is selected */
456 queue_post(&backlight_queue, SYS_TIMEOUT, 0); 481 queue_post(&backlight_queue, SYS_TIMEOUT, 0);
457#else
458 _backlight_off();
459#ifdef HAVE_LCD_SLEEP
460 backlight_lcd_sleep_countdown(true); /* start sleep countdown */
461#endif
462#endif 482#endif
463 } 483 }
464 else 484 else
@@ -469,8 +489,7 @@ static void backlight_update_state(void)
469 backlight_lcd_sleep_countdown(false); /* wake up lcd */ 489 backlight_lcd_sleep_countdown(false); /* wake up lcd */
470#endif 490#endif
471 491
472#if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \ 492#if BACKLIGHT_FADE_IN_THREAD
473 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
474 backlight_setup_fade_up(); 493 backlight_setup_fade_up();
475#else 494#else
476 _backlight_on(); 495 _backlight_on();
@@ -496,16 +515,6 @@ static void remote_backlight_update_state(void)
496 } 515 }
497} 516}
498#endif /* HAVE_REMOTE_LCD */ 517#endif /* HAVE_REMOTE_LCD */
499static inline void do_backlight_off(void)
500{
501 backlight_timer = 0;
502#if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \
503 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
504 backlight_setup_fade_down();
505#else
506 _backlight_off();
507#endif /* CONFIG_BACKLIGHT_FADING */
508}
509 518
510void backlight_thread(void) 519void backlight_thread(void)
511{ 520{