From 6b21b37aef88cedeac3761ac3d69c854edfc9ec9 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 13 Aug 2019 21:40:22 -0600 Subject: [PATCH] First attempt to address HDCP setting on input cards/TXs on DmChassisControllerBridge --- .../Bridges/DmChassisControllerBridge.cs | 182 ++++++++++++++++-- .../Bridges/DmTxControllerBridge.cs | 2 +- 2 files changed, 162 insertions(+), 22 deletions(-) diff --git a/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs b/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs index f643dfab..08de8eee 100644 --- a/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmChassisControllerBridge.cs @@ -5,6 +5,8 @@ using System.Text; using Crestron.SimplSharp; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; using PepperDash.Core; using PepperDash.Essentials.Core; @@ -38,26 +40,96 @@ namespace PepperDash.Essentials.Bridges if (dmChassis.TxDictionary.ContainsKey(ioSlot)) { Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); - var TxKey = dmChassis.TxDictionary[ioSlot]; - var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase; + var txKey = dmChassis.TxDictionary[ioSlot]; + var txDevice = DeviceManager.GetDeviceForKey(txKey) as DmTxControllerBase; if (dmChassis.Chassis is DmMd8x8Cpu3 || dmChassis.Chassis is DmMd8x8Cpu3rps || dmChassis.Chassis is DmMd16x16Cpu3 || dmChassis.Chassis is DmMd16x16Cpu3rps || dmChassis.Chassis is DmMd32x32Cpu3 || dmChassis.Chassis is DmMd32x32Cpu3rps) { dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); } - else if (TxDevice != null) + else { - TxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + if (txDevice != null) + { + txDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + } + } + + if (txDevice != null) + { + bool hdcpTypeSimple; + + if (txDevice.Hardware is DmTx4kX02CBase || txDevice.Hardware is DmTx4kzX02CBase) + hdcpTypeSimple = false; + else + hdcpTypeSimple = true; + + txDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); + //TxDevice.SetPortHdcpCapability((eHdcpCapabilityType)(u),)); + + trilist.UShortInput[joinMap.HdcpSupportCapability + ioSlot].UShortValue = (ushort)txDevice.HdcpSupportCapability; + + if (txDevice is ITxRouting) + { + var txR = txDevice as ITxRouting; + + trilist.BooleanInput[joinMap.TxHdcpSupportTypeSimple + ioSlot].BoolValue = hdcpTypeSimple; + + if (hdcpTypeSimple) + { + + if (txR.InputPorts[DmPortName.HdmiIn] != null) + { + var inputPort = txR.InputPorts[DmPortName.HdmiIn]; + + if (txDevice.Feedbacks["HdmiInHdcpCapability"] != null) + (txDevice.Feedbacks["HdmiInHdcpCapability"] as IntFeedback).LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportState + ioSlot]); + + if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null) + { + var port = inputPort.Port as EndpointHdmiInput; + + SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.HdcpSupportState + ioSlot, trilist); + } + } + } + } + } + else + { + var inputPort = dmChassis.InputPorts[string.Format("inputCard{0}--hdmiIn", ioSlot)]; + if(inputPort != null) + { + var hdmiInPort = inputPort.Port; + + if (hdmiInPort != null) + { + if (hdmiInPort is HdmiInputWithCEC) + { + var hdmiInPortWCec = hdmiInPort as HdmiInputWithCEC; + + if (hdmiInPortWCec.HdcpSupportedLevel != eHdcpSupportedLevel.Unknown) + SetHdcpCapabilityAction(true, hdmiInPortWCec, joinMap.HdcpSupportState + ioSlot, trilist); + + //TODO: Figure out how the heck to get feedback properly. + } + + } + } + } - // TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); - // trilist.SetUShortSigAction((ApiMap.HdcpSupport[ioSlot]), u => TxDevice.SetHdcpSupportAll((ePdtHdcpSupport)(u))); - // TxDevice.HdcpSupportAllFeedback.LinkInputSig(trilist.UShortInput[joinMap. + ioSlot]); - // trilist.UShortInput[ApiMap.HdcpSupportCapability[ioSlot]].UShortValue = TxDevice.HdcpSupportCapability; } else { - // dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[ApiMap.TxVideoSyncStatus[ioSlot]]); + dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); + + var inputPort = dmChassis.InputPorts[string.Format("inputCard{0}-hdmiIn", ioSlot)].Port as EndpointHdmiInput; + + if (inputPort != null) + { + //trilist.SetUShortSigAction((joinMap.HdcpSupport + ioSlot), u => + } } if (dmChassis.RxDictionary.ContainsKey(ioSlot)) { @@ -88,39 +160,107 @@ namespace PepperDash.Essentials.Bridges } } + static void SetHdcpCapabilityAction(bool hdcpTypeSimple, HdmiInputWithCEC port, uint join, BasicTriList trilist) + { + if (hdcpTypeSimple) + { + trilist.SetUShortSigAction(join, + new Action(s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + })); + } + else + { + trilist.SetUShortSigAction(join, + new Action(s => + { + port.HdcpReceiveCapability = (eHdcpCapabilityType)s; + })); + } + } + + static void SetHdcpCapabilityAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist) + { + if (hdcpTypeSimple) + { + trilist.SetUShortSigAction(join, + new Action(s => + { + if (s == 0) + { + port.HdcpSupportOff(); + } + else if (s > 0) + { + port.HdcpSupportOn(); + } + })); + } + else + { + trilist.SetUShortSigAction(join, + new Action(s => + { + port.HdcpCapability = (eHdcpCapabilityType)s; + })); + } + } public class DmChassisControllerJoinMap : JoinMapBase { + //Digital public uint IsOnline { get; set; } + public uint VideoSyncStatus { get; set; } + public uint InputEndpointOnline { get; set; } + public uint OutputEndpointOnline { get; set; } + public uint TxHdcpSupportTypeSimple { get; set; } + + //Analog public uint OutputVideo { get; set; } public uint OutputAudio { get; set; } - public uint VideoSyncStatus { get; set; } + public uint HdcpSupportState { get; set; } + public uint HdcpSupportCapability { get; set; } + + //SErial public uint InputNames { get; set; } public uint OutputNames { get; set; } public uint OutputCurrentVideoInputNames { get; set; } public uint OutputCurrentAudioInputNames { get; set; } public uint InputCurrentResolution { get; set; } - public uint InputEndpointOnline { get; set; } - public uint OutputEndpointOnline { get; set; } - //public uint HdcpSupport { get; set; } - //public uint HdcpSupportCapability { get; set; } + public DmChassisControllerJoinMap() { + //Digital IsOnline = 11; + VideoSyncStatus = 100; //101-299 + InputEndpointOnline = 500; //501-699 + OutputEndpointOnline = 700; //701-899 + TxHdcpSupportTypeSimple = 1000; //1001-1199 + + //Analog OutputVideo = 100; //101-299 OutputAudio = 300; //301-499 - VideoSyncStatus = 100; //101-299 + HdcpSupportState = 1000; //1001-1199 + HdcpSupportCapability = 1200; //1201-1399 + + + //Serial InputNames = 100; //101-299 OutputNames = 300; //301-499 OutputCurrentVideoInputNames = 2000; //2001-2199 OutputCurrentAudioInputNames = 2200; //2201-2399 InputCurrentResolution = 2400; // 2401-2599 - InputEndpointOnline = 500; - OutputEndpointOnline = 700; - //HdcpSupport = 1000; //1001-1199 - //HdcpSupportCapability = 1200; //1201-1399 + } @@ -139,8 +279,8 @@ namespace PepperDash.Essentials.Bridges InputCurrentResolution = InputCurrentResolution + joinOffset; InputEndpointOnline = InputEndpointOnline + joinOffset; OutputEndpointOnline = OutputEndpointOnline + joinOffset; - //HdcpSupport = HdcpSupport + joinOffset; - //HdcpSupportCapability = HdcpSupportCapability + joinOffset; + HdcpSupportState = HdcpSupportState + joinOffset; + HdcpSupportCapability = HdcpSupportCapability + joinOffset; } } } diff --git a/PepperDashEssentials/Bridges/DmTxControllerBridge.cs b/PepperDashEssentials/Bridges/DmTxControllerBridge.cs index 26a6a939..906e189c 100644 --- a/PepperDashEssentials/Bridges/DmTxControllerBridge.cs +++ b/PepperDashEssentials/Bridges/DmTxControllerBridge.cs @@ -30,7 +30,7 @@ namespace PepperDash.Essentials.Bridges tx.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); tx.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus]); tx.AnyVideoInput.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentInputResolution]); - //tx.HdcpSupportAllFeedback.LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportCapability]); + trilist.UShortInput[joinMap.HdcpSupportCapability].UShortValue = (ushort)tx.HdcpSupportCapability; bool hdcpTypeSimple;