Пример #1
0
int cat66121_hdmi_sys_remove(void)
{
	hdmi_dbg(hdmi->dev, "[%s]\n", __FUNCTION__);
#ifdef SUPPORT_HDCP
	cancel_delayed_work_sync(&hdcp_delay_work);
	HDMITX_EnableHDCP(FALSE);
#endif
	HDMITX_DisableVideoOutput();
	if(getHDMI_PowerStatus()==TRUE)
		HDMITX_PowerDown();
	return 0;
}
Пример #2
0
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


    }

}
Пример #3
0
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();
    }

}