summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tcc77x/c100/lcd-S6B33B2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tcc77x/c100/lcd-S6B33B2.c')
-rw-r--r--firmware/target/arm/tcc77x/c100/lcd-S6B33B2.c286
1 files changed, 0 insertions, 286 deletions
diff --git a/firmware/target/arm/tcc77x/c100/lcd-S6B33B2.c b/firmware/target/arm/tcc77x/c100/lcd-S6B33B2.c
deleted file mode 100644
index c53aadaf30..0000000000
--- a/firmware/target/arm/tcc77x/c100/lcd-S6B33B2.c
+++ /dev/null
@@ -1,286 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Mark Arigo
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22#include "cpu.h"
23#include "lcd.h"
24#include "kernel.h"
25#include "system.h"
26
27/* Display status */
28static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0;
29
30/* LCD command set for Samsung S6B33B2 */
31#define R_NOP 0x00
32#define R_OSCILLATION_MODE 0x02
33#define R_DRIVER_OUTPUT_MODE 0x10
34#define R_DCDC_SET 0x20
35#define R_BIAS_SET 0x22
36#define R_DCDC_CLOCK_DIV 0x24
37#define R_DCDC_AMP_ONOFF 0x26
38#define R_TEMP_COMPENSATION 0x28
39#define R_CONTRAST_CONTROL1 0x2a
40#define R_CONTRAST_CONTROL2 0x2b
41#define R_STANDBY_OFF 0x2c
42#define R_STANDBY_ON 0x2d
43#define R_DDRAM_BURST_OFF 0x2e
44#define R_DDRAM_BURST_ON 0x2f
45#define R_ADDRESSING_MODE 0x30
46#define R_ROW_VECTOR_MODE 0x32
47#define R_N_LINE_INVERSION 0x34
48#define R_FRAME_FREQ_CONTROL 0x36
49#define R_RED_PALETTE 0x38
50#define R_GREEN_PALETTE 0x3a
51#define R_BLUE_PALETTE 0x3c
52#define R_ENTRY_MODE 0x40
53#define R_X_ADDR_AREA 0x42
54#define R_Y_ADDR_AREA 0x43
55#define R_RAM_SKIP_AREA 0x45
56#define R_DISPLAY_OFF 0x50
57#define R_DISPLAY_ON 0x51
58#define R_SPEC_DISPLAY_PATTERN 0x53
59#define R_PARTIAL_DISPLAY_MODE 0x55
60#define R_PARTIAL_START_LINE 0x56
61#define R_PARTIAL_END_LINE 0x57
62#define R_AREA_SCROLL_MODE 0x59
63#define R_SCROLL_START_LINE 0x5a
64#define R_DATA_FORMAT_SELECT 0x60
65
66/* TCC77x specific defines */
67#define LCD_BASE 0x50000000
68#define LCD_CMD *(volatile unsigned char*)(LCD_BASE)
69#define LCD_DATA *(volatile unsigned char*)(LCD_BASE+1)
70
71static void lcd_send_command(unsigned cmd)
72{
73 LCD_CMD = cmd;
74
75 asm volatile (
76 "nop \n\t"
77 "nop \n\t"
78 "nop \n\t"
79 );
80}
81
82static void lcd_send_data(unsigned data)
83{
84 LCD_DATA = (data & 0xff00) >> 8;
85 LCD_DATA = (data & 0x00ff);
86}
87
88/* End of TCC77x specific defines */
89
90/* LCD init */
91void lcd_init_device(void)
92{
93 uint32_t bus_width;
94
95 /* Telechips init the same as the original firmware */
96 bus_width = ((MCFG >> 11) & 0x3) ^ 3;
97
98 CSCFG1 = (bus_width << 28) |
99 (3 << 26) | /* MTYPE = 3 */
100 ((LCD_BASE >> 28) << 22) | /* CSBASE = 0x5 */
101 (1 << 20) | /* Unknown */
102 (2 << 11) | /* Setup time = 2 cycles */
103 (2 << 3) | /* Pulse width = 2+1 cycles */
104 (2 << 0); /* Hold time = 2 cycle */
105
106 GPIOE &= ~0x8;
107 sleep(HZ/100); /* 10ms */
108
109 GPIOE |= 0x08;
110 sleep(HZ/100); /* 10ms */
111
112 lcd_send_command(R_STANDBY_OFF);
113 sleep(HZ/20); /* 50ms */
114
115 lcd_send_command(R_OSCILLATION_MODE);
116 lcd_send_command(0x01);
117 sleep(HZ/100); /* 10ms */
118
119 lcd_send_command(R_DCDC_AMP_ONOFF);
120 lcd_send_command(0x01);
121 sleep(HZ/100); /* 10ms */
122
123 lcd_send_command(R_DCDC_AMP_ONOFF);
124 lcd_send_command(0x09);
125 sleep(HZ/100); /* 10ms */
126
127 lcd_send_command(R_DCDC_AMP_ONOFF);
128 lcd_send_command(0x0b);
129 sleep(HZ/100); /* 10ms */
130
131 lcd_send_command(R_DCDC_AMP_ONOFF);
132 lcd_send_command(0x0f);
133 sleep(HZ/100); /* 10ms */
134
135 lcd_send_command(R_DCDC_SET);
136 lcd_send_command(0x01);
137 sleep(HZ/100); /* 10ms */
138 sleep(HZ/10); /* 100ms */
139
140 lcd_send_command(R_TEMP_COMPENSATION);
141 lcd_send_command(0x01);
142 sleep(HZ/100); /* 10ms */
143
144 lcd_send_command(R_DRIVER_OUTPUT_MODE);
145 lcd_send_command(0x03);
146
147 lcd_send_command(R_ENTRY_MODE);
148 lcd_send_command(0x81);
149
150 lcd_send_command(R_N_LINE_INVERSION);
151 lcd_send_command(0x04);
152 lcd_send_command(0xfa);
153 lcd_send_command(0x5f);
154
155 lcd_set_contrast(0x28);
156
157 lcd_send_command(R_SPEC_DISPLAY_PATTERN);
158 lcd_send_command(0x0);
159 sleep(HZ/100); /* 10ms */
160
161 lcd_send_command(R_ADDRESSING_MODE);
162 lcd_send_command(0x0);
163 sleep(HZ/100); /* 10ms */
164
165 lcd_send_command(R_PARTIAL_DISPLAY_MODE);
166 lcd_send_command(0x0);
167 sleep(HZ/100); /* 10ms */
168
169 lcd_send_command(R_X_ADDR_AREA);
170 lcd_send_command(0);
171 lcd_send_command(0x80);
172
173 lcd_send_command(R_Y_ADDR_AREA);
174 lcd_send_command(0x0);
175 lcd_send_command(0x80);
176
177 lcd_send_command(R_DISPLAY_ON);
178
179 lcd_send_command(R_SPEC_DISPLAY_PATTERN);
180 lcd_send_command(0x0);
181
182 /* Rockbox init */
183 lcd_clear_display();
184 lcd_update();
185}
186
187/*** hardware configuration ***/
188int lcd_default_contrast(void)
189{
190 return 0x28;
191}
192
193void lcd_set_contrast(int val)
194{
195 //val &= 0xFF;
196 lcd_send_command(R_CONTRAST_CONTROL1);
197 lcd_send_command(val);
198}
199
200void lcd_set_invert_display(bool yesno)
201{
202 /* TODO: Implement lcd_set_invert_display() */
203 (void)yesno;
204}
205
206/* turn the display upside down (call lcd_update() afterwards) */
207void lcd_set_flip(bool yesno)
208{
209 lcd_send_command(R_DRIVER_OUTPUT_MODE);
210 lcd_send_command(yesno ? 0x02 : 0x07);
211}
212
213/*** update functions ***/
214void lcd_yuv_set_options(unsigned options)
215{
216 lcd_yuv_options = options;
217}
218
219/* TODO: implement me */
220void lcd_blit_yuv(unsigned char *const src[3],
221 int src_x, int src_y, int stride,
222 int x, int y, int width, int height)
223{
224 (void) src;
225 (void) src_x;
226 (void) src_y;
227 (void) stride;
228 (void) x;
229 (void) y;
230
231 return;
232
233}
234
235/* Update the display.
236 This must be called after all other LCD functions that change the display. */
237void lcd_update(void)
238{
239 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
240}
241
242/* Update a fraction of the display. */
243void lcd_update_rect(int x, int y, int width, int height)
244{
245 const fb_data *addr;
246
247 if (x + width >= LCD_WIDTH)
248 width = LCD_WIDTH - x;
249 if (y + height >= LCD_HEIGHT)
250 height = LCD_HEIGHT - y;
251
252 if ((width <= 0) || (height <= 0))
253 return; /* Nothing left to do. */
254
255 addr = FBADDR(x,y);
256
257 if (width <= 1) {
258 lcd_send_command(R_ENTRY_MODE); /* The X end address must be larger */
259 lcd_send_command(0x80); /* that the X start address, so we */
260 lcd_send_command(R_X_ADDR_AREA); /* switch to vertical mode for */
261 lcd_send_command(x); /* single column updates and set */
262 lcd_send_command(x + 1); /* the window width to 2 */
263 } else {
264 lcd_send_command(R_ENTRY_MODE);
265 lcd_send_command(0x82);
266 lcd_send_command(R_X_ADDR_AREA);
267 lcd_send_command(x);
268 lcd_send_command(x + width - 1);
269 }
270
271 lcd_send_command(R_Y_ADDR_AREA);
272 lcd_send_command(y);
273 lcd_send_command(y + height - 1);
274
275 /* NOP needed because on some c200s, the previous lcd_send_command is
276 interpreted as a separate command instead of part of R_Y_ADDR_AREA. */
277 lcd_send_command(R_NOP);
278
279 do {
280 int w = width;
281 do {
282 lcd_send_data(*addr++);
283 } while (--w > 0);
284 addr += LCD_WIDTH - width;
285 } while (--height > 0);
286}