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

📄 aticonfg.cpp

📁 winddk src目录下的WDM源码压缩!
💻 CPP
📖 第 1 页 / 共 5 页
字号:

                for( nIndex = 0; nIndex < nNumberOfRegs; nIndex ++)
                {
                    uchWriteBuffer[0] = AUDIO_TDA9850_Reg_Control1 + nIndex;
                    uchWriteBuffer[1] = puchInitializationBuffer[nIndex];
                    if( !( bResult = pCScript->ExecuteI2CPacket( &i2cPacket)))
                        break;
                }

                if( puchInitializationBuffer != NULL)
                    ::ExFreePool( puchInitializationBuffer);

                return( bResult);
            }
            break;

        case ATI_AUDIO_CONFIG_4:
                // TDA8425 volume control should be initialized
                return( SetDefaultVolumeControl( pCScript));
            break;

        case ATI_AUDIO_CONFIG_6:
            {
                UCHAR   uchWriteBuffer;

                // write the power-up defaults values into the chip
                i2cPacket.uchChipAddress = uchAudioChipAddress;
                i2cPacket.cbReadCount = 0;
                i2cPacket.cbWriteCount = 1;
                i2cPacket.puchReadBuffer = NULL;
                i2cPacket.puchWriteBuffer = &uchWriteBuffer;
                i2cPacket.usFlags = I2COPERATION_WRITE;
                uchWriteBuffer = AUDIO_TDA9851_DefaultValue;

                return( pCScript->ExecuteI2CPacket( &i2cPacket));
            }
            break;

        case ATI_AUDIO_CONFIG_8:
            //Reset MSP3430
            
                    i2cPacket.uchChipAddress = m_uchAudioAddress;
                    i2cPacket.cbReadCount = 0;
                    i2cPacket.usFlags = I2COPERATION_WRITE;
                    i2cPacket.puchWriteBuffer = uchWrite16Value;


                    //Write 0x80 - 00 to Subaddr 0x00
                    i2cPacket.cbWriteCount = 3;
                    uchWrite16Value[0] = 0x00;
                    uchWrite16Value[1] = 0x80;
                    uchWrite16Value[2] = 0x00;

                    bResult = pCScript->PerformI2CPacketOperation( &i2cPacket);
                    if(bResult)
                    {
                        if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
                            return(FALSE);
                    }
                    else
                        return(FALSE);

                    //Write 0x00 - 00 to Subaddr 0x00
                    i2cPacket.cbWriteCount = 3;
                    uchWrite16Value[0] = 0x00;
                    uchWrite16Value[1] = 0x00;
                    uchWrite16Value[2] = 0x00;

                    bResult = pCScript->PerformI2CPacketOperation( &i2cPacket);
                    if(bResult)
                    {
                        if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
                            return(FALSE);
                    }
                    else
                        return(FALSE);

                    //SubAddr 0x12 Reg 0x13 Val 0x3f60
                    i2cPacket.cbWriteCount = 5;
                    uchWrite16Value[0] = 0x12;
                    uchWrite16Value[1] = 0x00;
                    uchWrite16Value[2] = 0x13;
                    uchWrite16Value[3] = 0x3f;
                    uchWrite16Value[4] = 0x60;

                    bResult = pCScript->PerformI2CPacketOperation( &i2cPacket);
                    if(bResult)
                    {
                        if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
                            return(FALSE);
                    }
                    else
                        return(FALSE);

                    //SubAddr 0x12 Reg 0x00 Val 0x0000
                    i2cPacket.cbWriteCount = 5;
                    uchWrite16Value[0] = 0x12;
                    uchWrite16Value[1] = 0x00;
                    uchWrite16Value[2] = 0x00;
                    uchWrite16Value[3] = 0x00;
                    uchWrite16Value[4] = 0x00;

                    bResult = pCScript->PerformI2CPacketOperation( &i2cPacket);
                    if(bResult)
                    {
                        if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
                            return(FALSE);
                    }
                    else
                        return(FALSE);
#ifdef  I2S_CAPTURE
#pragma message ("\n!!! PAY ATTENTION: Driver has been build with ITT CHIP I2S CAPTURE CONFIGURED !!!\n")


                    i2cPacket.uchChipAddress = m_uchAudioAddress;
                    i2cPacket.usFlags = I2COPERATION_WRITE;
                    i2cPacket.puchWriteBuffer = uchWrite16Value;
                    i2cPacket.puchReadBuffer = uchRead16Value;

                    //Setup I2S Source Select and Output Channel Matrix

                    //SubAddr 0x12 Reg 0x0b Val 0x0320
                    i2cPacket.cbWriteCount = 5;
                    i2cPacket.cbReadCount = 0;
                    uchWrite16Value[0] = 0x12;
                    uchWrite16Value[1] = 0x00;
                    uchWrite16Value[2] = 0x0b;
                    uchWrite16Value[3] = 0x03;
                    uchWrite16Value[4] = 0x20;

                    bResult = pCScript->PerformI2CPacketOperation( &i2cPacket);
                    if(bResult)
                    {
                        if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
                            return(FALSE);
                    }
                    else
                        return(FALSE);



                    //Setup MODUS 

                    i2cPacket.cbWriteCount = 5;
                    i2cPacket.cbReadCount = 0;
                    uchWrite16Value[0] = 0x10;
                    uchWrite16Value[1] = 0x00;
                    uchWrite16Value[2] = 0x30;
                    uchWrite16Value[3] = 0x20;
                    uchWrite16Value[4] = 0xe3;

                    bResult = pCScript->PerformI2CPacketOperation( &i2cPacket);
                    if(bResult)
                    {
                        if( i2cPacket.uchI2CResult != I2CSCRIPT_NOERROR)
                            return(FALSE);
                    }
                    else
                        return(FALSE);

#endif // I2S_CAPTURE

            break;

        default:
            break;
    }

    return( TRUE);
}



/*^^*
 *      GetTVAudioSignalProperties()
 * Purpose  : Gets Audio signal properties readable from ATI dependand hardware,
 *              like I2C expander. This call is always synchronous.
 *
 * Inputs   :   CI2CScript * pCScript   : pointer to the I2CScript object
 *              PBOOL pbStereo          : pointer to the Stereo Indicator
 *              PBOOL pbSAP             : pointer to the SAP Indicator
 *
 * Outputs  : BOOL, returns TRUE, if successful
 * Author   : IKLEBANOV
 *^^*/
BOOL CATIHwConfiguration::GetTVAudioSignalProperties( CI2CScript * pCScript, PBOOL pbStereo, PBOOL pbSAP)
{
    I2CPacket   i2cPacket;
    UCHAR       uchReadValue, uchWriteValue;
    BOOL        bResult;

    switch( m_uiAudioConfiguration)
    {
        case ATI_AUDIO_CONFIG_1:
        case ATI_AUDIO_CONFIG_5:
            // Stereo property is read back from I2C expander
            i2cPacket.uchChipAddress = m_uchI2CExpanderAddress;
            i2cPacket.cbReadCount = 1;
            i2cPacket.cbWriteCount = 1;
            i2cPacket.puchReadBuffer = &uchReadValue;
            i2cPacket.puchWriteBuffer = &uchWriteValue;
            i2cPacket.usFlags = I2COPERATION_READWRITE;
            i2cPacket.uchORValue = 0x40;
            i2cPacket.uchANDValue = 0xFF;

            bResult = FALSE;

            ENSURE
            {
                if( !pCScript->LockI2CProviderEx())
                    FAIL;

                pCScript->ExecuteI2CPacket( &i2cPacket);
                if( !( bResult = ( i2cPacket.uchI2CResult == I2C_STATUS_NOERROR)))
                    FAIL;

                i2cPacket.puchWriteBuffer = NULL;
                i2cPacket.usFlags = I2COPERATION_READ;

                pCScript->ExecuteI2CPacket( &i2cPacket);
                if( !( bResult = ( i2cPacket.uchI2CResult == I2C_STATUS_NOERROR)))
                    FAIL;

                * pbStereo = uchReadValue & 0x40;

                bResult = TRUE;

            } END_ENSURE;

            pCScript->ReleaseI2CProvider();

            break;

        default:
            bResult = FALSE;
            break;
    }

    if( bResult)
        // no case, where SAP property is read back from ATI's hardware
        * pbSAP = FALSE;

    return( bResult);
}



