summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-01-12 07:36:02 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-01-12 07:36:02 +0000
commit13435127b775252c746cae06d041f98fecb0e672 (patch)
treed8ef2d20ad2fccb8779856295e95ddd42dc93cc2
parent267ac4b79b4533043731141115acf45e8018ba38 (diff)
downloadrockbox-13435127b775252c746cae06d041f98fecb0e672.tar.gz
rockbox-13435127b775252c746cae06d041f98fecb0e672.zip
Fix FS#11820. Implement LCD shutdown for iPod Photo/Color and iPod nano 1G. The code was taken from FS#10034 and slightly changed to avoid white flashing when shutting off the display.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29033 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/config/ipodcolor.h3
-rw-r--r--firmware/export/config/ipodnano1g.h3
-rw-r--r--firmware/target/arm/ipod/backlight-4g_color.c4
-rw-r--r--firmware/target/arm/ipod/lcd-color_nano.c63
4 files changed, 53 insertions, 20 deletions
diff --git a/firmware/export/config/ipodcolor.h b/firmware/export/config/ipodcolor.h
index 92722560c6..f1bd62cca3 100644
--- a/firmware/export/config/ipodcolor.h
+++ b/firmware/export/config/ipodcolor.h
@@ -58,6 +58,9 @@
58#define LCD_DEPTH 16 /* 65536 colours */ 58#define LCD_DEPTH 16 /* 65536 colours */
59#define LCD_PIXELFORMAT RGB565SWAPPED /* rgb565 byte-swapped */ 59#define LCD_PIXELFORMAT RGB565SWAPPED /* rgb565 byte-swapped */
60 60
61/* Define this if the LCD can shut down */
62#define HAVE_LCD_SHUTDOWN
63
61/* LCD stays visible without backlight - simulator hint */ 64/* LCD stays visible without backlight - simulator hint */
62#define HAVE_TRANSFLECTIVE_LCD 65#define HAVE_TRANSFLECTIVE_LCD
63 66
diff --git a/firmware/export/config/ipodnano1g.h b/firmware/export/config/ipodnano1g.h
index 265a8b05aa..6f030a8859 100644
--- a/firmware/export/config/ipodnano1g.h
+++ b/firmware/export/config/ipodnano1g.h
@@ -58,6 +58,9 @@
58#define LCD_DEPTH 16 /* 65536 colours */ 58#define LCD_DEPTH 16 /* 65536 colours */
59#define LCD_PIXELFORMAT RGB565SWAPPED /* rgb565 byte-swapped */ 59#define LCD_PIXELFORMAT RGB565SWAPPED /* rgb565 byte-swapped */
60 60
61/* Define this if the LCD can shut down */
62#define HAVE_LCD_SHUTDOWN
63
61/* LCD stays visible without backlight - simulator hint */ 64/* LCD stays visible without backlight - simulator hint */
62#define HAVE_TRANSFLECTIVE_LCD 65#define HAVE_TRANSFLECTIVE_LCD
63 66
diff --git a/firmware/target/arm/ipod/backlight-4g_color.c b/firmware/target/arm/ipod/backlight-4g_color.c
index a0e14c99e3..befb036eab 100644
--- a/firmware/target/arm/ipod/backlight-4g_color.c
+++ b/firmware/target/arm/ipod/backlight-4g_color.c
@@ -52,14 +52,14 @@ void _backlight_on(void)
52{ 52{
53 /* brightness full */ 53 /* brightness full */
54 outl(0x80000000 | (brightness << 16), 0x7000a010); 54 outl(0x80000000 | (brightness << 16), 0x7000a010);
55 /* GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08); */ 55 GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08);
56 enabled = true; 56 enabled = true;
57} 57}
58 58
59void _backlight_off(void) 59void _backlight_off(void)
60{ 60{
61 outl(0x80000000, 0x7000a010); 61 outl(0x80000000, 0x7000a010);
62 /* GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x08); */ 62 GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x08);
63 enabled = false; 63 enabled = false;
64} 64}
65 65
diff --git a/firmware/target/arm/ipod/lcd-color_nano.c b/firmware/target/arm/ipod/lcd-color_nano.c
index 0b62666c81..a331b98c88 100644
--- a/firmware/target/arm/ipod/lcd-color_nano.c
+++ b/firmware/target/arm/ipod/lcd-color_nano.c
@@ -31,6 +31,7 @@
31#include "kernel.h" 31#include "kernel.h"
32#include "system.h" 32#include "system.h"
33#include "hwcompat.h" 33#include "hwcompat.h"
34#include "backlight-target.h"
34 35
35/* LCD command codes for HD66789R */ 36/* LCD command codes for HD66789R */
36#define LCD_CNTL_RAM_ADDR_SET 0x21 37#define LCD_CNTL_RAM_ADDR_SET 0x21
@@ -39,7 +40,7 @@
39#define LCD_CNTL_VERT_RAM_ADDR_POS 0x45 40#define LCD_CNTL_VERT_RAM_ADDR_POS 0x45
40 41
41/*** globals ***/ 42/*** globals ***/
42int lcd_type = 1; /* 0 = "old" Color/Photo, 1 = "new" Color & Nano */ 43int lcd_type = 1; /* 0,2 = "old" Color/Photo; 1,3 = similar to HD66789R */
43 44
44static inline void lcd_wait_write(void) 45static inline void lcd_wait_write(void)
45{ 46{
@@ -48,7 +49,7 @@ static inline void lcd_wait_write(void)
48 49
49static void lcd_cmd_data(unsigned cmd, unsigned data) 50static void lcd_cmd_data(unsigned cmd, unsigned data)
50{ 51{
51 if (lcd_type == 0) { /* 16 bit transfers */ 52 if ((lcd_type&1) == 0) { /* 16 bit transfers */
52 lcd_wait_write(); 53 lcd_wait_write();
53 LCD2_PORT = LCD2_CMD_MASK | cmd; 54 LCD2_PORT = LCD2_CMD_MASK | cmd;
54 lcd_wait_write(); 55 lcd_wait_write();
@@ -91,22 +92,11 @@ void lcd_init_device(void)
91 if (IPOD_HW_REVISION == 0x60000) { 92 if (IPOD_HW_REVISION == 0x60000) {
92 lcd_type = 0; 93 lcd_type = 0;
93 } else { 94 } else {
94 int gpio_a01, gpio_a04; 95 lcd_type = (GPIOA_INPUT_VAL & 0x2) | ((GPIOA_INPUT_VAL & 0x10) >> 4);
95
96 /* A01 */
97 gpio_a01 = (GPIOA_INPUT_VAL & 0x2) >> 1;
98 /* A04 */
99 gpio_a04 = (GPIOA_INPUT_VAL & 0x10) >> 4;
100
101 if (((gpio_a01 << 1) | gpio_a04) == 0 || ((gpio_a01 << 1) | gpio_a04) == 2) {
102 lcd_type = 0;
103 } else {
104 lcd_type = 1;
105 }
106 } 96 }
107 if (lcd_type == 0) { 97 if ((lcd_type&1) == 0) {
108 lcd_cmd_data(0xef, 0x0); 98 lcd_cmd_data(0xef, 0x0);
109 lcd_cmd_data(0x1, 0x0); 99 lcd_cmd_data(0x01, 0x0);
110 lcd_cmd_data(0x80, 0x1); 100 lcd_cmd_data(0x80, 0x1);
111 lcd_cmd_data(0x10, 0xc); 101 lcd_cmd_data(0x10, 0xc);
112 lcd_cmd_data(0x18, 0x6); 102 lcd_cmd_data(0x18, 0x6);
@@ -114,12 +104,49 @@ void lcd_init_device(void)
114 lcd_cmd_data(0x7e, 0x5); 104 lcd_cmd_data(0x7e, 0x5);
115 lcd_cmd_data(0x7f, 0x1); 105 lcd_cmd_data(0x7f, 0x1);
116 } 106 }
117
118#elif CONFIG_LCD == LCD_IPODNANO 107#elif CONFIG_LCD == LCD_IPODNANO
119 /* iPodLinux doesn't appear have any LCD init code for the Nano */ 108 /* iPodLinux doesn't appear have any LCD init code for the Nano */
120#endif 109#endif
121} 110}
122 111
112#ifdef HAVE_LCD_SHUTDOWN
113void lcd_shutdown(void) {
114 /* Immediately switch off the backlight to avoid flashing. */
115#if defined(IPOD_NANO)
116 _backlight_hw_enable(false);
117#elif defined(IPOD_COLOR)
118 _backlight_off();
119#endif
120
121 if ((lcd_type&1) == 0) {
122 /* lcd_type 0 and 2 */
123 lcd_cmd_data(0x00EF, 0x0000);
124 lcd_cmd_data(0x0080, 0x0000); udelay(1000);
125 lcd_cmd_data(0x0001, 0x0001);
126 } else if (lcd_type == 1) {
127 /* lcd_type 1 */
128 lcd_cmd_data(0x0007, 0x0236); sleep( 40*HZ/1000);
129 lcd_cmd_data(0x0007, 0x0226); sleep( 40*HZ/1000);
130 lcd_cmd_data(0x0007, 0x0204);
131 lcd_cmd_data(0x0010, 0x7574); sleep(200*HZ/1000);
132 lcd_cmd_data(0x0010, 0x7504); sleep( 50*HZ/1000);
133 lcd_cmd_data(0x0010, 0x0501);
134 } else {
135 /* lcd_type 3 */
136 lcd_cmd_data(0x0007, 0x4016); sleep( 20*HZ/1000);
137 lcd_cmd_data(0x0059, 0x0011); sleep( 20*HZ/1000);
138 lcd_cmd_data(0x0059, 0x0003); sleep( 20*HZ/1000);
139 lcd_cmd_data(0x0059, 0x0002); sleep( 20*HZ/1000);
140 lcd_cmd_data(0x0010, 0x6360); sleep(200*HZ/1000);
141 lcd_cmd_data(0x0010, 0x6300); sleep( 50*HZ/1000);
142 lcd_cmd_data(0x0010, 0x0300);
143 lcd_cmd_data(0x0059, 0x0000);
144 lcd_cmd_data(0x0007, 0x4004);
145 lcd_cmd_data(0x0010, 0x0301);
146 }
147}
148#endif
149
123/* Helper function to set up drawing region and start drawing */ 150/* Helper function to set up drawing region and start drawing */
124static void lcd_setup_drawing_region(int x, int y, int width, int height) 151static void lcd_setup_drawing_region(int x, int y, int width, int height)
125{ 152{
@@ -139,7 +166,7 @@ static void lcd_setup_drawing_region(int x, int y, int width, int height)
139#endif 166#endif
140 167
141 /* setup the drawing region */ 168 /* setup the drawing region */
142 if (lcd_type == 0) { 169 if ((lcd_type&1) == 0) {
143 lcd_cmd_data(0x12, y0); /* start vert */ 170 lcd_cmd_data(0x12, y0); /* start vert */
144 lcd_cmd_data(0x13, x0); /* start horiz */ 171 lcd_cmd_data(0x13, x0); /* start horiz */
145 lcd_cmd_data(0x15, y1); /* end vert */ 172 lcd_cmd_data(0x15, y1); /* end vert */