| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * This file is part of the Falcon Player (FPP) and is Copyright (C) | ||
| 4 | * 2013-2022 by the Falcon Player Developers. | ||
| 5 | * | ||
| 6 | * The Falcon Player (FPP) is free software, and is covered under | ||
| 7 | * multiple Open Source licenses. Please see the included 'LICENSES' | ||
| 8 | * file for descriptions of what files are covered by each license. | ||
| 9 | * | ||
| 10 | * This source file is covered under the CC-BY-ND as described in the | ||
| 11 | * included LICENSE.CC-BY-ND file. This file may be modified for | ||
| 12 | * personal use, but modified copies MAY NOT be redistributed in any form. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <array> | ||
| 16 | #include <string> | ||
| 17 | #include "fpp-json-fwd.h" | ||
| 18 | #include <vector> | ||
| 19 | |||
| 20 | #include "channeloutput/ChannelOutput.h" | ||
| 21 | #include "channeloutput/PixelString.h" | ||
| 22 | #include "util/BBBPruUtils.h" | ||
| 23 | |||
| 24 | #define MAX_WS2811_TIMINGS 128 | ||
| 25 | |||
| 26 | // structure of the data at the start of the PRU ram | ||
| 27 | // that the pru program expects to see | ||
| 28 | typedef struct { | ||
| 29 | // in the DDR shared with the PRU | ||
| 30 | uint32_t address_dma; | ||
| 31 | |||
| 32 | // write data length to start, 0xFFFF to abort | ||
| 33 | volatile uint32_t command; | ||
| 34 | volatile uint32_t response; | ||
| 35 | |||
| 36 | uint16_t timings[MAX_WS2811_TIMINGS]; | ||
| 37 | } __attribute__((__packed__)) BBB48StringData; | ||
| 38 | |||
| 39 | class BBB48StringOutput : public ChannelOutput { | ||
| 40 | public: | ||
| 41 | BBB48StringOutput(unsigned int startChannel, unsigned int channelCount); | ||
| 42 | virtual ~BBB48StringOutput(); | ||
| 43 | |||
| 44 | 61 | virtual std::string GetOutputType() const { | |
| 45 |
1/2✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
|
122 | return "BBB Pixel Strings"; |
| 46 | } | ||
| 47 | |||
| 48 | virtual int Init(Json::Value config) override; | ||
| 49 | virtual int Close(void) override; | ||
| 50 | |||
| 51 | virtual int SendData(unsigned char* channelData) override; | ||
| 52 | virtual void PrepData(unsigned char* channelData) override; | ||
| 53 | virtual void DumpConfig(void) override; | ||
| 54 | |||
| 55 | virtual void GetRequiredChannelRanges(const std::function<void(int, int)>& addRange) override; | ||
| 56 | |||
| 57 | virtual void OverlayTestData(unsigned char* channelData, int cycleNum, float percentOfCycle, int testType, const Json::Value& config) override; | ||
| 58 | ✗ | virtual bool SupportsTesting() const { return true; } | |
| 59 | |||
| 60 | private: | ||
| 61 | void StopPRU(bool wait = true); | ||
| 62 | int StartPRU(bool both); | ||
| 63 | |||
| 64 | std::string m_subType; | ||
| 65 | |||
| 66 | class FrameData { | ||
| 67 | public: | ||
| 68 | std::vector<int> gpioStringMap; | ||
| 69 | uint8_t* lastData = nullptr; | ||
| 70 | uint8_t* curData = nullptr; | ||
| 71 | uint32_t frameSize = 0; | ||
| 72 | int maxStringLen = 0; | ||
| 73 | bool copyToPru = true; | ||
| 74 | uint32_t outputStringLen; | ||
| 75 | // the Falcon V4 config packet for the chain heads this PRU drives, | ||
| 76 | // pre-transposed into the frame's byte-lane format; empty when none | ||
| 77 | std::vector<uint8_t> falconPacketLanes; | ||
| 78 | } m_gpio0Data, m_gpioData; | ||
| 79 | std::vector<PixelString*> m_strings; | ||
| 80 | // per string, per virtual string: nonzero when chMap[i+3] == chMap[i]+3 | ||
| 81 | // for the whole map, letting prepData skip the map indirection | ||
| 82 | std::vector<std::vector<uint8_t>> m_vsAffine; | ||
| 83 | |||
| 84 | uint32_t m_curFrame; | ||
| 85 | int m_stallCount; | ||
| 86 | uint32_t m_licensedOutputs; | ||
| 87 | |||
| 88 | BBBPru* m_pru; | ||
| 89 | BBB48StringData* m_pruData; | ||
| 90 | |||
| 91 | BBBPru* m_pru0; | ||
| 92 | BBB48StringData* m_pru0Data; | ||
| 93 | |||
| 94 | int m_testCycle = -1; | ||
| 95 | int m_testType = 0; | ||
| 96 | float m_testPercent = 0.0f; | ||
| 97 | std::list<std::string> m_autoCreatedModelNames; | ||
| 98 | |||
| 99 | // Falcon V4 (send-only) smart receiver support: the chains, and the | ||
| 100 | // m_strings index of each chain's first port. The config packet rides | ||
| 101 | // in each FrameData's falconPacketLanes, appended to the frame and sent | ||
| 102 | // by the firmware every twelfth frame. | ||
| 103 | class FalconV5Support* falconV5Support = nullptr; | ||
| 104 | std::vector<int> m_falconChainHeads; | ||
| 105 | bool m_sendFalconPacket = false; | ||
| 106 | |||
| 107 | void prepData(FrameData& d, unsigned char* channelData); | ||
| 108 | void sendData(FrameData& d, uint32_t* dptr); | ||
| 109 | void createOutputLengths(FrameData& d, const std::string& pfx, std::vector<std::string>& args); | ||
| 110 | void groupFalconV4Chains(); | ||
| 111 | void setupFalconV4Lanes(FrameData& d, const std::vector<std::array<uint8_t, 64>>& packets, | ||
| 112 | Json::Value& root, std::vector<std::string>& args); | ||
| 113 | void setupFalconV4Support(Json::Value& root, std::vector<std::string>& args1, std::vector<std::string>& args0); | ||
| 114 | }; | ||
| 115 |