コード例 #1
0
static int 
hdmi_task_handle(void *data) 
{

    int repeater = 0;
    int stable_count = 0;
    static BOOL bSignal ;
    BOOL bOldSignal, bChangeMode ;
    int i;

    int dump_count = 0 ;

    MCU_init() ;

	printk("\n%s\n" , VERSION_STRING);
  while(1){
    	HoldSystem();
    	hdmirx_clear_hpd();
    	#ifdef _COPY_EDID_
    	CopyDefaultEDID() ;
    	#endif
    
      repeater=repeater_enable ;
    #if 0
        GetCurrentHDMIPort();
        SelectHDMIPort(CAT_HDMI_PORTA);
    #endif    
    	// InitHDMIRX(FALSE);
    	if( repeater )
    	{
    	    DownStreamCount = 3 ;
        	RxHDCPSetRepeater();
        }
        else
        {
        	RxHDCPSetReceiver();
        }
    	hdmirx_set_hpd();
    
      while(hdmirx_device.it660x_enable){
            while(hdmirx_device.task_pause){
                msleep(10);
            }
    
            //HoldSystem();
    
    		if(ReadRXIntPin())
    		{
    	        Check_HDMInterrupt();
    	    }
    
    	    //if(IsTimeOut(20))
    	    //{
    
                dump_count ++ ;
    		    bOldSignal = bSignal ;
    		    bSignal = CheckHDMIRX();
    		    bChangeMode = (bSignal != bOldSignal);
    
                if(bChangeMode)
                {
                    // if Changed Mode ...
    
        	        if(bSignal)
        	        {
                        stable_count = 0;
                        update_status(0);
        	            // if signal is TRUE , then ...
                        dump_vidmode();
                        if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ;
                        dump_audSts();
    
        	        }
        	        else
        	        {
                        stable_count = 0;
                        stop_vdin();
                        update_status(1);
        	            // if signal is FALSE , then ...
                        xCntCnt = 0 ;
                        xCntSum = 0 ;
    
        	        }
    
        			bChangeMode = FALSE ; // clear bChange Mode action
                }
                else
                {
                    // if not change mode, ...
        	        if(bSignal)
        	        {
                      if(stable_count<stable_threshold){
                        stable_count++;
                        if(stable_count == stable_threshold){
                            start_vdin(getHDMIRXHorzActive(), getHDMIRXVertActive(), 10000, IsHDMIRXInterlace());
                        }
                      }

                      update_status(0);

        	            // if signal is TRUE , then ...
        	            if( (dump_count % 20) == 1 )
        	            {
                            xCntCnt ++ ;
                            xCntSum += getHDMIRXxCnt() ;
                            if( xCntCnt > 40 )
                            {
                                xCntCnt /= 2 ;
                                xCntSum /= 2 ;
                            }
    
        	            }
        	        }
        	        else
        	        {
                       stable_count = 0;
                       stop_vdin();
                       update_status(1);
        	            
        	            // if signal is FALSE , then ...
                        xCntCnt = 0 ;
                        xCntSum = 0 ;
        	        }
        	    }
    
    
                if( dump_count > (DUMP_TIME*1000/20) )
                {
                    dump_count = 0 ;
                    if( bSignal )
                    {
                        dump_vidmode();
                        if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ;
                        dump_audSts();
    
                    }
                    else
                    {
                        printk("Reg10 = %02X\nReg12 = %02X\nReg64 = %02X\nReg65 = %02X\n"
                            ,(int)HDMIRX_ReadI2C_Byte(0x10)
                            ,(int)HDMIRX_ReadI2C_Byte(0x12)
                            ,(int)HDMIRX_ReadI2C_Byte(0x64)
                            ,(int)HDMIRX_ReadI2C_Byte(0x65) ) ;
                    }
                    printk("\n\n");
                    DumpHDMIRXReg();
                }
    
                if( (dump_count % (1000/20)) == 0)
                {
                    if( repeater!=repeater_enable )
                    {
                        repeater=repeater_enable ;
                    	hdmirx_clear_hpd();
    
    
                    	if( repeater )
                    	{
                    	    if( DownStreamCount == 0 )
                    	    {
                    	        DownStreamCount = 5 ;
                    	    }
                    	    else
                    	    {
                    	        DownStreamCount -- ;
                    	    }
                    	    printk("Set Repeater Mode, DownStream  = %d\n",DownStreamCount) ;
                        	RxHDCPSetRepeater();
                        }
                        else
                        {
                        	RxHDCPSetReceiver();
                        }
                    	hdmirx_set_hpd();
                    }
    
                }
    
                if( repeater )
                {
            	    if(IsRxAuthStart())
            	    {
            	        DelayCounter = 0 ;
            	    }
    
            	    if(IsRxAuthDone())
            	    {
            	        DelayCounter = DownStreamCount*2+1 ;
            	    }
    
            	    if(DelayCounter > 0)
            	    {
            	        DelayCounter -- ;
            	        if(DelayCounter == 0)
            	        {
            	            for(i = 0 ; i < 5*DownStreamCount ; i++)
            	            {
            	                KSVList[i] = SampleKSVList[i] ;
            	            }
            	            setRxHDCPKSVList(0,KSVList,DownStreamCount);
            	            if( DownStreamCount > 0 )
            	            {
            	                bStatus=DownStreamCount|0x0100 ;
            	            }
            	            else
            	            {
            	                bStatus=0;
            	            }
            	            setRxHDCPBStatus(bStatus);
            	            setRxHDCPCalcSHA();
    
            	        }
            	    }
                }
            //}//	if(IsTimeOut(20))
            msleep(10);
    
        }
        PowerDownHDMI();
  }
	return 0;
}
コード例 #2
0
ファイル: hello_world.c プロジェクト: rcavazza/LPVR
void button_isr(void* context, alt_u32 id) {
    static alt_u32 NextActiveTime = 0;
    bool bUpdateVPG = FALSE;
    // static alt_u8 disp_mode = 0;
    alt_u8 pushbutton_mask;

    if (id != PIO_BUTTON_IRQ)
        return;

    // get the edge capture mask
    pushbutton_mask = IORD_ALTERA_AVALON_PIO_EDGE_CAP(
                          PIO_BUTTON_BASE) & 0x03;  // button0/1

    // Reset the edge capture register
    IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_BUTTON_BASE,0);

