root / hw / omap_lcdc.c @ b13ce26d
History | View | Annotate | Download (13.4 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 | fad6cb1a | aurel32 | * You should have received a copy of the GNU General Public License along
|
17 | 8167ee88 | Blue Swirl | * with this program; if not, see <http://www.gnu.org/licenses/>.
|
18 | c3d2689d | balrog | */
|
19 | 87ecb68b | pbrook | #include "hw.h" |
20 | 87ecb68b | pbrook | #include "console.h" |
21 | 87ecb68b | pbrook | #include "omap.h" |
22 | 714fa308 | pbrook | #include "framebuffer.h" |
23 | c3d2689d | balrog | |
24 | c3d2689d | balrog | struct omap_lcd_panel_s {
|
25 | 75c9d6c2 | Avi Kivity | MemoryRegion *sysmem; |
26 | 30af1ec7 | Benoît Canet | MemoryRegion iomem; |
27 | c3d2689d | balrog | qemu_irq irq; |
28 | c3d2689d | balrog | DisplayState *state; |
29 | c3d2689d | balrog | |
30 | c3d2689d | balrog | int plm;
|
31 | c3d2689d | balrog | int tft;
|
32 | c3d2689d | balrog | int mono;
|
33 | c3d2689d | balrog | int enable;
|
34 | c3d2689d | balrog | int width;
|
35 | c3d2689d | balrog | int height;
|
36 | c3d2689d | balrog | int interrupts;
|
37 | c3d2689d | balrog | uint32_t timing[3];
|
38 | c3d2689d | balrog | uint32_t subpanel; |
39 | c3d2689d | balrog | uint32_t ctrl; |
40 | c3d2689d | balrog | |
41 | c3d2689d | balrog | struct omap_dma_lcd_channel_s *dma;
|
42 | c3d2689d | balrog | uint16_t palette[256];
|
43 | c3d2689d | balrog | int palette_done;
|
44 | c3d2689d | balrog | int frame_done;
|
45 | c3d2689d | balrog | int invalidate;
|
46 | c3d2689d | balrog | int sync_error;
|
47 | c3d2689d | balrog | }; |
48 | c3d2689d | balrog | |
49 | c3d2689d | balrog | static void omap_lcd_interrupts(struct omap_lcd_panel_s *s) |
50 | c3d2689d | balrog | { |
51 | c3d2689d | balrog | if (s->frame_done && (s->interrupts & 1)) { |
52 | c3d2689d | balrog | qemu_irq_raise(s->irq); |
53 | c3d2689d | balrog | return;
|
54 | c3d2689d | balrog | } |
55 | c3d2689d | balrog | |
56 | c3d2689d | balrog | if (s->palette_done && (s->interrupts & 2)) { |
57 | c3d2689d | balrog | qemu_irq_raise(s->irq); |
58 | c3d2689d | balrog | return;
|
59 | c3d2689d | balrog | } |
60 | c3d2689d | balrog | |
61 | c3d2689d | balrog | if (s->sync_error) {
|
62 | c3d2689d | balrog | qemu_irq_raise(s->irq); |
63 | c3d2689d | balrog | return;
|
64 | c3d2689d | balrog | } |
65 | c3d2689d | balrog | |
66 | c3d2689d | balrog | qemu_irq_lower(s->irq); |
67 | c3d2689d | balrog | } |
68 | c3d2689d | balrog | |
69 | c3d2689d | balrog | #include "pixel_ops.h" |
70 | c3d2689d | balrog | |
71 | 714fa308 | pbrook | #define draw_line_func drawfn
|
72 | c3d2689d | balrog | |
73 | c3d2689d | balrog | #define DEPTH 8 |
74 | c3d2689d | balrog | #include "omap_lcd_template.h" |
75 | c3d2689d | balrog | #define DEPTH 15 |
76 | c3d2689d | balrog | #include "omap_lcd_template.h" |
77 | c3d2689d | balrog | #define DEPTH 16 |
78 | c3d2689d | balrog | #include "omap_lcd_template.h" |
79 | c3d2689d | balrog | #define DEPTH 32 |
80 | c3d2689d | balrog | #include "omap_lcd_template.h" |
81 | c3d2689d | balrog | |
82 | 714fa308 | pbrook | static draw_line_func draw_line_table2[33] = { |
83 | b9d38e95 | Blue Swirl | [0 ... 32] = NULL, |
84 | c3d2689d | balrog | [8] = draw_line2_8,
|
85 | c3d2689d | balrog | [15] = draw_line2_15,
|
86 | c3d2689d | balrog | [16] = draw_line2_16,
|
87 | c3d2689d | balrog | [32] = draw_line2_32,
|
88 | 714fa308 | pbrook | }, draw_line_table4[33] = {
|
89 | b9d38e95 | Blue Swirl | [0 ... 32] = NULL, |
90 | c3d2689d | balrog | [8] = draw_line4_8,
|
91 | c3d2689d | balrog | [15] = draw_line4_15,
|
92 | c3d2689d | balrog | [16] = draw_line4_16,
|
93 | c3d2689d | balrog | [32] = draw_line4_32,
|
94 | 714fa308 | pbrook | }, draw_line_table8[33] = {
|
95 | b9d38e95 | Blue Swirl | [0 ... 32] = NULL, |
96 | c3d2689d | balrog | [8] = draw_line8_8,
|
97 | c3d2689d | balrog | [15] = draw_line8_15,
|
98 | c3d2689d | balrog | [16] = draw_line8_16,
|
99 | c3d2689d | balrog | [32] = draw_line8_32,
|
100 | 714fa308 | pbrook | }, draw_line_table12[33] = {
|
101 | b9d38e95 | Blue Swirl | [0 ... 32] = NULL, |
102 | c3d2689d | balrog | [8] = draw_line12_8,
|
103 | c3d2689d | balrog | [15] = draw_line12_15,
|
104 | c3d2689d | balrog | [16] = draw_line12_16,
|
105 | c3d2689d | balrog | [32] = draw_line12_32,
|
106 | 714fa308 | pbrook | }, draw_line_table16[33] = {
|
107 | b9d38e95 | Blue Swirl | [0 ... 32] = NULL, |
108 | c3d2689d | balrog | [8] = draw_line16_8,
|
109 | c3d2689d | balrog | [15] = draw_line16_15,
|
110 | c3d2689d | balrog | [16] = draw_line16_16,
|
111 | c3d2689d | balrog | [32] = draw_line16_32,
|
112 | c3d2689d | balrog | }; |
113 | c3d2689d | balrog | |
114 | 9596ebb7 | pbrook | static void omap_update_display(void *opaque) |
115 | c3d2689d | balrog | { |
116 | c3d2689d | balrog | struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque; |
117 | 714fa308 | pbrook | draw_line_func draw_line; |
118 | 714fa308 | pbrook | int size, height, first, last;
|
119 | 714fa308 | pbrook | int width, linesize, step, bpp, frame_offset;
|
120 | a8170e5e | Avi Kivity | hwaddr frame_base; |
121 | c3d2689d | balrog | |
122 | c3d2689d | balrog | if (!omap_lcd || omap_lcd->plm == 1 || |
123 | 0e1f5a0c | aliguori | !omap_lcd->enable || !ds_get_bits_per_pixel(omap_lcd->state)) |
124 | c3d2689d | balrog | return;
|
125 | c3d2689d | balrog | |
126 | c3d2689d | balrog | frame_offset = 0;
|
127 | c3d2689d | balrog | if (omap_lcd->plm != 2) { |
128 | 714fa308 | pbrook | cpu_physical_memory_read(omap_lcd->dma->phys_framebuffer[ |
129 | 714fa308 | pbrook | omap_lcd->dma->current_frame], |
130 | 714fa308 | pbrook | (void *)omap_lcd->palette, 0x200); |
131 | c3d2689d | balrog | switch (omap_lcd->palette[0] >> 12 & 7) { |
132 | c3d2689d | balrog | case 3 ... 7: |
133 | c3d2689d | balrog | frame_offset += 0x200;
|
134 | c3d2689d | balrog | break;
|
135 | c3d2689d | balrog | default:
|
136 | c3d2689d | balrog | frame_offset += 0x20;
|
137 | c3d2689d | balrog | } |
138 | c3d2689d | balrog | } |
139 | c3d2689d | balrog | |
140 | c3d2689d | balrog | /* Colour depth */
|
141 | c3d2689d | balrog | switch ((omap_lcd->palette[0] >> 12) & 7) { |
142 | c3d2689d | balrog | case 1: |
143 | 0e1f5a0c | aliguori | draw_line = draw_line_table2[ds_get_bits_per_pixel(omap_lcd->state)]; |
144 | c3d2689d | balrog | bpp = 2;
|
145 | c3d2689d | balrog | break;
|
146 | c3d2689d | balrog | |
147 | c3d2689d | balrog | case 2: |
148 | 0e1f5a0c | aliguori | draw_line = draw_line_table4[ds_get_bits_per_pixel(omap_lcd->state)]; |
149 | c3d2689d | balrog | bpp = 4;
|
150 | c3d2689d | balrog | break;
|
151 | c3d2689d | balrog | |
152 | c3d2689d | balrog | case 3: |
153 | 0e1f5a0c | aliguori | draw_line = draw_line_table8[ds_get_bits_per_pixel(omap_lcd->state)]; |
154 | c3d2689d | balrog | bpp = 8;
|
155 | c3d2689d | balrog | break;
|
156 | c3d2689d | balrog | |
157 | c3d2689d | balrog | case 4 ... 7: |
158 | c3d2689d | balrog | if (!omap_lcd->tft)
|
159 | 0e1f5a0c | aliguori | draw_line = draw_line_table12[ds_get_bits_per_pixel(omap_lcd->state)]; |
160 | c3d2689d | balrog | else
|
161 | 0e1f5a0c | aliguori | draw_line = draw_line_table16[ds_get_bits_per_pixel(omap_lcd->state)]; |
162 | c3d2689d | balrog | bpp = 16;
|
163 | c3d2689d | balrog | break;
|
164 | c3d2689d | balrog | |
165 | c3d2689d | balrog | default:
|
166 | c3d2689d | balrog | /* Unsupported at the moment. */
|
167 | c3d2689d | balrog | return;
|
168 | c3d2689d | balrog | } |
169 | c3d2689d | balrog | |
170 | c3d2689d | balrog | /* Resolution */
|
171 | c3d2689d | balrog | width = omap_lcd->width; |
172 | 0e1f5a0c | aliguori | if (width != ds_get_width(omap_lcd->state) ||
|
173 | 0e1f5a0c | aliguori | omap_lcd->height != ds_get_height(omap_lcd->state)) { |
174 | 3023f332 | aliguori | qemu_console_resize(omap_lcd->state, |
175 | c60e08d9 | pbrook | omap_lcd->width, omap_lcd->height); |
176 | c3d2689d | balrog | omap_lcd->invalidate = 1;
|
177 | c3d2689d | balrog | } |
178 | c3d2689d | balrog | |
179 | c3d2689d | balrog | if (omap_lcd->dma->current_frame == 0) |
180 | c3d2689d | balrog | size = omap_lcd->dma->src_f1_bottom - omap_lcd->dma->src_f1_top; |
181 | c3d2689d | balrog | else
|
182 | c3d2689d | balrog | size = omap_lcd->dma->src_f2_bottom - omap_lcd->dma->src_f2_top; |
183 | c3d2689d | balrog | |
184 | c3d2689d | balrog | if (frame_offset + ((width * omap_lcd->height * bpp) >> 3) > size + 2) { |
185 | c3d2689d | balrog | omap_lcd->sync_error = 1;
|
186 | c3d2689d | balrog | omap_lcd_interrupts(omap_lcd); |
187 | c3d2689d | balrog | omap_lcd->enable = 0;
|
188 | c3d2689d | balrog | return;
|
189 | c3d2689d | balrog | } |
190 | c3d2689d | balrog | |
191 | c3d2689d | balrog | /* Content */
|
192 | c3d2689d | balrog | frame_base = omap_lcd->dma->phys_framebuffer[ |
193 | c3d2689d | balrog | omap_lcd->dma->current_frame] + frame_offset; |
194 | c3d2689d | balrog | omap_lcd->dma->condition |= 1 << omap_lcd->dma->current_frame;
|
195 | c3d2689d | balrog | if (omap_lcd->dma->interrupts & 1) |
196 | c3d2689d | balrog | qemu_irq_raise(omap_lcd->dma->irq); |
197 | c3d2689d | balrog | if (omap_lcd->dma->dual)
|
198 | c3d2689d | balrog | omap_lcd->dma->current_frame ^= 1;
|
199 | c3d2689d | balrog | |
200 | 0e1f5a0c | aliguori | if (!ds_get_bits_per_pixel(omap_lcd->state))
|
201 | c3d2689d | balrog | return;
|
202 | c3d2689d | balrog | |
203 | 714fa308 | pbrook | first = 0;
|
204 | c3d2689d | balrog | height = omap_lcd->height; |
205 | c3d2689d | balrog | if (omap_lcd->subpanel & (1 << 31)) { |
206 | c3d2689d | balrog | if (omap_lcd->subpanel & (1 << 29)) |
207 | 714fa308 | pbrook | first = (omap_lcd->subpanel >> 16) & 0x3ff; |
208 | c3d2689d | balrog | else
|
209 | c3d2689d | balrog | height = (omap_lcd->subpanel >> 16) & 0x3ff; |
210 | c3d2689d | balrog | /* TODO: fill the rest of the panel with DPD */
|
211 | c3d2689d | balrog | } |
212 | 714fa308 | pbrook | |
213 | c3d2689d | balrog | step = width * bpp >> 3;
|
214 | 0e1f5a0c | aliguori | linesize = ds_get_linesize(omap_lcd->state); |
215 | 75c9d6c2 | Avi Kivity | framebuffer_update_display(omap_lcd->state, omap_lcd->sysmem, |
216 | 714fa308 | pbrook | frame_base, width, height, |
217 | 714fa308 | pbrook | step, linesize, 0,
|
218 | 714fa308 | pbrook | omap_lcd->invalidate, |
219 | 714fa308 | pbrook | draw_line, omap_lcd->palette, |
220 | 714fa308 | pbrook | &first, &last); |
221 | 714fa308 | pbrook | if (first >= 0) { |
222 | 714fa308 | pbrook | dpy_update(omap_lcd->state, 0, first, width, last - first + 1); |
223 | c3d2689d | balrog | } |
224 | 714fa308 | pbrook | omap_lcd->invalidate = 0;
|
225 | c3d2689d | balrog | } |
226 | c3d2689d | balrog | |
227 | d9c7ebb1 | Luiz Capitulino | static void omap_ppm_save(const char *filename, uint8_t *data, |
228 | d9c7ebb1 | Luiz Capitulino | int w, int h, int linesize, Error **errp) |
229 | c3d2689d | balrog | { |
230 | c3d2689d | balrog | FILE *f; |
231 | c3d2689d | balrog | uint8_t *d, *d1; |
232 | c3d2689d | balrog | unsigned int v; |
233 | d9c7ebb1 | Luiz Capitulino | int ret, y, x, bpp;
|
234 | c3d2689d | balrog | |
235 | c3d2689d | balrog | f = fopen(filename, "wb");
|
236 | d9c7ebb1 | Luiz Capitulino | if (!f) {
|
237 | d9c7ebb1 | Luiz Capitulino | error_setg(errp, "failed to open file '%s': %s", filename,
|
238 | d9c7ebb1 | Luiz Capitulino | strerror(errno)); |
239 | d9c7ebb1 | Luiz Capitulino | return;
|
240 | d9c7ebb1 | Luiz Capitulino | } |
241 | d9c7ebb1 | Luiz Capitulino | ret = fprintf(f, "P6\n%d %d\n%d\n", w, h, 255); |
242 | d9c7ebb1 | Luiz Capitulino | if (ret < 0) { |
243 | d9c7ebb1 | Luiz Capitulino | goto write_err;
|
244 | d9c7ebb1 | Luiz Capitulino | } |
245 | c3d2689d | balrog | d1 = data; |
246 | c3d2689d | balrog | bpp = linesize / w; |
247 | c3d2689d | balrog | for (y = 0; y < h; y ++) { |
248 | c3d2689d | balrog | d = d1; |
249 | c3d2689d | balrog | for (x = 0; x < w; x ++) { |
250 | c3d2689d | balrog | v = *(uint32_t *) d; |
251 | c3d2689d | balrog | switch (bpp) {
|
252 | c3d2689d | balrog | case 2: |
253 | d9c7ebb1 | Luiz Capitulino | ret = fputc((v >> 8) & 0xf8, f); |
254 | d9c7ebb1 | Luiz Capitulino | if (ret == EOF) { |
255 | d9c7ebb1 | Luiz Capitulino | goto write_err;
|
256 | d9c7ebb1 | Luiz Capitulino | } |
257 | d9c7ebb1 | Luiz Capitulino | ret = fputc((v >> 3) & 0xfc, f); |
258 | d9c7ebb1 | Luiz Capitulino | if (ret == EOF) { |
259 | d9c7ebb1 | Luiz Capitulino | goto write_err;
|
260 | d9c7ebb1 | Luiz Capitulino | } |
261 | d9c7ebb1 | Luiz Capitulino | ret = fputc((v << 3) & 0xf8, f); |
262 | d9c7ebb1 | Luiz Capitulino | if (ret == EOF) { |
263 | d9c7ebb1 | Luiz Capitulino | goto write_err;
|
264 | d9c7ebb1 | Luiz Capitulino | } |
265 | c3d2689d | balrog | break;
|
266 | c3d2689d | balrog | case 3: |
267 | c3d2689d | balrog | case 4: |
268 | c3d2689d | balrog | default:
|
269 | d9c7ebb1 | Luiz Capitulino | ret = fputc((v >> 16) & 0xff, f); |
270 | d9c7ebb1 | Luiz Capitulino | if (ret == EOF) { |
271 | d9c7ebb1 | Luiz Capitulino | goto write_err;
|
272 | d9c7ebb1 | Luiz Capitulino | } |
273 | d9c7ebb1 | Luiz Capitulino | ret = fputc((v >> 8) & 0xff, f); |
274 | d9c7ebb1 | Luiz Capitulino | if (ret == EOF) { |
275 | d9c7ebb1 | Luiz Capitulino | goto write_err;
|
276 | d9c7ebb1 | Luiz Capitulino | } |
277 | d9c7ebb1 | Luiz Capitulino | ret = fputc((v) & 0xff, f);
|
278 | d9c7ebb1 | Luiz Capitulino | if (ret == EOF) { |
279 | d9c7ebb1 | Luiz Capitulino | goto write_err;
|
280 | d9c7ebb1 | Luiz Capitulino | } |
281 | c3d2689d | balrog | break;
|
282 | c3d2689d | balrog | } |
283 | c3d2689d | balrog | d += bpp; |
284 | c3d2689d | balrog | } |
285 | c3d2689d | balrog | d1 += linesize; |
286 | c3d2689d | balrog | } |
287 | d9c7ebb1 | Luiz Capitulino | out:
|
288 | c3d2689d | balrog | fclose(f); |
289 | d9c7ebb1 | Luiz Capitulino | return;
|
290 | d9c7ebb1 | Luiz Capitulino | |
291 | d9c7ebb1 | Luiz Capitulino | write_err:
|
292 | d9c7ebb1 | Luiz Capitulino | error_setg(errp, "failed to write to file '%s': %s", filename,
|
293 | d9c7ebb1 | Luiz Capitulino | strerror(errno)); |
294 | d9c7ebb1 | Luiz Capitulino | unlink(filename); |
295 | d9c7ebb1 | Luiz Capitulino | goto out;
|
296 | c3d2689d | balrog | } |
297 | c3d2689d | balrog | |
298 | d7098135 | Luiz Capitulino | static void omap_screen_dump(void *opaque, const char *filename, bool cswitch, |
299 | d7098135 | Luiz Capitulino | Error **errp) |
300 | 45efb161 | Gerd Hoffmann | { |
301 | c3d2689d | balrog | struct omap_lcd_panel_s *omap_lcd = opaque;
|
302 | 08c4ea29 | Gerd Hoffmann | |
303 | 08c4ea29 | Gerd Hoffmann | omap_update_display(opaque); |
304 | 0e1f5a0c | aliguori | if (omap_lcd && ds_get_data(omap_lcd->state))
|
305 | 8dc4cc7b | Luiz Capitulino | omap_ppm_save(filename, ds_get_data(omap_lcd->state), |
306 | 8dc4cc7b | Luiz Capitulino | omap_lcd->width, omap_lcd->height, |
307 | d9c7ebb1 | Luiz Capitulino | ds_get_linesize(omap_lcd->state), errp); |
308 | c3d2689d | balrog | } |
309 | c3d2689d | balrog | |
310 | 9596ebb7 | pbrook | static void omap_invalidate_display(void *opaque) { |
311 | c3d2689d | balrog | struct omap_lcd_panel_s *omap_lcd = opaque;
|
312 | c3d2689d | balrog | omap_lcd->invalidate = 1;
|
313 | c3d2689d | balrog | } |
314 | c3d2689d | balrog | |
315 | 9596ebb7 | pbrook | static void omap_lcd_update(struct omap_lcd_panel_s *s) { |
316 | c3d2689d | balrog | if (!s->enable) {
|
317 | c3d2689d | balrog | s->dma->current_frame = -1;
|
318 | c3d2689d | balrog | s->sync_error = 0;
|
319 | c3d2689d | balrog | if (s->plm != 1) |
320 | c3d2689d | balrog | s->frame_done = 1;
|
321 | c3d2689d | balrog | omap_lcd_interrupts(s); |
322 | c3d2689d | balrog | return;
|
323 | c3d2689d | balrog | } |
324 | c3d2689d | balrog | |
325 | c3d2689d | balrog | if (s->dma->current_frame == -1) { |
326 | c3d2689d | balrog | s->frame_done = 0;
|
327 | c3d2689d | balrog | s->palette_done = 0;
|
328 | c3d2689d | balrog | s->dma->current_frame = 0;
|
329 | c3d2689d | balrog | } |
330 | c3d2689d | balrog | |
331 | c3d2689d | balrog | if (!s->dma->mpu->port[s->dma->src].addr_valid(s->dma->mpu,
|
332 | c3d2689d | balrog | s->dma->src_f1_top) || |
333 | c3d2689d | balrog | !s->dma->mpu->port[ |
334 | c3d2689d | balrog | s->dma->src].addr_valid(s->dma->mpu, |
335 | c3d2689d | balrog | s->dma->src_f1_bottom) || |
336 | c3d2689d | balrog | (s->dma->dual && |
337 | c3d2689d | balrog | (!s->dma->mpu->port[ |
338 | c3d2689d | balrog | s->dma->src].addr_valid(s->dma->mpu, |
339 | c3d2689d | balrog | s->dma->src_f2_top) || |
340 | c3d2689d | balrog | !s->dma->mpu->port[ |
341 | c3d2689d | balrog | s->dma->src].addr_valid(s->dma->mpu, |
342 | c3d2689d | balrog | s->dma->src_f2_bottom)))) { |
343 | c3d2689d | balrog | s->dma->condition |= 1 << 2; |
344 | c3d2689d | balrog | if (s->dma->interrupts & (1 << 1)) |
345 | c3d2689d | balrog | qemu_irq_raise(s->dma->irq); |
346 | c3d2689d | balrog | s->enable = 0;
|
347 | c3d2689d | balrog | return;
|
348 | c3d2689d | balrog | } |
349 | c3d2689d | balrog | |
350 | 714fa308 | pbrook | s->dma->phys_framebuffer[0] = s->dma->src_f1_top;
|
351 | 714fa308 | pbrook | s->dma->phys_framebuffer[1] = s->dma->src_f2_top;
|
352 | c3d2689d | balrog | |
353 | c3d2689d | balrog | if (s->plm != 2 && !s->palette_done) { |
354 | 714fa308 | pbrook | cpu_physical_memory_read( |
355 | 714fa308 | pbrook | s->dma->phys_framebuffer[s->dma->current_frame], |
356 | 714fa308 | pbrook | (void *)s->palette, 0x200); |
357 | c3d2689d | balrog | s->palette_done = 1;
|
358 | c3d2689d | balrog | omap_lcd_interrupts(s); |
359 | c3d2689d | balrog | } |
360 | c3d2689d | balrog | } |
361 | c3d2689d | balrog | |
362 | a8170e5e | Avi Kivity | static uint64_t omap_lcdc_read(void *opaque, hwaddr addr, |
363 | 30af1ec7 | Benoît Canet | unsigned size)
|
364 | c3d2689d | balrog | { |
365 | c3d2689d | balrog | struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) opaque; |
366 | c3d2689d | balrog | |
367 | 8da3ff18 | pbrook | switch (addr) {
|
368 | c3d2689d | balrog | case 0x00: /* LCD_CONTROL */ |
369 | c3d2689d | balrog | return (s->tft << 23) | (s->plm << 20) | |
370 | c3d2689d | balrog | (s->tft << 7) | (s->interrupts << 3) | |
371 | c3d2689d | balrog | (s->mono << 1) | s->enable | s->ctrl | 0xfe000c34; |
372 | c3d2689d | balrog | |
373 | c3d2689d | balrog | case 0x04: /* LCD_TIMING0 */ |
374 | c3d2689d | balrog | return (s->timing[0] << 10) | (s->width - 1) | 0x0000000f; |
375 | c3d2689d | balrog | |
376 | c3d2689d | balrog | case 0x08: /* LCD_TIMING1 */ |
377 | c3d2689d | balrog | return (s->timing[1] << 10) | (s->height - 1); |
378 | c3d2689d | balrog | |
379 | c3d2689d | balrog | case 0x0c: /* LCD_TIMING2 */ |
380 | c3d2689d | balrog | return s->timing[2] | 0xfc000000; |
381 | c3d2689d | balrog | |
382 | c3d2689d | balrog | case 0x10: /* LCD_STATUS */ |
383 | c3d2689d | balrog | return (s->palette_done << 6) | (s->sync_error << 2) | s->frame_done; |
384 | c3d2689d | balrog | |
385 | c3d2689d | balrog | case 0x14: /* LCD_SUBPANEL */ |
386 | c3d2689d | balrog | return s->subpanel;
|
387 | c3d2689d | balrog | |
388 | c3d2689d | balrog | default:
|
389 | c3d2689d | balrog | break;
|
390 | c3d2689d | balrog | } |
391 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
392 | c3d2689d | balrog | return 0; |
393 | c3d2689d | balrog | } |
394 | c3d2689d | balrog | |
395 | a8170e5e | Avi Kivity | static void omap_lcdc_write(void *opaque, hwaddr addr, |
396 | 30af1ec7 | Benoît Canet | uint64_t value, unsigned size)
|
397 | c3d2689d | balrog | { |
398 | c3d2689d | balrog | struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) opaque; |
399 | c3d2689d | balrog | |
400 | 8da3ff18 | pbrook | switch (addr) {
|
401 | c3d2689d | balrog | case 0x00: /* LCD_CONTROL */ |
402 | c3d2689d | balrog | s->plm = (value >> 20) & 3; |
403 | c3d2689d | balrog | s->tft = (value >> 7) & 1; |
404 | c3d2689d | balrog | s->interrupts = (value >> 3) & 3; |
405 | c3d2689d | balrog | s->mono = (value >> 1) & 1; |
406 | c3d2689d | balrog | s->ctrl = value & 0x01cff300;
|
407 | c3d2689d | balrog | if (s->enable != (value & 1)) { |
408 | c3d2689d | balrog | s->enable = value & 1;
|
409 | c3d2689d | balrog | omap_lcd_update(s); |
410 | c3d2689d | balrog | } |
411 | c3d2689d | balrog | break;
|
412 | c3d2689d | balrog | |
413 | c3d2689d | balrog | case 0x04: /* LCD_TIMING0 */ |
414 | c3d2689d | balrog | s->timing[0] = value >> 10; |
415 | c3d2689d | balrog | s->width = (value & 0x3ff) + 1; |
416 | c3d2689d | balrog | break;
|
417 | c3d2689d | balrog | |
418 | c3d2689d | balrog | case 0x08: /* LCD_TIMING1 */ |
419 | c3d2689d | balrog | s->timing[1] = value >> 10; |
420 | c3d2689d | balrog | s->height = (value & 0x3ff) + 1; |
421 | c3d2689d | balrog | break;
|
422 | c3d2689d | balrog | |
423 | c3d2689d | balrog | case 0x0c: /* LCD_TIMING2 */ |
424 | c3d2689d | balrog | s->timing[2] = value;
|
425 | c3d2689d | balrog | break;
|
426 | c3d2689d | balrog | |
427 | c3d2689d | balrog | case 0x10: /* LCD_STATUS */ |
428 | c3d2689d | balrog | break;
|
429 | c3d2689d | balrog | |
430 | c3d2689d | balrog | case 0x14: /* LCD_SUBPANEL */ |
431 | c3d2689d | balrog | s->subpanel = value & 0xa1ffffff;
|
432 | c3d2689d | balrog | break;
|
433 | c3d2689d | balrog | |
434 | c3d2689d | balrog | default:
|
435 | c3d2689d | balrog | OMAP_BAD_REG(addr); |
436 | c3d2689d | balrog | } |
437 | c3d2689d | balrog | } |
438 | c3d2689d | balrog | |
439 | 30af1ec7 | Benoît Canet | static const MemoryRegionOps omap_lcdc_ops = { |
440 | 30af1ec7 | Benoît Canet | .read = omap_lcdc_read, |
441 | 30af1ec7 | Benoît Canet | .write = omap_lcdc_write, |
442 | 30af1ec7 | Benoît Canet | .endianness = DEVICE_NATIVE_ENDIAN, |
443 | c3d2689d | balrog | }; |
444 | c3d2689d | balrog | |
445 | c3d2689d | balrog | void omap_lcdc_reset(struct omap_lcd_panel_s *s) |
446 | c3d2689d | balrog | { |
447 | c3d2689d | balrog | s->dma->current_frame = -1;
|
448 | c3d2689d | balrog | s->plm = 0;
|
449 | c3d2689d | balrog | s->tft = 0;
|
450 | c3d2689d | balrog | s->mono = 0;
|
451 | c3d2689d | balrog | s->enable = 0;
|
452 | c3d2689d | balrog | s->width = 0;
|
453 | c3d2689d | balrog | s->height = 0;
|
454 | c3d2689d | balrog | s->interrupts = 0;
|
455 | c3d2689d | balrog | s->timing[0] = 0; |
456 | c3d2689d | balrog | s->timing[1] = 0; |
457 | c3d2689d | balrog | s->timing[2] = 0; |
458 | c3d2689d | balrog | s->subpanel = 0;
|
459 | c3d2689d | balrog | s->palette_done = 0;
|
460 | c3d2689d | balrog | s->frame_done = 0;
|
461 | c3d2689d | balrog | s->sync_error = 0;
|
462 | c3d2689d | balrog | s->invalidate = 1;
|
463 | c3d2689d | balrog | s->subpanel = 0;
|
464 | c3d2689d | balrog | s->ctrl = 0;
|
465 | c3d2689d | balrog | } |
466 | c3d2689d | balrog | |
467 | 30af1ec7 | Benoît Canet | struct omap_lcd_panel_s *omap_lcdc_init(MemoryRegion *sysmem,
|
468 | a8170e5e | Avi Kivity | hwaddr base, |
469 | 30af1ec7 | Benoît Canet | qemu_irq irq, |
470 | 30af1ec7 | Benoît Canet | struct omap_dma_lcd_channel_s *dma,
|
471 | 30af1ec7 | Benoît Canet | omap_clk clk) |
472 | c3d2689d | balrog | { |
473 | c3d2689d | balrog | struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) |
474 | 7267c094 | Anthony Liguori | g_malloc0(sizeof(struct omap_lcd_panel_s)); |
475 | c3d2689d | balrog | |
476 | c3d2689d | balrog | s->irq = irq; |
477 | c3d2689d | balrog | s->dma = dma; |
478 | 75c9d6c2 | Avi Kivity | s->sysmem = sysmem; |
479 | c3d2689d | balrog | omap_lcdc_reset(s); |
480 | c3d2689d | balrog | |
481 | 30af1ec7 | Benoît Canet | memory_region_init_io(&s->iomem, &omap_lcdc_ops, s, "omap.lcdc", 0x100); |
482 | 30af1ec7 | Benoît Canet | memory_region_add_subregion(sysmem, base, &s->iomem); |
483 | c3d2689d | balrog | |
484 | 3023f332 | aliguori | s->state = graphic_console_init(omap_update_display, |
485 | 3023f332 | aliguori | omap_invalidate_display, |
486 | 3023f332 | aliguori | omap_screen_dump, NULL, s);
|
487 | c3d2689d | balrog | |
488 | c3d2689d | balrog | return s;
|
489 | c3d2689d | balrog | } |