gem5  v20.1.0.0
pixelpump.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, 2017 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
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __DEV_PIXELPUMP_HH__
39 #define __DEV_PIXELPUMP_HH__
40 
41 #include "base/framebuffer.hh"
42 #include "sim/clocked_object.hh"
43 
44 struct BasePixelPumpParams;
45 
47 {
60  DisplayTimings(unsigned width, unsigned height,
61  unsigned hbp, unsigned h_sync, unsigned hfp,
62  unsigned vbp, unsigned v_sync, unsigned vfp);
63 
64  void serialize(CheckpointOut &cp) const override;
65  void unserialize(CheckpointIn &cp) override;
66 
69  return Cycles(hSync + hBackPorch + width + hBackPorch);
70  }
71 
74  return Cycles(cyclesPerLine() * linesPerFrame());
75  }
76 
78  unsigned lineVSyncStart() const {
79  return 0;
80  }
81 
83  unsigned lineVBackPorchStart() const {
84  return lineVSyncStart() + vSync;
85  }
86 
88  unsigned lineFirstVisible() const {
90  }
91 
93  unsigned lineFrontPorchStart() const {
94  return lineFirstVisible() + height;
95  }
96 
98  unsigned linesPerFrame() const {
100  }
101 
103  unsigned width;
105  unsigned height;
106 
108  unsigned hBackPorch;
110  unsigned hFrontPorch;
112  unsigned hSync;
113 
115  unsigned vBackPorch;
117  unsigned vFrontPorch;
119  unsigned vSync;
120 
121  static const DisplayTimings vga;
122 };
123 
145  : public EventManager, public Clocked,
146  public Serializable
147 {
148  public:
150  unsigned pixel_chunk);
151  virtual ~BasePixelPump();
152 
153  void serialize(CheckpointOut &cp) const override;
154  void unserialize(CheckpointIn &cp) override;
155 
156  public: // Public API
158  void updateTimings(const DisplayTimings &timings);
159 
161  void renderFrame();
162 
164  void start();
165 
167  void stop();
168 
170  const DisplayTimings &timings() const { return _timings; }
171 
173  bool active() const { return evBeginLine.active(); }
174 
176  bool underrun() const { return _underrun; }
177 
179  bool visibleLine() const {
180  return line >= _timings.lineFirstVisible() &&
182  }
183 
185  unsigned posX() const { return _posX; }
186 
188  unsigned posY() const {
189  return visibleLine() ? line - _timings.lineFirstVisible() : 0;
190  }
191 
194 
195  protected: // Callbacks
202  virtual bool nextPixel(Pixel &p) = 0;
203 
205  virtual void onVSyncBegin() {};
206 
211  virtual void onVSyncEnd() {};
212 
219  virtual void onHSyncBegin() {};
220 
227  virtual void onHSyncEnd() {};
228 
239  virtual void onUnderrun(unsigned x, unsigned y) {};
240 
242  virtual void onFrameDone() {};
243 
244  private: // Params
246  const unsigned pixelChunk;
247 
248  private:
258  class PixelEvent : public Event, public Drainable
259  {
260  typedef void (BasePixelPump::* CallbackType)();
261 
262  public:
264 
265  DrainState drain() override;
266  void drainResume() override;
267 
268  void serialize(CheckpointOut &cp) const override;
269  void unserialize(CheckpointIn &cp) override;
270 
271  const std::string name() const override { return _name; }
272  void process() override {
273  (parent.*func)();
274  }
275 
276  bool active() const { return scheduled() || suspended; }
277 
278  private:
279  void suspend();
280  void resume();
281 
282  const std::string _name;
285 
286  bool suspended;
288  };
289 
290  void beginLine();
291  void renderPixels();
292 
294  void renderLine();
295 
298 
305 
307 
312  unsigned line;
314  unsigned _posX;
315 
317  bool _underrun;
318 };
319 
320 #endif // __DEV_PIXELPUMP_HH__
DisplayTimings::cyclesPerLine
Cycles cyclesPerLine() const
How many pixel clocks are required for one line?
Definition: pixelpump.hh:68
Event::scheduled
bool scheduled() const
Determine if the current event is scheduled.
Definition: eventq.hh:460
DisplayTimings::lineVSyncStart
unsigned lineVSyncStart() const
Calculate the first line of the vsync signal.
Definition: pixelpump.hh:78
BasePixelPump::PixelEvent::func
const CallbackType func
Definition: pixelpump.hh:284
BasePixelPump::BasePixelPump
BasePixelPump(EventManager &em, ClockDomain &pxl_clk, unsigned pixel_chunk)
Definition: pixelpump.cc:86
DisplayTimings::linesPerFrame
unsigned linesPerFrame() const
Calculate the total number of lines in a frame.
Definition: pixelpump.hh:98
Clocked
Helper class for objects that need to be clocked.
Definition: clocked_object.hh:59
BasePixelPump::_timings
DisplayTimings _timings
Definition: pixelpump.hh:306
DisplayTimings::vga
static const DisplayTimings vga
Definition: pixelpump.hh:121
BasePixelPump::evVSyncBegin
PixelEvent evVSyncBegin
Definition: pixelpump.hh:299
BasePixelPump::active
bool active() const
Is the pixel pump active and refreshing the display?
Definition: pixelpump.hh:173
DisplayTimings::cyclesPerFrame
Cycles cyclesPerFrame() const
How many pixel clocks are required for one frame?
Definition: pixelpump.hh:73
Serializable
Basic support for object serialization.
Definition: serialize.hh:172
DisplayTimings::vBackPorch
unsigned vBackPorch
Vertical back porch in lines.
Definition: pixelpump.hh:115
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
BasePixelPump::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pixelpump.cc:121
DisplayTimings::lineVBackPorchStart
unsigned lineVBackPorchStart() const
Calculate the first line of the vertical back porch.
Definition: pixelpump.hh:83
BasePixelPump::onHSyncBegin
virtual void onHSyncBegin()
Start of the HSync region.
Definition: pixelpump.hh:219
BasePixelPump::PixelEvent::drainResume
void drainResume() override
Resume execution after a successful drain.
Definition: pixelpump.cc:316
std::vector
STL vector class.
Definition: stl.hh:37
BasePixelPump::posX
unsigned posX() const
Current pixel position within the visible area.
Definition: pixelpump.hh:185
DisplayTimings::vFrontPorch
unsigned vFrontPorch
Vertical front porch in lines.
Definition: pixelpump.hh:117
BasePixelPump::evRenderPixels
PixelEvent evRenderPixels
Definition: pixelpump.hh:304
ClockDomain
The ClockDomain provides clock to group of clocked objects bundled under the same clock domain.
Definition: clock_domain.hh:68
BasePixelPump::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pixelpump.cc:107
BasePixelPump::pixelEvents
std::vector< PixelEvent * > pixelEvents
Convenience vector when doing operations on all events.
Definition: pixelpump.hh:297
BasePixelPump::evHSyncBegin
PixelEvent evHSyncBegin
Definition: pixelpump.hh:301
BasePixelPump
Timing generator for a pixel-based display.
Definition: pixelpump.hh:144
BasePixelPump::PixelEvent::active
bool active() const
Definition: pixelpump.hh:276
BasePixelPump::posY
unsigned posY() const
Current pixel position within the visible area.
Definition: pixelpump.hh:188
DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:71
BasePixelPump::beginLine
void beginLine()
Definition: pixelpump.cc:180
BasePixelPump::start
void start()
Starting pushing pixels in timing mode.
Definition: pixelpump.cc:154
BasePixelPump::onFrameDone
virtual void onFrameDone()
Finished displaying the visible region of a frame.
Definition: pixelpump.hh:242
cp
Definition: cprintf.cc:40
DisplayTimings::lineFrontPorchStart
unsigned lineFrontPorchStart() const
Calculate the first line of the back porch.
Definition: pixelpump.hh:93
BasePixelPump::PixelEvent
Callback helper class with suspend support.
Definition: pixelpump.hh:258
DisplayTimings::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pixelpump.cc:56
Drainable
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:230
Event
Definition: eventq.hh:246
DisplayTimings::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pixelpump.cc:71
BasePixelPump::PixelEvent::drain
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Definition: pixelpump.cc:308
DisplayTimings::hBackPorch
unsigned hBackPorch
Horizontal back porch in pixels.
Definition: pixelpump.hh:108
BasePixelPump::~BasePixelPump
virtual ~BasePixelPump()
Definition: pixelpump.cc:102
BasePixelPump::fb
FrameBuffer fb
Output frame buffer.
Definition: pixelpump.hh:193
BasePixelPump::nextPixel
virtual bool nextPixel(Pixel &p)=0
Get the next pixel from the scan line buffer.
X86ISA::em
Bitfield< 2 > em
Definition: misc.hh:602
DisplayTimings::width
unsigned width
Display width in pixels.
Definition: pixelpump.hh:103
BasePixelPump::onHSyncEnd
virtual void onHSyncEnd()
Start of the first pixel after the HSync region.
Definition: pixelpump.hh:227
RiscvISA::x
Bitfield< 3 > x
Definition: pagetable.hh:69
BasePixelPump::PixelEvent::resume
void resume()
Definition: pixelpump.cc:352
BasePixelPump::timings
const DisplayTimings & timings() const
Get a constant reference of the current display timings.
Definition: pixelpump.hh:170
Pixel
Internal gem5 representation of a Pixel.
Definition: pixel.hh:54
BasePixelPump::PixelEvent::suspend
void suspend()
Definition: pixelpump.cc:341
BasePixelPump::PixelEvent::CallbackType
void(BasePixelPump::* CallbackType)()
Definition: pixelpump.hh:260
BasePixelPump::updateTimings
void updateTimings(const DisplayTimings &timings)
Update frame size using display timing.
Definition: pixelpump.cc:138
framebuffer.hh
BasePixelPump::line
unsigned line
Current line (including back porch, front porch, and vsync) within a frame.
Definition: pixelpump.hh:312
DisplayTimings::height
unsigned height
Display height in pixels.
Definition: pixelpump.hh:105
BasePixelPump::onUnderrun
virtual void onUnderrun(unsigned x, unsigned y)
Buffer underrun occurred on a frame.
Definition: pixelpump.hh:239
BasePixelPump::PixelEvent::parent
BasePixelPump & parent
Definition: pixelpump.hh:283
DisplayTimings::lineFirstVisible
unsigned lineFirstVisible() const
Calculate the first line of the visible region.
Definition: pixelpump.hh:88
FrameBuffer
Internal gem5 representation of a frame buffer.
Definition: framebuffer.hh:65
BasePixelPump::PixelEvent::relativeTick
Tick relativeTick
Definition: pixelpump.hh:287
clocked_object.hh
BasePixelPump::renderPixels
void renderPixels()
Definition: pixelpump.cc:213
BasePixelPump::evVSyncEnd
PixelEvent evVSyncEnd
Definition: pixelpump.hh:300
BasePixelPump::evHSyncEnd
PixelEvent evHSyncEnd
Definition: pixelpump.hh:302
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
BasePixelPump::PixelEvent::name
const std::string name() const override
Definition: pixelpump.hh:271
DisplayTimings::hFrontPorch
unsigned hFrontPorch
Horizontal front porch in pixels.
Definition: pixelpump.hh:110
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
BasePixelPump::PixelEvent::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pixelpump.cc:323
EventManager
Definition: eventq.hh:973
DisplayTimings
Definition: pixelpump.hh:46
BasePixelPump::PixelEvent::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pixelpump.cc:332
BasePixelPump::PixelEvent::process
void process() override
Definition: pixelpump.hh:272
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
DisplayTimings::vSync
unsigned vSync
Vertical sync signal in lines.
Definition: pixelpump.hh:119
BasePixelPump::PixelEvent::_name
const std::string _name
Definition: pixelpump.hh:282
BasePixelPump::_posX
unsigned _posX
X-coordinate within the visible region of a frame.
Definition: pixelpump.hh:314
BasePixelPump::PixelEvent::PixelEvent
PixelEvent(const char *name, BasePixelPump *parent, CallbackType func)
Definition: pixelpump.cc:297
BasePixelPump::onVSyncBegin
virtual void onVSyncBegin()
First pixel clock of the first VSync line.
Definition: pixelpump.hh:205
CheckpointIn
Definition: serialize.hh:67
BasePixelPump::stop
void stop()
Immediately stop pushing pixels.
Definition: pixelpump.cc:161
BasePixelPump::visibleLine
bool visibleLine() const
Is the current line within the visible range?
Definition: pixelpump.hh:179
BasePixelPump::underrun
bool underrun() const
Did a buffer underrun occur within this refresh interval?
Definition: pixelpump.hh:176
DisplayTimings::DisplayTimings
DisplayTimings(unsigned width, unsigned height, unsigned hbp, unsigned h_sync, unsigned hfp, unsigned vbp, unsigned v_sync, unsigned vfp)
Create a display timing configuration struct.
Definition: pixelpump.cc:46
BasePixelPump::PixelEvent::suspended
bool suspended
Definition: pixelpump.hh:286
BasePixelPump::renderLine
void renderLine()
Fast and event-free line rendering function.
Definition: pixelpump.cc:282
BasePixelPump::onVSyncEnd
virtual void onVSyncEnd()
Callback on the first pixel of the line after the end VSync region (typically the first pixel of the ...
Definition: pixelpump.hh:211
BasePixelPump::renderFrame
void renderFrame()
Render an entire frame in KVM execution mode.
Definition: pixelpump.cc:250
BasePixelPump::pixelChunk
const unsigned pixelChunk
Maximum number of pixels to handle per render callback.
Definition: pixelpump.hh:242
BasePixelPump::_underrun
bool _underrun
Did a buffer underrun occur within this refresh interval?
Definition: pixelpump.hh:317
BasePixelPump::evBeginLine
PixelEvent evBeginLine
Definition: pixelpump.hh:303
DisplayTimings::hSync
unsigned hSync
Horizontal sync signal length in pixels.
Definition: pixelpump.hh:112

Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17