summaryrefslogtreecommitdiff
path: root/firmware/target/arm/rk27xx/lcd-hifiman.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/rk27xx/lcd-hifiman.c')
-rw-r--r--firmware/target/arm/rk27xx/lcd-hifiman.c89
1 files changed, 59 insertions, 30 deletions
diff --git a/firmware/target/arm/rk27xx/lcd-hifiman.c b/firmware/target/arm/rk27xx/lcd-hifiman.c
index aaf181690e..4ab04f7653 100644
--- a/firmware/target/arm/rk27xx/lcd-hifiman.c
+++ b/firmware/target/arm/rk27xx/lcd-hifiman.c
@@ -20,6 +20,7 @@
20 * 20 *
21 ****************************************************************************/ 21 ****************************************************************************/
22 22
23
23#include "config.h" 24#include "config.h"
24#include "kernel.h" 25#include "kernel.h"
25#include "lcd.h" 26#include "lcd.h"
@@ -29,7 +30,7 @@
29 30
30static bool display_on = false; 31static bool display_on = false;
31 32
32static void lcd_v1_display_init(void) 33void lcd_v1_display_init(void)
33{ 34{
34 unsigned int x, y; 35 unsigned int x, y;
35 36
@@ -84,7 +85,7 @@ static void lcd_v1_display_init(void)
84 udelay(40); 85 udelay(40);
85 86
86 /* Memmory access setting */ 87 /* Memmory access setting */
87 lcd_write_reg(0x16, 0x48); 88 lcd_write_reg(0x16, 0x68);
88 /* Setup 16bit mode */ 89 /* Setup 16bit mode */
89 lcd_write_reg(0x17, 0x05); 90 lcd_write_reg(0x17, 0x05);
90 91
@@ -92,11 +93,11 @@ static void lcd_v1_display_init(void)
92 lcd_write_reg(0x02, 0x00); 93 lcd_write_reg(0x02, 0x00);
93 lcd_write_reg(0x03, 0x00); 94 lcd_write_reg(0x03, 0x00);
94 lcd_write_reg(0x04, 0x00); 95 lcd_write_reg(0x04, 0x00);
95 lcd_write_reg(0x05, LCD_HEIGHT - 1); 96 lcd_write_reg(0x05, LCD_WIDTH - 1);
96 lcd_write_reg(0x06, 0x00); 97 lcd_write_reg(0x06, 0x00);
97 lcd_write_reg(0x07, 0x00); 98 lcd_write_reg(0x07, 0x00);
98 lcd_write_reg(0x08, 0x00); 99 lcd_write_reg(0x08, 0x00);
99 lcd_write_reg(0x09, LCD_WIDTH - 1); 100 lcd_write_reg(0x09, LCD_HEIGHT - 1);
100 101
101 /* Start GRAM write */ 102 /* Start GRAM write */
102 lcd_cmd(0x22); 103 lcd_cmd(0x22);
@@ -110,6 +111,9 @@ static void lcd_v1_display_init(void)
110 111
111static void lcd_v1_enable (bool on) 112static void lcd_v1_enable (bool on)
112{ 113{
114 lcdctrl_bypass(1);
115 LCDC_CTRL |= RGB24B;
116
113 if (on) 117 if (on)
114 { 118 {
115 lcd_write_reg(0x18, 0x44); 119 lcd_write_reg(0x18, 0x44);
@@ -139,23 +143,33 @@ static void lcd_v1_enable (bool on)
139 lcd_write_reg(0x21, 0x00); 143 lcd_write_reg(0x21, 0x00);
140 } 144 }
141 display_on = on; 145 display_on = on;
146
147 LCDC_CTRL &= ~RGB24B;
148}
149static void lcd_v1_set_gram_area(int x, int y, int width, int height)
150{
151 lcdctrl_bypass(1);
152 LCDC_CTRL |= RGB24B;
153
154 lcd_write_reg(0x03, x);
155 lcd_write_reg(0x05, width-1);
156 lcd_write_reg(0x07, y);
157 lcd_write_reg(0x09, height-1);
158
159 lcd_cmd(0x22);
160 LCDC_CTRL &= ~RGB24B;
142} 161}
143 162
144static void lcd_v1_update_rect(int x, int y, int width, int height) 163static void lcd_v1_update_rect(int x, int y, int width, int height)
145{ 164{
146 int px = x, py = y; 165 int px = x, py = y;
147 int pxmax = x + width, pymax = y + height; 166 int pxmax = x + width, pymax = y + height;
148 167
149 lcd_write_reg(0x03, y); 168 lcd_v1_set_gram_area(x, y, pxmax, pymax);
150 lcd_write_reg(0x05, pymax-1); 169
151 lcd_write_reg(0x07, x); 170 for (py=y; py<pymax; py++)
152 lcd_write_reg(0x09, pxmax-1); 171 for (px=x; px<pxmax; px++)
153 172 LCD_DATA = (*FBADDR(px, py));
154 lcd_cmd(0x22);
155
156 for (px=x; px<pxmax; px++)
157 for (py=y; py<pymax; py++)
158 lcd_data(*FBADDR(px, py));
159} 173}
160 174
161 175
@@ -246,31 +260,34 @@ static void lcd_v2_enable (bool on)
246 display_on = on; 260 display_on = on;
247} 261}
248 262
249static void lcd_v2_update_rect(int x, int y, int width, int height) 263static void lcd_v2_set_gram_area(int x, int y, int width, int height)
250{ 264{
251 int px, py;
252 (void) x; 265 (void) x;
253 (void) y; 266 (void) y;
254 (void) width; 267 (void) width;
255 (void)height; 268 (void) height;
256 269 lcdctrl_bypass(1);
270 LCDC_CTRL |= RGB24B;
257 lcd_cmd(0x22); 271 lcd_cmd(0x22);
258 272 LCDC_CTRL &= ~RGB24B;
259 for (py=0; py<LCD_HEIGHT; py++)
260 for (px=0; px<LCD_WIDTH; px++)
261 lcd_data(*FBADDR(px, py));
262} 273}
263 274
264void lcd_init_device(void) 275static void lcd_v2_update_rect(int x, int y, int width, int height)
265{ 276{
266 lcdif_init(LCDIF_16BIT); 277 (void) x;
278 (void) y;
279 (void) width;
280 (void) height;
281 lcd_update();
282}
267 283
284void lcd_display_init(void)
285{
268 identify_lcd(); 286 identify_lcd();
269 if (lcd_type == LCD_V1) 287 if (lcd_type == LCD_V1)
270 lcd_v1_display_init(); 288 lcd_v1_display_init();
271 else 289 else
272 lcd_v2_display_init(); 290 lcd_v2_display_init();
273
274} 291}
275 292
276void lcd_enable (bool on) 293void lcd_enable (bool on)
@@ -281,6 +298,14 @@ void lcd_enable (bool on)
281 lcd_v2_enable(on); 298 lcd_v2_enable(on);
282} 299}
283 300
301void lcd_set_gram_area(int x, int y, int width, int height)
302{
303 if (lcd_type == LCD_V1)
304 lcd_v1_set_gram_area(x, y, width, height);
305 else
306 lcd_v2_set_gram_area(x, y, width, height);
307}
308
284void lcd_update_rect(int x, int y, int width, int height) 309void lcd_update_rect(int x, int y, int width, int height)
285{ 310{
286 if (lcd_type == LCD_V1) 311 if (lcd_type == LCD_V1)
@@ -293,9 +318,8 @@ void lcd_update_rect(int x, int y, int width, int height)
293 318
294#else /* HM801 */ 319#else /* HM801 */
295 320
296void lcd_init_device(void) 321void lcd_display_init(void)
297{ 322{
298 lcdif_init(LCDIF_16BIT);
299 lcd_v1_display_init(); 323 lcd_v1_display_init();
300} 324}
301 325
@@ -304,6 +328,11 @@ void lcd_enable (bool on)
304 lcd_v1_enable(on); 328 lcd_v1_enable(on);
305} 329}
306 330
331void lcd_set_gram_area(int x, int y, int width, int height)
332{
333 lcd_v1_set_gram_area(x, y, width, height);
334}
335
307void lcd_update_rect(int x, int y, int width, int height) 336void lcd_update_rect(int x, int y, int width, int height)
308{ 337{
309 lcd_v1_update_rect(x, y, width, height); 338 lcd_v1_update_rect(x, y, width, height);