⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 philips_debug_tm1300.c

📁 用于TM1300/PNX1300系列DSP(主要用于视频处理)的设备库的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
    saa7113DisableDecoder,          /* disable video decoder */
    saa7113EnablePowerSaveMode,     /* set power save mode */
    saa7113GetGPIOCount,            /* get number of GPIOs on decoder */
    saa7113SetGPIOState,            /* set the state of one GPIO pin */
    saa7113GetGPIOState,            /* get a GPIO pin's state */
    saa7113OpenVBI,                 /* open VBI decoder */
    saa7113EnableVBI,               /* enable VBI */
    saa7113SetVBIMode,              /* set VBI mode */
    saa7113SetSlicerMode,           /* set the slicer's mode */
    saa7113CloseVBI,                /* close VBI decoder */
    saa7113GetSlicerLineFlags,      /* Get input status for every line */
    { 0x4A,                         /* decoder's I2C slave address */
      NO_OF_VIDEO_ADAPTERS,         /* number of adapters          */
      tm1300Debug_vi_adapters },    /* mapping table of adapters to inputs */
    tm1300Debug_VI_GetAdapterStandard  /* Get the standard for a specific adapter */
};



/******************************************************************************/
/* 
 * Contrary to other codecs (7111, 7111A, 7112), when the 7113H is
 * taken out of reset, it is not in a state that would allow the  
 * detect function to work. Therefore, it has to be initialized   
 * first. To avoid resetting the chip every time to try to get the
 * video statndard, there is a static variable that keeps track of
 * whether the 7113 has been previoulsy initialized 
 */    

static tmLibdevErr_t 
tm1300Debug_VI_Init (pboardVIParam_t param)
{
    tmLibdevErr_t err;
    if ((err = saa7113InitM(&tm1300Debug_vi.vDec, param)) != TMLIBDEV_OK)
        return err;
    else
        Is7113Initialized = True;
    return TMLIBDEV_OK; 
}

/******************************************************************************/

static tmLibdevErr_t 
tm1300Debug_VI_GetStandard(tmVideoAnalogStandard_t *standard)
{
    boardVIParam_t param;
    tmLibdevErr_t  err;

    if (Is7113Initialized == False)
    {
        param.videoStandard = vasPAL; /* this parameter is ignored */
        /* 
         * the following implies that the detection function will not work
         * if the adapterType is not Svideo
         * Svideo is the default in this case, because HSDB have
         * only a Svideo connector (even if CVBS is available)
         */
        param.adapterType     = vaaSvideo; /* FIXME */
        param.adapterInstance = 0;
        param.adapterType   = vaaCVBS;
        param.mmioBase      = tm1300Debug_vi.mmioBase;
        if ((err = tm1300Debug_vi.init_func(&param)) != TMLIBDEV_OK)
        {
            return err;
        }
    }

    return saa7113GetStandardM(&tm1300Debug_vi.vDec, standard);
}

/******************************************************************************/

static tmLibdevErr_t 
tm1300Debug_VI_GetAdapterStandard(pboardVIDec_t pVD, tmVideoAnalogAdapter_t adapter, UInt adapterNum, tmVideoAnalogStandard_t *standard)
{
    boardVIParam_t param;
    tmLibdevErr_t  err;

    if (Is7113Initialized == False)
    {
        param.videoStandard = vasPAL; /* this parameter is ignored */
        /* 
         * the following implies that the detection function will not work
         * if the adapterType is not Svideo
         * Svideo is the default in this case, because HSDB have
         * only a Svideo connector (even if CVBS is available)
         */
        param.adapterType     = adapter; 
        param.adapterInstance = 0;
        param.mmioBase      = tm1300Debug_vi.mmioBase;
        if ((err = tm1300Debug_vi.init_func(&param)) != TMLIBDEV_OK)
        {
            return err;
        }
    }

    return saa7113GetAdapterVideoStandard(pVD, adapter, adapterNum, standard);
}

/******************************************************************************/

static tmLibdevErr_t 
tm1300Debug_VI_Configure(UInt32 subaddr, UInt32 value)
{
    return saa7113ConfigureM(&tm1300Debug_vi.vDec, subaddr, value);
}

/******************************************************************************/

static      tmLibdevErr_t
tm1300Debug_VI_SetBrightness(UInt val)
{
    return saa7113SetBrightnessM(&tm1300Debug_vi.vDec, val);
}

/******************************************************************************/

static      tmLibdevErr_t
tm1300Debug_VI_SetContrast(UInt val)
{
    return saa7113SetContrastM(&tm1300Debug_vi.vDec, val);
}

/******************************************************************************/

static      tmLibdevErr_t
tm1300Debug_VI_SetSaturation(UInt val)
{
    return saa7113SetSaturationM(&tm1300Debug_vi.vDec, val);
}

/******************************************************************************/

static      tmLibdevErr_t
tm1300Debug_VI_SetHue(UInt val)
{
    return saa7113SetHueM(&tm1300Debug_vi.vDec, val);
}