//    // the following function only work for tx-only mode
//    if (gDemoMode != DEMO_TX_ONLY)
//        return;

    if (pushbutton_mask & 0x02) { // BUTTON[1]     // play tone
//        gbPlayTone = TRUE;
//        #ifndef TX_VPG_COLOR_CTRL_DISABLED
        OS_PRINTF("===> BUTTON 1 \n");

//RxActivePort = RX_PORT_A;
//                    // 1. power down hdmi
//PowerDownHDMI();
//                    // 2. Select HDMI Port
        SelectHDMIPort(CAT_HDMI_PORTA);
////                    // 3. Call InitIT6605
        InitIT6605();

        if (alt_nticks() > NextActiveTime) {
//                gVpgColor++;
//                if (gVpgColor == COLOR_YUV422 && !HDMITX_IsSinkSupportYUV422())
//                    gVpgColor++;
//                if (gVpgColor == COLOR_YUV444 && !HDMITX_IsSinkSupportYUV444())
//                    gVpgColor++;
//                if (gVpgColor == COLOR_MODE_NUM)
//                    gVpgColor = 0;  // RGB
//                bUpdateVPG = TRUE;
//gh00st
            NextActiveTime = alt_nticks() + alt_ticks_per_second()/2;
        }
//        #endif //TX_VPG_COLOR_CTRL_DISABLED
    } else if (pushbutton_mask & 0x01) { // BUTTON[0]    // change pattern generotor's pattern
        OS_PRINTF("===> BUTTON 0 \n");
//RxActivePort = RX_PORT_B;
//                    // 1. power down hdmi
//PowerDownHDMI();
//                    // 2. Select HDMI Port
        SelectHDMIPort(CAT_HDMI_PORTB);
//                    // 3. Call InitIT6605
        InitIT6605();
        if (alt_nticks() > NextActiveTime) { // note. timer should have a highter IRQ priority than button
//            // next mode
//            if (gVpgMode == MODE_1920x1080i120)
//                gVpgMode = MODE_720x480;
//            else
//                gVpgMode++;
//            bUpdateVPG = TRUE;
            NextActiveTime = alt_nticks() + alt_ticks_per_second()/2;
        }
    }

    if (bUpdateVPG) {
        HDMITX_DisableVideoOutput();
        VPG_Config(gVpgMode, gVpgColor);
        SetupTxVIC(gVpgMode);
        SetupColorSpace();
        HDMITX_EnableVideoOutput();
    }

}
コード例 #3
0
ファイル: hello_world.c プロジェクト: rcavazza/LPVR
int main()
{
    bool bRxVideoOn = FALSE, bTxSinkOn = FALSE, bRxModeChanged = FALSE;
    alt_u8 led_mask;
    alt_u32 BlinkTime;
    bool bHwNg = FALSE;

    // disable color depth if button1 is pressed when system boot.
    gEnableColorDepth = ((~IORD(PIO_BUTTON_BASE,0)) & 0x02)?0:1;

    OS_PRINTF("\n======== HDMI Demo REMIX by gh00st==============\n");

    //-------------------------------
    // HDMI TX init
    //-------------------------------
#ifndef TX_DISABLED
    if (!HDMITX_Init()) {
        printf("Failed to find CAT6613 HDMI-TX Chip.\n");
        bHwNg = TRUE;
        //return 0;
    }

    // init tx i2s irq
    THDMI_TX_I2S_Start();
    IOWR(I2S_TX_BASE, I2S_REG_IRQ_CLEAR, 0x00);  //clear interrupt flag

    // hdmi i2s irq
    if ((alt_irq_register(I2S_TX_IRQ, (void *)0, i2s_isr) != 0))
        OS_PRINTF("[I2S]register callback fail\n");
    else
        OS_PRINTF("[I2S]register callback success\n");

    //
    // button irq for generate audio
    // enable interrupt, button0/1

    IOWR_ALTERA_AVALON_PIO_IRQ_MASK(PIO_BUTTON_BASE, 0x03);

    // Reset the edge capture register
    IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_BUTTON_BASE,0);

    if ((alt_irq_register(PIO_BUTTON_IRQ, (void *)0, button_isr) != 0))
        OS_PRINTF("[I2S]register button callback fail\n");
    else
        OS_PRINTF("[I2S]register button callback success\n");
    //

