| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of the Falcon Player (FPP) and is Copyright (C) | ||
| 3 | * 2013-2022 by the Falcon Player Developers. | ||
| 4 | * | ||
| 5 | * The Falcon Player (FPP) is free software, and is covered under | ||
| 6 | * multiple Open Source licenses. Please see the included 'LICENSES' | ||
| 7 | * file for descriptions of what files are covered by each license. | ||
| 8 | * | ||
| 9 | * This source file is covered under the CC-BY-ND as described in the | ||
| 10 | * included LICENSE.CC-BY-ND file. This file may be modified for | ||
| 11 | * personal use, but modified copies MAY NOT be redistributed in any form. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include "fpp-pch.h" | ||
| 15 | |||
| 16 | #include "fpp-json.h" | ||
| 17 | |||
| 18 | #include <pthread.h> | ||
| 19 | #include <sched.h> | ||
| 20 | #include <sys/mman.h> | ||
| 21 | #include <sys/wait.h> | ||
| 22 | #include <time.h> | ||
| 23 | #include <unistd.h> | ||
| 24 | |||
| 25 | #include <sys/wait.h> | ||
| 26 | #include <arm_neon.h> | ||
| 27 | #include <cstring> | ||
| 28 | #include <tuple> | ||
| 29 | |||
| 30 | #include <chrono> | ||
| 31 | |||
| 32 | // FPP includes | ||
| 33 | #include "../../Sequence.h" | ||
| 34 | #include "../../channeloutput/channeloutputthread.h" | ||
| 35 | #include "../../Warnings.h" | ||
| 36 | #include "../../channeloutput/ChannelOutputSetup.h" | ||
| 37 | #include "../../common.h" | ||
| 38 | #include "../../log.h" | ||
| 39 | |||
| 40 | #include "BBShiftString.h" | ||
| 41 | #include "../CapeUtils/CapeUtils.h" | ||
| 42 | #include "../../pru/SMEMRing.hp" | ||
| 43 | |||
| 44 | #include "../../overlays/PixelOverlay.h" | ||
| 45 | |||
| 46 | #include "channeloutput/stringtesters/PixelStringTester.h" | ||
| 47 | #include "util/BBBUtils.h" | ||
| 48 | |||
| 49 | #include "Plugin.h" | ||
| 50 | class BBShiftStringPlugin : public FPPPlugins::Plugin, public FPPPlugins::ChannelOutputPlugin { | ||
| 51 | public: | ||
| 52 | 40 | BBShiftStringPlugin() : | |
| 53 |
2/4✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
|
120 | FPPPlugins::Plugin("BBShiftString") { |
| 54 | 40 | } | |
| 55 | 62 | virtual ChannelOutput* createChannelOutput(unsigned int startChannel, unsigned int channelCount) override { | |
| 56 |
2/6✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
124 | return new BBShiftStringOutput(startChannel, channelCount); |
| 57 | } | ||
| 58 | }; | ||
| 59 | |||
| 60 | extern "C" { | ||
| 61 | 40 | FPPPlugins::Plugin* createPlugin() { | |
| 62 |
2/6✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
80 | return new BBShiftStringPlugin(); |
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | #ifdef PLATFORM_BBB | ||
| 67 | static const std::vector<std::string> PRU0_DATA_PINS = { "P9-31", "P9-29", "P9-30", "P9-28", "P9-92", "P9-27", "P9-91", "P9-25" }; | ||
| 68 | static const std::vector<std::string> PRU0_CTRL_PINS = { "P8-12", "P8-11" }; | ||
| 69 | static const std::vector<std::string> PRU1_DATA_PINS = { "P8-45", "P8-46", "P8-43", "P8-44", "P8-41", "P8-42", "P8-39", "P8-40" }; | ||
| 70 | static const std::vector<std::string> PRU1_CTRL_PINS = { "P8-28", "P8-30" }; | ||
| 71 | static const std::string PRU1_ENABLE_PIN = "P8-27"; | ||
| 72 | #else | ||
| 73 | static const std::vector<std::string> PRU0_DATA_PINS = {}; | ||
| 74 | static const std::vector<std::string> PRU0_CTRL_PINS = {}; | ||
| 75 | static const std::vector<std::string> PRU1_DATA_PINS = { "P2-02", "P2-04", "P2-06", "P2-08", "P2-20", "P1-20", "P2-24", "P2-33" }; | ||
| 76 | static const std::vector<std::string> PRU1_CTRL_PINS = { "P2-17", "P2-18" }; | ||
| 77 | static const std::string PRU1_ENABLE_PIN = "P2-22"; | ||
| 78 | #endif | ||
| 79 | |||
| 80 | static const std::vector<std::string> PRU_CTRL_PINS[2] = { PRU0_CTRL_PINS, PRU1_CTRL_PINS }; | ||
| 81 | static const std::vector<std::string> PRU_DATA_PINS[2] = { PRU0_DATA_PINS, PRU1_DATA_PINS }; | ||
| 82 | |||
| 83 | // r30 bit numbers of the clock/latch pins, matching the compile-time | ||
| 84 | // defaults in BBShiftString.asm (CONTROL_BIT_BASE + CLOCK_PIN/LATCH_PIN); | ||
| 85 | // a cape's pruPinConfig clockPin/latchPin names override them and the | ||
| 86 | // resolved values are published to the firmware at PINCFG_OFFSET | ||
| 87 | #ifdef PLATFORM_BBB | ||
| 88 | static const int DEFAULT_CLOCK_BIT[2] = { 15, 10 }; | ||
| 89 | static const int DEFAULT_LATCH_BIT[2] = { 14, 11 }; | ||
| 90 | #else | ||
| 91 | static const int DEFAULT_CLOCK_BIT[2] = { 19, 19 }; | ||
| 92 | static const int DEFAULT_LATCH_BIT[2] = { 16, 16 }; | ||
| 93 | #endif | ||
| 94 | // must match PINCFG_OFFSET in BBShiftString.asm | ||
| 95 | #define PINCFG_OFFSET 0x1FE8 | ||
| 96 | |||
| 97 | 62 | BBShiftStringOutput::BBShiftStringOutput(unsigned int startChannel, unsigned int channelCount) : | |
| 98 |
2/8✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
62 | ChannelOutput(startChannel, channelCount) { |
| 99 |
1/2✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
|
62 | LogDebug(VB_CHANNELOUT, "BBShiftStringOutput::BBShiftStringOutput(%u, %u)\n", |
| 100 | startChannel, channelCount); | ||
| 101 |
0/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
62 | } |
| 102 | |||
| 103 | /* | ||
| 104 | * | ||
| 105 | */ | ||
| 106 |
2/4✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
|
868 | BBShiftStringOutput::~BBShiftStringOutput() { |
| 107 | 124 | LogDebug(VB_CHANNELOUT, "BBShiftStringOutput::~BBShiftStringOutput()\n"); | |
| 108 | // idempotent; Close() normally does this, but an output torn down without | ||
| 109 | // one must not leave its frame rate warning stranded in the UI | ||
| 110 | 124 | setFrameRateWarning(false); | |
| 111 | 124 | clearBudgetWarning(); | |
| 112 | 124 | BBBPru::ddrRelease("BBShiftString"); | |
| 113 | 124 | m_pumpRunning = false; | |
| 114 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 61 times.
|
124 | if (m_pumpThread.joinable()) { |
| 115 | 2 | m_pumpThread.join(); | |
| 116 | } | ||
| 117 |
2/2✓ Branch 0 taken 425 times.
✓ Branch 1 taken 62 times.
|
974 | for (auto a : m_strings) { |
| 118 |
1/2✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
|
850 | delete a; |
| 119 | } | ||
| 120 | 124 | m_strings.clear(); | |
| 121 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
|
124 | if (m_pru0.pru) { |
| 122 | ✗ | delete m_pru0.pru; | |
| 123 | } | ||
| 124 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 60 times.
|
124 | if (m_pru1.pru) { |
| 125 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
4 | delete m_pru1.pru; |
| 126 | } | ||
| 127 |
2/2✓ Branch 0 taken 23 times.
✓ Branch 1 taken 39 times.
|
124 | if (falconV5Support) { |
| 128 |
1/2✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
|
46 | delete falconV5Support; |
| 129 | } | ||
| 130 |
2/2✓ Branch 0 taken 23 times.
✓ Branch 1 taken 39 times.
|
124 | if (m_fv5PacketMem) { |
| 131 | 46 | free(m_fv5PacketMem); | |
| 132 | } | ||
| 133 |
4/4✓ Branch 0 taken 124 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 62 times.
|
1116 | } |
| 134 | |||
| 135 | // Inverted lines and Falcon smart receivers do not mix, but only for one of | ||
| 136 | // the two reasons a line can be inverted. | ||
| 137 | // | ||
| 138 | // A chain's first port carries the config packet and the receiver's processor | ||
| 139 | // watches that line, so an inverted head is refused whatever set it. Protocol | ||
| 140 | // inversion (TM18xx) is meant to reach the pixels, so it passes through the | ||
| 141 | // receiver and is refused for every port of the chain. | ||
| 142 | // | ||
| 143 | // Cape declared inversion on a non-head port is left alone: it exists to undo | ||
| 144 | // a backwards wired differential pair, so the receiver already sees a correct | ||
| 145 | // signal. That is the one shipped use - a batch of K16A-B boards with the | ||
| 146 | // second line of the first differential group reversed - and it has to keep | ||
| 147 | // working. | ||
| 148 | // T0, T1 and the end of the bit cell are single latch instants shared by every | ||
| 149 | // port on the PRU, so the controller can only run one bit cell at a time. Take | ||
| 150 | // it from the ports that actually have pixels, and if they disagree, say so | ||
| 151 | // loudly and name the odd ones out rather than driving them at a timing their | ||
| 152 | // part cannot decode. | ||
| 153 | // | ||
| 154 | // Mixing cannot be papered over by picking the slower cell: a ws281x part fed a | ||
| 155 | // 2000ns one-pulse reads it as garbage, so there is no safe common value. | ||
| 156 | 61 | void BBShiftStringOutput::resolveTiming(const Json::Value& config) { | |
| 157 | 61 | std::map<PixelString::Timing, std::vector<int>, TimingLess> used; | |
| 158 |
2/2✓ Branch 0 taken 425 times.
✓ Branch 1 taken 61 times.
|
486 | for (int i = 0; i < (int)m_strings.size(); i++) { |
| 159 |
2/2✓ Branch 0 taken 398 times.
✓ Branch 1 taken 27 times.
|
425 | if (m_strings[i]->m_outputBytes > 0) { |
| 160 |
6/12✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 398 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 398 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 398 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 398 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 398 times.
✗ Branch 11 not taken.
|
796 | used[PixelString::protocolTiming(config["outputs"][i]["protocol"].asString())] |
| 161 |
1/2✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
|
398 | .push_back(m_strings[i]->m_portNumber + 1); |
| 162 | } | ||
| 163 | } | ||
| 164 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
|
61 | if (used.empty()) { |
| 165 | ✗ | return; | |
| 166 | } | ||
| 167 | // the cell the most ports want wins | ||
| 168 | 61 | auto best = used.begin(); | |
| 169 |
2/2✓ Branch 0 taken 61 times.
✓ Branch 1 taken 61 times.
|
122 | for (auto it = used.begin(); it != used.end(); ++it) { |
| 170 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
|
61 | if (it->second.size() > best->second.size()) { |
| 171 | ✗ | best = it; | |
| 172 | } | ||
| 173 | } | ||
| 174 | 61 | m_t0Ns = best->first.t0Ns; | |
| 175 | 61 | m_t1Ns = best->first.t1Ns; | |
| 176 | 61 | m_lowNs = best->first.periodNs; | |
| 177 | |||
| 178 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
|
61 | if (used.size() > 1) { |
| 179 | ✗ | std::string odd; | |
| 180 | ✗ | for (auto& [t, ports] : used) { | |
| 181 | ✗ | if (t == best->first) { | |
| 182 | ✗ | continue; | |
| 183 | } | ||
| 184 | ✗ | for (int p : ports) { | |
| 185 | ✗ | odd += (odd.empty() ? "" : ", ") + std::to_string(p); | |
| 186 | } | ||
| 187 | } | ||
| 188 | ✗ | LogErr(VB_CHANNELOUT, "Ports on one controller must share a bit timing; using %d/%d/%dns. Port(s) %s want a different one and will not work\n", | |
| 189 | m_t0Ns, m_t1Ns, m_lowNs, odd.c_str()); | ||
| 190 | ✗ | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: port(s) " + odd + | |
| 191 | ✗ | " use a pixel protocol whose timing differs from the rest of the controller"); | |
| 192 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 58 times.
|
61 | } else if (!(best->first == PixelString::Timing{ 320, 750, 1120 })) { |
| 193 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | LogInfo(VB_CHANNELOUT, "BBShiftString: bit timing %d/%d/%dns\n", m_t0Ns, m_t1Ns, m_lowNs); |
| 194 | } | ||
| 195 |
1/2✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
|
61 | } |
| 196 | |||
| 197 | 61 | void BBShiftStringOutput::demoteInvertedReceiverChains() { | |
| 198 | 61 | int x = 0; | |
| 199 |
2/2✓ Branch 0 taken 346 times.
✓ Branch 1 taken 61 times.
|
407 | while (x < m_strings.size()) { |
| 200 | 346 | PixelString* head = m_strings[x++]; | |
| 201 |
2/2✓ Branch 0 taken 31 times.
✓ Branch 1 taken 315 times.
|
346 | if (!head->m_isSmartReceiver || |
| 202 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 26 times.
|
31 | (head->smartReceiverType != PixelString::ReceiverType::FalconV5 && |
| 203 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | head->smartReceiverType != PixelString::ReceiverType::FalconV4)) { |
| 204 | 346 | continue; | |
| 205 | } | ||
| 206 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
54 | std::vector<PixelString*> chain{ head }; |
| 207 |
6/6✓ Branch 0 taken 80 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 79 times.
✓ Branch 5 taken 27 times.
|
106 | for (int i = 0; i < 3 && x < m_strings.size(); ++i) { |
| 208 |
1/2✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
|
79 | chain.push_back(m_strings[x++]); |
| 209 | } | ||
| 210 | |||
| 211 | 27 | std::string why; | |
| 212 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
|
27 | if (head->m_isInverted) { |
| 213 | ✗ | why = "its first port is inverted"; | |
| 214 | } else { | ||
| 215 |
2/2✓ Branch 0 taken 106 times.
✓ Branch 1 taken 27 times.
|
133 | for (auto* p : chain) { |
| 216 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
|
106 | if (p->m_protocolInverted) { |
| 217 | ✗ | why = "port " + std::to_string(p->m_portNumber + 1) + " uses an inverted protocol"; | |
| 218 | ✗ | break; | |
| 219 | } | ||
| 220 | } | ||
| 221 | } | ||
| 222 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
27 | if (why.empty()) { |
| 223 | 27 | continue; | |
| 224 | } | ||
| 225 | |||
| 226 | ✗ | LogWarn(VB_CHANNELOUT, "Falcon smart receivers on port %d disabled: %s\n", | |
| 227 | head->m_portNumber + 1, why.c_str()); | ||
| 228 | ✗ | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: smart receivers on port " + | |
| 229 | ✗ | std::to_string(head->m_portNumber + 1) + | |
| 230 | ✗ | " disabled, " + why); | |
| 231 | ✗ | head->smartReceiverType = PixelString::ReceiverType::None; | |
| 232 | ✗ | head->m_isSmartReceiver = false; | |
| 233 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
|
54 | } |
| 234 | 61 | } | |
| 235 | |||
| 236 | 106 | void BBShiftStringOutput::createOutputLengths(FrameData& d, const std::string& pfx) { | |
| 237 | // One command table record is the high mask for every string slot, then | ||
| 238 | // the low mask for every slot, then the two byte channel offset at which | ||
| 239 | // the next record takes over. Each slot contributes one byte (a bitmask | ||
| 240 | // of the eight data pins), so a record carries 2 * stringsPerPin mask | ||
| 241 | // bytes - 16 at 8 deep, 32 at 16 deep - and BYTES_FOR_MASKS in the | ||
| 242 | // firmware has to agree. The 16 deep firmware loads the high half into | ||
| 243 | // scratchpad bank 11 and the low half into bank 12; the 8 deep one loads | ||
| 244 | // both straight into r21-r24. | ||
| 245 | union { | ||
| 246 | uint16_t r[2]; | ||
| 247 | uint8_t b[4]; | ||
| 248 | } r45[2 * MAX_STRINGS_PER_PIN / 4]; | ||
| 249 | |||
| 250 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 84 times.
|
106 | if (!d.pruData) { |
| 251 | 22 | return; | |
| 252 | } | ||
| 253 | // registers spanned by one mask half; the low half starts at r45[nRegs] | ||
| 254 | 84 | const int nRegs = m_stringsPerPin / 4; | |
| 255 |
2/2✓ Branch 0 taken 340 times.
✓ Branch 1 taken 84 times.
|
424 | for (int x = 0; x < 2 * nRegs; x++) { |
| 256 | 340 | r45[x].r[0] = 0; | |
| 257 | 340 | r45[x].r[1] = 0; | |
| 258 | } | ||
| 259 | 84 | std::map<int, std::vector<std::tuple<int, int, GPIOCommand, bool>>> sizes; | |
| 260 | 84 | int bmask = 0x1; | |
| 261 |
2/2✓ Branch 0 taken 672 times.
✓ Branch 1 taken 84 times.
|
756 | for (int y = 0; y < MAX_PINS_PER_PRU; ++y) { |
| 262 |
2/2✓ Branch 0 taken 5440 times.
✓ Branch 1 taken 672 times.
|
6112 | for (int x = 0; x < m_stringsPerPin; ++x) { |
| 263 | 5440 | int pc = d.stringMap[y][x]; | |
| 264 |
2/2✓ Branch 0 taken 569 times.
✓ Branch 1 taken 4871 times.
|
5440 | if (pc >= 0) { |
| 265 |
2/2✓ Branch 0 taken 532 times.
✓ Branch 1 taken 569 times.
|
1101 | for (auto& a : m_strings[pc]->m_gpioCommands) { |
| 266 |
2/4✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 532 times.
✗ Branch 3 not taken.
|
532 | sizes[a.channelOffset].push_back(std::make_tuple(y, x, a, m_strings[pc]->m_isInverted)); |
| 267 | } | ||
| 268 | 569 | int breg = x % 4; | |
| 269 | 569 | int idx = x / 4; | |
| 270 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 569 times.
|
569 | if (m_strings[pc]->m_isInverted) { |
| 271 | ✗ | r45[idx + nRegs].b[breg] |= bmask; | |
| 272 | } else { | ||
| 273 | 569 | r45[idx].b[breg] |= bmask; | |
| 274 | } | ||
| 275 | } | ||
| 276 | } | ||
| 277 | 672 | bmask <<= 1; | |
| 278 | } | ||
| 279 | |||
| 280 | // need to use pru->memcpyToPRU so we'll use a temporary here | ||
| 281 | // and it also needs to be 64 byte aligned | ||
| 282 | // the tail of the table is the between-packets mask slot, see BBShiftStringDefs.hp | ||
| 283 | 84 | const int maxEntries = BBSS_COMMAND_TABLE_ENTRIES - BBSS_PACKET2_MASKS_ENTRIES; | |
| 284 | // one record is the mask halves plus the two byte offset that introduces | ||
| 285 | // the next one; 9 entries at 8 deep, 17 at 16 deep | ||
| 286 | 84 | const int entriesPerRecord = 1 + 4 * nRegs; | |
| 287 | 84 | uint8_t* buffer = (uint8_t*)malloc(maxEntries * sizeof(uint16_t) + 256); | |
| 288 | 84 | uintptr_t ptr = (uintptr_t)buffer; | |
| 289 | 84 | ptr += 64 - (ptr % 64); | |
| 290 | 84 | uint16_t* commandTable = (uint16_t*)ptr; | |
| 291 | |||
| 292 | 84 | int curCommandTable = 0; | |
| 293 | 252 | auto emitMasks = [&]() { | |
| 294 |
2/2✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 252 times.
|
1272 | for (int r = 0; r < 2 * nRegs; ++r) { |
| 295 | 1020 | commandTable[curCommandTable++] = r45[r].r[0]; | |
| 296 | 1020 | commandTable[curCommandTable++] = r45[r].r[1]; | |
| 297 | } | ||
| 298 | 336 | }; | |
| 299 | 84 | emitMasks(); | |
| 300 | |||
| 301 | 84 | auto i = sizes.begin(); | |
| 302 |
2/2✓ Branch 0 taken 88 times.
✓ Branch 1 taken 82 times.
|
170 | while (i != sizes.end()) { |
| 303 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 86 times.
|
88 | if (i->first == GPIO_CMD_AFTER_FIRST_PACKET) { |
| 304 | // not a data byte position; applied to the parked masks below | ||
| 305 | 2 | break; | |
| 306 | } | ||
| 307 | 86 | uint16_t min = i->first & 0xFFFF; | |
| 308 |
2/2✓ Branch 0 taken 84 times.
✓ Branch 1 taken 2 times.
|
86 | if (min <= d.maxStringLen) { |
| 309 | // the table lives in the PRU's data RAM, just below the ring | ||
| 310 | // config words - always leave room for this record and the | ||
| 311 | // terminator. A 16 deep cape can reach this: twice the strings | ||
| 312 | // and near twice the record size. | ||
| 313 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
|
84 | if (curCommandTable + entriesPerRecord + 1 > maxEntries) { |
| 314 | ✗ | LogErr(VB_CHANNELOUT, "%s: GPIO command table full at channel offset %d; later commands dropped\n", | |
| 315 | pfx.c_str(), i->first); | ||
| 316 | ✗ | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: too many smart receiver GPIO commands to fit the PRU command table"); | |
| 317 | ✗ | break; | |
| 318 | } | ||
| 319 | 84 | commandTable[curCommandTable++] = min; | |
| 320 |
2/2✓ Branch 0 taken 522 times.
✓ Branch 1 taken 84 times.
|
606 | for (auto& t : i->second) { |
| 321 | 522 | auto [y, x, cmd, inverted] = t; | |
| 322 | |||
| 323 | 522 | int reg = (x / 4); | |
| 324 | 522 | int breg = x % 4; | |
| 325 | 522 | uint8_t mask = 0x1 << y; | |
| 326 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 522 times.
|
522 | if (cmd.type) { |
| 327 | ✗ | if (inverted) { | |
| 328 | ✗ | r45[reg].b[breg] &= ~mask; | |
| 329 | } else { | ||
| 330 | ✗ | r45[reg].b[breg] |= mask; | |
| 331 | } | ||
| 332 | } else { | ||
| 333 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 522 times.
|
522 | if (inverted) { |
| 334 | ✗ | r45[reg].b[breg] |= mask; | |
| 335 | } else { | ||
| 336 | 522 | r45[reg].b[breg] &= ~mask; | |
| 337 | } | ||
| 338 | } | ||
| 339 | 522 | } | |
| 340 | 84 | emitMasks(); | |
| 341 | } | ||
| 342 | 86 | i++; | |
| 343 | } | ||
| 344 | 84 | commandTable[curCommandTable++] = 0xFFFF; | |
| 345 | // round up to nearest 64 byte boundary | ||
| 346 | 84 | int len = (curCommandTable) * 2; | |
| 347 | 84 | len += 64 - (len % 64); | |
| 348 |
1/2✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
|
84 | d.pru->memcpyToPRU((uint8_t*)&d.pruData->commandTable[0], (uint8_t*)&commandTable[0], len); |
| 349 | |||
| 350 | // Park the masks the firmware loads in the packet phase (after the first | ||
| 351 | // packet, or for the whole phase of a listen frame): the end-of-frame | ||
| 352 | // masks (r45 has every record applied), less the send-only chain heads, | ||
| 353 | // whose line goes low after their config packet and never carries a | ||
| 354 | // second packet or precedes the bus turnaround. Always written, so the | ||
| 355 | // load is harmless when no such chain exists. | ||
| 356 |
1/2✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
|
84 | auto p2 = sizes.find(GPIO_CMD_AFTER_FIRST_PACKET); |
| 357 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 82 times.
|
84 | if (p2 != sizes.end()) { |
| 358 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | for (auto& t : p2->second) { |
| 359 | 2 | auto [y, x, cmd, inverted] = t; | |
| 360 | 2 | int reg = (x / 4); | |
| 361 | 2 | int breg = x % 4; | |
| 362 | 2 | uint8_t mask = 0x1 << y; | |
| 363 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if ((cmd.type != 0) != inverted) { |
| 364 | ✗ | r45[reg].b[breg] |= mask; | |
| 365 | } else { | ||
| 366 | 2 | r45[reg].b[breg] &= ~mask; | |
| 367 | } | ||
| 368 | 2 | } | |
| 369 | } | ||
| 370 | 84 | curCommandTable = 0; | |
| 371 | 84 | emitMasks(); | |
| 372 | // one mask set is 2 * stringsPerPin bytes, the slot is 2 * ENTRIES bytes | ||
| 373 | static_assert(2 * MAX_STRINGS_PER_PIN <= 2 * BBSS_PACKET2_MASKS_ENTRIES, "between-packets mask slot too small"); | ||
| 374 | 84 | d.pru->memcpyToPRU((uint8_t*)&d.pruData->commandTable[BBSS_COMMAND_TABLE_ENTRIES - BBSS_PACKET2_MASKS_ENTRIES], | |
| 375 |
1/2✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
|
84 | (uint8_t*)&commandTable[0], curCommandTable * 2); |
| 376 | 84 | free(buffer); | |
| 377 | 84 | } | |
| 378 | |||
| 379 | /* | ||
| 380 | * | ||
| 381 | */ | ||
| 382 | 62 | int BBShiftStringOutput::Init(Json::Value config) { | |
| 383 |
1/2✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
|
62 | LogDebug(VB_CHANNELOUT, "BBShiftStringOutput::Init(JSON)\n"); |
| 384 | 62 | std::string v; | |
| 385 | |||
| 386 |
2/4✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
|
62 | m_subType = config["subType"].asString(); |
| 387 |
2/4✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
|
62 | m_channelCount = config["channelCount"].asInt(); |
| 388 | |||
| 389 |
1/2✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
|
62 | Json::Value root; |
| 390 |
2/4✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
|
62 | if (!CapeUtils::INSTANCE.getStringConfig(m_subType, root)) { |
| 391 | ✗ | LogErr(VB_CHANNELOUT, "Could not read pin configuration for %s\n", m_subType.c_str()); | |
| 392 | ✗ | return 0; | |
| 393 | } | ||
| 394 | |||
| 395 | // The cape's string config has to be one written for this driver. Here an | ||
| 396 | // output is a place in the cape's shift register chains (numeric "pru", | ||
| 397 | // "pin" and "index"); on a BBB48String cape it is a header pin name | ||
| 398 | // ("pin": "P8-08"). Reading a pin name as an int throws out of jsoncpp and | ||
| 399 | // reaches the user as a bare "Value is not convertible to Int.", so name the | ||
| 400 | // real problem instead: the config asked for the wrong driver for this cape. | ||
| 401 | // Configs like that do arrive - xLights 2026.16 pointed an early K16A-B at | ||
| 402 | // this driver, a revision whose eeprom predates it and so is still a | ||
| 403 | // BBB48String pinout (and names no "driver" at all, hence the default | ||
| 404 | // below; later revisions of the same cape do belong here). | ||
| 405 |
2/4✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
|
62 | const int capeOutputCount = root["outputs"].size(); |
| 406 |
2/2✓ Branch 0 taken 1063 times.
✓ Branch 1 taken 61 times.
|
1124 | for (int i = 0; i < capeOutputCount; i++) { |
| 407 | // a string "pin" is the unambiguous BBB48String signature; a missing | ||
| 408 | // one is left to the null-reads-as-0 behaviour the shift capes have | ||
| 409 | // always relied on for their unused fields | ||
| 410 |
6/10✓ Branch 0 taken 1063 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1063 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1063 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1063 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1062 times.
✓ Branch 9 taken 1 times.
|
1063 | if (!root["outputs"][i]["pin"].isString()) { |
| 411 | 1062 | continue; | |
| 412 | } | ||
| 413 |
3/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | std::string capeDriver = root.get("driver", "BBB48String").asString(); |
| 414 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | LogErr(VB_CHANNELOUT, "Cape %s is not a BBShiftString cape - its string configuration names header pins, so it needs the %s output type\n", |
| 415 | m_subType.c_str(), capeDriver.c_str()); | ||
| 416 |
4/8✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
2 | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: " + m_subType + " needs the " + capeDriver + |
| 417 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | " output type - open the Pixel Strings page and save to correct it"); |
| 418 | 1 | return 0; | |
| 419 | 1 | } | |
| 420 | |||
| 421 | // A combo cape shares the PRUSS with a panel driver: this side must not | ||
| 422 | // clear the shared RAM or the other PRU's memory on a restart, and the | ||
| 423 | // FalconV5 listener (a PRU0 program whose capture area overlaps the | ||
| 424 | // panel ring) is unavailable. (Also honored from the output config for | ||
| 425 | // bench testing.) | ||
| 426 |
6/12✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 61 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 61 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 61 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 61 times.
|
61 | m_sharedPRUSS = root["sharedPRUSS"].asBool() || config["sharedPRUSS"].asBool(); |
| 427 | |||
| 428 | // How deep the cape's shift register chains are. Absent means 8, the | ||
| 429 | // layout every cape has shipped with so far; 16 doubles the strings one | ||
| 430 | // PRU can drive and selects the SHIFT16 firmware. | ||
| 431 | // (Also honored from the output config, so a new cape can be brought up | ||
| 432 | // before its eeprom is finalized.) | ||
| 433 | 61 | m_stringsPerPin = 8; | |
| 434 |
7/10✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 60 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 60 times.
|
61 | if (root.isMember("stringsPerPin") || config.isMember("stringsPerPin")) { |
| 435 |
4/12✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
|
1 | int spp = config.isMember("stringsPerPin") ? config["stringsPerPin"].asInt() : root["stringsPerPin"].asInt(); |
| 436 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if (spp != 8 && spp != 16) { |
| 437 | ✗ | LogErr(VB_CHANNELOUT, "Cape declares stringsPerPin %d; only 8 and 16 are supported, using 8\n", spp); | |
| 438 | ✗ | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: unsupported stringsPerPin, falling back to 8"); | |
| 439 | } else { | ||
| 440 | 1 | m_stringsPerPin = spp; | |
| 441 | } | ||
| 442 | } | ||
| 443 | #ifdef PLATFORM_BBB | ||
| 444 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (m_stringsPerPin != 8) { |
| 445 | // At 200MHz the three shift phases of a 16 deep chain come to 1045ns | ||
| 446 | // against a 1120ns bit budget, leaving no room for the data block | ||
| 447 | // read - and the AM335x already reaches 128 strings using both PRUs. | ||
| 448 | ✗ | LogErr(VB_CHANNELOUT, "16 strings per pin requires the AM62x; using 8\n"); | |
| 449 | ✗ | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: 16 strings per pin is not supported on this SBC"); | |
| 450 | ✗ | m_stringsPerPin = 8; | |
| 451 | } | ||
| 452 | #endif | ||
| 453 | |||
| 454 | // Default pin sets, overridable per PRU by the cape for combo pinouts. | ||
| 455 | // The cape only ever names header pins (P2-02 style); the mapping to | ||
| 456 | // r30 bit numbers happens here via the per-platform pin table, so a new | ||
| 457 | // SBC in the same form factor can reuse the same capes and eeproms | ||
| 458 | // (exactly how the PocketBeagle2 picked up PocketBeagle1 capes). The | ||
| 459 | // resolved clock/latch bits are published to the firmware at runtime. | ||
| 460 |
2/2✓ Branch 0 taken 122 times.
✓ Branch 1 taken 61 times.
|
183 | for (int p = 0; p < 2; p++) { |
| 461 |
1/2✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
|
122 | m_dataPins[p] = PRU_DATA_PINS[p]; |
| 462 |
1/2✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
|
122 | m_ctrlPins[p] = PRU_CTRL_PINS[p]; |
| 463 | 122 | m_clockBit[p] = DEFAULT_CLOCK_BIT[p]; | |
| 464 | 122 | m_latchBit[p] = DEFAULT_LATCH_BIT[p]; | |
| 465 | 122 | m_pinNamesOverridden[p] = false; | |
| 466 | } | ||
| 467 |
8/14✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 61 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 62 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 61 times.
|
62 | for (auto const& pc : root["pruPinConfig"]) { |
| 468 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | int p = pc["pru"].asInt(); |
| 469 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if (p < 0 || p > 1) { |
| 470 | ✗ | continue; | |
| 471 | } | ||
| 472 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | if (pc.isMember("dataPins")) { |
| 473 | 1 | m_dataPins[p].clear(); | |
| 474 |
7/12✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 1 times.
|
3 | for (auto const& pin : pc["dataPins"]) { |
| 475 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | m_dataPins[p].push_back(pin.asString()); |
| 476 | } | ||
| 477 | 1 | m_pinNamesOverridden[p] = true; | |
| 478 | } | ||
| 479 | 1 | m_ctrlPins[p].clear(); | |
| 480 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (auto const& nm : { "clockPin", "latchPin" }) { |
| 481 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | if (pc.isMember(nm)) { |
| 482 | ✗ | std::string pinName = pc[nm].asString(); | |
| 483 | ✗ | m_ctrlPins[p].push_back(pinName); | |
| 484 | ✗ | const BBBPinCapabilities* bp = (const BBBPinCapabilities*)(PinCapabilities::getPinByName(pinName).ptr()); | |
| 485 | // pruPin() returns uint8_t; the unmapped value (-1) needs | ||
| 486 | // the sign restored | ||
| 487 | ✗ | int bit = bp ? (int8_t)bp->pruPin(p) : -1; | |
| 488 | ✗ | if (bit < 0) { | |
| 489 | ✗ | LogErr(VB_CHANNELOUT, "%s %s has no known PRU%d r30 bit\n", nm, pinName.c_str(), p); | |
| 490 | ✗ | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: unusable control pin " + pinName); | |
| 491 | ✗ | } else if (strcmp(nm, "clockPin") == 0) { | |
| 492 | ✗ | m_clockBit[p] = bit; | |
| 493 | } else { | ||
| 494 | ✗ | m_latchBit[p] = bit; | |
| 495 | } | ||
| 496 | ✗ | } | |
| 497 | } | ||
| 498 | } | ||
| 499 | |||
| 500 | 61 | int maxStringLen = 0; | |
| 501 | 61 | bool hasV5SR = false; | |
| 502 | 61 | bool hasFalconSR = false; | |
| 503 |
4/6✓ Branch 0 taken 486 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 486 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 425 times.
✓ Branch 5 taken 61 times.
|
486 | for (int i = 0; i < config["outputs"].size(); i++) { |
| 504 |
3/6✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 425 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 425 times.
✗ Branch 5 not taken.
|
425 | Json::Value s = config["outputs"][i]; |
| 505 |
3/8✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 425 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 425 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
425 | PixelString* newString = new PixelString(true); |
| 506 | |||
| 507 |
5/10✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 425 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 425 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 425 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 425 times.
|
425 | if (!newString->Init(s, &root["outputs"][i])) { |
| 508 | ✗ | return 0; | |
| 509 | } | ||
| 510 | |||
| 511 |
2/2✓ Branch 0 taken 62 times.
✓ Branch 1 taken 363 times.
|
425 | if (newString->m_outputBytes > maxStringLen) { |
| 512 | 62 | maxStringLen = newString->m_outputBytes; | |
| 513 | } | ||
| 514 | |||
| 515 |
1/2✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
|
425 | m_strings.push_back(newString); |
| 516 |
1/2✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
|
425 | } |
| 517 | |||
| 518 |
1/2✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
|
61 | resolveTiming(config); |
| 519 |
1/2✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
|
61 | demoteInvertedReceiverChains(); |
| 520 | |||
| 521 |
2/2✓ Branch 0 taken 425 times.
✓ Branch 1 taken 61 times.
|
486 | for (auto& a : m_strings) { |
| 522 | 425 | hasV5SR |= a->smartReceiverType == PixelString::ReceiverType::FalconV5; | |
| 523 |
4/4✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 389 times.
|
425 | hasFalconSR |= a->smartReceiverType == PixelString::ReceiverType::FalconV4 || a->smartReceiverType == PixelString::ReceiverType::FalconV5; |
| 524 | } | ||
| 525 | |||
| 526 |
2/4✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
|
61 | int retVal = ChannelOutput::Init(config); |
| 527 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
|
61 | if (retVal == 0) { |
| 528 | ✗ | return 0; | |
| 529 | } | ||
| 530 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
|
61 | if (maxStringLen == 0) { |
| 531 | ✗ | LogErr(VB_CHANNELOUT, "No pixels configured in any string\n"); | |
| 532 | ✗ | return 1; | |
| 533 | } | ||
| 534 | |||
| 535 |
1/2✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
|
61 | m_licensedOutputs = CapeUtils::INSTANCE.getLicensedOutputs(); |
| 536 | |||
| 537 |
2/4✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
|
61 | config["base"] = root; |
| 538 | |||
| 539 | // The full bidirectional Falcon V5 protocol needs the cape's PRU0 | ||
| 540 | // listener support (and sole ownership of the PRUSS - the listener is a | ||
| 541 | // PRU0 program whose capture area overlaps the panel ring half of the | ||
| 542 | // shared RAM). Without that, V5 receivers still work as send-only V4: | ||
| 543 | // the config packet goes out, queries and responses do not. | ||
| 544 |
4/6✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
|
61 | supportsV5Listeners = root.isMember("falconV5ListenerConfig") && !m_sharedPRUSS; |
| 545 |
4/4✓ Branch 0 taken 22 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 21 times.
|
61 | if (hasV5SR && !supportsV5Listeners) { |
| 546 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | LogWarn(VB_CHANNELOUT, "Falcon V5 (bidirectional) smart receivers are not supported on this cape%s; falling back to send-only V4 handling\n", |
| 547 | m_sharedPRUSS ? " (shared PRUSS)" : ""); | ||
| 548 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | for (auto& a : m_strings) { |
| 549 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
|
4 | if (a->smartReceiverType == PixelString::ReceiverType::FalconV5) { |
| 550 | 1 | a->smartReceiverType = PixelString::ReceiverType::FalconV4; | |
| 551 | } | ||
| 552 | } | ||
| 553 | 1 | hasV5SR = false; | |
| 554 | } | ||
| 555 | 61 | m_hasBidirSR = hasV5SR; | |
| 556 | |||
| 557 | // On a cape that wires the receiver enable line to PRU1, that pin gates | ||
| 558 | // the whole differential bus, so it has to be configured whenever the | ||
| 559 | // cape has it - not just for Falcon receivers, and not just for smart | ||
| 560 | // receivers at all. Left unconfigured, nothing downstream of it gets | ||
| 561 | // data, dumb strings included. Configuring it also commits us to | ||
| 562 | // actually running PRU1 (see the maxStringLen bump below): the firmware | ||
| 563 | // parks the pin in its disabled state, so a halted PRU1 holds it there. | ||
| 564 | 61 | m_usesEnablePin = supportsV5Listeners; | |
| 565 | |||
| 566 | 61 | int curRecPort = -1; | |
| 567 |
2/2✓ Branch 0 taken 425 times.
✓ Branch 1 taken 61 times.
|
486 | for (int x = 0; x < m_strings.size(); x++) { |
| 568 |
6/6✓ Branch 0 taken 131 times.
✓ Branch 1 taken 294 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 398 times.
|
531 | if (curRecPort == -1 && (m_strings[x]->smartReceiverType == PixelString::ReceiverType::FalconV5 || |
| 569 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 104 times.
|
106 | m_strings[x]->smartReceiverType == PixelString::ReceiverType::FalconV4)) { |
| 570 | 27 | curRecPort = 0; | |
| 571 | } | ||
| 572 |
6/6✓ Branch 0 taken 27 times.
✓ Branch 1 taken 398 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 411 times.
✓ Branch 5 taken 14 times.
|
425 | if (m_strings[x]->m_outputBytes > 0 || curRecPort >= 0) { |
| 573 |
6/6✓ Branch 0 taken 90 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 89 times.
✓ Branch 5 taken 322 times.
|
411 | if (curRecPort == -1 && m_strings[x]->smartReceiverType != PixelString::ReceiverType::None) { |
| 574 | 89 | curRecPort = m_strings[x]->m_portNumber % 4; | |
| 575 | } | ||
| 576 | // need to output this pin, configure it | ||
| 577 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 410 times.
|
411 | if (x >= capeOutputCount) { |
| 578 | // the loop above only vetted the outputs the cape declares; | ||
| 579 | // a config with more ports than that has nowhere to send them | ||
| 580 | // (and a bare operator[] here would read a null entry as | ||
| 581 | // pru 0 / pin 0 / stage 0, colliding with a real port) | ||
| 582 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | LogErr(VB_CHANNELOUT, "Output %d is past the %d the %s cape declares\n", |
| 583 | x + 1, capeOutputCount, m_subType.c_str()); | ||
| 584 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: output " + std::to_string(x + 1) + |
| 585 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | " is past the end of the cape's pinout"); |
| 586 | 1 | continue; | |
| 587 | } | ||
| 588 |
4/8✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 410 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 410 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 410 times.
✗ Branch 7 not taken.
|
410 | int pru = root["outputs"][x]["pru"].asInt(); |
| 589 |
4/8✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 410 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 410 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 410 times.
✗ Branch 7 not taken.
|
410 | int pin = root["outputs"][x]["pin"].asInt(); |
| 590 |
4/8✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 410 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 410 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 410 times.
✗ Branch 7 not taken.
|
410 | int pinIdx = root["outputs"][x]["index"].asInt(); |
| 591 |
4/4✓ Branch 0 taken 409 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 408 times.
|
410 | if (pru < 0 || pru > 1) { |
| 592 | // m_dataPins/m_ctrlPins/m_pinNamesOverridden are all [2]; a | ||
| 593 | // cape pinout written for a different driver can name a pru | ||
| 594 | // outside that range and would index straight past them | ||
| 595 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | LogErr(VB_CHANNELOUT, "Output %d names pru %d but only pru 0 and 1 exist\n", x, pru); |
| 596 |
3/6✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
2 | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: output " + std::to_string(x) + " names an invalid pru"); |
| 597 | 2 | continue; | |
| 598 | } | ||
| 599 |
2/4✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 408 times.
|
408 | if (pinIdx < 0 || pinIdx >= m_stringsPerPin) { |
| 600 | ✗ | LogErr(VB_CHANNELOUT, "Output %d has shift stage index %d but the cape declares %d strings per pin\n", | |
| 601 | x, pinIdx, m_stringsPerPin); | ||
| 602 | ✗ | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: output " + std::to_string(x) + " shift stage index out of range"); | |
| 603 | ✗ | continue; | |
| 604 | } | ||
| 605 |
2/2✓ Branch 0 taken 812 times.
✓ Branch 1 taken 408 times.
|
1220 | for (auto& a : m_ctrlPins[pru]) { |
| 606 |
3/4✓ Branch 0 taken 812 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 686 times.
|
812 | if (m_usedPins.find(a) == m_usedPins.end()) { |
| 607 |
3/6✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
|
126 | m_usedPins[a] = "pru" + std::to_string(pru) + "out"; |
| 608 | } | ||
| 609 | } | ||
| 610 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
|
408 | if (pin >= (int)m_dataPins[pru].size()) { |
| 611 | ✗ | LogErr(VB_CHANNELOUT, "Output %d references pru %d data pin %d but only %d exist\n", | |
| 612 | x, pru, pin, (int)m_dataPins[pru].size()); | ||
| 613 | ✗ | continue; | |
| 614 | } | ||
| 615 | 408 | const std::string& pinName = m_dataPins[pru][pin]; | |
| 616 |
3/4✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 324 times.
|
408 | if (m_usedPins.find(pinName) == m_usedPins.end()) { |
| 617 |
3/6✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84 times.
✗ Branch 5 not taken.
|
84 | m_usedPins[pinName] = "pru" + std::to_string(pru) + "out"; |
| 618 | } | ||
| 619 | // with the default pin sets the cape's pin index is the r30 bit; | ||
| 620 | // cape-named pins resolve through the platform pin table | ||
| 621 | 408 | int bit = pin; | |
| 622 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 406 times.
|
408 | if (m_pinNamesOverridden[pru]) { |
| 623 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | const BBBPinCapabilities* bp = (const BBBPinCapabilities*)(PinCapabilities::getPinByName(pinName).ptr()); |
| 624 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | bit = bp ? (int8_t)bp->pruPin(pru) : -1; |
| 625 |
3/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
|
2 | if (bit < 0 || bit >= MAX_PINS_PER_PRU) { |
| 626 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | LogErr(VB_CHANNELOUT, "Data pin %s maps to PRU%d r30 bit %d; the firmware supports bits 0-%d\n", |
| 627 | pinName.c_str(), pru, bit, MAX_PINS_PER_PRU - 1); | ||
| 628 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: unusable data pin " + pinName); |
| 629 | 1 | continue; | |
| 630 | } | ||
| 631 | } | ||
| 632 | |||
| 633 | // printf("pru: %d pin: %d idx: %d\n", pru, pin, pinIdx); | ||
| 634 |
6/6✓ Branch 0 taken 344 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 340 times.
✓ Branch 5 taken 67 times.
|
407 | if (x >= m_licensedOutputs && m_strings[x]->m_outputBytes > 0) { |
| 635 | // apply limit | ||
| 636 | 340 | int pixels = 50; | |
| 637 | 340 | int chanCount = 0; | |
| 638 |
2/2✓ Branch 0 taken 341 times.
✓ Branch 1 taken 340 times.
|
681 | for (auto& a : m_strings[x]->m_virtualStrings) { |
| 639 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
|
341 | if (pixels < a.pixelCount) { |
| 640 | ✗ | a.pixelCount = pixels; | |
| 641 | } | ||
| 642 | 341 | pixels -= a.pixelCount; | |
| 643 |
1/2✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
|
341 | chanCount += a.channelCount(); |
| 644 | } | ||
| 645 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 308 times.
|
340 | if (m_strings[x]->m_isSmartReceiver) { |
| 646 | 32 | chanCount = 0; | |
| 647 | } | ||
| 648 |
1/2✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
|
340 | m_strings[x]->setPixelDataChannels(chanCount); |
| 649 | } | ||
| 650 | |||
| 651 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 404 times.
|
407 | if (pru == 0) { |
| 652 | 3 | m_pru0.stringMap[bit][pinIdx] = x; | |
| 653 | 3 | m_pru0.maxStringLen = std::max(m_pru0.maxStringLen, m_strings[x]->m_outputBytes); | |
| 654 | } else { | ||
| 655 | 404 | m_pru1.stringMap[bit][pinIdx] = x; | |
| 656 | 404 | m_pru1.maxStringLen = std::max(m_pru1.maxStringLen, m_strings[x]->m_outputBytes); | |
| 657 | } | ||
| 658 |
2/2✓ Branch 0 taken 406 times.
✓ Branch 1 taken 1 times.
|
407 | if (curRecPort >= 0) { |
| 659 |
2/2✓ Branch 0 taken 96 times.
✓ Branch 1 taken 310 times.
|
406 | if (++curRecPort == 4) { |
| 660 | 96 | curRecPort = -1; | |
| 661 | } | ||
| 662 | } | ||
| 663 | } | ||
| 664 | } | ||
| 665 |
4/4✓ Branch 0 taken 22 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 20 times.
|
61 | if (m_usesEnablePin && m_pru1.maxStringLen <= m_pru0.maxStringLen) { |
| 666 | // pru1 controls the enable/reading mux pins so it has to output more pixels | ||
| 667 | // than pru0 so it knows pru0 is done (and so it is started at all) | ||
| 668 | 2 | m_pru1.maxStringLen = m_pru0.maxStringLen + 1; | |
| 669 | } | ||
| 670 | |||
| 671 | 61 | int maxLen = std::max(m_pru0.maxStringLen, m_pru1.maxStringLen); | |
| 672 |
1/2✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
|
61 | if (maxLen > 0) { |
| 673 | // m_lowNs is the programmed bit cell from resolveTiming(); the bit loop | ||
| 674 | // carries ~130ns/bit of instruction time outside the waits. Measured | ||
| 675 | // on a K32-Max at two cells: ws281x 1120 -> 1245-1252ns achieved, | ||
| 676 | // ucs1903 2500 -> 2619ns achieved. | ||
| 677 | // | ||
| 678 | // Every frame pays the firmware's fixed 300us reset. Any Falcon | ||
| 679 | // receiver chain, V4 or V5, also gets a config packet on one frame in | ||
| 680 | // twelve: 69us of lead-in plus 57 bytes of 10 cells, measured +0.70ms | ||
| 681 | // on the AM62x and ~770us at the ~1235ns cell measured on the AM335x. | ||
| 682 | // The pending frame slot absorbs that one long frame, so it is | ||
| 683 | // charged as its average; V5 queries are added below the same way. | ||
| 684 | // Without a receiver the reset is all there is - the next frame is | ||
| 685 | // staged while the reset runs, and 300 px at 100fps measured a | ||
| 686 | // 110fps ceiling, where charging a flat 1700us here warned at 93. | ||
| 687 |
2/2✓ Branch 0 taken 23 times.
✓ Branch 1 taken 38 times.
|
61 | int falconUs = hasFalconSR ? 770 / 12 : 0; |
| 688 | 61 | int bitNs = m_lowNs + 130; | |
| 689 | 61 | m_frameTimeUs = (int)((maxLen * 8LL * bitNs) / 1000) + 300 + falconUs; | |
| 690 |
1/2✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
|
61 | LogInfo(VB_CHANNELOUT, "BBShiftString: longest string %d bytes at %dns/bit -> %.1fms/frame, sustainable ceiling ~%.4g fps\n", |
| 691 | maxLen, bitNs, m_frameTimeUs / 1000.0, 1000000.0 / m_frameTimeUs); | ||
| 692 | } | ||
| 693 | |||
| 694 |
4/4✓ Branch 0 taken 60 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 59 times.
|
61 | if (!StartPRU()) { |
| 695 | 1 | return 0; | |
| 696 | } | ||
| 697 | |||
| 698 | #ifdef PLATFORM_BBB | ||
| 699 | // give each area two chunks (frame flipping) of DDR memory, from the | ||
| 700 | // shared region allocator so other outputs on the region cannot | ||
| 701 | // overlap us; the FalconV5 packet area rides at the end | ||
| 702 | 3 | m_pru0.frameSize = stringsPerPru() * std::max(2400, m_pru0.maxStringLen); | |
| 703 | // leave a full memory page between to avoid conflicts | ||
| 704 | 3 | int offset0 = ((m_pru0.frameSize / 4096) + 2) * 4096; | |
| 705 | 3 | m_pru1.frameSize = stringsPerPru() * std::max(2400, m_pru1.maxStringLen); | |
| 706 | 3 | int offset1 = ((m_pru1.frameSize / 4096) + 2) * 4096; | |
| 707 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | size_t v5Size = hasFalconSR ? 128 * 1024 : 0; |
| 708 | 3 | uint32_t ddrPhys = 0; | |
| 709 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
3 | uint8_t* start = BBBPru::ddrAlloc("BBShiftString", 2 * offset0 + 2 * offset1 + v5Size, ddrPhys); |
| 710 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (!start) { |
| 711 | ✗ | LogErr(VB_CHANNELOUT, "BBShiftString: no room in the PRU DDR region\n"); | |
| 712 | ✗ | AddOutputConfigWarning(20, "BBShiftString: no room in the PRU DDR region - reduce string lengths or other outputs' buffers"); | |
| 713 | ✗ | return 0; | |
| 714 | } | ||
| 715 | 3 | m_pru0.curData = start; | |
| 716 | 3 | m_pru0.lastData = m_pru0.curData + offset0; | |
| 717 | |||
| 718 | 3 | m_pru0.formattedData = (uint8_t*)calloc(1, m_pru0.frameSize); | |
| 719 | |||
| 720 | 3 | m_pru1.curData = m_pru0.lastData + offset0; | |
| 721 | 3 | m_pru1.lastData = m_pru1.curData + offset1; | |
| 722 | |||
| 723 | 3 | m_pru1.formattedData = (uint8_t*)calloc(1, m_pru1.frameSize); | |
| 724 | #else | ||
| 725 | // AM62x: the frame flipping buffers live in normal cached memory; the | ||
| 726 | // pump thread streams them into the PRU shared memory ring | ||
| 727 | 56 | m_pru0.frameSize = stringsPerPru() * std::max(2400, m_pru0.maxStringLen); | |
| 728 | 56 | m_pru0.curData = (uint8_t*)calloc(1, m_pru0.frameSize); | |
| 729 | 56 | m_pru0.lastData = (uint8_t*)calloc(1, m_pru0.frameSize); | |
| 730 | 56 | m_pru0.heapData = true; | |
| 731 | 56 | m_pru0.formattedData = (uint8_t*)calloc(1, m_pru0.frameSize); | |
| 732 | |||
| 733 | 56 | m_pru1.frameSize = stringsPerPru() * std::max(2400, m_pru1.maxStringLen); | |
| 734 | 56 | m_pru1.curData = (uint8_t*)calloc(1, m_pru1.frameSize); | |
| 735 | 56 | m_pru1.lastData = (uint8_t*)calloc(1, m_pru1.frameSize); | |
| 736 | 56 | m_pru1.heapData = true; | |
| 737 | 56 | m_pru1.formattedData = (uint8_t*)calloc(1, m_pru1.frameSize); | |
| 738 | #endif | ||
| 739 | |||
| 740 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 37 times.
|
59 | if (m_usesEnablePin) { |
| 741 | // without this the enable line stays unconfigured and nothing | ||
| 742 | // behind it - receiver port 1, dumb strings - gets data | ||
| 743 |
4/8✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
|
110 | PinCapabilities::getPinByName(PRU1_ENABLE_PIN).configPin("pru1out", true, "BBShiftString-Enable"); |
| 744 | } | ||
| 745 |
2/2✓ Branch 0 taken 23 times.
✓ Branch 1 taken 36 times.
|
59 | if (hasFalconSR) { |
| 746 | #ifdef PLATFORM_BBB | ||
| 747 | ✗ | setupFalconV5Support(root, m_pru1.lastData + offset1); | |
| 748 | #else | ||
| 749 | // each config packet occupies 64 * stringsPerPru() bytes per PRU per | ||
| 750 | // repeat, so the packet area scales with the chain depth | ||
| 751 | 23 | m_fv5PacketMem = (uint8_t*)calloc(1, (size_t)128 * 1024 * (m_stringsPerPin / 8)); | |
| 752 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 1 times.
|
23 | setupFalconV5Support(root, m_fv5PacketMem); |
| 753 | #endif | ||
| 754 | } | ||
| 755 | |||
| 756 |
3/4✓ Branch 0 taken 22 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
|
58 | if (falconV5Support && m_frameTimeUs > 0) { |
| 757 | // A query frame costs every pin the packet phase and the listen | ||
| 758 | // window on top of the pixel data: 69us of lead-in, 57 bytes of 10 | ||
| 759 | // cells at 1130ns, 35us of listener lead-in and a window of 500us, | ||
| 760 | // extended by 1.6ms when the receiver answers. Measured on a K8-Max | ||
| 761 | // from the PRU's frame counter: +2.85ms answered, +1.2ms when no | ||
| 762 | // receiver answers. Spread over the frames that carry one so the | ||
| 763 | // ceiling (and the warning) is honest for a receiver config: at | ||
| 764 | // 768px per port and 40fps the string data alone fits, the queries | ||
| 765 | // do not, and without this term the drops came with no warning. | ||
| 766 | // How often a query goes out depends on the frame rate (see | ||
| 767 | // FalconV5Support::setFrameBudget), so the estimate without queries | ||
| 768 | // is kept and the query term is added again whenever the spacing | ||
| 769 | // changes. | ||
| 770 | 22 | m_frameTimeBaseUs = m_frameTimeUs; | |
| 771 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 | applyV5QueryCost(true); |
| 772 | } | ||
| 773 | |||
| 774 | // flag the virtual strings whose channel map is a plain run so prepData | ||
| 775 | // can walk the channel data directly instead of through the map | ||
| 776 |
1/2✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
|
58 | m_vsAffine.resize(m_strings.size()); |
| 777 |
2/2✓ Branch 0 taken 421 times.
✓ Branch 1 taken 58 times.
|
479 | for (size_t s = 0; s < m_strings.size(); s++) { |
| 778 |
1/2✓ Branch 0 taken 421 times.
✗ Branch 1 not taken.
|
421 | m_vsAffine[s].resize(m_strings[s]->m_virtualStrings.size()); |
| 779 |
2/2✓ Branch 0 taken 422 times.
✓ Branch 1 taken 421 times.
|
843 | for (size_t v = 0; v < m_strings[s]->m_virtualStrings.size(); v++) { |
| 780 | 422 | auto& vs = m_strings[s]->m_virtualStrings[v]; | |
| 781 | 422 | bool affine = true; | |
| 782 |
2/2✓ Branch 0 taken 41227 times.
✓ Branch 1 taken 421 times.
|
41648 | for (int i = 0; i + 3 < vs.chMapCount; i++) { |
| 783 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 41226 times.
|
41227 | if (vs.chMap[i + 3] != vs.chMap[i] + 3) { |
| 784 | 1 | affine = false; | |
| 785 | 1 | break; | |
| 786 | } | ||
| 787 | } | ||
| 788 | 422 | m_vsAffine[s][v] = affine; | |
| 789 | } | ||
| 790 | } | ||
| 791 | |||
| 792 |
1/2✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
|
58 | PixelString::AutoCreateOverlayModels(m_strings, m_autoCreatedModelNames); |
| 793 | 58 | return retVal; | |
| 794 | 64 | } | |
| 795 | |||
| 796 | // Bit timing, as PRU cycle counts, published where the firmware's per-bit | ||
| 797 | // waits read them (TIMING_*_OFFSET in BBShiftString.asm - the unused "buffer" | ||
| 798 | // words, which have to be in the low 256 bytes because LBCO's offset field is | ||
| 799 | // 8 bit). The firmware spins on the marker before its first frame, so the | ||
| 800 | // three counts must be written before it. | ||
| 801 | // | ||
| 802 | // The waits count from a clock reset at the start of the bit, and the macro | ||
| 803 | // spends a few instructions between reading the counter and entering its | ||
| 804 | // delay loop, so the target is reduced by that overhead here rather than on | ||
| 805 | // the PRU. The immediate form compensated 3 (LDI+MAX+SUB); the runtime form | ||
| 806 | // reads through LBCO instead of LDI, which is slower. | ||
| 807 | constexpr int TIMING_OVERHEAD_CYCLES = 5; | ||
| 808 | |||
| 809 | // ns per PRU cycle: 200MHz on the AM335x, 250MHz on the AM62x | ||
| 810 | #ifdef PLATFORM_BBB | ||
| 811 | constexpr int PRU_NS_PER_CYCLE = 5; | ||
| 812 | #else | ||
| 813 | constexpr int PRU_NS_PER_CYCLE = 4; | ||
| 814 | #endif | ||
| 815 | |||
| 816 | 186 | static uint32_t timingCycles(int ns) { | |
| 817 | 186 | int c = ns / PRU_NS_PER_CYCLE - TIMING_OVERHEAD_CYCLES; | |
| 818 | 186 | return (uint32_t)std::max(1, c); | |
| 819 | } | ||
| 820 | |||
| 821 | 62 | static void publishTiming(BBBPru* pru, int t0ns, int t1ns, int lowns) { | |
| 822 | 62 | volatile uint32_t* p = (volatile uint32_t*)(pru->data_ram + 16); | |
| 823 | 62 | p[0] = timingCycles(t0ns); // TIMING_T0_OFFSET | |
| 824 | 62 | p[1] = timingCycles(t1ns); // TIMING_T1_OFFSET | |
| 825 | 62 | p[2] = timingCycles(lowns); // TIMING_LOW_OFFSET | |
| 826 | 62 | __sync_synchronize(); | |
| 827 | 62 | p[3] = 0xA5A5A5A5; // TIMING_MAGIC_OFFSET, written last | |
| 828 | 62 | __sync_synchronize(); | |
| 829 | 62 | } | |
| 830 | |||
| 831 | // Publish the resolved clock/latch r30 bit numbers to the firmware (see | ||
| 832 | // PINCFG_OFFSET in BBShiftString.asm; the 0xA5 marker distinguishes a real | ||
| 833 | // config from cleared memory). Must land after run() - the firmware load | ||
| 834 | // clears the data RAM - and the firmware rereads it while waiting for the | ||
| 835 | // first frame command. | ||
| 836 | 62 | static void publishPinConfig(BBBPru* pru, int clockBit, int latchBit) { | |
| 837 | 62 | uint32_t v = (uint32_t)(clockBit & 0xFF) | (((uint32_t)(latchBit & 0xFF)) << 8) | (0xA5u << 24); | |
| 838 | 62 | *(volatile uint32_t*)(pru->data_ram + PINCFG_OFFSET) = v; | |
| 839 | 62 | __sync_synchronize(); | |
| 840 | 62 | } | |
| 841 | |||
| 842 | // A 16 deep chain shifts twice as many bytes per phase, keeps its output masks | ||
| 843 | // in the PRU scratchpad and stretches T0H, so it gets its own firmware image | ||
| 844 | // rather than a runtime switch (see SHIFT16 in BBShiftString.asm). | ||
| 845 | 63 | static std::string pruFirmware(int pru, int stringsPerPin) { | |
| 846 |
1/2✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
|
63 | std::string f = "/opt/fpp/src/non-gpl/BBShiftString/BBShiftString_pru" + std::to_string(pru); |
| 847 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 62 times.
|
63 | if (stringsPerPin == 16) { |
| 848 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | f += "_16"; |
| 849 | } | ||
| 850 |
1/2✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
|
126 | return f + ".out"; |
| 851 | 63 | } | |
| 852 | |||
| 853 | 61 | int BBShiftStringOutput::StartPRU() { | |
| 854 | 61 | m_curFrame = 0; | |
| 855 | 61 | m_bpOffered = 0; | |
| 856 | 61 | m_bpDeclined = 0; | |
| 857 | 61 | m_bpLastDeclined = false; | |
| 858 | 61 | m_bpWindowStart = {}; | |
| 859 |
2/2✓ Branch 0 taken 210 times.
✓ Branch 1 taken 61 times.
|
271 | for (auto& a : m_usedPins) { |
| 860 |
3/6✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 210 times.
✗ Branch 5 not taken.
|
630 | PinCapabilities::getPinByName(a.first).configPin(a.second, true, "BBShiftString"); |
| 861 | } | ||
| 862 | |||
| 863 | #ifdef PLATFORM_BBB | ||
| 864 | 3 | constexpr bool mapShared = false; | |
| 865 | #else | ||
| 866 | 58 | constexpr bool mapShared = true; | |
| 867 | |||
| 868 | // Where each PRU's data ring sits in the 32KB shared RAM. Halving it is | ||
| 869 | // required when both PRUs output strings, or when a panel driver owns the | ||
| 870 | // other half of a combo cape. A sole string PRU can have the rest, | ||
| 871 | // starting above the FalconV5 listener's capture area if a listener will | ||
| 872 | // run on the other PRU (the listener captures from the base upwards). | ||
| 873 | // | ||
| 874 | // 16 deep needs this: it drains the ring at 12.8MB/s, so a 16320 byte half | ||
| 875 | // is only 1.27ms of buffer against 1.60ms from the V5 layout (the listener | ||
| 876 | // reservation cannot shrink - see SMEMRing.hp). | ||
| 877 | 58 | uint32_t ringBase[2] = { SMEM_RING_SPLIT0_BASE, SMEM_RING_SPLIT1_BASE }; | |
| 878 | 58 | uint32_t ringSize[2] = { SMEM_RING_SPLIT_SIZE, SMEM_RING_SPLIT_SIZE }; | |
| 879 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
58 | const bool bothPrus = m_pru0.maxStringLen && m_pru1.maxStringLen; |
| 880 |
4/4✓ Branch 0 taken 22 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 1 times.
|
58 | const bool willListen = supportsV5Listeners && m_hasBidirSR; |
| 881 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 57 times.
|
58 | if (m_stringsPerPin == 16) { |
| 882 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if (bothPrus || m_sharedPRUSS) { |
| 883 | // 16 deep already fills a PRU's pins; needing both means the cape | ||
| 884 | // is asking for something the shared RAM cannot feed. | ||
| 885 | ✗ | LogErr(VB_CHANNELOUT, "BBShiftString: 16 strings per pin needs sole use of one PRU%s\n", | |
| 886 | m_sharedPRUSS ? " and cannot share the PRUSS with a panel driver" : ""); | ||
| 887 | ✗ | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: 16 strings per pin requires all strings on one PRU"); | |
| 888 | } else { | ||
| 889 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | int p = m_pru1.maxStringLen ? 1 : 0; |
| 890 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | if (willListen && p == 0) { |
| 891 | // the listener is a PRU0 program; strings must leave it free | ||
| 892 | ✗ | LogErr(VB_CHANNELOUT, "BBShiftString: FalconV5 listeners need PRU0, so the strings must be on PRU1\n"); | |
| 893 | ✗ | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: FalconV5 listeners require the strings on PRU1"); | |
| 894 | } | ||
| 895 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | ringBase[p] = willListen ? SMEM_RING_V5_BASE : SMEM_RING_DEFAULT_BASE; |
| 896 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | ringSize[p] = willListen ? SMEM_RING_V5_SIZE : SMEM_RING_DEFAULT_SIZE; |
| 897 | } | ||
| 898 | } | ||
| 899 |
3/4✓ Branch 0 taken 21 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
|
58 | LogDebug(VB_CHANNELOUT, "BBShiftString: ring pru0 %X/%d pru1 %X/%d (listener %d)\n", |
| 900 | ringBase[0], ringSize[0], ringBase[1], ringSize[1], willListen ? 1 : 0); | ||
| 901 | #endif | ||
| 902 |
1/2✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
|
61 | if (m_pru1.maxStringLen) { |
| 903 |
5/8✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
61 | m_pru1.pru = new BBBPru(1, mapShared, false); |
| 904 | 60 | m_pru1.pruData = (BBShiftStringData*)m_pru1.pru->data_ram; | |
| 905 |
4/6✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 59 times.
|
60 | if (!m_pru1.pru->run(pruFirmware(1, m_stringsPerPin), !m_sharedPRUSS)) { |
| 906 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | LogErr(VB_CHANNELOUT, "BBShiftString: Unable to start PRU1. May require a reboot.\n"); |
| 907 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: Unable to start PRU1. May require a reboot."); |
| 908 | 1 | return 0; | |
| 909 | } | ||
| 910 | 59 | publishPinConfig(m_pru1.pru, m_clockBit[1], m_latchBit[1]); | |
| 911 |
1/2✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
|
59 | publishTiming(m_pru1.pru, m_t0Ns, m_t1Ns, m_lowNs); |
| 912 | #ifndef PLATFORM_BBB | ||
| 913 | // the firmware polls for the ring location; the upper half of the | ||
| 914 | // shared RAM keeps clear of the FalconV5 listener capture area | ||
| 915 |
1/2✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
|
56 | m_pru1.ring.attach(m_pru1.pru, ringBase[1], ringSize[1], true); |
| 916 | #endif | ||
| 917 |
2/4✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
|
118 | createOutputLengths(m_pru1, "pru1"); |
| 918 |
1/2✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
|
59 | std::this_thread::sleep_for(std::chrono::milliseconds(10)); |
| 919 | } | ||
| 920 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 56 times.
|
59 | if (m_pru0.maxStringLen) { |
| 921 |
2/8✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
3 | m_pru0.pru = new BBBPru(0, mapShared, false); |
| 922 | 3 | m_pru0.pruData = (BBShiftStringData*)m_pru0.pru->data_ram; | |
| 923 |
3/6✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
|
3 | if (!m_pru0.pru->run(pruFirmware(0, m_stringsPerPin), !m_sharedPRUSS)) { |
| 924 | ✗ | LogErr(VB_CHANNELOUT, "BBShiftString: Unable to start PRU0. May require a reboot.\n"); | |
| 925 | ✗ | AddOutputConfigWarning(UNKNOWN_WARNING_ID, "BBShiftString: Unable to start PRU0. May require a reboot."); | |
| 926 | ✗ | return 0; | |
| 927 | } | ||
| 928 | 3 | publishPinConfig(m_pru0.pru, m_clockBit[0], m_latchBit[0]); | |
| 929 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
3 | publishTiming(m_pru0.pru, m_t0Ns, m_t1Ns, m_lowNs); |
| 930 | #ifndef PLATFORM_BBB | ||
| 931 | ✗ | m_pru0.ring.attach(m_pru0.pru, ringBase[0], ringSize[0], true); | |
| 932 | #endif | ||
| 933 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
|
9 | createOutputLengths(m_pru0, "pru0"); |
| 934 | } | ||
| 935 | #ifndef PLATFORM_BBB | ||
| 936 |
4/8✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 56 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
|
56 | if (!m_pumpThread.joinable() && (m_pru0.pru || m_pru1.pru)) { |
| 937 | 56 | m_pumpRunning = true; | |
| 938 |
1/2✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
|
56 | m_pumpThread = std::thread(&BBShiftStringOutput::runPumpThread, this); |
| 939 | } | ||
| 940 | #endif | ||
| 941 | 59 | return 1; | |
| 942 | } | ||
| 943 | 58 | void BBShiftStringOutput::StopPRU(bool wait) { | |
| 944 | // Send the stop command | ||
| 945 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
|
58 | if (m_pru0.pru) { |
| 946 | 3 | m_pru0.pruData->response = 0; | |
| 947 | 3 | m_pru0.pruData->command = 0xFFFF; | |
| 948 | } | ||
| 949 |
1/2✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
|
58 | if (m_pru1.pru) { |
| 950 | 58 | m_pru1.pruData->response = 0; | |
| 951 | 58 | m_pru1.pruData->command = 0xFFFF; | |
| 952 | } | ||
| 953 | 58 | __asm__ __volatile__("" :: | |
| 954 | : "memory"); | ||
| 955 | |||
| 956 |
1/2✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
|
58 | if (m_pru1.pru) { |
| 957 | 58 | int cnt = 0; | |
| 958 |
7/8✓ Branch 0 taken 1108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1066 times.
✓ Branch 3 taken 42 times.
✓ Branch 4 taken 1050 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 1050 times.
✓ Branch 7 taken 58 times.
|
1108 | while (wait && cnt < 25 && m_pru1.pruData->response != 0xFFFF) { |
| 959 |
1/2✓ Branch 0 taken 1050 times.
✗ Branch 1 not taken.
|
1050 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); |
| 960 | 1050 | cnt++; | |
| 961 | 1050 | __asm__ __volatile__("" :: | |
| 962 | : "memory"); | ||
| 963 | } | ||
| 964 | } | ||
| 965 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
|
58 | if (m_pru0.pru) { |
| 966 | 3 | int cnt = 0; | |
| 967 |
6/8✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 75 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 75 times.
✓ Branch 7 taken 3 times.
|
78 | while (wait && cnt < 25 && m_pru0.pruData->response != 0xFFFF) { |
| 968 |
1/2✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
|
75 | std::this_thread::sleep_for(std::chrono::milliseconds(1)); |
| 969 | 75 | cnt++; | |
| 970 | 75 | __asm__ __volatile__("" :: | |
| 971 | : "memory"); | ||
| 972 | } | ||
| 973 | } | ||
| 974 | // stop the pump before the PRU memory mappings go away | ||
| 975 | 58 | m_pumpRunning = false; | |
| 976 |
2/2✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
|
58 | if (m_pumpThread.joinable()) { |
| 977 | 55 | m_pumpThread.join(); | |
| 978 | } | ||
| 979 | |||
| 980 |
1/2✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
|
58 | if (m_pru1.pru) { |
| 981 | 58 | m_pru1.pru->stop(); | |
| 982 |
1/2✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
|
58 | delete m_pru1.pru; |
| 983 | 58 | m_pru1.pru = nullptr; | |
| 984 | } | ||
| 985 | |||
| 986 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 55 times.
|
58 | if (m_pru0.pru) { |
| 987 | 3 | m_pru0.pru->stop(); | |
| 988 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | delete m_pru0.pru; |
| 989 | 3 | m_pru0.pru = nullptr; | |
| 990 | } | ||
| 991 | 58 | } | |
| 992 | /* | ||
| 993 | * | ||
| 994 | */ | ||
| 995 | 58 | int BBShiftStringOutput::Close(void) { | |
| 996 | 58 | LogDebug(VB_CHANNELOUT, "BBShiftStringOutput::Close()\n"); | |
| 997 |
2/2✓ Branch 0 taken 395 times.
✓ Branch 1 taken 58 times.
|
453 | for (auto& n : m_autoCreatedModelNames) { |
| 998 |
1/2✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
|
395 | PixelOverlayManager::INSTANCE.removeAutoOverlayModel(n); |
| 999 | } | ||
| 1000 | 58 | StopPRU(); | |
| 1001 | 58 | setFrameRateWarning(false); | |
| 1002 | 58 | clearBudgetWarning(); | |
| 1003 |
2/2✓ Branch 0 taken 201 times.
✓ Branch 1 taken 58 times.
|
259 | for (auto& a : m_usedPins) { |
| 1004 |
2/4✓ Branch 0 taken 201 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 201 times.
✗ Branch 3 not taken.
|
201 | PinCapabilities::getPinByName(a.first).releasePin(); |
| 1005 | } | ||
| 1006 |
2/2✓ Branch 0 taken 21 times.
✓ Branch 1 taken 37 times.
|
58 | if (m_usesEnablePin) { |
| 1007 | 21 | PinCapabilities::getPinByName(PRU1_ENABLE_PIN).releasePin(); | |
| 1008 | } | ||
| 1009 | 58 | return ChannelOutput::Close(); | |
| 1010 | } | ||
| 1011 | |||
| 1012 | 116 | void BBShiftStringOutput::GetRequiredChannelRanges(const std::function<void(int, int)>& addRange) { | |
| 1013 | 116 | PixelString* ps = NULL; | |
| 1014 |
2/2✓ Branch 0 taken 842 times.
✓ Branch 1 taken 116 times.
|
958 | for (int s = 0; s < m_strings.size(); s++) { |
| 1015 | 842 | ps = m_strings[s]; | |
| 1016 | |||
| 1017 |
2/2✓ Branch 0 taken 844 times.
✓ Branch 1 taken 842 times.
|
1686 | for (auto& vs : ps->m_virtualStrings) { |
| 1018 | 844 | int min = FPPD_MAX_CHANNELS; | |
| 1019 | 844 | int max = -1; | |
| 1020 | |||
| 1021 | 844 | int* map = vs.chMap; | |
| 1022 |
2/2✓ Branch 0 taken 84840 times.
✓ Branch 1 taken 844 times.
|
85684 | for (int c = 0; c < vs.chMapCount; c++) { |
| 1023 | 84840 | int ch = map[c]; | |
| 1024 |
2/2✓ Branch 0 taken 84828 times.
✓ Branch 1 taken 12 times.
|
84840 | if (ch < FPPD_MAX_CHANNELS) { |
| 1025 | 84828 | min = std::min(min, ch); | |
| 1026 | 84828 | max = std::max(max, ch); | |
| 1027 | } | ||
| 1028 | } | ||
| 1029 |
2/2✓ Branch 0 taken 790 times.
✓ Branch 1 taken 54 times.
|
844 | if (min < max) { |
| 1030 |
1/2✓ Branch 0 taken 790 times.
✗ Branch 1 not taken.
|
790 | addRange(min, max); |
| 1031 | } | ||
| 1032 | } | ||
| 1033 | } | ||
| 1034 | 116 | } | |
| 1035 | 124 | void BBShiftStringOutput::OverlayTestData(unsigned char* channelData, int cycleNum, float percentOfCycle, int testType, const Json::Value& config) { | |
| 1036 | 124 | m_testCycle = cycleNum; | |
| 1037 | 124 | m_testType = testType; | |
| 1038 | 124 | m_testPercent = percentOfCycle; | |
| 1039 | |||
| 1040 | // We won't overlay the data here because we could have multiple strings | ||
| 1041 | // pointing at the same channel range so a per-port test cannot | ||
| 1042 | // be done via channel ranges. We'll record the test information and use | ||
| 1043 | // that in prepData | ||
| 1044 | 124 | } | |
| 1045 | |||
| 1046 | // 8x8 byte transpose: in, rows are 8 consecutive bytes of 8 strings; out, | ||
| 1047 | // rows are the 8 strings' bytes for 8 consecutive positions | ||
| 1048 | 5239856 | static inline void transpose8x8(uint8x8_t r[8]) { | |
| 1049 | 5239856 | uint8x8x2_t t0 = vtrn_u8(r[0], r[1]); | |
| 1050 | 5239856 | uint8x8x2_t t1 = vtrn_u8(r[2], r[3]); | |
| 1051 | 5239856 | uint8x8x2_t t2 = vtrn_u8(r[4], r[5]); | |
| 1052 | 5239856 | uint8x8x2_t t3 = vtrn_u8(r[6], r[7]); | |
| 1053 | 5241584 | uint16x4x2_t s0 = vtrn_u16(vreinterpret_u16_u8(t0.val[0]), vreinterpret_u16_u8(t1.val[0])); | |
| 1054 | 5241584 | uint16x4x2_t s1 = vtrn_u16(vreinterpret_u16_u8(t0.val[1]), vreinterpret_u16_u8(t1.val[1])); | |
| 1055 | 5241584 | uint16x4x2_t s2 = vtrn_u16(vreinterpret_u16_u8(t2.val[0]), vreinterpret_u16_u8(t3.val[0])); | |
| 1056 | 5241584 | uint16x4x2_t s3 = vtrn_u16(vreinterpret_u16_u8(t2.val[1]), vreinterpret_u16_u8(t3.val[1])); | |
| 1057 | 5241584 | uint32x2x2_t u0 = vtrn_u32(vreinterpret_u32_u16(s0.val[0]), vreinterpret_u32_u16(s2.val[0])); | |
| 1058 | 5241584 | uint32x2x2_t u1 = vtrn_u32(vreinterpret_u32_u16(s1.val[0]), vreinterpret_u32_u16(s3.val[0])); | |
| 1059 | 5241584 | uint32x2x2_t u2 = vtrn_u32(vreinterpret_u32_u16(s0.val[1]), vreinterpret_u32_u16(s2.val[1])); | |
| 1060 | 5241584 | uint32x2x2_t u3 = vtrn_u32(vreinterpret_u32_u16(s1.val[1]), vreinterpret_u32_u16(s3.val[1])); | |
| 1061 | 5239856 | r[0] = vreinterpret_u8_u32(u0.val[0]); | |
| 1062 | 5239856 | r[1] = vreinterpret_u8_u32(u1.val[0]); | |
| 1063 | 5239856 | r[2] = vreinterpret_u8_u32(u2.val[0]); | |
| 1064 | 5239856 | r[3] = vreinterpret_u8_u32(u3.val[0]); | |
| 1065 | 5239856 | r[4] = vreinterpret_u8_u32(u0.val[1]); | |
| 1066 | 5239856 | r[5] = vreinterpret_u8_u32(u1.val[1]); | |
| 1067 | 5239856 | r[6] = vreinterpret_u8_u32(u2.val[1]); | |
| 1068 | 5239856 | r[7] = vreinterpret_u8_u32(u3.val[1]); | |
| 1069 | 5239856 | } | |
| 1070 | |||
| 1071 | // Transpose one 8x8 block of the interleaved frame: eight source bytes, one | ||
| 1072 | // per data pin, taken inStride apart, become eight bit planes outStride apart. | ||
| 1073 | // SH selects which bit of the pixel byte this plane carries; the caller emits | ||
| 1074 | // SH 0 (the LSB, clocked out last) into the highest numbered plane. Within a | ||
| 1075 | // plane, lane i is the byte destined for shift register stage i. | ||
| 1076 | // | ||
| 1077 | // The reference implementation this replaces, per pixel byte: | ||
| 1078 | // for (int x = 0; x < 8; x++) { | ||
| 1079 | // iframe[7-x] = (buf[0] >> x) & 0x0101010101010101ULL; | ||
| 1080 | // iframe[7-x] |= ((buf[1] >> x) & mask) << 1; | ||
| 1081 | // ... one term per data pin ... | ||
| 1082 | // } | ||
| 1083 | // On 32 bit arm each of those 64 bit shifts is three instructions, hence NEON. | ||
| 1084 | template<int SH> | ||
| 1085 | 86458080 | static inline void bitFlipPlane(const uint8x8_t* buf, uint8_t* out) { | |
| 1086 | uint8x8_t b[8]; | ||
| 1087 | // vshr_n_u8 requires 1 <= n <= 8, so the LSB plane takes the bytes as they | ||
| 1088 | // are; vsli_n_u8 preserves the low bits of its first operand either way | ||
| 1089 | if constexpr (SH == 0) { | ||
| 1090 |
2/2✓ Branch 0 taken 43229040 times.
✓ Branch 1 taken 5403630 times.
|
97265340 | for (int k = 0; k < 8; ++k) { |
| 1091 | 86458080 | b[k] = buf[k]; | |
| 1092 | } | ||
| 1093 | } else { | ||
| 1094 |
2/2✓ Branch 0 taken 302603280 times.
✓ Branch 1 taken 37825410 times.
|
680857380 | for (int k = 0; k < 8; ++k) { |
| 1095 |
1/2✓ Branch 0 taken 60480 times.
✗ Branch 1 not taken.
|
1210413120 | b[k] = vshr_n_u8(buf[k], SH); |
| 1096 | } | ||
| 1097 | } | ||
| 1098 |
1/2✓ Branch 0 taken 8640 times.
✗ Branch 1 not taken.
|
86458080 | uint8x8_t tmp = vsli_n_u8(b[0], b[1], 1); |
| 1099 |
1/2✓ Branch 0 taken 8640 times.
✗ Branch 1 not taken.
|
86458080 | tmp = vsli_n_u8(tmp, b[2], 2); |
| 1100 |
1/2✓ Branch 0 taken 8640 times.
✗ Branch 1 not taken.
|
86458080 | tmp = vsli_n_u8(tmp, b[3], 3); |
| 1101 |
1/2✓ Branch 0 taken 8640 times.
✗ Branch 1 not taken.
|
86458080 | tmp = vsli_n_u8(tmp, b[4], 4); |
| 1102 |
1/2✓ Branch 0 taken 8640 times.
✗ Branch 1 not taken.
|
86458080 | tmp = vsli_n_u8(tmp, b[5], 5); |
| 1103 |
1/2✓ Branch 0 taken 8640 times.
✗ Branch 1 not taken.
|
86458080 | tmp = vsli_n_u8(tmp, b[6], 6); |
| 1104 |
2/4✓ Branch 0 taken 8640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8640 times.
✗ Branch 3 not taken.
|
172916160 | vst1_u8(out, vsli_n_u8(tmp, b[7], 7)); |
| 1105 | 86458080 | } | |
| 1106 | |||
| 1107 | template<int SPP> | ||
| 1108 | 187814 | void BBShiftStringOutput::bitFlipDataT(uint8_t* stringChannelData, uint8_t* bitSwapped, size_t len) { | |
| 1109 | 187814 | constexpr int NSTR = MAX_PINS_PER_PRU * SPP; | |
| 1110 | 187814 | uint8_t* iframe = bitSwapped; | |
| 1111 |
2/2✓ Branch 0 taken 5394630 times.
✓ Branch 1 taken 93907 times.
|
10977074 | for (size_t p = 0; p < len; p++) { |
| 1112 | // one 8x8 transpose per group of eight shift register stages; a 16 | ||
| 1113 | // deep chain is just two of them, landing in the two halves of each | ||
| 1114 | // plane | ||
| 1115 |
2/2✓ Branch 0 taken 5403630 times.
✓ Branch 1 taken 5394630 times.
|
21596520 | for (int h = 0; h < SPP / 8; ++h) { |
| 1116 | 10807260 | const int off = h * 8; | |
| 1117 | uint8x8_t buf[8]; | ||
| 1118 |
2/2✓ Branch 0 taken 43229040 times.
✓ Branch 1 taken 5403630 times.
|
97265340 | for (int k = 0; k < 8; ++k) { |
| 1119 |
1/2✓ Branch 0 taken 8640 times.
✗ Branch 1 not taken.
|
172916160 | buf[k] = vld1_u8(&stringChannelData[k * SPP + off]); |
| 1120 | } | ||
| 1121 |
1/2✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
|
10807260 | bitFlipPlane<0>(buf, &iframe[7 * SPP + off]); |
| 1122 |
1/2✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
|
10807260 | bitFlipPlane<1>(buf, &iframe[6 * SPP + off]); |
| 1123 |
1/2✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
|
10807260 | bitFlipPlane<2>(buf, &iframe[5 * SPP + off]); |
| 1124 |
1/2✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
|
10807260 | bitFlipPlane<3>(buf, &iframe[4 * SPP + off]); |
| 1125 |
1/2✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
|
10807260 | bitFlipPlane<4>(buf, &iframe[3 * SPP + off]); |
| 1126 |
1/2✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
|
10807260 | bitFlipPlane<5>(buf, &iframe[2 * SPP + off]); |
| 1127 |
1/2✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
|
10807260 | bitFlipPlane<6>(buf, &iframe[1 * SPP + off]); |
| 1128 |
1/2✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
|
10807260 | bitFlipPlane<7>(buf, &iframe[0 * SPP + off]); |
| 1129 | } | ||
| 1130 | 10789260 | iframe += NSTR; | |
| 1131 | 10789260 | stringChannelData += NSTR; | |
| 1132 | } | ||
| 1133 | 187814 | } | |
| 1134 | |||
| 1135 | 1542 | void BBShiftStringOutput::bitFlipData(uint8_t* stringChannelData, uint8_t* bitSwapped, size_t len) { | |
| 1136 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1542 times.
|
1542 | if (m_stringsPerPin == 16) { |
| 1137 | ✗ | bitFlipDataT<16>(stringChannelData, bitSwapped, len); | |
| 1138 | } else { | ||
| 1139 | 1542 | bitFlipDataT<8>(stringChannelData, bitSwapped, len); | |
| 1140 | } | ||
| 1141 | 1542 | } | |
| 1142 | |||
| 1143 | template<int SPP> | ||
| 1144 | 61164 | void BBShiftStringOutput::prepDataT(FrameData& d, unsigned char* channelData) { | |
| 1145 |
2/2✓ Branch 0 taken 15273 times.
✓ Branch 1 taken 15309 times.
|
61164 | if (d.maxStringLen == 0) { |
| 1146 | 30546 | return; | |
| 1147 | } | ||
| 1148 | 30618 | PixelStringTester* tester = nullptr; | |
| 1149 |
3/4✓ Branch 0 taken 121 times.
✓ Branch 1 taken 15188 times.
✓ Branch 2 taken 121 times.
✗ Branch 3 not taken.
|
30618 | if (m_testType && m_testCycle >= 0) { |
| 1150 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
242 | if (m_testType == 999 && falconV5Support && m_testCycle == 0) { |
| 1151 | ✗ | falconV5Support->sendCountPixelPackets(); | |
| 1152 | } | ||
| 1153 |
1/2✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
|
242 | tester = PixelStringTester::getPixelStringTester(m_testType); |
| 1154 | // null for a test type no string tester implements; the strings then | ||
| 1155 | // just send their normal data | ||
| 1156 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
|
242 | if (tester) { |
| 1157 | ✗ | tester->prepareTestData(m_testCycle, m_testPercent); | |
| 1158 | } | ||
| 1159 | } | ||
| 1160 | 30618 | constexpr int NSTR = MAX_PINS_PER_PRU * SPP; | |
| 1161 | // per string slot: either a fully prepared buffer (test mode) or the | ||
| 1162 | // PixelString whose virtual strings are rendered on the fly per tile, | ||
| 1163 | // with a cursor tracking where in the virtual string list the next tile | ||
| 1164 | // continues | ||
| 1165 | struct SlotSrc { | ||
| 1166 | const uint8_t* buf = nullptr; | ||
| 1167 | PixelString* ps = nullptr; | ||
| 1168 | const uint8_t* affine = nullptr; | ||
| 1169 | uint32_t len = 0; | ||
| 1170 | uint32_t vsIdx = 0; | ||
| 1171 | uint32_t vsOff = 0; | ||
| 1172 | uint8_t pad = 0; | ||
| 1173 | 30618 | } slots[MAX_PINS_PER_PRU][SPP]; | |
| 1174 | 30618 | uint32_t newMax = d.maxStringLen; | |
| 1175 |
2/2✓ Branch 0 taken 122472 times.
✓ Branch 1 taken 15309 times.
|
275562 | for (int y = 0; y < MAX_PINS_PER_PRU; ++y) { |
| 1176 |
2/2✓ Branch 0 taken 989376 times.
✓ Branch 1 taken 122472 times.
|
2223696 | for (int x = 0; x < SPP; ++x) { |
| 1177 | 1978752 | int idx = d.stringMap[y][x]; | |
| 1178 |
2/2✓ Branch 0 taken 158309 times.
✓ Branch 1 taken 831067 times.
|
1978752 | if (idx != -1) { |
| 1179 | 316618 | PixelString* ps = m_strings[idx]; | |
| 1180 | 316618 | uint32_t newLen = ps->m_outputBytes; | |
| 1181 | 316618 | SlotSrc& sl = slots[y][x]; | |
| 1182 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 158309 times.
|
316618 | if (tester) { |
| 1183 | ✗ | sl.buf = tester->createTestData(ps, m_testCycle, m_testPercent, channelData, newLen); | |
| 1184 | } else { | ||
| 1185 | 316618 | sl.ps = ps; | |
| 1186 | 316618 | sl.affine = m_vsAffine[idx].data(); | |
| 1187 | } | ||
| 1188 | 316618 | sl.len = newLen; | |
| 1189 | // Past the end of a string the port is parked at its idle | ||
| 1190 | // level, which an inverted line holds high. The data phase | ||
| 1191 | // still shifts whatever is in the buffer, so padding a short | ||
| 1192 | // inverted port with zeros would drop the line mid bit. | ||
| 1193 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 158309 times.
|
316618 | sl.pad = ps->m_isInverted ? 0xFF : 0x00; |
| 1194 | 316618 | newMax = std::max(newMax, newLen); | |
| 1195 | } | ||
| 1196 | } | ||
| 1197 | } | ||
| 1198 | 30618 | d.outputStringLen = newMax; | |
| 1199 | |||
| 1200 | // Interleave and bit flip the string data in tiles that stay in the L1 | ||
| 1201 | // cache. Interleaving the whole frame at once writes a byte every 64 | ||
| 1202 | // bytes which forces every cache line of the frame to be re-fetched for | ||
| 1203 | // every string once the frame no longer fits in cache. The brightness/ | ||
| 1204 | // gamma application is fused into the tile fill so the string bytes are | ||
| 1205 | // never staged in a full-size intermediate buffer, and virtual strings | ||
| 1206 | // whose channel map is a simple run (map[i+3] == map[i]+3, the normal | ||
| 1207 | // non-grouped case) skip the per-channel map indirection. | ||
| 1208 | 30618 | constexpr uint32_t TILE = 64; | |
| 1209 | uint8_t col[SPP][TILE]; | ||
| 1210 | uint8_t tile[TILE * NSTR]; | ||
| 1211 |
2/2✓ Branch 0 taken 92365 times.
✓ Branch 1 taken 15309 times.
|
215348 | for (uint32_t p0 = 0; p0 < newMax; p0 += TILE) { |
| 1212 | 184730 | const uint32_t n = std::min(TILE, newMax - p0); | |
| 1213 | 184730 | const uint32_t nFull = n & ~7; | |
| 1214 |
2/2✓ Branch 0 taken 738920 times.
✓ Branch 1 taken 92365 times.
|
1662570 | for (int y = 0; y < MAX_PINS_PER_PRU; ++y) { |
| 1215 |
2/2✓ Branch 0 taken 5920960 times.
✓ Branch 1 taken 738920 times.
|
13319760 | for (int x = 0; x < SPP; ++x) { |
| 1216 | 11841920 | SlotSrc& sl = slots[y][x]; | |
| 1217 |
2/2✓ Branch 0 taken 504749 times.
✓ Branch 1 taken 5416211 times.
|
11841920 | uint32_t avail = sl.len > p0 ? std::min(n, sl.len - p0) : 0; |
| 1218 | 11841920 | uint32_t p = 0; | |
| 1219 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5920960 times.
|
11841920 | if (sl.buf) { |
| 1220 | ✗ | memcpy(col[x], sl.buf + p0, avail); | |
| 1221 | ✗ | p = avail; | |
| 1222 |
2/2✓ Branch 0 taken 1752933 times.
✓ Branch 1 taken 4168027 times.
|
11841920 | } else if (sl.ps) { |
| 1223 | // A protocol preamble (TM1814's C1/C2 current words) is | ||
| 1224 | // constant and leads the port's stream, so it is consumed | ||
| 1225 | // out of the first tile before the virtual strings start. | ||
| 1226 | 3505866 | const auto& pre = sl.ps->m_preamble; | |
| 1227 |
4/6✓ Branch 0 taken 504749 times.
✓ Branch 1 taken 1248184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 504749 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1752933 times.
|
3505866 | while (p < avail && (p0 + p) < pre.size()) { |
| 1228 | ✗ | col[x][p] = pre[p0 + p]; | |
| 1229 | ✗ | ++p; | |
| 1230 | } | ||
| 1231 | 3505866 | auto& vstrings = sl.ps->m_virtualStrings; | |
| 1232 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1752933 times.
|
3505866 | if (sl.ps->m_bytesPerChannel == 2) { |
| 1233 | // 16 bit part: two bytes per channel, most significant | ||
| 1234 | // first. vsOff counts wire bytes here rather than | ||
| 1235 | // channels, so the channel index is vsOff >> 1. Kept | ||
| 1236 | // as its own loop so the 8 bit path below is untouched. | ||
| 1237 | ✗ | while (p < avail && sl.vsIdx < vstrings.size()) { | |
| 1238 | ✗ | auto& vs = vstrings[sl.vsIdx]; | |
| 1239 | ✗ | uint32_t vsBytes = (uint32_t)vs.chMapCount * 2; | |
| 1240 | ✗ | uint32_t m = std::min(avail - p, vsBytes - sl.vsOff); | |
| 1241 | ✗ | const uint16_t* br = vs.brightnessMap16; | |
| 1242 | ✗ | const int* mp = vs.chMap; | |
| 1243 | ✗ | for (uint32_t k = 0; k < m; ++k) { | |
| 1244 | ✗ | uint32_t wb = sl.vsOff + k; | |
| 1245 | ✗ | uint16_t v = br[channelData[mp[wb >> 1]]]; | |
| 1246 | ✗ | col[x][p++] = (wb & 1) ? (uint8_t)v : (uint8_t)(v >> 8); | |
| 1247 | } | ||
| 1248 | ✗ | sl.vsOff += m; | |
| 1249 | ✗ | if (sl.vsOff >= vsBytes) { | |
| 1250 | ✗ | sl.vsOff = 0; | |
| 1251 | ✗ | sl.vsIdx++; | |
| 1252 | } | ||
| 1253 | } | ||
| 1254 | ✗ | if (p < n) { | |
| 1255 | ✗ | memset(&col[x][p], sl.pad, n - p); | |
| 1256 | } | ||
| 1257 | ✗ | continue; | |
| 1258 | ✗ | } | |
| 1259 |
5/6✓ Branch 0 taken 505066 times.
✓ Branch 1 taken 1752933 times.
✓ Branch 2 taken 505066 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 505066 times.
✓ Branch 5 taken 1752933 times.
|
4515998 | while (p < avail && sl.vsIdx < vstrings.size()) { |
| 1260 | 1010132 | auto& vs = vstrings[sl.vsIdx]; | |
| 1261 | 1010132 | uint32_t m = std::min(avail - p, (uint32_t)vs.chMapCount - sl.vsOff); | |
| 1262 | 1010132 | const uint8_t* br = vs.brightnessMap; | |
| 1263 | 1010132 | const int* mp = vs.chMap; | |
| 1264 |
2/2✓ Branch 0 taken 504749 times.
✓ Branch 1 taken 317 times.
|
1010132 | if (sl.affine[sl.vsIdx]) { |
| 1265 | 1009498 | uint32_t c = sl.vsOff % 3; | |
| 1266 | 1009498 | int32_t base = (int32_t)(sl.vsOff - c); | |
| 1267 |
2/2✓ Branch 0 taken 25965288 times.
✓ Branch 1 taken 504749 times.
|
52940074 | for (uint32_t k = 0; k < m; ++k) { |
| 1268 | 51930576 | col[x][p++] = br[channelData[mp[c] + base]]; | |
| 1269 |
2/2✓ Branch 0 taken 8655096 times.
✓ Branch 1 taken 17310192 times.
|
51930576 | if (++c == 3) { |
| 1270 | 17310192 | c = 0; | |
| 1271 | 17310192 | base += 3; | |
| 1272 | } | ||
| 1273 | } | ||
| 1274 | } else { | ||
| 1275 | 634 | const int* mo = mp + sl.vsOff; | |
| 1276 |
2/2✓ Branch 0 taken 3804 times.
✓ Branch 1 taken 317 times.
|
8242 | for (uint32_t k = 0; k < m; ++k) { |
| 1277 | 7608 | col[x][p++] = br[channelData[mo[k]]]; | |
| 1278 | } | ||
| 1279 | } | ||
| 1280 | 1010132 | sl.vsOff += m; | |
| 1281 |
2/2✓ Branch 0 taken 157482 times.
✓ Branch 1 taken 347584 times.
|
1010132 | if (sl.vsOff >= (uint32_t)vs.chMapCount) { |
| 1282 | 314964 | sl.vsOff = 0; | |
| 1283 | 314964 | sl.vsIdx++; | |
| 1284 | } | ||
| 1285 | } | ||
| 1286 | } | ||
| 1287 |
2/2✓ Branch 0 taken 5520125 times.
✓ Branch 1 taken 400835 times.
|
11841920 | if (p < n) { |
| 1288 | 11040250 | memset(&col[x][p], sl.pad, n - p); | |
| 1289 | } | ||
| 1290 | } | ||
| 1291 | 1477840 | uint32_t g = 0; | |
| 1292 |
2/2✓ Branch 0 taken 5231456 times.
✓ Branch 1 taken 738920 times.
|
11940752 | for (; g < nFull; g += 8) { |
| 1293 | // transpose8x8 handles eight strings at a time, so a 16 deep | ||
| 1294 | // chain needs one pass per half, each landing in its own half | ||
| 1295 | // of the pin's slot range | ||
| 1296 |
2/2✓ Branch 0 taken 5239856 times.
✓ Branch 1 taken 5231456 times.
|
20942624 | for (int h = 0; h < SPP / 8; ++h) { |
| 1297 | uint8x8_t r[8]; | ||
| 1298 |
2/2✓ Branch 0 taken 41918848 times.
✓ Branch 1 taken 5239856 times.
|
94317408 | for (int x = 0; x < 8; ++x) { |
| 1299 |
1/2✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
|
167675392 | r[x] = vld1_u8(&col[h * 8 + x][g]); |
| 1300 | } | ||
| 1301 | 10479712 | transpose8x8(r); | |
| 1302 |
2/2✓ Branch 0 taken 41918848 times.
✓ Branch 1 taken 5239856 times.
|
94317408 | for (int i = 0; i < 8; i++) { |
| 1303 |
1/2✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
|
83837696 | vst1_u8(&tile[(g + i) * NSTR + y * SPP + h * 8], r[i]); |
| 1304 | } | ||
| 1305 | } | ||
| 1306 | } | ||
| 1307 |
2/2✓ Branch 0 taken 602240 times.
✓ Branch 1 taken 738920 times.
|
2682320 | for (uint32_t p = g; p < n; ++p) { |
| 1308 |
2/2✓ Branch 0 taken 4856320 times.
✓ Branch 1 taken 602240 times.
|
10917120 | for (int x = 0; x < SPP; ++x) { |
| 1309 | 9712640 | tile[p * NSTR + y * SPP + x] = col[x][p]; | |
| 1310 | } | ||
| 1311 | } | ||
| 1312 | } | ||
| 1313 |
1/2✓ Branch 0 taken 92365 times.
✗ Branch 1 not taken.
|
184730 | bitFlipDataT<SPP>(tile, d.formattedData + (size_t)p0 * NSTR, n); |
| 1314 | } | ||
| 1315 | } | ||
| 1316 | |||
| 1317 | // The firmware counts the frames it had to re-seat onto the published frame | ||
| 1318 | // start (see CONT_DATA in BBShiftString.asm). In a healthy system this stays | ||
| 1319 | // zero for the life of the output; anything else means the two sides disagreed | ||
| 1320 | // about a frame's length and the resync covered for it, at the cost of one | ||
| 1321 | // glitched frame. | ||
| 1322 | 290 | void BBShiftStringOutput::reportRingResync(FrameData& d, int pru) { | |
| 1323 | #ifndef PLATFORM_BBB | ||
| 1324 |
2/2✓ Branch 0 taken 145 times.
✓ Branch 1 taken 145 times.
|
290 | if (!d.pruData) { |
| 1325 | 145 | return; | |
| 1326 | } | ||
| 1327 | 145 | uint32_t n = *(volatile uint32_t*)((uint8_t*)d.pruData + SMEM_RING_RESYNC_OFFSET); | |
| 1328 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 144 times.
|
145 | if (n != d.resyncCount) { |
| 1329 | 1 | LogWarn(VB_CHANNELOUT, "BBShiftString: PRU%d ring read position re-seated %u time(s) (%u total); a frame was glitched but the output is aligned\n", | |
| 1330 | pru, n - d.resyncCount, n); | ||
| 1331 | 1 | d.resyncCount = n; | |
| 1332 | } | ||
| 1333 | #endif | ||
| 1334 | ✗ | } | |
| 1335 | |||
| 1336 | 30582 | void BBShiftStringOutput::prepData(FrameData& d, unsigned char* channelData) { | |
| 1337 |
2/2✓ Branch 0 taken 300 times.
✓ Branch 1 taken 30282 times.
|
30582 | if (m_stringsPerPin == 16) { |
| 1338 | 300 | prepDataT<16>(d, channelData); | |
| 1339 | } else { | ||
| 1340 | 30282 | prepDataT<8>(d, channelData); | |
| 1341 | } | ||
| 1342 | 30582 | } | |
| 1343 | |||
| 1344 | 15291 | void BBShiftStringOutput::PrepData(unsigned char* channelData) { | |
| 1345 | 15291 | LogExcess(VB_CHANNELOUT, "BBShiftStringOutput::PrepData(%p)\n", channelData); | |
| 1346 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15291 times.
|
15291 | if (!hasStrings()) { |
| 1347 | ✗ | return; | |
| 1348 | } | ||
| 1349 | // auto start = std::chrono::high_resolution_clock::now(); | ||
| 1350 | 15291 | m_curFrame++; | |
| 1351 | |||
| 1352 | // the firmware heals a ring misalignment on its own, but it should never | ||
| 1353 | // have to - surface it rather than let it stay silent | ||
| 1354 |
2/2✓ Branch 0 taken 145 times.
✓ Branch 1 taken 15146 times.
|
15291 | if ((m_curFrame % 100) == 0) { |
| 1355 | 145 | reportRingResync(m_pru0, 0); | |
| 1356 | 145 | reportRingResync(m_pru1, 1); | |
| 1357 | } | ||
| 1358 | |||
| 1359 | 15291 | prepData(m_pru0, channelData); | |
| 1360 | 15291 | prepData(m_pru1, channelData); | |
| 1361 | 15291 | m_testCycle = -1; | |
| 1362 | |||
| 1363 | // PrepData runs for every offered frame, but the cursor only moves for a | ||
| 1364 | // frame SendData's back-pressure gate accepts. A dynamic packet parks in | ||
| 1365 | // the slot, so a declined frame finds it there and asks for nothing; a | ||
| 1366 | // "no packet" answer leaves the slot empty, so it is remembered in | ||
| 1367 | // m_v5RestPending instead. Asking again would get the next query, and | ||
| 1368 | // over budget every rest frame went that way: one V5 chain measured 45% | ||
| 1369 | // query frames under budget and 89% over it, each ~2.85ms long, so | ||
| 1370 | // going over budget pushed it further over. | ||
| 1371 |
6/6✓ Branch 0 taken 14213 times.
✓ Branch 1 taken 1078 times.
✓ Branch 2 taken 5413 times.
✓ Branch 3 taken 8800 times.
✓ Branch 4 taken 4413 times.
✓ Branch 5 taken 1000 times.
|
15291 | if (m_pru1.curV5ConfigPacket > FIRST_LOOPING_CONFIG_PACKET && falconV5Support && !m_v5RestPending && |
| 1372 |
2/2✓ Branch 0 taken 2927 times.
✓ Branch 1 taken 1486 times.
|
4413 | m_pru1.v5_config_packets[m_pru1.curV5ConfigPacket] == nullptr) { |
| 1373 | 2927 | std::vector<std::array<uint8_t, 64>> packets; | |
| 1374 |
1/2✓ Branch 0 taken 2927 times.
✗ Branch 1 not taken.
|
2927 | packets.resize(m_strings.size()); |
| 1375 |
2/2✓ Branch 0 taken 64796 times.
✓ Branch 1 taken 2927 times.
|
67723 | for (auto& p : packets) { |
| 1376 | 64796 | memset(&p[0], 0, 64); | |
| 1377 | } | ||
| 1378 | 2927 | bool listen = false; | |
| 1379 |
3/4✓ Branch 0 taken 2927 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1460 times.
✓ Branch 3 taken 1467 times.
|
2927 | if (falconV5Support->generateDynamicPacket(packets, listen)) { |
| 1380 |
1/2✓ Branch 0 taken 1460 times.
✗ Branch 1 not taken.
|
1460 | applySendOnlyConfigPackets(packets); |
| 1381 |
2/2✓ Branch 0 taken 730 times.
✓ Branch 1 taken 730 times.
|
1460 | if (m_pru0.dynamicPacketInfo == &m_pru0.dynamicPacketInfo1) { |
| 1382 | 730 | m_pru0.dynamicPacketInfo = &m_pru0.dynamicPacketInfo2; | |
| 1383 | 730 | m_pru1.dynamicPacketInfo = &m_pru1.dynamicPacketInfo2; | |
| 1384 | } else { | ||
| 1385 | 730 | m_pru0.dynamicPacketInfo = &m_pru0.dynamicPacketInfo1; | |
| 1386 | 730 | m_pru1.dynamicPacketInfo = &m_pru1.dynamicPacketInfo1; | |
| 1387 | } | ||
| 1388 |
1/2✓ Branch 0 taken 1460 times.
✗ Branch 1 not taken.
|
1460 | encodeFalconV5Packet(packets, m_pru0.dynamicPacketInfo->data, m_pru1.dynamicPacketInfo->data); |
| 1389 | 1460 | m_pru0.dynamicPacketInfo->listen = listen; | |
| 1390 | 1460 | m_pru1.dynamicPacketInfo->listen = listen; | |
| 1391 | 1460 | m_pru0.v5_config_packets[m_pru0.curV5ConfigPacket] = m_pru0.dynamicPacketInfo; | |
| 1392 | 1460 | m_pru1.v5_config_packets[m_pru1.curV5ConfigPacket] = m_pru1.dynamicPacketInfo; | |
| 1393 | } else { | ||
| 1394 | 1467 | m_v5RestPending = true; | |
| 1395 | } | ||
| 1396 | 2927 | } | |
| 1397 | |||
| 1398 | /* | ||
| 1399 | uint32_t *iframe = (uint32_t*)m_pru1.curData; | ||
| 1400 | for (int x = 0; x < 3; x++) { | ||
| 1401 | for (int y = 0; y < 8; y++) { | ||
| 1402 | printf("%8X ", iframe[y]); | ||
| 1403 | } | ||
| 1404 | printf("\n"); | ||
| 1405 | iframe += 8; | ||
| 1406 | } | ||
| 1407 | printf("\n"); | ||
| 1408 | */ | ||
| 1409 | // auto finish = std::chrono::high_resolution_clock::now(); | ||
| 1410 | // auto total =std::chrono::duration_cast<std::chrono::nanoseconds>(finish-start).count(); | ||
| 1411 | // printf("Total: %lld\n", total); | ||
| 1412 | } | ||
| 1413 | |||
| 1414 | 11384 | void BBShiftStringOutput::sendData(FrameData& d) { | |
| 1415 |
2/2✓ Branch 0 taken 5696 times.
✓ Branch 1 taken 5688 times.
|
11384 | if (d.outputStringLen) { |
| 1416 | #ifdef PLATFORM_BBB | ||
| 1417 | // only the bytes the PRU will consume need to be copied; the DDR | ||
| 1418 | // region is mapped non-cacheable, so there is nothing to flush | ||
| 1419 | // (SendData's frameDataBarrier() orders it before the command) | ||
| 1420 | 24 | uint32_t bytes = d.outputStringLen * stringsPerPru(); | |
| 1421 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
|
24 | if (bytes > d.frameSize) { |
| 1422 | ✗ | bytes = d.frameSize; | |
| 1423 | } | ||
| 1424 | 24 | memcpy(d.curData, d.formattedData, bytes); | |
| 1425 | |||
| 1426 | 24 | d.pruData->address_dma = (d.pru->ddr_addr + (d.curData - d.pru->ddr)); | |
| 1427 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
|
24 | if (d.v5_config_packets[d.curV5ConfigPacket]) { |
| 1428 | ✗ | d.pruData->address_dma_packet = (d.pru->ddr_addr + (d.v5_config_packets[d.curV5ConfigPacket]->data - d.pru->ddr)); | |
| 1429 | } else { | ||
| 1430 | 24 | d.pruData->address_dma_packet = 0; | |
| 1431 | } | ||
| 1432 | 24 | std::swap(d.lastData, d.curData); | |
| 1433 | #else | ||
| 1434 | // the pump thread streams the frame (and any FalconV5 packet data) | ||
| 1435 | // into the shared memory ring in exactly the order the firmware | ||
| 1436 | // consumes blocks; the PRU consumes one 64 byte block per byte of | ||
| 1437 | // string data | ||
| 1438 | 5672 | uint32_t bytes = d.outputStringLen * stringsPerPru(); | |
| 1439 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5672 times.
|
5672 | if (bytes > d.frameSize) { |
| 1440 | ✗ | bytes = d.frameSize; | |
| 1441 | } | ||
| 1442 | 5672 | memcpy(d.curData, d.formattedData, bytes); | |
| 1443 | 5672 | d.pendingFrame.frameData = d.curData; | |
| 1444 | 5672 | d.pendingFrame.frameBytes = bytes; | |
| 1445 | 5672 | auto* pi = d.v5_config_packets[d.curV5ConfigPacket]; | |
| 1446 |
3/4✓ Branch 0 taken 1783 times.
✓ Branch 1 taken 3889 times.
✓ Branch 2 taken 1783 times.
✗ Branch 3 not taken.
|
5672 | if (pi && pi->data) { |
| 1447 | 1783 | d.pendingFrame.packetData = pi->data; | |
| 1448 | 1783 | d.pendingFrame.packetBytes = 57 * stringsPerPru() * pi->len; | |
| 1449 | } else { | ||
| 1450 | 3889 | d.pendingFrame.packetData = nullptr; | |
| 1451 | 3889 | d.pendingFrame.packetBytes = 0; | |
| 1452 | } | ||
| 1453 | 5672 | std::swap(d.lastData, d.curData); | |
| 1454 | #endif | ||
| 1455 | } | ||
| 1456 | 11384 | } | |
| 1457 | |||
| 1458 | // Extra time of one answered FalconV5 query frame on top of the pixel data, | ||
| 1459 | // see the estimate in Init() | ||
| 1460 | static constexpr float V5_QUERY_FRAME_US = 2850.0f; | ||
| 1461 | |||
| 1462 | // Persistent UI warning for "the sequence rate is past what these strings can | ||
| 1463 | // clock out". The flag is per output so Close() can retract it; a warning left | ||
| 1464 | // behind by an output that no longer exists has nothing left to clear it. | ||
| 1465 | 122 | void BBShiftStringOutput::setFrameRateWarning(bool on) { | |
| 1466 | static const std::string BP_WARN = | ||
| 1467 |
4/8✓ Branch 0 taken 40 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
202 | "Sequence frame rate is higher than the configured pixel strings can output; frames are being dropped"; |
| 1468 |
2/2✓ Branch 0 taken 118 times.
✓ Branch 1 taken 4 times.
|
122 | if (on == m_bpWarned) { |
| 1469 | 118 | return; | |
| 1470 | } | ||
| 1471 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | if (on) { |
| 1472 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | WarningHolder::AddWarning(63, BP_WARN); |
| 1473 | } else { | ||
| 1474 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
4 | WarningHolder::RemoveWarning(63, BP_WARN); |
| 1475 | } | ||
| 1476 | 4 | m_bpWarned = on; | |
| 1477 | } | ||
| 1478 | |||
| 1479 | // The frame-time estimate: the base from Init() plus the FalconV5 query frames | ||
| 1480 | // at the share the scheduler runs with. Rebuilt whenever the query spacing | ||
| 1481 | // changes. At Init the frame rate, and so the spacing, is not known yet; the | ||
| 1482 | // line is logged again with the real spacing if the first sequence changes it. | ||
| 1483 | 22 | void BBShiftStringOutput::applyV5QueryCost(bool atInit) { | |
| 1484 | 22 | m_frameTimeUs = m_frameTimeBaseUs; | |
| 1485 | 22 | float share = falconV5Support->queryFrameShare(); | |
| 1486 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 2 times.
|
22 | if (share > 0.0f) { |
| 1487 | 20 | m_frameTimeUs += (int)(V5_QUERY_FRAME_US * share); | |
| 1488 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | LogInfo(VB_CHANNELOUT, "BBShiftString: FalconV5 queries on %.0f%% of frames (%d extra rest frames per round%s) -> %.1fms/frame, sustainable ceiling ~%.4g fps\n", |
| 1489 | share * 100.0f, falconV5Support->getQueryRestFrames(), atInit ? ", before the frame rate is known" : "", | ||
| 1490 | m_frameTimeUs / 1000.0, 1000000.0 / m_frameTimeUs); | ||
| 1491 | } | ||
| 1492 | 22 | } | |
| 1493 | |||
| 1494 | // Predictive companion to the measured warning above, run whenever the | ||
| 1495 | // refresh rate changes. Sequence.cpp publishes the sequence's rate before the | ||
| 1496 | // first frame reaches SendData(), so an over-budget configuration is flagged | ||
| 1497 | // immediately instead of after a minute of measured drops - and a rate that | ||
| 1498 | // changes mid-playlist (sequences at different frame rates back to back, where | ||
| 1499 | // the output thread never restarts) is caught on the next frame. | ||
| 1500 | 46 | void BBShiftStringOutput::checkFrameRateBudget(float rate) { | |
| 1501 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
|
46 | if (m_frameTimeUs <= 0) { |
| 1502 | ✗ | return; | |
| 1503 | } | ||
| 1504 | // the query spacing follows the frame rate's slack; the ceiling below has | ||
| 1505 | // to use the share the scheduler will actually run with | ||
| 1506 |
4/6✓ Branch 0 taken 10 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 46 times.
|
56 | if (falconV5Support && m_frameTimeBaseUs > 0 && |
| 1507 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
|
10 | falconV5Support->setFrameBudget(rate, m_frameTimeBaseUs, (int)V5_QUERY_FRAME_US)) { |
| 1508 | ✗ | applyV5QueryCost(); | |
| 1509 | } | ||
| 1510 | 46 | float ceiling = 1000000.0f / m_frameTimeUs; | |
| 1511 | // 5% grace: covers the overhead constants' own uncertainty and keeps a | ||
| 1512 | // config a hair past budget - absorbed invisibly by the back-pressure | ||
| 1513 | // gate - quiet | ||
| 1514 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 45 times.
|
46 | if (rate > ceiling * 1.05f) { |
| 1515 | char buf[192]; | ||
| 1516 | 1 | snprintf(buf, sizeof(buf), | |
| 1517 | "Sequence frame rate (%.4g fps) is higher than the configured pixel strings can output (~%.4g fps); frames will be dropped", | ||
| 1518 | rate, ceiling); | ||
| 1519 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | std::string msg = buf; |
| 1520 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (msg != m_budgetWarnText) { |
| 1521 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | clearBudgetWarning(); |
| 1522 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | LogWarn(VB_CHANNELOUT, "BBShiftString: %s\n", msg.c_str()); |
| 1523 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | WarningHolder::AddWarning(63, msg); |
| 1524 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | m_budgetWarnText = msg; |
| 1525 | } | ||
| 1526 | 1 | } else { | |
| 1527 | 45 | clearBudgetWarning(); | |
| 1528 | } | ||
| 1529 | } | ||
| 1530 | |||
| 1531 | 166 | void BBShiftStringOutput::clearBudgetWarning() { | |
| 1532 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 165 times.
|
166 | if (!m_budgetWarnText.empty()) { |
| 1533 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
2 | WarningHolder::RemoveWarning(63, m_budgetWarnText); |
| 1534 | 1 | m_budgetWarnText.clear(); | |
| 1535 | } | ||
| 1536 | 166 | } | |
| 1537 | |||
| 1538 | 15216 | int BBShiftStringOutput::SendData(unsigned char* channelData) { | |
| 1539 | 15216 | LogExcess(VB_CHANNELOUT, "BBShiftStringOutput::SendData(%p)\n", channelData); | |
| 1540 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15216 times.
|
15216 | if (!hasStrings()) { |
| 1541 | ✗ | return 0; | |
| 1542 | } | ||
| 1543 | |||
| 1544 | 15216 | float bwRate = GetChannelOutputRefreshRate(); | |
| 1545 |
2/2✓ Branch 0 taken 46 times.
✓ Branch 1 taken 15170 times.
|
15216 | if (bwRate != m_lastBudgetRate) { |
| 1546 | 46 | m_lastBudgetRate = bwRate; | |
| 1547 | 46 | checkFrameRateBudget(bwRate); | |
| 1548 | } | ||
| 1549 | |||
| 1550 |
2/2✓ Branch 0 taken 5518 times.
✓ Branch 1 taken 9698 times.
|
15216 | if (falconV5Support) { |
| 1551 | 5518 | falconV5Support->processListenerData(); | |
| 1552 | } | ||
| 1553 | |||
| 1554 | #ifndef PLATFORM_BBB | ||
| 1555 | // ---- back-pressure gate -------------------------------------------------- | ||
| 1556 | // pumpFrameData() only snapshots pendingFrame once the firmware is ready for | ||
| 1557 | // another frame (command == 0 && ring drained). A frame staged before that | ||
| 1558 | // point is simply overwritten and never rendered. When the requested frame | ||
| 1559 | // rate exceeds what the configured string length can physically clock out, | ||
| 1560 | // that surplus of never-rendered frames is what eventually leaves the PRU | ||
| 1561 | // ring misaligned (#2855). Declining the frame while the previous one is | ||
| 1562 | // still pending drives the surplus to zero at whatever rate the hardware | ||
| 1563 | // actually sustains - frame dropping at the source, with no fixed divisor | ||
| 1564 | // to mis-tune, and configurations already inside their budget are untouched | ||
| 1565 | // (nothing is pending when the next frame arrives, so nothing is declined). | ||
| 1566 | // | ||
| 1567 | // It is also what keeps the two-phase write of pendingFrame safe: sendData() | ||
| 1568 | // fills the byte counts and the block below fills the command, and only a | ||
| 1569 | // frame the pump has already taken may be restaged, so the pump can never | ||
| 1570 | // snapshot one phase of one frame with the other phase of the next. Ditto | ||
| 1571 | // the FalconV5 packet cursor - curV5ConfigPacket only advances for a frame | ||
| 1572 | // that will actually be streamed, where before, over budget, better than | ||
| 1573 | // half the receiver's config and dynamic packets were marked consumed and | ||
| 1574 | // never sent. | ||
| 1575 | // | ||
| 1576 | // AM335x never reaches this: it has no ring and no pump, every frame | ||
| 1577 | // restates its own DDR address and length, and pendingSeq is never bumped. | ||
| 1578 | // | ||
| 1579 | // Cannot wedge: we only decline while pendingSeq != pumpedSeq, so | ||
| 1580 | // pumpFrameData() still enters its busy branch and its 250ms watchdog | ||
| 1581 | // still runs. A PRU is only party to the gate if the pump actually | ||
| 1582 | // services it (pump thread condition below) - otherwise its pendingSeq | ||
| 1583 | // would climb against a pumpedSeq nothing advances and every frame, | ||
| 1584 | // including the other PRU's, would be declined forever. | ||
| 1585 | // | ||
| 1586 | // A declined frame is not retried, so a one-shot frame can land late: the | ||
| 1587 | // end-of-sequence blank is offered three times (the forced output, then | ||
| 1588 | // twice more as onceMore unwinds), the last of those BridgeLightDelay | ||
| 1589 | // (E131BridgingInterval, 50ms default) after the one before it, which is | ||
| 1590 | // past the drain time of any frame this gate declines. Set that interval | ||
| 1591 | // below a frame's clocking time and blanking would be delayed further. | ||
| 1592 | { | ||
| 1593 | 15204 | bool taken = true; | |
| 1594 |
3/6✓ Branch 0 taken 15204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15204 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15204 times.
✗ Branch 5 not taken.
|
15204 | if (m_pru1.pru && m_pru1.ring.attached()) { |
| 1595 |
1/2✓ Branch 0 taken 15204 times.
✗ Branch 1 not taken.
|
30408 | taken = taken && (m_pru1.pendingSeq.load(std::memory_order_acquire) == |
| 1596 |
2/2✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 9524 times.
|
30408 | m_pru1.pumpedSeq.load(std::memory_order_acquire)); |
| 1597 | } | ||
| 1598 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 15204 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15204 times.
|
15204 | if (m_pru0.pru && m_pru0.ring.attached()) { |
| 1599 | ✗ | taken = taken && (m_pru0.pendingSeq.load(std::memory_order_acquire) == | |
| 1600 | ✗ | m_pru0.pumpedSeq.load(std::memory_order_acquire)); | |
| 1601 | } | ||
| 1602 | 15204 | ++m_bpOffered; | |
| 1603 |
2/2✓ Branch 0 taken 9524 times.
✓ Branch 1 taken 5680 times.
|
15204 | if (!taken) { |
| 1604 | 9524 | ++m_bpDeclined; | |
| 1605 | } | ||
| 1606 | // report on a wall-clock window rather than a frame count so the | ||
| 1607 | // hysteresis reacts at the same speed whatever the sequence rate | ||
| 1608 | 15204 | auto now = std::chrono::steady_clock::now(); | |
| 1609 |
2/2✓ Branch 0 taken 41 times.
✓ Branch 1 taken 15163 times.
|
15204 | if (m_bpWindowStart.time_since_epoch().count() == 0) { |
| 1610 | 41 | m_bpWindowStart = now; | |
| 1611 |
4/6✓ Branch 0 taken 15163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15163 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 15161 times.
|
15163 | } else if ((now - m_bpWindowStart) >= std::chrono::seconds(60)) { |
| 1612 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (m_bpDeclined) { |
| 1613 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | LogWarn(VB_CHANNELOUT, |
| 1614 | "BBShiftString: back-pressure gate declined %u of %u frames (%.1f%%)\n", | ||
| 1615 | m_bpDeclined, m_bpOffered, 100.0 * m_bpDeclined / m_bpOffered); | ||
| 1616 | ✗ | } else if (m_bpLastDeclined) { | |
| 1617 | // A clean window is the normal state, so only the transition | ||
| 1618 | // back to it is worth a line; one per window at the default | ||
| 1619 | // level filled the log on every healthy output. | ||
| 1620 | ✗ | LogInfo(VB_CHANNELOUT, "BBShiftString: back-pressure gate declined no frames of %u (recovered)\n", | |
| 1621 | m_bpOffered); | ||
| 1622 | } | ||
| 1623 | 2 | m_bpLastDeclined = m_bpDeclined != 0; | |
| 1624 | // Surface a persistent UI warning once the sequence rate is clearly | ||
| 1625 | // beyond what the strings can output; clear it again when the rate | ||
| 1626 | // drops back (e.g. a different sequence starts). The thresholds | ||
| 1627 | // are hysteresis: on at >=10% dropped, off again below 2%. | ||
| 1628 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (m_bpDeclined * 10 >= m_bpOffered) { |
| 1629 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | setFrameRateWarning(true); |
| 1630 | ✗ | } else if (m_bpDeclined * 50 <= m_bpOffered) { | |
| 1631 | ✗ | setFrameRateWarning(false); | |
| 1632 | } | ||
| 1633 | 2 | m_bpOffered = 0; | |
| 1634 | 2 | m_bpDeclined = 0; | |
| 1635 | 2 | m_bpWindowStart = now; | |
| 1636 | } | ||
| 1637 |
2/2✓ Branch 0 taken 9524 times.
✓ Branch 1 taken 5680 times.
|
15204 | if (!taken) { |
| 1638 | 9524 | return m_channelCount; | |
| 1639 | } | ||
| 1640 | } | ||
| 1641 | // -------------------------------------------------------------------------- | ||
| 1642 | #endif | ||
| 1643 | |||
| 1644 | 5692 | sendData(m_pru0); | |
| 1645 | 5692 | sendData(m_pru1); | |
| 1646 | // the frame data must reach DDR before the command reaches the PRU (the | ||
| 1647 | // AM62x pump writes only the PRU shared RAM, but a barrier costs nothing) | ||
| 1648 | 5692 | BBBPru::frameDataBarrier(); | |
| 1649 | |||
| 1650 | // Send the start command. A port set with no data to send must not get a | ||
| 1651 | // command at all: sendData() above leaves pendingFrame empty in that case, | ||
| 1652 | // so the command would name a frame the pump never streams. The length is | ||
| 1653 | // also not enough on its own to make it a no-op - a zero length still ORs | ||
| 1654 | // in the custom-length flag below, and the firmware's render loop reads its | ||
| 1655 | // first block before testing the count, so a "zero byte" frame still eats a | ||
| 1656 | // ring block the ARM never wrote. That block offsets every later frame by | ||
| 1657 | // one byte per string for as long as the output lives, and because both | ||
| 1658 | // sides still move the same number of blocks per frame the ring keeps | ||
| 1659 | // reaching empty and drained() never notices. A freshly Init()ed output | ||
| 1660 | // hits this on a config reload: PrepareChannelData() and SendChannelData() | ||
| 1661 | // are separate walks of the output list, so the replacement can pick up its | ||
| 1662 | // first SendData() before its first PrepData() has set outputStringLen. | ||
| 1663 |
3/4✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5680 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
|
5692 | if (m_pru0.pruData && m_pru0.outputStringLen) { |
| 1664 | 12 | uint32_t c = m_pru0.outputStringLen; | |
| 1665 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if (m_pru0.v5_config_packets[m_pru0.curV5ConfigPacket]) { |
| 1666 | ✗ | c |= m_pru0.v5_config_packets[m_pru0.curV5ConfigPacket]->getCommandFlags(); | |
| 1667 | ✗ | if (m_pru0.v5_config_packets[m_pru0.curV5ConfigPacket] == m_pru0.dynamicPacketInfo) { | |
| 1668 | ✗ | m_pru0.v5_config_packets[m_pru0.curV5ConfigPacket] = nullptr; | |
| 1669 | } | ||
| 1670 | } | ||
| 1671 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if (m_pru0.outputStringLen != m_pru0.maxStringLen) { |
| 1672 | ✗ | c |= 0x10000; // flag that the output len is custom and ignore the off config | |
| 1673 | } | ||
| 1674 | 12 | m_pru0.curV5ConfigPacket++; | |
| 1675 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
|
12 | if (m_pru0.curV5ConfigPacket == NUM_CONFIG_PACKETS) { |
| 1676 | ✗ | m_pru0.curV5ConfigPacket = FIRST_LOOPING_CONFIG_PACKET; | |
| 1677 | } | ||
| 1678 | #ifdef PLATFORM_BBB | ||
| 1679 | 12 | m_pru0.pruData->command = c; | |
| 1680 | #else | ||
| 1681 | // the pump thread writes the command once the PRU has taken the | ||
| 1682 | // previous one; the gate above guarantees the previous one is gone, | ||
| 1683 | // so this can never overwrite a frame the pump has yet to snapshot | ||
| 1684 | ✗ | m_pru0.pendingFrame.command = c; | |
| 1685 | ✗ | m_pru0.pendingSeq.fetch_add(1, std::memory_order_release); | |
| 1686 | #endif | ||
| 1687 | } | ||
| 1688 |
3/4✓ Branch 0 taken 5692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5684 times.
✓ Branch 3 taken 8 times.
|
5692 | if (m_pru1.pruData && m_pru1.outputStringLen) { |
| 1689 | 5684 | uint32_t c = m_pru1.outputStringLen; | |
| 1690 |
2/2✓ Branch 0 taken 1783 times.
✓ Branch 1 taken 3901 times.
|
5684 | if (m_pru1.v5_config_packets[m_pru1.curV5ConfigPacket]) { |
| 1691 | 1783 | c |= m_pru1.v5_config_packets[m_pru1.curV5ConfigPacket]->getCommandFlags(); | |
| 1692 |
2/2✓ Branch 0 taken 1458 times.
✓ Branch 1 taken 325 times.
|
1783 | if (m_pru1.v5_config_packets[m_pru1.curV5ConfigPacket] == m_pru1.dynamicPacketInfo) { |
| 1693 | 1458 | m_pru1.v5_config_packets[m_pru1.curV5ConfigPacket] = nullptr; | |
| 1694 | } | ||
| 1695 | } | ||
| 1696 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5684 times.
|
5684 | if (m_pru1.outputStringLen != m_pru1.maxStringLen) { |
| 1697 | ✗ | c |= 0x10000; // flag that the output len is custom and ignore the off config | |
| 1698 | } | ||
| 1699 | 5684 | m_pru1.curV5ConfigPacket++; | |
| 1700 | 5684 | m_v5RestPending = false; | |
| 1701 |
2/2✓ Branch 0 taken 51 times.
✓ Branch 1 taken 5633 times.
|
5684 | if (m_pru1.curV5ConfigPacket == NUM_CONFIG_PACKETS) { |
| 1702 | 51 | m_pru1.curV5ConfigPacket = FIRST_LOOPING_CONFIG_PACKET; | |
| 1703 | } | ||
| 1704 | #ifdef PLATFORM_BBB | ||
| 1705 | 12 | m_pru1.pruData->command = c; | |
| 1706 | #else | ||
| 1707 | 5672 | m_pru1.pendingFrame.command = c; | |
| 1708 | 5672 | m_pru1.pendingSeq.fetch_add(1, std::memory_order_release); | |
| 1709 | #endif | ||
| 1710 | } | ||
| 1711 | 5692 | __asm__ __volatile__("" :: | |
| 1712 | : "memory"); | ||
| 1713 | |||
| 1714 | 5692 | return m_channelCount; | |
| 1715 | } | ||
| 1716 | |||
| 1717 | #ifndef PLATFORM_BBB | ||
| 1718 | // Stream the pending frame into the shared memory ring; returns true if any | ||
| 1719 | // progress was made. The full frame does not fit in the ring, so the PRU is | ||
| 1720 | // started as soon as a frame is taken and the data streams ~2.5ms ahead of | ||
| 1721 | // the output. | ||
| 1722 | 690603 | bool BBShiftStringOutput::pumpFrameData(FrameData& d) { | |
| 1723 |
2/2✓ Branch 0 taken 621429 times.
✓ Branch 1 taken 69174 times.
|
690603 | if (!d.pumpActive) { |
| 1724 | 621429 | uint32_t seq = d.pendingSeq.load(std::memory_order_acquire); | |
| 1725 | // The command word says how many blocks to render but not WHERE the | ||
| 1726 | // frame starts - the firmware just reads on from wherever it stopped. | ||
| 1727 | // So a command may only be issued when the ring is empty, which is the | ||
| 1728 | // only moment the read pointer provably sits on this frame's first | ||
| 1729 | // byte. Without this the two channels drift apart by whatever was | ||
| 1730 | // still buffered when the first command went out, and every frame | ||
| 1731 | // after that renders that many bytes into the previous one. Streaming | ||
| 1732 | // ahead within a frame is unaffected (that is the loop below). | ||
| 1733 |
2/2✓ Branch 0 taken 354394 times.
✓ Branch 1 taken 267035 times.
|
1242858 | if (seq == d.pumpedSeq.load(std::memory_order_relaxed)) { |
| 1734 | 354394 | return false; | |
| 1735 | } | ||
| 1736 |
6/6✓ Branch 0 taken 17204 times.
✓ Branch 1 taken 249831 times.
✓ Branch 2 taken 11556 times.
✓ Branch 3 taken 5648 times.
✓ Branch 4 taken 261387 times.
✓ Branch 5 taken 5648 times.
|
267035 | if (d.pruData->command != 0 || !d.ring.drained()) { |
| 1737 | // The firmware has not finished with what it was already given. | ||
| 1738 | // That clears inside a frame time in normal operation; if it does | ||
| 1739 | // not, it is starved on a frame whose data never arrived (or on a | ||
| 1740 | // command that went missing), and waiting on the ring alone would | ||
| 1741 | // leave the output dead for good. Re-seat on its read pointer and | ||
| 1742 | // carry on rather than wedge. | ||
| 1743 | 261387 | uint32_t rendered = *(volatile uint32_t*)((uint8_t*)d.pruData + SMEM_RING_FRAMES_OFFSET); | |
| 1744 | 261387 | auto now = std::chrono::steady_clock::now(); | |
| 1745 |
6/6✓ Branch 0 taken 259080 times.
✓ Branch 1 taken 2307 times.
✓ Branch 2 taken 520 times.
✓ Branch 3 taken 258560 times.
✓ Branch 4 taken 2827 times.
✓ Branch 5 taken 258560 times.
|
261387 | if (rendered != d.renderedFrames || d.stalledSince.time_since_epoch().count() == 0) { |
| 1746 | 2827 | d.renderedFrames = rendered; | |
| 1747 | 2827 | d.stalledSince = now; | |
| 1748 |
4/6✓ Branch 0 taken 258560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 258560 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 495 times.
✓ Branch 5 taken 258065 times.
|
258560 | } else if ((now - d.stalledSince) > std::chrono::milliseconds(250)) { |
| 1749 |
1/2✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
|
495 | LogWarn(VB_CHANNELOUT, "BBShiftString: firmware rendered no frame for 250ms (command 0x%X, %u bytes unread); resynchronizing the ring\n", |
| 1750 | (unsigned)d.pruData->command, d.ring.usedBytes()); | ||
| 1751 | 495 | d.pruData->command = 0; | |
| 1752 | 495 | d.ring.seekToConsumer(); | |
| 1753 | 495 | d.stalledSince = now; | |
| 1754 | } | ||
| 1755 | 261387 | return false; | |
| 1756 | } | ||
| 1757 | 5648 | d.stalledSince = {}; | |
| 1758 | // Snapshot the newest pending frame; retry if SendData raced us. | ||
| 1759 | // pumpedSeq is published only once the copy is known good, never | ||
| 1760 | // before it: the back-pressure gate in SendData() treats | ||
| 1761 | // pumpedSeq == pendingSeq as its licence to restage, so publishing | ||
| 1762 | // first would invite the output thread to rewrite pendingFrame while | ||
| 1763 | // this copy is still reading it. | ||
| 1764 | while (true) { | ||
| 1765 | 5648 | uint32_t snapped = seq; | |
| 1766 | 5648 | d.activeFrame = d.pendingFrame; | |
| 1767 | 5648 | seq = d.pendingSeq.load(std::memory_order_acquire); | |
| 1768 |
1/2✓ Branch 0 taken 5648 times.
✗ Branch 1 not taken.
|
5648 | if (seq == snapped) { |
| 1769 | 5648 | d.pumpedSeq.store(snapped, std::memory_order_release); | |
| 1770 | 5648 | break; | |
| 1771 | } | ||
| 1772 | ✗ | } | |
| 1773 | 5648 | d.activeOff = 0; | |
| 1774 | 5648 | d.pumpActive = true; | |
| 1775 | // Publish where in the ring this frame starts before the command that | ||
| 1776 | // makes the firmware act on it - nothing has been written for this | ||
| 1777 | // frame yet, so the write position is its first byte. The firmware | ||
| 1778 | // takes its read position from this and zeroes it, so the two only | ||
| 1779 | // ever move together. This is what keeps a one-off disagreement about | ||
| 1780 | // a frame's length from becoming permanent: the drain gate above | ||
| 1781 | // cannot catch that on its own, because a frame offset by a whole | ||
| 1782 | // number of blocks empties the ring exactly like one offset by none. | ||
| 1783 | 5648 | d.pruData->address_dma = d.ring.writePos(); | |
| 1784 | 5648 | __sync_synchronize(); | |
| 1785 | 5648 | d.pruData->command = d.activeFrame.command; | |
| 1786 | } | ||
| 1787 | 74822 | uint32_t total = d.activeFrame.frameBytes + d.activeFrame.packetBytes; | |
| 1788 | 74822 | bool progress = false; | |
| 1789 |
2/2✓ Branch 0 taken 142049 times.
✓ Branch 1 taken 5648 times.
|
147697 | while (d.activeOff < total) { |
| 1790 | const uint8_t* src; | ||
| 1791 | uint32_t remaining; | ||
| 1792 |
2/2✓ Branch 0 taken 134877 times.
✓ Branch 1 taken 7172 times.
|
142049 | if (d.activeOff < d.activeFrame.frameBytes) { |
| 1793 | 134877 | src = d.activeFrame.frameData + d.activeOff; | |
| 1794 | 134877 | remaining = d.activeFrame.frameBytes - d.activeOff; | |
| 1795 | } else { | ||
| 1796 | 7172 | src = d.activeFrame.packetData + (d.activeOff - d.activeFrame.frameBytes); | |
| 1797 | 7172 | remaining = total - d.activeOff; | |
| 1798 | } | ||
| 1799 | 142049 | uint32_t n = d.ring.write(src, remaining); | |
| 1800 |
2/2✓ Branch 0 taken 69174 times.
✓ Branch 1 taken 72875 times.
|
142049 | if (n == 0) { |
| 1801 | 69174 | break; | |
| 1802 | } | ||
| 1803 | 72875 | d.activeOff += n; | |
| 1804 | 72875 | progress = true; | |
| 1805 | } | ||
| 1806 |
2/2✓ Branch 0 taken 5648 times.
✓ Branch 1 taken 69174 times.
|
74822 | if (d.activeOff == total) { |
| 1807 | 5648 | d.pumpActive = false; | |
| 1808 | } | ||
| 1809 | 74822 | return progress; | |
| 1810 | } | ||
| 1811 | |||
| 1812 | 56 | void BBShiftStringOutput::runPumpThread() { | |
| 1813 | struct sched_param sp; | ||
| 1814 | 56 | sp.sched_priority = 50; | |
| 1815 | 56 | int err = pthread_setschedparam(pthread_self(), SCHED_FIFO, &sp); | |
| 1816 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
|
56 | if (err) { |
| 1817 | ✗ | LogWarn(VB_CHANNELOUT, "BBShiftString: could not set pump thread to SCHED_FIFO: %s\n", strerror(err)); | |
| 1818 | } | ||
| 1819 |
2/2✓ Branch 0 taken 690603 times.
✓ Branch 1 taken 56 times.
|
690659 | while (m_pumpRunning) { |
| 1820 | 690603 | bool p = false; | |
| 1821 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 690603 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 690603 times.
|
690603 | if (m_pru0.pru && m_pru0.ring.attached()) { |
| 1822 | ✗ | p |= pumpFrameData(m_pru0); | |
| 1823 | } | ||
| 1824 |
3/6✓ Branch 0 taken 690603 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 690603 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 690603 times.
✗ Branch 5 not taken.
|
690603 | if (m_pru1.pru && m_pru1.ring.attached()) { |
| 1825 |
1/2✓ Branch 0 taken 690603 times.
✗ Branch 1 not taken.
|
690603 | p |= pumpFrameData(m_pru1); |
| 1826 | } | ||
| 1827 |
2/2✓ Branch 0 taken 214359 times.
✓ Branch 1 taken 476244 times.
|
690603 | if (falconV5Support) { |
| 1828 | // take a finished receiver reply out of the listener's shared RAM | ||
| 1829 | // as soon as it is published, before the next listen window can | ||
| 1830 | // overwrite it; the output thread decodes it on its next frame | ||
| 1831 |
1/2✓ Branch 0 taken 214359 times.
✗ Branch 1 not taken.
|
214359 | falconV5Support->stageListenerData(); |
| 1832 | } | ||
| 1833 |
2/2✓ Branch 0 taken 648162 times.
✓ Branch 1 taken 42441 times.
|
690603 | if (!p) { |
| 1834 | 648162 | struct timespec ts = { 0, 500000 }; | |
| 1835 |
1/2✓ Branch 0 taken 648162 times.
✗ Branch 1 not taken.
|
648162 | nanosleep(&ts, nullptr); |
| 1836 | } | ||
| 1837 | } | ||
| 1838 | 56 | } | |
| 1839 | #endif | ||
| 1840 | |||
| 1841 | /* | ||
| 1842 | * | ||
| 1843 | */ | ||
| 1844 | 61 | void BBShiftStringOutput::DumpConfig(void) { | |
| 1845 | 61 | LogDebug(VB_CHANNELOUT, "BBShiftStringOutput::DumpConfig()\n"); | |
| 1846 | 61 | LogDebug(VB_CHANNELOUT, " type : %s\n", m_subType.c_str()); | |
| 1847 | 61 | LogDebug(VB_CHANNELOUT, " strings : %d\n", m_strings.size()); | |
| 1848 | 61 | LogDebug(VB_CHANNELOUT, " longest string: %d channels\n", | |
| 1849 | std::max(m_pru0.maxStringLen, m_pru1.maxStringLen)); | ||
| 1850 | |||
| 1851 |
2/2✓ Branch 0 taken 425 times.
✓ Branch 1 taken 61 times.
|
486 | for (int i = 0; i < m_strings.size(); i++) { |
| 1852 | 425 | LogDebug(VB_CHANNELOUT, " string #%02d\n", i); | |
| 1853 | 425 | m_strings[i]->DumpConfig(); | |
| 1854 | } | ||
| 1855 | |||
| 1856 | 61 | ChannelOutput::DumpConfig(); | |
| 1857 | 61 | } | |
| 1858 | 49 | void BBShiftStringOutput::StartingOutput() { | |
| 1859 | 49 | m_pru1.curV5ConfigPacket = 0; | |
| 1860 | 49 | m_pru0.curV5ConfigPacket = 0; | |
| 1861 | 49 | m_v5RestPending = false; | |
| 1862 | 49 | } | |
| 1863 | 49 | void BBShiftStringOutput::StoppingOutput() { | |
| 1864 |
2/2✓ Branch 0 taken 4998 times.
✓ Branch 1 taken 49 times.
|
5047 | for (int y = 0; y < NUM_CONFIG_PACKETS; ++y) { |
| 1865 |
3/4✓ Branch 0 taken 4998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4996 times.
|
4998 | if (m_pru1.v5_config_packets[y] == &m_pru1.dynamicPacketInfo2 || m_pru1.v5_config_packets[y] == &m_pru1.dynamicPacketInfo1) { |
| 1866 | 2 | m_pru1.v5_config_packets[y] = nullptr; | |
| 1867 | } | ||
| 1868 |
3/4✓ Branch 0 taken 4998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 4995 times.
|
4998 | if (m_pru0.v5_config_packets[y] == &m_pru0.dynamicPacketInfo2 || m_pru0.v5_config_packets[y] == &m_pru0.dynamicPacketInfo1) { |
| 1869 | 3 | m_pru0.v5_config_packets[y] = nullptr; | |
| 1870 | } | ||
| 1871 | } | ||
| 1872 | 49 | m_pru1.curV5ConfigPacket = 0; | |
| 1873 | 49 | m_pru0.curV5ConfigPacket = 0; | |
| 1874 | 49 | m_v5RestPending = false; | |
| 1875 | 49 | } | |
| 1876 | constexpr int numPacketTypes = 12; | ||
| 1877 | // No inversion pass here: config packets only exist for a chain's first port, | ||
| 1878 | // and demoteInvertedReceiverChains() has already dropped any chain whose head | ||
| 1879 | // is inverted, so a packet never needs flipping. | ||
| 1880 | 1542 | void BBShiftStringOutput::encodeFalconV5Packet(std::vector<std::array<uint8_t, 64>>& packets, uint8_t* memLocPru0, uint8_t* memLocPru1) { | |
| 1881 | // zeroed: slots with no string mapped to them are still clocked out on | ||
| 1882 | // their shift stage, and must send zeros rather than old stack contents | ||
| 1883 | 1542 | std::array<uint8_t, 57 * MAX_PINS_PER_PRU * MAX_STRINGS_PER_PIN> pru0Data = {}; | |
| 1884 | 1542 | std::array<uint8_t, 57 * MAX_PINS_PER_PRU * MAX_STRINGS_PER_PIN> pru1Data = {}; | |
| 1885 |
2/2✓ Branch 0 taken 12336 times.
✓ Branch 1 taken 1542 times.
|
13878 | for (int y = 0; y < MAX_PINS_PER_PRU; ++y) { |
| 1886 | 12336 | uint8_t pinMask = 1 << y; | |
| 1887 |
2/2✓ Branch 0 taken 98688 times.
✓ Branch 1 taken 12336 times.
|
111024 | for (int x = 0; x < m_stringsPerPin; ++x) { |
| 1888 | 98688 | int idx = m_pru0.stringMap[y][x]; | |
| 1889 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 98688 times.
|
98688 | if (idx != -1) { |
| 1890 | ✗ | uint8_t* frame = &pru0Data[x + (y * m_stringsPerPin)]; | |
| 1891 | ✗ | for (int p = 0; p < 57; p++) { | |
| 1892 | ✗ | uint8_t b = packets[idx][p]; | |
| 1893 | ✗ | b = ((b * 0x0802LU & 0x22110LU) | (b * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16; | |
| 1894 | ✗ | *frame = b; | |
| 1895 | ✗ | frame += stringsPerPru(); | |
| 1896 | } | ||
| 1897 | } | ||
| 1898 | 98688 | idx = m_pru1.stringMap[y][x]; | |
| 1899 |
2/2✓ Branch 0 taken 33752 times.
✓ Branch 1 taken 64936 times.
|
98688 | if (idx != -1) { |
| 1900 | 33752 | uint8_t* frame = &pru1Data[x + (y * m_stringsPerPin)]; | |
| 1901 |
2/2✓ Branch 0 taken 1923864 times.
✓ Branch 1 taken 33752 times.
|
1957616 | for (int p = 0; p < 57; p++) { |
| 1902 | 1923864 | uint8_t b = packets[idx][p]; | |
| 1903 | 1923864 | b = ((b * 0x0802LU & 0x22110LU) | (b * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16; | |
| 1904 | 1923864 | *frame = b; | |
| 1905 | 1923864 | frame += stringsPerPru(); | |
| 1906 | } | ||
| 1907 | } | ||
| 1908 | } | ||
| 1909 | } | ||
| 1910 | 1542 | size_t pLen = 57 * stringsPerPru(); | |
| 1911 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1542 times.
|
1542 | if (m_pru0.maxStringLen) { |
| 1912 | ✗ | bitFlipData(&pru0Data[0], memLocPru0, 57); | |
| 1913 | } | ||
| 1914 |
1/2✓ Branch 0 taken 1542 times.
✗ Branch 1 not taken.
|
1542 | if (m_pru1.maxStringLen) { |
| 1915 |
1/2✓ Branch 0 taken 1542 times.
✗ Branch 1 not taken.
|
1542 | bitFlipData(&pru1Data[0], memLocPru1, 57); |
| 1916 | } | ||
| 1917 | 1542 | } | |
| 1918 | |||
| 1919 | 1540 | void BBShiftStringOutput::applySendOnlyConfigPackets(std::vector<std::array<uint8_t, 64>>& packets) { | |
| 1920 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1540 times.
|
1540 | for (auto& [port, packet] : m_sendOnlyConfigPackets) { |
| 1921 | ✗ | if (port >= 0 && port < (int)packets.size()) { | |
| 1922 | ✗ | packets[port] = packet; | |
| 1923 | } | ||
| 1924 | } | ||
| 1925 | 1540 | } | |
| 1926 | |||
| 1927 | 23 | void BBShiftStringOutput::setupFalconV5Support(const Json::Value& root, uint8_t* memLoc) { | |
| 1928 |
3/8✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
23 | falconV5Support = new FalconV5Support(); |
| 1929 | 23 | m_sendOnlyConfigPackets.clear(); | |
| 1930 |
3/4✓ Branch 0 taken 21 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
|
23 | if (supportsV5Listeners && m_hasBidirSR) { |
| 1931 |
3/4✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 1 times.
|
21 | falconV5Support->addListeners(root["falconV5ListenerConfig"]); |
| 1932 | } | ||
| 1933 | |||
| 1934 | 22 | int max = std::max(m_pru0.maxStringLen, m_pru1.maxStringLen); | |
| 1935 | 22 | int x = 0; | |
| 1936 |
2/2✓ Branch 0 taken 86 times.
✓ Branch 1 taken 22 times.
|
108 | while (x < m_strings.size()) { |
| 1937 | 86 | int p = x; | |
| 1938 | 86 | PixelString* p1 = m_strings[x++]; | |
| 1939 |
5/6✓ Branch 0 taken 26 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
|
86 | if (p1->m_isSmartReceiver && (p1->smartReceiverType == PixelString::ReceiverType::FalconV5 || p1->smartReceiverType == PixelString::ReceiverType::FalconV4)) { |
| 1940 | // V4 chains are send-only: the config packet goes out, but no | ||
| 1941 | // queries are scheduled and no responses are listened for | ||
| 1942 | 26 | bool sendOnly = p1->smartReceiverType == PixelString::ReceiverType::FalconV4; | |
| 1943 | 26 | int grp = 0; | |
| 1944 | 26 | int mux = 0; | |
| 1945 |
5/8✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 2 times.
|
26 | if (root["outputs"][p].isMember("falconV5Listener")) { |
| 1946 |
4/8✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✗ Branch 7 not taken.
|
24 | grp = root["outputs"][p]["falconV5Listener"].asInt(); |
| 1947 | } | ||
| 1948 |
5/8✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 25 times.
|
26 | if (root["outputs"][p].isMember("falconV5ListenerMux")) { |
| 1949 |
4/8✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
1 | mux = root["outputs"][p]["falconV5ListenerMux"].asInt(); |
| 1950 | } | ||
| 1951 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | PixelString* p2 = x < m_strings.size() ? m_strings[x++] : nullptr; |
| 1952 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | PixelString* p3 = x < m_strings.size() ? m_strings[x++] : nullptr; |
| 1953 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | PixelString* p4 = x < m_strings.size() ? m_strings[x++] : nullptr; |
| 1954 | |||
| 1955 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | falconV5Support->addReceiverChain(p1, p2, p3, p4, grp, mux, sendOnly); |
| 1956 | // need to keep the ports on. With v5, all ports need to be kept on | ||
| 1957 | // and must have edges that are aligned. Need to turn OFF the 2-4 ports during | ||
| 1958 | // the config packet | ||
| 1959 | 26 | p1->m_gpioCommands.clear(); | |
| 1960 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 24 times.
|
26 | if (sendOnly) { |
| 1961 | // a V4 chain gets its config packet in the packet frames that | ||
| 1962 | // end in the frame's low reset, and its line goes low right | ||
| 1963 | // after it; in a frame that opens a listen window the line | ||
| 1964 | // stays low for the whole packet phase | ||
| 1965 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | p1->m_gpioCommands.emplace_back(1, GPIO_CMD_AFTER_FIRST_PACKET, 0, 0); |
| 1966 | } | ||
| 1967 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | if (p2) { |
| 1968 | 26 | p2->m_gpioCommands.clear(); | |
| 1969 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | p2->m_gpioCommands.emplace_back(2, max, 0, 0); |
| 1970 | } | ||
| 1971 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | if (p3) { |
| 1972 | 26 | p3->m_gpioCommands.clear(); | |
| 1973 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | p3->m_gpioCommands.emplace_back(3, max, 0, 0); |
| 1974 | } | ||
| 1975 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | if (p4) { |
| 1976 | 26 | p4->m_gpioCommands.clear(); | |
| 1977 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | p4->m_gpioCommands.emplace_back(4, max, 0, 0); |
| 1978 | } | ||
| 1979 | } | ||
| 1980 | } | ||
| 1981 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 | if (!falconV5Support->getReceiverChains().empty()) { |
| 1982 | // we have receiver chains, generate standard packets | ||
| 1983 |
2/2✓ Branch 0 taken 66 times.
✓ Branch 1 taken 22 times.
|
88 | for (int x = 0; x < 3; x++) { |
| 1984 | 66 | std::vector<std::array<uint8_t, 64>> packets; | |
| 1985 | 66 | std::vector<std::array<uint8_t, 64>> packets2; | |
| 1986 |
1/2✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
|
66 | packets.resize(m_strings.size()); |
| 1987 |
1/2✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
|
66 | packets2.resize(m_strings.size()); |
| 1988 |
2/2✓ Branch 0 taken 492 times.
✓ Branch 1 taken 66 times.
|
558 | for (auto& p : packets) { |
| 1989 | 492 | memset(&p[0], 0, 64); | |
| 1990 | } | ||
| 1991 |
2/2✓ Branch 0 taken 492 times.
✓ Branch 1 taken 66 times.
|
558 | for (auto& p : packets2) { |
| 1992 | 492 | memset(&p[0], 0, 64); | |
| 1993 | } | ||
| 1994 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 44 times.
|
66 | int len = (x == 1) ? 2 : 1; |
| 1995 | 66 | int idx = x; | |
| 1996 | 66 | bool listen = false; | |
| 1997 | 66 | bool any = false; | |
| 1998 |
2/2✓ Branch 0 taken 78 times.
✓ Branch 1 taken 66 times.
|
144 | for (auto& rc : falconV5Support->getReceiverChains()) { |
| 1999 | 78 | int port = rc->getPixelStrings()[0]->m_portNumber; | |
| 2000 |
4/8✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 78 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 78 times.
|
78 | if (port < 0 || port >= (int)packets.size() || port >= (int)packets2.size()) { |
| 2001 | 4 | continue; // a port past the strings would write past the packets | |
| 2002 | } | ||
| 2003 |
6/6✓ Branch 0 taken 52 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 74 times.
|
78 | if (x > 0 && rc->isSendOnly()) { |
| 2004 | // V4 receivers never get number/fuse/query packets; their | ||
| 2005 | // slot in those frames is filled by applySendOnlyConfigPackets | ||
| 2006 | 4 | continue; | |
| 2007 | } | ||
| 2008 | 74 | any = true; | |
| 2009 |
2/2✓ Branch 0 taken 26 times.
✓ Branch 1 taken 48 times.
|
74 | if (x == 0) { |
| 2010 |
1/2✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
|
26 | rc->generateConfigPacket(&packets[port][0]); |
| 2011 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 24 times.
|
26 | if (rc->isSendOnly()) { |
| 2012 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | m_sendOnlyConfigPackets.emplace_back(port, packets[port]); |
| 2013 | } | ||
| 2014 |
2/2✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
|
48 | } else if (x == 1) { |
| 2015 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | rc->generateNumberPackets(&packets[port][0], &packets2[port][0]); |
| 2016 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | } else if (x == 2) { |
| 2017 |
1/2✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
|
24 | rc->generateSetFusesPacket(&packets[port][0], 1); |
| 2018 | } | ||
| 2019 | } | ||
| 2020 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 62 times.
|
66 | if (!any) { |
| 2021 | 4 | continue; | |
| 2022 | } | ||
| 2023 |
2/2✓ Branch 0 taken 40 times.
✓ Branch 1 taken 22 times.
|
62 | if (x > 0) { |
| 2024 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | applySendOnlyConfigPackets(packets); |
| 2025 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | applySendOnlyConfigPackets(packets2); |
| 2026 | } | ||
| 2027 |
1/2✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
|
62 | if (m_pru0.v5_config_packets[idx] == nullptr) { |
| 2028 |
2/4✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
|
62 | m_pru0.v5_config_packets[idx] = new FalconV5PacketInfo(len, memLoc, listen); |
| 2029 | // 64 to keep on 4K memory alignment | ||
| 2030 | 62 | memLoc += 64 * stringsPerPru() * len; | |
| 2031 |
2/4✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
|
62 | m_pru1.v5_config_packets[idx] = new FalconV5PacketInfo(len, memLoc, listen); |
| 2032 | 62 | memLoc += 64 * stringsPerPru() * len; | |
| 2033 | |||
| 2034 |
1/2✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
|
62 | encodeFalconV5Packet(packets, m_pru0.v5_config_packets[idx]->data, m_pru1.v5_config_packets[idx]->data); |
| 2035 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 42 times.
|
62 | if (len == 2) { |
| 2036 | 20 | size_t pLen = 57 * stringsPerPru(); | |
| 2037 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | encodeFalconV5Packet(packets2, m_pru0.v5_config_packets[idx]->data + pLen, m_pru1.v5_config_packets[idx]->data + pLen); |
| 2038 | } | ||
| 2039 | |||
| 2040 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 40 times.
|
62 | if (idx == 0) { |
| 2041 | // config packet, output in other spots | ||
| 2042 | 22 | idx += 12; | |
| 2043 |
2/2✓ Branch 0 taken 176 times.
✓ Branch 1 taken 22 times.
|
198 | while (idx < NUM_CONFIG_PACKETS) { |
| 2044 |
2/4✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
|
176 | m_pru0.v5_config_packets[idx] = new FalconV5PacketInfo(len, m_pru0.v5_config_packets[0]->data, listen); |
| 2045 |
2/4✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
|
176 | m_pru1.v5_config_packets[idx] = new FalconV5PacketInfo(len, m_pru1.v5_config_packets[0]->data, listen); |
| 2046 | 176 | idx += 12; | |
| 2047 | } | ||
| 2048 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 20 times.
|
40 | } else if (idx == 1) { |
| 2049 | // number packet, resend once every loop | ||
| 2050 | 20 | int nidx = NUM_CONFIG_PACKETS - 1; | |
| 2051 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
|
20 | while (m_pru0.v5_config_packets[nidx] != nullptr) { |
| 2052 | ✗ | --nidx; | |
| 2053 | } | ||
| 2054 |
2/4✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
|
20 | m_pru0.v5_config_packets[nidx] = new FalconV5PacketInfo(len, m_pru0.v5_config_packets[idx]->data, listen); |
| 2055 |
2/4✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
|
20 | m_pru1.v5_config_packets[nidx] = new FalconV5PacketInfo(len, m_pru1.v5_config_packets[idx]->data, listen); |
| 2056 | } | ||
| 2057 | } | ||
| 2058 |
4/4✓ Branch 0 taken 62 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 4 times.
|
70 | } |
| 2059 | } | ||
| 2060 | // Reserve space for the dynamic packets. The len must be set as well: | ||
| 2061 | // the AM62x pump streams 57*64*len packet bytes into the ring, and a | ||
| 2062 | // dynamic packet whose command flags said "packet present" but whose | ||
| 2063 | // len was 0 starves the PRU in its ring wait (the AM335x path reads by | ||
| 2064 | // DDR address and never noticed). | ||
| 2065 | 22 | m_pru0.dynamicPacketInfo1.data = memLoc; | |
| 2066 | 22 | m_pru0.dynamicPacketInfo1.len = 1; | |
| 2067 | 22 | memLoc += 64 * stringsPerPru(); | |
| 2068 | 22 | m_pru0.dynamicPacketInfo2.data = memLoc; | |
| 2069 | 22 | m_pru0.dynamicPacketInfo2.len = 1; | |
| 2070 | 22 | memLoc += 64 * stringsPerPru(); | |
| 2071 | 22 | m_pru1.dynamicPacketInfo1.data = memLoc; | |
| 2072 | 22 | m_pru1.dynamicPacketInfo1.len = 1; | |
| 2073 | 22 | memLoc += 64 * stringsPerPru(); | |
| 2074 | 22 | m_pru1.dynamicPacketInfo2.data = memLoc; | |
| 2075 | 22 | m_pru1.dynamicPacketInfo2.len = 1; | |
| 2076 | 22 | memLoc += 64 * stringsPerPru(); | |
| 2077 | |||
| 2078 | 22 | m_pru0.dynamicPacketInfo = &m_pru0.dynamicPacketInfo1; | |
| 2079 | 22 | m_pru1.dynamicPacketInfo = &m_pru1.dynamicPacketInfo1; | |
| 2080 | |||
| 2081 |
2/4✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
|
44 | createOutputLengths(m_pru0, "pru0"); |
| 2082 |
2/4✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
|
44 | createOutputLengths(m_pru1, "pru1"); |
| 2083 | 22 | } | |
| 2084 |