summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-07-27 12:05:54 +0000
committerJens Arnold <amiconn@rockbox.org>2007-07-27 12:05:54 +0000
commit021c0868dd6a9ac01f01db36a7b08cf7ad6737df (patch)
tree635d37509ce564e05b2065511912e7a436163510
parentb701322fea42c809092f50e252f45ddfc38293c3 (diff)
downloadrockbox-021c0868dd6a9ac01f01db36a7b08cf7ad6737df.tar.gz
rockbox-021c0868dd6a9ac01f01db36a7b08cf7ad6737df.zip
iPod 2nd gen: * Fake battery voltage of 4.00V so rockbox doesn't shutdown (ADC is not yet implemented). * Fix button hold polarity for main rockbox. * Implement backlight inversion (the 1st/2nd gen backlight works in a way that makes the LCD look inverted when active). * Fix default contrast and clean up target tree.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14022 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/SOURCES6
-rw-r--r--firmware/export/config-ipod1g2g.h5
-rw-r--r--firmware/target/arm/ipod/1g2g/backlight-1g2g.c34
-rw-r--r--firmware/target/arm/ipod/3g/backlight-3g.c11
-rw-r--r--firmware/target/arm/ipod/adc-ipod.c10
-rw-r--r--firmware/target/arm/ipod/button-1g-3g.c (renamed from firmware/target/arm/ipod/3g/button-3g.c)6
-rw-r--r--firmware/target/arm/ipod/lcd-gray.c32
7 files changed, 86 insertions, 18 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 7d8efbe272..6470528746 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -625,7 +625,7 @@ target/arm/wmcodec-pp.c
625target/arm/i2s-pp.c 625target/arm/i2s-pp.c
626target/arm/ipod/adc-ipod.c 626target/arm/ipod/adc-ipod.c
627target/arm/ipod/3g/backlight-3g.c 627target/arm/ipod/3g/backlight-3g.c
628target/arm/ipod/3g/button-3g.c 628target/arm/ipod/button-1g-3g.c
629target/arm/ipod/lcd-gray.c 629target/arm/ipod/lcd-gray.c
630target/arm/ipod/power-ipod.c 630target/arm/ipod/power-ipod.c
631target/arm/usb-pp.c 631target/arm/usb-pp.c
@@ -638,8 +638,8 @@ target/arm/ata-pp5002.c
638target/arm/wmcodec-pp.c 638target/arm/wmcodec-pp.c
639target/arm/i2s-pp.c 639target/arm/i2s-pp.c
640target/arm/ipod/adc-ipod.c 640target/arm/ipod/adc-ipod.c
641target/arm/ipod/3g/backlight-3g.c /* FIXME */ 641target/arm/ipod/1g2g/backlight-1g2g.c
642target/arm/ipod/3g/button-3g.c /* FIXME */ 642target/arm/ipod/button-1g-3g.c
643target/arm/ipod/lcd-gray.c 643target/arm/ipod/lcd-gray.c
644target/arm/ipod/power-ipod.c 644target/arm/ipod/power-ipod.c
645#endif /* SIMULATOR */ 645#endif /* SIMULATOR */
diff --git a/firmware/export/config-ipod1g2g.h b/firmware/export/config-ipod1g2g.h
index 40b158407d..bfff2b22ef 100644
--- a/firmware/export/config-ipod1g2g.h
+++ b/firmware/export/config-ipod1g2g.h
@@ -38,7 +38,7 @@
38/* LCD contrast */ 38/* LCD contrast */
39#define MIN_CONTRAST_SETTING 5 39#define MIN_CONTRAST_SETTING 5
40#define MAX_CONTRAST_SETTING 63 40#define MAX_CONTRAST_SETTING 63
41#define DEFAULT_CONTRAST_SETTING 40 /* Match boot contrast */ 41#define DEFAULT_CONTRAST_SETTING 28 /* Match boot contrast */
42 42
43#define CONFIG_KEYPAD IPOD_1G2G_PAD 43#define CONFIG_KEYPAD IPOD_1G2G_PAD
44 44
@@ -63,6 +63,9 @@
63/* Define this for LCD backlight available */ 63/* Define this for LCD backlight available */
64#define HAVE_BACKLIGHT 64#define HAVE_BACKLIGHT
65 65
66/* Define this if the backlight unverts LCD appearance */
67#define HAVE_BACKLIGHT_INVERSION
68
66#define BATTERY_CAPACITY_DEFAULT 630 /* default battery capacity */ 69#define BATTERY_CAPACITY_DEFAULT 630 /* default battery capacity */
67 70
68#ifndef SIMULATOR 71#ifndef SIMULATOR
diff --git a/firmware/target/arm/ipod/1g2g/backlight-1g2g.c b/firmware/target/arm/ipod/1g2g/backlight-1g2g.c
new file mode 100644
index 0000000000..88d638f4e3
--- /dev/null
+++ b/firmware/target/arm/ipod/1g2g/backlight-1g2g.c
@@ -0,0 +1,34 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20#include "system.h"
21#include "backlight.h"
22#include "lcd.h"
23
24void __backlight_on(void)
25{
26 outl(inl(0xc0001000) | 0x02, 0xc0001000);
27 lcd_set_backlight_inversion(true);
28}
29
30void __backlight_off(void)
31{
32 outl(inl(0xc0001000) & ~0x02, 0xc0001000);
33 lcd_set_backlight_inversion(false);
34}
diff --git a/firmware/target/arm/ipod/3g/backlight-3g.c b/firmware/target/arm/ipod/3g/backlight-3g.c
index b676e2473b..251c722dae 100644
--- a/firmware/target/arm/ipod/3g/backlight-3g.c
+++ b/firmware/target/arm/ipod/3g/backlight-3g.c
@@ -17,18 +17,7 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19#include "config.h" 19#include "config.h"
20#include <stdlib.h>
21#include "cpu.h"
22#include "kernel.h"
23#include "thread.h"
24#include "i2c.h"
25#include "debug.h"
26#include "rtc.h"
27#include "usb.h"
28#include "power.h"
29#include "system.h" 20#include "system.h"
30#include "button.h"
31#include "timer.h"
32#include "backlight.h" 21#include "backlight.h"
33 22
34inline void __backlight_on(void) 23inline void __backlight_on(void)
diff --git a/firmware/target/arm/ipod/adc-ipod.c b/firmware/target/arm/ipod/adc-ipod.c
index 493b98ef74..39463af30b 100644
--- a/firmware/target/arm/ipod/adc-ipod.c
+++ b/firmware/target/arm/ipod/adc-ipod.c
@@ -55,7 +55,7 @@ static unsigned short _adc_read(struct adc_struct *adc)
55 } 55 }
56 adc->data = value; 56 adc->data = value;
57 return value; 57 return value;
58 } else 58 } else
59#endif 59#endif
60 { 60 {
61 return adc->data; 61 return adc->data;
@@ -66,11 +66,19 @@ static unsigned short _adc_read(struct adc_struct *adc)
66unsigned short adc_scan(int channel) { 66unsigned short adc_scan(int channel) {
67 struct adc_struct *adc = &adcdata[channel]; 67 struct adc_struct *adc = &adcdata[channel];
68 adc->timeout = 0; 68 adc->timeout = 0;
69#ifdef IPOD_1G2G
70 if (channel == ADC_UNREG_POWER)
71 return 681; /* FIXME fake 4.00V */
72#endif
69 return _adc_read(adc); 73 return _adc_read(adc);
70} 74}
71 75
72/* Retrieve the ADC value, only does a scan periodically */ 76/* Retrieve the ADC value, only does a scan periodically */
73unsigned short adc_read(int channel) { 77unsigned short adc_read(int channel) {
78#ifdef IPOD_1G2G
79 if (channel == ADC_UNREG_POWER)
80 return 681; /* FIXME fake 4.00V */
81#endif
74 return _adc_read(&adcdata[channel]); 82 return _adc_read(&adcdata[channel]);
75} 83}
76 84
diff --git a/firmware/target/arm/ipod/3g/button-3g.c b/firmware/target/arm/ipod/button-1g-3g.c
index aa26e30280..a546bea9b6 100644
--- a/firmware/target/arm/ipod/3g/button-3g.c
+++ b/firmware/target/arm/ipod/button-1g-3g.c
@@ -194,7 +194,11 @@ int button_read_device(void)
194 194
195bool button_hold(void) 195bool button_hold(void)
196{ 196{
197 return (GPIOA_INPUT_VAL & 0x20)?false:true; 197#ifdef IPOD_1G2G
198 return (GPIOA_INPUT_VAL & 0x20);
199#else
200 return !(GPIOA_INPUT_VAL & 0x20);
201#endif
198} 202}
199 203
200bool headphones_inserted(void) 204bool headphones_inserted(void)
diff --git a/firmware/target/arm/ipod/lcd-gray.c b/firmware/target/arm/ipod/lcd-gray.c
index 0a3a4ae797..7a60eb6470 100644
--- a/firmware/target/arm/ipod/lcd-gray.c
+++ b/firmware/target/arm/ipod/lcd-gray.c
@@ -68,6 +68,12 @@ static inline bool timer_check(int clock_start, int usecs)
68#define R_RAM_ADDR_SET 0x11 68#define R_RAM_ADDR_SET 0x11
69#define R_RAM_DATA 0x12 69#define R_RAM_DATA 0x12
70 70
71#ifdef HAVE_BACKLIGHT_INVERSION
72/* The backlight makes the LCD appear negative on the 1st/2nd gen */
73static bool lcd_inverted = false;
74static bool lcd_backlit = false;
75#endif
76
71/* needed for flip */ 77/* needed for flip */
72static int addr_offset; 78static int addr_offset;
73#if defined(IPOD_MINI) || defined(IPOD_MINI2G) 79#if defined(IPOD_MINI) || defined(IPOD_MINI2G)
@@ -146,7 +152,9 @@ void lcd_init_device(void)
146 152
147int lcd_default_contrast(void) 153int lcd_default_contrast(void)
148{ 154{
149#if defined(IPOD_MINI) || defined(IPOD_MINI2G) || defined(IPOD_3G) 155#ifdef IPOD_1G2G
156 return 28;
157#elif defined(IPOD_MINI) || defined(IPOD_MINI2G) || defined(IPOD_3G)
150 return 42; 158 return 42;
151#else 159#else
152 return 35; 160 return 35;
@@ -162,6 +170,27 @@ void lcd_set_contrast(int val)
162 lcd_cmd_and_data(R_CONTRAST_CONTROL, 0x400 | (val + 64)); 170 lcd_cmd_and_data(R_CONTRAST_CONTROL, 0x400 | (val + 64));
163} 171}
164 172
173#ifdef HAVE_BACKLIGHT_INVERSION
174static void invert_display(void)
175{
176 if (lcd_inverted ^ lcd_backlit)
177 lcd_cmd_and_data(R_DISPLAY_CONTROL, 0x0023);
178 else
179 lcd_cmd_and_data(R_DISPLAY_CONTROL, 0x0009);
180}
181
182void lcd_set_invert_display(bool yesno)
183{
184 lcd_inverted = yesno;
185 invert_display();
186}
187
188void lcd_set_backlight_inversion(bool yesno)
189{
190 lcd_backlit = yesno;
191 invert_display();
192}
193#else
165void lcd_set_invert_display(bool yesno) 194void lcd_set_invert_display(bool yesno)
166{ 195{
167 if (yesno) 196 if (yesno)
@@ -169,6 +198,7 @@ void lcd_set_invert_display(bool yesno)
169 else 198 else
170 lcd_cmd_and_data(R_DISPLAY_CONTROL, 0x0009); 199 lcd_cmd_and_data(R_DISPLAY_CONTROL, 0x0009);
171} 200}
201#endif
172 202
173/* turn the display upside down (call lcd_update() afterwards) */ 203/* turn the display upside down (call lcd_update() afterwards) */
174void lcd_set_flip(bool yesno) 204void lcd_set_flip(bool yesno)