gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
46namespace gem5
47{
48
49struct 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
75 {
77 }
78
80 Cycles
82 {
84 }
85
87 unsigned
89 {
90 return 0;
91 }
92
94 unsigned
96 {
97 return lineVSyncStart() + vSync;
98 }
99
101 unsigned
103 {
105 }
106
108 unsigned
110 {
111 return lineFirstVisible() + height;
112 }
113
115 unsigned
117 {
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
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
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
336 };
337
338 void beginLine();
339 void renderPixels();
340
342 void renderLine();
343
346
353
355
360 unsigned line;
362 unsigned _posX;
363
366};
367
368} // namespace gem5
369
370#endif // __DEV_PIXELPUMP_HH__
Callback helper class with suspend support.
Definition pixelpump.hh:304
PixelEvent(const char *name, BasePixelPump *parent, CallbackType func)
Definition pixelpump.cc:298
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
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition pixelpump.cc:333
void drainResume() override
Resume execution after a successful drain.
Definition pixelpump.cc:317
void(BasePixelPump::* CallbackType)()
Definition pixelpump.hh:305
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition pixelpump.cc:324
const std::string name() const override
Definition pixelpump.hh:316
Timing generator for a pixel-based display.
Definition pixelpump.hh:166
void stop()
Immediately stop pushing pixels.
Definition pixelpump.cc:166
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition pixelpump.cc:126
PixelEvent evVSyncBegin
Definition pixelpump.hh:347
unsigned posX() const
Current pixel position within the visible area.
Definition pixelpump.hh:206
bool active() const
Is the pixel pump active and refreshing the display?
Definition pixelpump.hh:192
std::vector< PixelEvent * > pixelEvents
Convenience vector when doing operations on all events.
Definition pixelpump.hh:345
void updateTimings(const DisplayTimings &timings)
Update frame size using display timing.
Definition pixelpump.cc:143
FrameBuffer fb
Output frame buffer.
Definition pixelpump.hh:216
virtual void onHSyncEnd()
Start of the first pixel after the HSync region.
Definition pixelpump.hh:272
virtual void onVSyncBegin()
First pixel clock of the first VSync line.
Definition pixelpump.hh:250
BasePixelPump(EventManager &em, ClockDomain &pxl_clk, unsigned pixel_chunk)
Definition pixelpump.cc:91
const unsigned pixelChunk
Maximum number of pixels to handle per render callback.
Definition pixelpump.hh:291
bool _underrun
Did a buffer underrun occur within this refresh interval?
Definition pixelpump.hh:365
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
PixelEvent evHSyncEnd
Definition pixelpump.hh:350
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition pixelpump.cc:112
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
virtual ~BasePixelPump()
Definition pixelpump.cc:107
DisplayTimings _timings
Definition pixelpump.hh:354
PixelEvent evRenderPixels
Definition pixelpump.hh:352
bool visibleLine() const
Is the current line within the visible range?
Definition pixelpump.hh:199
void start()
Starting pushing pixels in timing mode.
Definition pixelpump.cc:159
virtual void onHSyncBegin()
Start of the HSync region.
Definition pixelpump.hh:264
bool underrun() const
Did a buffer underrun occur within this refresh interval?
Definition pixelpump.hh:195
void renderLine()
Fast and event-free line rendering function.
Definition pixelpump.cc:287
virtual bool nextPixel(Pixel &p)=0
Get the next pixel from the scan line buffer.
void renderFrame()
Render an entire frame in non-caching mode.
Definition pixelpump.cc:255
unsigned posY() const
Current pixel position within the visible area.
Definition pixelpump.hh:210
const DisplayTimings & timings() const
Get a constant reference of the current display timings.
Definition pixelpump.hh:189
PixelEvent evBeginLine
Definition pixelpump.hh:351
virtual void onUnderrun(unsigned x, unsigned y)
Buffer underrun occurred on a frame.
Definition pixelpump.hh:284
unsigned line
Current line (including back porch, front porch, and vsync) within a frame.
Definition pixelpump.hh:360
PixelEvent evHSyncBegin
Definition pixelpump.hh:349
unsigned _posX
X-coordinate within the visible region of a frame.
Definition pixelpump.hh:362
PixelEvent evVSyncEnd
Definition pixelpump.hh:348
virtual void onFrameDone()
Finished displaying the visible region of a frame.
Definition pixelpump.hh:287
The ClockDomain provides clock to group of clocked objects bundled under the same clock domain.
Helper class for objects that need to be clocked.
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
Interface for objects that might require draining before checkpointing.
Definition drain.hh:235
Internal gem5 representation of a frame buffer.
Basic support for object serialization.
Definition serialize.hh:170
STL vector class.
Definition stl.hh:37
ClockedObject declaration and implementation.
DrainState
Object drain/handover states.
Definition drain.hh:75
bool scheduled() const
Determine if the current event is scheduled.
Definition eventq.hh:458
Bitfield< 18, 16 > ps
Bitfield< 0 > p
Bitfield< 3 > x
Definition pagetable.hh:73
Bitfield< 2 > em
Definition misc.hh:617
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Tick
Tick count type.
Definition types.hh:58
unsigned vSync
Vertical sync signal in lines.
Definition pixelpump.hh:138
Cycles cyclesPerFrame() const
How many pixel clocks are required for one frame?
Definition pixelpump.hh:81
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition pixelpump.cc:76
unsigned linesPerFrame() const
Calculate the total number of lines in a frame.
Definition pixelpump.hh:116
unsigned height
Display height in pixels.
Definition pixelpump.hh:124
unsigned width
Display width in pixels.
Definition pixelpump.hh:122
unsigned lineVBackPorchStart() const
Calculate the first line of the vertical back porch.
Definition pixelpump.hh:95
unsigned hFrontPorch
Horizontal front porch in pixels.
Definition pixelpump.hh:129
unsigned lineFrontPorchStart() const
Calculate the first line of the back porch.
Definition pixelpump.hh:109
unsigned hSync
Horizontal sync signal length in pixels.
Definition pixelpump.hh:131
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition pixelpump.cc:61
static const DisplayTimings vga
Definition pixelpump.hh:140
Cycles cyclesPerLine() const
How many pixel clocks are required for one line?
Definition pixelpump.hh:74
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
unsigned vFrontPorch
Vertical front porch in lines.
Definition pixelpump.hh:136
unsigned hBackPorch
Horizontal back porch in pixels.
Definition pixelpump.hh:127
unsigned vBackPorch
Vertical back porch in lines.
Definition pixelpump.hh:134
unsigned lineVSyncStart() const
Calculate the first line of the vsync signal.
Definition pixelpump.hh:88
unsigned lineFirstVisible() const
Calculate the first line of the visible region.
Definition pixelpump.hh:102
Internal gem5 representation of a Pixel.
Definition pixel.hh:59

Generated on Tue Jun 18 2024 16:24:03 for gem5 by doxygen 1.11.0