summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/export/config/xduoox3.h7
-rw-r--r--firmware/target/mips/ingenic_jz47xx/xduoo_x3/lcd-xduoo_x3.c127
2 files changed, 122 insertions, 12 deletions
diff --git a/firmware/export/config/xduoox3.h b/firmware/export/config/xduoox3.h
index e5b5ed9a10..fa86caf511 100644
--- a/firmware/export/config/xduoox3.h
+++ b/firmware/export/config/xduoox3.h
@@ -45,6 +45,13 @@
45#define LCD_BL_DARKCOLOR 0x000000 45#define LCD_BL_DARKCOLOR 0x000000
46#define LCD_BL_BRIGHTCOLOR 0x0de2e5 46#define LCD_BL_BRIGHTCOLOR 0x0de2e5
47 47
48/* Define this if your LCD can set contrast */
49#define HAVE_LCD_CONTRAST
50
51#define MIN_CONTRAST_SETTING -9
52#define MAX_CONTRAST_SETTING -1
53#define DEFAULT_CONTRAST_SETTING -6
54
48/* define this if you have LCD enable function */ 55/* define this if you have LCD enable function */
49#define HAVE_LCD_ENABLE 56#define HAVE_LCD_ENABLE
50 57
diff --git a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/lcd-xduoo_x3.c b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/lcd-xduoo_x3.c
index ea29ce266d..ce8840f9d2 100644
--- a/firmware/target/mips/ingenic_jz47xx/xduoo_x3/lcd-xduoo_x3.c
+++ b/firmware/target/mips/ingenic_jz47xx/xduoo_x3/lcd-xduoo_x3.c
@@ -148,11 +148,79 @@ void lcd_enable_power(bool onoff)
148static bool display_on = false; /* used by lcd_enable */ 148static bool display_on = false; /* used by lcd_enable */
149 149
150/*** hardware configuration ***/ 150/*** hardware configuration ***/
151int lcd_default_contrast(void)
152{
153 return DEFAULT_CONTRAST_SETTING;
154}
151 155
152void lcd_set_contrast(int val) 156void lcd_set_contrast(int val)
153{ 157{
154 lcd_write_command(LCD_CNTL_CONTRAST); 158 static int last_val = 0xFFFFFF;
155 lcd_write_command(val); 159
160 if (val >= 0) /* brightness menu */
161 {
162 lcd_write_command(LCD_CNTL_CONTRAST);
163 lcd_write_command(val);
164 }
165 else if (val != last_val)
166 {
167 /* here we change the voltage level and drive times
168 * longer precharge = dimmer display
169 * higher voltage = shorter precharge required
170 */
171 int precharge;
172 int vcomdsel;
173 switch (val)
174 {
175 case -9:
176 precharge = 0xFF;
177 vcomdsel = 0x10;
178 break;
179 case -8:
180 precharge = 0xF9;
181 vcomdsel = 0x10;
182 break;
183 case -7:
184 precharge = 0xF6;
185 vcomdsel = 0x20;
186 break;
187 default:
188 case -6:
189 precharge = 0xF1;
190 vcomdsel = 0x30;
191 break;
192 case -5:
193 precharge = 0xF1;
194 vcomdsel = 0x40;
195 break;
196 case -4:
197 precharge = 0x91;
198 vcomdsel = 0x50;
199 break;
200 case -3:
201 precharge = 0x61;
202 vcomdsel = 0x60;
203 break;
204 case -2:
205 precharge = 0x31;
206 vcomdsel = 0x65;
207 break;
208 case -1:
209 precharge = 0x11;
210 vcomdsel = 0x70;
211 break;
212 }
213 last_val = val;
214 lcd_enable(false);
215 /* Set pre-charge period */
216 lcd_write_command(LCD_SET_PRECHARGE_PERIOD);
217 lcd_write_command(precharge); /* VCC Generated by Internal DC/DC Circuit */
218
219 /* Set VCOM deselect level */
220 lcd_write_command(LCD_SET_VCOM_DESELECT_LEVEL);
221 lcd_write_command(vcomdsel);
222 lcd_enable(true);
223 }
156} 224}
157 225
158void lcd_set_invert_display(bool yesno) 226void lcd_set_invert_display(bool yesno)
@@ -252,7 +320,7 @@ void lcd_init_device(void)
252 320
253 /* Set VCOM deselect level */ 321 /* Set VCOM deselect level */
254 lcd_write_command(LCD_SET_VCOM_DESELECT_LEVEL); 322 lcd_write_command(LCD_SET_VCOM_DESELECT_LEVEL);
255 lcd_write_command(0x40); 323 lcd_write_command(0x20);
256 324
257 /* Set normal display mode (not every pixel ON) */ 325 /* Set normal display mode (not every pixel ON) */
258 lcd_write_command(LCD_SET_ENTIRE_DISPLAY_OFF); 326 lcd_write_command(LCD_SET_ENTIRE_DISPLAY_OFF);
@@ -275,6 +343,22 @@ void lcd_init_device(void)
275 343
276/*** Update functions ***/ 344/*** Update functions ***/
277 345
346/* returns LCD_CNTL_HIGHCOL or'd with higher 4 bits of
347 the 8-bit column address for the display data RAM.
348*/
349static inline int get_column_high_byte(const int x)
350{
351 return (LCD_CNTL_HIGHCOL | (((x+LCD_COL_OFFSET) >> 4) & 0xf));
352}
353
354/* returns LCD_CNTL_LOWCOL or'd with lower 4 bits of
355 the 8-bit column address for the display data RAM.
356*/
357static inline int get_column_low_byte(const int x)
358{
359 return (LCD_CNTL_LOWCOL | ((x+LCD_COL_OFFSET) & 0xf));
360}
361
278/* Performance function that works with an external buffer 362/* Performance function that works with an external buffer
279 note that by and bheight are in 8-pixel units! */ 363 note that by and bheight are in 8-pixel units! */
280void lcd_blit_mono(const unsigned char *data, int x, int by, int width, 364void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
@@ -283,12 +367,15 @@ void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
283 if(!display_on) 367 if(!display_on)
284 return; 368 return;
285 369
370 const int column_high = get_column_high_byte(x);
371 const int column_low = get_column_low_byte(x);
372
286 /* Copy display bitmap to hardware */ 373 /* Copy display bitmap to hardware */
287 while (bheight--) 374 while (bheight--)
288 { 375 {
289 lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); 376 lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf));
290 lcd_write_command (LCD_CNTL_HIGHCOL | (((x+LCD_COL_OFFSET)>>4) & 0xf)); 377 lcd_write_command (column_high);
291 lcd_write_command (LCD_CNTL_LOWCOL | ((x+LCD_COL_OFFSET) & 0xf)); 378 lcd_write_command (column_low);
292 379
293 lcd_write_data(data, width); 380 lcd_write_data(data, width);
294 data += stride; 381 data += stride;
@@ -306,6 +393,7 @@ void lcd_grey_data(unsigned char *values, unsigned char *phases, int count)
306 unsigned long *lpha = (unsigned long *)phases; 393 unsigned long *lpha = (unsigned long *)phases;
307 const unsigned long mask = 0x80808080; 394 const unsigned long mask = 0x80808080;
308 395
396 __gpio_set_pin(PIN_LCD_DC);
309 while(count--) 397 while(count--)
310 { 398 {
311 /* calculate disp data from phase we only use the last byte (8bits) */ 399 /* calculate disp data from phase we only use the last byte (8bits) */
@@ -320,7 +408,12 @@ void lcd_grey_data(unsigned char *values, unsigned char *phases, int count)
320 lpha[0] = lval[0] + (lpha[0] & ~mask); 408 lpha[0] = lval[0] + (lpha[0] & ~mask);
321 lpha[1] = lval[1] + (lpha[1] & ~mask); 409 lpha[1] = lval[1] + (lpha[1] & ~mask);
322 410
323 lcd_write_data((const fb_data*) &ltmp, 1); 411 REG_GPIO_PXDATC(2) = 0x000030FC;
412 REG_GPIO_PXDATS(2) = ((ltmp & 0xC0) << 6) | ((ltmp & 0x3F) << 2);
413 __gpio_clear_pin(PIN_LCD_WR);
414 bitdelay();
415 __gpio_set_pin(PIN_LCD_WR);
416 bitdelay();
324 417
325 lpha+=2; 418 lpha+=2;
326 lval+=2; 419 lval+=2;
@@ -335,13 +428,16 @@ void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
335 if(!display_on) 428 if(!display_on)
336 return; 429 return;
337 430
431 const int column_high = get_column_high_byte(x);
432 const int column_low = get_column_low_byte(x);
433
338 stride <<= 3; /* 8 pixels per block */ 434 stride <<= 3; /* 8 pixels per block */
339 /* Copy display bitmap to hardware */ 435 /* Copy display bitmap to hardware */
340 while (bheight--) 436 while (bheight--)
341 { 437 {
342 lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); 438 lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf));
343 lcd_write_command (LCD_CNTL_HIGHCOL | (((x+LCD_COL_OFFSET)>>4) & 0xf)); 439 lcd_write_command (column_high);
344 lcd_write_command (LCD_CNTL_LOWCOL | ((x+LCD_COL_OFFSET) & 0xf)); 440 lcd_write_command (column_low);
345 441
346 lcd_grey_data(values, phases, width); 442 lcd_grey_data(values, phases, width);
347 443
@@ -361,12 +457,16 @@ void lcd_update(void)
361 if(!display_on) 457 if(!display_on)
362 return; 458 return;
363 459
460
461 const int column_high = get_column_high_byte(0);
462 const int column_low = get_column_low_byte(0);
463
364 /* Copy display bitmap to hardware */ 464 /* Copy display bitmap to hardware */
365 for (y = 0; y < LCD_FBHEIGHT; y++) 465 for (y = 0; y < LCD_FBHEIGHT; y++)
366 { 466 {
367 lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); 467 lcd_write_command (LCD_CNTL_PAGE | (y & 0xf));
368 lcd_write_command (LCD_CNTL_HIGHCOL | ((LCD_COL_OFFSET >> 4) & 0xf)); 468 lcd_write_command (column_high);
369 lcd_write_command (LCD_CNTL_LOWCOL | (LCD_COL_OFFSET & 0xf)); 469 lcd_write_command (column_low);
370 470
371 lcd_write_data (FBADDR(0, y), LCD_WIDTH); 471 lcd_write_data (FBADDR(0, y), LCD_WIDTH);
372 } 472 }
@@ -381,6 +481,9 @@ void lcd_update_rect(int x, int y, int width, int height)
381 if(!display_on) 481 if(!display_on)
382 return; 482 return;
383 483
484 const int column_high = get_column_high_byte(x);
485 const int column_low = get_column_low_byte(x);
486
384 /* The Y coordinates have to work on even 8 pixel rows */ 487 /* The Y coordinates have to work on even 8 pixel rows */
385 if (x < 0) 488 if (x < 0)
386 { 489 {
@@ -413,8 +516,8 @@ void lcd_update_rect(int x, int y, int width, int height)
413 for (; y <= ymax; y++) 516 for (; y <= ymax; y++)
414 { 517 {
415 lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); 518 lcd_write_command (LCD_CNTL_PAGE | (y & 0xf));
416 lcd_write_command (LCD_CNTL_HIGHCOL | (((x+LCD_COL_OFFSET) >> 4) & 0xf)); 519 lcd_write_command (column_high);
417 lcd_write_command (LCD_CNTL_LOWCOL | ((x+LCD_COL_OFFSET) & 0xf)); 520 lcd_write_command (column_low);
418 521
419 lcd_write_data (FBADDR(x,y), width); 522 lcd_write_data (FBADDR(x,y), width);
420 } 523 }