summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c')
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c260
1 files changed, 0 insertions, 260 deletions
diff --git a/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c
deleted file mode 100644
index e681e1eff7..0000000000
--- a/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c
+++ /dev/null
@@ -1,260 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2004 by Linus Nielsen Feltzing
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
22/*
23 Thanks Hein-Pieter van Braam for initial work.
24
25 Mostly based on lcd-h300.c, adapted for the iaudio 7 by Vitja Makarov
26 */
27
28#include <config.h>
29
30#include <kernel.h>
31#include <cpu.h>
32#include <lcd.h>
33#include <system-target.h>
34#include <panic.h>
35
36#include "hd66789r.h"
37
38static bool display_on = false; /* is the display turned on? */
39
40static inline void lcd_write_reg(int reg, int data)
41{
42 GPIOA &= ~0x400;
43 outw(0, 0x50010000);
44 outw(reg << 1, 0x50010000);
45 GPIOA |= 0x400;
46
47 outw((data & 0xff00) >> 7, 0x50010008);
48 outw((data << 24) >> 23, 0x50010008);
49}
50
51static void lcd_write_cmd(int reg)
52{
53 GPIOA &= ~0x400;
54 outw(0, 0x50010000);
55 outw(reg << 1, 0x50010000);
56 GPIOA |= 0x400;
57}
58
59/* Do what OF do */
60static void lcd_delay(int x)
61{
62 int i;
63
64 x *= 0xc35;
65 for (i = 0; i < x * 8; i++) {
66 }
67}
68
69
70static void _display_on(void)
71{
72 GPIOA_DIR |= 0x8000 | 0x400;
73 GPIOA |= 0x8000;
74
75 /* power setup */
76 lcd_write_reg(R_START_OSC, 0x0001);
77 lcd_delay(0xf);
78 lcd_write_reg(R_DISP_CONTROL1, 0x000);
79 lcd_delay(0xa);
80 lcd_write_reg(R_POWER_CONTROL2, 0x0002);
81 lcd_write_reg(R_POWER_CONTROL3, 0x000a);
82 lcd_write_reg(R_POWER_CONTROL4, 0xc5a);
83 lcd_write_reg(R_POWER_CONTROL1, 0x0004);
84 lcd_write_reg(R_POWER_CONTROL1, 0x0134);
85 lcd_write_reg(R_POWER_CONTROL2, 0x0111);
86 lcd_write_reg(R_POWER_CONTROL3, 0x001c);
87 lcd_delay(0x28);
88 lcd_write_reg(R_POWER_CONTROL4, 0x2c40);
89 lcd_write_reg(R_POWER_CONTROL1, 0x0510);
90 lcd_delay(0x3c);
91
92 /* lcd init 2 */
93 lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x0113);
94 lcd_write_reg(R_DRV_WAVEFORM_CONTROL, 0x0700);
95 lcd_write_reg(R_ENTRY_MODE, 0x1038);
96 lcd_write_reg(R_DISP_CONTROL2, 0x0508); // 0x3c8, TMM
97 lcd_write_reg(R_DISP_CONTROL3, 0x0000);
98 lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0003);
99 lcd_write_reg(R_RAM_ADDR_SET, 0x0000);
100 lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0406);
101 lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0303);
102 lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0000);
103 lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0305);
104 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0404);
105 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0000);
106 lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0000);
107 lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0503);
108 lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0x1d05);
109 lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x1d05);
110 lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000);
111 lcd_write_reg(R_1ST_SCR_DRV_POS, 0x9f00);
112 lcd_write_reg(R_2ND_SCR_DRV_POS, 0x9f00);
113 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00);
114 lcd_write_reg(R_VERT_RAM_ADDR_POS, 0x9f00);
115
116 /* lcd init 3 */
117 lcd_write_reg(R_POWER_CONTROL1, 0x4510);
118 lcd_write_reg(R_DISP_CONTROL1, 0x0005);
119 lcd_delay(0x28);
120 lcd_write_reg(R_DISP_CONTROL1, 0x0025);
121 lcd_write_reg(R_DISP_CONTROL1, 0x0027);
122 lcd_delay(0x28);
123 lcd_write_reg(R_DISP_CONTROL1, 0x0037);
124
125 display_on = true;
126}
127
128void lcd_init_device(void)
129{
130 /* Configure external memory banks */
131 CSCFG1 = 0x0d500023 | tcc77x_cscfg_bw(TCC77X_CSCFG_BW16);
132
133 /* may be reset */
134 GPIOA |= 0x8000;
135
136 _display_on();
137}
138
139void lcd_enable(bool on)
140{
141 if (display_on == on)
142 return;
143
144 if (on) {
145 _display_on();
146 send_event(LCD_EVENT_ACTIVATION, NULL);
147 } else {
148 /** Off sequence according to datasheet, p. 130 **/
149 lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0002); /* EQ=0, 18 clks/line */
150 lcd_write_reg(R_DISP_CONTROL1, 0x0036); /* GON=1, DTE=1, REV=1, D1-0=10 */
151 sleep(2);
152
153 lcd_write_reg(R_DISP_CONTROL1, 0x0026); /* GON=1, DTE=0, REV=1, D1-0=10 */
154 sleep(2);
155
156 lcd_write_reg(R_DISP_CONTROL1, 0x0000); /* GON=0, DTE=0, D1-0=00 */
157
158 lcd_write_reg(R_POWER_CONTROL1, 0x0000); /* SAP2-0=000, AP2-0=000 */
159 lcd_write_reg(R_POWER_CONTROL3, 0x0000); /* PON=0 */
160 lcd_write_reg(R_POWER_CONTROL4, 0x0000); /* VCOMG=0 */
161
162 /* datasheet p. 131 */
163 lcd_write_reg(R_POWER_CONTROL1, 0x0001); /* STB=1: standby mode */
164
165 display_on = false;
166 }
167}
168
169bool lcd_active(void)
170{
171 return display_on;
172}
173
174
175#define RGB(r,g,b) ((((r)&0x3f) << 12)|(((g)&0x3f) << 6)|(((b)&0x3f)))
176
177
178void lcd_update(void)
179{
180 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
181}
182
183/* todo: need tests */
184void lcd_update_rect(int sx, int sy, int width, int height)
185{
186 int x, y;
187
188 if (!display_on)
189 return;
190
191 if (width <= 0 || height <= 0) /* nothing to do */
192 return;
193
194 width += sx;
195 height += sy;
196
197 if (width > LCD_WIDTH)
198 width = LCD_WIDTH;
199 if (height > LCD_HEIGHT)
200 height = LCD_HEIGHT;
201
202 lcd_write_reg(R_ENTRY_MODE, 0x1028);
203 /* set update window */
204 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8);
205 lcd_write_reg(R_VERT_RAM_ADDR_POS, ((width - 1) << 8) | sx);
206 lcd_write_reg(R_RAM_ADDR_SET, (sx << 8) | (LCD_HEIGHT - sy - 1));
207 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
208
209 for (y = sy; y < height; y++) {
210 for (x = sx; x < width; x++) {
211 fb_data c;
212 unsigned long color;
213
214 c = *FBADDR(x,y);
215 color =
216 ((c & 0x1f) << 1) | ((c & 0x7e0) << 1) | ((c & 0xf800) <<
217 2);
218
219 /* TODO: our color is 18-bit */
220 outw((color >> 9) & 0x1ff, 0x50010008);
221 outw((color) & 0x1ff, 0x50010008);
222 }
223 }
224}
225
226void lcd_set_contrast(int val)
227{
228 (void) val;
229}
230
231void lcd_set_invert_display(bool yesno)
232{
233 (void) yesno;
234}
235
236void lcd_set_flip(bool yesno)
237{
238 (void) yesno;
239}
240
241/* TODO: implement me */
242void lcd_blit_yuv(unsigned char *const src[3],
243 int src_x, int src_y, int stride,
244 int x, int y, int width, int height)
245{
246 (void) src;
247 (void) src_x;
248 (void) src_y;
249 (void) stride;
250 (void) x;
251 (void) y;
252
253 if (!display_on)
254 return;
255
256 width &= ~1; /* stay on the safe side */
257 height &= ~1;
258
259 panicf("%s", __func__);
260}