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

📄 tmdlhdmitx.c

📁 HDMI NXP9983 chipset controller driver
💻 C
📖 第 1 页 / 共 5 页
字号:
    RETIF_SEM(dlHdmiTxItSemaphore[unit],        tmdlHdmiTxIWTaskStart(unitTableTx[unit].commandTaskHandle) != TM_OK, TMDL_ERR_DLHDMITX_NO_RESOURCES)	/* Create the hdcp check task associated to this instance/unit */    RETIF_SEM(dlHdmiTxItSemaphore[unit],        tmdlHdmiTxIWTaskCreate(hdcpTaskTableTx[unit],        gtmdlHdmiTxDriverConfigTable[unit].hdcpTaskPriority,        gtmdlHdmiTxDriverConfigTable[unit].hdcpTaskStackSize,        &(unitTableTx[unit].hdcpTaskHandle)) != TM_OK, TMDL_ERR_DLHDMITX_NO_RESOURCES)    *pInstance = (tmInstance_t)unit;#ifndef NO_HDCP    hdcpInfoListTx[unit].bKsvSecure = False;    hdcpInfoListTx[unit].hdcpKsvDevices = 0;    for(i=0; i<TMDL_HDMITX_KSV_BYTES_PER_DEVICE; i++) { hdcpInfoListTx[unit].hdcpBksv[i] = 0; }#endif /* NO_HDCP */    /* Init the BSL */	/* Make sure all events are disabled */    instanceStatusInfoTx[unit].pEventState[TMDL_HDMITX_HDCP_ACTIVE].status = TMDL_HDMITX_EVENT_DISABLED;    instanceStatusInfoTx[unit].pEventState[TMDL_HDMITX_HDCP_INACTIVE].status = TMDL_HDMITX_EVENT_DISABLED;    instanceStatusInfoTx[unit].pEventState[TMDL_HDMITX_HPD_ACTIVE].status = TMDL_HDMITX_EVENT_DISABLED;    instanceStatusInfoTx[unit].pEventState[TMDL_HDMITX_HPD_INACTIVE].status = TMDL_HDMITX_EVENT_DISABLED;    instanceStatusInfoTx[unit].pEventState[TMDL_HDMITX_RX_KEYS_RECEIVED].status = TMDL_HDMITX_EVENT_DISABLED;    instanceStatusInfoTx[unit].pEventState[TMDL_HDMITX_RX_DEVICE_ACTIVE].status = TMDL_HDMITX_EVENT_DISABLED;    instanceStatusInfoTx[unit].pEventState[TMDL_HDMITX_RX_DEVICE_INACTIVE].status = TMDL_HDMITX_EVENT_DISABLED;    instanceStatusInfoTx[unit].pEventState[TMDL_HDMITX_EDID_RECEIVED].status = TMDL_HDMITX_EVENT_DISABLED;    instanceStatusInfoTx[unit].pEventState[TMDL_HDMITX_VS_RPT_RECEIVED].status = TMDL_HDMITX_EVENT_DISABLED;    instanceStatusInfoTx[unit].pColBarState->disableColorBarOnR0 = False;    instanceStatusInfoTx[unit].pColBarState->hdcpColbarChange = False;    instanceStatusInfoTx[unit].pColBarState->hdcpEncryptOrT0 = True;    instanceStatusInfoTx[unit].pColBarState->hdcpSecureOrT0 = False;    instanceStatusInfoTx[unit].pColBarState->inOutFirstSetDone = False;    instanceStatusInfoTx[unit].pColBarState->colorBarOn = True;    instanceStatusInfoTx[unit].pColBarState->changeColorBarNow = True;    instanceStatusInfoTx[unit].gamutBufNum = 0; /* use buffer 0 by default */    /* The funcCallback is not the same between BSL, so fill it dynamically */    for(i=0; i<HDMITX_CALLBACK_INT_NUM; i++)    {        callbackFuncTableTx.funcCallback[i] = Null;    }    callbackFuncTableTx.funcCallback[HDMITX_CALLBACK_INT_ENCRYPT] = dlHdmiTxHandleENCRYPT;    callbackFuncTableTx.funcCallback[HDMITX_CALLBACK_INT_HPD] = dlHdmiTxHandleHPD;    callbackFuncTableTx.funcCallback[HDMITX_CALLBACK_INT_T0] = dlHdmiTxHandleT0;    callbackFuncTableTx.funcCallback[HDMITX_CALLBACK_INT_BCAPS] = dlHdmiTxHandleBCAPS;    callbackFuncTableTx.funcCallback[HDMITX_CALLBACK_INT_BSTATUS] = dlHdmiTxHandleBSTATUS;    callbackFuncTableTx.funcCallback[HDMITX_CALLBACK_INT_SHA_1] = dlHdmiTxHandleSHA_1;    callbackFuncTableTx.funcCallback[HDMITX_CALLBACK_INT_PJ] = dlHdmiTxHandlePJ;#ifdef TMFL_TDA9981_SUPPORT    callbackFuncTableTx.funcCallback[HDMITX_CALLBACK_INT_R0] = dlHdmiTxHandleR0;    callbackFuncTableTx.funcCallback[HDMITX_CALLBACK_INT_SW_INT] = dlHdmiTxHandleSW_INT;#endif#ifdef TMFL_RX_SENSE_ON    callbackFuncTableTx.funcCallback[HDMITX_CALLBACK_INT_RX_SENSE] = dlHdmiTxHandleRX_SENSE;#endif        /* Prepare static TDA9984 driver data as the compiler doesn't seem to */    tmbslHdmiTxHwStartup();	    errCode = tmbslHdmiTxInit(*pInstance,                 gtmdlHdmiTxDriverConfigTable[unit].i2cAddress,                gtmdlHdmiTxDriverConfigTable[unit].i2cWriteFunction,                gtmdlHdmiTxDriverConfigTable[unit].i2cReadFunction,                (ptmbslHdmiTxSysFuncEdid_t)gtmdlHdmiTxDriverConfigTable[unit].edidReadFunction, /* required for TDA9983 */                (ptmbslHdmiTxSysFuncTimer_t)tmdlHdmiTxIWWait,                &callbackFuncTableTx,                False, /* Alternate EDID address not used */                (tmbslHdmiTxVidFmt_t)instanceStatusInfoTx[unit].pVideoInfo->videoInConfig.format,                (tmbslHdmiTxPixRate_t)instanceStatusInfoTx[unit].pVideoInfo->videoInConfig.pixelRate);    if (errCode != TM_OK)    {        /* Init failed */        tmbslHdmiTxDeinit(unit);        /* Release the sempahore */        RETIF( (errCode = tmdlHdmiTxIWSemaphoreV(dlHdmiTxItSemaphore[unit]) ) != TM_OK, errCode)        return errCode;    }    else    {        /* Init passed, continue */        /* Start by forcing the TMDS ouputs off */        errCode = tmbslHdmiTxTmdsSetOutputs(unit,            HDMITX_TMDSOUT_FORCED0);        RETIF_SEM(dlHdmiTxItSemaphore[unit], (errCode != TM_OK) && (errCode != TMBSL_ERR_HDMI_NOT_SUPPORTED), errCode)        RETIF_SEM(dlHdmiTxItSemaphore[unit],            (errCode = tmbslHdmiTxHwGetCapabilities(unit, &featureSupported) ) != TM_OK, errCode)#ifndef NO_HDCP        if ((featureSupported == tmbslHdmiTxHwHDCP) || (featureSupported == tmbslHdmiTxHwHDCPScaler))        {			dlHdmiTxFindHdcpSeed(unit);        }#endif /* NO_HDCP */        /* Retrieve the hardware device version from the BSL layer */        RETIF_SEM(dlHdmiTxItSemaphore[unit],			(errCode = tmbslHdmiTxHwGetVersion(unit,			&deviceVersion) ) != TM_OK, errCode)        /* Store the hardware device version in the global variable */        switch (deviceVersion)        {	       case BSLHDMITX_TDA9981:		        unitTableTx[unit].deviceVersion = TMDL_HDMITX_DEVICE_TDA9981;	                break;               case BSLHDMITX_TDA9983:		        unitTableTx[unit].deviceVersion = TMDL_HDMITX_DEVICE_TDA9983;                        break;	       default:		        unitTableTx[unit].deviceVersion = TMDL_HDMITX_DEVICE_UNKNOWN;		        break;        }    }	/* Start HDCP check task */    RETIF_SEM(dlHdmiTxItSemaphore[unit],        tmdlHdmiTxIWTaskStart(unitTableTx[unit].hdcpTaskHandle) != TM_OK, TMDL_ERR_DLHDMITX_NO_RESOURCES)	/* Set the state machine to initialized */    dlHdmiTxSetState(unit, STATE_INITIALIZED);    /* Release the sempahore */    RETIF( (errCode = tmdlHdmiTxIWSemaphoreV(dlHdmiTxItSemaphore[unit]) ) != TM_OK, errCode)        return TM_OK;}/******************************************************************************    \brief Close an instance of HdmiTx driver.    \param instance Instance identifier.    \return The call result:            - TM_OK: the call was successful            - TMDL_ERR_DLHDMITX_BAD_INSTANCE: the instance number is wrong or               out of range            - TMDL_ERR_DLHDMITX_RESOURCE_NOT_OWNED: the caller does not own               the resource            - TMDL_ERR_DLHDMITX_BAD_HANDLE: the handle number is wrong******************************************************************************/tmErrorCode_t tmdlHdmiTxClose(    tmInstance_t    instance){    tmErrorCode_t   errCode = TM_OK;    /* Check if instance number is in range */    RETIF((instance < 0) || (instance >= MAX_UNITS), TMDL_ERR_DLHDMITX_BAD_INSTANCE)    /* Take the sempahore */    RETIF( (errCode = tmdlHdmiTxIWSemaphoreP(dlHdmiTxItSemaphore[instance]) ) != TM_OK, errCode)    /* Check if unit corresponding to instance is opened */    RETIF_SEM(dlHdmiTxItSemaphore[instance],         unitTableTx[instance].opened == False, TMDL_ERR_DLHDMITX_RESOURCE_NOT_OWNED)    /* Close instance */    unitTableTx[instance].opened = False;        /* Set the state machine */    dlHdmiTxSetState(instance, STATE_NOT_INITIALIZED);        /* Destroy resources allocated for this instance/unit */    tmdlHdmiTxIWTaskDestroy(unitTableTx[instance].hdcpTaskHandle);    tmdlHdmiTxIWTaskDestroy(unitTableTx[instance].commandTaskHandle);    tmdlHdmiTxIWQueueDestroy(unitTableTx[instance].queueHandle);    /* Reset an instance of an HDMI transmitter */    tmbslHdmiTxDeinit(instance);    /* Release the sempahore */    RETIF( (errCode = tmdlHdmiTxIWSemaphoreV(dlHdmiTxItSemaphore[instance]) ) != TM_OK, errCode)    /* Close the handle to the semaphore */    RETIF( (errCode == tmdlHdmiTxIWSemaphoreDestroy(dlHdmiTxItSemaphore[instance]) ) != TM_OK, errCode)    return TM_OK;}/******************************************************************************    \brief Set the power state of an instance of the HDMI transmitter.    \param instance   Instance identifier.    \param powerState Power state to set.    \return The call result:            - TM_OK: the call was successful            - TMDL_ERR_DLHDMITX_BAD_INSTANCE: the instance number is wrong or               out of range            - TMDL_ERR_DLHDMITX_BAD_HANDLE: the handle number is wrong            - TMBSL_ERR_HDMI_BAD_UNIT_NUMBER: bad transmitter unit number             - TMBSL_ERR_HDMI_BAD_PARAMETER: a parameter was out of range            - TMBSL_ERR_HDMI_NOT_INITIALIZED: transmitter not initialized            - TMBSL_ERR_HDMI_I2C_WRITE: failed when writing to the I2C bus            - TMBSL_ERR_HDMI_I2C_READ: failed when reading to the I2C bus******************************************************************************/tmErrorCode_t tmdlHdmiTxSetPowerState(    tmInstance_t    instance,    tmPowerState_t  powerState){    tmErrorCode_t           errCode;    tmbslHdmiTxHotPlug_t    hpdStatus;  /* HPD status */    /* Check if instance number is in range */    RETIF((instance < 0) || (instance >= MAX_UNITS), TMDL_ERR_DLHDMITX_BAD_INSTANCE)    /* Take the sempahore */    RETIF( (errCode = tmdlHdmiTxIWSemaphoreP(dlHdmiTxItSemaphore[instance]) ) != TM_OK, errCode)    if  (unitTableTx[instance].deviceVersion == TMDL_HDMITX_DEVICE_TDA9984)    {	    if (powerState == tmPowerSuspend)	    {	        return TMDL_ERR_DLHDMITX_NOT_SUPPORTED;	    }    }    /* Switch off HDCP */    if ( (powerState == tmPowerOff) && (unitTableTx[instance].hdcpEnable == True) )    {        /* Release the sempahore */        RETIF( (errCode = tmdlHdmiTxIWSemaphoreV(dlHdmiTxItSemaphore[instance]) ) != TM_OK, errCode)        /* Switch off HDCP */        RETIF( (errCode = tmdlHdmiTxSetHdcp(instance, False) ) != TM_OK, errCode)        /* Take the sempahore */        RETIF( (errCode = tmdlHdmiTxIWSemaphoreP(dlHdmiTxItSemaphore[instance]) ) != TM_OK, errCode)    }    /* Set the power state of the transmitter */    RETIF_SEM(dlHdmiTxItSemaphore[instance],        (errCode = tmbslHdmiTxPowerSetState(instance,         powerState) ) != TM_OK, errCode)    /* Get Hot Plug status */    RETIF_SEM(dlHdmiTxItSemaphore[instance],        (errCode = tmbslHdmiTxHotPlugGetStatus(instance,        &hpdStatus) ) != TM_OK, errCode)    if (powerState == tmPowerOn)    {        if ((hpdStatus == HDMITX_HOTPLUG_ACTIVE) && (dlHdmiTxGetState(instance) != STATE_EDID_AVAILABLE))        {            /* Yes: Wait for DDC line to settle before reading EDID */            tmbslHdmiTxSysTimerWait(instance,500); /* ms */	            /* EDID read */            RETIF_SEM(dlHdmiTxItSemaphore[instance],                (errCode = tmbslHdmiTxEdidGetBlockData(instance,                unitTableTx[instance].pEdidBuffer, (UInt32)((unitTableTx[instance].edidBufferSize) >> 7),                unitTableTx[instance].edidBufferSize, &edidDataStatus) ) != TM_OK, errCode)               dlHdmiTxHandleEDID_READ(instance);        }    }            /* Release the sempahore */    RETIF( (errCode = tmdlHdmiTxIWSemaphoreV(dlHdmiTxItSemaphore[instance]) ) != TM_OK, errCode)    return TM_OK;}/******************************************************************************    \brief Get the power state of an instance of the HDMI transmitter.    \param instance    Instance identifier.    \param pPowerState Pointer to the power state.    \return The call result:            - TM_OK: the call was successful            - TMDL_ERR_DLHDMITX_BAD_INSTANCE: the instance number is wrong or               out of range            - TMDL_ERR_DLHDMITX_BAD_HANDLE: the handle number is wrong            - TMDL_ERR_DLHDMITX_INCONSISTENT_PARAMS: an input parameter is              inconsistent            - TMBSL_ERR_HDMI_BAD_UNIT_NUMBER: bad transmitter unit number            - TMBSL_ERR_HDMI_BAD_PARAMETER: a parameter was out of range            - TMBSL_ERR_HDMI_NOT_INITIALIZED: transmitter not initialized******************************************************************************/tmErrorCode_t tmdlHdmiTxGetPowerState(    tmInstance_t    instance,    tmPowerState_t  *pPowerState){    tmErrorCode_t   errCode;    /* Check if instance number is in range */    RETIF((instance < 0) || (instance >= MAX_UNITS), TMDL_ERR_DLHDMITX_BAD_INSTANCE)    /* Check if PowerState pointer is Null */    RETIF(pPowerState == Null, TMDL_ERR_DLHDMITX_INCONSISTENT_PARAMS)    /* Take the sempahore */    RETIF( (errCode = tmdlHdmiTxIWSemaphoreP(dlHdmiTxItSemaphore[instance]) ) != TM_OK, errCode)    /* Get the power state of the transmitter */    RETIF_SEM(dlHdmiTxItSemaphore[instance],        (errCode = tmbslHdmiTxPowerGetState(instance,        pPowerState) ) != TM_OK, errCode)    /* Release the sempahore */

⌨️ 快捷键说明

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