XilinxProcessorIPLib/drivers/v_hdmitxss/examples/xhdmi_example/RepeaterProfessional/xhdcp.c
static void XHdcp_AuthenticationRequestCallback(void *HdcpInstancePtr)
{
  XHdcp_Repeater *InstancePtr =  (XHdcp_Repeater *)HdcpInstancePtr;
  XVidC_VideoStream *HdmiTxSsVidStreamPtr;

  /* Verify arguments */
  Xil_AssertVoid(InstancePtr != NULL);

  /* Clear topology */
  memset(&InstancePtr->Topology, 0, sizeof(XHdcp_Topology));

  if (XV_HdmiRxSs_HdcpIsRepeater(InstancePtr->UpstreamInstancePtr)) {
    /* Initialize the Authentication Request count.
     * Clear all previous requests. */
    InstancePtr->UpstreamAuthRequestCount = 0;

    /* Go through the Downstream interfaces */
    for (int i = 0; i < InstancePtr->DownstreamInstanceBinded; i++) {

      /* Check if the RX Stream is Up. */
      if (XV_HdmiRxSs_IsStreamUp(InstancePtr->UpstreamInstancePtr)) {

        /* Check if TX Stream is up */
        if (XV_HdmiTxSs_IsStreamUp(InstancePtr->DownstreamInstancePtr[i])) {
          /* Enable HDCP TX if it is not enabled. */
          if (!XV_HdmiTxSs_HdcpIsEnabled(InstancePtr->DownstreamInstancePtr[i])) {
            XV_HdmiTxSs_HdcpEnable(InstancePtr->DownstreamInstancePtr[i]);
          }

          /* Check if the TX Stream is valid. */
          HdmiTxSsVidStreamPtr = XV_HdmiTxSs_GetVideoStream(InstancePtr->DownstreamInstancePtr[i]);

          if (HdmiTxSsVidStreamPtr->VmId == XVIDC_VM_NO_INPUT ||
              HdmiTxSsVidStreamPtr->VmId == XVIDC_VM_NOT_SUPPORTED ||
              HdmiTxSsVidStreamPtr->VmId == XVIDC_VM_CUSTOM) {
		 /* HDCP Repeater authentication has started before the
		  * TX stream is stable;
		  * we pass this downstream and cannot be deterministic with
		  * regards to how long it takes the TX stream to have a valid
		  * resolution. Here we expect the upstream to time out and
		  * restart HDCP when HDCP fails.
		  */
#if HDCP_REPEATER_AUTH_FLOW
              xil_printf("HDCP Repeater AuthRequest :: TX Stream %d VmIs is not ",
			  "valid! (DwnStrmInstStreamUp = 0x%x) \r\n", i,
				  InstancePtr->DownstreamInstanceStreamUp);
#endif
		 XV_HdmiTxSs_HdcpAuthRequest(InstancePtr->DownstreamInstancePtr[i]);
          }

        } else {
#if HDCP_REPEATER_AUTH_FLOW
          xil_printf("HDCP Repeater AuthRequest :: TX Stream %d is not "
			  "up! (DwnStrmInstStreamUp = 0x%x) \r\n", i,
				  InstancePtr->DownstreamInstanceStreamUp);
#endif
          /* Check if the downstream instance "HDCP" stream is not Up. */
          if (!(InstancePtr->DownstreamInstanceStreamUp & (u32)(0x1 << i))) {
              /* TX HDCP Stream [i] is not up on the TX side.*/
		InstancePtr->DownstreamInstanceStreamUp |= (0x1 << i);
          }
        }
      } else {
		/* Here we shouldn't care for stream, if the RX stream is not up and
		 * we have received an authentication request, we should push it
		 * downstream.
		 */
		XV_HdmiTxSs_HdcpEnable(InstancePtr->DownstreamInstancePtr[i]);
		XV_HdmiTxSs_HdcpAuthRequest(InstancePtr->DownstreamInstancePtr[i]);
      }

      /* Pass the HDCP authentication request to the HDCP downstream
       * as we are a Repeater and can start authenticating regardless
       * of whether the downstream HDMI is up or not.
       */
      InstancePtr->UpstreamAuthRequestCount = 1;
    }

    /* Check if all the downstream interfaces are down. If so, the toggle Hpd. */
    if (InstancePtr->DownstreamInstanceStreamUp == 0x0) {
	  xil_printf("HDCP Repeater AuthRequest :: Downstream is all down !\r\n");
      if (XV_HdmiRxSs_GetVideoStreamType(InstancePtr->UpstreamInstancePtr)) {
#if HDCP_REPEATER_AUTH_FLOW
	xil_printf("HDCP Repeater AuthRequest :: Downstream is not Hdmi ;"
			" still pushing down AuthRequest \r\n");
#endif
      }
      InstancePtr->UpstreamAuthRequestCount = 1;
    }

  }

}
/*****************************************************************************/
/**
*
* This function is called when the upstream interface receives an
* authentication request. The function initiates authentication with
* each connected downstream interface that is not in the authenticated
* state. The function is registered with authentication request event.
* This function also sets the default content stream management type
* to zero when the upstream interface is HDCP 1.4.
*
* @param    HdcpInstancePtr is a pointer to the XHdcp_Repeater instance.
*
* @return   None.
*
* @note	    None.
*
******************************************************************************/
This function is called when the upstream interface receives an
authentication request. The function initiates authentication with
each connected downstream interface that is not in the authenticated
state. The function is registered with authentication request event.
This function also sets the default content stream management type
to zero when the upstream interface is HDCP 1.4.
This function is called when the upstream interface receives an authentication request . The function initiates authentication with each connected downstream interface that is not in the authenticated state . The function is registered with authentication request event . This function also sets the default content stream management type to zero when the upstream interface is HDCP 1 . 4 .
static void XHdcp_AuthenticationRequestCallback(void *HdcpInstancePtr)
{
  XHdcp_Repeater *InstancePtr =  (XHdcp_Repeater *)HdcpInstancePtr;
  XVidC_VideoStream *HdmiTxSsVidStreamPtr;
  Xil_AssertVoid(InstancePtr != NULL);
  memset(&InstancePtr->Topology, 0, sizeof(XHdcp_Topology));
  if (XV_HdmiRxSs_HdcpIsRepeater(InstancePtr->UpstreamInstancePtr)) {
    InstancePtr->UpstreamAuthRequestCount = 0;
    for (int i = 0; i < InstancePtr->DownstreamInstanceBinded; i++) {
      if (XV_HdmiRxSs_IsStreamUp(InstancePtr->UpstreamInstancePtr)) {
        if (XV_HdmiTxSs_IsStreamUp(InstancePtr->DownstreamInstancePtr[i])) {
          if (!XV_HdmiTxSs_HdcpIsEnabled(InstancePtr->DownstreamInstancePtr[i])) {
            XV_HdmiTxSs_HdcpEnable(InstancePtr->DownstreamInstancePtr[i]);
          }
          HdmiTxSsVidStreamPtr = XV_HdmiTxSs_GetVideoStream(InstancePtr->DownstreamInstancePtr[i]);
          if (HdmiTxSsVidStreamPtr->VmId == XVIDC_VM_NO_INPUT ||
              HdmiTxSsVidStreamPtr->VmId == XVIDC_VM_NOT_SUPPORTED ||
              HdmiTxSsVidStreamPtr->VmId == XVIDC_VM_CUSTOM) {
#if HDCP_REPEATER_AUTH_FLOW
              xil_printf("HDCP Repeater AuthRequest :: TX Stream %d VmIs is not ",
			  "valid! (DwnStrmInstStreamUp = 0x%x) \r\n", i,
				  InstancePtr->DownstreamInstanceStreamUp);
#endif
		 XV_HdmiTxSs_HdcpAuthRequest(InstancePtr->DownstreamInstancePtr[i]);
          }
        } else {
#if HDCP_REPEATER_AUTH_FLOW
          xil_printf("HDCP Repeater AuthRequest :: TX Stream %d is not "
			  "up! (DwnStrmInstStreamUp = 0x%x) \r\n", i,
				  InstancePtr->DownstreamInstanceStreamUp);
#endif
          if (!(InstancePtr->DownstreamInstanceStreamUp & (u32)(0x1 << i))) {
		InstancePtr->DownstreamInstanceStreamUp |= (0x1 << i);
          }
        }
      } else {
		XV_HdmiTxSs_HdcpEnable(InstancePtr->DownstreamInstancePtr[i]);
		XV_HdmiTxSs_HdcpAuthRequest(InstancePtr->DownstreamInstancePtr[i]);
      }
      InstancePtr->UpstreamAuthRequestCount = 1;
    }
    if (InstancePtr->DownstreamInstanceStreamUp == 0x0) {
	  xil_printf("HDCP Repeater AuthRequest :: Downstream is all down !\r\n");
      if (XV_HdmiRxSs_GetVideoStreamType(InstancePtr->UpstreamInstancePtr)) {
#if HDCP_REPEATER_AUTH_FLOW
	xil_printf("HDCP Repeater AuthRequest :: Downstream is not Hdmi ;"
			" still pushing down AuthRequest \r\n");
#endif
      }
      InstancePtr->UpstreamAuthRequestCount = 1;
    }
  }
}
static void XHdcp_AuthenticationRequestCallback ( void * HdcpInstancePtr ) { XHdcp_Repeater * InstancePtr = ( XHdcp_Repeater * ) HdcpInstancePtr ; XVidC_VideoStream * HdmiTxSsVidStreamPtr ; Xil_AssertVoid ( InstancePtr != NULL ) ; memset ( & InstancePtr -> Topology , 0 , sizeof ( XHdcp_Topology ) ) ; if ( XV_HdmiRxSs_HdcpIsRepeater ( InstancePtr -> UpstreamInstancePtr ) ) { InstancePtr -> UpstreamAuthRequestCount = 0 ; for ( int i = 0 ; i < InstancePtr -> DownstreamInstanceBinded ; i ++ ) { if ( XV_HdmiRxSs_IsStreamUp ( InstancePtr -> UpstreamInstancePtr ) ) { if ( XV_HdmiTxSs_IsStreamUp ( InstancePtr -> DownstreamInstancePtr [ i ] ) ) { if ( ! XV_HdmiTxSs_HdcpIsEnabled ( InstancePtr -> DownstreamInstancePtr [ i ] ) ) { XV_HdmiTxSs_HdcpEnable ( InstancePtr -> DownstreamInstancePtr [ i ] ) ; } HdmiTxSsVidStreamPtr = XV_HdmiTxSs_GetVideoStream ( InstancePtr -> DownstreamInstancePtr [ i ] ) ; if ( HdmiTxSsVidStreamPtr -> VmId == XVIDC_VM_NO_INPUT || HdmiTxSsVidStreamPtr -> VmId == XVIDC_VM_NOT_SUPPORTED || HdmiTxSsVidStreamPtr -> VmId == XVIDC_VM_CUSTOM ) { #if HDCP_REPEATER_AUTH_FLOW xil_printf ( " " , " \r \n " , i , InstancePtr -> DownstreamInstanceStreamUp ) ; #endif XV_HdmiTxSs_HdcpAuthRequest ( InstancePtr -> DownstreamInstancePtr [ i ] ) ; } } else { #if HDCP_REPEATER_AUTH_FLOW xil_printf ( " " " \r \n " , i , InstancePtr -> DownstreamInstanceStreamUp ) ; #endif if ( ! ( InstancePtr -> DownstreamInstanceStreamUp & ( u32 ) ( 0x1 << i ) ) ) { InstancePtr -> DownstreamInstanceStreamUp |= ( 0x1 << i ) ; } } } else { XV_HdmiTxSs_HdcpEnable ( InstancePtr -> DownstreamInstancePtr [ i ] ) ; XV_HdmiTxSs_HdcpAuthRequest ( InstancePtr -> DownstreamInstancePtr [ i ] ) ; } InstancePtr -> UpstreamAuthRequestCount = 1 ; } if ( InstancePtr -> DownstreamInstanceStreamUp == 0x0 ) { xil_printf ( " \r \n " ) ; if ( XV_HdmiRxSs_GetVideoStreamType ( InstancePtr -> UpstreamInstancePtr ) ) { #if HDCP_REPEATER_AUTH_FLOW xil_printf ( " " " \r \n " ) ; #endif } InstancePtr -> UpstreamAuthRequestCount = 1 ; } } }
This function is called when the upstream interface receives an
authentication request.
This function is called when the upstream interface receives an authentication request .
/* Verify arguments */ /* Clear topology */ /* Initialize the Authentication Request count.
     * Clear all previous requests. */ /* Go through the Downstream interfaces */ /* Check if the RX Stream is Up. */ /* Check if TX Stream is up */ /* Enable HDCP TX if it is not enabled. */ /* Check if the TX Stream is valid. */ /* HDCP Repeater authentication has started before the
		  * TX stream is stable;
		  * we pass this downstream and cannot be deterministic with
		  * regards to how long it takes the TX stream to have a valid
		  * resolution. Here we expect the upstream to time out and
		  * restart HDCP when HDCP fails.
		  */ /* Check if the downstream instance "HDCP" stream is not Up. */ /* TX HDCP Stream [i] is not up on the TX side.*/ /* Here we shouldn't care for stream, if the RX stream is not up and
		 * we have received an authentication request, we should push it
		 * downstream.
		 */ /* Pass the HDCP authentication request to the HDCP downstream
       * as we are a Repeater and can start authenticating regardless
       * of whether the downstream HDMI is up or not.
       */ /* Check if all the downstream interfaces are down. If so, the toggle Hpd. */