1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Rockbox driver for Sansa e200 LCDs
12 * Based on reverse engineering done my MrH
14 * Copyright (c) 2006 Daniel Ankers
16 * All files in this archive are subject to the GNU General Public License.
17 * See the file COPYING in the source tree root for full license agreement.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
26 #include "backlight-target.h"
29 /* Power and display status */
30 static bool power_on
= false; /* Is the power turned on? */
31 static bool display_on SHAREDBSS_ATTR
= false; /* Is the display turned on? */
32 static unsigned lcd_yuv_options SHAREDBSS_ATTR
= 0;
35 #define R_DISP_CONTROL_NORMAL 0x0004
36 #define R_DISP_CONTROL_REV 0x0000
37 static unsigned short r_disp_control_rev
= R_DISP_CONTROL_NORMAL
;
40 #define R_DRV_OUTPUT_CONTROL_NORMAL 0x101b
41 #define R_DRV_OUTPUT_CONTROL_FLIPPED 0x131b
42 static unsigned short r_drv_output_control
= R_DRV_OUTPUT_CONTROL_NORMAL
;
44 #define LCD_DATA_IN_GPIO GPIOB_INPUT_VAL
45 #define LCD_DATA_IN_PIN 6
47 #define LCD_DATA_OUT_GPIO GPIOB_OUTPUT_VAL
48 #define LCD_DATA_OUT_PIN 7
50 #define LCD_CLOCK_GPIO GPIOB_OUTPUT_VAL
51 #define LCD_CLOCK_PIN 5
53 #define LCD_CS_GPIO GPIOD_OUTPUT_VAL
56 #define LCD_REG_0 (*(volatile unsigned long *)(0xc2000000))
57 #define LCD_REG_1 (*(volatile unsigned long *)(0xc2000004))
58 #define LCD_REG_2 (*(volatile unsigned long *)(0xc2000008))
59 #define LCD_REG_3 (*(volatile unsigned long *)(0xc200000c))
60 #define LCD_REG_4 (*(volatile unsigned long *)(0xc2000010))
61 #define LCD_REG_5 (*(volatile unsigned long *)(0xc2000014))
62 #define LCD_REG_6 (*(volatile unsigned long *)(0xc2000018))
63 #define LCD_REG_7 (*(volatile unsigned long *)(0xc200001c))
64 #define LCD_REG_8 (*(volatile unsigned long *)(0xc2000020))
65 #define LCD_REG_9 (*(volatile unsigned long *)(0xc2000024))
66 #define LCD_FB_BASE_REG (*(volatile unsigned long *)(0xc2000028))
68 /* Taken from HD66789 datasheet and seems similar enough.
69 Definitely a Renesas chip though with a perfect register index
70 match but at least one bit seems to be set that that datasheet
71 doesn't show. It says T.B.D. on the regmap anyway. */
72 #define R_START_OSC 0x00
73 #define R_DRV_OUTPUT_CONTROL 0x01
74 #define R_DRV_WAVEFORM_CONTROL 0x02
75 #define R_ENTRY_MODE 0x03
76 #define R_COMPARE_REG1 0x04
77 #define R_COMPARE_REG2 0x05
78 #define R_DISP_CONTROL1 0x07
79 #define R_DISP_CONTROL2 0x08
80 #define R_DISP_CONTROL3 0x09
81 #define R_FRAME_CYCLE_CONTROL 0x0b
82 #define R_EXT_DISP_INTF_CONTROL 0x0c
83 #define R_POWER_CONTROL1 0x10
84 #define R_POWER_CONTROL2 0x11
85 #define R_POWER_CONTROL3 0x12
86 #define R_POWER_CONTROL4 0x13
87 #define R_RAM_ADDR_SET 0x21
88 #define R_RAM_READ_DATA 0x21
89 #define R_RAM_WRITE_DATA 0x22
90 #define R_RAM_WRITE_DATA_MASK1 0x23
91 #define R_RAM_WRITE_DATA_MASK2 0x24
92 #define R_GAMMA_FINE_ADJ_POS1 0x30
93 #define R_GAMMA_FINE_ADJ_POS2 0x31
94 #define R_GAMMA_FINE_ADJ_POS3 0x32
95 #define R_GAMMA_GRAD_ADJ_POS 0x33
96 #define R_GAMMA_FINE_ADJ_NEG1 0x34
97 #define R_GAMMA_FINE_ADJ_NEG2 0x35
98 #define R_GAMMA_FINE_ADJ_NEG3 0x36
99 #define R_GAMMA_GRAD_ADJ_NEG 0x37
100 #define R_GAMMA_AMP_ADJ_POS 0x38
101 #define R_GAMMA_AMP_ADJ_NEG 0x39
102 #define R_GATE_SCAN_START_POS 0x40
103 #define R_VERT_SCROLL_CONTROL 0x41
104 #define R_1ST_SCR_DRIVE_POS 0x42
105 #define R_2ND_SCR_DRIVE_POS 0x43
106 #define R_HORIZ_RAM_ADDR_POS 0x44
107 #define R_VERT_RAM_ADDR_POS 0x45
109 /* We don't know how to receive a DMA finished signal from the LCD controller.
110 * To avoid problems with flickering, we double-buffer the framebuffer.
111 * Align as in lcd-16bit.c and not cached. */
112 static fb_data lcd_driver_framebuffer
[LCD_FBHEIGHT
][LCD_FBWIDTH
]
113 __attribute__((aligned(16))) NOCACHEBSS_ATTR
;
116 static void lcd_init_gpio(void)
118 GPIOB_ENABLE
|= (1<<7);
119 GPIOB_ENABLE
|= (1<<5);
120 GPIOB_OUTPUT_EN
|= (1<<7);
121 GPIOB_OUTPUT_EN
|= (1<<5);
122 GPIOD_ENABLE
|= (1<<6);
123 GPIOD_OUTPUT_EN
|= (1<<6);
127 static void lcd_bus_idle(void)
129 LCD_CLOCK_GPIO
|= (1 << LCD_CLOCK_PIN
);
130 LCD_DATA_OUT_GPIO
|= (1 << LCD_DATA_OUT_PIN
);
133 static void lcd_send_byte(unsigned char byte
)
138 for (i
= 7; i
>=0 ; i
--)
140 LCD_CLOCK_GPIO
&= ~(1 << LCD_CLOCK_PIN
);
143 LCD_DATA_OUT_GPIO
|= (1 << LCD_DATA_OUT_PIN
);
145 LCD_DATA_OUT_GPIO
&= ~(1 << LCD_DATA_OUT_PIN
);
148 LCD_CLOCK_GPIO
|= (1 << LCD_CLOCK_PIN
);
155 static void lcd_send_msg(unsigned char cmd
, unsigned int data
)
159 LCD_CS_GPIO
&= ~(1 << LCD_CS_PIN
);
162 lcd_send_byte((unsigned char)(data
>> 8));
163 lcd_send_byte((unsigned char)(data
& 0xff));
164 LCD_CS_GPIO
|= (1 << LCD_CS_PIN
);
169 static void lcd_write_reg(unsigned int reg
, unsigned int data
)
171 lcd_send_msg(0x70, reg
);
172 lcd_send_msg(0x72, data
);
175 /* Run the powerup sequence for the driver IC */
176 static void lcd_power_on(void)
178 /* Clear standby bit */
179 lcd_write_reg(R_POWER_CONTROL1
, 0x0000);
181 /** Power ON Sequence **/
182 lcd_write_reg(R_START_OSC
, 0x0001);
183 /* 10ms or more for oscillation circuit to stabilize */
186 /* SAP2-0=100, BT2-0=100, AP2-0=100, DK=1, SLP=0, STB=0 */
187 lcd_write_reg(R_POWER_CONTROL1
, 0x4444);
188 /* DC12-10=000, DC2-0=000, VC2-0=001 */
189 lcd_write_reg(R_POWER_CONTROL2
, 0x0001);
190 /* PON=0, VRH3-0=0011 */
191 lcd_write_reg(R_POWER_CONTROL3
, 0x0003);
192 /* VCOMG=0, VDV4-0=10001, VCM3-0=11001 */
193 lcd_write_reg(R_POWER_CONTROL4
, 0x1119);
194 /* PON=1, VRH3-0=0011 */
195 lcd_write_reg(R_POWER_CONTROL3
, 0x0013);
198 /* SAP2-0=100, BT2-0=100, AP2-0=100, DK=0, SLP=0, STB=0 */
199 lcd_write_reg(R_POWER_CONTROL1
, 0x4440);
200 /* VCOMG=1, VDV4-0=10001, VCM3-0=11001 */
201 lcd_write_reg(R_POWER_CONTROL4
, 0x3119);
204 /* VSPL=0, HSPL=0, DPL=1, EPL=0, SM=0, GS=x, SS=x, NL4-0=11011 */
205 lcd_write_reg(R_DRV_OUTPUT_CONTROL
, r_drv_output_control
);
206 /* FLD=0, FLD0=1, B/C=1, EOR=1, NW5-0=000000 */
207 lcd_write_reg(R_DRV_WAVEFORM_CONTROL
, 0x0700);
208 /* TRI=0, DFM1-0=11, BGR=0, HWM=1, ID1-0=10, AM=0, LG2-0=000
209 * AM: horizontal update direction
210 * ID1-0: H decrement, V increment
212 lcd_write_reg(R_ENTRY_MODE
, 0x6020);
213 lcd_write_reg(R_COMPARE_REG1
, 0x0000);
214 lcd_write_reg(R_COMPARE_REG2
, 0x0000);
215 /* FP3-0=0010, BP3-0=0010 */
216 lcd_write_reg(R_DISP_CONTROL2
, 0x0202);
217 /* PTG1-0=00 (normal scan), ISC3-0=0000 (ignored) */
218 lcd_write_reg(R_DISP_CONTROL3
, 0x0000);
219 /* NO2-0=01, SDT1-0=00, EQ1-0=01, DIV1-0=00, RTN3-0=0000 */
220 lcd_write_reg(R_FRAME_CYCLE_CONTROL
, 0x4400);
221 /* RM=1, DM1-0=01, RIM1-0=00 */
222 lcd_write_reg(R_EXT_DISP_INTF_CONTROL
, 0x0110);
223 /* SCN4-0=00000 - G1 if GS=0, G240 if GS=1 */
224 lcd_write_reg(R_GATE_SCAN_START_POS
, 0x0000);
225 /* VL7-0=00000000 (0 lines) */
226 lcd_write_reg(R_VERT_SCROLL_CONTROL
, 0x0000);
227 /* SE17-10=219, SS17-10=0 - 220 gates */
228 lcd_write_reg(R_1ST_SCR_DRIVE_POS
, (219 << 8));
229 /* SE27-10=0, SS27-10=0 - no second screen */
230 lcd_write_reg(R_2ND_SCR_DRIVE_POS
, 0x0000);
231 /* HEA=175, HSA=0 = H window from 0-175 */
232 lcd_write_reg(R_HORIZ_RAM_ADDR_POS
, (175 << 8));
233 /* VEA=219, VSA=0 = V window from 0-219 */
234 lcd_write_reg(R_VERT_RAM_ADDR_POS
, (219 << 8));
235 /* PKP12-10=000, PKP02-00=000 */
236 lcd_write_reg(R_GAMMA_FINE_ADJ_POS1
, 0x0000);
237 /* PKP32-30=111, PKP22-20=100 */
238 lcd_write_reg(R_GAMMA_FINE_ADJ_POS2
, 0x0704);
239 /* PKP52-50=001, PKP42-40=111 */
240 lcd_write_reg(R_GAMMA_FINE_ADJ_POS3
, 0x0107);
241 /* PRP12-10=111, PRP02-00=100 */
242 lcd_write_reg(R_GAMMA_GRAD_ADJ_POS
, 0x0704);
243 /* PKN12-10=001, PKN02-00=111 */
244 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1
, 0x0107);
245 /* PKN32-30=000, PKN22-20=010 */
246 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2
, 0x0002);
247 /* PKN52-50=111, PKN42-40=111 */
248 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3
, 0x0707);
249 /* PRN12-10=101, PRN02-00=011 */
250 lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG
, 0x0503);
251 /* VRP14-10=00000, VRP03-00=0000 */
252 lcd_write_reg(R_GAMMA_AMP_ADJ_POS
, 0x0000);
253 /* WRN14-10=00000, VRN03-00=0000 */
254 lcd_write_reg(R_GAMMA_AMP_ADJ_NEG
, 0x0000);
255 /* AD15-0=175 (upper right corner) */
256 lcd_write_reg(R_RAM_ADDR_SET
, 175);
257 /* RM=1, DM1-0=01, RIM1-0=00 */
258 lcd_write_reg(R_EXT_DISP_INTF_CONTROL
, 0x0110);
263 /* Run the display on sequence for the driver IC */
264 static void lcd_display_on(void)
268 /* Power has been turned off so full reinit is needed */
273 /* Restore what we fiddled with when turning display off */
274 /* PON=1, VRH3-0=0011 */
275 lcd_write_reg(R_POWER_CONTROL3
, 0x0013);
276 /* NO2-0=01, SDT1-0=00, EQ1-0=01, DIV1-0=00, RTN3-0=0000 */
277 lcd_write_reg(R_FRAME_CYCLE_CONTROL
, 0x4400);
278 /* VCOMG=1, VDV4-0=10001, VCM3-0=11001 */
279 lcd_write_reg(R_POWER_CONTROL4
, 0x3119);
282 /* SAP2-0=100, BT2-0=111, AP2-0=100, DK=1, SLP=0, STB=0 */
283 lcd_write_reg(R_POWER_CONTROL1
, 0x4740);
287 /* PT1-0=00, VLE2-1=00, SPT=0, IB6(??)=1, GON=0, DTE=0, CL=0,
289 lcd_write_reg(R_DISP_CONTROL1
, 0x0041 | r_disp_control_rev
);
293 /* PT1-0=00, VLE2-1=00, SPT=0, IB6(??)=1, GON=1, DTE=0, CL=0,
295 lcd_write_reg(R_DISP_CONTROL1
, 0x0061 | r_disp_control_rev
);
296 /* PT1-0=00, VLE2-1=00, SPT=0, IB6(??)=1, GON=1, DTE=0, CL=0,
298 lcd_write_reg(R_DISP_CONTROL1
, 0x0063 | r_disp_control_rev
);
302 /* PT1-0=00, VLE2-1=00, SPT=0, IB6(??)=1, GON=1, DTE=1, CL=0,
304 lcd_write_reg(R_DISP_CONTROL1
, 0x0073 | r_disp_control_rev
);
306 /* Go into write data mode */
307 lcd_send_msg(0x70, R_RAM_WRITE_DATA
);
309 /* tell that we're on now */
313 /* Turn off visible display operations */
314 static void lcd_display_off(void)
316 /* block drawing operations and changing of first */
319 /* NO2-0=01, SDT1-0=00, EQ1-0=00, DIV1-0=00, RTN3-0=0000 */
320 lcd_write_reg(R_FRAME_CYCLE_CONTROL
, 0x4000);
322 /* PT1-0=00, VLE2-1=00, SPT=0, IB6(??)=1, GON=1, DTE=1, CL=0,
324 lcd_write_reg(R_DISP_CONTROL1
, 0x0072 | r_disp_control_rev
);
328 /* PT1-0=00, VLE2-1=00, SPT=0, IB6(??)=1, GON=1, DTE=0, CL=0,
330 lcd_write_reg(R_DISP_CONTROL1
, 0x0062 | r_disp_control_rev
);
334 /* PT1-0=00, VLE2-1=00, SPT=0, IB6(??)=0, GON=0, DTE=0, CL=0,
336 lcd_write_reg(R_DISP_CONTROL1
, 0x0000);
337 /* SAP2-0=000, BT2-0=000, AP2-0=000, DK=0, SLP=0, STBY=0 */
338 lcd_write_reg(R_POWER_CONTROL1
, 0x0000);
339 /* PON=0, VRH3-0=0011 */
340 lcd_write_reg(R_POWER_CONTROL3
, 0x0003);
341 /* VCOMG=0, VDV4-0=10001, VCM4-0=11001 */
342 lcd_write_reg(R_POWER_CONTROL4
, 0x1119);
345 void lcd_init_device(void)
347 /* All this is magic worked out by MrH */
349 /* Stop any DMA which is in progress */
353 #ifdef BOOTLOADER /* Bother at all to do this again? */
354 /* Init GPIO ports */
356 /* Controller init */
357 GPO32_ENABLE
|= (1 << 28);
358 GPO32_VAL
&= ~(1 << 28);
359 DEV_INIT1
= ( (DEV_INIT1
& 0x03ffffff) | (0x15 << 26) );
360 outl(((inl(0x70000014) & (0x0fffffff)) | (0x5 << 28)), 0x70000014);
361 outl((inl(0x70000020) & ~(0x3 << 10)), 0x70000020);
362 DEV_EN
|= DEV_LCD
; /* Enable controller */
363 outl(0x6, 0x600060d0);
364 DEV_RS
|= DEV_LCD
; /* Reset controller */
365 outl((inl(0x70000020) & ~(1 << 14)), 0x70000020);
367 DEV_RS
&=~DEV_LCD
; /* Clear reset */
370 LCD_REG_0
= (LCD_REG_0
& (0x00ffffff)) | (0x22 << 24);
371 LCD_REG_0
= (LCD_REG_0
& (0xff00ffff)) | (0x14 << 16);
372 LCD_REG_0
= (LCD_REG_0
& (0xffffc0ff)) | (0x3 << 8);
373 LCD_REG_0
= (LCD_REG_0
& (0xffffffc0)) | (0xa);
375 LCD_REG_1
&= 0x00ffffff;
376 LCD_REG_1
&= 0xff00ffff;
377 LCD_REG_1
= (LCD_REG_1
& 0xffff03ff) | (0x2 << 10);
378 LCD_REG_1
= (LCD_REG_1
& 0xfffffc00) | (0xdd);
380 LCD_REG_2
|= (1 << 5);
381 LCD_REG_2
|= (1 << 6);
382 LCD_REG_2
= (LCD_REG_2
& 0xfffffcff) | (0x2 << 8);
384 LCD_REG_7
&= (0xf800ffff);
385 LCD_REG_7
&= (0xfffff800);
387 LCD_REG_8
= (LCD_REG_8
& (0xf800ffff)) | (0xb0 << 16);
388 LCD_REG_8
= (LCD_REG_8
& (0xfffff800)) | (0xdc); /* X-Y Geometry? */
391 LCD_REG_5
= (LCD_REG_5
& ~(0x70)) | (0x3 << 4);
394 LCD_REG_6
&= ~(1 << 15);
395 LCD_REG_6
|= (0xe00);
396 LCD_REG_6
= (LCD_REG_6
& (0xffffff1f)) | (0x4 << 5);
397 LCD_REG_6
|= (1 << 4);
399 LCD_REG_5
&= ~(1 << 7);
400 /* lcd_driver_framebuffer is uncached therefore at the physical address */
401 LCD_FB_BASE_REG
= (long)lcd_driver_framebuffer
;
406 /* Pull RESET low, then high to reset driver IC */
407 GPO32_VAL
&= ~(1 << 28);
409 GPO32_VAL
|= (1 << 28);
414 /* Power and display already ON - switch framebuffer address and reset
416 /* lcd_driver_framebuffer is uncached therefore at the physical address */
417 LCD_FB_BASE_REG
= (long)lcd_driver_framebuffer
;
422 lcd_set_invert_display(false);
426 LCD_REG_6
|= 1; /* Start DMA */
429 void lcd_enable(bool on
)
431 if (on
== display_on
)
436 DEV_EN
|= DEV_LCD
; /* Enable LCD controller */
437 lcd_display_on(); /* Turn on display */
438 lcd_update(); /* Resync display */
439 LCD_REG_6
|= 1; /* Restart DMA */
440 sleep(HZ
/50); /* Wait for a frame to be written */
444 LCD_REG_6
&= ~1; /* Disable DMA */
445 sleep(HZ
/50); /* Wait for dma end (assuming 50Hz) */
446 lcd_display_off(); /* Turn off display */
447 DEV_EN
&= ~DEV_LCD
; /* Disable LCD controller */
451 bool lcd_enabled(void)
463 /* Turn off display */
470 /* Set standby mode */
471 /* SAP2-0=000, BT2-0=000, AP2-0=000, DK=0, SLP=0, STB=1 */
472 lcd_write_reg(R_POWER_CONTROL1
, 0x0001);
475 /* Copies a rectangle from one framebuffer to another. Can be used in
476 single transfer mode with width = num pixels, and height = 1 which
477 allows a full-width rectangle to be copied more efficiently. */
478 extern void lcd_copy_buffer_rect(fb_data
*dst
, const fb_data
*src
,
479 int width
, int height
);
480 void lcd_update_rect(int x
, int y
, int width
, int height
)
487 if (x
+ width
> LCD_WIDTH
)
488 width
= LCD_WIDTH
- x
; /* Clip right */
490 width
+= x
, x
= 0; /* Clip left */
492 return; /* nothing left to do */
494 if (y
+ height
> LCD_HEIGHT
)
495 height
= LCD_HEIGHT
- y
; /* Clip bottom */
497 height
+= y
, y
= 0; /* Clip top */
499 return; /* nothing left to do */
501 dst
= &lcd_driver_framebuffer
[y
][x
];
502 src
= &lcd_framebuffer
[y
][x
];
504 /* Copy part of the Rockbox framebuffer to the second framebuffer */
505 if (width
< LCD_WIDTH
)
507 /* Not full width - do line-by-line */
508 lcd_copy_buffer_rect(dst
, src
, width
, height
);
512 /* Full width - copy as one line */
513 lcd_copy_buffer_rect(dst
, src
, LCD_WIDTH
*height
, 1);
517 void lcd_update(void)
522 /* Copy the Rockbox framebuffer to the second framebuffer */
523 lcd_copy_buffer_rect(&lcd_driver_framebuffer
[0][0],
524 &lcd_framebuffer
[0][0], LCD_WIDTH
*LCD_HEIGHT
, 1);
528 /*** hardware configuration ***/
530 void lcd_set_contrast(int val
)
532 /* TODO: Implement lcd_set_contrast() */
536 void lcd_set_invert_display(bool yesno
)
538 bool dma_on
= LCD_REG_6
& 1;
542 LCD_REG_6
&= ~1; /* Disable DMA */
543 sleep(HZ
/50); /* Wait for dma end (assuming 50Hz) */
544 DEV_EN
&= ~DEV_LCD
; /* Disable LCD controller */
547 r_disp_control_rev
= yesno
? R_DISP_CONTROL_REV
:
548 R_DISP_CONTROL_NORMAL
;
552 /* PT1-0=00, VLE2-1=00, SPT=0, IB6(??)=1, GON=1, CL=0,
553 DTE=1, REV=x, D1-0=11 */
554 lcd_write_reg(R_DISP_CONTROL1
, 0x0073 | r_disp_control_rev
);
559 DEV_EN
|= DEV_LCD
; /* Enable LCD controller */
560 lcd_send_msg(0x70, R_RAM_WRITE_DATA
); /* Set to RAM write mode */
561 LCD_REG_6
|= 1; /* Restart DMA */
565 /* turn the display upside down (call lcd_update() afterwards) */
566 void lcd_set_flip(bool yesno
)
568 bool dma_on
= LCD_REG_6
& 1;
572 LCD_REG_6
&= ~1; /* Disable DMA */
573 sleep(HZ
/50); /* Wait for dma end (assuming 50Hz) */
574 DEV_EN
&= ~DEV_LCD
; /* Disable LCD controller */
577 r_drv_output_control
= yesno
? R_DRV_OUTPUT_CONTROL_FLIPPED
:
578 R_DRV_OUTPUT_CONTROL_NORMAL
;
582 /* VSPL=0, HSPL=0, DPL=1, EPL=0, SM=0, GS=x, SS=x,
583 NL4-0=11011 (G1-G224) */
584 lcd_write_reg(R_DRV_OUTPUT_CONTROL
, r_drv_output_control
);
589 DEV_EN
|= DEV_LCD
; /* Enable LCD controller */
590 lcd_send_msg(0x70, R_RAM_WRITE_DATA
); /* Set to RAM write mode */
591 LCD_REG_6
|= 1; /* Restart DMA */
595 /* Blitting functions */
597 void lcd_yuv_set_options(unsigned options
)
599 lcd_yuv_options
= options
;
602 /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
603 extern void lcd_write_yuv420_lines(fb_data
*dst
,
604 unsigned char const * const src
[3],
607 extern void lcd_write_yuv420_lines_odither(fb_data
*dst
,
608 unsigned char const * const src
[3],
611 int x_screen
, /* To align dither pattern */
613 /* Performance function to blit a YUV bitmap directly to the LCD */
614 /* For the e200 - show it rotated */
615 /* So the LCD_WIDTH is now the height */
616 void lcd_blit_yuv(unsigned char * const src
[3],
617 int src_x
, int src_y
, int stride
,
618 int x
, int y
, int width
, int height
)
620 unsigned char const * yuv_src
[3];
626 /* Sorry, but width and height must be >= 2 or else */
630 y
= LCD_WIDTH
- 1 - y
;
631 fb_data
*dst
= &lcd_driver_framebuffer
[x
][y
];
634 yuv_src
[0] = src
[0] + z
+ src_x
;
635 yuv_src
[1] = src
[1] + (z
>> 2) + (src_x
>> 1);
636 yuv_src
[2] = src
[2] + (yuv_src
[1] - src
[1]);
638 if (lcd_yuv_options
& LCD_YUV_DITHER
)
642 lcd_write_yuv420_lines_odither(dst
, yuv_src
, width
, stride
, y
, x
);
643 yuv_src
[0] += stride
<< 1; /* Skip down two luma lines */
644 yuv_src
[1] += stride
>> 1; /* Skip down one chroma line */
645 yuv_src
[2] += stride
>> 1;
649 while (--height
> 0);
655 lcd_write_yuv420_lines(dst
, yuv_src
, width
, stride
);
656 yuv_src
[0] += stride
<< 1; /* Skip down two luma lines */
657 yuv_src
[1] += stride
>> 1; /* Skip down one chroma line */
658 yuv_src
[2] += stride
>> 1;
661 while (--height
> 0);