2006-03-22 14:17:45 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 by Linus Nielsen Feltzing
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "config.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "backlight.h"
|
2006-11-10 18:47:41 +00:00
|
|
|
#include "backlight-target.h"
|
2006-03-22 14:17:45 +00:00
|
|
|
#include "pcf50606.h"
|
2006-08-08 22:03:56 +00:00
|
|
|
#include "lcd.h"
|
2006-03-22 14:17:45 +00:00
|
|
|
|
2007-11-12 18:49:53 +00:00
|
|
|
bool _backlight_init(void)
|
2006-11-10 18:47:41 +00:00
|
|
|
{
|
2007-11-12 18:49:53 +00:00
|
|
|
_backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
|
|
|
|
_backlight_on();
|
2007-01-12 20:26:23 +00:00
|
|
|
|
|
|
|
return true; /* Backlight always ON after boot. */
|
2006-11-10 18:47:41 +00:00
|
|
|
}
|
|
|
|
|
2007-11-12 18:49:53 +00:00
|
|
|
void _backlight_on(void)
|
2006-03-22 14:17:45 +00:00
|
|
|
{
|
2006-08-08 22:03:56 +00:00
|
|
|
int level;
|
|
|
|
lcd_enable(true);
|
2007-11-12 19:19:38 +00:00
|
|
|
#ifndef BOOTLOADER
|
2007-11-12 18:49:53 +00:00
|
|
|
_lcd_sleep_timer = 0; /* LCD should be awake already */
|
2007-11-12 19:19:38 +00:00
|
|
|
#endif
|
2008-03-26 01:50:41 +00:00
|
|
|
level = disable_irq_save();
|
2006-07-25 15:21:31 +00:00
|
|
|
pcf50606_write(0x38, 0xb0); /* Backlight ON, GPO1INV=1, GPO1ACT=011 */
|
2008-03-26 01:50:41 +00:00
|
|
|
restore_irq(level);
|
2006-03-22 14:17:45 +00:00
|
|
|
}
|
|
|
|
|
2007-11-12 18:49:53 +00:00
|
|
|
void _backlight_off(void)
|
2006-03-22 14:17:45 +00:00
|
|
|
{
|
2008-03-26 01:50:41 +00:00
|
|
|
int level = disable_irq_save();
|
2006-07-25 15:21:31 +00:00
|
|
|
pcf50606_write(0x38, 0x80); /* Backlight OFF, GPO1INV=1, GPO1ACT=000 */
|
2008-03-26 01:50:41 +00:00
|
|
|
restore_irq(level);
|
2006-08-08 22:03:56 +00:00
|
|
|
lcd_enable(false);
|
2007-11-12 19:19:38 +00:00
|
|
|
#ifndef BOOTLOADER
|
2007-11-12 18:49:53 +00:00
|
|
|
/* Start LCD sleep countdown */
|
|
|
|
if (_lcd_sleep_timeout < 0)
|
|
|
|
{
|
|
|
|
_lcd_sleep_timer = 0; /* Setting == Always */
|
|
|
|
lcd_sleep();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_lcd_sleep_timer = _lcd_sleep_timeout;
|
2007-11-12 19:19:38 +00:00
|
|
|
#endif
|
2006-03-22 14:17:45 +00:00
|
|
|
}
|
2006-07-26 13:38:31 +00:00
|
|
|
|
2006-11-10 01:25:52 +00:00
|
|
|
/* set brightness by changing the PWM */
|
2007-11-12 18:49:53 +00:00
|
|
|
void _backlight_set_brightness(int val)
|
2006-11-10 01:25:52 +00:00
|
|
|
{
|
|
|
|
/* disable IRQs while bitbanging */
|
2008-03-26 01:50:41 +00:00
|
|
|
int old_irq_level = disable_irq_save();
|
2006-11-10 01:25:52 +00:00
|
|
|
pcf50606_write(0x35, (val << 1) | 0x01); /* 512Hz, Enable PWM */
|
|
|
|
/* enable IRQs again */
|
2008-03-26 01:50:41 +00:00
|
|
|
restore_irq(old_irq_level);
|
2006-11-10 01:25:52 +00:00
|
|
|
}
|
|
|
|
|
2007-11-12 18:49:53 +00:00
|
|
|
void _remote_backlight_on(void)
|
2006-07-26 13:38:31 +00:00
|
|
|
{
|
|
|
|
and_l(~0x00200000, &GPIO_OUT);
|
|
|
|
}
|
|
|
|
|
2007-11-12 18:49:53 +00:00
|
|
|
void _remote_backlight_off(void)
|
2006-07-26 13:38:31 +00:00
|
|
|
{
|
|
|
|
or_l(0x00200000, &GPIO_OUT);
|
|
|
|
}
|