1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Barry Wardell
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
27 /** Initialized in lcd_init_device() **/
28 /* Is the power turned on? */
30 /* Is the display turned on? */
31 static bool display_on
;
32 /* Amount of vertical offset. Used for flip offset correction/detection. */
33 static int y_offset
= 4;
34 static int x_offset
= 16;
35 /* Reverse flag. Must be remembered when display is turned off. */
36 static unsigned short disp_control_rev
;
37 /* Contrast setting << 8 */
38 static int lcd_contrast
;
40 static unsigned lcd_yuv_options SHAREDBSS_ATTR
= 0;
42 /* Forward declarations */
43 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
44 static void lcd_display_off(void);
47 /* register defines for the Renesas HD66773R */
48 #define R_START_OSC 0x00
49 #define R_DEVICE_CODE_READ 0x00
50 #define R_DRV_OUTPUT_CONTROL 0x01
51 #define R_DRV_AC_CONTROL 0x02
52 #define R_POWER_CONTROL1 0x03
53 #define R_POWER_CONTROL2 0x04
54 #define R_ENTRY_MODE 0x05
55 #define R_COMPARE_REG 0x06
56 #define R_DISP_CONTROL 0x07
57 #define R_FRAME_CYCLE_CONTROL 0x0b
58 #define R_POWER_CONTROL3 0x0c
59 #define R_POWER_CONTROL4 0x0d
60 #define R_POWER_CONTROL5 0x0e
61 #define R_GATE_SCAN_START_POS 0x0f
62 #define R_VERT_SCROLL_CONTROL 0x11
63 #define R_1ST_SCR_DRV_POS 0x14
64 #define R_2ND_SCR_DRV_POS 0x15
65 #define R_HORIZ_RAM_ADDR_POS 0x16
66 #define R_VERT_RAM_ADDR_POS 0x17
67 #define R_RAM_WRITE_DATA_MASK 0x20
68 #define R_RAM_ADDR_SET 0x21
69 #define R_WRITE_DATA_2_GRAM 0x22
70 #define R_RAM_READ_DATA 0x22
71 #define R_GAMMA_FINE_ADJ_POS1 0x30
72 #define R_GAMMA_FINE_ADJ_POS2 0x31
73 #define R_GAMMA_FINE_ADJ_POS3 0x32
74 #define R_GAMMA_GRAD_ADJ_POS 0x33
75 #define R_GAMMA_FINE_ADJ_NEG1 0x34
76 #define R_GAMMA_FINE_ADJ_NEG2 0x35
77 #define R_GAMMA_FINE_ADJ_NEG3 0x36
78 #define R_GAMMA_GRAD_ADJ_NEG 0x37
79 #define R_GAMMA_AMP_ADJ_POS 0x3a
80 #define R_GAMMA_AMP_ADJ_NEG 0x3b
82 #define R_DRV_OUTPUT_CONTROL_NORMAL (1<<9|1<<4|1<<2|1<<0)
83 #define R_DRV_OUTPUT_CONTROL_FLIPPED (1<<11|1<<8|1<<5|1<<4|1<<3)
84 static inline void lcd_wait_write(void)
86 while (LCD2_PORT
& LCD2_BUSY_MASK
);
90 static inline void lcd_send_cmd(unsigned cmd
)
93 LCD2_PORT
= LCD2_CMD_MASK
; /* Send MSB first (should always be 0) */
95 LCD2_PORT
= LCD2_CMD_MASK
| cmd
;
98 /* Send 16-bit data */
99 static inline void lcd_send_data(unsigned data
)
102 LCD2_PORT
= (data
>> 8) | LCD2_DATA_MASK
; /* Send MSB first */
104 LCD2_PORT
= (data
& 0xff) | LCD2_DATA_MASK
;
107 /* Send 16-bit data byte-swapped. Only needed until we can use block transfer. */
108 static inline void lcd_send_data_swapped(unsigned v
)
111 LCD2_PORT
= LCD2_DATA_MASK
| (v
& 0xff); /* Send LSB first */
112 LCD2_PORT
= LCD2_DATA_MASK
| (v
>> 8);
115 /* Write value to register */
116 static void lcd_write_reg(int reg
, int val
)
122 /*** hardware configuration ***/
124 int lcd_default_contrast(void)
126 return DEFAULT_CONTRAST_SETTING
;
129 void lcd_set_contrast(int val
)
131 /* Clamp val in range 0-14, 16-30 */
139 lcd_contrast
= val
<< 8;
144 /* VCOMG=1, VDV4-0=xxxxx, VCM4-0=11000 */
145 lcd_write_reg(R_POWER_CONTROL5
, 0x2018 | lcd_contrast
);
148 void lcd_set_invert_display(bool yesno
)
150 if (yesno
== (disp_control_rev
== 0x0000))
153 disp_control_rev
= yesno
? 0x0000 : 0x0004;
158 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=11 */
159 lcd_write_reg(R_DISP_CONTROL
, 0x0033 | disp_control_rev
);
162 /* turn the display upside down (call lcd_update() afterwards) */
163 void lcd_set_flip(bool flip
)
165 int r_drv_output_control
;
166 if (flip
== (y_offset
!= 4))
168 /* The LCD controller is 132x160 while the LCD itself is 128x160, so we need
169 * to shift the origin by 4 when we flip the LCD
171 * the higher bits are the key bits for flipping */
174 x_offset
= 0; y_offset
= 0;
175 r_drv_output_control
= R_DRV_OUTPUT_CONTROL_FLIPPED
;
179 x_offset
= 16; y_offset
= 4;
180 r_drv_output_control
= R_DRV_OUTPUT_CONTROL_NORMAL
;
186 lcd_write_reg(R_1ST_SCR_DRV_POS
, ( (LCD_WIDTH
+ x_offset
- 1) << 8) | x_offset
);
187 lcd_write_reg(R_HORIZ_RAM_ADDR_POS
, (LCD_HEIGHT
- 1) << 8 | 0);
188 lcd_write_reg(R_VERT_RAM_ADDR_POS
, ((LCD_WIDTH
+ x_offset
- 1) << 8) | x_offset
);
189 lcd_write_reg(R_DRV_OUTPUT_CONTROL
, r_drv_output_control
);
190 lcd_write_reg(R_ENTRY_MODE
, 0x1028);
193 /* Reset the LCD prior to booting the OF */
197 lcd_write_reg(R_DRV_OUTPUT_CONTROL
, 0x0315);
198 lcd_write_reg(R_ENTRY_MODE
, 0x1028);
199 lcd_write_reg(R_HORIZ_RAM_ADDR_POS
, 0x7f00);
200 lcd_write_reg(R_VERT_RAM_ADDR_POS
, 0xaf10);
201 lcd_write_reg(R_RAM_ADDR_SET
, 0x0000);
206 void lcd_init_device(void)
209 /* This is the OF LCD init */
213 DEV_INIT1
|= 0xfc000000;
214 CLCD_CLOCK_SRC
&= ~0xf;
218 GPIOF_OUTPUT_EN
|= 0x4;
219 GPIOF_OUTPUT_VAL
&= ~0x4;
221 GPIOF_OUTPUT_VAL
|= 0x4;
223 outl(0x220, 0x70008a00);
224 outl(0x1f00, 0x70008a04);
225 LCD2_BLOCK_CTRL
= 0x10008080;
226 LCD2_BLOCK_CONFIG
= 0xf00000;
229 for (i
= 0; i
< 8; i
++)
235 lcd_write_reg(R_START_OSC
, 0x0001);
237 lcd_write_reg(R_DRV_OUTPUT_CONTROL
, 0x0315);
238 lcd_write_reg(R_DRV_AC_CONTROL
, 0x0700);
239 lcd_write_reg(R_ENTRY_MODE
, 0x1028);
240 lcd_write_reg(R_COMPARE_REG
, 0x0000);
241 lcd_write_reg(R_FRAME_CYCLE_CONTROL
, 0x4008);
242 lcd_write_reg(R_RAM_ADDR_SET
, 0x0000);
243 lcd_write_reg(R_GAMMA_FINE_ADJ_POS1
, 0x0700);
244 lcd_write_reg(R_GAMMA_FINE_ADJ_POS2
, 0x0000);
245 lcd_write_reg(R_GAMMA_FINE_ADJ_POS3
, 0x0000);
246 lcd_write_reg(R_GAMMA_GRAD_ADJ_POS
, 0x0100);
247 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1
, 0x0707);
248 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2
, 0x0007);
249 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3
, 0x0700);
250 lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG
, 0x0001);
251 lcd_write_reg(R_GATE_SCAN_START_POS
, 0x0000);
252 lcd_write_reg(R_VERT_SCROLL_CONTROL
, 0x0000);
253 lcd_write_reg(R_1ST_SCR_DRV_POS
, ( (LCD_WIDTH
+ 16 - 1) << 8) | 16);
254 lcd_write_reg(R_2ND_SCR_DRV_POS
, 0x0000);
255 lcd_write_reg(R_HORIZ_RAM_ADDR_POS
, (LCD_HEIGHT
- 1) << 8 | 0);
256 lcd_write_reg(R_VERT_RAM_ADDR_POS
, ((LCD_WIDTH
+ 16- 1) << 8) | 16);
257 lcd_write_reg(R_GAMMA_AMP_ADJ_POS
, 0x1600);
258 lcd_write_reg(R_GAMMA_AMP_ADJ_NEG
, 0x0006);
259 lcd_write_reg(R_DISP_CONTROL
, 0x0104);
260 lcd_write_reg(R_POWER_CONTROL4
, 0x0100);
261 lcd_write_reg(R_POWER_CONTROL5
, 0x0d18);
262 lcd_write_reg(R_POWER_CONTROL3
, 0x0000);
264 lcd_write_reg(R_POWER_CONTROL1
, 0x0008);
265 lcd_write_reg(R_POWER_CONTROL3
, 0x0000);
266 lcd_write_reg(R_POWER_CONTROL2
, 0x0000);
268 lcd_write_reg(R_POWER_CONTROL5
, 0x2d18);
269 lcd_write_reg(R_POWER_CONTROL3
, 0x0000);
271 lcd_write_reg(R_POWER_CONTROL4
, 0x0110);
272 //~ lcd_clear_display();
273 lcd_write_reg(R_DISP_CONTROL
, 0x0105);
275 lcd_write_reg(R_DISP_CONTROL
, 0x0125);
276 lcd_write_reg(R_DISP_CONTROL
, 0x0127);
278 lcd_write_reg(R_DISP_CONTROL
, 0x0137);
279 lcd_send_cmd(R_WRITE_DATA_2_GRAM
);
281 GPIOF_ENABLE
|= 0x02;
282 GPIOF_OUTPUT_EN
|= 0x02;
283 GPIOF_OUTPUT_VAL
|= 0x02;
287 /* The OF won't boot if this is done in the bootloader - ideally we should
288 tweak the lcd controller speed settings but this will do for now */
289 CLCD_CLOCK_SRC
|= 0xc0000000; /* Set LCD interface clock to PLL */
292 /* only these bits are needed from the OF init */
293 lcd_write_reg(R_DRV_OUTPUT_CONTROL
, R_DRV_OUTPUT_CONTROL_NORMAL
);
294 lcd_write_reg(R_ENTRY_MODE
, 0x1028);
298 disp_control_rev
= 0x0004;
299 lcd_contrast
= DEFAULT_CONTRAST_SETTING
<< 8;
302 /* THE SLEEP AND POWER FUNCTIONS HAVE NOT BEEN MODIFIED FOR THE YH-925 */
304 #ifdef HAVE_LCD_SLEEP
305 static void lcd_power_on(void)
307 /* Be sure standby bit is clear. */
308 /* BT2-0=000, DC2-0=000, AP2-0=000, SLP=0, STB=0 */
309 lcd_write_reg(R_POWER_CONTROL1
, 0x0000);
311 /** Power ON Sequence **/
312 /* Per datasheet Rev.1.10, Jun.21.2003, p. 99 */
314 lcd_write_reg(R_START_OSC
, 0x0001); /* Start Oscillation */
315 /* 10ms or more for oscillation circuit to stabilize */
317 /* Instruction (1) for power setting; VC2-0, VRH3-0, CAD,
318 VRL3-0, VCM4-0, VDV4-0 */
320 lcd_write_reg(R_POWER_CONTROL3
, 0x0001);
321 /* VRL3-0=0100, PON=0, VRH3-0=0001 */
322 lcd_write_reg(R_POWER_CONTROL4
, 0x0401);
324 lcd_write_reg(R_POWER_CONTROL2
, 0x8000);
325 /* VCOMG=0, VDV4-0=xxxxx (19), VCM4-0=11000 */
326 lcd_write_reg(R_POWER_CONTROL5
, 0x0018 | lcd_contrast
);
327 /* Instruction (2) for power setting; BT2-0, DC2-0, AP2-0 */
328 /* BT2-0=000, DC2-0=001, AP2-0=011, SLP=0, STB=0 */
329 lcd_write_reg(R_POWER_CONTROL1
, 0x002c);
330 /* Instruction (3) for power setting; VCOMG = "1" */
331 /* VCOMG=1, VDV4-0=xxxxx (19), VCM4-0=11000 */
332 lcd_write_reg(R_POWER_CONTROL5
, 0x2018 | lcd_contrast
);
334 /* 40ms or more; time for step-up circuits 1,2 to stabilize */
337 /* Instruction (4) for power setting; PON = "1" */
338 /* VRL3-0=0100, PON=1, VRH3-0=0001 */
339 lcd_write_reg(R_POWER_CONTROL4
, 0x0411);
341 /* 40ms or more; time for step-up circuit 4 to stabilize */
344 /* Instructions for other mode settings (in register order). */
345 /* SM=0, GS=x, SS=0, NL4-0=10011 (G1-G160)*/
346 lcd_write_reg(R_DRV_OUTPUT_CONTROL
, y_offset
? 0x0013 : 0x0113); /* different to X5 */
347 /* FLD1-0=01 (1 field), B/C=1, EOR=1 (C-pat), NW5-0=000000 (1 row) */
348 lcd_write_reg(R_DRV_AC_CONTROL
, 0x0700);
349 /* DIT=0, BGR=1, HWM=0, I/D1-0=10, AM=1, LG2-0=000 */
350 lcd_write_reg(R_ENTRY_MODE
, 0x1028); /* different to X5 */
351 /* CP15-0=0000000000000000 */
352 lcd_write_reg(R_COMPARE_REG
, 0x0000);
353 /* NO1-0=01, SDT1-0=00, EQ1-0=00, DIV1-0=00, RTN3-00000 */
354 lcd_write_reg(R_FRAME_CYCLE_CONTROL
, 0x4000);
355 /* SCN4-0=000x0 (G1/G160) */
356 /* lcd_write_reg(R_GATE_SCAN_START_POS, y_offset ? 0x0000 : 0x0002); */
358 lcd_write_reg(R_VERT_SCROLL_CONTROL
, 0x0000);
359 /* SE17-10(End)=0x9f (159), SS17-10(Start)=0x00 */
360 lcd_write_reg(R_1ST_SCR_DRV_POS
, 0x9f00);
361 /* SE27-20(End)=0x5c (92), SS27-20(Start)=0x00 */
362 lcd_write_reg(R_2ND_SCR_DRV_POS
, 0x5c00);
363 /* HEA7-0=7f, HSA7-0=00 */
364 lcd_write_reg(R_HORIZ_RAM_ADDR_POS
, 0x7f00);
365 /* PKP12-10=0x0, PKP02-00=0x0 */
366 lcd_write_reg(R_GAMMA_FINE_ADJ_POS1
, 0x0003);
367 /* PKP32-30=0x4, PKP22-20=0x0 */
368 lcd_write_reg(R_GAMMA_FINE_ADJ_POS2
, 0x0400);
369 /* PKP52-50=0x4, PKP42-40=0x7 */
370 lcd_write_reg(R_GAMMA_FINE_ADJ_POS3
, 0x0407);
371 /* PRP12-10=0x3, PRP02-00=0x5 */
372 lcd_write_reg(R_GAMMA_GRAD_ADJ_POS
, 0x0305);
373 /* PKN12-10=0x0, PKN02-00=0x3 */
374 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1
, 0x0003);
375 /* PKN32-30=0x7, PKN22-20=0x4 */
376 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2
, 0x0704);
377 /* PKN52-50=0x4, PRN42-40=0x7 */
378 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3
, 0x0407);
379 /* PRN12-10=0x5, PRN02-00=0x3 */
380 lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG
, 0x0503);
381 /* VRP14-10=0x14, VRP03-00=0x09 */
382 lcd_write_reg(R_GAMMA_AMP_ADJ_POS
, 0x1409);
383 /* VRN14-00=0x06, VRN03-00=0x02 */
384 lcd_write_reg(R_GAMMA_AMP_ADJ_NEG
, 0x0602);
386 /* 100ms or more; time for step-up circuits to stabilize */
392 static void lcd_power_off(void)
394 /* Display must be off first */
400 /** Power OFF sequence **/
401 /* Per datasheet Rev.1.10, Jun.21.2003, p. 99 */
403 /* Step-up1 halt setting bit */
404 /* BT2-0=110, DC2-0=001, AP2-0=011, SLP=0, STB=0 */
405 lcd_write_reg(R_POWER_CONTROL1
, 0x062c);
406 /* Step-up3,4 halt setting bit */
407 /* VRL3-0=0100, PON=0, VRH3-0=0001 */
408 lcd_write_reg(R_POWER_CONTROL4
, 0x0401);
409 /* VCOMG=0, VDV4-0=10011, VCM4-0=11000 */
410 lcd_write_reg(R_POWER_CONTROL5
, 0x0018 | lcd_contrast
);
412 /* Wait 100ms or more */
415 /* Step-up2,amp halt setting bit */
416 /* BT2-0=000, DC2-0=000, AP2-0=000, SLP=0, STB=0 */
417 lcd_write_reg(R_POWER_CONTROL1
, 0x0000);
425 /* Set standby mode */
426 /* BT2-0=000, DC2-0=000, AP2-0=000, SLP=0, STB=1 */
427 lcd_write_reg(R_POWER_CONTROL1
, 0x0001);
431 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
432 static void lcd_display_off(void)
436 /** Display OFF sequence **/
437 /* Per datasheet Rev.1.10, Jun.21.2003, p. 97 */
439 /* EQ1-0=00 already */
441 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=10 */
442 lcd_write_reg(R_DISP_CONTROL
, 0x0032 | disp_control_rev
);
444 sleep(HZ
/25); /* Wait 2 frames or more */
446 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=10 */
447 lcd_write_reg(R_DISP_CONTROL
, 0x0022 | disp_control_rev
);
449 sleep(HZ
/25); /* Wait 2 frames or more */
451 /* PT1-0=00, VLE2-1=00, SPT=0, GON=0, DTE=0, REV=0, D1-0=00 */
452 lcd_write_reg(R_DISP_CONTROL
, 0x0000);
456 #if defined(HAVE_LCD_ENABLE)
457 static void lcd_display_on(void)
459 /* Be sure power is on first */
463 /** Display ON Sequence **/
464 /* Per datasheet Rev.1.10, Jun.21.2003, p. 97 */
466 /* PT1-0=00, VLE2-1=00, SPT=0, GON=0, DTE=0, REV=0, D1-0=01 */
467 lcd_write_reg(R_DISP_CONTROL
, 0x0001);
469 sleep(HZ
/25); /* Wait 2 frames or more */
471 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=01 */
472 lcd_write_reg(R_DISP_CONTROL
, 0x0021 | disp_control_rev
);
473 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=11 */
474 lcd_write_reg(R_DISP_CONTROL
, 0x0023 | disp_control_rev
);
476 sleep(HZ
/25); /* Wait 2 frames or more */
478 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=11 */
479 lcd_write_reg(R_DISP_CONTROL
, 0x0033 | disp_control_rev
);
484 void lcd_enable(bool on
)
486 if (on
== display_on
)
492 /* Probably out of sync and we don't wanna pepper the code with
493 lcd_update() calls for this. */
495 lcd_activation_call_hook();
504 #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
505 bool lcd_active(void)
511 /*** update functions ***/
513 void lcd_yuv_set_options(unsigned options
)
515 lcd_yuv_options
= options
;
518 /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
519 extern void lcd_write_yuv420_lines(unsigned char const * const src
[3],
522 extern void lcd_write_yuv420_lines_odither(unsigned char const * const src
[3],
525 int x_screen
, /* To align dither pattern */
528 /* Performance function to blit a YUV bitmap directly to the LCD */
529 void lcd_blit_yuv(unsigned char * const src
[3],
530 int src_x
, int src_y
, int stride
,
531 int x
, int y
, int width
, int height
)
533 const unsigned char *yuv_src
[3];
534 const unsigned char *ysrc_max
;
538 /* NOT MODIFIED FOR THE YH-925 */
548 /* calculate the drawing region */
550 /* The 20GB LCD is actually 128x160 but rotated 90 degrees so the origin
551 * is actually the bottom left and horizontal and vertical are swapped.
552 * Rockbox expects the origin to be the top left so we need to use
553 * 127 - y instead of just y */
555 /* max vert << 8 | start vert */
556 lcd_write_reg(R_VERT_RAM_ADDR_POS
, ((x
+ width
- 1) << 8) | x
);
558 y0
= LCD_HEIGHT
- 1 - y
+ y_offset
;
560 /* DIT=0, BGR=1, HWM=0, I/D1-0=10, AM=0, LG2-0=000 */
561 lcd_write_reg(R_ENTRY_MODE
, 0x1020);
563 yuv_src
[0] = src
[0] + src_y
* stride
+ src_x
;
564 yuv_src
[1] = src
[1] + (src_y
* stride
>> 2) + (src_x
>> 1);
565 yuv_src
[2] = src
[2] + (yuv_src
[1] - src
[1]);
566 ysrc_max
= yuv_src
[0] + height
* stride
;
568 options
= lcd_yuv_options
;
572 /* max horiz << 8 | start horiz */
573 lcd_write_reg(R_HORIZ_RAM_ADDR_POS
, (y0
<< 8) | (y0
- 1));
575 /* position cursor (set AD0-AD15) */
576 /* start vert << 8 | start horiz */
577 lcd_write_reg(R_RAM_ADDR_SET
, (x
<< 8) | y0
);
580 lcd_send_cmd(R_WRITE_DATA_2_GRAM
);
582 if (options
& LCD_YUV_DITHER
)
584 lcd_write_yuv420_lines_odither(yuv_src
, width
, stride
,
590 lcd_write_yuv420_lines(yuv_src
, width
, stride
);
594 yuv_src
[0] += stride
<< 1;
595 yuv_src
[1] += stride
>> 1;
596 yuv_src
[2] += stride
>> 1;
598 while (yuv_src
[0] < ysrc_max
);
600 /* DIT=0, BGR=1, HWM=0, I/D1-0=10, AM=1, LG2-0=000 */
601 lcd_write_reg(R_ENTRY_MODE
, 0x1028);
605 /* Update a fraction of the display. */
606 void lcd_update_rect(int x0
, int y0
, int width
, int height
)
609 int lcd_x0
, lcd_x1
, lcd_y0
, lcd_y1
;
610 unsigned short *addr
;
615 /* calculate the drawing region */
616 y1
= (y0
+ height
) - 1; /* max vert */
617 x1
= (x0
+ width
) - 1; /* max horiz */
622 return; /* nothing left to do, 0 is harmful to lcd_write_data() */
626 /* The LCD is actually 128x160 rotated 90 degrees */
627 lcd_x0
= (LCD_HEIGHT
- 1) - y1
+ y_offset
;
628 lcd_x1
= (LCD_HEIGHT
- 1) - y0
+ y_offset
;
629 lcd_y0
= x0
+ x_offset
;
630 lcd_y1
= x1
+ x_offset
;
632 /* set the drawing window */
633 lcd_write_reg(R_HORIZ_RAM_ADDR_POS
, (lcd_x1
<< 8) | lcd_x0
);
634 lcd_write_reg(R_VERT_RAM_ADDR_POS
, (lcd_y1
<< 8) | lcd_y0
);
636 /* set the starting position */
637 lcd_write_reg(R_RAM_ADDR_SET
, (lcd_y0
<< 8) | lcd_x1
);
640 lcd_send_cmd(R_WRITE_DATA_2_GRAM
);
642 addr
= (unsigned short*)&lcd_framebuffer
[y0
][x0
];
647 for (r
= 0; r
< height
; r
++) {
648 /* for each column */
649 for (c
= 0; c
< width
; c
++) {
651 lcd_send_data(*addr
++);
654 addr
+= (LCD_WIDTH
- width
);
658 /* Update the display.
659 This must be called after all other LCD functions that change the display. */
660 void lcd_update(void)
662 lcd_update_rect(0, 0, LCD_WIDTH
, LCD_HEIGHT
);