Patch #1404233 by Peter D'Hoye: H300 brightness bugfix

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8387 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Hristo Kovachev 2006-01-19 13:10:15 +00:00
parent acf7d5e89e
commit 4926682378
3 changed files with 21 additions and 27 deletions

View File

@ -547,13 +547,29 @@ void remote_backlight_set_timeout(int index) {(void)index;}
#endif /* #ifdef CONFIG_BACKLIGHT */
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
#ifdef IRIVER_H300_SERIES
void backlight_set_brightness(int val)
{
/* set H300 brightness by changing the PWM
accepts 0..15 but note that 0 and 1 gives a black display! */
if(val < MIN_BRIGHTNESS_SETTING)
val = MIN_BRIGHTNESS_SETTING;
pcf50606_set_bl_pwm(val & 0xf);
accepts 0..15 but note that 0 and 1 give a black display! */
val &= 0x0F;
if(val<MIN_BRIGHTNESS_SETTING)
val=MIN_BRIGHTNESS_SETTING;
/* shift one bit left */
val <<= 1;
/* enable PWM */
val |= 0x01;
/* disable IRQs while bitbanging */
int old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL);
pcf50606_write(0x35, val);
/* enable IRQs again */
set_irq_level(old_irq_level);
}
#endif
#endif

View File

@ -44,8 +44,6 @@
/* delay loop to achieve 400kHz at 120MHz CPU frequency */
#define DELAY do { int _x; for(_x=0;_x<22;_x++);} while(0)
void pcf50606_set_bl_pwm(unsigned char ucVal);
static void pcf50606_i2c_start(void)
{
SDA_OUTPUT;
@ -285,24 +283,5 @@ void pcf50606_init(void)
pcf50606_write(0x09, 0x05); /* USB and ON key debounce: 14ms */
pcf50606_write(0x29, 0x1C); /* Disable the unused MBC module */
/* Backlight PWM = 512Hz 50/50 */
/*pcf50606_write(0x35, 0x13);*/
pcf50606_set_bl_pwm(9);
}
void pcf50606_set_bl_pwm(unsigned char ucVal)
{
/* set the backlight PWM */
/* range is 0 - 15 */
/* limit incoming value */
ucVal = ucVal & 0x0F;
/* shift one bit left */
ucVal = ucVal << 1;
ucVal = ucVal | 0x01;
/* 0x00 = 512Hz */
ucVal = ucVal | 0x00;
pcf50606_write(0x35, ucVal);
pcf50606_write(0x35, 0x13); /* Backlight PWM = 512Hz 50/50 */
}

View File

@ -25,7 +25,6 @@ int pcf50606_write_multiple(int address, const unsigned char* buf, int count);
int pcf50606_write(int address, unsigned char val);
int pcf50606_read_multiple(int address, unsigned char* buf, int count);
int pcf50606_read(int address);
void pcf50606_set_bl_pwm(unsigned char ucVal);
#endif
#endif