1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
32 #include "backlight.h"
34 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
35 #include "pcf50606.h" /* iRiver, iAudio X5 brightness */
38 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
39 #include "lcd.h" /* for lcd_enable() and lcd_sleep() */
41 #ifdef HAVE_REMOTE_LCD
42 #include "lcd-remote.h"
44 #if defined(TARGET_TREE) && !defined(SIMULATOR)
45 #include "backlight-target.h"
49 static inline void __backlight_on(void)
54 static inline void __backlight_off(void)
59 /* Basic low-level code that simply switches backlight on or off. Probably
60 * a nice candidate for inclusion in the target/ dir. */
62 static inline void __backlight_on(void)
64 #if CONFIG_BACKLIGHT == BL_IRIVER_H100
65 and_l(~0x00020000, &GPIO1_OUT
);
66 #elif CONFIG_BACKLIGHT == BL_IRIVER_H300
68 sleep(HZ
/100); /* lcd needs time - avoid flashing for dark screens */
69 or_l(0x00020000, &GPIO1_OUT
);
70 #elif CONFIG_BACKLIGHT == BL_RTC
71 /* Enable square wave */
72 rtc_write(0x0a, rtc_read(0x0a) | 0x40);
73 #elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */
74 and_b(~0x40, &PADRH
); /* drive and set low */
76 #elif CONFIG_BACKLIGHT == BL_PA14_HI /* Ondio */
77 or_b(0x40, &PADRH
); /* drive it high */
78 #elif CONFIG_BACKLIGHT == BL_GMINI
80 #elif CONFIG_BACKLIGHT == BL_IPOD4G
82 outl(0x80000000 | (0xff << 16), 0x7000a010);
84 /* set port b bit 3 on */
85 outl(((0x100 | 1) << 3), 0x6000d824);
86 #elif CONFIG_BACKLIGHT==BL_IPODMINI
88 outl(((0x100 | 1) << 3), 0x6000d824);
89 #elif CONFIG_BACKLIGHT==BL_IPODNANO
91 outl(((0x100 | 1) << 3), 0x6000d824);
94 outl(((0x100 | 1) << 7), 0x6000d12c);
95 #elif CONFIG_BACKLIGHT==BL_IPOD3G
96 outl(inl(0xc0001000) | 0x02, 0xc0001000);
97 #elif CONFIG_BACKLIGHT==BL_IRIVER_IFP7XX
102 static inline void __backlight_off(void)
104 #if CONFIG_BACKLIGHT == BL_IRIVER_H100
105 or_l(0x00020000, &GPIO1_OUT
);
106 #elif CONFIG_BACKLIGHT == BL_IRIVER_H300
107 and_l(~0x00020000, &GPIO1_OUT
);
109 #elif CONFIG_BACKLIGHT == BL_RTC
110 /* Disable square wave */
111 rtc_write(0x0a, rtc_read(0x0a) & ~0x40);
112 #elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */
113 and_b(~0x40, &PAIORH
); /* let it float (up) */
114 #elif CONFIG_BACKLIGHT == BL_PA14_HI /* Ondio */
115 and_b(~0x40, &PADRH
); /* drive it low */
116 #elif CONFIG_BACKLIGHT == BL_GMINI
118 #elif CONFIG_BACKLIGHT == BL_IPOD4G
119 /* fades backlight off on 4g */
120 outl(inl(0x70000084) & ~0x2000000, 0x70000084);
121 outl(0x80000000, 0x7000a010);
122 #elif CONFIG_BACKLIGHT==BL_IPODNANO
123 /* set port B03 off */
124 outl(((0x100 | 0) << 3), 0x6000d824);
126 /* set port L07 off */
127 outl(((0x100 | 0) << 7), 0x6000d12c);
128 #elif CONFIG_BACKLIGHT==BL_IRIVER_IFP7XX
130 #elif CONFIG_BACKLIGHT==BL_IPOD3G
131 outl(inl(0xc0001000) & ~0x02, 0xc0001000);
132 #elif CONFIG_BACKLIGHT==BL_IPODMINI
133 /* set port B03 off */
134 outl(((0x100 | 0) << 3), 0x6000d824);
138 #endif /* SIMULATOR */
140 #if defined(CONFIG_BACKLIGHT) && !defined(BOOTLOADER)
142 const signed char backlight_timeout_value
[19] =
144 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 45, 60, 90
147 #define BACKLIGHT_ON 1
148 #define BACKLIGHT_OFF 2
149 #define REMOTE_BACKLIGHT_ON 3
150 #define REMOTE_BACKLIGHT_OFF 4
151 #define BACKLIGHT_UNBOOST_CPU 5
152 #ifdef HAVE_LCD_SLEEP
156 static void backlight_thread(void);
157 static long backlight_stack
[DEFAULT_STACK_SIZE
/sizeof(long)];
158 #ifdef X5_BACKLIGHT_SHUTDOWN
159 #define BACKLIGHT_QUIT 256
160 /* Need to save this for x5 shutdown */
161 struct thread_entry
* backlight_thread_id
;
163 static const char backlight_thread_name
[] = "backlight";
164 static struct event_queue backlight_queue
;
166 static int backlight_timer
;
167 static int backlight_timeout
= 5*HZ
;
168 #ifdef CONFIG_CHARGING
169 static int backlight_timeout_plugged
= 5*HZ
;
171 #ifdef HAS_BUTTON_HOLD
172 static int backlight_on_button_hold
= 0;
175 #ifdef HAVE_REMOTE_LCD
176 static int remote_backlight_timer
;
177 static int remote_backlight_timeout
= 5*HZ
;
178 #ifdef CONFIG_CHARGING
179 static int remote_backlight_timeout_plugged
= 5*HZ
;
181 #ifdef HAS_REMOTE_BUTTON_HOLD
182 static int remote_backlight_on_button_hold
= 0;
186 #ifdef HAVE_LCD_SLEEP
187 const signed char lcd_sleep_timeout_value
[10] =
189 -1, 0, 5, 10, 15, 20, 30, 45, 60, 90
191 static int lcd_sleep_timer
;
192 static int lcd_sleep_timeout
= 10*HZ
;
195 #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
196 /* backlight fading */
197 #define BL_PWM_INTERVAL 5000 /* Cycle interval in µs */
198 #define BL_PWM_COUNT 100
199 static const char backlight_fade_value
[8] = { 0, 1, 2, 4, 6, 8, 10, 20 };
200 static int fade_in_count
= 1;
201 static int fade_out_count
= 4;
203 static bool bl_timer_active
= false;
204 static int bl_dim_current
= BL_PWM_COUNT
;
205 static int bl_dim_target
= BL_PWM_COUNT
;
206 static int bl_pwm_counter
= 0;
207 static volatile int bl_cycle_counter
= 0;
208 static enum {DIM_STATE_START
, DIM_STATE_MAIN
} bl_dim_state
= DIM_STATE_START
;
210 static void backlight_isr(void)
215 timer_period
= TIMER_FREQ
/ 1000 * BL_PWM_INTERVAL
/ 1000;
216 switch (bl_dim_state
)
219 case DIM_STATE_START
:
223 if (bl_dim_current
> 0 && bl_dim_current
< BL_PWM_COUNT
)
226 bl_pwm_counter
= bl_dim_current
;
227 timer_period
= timer_period
* bl_pwm_counter
/ BL_PWM_COUNT
;
228 bl_dim_state
= DIM_STATE_MAIN
;
236 if (bl_dim_current
== bl_dim_target
)
242 /* Dim main screen */
245 bl_dim_state
= DIM_STATE_START
;
246 timer_period
= timer_period
* (BL_PWM_COUNT
- bl_pwm_counter
) / BL_PWM_COUNT
;
250 if ((bl_dim_target
> bl_dim_current
) && (bl_cycle_counter
>= fade_in_count
))
253 bl_cycle_counter
= 0;
256 if ((bl_dim_target
< bl_dim_current
) && (bl_cycle_counter
>= fade_out_count
))
259 bl_cycle_counter
= 0;
265 queue_post(&backlight_queue
, BACKLIGHT_UNBOOST_CPU
, NULL
);
268 bl_timer_active
= false;
271 timer_set_period(timer_period
);
274 static void backlight_switch(void)
276 if (bl_dim_target
> (BL_PWM_COUNT
/2))
279 bl_dim_current
= BL_PWM_COUNT
;
288 static void backlight_release_timer(void)
294 bl_timer_active
= false;
298 static void backlight_dim(int value
)
300 /* protect from extraneous calls with the same target value */
301 if (value
== bl_dim_target
)
304 bl_dim_target
= value
;
309 if (timer_register(0, backlight_release_timer
, 2, 0, backlight_isr
))
312 /* Prevent cpu frequency changes while dimming. */
315 bl_timer_active
= true;
321 void backlight_set_fade_in(int index
)
323 fade_in_count
= backlight_fade_value
[index
];
326 void backlight_set_fade_out(int index
)
328 fade_out_count
= backlight_fade_value
[index
];
330 #endif /* defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) */
332 static void _backlight_on(void)
334 #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
335 if (fade_in_count
> 0)
336 backlight_dim(BL_PWM_COUNT
);
339 bl_dim_target
= bl_dim_current
= BL_PWM_COUNT
;
345 #ifdef HAVE_LCD_SLEEP
346 lcd_sleep_timer
= 0; /* LCD should be awake already */
350 static void _backlight_off(void)
352 #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
353 if (fade_out_count
> 0)
357 bl_dim_target
= bl_dim_current
= 0;
364 #ifdef HAVE_LCD_SLEEP
365 /* Start LCD sleep countdown */
366 if (lcd_sleep_timeout
< 0)
368 lcd_sleep_timer
= 0; /* Setting == Always */
372 lcd_sleep_timer
= lcd_sleep_timeout
;
376 #ifdef HAVE_REMOTE_LCD
378 static void __remote_backlight_on(void)
380 sim_remote_backlight(100);
383 static void __remote_backlight_off(void)
385 sim_remote_backlight(0);
389 static void __remote_backlight_on(void)
391 #if defined(IRIVER_H300_SERIES)
392 and_l(~0x00000002, &GPIO1_OUT
);
394 and_l(~0x00000800, &GPIO_OUT
);
398 static void __remote_backlight_off(void)
400 #if defined(IRIVER_H300_SERIES)
401 or_l(0x00000002, &GPIO1_OUT
);
403 or_l(0x00000800, &GPIO_OUT
);
406 #endif /* TARGET_TREE */
407 #endif /* SIMULATOR */
408 #endif /* HAVE_REMOTE_LCD */
410 /* Update state of backlight according to timeout setting */
411 static void backlight_update_state(void)
413 #ifdef CONFIG_CHARGING
414 if (charger_inserted()
415 #ifdef HAVE_USB_POWER
419 backlight_timer
= backlight_timeout_plugged
;
422 backlight_timer
= backlight_timeout
;
424 /* Backlight == OFF in the setting? */
425 if (backlight_timer
< 0)
427 backlight_timer
= 0; /* Disable the timeout */
428 #ifdef HAS_BUTTON_HOLD
429 if (backlight_on_button_hold
== 2 && button_hold())
430 return; /* Keep on if "On" */
436 #ifdef HAS_BUTTON_HOLD
437 if (backlight_on_button_hold
== 1 && button_hold())
439 /* Keep off if "Off". */
440 backlight_timer
= 0; /* Disable the timeout */
448 #ifdef HAVE_REMOTE_LCD
449 /* Update state of remote backlight according to timeout setting */
450 static void remote_backlight_update_state(void)
452 #ifdef CONFIG_CHARGING
453 if (charger_inserted()
454 #ifdef HAVE_USB_POWER
458 remote_backlight_timer
= remote_backlight_timeout_plugged
;
461 remote_backlight_timer
= remote_backlight_timeout
;
463 /* Backlight == OFF in the setting? */
464 if (remote_backlight_timer
< 0)
466 remote_backlight_timer
= 0; /* Disable the timeout */
467 #ifdef HAS_REMOTE_BUTTON_HOLD
468 if (remote_backlight_on_button_hold
== 2 && remote_button_hold())
469 return; /* Keep on if "On" */
471 __remote_backlight_off();
475 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
476 if (remote_type() == REMOTETYPE_H300_NONLCD
)
478 backlight_update_state();
483 #ifdef HAS_REMOTE_BUTTON_HOLD
484 if (remote_backlight_on_button_hold
== 1 && remote_button_hold())
486 /* Keep off if "Off". */
487 remote_backlight_timer
= 0; /* Disable the timeout */
491 __remote_backlight_on();
495 #endif /* HAVE_REMOTE_LCD */
497 void backlight_thread(void)
503 queue_wait(&backlight_queue
, &ev
);
506 #ifdef HAVE_REMOTE_LCD
507 case REMOTE_BACKLIGHT_ON
:
508 remote_backlight_update_state();
511 case REMOTE_BACKLIGHT_OFF
:
512 remote_backlight_timer
= 0; /* Disable the timeout */
513 #ifdef HAS_REMOTE_BUTTON_HOLD
514 if (remote_backlight_on_button_hold
== 2 &&
515 remote_button_hold())
516 break; /* Keep on if "On" */
518 __remote_backlight_off();
520 #endif /* HAVE_REMOTE_LCD */
523 backlight_update_state();
527 backlight_timer
= 0; /* Disable the timeout */
528 #ifdef HAS_BUTTON_HOLD
529 if (backlight_on_button_hold
== 2 && button_hold())
530 break; /* Keep on if "On" */
535 #ifdef HAVE_LCD_SLEEP
541 #ifdef X5_BACKLIGHT_SHUTDOWN
543 remove_thread(backlight_thread_id
);
547 #if defined(HAVE_BACKLIGHT_PWM_FADING) && defined(CPU_COLDFIRE) \
548 && !defined(SIMULATOR)
549 case BACKLIGHT_UNBOOST_CPU
:
554 case SYS_USB_CONNECTED
:
555 /* Tell the USB thread that we are safe */
556 DEBUGF("backlight_thread got SYS_USB_CONNECTED\n");
557 usb_acknowledge(SYS_USB_CONNECTED_ACK
);
560 case SYS_USB_DISCONNECTED
:
561 usb_acknowledge(SYS_USB_DISCONNECTED_ACK
);
567 static void backlight_tick(void)
569 #ifdef CONFIG_CHARGING
570 static bool charger_was_inserted
= false;
571 bool charger_is_inserted
= charger_inserted()
572 #ifdef HAVE_USB_POWER
577 if( charger_was_inserted
!= charger_is_inserted
)
580 #ifdef HAVE_REMOTE_LCD
581 remote_backlight_on();
584 charger_was_inserted
= charger_is_inserted
;
585 #endif /* CONFIG_CHARGING */
590 if(backlight_timer
== 0)
595 #ifdef HAVE_LCD_SLEEP
596 else if(lcd_sleep_timer
)
599 if(lcd_sleep_timer
== 0)
601 /* Queue on bl thread or freeze! */
602 queue_post(&backlight_queue
, LCD_SLEEP
, NULL
);
605 #endif /* HAVE_LCD_SLEEP */
607 #ifdef HAVE_REMOTE_LCD
608 if(remote_backlight_timer
)
610 remote_backlight_timer
--;
611 if(remote_backlight_timer
== 0)
613 remote_backlight_off();
616 #endif /* HAVE_REMOVE_LCD */
619 void backlight_init(void)
621 queue_init(&backlight_queue
, true);
622 #ifdef X5_BACKLIGHT_SHUTDOWN
623 backlight_thread_id
=
625 create_thread(backlight_thread
, backlight_stack
,
626 sizeof(backlight_stack
), backlight_thread_name
627 IF_PRIO(, PRIORITY_SYSTEM
));
628 tick_add_task(backlight_tick
);
631 #elif CONFIG_BACKLIGHT == BL_IRIVER_H100
632 or_l(0x00020000, &GPIO1_ENABLE
);
633 or_l(0x00020000, &GPIO1_FUNCTION
);
634 and_l(~0x00020000, &GPIO1_OUT
); /* Start with the backlight ON */
635 #elif CONFIG_BACKLIGHT == BL_IRIVER_H300
636 or_l(0x00020000, &GPIO1_ENABLE
);
637 or_l(0x00020000, &GPIO1_FUNCTION
);
638 or_l(0x00020000, &GPIO1_OUT
); /* Start with the backlight ON */
639 #elif CONFIG_BACKLIGHT == BL_PA14_LO || CONFIG_BACKLIGHT == BL_PA14_HI
640 PACR1
&= ~0x3000; /* Set PA14 (backlight control) to GPIO */
641 or_b(0x40, &PAIORH
); /* ..and output */
642 #elif CONFIG_BACKLIGHT == BL_GMINI
643 P1CON
|= 0x10; /* P1.4 C-MOS output mode */
646 #ifdef HAVE_REMOTE_LCD
647 remote_backlight_on();
651 #ifdef X5_BACKLIGHT_SHUTDOWN
652 void x5_backlight_shutdown(void)
654 /* Turn on the screen and don't let anyone else mess with it. Called
655 from clean_shutdown in misc.c. */
656 queue_empty(&backlight_queue
);
657 tick_remove_task(backlight_tick
);
658 /* Next time the thread runs, if at all, it will just remove itself. */
659 queue_post(&backlight_queue
, BACKLIGHT_QUIT
, NULL
);
662 #endif /* X5_BACKLIGHT_SHUTDOWN */
664 void backlight_on(void)
666 queue_post(&backlight_queue
, BACKLIGHT_ON
, NULL
);
669 void backlight_off(void)
671 queue_post(&backlight_queue
, BACKLIGHT_OFF
, NULL
);
674 /* returns true when the backlight is on OR when it's set to always off */
675 bool is_backlight_on(void)
677 if (backlight_timer
|| backlight_get_current_timeout() <= 0)
683 /* return value in ticks; 0 means always on, <0 means always off */
684 int backlight_get_current_timeout(void)
686 #ifdef CONFIG_CHARGING
687 if (charger_inserted()
688 #ifdef HAVE_USB_POWER
692 return backlight_timeout_plugged
;
694 return backlight_timeout
;
696 return backlight_timeout
;
700 void backlight_set_timeout(int index
)
702 if((unsigned)index
>= sizeof(backlight_timeout_value
))
703 /* if given a weird value, use default */
705 backlight_timeout
= HZ
* backlight_timeout_value
[index
];
706 backlight_update_state();
709 #ifdef CONFIG_CHARGING
710 void backlight_set_timeout_plugged(int index
)
712 if((unsigned)index
>= sizeof(backlight_timeout_value
))
713 /* if given a weird value, use default */
715 backlight_timeout_plugged
= HZ
* backlight_timeout_value
[index
];
716 backlight_update_state();
718 #endif /* CONFIG_CHARGING */
720 #ifdef HAS_BUTTON_HOLD
721 /* Hold button change event handler. */
722 void backlight_hold_changed(bool hold_button
)
724 /* Hold switch overrides all backlight behavior except when
726 /* Queue or freeze */
727 if (hold_button
&& backlight_on_button_hold
== 1)
728 backlight_off(); /* setting == Off */
729 else /* setting == On, Normal, no hold button, or anything else */
733 void backlight_set_on_button_hold(int index
)
735 if ((unsigned)index
>= 3)
736 /* if given a weird value, use default */
739 if (index
== backlight_on_button_hold
)
742 backlight_on_button_hold
= index
;
743 backlight_hold_changed(button_hold());
745 #endif /* HAS_BUTTON_HOLD */
747 #ifdef HAVE_LCD_SLEEP
748 void lcd_set_sleep_after_backlight_off(int index
)
750 if ((unsigned)index
>= sizeof(lcd_sleep_timeout_value
))
751 /* if given a weird value, use default */
754 lcd_sleep_timeout
= HZ
* lcd_sleep_timeout_value
[index
];
756 if (backlight_timer
> 0 || backlight_get_current_timeout() == 0)
757 /* Timer will be set when bl turns off or bl set to on. */
760 /* Backlight is Off */
761 if (lcd_sleep_timeout
< 0)
762 lcd_sleep_timer
= 1; /* Always - sleep next tick */
764 lcd_sleep_timer
= lcd_sleep_timeout
; /* Never, other */
766 #endif /* HAVE_LCD_SLEEP */
768 #ifdef HAVE_REMOTE_LCD
769 void remote_backlight_on(void)
771 queue_post(&backlight_queue
, REMOTE_BACKLIGHT_ON
, NULL
);
774 void remote_backlight_off(void)
776 queue_post(&backlight_queue
, REMOTE_BACKLIGHT_OFF
, NULL
);
779 void remote_backlight_set_timeout(int index
)
781 if((unsigned)index
>= sizeof(backlight_timeout_value
))
782 /* if given a weird value, use default */
784 remote_backlight_timeout
= HZ
* backlight_timeout_value
[index
];
785 remote_backlight_update_state();
788 #ifdef CONFIG_CHARGING
789 void remote_backlight_set_timeout_plugged(int index
)
791 if((unsigned)index
>= sizeof(backlight_timeout_value
))
792 /* if given a weird value, use default */
794 remote_backlight_timeout_plugged
= HZ
* backlight_timeout_value
[index
];
795 remote_backlight_update_state();
797 #endif /* CONFIG_CHARGING */
799 #ifdef HAS_REMOTE_BUTTON_HOLD
800 /* Remote hold button change event handler. */
801 void remote_backlight_hold_changed(bool rc_hold_button
)
803 /* Hold switch overrides all backlight behavior except when
805 /* Queue or freeze */
806 if (rc_hold_button
&& remote_backlight_on_button_hold
== 1)
807 remote_backlight_off(); /* setting == Off */
808 else /* setting == On, Normal, no hold button, or anything else */
809 remote_backlight_on();
813 void remote_backlight_set_on_button_hold(int index
)
815 if ((unsigned)index
>= 3)
816 /* if given a weird value, use default */
819 if (index
== remote_backlight_on_button_hold
)
822 remote_backlight_on_button_hold
= index
;
823 remote_backlight_hold_changed(remote_button_hold());
825 #endif /* HAS_REMOTE_BUTTON_HOLD */
827 /* return value in ticks; 0 means always on, <0 means always off */
828 int remote_backlight_get_current_timeout(void)
830 #ifdef CONFIG_CHARGING
831 if (charger_inserted()
832 #ifdef HAVE_USB_POWER
836 return remote_backlight_timeout_plugged
;
838 return remote_backlight_timeout
;
840 return remote_backlight_timeout
;
844 /* returns true when the backlight is on OR when it's set to always off */
845 bool is_remote_backlight_on(void)
847 if (remote_backlight_timer
!= 0 ||
848 remote_backlight_get_current_timeout() <= 0)
854 #endif /* HAVE_REMOTE_LCD */
856 #else /* !defined(CONFIG_BACKLIGHT) || defined(BOOTLOADER)
857 -- no backlight, empty dummy functions */
859 #if defined(BOOTLOADER) && defined(CONFIG_BACKLIGHT)
860 void backlight_init(void)
862 #ifdef IRIVER_H300_SERIES
863 or_l(0x00020000, &GPIO1_OUT
);
864 or_l(0x00020000, &GPIO1_ENABLE
);
865 or_l(0x00020000, &GPIO1_FUNCTION
);
870 void backlight_on(void) {}
871 void backlight_off(void) {}
872 void backlight_set_timeout(int index
) {(void)index
;}
873 bool is_backlight_on(void) {return true;}
874 #ifdef HAVE_REMOTE_LCD
875 void remote_backlight_on(void) {}
876 void remote_backlight_off(void) {}
877 void remote_backlight_set_timeout(int index
) {(void)index
;}
878 bool is_remote_backlight_on(void) {return true;}
880 #endif /* defined(CONFIG_BACKLIGHT) && !defined(BOOTLOADER) */
882 /* TODO: Move low level code to target/ tree. Create
883 __backlight_set_brightness and call from here. */
884 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
885 #if defined(IRIVER_H300_SERIES) || defined(IAUDIO_X5)
886 void backlight_set_brightness(int val
)
889 /* set brightness by changing the PWM
890 * accepts 0..15 but note that 0 and 1 give a black display on H300!
891 * 0 is black on the X5.
894 /* disable IRQs while bitbanging */
895 int old_irq_level
= set_irq_level(HIGHEST_IRQ_LEVEL
);
897 /* Clamp setting to range */
898 if(val
<MIN_BRIGHTNESS_SETTING
)
899 val
=MIN_BRIGHTNESS_SETTING
;
900 else if(val
>MAX_BRIGHTNESS_SETTING
)
901 val
=MAX_BRIGHTNESS_SETTING
;
903 pcf50606_write(0x35, (val
<< 1) | 0x01); /* 512Hz, Enable PWM */
905 /* enable IRQs again */
906 set_irq_level(old_irq_level
);
912 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */