pl111.cc (9330:4a3269a11230) pl111.cc (9394:e88cf95d33d3)
1/*
1/*
2 * Copyright (c) 2010 ARM Limited
2 * Copyright (c) 2010-2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

--- 48 unchanged lines hidden (view full) ---

59// initialize clcd registers
60Pl111::Pl111(const Params *p)
61 : AmbaDmaDevice(p), lcdTiming0(0), lcdTiming1(0), lcdTiming2(0),
62 lcdTiming3(0), lcdUpbase(0), lcdLpbase(0), lcdControl(0), lcdImsc(0),
63 lcdRis(0), lcdMis(0),
64 clcdCrsrCtrl(0), clcdCrsrConfig(0), clcdCrsrPalette0(0),
65 clcdCrsrPalette1(0), clcdCrsrXY(0), clcdCrsrClip(0), clcdCrsrImsc(0),
66 clcdCrsrIcr(0), clcdCrsrRis(0), clcdCrsrMis(0),
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

--- 48 unchanged lines hidden (view full) ---

59// initialize clcd registers
60Pl111::Pl111(const Params *p)
61 : AmbaDmaDevice(p), lcdTiming0(0), lcdTiming1(0), lcdTiming2(0),
62 lcdTiming3(0), lcdUpbase(0), lcdLpbase(0), lcdControl(0), lcdImsc(0),
63 lcdRis(0), lcdMis(0),
64 clcdCrsrCtrl(0), clcdCrsrConfig(0), clcdCrsrPalette0(0),
65 clcdCrsrPalette1(0), clcdCrsrXY(0), clcdCrsrClip(0), clcdCrsrImsc(0),
66 clcdCrsrIcr(0), clcdCrsrRis(0), clcdCrsrMis(0),
67 pixelClock(p->pixel_clock),
67 vnc(p->vnc), bmp(NULL), width(LcdMaxWidth), height(LcdMaxHeight),
68 bytesPerPixel(4), startTime(0), startAddr(0), maxAddr(0), curAddr(0),
69 waterMark(0), dmaPendingNum(0), readEvent(this), fillFifoEvent(this),
70 dmaDoneEvent(maxOutstandingDma, this), intEvent(this)
71{
72 pioSize = 0xFFFF;
73
74 pic = simout.create(csprintf("%s.framebuffer.bmp", sys->name()), true);

--- 360 unchanged lines hidden (view full) ---

435 startAddr = lcdUpbase;
436
437 // Updating base address, interrupt if we're supposed to
438 lcdRis.baseaddr = 1;
439 if (!intEvent.scheduled())
440 schedule(intEvent, nextCycle());
441
442 curAddr = 0;
68 vnc(p->vnc), bmp(NULL), width(LcdMaxWidth), height(LcdMaxHeight),
69 bytesPerPixel(4), startTime(0), startAddr(0), maxAddr(0), curAddr(0),
70 waterMark(0), dmaPendingNum(0), readEvent(this), fillFifoEvent(this),
71 dmaDoneEvent(maxOutstandingDma, this), intEvent(this)
72{
73 pioSize = 0xFFFF;
74
75 pic = simout.create(csprintf("%s.framebuffer.bmp", sys->name()), true);

--- 360 unchanged lines hidden (view full) ---

436 startAddr = lcdUpbase;
437
438 // Updating base address, interrupt if we're supposed to
439 lcdRis.baseaddr = 1;
440 if (!intEvent.scheduled())
441 schedule(intEvent, nextCycle());
442
443 curAddr = 0;
443 startTime = curCycle();
444 startTime = curTick();
444
445 maxAddr = static_cast<Addr>(length * bytesPerPixel);
446
447 DPRINTF(PL111, " lcd frame buffer size of %d bytes \n", maxAddr);
448
445
446 maxAddr = static_cast<Addr>(length * bytesPerPixel);
447
448 DPRINTF(PL111, " lcd frame buffer size of %d bytes \n", maxAddr);
449
449 dmaPendingNum = 0;
450
451 fillFifo();
452}
453
454void
455Pl111::fillFifo()
456{
457 while ((dmaPendingNum < maxOutstandingDma) && (maxAddr >= curAddr + dmaSize )) {
458 // concurrent dma reads need different dma done events

--- 11 unchanged lines hidden (view full) ---

470 0, Request::UNCACHEABLE);
471 curAddr += dmaSize;
472 }
473}
474
475void
476Pl111::dmaDone()
477{
450 fillFifo();
451}
452
453void
454Pl111::fillFifo()
455{
456 while ((dmaPendingNum < maxOutstandingDma) && (maxAddr >= curAddr + dmaSize )) {
457 // concurrent dma reads need different dma done events

--- 11 unchanged lines hidden (view full) ---

469 0, Request::UNCACHEABLE);
470 curAddr += dmaSize;
471 }
472}
473
474void
475Pl111::dmaDone()
476{
478 Cycles maxFrameTime(lcdTiming2.cpl * height);
477 DPRINTF(PL111, "DMA Done\n");
479
478
479 Tick maxFrameTime = lcdTiming2.cpl * height * pixelClock;
480
480 --dmaPendingNum;
481
482 if (maxAddr == curAddr && !dmaPendingNum) {
481 --dmaPendingNum;
482
483 if (maxAddr == curAddr && !dmaPendingNum) {
483 if ((curCycle() - startTime) > maxFrameTime) {
484 warn("CLCD controller buffer underrun, took %d cycles when should"
484 if ((curTick() - startTime) > maxFrameTime) {
485 warn("CLCD controller buffer underrun, took %d ticks when should"
485 " have taken %d\n", curTick() - startTime, maxFrameTime);
486 lcdRis.underflow = 1;
487 if (!intEvent.scheduled())
488 schedule(intEvent, nextCycle());
489 }
490
491 assert(!readEvent.scheduled());
492 if (vnc)
493 vnc->setDirty();
494
495 DPRINTF(PL111, "-- write out frame buffer into bmp\n");
496
497 assert(bmp);
498 pic->seekp(0);
499 bmp->write(pic);
500
501 // schedule the next read based on when the last frame started
502 // and the desired fps (i.e. maxFrameTime), we turn the
486 " have taken %d\n", curTick() - startTime, maxFrameTime);
487 lcdRis.underflow = 1;
488 if (!intEvent.scheduled())
489 schedule(intEvent, nextCycle());
490 }
491
492 assert(!readEvent.scheduled());
493 if (vnc)
494 vnc->setDirty();
495
496 DPRINTF(PL111, "-- write out frame buffer into bmp\n");
497
498 assert(bmp);
499 pic->seekp(0);
500 bmp->write(pic);
501
502 // schedule the next read based on when the last frame started
503 // and the desired fps (i.e. maxFrameTime), we turn the
503 // argument into a relative number of cycles in the future by
504 // subtracting curCycle()
504 // argument into a relative number of cycles in the future
505 if (lcdControl.lcden)
505 if (lcdControl.lcden)
506 // @todo: This is a terrible way of doing the time
507 // keeping, make it all relative
508 schedule(readEvent,
509 clockEdge(Cycles(startTime - curCycle() +
510 maxFrameTime)));
506 schedule(readEvent, clockEdge(ticksToCycles(startTime -
507 curTick() +
508 maxFrameTime)));
511 }
512
513 if (dmaPendingNum > (maxOutstandingDma - waterMark))
514 return;
515
516 if (!fillFifoEvent.scheduled())
517 schedule(fillFifoEvent, nextCycle());
518}

--- 227 unchanged lines hidden ---
509 }
510
511 if (dmaPendingNum > (maxOutstandingDma - waterMark))
512 return;
513
514 if (!fillFifoEvent.scheduled())
515 schedule(fillFifoEvent, nextCycle());
516}

--- 227 unchanged lines hidden ---