16 #define HEX16(__x__) "0x" << hex << setw(16) << setfill('0') << uint64_t(__x__) << dec 17 #define INSTP(_p_) HEX16(uint64_t(_p_)) 18 #define LOGGING_ROUTING_CHANGES (AJADebug::IsActive(AJA_DebugUnit_RoutingGeneric)) 19 #define ROUTEFAIL(__x__) AJA_sERROR (AJA_DebugUnit_RoutingGeneric, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 20 #define ROUTEWARN(__x__) AJA_sWARNING(AJA_DebugUnit_RoutingGeneric, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 21 #define ROUTENOTE(__x__) AJA_sNOTICE (AJA_DebugUnit_RoutingGeneric, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 22 #define ROUTEINFO(__x__) AJA_sINFO (AJA_DebugUnit_RoutingGeneric, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 23 #define ROUTEDBG(__x__) AJA_sDEBUG (AJA_DebugUnit_RoutingGeneric, INSTP(this) << "::" << AJAFUNC << ": " << __x__) 26 static const ULWord sMasks[] = { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 };
43 if (regNum > maxRegNum)
58 if (GetConnectedOutput (outInputXpt, tmpOutputXpt))
59 if (tmpOutputXpt == inOutputXpt)
79 if (GetConnectedOutput (inputXpt, tmpOutputXpt))
80 if (tmpOutputXpt == inOutputXpt)
81 outInputXpts.insert(inputXpt);
83 return !outInputXpts.empty();
106 if (regNum > maxRegNum)
110 bool changed (
false);
112 changed = ReadRegister(regNum, outputXpt,
sMasks[ndx],
sShifts[ndx]) && outputXpt;
116 if (result && changed)
135 bool isConnectedToBlack (
false);
136 if (!IsConnectedTo (inInputXpt,
NTV2_XptBlack, isConnectedToBlack))
139 outIsConnected = !isConnectedToBlack;
146 outIsConnected =
false;
147 if (!GetConnectedOutput (inConnection.first, outputID))
150 outIsConnected = outputID == inConnection.second;
161 outCanConnect =
false;
181 {outCanConnect =
true;
return true;}
194 + 4UL * uint32_t(inConnection.first
196 for (uint32_t ndx(0); ndx < 4; ndx++)
200 ReadRegister(regBase + ndx, regVal);
202 ROUTEWARN(GetDisplayName() <<
": GetRouteROMInfoFromReg failed for register " <<
DEC(regBase+ndx)
208 outCanConnect = legalOutputXpts.find(inConnection.second) != legalOutputXpts.end();
215 return Disconnect (inConnection.first);
218 bool canConnect (
true);
220 {
ROUTEFAIL(GetDisplayName() <<
": GetCrosspointSelectGroupRegisterInfo failed, inputXpt=" <<
DEC(inConnection.first));
return false;}
221 if (!regNum || regNum > maxRegNum)
222 {
ROUTEFAIL(GetDisplayName() <<
": GetCrosspointSelectGroupRegisterInfo returned bad reg num '" <<
DEC(regNum) <<
"' for inputXpt=" <<
DEC(inConnection.first));
return false;}
224 {
ROUTEFAIL(GetDisplayName() <<
": GetCrosspointSelectGroupRegisterInfo returned bad index '" <<
DEC(ndx) <<
"' for inputXpt=" <<
DEC(inConnection.first));
return false;}
227 if (CanConnect(inConnection, canConnect))
230 ROUTEFAIL (GetDisplayName() <<
": Unsupported connection '" << inConnection <<
"': reg=" <<
DEC(regNum)
239 const bool result (WriteRegister(regNum, inConnection.second,
sMasks[ndx],
sShifts[ndx]));
243 ROUTEFAIL(GetDisplayName() <<
": Failed to connect '" << inConnection <<
": reg=" <<
DEC(regNum)
244 <<
" val=" <<
DEC(inConnection.second) <<
" mask=" <<
xHEX0N(
sMasks[ndx],8)
246 else if (outputXpt && inConnection.second != outputXpt)
247 ROUTENOTE(GetDisplayName() <<
": Connected '" << inConnection <<
"' -- was from " 249 else if (!outputXpt && inConnection.second != outputXpt)
250 ROUTENOTE(GetDisplayName() <<
": Connected '" << inConnection <<
"' -- was disconnected");
266 for (uint32_t ndx(0); ndx < 4; ndx++)
270 if (ReadRegister(regBase + ndx, regVal))
273 return !outputXpts.empty();
280 if (!ClearRouting ())
287 return WriteRegisters (registerWrites);
293 if (!ClearRouting ())
296 unsigned failures(0);
300 return failures == 0;
305 unsigned failures(0);
307 if (!Disconnect(iter->first))
309 return failures == 0;
317 unsigned nFailures (0);
321 if (*it <= maxRegisterNumber)
323 if (ReadRegister (*it, num))
325 if (!WriteRegister (*it, 0))
329 if (tally && !nFailures)
330 ROUTEINFO(GetDisplayName() <<
": Routing cleared");
332 ROUTEDBG(GetDisplayName() <<
": Routing already clear, nothing changed");
334 ROUTEFAIL(GetDisplayName() <<
": " <<
DEC(nFailures) <<
" register write(s) failed");
335 return nFailures == 0;
349 ROUTEDBG(GetDisplayName() <<
": '" << ::
NTV2DeviceIDToString(GetDeviceID()) <<
"' has " << validWidgets.size() <<
" widgets: " << validWidgets);
363 if (!GetConnectedOutput (*pInputID, outputID))
375 ROUTEDBG(GetDisplayName() <<
": Returning " << outRouting);
382 outConnections.clear();
387 && ReadRegisters(regInfos)
404 if (IS_CHANNEL_INVALID(inChannel))
408 inputXptQueue.push_back(SDIOutInputs[inChannel]);
412 while (!inputXptQueue.empty())
419 inputXptQueue.pop_front();
425 if (!GetConnectedOutput (inputXpt, outputXpt))
437 if (wgtIDs.find(widgetID) == wgtIDs.end())
443 inputXptQueue.push_back(*it);
447 ROUTEDBG(GetDisplayName() <<
": Channel " <<
DEC(inChannel+1) <<
" routing: " << outRouting);
NTV2XptConnections::const_iterator NTV2XptConnectionsConstIter
std::string NTV2WidgetIDToString(const NTV2WidgetID inValue, const bool inCompactDisplay=false)
virtual void Reset(void)
Resets me, erasing any/all existing connections.
virtual bool GetConnectedOutput(const NTV2InputCrosspointID inInputXpt, NTV2OutputCrosspointID &outOutputXpt)
Answers with the currently connected NTV2OutputCrosspointID for the given NTV2InputCrosspointID.
virtual bool AddConnection(const NTV2InputXptID inSignalInput, const NTV2OutputXptID inSignalOutput=NTV2_XptBlack)
Adds a connection between a widget's signal input (sink) and another widget's signal output (source)...
static bool GetConnectionsFromRegs(const NTV2InputXptIDSet &inInputXptIDs, const NTV2RegisterReads &inRegValues, NTV2XptConnections &outConnections)
Converts a set of crosspoint registers into a set of crosspoint connections.
Declares the AJADebug class.
virtual bool GetRegisterWrites(NTV2RegisterWrites &outRegWrites) const
Returns a sequence of NTV2RegInfo values that can be written to an NTV2 device using its WriteRegiste...
static NTV2RegNumSet GetRegistersForClass(const std::string &inClassName)
virtual bool Disconnect(const NTV2InputCrosspointID inInputXpt)
Disconnects the given widget signal input (sink) from whatever output (source) it may be connected...
ULWordSetConstIter NTV2RegNumSetConstIter
A const iterator that iterates over a set of distinct NTV2RegisterNumbers.
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They're also commonly use...
This class is a collection of widget input-to-output connections that can be applied all-at-once to a...
virtual bool ClearRouting(void)
Removes all existing signal path connections between any and all widgets on the AJA device...
virtual bool SupportedOutputXptsForInputXpt(const NTV2InputXptID inInputXptID, NTV2OutputXptIDSet &outOutputXpts)
Answers with the set of output (sources) that can legally be connected to the given input (sink)...
NTV2InputCrosspointQueue::iterator NTV2InputCrosspointQueueIter
virtual bool GetConnectedInput(const NTV2OutputCrosspointID inOutputXpt, NTV2InputCrosspointID &outInputXpt)
Answers with a connected NTV2InputCrosspointID for the given NTV2OutputCrosspointID.
std::string NTV2InputCrosspointIDToString(const NTV2InputCrosspointID inValue, const bool inForRetailDisplay=false)
The highest register number for the device.
static bool GetRouteROMInfoFromReg(const ULWord inROMRegNum, const ULWord inROMRegValue, NTV2InputXptID &outInputXpt, NTV2OutputXptIDSet &outOutputXpts, const bool inAppendOutputXpts=false)
Answers with the NTV2InputXptID and NTV2OutputXptIDSet for the given ROM register value...
virtual bool CanConnect(const NTV2InputCrosspointID inInputXpt, const NTV2OutputCrosspointID inOutputXpt, bool &outCanConnect)
Answers whether or not the given widget signal input (sink) can legally be connected to the given sig...
virtual bool ReadRegister(const ULWord inRegNum, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Reads all or part of the 32-bit contents of a specific register (real or virtual) on the AJA device...
static bool GetAllRoutingRegInfos(const NTV2InputXptIDSet &inInputs, NTV2RegisterWrites &outRegInfos)
Returns all routing registers for the given set of input crosspoints.
std::set< NTV2WidgetID > NTV2WidgetIDSet
A collection of distinct NTV2WidgetID values.
#define NTV2_IS_VALID_InputCrosspointID(__s__)
NTV2RegisterNumberSet NTV2RegNumSet
A set of distinct NTV2RegisterNumbers.
std::set< ULWord > ULWordSet
A collection of unique ULWord (uint32_t) values.
static const ULWord sMasks[]
virtual bool ApplySignalRoute(const CNTV2SignalRouter &inRouter, const bool inReplace=(0))
Applies the given routing table to the AJA device.
NTV2RegWrites NTV2RegisterReads
#define kRegClass_Routing
static bool GetCrosspointSelectGroupRegisterInfo(const NTV2InputCrosspointID inInputXpt, uint32_t &outXptRegNum, uint32_t &outMaskIndex)
Answers with the crosspoint select register and mask information for a given widget input...
virtual bool RemoveConnections(const NTV2XptConnections &inConnections)
Removes the given widget routing connections from the AJA device.
#define LOGGING_ROUTING_CHANGES
#define NTV2_IS_VALID_OutputCrosspointID(__s__)
virtual bool IsConnected(const NTV2InputCrosspointID inInputXpt, bool &outIsConnected)
Answers whether or not the given widget signal input (sink) is connected to another output (source)...
virtual bool GetRouting(CNTV2SignalRouter &outRouting)
Answers with the current signal routing between any and all widgets on the AJA device.
virtual bool Connect(const NTV2InputCrosspointID inInputXpt, const NTV2OutputCrosspointID inOutputXpt, const bool inValidate=(0))
Connects the given widget signal input (sink) to the given widget signal output (source).
static bool GetAllWidgetInputs(const NTV2DeviceID inDeviceID, NTV2InputXptIDSet &outInputs)
Returns all supported widget input crosspoints for the given device.
std::string NTV2DeviceIDToString(const NTV2DeviceID inValue, const bool inForRetailDisplay=false)
Originally 0x01. Changed to 0x00 in SDK 17.1.
NTV2InputXptIDSet::const_iterator NTV2InputCrosspointIDSetConstIter
True if device has a crosspoint connection ROM (New in SDK 17.0)
NTV2WidgetIDSet::const_iterator NTV2WidgetIDSetConstIter
An iterator for iterating over a read-only NTV2WidgetIDSet.
static bool GetWidgetForOutput(const NTV2OutputXptID inOutputXpt, NTV2WidgetID &outWidgetID, const NTV2DeviceID inDeviceID=DEVICE_ID_NOTFOUND)
Returns the widget that "owns" the specified output crosspoint.
Declares numerous NTV2 utility functions.
std::set< NTV2InputXptID > NTV2InputXptIDSet
A collection of distinct NTV2InputXptID values.
NTV2OutputCrosspointID
Identifies a widget output, a signal source, that potentially can drive another widget's input (ident...
NTV2InputCrosspointID
Identifies a widget input that potentially can accept a signal emitted from another widget's output (...
static bool GetWidgetIDs(const NTV2DeviceID inDeviceID, NTV2WidgetIDSet &outWidgets)
Returns the widget IDs supported by the given device.
virtual bool GetRoutingForChannel(const NTV2Channel inChannel, CNTV2SignalRouter &outRouting)
Answers with the current signal routing for the given channel.
virtual bool IsConnectedTo(const NTV2InputCrosspointID inInputXpt, const NTV2OutputCrosspointID inOutputXpt, bool &outIsConnected)
Answers whether or not the given widget signal input (sink) is connected to another output (source)...
#define xHEX0N(__x__, __n__)
virtual bool GetConnectedInputs(const NTV2OutputCrosspointID inOutputXpt, NTV2InputCrosspointIDSet &outInputXpts)
Answers with all of the NTV2InputCrosspointIDs that are connected to the given NTV2OutputCrosspointID...
deque< NTV2InputCrosspointID > NTV2InputCrosspointQueue
Declares the CNTV2Card class.
std::pair< NTV2InputXptID, NTV2OutputXptID > NTV2XptConnection
enum NTV2InputCrosspointID NTV2InputXptID
std::set< NTV2InputXptID > NTV2InputCrosspointIDSet
std::string NTV2OutputCrosspointIDToString(const NTV2OutputCrosspointID inValue, const bool inForRetailDisplay=false)
std::map< NTV2InputXptID, NTV2OutputXptID > NTV2XptConnections
NTV2InputCrosspointQueue::const_iterator NTV2InputCrosspointQueueConstIter
std::vector< NTV2RegInfo > NTV2RegisterWrites
#define NTV2_IS_VALID_WIDGET(__w__)
Identifies the NTV2AudioWidgetID enumerated type.
std::set< NTV2OutputXptID > NTV2OutputXptIDSet
A collection of distinct NTV2OutputXptID values.
static bool GetWidgetInputs(const NTV2WidgetID inWidgetID, NTV2InputXptIDSet &outInputs)
Returns the input crosspoints known to be "owned" by the given widget.
enum NTV2OutputCrosspointID NTV2OutputXptID
virtual bool GetConnections(NTV2XptConnections &outConnections)
Answers with the device's current widget routing connections.
static const ULWord sShifts[]
Declares the CNTV2RegisterExpert class.