#endif //TX_DISABLED        


    //-------------------------------
    // HDMI RX init
    //-------------------------------

#ifndef RX_DISABLED

    IOWR(HDMI_RX_HPD_N_BASE, 0, 0x03);    // pull-low hdmi connector hpd
    OS_DelayMS(1); // 1 ms
    if (!HDMIRX_Init(RX_PORT_AUTO))
        bHwNg = TRUE;
    IOWR(HDMI_RX_HPD_N_BASE, 0, 0x00); // pull-high hdmi connector hpd

#endif //RX_ENABLED    


    // gh00st
    SelectHDMIPort(CAT_HDMI_PORTA);
    InitIT6605();
//HDMIRX_DevLoopProc();
    SelectHDMIPort(CAT_HDMI_PORTB);
    InitIT6605();
//HDMIRX_DevLoopProc();
    //

    IOWR(HDMI_RX_SYNC_BASE, 0,0x00);
    led_mask = ~0x01;
    IOWR(PIO_LED_BASE, 0, led_mask);
    BlinkTime = alt_nticks() + alt_ticks_per_second()/4;

    if (bHwNg) {
        led_mask = 0x00;
        while(1) {
            if (alt_nticks() > BlinkTime) {
                IOWR(PIO_LED_BASE, 0, led_mask);
                led_mask ^= 0xFF;
                BlinkTime = alt_nticks() + alt_ticks_per_second()/4;
            }
        }
    }

    //-------------------------------
    // MAIN LOOP
    //-------------------------------

    while(1) {
#ifndef TX_DISABLED
        //========== TX
        if (HDMITX_DevLoopProc() || bRxModeChanged) {
            bTxSinkOn = HDMITX_HPD();
            if (bTxSinkOn) {
                // update state
                gDemoMode = bRxVideoOn?DEMO_LOOPBACK: DEMO_TX_ONLY;
                //
                HDMITX_DisableVideoOutput();
                if (gDemoMode == DEMO_TX_ONLY) {
                    // tx-only
                    VPG_Config(gVpgMode, gVpgColor);
                    SetupTxVIC(gVpgMode);
                }
                SetupColorSpace();
                HDMITX_EnableVideoOutput();
            } else {
                HDMITX_DisableVideoOutput();
            }
        }

#endif //

#ifndef RX_DISABLED
        //========== RX
        bRxModeChanged = HDMIRX_DevLoopProc();
        if (HDMIRX_IsVideoOn() ^ bRxVideoOn) {
            bRxVideoOn = HDMIRX_IsVideoOn();
            IOWR(HDMI_RX_SYNC_BASE, 0, bRxVideoOn?0x01:0x00);
            OS_PRINTF("[RX]Video On:%s\n", bRxVideoOn?"Yes":"No");
            // update state
            gDemoMode = !bTxSinkOn?DEMO_READY:(bRxVideoOn?DEMO_LOOPBACK:DEMO_TX_ONLY);
        }

        if (bRxModeChanged && bRxVideoOn) {
            OS_PRINTF("XXXXXX \n");
#ifndef TX_DISABLED
            // bypass AviInfoFrame from source to sink
            alt_u8 VIC, ColorMode;
            bool b16x9, bITU709;
            if (HDMIRX_GetAVIInfoFrame(&VIC, &ColorMode, &b16x9, &bITU709)) {
                OS_PRINTF("YYYYYYY \n");
                HDMITX_ChangeVideoTimingAndColor(VIC, ColorMode);
            }
            //SetupColorSpace();
#endif
        }
#endif //RX_ENABLED        

        //===== LED indication
        if (alt_nticks() > BlinkTime) {
            led_mask ^= 0x03;
            led_mask |= ~0x03;
            if (HDMITX_HPD())
                led_mask &= ~0x04;  // rx-source available (led is low-active)
            if (bRxVideoOn)
                led_mask &= ~0x08;  // rx-source available (led is low-active)

            IOWR(PIO_LED_BASE, 0, led_mask);
            //led_mask ^= 0xFF;

            BlinkTime = alt_nticks() + alt_ticks_per_second()/4;
        }

#if 0   // (DEBUG Purpose) dump register if button is pressed        
        alt_u8 mask;
        mask = (~IORD(PIO_BUTTON_BASE,0)) & 0x03;  // active low (PCI)
        if ((mask & 0x01)  == 0x01) { // BUTTON[0]
            HDMITX_DumpAllReg();
            HDMIRX_DumpAllReg();
        }
#endif


    }

}
コード例 #4
0
ファイル: mainmcu2.c プロジェクト: 9crk/it6604
int main(void)
{
    static BOOL bSignal ;
    BOOL bOldSignal, bChangeMode ;
    int dump_count = 0 ;

	hdmirx_clear_hpd();

    EnableHDMIRXVideoOutput(VIDEO_AUTO) ;
    SelectHDMIPort(CAT_HDMI_PORTA);
	InitHDMIRX(TRUE);
	hdmirx_set_hpd();

    xCntCnt = 0 ;
    xCntSum = 0 ;

    while(1){

        HoldSystem();

		if(ReadRXIntPin())
		{
	        Check_HDMInterrupt();
	    }

        #if 0
        // for switching to port B

    	hdmirx_clear_hpd();
        EnableHDMIRXVideoOutput(VIDEO_AUTO) ;
        SelectHDMIPort(CAT_HDMI_PORTB);
    	hdmirx_set_hpd();
        #endif

	    if(IsTimeOut(LOOP_MSEC))
	    {
            dump_count ++ ;

		    bOldSignal = bSignal ;
		    bSignal = CheckHDMIRX();
		    bChangeMode = (bSignal != bOldSignal);


            if(bChangeMode)
            {
                // if Changed Mode ...

    	        if(bSignal)
    	        {
    	            // if signal is TRUE , then ...
                    dump_vidmode();
					if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ;
                    dump_audSts();
    	        }
    	        else
    	        {
    	            // if signal is FALSE , then ...
                    xCntCnt = 0 ;
                    xCntSum = 0 ;

    	        }

    			bChangeMode = FALSE ; // clear bChange Mode action
            }
            else
            {
                // if not change mode, ...
    	        if(bSignal)
    	        {
    	            // if signal is TRUE , then ...
    	            if( (dump_count % 20) == 1 )
    	            {
                        xCntCnt ++ ;
                        xCntSum += getHDMIRXxCnt() ;
                        if( xCntCnt > 40 )
                        {
                            xCntCnt /= 2 ;
                            xCntSum /= 2 ;
                        }

    	            }
    	        }
    	        else
    	        {
    	            // if signal is FALSE , then ...
                    xCntCnt = 0 ;
                    xCntSum = 0 ;
    	        }
            }

            if( dump_count > (DUMP_TIME*1000/20) )
            {
                dump_count = 0 ;
                if( bSignal )
                {
                    dump_vidmode();
                    if( IsHDMIRXHDMIMode() ) dump_InfoFrame() ;
					dump_audSts();

                }
                else
                {
                    printf("There is no signal: Reg10 = %02X Reg12 = %02X Reg64 = %02X Reg65 = %02X\n"
                        ,(int)HDMIRX_ReadI2C_Byte(0x10)
                        ,(int)HDMIRX_ReadI2C_Byte(0x12)
                        ,(int)HDMIRX_ReadI2C_Byte(0x64)
                        ,(int)HDMIRX_ReadI2C_Byte(0x65) ) ;
                }
                printf("\n\n") ;
                DumpHDMIRXReg();
            }
	    }//	if(IsTimeOut(20))

    }
	return 0;
}