diff --git a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x.c b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x.c index ee93631c..671f3b64 100644 --- a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x.c +++ b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x.c @@ -166,7 +166,7 @@ XHdcp1x_TimerDelay XHdcp1xTimerDelay = NULL; int XHdcp1x_CfgInitialize(XHdcp1x *InstancePtr, const XHdcp1x_Config *CfgPtr, void *PhyIfPtr) { - int Status = XST_SUCCESS; + int Status; /* Verify arguments. */ Xil_AssertNonvoid(InstancePtr != NULL); @@ -175,31 +175,32 @@ int XHdcp1x_CfgInitialize(XHdcp1x *InstancePtr, const XHdcp1x_Config *CfgPtr, /* Initialize InstancePtr */ memset(InstancePtr, 0, sizeof(XHdcp1x)); InstancePtr->Config = *CfgPtr; + InstancePtr->Port.PhyIfPtr = PhyIfPtr; + InstancePtr->Port.Adaptor = XHdcp1x_PortDetermineAdaptor(InstancePtr); -#if defined(INCLUDE_TX) - /* Check for TX */ - if (IsTX(InstancePtr)) { - Status = XHdcp1x_TxCfgInitialize(InstancePtr, CfgPtr, PhyIfPtr); + /* Ensure existence of an adaptor initialization function. */ + if (!InstancePtr->Port.Adaptor || !InstancePtr->Port.Adaptor->Init) { + return (XST_NO_FEATURE); } - else -#endif -#if defined(INCLUDE_RX) - /* Check for RX */ - if (IsRX(InstancePtr)) { - Status = XHdcp1x_RxCfgInitialize(InstancePtr, CfgPtr, PhyIfPtr); - } - else -#endif - { - Status = XST_FAILURE; + /* Invoke adaptor initialization function. */ + Status = (*(InstancePtr->Port.Adaptor->Init))(InstancePtr); + if (Status != XST_SUCCESS) { + return (Status); } - /* Update IsReady */ - if (Status == XST_SUCCESS) { - InstancePtr->IsReady = XIL_COMPONENT_IS_READY; + /* Initialize the cipher core. */ + XHdcp1x_CipherInit(InstancePtr); + /* Initialize the transmitter/receiver state machine. */ + if (!CfgPtr->IsRx) { + XHdcp1x_TxInit(InstancePtr); + } + else { + XHdcp1x_RxInit(InstancePtr); } - return (Status); + InstancePtr->IsReady = XIL_COMPONENT_IS_READY; + + return (XST_SUCCESS); } /*****************************************************************************/ diff --git a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_cipher.c b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_cipher.c index 7c3ea712..dd4b7390 100644 --- a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_cipher.c +++ b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_cipher.c @@ -215,59 +215,49 @@ static void Enable(XHdcp1x *InstancePtr); static void Disable(XHdcp1x *InstancePtr); -static void Init(XHdcp1x *InstancePtr); /************************** Function Definitions *****************************/ /*****************************************************************************/ /** -* This function initializes a cipher device. +* This function initializes an HDCP cipher. * * @param InstancePtr is the device to initialize. -* @param CfgPtr is the device configuration. * -* @return -* - XST_SUCCESS if successful. -* - XST_FAILURE otherwise. +* @return None. * * @note None. * ******************************************************************************/ -int XHdcp1x_CipherCfgInitialize(XHdcp1x *InstancePtr, - const XHdcp1x_Config *CfgPtr) +void XHdcp1x_CipherInit(XHdcp1x *InstancePtr) { - int Status = XST_SUCCESS; + u32 Value = 0; - /* Verify arguments. */ - Xil_AssertNonvoid(InstancePtr != NULL); - Xil_AssertNonvoid(CfgPtr != NULL); + /* Reset it */ + Value = RegRead(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL); + Value |= XHDCP1X_CIPHER_BITMASK_CONTROL_RESET; + RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL, Value); + Value = RegRead(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL); + Value &= ~XHDCP1X_CIPHER_BITMASK_CONTROL_RESET; + RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL, Value); - /* Check for mismatch on direction */ - if (IsRX(InstancePtr)) { - if (!(CfgPtr->IsRx)) { - Status = XST_FAILURE; - } - } - else if (CfgPtr->IsRx) { - Status = XST_FAILURE; + /* Ensure all interrupts are disabled and cleared */ + RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_INTERRUPT_MASK, (u32) (-1)); + RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_INTERRUPT_STATUS, (u32) (-1)); + + /* Check for DP */ + if (IsDP(InstancePtr)) { + /* Configure for four lanes SST */ + Value = RegRead(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL); + Value &= ~XHDCP1X_CIPHER_BITMASK_CONTROL_NUM_LANES; + Value |= (4u << 4); + RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL, Value); } - /* Check for mismatch on protocol */ - if (IsHDMI(InstancePtr)) { - if (!(CfgPtr->IsHDMI)) { - Status = XST_FAILURE; - } - } - else if (CfgPtr->IsHDMI) { - Status = XST_FAILURE; - } - - /* Initialize it */ - if (Status == XST_SUCCESS) { - Init(InstancePtr); - } - - return (Status); + /* Ensure that the register update bit is set */ + Value = RegRead(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL); + Value |= XHDCP1X_CIPHER_BITMASK_CONTROL_UPDATE; + RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL, Value); } /*****************************************************************************/ @@ -1333,45 +1323,3 @@ static void Disable(XHdcp1x *InstancePtr) /* Wait until the XOR has actually stopped */ while (XorInProgress(InstancePtr)); } - -/*****************************************************************************/ -/** -* This function initializes an HDCP cipher. -* -* @param InstancePtr is the device to initialize. -* -* @return None. -* -* @note None. -* -******************************************************************************/ -static void Init(XHdcp1x *InstancePtr) -{ - u32 Value = 0; - - /* Reset it */ - Value = RegRead(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL); - Value |= XHDCP1X_CIPHER_BITMASK_CONTROL_RESET; - RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL, Value); - Value = RegRead(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL); - Value &= ~XHDCP1X_CIPHER_BITMASK_CONTROL_RESET; - RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL, Value); - - /* Ensure all interrupts are disabled and cleared */ - RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_INTERRUPT_MASK, (u32) (-1)); - RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_INTERRUPT_STATUS, (u32) (-1)); - - /* Check for DP */ - if (IsDP(InstancePtr)) { - /* Configure for four lanes SST */ - Value = RegRead(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL); - Value &= ~XHDCP1X_CIPHER_BITMASK_CONTROL_NUM_LANES; - Value |= (4u << 4); - RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL, Value); - } - - /* Ensure that the register update bit is set */ - Value = RegRead(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL); - Value |= XHDCP1X_CIPHER_BITMASK_CONTROL_UPDATE; - RegWrite(InstancePtr, XHDCP1X_CIPHER_REG_CONTROL, Value); -} diff --git a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_cipher.h b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_cipher.h index b16015eb..beaad932 100644 --- a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_cipher.h +++ b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_cipher.h @@ -160,8 +160,7 @@ typedef enum { /************************** Function Prototypes ******************************/ -int XHdcp1x_CipherCfgInitialize(XHdcp1x *InstancePtr, - const XHdcp1x_Config *CfgPtr); +void XHdcp1x_CipherInit(XHdcp1x *InstancePtr); int XHdcp1x_CipherSetCallback(XHdcp1x *InstancePtr, u32 HandlerType, XHdcp1x_Callback Callback, void *Ref); diff --git a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_port.c b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_port.c index a55018b6..ff92dec5 100644 --- a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_port.c +++ b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_port.c @@ -89,49 +89,59 @@ extern const XHdcp1x_PortPhyIfAdaptor XHdcp1x_PortDpRxAdaptor; /*************************** Function Prototypes *****************************/ -static const XHdcp1x_PortPhyIfAdaptor *DetermineAdaptor(XHdcp1x *InstancePtr); /************************** Function Definitions *****************************/ /*****************************************************************************/ /** -* This function initializes a port device. +* This function determines the adaptor for a specified port device. * -* @param InstancePtr is the device to initialize. -* @param CfgPtr is the HDCP configuration structure. -* @param PhyIfPtr is pointer to the underlying physical interface. +* @param InstancePtr is the device whose adaptor is to be determined. * -* @return -* - XST_SUCCESS if successful. -* - XST_NO_FEATURE if the port lacks an Init function. +* @return A pointer to the adaptor table. NULL if not found. * * @note None. * ******************************************************************************/ -int XHdcp1x_PortCfgInitialize(XHdcp1x *InstancePtr, - const XHdcp1x_Config *CfgPtr, void *PhyIfPtr) +const XHdcp1x_PortPhyIfAdaptor *XHdcp1x_PortDetermineAdaptor( + XHdcp1x *InstancePtr) { - int Status = XST_SUCCESS; + const XHdcp1x_PortPhyIfAdaptor *Adaptor = NULL; + XHdcp1x_Config *CfgPtr = &InstancePtr->Config; - /* Verify arguments. */ - Xil_AssertNonvoid(InstancePtr != NULL); - Xil_AssertNonvoid(CfgPtr != NULL); - Xil_AssertNonvoid(PhyIfPtr != NULL); - - /* Initialize InstancePtr */ - InstancePtr->Port.PhyIfPtr = PhyIfPtr; - InstancePtr->Port.Adaptor = DetermineAdaptor(InstancePtr); - - /* Sanity Check */ - if (InstancePtr->Port.Adaptor == NULL) { - Status = XST_NO_FEATURE; +#if defined(INCLUDE_HDMI_RX) + /* Check for HDMI Rx */ + if ((CfgPtr->IsRx) && (CfgPtr->IsHDMI)) { + Adaptor = &XHdcp1x_PortHdmiRxAdaptor; } - /* Invoke adaptor function if present */ - else if (InstancePtr->Port.Adaptor->Init != NULL) { - Status = (*(InstancePtr->Port.Adaptor->Init))(InstancePtr); + else +#endif +#if defined(INCLUDE_HDMI_TX) + /* Check for HDMI Tx */ + if (!(CfgPtr->IsRx) && (CfgPtr->IsHDMI)) { + Adaptor = &XHdcp1x_PortHdmiTxAdaptor; + } + else +#endif +#if defined(INCLUDE_DP_RX) + /* Check for DP Rx */ + if ((CfgPtr->IsRx) && !(CfgPtr->IsHDMI)) { + Adaptor = &XHdcp1x_PortDpRxAdaptor; + } + else +#endif +#if defined(INCLUDE_DP_TX) + /* Check for DP Tx */ + if (!(CfgPtr->IsRx) && !(CfgPtr->IsHDMI)) { + Adaptor = &XHdcp1x_PortDpTxAdaptor; + } + else +#endif + { + Adaptor = NULL; } - return (Status); + return (Adaptor); } /*****************************************************************************/ @@ -376,55 +386,3 @@ int XHdcp1x_PortWrite(XHdcp1x *InstancePtr, u8 Offset, const void *Buf, return (NumWritten); } - -/*****************************************************************************/ -/** -* -* This function determines the adaptor for a specified port device. -* -* @param InstancePtr is the device whose adaptor is to be determined. -* -* @return A pointer to the adaptor table. NULL if not found. -* -* @note None. -* -******************************************************************************/ -static const XHdcp1x_PortPhyIfAdaptor *DetermineAdaptor(XHdcp1x *InstancePtr) -{ - const XHdcp1x_PortPhyIfAdaptor *Adaptor = NULL; - XHdcp1x_Config *CfgPtr = &InstancePtr->Config; - -#if defined(INCLUDE_HDMI_RX) - /* Check for HDMI Rx */ - if ((CfgPtr->IsRx) && (CfgPtr->IsHDMI)) { - Adaptor = &XHdcp1x_PortHdmiRxAdaptor; - } - else -#endif -#if defined(INCLUDE_HDMI_TX) - /* Check for HDMI Tx */ - if (!(CfgPtr->IsRx) && (CfgPtr->IsHDMI)) { - Adaptor = &XHdcp1x_PortHdmiTxAdaptor; - } - else -#endif -#if defined(INCLUDE_DP_RX) - /* Check for DP Rx */ - if ((CfgPtr->IsRx) && !(CfgPtr->IsHDMI)) { - Adaptor = &XHdcp1x_PortDpRxAdaptor; - } - else -#endif -#if defined(INCLUDE_DP_TX) - /* Check for DP Tx */ - if (!(CfgPtr->IsRx) && !(CfgPtr->IsHDMI)) { - Adaptor = &XHdcp1x_PortDpTxAdaptor; - } - else -#endif - { - Adaptor = NULL; - } - - return (Adaptor); -} diff --git a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_port.h b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_port.h index 0f76a949..cec560ed 100644 --- a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_port.h +++ b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_port.h @@ -189,9 +189,8 @@ typedef struct XHdcp1x_PortPhyIfAdaptorS { /************************** Function Prototypes ******************************/ -int XHdcp1x_PortCfgInitialize(XHdcp1x *InstancePtr, - const XHdcp1x_Config *ConfigPtr, void *PhyIfPtr); - +const XHdcp1x_PortPhyIfAdaptor *XHdcp1x_PortDetermineAdaptor( + XHdcp1x *InstancePtr); int XHdcp1x_PortSetCallback(XHdcp1x *InstancePtr, u32 HandlerType, XHdcp1x_Callback Callback, void *Parameter); diff --git a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_rx.c b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_rx.c index b6faf2ac..b7f460bb 100644 --- a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_rx.c +++ b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_rx.c @@ -151,7 +151,6 @@ static void EnterState(XHdcp1x *InstancePtr, tState State, tState *NextStatePtr); static void ExitState(XHdcp1x *InstancePtr, tState State); static void DoTheState(XHdcp1x *InstancePtr, tEvent Event); -static void Init(XHdcp1x *InstancePtr); static void ProcessPending(XHdcp1x *InstancePtr); static const char *StateToString(tState State); @@ -159,38 +158,24 @@ static const char *StateToString(tState State); /*****************************************************************************/ /** -* This function initializes the HDCP receiver module. +* This function initializes a HDCP receiver state machine. * * @param InstancePtr is the receiver instance. -* @param CfgPtr is the configuration of the instance. -* @param PhyIfPtr is a pointer to the underlying physical interface. * -* @return -* - XST_SUCCESS if successful. +* @return None. * * @note None. * ******************************************************************************/ -int XHdcp1x_RxCfgInitialize(XHdcp1x *InstancePtr, - const XHdcp1x_Config *CfgPtr, void *PhyIfPtr) +void XHdcp1x_RxInit(XHdcp1x *InstancePtr) { - int Status = XST_SUCCESS; + tState DummyState = STATE_DISABLED; - /* Verify arguments. */ - Xil_AssertNonvoid(InstancePtr != NULL); - Xil_AssertNonvoid(CfgPtr != NULL); - Xil_AssertNonvoid(PhyIfPtr != NULL); + /* Update theHandler */ + InstancePtr->Rx.PendingEvents = 0; - /* Initialize cipher, port and state machine */ - Status = XHdcp1x_PortCfgInitialize(InstancePtr, CfgPtr, PhyIfPtr); - if (Status == XST_SUCCESS) { - Status = XHdcp1x_CipherCfgInitialize(InstancePtr, CfgPtr); - if (Status == XST_SUCCESS) { - Init(InstancePtr); - } - } - - return (Status); + /* Kick the state machine */ + EnterState(InstancePtr, STATE_DISABLED, &DummyState); } /*****************************************************************************/ @@ -1320,28 +1305,6 @@ static void DoTheState(XHdcp1x *InstancePtr, tEvent Event) } } -/*****************************************************************************/ -/** -* This function initializes a HDCP receiver state machine. -* -* @param InstancePtr is the receiver instance. -* -* @return None. -* -* @note None. -* -******************************************************************************/ -static void Init(XHdcp1x *InstancePtr) -{ - tState DummyState = STATE_DISABLED; - - /* Update theHandler */ - InstancePtr->Rx.PendingEvents = 0; - - /* Kick the state machine */ - EnterState(InstancePtr, STATE_DISABLED, &DummyState); -} - /*****************************************************************************/ /** * This function processes the events pending on a state machine. diff --git a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_rx.h b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_rx.h index b1d33f9e..062bd59c 100644 --- a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_rx.h +++ b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_rx.h @@ -69,8 +69,7 @@ extern "C" { /************************** Function Prototypes ******************************/ -int XHdcp1x_RxCfgInitialize(XHdcp1x *InstancePtr, - const XHdcp1x_Config *CfgPtr, void *PhyIfPtr); +void XHdcp1x_RxInit(XHdcp1x *InstancePtr); int XHdcp1x_RxPoll(XHdcp1x *InstancePtr); diff --git a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_tx.c b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_tx.c index a4188b63..0a7fa716 100644 --- a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_tx.c +++ b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_tx.c @@ -189,7 +189,6 @@ static void EnterState(XHdcp1x *InstancePtr, tState State, tState *NextStatePtr); static void ExitState(XHdcp1x *InstancePtr, tState State); static void DoTheState(XHdcp1x *InstancePtr, tEvent Event); -static void Init(XHdcp1x *InstancePtr); static void ProcessPending(XHdcp1x *InstancePtr); static const char *StateToString(tState State); @@ -197,38 +196,24 @@ static const char *StateToString(tState State); /*****************************************************************************/ /** -* This function initializes an HDCP interface. +* This function initializes a transmit state machine. * -* @param InstancePtr is the transmitter instance. -* @param CfgPtr is the configuration of the instance. -* @param PhyIfPtr is pointer to the underlying physical interface. +* @param InstancePtr is the receiver instance. * -* @return -* - XST_SUCCESS if successful. +* @return None. * * @note None. * ******************************************************************************/ -int XHdcp1x_TxCfgInitialize(XHdcp1x *InstancePtr, - const XHdcp1x_Config *CfgPtr, void *PhyIfPtr) +void XHdcp1x_TxInit(XHdcp1x *InstancePtr) { - int Status = XST_SUCCESS; + tState DummyState = STATE_DISABLED; - /* Verify arguments. */ - Xil_AssertNonvoid(InstancePtr != NULL); - Xil_AssertNonvoid(CfgPtr != NULL); - Xil_AssertNonvoid(PhyIfPtr != NULL); + /* Update theHandler */ + InstancePtr->Tx.PendingEvents = 0; - /* Initialize cipher, port and state machine */ - Status = XHdcp1x_PortCfgInitialize(InstancePtr, CfgPtr, PhyIfPtr); - if (Status == XST_SUCCESS) { - Status = XHdcp1x_CipherCfgInitialize(InstancePtr, CfgPtr); - if (Status == XST_SUCCESS) { - Init(InstancePtr); - } - } - - return (Status); + /* Kick the state machine */ + EnterState(InstancePtr, STATE_DISABLED, &DummyState); } /*****************************************************************************/ @@ -2415,28 +2400,6 @@ static void DoTheState(XHdcp1x *InstancePtr, tEvent Event) } } -/*****************************************************************************/ -/** -* This function initializes a transmit state machine. -* -* @param InstancePtr is the receiver instance. -* -* @return None. -* -* @note None. -* -******************************************************************************/ -static void Init(XHdcp1x *InstancePtr) -{ - tState DummyState = STATE_DISABLED; - - /* Update theHandler */ - InstancePtr->Tx.PendingEvents = 0; - - /* Kick the state machine */ - EnterState(InstancePtr, STATE_DISABLED, &DummyState); -} - /*****************************************************************************/ /** * This function processes the events pending on a state machine. diff --git a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_tx.h b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_tx.h index 9fda1e22..6c02259d 100644 --- a/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_tx.h +++ b/XilinxProcessorIPLib/drivers/hdcp1x/src/xhdcp1x_tx.h @@ -69,8 +69,7 @@ extern "C" { /************************** Function Prototypes ******************************/ -int XHdcp1x_TxCfgInitialize(XHdcp1x *InstancePtr, - const XHdcp1x_Config *CfgPtr, void *PhyIfPtr); +void XHdcp1x_TxInit(XHdcp1x *InstancePtr); int XHdcp1x_TxPoll(XHdcp1x *InstancePtr);