/******************************************************************************/

/* describe telecom's Analog Front End (AFE) */
static boardSSIConfig_t tm1300Debug_afe =
{
    "st7545",
    st7545Setup,             /* setup */
    st7545Term,              /* term */
    Null,                    /* hook */
    Null,                    /* config */
    sacConnectToPOTS,        /* connection flags */
    Null,                    /* reserved */
    intINT_15,               /* interrupt number */
    0,                       /* gpio first pin */
    0                        /* gpio last pin */
};

static tmLibdevErr_t tm1300Debug_board_activate(pcomponent_t comp)
{
    TRY(tm1300Debug_board_detect());
    
    TRY(tm1300Debug_board_init());
    
    /* the board has to be registered now */
    TRY(tm1300Debug_board_register(comp));

    return TMLIBDEV_OK;
}

static tmLibdevErr_t tm1300Debug_board_init(void)
{
    pprocCapabilities_t procCap;
 
    TRY(procGetCapabilities(&procCap));

    /* make sure VO clock is running at 27MHz! */
    MMIO(VO_CLOCK) = (UInt) (0.5 + (1431655765.0 * 27000000 / procCap->cpuClockFrequency));
    MMIO(VO_CTL)   = 0x02700000;
    microsleep(10000);    /* wait for 10ms */

    /* reset peripherals and put UDA1320s into default state, AFE reset stays low */
    TRY(iicWriteReg(DEBUG_TM1300_IIC_EXPANDER_ADDRESS_1, -1, 0x80));    /* lower reset */
    TRY(iicWriteReg(DEBUG_TM1300_IIC_EXPANDER_ADDRESS_1, -1, 0x82));    /* raise reset */

    MMIO(SSI_CTL) = 0x00040000;
    TRY(iicWriteReg(DEBUG_TM1300_IIC_EXPANDER_ADDRESS_1, -1, 0x83)); /* raise reset for the AFE */

    /* reset the VI (7113H) */
    TRY(iicWriteReg(DEBUG_TM1300_IIC_EXPANDER_ADDRESS_2, -1, 0xdf));
    TRY(iicWriteReg(DEBUG_TM1300_IIC_EXPANDER_ADDRESS_2, -1, 0xff));
       
    /* Stop the 7125. */
    saa7125Stop(vasNTSC);
    MMIO(VO_CLOCK) = 0;

    return TMLIBDEV_OK;
}


/******************** tm1300Debug_board_detect *******************************
 * Returns true if the hardware appears to be a Philips TM1300 Debug board.
 */
static tmLibdevErr_t tm1300Debug_board_detect(void)
{
    Int   line, error;
    UInt  d1, d2, boardID, mfgID;
    UInt8 eepromData[8];

    DP(("tm1300Debug_board_detect\n"));
    
    for (line = 0; line < 8; line++) {
        error = iicReadReg(IIC_EEPROM_ADDRESS, line, &d1);
        if (error) 
        {
            TRY(iicReadReg(IIC_EEPROM_ADDRESS, line, &d1));
        }
        error = iicReadReg(IIC_EEPROM_ADDRESS, line, &d2);
        if (error)
        {
            TRY(iicReadReg(IIC_EEPROM_ADDRESS, line, &d2));
        }
        eepromData[line] = d1;
    }
    mfgID = (eepromData[3] << 8) + eepromData[4];
    boardID = (eepromData[1] << 8) + eepromData[2];

    if (mfgID != BOARD_ID_PHILIPS_MFG_ID)
        return BOARD_ERR_UNKNOWN_BOARD;

    if (boardID == BOARD_VERSION_PHILIPS_TM1300_DEBUG)
        return TMLIBDEV_OK;

    return BOARD_ERR_UNKNOWN_BOARD;
}

static tmLibdevErr_t tm1300Debug_board_register(pcomponent_t comp)
{
    UInt32 ID = BOARD_VERSION_PHILIPS_TM1300_DEBUG;

    TRY(tsaBoardRegisterAO(0, &tm1300Debug_ao));

    TRY(tsaBoardRegisterAI(0, &tm1300Debug_ai));

    TRY(tsaBoardRegisterSPDO(0, &tm1300Debug_spdo));

    TRY(tsaBoardRegisterVO(0, &tm1300Debug_vo));
    
    TRY(tsaBoardRegisterVI(0, &tm1300Debug_vi));
    
    TRY(tsaBoardRegisterSSI(0, &tm1300Debug_afe));

    /* register the GOMAD board */
    TRY(tsaBoardRegisterBoard(ID, "Philips TM1300 Debug"));

    return TMLIBDEV_OK;
}

TSA_COMP_DEF_O_COMPONENT( Philips_tm1300Debug, 
                          TSA_COMP_BUILD_ARG_LIST_1("bsp/boardID"), 
                          tm1300Debug_board_activate);
                          

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -