hdlcd.hh revision 12086
19646SChris.Emmons@arm.com/*
211898Ssudhanshu.jha@arm.com * Copyright (c) 2010-2013, 2015, 2017 ARM Limited
39646SChris.Emmons@arm.com * All rights reserved
49646SChris.Emmons@arm.com *
59646SChris.Emmons@arm.com * The license below extends only to copyright in the software and shall
69646SChris.Emmons@arm.com * not be construed as granting a license to any other intellectual
79646SChris.Emmons@arm.com * property including but not limited to intellectual property relating
89646SChris.Emmons@arm.com * to a hardware implementation of the functionality of the software
99646SChris.Emmons@arm.com * licensed hereunder.  You may use the software subject to the license
109646SChris.Emmons@arm.com * terms below provided that you ensure that this notice is replicated
119646SChris.Emmons@arm.com * unmodified and in its entirety in all distributions of the software,
129646SChris.Emmons@arm.com * modified or unmodified, in source code or in binary form.
139646SChris.Emmons@arm.com *
149646SChris.Emmons@arm.com * Redistribution and use in source and binary forms, with or without
159646SChris.Emmons@arm.com * modification, are permitted provided that the following conditions are
169646SChris.Emmons@arm.com * met: redistributions of source code must retain the above copyright
179646SChris.Emmons@arm.com * notice, this list of conditions and the following disclaimer;
189646SChris.Emmons@arm.com * redistributions in binary form must reproduce the above copyright
199646SChris.Emmons@arm.com * notice, this list of conditions and the following disclaimer in the
209646SChris.Emmons@arm.com * documentation and/or other materials provided with the distribution;
219646SChris.Emmons@arm.com * neither the name of the copyright holders nor the names of its
229646SChris.Emmons@arm.com * contributors may be used to endorse or promote products derived from
239646SChris.Emmons@arm.com * this software without specific prior written permission.
249646SChris.Emmons@arm.com *
259646SChris.Emmons@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
269646SChris.Emmons@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
279646SChris.Emmons@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
289646SChris.Emmons@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
299646SChris.Emmons@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
309646SChris.Emmons@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
319646SChris.Emmons@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
329646SChris.Emmons@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
339646SChris.Emmons@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
349646SChris.Emmons@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
359646SChris.Emmons@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
369646SChris.Emmons@arm.com *
379646SChris.Emmons@arm.com * Authors: Chris Emmons
3811090Sandreas.sandberg@arm.com *          Andreas Sandberg
399646SChris.Emmons@arm.com */
409646SChris.Emmons@arm.com
419646SChris.Emmons@arm.com
429646SChris.Emmons@arm.com/** @file
439646SChris.Emmons@arm.com * Implementiation of the ARM HDLcd controller.
449646SChris.Emmons@arm.com *
459646SChris.Emmons@arm.com * This implementation aims to have sufficient detail such that underrun
469646SChris.Emmons@arm.com * conditions are reasonable / behave similar to reality.  There are two
479646SChris.Emmons@arm.com * 'engines' going at once.  First, the DMA engine running at LCD clock
489646SChris.Emmons@arm.com * frequency is responsible for filling the controller's internal buffer.
499646SChris.Emmons@arm.com * The second engine runs at the pixel clock frequency and reads the pixels
509646SChris.Emmons@arm.com * out of the internal buffer.  The pixel rendering engine uses front / back
519646SChris.Emmons@arm.com * porch and sync delays between lines and frames.
529646SChris.Emmons@arm.com *
539646SChris.Emmons@arm.com * If the pixel rendering engine does not have a pixel to display, it will
549646SChris.Emmons@arm.com * cause an underrun event.  The HDLcd controller, per spec, will stop
559646SChris.Emmons@arm.com * issuing DMA requests for the rest of the frame and resume normal behavior
569646SChris.Emmons@arm.com * on the subsequent frame.  What pixels are rendered upon an underrun
579646SChris.Emmons@arm.com * condition is different than the real hardware; while the user will see
589646SChris.Emmons@arm.com * artifacts (previous frame mixed with current frame), it is not the same
599646SChris.Emmons@arm.com * behavior as real hardware which repeats the last pixel value for the rest
609646SChris.Emmons@arm.com * of the current frame.  This compromise was made to save on memory and
619646SChris.Emmons@arm.com * complexity and assumes that it is not important to accurately model the
629646SChris.Emmons@arm.com * content of an underrun frame.
639646SChris.Emmons@arm.com *
649646SChris.Emmons@arm.com * KNOWN ISSUES
6511090Sandreas.sandberg@arm.com * <ul>
6611090Sandreas.sandberg@arm.com *   <li>The HDLcd is implemented here as an AmbaDmaDevice, but it
6711090Sandreas.sandberg@arm.com *       doesn't have an AMBA ID as far as I know.  That is the only
6811090Sandreas.sandberg@arm.com *       bit of the AmbaDmaDevice interface that is irrelevant to it,
6911090Sandreas.sandberg@arm.com *       so a fake AMBA ID is used for now.  I didn't think inserting
7011090Sandreas.sandberg@arm.com *       an extra layer of hierachy between AmbaDmaDevice and
7111090Sandreas.sandberg@arm.com *       DmaDevice would be helpful to anyone else, but that may be
7211090Sandreas.sandberg@arm.com *       the right answer.
7311090Sandreas.sandberg@arm.com * </ul>
749646SChris.Emmons@arm.com */
759646SChris.Emmons@arm.com
769646SChris.Emmons@arm.com#ifndef __DEV_ARM_HDLCD_HH__
779646SChris.Emmons@arm.com#define __DEV_ARM_HDLCD_HH__
789646SChris.Emmons@arm.com
799646SChris.Emmons@arm.com#include <fstream>
8010839Sandreas.sandberg@arm.com#include <memory>
819646SChris.Emmons@arm.com
8210839Sandreas.sandberg@arm.com#include "base/bitmap.hh"
8310839Sandreas.sandberg@arm.com#include "base/framebuffer.hh"
8411359Sandreas@sandberg.pp.se#include "base/output.hh"
859646SChris.Emmons@arm.com#include "dev/arm/amba_device.hh"
8611090Sandreas.sandberg@arm.com#include "dev/pixelpump.hh"
879646SChris.Emmons@arm.com#include "sim/serialize.hh"
889646SChris.Emmons@arm.com
899646SChris.Emmons@arm.comclass VncInput;
9011090Sandreas.sandberg@arm.comstruct HDLcdParams;
9111090Sandreas.sandberg@arm.comclass HDLcdPixelPump;
929646SChris.Emmons@arm.com
939646SChris.Emmons@arm.comclass HDLcd: public AmbaDmaDevice
949646SChris.Emmons@arm.com{
9511090Sandreas.sandberg@arm.com  public:
9611090Sandreas.sandberg@arm.com    HDLcd(const HDLcdParams *p);
9711090Sandreas.sandberg@arm.com    ~HDLcd();
989646SChris.Emmons@arm.com
9911168Sandreas.hansson@arm.com    void regStats() override;
10011091Sandreas.sandberg@arm.com
10111168Sandreas.hansson@arm.com    void serialize(CheckpointOut &cp) const override;
10211168Sandreas.hansson@arm.com    void unserialize(CheckpointIn &cp) override;
10311090Sandreas.sandberg@arm.com
10411168Sandreas.hansson@arm.com    void drainResume() override;
10511090Sandreas.sandberg@arm.com
10611090Sandreas.sandberg@arm.com  public: // IO device interface
10711168Sandreas.hansson@arm.com    Tick read(PacketPtr pkt) override;
10811168Sandreas.hansson@arm.com    Tick write(PacketPtr pkt) override;
10911090Sandreas.sandberg@arm.com
11011168Sandreas.hansson@arm.com    AddrRangeList getAddrRanges() const override { return addrRanges; }
11111090Sandreas.sandberg@arm.com
11211090Sandreas.sandberg@arm.com  protected: // Parameters
11311090Sandreas.sandberg@arm.com    VncInput *vnc;
11411090Sandreas.sandberg@arm.com    const bool workaroundSwapRB;
11511090Sandreas.sandberg@arm.com    const bool workaroundDmaLineCount;
11611090Sandreas.sandberg@arm.com    const AddrRangeList addrRanges;
11711090Sandreas.sandberg@arm.com    const bool enableCapture;
11811090Sandreas.sandberg@arm.com    const Addr pixelBufferSize;
11911898Ssudhanshu.jha@arm.com    const Tick virtRefreshRate;
12011090Sandreas.sandberg@arm.com
12111090Sandreas.sandberg@arm.com  protected: // Register handling
1229646SChris.Emmons@arm.com    /** ARM HDLcd register offsets */
1239646SChris.Emmons@arm.com    enum RegisterOffset {
1249646SChris.Emmons@arm.com        Version          = 0x0000,
1259646SChris.Emmons@arm.com        Int_RawStat      = 0x0010,
1269646SChris.Emmons@arm.com        Int_Clear        = 0x0014,
1279646SChris.Emmons@arm.com        Int_Mask         = 0x0018,
1289646SChris.Emmons@arm.com        Int_Status       = 0x001C,
1299646SChris.Emmons@arm.com        Fb_Base          = 0x0100,
1309646SChris.Emmons@arm.com        Fb_Line_Length   = 0x0104,
1319646SChris.Emmons@arm.com        Fb_Line_Count    = 0x0108,
1329646SChris.Emmons@arm.com        Fb_Line_Pitch    = 0x010C,
1339646SChris.Emmons@arm.com        Bus_Options      = 0x0110,
1349646SChris.Emmons@arm.com        V_Sync           = 0x0200,
1359646SChris.Emmons@arm.com        V_Back_Porch     = 0x0204,
1369646SChris.Emmons@arm.com        V_Data           = 0x0208,
1379646SChris.Emmons@arm.com        V_Front_Porch    = 0x020C,
1389646SChris.Emmons@arm.com        H_Sync           = 0x0210,
1399646SChris.Emmons@arm.com        H_Back_Porch     = 0x0214,
1409646SChris.Emmons@arm.com        H_Data           = 0x0218,
1419646SChris.Emmons@arm.com        H_Front_Porch    = 0x021C,
1429646SChris.Emmons@arm.com        Polarities       = 0x0220,
1439646SChris.Emmons@arm.com        Command          = 0x0230,
1449646SChris.Emmons@arm.com        Pixel_Format     = 0x0240,
1459646SChris.Emmons@arm.com        Red_Select       = 0x0244,
1469646SChris.Emmons@arm.com        Green_Select     = 0x0248,
14711090Sandreas.sandberg@arm.com        Blue_Select      = 0x024C,
14811090Sandreas.sandberg@arm.com    };
1499646SChris.Emmons@arm.com
1509646SChris.Emmons@arm.com    /** Reset value for Bus_Options register */
15111090Sandreas.sandberg@arm.com    static constexpr size_t BUS_OPTIONS_RESETV = 0x408;
1529646SChris.Emmons@arm.com
1539646SChris.Emmons@arm.com    /** Reset value for Version register */
15411090Sandreas.sandberg@arm.com    static constexpr size_t VERSION_RESETV = 0x1CDC0000;
1559646SChris.Emmons@arm.com
15611090Sandreas.sandberg@arm.com    /** AXI port width in bytes */
15711090Sandreas.sandberg@arm.com    static constexpr size_t AXI_PORT_WIDTH = 8;
1589646SChris.Emmons@arm.com
1599646SChris.Emmons@arm.com    /** max number of beats delivered in one dma burst */
16011090Sandreas.sandberg@arm.com    static constexpr size_t MAX_BURST_LEN = 16;
1619646SChris.Emmons@arm.com
16211090Sandreas.sandberg@arm.com    /** Maximum number of bytes per pixel */
16311090Sandreas.sandberg@arm.com    static constexpr size_t MAX_PIXEL_SIZE = 4;
16410839Sandreas.sandberg@arm.com
1659646SChris.Emmons@arm.com    /**
1669646SChris.Emmons@arm.com     * @name RegisterFieldLayouts
1679646SChris.Emmons@arm.com     * Bit layout declarations for multi-field registers.
1689646SChris.Emmons@arm.com     */
1699646SChris.Emmons@arm.com    /**@{*/
1709646SChris.Emmons@arm.com    BitUnion32(VersionReg)
1719646SChris.Emmons@arm.com        Bitfield<7,0>   version_minor;
1729646SChris.Emmons@arm.com        Bitfield<15,8>  version_major;
1739646SChris.Emmons@arm.com        Bitfield<31,16> product_id;
1749646SChris.Emmons@arm.com    EndBitUnion(VersionReg)
1759646SChris.Emmons@arm.com
17611090Sandreas.sandberg@arm.com    static constexpr uint32_t INT_DMA_END = (1UL << 0);
17711090Sandreas.sandberg@arm.com    static constexpr uint32_t INT_BUS_ERROR = (1UL << 1);
17811090Sandreas.sandberg@arm.com    static constexpr uint32_t INT_VSYNC = (1UL << 2);
17911090Sandreas.sandberg@arm.com    static constexpr uint32_t INT_UNDERRUN = (1UL << 3);
1809646SChris.Emmons@arm.com
1819646SChris.Emmons@arm.com    BitUnion32(FbLineCountReg)
1829646SChris.Emmons@arm.com        Bitfield<11,0>  fb_line_count;
1839646SChris.Emmons@arm.com        Bitfield<31,12> reserved_31_12;
1849646SChris.Emmons@arm.com    EndBitUnion(FbLineCountReg)
1859646SChris.Emmons@arm.com
1869646SChris.Emmons@arm.com    BitUnion32(BusOptsReg)
1879646SChris.Emmons@arm.com        Bitfield<4,0>   burst_len;
1889646SChris.Emmons@arm.com        Bitfield<7,5>   reserved_7_5;
1899646SChris.Emmons@arm.com        Bitfield<11,8>  max_outstanding;
1909646SChris.Emmons@arm.com        Bitfield<31,12> reserved_31_12;
1919646SChris.Emmons@arm.com    EndBitUnion(BusOptsReg)
1929646SChris.Emmons@arm.com
1939646SChris.Emmons@arm.com    BitUnion32(TimingReg)
1949646SChris.Emmons@arm.com        Bitfield<11,0>  val;
1959646SChris.Emmons@arm.com        Bitfield<31,12> reserved_31_12;
1969646SChris.Emmons@arm.com    EndBitUnion(TimingReg)
1979646SChris.Emmons@arm.com
1989646SChris.Emmons@arm.com    BitUnion32(PolaritiesReg)
1999646SChris.Emmons@arm.com        Bitfield<0>    vsync_polarity;
2009646SChris.Emmons@arm.com        Bitfield<1>    hsync_polarity;
2019646SChris.Emmons@arm.com        Bitfield<2>    dataen_polarity;
2029646SChris.Emmons@arm.com        Bitfield<3>    data_polarity;
2039646SChris.Emmons@arm.com        Bitfield<4>    pxlclk_polarity;
2049646SChris.Emmons@arm.com        Bitfield<31,5> reserved_31_5;
2059646SChris.Emmons@arm.com    EndBitUnion(PolaritiesReg)
2069646SChris.Emmons@arm.com
2079646SChris.Emmons@arm.com    BitUnion32(CommandReg)
2089646SChris.Emmons@arm.com        Bitfield<0>    enable;
2099646SChris.Emmons@arm.com        Bitfield<31,1> reserved_31_1;
2109646SChris.Emmons@arm.com    EndBitUnion(CommandReg)
2119646SChris.Emmons@arm.com
2129646SChris.Emmons@arm.com    BitUnion32(PixelFormatReg)
2139646SChris.Emmons@arm.com        Bitfield<2,0>  reserved_2_0;
2149646SChris.Emmons@arm.com        Bitfield<4,3>  bytes_per_pixel;
2159646SChris.Emmons@arm.com        Bitfield<30,5> reserved_30_5;
2169646SChris.Emmons@arm.com        Bitfield<31>   big_endian;
2179646SChris.Emmons@arm.com    EndBitUnion(PixelFormatReg)
2189646SChris.Emmons@arm.com
2199646SChris.Emmons@arm.com    BitUnion32(ColorSelectReg)
2209646SChris.Emmons@arm.com        Bitfield<4,0>   offset;
2219646SChris.Emmons@arm.com        Bitfield<7,5>   reserved_7_5;
2229646SChris.Emmons@arm.com        Bitfield<11,8>  size;
2239646SChris.Emmons@arm.com        Bitfield<15,12> reserved_15_12;
2249646SChris.Emmons@arm.com        Bitfield<23,16> default_color;
2259646SChris.Emmons@arm.com        Bitfield<31,24> reserved_31_24;
2269646SChris.Emmons@arm.com    EndBitUnion(ColorSelectReg)
2279646SChris.Emmons@arm.com    /**@}*/
2289646SChris.Emmons@arm.com
2299646SChris.Emmons@arm.com    /**
2309646SChris.Emmons@arm.com     * @name HDLCDRegisters
2319646SChris.Emmons@arm.com     * HDLCD register contents.
2329646SChris.Emmons@arm.com     */
2339646SChris.Emmons@arm.com    /**@{*/
23411090Sandreas.sandberg@arm.com    const VersionReg version;       /**< Version register */
23511090Sandreas.sandberg@arm.com    uint32_t int_rawstat;           /**< Interrupt raw status register */
23611090Sandreas.sandberg@arm.com    uint32_t int_mask;              /**< Interrupt mask register */
2379646SChris.Emmons@arm.com    uint32_t fb_base;               /**< Frame buffer base address register */
2389646SChris.Emmons@arm.com    uint32_t fb_line_length;        /**< Frame buffer Line length register */
2399646SChris.Emmons@arm.com    FbLineCountReg fb_line_count;   /**< Frame buffer Line count register */
24011090Sandreas.sandberg@arm.com    int32_t fb_line_pitch;          /**< Frame buffer Line pitch register */
2419646SChris.Emmons@arm.com    BusOptsReg bus_options;         /**< Bus options register */
2429646SChris.Emmons@arm.com    TimingReg v_sync;               /**< Vertical sync width register */
2439646SChris.Emmons@arm.com    TimingReg v_back_porch;         /**< Vertical back porch width register */
2449646SChris.Emmons@arm.com    TimingReg v_data;               /**< Vertical data width register */
2459646SChris.Emmons@arm.com    TimingReg v_front_porch;        /**< Vertical front porch width register */
2469646SChris.Emmons@arm.com    TimingReg h_sync;               /**< Horizontal sync width register */
2479646SChris.Emmons@arm.com    TimingReg h_back_porch;         /**< Horizontal back porch width register */
2489646SChris.Emmons@arm.com    TimingReg h_data;               /**< Horizontal data width register */
2499646SChris.Emmons@arm.com    TimingReg h_front_porch;        /**< Horizontal front porch width reg */
2509646SChris.Emmons@arm.com    PolaritiesReg polarities;       /**< Polarities register */
2519646SChris.Emmons@arm.com    CommandReg command;             /**< Command register */
2529646SChris.Emmons@arm.com    PixelFormatReg pixel_format;    /**< Pixel format register */
2539646SChris.Emmons@arm.com    ColorSelectReg red_select;      /**< Red color select register */
2549646SChris.Emmons@arm.com    ColorSelectReg green_select;    /**< Green color select register */
2559646SChris.Emmons@arm.com    ColorSelectReg blue_select;     /**< Blue color select register */
2569646SChris.Emmons@arm.com    /** @} */
2579646SChris.Emmons@arm.com
25811090Sandreas.sandberg@arm.com    uint32_t readReg(Addr offset);
25911090Sandreas.sandberg@arm.com    void writeReg(Addr offset, uint32_t value);
2609646SChris.Emmons@arm.com
26111090Sandreas.sandberg@arm.com    PixelConverter pixelConverter() const;
26211090Sandreas.sandberg@arm.com    DisplayTimings displayTimings() const;
26310839Sandreas.sandberg@arm.com
26411090Sandreas.sandberg@arm.com    void createDmaEngine();
26511090Sandreas.sandberg@arm.com
26611090Sandreas.sandberg@arm.com    void cmdEnable();
26711090Sandreas.sandberg@arm.com    void cmdDisable();
26811090Sandreas.sandberg@arm.com
26911090Sandreas.sandberg@arm.com    bool enabled() const { return command.enable; }
27011090Sandreas.sandberg@arm.com
27111090Sandreas.sandberg@arm.com  public: // Pixel pump callbacks
27211090Sandreas.sandberg@arm.com    bool pxlNext(Pixel &p);
27311090Sandreas.sandberg@arm.com    void pxlVSyncBegin();
27411090Sandreas.sandberg@arm.com    void pxlVSyncEnd();
27511090Sandreas.sandberg@arm.com    void pxlUnderrun();
27611090Sandreas.sandberg@arm.com    void pxlFrameDone();
27711090Sandreas.sandberg@arm.com
27811090Sandreas.sandberg@arm.com  protected: // Interrupt handling
27911090Sandreas.sandberg@arm.com    /**
28011090Sandreas.sandberg@arm.com     * Assign new interrupt values and update interrupt signals
28111090Sandreas.sandberg@arm.com     *
28211090Sandreas.sandberg@arm.com     * A new interrupt is scheduled signalled if the set of unmasked
28311090Sandreas.sandberg@arm.com     * interrupts goes empty to non-empty. Conversely, if the set of
28411090Sandreas.sandberg@arm.com     * unmasked interrupts goes from non-empty to empty, the interrupt
28511090Sandreas.sandberg@arm.com     * signal is cleared.
28611090Sandreas.sandberg@arm.com     *
28711090Sandreas.sandberg@arm.com     * @param ints New <i>raw</i> interrupt status
28811090Sandreas.sandberg@arm.com     * @param mask New interrupt mask
28911090Sandreas.sandberg@arm.com     */
29011090Sandreas.sandberg@arm.com    void setInterrupts(uint32_t ints, uint32_t mask);
29111090Sandreas.sandberg@arm.com
29211090Sandreas.sandberg@arm.com    /**
29311090Sandreas.sandberg@arm.com     * Convenience function to update the interrupt mask
29411090Sandreas.sandberg@arm.com     *
29511090Sandreas.sandberg@arm.com     * @see setInterrupts
29611090Sandreas.sandberg@arm.com     * @param mask New interrupt mask
29711090Sandreas.sandberg@arm.com     */
29811090Sandreas.sandberg@arm.com    void intMask(uint32_t mask) { setInterrupts(int_rawstat, mask); }
29911090Sandreas.sandberg@arm.com
30011090Sandreas.sandberg@arm.com    /**
30111090Sandreas.sandberg@arm.com     * Convenience function to raise a new interrupt
30211090Sandreas.sandberg@arm.com     *
30311090Sandreas.sandberg@arm.com     * @see setInterrupts
30411090Sandreas.sandberg@arm.com     * @param ints Set of interrupts to raise
30511090Sandreas.sandberg@arm.com     */
30611090Sandreas.sandberg@arm.com    void intRaise(uint32_t ints) {
30711090Sandreas.sandberg@arm.com        setInterrupts(int_rawstat | ints, int_mask);
30811090Sandreas.sandberg@arm.com    }
30911090Sandreas.sandberg@arm.com
31011090Sandreas.sandberg@arm.com    /**
31111090Sandreas.sandberg@arm.com     * Convenience function to clear interrupts
31211090Sandreas.sandberg@arm.com     *
31311090Sandreas.sandberg@arm.com     * @see setInterrupts
31411090Sandreas.sandberg@arm.com     * @param ints Set of interrupts to clear
31511090Sandreas.sandberg@arm.com     */
31611090Sandreas.sandberg@arm.com    void intClear(uint32_t ints) {
31711090Sandreas.sandberg@arm.com        setInterrupts(int_rawstat & ~ints, int_mask);
31811090Sandreas.sandberg@arm.com    }
31911090Sandreas.sandberg@arm.com
32011090Sandreas.sandberg@arm.com    /** Masked interrupt status register */
32111294Sandreas.hansson@arm.com    uint32_t intStatus() const { return int_rawstat & int_mask; }
32211090Sandreas.sandberg@arm.com
32311090Sandreas.sandberg@arm.com  protected: // Pixel output
32411090Sandreas.sandberg@arm.com    class PixelPump : public BasePixelPump
32511090Sandreas.sandberg@arm.com    {
32611090Sandreas.sandberg@arm.com      public:
32711090Sandreas.sandberg@arm.com        PixelPump(HDLcd &p, ClockDomain &pxl_clk, unsigned pixel_chunk)
32811090Sandreas.sandberg@arm.com            : BasePixelPump(p, pxl_clk, pixel_chunk), parent(p) {}
32911090Sandreas.sandberg@arm.com
33011090Sandreas.sandberg@arm.com        void dumpSettings();
33111090Sandreas.sandberg@arm.com
33211090Sandreas.sandberg@arm.com      protected:
33311168Sandreas.hansson@arm.com        bool nextPixel(Pixel &p) override { return parent.pxlNext(p); }
33411090Sandreas.sandberg@arm.com
33511168Sandreas.hansson@arm.com        void onVSyncBegin() override { return parent.pxlVSyncBegin(); }
33611168Sandreas.hansson@arm.com        void onVSyncEnd() override { return parent.pxlVSyncEnd(); }
33711090Sandreas.sandberg@arm.com
33811168Sandreas.hansson@arm.com        void onUnderrun(unsigned x, unsigned y) override {
33911090Sandreas.sandberg@arm.com            parent.pxlUnderrun();
34011090Sandreas.sandberg@arm.com        }
34111090Sandreas.sandberg@arm.com
34211168Sandreas.hansson@arm.com        void onFrameDone() override { parent.pxlFrameDone(); }
34311090Sandreas.sandberg@arm.com
34411090Sandreas.sandberg@arm.com      protected:
34511090Sandreas.sandberg@arm.com        HDLcd &parent;
34611090Sandreas.sandberg@arm.com    };
3479646SChris.Emmons@arm.com
34811898Ssudhanshu.jha@arm.com    /** Handler for fast frame refresh in KVM-mode */
34911898Ssudhanshu.jha@arm.com    void virtRefresh();
35012086Sspwilson2@wisc.edu    EventFunctionWrapper virtRefreshEvent;
35111898Ssudhanshu.jha@arm.com
3529646SChris.Emmons@arm.com    /** Helper to write out bitmaps */
35310839Sandreas.sandberg@arm.com    Bitmap bmp;
3549646SChris.Emmons@arm.com
3559646SChris.Emmons@arm.com    /** Picture of what the current frame buffer looks like */
35611359Sandreas@sandberg.pp.se    OutputStream *pic;
3579646SChris.Emmons@arm.com
35811090Sandreas.sandberg@arm.com    /** Cached pixel converter, set when the converter is enabled. */
35911090Sandreas.sandberg@arm.com    PixelConverter conv;
36011090Sandreas.sandberg@arm.com
36111090Sandreas.sandberg@arm.com    PixelPump pixelPump;
36211090Sandreas.sandberg@arm.com
36311090Sandreas.sandberg@arm.com  protected: // DMA handling
36411090Sandreas.sandberg@arm.com    class DmaEngine : public DmaReadFifo
3659646SChris.Emmons@arm.com    {
36611090Sandreas.sandberg@arm.com      public:
36711090Sandreas.sandberg@arm.com        DmaEngine(HDLcd &_parent, size_t size,
36811090Sandreas.sandberg@arm.com                  unsigned request_size, unsigned max_pending,
36911090Sandreas.sandberg@arm.com                  size_t line_size, ssize_t line_pitch, unsigned num_lines);
3709646SChris.Emmons@arm.com
37111090Sandreas.sandberg@arm.com        void startFrame(Addr fb_base);
37211090Sandreas.sandberg@arm.com        void abortFrame();
37311090Sandreas.sandberg@arm.com        void dumpSettings();
3749646SChris.Emmons@arm.com
37511168Sandreas.hansson@arm.com        void serialize(CheckpointOut &cp) const override;
37611168Sandreas.hansson@arm.com        void unserialize(CheckpointIn &cp) override;
3779646SChris.Emmons@arm.com
37811090Sandreas.sandberg@arm.com      protected:
37911168Sandreas.hansson@arm.com        void onEndOfBlock() override;
38011168Sandreas.hansson@arm.com        void onIdle() override;
3819646SChris.Emmons@arm.com
38211090Sandreas.sandberg@arm.com        HDLcd &parent;
38311090Sandreas.sandberg@arm.com        const size_t lineSize;
38411090Sandreas.sandberg@arm.com        const ssize_t linePitch;
38511090Sandreas.sandberg@arm.com        const unsigned numLines;
3869646SChris.Emmons@arm.com
38711090Sandreas.sandberg@arm.com        Addr nextLineAddr;
38811090Sandreas.sandberg@arm.com        Addr frameEnd;
3899646SChris.Emmons@arm.com    };
3909646SChris.Emmons@arm.com
39111090Sandreas.sandberg@arm.com    std::unique_ptr<DmaEngine> dmaEngine;
39211091Sandreas.sandberg@arm.com
39311091Sandreas.sandberg@arm.com  protected: // Statistics
39411091Sandreas.sandberg@arm.com    struct {
39511091Sandreas.sandberg@arm.com        Stats::Scalar underruns;
39611091Sandreas.sandberg@arm.com    } stats;
3979646SChris.Emmons@arm.com};
3989646SChris.Emmons@arm.com
3999646SChris.Emmons@arm.com#endif
400