hdlcd.hh revision 11898
17405SAli.Saidi@ARM.com/*
27405SAli.Saidi@ARM.com * Copyright (c) 2010-2013, 2015, 2017 ARM Limited
37405SAli.Saidi@ARM.com * All rights reserved
47405SAli.Saidi@ARM.com *
57405SAli.Saidi@ARM.com * The license below extends only to copyright in the software and shall
67405SAli.Saidi@ARM.com * not be construed as granting a license to any other intellectual
77405SAli.Saidi@ARM.com * property including but not limited to intellectual property relating
87405SAli.Saidi@ARM.com * to a hardware implementation of the functionality of the software
97405SAli.Saidi@ARM.com * licensed hereunder.  You may use the software subject to the license
107405SAli.Saidi@ARM.com * terms below provided that you ensure that this notice is replicated
117405SAli.Saidi@ARM.com * unmodified and in its entirety in all distributions of the software,
127405SAli.Saidi@ARM.com * modified or unmodified, in source code or in binary form.
137405SAli.Saidi@ARM.com *
147405SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without
157405SAli.Saidi@ARM.com * modification, are permitted provided that the following conditions are
167405SAli.Saidi@ARM.com * met: redistributions of source code must retain the above copyright
177405SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer;
187405SAli.Saidi@ARM.com * redistributions in binary form must reproduce the above copyright
197405SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer in the
207405SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution;
217405SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its
227405SAli.Saidi@ARM.com * contributors may be used to endorse or promote products derived from
237405SAli.Saidi@ARM.com * this software without specific prior written permission.
247405SAli.Saidi@ARM.com *
257405SAli.Saidi@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
267405SAli.Saidi@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
277405SAli.Saidi@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
287405SAli.Saidi@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
297405SAli.Saidi@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
307405SAli.Saidi@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
317405SAli.Saidi@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
327405SAli.Saidi@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
337405SAli.Saidi@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
347405SAli.Saidi@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
357405SAli.Saidi@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
367405SAli.Saidi@ARM.com *
377405SAli.Saidi@ARM.com * Authors: Chris Emmons
387405SAli.Saidi@ARM.com *          Andreas Sandberg
397405SAli.Saidi@ARM.com */
407405SAli.Saidi@ARM.com
417405SAli.Saidi@ARM.com
427405SAli.Saidi@ARM.com/** @file
437405SAli.Saidi@ARM.com * Implementiation of the ARM HDLcd controller.
447405SAli.Saidi@ARM.com *
457405SAli.Saidi@ARM.com * This implementation aims to have sufficient detail such that underrun
467427Sgblack@eecs.umich.edu * conditions are reasonable / behave similar to reality.  There are two
477427Sgblack@eecs.umich.edu * 'engines' going at once.  First, the DMA engine running at LCD clock
487427Sgblack@eecs.umich.edu * frequency is responsible for filling the controller's internal buffer.
497427Sgblack@eecs.umich.edu * The second engine runs at the pixel clock frequency and reads the pixels
507427Sgblack@eecs.umich.edu * out of the internal buffer.  The pixel rendering engine uses front / back
517427Sgblack@eecs.umich.edu * porch and sync delays between lines and frames.
527427Sgblack@eecs.umich.edu *
537427Sgblack@eecs.umich.edu * If the pixel rendering engine does not have a pixel to display, it will
547427Sgblack@eecs.umich.edu * cause an underrun event.  The HDLcd controller, per spec, will stop
557427Sgblack@eecs.umich.edu * issuing DMA requests for the rest of the frame and resume normal behavior
567427Sgblack@eecs.umich.edu * on the subsequent frame.  What pixels are rendered upon an underrun
577427Sgblack@eecs.umich.edu * condition is different than the real hardware; while the user will see
587427Sgblack@eecs.umich.edu * artifacts (previous frame mixed with current frame), it is not the same
597427Sgblack@eecs.umich.edu * behavior as real hardware which repeats the last pixel value for the rest
607427Sgblack@eecs.umich.edu * of the current frame.  This compromise was made to save on memory and
617427Sgblack@eecs.umich.edu * complexity and assumes that it is not important to accurately model the
627427Sgblack@eecs.umich.edu * content of an underrun frame.
637427Sgblack@eecs.umich.edu *
647427Sgblack@eecs.umich.edu * KNOWN ISSUES
657427Sgblack@eecs.umich.edu * <ul>
667427Sgblack@eecs.umich.edu *   <li>The HDLcd is implemented here as an AmbaDmaDevice, but it
677427Sgblack@eecs.umich.edu *       doesn't have an AMBA ID as far as I know.  That is the only
687427Sgblack@eecs.umich.edu *       bit of the AmbaDmaDevice interface that is irrelevant to it,
697427Sgblack@eecs.umich.edu *       so a fake AMBA ID is used for now.  I didn't think inserting
707427Sgblack@eecs.umich.edu *       an extra layer of hierachy between AmbaDmaDevice and
717427Sgblack@eecs.umich.edu *       DmaDevice would be helpful to anyone else, but that may be
727427Sgblack@eecs.umich.edu *       the right answer.
737427Sgblack@eecs.umich.edu * </ul>
747427Sgblack@eecs.umich.edu */
757427Sgblack@eecs.umich.edu
767427Sgblack@eecs.umich.edu#ifndef __DEV_ARM_HDLCD_HH__
777427Sgblack@eecs.umich.edu#define __DEV_ARM_HDLCD_HH__
787427Sgblack@eecs.umich.edu
797427Sgblack@eecs.umich.edu#include <fstream>
807427Sgblack@eecs.umich.edu#include <memory>
817427Sgblack@eecs.umich.edu
827427Sgblack@eecs.umich.edu#include "base/bitmap.hh"
837427Sgblack@eecs.umich.edu#include "base/framebuffer.hh"
847427Sgblack@eecs.umich.edu#include "base/output.hh"
857427Sgblack@eecs.umich.edu#include "dev/arm/amba_device.hh"
867427Sgblack@eecs.umich.edu#include "dev/pixelpump.hh"
877427Sgblack@eecs.umich.edu#include "sim/serialize.hh"
887427Sgblack@eecs.umich.edu
897427Sgblack@eecs.umich.educlass VncInput;
907427Sgblack@eecs.umich.edustruct HDLcdParams;
917427Sgblack@eecs.umich.educlass HDLcdPixelPump;
927427Sgblack@eecs.umich.edu
937427Sgblack@eecs.umich.educlass HDLcd: public AmbaDmaDevice
947427Sgblack@eecs.umich.edu{
957427Sgblack@eecs.umich.edu  public:
967427Sgblack@eecs.umich.edu    HDLcd(const HDLcdParams *p);
977427Sgblack@eecs.umich.edu    ~HDLcd();
987427Sgblack@eecs.umich.edu
997427Sgblack@eecs.umich.edu    void regStats() override;
1007427Sgblack@eecs.umich.edu
1017427Sgblack@eecs.umich.edu    void serialize(CheckpointOut &cp) const override;
1027427Sgblack@eecs.umich.edu    void unserialize(CheckpointIn &cp) override;
1037427Sgblack@eecs.umich.edu
1047427Sgblack@eecs.umich.edu    void drainResume() override;
1057427Sgblack@eecs.umich.edu
1067427Sgblack@eecs.umich.edu  public: // IO device interface
1077427Sgblack@eecs.umich.edu    Tick read(PacketPtr pkt) override;
1087427Sgblack@eecs.umich.edu    Tick write(PacketPtr pkt) override;
1097427Sgblack@eecs.umich.edu
1107427Sgblack@eecs.umich.edu    AddrRangeList getAddrRanges() const override { return addrRanges; }
1117427Sgblack@eecs.umich.edu
1127427Sgblack@eecs.umich.edu  protected: // Parameters
1137427Sgblack@eecs.umich.edu    VncInput *vnc;
1147427Sgblack@eecs.umich.edu    const bool workaroundSwapRB;
1157427Sgblack@eecs.umich.edu    const bool workaroundDmaLineCount;
1167427Sgblack@eecs.umich.edu    const AddrRangeList addrRanges;
1177427Sgblack@eecs.umich.edu    const bool enableCapture;
1187427Sgblack@eecs.umich.edu    const Addr pixelBufferSize;
1197427Sgblack@eecs.umich.edu    const Tick virtRefreshRate;
1207436Sdam.sunwoo@arm.com
1217436Sdam.sunwoo@arm.com  protected: // Register handling
1227436Sdam.sunwoo@arm.com    /** ARM HDLcd register offsets */
1237436Sdam.sunwoo@arm.com    enum RegisterOffset {
1247436Sdam.sunwoo@arm.com        Version          = 0x0000,
1257436Sdam.sunwoo@arm.com        Int_RawStat      = 0x0010,
1267436Sdam.sunwoo@arm.com        Int_Clear        = 0x0014,
1277436Sdam.sunwoo@arm.com        Int_Mask         = 0x0018,
1287436Sdam.sunwoo@arm.com        Int_Status       = 0x001C,
1297436Sdam.sunwoo@arm.com        Fb_Base          = 0x0100,
1307436Sdam.sunwoo@arm.com        Fb_Line_Length   = 0x0104,
1317436Sdam.sunwoo@arm.com        Fb_Line_Count    = 0x0108,
1327436Sdam.sunwoo@arm.com        Fb_Line_Pitch    = 0x010C,
1337436Sdam.sunwoo@arm.com        Bus_Options      = 0x0110,
1347436Sdam.sunwoo@arm.com        V_Sync           = 0x0200,
1357436Sdam.sunwoo@arm.com        V_Back_Porch     = 0x0204,
1367436Sdam.sunwoo@arm.com        V_Data           = 0x0208,
1377436Sdam.sunwoo@arm.com        V_Front_Porch    = 0x020C,
1387436Sdam.sunwoo@arm.com        H_Sync           = 0x0210,
1397436Sdam.sunwoo@arm.com        H_Back_Porch     = 0x0214,
1407436Sdam.sunwoo@arm.com        H_Data           = 0x0218,
1417436Sdam.sunwoo@arm.com        H_Front_Porch    = 0x021C,
1427436Sdam.sunwoo@arm.com        Polarities       = 0x0220,
1437436Sdam.sunwoo@arm.com        Command          = 0x0230,
1447436Sdam.sunwoo@arm.com        Pixel_Format     = 0x0240,
1457436Sdam.sunwoo@arm.com        Red_Select       = 0x0244,
1467436Sdam.sunwoo@arm.com        Green_Select     = 0x0248,
1477436Sdam.sunwoo@arm.com        Blue_Select      = 0x024C,
1487436Sdam.sunwoo@arm.com    };
1497436Sdam.sunwoo@arm.com
1507436Sdam.sunwoo@arm.com    /** Reset value for Bus_Options register */
1517436Sdam.sunwoo@arm.com    static constexpr size_t BUS_OPTIONS_RESETV = 0x408;
1527427Sgblack@eecs.umich.edu
1537427Sgblack@eecs.umich.edu    /** Reset value for Version register */
1547427Sgblack@eecs.umich.edu    static constexpr size_t VERSION_RESETV = 0x1CDC0000;
1557405SAli.Saidi@ARM.com
1567405SAli.Saidi@ARM.com    /** AXI port width in bytes */
1577405SAli.Saidi@ARM.com    static constexpr size_t AXI_PORT_WIDTH = 8;
1587405SAli.Saidi@ARM.com
1597405SAli.Saidi@ARM.com    /** max number of beats delivered in one dma burst */
1607405SAli.Saidi@ARM.com    static constexpr size_t MAX_BURST_LEN = 16;
1617405SAli.Saidi@ARM.com
1627405SAli.Saidi@ARM.com    /** Maximum number of bytes per pixel */
1637405SAli.Saidi@ARM.com    static constexpr size_t MAX_PIXEL_SIZE = 4;
1647405SAli.Saidi@ARM.com
1657405SAli.Saidi@ARM.com    /**
1667405SAli.Saidi@ARM.com     * @name RegisterFieldLayouts
1677405SAli.Saidi@ARM.com     * Bit layout declarations for multi-field registers.
1687405SAli.Saidi@ARM.com     */
1697405SAli.Saidi@ARM.com    /**@{*/
1707405SAli.Saidi@ARM.com    BitUnion32(VersionReg)
1717405SAli.Saidi@ARM.com        Bitfield<7,0>   version_minor;
1727405SAli.Saidi@ARM.com        Bitfield<15,8>  version_major;
1737405SAli.Saidi@ARM.com        Bitfield<31,16> product_id;
1747405SAli.Saidi@ARM.com    EndBitUnion(VersionReg)
1757405SAli.Saidi@ARM.com
1767405SAli.Saidi@ARM.com    static constexpr uint32_t INT_DMA_END = (1UL << 0);
1777405SAli.Saidi@ARM.com    static constexpr uint32_t INT_BUS_ERROR = (1UL << 1);
1787405SAli.Saidi@ARM.com    static constexpr uint32_t INT_VSYNC = (1UL << 2);
1797405SAli.Saidi@ARM.com    static constexpr uint32_t INT_UNDERRUN = (1UL << 3);
1807405SAli.Saidi@ARM.com
1817405SAli.Saidi@ARM.com    BitUnion32(FbLineCountReg)
1827405SAli.Saidi@ARM.com        Bitfield<11,0>  fb_line_count;
1837405SAli.Saidi@ARM.com        Bitfield<31,12> reserved_31_12;
1847405SAli.Saidi@ARM.com    EndBitUnion(FbLineCountReg)
1857405SAli.Saidi@ARM.com
1867405SAli.Saidi@ARM.com    BitUnion32(BusOptsReg)
1877405SAli.Saidi@ARM.com        Bitfield<4,0>   burst_len;
1887405SAli.Saidi@ARM.com        Bitfield<7,5>   reserved_7_5;
1897405SAli.Saidi@ARM.com        Bitfield<11,8>  max_outstanding;
1907405SAli.Saidi@ARM.com        Bitfield<31,12> reserved_31_12;
1917405SAli.Saidi@ARM.com    EndBitUnion(BusOptsReg)
1927405SAli.Saidi@ARM.com
1937405SAli.Saidi@ARM.com    BitUnion32(TimingReg)
1947405SAli.Saidi@ARM.com        Bitfield<11,0>  val;
1957405SAli.Saidi@ARM.com        Bitfield<31,12> reserved_31_12;
1967405SAli.Saidi@ARM.com    EndBitUnion(TimingReg)
1977405SAli.Saidi@ARM.com
1987405SAli.Saidi@ARM.com    BitUnion32(PolaritiesReg)
1997405SAli.Saidi@ARM.com        Bitfield<0>    vsync_polarity;
2007405SAli.Saidi@ARM.com        Bitfield<1>    hsync_polarity;
2017405SAli.Saidi@ARM.com        Bitfield<2>    dataen_polarity;
2027405SAli.Saidi@ARM.com        Bitfield<3>    data_polarity;
2037405SAli.Saidi@ARM.com        Bitfield<4>    pxlclk_polarity;
2047405SAli.Saidi@ARM.com        Bitfield<31,5> reserved_31_5;
2057405SAli.Saidi@ARM.com    EndBitUnion(PolaritiesReg)
2067405SAli.Saidi@ARM.com
2077405SAli.Saidi@ARM.com    BitUnion32(CommandReg)
2087405SAli.Saidi@ARM.com        Bitfield<0>    enable;
2097405SAli.Saidi@ARM.com        Bitfield<31,1> reserved_31_1;
2107405SAli.Saidi@ARM.com    EndBitUnion(CommandReg)
2117405SAli.Saidi@ARM.com
2127405SAli.Saidi@ARM.com    BitUnion32(PixelFormatReg)
2137405SAli.Saidi@ARM.com        Bitfield<2,0>  reserved_2_0;
2147405SAli.Saidi@ARM.com        Bitfield<4,3>  bytes_per_pixel;
2157405SAli.Saidi@ARM.com        Bitfield<30,5> reserved_30_5;
2167405SAli.Saidi@ARM.com        Bitfield<31>   big_endian;
2177405SAli.Saidi@ARM.com    EndBitUnion(PixelFormatReg)
2187405SAli.Saidi@ARM.com
2197405SAli.Saidi@ARM.com    BitUnion32(ColorSelectReg)
2207405SAli.Saidi@ARM.com        Bitfield<4,0>   offset;
2217405SAli.Saidi@ARM.com        Bitfield<7,5>   reserved_7_5;
2227405SAli.Saidi@ARM.com        Bitfield<11,8>  size;
2237405SAli.Saidi@ARM.com        Bitfield<15,12> reserved_15_12;
2247405SAli.Saidi@ARM.com        Bitfield<23,16> default_color;
2257405SAli.Saidi@ARM.com        Bitfield<31,24> reserved_31_24;
2267405SAli.Saidi@ARM.com    EndBitUnion(ColorSelectReg)
2277405SAli.Saidi@ARM.com    /**@}*/
2287405SAli.Saidi@ARM.com
2297405SAli.Saidi@ARM.com    /**
2307405SAli.Saidi@ARM.com     * @name HDLCDRegisters
2317405SAli.Saidi@ARM.com     * HDLCD register contents.
2327405SAli.Saidi@ARM.com     */
2337405SAli.Saidi@ARM.com    /**@{*/
2347405SAli.Saidi@ARM.com    const VersionReg version;       /**< Version register */
2357405SAli.Saidi@ARM.com    uint32_t int_rawstat;           /**< Interrupt raw status register */
2367405SAli.Saidi@ARM.com    uint32_t int_mask;              /**< Interrupt mask register */
2377405SAli.Saidi@ARM.com    uint32_t fb_base;               /**< Frame buffer base address register */
2387405SAli.Saidi@ARM.com    uint32_t fb_line_length;        /**< Frame buffer Line length register */
2397405SAli.Saidi@ARM.com    FbLineCountReg fb_line_count;   /**< Frame buffer Line count register */
2407405SAli.Saidi@ARM.com    int32_t fb_line_pitch;          /**< Frame buffer Line pitch register */
2417405SAli.Saidi@ARM.com    BusOptsReg bus_options;         /**< Bus options register */
2427405SAli.Saidi@ARM.com    TimingReg v_sync;               /**< Vertical sync width register */
2437405SAli.Saidi@ARM.com    TimingReg v_back_porch;         /**< Vertical back porch width register */
2447405SAli.Saidi@ARM.com    TimingReg v_data;               /**< Vertical data width register */
2457405SAli.Saidi@ARM.com    TimingReg v_front_porch;        /**< Vertical front porch width register */
2467405SAli.Saidi@ARM.com    TimingReg h_sync;               /**< Horizontal sync width register */
2477405SAli.Saidi@ARM.com    TimingReg h_back_porch;         /**< Horizontal back porch width register */
2487405SAli.Saidi@ARM.com    TimingReg h_data;               /**< Horizontal data width register */
2497405SAli.Saidi@ARM.com    TimingReg h_front_porch;        /**< Horizontal front porch width reg */
2507405SAli.Saidi@ARM.com    PolaritiesReg polarities;       /**< Polarities register */
2517405SAli.Saidi@ARM.com    CommandReg command;             /**< Command register */
2527405SAli.Saidi@ARM.com    PixelFormatReg pixel_format;    /**< Pixel format register */
2537405SAli.Saidi@ARM.com    ColorSelectReg red_select;      /**< Red color select register */
2547405SAli.Saidi@ARM.com    ColorSelectReg green_select;    /**< Green color select register */
2557405SAli.Saidi@ARM.com    ColorSelectReg blue_select;     /**< Blue color select register */
2567405SAli.Saidi@ARM.com    /** @} */
2577405SAli.Saidi@ARM.com
2587405SAli.Saidi@ARM.com    uint32_t readReg(Addr offset);
2597405SAli.Saidi@ARM.com    void writeReg(Addr offset, uint32_t value);
2607405SAli.Saidi@ARM.com
2617405SAli.Saidi@ARM.com    PixelConverter pixelConverter() const;
2627405SAli.Saidi@ARM.com    DisplayTimings displayTimings() const;
2637405SAli.Saidi@ARM.com
2647405SAli.Saidi@ARM.com    void createDmaEngine();
2657405SAli.Saidi@ARM.com
2667405SAli.Saidi@ARM.com    void cmdEnable();
2677405SAli.Saidi@ARM.com    void cmdDisable();
2687405SAli.Saidi@ARM.com
2697405SAli.Saidi@ARM.com    bool enabled() const { return command.enable; }
2707405SAli.Saidi@ARM.com
2717408Sgblack@eecs.umich.edu  public: // Pixel pump callbacks
2727405SAli.Saidi@ARM.com    bool pxlNext(Pixel &p);
2737405SAli.Saidi@ARM.com    void pxlVSyncBegin();
2747405SAli.Saidi@ARM.com    void pxlVSyncEnd();
2757408Sgblack@eecs.umich.edu    void pxlUnderrun();
2767408Sgblack@eecs.umich.edu    void pxlFrameDone();
2777408Sgblack@eecs.umich.edu
2787408Sgblack@eecs.umich.edu  protected: // Interrupt handling
2797408Sgblack@eecs.umich.edu    /**
2807408Sgblack@eecs.umich.edu     * Assign new interrupt values and update interrupt signals
2817408Sgblack@eecs.umich.edu     *
2827408Sgblack@eecs.umich.edu     * A new interrupt is scheduled signalled if the set of unmasked
2837408Sgblack@eecs.umich.edu     * interrupts goes empty to non-empty. Conversely, if the set of
2847408Sgblack@eecs.umich.edu     * unmasked interrupts goes from non-empty to empty, the interrupt
2857408Sgblack@eecs.umich.edu     * signal is cleared.
2867408Sgblack@eecs.umich.edu     *
2877405SAli.Saidi@ARM.com     * @param ints New <i>raw</i> interrupt status
2887408Sgblack@eecs.umich.edu     * @param mask New interrupt mask
2897408Sgblack@eecs.umich.edu     */
2907408Sgblack@eecs.umich.edu    void setInterrupts(uint32_t ints, uint32_t mask);
2917408Sgblack@eecs.umich.edu
2927408Sgblack@eecs.umich.edu    /**
2937408Sgblack@eecs.umich.edu     * Convenience function to update the interrupt mask
2947408Sgblack@eecs.umich.edu     *
2957408Sgblack@eecs.umich.edu     * @see setInterrupts
2967408Sgblack@eecs.umich.edu     * @param mask New interrupt mask
2977408Sgblack@eecs.umich.edu     */
2987408Sgblack@eecs.umich.edu    void intMask(uint32_t mask) { setInterrupts(int_rawstat, mask); }
2997408Sgblack@eecs.umich.edu
3007408Sgblack@eecs.umich.edu    /**
3017408Sgblack@eecs.umich.edu     * Convenience function to raise a new interrupt
3027408Sgblack@eecs.umich.edu     *
3037408Sgblack@eecs.umich.edu     * @see setInterrupts
3047408Sgblack@eecs.umich.edu     * @param ints Set of interrupts to raise
3057408Sgblack@eecs.umich.edu     */
3067408Sgblack@eecs.umich.edu    void intRaise(uint32_t ints) {
3077408Sgblack@eecs.umich.edu        setInterrupts(int_rawstat | ints, int_mask);
3087408Sgblack@eecs.umich.edu    }
3097408Sgblack@eecs.umich.edu
3107408Sgblack@eecs.umich.edu    /**
3117408Sgblack@eecs.umich.edu     * Convenience function to clear interrupts
3127408Sgblack@eecs.umich.edu     *
3137408Sgblack@eecs.umich.edu     * @see setInterrupts
3147408Sgblack@eecs.umich.edu     * @param ints Set of interrupts to clear
3157408Sgblack@eecs.umich.edu     */
3167408Sgblack@eecs.umich.edu    void intClear(uint32_t ints) {
3177408Sgblack@eecs.umich.edu        setInterrupts(int_rawstat & ~ints, int_mask);
3187408Sgblack@eecs.umich.edu    }
3197408Sgblack@eecs.umich.edu
3207408Sgblack@eecs.umich.edu    /** Masked interrupt status register */
3217408Sgblack@eecs.umich.edu    uint32_t intStatus() const { return int_rawstat & int_mask; }
3227408Sgblack@eecs.umich.edu
3237408Sgblack@eecs.umich.edu  protected: // Pixel output
3247408Sgblack@eecs.umich.edu    class PixelPump : public BasePixelPump
3257408Sgblack@eecs.umich.edu    {
3267408Sgblack@eecs.umich.edu      public:
3277408Sgblack@eecs.umich.edu        PixelPump(HDLcd &p, ClockDomain &pxl_clk, unsigned pixel_chunk)
3287408Sgblack@eecs.umich.edu            : BasePixelPump(p, pxl_clk, pixel_chunk), parent(p) {}
3297408Sgblack@eecs.umich.edu
3307408Sgblack@eecs.umich.edu        void dumpSettings();
3317408Sgblack@eecs.umich.edu
3327408Sgblack@eecs.umich.edu      protected:
3337408Sgblack@eecs.umich.edu        bool nextPixel(Pixel &p) override { return parent.pxlNext(p); }
3347408Sgblack@eecs.umich.edu
3357408Sgblack@eecs.umich.edu        void onVSyncBegin() override { return parent.pxlVSyncBegin(); }
3367408Sgblack@eecs.umich.edu        void onVSyncEnd() override { return parent.pxlVSyncEnd(); }
3377408Sgblack@eecs.umich.edu
3387408Sgblack@eecs.umich.edu        void onUnderrun(unsigned x, unsigned y) override {
3397408Sgblack@eecs.umich.edu            parent.pxlUnderrun();
3407408Sgblack@eecs.umich.edu        }
3417408Sgblack@eecs.umich.edu
3427408Sgblack@eecs.umich.edu        void onFrameDone() override { parent.pxlFrameDone(); }
3437408Sgblack@eecs.umich.edu
3447408Sgblack@eecs.umich.edu      protected:
3457408Sgblack@eecs.umich.edu        HDLcd &parent;
3467408Sgblack@eecs.umich.edu    };
3477408Sgblack@eecs.umich.edu
3487408Sgblack@eecs.umich.edu    /** Handler for fast frame refresh in KVM-mode */
3497408Sgblack@eecs.umich.edu    void virtRefresh();
3507408Sgblack@eecs.umich.edu    EventWrapper<HDLcd, &HDLcd::virtRefresh> virtRefreshEvent;
3517408Sgblack@eecs.umich.edu
3527408Sgblack@eecs.umich.edu    /** Helper to write out bitmaps */
3537408Sgblack@eecs.umich.edu    Bitmap bmp;
3547408Sgblack@eecs.umich.edu
3557408Sgblack@eecs.umich.edu    /** Picture of what the current frame buffer looks like */
3567408Sgblack@eecs.umich.edu    OutputStream *pic;
3577408Sgblack@eecs.umich.edu
3587408Sgblack@eecs.umich.edu    /** Cached pixel converter, set when the converter is enabled. */
3597408Sgblack@eecs.umich.edu    PixelConverter conv;
3607408Sgblack@eecs.umich.edu
3617408Sgblack@eecs.umich.edu    PixelPump pixelPump;
3627408Sgblack@eecs.umich.edu
3637408Sgblack@eecs.umich.edu  protected: // DMA handling
3647408Sgblack@eecs.umich.edu    class DmaEngine : public DmaReadFifo
3657408Sgblack@eecs.umich.edu    {
3667408Sgblack@eecs.umich.edu      public:
3677408Sgblack@eecs.umich.edu        DmaEngine(HDLcd &_parent, size_t size,
3687408Sgblack@eecs.umich.edu                  unsigned request_size, unsigned max_pending,
3697408Sgblack@eecs.umich.edu                  size_t line_size, ssize_t line_pitch, unsigned num_lines);
3707408Sgblack@eecs.umich.edu
3717408Sgblack@eecs.umich.edu        void startFrame(Addr fb_base);
3727408Sgblack@eecs.umich.edu        void abortFrame();
3737408Sgblack@eecs.umich.edu        void dumpSettings();
3747408Sgblack@eecs.umich.edu
3757408Sgblack@eecs.umich.edu        void serialize(CheckpointOut &cp) const override;
3767408Sgblack@eecs.umich.edu        void unserialize(CheckpointIn &cp) override;
3777408Sgblack@eecs.umich.edu
3787408Sgblack@eecs.umich.edu      protected:
3797408Sgblack@eecs.umich.edu        void onEndOfBlock() override;
3807408Sgblack@eecs.umich.edu        void onIdle() override;
3817408Sgblack@eecs.umich.edu
3827408Sgblack@eecs.umich.edu        HDLcd &parent;
3837408Sgblack@eecs.umich.edu        const size_t lineSize;
3847408Sgblack@eecs.umich.edu        const ssize_t linePitch;
3857408Sgblack@eecs.umich.edu        const unsigned numLines;
3867408Sgblack@eecs.umich.edu
3877408Sgblack@eecs.umich.edu        Addr nextLineAddr;
3887408Sgblack@eecs.umich.edu        Addr frameEnd;
3897408Sgblack@eecs.umich.edu    };
3907408Sgblack@eecs.umich.edu
3917408Sgblack@eecs.umich.edu    std::unique_ptr<DmaEngine> dmaEngine;
3927408Sgblack@eecs.umich.edu
3937408Sgblack@eecs.umich.edu  protected: // Statistics
3947408Sgblack@eecs.umich.edu    struct {
3957408Sgblack@eecs.umich.edu        Stats::Scalar underruns;
3967405SAli.Saidi@ARM.com    } stats;
3977436Sdam.sunwoo@arm.com};
3987436Sdam.sunwoo@arm.com
3997436Sdam.sunwoo@arm.com#endif
4007436Sdam.sunwoo@arm.com