root / hw / omap_lcdc.c @ c60e08d9
History | View | Annotate | Download (13.7 kB)
1 | c3d2689d | balrog | /*
|
---|---|---|---|
2 | c3d2689d | balrog | * OMAP LCD controller.
|
3 | c3d2689d | balrog | *
|
4 | c3d2689d | balrog | * Copyright (C) 2006-2007 Andrzej Zaborowski <balrog@zabor.org>
|
5 | c3d2689d | balrog | *
|
6 | c3d2689d | balrog | * This program is free software; you can redistribute it and/or
|
7 | c3d2689d | balrog | * modify it under the terms of the GNU General Public License as
|
8 | c3d2689d | balrog | * published by the Free Software Foundation; either version 2 of
|
9 | c3d2689d | balrog | * the License, or (at your option) any later version.
|
10 | c3d2689d | balrog | *
|
11 | c3d2689d | balrog | * This program is distributed in the hope that it will be useful,
|
12 | c3d2689d | balrog | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | c3d2689d | balrog | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | c3d2689d | balrog | * GNU General Public License for more details.
|
15 | c3d2689d | balrog | *
|
16 | c3d2689d | balrog | * You should have received a copy of the GNU General Public License
|
17 | c3d2689d | balrog | * along with this program; if not, write to the Free Software
|
18 | c3d2689d | balrog | * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
19 | c3d2689d | balrog | * MA 02111-1307 USA
|
20 | c3d2689d | balrog | */
|
21 | 87ecb68b | pbrook | #include "hw.h" |
22 | 87ecb68b | pbrook | #include "console.h" |
23 | 87ecb68b | pbrook | #include "omap.h" |
24 | c3d2689d | balrog | |
25 | c3d2689d | balrog | struct omap_lcd_panel_s {
|
26 | c3d2689d | balrog | target_phys_addr_t base; |
27 | c3d2689d | balrog | qemu_irq irq; |
28 | c3d2689d | balrog | DisplayState *state; |
29 | c60e08d9 | pbrook | QEMUConsole *console; |
30 | c3d2689d | balrog | ram_addr_t imif_base; |
31 | c3d2689d | balrog | ram_addr_t emiff_base; |
32 | c3d2689d | balrog | |
33 | c3d2689d | balrog | int plm;
|
34 | c3d2689d | balrog | int tft;
|
35 | c3d2689d | balrog | int mono;
|
36 | c3d2689d | balrog | int enable;
|
37 | c3d2689d | balrog | int width;
|
38 | c3d2689d | balrog | int height;
|
39 | c3d2689d | balrog | int interrupts;
|
40 | c3d2689d | balrog | uint32_t timing[3];
|
41 | c3d2689d | balrog | uint32_t subpanel; |
42 | c3d2689d | balrog | uint32_t ctrl; |
43 | c3d2689d | balrog | |
44 | c3d2689d | balrog | struct omap_dma_lcd_channel_s *dma;
|
45 | c3d2689d | balrog | uint16_t palette[256];
|
46 | c3d2689d | balrog | int palette_done;
|
47 | c3d2689d | balrog | int frame_done;
|
48 | c3d2689d | balrog | int invalidate;
|
49 | c3d2689d | balrog | int sync_error;
|
50 | c3d2689d | balrog | }; |
51 | c3d2689d | balrog | |
52 | c3d2689d | balrog | static void omap_lcd_interrupts(struct omap_lcd_panel_s *s) |
53 | c3d2689d | balrog | { |
54 | c3d2689d | balrog | if (s->frame_done && (s->interrupts & 1)) { |
55 | c3d2689d | balrog | qemu_irq_raise(s->irq); |
56 | c3d2689d | balrog | return;
|
57 | c3d2689d | balrog | } |
58 | c3d2689d | balrog | |
59 | c3d2689d | balrog | if (s->palette_done && (s->interrupts & 2)) { |
60 | c3d2689d | balrog | qemu_irq_raise(s->irq); |
61 | c3d2689d | balrog | return;
|
62 | c3d2689d | balrog | } |
63 | c3d2689d | balrog | |
64 | c3d2689d | balrog | if (s->sync_error) {
|
65 | c3d2689d | balrog | qemu_irq_raise(s->irq); |
66 | c3d2689d | balrog | return;
|
67 | c3d2689d | balrog | } |
68 | c3d2689d | balrog | |
69 | c3d2689d | balrog | qemu_irq_lower(s->irq); |
70 | c3d2689d | balrog | } |
71 | c3d2689d | balrog | |
72 | c3d2689d | balrog | #include "pixel_ops.h" |
73 | c3d2689d | balrog | |
74 | c3d2689d | balrog | typedef void draw_line_func( |
75 | c3d2689d | balrog | uint8_t *d, const uint8_t *s, int width, const uint16_t *pal); |
76 | c3d2689d | balrog | |
77 | c3d2689d | balrog | #define DEPTH 8 |
78 | c3d2689d | balrog | #include "omap_lcd_template.h" |
79 | c3d2689d | balrog | #define DEPTH 15 |
80 | c3d2689d | balrog | #include "omap_lcd_template.h" |
81 | c3d2689d | balrog | #define DEPTH 16 |
82 | c3d2689d | balrog | #include "omap_lcd_template.h" |
83 | c3d2689d | balrog | #define DEPTH 32 |
84 | c3d2689d | balrog | #include "omap_lcd_template.h" |
85 | c3d2689d | balrog | |
86 | c3d2689d | balrog | static draw_line_func *draw_line_table2[33] = { |
87 | c3d2689d | balrog | [0 ... 32] = 0, |
88 | c3d2689d | balrog | [8] = draw_line2_8,
|
89 | c3d2689d | balrog | [15] = draw_line2_15,
|
90 | c3d2689d | balrog | [16] = draw_line2_16,
|
91 | c3d2689d | balrog | [32] = draw_line2_32,
|
92 | c3d2689d | balrog | }, *draw_line_table4[33] = {
|
93 | c3d2689d | balrog | [0 ... 32] = 0, |
94 | c3d2689d | balrog | [8] = draw_line4_8,
|
95 | c3d2689d | balrog | [15] = draw_line4_15,
|
96 | c3d2689d | balrog | [16] = draw_line4_16,
|
97 | c3d2689d | balrog | [32] = draw_line4_32,
|
98 | c3d2689d | balrog | }, *draw_line_table8[33] = {
|
99 | c3d2689d | balrog | [0 ... 32] = 0, |
100 | c3d2689d | balrog | [8] = draw_line8_8,
|
101 | c3d2689d | balrog | [15] = draw_line8_15,
|
102 | c3d2689d | balrog | [16] = draw_line8_16,
|
103 | c3d2689d | balrog | [32] = draw_line8_32,
|
104 | c3d2689d | balrog | }, *draw_line_table12[33] = {
|
105 | c3d2689d | balrog | [0 ... 32] = 0, |
106 | c3d2689d | balrog | [8] = draw_line12_8,
|
107 | c3d2689d | balrog | [15] = draw_line12_15,
|
108 | c3d2689d | balrog | [16] = draw_line12_16,
|
109 | c3d2689d | balrog | [32] = draw_line12_32,
|
110 | c3d2689d | balrog | }, *draw_line_table16[33] = {
|
111 | c3d2689d | balrog | [0 ... 32] = 0, |
112 | c3d2689d | balrog | [8] = draw_line16_8,
|
113 | c3d2689d | balrog | [15] = draw_line16_15,
|
114 | c3d2689d | balrog | [16] = draw_line16_16,
|
115 | c3d2689d | balrog | [32] = draw_line16_32,
|
116 | c3d2689d | balrog | }; |
117 | c3d2689d | balrog | |
118 | 9596ebb7 | pbrook | static void omap_update_display(void *opaque) |
119 | c3d2689d | balrog | { |
120 | c3d2689d | balrog | struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque; |
121 | c3d2689d | balrog | draw_line_func *draw_line; |
122 | c3d2689d | balrog | int size, dirty[2], minline, maxline, height; |
123 | c3d2689d | balrog | int line, width, linesize, step, bpp, frame_offset;
|
124 | c3d2689d | balrog | ram_addr_t frame_base, scanline, newline, x; |
125 | c3d2689d | balrog | uint8_t *s, *d; |
126 | c3d2689d | balrog | |
127 | c3d2689d | balrog | if (!omap_lcd || omap_lcd->plm == 1 || |
128 | c3d2689d | balrog | !omap_lcd->enable || !omap_lcd->state->depth) |
129 | c3d2689d | balrog | return;
|
130 | c3d2689d | balrog | |
131 | c3d2689d | balrog | frame_offset = 0;
|
132 | c3d2689d | balrog | if (omap_lcd->plm != 2) { |
133 | c3d2689d | balrog | memcpy(omap_lcd->palette, phys_ram_base + |
134 | c3d2689d | balrog | omap_lcd->dma->phys_framebuffer[ |
135 | c3d2689d | balrog | omap_lcd->dma->current_frame], 0x200);
|
136 | c3d2689d | balrog | switch (omap_lcd->palette[0] >> 12 & 7) { |
137 | c3d2689d | balrog | case 3 ... 7: |
138 | c3d2689d | balrog | frame_offset += 0x200;
|
139 | c3d2689d | balrog | break;
|
140 | c3d2689d | balrog | default:
|
141 | c3d2689d | balrog | frame_offset += 0x20;
|
142 | c3d2689d | balrog | } |
143 | c3d2689d | balrog | } |
144 | c3d2689d | balrog | |
145 | c3d2689d | balrog | /* Colour depth */
|
146 | c3d2689d | balrog | switch ((omap_lcd->palette[0] >> 12) & 7) { |
147 | c3d2689d | balrog | case 1: |
148 | c3d2689d | balrog | draw_line = draw_line_table2[omap_lcd->state->depth]; |
149 | c3d2689d | balrog | bpp = 2;
|
150 | c3d2689d | balrog | break;
|
151 | c3d2689d | balrog | |
152 | c3d2689d | balrog | case 2: |
153 | c3d2689d | balrog | draw_line = draw_line_table4[omap_lcd->state->depth]; |
154 | c3d2689d | balrog | bpp = 4;
|
155 | c3d2689d | balrog | break;
|
156 | c3d2689d | balrog | |
157 | c3d2689d | balrog | case 3: |
158 | c3d2689d | balrog | draw_line = draw_line_table8[omap_lcd->state->depth]; |
159 | c3d2689d | balrog | bpp = 8;
|
160 | c3d2689d | balrog | break;
|
161 | c3d2689d | balrog | |
162 | c3d2689d | balrog | case 4 ... 7: |
163 | c3d2689d | balrog | if (!omap_lcd->tft)
|
164 | c3d2689d | balrog | draw_line = draw_line_table12[omap_lcd->state->depth]; |
165 | c3d2689d | balrog | else
|
166 | c3d2689d | balrog | draw_line = draw_line_table16[omap_lcd->state->depth]; |
167 | c3d2689d | balrog | bpp = 16;
|
168 | c3d2689d | balrog | break;
|
169 | c3d2689d | balrog | |
170 | c3d2689d | balrog | default:
|
171 | c3d2689d | balrog | /* Unsupported at the moment. */
|
172 | c3d2689d | balrog | return;
|
173 | c3d2689d | balrog | } |
174 | c3d2689d | balrog | |
175 | c3d2689d | balrog | /* Resolution */
|
176 | c3d2689d | balrog | width = omap_lcd->width; |
177 | c3d2689d | balrog | if (width != omap_lcd->state->width ||
|
178 | c3d2689d | balrog | omap_lcd->height != omap_lcd->state->height) { |
179 | c60e08d9 | pbrook | qemu_console_resize(omap_lcd->console, |
180 | c60e08d9 | pbrook | omap_lcd->width, omap_lcd->height); |
181 | c3d2689d | balrog | omap_lcd->invalidate = 1;
|
182 | c3d2689d | balrog | } |
183 | c3d2689d | balrog | |
184 | c3d2689d | balrog | if (omap_lcd->dma->current_frame == 0) |
185 | c3d2689d | balrog | size = omap_lcd->dma->src_f1_bottom - omap_lcd->dma->src_f1_top; |
186 | c3d2689d | balrog | else
|
187 | c3d2689d | balrog | size = omap_lcd->dma->src_f2_bottom - omap_lcd->dma->src_f2_top; |
188 | c3d2689d | balrog | |
189 | c3d2689d | balrog | if (frame_offset + ((width * omap_lcd->height * bpp) >> 3) > size + 2) { |
190 | c3d2689d | balrog | omap_lcd->sync_error = 1;
|
191 | c3d2689d | balrog | omap_lcd_interrupts(omap_lcd); |
192 | c3d2689d | balrog | omap_lcd->enable = 0;
|
193 | c3d2689d | balrog | return;
|
194 | c3d2689d | balrog | } |
195 | c3d2689d | balrog | |
196 | c3d2689d | balrog | /* Content */
|
197 | c3d2689d | balrog | frame_base = omap_lcd->dma->phys_framebuffer[ |
198 | c3d2689d | balrog | omap_lcd->dma->current_frame] + frame_offset; |
199 | c3d2689d | balrog | omap_lcd->dma->condition |= 1 << omap_lcd->dma->current_frame;
|
200 | c3d2689d | balrog | if (omap_lcd->dma->interrupts & 1) |
201 | c3d2689d | balrog | qemu_irq_raise(omap_lcd->dma->irq); |
202 | c3d2689d | balrog | if (omap_lcd->dma->dual)
|
203 | c3d2689d | balrog | omap_lcd->dma->current_frame ^= 1;
|
204 | c3d2689d | balrog | |
205 | c3d2689d | balrog | if (!omap_lcd->state->depth)
|
206 | c3d2689d | balrog | return;
|
207 | c3d2689d | balrog | |
208 | c3d2689d | balrog | line = 0;
|
209 | c3d2689d | balrog | height = omap_lcd->height; |
210 | c3d2689d | balrog | if (omap_lcd->subpanel & (1 << 31)) { |
211 | c3d2689d | balrog | if (omap_lcd->subpanel & (1 << 29)) |
212 | c3d2689d | balrog | line = (omap_lcd->subpanel >> 16) & 0x3ff; |
213 | c3d2689d | balrog | else
|
214 | c3d2689d | balrog | height = (omap_lcd->subpanel >> 16) & 0x3ff; |
215 | c3d2689d | balrog | /* TODO: fill the rest of the panel with DPD */
|
216 | c3d2689d | balrog | } |
217 | c3d2689d | balrog | step = width * bpp >> 3;
|
218 | c3d2689d | balrog | scanline = frame_base + step * line; |
219 | c3d2689d | balrog | s = (uint8_t *) (phys_ram_base + scanline); |
220 | c3d2689d | balrog | d = omap_lcd->state->data; |
221 | c3d2689d | balrog | linesize = omap_lcd->state->linesize; |
222 | c3d2689d | balrog | |
223 | c3d2689d | balrog | dirty[0] = dirty[1] = |
224 | c3d2689d | balrog | cpu_physical_memory_get_dirty(scanline, VGA_DIRTY_FLAG); |
225 | c3d2689d | balrog | minline = height; |
226 | c3d2689d | balrog | maxline = line; |
227 | c3d2689d | balrog | for (; line < height; line ++) {
|
228 | c3d2689d | balrog | newline = scanline + step; |
229 | c3d2689d | balrog | for (x = scanline + TARGET_PAGE_SIZE; x < newline;
|
230 | c3d2689d | balrog | x += TARGET_PAGE_SIZE) { |
231 | c3d2689d | balrog | dirty[1] = cpu_physical_memory_get_dirty(x, VGA_DIRTY_FLAG);
|
232 | c3d2689d | balrog | dirty[0] |= dirty[1]; |
233 | c3d2689d | balrog | } |
234 | c3d2689d | balrog | if (dirty[0] || omap_lcd->invalidate) { |
235 | c3d2689d | balrog | draw_line(d, s, width, omap_lcd->palette); |
236 | c3d2689d | balrog | if (line < minline)
|
237 | c3d2689d | balrog | minline = line; |
238 | c3d2689d | balrog | maxline = line + 1;
|
239 | c3d2689d | balrog | } |
240 | c3d2689d | balrog | scanline = newline; |
241 | c3d2689d | balrog | dirty[0] = dirty[1]; |
242 | c3d2689d | balrog | s += step; |
243 | c3d2689d | balrog | d += linesize; |
244 | c3d2689d | balrog | } |
245 | c3d2689d | balrog | |
246 | c3d2689d | balrog | if (maxline >= minline) {
|
247 | c3d2689d | balrog | dpy_update(omap_lcd->state, 0, minline, width, maxline);
|
248 | c3d2689d | balrog | cpu_physical_memory_reset_dirty(frame_base + step * minline, |
249 | c3d2689d | balrog | frame_base + step * maxline, VGA_DIRTY_FLAG); |
250 | c3d2689d | balrog | } |
251 | c3d2689d | balrog | } |
252 | c3d2689d | balrog | |
253 | c3d2689d | balrog | static int ppm_save(const char *filename, uint8_t *data, |
254 | c3d2689d | balrog | int w, int h, int linesize) |
255 | c3d2689d | balrog | { |
256 | c3d2689d | balrog | FILE *f; |
257 | c3d2689d | balrog | uint8_t *d, *d1; |
258 | c3d2689d | balrog | unsigned int v; |
259 | c3d2689d | balrog | int y, x, bpp;
|
260 | c3d2689d | balrog | |
261 | c3d2689d | balrog | f = fopen(filename, "wb");
|
262 | c3d2689d | balrog | if (!f)
|
263 | c3d2689d | balrog | return -1; |
264 | c3d2689d | balrog | fprintf(f, "P6\n%d %d\n%d\n", w, h, 255); |
265 | c3d2689d | balrog | d1 = data; |
266 | c3d2689d | balrog | bpp = linesize / w; |
267 | c3d2689d | balrog | for (y = 0; y < h; y ++) { |
268 | c3d2689d | balrog | d = d1; |
269 | c3d2689d | balrog | for (x = 0; x < w; x ++) { |
270 | c3d2689d | balrog | v = *(uint32_t *) d; |
271 | c3d2689d | balrog | switch (bpp) {
|
272 | c3d2689d | balrog | case 2: |
273 | c3d2689d | balrog | fputc((v >> 8) & 0xf8, f); |
274 | c3d2689d | balrog | fputc((v >> 3) & 0xfc, f); |
275 | c3d2689d | balrog | fputc((v << 3) & 0xf8, f); |
276 | c3d2689d | balrog | break;
|
277 | c3d2689d | balrog | case 3: |
278 | c3d2689d | balrog | case 4: |
279 | c3d2689d | balrog | default:
|
280 | c3d2689d | balrog | fputc((v >> 16) & 0xff, f); |
281 | c3d2689d | balrog | fputc((v >> 8) & 0xff, f); |
282 | c3d2689d | balrog | fputc((v) & 0xff, f);
|
283 | c3d2689d | balrog | break;
|
284 | c3d2689d | balrog | } |
285 | c3d2689d | balrog | d += bpp; |
286 | c3d2689d | balrog | } |
287 | c3d2689d | balrog | d1 += linesize; |
288 | c3d2689d | balrog | } |
289 | c3d2689d | balrog | fclose(f); |
290 | c3d2689d | balrog | return 0; |
291 | c3d2689d | balrog | } |
292 | c3d2689d | balrog | |
293 | 9596ebb7 | pbrook | static void omap_screen_dump(void *opaque, const char *filename) { |
294 | c3d2689d | balrog | struct omap_lcd_panel_s *omap_lcd = opaque;
|
295 | c3d2689d | balrog | omap_update_display(opaque); |
296 | c3d2689d | balrog | if (omap_lcd && omap_lcd->state->data)
|
297 | c3d2689d | balrog | ppm_save(filename, omap_lcd->state->data, |
298 | c3d2689d | balrog | omap_lcd->width, omap_lcd->height, |
299 | c3d2689d | balrog | omap_lcd->state->linesize); |
300 | c3d2689d | balrog | } |
301 | c3d2689d | balrog | |
302 | 9596ebb7 | pbrook | static void omap_invalidate_display(void *opaque) { |
303 | c3d2689d | balrog | struct omap_lcd_panel_s *omap_lcd = opaque;
|
304 | c3d2689d | balrog | omap_lcd->invalidate = 1;
|
305 | c3d2689d | balrog | } |
306 | c3d2689d | balrog | |
307 | 9596ebb7 | pbrook | static void omap_lcd_update(struct omap_lcd_panel_s *s) { |
308 | c3d2689d | balrog | if (!s->enable) {
|
309 | c3d2689d | balrog | s->dma->current_frame = -1;
|
310 | c3d2689d | balrog | s->sync_error = 0;
|
311 | c3d2689d | balrog | if (s->plm != 1) |
312 | c3d2689d | balrog | s->frame_done = 1;
|
313 | c3d2689d | balrog | omap_lcd_interrupts(s); |
314 | c3d2689d | balrog | return;
|
315 | c3d2689d | balrog | } |
316 | c3d2689d | balrog | |
317 | c3d2689d | balrog | if (s->dma->current_frame == -1) { |
318 | c3d2689d | balrog | s->frame_done = 0;
|
319 | c3d2689d | balrog | s->palette_done = 0;
|
320 | c3d2689d | balrog | s->dma->current_frame = 0;
|
321 | c3d2689d | balrog | } |
322 | c3d2689d | balrog | |
323 | c3d2689d | balrog | if (!s->dma->mpu->port[s->dma->src].addr_valid(s->dma->mpu,
|
324 | c3d2689d | balrog | s->dma->src_f1_top) || |
325 | c3d2689d | balrog | !s->dma->mpu->port[ |
326 | c3d2689d | balrog | s->dma->src].addr_valid(s->dma->mpu, |
327 | c3d2689d | balrog | s->dma->src_f1_bottom) || |
328 | c3d2689d | balrog | (s->dma->dual && |
329 | c3d2689d | balrog | (!s->dma->mpu->port[ |
330 | c3d2689d | balrog | s->dma->src].addr_valid(s->dma->mpu, |
331 | c3d2689d | balrog | s->dma->src_f2_top) || |
332 | c3d2689d | balrog | !s->dma->mpu->port[ |
333 | c3d2689d | balrog | s->dma->src].addr_valid(s->dma->mpu, |
334 | c3d2689d | balrog | s->dma->src_f2_bottom)))) { |
335 | c3d2689d | balrog | s->dma->condition |= 1 << 2; |
336 | c3d2689d | balrog | if (s->dma->interrupts & (1 << 1)) |
337 | c3d2689d | balrog | qemu_irq_raise(s->dma->irq); |
338 | c3d2689d | balrog | s->enable = 0;
|
339 | c3d2689d | balrog | return;
|
340 | c3d2689d | balrog | } |
341 | c3d2689d | balrog | |
342 | c3d2689d | balrog | if (s->dma->src == imif) {
|
343 | c3d2689d | balrog | /* Framebuffers are in SRAM */
|
344 | c3d2689d | balrog | s->dma->phys_framebuffer[0] = s->imif_base +
|
345 | c3d2689d | balrog | s->dma->src_f1_top - OMAP_IMIF_BASE; |
346 | c3d2689d | balrog | |
347 | c3d2689d | balrog | s->dma->phys_framebuffer[1] = s->imif_base +
|
348 | c3d2689d | balrog | s->dma->src_f2_top - OMAP_IMIF_BASE; |
349 | c3d2689d | balrog | } else {
|
350 | c3d2689d | balrog | /* Framebuffers are in RAM */
|
351 | c3d2689d | balrog | s->dma->phys_framebuffer[0] = s->emiff_base +
|
352 | c3d2689d | balrog | s->dma->src_f1_top - OMAP_EMIFF_BASE; |
353 | c3d2689d | balrog | |
354 | c3d2689d | balrog | s->dma->phys_framebuffer[1] = s->emiff_base +
|
355 | c3d2689d | balrog | s->dma->src_f2_top - OMAP_EMIFF_BASE; |
356 | c3d2689d | balrog | } |
357 | c3d2689d | balrog | |
358 | c3d2689d | balrog | if (s->plm != 2 && !s->palette_done) { |
359 | c3d2689d | balrog | memcpy(s->palette, phys_ram_base + |
360 | c3d2689d | balrog | s->dma->phys_framebuffer[s->dma->current_frame], 0x200);
|
361 | c3d2689d | balrog | s->palette_done = 1;
|
362 | c3d2689d | balrog | omap_lcd_interrupts(s); |
363 | c3d2689d | balrog | } |
364 | c3d2689d | balrog | } |
365 | c3d2689d | balrog | |
366 | c3d2689d | balrog | static uint32_t omap_lcdc_read(void *opaque, target_phys_addr_t addr) |
367 | c3d2689d | balrog | { |
368 | c3d2689d | balrog | struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) opaque; |
369 | c3d2689d | balrog | int offset = addr - s->base;
|
370 | c3d2689d | balrog | |
371 | c3d2689d | balrog | switch (offset) {
|
372 | c3d2689d | balrog | case 0x00: /* LCD_CONTROL */ |
373 | c3d2689d | balrog | return (s->tft << 23) | (s->plm << 20) | |
374 | c3d2689d | balrog | (s->tft << 7) | (s->interrupts << 3) | |
375 | c3d2689d | balrog | (s->mono << 1) | s->enable | s->ctrl | 0xfe000c34; |
376 | c3d2689d | balrog | |
377 | c3d2689d | balrog | case 0x04: /* LCD_TIMING0 */ |
378 | c3d2689d | balrog | return (s->timing[0] << 10) | (s->width - 1) | 0x0000000f; |
379 | c3d2689d | balrog | |
380 | c3d2689d | balrog | case 0x08: /* LCD_TIMING1 */ |
381 | c3d2689d | balrog | return (s->timing[1] << 10) | (s->height - 1); |
382 | c3d2689d | balrog | |
383 | c3d2689d | balrog | case 0x0c: /* LCD_TIMING2 */ |
384 | c3d2689d | balrog | return s->timing[2] | 0xfc000000; |
385 | c3d2689d | balrog | |
386 | c3d2689d | balrog | case 0x10: /* LCD_STATUS */ |
387 | c3d2689d | balrog | return (s->palette_done << 6) | (s->sync_error << 2) | s->frame_done; |
388 | c3d2689d | balrog | |
389 | c3d2689d | balrog | case 0x14: /* LCD_SUBPANEL */ |
390 | c3d2689d | balrog | return s->subpanel;
|
391 | c3d2689d | balrog | |
392 | c3d2689d | balrog | default:
|
393 | c3d2689d | balrog | break;
|
394 | c3d2689d | balrog | } |
395 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
396 | c3d2689d | balrog | return 0; |
397 | c3d2689d | balrog | } |
398 | c3d2689d | balrog | |
399 | c3d2689d | balrog | static void omap_lcdc_write(void *opaque, target_phys_addr_t addr, |
400 | c3d2689d | balrog | uint32_t value) |
401 | c3d2689d | balrog | { |
402 | c3d2689d | balrog | struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) opaque; |
403 | c3d2689d | balrog | int offset = addr - s->base;
|
404 | c3d2689d | balrog | |
405 | c3d2689d | balrog | switch (offset) {
|
406 | c3d2689d | balrog | case 0x00: /* LCD_CONTROL */ |
407 | c3d2689d | balrog | s->plm = (value >> 20) & 3; |
408 | c3d2689d | balrog | s->tft = (value >> 7) & 1; |
409 | c3d2689d | balrog | s->interrupts = (value >> 3) & 3; |
410 | c3d2689d | balrog | s->mono = (value >> 1) & 1; |
411 | c3d2689d | balrog | s->ctrl = value & 0x01cff300;
|
412 | c3d2689d | balrog | if (s->enable != (value & 1)) { |
413 | c3d2689d | balrog | s->enable = value & 1;
|
414 | c3d2689d | balrog | omap_lcd_update(s); |
415 | c3d2689d | balrog | } |
416 | c3d2689d | balrog | break;
|
417 | c3d2689d | balrog | |
418 | c3d2689d | balrog | case 0x04: /* LCD_TIMING0 */ |
419 | c3d2689d | balrog | s->timing[0] = value >> 10; |
420 | c3d2689d | balrog | s->width = (value & 0x3ff) + 1; |
421 | c3d2689d | balrog | break;
|
422 | c3d2689d | balrog | |
423 | c3d2689d | balrog | case 0x08: /* LCD_TIMING1 */ |
424 | c3d2689d | balrog | s->timing[1] = value >> 10; |
425 | c3d2689d | balrog | s->height = (value & 0x3ff) + 1; |
426 | c3d2689d | balrog | break;
|
427 | c3d2689d | balrog | |
428 | c3d2689d | balrog | case 0x0c: /* LCD_TIMING2 */ |
429 | c3d2689d | balrog | s->timing[2] = value;
|
430 | c3d2689d | balrog | break;
|
431 | c3d2689d | balrog | |
432 | c3d2689d | balrog | case 0x10: /* LCD_STATUS */ |
433 | c3d2689d | balrog | break;
|
434 | c3d2689d | balrog | |
435 | c3d2689d | balrog | case 0x14: /* LCD_SUBPANEL */ |
436 | c3d2689d | balrog | s->subpanel = value & 0xa1ffffff;
|
437 | c3d2689d | balrog | break;
|
438 | c3d2689d | balrog | |
439 | c3d2689d | balrog | default:
|
440 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
441 | c3d2689d | balrog | } |
442 | c3d2689d | balrog | } |
443 | c3d2689d | balrog | |
444 | c3d2689d | balrog | static CPUReadMemoryFunc *omap_lcdc_readfn[] = {
|
445 | c3d2689d | balrog | omap_lcdc_read, |
446 | c3d2689d | balrog | omap_lcdc_read, |
447 | c3d2689d | balrog | omap_lcdc_read, |
448 | c3d2689d | balrog | }; |
449 | c3d2689d | balrog | |
450 | c3d2689d | balrog | static CPUWriteMemoryFunc *omap_lcdc_writefn[] = {
|
451 | c3d2689d | balrog | omap_lcdc_write, |
452 | c3d2689d | balrog | omap_lcdc_write, |
453 | c3d2689d | balrog | omap_lcdc_write, |
454 | c3d2689d | balrog | }; |
455 | c3d2689d | balrog | |
456 | c3d2689d | balrog | void omap_lcdc_reset(struct omap_lcd_panel_s *s) |
457 | c3d2689d | balrog | { |
458 | c3d2689d | balrog | s->dma->current_frame = -1;
|
459 | c3d2689d | balrog | s->plm = 0;
|
460 | c3d2689d | balrog | s->tft = 0;
|
461 | c3d2689d | balrog | s->mono = 0;
|
462 | c3d2689d | balrog | s->enable = 0;
|
463 | c3d2689d | balrog | s->width = 0;
|
464 | c3d2689d | balrog | s->height = 0;
|
465 | c3d2689d | balrog | s->interrupts = 0;
|
466 | c3d2689d | balrog | s->timing[0] = 0; |
467 | c3d2689d | balrog | s->timing[1] = 0; |
468 | c3d2689d | balrog | s->timing[2] = 0; |
469 | c3d2689d | balrog | s->subpanel = 0;
|
470 | c3d2689d | balrog | s->palette_done = 0;
|
471 | c3d2689d | balrog | s->frame_done = 0;
|
472 | c3d2689d | balrog | s->sync_error = 0;
|
473 | c3d2689d | balrog | s->invalidate = 1;
|
474 | c3d2689d | balrog | s->subpanel = 0;
|
475 | c3d2689d | balrog | s->ctrl = 0;
|
476 | c3d2689d | balrog | } |
477 | c3d2689d | balrog | |
478 | c3d2689d | balrog | struct omap_lcd_panel_s *omap_lcdc_init(target_phys_addr_t base, qemu_irq irq,
|
479 | c3d2689d | balrog | struct omap_dma_lcd_channel_s *dma, DisplayState *ds,
|
480 | c3d2689d | balrog | ram_addr_t imif_base, ram_addr_t emiff_base, omap_clk clk) |
481 | c3d2689d | balrog | { |
482 | c3d2689d | balrog | int iomemtype;
|
483 | c3d2689d | balrog | struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) |
484 | c3d2689d | balrog | qemu_mallocz(sizeof(struct omap_lcd_panel_s)); |
485 | c3d2689d | balrog | |
486 | c3d2689d | balrog | s->irq = irq; |
487 | c3d2689d | balrog | s->dma = dma; |
488 | c3d2689d | balrog | s->base = base; |
489 | c3d2689d | balrog | s->state = ds; |
490 | c3d2689d | balrog | s->imif_base = imif_base; |
491 | c3d2689d | balrog | s->emiff_base = emiff_base; |
492 | c3d2689d | balrog | omap_lcdc_reset(s); |
493 | c3d2689d | balrog | |
494 | c3d2689d | balrog | iomemtype = cpu_register_io_memory(0, omap_lcdc_readfn,
|
495 | c3d2689d | balrog | omap_lcdc_writefn, s); |
496 | c3d2689d | balrog | cpu_register_physical_memory(s->base, 0x100, iomemtype);
|
497 | c3d2689d | balrog | |
498 | c60e08d9 | pbrook | s->console = graphic_console_init(ds, omap_update_display, |
499 | c60e08d9 | pbrook | omap_invalidate_display, |
500 | c60e08d9 | pbrook | omap_screen_dump, NULL, s);
|
501 | c3d2689d | balrog | |
502 | c3d2689d | balrog | return s;
|
503 | c3d2689d | balrog | } |