1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 * Additional work by Martin Ritter (2007) and Thomas Martitz (2008)
12 * for backlight thread fading
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
36 #include "backlight.h"
38 #include "screendump.h"
40 #ifdef HAVE_REMOTE_LCD
41 #include "lcd-remote.h"
44 #include "backlight-target.h"
47 #if !defined(BOOTLOADER)
48 /* The whole driver should be built */
49 #define BACKLIGHT_FULL_INIT
52 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
53 int backlight_brightness
= DEFAULT_BRIGHTNESS_SETTING
;
56 #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \
57 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
58 #include "backlight-sw-fading.h"
62 static inline void _backlight_on(void)
67 static inline void _backlight_off(void)
72 static inline void _backlight_set_brightness(int val
)
77 static inline void _buttonlight_on(void)
81 static inline void _buttonlight_off(void)
85 static inline void _buttonlight_set_brightness(int val
)
89 #ifdef HAVE_REMOTE_LCD
90 static inline void _remote_backlight_on(void)
92 sim_remote_backlight(100);
95 static inline void _remote_backlight_off(void)
97 sim_remote_backlight(0);
99 #endif /* HAVE_REMOTE_LCD */
101 #endif /* SIMULATOR */
103 #if defined(HAVE_BACKLIGHT) && defined(BACKLIGHT_FULL_INIT)
108 #ifdef HAVE_REMOTE_LCD
110 REMOTE_BACKLIGHT_OFF
,
112 #if defined(_BACKLIGHT_FADE_BOOST) || defined(_BACKLIGHT_FADE_ENABLE)
113 BACKLIGHT_FADE_FINISH
,
115 #ifdef HAVE_LCD_SLEEP
118 #ifdef HAVE_BUTTON_LIGHT
122 #ifdef BACKLIGHT_DRIVER_CLOSE
127 static void backlight_thread(void);
128 static long backlight_stack
[DEFAULT_STACK_SIZE
/sizeof(long)];
129 static const char backlight_thread_name
[] = "backlight";
130 static struct event_queue backlight_queue
;
131 #ifdef BACKLIGHT_DRIVER_CLOSE
132 static unsigned int backlight_thread_id
= 0;
135 static int backlight_timer SHAREDBSS_ATTR
;
136 static int backlight_timeout SHAREDBSS_ATTR
;
137 static int backlight_timeout_normal
= 5*HZ
;
139 static int backlight_timeout_plugged
= 5*HZ
;
141 #ifdef HAS_BUTTON_HOLD
142 static int backlight_on_button_hold
= 0;
145 #ifdef HAVE_BUTTON_LIGHT
146 static int buttonlight_timer
;
147 int _buttonlight_timeout
= 5*HZ
;
149 /* Update state of buttonlight according to timeout setting */
150 static void buttonlight_update_state(void)
152 buttonlight_timer
= _buttonlight_timeout
;
154 /* Buttonlight == OFF in the setting? */
155 if (buttonlight_timer
< 0)
157 buttonlight_timer
= 0; /* Disable the timeout */
164 /* external interface */
165 void buttonlight_on(void)
167 queue_remove_from_head(&backlight_queue
, BUTTON_LIGHT_ON
);
168 queue_post(&backlight_queue
, BUTTON_LIGHT_ON
, 0);
171 void buttonlight_off(void)
173 queue_post(&backlight_queue
, BUTTON_LIGHT_OFF
, 0);
176 void buttonlight_set_timeout(int value
)
178 _buttonlight_timeout
= HZ
* value
;
179 buttonlight_update_state();
182 #endif /* HAVE_BUTTON_LIGHT */
184 #ifdef HAVE_REMOTE_LCD
185 static int remote_backlight_timer
;
186 static int remote_backlight_timeout
;
187 static int remote_backlight_timeout_normal
= 5*HZ
;
189 static int remote_backlight_timeout_plugged
= 5*HZ
;
191 #ifdef HAS_REMOTE_BUTTON_HOLD
192 static int remote_backlight_on_button_hold
= 0;
194 #endif /* HAVE_REMOTE_LCD */
196 #ifdef HAVE_LCD_SLEEP
197 #ifdef HAVE_LCD_SLEEP_SETTING
198 const signed char lcd_sleep_timeout_value
[10] =
200 -1, 0, 5, 10, 15, 20, 30, 45, 60, 90
202 static int lcd_sleep_timeout
= 10*HZ
;
204 /* Target defines needed value */
205 static const int lcd_sleep_timeout
= LCD_SLEEP_TIMEOUT
;
208 static int lcd_sleep_timer
= 0;
210 void backlight_lcd_sleep_countdown(bool start
)
214 /* Cancel the LCD sleep countdown */
219 /* Start LCD sleep countdown */
220 if (lcd_sleep_timeout
< 0)
222 lcd_sleep_timer
= 0; /* Setting == Always */
227 lcd_sleep_timer
= lcd_sleep_timeout
;
230 #endif /* HAVE_LCD_SLEEP */
232 #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \
233 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
234 static int backlight_fading_type
= (FADING_UP
|FADING_DOWN
);
235 static int backlight_fading_state
= NOT_FADING
;
239 /* backlight fading */
240 #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_PWM)
241 #define BL_PWM_INTERVAL 5 /* Cycle interval in ms */
242 #define BL_PWM_BITS 8
243 #define BL_PWM_COUNT (1<<BL_PWM_BITS)
245 /* s15.16 fixed point variables */
246 static int32_t bl_fade_in_step
= ((BL_PWM_INTERVAL
*BL_PWM_COUNT
)<<16)/300;
247 static int32_t bl_fade_out_step
= ((BL_PWM_INTERVAL
*BL_PWM_COUNT
)<<16)/2000;
248 static int32_t bl_dim_fraction
= 0;
250 static int bl_dim_target
= 0;
251 static int bl_dim_current
= 0;
252 static enum {DIM_STATE_START
, DIM_STATE_MAIN
} bl_dim_state
= DIM_STATE_START
;
253 static bool bl_timer_active
= false;
255 static void backlight_isr(void)
257 int timer_period
= (TIMER_FREQ
*BL_PWM_INTERVAL
/1000);
260 switch (bl_dim_state
)
263 case DIM_STATE_START
:
264 bl_dim_current
= bl_dim_fraction
>> 16;
266 if (bl_dim_current
> 0 && bl_dim_current
< BL_PWM_COUNT
)
269 timer_period
= (timer_period
* bl_dim_current
) >> BL_PWM_BITS
;
270 bl_dim_state
= DIM_STATE_MAIN
;
277 _backlight_off_isr();
278 if (bl_dim_current
== bl_dim_target
)
281 if (bl_dim_current
< bl_dim_target
)
283 bl_dim_fraction
= MIN(bl_dim_fraction
+ bl_fade_in_step
,
286 else if (bl_dim_current
> bl_dim_target
)
288 bl_dim_fraction
= MAX(bl_dim_fraction
- bl_fade_out_step
, 0);
292 /* Dim main screen */
294 _backlight_off_isr();
295 timer_period
= (timer_period
* (BL_PWM_COUNT
- bl_dim_current
))
297 bl_dim_state
= DIM_STATE_START
;
302 #if defined(_BACKLIGHT_FADE_BOOST) || defined(_BACKLIGHT_FADE_ENABLE)
303 queue_post(&backlight_queue
, BACKLIGHT_FADE_FINISH
, 0);
306 bl_timer_active
= false;
309 timer_set_period(timer_period
);
312 static void backlight_switch(void)
314 if (bl_dim_target
> (BL_PWM_COUNT
/2))
316 _backlight_on_normal();
317 bl_dim_fraction
= (BL_PWM_COUNT
<<16);
321 _backlight_off_normal();
326 static void backlight_release_timer(void)
328 #ifdef _BACKLIGHT_FADE_BOOST
332 bl_timer_active
= false;
336 static void backlight_dim(int value
)
338 /* protect from extraneous calls with the same target value */
339 if (value
== bl_dim_target
)
342 bl_dim_target
= value
;
347 if (timer_register(0, backlight_release_timer
, 2, 0, backlight_isr
350 #ifdef _BACKLIGHT_FADE_BOOST
351 /* Prevent cpu frequency changes while dimming. */
354 bl_timer_active
= true;
360 static void _backlight_on(void)
362 #ifdef HAVE_LCD_SLEEP
363 backlight_lcd_sleep_countdown(false);
366 if (bl_fade_in_step
> 0)
368 #ifdef _BACKLIGHT_FADE_ENABLE
369 _backlight_hw_enable(true);
371 backlight_dim(BL_PWM_COUNT
);
375 bl_dim_target
= BL_PWM_COUNT
;
376 bl_dim_fraction
= (BL_PWM_COUNT
<<16);
377 _backlight_on_normal();
381 static void _backlight_off(void)
383 if (bl_fade_out_step
> 0)
389 bl_dim_target
= bl_dim_fraction
= 0;
390 _backlight_off_normal();
393 #ifdef HAVE_LCD_SLEEP
394 backlight_lcd_sleep_countdown(true);
398 void backlight_set_fade_in(int value
)
401 bl_fade_in_step
= ((BL_PWM_INTERVAL
*BL_PWM_COUNT
)<<16) / value
;
406 void backlight_set_fade_out(int value
)
409 bl_fade_out_step
= ((BL_PWM_INTERVAL
*BL_PWM_COUNT
)<<16) / value
;
411 bl_fade_out_step
= 0;
414 #elif (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \
415 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
417 void backlight_set_fade_out(bool value
)
420 backlight_fading_type
|= FADING_DOWN
;
422 backlight_fading_type
&= FADING_UP
;
425 void backlight_set_fade_in(bool value
)
428 backlight_fading_type
|= FADING_UP
;
430 backlight_fading_type
&= FADING_DOWN
;
433 static void backlight_setup_fade_up(void)
435 if (backlight_fading_type
& FADING_UP
)
437 if (backlight_fading_state
== NOT_FADING
)
439 /* make sure the backlight is at lowest level */
442 backlight_fading_state
= FADING_UP
;
446 backlight_fading_state
= NOT_FADING
;
447 _backlight_fade_update_state(backlight_brightness
);
449 _backlight_set_brightness(backlight_brightness
);
453 static void backlight_setup_fade_down(void)
455 if (backlight_fading_type
& FADING_DOWN
)
457 backlight_fading_state
= FADING_DOWN
;
461 backlight_fading_state
= NOT_FADING
;
462 _backlight_fade_update_state(MIN_BRIGHTNESS_SETTING
-1);
464 #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
465 /* write the lowest brightness level to the hardware so that
466 * fading up is glitch free */
467 _backlight_set_brightness(MIN_BRIGHTNESS_SETTING
);
471 #endif /* CONFIG_BACKLIGHT_FADING */
473 /* Update state of backlight according to timeout setting */
474 static void backlight_update_state(void)
476 #ifdef HAS_BUTTON_HOLD
477 if ((backlight_on_button_hold
!= 0)
478 #ifdef HAVE_REMOTE_LCD_AS_MAIN
479 && remote_button_hold()
484 backlight_timeout
= (backlight_on_button_hold
== 2) ? 0 : -1;
485 /* always on or always off */
489 if (power_input_present())
490 backlight_timeout
= backlight_timeout_plugged
;
493 backlight_timeout
= backlight_timeout_normal
;
495 /* Backlight == OFF in the setting? */
496 if (UNLIKELY(backlight_timeout
< 0))
498 backlight_timer
= 0; /* Disable the timeout */
499 #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \
500 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
501 backlight_setup_fade_down();
502 /* necessary step to issue fading down when the setting is selected */
503 queue_post(&backlight_queue
, SYS_TIMEOUT
, 0);
510 backlight_timer
= backlight_timeout
;
511 #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \
512 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
513 backlight_setup_fade_up();
520 #ifdef HAVE_REMOTE_LCD
521 /* Update state of remote backlight according to timeout setting */
522 static void remote_backlight_update_state(void)
524 #ifdef HAS_REMOTE_BUTTON_HOLD
525 if (remote_button_hold() && (remote_backlight_on_button_hold
!= 0))
526 remote_backlight_timeout
= (remote_backlight_on_button_hold
== 2)
527 ? 0 : -1; /* always on or always off */
531 if (power_input_present())
532 remote_backlight_timeout
= remote_backlight_timeout_plugged
;
535 remote_backlight_timeout
= remote_backlight_timeout_normal
;
537 /* Backlight == OFF in the setting? */
538 if (remote_backlight_timeout
< 0)
540 remote_backlight_timer
= 0; /* Disable the timeout */
541 _remote_backlight_off();
545 remote_backlight_timer
= remote_backlight_timeout
;
546 _remote_backlight_on();
549 #endif /* HAVE_REMOTE_LCD */
551 void backlight_thread(void)
553 struct queue_event ev
;
558 #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \
559 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
560 if (backlight_fading_state
)
561 queue_wait_w_tmo(&backlight_queue
, &ev
, FADE_DELAY
);
564 queue_wait(&backlight_queue
, &ev
);
566 { /* These events must always be processed */
567 #ifdef _BACKLIGHT_FADE_BOOST
568 case BACKLIGHT_FADE_FINISH
:
572 #ifdef _BACKLIGHT_FADE_ENABLE
573 case BACKLIGHT_FADE_FINISH
:
574 _backlight_hw_enable((bl_dim_current
|bl_dim_target
) != 0);
579 /* Here for now or else the aggressive init messes up scrolling */
580 #ifdef HAVE_REMOTE_LCD
581 case SYS_REMOTE_PLUGGED
:
586 case SYS_REMOTE_UNPLUGGED
:
589 #elif defined HAVE_REMOTE_LCD_AS_MAIN
590 case SYS_REMOTE_PLUGGED
:
595 case SYS_REMOTE_UNPLUGGED
:
598 #endif /* HAVE_REMOTE_LCD/ HAVE_REMOTE_LCD_AS_MAIN */
599 #endif /* !SIMULATOR */
600 case SYS_USB_CONNECTED
:
601 /* Tell the USB thread that we are safe */
602 DEBUGF("backlight_thread got SYS_USB_CONNECTED\n");
603 usb_acknowledge(SYS_USB_CONNECTED_ACK
);
606 case SYS_USB_DISCONNECTED
:
607 usb_acknowledge(SYS_USB_DISCONNECTED_ACK
);
610 #ifdef BACKLIGHT_DRIVER_CLOSE
611 /* Get out of here */
620 { /* These events are only processed if backlight isn't locked */
621 #ifdef HAVE_REMOTE_LCD
622 case REMOTE_BACKLIGHT_ON
:
623 remote_backlight_update_state();
626 case REMOTE_BACKLIGHT_OFF
:
627 remote_backlight_timer
= 0; /* Disable the timeout */
628 _remote_backlight_off();
630 #endif /* HAVE_REMOTE_LCD */
633 backlight_update_state();
637 backlight_timer
= 0; /* Disable the timeout */
638 #if (CONFIG_BACKLIGHT_FADING != BACKLIGHT_FADING_SW_SETTING) \
639 && (CONFIG_BACKLIGHT_FADING != BACKLIGHT_FADING_SW_HW_REG)
642 backlight_setup_fade_down();
643 #endif /* CONFIG_BACKLIGHT_FADING */
645 #ifdef HAVE_LCD_SLEEP
650 #ifdef HAVE_BUTTON_LIGHT
651 case BUTTON_LIGHT_ON
:
652 buttonlight_update_state();
655 case BUTTON_LIGHT_OFF
:
656 buttonlight_timer
= 0;
661 case SYS_POWEROFF
: /* Lock backlight on poweroff so it doesn't */
662 locked
= true; /* go off before power is actually cut. */
665 case SYS_CHARGER_CONNECTED
:
666 case SYS_CHARGER_DISCONNECTED
:
668 backlight_update_state();
669 #ifdef HAVE_REMOTE_LCD
670 remote_backlight_update_state();
673 #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \
674 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
676 if ((_backlight_fade_step(backlight_fading_state
)))
677 backlight_fading_state
= NOT_FADING
; /* finished fading */
679 #endif /* CONFIG_BACKLIGHT_FADING */
684 static void backlight_tick(void)
688 if(--backlight_timer
== 0)
693 #ifdef HAVE_LCD_SLEEP
694 else if(lcd_sleep_timer
)
696 if(--lcd_sleep_timer
== 0)
698 /* Queue on bl thread or freeze! */
699 queue_post(&backlight_queue
, LCD_SLEEP
, 0);
702 #endif /* HAVE_LCD_SLEEP */
703 #ifdef HAVE_REMOTE_LCD
704 if(remote_backlight_timer
)
706 if(--remote_backlight_timer
== 0)
708 remote_backlight_off();
711 #endif /* HAVE_REMOVE_LCD */
712 #ifdef HAVE_BUTTON_LIGHT
713 if (buttonlight_timer
)
715 if (--buttonlight_timer
== 0)
720 #endif /* HAVE_BUTTON_LIGHT */
723 void backlight_init(void)
725 queue_init(&backlight_queue
, true);
728 if (_backlight_init())
730 #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_PWM)
731 /* If backlight is already on, don't fade in. */
732 bl_dim_target
= BL_PWM_COUNT
;
733 bl_dim_fraction
= (BL_PWM_COUNT
<<16);
737 /* Leave all lights as set by the bootloader here. The settings load will
738 * call the appropriate backlight_set_*() functions, only changing light
739 * status if necessary. */
740 #ifdef BACKLIGHT_DRIVER_CLOSE
741 backlight_thread_id
=
743 create_thread(backlight_thread
, backlight_stack
,
744 sizeof(backlight_stack
), 0, backlight_thread_name
745 IF_PRIO(, PRIORITY_USER_INTERFACE
)
747 tick_add_task(backlight_tick
);
750 #ifdef BACKLIGHT_DRIVER_CLOSE
751 void backlight_close(void)
753 unsigned int thread
= backlight_thread_id
;
755 /* Wait for thread to exit */
759 backlight_thread_id
= 0;
761 queue_post(&backlight_queue
, BACKLIGHT_QUIT
, 0);
764 #endif /* BACKLIGHT_DRIVER_CLOSE */
766 void backlight_on(void)
768 queue_remove_from_head(&backlight_queue
, BACKLIGHT_ON
);
769 queue_post(&backlight_queue
, BACKLIGHT_ON
, 0);
772 void backlight_off(void)
774 queue_post(&backlight_queue
, BACKLIGHT_OFF
, 0);
777 /* returns true when the backlight is on,
778 * and optionally when it's set to always off. */
779 bool is_backlight_on(bool ignore_always_off
)
781 return (backlight_timer
> 0) /* countdown */
782 || (backlight_timeout
== 0) /* always on */
783 || ((backlight_timeout
< 0) && !ignore_always_off
);
786 /* return value in ticks; 0 means always on, <0 means always off */
787 int backlight_get_current_timeout(void)
789 return backlight_timeout
;
792 void backlight_set_timeout(int value
)
794 backlight_timeout_normal
= HZ
* value
;
795 backlight_update_state();
799 void backlight_set_timeout_plugged(int value
)
801 backlight_timeout_plugged
= HZ
* value
;
802 backlight_update_state();
804 #endif /* CONFIG_CHARGING */
806 #ifdef HAS_BUTTON_HOLD
807 /* Hold button change event handler. */
808 void backlight_hold_changed(bool hold_button
)
810 if (!hold_button
|| (backlight_on_button_hold
> 0))
811 /* if unlocked or override in effect */
815 void backlight_set_on_button_hold(int index
)
817 if ((unsigned)index
>= 3)
818 /* if given a weird value, use default */
821 backlight_on_button_hold
= index
;
822 backlight_update_state();
824 #endif /* HAS_BUTTON_HOLD */
826 #ifdef HAVE_LCD_SLEEP_SETTING
827 void lcd_set_sleep_after_backlight_off(int index
)
829 if ((unsigned)index
>= sizeof(lcd_sleep_timeout_value
))
830 /* if given a weird value, use default */
833 lcd_sleep_timeout
= HZ
* lcd_sleep_timeout_value
[index
];
835 if (backlight_timer
> 0 || backlight_get_current_timeout() == 0)
836 /* Timer will be set when bl turns off or bl set to on. */
839 /* Backlight is Off */
840 if (lcd_sleep_timeout
< 0)
841 lcd_sleep_timer
= 1; /* Always - sleep next tick */
843 lcd_sleep_timer
= lcd_sleep_timeout
; /* Never, other */
845 #endif /* HAVE_LCD_SLEEP_SETTING */
847 #ifdef HAVE_REMOTE_LCD
848 void remote_backlight_on(void)
850 queue_post(&backlight_queue
, REMOTE_BACKLIGHT_ON
, 0);
853 void remote_backlight_off(void)
855 queue_post(&backlight_queue
, REMOTE_BACKLIGHT_OFF
, 0);
858 void remote_backlight_set_timeout(int value
)
860 remote_backlight_timeout_normal
= HZ
* value
;
861 remote_backlight_update_state();
865 void remote_backlight_set_timeout_plugged(int value
)
867 remote_backlight_timeout_plugged
= HZ
* value
;
868 remote_backlight_update_state();
870 #endif /* CONFIG_CHARGING */
872 #ifdef HAS_REMOTE_BUTTON_HOLD
873 /* Remote hold button change event handler. */
874 void remote_backlight_hold_changed(bool rc_hold_button
)
876 if (!rc_hold_button
|| (remote_backlight_on_button_hold
> 0))
877 /* if unlocked or override */
878 remote_backlight_on();
881 void remote_backlight_set_on_button_hold(int index
)
883 if ((unsigned)index
>= 3)
884 /* if given a weird value, use default */
887 remote_backlight_on_button_hold
= index
;
888 remote_backlight_update_state();
890 #endif /* HAS_REMOTE_BUTTON_HOLD */
892 /* return value in ticks; 0 means always on, <0 means always off */
893 int remote_backlight_get_current_timeout(void)
895 return remote_backlight_timeout
;
898 /* returns true when the backlight is on, and
899 * optionally when it's set to always off */
900 bool is_remote_backlight_on(bool ignore_always_off
)
902 return (remote_backlight_timer
> 0) /* countdown */
903 || (remote_backlight_timeout
== 0) /* always on */
904 || ((remote_backlight_timeout
< 0) && !ignore_always_off
);
907 #endif /* HAVE_REMOTE_LCD */
909 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
910 void backlight_set_brightness(int val
)
912 if (val
< MIN_BRIGHTNESS_SETTING
)
913 val
= MIN_BRIGHTNESS_SETTING
;
914 else if (val
> MAX_BRIGHTNESS_SETTING
)
915 val
= MAX_BRIGHTNESS_SETTING
;
917 backlight_brightness
= val
;
918 _backlight_set_brightness(val
);
919 #if (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_SETTING) \
920 || (CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG)
921 /* receive backlight brightness */
922 _backlight_fade_update_state(val
);
925 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
927 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
928 void buttonlight_set_brightness(int val
)
930 if (val
< MIN_BRIGHTNESS_SETTING
)
931 val
= MIN_BRIGHTNESS_SETTING
;
932 else if (val
> MAX_BRIGHTNESS_SETTING
)
933 val
= MAX_BRIGHTNESS_SETTING
;
935 _buttonlight_set_brightness(val
);
937 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
939 #else /* !defined(HAVE_BACKLIGHT) || !defined(BACKLIGHT_FULL_INIT)
940 -- no backlight, empty dummy functions */
942 #if defined(HAVE_BACKLIGHT) && !defined(BACKLIGHT_FULL_INIT)
943 void backlight_init(void)
945 (void)_backlight_init();
950 void backlight_on(void) {}
951 void backlight_off(void) {}
952 void buttonlight_on(void) {}
953 void backlight_set_timeout(int value
) {(void)value
;}
955 bool is_backlight_on(bool ignore_always_off
)
957 (void)ignore_always_off
;
960 #ifdef HAVE_REMOTE_LCD
961 void remote_backlight_on(void) {}
962 void remote_backlight_off(void) {}
963 void remote_backlight_set_timeout(int value
) {(void)value
;}
965 bool is_remote_backlight_on(bool ignore_always_off
)
967 (void)ignore_always_off
;
970 #endif /* HAVE_REMOTE_LCD */
971 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
972 void backlight_set_brightness(int val
) { (void)val
; }
974 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
975 void buttonlight_set_brightness(int val
) { (void)val
; }
977 #endif /* defined(HAVE_BACKLIGHT) && defined(BACKLIGHT_FULL_INIT) */