GCC Code Coverage Report


Directory: ./
File: channeloutput/BBBMatrix.h
Date: 2026-10-29 08:11:58
Exec Total Coverage
Lines: 2 3 66.7%
Functions: 1 2 50.0%
Branches: 1 2 50.0%

Line Branch Exec Source
1 #pragma once
2 /*
3 * This file is part of the Falcon Player (FPP) and is Copyright (C)
4 * 2013-2022 by the Falcon Player Developers.
5 *
6 * The Falcon Player (FPP) is free software, and is covered under
7 * multiple Open Source licenses. Please see the included 'LICENSES'
8 * file for descriptions of what files are covered by each license.
9 *
10 * This source file is covered under the GPL v2 as described in the
11 * included LICENSE.GPL file.
12 */
13
14 #include "fpp-json-fwd.h"
15 #include <string>
16 #include <vector>
17
18 #include "Matrix.h"
19 #include "PanelMatrix.h"
20 #include "util/BBBPruUtils.h"
21
22 #include "ChannelOutput.h"
23
24 // 16 rows (1/16 scan) * 8bits per row
25 #define MAX_STATS 16 * 8
26
27 class PanelInterleaveHandler;
28
29 // structure of the data at the start of the PRU ram
30 // that the pru program expects to see
31 typedef struct {
32 // in the DDR shared with the PRU
33 volatile uint32_t address_dma;
34
35 // write 1 to start, 0xFF to abort. will be cleared when started
36 volatile uint32_t command;
37 volatile uint32_t response;
38
39 volatile uint16_t pwmBrightness[8];
40 uint32_t stats[3 * MAX_STATS]; // 3 values per collection
41 } __attribute__((__packed__)) BBBPruMatrixData;
42
43 class BBBMatrix : public ChannelOutput {
44 public:
45 BBBMatrix(unsigned int startChannel, unsigned int channelCount);
46 virtual ~BBBMatrix();
47
48 13 virtual std::string GetOutputType() const override {
49
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
26 return "BBB Panels";
50 }
51
52 virtual int Init(Json::Value config) override;
53 virtual int Close(void) override;
54
55 virtual void PrepData(unsigned char* channelData) override;
56
57 virtual int SendData(unsigned char* channelData) override;
58
59 virtual void DumpConfig(void) override;
60
61 virtual void GetRequiredChannelRanges(const std::function<void(int, int)>& addRange) override;
62
63 virtual void OverlayTestData(unsigned char* channelData, int cycleNum, float percentOfCycle, int testType, const Json::Value& config) override;
64 ✗ virtual bool SupportsTesting() const override { return true; }
65
66 private:
67 void calcBrightnessFlags(std::vector<std::string>& sargs);
68 void printStats();
69 bool configureControlPin(const std::string& ctype, Json::Value& root, std::ofstream& outputFile, int pru, int& controlGPIO);
70 void configurePanelPins(int x, Json::Value& root, std::ofstream& outputFile, int* minPort);
71 void configurePanelPin(int x, const std::string& color, int row, Json::Value& root, std::ofstream& outputFile, int* minPort);
72
73 BBBPru* m_pru;
74 BBBPru* m_pruCopy;
75 BBBPruMatrixData* m_pruData;
76 Matrix* m_matrix;
77 PanelMatrix* m_panelMatrix;
78 bool m_singlePRU = false;
79 // dual PRU split output: the copy PRU also writes these GPIO banks
80 bool m_splitOutput = false;
81 bool m_splitCpyBanks[4] = { false, false, false, false };
82 size_t m_dataOffset = 0;
83
84 int m_panelWidth;
85 int m_panelHeight;
86 int m_panelScan;
87 std::string m_panelInterleave;
88
89 int m_outputs;
90 int m_longestChain;
91 int m_invertedData;
92 int m_brightness;
93 int m_colorDepth;
94 bool m_printStats;
95 FPPColorOrder m_colorOrder;
96
97 uint32_t* m_gpioFrame;
98 int m_panels;
99 int m_rows;
100 int m_width;
101 int m_height;
102 int m_rowSize;
103
104 bool m_outputByRow;
105 bool m_outputBlankData;
106 std::vector<int> m_bitOrder;
107
108 int m_timing;
109 PanelInterleaveHandler* m_handler;
110
111 uint32_t brightnessValues[12];
112 uint32_t delayValues[12];
113 uint16_t gammaCurve[256];
114
115 std::string m_autoCreatedModelName;
116
117 class GPIOPinInfo {
118 public:
119 class Pins {
120 public:
121 uint32_t r_pin = 0;
122 uint32_t g_pin = 0;
123 uint32_t b_pin = 0;
124
125 uint8_t r_gpio = 0;
126 uint8_t g_gpio = 0;
127 uint8_t b_gpio = 0;
128 } row[2];
129 } m_pinInfo[8];
130
131 uint8_t* m_frames[8];
132 int m_curFrame;
133 int m_numFrames;
134 int m_fullFrameLen;
135
136 // Precomputed acceleration structures for PrepData (see buildPrepTables):
137 // per output, the 4 GPIO bank words for each combination of the 6 pins
138 uint32_t m_pinLUT[8][64][4];
139 // bit-spread gamma: bit b of gammaCurve[v] lands in byte b (low 8 bits)
140 // or byte b-8 (bits 8-11) so all bit-plane indexes compute per pixel
141 uint64_t m_gammaSpreadLo[256];
142 uint32_t m_gammaSpreadHi[256];
143 // (output, panel) pairs grouped by chain position
144 std::vector<std::vector<std::pair<int, int>>> m_chainPanels;
145 // interleave handler results precomputed per panel row/pixel
146 std::vector<int> m_yOutMap;
147 std::vector<uint16_t> m_xOutMap;
148 // staging for the packed per-bitplane pin indexes
149 std::vector<uint8_t> m_stageLo;
150 std::vector<uint8_t> m_stageHi;
151 // set when the interleave map is not a clean bijection and PrepData must
152 // memset the frame and OR into it (the historical behavior)
153 bool m_prepNeedsMemset = false;
154 void buildPrepTables();
155 };
156