D2: Adjustable backlight brightness (sometimes fails when boosted, suggests I2C timing needs adjustment). Tweak lcd_enable() to behave more like other targets.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16967 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
9b691d335a
commit
91202e1804
5 changed files with 69 additions and 45 deletions
|
@ -911,6 +911,7 @@ target/arm/tcc780x/cowond2/lcd-cowond2.c
|
|||
target/arm/tcc780x/cowond2/power-cowond2.c
|
||||
target/arm/tcc780x/cowond2/powermgmt-cowond2.c
|
||||
target/arm/tcc780x/cowond2/usb-cowond2.c
|
||||
target/arm/tcc780x/cowond2/backlight-cowond2.c
|
||||
#ifndef BOOTLOADER
|
||||
target/arm/tcc780x/kernel-tcc780x.c
|
||||
target/arm/tcc780x/timer-tcc780x.c
|
||||
|
|
|
@ -89,13 +89,13 @@
|
|||
/* Define this for LCD backlight available */
|
||||
#define HAVE_BACKLIGHT
|
||||
|
||||
/* TODO: Enable LCD brightness control */
|
||||
//#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||
/* Enable LCD brightness control */
|
||||
#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||
|
||||
/* Main LCD backlight brightness range and defaults */
|
||||
//#define MIN_BRIGHTNESS_SETTING 1
|
||||
//#define MAX_BRIGHTNESS_SETTING 10
|
||||
//#define DEFAULT_BRIGHTNESS_SETTING 8
|
||||
#define MIN_BRIGHTNESS_SETTING 1
|
||||
#define MAX_BRIGHTNESS_SETTING 14
|
||||
#define DEFAULT_BRIGHTNESS_SETTING 8
|
||||
|
||||
#define CONFIG_I2C I2C_TCC780X
|
||||
|
||||
|
|
56
firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c
Normal file
56
firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c
Normal file
|
@ -0,0 +1,56 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2008 by Rob Purchase
|
||||
*
|
||||
* 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 "backlight-target.h"
|
||||
#include "system.h"
|
||||
#include "backlight.h"
|
||||
#include "pcf50606.h"
|
||||
#include "tcc780x.h"
|
||||
|
||||
static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
|
||||
|
||||
int _backlight_init(void)
|
||||
{
|
||||
_backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
|
||||
return true;
|
||||
}
|
||||
|
||||
void _backlight_set_brightness(int brightness)
|
||||
{
|
||||
backlight_brightness = brightness;
|
||||
|
||||
int level = disable_irq_save();
|
||||
pcf50606_write(PCF5060X_PWMC1, 0xe1 | (14-backlight_brightness)<<1);
|
||||
pcf50606_write(PCF5060X_GPOC1, 0x3);
|
||||
restore_irq(level);
|
||||
|
||||
if (brightness > 0)
|
||||
_backlight_on();
|
||||
else
|
||||
_backlight_off();
|
||||
}
|
||||
|
||||
void _backlight_on(void)
|
||||
{
|
||||
GPIOA_SET = (1<<6);
|
||||
}
|
||||
|
||||
void _backlight_off(void)
|
||||
{
|
||||
GPIOA_CLEAR = (1<<6);
|
||||
}
|
|
@ -19,22 +19,9 @@
|
|||
#ifndef BACKLIGHT_TARGET_H
|
||||
#define BACKLIGHT_TARGET_H
|
||||
|
||||
#include "tcc780x.h"
|
||||
|
||||
#define _backlight_init() true
|
||||
|
||||
/* nb: we can set the backlight intensity using PCF50606 register 0x35 */
|
||||
|
||||
static inline void _backlight_on(void)
|
||||
{
|
||||
/* Enable backlight */
|
||||
GPIOA_SET = (1<<6);
|
||||
}
|
||||
|
||||
static inline void _backlight_off(void)
|
||||
{
|
||||
/* Disable backlight */
|
||||
GPIOA_CLEAR = (1<<6);
|
||||
}
|
||||
int _backlight_init(void);
|
||||
void _backlight_on(void);
|
||||
void _backlight_off(void);
|
||||
void _backlight_set_brightness(int brightness);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "lcd.h"
|
||||
#include "system.h"
|
||||
#include "cpu.h"
|
||||
#include "i2c.h"
|
||||
|
||||
/* GPIO A pins for LCD panel SDI interface */
|
||||
|
||||
|
@ -100,16 +99,6 @@ static void lcd_write_reg(unsigned char reg, unsigned short val)
|
|||
}
|
||||
|
||||
|
||||
/* TODO: The existing pcf50606 drivers are target-specific, so the following
|
||||
lonely function exists until a D2 driver exists. */
|
||||
|
||||
void pcf50606_write_reg(unsigned char reg, unsigned char val)
|
||||
{
|
||||
unsigned char data[] = { reg, val };
|
||||
i2c_write(0x10, data, 2);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TEMP: Rough millisecond delay routine used by the LCD panel init sequence.
|
||||
PCK_TCT must first have been initialised to 2Mhz by calling clock_init().
|
||||
|
@ -190,9 +179,6 @@ static void lcd_display_on(void)
|
|||
lcd_write_reg(10, 0x111F);
|
||||
sleep_ms(10);
|
||||
|
||||
pcf50606_write_reg(0x35, 0xe9); /* PWMC1 - backlight power (intensity) */
|
||||
pcf50606_write_reg(0x38, 0x3); /* GPOC1 - ? */
|
||||
|
||||
/* tell that we're on now */
|
||||
display_on = true;
|
||||
}
|
||||
|
@ -213,9 +199,6 @@ static void lcd_display_off(void)
|
|||
|
||||
/* kill power to LCD panel (unconfirmed) */
|
||||
GPIOA_CLEAR = (1<<16);
|
||||
|
||||
/* also kill the backlight, otherwise LCD fade is visible on screen */
|
||||
GPIOA_CLEAR = (1<<6);
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,14 +209,14 @@ void lcd_enable(bool on)
|
|||
|
||||
if (on)
|
||||
{
|
||||
lcd_display_on();
|
||||
LCDC_CTRL |= 1; /* controller enable */
|
||||
GPIOA_SET = (1<<6); /* backlight enable - not visible otherwise */
|
||||
lcd_update(); /* Resync display */
|
||||
}
|
||||
else
|
||||
{
|
||||
LCDC_CTRL &= ~1; /* controller disable */
|
||||
GPIOA_CLEAR = (1<<6); /* backlight off */
|
||||
LCDC_CTRL &= ~1; /* controller disable */
|
||||
lcd_display_off();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,9 +273,6 @@ void lcd_init_device(void)
|
|||
|
||||
/* enable LTV250QV panel */
|
||||
lcd_display_on();
|
||||
|
||||
/* turn on the backlight, without it the LCD is not visible at all */
|
||||
GPIOA_SET = (1<<6);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue