summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Dziok <b0hoon@o2.pl>2011-09-13 20:35:25 +0000
committerSzymon Dziok <b0hoon@o2.pl>2011-09-13 20:35:25 +0000
commit036c5fef464ca8bf77c34dbf5793e50478d5f074 (patch)
tree30ed807aaaa45802bf6a5ab9c309608b262d3b67
parent780968d2491fa3b5ddf9ec059a5e66ff725a7764 (diff)
downloadrockbox-036c5fef464ca8bf77c34dbf5793e50478d5f074.tar.gz
rockbox-036c5fef464ca8bf77c34dbf5793e50478d5f074.zip
HDD6330: implement lcd_enable (display on/off).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30519 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/config/gogearhdd6330.h2
-rw-r--r--firmware/target/arm/philips/hdd6330/backlight-hdd6330.c9
-rw-r--r--firmware/target/arm/philips/hdd6330/lcd-hdd6330.c75
3 files changed, 71 insertions, 15 deletions
diff --git a/firmware/export/config/gogearhdd6330.h b/firmware/export/config/gogearhdd6330.h
index 40c5658649..b822316172 100644
--- a/firmware/export/config/gogearhdd6330.h
+++ b/firmware/export/config/gogearhdd6330.h
@@ -61,7 +61,7 @@
61 61
62#ifndef BOOTLOADER 62#ifndef BOOTLOADER
63/* Define this if your LCD can be enabled/disabled */ 63/* Define this if your LCD can be enabled/disabled */
64/* #define HAVE_LCD_ENABLE */ 64#define HAVE_LCD_ENABLE
65 65
66/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE 66/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
67 * should be defined as well. 67 * should be defined as well.
diff --git a/firmware/target/arm/philips/hdd6330/backlight-hdd6330.c b/firmware/target/arm/philips/hdd6330/backlight-hdd6330.c
index 68d2ad8149..46c03e712e 100644
--- a/firmware/target/arm/philips/hdd6330/backlight-hdd6330.c
+++ b/firmware/target/arm/philips/hdd6330/backlight-hdd6330.c
@@ -22,6 +22,7 @@
22#include "backlight-target.h" 22#include "backlight-target.h"
23#include "system.h" 23#include "system.h"
24#include "backlight.h" 24#include "backlight.h"
25#include "lcd.h"
25#include "synaptics-mep.h" 26#include "synaptics-mep.h"
26 27
27#ifdef HAVE_BACKLIGHT_BRIGHTNESS 28#ifdef HAVE_BACKLIGHT_BRIGHTNESS
@@ -36,6 +37,10 @@ void _backlight_set_brightness(int brightness)
36 37
37void _backlight_on(void) 38void _backlight_on(void)
38{ 39{
40#ifdef HAVE_LCD_ENABLE
41 lcd_enable(true);
42#endif
43
39 GPO32_ENABLE |= 0x400; 44 GPO32_ENABLE |= 0x400;
40 GPO32_VAL |= 0x400; 45 GPO32_VAL |= 0x400;
41} 46}
@@ -44,6 +49,10 @@ void _backlight_off(void)
44{ 49{
45 GPO32_ENABLE |= 0x400; 50 GPO32_ENABLE |= 0x400;
46 GPO32_VAL &= ~0x400; 51 GPO32_VAL &= ~0x400;
52
53#ifdef HAVE_LCD_ENABLE
54 lcd_enable(false);
55#endif
47} 56}
48 57
49#ifdef HAVE_BUTTON_LIGHT 58#ifdef HAVE_BUTTON_LIGHT
diff --git a/firmware/target/arm/philips/hdd6330/lcd-hdd6330.c b/firmware/target/arm/philips/hdd6330/lcd-hdd6330.c
index 86006c9636..328c270b5e 100644
--- a/firmware/target/arm/philips/hdd6330/lcd-hdd6330.c
+++ b/firmware/target/arm/philips/hdd6330/lcd-hdd6330.c
@@ -34,12 +34,21 @@
34#define LCD_REG_VERT_ADDR_START 0x0a 34#define LCD_REG_VERT_ADDR_START 0x0a
35#define LCD_REG_VERT_ADDR_END 0x0b 35#define LCD_REG_VERT_ADDR_END 0x0b
36 36
37/* whether the lcd is currently enabled or not */
38static bool lcd_enabled;
39
37/* Display status */ 40/* Display status */
38static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; 41static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
39 42
43/* Value used for flipping. Must be remembered when display is turned off. */
44static unsigned short flip;
45
40/* Used for flip offset correction */ 46/* Used for flip offset correction */
41static int x_offset; 47static int x_offset;
42 48
49/* Inverse value. Must be remembered when display is turned off. */
50static unsigned short invert;
51
43/* wait for LCD */ 52/* wait for LCD */
44static inline void lcd_wait_write(void) 53static inline void lcd_wait_write(void)
45{ 54{
@@ -63,16 +72,54 @@ static void lcd_send_reg(unsigned reg)
63 72
64void lcd_init_device(void) 73void lcd_init_device(void)
65{ 74{
66 lcd_send_reg(LCD_REG_UNKNOWN_00);
67 lcd_send_data(0x00);
68 lcd_send_reg(LCD_REG_UNKNOWN_01);
69 lcd_send_data(0x48);
70 lcd_send_reg(LCD_REG_UNKNOWN_05);
71 lcd_send_data(0x0f);
72
73 x_offset = 16; 75 x_offset = 16;
76 invert = 0x00;
77 flip = 0x40;
78
79 lcd_enabled = true;
74} 80}
75 81
82#ifdef HAVE_LCD_ENABLE
83/* enable / disable lcd */
84void lcd_enable(bool on)
85{
86 if (on == lcd_enabled)
87 return;
88
89 if (on) /* lcd_display_on() */
90 {
91 lcd_send_reg(LCD_REG_UNKNOWN_00);
92 lcd_send_data(0x00 | invert);
93 lcd_send_reg(LCD_REG_UNKNOWN_01);
94 lcd_send_data(0x08 | flip);
95 lcd_send_reg(LCD_REG_UNKNOWN_05);
96 lcd_send_data(0x0f);
97 sleep(HZ/10); /* 100ms */
98
99 /* Probably out of sync and we don't wanna pepper the code with
100 lcd_update() calls for this. */
101 lcd_update();
102 send_event(LCD_EVENT_ACTIVATION, NULL);
103
104 lcd_enabled = true;
105 }
106 else /* lcd_display_off() */
107 {
108 lcd_send_reg(LCD_REG_UNKNOWN_00);
109 lcd_send_data(0x08);
110
111 lcd_enabled = false;
112 }
113}
114
115
116bool lcd_active(void)
117{
118 return lcd_enabled;
119}
120#endif /* HAVE_LCD_ENABLE */
121
122
76/*** hardware configuration ***/ 123/*** hardware configuration ***/
77int lcd_default_contrast(void) 124int lcd_default_contrast(void)
78{ 125{
@@ -86,7 +133,7 @@ void lcd_set_contrast(int val)
86 133
87void lcd_set_invert_display(bool yesno) 134void lcd_set_invert_display(bool yesno)
88{ 135{
89 int invert = (yesno) ? 0x40 : 0x00; 136 invert = (yesno) ? 0x40 : 0x00;
90 lcd_send_reg(LCD_REG_UNKNOWN_00); 137 lcd_send_reg(LCD_REG_UNKNOWN_00);
91 lcd_send_data(invert); 138 lcd_send_data(invert);
92} 139}
@@ -94,10 +141,10 @@ void lcd_set_invert_display(bool yesno)
94/* turn the display upside down (call lcd_update() afterwards) */ 141/* turn the display upside down (call lcd_update() afterwards) */
95void lcd_set_flip(bool yesno) 142void lcd_set_flip(bool yesno)
96{ 143{
97 int flip = (yesno) ? 0x88 : 0x48; 144 flip = (yesno) ? 0x80 : 0x40;
98 x_offset = (yesno) ? 4 : 16; 145 x_offset = (yesno) ? 4 : 16;
99 lcd_send_reg(LCD_REG_UNKNOWN_01); 146 lcd_send_reg(LCD_REG_UNKNOWN_01);
100 lcd_send_data(flip); 147 lcd_send_data(0x08 | flip);
101} 148}
102 149
103void lcd_yuv_set_options(unsigned options) 150void lcd_yuv_set_options(unsigned options)
@@ -208,7 +255,7 @@ void lcd_update_rect(int x, int y, int width, int height)
208 unsigned long *addr; 255 unsigned long *addr;
209 int new_x, new_width; 256 int new_x, new_width;
210 257
211 /* Ensure x and width are both even - so we can read 32-bit aligned 258 /* Ensure x and width are both even - so we can read 32-bit aligned
212 data from lcd_framebuffer */ 259 data from lcd_framebuffer */
213 new_x = x&~1; 260 new_x = x&~1;
214 new_width = width&~1; 261 new_width = width&~1;
@@ -249,7 +296,7 @@ void lcd_update_rect(int x, int y, int width, int height)
249 h = height; 296 h = height;
250 297
251 /* calculate how much we can do in one go */ 298 /* calculate how much we can do in one go */
252 if (pixels_to_write > 0x10000) 299 if (pixels_to_write > 0x10000)
253 { 300 {
254 h = (0x10000/2) / width; 301 h = (0x10000/2) / width;
255 pixels_to_write = (width * h) * 2; 302 pixels_to_write = (width * h) * 2;
@@ -260,10 +307,10 @@ void lcd_update_rect(int x, int y, int width, int height)
260 LCD2_BLOCK_CTRL = 0x34000000; 307 LCD2_BLOCK_CTRL = 0x34000000;
261 308
262 /* for each row */ 309 /* for each row */
263 for (r = 0; r < h; r++) 310 for (r = 0; r < h; r++)
264 { 311 {
265 /* for each column */ 312 /* for each column */
266 for (c = 0; c < width; c += 2) 313 for (c = 0; c < width; c += 2)
267 { 314 {
268 while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_TXOK)); 315 while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_TXOK));
269 316