1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by Mark Arigo
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
26 static unsigned lcd_yuv_options SHAREDBSS_ATTR
= 0;
29 static inline void lcd_wait_write(void)
31 while (LCD1_CONTROL
& LCD1_BUSY_MASK
);
35 static void lcd_send_data(unsigned data
)
38 LCD1_DATA
= data
>> 8;
40 LCD1_DATA
= data
& 0xff;
43 /* send LCD command */
44 static void lcd_send_command(unsigned cmd
)
49 LCD1_CMD
= cmd
& 0xff;
52 static void lcd_write_reg(unsigned reg
, unsigned data
)
54 lcd_send_command(reg
);
58 void lcd_init_device(void)
61 /* This is the init done by the OF bootloader.
62 Re-initializing the lcd causes it to flash
63 a white screen, so for now disable this. */
65 DEV_INIT1
= DEV_INIT1
;
68 LCD1_CONTROL
= 0x4680;
70 LCD1_CONTROL
= 0x4684;
74 LCD1_CONTROL
&= ~0x200;
75 LCD1_CONTROL
&= ~0x800;
76 LCD1_CONTROL
&= ~0x400;
81 lcd_write_reg(0x0000, 0x0001);
84 lcd_write_reg(0x0011, 0x171f);
85 lcd_write_reg(0x0012, 0x0001);
86 lcd_write_reg(0x0013, 0x08cd);
87 lcd_write_reg(0x0014, 0x0416);
88 lcd_write_reg(0x0010, 0x1208);
91 lcd_write_reg(0x0013, 0x081C);
94 lcd_write_reg(0x0001, 0x0a0c);
95 lcd_write_reg(0x0002, 0x0200);
96 lcd_write_reg(0x0003, 0x1030);
97 lcd_write_reg(0x0007, 0x0005);
98 lcd_write_reg(0x0008, 0x030a);
99 lcd_write_reg(0x000b, 0x0000);
100 lcd_write_reg(0x000c, 0x0000);
101 lcd_write_reg(0x0030, 0x0000);
102 lcd_write_reg(0x0031, 0x0204);
103 lcd_write_reg(0x0032, 0x0001);
104 lcd_write_reg(0x0033, 0x0600);
105 lcd_write_reg(0x0034, 0x0607);
106 lcd_write_reg(0x0035, 0x0305);
107 lcd_write_reg(0x0036, 0x0707);
108 lcd_write_reg(0x0037, 0x0006);
109 lcd_write_reg(0x0038, 0x0400);
110 lcd_write_reg(0x0040, 0x0000);
111 lcd_write_reg(0x0042, 0x9f00);
112 lcd_write_reg(0x0043, 0x0000);
113 lcd_write_reg(0x0044, 0x7f00);
114 lcd_write_reg(0x0045, 0x9f00);
115 lcd_write_reg(0x00a8, 0x0125);
116 lcd_write_reg(0x00a9, 0x0014);
117 lcd_write_reg(0x00a7, 0x0022);
119 lcd_write_reg(0x0007, 0x0021);
121 lcd_write_reg(0x0007, 0x0023);
123 lcd_write_reg(0x0007, 0x1037);
125 lcd_write_reg(0x0021, 0x0000);
129 /*** hardware configuration ***/
131 int lcd_default_contrast(void)
133 return DEFAULT_CONTRAST_SETTING
;
137 void lcd_set_contrast(int val
)
142 void lcd_set_invert_display(bool yesno
)
147 /* turn the display upside down (call lcd_update() afterwards) */
148 void lcd_set_flip(bool yesno
)
153 void lcd_yuv_set_options(unsigned options
)
155 lcd_yuv_options
= options
;
158 /* Performance function to blit a YUV bitmap directly to the LCD */
159 void lcd_blit_yuv(unsigned char * const src
[3],
160 int src_x
, int src_y
, int stride
,
161 int x
, int y
, int width
, int height
)
173 /* Update the display.
174 This must be called after all other LCD functions that change the display. */
175 void lcd_update(void)
177 lcd_update_rect(0, 0, LCD_WIDTH
, LCD_HEIGHT
);
180 /* Update a fraction of the display. */
181 void lcd_update_rect(int x
, int y
, int width
, int height
)
185 if (x
+ width
>= LCD_WIDTH
)
186 width
= LCD_WIDTH
- x
;
187 if (y
+ height
>= LCD_HEIGHT
)
188 height
= LCD_HEIGHT
- y
;
190 if ((width
<= 0) || (height
<= 0))
191 return; /* Nothing left to do. */
193 addr
= &lcd_framebuffer
[y
][x
];
196 lcd_write_reg(0x0021, ((y
++ & 0xff) << 8) | (x
& 0xff));
197 lcd_send_command(0x0022);
201 lcd_send_data(*addr
++);
203 addr
+= LCD_WIDTH
- width
;
204 } while (--height
> 0);