summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/backlight.c61
-rw-r--r--firmware/export/config-h100.h19
-rw-r--r--firmware/export/config-h120.h19
-rw-r--r--firmware/export/config-h300.h13
-rw-r--r--firmware/export/config-iaudiox5.h34
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/backlight-target.h2
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/backlight-x5.c7
-rw-r--r--firmware/target/coldfire/iaudio/x5/pcf50606-x5.c9
-rw-r--r--firmware/target/coldfire/iriver/backlight-target.h2
-rw-r--r--firmware/target/coldfire/iriver/h100/backlight-h100.c7
-rw-r--r--firmware/target/coldfire/iriver/h300/backlight-h300.c7
11 files changed, 98 insertions, 82 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index e1d92581c4..bc692b1675 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -31,10 +31,6 @@
31#include "timer.h" 31#include "timer.h"
32#include "backlight.h" 32#include "backlight.h"
33 33
34#ifdef HAVE_BACKLIGHT_BRIGHTNESS
35#include "pcf50606.h" /* iRiver, iAudio X5 brightness */
36#endif
37
38#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) 34#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
39#include "lcd.h" /* for lcd_enable() and lcd_sleep() */ 35#include "lcd.h" /* for lcd_enable() and lcd_sleep() */
40#endif 36#endif
@@ -110,8 +106,6 @@ static void backlight_thread(void);
110static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)]; 106static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)];
111#ifdef X5_BACKLIGHT_SHUTDOWN 107#ifdef X5_BACKLIGHT_SHUTDOWN
112#define BACKLIGHT_QUIT 256 108#define BACKLIGHT_QUIT 256
113/* Need to save this for x5 shutdown */
114struct thread_entry* backlight_thread_id;
115#endif 109#endif
116static const char backlight_thread_name[] = "backlight"; 110static const char backlight_thread_name[] = "backlight";
117static struct event_queue backlight_queue; 111static struct event_queue backlight_queue;
@@ -473,7 +467,7 @@ void backlight_thread(void)
473 467
474#ifdef X5_BACKLIGHT_SHUTDOWN 468#ifdef X5_BACKLIGHT_SHUTDOWN
475 case BACKLIGHT_QUIT: 469 case BACKLIGHT_QUIT:
476 remove_thread(backlight_thread_id); 470 remove_thread(NULL);
477 break; 471 break;
478#endif 472#endif
479 473
@@ -552,23 +546,17 @@ static void backlight_tick(void)
552void backlight_init(void) 546void backlight_init(void)
553{ 547{
554 queue_init(&backlight_queue, true); 548 queue_init(&backlight_queue, true);
555#ifdef X5_BACKLIGHT_SHUTDOWN
556 backlight_thread_id =
557#endif
558 create_thread(backlight_thread, backlight_stack, 549 create_thread(backlight_thread, backlight_stack,
559 sizeof(backlight_stack), backlight_thread_name 550 sizeof(backlight_stack), backlight_thread_name
560 IF_PRIO(, PRIORITY_SYSTEM)); 551 IF_PRIO(, PRIORITY_SYSTEM));
561 tick_add_task(backlight_tick); 552 tick_add_task(backlight_tick);
562#ifdef SIMULATOR 553#ifdef SIMULATOR
563 /* do nothing */ 554 /* do nothing */
564#elif CONFIG_BACKLIGHT == BL_IRIVER_H100 555#elif defined(__BACKLIGHT_INIT)
565 or_l(0x00020000, &GPIO1_ENABLE); 556 /* Remove the __BACKLIGHT_INIT references when __backlight_init is
566 or_l(0x00020000, &GPIO1_FUNCTION); 557 available on all backlighted targets. Take them out of the
567 and_l(~0x00020000, &GPIO1_OUT); /* Start with the backlight ON */ 558 backlight-target.h files as well */
568#elif CONFIG_BACKLIGHT == BL_IRIVER_H300 559 __backlight_init();
569 or_l(0x00020000, &GPIO1_ENABLE);
570 or_l(0x00020000, &GPIO1_FUNCTION);
571 or_l(0x00020000, &GPIO1_OUT); /* Start with the backlight ON */
572#elif CONFIG_BACKLIGHT == BL_PA14_LO || CONFIG_BACKLIGHT == BL_PA14_HI 560#elif CONFIG_BACKLIGHT == BL_PA14_LO || CONFIG_BACKLIGHT == BL_PA14_HI
573 PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */ 561 PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
574 or_b(0x40, &PAIORH); /* ..and output */ 562 or_b(0x40, &PAIORH); /* ..and output */
@@ -787,16 +775,26 @@ bool is_remote_backlight_on(void)
787 775
788#endif /* HAVE_REMOTE_LCD */ 776#endif /* HAVE_REMOTE_LCD */
789 777
778#ifdef HAVE_BACKLIGHT_BRIGHTNESS
779void backlight_set_brightness(int val)
780{
781 if (val < MIN_BRIGHTNESS_SETTING)
782 val = MIN_BRIGHTNESS_SETTING;
783 else if (val > MAX_BRIGHTNESS_SETTING)
784 val = MAX_BRIGHTNESS_SETTING;
785
786 __backlight_set_brightness(val);
787}
788#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
789
790#else /* !defined(CONFIG_BACKLIGHT) || defined(BOOTLOADER) 790#else /* !defined(CONFIG_BACKLIGHT) || defined(BOOTLOADER)
791 -- no backlight, empty dummy functions */ 791 -- no backlight, empty dummy functions */
792 792
793#if defined(BOOTLOADER) && defined(CONFIG_BACKLIGHT) 793#if defined(BOOTLOADER) && defined(CONFIG_BACKLIGHT)
794void backlight_init(void) 794void backlight_init(void)
795{ 795{
796#ifdef IRIVER_H300_SERIES 796#ifdef __BACKLIGHT_INIT
797 or_l(0x00020000, &GPIO1_OUT); 797 __backlight_init();
798 or_l(0x00020000, &GPIO1_ENABLE);
799 or_l(0x00020000, &GPIO1_FUNCTION);
800#endif 798#endif
801} 799}
802#endif 800#endif
@@ -810,21 +808,8 @@ void remote_backlight_on(void) {}
810void remote_backlight_off(void) {} 808void remote_backlight_off(void) {}
811void remote_backlight_set_timeout(int index) {(void)index;} 809void remote_backlight_set_timeout(int index) {(void)index;}
812bool is_remote_backlight_on(void) {return true;} 810bool is_remote_backlight_on(void) {return true;}
813#endif 811#endif /* HAVE_REMOTE_LCD */
814#endif /* defined(CONFIG_BACKLIGHT) && !defined(BOOTLOADER) */
815
816#ifdef HAVE_BACKLIGHT_BRIGHTNESS 812#ifdef HAVE_BACKLIGHT_BRIGHTNESS
817void backlight_set_brightness(int val) 813void backlight_set_brightness(int val) { (void)val; }
818{
819#ifndef SIMULATOR
820 if (val < MIN_BRIGHTNESS_SETTING)
821 val = MIN_BRIGHTNESS_SETTING;
822 else if (val > MAX_BRIGHTNESS_SETTING)
823 val = MAX_BRIGHTNESS_SETTING;
824
825 __backlight_set_brightness(val);
826#else
827 (void)val;
828#endif 814#endif
829} 815#endif /* defined(CONFIG_BACKLIGHT) && !defined(BOOTLOADER) */
830#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h
index 8ef227676a..fd84f37061 100644
--- a/firmware/export/config-h100.h
+++ b/firmware/export/config-h100.h
@@ -154,13 +154,6 @@
154 154
155#endif /* !SIMULATOR */ 155#endif /* !SIMULATOR */
156 156
157#define DEFAULT_CONTRAST_SETTING 28
158#define MIN_CONTRAST_SETTING 14 /* White screen a bit higher than this */
159#define MAX_CONTRAST_SETTING 63 /* Black screen a bit lower than this*/
160#define DEFAULT_REMOTE_CONTRAST_SETTING 42
161#define MIN_REMOTE_CONTRAST_SETTING MIN_CONTRAST_SETTING
162#define MAX_REMOTE_CONTRAST_SETTING MAX_CONTRAST_SETTING
163
164/* Define this for S/PDIF input available */ 157/* Define this for S/PDIF input available */
165#define HAVE_SPDIF_IN 158#define HAVE_SPDIF_IN
166 159
@@ -173,3 +166,15 @@
173 166
174/* Define this for FM radio input available */ 167/* Define this for FM radio input available */
175#define HAVE_FMRADIO_IN 168#define HAVE_FMRADIO_IN
169
170/** Port-specific settings **/
171
172/* Main LCD backlight brightness range and defaults */
173#define MIN_CONTRAST_SETTING 14 /* White screen a bit higher than this */
174#define MAX_CONTRAST_SETTING 63 /* Black screen a bit lower than this */
175#define DEFAULT_CONTRAST_SETTING 28
176
177/* Remote LCD contrast range and defaults */
178#define MIN_REMOTE_CONTRAST_SETTING 5
179#define MAX_REMOTE_CONTRAST_SETTING 63
180#define DEFAULT_REMOTE_CONTRAST_SETTING 42
diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h
index e4c5cfe876..4a8a3c99be 100644
--- a/firmware/export/config-h120.h
+++ b/firmware/export/config-h120.h
@@ -150,13 +150,6 @@
150 150
151#endif /* !SIMULATOR */ 151#endif /* !SIMULATOR */
152 152
153#define DEFAULT_CONTRAST_SETTING 28
154#define MIN_CONTRAST_SETTING 14 /* White screen a bit higher than this */
155#define MAX_CONTRAST_SETTING 63 /* Black screen a bit lower than this*/
156#define DEFAULT_REMOTE_CONTRAST_SETTING 42
157#define MIN_REMOTE_CONTRAST_SETTING MIN_CONTRAST_SETTING
158#define MAX_REMOTE_CONTRAST_SETTING MAX_CONTRAST_SETTING
159
160/* Define this for S/PDIF input available */ 153/* Define this for S/PDIF input available */
161#define HAVE_SPDIF_IN 154#define HAVE_SPDIF_IN
162 155
@@ -171,3 +164,15 @@
171 164
172/* Define this if you have a serial port */ 165/* Define this if you have a serial port */
173/*#define HAVE_SERIAL*/ 166/*#define HAVE_SERIAL*/
167
168/** Port-specific settings **/
169
170/* Main LCD backlight brightness range and defaults */
171#define DEFAULT_CONTRAST_SETTING 28
172#define MIN_CONTRAST_SETTING 14 /* White screen a bit higher than this */
173#define MAX_CONTRAST_SETTING 63 /* Black screen a bit lower than this */
174
175/* Remote LCD contrast range and defaults */
176#define MIN_REMOTE_CONTRAST_SETTING 5
177#define MAX_REMOTE_CONTRAST_SETTING 63
178#define DEFAULT_REMOTE_CONTRAST_SETTING 42
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h
index 14034c61f0..b44a2c5108 100644
--- a/firmware/export/config-h300.h
+++ b/firmware/export/config-h300.h
@@ -151,6 +151,12 @@
151#define HAVE_EEPROM 151#define HAVE_EEPROM
152 152
153#endif /* SIMULATOR */ 153#endif /* SIMULATOR */
154
155/* Define this for FM radio input available */
156#define HAVE_FMRADIO_IN
157
158/** Port-specific settings **/
159
154/* Main LCD contrast range and defaults */ 160/* Main LCD contrast range and defaults */
155#define MIN_CONTRAST_SETTING 5 161#define MIN_CONTRAST_SETTING 5
156#define MAX_CONTRAST_SETTING 63 162#define MAX_CONTRAST_SETTING 63
@@ -163,9 +169,6 @@
163#define DEFAULT_BRIGHTNESS_SETTING 9 /* 9/16 (56.25%) */ 169#define DEFAULT_BRIGHTNESS_SETTING 9 /* 9/16 (56.25%) */
164 170
165/* Remote LCD contrast range and defaults */ 171/* Remote LCD contrast range and defaults */
166#define MIN_REMOTE_CONTRAST_SETTING MIN_CONTRAST_SETTING 172#define MIN_REMOTE_CONTRAST_SETTING 5
167#define MAX_REMOTE_CONTRAST_SETTING MAX_CONTRAST_SETTING 173#define MAX_REMOTE_CONTRAST_SETTING 63
168#define DEFAULT_REMOTE_CONTRAST_SETTING 42 174#define DEFAULT_REMOTE_CONTRAST_SETTING 42
169
170/* Define this for FM radio input available */
171#define HAVE_FMRADIO_IN
diff --git a/firmware/export/config-iaudiox5.h b/firmware/export/config-iaudiox5.h
index d45f58f14c..82c36437f5 100644
--- a/firmware/export/config-iaudiox5.h
+++ b/firmware/export/config-iaudiox5.h
@@ -62,22 +62,6 @@
62 62
63#define CONFIG_LCD LCD_X5 63#define CONFIG_LCD LCD_X5
64 64
65/* Main LCD contrast range and defaults */
66#define MIN_CONTRAST_SETTING 1
67#define MAX_CONTRAST_SETTING 30
68#define DEFAULT_CONTRAST_SETTING 19 /* Match boot contrast */
69
70/* Remote LCD contrast range and defaults */
71#define MIN_REMOTE_CONTRAST_SETTING 10
72#define MAX_REMOTE_CONTRAST_SETTING 35
73#define DEFAULT_REMOTE_CONTRAST_SETTING 24 /* Match boot contrast */
74
75/* Main LCD backlight brightness range and defaults */
76/* PCF50506 can output 0%-100% duty cycle but D305A expects %15-100%. */
77#define MIN_BRIGHTNESS_SETTING 1 /* 15/16 (93.75%) */
78#define MAX_BRIGHTNESS_SETTING 13 /* 3/16 (18.75%) */
79#define DEFAULT_BRIGHTNESS_SETTING 8 /* 8/16 (50.00%) = x5 boot default */
80
81/* Define this for LCD backlight available */ 65/* Define this for LCD backlight available */
82#define CONFIG_BACKLIGHT BL_X5 /* PCF50606 I2C */ 66#define CONFIG_BACKLIGHT BL_X5 /* PCF50606 I2C */
83#define HAVE_BACKLIGHT_BRIGHTNESS 67#define HAVE_BACKLIGHT_BRIGHTNESS
@@ -170,3 +154,21 @@
170 154
171/* Define this for FM radio input available */ 155/* Define this for FM radio input available */
172#define HAVE_FMRADIO_IN 156#define HAVE_FMRADIO_IN
157
158/** Port-specific settings **/
159
160/* Main LCD contrast range and defaults */
161#define MIN_CONTRAST_SETTING 1
162#define MAX_CONTRAST_SETTING 30
163#define DEFAULT_CONTRAST_SETTING 19 /* Match boot contrast */
164
165/* Main LCD backlight brightness range and defaults */
166/* PCF50506 can output 0%-100% duty cycle but D305A expects %15-100%. */
167#define MIN_BRIGHTNESS_SETTING 1 /* 15/16 (93.75%) */
168#define MAX_BRIGHTNESS_SETTING 13 /* 3/16 (18.75%) */
169#define DEFAULT_BRIGHTNESS_SETTING 8 /* 8/16 (50.00%) = x5 boot default */
170
171/* Remote LCD contrast range and defaults */
172#define MIN_REMOTE_CONTRAST_SETTING 10
173#define MAX_REMOTE_CONTRAST_SETTING 35
174#define DEFAULT_REMOTE_CONTRAST_SETTING 24 /* Match boot contrast */
diff --git a/firmware/target/coldfire/iaudio/x5/backlight-target.h b/firmware/target/coldfire/iaudio/x5/backlight-target.h
index e982e656d6..e6feb8bc0c 100755
--- a/firmware/target/coldfire/iaudio/x5/backlight-target.h
+++ b/firmware/target/coldfire/iaudio/x5/backlight-target.h
@@ -19,6 +19,8 @@
19#ifndef BACKLIGHT_TARGET_H 19#ifndef BACKLIGHT_TARGET_H
20#define BACKLIGHT_TARGET_H 20#define BACKLIGHT_TARGET_H
21 21
22#define __BACKLIGHT_INIT
23void __backlight_init(void);
22void __backlight_on(void); 24void __backlight_on(void);
23void __backlight_off(void); 25void __backlight_off(void);
24void __backlight_set_brightness(int val); 26void __backlight_set_brightness(int val);
diff --git a/firmware/target/coldfire/iaudio/x5/backlight-x5.c b/firmware/target/coldfire/iaudio/x5/backlight-x5.c
index 9d02c35988..9b50993d90 100755
--- a/firmware/target/coldfire/iaudio/x5/backlight-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/backlight-x5.c
@@ -20,9 +20,16 @@
20#include "cpu.h" 20#include "cpu.h"
21#include "system.h" 21#include "system.h"
22#include "backlight.h" 22#include "backlight.h"
23#include "backlight-target.h"
23#include "pcf50606.h" 24#include "pcf50606.h"
24#include "lcd.h" 25#include "lcd.h"
25 26
27void __backlight_init(void)
28{
29 __backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
30 __backlight_on();
31}
32
26void __backlight_on(void) 33void __backlight_on(void)
27{ 34{
28 int level; 35 int level;
diff --git a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
index 59140667ef..b8128617c2 100644
--- a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
@@ -81,15 +81,6 @@ void pcf50606_init(void)
81 pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */ 81 pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */
82 pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */ 82 pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */
83 83
84 pcf50606_write(0x35, 0x11); /* Backlight PWM = 512Hz, 8/16, Active */
85#ifdef BOOTLOADER
86 /* Backlight starts OFF in bootloader */
87 pcf50606_write(0x38, 0x80); /* Backlight OFF, GPO1INV=1, GPO1ACT=011 */
88#else
89 /* Keep backlight on when changing to firmware */
90 pcf50606_write(0x38, 0xb0); /* Backlight ON, GPO1INV=1, GPO1ACT=011 */
91#endif
92
93 /* Accessory detect */ 84 /* Accessory detect */
94 pcf50606_write(0x33, 0x8e); /* ACDAPE=1, THRSHLD=2.40V */ 85 pcf50606_write(0x33, 0x8e); /* ACDAPE=1, THRSHLD=2.40V */
95 86
diff --git a/firmware/target/coldfire/iriver/backlight-target.h b/firmware/target/coldfire/iriver/backlight-target.h
index 086ab02761..ac146eac83 100644
--- a/firmware/target/coldfire/iriver/backlight-target.h
+++ b/firmware/target/coldfire/iriver/backlight-target.h
@@ -19,6 +19,8 @@
19#ifndef BACKLIGHT_TARGET_H 19#ifndef BACKLIGHT_TARGET_H
20#define BACKLIGHT_TARGET_H 20#define BACKLIGHT_TARGET_H
21 21
22#define __BACKLIGHT_INIT
23void __backlight_init(void);
22void __backlight_on(void); 24void __backlight_on(void);
23void __backlight_off(void); 25void __backlight_off(void);
24#ifdef HAVE_BACKLIGHT_BRIGHTNESS 26#ifdef HAVE_BACKLIGHT_BRIGHTNESS
diff --git a/firmware/target/coldfire/iriver/h100/backlight-h100.c b/firmware/target/coldfire/iriver/h100/backlight-h100.c
index 8ceac8a6ff..62c24dc861 100644
--- a/firmware/target/coldfire/iriver/h100/backlight-h100.c
+++ b/firmware/target/coldfire/iriver/h100/backlight-h100.c
@@ -24,6 +24,13 @@
24#include "backlight.h" 24#include "backlight.h"
25#include "lcd.h" 25#include "lcd.h"
26 26
27void __backlight_init(void)
28{
29 or_l(0x00020000, &GPIO1_ENABLE);
30 or_l(0x00020000, &GPIO1_FUNCTION);
31 and_l(~0x00020000, &GPIO1_OUT); /* Start with the backlight ON */
32}
33
27void __backlight_on(void) 34void __backlight_on(void)
28{ 35{
29 and_l(~0x00020000, &GPIO1_OUT); 36 and_l(~0x00020000, &GPIO1_OUT);
diff --git a/firmware/target/coldfire/iriver/h300/backlight-h300.c b/firmware/target/coldfire/iriver/h300/backlight-h300.c
index 50bd757612..ef1d6d344d 100644
--- a/firmware/target/coldfire/iriver/h300/backlight-h300.c
+++ b/firmware/target/coldfire/iriver/h300/backlight-h300.c
@@ -25,6 +25,13 @@
25#include "pcf50606.h" 25#include "pcf50606.h"
26#include "lcd.h" 26#include "lcd.h"
27 27
28void __backlight_init(void)
29{
30 or_l(0x00020000, &GPIO1_ENABLE);
31 or_l(0x00020000, &GPIO1_FUNCTION);
32 or_l(0x00020000, &GPIO1_OUT); /* Start with the backlight ON */
33}
34
28void __backlight_on(void) 35void __backlight_on(void)
29{ 36{
30 lcd_enable(true); 37 lcd_enable(true);