summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHristo Kovachev <bger@rockbox.org>2006-01-19 13:10:15 +0000
committerHristo Kovachev <bger@rockbox.org>2006-01-19 13:10:15 +0000
commit4926682378ea22225675a4155a4fd3e5671f1a1c (patch)
tree0ef2efeecdcd16e1b483e0d518dd89de7059ba7e
parentacf7d5e89e356cfe9e137e7e9eff74ddbbc9bc09 (diff)
downloadrockbox-4926682378ea22225675a4155a4fd3e5671f1a1c.tar.gz
rockbox-4926682378ea22225675a4155a4fd3e5671f1a1c.zip
Patch #1404233 by Peter D'Hoye: H300 brightness bugfix
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8387 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/backlight.c24
-rw-r--r--firmware/drivers/pcf50606.c23
-rw-r--r--firmware/export/pcf50606.h1
3 files changed, 21 insertions, 27 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 25a91632cd..5e79e4e479 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -547,13 +547,29 @@ void remote_backlight_set_timeout(int index) {(void)index;}
547#endif /* #ifdef CONFIG_BACKLIGHT */ 547#endif /* #ifdef CONFIG_BACKLIGHT */
548 548
549#ifdef HAVE_BACKLIGHT_BRIGHTNESS 549#ifdef HAVE_BACKLIGHT_BRIGHTNESS
550#ifdef IRIVER_H300_SERIES
550void backlight_set_brightness(int val) 551void backlight_set_brightness(int val)
551{ 552{
552 /* set H300 brightness by changing the PWM 553 /* set H300 brightness by changing the PWM
553 accepts 0..15 but note that 0 and 1 gives a black display! */ 554 accepts 0..15 but note that 0 and 1 give a black display! */
554 if(val < MIN_BRIGHTNESS_SETTING) 555 val &= 0x0F;
555 val = MIN_BRIGHTNESS_SETTING; 556 if(val<MIN_BRIGHTNESS_SETTING)
556 pcf50606_set_bl_pwm(val & 0xf); 557 val=MIN_BRIGHTNESS_SETTING;
558
559 /* shift one bit left */
560 val <<= 1;
561
562 /* enable PWM */
563 val |= 0x01;
564
565 /* disable IRQs while bitbanging */
566 int old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL);
567
568 pcf50606_write(0x35, val);
569
570 /* enable IRQs again */
571 set_irq_level(old_irq_level);
557} 572}
558#endif 573#endif
574#endif
559 575
diff --git a/firmware/drivers/pcf50606.c b/firmware/drivers/pcf50606.c
index af2c2ca2eb..f4c93deb38 100644
--- a/firmware/drivers/pcf50606.c
+++ b/firmware/drivers/pcf50606.c
@@ -44,8 +44,6 @@
44/* delay loop to achieve 400kHz at 120MHz CPU frequency */ 44/* delay loop to achieve 400kHz at 120MHz CPU frequency */
45#define DELAY do { int _x; for(_x=0;_x<22;_x++);} while(0) 45#define DELAY do { int _x; for(_x=0;_x<22;_x++);} while(0)
46 46
47void pcf50606_set_bl_pwm(unsigned char ucVal);
48
49static void pcf50606_i2c_start(void) 47static void pcf50606_i2c_start(void)
50{ 48{
51 SDA_OUTPUT; 49 SDA_OUTPUT;
@@ -285,24 +283,5 @@ void pcf50606_init(void)
285 pcf50606_write(0x09, 0x05); /* USB and ON key debounce: 14ms */ 283 pcf50606_write(0x09, 0x05); /* USB and ON key debounce: 14ms */
286 pcf50606_write(0x29, 0x1C); /* Disable the unused MBC module */ 284 pcf50606_write(0x29, 0x1C); /* Disable the unused MBC module */
287 285
288 /* Backlight PWM = 512Hz 50/50 */ 286 pcf50606_write(0x35, 0x13); /* Backlight PWM = 512Hz 50/50 */
289 /*pcf50606_write(0x35, 0x13);*/
290 pcf50606_set_bl_pwm(9);
291}
292
293void pcf50606_set_bl_pwm(unsigned char ucVal)
294{
295 /* set the backlight PWM */
296 /* range is 0 - 15 */
297
298 /* limit incoming value */
299 ucVal = ucVal & 0x0F;
300
301 /* shift one bit left */
302 ucVal = ucVal << 1;
303 ucVal = ucVal | 0x01;
304
305 /* 0x00 = 512Hz */
306 ucVal = ucVal | 0x00;
307 pcf50606_write(0x35, ucVal);
308} 287}
diff --git a/firmware/export/pcf50606.h b/firmware/export/pcf50606.h
index daacbac725..fd180bfaee 100644
--- a/firmware/export/pcf50606.h
+++ b/firmware/export/pcf50606.h
@@ -25,7 +25,6 @@ int pcf50606_write_multiple(int address, const unsigned char* buf, int count);
25int pcf50606_write(int address, unsigned char val); 25int pcf50606_write(int address, unsigned char val);
26int pcf50606_read_multiple(int address, unsigned char* buf, int count); 26int pcf50606_read_multiple(int address, unsigned char* buf, int count);
27int pcf50606_read(int address); 27int pcf50606_read(int address);
28void pcf50606_set_bl_pwm(unsigned char ucVal);
29#endif 28#endif
30 29
31#endif 30#endif