From 9b83c6c4bddca41411d31b8aab17ecc577b37eb4 Mon Sep 17 00:00:00 2001 From: Hristo Kovachev Date: Thu, 22 Dec 2005 10:43:36 +0000 Subject: Patch No 1387627 by Peter D'Hoye: Backlight Brightness setting for H300 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8280 a1c6a512-1295-4272-9138-f99709370657 --- firmware/backlight.c | 14 ++++++++++++++ firmware/drivers/pcf50606.c | 21 ++++++++++++++++++++- firmware/export/backlight.h | 4 ++++ firmware/export/config-h300.h | 2 ++ firmware/export/pcf50606.h | 1 + 5 files changed, 41 insertions(+), 1 deletion(-) (limited to 'firmware') diff --git a/firmware/backlight.c b/firmware/backlight.c index 291c5da8e7..d118830721 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c @@ -30,6 +30,10 @@ #include "timer.h" #include "backlight.h" +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +#include "pcf50606.h" /* iRiver brightness */ +#endif + #if CONFIG_BACKLIGHT == BL_IRIVER_H300 #include "lcd.h" /* for lcd_enable() */ #endif @@ -538,3 +542,13 @@ void remote_backlight_set_timeout(int index) {(void)index;} #endif #endif /* #ifdef CONFIG_BACKLIGHT */ +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +void backlight_set_brightness(int val) +{ + /* set H300 brightness by changing the PWM + accepts 0..15 but note that 0 and 1 give a black display! */ + unsigned char ucVal = (unsigned char)(val & 0x0F); + pcf50606_set_bl_pwm(ucVal); +} +#endif + diff --git a/firmware/drivers/pcf50606.c b/firmware/drivers/pcf50606.c index b99b2e9e88..cb05d25345 100644 --- a/firmware/drivers/pcf50606.c +++ b/firmware/drivers/pcf50606.c @@ -44,6 +44,7 @@ /* 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) { @@ -281,5 +282,23 @@ void pcf50606_init(void) set_voltages(); /* Backlight PWM = 512Hz 50/50 */ - pcf50606_write(0x35, 0x13); + /*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); } diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h index 9c3f5aa90b..f4c62a2028 100644 --- a/firmware/export/backlight.h +++ b/firmware/export/backlight.h @@ -49,3 +49,7 @@ void sim_backlight(int value); void sim_remote_backlight(int value); #endif #endif + +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +void backlight_set_brightness(int val); +#endif diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h index 20e27c505b..54a2ef543f 100644 --- a/firmware/export/config-h300.h +++ b/firmware/export/config-h300.h @@ -100,4 +100,6 @@ #define BOOTFILE_EXT "iriver" #define BOOTFILE "rockbox." BOOTFILE_EXT +#define HAVE_BACKLIGHT_BRIGHTNESS + #endif diff --git a/firmware/export/pcf50606.h b/firmware/export/pcf50606.h index fd180bfaee..daacbac725 100644 --- a/firmware/export/pcf50606.h +++ b/firmware/export/pcf50606.h @@ -25,6 +25,7 @@ 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 -- cgit v1.2.3