Ejemplo n.º 1
0
int dump_vidmode()
{
    USHORT HActive, VActive ;
    USHORT HTotal, VTotal ;
    ULONG HFreq, VFreq ;
    ULONG PCLK ;

    xCntCnt ++ ;
    xCntSum += getHDMIRXxCnt() ;

    HActive = getHDMIRXHorzActive() ;
    VActive = getHDMIRXVertActive() ;
    HTotal = getHDMIRXHorzTotal() ;
    VTotal = getHDMIRXVertTotal() ;

    PCLK = 27000L * 128;
    PCLK *= (ULONG) xCntCnt ;
    PCLK /= (ULONG) xCntSum ;
    PCLK *= 1000L ; // 100*PCLK ;

    HFreq = PCLK / (ULONG)HTotal ; // HFreq
    VFreq = (HFreq*100) / (ULONG)VTotal ; // VFreq * 100


	printf("\n========================================================================\n") ;
	printf("%s mode\n",IsHDMIRXHDMIMode()?"HDMI":"DVI") ;
    printf("Mode - %dx%d@",HActive,VActive);
    printf("%ld.%02ldHz",VFreq/100,VFreq%100) ;
    switch(getHDMIRXOutputColorDepth())
    {
    case 0x7: printf("@48bits") ; break ;
    case 0x6: printf("@36bits") ; break ;
    case 0x5: printf("@30bits") ; break ;
    case 0x4: printf("@24bits") ; break ;
    default: printf("@No def(24bits)") ; break ;
    }
    printf(", PCLK = %ld.%02ldMHz", PCLK/1000000, (PCLK/10000)%100) ;
    PCLK = xCntSum ;
    PCLK *= 100 ;
    PCLK /= xCntCnt ;
    PCLK -= (ULONG)(xCntSum / xCntCnt)*100 ;
    printf(",xCnt= %d.%02ld\n", xCntSum/xCntCnt,PCLK) ;

    printf("<%4dx%4d>,",HTotal,VTotal);

    printf("H:(%d,%d,%d),"
		,getHDMIRXHorzFrontPorch()
	    ,getHDMIRXHorzSyncWidth()
	    ,getHDMIRXHorzBackPorch());

    printf("V:(%d,%d,%d), "
		,getHDMIRXVertFrontPorch()
	    ,getHDMIRXVertSyncWidth()
	    ,getHDMIRXVertSyncBackPorch());

    printf("VSyncToDE = %d\n",getHDMIRXVertSyncToDE());
	printf("========================================================================\n") ;
    printf("HDCP %s\n",IsHDCPOn()?"ON":"OFF") ;
	printf("========================================================================\n") ;
}
void setRxHDCPBStatus(WORD bstatus)
{
    HDMIRX_WriteI2C_Byte(REG_RX_BLOCK_SEL,1);
    HDMIRX_WriteI2C_Byte(REG_RX_BSTATUSH,(BYTE)((bstatus>>8)& 0x0F));
    HDMIRX_WriteI2C_Byte(REG_RX_BSTATUSL,(BYTE)(bstatus & 0xFF));
    HDMIRX_WriteI2C_Byte(REG_RX_BLOCK_SEL,0);

    cDownStream = (BYTE)(bstatus &0x7F);
    if((0==(bstatus & 0x880))&& cDownStream <= HDMIRX_MAX_KSV)
    {
        SHABuff[cDownStream*5] = (BYTE)(bstatus &0xFF);
        SHABuff[cDownStream*5+1] = (BYTE)((bstatus>>8)&0x0F)| (IsHDMIRXHDMIMode()?0x10:0);
    }
Ejemplo n.º 3
0
static int 
hdmi_task_handle(void *data) 
{
    static BOOL bSignal ;
    BOOL bOldSignal, bChangeMode ;
    int dump_count = 0 ;
    int stable_count = 0;

    MCU_init() ;
	  printk("\n%s\n" , VERSION_STRING);
    while(1){
    	  HoldSystem();
        hdmirx_clear_hpd();
#ifdef _COPY_EDID_
        CopyDefaultEDID() ;
#endif

    	  InitHDMIRX(TRUE);
    	  hdmirx_set_hpd();
    
        xCntCnt = 0 ;
        xCntSum = 0 ;

        while(hdmirx_device.it660x_enable){
            while(hdmirx_device.task_pause){
                msleep(10);
            }

            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(IsTimeOut(20))
            msleep(10);
    
        }
        PowerDownHDMI();
    }
    return 0;

}
Ejemplo n.º 4
0
static void update_status(unsigned char clear)
{
    static int xcntcnt, xcntsum;
    if(clear){
        is_hdmi_mode = 0;
        horz_active = 0;
        vert_active = 0;
        is_interlace = 0;
        vfreq = 0;
        
        audio_status = 0;
        audio_sample_freq = 0;
        audio_channel_alloc = 0;
        xcntcnt = 0;
        xcntsum = 0;
    }
    else{
        ULONG PCLK, HFreq;
        unsigned char sample_freq_idx, valid_ch;
        is_hdmi_mode = IsHDMIRXHDMIMode();
        horz_active = getHDMIRXHorzActive();
        vert_active = getHDMIRXVertActive();
        is_interlace = IsHDMIRXInterlace();

        xcntcnt ++ ;
        xcntsum += getHDMIRXxCnt() ;
        if( xcntcnt > 40 )
        {
            xcntcnt /= 2 ;
            xcntsum /= 2 ;
        }
        PCLK = 27000L * 128;
        PCLK *= (ULONG) xcntcnt ;
        PCLK /= (ULONG) xcntsum ;
        PCLK *= 1000L ; // 100*PCLK ;

        HFreq = PCLK / (ULONG)getHDMIRXHorzTotal() ; // HFreq
        vfreq = (HFreq*100) / (ULONG)getHDMIRXVertTotal() ; // VFreq * 100

        if(is_hdmi_mode!=0){
            audio_status = getHDMIRXAudioStatus();
            getHDMIRXAudioInfo(&sample_freq_idx, &valid_ch);
            audio_channel_alloc = valid_ch;
            switch(sample_freq_idx){
                case 0x0:
                    audio_sample_freq = 44100;
                    break;
                case 0x2:
                    audio_sample_freq = 48000;
                    break;
                case 0x3:
                    audio_sample_freq = 32000;
                    break;
                case 0x8:
                    audio_sample_freq = 88200;
                    break;
                case 0xa:
                    audio_sample_freq = 96000;
                    break;
                case 0xc:
                    audio_sample_freq = 176400;
                    break;
                case 0xe:
                    audio_sample_freq = 192000;
                    break;
                case 0x9:    
                    printk("smaple freq for HBR\n");
                    audio_sample_freq = 768000;
                    break;                        
            }
            if((audio_sample_freq != hdmirx_device.aud_info.real_sample_rate)||
                (hdmirx_device.global_event&0x1)){
                hdmirx_device.aud_info.real_sample_rate = audio_sample_freq;                    
#ifdef CONFIG_AML_AUDIO_DSP
                if(hdmirx_device.vdin_started){
                    mailbox_send_audiodsp(1, M2B_IRQ0_DSP_AUDIO_EFFECT, DSP_CMD_SET_HDMI_SR, (char *)&hdmirx_device.aud_info.real_sample_rate,sizeof(hdmirx_device.aud_info.real_sample_rate));
                    hdmirx_device.global_event&=(~0x1);
                    printk("[IT660x]%s: mailbox_send_audiodsp %d\n",__func__, hdmirx_device.aud_info.real_sample_rate);
                }
#endif
            }
        }
        else{
            audio_status = 0;
            audio_sample_freq = 0;
            audio_channel_alloc = 0;
        }
    }    
}    
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
0
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;
}