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 along
18 * with this program; if not, see <http://www.gnu.org/licenses/>.
20 #include "qemu/osdep.h"
22 #include "ui/console.h"
23 #include "hw/arm/omap.h"
29 MemoryRegion iomem_diss1
, iomem_disc1
, iomem_rfbi1
, iomem_venc1
, iomem_im3
;
35 struct omap_dss_panel_s
{
56 struct omap_dss_plane_s
{
74 uint16_t palette
[256];
90 struct rfbi_chip_s
*chip
[2];
94 static void omap_dispc_interrupt_update(struct omap_dss_s
*s
)
96 qemu_set_irq(s
->irq
, s
->dispc
.irqst
& s
->dispc
.irqen
);
99 static void omap_rfbi_reset(struct omap_dss_s
*s
)
101 s
->rfbi
.idlemode
= 0;
105 s
->rfbi
.skiplines
= 0;
107 s
->rfbi
.config
[0] = 0x00310000;
108 s
->rfbi
.config
[1] = 0x00310000;
123 void omap_dss_reset(struct omap_dss_s
*s
)
137 s
->dispc
.idlemode
= 0;
140 s
->dispc
.control
= 0;
142 s
->dispc
.capable
= 0x161;
143 s
->dispc
.timing
[0] = 0;
144 s
->dispc
.timing
[1] = 0;
145 s
->dispc
.timing
[2] = 0;
146 s
->dispc
.timing
[3] = 0;
150 s
->dispc
.trans
[0] = 0;
151 s
->dispc
.trans
[1] = 0;
153 s
->dispc
.l
[0].enable
= 0;
154 s
->dispc
.l
[0].bpp
= 0;
155 s
->dispc
.l
[0].addr
[0] = 0;
156 s
->dispc
.l
[0].addr
[1] = 0;
157 s
->dispc
.l
[0].addr
[2] = 0;
158 s
->dispc
.l
[0].posx
= 0;
159 s
->dispc
.l
[0].posy
= 0;
160 s
->dispc
.l
[0].nx
= 1;
161 s
->dispc
.l
[0].ny
= 1;
162 s
->dispc
.l
[0].attr
= 0;
163 s
->dispc
.l
[0].tresh
= 0;
164 s
->dispc
.l
[0].rowinc
= 1;
165 s
->dispc
.l
[0].colinc
= 1;
166 s
->dispc
.l
[0].wininc
= 0;
169 omap_dispc_interrupt_update(s
);
172 static uint64_t omap_diss_read(void *opaque
, hwaddr addr
,
175 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
178 return omap_badwidth_read32(opaque
, addr
);
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
, hwaddr addr
,
211 uint64_t value
, unsigned size
)
213 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
216 omap_badwidth_write32(opaque
, addr
, value
);
221 case 0x00: /* DSS_REVISIONNUMBER */
222 case 0x14: /* DSS_SYSSTATUS */
223 case 0x50: /* DSS_PSA_LCD_REG_1 */
224 case 0x54: /* DSS_PSA_LCD_REG_2 */
225 case 0x58: /* DSS_PSA_VIDEO_REG */
226 case 0x5c: /* DSS_STATUS */
230 case 0x10: /* DSS_SYSCONFIG */
231 if (value
& 2) /* SOFTRESET */
233 s
->autoidle
= value
& 1;
236 case 0x40: /* DSS_CONTROL */
237 s
->control
= value
& 0x3dd;
245 static const MemoryRegionOps omap_diss_ops
= {
246 .read
= omap_diss_read
,
247 .write
= omap_diss_write
,
248 .endianness
= DEVICE_NATIVE_ENDIAN
,
251 static uint64_t omap_disc_read(void *opaque
, hwaddr addr
,
254 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
257 return omap_badwidth_read32(opaque
, addr
);
261 case 0x000: /* DISPC_REVISION */
264 case 0x010: /* DISPC_SYSCONFIG */
265 return s
->dispc
.idlemode
;
267 case 0x014: /* DISPC_SYSSTATUS */
268 return 1; /* RESETDONE */
270 case 0x018: /* DISPC_IRQSTATUS */
271 return s
->dispc
.irqst
;
273 case 0x01c: /* DISPC_IRQENABLE */
274 return s
->dispc
.irqen
;
276 case 0x040: /* DISPC_CONTROL */
277 return s
->dispc
.control
;
279 case 0x044: /* DISPC_CONFIG */
280 return s
->dispc
.config
;
282 case 0x048: /* DISPC_CAPABLE */
283 return s
->dispc
.capable
;
285 case 0x04c: /* DISPC_DEFAULT_COLOR0 */
286 return s
->dispc
.bg
[0];
287 case 0x050: /* DISPC_DEFAULT_COLOR1 */
288 return s
->dispc
.bg
[1];
289 case 0x054: /* DISPC_TRANS_COLOR0 */
290 return s
->dispc
.trans
[0];
291 case 0x058: /* DISPC_TRANS_COLOR1 */
292 return s
->dispc
.trans
[1];
294 case 0x05c: /* DISPC_LINE_STATUS */
296 case 0x060: /* DISPC_LINE_NUMBER */
297 return s
->dispc
.line
;
299 case 0x064: /* DISPC_TIMING_H */
300 return s
->dispc
.timing
[0];
301 case 0x068: /* DISPC_TIMING_V */
302 return s
->dispc
.timing
[1];
303 case 0x06c: /* DISPC_POL_FREQ */
304 return s
->dispc
.timing
[2];
305 case 0x070: /* DISPC_DIVISOR */
306 return s
->dispc
.timing
[3];
308 case 0x078: /* DISPC_SIZE_DIG */
309 return ((s
->dig
.ny
- 1) << 16) | (s
->dig
.nx
- 1);
310 case 0x07c: /* DISPC_SIZE_LCD */
311 return ((s
->lcd
.ny
- 1) << 16) | (s
->lcd
.nx
- 1);
313 case 0x080: /* DISPC_GFX_BA0 */
314 return s
->dispc
.l
[0].addr
[0];
315 case 0x084: /* DISPC_GFX_BA1 */
316 return s
->dispc
.l
[0].addr
[1];
317 case 0x088: /* DISPC_GFX_POSITION */
318 return (s
->dispc
.l
[0].posy
<< 16) | s
->dispc
.l
[0].posx
;
319 case 0x08c: /* DISPC_GFX_SIZE */
320 return ((s
->dispc
.l
[0].ny
- 1) << 16) | (s
->dispc
.l
[0].nx
- 1);
321 case 0x0a0: /* DISPC_GFX_ATTRIBUTES */
322 return s
->dispc
.l
[0].attr
;
323 case 0x0a4: /* DISPC_GFX_FIFO_TRESHOLD */
324 return s
->dispc
.l
[0].tresh
;
325 case 0x0a8: /* DISPC_GFX_FIFO_SIZE_STATUS */
327 case 0x0ac: /* DISPC_GFX_ROW_INC */
328 return s
->dispc
.l
[0].rowinc
;
329 case 0x0b0: /* DISPC_GFX_PIXEL_INC */
330 return s
->dispc
.l
[0].colinc
;
331 case 0x0b4: /* DISPC_GFX_WINDOW_SKIP */
332 return s
->dispc
.l
[0].wininc
;
333 case 0x0b8: /* DISPC_GFX_TABLE_BA */
334 return s
->dispc
.l
[0].addr
[2];
336 case 0x0bc: /* DISPC_VID1_BA0 */
337 case 0x0c0: /* DISPC_VID1_BA1 */
338 case 0x0c4: /* DISPC_VID1_POSITION */
339 case 0x0c8: /* DISPC_VID1_SIZE */
340 case 0x0cc: /* DISPC_VID1_ATTRIBUTES */
341 case 0x0d0: /* DISPC_VID1_FIFO_TRESHOLD */
342 case 0x0d4: /* DISPC_VID1_FIFO_SIZE_STATUS */
343 case 0x0d8: /* DISPC_VID1_ROW_INC */
344 case 0x0dc: /* DISPC_VID1_PIXEL_INC */
345 case 0x0e0: /* DISPC_VID1_FIR */
346 case 0x0e4: /* DISPC_VID1_PICTURE_SIZE */
347 case 0x0e8: /* DISPC_VID1_ACCU0 */
348 case 0x0ec: /* DISPC_VID1_ACCU1 */
349 case 0x0f0 ... 0x140: /* DISPC_VID1_FIR_COEF, DISPC_VID1_CONV_COEF */
350 case 0x14c: /* DISPC_VID2_BA0 */
351 case 0x150: /* DISPC_VID2_BA1 */
352 case 0x154: /* DISPC_VID2_POSITION */
353 case 0x158: /* DISPC_VID2_SIZE */
354 case 0x15c: /* DISPC_VID2_ATTRIBUTES */
355 case 0x160: /* DISPC_VID2_FIFO_TRESHOLD */
356 case 0x164: /* DISPC_VID2_FIFO_SIZE_STATUS */
357 case 0x168: /* DISPC_VID2_ROW_INC */
358 case 0x16c: /* DISPC_VID2_PIXEL_INC */
359 case 0x170: /* DISPC_VID2_FIR */
360 case 0x174: /* DISPC_VID2_PICTURE_SIZE */
361 case 0x178: /* DISPC_VID2_ACCU0 */
362 case 0x17c: /* DISPC_VID2_ACCU1 */
363 case 0x180 ... 0x1d0: /* DISPC_VID2_FIR_COEF, DISPC_VID2_CONV_COEF */
364 case 0x1d4: /* DISPC_DATA_CYCLE1 */
365 case 0x1d8: /* DISPC_DATA_CYCLE2 */
366 case 0x1dc: /* DISPC_DATA_CYCLE3 */
376 static void omap_disc_write(void *opaque
, hwaddr addr
,
377 uint64_t value
, unsigned size
)
379 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
382 omap_badwidth_write32(opaque
, addr
, value
);
387 case 0x010: /* DISPC_SYSCONFIG */
388 if (value
& 2) /* SOFTRESET */
390 s
->dispc
.idlemode
= value
& 0x301b;
393 case 0x018: /* DISPC_IRQSTATUS */
394 s
->dispc
.irqst
&= ~value
;
395 omap_dispc_interrupt_update(s
);
398 case 0x01c: /* DISPC_IRQENABLE */
399 s
->dispc
.irqen
= value
& 0xffff;
400 omap_dispc_interrupt_update(s
);
403 case 0x040: /* DISPC_CONTROL */
404 s
->dispc
.control
= value
& 0x07ff9fff;
405 s
->dig
.enable
= (value
>> 1) & 1;
406 s
->lcd
.enable
= (value
>> 0) & 1;
407 if (value
& (1 << 12)) /* OVERLAY_OPTIMIZATION */
408 if (!((s
->dispc
.l
[1].attr
| s
->dispc
.l
[2].attr
) & 1)) {
409 fprintf(stderr
, "%s: Overlay Optimization when no overlay "
410 "region effectively exists leads to "
411 "unpredictable behaviour!\n", __func__
);
413 if (value
& (1 << 6)) { /* GODIGITAL */
414 /* XXX: Shadowed fields are:
430 * s->dispc.l[0].addr[0]
431 * s->dispc.l[0].addr[1]
432 * s->dispc.l[0].addr[2]
437 * s->dispc.l[0].tresh
438 * s->dispc.l[0].rowinc
439 * s->dispc.l[0].colinc
440 * s->dispc.l[0].wininc
441 * All they need to be loaded here from their shadow registers.
444 if (value
& (1 << 5)) { /* GOLCD */
445 /* XXX: Likewise for LCD here. */
447 s
->dispc
.invalidate
= 1;
450 case 0x044: /* DISPC_CONFIG */
451 s
->dispc
.config
= value
& 0x3fff;
453 * bits 2:1 (LOADMODE) reset to 0 after set to 1 and palette loaded
454 * bits 2:1 (LOADMODE) reset to 2 after set to 3 and palette loaded
456 s
->dispc
.invalidate
= 1;
459 case 0x048: /* DISPC_CAPABLE */
460 s
->dispc
.capable
= value
& 0x3ff;
463 case 0x04c: /* DISPC_DEFAULT_COLOR0 */
464 s
->dispc
.bg
[0] = value
& 0xffffff;
465 s
->dispc
.invalidate
= 1;
467 case 0x050: /* DISPC_DEFAULT_COLOR1 */
468 s
->dispc
.bg
[1] = value
& 0xffffff;
469 s
->dispc
.invalidate
= 1;
471 case 0x054: /* DISPC_TRANS_COLOR0 */
472 s
->dispc
.trans
[0] = value
& 0xffffff;
473 s
->dispc
.invalidate
= 1;
475 case 0x058: /* DISPC_TRANS_COLOR1 */
476 s
->dispc
.trans
[1] = value
& 0xffffff;
477 s
->dispc
.invalidate
= 1;
480 case 0x060: /* DISPC_LINE_NUMBER */
481 s
->dispc
.line
= value
& 0x7ff;
484 case 0x064: /* DISPC_TIMING_H */
485 s
->dispc
.timing
[0] = value
& 0x0ff0ff3f;
487 case 0x068: /* DISPC_TIMING_V */
488 s
->dispc
.timing
[1] = value
& 0x0ff0ff3f;
490 case 0x06c: /* DISPC_POL_FREQ */
491 s
->dispc
.timing
[2] = value
& 0x0003ffff;
493 case 0x070: /* DISPC_DIVISOR */
494 s
->dispc
.timing
[3] = value
& 0x00ff00ff;
497 case 0x078: /* DISPC_SIZE_DIG */
498 s
->dig
.nx
= ((value
>> 0) & 0x7ff) + 1; /* PPL */
499 s
->dig
.ny
= ((value
>> 16) & 0x7ff) + 1; /* LPP */
500 s
->dispc
.invalidate
= 1;
502 case 0x07c: /* DISPC_SIZE_LCD */
503 s
->lcd
.nx
= ((value
>> 0) & 0x7ff) + 1; /* PPL */
504 s
->lcd
.ny
= ((value
>> 16) & 0x7ff) + 1; /* LPP */
505 s
->dispc
.invalidate
= 1;
507 case 0x080: /* DISPC_GFX_BA0 */
508 s
->dispc
.l
[0].addr
[0] = (hwaddr
) value
;
509 s
->dispc
.invalidate
= 1;
511 case 0x084: /* DISPC_GFX_BA1 */
512 s
->dispc
.l
[0].addr
[1] = (hwaddr
) value
;
513 s
->dispc
.invalidate
= 1;
515 case 0x088: /* DISPC_GFX_POSITION */
516 s
->dispc
.l
[0].posx
= ((value
>> 0) & 0x7ff); /* GFXPOSX */
517 s
->dispc
.l
[0].posy
= ((value
>> 16) & 0x7ff); /* GFXPOSY */
518 s
->dispc
.invalidate
= 1;
520 case 0x08c: /* DISPC_GFX_SIZE */
521 s
->dispc
.l
[0].nx
= ((value
>> 0) & 0x7ff) + 1; /* GFXSIZEX */
522 s
->dispc
.l
[0].ny
= ((value
>> 16) & 0x7ff) + 1; /* GFXSIZEY */
523 s
->dispc
.invalidate
= 1;
525 case 0x0a0: /* DISPC_GFX_ATTRIBUTES */
526 s
->dispc
.l
[0].attr
= value
& 0x7ff;
527 if (value
& (3 << 9))
528 fprintf(stderr
, "%s: Big-endian pixel format not supported\n",
530 s
->dispc
.l
[0].enable
= value
& 1;
531 s
->dispc
.l
[0].bpp
= (value
>> 1) & 0xf;
532 s
->dispc
.invalidate
= 1;
534 case 0x0a4: /* DISPC_GFX_FIFO_TRESHOLD */
535 s
->dispc
.l
[0].tresh
= value
& 0x01ff01ff;
537 case 0x0ac: /* DISPC_GFX_ROW_INC */
538 s
->dispc
.l
[0].rowinc
= value
;
539 s
->dispc
.invalidate
= 1;
541 case 0x0b0: /* DISPC_GFX_PIXEL_INC */
542 s
->dispc
.l
[0].colinc
= value
;
543 s
->dispc
.invalidate
= 1;
545 case 0x0b4: /* DISPC_GFX_WINDOW_SKIP */
546 s
->dispc
.l
[0].wininc
= value
;
548 case 0x0b8: /* DISPC_GFX_TABLE_BA */
549 s
->dispc
.l
[0].addr
[2] = (hwaddr
) value
;
550 s
->dispc
.invalidate
= 1;
553 case 0x0bc: /* DISPC_VID1_BA0 */
554 case 0x0c0: /* DISPC_VID1_BA1 */
555 case 0x0c4: /* DISPC_VID1_POSITION */
556 case 0x0c8: /* DISPC_VID1_SIZE */
557 case 0x0cc: /* DISPC_VID1_ATTRIBUTES */
558 case 0x0d0: /* DISPC_VID1_FIFO_TRESHOLD */
559 case 0x0d8: /* DISPC_VID1_ROW_INC */
560 case 0x0dc: /* DISPC_VID1_PIXEL_INC */
561 case 0x0e0: /* DISPC_VID1_FIR */
562 case 0x0e4: /* DISPC_VID1_PICTURE_SIZE */
563 case 0x0e8: /* DISPC_VID1_ACCU0 */
564 case 0x0ec: /* DISPC_VID1_ACCU1 */
565 case 0x0f0 ... 0x140: /* DISPC_VID1_FIR_COEF, DISPC_VID1_CONV_COEF */
566 case 0x14c: /* DISPC_VID2_BA0 */
567 case 0x150: /* DISPC_VID2_BA1 */
568 case 0x154: /* DISPC_VID2_POSITION */
569 case 0x158: /* DISPC_VID2_SIZE */
570 case 0x15c: /* DISPC_VID2_ATTRIBUTES */
571 case 0x160: /* DISPC_VID2_FIFO_TRESHOLD */
572 case 0x168: /* DISPC_VID2_ROW_INC */
573 case 0x16c: /* DISPC_VID2_PIXEL_INC */
574 case 0x170: /* DISPC_VID2_FIR */
575 case 0x174: /* DISPC_VID2_PICTURE_SIZE */
576 case 0x178: /* DISPC_VID2_ACCU0 */
577 case 0x17c: /* DISPC_VID2_ACCU1 */
578 case 0x180 ... 0x1d0: /* DISPC_VID2_FIR_COEF, DISPC_VID2_CONV_COEF */
579 case 0x1d4: /* DISPC_DATA_CYCLE1 */
580 case 0x1d8: /* DISPC_DATA_CYCLE2 */
581 case 0x1dc: /* DISPC_DATA_CYCLE3 */
589 static const MemoryRegionOps omap_disc_ops
= {
590 .read
= omap_disc_read
,
591 .write
= omap_disc_write
,
592 .endianness
= DEVICE_NATIVE_ENDIAN
,
595 static void omap_rfbi_transfer_stop(struct omap_dss_s
*s
)
600 /* TODO: in non-Bypass mode we probably need to just deassert the DRQ. */
605 static void omap_rfbi_transfer_start(struct omap_dss_s
*s
)
611 static void *bounce_buffer
;
612 static hwaddr bounce_len
;
614 if (!s
->rfbi
.enable
|| s
->rfbi
.busy
)
617 if (s
->rfbi
.control
& (1 << 1)) { /* BYPASS */
618 /* TODO: in non-Bypass mode we probably need to just assert the
619 * DRQ and wait for DMA to write the pixels. */
620 fprintf(stderr
, "%s: Bypass mode unimplemented\n", __FUNCTION__
);
624 if (!(s
->dispc
.control
& (1 << 11))) /* RFBIMODE */
626 /* TODO: check that LCD output is enabled in DISPC. */
630 len
= s
->rfbi
.pixels
* 2;
632 data_addr
= s
->dispc
.l
[0].addr
[0];
633 data
= cpu_physical_memory_map(data_addr
, &len
, 0);
634 if (data
&& len
!= s
->rfbi
.pixels
* 2) {
635 cpu_physical_memory_unmap(data
, len
, 0, 0);
637 len
= s
->rfbi
.pixels
* 2;
640 if (len
> bounce_len
) {
641 bounce_buffer
= g_realloc(bounce_buffer
, len
);
643 data
= bounce_buffer
;
644 cpu_physical_memory_read(data_addr
, data
, len
);
650 /* TODO: negative values */
651 pitch
= s
->dispc
.l
[0].nx
+ (s
->dispc
.l
[0].rowinc
- 1) / 2;
653 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0])
654 s
->rfbi
.chip
[0]->block(s
->rfbi
.chip
[0]->opaque
, 1, data
, len
, pitch
);
655 if ((s
->rfbi
.control
& (1 << 3)) && s
->rfbi
.chip
[1])
656 s
->rfbi
.chip
[1]->block(s
->rfbi
.chip
[1]->opaque
, 1, data
, len
, pitch
);
658 if (data
!= bounce_buffer
) {
659 cpu_physical_memory_unmap(data
, len
, 0, len
);
662 omap_rfbi_transfer_stop(s
);
665 s
->dispc
.irqst
|= 1; /* FRAMEDONE */
666 omap_dispc_interrupt_update(s
);
669 static uint64_t omap_rfbi_read(void *opaque
, hwaddr addr
,
672 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
675 return omap_badwidth_read32(opaque
, addr
);
679 case 0x00: /* RFBI_REVISION */
682 case 0x10: /* RFBI_SYSCONFIG */
683 return s
->rfbi
.idlemode
;
685 case 0x14: /* RFBI_SYSSTATUS */
686 return 1 | (s
->rfbi
.busy
<< 8); /* RESETDONE */
688 case 0x40: /* RFBI_CONTROL */
689 return s
->rfbi
.control
;
691 case 0x44: /* RFBI_PIXELCNT */
692 return s
->rfbi
.pixels
;
694 case 0x48: /* RFBI_LINE_NUMBER */
695 return s
->rfbi
.skiplines
;
697 case 0x58: /* RFBI_READ */
698 case 0x5c: /* RFBI_STATUS */
699 return s
->rfbi
.rxbuf
;
701 case 0x60: /* RFBI_CONFIG0 */
702 return s
->rfbi
.config
[0];
703 case 0x64: /* RFBI_ONOFF_TIME0 */
704 return s
->rfbi
.time
[0];
705 case 0x68: /* RFBI_CYCLE_TIME0 */
706 return s
->rfbi
.time
[1];
707 case 0x6c: /* RFBI_DATA_CYCLE1_0 */
708 return s
->rfbi
.data
[0];
709 case 0x70: /* RFBI_DATA_CYCLE2_0 */
710 return s
->rfbi
.data
[1];
711 case 0x74: /* RFBI_DATA_CYCLE3_0 */
712 return s
->rfbi
.data
[2];
714 case 0x78: /* RFBI_CONFIG1 */
715 return s
->rfbi
.config
[1];
716 case 0x7c: /* RFBI_ONOFF_TIME1 */
717 return s
->rfbi
.time
[2];
718 case 0x80: /* RFBI_CYCLE_TIME1 */
719 return s
->rfbi
.time
[3];
720 case 0x84: /* RFBI_DATA_CYCLE1_1 */
721 return s
->rfbi
.data
[3];
722 case 0x88: /* RFBI_DATA_CYCLE2_1 */
723 return s
->rfbi
.data
[4];
724 case 0x8c: /* RFBI_DATA_CYCLE3_1 */
725 return s
->rfbi
.data
[5];
727 case 0x90: /* RFBI_VSYNC_WIDTH */
728 return s
->rfbi
.vsync
;
729 case 0x94: /* RFBI_HSYNC_WIDTH */
730 return s
->rfbi
.hsync
;
736 static void omap_rfbi_write(void *opaque
, hwaddr addr
,
737 uint64_t value
, unsigned size
)
739 struct omap_dss_s
*s
= (struct omap_dss_s
*) opaque
;
742 omap_badwidth_write32(opaque
, addr
, value
);
747 case 0x10: /* RFBI_SYSCONFIG */
748 if (value
& 2) /* SOFTRESET */
750 s
->rfbi
.idlemode
= value
& 0x19;
753 case 0x40: /* RFBI_CONTROL */
754 s
->rfbi
.control
= value
& 0xf;
755 s
->rfbi
.enable
= value
& 1;
756 if (value
& (1 << 4) && /* ITE */
757 !(s
->rfbi
.config
[0] & s
->rfbi
.config
[1] & 0xc))
758 omap_rfbi_transfer_start(s
);
761 case 0x44: /* RFBI_PIXELCNT */
762 s
->rfbi
.pixels
= value
;
765 case 0x48: /* RFBI_LINE_NUMBER */
766 s
->rfbi
.skiplines
= value
& 0x7ff;
769 case 0x4c: /* RFBI_CMD */
770 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0])
771 s
->rfbi
.chip
[0]->write(s
->rfbi
.chip
[0]->opaque
, 0, value
& 0xffff);
772 if ((s
->rfbi
.control
& (1 << 3)) && s
->rfbi
.chip
[1])
773 s
->rfbi
.chip
[1]->write(s
->rfbi
.chip
[1]->opaque
, 0, value
& 0xffff);
775 case 0x50: /* RFBI_PARAM */
776 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0])
777 s
->rfbi
.chip
[0]->write(s
->rfbi
.chip
[0]->opaque
, 1, value
& 0xffff);
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);
781 case 0x54: /* RFBI_DATA */
782 /* TODO: take into account the format set up in s->rfbi.config[?] and
783 * s->rfbi.data[?], but special-case the most usual scenario so that
784 * speed doesn't suffer. */
785 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0]) {
786 s
->rfbi
.chip
[0]->write(s
->rfbi
.chip
[0]->opaque
, 1, value
& 0xffff);
787 s
->rfbi
.chip
[0]->write(s
->rfbi
.chip
[0]->opaque
, 1, value
>> 16);
789 if ((s
->rfbi
.control
& (1 << 3)) && s
->rfbi
.chip
[1]) {
790 s
->rfbi
.chip
[1]->write(s
->rfbi
.chip
[1]->opaque
, 1, value
& 0xffff);
791 s
->rfbi
.chip
[1]->write(s
->rfbi
.chip
[1]->opaque
, 1, value
>> 16);
793 if (!-- s
->rfbi
.pixels
)
794 omap_rfbi_transfer_stop(s
);
796 case 0x58: /* RFBI_READ */
797 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0])
798 s
->rfbi
.rxbuf
= s
->rfbi
.chip
[0]->read(s
->rfbi
.chip
[0]->opaque
, 1);
799 else if ((s
->rfbi
.control
& (1 << 3)) && s
->rfbi
.chip
[1])
800 s
->rfbi
.rxbuf
= s
->rfbi
.chip
[1]->read(s
->rfbi
.chip
[1]->opaque
, 1);
801 if (!-- s
->rfbi
.pixels
)
802 omap_rfbi_transfer_stop(s
);
805 case 0x5c: /* RFBI_STATUS */
806 if ((s
->rfbi
.control
& (1 << 2)) && s
->rfbi
.chip
[0])
807 s
->rfbi
.rxbuf
= s
->rfbi
.chip
[0]->read(s
->rfbi
.chip
[0]->opaque
, 0);
808 else if ((s
->rfbi
.control
& (1 << 3)) && s
->rfbi
.chip
[1])
809 s
->rfbi
.rxbuf
= s
->rfbi
.chip
[1]->read(s
->rfbi
.chip
[1]->opaque
, 0);
810 if (!-- s
->rfbi
.pixels
)
811 omap_rfbi_transfer_stop(s
);
814 case 0x60: /* RFBI_CONFIG0 */
815 s
->rfbi
.config
[0] = value
& 0x003f1fff;
818 case 0x64: /* RFBI_ONOFF_TIME0 */
819 s
->rfbi
.time
[0] = value
& 0x3fffffff;
821 case 0x68: /* RFBI_CYCLE_TIME0 */
822 s
->rfbi
.time
[1] = value
& 0x0fffffff;
824 case 0x6c: /* RFBI_DATA_CYCLE1_0 */
825 s
->rfbi
.data
[0] = value
& 0x0f1f0f1f;
827 case 0x70: /* RFBI_DATA_CYCLE2_0 */
828 s
->rfbi
.data
[1] = value
& 0x0f1f0f1f;
830 case 0x74: /* RFBI_DATA_CYCLE3_0 */
831 s
->rfbi
.data
[2] = value
& 0x0f1f0f1f;
833 case 0x78: /* RFBI_CONFIG1 */
834 s
->rfbi
.config
[1] = value
& 0x003f1fff;
837 case 0x7c: /* RFBI_ONOFF_TIME1 */
838 s
->rfbi
.time
[2] = value
& 0x3fffffff;
840 case 0x80: /* RFBI_CYCLE_TIME1 */
841 s
->rfbi
.time
[3] = value
& 0x0fffffff;
843 case 0x84: /* RFBI_DATA_CYCLE1_1 */
844 s
->rfbi
.data
[3] = value
& 0x0f1f0f1f;
846 case 0x88: /* RFBI_DATA_CYCLE2_1 */
847 s
->rfbi
.data
[4] = value
& 0x0f1f0f1f;
849 case 0x8c: /* RFBI_DATA_CYCLE3_1 */
850 s
->rfbi
.data
[5] = value
& 0x0f1f0f1f;
853 case 0x90: /* RFBI_VSYNC_WIDTH */
854 s
->rfbi
.vsync
= value
& 0xffff;
856 case 0x94: /* RFBI_HSYNC_WIDTH */
857 s
->rfbi
.hsync
= value
& 0xffff;
865 static const MemoryRegionOps omap_rfbi_ops
= {
866 .read
= omap_rfbi_read
,
867 .write
= omap_rfbi_write
,
868 .endianness
= DEVICE_NATIVE_ENDIAN
,
871 static uint64_t omap_venc_read(void *opaque
, hwaddr addr
,
875 return omap_badwidth_read32(opaque
, addr
);
879 case 0x00: /* REV_ID */
880 case 0x04: /* STATUS */
881 case 0x08: /* F_CONTROL */
882 case 0x10: /* VIDOUT_CTRL */
883 case 0x14: /* SYNC_CTRL */
884 case 0x1c: /* LLEN */
885 case 0x20: /* FLENS */
886 case 0x24: /* HFLTR_CTRL */
887 case 0x28: /* CC_CARR_WSS_CARR */
888 case 0x2c: /* C_PHASE */
889 case 0x30: /* GAIN_U */
890 case 0x34: /* GAIN_V */
891 case 0x38: /* GAIN_Y */
892 case 0x3c: /* BLACK_LEVEL */
893 case 0x40: /* BLANK_LEVEL */
894 case 0x44: /* X_COLOR */
895 case 0x48: /* M_CONTROL */
896 case 0x4c: /* BSTAMP_WSS_DATA */
897 case 0x50: /* S_CARR */
898 case 0x54: /* LINE21 */
899 case 0x58: /* LN_SEL */
900 case 0x5c: /* L21__WC_CTL */
901 case 0x60: /* HTRIGGER_VTRIGGER */
902 case 0x64: /* SAVID__EAVID */
903 case 0x68: /* FLEN__FAL */
904 case 0x6c: /* LAL__PHASE_RESET */
905 case 0x70: /* HS_INT_START_STOP_X */
906 case 0x74: /* HS_EXT_START_STOP_X */
907 case 0x78: /* VS_INT_START_X */
908 case 0x7c: /* VS_INT_STOP_X__VS_INT_START_Y */
909 case 0x80: /* VS_INT_STOP_Y__VS_INT_START_X */
910 case 0x84: /* VS_EXT_STOP_X__VS_EXT_START_Y */
911 case 0x88: /* VS_EXT_STOP_Y */
912 case 0x90: /* AVID_START_STOP_X */
913 case 0x94: /* AVID_START_STOP_Y */
914 case 0xa0: /* FID_INT_START_X__FID_INT_START_Y */
915 case 0xa4: /* FID_INT_OFFSET_Y__FID_EXT_START_X */
916 case 0xa8: /* FID_EXT_START_Y__FID_EXT_OFFSET_Y */
917 case 0xb0: /* TVDETGP_INT_START_STOP_X */
918 case 0xb4: /* TVDETGP_INT_START_STOP_Y */
919 case 0xb8: /* GEN_CTRL */
920 case 0xc4: /* DAC_TST__DAC_A */
921 case 0xc8: /* DAC_B__DAC_C */
931 static void omap_venc_write(void *opaque
, hwaddr addr
,
932 uint64_t value
, unsigned size
)
935 omap_badwidth_write32(opaque
, addr
, size
);
940 case 0x08: /* F_CONTROL */
941 case 0x10: /* VIDOUT_CTRL */
942 case 0x14: /* SYNC_CTRL */
943 case 0x1c: /* LLEN */
944 case 0x20: /* FLENS */
945 case 0x24: /* HFLTR_CTRL */
946 case 0x28: /* CC_CARR_WSS_CARR */
947 case 0x2c: /* C_PHASE */
948 case 0x30: /* GAIN_U */
949 case 0x34: /* GAIN_V */
950 case 0x38: /* GAIN_Y */
951 case 0x3c: /* BLACK_LEVEL */
952 case 0x40: /* BLANK_LEVEL */
953 case 0x44: /* X_COLOR */
954 case 0x48: /* M_CONTROL */
955 case 0x4c: /* BSTAMP_WSS_DATA */
956 case 0x50: /* S_CARR */
957 case 0x54: /* LINE21 */
958 case 0x58: /* LN_SEL */
959 case 0x5c: /* L21__WC_CTL */
960 case 0x60: /* HTRIGGER_VTRIGGER */
961 case 0x64: /* SAVID__EAVID */
962 case 0x68: /* FLEN__FAL */
963 case 0x6c: /* LAL__PHASE_RESET */
964 case 0x70: /* HS_INT_START_STOP_X */
965 case 0x74: /* HS_EXT_START_STOP_X */
966 case 0x78: /* VS_INT_START_X */
967 case 0x7c: /* VS_INT_STOP_X__VS_INT_START_Y */
968 case 0x80: /* VS_INT_STOP_Y__VS_INT_START_X */
969 case 0x84: /* VS_EXT_STOP_X__VS_EXT_START_Y */
970 case 0x88: /* VS_EXT_STOP_Y */
971 case 0x90: /* AVID_START_STOP_X */
972 case 0x94: /* AVID_START_STOP_Y */
973 case 0xa0: /* FID_INT_START_X__FID_INT_START_Y */
974 case 0xa4: /* FID_INT_OFFSET_Y__FID_EXT_START_X */
975 case 0xa8: /* FID_EXT_START_Y__FID_EXT_OFFSET_Y */
976 case 0xb0: /* TVDETGP_INT_START_STOP_X */
977 case 0xb4: /* TVDETGP_INT_START_STOP_Y */
978 case 0xb8: /* GEN_CTRL */
979 case 0xc4: /* DAC_TST__DAC_A */
980 case 0xc8: /* DAC_B__DAC_C */
988 static const MemoryRegionOps omap_venc_ops
= {
989 .read
= omap_venc_read
,
990 .write
= omap_venc_write
,
991 .endianness
= DEVICE_NATIVE_ENDIAN
,
994 static uint64_t omap_im3_read(void *opaque
, hwaddr addr
,
998 return omap_badwidth_read32(opaque
, addr
);
1002 case 0x0a8: /* SBIMERRLOGA */
1003 case 0x0b0: /* SBIMERRLOG */
1004 case 0x190: /* SBIMSTATE */
1005 case 0x198: /* SBTMSTATE_L */
1006 case 0x19c: /* SBTMSTATE_H */
1007 case 0x1a8: /* SBIMCONFIG_L */
1008 case 0x1ac: /* SBIMCONFIG_H */
1009 case 0x1f8: /* SBID_L */
1010 case 0x1fc: /* SBID_H */
1020 static void omap_im3_write(void *opaque
, hwaddr addr
,
1021 uint64_t value
, unsigned size
)
1024 omap_badwidth_write32(opaque
, addr
, value
);
1029 case 0x0b0: /* SBIMERRLOG */
1030 case 0x190: /* SBIMSTATE */
1031 case 0x198: /* SBTMSTATE_L */
1032 case 0x19c: /* SBTMSTATE_H */
1033 case 0x1a8: /* SBIMCONFIG_L */
1034 case 0x1ac: /* SBIMCONFIG_H */
1042 static const MemoryRegionOps omap_im3_ops
= {
1043 .read
= omap_im3_read
,
1044 .write
= omap_im3_write
,
1045 .endianness
= DEVICE_NATIVE_ENDIAN
,
1048 struct omap_dss_s
*omap_dss_init(struct omap_target_agent_s
*ta
,
1049 MemoryRegion
*sysmem
,
1051 qemu_irq irq
, qemu_irq drq
,
1052 omap_clk fck1
, omap_clk fck2
, omap_clk ck54m
,
1053 omap_clk ick1
, omap_clk ick2
)
1055 struct omap_dss_s
*s
= g_new0(struct omap_dss_s
, 1);
1061 memory_region_init_io(&s
->iomem_diss1
, NULL
, &omap_diss_ops
, s
, "omap.diss1",
1062 omap_l4_region_size(ta
, 0));
1063 memory_region_init_io(&s
->iomem_disc1
, NULL
, &omap_disc_ops
, s
, "omap.disc1",
1064 omap_l4_region_size(ta
, 1));
1065 memory_region_init_io(&s
->iomem_rfbi1
, NULL
, &omap_rfbi_ops
, s
, "omap.rfbi1",
1066 omap_l4_region_size(ta
, 2));
1067 memory_region_init_io(&s
->iomem_venc1
, NULL
, &omap_venc_ops
, s
, "omap.venc1",
1068 omap_l4_region_size(ta
, 3));
1069 memory_region_init_io(&s
->iomem_im3
, NULL
, &omap_im3_ops
, s
,
1070 "omap.im3", 0x1000);
1072 omap_l4_attach(ta
, 0, &s
->iomem_diss1
);
1073 omap_l4_attach(ta
, 1, &s
->iomem_disc1
);
1074 omap_l4_attach(ta
, 2, &s
->iomem_rfbi1
);
1075 omap_l4_attach(ta
, 3, &s
->iomem_venc1
);
1076 memory_region_add_subregion(sysmem
, l3_base
, &s
->iomem_im3
);
1079 s
->state
= graphic_console_init(omap_update_display
,
1080 omap_invalidate_display
, omap_screen_dump
, s
);
1086 void omap_rfbi_attach(struct omap_dss_s
*s
, int cs
, struct rfbi_chip_s
*chip
)
1088 if (cs
< 0 || cs
> 1)
1089 hw_error("%s: wrong CS %i\n", __FUNCTION__
, cs
);
1090 s
->rfbi
.chip
[cs
] = chip
;