AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
ntv2config2022.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #include "ntv2config2022.h"
9 #include "ntv2configts2022.h"
10 #include "ntv2endian.h"
11 #include "ntv2utils.h"
12 #include "ntv2card.h"
13 #include <ajabase/network/network.h>
14 #include <sstream>
15 
16 #if defined (AJALinux) || defined (AJAMac)
17  #include <stdlib.h>
18 #endif
19 
20 using namespace std;
22 {
23  sfp1Enable = true;
24  sfp2Enable = false;
25 
26  sfp1RemoteIP.erase();
27  sfp1LocalPort = 0;
28  sfp1RemotePort = 0;
29 
30  sfp2RemoteIP.erase();
31  sfp2LocalPort = 0;
32  sfp2RemotePort = 0;
33 
34  tos = 0x64;
35  ttl = 0x40;
36  ssrc = 0;
37 }
38 
40 {
41  return !(*this == other);
42 }
43 
45 {
46  if ((sfp1Enable == other.sfp1Enable) &&
47  (sfp2Enable == other.sfp2Enable) &&
48 
49  (sfp1LocalPort == other.sfp1LocalPort) &&
50  (sfp1RemoteIP == other.sfp1RemoteIP) &&
51  (sfp1RemotePort == other.sfp1RemotePort) &&
52 
53  (sfp2LocalPort == other.sfp2LocalPort) &&
54  (sfp2RemoteIP == other.sfp2RemoteIP) &&
55  (sfp2RemotePort == other.sfp2RemotePort))
56  {
57  return true;
58  }
59  else
60  {
61  return false;
62  }
63 }
64 
66 {
67  sfp1Enable = true;
68  sfp2Enable = false;
69 
70  sfp1RxMatch = 0;
71  sfp1SourceIP.erase();
72  sfp1DestIP.erase();
73  sfp1SourcePort = 0;
74  sfp1DestPort = 0;
75  sfp1Vlan = 0;
76 
77  sfp2RxMatch = 0;
78  sfp2SourceIP.erase();
79  sfp2DestIP.erase();
80  sfp2SourcePort = 0;
81  sfp2DestPort = 0;
82  sfp2Vlan = 0;
83 
84  ssrc = 0;
85  playoutDelay = 50;
86 }
87 
89 {
90  return !(*this == other);
91 }
92 
94 {
95  if ((sfp1Enable == other.sfp1Enable) &&
96  (sfp2Enable == other.sfp2Enable) &&
97 
98  (sfp1RxMatch == other.sfp1RxMatch) &&
99  (sfp1SourceIP == other.sfp1SourceIP) &&
100  (sfp1DestIP == other.sfp1DestIP) &&
101  (sfp1SourcePort == other.sfp1SourcePort) &&
102  (sfp1DestPort == other.sfp1DestPort) &&
103  (sfp1Vlan == other.sfp1Vlan) &&
104 
105  (sfp2RxMatch == other.sfp2RxMatch) &&
106  (sfp2SourceIP == other.sfp2SourceIP) &&
107  (sfp2DestIP == other.sfp2DestIP) &&
108  (sfp2SourcePort == other.sfp2SourcePort) &&
109  (sfp2DestPort == other.sfp2DestPort) &&
110  (sfp2Vlan == other.sfp2Vlan) &&
111 
112  (ssrc == other.ssrc) &&
113  (playoutDelay == other.playoutDelay))
114  {
115  return true;
116  }
117  else
118  {
119  return false;
120  }
121 }
122 
123 
125 {
126  videoFormat = NTV2_FORMAT_720p_5994;
127  ullMode = false;
128  bitDepth = 10;
129  chromaSubsamp = kJ2KChromaSubSamp_422_Standard;
130  mbps = 200;
131  streamType = kJ2KStreamTypeStandard;
132  audioChannels = 2;
133  pmtPid = 255;
134  videoPid = 256;
135  pcrPid = 257;
136  audio1Pid = 258;
137 }
138 
140 {
141  return (!(*this == other));
142 }
143 
145 {
146  if ((videoFormat == other.videoFormat) &&
147  (ullMode == other.ullMode) &&
148  (bitDepth == other.bitDepth) &&
149  (chromaSubsamp == other.chromaSubsamp) &&
150  (mbps == other.mbps) &&
151  (streamType == other.streamType) &&
152  (audioChannels == other.audioChannels) &&
153  (pmtPid == other.pmtPid) &&
154  (videoPid == other.videoPid) &&
155  (pcrPid == other.pcrPid) &&
156  (audio1Pid == other.audio1Pid))
157  {
158  return true;
159  }
160  else
161  {
162  return false;
163  }
164 }
165 
167 {
168  selectionMode = j2kDecoderConfig::eProgSel_Default;
169  programNumber = 1;
170  programPID = 0;
171  audioNumber = 1;
172 }
173 
175 {
176  return (!(*this == other));
177 }
178 
180 {
181  if ((selectionMode == other.selectionMode) &&
182  (programNumber == other.programNumber) &&
183  (programPID == other.programPID) &&
184  (audioNumber == other.audioNumber))
185  {
186  return true;
187  }
188  else
189  {
190  return false;
191  }
192 }
193 
195 {
196  numAvailablePrograms = 0;
197  numAvailableAudios = 0;
198  availableProgramNumbers.clear();
199  availableProgramPIDs.clear();
200  availableAudioPIDs.clear();
201 }
202 
204 //
205 // CNTV2Config2022
206 //
208 
210 {
211  uint32_t features = getFeatures();
212 
213  _numTx0Chans = (features & (SAREK_TX0_MASK)) >> 28;
214  _numRx0Chans = (features & (SAREK_RX0_MASK)) >> 24;
215  _numTx1Chans = (features & (SAREK_TX1_MASK)) >> 20;
216  _numRx1Chans = (features & (SAREK_RX1_MASK)) >> 16;
217 
218  _numRxChans = _numRx0Chans + _numRx1Chans;
219  _numTxChans = _numTx0Chans + _numTx1Chans;
220 
221  _is2022_6 = ((features & SAREK_2022_6) != 0);
222  _is2022_2 = ((features & SAREK_2022_2) != 0);
223  _is2022_7 = ((features & SAREK_2022_7) != 0);
224  _is_txTop34 = ((features & SAREK_TX_TOP34) != 0);
225 
226  _biDirectionalChannels = false;
227 
228  _tstreamConfig = NULL;
229  if (_is2022_2)
230  {
231  _tstreamConfig = new CNTV2ConfigTs2022(device);
232  }
233 
234  _isIoIp = (device.GetDeviceID() == DEVICE_ID_IOIP_2022);
235 }
236 
238 {
239  if (_is2022_2)
240  {
241  delete _tstreamConfig;
242  }
243 }
244 
246 {
247  string ip, subnet, gateway;
248  struct in_addr addr;
249  addr.s_addr = (uint32_t)netConfig.ipc_ip;
250  ip = AJANetwork::aja_inet_ntoa(addr);
251  addr.s_addr = (uint32_t)netConfig.ipc_subnet;
252  subnet = AJANetwork::aja_inet_ntoa(addr);
253  addr.s_addr = (uint32_t)netConfig.ipc_gateway;
254  gateway = AJANetwork::aja_inet_ntoa(addr);
255 
256  bool rv = SetNetworkConfiguration(sfp, ip, subnet, gateway);
257  return rv;
258 }
259 
261 {
262  string ip, subnet, gateway;
263  GetNetworkConfiguration(sfp, ip, subnet, gateway);
264 
265  netConfig.ipc_ip = NTV2EndianSwap32((uint32_t)AJANetwork::aja_inet_addr(ip.c_str()));
266  netConfig.ipc_subnet = NTV2EndianSwap32((uint32_t)AJANetwork::aja_inet_addr(subnet.c_str()));
267  netConfig.ipc_gateway = NTV2EndianSwap32((uint32_t)AJANetwork::aja_inet_addr(gateway.c_str()));
268 
269  return true;
270 }
271 
272 bool CNTV2Config2022::SetNetworkConfiguration(const eSFP sfp, const std::string localIPAddress, const std::string subnetMask, const std::string gateway)
273 {
274  if (!mDevice.IsMBSystemReady())
275  {
277  return false;
278  }
279 
280  if (!mDevice.IsMBSystemValid())
281  {
283  return false;
284  }
285 
286  uint32_t addr = AJANetwork::aja_inet_addr(localIPAddress.c_str());
287  addr = NTV2EndianSwap32(addr);
288 
289  uint32_t macLo;
290  uint32_t macHi;
291 
292  // get primaray mac address
293  uint32_t macAddressRegister = SAREK_REGS + kRegSarekMAC;
294  mDevice.ReadRegister(macAddressRegister, macHi);
295  macAddressRegister++;
296  mDevice.ReadRegister(macAddressRegister, macLo);
297 
298  uint32_t boardHi = (macHi & 0xffff0000) >>16;
299  uint32_t boardLo = ((macHi & 0x0000ffff) << 16) + ((macLo & 0xffff0000) >> 16);
300 
301  // get sfp2 mac address
302  macAddressRegister++;
303  mDevice.ReadRegister(macAddressRegister, macHi);
304  macAddressRegister++;
305  mDevice.ReadRegister(macAddressRegister, macLo);
306 
307  uint32_t boardHi2 = (macHi & 0xffff0000) >>16;
308  uint32_t boardLo2 = ((macHi & 0x0000ffff) << 16) + ((macLo & 0xffff0000) >> 16);
309 
310  uint32_t core6;
311  uint32_t core2;
312 
313  if (sfp == SFP_1)
314  {
315  core6 = (_is_txTop34) ? SAREK_2022_6_TX_CORE_1 : SAREK_2022_6_TX_CORE_0;
316  core2 = SAREK_2022_2_TX_CORE_0;
317  }
318  else
319  {
320  core6 = (_is_txTop34) ? SAREK_2022_6_TX_CORE_0 : SAREK_2022_6_TX_CORE_1;
321  core2 = SAREK_2022_2_TX_CORE_1;
322  }
323 
324  if (_is2022_6)
325  {
326  // initialise constants
327  if (_isIoIp)
328  mDevice.WriteRegister(kReg2022_6_tx_sys_mem_conf + core6, 0x10); // IoIP
329  else
330  mDevice.WriteRegister(kReg2022_6_tx_sys_mem_conf + core6, 0x04); // KonaIP
331  mDevice.WriteRegister(kReg2022_6_tx_hitless_config + core6, 0x01); // disable
332 
333  // source ip address
335 
338 
341  }
342  else
343  {
346 
349  }
350 
351  bool rv = SetMBNetworkConfiguration (sfp, localIPAddress, subnetMask, gateway);
352  return rv;
353 }
354 
355 bool CNTV2Config2022::GetNetworkConfiguration(const eSFP sfp, std::string & localIPAddress, std::string & subnetMask, std::string & gateway)
356 {
357  struct in_addr addr;
358 
359  if (sfp == SFP_1)
360  {
361  uint32_t val;
363  addr.s_addr = val;
364  localIPAddress = AJANetwork::aja_inet_ntoa(addr);
365 
367  addr.s_addr = val;
368  subnetMask = AJANetwork::aja_inet_ntoa(addr);
369 
371  addr.s_addr = val;
372  gateway = AJANetwork::aja_inet_ntoa(addr);
373  }
374  else
375  {
376  uint32_t val;
378  addr.s_addr = val;
379  localIPAddress = AJANetwork::aja_inet_ntoa(addr);
380 
382  addr.s_addr = val;
383  subnetMask = AJANetwork::aja_inet_ntoa(addr);
384 
386  addr.s_addr = val;
387  gateway = AJANetwork::aja_inet_ntoa(addr);
388  }
389  return true;
390 }
391 
393 {
395 }
396 
397 
399 {
400  uint32_t baseAddr;
401  bool rv;
402 
403  bool enabled_7 = false;
404  uint32_t unused = 0;
405  Get2022_7_Mode(enabled_7,unused);
406 
407  bool sfp1 = rxConfig.sfp1Enable;
408  bool sfp2 = rxConfig.sfp2Enable;
409  if (enabled_7)
410  {
411  sfp1 = true;
412  sfp2 = true;
413  }
414 
415  if (sfp1 && (GetSFPActive(SFP_1) == false))
416  {
418  return false;
419  }
420 
421  if (sfp2 && (GetSFPActive(SFP_2) == false))
422  {
424  return false;
425  }
426 
427  if (_is2022_7)
428  {
429  // select sfp2 channel
430  rv = SelectRxChannel(channel, SFP_2, baseAddr);
431  if (!rv) return false;
432 
433  // hold off access while we update channel regs
434  ChannelSemaphoreClear(kReg2022_6_rx_control, baseAddr);
435 
436  SetRxMatch(channel, SFP_2, 0); // disable while configuring
437 
438  // source ip address
439  uint32_t sourceIp = AJANetwork::aja_inet_addr(rxConfig.sfp2SourceIP.c_str());
440  sourceIp = NTV2EndianSwap32(sourceIp);
442 
443  // dest ip address
444  uint32_t destIp = AJANetwork::aja_inet_addr(rxConfig.sfp2DestIP.c_str());
445  destIp = NTV2EndianSwap32(destIp);
447 
448  // source port
450 
451  // dest port
453 
454  // vlan
456 
457  // matching
458  SetRxMatch(channel, SFP_2, rxConfig.sfp2RxMatch);
459 
460  // enable register updates
461  ChannelSemaphoreSet(kReg2022_6_rx_control, baseAddr);
462 
463  // update IGMP subscriptions
464  uint8_t ip0 = (destIp & 0xff000000)>> 24;
465  if ((ip0 >= 224 && ip0 <= 239) && sfp2)
466  {
467  // is multicast
468  bool enabled = false;
469  GetRxChannelEnable(channel,enabled);
470  if (rxConfig.sfp2RxMatch & RX_MATCH_2022_SOURCE_IP)
471  SetIGMPGroup(SFP_2, VideoChannelToStream(channel), destIp, sourceIp, enabled);
472  else
473  SetIGMPGroup(SFP_2, VideoChannelToStream(channel), destIp, 0, enabled);
474  }
475  else
476  {
477  UnsetIGMPGroup(SFP_2, VideoChannelToStream(channel));
478  }
479 
480  SetRxLinkState(channel, sfp1, sfp2);
481  }
482  else
483  {
484  SetRxLinkState(channel, true, false);
485  }
486 
487  // select sfp1 channel
488  rv = SelectRxChannel(channel, SFP_1, baseAddr);
489  if (!rv) return false;
490 
491  // hold off access while we update channel regs
492  ChannelSemaphoreClear(kReg2022_6_rx_control, baseAddr);
493 
494  SetRxMatch(channel, SFP_1, 0); // disable while configuring
495 
496  // source ip address
497  uint32_t sourceIp = AJANetwork::aja_inet_addr(rxConfig.sfp1SourceIP.c_str());
498  sourceIp = NTV2EndianSwap32(sourceIp);
500 
501  // dest ip address
502  uint32_t destIp = AJANetwork::aja_inet_addr(rxConfig.sfp1DestIP.c_str());
503  destIp = NTV2EndianSwap32(destIp);
505 
506  // source port
508 
509  // dest port
511 
512  // ssrc
513  WriteChannelRegister(kReg2022_6_rx_match_ssrc + baseAddr, rxConfig.ssrc);
514 
515  // vlan
517 
518  // matching
519  SetRxMatch(channel, SFP_1, rxConfig.sfp1RxMatch);
520 
521  // playout delay in 27MHz clocks or 90kHz clocks
522  uint32_t delay;
523  delay = (_is2022_2) ? (rxConfig.playoutDelay * 90) << 9 : rxConfig.playoutDelay * 27000;
525 
526  // network path differential
527  if (_is2022_2 || (enabled_7 == false))
528  {
530  }
531 
532  // some constants
533  WriteChannelRegister(kReg2022_6_rx_chan_timeout + baseAddr, 0x12ffffff);
535  if (_isIoIp)
536  WriteChannelRegister(kReg2022_6_rx_media_buf_base_addr + baseAddr, 0xC0000000 + (0x10000000 * channel)); // IoIp
537  else
538  WriteChannelRegister(kReg2022_6_rx_media_buf_base_addr + baseAddr, 0x10000000 * channel); // KonaIp
539 
540  // enable register updates
541  ChannelSemaphoreSet(kReg2022_6_rx_control, baseAddr);
542 
543  if (_is2022_2)
544  {
545  // setup PLL
551 
552  uint32_t rxMatch = rxConfig.sfp1RxMatch;
553  uint32_t pllMatch = 0;
554  if (rxMatch & RX_MATCH_2022_DEST_IP) pllMatch |= PLL_MATCH_DEST_IP;
555  if (rxMatch & RX_MATCH_2022_SOURCE_IP) pllMatch |= PLL_MATCH_SOURCE_IP;
556  if (rxMatch & RX_MATCH_2022_DEST_PORT) pllMatch |= PLL_MATCH_DEST_PORT;
557  if (rxMatch & RX_MATCH_2022_SOURCE_PORT) pllMatch |= PLL_MATCH_SOURCE_PORT;
558  pllMatch |= PLL_MATCH_ES_PID; // always set for TS PCR
560 
561  }
562 
563  // update IGMP subscriptions
564  uint8_t ip0 = (destIp & 0xff000000)>> 24;
565  if ((ip0 >= 224 && ip0 <= 239) && sfp1)
566  {
567  // is multicast
568  bool enabled = false;
569  GetRxChannelEnable(channel,enabled);
570  if (rxConfig.sfp1RxMatch & RX_MATCH_2022_SOURCE_IP)
571  SetIGMPGroup(SFP_1, VideoChannelToStream(channel), destIp, sourceIp, enabled);
572  else
573  SetIGMPGroup(SFP_1, VideoChannelToStream(channel), destIp, 0, enabled);
574  }
575  else
576  {
577  UnsetIGMPGroup(SFP_1, VideoChannelToStream(channel));
578  }
579 
580  return rv;
581 }
582 
584 {
585  uint32_t baseAddr;
586  uint32_t val;
587  bool rv;
588 
589  //get sfp enables
590  GetRxLinkState(channel,rxConfig.sfp1Enable, rxConfig.sfp2Enable);
591 
592  if (_is2022_7)
593  {
594  // Select sfp2 channel
595  rv = SelectRxChannel(channel, SFP_2, baseAddr);
596  if (!rv) return false;
597 
598  // source ip address
600  struct in_addr in;
601  in.s_addr = NTV2EndianSwap32(val);
602  char * ip = AJANetwork::aja_inet_ntoa(in);
603  rxConfig.sfp2SourceIP = ip;
604 
605  // dest ip address
607  in.s_addr = NTV2EndianSwap32(val);
608  ip = AJANetwork::aja_inet_ntoa(in);
609  rxConfig.sfp2DestIP = ip;
610 
611  // source port
613 
614  // dest port
616 
617  // vlan
619  rxConfig.sfp2Vlan = val & 0xffff;
620 
621  // matching
622  GetRxMatch(channel, SFP_2, rxConfig.sfp2RxMatch);
623  }
624  else
625  {
626  rxConfig.sfp1Enable = true;
627  rxConfig.sfp2Enable = false;
628  }
629 
630  // select sfp1 channel
631  rv = SelectRxChannel(channel, SFP_1, baseAddr);
632  if (!rv) return false;
633 
634  // source ip address
636  struct in_addr in;
637  in.s_addr = NTV2EndianSwap32(val);
638  char * ip = AJANetwork::aja_inet_ntoa(in);
639  rxConfig.sfp1SourceIP = ip;
640 
641  // dest ip address
643  in.s_addr = NTV2EndianSwap32(val);
644  ip = AJANetwork::aja_inet_ntoa(in);
645  rxConfig.sfp1DestIP = ip;
646 
647  // source port
649 
650  // dest port
652 
653  // ssrc
654  ReadChannelRegister(kReg2022_6_rx_match_ssrc + baseAddr, &rxConfig.ssrc);
655 
656  // vlan
658  rxConfig.sfp1Vlan = val & 0xffff;
659 
660  // matching
661  GetRxMatch(channel, SFP_1, rxConfig.sfp1RxMatch);
662 
663  // playout delay in ms
665  rxConfig.playoutDelay = (_is2022_2) ? (val >>9)/90 : val/27000;
666 
667  return true;
668 }
669 
670 bool CNTV2Config2022::SetRxChannelEnable(const NTV2Channel channel, bool enable)
671 {
672  uint32_t baseAddr;
673  bool rv;
674  bool disableIGMP;
675 
676  //get sfp enables
677  bool sfp1Enable;
678  bool sfp2Enable;
679  GetRxLinkState(channel,sfp1Enable, sfp2Enable);
680 
681  if (enable && sfp1Enable)
682  {
683  if (GetSFPActive(SFP_1) == false)
684  {
686  return false;
687  }
688  }
689 
690  if (enable && sfp2Enable)
691  {
692  if (GetSFPActive(SFP_2) == false)
693  {
695  return false;
696  }
697  }
698 
699  if (enable && _biDirectionalChannels)
700  {
701  bool txEnabled;
702  GetTxChannelEnable(channel, txEnabled);
703  if (txEnabled)
704  {
705  // disable tx channel
706  SetTxChannelEnable(channel,false);
707  }
708  mDevice.SetSDITransmitEnable(channel, false);
709  }
710 
711  if (sfp2Enable)
712  {
713  // IGMP subscription for sfp2 channel
714  GetIGMPDisable(SFP_2, disableIGMP);
715  if (!disableIGMP)
716  {
717  EnableIGMPGroup(SFP_2, VideoChannelToStream(channel), enable);
718  }
719  }
720  else
721  {
722  EnableIGMPGroup(SFP_2, VideoChannelToStream(channel), false);
723  }
724 
725  if (sfp1Enable)
726  {
727  // IGMP subscription for sfp1 channel
728  GetIGMPDisable(SFP_1, disableIGMP);
729  if (!disableIGMP)
730  {
731  EnableIGMPGroup(SFP_1, VideoChannelToStream(channel), enable);
732  }
733  }
734  else
735  {
736  EnableIGMPGroup(SFP_1, VideoChannelToStream(channel), false);
737  }
738 
739  rv = SelectRxChannel(channel, SFP_1, baseAddr);
740  if (!rv) return false;
741  if (enable & sfp1Enable)
742  {
743  uint8_t match;
744  GetRxMatch(channel, SFP_1, match);
745  WriteChannelRegister(kReg2022_6_rx_match_sel + baseAddr, (uint32_t)match);
746  }
747  else
748  {
749  // disables rx
751  }
752 
753  rv = SelectRxChannel(channel, SFP_2, baseAddr);
754  if (!rv) return false;
755  if (enable & sfp2Enable)
756  {
757  uint8_t match;
758  GetRxMatch(channel, SFP_2, match);
759  WriteChannelRegister(kReg2022_6_rx_match_sel + baseAddr, (uint32_t)match);
760  }
761  else
762  {
763  // disables rx
765  }
766 
767  // set channel enable
768  rv = SelectRxChannel(channel, SFP_1, baseAddr);
769  if (enable)
770  {
771  // Bit 0 = enable
772  // Bit 1 = ignore RTP timestamp
773  // Bit 1 is set because otherwise, we sometimes lock up on format
774  // change on incoming stream
776  }
777  else
778  {
780  }
781 
782  return rv;
783 }
784 
785 bool CNTV2Config2022::GetRxChannelEnable(const NTV2Channel channel, bool & enabled)
786 {
787  uint32_t baseAddr;
788 
789  enabled = false;
790 
791  // select sfp1 channel
792  bool rv = SelectRxChannel(channel, SFP_1, baseAddr);
793  if (!rv) return false;
794 
795  uint32_t val;
796  rv = ReadChannelRegister(kReg2022_6_rx_match_sel + baseAddr,&val);
797  if (!rv) return false;
798  if (val)
799  {
800  enabled = true;
801  return true;
802  }
803 
804  // select sfp2 channel
805  rv = SelectRxChannel(channel, SFP_2, baseAddr);
806  if (!rv) return false;
807 
808  rv = ReadChannelRegister(kReg2022_6_rx_match_sel + baseAddr,&val);
809  if (!rv) return false;
810  if (val)
811  {
812  enabled = true;
813  return true;
814  }
815 
816  return true;
817 }
818 
819 static bool MacAddressToRegisters(const MACAddr &macaddr, uint32_t & hi, uint32_t & lo)
820 {
821  hi = macaddr.mac[0] << 8;
822  hi += macaddr.mac[1];
823 
824  lo = macaddr.mac[2] << 24;
825  lo += macaddr.mac[3] << 16;
826  lo += macaddr.mac[4] << 8;
827  lo += macaddr.mac[5];
828  return true;
829 }
830 
832 {
833  uint32_t baseAddr;
834  uint32_t hi;
835  uint32_t lo;
836 
837 
838  uint32_t destIp;
839 
840  bool rv;
841 
842  if (txConfig.sfp1Enable && (GetSFPActive(SFP_1) == false))
843  {
845  return false;
846  }
847 
848  if (txConfig.sfp2Enable && (GetSFPActive(SFP_2) == false))
849  {
851  return false;
852  }
853 
854  if (_is2022_7)
855  {
856  // Select sfp2 channel
857  rv = SelectTxChannel(channel, SFP_2, baseAddr);
858  if (!rv) return false;
859 
860  // hold off access while we update channel regs
861  ChannelSemaphoreClear(kReg2022_6_tx_control, baseAddr);
862 
863  // initialise
864  uint32_t val = (txConfig.tos << 8) | txConfig.ttl;
866  WriteChannelRegister(kReg2022_6_tx_ssrc + baseAddr, txConfig.ssrc);
867 
868  if (_is2022_6)
869  {
870  WriteChannelRegister(kReg2022_6_tx_video_para_config + baseAddr, 0x01); // include video timestamp
871  }
872  else
873  {
875  }
876 
877  // dest ip address
878  destIp = AJANetwork::aja_inet_addr(txConfig.sfp2RemoteIP.c_str());
879  destIp = NTV2EndianSwap32(destIp);
881 
882  // source port
884 
885  // dest port
887 
888  // Get or generate a Mac address if we have 2022-7 enabled.
889  if (txConfig.sfp2Enable)
890  {
891  rv = GetMACAddress(SFP_2, VideoChannelToStream(channel), txConfig.sfp2RemoteIP,hi,lo);
892  if (!rv) return false;
895  }
896 
897  // enable register updates
898  ChannelSemaphoreSet(kReg2022_6_tx_control, baseAddr);
899 
900  SetTxLinkState(channel, txConfig.sfp1Enable,txConfig.sfp2Enable);
901  }
902  else
903  {
904  SetTxLinkState(channel, true, false);
905  }
906 
907  // select sfp1 channel
908  rv = SelectTxChannel(channel, SFP_1, baseAddr);
909  if (!rv) return false;
910 
911  // hold off access while we update channel regs
912  ChannelSemaphoreClear(kReg2022_6_tx_control, baseAddr);
913 
914  // initialise
915  uint32_t val = (txConfig.tos << 8) | txConfig.ttl;
917  WriteChannelRegister(kReg2022_6_tx_ssrc + baseAddr, txConfig.ssrc);
918  if (_is2022_6)
919  {
920  WriteChannelRegister(kReg2022_6_tx_video_para_config + baseAddr, 0x01); // include video timestamp
921  }
922  else
923  {
925  }
926 
927  // dest ip address
928  destIp = AJANetwork::aja_inet_addr(txConfig.sfp1RemoteIP.c_str());
929  destIp = NTV2EndianSwap32(destIp);
931 
932  // source port
934 
935  // dest port
937 
938  if (txConfig.sfp1Enable)
939  {
940  rv = GetMACAddress(SFP_1, VideoChannelToStream(channel), txConfig.sfp1RemoteIP,hi,lo);
941  if (!rv) return false;
944  }
945 
946  // enable register updates
947  ChannelSemaphoreSet(kReg2022_6_tx_control, baseAddr);
948 
949  return rv;
950 }
951 
953 {
954  uint32_t baseAddr;
955  uint32_t val;
956  bool rv;
957  if (_is2022_7)
958  {
959  // select sfp2 channel
960  rv = SelectTxChannel(channel, SFP_2, baseAddr);
961  if (!rv) return false;
962 
963  //get sfp enables
964  GetTxLinkState(channel,txConfig.sfp1Enable, txConfig.sfp2Enable);
965 
967  txConfig.ttl = val & 0xff;
968  txConfig.tos = (val & 0xff00) >> 8;
969  ReadChannelRegister(kReg2022_6_tx_ssrc + baseAddr,&txConfig.ssrc);
970 
971  // dest ip address
973  struct in_addr in;
974  in.s_addr = NTV2EndianSwap32(val);
975  char * ip = AJANetwork::aja_inet_ntoa(in);
976  txConfig.sfp2RemoteIP = ip;
977  // source port
979 
980  // dest port
982  }
983  else
984  {
985  txConfig.sfp1Enable = true;
986  txConfig.sfp2Enable = false;
987  }
988  // Select sfp1 channel
989  rv = SelectTxChannel(channel, SFP_1, baseAddr);
990  if (!rv) return false;
991 
992  // dest ip address
994  struct in_addr in;
995  in.s_addr = NTV2EndianSwap32(val);
996  char * ip = AJANetwork::aja_inet_ntoa(in);
997  txConfig.sfp1RemoteIP = ip;
998 
999  // source port
1001 
1002  // dest port
1004  return true;
1005 }
1006 
1007 bool CNTV2Config2022::SetTxChannelEnable(const NTV2Channel channel, bool enable)
1008 {
1009  uint32_t baseAddr;
1010  bool rv;
1011  uint32_t localIp;
1012 
1013  //get sfp enables
1014  bool sfp1Enable;
1015  bool sfp2Enable;
1016  GetTxLinkState(channel,sfp1Enable, sfp2Enable);
1017 
1018  if (enable && sfp1Enable)
1019  {
1020  if (GetSFPActive(SFP_1) == false)
1021  {
1023  return false;
1024  }
1025  }
1026 
1027  if (enable && sfp2Enable)
1028  {
1029  if (GetSFPActive(SFP_2) == false)
1030  {
1032  return false;
1033  }
1034  }
1035 
1036  if (_biDirectionalChannels)
1037  {
1038  bool rxEnabled;
1039  GetRxChannelEnable(channel,rxEnabled);
1040  if (rxEnabled)
1041  {
1042  // disable rx channel
1043  SetRxChannelEnable(channel,false);
1044  }
1045  mDevice.SetSDITransmitEnable(channel, true);
1046  }
1047 
1048  // select sfp1 channel
1049  rv = SelectTxChannel(channel, SFP_1, baseAddr);
1050  if (!rv) return false;
1051 
1052  if (!enable)
1053  {
1054  rv = SelectTxChannel(channel, SFP_1, baseAddr);
1055  if (!rv) return false;
1056 
1057  WriteChannelRegister(kReg2022_6_tx_chan_enable + baseAddr,0x0); // disables channel
1058  }
1059 
1060  // hold off access while we update channel regs
1061  ChannelSemaphoreClear(kReg2022_6_tx_control, baseAddr);
1062 
1063  WriteChannelRegister(kReg2022_6_tx_hitless_config + baseAddr,0x0); // 0 enables hitless mode
1064 
1065  if (enable && sfp1Enable)
1066  {
1067  if (GetTxLink(channel) == SFP_1)
1068  {
1070  }
1071  else
1072  {
1074  }
1076 
1077  WriteChannelRegister(kReg2022_6_tx_link_enable + baseAddr,0x01); // enables tx over mac1/mac2
1078  }
1079  else
1080  {
1081  WriteChannelRegister(kReg2022_6_tx_link_enable + baseAddr,0x00); // enables tx over mac1/mac2
1082  }
1083 
1084  // enable register updates
1085  ChannelSemaphoreSet(kReg2022_6_tx_control, baseAddr);
1086 
1087  if (_is2022_7)
1088  {
1089  // Select sfp2 channel
1090  rv = SelectTxChannel(channel, SFP_2, baseAddr);
1091  if (!rv) return false;
1092 
1093  // hold off access while we update channel regs
1094  ChannelSemaphoreClear(kReg2022_6_tx_control, baseAddr);
1095 
1096  WriteChannelRegister(kReg2022_6_tx_hitless_config + baseAddr,0x0); // 0 enables hitless mode
1097 
1098  if (enable && sfp2Enable)
1099  {
1102 
1103  // enable
1104  WriteChannelRegister(kReg2022_6_tx_link_enable + baseAddr,0x01); // enables tx over mac1/mac2
1105  }
1106  else
1107  {
1108  // disable
1109  WriteChannelRegister(kReg2022_6_tx_link_enable + baseAddr,0x0); // disables tx over mac1/mac2
1110  }
1111 
1112  // enable register updates
1113  ChannelSemaphoreSet(kReg2022_6_tx_control, baseAddr);
1114  }
1115 
1116  if (enable)
1117  {
1118  SelectTxChannel(channel, SFP_1, baseAddr);
1119  WriteChannelRegister(kReg2022_6_tx_chan_enable + baseAddr,0x01); // enables channel
1120  }
1121 
1122  return true;
1123 }
1124 
1125 bool CNTV2Config2022::GetTxChannelEnable(const NTV2Channel channel, bool & enabled)
1126 {
1127  uint32_t baseAddr;
1128  uint32_t val;
1129  bool rv;
1130 
1131  enabled = false;
1132 
1133  rv = SelectTxChannel(channel, SFP_1, baseAddr);
1134  if (!rv) return false;
1135 
1137  if (val == 0x01)
1138  {
1139  enabled = true;
1140  }
1141 
1142  return true;
1143 }
1144 
1145 bool CNTV2Config2022::Set2022_7_Mode(bool enable, uint32_t rx_networkPathDifferential)
1146 {
1147  if (!mDevice.IsMBSystemReady())
1148  {
1150  return false;
1151  }
1152 
1153  if (!_is2022_7)
1154  {
1156  return false;
1157  }
1158 
1159  bool old_enable = false;
1160  uint32_t unused = 0;
1161  Get2022_7_Mode(old_enable, unused);
1162 
1163  bool enableChange = (old_enable != enable);
1164 
1165  SetDualLinkMode(enable);
1166 
1167  if (_numRxChans)
1168  {
1169  uint32_t baseAddr;
1170  SelectRxChannel(NTV2_CHANNEL1, SFP_1, baseAddr);
1171  if (enableChange)
1172  {
1173  // reset
1174  WriteChannelRegister(kReg2022_6_rx_reset + baseAddr, 0x01);
1175  WriteChannelRegister(kReg2022_6_rx_reset + baseAddr, 0x00);
1176  }
1177  if (enable)
1178  {
1179  uint32_t delay = rx_networkPathDifferential * 27000;
1180  // network path differential in 27MHz clocks
1182  }
1183  else
1184  {
1186  }
1187  }
1188 
1189  if (_numTxChans && enableChange)
1190  {
1191  // save
1192  uint32_t addr;
1194 
1195  // reset the tx core
1196  uint32_t baseAddr;
1197  SelectTxChannel(NTV2_CHANNEL1, SFP_1, baseAddr);
1198  WriteChannelRegister(kReg2022_6_tx_reset + baseAddr, 0x01);
1199  WriteChannelRegister(kReg2022_6_tx_reset + baseAddr, 0x00);
1200 
1201  // restore everything
1202  uint32_t macLo;
1203  uint32_t macHi;
1204 
1205  // get primaray mac address
1206  uint32_t macAddressRegister = SAREK_REGS + kRegSarekMAC;
1207  mDevice.ReadRegister(macAddressRegister, macHi);
1208  macAddressRegister++;
1209  mDevice.ReadRegister(macAddressRegister, macLo);
1210 
1211  uint32_t boardHi = (macHi & 0xffff0000) >>16;
1212  uint32_t boardLo = ((macHi & 0x0000ffff) << 16) + ((macLo & 0xffff0000) >> 16);
1213 
1214  // get sfp2 mac address
1215  macAddressRegister++;
1216  mDevice.ReadRegister(macAddressRegister, macHi);
1217  macAddressRegister++;
1218  mDevice.ReadRegister(macAddressRegister, macLo);
1219 
1220  uint32_t boardHi2 = (macHi & 0xffff0000) >>16;
1221  uint32_t boardLo2 = ((macHi & 0x0000ffff) << 16) + ((macLo & 0xffff0000) >> 16);
1222 
1223  // initialise constants
1226 
1227  // source ip address
1229 
1232 
1235  }
1236 
1237  return true;
1238 }
1239 
1240 bool CNTV2Config2022::Get2022_7_Mode(bool & enable, uint32_t & rx_networkPathDifferential)
1241 {
1242  enable = false;
1243  rx_networkPathDifferential = 0;
1244 
1245  if (!_is2022_7)
1246  {
1248  return false;
1249  }
1250 
1251  GetDualLinkMode(enable);
1252 
1253  if (_numRxChans)
1254  {
1255  // network path differential in ms
1256  uint32_t val;
1257  uint32_t baseAddr;
1258  SelectRxChannel(NTV2_CHANNEL1, SFP_1, baseAddr);
1260  rx_networkPathDifferential = val/27000;
1261  }
1262  return true;
1263 }
1264 
1265 bool CNTV2Config2022::SetIGMPDisable(eSFP sfp, bool disable)
1266 {
1267  uint32_t val = (disable) ? 1 : 0;
1268  if (sfp == SFP_1)
1269  {
1271  }
1272  else
1273  {
1275  }
1276  return true;
1277 }
1278 
1279 bool CNTV2Config2022::GetIGMPDisable(eSFP sfp, bool & disabled)
1280 {
1281  uint32_t val;
1282  if (sfp == SFP_1)
1283  {
1285  }
1286  else
1287  {
1289  }
1290 
1291  disabled = (val == 1) ? true : false;
1292 
1293  return true;
1294 }
1295 
1297 {
1298  uint32_t mbversion;
1299  switch (version)
1300  {
1301  case eIGMPVersion_2:
1302  mbversion = 2;
1303  break;
1304  case eIGMPVersion_3:
1305  mbversion = 3;
1306  break;
1307  default:
1309  return false;
1310  }
1311  return CNTV2MBController::SetIGMPVersion(mbversion);
1312 }
1313 
1315 {
1316  uint32_t version32;
1317  bool rv = mDevice.ReadRegister(SAREK_REGS + kRegSarekIGMPVersion, version32);
1318  version = (version32 == 2) ? eIGMPVersion_2 : eIGMPVersion_3;
1319  return rv;
1320 }
1321 
1323 {
1324  if (_is2022_2)
1325  {
1326  CNTV2ConfigTs2022 tsConfig(mDevice);
1327  bool rv = tsConfig.SetupJ2KEncoder(channel, j2kConfig);
1328  mIpErrorCode = tsConfig.getLastErrorCode();
1329  return rv;
1330  }
1331  return false;
1332 }
1333 
1335 {
1336  if (_is2022_2)
1337  {
1338  CNTV2ConfigTs2022 tsConfig(mDevice);
1339  bool rv = tsConfig.ReadbackJ2KEncoder(channel, j2kConfig);
1340  mIpErrorCode = tsConfig.getLastErrorCode();
1341  return rv;
1342  }
1343  return false;
1344 }
1345 
1347 {
1348  if (_is2022_2)
1349  {
1351  CNTV2ConfigTs2022 tsConfig(mDevice);
1352  bool rv = tsConfig.SetupJ2KDecoder(j2kConfig);
1353  mIpErrorCode = tsConfig.getLastErrorCode();
1354  return rv;
1355  }
1356  return false;
1357 }
1358 
1360 {
1361  if (_is2022_2)
1362  {
1363  CNTV2ConfigTs2022 tsConfig(mDevice);
1364  bool rv = tsConfig.ReadbackJ2KDecoder(j2kConfig);
1365  mIpErrorCode = tsConfig.getLastErrorCode();
1366  return rv;
1367  }
1368  return false;
1369 }
1370 
1372 {
1373  if (_is2022_2)
1374  {
1375  CNTV2ConfigTs2022 tsConfig(mDevice);
1376  bool rv = tsConfig.GetJ2KDecoderStatus(j2kStatus);
1377  return rv;
1378  }
1379  return false;
1380 }
1381 
1382 
1384 //
1385 //
1386 //
1388 
1389 eSFP CNTV2Config2022::GetTxLink(NTV2Channel chan)
1390 {
1391  if (!_is_txTop34)
1392  {
1393  if ((uint32_t)chan >= _numTx0Chans)
1394  {
1395  return SFP_2;
1396  }
1397  else
1398  {
1399  return SFP_1;
1400  }
1401  }
1402  else
1403  {
1404  if ((uint32_t)chan >= _numTx0Chans)
1405  {
1406  return SFP_1;
1407  }
1408  else
1409  {
1410  return SFP_2;
1411  }
1412  }
1413 }
1414 
1415 
1416 bool CNTV2Config2022::SelectRxChannel(NTV2Channel channel, eSFP sfp, uint32_t & baseAddr)
1417 {
1418  uint32_t iChannel = (uint32_t) channel;
1419  uint32_t channelIndex = iChannel;
1420 
1421  if (iChannel > _numRxChans)
1422  return false;
1423 
1424  if (_is2022_6)
1425  {
1426  if (iChannel >= _numRx0Chans)
1427  {
1428  channelIndex = iChannel - _numRx0Chans;
1429  baseAddr = SAREK_2022_6_RX_CORE_1;
1430  }
1431  else
1432  {
1433  channelIndex = iChannel;
1434  baseAddr = SAREK_2022_6_RX_CORE_0;
1435  }
1436  }
1437  else
1438  {
1439  if (iChannel >= _numRx0Chans)
1440  {
1441  channelIndex = iChannel - _numRx0Chans;
1442  baseAddr = SAREK_2022_2_RX_CORE_1;
1443  }
1444  else
1445  {
1446  channelIndex = iChannel;
1447  baseAddr = SAREK_2022_2_RX_CORE_0;
1448  }
1449  }
1450 
1451  if (sfp == SFP_2)
1452  channelIndex |= 0x80000000;
1453 
1454  // select channel
1455  SetChannel(kReg2022_6_rx_channel_access + baseAddr, channelIndex);
1456 
1457  return true;
1458 }
1459 
1460 bool CNTV2Config2022::SelectTxChannel(NTV2Channel channel, eSFP sfp, uint32_t & baseAddr)
1461 {
1462  uint32_t iChannel = (uint32_t) channel;
1463  uint32_t channelIndex = iChannel;
1464 
1465  if (iChannel > _numTxChans)
1466  return false;
1467 
1468  if (_is2022_6)
1469  {
1470  if (iChannel >= _numTx0Chans)
1471  {
1472  channelIndex = iChannel - _numTx0Chans;
1473  baseAddr = SAREK_2022_6_TX_CORE_1;
1474  }
1475  else
1476  {
1477  channelIndex = iChannel;
1478  baseAddr = SAREK_2022_6_TX_CORE_0;
1479  }
1480  }
1481  else
1482  {
1483  if (iChannel >= _numTx0Chans)
1484  {
1485  channelIndex = iChannel - _numTx0Chans;
1486  baseAddr = SAREK_2022_2_TX_CORE_1;
1487  }
1488  else
1489  {
1490  channelIndex = iChannel;
1491  baseAddr = SAREK_2022_2_TX_CORE_0;
1492  }
1493  }
1494 
1495  if (sfp == SFP_2)
1496  channelIndex |= 0x80000000;
1497 
1498  // select channel
1499  SetChannel(kReg2022_6_tx_channel_access + baseAddr, channelIndex);
1500 
1501  return true;
1502 }
1503 
1505 {
1507 }
1508 
1510 {
1511  NTV2IpError error = mIpErrorCode;
1513  return error;
1514 }
1515 
1516 void CNTV2Config2022::ChannelSemaphoreSet(uint32_t controlReg, uint32_t baseAddr)
1517 {
1518  uint32_t val;
1519  ReadChannelRegister(controlReg + baseAddr, &val);
1520  WriteChannelRegister(controlReg + baseAddr, val | VOIP_SEMAPHORE_SET);
1521 }
1522 
1523 void CNTV2Config2022::ChannelSemaphoreClear(uint32_t controlReg, uint32_t baseAddr)
1524 {
1525  uint32_t val;
1526  ReadChannelRegister(controlReg + baseAddr, &val);
1527  WriteChannelRegister(controlReg + baseAddr, val & VOIP_SEMAPHORE_CLEAR);
1528 }
1529 
1530 
1531 bool CNTV2Config2022::GetMACAddress(eSFP sfp, NTV2Stream stream, string remoteIP, uint32_t & hi, uint32_t & lo)
1532 {
1533  uint32_t destIp = AJANetwork::aja_inet_addr(remoteIP.c_str());
1534  destIp = NTV2EndianSwap32(destIp);
1535 
1536  uint32_t mac;
1537  MACAddr macaddr;
1538 
1539  // is remote address muticast?
1540  uint8_t ip0 = (destIp & 0xff000000)>> 24;
1541  if (ip0 >= 224 && ip0 <= 239)
1542  {
1543  // multicast - generate MAC
1544  mac = destIp & 0x7fffff; // lower 23 bits
1545 
1546  macaddr.mac[0] = 0x01;
1547  macaddr.mac[1] = 0x00;
1548  macaddr.mac[2] = 0x5e;
1549  macaddr.mac[3] = mac >> 16;
1550  macaddr.mac[4] = (mac & 0xffff) >> 8;
1551  macaddr.mac[5] = mac & 0xff;
1552  }
1553  else
1554  {
1555  // unicast - get MAC from ARP
1556  string macAddr;
1557  bool rv;
1558  // is destination on the same subnet?
1559  IPVNetConfig nc;
1560  GetNetworkConfiguration(sfp, nc);
1561  if ( (destIp & nc.ipc_subnet) != (nc.ipc_ip & nc.ipc_subnet))
1562  {
1563  struct in_addr addr;
1564  addr.s_addr = NTV2EndianSwap32(nc.ipc_gateway);
1565  string gateIp = AJANetwork::aja_inet_ntoa(addr);
1566  rv = GetRemoteMAC(gateIp, sfp, stream, macAddr);
1567  }
1568  else
1569  {
1570  rv = GetRemoteMAC(remoteIP, sfp, stream, macAddr);
1571  }
1572  if (!rv)
1573  {
1574  SetTxChannelEnable(VideoStreamToChannel(stream), false); // stop transmit
1576  return false;
1577  }
1578 
1579  istringstream ss(macAddr);
1580  string token;
1581  int i=0;
1582  while (i < 6)
1583  {
1584  getline (ss, token, ':');
1585  macaddr.mac[i++] = (uint8_t)strtoul(token.c_str(),NULL,16);
1586  }
1587  }
1588 
1589  return MacAddressToRegisters( macaddr, hi, lo );
1590 }
1591 
1593 {
1594  return GetSFPInfo(sfp, data);
1595 }
1596 
1598 {
1599  uint32_t val;
1601  uint32_t val2;
1603 
1604  if (sfp == SFP_2)
1605  {
1606  sfpStatus.SFP_linkUp = (val & LINK_B_UP) ? true : false;
1607  sfpStatus.SFP_present = (val2 & SFP_2_NOT_PRESENT) ? false : true;
1608  sfpStatus.SFP_rxLoss = (val2 & SFP_2_RX_LOS) ? true : false;
1609  sfpStatus.SFP_txFault = (val2 & SFP_2_TX_FAULT) ? true : false;
1610  }
1611  else
1612  {
1613  sfpStatus.SFP_linkUp = (val & LINK_A_UP) ? true : false;
1614  sfpStatus.SFP_present = (val2 & SFP_1_NOT_PRESENT) ? false : true;
1615  sfpStatus.SFP_rxLoss = (val2 & SFP_1_RX_LOS) ? true : false;
1616  sfpStatus.SFP_txFault = (val2 & SFP_1_TX_FAULT) ? true : false;
1617  }
1618 
1619  return true;
1620 }
1621 
1623 {
1624  uint32_t addr;
1625 
1626  SelectRxChannel(channel, SFP_2, addr);
1629 
1630  SelectRxChannel(channel, SFP_1, addr);
1633 
1634  return true;
1635 }
1636 
1637 bool CNTV2Config2022::SetIPServicesControl(const bool enable, const bool forceReconfig)
1638 {
1639  uint32_t val = 0;
1640  if (enable)
1641  val |= BIT(0);
1642 
1643  if (forceReconfig)
1644  val |= BIT(0);
1645 
1647 
1648  return true;
1649 }
1650 
1651 bool CNTV2Config2022::GetIPServicesControl(bool & enable, bool & forceReconfig)
1652 {
1653  uint32_t val;
1655 
1656  if (val & BIT(0))
1657  enable = true;
1658  else
1659  enable = false;
1660 
1661  if (val & BIT(1))
1662  forceReconfig = true;
1663  else
1664  forceReconfig = false;
1665 
1666  return true;
1667 }
1668 
1669 NTV2Stream CNTV2Config2022::VideoChannelToStream(const NTV2Channel channel)
1670 {
1671  NTV2Stream stream;
1672  switch (channel)
1673  {
1674  case NTV2_CHANNEL1: stream = NTV2_VIDEO1_STREAM; break;
1675  case NTV2_CHANNEL2: stream = NTV2_VIDEO2_STREAM; break;
1676  case NTV2_CHANNEL3: stream = NTV2_VIDEO3_STREAM; break;
1677  case NTV2_CHANNEL4: stream = NTV2_VIDEO4_STREAM; break;
1678  default: stream = NTV2_STREAM_INVALID; break;
1679  }
1680  return stream;
1681 }
1682 
1683 NTV2Channel CNTV2Config2022::VideoStreamToChannel(const NTV2Stream stream)
1684 {
1685  NTV2Channel channel;
1686  switch (stream)
1687  {
1688  case NTV2_VIDEO1_STREAM: channel = NTV2_CHANNEL1; break;
1689  case NTV2_VIDEO2_STREAM: channel = NTV2_CHANNEL2; break;
1690  case NTV2_VIDEO3_STREAM: channel = NTV2_CHANNEL3; break;
1691  case NTV2_VIDEO4_STREAM: channel = NTV2_CHANNEL4; break;
1692  default: channel = NTV2_CHANNEL_INVALID; break;
1693  }
1694  return channel;
1695 }
uint32_t pcrPid
Specifies the PID for the PCR.
#define kReg2022_6_tx_reset
bool SetNetworkConfiguration(const eSFP sfp, const IPVNetConfig &netConfig)
#define SFP_1_RX_LOS
#define kReg2022_6_rx_media_buf_base_addr
#define kReg2022_6_tx_link_enable
uint32_t audioChannels
Specifies the number of audio channels for J2K encode, a value of 0 indicates no audio.
#define kRegPll_SrcPort
uint32_t pmtPid
Specifies the PID for the PMT.
std::string NTV2IpErrorEnumToString(const NTV2IpError inIpErrorEnumValue)
Definition: ntv2utils.cpp:7512
#define RX_MATCH_2022_DEST_PORT
uint16_t sfp2Vlan
Specifies the VLAN TCI (if RX_MATCH_2022_VLAN set)
uint32_t ssrc
Specifies the SSRC identifier (if RX_MATCH_2022_SSRC set)
#define PLL_MATCH_SOURCE_PORT
bool GetJ2KDecoderStatus(j2kDecoderStatus &status)
#define kReg2022_6_tx_udp_src_port
bool GetRxMatch(NTV2Channel channel, eSFP link, uint8_t &match)
bool SetJ2KDecoderConfiguration(const j2kDecoderConfig &j2kConfig)
#define NULL
#define kSarekRegIGMPDisable2
#define SAREK_2022_2_RX_CORE_0
std::string sfp1RemoteIP
Specifies remote (destination) IP address.
#define SFP_2_TX_FAULT
#define kRegPll_DstIp
CNTV2Card & mDevice
Definition: ntv2mailbox.h:79
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
#define BIT(_x_)
Definition: ajatypes.h:578
#define kReg2022_6_rx_match_dest_ip_addr
#define SAREK_2022_2_TX_CORE_0
#define kReg2022_6_tx_channel_access
Obtain audio samples from the device AES inputs, if available.
Definition: ntv2enums.h:2008
bool GetIGMPDisable(eSFP sfp, bool &disabled)
bool Set2022_7_Mode(bool enable, uint32_t rx_networkPathDifferential)
NTV2IpError getLastErrorCode()
bool GetTxChannelConfiguration(const NTV2Channel channel, tx_2022_channel &txConfig)
uint32_t playoutDelay
Specifies the wait time in milliseconds to SDI playout from incoming packet (0-150).
#define SAREK_RX0_MASK
#define kReg2022_6_rx_match_dest_port
#define PLL_MATCH_DEST_PORT
#define SAREK_TX_TOP34
#define LINK_B_UP
#define kRegPll_Match
#define kReg2022_6_rx_match_sel
std::string sfp1SourceIP
Specifies the source (sender) IP address (if RX_MATCH_2022_SOURCE_IP set). If it&#39;s in the multiclass ...
uint32_t sfp2RemotePort
Specifies the remote (destination) port number.
#define kReg2022_6_rx_match_vlan
#define SAREK_2022_6_TX_CORE_0
bool SetIGMPVersion(eIGMPVersion_t version)
#define SAREK_REGS
#define kReg2022_6_tx_udp_dest_port
uint32_t sfp1RemotePort
Specifies the remote (destination) port number.
uint16_t sfp1Vlan
Specifies the VLAN TCI (if RX_MATCH_2022_VLAN set)
bool GetSFPInfo(eSFP port, SFPMSAData &sfpdata)
#define kSarekRegIGMPDisable
#define SFP_1_NOT_PRESENT
#define kRegSarekGATE0
Defines a number of handy byte-swapping macros.
uint32_t ullMode
Specifies the ull mode for J2K encode.
#define kReg2022_6_tx_sec_mac_low_addr
#define kReg2022_6_tx_dest_mac_hi_addr
bool WriteChannelRegister(ULWord reg, ULWord value, ULWord mask=0xFFFFFFFF, ULWord shift=0x0)
bool SetTxChannelEnable(const NTV2Channel channel, bool enable)
Definition: json.hpp:5362
#define kReg2022_6_tx_sys_mem_conf
NTV2Channel
These enum values are mostly used to identify a specific widget_framestore. They&#39;re also commonly use...
Definition: ntv2enums.h:1357
bool SetupJ2KEncoder(const NTV2Channel channel, const j2kEncoderConfig &config)
#define kReg2022_6_rx_control
bool GetLinkStatus(eSFP sfp, SFPStatus &sfpStatus)
bool GetNetworkConfiguration(const eSFP sfp, IPVNetConfig &netConfig)
bool GetSFPActive(eSFP sfp)
#define kReg2022_6_tx_pri_mac_low_addr
#define kReg2022_6_rx_match_ssrc
uint32_t audio1Pid
Specifies the PID for audio 1.
#define kReg2022_6_tx_video_para_config
#define kRegSarekLinkStatus
NTV2IpError getLastErrorCode()
bool SetJ2KEncoderConfiguration(const NTV2Channel channel, const j2kEncoderConfig &j2kConfig)
void EnableIGMPGroup(eSFP port, NTV2Stream stream, bool enable)
#define kReg2022_6_rx_link_valid_media_pkt_cnt
#define kReg2022_6_rx_media_pkt_buf_size
Configures a SMPTE 2022 Receive Channel.
virtual bool SetAudioSystemInputSource(const NTV2AudioSystem inAudioSystem, const NTV2AudioSource inAudioSource, const NTV2EmbeddedAudioInput inEmbeddedInput)
Sets the audio source for the given NTV2AudioSystem on the device.
Definition: ntv2audio.cpp:485
#define kReg2022_2_tx_ts_config
bool SetTxChannelConfiguration(const NTV2Channel channel, const tx_2022_channel &txConfig)
#define PLL_MATCH_DEST_IP
bool ReadbackJ2KEncoder(const NTV2Channel channel, j2kEncoderConfig &config)
bool GetJ2KDecoderConfiguration(j2kDecoderConfig &j2kConfig)
NTV2VideoFormat videoFormat
Specifies the video format for J2K encode.
#define kReg2022_6_tx_sec_mac_hi_addr
#define kReg2022_6_tx_ssrc
std::string sfp1DestIP
Specifies the destination (target) IP address (if RX_MATCH_2022_DEST_IP set)
virtual bool SetSDITransmitEnable(const NTV2Channel inChannel, const bool inEnable)
Sets the specified bidirectional SDI connector to act as an input or an output.
bool SetIPServicesControl(const bool enable, const bool forceReconfig)
std::string sfp2RemoteIP
Specifies remote (destination) IP address.
eIGMPVersion_t
uint32_t sfp1LocalPort
Specifies the local (source) port number.
#define kRegSarekGATE1
bool GetSFPMSAData(eSFP sfp, SFPMSAData &data)
#define kReg2022_6_tx_control
void SetIGMPGroup(eSFP port, NTV2Stream stream, uint32_t mcast_addr, uint32_t src_addr, bool enable)
#define kReg2022_6_tx_pri_mac_hi_addr
#define VOIP_SEMAPHORE_CLEAR
#define kReg2022_6_rx_chan_enable
#define kReg2022_6_rx_channel_access
uint32_t sfp1DestPort
Specifies the destination (target) port number (if RX_MATCH_2022_DEST_PORT set)
The CNTV2ConfigTs2022 class is the interface to Kona-IP SMPTE 2022 J2K encoder and TS chips...
bool DisableNetworkInterface(const eSFP sfp)
#define kReg2022_6_rx_network_path_differential
#define kRegSarekNET1
Declares the CNTV2Config2022 class.
bool ReadbackJ2KDecoder(j2kDecoderConfig &config)
#define kRegPll_SrcIp
uint32_t sfp2LocalPort
Specifies the local (source) port number.
Configures a SMPTE 2022 Transmit Channel.
bool SetRxLinkState(NTV2Channel channel, bool sfp1Enable, bool sfp2Enable)
#define kReg2022_6_rx_reset
Specifies channel or FrameStore 2 (or the 2nd item).
Definition: ntv2enums.h:1360
virtual NTV2DeviceID GetDeviceID(void)
#define SAREK_2022_6
bool GetTxLinkState(NTV2Channel channel, bool &sfp1Enable, bool &sfp2Enable)
bool GetRxChannelEnable(const NTV2Channel channel, bool &enabled)
#define kReg2022_6_tx_chan_enable
#define kReg2022_6_tx_ip_header
#define SAREK_2022_6_RX_CORE_1
CNTV2Config2022(CNTV2Card &device)
#define kRegSarekSFPStatus
Declares the CNTV2ConfigTs2022 class.
bool SetIGMPVersion(uint32_t version)
uint8_t sfp1RxMatch
Bitmap of rxMatch criteria used.
#define kReg2022_6_tx_hitless_config
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...
#define SAREK_2022_6_RX_CORE_0
#define LINK_A_UP
uint32_t ipc_subnet
J2KChromaSubSampling chromaSubsamp
Specifies the chroma sub sampling for J2K encode.
#define kReg2022_6_rx_match_src_ip_addr
#define SAREK_2022_2_TX_CORE_1
bool GetMACAddress(eSFP sfp, NTV2Stream stream, std::string remoteIP, uint32_t &hi, uint32_t &lo)
bool operator==(const tx_2022_channel &other)
bool GetIGMPVersion(eIGMPVersion_t &version)
uint32_t mbps
Specifies the mbits per-second for J2K encode.
#define SAREK_2022_2
bool GetJ2KEncoderConfiguration(const NTV2Channel channel, j2kEncoderConfig &j2kConfig)
#define kReg2022_6_rx_chan_timeout
bool SetRxChannelEnable(const NTV2Channel channel, bool enable)
void UnsetIGMPGroup(eSFP port, NTV2Stream stream)
bool SetRxMatch(NTV2Channel channel, eSFP link, uint8_t match)
std::string getLastError()
eProgSelMode_t selectionMode
This identifies the first Audio System.
Definition: ntv2enums.h:3897
std::string sfp2DestIP
Specifies the destination (target) IP address (if RX_MATCH_2022_DEST_IP set)
bool SetTxLinkState(NTV2Channel channel, bool sfp1Enable, bool sfp2Enable)
Declares numerous NTV2 utility functions.
bool SetMBNetworkConfiguration(eSFP port, std::string ipaddr, std::string netmask, std::string gateway)
#define SAREK_2022_7
uint8_t sfp2RxMatch
Bitmap of rxMatch criteria used.
uint32_t sfp2SourcePort
Specifies the source (sender) port number (if RX_MATCH_2022_SOURCE_PORT set)
bool SetupJ2KDecoder(const j2kDecoderConfig &config)
bool GetRemoteMAC(std::string remote_IPAddress, eSFP port, NTV2Stream stream, std::string &MACaddress)
#define SAREK_TX0_MASK
#define SAREK_2022_2_RX_CORE_1
virtual bool WriteRegister(const ULWord inRegNum, const ULWord inValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0)
Updates or replaces all or part of the 32-bit contents of a specific register (real or virtual) on th...
#define kReg2022_6_tx_dest_mac_low_addr
uint8_t mac[6]
Specifies channel or FrameStore 1 (or the first item).
Definition: ntv2enums.h:1359
uint32_t bitDepth
Specifies the bit depth for J2K encode.
bool operator==(const rx_2022_channel &other)
See Io IP.
Definition: ntv2enums.h:40
#define SFP_2_NOT_PRESENT
bool SetIGMPDisable(eSFP sfp, bool disable)
Disables the automatic (default) joining of multicast groups using IGMP, based on remote IP address f...
#define kRegSarekMAC
NTV2Stream
Identifies a specific IP-based data stream.
Definition: ntv2enums.h:1407
#define SAREK_TX1_MASK
#define RX_MATCH_2022_SOURCE_IP
Declares the CNTV2Card class.
#define kReg2022_6_rx_playout_delay
#define kRegPll_DstPort
uint32_t getFeatures()
bool Get2022ChannelRxStatus(NTV2Channel channel, s2022RxChannelStatus &status)
bool SetDualLinkMode(bool enable)
Specifies channel or FrameStore 4 (or the 4th item).
Definition: ntv2enums.h:1362
#define PLL_MATCH_SOURCE_IP
#define VOIP_SEMAPHORE_SET
bool GetJ2KDecoderStatus(j2kDecoderStatus &j2kStatus)
bool operator==(const j2kDecoderConfig &other)
bool operator!=(const j2kDecoderConfig &other)
uint32_t sfp2DestPort
Specifies the destination (target) port number (if RX_MATCH_2022_DEST_PORT set)
virtual bool IsMBSystemValid(void)
std::string sfp2SourceIP
Specifies the source (sender) IP address (if RX_MATCH_2022_SOURCE_IP set). If it&#39;s in the multiclass ...
bool GetIPServicesControl(bool &enable, bool &forceReconfig)
uint32_t programNumber
bool GetRxLinkState(NTV2Channel channel, bool &sfp1Enable, bool &sfp2Enable)
#define kReg2022_6_rx_match_src_port
#define SAREK_PLL
#define kRegSarekIGMPVersion
J2KStreamType streamType
Specifies the stream type for J2K encode.
uint32_t videoPid
Specifies the PID for the video.
uint32_t sfp1SourcePort
Specifies the source (sender) port number (if RX_MATCH_2022_SOURCE_PORT set)
#define PLL_CONFIG_PCR
bool Get2022_7_Mode(bool &enable, uint32_t &rx_networkPathDifferential)
virtual bool IsMBSystemReady(void)
bool DisableNetworkInterface(eSFP port)
#define kRegSarekIP1
bool SetRxChannelConfiguration(const NTV2Channel channel, const rx_2022_channel &rxConfig)
#define kRegSarekIP0
#define kRegSarekNET0
NTV2IpError
Definition: ntv2enums.h:4313
bool GetDualLinkMode(bool &enable)
bool operator!=(const tx_2022_channel &other)
#define SFP_2_RX_LOS
#define kReg2022_6_tx_src_ip_addr
bool GetRxChannelConfiguration(const NTV2Channel channel, rx_2022_channel &rxConfig)
bool GetTxChannelEnable(const NTV2Channel channel, bool &enabled)
bool operator!=(const rx_2022_channel &other)
#define SFP_1_TX_FAULT
bool ReadChannelRegister(const ULWord inReg, ULWord &outValue, const ULWord inMask=0xFFFFFFFF, const ULWord inShift=0x0)
#define PLL_MATCH_ES_PID
#define NTV2EndianSwap32(__val__)
Definition: ntv2endian.h:19
#define SAREK_2022_6_TX_CORE_1
#define SAREK_RX1_MASK
#define kReg2022_6_rx_sec_recv_pkt_cnt
uint32_t ipc_gateway
Specifies channel or FrameStore 3 (or the 3rd item).
Definition: ntv2enums.h:1361
#define RX_MATCH_2022_DEST_IP
bool operator==(const j2kEncoderConfig &other)
#define kReg2022_6_tx_dest_ip_addr
#define kRegSarekServices
#define RX_MATCH_2022_SOURCE_PORT
NTV2IpError mIpErrorCode
Definition: ntv2mailbox.h:81
#define kRegPll_Config
bool operator!=(const j2kEncoderConfig &other)
static bool MacAddressToRegisters(const MACAddr &macaddr, uint32_t &hi, uint32_t &lo)
void SetChannel(ULWord channelOffset, ULWord channelNumber)
#define kReg2022_6_rx_pri_recv_pkt_cnt