diff options
Diffstat (limited to 'firmware/target/arm/philips/hdd6330/lcd-hdd6330.c')
-rw-r--r-- | firmware/target/arm/philips/hdd6330/lcd-hdd6330.c | 75 |
1 files changed, 61 insertions, 14 deletions
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 */ | ||
38 | static bool lcd_enabled; | ||
39 | |||
37 | /* Display status */ | 40 | /* Display status */ |
38 | static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; | 41 | static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; |
39 | 42 | ||
43 | /* Value used for flipping. Must be remembered when display is turned off. */ | ||
44 | static unsigned short flip; | ||
45 | |||
40 | /* Used for flip offset correction */ | 46 | /* Used for flip offset correction */ |
41 | static int x_offset; | 47 | static int x_offset; |
42 | 48 | ||
49 | /* Inverse value. Must be remembered when display is turned off. */ | ||
50 | static unsigned short invert; | ||
51 | |||
43 | /* wait for LCD */ | 52 | /* wait for LCD */ |
44 | static inline void lcd_wait_write(void) | 53 | static inline void lcd_wait_write(void) |
45 | { | 54 | { |
@@ -63,16 +72,54 @@ static void lcd_send_reg(unsigned reg) | |||
63 | 72 | ||
64 | void lcd_init_device(void) | 73 | void 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 */ | ||
84 | void 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 | |||
116 | bool lcd_active(void) | ||
117 | { | ||
118 | return lcd_enabled; | ||
119 | } | ||
120 | #endif /* HAVE_LCD_ENABLE */ | ||
121 | |||
122 | |||
76 | /*** hardware configuration ***/ | 123 | /*** hardware configuration ***/ |
77 | int lcd_default_contrast(void) | 124 | int lcd_default_contrast(void) |
78 | { | 125 | { |
@@ -86,7 +133,7 @@ void lcd_set_contrast(int val) | |||
86 | 133 | ||
87 | void lcd_set_invert_display(bool yesno) | 134 | void 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) */ |
95 | void lcd_set_flip(bool yesno) | 142 | void 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 | ||
103 | void lcd_yuv_set_options(unsigned options) | 150 | void 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 | ||