gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  * Authors: Andreas Sandberg
38  */
39 
40 #ifndef __DEV_PIXELPUMP_HH__
41 #define __DEV_PIXELPUMP_HH__
42 
43 #include "base/framebuffer.hh"
44 #include "sim/clocked_object.hh"
45 
46 struct BasePixelPumpParams;
47 
49 {
62  DisplayTimings(unsigned width, unsigned height,
63  unsigned hbp, unsigned h_sync, unsigned hfp,
64  unsigned vbp, unsigned v_sync, unsigned vfp);
65 
66  void serialize(CheckpointOut &cp) const override;
67  void unserialize(CheckpointIn &cp) override;
68 
71  return Cycles(hSync + hBackPorch + width + hBackPorch);
72  }
73 
76  return Cycles(cyclesPerLine() * linesPerFrame());
77  }
78 
80  unsigned lineVSyncStart() const {
81  return 0;
82  }
83 
85  unsigned lineVBackPorchStart() const {
86  return lineVSyncStart() + vSync;
87  }
88 
90  unsigned lineFirstVisible() const {
92  }
93 
95  unsigned lineFrontPorchStart() const {
96  return lineFirstVisible() + height;
97  }
98 
100  unsigned linesPerFrame() const {
101  return lineFrontPorchStart() + vFrontPorch;
102  }
103 
105  unsigned width;
107  unsigned height;
108 
110  unsigned hBackPorch;
112  unsigned hFrontPorch;
114  unsigned hSync;
115 
117  unsigned vBackPorch;
119  unsigned vFrontPorch;
121  unsigned vSync;
122 
123  static const DisplayTimings vga;
124 };
125 
147  : public EventManager, public Clocked,
148  public Serializable
149 {
150  public:
152  unsigned pixel_chunk);
153  virtual ~BasePixelPump();
154 
155  void serialize(CheckpointOut &cp) const override;
156  void unserialize(CheckpointIn &cp) override;
157 
158  public: // Public API
160  void updateTimings(const DisplayTimings &timings);
161 
163  void renderFrame();
164 
166  void start();
167 
169  void stop();
170 
172  const DisplayTimings &timings() const { return _timings; }
173 
175  bool active() const { return evBeginLine.active(); }
176 
178  bool underrun() const { return _underrun; }
179 
181  bool visibleLine() const {
182  return line >= _timings.lineFirstVisible() &&
184  }
185 
187  unsigned posX() const { return _posX; }
188 
190  unsigned posY() const {
191  return visibleLine() ? line - _timings.lineFirstVisible() : 0;
192  }
193 
196 
197  protected: // Callbacks
204  virtual bool nextPixel(Pixel &p) = 0;
205 
207  virtual void onVSyncBegin() {};
208 
213  virtual void onVSyncEnd() {};
214 
221  virtual void onHSyncBegin() {};
222 
229  virtual void onHSyncEnd() {};
230 
241  virtual void onUnderrun(unsigned x, unsigned y) {};
242 
244  virtual void onFrameDone() {};
245 
246  private: // Params
248  const unsigned pixelChunk;
249 
250  private:
260  class PixelEvent : public Event, public Drainable
261  {
262  typedef void (BasePixelPump::* CallbackType)();
263 
264  public:
266 
267  DrainState drain() override;
268  void drainResume() override;
269 
270  void serialize(CheckpointOut &cp) const override;
271  void unserialize(CheckpointIn &cp) override;
272 
273  const std::string name() const override { return _name; }
274  void process() override {
275  (parent.*func)();
276  }
277 
278  bool active() const { return scheduled() || suspended; }
279 
280  private:
281  void suspend();
282  void resume();
283 
284  const std::string _name;
287 
288  bool suspended;
290  };
291 
292  void beginLine();
293  void renderPixels();
294 
296  void renderLine();
297 
300 
307 
309 
314  unsigned line;
316  unsigned _posX;
317 
319  bool _underrun;
320 };
321 
322 #endif // __DEV_PIXELPUMP_HH__
unsigned vSync
Vertical sync signal in lines.
Definition: pixelpump.hh:121
std::vector< PixelEvent * > pixelEvents
Convenience vector when doing operations on all events.
Definition: pixelpump.hh:299
Timing generator for a pixel-based display.
Definition: pixelpump.hh:146
void(BasePixelPump::* CallbackType)()
Definition: pixelpump.hh:262
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
unsigned lineFrontPorchStart() const
Calculate the first line of the back porch.
Definition: pixelpump.hh:95
Internal gem5 representation of a frame buffer.
Definition: framebuffer.hh:244
virtual void onFrameDone()
Finished displaying the visible region of a frame.
Definition: pixelpump.hh:244
void beginLine()
Definition: pixelpump.cc:182
bool _underrun
Did a buffer underrun occur within this refresh interval?
Definition: pixelpump.hh:319
DrainState
Object drain/handover states.
Definition: drain.hh:71
virtual void onHSyncBegin()
Start of the HSync region.
Definition: pixelpump.hh:221
void process() override
Definition: pixelpump.hh:274
DrainState drain() override
Notify an object that it needs to drain its state.
Definition: pixelpump.cc:310
unsigned line
Current line (including back porch, front porch, and vsync) within a frame.
Definition: pixelpump.hh:314
bool scheduled() const
Determine if the current event is scheduled.
Definition: eventq.hh:381
unsigned posY() const
Current pixel position within the visible area.
Definition: pixelpump.hh:190
Bitfield< 2 > em
Definition: misc.hh:603
void stop()
Immediately stop pushing pixels.
Definition: pixelpump.cc:163
unsigned hBackPorch
Horizontal back porch in pixels.
Definition: pixelpump.hh:110
void renderLine()
Fast and event-free line rendering function.
Definition: pixelpump.cc:284
unsigned linesPerFrame() const
Calculate the total number of lines in a frame.
Definition: pixelpump.hh:100
unsigned vFrontPorch
Vertical front porch in lines.
Definition: pixelpump.hh:119
Cycles cyclesPerLine() const
How many pixel clocks are required for one line?
Definition: pixelpump.hh:70
void start()
Starting pushing pixels in timing mode.
Definition: pixelpump.cc:156
unsigned posX() const
Current pixel position within the visible area.
Definition: pixelpump.hh:187
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pixelpump.cc:123
STL vector class.
Definition: stl.hh:40
const std::string _name
Definition: pixelpump.hh:284
PixelEvent(const char *name, BasePixelPump *parent, CallbackType func)
Definition: pixelpump.cc:299
const std::string name() const override
Definition: pixelpump.hh:273
BasePixelPump(EventManager &em, ClockDomain &pxl_clk, unsigned pixel_chunk)
Definition: pixelpump.cc:88
Callback helper class with suspend support.
Definition: pixelpump.hh:260
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:223
DisplayTimings _timings
Definition: pixelpump.hh:308
virtual void onUnderrun(unsigned x, unsigned y)
Buffer underrun occurred on a frame.
Definition: pixelpump.hh:241
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pixelpump.cc:334
bool active() const
Is the pixel pump active and refreshing the display?
Definition: pixelpump.hh:175
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pixelpump.cc:109
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:213
void renderFrame()
Render an entire frame in KVM execution mode.
Definition: pixelpump.cc:252
virtual void onHSyncEnd()
Start of the first pixel after the HSync region.
Definition: pixelpump.hh:229
void renderPixels()
Definition: pixelpump.cc:215
uint64_t Tick
Tick count type.
Definition: types.hh:63
BasePixelPump & parent
Definition: pixelpump.hh:285
PixelEvent evHSyncEnd
Definition: pixelpump.hh:304
bool visibleLine() const
Is the current line within the visible range?
Definition: pixelpump.hh:181
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: pixelpump.cc:73
PixelEvent evVSyncEnd
Definition: pixelpump.hh:302
ClockedObject declaration and implementation.
unsigned _posX
X-coordinate within the visible region of a frame.
Definition: pixelpump.hh:316
void updateTimings(const DisplayTimings &timings)
Update frame size using display timing.
Definition: pixelpump.cc:140
FrameBuffer fb
Output frame buffer.
Definition: pixelpump.hh:195
virtual void onVSyncBegin()
First pixel clock of the first VSync line.
Definition: pixelpump.hh:207
Helper class for objects that need to be clocked.
PixelEvent evVSyncBegin
Definition: pixelpump.hh:301
unsigned height
Display height in pixels.
Definition: pixelpump.hh:107
Basic support for object serialization.
Definition: serialize.hh:220
PixelEvent evRenderPixels
Definition: pixelpump.hh:306
const unsigned pixelChunk
Maximum number of pixels to handle per render callback.
Definition: pixelpump.hh:244
bool underrun() const
Did a buffer underrun occur within this refresh interval?
Definition: pixelpump.hh:178
PixelEvent evBeginLine
Definition: pixelpump.hh:305
unsigned hFrontPorch
Horizontal front porch in pixels.
Definition: pixelpump.hh:112
PixelEvent evHSyncBegin
Definition: pixelpump.hh:303
unsigned lineFirstVisible() const
Calculate the first line of the visible region.
Definition: pixelpump.hh:90
unsigned hSync
Horizontal sync signal length in pixels.
Definition: pixelpump.hh:114
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pixelpump.cc:58
The ClockDomain provides clock to group of clocked objects bundled under the same clock domain...
Definition: clock_domain.hh:73
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: pixelpump.cc:325
std::ostream CheckpointOut
Definition: serialize.hh:67
Cycles cyclesPerFrame() const
How many pixel clocks are required for one frame?
Definition: pixelpump.hh:75
Definition: eventq.hh:185
const CallbackType func
Definition: pixelpump.hh:286
unsigned vBackPorch
Vertical back porch in lines.
Definition: pixelpump.hh:117
static const DisplayTimings vga
Definition: pixelpump.hh:123
virtual bool nextPixel(Pixel &p)=0
Get the next pixel from the scan line buffer.
Internal gem5 representation of a Pixel.
Definition: framebuffer.hh:58
unsigned lineVBackPorchStart() const
Calculate the first line of the vertical back porch.
Definition: pixelpump.hh:85
unsigned lineVSyncStart() const
Calculate the first line of the vsync signal.
Definition: pixelpump.hh:80
Bitfield< 0 > p
Bitfield< 1 > x
Definition: types.hh:105
void drainResume() override
Resume execution after a successful drain.
Definition: pixelpump.cc:318
unsigned width
Display width in pixels.
Definition: pixelpump.hh:105
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:48
const DisplayTimings & timings() const
Get a constant reference of the current display timings.
Definition: pixelpump.hh:172
virtual ~BasePixelPump()
Definition: pixelpump.cc:104

Generated on Fri Jun 9 2017 13:03:46 for gem5 by doxygen 1.8.6