2 * OMAP2 Display Subsystem.
4 * Copyright (C) 2008 Nokia Corporation
5 * Written by Andrzej Zaborowski <andrew@openedhand.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 or
10 * (at your option) version 3 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 target_phys_addr_t diss_base
;
28 target_phys_addr_t disc_base
;
29 target_phys_addr_t rfbi_base
;
30 target_phys_addr_t venc_base
;
31 target_phys_addr_t im3_base
;
40 struct omap_dss_panel_s
{
61 struct omap_dss_plane_s
{
69 target_phys_addr_t addr
[3];
79 uint16_t palette
[256];
95 struct rfbi_chip_s
*chip
[2];
99 static void omap_dispc_interrupt_update(struct omap_dss_s
*s
)
101 qemu_set_irq(s
->irq
, s
->dispc
.irqst
& s
->dispc
.irqen
);
104 static void omap_rfbi_reset(struct omap_dss_s
*s
)
106 s
->rfbi
.idlemode
= 0;
110 s
->rfbi
.skiplines
= 0;
112 s
->rfbi
.config
[0] = 0x00310000;
113 s
->rfbi
.config
[1] = 0x00310000;
128 void omap_dss_reset(struct omap_dss_s
*s
)
142 s
->dispc
.idlemode
= 0;
145 s
->dispc
.control
= 0;
147 s
->dispc
.capable
= 0x161;
148 s
->dispc
.timing
[0] = 0;
149 s
->dispc
.timing
[1] = 0;
150 s
->dispc
.timing
[2] = 0;
154 s
->dispc
.trans
[0] = 0;
155 s
->dispc
.trans
[1] = 0;
157 s
->dispc
.l
[0].enable
= 0;
158 s
->dispc
.l
[0].bpp
= 0;
159 s
->dispc
.l
[0].addr
[0] = 0;
160 s
->dispc
.l
[0].addr
[1] = 0;
161 s
->dispc
.l
[0].addr
[2] = 0;
162 s
->dispc
.l
[0].posx
= 0;
163 s
->dispc
.l
[0].posy
= 0;
164 s
->dispc
.l
[0].nx
= 1;
165 s
->dispc
.l
[0].ny
= 1;
166 s
->dispc
.l
[0].attr
= 0;
167 s
->dispc
.l
[0].tresh
= 0;
168 s
->dispc
.l
[0].rowinc
= 1;
169 s
->dispc
.l
[0].colinc
= 1;
170 s
->dispc
.l
[0].wininc
= 0;
173 omap_dispc_interrupt_update(s
);
176 static uint32_t omap_diss_read(void *opaque
, target_phys_addr_t addr
)
178 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
179 int offset
= addr
- s
->diss_base
;
182 case 0x00: /* DSS_REVISIONNUMBER */
185 case 0x10: /* DSS_SYSCONFIG */
188 case 0x14: /* DSS_SYSSTATUS */
189 return 1; /* RESETDONE */
191 case 0x40: /* DSS_CONTROL */
194 case 0x50: /* DSS_PSA_LCD_REG_1 */
195 case 0x54: /* DSS_PSA_LCD_REG_2 */
196 case 0x58: /* DSS_PSA_VIDEO_REG */
197 /* TODO: fake some values when appropriate s->control bits are set */
200 case 0x5c: /* DSS_STATUS */
201 return 1 + (s
->control
& 1);
210 static void omap_diss_write(void *opaque
, target_phys_addr_t addr
,
213 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
214 int offset
= addr
- s
->diss_base
;
217 case 0x00: /* DSS_REVISIONNUMBER */
218 case 0x14: /* DSS_SYSSTATUS */
219 case 0x50: /* DSS_PSA_LCD_REG_1 */
220 case 0x54: /* DSS_PSA_LCD_REG_2 */
221 case 0x58: /* DSS_PSA_VIDEO_REG */
222 case 0x5c: /* DSS_STATUS */
226 case 0x10: /* DSS_SYSCONFIG */
227 if (value
& 2) /* SOFTRESET */
229 s
->autoidle
= value
& 1;
232 case 0x40: /* DSS_CONTROL */
233 s
->control
= value
& 0x3dd;
241 static CPUReadMemoryFunc
*omap_diss1_readfn
[] = {
242 omap_badwidth_read32
,
243 omap_badwidth_read32
,
247 static CPUWriteMemoryFunc
*omap_diss1_writefn
[] = {
248 omap_badwidth_write32
,
249 omap_badwidth_write32
,
253 static uint32_t omap_disc_read(void *opaque
, target_phys_addr_t addr
)
255 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
256 int offset
= addr
- s
->disc_base
;
259 case 0x000: /* DISPC_REVISION */
262 case 0x010: /* DISPC_SYSCONFIG */
263 return s
->dispc
.idlemode
;
265 case 0x014: /* DISPC_SYSSTATUS */
266 return 1; /* RESETDONE */
268 case 0x018: /* DISPC_IRQSTATUS */
269 return s
->dispc
.irqst
;
271 case 0x01c: /* DISPC_IRQENABLE */
272 return s
->dispc
.irqen
;
274 case 0x040: /* DISPC_CONTROL */
275 return s
->dispc
.control
;
277 case 0x044: /* DISPC_CONFIG */
278 return s
->dispc
.config
;
280 case 0x048: /* DISPC_CAPABLE */
281 return s
->dispc
.capable
;
283 case 0x04c: /* DISPC_DEFAULT_COLOR0 */
284 return s
->dispc
.bg
[0];
285 case 0x050: /* DISPC_DEFAULT_COLOR1 */
286 return s
->dispc
.bg
[1];
287 case 0x054: /* DISPC_TRANS_COLOR0 */
288 return s
->dispc
.trans
[0];
289 case 0x058: /* DISPC_TRANS_COLOR1 */
290 return s
->dispc
.trans
[1];
292 case 0x05c: /* DISPC_LINE_STATUS */
294 case 0x060: /* DISPC_LINE_NUMBER */
295 return s
->dispc
.line
;
297 case 0x064: /* DISPC_TIMING_H */
298 return s
->dispc
.timing
[0];
299 case 0x068: /* DISPC_TIMING_V */
300 return s
->dispc
.timing
[1];
301 case 0x06c: /* DISPC_POL_FREQ */
302 return s
->dispc
.timing
[2];
303 case 0x070: /* DISPC_DIVISOR */
304 return s
->dispc
.timing
[3];
306 case 0x078: /* DISPC_SIZE_DIG */
307 return ((s
->dig
.ny
- 1) << 16) | (s
->dig
.nx
- 1);
308 case 0x07c: /* DISPC_SIZE_LCD */
309 return ((s
->lcd
.ny
- 1) << 16) | (s
->lcd
.nx
- 1);
311 case 0x080: /* DISPC_GFX_BA0 */
312 return s
->dispc
.l
[0].addr
[0];
313 case 0x084: /* DISPC_GFX_BA1 */
314 return s
->dispc
.l
[0].addr
[1];
315 case 0x088: /* DISPC_GFX_POSITION */
316 return (s
->dispc
.l
[0].posy
<< 16) | s
->dispc
.l
[0].posx
;
317 case 0x08c: /* DISPC_GFX_SIZE */
318 return ((s
->dispc
.l
[0].ny
- 1) << 16) | (s
->dispc
.l
[0].nx
- 1);
319 case 0x0a0: /* DISPC_GFX_ATTRIBUTES */
320 return s
->dispc
.l
[0].attr
;
321 case 0x0a4: /* DISPC_GFX_FIFO_TRESHOLD */
322 return s
->dispc
.l
[0].tresh
;
323 case 0x0a8: /* DISPC_GFX_FIFO_SIZE_STATUS */
325 case 0x0ac: /* DISPC_GFX_ROW_INC */
326 return s
->dispc
.l
[0].rowinc
;
327 case 0x0b0: /* DISPC_GFX_PIXEL_INC */
328 return s
->dispc
.l
[0].colinc
;
329 case 0x0b4: /* DISPC_GFX_WINDOW_SKIP */
330 return s
->dispc
.l
[0].wininc
;
331 case 0x0b8: /* DISPC_GFX_TABLE_BA */
332 return s
->dispc
.l
[0].addr
[2];
334 case 0x0bc: /* DISPC_VID1_BA0 */
335 case 0x0c0: /* DISPC_VID1_BA1 */
336 case 0x0c4: /* DISPC_VID1_POSITION */
337 case 0x0c8: /* DISPC_VID1_SIZE */
338 case 0x0cc: /* DISPC_VID1_ATTRIBUTES */
339 case 0x0d0: /* DISPC_VID1_FIFO_TRESHOLD */
340 case 0x0d4: /* DISPC_VID1_FIFO_SIZE_STATUS */
341 case 0x0d8: /* DISPC_VID1_ROW_INC */
342 case 0x0dc: /* DISPC_VID1_PIXEL_INC */
343 case 0x0e0: /* DISPC_VID1_FIR */
344 case 0x0e4: /* DISPC_VID1_PICTURE_SIZE */
345 case 0x0e8: /* DISPC_VID1_ACCU0 */
346 case 0x0ec: /* DISPC_VID1_ACCU1 */
347 case 0x0f0 ... 0x140: /* DISPC_VID1_FIR_COEF, DISPC_VID1_CONV_COEF */
348 case 0x14c: /* DISPC_VID2_BA0 */
349 case 0x150: /* DISPC_VID2_BA1 */
350 case 0x154: /* DISPC_VID2_POSITION */
351 case 0x158: /* DISPC_VID2_SIZE */
352 case 0x15c: /* DISPC_VID2_ATTRIBUTES */
353 case 0x160: /* DISPC_VID2_FIFO_TRESHOLD */
354 case 0x164: /* DISPC_VID2_FIFO_SIZE_STATUS */
355 case 0x168: /* DISPC_VID2_ROW_INC */
356 case 0x16c: /* DISPC_VID2_PIXEL_INC */
357 case 0x170: /* DISPC_VID2_FIR */
358 case 0x174: /* DISPC_VID2_PICTURE_SIZE */
359 case 0x178: /* DISPC_VID2_ACCU0 */
360 case 0x17c: /* DISPC_VID2_ACCU1 */
361 case 0x180 ... 0x1d0: /* DISPC_VID2_FIR_COEF, DISPC_VID2_CONV_COEF */
362 case 0x1d4: /* DISPC_DATA_CYCLE1 */
363 case 0x1d8: /* DISPC_DATA_CYCLE2 */
364 case 0x1dc: /* DISPC_DATA_CYCLE3 */
374 static void omap_disc_write(void *opaque
, target_phys_addr_t addr
,
377 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
378 int offset
= addr
- s
->disc_base
;
381 case 0x010: /* DISPC_SYSCONFIG */
382 if (value
& 2) /* SOFTRESET */
384 s
->dispc
.idlemode
= value
& 0x301b;
387 case 0x018: /* DISPC_IRQSTATUS */
388 s
->dispc
.irqst
&= ~value
;
389 omap_dispc_interrupt_update(s
);
392 case 0x01c: /* DISPC_IRQENABLE */
393 s
->dispc
.irqen
= value
& 0xffff;
394 omap_dispc_interrupt_update(s
);
397 case 0x040: /* DISPC_CONTROL */
398 s
->dispc
.control
= value
& 0x07ff9fff;
399 s
->dig
.enable
= (value
>> 1) & 1;
400 s
->lcd
.enable
= (value
>> 0) & 1;
401 if (value
& (1 << 12)) /* OVERLAY_OPTIMIZATION */
402 if (~((s
->dispc
.l
[1].attr
| s
->dispc
.l
[2].attr
) & 1))
403 fprintf(stderr
, "%s: Overlay Optimization when no overlay "
404 "region effectively exists leads to "
405 "unpredictable behaviour!\n", __FUNCTION__
);
406 if (value
& (1 << 6)) { /* GODIGITAL */
407 /* XXX: Shadowed fields are:
423 * s->dispc.l[0].addr[0]
424 * s->dispc.l[0].addr[1]
425 * s->dispc.l[0].addr[2]
430 * s->dispc.l[0].tresh
431 * s->dispc.l[0].rowinc
432 * s->dispc.l[0].colinc
433 * s->dispc.l[0].wininc
434 * All they need to be loaded here from their shadow registers.
437 if (value
& (1 << 5)) { /* GOLCD */
438 /* XXX: Likewise for LCD here. */
440 s
->dispc
.invalidate
= 1;
443 case 0x044: /* DISPC_CONFIG */
444 s
->dispc
.config
= value
& 0x3fff;
446 * bits 2:1 (LOADMODE) reset to 0 after set to 1 and palette loaded
447 * bits 2:1 (LOADMODE) reset to 2 after set to 3 and palette loaded
449 s
->dispc
.invalidate
= 1;
452 case 0x048: /* DISPC_CAPABLE */
453 s
->dispc
.capable
= value
& 0x3ff;
456 case 0x04c: /* DISPC_DEFAULT_COLOR0 */
457 s
->dispc
.bg
[0] = value
& 0xffffff;
458 s
->dispc
.invalidate
= 1;
460 case 0x050: /* DISPC_DEFAULT_COLOR1 */
461 s
->dispc
.bg
[1] = value
& 0xffffff;
462 s
->dispc
.invalidate
= 1;
464 case 0x054: /* DISPC_TRANS_COLOR0 */
465 s
->dispc
.trans
[0] = value
& 0xffffff;
466 s
->dispc
.invalidate
= 1;
468 case 0x058: /* DISPC_TRANS_COLOR1 */
469 s
->dispc
.trans
[1] = value
& 0xffffff;
470 s
->dispc
.invalidate
= 1;
473 case 0x060: /* DISPC_LINE_NUMBER */
474 s
->dispc
.line
= value
& 0x7ff;
477 case 0x064: /* DISPC_TIMING_H */
478 s
->dispc
.timing
[0] = value
& 0x0ff0ff3f;
480 case 0x068: /* DISPC_TIMING_V */
481 s
->dispc
.timing
[1] = value
& 0x0ff0ff3f;
483 case 0x06c: /* DISPC_POL_FREQ */
484 s
->dispc
.timing
[2] = value
& 0x0003ffff;
486 case 0x070: /* DISPC_DIVISOR */
487 s
->dispc
.timing
[3] = value
& 0x00ff00ff;
490 case 0x078: /* DISPC_SIZE_DIG */
491 s
->dig
.nx
= ((value
>> 0) & 0x7ff) + 1; /* PPL */
492 s
->dig
.ny
= ((value
>> 16) & 0x7ff) + 1; /* LPP */
493 s
->dispc
.invalidate
= 1;
495 case 0x07c: /* DISPC_SIZE_LCD */
496 s
->lcd
.nx
= ((value
>> 0) & 0x7ff) + 1; /* PPL */
497 s
->lcd
.ny
= ((value
>> 16) & 0x7ff) + 1; /* LPP */
498 s
->dispc
.invalidate
= 1;
500 case 0x080: /* DISPC_GFX_BA0 */
501 s
->dispc
.l
[0].addr
[0] = (target_phys_addr_t
) value
;
502 s
->dispc
.invalidate
= 1;
504 case 0x084: /* DISPC_GFX_BA1 */
505 s
->dispc
.l
[0].addr
[1] = (target_phys_addr_t
) value
;
506 s
->dispc
.invalidate
= 1;
508 case 0x088: /* DISPC_GFX_POSITION */
509 s
->dispc
.l
[0].posx
= ((value
>> 0) & 0x7ff); /* GFXPOSX */
510 s
->dispc
.l
[0].posy
= ((value
>> 16) & 0x7ff); /* GFXPOSY */
511 s
->dispc
.invalidate
= 1;
513 case 0x08c: /* DISPC_GFX_SIZE */
514 s
->dispc
.l
[0].nx
= ((value
>> 0) & 0x7ff) + 1; /* GFXSIZEX */
515 s
->dispc
.l
[0].ny
= ((value
>> 16) & 0x7ff) + 1; /* GFXSIZEY */
516 s
->dispc
.invalidate
= 1;
518 case 0x0a0: /* DISPC_GFX_ATTRIBUTES */
519 s
->dispc
.l
[0].attr
= value
& 0x7ff;
520 if (value
& (3 << 9))
521 fprintf(stderr
, "%s: Big-endian pixel format not supported\n",
523 s
->dispc
.l
[0].enable
= value
& 1;
524 s
->dispc
.l
[0].bpp
= (value
>> 1) & 0xf;
525 s
->dispc
.invalidate
= 1;
527 case 0x0a4: /* DISPC_GFX_FIFO_TRESHOLD */
528 s
->dispc
.l
[0].tresh
= value
& 0x01ff01ff;
530 case 0x0ac: /* DISPC_GFX_ROW_INC */
531 s
->dispc
.l
[0].rowinc
= value
;
532 s
->dispc
.invalidate
= 1;
534 case 0x0b0: /* DISPC_GFX_PIXEL_INC */
535 s
->dispc
.l
[0].colinc
= value
;
536 s
->dispc
.invalidate
= 1;
538 case 0x0b4: /* DISPC_GFX_WINDOW_SKIP */
539 s
->dispc
.l
[0].wininc
= value
;
541 case 0x0b8: /* DISPC_GFX_TABLE_BA */
542 s
->dispc
.l
[0].addr
[2] = (target_phys_addr_t
) value
;
543 s
->dispc
.invalidate
= 1;
546 case 0x0bc: /* DISPC_VID1_BA0 */
547 case 0x0c0: /* DISPC_VID1_BA1 */
548 case 0x0c4: /* DISPC_VID1_POSITION */
549 case 0x0c8: /* DISPC_VID1_SIZE */
550 case 0x0cc: /* DISPC_VID1_ATTRIBUTES */
551 case 0x0d0: /* DISPC_VID1_FIFO_TRESHOLD */
552 case 0x0d8: /* DISPC_VID1_ROW_INC */
553 case 0x0dc: /* DISPC_VID1_PIXEL_INC */
554 case 0x0e0: /* DISPC_VID1_FIR */
555 case 0x0e4: /* DISPC_VID1_PICTURE_SIZE */
556 case 0x0e8: /* DISPC_VID1_ACCU0 */
557 case 0x0ec: /* DISPC_VID1_ACCU1 */
558 case 0x0f0 ... 0x140: /* DISPC_VID1_FIR_COEF, DISPC_VID1_CONV_COEF */
559 case 0x14c: /* DISPC_VID2_BA0 */
560 case 0x150: /* DISPC_VID2_BA1 */
561 case 0x154: /* DISPC_VID2_POSITION */
562 case 0x158: /* DISPC_VID2_SIZE */
563 case 0x15c: /* DISPC_VID2_ATTRIBUTES */
564 case 0x160: /* DISPC_VID2_FIFO_TRESHOLD */
565 case 0x168: /* DISPC_VID2_ROW_INC */
566 case 0x16c: /* DISPC_VID2_PIXEL_INC */
567 case 0x170: /* DISPC_VID2_FIR */
568 case 0x174: /* DISPC_VID2_PICTURE_SIZE */
569 case 0x178: /* DISPC_VID2_ACCU0 */
570 case 0x17c: /* DISPC_VID2_ACCU1 */
571 case 0x180 ... 0x1d0: /* DISPC_VID2_FIR_COEF, DISPC_VID2_CONV_COEF */
572 case 0x1d4: /* DISPC_DATA_CYCLE1 */
573 case 0x1d8: /* DISPC_DATA_CYCLE2 */
574 case 0x1dc: /* DISPC_DATA_CYCLE3 */
582 static CPUReadMemoryFunc
*omap_disc1_readfn
[] = {
583 omap_badwidth_read32
,
584 omap_badwidth_read32
,
588 static CPUWriteMemoryFunc
*omap_disc1_writefn
[] = {
589 omap_badwidth_write32
,
590 omap_badwidth_write32
,
594 static void *omap_rfbi_get_buffer(struct omap_dss_s
*s
)
596 target_phys_addr_t fb
;
600 fb
= s
->dispc
.l
[0].addr
[0];
602 pd
= cpu_get_physical_page_desc(fb
);
603 if ((pd
& ~TARGET_PAGE_MASK
) != IO_MEM_RAM
)
605 cpu_abort(cpu_single_env
, "%s: framebuffer outside RAM!\n",
608 return phys_ram_base
+
609 (pd
& TARGET_PAGE_MASK
) +
610 (fb
& ~TARGET_PAGE_MASK
);
613 static void omap_rfbi_transfer_stop(struct omap_dss_s
*s
)
618 /* TODO: in non-Bypass mode we probably need to just deassert the DRQ. */
623 static void omap_rfbi_transfer_start(struct omap_dss_s
*s
)
629 if (!s
->rfbi
.enable
|| s
->rfbi
.busy
)
632 if (s
->rfbi
.control
& (1 << 1)) { /* BYPASS */
633 /* TODO: in non-Bypass mode we probably need to just assert the
634 * DRQ and wait for DMA to write the pixels. */
635 fprintf(stderr
, "%s: Bypass mode unimplemented\n", __FUNCTION__
);
639 if (!(s
->dispc
.control
& (1 << 11))) /* RFBIMODE */
641 /* TODO: check that LCD output is enabled in DISPC. */
645 data
= omap_rfbi_get_buffer(s
);
648 len
= s
->rfbi
.pixels
* 2;
651 /* TODO: negative values */
652 pitch
= s
->dispc
.l
[0].nx
+ (s
->dispc
.l
[0].rowinc
- 1) / 2;
654 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0])
655 s
->rfbi
.chip
[0]->block(s
->rfbi
.chip
[0]->opaque
, 1, data
, len
, pitch
);
656 if ((s
->rfbi
.control
& (1 << 3)) && s
->rfbi
.chip
[1])
657 s
->rfbi
.chip
[1]->block(s
->rfbi
.chip
[1]->opaque
, 1, data
, len
, pitch
);
659 omap_rfbi_transfer_stop(s
);
662 s
->dispc
.irqst
|= 1; /* FRAMEDONE */
663 omap_dispc_interrupt_update(s
);
666 static uint32_t omap_rfbi_read(void *opaque
, target_phys_addr_t addr
)
668 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
669 int offset
= addr
- s
->rfbi_base
;
672 case 0x00: /* RFBI_REVISION */
675 case 0x10: /* RFBI_SYSCONFIG */
676 return s
->rfbi
.idlemode
;
678 case 0x14: /* RFBI_SYSSTATUS */
679 return 1 | (s
->rfbi
.busy
<< 8); /* RESETDONE */
681 case 0x40: /* RFBI_CONTROL */
682 return s
->rfbi
.control
;
684 case 0x44: /* RFBI_PIXELCNT */
685 return s
->rfbi
.pixels
;
687 case 0x48: /* RFBI_LINE_NUMBER */
688 return s
->rfbi
.skiplines
;
690 case 0x58: /* RFBI_READ */
691 case 0x5c: /* RFBI_STATUS */
692 return s
->rfbi
.rxbuf
;
694 case 0x60: /* RFBI_CONFIG0 */
695 return s
->rfbi
.config
[0];
696 case 0x64: /* RFBI_ONOFF_TIME0 */
697 return s
->rfbi
.time
[0];
698 case 0x68: /* RFBI_CYCLE_TIME0 */
699 return s
->rfbi
.time
[1];
700 case 0x6c: /* RFBI_DATA_CYCLE1_0 */
701 return s
->rfbi
.data
[0];
702 case 0x70: /* RFBI_DATA_CYCLE2_0 */
703 return s
->rfbi
.data
[1];
704 case 0x74: /* RFBI_DATA_CYCLE3_0 */
705 return s
->rfbi
.data
[2];
707 case 0x78: /* RFBI_CONFIG1 */
708 return s
->rfbi
.config
[1];
709 case 0x7c: /* RFBI_ONOFF_TIME1 */
710 return s
->rfbi
.time
[2];
711 case 0x80: /* RFBI_CYCLE_TIME1 */
712 return s
->rfbi
.time
[3];
713 case 0x84: /* RFBI_DATA_CYCLE1_1 */
714 return s
->rfbi
.data
[3];
715 case 0x88: /* RFBI_DATA_CYCLE2_1 */
716 return s
->rfbi
.data
[4];
717 case 0x8c: /* RFBI_DATA_CYCLE3_1 */
718 return s
->rfbi
.data
[5];
720 case 0x90: /* RFBI_VSYNC_WIDTH */
721 return s
->rfbi
.vsync
;
722 case 0x94: /* RFBI_HSYNC_WIDTH */
723 return s
->rfbi
.hsync
;
729 static void omap_rfbi_write(void *opaque
, target_phys_addr_t addr
,
732 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
733 int offset
= addr
- s
->rfbi_base
;
736 case 0x10: /* RFBI_SYSCONFIG */
737 if (value
& 2) /* SOFTRESET */
739 s
->rfbi
.idlemode
= value
& 0x19;
742 case 0x40: /* RFBI_CONTROL */
743 s
->rfbi
.control
= value
& 0xf;
744 s
->rfbi
.enable
= value
& 1;
745 if (value
& (1 << 4) && /* ITE */
746 !(s
->rfbi
.config
[0] & s
->rfbi
.config
[1] & 0xc))
747 omap_rfbi_transfer_start(s
);
750 case 0x44: /* RFBI_PIXELCNT */
751 s
->rfbi
.pixels
= value
;
754 case 0x48: /* RFBI_LINE_NUMBER */
755 s
->rfbi
.skiplines
= value
& 0x7ff;
758 case 0x4c: /* RFBI_CMD */
759 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0])
760 s
->rfbi
.chip
[0]->write(s
->rfbi
.chip
[0]->opaque
, 0, value
& 0xffff);
761 if ((s
->rfbi
.control
& (1 << 3)) && s
->rfbi
.chip
[1])
762 s
->rfbi
.chip
[1]->write(s
->rfbi
.chip
[1]->opaque
, 0, value
& 0xffff);
764 case 0x50: /* RFBI_PARAM */
765 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0])
766 s
->rfbi
.chip
[0]->write(s
->rfbi
.chip
[0]->opaque
, 1, value
& 0xffff);
767 if ((s
->rfbi
.control
& (1 << 3)) && s
->rfbi
.chip
[1])
768 s
->rfbi
.chip
[1]->write(s
->rfbi
.chip
[1]->opaque
, 1, value
& 0xffff);
770 case 0x54: /* RFBI_DATA */
771 /* TODO: take into account the format set up in s->rfbi.config[?] and
772 * s->rfbi.data[?], but special-case the most usual scenario so that
773 * speed doesn't suffer. */
774 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0]) {
775 s
->rfbi
.chip
[0]->write(s
->rfbi
.chip
[0]->opaque
, 1, value
& 0xffff);
776 s
->rfbi
.chip
[0]->write(s
->rfbi
.chip
[0]->opaque
, 1, value
>> 16);
778 if ((s
->rfbi
.control
& (1 << 3)) && s
->rfbi
.chip
[1]) {
779 s
->rfbi
.chip
[1]->write(s
->rfbi
.chip
[1]->opaque
, 1, value
& 0xffff);
780 s
->rfbi
.chip
[1]->write(s
->rfbi
.chip
[1]->opaque
, 1, value
>> 16);
782 if (!-- s
->rfbi
.pixels
)
783 omap_rfbi_transfer_stop(s
);
785 case 0x58: /* RFBI_READ */
786 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0])
787 s
->rfbi
.rxbuf
= s
->rfbi
.chip
[0]->read(s
->rfbi
.chip
[0]->opaque
, 1);
788 else if ((s
->rfbi
.control
& (1 << 3)) && s
->rfbi
.chip
[1])
789 s
->rfbi
.rxbuf
= s
->rfbi
.chip
[0]->read(s
->rfbi
.chip
[0]->opaque
, 1);
790 if (!-- s
->rfbi
.pixels
)
791 omap_rfbi_transfer_stop(s
);
794 case 0x5c: /* RFBI_STATUS */
795 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0])
796 s
->rfbi
.rxbuf
= s
->rfbi
.chip
[0]->read(s
->rfbi
.chip
[0]->opaque
, 0);
797 else if ((s
->rfbi
.control
& (1 << 3)) && s
->rfbi
.chip
[1])
798 s
->rfbi
.rxbuf
= s
->rfbi
.chip
[0]->read(s
->rfbi
.chip
[0]->opaque
, 0);
799 if (!-- s
->rfbi
.pixels
)
800 omap_rfbi_transfer_stop(s
);
803 case 0x60: /* RFBI_CONFIG0 */
804 s
->rfbi
.config
[0] = value
& 0x003f1fff;
807 case 0x64: /* RFBI_ONOFF_TIME0 */
808 s
->rfbi
.time
[0] = value
& 0x3fffffff;
810 case 0x68: /* RFBI_CYCLE_TIME0 */
811 s
->rfbi
.time
[1] = value
& 0x0fffffff;
813 case 0x6c: /* RFBI_DATA_CYCLE1_0 */
814 s
->rfbi
.data
[0] = value
& 0x0f1f0f1f;
816 case 0x70: /* RFBI_DATA_CYCLE2_0 */
817 s
->rfbi
.data
[1] = value
& 0x0f1f0f1f;
819 case 0x74: /* RFBI_DATA_CYCLE3_0 */
820 s
->rfbi
.data
[2] = value
& 0x0f1f0f1f;
822 case 0x78: /* RFBI_CONFIG1 */
823 s
->rfbi
.config
[1] = value
& 0x003f1fff;
826 case 0x7c: /* RFBI_ONOFF_TIME1 */
827 s
->rfbi
.time
[2] = value
& 0x3fffffff;
829 case 0x80: /* RFBI_CYCLE_TIME1 */
830 s
->rfbi
.time
[3] = value
& 0x0fffffff;
832 case 0x84: /* RFBI_DATA_CYCLE1_1 */
833 s
->rfbi
.data
[3] = value
& 0x0f1f0f1f;
835 case 0x88: /* RFBI_DATA_CYCLE2_1 */
836 s
->rfbi
.data
[4] = value
& 0x0f1f0f1f;
838 case 0x8c: /* RFBI_DATA_CYCLE3_1 */
839 s
->rfbi
.data
[5] = value
& 0x0f1f0f1f;
842 case 0x90: /* RFBI_VSYNC_WIDTH */
843 s
->rfbi
.vsync
= value
& 0xffff;
845 case 0x94: /* RFBI_HSYNC_WIDTH */
846 s
->rfbi
.hsync
= value
& 0xffff;
854 static CPUReadMemoryFunc
*omap_rfbi1_readfn
[] = {
855 omap_badwidth_read32
,
856 omap_badwidth_read32
,
860 static CPUWriteMemoryFunc
*omap_rfbi1_writefn
[] = {
861 omap_badwidth_write32
,
862 omap_badwidth_write32
,
866 static uint32_t omap_venc_read(void *opaque
, target_phys_addr_t addr
)
868 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
869 int offset
= addr
- s
->venc_base
;
872 case 0x00: /* REV_ID */
873 case 0x04: /* STATUS */
874 case 0x08: /* F_CONTROL */
875 case 0x10: /* VIDOUT_CTRL */
876 case 0x14: /* SYNC_CTRL */
877 case 0x1c: /* LLEN */
878 case 0x20: /* FLENS */
879 case 0x24: /* HFLTR_CTRL */
880 case 0x28: /* CC_CARR_WSS_CARR */
881 case 0x2c: /* C_PHASE */
882 case 0x30: /* GAIN_U */
883 case 0x34: /* GAIN_V */
884 case 0x38: /* GAIN_Y */
885 case 0x3c: /* BLACK_LEVEL */
886 case 0x40: /* BLANK_LEVEL */
887 case 0x44: /* X_COLOR */
888 case 0x48: /* M_CONTROL */
889 case 0x4c: /* BSTAMP_WSS_DATA */
890 case 0x50: /* S_CARR */
891 case 0x54: /* LINE21 */
892 case 0x58: /* LN_SEL */
893 case 0x5c: /* L21__WC_CTL */
894 case 0x60: /* HTRIGGER_VTRIGGER */
895 case 0x64: /* SAVID__EAVID */
896 case 0x68: /* FLEN__FAL */
897 case 0x6c: /* LAL__PHASE_RESET */
898 case 0x70: /* HS_INT_START_STOP_X */
899 case 0x74: /* HS_EXT_START_STOP_X */
900 case 0x78: /* VS_INT_START_X */
901 case 0x7c: /* VS_INT_STOP_X__VS_INT_START_Y */
902 case 0x80: /* VS_INT_STOP_Y__VS_INT_START_X */
903 case 0x84: /* VS_EXT_STOP_X__VS_EXT_START_Y */
904 case 0x88: /* VS_EXT_STOP_Y */
905 case 0x90: /* AVID_START_STOP_X */
906 case 0x94: /* AVID_START_STOP_Y */
907 case 0xa0: /* FID_INT_START_X__FID_INT_START_Y */
908 case 0xa4: /* FID_INT_OFFSET_Y__FID_EXT_START_X */
909 case 0xa8: /* FID_EXT_START_Y__FID_EXT_OFFSET_Y */
910 case 0xb0: /* TVDETGP_INT_START_STOP_X */
911 case 0xb4: /* TVDETGP_INT_START_STOP_Y */
912 case 0xb8: /* GEN_CTRL */
913 case 0xc4: /* DAC_TST__DAC_A */
914 case 0xc8: /* DAC_B__DAC_C */
924 static void omap_venc_write(void *opaque
, target_phys_addr_t addr
,
927 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
928 int offset
= addr
- s
->venc_base
;
931 case 0x08: /* F_CONTROL */
932 case 0x10: /* VIDOUT_CTRL */
933 case 0x14: /* SYNC_CTRL */
934 case 0x1c: /* LLEN */
935 case 0x20: /* FLENS */
936 case 0x24: /* HFLTR_CTRL */
937 case 0x28: /* CC_CARR_WSS_CARR */
938 case 0x2c: /* C_PHASE */
939 case 0x30: /* GAIN_U */
940 case 0x34: /* GAIN_V */
941 case 0x38: /* GAIN_Y */
942 case 0x3c: /* BLACK_LEVEL */
943 case 0x40: /* BLANK_LEVEL */
944 case 0x44: /* X_COLOR */
945 case 0x48: /* M_CONTROL */
946 case 0x4c: /* BSTAMP_WSS_DATA */
947 case 0x50: /* S_CARR */
948 case 0x54: /* LINE21 */
949 case 0x58: /* LN_SEL */
950 case 0x5c: /* L21__WC_CTL */
951 case 0x60: /* HTRIGGER_VTRIGGER */
952 case 0x64: /* SAVID__EAVID */
953 case 0x68: /* FLEN__FAL */
954 case 0x6c: /* LAL__PHASE_RESET */
955 case 0x70: /* HS_INT_START_STOP_X */
956 case 0x74: /* HS_EXT_START_STOP_X */
957 case 0x78: /* VS_INT_START_X */
958 case 0x7c: /* VS_INT_STOP_X__VS_INT_START_Y */
959 case 0x80: /* VS_INT_STOP_Y__VS_INT_START_X */
960 case 0x84: /* VS_EXT_STOP_X__VS_EXT_START_Y */
961 case 0x88: /* VS_EXT_STOP_Y */
962 case 0x90: /* AVID_START_STOP_X */
963 case 0x94: /* AVID_START_STOP_Y */
964 case 0xa0: /* FID_INT_START_X__FID_INT_START_Y */
965 case 0xa4: /* FID_INT_OFFSET_Y__FID_EXT_START_X */
966 case 0xa8: /* FID_EXT_START_Y__FID_EXT_OFFSET_Y */
967 case 0xb0: /* TVDETGP_INT_START_STOP_X */
968 case 0xb4: /* TVDETGP_INT_START_STOP_Y */
969 case 0xb8: /* GEN_CTRL */
970 case 0xc4: /* DAC_TST__DAC_A */
971 case 0xc8: /* DAC_B__DAC_C */
979 static CPUReadMemoryFunc
*omap_venc1_readfn
[] = {
980 omap_badwidth_read32
,
981 omap_badwidth_read32
,
985 static CPUWriteMemoryFunc
*omap_venc1_writefn
[] = {
986 omap_badwidth_write32
,
987 omap_badwidth_write32
,
991 static uint32_t omap_im3_read(void *opaque
, target_phys_addr_t addr
)
993 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
994 int offset
= addr
- s
->im3_base
;
997 case 0x0a8: /* SBIMERRLOGA */
998 case 0x0b0: /* SBIMERRLOG */
999 case 0x190: /* SBIMSTATE */
1000 case 0x198: /* SBTMSTATE_L */
1001 case 0x19c: /* SBTMSTATE_H */
1002 case 0x1a8: /* SBIMCONFIG_L */
1003 case 0x1ac: /* SBIMCONFIG_H */
1004 case 0x1f8: /* SBID_L */
1005 case 0x1fc: /* SBID_H */
1015 static void omap_im3_write(void *opaque
, target_phys_addr_t addr
,
1018 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
1019 int offset
= addr
- s
->im3_base
;
1022 case 0x0b0: /* SBIMERRLOG */
1023 case 0x190: /* SBIMSTATE */
1024 case 0x198: /* SBTMSTATE_L */
1025 case 0x19c: /* SBTMSTATE_H */
1026 case 0x1a8: /* SBIMCONFIG_L */
1027 case 0x1ac: /* SBIMCONFIG_H */
1035 static CPUReadMemoryFunc
*omap_im3_readfn
[] = {
1036 omap_badwidth_read32
,
1037 omap_badwidth_read32
,
1041 static CPUWriteMemoryFunc
*omap_im3_writefn
[] = {
1042 omap_badwidth_write32
,
1043 omap_badwidth_write32
,
1047 struct omap_dss_s
*omap_dss_init(struct omap_target_agent_s
*ta
,
1048 target_phys_addr_t l3_base
, DisplayState
*ds
,
1049 qemu_irq irq
, qemu_irq drq
,
1050 omap_clk fck1
, omap_clk fck2
, omap_clk ck54m
,
1051 omap_clk ick1
, omap_clk ick2
)
1054 struct omap_dss_s
*s
= (struct omap_dss_s
*)
1055 qemu_mallocz(sizeof(struct omap_dss_s
));
1062 iomemtype
[0] = l4_register_io_memory(0, omap_diss1_readfn
,
1063 omap_diss1_writefn
, s
);
1064 iomemtype
[1] = l4_register_io_memory(0, omap_disc1_readfn
,
1065 omap_disc1_writefn
, s
);
1066 iomemtype
[2] = l4_register_io_memory(0, omap_rfbi1_readfn
,
1067 omap_rfbi1_writefn
, s
);
1068 iomemtype
[3] = l4_register_io_memory(0, omap_venc1_readfn
,
1069 omap_venc1_writefn
, s
);
1070 iomemtype
[4] = cpu_register_io_memory(0, omap_im3_readfn
,
1071 omap_im3_writefn
, s
);
1072 s
->diss_base
= omap_l4_attach(ta
, 0, iomemtype
[0]);
1073 s
->disc_base
= omap_l4_attach(ta
, 1, iomemtype
[1]);
1074 s
->rfbi_base
= omap_l4_attach(ta
, 2, iomemtype
[2]);
1075 s
->venc_base
= omap_l4_attach(ta
, 3, iomemtype
[3]);
1076 s
->im3_base
= l3_base
;
1077 cpu_register_physical_memory(s
->im3_base
, 0x1000, iomemtype
[4]);
1081 graphic_console_init(ds
, omap_update_display
,
1082 omap_invalidate_display
, omap_screen_dump
, s
);
1088 void omap_rfbi_attach(struct omap_dss_s
*s
, int cs
, struct rfbi_chip_s
*chip
)
1090 if (cs
< 0 || cs
> 1)
1091 cpu_abort(cpu_single_env
, "%s: wrong CS %i\n", __FUNCTION__
, cs
);
1092 s
->rfbi
.chip
[cs
] = chip
;