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
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 7d8efbe..6470528 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -625,7 +625,7 @@
target/arm/i2s-pp.c
target/arm/ipod/adc-ipod.c
target/arm/ipod/3g/backlight-3g.c
-target/arm/ipod/3g/button-3g.c
+target/arm/ipod/button-1g-3g.c
target/arm/ipod/lcd-gray.c
target/arm/ipod/power-ipod.c
target/arm/usb-pp.c
@@ -638,8 +638,8 @@
target/arm/wmcodec-pp.c
target/arm/i2s-pp.c
target/arm/ipod/adc-ipod.c
-target/arm/ipod/3g/backlight-3g.c /* FIXME */
-target/arm/ipod/3g/button-3g.c /* FIXME */
+target/arm/ipod/1g2g/backlight-1g2g.c
+target/arm/ipod/button-1g-3g.c
target/arm/ipod/lcd-gray.c
target/arm/ipod/power-ipod.c
#endif /* SIMULATOR */
diff --git a/firmware/export/config-ipod1g2g.h b/firmware/export/config-ipod1g2g.h
index 40b1584..bfff2b2 100644
--- a/firmware/export/config-ipod1g2g.h
+++ b/firmware/export/config-ipod1g2g.h
@@ -38,7 +38,7 @@
/* LCD contrast */
#define MIN_CONTRAST_SETTING 5
#define MAX_CONTRAST_SETTING 63
-#define DEFAULT_CONTRAST_SETTING 40 /* Match boot contrast */
+#define DEFAULT_CONTRAST_SETTING 28 /* Match boot contrast */
#define CONFIG_KEYPAD IPOD_1G2G_PAD
@@ -63,6 +63,9 @@
/* Define this for LCD backlight available */
#define HAVE_BACKLIGHT
+/* Define this if the backlight unverts LCD appearance */
+#define HAVE_BACKLIGHT_INVERSION
+
#define BATTERY_CAPACITY_DEFAULT 630 /* default battery capacity */
#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 0000000..88d638f
--- /dev/null
+++ b/firmware/target/arm/ipod/1g2g/backlight-1g2g.c
@@ -0,0 +1,34 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Linus Nielsen Feltzing
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "config.h"
+#include "system.h"
+#include "backlight.h"
+#include "lcd.h"
+
+void __backlight_on(void)
+{
+ outl(inl(0xc0001000) | 0x02, 0xc0001000);
+ lcd_set_backlight_inversion(true);
+}
+
+void __backlight_off(void)
+{
+ outl(inl(0xc0001000) & ~0x02, 0xc0001000);
+ lcd_set_backlight_inversion(false);
+}
diff --git a/firmware/target/arm/ipod/3g/backlight-3g.c b/firmware/target/arm/ipod/3g/backlight-3g.c
index b676e24..251c722 100644
--- a/firmware/target/arm/ipod/3g/backlight-3g.c
+++ b/firmware/target/arm/ipod/3g/backlight-3g.c
@@ -17,18 +17,7 @@
*
****************************************************************************/
#include "config.h"
-#include <stdlib.h>
-#include "cpu.h"
-#include "kernel.h"
-#include "thread.h"
-#include "i2c.h"
-#include "debug.h"
-#include "rtc.h"
-#include "usb.h"
-#include "power.h"
#include "system.h"
-#include "button.h"
-#include "timer.h"
#include "backlight.h"
inline void __backlight_on(void)
diff --git a/firmware/target/arm/ipod/adc-ipod.c b/firmware/target/arm/ipod/adc-ipod.c
index 493b98e..39463af 100644
--- a/firmware/target/arm/ipod/adc-ipod.c
+++ b/firmware/target/arm/ipod/adc-ipod.c
@@ -55,7 +55,7 @@
}
adc->data = value;
return value;
- } else
+ } else
#endif
{
return adc->data;
@@ -66,11 +66,19 @@
unsigned short adc_scan(int channel) {
struct adc_struct *adc = &adcdata[channel];
adc->timeout = 0;
+#ifdef IPOD_1G2G
+ if (channel == ADC_UNREG_POWER)
+ return 681; /* FIXME fake 4.00V */
+#endif
return _adc_read(adc);
}
/* Retrieve the ADC value, only does a scan periodically */
unsigned short adc_read(int channel) {
+#ifdef IPOD_1G2G
+ if (channel == ADC_UNREG_POWER)
+ return 681; /* FIXME fake 4.00V */
+#endif
return _adc_read(&adcdata[channel]);
}
diff --git a/firmware/target/arm/ipod/3g/button-3g.c b/firmware/target/arm/ipod/button-1g-3g.c
similarity index 97%
rename from firmware/target/arm/ipod/3g/button-3g.c
rename to firmware/target/arm/ipod/button-1g-3g.c
index aa26e30..a546bea 100644
--- a/firmware/target/arm/ipod/3g/button-3g.c
+++ b/firmware/target/arm/ipod/button-1g-3g.c
@@ -194,7 +194,11 @@
bool button_hold(void)
{
- return (GPIOA_INPUT_VAL & 0x20)?false:true;
+#ifdef IPOD_1G2G
+ return (GPIOA_INPUT_VAL & 0x20);
+#else
+ return !(GPIOA_INPUT_VAL & 0x20);
+#endif
}
bool headphones_inserted(void)
diff --git a/firmware/target/arm/ipod/lcd-gray.c b/firmware/target/arm/ipod/lcd-gray.c
index 0a3a4ae..7a60eb6 100644
--- a/firmware/target/arm/ipod/lcd-gray.c
+++ b/firmware/target/arm/ipod/lcd-gray.c
@@ -68,6 +68,12 @@
#define R_RAM_ADDR_SET 0x11
#define R_RAM_DATA 0x12
+#ifdef HAVE_BACKLIGHT_INVERSION
+/* The backlight makes the LCD appear negative on the 1st/2nd gen */
+static bool lcd_inverted = false;
+static bool lcd_backlit = false;
+#endif
+
/* needed for flip */
static int addr_offset;
#if defined(IPOD_MINI) || defined(IPOD_MINI2G)
@@ -146,7 +152,9 @@
int lcd_default_contrast(void)
{
-#if defined(IPOD_MINI) || defined(IPOD_MINI2G) || defined(IPOD_3G)
+#ifdef IPOD_1G2G
+ return 28;
+#elif defined(IPOD_MINI) || defined(IPOD_MINI2G) || defined(IPOD_3G)
return 42;
#else
return 35;
@@ -162,6 +170,27 @@
lcd_cmd_and_data(R_CONTRAST_CONTROL, 0x400 | (val + 64));
}
+#ifdef HAVE_BACKLIGHT_INVERSION
+static void invert_display(void)
+{
+ if (lcd_inverted ^ lcd_backlit)
+ lcd_cmd_and_data(R_DISPLAY_CONTROL, 0x0023);
+ else
+ lcd_cmd_and_data(R_DISPLAY_CONTROL, 0x0009);
+}
+
+void lcd_set_invert_display(bool yesno)
+{
+ lcd_inverted = yesno;
+ invert_display();
+}
+
+void lcd_set_backlight_inversion(bool yesno)
+{
+ lcd_backlit = yesno;
+ invert_display();
+}
+#else
void lcd_set_invert_display(bool yesno)
{
if (yesno)
@@ -169,6 +198,7 @@
else
lcd_cmd_and_data(R_DISPLAY_CONTROL, 0x0009);
}
+#endif
/* turn the display upside down (call lcd_update() afterwards) */
void lcd_set_flip(bool yesno)