/*^^*
 *      GetDecoderOutputEnableLevel()
 * Purpose  : Retrieves ATI dependent hardware configuration property of the logical level
 *              should be applied on OUTEN field of Bt829x decoder in order to enable
 *              output stream
 *
 * Inputs   : none
 *
 * Outputs  : UINT,
 *              UINT( -1) value is returned if an error occures
 * Author   : IKLEBANOV
 *^^*/
UINT CATIHwConfiguration::GetDecoderOutputEnableLevel( void)
{
    UINT uiEnableLevel;

    switch( m_usDecoderConfiguration)
    {
        case ATI_VIDEODECODER_CONFIG_1:
        case ATI_VIDEODECODER_CONFIG_3:
        case ATI_VIDEODECODER_CONFIG_4:
            uiEnableLevel = 0;
            break;

        case ATI_VIDEODECODER_CONFIG_2:
            uiEnableLevel = 1;
            break;

        default:
            uiEnableLevel = UINT( -1);
            break;
    }

    return( uiEnableLevel);
}



/*^^*
 *      EnableDecoderI2CAccess()
 * Purpose  : Enables/disables I2C access to the decoder chip
 *
 * Inputs   : CI2CScript * pCScript : pointer to the I2CScript object
 *            BOOL bEnable          : defines what to do - enable/disable the decoder's outputs
 *
 * Outputs  : none
 * Author   : IKLEBANOV
 *^^*/
void CATIHwConfiguration::EnableDecoderI2CAccess( CI2CScript * pCScript, BOOL bEnable)
{
    UCHAR       uchORMask   = 0;
    UCHAR       uchANDMask  = 0xFF;
    UCHAR       uchReadValue, uchWriteValue;
    I2CPacket   i2cPacket;

    switch( m_usDecoderConfiguration)
    {
        case ATI_VIDEODECODER_CONFIG_1:     // Add-On TV Tuner board - ATI TV requires certain actions to be taken
            i2cPacket.uchChipAddress = m_uchI2CExpanderAddress;
            i2cPacket.cbReadCount = 1;
            i2cPacket.cbWriteCount = 1;
            if( bEnable)
                uchANDMask &= 0x7F;
            else
                uchORMask |= 0x80;

            i2cPacket.puchReadBuffer = &uchReadValue;
            i2cPacket.puchWriteBuffer = &uchWriteValue;
            i2cPacket.usFlags = I2COPERATION_READWRITE;
            i2cPacket.uchORValue = uchORMask;
            i2cPacket.uchANDValue = uchANDMask;

            pCScript->PerformI2CPacketOperation( &i2cPacket);

            break;

#ifdef _X86_
        case ATI_VIDEODECODER_CONFIG_3:
            _outp( 0x7D, ( _inp( 0x7D) | 0x80));
            if( bEnable)
                _outp( 0x7C, ( _inp( 0x7C) & 0x7F));
            else
                _outp( 0x7C, ( _inp( 0x7C) | 0x80));
            return;

        case ATI_VIDEODECODER_CONFIG_4:
            if( bEnable)
                _outp( 0x78, ( _inp( 0x78) & 0xF7));
            else
                _outp( 0x78, ( _inp( 0x78) | 0x08));
            return;
#endif

        default:
            break;
    }
}


/*^^*
 *      GetI2CExpanderConfiguration()
 * Purpose  : Gets board configuration via I2C expander
 *              Reads the configuration registers back
 * Inputs   :   CI2CScript * pCScript   : pointer to CI2CScript object
 *              PUCHAR puchI2CValue     : pointer to read the I2C value into    
 *
 * Outputs  : BOOL : returns TRUE
 *              also sets the requested values into the input pointers
 * Author   : IKLEBANOV
 *^^*/
BOOL CATIHwConfiguration::GetI2CExpanderConfiguration( CI2CScript * pCScript, PUCHAR puchI2CValue)
{
    I2CPacket   i2cPacket;

⌨️ 快捷键说明

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