2006-10-30 08:56:06 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 by Linus Nielsen Feltzing
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2006-10-30 08:56:06 +00:00
|
|
|
*
|
|
|
|
* 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 "kernel.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "backlight.h"
|
2009-08-06 09:28:25 +00:00
|
|
|
#include "backlight-target.h"
|
2006-10-30 08:56:06 +00:00
|
|
|
#include "pcf50606.h"
|
|
|
|
#include "lcd.h"
|
|
|
|
|
2015-01-08 23:22:40 +00:00
|
|
|
bool backlight_hw_init(void)
|
2006-11-10 18:47:41 +00:00
|
|
|
{
|
|
|
|
or_l(0x00020000, &GPIO1_ENABLE);
|
|
|
|
or_l(0x00020000, &GPIO1_FUNCTION);
|
|
|
|
or_l(0x00020000, &GPIO1_OUT); /* Start with the 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
|
|
|
}
|
|
|
|
|
2015-01-08 23:22:40 +00:00
|
|
|
void backlight_hw_on(void)
|
2006-10-30 08:56:06 +00:00
|
|
|
{
|
|
|
|
lcd_enable(true);
|
|
|
|
sleep(HZ/100); /* lcd needs time - avoid flashing for dark screens */
|
|
|
|
or_l(0x00020000, &GPIO1_OUT);
|
|
|
|
}
|
|
|
|
|
2015-01-08 23:22:40 +00:00
|
|
|
void backlight_hw_off(void)
|
2006-10-30 08:56:06 +00:00
|
|
|
{
|
|
|
|
and_l(~0x00020000, &GPIO1_OUT);
|
|
|
|
lcd_enable(false);
|
|
|
|
}
|
|
|
|
|
2006-11-10 01:25:52 +00:00
|
|
|
/* set brightness by changing the PWM */
|
2015-01-08 23:22:40 +00:00
|
|
|
void backlight_hw_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
|
|
|
}
|
|
|
|
|
2015-01-08 23:22:40 +00:00
|
|
|
void remote_backlight_hw_on(void)
|
2006-10-30 08:56:06 +00:00
|
|
|
{
|
|
|
|
and_l(~0x00000002, &GPIO1_OUT);
|
|
|
|
}
|
|
|
|
|
2015-01-08 23:22:40 +00:00
|
|
|
void remote_backlight_hw_off(void)
|
2006-10-30 08:56:06 +00:00
|
|
|
{
|
|
|
|
or_l(0x00000002, &GPIO1_OUT);
|
|
|
|
}
|