From a823b320b1baa1440e10793b9042a6f5c4138748 Mon Sep 17 00:00:00 2001 From: Octasic Inc Date: Fri, 10 Feb 2006 13:40:24 +0200 Subject: importing OCT612x-01.00-PR39 --- .../oct6100api/oct6100_api/oct6100_channel.c | 757 +++++++++++++++------ 1 file changed, 546 insertions(+), 211 deletions(-) (limited to 'software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c') diff --git a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c index b51ebfd..7710154 100644 --- a/software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c +++ b/software/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c @@ -2,7 +2,7 @@ File: oct6100_channel.c - Copyright (c) 2001-2005 Octasic Inc. + Copyright (c) 2001-2006 Octasic Inc. Description: @@ -23,9 +23,9 @@ You should have received a copy of the GNU General Public License along with the OCT6100 GPL API; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -$Octasic_Release: OCT612xAPI-01.00-PR38 $ +$Octasic_Release: OCT612xAPI-01.00-PR39 $ -$Octasic_Revision: 449 $ +$Octasic_Revision: 460 $ \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ @@ -117,6 +117,7 @@ UINT32 Oct6100ChannelOpenDef( f_pChannelOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = -20; f_pChannelOpen->VqeConfig.fSoutAutomaticLevelControl = FALSE; f_pChannelOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = -20; + f_pChannelOpen->VqeConfig.ulAlcNoiseBleedOutTime = 0; f_pChannelOpen->VqeConfig.fRinHighLevelCompensation = FALSE; f_pChannelOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = -10; f_pChannelOpen->VqeConfig.fSoutAdaptiveNoiseReduction = FALSE; @@ -147,6 +148,8 @@ UINT32 Oct6100ChannelOpenDef( f_pChannelOpen->VqeConfig.fEnableMusicProtection = FALSE; /* Older images have idle code detection hard-coded to enabled. */ f_pChannelOpen->VqeConfig.fIdleCodeDetection = TRUE; + f_pChannelOpen->VqeConfig.fResetRinAlcOnTones = FALSE; + f_pChannelOpen->VqeConfig.fResetSoutAlcOnTones = FALSE; /* TDM configuration.*/ f_pChannelOpen->TdmConfig.ulRinNumTssts = 1; @@ -341,6 +344,7 @@ UINT32 Oct6100ChannelModifyDef( f_pChannelModify->VqeConfig.lRinAutomaticLevelControlTargetDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; f_pChannelModify->VqeConfig.fSoutAutomaticLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING; f_pChannelModify->VqeConfig.lSoutAutomaticLevelControlTargetDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.ulAlcNoiseBleedOutTime = cOCT6100_KEEP_PREVIOUS_SETTING; f_pChannelModify->VqeConfig.fRinHighLevelCompensation = cOCT6100_KEEP_PREVIOUS_SETTING; f_pChannelModify->VqeConfig.lRinHighLevelCompensationThresholdDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; f_pChannelModify->VqeConfig.fSoutAdaptiveNoiseReduction = cOCT6100_KEEP_PREVIOUS_SETTING; @@ -369,6 +373,8 @@ UINT32 Oct6100ChannelModifyDef( f_pChannelModify->VqeConfig.ulToneDisablerVqeActivationDelay = cOCT6100_KEEP_PREVIOUS_SETTING; f_pChannelModify->VqeConfig.fEnableMusicProtection = cOCT6100_KEEP_PREVIOUS_SETTING; f_pChannelModify->VqeConfig.fIdleCodeDetection = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fResetRinAlcOnTones = cOCT6100_KEEP_PREVIOUS_SETTING; + f_pChannelModify->VqeConfig.fResetSoutAlcOnTones = cOCT6100_KEEP_PREVIOUS_SETTING; /* TDM config. */ f_pChannelModify->TdmConfig.ulRinNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING; @@ -504,6 +510,7 @@ UINT32 Oct6100ChannelCreateBiDirDef( f_pChannelCreateBiDir->ulFirstChannelHndl = cOCT6100_INVALID_HANDLE; f_pChannelCreateBiDir->ulSecondChannelHndl = cOCT6100_INVALID_HANDLE; + return cOCT6100_ERR_OK; } @@ -796,6 +803,7 @@ UINT32 Oct6100ChannelGetStatsDef( f_pChannelStats->VqeConfig.fSoutLevelControl = FALSE; f_pChannelStats->VqeConfig.fRinAutomaticLevelControl = FALSE; f_pChannelStats->VqeConfig.fSoutAutomaticLevelControl = FALSE; + f_pChannelStats->VqeConfig.ulAlcNoiseBleedOutTime = cOCT6100_INVALID_STAT; f_pChannelStats->VqeConfig.fRinHighLevelCompensation = FALSE; f_pChannelStats->VqeConfig.fAcousticEcho = FALSE; f_pChannelStats->VqeConfig.fSoutAdaptiveNoiseReduction = FALSE; @@ -825,6 +833,8 @@ UINT32 Oct6100ChannelGetStatsDef( f_pChannelStats->VqeConfig.ulToneDisablerVqeActivationDelay = cOCT6100_INVALID_STAT; f_pChannelStats->VqeConfig.fEnableMusicProtection = FALSE; f_pChannelStats->VqeConfig.fIdleCodeDetection = FALSE; + f_pChannelStats->VqeConfig.fResetRinAlcOnTones = FALSE; + f_pChannelStats->VqeConfig.fResetSoutAlcOnTones = FALSE; @@ -2479,6 +2489,7 @@ UINT32 Oct6100ApiUpdateChannelEntry( pChanEntry->VqeConfig.fRinAutomaticLevelControl = (UINT8)( pVqeConfig->fRinAutomaticLevelControl & 0xFF ); pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb = (INT8)( pVqeConfig->lRinAutomaticLevelControlTargetDb & 0xFF ); pChanEntry->VqeConfig.fSoutAutomaticLevelControl = (UINT8)( pVqeConfig->fSoutAutomaticLevelControl & 0xFF ); + pChanEntry->VqeConfig.usAlcNoiseBleedOutTime = (UINT16)( pVqeConfig->ulAlcNoiseBleedOutTime & 0xFFFF ); pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb = (INT8)( pVqeConfig->lSoutAutomaticLevelControlTargetDb & 0xFF ); pChanEntry->VqeConfig.fRinHighLevelCompensation = (UINT8)( pVqeConfig->fRinHighLevelCompensation & 0xFF ); pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb = (INT8)( pVqeConfig->lRinHighLevelCompensationThresholdDb & 0xFF ); @@ -2506,6 +2517,8 @@ UINT32 Oct6100ApiUpdateChannelEntry( pChanEntry->VqeConfig.fRoutNoiseReduction = (UINT8)( pVqeConfig->fRoutNoiseReduction & 0xFF ); pChanEntry->VqeConfig.fEnableMusicProtection = (UINT8)( pVqeConfig->fEnableMusicProtection & 0xFF ); pChanEntry->VqeConfig.fIdleCodeDetection = (UINT8)( pVqeConfig->fIdleCodeDetection & 0xFF ); + pChanEntry->VqeConfig.fResetRinAlcOnTones = (UINT8)( pVqeConfig->fResetRinAlcOnTones & 0xFF ); + pChanEntry->VqeConfig.fResetSoutAlcOnTones = (UINT8)( pVqeConfig->fResetSoutAlcOnTones & 0xFF ); /* Save the codec information.*/ pChanEntry->CodecConfig.byAdpcmNibblePosition = (UINT8)( pCodecConfig->ulAdpcmNibblePosition & 0xFF ); @@ -3118,6 +3131,18 @@ UINT32 Oct6100ApiInvalidateChannelStructs( /*------------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------------*/ + /* Clear the mute with feature bit. */ + + if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) + { + ulResult = Oct6100ApiMuteSinWithFeatures( f_pApiInstance, f_usChanIndex, FALSE ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /*------------------------------------------------------------------------------*/ + /*------------------------------------------------------------------------------*/ /* Clear the VQE memory. */ @@ -3130,7 +3155,7 @@ UINT32 Oct6100ApiInvalidateChannelStructs( return ulResult; /*------------------------------------------------------------------------------*/ - + /*------------------------------------------------------------------------------*/ /* Clear the AF information memory. */ @@ -5683,6 +5708,7 @@ UINT32 Oct6100ApiModifyChannelEntry( pApiVqeConf->fSoutLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fSoutLevelControl & 0xFF ); pApiVqeConf->fRinAutomaticLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fRinAutomaticLevelControl & 0xFF ); pApiVqeConf->fSoutAutomaticLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAutomaticLevelControl & 0xFF ); + pApiVqeConf->usAlcNoiseBleedOutTime = (UINT16)( f_pChannelOpen->VqeConfig.ulAlcNoiseBleedOutTime & 0xFFFF ); pApiVqeConf->fRinHighLevelCompensation = (UINT8)( f_pChannelOpen->VqeConfig.fRinHighLevelCompensation & 0xFF ); pApiVqeConf->fSoutAdaptiveNoiseReduction = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAdaptiveNoiseReduction & 0xFF ); @@ -5714,6 +5740,8 @@ UINT32 Oct6100ApiModifyChannelEntry( pApiVqeConf->fRoutNoiseReduction = (UINT8)( f_pChannelOpen->VqeConfig.fRoutNoiseReduction & 0xFF ); pApiVqeConf->fEnableMusicProtection = (UINT8)( f_pChannelOpen->VqeConfig.fEnableMusicProtection & 0xFF ); pApiVqeConf->fIdleCodeDetection = (UINT8)( f_pChannelOpen->VqeConfig.fIdleCodeDetection & 0xFF ); + pApiVqeConf->fResetRinAlcOnTones = (UINT8)( f_pChannelOpen->VqeConfig.fResetRinAlcOnTones & 0xFF ); + pApiVqeConf->fResetSoutAlcOnTones = (UINT8)( f_pChannelOpen->VqeConfig.fResetSoutAlcOnTones & 0xFF ); } /*=======================================================================*/ @@ -6745,6 +6773,7 @@ UINT32 Oct6100ApiChannelGetStatsSer( f_pChannelStats->VqeConfig.fSoutLevelControl = pChanEntry->VqeConfig.fSoutLevelControl; f_pChannelStats->VqeConfig.fRinAutomaticLevelControl = pChanEntry->VqeConfig.fRinAutomaticLevelControl; f_pChannelStats->VqeConfig.fSoutAutomaticLevelControl = pChanEntry->VqeConfig.fSoutAutomaticLevelControl; + f_pChannelStats->VqeConfig.ulAlcNoiseBleedOutTime = pChanEntry->VqeConfig.usAlcNoiseBleedOutTime; f_pChannelStats->VqeConfig.fRinHighLevelCompensation = pChanEntry->VqeConfig.fRinHighLevelCompensation; f_pChannelStats->VqeConfig.fSoutAdaptiveNoiseReduction = pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction; f_pChannelStats->VqeConfig.fSoutNoiseBleaching = pChanEntry->VqeConfig.fSoutNoiseBleaching; @@ -6772,6 +6801,8 @@ UINT32 Oct6100ApiChannelGetStatsSer( f_pChannelStats->VqeConfig.fRoutNoiseReduction = pChanEntry->VqeConfig.fRoutNoiseReduction; f_pChannelStats->VqeConfig.fEnableMusicProtection = pChanEntry->VqeConfig.fEnableMusicProtection; f_pChannelStats->VqeConfig.fIdleCodeDetection = pChanEntry->VqeConfig.fIdleCodeDetection; + f_pChannelStats->VqeConfig.fResetRinAlcOnTones = pChanEntry->VqeConfig.fResetRinAlcOnTones; + f_pChannelStats->VqeConfig.fResetSoutAlcOnTones = pChanEntry->VqeConfig.fResetSoutAlcOnTones; /* Copy the CODEC configuration.*/ f_pChannelStats->CodecConfig.ulAdpcmNibblePosition = pChanEntry->CodecConfig.byAdpcmNibblePosition; @@ -7580,9 +7611,23 @@ UINT32 Oct6100ApiCheckVqeConfig( if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) && ( pImageInfo->fRinAutoLevelControl == FALSE ) ) return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_AUTO_LC; + if ( f_pVqeConfig->ulAlcNoiseBleedOutTime > 63750 ) + return cOCT6100_ERR_CHANNEL_ALC_NOISE_BLEED_OUT_TIME; + + if ( ( f_pVqeConfig->ulAlcNoiseBleedOutTime != 0 ) && ( pImageInfo->fAlcNoiseBleedOutTime == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ALC_NOISE_BLEED_OUT_TIME; + if ( ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) && ( pImageInfo->fRinHighLevelCompensation == FALSE ) ) return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_HIGH_LEVEL_COMP; + /* Check the enable reset Rin ALC on tone detection flag. */ + if ( ( f_pVqeConfig->fResetRinAlcOnTones != TRUE ) && ( f_pVqeConfig->fResetRinAlcOnTones != FALSE ) ) + return cOCT6100_ERR_CHANNEL_RESET_RIN_ALC_ON_TONES; + + /* The reset Rin ALC on tone detection can be activated if the image supports it. */ + if ( ( f_pVqeConfig->fResetRinAlcOnTones == TRUE ) && ( pImageInfo->fResetRinAlcOnTones == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_RESET_RIN_ALC_ON_TONES; + if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) { if ( f_pVqeConfig->fRinLevelControl == TRUE ) @@ -7594,6 +7639,12 @@ UINT32 Oct6100ApiCheckVqeConfig( if ( ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lRinAutomaticLevelControlTargetDb > 0 ) ) return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL_TARGET; } + else /* if ( f_pVqeConfig->fRinAutomaticLevelControl != TRUE ) */ + { + /* Reset Rin ALC on tones can only be activated in Rin ALC is requested. */ + if ( f_pVqeConfig->fResetRinAlcOnTones == TRUE ) + return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL_REQUIRED; + } if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) { @@ -7610,6 +7661,14 @@ UINT32 Oct6100ApiCheckVqeConfig( if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) && ( pImageInfo->fSoutAutoLevelControl == FALSE ) ) return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SOUT_AUTO_LC; + /* Check the enable reset Sout ALC on tone detection flag. */ + if ( ( f_pVqeConfig->fResetSoutAlcOnTones != TRUE ) && ( f_pVqeConfig->fResetSoutAlcOnTones != FALSE ) ) + return cOCT6100_ERR_CHANNEL_RESET_SOUT_ALC_ON_TONES; + + /* The reset Sout ALC on tone detection can be activated if the image supports it. */ + if ( ( f_pVqeConfig->fResetSoutAlcOnTones == TRUE ) && ( pImageInfo->fResetSoutAlcOnTones == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_RESET_SOUT_ALC_ON_TONES; + if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) { if ( f_pVqeConfig->fSoutLevelControl == TRUE ) @@ -7618,6 +7677,21 @@ UINT32 Oct6100ApiCheckVqeConfig( if ( ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lSoutAutomaticLevelControlTargetDb > 0 ) ) return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL_TARGET; } + else /* if ( f_pVqeConfig->fSoutAutomaticLevelControl != TRUE ) */ + { + /* Reset Sout ALC on tones can only be activated if Sout ALC is requested. */ + if ( f_pVqeConfig->fResetSoutAlcOnTones == TRUE ) + return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL_REQUIRED; + } + + /* ALC noise bleed out can only be configured if ALC is requested. */ + if ( f_pVqeConfig->ulAlcNoiseBleedOutTime != 0 ) + { + /* If both ports ALC is disabled, let the user know. */ + if ( ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) + && ( f_pVqeConfig->fSoutAutomaticLevelControl == FALSE ) ) + return cOCT6100_ERR_CHANNEL_AUTO_LEVEL_CONTROL_REQUIRED; + } if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != TRUE && f_pVqeConfig->fSoutAdaptiveNoiseReduction != FALSE ) @@ -7887,8 +7961,11 @@ UINT32 Oct6100ApiCheckVqeConfig( /* The idle code detection module can be disabled only if idle code detection configuration */ /* is supported in the image. */ - if ( ( f_pVqeConfig->fIdleCodeDetection == FALSE ) && ( pImageInfo->fIdleCodeDetectionConfiguration == FALSE ) ) - return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION_CONFIG; + if ( pImageInfo->fIdleCodeDetection == TRUE ) + { + if ( ( f_pVqeConfig->fIdleCodeDetection == FALSE ) && ( pImageInfo->fIdleCodeDetectionConfiguration == FALSE ) ) + return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION_CONFIG; + } return cOCT6100_ERR_OK; } @@ -10203,6 +10280,18 @@ UINT32 Oct6100ApiUpdateOpenStruct( f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanModify->VqeConfig.fRinAutomaticLevelControl; + if ( f_pChanModify->VqeConfig.fResetRinAlcOnTones == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fResetRinAlcOnTones = f_pChanEntry->VqeConfig.fResetRinAlcOnTones; + else + f_pChanOpen->VqeConfig.fResetRinAlcOnTones = f_pChanModify->VqeConfig.fResetRinAlcOnTones; + + + if ( f_pChanModify->VqeConfig.ulAlcNoiseBleedOutTime == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.ulAlcNoiseBleedOutTime = f_pChanEntry->VqeConfig.usAlcNoiseBleedOutTime; + else + f_pChanOpen->VqeConfig.ulAlcNoiseBleedOutTime = f_pChanModify->VqeConfig.ulAlcNoiseBleedOutTime; + + if ( f_pChanModify->VqeConfig.fRinHighLevelCompensation == cOCT6100_KEEP_PREVIOUS_SETTING ) f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanEntry->VqeConfig.fRinHighLevelCompensation; else @@ -10249,6 +10338,12 @@ UINT32 Oct6100ApiUpdateOpenStruct( f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanEntry->VqeConfig.fSoutAutomaticLevelControl; else f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanModify->VqeConfig.fSoutAutomaticLevelControl; + + + if ( f_pChanModify->VqeConfig.fResetSoutAlcOnTones == cOCT6100_KEEP_PREVIOUS_SETTING ) + f_pChanOpen->VqeConfig.fResetSoutAlcOnTones = f_pChanEntry->VqeConfig.fResetSoutAlcOnTones; + else + f_pChanOpen->VqeConfig.fResetSoutAlcOnTones = f_pChanModify->VqeConfig.fResetSoutAlcOnTones; if ( f_pChanModify->VqeConfig.lRinLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) ) @@ -10605,6 +10700,7 @@ UINT32 Oct6100ChannelCreateBiDirSer( UINT16 usBiDirChanIndex; UINT32 ulResult; + /* Check the user's configuration of the bidir channel for errors. */ ulResult = Oct6100ApiCheckChannelCreateBiDirParams( f_pApiInstance, f_pChannelCreateBiDir, @@ -10613,12 +10709,15 @@ UINT32 Oct6100ChannelCreateBiDirSer( &usFirstChanSinCopyEventIndex, &usSecondChanIndex, &usSecondChanExtraTsiIndex, - &usSecondChanSinCopyEventIndex ); + &usSecondChanSinCopyEventIndex + + ); if ( ulResult != cOCT6100_ERR_OK ) return ulResult; /* Reserve all resources needed by the bidir channel. */ ulResult = Oct6100ApiReserveChannelCreateBiDirResources(f_pApiInstance, + &usBiDirChanIndex, &usFirstChanExtraTsiIndex, &usFirstChanSinCopyEventIndex, @@ -10631,6 +10730,7 @@ UINT32 Oct6100ChannelCreateBiDirSer( /* Write all necessary structures to activate the echo cancellation channel. */ ulResult = Oct6100ApiWriteChannelCreateBiDirStructs( f_pApiInstance, + usFirstChanIndex, usFirstChanExtraTsiIndex, usFirstChanSinCopyEventIndex, @@ -10693,12 +10793,15 @@ UINT32 Oct6100ApiCheckChannelCreateBiDirParams( OUT PUINT16 f_pusFirstChanSinCopyEventIndex, OUT PUINT16 f_pusSecondChanIndex, OUT PUINT16 f_pusSecondChanExtraTsiIndex, - OUT PUINT16 f_pusSecondChanSinCopyEventIndex ) + OUT PUINT16 f_pusSecondChanSinCopyEventIndex + + ) { tPOCT6100_SHARED_INFO pSharedInfo; tPOCT6100_API_CHANNEL pFirstChanEntry; tPOCT6100_API_CHANNEL pSecondChanEntry; - UINT32 ulEntryOpenCnt; + UINT32 ulEntryOpenCnt; + BOOL fCheckTssts = TRUE; /* Obtain shared resources pointer.*/ pSharedInfo = f_pApiInstance->pSharedInfo; @@ -10706,6 +10809,8 @@ UINT32 Oct6100ApiCheckChannelCreateBiDirParams( /* validate the bidirectional channel handle memory.*/ if ( f_pChannelCreateBiDir->pulBiDirChannelHndl == NULL ) return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE; + + /* Check if bi-dir channels are activated. */ if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxBiDirChannels == 0 ) @@ -10742,10 +10847,13 @@ UINT32 Oct6100ApiCheckChannelCreateBiDirParams( if ( pFirstChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX ) return cOCT6100_ERR_CHANNEL_FIRST_CHAN_IN_CONFERENCE; - if ( pFirstChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX ) - return cOCT6100_ERR_CHANNEL_FIRST_CHAN_SOUT_PORT; - if ( pFirstChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX ) - return cOCT6100_ERR_CHANNEL_FIRST_CHAN_RIN_PORT; + if ( fCheckTssts == TRUE ) + { + if ( pFirstChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX ) + return cOCT6100_ERR_CHANNEL_FIRST_CHAN_SOUT_PORT; + if ( pFirstChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX ) + return cOCT6100_ERR_CHANNEL_FIRST_CHAN_RIN_PORT; + } /* Return the desired info.*/ *f_pusFirstChanExtraTsiIndex = pFirstChanEntry->usExtraSinTsiMemIndex; @@ -10780,10 +10888,13 @@ UINT32 Oct6100ApiCheckChannelCreateBiDirParams( if ( pSecondChanEntry->fBiDirChannel == TRUE ) return cOCT6100_ERR_CHANNEL_ALREADY_BIDIR; - if ( pSecondChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX ) - return cOCT6100_ERR_CHANNEL_SECOND_CHAN_SOUT_PORT; - if ( pSecondChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX ) - return cOCT6100_ERR_CHANNEL_SECOND_CHAN_RIN_PORT; + if ( fCheckTssts == TRUE ) + { + if ( pSecondChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX ) + return cOCT6100_ERR_CHANNEL_SECOND_CHAN_SOUT_PORT; + if ( pSecondChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX ) + return cOCT6100_ERR_CHANNEL_SECOND_CHAN_RIN_PORT; + } if ( pSecondChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX ) return cOCT6100_ERR_CHANNEL_SECOND_CHAN_IN_CONFERENCE; @@ -10797,7 +10908,6 @@ UINT32 Oct6100ApiCheckChannelCreateBiDirParams( if ( pFirstChanEntry->TdmConfig.bySoutPcmLaw != pSecondChanEntry->TdmConfig.byRinPcmLaw || pFirstChanEntry->TdmConfig.byRinPcmLaw != pSecondChanEntry->TdmConfig.bySoutPcmLaw ) return cOCT6100_ERR_CHANNEL_BIDIR_PCM_LAW; - return cOCT6100_ERR_OK; } @@ -10825,6 +10935,7 @@ f_pusSecondChanSoutCopyEventIndex Pointer to the second channel Sout copy event \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ UINT32 Oct6100ApiReserveChannelCreateBiDirResources( IN tPOCT6100_INSTANCE_API f_pApiInstance, + OUT PUINT16 f_pusBiDirChanIndex, IN OUT PUINT16 f_pusFirstChanExtraTsiIndex, IN OUT PUINT16 f_pusFirstChanSinCopyEventIndex, @@ -10850,22 +10961,25 @@ UINT32 Oct6100ApiReserveChannelCreateBiDirResources( /*===============================================================================*/ /* Verify and reserve the resources that might already by allocated. */ - if ( *f_pusFirstChanExtraTsiIndex == cOCT6100_INVALID_INDEX ) - { - /* Reserve the first Extra TSI memory entry */ - ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, - f_pusFirstChanExtraTsiIndex ); - if ( ulResult == cOCT6100_ERR_OK ) - fFirstExtraTsi = TRUE; - } - if ( *f_pusFirstChanSinCopyEventIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK ) { - /* Reserve the Sin copy event for the first channel.*/ - ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance, - f_pusFirstChanSinCopyEventIndex ); - if ( ulResult == cOCT6100_ERR_OK ) - fFirstSinCopyEvent = TRUE; + if ( *f_pusFirstChanExtraTsiIndex == cOCT6100_INVALID_INDEX ) + { + /* Reserve the first Extra TSI memory entry */ + ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, + f_pusFirstChanExtraTsiIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + fFirstExtraTsi = TRUE; + } + + if ( *f_pusFirstChanSinCopyEventIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK ) + { + /* Reserve the Sin copy event for the first channel.*/ + ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance, + f_pusFirstChanSinCopyEventIndex ); + if ( ulResult == cOCT6100_ERR_OK ) + fFirstSinCopyEvent = TRUE; + } } if ( *f_pusSecondChanExtraTsiIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK ) @@ -10899,9 +11013,14 @@ UINT32 Oct6100ApiReserveChannelCreateBiDirResources( { fBiDirChanIndex = TRUE; - /* Reserve the first channel Sout copy mixer event.*/ - ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance, - f_pusFirstChanSoutCopyEventIndex ); + + { + + /* Reserve the first channel Sout copy mixer event.*/ + ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance, + f_pusFirstChanSoutCopyEventIndex ); + } + if ( ulResult == cOCT6100_ERR_OK ) { fFirstSoutCopyEvent = TRUE; @@ -10962,7 +11081,9 @@ UINT32 Oct6100ApiReserveChannelCreateBiDirResources( return ulTempVar; } - if ( fFirstSoutCopyEvent == TRUE ) + if ( ( fFirstSoutCopyEvent == TRUE ) + + ) { ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, *f_pusFirstChanSoutCopyEventIndex ); @@ -11004,6 +11125,7 @@ f_usSecondChanSoutCopyEventIndex Pointer to the second channel Sout copy event i \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ UINT32 Oct6100ApiWriteChannelCreateBiDirStructs( IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usFirstChanIndex, IN UINT16 f_usFirstChanExtraTsiIndex, IN UINT16 f_usFirstChanSinCopyEventIndex, @@ -11034,50 +11156,55 @@ UINT32 Oct6100ApiWriteChannelCreateBiDirStructs( mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex ); mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex ); - /*==============================================================================*/ - /* Configure the Tsst control memory and add the Sin copy event if necessary.*/ - - /*=======================================================================*/ - /* Program the Sin Copy event.*/ - WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); - - WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY; - WriteParams.usWriteData |= f_usFirstChanExtraTsiIndex; - WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET; - mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; - WriteParams.ulWriteAddress += 2; - WriteParams.usWriteData = (UINT16)( pFirstChanEntry->usSinSoutTsiMemIndex ); - mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; + { + /*==============================================================================*/ + /* Configure the Tsst control memory and add the Sin copy event if necessary. */ + + /*=======================================================================*/ + /* Program the Sin Copy event.*/ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY; + WriteParams.usWriteData |= f_usFirstChanExtraTsiIndex; + WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET; - /*=======================================================================*/ + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; - /* Configure the TSST memory.*/ - if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) - { - ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, - pFirstChanEntry->usSinTsstIndex, - f_usFirstChanExtraTsiIndex, - pFirstChanEntry->TdmConfig.bySinPcmLaw ); - if ( ulResult != cOCT6100_ERR_OK ) + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = (UINT16)( pFirstChanEntry->usSinSoutTsiMemIndex ); + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) return ulResult; - } - /* Now insert the event into the event list.*/ - ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance, - f_usFirstChanSinCopyEventIndex, - cOCT6100_EVENT_TYPE_SIN_COPY, - f_usFirstChanIndex ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; + /*=======================================================================*/ - /*==============================================================================*/ + /* Configure the TSST memory.*/ + if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pFirstChanEntry->usSinTsstIndex, + f_usFirstChanExtraTsiIndex, + pFirstChanEntry->TdmConfig.bySinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Now insert the event into the event list.*/ + ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance, + f_usFirstChanSinCopyEventIndex, + cOCT6100_EVENT_TYPE_SIN_COPY, + f_usFirstChanIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /*==============================================================================*/ + } @@ -11108,10 +11235,13 @@ UINT32 Oct6100ApiWriteChannelCreateBiDirStructs( /* Configure the TSST memory.*/ if ( pSecondChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) { - ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, - pSecondChanEntry->usSinTsstIndex, - f_usSecondChanExtraTsiIndex, - pSecondChanEntry->TdmConfig.bySinPcmLaw ); + + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pSecondChanEntry->usSinTsstIndex, + f_usSecondChanExtraTsiIndex, + pSecondChanEntry->TdmConfig.bySinPcmLaw ); + } if ( ulResult != cOCT6100_ERR_OK ) return ulResult; } @@ -11131,30 +11261,31 @@ UINT32 Oct6100ApiWriteChannelCreateBiDirStructs( /*==============================================================================*/ /* Now, let's configure the two Sout copy events.*/ - /* First event.*/ - WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); - - WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY; - WriteParams.usWriteData |= pFirstChanEntry->usSinSoutTsiMemIndex; - WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET; - mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; + /* First event.*/ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY; + WriteParams.usWriteData |= pFirstChanEntry->usSinSoutTsiMemIndex; + WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET; - WriteParams.ulWriteAddress += 2; - WriteParams.usWriteData = pSecondChanEntry->usRinRoutTsiMemIndex; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; - mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; + WriteParams.ulWriteAddress += 2; + WriteParams.usWriteData = pSecondChanEntry->usRinRoutTsiMemIndex; - ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance, - f_usFirstChanSoutCopyEventIndex, - cOCT6100_EVENT_TYPE_SOUT_COPY, - f_usFirstChanIndex ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance, + f_usFirstChanSoutCopyEventIndex, + cOCT6100_EVENT_TYPE_SOUT_COPY, + f_usFirstChanIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; /* Second event.*/ @@ -11205,7 +11336,9 @@ UINT32 Oct6100ApiWriteChannelCreateBiDirStructs( pFirstChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX; } - if ( pSecondChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX ) + if ( ( pSecondChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX ) + + ) { /* Remove the event from the list.*/ ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, @@ -11282,8 +11415,11 @@ UINT32 Oct6100ApiUpdateBiDirChannelEntry( pBiDirChanEntry->usFirstChanIndex = f_usFirstChanIndex; pBiDirChanEntry->usSecondChanIndex = f_usSecondChanIndex; + + /* Increment the extra TSI memory dependency count.*/ - pFirstChanEntry->usExtraSinTsiDependencyCnt++; + + pFirstChanEntry->usExtraSinTsiDependencyCnt++; pSecondChanEntry->usExtraSinTsiDependencyCnt++; /* Set the bidir flag in the channel structure.*/ @@ -11333,12 +11469,14 @@ UINT32 Oct6100ChannelDestroyBiDirSer( UINT16 usFirstChanIndex; UINT16 usSecondChanIndex; + UINT32 ulResult; /* Verify that all the parameters given match the state of the API. */ ulResult = Oct6100ApiAssertDestroyBiDirChanParams( f_pApiInstance, f_pChannelDestroyBiDir, &usBiDirChanIndex, + &usFirstChanIndex, &usSecondChanIndex ); if ( ulResult != cOCT6100_ERR_OK ) @@ -11346,6 +11484,7 @@ UINT32 Oct6100ChannelDestroyBiDirSer( /* Release all resources associated to the echo cancellation channel. */ ulResult = Oct6100ApiInvalidateBiDirChannelStructs( f_pApiInstance, + usFirstChanIndex, usSecondChanIndex ); if ( ulResult != cOCT6100_ERR_OK ) @@ -11354,6 +11493,7 @@ UINT32 Oct6100ChannelDestroyBiDirSer( /* Release all resources associated to the echo cancellation channel. */ ulResult = Oct6100ApiReleaseBiDirChannelResources( f_pApiInstance, usBiDirChanIndex, + usFirstChanIndex, usSecondChanIndex ); if ( ulResult != cOCT6100_ERR_OK ) @@ -11388,6 +11528,7 @@ UINT32 Oct6100ApiAssertDestroyBiDirChanParams( IN tPOCT6100_INSTANCE_API f_pApiInstance, IN tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir, IN OUT PUINT16 f_pusBiDirChanIndex, + IN OUT PUINT16 f_pusFirstChanIndex, IN OUT PUINT16 f_pusSecondChanIndex ) { @@ -11426,6 +11567,8 @@ UINT32 Oct6100ApiAssertDestroyBiDirChanParams( *f_pusFirstChanIndex = pBiDirChanEntry->usFirstChanIndex; *f_pusSecondChanIndex = pBiDirChanEntry->usSecondChanIndex; + + return cOCT6100_ERR_OK; } @@ -11444,6 +11587,7 @@ f_pApiInstance Pointer to API instance. This memory is used to keep the \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ UINT32 Oct6100ApiInvalidateBiDirChannelStructs( IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usFirstChanIndex, IN UINT16 f_usSecondChanIndex ) { @@ -11467,37 +11611,40 @@ UINT32 Oct6100ApiInvalidateBiDirChannelStructs( /* Clear the SIN copy event of the first channel and release the Extra TSI memory if this feature was the only one using it. */ - if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { - /*=======================================================================*/ - /* Clear the Sin Copy event.*/ - WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); - WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { + /*=======================================================================*/ + /* Clear the Sin Copy event.*/ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; - mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; - /*=======================================================================*/ + /*=======================================================================*/ - /* Configure the TSST memory.*/ - if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) - { - ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, - pFirstChanEntry->usSinTsstIndex, - pFirstChanEntry->usSinSoutTsiMemIndex, - pFirstChanEntry->TdmConfig.bySinPcmLaw ); + /* Configure the TSST memory.*/ + if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX ) + { + ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance, + pFirstChanEntry->usSinTsstIndex, + pFirstChanEntry->usSinSoutTsiMemIndex, + pFirstChanEntry->TdmConfig.bySinPcmLaw ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Remove the event from the list.*/ + ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, + pFirstChanEntry->usSinCopyEventIndex, + cOCT6100_EVENT_TYPE_SIN_COPY ); if ( ulResult != cOCT6100_ERR_OK ) return ulResult; - } - - /* Remove the event from the list.*/ - ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, - pFirstChanEntry->usSinCopyEventIndex, - cOCT6100_EVENT_TYPE_SIN_COPY ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; + } } /* Clear the SIN copy event of the first channel and release the Extra TSI memory if @@ -11537,22 +11684,26 @@ UINT32 Oct6100ApiInvalidateBiDirChannelStructs( /* Now remove the sout copy of the first channel.*/ - /*=======================================================================*/ - /* Clear the Sout Copy event of the first channel.*/ - WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); - WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; - mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; - /*=======================================================================*/ + { + /*=======================================================================*/ + /* Clear the Sout Copy event of the first channel.*/ + WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE ); + WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP; + + mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + /*=======================================================================*/ + + /* Remove the event from the list.*/ + ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, + pFirstChanEntry->usSoutCopyEventIndex, + cOCT6100_EVENT_TYPE_SOUT_COPY ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } - /* Remove the event from the list.*/ - ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, - pFirstChanEntry->usSoutCopyEventIndex, - cOCT6100_EVENT_TYPE_SOUT_COPY ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; /* Now remove the sout copy of the second channel.*/ @@ -11575,6 +11726,7 @@ UINT32 Oct6100ApiInvalidateBiDirChannelStructs( return ulResult; + return cOCT6100_ERR_OK; } @@ -11598,6 +11750,7 @@ f_usSecondChanIndex Index of the second channel used to create the bidir channe UINT32 Oct6100ApiReleaseBiDirChannelResources( IN tPOCT6100_INSTANCE_API f_pApiInstance, IN UINT16 f_usBiDirChanIndex, + IN UINT16 f_usFirstChanIndex, IN UINT16 f_usSecondChanIndex ) { @@ -11621,32 +11774,35 @@ UINT32 Oct6100ApiReleaseBiDirChannelResources( return cOCT6100_ERR_FATAL_AC; /* Release the Extra TSI memory and the SIN copy event if required.*/ - if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { - /* Release the two TSI chariot memory entries.*/ - ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pFirstChanEntry->usExtraSinTsiMemIndex ); - if ( ulResult != cOCT6100_ERR_OK ) - return cOCT6100_ERR_FATAL_A3; + if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 ) + { + /* Release the two TSI chariot memory entries.*/ + ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pFirstChanEntry->usExtraSinTsiMemIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_A3; - /* Relese the SIN copy event.*/ - ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSinCopyEventIndex ); - if ( ulResult != cOCT6100_ERR_OK ) - return cOCT6100_ERR_FATAL_A4; + /* Relese the SIN copy event.*/ + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSinCopyEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_A4; - mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pFirstChanEntry->usSinCopyEventIndex ); + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pFirstChanEntry->usSinCopyEventIndex ); - /* Invalidate the entry.*/ - pTempEventEntry->fReserved = FALSE; - pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT; - pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + /* Invalidate the entry.*/ + pTempEventEntry->fReserved = FALSE; + pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT; + pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; - pFirstChanEntry->usExtraSinTsiDependencyCnt--; - pFirstChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX; - pFirstChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX; - } - else - { - pFirstChanEntry->usExtraSinTsiDependencyCnt--; + pFirstChanEntry->usExtraSinTsiDependencyCnt--; + pFirstChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX; + pFirstChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX; + } + else + { + pFirstChanEntry->usExtraSinTsiDependencyCnt--; + } } if ( pSecondChanEntry->usExtraSinTsiDependencyCnt == 1 ) @@ -11676,18 +11832,20 @@ UINT32 Oct6100ApiReleaseBiDirChannelResources( pSecondChanEntry->usExtraSinTsiDependencyCnt--; } - /* Release the SOUT copy event of the first channel.*/ - ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSoutCopyEventIndex ); - if ( ulResult != cOCT6100_ERR_OK ) - return cOCT6100_ERR_FATAL_A7; - mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pSecondChanEntry->usSoutCopyEventIndex ); - /* Invalidate the entry.*/ - pTempEventEntry->fReserved = FALSE; - pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT; - pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + { + /* Release the SOUT copy event of the first channel.*/ + ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSoutCopyEventIndex ); + if ( ulResult != cOCT6100_ERR_OK ) + return cOCT6100_ERR_FATAL_A7; + + mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pFirstChanEntry->usSoutCopyEventIndex ); + /* Invalidate the entry.*/ + pTempEventEntry->fReserved = FALSE; + pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT; + pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX; + } - /* Release the SOUT copy event of the second channel.*/ ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usSoutCopyEventIndex ); if ( ulResult != cOCT6100_ERR_OK ) @@ -11713,6 +11871,7 @@ UINT32 Oct6100ApiReleaseBiDirChannelResources( /* Update the second channel's list entry. */ /* Mark the channel as closed. */ + pSecondChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX; pSecondChanEntry->fBiDirChannel = FALSE; @@ -12217,7 +12376,10 @@ UINT32 Oct6100ApiSetChannelLevelControl( || ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb != pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb ) || ( f_pVqeConfig->fSoutNaturalListenerEnhancement != pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement ) || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb ) - || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb ) ) + || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb ) + || ( f_pVqeConfig->fResetRinAlcOnTones != pChanEntry->VqeConfig.fResetRinAlcOnTones ) + || ( f_pVqeConfig->fResetSoutAlcOnTones != pChanEntry->VqeConfig.fResetSoutAlcOnTones ) + || ( f_pVqeConfig->ulAlcNoiseBleedOutTime != pChanEntry->VqeConfig.usAlcNoiseBleedOutTime ) ) { /* Calculate base address for manual level control configuration. */ ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst; @@ -12331,6 +12493,49 @@ UINT32 Oct6100ApiSetChannelLevelControl( /* Calculate base address for auto level control + high level compensation configuration. */ ulBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst; + /* Configure the ALC bleed out time. */ + if ( pSharedInfo->ImageInfo.fAlcNoiseBleedOutTime == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.AlcNoiseBleedOutTimeFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.AlcNoiseBleedOutTimeFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.AlcNoiseBleedOutTimeFieldOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( f_pVqeConfig->ulAlcNoiseBleedOutTime != 0 ) + { + /* Set ALC noise bleed out time. */ + usTempData = (UINT16)( f_pVqeConfig->ulAlcNoiseBleedOutTime / 250 ); + ulTempData |= ( usTempData << ulFeatureBitOffset ); + } + else /* if ( f_pVqeConfig->ulAlcNoiseBleedOutTime == 0 ) */ + { + /* Disable ALC noise bleed out. */ + ulTempData |= ( 0x0 << ulFeatureBitOffset ); + } + + /* Save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + /* Check which one is to be disabled first. */ if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) fDisableAlcFirst = FALSE; @@ -12480,6 +12685,88 @@ UINT32 Oct6100ApiSetChannelLevelControl( return ulResult; } + /* Set the reset Rin ALC on tones. */ + if ( pSharedInfo->ImageInfo.fResetRinAlcOnTones == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.ResetRinAlcOnTonesFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.ResetRinAlcOnTonesFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.ResetRinAlcOnTonesFieldOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( f_pVqeConfig->fResetRinAlcOnTones == TRUE ) + { + ulTempData |= ( 1 << ulFeatureBitOffset ); + } + else /* if ( f_pVqeConfig->fResetRinAlcOnTones == FALSE ) */ + { + /* Disable ALC reset on tone detection. */ + ulTempData |= ( 0 << ulFeatureBitOffset ); + } + + /* Save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + /* Set the reset Sout ALC on tones. */ + if ( pSharedInfo->ImageInfo.fResetSoutAlcOnTones == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.ResetSoutAlcOnTonesFieldOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.ResetSoutAlcOnTonesFieldOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.ResetSoutAlcOnTonesFieldOfst.byFieldSize; + + /* First read the DWORD where the field is located.*/ + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + ulTempData &= (~ulMask); + + if ( f_pVqeConfig->fResetSoutAlcOnTones == TRUE ) + { + ulTempData |= ( 1 << ulFeatureBitOffset ); + } + else /* if ( f_pVqeConfig->fResetSoutAlcOnTones == FALSE ) */ + { + /* Disable ALC reset on tone detection. */ + ulTempData |= ( 0 << ulFeatureBitOffset ); + } + + /* Save the DWORD where the field is located.*/ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + /* Set the high level compensation threshold Db for the Sout port. */ if ( pSharedInfo->ImageInfo.fSoutHighLevelCompensation == TRUE ) { @@ -12516,7 +12803,9 @@ UINT32 Oct6100ApiSetChannelLevelControl( /* Check if have to clear the ALC-HLC status. */ if ( ( pSharedInfo->ImageInfo.fAlcHlcStatus == TRUE ) - && ( f_fClearAlcHlcStatusBit == TRUE ) ) + && ( ( f_fClearAlcHlcStatusBit == TRUE ) + + ) ) { ulFeatureBytesOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.usDwordOffset * 4; ulFeatureBitOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byBitOffset; @@ -13177,6 +13466,91 @@ UINT32 Oct6100ApiAssertChannelUnMuteParams( return cOCT6100_ERR_OK; } + +/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ + +Function: Oct6100ApiMuteSinWithFeatures + +Description: Mute or Unmute the sin with features port. + +------------------------------------------------------------------------------- +| Argument | Description +------------------------------------------------------------------------------- +f_pApiInstance Pointer to API instance. This memory is used to keep + the present state of the chip and all its resources. + +f_usChanIndex Resulting channel index where the muting should + be applied. +f_fEnableSinWithFeatures Whether to enable the feature or not. + +\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ +UINT32 Oct6100ApiMuteSinWithFeatures( + IN tPOCT6100_INSTANCE_API f_pApiInstance, + IN UINT16 f_usChanIndex, + IN BOOL f_fEnableSinWithFeatures ) +{ + tPOCT6100_SHARED_INFO pSharedInfo; + tPOCT6100_API_CHANNEL pChanEntry; + tOCT6100_WRITE_PARAMS WriteParams; + UINT32 ulResult; + + UINT32 ulTempData; + UINT32 ulBaseAddress; + UINT32 ulFeatureBytesOffset; + UINT32 ulFeatureBitOffset; + UINT32 ulFeatureFieldLength; + UINT32 ulMask; + + /* Get local pointer(s). */ + pSharedInfo = f_pApiInstance->pSharedInfo; + + WriteParams.pProcessContext = f_pApiInstance->pProcessContext; + + WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; + + /* Get a pointer to the channel's list entry. */ + mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex ) + + ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst; + + if ( pSharedInfo->ImageInfo.fSinMute == TRUE ) + { + ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinMuteOfst.usDwordOffset * 4; + ulFeatureBitOffset = pSharedInfo->MemoryMap.SinMuteOfst.byBitOffset; + ulFeatureFieldLength = pSharedInfo->MemoryMap.SinMuteOfst.byFieldSize; + + mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + &ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + + /* Clear previous value set in the feature field.*/ + mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); + + /* Clear the mute flag. */ + ulTempData &= (~ulMask); + + /* Set the mute flag on the Sin port.*/ + if ( f_fEnableSinWithFeatures == TRUE ) + ulTempData |= ( 0x1 << ulFeatureBitOffset ); + + /* Write the new DWORD where the field is located. */ + mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, + pChanEntry, + ulBaseAddress + ulFeatureBytesOffset, + ulTempData, + ulResult ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; + } + + return cOCT6100_ERR_OK; +} + + /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ Function: Oct6100ApiMuteChannelPorts @@ -13204,13 +13578,6 @@ UINT32 Oct6100ApiMuteChannelPorts( tPOCT6100_API_CHANNEL pChanEntry; tOCT6100_WRITE_PARAMS WriteParams; UINT32 ulResult; - - UINT32 ulTempData; - UINT32 ulBaseAddress; - UINT32 ulFeatureBytesOffset; - UINT32 ulFeatureBitOffset; - UINT32 ulFeatureFieldLength; - UINT32 ulMask; BOOL fDisableSinWithFeatures = FALSE; BOOL fEnableSinWithFeatures = FALSE; @@ -13390,41 +13757,9 @@ UINT32 Oct6100ApiMuteChannelPorts( /* Check if must enable or disable SIN mute with features. */ if ( fDisableSinWithFeatures == TRUE || fEnableSinWithFeatures == TRUE ) { - ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst; - - if ( pSharedInfo->ImageInfo.fSinMute == TRUE ) - { - ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinMuteOfst.usDwordOffset * 4; - ulFeatureBitOffset = pSharedInfo->MemoryMap.SinMuteOfst.byBitOffset; - ulFeatureFieldLength = pSharedInfo->MemoryMap.SinMuteOfst.byFieldSize; - - mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, - pChanEntry, - ulBaseAddress + ulFeatureBytesOffset, - &ulTempData, - ulResult ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; - - /* Clear previous value set in the feature field.*/ - mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask ); - - /* Clear the mute flag. */ - ulTempData &= (~ulMask); - - /* Set the mute flag on the Sin port.*/ - if ( fEnableSinWithFeatures == TRUE ) - ulTempData |= ( 0x1 << ulFeatureBitOffset ); - - /* Write the new DWORD where the field is located. */ - mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance, - pChanEntry, - ulBaseAddress + ulFeatureBytesOffset, - ulTempData, - ulResult ); - if ( ulResult != cOCT6100_ERR_OK ) - return ulResult; - } + ulResult = Oct6100ApiMuteSinWithFeatures( f_pApiInstance, f_usChanIndex, fEnableSinWithFeatures ); + if ( ulResult != cOCT6100_ERR_OK ) + return ulResult; } return cOCT6100_ERR_OK; -- cgit v1.2.3