gem5  v21.1.0.2
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 <vector>
42 
43 #include "base/framebuffer.hh"
44 #include "sim/clocked_object.hh"
45 
46 namespace gem5
47 {
48 
49 struct BasePixelPumpParams;
50 
52 {
65  DisplayTimings(unsigned width, unsigned height,
66  unsigned hbp, unsigned h_sync, unsigned hfp,
67  unsigned vbp, unsigned v_sync, unsigned vfp);
68 
69  void serialize(CheckpointOut &cp) const override;
70  void unserialize(CheckpointIn &cp) override;
71 
73  Cycles
74  cyclesPerLine() const
75  {
76  return Cycles(hSync + hBackPorch + width + hBackPorch);
77  }
78 
80  Cycles
82  {
83  return Cycles(cyclesPerLine() * linesPerFrame());
84  }
85 
87  unsigned
89  {
90  return 0;
91  }
92 
94  unsigned
96  {
97  return lineVSyncStart() + vSync;
98  }
99 
101  unsigned
103  {
104  return lineVBackPorchStart() + vBackPorch;
105  }
106 
108  unsigned
110  {
111  return lineFirstVisible() + height;
112  }
113 
115  unsigned
117  {
118  return lineFrontPorchStart() + vFrontPorch;
119  }
120 
122  unsigned width;
124  unsigned height;
125 
127  unsigned hBackPorch;
129  unsigned hFrontPorch;
131  unsigned hSync;
132 
134  unsigned vBackPorch;
136  unsigned vFrontPorch;
138  unsigned vSync;
139 
140  static const DisplayTimings vga;
141 };
142 
164  : public EventManager, public Clocked,
165  public Serializable
166 {
167  public:
169  unsigned pixel_chunk);
170  virtual ~BasePixelPump();
171 
172  void serialize(CheckpointOut &cp) const override;
173  void unserialize(CheckpointIn &cp) override;
174 
175  public: // Public API
177  void updateTimings(const DisplayTimings &timings);
178 
180  void renderFrame();
181 
183  void start();
184 
186  void stop();
187 
189  const DisplayTimings &timings() const { return _timings; }
190 
192  bool active() const { return evBeginLine.active(); }
193 
195  bool underrun() const { return _underrun; }
196 
198  bool
199  visibleLine() const
200  {
201  return line >= _timings.lineFirstVisible() &&
203  }
204 
206  unsigned posX() const { return _posX; }
207 
209  unsigned
210  posY() const
211  {
212  return visibleLine() ? line - _timings.lineFirstVisible() : 0;
213  }
214 
217 
218  protected: // Callbacks
225  virtual bool nextPixel(Pixel &p) = 0;
226 
240  virtual size_t
242  {
243  size_t count = 0;
244  while (count < line_length && nextPixel(*ps++))
245  count++;
246  return count;
247  }
248 
250  virtual void onVSyncBegin() {};
251 
256  virtual void onVSyncEnd() {};
257 
264  virtual void onHSyncBegin() {};
265 
272  virtual void onHSyncEnd() {};
273 
284  virtual void onUnderrun(unsigned x, unsigned y) {};
285 
287  virtual void onFrameDone() {};
288 
289  private: // Params
291  const unsigned pixelChunk;
292 
293  private:
303  class PixelEvent : public Event, public Drainable
304  {
305  typedef void (BasePixelPump::* CallbackType)();
306 
307  public:
309 
310  DrainState drain() override;
311  void drainResume() override;
312 
313  void serialize(CheckpointOut &cp) const override;
314  void unserialize(CheckpointIn &cp) override;
315 
316  const std::string name() const override { return _name; }
317 
318  void
319  process() override
320  {
321  (parent.*func)();
322  }
323 
324  bool active() const { return scheduled() || suspended; }
325 
326  private:
327  void suspend();
328  void resume();
329 
330  const std::string _name;
333 
334  bool suspended;
336  };
337 
338  void beginLine();
339  void renderPixels();
340 
342  void renderLine();
343 
346 
353 
355 
360  unsigned line;
362  unsigned _posX;
363 
365  bool _underrun;
366 };
367 
368 } // namespace gem5
369 
370 #endif // __DEV_PIXELPUMP_HH__
gem5::BasePixelPump::stop
void stop()
Immediately stop pushing pixels.
Definition: pixelpump.cc:166
gem5::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:256
gem5::BasePixelPump::BasePixelPump
BasePixelPump(EventManager &em, ClockDomain &pxl_clk, unsigned pixel_chunk)
Definition: pixelpump.cc:91
gem5::DisplayTimings::vSync
unsigned vSync
Vertical sync signal in lines.
Definition: pixelpump.hh:138
gem5::DisplayTimings::cyclesPerLine
Cycles cyclesPerLine() const
How many pixel clocks are required for one line?
Definition: pixelpump.hh:74
gem5::BasePixelPump::PixelEvent::name
const std::string name() const override
Definition: pixelpump.hh:316
gem5::BasePixelPump::_underrun
bool _underrun
Did a buffer underrun occur within this refresh interval?
Definition: pixelpump.hh:365
gem5::FrameBuffer
Internal gem5 representation of a frame buffer.
Definition: framebuffer.hh:68
gem5::BasePixelPump::underrun
bool underrun() const
Did a buffer underrun occur within this refresh interval?
Definition: pixelpump.hh:195
gem5::BasePixelPump::pixelEvents
std::vector< PixelEvent * > pixelEvents
Convenience vector when doing operations on all events.
Definition: pixelpump.hh:345
gem5::DisplayTimings::lineVSyncStart
unsigned lineVSyncStart() const
Calculate the first line of the vsync signal.
Definition: pixelpump.hh:88
gem5::BasePixelPump::evHSyncEnd
PixelEvent evHSyncEnd
Definition: pixelpump.hh:350
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::BasePixelPump::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pixelpump.cc:126
gem5::BasePixelPump::renderLine
void renderLine()
Fast and event-free line rendering function.
Definition: pixelpump.cc:287
gem5::BasePixelPump::start
void start()
Starting pushing pixels in timing mode.
Definition: pixelpump.cc:159
gem5::BasePixelPump::renderFrame
void renderFrame()
Render an entire frame in non-caching mode.
Definition: pixelpump.cc:255
gem5::BasePixelPump::evBeginLine
PixelEvent evBeginLine
Definition: pixelpump.hh:351
gem5::DisplayTimings::vFrontPorch
unsigned vFrontPorch
Vertical front porch in lines.
Definition: pixelpump.hh:136
std::vector
STL vector class.
Definition: stl.hh:37
gem5::BasePixelPump::onFrameDone
virtual void onFrameDone()
Finished displaying the visible region of a frame.
Definition: pixelpump.hh:287
gem5::DisplayTimings::vga
static const DisplayTimings vga
Definition: pixelpump.hh:140
gem5::DisplayTimings::height
unsigned height
Display height in pixels.
Definition: pixelpump.hh:124
gem5::BasePixelPump::PixelEvent::suspended
bool suspended
Definition: pixelpump.hh:334
gem5::BasePixelPump::PixelEvent::func
const CallbackType func
Definition: pixelpump.hh:332
gem5::DisplayTimings::hBackPorch
unsigned hBackPorch
Horizontal back porch in pixels.
Definition: pixelpump.hh:127
gem5::BasePixelPump::renderPixels
void renderPixels()
Definition: pixelpump.cc:218
gem5::DisplayTimings
Definition: pixelpump.hh:51
gem5::BasePixelPump::PixelEvent::drainResume
void drainResume() override
Resume execution after a successful drain.
Definition: pixelpump.cc:317
gem5::BasePixelPump::PixelEvent::process
void process() override
Definition: pixelpump.hh:319
gem5::Clocked
Helper class for objects that need to be clocked.
Definition: clocked_object.hh:62
gem5::BasePixelPump::PixelEvent
Callback helper class with suspend support.
Definition: pixelpump.hh:303
gem5::Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:78
gem5::BasePixelPump::onVSyncBegin
virtual void onVSyncBegin()
First pixel clock of the first VSync line.
Definition: pixelpump.hh:250
gem5::BasePixelPump::nextLine
virtual size_t nextLine(std::vector< Pixel >::iterator ps, size_t line_length)
Get the next line of pixels directly from memory.
Definition: pixelpump.hh:241
gem5::DisplayTimings::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pixelpump.cc:61
gem5::X86ISA::em
Bitfield< 2 > em
Definition: misc.hh:608
gem5::BasePixelPump::PixelEvent::suspend
void suspend()
Definition: pixelpump.cc:342
gem5::EventManager
Definition: eventq.hh:987
gem5::Serializable
Basic support for object serialization.
Definition: serialize.hh:169
gem5::BasePixelPump::PixelEvent::resume
void resume()
Definition: pixelpump.cc:353
gem5::DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:74
gem5::DisplayTimings::linesPerFrame
unsigned linesPerFrame() const
Calculate the total number of lines in a frame.
Definition: pixelpump.hh:116
gem5::ClockDomain
The ClockDomain provides clock to group of clocked objects bundled under the same clock domain.
Definition: clock_domain.hh:71
gem5::Event
Definition: eventq.hh:251
gem5::X86ISA::count
count
Definition: misc.hh:709
gem5::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:51
gem5::BasePixelPump::pixelChunk
const unsigned pixelChunk
Maximum number of pixels to handle per render callback.
Definition: pixelpump.hh:287
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::BasePixelPump::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pixelpump.cc:112
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::BasePixelPump::PixelEvent::PixelEvent
PixelEvent(const char *name, BasePixelPump *parent, CallbackType func)
Definition: pixelpump.cc:298
gem5::BasePixelPump::evVSyncBegin
PixelEvent evVSyncBegin
Definition: pixelpump.hh:347
gem5::DisplayTimings::hSync
unsigned hSync
Horizontal sync signal length in pixels.
Definition: pixelpump.hh:131
gem5::BasePixelPump::updateTimings
void updateTimings(const DisplayTimings &timings)
Update frame size using display timing.
Definition: pixelpump.cc:143
gem5::BasePixelPump::timings
const DisplayTimings & timings() const
Get a constant reference of the current display timings.
Definition: pixelpump.hh:189
gem5::DisplayTimings::lineFrontPorchStart
unsigned lineFrontPorchStart() const
Calculate the first line of the back porch.
Definition: pixelpump.hh:109
gem5::DisplayTimings::cyclesPerFrame
Cycles cyclesPerFrame() const
How many pixel clocks are required for one frame?
Definition: pixelpump.hh:81
gem5::BasePixelPump::onHSyncBegin
virtual void onHSyncBegin()
Start of the HSync region.
Definition: pixelpump.hh:264
gem5::DisplayTimings::hFrontPorch
unsigned hFrontPorch
Horizontal front porch in pixels.
Definition: pixelpump.hh:129
gem5::BasePixelPump::_timings
DisplayTimings _timings
Definition: pixelpump.hh:354
gem5::BasePixelPump::PixelEvent::CallbackType
void(BasePixelPump::* CallbackType)()
Definition: pixelpump.hh:305
gem5::BasePixelPump::visibleLine
bool visibleLine() const
Is the current line within the visible range?
Definition: pixelpump.hh:199
gem5::DisplayTimings::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pixelpump.cc:76
framebuffer.hh
gem5::BasePixelPump::active
bool active() const
Is the pixel pump active and refreshing the display?
Definition: pixelpump.hh:192
gem5::Pixel
Internal gem5 representation of a Pixel.
Definition: pixel.hh:58
gem5::DisplayTimings::width
unsigned width
Display width in pixels.
Definition: pixelpump.hh:122
gem5::BasePixelPump::nextPixel
virtual bool nextPixel(Pixel &p)=0
Get the next pixel from the scan line buffer.
gem5::BasePixelPump::PixelEvent::active
bool active() const
Definition: pixelpump.hh:324
gem5::DisplayTimings::vBackPorch
unsigned vBackPorch
Vertical back porch in lines.
Definition: pixelpump.hh:134
gem5::BasePixelPump::PixelEvent::_name
const std::string _name
Definition: pixelpump.hh:330
gem5::BasePixelPump::onHSyncEnd
virtual void onHSyncEnd()
Start of the first pixel after the HSync region.
Definition: pixelpump.hh:272
gem5::BasePixelPump::line
unsigned line
Current line (including back porch, front porch, and vsync) within a frame.
Definition: pixelpump.hh:360
gem5::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:309
gem5::BasePixelPump::PixelEvent::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pixelpump.cc:333
gem5::BasePixelPump::PixelEvent::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pixelpump.cc:324
gem5::BasePixelPump::_posX
unsigned _posX
X-coordinate within the visible region of a frame.
Definition: pixelpump.hh:362
gem5::RiscvISA::x
Bitfield< 3 > x
Definition: pagetable.hh:73
gem5::BasePixelPump::evVSyncEnd
PixelEvent evVSyncEnd
Definition: pixelpump.hh:348
clocked_object.hh
gem5::ArmISA::ps
Bitfield< 18, 16 > ps
Definition: misc_types.hh:513
gem5::BasePixelPump::PixelEvent::relativeTick
Tick relativeTick
Definition: pixelpump.hh:335
gem5::Drainable
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:234
gem5::BasePixelPump::PixelEvent::parent
BasePixelPump & parent
Definition: pixelpump.hh:331
gem5::BasePixelPump::evRenderPixels
PixelEvent evRenderPixels
Definition: pixelpump.hh:352
gem5::BasePixelPump::posY
unsigned posY() const
Current pixel position within the visible area.
Definition: pixelpump.hh:210
gem5::DisplayTimings::lineVBackPorchStart
unsigned lineVBackPorchStart() const
Calculate the first line of the vertical back porch.
Definition: pixelpump.hh:95
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::BasePixelPump::onUnderrun
virtual void onUnderrun(unsigned x, unsigned y)
Buffer underrun occurred on a frame.
Definition: pixelpump.hh:284
gem5::BasePixelPump::posX
unsigned posX() const
Current pixel position within the visible area.
Definition: pixelpump.hh:206
gem5::BasePixelPump::beginLine
void beginLine()
Definition: pixelpump.cc:185
gem5::BasePixelPump::evHSyncBegin
PixelEvent evHSyncBegin
Definition: pixelpump.hh:349
gem5::BasePixelPump::~BasePixelPump
virtual ~BasePixelPump()
Definition: pixelpump.cc:107
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::BasePixelPump
Timing generator for a pixel-based display.
Definition: pixelpump.hh:163
gem5::Event::scheduled
bool scheduled() const
Determine if the current event is scheduled.
Definition: eventq.hh:465
gem5::DisplayTimings::lineFirstVisible
unsigned lineFirstVisible() const
Calculate the first line of the visible region.
Definition: pixelpump.hh:102
gem5::BasePixelPump::fb
FrameBuffer fb
Output frame buffer.
Definition: pixelpump.hh:216

Generated on Tue Sep 21 2021 12:25:17 for gem5 by doxygen 1.8.17