~ubuntu-branches/ubuntu/quantal/zaptel/quantal

« back to all changes in this revision

Viewing changes to oct612x/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c

  • Committer: Bazaar Package Importer
  • Author(s): Tzafrir Cohen
  • Date: 2008-08-28 22:58:23 UTC
  • mfrom: (11.1.11 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080828225823-r8bdunirm8hmc76m
Tags: 1:1.4.11~dfsg-2
* Patch xpp_fxs_power: Fixed an issue with hook detection of the Astribank
  FXS module.
* Don't fail init.d script if fxotune fails. This may happen if running it
  when Asterisk is already running.
* Bump standards version to 3.8.0.0 .
* Ignore false lintian warning ("m-a a-i" has "a a").
* Patch xpp_fxo_cid_always: do always pass PCM if that's what the user
  asked.
* Patch vzaphfc_proc_root_dir: fix vzaphfc on 2.6.26.
* Patch wcte12xp_flags: Proper time for irq save flags.
* Patch headers_2627: Fix location of semaphore.h for 2.6.27 .
* Patch xpp_fxs_dtmf_leak: Don't play DTMFs to the wrong channel.
* Patch wctdm_fix_alarm: Fix sending channel alarms.
* Patch device_class_2626: Fix building 2.6.26 (Closes: #493397).
* Using dh_lintian for lintian overrides, hence requiring debhelper 6.0.7.
* Lintian: we know we have direct changes. Too bad we're half-upstream :-(
* Fix doc-base section names. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2
 
 
3
 
File: oct6100_channel.c
4
 
 
5
 
    Copyright (c) 2001-2006 Octasic Inc.
6
 
    
7
 
Description: 
8
 
 
9
 
        This file contains functions used to open, modify and close echo 
10
 
        cancellation channels.
11
 
 
12
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
13
 
free software; you can redistribute it and/or modify it under the terms of 
14
 
the GNU General Public License as published by the Free Software Foundation; 
15
 
either version 2 of the License, or (at your option) any later version.
16
 
 
17
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
18
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
19
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
20
 
for more details. 
21
 
 
22
 
You should have received a copy of the GNU General Public License 
23
 
along with the OCT6100 GPL API; if not, write to the Free Software 
24
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25
 
 
26
 
$Octasic_Release: OCT612xAPI-01.00-PR43 $
27
 
 
28
 
$Octasic_Revision: 469 $
29
 
 
30
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
31
 
 
32
 
 
33
 
/*****************************  INCLUDE FILES  *******************************/
34
 
 
35
 
#include <linux/slab.h>
36
 
 
37
 
#include "octdef.h"
38
 
 
39
 
#include "oct6100api/oct6100_defines.h"
40
 
#include "oct6100api/oct6100_errors.h"
41
 
#include "oct6100api/oct6100_apiud.h"
42
 
 
43
 
#include "apilib/octapi_llman.h"
44
 
 
45
 
#include "oct6100api/oct6100_tlv_inst.h"
46
 
#include "oct6100api/oct6100_chip_open_inst.h"
47
 
#include "oct6100api/oct6100_chip_stats_inst.h"
48
 
#include "oct6100api/oct6100_interrupts_inst.h"
49
 
#include "oct6100api/oct6100_remote_debug_inst.h"
50
 
#include "oct6100api/oct6100_debug_inst.h"
51
 
#include "oct6100api/oct6100_api_inst.h"
52
 
#include "oct6100api/oct6100_mixer_inst.h"
53
 
#include "oct6100api/oct6100_tsi_cnct_inst.h"
54
 
#include "oct6100api/oct6100_conf_bridge_inst.h"
55
 
#include "oct6100api/oct6100_tone_detection_inst.h"
56
 
#include "oct6100api/oct6100_phasing_tsst_inst.h"
57
 
#include "oct6100api/oct6100_tsst_inst.h"
58
 
#include "oct6100api/oct6100_channel_inst.h"
59
 
 
60
 
#include "oct6100api/oct6100_interrupts_pub.h"
61
 
#include "oct6100api/oct6100_chip_open_pub.h"
62
 
#include "oct6100api/oct6100_tsi_cnct_pub.h"
63
 
#include "oct6100api/oct6100_playout_buf_pub.h"
64
 
#include "oct6100api/oct6100_phasing_tsst_pub.h"
65
 
#include "oct6100api/oct6100_mixer_pub.h"
66
 
#include "oct6100api/oct6100_conf_bridge_pub.h"
67
 
#include "oct6100api/oct6100_tone_detection_pub.h"
68
 
#include "oct6100api/oct6100_channel_pub.h"
69
 
#include "oct6100api/oct6100_debug_pub.h"
70
 
 
71
 
#include "oct6100_chip_open_priv.h"
72
 
#include "oct6100_miscellaneous_priv.h"
73
 
#include "oct6100_memory_priv.h"
74
 
#include "oct6100_tsst_priv.h"
75
 
#include "oct6100_mixer_priv.h"
76
 
#include "oct6100_phasing_tsst_priv.h"
77
 
#include "oct6100_tsi_cnct_priv.h"
78
 
#include "oct6100_playout_buf_priv.h"
79
 
#include "oct6100_conf_bridge_priv.h"
80
 
#include "oct6100_tone_detection_priv.h"
81
 
#include "oct6100_channel_priv.h"
82
 
#include "oct6100_debug_priv.h"
83
 
 
84
 
 
85
 
/****************************  PUBLIC FUNCTIONS  ****************************/
86
 
 
87
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
88
 
 
89
 
Function:               Oct6100ChannelOpen
90
 
 
91
 
Description:    This function opens a echo cancellation channel. An echo cancellation
92
 
                                channel is constituted of two voice stream (RIN/ROUT and SIN/SOUT), and
93
 
                                an echo cancelling core.
94
 
 
95
 
-------------------------------------------------------------------------------
96
 
|       Argument                |       Description
97
 
-------------------------------------------------------------------------------
98
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
99
 
                                                present state of the chip and all its resources.
100
 
 
101
 
f_pChannelOpen                  Pointer to echo channel open structure.
102
 
 
103
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
104
 
#if !SKIP_Oct6100ChannelOpenDef
105
 
UINT32 Oct6100ChannelOpenDef(
106
 
                                IN OUT tPOCT6100_CHANNEL_OPEN                   f_pChannelOpen )
107
 
{
108
 
        f_pChannelOpen->pulChannelHndl                  = NULL;
109
 
        f_pChannelOpen->ulUserChanId                    = cOCT6100_INVALID_VALUE;
110
 
        f_pChannelOpen->ulEchoOperationMode             = cOCT6100_ECHO_OP_MODE_POWER_DOWN;
111
 
        f_pChannelOpen->fEnableToneDisabler             = FALSE;
112
 
        f_pChannelOpen->fEnableExtToneDetection         = FALSE;
113
 
 
114
 
        /* VQE configuration.*/
115
 
        f_pChannelOpen->VqeConfig.fSinDcOffsetRemoval = TRUE;
116
 
        f_pChannelOpen->VqeConfig.fRinDcOffsetRemoval = TRUE;
117
 
        f_pChannelOpen->VqeConfig.fRinLevelControl      = FALSE;
118
 
        f_pChannelOpen->VqeConfig.lRinLevelControlGainDb = 0;
119
 
        f_pChannelOpen->VqeConfig.fSoutLevelControl = FALSE;
120
 
        f_pChannelOpen->VqeConfig.lSoutLevelControlGainDb = 0;
121
 
        f_pChannelOpen->VqeConfig.fRinAutomaticLevelControl     = FALSE;
122
 
        f_pChannelOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = -20;
123
 
        f_pChannelOpen->VqeConfig.fSoutAutomaticLevelControl = FALSE;
124
 
        f_pChannelOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = -20;
125
 
        f_pChannelOpen->VqeConfig.ulAlcNoiseBleedOutTime = 0;
126
 
        f_pChannelOpen->VqeConfig.fRinHighLevelCompensation = FALSE;
127
 
        f_pChannelOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = -10;
128
 
        f_pChannelOpen->VqeConfig.fSoutAdaptiveNoiseReduction = FALSE;
129
 
        f_pChannelOpen->VqeConfig.fSoutNoiseBleaching = FALSE;
130
 
        f_pChannelOpen->VqeConfig.fSoutConferencingNoiseReduction = FALSE;
131
 
        f_pChannelOpen->VqeConfig.ulComfortNoiseMode = cOCT6100_COMFORT_NOISE_NORMAL;
132
 
        f_pChannelOpen->VqeConfig.fEnableNlp = TRUE;
133
 
        f_pChannelOpen->VqeConfig.fEnableTailDisplacement = FALSE;
134
 
        f_pChannelOpen->VqeConfig.ulTailDisplacement = cOCT6100_AUTO_SELECT_TAIL;
135
 
        f_pChannelOpen->VqeConfig.ulTailLength = cOCT6100_AUTO_SELECT_TAIL;
136
 
 
137
 
        f_pChannelOpen->VqeConfig.fDtmfToneRemoval = FALSE;
138
 
 
139
 
        f_pChannelOpen->VqeConfig.fAcousticEcho = FALSE;
140
 
        f_pChannelOpen->VqeConfig.lDefaultErlDb = -6;
141
 
        f_pChannelOpen->VqeConfig.ulAecTailLength = 128;
142
 
        f_pChannelOpen->VqeConfig.lAecDefaultErlDb = 0;
143
 
        f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorA = 1;
144
 
        f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorB = 0;  
145
 
        f_pChannelOpen->VqeConfig.ulDoubleTalkBehavior = cOCT6100_DOUBLE_TALK_BEH_NORMAL;
146
 
        f_pChannelOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = 0;
147
 
        f_pChannelOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = 0;
148
 
        f_pChannelOpen->VqeConfig.fSoutNaturalListenerEnhancement = FALSE;
149
 
        f_pChannelOpen->VqeConfig.fRoutNoiseReduction = FALSE;
150
 
        f_pChannelOpen->VqeConfig.lAnrSnrEnhancementDb = -18;
151
 
        f_pChannelOpen->VqeConfig.ulAnrVoiceNoiseSegregation = 6;
152
 
        f_pChannelOpen->VqeConfig.ulToneDisablerVqeActivationDelay = 300;
153
 
        f_pChannelOpen->VqeConfig.fEnableMusicProtection = FALSE;
154
 
        /* Older images have idle code detection hard-coded to enabled. */
155
 
        f_pChannelOpen->VqeConfig.fIdleCodeDetection = TRUE;
156
 
        f_pChannelOpen->VqeConfig.fResetRinAlcOnTones = FALSE;
157
 
        f_pChannelOpen->VqeConfig.fResetSoutAlcOnTones = FALSE;
158
 
 
159
 
        /* TDM configuration.*/
160
 
        f_pChannelOpen->TdmConfig.ulRinNumTssts = 1;
161
 
        f_pChannelOpen->TdmConfig.ulSinNumTssts = 1;
162
 
        f_pChannelOpen->TdmConfig.ulRoutNumTssts = 1;
163
 
        f_pChannelOpen->TdmConfig.ulSoutNumTssts = 1;
164
 
 
165
 
        f_pChannelOpen->TdmConfig.ulRinTimeslot = cOCT6100_UNASSIGNED;
166
 
        f_pChannelOpen->TdmConfig.ulRinStream = cOCT6100_UNASSIGNED;
167
 
        f_pChannelOpen->TdmConfig.ulRinPcmLaw = cOCT6100_PCM_U_LAW;
168
 
 
169
 
        f_pChannelOpen->TdmConfig.ulSinTimeslot = cOCT6100_UNASSIGNED;
170
 
        f_pChannelOpen->TdmConfig.ulSinStream = cOCT6100_UNASSIGNED;
171
 
        f_pChannelOpen->TdmConfig.ulSinPcmLaw = cOCT6100_PCM_U_LAW;
172
 
 
173
 
        f_pChannelOpen->TdmConfig.ulRoutTimeslot = cOCT6100_UNASSIGNED;
174
 
        f_pChannelOpen->TdmConfig.ulRoutStream = cOCT6100_UNASSIGNED;
175
 
        f_pChannelOpen->TdmConfig.ulRoutPcmLaw = cOCT6100_PCM_U_LAW;
176
 
 
177
 
        f_pChannelOpen->TdmConfig.ulSoutTimeslot = cOCT6100_UNASSIGNED;
178
 
        f_pChannelOpen->TdmConfig.ulSoutStream = cOCT6100_UNASSIGNED;
179
 
        f_pChannelOpen->TdmConfig.ulSoutPcmLaw = cOCT6100_PCM_U_LAW;
180
 
 
181
 
        /* CODEC configuration.*/
182
 
        f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition = cOCT6100_ADPCM_IN_LOW_BITS;
183
 
 
184
 
        f_pChannelOpen->CodecConfig.ulEncoderPort = cOCT6100_CHANNEL_PORT_SOUT;
185
 
        f_pChannelOpen->CodecConfig.ulEncodingRate = cOCT6100_G711_64KBPS;
186
 
        f_pChannelOpen->CodecConfig.ulDecoderPort = cOCT6100_CHANNEL_PORT_RIN;
187
 
        f_pChannelOpen->CodecConfig.ulDecodingRate = cOCT6100_G711_64KBPS;
188
 
 
189
 
        f_pChannelOpen->CodecConfig.fEnableSilenceSuppression = FALSE;
190
 
        f_pChannelOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
191
 
        f_pChannelOpen->CodecConfig.ulPhase = 1;
192
 
        f_pChannelOpen->CodecConfig.ulPhasingType = cOCT6100_NO_PHASING;
193
 
 
194
 
 
195
 
        return cOCT6100_ERR_OK;
196
 
}
197
 
#endif
198
 
 
199
 
#if !SKIP_Oct6100ChannelOpen
200
 
UINT32 Oct6100ChannelOpen(
201
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
202
 
                                IN OUT tPOCT6100_CHANNEL_OPEN                   f_pChannelOpen )
203
 
{
204
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
205
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
206
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
207
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
208
 
 
209
 
        /* Set the process context of the serialize structure.*/
210
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
211
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
212
 
 
213
 
        /* Seize all list semaphores needed by this function. */
214
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
215
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
216
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
217
 
        if ( ulSerRes == cOCT6100_ERR_OK )
218
 
        {
219
 
                /* Call the serialized function. */
220
 
                ulFncRes = Oct6100ChannelOpenSer( f_pApiInstance, f_pChannelOpen );
221
 
        }
222
 
        else
223
 
        {
224
 
                return ulSerRes;
225
 
        }
226
 
 
227
 
        /* Release the seized semaphores. */
228
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
229
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
230
 
 
231
 
        /* If an error occured then return the error code. */
232
 
        if ( ulSerRes != cOCT6100_ERR_OK )
233
 
                return ulSerRes;
234
 
        if ( ulFncRes != cOCT6100_ERR_OK )
235
 
                return ulFncRes;
236
 
 
237
 
        return cOCT6100_ERR_OK;
238
 
}
239
 
#endif
240
 
 
241
 
 
242
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
243
 
 
244
 
Function:               Oct6100ChannelClose
245
 
 
246
 
Description:    This function closes an echo canceller channel
247
 
 
248
 
-------------------------------------------------------------------------------
249
 
|       Argument                |       Description
250
 
-------------------------------------------------------------------------------
251
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
252
 
                                                present state of the chip and all its resources.
253
 
 
254
 
f_pChannelClose                 Pointer to channel close structure.
255
 
 
256
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
257
 
#if !SKIP_Oct6100ChannelCloseDef
258
 
UINT32 Oct6100ChannelCloseDef(
259
 
                                IN OUT tPOCT6100_CHANNEL_CLOSE          f_pChannelClose )
260
 
{
261
 
        f_pChannelClose->ulChannelHndl = cOCT6100_INVALID_HANDLE;
262
 
        
263
 
        return cOCT6100_ERR_OK;
264
 
}
265
 
#endif
266
 
 
267
 
#if !SKIP_Oct6100ChannelClose
268
 
UINT32 Oct6100ChannelClose(
269
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
270
 
                                IN tPOCT6100_CHANNEL_CLOSE                      f_pChannelClose )
271
 
{
272
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
273
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
274
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
275
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
276
 
 
277
 
        /* Set the process context of the serialize structure.*/
278
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
279
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
280
 
 
281
 
        /* Seize all list semaphores needed by this function. */
282
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
283
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
284
 
 
285
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
286
 
        if ( ulSerRes == cOCT6100_ERR_OK )
287
 
        {
288
 
                /* Call the serialized function. */
289
 
                ulFncRes = Oct6100ChannelCloseSer( f_pApiInstance, f_pChannelClose );
290
 
        }
291
 
        else
292
 
        {
293
 
                return ulSerRes;
294
 
        }
295
 
 
296
 
        /* Release the seized semaphores. */
297
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
298
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
299
 
 
300
 
        /* If an error occured then return the error code. */
301
 
        if ( ulSerRes != cOCT6100_ERR_OK )
302
 
                return ulSerRes;
303
 
        if ( ulFncRes != cOCT6100_ERR_OK )
304
 
                return ulFncRes;
305
 
 
306
 
        return cOCT6100_ERR_OK;
307
 
}
308
 
#endif
309
 
 
310
 
 
311
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
312
 
 
313
 
Function:               Oct6100ChannelModify
314
 
 
315
 
Description:    This function will modify the parameter of an echo channel. If 
316
 
                                the call to this channel allows the channel to go from power down
317
 
                                to enable, the API will activate it.
318
 
 
319
 
-------------------------------------------------------------------------------
320
 
|       Argument                |       Description
321
 
-------------------------------------------------------------------------------
322
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
323
 
                                                        present state of the chip and all its resources.
324
 
 
325
 
f_pChannelModify                        Pointer to echo channel change structure.
326
 
 
327
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
328
 
#if !SKIP_Oct6100ChannelModifyDef
329
 
UINT32 Oct6100ChannelModifyDef(
330
 
                                IN OUT tPOCT6100_CHANNEL_MODIFY                 f_pChannelModify )
331
 
{
332
 
        f_pChannelModify->ulChannelHndl = cOCT6100_INVALID_HANDLE;
333
 
        f_pChannelModify->ulUserChanId = cOCT6100_KEEP_PREVIOUS_SETTING;
334
 
        f_pChannelModify->ulEchoOperationMode = cOCT6100_KEEP_PREVIOUS_SETTING;
335
 
        
336
 
        f_pChannelModify->fEnableToneDisabler = cOCT6100_KEEP_PREVIOUS_SETTING;
337
 
 
338
 
        f_pChannelModify->fApplyToAllChannels = FALSE;
339
 
 
340
 
        f_pChannelModify->fDisableToneDetection = FALSE;
341
 
        f_pChannelModify->fStopBufferPlayout = FALSE;
342
 
        f_pChannelModify->fRemoveConfBridgeParticipant = FALSE;
343
 
        f_pChannelModify->fRemoveBroadcastTssts = FALSE;
344
 
 
345
 
        f_pChannelModify->fTdmConfigModified = FALSE;
346
 
        f_pChannelModify->fVqeConfigModified = FALSE;
347
 
        f_pChannelModify->fCodecConfigModified = FALSE;
348
 
 
349
 
        /* VQE config. */
350
 
        f_pChannelModify->VqeConfig.fSinDcOffsetRemoval = cOCT6100_KEEP_PREVIOUS_SETTING;
351
 
        f_pChannelModify->VqeConfig.fRinDcOffsetRemoval = cOCT6100_KEEP_PREVIOUS_SETTING;
352
 
        f_pChannelModify->VqeConfig.fRinLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
353
 
        f_pChannelModify->VqeConfig.lRinLevelControlGainDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
354
 
        f_pChannelModify->VqeConfig.fSoutLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
355
 
        f_pChannelModify->VqeConfig.lSoutLevelControlGainDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
356
 
        f_pChannelModify->VqeConfig.fRinAutomaticLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
357
 
        f_pChannelModify->VqeConfig.lRinAutomaticLevelControlTargetDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
358
 
        f_pChannelModify->VqeConfig.fSoutAutomaticLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
359
 
        f_pChannelModify->VqeConfig.lSoutAutomaticLevelControlTargetDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
360
 
        f_pChannelModify->VqeConfig.ulAlcNoiseBleedOutTime = cOCT6100_KEEP_PREVIOUS_SETTING;
361
 
        f_pChannelModify->VqeConfig.fRinHighLevelCompensation = cOCT6100_KEEP_PREVIOUS_SETTING;
362
 
        f_pChannelModify->VqeConfig.lRinHighLevelCompensationThresholdDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
363
 
        f_pChannelModify->VqeConfig.fSoutAdaptiveNoiseReduction = cOCT6100_KEEP_PREVIOUS_SETTING;
364
 
        f_pChannelModify->VqeConfig.fSoutNoiseBleaching = cOCT6100_KEEP_PREVIOUS_SETTING;
365
 
        f_pChannelModify->VqeConfig.fSoutConferencingNoiseReduction     = cOCT6100_KEEP_PREVIOUS_SETTING;
366
 
        f_pChannelModify->VqeConfig.ulComfortNoiseMode = cOCT6100_KEEP_PREVIOUS_SETTING;
367
 
        f_pChannelModify->VqeConfig.fEnableNlp = cOCT6100_KEEP_PREVIOUS_SETTING;
368
 
        f_pChannelModify->VqeConfig.fEnableTailDisplacement = cOCT6100_KEEP_PREVIOUS_SETTING;
369
 
        f_pChannelModify->VqeConfig.ulTailDisplacement = cOCT6100_KEEP_PREVIOUS_SETTING;
370
 
 
371
 
        f_pChannelModify->VqeConfig.fDtmfToneRemoval = cOCT6100_KEEP_PREVIOUS_SETTING;
372
 
 
373
 
        f_pChannelModify->VqeConfig.fAcousticEcho = cOCT6100_KEEP_PREVIOUS_SETTING;
374
 
        f_pChannelModify->VqeConfig.lDefaultErlDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; 
375
 
        f_pChannelModify->VqeConfig.ulAecTailLength = cOCT6100_KEEP_PREVIOUS_SETTING;
376
 
        f_pChannelModify->VqeConfig.lAecDefaultErlDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
377
 
        f_pChannelModify->VqeConfig.ulNonLinearityBehaviorA = cOCT6100_KEEP_PREVIOUS_SETTING;
378
 
        f_pChannelModify->VqeConfig.ulNonLinearityBehaviorB = cOCT6100_KEEP_PREVIOUS_SETTING;
379
 
        f_pChannelModify->VqeConfig.ulDoubleTalkBehavior = cOCT6100_KEEP_PREVIOUS_SETTING;
380
 
        f_pChannelModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = cOCT6100_KEEP_PREVIOUS_SETTING;
381
 
        f_pChannelModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = cOCT6100_KEEP_PREVIOUS_SETTING;
382
 
        f_pChannelModify->VqeConfig.fSoutNaturalListenerEnhancement = cOCT6100_KEEP_PREVIOUS_SETTING;
383
 
        f_pChannelModify->VqeConfig.fRoutNoiseReduction = cOCT6100_KEEP_PREVIOUS_SETTING;
384
 
        f_pChannelModify->VqeConfig.lAnrSnrEnhancementDb = cOCT6100_KEEP_PREVIOUS_SETTING;
385
 
        f_pChannelModify->VqeConfig.ulAnrVoiceNoiseSegregation = cOCT6100_KEEP_PREVIOUS_SETTING;
386
 
        f_pChannelModify->VqeConfig.ulToneDisablerVqeActivationDelay = cOCT6100_KEEP_PREVIOUS_SETTING;
387
 
        f_pChannelModify->VqeConfig.fEnableMusicProtection = cOCT6100_KEEP_PREVIOUS_SETTING;
388
 
        f_pChannelModify->VqeConfig.fIdleCodeDetection = cOCT6100_KEEP_PREVIOUS_SETTING;
389
 
        f_pChannelModify->VqeConfig.fResetRinAlcOnTones = cOCT6100_KEEP_PREVIOUS_SETTING;
390
 
        f_pChannelModify->VqeConfig.fResetSoutAlcOnTones = cOCT6100_KEEP_PREVIOUS_SETTING;
391
 
 
392
 
        /* TDM config. */
393
 
        f_pChannelModify->TdmConfig.ulRinNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
394
 
        f_pChannelModify->TdmConfig.ulSinNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
395
 
        f_pChannelModify->TdmConfig.ulRoutNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
396
 
        f_pChannelModify->TdmConfig.ulSoutNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
397
 
 
398
 
        f_pChannelModify->TdmConfig.ulRinTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
399
 
        f_pChannelModify->TdmConfig.ulRinStream = cOCT6100_KEEP_PREVIOUS_SETTING;
400
 
        f_pChannelModify->TdmConfig.ulRinPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
401
 
 
402
 
        f_pChannelModify->TdmConfig.ulSinTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
403
 
        f_pChannelModify->TdmConfig.ulSinStream = cOCT6100_KEEP_PREVIOUS_SETTING;
404
 
        f_pChannelModify->TdmConfig.ulSinPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
405
 
 
406
 
        f_pChannelModify->TdmConfig.ulRoutTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
407
 
        f_pChannelModify->TdmConfig.ulRoutStream = cOCT6100_KEEP_PREVIOUS_SETTING;
408
 
        f_pChannelModify->TdmConfig.ulRoutPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
409
 
 
410
 
        f_pChannelModify->TdmConfig.ulSoutTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
411
 
        f_pChannelModify->TdmConfig.ulSoutStream = cOCT6100_KEEP_PREVIOUS_SETTING;
412
 
        f_pChannelModify->TdmConfig.ulSoutPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
413
 
 
414
 
        /* CODEC config. */
415
 
        f_pChannelModify->CodecConfig.ulEncoderPort = cOCT6100_KEEP_PREVIOUS_SETTING;
416
 
        f_pChannelModify->CodecConfig.ulEncodingRate = cOCT6100_KEEP_PREVIOUS_SETTING;
417
 
        f_pChannelModify->CodecConfig.ulDecoderPort = cOCT6100_KEEP_PREVIOUS_SETTING;
418
 
        f_pChannelModify->CodecConfig.ulDecodingRate = cOCT6100_KEEP_PREVIOUS_SETTING;
419
 
 
420
 
        f_pChannelModify->CodecConfig.fEnableSilenceSuppression = cOCT6100_KEEP_PREVIOUS_SETTING;
421
 
        f_pChannelModify->CodecConfig.ulPhasingTsstHndl = cOCT6100_KEEP_PREVIOUS_SETTING;
422
 
        f_pChannelModify->CodecConfig.ulPhase = cOCT6100_KEEP_PREVIOUS_SETTING;
423
 
        f_pChannelModify->CodecConfig.ulPhasingType = cOCT6100_KEEP_PREVIOUS_SETTING;
424
 
 
425
 
 
426
 
        return cOCT6100_ERR_OK;
427
 
}
428
 
#endif
429
 
 
430
 
#if !SKIP_Oct6100ChannelModify
431
 
UINT32 Oct6100ChannelModify(
432
 
                                IN tPOCT6100_INSTANCE_API               f_pApiInstance,
433
 
                                IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify )
434
 
{
435
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
436
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
437
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
438
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
439
 
 
440
 
        /* Set the process context of the serialize structure.*/
441
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
442
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
443
 
 
444
 
        /* Seize all list semaphores needed by this function. */
445
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
446
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
447
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
448
 
        if ( ulSerRes == cOCT6100_ERR_OK )
449
 
        {
450
 
                /* Check the apply to all channels flag first. */
451
 
                if ( f_pChannelModify->fApplyToAllChannels != TRUE &&
452
 
                        f_pChannelModify->fApplyToAllChannels != FALSE )
453
 
                        return cOCT6100_ERR_CHANNEL_APPLY_TO_ALL_CHANNELS;
454
 
 
455
 
                /* Check if must apply modification to all channels. */
456
 
                if ( f_pChannelModify->fApplyToAllChannels == TRUE )
457
 
                {
458
 
                        tPOCT6100_API_CHANNEL   pChanEntry;
459
 
                        UINT16                                  usChanIndex;
460
 
 
461
 
                        /* Loop through all channels and look for the opened ones. */
462
 
                        for ( usChanIndex = 0; usChanIndex < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; usChanIndex++ )
463
 
                        {
464
 
                                mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, usChanIndex );
465
 
 
466
 
                                /* Check if this one is opened. */
467
 
                                if ( pChanEntry->fReserved == TRUE )
468
 
                                {
469
 
                                        /* Channel is opened.  Form handle and call actual modify function. */
470
 
                                        f_pChannelModify->ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | usChanIndex;
471
 
 
472
 
                                        /* Call the serialized function. */
473
 
                                        ulFncRes = Oct6100ChannelModifySer( f_pApiInstance, f_pChannelModify );
474
 
                                        if ( ulFncRes != cOCT6100_ERR_OK )
475
 
                                                break;
476
 
                                }
477
 
                        }
478
 
                }
479
 
                else /* if ( f_pChannelModify->fApplyToAllChannels == FALSE ) */
480
 
                {
481
 
                        /* Call the serialized function. */
482
 
                        ulFncRes = Oct6100ChannelModifySer( f_pApiInstance, f_pChannelModify );
483
 
                }
484
 
        }
485
 
        else
486
 
        {
487
 
                return ulSerRes;
488
 
        }
489
 
 
490
 
        /* Release the seized semaphores. */
491
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
492
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
493
 
 
494
 
        /* If an error occured then return the error code. */
495
 
        if ( ulSerRes != cOCT6100_ERR_OK )
496
 
                return ulSerRes;
497
 
        if ( ulFncRes != cOCT6100_ERR_OK )
498
 
                return ulFncRes;
499
 
 
500
 
        return cOCT6100_ERR_OK;
501
 
}
502
 
#endif
503
 
 
504
 
 
505
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
506
 
 
507
 
Function:               Oct6100ChannelCreateBiDir
508
 
 
509
 
Description:    This function creates a bidirectional channel using two standard
510
 
                                echo cancellation channel.
511
 
 
512
 
-------------------------------------------------------------------------------
513
 
|       Argument                |       Description
514
 
-------------------------------------------------------------------------------
515
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
516
 
                                                present state of the chip and all its resources.
517
 
 
518
 
f_pChannelCreateBiDir   Pointer to channel create BiDir structure.
519
 
 
520
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
521
 
#if !SKIP_Oct6100ChannelCreateBiDirDef
522
 
UINT32 Oct6100ChannelCreateBiDirDef(
523
 
                        IN OUT  tPOCT6100_CHANNEL_CREATE_BIDIR          f_pChannelCreateBiDir )
524
 
{
525
 
        f_pChannelCreateBiDir->pulBiDirChannelHndl = NULL;
526
 
 
527
 
        f_pChannelCreateBiDir->ulFirstChannelHndl = cOCT6100_INVALID_HANDLE;
528
 
        f_pChannelCreateBiDir->ulSecondChannelHndl = cOCT6100_INVALID_HANDLE;
529
 
 
530
 
 
531
 
        return cOCT6100_ERR_OK;
532
 
}
533
 
#endif
534
 
 
535
 
#if !SKIP_Oct6100ChannelCreateBiDir
536
 
UINT32 Oct6100ChannelCreateBiDir(       
537
 
                        IN tPOCT6100_INSTANCE_API                                       f_pApiInstance,
538
 
                        IN OUT tPOCT6100_CHANNEL_CREATE_BIDIR           f_pChannelCreateBiDir )
539
 
{
540
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
541
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
542
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
543
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
544
 
        
545
 
        /* Set the process context of the serialize structure.*/
546
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
547
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
548
 
 
549
 
        /* Seize all list semaphores needed by this function. */
550
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
551
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
552
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
553
 
        if ( ulSerRes == cOCT6100_ERR_OK )
554
 
        {
555
 
                /* Call the serialized function. */
556
 
                ulFncRes = Oct6100ChannelCreateBiDirSer( f_pApiInstance, f_pChannelCreateBiDir );
557
 
        }
558
 
        else
559
 
        {
560
 
                return ulSerRes;
561
 
        }
562
 
 
563
 
        /* Release the seized semaphores. */
564
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
565
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
566
 
 
567
 
        /* If an error occured then return the error code. */
568
 
        if ( ulSerRes != cOCT6100_ERR_OK )
569
 
                return ulSerRes;
570
 
        if ( ulFncRes != cOCT6100_ERR_OK )
571
 
                return ulFncRes;
572
 
 
573
 
        return cOCT6100_ERR_OK;
574
 
}
575
 
#endif
576
 
 
577
 
 
578
 
 
579
 
 
580
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
581
 
 
582
 
Function:               Oct6100ChannelDestroyBiDir
583
 
 
584
 
Description:    This function destroys a bidirectional channel.
585
 
 
586
 
-------------------------------------------------------------------------------
587
 
|       Argument                |       Description
588
 
-------------------------------------------------------------------------------
589
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
590
 
                                                present state of the chip and all its resources.
591
 
 
592
 
f_pChannelDestroyBiDir  Pointer to channel destroy BiDir structure.
593
 
 
594
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
595
 
#if !SKIP_Oct6100ChannelDestroyBiDirDef
596
 
UINT32 Oct6100ChannelDestroyBiDirDef(
597
 
                        IN OUT  tPOCT6100_CHANNEL_DESTROY_BIDIR         f_pChannelDestroyBiDir )
598
 
{
599
 
        f_pChannelDestroyBiDir->ulBiDirChannelHndl = cOCT6100_INVALID_HANDLE;
600
 
 
601
 
        return cOCT6100_ERR_OK;
602
 
}
603
 
#endif
604
 
 
605
 
#if !SKIP_Oct6100ChannelDestroyBiDir
606
 
UINT32 Oct6100ChannelDestroyBiDir(      
607
 
                        IN tPOCT6100_INSTANCE_API                                       f_pApiInstance,
608
 
                        IN OUT tPOCT6100_CHANNEL_DESTROY_BIDIR          f_pChannelDestroyBiDir )
609
 
{
610
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
611
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
612
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
613
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
614
 
 
615
 
        /* Set the process context of the serialize structure.*/
616
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
617
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
618
 
 
619
 
        /* Seize all list semaphores needed by this function. */
620
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
621
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
622
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
623
 
        if ( ulSerRes == cOCT6100_ERR_OK )
624
 
        {
625
 
                /* Call the serialized function. */
626
 
                ulFncRes = Oct6100ChannelDestroyBiDirSer( f_pApiInstance, f_pChannelDestroyBiDir );
627
 
        }
628
 
        else
629
 
        {
630
 
                return ulSerRes;
631
 
        }
632
 
 
633
 
        /* Release the seized semaphores. */
634
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
635
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
636
 
 
637
 
        /* If an error occured then return the error code. */
638
 
        if ( ulSerRes != cOCT6100_ERR_OK )
639
 
                return ulSerRes;
640
 
        if ( ulFncRes != cOCT6100_ERR_OK )
641
 
                return ulFncRes;
642
 
 
643
 
        return cOCT6100_ERR_OK;
644
 
}
645
 
#endif
646
 
 
647
 
 
648
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
649
 
 
650
 
Function:               Oct6100ChannelBroadcastTsstAdd
651
 
 
652
 
Description:    This function adds a TSST to one of the two output ports of a channel.
653
 
                                This TSST can never be modified by a call to Oct6100ChannelModify.
654
 
 
655
 
-------------------------------------------------------------------------------
656
 
|       Argument                |       Description
657
 
-------------------------------------------------------------------------------
658
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
659
 
                                                        the present state of the chip and all its resources.
660
 
 
661
 
f_pChannelBroadcastTsstAdd      Pointer to the an Add Broadcast TSST structure.
662
 
 
663
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
664
 
#if !SKIP_Oct6100ChannelBroadcastTsstAddDef
665
 
UINT32 Oct6100ChannelBroadcastTsstAddDef(
666
 
                        tPOCT6100_CHANNEL_BROADCAST_TSST_ADD            f_pChannelBroadcastTsstAdd )
667
 
{
668
 
        f_pChannelBroadcastTsstAdd->ulChannelHndl = cOCT6100_INVALID_HANDLE;
669
 
 
670
 
        f_pChannelBroadcastTsstAdd->ulPort = cOCT6100_INVALID_PORT;
671
 
        f_pChannelBroadcastTsstAdd->ulTimeslot = cOCT6100_INVALID_TIMESLOT;
672
 
        f_pChannelBroadcastTsstAdd->ulStream = cOCT6100_INVALID_STREAM;
673
 
 
674
 
        return cOCT6100_ERR_OK;
675
 
 
676
 
}
677
 
#endif
678
 
 
679
 
#if !SKIP_Oct6100ChannelBroadcastTsstAdd
680
 
UINT32 Oct6100ChannelBroadcastTsstAdd(
681
 
                        tPOCT6100_INSTANCE_API                                          f_pApiInstance,
682
 
                        tPOCT6100_CHANNEL_BROADCAST_TSST_ADD            f_pChannelBroadcastTsstAdd )
683
 
{
684
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
685
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
686
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
687
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
688
 
 
689
 
        /* Set the process context of the serialize structure.*/
690
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
691
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
692
 
 
693
 
        /* Seize all list semaphores needed by this function. */
694
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
695
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
696
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
697
 
        if ( ulSerRes == cOCT6100_ERR_OK )
698
 
        {
699
 
                /* Call the serialized function. */
700
 
                ulFncRes = Oct6100ChannelBroadcastTsstAddSer( f_pApiInstance, f_pChannelBroadcastTsstAdd );
701
 
        }
702
 
        else
703
 
        {
704
 
                return ulSerRes;
705
 
        }
706
 
 
707
 
        /* Release the seized semaphores. */
708
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
709
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
710
 
 
711
 
        /* If an error occured then return the error code. */
712
 
        if ( ulSerRes != cOCT6100_ERR_OK )
713
 
                return ulSerRes;
714
 
        if ( ulFncRes != cOCT6100_ERR_OK )
715
 
                return ulFncRes;
716
 
 
717
 
        return cOCT6100_ERR_OK; 
718
 
}
719
 
#endif
720
 
 
721
 
 
722
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
723
 
 
724
 
Function:               Oct6100ChannelBroadcastTsstRemove
725
 
 
726
 
Description:    This function removes a TSST from one of the two output ports of a channel.
727
 
 
728
 
-------------------------------------------------------------------------------
729
 
|       Argument                |       Description
730
 
-------------------------------------------------------------------------------
731
 
f_pApiInstance                                  Pointer to API instance. This memory is used to keep
732
 
                                                                the present state of the chip and all its resources.
733
 
 
734
 
f_pChannelBroadcastTsstRemove   Pointer to the a Remove Broadcast TSST structure.
735
 
 
736
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
737
 
#if !SKIP_Oct6100ChannelBroadcastTsstRemoveDef
738
 
UINT32 Oct6100ChannelBroadcastTsstRemoveDef(
739
 
                        tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE         f_pChannelBroadcastTsstRemove )
740
 
{
741
 
        f_pChannelBroadcastTsstRemove->ulChannelHndl = cOCT6100_INVALID_HANDLE;
742
 
 
743
 
        f_pChannelBroadcastTsstRemove->ulPort = cOCT6100_INVALID_PORT;
744
 
        f_pChannelBroadcastTsstRemove->ulTimeslot = cOCT6100_INVALID_TIMESLOT;
745
 
        f_pChannelBroadcastTsstRemove->ulStream = cOCT6100_INVALID_STREAM;
746
 
        
747
 
        f_pChannelBroadcastTsstRemove->fRemoveAll = FALSE;
748
 
 
749
 
        return cOCT6100_ERR_OK;
750
 
}
751
 
#endif
752
 
 
753
 
 
754
 
#if !SKIP_Oct6100ChannelBroadcastTsstRemove
755
 
UINT32 Oct6100ChannelBroadcastTsstRemove(
756
 
                        tPOCT6100_INSTANCE_API                                          f_pApiInstance,
757
 
                        tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE         f_pChannelBroadcastTsstRemove )
758
 
{
759
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
760
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
761
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
762
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
763
 
 
764
 
        /* Set the process context of the serialize structure.*/
765
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
766
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
767
 
 
768
 
        /* Seize all list semaphores needed by this function. */
769
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
770
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
771
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
772
 
        if ( ulSerRes == cOCT6100_ERR_OK )
773
 
        {
774
 
                /* Call the serialized function. */
775
 
                ulFncRes = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, f_pChannelBroadcastTsstRemove );
776
 
        }
777
 
        else
778
 
        {
779
 
                return ulSerRes;
780
 
        }
781
 
 
782
 
        /* Release the seized semaphores. */
783
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
784
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
785
 
 
786
 
        /* If an error occured then return the error code. */
787
 
        if ( ulSerRes != cOCT6100_ERR_OK )
788
 
                return ulSerRes;
789
 
        if ( ulFncRes != cOCT6100_ERR_OK )
790
 
                return ulFncRes;
791
 
 
792
 
        return cOCT6100_ERR_OK; 
793
 
}
794
 
#endif
795
 
 
796
 
 
797
 
 
798
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
799
 
 
800
 
Function:               Oct6100ChannelGetStats
801
 
 
802
 
Description:    This function retrieves all the config and stats related to the channel
803
 
                                designated by ulChannelHndl.
804
 
 
805
 
-------------------------------------------------------------------------------
806
 
|       Argument                |       Description
807
 
-------------------------------------------------------------------------------
808
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
809
 
                                                present state of the chip and all its resources.
810
 
 
811
 
f_pChannelStats                 Pointer to a tOCT6100_CHANNEL_STATS structure.
812
 
 
813
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
814
 
#if !SKIP_Oct6100ChannelGetStatsDef
815
 
UINT32 Oct6100ChannelGetStatsDef(
816
 
                                IN OUT tPOCT6100_CHANNEL_STATS                  f_pChannelStats )
817
 
{
818
 
        f_pChannelStats->fResetStats = FALSE;
819
 
 
820
 
        f_pChannelStats->ulChannelHndl = cOCT6100_INVALID_HANDLE;
821
 
        f_pChannelStats->ulUserChanId = cOCT6100_INVALID_STAT;
822
 
        f_pChannelStats->ulEchoOperationMode = cOCT6100_INVALID_STAT;
823
 
        f_pChannelStats->fEnableToneDisabler = FALSE;
824
 
        f_pChannelStats->ulMutePortsMask = cOCT6100_CHANNEL_MUTE_PORT_NONE;
825
 
        f_pChannelStats->fEnableExtToneDetection = FALSE;
826
 
 
827
 
        /* VQE configuration.*/
828
 
        f_pChannelStats->VqeConfig.fEnableNlp = FALSE;
829
 
        f_pChannelStats->VqeConfig.fEnableTailDisplacement = FALSE;
830
 
        f_pChannelStats->VqeConfig.ulTailDisplacement = cOCT6100_INVALID_STAT;
831
 
        f_pChannelStats->VqeConfig.ulTailLength = cOCT6100_INVALID_STAT;
832
 
 
833
 
        f_pChannelStats->VqeConfig.fSinDcOffsetRemoval = FALSE;
834
 
        f_pChannelStats->VqeConfig.fRinDcOffsetRemoval = FALSE;
835
 
        f_pChannelStats->VqeConfig.fRinLevelControl = FALSE;
836
 
        f_pChannelStats->VqeConfig.fSoutLevelControl = FALSE;
837
 
        f_pChannelStats->VqeConfig.fRinAutomaticLevelControl = FALSE;
838
 
        f_pChannelStats->VqeConfig.fSoutAutomaticLevelControl = FALSE;
839
 
        f_pChannelStats->VqeConfig.ulAlcNoiseBleedOutTime = cOCT6100_INVALID_STAT;
840
 
        f_pChannelStats->VqeConfig.fRinHighLevelCompensation = FALSE;
841
 
        f_pChannelStats->VqeConfig.fAcousticEcho = FALSE;
842
 
        f_pChannelStats->VqeConfig.fSoutAdaptiveNoiseReduction = FALSE;
843
 
        f_pChannelStats->VqeConfig.fDtmfToneRemoval = FALSE;
844
 
 
845
 
        f_pChannelStats->VqeConfig.fSoutNoiseBleaching = FALSE;
846
 
        f_pChannelStats->VqeConfig.fSoutConferencingNoiseReduction = FALSE;
847
 
        
848
 
        f_pChannelStats->VqeConfig.ulComfortNoiseMode = cOCT6100_INVALID_STAT;
849
 
        f_pChannelStats->VqeConfig.ulNonLinearityBehaviorA = cOCT6100_INVALID_STAT;
850
 
        f_pChannelStats->VqeConfig.ulNonLinearityBehaviorB = cOCT6100_INVALID_STAT;
851
 
        f_pChannelStats->VqeConfig.ulDoubleTalkBehavior = cOCT6100_INVALID_STAT;
852
 
        f_pChannelStats->VqeConfig.lRinLevelControlGainDb = cOCT6100_INVALID_SIGNED_STAT;
853
 
        f_pChannelStats->VqeConfig.lSoutLevelControlGainDb = cOCT6100_INVALID_SIGNED_STAT;
854
 
        f_pChannelStats->VqeConfig.lRinAutomaticLevelControlTargetDb = cOCT6100_INVALID_SIGNED_STAT;
855
 
        f_pChannelStats->VqeConfig.lSoutAutomaticLevelControlTargetDb = cOCT6100_INVALID_SIGNED_STAT;
856
 
        f_pChannelStats->VqeConfig.lRinHighLevelCompensationThresholdDb = cOCT6100_INVALID_SIGNED_STAT;
857
 
        f_pChannelStats->VqeConfig.lDefaultErlDb = cOCT6100_INVALID_SIGNED_STAT;
858
 
        f_pChannelStats->VqeConfig.lAecDefaultErlDb = cOCT6100_INVALID_SIGNED_STAT;
859
 
        f_pChannelStats->VqeConfig.ulAecTailLength = cOCT6100_INVALID_STAT;
860
 
        f_pChannelStats->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = cOCT6100_INVALID_STAT;
861
 
        f_pChannelStats->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = cOCT6100_INVALID_STAT;
862
 
        f_pChannelStats->VqeConfig.fSoutNaturalListenerEnhancement = FALSE;
863
 
        f_pChannelStats->VqeConfig.fRoutNoiseReduction = FALSE;
864
 
        f_pChannelStats->VqeConfig.lAnrSnrEnhancementDb = cOCT6100_INVALID_SIGNED_STAT;
865
 
        f_pChannelStats->VqeConfig.ulAnrVoiceNoiseSegregation = cOCT6100_INVALID_STAT;
866
 
        f_pChannelStats->VqeConfig.ulToneDisablerVqeActivationDelay = cOCT6100_INVALID_STAT;
867
 
        f_pChannelStats->VqeConfig.fEnableMusicProtection = FALSE;
868
 
        f_pChannelStats->VqeConfig.fIdleCodeDetection = FALSE;
869
 
        f_pChannelStats->VqeConfig.fResetRinAlcOnTones = FALSE;
870
 
        f_pChannelStats->VqeConfig.fResetSoutAlcOnTones = FALSE;
871
 
 
872
 
 
873
 
 
874
 
        /* TDM configuration.*/
875
 
        f_pChannelStats->TdmConfig.ulMaxBroadcastTssts = 0;
876
 
        f_pChannelStats->TdmConfig.fMoreRoutBroadcastTssts = FALSE;
877
 
        f_pChannelStats->TdmConfig.fMoreSoutBroadcastTssts = FALSE;
878
 
 
879
 
        f_pChannelStats->TdmConfig.ulNumRoutBroadcastTssts = 0;
880
 
        f_pChannelStats->TdmConfig.ulNumSoutBroadcastTssts = 0;
881
 
        
882
 
        f_pChannelStats->TdmConfig.ulRinNumTssts = cOCT6100_INVALID_STAT;
883
 
        f_pChannelStats->TdmConfig.ulSinNumTssts = cOCT6100_INVALID_STAT;
884
 
        f_pChannelStats->TdmConfig.ulRoutNumTssts = cOCT6100_INVALID_STAT;
885
 
        f_pChannelStats->TdmConfig.ulSoutNumTssts = cOCT6100_INVALID_STAT;
886
 
 
887
 
        f_pChannelStats->TdmConfig.ulRinTimeslot = cOCT6100_INVALID_STAT;
888
 
        f_pChannelStats->TdmConfig.ulRinStream = cOCT6100_INVALID_STAT;
889
 
        f_pChannelStats->TdmConfig.ulRinPcmLaw = cOCT6100_INVALID_STAT;
890
 
 
891
 
        f_pChannelStats->TdmConfig.ulSinTimeslot = cOCT6100_INVALID_STAT;
892
 
        f_pChannelStats->TdmConfig.ulSinStream = cOCT6100_INVALID_STAT;
893
 
        f_pChannelStats->TdmConfig.ulSinPcmLaw = cOCT6100_INVALID_STAT;
894
 
 
895
 
        f_pChannelStats->TdmConfig.ulRoutTimeslot = cOCT6100_INVALID_STAT;
896
 
        f_pChannelStats->TdmConfig.ulRoutStream = cOCT6100_INVALID_STAT;
897
 
        f_pChannelStats->TdmConfig.ulRoutPcmLaw = cOCT6100_INVALID_STAT;
898
 
        
899
 
        f_pChannelStats->TdmConfig.pulRoutBroadcastTimeslot = NULL;
900
 
        f_pChannelStats->TdmConfig.pulRoutBroadcastStream = NULL;
901
 
        
902
 
        f_pChannelStats->TdmConfig.ulSoutTimeslot = cOCT6100_INVALID_STAT;
903
 
        f_pChannelStats->TdmConfig.ulSoutStream = cOCT6100_INVALID_STAT;
904
 
        f_pChannelStats->TdmConfig.ulSoutPcmLaw = cOCT6100_INVALID_STAT;
905
 
 
906
 
        f_pChannelStats->TdmConfig.pulSoutBroadcastTimeslot = NULL;
907
 
        f_pChannelStats->TdmConfig.pulSoutBroadcastStream = NULL;
908
 
        
909
 
 
910
 
        /* CODEC configuration.*/
911
 
        f_pChannelStats->CodecConfig.ulAdpcmNibblePosition = cOCT6100_INVALID_STAT;
912
 
 
913
 
        f_pChannelStats->CodecConfig.ulEncoderPort = cOCT6100_INVALID_STAT;
914
 
        f_pChannelStats->CodecConfig.ulEncodingRate = cOCT6100_INVALID_STAT;
915
 
        f_pChannelStats->CodecConfig.ulDecoderPort = cOCT6100_INVALID_STAT;
916
 
        f_pChannelStats->CodecConfig.ulDecodingRate = cOCT6100_INVALID_STAT;
917
 
 
918
 
        f_pChannelStats->CodecConfig.fEnableSilenceSuppression = FALSE;
919
 
        f_pChannelStats->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_STAT;
920
 
        f_pChannelStats->CodecConfig.ulPhase = cOCT6100_INVALID_STAT;
921
 
        f_pChannelStats->CodecConfig.ulPhasingType = cOCT6100_INVALID_STAT;
922
 
 
923
 
        f_pChannelStats->ulNumEchoPathChanges = cOCT6100_INVALID_STAT;
924
 
        f_pChannelStats->ulToneDisablerStatus = cOCT6100_INVALID_STAT;
925
 
        f_pChannelStats->fEchoCancellerConverged = FALSE;
926
 
        f_pChannelStats->fSinVoiceDetected = FALSE;
927
 
        f_pChannelStats->lCurrentERL  = cOCT6100_INVALID_SIGNED_STAT;
928
 
        f_pChannelStats->lCurrentERLE = cOCT6100_INVALID_SIGNED_STAT;
929
 
        f_pChannelStats->ulCurrentEchoDelay = cOCT6100_INVALID_STAT;
930
 
        
931
 
        f_pChannelStats->lMaxERL  = cOCT6100_INVALID_SIGNED_STAT;
932
 
        f_pChannelStats->lMaxERLE = cOCT6100_INVALID_SIGNED_STAT;
933
 
        f_pChannelStats->ulMaxEchoDelay = cOCT6100_INVALID_STAT;
934
 
        
935
 
        f_pChannelStats->lRinLevel = cOCT6100_INVALID_SIGNED_STAT;
936
 
        f_pChannelStats->lSinLevel = cOCT6100_INVALID_SIGNED_STAT;
937
 
        f_pChannelStats->lRinAppliedGain = cOCT6100_INVALID_SIGNED_STAT;
938
 
        f_pChannelStats->lSoutAppliedGain = cOCT6100_INVALID_SIGNED_STAT;
939
 
        f_pChannelStats->lComfortNoiseLevel = cOCT6100_INVALID_SIGNED_STAT;
940
 
        
941
 
 
942
 
 
943
 
        return cOCT6100_ERR_OK;
944
 
}
945
 
#endif
946
 
 
947
 
#if !SKIP_Oct6100ChannelGetStats
948
 
UINT32 Oct6100ChannelGetStats(
949
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
950
 
                                IN OUT tPOCT6100_CHANNEL_STATS                  f_pChannelStats )
951
 
{
952
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
953
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
954
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
955
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
956
 
 
957
 
        /* Set the process context of the serialize structure.*/
958
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
959
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
960
 
 
961
 
        /* Seize all list semaphores needed by this function. */
962
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
963
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
964
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
965
 
        if ( ulSerRes == cOCT6100_ERR_OK )
966
 
        {
967
 
                /* Call the serialized function. */
968
 
                ulFncRes = Oct6100ApiChannelGetStatsSer( f_pApiInstance, f_pChannelStats );
969
 
        }
970
 
        else
971
 
        {
972
 
                return ulSerRes;
973
 
        }
974
 
 
975
 
        /* Release the seized semaphores. */
976
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
977
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
978
 
 
979
 
        /* If an error occured then return the error code. */
980
 
        if ( ulSerRes != cOCT6100_ERR_OK )
981
 
                return ulSerRes;
982
 
        if ( ulFncRes != cOCT6100_ERR_OK )
983
 
                return ulFncRes;
984
 
 
985
 
        return cOCT6100_ERR_OK;
986
 
}
987
 
#endif
988
 
 
989
 
 
990
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
991
 
 
992
 
Function:               Oct6100ChannelMute
993
 
 
994
 
Description:    This function mutes some or all of the ports designated by 
995
 
                                ulChannelHndl.
996
 
 
997
 
-------------------------------------------------------------------------------
998
 
|       Argument                |       Description
999
 
-------------------------------------------------------------------------------
1000
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
1001
 
                                                present state of the chip and all its resources.
1002
 
 
1003
 
f_pChannelMute                  Pointer to a tPOCT6100_CHANNEL_MUTE structure.
1004
 
 
1005
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1006
 
#if !SKIP_Oct6100ChannelMuteDef
1007
 
UINT32 Oct6100ChannelMuteDef(
1008
 
                                IN OUT tPOCT6100_CHANNEL_MUTE                   f_pChannelMute )
1009
 
{
1010
 
        f_pChannelMute->ulChannelHndl = cOCT6100_INVALID_HANDLE;
1011
 
        f_pChannelMute->ulPortMask = cOCT6100_CHANNEL_MUTE_PORT_NONE;
1012
 
 
1013
 
        return cOCT6100_ERR_OK;
1014
 
}
1015
 
#endif
1016
 
 
1017
 
#if !SKIP_Oct6100ChannelMute
1018
 
UINT32 Oct6100ChannelMute(
1019
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
1020
 
                                IN OUT tPOCT6100_CHANNEL_MUTE                   f_pChannelMute )
1021
 
{
1022
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
1023
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
1024
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
1025
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
1026
 
 
1027
 
        /* Set the process context of the serialize structure.*/
1028
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
1029
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
1030
 
 
1031
 
        /* Seize all list semaphores needed by this function. */
1032
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
1033
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
1034
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
1035
 
        if ( ulSerRes == cOCT6100_ERR_OK )
1036
 
        {
1037
 
                /* Call the serialized function. */
1038
 
                ulFncRes = Oct6100ChannelMuteSer( f_pApiInstance, f_pChannelMute );
1039
 
        }
1040
 
        else
1041
 
        {
1042
 
                return ulSerRes;
1043
 
        }
1044
 
 
1045
 
        /* Release the seized semaphores. */
1046
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
1047
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
1048
 
 
1049
 
        /* If an error occured then return the error code. */
1050
 
        if ( ulSerRes != cOCT6100_ERR_OK )
1051
 
                return ulSerRes;
1052
 
        if ( ulFncRes != cOCT6100_ERR_OK )
1053
 
                return ulFncRes;
1054
 
 
1055
 
        return cOCT6100_ERR_OK;
1056
 
}
1057
 
#endif
1058
 
 
1059
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1060
 
 
1061
 
Function:               Oct6100ChannelUnMute
1062
 
 
1063
 
Description:    This function unmutes some or all of the ports designated by 
1064
 
                                ulChannelHndl.
1065
 
 
1066
 
-------------------------------------------------------------------------------
1067
 
|       Argument                |       Description
1068
 
-------------------------------------------------------------------------------
1069
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
1070
 
                                                present state of the chip and all its resources.
1071
 
 
1072
 
f_pChannelUnMute                Pointer to a tPOCT6100_CHANNEL_UNMUTE structure.
1073
 
 
1074
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1075
 
#if !SKIP_Oct6100ChannelUnMuteDef
1076
 
UINT32 Oct6100ChannelUnMuteDef(
1077
 
                                IN OUT tPOCT6100_CHANNEL_UNMUTE                 f_pChannelUnMute )
1078
 
{
1079
 
        f_pChannelUnMute->ulChannelHndl = cOCT6100_INVALID_HANDLE;
1080
 
        f_pChannelUnMute->ulPortMask = cOCT6100_CHANNEL_MUTE_PORT_NONE;
1081
 
 
1082
 
        return cOCT6100_ERR_OK;
1083
 
}
1084
 
#endif
1085
 
 
1086
 
#if !SKIP_Oct6100ChannelUnMute
1087
 
UINT32 Oct6100ChannelUnMute(
1088
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
1089
 
                                IN OUT tPOCT6100_CHANNEL_UNMUTE                 f_pChannelUnMute )
1090
 
{
1091
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
1092
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
1093
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
1094
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
1095
 
 
1096
 
        /* Set the process context of the serialize structure.*/
1097
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
1098
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
1099
 
 
1100
 
        /* Seize all list semaphores needed by this function. */
1101
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
1102
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
1103
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
1104
 
        if ( ulSerRes == cOCT6100_ERR_OK )
1105
 
        {
1106
 
                /* Call the serialized function. */
1107
 
                ulFncRes = Oct6100ChannelUnMuteSer( f_pApiInstance, f_pChannelUnMute );
1108
 
        }
1109
 
        else
1110
 
        {
1111
 
                return ulSerRes;
1112
 
        }
1113
 
 
1114
 
        /* Release the seized semaphores. */
1115
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
1116
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
1117
 
 
1118
 
        /* If an error occured then return the error code. */
1119
 
        if ( ulSerRes != cOCT6100_ERR_OK )
1120
 
                return ulSerRes;
1121
 
        if ( ulFncRes != cOCT6100_ERR_OK )
1122
 
                return ulFncRes;
1123
 
 
1124
 
        return cOCT6100_ERR_OK;
1125
 
}
1126
 
#endif
1127
 
 
1128
 
/****************************  PRIVATE FUNCTIONS  ****************************/
1129
 
 
1130
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1131
 
 
1132
 
Function:               Oct6100ApiGetChannelsEchoSwSizes
1133
 
 
1134
 
Description:    Gets the sizes of all portions of the API instance pertinent
1135
 
                                to the management of the ECHO memory.
1136
 
 
1137
 
-------------------------------------------------------------------------------
1138
 
|       Argument                |       Description
1139
 
-------------------------------------------------------------------------------
1140
 
f_pOpenChip                             Pointer to chip configuration struct.
1141
 
f_pInstSizes                    Pointer to struct containing instance sizes.
1142
 
 
1143
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1144
 
#if !SKIP_Oct6100ApiGetChannelsEchoSwSizes
1145
 
UINT32 Oct6100ApiGetChannelsEchoSwSizes(
1146
 
                                IN      tPOCT6100_CHIP_OPEN                             f_pOpenChip,
1147
 
                                OUT     tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
1148
 
{
1149
 
        UINT32  ulTempVar;
1150
 
        UINT32  ulResult;
1151
 
        UINT32  ulMaxChannels;
1152
 
 
1153
 
        ulMaxChannels = f_pOpenChip->ulMaxChannels;
1154
 
 
1155
 
        if ( f_pOpenChip->fEnableChannelRecording == TRUE && ulMaxChannels != 672 )
1156
 
                ulMaxChannels++;
1157
 
 
1158
 
        /* Determine the amount of memory required for the API echo channel list.*/
1159
 
        f_pInstSizes->ulChannelList                     = ulMaxChannels * sizeof( tOCT6100_API_CHANNEL );       /* Add one for the record channel.*/
1160
 
        f_pInstSizes->ulBiDirChannelList        = f_pOpenChip->ulMaxBiDirChannels * sizeof( tOCT6100_API_BIDIR_CHANNEL );
1161
 
        if ( ulMaxChannels > 0 )
1162
 
        {
1163
 
                /* Calculate memory needed for ECHO memory allocation */
1164
 
                ulResult = OctapiLlmAllocGetSize( ulMaxChannels, &f_pInstSizes->ulChannelAlloc );
1165
 
                if ( ulResult != cOCT6100_ERR_OK  )
1166
 
                        return cOCT6100_ERR_FATAL_0;
1167
 
        }
1168
 
        else
1169
 
        {
1170
 
                f_pInstSizes->ulChannelAlloc = 0;
1171
 
        }
1172
 
        if ( f_pOpenChip->ulMaxBiDirChannels > 0 )
1173
 
        {
1174
 
                /* Calculate memory needed for ECHO memory allocation */
1175
 
                ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxBiDirChannels, &f_pInstSizes->ulBiDirChannelAlloc );
1176
 
                if ( ulResult != cOCT6100_ERR_OK  )
1177
 
                        return cOCT6100_ERR_FATAL_0;
1178
 
        }
1179
 
        else
1180
 
        {
1181
 
                f_pInstSizes->ulBiDirChannelAlloc = 0;
1182
 
        }
1183
 
 
1184
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulChannelList, ulTempVar )
1185
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulChannelAlloc, ulTempVar )
1186
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulBiDirChannelList, ulTempVar )
1187
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulBiDirChannelAlloc, ulTempVar )
1188
 
        return cOCT6100_ERR_OK;
1189
 
}
1190
 
#endif
1191
 
 
1192
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1193
 
 
1194
 
Function:               Oct6100ApiChannelsEchoSwInit
1195
 
 
1196
 
Description:    Initializes all elements of the instance structure associated
1197
 
                                to the ECHO memory.
1198
 
 
1199
 
-------------------------------------------------------------------------------
1200
 
|       Argument                |       Description
1201
 
-------------------------------------------------------------------------------
1202
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
1203
 
                                                the present state of the chip and all its resources.
1204
 
 
1205
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1206
 
#if !SKIP_Oct6100ApiChannelsEchoSwInit
1207
 
UINT32 Oct6100ApiChannelsEchoSwInit(
1208
 
                                IN tPOCT6100_INSTANCE_API                       f_pApiInstance )
1209
 
{
1210
 
        tPOCT6100_API_CHANNEL                   pChannelsEchoList;
1211
 
        tPOCT6100_API_BIDIR_CHANNEL             pBiDirChannelsList;
1212
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
1213
 
        UINT16  usMaxChannels;
1214
 
        PVOID   pEchoChanAlloc;
1215
 
        PVOID   pBiDirChanAlloc;
1216
 
        UINT32  ulResult;
1217
 
 
1218
 
        /* Get local pointer to shared portion of the API instance. */
1219
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
1220
 
 
1221
 
        /* Initialize the ECHO channel API list.*/
1222
 
        usMaxChannels = pSharedInfo->ChipConfig.usMaxChannels;
1223
 
 
1224
 
        /* add a channel to initialize if the recording is activated. */
1225
 
        if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
1226
 
                usMaxChannels++;
1227
 
 
1228
 
        /* Set all entries in the ADCPM channel list to unused. */
1229
 
        mOCT6100_GET_CHANNEL_LIST_PNT( pSharedInfo, pChannelsEchoList );
1230
 
        
1231
 
        /* Initialize the API ECHO channels allocation software to "all free". */
1232
 
        if ( usMaxChannels > 0 )
1233
 
        {
1234
 
                /* Clear the memory */
1235
 
                Oct6100UserMemSet( pChannelsEchoList, 0x00, sizeof(tOCT6100_API_CHANNEL) * usMaxChannels );
1236
 
 
1237
 
                mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoChanAlloc )
1238
 
                
1239
 
                ulResult = OctapiLlmAllocInit( &pEchoChanAlloc, usMaxChannels );
1240
 
                if ( ulResult != cOCT6100_ERR_OK  )
1241
 
                        return cOCT6100_ERR_FATAL_1;
1242
 
        }
1243
 
 
1244
 
        mOCT6100_GET_BIDIR_CHANNEL_LIST_PNT( pSharedInfo, pBiDirChannelsList ); 
1245
 
 
1246
 
        if ( pSharedInfo->ChipConfig.usMaxBiDirChannels > 0 )
1247
 
        {
1248
 
                /* Clear the memory */
1249
 
                Oct6100UserMemSet( pBiDirChannelsList, 0x00, sizeof(tOCT6100_API_BIDIR_CHANNEL) * pSharedInfo->ChipConfig.usMaxBiDirChannels );
1250
 
                
1251
 
                mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pBiDirChanAlloc )
1252
 
                
1253
 
                ulResult = OctapiLlmAllocInit( &pBiDirChanAlloc, pSharedInfo->ChipConfig.usMaxBiDirChannels );
1254
 
                if ( ulResult != cOCT6100_ERR_OK  )
1255
 
                        return cOCT6100_ERR_FATAL_A9;
1256
 
                
1257
 
        }
1258
 
 
1259
 
        return cOCT6100_ERR_OK;
1260
 
}
1261
 
#endif
1262
 
 
1263
 
 
1264
 
 
1265
 
 
1266
 
 
1267
 
 
1268
 
 
1269
 
 
1270
 
 
1271
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1272
 
 
1273
 
Function:               Oct6100ChannelOpenSer
1274
 
 
1275
 
Description:    Opens a echo cancellation channel.
1276
 
 
1277
 
-------------------------------------------------------------------------------
1278
 
|       Argument                |       Description
1279
 
-------------------------------------------------------------------------------
1280
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
1281
 
                                                present state of the chip and all its resources.
1282
 
 
1283
 
f_pChannelOpen                  Pointer to channel configuration structure.  Then handle
1284
 
                                                identifying the buffer in all future function calls is
1285
 
                                                returned in this structure.
1286
 
 
1287
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1288
 
#if !SKIP_Oct6100ChannelOpenSer
1289
 
UINT32 Oct6100ChannelOpenSer(
1290
 
                                IN tPOCT6100_INSTANCE_API                       f_pApiInstance,
1291
 
                                IN OUT tPOCT6100_CHANNEL_OPEN           f_pChannelOpen )
1292
 
{
1293
 
        tOCT6100_API_ECHO_CHAN_INDEX            ChannelIndexConf;
1294
 
        UINT32  ulResult;
1295
 
 
1296
 
        /* Check the user's configuration of the echo cancellation channel for errors. */
1297
 
        ulResult = Oct6100ApiCheckChannelParams( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf );
1298
 
        if ( ulResult != cOCT6100_ERR_OK  )
1299
 
                return ulResult;
1300
 
 
1301
 
        /* Reserve all resources needed by the echo cancellation channel. */
1302
 
        ulResult = Oct6100ApiReserveChannelResources( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf );
1303
 
        if ( ulResult != cOCT6100_ERR_OK  )
1304
 
                return ulResult;
1305
 
 
1306
 
        /* Write all necessary structures to activate the echo cancellation channel. */
1307
 
        ulResult = Oct6100ApiWriteChannelStructs( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf );
1308
 
        if ( ulResult != cOCT6100_ERR_OK  )
1309
 
                return ulResult;
1310
 
 
1311
 
        /* Update the new echo cancellation channels's entry in the ECHO channel list. */
1312
 
        ulResult = Oct6100ApiUpdateChannelEntry( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf );
1313
 
        if ( ulResult != cOCT6100_ERR_OK  )
1314
 
                return ulResult;
1315
 
 
1316
 
        return cOCT6100_ERR_OK;
1317
 
}
1318
 
#endif
1319
 
 
1320
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1321
 
 
1322
 
Function:               Oct6100ApiCheckChannelParams
1323
 
 
1324
 
Description:    Checks the user's echo cancellation channel open configuration for errors.
1325
 
 
1326
 
-------------------------------------------------------------------------------
1327
 
|       Argument                |       Description
1328
 
-------------------------------------------------------------------------------
1329
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
1330
 
                                                present state of the chip and all its resources.
1331
 
 
1332
 
f_pChannelOpen                  Pointer to echo cancellation channel open configuration structure.
1333
 
f_pChanIndexConf                Pointer to a structure used to store the multiple resources indexes.
1334
 
 
1335
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1336
 
#if !SKIP_Oct6100ApiCheckChannelParams
1337
 
UINT32 Oct6100ApiCheckChannelParams(
1338
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
1339
 
                                IN tPOCT6100_CHANNEL_OPEN                               f_pChannelOpen,
1340
 
                                OUT tPOCT6100_API_ECHO_CHAN_INDEX               f_pChanIndexConf )
1341
 
{
1342
 
        tPOCT6100_CHANNEL_OPEN_TDM              pTdmConfig;
1343
 
        tPOCT6100_CHANNEL_OPEN_VQE              pVqeConfig;
1344
 
        tPOCT6100_CHANNEL_OPEN_CODEC    pCodecConfig;
1345
 
        UINT32  ulDecoderNumTssts;
1346
 
        UINT32  ulResult;
1347
 
 
1348
 
        /* Dereference the configuration structure for clearer code and faster access.*/
1349
 
        pTdmConfig       = &f_pChannelOpen->TdmConfig;
1350
 
        pVqeConfig       = &f_pChannelOpen->VqeConfig;
1351
 
        pCodecConfig = &f_pChannelOpen->CodecConfig;
1352
 
 
1353
 
        /* Check for errors. */
1354
 
        if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels == 0 )
1355
 
                return cOCT6100_ERR_CHANNEL_DISABLED;
1356
 
 
1357
 
        if ( f_pChannelOpen->pulChannelHndl == NULL )
1358
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
1359
 
 
1360
 
        if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NORMAL &&
1361
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_FREEZE &&
1362
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET &&
1363
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN &&
1364
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL &&
1365
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION &&
1366
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
1367
 
                return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE;
1368
 
 
1369
 
        /* Check the 2100Hz echo disabling configuration.*/
1370
 
        if ( f_pChannelOpen->fEnableToneDisabler != TRUE && 
1371
 
                 f_pChannelOpen->fEnableToneDisabler != FALSE  )
1372
 
                return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ENABLE;
1373
 
        
1374
 
        /* Check the extended Tone Detection flag value.*/
1375
 
        if ( f_pChannelOpen->fEnableExtToneDetection != TRUE &&
1376
 
                 f_pChannelOpen->fEnableExtToneDetection != FALSE )
1377
 
                return cOCT6100_ERR_CHANNEL_ENABLE_EXT_TONE_DETECTION;
1378
 
 
1379
 
        /* Check that extented tone detection is actually enabled by the user. */
1380
 
        if ( ( f_pChannelOpen->fEnableExtToneDetection == TRUE ) &&
1381
 
                ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableExtToneDetection == FALSE ) )
1382
 
                return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DISABLED;
1383
 
 
1384
 
 
1385
 
 
1386
 
        /*==============================================================================*/
1387
 
        /* Check the TDM configuration parameters.*/
1388
 
 
1389
 
        ulResult = Oct6100ApiCheckTdmConfig( f_pApiInstance, pTdmConfig );
1390
 
        if ( ulResult != cOCT6100_ERR_OK )
1391
 
                return ulResult;
1392
 
 
1393
 
        /*==============================================================================*/
1394
 
 
1395
 
 
1396
 
        /*==============================================================================*/
1397
 
        /* Now validate the VQE parameters */
1398
 
 
1399
 
        ulResult = Oct6100ApiCheckVqeConfig( f_pApiInstance, pVqeConfig, f_pChannelOpen->fEnableToneDisabler );
1400
 
        if ( ulResult != cOCT6100_ERR_OK )
1401
 
                return ulResult;
1402
 
 
1403
 
        /* Verify if the echo operation mode selected can be applied. */
1404
 
        if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
1405
 
                && ( pVqeConfig->fEnableNlp == FALSE ) )
1406
 
                return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
1407
 
        
1408
 
        if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
1409
 
                && ( pVqeConfig->fEnableNlp == FALSE ) )
1410
 
                return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
1411
 
 
1412
 
        /* Comfort noise must be activated for speech recognition mode to work. */
1413
 
        if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
1414
 
                && ( pVqeConfig->ulComfortNoiseMode == cOCT6100_COMFORT_NOISE_OFF ) )
1415
 
                return cOCT6100_ERR_CHANNEL_COMFORT_NOISE_REQUIRED;
1416
 
 
1417
 
        /*==============================================================================*/
1418
 
 
1419
 
        /*==============================================================================*/
1420
 
        /* Finally, validate the CODEC configuration.*/
1421
 
 
1422
 
        if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1423
 
                ulDecoderNumTssts = pTdmConfig->ulRinNumTssts;
1424
 
        else /* pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
1425
 
                ulDecoderNumTssts  = pTdmConfig->ulSinNumTssts;
1426
 
        
1427
 
        ulResult = Oct6100ApiCheckCodecConfig( f_pApiInstance, pCodecConfig, ulDecoderNumTssts, &f_pChanIndexConf->usPhasingTsstIndex );
1428
 
        if ( ulResult != cOCT6100_ERR_OK )
1429
 
                return ulResult;
1430
 
 
1431
 
 
1432
 
 
1433
 
        /* make sure that if silence suppression is activated, the NLP is enabled.*/
1434
 
        if ( pCodecConfig->fEnableSilenceSuppression == TRUE && pVqeConfig->fEnableNlp == FALSE )
1435
 
                return cOCT6100_ERR_CHANNEL_SIL_SUP_NLP_MUST_BE_ENABLED;
1436
 
        
1437
 
        /* Verify if law conversion is allowed. */
1438
 
        if ( pCodecConfig->ulEncoderPort == cOCT6100_NO_ENCODING ||
1439
 
                 pCodecConfig->ulDecoderPort == cOCT6100_NO_DECODING )
1440
 
        {
1441
 
                /* No law conversion can occurs if one ADPCM memory is not reserved.*/
1442
 
                if ( pTdmConfig->ulRinPcmLaw != pTdmConfig->ulRoutPcmLaw )
1443
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_LAW_TRANSLATION;
1444
 
 
1445
 
                if ( pTdmConfig->ulSinPcmLaw != pTdmConfig->ulSoutPcmLaw )
1446
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_LAW_TRANSLATION;
1447
 
        }
1448
 
 
1449
 
        /* Verify if the config supports extended tone detection.*/
1450
 
        if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
1451
 
        {
1452
 
                if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1453
 
                        return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT;
1454
 
        }
1455
 
        /*==============================================================================*/
1456
 
 
1457
 
        return cOCT6100_ERR_OK;
1458
 
}
1459
 
#endif
1460
 
 
1461
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1462
 
 
1463
 
Function:               Oct6100ApiReserveChannelResources
1464
 
 
1465
 
Description:    Reserves all resources needed for the new channel.
1466
 
 
1467
 
-------------------------------------------------------------------------------
1468
 
|       Argument                |       Description
1469
 
-------------------------------------------------------------------------------
1470
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
1471
 
                                                present state of the chip and all its resources.
1472
 
        
1473
 
f_pChannelOpen                  Pointer to echo cancellation channel configuration structure.
1474
 
f_pulChannelIndex               Allocated entry in ECHO channel list.
1475
 
f_pChanIndexConf                Pointer to a structure used to store the multiple resources indexes.
1476
 
 
1477
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1478
 
#if !SKIP_Oct6100ApiReserveChannelResources
1479
 
UINT32 Oct6100ApiReserveChannelResources(       
1480
 
                                IN  tPOCT6100_INSTANCE_API                              f_pApiInstance,
1481
 
                                IN  tPOCT6100_CHANNEL_OPEN                              f_pChannelOpen,
1482
 
                                OUT tPOCT6100_API_ECHO_CHAN_INDEX               f_pChanIndexConf )
1483
 
{
1484
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
1485
 
        tPOCT6100_CHANNEL_OPEN_TDM              pTdmConfig;
1486
 
        tPOCT6100_CHANNEL_OPEN_CODEC    pCodecConfig;
1487
 
 
1488
 
        UINT32  ulResult;
1489
 
        UINT32  ulTempVar;
1490
 
        UINT32  ulFreeMixerEventCnt;
1491
 
 
1492
 
        BOOL    fRinTsstEntry = FALSE;
1493
 
        BOOL    fSinTsstEntry = FALSE;
1494
 
        BOOL    fRoutTsstEntry = FALSE;
1495
 
        BOOL    fSoutTsstEntry = FALSE;
1496
 
 
1497
 
        BOOL    fRinRoutTsiMemEntry = FALSE;
1498
 
        BOOL    fSinSoutTsiMemEntry = FALSE;
1499
 
 
1500
 
        BOOL    fEchoChanEntry = FALSE;
1501
 
 
1502
 
        PUINT16 pusRinRoutConversionMemIndex = NULL;
1503
 
        PUINT16 pusSinSoutConversionMemIndex = NULL;
1504
 
        BOOL    fRinRoutConversionMemEntry = FALSE;
1505
 
        BOOL    fSinSoutConversionMemEntry = FALSE;
1506
 
 
1507
 
        BOOL    fExtToneChanEntry       = FALSE;
1508
 
        BOOL    fExtToneTsiEntry        = FALSE;
1509
 
        BOOL    fExtToneMixerEntry      = FALSE;
1510
 
        
1511
 
        /* Obtain local pointer to shared portion of instance. */
1512
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
1513
 
 
1514
 
        /* Obtain a local pointer to the configuration structures.*/
1515
 
        pTdmConfig              = &f_pChannelOpen->TdmConfig;
1516
 
        pCodecConfig    = &f_pChannelOpen->CodecConfig;
1517
 
 
1518
 
        /*===============================================================================*/
1519
 
        /* Reserve Echo and TSI entries. */
1520
 
 
1521
 
        ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, 
1522
 
                                                                                   &f_pChanIndexConf->usEchoChanIndex );
1523
 
        if ( ulResult == cOCT6100_ERR_OK )
1524
 
        {
1525
 
                fEchoChanEntry = TRUE;
1526
 
 
1527
 
                /* Set the echo, encoder and decoder memory indexes.*/
1528
 
                f_pChanIndexConf->usEchoMemIndex = f_pChanIndexConf->usEchoChanIndex;
1529
 
                
1530
 
                /* Reserve an entry for the RIN/ROUT tsi chariot memory. */
1531
 
                ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, 
1532
 
                                                                                                 &f_pChanIndexConf->usRinRoutTsiMemIndex );
1533
 
                if ( ulResult == cOCT6100_ERR_OK )
1534
 
                {
1535
 
                        fRinRoutTsiMemEntry = TRUE;
1536
 
 
1537
 
                        /* Reserve an entry for the SIN/SOUT tsi chariot memory. */
1538
 
                        ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, 
1539
 
                                                                                                         &f_pChanIndexConf->usSinSoutTsiMemIndex );
1540
 
                        if ( ulResult == cOCT6100_ERR_OK )
1541
 
                        {
1542
 
                                fSinSoutTsiMemEntry = TRUE;
1543
 
 
1544
 
                                /* Reserve an ADPCM memory block for compression if required.*/
1545
 
                                if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
1546
 
                                {
1547
 
                                        pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex;
1548
 
                                }
1549
 
                                else if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT )
1550
 
                                {
1551
 
                                        pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex;
1552
 
                                }
1553
 
 
1554
 
                                /* Reserve an ADPCM memory block for decompression if required.*/
1555
 
                                if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1556
 
                                {
1557
 
                                        pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex;
1558
 
                                }
1559
 
                                else if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN )
1560
 
                                {
1561
 
                                        pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex;
1562
 
                                }
1563
 
 
1564
 
 
1565
 
                                /* Reserve the conversion memories. */
1566
 
                                if ( pusRinRoutConversionMemIndex != NULL )
1567
 
                                {
1568
 
                                        /* Reserve a conversion memory for the Rin/Rout stream. */
1569
 
                                        ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, 
1570
 
                                                                                                                                        pusRinRoutConversionMemIndex );
1571
 
                                        if ( ulResult == cOCT6100_ERR_OK )
1572
 
                                        {
1573
 
                                                fRinRoutConversionMemEntry = TRUE;
1574
 
                                        }
1575
 
                                }
1576
 
                                else
1577
 
                                {
1578
 
                                        /* No conversion memory reserved.*/
1579
 
                                        f_pChanIndexConf->usRinRoutConversionMemIndex = cOCT6100_INVALID_INDEX;
1580
 
                                }
1581
 
 
1582
 
                                if ( ( pusSinSoutConversionMemIndex != NULL ) && 
1583
 
                                         ( ulResult == cOCT6100_ERR_OK ) )
1584
 
                                {
1585
 
                                        /* Reserve a conversion memory for the Sin/Sout stream. */
1586
 
                                        ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, 
1587
 
                                                                                                                                        pusSinSoutConversionMemIndex );
1588
 
                                        if ( ulResult == cOCT6100_ERR_OK )
1589
 
                                        {
1590
 
                                                fSinSoutConversionMemEntry = TRUE;
1591
 
                                        }
1592
 
                                }
1593
 
                                else
1594
 
                                {
1595
 
                                        /* No conversion memory reserved.*/
1596
 
                                        f_pChanIndexConf->usSinSoutConversionMemIndex = cOCT6100_INVALID_INDEX;
1597
 
                                }
1598
 
 
1599
 
                                /* Reserve any resources required if the extended Tone detection is enabled.*/
1600
 
                                if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
1601
 
                                {
1602
 
                                        ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, 
1603
 
                                                                                                                   &f_pChanIndexConf->usExtToneChanIndex );
1604
 
                                        if ( ulResult == cOCT6100_ERR_OK )
1605
 
                                        {
1606
 
                                                fExtToneChanEntry = TRUE;
1607
 
                                                
1608
 
                                                /* Reserve an entry for the TSI chariot memory for the additionnal channel. */
1609
 
                                                ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, 
1610
 
                                                                                                                                 &f_pChanIndexConf->usExtToneTsiIndex );
1611
 
                                                if ( ulResult == cOCT6100_ERR_OK )
1612
 
                                                {
1613
 
                                                        fExtToneTsiEntry = TRUE;
1614
 
 
1615
 
                                                        /* Reserve an entry for the TSI chariot memory for the additionnal channel. */
1616
 
                                                        ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, 
1617
 
                                                                                                                                                 &f_pChanIndexConf->usExtToneMixerIndex );
1618
 
                                                        if ( ulResult == cOCT6100_ERR_OK )
1619
 
                                                                fExtToneMixerEntry = TRUE;
1620
 
                                                }
1621
 
                                        }
1622
 
                                }
1623
 
                                else
1624
 
                                {
1625
 
                                        f_pChanIndexConf->usExtToneChanIndex    = cOCT6100_INVALID_INDEX;
1626
 
                                        f_pChanIndexConf->usExtToneMixerIndex   = cOCT6100_INVALID_INDEX;
1627
 
                                        f_pChanIndexConf->usExtToneTsiIndex             = cOCT6100_INVALID_INDEX;
1628
 
                                }
1629
 
                        }
1630
 
                        else
1631
 
                        {
1632
 
                                /* Return an error other then a Fatal.*/
1633
 
                                ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY;
1634
 
                        }
1635
 
                }
1636
 
                else
1637
 
                {
1638
 
                        /* Return an error other then a Fatal.*/
1639
 
                        ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY;
1640
 
                }
1641
 
        }
1642
 
 
1643
 
        /*===============================================================================*/
1644
 
 
1645
 
        /*===============================================================================*/
1646
 
        /* Now reserve the TSST entries if required.*/
1647
 
 
1648
 
        /* Reserve the Rin TSST entry */        
1649
 
        if ( (ulResult == cOCT6100_ERR_OK ) &&
1650
 
                 (pTdmConfig->ulRinTimeslot != cOCT6100_UNASSIGNED && 
1651
 
                  pTdmConfig->ulRinStream != cOCT6100_UNASSIGNED) )
1652
 
        {
1653
 
                ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
1654
 
                                                                                  pTdmConfig->ulRinTimeslot, 
1655
 
                                                                                  pTdmConfig->ulRinStream, 
1656
 
                                                                                  pTdmConfig->ulRinNumTssts, 
1657
 
                                                                                  cOCT6100_INPUT_TSST,
1658
 
                                                                                  &f_pChanIndexConf->usRinTsstIndex, 
1659
 
                                                                                  NULL );
1660
 
                if ( ulResult == cOCT6100_ERR_OK )
1661
 
                        fRinTsstEntry = TRUE;
1662
 
        }
1663
 
        else
1664
 
        {
1665
 
                f_pChanIndexConf->usRinTsstIndex = cOCT6100_INVALID_INDEX;
1666
 
        }
1667
 
 
1668
 
                
1669
 
        if ( (ulResult == cOCT6100_ERR_OK ) &&
1670
 
                 (pTdmConfig->ulSinTimeslot != cOCT6100_UNASSIGNED && 
1671
 
                  pTdmConfig->ulSinStream != cOCT6100_UNASSIGNED) )
1672
 
        {
1673
 
                /* Reserve the Sin TSST entry.*/
1674
 
                ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
1675
 
                                                                                  pTdmConfig->ulSinTimeslot, 
1676
 
                                                                                  pTdmConfig->ulSinStream, 
1677
 
                                                                                  pTdmConfig->ulSinNumTssts, 
1678
 
                                                                                  cOCT6100_INPUT_TSST,
1679
 
                                                                                  &f_pChanIndexConf->usSinTsstIndex, 
1680
 
                                                                                  NULL );
1681
 
                if ( ulResult == cOCT6100_ERR_OK )
1682
 
                        fSinTsstEntry = TRUE;
1683
 
        }
1684
 
        else 
1685
 
        {
1686
 
                f_pChanIndexConf->usSinTsstIndex = cOCT6100_INVALID_INDEX;
1687
 
        }
1688
 
 
1689
 
        if ( (ulResult == cOCT6100_ERR_OK ) &&
1690
 
                 (pTdmConfig->ulRoutTimeslot != cOCT6100_UNASSIGNED && 
1691
 
                  pTdmConfig->ulRoutStream != cOCT6100_UNASSIGNED) )
1692
 
        {
1693
 
                /* Reserve the Rout TSST entry.*/
1694
 
                ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
1695
 
                                                                                  pTdmConfig->ulRoutTimeslot, 
1696
 
                                                                                  pTdmConfig->ulRoutStream, 
1697
 
                                                                                  pTdmConfig->ulRoutNumTssts, 
1698
 
                                                                                  cOCT6100_OUTPUT_TSST,
1699
 
                                                                                  &f_pChanIndexConf->usRoutTsstIndex, 
1700
 
                                                                                  NULL );
1701
 
                if ( ulResult == cOCT6100_ERR_OK )
1702
 
                        fRoutTsstEntry = TRUE;
1703
 
        }
1704
 
        else
1705
 
        {
1706
 
                f_pChanIndexConf->usRoutTsstIndex = cOCT6100_INVALID_INDEX;
1707
 
        }
1708
 
 
1709
 
                                
1710
 
        if ( (ulResult == cOCT6100_ERR_OK ) &&
1711
 
                 (pTdmConfig->ulSoutTimeslot != cOCT6100_UNASSIGNED && 
1712
 
                  pTdmConfig->ulSoutStream != cOCT6100_UNASSIGNED) )
1713
 
        {
1714
 
                /* Reserve the Sout TSST entry.*/
1715
 
                ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
1716
 
                                                                                  pTdmConfig->ulSoutTimeslot, 
1717
 
                                                                                  pTdmConfig->ulSoutStream, 
1718
 
                                                                                  pTdmConfig->ulSoutNumTssts, 
1719
 
                                                                                  cOCT6100_OUTPUT_TSST,
1720
 
                                                                                  &f_pChanIndexConf->usSoutTsstIndex, 
1721
 
                                                                                  NULL );
1722
 
                if ( ulResult == cOCT6100_ERR_OK )
1723
 
                        fSoutTsstEntry = TRUE;
1724
 
        }
1725
 
        else 
1726
 
        {
1727
 
                f_pChanIndexConf->usSoutTsstIndex = cOCT6100_INVALID_INDEX;
1728
 
        }
1729
 
 
1730
 
        /*===============================================================================*/
1731
 
        
1732
 
 
1733
 
        /*===============================================================================*/
1734
 
        /* Check if there are a couple of mixer events available for us. */
1735
 
 
1736
 
        if ( ulResult == cOCT6100_ERR_OK )
1737
 
        {
1738
 
                UINT32 ulMixerEventCntNeeded = 0;
1739
 
 
1740
 
                /* Calculate how many mixer events are needed. */
1741
 
                if ( f_pChanIndexConf->usRinTsstIndex == cOCT6100_INVALID_INDEX )
1742
 
                        ulMixerEventCntNeeded++;
1743
 
 
1744
 
                if ( f_pChanIndexConf->usSinTsstIndex == cOCT6100_INVALID_INDEX )
1745
 
                        ulMixerEventCntNeeded++;
1746
 
 
1747
 
                /* If at least 1 mixer event is needed, check if those are available. */
1748
 
                if ( ulMixerEventCntNeeded != 0 )
1749
 
                {
1750
 
                        ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt );
1751
 
                        if ( ulResult == cOCT6100_ERR_OK )
1752
 
                        {
1753
 
                                /* The API might need more mixer events if the ports have to be muted. */
1754
 
                                /* Check if these are available. */
1755
 
                                if ( ulFreeMixerEventCnt < ulMixerEventCntNeeded )
1756
 
                                {
1757
 
                                        ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS;
1758
 
                                }
1759
 
                        }
1760
 
                }
1761
 
        }
1762
 
 
1763
 
        /*===============================================================================*/
1764
 
 
1765
 
 
1766
 
        /*===============================================================================*/
1767
 
        /* Release the resources if something went wrong */             
1768
 
        if ( ulResult != cOCT6100_ERR_OK  )
1769
 
        {
1770
 
                /*===============================================================================*/
1771
 
                /* Release the previously reserved resources .*/
1772
 
                if( fRinTsstEntry == TRUE )
1773
 
                {
1774
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,  
1775
 
                                                                                           pTdmConfig->ulRinTimeslot,
1776
 
                                                                                           pTdmConfig->ulRinStream,
1777
 
                                                                                           pTdmConfig->ulRinNumTssts, 
1778
 
                                                                                           cOCT6100_INPUT_TSST,
1779
 
                                                                                           cOCT6100_INVALID_INDEX );
1780
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1781
 
                                return ulTempVar;
1782
 
                }
1783
 
 
1784
 
                if( fSinTsstEntry == TRUE )
1785
 
                {
1786
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,  
1787
 
                                                                                           pTdmConfig->ulSinTimeslot,
1788
 
                                                                                           pTdmConfig->ulSinStream,
1789
 
                                                                                           pTdmConfig->ulSinNumTssts, 
1790
 
                                                                                           cOCT6100_INPUT_TSST,
1791
 
                                                                                           cOCT6100_INVALID_INDEX );
1792
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1793
 
                                return ulTempVar;
1794
 
                }
1795
 
 
1796
 
                if( fRoutTsstEntry == TRUE )
1797
 
                {
1798
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,  
1799
 
                                                                                           pTdmConfig->ulRoutTimeslot,
1800
 
                                                                                           pTdmConfig->ulRoutStream,
1801
 
                                                                                           pTdmConfig->ulRoutNumTssts, 
1802
 
                                                                                           cOCT6100_OUTPUT_TSST,
1803
 
                                                                                           cOCT6100_INVALID_INDEX );
1804
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1805
 
                                return ulTempVar;
1806
 
                }
1807
 
 
1808
 
                if( fSoutTsstEntry == TRUE )
1809
 
                {
1810
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, 
1811
 
                                                                                           pTdmConfig->ulSoutTimeslot,
1812
 
                                                                                           pTdmConfig->ulSoutStream,
1813
 
                                                                                           pTdmConfig->ulSoutNumTssts, 
1814
 
                                                                                           cOCT6100_OUTPUT_TSST,
1815
 
                                                                                           cOCT6100_INVALID_INDEX );
1816
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1817
 
                                return ulTempVar;
1818
 
                }
1819
 
 
1820
 
                if( fRinRoutTsiMemEntry == TRUE )
1821
 
                {
1822
 
                        ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, 
1823
 
                                                                                                          f_pChanIndexConf->usRinRoutTsiMemIndex );
1824
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1825
 
                                return ulTempVar;
1826
 
                }
1827
 
 
1828
 
                if( fSinSoutTsiMemEntry == TRUE )
1829
 
                {
1830
 
                        ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, 
1831
 
                                                                                                          f_pChanIndexConf->usSinSoutTsiMemIndex );
1832
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1833
 
                                return ulTempVar;
1834
 
                }
1835
 
 
1836
 
                /*===============================================================================*/
1837
 
 
1838
 
                /*===============================================================================*/
1839
 
                /* Release the previously reserved echo resources .*/
1840
 
                if( fEchoChanEntry == TRUE )
1841
 
                {
1842
 
                        ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance, 
1843
 
                                                                                                        f_pChanIndexConf->usEchoChanIndex );
1844
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1845
 
                                return ulTempVar;
1846
 
                }
1847
 
 
1848
 
                /*===============================================================================*/
1849
 
        
1850
 
                /*===============================================================================*/
1851
 
                /* Release the previously reserved resources for the extended tone detection.*/
1852
 
                if( fExtToneChanEntry == TRUE )
1853
 
                {
1854
 
                        ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance, 
1855
 
                                                                                                        f_pChanIndexConf->usExtToneChanIndex );
1856
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1857
 
                                return ulTempVar;
1858
 
                }
1859
 
 
1860
 
                if( fExtToneTsiEntry == TRUE )
1861
 
                {
1862
 
                        ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, 
1863
 
                                                                                                          f_pChanIndexConf->usExtToneTsiIndex );
1864
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1865
 
                                return ulTempVar;
1866
 
                }
1867
 
 
1868
 
                if( fExtToneMixerEntry == TRUE )
1869
 
                {
1870
 
                        ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, 
1871
 
                                                                                                                 f_pChanIndexConf->usExtToneMixerIndex );
1872
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1873
 
                                return ulTempVar;
1874
 
                }
1875
 
                /*===============================================================================*/
1876
 
 
1877
 
                /*===============================================================================*/
1878
 
                /* Release the conversion resources. */
1879
 
                if( fRinRoutConversionMemEntry == TRUE )
1880
 
                {
1881
 
                        ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, 
1882
 
                                                                                                                        f_pChanIndexConf->usRinRoutConversionMemIndex );
1883
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1884
 
                                return ulTempVar;
1885
 
                }
1886
 
 
1887
 
                if( fSinSoutConversionMemEntry == TRUE )
1888
 
                {
1889
 
                        ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, 
1890
 
                                                                                                                        f_pChanIndexConf->usSinSoutConversionMemIndex );
1891
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1892
 
                                return ulTempVar;
1893
 
                }
1894
 
 
1895
 
                /*===============================================================================*/
1896
 
                
1897
 
                return ulResult;
1898
 
        }
1899
 
 
1900
 
        return cOCT6100_ERR_OK;
1901
 
}
1902
 
#endif
1903
 
 
1904
 
 
1905
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1906
 
 
1907
 
Function:               Oct6100ApiWriteChannelStructs
1908
 
 
1909
 
Description:    Performs all the required structure writes to configure the
1910
 
                                new echo cancellation channel.
1911
 
 
1912
 
-------------------------------------------------------------------------------
1913
 
|       Argument                |       Description
1914
 
-------------------------------------------------------------------------------
1915
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
1916
 
                                                present state of the chip and all its resources.
1917
 
        
1918
 
f_pChannelOpen                  Pointer to echo cancellation channel configuration structure.
1919
 
f_pChanIndexConf                Pointer to a structure used to store the multiple resources indexes.
1920
 
 
1921
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1922
 
#if !SKIP_Oct6100ApiWriteChannelStructs
1923
 
UINT32 Oct6100ApiWriteChannelStructs(
1924
 
                                IN tPOCT6100_INSTANCE_API                       f_pApiInstance,
1925
 
                                IN tPOCT6100_CHANNEL_OPEN                       f_pChannelOpen,
1926
 
                                OUT tPOCT6100_API_ECHO_CHAN_INDEX       f_pChanIndexConf )
1927
 
{
1928
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
1929
 
        tPOCT6100_CHANNEL_OPEN_TDM              pTdmConfig;
1930
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
1931
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
1932
 
        UINT32  ulResult;
1933
 
        UINT32  ulDwordAddress;
1934
 
        UINT32  ulDwordData;
1935
 
        BOOL    fConversionEnabled = FALSE;
1936
 
        BOOL    fProgramAdpcmMem;
1937
 
        UINT32  ulCompType = 0;
1938
 
        UINT32  ulPcmLaw;
1939
 
        UINT16  usTempTsiMemIndex;
1940
 
        UINT16  usConversionMemIndex;
1941
 
        UINT32  ulToneEventNumber;
1942
 
        BOOL    fSSTone;
1943
 
 
1944
 
        /* Obtain local pointer to shared portion of instance. */
1945
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
1946
 
        
1947
 
        /* Obtain a local pointer to the TDM configuration structure.*/
1948
 
        pTdmConfig = &f_pChannelOpen->TdmConfig;
1949
 
 
1950
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1951
 
 
1952
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1953
 
 
1954
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex );
1955
 
 
1956
 
        /*==============================================================================*/
1957
 
        /* Configure the Tsst control memory.*/
1958
 
        
1959
 
        /* Set the RIN Tsst control entry.*/
1960
 
        if ( f_pChanIndexConf->usRinTsstIndex != cOCT6100_INVALID_INDEX )
1961
 
        {
1962
 
                ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
1963
 
                                                                                                                  f_pChanIndexConf->usRinTsstIndex,
1964
 
                                                                                                                  f_pChanIndexConf->usRinRoutTsiMemIndex,
1965
 
                                                                                                                  pTdmConfig->ulRinPcmLaw );
1966
 
                if ( ulResult != cOCT6100_ERR_OK )
1967
 
                        return ulResult;
1968
 
        }
1969
 
 
1970
 
        /* Set the ROUT Tsst control entry.*/
1971
 
        if ( f_pChanIndexConf->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
1972
 
        {
1973
 
                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
1974
 
                                                                                                                   f_pChanIndexConf->usRoutTsstIndex,
1975
 
                                                                                                                   f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
1976
 
                                                                                                                   pTdmConfig->ulRoutNumTssts,
1977
 
                                                                                                                   f_pChanIndexConf->usRinRoutTsiMemIndex );
1978
 
                if ( ulResult != cOCT6100_ERR_OK )
1979
 
                        return ulResult;
1980
 
        }
1981
 
 
1982
 
        /* Set the SIN Tsst control entry.*/
1983
 
        if ( f_pChanIndexConf->usSinTsstIndex != cOCT6100_INVALID_INDEX )
1984
 
        {
1985
 
                ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
1986
 
                                                                                                                  f_pChanIndexConf->usSinTsstIndex,
1987
 
                                                                                                                  f_pChanIndexConf->usSinSoutTsiMemIndex,
1988
 
                                                                                                                  pTdmConfig->ulSinPcmLaw );
1989
 
                if ( ulResult != cOCT6100_ERR_OK )
1990
 
                        return ulResult;
1991
 
        }
1992
 
 
1993
 
        /* Set the SOUT Tsst control entry.*/
1994
 
        if ( f_pChanIndexConf->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
1995
 
        {
1996
 
                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
1997
 
                                                                                                                   f_pChanIndexConf->usSoutTsstIndex,
1998
 
                                                                                                                   f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
1999
 
                                                                                                                   pTdmConfig->ulSoutNumTssts,
2000
 
                                                                                                                   f_pChanIndexConf->usSinSoutTsiMemIndex );
2001
 
                if ( ulResult != cOCT6100_ERR_OK )
2002
 
                        return ulResult;
2003
 
        }
2004
 
 
2005
 
        /*==============================================================================*/
2006
 
 
2007
 
        /*==============================================================================*/
2008
 
        /* Configure the ADPCM control memory for the Decoder.*/
2009
 
 
2010
 
        /* Set the codec state flags.*/
2011
 
        f_pChanIndexConf->fRinRoutCodecActive = FALSE;
2012
 
        f_pChanIndexConf->fSinSoutCodecActive = FALSE;
2013
 
 
2014
 
        if ( f_pChannelOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING )
2015
 
        {
2016
 
                fProgramAdpcmMem = TRUE;
2017
 
 
2018
 
                switch( f_pChannelOpen->CodecConfig.ulDecodingRate )
2019
 
                {
2020
 
                case cOCT6100_G711_64KBPS:                              
2021
 
                        ulCompType = 0x8;               
2022
 
                        if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
2023
 
                        {
2024
 
                                if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw )
2025
 
                                        fProgramAdpcmMem = FALSE;
2026
 
                        }
2027
 
                        else /*  f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
2028
 
                        {
2029
 
                                if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
2030
 
                                        fProgramAdpcmMem = FALSE;
2031
 
                        }
2032
 
                        break;
2033
 
                case cOCT6100_G726_40KBPS:                              
2034
 
                        ulCompType = 0x3;               
2035
 
                        fConversionEnabled = TRUE;
2036
 
                        break;
2037
 
 
2038
 
                case cOCT6100_G726_32KBPS:                              
2039
 
                        ulCompType = 0x2;               
2040
 
                        fConversionEnabled = TRUE;
2041
 
                        break;
2042
 
 
2043
 
                case cOCT6100_G726_24KBPS:                              
2044
 
                        ulCompType = 0x1;               
2045
 
                        fConversionEnabled = TRUE;
2046
 
                        break;
2047
 
 
2048
 
                case cOCT6100_G726_16KBPS:                              
2049
 
                        ulCompType = 0x0;               
2050
 
                        fConversionEnabled = TRUE;
2051
 
                        break;          
2052
 
 
2053
 
                case cOCT6100_G727_2C_ENCODED:                  
2054
 
                        ulCompType = 0x4;               
2055
 
                        fConversionEnabled = TRUE;
2056
 
                        break;
2057
 
 
2058
 
                case cOCT6100_G727_3C_ENCODED:                  
2059
 
                        ulCompType = 0x5;               
2060
 
                        fConversionEnabled = TRUE;
2061
 
                        break;
2062
 
 
2063
 
                case cOCT6100_G727_4C_ENCODED:                  
2064
 
                        ulCompType = 0x6;               
2065
 
                        fConversionEnabled = TRUE;
2066
 
                        break;
2067
 
 
2068
 
                case cOCT6100_G726_ENCODED:                             
2069
 
                        ulCompType = 0x9;               
2070
 
                        fConversionEnabled = TRUE;
2071
 
                        break;
2072
 
 
2073
 
                case cOCT6100_G711_G726_ENCODED:                
2074
 
                        ulCompType = 0xA;               
2075
 
                        fConversionEnabled = TRUE;
2076
 
                        break;
2077
 
 
2078
 
                case cOCT6100_G711_G727_2C_ENCODED:             
2079
 
                        ulCompType = 0xC;               
2080
 
                        fConversionEnabled = TRUE;
2081
 
                        break;
2082
 
 
2083
 
                case cOCT6100_G711_G727_3C_ENCODED:             
2084
 
                        ulCompType = 0xD;               
2085
 
                        fConversionEnabled = TRUE;
2086
 
                        break;
2087
 
 
2088
 
                case cOCT6100_G711_G727_4C_ENCODED:             
2089
 
                        ulCompType = 0xE;               
2090
 
                        fConversionEnabled = TRUE;
2091
 
                        break;
2092
 
                default:
2093
 
                        return cOCT6100_ERR_FATAL_D4;
2094
 
                }
2095
 
 
2096
 
                if ( fProgramAdpcmMem == TRUE )
2097
 
                {
2098
 
                        /* Set the chariot memory based on the selected port.*/
2099
 
                        if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
2100
 
                        {
2101
 
                                usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
2102
 
                                ulPcmLaw = pTdmConfig->ulRoutPcmLaw;            /* Set the law for later use */
2103
 
 
2104
 
                                /* Set the codec state flags.*/
2105
 
                                f_pChanIndexConf->fRinRoutCodecActive = TRUE;
2106
 
 
2107
 
                                /* Set the conversion memory index to use for decompression */
2108
 
                                usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
2109
 
                        }
2110
 
                        else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
2111
 
                        {
2112
 
                                usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
2113
 
                                ulPcmLaw = pTdmConfig->ulSoutPcmLaw;            /* Set the law for later use */
2114
 
 
2115
 
                                /* Set the codec state flags.*/
2116
 
                                f_pChanIndexConf->fSinSoutCodecActive = TRUE;
2117
 
 
2118
 
                                /* Set the conversion memory index to use for decompression */
2119
 
                                usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
2120
 
                        }
2121
 
 
2122
 
                        ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance,
2123
 
                                                                                                         usConversionMemIndex,
2124
 
                                                                                                         ulCompType,
2125
 
                                                                                                         usTempTsiMemIndex,
2126
 
                                                                                                         ulPcmLaw,
2127
 
                                                                                                         f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition );
2128
 
                        if ( ulResult != cOCT6100_ERR_OK )
2129
 
                                return ulResult;
2130
 
                }
2131
 
        }
2132
 
        /*==============================================================================*/
2133
 
 
2134
 
 
2135
 
        /*==============================================================================*/
2136
 
        /* Configure the ADPCM control memory for the Encoder */
2137
 
 
2138
 
        if ( f_pChannelOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING )
2139
 
        {
2140
 
                fProgramAdpcmMem = TRUE;
2141
 
 
2142
 
                switch( f_pChannelOpen->CodecConfig.ulEncodingRate )
2143
 
                {
2144
 
                case cOCT6100_G711_64KBPS:
2145
 
                        if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
2146
 
                        {
2147
 
                                if ( pTdmConfig->ulRoutPcmLaw == cOCT6100_PCM_U_LAW )
2148
 
                                        ulCompType = 0x4;
2149
 
                                else
2150
 
                                        ulCompType = 0x5;
2151
 
 
2152
 
                                /* Check for law conversion.*/
2153
 
                                if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw )
2154
 
                                        fProgramAdpcmMem = FALSE;
2155
 
                        }       
2156
 
                        else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
2157
 
                        {
2158
 
                                if ( pTdmConfig->ulSoutPcmLaw == cOCT6100_PCM_U_LAW )
2159
 
                                        ulCompType = 0x4;
2160
 
                                else
2161
 
                                        ulCompType = 0x5;
2162
 
 
2163
 
                                /* Check for law conversion.*/
2164
 
                                if ( pTdmConfig->ulSinPcmLaw == pTdmConfig->ulSoutPcmLaw )
2165
 
                                        fProgramAdpcmMem = FALSE;
2166
 
                        }       
2167
 
 
2168
 
                        break;
2169
 
                case cOCT6100_G726_40KBPS:                              
2170
 
                        ulCompType = 0x3;               
2171
 
                        fConversionEnabled = TRUE;
2172
 
                        break;
2173
 
 
2174
 
                case cOCT6100_G726_32KBPS:                              
2175
 
                        ulCompType = 0x2;               
2176
 
                        fConversionEnabled = TRUE;
2177
 
                        break;
2178
 
 
2179
 
                case cOCT6100_G726_24KBPS:                              
2180
 
                        ulCompType = 0x1;               
2181
 
                        fConversionEnabled = TRUE;
2182
 
                        break;
2183
 
 
2184
 
                case cOCT6100_G726_16KBPS:                              
2185
 
                        ulCompType = 0x0;               
2186
 
                        fConversionEnabled = TRUE;
2187
 
                        break;          
2188
 
 
2189
 
                case cOCT6100_G727_40KBPS_4_1:                  
2190
 
                        ulCompType = 0xD;               
2191
 
                        fConversionEnabled = TRUE;
2192
 
                        break;
2193
 
 
2194
 
                case cOCT6100_G727_40KBPS_3_2:                  
2195
 
                        ulCompType = 0xA;               
2196
 
                        fConversionEnabled = TRUE;
2197
 
                        break;
2198
 
 
2199
 
                case cOCT6100_G727_40KBPS_2_3:                  
2200
 
                        ulCompType = 0x6;               
2201
 
                        fConversionEnabled = TRUE;
2202
 
                        break;
2203
 
 
2204
 
                case cOCT6100_G727_32KBPS_4_0:                  
2205
 
                        ulCompType = 0xE;               
2206
 
                        fConversionEnabled = TRUE;
2207
 
                        break;
2208
 
 
2209
 
                case cOCT6100_G727_32KBPS_3_1:                  
2210
 
                        ulCompType = 0xB;               
2211
 
                        fConversionEnabled = TRUE;
2212
 
                        break;
2213
 
 
2214
 
                case cOCT6100_G727_32KBPS_2_2:                  
2215
 
                        ulCompType = 0x7;               
2216
 
                        fConversionEnabled = TRUE;
2217
 
                        break;
2218
 
 
2219
 
                case cOCT6100_G727_24KBPS_3_0:                  
2220
 
                        ulCompType = 0xC;               
2221
 
                        fConversionEnabled = TRUE;
2222
 
                        break;
2223
 
 
2224
 
                case cOCT6100_G727_24KBPS_2_1:                  
2225
 
                        ulCompType = 0x8;               
2226
 
                        fConversionEnabled = TRUE;
2227
 
                        break;
2228
 
 
2229
 
                case cOCT6100_G727_16KBPS_2_0:                  
2230
 
                        ulCompType = 0x9;               
2231
 
                        fConversionEnabled = TRUE;
2232
 
                        break;
2233
 
 
2234
 
                default:
2235
 
                        return cOCT6100_ERR_FATAL_D5;
2236
 
                }
2237
 
 
2238
 
                /* Program the APDCM memory only if ADPCM is requried.*/
2239
 
                if ( fProgramAdpcmMem == TRUE || f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
2240
 
                {
2241
 
                        /* Set the chariot memory based on the selected port.*/
2242
 
                        if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
2243
 
                        {
2244
 
                                usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
2245
 
 
2246
 
                                /* Set the codec state flags.*/
2247
 
                                f_pChanIndexConf->fRinRoutCodecActive = TRUE;
2248
 
 
2249
 
                                /* Set the conversion memory index to use for compression */
2250
 
                                usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
2251
 
                        }
2252
 
 
2253
 
                        else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
2254
 
                        {
2255
 
                                usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
2256
 
 
2257
 
                                /* Set the codec state flags.*/
2258
 
                                f_pChanIndexConf->fSinSoutCodecActive = TRUE;
2259
 
 
2260
 
                                /* Set the conversion memory index to use for compression */
2261
 
                                usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
2262
 
                        }
2263
 
 
2264
 
                        ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance,
2265
 
                                                                                                         usConversionMemIndex,
2266
 
                                                                                                         ulCompType,
2267
 
                                                                                                         usTempTsiMemIndex,
2268
 
                                                                                                         f_pChannelOpen->CodecConfig.fEnableSilenceSuppression,
2269
 
                                                                                                         f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
2270
 
                                                                                                         f_pChanIndexConf->usPhasingTsstIndex,
2271
 
                                                                                                         f_pChannelOpen->CodecConfig.ulPhasingType,
2272
 
                                                                                                         f_pChannelOpen->CodecConfig.ulPhase );
2273
 
                        if ( ulResult != cOCT6100_ERR_OK )
2274
 
                                return ulResult;
2275
 
                }
2276
 
        }
2277
 
        /*==============================================================================*/
2278
 
 
2279
 
        
2280
 
        /*==============================================================================*/
2281
 
        /* Clearing the tone events bit vector */
2282
 
 
2283
 
        ulDwordAddress  = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usEchoChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
2284
 
        ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
2285
 
        ulDwordData = 0x00000000;
2286
 
 
2287
 
        ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2288
 
        if ( ulResult != cOCT6100_ERR_OK  )
2289
 
                return ulResult;
2290
 
 
2291
 
        ulDwordAddress += 4;
2292
 
 
2293
 
        ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2294
 
        if ( ulResult != cOCT6100_ERR_OK  )
2295
 
                return ulResult;
2296
 
 
2297
 
        /*==============================================================================*/
2298
 
 
2299
 
        
2300
 
        /*==============================================================================*/
2301
 
        /*      Write the VQE memory */
2302
 
        
2303
 
        ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance,
2304
 
                                                                                  &f_pChannelOpen->VqeConfig,
2305
 
                                                                                  f_pChannelOpen,
2306
 
                                                                                  f_pChanIndexConf->usEchoChanIndex,    
2307
 
                                                                                  f_pChanIndexConf->usEchoMemIndex,
2308
 
                                                                                  TRUE,
2309
 
                                                                                  FALSE );
2310
 
        if ( ulResult != cOCT6100_ERR_OK )
2311
 
                return ulResult;
2312
 
 
2313
 
        /*==============================================================================*/
2314
 
 
2315
 
        /*==============================================================================*/
2316
 
        /*      Write the echo memory */
2317
 
 
2318
 
        ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance,
2319
 
                                                                                  pTdmConfig,
2320
 
                                                                                  f_pChannelOpen,
2321
 
                                                                                  f_pChanIndexConf->usEchoMemIndex,
2322
 
                                                                                  f_pChanIndexConf->usRinRoutTsiMemIndex,
2323
 
                                                                                  f_pChanIndexConf->usSinSoutTsiMemIndex );
2324
 
        if ( ulResult != cOCT6100_ERR_OK )
2325
 
                return ulResult;
2326
 
 
2327
 
        /*==============================================================================*/
2328
 
 
2329
 
 
2330
 
 
2331
 
        /*==============================================================================*/
2332
 
        /*      Mute channel if required, this is done on a port basis */
2333
 
 
2334
 
        /* Initialize the silence indexes to invalid for now. */
2335
 
        pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
2336
 
        pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
2337
 
 
2338
 
        /* Set the TSI memory indexes. */
2339
 
        pChanEntry->usRinRoutTsiMemIndex  = f_pChanIndexConf->usRinRoutTsiMemIndex;
2340
 
        pChanEntry->usSinSoutTsiMemIndex  = f_pChanIndexConf->usSinSoutTsiMemIndex;
2341
 
 
2342
 
        ulResult = Oct6100ApiMutePorts( f_pApiInstance,
2343
 
                                                                        f_pChanIndexConf->usEchoChanIndex,
2344
 
                                                                        f_pChanIndexConf->usRinTsstIndex,
2345
 
                                                                        f_pChanIndexConf->usSinTsstIndex,
2346
 
                                                                        FALSE );
2347
 
        if ( ulResult != cOCT6100_ERR_OK )
2348
 
                return ulResult;
2349
 
        
2350
 
        /*==============================================================================*/
2351
 
 
2352
 
        
2353
 
        /*==============================================================================*/
2354
 
        /* Set the dominant speaker to unassigned, if required. */
2355
 
 
2356
 
        if ( f_pApiInstance->pSharedInfo->ImageInfo.fDominantSpeakerEnabled == TRUE )
2357
 
        {
2358
 
                ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_pChanIndexConf->usEchoChanIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED );
2359
 
                if ( ulResult != cOCT6100_ERR_OK )
2360
 
                        return ulResult;
2361
 
        }
2362
 
        
2363
 
        /*==============================================================================*/
2364
 
 
2365
 
 
2366
 
        /*==============================================================================*/
2367
 
        /* If necessary, configure the extended tone detection channel.*/
2368
 
 
2369
 
        if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
2370
 
        {
2371
 
                UINT32  ulTempSinLaw;
2372
 
                UINT32  ulTempSoutLaw;
2373
 
                UINT32  ulTempEchoOpMode;
2374
 
 
2375
 
                /* save the original law.*/
2376
 
                ulTempSinLaw            = pTdmConfig->ulSinPcmLaw;
2377
 
                ulTempSoutLaw           = pTdmConfig->ulSoutPcmLaw;
2378
 
                ulTempEchoOpMode        = f_pChannelOpen->ulEchoOperationMode;
2379
 
 
2380
 
                /* Now, make sure the Sin and Sout law are the same as the Rin law.*/
2381
 
 
2382
 
                pTdmConfig->ulSinPcmLaw         = pTdmConfig->ulRinPcmLaw;
2383
 
                pTdmConfig->ulSoutPcmLaw        = pTdmConfig->ulRinPcmLaw;
2384
 
                
2385
 
                f_pChannelOpen->ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_NORMAL;
2386
 
 
2387
 
                /* Write the Echo and VQE memory of the extended channel.*/
2388
 
 
2389
 
                ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance,
2390
 
                                                                                                   pTdmConfig,
2391
 
                                                                                                   &f_pChannelOpen->VqeConfig,
2392
 
                                                                                                   f_pChannelOpen,
2393
 
                                                                                                   f_pChanIndexConf->usExtToneChanIndex,
2394
 
                                                                                                   f_pChanIndexConf->usExtToneChanIndex,
2395
 
                                                                                                   cOCT6100_API_EXT_TONE_EXTRA_TSI,
2396
 
                                                                                                   f_pChanIndexConf->usExtToneTsiIndex );
2397
 
                if ( ulResult != cOCT6100_ERR_OK )
2398
 
                        return ulResult;
2399
 
 
2400
 
                /* Now, write the mixer event used to copy the RIN signal of the original channel
2401
 
                   into the SIN signal of the exteded channel. */
2402
 
 
2403
 
                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_pChanIndexConf->usExtToneMixerIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
2404
 
                
2405
 
                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
2406
 
                WriteParams.usWriteData |= f_pChanIndexConf->usRinRoutTsiMemIndex;
2407
 
                WriteParams.usWriteData |= pTdmConfig->ulRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
2408
 
 
2409
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2410
 
                if ( ulResult != cOCT6100_ERR_OK  )
2411
 
                        return ulResult;
2412
 
 
2413
 
                WriteParams.ulWriteAddress += 2;
2414
 
                WriteParams.usWriteData = f_pChanIndexConf->usExtToneTsiIndex;
2415
 
 
2416
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2417
 
                if ( ulResult != cOCT6100_ERR_OK  )
2418
 
                        return ulResult;
2419
 
 
2420
 
                /*=======================================================================*/
2421
 
 
2422
 
 
2423
 
                /*=======================================================================*/
2424
 
                /* Now insert the Sin copy event into the list.*/
2425
 
 
2426
 
                ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
2427
 
                                                                                        f_pChanIndexConf->usExtToneMixerIndex,
2428
 
                                                                                        cOCT6100_EVENT_TYPE_SIN_COPY,
2429
 
                                                                                        f_pChanIndexConf->usEchoChanIndex );
2430
 
                if ( ulResult != cOCT6100_ERR_OK )
2431
 
                        return ulResult;
2432
 
                /*=======================================================================*/
2433
 
 
2434
 
                /*==============================================================================*/
2435
 
                /* Clearing the tone events bit vector */
2436
 
 
2437
 
                ulDwordAddress  = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
2438
 
                ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
2439
 
                ulDwordData = 0x00000000;
2440
 
 
2441
 
                ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2442
 
                if ( ulResult != cOCT6100_ERR_OK  )
2443
 
                        return ulResult;
2444
 
 
2445
 
                ulDwordAddress += 4;
2446
 
 
2447
 
                ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2448
 
                if ( ulResult != cOCT6100_ERR_OK  )
2449
 
                        return ulResult;
2450
 
 
2451
 
                /*==============================================================================*/
2452
 
 
2453
 
                /* Write back the original values in the channel open structure.*/
2454
 
 
2455
 
                pTdmConfig->ulSinPcmLaw         = ulTempSinLaw;
2456
 
                pTdmConfig->ulSoutPcmLaw        = ulTempSoutLaw;
2457
 
                
2458
 
                f_pChannelOpen->ulEchoOperationMode = ulTempEchoOpMode;
2459
 
        }
2460
 
 
2461
 
        /*==============================================================================*/
2462
 
 
2463
 
 
2464
 
        /*==============================================================================*/
2465
 
        /* If necessary, configure the SS tone detection. */
2466
 
 
2467
 
        for ( ulToneEventNumber = 0; ulToneEventNumber < cOCT6100_MAX_TONE_EVENT; ulToneEventNumber++ )
2468
 
        {
2469
 
                /* Check if the current tone is a SS tone. */
2470
 
                ulResult = Oct6100ApiIsSSTone( 
2471
 
                                                                        f_pApiInstance, 
2472
 
                                                                        f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID, 
2473
 
                                                                        &fSSTone );
2474
 
                if ( ulResult != cOCT6100_ERR_OK )
2475
 
                        return ulResult;
2476
 
 
2477
 
                if ( fSSTone == TRUE )
2478
 
                {
2479
 
                        /* Write to all resources needed to activate tone detection on this SS tone. */
2480
 
                        ulResult = Oct6100ApiWriteToneDetectEvent( 
2481
 
                                                                                                        f_pApiInstance, 
2482
 
                                                                                                        f_pChanIndexConf->usEchoChanIndex, 
2483
 
                                                                                                        ulToneEventNumber,
2484
 
 
2485
 
                                                                                                        cOCT6100_INVALID_INDEX );
2486
 
                        if ( ulResult != cOCT6100_ERR_OK  )
2487
 
                                return ulResult;
2488
 
                }
2489
 
        }
2490
 
 
2491
 
        /*==============================================================================*/
2492
 
 
2493
 
 
2494
 
        return cOCT6100_ERR_OK;
2495
 
}
2496
 
#endif
2497
 
 
2498
 
 
2499
 
 
2500
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2501
 
 
2502
 
Function:               Oct6100ApiUpdateChannelEntry
2503
 
 
2504
 
Description:    Updates the new channel in the ECHO channel list.
2505
 
 
2506
 
-------------------------------------------------------------------------------
2507
 
|       Argument                |       Description
2508
 
-------------------------------------------------------------------------------
2509
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
2510
 
                                                the present state of the chip and all its resources.
2511
 
 
2512
 
f_pChannelOpen                  Pointer to echo cancellation channel configuration structure.
2513
 
f_pChanIndexConf                Pointer to a structure used to store the multiple resources indexes.
2514
 
 
2515
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2516
 
#if !SKIP_Oct6100ApiUpdateChannelEntry
2517
 
UINT32 Oct6100ApiUpdateChannelEntry(
2518
 
                                IN tPOCT6100_INSTANCE_API                       f_pApiInstance,
2519
 
                                IN tPOCT6100_CHANNEL_OPEN                       f_pChannelOpen,
2520
 
                                OUT tPOCT6100_API_ECHO_CHAN_INDEX       f_pChanIndexConf )
2521
 
{
2522
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
2523
 
        tPOCT6100_CHANNEL_OPEN_TDM              pTdmConfig;
2524
 
        tPOCT6100_CHANNEL_OPEN_VQE              pVqeConfig;
2525
 
        tPOCT6100_CHANNEL_OPEN_CODEC    pCodecConfig;
2526
 
 
2527
 
        /* Obtain a pointer to the config structures of the tPOCT6100_CHANNEL_OPEN structure. */
2528
 
        pTdmConfig   = &f_pChannelOpen->TdmConfig;
2529
 
        pVqeConfig   = &f_pChannelOpen->VqeConfig;
2530
 
        pCodecConfig = &f_pChannelOpen->CodecConfig;
2531
 
 
2532
 
        /* Obtain a pointer to the new buffer's list entry. */
2533
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex )
2534
 
        
2535
 
        /*=======================================================================*/
2536
 
        /* Copy the channel's configuration and allocated resources. */
2537
 
        pChanEntry->ulUserChanId = f_pChannelOpen->ulUserChanId;
2538
 
        pChanEntry->byEchoOperationMode = (UINT8)( f_pChannelOpen->ulEchoOperationMode & 0xFF );
2539
 
        pChanEntry->fEnableToneDisabler = (UINT8)( f_pChannelOpen->fEnableToneDisabler & 0xFF );
2540
 
        pChanEntry->fEnableExtToneDetection = (UINT8)( f_pChannelOpen->fEnableExtToneDetection & 0xFF );
2541
 
 
2542
 
        /* Save the VQE configuration.*/
2543
 
        pChanEntry->VqeConfig.byComfortNoiseMode = (UINT8)( pVqeConfig->ulComfortNoiseMode & 0xFF );
2544
 
        pChanEntry->VqeConfig.fEnableNlp = (UINT8)( pVqeConfig->fEnableNlp & 0xFF );
2545
 
        pChanEntry->VqeConfig.fEnableTailDisplacement = (UINT8)( pVqeConfig->fEnableTailDisplacement );
2546
 
        pChanEntry->VqeConfig.usTailDisplacement = (UINT16)( pVqeConfig->ulTailDisplacement & 0xFFFF );
2547
 
        pChanEntry->VqeConfig.usTailLength = (UINT16)( pVqeConfig->ulTailLength & 0xFFFF );
2548
 
 
2549
 
        pChanEntry->VqeConfig.fSinDcOffsetRemoval = (UINT8)( pVqeConfig->fSinDcOffsetRemoval & 0xFF );
2550
 
        pChanEntry->VqeConfig.fRinDcOffsetRemoval = (UINT8)( pVqeConfig->fRinDcOffsetRemoval & 0xFF );
2551
 
        pChanEntry->VqeConfig.fRinLevelControl = (UINT8)( pVqeConfig->fRinLevelControl & 0xFF );
2552
 
        pChanEntry->VqeConfig.chRinLevelControlGainDb = (OCT_INT8)( pVqeConfig->lRinLevelControlGainDb & 0xFF );
2553
 
        pChanEntry->VqeConfig.fSoutLevelControl = (UINT8)( pVqeConfig->fSoutLevelControl & 0xFF );
2554
 
        pChanEntry->VqeConfig.chSoutLevelControlGainDb = (OCT_INT8)( pVqeConfig->lSoutLevelControlGainDb & 0xFF );
2555
 
        pChanEntry->VqeConfig.fRinAutomaticLevelControl = (UINT8)( pVqeConfig->fRinAutomaticLevelControl & 0xFF );
2556
 
        pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb = (OCT_INT8)( pVqeConfig->lRinAutomaticLevelControlTargetDb & 0xFF );
2557
 
        pChanEntry->VqeConfig.fSoutAutomaticLevelControl = (UINT8)( pVqeConfig->fSoutAutomaticLevelControl & 0xFF );
2558
 
        pChanEntry->VqeConfig.usAlcNoiseBleedOutTime = (UINT16)( pVqeConfig->ulAlcNoiseBleedOutTime & 0xFFFF );
2559
 
        pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb = (OCT_INT8)( pVqeConfig->lSoutAutomaticLevelControlTargetDb & 0xFF );
2560
 
        pChanEntry->VqeConfig.fRinHighLevelCompensation = (UINT8)( pVqeConfig->fRinHighLevelCompensation & 0xFF );
2561
 
        pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb = (OCT_INT8)( pVqeConfig->lRinHighLevelCompensationThresholdDb & 0xFF );
2562
 
        pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction = (UINT8)( pVqeConfig->fSoutAdaptiveNoiseReduction & 0xFF );
2563
 
        pChanEntry->VqeConfig.fSoutNoiseBleaching = (UINT8)( pVqeConfig->fSoutNoiseBleaching & 0xFF );
2564
 
        pChanEntry->VqeConfig.fSoutConferencingNoiseReduction = (UINT8)( pVqeConfig->fSoutConferencingNoiseReduction & 0xFF );
2565
 
 
2566
 
        pChanEntry->VqeConfig.fAcousticEcho             = (UINT8)( pVqeConfig->fAcousticEcho & 0xFF );
2567
 
 
2568
 
        pChanEntry->VqeConfig.fDtmfToneRemoval  = (UINT8)( pVqeConfig->fDtmfToneRemoval & 0xFF );
2569
 
 
2570
 
        pChanEntry->VqeConfig.chDefaultErlDb    = (OCT_INT8)( pVqeConfig->lDefaultErlDb & 0xFF );
2571
 
        pChanEntry->VqeConfig.chAecDefaultErlDb = (OCT_INT8)( pVqeConfig->lAecDefaultErlDb & 0xFF );
2572
 
        pChanEntry->VqeConfig.usAecTailLength = (UINT16)( pVqeConfig->ulAecTailLength & 0xFFFF );
2573
 
        pChanEntry->VqeConfig.byNonLinearityBehaviorA = (UINT8)( pVqeConfig->ulNonLinearityBehaviorA & 0xFF );
2574
 
        pChanEntry->VqeConfig.byNonLinearityBehaviorB = (UINT8)( pVqeConfig->ulNonLinearityBehaviorB & 0xFF );
2575
 
        pChanEntry->VqeConfig.byDoubleTalkBehavior = (UINT8)( pVqeConfig->ulDoubleTalkBehavior & 0xFF );
2576
 
        pChanEntry->VqeConfig.chAnrSnrEnhancementDb     = (OCT_INT8)( pVqeConfig->lAnrSnrEnhancementDb & 0xFF );
2577
 
        pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation = (UINT8)( pVqeConfig->ulAnrVoiceNoiseSegregation & 0xFF );
2578
 
        pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay = (UINT16)( pVqeConfig->ulToneDisablerVqeActivationDelay & 0xFFFF );
2579
 
 
2580
 
        pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb = (UINT8)( pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb & 0xFF );
2581
 
        pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb = (UINT8)( pVqeConfig->ulSoutNaturalListenerEnhancementGainDb & 0xFF );
2582
 
        pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement = (UINT8)( pVqeConfig->fSoutNaturalListenerEnhancement & 0xFF );
2583
 
        pChanEntry->VqeConfig.fRoutNoiseReduction = (UINT8)( pVqeConfig->fRoutNoiseReduction & 0xFF );
2584
 
        pChanEntry->VqeConfig.fEnableMusicProtection = (UINT8)( pVqeConfig->fEnableMusicProtection & 0xFF );
2585
 
        pChanEntry->VqeConfig.fIdleCodeDetection = (UINT8)( pVqeConfig->fIdleCodeDetection & 0xFF );
2586
 
        pChanEntry->VqeConfig.fResetRinAlcOnTones = (UINT8)( pVqeConfig->fResetRinAlcOnTones & 0xFF );
2587
 
        pChanEntry->VqeConfig.fResetSoutAlcOnTones = (UINT8)( pVqeConfig->fResetSoutAlcOnTones & 0xFF );
2588
 
 
2589
 
        /* Save the codec information.*/
2590
 
        pChanEntry->CodecConfig.byAdpcmNibblePosition = (UINT8)( pCodecConfig->ulAdpcmNibblePosition & 0xFF );
2591
 
 
2592
 
        pChanEntry->CodecConfig.byDecoderPort = (UINT8)( pCodecConfig->ulDecoderPort & 0xFF );
2593
 
        pChanEntry->CodecConfig.byDecodingRate = (UINT8)( pCodecConfig->ulDecodingRate & 0xFF );
2594
 
        pChanEntry->CodecConfig.byEncoderPort = (UINT8)( pCodecConfig->ulEncoderPort & 0xFF );
2595
 
        pChanEntry->CodecConfig.byEncodingRate = (UINT8)( pCodecConfig->ulEncodingRate & 0xFF );
2596
 
        
2597
 
        pChanEntry->CodecConfig.fEnableSilenceSuppression = (UINT8)( pCodecConfig->fEnableSilenceSuppression & 0xFF );
2598
 
        pChanEntry->CodecConfig.byPhase = (UINT8)( pCodecConfig->ulPhase & 0xFF );
2599
 
        pChanEntry->CodecConfig.byPhasingType = (UINT8)( pCodecConfig->ulPhasingType & 0xFF );
2600
 
        
2601
 
        /* Save the RIN settings.*/
2602
 
        pChanEntry->TdmConfig.byRinPcmLaw = (UINT8)( pTdmConfig->ulRinPcmLaw & 0xFF );
2603
 
        pChanEntry->TdmConfig.usRinTimeslot = (UINT16)( pTdmConfig->ulRinTimeslot & 0xFFFF );
2604
 
        pChanEntry->TdmConfig.usRinStream = (UINT16)( pTdmConfig->ulRinStream & 0xFFFF );
2605
 
        
2606
 
        /* Save the SIN settings.*/
2607
 
        pChanEntry->TdmConfig.bySinPcmLaw = (UINT8)( pTdmConfig->ulSinPcmLaw & 0xFF );
2608
 
        pChanEntry->TdmConfig.usSinTimeslot = (UINT16)( pTdmConfig->ulSinTimeslot & 0xFFFF );
2609
 
        pChanEntry->TdmConfig.usSinStream = (UINT16)( pTdmConfig->ulSinStream & 0xFFFF );
2610
 
 
2611
 
        /* Save the ROUT settings.*/
2612
 
        pChanEntry->TdmConfig.byRoutPcmLaw = (UINT8)( pTdmConfig->ulRoutPcmLaw & 0xFF );
2613
 
        pChanEntry->TdmConfig.usRoutTimeslot = (UINT16)( pTdmConfig->ulRoutTimeslot & 0xFFFF );
2614
 
        pChanEntry->TdmConfig.usRoutStream = (UINT16)( pTdmConfig->ulRoutStream & 0xFFFF );
2615
 
 
2616
 
        pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
2617
 
        pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0;
2618
 
 
2619
 
        /* Save the SOUT settings.*/
2620
 
        pChanEntry->TdmConfig.bySoutPcmLaw = (UINT8)( pTdmConfig->ulSoutPcmLaw & 0xFF );
2621
 
        pChanEntry->TdmConfig.usSoutTimeslot = (UINT16)( pTdmConfig->ulSoutTimeslot & 0xFFFF );
2622
 
        pChanEntry->TdmConfig.usSoutStream = (UINT16)( pTdmConfig->ulSoutStream & 0xFFFF );
2623
 
 
2624
 
        pChanEntry->TdmConfig.byRinNumTssts = (UINT8)( pTdmConfig->ulRinNumTssts & 0xFF );
2625
 
        pChanEntry->TdmConfig.bySinNumTssts = (UINT8)( pTdmConfig->ulSinNumTssts & 0xFF );
2626
 
        pChanEntry->TdmConfig.byRoutNumTssts = (UINT8)( pTdmConfig->ulRoutNumTssts & 0xFF );
2627
 
        pChanEntry->TdmConfig.bySoutNumTssts = (UINT8)( pTdmConfig->ulSoutNumTssts & 0xFF );
2628
 
        pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
2629
 
        pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry = 0;
2630
 
 
2631
 
        /* Save the extended Tone detection information.*/
2632
 
        pChanEntry->usExtToneChanIndex          = f_pChanIndexConf->usExtToneChanIndex;
2633
 
        pChanEntry->usExtToneMixerIndex         = f_pChanIndexConf->usExtToneMixerIndex;
2634
 
        pChanEntry->usExtToneTsiIndex           = f_pChanIndexConf->usExtToneTsiIndex;
2635
 
 
2636
 
        if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
2637
 
        {
2638
 
                tPOCT6100_API_CHANNEL                   pExtToneChanEntry;
2639
 
 
2640
 
                /* Set the mode of the original channel. He is the channel performing detection on the
2641
 
                   SIN port.  The extended channel will perform detection on the RIN port.*/
2642
 
                pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_SIN_PORT_MODE;
2643
 
 
2644
 
                /* Now, program the associated channel.*/
2645
 
                
2646
 
                /* Obtain a pointer to the extended tone detection channel entry. */
2647
 
                mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pExtToneChanEntry, f_pChanIndexConf->usExtToneChanIndex );
2648
 
 
2649
 
                pExtToneChanEntry->fReserved                    = TRUE;
2650
 
                pExtToneChanEntry->ulExtToneChanMode    = cOCT6100_API_EXT_TONE_RIN_PORT_MODE;  /* Detect on RIN port.*/
2651
 
                pExtToneChanEntry->usExtToneChanIndex   = f_pChanIndexConf->usEchoChanIndex;
2652
 
 
2653
 
                pExtToneChanEntry->aulToneConf[ 0 ] = 0;
2654
 
                pExtToneChanEntry->aulToneConf[ 1 ] = 0;
2655
 
 
2656
 
        }
2657
 
        else
2658
 
        {
2659
 
                /* No extended tone detection supported.*/
2660
 
                pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED;
2661
 
        }
2662
 
 
2663
 
        /*=======================================================================*/
2664
 
 
2665
 
        /*=======================================================================*/
2666
 
        /* Store hardware related information.*/
2667
 
        pChanEntry->usRinRoutTsiMemIndex  = f_pChanIndexConf->usRinRoutTsiMemIndex;
2668
 
        pChanEntry->usSinSoutTsiMemIndex  = f_pChanIndexConf->usSinSoutTsiMemIndex;
2669
 
        pChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
2670
 
        pChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX;
2671
 
 
2672
 
        /* We are not being tapped for now. */
2673
 
        pChanEntry->fBeingTapped = FALSE;
2674
 
 
2675
 
        pChanEntry->usTapChanIndex = cOCT6100_INVALID_INDEX;
2676
 
        pChanEntry->usTapBridgeIndex = cOCT6100_INVALID_INDEX;
2677
 
 
2678
 
        /* The copy event has not yet been created. */
2679
 
        pChanEntry->fCopyEventCreated = FALSE;
2680
 
 
2681
 
        pChanEntry->usRinRoutConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
2682
 
        pChanEntry->usSinSoutConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
2683
 
 
2684
 
        pChanEntry->usPhasingTsstIndex = f_pChanIndexConf->usPhasingTsstIndex;
2685
 
 
2686
 
        pChanEntry->fSinSoutCodecActive = f_pChanIndexConf->fSinSoutCodecActive;
2687
 
        pChanEntry->fRinRoutCodecActive = f_pChanIndexConf->fRinRoutCodecActive;
2688
 
        
2689
 
 
2690
 
 
2691
 
        pChanEntry->usEchoMemIndex = f_pChanIndexConf->usEchoMemIndex;
2692
 
 
2693
 
        pChanEntry->usRinTsstIndex = f_pChanIndexConf->usRinTsstIndex;
2694
 
        pChanEntry->usSinTsstIndex = f_pChanIndexConf->usSinTsstIndex;
2695
 
        pChanEntry->usRoutTsstIndex = f_pChanIndexConf->usRoutTsstIndex;
2696
 
        pChanEntry->usSoutTsstIndex = f_pChanIndexConf->usSoutTsstIndex;
2697
 
 
2698
 
        pChanEntry->usSinCopyEventIndex         = cOCT6100_INVALID_INDEX;
2699
 
        pChanEntry->usSoutCopyEventIndex        = cOCT6100_INVALID_INDEX;
2700
 
 
2701
 
        /* Nothing muted for now. */
2702
 
        pChanEntry->usMutedPorts                        = cOCT6100_CHANNEL_MUTE_PORT_NONE;
2703
 
 
2704
 
        /* Set all the GW feature initial value.*/
2705
 
        /* Bridge info */
2706
 
        pChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
2707
 
        pChanEntry->fMute = FALSE;
2708
 
 
2709
 
        pChanEntry->usLoadEventIndex            = cOCT6100_INVALID_INDEX;
2710
 
        pChanEntry->usSubStoreEventIndex        = cOCT6100_INVALID_INDEX;
2711
 
 
2712
 
        /* Buffer playout info.*/
2713
 
        pChanEntry->fRinBufPlaying = FALSE;
2714
 
        pChanEntry->fSoutBufPlaying = FALSE;
2715
 
 
2716
 
        /* Tone detection state. */
2717
 
        /* This array is configured as follow.*/
2718
 
        /* Index 0 contain event 0 to 31 (msb = event 31) and Index 1 contain index 32 - 55  */
2719
 
        pChanEntry->aulToneConf[ 0 ] = 0;
2720
 
        pChanEntry->aulToneConf[ 1 ] = 0;
2721
 
        pChanEntry->ulLastSSToneDetected = cOCT6100_INVALID_VALUE;
2722
 
        pChanEntry->ulLastSSToneTimestamp = cOCT6100_INVALID_VALUE;
2723
 
 
2724
 
        /* Initialize the bidirectional flag.*/
2725
 
        pChanEntry->fBiDirChannel = FALSE;
2726
 
 
2727
 
        /*=======================================================================*/
2728
 
        /* Init some of the stats.*/
2729
 
 
2730
 
        pChanEntry->sMaxERL                                             = cOCT6100_INVALID_SIGNED_STAT_W;
2731
 
        pChanEntry->sMaxERLE                                    = cOCT6100_INVALID_SIGNED_STAT_W;
2732
 
        pChanEntry->usMaxEchoDelay                              = cOCT6100_INVALID_STAT_W;
2733
 
        pChanEntry->usNumEchoPathChangesOfst    = 0;
2734
 
 
2735
 
        /*=======================================================================*/
2736
 
 
2737
 
        /*=======================================================================*/
2738
 
        /* Update the dependency of the phasing TSST if one is associated to the chanel.*/
2739
 
 
2740
 
        if ( f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
2741
 
        {
2742
 
                tPOCT6100_API_PHASING_TSST      pPhasingEntry;
2743
 
 
2744
 
                mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanIndexConf->usPhasingTsstIndex );
2745
 
 
2746
 
                pPhasingEntry->usDependencyCnt++;
2747
 
        }
2748
 
        /*=======================================================================*/
2749
 
 
2750
 
        /*=======================================================================*/
2751
 
        
2752
 
        /* Form handle returned to user. */
2753
 
        *f_pChannelOpen->pulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_pChanIndexConf->usEchoChanIndex;
2754
 
 
2755
 
        /* Finally, mark the channel as open. */
2756
 
        pChanEntry->fReserved = TRUE;
2757
 
        pChanEntry->usExtraSinTsiDependencyCnt = 0;
2758
 
        
2759
 
        /* Increment the number of channel open.*/
2760
 
        f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels++;
2761
 
 
2762
 
        /*=======================================================================*/
2763
 
 
2764
 
        return cOCT6100_ERR_OK;
2765
 
}
2766
 
#endif
2767
 
 
2768
 
 
2769
 
 
2770
 
 
2771
 
 
2772
 
 
2773
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2774
 
 
2775
 
Function:               Oct6100ChannelCloseSer
2776
 
 
2777
 
Description:    Closes a echo cancellation channel.
2778
 
 
2779
 
-------------------------------------------------------------------------------
2780
 
|       Argument                |       Description
2781
 
-------------------------------------------------------------------------------
2782
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
2783
 
                                                present state of the chip and all its resources.
2784
 
 
2785
 
f_pChannelClose                 Pointer to echo cancellation channel close structure.
2786
 
 
2787
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2788
 
#if !SKIP_Oct6100ChannelCloseSer
2789
 
UINT32 Oct6100ChannelCloseSer(
2790
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
2791
 
                                IN tPOCT6100_CHANNEL_CLOSE                              f_pChannelClose )
2792
 
{
2793
 
        UINT16  usChannelIndex;
2794
 
 
2795
 
 
2796
 
        UINT32  ulResult;
2797
 
 
2798
 
        /* Verify that all the parameters given match the state of the API. */
2799
 
        ulResult = Oct6100ApiAssertChannelParams( f_pApiInstance, 
2800
 
                                                                                          f_pChannelClose, 
2801
 
 
2802
 
                                                                                          &usChannelIndex );
2803
 
        if ( ulResult != cOCT6100_ERR_OK  )
2804
 
                return ulResult;
2805
 
 
2806
 
        /* Release all resources associated to the echo cancellation channel. */
2807
 
        ulResult = Oct6100ApiInvalidateChannelStructs( f_pApiInstance, 
2808
 
 
2809
 
                                                                                                   usChannelIndex );
2810
 
        if ( ulResult != cOCT6100_ERR_OK  )
2811
 
                return ulResult;
2812
 
 
2813
 
        /* Release all resources associated to the echo cancellation channel. */
2814
 
        ulResult = Oct6100ApiReleaseChannelResources( f_pApiInstance, usChannelIndex );
2815
 
        if ( ulResult != cOCT6100_ERR_OK  )
2816
 
                return ulResult;
2817
 
 
2818
 
        /* Invalidate the handle.*/
2819
 
        f_pChannelClose->ulChannelHndl = cOCT6100_INVALID_HANDLE;
2820
 
 
2821
 
        return cOCT6100_ERR_OK;
2822
 
}
2823
 
#endif
2824
 
 
2825
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2826
 
 
2827
 
Function:               Oct6100ApiAssertChannelParams
2828
 
 
2829
 
Description:    Validate the handle given by the user and verify the state of 
2830
 
                                the channel about to be closed.
2831
 
 
2832
 
-------------------------------------------------------------------------------
2833
 
|       Argument                |       Description
2834
 
-------------------------------------------------------------------------------
2835
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
2836
 
                                                present state of the chip and all its resources.
2837
 
 
2838
 
f_pChannelClose                 Pointer to echo cancellation channel close structure.
2839
 
f_pulFpgaChanIndex              Pointer to the FPGA channel index associated to this channel.
2840
 
f_pusChanIndex                  Pointer to the index of the channel within the API instance.
2841
 
 
2842
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2843
 
#if !SKIP_Oct6100ApiAssertChannelParams
2844
 
UINT32 Oct6100ApiAssertChannelParams( 
2845
 
                                IN              tPOCT6100_INSTANCE_API                          f_pApiInstance,
2846
 
                                IN              tPOCT6100_CHANNEL_CLOSE                         f_pChannelClose,
2847
 
 
2848
 
                                IN OUT  PUINT16                                                         f_pusChanIndex )
2849
 
{
2850
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
2851
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
2852
 
        UINT32                                                  ulEntryOpenCnt;
2853
 
 
2854
 
        /* Get local pointer(s). */
2855
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
2856
 
 
2857
 
        /* Check the provided handle. */
2858
 
        if ( (f_pChannelClose->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
2859
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2860
 
 
2861
 
        *f_pusChanIndex = (UINT16)( f_pChannelClose->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
2862
 
        if ( *f_pusChanIndex  >= pSharedInfo->ChipConfig.usMaxChannels )
2863
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2864
 
 
2865
 
        /*=======================================================================*/
2866
 
        /* Get a pointer to the channel's list entry. */
2867
 
 
2868
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex  )
2869
 
 
2870
 
        /* Extract the entry open count from the provided handle. */
2871
 
        ulEntryOpenCnt = ( f_pChannelClose->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
2872
 
 
2873
 
        /* Check for errors. */
2874
 
        if ( pChanEntry->fReserved != TRUE )
2875
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
2876
 
        if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
2877
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2878
 
        if ( pChanEntry->fBiDirChannel == TRUE )
2879
 
                return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL;
2880
 
 
2881
 
        /*=======================================================================*/
2882
 
        
2883
 
        /* Check if the channel is bound to a bridge. */
2884
 
        if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
2885
 
                return cOCT6100_ERR_CHANNEL_ACTIVE_DEPENDENCIES;
2886
 
 
2887
 
 
2888
 
 
2889
 
        return cOCT6100_ERR_OK;
2890
 
}
2891
 
#endif
2892
 
 
2893
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2894
 
 
2895
 
Function:               Oct6100ApiInvalidateChannelStructs
2896
 
 
2897
 
Description:    Closes a echo cancellation channel.
2898
 
 
2899
 
-------------------------------------------------------------------------------
2900
 
|       Argument                |       Description
2901
 
-------------------------------------------------------------------------------
2902
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
2903
 
                                                present state of the chip and all its resources.
2904
 
 
2905
 
f_ulFpgaChanIndex               Index of the channel within the SCN_PLC FPGA.
2906
 
f_usChanIndex                   Index of the channel within the API instance.
2907
 
 
2908
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2909
 
#if !SKIP_Oct6100ApiInvalidateChannelStructs
2910
 
UINT32 Oct6100ApiInvalidateChannelStructs( 
2911
 
                                IN              tPOCT6100_INSTANCE_API                          f_pApiInstance,
2912
 
 
2913
 
                                IN              UINT16                                                          f_usChanIndex )
2914
 
{
2915
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
2916
 
        tPOCT6100_API_CHANNEL_TDM               pTdmConfig;
2917
 
        tPOCT6100_API_TSST_ENTRY                pTsstEntry;
2918
 
        tOCT6100_BUFFER_PLAYOUT_STOP    BufferPlayoutStop;
2919
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
2920
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
2921
 
        tOCT6100_WRITE_SMEAR_PARAMS             SmearParams;
2922
 
        UINT32                                                  ulResult;
2923
 
        UINT16                                                  usCurrentEntry;
2924
 
        
2925
 
        /* Obtain local pointer to shared portion of instance. */
2926
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
2927
 
 
2928
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
2929
 
        
2930
 
        /* Obtain local pointer to the TDM configuration of the channel */
2931
 
        pTdmConfig = &pChanEntry->TdmConfig;
2932
 
 
2933
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
2934
 
 
2935
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
2936
 
 
2937
 
        SmearParams.pProcessContext = f_pApiInstance->pProcessContext;
2938
 
 
2939
 
        SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
2940
 
        
2941
 
        /* If this channel is currently debugged, automatically close the debug channel. */
2942
 
        if ( ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
2943
 
                && ( pSharedInfo->DebugInfo.usCurrentDebugChanIndex == f_usChanIndex ) )
2944
 
        {
2945
 
                tOCT6100_DEBUG_SELECT_CHANNEL   SelectDebugChan;
2946
 
 
2947
 
                /* Ensure forward compatibility. */
2948
 
                Oct6100DebugSelectChannelDef( &SelectDebugChan );
2949
 
 
2950
 
                /* Set the hot channel to an invalid handle to disable recording. */
2951
 
                SelectDebugChan.ulChannelHndl = cOCT6100_INVALID_HANDLE;
2952
 
 
2953
 
                /* Call the serialized fonction. */
2954
 
                ulResult = Oct6100DebugSelectChannelSer( f_pApiInstance, &SelectDebugChan, FALSE );
2955
 
                if ( ulResult != cOCT6100_ERR_OK )
2956
 
                        return ulResult;
2957
 
        }
2958
 
 
2959
 
        /* Deactivate the TSST control memory if used. */
2960
 
        
2961
 
        /* RIN port.*/
2962
 
        if ( pTdmConfig->usRinTimeslot != cOCT6100_UNASSIGNED )
2963
 
        {
2964
 
                /* Deactivate the TSST entry.*/
2965
 
                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usRinTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
2966
 
                WriteParams.usWriteData  = 0x0000;
2967
 
 
2968
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2969
 
                if ( ulResult != cOCT6100_ERR_OK  )
2970
 
                        return ulResult;
2971
 
        }
2972
 
 
2973
 
        /* SIN port.*/
2974
 
        if ( pTdmConfig->usSinTimeslot != cOCT6100_UNASSIGNED )
2975
 
        {
2976
 
                /* Deactivate the TSST entry.*/
2977
 
                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usSinTsstIndex  * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
2978
 
                WriteParams.usWriteData  = 0x0000;
2979
 
 
2980
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2981
 
                if ( ulResult != cOCT6100_ERR_OK  )
2982
 
                        return ulResult;
2983
 
        }
2984
 
        
2985
 
        /*=======================================================================*/
2986
 
        /* ROUT port.*/
2987
 
        
2988
 
        if ( pTdmConfig->usRoutTimeslot != cOCT6100_UNASSIGNED )
2989
 
        {
2990
 
                /* Deactivate the TSST entry.*/
2991
 
                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usRoutTsstIndex  * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
2992
 
                WriteParams.usWriteData  = 0x0000;
2993
 
 
2994
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2995
 
                if ( ulResult != cOCT6100_ERR_OK  )
2996
 
                        return ulResult;
2997
 
        }
2998
 
 
2999
 
        /* Now the broadcast TSST.*/
3000
 
        usCurrentEntry = pTdmConfig->usRoutBrdcastTsstFirstEntry;
3001
 
        while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3002
 
        {
3003
 
                mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3004
 
 
3005
 
                /* Deactivate the TSST entry.*/
3006
 
                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pTsstEntry->usTsstMemoryIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3007
 
                WriteParams.usWriteData  = 0x0000;
3008
 
 
3009
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3010
 
                if ( ulResult != cOCT6100_ERR_OK  )
3011
 
                        return ulResult;
3012
 
                
3013
 
                /* Move to the next entry.*/
3014
 
                usCurrentEntry = pTsstEntry->usNextEntry;
3015
 
        }
3016
 
        /*=======================================================================*/
3017
 
        
3018
 
        /*=======================================================================*/
3019
 
        /* SOUT port.*/
3020
 
 
3021
 
        if ( pTdmConfig->usSoutTimeslot != cOCT6100_UNASSIGNED )
3022
 
        {
3023
 
                /* Deactivate the TSST entry.*/
3024
 
                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usSoutTsstIndex  * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3025
 
                WriteParams.usWriteData  = 0x0000;
3026
 
 
3027
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3028
 
                if ( ulResult != cOCT6100_ERR_OK  )
3029
 
                        return ulResult;
3030
 
        }
3031
 
 
3032
 
        /* Now the broadcast TSST.*/
3033
 
        usCurrentEntry = pTdmConfig->usSoutBrdcastTsstFirstEntry;
3034
 
        while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3035
 
        {
3036
 
                mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3037
 
 
3038
 
                /* Deactivate the TSST entry.*/
3039
 
                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pTsstEntry->usTsstMemoryIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3040
 
                WriteParams.usWriteData  = 0x0000;
3041
 
 
3042
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3043
 
                if ( ulResult != cOCT6100_ERR_OK  )
3044
 
                        return ulResult;
3045
 
                
3046
 
                /* Move to the next entry.*/
3047
 
                usCurrentEntry = pTsstEntry->usNextEntry;
3048
 
        }
3049
 
                /*=======================================================================*/
3050
 
 
3051
 
        
3052
 
        /*------------------------------------------------------------------------------*/
3053
 
        /* Deactivate the ECHO control memory entry.*/
3054
 
        
3055
 
        /* Set the input Echo control entry to unused.*/
3056
 
        WriteParams.ulWriteAddress  = cOCT6100_ECHO_CONTROL_MEM_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
3057
 
        WriteParams.usWriteData = 0x85FF;       /* TSI index 1535 reserved for power-down mode */
3058
 
 
3059
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3060
 
        if ( ulResult != cOCT6100_ERR_OK  )
3061
 
                return ulResult;
3062
 
 
3063
 
        WriteParams.ulWriteAddress += 2;
3064
 
        WriteParams.usWriteData = 0xC5FF;       /* TSI index 1535 reserved for power-down mode */
3065
 
 
3066
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3067
 
        if ( ulResult != cOCT6100_ERR_OK  )
3068
 
                return ulResult;
3069
 
        /*------------------------------------------------------------------------------*/
3070
 
 
3071
 
        /*------------------------------------------------------------------------------*/
3072
 
        /* Deactivate the conversion control memories if used. */
3073
 
        
3074
 
        if ( pChanEntry->usRinRoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3075
 
        {
3076
 
                /* Rin/Rout stream conversion memory was used */
3077
 
                ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, pChanEntry->usRinRoutConversionMemIndex );
3078
 
                if ( ulResult != cOCT6100_ERR_OK  )
3079
 
                        return ulResult;
3080
 
        }
3081
 
        
3082
 
        if ( pChanEntry->usSinSoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3083
 
        {
3084
 
                /* Sin/Sout stream conversion memory was used */
3085
 
                ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, pChanEntry->usSinSoutConversionMemIndex );
3086
 
                if ( ulResult != cOCT6100_ERR_OK  )
3087
 
                        return ulResult;
3088
 
        }
3089
 
 
3090
 
        /*------------------------------------------------------------------------------*/
3091
 
 
3092
 
 
3093
 
        /*------------------------------------------------------------------------------*/
3094
 
        /* Clear the silence copy events if they were created. */
3095
 
 
3096
 
        /* Unmute the Rin port if it was muted. */
3097
 
        if ( pChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
3098
 
        {
3099
 
                /* Remove the event from the list.*/
3100
 
                ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
3101
 
                                                                                                pChanEntry->usRinSilenceEventIndex,
3102
 
                                                                                                cOCT6100_EVENT_TYPE_SOUT_COPY );
3103
 
                if ( ulResult != cOCT6100_ERR_OK )
3104
 
                        return ulResult;
3105
 
 
3106
 
                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usRinSilenceEventIndex );
3107
 
                if ( ulResult != cOCT6100_ERR_OK  )
3108
 
                        return cOCT6100_ERR_FATAL_DF;
3109
 
 
3110
 
                pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
3111
 
        }
3112
 
 
3113
 
        /* Unmute the Sin port if it was muted. */
3114
 
        if ( pChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX )
3115
 
        {
3116
 
                /* Remove the event from the list.*/
3117
 
                ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
3118
 
                                                                                                pChanEntry->usSinSilenceEventIndex,
3119
 
                                                                                                cOCT6100_EVENT_TYPE_SOUT_COPY );
3120
 
                if ( ulResult != cOCT6100_ERR_OK )
3121
 
                        return ulResult;
3122
 
 
3123
 
                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usSinSilenceEventIndex );
3124
 
                if ( ulResult != cOCT6100_ERR_OK  )
3125
 
                        return cOCT6100_ERR_FATAL_E0;
3126
 
 
3127
 
                pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
3128
 
        }
3129
 
 
3130
 
        /*------------------------------------------------------------------------------*/
3131
 
 
3132
 
        /* Synch all the buffer playout field.*/
3133
 
        if ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE )
3134
 
        {       
3135
 
                Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
3136
 
 
3137
 
                BufferPlayoutStop.ulChannelHndl = cOCT6100_INVALID_HANDLE;
3138
 
                BufferPlayoutStop.fStopCleanly = FALSE;
3139
 
                
3140
 
                BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
3141
 
                ulResult = Oct6100ApiInvalidateChanPlayoutStructs( 
3142
 
                                                                                                        f_pApiInstance, 
3143
 
                                                                                                        &BufferPlayoutStop, 
3144
 
                                                                                                        f_usChanIndex, 
3145
 
                                                                                                        pChanEntry->usEchoMemIndex
3146
 
 
3147
 
                                                                                                        );
3148
 
                if ( ulResult != cOCT6100_ERR_OK )
3149
 
                        return ulResult;
3150
 
                
3151
 
                BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
3152
 
                ulResult = Oct6100ApiInvalidateChanPlayoutStructs( 
3153
 
                                                                                                        f_pApiInstance, 
3154
 
                                                                                                        &BufferPlayoutStop, 
3155
 
                                                                                                        f_usChanIndex, 
3156
 
                                                                                                        pChanEntry->usEchoMemIndex 
3157
 
 
3158
 
                                                                                                        );
3159
 
                if ( ulResult != cOCT6100_ERR_OK )
3160
 
                        return ulResult;
3161
 
        }
3162
 
 
3163
 
 
3164
 
 
3165
 
 
3166
 
 
3167
 
        /* Free all resources reserved for extended tone detection.*/
3168
 
        if ( pChanEntry->fEnableExtToneDetection == TRUE )
3169
 
        {
3170
 
                /*------------------------------------------------------------------------------*/
3171
 
                /* Deactivate the ECHO control memory entry of the extended channel.*/
3172
 
                
3173
 
                /* Set the input Echo control entry to unused.*/
3174
 
                WriteParams.ulWriteAddress  = cOCT6100_ECHO_CONTROL_MEM_BASE + ( pChanEntry->usExtToneChanIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
3175
 
                WriteParams.usWriteData = 0x85FF;       /* TSI index 1535 reserved for power-down mode */
3176
 
 
3177
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3178
 
                if ( ulResult != cOCT6100_ERR_OK  )
3179
 
                        return ulResult;
3180
 
 
3181
 
                WriteParams.ulWriteAddress += 2;
3182
 
                WriteParams.usWriteData = 0xC5FF;       /* TSI index 1535 reserved for power-down mode */
3183
 
 
3184
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3185
 
                if ( ulResult != cOCT6100_ERR_OK  )
3186
 
                        return ulResult;
3187
 
                /*------------------------------------------------------------------------------*/
3188
 
 
3189
 
                /*------------------------------------------------------------------------------*/
3190
 
                /* Remove the mixer event used to copy the RIN signal to the SIN port of the extended
3191
 
                   channel.*/
3192
 
 
3193
 
                /* Clear the Copy event.*/
3194
 
                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usExtToneMixerIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
3195
 
                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
3196
 
 
3197
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3198
 
                if ( ulResult != cOCT6100_ERR_OK  )
3199
 
                        return ulResult;
3200
 
 
3201
 
                /* Remove the event from the list.*/
3202
 
                ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
3203
 
                                                                                                pChanEntry->usExtToneMixerIndex,
3204
 
                                                                                                cOCT6100_EVENT_TYPE_SIN_COPY );
3205
 
                if ( ulResult != cOCT6100_ERR_OK )
3206
 
                        return ulResult;
3207
 
                
3208
 
                /*------------------------------------------------------------------------------*/
3209
 
 
3210
 
        }
3211
 
 
3212
 
        /*------------------------------------------------------------------------------*/
3213
 
        /* Reset PGSP */
3214
 
 
3215
 
        WriteParams.ulWriteAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
3216
 
        WriteParams.usWriteData = 0x0800;
3217
 
 
3218
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3219
 
        if ( ulResult != cOCT6100_ERR_OK )
3220
 
                return ulResult; 
3221
 
 
3222
 
        /*------------------------------------------------------------------------------*/
3223
 
 
3224
 
        /*------------------------------------------------------------------------------*/
3225
 
        /* Clear the mute with feature bit. */
3226
 
 
3227
 
        if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
3228
 
        {
3229
 
                ulResult = Oct6100ApiMuteSinWithFeatures( f_pApiInstance, f_usChanIndex, FALSE );
3230
 
                if ( ulResult != cOCT6100_ERR_OK )
3231
 
                        return ulResult;
3232
 
        }
3233
 
 
3234
 
        /*------------------------------------------------------------------------------*/
3235
 
 
3236
 
        /*------------------------------------------------------------------------------*/
3237
 
        /* Clear the VQE memory. */
3238
 
 
3239
 
        SmearParams.ulWriteAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst + 0x20;
3240
 
        SmearParams.usWriteData = 0x0000;
3241
 
        SmearParams.ulWriteLength = 2;
3242
 
 
3243
 
        mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
3244
 
        if ( ulResult != cOCT6100_ERR_OK  )
3245
 
                return ulResult;
3246
 
 
3247
 
        /*------------------------------------------------------------------------------*/
3248
 
 
3249
 
        /*------------------------------------------------------------------------------*/
3250
 
        /* Clear the AF information memory. */
3251
 
 
3252
 
        SmearParams.ulWriteAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( pChanEntry->usEchoMemIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
3253
 
        SmearParams.usWriteData = 0x0000;
3254
 
        SmearParams.ulWriteLength = 12;
3255
 
 
3256
 
        mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
3257
 
        if ( ulResult != cOCT6100_ERR_OK  )
3258
 
                return ulResult;
3259
 
        
3260
 
        /*Reset ALC status*/
3261
 
        WriteParams.ulWriteAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( pChanEntry->usEchoMemIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + 0x3A;
3262
 
        WriteParams.usWriteData = 0x0000;
3263
 
 
3264
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3265
 
        if ( ulResult != cOCT6100_ERR_OK )
3266
 
                return ulResult; 
3267
 
        
3268
 
        /*------------------------------------------------------------------------------*/
3269
 
 
3270
 
        return cOCT6100_ERR_OK;
3271
 
}
3272
 
#endif
3273
 
 
3274
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3275
 
 
3276
 
Function:               Oct6100ApiReleaseChannelResources
3277
 
 
3278
 
Description:    Release and clear the API entry associated to the echo cancellation channel.
3279
 
 
3280
 
-------------------------------------------------------------------------------
3281
 
|       Argument                |       Description
3282
 
-------------------------------------------------------------------------------
3283
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
3284
 
                                                present state of the chip and all its resources.
3285
 
 
3286
 
f_usChannelIndex                Index of the echo cancellation channel in the API list.
3287
 
 
3288
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3289
 
#if !SKIP_Oct6100ApiReleaseChannelResources
3290
 
UINT32 Oct6100ApiReleaseChannelResources( 
3291
 
                                IN  tPOCT6100_INSTANCE_API                              f_pApiInstance,
3292
 
                                IN      UINT16                                                          f_usChannelIndex )
3293
 
{
3294
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
3295
 
        tPOCT6100_API_CHANNEL           pChanEntry;
3296
 
        tPOCT6100_API_CHANNEL_TDM       pTdmConfig;
3297
 
        tPOCT6100_API_TSST_ENTRY        pTsstEntry;
3298
 
        UINT32  ulResult;
3299
 
        UINT16  usCurrentEntry;
3300
 
        UINT32  ulTimeslot;
3301
 
        UINT32  ulStream;
3302
 
 
3303
 
        /* Obtain local pointer to shared portion of instance. */
3304
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
3305
 
 
3306
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChannelIndex );
3307
 
 
3308
 
        /* Obtain local pointer to the TDM configurationof the channel */
3309
 
        pTdmConfig = &pChanEntry->TdmConfig;
3310
 
 
3311
 
        /* Release the two TSI chariot memory entries.*/
3312
 
        ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usRinRoutTsiMemIndex );
3313
 
        if ( ulResult != cOCT6100_ERR_OK  )
3314
 
                return cOCT6100_ERR_FATAL_2;
3315
 
 
3316
 
        ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usSinSoutTsiMemIndex );
3317
 
        if ( ulResult != cOCT6100_ERR_OK  )
3318
 
                return cOCT6100_ERR_FATAL_3;
3319
 
 
3320
 
        /* Now release the ECHO channel and control memory entries.*/
3321
 
        ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, f_usChannelIndex );
3322
 
        if ( ulResult != cOCT6100_ERR_OK  )
3323
 
                return cOCT6100_ERR_FATAL_4;
3324
 
 
3325
 
        /* Release the conversion resources.*/
3326
 
        if ( pChanEntry->usRinRoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3327
 
        {
3328
 
                ulResult = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, pChanEntry->usRinRoutConversionMemIndex );
3329
 
                if ( ulResult != cOCT6100_ERR_OK  )
3330
 
                        return cOCT6100_ERR_FATAL_B9;
3331
 
 
3332
 
                pChanEntry->usRinRoutConversionMemIndex = cOCT6100_INVALID_INDEX;
3333
 
        }
3334
 
 
3335
 
        if ( pChanEntry->usSinSoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3336
 
        {
3337
 
                ulResult = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, pChanEntry->usSinSoutConversionMemIndex );
3338
 
                if ( ulResult != cOCT6100_ERR_OK  )
3339
 
                        return cOCT6100_ERR_FATAL_BA;
3340
 
 
3341
 
                pChanEntry->usSinSoutConversionMemIndex = cOCT6100_INVALID_INDEX;
3342
 
        }
3343
 
 
3344
 
        /*=========================================================================*/
3345
 
        /* Release the TSST control memory entries if any were reserved.*/
3346
 
        if ( pTdmConfig->usRinTimeslot != cOCT6100_UNASSIGNED)
3347
 
        {
3348
 
                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
3349
 
                                                                                  pTdmConfig->usRinTimeslot,
3350
 
                                                                                  pTdmConfig->usRinStream,
3351
 
                                                                              pTdmConfig->byRinNumTssts, 
3352
 
                                                                                  cOCT6100_INPUT_TSST,
3353
 
                                                                                  cOCT6100_INVALID_INDEX );
3354
 
                if ( ulResult != cOCT6100_ERR_OK  )
3355
 
                        return cOCT6100_ERR_FATAL_5;
3356
 
        }
3357
 
 
3358
 
        if ( pTdmConfig->usSinTimeslot != cOCT6100_UNASSIGNED)
3359
 
        {
3360
 
                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
3361
 
                                                                                  pTdmConfig->usSinTimeslot,
3362
 
                                                                                  pTdmConfig->usSinStream,
3363
 
                                                                              pTdmConfig->bySinNumTssts, 
3364
 
                                                                                  cOCT6100_INPUT_TSST,
3365
 
                                                                                  cOCT6100_INVALID_INDEX );
3366
 
                if ( ulResult != cOCT6100_ERR_OK  )
3367
 
                        return cOCT6100_ERR_FATAL_6;
3368
 
        }
3369
 
 
3370
 
                /*=======================================================================*/
3371
 
        /* Release all the TSSTs associated to the ROUT port of this channel. */
3372
 
        if ( pTdmConfig->usRoutTimeslot != cOCT6100_UNASSIGNED)
3373
 
        {
3374
 
                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
3375
 
                                                                                  pTdmConfig->usRoutTimeslot,
3376
 
                                                                                  pTdmConfig->usRoutStream,
3377
 
                                                                              pTdmConfig->byRoutNumTssts, 
3378
 
                                                                                  cOCT6100_OUTPUT_TSST,
3379
 
                                                                                  cOCT6100_INVALID_INDEX );
3380
 
                if ( ulResult != cOCT6100_ERR_OK  )
3381
 
                        return cOCT6100_ERR_FATAL_7;
3382
 
        }
3383
 
 
3384
 
        /* Now release the Broadcast TSSTs. */
3385
 
        usCurrentEntry = pTdmConfig->usRoutBrdcastTsstFirstEntry;
3386
 
        while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3387
 
        {
3388
 
                mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3389
 
 
3390
 
                ulTimeslot = pTsstEntry->usTsstValue >> 5;
3391
 
                ulStream = pTsstEntry->usTsstValue & 0x1F;
3392
 
 
3393
 
                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
3394
 
                                                                                  ulTimeslot,
3395
 
                                                                                  ulStream,
3396
 
                                                                              cOCT6100_NUMBER_TSSTS_1, 
3397
 
                                                                                  cOCT6100_OUTPUT_TSST,
3398
 
                                                                                  usCurrentEntry );
3399
 
                if ( ulResult != cOCT6100_ERR_OK  )
3400
 
                        return cOCT6100_ERR_FATAL_8;
3401
 
 
3402
 
                /* Move to the next entry.*/
3403
 
                usCurrentEntry = pTsstEntry->usNextEntry;
3404
 
 
3405
 
                /* Invalidate the current entry.*/
3406
 
                pTsstEntry->usTsstMemoryIndex = 0xFFFF;
3407
 
                pTsstEntry->usTsstValue = 0xFFFF;
3408
 
                pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
3409
 
        }
3410
 
 
3411
 
                /*=======================================================================*/
3412
 
 
3413
 
        
3414
 
                /*=======================================================================*/
3415
 
        /* Release all the TSSTs associated to the SOUT port of this channel. */
3416
 
        if ( pTdmConfig->usSoutTimeslot != cOCT6100_UNASSIGNED)
3417
 
        {
3418
 
                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
3419
 
                                                                                  pTdmConfig->usSoutTimeslot,
3420
 
                                                                                  pTdmConfig->usSoutStream,
3421
 
                                                                              pTdmConfig->bySoutNumTssts, 
3422
 
                                                                                  cOCT6100_OUTPUT_TSST,
3423
 
                                                                                  cOCT6100_INVALID_INDEX );
3424
 
                if ( ulResult != cOCT6100_ERR_OK  )
3425
 
                        return cOCT6100_ERR_FATAL_9;
3426
 
        }
3427
 
 
3428
 
        /* Now release the Broadcast TSSTs. */
3429
 
        usCurrentEntry = pTdmConfig->usSoutBrdcastTsstFirstEntry;
3430
 
        while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3431
 
        {
3432
 
                mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3433
 
 
3434
 
                ulTimeslot = pTsstEntry->usTsstValue >> 5;
3435
 
                ulStream = pTsstEntry->usTsstValue & 0x1F;
3436
 
 
3437
 
                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
3438
 
                                                                                  ulTimeslot,
3439
 
                                                                                  ulStream,
3440
 
                                                                              cOCT6100_NUMBER_TSSTS_1,
3441
 
                                                                                  cOCT6100_OUTPUT_TSST,
3442
 
                                                                                  usCurrentEntry );
3443
 
                if ( ulResult != cOCT6100_ERR_OK  )
3444
 
                        return cOCT6100_ERR_FATAL_A;
3445
 
 
3446
 
                /* Move to the next entry.*/
3447
 
                usCurrentEntry = pTsstEntry->usNextEntry;
3448
 
 
3449
 
                /* Invalidate the current entry.*/
3450
 
                pTsstEntry->usTsstMemoryIndex = 0xFFFF;
3451
 
                pTsstEntry->usTsstValue = 0xFFFF;
3452
 
                pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
3453
 
        }
3454
 
        /*=======================================================================*/
3455
 
 
3456
 
        /*=======================================================================*/
3457
 
        /* Update the dependency of the phasing TSST if one is associated to the chanel.*/
3458
 
 
3459
 
        if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
3460
 
        {
3461
 
                tPOCT6100_API_PHASING_TSST      pPhasingEntry;
3462
 
 
3463
 
                mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, pChanEntry->usPhasingTsstIndex );
3464
 
 
3465
 
                pPhasingEntry->usDependencyCnt--;
3466
 
        }
3467
 
        /*=======================================================================*/
3468
 
 
3469
 
 
3470
 
        /*=======================================================================*/
3471
 
        /* Release any resources reserved for the extended tone detection.*/
3472
 
 
3473
 
        if ( pChanEntry->fEnableExtToneDetection == TRUE )
3474
 
        {
3475
 
                tPOCT6100_API_CHANNEL           pExtToneChanEntry;
3476
 
 
3477
 
                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pExtToneChanEntry, pChanEntry->usExtToneChanIndex );
3478
 
 
3479
 
                /* Release the ECHO channel and control memory entries.*/
3480
 
                ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, pChanEntry->usExtToneChanIndex );
3481
 
                if ( ulResult != cOCT6100_ERR_OK  )
3482
 
                        return cOCT6100_ERR_FATAL_C1;
3483
 
 
3484
 
                ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usExtToneTsiIndex );
3485
 
                if ( ulResult != cOCT6100_ERR_OK  )
3486
 
                        return cOCT6100_ERR_FATAL_C2;
3487
 
 
3488
 
                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usExtToneMixerIndex );
3489
 
                if ( ulResult != cOCT6100_ERR_OK  )
3490
 
                        return cOCT6100_ERR_FATAL_C3;
3491
 
 
3492
 
                /* Now release the channel entry */
3493
 
                pExtToneChanEntry->ulExtToneChanMode    = cOCT6100_API_EXT_TONE_DISABLED;
3494
 
                pExtToneChanEntry->fReserved                    = FALSE;
3495
 
 
3496
 
                /* Set the current entry to disable, just in case.*/
3497
 
                pChanEntry->ulExtToneChanMode                   = cOCT6100_API_EXT_TONE_DISABLED;
3498
 
        }
3499
 
        /*=======================================================================*/
3500
 
 
3501
 
 
3502
 
        /*=======================================================================*/
3503
 
        /* Update the channel's list entry. */
3504
 
 
3505
 
        /* Clear the NLP dword array. */
3506
 
        Oct6100UserMemSet( pChanEntry->aulNlpConfDword, 0, sizeof( pChanEntry->aulNlpConfDword ) );
3507
 
 
3508
 
        /* Clear the echo operation mode. */
3509
 
        pChanEntry->byEchoOperationMode = cOCT6100_ECHO_OP_MODE_POWER_DOWN;
3510
 
 
3511
 
        /* Mark the channel as closed. */
3512
 
        pChanEntry->fReserved = FALSE;
3513
 
        pChanEntry->byEntryOpenCnt++;
3514
 
 
3515
 
        /* Decrement the number of channel open.*/
3516
 
        f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels--;
3517
 
 
3518
 
        /*=======================================================================*/
3519
 
 
3520
 
        return cOCT6100_ERR_OK;
3521
 
 
3522
 
}
3523
 
#endif
3524
 
 
3525
 
 
3526
 
 
3527
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3528
 
 
3529
 
Function:               Oct6100ChannelModifySer
3530
 
 
3531
 
Description:    Modify an echo cancellation channel.
3532
 
 
3533
 
-------------------------------------------------------------------------------
3534
 
|       Argument                |       Description
3535
 
-------------------------------------------------------------------------------
3536
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
3537
 
                                                present state of the chip and all its resources.
3538
 
 
3539
 
f_pChannelModify                Pointer to channel configuration structure.  The handle
3540
 
                                                identifying the buffer in all future function calls is
3541
 
                                                returned in this structure.
3542
 
 
3543
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3544
 
#if !SKIP_Oct6100ChannelModifySer
3545
 
UINT32 Oct6100ChannelModifySer(
3546
 
                                IN              tPOCT6100_INSTANCE_API                                  f_pApiInstance,
3547
 
                                IN OUT  tPOCT6100_CHANNEL_MODIFY                                f_pChannelModify )
3548
 
{
3549
 
        UINT16  usChanIndex;
3550
 
        UINT32  ulResult;
3551
 
        UINT16  usNewRinTsstIndex;
3552
 
        UINT16  usNewSinTsstIndex;
3553
 
        UINT16  usNewRoutTsstIndex;
3554
 
        UINT16  usNewSoutTsstIndex;
3555
 
        UINT8   fSinSoutCodecActive = FALSE;
3556
 
        UINT8   fRinRoutCodecActive = FALSE;
3557
 
        UINT16  usNewPhasingTsstIndex;
3558
 
        tOCT6100_CHANNEL_OPEN   *pTempChanOpen;
3559
 
 
3560
 
        /* We don't want this 290 byte structure on the stack */
3561
 
        pTempChanOpen = kmalloc(sizeof(*pTempChanOpen), GFP_ATOMIC);
3562
 
        if (!pTempChanOpen)
3563
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
3564
 
 
3565
 
        /* Check the user's configuration of the echo cancellation channel for errors. */
3566
 
        ulResult = Oct6100ApiCheckChannelModify( f_pApiInstance, 
3567
 
                                                                                         f_pChannelModify, 
3568
 
                                                                                         pTempChanOpen, 
3569
 
                                                                                         &usNewPhasingTsstIndex,
3570
 
                                                                                         &usChanIndex );
3571
 
        if ( ulResult != cOCT6100_ERR_OK  )
3572
 
                goto out;
3573
 
 
3574
 
        /* Reserve all resources needed by the echo cancellation channel. */
3575
 
        ulResult = Oct6100ApiModifyChannelResources( f_pApiInstance, 
3576
 
                                                                                                 f_pChannelModify, 
3577
 
                                                                                                 usChanIndex, 
3578
 
                                                                                                 &usNewRinTsstIndex, 
3579
 
                                                                                                 &usNewSinTsstIndex, 
3580
 
                                                                                                 &usNewRoutTsstIndex, 
3581
 
                                                                                                 &usNewSoutTsstIndex );
3582
 
        if ( ulResult != cOCT6100_ERR_OK  )
3583
 
                goto out;
3584
 
 
3585
 
        /* Write all necessary structures to activate the echo cancellation channel. */
3586
 
        ulResult = Oct6100ApiModifyChannelStructs( f_pApiInstance, 
3587
 
                                                                                           f_pChannelModify, 
3588
 
                                                                                           pTempChanOpen, 
3589
 
                                                                                           usChanIndex, 
3590
 
                                                                                           usNewPhasingTsstIndex,
3591
 
                                                                                           &fSinSoutCodecActive,
3592
 
                                                                                           &fRinRoutCodecActive,
3593
 
                                                                                           usNewRinTsstIndex, 
3594
 
                                                                                           usNewSinTsstIndex, 
3595
 
                                                                                           usNewRoutTsstIndex, 
3596
 
                                                                                           usNewSoutTsstIndex );
3597
 
        if ( ulResult != cOCT6100_ERR_OK  )
3598
 
                goto out;
3599
 
 
3600
 
        /* Update the new echo cancellation channels's entry in the ECHO channel list. */
3601
 
        ulResult = Oct6100ApiModifyChannelEntry( f_pApiInstance, 
3602
 
                                                                                         f_pChannelModify, 
3603
 
                                                                                         pTempChanOpen, 
3604
 
                                                                                         usChanIndex,  
3605
 
                                                                                         usNewPhasingTsstIndex,
3606
 
                                                                                         fSinSoutCodecActive,
3607
 
                                                                                         fRinRoutCodecActive,
3608
 
                                                                                         usNewRinTsstIndex, 
3609
 
                                                                                         usNewSinTsstIndex, 
3610
 
                                                                                         usNewRoutTsstIndex, 
3611
 
                                                                                         usNewSoutTsstIndex  );
3612
 
out:
3613
 
        kfree(pTempChanOpen);
3614
 
 
3615
 
        return ulResult;
3616
 
}
3617
 
#endif
3618
 
 
3619
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3620
 
 
3621
 
Function:               Oct6100ApiCheckChannelModify
3622
 
 
3623
 
Description:    Checks the user's echo cancellation channel modify structure for errors.
3624
 
 
3625
 
-------------------------------------------------------------------------------
3626
 
|       Argument                |       Description
3627
 
-------------------------------------------------------------------------------
3628
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
3629
 
                                                present state of the chip and all its resources.
3630
 
 
3631
 
f_pChannelModify                Pointer to echo cancellation channel modify structure.
3632
 
f_pTempChanOpen                 Pointer to a channel open structure.
3633
 
f_pusNewPhasingTsstIndex        Pointer to a new phasing TSST index within the API instance.
3634
 
f_pusChanIndex                  Pointer to the channel index within the API instance channel list
3635
 
 
3636
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3637
 
#if !SKIP_Oct6100ApiCheckChannelModify
3638
 
UINT32 Oct6100ApiCheckChannelModify(
3639
 
                                IN              tPOCT6100_INSTANCE_API                                  f_pApiInstance,
3640
 
                                IN OUT  tPOCT6100_CHANNEL_MODIFY                                f_pChannelModify,
3641
 
                                IN              tPOCT6100_CHANNEL_OPEN                                  f_pTempChanOpen,
3642
 
                                OUT             PUINT16                                                                 f_pusNewPhasingTsstIndex,
3643
 
                                OUT             PUINT16                                                                 f_pusChanIndex )
3644
 
{
3645
 
        tPOCT6100_API_CHANNEL           pChanEntry;
3646
 
        UINT32  ulResult;
3647
 
        UINT32  ulEntryOpenCnt;
3648
 
        UINT32  ulDecoderNumTssts;
3649
 
 
3650
 
        /* Check the provided handle. */
3651
 
        if ( (f_pChannelModify->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
3652
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
3653
 
 
3654
 
        *f_pusChanIndex = (UINT16)( f_pChannelModify->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
3655
 
        if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
3656
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
3657
 
 
3658
 
        /*=======================================================================*/
3659
 
        /* Get a pointer to the channel's list entry. */
3660
 
 
3661
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
3662
 
 
3663
 
        /* Extract the entry open count from the provided handle. */
3664
 
        ulEntryOpenCnt = ( f_pChannelModify->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
3665
 
 
3666
 
        /* Check for errors. */
3667
 
        if ( pChanEntry->fReserved != TRUE )
3668
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
3669
 
        if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
3670
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
3671
 
 
3672
 
        /*=======================================================================*/
3673
 
 
3674
 
 
3675
 
        /*=======================================================================*/
3676
 
        /* Check the general modify parameters. */
3677
 
        
3678
 
        if ( f_pChannelModify->ulEchoOperationMode != cOCT6100_KEEP_PREVIOUS_SETTING &&
3679
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NORMAL &&
3680
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_FREEZE &&
3681
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET &&
3682
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN &&
3683
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL &&
3684
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION &&
3685
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
3686
 
                return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE;
3687
 
 
3688
 
        /* Check the 2100Hz echo disabling configuration.*/
3689
 
        if ( f_pChannelModify->fEnableToneDisabler != cOCT6100_KEEP_PREVIOUS_SETTING &&
3690
 
                 f_pChannelModify->fEnableToneDisabler != TRUE && 
3691
 
                 f_pChannelModify->fEnableToneDisabler != FALSE )
3692
 
                return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ENABLE;
3693
 
 
3694
 
        /* Check the disable tone detection flag. */
3695
 
        if ( f_pChannelModify->fDisableToneDetection != TRUE &&
3696
 
                f_pChannelModify->fDisableToneDetection != FALSE )
3697
 
                return cOCT6100_ERR_CHANNEL_DISABLE_TONE_DETECTION;
3698
 
 
3699
 
        /* Check the stop buffer playout flag. */
3700
 
        if ( f_pChannelModify->fStopBufferPlayout != TRUE &&
3701
 
                f_pChannelModify->fStopBufferPlayout != FALSE )
3702
 
                return cOCT6100_ERR_CHANNEL_STOP_BUFFER_PLAYOUT;
3703
 
 
3704
 
        /* Check the remove conference bridge participant flag. */
3705
 
        if ( f_pChannelModify->fRemoveConfBridgeParticipant != TRUE &&
3706
 
                f_pChannelModify->fRemoveConfBridgeParticipant != FALSE )
3707
 
                return cOCT6100_ERR_CHANNEL_REMOVE_CONF_BRIDGE_PARTICIPANT;
3708
 
 
3709
 
        /* Check the remove broadcast timeslots flag. */
3710
 
        if ( f_pChannelModify->fRemoveBroadcastTssts != TRUE &&
3711
 
                f_pChannelModify->fRemoveBroadcastTssts != FALSE )
3712
 
                return cOCT6100_ERR_CHANNEL_REMOVE_BROADCAST_TSSTS;
3713
 
 
3714
 
        if ( f_pChannelModify->fCodecConfigModified != TRUE && 
3715
 
                 f_pChannelModify->fCodecConfigModified != FALSE )
3716
 
                return cOCT6100_ERR_CHANNEL_MODIFY_CODEC_CONFIG;
3717
 
 
3718
 
        if ( f_pChannelModify->fVqeConfigModified != TRUE && 
3719
 
                 f_pChannelModify->fVqeConfigModified != FALSE )
3720
 
                return cOCT6100_ERR_CHANNEL_MODIFY_VQE_CONFIG;
3721
 
 
3722
 
        if ( f_pChannelModify->fTdmConfigModified != TRUE && 
3723
 
                 f_pChannelModify->fTdmConfigModified != FALSE )
3724
 
                return cOCT6100_ERR_CHANNEL_MODIFY_TDM_CONFIG;
3725
 
 
3726
 
        /*=======================================================================*/
3727
 
 
3728
 
        /*=======================================================================*/
3729
 
        /* Verify if any law change was requested. If so reprogram all structures.*/
3730
 
 
3731
 
        if (( f_pChannelModify->fTdmConfigModified == TRUE ) &&
3732
 
                ( f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
3733
 
                  f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
3734
 
                  f_pChannelModify->TdmConfig.ulRoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
3735
 
                  f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ))
3736
 
        {
3737
 
                f_pChannelModify->fVqeConfigModified = TRUE;
3738
 
                f_pChannelModify->fCodecConfigModified = TRUE;
3739
 
        }
3740
 
        /*=======================================================================*/
3741
 
        
3742
 
        ulResult = Oct6100ApiUpdateOpenStruct( f_pApiInstance, f_pChannelModify, f_pTempChanOpen, pChanEntry );
3743
 
        if ( ulResult != cOCT6100_ERR_OK )
3744
 
                return ulResult;
3745
 
 
3746
 
        /* All further check will now be performed using the TempOpenChan structure in order
3747
 
           to reuse the checks written for the open channel structure.*/
3748
 
        
3749
 
 
3750
 
 
3751
 
        /* Check the TDM config.*/
3752
 
        if ( f_pChannelModify->fTdmConfigModified == TRUE )
3753
 
        {
3754
 
                tPOCT6100_CHANNEL_MODIFY_TDM            pModifyTdm;
3755
 
                tPOCT6100_CHANNEL_OPEN_TDM                      pOpenTdm;
3756
 
 
3757
 
                pModifyTdm = &f_pChannelModify->TdmConfig;
3758
 
                pOpenTdm = &f_pTempChanOpen->TdmConfig;
3759
 
 
3760
 
                ulResult = Oct6100ApiCheckTdmConfig( f_pApiInstance,
3761
 
                                                                                         pOpenTdm );
3762
 
                if ( ulResult != cOCT6100_ERR_OK )
3763
 
                        return ulResult;
3764
 
 
3765
 
                /* Check if that Stream and Timeslot values are valid.*/
3766
 
                
3767
 
                /* Check the RIN port.*/
3768
 
                if ( f_pChannelModify->TdmConfig.ulRinStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3769
 
                        f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3770
 
                        return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
3771
 
 
3772
 
                if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3773
 
                        f_pChannelModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3774
 
                        return cOCT6100_ERR_CHANNEL_RIN_STREAM;
3775
 
                 
3776
 
                if ( pChanEntry->fBeingTapped == TRUE )
3777
 
                {
3778
 
                        /* Check that the Rin stream + timeslot are not being assigned. */
3779
 
                        if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING )
3780
 
                        {
3781
 
                                if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_UNASSIGNED )
3782
 
                                        return cOCT6100_ERR_CHANNEL_RIN_STREAM;
3783
 
 
3784
 
                                if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3785
 
                                        return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
3786
 
                        }
3787
 
                }
3788
 
 
3789
 
                /* Check the SIN port.*/
3790
 
                if ( f_pChannelModify->TdmConfig.ulSinStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3791
 
                        f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3792
 
                        return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT;
3793
 
 
3794
 
                if ( f_pChannelModify->TdmConfig.ulSinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3795
 
                        f_pChannelModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3796
 
                        return cOCT6100_ERR_CHANNEL_SIN_STREAM;
3797
 
 
3798
 
                /* Check the ROUT port.*/
3799
 
                if ( f_pChannelModify->TdmConfig.ulRoutStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3800
 
                        f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3801
 
                        return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT;
3802
 
 
3803
 
                if ( f_pChannelModify->TdmConfig.ulRoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3804
 
                        f_pChannelModify->TdmConfig.ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3805
 
                        return cOCT6100_ERR_CHANNEL_ROUT_STREAM;
3806
 
 
3807
 
                /* Check the SOUT port.*/
3808
 
                if ( f_pChannelModify->TdmConfig.ulSoutStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3809
 
                        f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3810
 
                        return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
3811
 
 
3812
 
                if ( f_pChannelModify->TdmConfig.ulSoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3813
 
                        f_pChannelModify->TdmConfig.ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3814
 
                        return cOCT6100_ERR_CHANNEL_SOUT_STREAM;
3815
 
 
3816
 
                /* Verify if the channel is currently part of a bidirectional channel, and if */
3817
 
                /* so perform the required checks. */
3818
 
                if ( pChanEntry->fBiDirChannel == TRUE )
3819
 
                {
3820
 
                        /* Check the ports that must remain unassigned.*/
3821
 
                        if ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3822
 
                                return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
3823
 
                        if ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED )
3824
 
                                return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
3825
 
                        
3826
 
                        /* Check that no PCM law change is requested.*/
3827
 
                        if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
3828
 
                                return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
3829
 
                        if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
3830
 
                                return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
3831
 
                }
3832
 
 
3833
 
                /* If this channel is on a conference bridge, a few more things must be checked. */
3834
 
                if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
3835
 
                {
3836
 
                        /* If conferencing, law conversion cannot be applied. */
3837
 
                        /* This check is done only if both input and output ports are assigned. */
3838
 
                        if ( ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3839
 
                                && ( f_pTempChanOpen->TdmConfig.ulRoutTimeslot != cOCT6100_UNASSIGNED ) )
3840
 
                        {
3841
 
                                /* Laws must be the same! */
3842
 
                                if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
3843
 
                                        return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
3844
 
                        }
3845
 
 
3846
 
                        /* Check for Sin. */
3847
 
                        if ( ( f_pTempChanOpen->TdmConfig.ulSinTimeslot != cOCT6100_UNASSIGNED )
3848
 
                                && ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED ) )
3849
 
                        {
3850
 
                                /* Laws must be the same! */
3851
 
                                if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
3852
 
                                        return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
3853
 
                        }
3854
 
 
3855
 
                        /* Check if ADPCM is requested. */
3856
 
                        if ( f_pTempChanOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING &&
3857
 
                                 f_pTempChanOpen->CodecConfig.ulEncodingRate != cOCT6100_G711_64KBPS )
3858
 
                        {
3859
 
                                /* No ADPCM in a conference bridge! */
3860
 
                                return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
3861
 
                        }
3862
 
 
3863
 
                        if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING &&
3864
 
                                 f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS )
3865
 
                        {
3866
 
                                /* No ADPCM in a conference bridge! */
3867
 
                                return cOCT6100_ERR_CHANNEL_DECODING_RATE;
3868
 
                        }
3869
 
                }
3870
 
 
3871
 
                if ( f_pTempChanOpen->CodecConfig.ulEncoderPort == cOCT6100_NO_ENCODING || 
3872
 
                        f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_NO_DECODING )
3873
 
                {
3874
 
                        /* Make sure no law conversion is attempted since it is not supported by the device.*/
3875
 
                        if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
3876
 
                                return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
3877
 
                        if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
3878
 
                                return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
3879
 
                }
3880
 
 
3881
 
                if ( pChanEntry->fEnableExtToneDetection == TRUE && 
3882
 
                         f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3883
 
                        return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT;
3884
 
 
3885
 
                /* A few special checks must be done if the configuration is to be applied */
3886
 
                /* to all opened channels. */
3887
 
                if ( f_pChannelModify->fApplyToAllChannels == TRUE )
3888
 
                {
3889
 
                        /* When the configuration to be applied is for all channels, */
3890
 
                        /* check that the stream and timeslot parameters are not being assigned. */
3891
 
 
3892
 
                        /* Check the Rout port. */
3893
 
                        if ( f_pChannelModify->TdmConfig.ulRoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3894
 
                                f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3895
 
                        {
3896
 
                                /* Check that the Rout ports is being unassigned. */
3897
 
                                if ( f_pTempChanOpen->TdmConfig.ulRoutStream != cOCT6100_UNASSIGNED )
3898
 
                                        return cOCT6100_ERR_CHANNEL_ROUT_STREAM_UNASSIGN;
3899
 
                                if ( f_pTempChanOpen->TdmConfig.ulRoutTimeslot != cOCT6100_UNASSIGNED )
3900
 
                                        return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT_UNASSIGN;
3901
 
                        }
3902
 
 
3903
 
                        /* Check the Rin port. */
3904
 
                        if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3905
 
                                f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3906
 
                        {
3907
 
                                /* Check that the Rin ports is being unassigned. */
3908
 
                                if ( f_pTempChanOpen->TdmConfig.ulRinStream != cOCT6100_UNASSIGNED )
3909
 
                                        return cOCT6100_ERR_CHANNEL_RIN_STREAM_UNASSIGN;
3910
 
                                if ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3911
 
                                        return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT_UNASSIGN;
3912
 
                        }
3913
 
 
3914
 
                        /* Check the Sout port. */
3915
 
                        if ( f_pChannelModify->TdmConfig.ulSoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3916
 
                                f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3917
 
                        {
3918
 
                                /* Check that the Sout ports is being unassigned. */
3919
 
                                if ( f_pTempChanOpen->TdmConfig.ulSoutStream != cOCT6100_UNASSIGNED )
3920
 
                                        return cOCT6100_ERR_CHANNEL_SOUT_STREAM_UNASSIGN;
3921
 
                                if ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED )
3922
 
                                        return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT_UNASSIGN;
3923
 
                        }
3924
 
 
3925
 
                        /* Check the Sin port. */
3926
 
                        if ( f_pChannelModify->TdmConfig.ulSinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3927
 
                                f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3928
 
                        {
3929
 
                                /* Check that the Sin ports is being unassigned. */
3930
 
                                if ( f_pTempChanOpen->TdmConfig.ulSinStream != cOCT6100_UNASSIGNED )
3931
 
                                        return cOCT6100_ERR_CHANNEL_SIN_STREAM_UNASSIGN;
3932
 
                                if ( f_pTempChanOpen->TdmConfig.ulSinTimeslot != cOCT6100_UNASSIGNED )
3933
 
                                        return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT_UNASSIGN;
3934
 
                        }
3935
 
                }
3936
 
        }
3937
 
 
3938
 
        /* Check the VQE config.*/
3939
 
        if ( f_pChannelModify->fVqeConfigModified == TRUE )
3940
 
        {
3941
 
                ulResult = Oct6100ApiCheckVqeConfig( f_pApiInstance,
3942
 
                                                                                         &f_pTempChanOpen->VqeConfig,
3943
 
                                                                                         f_pTempChanOpen->fEnableToneDisabler );
3944
 
                if ( ulResult != cOCT6100_ERR_OK )
3945
 
                        return ulResult;
3946
 
        }
3947
 
 
3948
 
        /* Verify if the echo operation mode selected can be applied. */
3949
 
        if ( ( f_pTempChanOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
3950
 
                && ( f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE ) )
3951
 
                return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
3952
 
        
3953
 
        if ( ( f_pTempChanOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
3954
 
                && ( f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE ) )
3955
 
                return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
3956
 
 
3957
 
        /* Comfort noise must be activated for speech recognition mode to work. */
3958
 
        if ( ( f_pTempChanOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
3959
 
                && ( f_pTempChanOpen->VqeConfig.ulComfortNoiseMode == cOCT6100_COMFORT_NOISE_OFF ) )
3960
 
                return cOCT6100_ERR_CHANNEL_COMFORT_NOISE_REQUIRED;
3961
 
 
3962
 
        /* Check the Codec config.*/
3963
 
        if ( f_pChannelModify->fCodecConfigModified == TRUE )
3964
 
        {
3965
 
                if ( f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3966
 
                        ulDecoderNumTssts = f_pTempChanOpen->TdmConfig.ulRinNumTssts;
3967
 
                else /* f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
3968
 
                        ulDecoderNumTssts  = f_pTempChanOpen->TdmConfig.ulSinNumTssts;
3969
 
 
3970
 
                ulResult = Oct6100ApiCheckCodecConfig( f_pApiInstance,
3971
 
                                                                                           &f_pTempChanOpen->CodecConfig,
3972
 
                                                                                           ulDecoderNumTssts,
3973
 
                                                                                           f_pusNewPhasingTsstIndex );
3974
 
                if ( ulResult != cOCT6100_ERR_OK )
3975
 
                        return ulResult;
3976
 
 
3977
 
 
3978
 
 
3979
 
                /* make sure that if silence suppression is activated, the NLP is enabled.*/
3980
 
                if ( f_pTempChanOpen->CodecConfig.fEnableSilenceSuppression == TRUE && f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE )
3981
 
                        return cOCT6100_ERR_CHANNEL_SIL_SUP_NLP_MUST_BE_ENABLED;
3982
 
 
3983
 
                /* Verify if the channel is currently part of a bidirectional channel, and if so perform
3984
 
                    the required checks.*/
3985
 
                if ( pChanEntry->fBiDirChannel == TRUE )
3986
 
                {
3987
 
                        /* Check the ports that must remain unassigned.*/
3988
 
                        if ( f_pTempChanOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING && 
3989
 
                                 f_pTempChanOpen->CodecConfig.ulEncodingRate != cOCT6100_G711_64KBPS )
3990
 
                                return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
3991
 
 
3992
 
                        if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING && 
3993
 
                                 f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS )
3994
 
                                return cOCT6100_ERR_CHANNEL_DECODING_RATE;
3995
 
                }
3996
 
 
3997
 
        }
3998
 
        /*=======================================================================*/
3999
 
 
4000
 
        return cOCT6100_ERR_OK;
4001
 
}
4002
 
#endif
4003
 
 
4004
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4005
 
 
4006
 
Function:               Oct6100ApiModifyChannelResources
4007
 
 
4008
 
Description:    Reserves any new resources needed for the channel
4009
 
-------------------------------------------------------------------------------
4010
 
|       Argument                |       Description
4011
 
-------------------------------------------------------------------------------
4012
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
4013
 
                                                present state of the chip and all its resources.
4014
 
        
4015
 
f_pChannelModify                Pointer to echo cancellation channel configuration structure.
4016
 
f_usChanIndex                   Allocated entry in ECHO channel list.
4017
 
 
4018
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4019
 
#if !SKIP_Oct6100ApiModifyChannelResources
4020
 
UINT32 Oct6100ApiModifyChannelResources(        
4021
 
                                IN  tPOCT6100_INSTANCE_API                              f_pApiInstance,
4022
 
                                IN  tPOCT6100_CHANNEL_MODIFY                    f_pChannelModify,
4023
 
                                IN      UINT16                                                          f_usChanIndex,
4024
 
                                OUT     PUINT16                                                         f_pusNewRinTsstIndex,
4025
 
                                OUT     PUINT16                                                         f_pusNewSinTsstIndex,
4026
 
                                OUT     PUINT16                                                         f_pusNewRoutTsstIndex,
4027
 
                                OUT     PUINT16                                                         f_pusNewSoutTsstIndex )
4028
 
{
4029
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
4030
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
4031
 
 
4032
 
        tPOCT6100_API_CHANNEL_TDM               pApiTdmConf;
4033
 
        tPOCT6100_CHANNEL_MODIFY_TDM    pModifyTdmConf;
4034
 
 
4035
 
        UINT32  ulResult = cOCT6100_ERR_OK;
4036
 
        UINT32  ulTempVar = cOCT6100_ERR_OK;
4037
 
        UINT32  ulFreeMixerEventCnt;
4038
 
        
4039
 
        BOOL    fRinReleased = FALSE;
4040
 
        BOOL    fSinReleased = FALSE;
4041
 
        BOOL    fRoutReleased = FALSE;
4042
 
        BOOL    fSoutReleased = FALSE;
4043
 
 
4044
 
        BOOL    fRinReserved = FALSE;
4045
 
        BOOL    fSinReserved = FALSE;
4046
 
        BOOL    fRoutReserved = FALSE;
4047
 
        BOOL    fSoutReserved = FALSE;
4048
 
 
4049
 
        BOOL    fReserveRin = FALSE;
4050
 
        BOOL    fReserveSin = FALSE;
4051
 
        BOOL    fReserveRout = FALSE;
4052
 
        BOOL    fReserveSout = FALSE;
4053
 
 
4054
 
        BOOL    fRinRoutConversionMemReserved = FALSE;
4055
 
        BOOL    fSinSoutConversionMemReserved = FALSE;
4056
 
 
4057
 
 
4058
 
        UINT32  ulRinNumTssts = 1;
4059
 
        UINT32  ulSinNumTssts = 1;
4060
 
        UINT32  ulRoutNumTssts = 1;
4061
 
        UINT32  ulSoutNumTssts = 1;
4062
 
 
4063
 
        /* Obtain local pointer to shared portion of instance. */
4064
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
4065
 
 
4066
 
        /* Obtain local pointer to the TDM configuration structure of the tPOCT6100_CHANNEL_MODIFY structure. */
4067
 
        pModifyTdmConf   = &f_pChannelModify->TdmConfig;
4068
 
 
4069
 
        /*=======================================================================*/
4070
 
        /* Get a pointer to the channel's list entry. */
4071
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
4072
 
 
4073
 
        /* Obtain local pointer to the TDM configuration structure of the tPOCT6100_API_CHANNEL structure. */
4074
 
        pApiTdmConf   = &pChanEntry->TdmConfig;
4075
 
 
4076
 
        /*===============================================================================*/
4077
 
        /* Modify TSST resources if required.*/
4078
 
        if ( f_pChannelModify->fTdmConfigModified == TRUE )
4079
 
        {
4080
 
                /* First release any entry that need to be released.*/
4081
 
                if ( ( pModifyTdmConf->ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4082
 
                        || ( pModifyTdmConf->ulRinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) 
4083
 
                        )
4084
 
                {
4085
 
                        if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4086
 
                        {
4087
 
                                /* Release the previously reserved entry.*/
4088
 
                                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
4089
 
                                                                                                  pChanEntry->TdmConfig.usRinTimeslot,
4090
 
                                                                                                  pChanEntry->TdmConfig.usRinStream, 
4091
 
                                                                                                  pChanEntry->TdmConfig.byRinNumTssts, 
4092
 
                                                                                                  cOCT6100_INPUT_TSST,
4093
 
                                                                                                  cOCT6100_INVALID_INDEX );
4094
 
                                if ( ulResult == cOCT6100_ERR_OK  )
4095
 
                                {
4096
 
                                        fRinReleased = TRUE;
4097
 
                                }
4098
 
                        }
4099
 
 
4100
 
                        fReserveRin = TRUE;
4101
 
                }
4102
 
 
4103
 
                /* Release SIN port.*/
4104
 
                if ( ( ulResult == cOCT6100_ERR_OK ) 
4105
 
                        && ( ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4106
 
                                || ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4107
 
                                ) )
4108
 
                {
4109
 
                        if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4110
 
                        {
4111
 
                                /* Release the previously reserved entry.*/
4112
 
                                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
4113
 
                                                                                                  pChanEntry->TdmConfig.usSinTimeslot,
4114
 
                                                                                                  pChanEntry->TdmConfig.usSinStream, 
4115
 
                                                                                                  pChanEntry->TdmConfig.bySinNumTssts, 
4116
 
                                                                                                  cOCT6100_INPUT_TSST,
4117
 
                                                                                                  cOCT6100_INVALID_INDEX );
4118
 
                                if ( ulResult == cOCT6100_ERR_OK  )
4119
 
                                {
4120
 
                                        fSinReleased = TRUE;
4121
 
                                }
4122
 
                        }
4123
 
 
4124
 
                        fReserveSin = TRUE;
4125
 
                }
4126
 
 
4127
 
                /* Release ROUT port.*/
4128
 
                if ( ( ulResult == cOCT6100_ERR_OK ) 
4129
 
                        && ( ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4130
 
                                || ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) 
4131
 
                                ) )
4132
 
                {
4133
 
                        if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
4134
 
                        {
4135
 
                                /* Release the previously reserved entry.*/
4136
 
                                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
4137
 
                                                                                                  pChanEntry->TdmConfig.usRoutTimeslot,
4138
 
                                                                                                  pChanEntry->TdmConfig.usRoutStream, 
4139
 
                                                                                                  pChanEntry->TdmConfig.byRoutNumTssts, 
4140
 
                                                                                                  cOCT6100_OUTPUT_TSST,
4141
 
                                                                                                  cOCT6100_INVALID_INDEX );
4142
 
                                if ( ulResult == cOCT6100_ERR_OK  )
4143
 
                                {
4144
 
                                        fRoutReleased = TRUE;
4145
 
                                }
4146
 
                        }
4147
 
 
4148
 
                        fReserveRout = TRUE;
4149
 
                }
4150
 
 
4151
 
                /* Release the SOUT port.*/
4152
 
                if ( ( ulResult == cOCT6100_ERR_OK ) 
4153
 
                        && ( ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4154
 
                                || ( pModifyTdmConf->ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) 
4155
 
                                ) )
4156
 
                {
4157
 
                        if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
4158
 
                        {
4159
 
                                /* Release the previously reserved entry.*/
4160
 
                                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
4161
 
                                                                                                  pChanEntry->TdmConfig.usSoutTimeslot,
4162
 
                                                                                                  pChanEntry->TdmConfig.usSoutStream, 
4163
 
                                                                                                  pChanEntry->TdmConfig.bySoutNumTssts, 
4164
 
                                                                                                  cOCT6100_OUTPUT_TSST,
4165
 
                                                                                                  cOCT6100_INVALID_INDEX );
4166
 
                                if ( ulResult == cOCT6100_ERR_OK  )
4167
 
                                {
4168
 
                                        fSoutReleased = TRUE;
4169
 
                                }
4170
 
                        }
4171
 
 
4172
 
                        fReserveSout = TRUE;
4173
 
                }
4174
 
 
4175
 
                /* Now reserve any new entry required.*/
4176
 
                
4177
 
                /* Modify RIN port.*/
4178
 
                if ( ( fReserveRin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4179
 
                {
4180
 
                        if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_UNASSIGNED )
4181
 
                        {
4182
 
                                /* Check what number of TSSTs should be reserved this time. */
4183
 
                                if ( pModifyTdmConf->ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4184
 
                                {
4185
 
                                        ulRinNumTssts = pApiTdmConf->byRinNumTssts;
4186
 
                                }
4187
 
                                else /* if ( pModifyTdmConf->ulRinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4188
 
                                {
4189
 
                                        /* New number of TSSTs. */
4190
 
                                        ulRinNumTssts = pModifyTdmConf->ulRinNumTssts;
4191
 
                                }
4192
 
 
4193
 
                                if ( pModifyTdmConf->ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4194
 
                                {
4195
 
                                        /* Reserve the new number of TSSTs. */
4196
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
4197
 
                                                                                                  pApiTdmConf->usRinTimeslot, 
4198
 
                                                                                                  pApiTdmConf->usRinStream, 
4199
 
                                                                                                  ulRinNumTssts, 
4200
 
                                                                                                  cOCT6100_INPUT_TSST,
4201
 
                                                                                                  f_pusNewRinTsstIndex, 
4202
 
                                                                                                  NULL );
4203
 
                                }
4204
 
                                else /* if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4205
 
                                {
4206
 
                                        /* Reserve the new TSST.*/
4207
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
4208
 
                                                                                                  pModifyTdmConf->ulRinTimeslot, 
4209
 
                                                                                                  pModifyTdmConf->ulRinStream, 
4210
 
                                                                                                  ulRinNumTssts, 
4211
 
                                                                                                  cOCT6100_INPUT_TSST,
4212
 
                                                                                                  f_pusNewRinTsstIndex, 
4213
 
                                                                                                  NULL );
4214
 
                                        if ( ulResult == cOCT6100_ERR_OK  )
4215
 
                                        {
4216
 
                                                fRinReserved = TRUE;
4217
 
                                        }
4218
 
                                }
4219
 
                        }
4220
 
                        else
4221
 
                        {
4222
 
                                *f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX;
4223
 
                        }
4224
 
                }
4225
 
                else
4226
 
                {
4227
 
                        *f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX;
4228
 
                }
4229
 
 
4230
 
                /* Modify SIN port.*/
4231
 
                if ( ( fReserveSin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4232
 
                {
4233
 
                        if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_UNASSIGNED )
4234
 
                        {
4235
 
                                /* Check what number of TSSTs should be reserved this time. */
4236
 
                                if ( pModifyTdmConf->ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4237
 
                                {
4238
 
                                        ulSinNumTssts = pApiTdmConf->bySinNumTssts;
4239
 
                                }
4240
 
                                else /* if ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4241
 
                                {
4242
 
                                        /* New number of TSSTs. */
4243
 
                                        ulSinNumTssts = pModifyTdmConf->ulSinNumTssts;
4244
 
                                }
4245
 
 
4246
 
                                if ( pModifyTdmConf->ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4247
 
                                {
4248
 
                                        /* Reserve the new number of TSSTs. */
4249
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
4250
 
                                                                                                  pApiTdmConf->usSinTimeslot, 
4251
 
                                                                                                  pApiTdmConf->usSinStream, 
4252
 
                                                                                                  ulSinNumTssts, 
4253
 
                                                                                                  cOCT6100_INPUT_TSST,
4254
 
                                                                                                  f_pusNewSinTsstIndex, 
4255
 
                                                                                                  NULL );
4256
 
                                }
4257
 
                                else /* if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4258
 
                                {
4259
 
                                        /* Reserve the new TSST.*/
4260
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
4261
 
                                                                                                  pModifyTdmConf->ulSinTimeslot, 
4262
 
                                                                                                  pModifyTdmConf->ulSinStream, 
4263
 
                                                                                                  ulSinNumTssts, 
4264
 
                                                                                                  cOCT6100_INPUT_TSST,
4265
 
                                                                                                  f_pusNewSinTsstIndex, 
4266
 
                                                                                                  NULL );
4267
 
                                        if ( ulResult == cOCT6100_ERR_OK )
4268
 
                                        {
4269
 
                                                fSinReserved = TRUE;
4270
 
                                        }
4271
 
                                }
4272
 
                        }
4273
 
                        else
4274
 
                        {
4275
 
                                *f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX;
4276
 
                        }
4277
 
                }
4278
 
                else
4279
 
                {
4280
 
                        *f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX;
4281
 
                }
4282
 
 
4283
 
                /* Modify ROUT port.*/
4284
 
                if ( ( fReserveRout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4285
 
                {
4286
 
                        if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_UNASSIGNED )
4287
 
                        {
4288
 
                                /* Check what number of TSSTs should be reserved this time. */
4289
 
                                if ( pModifyTdmConf->ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4290
 
                                {
4291
 
                                        ulRoutNumTssts = pApiTdmConf->byRoutNumTssts;
4292
 
                                }
4293
 
                                else /* if ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4294
 
                                {
4295
 
                                        /* New number of TSSTs. */
4296
 
                                        ulRoutNumTssts = pModifyTdmConf->ulRoutNumTssts;
4297
 
                                }
4298
 
 
4299
 
                                if ( pModifyTdmConf->ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4300
 
                                {
4301
 
                                        /* Reserve the new number of TSSTs. */
4302
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
4303
 
                                                                                                  pApiTdmConf->usRoutTimeslot, 
4304
 
                                                                                                  pApiTdmConf->usRoutStream, 
4305
 
                                                                                                  ulRoutNumTssts, 
4306
 
                                                                                                  cOCT6100_OUTPUT_TSST,
4307
 
                                                                                                  f_pusNewRoutTsstIndex, 
4308
 
                                                                                                  NULL );
4309
 
                                }
4310
 
                                else /* if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4311
 
                                {
4312
 
                                        /* Reserve the new TSST.*/
4313
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
4314
 
                                                                                                  pModifyTdmConf->ulRoutTimeslot, 
4315
 
                                                                                                  pModifyTdmConf->ulRoutStream, 
4316
 
                                                                                                  ulRoutNumTssts, 
4317
 
                                                                                                  cOCT6100_OUTPUT_TSST,
4318
 
                                                                                                  f_pusNewRoutTsstIndex, 
4319
 
                                                                                                  NULL );
4320
 
                                        if ( ulResult == cOCT6100_ERR_OK  )
4321
 
                                        {
4322
 
                                                fRoutReserved = TRUE;
4323
 
                                        }
4324
 
                                }
4325
 
                        }
4326
 
                        else
4327
 
                        {
4328
 
                                *f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX;
4329
 
                        }
4330
 
                }
4331
 
                else
4332
 
                {
4333
 
                        *f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX;
4334
 
                }
4335
 
 
4336
 
                /* Modify SOUT port.*/
4337
 
                if ( ( fReserveSout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4338
 
                {
4339
 
                        if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_UNASSIGNED )
4340
 
                        {
4341
 
                                /* Check what number of TSSTs should be reserved this time. */
4342
 
                                if ( pModifyTdmConf->ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4343
 
                                {
4344
 
                                        ulSoutNumTssts = pApiTdmConf->bySoutNumTssts;
4345
 
                                }
4346
 
                                else /* if ( pModifyTdmConf->ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4347
 
                                {
4348
 
                                        /* New number of TSSTs. */
4349
 
                                        ulSoutNumTssts = pModifyTdmConf->ulSoutNumTssts;
4350
 
                                }
4351
 
 
4352
 
                                if ( pModifyTdmConf->ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4353
 
                                {
4354
 
                                        /* Reserve the new number of TSSTs. */
4355
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
4356
 
                                                                                                  pApiTdmConf->usSoutTimeslot, 
4357
 
                                                                                                  pApiTdmConf->usSoutStream, 
4358
 
                                                                                                  ulSoutNumTssts, 
4359
 
                                                                                                  cOCT6100_OUTPUT_TSST,
4360
 
                                                                                                  f_pusNewSoutTsstIndex, 
4361
 
                                                                                                  NULL );
4362
 
                                }
4363
 
                                else /* if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4364
 
                                {
4365
 
                                        /* Reserve the new TSST.*/
4366
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
4367
 
                                                                                                  pModifyTdmConf->ulSoutTimeslot, 
4368
 
                                                                                                  pModifyTdmConf->ulSoutStream, 
4369
 
                                                                                                  ulSoutNumTssts, 
4370
 
                                                                                                  cOCT6100_OUTPUT_TSST,
4371
 
                                                                                                  f_pusNewSoutTsstIndex, 
4372
 
                                                                                                  NULL );
4373
 
                                        if ( ulResult == cOCT6100_ERR_OK  )
4374
 
                                        {
4375
 
                                                fSoutReserved = TRUE;
4376
 
                                        }
4377
 
                                }
4378
 
                        }
4379
 
                        else
4380
 
                        {
4381
 
                                *f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX;
4382
 
                        }
4383
 
                }
4384
 
                else
4385
 
                {
4386
 
                        *f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX;
4387
 
                }
4388
 
 
4389
 
 
4390
 
        }
4391
 
 
4392
 
        if ( f_pChannelModify->fCodecConfigModified == TRUE )
4393
 
        {
4394
 
                if (   ulResult == cOCT6100_ERR_OK &&
4395
 
                           pChanEntry->usRinRoutConversionMemIndex == cOCT6100_INVALID_INDEX &&
4396
 
                         ( f_pChannelModify->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ||
4397
 
                           f_pChannelModify->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) )
4398
 
                {
4399
 
                        /* Reserve an ADPCM memory block.*/
4400
 
                        ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usRinRoutConversionMemIndex );
4401
 
                        if ( ulResult == cOCT6100_ERR_OK  )
4402
 
                        {
4403
 
                                fRinRoutConversionMemReserved = TRUE;
4404
 
                        }
4405
 
                }
4406
 
 
4407
 
                if (   ulResult == cOCT6100_ERR_OK && 
4408
 
                           pChanEntry->usSinSoutConversionMemIndex == cOCT6100_INVALID_INDEX &&
4409
 
                         ( f_pChannelModify->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT ||
4410
 
                           f_pChannelModify->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN ) )
4411
 
                {
4412
 
                        /* Reserve an ADPCM memory block.*/
4413
 
                        ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usSinSoutConversionMemIndex );
4414
 
                        if ( ulResult == cOCT6100_ERR_OK  )
4415
 
                        {
4416
 
                                fSinSoutConversionMemReserved = TRUE;
4417
 
                        }
4418
 
                }
4419
 
        }
4420
 
 
4421
 
 
4422
 
        /*===============================================================================*/
4423
 
        /* Check if there are a couple of mixer events available for us. */
4424
 
 
4425
 
        if ( ulResult == cOCT6100_ERR_OK )
4426
 
        {
4427
 
                UINT32 ulMixerEventCntNeeded = 0;
4428
 
 
4429
 
                /* Calculate how many mixer events are needed. */
4430
 
                if ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX )
4431
 
                {
4432
 
                        /* If the channel is in bidir mode, do not create the Rin silence event!!! */
4433
 
                        if ( pChanEntry->fBiDirChannel == FALSE )
4434
 
                        {
4435
 
                                if ( ( *f_pusNewRinTsstIndex == cOCT6100_INVALID_INDEX )
4436
 
                                        && ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
4437
 
                                        ulMixerEventCntNeeded++;
4438
 
                        }
4439
 
                }
4440
 
 
4441
 
                if ( ( *f_pusNewSinTsstIndex == cOCT6100_INVALID_INDEX )
4442
 
                        && ( pChanEntry->usSinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
4443
 
                {
4444
 
                        ulMixerEventCntNeeded++;
4445
 
                }
4446
 
 
4447
 
                /* If at least 1 mixer event is needed, check if those are available. */
4448
 
                if ( ulMixerEventCntNeeded != 0 )
4449
 
                {
4450
 
                        ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt );
4451
 
                        if ( ulResult == cOCT6100_ERR_OK )
4452
 
                        {
4453
 
                                /* The API might need more mixer events if the ports have to be muted. */
4454
 
                                /* Check if these are available. */
4455
 
                                if ( ulFreeMixerEventCnt < ulMixerEventCntNeeded )
4456
 
                                {
4457
 
                                        ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS;
4458
 
                                }
4459
 
                        }
4460
 
                }
4461
 
        }
4462
 
 
4463
 
        /*===============================================================================*/
4464
 
 
4465
 
        /* Verify if an error occured. */
4466
 
        if ( ulResult != cOCT6100_ERR_OK )
4467
 
        {
4468
 
                /* Release any resources newly reserved.*/
4469
 
                if ( fRinReserved == TRUE )
4470
 
                {
4471
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, 
4472
 
                                                                                          pModifyTdmConf->ulRinTimeslot,
4473
 
                                                                                          pModifyTdmConf->ulRinStream, 
4474
 
                                                                                          ulRinNumTssts, 
4475
 
                                                                                          cOCT6100_INPUT_TSST,
4476
 
                                                                                          cOCT6100_INVALID_INDEX );
4477
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
4478
 
                                return ulTempVar;
4479
 
                }
4480
 
 
4481
 
                /* For the SIN port.*/
4482
 
                if ( fSinReserved == TRUE )
4483
 
                {
4484
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, 
4485
 
                                                                                          pModifyTdmConf->ulSinTimeslot,
4486
 
                                                                                          pModifyTdmConf->ulSinStream, 
4487
 
                                                                                          ulSinNumTssts, 
4488
 
                                                                                          cOCT6100_INPUT_TSST,
4489
 
                                                                                          cOCT6100_INVALID_INDEX );
4490
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
4491
 
                                return ulTempVar;
4492
 
                }
4493
 
 
4494
 
                /* For the ROUT port.*/
4495
 
                if ( fRoutReserved == TRUE )
4496
 
                {
4497
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, 
4498
 
                                                                                          pModifyTdmConf->ulRoutTimeslot,
4499
 
                                                                                          pModifyTdmConf->ulRoutStream, 
4500
 
                                                                                          ulRoutNumTssts, 
4501
 
                                                                                          cOCT6100_OUTPUT_TSST,
4502
 
                                                                                          cOCT6100_INVALID_INDEX );
4503
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
4504
 
                                return ulTempVar;
4505
 
                }
4506
 
 
4507
 
                /* For the SOUT port.*/
4508
 
                if ( fSoutReserved == TRUE )
4509
 
                {
4510
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, 
4511
 
                                                                                          pModifyTdmConf->ulSoutTimeslot,
4512
 
                                                                                          pModifyTdmConf->ulSoutStream, 
4513
 
                                                                                          ulSoutNumTssts, 
4514
 
                                                                                          cOCT6100_OUTPUT_TSST,
4515
 
                                                                                          cOCT6100_INVALID_INDEX );
4516
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
4517
 
                                return ulTempVar;
4518
 
                }
4519
 
 
4520
 
                /* Now make sure any resources released gets reserved back again.*/
4521
 
 
4522
 
                /* For the RIN port.*/
4523
 
                if ( fRinReleased == TRUE )
4524
 
                {
4525
 
                        /* Reserve the new TSST.*/
4526
 
                        ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, 
4527
 
                                                                                          pChanEntry->TdmConfig.usRinTimeslot, 
4528
 
                                                                                          pChanEntry->TdmConfig.usRinStream, 
4529
 
                                                                                          pChanEntry->TdmConfig.byRinNumTssts, 
4530
 
                                                                                          cOCT6100_INPUT_TSST,
4531
 
                                                                                          &pChanEntry->usRinTsstIndex, 
4532
 
                                                                                          NULL );
4533
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
4534
 
                                return ulTempVar;
4535
 
                }
4536
 
 
4537
 
                /* For the SIN port.*/
4538
 
                if ( fSinReleased == TRUE )
4539
 
                {
4540
 
                        /* Reserve the new TSST.*/
4541
 
                        ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, 
4542
 
                                                                                          pChanEntry->TdmConfig.usSinTimeslot, 
4543
 
                                                                                          pChanEntry->TdmConfig.usSinStream, 
4544
 
                                                                                          pChanEntry->TdmConfig.bySinNumTssts, 
4545
 
                                                                                          cOCT6100_INPUT_TSST,
4546
 
                                                                                          &pChanEntry->usSinTsstIndex, 
4547
 
                                                                                          NULL );
4548
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
4549
 
                                return ulTempVar;
4550
 
                }
4551
 
 
4552
 
                /* For the ROUT port.*/
4553
 
                if ( fRoutReleased == TRUE )
4554
 
                {
4555
 
                        /* Reserve the new TSST.*/
4556
 
                        ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, 
4557
 
                                                                                          pChanEntry->TdmConfig.usRoutTimeslot, 
4558
 
                                                                                          pChanEntry->TdmConfig.usRoutStream, 
4559
 
                                                                                          pChanEntry->TdmConfig.byRoutNumTssts, 
4560
 
                                                                                          cOCT6100_OUTPUT_TSST,
4561
 
                                                                                          &pChanEntry->usRoutTsstIndex, 
4562
 
                                                                                          NULL );
4563
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
4564
 
                                return ulTempVar;
4565
 
                }
4566
 
 
4567
 
                /* For the SOUT port.*/
4568
 
                if ( fSoutReleased == TRUE )
4569
 
                {
4570
 
                        /* Reserve the new TSST.*/
4571
 
                        ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, 
4572
 
                                                                                          pChanEntry->TdmConfig.usSoutTimeslot, 
4573
 
                                                                                          pChanEntry->TdmConfig.usSoutStream, 
4574
 
                                                                                          pChanEntry->TdmConfig.bySoutNumTssts, 
4575
 
                                                                                          cOCT6100_OUTPUT_TSST,
4576
 
                                                                                          &pChanEntry->usSoutTsstIndex, 
4577
 
                                                                                          NULL );
4578
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
4579
 
                                return ulTempVar;
4580
 
                }
4581
 
 
4582
 
                /* Release the conversion memories if they were reserved.*/
4583
 
                if ( fRinRoutConversionMemReserved == TRUE )
4584
 
                {
4585
 
                        ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, 
4586
 
                                                                                                            pChanEntry->usRinRoutConversionMemIndex );
4587
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
4588
 
                                return ulTempVar;
4589
 
                }
4590
 
 
4591
 
                if ( fSinSoutConversionMemReserved == TRUE )
4592
 
                {
4593
 
                        ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, 
4594
 
                                                                                                            pChanEntry->usSinSoutConversionMemIndex );
4595
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
4596
 
                                return ulTempVar;
4597
 
                }
4598
 
                
4599
 
                /* Now return the error.*/
4600
 
                return ulResult;
4601
 
        }
4602
 
 
4603
 
        return cOCT6100_ERR_OK;
4604
 
}
4605
 
#endif
4606
 
 
4607
 
 
4608
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4609
 
 
4610
 
Function:               Oct6100ApiModifyChannelStructs
4611
 
 
4612
 
Description:    Performs all the required structure writes to configure the
4613
 
                                echo cancellation channel based on the new modifications.
4614
 
 
4615
 
-------------------------------------------------------------------------------
4616
 
|       Argument                |       Description
4617
 
-------------------------------------------------------------------------------
4618
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
4619
 
                                                        present state of the chip and all its resources.
4620
 
                                        
4621
 
f_pChannelModify                        Pointer to echo cancellation channel configuration structure.
4622
 
f_pChannelOpen                          Pointer to a structure used to store the multiple resources indexes.
4623
 
f_usChanIndex                           Index of the channel within the API's channel list.
4624
 
f_usNewPhasingTsstIndex         Index of the new phasing TSST.
4625
 
f_pfSinSoutCodecActive          Pointer to the state of the SIN/SOUT codec.
4626
 
f_pfRinRoutCodecActive          Pointer to the state of the RIN/ROUT codec.
4627
 
f_usNewRinTsstIndex                     New RIN TSST memory index.
4628
 
f_usNewSinTsstIndex                     New SIN TSST memory index.
4629
 
f_usNewRoutTsstIndex            New ROUT TSST memory index.
4630
 
f_usNewSoutTsstIndex            New SOUT TSST memory index.
4631
 
 
4632
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4633
 
#if !SKIP_Oct6100ApiModifyChannelStructs
4634
 
UINT32 Oct6100ApiModifyChannelStructs(
4635
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
4636
 
                                IN      tPOCT6100_CHANNEL_MODIFY                f_pChannelModify, 
4637
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen, 
4638
 
                                IN      UINT16                                                  f_usChanIndex,
4639
 
                                IN      UINT16                                                  f_usNewPhasingTsstIndex,
4640
 
                                OUT     PUINT8                                                  f_pfSinSoutCodecActive,
4641
 
                                OUT     PUINT8                                                  f_pfRinRoutCodecActive,
4642
 
                                IN      UINT16                                                  f_usNewRinTsstIndex,
4643
 
                                IN      UINT16                                                  f_usNewSinTsstIndex,
4644
 
                                IN      UINT16                                                  f_usNewRoutTsstIndex,
4645
 
                                IN      UINT16                                                  f_usNewSoutTsstIndex )
4646
 
{
4647
 
        tPOCT6100_API_CHANNEL           pChanEntry;
4648
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
4649
 
        tOCT6100_READ_PARAMS    ReadParams;
4650
 
        tOCT6100_WRITE_PARAMS   WriteParams;
4651
 
        tPOCT6100_API_CHANNEL_CODEC     pApiCodecConf;
4652
 
        tPOCT6100_API_CHANNEL_TDM       pApiTdmConf;
4653
 
        tPOCT6100_API_CHANNEL_VQE       pApiVqeConf;
4654
 
 
4655
 
        UINT32  ulResult;
4656
 
        UINT16  usReadData;
4657
 
 
4658
 
        UINT16  usSinTsstIndex;
4659
 
        UINT16  usRinTsstIndex;
4660
 
 
4661
 
        UINT32  ulToneConfIndex;
4662
 
        BOOL    fClearPlayoutPointers = FALSE;
4663
 
 
4664
 
        BOOL    fConversionEnabled = FALSE;
4665
 
 
4666
 
 
4667
 
 
4668
 
        /* Obtain local pointer to shared portion of instance. */
4669
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
4670
 
 
4671
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4672
 
 
4673
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
4674
 
 
4675
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
4676
 
 
4677
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
4678
 
        ReadParams.pusReadData = &usReadData;
4679
 
 
4680
 
        /*=======================================================================*/
4681
 
        /* Get a pointer to the channel's list entry. */
4682
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
4683
 
 
4684
 
        /* Obtain local pointer to the configuration structures of the tPOCT6100_API_CHANNEL structure. */
4685
 
        pApiCodecConf = &pChanEntry->CodecConfig;
4686
 
        pApiTdmConf   = &pChanEntry->TdmConfig;
4687
 
        pApiVqeConf   = &pChanEntry->VqeConfig;
4688
 
 
4689
 
        /*=======================================================================*/
4690
 
        /* Init the RIN and SIN TSST index */
4691
 
        
4692
 
        usRinTsstIndex = pChanEntry->usRinTsstIndex;
4693
 
        usSinTsstIndex = pChanEntry->usSinTsstIndex;
4694
 
 
4695
 
 
4696
 
        /*==============================================================================*/
4697
 
        /* Clear the TSST that will be release.*/
4698
 
 
4699
 
        if ( f_pChannelModify->fTdmConfigModified == TRUE )     
4700
 
        {
4701
 
                /* Modify RIN port.*/
4702
 
                if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4703
 
                {
4704
 
                        if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4705
 
                        {
4706
 
                                /* Clear the previous entry  */
4707
 
                                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usRinTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4708
 
                                WriteParams.usWriteData  = 0x0000;
4709
 
 
4710
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4711
 
                                if ( ulResult != cOCT6100_ERR_OK  )
4712
 
                                        return ulResult;
4713
 
                        }
4714
 
                }
4715
 
 
4716
 
                /* Modify SIN port.*/
4717
 
                if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4718
 
                {
4719
 
                        if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4720
 
                        {
4721
 
                                /* Clear the previous entry  */
4722
 
                                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usSinTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4723
 
                                WriteParams.usWriteData  = 0x0000;
4724
 
 
4725
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4726
 
                                if ( ulResult != cOCT6100_ERR_OK  )
4727
 
                                        return ulResult;
4728
 
                        }
4729
 
                }
4730
 
 
4731
 
                /* Modify ROUT port.*/
4732
 
                if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4733
 
                {
4734
 
                        if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
4735
 
                        {
4736
 
                                /* Clear the previous entry  */
4737
 
                                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usRoutTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4738
 
                                WriteParams.usWriteData  = 0x0000;
4739
 
 
4740
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4741
 
                                if ( ulResult != cOCT6100_ERR_OK  )
4742
 
                                        return ulResult;
4743
 
                        }
4744
 
                }
4745
 
 
4746
 
                /* Modify SOUT port.*/
4747
 
                if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING)
4748
 
                {
4749
 
                        if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
4750
 
                        {
4751
 
                                /* Clear the previous entry  */
4752
 
                                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usSoutTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4753
 
                                WriteParams.usWriteData  = 0x0000;
4754
 
 
4755
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4756
 
                                if ( ulResult != cOCT6100_ERR_OK  )
4757
 
                                        return ulResult;
4758
 
                        }
4759
 
                }
4760
 
        }
4761
 
        /*==============================================================================*/
4762
 
 
4763
 
        
4764
 
        /*==============================================================================*/
4765
 
        /* Now, Configure the Tsst control memory.*/
4766
 
 
4767
 
        if ( f_pChannelModify->fTdmConfigModified == TRUE )     
4768
 
        {
4769
 
                /* Modify RIN port.*/
4770
 
                if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4771
 
                {
4772
 
                        usRinTsstIndex = f_usNewRinTsstIndex;
4773
 
 
4774
 
                        if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX )
4775
 
                        {
4776
 
                                if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX )
4777
 
                                {
4778
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4779
 
                                                                                                                                          f_usNewRinTsstIndex,
4780
 
                                                                                                                                          pChanEntry->usExtraRinTsiMemIndex,
4781
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4782
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
4783
 
                                                return ulResult;
4784
 
                                }
4785
 
                                else
4786
 
                                {
4787
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4788
 
                                                                                                                                          f_usNewRinTsstIndex,
4789
 
                                                                                                                                          pChanEntry->usRinRoutTsiMemIndex,
4790
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4791
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
4792
 
                                                return ulResult;
4793
 
                                }
4794
 
                        }
4795
 
                }
4796
 
                if ( f_pChannelModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING &&
4797
 
                         f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
4798
 
                {
4799
 
                        if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX )
4800
 
                        {
4801
 
                                if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4802
 
                                {
4803
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4804
 
                                                                                                                                          pChanEntry->usRinTsstIndex,
4805
 
                                                                                                                                          pChanEntry->usExtraRinTsiMemIndex,
4806
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4807
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
4808
 
                                                return ulResult;
4809
 
                                }
4810
 
                        }
4811
 
                        else
4812
 
                        {
4813
 
                                if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4814
 
                                {
4815
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4816
 
                                                                                                                                          pChanEntry->usRinTsstIndex,
4817
 
                                                                                                                                          pChanEntry->usRinRoutTsiMemIndex,
4818
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4819
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
4820
 
                                                return ulResult;
4821
 
                                }
4822
 
                        }
4823
 
                }
4824
 
 
4825
 
                /* Modify SIN port.*/
4826
 
                if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4827
 
                {
4828
 
                        usSinTsstIndex = f_usNewSinTsstIndex;
4829
 
 
4830
 
                        if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX )
4831
 
                        {
4832
 
                                if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
4833
 
                                {
4834
 
                                        /* Write the new entry now.*/
4835
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4836
 
                                                                                                                                          f_usNewSinTsstIndex,
4837
 
                                                                                                                                          pChanEntry->usExtraSinTsiMemIndex,
4838
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4839
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
4840
 
                                                return ulResult;
4841
 
                                }
4842
 
                                else
4843
 
                                {
4844
 
                                        /* Write the new entry now.*/
4845
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4846
 
                                                                                                                                          f_usNewSinTsstIndex,
4847
 
                                                                                                                                          pChanEntry->usSinSoutTsiMemIndex,
4848
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4849
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
4850
 
                                                return ulResult;
4851
 
                                }
4852
 
                        }
4853
 
                }
4854
 
                if ( f_pChannelModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING &&
4855
 
                         f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
4856
 
                {
4857
 
                        if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
4858
 
                        {
4859
 
                                if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4860
 
                                {
4861
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4862
 
                                                                                                                                          pChanEntry->usSinTsstIndex ,
4863
 
                                                                                                                                          pChanEntry->usExtraSinTsiMemIndex,
4864
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4865
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
4866
 
                                                return ulResult;
4867
 
                                }
4868
 
                        }
4869
 
                        else
4870
 
                        {
4871
 
                                if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4872
 
                                {
4873
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4874
 
                                                                                                                                          pChanEntry->usSinTsstIndex ,
4875
 
                                                                                                                                          pChanEntry->usSinSoutTsiMemIndex,
4876
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4877
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
4878
 
                                                return ulResult;
4879
 
                                }
4880
 
                        }
4881
 
                }
4882
 
 
4883
 
                /* Modify ROUT port.*/
4884
 
                if ( ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4885
 
                        || ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) 
4886
 
                        )
4887
 
                {
4888
 
                        if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX )
4889
 
                        {
4890
 
                                if ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4891
 
                                {
4892
 
                                        /* If this output port is not muted. */
4893
 
                                        if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 )
4894
 
                                        {
4895
 
                                                /* Write the new entry now.*/
4896
 
                                                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
4897
 
                                                                                                                                           f_usNewRoutTsstIndex,
4898
 
                                                                                                                                           pApiCodecConf->byAdpcmNibblePosition,
4899
 
                                                                                                                                           f_pChannelModify->TdmConfig.ulRoutNumTssts,
4900
 
                                                                                                                                           pChanEntry->usRinRoutTsiMemIndex );
4901
 
                                                if ( ulResult != cOCT6100_ERR_OK  )
4902
 
                                                        return ulResult;
4903
 
                                        }
4904
 
                                }
4905
 
                                else
4906
 
                                {
4907
 
                                        /* If this output port is not muted. */
4908
 
                                        if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 )
4909
 
                                        {
4910
 
                                                /* Write the new entry now.*/
4911
 
                                                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
4912
 
                                                                                                                                   f_usNewRoutTsstIndex,
4913
 
                                                                                                                                   pApiCodecConf->byAdpcmNibblePosition,
4914
 
                                                                                                                                   pApiTdmConf->byRoutNumTssts,
4915
 
                                                                                                                                   pChanEntry->usRinRoutTsiMemIndex );
4916
 
                                                if ( ulResult != cOCT6100_ERR_OK  )
4917
 
                                                        return ulResult;
4918
 
                                        }
4919
 
                                }
4920
 
                        }
4921
 
                }
4922
 
 
4923
 
                /* Modify SOUT port.*/
4924
 
                if ( ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4925
 
                        || ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) 
4926
 
                        )
4927
 
                {
4928
 
                        if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX )
4929
 
                        {
4930
 
                                if ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4931
 
                                {
4932
 
                                        /* If this output port is not muted. */
4933
 
                                        if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 )
4934
 
                                        {
4935
 
                                                /* Write the new entry now.*/
4936
 
                                                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
4937
 
                                                                                                                                           f_usNewSoutTsstIndex,
4938
 
                                                                                                                                           pApiCodecConf->byAdpcmNibblePosition,
4939
 
                                                                                                                                           f_pChannelModify->TdmConfig.ulSoutNumTssts,
4940
 
                                                                                                                                           pChanEntry->usSinSoutTsiMemIndex );
4941
 
 
4942
 
                                                if ( ulResult != cOCT6100_ERR_OK  )
4943
 
                                                        return ulResult;
4944
 
                                        }
4945
 
                                }
4946
 
                                else
4947
 
                                {
4948
 
                                        /* If this output port is not muted. */
4949
 
                                        if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 )
4950
 
                                        {
4951
 
                                                /* Write the new entry now.*/
4952
 
                                                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
4953
 
                                                                                                                                   f_usNewSoutTsstIndex,
4954
 
                                                                                                                                   pApiCodecConf->byAdpcmNibblePosition,
4955
 
                                                                                                                                   pApiTdmConf->bySoutNumTssts,
4956
 
                                                                                                                                   pChanEntry->usSinSoutTsiMemIndex );
4957
 
 
4958
 
                                                if ( ulResult != cOCT6100_ERR_OK  )
4959
 
                                                        return ulResult;
4960
 
                                        }
4961
 
                                }
4962
 
                        }
4963
 
                }
4964
 
 
4965
 
 
4966
 
 
4967
 
        }
4968
 
 
4969
 
        /*==============================================================================*/
4970
 
 
4971
 
 
4972
 
        /*==============================================================================*/
4973
 
        /* Modify the Encoder/Decoder memory if required.*/
4974
 
 
4975
 
        if ( f_pChannelModify->fCodecConfigModified == TRUE )
4976
 
        {
4977
 
                UINT32  ulCompType = 0;
4978
 
                UINT16  usTempTsiMemIndex;
4979
 
                UINT16  usDecoderMemIndex;
4980
 
                UINT16  usEncoderMemIndex;
4981
 
                UINT32  ulPcmLaw;
4982
 
                UINT16  usPhasingIndex;
4983
 
                BOOL    fModifyAdpcmMem = TRUE;
4984
 
 
4985
 
                /*==============================================================================*/
4986
 
                /* Reprogram the Decoder memory.*/
4987
 
 
4988
 
                if ( pChanEntry->CodecConfig.byDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
4989
 
                {
4990
 
                        usDecoderMemIndex = pChanEntry->usRinRoutConversionMemIndex;
4991
 
                }
4992
 
                else
4993
 
                {
4994
 
                        usDecoderMemIndex = pChanEntry->usSinSoutConversionMemIndex;
4995
 
                }
4996
 
 
4997
 
                if ( pChanEntry->CodecConfig.byEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
4998
 
                {
4999
 
                        usEncoderMemIndex = pChanEntry->usRinRoutConversionMemIndex;
5000
 
                }
5001
 
                else
5002
 
                {
5003
 
                        usEncoderMemIndex = pChanEntry->usSinSoutConversionMemIndex;
5004
 
                }
5005
 
 
5006
 
                if ( usDecoderMemIndex != cOCT6100_INVALID_INDEX  )
5007
 
                {
5008
 
                        switch( f_pChannelOpen->CodecConfig.ulDecodingRate )
5009
 
                        {
5010
 
                        case cOCT6100_G711_64KBPS:                              
5011
 
                                ulCompType = 0x8;
5012
 
                                
5013
 
                                if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5014
 
                                {
5015
 
                                        if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw )
5016
 
                                                fModifyAdpcmMem = FALSE;
5017
 
 
5018
 
                                        /* Check if both ports are assigned.  If not, no law conversion needed here.. */
5019
 
                                        if ( ( f_pChannelOpen->TdmConfig.ulRinStream == cOCT6100_UNASSIGNED ) 
5020
 
                                                || ( f_pChannelOpen->TdmConfig.ulRoutStream == cOCT6100_UNASSIGNED ) )
5021
 
                                                fModifyAdpcmMem = FALSE;
5022
 
                                }
5023
 
                                else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
5024
 
                                {
5025
 
                                        if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
5026
 
                                                fModifyAdpcmMem = FALSE;
5027
 
 
5028
 
                                        /* Check if both ports are assigned.  If not, no law conversion needed here.. */
5029
 
                                        if ( ( f_pChannelOpen->TdmConfig.ulSinStream == cOCT6100_UNASSIGNED ) 
5030
 
                                                || ( f_pChannelOpen->TdmConfig.ulSoutStream == cOCT6100_UNASSIGNED ) )
5031
 
                                                fModifyAdpcmMem = FALSE;
5032
 
                                }
5033
 
 
5034
 
                                break;
5035
 
                        case cOCT6100_G726_40KBPS:                              
5036
 
                                ulCompType = 0x3;               
5037
 
                                fConversionEnabled = TRUE;
5038
 
                                break;
5039
 
 
5040
 
                        case cOCT6100_G726_32KBPS:                              
5041
 
                                ulCompType = 0x2;               
5042
 
                                fConversionEnabled = TRUE;
5043
 
                                break;
5044
 
 
5045
 
                        case cOCT6100_G726_24KBPS:                              
5046
 
                                ulCompType = 0x1;               
5047
 
                                fConversionEnabled = TRUE;
5048
 
                                break;
5049
 
 
5050
 
                        case cOCT6100_G726_16KBPS:                              
5051
 
                                ulCompType = 0x0;               
5052
 
                                fConversionEnabled = TRUE;
5053
 
                                break;          
5054
 
 
5055
 
                        case cOCT6100_G727_2C_ENCODED:                  
5056
 
                                ulCompType = 0x4;               
5057
 
                                fConversionEnabled = TRUE;
5058
 
                                break;
5059
 
 
5060
 
                        case cOCT6100_G727_3C_ENCODED:                  
5061
 
                                ulCompType = 0x5;               
5062
 
                                fConversionEnabled = TRUE;
5063
 
                                break;
5064
 
 
5065
 
                        case cOCT6100_G727_4C_ENCODED:                  
5066
 
                                ulCompType = 0x6;               
5067
 
                                fConversionEnabled = TRUE;
5068
 
                                break;
5069
 
 
5070
 
                        case cOCT6100_G726_ENCODED:                             
5071
 
                                ulCompType = 0x9;               
5072
 
                                fConversionEnabled = TRUE;
5073
 
                                break;
5074
 
 
5075
 
                        case cOCT6100_G711_G726_ENCODED:                
5076
 
                                ulCompType = 0xA;               
5077
 
                                fConversionEnabled = TRUE;
5078
 
                                break;
5079
 
 
5080
 
                        case cOCT6100_G711_G727_2C_ENCODED:             
5081
 
                                ulCompType = 0xC;               
5082
 
                                fConversionEnabled = TRUE;
5083
 
                                break;
5084
 
 
5085
 
                        case cOCT6100_G711_G727_3C_ENCODED:             
5086
 
                                ulCompType = 0xD;               
5087
 
                                fConversionEnabled = TRUE;
5088
 
                                break;
5089
 
 
5090
 
                        case cOCT6100_G711_G727_4C_ENCODED:             
5091
 
                                ulCompType = 0xE;               
5092
 
                                fConversionEnabled = TRUE;
5093
 
                                break;
5094
 
 
5095
 
                        default:
5096
 
                                return cOCT6100_ERR_FATAL_D6;
5097
 
                        }
5098
 
 
5099
 
                        if ( fModifyAdpcmMem == TRUE )
5100
 
                        {
5101
 
                                /* Set the chariot memory based on the selected port.*/
5102
 
                                if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5103
 
                                {
5104
 
                                        usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
5105
 
                                        ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;              /* Set the law for later use */
5106
 
                                        
5107
 
                                        /* Flag the entry as active.*/
5108
 
                                        *f_pfRinRoutCodecActive = TRUE;
5109
 
                                }
5110
 
                                else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
5111
 
                                {
5112
 
                                        usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
5113
 
                                        ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;              /* Set the law for later use */
5114
 
 
5115
 
                                        /* Flag the entry as active.*/
5116
 
                                        *f_pfSinSoutCodecActive = TRUE;
5117
 
                                }
5118
 
 
5119
 
                                ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance,
5120
 
                                                                                                                 usDecoderMemIndex,
5121
 
                                                                                                                 ulCompType,
5122
 
                                                                                                                 usTempTsiMemIndex,
5123
 
                                                                                                                 ulPcmLaw,
5124
 
                                                                                                                 pApiCodecConf->byAdpcmNibblePosition );
5125
 
                                if ( ulResult != cOCT6100_ERR_OK )
5126
 
                                        return ulResult;
5127
 
                        }
5128
 
                        else
5129
 
                        {
5130
 
                                ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance,
5131
 
                                                                                                                 usDecoderMemIndex );
5132
 
                                if ( ulResult != cOCT6100_ERR_OK )
5133
 
                                        return ulResult;
5134
 
 
5135
 
                                /* Flag the entry as deactivated.*/
5136
 
                                if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5137
 
                                {
5138
 
                                        *f_pfRinRoutCodecActive = FALSE;
5139
 
                                }
5140
 
                                else
5141
 
                                {
5142
 
                                        *f_pfSinSoutCodecActive = FALSE;
5143
 
                                }
5144
 
                        }
5145
 
                }
5146
 
 
5147
 
                /*==============================================================================*/
5148
 
 
5149
 
 
5150
 
 
5151
 
 
5152
 
                /*==============================================================================*/
5153
 
                /* Reprogram the Encoder memory.*/
5154
 
        
5155
 
                if ( usEncoderMemIndex != cOCT6100_INVALID_INDEX )
5156
 
                {
5157
 
 
5158
 
                        fModifyAdpcmMem = TRUE;
5159
 
                        
5160
 
                        /* Set the chariot memory based on the selected port.*/
5161
 
                        if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5162
 
                        {
5163
 
                                usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
5164
 
                                ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;              /* Set the law for later use */
5165
 
                        }
5166
 
                        else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5167
 
                        {
5168
 
                                usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
5169
 
                                ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;              /* Set the law for later use */
5170
 
                        }
5171
 
 
5172
 
                        /* Set the phasing index .*/
5173
 
                        if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX )
5174
 
                                usPhasingIndex = f_usNewPhasingTsstIndex;
5175
 
                        else
5176
 
                                usPhasingIndex = pChanEntry->usPhasingTsstIndex;
5177
 
 
5178
 
                        switch( f_pChannelOpen->CodecConfig.ulEncodingRate )
5179
 
                        {
5180
 
                                case cOCT6100_G711_64KBPS:
5181
 
                                        if ( ulPcmLaw == cOCT6100_PCM_U_LAW )
5182
 
                                                ulCompType = 0x4;
5183
 
                                        else /* ulPcmLaw  == cOCT6100_PCM_A_LAW */
5184
 
                                                ulCompType = 0x5;
5185
 
                                        
5186
 
                                        if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5187
 
                                        {
5188
 
                                                if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw )
5189
 
                                                        fModifyAdpcmMem = FALSE;
5190
 
 
5191
 
                                                /* Check if both ports are assigned.  If not, no law conversion needed here.. */
5192
 
                                                if ( ( f_pChannelOpen->TdmConfig.ulRinStream == cOCT6100_UNASSIGNED ) 
5193
 
                                                        || ( f_pChannelOpen->TdmConfig.ulRoutStream == cOCT6100_UNASSIGNED ) )
5194
 
                                                        fModifyAdpcmMem = FALSE;
5195
 
                                        }
5196
 
                                        else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5197
 
                                        {
5198
 
                                                if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
5199
 
                                                        fModifyAdpcmMem = FALSE;
5200
 
 
5201
 
                                                /* Check if both ports are assigned.  If not, no law conversion needed here.. */
5202
 
                                                if ( ( f_pChannelOpen->TdmConfig.ulSinStream == cOCT6100_UNASSIGNED ) 
5203
 
                                                        || ( f_pChannelOpen->TdmConfig.ulSoutStream == cOCT6100_UNASSIGNED ) )
5204
 
                                                        fModifyAdpcmMem = FALSE;
5205
 
                                        }
5206
 
                                        break;
5207
 
                                case cOCT6100_G726_40KBPS:                              
5208
 
                                        ulCompType = 0x3;               
5209
 
                                        fConversionEnabled = TRUE;
5210
 
                                        break;
5211
 
 
5212
 
                                case cOCT6100_G726_32KBPS:                              
5213
 
                                        ulCompType = 0x2;               
5214
 
                                        fConversionEnabled = TRUE;
5215
 
                                        break;
5216
 
 
5217
 
                                case cOCT6100_G726_24KBPS:                              
5218
 
                                        ulCompType = 0x1;               
5219
 
                                        fConversionEnabled = TRUE;
5220
 
                                        break;
5221
 
 
5222
 
                                case cOCT6100_G726_16KBPS:                              
5223
 
                                        ulCompType = 0x0;               
5224
 
                                        fConversionEnabled = TRUE;
5225
 
                                        break;          
5226
 
 
5227
 
                                case cOCT6100_G727_40KBPS_4_1:                  
5228
 
                                        ulCompType = 0xD;               
5229
 
                                        fConversionEnabled = TRUE;
5230
 
                                        break;
5231
 
 
5232
 
                                case cOCT6100_G727_40KBPS_3_2:                  
5233
 
                                        ulCompType = 0xA;               
5234
 
                                        fConversionEnabled = TRUE;
5235
 
                                        break;
5236
 
 
5237
 
                                case cOCT6100_G727_40KBPS_2_3:                  
5238
 
                                        ulCompType = 0x6;               
5239
 
                                        fConversionEnabled = TRUE;
5240
 
                                        break;
5241
 
 
5242
 
                                case cOCT6100_G727_32KBPS_4_0:                  
5243
 
                                        ulCompType = 0xE;               
5244
 
                                        fConversionEnabled = TRUE;
5245
 
                                        break;
5246
 
 
5247
 
                                case cOCT6100_G727_32KBPS_3_1:                  
5248
 
                                        ulCompType = 0xB;               
5249
 
                                        fConversionEnabled = TRUE;
5250
 
                                        break;
5251
 
 
5252
 
                                case cOCT6100_G727_32KBPS_2_2:                  
5253
 
                                        ulCompType = 0x7;               
5254
 
                                        fConversionEnabled = TRUE;
5255
 
                                        break;
5256
 
 
5257
 
                                case cOCT6100_G727_24KBPS_3_0:                  
5258
 
                                        ulCompType = 0xC;               
5259
 
                                        fConversionEnabled = TRUE;
5260
 
                                        break;
5261
 
 
5262
 
                                case cOCT6100_G727_24KBPS_2_1:                  
5263
 
                                        ulCompType = 0x8;               
5264
 
                                        fConversionEnabled = TRUE;
5265
 
                                        break;
5266
 
 
5267
 
                                case cOCT6100_G727_16KBPS_2_0:                  
5268
 
                                        ulCompType = 0x9;               
5269
 
                                        fConversionEnabled = TRUE;
5270
 
                                        break;
5271
 
 
5272
 
                                default:
5273
 
                                        return cOCT6100_ERR_FATAL_D7;
5274
 
                        }
5275
 
 
5276
 
                        if ( fModifyAdpcmMem == TRUE )
5277
 
                        {
5278
 
                                if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5279
 
                                {
5280
 
                                        *f_pfRinRoutCodecActive = TRUE;
5281
 
                                }
5282
 
                                else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5283
 
                                {
5284
 
                                        *f_pfSinSoutCodecActive = TRUE;
5285
 
                                }
5286
 
                                
5287
 
                                ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance,
5288
 
                                                                                                                 usEncoderMemIndex,
5289
 
                                                                                                                 ulCompType,
5290
 
                                                                                                                 usTempTsiMemIndex,
5291
 
                                                                                                                 f_pChannelOpen->CodecConfig.fEnableSilenceSuppression,
5292
 
                                                                                                                 pApiCodecConf->byAdpcmNibblePosition,
5293
 
                                                                                                                 usPhasingIndex,
5294
 
                                                                                                                 f_pChannelOpen->CodecConfig.ulPhasingType,
5295
 
                                                                                                                 f_pChannelOpen->CodecConfig.ulPhase );
5296
 
                                                                                                         
5297
 
                                if ( ulResult != cOCT6100_ERR_OK )
5298
 
                                        return ulResult;
5299
 
                        }
5300
 
                        else
5301
 
                        {
5302
 
                                ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance,
5303
 
                                                                                                                        usEncoderMemIndex );
5304
 
                                if ( ulResult != cOCT6100_ERR_OK )
5305
 
                                        return ulResult;
5306
 
 
5307
 
                                if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5308
 
                                {
5309
 
                                        *f_pfRinRoutCodecActive = FALSE;
5310
 
                                }
5311
 
                                else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5312
 
                                {
5313
 
                                        *f_pfSinSoutCodecActive = FALSE;
5314
 
                                }
5315
 
                        }
5316
 
                }
5317
 
 
5318
 
                /*==============================================================================*/
5319
 
        }
5320
 
 
5321
 
 
5322
 
 
5323
 
        
5324
 
        /*==============================================================================*/
5325
 
        /* Modify the VQE parameter if required.*/
5326
 
 
5327
 
        if ( ( f_pChannelModify->fVqeConfigModified == TRUE )
5328
 
                || ( (UINT8)f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode )
5329
 
                || ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) )
5330
 
        {
5331
 
                ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance,
5332
 
                                                                                          &f_pChannelOpen->VqeConfig,
5333
 
                                                                                          f_pChannelOpen,
5334
 
                                                                                          f_usChanIndex,
5335
 
                                                                                          pChanEntry->usEchoMemIndex,
5336
 
                                                                                          FALSE,
5337
 
                                                                                          TRUE );
5338
 
                if ( ulResult != cOCT6100_ERR_OK )
5339
 
                        return ulResult;
5340
 
        }
5341
 
 
5342
 
        /*==============================================================================*/
5343
 
        /* Modify the Echo memory if required.*/
5344
 
        if ( f_pChannelModify->fEnableToneDisabler               != cOCT6100_KEEP_PREVIOUS_SETTING ||
5345
 
                 f_pChannelModify->ulEchoOperationMode       != cOCT6100_KEEP_PREVIOUS_SETTING ||
5346
 
                 f_pChannelModify->TdmConfig.ulRinPcmLaw         != cOCT6100_KEEP_PREVIOUS_SETTING ||
5347
 
                 f_pChannelModify->TdmConfig.ulSinPcmLaw         != cOCT6100_KEEP_PREVIOUS_SETTING ||
5348
 
                 f_pChannelModify->TdmConfig.ulRoutPcmLaw        != cOCT6100_KEEP_PREVIOUS_SETTING ||
5349
 
                 f_pChannelModify->TdmConfig.ulSoutPcmLaw        != cOCT6100_KEEP_PREVIOUS_SETTING )
5350
 
        {
5351
 
                ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance,
5352
 
                                                                                          &f_pChannelOpen->TdmConfig,
5353
 
                                                                                          f_pChannelOpen,
5354
 
                                                                                          pChanEntry->usEchoMemIndex,
5355
 
                                                                                          pChanEntry->usRinRoutTsiMemIndex,
5356
 
                                                                                          pChanEntry->usSinSoutTsiMemIndex );
5357
 
                if ( ulResult != cOCT6100_ERR_OK )
5358
 
                        return ulResult;
5359
 
                
5360
 
                /* Synch all the buffer playout field if needed by echo operation mode. */
5361
 
                /* Note that Oct6100ApiWriteVqeMemory does not clear the playout pointers */
5362
 
                /* since the flag is set to FALSE. */
5363
 
                if ( ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE ) 
5364
 
                        && ( ( f_pChannelModify->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_HT_FREEZE )
5365
 
                                || ( f_pChannelModify->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_POWER_DOWN ) ) )
5366
 
                {       
5367
 
                        /* Buffer playout must be stopped. */
5368
 
                        fClearPlayoutPointers = TRUE;
5369
 
                }
5370
 
        }
5371
 
 
5372
 
        /*==============================================================================*/
5373
 
        /* Modify the Mixer events if law changes are requested. */
5374
 
        
5375
 
        if ( pChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX && 
5376
 
                 f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
5377
 
        {
5378
 
                ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
5379
 
 
5380
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5381
 
                if ( ulResult != cOCT6100_ERR_OK )
5382
 
                        return ulResult;
5383
 
 
5384
 
                /* Modify the value according to the new law.*/
5385
 
                if ( f_pChannelModify->TdmConfig.ulSinPcmLaw == cOCT6100_PCM_A_LAW )
5386
 
                        WriteParams.usWriteData = (UINT16)( usReadData | ( f_pChannelModify->TdmConfig.ulSinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET ));
5387
 
                else
5388
 
                        WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )));
5389
 
 
5390
 
                /* Write back the new value.*/
5391
 
                WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
5392
 
 
5393
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5394
 
                if ( ulResult != cOCT6100_ERR_OK )
5395
 
                        return ulResult;
5396
 
        }
5397
 
 
5398
 
        if ( pChanEntry->usSoutCopyEventIndex != cOCT6100_INVALID_INDEX && 
5399
 
                 f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
5400
 
        {
5401
 
                ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
5402
 
 
5403
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5404
 
                if ( ulResult != cOCT6100_ERR_OK )
5405
 
                        return ulResult;
5406
 
 
5407
 
                /* Modify the value according to the new law.*/
5408
 
                if ( f_pChannelModify->TdmConfig.ulSoutPcmLaw == cOCT6100_PCM_A_LAW )
5409
 
                        WriteParams.usWriteData = (UINT16)( usReadData | ( f_pChannelModify->TdmConfig.ulSoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET ));
5410
 
                else
5411
 
                        WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )));
5412
 
 
5413
 
                /* Write back the new value.*/
5414
 
                WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
5415
 
 
5416
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5417
 
                if ( ulResult != cOCT6100_ERR_OK )
5418
 
                        return ulResult;
5419
 
        }
5420
 
 
5421
 
        /*==============================================================================*/
5422
 
        /*      Mute channel if required, this is done on a port basis */
5423
 
        
5424
 
        ulResult = Oct6100ApiMutePorts( f_pApiInstance,
5425
 
                                                                        f_usChanIndex,
5426
 
                                                                        usRinTsstIndex,
5427
 
                                                                        usSinTsstIndex,
5428
 
                                                                        TRUE );
5429
 
        if ( ulResult != cOCT6100_ERR_OK )
5430
 
                return ulResult;
5431
 
 
5432
 
        /*==============================================================================*/
5433
 
 
5434
 
        /* Completely disable tone detection? */
5435
 
        if ( f_pChannelModify->fDisableToneDetection == TRUE )
5436
 
        {
5437
 
                /* Check if tone detection has been enabled on this channel. */
5438
 
                for ( ulToneConfIndex = 0; ulToneConfIndex < ( sizeof( pChanEntry->aulToneConf ) / sizeof(UINT32) ); ulToneConfIndex ++ )
5439
 
                {
5440
 
                        /* Check if some tone has been activated on this channel. */
5441
 
                        if ( pChanEntry->aulToneConf[ ulToneConfIndex ] != 0 )
5442
 
                        {
5443
 
                                tOCT6100_TONE_DETECTION_DISABLE         ToneDetectDisable;
5444
 
 
5445
 
                                /* Call the default function to make sure all parameters are assigned default values. */
5446
 
                                ulResult = Oct6100ToneDetectionDisableDef( &ToneDetectDisable );
5447
 
                                if ( ulResult != cOCT6100_ERR_OK )
5448
 
                                        return ulResult;
5449
 
                                
5450
 
                                /* Form channel handle. */
5451
 
                                ToneDetectDisable.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5452
 
 
5453
 
                                /* Disable all tones activated on this channel. */
5454
 
                                ToneDetectDisable.fDisableAll = TRUE;
5455
 
 
5456
 
                                /* Call tone detection serialized function. */
5457
 
                                ulResult = Oct6100ToneDetectionDisableSer( f_pApiInstance, &ToneDetectDisable );
5458
 
                                if ( ulResult != cOCT6100_ERR_OK )
5459
 
                                        return ulResult;
5460
 
 
5461
 
                                /* Get out of the loop, tone detection has been disabled! */
5462
 
                                break;
5463
 
                        }
5464
 
                }
5465
 
        }
5466
 
 
5467
 
        /* Hard-stop buffer playout? */
5468
 
        if ( f_pChannelModify->fStopBufferPlayout == TRUE )
5469
 
        {
5470
 
                /* Check if playout has been started on the Rout port. */
5471
 
                if ( ( pChanEntry->fRinBufPlaying == TRUE ) || ( pChanEntry->fRinBufAdded == TRUE ) )
5472
 
                {
5473
 
                        tOCT6100_BUFFER_PLAYOUT_STOP    PlayoutStop;
5474
 
 
5475
 
                        /* Call the default function to make sure all parameters are assigned default values. */
5476
 
                        ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop );
5477
 
                        if ( ulResult != cOCT6100_ERR_OK )
5478
 
                                return ulResult;
5479
 
 
5480
 
                        /* Hard stop request. */
5481
 
                        PlayoutStop.fStopCleanly = FALSE;
5482
 
 
5483
 
                        /* Form channel handle. */
5484
 
                        PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5485
 
 
5486
 
                        /* For the Rout port. */
5487
 
                        PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
5488
 
 
5489
 
                        /* Call buffer playout stop serialized function. */
5490
 
                        ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop );
5491
 
                        if ( ulResult != cOCT6100_ERR_OK )
5492
 
                                return ulResult;
5493
 
                }
5494
 
                else
5495
 
                {
5496
 
                        /* The chip might still be playing a last buffer.  Make sure it hard-stops! */
5497
 
                        fClearPlayoutPointers = TRUE;
5498
 
                }
5499
 
 
5500
 
                /* Check if playout has been started on the Sout port. */
5501
 
                if ( ( pChanEntry->fSoutBufPlaying == TRUE ) || ( pChanEntry->fSoutBufAdded == TRUE ) )
5502
 
                {
5503
 
                        tOCT6100_BUFFER_PLAYOUT_STOP    PlayoutStop;
5504
 
 
5505
 
                        /* Call the default function to make sure all parameters are assigned default values. */
5506
 
                        ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop );
5507
 
                        if ( ulResult != cOCT6100_ERR_OK )
5508
 
                                return ulResult;
5509
 
                        
5510
 
                        /* Hard stop request. */
5511
 
                        PlayoutStop.fStopCleanly = FALSE;
5512
 
 
5513
 
                        /* Form channel handle. */
5514
 
                        PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5515
 
 
5516
 
                        /* For the Rout port. */
5517
 
                        PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
5518
 
 
5519
 
                        /* Call buffer playout stop serialized function. */
5520
 
                        ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop );
5521
 
                        if ( ulResult != cOCT6100_ERR_OK )
5522
 
                                return ulResult;
5523
 
                }
5524
 
                else
5525
 
                {
5526
 
                        /* The chip might still be playing a last buffer.  Make sure it hard-stops! */
5527
 
                        fClearPlayoutPointers = TRUE;
5528
 
                }
5529
 
        }
5530
 
 
5531
 
        /* Remove participant from bridge? */
5532
 
        if ( f_pChannelModify->fRemoveConfBridgeParticipant == TRUE )
5533
 
        {
5534
 
                /* Check if this channel is on a bridge. */
5535
 
                if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
5536
 
                {
5537
 
                        /* Channel is on a bridge, remove it. */
5538
 
                        tOCT6100_CONF_BRIDGE_CHAN_REMOVE        BridgeChanRemove;
5539
 
 
5540
 
                        /* Call the default function to make sure all parameters are assigned default values. */
5541
 
                        ulResult = Oct6100ConfBridgeChanRemoveDef( &BridgeChanRemove );
5542
 
                        if ( ulResult != cOCT6100_ERR_OK )
5543
 
                                return ulResult;
5544
 
                        
5545
 
                        /* Form channel handle. */
5546
 
                        BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5547
 
 
5548
 
                        /* Do not remove all channels, only the one specified. */
5549
 
                        BridgeChanRemove.fRemoveAll = FALSE;
5550
 
 
5551
 
                        /* No need to assign conference bridge handle, the remove function will figure it out. */
5552
 
 
5553
 
                        /* Call conference bridge channel remove serialized function. */
5554
 
                        ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
5555
 
                        if ( ulResult != cOCT6100_ERR_OK )
5556
 
                        {
5557
 
                                if ( ulResult == cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_DEPENDENCY )
5558
 
                                {
5559
 
                                        tPOCT6100_API_CHANNEL           pTapChanEntry;
5560
 
 
5561
 
                                        /* Get a pointer to the tap channel's list entry. */
5562
 
                                        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTapChanEntry, pChanEntry->usTapChanIndex )
5563
 
 
5564
 
                                        /* Form tap channel handle. */
5565
 
                                        BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pTapChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | pChanEntry->usTapChanIndex;
5566
 
 
5567
 
                                        ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
5568
 
                                        if ( ulResult != cOCT6100_ERR_OK )
5569
 
                                                return ulResult;
5570
 
 
5571
 
                                        /* Re-form original channel handle. */
5572
 
                                        BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5573
 
 
5574
 
                                        ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
5575
 
                                        if ( ulResult != cOCT6100_ERR_OK )
5576
 
                                                return ulResult;
5577
 
                                }
5578
 
                                else
5579
 
                                {
5580
 
                                        return ulResult;
5581
 
                                }
5582
 
                        }
5583
 
                }
5584
 
        }
5585
 
 
5586
 
        /* Remove all broadcast TSSTs? */
5587
 
        if ( f_pChannelModify->fRemoveBroadcastTssts == TRUE )
5588
 
        {
5589
 
                /* Check if broadcast TSSTs were used on the Rout port. */
5590
 
                if ( pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX )
5591
 
                {
5592
 
                        tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE  BroadcastTsstRemove;
5593
 
 
5594
 
                        ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove );
5595
 
                        if ( ulResult != cOCT6100_ERR_OK )
5596
 
                                return ulResult;
5597
 
                        
5598
 
                        /* Form channel handle. */
5599
 
                        BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5600
 
 
5601
 
                        /* Remove all broadcast TSSTs associated to the current channel. */
5602
 
                        BroadcastTsstRemove.fRemoveAll = TRUE;
5603
 
 
5604
 
                        /* On the Rout port. */
5605
 
                        BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_ROUT; 
5606
 
 
5607
 
                        ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove );
5608
 
                        if ( ulResult != cOCT6100_ERR_OK )
5609
 
                                return ulResult;
5610
 
                }
5611
 
 
5612
 
 
5613
 
                /* Check if broadcast TSSTs were used on the Sout port. */
5614
 
                if ( pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX )
5615
 
                {
5616
 
                        tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE  BroadcastTsstRemove;
5617
 
 
5618
 
                        ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove );
5619
 
                        if ( ulResult != cOCT6100_ERR_OK )
5620
 
                                return ulResult;
5621
 
                        
5622
 
                        /* Form channel handle. */
5623
 
                        BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5624
 
 
5625
 
                        /* Remove all broadcast TSSTs associated to the current channel. */
5626
 
                        BroadcastTsstRemove.fRemoveAll = TRUE;
5627
 
 
5628
 
                        /* On the Sout port. */
5629
 
                        BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_SOUT;
5630
 
 
5631
 
                        ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove );
5632
 
                        if ( ulResult != cOCT6100_ERR_OK )
5633
 
                                return ulResult;
5634
 
                }
5635
 
        }
5636
 
 
5637
 
        /* Check if have to make sure buffer playout is stopped. */
5638
 
        if ( fClearPlayoutPointers == TRUE )
5639
 
        {       
5640
 
                tOCT6100_BUFFER_PLAYOUT_STOP    BufferPlayoutStop;
5641
 
 
5642
 
                Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
5643
 
 
5644
 
                BufferPlayoutStop.fStopCleanly = FALSE;
5645
 
                BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
5646
 
 
5647
 
                ulResult = Oct6100ApiInvalidateChanPlayoutStructs( 
5648
 
                                                                                                        f_pApiInstance, 
5649
 
                                                                                                        &BufferPlayoutStop, 
5650
 
                                                                                                        f_usChanIndex, 
5651
 
                                                                                                        pChanEntry->usEchoMemIndex 
5652
 
 
5653
 
                                                                                                        );
5654
 
                if ( ulResult != cOCT6100_ERR_OK )
5655
 
                        return ulResult;
5656
 
                
5657
 
                BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
5658
 
                ulResult = Oct6100ApiInvalidateChanPlayoutStructs( 
5659
 
                                                                                                        f_pApiInstance, 
5660
 
                                                                                                        &BufferPlayoutStop, 
5661
 
                                                                                                        f_usChanIndex, 
5662
 
                                                                                                        pChanEntry->usEchoMemIndex 
5663
 
 
5664
 
                                                                                                        );
5665
 
                if ( ulResult != cOCT6100_ERR_OK )
5666
 
                        return ulResult;
5667
 
        }
5668
 
 
5669
 
        return cOCT6100_ERR_OK;
5670
 
}
5671
 
#endif
5672
 
 
5673
 
 
5674
 
 
5675
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5676
 
 
5677
 
Function:               Oct6100ApiModifyChannelEntry
5678
 
 
5679
 
Description:    Updates the channel structure in the ECHO channel list.
5680
 
 
5681
 
-------------------------------------------------------------------------------
5682
 
|       Argument                |       Description
5683
 
-------------------------------------------------------------------------------
5684
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
5685
 
                                                        the present state of the chip and all its resources.
5686
 
 
5687
 
f_pChannelModify                        Pointer to echo cancellation channel modify structure.
5688
 
f_pChannelOpen                          Pointer to echo cancellation channel configuration structure.
5689
 
f_usChanIndex                           Index of the channel within the API's channel list.
5690
 
f_usNewPhasingTsstIndex         Index of the new phasing TSST.
5691
 
f_fSinSoutCodecActive           State of the SIN/SOUT codec.
5692
 
f_fRinRoutCodecActive           State of the RIN/ROUT codec.
5693
 
f_usNewRinTsstIndex                     New RIN TSST memory index.
5694
 
f_usNewSinTsstIndex                     New SIN TSST memory index.
5695
 
f_usNewRoutTsstIndex            New ROUT TSST memory index.
5696
 
f_usNewSoutTsstIndex            New SOUT TSST memory index.
5697
 
 
5698
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5699
 
#if !SKIP_Oct6100ApiModifyChannelEntry
5700
 
UINT32 Oct6100ApiModifyChannelEntry(
5701
 
                                IN tPOCT6100_INSTANCE_API                       f_pApiInstance,
5702
 
                                IN tPOCT6100_CHANNEL_MODIFY                     f_pChannelModify,
5703
 
                                IN tPOCT6100_CHANNEL_OPEN                       f_pChannelOpen,
5704
 
                                IN UINT16                                                       f_usChanIndex,
5705
 
                                IN UINT16                                                       f_usNewPhasingTsstIndex,
5706
 
                                IN UINT8                                                        f_fSinSoutCodecActive,
5707
 
                                IN UINT8                                                        f_fRinRoutCodecActive,
5708
 
                                IN UINT16                                                       f_usNewRinTsstIndex,
5709
 
                                IN UINT16                                                       f_usNewSinTsstIndex,
5710
 
                                IN UINT16                                                       f_usNewRoutTsstIndex,
5711
 
                                IN UINT16                                                       f_usNewSoutTsstIndex )
5712
 
{
5713
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
5714
 
        tPOCT6100_API_CHANNEL           pChanEntry;
5715
 
        tPOCT6100_API_CHANNEL_CODEC     pApiCodecConf;
5716
 
        tPOCT6100_API_CHANNEL_TDM       pApiTdmConf;
5717
 
        tPOCT6100_API_CHANNEL_VQE       pApiVqeConf;
5718
 
 
5719
 
        /* Obtain local pointer to shared portion of instance. */
5720
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
5721
 
 
5722
 
        /*=======================================================================*/
5723
 
        /* Get a pointer to the channel's list entry. */
5724
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
5725
 
 
5726
 
        /* Obtain local pointer to the configuration structures of the tPOCT6100_API_CHANNEL structure. */
5727
 
        pApiCodecConf = &pChanEntry->CodecConfig;
5728
 
        pApiTdmConf   = &pChanEntry->TdmConfig;
5729
 
        pApiVqeConf   = &pChanEntry->VqeConfig;
5730
 
 
5731
 
        /*=======================================================================*/
5732
 
        /* Copy the channel's general configuration. */
5733
 
 
5734
 
        pChanEntry->ulUserChanId = f_pChannelOpen->ulUserChanId;
5735
 
        pChanEntry->byEchoOperationMode = (UINT8)( f_pChannelOpen->ulEchoOperationMode & 0xFF );
5736
 
        pChanEntry->fEnableToneDisabler = (UINT8)( f_pChannelOpen->fEnableToneDisabler & 0xFF );
5737
 
 
5738
 
        /* Save the codec state.*/
5739
 
        pChanEntry->fSinSoutCodecActive = (UINT8)( f_fSinSoutCodecActive & 0xFF );
5740
 
        pChanEntry->fRinRoutCodecActive = (UINT8)( f_fRinRoutCodecActive & 0xFF );
5741
 
 
5742
 
        /*=======================================================================*/
5743
 
        /* Copy the channel's TDM configuration of all the modified fields. */
5744
 
 
5745
 
        if ( f_pChannelModify->fTdmConfigModified == TRUE )
5746
 
        {
5747
 
                pApiTdmConf->byRinPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulRinPcmLaw & 0xFF );
5748
 
                pApiTdmConf->bySinPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulSinPcmLaw & 0xFF );
5749
 
                pApiTdmConf->byRoutPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulRoutPcmLaw & 0xFF );
5750
 
                pApiTdmConf->bySoutPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulSoutPcmLaw & 0xFF );
5751
 
 
5752
 
                pApiTdmConf->byRinNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulRinNumTssts & 0xFF );
5753
 
                pApiTdmConf->bySinNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulSinNumTssts & 0xFF );
5754
 
                pApiTdmConf->byRoutNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulRoutNumTssts & 0xFF );
5755
 
                pApiTdmConf->bySoutNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulSoutNumTssts & 0xFF );
5756
 
 
5757
 
                if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) 
5758
 
                {
5759
 
                        if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX )
5760
 
                        {
5761
 
                                pApiTdmConf->usRinStream        = (UINT16)( f_pChannelOpen->TdmConfig.ulRinStream & 0xFFFF );
5762
 
                                pApiTdmConf->usRinTimeslot      = (UINT16)( f_pChannelOpen->TdmConfig.ulRinTimeslot & 0xFFFF );
5763
 
                                pChanEntry->usRinTsstIndex      = f_usNewRinTsstIndex;
5764
 
                        }
5765
 
                        else /* f_ulNewRinTsstIndex != cOCT6100_INVALID_INDEX */
5766
 
                        {
5767
 
                                pApiTdmConf->usRinStream        = cOCT6100_UNASSIGNED;
5768
 
                                pApiTdmConf->usRinTimeslot      = cOCT6100_UNASSIGNED;
5769
 
                                pChanEntry->usRinTsstIndex      = cOCT6100_INVALID_INDEX;
5770
 
                        }
5771
 
                }
5772
 
 
5773
 
                if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) 
5774
 
                {
5775
 
                        if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX )
5776
 
                        {
5777
 
                                pApiTdmConf->usSinStream        = (UINT16)( f_pChannelOpen->TdmConfig.ulSinStream & 0xFFFF );
5778
 
                                pApiTdmConf->usSinTimeslot      = (UINT16)( f_pChannelOpen->TdmConfig.ulSinTimeslot & 0xFFFF );
5779
 
                                pChanEntry->usSinTsstIndex      = f_usNewSinTsstIndex;
5780
 
                        }
5781
 
                        else /* f_ulNewSinTsstIndex != cOCT6100_INVALID_INDEX */
5782
 
                        {
5783
 
                                pApiTdmConf->usSinStream        = cOCT6100_UNASSIGNED;
5784
 
                                pApiTdmConf->usSinTimeslot      = cOCT6100_UNASSIGNED;
5785
 
                                pChanEntry->usSinTsstIndex      = cOCT6100_INVALID_INDEX;
5786
 
                        }
5787
 
                }
5788
 
 
5789
 
                if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) 
5790
 
                {
5791
 
                        if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX )
5792
 
                        {
5793
 
                                pApiTdmConf->usRoutStream       = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutStream & 0xFFFF );
5794
 
                                pApiTdmConf->usRoutTimeslot     = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutTimeslot & 0xFFFF );
5795
 
                                pChanEntry->usRoutTsstIndex     = f_usNewRoutTsstIndex;
5796
 
                        }
5797
 
                        else /* f_ulNewRoutTsstIndex != cOCT6100_INVALID_INDEX */
5798
 
                        {
5799
 
                                pApiTdmConf->usRoutStream       = cOCT6100_UNASSIGNED;
5800
 
                                pApiTdmConf->usRoutTimeslot     = cOCT6100_UNASSIGNED;
5801
 
                                pChanEntry->usRoutTsstIndex     = cOCT6100_INVALID_INDEX;
5802
 
                        }
5803
 
                }
5804
 
 
5805
 
                if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) 
5806
 
                {
5807
 
                        if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX )
5808
 
                        {
5809
 
                                pApiTdmConf->usSoutStream       = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutStream & 0xFFFF );
5810
 
                                pApiTdmConf->usSoutTimeslot     = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutTimeslot & 0xFFFF );
5811
 
                                pChanEntry->usSoutTsstIndex     = f_usNewSoutTsstIndex;
5812
 
                        }
5813
 
                        else /* f_ulNewSoutTsstIndex != cOCT6100_INVALID_INDEX */
5814
 
                        {
5815
 
                                pApiTdmConf->usSoutStream       = cOCT6100_UNASSIGNED;
5816
 
                                pApiTdmConf->usSoutTimeslot     = cOCT6100_UNASSIGNED;
5817
 
                                pChanEntry->usSoutTsstIndex     = cOCT6100_INVALID_INDEX;
5818
 
                        }
5819
 
                }
5820
 
        }
5821
 
        
5822
 
        /*=======================================================================*/
5823
 
        /* Copy the channel's VQE configuration of all the modified fields. */
5824
 
 
5825
 
        if ( f_pChannelModify->fVqeConfigModified == TRUE )
5826
 
        {
5827
 
                pApiVqeConf->fEnableNlp                                                                 = (UINT8)( f_pChannelOpen->VqeConfig.fEnableNlp & 0xFF );
5828
 
                pApiVqeConf->byComfortNoiseMode                                                 = (UINT8)( f_pChannelOpen->VqeConfig.ulComfortNoiseMode & 0xFF );
5829
 
                pApiVqeConf->fSinDcOffsetRemoval                                                = (UINT8)( f_pChannelOpen->VqeConfig.fSinDcOffsetRemoval & 0xFF );
5830
 
                pApiVqeConf->fRinDcOffsetRemoval                                                = (UINT8)( f_pChannelOpen->VqeConfig.fRinDcOffsetRemoval & 0xFF );
5831
 
                pApiVqeConf->fRinLevelControl                                                   = (UINT8)( f_pChannelOpen->VqeConfig.fRinLevelControl & 0xFF );
5832
 
                pApiVqeConf->fSoutLevelControl                                                  = (UINT8)( f_pChannelOpen->VqeConfig.fSoutLevelControl & 0xFF );
5833
 
                pApiVqeConf->fRinAutomaticLevelControl                                  = (UINT8)( f_pChannelOpen->VqeConfig.fRinAutomaticLevelControl & 0xFF );
5834
 
                pApiVqeConf->fSoutAutomaticLevelControl                                 = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAutomaticLevelControl & 0xFF );
5835
 
                pApiVqeConf->usAlcNoiseBleedOutTime                                             = (UINT16)( f_pChannelOpen->VqeConfig.ulAlcNoiseBleedOutTime & 0xFFFF );
5836
 
                pApiVqeConf->fRinHighLevelCompensation                                  = (UINT8)( f_pChannelOpen->VqeConfig.fRinHighLevelCompensation & 0xFF );
5837
 
 
5838
 
                pApiVqeConf->fSoutAdaptiveNoiseReduction                                = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAdaptiveNoiseReduction & 0xFF );
5839
 
                pApiVqeConf->fSoutNoiseBleaching                                                = (UINT8)( f_pChannelOpen->VqeConfig.fSoutNoiseBleaching & 0xFF );
5840
 
                pApiVqeConf->fSoutConferencingNoiseReduction                    = (UINT8)( f_pChannelOpen->VqeConfig.fSoutConferencingNoiseReduction & 0xFF );
5841
 
                pApiVqeConf->chRinLevelControlGainDb                                    = (OCT_INT8)( f_pChannelOpen->VqeConfig.lRinLevelControlGainDb & 0xFF );
5842
 
                pApiVqeConf->chSoutLevelControlGainDb                                   = (OCT_INT8)( f_pChannelOpen->VqeConfig.lSoutLevelControlGainDb & 0xFF );
5843
 
                pApiVqeConf->chRinAutomaticLevelControlTargetDb                 = (OCT_INT8)( f_pChannelOpen->VqeConfig.lRinAutomaticLevelControlTargetDb & 0xFF );
5844
 
                pApiVqeConf->chSoutAutomaticLevelControlTargetDb                = (OCT_INT8)( f_pChannelOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb & 0xFF );
5845
 
                pApiVqeConf->chRinHighLevelCompensationThresholdDb              = (OCT_INT8)( f_pChannelOpen->VqeConfig.lRinHighLevelCompensationThresholdDb & 0xFF );
5846
 
                pApiVqeConf->fEnableTailDisplacement                                    = (UINT8)( f_pChannelOpen->VqeConfig.fEnableTailDisplacement & 0xFF );
5847
 
                pApiVqeConf->usTailDisplacement                                                 = (UINT16)( f_pChannelOpen->VqeConfig.ulTailDisplacement & 0xFFFF );
5848
 
                pApiVqeConf->usTailLength                                                               = (UINT16)( f_pChannelOpen->VqeConfig.ulTailLength & 0xFFFF );
5849
 
                pApiVqeConf->fAcousticEcho                                                              = (UINT8)( f_pChannelOpen->VqeConfig.fAcousticEcho & 0xFF );
5850
 
                pApiVqeConf->fDtmfToneRemoval                                                   = (UINT8)( f_pChannelOpen->VqeConfig.fDtmfToneRemoval & 0xFF );
5851
 
 
5852
 
                pApiVqeConf->chDefaultErlDb                                                             = (OCT_INT8)( f_pChannelOpen->VqeConfig.lDefaultErlDb & 0xFF );
5853
 
                pApiVqeConf->chAecDefaultErlDb                                                  = (OCT_INT8)( f_pChannelOpen->VqeConfig.lAecDefaultErlDb & 0xFF );
5854
 
                pApiVqeConf->usAecTailLength                                                    = (UINT16)( f_pChannelOpen->VqeConfig.ulAecTailLength & 0xFFFF );
5855
 
                pApiVqeConf->chAnrSnrEnhancementDb                                              = (OCT_INT8)( f_pChannelOpen->VqeConfig.lAnrSnrEnhancementDb & 0xFF );
5856
 
                pApiVqeConf->byAnrVoiceNoiseSegregation                                 = (UINT8)( f_pChannelOpen->VqeConfig.ulAnrVoiceNoiseSegregation & 0xFF );
5857
 
                pApiVqeConf->usToneDisablerVqeActivationDelay                   = (UINT16)( f_pChannelOpen->VqeConfig.ulToneDisablerVqeActivationDelay & 0xFFFF );
5858
 
                pApiVqeConf->byNonLinearityBehaviorA                                    = (UINT8)( f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorA & 0xFF );
5859
 
                pApiVqeConf->byNonLinearityBehaviorB                                    = (UINT8)( f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorB & 0xFF );
5860
 
                pApiVqeConf->byDoubleTalkBehavior                                               = (UINT8)( f_pChannelOpen->VqeConfig.ulDoubleTalkBehavior & 0xFF );
5861
 
                pApiVqeConf->bySoutAutomaticListenerEnhancementGainDb   = (UINT8)( f_pChannelOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb & 0xFF );
5862
 
                pApiVqeConf->bySoutNaturalListenerEnhancementGainDb             = (UINT8)( f_pChannelOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb & 0xFF );
5863
 
                pApiVqeConf->fSoutNaturalListenerEnhancement                    = (UINT8)( f_pChannelOpen->VqeConfig.fSoutNaturalListenerEnhancement & 0xFF );
5864
 
                pApiVqeConf->fRoutNoiseReduction                                                = (UINT8)( f_pChannelOpen->VqeConfig.fRoutNoiseReduction & 0xFF );
5865
 
                pApiVqeConf->fEnableMusicProtection                                             = (UINT8)( f_pChannelOpen->VqeConfig.fEnableMusicProtection & 0xFF );
5866
 
                pApiVqeConf->fIdleCodeDetection                                                 = (UINT8)( f_pChannelOpen->VqeConfig.fIdleCodeDetection & 0xFF );
5867
 
                pApiVqeConf->fResetRinAlcOnTones                                                = (UINT8)( f_pChannelOpen->VqeConfig.fResetRinAlcOnTones & 0xFF );
5868
 
                pApiVqeConf->fResetSoutAlcOnTones                                               = (UINT8)( f_pChannelOpen->VqeConfig.fResetSoutAlcOnTones & 0xFF );
5869
 
        }
5870
 
 
5871
 
        /*=======================================================================*/
5872
 
        /* Copy the channel's CODEC configuration of all the modified fields. */
5873
 
        if ( f_pChannelModify->fCodecConfigModified == TRUE )
5874
 
        {
5875
 
                pApiCodecConf->byAdpcmNibblePosition            = (UINT8)( f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition & 0xFF );
5876
 
                pApiCodecConf->byEncoderPort                            = (UINT8)( f_pChannelOpen->CodecConfig.ulEncoderPort & 0xFF );
5877
 
                pApiCodecConf->byEncodingRate                           = (UINT8)( f_pChannelOpen->CodecConfig.ulEncodingRate & 0xFF );
5878
 
                pApiCodecConf->byDecoderPort                            = (UINT8)( f_pChannelOpen->CodecConfig.ulDecoderPort & 0xFF );
5879
 
                pApiCodecConf->byDecodingRate                           = (UINT8)( f_pChannelOpen->CodecConfig.ulDecodingRate & 0xFF );
5880
 
                pApiCodecConf->fEnableSilenceSuppression        = (UINT8)( f_pChannelOpen->CodecConfig.fEnableSilenceSuppression & 0xFF );
5881
 
                pApiCodecConf->byPhase                                          = (UINT8)( f_pChannelOpen->CodecConfig.ulPhase & 0xFF );
5882
 
                pApiCodecConf->byPhasingType                            = (UINT8)( f_pChannelOpen->CodecConfig.ulPhasingType & 0xFF );
5883
 
 
5884
 
                /* Update the API phasing TSST structure */
5885
 
                if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX )
5886
 
                {
5887
 
                        tPOCT6100_API_PHASING_TSST      pPhasingTsst;
5888
 
 
5889
 
                        /* Release the previous phasing TSST if the channel was already bound to one.*/
5890
 
                        if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
5891
 
                        {
5892
 
                                mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, pChanEntry->usPhasingTsstIndex );
5893
 
 
5894
 
                                pPhasingTsst->usDependencyCnt--;
5895
 
                        }
5896
 
                        
5897
 
                        mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, f_usNewPhasingTsstIndex );
5898
 
 
5899
 
                        pPhasingTsst->usDependencyCnt++;
5900
 
                        pChanEntry->usPhasingTsstIndex = f_usNewPhasingTsstIndex;
5901
 
 
5902
 
                }
5903
 
        }
5904
 
 
5905
 
 
5906
 
 
5907
 
        return cOCT6100_ERR_OK;
5908
 
}
5909
 
#endif
5910
 
 
5911
 
 
5912
 
 
5913
 
 
5914
 
 
5915
 
 
5916
 
 
5917
 
 
5918
 
 
5919
 
 
5920
 
 
5921
 
 
5922
 
 
5923
 
 
5924
 
 
5925
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5926
 
 
5927
 
Function:               Oct6100ChannelBroadcastTsstAddSer
5928
 
 
5929
 
Description:    Assign a TSST to one of the port of an echo cancellation channel.
5930
 
 
5931
 
-------------------------------------------------------------------------------
5932
 
|       Argument                |       Description
5933
 
-------------------------------------------------------------------------------
5934
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
5935
 
                                                present state of the chip and all its resources.
5936
 
 
5937
 
f_pChannelTsstAdd               Pointer to TSST assign structure.  
5938
 
 
5939
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5940
 
#if !SKIP_Oct6100ChannelBroadcastTsstAddSer
5941
 
UINT32 Oct6100ChannelBroadcastTsstAddSer(
5942
 
                                IN tPOCT6100_INSTANCE_API                                               f_pApiInstance,
5943
 
                                IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_ADD             f_pChannelTsstAdd )
5944
 
{
5945
 
        UINT16  usChanIndex;
5946
 
        UINT16  usNewTsstIndex;
5947
 
        UINT16  usNewTsstEntry;
5948
 
        UINT32  ulResult;
5949
 
 
5950
 
        ulResult = Oct6100ApiCheckChanTsstAddParams( f_pApiInstance, f_pChannelTsstAdd, &usChanIndex );
5951
 
        if ( ulResult != cOCT6100_ERR_OK  )
5952
 
                return ulResult;
5953
 
 
5954
 
        ulResult = Oct6100ApiReserveTsstAddResources( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, &usNewTsstIndex, &usNewTsstEntry );
5955
 
        if ( ulResult != cOCT6100_ERR_OK  )
5956
 
                return ulResult;
5957
 
 
5958
 
        ulResult = Oct6100ApiWriteTsstAddStructs( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, usNewTsstIndex );
5959
 
        if ( ulResult != cOCT6100_ERR_OK  )
5960
 
                return ulResult;
5961
 
 
5962
 
        ulResult = Oct6100ApiUpdateTsstAddChanEntry( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, usNewTsstIndex, usNewTsstEntry );
5963
 
        if ( ulResult != cOCT6100_ERR_OK  )
5964
 
                return ulResult;
5965
 
 
5966
 
        return cOCT6100_ERR_OK;
5967
 
}
5968
 
#endif
5969
 
 
5970
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5971
 
 
5972
 
Function:               Oct6100ApiCheckChanTsstAddParams
5973
 
 
5974
 
Description:    Verify the validity of the tPOCT6100_CHANNEL_BROADCAST_TSST_ADD
5975
 
                                structure.
5976
 
 
5977
 
-------------------------------------------------------------------------------
5978
 
|       Argument                |       Description
5979
 
-------------------------------------------------------------------------------
5980
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
5981
 
                                                present state of the chip and all its resources.
5982
 
 
5983
 
f_pChannelTsstAdd               Pointer to echo cancellation channel open configuration structure.
5984
 
f_pusChanIndex                  Pointer to a structure used to store the multiple resources indexes.
5985
 
 
5986
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5987
 
#if !SKIP_Oct6100ApiCheckChanTsstAddParams
5988
 
UINT32 Oct6100ApiCheckChanTsstAddParams(
5989
 
                                IN  tPOCT6100_INSTANCE_API                                      f_pApiInstance,
5990
 
                                IN  tPOCT6100_CHANNEL_BROADCAST_TSST_ADD        f_pChannelTsstAdd, 
5991
 
                                OUT PUINT16                                                                     f_pusChanIndex )
5992
 
{
5993
 
        tPOCT6100_API_CHANNEL           pChanEntry;
5994
 
        UINT32  ulResult;
5995
 
        UINT32  ulNumTssts = 1;
5996
 
        UINT32  ulEntryOpenCnt;
5997
 
 
5998
 
        /* Check the provided handle. */
5999
 
        if ( (f_pChannelTsstAdd->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
6000
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6001
 
 
6002
 
        *f_pusChanIndex = (UINT16)( f_pChannelTsstAdd->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
6003
 
        if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
6004
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6005
 
 
6006
 
        /*=======================================================================*/
6007
 
        /* Get a pointer to the channel's list entry. */
6008
 
 
6009
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
6010
 
 
6011
 
        /* Extract the entry open count from the provided handle. */
6012
 
        ulEntryOpenCnt = ( f_pChannelTsstAdd->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
6013
 
 
6014
 
        /* Check for errors. */
6015
 
        if ( pChanEntry->fReserved != TRUE )
6016
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
6017
 
        if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
6018
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6019
 
 
6020
 
        /*=======================================================================*/
6021
 
 
6022
 
        /* validate the port parameter.*/
6023
 
        if ( f_pChannelTsstAdd->ulPort != cOCT6100_CHANNEL_PORT_ROUT &&
6024
 
                 f_pChannelTsstAdd->ulPort != cOCT6100_CHANNEL_PORT_SOUT )
6025
 
                return cOCT6100_ERR_CHANNEL_TSST_ADD_PORT;
6026
 
 
6027
 
        /* Get the required number of TSST based on the port.*/
6028
 
        switch( f_pChannelTsstAdd->ulPort )
6029
 
        {
6030
 
        case cOCT6100_CHANNEL_PORT_ROUT:
6031
 
                ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6032
 
                break;
6033
 
        case cOCT6100_CHANNEL_PORT_SOUT:
6034
 
                ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6035
 
                break;
6036
 
        default:
6037
 
                return cOCT6100_ERR_FATAL_B;
6038
 
        }
6039
 
 
6040
 
        /* Check the validity of the timeslot and stream. */
6041
 
        ulResult = Oct6100ApiValidateTsst( f_pApiInstance, 
6042
 
                                                                           ulNumTssts,
6043
 
                                                                           f_pChannelTsstAdd->ulTimeslot, 
6044
 
                                                                           f_pChannelTsstAdd->ulStream,
6045
 
                                                                           cOCT6100_OUTPUT_TSST );
6046
 
        if ( ulResult != cOCT6100_ERR_OK  )
6047
 
        {
6048
 
                if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
6049
 
                {
6050
 
                        return cOCT6100_ERR_CHANNEL_TSST_ADD_TIMESLOT;
6051
 
                }
6052
 
                else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
6053
 
                {
6054
 
                        return cOCT6100_ERR_CHANNEL_TSST_ADD_STREAM;
6055
 
                }
6056
 
                else
6057
 
                {
6058
 
                        return ulResult;
6059
 
                }
6060
 
        }
6061
 
 
6062
 
        return cOCT6100_ERR_OK;
6063
 
}       
6064
 
#endif
6065
 
 
6066
 
 
6067
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6068
 
 
6069
 
Function:               Oct6100ApiReserveTsstAddResources
6070
 
 
6071
 
Description:    Reserve the entry for the new broadcast TSST.
6072
 
 
6073
 
-------------------------------------------------------------------------------
6074
 
|       Argument                |       Description
6075
 
-------------------------------------------------------------------------------
6076
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
6077
 
                                                present state of the chip and all its resources.
6078
 
 
6079
 
f_pChannelTsstAdd               Pointer to echo cancellation channel open configuration structure.
6080
 
f_usChanIndex                   Channel index within the API's channel list.
6081
 
f_pusNewTsstIndex               Pointer to the new TSST index within the API's TSST memory.
6082
 
f_pusNewTsstEntry               Pointer to the new TSST entry within the API's TSST list.
6083
 
 
6084
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6085
 
#if !SKIP_Oct6100ApiReserveTsstAddResources
6086
 
UINT32 Oct6100ApiReserveTsstAddResources(
6087
 
                                IN  tPOCT6100_INSTANCE_API                                      f_pApiInstance,
6088
 
                                IN  tPOCT6100_CHANNEL_BROADCAST_TSST_ADD        f_pChannelTsstAdd, 
6089
 
                                IN      UINT16                                                                  f_usChanIndex,
6090
 
                                OUT     PUINT16                                                                 f_pusNewTsstIndex,
6091
 
                                OUT     PUINT16                                                                 f_pusNewTsstEntry )
6092
 
{
6093
 
        tPOCT6100_API_CHANNEL           pChanEntry;
6094
 
        UINT32  ulResult;
6095
 
        UINT32  ulNumTssts = 1;
6096
 
 
6097
 
        /*=======================================================================*/
6098
 
        /* Get a pointer to the channel's list entry. */
6099
 
 
6100
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6101
 
 
6102
 
        switch( f_pChannelTsstAdd->ulPort )
6103
 
        {
6104
 
        case cOCT6100_CHANNEL_PORT_ROUT:
6105
 
                ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6106
 
                break;
6107
 
        case cOCT6100_CHANNEL_PORT_SOUT:
6108
 
                ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6109
 
                break;
6110
 
        default:
6111
 
                return cOCT6100_ERR_FATAL_C;
6112
 
        }
6113
 
 
6114
 
        /* Reserve the new entry.*/
6115
 
        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
6116
 
                                                                          f_pChannelTsstAdd->ulTimeslot, 
6117
 
                                                                          f_pChannelTsstAdd->ulStream, 
6118
 
                                                                          ulNumTssts, 
6119
 
                                                                          cOCT6100_OUTPUT_TSST,
6120
 
                                                                          f_pusNewTsstIndex, 
6121
 
                                                                          f_pusNewTsstEntry );
6122
 
        if ( ulResult != cOCT6100_ERR_OK  )
6123
 
                return ulResult;
6124
 
 
6125
 
        return cOCT6100_ERR_OK;
6126
 
}       
6127
 
#endif
6128
 
 
6129
 
 
6130
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6131
 
 
6132
 
Function:               Oct6100ApiWriteTsstAddStructs
6133
 
 
6134
 
Description:    Configure the TSST control memory for the new TSST entry.
6135
 
 
6136
 
-------------------------------------------------------------------------------
6137
 
|       Argument                |       Description
6138
 
-------------------------------------------------------------------------------
6139
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
6140
 
                                                present state of the chip and all its resources.
6141
 
 
6142
 
f_pChannelTsstAdd               Pointer to echo cancellation channel open configuration structure.
6143
 
f_usChanIndex                   Channel index.
6144
 
f_usNewTsstIndex                Tsst index in the TSST control memory.
6145
 
 
6146
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6147
 
#if !SKIP_Oct6100ApiWriteTsstAddStructs
6148
 
UINT32 Oct6100ApiWriteTsstAddStructs(
6149
 
                                IN  tPOCT6100_INSTANCE_API                                      f_pApiInstance,
6150
 
                                IN  tPOCT6100_CHANNEL_BROADCAST_TSST_ADD        f_pChannelTsstAdd, 
6151
 
                                IN      UINT16                                                                  f_usChanIndex,
6152
 
                                IN      UINT16                                                                  f_usNewTsstIndex )
6153
 
{
6154
 
        tPOCT6100_API_CHANNEL           pChanEntry;
6155
 
        tOCT6100_WRITE_PARAMS           WriteParams;
6156
 
        UINT32  ulResult = cOCT6100_ERR_OK;
6157
 
        UINT16  usTsiMemIndex;
6158
 
        UINT32  ulNumTssts = 1;
6159
 
 
6160
 
        
6161
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6162
 
 
6163
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6164
 
 
6165
 
        /*=======================================================================*/
6166
 
        /* Get a pointer to the channel's list entry. */
6167
 
 
6168
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6169
 
 
6170
 
        switch( f_pChannelTsstAdd->ulPort )
6171
 
        {
6172
 
        case cOCT6100_CHANNEL_PORT_ROUT:
6173
 
                usTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
6174
 
                ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6175
 
                break;
6176
 
        case cOCT6100_CHANNEL_PORT_SOUT:
6177
 
                usTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
6178
 
                ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6179
 
                break;
6180
 
        default:
6181
 
                return cOCT6100_ERR_FATAL_D;
6182
 
        }
6183
 
 
6184
 
 
6185
 
        /* Write the new entry now.*/
6186
 
        WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usNewTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6187
 
        
6188
 
        WriteParams.usWriteData  = cOCT6100_TSST_CONTROL_MEM_OUTPUT_TSST;
6189
 
        WriteParams.usWriteData |= (UINT16)( pChanEntry->CodecConfig.byAdpcmNibblePosition << cOCT6100_TSST_CONTROL_MEM_NIBBLE_POS_OFFSET );
6190
 
        WriteParams.usWriteData |= (UINT16)( (ulNumTssts - 1) << cOCT6100_TSST_CONTROL_MEM_TSST_NUM_OFFSET );
6191
 
        WriteParams.usWriteData |= (UINT16)( usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK );
6192
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6193
 
        if ( ulResult != cOCT6100_ERR_OK  )
6194
 
                return ulResult;
6195
 
 
6196
 
        return cOCT6100_ERR_OK;
6197
 
}       
6198
 
#endif
6199
 
 
6200
 
 
6201
 
 
6202
 
 
6203
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6204
 
 
6205
 
Function:               Oct6100ApiUpdateTsstAddChanEntry
6206
 
 
6207
 
Description:    Update the associated channel API entry to add the new broacast TSST.
6208
 
 
6209
 
-------------------------------------------------------------------------------
6210
 
|       Argument                |       Description
6211
 
-------------------------------------------------------------------------------
6212
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
6213
 
                                                present state of the chip and all its resources.
6214
 
 
6215
 
f_pChannelTsstAdd               Pointer to echo cancellation channel open configuration structure.
6216
 
f_usChanIndex                   Channel index.
6217
 
f_usNewTsstIndex                TSST index within the TSST control memory.
6218
 
f_usNewTsstEntry                TSST entry within the API TSST list.
6219
 
 
6220
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6221
 
#if !SKIP_Oct6100ApiUpdateTsstAddChanEntry
6222
 
UINT32 Oct6100ApiUpdateTsstAddChanEntry(
6223
 
                                IN  tPOCT6100_INSTANCE_API                                      f_pApiInstance,
6224
 
                                IN  tPOCT6100_CHANNEL_BROADCAST_TSST_ADD        f_pChannelTsstAdd, 
6225
 
                                IN      UINT16                                                                  f_usChanIndex,
6226
 
                                IN      UINT16                                                                  f_usNewTsstIndex,
6227
 
                                IN      UINT16                                                                  f_usNewTsstEntry )
6228
 
{
6229
 
        tPOCT6100_API_CHANNEL           pChanEntry;
6230
 
        tPOCT6100_API_TSST_ENTRY        pTsstEntry;
6231
 
 
6232
 
        /*=======================================================================*/
6233
 
        /* Get a pointer to the channel's list entry. */
6234
 
 
6235
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6236
 
        mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, f_usNewTsstEntry );
6237
 
 
6238
 
        /* Update the channel entry.*/
6239
 
        if ( f_pChannelTsstAdd->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6240
 
        {
6241
 
                /* Add the new TSST entry to the broadcast list.*/
6242
 
                pTsstEntry->usNextEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6243
 
                pTsstEntry->usTsstMemoryIndex = (UINT16)f_usNewTsstIndex;
6244
 
                pTsstEntry->usTsstValue = (UINT16)( (f_pChannelTsstAdd->ulTimeslot << 5) | f_pChannelTsstAdd->ulStream );
6245
 
 
6246
 
                /* Modify the first entry pointer.*/
6247
 
                pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = f_usNewTsstEntry;
6248
 
 
6249
 
                /* Increment the number of broadcast TSST. */
6250
 
                pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry++;
6251
 
                
6252
 
        }
6253
 
        else /* f_pChannelTsstAdd->ulPort == cOCT6100_CHANNEL_PORT_SOUT  */
6254
 
        {
6255
 
                /* Add the new TSST entry to the broadcast list.*/
6256
 
                pTsstEntry->usNextEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6257
 
                pTsstEntry->usTsstMemoryIndex = (UINT16)f_usNewTsstIndex;
6258
 
                pTsstEntry->usTsstValue = (UINT16)( (f_pChannelTsstAdd->ulTimeslot << 5) | f_pChannelTsstAdd->ulStream );
6259
 
 
6260
 
                /* Modify the first entry pointer.*/
6261
 
                pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = f_usNewTsstEntry;
6262
 
 
6263
 
                /* Increment the number of broadcast TSST. */
6264
 
                pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry++;
6265
 
        }
6266
 
 
6267
 
        return cOCT6100_ERR_OK;
6268
 
}       
6269
 
#endif
6270
 
 
6271
 
 
6272
 
 
6273
 
 
6274
 
 
6275
 
 
6276
 
 
6277
 
 
6278
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6279
 
 
6280
 
Function:               Oct6100ChannelBroadcastTsstRemoveSer
6281
 
 
6282
 
Description:    Removes a broadcast TSST from one of the output port of an 
6283
 
                                echo cancellation channel.
6284
 
 
6285
 
-------------------------------------------------------------------------------
6286
 
|       Argument                |       Description
6287
 
-------------------------------------------------------------------------------
6288
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
6289
 
                                                present state of the chip and all its resources.
6290
 
 
6291
 
f_pChannelTsstRemove    Pointer to TSST remove structure.  
6292
 
 
6293
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6294
 
#if !SKIP_Oct6100ChannelBroadcastTsstRemoveSer
6295
 
UINT32 Oct6100ChannelBroadcastTsstRemoveSer(
6296
 
                                IN tPOCT6100_INSTANCE_API                                               f_pApiInstance,
6297
 
                                IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE  f_pChannelTsstRemove)
6298
 
{
6299
 
        UINT16  usChanIndex;
6300
 
        UINT16  usTsstIndex;
6301
 
        UINT16  usTsstEntry;
6302
 
        UINT16  usPrevTsstEntry;
6303
 
        UINT32  ulResult;
6304
 
 
6305
 
        ulResult = Oct6100ApiAssertChanTsstRemoveParams( f_pApiInstance, f_pChannelTsstRemove, &usChanIndex, &usTsstIndex, &usTsstEntry, &usPrevTsstEntry );
6306
 
        if ( ulResult != cOCT6100_ERR_OK  )
6307
 
                return ulResult;
6308
 
 
6309
 
        ulResult = Oct6100ApiInvalidateTsstRemoveStructs( f_pApiInstance, usChanIndex, usTsstIndex, f_pChannelTsstRemove->ulPort, f_pChannelTsstRemove->fRemoveAll );
6310
 
        if ( ulResult != cOCT6100_ERR_OK  )
6311
 
                return ulResult;
6312
 
 
6313
 
        ulResult = Oct6100ApiReleaseTsstRemoveResources( f_pApiInstance, f_pChannelTsstRemove, usChanIndex, usTsstIndex, usTsstEntry, usPrevTsstEntry );
6314
 
        if ( ulResult != cOCT6100_ERR_OK  )
6315
 
                return ulResult;
6316
 
 
6317
 
        return cOCT6100_ERR_OK;
6318
 
}
6319
 
#endif
6320
 
 
6321
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6322
 
 
6323
 
Function:               Oct6100ApiAssertChanTsstRemoveParams
6324
 
 
6325
 
Description:    Verify the validity of the tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE
6326
 
                                structure.
6327
 
 
6328
 
-------------------------------------------------------------------------------
6329
 
|       Argument                |       Description
6330
 
-------------------------------------------------------------------------------
6331
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
6332
 
                                                present state of the chip and all its resources.
6333
 
 
6334
 
f_pChannelTsstRemove    Pointer to echo cancellation channel open configuration structure.
6335
 
f_pulChanIndex                  Pointer to a channel index.
6336
 
f_pulNewTsstIndex               Pointer to a TSST index within the TSST control memory.
6337
 
f_pulNewTsstEntry               Pointer to a TSST entry within the API TSST list.
6338
 
f_pulPrevTsstEntry              Pointer to the previous TSST entry.
6339
 
 
6340
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6341
 
#if !SKIP_Oct6100ApiAssertChanTsstRemoveParams
6342
 
UINT32 Oct6100ApiAssertChanTsstRemoveParams(
6343
 
                                IN  tPOCT6100_INSTANCE_API                                      f_pApiInstance,
6344
 
                                IN  tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE     f_pChannelTsstRemove, 
6345
 
                                OUT PUINT16                                                                     f_pusChanIndex,
6346
 
                                OUT     PUINT16                                                                 f_pusTsstIndex,
6347
 
                                OUT     PUINT16                                                                 f_pusTsstEntry,
6348
 
                                OUT     PUINT16                                                                 f_pusPrevTsstEntry )
6349
 
{
6350
 
        tPOCT6100_API_CHANNEL           pChanEntry;
6351
 
        tPOCT6100_API_TSST_ENTRY        pTsstEntry;
6352
 
        UINT32  ulResult;
6353
 
        UINT32  ulNumTssts = 1;
6354
 
        UINT32  ulEntryOpenCnt;
6355
 
        UINT16  usCurrentEntry;
6356
 
        UINT16  usTsstValue;
6357
 
        UINT16  usNumEntry;
6358
 
        
6359
 
        /* Check the provided handle. */
6360
 
        if ( (f_pChannelTsstRemove->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
6361
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6362
 
 
6363
 
        *f_pusChanIndex = (UINT16)( f_pChannelTsstRemove->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
6364
 
        if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
6365
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6366
 
 
6367
 
        /*=======================================================================*/
6368
 
        /* Get a pointer to the channel's list entry. */
6369
 
 
6370
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
6371
 
 
6372
 
        /* Extract the entry open count from the provided handle. */
6373
 
        ulEntryOpenCnt = ( f_pChannelTsstRemove->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
6374
 
 
6375
 
        /* Check for errors. */
6376
 
        if ( pChanEntry->fReserved != TRUE )
6377
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
6378
 
        if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
6379
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6380
 
 
6381
 
        /*=======================================================================*/
6382
 
 
6383
 
        /* validate the port parameter.*/
6384
 
        if ( f_pChannelTsstRemove->ulPort != cOCT6100_CHANNEL_PORT_ROUT &&
6385
 
                 f_pChannelTsstRemove->ulPort != cOCT6100_CHANNEL_PORT_SOUT )
6386
 
                return cOCT6100_ERR_CHANNEL_TSST_REMOVE_PORT;
6387
 
 
6388
 
        /* Verify that the requested entry is present in the channel's port broadcast TSST.*/
6389
 
        if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6390
 
        {
6391
 
                usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6392
 
                usNumEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry;
6393
 
        }
6394
 
        else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
6395
 
        {
6396
 
                usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6397
 
                usNumEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry;
6398
 
        }
6399
 
 
6400
 
        /* Verify if at least one TSST is present on the channel port.*/
6401
 
        if ( usNumEntry == 0 )
6402
 
                return cOCT6100_ERR_CHANNEL_TSST_REMOVE_NO_BROADCAST_TSST;
6403
 
 
6404
 
        /* Get the required number of TSST based on the port.*/
6405
 
        switch( f_pChannelTsstRemove->ulPort )
6406
 
        {
6407
 
        case cOCT6100_CHANNEL_PORT_ROUT:
6408
 
                ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6409
 
                break;
6410
 
        case cOCT6100_CHANNEL_PORT_SOUT:
6411
 
                ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6412
 
                break;
6413
 
        default:
6414
 
                return cOCT6100_ERR_FATAL_E;
6415
 
        }
6416
 
 
6417
 
        /* Initialize the TSST entry to invalid.*/
6418
 
        *f_pusTsstEntry         = cOCT6100_INVALID_INDEX;
6419
 
        *f_pusPrevTsstEntry     = cOCT6100_INVALID_INDEX;
6420
 
        *f_pusTsstIndex         = cOCT6100_INVALID_INDEX;
6421
 
 
6422
 
        if ( f_pChannelTsstRemove->fRemoveAll != TRUE )
6423
 
        {
6424
 
                /* Check the validity of the timeslot and Stream.*/
6425
 
                ulResult = Oct6100ApiValidateTsst( f_pApiInstance, 
6426
 
                                                                                   ulNumTssts,
6427
 
                                                                                   f_pChannelTsstRemove->ulTimeslot, 
6428
 
                                                                                   f_pChannelTsstRemove->ulStream,
6429
 
                                                                                   cOCT6100_OUTPUT_TSST );
6430
 
                if ( ulResult != cOCT6100_ERR_OK  )
6431
 
                {
6432
 
                        if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
6433
 
                        {
6434
 
                                return cOCT6100_ERR_CHANNEL_TSST_REMOVE_TIMESLOT;
6435
 
                        }
6436
 
                        else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
6437
 
                        {
6438
 
                                return cOCT6100_ERR_CHANNEL_TSST_REMOVE_STREAM;
6439
 
                        }
6440
 
                        else
6441
 
                        {
6442
 
                                return ulResult;
6443
 
                        }
6444
 
                }
6445
 
        
6446
 
                /* Set the TSST value based on the timeslot and stream value.*/
6447
 
                usTsstValue = (UINT16)( (f_pChannelTsstRemove->ulTimeslot << 5) | f_pChannelTsstRemove->ulStream );
6448
 
 
6449
 
                while( usCurrentEntry != cOCT6100_INVALID_INDEX )
6450
 
                {
6451
 
                        mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6452
 
 
6453
 
                        if ( usTsstValue == pTsstEntry->usTsstValue )
6454
 
                        {
6455
 
                                /* A match was found.*/
6456
 
                                *f_pusTsstEntry = usCurrentEntry;
6457
 
                                *f_pusTsstIndex = pTsstEntry->usTsstMemoryIndex;
6458
 
                                break;
6459
 
                        }
6460
 
 
6461
 
                        /* Move on to the next entry.*/
6462
 
                        *f_pusPrevTsstEntry = usCurrentEntry;
6463
 
                        usCurrentEntry = pTsstEntry->usNextEntry;
6464
 
                }
6465
 
 
6466
 
                if ( *f_pusTsstEntry == cOCT6100_INVALID_INDEX )
6467
 
                        return cOCT6100_ERR_CHANNEL_TSST_REMOVE_INVALID_TSST;
6468
 
        }
6469
 
        
6470
 
        return cOCT6100_ERR_OK;
6471
 
}       
6472
 
#endif
6473
 
 
6474
 
 
6475
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6476
 
 
6477
 
Function:               Oct6100ApiInvalidateTsstRemoveStructs
6478
 
 
6479
 
Description:    Invalidate the entry of the broadcast TSST.
6480
 
 
6481
 
-------------------------------------------------------------------------------
6482
 
|       Argument                |       Description
6483
 
-------------------------------------------------------------------------------
6484
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
6485
 
                                                present state of the chip and all its resources.
6486
 
 
6487
 
f_usChanIndex                   Channel index.
6488
 
f_usTsstIndex                   TSST index within the TSST control memory.
6489
 
f_ulPort                                Channel port where the TSST are removed from. (only used if remove all == TRUE)
6490
 
f_fRemoveAll                    Remove all flag.
6491
 
 
6492
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6493
 
#if !SKIP_Oct6100ApiInvalidateTsstRemoveStructs
6494
 
UINT32 Oct6100ApiInvalidateTsstRemoveStructs(
6495
 
                                IN  tPOCT6100_INSTANCE_API                                      f_pApiInstance,
6496
 
                                IN      UINT16                                                                  f_usChanIndex,
6497
 
                                IN      UINT16                                                                  f_usTsstIndex,
6498
 
                                IN      UINT32                                                                  f_ulPort,
6499
 
                                IN      BOOL                                                                    f_fRemoveAll )
6500
 
{
6501
 
        tOCT6100_WRITE_PARAMS           WriteParams;
6502
 
        UINT32  ulResult;
6503
 
 
6504
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6505
 
 
6506
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6507
 
 
6508
 
        if ( f_fRemoveAll == FALSE )
6509
 
        {
6510
 
                /* Deactivate the entry now.*/
6511
 
                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6512
 
                WriteParams.usWriteData  = 0x0000;
6513
 
 
6514
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6515
 
                if ( ulResult != cOCT6100_ERR_OK  )
6516
 
                        return ulResult;
6517
 
        }
6518
 
        else /* f_fRemoveAll == TRUE */
6519
 
        {
6520
 
                tPOCT6100_API_CHANNEL           pChanEntry;
6521
 
                tPOCT6100_API_TSST_ENTRY        pTsstEntry;
6522
 
                UINT16                                          usTsstEntry;
6523
 
 
6524
 
                /*=======================================================================*/
6525
 
                /* Get a pointer to the channel's list entry. */
6526
 
 
6527
 
                mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6528
 
 
6529
 
                /* Clear all entry associated to the selected port.*/
6530
 
                if ( f_ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6531
 
                        usTsstEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6532
 
                else
6533
 
                        usTsstEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6534
 
 
6535
 
                do
6536
 
                {
6537
 
                        mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usTsstEntry );
6538
 
 
6539
 
                        /* Deactivate the entry now.*/
6540
 
                        WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( ( pTsstEntry->usTsstMemoryIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6541
 
                        WriteParams.usWriteData  = 0x0000;
6542
 
 
6543
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6544
 
                        if ( ulResult != cOCT6100_ERR_OK  )
6545
 
                                return ulResult;
6546
 
 
6547
 
                        usTsstEntry = pTsstEntry->usNextEntry;
6548
 
                
6549
 
                } while ( usTsstEntry != cOCT6100_INVALID_INDEX );
6550
 
        }
6551
 
 
6552
 
        return cOCT6100_ERR_OK;
6553
 
}       
6554
 
#endif
6555
 
 
6556
 
 
6557
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6558
 
 
6559
 
Function:               Oct6100ApiReleaseTsstRemoveResources
6560
 
 
6561
 
Description:    Release all API resources associated to the Removed TSST and 
6562
 
                                update the channel entry accordingly.
6563
 
 
6564
 
-------------------------------------------------------------------------------
6565
 
|       Argument                |       Description
6566
 
-------------------------------------------------------------------------------
6567
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
6568
 
                                                present state of the chip and all its resources.
6569
 
 
6570
 
f_pChannelTsstRemove    Pointer to echo cancellation channel open configuration structure.
6571
 
f_usChanIndex                   Channel index.
6572
 
f_usTsstIndex                   TSST index within the TSST control memory.
6573
 
f_usTsstEntry                   TSST entry within the API's TSST list.
6574
 
f_usPrevTsstEntry               Previous TSST entry within the API's TSST list.
6575
 
 
6576
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6577
 
#if !SKIP_Oct6100ApiReleaseTsstRemoveResources
6578
 
UINT32 Oct6100ApiReleaseTsstRemoveResources(
6579
 
                                IN  tPOCT6100_INSTANCE_API                                      f_pApiInstance,
6580
 
                                IN  tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE     f_pChannelTsstRemove, 
6581
 
                                IN      UINT16                                                                  f_usChanIndex,
6582
 
                                IN      UINT16                                                                  f_usTsstIndex,
6583
 
                                IN      UINT16                                                                  f_usTsstEntry,
6584
 
                                IN      UINT16                                                                  f_usPrevTsstEntry )
6585
 
{
6586
 
        tPOCT6100_API_CHANNEL           pChanEntry;
6587
 
        tPOCT6100_API_TSST_ENTRY        pTsstEntry;
6588
 
        tPOCT6100_API_TSST_ENTRY        pPrevTsstEntry;
6589
 
        UINT16  usCurrentEntry;
6590
 
        UINT32  ulResult;
6591
 
        UINT32  ulTimeslot;
6592
 
        UINT32  ulStream;
6593
 
        /*=======================================================================*/
6594
 
        /* Get a pointer to the channel's list entry. */
6595
 
 
6596
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6597
 
 
6598
 
        if ( f_pChannelTsstRemove->fRemoveAll == FALSE )
6599
 
        {
6600
 
                mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, f_usTsstEntry );
6601
 
 
6602
 
                /* Update the channel entry.*/
6603
 
                if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6604
 
                {
6605
 
                        /* Check if the entry was the first in the list.*/
6606
 
                        if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX )
6607
 
                        {
6608
 
                                pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry;
6609
 
                        }
6610
 
                        else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */
6611
 
                        {
6612
 
                                /* Get a pointer to the previous entry.*/
6613
 
                                mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPrevTsstEntry, f_usPrevTsstEntry );
6614
 
                                pPrevTsstEntry->usNextEntry = pTsstEntry->usNextEntry;
6615
 
                        }
6616
 
 
6617
 
                        /* Decrement the number of entry.*/
6618
 
                        pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry--;
6619
 
                }
6620
 
                else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
6621
 
                {
6622
 
                        /* Check if the entry was the first in the list.*/
6623
 
                        if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX )
6624
 
                        {
6625
 
                                pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry;
6626
 
                        }
6627
 
                        else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */
6628
 
                        {
6629
 
                                /* Get a pointer to the previous entry.*/
6630
 
                                mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPrevTsstEntry, f_usPrevTsstEntry );
6631
 
                                pPrevTsstEntry->usNextEntry = pTsstEntry->usNextEntry;
6632
 
                        }
6633
 
 
6634
 
                        /* Decrement the number of entry.*/
6635
 
                        pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry--;
6636
 
                }
6637
 
 
6638
 
                ulTimeslot = pTsstEntry->usTsstValue >> 5;
6639
 
                ulStream = pTsstEntry->usTsstValue & 0x1F;
6640
 
 
6641
 
                /* Release the  entry.*/
6642
 
                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
6643
 
                                                                                  ulTimeslot,
6644
 
                                                                                  ulStream,
6645
 
                                                                              cOCT6100_NUMBER_TSSTS_1,
6646
 
                                                                                  cOCT6100_OUTPUT_TSST,
6647
 
                                                                                  f_usTsstEntry );
6648
 
                if ( ulResult != cOCT6100_ERR_OK  )
6649
 
                        return ulResult;
6650
 
        }
6651
 
        else /* f_pChannelTsstRemove->fRemoveAll == TRUE */
6652
 
        {
6653
 
 
6654
 
                /* Update the channel entry.*/
6655
 
                if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6656
 
                        usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6657
 
                else
6658
 
                        usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6659
 
 
6660
 
                do
6661
 
                {
6662
 
                        mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6663
 
 
6664
 
                        ulTimeslot = pTsstEntry->usTsstValue >> 5;
6665
 
                        ulStream = pTsstEntry->usTsstValue & 0x1F;
6666
 
 
6667
 
                        /* Release the  entry.*/
6668
 
                        ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
6669
 
                                                                                          ulTimeslot,
6670
 
                                                                                          ulStream,
6671
 
                                                                                          cOCT6100_NUMBER_TSSTS_1,
6672
 
                                                                                          cOCT6100_OUTPUT_TSST,
6673
 
                                                                                          usCurrentEntry );                     /* Release the  entry.*/
6674
 
                        if ( ulResult != cOCT6100_ERR_OK  )
6675
 
                                return ulResult;
6676
 
 
6677
 
                        usCurrentEntry = pTsstEntry->usNextEntry;
6678
 
 
6679
 
                        /* Clear the previous node.*/
6680
 
                        pTsstEntry->usTsstMemoryIndex = 0xFFFF;
6681
 
                        pTsstEntry->usTsstValue = 0xFFFF;
6682
 
                        pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
6683
 
 
6684
 
                } while ( usCurrentEntry != cOCT6100_INVALID_INDEX );
6685
 
                
6686
 
                /* Reset the channel status.*/
6687
 
                if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6688
 
                {
6689
 
                        pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
6690
 
                        pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0;
6691
 
                }
6692
 
                else
6693
 
                {
6694
 
                        pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
6695
 
                        pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry = 0;
6696
 
                }
6697
 
        }
6698
 
        return cOCT6100_ERR_OK;
6699
 
}       
6700
 
#endif
6701
 
 
6702
 
 
6703
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6704
 
 
6705
 
Function:               Oct6100ApiChannelGetStatsSer
6706
 
 
6707
 
Description:    Serialized function that returns all the stats of the specified
6708
 
                                channel.
6709
 
 
6710
 
-------------------------------------------------------------------------------
6711
 
|       Argument                |       Description
6712
 
-------------------------------------------------------------------------------
6713
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
6714
 
                                                present state of the chip and all its resources.
6715
 
 
6716
 
f_pChannelStats                 Pointer to a channel stats structure.
6717
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6718
 
#if !SKIP_Oct6100ApiChannelGetStatsSer
6719
 
UINT32 Oct6100ApiChannelGetStatsSer(
6720
 
                                IN  tPOCT6100_INSTANCE_API                                      f_pApiInstance,
6721
 
                                IN  tPOCT6100_CHANNEL_STATS                                     f_pChannelStats )
6722
 
{
6723
 
        tOCT6100_READ_PARAMS            ReadParams;
6724
 
        tOCT6100_READ_BURST_PARAMS      BurstParams;
6725
 
        tPOCT6100_API_CHANNEL           pChanEntry;
6726
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
6727
 
        tPOCT6100_API_TSST_ENTRY        pTsstEntry;
6728
 
        UINT32  ulEntryOpenCnt;
6729
 
        UINT16  usCurrentEntry;
6730
 
        UINT16  usTsstCount;
6731
 
        UINT32  ulBaseAddress;
6732
 
        UINT32  ulFeatureBytesOffset;
6733
 
        UINT32  ulFeatureBitOffset;
6734
 
        UINT32  ulFeatureFieldLength;
6735
 
        UINT32  ulTempData;
6736
 
        UINT32  ulMask;
6737
 
        UINT16  usChanIndex;
6738
 
        UINT16  ausReadData[ 32 ];
6739
 
 
6740
 
        BYTE    byRinEnergyRaw;
6741
 
        BYTE    bySinEnergyRaw;
6742
 
        BYTE    bySoutEnergyRaw;
6743
 
        INT32   lSoutEnergyIndB;
6744
 
        BYTE    byCnEnergyRaw;
6745
 
        UINT16  usEchoDelayInFrames;
6746
 
        UINT16  usErlRaw;
6747
 
 
6748
 
        UINT32  ulResult;
6749
 
        UINT16  usReadData;
6750
 
 
6751
 
        /* Get local pointer to shared portion of instance. */
6752
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
6753
 
 
6754
 
        BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
6755
 
 
6756
 
        BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6757
 
        BurstParams.pusReadData = ausReadData;
6758
 
                
6759
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
6760
 
 
6761
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6762
 
        ReadParams.pusReadData = &usReadData;
6763
 
 
6764
 
        /* Check the reset stats flag.*/
6765
 
        if ( f_pChannelStats->fResetStats != TRUE && f_pChannelStats->fResetStats != FALSE )
6766
 
                return cOCT6100_ERR_CHANNEL_STATS_RESET;
6767
 
 
6768
 
        /* Check the provided handle. */
6769
 
        if ( cOCT6100_HNDL_TAG_CHANNEL != (f_pChannelStats->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) )
6770
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6771
 
 
6772
 
        usChanIndex = (UINT16)( f_pChannelStats->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
6773
 
        if ( usChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
6774
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6775
 
 
6776
 
        /*=======================================================================*/
6777
 
        /* Get a pointer to the channel's list entry. */
6778
 
 
6779
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, usChanIndex )
6780
 
 
6781
 
        /* Extract the entry open count from the provided handle. */
6782
 
        ulEntryOpenCnt = ( f_pChannelStats->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
6783
 
 
6784
 
        /* Check for errors. */
6785
 
        if ( pChanEntry->fReserved != TRUE )
6786
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
6787
 
        if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
6788
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6789
 
 
6790
 
        /*=======================================================================*/
6791
 
        
6792
 
        /* Check the value of the max broadcast tsst.*/
6793
 
        if ( f_pChannelStats->TdmConfig.ulMaxBroadcastTssts > cOCT6100_MAX_TSSTS )
6794
 
                return cOCT6100_ERR_CHANNEL_GET_STATS_MAX_BROADCAST_TSST;
6795
 
 
6796
 
        if ( f_pChannelStats->TdmConfig.ulMaxBroadcastTssts != 0 )
6797
 
        {
6798
 
                /* Check if memory was allocated by the user for the stream and timeslot values.*/
6799
 
                if ( f_pChannelStats->TdmConfig.pulRoutBroadcastTimeslot == NULL )
6800
 
                        return cOCT6100_ERR_CHANNEL_ROUT_BROADCAST_TIMESLOT;
6801
 
 
6802
 
                if ( f_pChannelStats->TdmConfig.pulRoutBroadcastStream == NULL )
6803
 
                        return cOCT6100_ERR_CHANNEL_ROUT_BROADCAST_STREAM;
6804
 
 
6805
 
                if ( f_pChannelStats->TdmConfig.pulSoutBroadcastTimeslot == NULL )
6806
 
                        return cOCT6100_ERR_CHANNEL_SOUT_BROADCAST_TIMESLOT;
6807
 
 
6808
 
                if ( f_pChannelStats->TdmConfig.pulSoutBroadcastStream == NULL )
6809
 
                        return cOCT6100_ERR_CHANNEL_SOUT_BROADCAST_STREAM;
6810
 
        }
6811
 
 
6812
 
        /* Copy the general configuration.*/
6813
 
        f_pChannelStats->ulUserChanId = pChanEntry->ulUserChanId;
6814
 
        f_pChannelStats->ulEchoOperationMode = pChanEntry->byEchoOperationMode;
6815
 
        f_pChannelStats->fEnableToneDisabler = pChanEntry->fEnableToneDisabler;
6816
 
        f_pChannelStats->ulMutePortsMask = pChanEntry->usMutedPorts;
6817
 
        f_pChannelStats->fEnableExtToneDetection = pChanEntry->fEnableExtToneDetection;
6818
 
 
6819
 
 
6820
 
        
6821
 
        /* Copy the TDM configuration.*/
6822
 
        f_pChannelStats->TdmConfig.ulNumRoutBroadcastTssts = pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry;
6823
 
        f_pChannelStats->TdmConfig.ulNumSoutBroadcastTssts = pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry;
6824
 
 
6825
 
        f_pChannelStats->TdmConfig.ulSinNumTssts = pChanEntry->TdmConfig.bySinNumTssts;
6826
 
        f_pChannelStats->TdmConfig.ulSinTimeslot = pChanEntry->TdmConfig.usSinTimeslot;
6827
 
        f_pChannelStats->TdmConfig.ulSinStream = pChanEntry->TdmConfig.usSinStream;
6828
 
        f_pChannelStats->TdmConfig.ulSinPcmLaw = pChanEntry->TdmConfig.bySinPcmLaw;
6829
 
 
6830
 
        f_pChannelStats->TdmConfig.ulSoutNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6831
 
        f_pChannelStats->TdmConfig.ulSoutTimeslot = pChanEntry->TdmConfig.usSoutTimeslot;
6832
 
        f_pChannelStats->TdmConfig.ulSoutStream = pChanEntry->TdmConfig.usSoutStream;
6833
 
        f_pChannelStats->TdmConfig.ulSoutPcmLaw = pChanEntry->TdmConfig.bySoutPcmLaw;
6834
 
 
6835
 
        /* Copy the SOUT Broadcast TSST into the Stream and timeslot array.*/
6836
 
        usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6837
 
        for( usTsstCount = 0; (usTsstCount < pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry) && (usTsstCount < f_pChannelStats->TdmConfig.ulMaxBroadcastTssts); usTsstCount++ )
6838
 
        {
6839
 
                if ( usCurrentEntry == cOCT6100_INVALID_INDEX )
6840
 
                        return cOCT6100_ERR_FATAL_F;
6841
 
 
6842
 
                mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6843
 
 
6844
 
                f_pChannelStats->TdmConfig.pulSoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue & 0x1F;
6845
 
                f_pChannelStats->TdmConfig.pulSoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue >> 5;
6846
 
 
6847
 
                /* Obtain the index of the next entry.*/
6848
 
                usCurrentEntry = pTsstEntry->usNextEntry;
6849
 
        }
6850
 
 
6851
 
        /* Check if all Sout Broadcast TSST were returned.*/
6852
 
        if ( usTsstCount < pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry )
6853
 
        {
6854
 
                f_pChannelStats->TdmConfig.fMoreSoutBroadcastTssts = TRUE;
6855
 
        }
6856
 
        else /* usTsstCount >= pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry */
6857
 
        {
6858
 
                f_pChannelStats->TdmConfig.fMoreSoutBroadcastTssts = FALSE;
6859
 
        }
6860
 
                
6861
 
        f_pChannelStats->TdmConfig.ulRinNumTssts = pChanEntry->TdmConfig.byRinNumTssts;
6862
 
        f_pChannelStats->TdmConfig.ulRinTimeslot = pChanEntry->TdmConfig.usRinTimeslot;
6863
 
        f_pChannelStats->TdmConfig.ulRinStream = pChanEntry->TdmConfig.usRinStream;
6864
 
        f_pChannelStats->TdmConfig.ulRinPcmLaw = pChanEntry->TdmConfig.byRinPcmLaw;
6865
 
 
6866
 
        f_pChannelStats->TdmConfig.ulRoutNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6867
 
        f_pChannelStats->TdmConfig.ulRoutTimeslot = pChanEntry->TdmConfig.usRoutTimeslot;
6868
 
        f_pChannelStats->TdmConfig.ulRoutStream = pChanEntry->TdmConfig.usRoutStream;
6869
 
        f_pChannelStats->TdmConfig.ulRoutPcmLaw = pChanEntry->TdmConfig.byRoutPcmLaw;
6870
 
 
6871
 
 
6872
 
        /* Copy the ROUT Broadcast TSST into the Stream and timeslot array.*/
6873
 
        usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6874
 
        for( usTsstCount = 0; (usTsstCount < pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry) && (usTsstCount < f_pChannelStats->TdmConfig.ulMaxBroadcastTssts); usTsstCount++ )
6875
 
        {
6876
 
                if ( usCurrentEntry == cOCT6100_INVALID_INDEX )
6877
 
                        return cOCT6100_ERR_FATAL_10;
6878
 
 
6879
 
                mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6880
 
 
6881
 
                f_pChannelStats->TdmConfig.pulRoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue & 0x1F;
6882
 
                f_pChannelStats->TdmConfig.pulRoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue >> 5;
6883
 
 
6884
 
                /* Obtain the index of the next entry.*/
6885
 
                usCurrentEntry = pTsstEntry->usNextEntry;
6886
 
        }
6887
 
 
6888
 
        /* Check if all Rout Broadcast TSST were returned.*/
6889
 
        if ( usTsstCount < pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry )
6890
 
        {
6891
 
                f_pChannelStats->TdmConfig.fMoreRoutBroadcastTssts = TRUE;
6892
 
        }
6893
 
        else /* usTsstCount >= pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry */
6894
 
        {
6895
 
                f_pChannelStats->TdmConfig.fMoreRoutBroadcastTssts = FALSE;
6896
 
        }
6897
 
 
6898
 
        /* Copy the VQE configuration.*/
6899
 
        f_pChannelStats->VqeConfig.fEnableNlp = pChanEntry->VqeConfig.fEnableNlp;
6900
 
        f_pChannelStats->VqeConfig.ulComfortNoiseMode = pChanEntry->VqeConfig.byComfortNoiseMode;
6901
 
        f_pChannelStats->VqeConfig.fEnableTailDisplacement = pChanEntry->VqeConfig.fEnableTailDisplacement;
6902
 
        if ( pChanEntry->VqeConfig.usTailDisplacement != cOCT6100_AUTO_SELECT_TAIL )
6903
 
                f_pChannelStats->VqeConfig.ulTailDisplacement = pChanEntry->VqeConfig.usTailDisplacement;
6904
 
        else
6905
 
                f_pChannelStats->VqeConfig.ulTailDisplacement = f_pApiInstance->pSharedInfo->ChipConfig.usTailDisplacement;
6906
 
 
6907
 
        if ( pChanEntry->VqeConfig.usTailLength != cOCT6100_AUTO_SELECT_TAIL )
6908
 
                f_pChannelStats->VqeConfig.ulTailLength = pChanEntry->VqeConfig.usTailLength;
6909
 
        else
6910
 
                f_pChannelStats->VqeConfig.ulTailLength = f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength;
6911
 
        
6912
 
 
6913
 
 
6914
 
        f_pChannelStats->VqeConfig.fSinDcOffsetRemoval = pChanEntry->VqeConfig.fSinDcOffsetRemoval;
6915
 
        f_pChannelStats->VqeConfig.fRinDcOffsetRemoval = pChanEntry->VqeConfig.fRinDcOffsetRemoval;
6916
 
        f_pChannelStats->VqeConfig.fRinLevelControl = pChanEntry->VqeConfig.fRinLevelControl;
6917
 
        f_pChannelStats->VqeConfig.fSoutLevelControl = pChanEntry->VqeConfig.fSoutLevelControl;
6918
 
        f_pChannelStats->VqeConfig.fRinAutomaticLevelControl = pChanEntry->VqeConfig.fRinAutomaticLevelControl;
6919
 
        f_pChannelStats->VqeConfig.fSoutAutomaticLevelControl = pChanEntry->VqeConfig.fSoutAutomaticLevelControl;
6920
 
        f_pChannelStats->VqeConfig.ulAlcNoiseBleedOutTime = pChanEntry->VqeConfig.usAlcNoiseBleedOutTime;
6921
 
        f_pChannelStats->VqeConfig.fRinHighLevelCompensation = pChanEntry->VqeConfig.fRinHighLevelCompensation;
6922
 
        f_pChannelStats->VqeConfig.fSoutAdaptiveNoiseReduction = pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction;
6923
 
        f_pChannelStats->VqeConfig.fSoutNoiseBleaching = pChanEntry->VqeConfig.fSoutNoiseBleaching;
6924
 
        f_pChannelStats->VqeConfig.fSoutConferencingNoiseReduction = pChanEntry->VqeConfig.fSoutConferencingNoiseReduction;
6925
 
        f_pChannelStats->VqeConfig.lRinLevelControlGainDb       = pChanEntry->VqeConfig.chRinLevelControlGainDb;
6926
 
        f_pChannelStats->VqeConfig.lSoutLevelControlGainDb      = pChanEntry->VqeConfig.chSoutLevelControlGainDb;
6927
 
        f_pChannelStats->VqeConfig.lRinAutomaticLevelControlTargetDb    = pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb;
6928
 
        f_pChannelStats->VqeConfig.lSoutAutomaticLevelControlTargetDb   = pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb;
6929
 
        f_pChannelStats->VqeConfig.lRinHighLevelCompensationThresholdDb = pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb;
6930
 
        f_pChannelStats->VqeConfig.fAcousticEcho                        = pChanEntry->VqeConfig.fAcousticEcho;
6931
 
        f_pChannelStats->VqeConfig.fDtmfToneRemoval                     = pChanEntry->VqeConfig.fDtmfToneRemoval;
6932
 
 
6933
 
        f_pChannelStats->VqeConfig.lDefaultErlDb                                                        = pChanEntry->VqeConfig.chDefaultErlDb;
6934
 
        f_pChannelStats->VqeConfig.lAecDefaultErlDb                                                     = pChanEntry->VqeConfig.chAecDefaultErlDb;
6935
 
        f_pChannelStats->VqeConfig.ulAecTailLength                                                      = pChanEntry->VqeConfig.usAecTailLength;
6936
 
        f_pChannelStats->VqeConfig.lAnrSnrEnhancementDb                                         = pChanEntry->VqeConfig.chAnrSnrEnhancementDb;
6937
 
        f_pChannelStats->VqeConfig.ulAnrVoiceNoiseSegregation                           = pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation;
6938
 
        f_pChannelStats->VqeConfig.ulToneDisablerVqeActivationDelay                     = pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay;
6939
 
        f_pChannelStats->VqeConfig.ulNonLinearityBehaviorA                                      = pChanEntry->VqeConfig.byNonLinearityBehaviorA;
6940
 
        f_pChannelStats->VqeConfig.ulNonLinearityBehaviorB                                      = pChanEntry->VqeConfig.byNonLinearityBehaviorB;
6941
 
        f_pChannelStats->VqeConfig.ulDoubleTalkBehavior                                         = pChanEntry->VqeConfig.byDoubleTalkBehavior;
6942
 
        f_pChannelStats->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb     = pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb;
6943
 
        f_pChannelStats->VqeConfig.ulSoutNaturalListenerEnhancementGainDb       = pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb;
6944
 
        f_pChannelStats->VqeConfig.fSoutNaturalListenerEnhancement                      = pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement;
6945
 
        f_pChannelStats->VqeConfig.fRoutNoiseReduction                                          = pChanEntry->VqeConfig.fRoutNoiseReduction;
6946
 
        f_pChannelStats->VqeConfig.fEnableMusicProtection                                       = pChanEntry->VqeConfig.fEnableMusicProtection;
6947
 
        f_pChannelStats->VqeConfig.fIdleCodeDetection                                           = pChanEntry->VqeConfig.fIdleCodeDetection;
6948
 
        f_pChannelStats->VqeConfig.fResetRinAlcOnTones                                          = pChanEntry->VqeConfig.fResetRinAlcOnTones;
6949
 
        f_pChannelStats->VqeConfig.fResetSoutAlcOnTones                                         = pChanEntry->VqeConfig.fResetSoutAlcOnTones;
6950
 
        
6951
 
        /* Copy the CODEC configuration.*/
6952
 
        f_pChannelStats->CodecConfig.ulAdpcmNibblePosition = pChanEntry->CodecConfig.byAdpcmNibblePosition;
6953
 
 
6954
 
        f_pChannelStats->CodecConfig.ulEncoderPort = pChanEntry->CodecConfig.byEncoderPort;
6955
 
        f_pChannelStats->CodecConfig.ulEncodingRate = pChanEntry->CodecConfig.byEncodingRate;
6956
 
 
6957
 
        f_pChannelStats->CodecConfig.ulDecoderPort = pChanEntry->CodecConfig.byDecoderPort;
6958
 
        f_pChannelStats->CodecConfig.ulDecodingRate = pChanEntry->CodecConfig.byDecodingRate;
6959
 
 
6960
 
        f_pChannelStats->CodecConfig.fEnableSilenceSuppression = pChanEntry->CodecConfig.fEnableSilenceSuppression;
6961
 
        f_pChannelStats->CodecConfig.ulPhase = pChanEntry->CodecConfig.byPhase;
6962
 
        f_pChannelStats->CodecConfig.ulPhasingType = pChanEntry->CodecConfig.byPhasingType;
6963
 
 
6964
 
        if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
6965
 
        {
6966
 
                tPOCT6100_API_PHASING_TSST      pPhasingTsstEntry;
6967
 
 
6968
 
                mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingTsstEntry, pChanEntry->usPhasingTsstIndex );
6969
 
 
6970
 
                f_pChannelStats->CodecConfig.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingTsstEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pChanEntry->usPhasingTsstIndex;
6971
 
        }
6972
 
        else
6973
 
        {
6974
 
                f_pChannelStats->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
6975
 
        }
6976
 
 
6977
 
 
6978
 
        /* Reset the stats and exit if the reset flag is set.*/
6979
 
        if ( f_pChannelStats->fResetStats == TRUE )
6980
 
        {
6981
 
                pChanEntry->sMaxERLE = cOCT6100_INVALID_SIGNED_STAT_W;
6982
 
                pChanEntry->sMaxERL = cOCT6100_INVALID_SIGNED_STAT_W;
6983
 
                pChanEntry->usMaxEchoDelay = cOCT6100_INVALID_STAT_W;
6984
 
        }
6985
 
        
6986
 
        /*---------------------------------------------------------------------*/
6987
 
        /* Update the API internal stats.*/
6988
 
 
6989
 
        BurstParams.ulReadAddress  = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
6990
 
        BurstParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsOfst;
6991
 
        BurstParams.ulReadLength = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsSize / 2;    /* Length in words.*/
6992
 
 
6993
 
        mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult );
6994
 
        if ( ulResult != cOCT6100_ERR_OK )
6995
 
                return ulResult;
6996
 
        
6997
 
        /* Check if the energy stat are found in the new memory location. */
6998
 
        if ( ( pSharedInfo->ImageInfo.fRinEnergyStat == TRUE )
6999
 
                && ( pSharedInfo->ImageInfo.fSoutEnergyStat == TRUE ) )
7000
 
        {
7001
 
                ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.usDwordOffset * 4;
7002
 
                ulFeatureBitOffset       = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.byBitOffset;
7003
 
                ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.byFieldSize;
7004
 
 
7005
 
                ReadParams.ulReadAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
7006
 
                ReadParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + ulFeatureBytesOffset;
7007
 
 
7008
 
                /* Optimize this access by only reading the word we are interested in. */
7009
 
                if ( ulFeatureBitOffset < 16 )
7010
 
                        ReadParams.ulReadAddress += 2;
7011
 
 
7012
 
                /* Must read in memory directly since this value is changed by hardware */
7013
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
7014
 
                if ( ulResult != cOCT6100_ERR_OK )
7015
 
                        return ulResult;
7016
 
 
7017
 
                /* Move data at correct position according to what was read. */
7018
 
                if ( ulFeatureBitOffset < 16 )
7019
 
                        ulTempData = usReadData;
7020
 
                else
7021
 
                        ulTempData = usReadData << 16;
7022
 
 
7023
 
                /* Clear previous value set in the feature field. */
7024
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7025
 
 
7026
 
                ulTempData &= ulMask;
7027
 
 
7028
 
                /* Shift to get value. */
7029
 
                ulTempData = ulTempData >> ulFeatureBitOffset;
7030
 
 
7031
 
                /* Overwrite value read the old way. */
7032
 
                ausReadData[ 0 ] &= 0x00FF;
7033
 
                ausReadData[ 0 ] |= (UINT16)( ( ulTempData << 8 ) & 0xFF00 );
7034
 
 
7035
 
                ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.usDwordOffset * 4;
7036
 
                ulFeatureBitOffset       = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.byBitOffset;
7037
 
                ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.byFieldSize;
7038
 
 
7039
 
                ReadParams.ulReadAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
7040
 
                ReadParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + ulFeatureBytesOffset;
7041
 
 
7042
 
                /* Optimize this access by only reading the word we are interested in. */
7043
 
                if ( ulFeatureBitOffset < 16 )
7044
 
                        ReadParams.ulReadAddress += 2;
7045
 
 
7046
 
                /* Must read in memory directly since this value is changed by hardware */
7047
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
7048
 
                if ( ulResult != cOCT6100_ERR_OK )
7049
 
                        return ulResult;
7050
 
 
7051
 
                /* Move data at correct position according to what was read. */
7052
 
                if ( ulFeatureBitOffset < 16 )
7053
 
                        ulTempData = usReadData;
7054
 
                else
7055
 
                        ulTempData = usReadData << 16;
7056
 
 
7057
 
                /* Clear previous value set in the feature field. */
7058
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7059
 
 
7060
 
                ulTempData &= ulMask;
7061
 
 
7062
 
                /* Shift to get value. */
7063
 
                ulTempData = ulTempData >> ulFeatureBitOffset;
7064
 
 
7065
 
                /* Overwrite value read the old way. */
7066
 
                ausReadData[ 1 ] &= 0x00FF;
7067
 
                ausReadData[ 1 ] |= (UINT16)( ( ulTempData << 8 ) & 0xFF00 );
7068
 
        }
7069
 
 
7070
 
        byRinEnergyRaw  = (BYTE)(( ausReadData[ 0 ] >> 8 ) & 0xFF);
7071
 
        bySinEnergyRaw  = (BYTE)(( ausReadData[ 0 ] >> 0 ) & 0xFF);
7072
 
        bySoutEnergyRaw = (BYTE)(( ausReadData[ 1 ] >> 8 ) & 0xFF);
7073
 
        byCnEnergyRaw   = (BYTE)(( ausReadData[ 5 ] >> 8 ) & 0xFF);
7074
 
 
7075
 
        usEchoDelayInFrames             = (UINT16)(ausReadData[ 4 ]);
7076
 
        usErlRaw                                = ausReadData[ 2 ];
7077
 
 
7078
 
        pChanEntry->byToneDisablerStatus = (UINT8)(( ausReadData[ 5 ] >> 0 ) & 0xFF);
7079
 
        if ( f_pChannelStats->fResetStats == TRUE )
7080
 
        {
7081
 
                pChanEntry->usNumEchoPathChangesOfst = (UINT16)(ausReadData[ 3 ]);
7082
 
                pChanEntry->usNumEchoPathChanges = 0;
7083
 
        }
7084
 
        else /* if ( f_pChannelStats->fResetStats == FALSE ) */
7085
 
        {
7086
 
                pChanEntry->usNumEchoPathChanges = (UINT16)( ausReadData[ 3 ] - pChanEntry->usNumEchoPathChangesOfst );
7087
 
        }
7088
 
 
7089
 
        pChanEntry->sComfortNoiseLevel  = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( byCnEnergyRaw ) & 0xFFFF );
7090
 
        pChanEntry->sComfortNoiseLevel -= 12;
7091
 
        pChanEntry->sRinLevel  = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( byRinEnergyRaw ) & 0xFFFF );
7092
 
        pChanEntry->sRinLevel -= 12;
7093
 
        pChanEntry->sSinLevel = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( bySinEnergyRaw ) & 0xFFFF );
7094
 
        pChanEntry->sSinLevel -= 12;
7095
 
        lSoutEnergyIndB        = Oct6100ApiOctFloatToDbEnergyByte( bySoutEnergyRaw );
7096
 
        lSoutEnergyIndB           -= 12;
7097
 
        
7098
 
        /* Process some stats only if the channel is converged.*/
7099
 
        if ( ( usEchoDelayInFrames != cOCT6100_INVALID_ECHO_DELAY ) 
7100
 
                && ( pChanEntry->byEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN ) 
7101
 
                && ( pChanEntry->byEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET ) )
7102
 
        {
7103
 
                /* Update the current ERL. */
7104
 
                pChanEntry->sCurrentERL                         = (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( usErlRaw ) & 0xFFFF );
7105
 
                pChanEntry->sCurrentERLE                        = (INT16)( ( lSoutEnergyIndB - pChanEntry->sSinLevel ) & 0xFFFF );
7106
 
                pChanEntry->usCurrentEchoDelay          = (UINT16)( usEchoDelayInFrames / 8 );  /* To convert in msec.*/
7107
 
 
7108
 
                /* Update the max value if required.*/
7109
 
                if ( pChanEntry->usCurrentEchoDelay > pChanEntry->usMaxEchoDelay || 
7110
 
                         pChanEntry->usMaxEchoDelay == cOCT6100_INVALID_STAT_W )
7111
 
                {
7112
 
                        pChanEntry->usMaxEchoDelay = pChanEntry->usCurrentEchoDelay;
7113
 
                }
7114
 
 
7115
 
                if ( pChanEntry->sCurrentERL > pChanEntry->sMaxERL ||
7116
 
                         pChanEntry->sMaxERL == cOCT6100_INVALID_SIGNED_STAT_W )
7117
 
                {
7118
 
                        pChanEntry->sMaxERL = pChanEntry->sCurrentERL;
7119
 
                }
7120
 
 
7121
 
                if ( pChanEntry->sCurrentERLE > pChanEntry->sMaxERLE ||
7122
 
                         pChanEntry->sMaxERLE == cOCT6100_INVALID_SIGNED_STAT_W )
7123
 
                {
7124
 
                        pChanEntry->sMaxERLE = pChanEntry->sCurrentERLE;
7125
 
                }
7126
 
        }
7127
 
        else
7128
 
        {
7129
 
                pChanEntry->sCurrentERLE                = cOCT6100_INVALID_SIGNED_STAT_W;
7130
 
                pChanEntry->sCurrentERL                 = cOCT6100_INVALID_SIGNED_STAT_W;
7131
 
                pChanEntry->usCurrentEchoDelay  = cOCT6100_INVALID_STAT_W;
7132
 
        }
7133
 
 
7134
 
        if ( f_pApiInstance->pSharedInfo->ImageInfo.fRinAppliedGainStat == TRUE )
7135
 
        {
7136
 
                /* Calculate base address for auto level control + high level compensation configuration. */
7137
 
                ulBaseAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + ( usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
7138
 
                        
7139
 
                ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.usDwordOffset * 4;
7140
 
                ulFeatureBitOffset       = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.byBitOffset;
7141
 
                ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.byFieldSize;
7142
 
 
7143
 
                ReadParams.ulReadAddress = ulBaseAddress + ulFeatureBytesOffset;
7144
 
 
7145
 
                /* Optimize this access by only reading the word we are interested in. */
7146
 
                if ( ulFeatureBitOffset < 16 )
7147
 
                        ReadParams.ulReadAddress += 2;
7148
 
 
7149
 
                /* Must read in memory directly since this value is changed by hardware */
7150
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
7151
 
                if ( ulResult != cOCT6100_ERR_OK )
7152
 
                        return ulResult;
7153
 
 
7154
 
                /* Move data at correct position according to what was read. */
7155
 
                if ( ulFeatureBitOffset < 16 )
7156
 
                        ulTempData = usReadData;
7157
 
                else
7158
 
                        ulTempData = usReadData << 16;
7159
 
 
7160
 
                /* Clear previous value set in the feature field.*/
7161
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7162
 
 
7163
 
                ulTempData &= ulMask;
7164
 
 
7165
 
                /* Shift to get value. */
7166
 
                ulTempData = ulTempData >> ulFeatureBitOffset;
7167
 
                
7168
 
                pChanEntry->sRinAppliedGain = (INT16)( 2 * (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)( ulTempData & 0xFFFF ) ) & 0xFFFF ) );
7169
 
        }
7170
 
 
7171
 
        if ( f_pApiInstance->pSharedInfo->ImageInfo.fSoutAppliedGainStat == TRUE )
7172
 
        {
7173
 
                /* Calculate base address for auto level control + high level compensation configuration. */
7174
 
                ulBaseAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + ( usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
7175
 
                        
7176
 
                ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.usDwordOffset * 4;
7177
 
                ulFeatureBitOffset       = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.byBitOffset;
7178
 
                ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.byFieldSize;
7179
 
 
7180
 
                ReadParams.ulReadAddress = ulBaseAddress + ulFeatureBytesOffset;
7181
 
 
7182
 
                /* Optimize this access by only reading the word we are interested in. */
7183
 
                if ( ulFeatureBitOffset < 16 )
7184
 
                        ReadParams.ulReadAddress += 2;
7185
 
 
7186
 
                /* Must read in memory directly since this value is changed by hardware */
7187
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
7188
 
                if ( ulResult != cOCT6100_ERR_OK )
7189
 
                        return ulResult;
7190
 
 
7191
 
                /* Move data at correct position according to what was read. */
7192
 
                if ( ulFeatureBitOffset < 16 )
7193
 
                        ulTempData = usReadData;
7194
 
                else
7195
 
                        ulTempData = usReadData << 16;
7196
 
 
7197
 
                /* Clear previous value set in the feature field. */
7198
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7199
 
 
7200
 
                ulTempData &= ulMask;
7201
 
 
7202
 
                /* Shift to get value. */
7203
 
                ulTempData = ulTempData >> ulFeatureBitOffset;
7204
 
                
7205
 
                pChanEntry->sSoutAppliedGain = (INT16)( 2 * (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)( ulTempData & 0xFFFF ) ) & 0xFFFF ) );
7206
 
        }
7207
 
 
7208
 
        /*---------------------------------------------------------------------*/
7209
 
        /* Return the real stats.*/
7210
 
 
7211
 
        f_pChannelStats->ulNumEchoPathChanges = pChanEntry->usNumEchoPathChanges;
7212
 
        if ( usEchoDelayInFrames != cOCT6100_INVALID_ECHO_DELAY )
7213
 
        {
7214
 
                f_pChannelStats->fEchoCancellerConverged = TRUE;
7215
 
        }
7216
 
        else
7217
 
        {
7218
 
                f_pChannelStats->fEchoCancellerConverged = FALSE;
7219
 
        }
7220
 
        if ( pChanEntry->sCurrentERL == cOCT6100_INVALID_SIGNED_STAT_W )
7221
 
                f_pChannelStats->lCurrentERL = cOCT6100_INVALID_SIGNED_STAT;
7222
 
        else
7223
 
                f_pChannelStats->lCurrentERL = pChanEntry->sCurrentERL;
7224
 
 
7225
 
        if ( pChanEntry->sMaxERL == cOCT6100_INVALID_SIGNED_STAT_W )
7226
 
                f_pChannelStats->lMaxERL = cOCT6100_INVALID_SIGNED_STAT;
7227
 
        else
7228
 
                f_pChannelStats->lMaxERL = pChanEntry->sMaxERL;
7229
 
 
7230
 
        if ( pChanEntry->usMaxEchoDelay == cOCT6100_INVALID_STAT_W )
7231
 
                f_pChannelStats->ulMaxEchoDelay = cOCT6100_INVALID_STAT;
7232
 
        else
7233
 
                f_pChannelStats->ulMaxEchoDelay = pChanEntry->usMaxEchoDelay;
7234
 
 
7235
 
        if ( pChanEntry->sRinLevel == cOCT6100_INVALID_SIGNED_STAT_W )
7236
 
                f_pChannelStats->lRinLevel = cOCT6100_INVALID_SIGNED_STAT;
7237
 
        else
7238
 
                f_pChannelStats->lRinLevel = pChanEntry->sRinLevel;
7239
 
 
7240
 
        if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
7241
 
        {
7242
 
                if ( pChanEntry->sSinLevel == cOCT6100_INVALID_SIGNED_STAT_W )
7243
 
                        f_pChannelStats->lSinLevel = cOCT6100_INVALID_SIGNED_STAT;
7244
 
                else
7245
 
                        f_pChannelStats->lSinLevel = pChanEntry->sSinLevel;
7246
 
        }
7247
 
        else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
7248
 
        {
7249
 
                /* SIN level is not supported in this image. */
7250
 
                f_pChannelStats->lSinLevel = cOCT6100_INVALID_SIGNED_STAT;
7251
 
        }
7252
 
 
7253
 
        f_pChannelStats->lRinAppliedGain = pChanEntry->VqeConfig.chRinLevelControlGainDb;
7254
 
        if ( ( f_pApiInstance->pSharedInfo->ImageInfo.fRinAppliedGainStat == TRUE )
7255
 
                && ( ( pChanEntry->VqeConfig.fRinAutomaticLevelControl == TRUE )
7256
 
                || ( pChanEntry->VqeConfig.fRinHighLevelCompensation == TRUE ) ) )
7257
 
        {
7258
 
                f_pChannelStats->lRinAppliedGain = pChanEntry->sRinAppliedGain;
7259
 
        }
7260
 
 
7261
 
        f_pChannelStats->lSoutAppliedGain = pChanEntry->VqeConfig.chSoutLevelControlGainDb;
7262
 
        if ( ( f_pApiInstance->pSharedInfo->ImageInfo.fSoutAppliedGainStat == TRUE )
7263
 
                && ( pChanEntry->VqeConfig.fSoutAutomaticLevelControl == TRUE ) )
7264
 
        {
7265
 
                f_pChannelStats->lSoutAppliedGain = pChanEntry->sSoutAppliedGain;
7266
 
        }
7267
 
 
7268
 
        if ( pChanEntry->usCurrentEchoDelay == cOCT6100_INVALID_STAT_W )
7269
 
                f_pChannelStats->ulCurrentEchoDelay     = cOCT6100_INVALID_STAT;
7270
 
        else
7271
 
                f_pChannelStats->ulCurrentEchoDelay     = pChanEntry->usCurrentEchoDelay;
7272
 
 
7273
 
        if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
7274
 
        {
7275
 
                if ( pChanEntry->sCurrentERLE == cOCT6100_INVALID_SIGNED_STAT_W )
7276
 
                        f_pChannelStats->lCurrentERLE = cOCT6100_INVALID_SIGNED_STAT;
7277
 
                else
7278
 
                        f_pChannelStats->lCurrentERLE = pChanEntry->sCurrentERLE;
7279
 
        }
7280
 
        else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
7281
 
        {
7282
 
                f_pChannelStats->lCurrentERLE = cOCT6100_INVALID_SIGNED_STAT;
7283
 
        }
7284
 
 
7285
 
        if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
7286
 
        {
7287
 
                if ( pChanEntry->sMaxERLE == cOCT6100_INVALID_SIGNED_STAT_W )
7288
 
                        f_pChannelStats->lMaxERLE = cOCT6100_INVALID_SIGNED_STAT;
7289
 
                else
7290
 
                        f_pChannelStats->lMaxERLE = pChanEntry->sMaxERLE;
7291
 
        }
7292
 
        else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
7293
 
        {
7294
 
                f_pChannelStats->lMaxERLE = cOCT6100_INVALID_SIGNED_STAT;
7295
 
        }
7296
 
 
7297
 
        f_pChannelStats->lComfortNoiseLevel             = pChanEntry->sComfortNoiseLevel;
7298
 
        f_pChannelStats->ulToneDisablerStatus   = pChanEntry->byToneDisablerStatus;
7299
 
 
7300
 
        if ( f_pApiInstance->pSharedInfo->ImageInfo.fSinVoiceDetectedStat == TRUE )
7301
 
        {
7302
 
                UINT32 ulVoiceDetectedBytesOfst = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.usDwordOffset * 4;
7303
 
                UINT32 ulVoiceDetectedBitOfst   = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.byBitOffset;
7304
 
                UINT32 ulVoiceDetectedFieldSize = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.byFieldSize;
7305
 
 
7306
 
                /* Set the channel root base address.*/
7307
 
                UINT32 ulChannelRootBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( usChanIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanRootConfOfst;
7308
 
 
7309
 
                ReadParams.ulReadAddress = ulChannelRootBaseAddress + ulVoiceDetectedBytesOfst;
7310
 
 
7311
 
                /* Optimize this access by only reading the word we are interested in. */
7312
 
                if ( ulVoiceDetectedBitOfst < 16 )
7313
 
                        ReadParams.ulReadAddress += 2;
7314
 
 
7315
 
                /* Must read in memory directly since this value is changed by hardware */
7316
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
7317
 
                if ( ulResult != cOCT6100_ERR_OK )
7318
 
                        return ulResult;
7319
 
 
7320
 
                /* Move data at correct position according to what was read. */
7321
 
                if ( ulVoiceDetectedBitOfst < 16 )
7322
 
                        ulTempData = usReadData;
7323
 
                else
7324
 
                        ulTempData = usReadData << 16;
7325
 
 
7326
 
                mOCT6100_CREATE_FEATURE_MASK( ulVoiceDetectedFieldSize, ulVoiceDetectedBitOfst, &ulMask );
7327
 
                
7328
 
                if ( ( ulTempData & ulMask ) != 0x0 )
7329
 
                        f_pChannelStats->fSinVoiceDetected = TRUE;
7330
 
                else
7331
 
                        f_pChannelStats->fSinVoiceDetected = FALSE;
7332
 
        }
7333
 
        
7334
 
        /*---------------------------------------------------------------------*/
7335
 
 
7336
 
        return cOCT6100_ERR_OK;
7337
 
}       
7338
 
#endif
7339
 
 
7340
 
 
7341
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7342
 
 
7343
 
Function:               Oct6100ApiReserveEchoEntry
7344
 
 
7345
 
Description:    Reserves one of the echo channel API entry.
7346
 
 
7347
 
-------------------------------------------------------------------------------
7348
 
|       Argument                |       Description
7349
 
-------------------------------------------------------------------------------
7350
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
7351
 
                                                the present state of the chip and all its resources.
7352
 
 
7353
 
f_pusEchoIndex                  Resulting index reserved in the echo channel list.
7354
 
 
7355
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7356
 
#if !SKIP_Oct6100ApiReserveEchoEntry
7357
 
UINT32 Oct6100ApiReserveEchoEntry(
7358
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
7359
 
                                OUT     PUINT16                                         f_pusEchoIndex )
7360
 
{
7361
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
7362
 
        PVOID   pEchoAlloc;
7363
 
        UINT32  ulResult;
7364
 
        UINT32  ulEchoIndex;
7365
 
 
7366
 
        /* Get local pointer to shared portion of instance. */
7367
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
7368
 
 
7369
 
        mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc )
7370
 
        
7371
 
        ulResult = OctapiLlmAllocAlloc( pEchoAlloc, &ulEchoIndex );
7372
 
        if ( ulResult != cOCT6100_ERR_OK  )
7373
 
        {
7374
 
                if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
7375
 
                        return cOCT6100_ERR_CHANNEL_ALL_CHANNELS_ARE_OPENED;
7376
 
                else
7377
 
                        return cOCT6100_ERR_FATAL_11;
7378
 
        }
7379
 
 
7380
 
        *f_pusEchoIndex = (UINT16)( ulEchoIndex & 0xFFFF );
7381
 
 
7382
 
        return cOCT6100_ERR_OK;
7383
 
}
7384
 
#endif
7385
 
 
7386
 
 
7387
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7388
 
 
7389
 
Function:               Oct6100ApiReleaseEchoEntry
7390
 
 
7391
 
Description:    Releases the specified ECHO channel API entry.
7392
 
 
7393
 
-------------------------------------------------------------------------------
7394
 
|       Argument                |       Description
7395
 
-------------------------------------------------------------------------------
7396
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
7397
 
                                                the present state of the chip and all its resources.
7398
 
 
7399
 
f_usEchoIndex                   Index reserved in the echo channel list.
7400
 
 
7401
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7402
 
#if !SKIP_Oct6100ApiReleaseEchoEntry
7403
 
UINT32 Oct6100ApiReleaseEchoEntry(
7404
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
7405
 
                                IN      UINT16                                          f_usEchoIndex )
7406
 
{
7407
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
7408
 
        PVOID   pEchoAlloc;
7409
 
        UINT32  ulResult;
7410
 
 
7411
 
        /* Get local pointer to shared portion of instance. */
7412
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
7413
 
 
7414
 
        mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc )
7415
 
        
7416
 
        ulResult = OctapiLlmAllocDealloc( pEchoAlloc, f_usEchoIndex );
7417
 
        if ( ulResult != cOCT6100_ERR_OK  )
7418
 
        {
7419
 
                return cOCT6100_ERR_FATAL_12;
7420
 
        }
7421
 
 
7422
 
        return cOCT6100_ERR_OK;
7423
 
}
7424
 
#endif
7425
 
 
7426
 
 
7427
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7428
 
 
7429
 
Function:               Oct6100ApiReserveBiDirChanEntry
7430
 
 
7431
 
Description:    Reserves one of the bidirectional channel API entry.
7432
 
 
7433
 
-------------------------------------------------------------------------------
7434
 
|       Argument                |       Description
7435
 
-------------------------------------------------------------------------------
7436
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
7437
 
                                                the present state of the chip and all its resources.
7438
 
 
7439
 
f_pusBiDirChanIndex             Resulting index reserved in the bidir channel list.
7440
 
 
7441
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7442
 
#if !SKIP_Oct6100ApiReserveBiDirChanEntry
7443
 
UINT32 Oct6100ApiReserveBiDirChanEntry(
7444
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
7445
 
                                OUT     PUINT16                                         f_pusBiDirChanIndex )
7446
 
{
7447
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
7448
 
        PVOID   pChanAlloc;
7449
 
        UINT32  ulResult;
7450
 
        UINT32  ulBiDirChanIndex;
7451
 
 
7452
 
        /* Get local pointer to shared portion of the API instance. */
7453
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
7454
 
 
7455
 
        mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pChanAlloc )
7456
 
        
7457
 
        ulResult = OctapiLlmAllocAlloc( pChanAlloc, &ulBiDirChanIndex );
7458
 
        if ( ulResult != cOCT6100_ERR_OK  )
7459
 
        {
7460
 
                if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
7461
 
                        return cOCT6100_ERR_CHANNEL_ALL_BIDIR_CHANNELS_ARE_OPENED;
7462
 
                else
7463
 
                        return cOCT6100_ERR_FATAL_9F;
7464
 
        }
7465
 
 
7466
 
        *f_pusBiDirChanIndex = (UINT16)( ulBiDirChanIndex & 0xFFFF );
7467
 
 
7468
 
        return cOCT6100_ERR_OK;
7469
 
}
7470
 
#endif
7471
 
 
7472
 
 
7473
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7474
 
 
7475
 
Function:               Oct6100ApiReleaseBiDirChanEntry
7476
 
 
7477
 
Description:    Releases the specified bidirectional channel API entry.
7478
 
 
7479
 
-------------------------------------------------------------------------------
7480
 
|       Argument                |       Description
7481
 
-------------------------------------------------------------------------------
7482
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
7483
 
                                                the present state of the chip and all its resources.
7484
 
 
7485
 
f_ulBiDirChanIndex              Bidirectional channel index within the API's Bidir channel list.
7486
 
 
7487
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7488
 
#if !SKIP_Oct6100ApiReleaseBiDirChanEntry
7489
 
UINT32 Oct6100ApiReleaseBiDirChanEntry(
7490
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
7491
 
                                IN      UINT32                                          f_ulBiDirChanIndex )
7492
 
{
7493
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
7494
 
        PVOID   pChanAlloc;
7495
 
        UINT32  ulResult;
7496
 
 
7497
 
        /* Get local pointer to shared portion of instance. */
7498
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
7499
 
 
7500
 
        mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pChanAlloc )
7501
 
        
7502
 
        ulResult = OctapiLlmAllocDealloc( pChanAlloc, f_ulBiDirChanIndex );
7503
 
        if ( ulResult != cOCT6100_ERR_OK  )
7504
 
        {
7505
 
                return cOCT6100_ERR_FATAL_A0;
7506
 
        }
7507
 
 
7508
 
        return cOCT6100_ERR_OK;
7509
 
}
7510
 
#endif
7511
 
 
7512
 
 
7513
 
 
7514
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7515
 
 
7516
 
Function:               Oct6100ApiCheckTdmConfig
7517
 
 
7518
 
Description:    This function will check the validity of the TDM config parameter
7519
 
                                of an Open TDM config structure.
7520
 
 
7521
 
-------------------------------------------------------------------------------
7522
 
|       Argument                |       Description
7523
 
-------------------------------------------------------------------------------
7524
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
7525
 
                                                the present state of the chip and all its resources.
7526
 
 
7527
 
f_pTdmConfig                    TDM config of the channel.
7528
 
 
7529
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7530
 
#if !SKIP_Oct6100ApiCheckTdmConfig
7531
 
UINT32 Oct6100ApiCheckTdmConfig( 
7532
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
7533
 
                                IN      tPOCT6100_CHANNEL_OPEN_TDM              f_pTdmConfig )
7534
 
{
7535
 
        UINT32  ulResult;
7536
 
 
7537
 
        /*==============================================================================*/
7538
 
        /* Check the TDM configuration parameters.*/
7539
 
 
7540
 
        /* Check the validity of the timeslot and Stream only if it is defined.*/
7541
 
        if ( f_pTdmConfig->ulRinTimeslot != cOCT6100_UNASSIGNED || 
7542
 
                 f_pTdmConfig->ulRinStream != cOCT6100_UNASSIGNED )
7543
 
        {
7544
 
                if ( f_pTdmConfig->ulRinNumTssts != 1 &&
7545
 
                         f_pTdmConfig->ulRinNumTssts != 2 )
7546
 
                        return cOCT6100_ERR_CHANNEL_RIN_NUM_TSSTS;
7547
 
 
7548
 
                /* Check the RIN TDM streams, timeslots component for errors.*/
7549
 
                ulResult = Oct6100ApiValidateTsst( f_pApiInstance, 
7550
 
                                                                                   f_pTdmConfig->ulRinNumTssts,
7551
 
                                                                                   f_pTdmConfig->ulRinTimeslot, 
7552
 
                                                                                   f_pTdmConfig->ulRinStream,
7553
 
                                                                                   cOCT6100_INPUT_TSST );
7554
 
                if ( ulResult != cOCT6100_ERR_OK  )
7555
 
                {
7556
 
                        if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7557
 
                        {
7558
 
                                return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
7559
 
                        }
7560
 
                        else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7561
 
                        {
7562
 
                                return cOCT6100_ERR_CHANNEL_RIN_STREAM;
7563
 
                        }
7564
 
                        else
7565
 
                        {
7566
 
                                return ulResult;
7567
 
                        }
7568
 
                }
7569
 
        }
7570
 
 
7571
 
        /* Check the validity of the timeslot and Stream only if it is defined.*/
7572
 
        if ( f_pTdmConfig->ulRoutTimeslot != cOCT6100_UNASSIGNED || 
7573
 
                 f_pTdmConfig->ulRoutStream != cOCT6100_UNASSIGNED )
7574
 
        {
7575
 
                if ( f_pTdmConfig->ulRoutNumTssts != 1 &&
7576
 
                         f_pTdmConfig->ulRoutNumTssts != 2 )
7577
 
                        return cOCT6100_ERR_CHANNEL_ROUT_NUM_TSSTS;
7578
 
 
7579
 
                /* Check the ROUT TDM streams, timeslots component for errors.*/
7580
 
                ulResult = Oct6100ApiValidateTsst( f_pApiInstance, 
7581
 
                                                                                   f_pTdmConfig->ulRoutNumTssts,
7582
 
                                                                                   f_pTdmConfig->ulRoutTimeslot, 
7583
 
                                                                                   f_pTdmConfig->ulRoutStream,
7584
 
                                                                                   cOCT6100_OUTPUT_TSST );
7585
 
                if ( ulResult != cOCT6100_ERR_OK  )
7586
 
                {
7587
 
                        if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7588
 
                        {
7589
 
                                return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT;
7590
 
                        }
7591
 
                        else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7592
 
                        {
7593
 
                                return cOCT6100_ERR_CHANNEL_ROUT_STREAM;
7594
 
                        }
7595
 
                        else
7596
 
                        {
7597
 
                                return ulResult;
7598
 
                        }
7599
 
                }
7600
 
        }
7601
 
 
7602
 
        /* Check the validity of the timeslot and Stream only if it is defined.*/
7603
 
        if ( f_pTdmConfig->ulSinTimeslot != cOCT6100_UNASSIGNED || 
7604
 
                 f_pTdmConfig->ulSinStream != cOCT6100_UNASSIGNED )
7605
 
        {
7606
 
                if ( f_pTdmConfig->ulSinNumTssts != 1 &&
7607
 
                         f_pTdmConfig->ulSinNumTssts != 2 )
7608
 
                        return cOCT6100_ERR_CHANNEL_SIN_NUM_TSSTS;
7609
 
 
7610
 
                /* Check the SIN TDM streams, timeslots component for errors.*/
7611
 
                ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
7612
 
                                                                                   f_pTdmConfig->ulSinNumTssts, 
7613
 
                                                                                   f_pTdmConfig->ulSinTimeslot, 
7614
 
                                                                                   f_pTdmConfig->ulSinStream,
7615
 
                                                                                   cOCT6100_INPUT_TSST );
7616
 
                if ( ulResult != cOCT6100_ERR_OK  )
7617
 
                {
7618
 
                        if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7619
 
                        {
7620
 
                                return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT;
7621
 
                        }
7622
 
                        else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7623
 
                        {
7624
 
                                return cOCT6100_ERR_CHANNEL_SIN_STREAM;
7625
 
                        }
7626
 
                        else
7627
 
                        {
7628
 
                                return ulResult;
7629
 
                        }
7630
 
                }
7631
 
        }
7632
 
 
7633
 
        /* Check the validity of the timeslot and Stream only if it is defined.*/
7634
 
        if ( f_pTdmConfig->ulSoutTimeslot != cOCT6100_UNASSIGNED || 
7635
 
                 f_pTdmConfig->ulSoutStream != cOCT6100_UNASSIGNED )
7636
 
        {
7637
 
                if ( f_pTdmConfig->ulSoutNumTssts != 1 &&
7638
 
                         f_pTdmConfig->ulSoutNumTssts != 2 )
7639
 
                        return cOCT6100_ERR_CHANNEL_SOUT_NUM_TSSTS;
7640
 
 
7641
 
                /* Check the ROUT TDM streams, timeslots component for errors.*/
7642
 
                ulResult = Oct6100ApiValidateTsst( f_pApiInstance, 
7643
 
                                                                                   f_pTdmConfig->ulSoutNumTssts,
7644
 
                                                                                   f_pTdmConfig->ulSoutTimeslot, 
7645
 
                                                                                   f_pTdmConfig->ulSoutStream,
7646
 
                                                                                   cOCT6100_OUTPUT_TSST );
7647
 
                if ( ulResult != cOCT6100_ERR_OK  )
7648
 
                {
7649
 
                        if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7650
 
                        {
7651
 
                                return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
7652
 
                        }
7653
 
                        else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7654
 
                        {
7655
 
                                return cOCT6100_ERR_CHANNEL_SOUT_STREAM;
7656
 
                        }
7657
 
                        else
7658
 
                        {
7659
 
                                return ulResult;
7660
 
                        }
7661
 
                }
7662
 
        }       
7663
 
        
7664
 
        /* Check the PCM law parameters.*/
7665
 
        if ( f_pTdmConfig->ulRinPcmLaw != cOCT6100_PCM_U_LAW && 
7666
 
                 f_pTdmConfig->ulRinPcmLaw != cOCT6100_PCM_A_LAW )
7667
 
                return cOCT6100_ERR_CHANNEL_RIN_PCM_LAW;
7668
 
 
7669
 
        if ( f_pTdmConfig->ulSinPcmLaw != cOCT6100_PCM_U_LAW && 
7670
 
                 f_pTdmConfig->ulSinPcmLaw != cOCT6100_PCM_A_LAW )
7671
 
                return cOCT6100_ERR_CHANNEL_SIN_PCM_LAW;
7672
 
 
7673
 
        if ( f_pTdmConfig->ulRoutPcmLaw != cOCT6100_PCM_U_LAW && 
7674
 
                 f_pTdmConfig->ulRoutPcmLaw != cOCT6100_PCM_A_LAW )
7675
 
                return cOCT6100_ERR_CHANNEL_ROUT_PCM_LAW;
7676
 
 
7677
 
        if ( f_pTdmConfig->ulSoutPcmLaw != cOCT6100_PCM_U_LAW && 
7678
 
                 f_pTdmConfig->ulSoutPcmLaw != cOCT6100_PCM_A_LAW )
7679
 
                return cOCT6100_ERR_CHANNEL_SOUT_PCM_LAW;
7680
 
        
7681
 
        /*==============================================================================*/
7682
 
 
7683
 
 
7684
 
 
7685
 
        return cOCT6100_ERR_OK;
7686
 
}
7687
 
#endif
7688
 
 
7689
 
 
7690
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7691
 
 
7692
 
Function:               Oct6100ApiCheckVqeConfig
7693
 
 
7694
 
Description:    This function will check the validity of the VQE config parameter
7695
 
                                of an Open VQE config structure.
7696
 
 
7697
 
-------------------------------------------------------------------------------
7698
 
|       Argument                |       Description
7699
 
-------------------------------------------------------------------------------
7700
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
7701
 
                                                the present state of the chip and all its resources.
7702
 
 
7703
 
f_pVqeConfig                    VQE config of the channel.
7704
 
f_fEnableToneDisabler   Whether the tone disabler is active or not.
7705
 
 
7706
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7707
 
#if !SKIP_Oct6100ApiCheckVqeConfig
7708
 
UINT32 Oct6100ApiCheckVqeConfig( 
7709
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
7710
 
                                IN              tPOCT6100_CHANNEL_OPEN_VQE              f_pVqeConfig,
7711
 
                                IN              BOOL                                                    f_fEnableToneDisabler )
7712
 
{
7713
 
        tPOCT6100_API_IMAGE_INFO                pImageInfo;
7714
 
 
7715
 
        pImageInfo = &f_pApiInstance->pSharedInfo->ImageInfo;
7716
 
 
7717
 
        if ( f_pVqeConfig->fEnableNlp != TRUE && f_pVqeConfig->fEnableNlp != FALSE )
7718
 
                return cOCT6100_ERR_CHANNEL_ENABLE_NLP;
7719
 
 
7720
 
        if ( f_pVqeConfig->fEnableNlp == TRUE && pImageInfo->fNlpControl == FALSE )
7721
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLP_CONTROL;
7722
 
        
7723
 
 
7724
 
 
7725
 
        /* Check the comfort noise mode.*/
7726
 
        if ( f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_OFF && pImageInfo->fComfortNoise == FALSE )
7727
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_BKG_NOISE_FREEZE;
7728
 
 
7729
 
        if ( f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_NORMAL && 
7730
 
                 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_EXTENDED &&
7731
 
                 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_FAST_LATCH &&
7732
 
                 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_OFF )
7733
 
                return cOCT6100_ERR_CHANNEL_COMFORT_NOISE_MODE;
7734
 
 
7735
 
        /* Check the DC offset removal.*/
7736
 
        if ( f_pVqeConfig->fSinDcOffsetRemoval != TRUE && f_pVqeConfig->fSinDcOffsetRemoval != FALSE )
7737
 
                return cOCT6100_ERR_CHANNEL_SIN_DC_OFFSET_REM;
7738
 
 
7739
 
        if ( f_pVqeConfig->fSinDcOffsetRemoval == TRUE && pImageInfo->fSinDcOffsetRemoval == FALSE )
7740
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_DC_OFFSET_REM;
7741
 
 
7742
 
        if ( f_pVqeConfig->fRinDcOffsetRemoval != TRUE && f_pVqeConfig->fRinDcOffsetRemoval != FALSE )
7743
 
                return cOCT6100_ERR_CHANNEL_RIN_DC_OFFSET_REM;
7744
 
 
7745
 
        if ( f_pVqeConfig->fRinDcOffsetRemoval == TRUE && pImageInfo->fRinDcOffsetRemoval == FALSE )
7746
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_DC_OFFSET_REM;
7747
 
 
7748
 
        /* Check the Level control.*/
7749
 
        if ( f_pVqeConfig->fRinLevelControl != TRUE && f_pVqeConfig->fRinLevelControl != FALSE )
7750
 
                return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL;
7751
 
 
7752
 
        if ( f_pVqeConfig->fSoutLevelControl != TRUE && f_pVqeConfig->fSoutLevelControl != FALSE )
7753
 
                return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL;
7754
 
 
7755
 
        if ( ( f_pVqeConfig->lRinLevelControlGainDb < -24 ) || ( f_pVqeConfig->lRinLevelControlGainDb >  24 ) )
7756
 
                return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL_GAIN;
7757
 
 
7758
 
        if ( ( f_pVqeConfig->lSoutLevelControlGainDb < -24 ) || ( f_pVqeConfig->lSoutLevelControlGainDb >  24 ) )
7759
 
                return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL_GAIN;
7760
 
 
7761
 
        if ( ( f_pVqeConfig->fRinAutomaticLevelControl != TRUE ) && ( f_pVqeConfig->fRinAutomaticLevelControl != FALSE ) )
7762
 
                return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL;
7763
 
 
7764
 
        if ( ( f_pVqeConfig->fRinHighLevelCompensation != TRUE ) && ( f_pVqeConfig->fRinHighLevelCompensation != FALSE ) )
7765
 
                return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP;
7766
 
 
7767
 
        if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) && ( pImageInfo->fRinAutoLevelControl == FALSE ) ) 
7768
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_AUTO_LC;
7769
 
 
7770
 
        if ( f_pVqeConfig->ulAlcNoiseBleedOutTime > 63750 )
7771
 
                return cOCT6100_ERR_CHANNEL_ALC_NOISE_BLEED_OUT_TIME;
7772
 
 
7773
 
        if ( ( f_pVqeConfig->ulAlcNoiseBleedOutTime != 0 ) && ( pImageInfo->fAlcNoiseBleedOutTime == FALSE ) ) 
7774
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ALC_NOISE_BLEED_OUT_TIME;
7775
 
 
7776
 
        if ( ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) && ( pImageInfo->fRinHighLevelCompensation == FALSE ) )
7777
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_HIGH_LEVEL_COMP;
7778
 
 
7779
 
        /* Check the enable reset Rin ALC on tone detection flag. */
7780
 
        if ( ( f_pVqeConfig->fResetRinAlcOnTones != TRUE ) && ( f_pVqeConfig->fResetRinAlcOnTones != FALSE ) )
7781
 
                return cOCT6100_ERR_CHANNEL_RESET_RIN_ALC_ON_TONES;
7782
 
 
7783
 
        /* The reset Rin ALC on tone detection can be activated if the image supports it. */
7784
 
        if ( ( f_pVqeConfig->fResetRinAlcOnTones == TRUE ) && ( pImageInfo->fResetRinAlcOnTones == FALSE ) )
7785
 
                return cOCT6100_ERR_NOT_SUPPORTED_RESET_RIN_ALC_ON_TONES;
7786
 
 
7787
 
        if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
7788
 
        {
7789
 
                if ( f_pVqeConfig->fRinLevelControl == TRUE )
7790
 
                        return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_MANUAL;
7791
 
 
7792
 
                if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
7793
 
                        return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_HIGH_LEVEL_COMP;
7794
 
 
7795
 
                if ( ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lRinAutomaticLevelControlTargetDb > 0 ) )
7796
 
                        return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL_TARGET;
7797
 
        }
7798
 
        else /* if ( f_pVqeConfig->fRinAutomaticLevelControl != TRUE ) */
7799
 
        {
7800
 
                /* Reset Rin ALC on tones can only be activated in Rin ALC is requested. */
7801
 
                if ( f_pVqeConfig->fResetRinAlcOnTones == TRUE )
7802
 
                        return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL_REQUIRED;
7803
 
        }
7804
 
 
7805
 
        if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
7806
 
        {
7807
 
                if ( f_pVqeConfig->fRinLevelControl == TRUE )
7808
 
                        return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_MANUAL;
7809
 
 
7810
 
                if ( ( f_pVqeConfig->lRinHighLevelCompensationThresholdDb < -40 || f_pVqeConfig->lRinHighLevelCompensationThresholdDb > 0 ) )
7811
 
                        return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_THRESHOLD;
7812
 
        }
7813
 
 
7814
 
        if ( f_pVqeConfig->fSoutAutomaticLevelControl != TRUE && f_pVqeConfig->fSoutAutomaticLevelControl != FALSE )
7815
 
                return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL;
7816
 
 
7817
 
        if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) && ( pImageInfo->fSoutAutoLevelControl == FALSE ) ) 
7818
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SOUT_AUTO_LC;
7819
 
 
7820
 
        /* Check the enable reset Sout ALC on tone detection flag. */
7821
 
        if ( ( f_pVqeConfig->fResetSoutAlcOnTones != TRUE ) && ( f_pVqeConfig->fResetSoutAlcOnTones != FALSE ) )
7822
 
                return cOCT6100_ERR_CHANNEL_RESET_SOUT_ALC_ON_TONES;
7823
 
 
7824
 
        /* The reset Sout ALC on tone detection can be activated if the image supports it. */
7825
 
        if ( ( f_pVqeConfig->fResetSoutAlcOnTones == TRUE ) && ( pImageInfo->fResetSoutAlcOnTones == FALSE ) )
7826
 
                return cOCT6100_ERR_NOT_SUPPORTED_RESET_SOUT_ALC_ON_TONES;
7827
 
 
7828
 
        if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
7829
 
        {
7830
 
                if ( f_pVqeConfig->fSoutLevelControl == TRUE )
7831
 
                        return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_MANUAL;
7832
 
 
7833
 
                if ( ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lSoutAutomaticLevelControlTargetDb > 0 ) )
7834
 
                        return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL_TARGET;
7835
 
        }
7836
 
        else /* if ( f_pVqeConfig->fSoutAutomaticLevelControl != TRUE ) */
7837
 
        {
7838
 
                /* Reset Sout ALC on tones can only be activated if Sout ALC is requested. */
7839
 
                if ( f_pVqeConfig->fResetSoutAlcOnTones == TRUE )
7840
 
                        return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL_REQUIRED;
7841
 
        }
7842
 
 
7843
 
        /* ALC noise bleed out can only be configured if ALC is requested. */
7844
 
        if ( f_pVqeConfig->ulAlcNoiseBleedOutTime != 0 ) 
7845
 
        {
7846
 
                /* If both ports ALC is disabled, let the user know. */
7847
 
                if ( ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) 
7848
 
                        && ( f_pVqeConfig->fSoutAutomaticLevelControl == FALSE ) )
7849
 
                        return cOCT6100_ERR_CHANNEL_AUTO_LEVEL_CONTROL_REQUIRED;
7850
 
        }
7851
 
 
7852
 
        if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != TRUE && 
7853
 
                 f_pVqeConfig->fSoutAdaptiveNoiseReduction != FALSE )
7854
 
                return cOCT6100_ERR_CHANNEL_SOUT_ADAPT_NOISE_REDUCTION;
7855
 
 
7856
 
        if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE && pImageInfo->fAdaptiveNoiseReduction == FALSE )
7857
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR;
7858
 
 
7859
 
        if ( f_pVqeConfig->fSoutConferencingNoiseReduction != TRUE && 
7860
 
                 f_pVqeConfig->fSoutConferencingNoiseReduction != FALSE )
7861
 
                return cOCT6100_ERR_CHANNEL_SOUT_CONFERENCE_NOISE_REDUCTION;
7862
 
 
7863
 
        if ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE && pImageInfo->fConferencingNoiseReduction == FALSE )
7864
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_CNR;
7865
 
 
7866
 
        /* Validate Sout noise bleaching parameter. */
7867
 
        if ( f_pVqeConfig->fSoutNoiseBleaching != TRUE && 
7868
 
                 f_pVqeConfig->fSoutNoiseBleaching != FALSE )
7869
 
                return cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING;
7870
 
 
7871
 
        /* Check if firmware supports Sout noise bleaching. */
7872
 
        if ( f_pVqeConfig->fSoutNoiseBleaching == TRUE && pImageInfo->fSoutNoiseBleaching == FALSE )
7873
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NOISE_BLEACHING;
7874
 
 
7875
 
        /* If Sout noise bleaching is requested, no ANR or CNR shall be activated. */
7876
 
        if ( f_pVqeConfig->fSoutNoiseBleaching == TRUE )
7877
 
        {
7878
 
                /* No xNR! */
7879
 
                if ( ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE )
7880
 
                        || ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE ) )
7881
 
                        return cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING_NR;
7882
 
        }
7883
 
 
7884
 
        /* Cannot activate both ANR and CNR when noise bleaching is present */
7885
 
        if ( pImageInfo->fSoutNoiseBleaching == TRUE )
7886
 
        {
7887
 
                if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE && 
7888
 
                        f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE )
7889
 
                        return cOCT6100_ERR_CHANNEL_ANR_CNR_SIMULTANEOUSLY;
7890
 
        }
7891
 
 
7892
 
        /* Validate the DTMF tone removal parameter.*/
7893
 
        if ( f_pVqeConfig->fDtmfToneRemoval != TRUE && f_pVqeConfig->fDtmfToneRemoval != FALSE )
7894
 
                return cOCT6100_ERR_CHANNEL_TONE_REMOVAL;
7895
 
 
7896
 
        if ( f_pVqeConfig->fDtmfToneRemoval == TRUE && pImageInfo->fToneRemoval == FALSE )
7897
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_REMOVAL;
7898
 
 
7899
 
 
7900
 
 
7901
 
        /* Check the Tail displacement enable.*/
7902
 
        if ( f_pVqeConfig->fEnableTailDisplacement != TRUE && f_pVqeConfig->fEnableTailDisplacement != FALSE )
7903
 
                return cOCT6100_ERR_CHANNEL_ENABLE_TAIL_DISPLACEMENT;
7904
 
 
7905
 
        if ( f_pVqeConfig->fEnableTailDisplacement == TRUE && pImageInfo->fTailDisplacement == FALSE )
7906
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_DISPLACEMENT;
7907
 
 
7908
 
        /* Check the Tail displacement value.*/
7909
 
        if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
7910
 
        {
7911
 
                if ( f_pVqeConfig->ulTailDisplacement != cOCT6100_AUTO_SELECT_TAIL )
7912
 
                {
7913
 
                        /* Check if this feature is supported by the image. */
7914
 
                        if ( pImageInfo->fPerChannelTailDisplacement == FALSE )
7915
 
                                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_PER_CHAN_TAIL;
7916
 
 
7917
 
                        /* Check that this value is not greater then what the image supports. */
7918
 
                        if ( f_pVqeConfig->ulTailDisplacement > pImageInfo->usMaxTailDisplacement )
7919
 
                                return cOCT6100_ERR_CHANNEL_TAIL_DISPLACEMENT_INVALID;
7920
 
                }
7921
 
        }
7922
 
 
7923
 
        /* Check the tail length value. */
7924
 
        if ( f_pVqeConfig->ulTailLength != cOCT6100_AUTO_SELECT_TAIL )
7925
 
        {
7926
 
                /* Check if this feature is supported by the image. */
7927
 
                if ( ( pImageInfo->fPerChannelTailLength == FALSE )
7928
 
                        && ( (UINT16)( f_pVqeConfig->ulTailLength & 0xFFFF ) != pImageInfo->usMaxTailLength ) )
7929
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_LENGTH;
7930
 
 
7931
 
                if ( ( f_pVqeConfig->ulTailLength < 32 ) || ( f_pVqeConfig->ulTailLength > 128 ) 
7932
 
                        || ( ( f_pVqeConfig->ulTailLength % 4 ) != 0x0 ) )
7933
 
                        return cOCT6100_ERR_CHANNEL_TAIL_LENGTH;
7934
 
 
7935
 
                /* Check if the requested tail length is supported by the chip. */
7936
 
                if ( f_pVqeConfig->ulTailLength > pImageInfo->usMaxTailLength )
7937
 
                        return cOCT6100_ERR_CHANNEL_TAIL_LENGTH_INVALID;
7938
 
        }
7939
 
 
7940
 
        /* Validate the acoustic echo cancellation parameter.*/
7941
 
        if ( f_pVqeConfig->fAcousticEcho != TRUE && f_pVqeConfig->fAcousticEcho != FALSE )
7942
 
                return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO;
7943
 
 
7944
 
        if ( f_pVqeConfig->fAcousticEcho == TRUE && pImageInfo->fAcousticEcho == FALSE )
7945
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO;
7946
 
 
7947
 
        if ( f_pVqeConfig->fAcousticEcho == TRUE )
7948
 
        {
7949
 
                /* Check if acoustic echo tail length configuration is supported in the image. */
7950
 
                if ( ( f_pVqeConfig->ulAecTailLength != 128 ) && ( pImageInfo->fAecTailLength == FALSE ) )
7951
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH;
7952
 
 
7953
 
                /* Check the requested acoustic echo tail length. */
7954
 
                if ( ( f_pVqeConfig->ulAecTailLength != 128 )
7955
 
                        && ( f_pVqeConfig->ulAecTailLength != 256 ) 
7956
 
                        && ( f_pVqeConfig->ulAecTailLength != 512 )
7957
 
                        && ( f_pVqeConfig->ulAecTailLength != 1024 ) )
7958
 
                        return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH;
7959
 
 
7960
 
                if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
7961
 
                {
7962
 
                        UINT32 ulTailSum;
7963
 
 
7964
 
                        /* Start with requested tail displacement. */
7965
 
                        if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
7966
 
                        {
7967
 
                                ulTailSum = f_pApiInstance->pSharedInfo->ChipConfig.usTailDisplacement;
7968
 
                        }
7969
 
                        else
7970
 
                        {
7971
 
                                ulTailSum = f_pVqeConfig->ulTailDisplacement;
7972
 
                        }
7973
 
 
7974
 
                        /* Add requested tail length. */
7975
 
                        if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
7976
 
                        {
7977
 
                                ulTailSum += f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength;
7978
 
                        }
7979
 
                        else
7980
 
                        {
7981
 
                                ulTailSum += f_pVqeConfig->ulTailLength;
7982
 
                        }
7983
 
 
7984
 
                        /* The tail sum must be smaller then the requested AEC tail length. */
7985
 
                        if ( ulTailSum > f_pVqeConfig->ulAecTailLength )
7986
 
                                return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_SUM;
7987
 
                }
7988
 
        }
7989
 
        
7990
 
        /* Validate the Default ERL parameter.*/
7991
 
        if ( f_pVqeConfig->lDefaultErlDb != -6 && pImageInfo->fDefaultErl == FALSE )
7992
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DEFAULT_ERL;
7993
 
 
7994
 
        if ( ( f_pVqeConfig->lDefaultErlDb != 0 ) && 
7995
 
                ( f_pVqeConfig->lDefaultErlDb != -3 ) && 
7996
 
                ( f_pVqeConfig->lDefaultErlDb != -6 ) &&
7997
 
                ( f_pVqeConfig->lDefaultErlDb != -9 ) &&
7998
 
                ( f_pVqeConfig->lDefaultErlDb != -12 ) )
7999
 
                return cOCT6100_ERR_CHANNEL_DEFAULT_ERL;
8000
 
 
8001
 
        /* Validate the Default AEC ERL parameter.*/
8002
 
        if ( f_pVqeConfig->lAecDefaultErlDb != 0 && pImageInfo->fAecDefaultErl == FALSE )
8003
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_AEC_DEFAULT_ERL;
8004
 
 
8005
 
        if ( f_pVqeConfig->lAecDefaultErlDb != 0 && f_pVqeConfig->lAecDefaultErlDb != -3 && f_pVqeConfig->lAecDefaultErlDb != -6 )
8006
 
                return cOCT6100_ERR_CHANNEL_AEC_DEFAULT_ERL;
8007
 
 
8008
 
        /* Validate the non-linearity A parameter.*/
8009
 
        if ( f_pVqeConfig->ulNonLinearityBehaviorA != 1 && pImageInfo->fNonLinearityBehaviorA == FALSE )
8010
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DOUBLE_TALK;
8011
 
 
8012
 
        if ( f_pVqeConfig->ulNonLinearityBehaviorA >= 14 )
8013
 
                return cOCT6100_ERR_CHANNEL_DOUBLE_TALK;
8014
 
 
8015
 
        /* Validate the non-linearity B parameter.*/
8016
 
        if ( f_pVqeConfig->ulNonLinearityBehaviorB != 0 && pImageInfo->fNonLinearityBehaviorB == FALSE )
8017
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NON_LINEARITY_B;
8018
 
 
8019
 
        if ( f_pVqeConfig->ulNonLinearityBehaviorB >= 9 )
8020
 
                return cOCT6100_ERR_CHANNEL_NON_LINEARITY_B;
8021
 
 
8022
 
        /* Check if configuring the double talk behavior is supported in the firmware. */
8023
 
        if ( f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_NORMAL && pImageInfo->fDoubleTalkBehavior == FALSE )
8024
 
                return cOCT6100_ERR_NOT_SUPPORTED_DOUBLE_TALK_BEHAVIOR_MODE;
8025
 
        
8026
 
        /* Validate the double talk behavior mode parameter. */
8027
 
        if ( f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_NORMAL && f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_LESS_AGGRESSIVE )
8028
 
                return cOCT6100_ERR_CHANNEL_DOUBLE_TALK_MODE;
8029
 
 
8030
 
        /* Validate the Sout automatic listener enhancement ratio. */
8031
 
        if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 && pImageInfo->fListenerEnhancement == FALSE )
8032
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ALE;
8033
 
 
8034
 
        if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb > 30 )
8035
 
                return cOCT6100_ERR_CHANNEL_ALE_RATIO;
8036
 
 
8037
 
        /* Validate the Sout natural listener enhancement ratio. */
8038
 
        if ( f_pVqeConfig->fSoutNaturalListenerEnhancement != TRUE && f_pVqeConfig->fSoutNaturalListenerEnhancement != FALSE )
8039
 
                return cOCT6100_ERR_CHANNEL_NLE_FLAG;
8040
 
 
8041
 
        if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE && pImageInfo->fListenerEnhancement == FALSE )
8042
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLE;
8043
 
 
8044
 
        if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
8045
 
        {
8046
 
                if ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb > 30 )
8047
 
                        return cOCT6100_ERR_CHANNEL_NLE_RATIO;
8048
 
        }
8049
 
 
8050
 
        /* Both ALE and NLE cannot be activated simultaneously. */
8051
 
        if ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 )
8052
 
                && ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE ) )
8053
 
                return cOCT6100_ERR_CHANNEL_ALE_NLE_SIMULTANEOUSLY;
8054
 
        
8055
 
        /* Validate Rout noise reduction. */
8056
 
        if ( f_pVqeConfig->fRoutNoiseReduction != TRUE && f_pVqeConfig->fRoutNoiseReduction != FALSE )
8057
 
                return cOCT6100_ERR_CHANNEL_ROUT_NOISE_REDUCTION;
8058
 
 
8059
 
        /* Check if Rout noise reduction is supported. */
8060
 
        if ( f_pVqeConfig->fRoutNoiseReduction == TRUE && pImageInfo->fRoutNoiseReduction == FALSE )
8061
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ROUT_NR;
8062
 
 
8063
 
        /* Check if ANR SNRE is supported. */
8064
 
        if ( ( f_pVqeConfig->lAnrSnrEnhancementDb != -18 ) && ( pImageInfo->fAnrSnrEnhancement == FALSE ) )
8065
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SNR_ENHANCEMENT;
8066
 
 
8067
 
        /* Validate Sout ANR SNR enhancement. */
8068
 
        if ( ( f_pVqeConfig->lAnrSnrEnhancementDb != -9 )
8069
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -12 ) 
8070
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -15 )
8071
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -18 )
8072
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -21 )
8073
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -24 )
8074
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -27 )
8075
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -30 ) )
8076
 
                return cOCT6100_ERR_CHANNEL_ANR_SNR_ENHANCEMENT;
8077
 
        
8078
 
        /* Validate ANR voice-noise segregation. */
8079
 
        if ( f_pVqeConfig->ulAnrVoiceNoiseSegregation > 15 )
8080
 
                return cOCT6100_ERR_CHANNEL_ANR_SEGREGATION;
8081
 
 
8082
 
        /* Check if ANR VN segregation is supported. */
8083
 
        if ( ( f_pVqeConfig->ulAnrVoiceNoiseSegregation != 6 ) && ( pImageInfo->fAnrVoiceNoiseSegregation == FALSE ) )
8084
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SEGREGATION;
8085
 
 
8086
 
        /* Check if the loaded image supports tone disabler VQE activation delay. */
8087
 
        if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != 300 )
8088
 
                && ( pImageInfo->fToneDisablerVqeActivationDelay == FALSE ) )
8089
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY;
8090
 
 
8091
 
        /* Check if the specified tone disabler VQE activation delay is correct. */
8092
 
        if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay < 300 )
8093
 
                || ( ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay - 300 ) % 512 ) != 0 ) )
8094
 
                return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY;
8095
 
 
8096
 
        /* Check the enable music protection flag. */
8097
 
        if ( ( f_pVqeConfig->fEnableMusicProtection != TRUE ) && ( f_pVqeConfig->fEnableMusicProtection != FALSE ) )
8098
 
                return cOCT6100_ERR_CHANNEL_ENABLE_MUSIC_PROTECTION;
8099
 
 
8100
 
        /* The music protection module can only be activated if the image supports it. */
8101
 
        if ( ( f_pVqeConfig->fEnableMusicProtection == TRUE ) &&
8102
 
                ( pImageInfo->fMusicProtection == FALSE ) )
8103
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_MUSIC_PROTECTION;
8104
 
 
8105
 
        /* Check the enable idle code detection flag. */
8106
 
        if ( ( f_pVqeConfig->fIdleCodeDetection != TRUE ) && ( f_pVqeConfig->fIdleCodeDetection != FALSE ) )
8107
 
                return cOCT6100_ERR_CHANNEL_IDLE_CODE_DETECTION;
8108
 
 
8109
 
        /* The idle code detection module can only be activated if the image supports it. */
8110
 
        if ( ( f_pVqeConfig->fIdleCodeDetection == TRUE ) && ( pImageInfo->fIdleCodeDetection == FALSE ) )
8111
 
                return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION;
8112
 
 
8113
 
        /* The idle code detection module can be disabled only if idle code detection configuration */
8114
 
        /* is supported in the image. */
8115
 
        if ( pImageInfo->fIdleCodeDetection == TRUE )
8116
 
        {
8117
 
                if ( ( f_pVqeConfig->fIdleCodeDetection == FALSE ) && ( pImageInfo->fIdleCodeDetectionConfiguration == FALSE ) )
8118
 
                        return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION_CONFIG;
8119
 
        }
8120
 
 
8121
 
        return cOCT6100_ERR_OK;
8122
 
}
8123
 
#endif
8124
 
 
8125
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8126
 
 
8127
 
Function:               Oct6100ApiCheckCodecConfig
8128
 
 
8129
 
Description:    This function will check the validity of the Codec config parameter
8130
 
                                of an Open Codec config structure.
8131
 
 
8132
 
-------------------------------------------------------------------------------
8133
 
|       Argument                |       Description
8134
 
-------------------------------------------------------------------------------
8135
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
8136
 
                                                the present state of the chip and all its resources.
8137
 
 
8138
 
f_pCodecConfig                  Codec config of the channel.
8139
 
f_ulDecoderNumTssts             Number of TSST for the decoder.
8140
 
f_pusPhasingTsstIndex   Pointer to the Phasing TSST index within the API's phasing TSST list.
8141
 
 
8142
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8143
 
#if !SKIP_Oct6100ApiCheckCodecConfig
8144
 
UINT32 Oct6100ApiCheckCodecConfig( 
8145
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
8146
 
                                IN      tPOCT6100_CHANNEL_OPEN_CODEC    f_pCodecConfig,
8147
 
                                IN  UINT32                                                      f_ulDecoderNumTssts,
8148
 
                                OUT PUINT16                                                     f_pusPhasingTsstIndex )
8149
 
{
8150
 
        
8151
 
        /* Verify the ADPCM nibble value.*/
8152
 
        if ( f_pCodecConfig->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_LOW_BITS && 
8153
 
                 f_pCodecConfig->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_HIGH_BITS )
8154
 
                return cOCT6100_ERR_CHANNEL_ADPCM_NIBBLE;
8155
 
 
8156
 
        /* Verify the Encoder port.*/
8157
 
        if ( f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_ROUT && 
8158
 
                 f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_SOUT &&
8159
 
                 f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
8160
 
                return cOCT6100_ERR_CHANNEL_ENCODER_PORT;
8161
 
        
8162
 
        /* Verify the Decoder port.*/
8163
 
        if ( f_pCodecConfig->ulDecoderPort != cOCT6100_CHANNEL_PORT_RIN && 
8164
 
                 f_pCodecConfig->ulDecoderPort != cOCT6100_CHANNEL_PORT_SIN &&
8165
 
                 f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
8166
 
                return cOCT6100_ERR_CHANNEL_DECODER_PORT;
8167
 
 
8168
 
        /* The codec cannot be on the same stream.*/
8169
 
        if ( f_pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT && 
8170
 
                 f_pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
8171
 
                return cOCT6100_ERR_CHANNEL_INVALID_CODEC_POSITION;
8172
 
 
8173
 
        if ( f_pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT && 
8174
 
                 f_pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN )
8175
 
                return cOCT6100_ERR_CHANNEL_INVALID_CODEC_POSITION;
8176
 
 
8177
 
        /* Verify if the requested functions are supported by the chip.*/
8178
 
        if ( f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm == FALSE &&
8179
 
                 f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
8180
 
        {
8181
 
                if ( f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS )
8182
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ENCODING;
8183
 
        }
8184
 
 
8185
 
        if ( f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm == FALSE &&
8186
 
                 f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
8187
 
        {
8188
 
                if ( f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS )
8189
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DECODING;
8190
 
        }
8191
 
        
8192
 
        /* Check if encoder port has been specified when a rate has been set. */
8193
 
        if ( f_pCodecConfig->ulEncoderPort == cOCT6100_NO_ENCODING && 
8194
 
                f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS )
8195
 
                return cOCT6100_ERR_CHANNEL_ENCODER_PORT;
8196
 
 
8197
 
        /* Check if decoder port has been specified when a rate has been set. */
8198
 
        if ( f_pCodecConfig->ulDecoderPort == cOCT6100_NO_DECODING && 
8199
 
                f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS )
8200
 
                return cOCT6100_ERR_CHANNEL_DECODER_PORT;
8201
 
 
8202
 
        /* Check Encoder related parameter if one is used.*/
8203
 
        if ( f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
8204
 
        {
8205
 
                /* Check the Encoder compression rate.*/
8206
 
                if ( ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G711_64KBPS ) && 
8207
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G726_40KBPS ) &&
8208
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G726_32KBPS ) &&
8209
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G726_24KBPS ) &&
8210
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G726_16KBPS ) &&
8211
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_40KBPS_4_1 ) &&
8212
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_40KBPS_3_2 ) &&
8213
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_40KBPS_2_3 ) &&
8214
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_32KBPS_4_0 ) &&
8215
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_32KBPS_3_1 ) &&
8216
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_32KBPS_2_2 ) &&
8217
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_24KBPS_3_0 ) &&
8218
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_24KBPS_2_1 ) &&
8219
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_16KBPS_2_0 ) )
8220
 
                        return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
8221
 
 
8222
 
                /* Verify phasing information.*/
8223
 
                if ( f_pCodecConfig->ulPhasingType != cOCT6100_SINGLE_PHASING && 
8224
 
                         f_pCodecConfig->ulPhasingType != cOCT6100_DUAL_PHASING &&
8225
 
                         f_pCodecConfig->ulPhasingType != cOCT6100_NO_PHASING )
8226
 
                        return cOCT6100_ERR_CHANNEL_PHASING_TYPE;
8227
 
 
8228
 
                /* Verify the silence suppression parameters.*/
8229
 
                if ( f_pCodecConfig->fEnableSilenceSuppression != TRUE && 
8230
 
                         f_pCodecConfig->fEnableSilenceSuppression != FALSE )
8231
 
                        return cOCT6100_ERR_CHANNEL_SIL_SUP_ENABLE;
8232
 
 
8233
 
                if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8234
 
                         f_pApiInstance->pSharedInfo->ImageInfo.fSilenceSuppression == FALSE )
8235
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIL_SUP;
8236
 
 
8237
 
                if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8238
 
                         f_pCodecConfig->ulPhasingType == cOCT6100_NO_PHASING )
8239
 
                        return cOCT6100_ERR_CHANNEL_PHASE_TYPE_REQUIRED;
8240
 
 
8241
 
                if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8242
 
                         f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE )
8243
 
                        return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED;
8244
 
 
8245
 
                if ( f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE &&
8246
 
                         f_pCodecConfig->ulPhasingType != cOCT6100_NO_PHASING )
8247
 
                        return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED;
8248
 
 
8249
 
                /* Silence suppression can only be performed if the encoder is using the SOUT port.*/
8250
 
                if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8251
 
                         f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_SOUT )
8252
 
                        return cOCT6100_ERR_CHANNEL_SIL_SUP_INVALID_ENCODER_PORT;
8253
 
 
8254
 
                /* Check phasing TSST info if phasing is required.*/
8255
 
                if ( f_pCodecConfig->ulPhasingTsstHndl != cOCT6100_INVALID_HANDLE )
8256
 
                {
8257
 
                        tPOCT6100_API_PHASING_TSST      pPhasingEntry;
8258
 
                        UINT32                                          ulEntryOpenCnt;
8259
 
 
8260
 
                        /* Check the provided handle. */
8261
 
                        if ( (f_pCodecConfig->ulPhasingTsstHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_PHASING_TSST )
8262
 
                                return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
8263
 
 
8264
 
                        *f_pusPhasingTsstIndex = (UINT16)( f_pCodecConfig->ulPhasingTsstHndl & cOCT6100_HNDL_INDEX_MASK );
8265
 
                        if ( *f_pusPhasingTsstIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxPhasingTssts )
8266
 
                                return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
8267
 
 
8268
 
                        mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, *f_pusPhasingTsstIndex );
8269
 
 
8270
 
                        /* Extract the entry open count from the provided handle. */
8271
 
                        ulEntryOpenCnt = (f_pCodecConfig->ulPhasingTsstHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
8272
 
                        
8273
 
                        /* Verify if the state of the phasing TSST.*/
8274
 
                        if ( pPhasingEntry->fReserved != TRUE )
8275
 
                                return cOCT6100_ERR_CHANNEL_PHASING_TSST_NOT_OPEN;
8276
 
                        if ( ulEntryOpenCnt != pPhasingEntry->byEntryOpenCnt )
8277
 
                                return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
8278
 
                        
8279
 
                        /* Check the specified phase value against the phasing length of the phasing TSST.*/
8280
 
                        if ( ( f_pCodecConfig->ulPhase == 0 )
8281
 
                                || ( f_pCodecConfig->ulPhase >= pPhasingEntry->usPhasingLength ) )
8282
 
                                return cOCT6100_ERR_CHANNEL_PHASING_INVALID_PHASE;
8283
 
                }
8284
 
                else
8285
 
                {
8286
 
                        *f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX;
8287
 
                }
8288
 
        }
8289
 
        else
8290
 
        {
8291
 
                *f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX;
8292
 
        }
8293
 
 
8294
 
 
8295
 
        /* Check Decoder related parameter if one is used.*/
8296
 
        if ( f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
8297
 
        {
8298
 
                /* Check the Decoding rate.*/
8299
 
                if ( f_pCodecConfig->ulDecodingRate  != cOCT6100_G711_64KBPS &&
8300
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G726_40KBPS &&
8301
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G726_32KBPS &&
8302
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G726_24KBPS &&
8303
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G726_16KBPS &&
8304
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G726_ENCODED &&
8305
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G711_G726_ENCODED &&
8306
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G727_2C_ENCODED &&
8307
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G727_3C_ENCODED &&
8308
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G727_4C_ENCODED &&
8309
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G711_G727_2C_ENCODED &&
8310
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G711_G727_3C_ENCODED &&
8311
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G711_G727_4C_ENCODED )
8312
 
                        return cOCT6100_ERR_CHANNEL_DECODING_RATE;
8313
 
 
8314
 
                /* Make sure that two timeslot are allocated if PCM-ECHO encoded is selected.*/
8315
 
                if ( (f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G726_ENCODED ||
8316
 
                          f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_2C_ENCODED ||
8317
 
                          f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_3C_ENCODED ||
8318
 
                          f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_4C_ENCODED ) &&
8319
 
                          f_ulDecoderNumTssts != 2 )
8320
 
                        return cOCT6100_ERR_CHANNEL_MISSING_TSST;
8321
 
        }
8322
 
 
8323
 
        return cOCT6100_ERR_OK;
8324
 
}
8325
 
#endif
8326
 
 
8327
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8328
 
 
8329
 
Function:               Oct6100ApiWriteInputTsstControlMemory
8330
 
 
8331
 
Description:    This function configure a TSST control memory entry in internal memory.
8332
 
 
8333
 
-------------------------------------------------------------------------------
8334
 
|       Argument                |       Description
8335
 
-------------------------------------------------------------------------------
8336
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
8337
 
                                                the present state of the chip and all its resources.
8338
 
 
8339
 
f_usTsstIndex                   TSST index within the TSST control memory.
8340
 
f_usTsiMemIndex                 TSI index within the TSI chariot memory.
8341
 
f_ulTsstInputLaw                PCM law of the input TSST.
8342
 
 
8343
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8344
 
#if !SKIP_Oct6100ApiWriteInputTsstControlMemory
8345
 
UINT32 Oct6100ApiWriteInputTsstControlMemory( 
8346
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
8347
 
                                IN      UINT16                                                  f_usTsstIndex,
8348
 
                                IN      UINT16                                                  f_usTsiMemIndex,
8349
 
                                IN      UINT32                                                  f_ulTsstInputLaw )
8350
 
{
8351
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
8352
 
        UINT32                                                  ulResult;
8353
 
 
8354
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8355
 
 
8356
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8357
 
 
8358
 
        WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
8359
 
        
8360
 
        WriteParams.usWriteData  = cOCT6100_TSST_CONTROL_MEM_INPUT_TSST;
8361
 
        WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8362
 
 
8363
 
        /* Set the PCM law.*/
8364
 
        WriteParams.usWriteData |= f_ulTsstInputLaw << cOCT6100_TSST_CONTROL_MEM_PCM_LAW_OFFSET;
8365
 
 
8366
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8367
 
        if ( ulResult != cOCT6100_ERR_OK  )
8368
 
                return ulResult;
8369
 
 
8370
 
        return cOCT6100_ERR_OK;
8371
 
}
8372
 
#endif
8373
 
 
8374
 
 
8375
 
 
8376
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8377
 
 
8378
 
Function:               Oct6100ApiWriteOutputTsstControlMemory
8379
 
 
8380
 
Description:    This function configure a TSST control memory entry in internal memory.
8381
 
 
8382
 
-------------------------------------------------------------------------------
8383
 
|       Argument                |       Description
8384
 
-------------------------------------------------------------------------------
8385
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
8386
 
                                                the present state of the chip and all its resources.
8387
 
 
8388
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8389
 
#if !SKIP_Oct6100ApiWriteOutputTsstControlMemory
8390
 
UINT32 Oct6100ApiWriteOutputTsstControlMemory( 
8391
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
8392
 
                                IN      UINT16                                                  f_usTsstIndex,
8393
 
                                IN      UINT32                                                  f_ulAdpcmNibblePosition,
8394
 
                                IN      UINT32                                                  f_ulNumTssts,
8395
 
                                IN      UINT16                                                  f_usTsiMemIndex )
8396
 
{
8397
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
8398
 
        UINT32                                                  ulResult;
8399
 
 
8400
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8401
 
 
8402
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8403
 
 
8404
 
        WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
8405
 
        
8406
 
        WriteParams.usWriteData  = cOCT6100_TSST_CONTROL_MEM_OUTPUT_TSST;
8407
 
        WriteParams.usWriteData |= f_ulAdpcmNibblePosition << cOCT6100_TSST_CONTROL_MEM_NIBBLE_POS_OFFSET;
8408
 
        WriteParams.usWriteData |= (f_ulNumTssts - 1) << cOCT6100_TSST_CONTROL_MEM_TSST_NUM_OFFSET;
8409
 
        WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8410
 
 
8411
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8412
 
        if ( ulResult != cOCT6100_ERR_OK  )
8413
 
                return ulResult;
8414
 
 
8415
 
        return cOCT6100_ERR_OK;
8416
 
}
8417
 
#endif
8418
 
 
8419
 
 
8420
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8421
 
 
8422
 
Function:               Oct6100ApiWriteEncoderMemory
8423
 
 
8424
 
Description:    This function configure a Encoded memory entry in internal memory.
8425
 
 
8426
 
-------------------------------------------------------------------------------
8427
 
|       Argument                |       Description
8428
 
-------------------------------------------------------------------------------
8429
 
f_pApiInstance                                  Pointer to API instance. This memory is used to keep
8430
 
                                                                the present state of the chip and all its resources.
8431
 
 
8432
 
f_ulEncoderIndex                                Index of the encoder block within the ADPCM context memory.
8433
 
f_ulCompType                                    Compression rate of the encoder.
8434
 
f_usTsiMemIndex                                 TSI index within the TSI chariot memory used by the encoder.
8435
 
f_ulEnableSilenceSuppression    Silence suppression enable flag.
8436
 
f_ulAdpcmNibblePosition                 ADPCM nibble position.
8437
 
f_usPhasingTsstIndex                    Phasing TSST index within the API's Phassing TSST list.
8438
 
f_ulPhasingType                                 Type of the Phasing TSST.
8439
 
f_ulPhase                                               Phase used with this encoder.
8440
 
 
8441
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8442
 
#if !SKIP_Oct6100ApiWriteEncoderMemory
8443
 
UINT32 Oct6100ApiWriteEncoderMemory( 
8444
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
8445
 
                                IN      UINT32                                                  f_ulEncoderIndex,
8446
 
                                IN      UINT32                                                  f_ulCompType,
8447
 
                                IN      UINT16                                                  f_usTsiMemIndex,
8448
 
                                IN      UINT32                                                  f_ulEnableSilenceSuppression,
8449
 
                                IN      UINT32                                                  f_ulAdpcmNibblePosition,
8450
 
                                IN  UINT16                                                      f_usPhasingTsstIndex,
8451
 
                                IN      UINT32                                                  f_ulPhasingType,
8452
 
                                IN      UINT32                                                  f_ulPhase )
8453
 
{
8454
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
8455
 
        UINT32                                                  ulResult;
8456
 
 
8457
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8458
 
 
8459
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8460
 
 
8461
 
        /*==============================================================================*/
8462
 
        /* Conversion Control Base */
8463
 
        WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_ulEncoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
8464
 
        
8465
 
        WriteParams.usWriteData  = cOCT6100_CONVERSION_CONTROL_MEM_ENCODER;
8466
 
        WriteParams.usWriteData |= f_ulCompType << cOCT6100_CONVERSION_CONTROL_MEM_COMP_OFFSET;
8467
 
        WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8468
 
 
8469
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8470
 
        if ( ulResult != cOCT6100_ERR_OK  )
8471
 
                return ulResult;
8472
 
        
8473
 
        /*==============================================================================*/
8474
 
        /* Conversion Control Base + 2 */
8475
 
        WriteParams.ulWriteAddress += 2;
8476
 
 
8477
 
        /* Set the phasing TSST number.*/
8478
 
        if ( f_usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
8479
 
                WriteParams.usWriteData = (UINT16)( f_usPhasingTsstIndex << cOCT6100_CONVERSION_CONTROL_MEM_PHASE_OFFSET );
8480
 
        else
8481
 
                WriteParams.usWriteData = 0;
8482
 
        
8483
 
        /* Set the phasing type and the phase value if required.*/
8484
 
        switch( f_ulPhasingType )
8485
 
        {
8486
 
        case cOCT6100_NO_PHASING:
8487
 
                WriteParams.usWriteData |= 0x1 << 10;
8488
 
                break;
8489
 
        case cOCT6100_SINGLE_PHASING:
8490
 
                WriteParams.usWriteData |= f_ulPhase;
8491
 
                break;
8492
 
        case cOCT6100_DUAL_PHASING:
8493
 
                WriteParams.usWriteData |= 0x1 << 11;
8494
 
                WriteParams.usWriteData |= f_ulPhase;
8495
 
                break;
8496
 
        default:
8497
 
                /* No problem. */
8498
 
                break;
8499
 
        }
8500
 
 
8501
 
        /* Set the silence suppression flag.*/
8502
 
        WriteParams.usWriteData |= f_ulEnableSilenceSuppression << cOCT6100_CONVERSION_CONTROL_MEM_SIL_SUP_OFFSET;
8503
 
 
8504
 
        /* Set the nibble position.*/
8505
 
        WriteParams.usWriteData |= f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET;
8506
 
        
8507
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8508
 
        if ( ulResult != cOCT6100_ERR_OK  )
8509
 
                return ulResult;
8510
 
 
8511
 
        /*==============================================================================*/
8512
 
        /* Conversion Control Base + 4 */
8513
 
        WriteParams.ulWriteAddress += 2;
8514
 
                
8515
 
        /* Set the reset mode */
8516
 
        WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR;
8517
 
 
8518
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8519
 
        if ( ulResult != cOCT6100_ERR_OK  )
8520
 
                return ulResult;
8521
 
 
8522
 
        /*==============================================================================*/
8523
 
        /* Conversion Control Base + 6 */
8524
 
        WriteParams.ulWriteAddress += 2;
8525
 
                
8526
 
        /* Set the reset mode */
8527
 
        WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY;
8528
 
 
8529
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8530
 
        if ( ulResult != cOCT6100_ERR_OK  )
8531
 
                return ulResult;
8532
 
 
8533
 
        /*==============================================================================*/
8534
 
        return cOCT6100_ERR_OK;
8535
 
}
8536
 
#endif
8537
 
 
8538
 
 
8539
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8540
 
 
8541
 
Function:               Oct6100ApiWriteDecoderMemory
8542
 
 
8543
 
Description:    This function configure a Decoder memory entry in internal memory.
8544
 
 
8545
 
-------------------------------------------------------------------------------
8546
 
|       Argument                |       Description
8547
 
-------------------------------------------------------------------------------
8548
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
8549
 
                                                the present state of the chip and all its resources.
8550
 
 
8551
 
f_usDecoderIndex                Index of the decoder block within the ADPCM context memory.
8552
 
f_ulCompType                    Decompression rate of the decoder.
8553
 
f_usTsiMemIndex                 TSI index within the TSI chariot memory.
8554
 
f_ulPcmLaw                              PCM law of the decoded samples.
8555
 
f_ulAdpcmNibblePosition ADPCM nibble position.
8556
 
 
8557
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8558
 
#if !SKIP_Oct6100ApiWriteDecoderMemory
8559
 
UINT32 Oct6100ApiWriteDecoderMemory( 
8560
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
8561
 
                                IN      UINT16                                                  f_usDecoderIndex,
8562
 
                                IN      UINT32                                                  f_ulCompType,
8563
 
                                IN      UINT16                                                  f_usTsiMemIndex,
8564
 
                                IN      UINT32                                                  f_ulPcmLaw,
8565
 
                                IN      UINT32                                                  f_ulAdpcmNibblePosition )
8566
 
{
8567
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
8568
 
        UINT32                                                  ulResult;
8569
 
 
8570
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8571
 
 
8572
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8573
 
 
8574
 
 
8575
 
        /*==============================================================================*/
8576
 
        /* Conversion Control Base */
8577
 
        WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_usDecoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
8578
 
        
8579
 
        WriteParams.usWriteData  = cOCT6100_CONVERSION_CONTROL_MEM_DECODER;
8580
 
        WriteParams.usWriteData |= f_ulCompType << cOCT6100_CONVERSION_CONTROL_MEM_COMP_OFFSET;
8581
 
        WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8582
 
 
8583
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8584
 
        if ( ulResult != cOCT6100_ERR_OK  )
8585
 
                return ulResult;
8586
 
        
8587
 
        /*==============================================================================*/
8588
 
        /* Conversion Control Base + 2 */
8589
 
        WriteParams.ulWriteAddress += 2;
8590
 
 
8591
 
        /* Set the nibble position.*/
8592
 
        WriteParams.usWriteData = (UINT16)( f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET );
8593
 
 
8594
 
        /* Set the law.*/
8595
 
        WriteParams.usWriteData |= f_ulPcmLaw << cOCT6100_CONVERSION_CONTROL_MEM_LAW_OFFSET;
8596
 
        
8597
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8598
 
        if ( ulResult != cOCT6100_ERR_OK  )
8599
 
                return ulResult;
8600
 
 
8601
 
        /*==============================================================================*/
8602
 
        /* Conversion Control Base + 4 */
8603
 
        WriteParams.ulWriteAddress += 2;
8604
 
                
8605
 
        /* Set the reset mode */
8606
 
        WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR;
8607
 
 
8608
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8609
 
        if ( ulResult != cOCT6100_ERR_OK  )
8610
 
                return ulResult;
8611
 
 
8612
 
        /*==============================================================================*/
8613
 
        /* Conversion Control Base + 6 */
8614
 
        WriteParams.ulWriteAddress += 2;
8615
 
                
8616
 
        /* Set the reset mode */
8617
 
        WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY;
8618
 
 
8619
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8620
 
        if ( ulResult != cOCT6100_ERR_OK  )
8621
 
                return ulResult;
8622
 
 
8623
 
        return cOCT6100_ERR_OK;
8624
 
}
8625
 
#endif
8626
 
 
8627
 
 
8628
 
 
8629
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8630
 
 
8631
 
Function:               Oct6100ApiClearConversionMemory
8632
 
 
8633
 
Description:    This function clears a conversion memory entry in internal 
8634
 
                                memory.
8635
 
 
8636
 
-------------------------------------------------------------------------------
8637
 
|       Argument                |       Description
8638
 
-------------------------------------------------------------------------------
8639
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep 
8640
 
                                                the present state of the chip and all its resources.
8641
 
 
8642
 
f_usConversionMemIndex  Index of the block within the conversion memory.
8643
 
 
8644
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8645
 
#if !SKIP_Oct6100ApiClearConversionMemory
8646
 
UINT32 Oct6100ApiClearConversionMemory( 
8647
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
8648
 
                                IN      UINT16                                                  f_usConversionMemIndex )
8649
 
{
8650
 
        tOCT6100_WRITE_PARAMS           WriteParams;
8651
 
        tOCT6100_READ_PARAMS            ReadParams;
8652
 
        UINT32                                          ulResult;
8653
 
        UINT32                                          ulBaseAddress;
8654
 
        UINT16                                          usReadData;
8655
 
 
8656
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8657
 
 
8658
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8659
 
        WriteParams.usWriteData = 0;
8660
 
 
8661
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
8662
 
 
8663
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8664
 
        ReadParams.pusReadData = &usReadData;
8665
 
 
8666
 
        /*==============================================================================*/
8667
 
        /* Clear the entry */
8668
 
        ulBaseAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_usConversionMemIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
8669
 
        /* The "activate" bit at offset +6 must be cleared first. */
8670
 
        WriteParams.ulWriteAddress = ulBaseAddress + 6;
8671
 
 
8672
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8673
 
        if ( ulResult != cOCT6100_ERR_OK  )
8674
 
                return ulResult;
8675
 
        
8676
 
        /* Read at 0x200 to make sure there is no corruption on channel 0. */
8677
 
        ReadParams.ulReadAddress = 0x200;
8678
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
8679
 
        if ( ulResult != cOCT6100_ERR_OK  )
8680
 
                return ulResult;        
8681
 
 
8682
 
        /* Then clear the rest of the structure. */
8683
 
        WriteParams.ulWriteAddress = ulBaseAddress + 4;
8684
 
 
8685
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8686
 
        if ( ulResult != cOCT6100_ERR_OK  )
8687
 
                return ulResult;
8688
 
 
8689
 
        WriteParams.ulWriteAddress = ulBaseAddress + 2;
8690
 
 
8691
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8692
 
        if ( ulResult != cOCT6100_ERR_OK  )
8693
 
                return ulResult;
8694
 
 
8695
 
        WriteParams.ulWriteAddress = ulBaseAddress;
8696
 
 
8697
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8698
 
        if ( ulResult != cOCT6100_ERR_OK  )
8699
 
                return ulResult;
8700
 
        
8701
 
        /*==============================================================================*/
8702
 
        
8703
 
        return cOCT6100_ERR_OK;
8704
 
}
8705
 
#endif
8706
 
 
8707
 
 
8708
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8709
 
 
8710
 
Function:               Oct6100ApiWriteVqeMemory
8711
 
 
8712
 
Description:    This function configure an echo memory entry in internal memory and
8713
 
                                external memory.
8714
 
 
8715
 
-------------------------------------------------------------------------------
8716
 
|       Argument                |       Description
8717
 
-------------------------------------------------------------------------------
8718
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
8719
 
                                                        the present state of the chip and all its resources.
8720
 
 
8721
 
f_pVqeConfig                            Pointer to a VQE config structure.
8722
 
f_pChannelOpen                          Pointer to a channel configuration structure.
8723
 
f_usChanIndex                           Index of the echo channel in the API instance.
8724
 
f_usEchoMemIndex                        Index of the echo channel within the SSPX memory.
8725
 
f_fClearPlayoutPointers         Flag indicating if the playout pointer should be cleared.
8726
 
f_fModifyOnly                           Flag indicating if the configuration should be
8727
 
                                                        modified only.
8728
 
 
8729
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8730
 
#if !SKIP_Oct6100ApiWriteVqeMemory
8731
 
UINT32 Oct6100ApiWriteVqeMemory( 
8732
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
8733
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE              f_pVqeConfig,
8734
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen,
8735
 
                                IN      UINT16                                                  f_usChanIndex,
8736
 
                                IN      UINT16                                                  f_usEchoMemIndex,
8737
 
                                IN      BOOL                                                    f_fClearPlayoutPointers,
8738
 
                                IN      BOOL                                                    f_fModifyOnly )
8739
 
{
8740
 
        UINT32  ulResult;
8741
 
 
8742
 
        /* Write the NLP software configuration structure. */
8743
 
        ulResult = Oct6100ApiWriteVqeNlpMemory(
8744
 
                                                        f_pApiInstance,
8745
 
                                                        f_pVqeConfig,
8746
 
                                                        f_pChannelOpen,
8747
 
                                                        f_usChanIndex,
8748
 
                                                        f_usEchoMemIndex,
8749
 
                                                        f_fClearPlayoutPointers,
8750
 
                                                        f_fModifyOnly );
8751
 
        if ( ulResult != cOCT6100_ERR_OK )
8752
 
                return ulResult;
8753
 
 
8754
 
        /* Write the AF software configuration structure. */
8755
 
        ulResult = Oct6100ApiWriteVqeAfMemory(
8756
 
                                                        f_pApiInstance,
8757
 
                                                        f_pVqeConfig,
8758
 
                                                        f_pChannelOpen,
8759
 
                                                        f_usChanIndex,
8760
 
                                                        f_usEchoMemIndex,
8761
 
                                                        f_fClearPlayoutPointers,
8762
 
                                                        f_fModifyOnly );
8763
 
        if ( ulResult != cOCT6100_ERR_OK )
8764
 
                return ulResult;
8765
 
 
8766
 
        return cOCT6100_ERR_OK;
8767
 
}
8768
 
#endif
8769
 
 
8770
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8771
 
 
8772
 
Function:               Oct6100ApiWriteVqeNlpMemory
8773
 
 
8774
 
Description:    This function configures the NLP related VQE features of an 
8775
 
                                echo channel.
8776
 
 
8777
 
-------------------------------------------------------------------------------
8778
 
|       Argument                |       Description
8779
 
-------------------------------------------------------------------------------
8780
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
8781
 
                                                        the present state of the chip and all its resources.
8782
 
 
8783
 
f_pVqeConfig                            Pointer to a VQE config structure.
8784
 
f_pChannelOpen                          Pointer to a channel configuration structure.
8785
 
f_usChanIndex                           Index of the echo channel in the API instance.
8786
 
f_usEchoMemIndex                        Index of the echo channel within the SSPX memory.
8787
 
f_fClearPlayoutPointers         Flag indicating if the playout pointer should be cleared.
8788
 
f_fModifyOnly                           Flag indicating if the configuration should be
8789
 
                                                        modified only.
8790
 
 
8791
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8792
 
#if !SKIP_Oct6100ApiWriteVqeNlpMemory
8793
 
UINT32 Oct6100ApiWriteVqeNlpMemory( 
8794
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
8795
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE              f_pVqeConfig,
8796
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen,
8797
 
                                IN      UINT16                                                  f_usChanIndex,
8798
 
                                IN      UINT16                                                  f_usEchoMemIndex,
8799
 
                                IN      BOOL                                                    f_fClearPlayoutPointers,
8800
 
                                IN      BOOL                                                    f_fModifyOnly )
8801
 
{
8802
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
8803
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
8804
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
8805
 
        tOCT6100_BUFFER_PLAYOUT_STOP    BufferPlayoutStop;
8806
 
        UINT32                                                  ulResult;
8807
 
        UINT32                                                  ulTempData;
8808
 
        UINT32                                                  ulNlpConfigBaseAddress;
8809
 
        UINT32                                                  ulFeatureBytesOffset;
8810
 
        UINT32                                                  ulFeatureBitOffset;
8811
 
        UINT32                                                  ulFeatureFieldLength;
8812
 
        UINT32                                                  ulMask;
8813
 
        UINT16                                                  usTempData;
8814
 
        BOOL                                                    fEchoOperationModeChanged;
8815
 
        
8816
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
8817
 
 
8818
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8819
 
 
8820
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
8821
 
 
8822
 
        /* Obtain a pointer to the new buffer's list entry. */
8823
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
8824
 
 
8825
 
        /*==============================================================================*/
8826
 
        /*      Configure the CPU NLP configuration of the channel feature by feature.*/
8827
 
 
8828
 
        ulNlpConfigBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
8829
 
        
8830
 
        /* Set initial value to zero.*/
8831
 
        ulTempData = 0;
8832
 
 
8833
 
        /* Configure Adaptive Noise Reduction.*/
8834
 
        if ( pSharedInfo->ImageInfo.fAdaptiveNoiseReduction == TRUE )
8835
 
        {
8836
 
                /* Check if the configuration has been changed. */
8837
 
                if ( ( f_fModifyOnly == FALSE ) 
8838
 
                        || ( ( f_fModifyOnly == TRUE ) 
8839
 
                                && ( ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction ) 
8840
 
                                        || ( f_pVqeConfig->fSoutNoiseBleaching != pChanEntry->VqeConfig.fSoutNoiseBleaching )
8841
 
                                        ) ) )
8842
 
                {
8843
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.usDwordOffset * 4;
8844
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byBitOffset;
8845
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byFieldSize;
8846
 
 
8847
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
8848
 
                                                                                                pChanEntry,
8849
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8850
 
                                                                                                &ulTempData, 
8851
 
                                                                                                ulResult );
8852
 
                        if ( ulResult != cOCT6100_ERR_OK )
8853
 
                                return ulResult;
8854
 
                        
8855
 
                        /* Clear previous value set in the feature field.*/
8856
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8857
 
 
8858
 
                        ulTempData &= (~ulMask);
8859
 
 
8860
 
                        /* Set adaptive noise reduction on the SOUT port.*/
8861
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutAdaptiveNoiseReduction ) << ulFeatureBitOffset );
8862
 
 
8863
 
                        /* If SOUT noise bleaching is requested, ANR must be activated. */
8864
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutNoiseBleaching ) << ulFeatureBitOffset );
8865
 
 
8866
 
                        /* First read the DWORD where the field is located. */
8867
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
8868
 
                                                                                        pChanEntry,
8869
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8870
 
                                                                                        ulTempData,
8871
 
                                                                                        ulResult );
8872
 
                        if ( ulResult != cOCT6100_ERR_OK )
8873
 
                                return ulResult;        
8874
 
                }
8875
 
        }
8876
 
 
8877
 
        /* Configure Rout Noise Reduction. */
8878
 
        if ( pSharedInfo->ImageInfo.fRoutNoiseReduction == TRUE )
8879
 
        {
8880
 
                /* Check if the configuration has been changed. */
8881
 
                if ( ( f_fModifyOnly == FALSE )
8882
 
                        || ( ( f_fModifyOnly == TRUE ) 
8883
 
                                && ( f_pVqeConfig->fRoutNoiseReduction != pChanEntry->VqeConfig.fRoutNoiseReduction ) ) )
8884
 
                {
8885
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAnrOfst.usDwordOffset * 4;
8886
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.RinAnrOfst.byBitOffset;
8887
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAnrOfst.byFieldSize;
8888
 
 
8889
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
8890
 
                                                                                                pChanEntry,
8891
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8892
 
                                                                                                &ulTempData,
8893
 
                                                                                                ulResult );
8894
 
                        if ( ulResult != cOCT6100_ERR_OK )
8895
 
                                return ulResult;
8896
 
                        
8897
 
                        /* Clear previous value set in the feature field.*/
8898
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8899
 
 
8900
 
                        ulTempData &= (~ulMask);
8901
 
 
8902
 
                        /* Set noise reduction on the Rout port. */
8903
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fRoutNoiseReduction ) << ulFeatureBitOffset );
8904
 
 
8905
 
                        /* Write the new DWORD where the field is located. */
8906
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
8907
 
                                                                                        pChanEntry,
8908
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8909
 
                                                                                        ulTempData,
8910
 
                                                                                        ulResult );
8911
 
                        if ( ulResult != cOCT6100_ERR_OK )
8912
 
                                return ulResult;        
8913
 
                }
8914
 
        }
8915
 
 
8916
 
        /* Configure Sout ANR SNR enhancement. */
8917
 
        if ( pSharedInfo->ImageInfo.fAnrSnrEnhancement == TRUE )
8918
 
        {
8919
 
                /* Check if the configuration has been changed. */
8920
 
                if ( ( f_fModifyOnly == FALSE )
8921
 
                        || ( ( f_fModifyOnly == TRUE ) 
8922
 
                                && ( f_pVqeConfig->lAnrSnrEnhancementDb != pChanEntry->VqeConfig.chAnrSnrEnhancementDb ) ) )
8923
 
                {
8924
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.usDwordOffset * 4;
8925
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byBitOffset;
8926
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byFieldSize;
8927
 
 
8928
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
8929
 
                                                                                                pChanEntry,
8930
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8931
 
                                                                                                &ulTempData,
8932
 
                                                                                                ulResult );
8933
 
                        if ( ulResult != cOCT6100_ERR_OK )
8934
 
                                return ulResult;
8935
 
                        
8936
 
                        /* Clear previous value set in the feature field.*/
8937
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8938
 
 
8939
 
                        ulTempData &= (~ulMask);
8940
 
 
8941
 
                        /* Set ANR SNR enhancement on the Sout port. */
8942
 
                        switch( f_pVqeConfig->lAnrSnrEnhancementDb )
8943
 
                        {
8944
 
                        case -9:        ulTempData |= ( 7 << ulFeatureBitOffset );
8945
 
                                break;
8946
 
                        case -12:       ulTempData |= ( 6 << ulFeatureBitOffset );
8947
 
                                break;
8948
 
                        case -15:       ulTempData |= ( 5 << ulFeatureBitOffset );
8949
 
                                break;
8950
 
                        case -21:       ulTempData |= ( 3 << ulFeatureBitOffset );
8951
 
                                break;
8952
 
                        case -24:       ulTempData |= ( 2 << ulFeatureBitOffset );
8953
 
                                break;
8954
 
                        case -27:       ulTempData |= ( 1 << ulFeatureBitOffset );
8955
 
                                break;
8956
 
                        case -30:       ulTempData |= ( 0 << ulFeatureBitOffset );
8957
 
                                break;
8958
 
                        default:        ulTempData |= ( 4 << ulFeatureBitOffset );
8959
 
                                /* -18 */
8960
 
                                break;
8961
 
                        }
8962
 
 
8963
 
                        /* Write the new DWORD where the field is located. */
8964
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
8965
 
                                                                                        pChanEntry,
8966
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8967
 
                                                                                        ulTempData,
8968
 
                                                                                        ulResult );
8969
 
                        if ( ulResult != cOCT6100_ERR_OK )
8970
 
                                return ulResult;        
8971
 
                }
8972
 
        }
8973
 
 
8974
 
        /* Configure Sout ANR voice-noise segregation. */
8975
 
        if ( pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation == TRUE )
8976
 
        {
8977
 
                /* Check if the configuration has been changed. */
8978
 
                if ( ( f_fModifyOnly == FALSE )
8979
 
                        || ( ( f_fModifyOnly == TRUE ) 
8980
 
                                && ( f_pVqeConfig->ulAnrVoiceNoiseSegregation != pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation ) ) )
8981
 
                {
8982
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.usDwordOffset * 4;
8983
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byBitOffset;
8984
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byFieldSize;
8985
 
 
8986
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
8987
 
                                                                                                pChanEntry,
8988
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8989
 
                                                                                                &ulTempData,
8990
 
                                                                                                ulResult );
8991
 
                        if ( ulResult != cOCT6100_ERR_OK )
8992
 
                                return ulResult;
8993
 
                        
8994
 
                        /* Clear previous value set in the feature field.*/
8995
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8996
 
 
8997
 
                        ulTempData &= (~ulMask);
8998
 
 
8999
 
                        /* Set ANR voice-noise segregation on the Sout port. */
9000
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->ulAnrVoiceNoiseSegregation ) << ulFeatureBitOffset );
9001
 
 
9002
 
                        /* Write the new DWORD where the field is located. */
9003
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9004
 
                                                                                        pChanEntry,
9005
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9006
 
                                                                                        ulTempData,
9007
 
                                                                                        ulResult );
9008
 
                        if ( ulResult != cOCT6100_ERR_OK )
9009
 
                                return ulResult;        
9010
 
                }
9011
 
        }
9012
 
 
9013
 
        /* Configure the tone disabler VQE activation delay. */
9014
 
        if ( pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay == TRUE )
9015
 
        {
9016
 
                /* Check if the configuration has been changed. */
9017
 
                if ( ( f_fModifyOnly == FALSE )
9018
 
                        || ( ( f_fModifyOnly == TRUE ) 
9019
 
                                && ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay ) 
9020
 
                                        || ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) ) ) )
9021
 
                {
9022
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.usDwordOffset * 4;
9023
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byBitOffset;
9024
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byFieldSize;
9025
 
 
9026
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9027
 
                                                                                                pChanEntry,
9028
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9029
 
                                                                                                &ulTempData,
9030
 
                                                                                                ulResult );
9031
 
                        if ( ulResult != cOCT6100_ERR_OK )
9032
 
                                return ulResult;
9033
 
                        
9034
 
                        /* Clear previous value set in the feature field.*/
9035
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9036
 
 
9037
 
                        ulTempData &= (~ulMask);
9038
 
 
9039
 
                        /* Set the tone disabler VQE activation delay.  The VQE activation delay */
9040
 
                        /* is only set if the tone disabler is activated. */
9041
 
                        if ( f_pChannelOpen->fEnableToneDisabler == TRUE )
9042
 
                                ulTempData |= ( ( (UINT32)( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay - 300 ) / 512 ) ) << ulFeatureBitOffset );
9043
 
                        else
9044
 
                                ulTempData |= ( 0 ) << ulFeatureBitOffset;
9045
 
 
9046
 
                        /* Write the new DWORD where the field is located. */
9047
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9048
 
                                                                                        pChanEntry,
9049
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9050
 
                                                                                        ulTempData,
9051
 
                                                                                        ulResult );
9052
 
                        if ( ulResult != cOCT6100_ERR_OK )
9053
 
                                return ulResult;        
9054
 
                }
9055
 
        }
9056
 
 
9057
 
        /* Configure Conferencing Noise Reduction.*/
9058
 
        if ( pSharedInfo->ImageInfo.fConferencingNoiseReduction == TRUE )
9059
 
        {
9060
 
                /* Check if the configuration has been changed. */
9061
 
                if ( ( f_fModifyOnly == FALSE )
9062
 
                        || ( ( f_fModifyOnly == TRUE ) 
9063
 
                                && ( ( f_pVqeConfig->fSoutConferencingNoiseReduction != pChanEntry->VqeConfig.fSoutConferencingNoiseReduction ) 
9064
 
                                        || ( f_pVqeConfig->fSoutNoiseBleaching != pChanEntry->VqeConfig.fSoutNoiseBleaching ) ) ) )
9065
 
                {
9066
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.usDwordOffset * 4;
9067
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byBitOffset;
9068
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byFieldSize;
9069
 
 
9070
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9071
 
                                                                                                pChanEntry,
9072
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9073
 
                                                                                                &ulTempData,
9074
 
                                                                                                ulResult );
9075
 
                        if ( ulResult != cOCT6100_ERR_OK )
9076
 
                                return ulResult;
9077
 
                        
9078
 
                        /* Clear previous value set in the feature field.*/
9079
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9080
 
 
9081
 
                        ulTempData &= (~ulMask);
9082
 
 
9083
 
                        /* Set conferencing noise reduction on the SOUT port. */
9084
 
                        ulTempData |= (f_pVqeConfig->fSoutConferencingNoiseReduction << ulFeatureBitOffset );
9085
 
 
9086
 
                        /* If SOUT noise bleaching is requested, CNR must be activated. */
9087
 
                        ulTempData |= (f_pVqeConfig->fSoutNoiseBleaching << ulFeatureBitOffset );
9088
 
 
9089
 
                        /* Save the DWORD where the field is located. */
9090
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9091
 
                                                                                        pChanEntry,
9092
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9093
 
                                                                                        ulTempData,
9094
 
                                                                                        ulResult );
9095
 
                        if ( ulResult != cOCT6100_ERR_OK )
9096
 
                                return ulResult;
9097
 
                }
9098
 
        }
9099
 
        
9100
 
        /* Set the DC removal on RIN ports.*/
9101
 
        if ( pSharedInfo->ImageInfo.fRinDcOffsetRemoval == TRUE )
9102
 
        {
9103
 
                /* Check if the configuration has been changed. */
9104
 
                if ( ( f_fModifyOnly == FALSE )
9105
 
                        || ( ( f_fModifyOnly == TRUE ) 
9106
 
                                && ( f_pVqeConfig->fRinDcOffsetRemoval != pChanEntry->VqeConfig.fRinDcOffsetRemoval ) ) )
9107
 
                {
9108
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.usDwordOffset * 4;
9109
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byBitOffset;
9110
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byFieldSize;
9111
 
 
9112
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9113
 
                                                                                                pChanEntry,
9114
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9115
 
                                                                                                &ulTempData, 
9116
 
                                                                                                ulResult );
9117
 
                        if ( ulResult != cOCT6100_ERR_OK )
9118
 
                                return ulResult;
9119
 
 
9120
 
                        /* Clear previous value set in the feature field.*/
9121
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9122
 
 
9123
 
                        ulTempData &= (~ulMask);
9124
 
 
9125
 
                        /* Set adaptive noise reduction on the SOUT port.*/
9126
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fRinDcOffsetRemoval ) << ulFeatureBitOffset );
9127
 
 
9128
 
                        /* The write the new DWORD where the field is located.*/
9129
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9130
 
                                                                                        pChanEntry,
9131
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9132
 
                                                                                        ulTempData,
9133
 
                                                                                        ulResult );
9134
 
                        if ( ulResult != cOCT6100_ERR_OK )
9135
 
                                return ulResult;        
9136
 
                }
9137
 
        }
9138
 
 
9139
 
        /* Set the DC removal on SIN ports.*/
9140
 
        if ( pSharedInfo->ImageInfo.fSinDcOffsetRemoval == TRUE )
9141
 
        {
9142
 
                /* Check if the configuration has been changed. */
9143
 
                if ( ( f_fModifyOnly == FALSE )
9144
 
                        || ( ( f_fModifyOnly == TRUE ) 
9145
 
                                && ( f_pVqeConfig->fSinDcOffsetRemoval != pChanEntry->VqeConfig.fSinDcOffsetRemoval ) ) )
9146
 
                {
9147
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.usDwordOffset * 4;
9148
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byBitOffset;
9149
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byFieldSize;
9150
 
 
9151
 
                        /* First read the DWORD where the field is located.*/
9152
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9153
 
                                                                                                pChanEntry,
9154
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9155
 
                                                                                                &ulTempData,
9156
 
                                                                                                ulResult );
9157
 
                        if ( ulResult != cOCT6100_ERR_OK )
9158
 
                                return ulResult;
9159
 
 
9160
 
                        /* Clear previous value set in the feature field.*/
9161
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9162
 
 
9163
 
                        ulTempData &= (~ulMask);
9164
 
 
9165
 
                        /* Set adaptive noise reduction on the SOUT port.*/
9166
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fSinDcOffsetRemoval ) << ulFeatureBitOffset );
9167
 
 
9168
 
                        /* Save the DWORD where the field is located.*/
9169
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9170
 
                                                                                        pChanEntry,
9171
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9172
 
                                                                                        ulTempData,
9173
 
                                                                                        ulResult );
9174
 
                        if ( ulResult != cOCT6100_ERR_OK )
9175
 
                                return ulResult;        
9176
 
                }
9177
 
        }
9178
 
 
9179
 
        /* Set the level control. */
9180
 
        if ( ( pChanEntry->byEchoOperationMode != f_pChannelOpen->ulEchoOperationMode )
9181
 
                && ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NORMAL ) )
9182
 
                fEchoOperationModeChanged = TRUE;
9183
 
        else
9184
 
                fEchoOperationModeChanged = FALSE;
9185
 
 
9186
 
        /* If opening the channel, all level control configuration must be written. */
9187
 
        if ( f_fModifyOnly == FALSE )
9188
 
                fEchoOperationModeChanged = TRUE;
9189
 
        ulResult = Oct6100ApiSetChannelLevelControl( f_pApiInstance, 
9190
 
                                                                                                 f_pVqeConfig, 
9191
 
                                                                                                 f_usChanIndex,
9192
 
                                                                                                 f_usEchoMemIndex,
9193
 
                                                                                                 fEchoOperationModeChanged );
9194
 
        if ( ulResult != cOCT6100_ERR_OK )
9195
 
                return ulResult;
9196
 
 
9197
 
        /* Set the background noise freeze.*/
9198
 
        if ( pSharedInfo->ImageInfo.fComfortNoise == TRUE )
9199
 
        {
9200
 
                /* Check if the configuration has been changed. */
9201
 
                if ( ( f_fModifyOnly == FALSE )
9202
 
                        || ( ( f_fModifyOnly == TRUE ) 
9203
 
                                && ( f_pVqeConfig->ulComfortNoiseMode != pChanEntry->VqeConfig.byComfortNoiseMode ) ) )
9204
 
                {
9205
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.usDwordOffset * 4;
9206
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byBitOffset;
9207
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byFieldSize;
9208
 
 
9209
 
                        /* First read the DWORD where the field is located.*/
9210
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9211
 
                                                                                                pChanEntry,
9212
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9213
 
                                                                                                &ulTempData,
9214
 
                                                                                                ulResult );
9215
 
                        if ( ulResult != cOCT6100_ERR_OK )
9216
 
                                return ulResult;
9217
 
 
9218
 
                        /* Clear previous value set in the feature field.*/
9219
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9220
 
 
9221
 
                        ulTempData &= (~ulMask);
9222
 
                        ulTempData |= ( f_pVqeConfig->ulComfortNoiseMode << ulFeatureBitOffset );
9223
 
 
9224
 
                        /* Save the new DWORD where the field is located. */
9225
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9226
 
                                                                                        pChanEntry,
9227
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9228
 
                                                                                        ulTempData,
9229
 
                                                                                        ulResult );
9230
 
                        if ( ulResult != cOCT6100_ERR_OK )
9231
 
                                return ulResult;        
9232
 
                }
9233
 
        }
9234
 
 
9235
 
        /* Set the state of the NLP */
9236
 
        if ( pSharedInfo->ImageInfo.fNlpControl == TRUE )
9237
 
        {
9238
 
                /* Check if the configuration has been changed. */
9239
 
                if ( ( f_fModifyOnly == FALSE )
9240
 
                        || ( ( f_fModifyOnly == TRUE ) 
9241
 
                                && ( f_pVqeConfig->fEnableNlp != pChanEntry->VqeConfig.fEnableNlp ) ) )
9242
 
                {
9243
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpControlFieldOfst.usDwordOffset * 4;
9244
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.NlpControlFieldOfst.byBitOffset;
9245
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpControlFieldOfst.byFieldSize;
9246
 
 
9247
 
                        /* First read the DWORD where the field is located.*/
9248
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9249
 
                                                                                                pChanEntry,
9250
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9251
 
                                                                                                &ulTempData,
9252
 
                                                                                                ulResult );
9253
 
                        if ( ulResult != cOCT6100_ERR_OK )
9254
 
                                return ulResult;
9255
 
 
9256
 
                        /* Clear previous value set in the feature field.*/
9257
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9258
 
 
9259
 
                        ulTempData &= (~ulMask);
9260
 
 
9261
 
                        if ( f_pVqeConfig->fEnableNlp == FALSE )
9262
 
                                ulTempData |= 0x1 << ulFeatureBitOffset;
9263
 
 
9264
 
                        /* Save the new DWORD where the field is located.*/
9265
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9266
 
                                                                                        pChanEntry,
9267
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9268
 
                                                                                        ulTempData,
9269
 
                                                                                        ulResult );
9270
 
                        if ( ulResult != cOCT6100_ERR_OK )
9271
 
                                return ulResult;
9272
 
                }
9273
 
        }
9274
 
 
9275
 
        /* Set the tail configuration. */
9276
 
        ulResult = Oct6100ApiSetChannelTailConfiguration(
9277
 
                                                                                                f_pApiInstance,
9278
 
                                                                                                f_pVqeConfig,
9279
 
                                                                                                f_usChanIndex,
9280
 
                                                                                                f_usEchoMemIndex,
9281
 
                                                                                                f_fModifyOnly );
9282
 
        if ( ulResult != cOCT6100_ERR_OK )
9283
 
                return ulResult;
9284
 
 
9285
 
        /* Set the Default ERL. */
9286
 
        if ( ( pSharedInfo->ImageInfo.fDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == FALSE ) )
9287
 
        {
9288
 
                /* Check if the configuration has been changed. */
9289
 
                if ( ( f_fModifyOnly == FALSE )
9290
 
                        || ( ( f_fModifyOnly == TRUE ) 
9291
 
                                && ( ( f_pVqeConfig->lDefaultErlDb != pChanEntry->VqeConfig.chDefaultErlDb ) 
9292
 
                                        || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) 
9293
 
                                        || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
9294
 
                {
9295
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.DefaultErlFieldOfst.usDwordOffset * 4;
9296
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byBitOffset;
9297
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byFieldSize;
9298
 
 
9299
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9300
 
                                                                                                pChanEntry,
9301
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9302
 
                                                                                                &ulTempData,
9303
 
                                                                                                ulResult );
9304
 
                        if ( ulResult != cOCT6100_ERR_OK )
9305
 
                                return ulResult;
9306
 
 
9307
 
                        /* Clear previous value set in the feature field.*/
9308
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9309
 
 
9310
 
                        ulTempData &= (~ulMask);
9311
 
 
9312
 
                        /* Convert the DB value to octasic's float format. (In energy) */
9313
 
                        if ( ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
9314
 
                                && ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9315
 
                        {
9316
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb );
9317
 
                        }
9318
 
                        else
9319
 
                        {
9320
 
                                /* Clear the defautl ERL when using the no echo cancellation operation mode. */
9321
 
                                usTempData = 0x0;
9322
 
                        }
9323
 
 
9324
 
                        if ( ulFeatureFieldLength < 16 )
9325
 
                                usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
9326
 
 
9327
 
                        ulTempData |= ( usTempData << ulFeatureBitOffset );
9328
 
 
9329
 
                        /* Save the new DWORD where the field is located.*/
9330
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9331
 
                                                                                        pChanEntry,
9332
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9333
 
                                                                                        ulTempData,
9334
 
                                                                                        ulResult );
9335
 
                        if ( ulResult != cOCT6100_ERR_OK )
9336
 
                                return ulResult;        
9337
 
                }
9338
 
        }
9339
 
 
9340
 
        /* Set the Acoustic echo control.*/
9341
 
        if ( pSharedInfo->ImageInfo.fAcousticEcho == TRUE )
9342
 
        {
9343
 
                /* Check if the configuration has been changed. */
9344
 
                if ( ( f_fModifyOnly == FALSE )
9345
 
                        || ( ( f_fModifyOnly == TRUE ) 
9346
 
                                && ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) )
9347
 
                {
9348
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecFieldOfst.usDwordOffset * 4;
9349
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AecFieldOfst.byBitOffset;
9350
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AecFieldOfst.byFieldSize;
9351
 
 
9352
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9353
 
                                                                                                pChanEntry,
9354
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9355
 
                                                                                                &ulTempData,
9356
 
                                                                                                ulResult );
9357
 
                        if ( ulResult != cOCT6100_ERR_OK )
9358
 
                                return ulResult;
9359
 
 
9360
 
                        /* Clear previous value set in the feature field. */
9361
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9362
 
 
9363
 
                        ulTempData &= (~ulMask);
9364
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fAcousticEcho ) << ulFeatureBitOffset );
9365
 
 
9366
 
                        /* Then save the new DWORD where the field is located. */
9367
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9368
 
                                                                                        pChanEntry,
9369
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9370
 
                                                                                        ulTempData,
9371
 
                                                                                        ulResult );
9372
 
                        if ( ulResult != cOCT6100_ERR_OK )
9373
 
                                return ulResult;        
9374
 
                }
9375
 
        }
9376
 
 
9377
 
        /* Set the Acoustic Echo Default ERL. */
9378
 
        if ( ( pSharedInfo->ImageInfo.fAecDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == TRUE ) )
9379
 
        {
9380
 
                /* Check if the configuration has been changed. */
9381
 
                if ( ( f_fModifyOnly == FALSE )
9382
 
                        || ( ( f_fModifyOnly == TRUE ) 
9383
 
                                && ( ( f_pVqeConfig->lAecDefaultErlDb != pChanEntry->VqeConfig.chAecDefaultErlDb ) 
9384
 
                                        || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
9385
 
                {
9386
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.usDwordOffset * 4;
9387
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byBitOffset;
9388
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byFieldSize;
9389
 
 
9390
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9391
 
                                                                                                pChanEntry,
9392
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9393
 
                                                                                                &ulTempData,
9394
 
                                                                                                ulResult );
9395
 
                        if ( ulResult != cOCT6100_ERR_OK )
9396
 
                                return ulResult;
9397
 
 
9398
 
                        /* Clear previous value set in the feature field. */
9399
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9400
 
 
9401
 
                        ulTempData &= (~ulMask);
9402
 
                        
9403
 
                        if ( ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
9404
 
                                && ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9405
 
                        {
9406
 
                                /* Convert the DB value to octasic's float format. (In energy) */
9407
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lAecDefaultErlDb );
9408
 
                        }
9409
 
                        else
9410
 
                        {
9411
 
                                /* Clear the AEC defautl ERL when using the no echo cancellation operation mode. */
9412
 
                                usTempData = 0x0;
9413
 
                        }
9414
 
 
9415
 
                        if ( ulFeatureFieldLength < 16 )
9416
 
                                usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
9417
 
 
9418
 
                        ulTempData |= ( usTempData << ulFeatureBitOffset );
9419
 
 
9420
 
                        /* Then save the DWORD where the field is located. */
9421
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9422
 
                                                                                        pChanEntry,
9423
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9424
 
                                                                                        ulTempData,
9425
 
                                                                                        ulResult );
9426
 
                        if ( ulResult != cOCT6100_ERR_OK )
9427
 
                                return ulResult;        
9428
 
                }
9429
 
        }
9430
 
 
9431
 
        /* Set the DTMF tone removal bit.*/
9432
 
        if ( pSharedInfo->ImageInfo.fToneRemoval == TRUE )
9433
 
        {
9434
 
                /* Check if the configuration has been changed. */
9435
 
                if ( ( f_fModifyOnly == FALSE )
9436
 
                        || ( ( f_fModifyOnly == TRUE ) 
9437
 
                                && ( f_pVqeConfig->fDtmfToneRemoval != pChanEntry->VqeConfig.fDtmfToneRemoval ) ) )
9438
 
                {
9439
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.usDwordOffset * 4;
9440
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byBitOffset;
9441
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byFieldSize;
9442
 
 
9443
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9444
 
                                                                                                pChanEntry,
9445
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9446
 
                                                                                                &ulTempData,
9447
 
                                                                                                ulResult );
9448
 
                        if ( ulResult != cOCT6100_ERR_OK )
9449
 
                                return ulResult;
9450
 
 
9451
 
                        /* Clear previous value set in the feature field.*/
9452
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9453
 
 
9454
 
                        ulTempData &= (~ulMask);
9455
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fDtmfToneRemoval ) << ulFeatureBitOffset );
9456
 
 
9457
 
                        /* First read the DWORD where the field is located.*/
9458
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9459
 
                                                                                        pChanEntry,
9460
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9461
 
                                                                                        ulTempData,
9462
 
                                                                                        ulResult );
9463
 
                        if ( ulResult != cOCT6100_ERR_OK )
9464
 
                                return ulResult;        
9465
 
                }
9466
 
        }
9467
 
 
9468
 
 
9469
 
 
9470
 
        /* Set the non-linear behavior A.*/
9471
 
        if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorA == TRUE )
9472
 
        {
9473
 
                /* Check if the configuration has been changed. */
9474
 
                if ( ( f_fModifyOnly == FALSE )
9475
 
                        || ( ( f_fModifyOnly == TRUE ) 
9476
 
                                && ( ( f_pVqeConfig->ulNonLinearityBehaviorA != pChanEntry->VqeConfig.byNonLinearityBehaviorA ) 
9477
 
                                        || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
9478
 
                {
9479
 
                        UINT16  ausLookupTable[ 14 ] = { 0x3663, 0x3906, 0x399C, 0x3A47, 0x3B06, 0x3B99, 0x3C47, 0x3D02, 0x3D99, 0x3E47, 0x3F00, 0x3F99, 0x4042, 0x4100 };
9480
 
                        
9481
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.PcmLeakFieldOfst.usDwordOffset * 4;
9482
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byBitOffset;
9483
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byFieldSize;
9484
 
 
9485
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9486
 
                                                                                                pChanEntry,
9487
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9488
 
                                                                                                &ulTempData,
9489
 
                                                                                                ulResult );
9490
 
                        if ( ulResult != cOCT6100_ERR_OK )
9491
 
                                return ulResult;
9492
 
 
9493
 
                        /* Clear previous value set in the feature field.*/
9494
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9495
 
 
9496
 
                        ulTempData &= (~ulMask);
9497
 
                        if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
9498
 
                                || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9499
 
                                ulTempData |= ( 0x0 << ulFeatureBitOffset );
9500
 
                        else
9501
 
                                ulTempData |= ( ausLookupTable[ f_pVqeConfig->ulNonLinearityBehaviorA ] << ulFeatureBitOffset );
9502
 
 
9503
 
                        /* Then save the DWORD where the field is located.*/
9504
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9505
 
                                                                                        pChanEntry,
9506
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9507
 
                                                                                        ulTempData,
9508
 
                                                                                        ulResult );
9509
 
                        if ( ulResult != cOCT6100_ERR_OK )
9510
 
                                return ulResult;
9511
 
                }
9512
 
        }
9513
 
        
9514
 
        /* Synch all the buffer playout field.*/
9515
 
        if ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE && f_fClearPlayoutPointers == TRUE )
9516
 
        {       
9517
 
                Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
9518
 
 
9519
 
                BufferPlayoutStop.ulChannelHndl = cOCT6100_INVALID_HANDLE;
9520
 
                BufferPlayoutStop.fStopCleanly = TRUE;
9521
 
                
9522
 
                BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
9523
 
                ulResult = Oct6100ApiInvalidateChanPlayoutStructs( 
9524
 
                                                                                                                f_pApiInstance, 
9525
 
                                                                                                                &BufferPlayoutStop, 
9526
 
                                                                                                                f_usChanIndex, 
9527
 
                                                                                                                f_usEchoMemIndex 
9528
 
 
9529
 
                                                                                                                );
9530
 
                if ( ulResult != cOCT6100_ERR_OK )
9531
 
                        return ulResult;
9532
 
                
9533
 
                BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
9534
 
                ulResult = Oct6100ApiInvalidateChanPlayoutStructs( 
9535
 
                                                                                                                f_pApiInstance, 
9536
 
                                                                                                                &BufferPlayoutStop, 
9537
 
                                                                                                                f_usChanIndex, 
9538
 
                                                                                                                f_usEchoMemIndex 
9539
 
 
9540
 
                                                                                                                );
9541
 
                if ( ulResult != cOCT6100_ERR_OK )
9542
 
                        return ulResult;
9543
 
        }
9544
 
 
9545
 
        /*==============================================================================*/
9546
 
        /* Write the 2100 Hz Echo Disabling mode */
9547
 
 
9548
 
        /* Check if the configuration has been changed. */
9549
 
        if ( ( f_fModifyOnly == FALSE )
9550
 
                || ( ( f_fModifyOnly == TRUE ) 
9551
 
                        && ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) ) )
9552
 
        {
9553
 
                ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerControlOfst.usDwordOffset * 4;
9554
 
                ulFeatureBitOffset       = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byBitOffset;
9555
 
                ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byFieldSize;
9556
 
 
9557
 
                /* First read the DWORD where the field is located.*/
9558
 
                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9559
 
                                                                                        pChanEntry,
9560
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9561
 
                                                                                        &ulTempData,
9562
 
                                                                                        ulResult );
9563
 
                if ( ulResult != cOCT6100_ERR_OK )
9564
 
                        return ulResult;
9565
 
 
9566
 
                /* Clear previous value set in the feature field.*/
9567
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9568
 
 
9569
 
                ulTempData &= (~ulMask);
9570
 
                
9571
 
                /* This is a disable bit, so it must be set only if the enable flag is set to false. */
9572
 
                if ( f_pChannelOpen->fEnableToneDisabler == FALSE )
9573
 
                        ulTempData |= 0x1 << ulFeatureBitOffset;
9574
 
 
9575
 
                /* Save the DWORD where the field is located. */
9576
 
                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9577
 
                                                                                pChanEntry,
9578
 
                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9579
 
                                                                                ulTempData,
9580
 
                                                                                ulResult );
9581
 
                if ( ulResult != cOCT6100_ERR_OK )
9582
 
                        return ulResult;        
9583
 
        }
9584
 
        /*==============================================================================*/
9585
 
 
9586
 
 
9587
 
        /*==============================================================================*/
9588
 
        /* Write the Nlp Trivial enable flag. */
9589
 
 
9590
 
        /* Check if the configuration has been changed. */
9591
 
        if ( ( f_fModifyOnly == FALSE )
9592
 
                || ( ( f_fModifyOnly == TRUE ) 
9593
 
                        && ( 
9594
 
 
9595
 
                                ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
9596
 
        {
9597
 
                ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.usDwordOffset * 4;
9598
 
                ulFeatureBitOffset       = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byBitOffset;
9599
 
                ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byFieldSize;
9600
 
 
9601
 
                /* First read the DWORD where the field is located.*/
9602
 
                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9603
 
                                                                                        pChanEntry,
9604
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9605
 
                                                                                        &ulTempData,
9606
 
                                                                                        ulResult );
9607
 
                if ( ulResult != cOCT6100_ERR_OK )
9608
 
                        return ulResult;
9609
 
 
9610
 
                /* Clear previous value set in the feature field.*/
9611
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9612
 
 
9613
 
                ulTempData &= (~ulMask);
9614
 
                if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
9615
 
                        || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9616
 
                {
9617
 
                        ulTempData |= TRUE << ulFeatureBitOffset;
9618
 
                }
9619
 
 
9620
 
 
9621
 
                /* Then write the DWORD where the field is located. */
9622
 
                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9623
 
                                                                                pChanEntry,
9624
 
                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9625
 
                                                                                ulTempData,
9626
 
                                                                                ulResult );
9627
 
                if ( ulResult != cOCT6100_ERR_OK )
9628
 
                        return ulResult;        
9629
 
        }
9630
 
        /*==============================================================================*/
9631
 
 
9632
 
 
9633
 
        /*==============================================================================*/
9634
 
        /* Set the double talk behavior mode. */
9635
 
        if ( pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst == TRUE )
9636
 
        {
9637
 
                /* Check if the configuration has been changed. */
9638
 
                if ( ( f_fModifyOnly == FALSE )
9639
 
                        || ( ( f_fModifyOnly == TRUE ) 
9640
 
                                && ( f_pVqeConfig->ulDoubleTalkBehavior != pChanEntry->VqeConfig.byDoubleTalkBehavior ) ) )
9641
 
                {
9642
 
                        /* The field is located in the CPURO structure. */
9643
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.usDwordOffset * 4;
9644
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.byBitOffset;
9645
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.byFieldSize;
9646
 
 
9647
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9648
 
                                                                                                pChanEntry,
9649
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9650
 
                                                                                                &ulTempData, 
9651
 
                                                                                                ulResult );
9652
 
                        if ( ulResult != cOCT6100_ERR_OK )
9653
 
                                return ulResult;
9654
 
 
9655
 
                        /* Clear previous value set in the feature field.*/
9656
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9657
 
 
9658
 
                        ulTempData &= (~ulMask);
9659
 
                        ulTempData |= (f_pVqeConfig->ulDoubleTalkBehavior  << ulFeatureBitOffset );
9660
 
 
9661
 
                        /* Then save the DWORD where the field is located.*/
9662
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9663
 
                                                                                        pChanEntry,
9664
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9665
 
                                                                                        ulTempData,
9666
 
                                                                                        ulResult );
9667
 
                        if ( ulResult != cOCT6100_ERR_OK )
9668
 
                                return ulResult;        
9669
 
                }                       
9670
 
        }
9671
 
        /*==============================================================================*/
9672
 
 
9673
 
 
9674
 
        /*==============================================================================*/
9675
 
        /* Set the music protection enable. */
9676
 
        if ( ( pSharedInfo->ImageInfo.fMusicProtection == TRUE )
9677
 
                && ( pSharedInfo->ImageInfo.fMusicProtectionConfiguration == TRUE ) )
9678
 
        {
9679
 
                /* Check if the configuration has been changed. */
9680
 
                if ( ( f_fModifyOnly == FALSE )
9681
 
                        || ( ( f_fModifyOnly == TRUE ) 
9682
 
                                && ( f_pVqeConfig->fEnableMusicProtection != pChanEntry->VqeConfig.fEnableMusicProtection ) ) )
9683
 
                {
9684
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.usDwordOffset * 4;
9685
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byBitOffset;
9686
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byFieldSize;
9687
 
 
9688
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9689
 
                                                                                                pChanEntry,
9690
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9691
 
                                                                                                &ulTempData, 
9692
 
                                                                                                ulResult );
9693
 
                        if ( ulResult != cOCT6100_ERR_OK )
9694
 
                                return ulResult;
9695
 
 
9696
 
                        /* Clear previous value set in the feature field.*/
9697
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9698
 
 
9699
 
                        ulTempData &= (~ulMask);
9700
 
                        if ( f_pVqeConfig->fEnableMusicProtection == TRUE )
9701
 
                                ulTempData |= ( 1 << ulFeatureBitOffset );
9702
 
 
9703
 
                        /* Then save the DWORD where the field is located.*/
9704
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9705
 
                                                                                        pChanEntry,
9706
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9707
 
                                                                                        ulTempData,
9708
 
                                                                                        ulResult );
9709
 
                        if ( ulResult != cOCT6100_ERR_OK )
9710
 
                                return ulResult;        
9711
 
                }
9712
 
        }
9713
 
        /*==============================================================================*/
9714
 
 
9715
 
        return cOCT6100_ERR_OK;
9716
 
}
9717
 
#endif
9718
 
 
9719
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9720
 
 
9721
 
Function:               Oct6100ApiWriteVqeAfMemory
9722
 
 
9723
 
Description:    This function configures the AF related VQE features of an 
9724
 
                                echo channel.
9725
 
 
9726
 
-------------------------------------------------------------------------------
9727
 
|       Argument                |       Description
9728
 
-------------------------------------------------------------------------------
9729
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
9730
 
                                                        the present state of the chip and all its resources.
9731
 
 
9732
 
f_pVqeConfig                            Pointer to a VQE config structure.
9733
 
f_pChannelOpen                          Pointer to a channel configuration structure.
9734
 
f_usChanIndex                           Index of the echo channel in the API instance.
9735
 
f_usEchoMemIndex                        Index of the echo channel within the SSPX memory.
9736
 
f_fClearPlayoutPointers         Flag indicating if the playout pointer should be cleared.
9737
 
f_fModifyOnly                           Flag indicating if the configuration should be
9738
 
                                                        modified only.
9739
 
 
9740
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9741
 
#if !SKIP_Oct6100ApiWriteVqeAfMemory
9742
 
UINT32 Oct6100ApiWriteVqeAfMemory( 
9743
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
9744
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE              f_pVqeConfig,
9745
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen,
9746
 
                                IN      UINT16                                                  f_usChanIndex,
9747
 
                                IN      UINT16                                                  f_usEchoMemIndex,
9748
 
                                IN      BOOL                                                    f_fClearPlayoutPointers,
9749
 
                                IN      BOOL                                                    f_fModifyOnly )
9750
 
{
9751
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
9752
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
9753
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
9754
 
        UINT32                                                  ulResult;
9755
 
        UINT32                                                  ulTempData;
9756
 
        UINT32                                                  ulAfConfigBaseAddress;
9757
 
        UINT32                                                  ulFeatureBytesOffset;
9758
 
        UINT32                                                  ulFeatureBitOffset;
9759
 
        UINT32                                                  ulFeatureFieldLength;
9760
 
        UINT32                                                  ulMask;
9761
 
        UINT16                                                  usTempData;
9762
 
        
9763
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
9764
 
 
9765
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
9766
 
 
9767
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
9768
 
 
9769
 
        /* Obtain a pointer to the new buffer's list entry. */
9770
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
9771
 
 
9772
 
        /*==============================================================================*/
9773
 
        /*      Write the AF CPU configuration of the channel feature by feature.*/
9774
 
 
9775
 
        /* Calculate AF CPU configuration base address. */
9776
 
        ulAfConfigBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
9777
 
        
9778
 
        /* Set initial value to zero.*/
9779
 
        ulTempData = 0;
9780
 
 
9781
 
        /*==============================================================================*/
9782
 
        /* Program the Maximum echo point within the Main channel memory.*/
9783
 
        if ( pSharedInfo->ImageInfo.fMaxEchoPoint == TRUE )
9784
 
        {
9785
 
                /* Check if the configuration has been changed. */
9786
 
                if ( ( f_fModifyOnly == FALSE )
9787
 
                        || ( ( f_fModifyOnly == TRUE ) 
9788
 
                                && ( ( f_pVqeConfig->lDefaultErlDb != pChanEntry->VqeConfig.chDefaultErlDb ) 
9789
 
                                        || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
9790
 
                {
9791
 
                        /* Write the echo tail length */
9792
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.usDwordOffset * 4;
9793
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.byBitOffset;
9794
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.byFieldSize;
9795
 
 
9796
 
                        /* First read the DWORD where the field is located.*/
9797
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9798
 
                                                                                                pChanEntry,
9799
 
                                                                                                ulAfConfigBaseAddress + ulFeatureBytesOffset,
9800
 
                                                                                                &ulTempData,
9801
 
                                                                                                ulResult );
9802
 
                        if ( ulResult != cOCT6100_ERR_OK )
9803
 
                                return ulResult;
9804
 
 
9805
 
                        /* Clear previous value set in the feature field.*/
9806
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9807
 
 
9808
 
                        ulTempData &= (~ulMask);
9809
 
 
9810
 
                        /* Convert the DB value to octasic's float format.*/
9811
 
                        if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
9812
 
                        {
9813
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb );
9814
 
                        }
9815
 
                        else
9816
 
                        {
9817
 
                                /* Clear max echo point.  No echo cancellation here. */
9818
 
                                usTempData = 0x0;
9819
 
                        }
9820
 
 
9821
 
                        if ( ulFeatureFieldLength < 16 )
9822
 
                                usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
9823
 
 
9824
 
                        ulTempData |= usTempData << ulFeatureBitOffset;
9825
 
 
9826
 
                        /* First read the DWORD where the field is located.*/
9827
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9828
 
                                                                                        pChanEntry,
9829
 
                                                                                        ulAfConfigBaseAddress + ulFeatureBytesOffset,
9830
 
                                                                                        ulTempData,
9831
 
                                                                                        ulResult );
9832
 
                        if ( ulResult != cOCT6100_ERR_OK )
9833
 
                                return ulResult;        
9834
 
                }
9835
 
        }
9836
 
        /*==============================================================================*/
9837
 
 
9838
 
 
9839
 
        /*==============================================================================*/
9840
 
        /* Set the non-linear behavior B.*/
9841
 
        if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorB == TRUE )
9842
 
        {
9843
 
                /* Check if the configuration has been changed. */
9844
 
                if ( ( f_fModifyOnly == FALSE )
9845
 
                        || ( ( f_fModifyOnly == TRUE ) 
9846
 
                                && ( f_pVqeConfig->ulNonLinearityBehaviorB != pChanEntry->VqeConfig.byNonLinearityBehaviorB ) ) )
9847
 
                {
9848
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.usDwordOffset * 4;
9849
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byBitOffset;
9850
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byFieldSize;
9851
 
 
9852
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9853
 
                                                                                                pChanEntry,
9854
 
                                                                                                ulAfConfigBaseAddress + ulFeatureBytesOffset,
9855
 
                                                                                                &ulTempData, 
9856
 
                                                                                                ulResult );
9857
 
                        if ( ulResult != cOCT6100_ERR_OK )
9858
 
                                return ulResult;
9859
 
 
9860
 
                        /* Clear previous value set in the feature field.*/
9861
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9862
 
 
9863
 
                        ulTempData &= (~ulMask);
9864
 
                        ulTempData |= (f_pVqeConfig->ulNonLinearityBehaviorB  << ulFeatureBitOffset );
9865
 
 
9866
 
                        /* Then save the DWORD where the field is located.*/
9867
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9868
 
                                                                                        pChanEntry,
9869
 
                                                                                        ulAfConfigBaseAddress + ulFeatureBytesOffset,
9870
 
                                                                                        ulTempData,
9871
 
                                                                                        ulResult );
9872
 
                        if ( ulResult != cOCT6100_ERR_OK )
9873
 
                                return ulResult;        
9874
 
                }
9875
 
        }
9876
 
        /*==============================================================================*/
9877
 
 
9878
 
        
9879
 
        /*==============================================================================*/
9880
 
        /* Set the listener enhancement feature. */
9881
 
        if ( pSharedInfo->ImageInfo.fListenerEnhancement == TRUE )
9882
 
        {
9883
 
                /* Check if the configuration has been changed. */
9884
 
                if ( ( f_fModifyOnly == FALSE )
9885
 
                        || ( ( f_fModifyOnly == TRUE ) 
9886
 
                                && ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb ) 
9887
 
                                        || ( f_pVqeConfig->fSoutNaturalListenerEnhancement != pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement ) 
9888
 
                                        || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb ) ) ) )
9889
 
                {
9890
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveAleOfst.usDwordOffset * 4;
9891
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AdaptiveAleOfst.byBitOffset;
9892
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveAleOfst.byFieldSize;
9893
 
 
9894
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9895
 
                                                                                                pChanEntry,
9896
 
                                                                                                ulAfConfigBaseAddress + ulFeatureBytesOffset,
9897
 
                                                                                                &ulTempData,
9898
 
                                                                                                ulResult );
9899
 
                        if ( ulResult != cOCT6100_ERR_OK )
9900
 
                                return ulResult;
9901
 
 
9902
 
                        /* Clear previous value set in the feature field.*/
9903
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9904
 
                        
9905
 
                        ulTempData &= (~ulMask);
9906
 
 
9907
 
                        if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 )
9908
 
                        {
9909
 
                                UINT32 ulGainDb;
9910
 
 
9911
 
                                ulGainDb = f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb / 3;
9912
 
 
9913
 
                                /* Round up. */
9914
 
                                if ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb % 3 ) != 0x0 )
9915
 
                                        ulGainDb ++;
9916
 
 
9917
 
                                ulTempData |= ( ulGainDb << ulFeatureBitOffset );
9918
 
                        }
9919
 
                        else if ( f_pVqeConfig->fSoutNaturalListenerEnhancement != 0 )
9920
 
                        {
9921
 
                                UINT32 ulGainDb;
9922
 
 
9923
 
                                ulGainDb = f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb / 3;
9924
 
 
9925
 
                                /* Round up. */
9926
 
                                if ( ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb % 3 ) != 0x0 )
9927
 
                                        ulGainDb ++;
9928
 
 
9929
 
                                ulTempData |= ( ( 0x80 | ulGainDb ) << ulFeatureBitOffset );
9930
 
                        }
9931
 
 
9932
 
                        /* Now write the DWORD where the field is located containing the new configuration. */
9933
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9934
 
                                                                                        pChanEntry,
9935
 
                                                                                        ulAfConfigBaseAddress + ulFeatureBytesOffset,
9936
 
                                                                                        ulTempData,
9937
 
                                                                                        ulResult );
9938
 
                        if ( ulResult != cOCT6100_ERR_OK )
9939
 
                                return ulResult;        
9940
 
                }
9941
 
        }
9942
 
        /*==============================================================================*/
9943
 
 
9944
 
 
9945
 
        /*==============================================================================*/
9946
 
        /* Set the idle code detection enable. */
9947
 
        if ( ( pSharedInfo->ImageInfo.fIdleCodeDetection == TRUE )
9948
 
                && ( pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration == TRUE ) )
9949
 
        {
9950
 
                /* Check if the configuration has been changed. */
9951
 
                if ( ( f_fModifyOnly == FALSE )
9952
 
                        || ( ( f_fModifyOnly == TRUE ) 
9953
 
                                && ( f_pVqeConfig->fIdleCodeDetection != pChanEntry->VqeConfig.fIdleCodeDetection ) ) )
9954
 
                {
9955
 
                        /* Calculate base address in the AF software configuration. */
9956
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.usDwordOffset * 4;
9957
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.byBitOffset;
9958
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.byFieldSize;
9959
 
 
9960
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9961
 
                                                                                                pChanEntry,
9962
 
                                                                                                ulAfConfigBaseAddress + ulFeatureBytesOffset,
9963
 
                                                                                                &ulTempData, 
9964
 
                                                                                                ulResult );
9965
 
                        if ( ulResult != cOCT6100_ERR_OK )
9966
 
                                return ulResult;
9967
 
 
9968
 
                        /* Clear previous value set in the feature field.*/
9969
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9970
 
 
9971
 
                        ulTempData &= (~ulMask);
9972
 
                        if ( f_pVqeConfig->fIdleCodeDetection == FALSE )
9973
 
                                ulTempData |= ( 1 << ulFeatureBitOffset );
9974
 
 
9975
 
                        /* Then save the DWORD where the field is located.*/
9976
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9977
 
                                                                                        pChanEntry,
9978
 
                                                                                        ulAfConfigBaseAddress + ulFeatureBytesOffset,
9979
 
                                                                                        ulTempData,
9980
 
                                                                                        ulResult );
9981
 
                        if ( ulResult != cOCT6100_ERR_OK )
9982
 
                                return ulResult;        
9983
 
                }
9984
 
        }
9985
 
        /*==============================================================================*/
9986
 
 
9987
 
 
9988
 
        /*==============================================================================*/
9989
 
        /* Set the AFT control field. */
9990
 
        if ( pSharedInfo->ImageInfo.fAftControl == TRUE )
9991
 
        {
9992
 
                /* Check if the configuration has been changed. */
9993
 
                if ( ( f_fModifyOnly == FALSE )
9994
 
                        || ( ( f_fModifyOnly == TRUE ) 
9995
 
                                && ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) )
9996
 
                {
9997
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AftControlOfst.usDwordOffset * 4;
9998
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AftControlOfst.byBitOffset;
9999
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AftControlOfst.byFieldSize;
10000
 
 
10001
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
10002
 
                                                                                                pChanEntry,
10003
 
                                                                                                ulAfConfigBaseAddress + ulFeatureBytesOffset,
10004
 
                                                                                                &ulTempData,
10005
 
                                                                                                ulResult );
10006
 
                        if ( ulResult != cOCT6100_ERR_OK )
10007
 
                                return ulResult;
10008
 
 
10009
 
                        /* Clear previous value set in the feature field.*/
10010
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
10011
 
 
10012
 
                        ulTempData &= (~ulMask);
10013
 
                        
10014
 
                        /* If the operation mode is no echo, set the field such that echo cancellation is disabled. */
10015
 
                        if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
10016
 
                        {
10017
 
                                ulTempData |= ( 0x1234 << ulFeatureBitOffset );
10018
 
                        }
10019
 
                        else if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
10020
 
                        {
10021
 
                                /* For clarity. */
10022
 
                                ulTempData |= ( 0x0 << ulFeatureBitOffset );
10023
 
                        }
10024
 
 
10025
 
                        /* Then save the DWORD where the field is located.*/
10026
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
10027
 
                                                                                        pChanEntry,
10028
 
                                                                                        ulAfConfigBaseAddress + ulFeatureBytesOffset,
10029
 
                                                                                        ulTempData,
10030
 
                                                                                        ulResult );
10031
 
                        if ( ulResult != cOCT6100_ERR_OK )
10032
 
                                return ulResult;        
10033
 
                }
10034
 
        }
10035
 
        /*==============================================================================*/
10036
 
 
10037
 
        return cOCT6100_ERR_OK;
10038
 
}
10039
 
#endif
10040
 
 
10041
 
 
10042
 
 
10043
 
 
10044
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10045
 
 
10046
 
Function:               Oct6100ApiWriteEchoMemory
10047
 
 
10048
 
Description:    This function configure an echo memory entry in internal memory.and
10049
 
                                external memory.
10050
 
 
10051
 
-------------------------------------------------------------------------------
10052
 
|       Argument                |       Description
10053
 
-------------------------------------------------------------------------------
10054
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
10055
 
                                                the present state of the chip and all its resources.
10056
 
 
10057
 
f_pTdmConfig                    Pointer to a TDM config structure.
10058
 
f_pChannelOpen                  Pointer to a channel configuration structure.
10059
 
f_usEchoIndex                   Echo channel index within the SSPX memory.
10060
 
f_usRinRoutTsiIndex             RIN/ROUT TSI index within the TSI chariot memory
10061
 
f_usSinSoutTsiIndex             SIN/SOUT TSI index within the TSI chariot memory
10062
 
 
10063
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10064
 
#if !SKIP_Oct6100ApiWriteEchoMemory
10065
 
UINT32 Oct6100ApiWriteEchoMemory( 
10066
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
10067
 
                                IN      tPOCT6100_CHANNEL_OPEN_TDM              f_pTdmConfig,
10068
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen,
10069
 
                                IN      UINT16                                                  f_usEchoIndex,
10070
 
                                IN      UINT16                                                  f_usRinRoutTsiIndex,
10071
 
                                IN      UINT16                                                  f_usSinSoutTsiIndex )
10072
 
 
10073
 
{
10074
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
10075
 
        tOCT6100_WRITE_PARAMS           WriteParams;
10076
 
        UINT32                                          ulResult;
10077
 
        UINT32                                          ulTempData;
10078
 
        UINT32                                          ulBaseAddress;
10079
 
        UINT32                                          ulRinPcmLaw;
10080
 
        UINT32                                          ulRoutPcmLaw;
10081
 
        UINT32                                          ulSinPcmLaw;
10082
 
        UINT32                                          ulSoutPcmLaw;
10083
 
 
10084
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
10085
 
 
10086
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
10087
 
 
10088
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
10089
 
 
10090
 
        /* Set immediately the PCM law to be programmed in the SSPX and NLP memory.*/
10091
 
        if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
10092
 
        {
10093
 
                ulRinPcmLaw             = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;
10094
 
                ulRoutPcmLaw    = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;
10095
 
                ulSinPcmLaw             = f_pChannelOpen->TdmConfig.ulSinPcmLaw;
10096
 
                ulSoutPcmLaw    = f_pChannelOpen->TdmConfig.ulSinPcmLaw;
10097
 
        }
10098
 
        else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
10099
 
        {
10100
 
                ulRinPcmLaw             = f_pChannelOpen->TdmConfig.ulRinPcmLaw;
10101
 
                ulRoutPcmLaw    = f_pChannelOpen->TdmConfig.ulRinPcmLaw;
10102
 
                ulSinPcmLaw             = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;
10103
 
                ulSoutPcmLaw    = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;
10104
 
        }
10105
 
 
10106
 
        /*==============================================================================*/
10107
 
        /*      Configure the Global Static Configuration of the channel.*/
10108
 
 
10109
 
        ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET;
10110
 
 
10111
 
        /* Set the PGSP context base address. */
10112
 
        ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET;
10113
 
        
10114
 
        WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET;
10115
 
        WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10116
 
 
10117
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10118
 
        if ( ulResult != cOCT6100_ERR_OK  )
10119
 
                return ulResult;
10120
 
 
10121
 
        WriteParams.ulWriteAddress += 2;
10122
 
        WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10123
 
 
10124
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10125
 
        if ( ulResult != cOCT6100_ERR_OK  )
10126
 
                return ulResult;
10127
 
 
10128
 
        /* Set the PGSP init context base address. */
10129
 
        ulTempData = ( cOCT6100_IMAGE_FILE_BASE + 0x200 ) & 0x07FFFFFF;
10130
 
        
10131
 
        WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET;
10132
 
        WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10133
 
 
10134
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10135
 
        if ( ulResult != cOCT6100_ERR_OK  )
10136
 
                return ulResult;
10137
 
 
10138
 
        WriteParams.ulWriteAddress += 2;
10139
 
        WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10140
 
 
10141
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10142
 
        if ( ulResult != cOCT6100_ERR_OK  )
10143
 
                return ulResult;
10144
 
        
10145
 
        /* Set the RIN circular buffer base address. */
10146
 
        ulTempData  = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst) & 0x07FFFF00;
10147
 
        ulTempData |= ( ulRoutPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
10148
 
        
10149
 
        /* Set the circular buffer size.*/
10150
 
        if (( pSharedInfo->MemoryMap.ulChanMainRinCBMemSize & 0xFFFF00FF ) != 0 )
10151
 
                return cOCT6100_ERR_CHANNEL_INVALID_RIN_CB_SIZE;
10152
 
        ulTempData |= pSharedInfo->MemoryMap.ulChanMainRinCBMemSize >> 8;
10153
 
                
10154
 
        WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET;
10155
 
        WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10156
 
 
10157
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10158
 
        if ( ulResult != cOCT6100_ERR_OK  )
10159
 
                return ulResult;
10160
 
 
10161
 
        WriteParams.ulWriteAddress += 2;
10162
 
        WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10163
 
 
10164
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10165
 
        if ( ulResult != cOCT6100_ERR_OK  )
10166
 
                return ulResult;
10167
 
 
10168
 
        /* Set the SIN circular buffer base address. */
10169
 
        ulTempData  = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst) & 0x07FFFF00;
10170
 
        ulTempData |= ( ulSinPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
10171
 
 
10172
 
        WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET;
10173
 
        WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10174
 
 
10175
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10176
 
        if ( ulResult != cOCT6100_ERR_OK  )
10177
 
                return ulResult;
10178
 
 
10179
 
        WriteParams.ulWriteAddress += 2;
10180
 
        WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10181
 
 
10182
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10183
 
        if ( ulResult != cOCT6100_ERR_OK  )
10184
 
                return ulResult;
10185
 
 
10186
 
        /* Set the SOUT circular buffer base address. */
10187
 
        ulTempData  = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst ) & 0x07FFFF00;
10188
 
        ulTempData |= ( ulSoutPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
10189
 
 
10190
 
        WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET;
10191
 
        WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10192
 
 
10193
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10194
 
        if ( ulResult != cOCT6100_ERR_OK  )
10195
 
                return ulResult;
10196
 
 
10197
 
        WriteParams.ulWriteAddress += 2;
10198
 
        WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10199
 
 
10200
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10201
 
        if ( ulResult != cOCT6100_ERR_OK  )
10202
 
                return ulResult;
10203
 
 
10204
 
        /*==============================================================================*/
10205
 
 
10206
 
        
10207
 
        /*==============================================================================*/
10208
 
        /*      ECHO SSPX Memory configuration.*/
10209
 
        
10210
 
        WriteParams.ulWriteAddress  = cOCT6100_ECHO_CONTROL_MEM_BASE + ( f_usEchoIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
10211
 
 
10212
 
        /* ECHO memory BASE + 2 */
10213
 
        WriteParams.ulWriteAddress += 2;
10214
 
        WriteParams.usWriteData = 0x0000;
10215
 
 
10216
 
        /* Set the echo control field.*/
10217
 
        if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
10218
 
                || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
10219
 
        {
10220
 
                WriteParams.usWriteData |= cOCT6100_ECHO_OP_MODE_NORMAL << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL;
10221
 
        }
10222
 
        else if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL )
10223
 
        {
10224
 
                WriteParams.usWriteData |= f_pChannelOpen->ulEchoOperationMode << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL;
10225
 
        }
10226
 
 
10227
 
        /* Set the SIN/SOUT law.*/
10228
 
        WriteParams.usWriteData |= ulSinPcmLaw << cOCT6100_ECHO_CONTROL_MEM_INPUT_LAW_OFFSET;
10229
 
        WriteParams.usWriteData |= ulSoutPcmLaw << cOCT6100_ECHO_CONTROL_MEM_OUTPUT_LAW_OFFSET;
10230
 
 
10231
 
        /* Set the TSI chariot memory field.*/
10232
 
        WriteParams.usWriteData |= f_usSinSoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK; 
10233
 
 
10234
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10235
 
        if ( ulResult != cOCT6100_ERR_OK  )
10236
 
                return ulResult;
10237
 
 
10238
 
        /* ECHO memory BASE */
10239
 
        WriteParams.ulWriteAddress -= 2;
10240
 
        WriteParams.usWriteData  = cOCT6100_ECHO_CONTROL_MEM_ACTIVATE_ENTRY;
10241
 
 
10242
 
        /* Set the RIN/ROUT law.*/
10243
 
        WriteParams.usWriteData |= ulRinPcmLaw << cOCT6100_ECHO_CONTROL_MEM_INPUT_LAW_OFFSET;
10244
 
        WriteParams.usWriteData |= ulRoutPcmLaw << cOCT6100_ECHO_CONTROL_MEM_OUTPUT_LAW_OFFSET;
10245
 
 
10246
 
        /* Set the RIN external echo control bit.*/
10247
 
        if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_EXTERNAL )
10248
 
                WriteParams.usWriteData |= cOCT6100_ECHO_CONTROL_MEM_EXTERNAL_AF_CTRL;
10249
 
 
10250
 
        /* Set the TSI chariot memory field.*/
10251
 
        WriteParams.usWriteData |= f_usRinRoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK; 
10252
 
 
10253
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10254
 
        if ( ulResult != cOCT6100_ERR_OK  )
10255
 
                return ulResult;
10256
 
 
10257
 
        /*==============================================================================*/
10258
 
 
10259
 
        return cOCT6100_ERR_OK;
10260
 
}
10261
 
#endif
10262
 
 
10263
 
 
10264
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10265
 
 
10266
 
Function:               Oct6100ApiUpdateOpenStruct
10267
 
 
10268
 
Description:    This function will copy the new parameter from the modify structure 
10269
 
                                into a channel open structure to be processed later by the same path 
10270
 
                                as the channel open function.  
10271
 
                                If a parameter is set to keep previous, it's current value will be 
10272
 
                                extracted from the channel entry in the API.
10273
 
 
10274
 
-------------------------------------------------------------------------------
10275
 
|       Argument                |       Description
10276
 
-------------------------------------------------------------------------------
10277
 
 
10278
 
IN              f_pApiInstance                          Pointer to an API instance structure.
10279
 
IN              f_pChanModify                   Pointer to a channel modify structure.
10280
 
IN OUT  f_pChanOpen                             Pointer to a channel open structure.
10281
 
IN              f_pChanEntry                    Pointer to an API channel structure.
10282
 
 
10283
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10284
 
#if !SKIP_Oct6100ApiUpdateOpenStruct
10285
 
UINT32 Oct6100ApiUpdateOpenStruct( 
10286
 
                                IN              tPOCT6100_INSTANCE_API                  f_pApiInstance,
10287
 
                                IN              tPOCT6100_CHANNEL_MODIFY                f_pChanModify,
10288
 
                                IN OUT  tPOCT6100_CHANNEL_OPEN                  f_pChanOpen,
10289
 
                                IN              tPOCT6100_API_CHANNEL                   f_pChanEntry )
10290
 
{
10291
 
        
10292
 
        /* Check the generic Echo parameters.*/
10293
 
        if ( f_pChanModify->ulEchoOperationMode == cOCT6100_KEEP_PREVIOUS_SETTING )
10294
 
                f_pChanOpen->ulEchoOperationMode = f_pChanEntry->byEchoOperationMode;
10295
 
        else
10296
 
                f_pChanOpen->ulEchoOperationMode = f_pChanModify->ulEchoOperationMode;
10297
 
 
10298
 
 
10299
 
        if ( f_pChanModify->fEnableToneDisabler == cOCT6100_KEEP_PREVIOUS_SETTING )
10300
 
                f_pChanOpen->fEnableToneDisabler = f_pChanEntry->fEnableToneDisabler;
10301
 
        else
10302
 
                f_pChanOpen->fEnableToneDisabler = f_pChanModify->fEnableToneDisabler;
10303
 
 
10304
 
 
10305
 
        if ( f_pChanModify->ulUserChanId == cOCT6100_KEEP_PREVIOUS_SETTING )
10306
 
                f_pChanOpen->ulUserChanId = f_pChanEntry->ulUserChanId;
10307
 
        else
10308
 
                f_pChanOpen->ulUserChanId = f_pChanModify->ulUserChanId;
10309
 
 
10310
 
 
10311
 
        
10312
 
        /*======================================================================*/
10313
 
        /* Now update the TDM config.*/
10314
 
        /* Rin PCM LAW */
10315
 
        if ( f_pChanModify->TdmConfig.ulRinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10316
 
                f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanEntry->TdmConfig.byRinPcmLaw;
10317
 
        else
10318
 
                f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanModify->TdmConfig.ulRinPcmLaw;
10319
 
        
10320
 
        /* Sin PCM LAW */
10321
 
        if ( f_pChanModify->TdmConfig.ulSinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10322
 
                f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanEntry->TdmConfig.bySinPcmLaw;
10323
 
        else
10324
 
                f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanModify->TdmConfig.ulSinPcmLaw;
10325
 
        
10326
 
        /* Rout PCM LAW */
10327
 
        if ( f_pChanModify->TdmConfig.ulRoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10328
 
                f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanEntry->TdmConfig.byRoutPcmLaw;
10329
 
        else
10330
 
                f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanModify->TdmConfig.ulRoutPcmLaw;
10331
 
 
10332
 
        /* Sout PCM LAW */
10333
 
        if ( f_pChanModify->TdmConfig.ulSoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10334
 
                f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanEntry->TdmConfig.bySoutPcmLaw;
10335
 
        else
10336
 
                f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanModify->TdmConfig.ulSoutPcmLaw;
10337
 
 
10338
 
 
10339
 
        /* Rin Timeslot */
10340
 
        if ( f_pChanModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10341
 
                f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanEntry->TdmConfig.usRinTimeslot;
10342
 
        else
10343
 
                f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanModify->TdmConfig.ulRinTimeslot;
10344
 
        
10345
 
        /* Rin Stream */
10346
 
        if ( f_pChanModify->TdmConfig.ulRinStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10347
 
                f_pChanOpen->TdmConfig.ulRinStream = f_pChanEntry->TdmConfig.usRinStream;
10348
 
        else
10349
 
                f_pChanOpen->TdmConfig.ulRinStream = f_pChanModify->TdmConfig.ulRinStream;
10350
 
 
10351
 
        /* Rin Num TSSTs */
10352
 
        if ( f_pChanModify->TdmConfig.ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10353
 
                f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanEntry->TdmConfig.byRinNumTssts;
10354
 
        else
10355
 
                f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanModify->TdmConfig.ulRinNumTssts;
10356
 
 
10357
 
 
10358
 
        /* Sin Timeslot */
10359
 
        if ( f_pChanModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10360
 
                f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanEntry->TdmConfig.usSinTimeslot;
10361
 
        else
10362
 
                f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanModify->TdmConfig.ulSinTimeslot;
10363
 
        
10364
 
        /* Sin Stream */
10365
 
        if ( f_pChanModify->TdmConfig.ulSinStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10366
 
                f_pChanOpen->TdmConfig.ulSinStream = f_pChanEntry->TdmConfig.usSinStream;
10367
 
        else
10368
 
                f_pChanOpen->TdmConfig.ulSinStream = f_pChanModify->TdmConfig.ulSinStream;
10369
 
 
10370
 
        /* Sin Num TSSTs */
10371
 
        if ( f_pChanModify->TdmConfig.ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10372
 
                f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanEntry->TdmConfig.bySinNumTssts;
10373
 
        else
10374
 
                f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanModify->TdmConfig.ulSinNumTssts;
10375
 
 
10376
 
 
10377
 
        /* Rout Timeslot */
10378
 
        if ( f_pChanModify->TdmConfig.ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10379
 
                f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanEntry->TdmConfig.usRoutTimeslot;
10380
 
        else
10381
 
                f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanModify->TdmConfig.ulRoutTimeslot;
10382
 
        
10383
 
        /* Rout Stream */
10384
 
        if ( f_pChanModify->TdmConfig.ulRoutStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10385
 
                f_pChanOpen->TdmConfig.ulRoutStream = f_pChanEntry->TdmConfig.usRoutStream;
10386
 
        else
10387
 
                f_pChanOpen->TdmConfig.ulRoutStream = f_pChanModify->TdmConfig.ulRoutStream;
10388
 
 
10389
 
        /* Rout Num TSSTs */
10390
 
        if ( f_pChanModify->TdmConfig.ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10391
 
                f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanEntry->TdmConfig.byRoutNumTssts;
10392
 
        else
10393
 
                f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanModify->TdmConfig.ulRoutNumTssts;
10394
 
 
10395
 
 
10396
 
        /* Sout Timeslot */
10397
 
        if ( f_pChanModify->TdmConfig.ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10398
 
                f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanEntry->TdmConfig.usSoutTimeslot;
10399
 
        else
10400
 
                f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanModify->TdmConfig.ulSoutTimeslot;
10401
 
        
10402
 
        /* Sout Stream */
10403
 
        if ( f_pChanModify->TdmConfig.ulSoutStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10404
 
                f_pChanOpen->TdmConfig.ulSoutStream = f_pChanEntry->TdmConfig.usSoutStream;
10405
 
        else
10406
 
                f_pChanOpen->TdmConfig.ulSoutStream = f_pChanModify->TdmConfig.ulSoutStream;
10407
 
 
10408
 
        /* Sout Num TSSTs */
10409
 
        if ( f_pChanModify->TdmConfig.ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10410
 
                f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanEntry->TdmConfig.bySoutNumTssts;
10411
 
        else
10412
 
                f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanModify->TdmConfig.ulSoutNumTssts;
10413
 
 
10414
 
        /*======================================================================*/
10415
 
        
10416
 
        /*======================================================================*/
10417
 
        /* Now update the VQE config.*/
10418
 
        
10419
 
        if ( f_pChanModify->VqeConfig.ulComfortNoiseMode == cOCT6100_KEEP_PREVIOUS_SETTING )
10420
 
                f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanEntry->VqeConfig.byComfortNoiseMode;
10421
 
        else
10422
 
                f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanModify->VqeConfig.ulComfortNoiseMode;
10423
 
 
10424
 
        if ( f_pChanModify->VqeConfig.fEnableNlp == cOCT6100_KEEP_PREVIOUS_SETTING )
10425
 
                f_pChanOpen->VqeConfig.fEnableNlp = f_pChanEntry->VqeConfig.fEnableNlp;
10426
 
        else
10427
 
                f_pChanOpen->VqeConfig.fEnableNlp = f_pChanModify->VqeConfig.fEnableNlp;
10428
 
        
10429
 
        if ( f_pChanModify->VqeConfig.fEnableTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING )
10430
 
                f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanEntry->VqeConfig.fEnableTailDisplacement;
10431
 
        else
10432
 
                f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanModify->VqeConfig.fEnableTailDisplacement;
10433
 
 
10434
 
        if ( f_pChanModify->VqeConfig.ulTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING )
10435
 
                f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanEntry->VqeConfig.usTailDisplacement;
10436
 
        else
10437
 
                f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanModify->VqeConfig.ulTailDisplacement;
10438
 
 
10439
 
        /* Tail length cannot be modifed. */
10440
 
        f_pChanOpen->VqeConfig.ulTailLength = f_pChanEntry->VqeConfig.usTailLength;
10441
 
 
10442
 
 
10443
 
        
10444
 
        if ( f_pChanModify->VqeConfig.fRinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
10445
 
                f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanEntry->VqeConfig.fRinDcOffsetRemoval;
10446
 
        else
10447
 
                f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanModify->VqeConfig.fRinDcOffsetRemoval;
10448
 
        
10449
 
 
10450
 
        if ( f_pChanModify->VqeConfig.fRinLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10451
 
                f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanEntry->VqeConfig.fRinLevelControl;
10452
 
        else
10453
 
                f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanModify->VqeConfig.fRinLevelControl;
10454
 
 
10455
 
 
10456
 
        if ( f_pChanModify->VqeConfig.fRinAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10457
 
                f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanEntry->VqeConfig.fRinAutomaticLevelControl;
10458
 
        else
10459
 
                f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanModify->VqeConfig.fRinAutomaticLevelControl;
10460
 
 
10461
 
 
10462
 
        if ( f_pChanModify->VqeConfig.fResetRinAlcOnTones == cOCT6100_KEEP_PREVIOUS_SETTING )
10463
 
                f_pChanOpen->VqeConfig.fResetRinAlcOnTones = f_pChanEntry->VqeConfig.fResetRinAlcOnTones;
10464
 
        else
10465
 
                f_pChanOpen->VqeConfig.fResetRinAlcOnTones = f_pChanModify->VqeConfig.fResetRinAlcOnTones;
10466
 
 
10467
 
 
10468
 
        if ( f_pChanModify->VqeConfig.ulAlcNoiseBleedOutTime == cOCT6100_KEEP_PREVIOUS_SETTING )
10469
 
                f_pChanOpen->VqeConfig.ulAlcNoiseBleedOutTime = f_pChanEntry->VqeConfig.usAlcNoiseBleedOutTime;
10470
 
        else
10471
 
                f_pChanOpen->VqeConfig.ulAlcNoiseBleedOutTime = f_pChanModify->VqeConfig.ulAlcNoiseBleedOutTime;
10472
 
 
10473
 
 
10474
 
        if ( f_pChanModify->VqeConfig.fRinHighLevelCompensation == cOCT6100_KEEP_PREVIOUS_SETTING )
10475
 
                f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanEntry->VqeConfig.fRinHighLevelCompensation;
10476
 
        else
10477
 
                f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanModify->VqeConfig.fRinHighLevelCompensation;
10478
 
 
10479
 
 
10480
 
        if ( f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10481
 
                f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb;
10482
 
        else
10483
 
                f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb;
10484
 
 
10485
 
        
10486
 
        if ( f_pChanModify->VqeConfig.fSinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
10487
 
                f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanEntry->VqeConfig.fSinDcOffsetRemoval;
10488
 
        else
10489
 
                f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanModify->VqeConfig.fSinDcOffsetRemoval;
10490
 
        
10491
 
 
10492
 
        if ( f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
10493
 
                f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction;
10494
 
        else
10495
 
                f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction;
10496
 
 
10497
 
        
10498
 
        if ( f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
10499
 
                f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanEntry->VqeConfig.fSoutConferencingNoiseReduction;
10500
 
        else
10501
 
                f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction;
10502
 
 
10503
 
 
10504
 
        if ( f_pChanModify->VqeConfig.fSoutNoiseBleaching == cOCT6100_KEEP_PREVIOUS_SETTING )
10505
 
                f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanEntry->VqeConfig.fSoutNoiseBleaching;
10506
 
        else
10507
 
                f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanModify->VqeConfig.fSoutNoiseBleaching;
10508
 
        
10509
 
 
10510
 
        if ( f_pChanModify->VqeConfig.fSoutLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10511
 
                f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanEntry->VqeConfig.fSoutLevelControl;
10512
 
        else
10513
 
                f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanModify->VqeConfig.fSoutLevelControl;
10514
 
 
10515
 
 
10516
 
        if ( f_pChanModify->VqeConfig.fSoutAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10517
 
                f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanEntry->VqeConfig.fSoutAutomaticLevelControl;
10518
 
        else
10519
 
                f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanModify->VqeConfig.fSoutAutomaticLevelControl;
10520
 
 
10521
 
 
10522
 
        if ( f_pChanModify->VqeConfig.fResetSoutAlcOnTones == cOCT6100_KEEP_PREVIOUS_SETTING )
10523
 
                f_pChanOpen->VqeConfig.fResetSoutAlcOnTones = f_pChanEntry->VqeConfig.fResetSoutAlcOnTones;
10524
 
        else
10525
 
                f_pChanOpen->VqeConfig.fResetSoutAlcOnTones = f_pChanModify->VqeConfig.fResetSoutAlcOnTones;
10526
 
        
10527
 
 
10528
 
        if ( f_pChanModify->VqeConfig.lRinLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10529
 
                f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanEntry->VqeConfig.chRinLevelControlGainDb;
10530
 
        else
10531
 
                f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanModify->VqeConfig.lRinLevelControlGainDb;
10532
 
        
10533
 
 
10534
 
        if ( f_pChanModify->VqeConfig.lSoutLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10535
 
                f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanEntry->VqeConfig.chSoutLevelControlGainDb;
10536
 
        else
10537
 
                f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanModify->VqeConfig.lSoutLevelControlGainDb;
10538
 
 
10539
 
 
10540
 
        if ( f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10541
 
                f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb;
10542
 
        else
10543
 
                f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb;
10544
 
        
10545
 
 
10546
 
        if ( f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10547
 
                f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb;
10548
 
        else
10549
 
                f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb;
10550
 
 
10551
 
 
10552
 
        if ( f_pChanModify->VqeConfig.lDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10553
 
                f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanEntry->VqeConfig.chDefaultErlDb;
10554
 
        else
10555
 
                f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanModify->VqeConfig.lDefaultErlDb;
10556
 
 
10557
 
 
10558
 
        if ( f_pChanModify->VqeConfig.lAecDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10559
 
                f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanEntry->VqeConfig.chAecDefaultErlDb;
10560
 
        else
10561
 
                f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanModify->VqeConfig.lAecDefaultErlDb;
10562
 
 
10563
 
 
10564
 
        if ( f_pChanModify->VqeConfig.ulAecTailLength == cOCT6100_KEEP_PREVIOUS_SETTING )
10565
 
                f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanEntry->VqeConfig.usAecTailLength;
10566
 
        else
10567
 
                f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanModify->VqeConfig.ulAecTailLength;
10568
 
 
10569
 
 
10570
 
        if ( f_pChanModify->VqeConfig.fAcousticEcho == cOCT6100_KEEP_PREVIOUS_SETTING )
10571
 
                f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanEntry->VqeConfig.fAcousticEcho;
10572
 
        else
10573
 
                f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanModify->VqeConfig.fAcousticEcho;
10574
 
 
10575
 
 
10576
 
        if ( f_pChanModify->VqeConfig.fDtmfToneRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
10577
 
                f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanEntry->VqeConfig.fDtmfToneRemoval;
10578
 
        else
10579
 
                f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanModify->VqeConfig.fDtmfToneRemoval;
10580
 
 
10581
 
 
10582
 
 
10583
 
 
10584
 
 
10585
 
        if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorA == cOCT6100_KEEP_PREVIOUS_SETTING )
10586
 
                f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanEntry->VqeConfig.byNonLinearityBehaviorA;
10587
 
        else
10588
 
                f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanModify->VqeConfig.ulNonLinearityBehaviorA;
10589
 
 
10590
 
 
10591
 
        if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorB == cOCT6100_KEEP_PREVIOUS_SETTING )
10592
 
                f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanEntry->VqeConfig.byNonLinearityBehaviorB;
10593
 
        else
10594
 
                f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanModify->VqeConfig.ulNonLinearityBehaviorB;
10595
 
 
10596
 
 
10597
 
        if ( f_pChanModify->VqeConfig.ulDoubleTalkBehavior == cOCT6100_KEEP_PREVIOUS_SETTING )
10598
 
                f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanEntry->VqeConfig.byDoubleTalkBehavior;
10599
 
        else
10600
 
                f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanModify->VqeConfig.ulDoubleTalkBehavior;
10601
 
 
10602
 
 
10603
 
        if ( f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10604
 
                f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb;
10605
 
        else
10606
 
                f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb;
10607
 
 
10608
 
 
10609
 
        if ( f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10610
 
                f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb;
10611
 
        else
10612
 
                f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb;
10613
 
 
10614
 
 
10615
 
        if ( f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement == cOCT6100_KEEP_PREVIOUS_SETTING )
10616
 
                f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement;
10617
 
        else
10618
 
                f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement;
10619
 
 
10620
 
 
10621
 
        if ( f_pChanModify->VqeConfig.fRoutNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
10622
 
                f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanEntry->VqeConfig.fRoutNoiseReduction;
10623
 
        else
10624
 
                f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanModify->VqeConfig.fRoutNoiseReduction;
10625
 
 
10626
 
 
10627
 
        if ( f_pChanModify->VqeConfig.lAnrSnrEnhancementDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10628
 
                f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanEntry->VqeConfig.chAnrSnrEnhancementDb;
10629
 
        else
10630
 
                f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanModify->VqeConfig.lAnrSnrEnhancementDb;
10631
 
 
10632
 
 
10633
 
        if ( f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation == cOCT6100_KEEP_PREVIOUS_SETTING )
10634
 
                f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation;
10635
 
        else
10636
 
                f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation;
10637
 
 
10638
 
 
10639
 
        if ( f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay == cOCT6100_KEEP_PREVIOUS_SETTING )
10640
 
                f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay;
10641
 
        else
10642
 
                f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay;
10643
 
 
10644
 
 
10645
 
        if ( f_pChanModify->VqeConfig.fEnableMusicProtection == cOCT6100_KEEP_PREVIOUS_SETTING )
10646
 
                f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanEntry->VqeConfig.fEnableMusicProtection;
10647
 
        else
10648
 
                f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanModify->VqeConfig.fEnableMusicProtection;
10649
 
 
10650
 
 
10651
 
        if ( f_pChanModify->VqeConfig.fIdleCodeDetection == cOCT6100_KEEP_PREVIOUS_SETTING )
10652
 
                f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanEntry->VqeConfig.fIdleCodeDetection;
10653
 
        else
10654
 
                f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanModify->VqeConfig.fIdleCodeDetection;
10655
 
 
10656
 
        /*======================================================================*/
10657
 
 
10658
 
 
10659
 
        /*======================================================================*/
10660
 
        /* Finaly the codec config.*/
10661
 
 
10662
 
        if ( f_pChanModify->CodecConfig.ulDecoderPort == cOCT6100_KEEP_PREVIOUS_SETTING )
10663
 
                f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanEntry->CodecConfig.byDecoderPort;
10664
 
        else
10665
 
                f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanModify->CodecConfig.ulDecoderPort;
10666
 
        
10667
 
 
10668
 
        if ( f_pChanModify->CodecConfig.ulDecodingRate == cOCT6100_KEEP_PREVIOUS_SETTING )
10669
 
                f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanEntry->CodecConfig.byDecodingRate;
10670
 
        else
10671
 
                f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanModify->CodecConfig.ulDecodingRate;
10672
 
        
10673
 
 
10674
 
        if ( f_pChanModify->CodecConfig.ulEncoderPort == cOCT6100_KEEP_PREVIOUS_SETTING )
10675
 
                f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanEntry->CodecConfig.byEncoderPort;
10676
 
        else
10677
 
                f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanModify->CodecConfig.ulEncoderPort;
10678
 
        
10679
 
 
10680
 
        if ( f_pChanModify->CodecConfig.ulEncodingRate == cOCT6100_KEEP_PREVIOUS_SETTING )
10681
 
                f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanEntry->CodecConfig.byEncodingRate;
10682
 
        else
10683
 
                f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanModify->CodecConfig.ulEncodingRate;
10684
 
 
10685
 
        if ( f_pChanModify->CodecConfig.fEnableSilenceSuppression == cOCT6100_KEEP_PREVIOUS_SETTING )
10686
 
                f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanEntry->CodecConfig.fEnableSilenceSuppression;
10687
 
        else
10688
 
                f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanModify->CodecConfig.fEnableSilenceSuppression;
10689
 
 
10690
 
        if ( f_pChanModify->CodecConfig.ulPhasingType == cOCT6100_KEEP_PREVIOUS_SETTING )
10691
 
                f_pChanOpen->CodecConfig.ulPhasingType = f_pChanEntry->CodecConfig.byPhasingType;
10692
 
        else
10693
 
                f_pChanOpen->CodecConfig.ulPhasingType = f_pChanModify->CodecConfig.ulPhasingType;
10694
 
 
10695
 
        if ( f_pChanModify->CodecConfig.ulPhase == cOCT6100_KEEP_PREVIOUS_SETTING )
10696
 
                f_pChanOpen->CodecConfig.ulPhase = f_pChanEntry->CodecConfig.byPhase;
10697
 
        else
10698
 
                f_pChanOpen->CodecConfig.ulPhase = f_pChanModify->CodecConfig.ulPhase;
10699
 
        
10700
 
        if ( f_pChanModify->CodecConfig.ulPhasingTsstHndl == cOCT6100_KEEP_PREVIOUS_SETTING )
10701
 
        {
10702
 
                if ( f_pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
10703
 
                {
10704
 
                        tPOCT6100_API_PHASING_TSST      pPhasingEntry;
10705
 
 
10706
 
                        mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanEntry->usPhasingTsstIndex );
10707
 
 
10708
 
                        /* Now recreate the Phasing TSST handle.*/
10709
 
                        f_pChanOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_pChanEntry->usPhasingTsstIndex;
10710
 
                }
10711
 
                else
10712
 
                {
10713
 
                        f_pChanOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
10714
 
                }
10715
 
        }
10716
 
        else
10717
 
        {
10718
 
                f_pChanOpen->CodecConfig.ulPhasingTsstHndl              = f_pChanModify->CodecConfig.ulPhasingTsstHndl;
10719
 
        }
10720
 
        
10721
 
        f_pChanOpen->CodecConfig.ulAdpcmNibblePosition  = f_pChanEntry->CodecConfig.byAdpcmNibblePosition;
10722
 
        /*======================================================================*/
10723
 
 
10724
 
        return cOCT6100_ERR_OK;
10725
 
}
10726
 
#endif
10727
 
 
10728
 
 
10729
 
 
10730
 
 
10731
 
 
10732
 
 
10733
 
 
10734
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10735
 
 
10736
 
Function:               Oct6100ApiRetrieveNlpConfDword
10737
 
 
10738
 
Description:    This function is used by the API to store on a per channel basis
10739
 
                                the various confguration DWORD from the device. The API performs 
10740
 
                                less read to the chip that way since it is always in synch with the 
10741
 
                                chip.
10742
 
 
10743
 
-------------------------------------------------------------------------------
10744
 
|       Argument                |       Description
10745
 
-------------------------------------------------------------------------------
10746
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
10747
 
                                                the present state of the chip and all its resources.
10748
 
 
10749
 
f_pChanEntry                    Pointer to an API channel structure..
10750
 
f_ulAddress                             Address that needs to be modified..
10751
 
f_pulConfigDword                Pointer to the content stored in the API located at the
10752
 
                                                desired address.
10753
 
 
10754
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10755
 
#if !SKIP_Oct6100ApiRetrieveNlpConfDword
10756
 
UINT32  Oct6100ApiRetrieveNlpConfDword( 
10757
 
                                                                           
10758
 
                                IN              tPOCT6100_INSTANCE_API                          f_pApiInstance,
10759
 
                                IN              tPOCT6100_API_CHANNEL                           f_pChanEntry,
10760
 
                                IN              UINT32                                                          f_ulAddress,
10761
 
                                OUT             PUINT32                                                         f_pulConfigDword )
10762
 
{
10763
 
        UINT32  ulResult;
10764
 
        UINT32  ulFirstEmptyIndex = 0xFFFFFFFF;
10765
 
        UINT32  i;
10766
 
 
10767
 
        /* Search for the Dword.*/
10768
 
        for ( i = 0; i < cOCT6100_MAX_NLP_CONF_DWORD; i++ )
10769
 
        {
10770
 
                if ( ( ulFirstEmptyIndex == 0xFFFFFFFF ) && ( f_pChanEntry->aulNlpConfDword[ i ][ 0 ] == 0x0 ) )
10771
 
                        ulFirstEmptyIndex = i;
10772
 
                
10773
 
                if ( f_pChanEntry->aulNlpConfDword[ i ][ 0 ] == f_ulAddress )
10774
 
                {
10775
 
                        /* We found the matching Dword.*/
10776
 
                        *f_pulConfigDword = f_pChanEntry->aulNlpConfDword[ i ][ 1 ];
10777
 
                        return cOCT6100_ERR_OK;
10778
 
                }
10779
 
        }
10780
 
 
10781
 
        if ( i == cOCT6100_MAX_NLP_CONF_DWORD && ulFirstEmptyIndex == 0xFFFFFFFF )
10782
 
                return cOCT6100_ERR_FATAL_8E;
10783
 
 
10784
 
        /* We did not found any entry, let's create a new entry.*/
10785
 
        f_pChanEntry->aulNlpConfDword[ ulFirstEmptyIndex ][ 0 ] = f_ulAddress;
10786
 
 
10787
 
 
10788
 
        /* Read the DWORD where the field is located.*/
10789
 
        ulResult = Oct6100ApiReadDword( f_pApiInstance,
10790
 
                                                                        f_ulAddress,
10791
 
                                                                        f_pulConfigDword );
10792
 
        if ( ulResult != cOCT6100_ERR_OK )
10793
 
                return ulResult;
10794
 
 
10795
 
        return cOCT6100_ERR_OK;
10796
 
}
10797
 
#endif
10798
 
 
10799
 
 
10800
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10801
 
 
10802
 
Function:               Oct6100ApiSaveNlpConfDword
10803
 
 
10804
 
Description:    This function stores a configuration Dword within an API channel
10805
 
                                structure and then writes it into the chip.
10806
 
 
10807
 
-------------------------------------------------------------------------------
10808
 
|       Argument                |       Description
10809
 
-------------------------------------------------------------------------------
10810
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
10811
 
                                                the present state of the chip and all its resources.
10812
 
 
10813
 
f_pChanEntry                    Pointer to an API channel structure..
10814
 
f_ulAddress                             Address that needs to be modified..
10815
 
f_pulConfigDword                content to be stored in the API located at the
10816
 
                                                desired address.
10817
 
 
10818
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10819
 
#if !SKIP_Oct6100ApiSaveNlpConfDword
10820
 
UINT32  Oct6100ApiSaveNlpConfDword( 
10821
 
                                                                           
10822
 
                                IN              tPOCT6100_INSTANCE_API                          f_pApiInstance,
10823
 
                                IN              tPOCT6100_API_CHANNEL                           f_pChanEntry,
10824
 
                                IN              UINT32                                                          f_ulAddress,
10825
 
                                IN              UINT32                                                          f_ulConfigDword )
10826
 
{
10827
 
        UINT32  ulResult;
10828
 
        UINT32  i;
10829
 
 
10830
 
        /* Search for the Dword.*/
10831
 
        for ( i = 0; i < cOCT6100_MAX_NLP_CONF_DWORD; i++ )
10832
 
        {
10833
 
 
10834
 
                if ( f_pChanEntry->aulNlpConfDword[ i ][ 0 ] == f_ulAddress )
10835
 
                {
10836
 
                        /* We found the matching Dword.*/
10837
 
                        f_pChanEntry->aulNlpConfDword[ i ][ 1 ] = f_ulConfigDword;
10838
 
                        break;
10839
 
                }
10840
 
        }
10841
 
 
10842
 
        if ( i == cOCT6100_MAX_NLP_CONF_DWORD )
10843
 
                return cOCT6100_ERR_FATAL_8F;
10844
 
 
10845
 
 
10846
 
        /* Write the config DWORD.*/
10847
 
        ulResult = Oct6100ApiWriteDword( f_pApiInstance,
10848
 
                                                                        f_ulAddress,
10849
 
                                                                        f_ulConfigDword );
10850
 
        if ( ulResult != cOCT6100_ERR_OK )
10851
 
                return ulResult;
10852
 
        
10853
 
        return cOCT6100_ERR_OK;
10854
 
}
10855
 
#endif
10856
 
 
10857
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10858
 
 
10859
 
Function:               Oct6100ChannelCreateBiDirSer
10860
 
 
10861
 
Description:    Creates a bidirectional echo cancellation channel.
10862
 
 
10863
 
-------------------------------------------------------------------------------
10864
 
|       Argument                |       Description
10865
 
-------------------------------------------------------------------------------
10866
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
10867
 
                                                present state of the chip and all its resources.
10868
 
 
10869
 
f_pChannelCreateBiDir   Pointer to a create bidirectionnal channel structure.
10870
 
 
10871
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10872
 
#if !SKIP_Oct6100ChannelCreateBiDirSer
10873
 
UINT32 Oct6100ChannelCreateBiDirSer(
10874
 
                                IN tPOCT6100_INSTANCE_API                                       f_pApiInstance,
10875
 
                                IN OUT tPOCT6100_CHANNEL_CREATE_BIDIR           f_pChannelCreateBiDir )
10876
 
{
10877
 
        UINT16  usFirstChanIndex;
10878
 
        UINT16  usFirstChanExtraTsiIndex;
10879
 
        UINT16  usFirstChanSinCopyEventIndex;
10880
 
        UINT16  usFirstChanSoutCopyEventIndex;
10881
 
        UINT16  usSecondChanIndex;
10882
 
        UINT16  usSecondChanExtraTsiIndex;
10883
 
        UINT16  usSecondChanSinCopyEventIndex;
10884
 
        UINT16  usSecondChanSoutCopyEventIndex;
10885
 
        UINT16  usBiDirChanIndex;
10886
 
        UINT32  ulResult;
10887
 
 
10888
 
        
10889
 
        /* Check the user's configuration of the bidir channel for errors. */
10890
 
        ulResult = Oct6100ApiCheckChannelCreateBiDirParams(             f_pApiInstance, 
10891
 
                                                                                                                        f_pChannelCreateBiDir, 
10892
 
                                                                                                                        &usFirstChanIndex, 
10893
 
                                                                                                                        &usFirstChanExtraTsiIndex, 
10894
 
                                                                                                                        &usFirstChanSinCopyEventIndex,
10895
 
                                                                                                                        &usSecondChanIndex, 
10896
 
                                                                                                                        &usSecondChanExtraTsiIndex,
10897
 
                                                                                                                        &usSecondChanSinCopyEventIndex 
10898
 
 
10899
 
                                                                                                                        );
10900
 
        if ( ulResult != cOCT6100_ERR_OK  )
10901
 
                return ulResult;
10902
 
 
10903
 
        /* Reserve all resources needed by the bidir channel. */
10904
 
        ulResult = Oct6100ApiReserveChannelCreateBiDirResources(f_pApiInstance, 
10905
 
 
10906
 
                                                                                                                        &usBiDirChanIndex, 
10907
 
                                                                                                                        &usFirstChanExtraTsiIndex,
10908
 
                                                                                                                        &usFirstChanSinCopyEventIndex,
10909
 
                                                                                                                        &usFirstChanSoutCopyEventIndex,
10910
 
                                                                                                                        &usSecondChanExtraTsiIndex,
10911
 
                                                                                                                        &usSecondChanSinCopyEventIndex,
10912
 
                                                                                                                        &usSecondChanSoutCopyEventIndex );
10913
 
        if ( ulResult != cOCT6100_ERR_OK  )
10914
 
                return ulResult;
10915
 
 
10916
 
        /* Write all necessary structures to activate the echo cancellation channel. */
10917
 
        ulResult = Oct6100ApiWriteChannelCreateBiDirStructs(    f_pApiInstance, 
10918
 
 
10919
 
                                                                                                                        usFirstChanIndex,
10920
 
                                                                                                                        usFirstChanExtraTsiIndex,
10921
 
                                                                                                                        usFirstChanSinCopyEventIndex,
10922
 
                                                                                                                        usFirstChanSoutCopyEventIndex,
10923
 
                                                                                                                        usSecondChanIndex, 
10924
 
                                                                                                                        usSecondChanExtraTsiIndex,
10925
 
                                                                                                                        usSecondChanSinCopyEventIndex,
10926
 
                                                                                                                        usSecondChanSoutCopyEventIndex );
10927
 
        if ( ulResult != cOCT6100_ERR_OK  )
10928
 
                return ulResult;
10929
 
 
10930
 
        /* Update the new echo cancellation channels's entry in the ECHO channel list. */
10931
 
        ulResult = Oct6100ApiUpdateBiDirChannelEntry(                   f_pApiInstance, 
10932
 
                                                                                                                        f_pChannelCreateBiDir,
10933
 
                                                                                                                        usBiDirChanIndex,
10934
 
                                                                                                                        usFirstChanIndex,
10935
 
                                                                                                                        usFirstChanExtraTsiIndex,
10936
 
                                                                                                                        usFirstChanSinCopyEventIndex,
10937
 
                                                                                                                        usFirstChanSoutCopyEventIndex,
10938
 
                                                                                                                        usSecondChanIndex, 
10939
 
                                                                                                                        usSecondChanExtraTsiIndex,
10940
 
                                                                                                                        usSecondChanSinCopyEventIndex,
10941
 
                                                                                                                        usSecondChanSoutCopyEventIndex );
10942
 
        if ( ulResult != cOCT6100_ERR_OK  )
10943
 
                return ulResult;
10944
 
 
10945
 
        return cOCT6100_ERR_OK;
10946
 
}
10947
 
#endif
10948
 
 
10949
 
 
10950
 
 
10951
 
 
10952
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10953
 
 
10954
 
Function:               Oct6100ApiCheckChannelCreateBiDirParams
10955
 
 
10956
 
Description:    Checks the user's parameter passed to the create bidirectional channel
10957
 
                                function.
10958
 
 
10959
 
-------------------------------------------------------------------------------
10960
 
|       Argument                |       Description
10961
 
-------------------------------------------------------------------------------
10962
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
10963
 
                                                        present state of the chip and all its resources.
10964
 
 
10965
 
f_pChannelCreateBiDir                           Pointer to a create bidirectionnal channel structure.
10966
 
f_pusFirstChanIndex                                     Pointer to the first channel index.
10967
 
f_pusFirstChanExtraTsiIndex                     Pointer to the first channel extra TSI index.
10968
 
f_pusFirstChanSinCopyEventIndex         Pointer to the first channel Sin copy event index.
10969
 
f_pusSecondChanIndex                            Pointer to the second channel index.
10970
 
f_pusSecondChanExtraTsiIndex            Pointer to the second channel extra TSI index.
10971
 
f_pusSecondChanSinCopyEventIndex        Pointer to the second channel Sin copy event index.
10972
 
 
10973
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10974
 
#if !SKIP_Oct6100ApiCheckChannelCreateBiDirParams
10975
 
UINT32 Oct6100ApiCheckChannelCreateBiDirParams(
10976
 
                                IN      tPOCT6100_INSTANCE_API                          f_pApiInstance,
10977
 
                                IN      tPOCT6100_CHANNEL_CREATE_BIDIR          f_pChannelCreateBiDir, 
10978
 
                                OUT     PUINT16                                                         f_pusFirstChanIndex, 
10979
 
                                OUT     PUINT16                                                         f_pusFirstChanExtraTsiIndex, 
10980
 
                                OUT     PUINT16                                                         f_pusFirstChanSinCopyEventIndex,
10981
 
                                OUT     PUINT16                                                         f_pusSecondChanIndex, 
10982
 
                                OUT     PUINT16                                                         f_pusSecondChanExtraTsiIndex,
10983
 
                                OUT     PUINT16                                                         f_pusSecondChanSinCopyEventIndex 
10984
 
 
10985
 
                                )
10986
 
{
10987
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
10988
 
        tPOCT6100_API_CHANNEL   pFirstChanEntry;
10989
 
        tPOCT6100_API_CHANNEL   pSecondChanEntry;
10990
 
        UINT32                                  ulEntryOpenCnt;
10991
 
        BOOL                                    fCheckTssts = TRUE;
10992
 
 
10993
 
        /* Obtain shared resources pointer.*/
10994
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
10995
 
 
10996
 
        /* validate the bidirectional channel handle memory.*/
10997
 
        if ( f_pChannelCreateBiDir->pulBiDirChannelHndl == NULL ) 
10998
 
                return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
10999
 
 
11000
 
 
11001
 
        
11002
 
        /* Check if bi-dir channels are activated. */
11003
 
        if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxBiDirChannels == 0 )
11004
 
                return cOCT6100_ERR_CHANNEL_BIDIR_DISABLED;
11005
 
 
11006
 
        /*=======================================================================*/
11007
 
        /* Verify the first channel handle. */
11008
 
 
11009
 
        if ( (f_pChannelCreateBiDir->ulFirstChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
11010
 
                return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
11011
 
 
11012
 
        *f_pusFirstChanIndex = (UINT16)( f_pChannelCreateBiDir->ulFirstChannelHndl & cOCT6100_HNDL_INDEX_MASK );
11013
 
        if ( *f_pusFirstChanIndex  >= pSharedInfo->ChipConfig.usMaxChannels )
11014
 
                return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
11015
 
 
11016
 
        /* Get a pointer to the channel's list entry. */
11017
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, *f_pusFirstChanIndex  )
11018
 
 
11019
 
        /* Extract the entry open count from the provided handle. */
11020
 
        ulEntryOpenCnt = ( f_pChannelCreateBiDir->ulFirstChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
11021
 
 
11022
 
        /* Check for errors. */
11023
 
        if ( pFirstChanEntry->fReserved != TRUE )
11024
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
11025
 
        if ( ulEntryOpenCnt != pFirstChanEntry->byEntryOpenCnt )
11026
 
                return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
11027
 
        
11028
 
        /* Check the specific state of the channel.*/
11029
 
        if ( pFirstChanEntry->fRinRoutCodecActive == TRUE || pFirstChanEntry->fSinSoutCodecActive == TRUE )
11030
 
                return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
11031
 
        if ( pFirstChanEntry->fBiDirChannel == TRUE )
11032
 
                return cOCT6100_ERR_CHANNEL_ALREADY_BIDIR;
11033
 
        
11034
 
        if ( pFirstChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
11035
 
                return cOCT6100_ERR_CHANNEL_FIRST_CHAN_IN_CONFERENCE;
11036
 
 
11037
 
        if ( fCheckTssts == TRUE )
11038
 
        {
11039
 
                if ( pFirstChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
11040
 
                        return cOCT6100_ERR_CHANNEL_FIRST_CHAN_SOUT_PORT;
11041
 
                if ( pFirstChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
11042
 
                        return cOCT6100_ERR_CHANNEL_FIRST_CHAN_RIN_PORT;
11043
 
        }
11044
 
 
11045
 
        /* Return the desired info.*/
11046
 
        *f_pusFirstChanExtraTsiIndex            = pFirstChanEntry->usExtraSinTsiMemIndex;
11047
 
        *f_pusFirstChanSinCopyEventIndex        = pFirstChanEntry->usSinCopyEventIndex;
11048
 
        /*=======================================================================*/
11049
 
 
11050
 
        /*=======================================================================*/
11051
 
        /* Verify the second channel handle. */
11052
 
 
11053
 
        if ( (f_pChannelCreateBiDir->ulSecondChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
11054
 
                return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
11055
 
 
11056
 
        *f_pusSecondChanIndex = (UINT16)( f_pChannelCreateBiDir->ulSecondChannelHndl & cOCT6100_HNDL_INDEX_MASK );
11057
 
        if ( *f_pusSecondChanIndex  >= pSharedInfo->ChipConfig.usMaxChannels )
11058
 
                return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
11059
 
 
11060
 
        /* Get a pointer to the channel's list entry. */
11061
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, *f_pusSecondChanIndex  )
11062
 
 
11063
 
        /* Extract the entry open count from the provided handle. */
11064
 
        ulEntryOpenCnt = ( f_pChannelCreateBiDir->ulSecondChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
11065
 
 
11066
 
        /* Check for errors. */
11067
 
        if ( pSecondChanEntry->fReserved != TRUE )
11068
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
11069
 
        if ( ulEntryOpenCnt != pSecondChanEntry->byEntryOpenCnt )
11070
 
                return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
11071
 
 
11072
 
        /* Check the specific state of the channel.*/
11073
 
        if ( pSecondChanEntry->fRinRoutCodecActive == TRUE )
11074
 
                return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
11075
 
        if ( pSecondChanEntry->fSinSoutCodecActive == TRUE )
11076
 
        {
11077
 
 
11078
 
                        return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
11079
 
        }
11080
 
                
11081
 
        if ( pSecondChanEntry->fBiDirChannel == TRUE )
11082
 
                return cOCT6100_ERR_CHANNEL_ALREADY_BIDIR;
11083
 
 
11084
 
        if ( fCheckTssts == TRUE )
11085
 
        {
11086
 
                if ( pSecondChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
11087
 
                        return cOCT6100_ERR_CHANNEL_SECOND_CHAN_SOUT_PORT;
11088
 
                if ( pSecondChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
11089
 
                        return cOCT6100_ERR_CHANNEL_SECOND_CHAN_RIN_PORT;
11090
 
        }
11091
 
 
11092
 
        if ( pSecondChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
11093
 
                return cOCT6100_ERR_CHANNEL_SECOND_CHAN_IN_CONFERENCE;
11094
 
 
11095
 
        /* Return the desired info.*/
11096
 
        *f_pusSecondChanExtraTsiIndex           = pSecondChanEntry->usExtraSinTsiMemIndex;
11097
 
        *f_pusSecondChanSinCopyEventIndex       = pSecondChanEntry->usSinCopyEventIndex;
11098
 
        /*=======================================================================*/
11099
 
 
11100
 
        /* Check the law compatibility.*/
11101
 
        if ( pFirstChanEntry->TdmConfig.bySoutPcmLaw != pSecondChanEntry->TdmConfig.byRinPcmLaw ||
11102
 
                 pFirstChanEntry->TdmConfig.byRinPcmLaw  != pSecondChanEntry->TdmConfig.bySoutPcmLaw )
11103
 
                return cOCT6100_ERR_CHANNEL_BIDIR_PCM_LAW;
11104
 
 
11105
 
        return cOCT6100_ERR_OK;
11106
 
}
11107
 
#endif
11108
 
 
11109
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11110
 
 
11111
 
Function:               Oct6100ApiReserveChannelCreateBiDirResources
11112
 
 
11113
 
Description:    Reserves all resources needed for the new bidirectional channel.
11114
 
 
11115
 
-------------------------------------------------------------------------------
11116
 
|       Argument                |       Description
11117
 
-------------------------------------------------------------------------------
11118
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
11119
 
                                                present state of the chip and all its resources.
11120
 
 
11121
 
f_pusBiDirChanIndex                                     Pointer to the index of the bidirectionnal channel within the API instance.
11122
 
f_pusFirstChanExtraTsiIndex                     Pointer to the first channel extra TSI index.
11123
 
f_pusFirstChanSinCopyEventIndex         Pointer to the first channel Sin copy event index.
11124
 
f_pusFirstChanSoutCopyEventIndex        Pointer to the first channel Sout copy event index.
11125
 
f_pusSecondChanExtraTsiIndex            Pointer to the second channel extra TSI index.
11126
 
f_pusSecondChanSinCopyEventIndex        Pointer to the second channel Sin copy event index.
11127
 
f_pusSecondChanSoutCopyEventIndex       Pointer to the second channel Sout copy event index.
11128
 
 
11129
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11130
 
#if !SKIP_Oct6100ApiReserveChannelCreateBiDirResources
11131
 
UINT32 Oct6100ApiReserveChannelCreateBiDirResources(    
11132
 
                                IN              tPOCT6100_INSTANCE_API                          f_pApiInstance,
11133
 
 
11134
 
                                OUT             PUINT16                                                         f_pusBiDirChanIndex, 
11135
 
                                IN OUT  PUINT16                                                         f_pusFirstChanExtraTsiIndex, 
11136
 
                                IN OUT  PUINT16                                                         f_pusFirstChanSinCopyEventIndex, 
11137
 
                                OUT             PUINT16                                                         f_pusFirstChanSoutCopyEventIndex,
11138
 
                                IN OUT  PUINT16                                                         f_pusSecondChanExtraTsiIndex, 
11139
 
                                IN OUT  PUINT16                                                         f_pusSecondChanSinCopyEventIndex,
11140
 
                                OUT             PUINT16                                                         f_pusSecondChanSoutCopyEventIndex )
11141
 
{
11142
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
11143
 
        UINT32  ulResult = cOCT6100_ERR_OK;
11144
 
        UINT32  ulTempVar;
11145
 
 
11146
 
        BOOL    fBiDirChanIndex                 = FALSE;
11147
 
        BOOL    fFirstExtraTsi                  = FALSE;
11148
 
        BOOL    fSecondExtraTsi                 = FALSE;
11149
 
        BOOL    fFirstSinCopyEvent              = FALSE;
11150
 
        BOOL    fSecondSinCopyEvent             = FALSE;
11151
 
        BOOL    fFirstSoutCopyEvent             = FALSE;
11152
 
        
11153
 
        /* Obtain local pointer to shared portion of instance. */
11154
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11155
 
 
11156
 
        /*===============================================================================*/
11157
 
        /* Verify and reserve the resources that might already by allocated. */
11158
 
 
11159
 
 
11160
 
        {
11161
 
                if ( *f_pusFirstChanExtraTsiIndex == cOCT6100_INVALID_INDEX )
11162
 
                {
11163
 
                        /* Reserve the first Extra TSI memory entry */
11164
 
                        ulResult = Oct6100ApiReserveTsiMemEntry(        f_pApiInstance, 
11165
 
                                                                                                                f_pusFirstChanExtraTsiIndex );
11166
 
                        if ( ulResult == cOCT6100_ERR_OK )
11167
 
                                fFirstExtraTsi = TRUE;
11168
 
                }
11169
 
 
11170
 
                if ( *f_pusFirstChanSinCopyEventIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
11171
 
                {
11172
 
                        /* Reserve the Sin copy event for the first channel.*/
11173
 
                        ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance, 
11174
 
                                                                                                                  f_pusFirstChanSinCopyEventIndex );
11175
 
                        if ( ulResult == cOCT6100_ERR_OK )
11176
 
                                fFirstSinCopyEvent = TRUE;
11177
 
                }
11178
 
        }
11179
 
 
11180
 
        if ( *f_pusSecondChanExtraTsiIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
11181
 
        {
11182
 
                /* Reserve the second Extra TSI memory entry */
11183
 
                ulResult = Oct6100ApiReserveTsiMemEntry(        f_pApiInstance, 
11184
 
                                                                                                        f_pusSecondChanExtraTsiIndex );
11185
 
                if ( ulResult == cOCT6100_ERR_OK )
11186
 
                        fSecondExtraTsi = TRUE;
11187
 
        }
11188
 
 
11189
 
        if ( *f_pusSecondChanSinCopyEventIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
11190
 
        {
11191
 
                /* Reserve the Sin copy event for the second channel.*/
11192
 
                ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance, 
11193
 
                                                                                                          f_pusSecondChanSinCopyEventIndex );
11194
 
                if ( ulResult == cOCT6100_ERR_OK )
11195
 
                        fSecondSinCopyEvent = TRUE;
11196
 
        }
11197
 
        /*===============================================================================*/
11198
 
 
11199
 
        
11200
 
        /*===============================================================================*/
11201
 
        /* Now reserve all the resources specific to bidirectional channels */
11202
 
        
11203
 
        if ( ulResult == cOCT6100_ERR_OK )
11204
 
        {
11205
 
                ulResult = Oct6100ApiReserveBiDirChanEntry(  f_pApiInstance, 
11206
 
                                                                                                 f_pusBiDirChanIndex );
11207
 
                if ( ulResult == cOCT6100_ERR_OK )
11208
 
                {
11209
 
                        fBiDirChanIndex = TRUE;
11210
 
 
11211
 
 
11212
 
                        {
11213
 
 
11214
 
                                /* Reserve the first channel Sout copy mixer event.*/
11215
 
                                ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance, 
11216
 
                                                                                                                          f_pusFirstChanSoutCopyEventIndex );
11217
 
                        }
11218
 
                        
11219
 
                        if ( ulResult == cOCT6100_ERR_OK )
11220
 
                        {
11221
 
                                fFirstSoutCopyEvent = TRUE;
11222
 
 
11223
 
                                /* Reserve the second channel Sout copy mixer event.*/
11224
 
                                ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance, 
11225
 
                                                                                                                          f_pusSecondChanSoutCopyEventIndex );
11226
 
                        }
11227
 
                }
11228
 
        }
11229
 
 
11230
 
        /*===============================================================================*/
11231
 
 
11232
 
 
11233
 
        /*===============================================================================*/
11234
 
        /* Release the resources if something went wrong */             
11235
 
        if ( ulResult != cOCT6100_ERR_OK  )
11236
 
        {
11237
 
                /*===============================================================================*/
11238
 
                /* Release the previously reserved echo resources .*/
11239
 
                if ( fBiDirChanIndex == TRUE )
11240
 
                {
11241
 
                        ulTempVar = Oct6100ApiReleaseBiDirChanEntry( f_pApiInstance, 
11242
 
                                                                                                                 *f_pusBiDirChanIndex );
11243
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
11244
 
                                return ulTempVar;
11245
 
                }
11246
 
 
11247
 
                if ( fFirstExtraTsi == TRUE )
11248
 
                {
11249
 
                        ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
11250
 
                                                                                                                *f_pusFirstChanExtraTsiIndex );
11251
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
11252
 
                                return ulTempVar;
11253
 
                }
11254
 
 
11255
 
                if ( fSecondExtraTsi == TRUE )
11256
 
                {
11257
 
                        ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
11258
 
                                                                                                                *f_pusSecondChanExtraTsiIndex );
11259
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
11260
 
                                return ulTempVar;
11261
 
                }
11262
 
 
11263
 
                if ( fFirstSinCopyEvent == TRUE )
11264
 
                {
11265
 
                        ulTempVar = Oct6100ApiReleaseMixerEventEntry(  f_pApiInstance,
11266
 
                                                                                                                   *f_pusFirstChanSinCopyEventIndex );
11267
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
11268
 
                                return ulTempVar;
11269
 
                }
11270
 
 
11271
 
                if ( fSecondSinCopyEvent == TRUE )
11272
 
                {
11273
 
                        ulTempVar = Oct6100ApiReleaseMixerEventEntry(  f_pApiInstance,
11274
 
                                                                                                                   *f_pusSecondChanSinCopyEventIndex );
11275
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
11276
 
                                return ulTempVar;
11277
 
                }
11278
 
 
11279
 
                if ( ( fFirstSoutCopyEvent == TRUE )
11280
 
 
11281
 
                        )
11282
 
                {
11283
 
                        ulTempVar = Oct6100ApiReleaseMixerEventEntry(  f_pApiInstance,
11284
 
                                                                                                                   *f_pusFirstChanSoutCopyEventIndex );
11285
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
11286
 
                                return ulTempVar;
11287
 
                }
11288
 
 
11289
 
                /*===============================================================================*/
11290
 
 
11291
 
                return ulResult;
11292
 
        }
11293
 
 
11294
 
        return cOCT6100_ERR_OK;
11295
 
}
11296
 
#endif
11297
 
 
11298
 
 
11299
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11300
 
 
11301
 
Function:               Oct6100ApiWriteChannelCreateBiDirStructs
11302
 
 
11303
 
Description:    Performs all the required structure writes to configure the
11304
 
                                new echo cancellation channel.
11305
 
 
11306
 
-------------------------------------------------------------------------------
11307
 
|       Argument                |       Description
11308
 
-------------------------------------------------------------------------------
11309
 
f_pApiInstance                                          Pointer to API instance. This memory is used to keep the
11310
 
                                                                        present state of the chip and all its resources.
11311
 
 
11312
 
f_usFirstChanIndex                                      Pointer to the first channel index.
11313
 
f_usFirstChanExtraTsiIndex                      Pointer to the first channel extra TSI index.
11314
 
f_usFirstChanSinCopyEventIndex          Pointer to the first channel Sin copy event index.
11315
 
f_usFirstChanSoutCopyEventIndex         Pointer to the first channel Sout copy event index.
11316
 
f_usFirstChanIndex                                      Pointer to the second channel index.
11317
 
f_usSecondChanExtraTsiIndex                     Pointer to the second channel extra TSI index.
11318
 
f_usSecondChanSinCopyEventIndex         Pointer to the second channel Sin copy event index.
11319
 
f_usSecondChanSoutCopyEventIndex        Pointer to the second channel Sout copy event index.
11320
 
 
11321
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11322
 
#if !SKIP_Oct6100ApiWriteChannelCreateBiDirStructs
11323
 
UINT32 Oct6100ApiWriteChannelCreateBiDirStructs(
11324
 
                                IN      tPOCT6100_INSTANCE_API                          f_pApiInstance,
11325
 
 
11326
 
                                IN      UINT16                                                          f_usFirstChanIndex,
11327
 
                                IN      UINT16                                                          f_usFirstChanExtraTsiIndex, 
11328
 
                                IN      UINT16                                                          f_usFirstChanSinCopyEventIndex, 
11329
 
                                IN      UINT16                                                          f_usFirstChanSoutCopyEventIndex,
11330
 
                                IN      UINT16                                                          f_usSecondChanIndex,
11331
 
                                IN      UINT16                                                          f_usSecondChanExtraTsiIndex, 
11332
 
                                IN      UINT16                                                          f_usSecondChanSinCopyEventIndex,
11333
 
                                IN      UINT16                                                          f_usSecondChanSoutCopyEventIndex )
11334
 
{
11335
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
11336
 
        tPOCT6100_API_CHANNEL                   pFirstChanEntry;
11337
 
        tPOCT6100_API_CHANNEL                   pSecondChanEntry;
11338
 
 
11339
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
11340
 
        UINT32  ulResult;
11341
 
        
11342
 
 
11343
 
        /* Obtain local pointer to shared portion of instance. */
11344
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11345
 
 
11346
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
11347
 
 
11348
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
11349
 
        
11350
 
        /*==============================================================================*/
11351
 
        /* Get a pointer to the two channel entry.*/
11352
 
        
11353
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
11354
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
11355
 
 
11356
 
 
11357
 
 
11358
 
 
11359
 
        {
11360
 
                /*==============================================================================*/
11361
 
                /* Configure the Tsst control memory and add the Sin copy event if necessary. */
11362
 
                
11363
 
                /*=======================================================================*/
11364
 
                /* Program the Sin Copy event.*/
11365
 
                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11366
 
                
11367
 
                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11368
 
                WriteParams.usWriteData |= f_usFirstChanExtraTsiIndex;
11369
 
                WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11370
 
 
11371
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11372
 
                if ( ulResult != cOCT6100_ERR_OK  )
11373
 
                        return ulResult;
11374
 
 
11375
 
                WriteParams.ulWriteAddress += 2;
11376
 
                WriteParams.usWriteData = (UINT16)( pFirstChanEntry->usSinSoutTsiMemIndex );
11377
 
 
11378
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11379
 
                if ( ulResult != cOCT6100_ERR_OK  )
11380
 
                        return ulResult;
11381
 
 
11382
 
                /*=======================================================================*/
11383
 
 
11384
 
                /* Configure the TSST memory.*/
11385
 
                if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11386
 
                {
11387
 
                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11388
 
                                                                                                                          pFirstChanEntry->usSinTsstIndex,
11389
 
                                                                                                                          f_usFirstChanExtraTsiIndex,
11390
 
                                                                                                                          pFirstChanEntry->TdmConfig.bySinPcmLaw );
11391
 
                        if ( ulResult != cOCT6100_ERR_OK )
11392
 
                                return ulResult;
11393
 
                }
11394
 
 
11395
 
                /* Now insert the event into the event list.*/
11396
 
                ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11397
 
                                                                                        f_usFirstChanSinCopyEventIndex,
11398
 
                                                                                        cOCT6100_EVENT_TYPE_SIN_COPY,
11399
 
                                                                                        f_usFirstChanIndex );
11400
 
                if ( ulResult != cOCT6100_ERR_OK )
11401
 
                        return ulResult;
11402
 
 
11403
 
                /*==============================================================================*/
11404
 
        }
11405
 
 
11406
 
 
11407
 
 
11408
 
        /*==============================================================================*/
11409
 
        /* Configure the Tsst control memory and add the Sin copy event if necessary.*/
11410
 
        
11411
 
        /*=======================================================================*/
11412
 
        /* Program the Sin Copy event.*/
11413
 
        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSecondChanSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11414
 
        
11415
 
        WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11416
 
        WriteParams.usWriteData |= f_usSecondChanExtraTsiIndex;
11417
 
        WriteParams.usWriteData |= pSecondChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11418
 
 
11419
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11420
 
        if ( ulResult != cOCT6100_ERR_OK  )
11421
 
                return ulResult;
11422
 
 
11423
 
        WriteParams.ulWriteAddress += 2;
11424
 
        WriteParams.usWriteData = (UINT16)( pSecondChanEntry->usSinSoutTsiMemIndex );
11425
 
 
11426
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11427
 
        if ( ulResult != cOCT6100_ERR_OK  )
11428
 
                return ulResult;
11429
 
 
11430
 
        /*=======================================================================*/
11431
 
 
11432
 
        /* Configure the TSST memory.*/
11433
 
        if ( pSecondChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11434
 
        {
11435
 
 
11436
 
                {
11437
 
                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11438
 
                                                                                                                          pSecondChanEntry->usSinTsstIndex,
11439
 
                                                                                                                          f_usSecondChanExtraTsiIndex,
11440
 
                                                                                                                          pSecondChanEntry->TdmConfig.bySinPcmLaw );
11441
 
                }
11442
 
                if ( ulResult != cOCT6100_ERR_OK )
11443
 
                        return ulResult;
11444
 
        }
11445
 
 
11446
 
        /* Now insert the event into the event list.*/
11447
 
        ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11448
 
                                                                                f_usSecondChanSinCopyEventIndex,
11449
 
                                                                                cOCT6100_EVENT_TYPE_SIN_COPY,
11450
 
                                                                                f_usSecondChanIndex );
11451
 
        if ( ulResult != cOCT6100_ERR_OK )
11452
 
                return ulResult;
11453
 
 
11454
 
        /*==============================================================================*/
11455
 
 
11456
 
 
11457
 
 
11458
 
        /*==============================================================================*/
11459
 
        /* Now, let's configure the two Sout copy events.*/
11460
 
 
11461
 
 
11462
 
                /* First event.*/
11463
 
                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11464
 
                
11465
 
                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11466
 
                WriteParams.usWriteData |= pFirstChanEntry->usSinSoutTsiMemIndex;
11467
 
                WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11468
 
 
11469
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11470
 
                if ( ulResult != cOCT6100_ERR_OK  )
11471
 
                        return ulResult;
11472
 
 
11473
 
                WriteParams.ulWriteAddress += 2;
11474
 
                WriteParams.usWriteData = pSecondChanEntry->usRinRoutTsiMemIndex;
11475
 
 
11476
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11477
 
                if ( ulResult != cOCT6100_ERR_OK  )
11478
 
                        return ulResult;
11479
 
 
11480
 
                ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11481
 
                                                                                        f_usFirstChanSoutCopyEventIndex,
11482
 
                                                                                        cOCT6100_EVENT_TYPE_SOUT_COPY,
11483
 
                                                                                        f_usFirstChanIndex );
11484
 
                if ( ulResult != cOCT6100_ERR_OK )
11485
 
                        return ulResult;
11486
 
 
11487
 
 
11488
 
        /* Second event.*/      
11489
 
        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSecondChanSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11490
 
        
11491
 
        WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11492
 
        WriteParams.usWriteData |= pSecondChanEntry->usSinSoutTsiMemIndex;
11493
 
        WriteParams.usWriteData |= pSecondChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11494
 
 
11495
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11496
 
        if ( ulResult != cOCT6100_ERR_OK  )
11497
 
                return ulResult;
11498
 
 
11499
 
        WriteParams.ulWriteAddress += 2;
11500
 
        WriteParams.usWriteData = pFirstChanEntry->usRinRoutTsiMemIndex;
11501
 
 
11502
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11503
 
        if ( ulResult != cOCT6100_ERR_OK  )
11504
 
                return ulResult;
11505
 
        
11506
 
        
11507
 
        ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11508
 
                                                                                f_usSecondChanSoutCopyEventIndex,
11509
 
                                                                                cOCT6100_EVENT_TYPE_SOUT_COPY,
11510
 
                                                                                f_usSecondChanIndex );
11511
 
        if ( ulResult != cOCT6100_ERR_OK )
11512
 
                return ulResult;
11513
 
 
11514
 
        /*==============================================================================*/
11515
 
 
11516
 
 
11517
 
        /*==============================================================================*/
11518
 
        /* Clear + release the silence events if they were created. */
11519
 
 
11520
 
        if ( pFirstChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
11521
 
        {
11522
 
                /* Remove the event from the list.*/
11523
 
                ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
11524
 
                                                                                                pFirstChanEntry->usRinSilenceEventIndex,
11525
 
                                                                                                cOCT6100_EVENT_TYPE_SOUT_COPY );
11526
 
                if ( ulResult != cOCT6100_ERR_OK )
11527
 
                        return ulResult;
11528
 
 
11529
 
                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usRinSilenceEventIndex );
11530
 
                if ( ulResult != cOCT6100_ERR_OK  )
11531
 
                        return cOCT6100_ERR_FATAL_E0;
11532
 
 
11533
 
                pFirstChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
11534
 
        }
11535
 
 
11536
 
        if ( ( pSecondChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
11537
 
 
11538
 
                )
11539
 
        {
11540
 
                /* Remove the event from the list.*/
11541
 
                ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
11542
 
                                                                                                pSecondChanEntry->usRinSilenceEventIndex,
11543
 
                                                                                                cOCT6100_EVENT_TYPE_SOUT_COPY );
11544
 
                if ( ulResult != cOCT6100_ERR_OK )
11545
 
                        return ulResult;
11546
 
 
11547
 
                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usRinSilenceEventIndex );
11548
 
                if ( ulResult != cOCT6100_ERR_OK  )
11549
 
                        return cOCT6100_ERR_FATAL_E0;
11550
 
 
11551
 
                pSecondChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
11552
 
        }
11553
 
 
11554
 
        /*==============================================================================*/
11555
 
 
11556
 
        return cOCT6100_ERR_OK;
11557
 
}
11558
 
#endif
11559
 
 
11560
 
 
11561
 
 
11562
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11563
 
 
11564
 
Function:               Oct6100ApiUpdateBiDirChannelEntry
11565
 
 
11566
 
Description:    Updates the new bidir channel and the channel used to create that channel.
11567
 
 
11568
 
-------------------------------------------------------------------------------
11569
 
|       Argument                |       Description
11570
 
-------------------------------------------------------------------------------
11571
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
11572
 
                                                the present state of the chip and all its resources.
11573
 
 
11574
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11575
 
#if !SKIP_Oct6100ApiUpdateBiDirChannelEntry
11576
 
UINT32 Oct6100ApiUpdateBiDirChannelEntry(
11577
 
                                IN      tPOCT6100_INSTANCE_API                          f_pApiInstance,
11578
 
                                OUT     tPOCT6100_CHANNEL_CREATE_BIDIR          f_pChannelCreateBiDir,
11579
 
                                IN      UINT16                                                          f_usBiDirChanIndex,
11580
 
                                IN      UINT16                                                          f_usFirstChanIndex,
11581
 
                                IN      UINT16                                                          f_usFirstChanExtraTsiIndex, 
11582
 
                                IN      UINT16                                                          f_usFirstChanSinCopyEventIndex, 
11583
 
                                IN      UINT16                                                          f_usFirstChanSoutCopyEventIndex,
11584
 
                                IN      UINT16                                                          f_usSecondChanIndex,
11585
 
                                IN      UINT16                                                          f_usSecondChanExtraTsiIndex, 
11586
 
                                IN      UINT16                                                          f_usSecondChanSinCopyEventIndex,
11587
 
                                IN      UINT16                                                          f_usSecondChanSoutCopyEventIndex )
11588
 
{
11589
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
11590
 
        tPOCT6100_API_CHANNEL                   pFirstChanEntry;
11591
 
        tPOCT6100_API_CHANNEL                   pSecondChanEntry;
11592
 
        tPOCT6100_API_BIDIR_CHANNEL             pBiDirChanEntry;
11593
 
 
11594
 
        /* Obtain local pointer to shared portion of instance. */
11595
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11596
 
 
11597
 
        /* Obtain a pointer to the new buffer's list entry. */
11598
 
        mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, f_usBiDirChanIndex );
11599
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
11600
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
11601
 
        
11602
 
        /*=======================================================================*/
11603
 
        /* Copy the channel's configuration and allocated resources. */
11604
 
 
11605
 
        pFirstChanEntry->usExtraSinTsiMemIndex  = f_usFirstChanExtraTsiIndex;
11606
 
        pFirstChanEntry->usSinCopyEventIndex    = f_usFirstChanSinCopyEventIndex;
11607
 
        pFirstChanEntry->usSoutCopyEventIndex   = f_usFirstChanSoutCopyEventIndex;
11608
 
 
11609
 
        pSecondChanEntry->usExtraSinTsiMemIndex = f_usSecondChanExtraTsiIndex;
11610
 
        pSecondChanEntry->usSinCopyEventIndex   = f_usSecondChanSinCopyEventIndex;
11611
 
        pSecondChanEntry->usSoutCopyEventIndex  = f_usSecondChanSoutCopyEventIndex;
11612
 
 
11613
 
        /* Save the channel info in the bidir channel.*/
11614
 
        pBiDirChanEntry->usFirstChanIndex = f_usFirstChanIndex;
11615
 
        pBiDirChanEntry->usSecondChanIndex = f_usSecondChanIndex;
11616
 
 
11617
 
 
11618
 
 
11619
 
        /* Increment the extra TSI memory dependency count.*/
11620
 
 
11621
 
                pFirstChanEntry->usExtraSinTsiDependencyCnt++;
11622
 
        pSecondChanEntry->usExtraSinTsiDependencyCnt++;
11623
 
 
11624
 
        /* Set the bidir flag in the channel structure.*/
11625
 
        pFirstChanEntry->fBiDirChannel = TRUE;  
11626
 
        pSecondChanEntry->fBiDirChannel = TRUE;
11627
 
 
11628
 
        /*=======================================================================*/
11629
 
        
11630
 
        /* Form handle returned to user. */
11631
 
        *f_pChannelCreateBiDir->pulBiDirChannelHndl = cOCT6100_HNDL_TAG_BIDIR_CHANNEL | (pBiDirChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_usBiDirChanIndex;
11632
 
 
11633
 
        /* Finally, mark the channel as open. */
11634
 
        pBiDirChanEntry->fReserved = TRUE;
11635
 
        
11636
 
        /* Increment the number of channel open.*/
11637
 
        f_pApiInstance->pSharedInfo->ChipStats.usNumberBiDirChannels++;
11638
 
 
11639
 
        /*=======================================================================*/
11640
 
 
11641
 
        return cOCT6100_ERR_OK;
11642
 
}
11643
 
#endif
11644
 
 
11645
 
 
11646
 
 
11647
 
 
11648
 
 
11649
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11650
 
 
11651
 
Function:               Oct6100ChannelDestroyBiDirSer
11652
 
 
11653
 
Description:    Closes a bidirectional channel.
11654
 
 
11655
 
-------------------------------------------------------------------------------
11656
 
|       Argument                |       Description
11657
 
-------------------------------------------------------------------------------
11658
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
11659
 
                                                present state of the chip and all its resources.
11660
 
 
11661
 
f_pChannelDestroyBiDir  Pointer to a destroy bidirectionnal channel structure.
11662
 
 
11663
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11664
 
#if !SKIP_Oct6100ChannelDestroyBiDirSer
11665
 
UINT32 Oct6100ChannelDestroyBiDirSer(
11666
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
11667
 
                                IN tPOCT6100_CHANNEL_DESTROY_BIDIR              f_pChannelDestroyBiDir )
11668
 
{
11669
 
        UINT16  usBiDirChanIndex;
11670
 
        UINT16  usFirstChanIndex;
11671
 
        UINT16  usSecondChanIndex;
11672
 
 
11673
 
 
11674
 
        UINT32  ulResult;
11675
 
 
11676
 
        /* Verify that all the parameters given match the state of the API. */
11677
 
        ulResult = Oct6100ApiAssertDestroyBiDirChanParams(      f_pApiInstance, 
11678
 
                                                                                                                f_pChannelDestroyBiDir, 
11679
 
                                                                                                                &usBiDirChanIndex,
11680
 
 
11681
 
                                                                                                                &usFirstChanIndex,
11682
 
                                                                                                                &usSecondChanIndex );
11683
 
        if ( ulResult != cOCT6100_ERR_OK  )
11684
 
                return ulResult;
11685
 
 
11686
 
        /* Release all resources associated to the echo cancellation channel. */
11687
 
        ulResult = Oct6100ApiInvalidateBiDirChannelStructs( f_pApiInstance, 
11688
 
 
11689
 
                                                                                                                usFirstChanIndex,
11690
 
                                                                                                                usSecondChanIndex );
11691
 
        if ( ulResult != cOCT6100_ERR_OK  )
11692
 
                return ulResult;
11693
 
 
11694
 
        /* Release all resources associated to the echo cancellation channel. */
11695
 
        ulResult = Oct6100ApiReleaseBiDirChannelResources(      f_pApiInstance, 
11696
 
                                                                                                                usBiDirChanIndex,
11697
 
 
11698
 
                                                                                                                usFirstChanIndex,
11699
 
                                                                                                                usSecondChanIndex );
11700
 
        if ( ulResult != cOCT6100_ERR_OK  )
11701
 
                return ulResult;
11702
 
 
11703
 
        /* Invalidate the handle.*/
11704
 
        f_pChannelDestroyBiDir->ulBiDirChannelHndl = cOCT6100_INVALID_HANDLE;
11705
 
 
11706
 
        return cOCT6100_ERR_OK;
11707
 
}
11708
 
#endif
11709
 
 
11710
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11711
 
 
11712
 
Function:               Oct6100ApiAssertDestroyBiDirChanParams
11713
 
 
11714
 
Description:    Validate the handle given by the user and verify the state of 
11715
 
                                the channel about to be closed.
11716
 
 
11717
 
-------------------------------------------------------------------------------
11718
 
|       Argument                |       Description
11719
 
-------------------------------------------------------------------------------
11720
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
11721
 
                                                present state of the chip and all its resources.
11722
 
 
11723
 
f_pChannelDestroyBiDir  Pointer to a destroy bidirectional channel structure.
11724
 
f_pusBiDirChanIndex             Pointer to the bidir channel entry within the API's list.
11725
 
f_pusFirstChanIndex             Pointer to the first channel index part of the bidir channel.
11726
 
f_pusFirstChanIndex             Pointer to the second channel index part of the bidir channel.
11727
 
 
11728
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11729
 
#if !SKIP_Oct6100ApiAssertDestroyBiDirChanParams
11730
 
UINT32 Oct6100ApiAssertDestroyBiDirChanParams( 
11731
 
                                IN              tPOCT6100_INSTANCE_API                          f_pApiInstance,
11732
 
                                IN              tPOCT6100_CHANNEL_DESTROY_BIDIR         f_pChannelDestroyBiDir,
11733
 
                                IN OUT  PUINT16                                                         f_pusBiDirChanIndex,
11734
 
 
11735
 
                                IN OUT  PUINT16                                                         f_pusFirstChanIndex,
11736
 
                                IN OUT  PUINT16                                                         f_pusSecondChanIndex )
11737
 
{
11738
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
11739
 
        tPOCT6100_API_BIDIR_CHANNEL             pBiDirChanEntry;
11740
 
        UINT32                                                  ulEntryOpenCnt;
11741
 
 
11742
 
        /* Get local pointer(s). */
11743
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11744
 
 
11745
 
        /* Check the provided handle. */
11746
 
        if ( (f_pChannelDestroyBiDir->ulBiDirChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_BIDIR_CHANNEL )
11747
 
                return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
11748
 
 
11749
 
        *f_pusBiDirChanIndex = (UINT16)( f_pChannelDestroyBiDir->ulBiDirChannelHndl & cOCT6100_HNDL_INDEX_MASK );
11750
 
        if ( *f_pusBiDirChanIndex  >= pSharedInfo->ChipConfig.usMaxBiDirChannels )
11751
 
                return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
11752
 
 
11753
 
        /*=======================================================================*/
11754
 
        /* Get a pointer to the bidir channel's list entry. */
11755
 
 
11756
 
        mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, *f_pusBiDirChanIndex  )
11757
 
 
11758
 
        /* Extract the entry open count from the provided handle. */
11759
 
        ulEntryOpenCnt = ( f_pChannelDestroyBiDir->ulBiDirChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
11760
 
 
11761
 
        /* Check for errors. */
11762
 
        if ( pBiDirChanEntry->fReserved != TRUE )
11763
 
                return cOCT6100_ERR_CHANNEL_BIDIR_CHAN_NOT_OPEN;
11764
 
        if ( ulEntryOpenCnt != pBiDirChanEntry->byEntryOpenCnt )
11765
 
                return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
11766
 
 
11767
 
        /*=======================================================================*/
11768
 
        
11769
 
        /* Return the index of the channel used to create this bidirectional channel.*/
11770
 
        *f_pusFirstChanIndex = pBiDirChanEntry->usFirstChanIndex;
11771
 
        *f_pusSecondChanIndex = pBiDirChanEntry->usSecondChanIndex;
11772
 
 
11773
 
 
11774
 
 
11775
 
        return cOCT6100_ERR_OK;
11776
 
}
11777
 
#endif
11778
 
 
11779
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11780
 
 
11781
 
Function:               Oct6100ApiInvalidateBiDirChannelStructs
11782
 
 
11783
 
Description:    Destroy the link between the two channels.
11784
 
 
11785
 
-------------------------------------------------------------------------------
11786
 
|       Argument                |       Description
11787
 
-------------------------------------------------------------------------------
11788
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
11789
 
                                                        present state of the chip and all its resources.
11790
 
 
11791
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11792
 
#if !SKIP_Oct6100ApiInvalidateBiDirChannelStructs
11793
 
UINT32 Oct6100ApiInvalidateBiDirChannelStructs( 
11794
 
                                IN              tPOCT6100_INSTANCE_API                          f_pApiInstance,
11795
 
 
11796
 
                                IN              UINT16                                                          f_usFirstChanIndex,
11797
 
                                IN              UINT16                                                          f_usSecondChanIndex )
11798
 
{
11799
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
11800
 
        tPOCT6100_API_CHANNEL                   pFirstChanEntry;
11801
 
        tPOCT6100_API_CHANNEL                   pSecondChanEntry;
11802
 
 
11803
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
11804
 
        UINT32  ulResult;
11805
 
        
11806
 
        /* Obtain local pointer to shared portion of instance. */
11807
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11808
 
 
11809
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
11810
 
 
11811
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
11812
 
 
11813
 
        /* Get pointers to the API entry of the two channel used to create the bidir channel.*/
11814
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry,  f_usFirstChanIndex );
11815
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
11816
 
 
11817
 
        /* Clear the SIN copy event of the first channel and release the Extra TSI memory if 
11818
 
          this feature was the only one using it. */
11819
 
 
11820
 
        {
11821
 
                if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 )
11822
 
                {
11823
 
                        /*=======================================================================*/
11824
 
                        /* Clear the Sin Copy event.*/
11825
 
                        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11826
 
                        WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
11827
 
 
11828
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11829
 
                        if ( ulResult != cOCT6100_ERR_OK  )
11830
 
                                return ulResult;
11831
 
 
11832
 
                        /*=======================================================================*/
11833
 
 
11834
 
                        /* Configure the TSST memory.*/
11835
 
                        if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11836
 
                        {
11837
 
                                ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11838
 
                                                                                                                                  pFirstChanEntry->usSinTsstIndex,
11839
 
                                                                                                                                  pFirstChanEntry->usSinSoutTsiMemIndex,
11840
 
                                                                                                                                  pFirstChanEntry->TdmConfig.bySinPcmLaw );
11841
 
                                if ( ulResult != cOCT6100_ERR_OK )
11842
 
                                        return ulResult;
11843
 
                        }
11844
 
 
11845
 
                        /* Remove the event from the list.*/
11846
 
                        ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
11847
 
                                                                                                        pFirstChanEntry->usSinCopyEventIndex,
11848
 
                                                                                                        cOCT6100_EVENT_TYPE_SIN_COPY );
11849
 
                        if ( ulResult != cOCT6100_ERR_OK )
11850
 
                                return ulResult;
11851
 
 
11852
 
                }
11853
 
        }
11854
 
 
11855
 
        /* Clear the SIN copy event of the first channel and release the Extra TSI memory if 
11856
 
          this feature was the only one using it. */
11857
 
        if ( pSecondChanEntry->usExtraSinTsiDependencyCnt == 1 )
11858
 
        {
11859
 
                /*=======================================================================*/
11860
 
                /* Clear the Sin Copy event.*/
11861
 
                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSecondChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11862
 
                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
11863
 
 
11864
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11865
 
                if ( ulResult != cOCT6100_ERR_OK  )
11866
 
                        return ulResult;
11867
 
 
11868
 
                /*=======================================================================*/
11869
 
 
11870
 
                /* Configure the TSST memory.*/
11871
 
                if ( pSecondChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11872
 
                {
11873
 
                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11874
 
                                                                                                                          pSecondChanEntry->usSinTsstIndex,
11875
 
                                                                                                                          pSecondChanEntry->usSinSoutTsiMemIndex,
11876
 
                                                                                                                          pSecondChanEntry->TdmConfig.bySinPcmLaw );
11877
 
                        if ( ulResult != cOCT6100_ERR_OK )
11878
 
                                return ulResult;
11879
 
                }
11880
 
 
11881
 
                /* Remove the event from the list.*/
11882
 
                ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
11883
 
                                                                                                pSecondChanEntry->usSinCopyEventIndex,
11884
 
                                                                                                cOCT6100_EVENT_TYPE_SIN_COPY );
11885
 
                if ( ulResult != cOCT6100_ERR_OK )
11886
 
                        return ulResult;
11887
 
 
11888
 
        }
11889
 
 
11890
 
        /* Now remove the sout copy of the first channel.*/
11891
 
 
11892
 
 
11893
 
        {
11894
 
                /*=======================================================================*/
11895
 
                /* Clear the Sout Copy event of the first channel.*/
11896
 
                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11897
 
                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
11898
 
 
11899
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11900
 
                if ( ulResult != cOCT6100_ERR_OK  )
11901
 
                        return ulResult;
11902
 
                /*=======================================================================*/
11903
 
 
11904
 
                /* Remove the event from the list.*/
11905
 
                ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
11906
 
                                                                                                pFirstChanEntry->usSoutCopyEventIndex,
11907
 
                                                                                                cOCT6100_EVENT_TYPE_SOUT_COPY );
11908
 
                if ( ulResult != cOCT6100_ERR_OK )
11909
 
                        return ulResult;
11910
 
        }
11911
 
 
11912
 
 
11913
 
 
11914
 
        /* Now remove the sout copy of the second channel.*/
11915
 
 
11916
 
        /*=======================================================================*/
11917
 
        /* Clear the Sout Copy event of the second channel.*/
11918
 
        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSecondChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11919
 
        WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
11920
 
 
11921
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11922
 
        if ( ulResult != cOCT6100_ERR_OK  )
11923
 
                return ulResult;
11924
 
        /*=======================================================================*/
11925
 
 
11926
 
        /* Remove the event from the list.*/
11927
 
        ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
11928
 
                                                                                        pSecondChanEntry->usSoutCopyEventIndex,
11929
 
                                                                                        cOCT6100_EVENT_TYPE_SOUT_COPY );
11930
 
        if ( ulResult != cOCT6100_ERR_OK )
11931
 
                return ulResult;
11932
 
 
11933
 
 
11934
 
 
11935
 
        return cOCT6100_ERR_OK;
11936
 
}
11937
 
#endif
11938
 
 
11939
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11940
 
 
11941
 
Function:               Oct6100ApiReleaseBiDirChannelResources
11942
 
 
11943
 
Description:    Release and clear the API entry associated to the bidirectional channel.
11944
 
 
11945
 
-------------------------------------------------------------------------------
11946
 
|       Argument                |       Description
11947
 
-------------------------------------------------------------------------------
11948
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
11949
 
                                                present state of the chip and all its resources.
11950
 
 
11951
 
f_usBiDirChanIndex              Index of the bidirectionnal channel in the API's bidir channel list.
11952
 
f_usFirstChanIndex              Index of the first channel used to create the bidir channel.
11953
 
f_usSecondChanIndex             Index of the second channel used to create the bidir channel.
11954
 
 
11955
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11956
 
#if !SKIP_Oct6100ApiReleaseBiDirChannelResources
11957
 
UINT32 Oct6100ApiReleaseBiDirChannelResources( 
11958
 
                                IN              tPOCT6100_INSTANCE_API                          f_pApiInstance,
11959
 
                                IN              UINT16                                                          f_usBiDirChanIndex,
11960
 
 
11961
 
                                IN              UINT16                                                          f_usFirstChanIndex,
11962
 
                                IN              UINT16                                                          f_usSecondChanIndex )
11963
 
{
11964
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
11965
 
        tPOCT6100_API_BIDIR_CHANNEL             pBiDirChanEntry;
11966
 
        tPOCT6100_API_CHANNEL                   pFirstChanEntry;
11967
 
        tPOCT6100_API_CHANNEL                   pSecondChanEntry;
11968
 
        tPOCT6100_API_MIXER_EVENT               pTempEventEntry;
11969
 
        UINT32  ulResult;
11970
 
        
11971
 
        /* Obtain local pointer to shared portion of instance. */
11972
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11973
 
 
11974
 
        mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, f_usBiDirChanIndex );
11975
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry,  f_usFirstChanIndex );
11976
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
11977
 
 
11978
 
        /* Release the bidir entry.*/
11979
 
        ulResult = Oct6100ApiReleaseBiDirChanEntry( f_pApiInstance, f_usBiDirChanIndex );
11980
 
        if ( ulResult != cOCT6100_ERR_OK  )
11981
 
                return cOCT6100_ERR_FATAL_AC;
11982
 
        
11983
 
        /* Release the Extra TSI memory and the SIN copy event if required.*/
11984
 
 
11985
 
        {
11986
 
                if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 )
11987
 
                {
11988
 
                        /* Release the two TSI chariot memory entries.*/
11989
 
                        ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pFirstChanEntry->usExtraSinTsiMemIndex );
11990
 
                        if ( ulResult != cOCT6100_ERR_OK  )
11991
 
                                return cOCT6100_ERR_FATAL_A3;
11992
 
 
11993
 
                        /* Relese the SIN copy event.*/
11994
 
                        ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSinCopyEventIndex );
11995
 
                        if ( ulResult != cOCT6100_ERR_OK  )
11996
 
                                return cOCT6100_ERR_FATAL_A4;
11997
 
 
11998
 
                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pFirstChanEntry->usSinCopyEventIndex );
11999
 
 
12000
 
                        /* Invalidate the entry.*/
12001
 
                        pTempEventEntry->fReserved              = FALSE;
12002
 
                        pTempEventEntry->usEventType    = cOCT6100_INVALID_EVENT;
12003
 
                        pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12004
 
 
12005
 
                        pFirstChanEntry->usExtraSinTsiDependencyCnt--;
12006
 
                        pFirstChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
12007
 
                        pFirstChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
12008
 
                }
12009
 
                else
12010
 
                {
12011
 
                        pFirstChanEntry->usExtraSinTsiDependencyCnt--;
12012
 
                }
12013
 
        }
12014
 
 
12015
 
        if ( pSecondChanEntry->usExtraSinTsiDependencyCnt == 1 )
12016
 
        {
12017
 
                /* Release the two TSI chariot memory entries.*/
12018
 
                ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pSecondChanEntry->usExtraSinTsiMemIndex );
12019
 
                if ( ulResult != cOCT6100_ERR_OK  )
12020
 
                        return cOCT6100_ERR_FATAL_A5;
12021
 
 
12022
 
                /* Relese the SIN copy event.*/
12023
 
                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usSinCopyEventIndex );
12024
 
                if ( ulResult != cOCT6100_ERR_OK  )
12025
 
                        return cOCT6100_ERR_FATAL_A6;
12026
 
 
12027
 
                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pSecondChanEntry->usSinCopyEventIndex );
12028
 
                /* Invalidate the entry.*/
12029
 
                pTempEventEntry->fReserved              = FALSE;
12030
 
                pTempEventEntry->usEventType    = cOCT6100_INVALID_EVENT;
12031
 
                pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12032
 
 
12033
 
                pSecondChanEntry->usExtraSinTsiDependencyCnt--;
12034
 
                pSecondChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
12035
 
                pSecondChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
12036
 
        }
12037
 
        else
12038
 
        {
12039
 
                pSecondChanEntry->usExtraSinTsiDependencyCnt--;
12040
 
        }
12041
 
 
12042
 
 
12043
 
        {
12044
 
                /* Release the SOUT copy event of the first channel.*/
12045
 
                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSoutCopyEventIndex );
12046
 
                if ( ulResult != cOCT6100_ERR_OK  )
12047
 
                        return cOCT6100_ERR_FATAL_A7;
12048
 
 
12049
 
                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pFirstChanEntry->usSoutCopyEventIndex );
12050
 
                /* Invalidate the entry.*/
12051
 
                pTempEventEntry->fReserved              = FALSE;
12052
 
                pTempEventEntry->usEventType    = cOCT6100_INVALID_EVENT;
12053
 
                pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12054
 
        }
12055
 
 
12056
 
        /* Release the SOUT copy event of the second channel.*/
12057
 
        ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usSoutCopyEventIndex );
12058
 
        if ( ulResult != cOCT6100_ERR_OK  )
12059
 
                return cOCT6100_ERR_FATAL_A8;
12060
 
 
12061
 
        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pSecondChanEntry->usSoutCopyEventIndex );
12062
 
        /* Invalidate the entry.*/
12063
 
        pTempEventEntry->fReserved              = FALSE;
12064
 
        pTempEventEntry->usEventType    = cOCT6100_INVALID_EVENT;
12065
 
        pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12066
 
 
12067
 
 
12068
 
        /*=======================================================================*/
12069
 
        /* Update the first channel's list entry. */
12070
 
 
12071
 
        /* Mark the channel as closed. */
12072
 
        pFirstChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX;
12073
 
        pFirstChanEntry->fBiDirChannel = FALSE;
12074
 
 
12075
 
        /*=======================================================================*/
12076
 
 
12077
 
        /*=======================================================================*/
12078
 
        /* Update the second channel's list entry. */
12079
 
 
12080
 
        /* Mark the channel as closed. */
12081
 
 
12082
 
        pSecondChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX;
12083
 
        pSecondChanEntry->fBiDirChannel = FALSE;
12084
 
 
12085
 
        /*=======================================================================*/
12086
 
 
12087
 
        /*=======================================================================*/
12088
 
        /* Update the bidirectional channel's list entry. */
12089
 
 
12090
 
        /* Mark the channel as closed. */
12091
 
        pBiDirChanEntry->fReserved = FALSE;
12092
 
        pBiDirChanEntry->byEntryOpenCnt++;
12093
 
 
12094
 
        pBiDirChanEntry->usFirstChanIndex = cOCT6100_INVALID_INDEX;
12095
 
        pBiDirChanEntry->usSecondChanIndex = cOCT6100_INVALID_INDEX;
12096
 
        
12097
 
        /* Decrement the number of channel open.*/
12098
 
        f_pApiInstance->pSharedInfo->ChipStats.usNumberBiDirChannels--;
12099
 
 
12100
 
        /*=======================================================================*/
12101
 
 
12102
 
 
12103
 
        /*=======================================================================*/
12104
 
        /* Check if some of the ports must be muted back. */
12105
 
        
12106
 
        ulResult = Oct6100ApiMutePorts( f_pApiInstance,
12107
 
                                                                        f_usFirstChanIndex,
12108
 
                                                                        pFirstChanEntry->usRinTsstIndex,
12109
 
                                                                        pFirstChanEntry->usSinTsstIndex,
12110
 
                                                                        FALSE );
12111
 
        if ( ulResult != cOCT6100_ERR_OK )
12112
 
                return ulResult;
12113
 
 
12114
 
        ulResult = Oct6100ApiMutePorts( f_pApiInstance,
12115
 
                                                                        f_usSecondChanIndex,
12116
 
                                                                        pSecondChanEntry->usRinTsstIndex,
12117
 
                                                                        pSecondChanEntry->usSinTsstIndex,
12118
 
                                                                        FALSE );
12119
 
        if ( ulResult != cOCT6100_ERR_OK )
12120
 
                return ulResult;
12121
 
 
12122
 
        /*=======================================================================*/
12123
 
 
12124
 
        return cOCT6100_ERR_OK;
12125
 
}
12126
 
#endif
12127
 
 
12128
 
#if !SKIP_Oct6100ApiOctFloatToDbEnergyByte
12129
 
INT32 Oct6100ApiOctFloatToDbEnergyByte(UINT8 x)
12130
 
{
12131
 
        INT32   lResult;
12132
 
 
12133
 
        lResult = Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)(x << 8) );
12134
 
        return lResult;
12135
 
}
12136
 
#endif
12137
 
 
12138
 
#if !SKIP_Oct6100ApiOctFloatToDbEnergyHalf
12139
 
INT32 Oct6100ApiOctFloatToDbEnergyHalf(UINT16 x)
12140
 
{
12141
 
        INT32 y;
12142
 
        UINT16 m;
12143
 
 
12144
 
        y = (((x >> 8) & 0x7F) - 0x41) * 3;
12145
 
 
12146
 
        m = (UINT16)((x & 0x00E0) >> 5);
12147
 
        if (m < 2) y += 0;
12148
 
        else if (m < 5) y += 1;
12149
 
        else y += 2;
12150
 
 
12151
 
        return y;
12152
 
}
12153
 
#endif
12154
 
 
12155
 
#if !SKIP_Oct6100ApiDbAmpHalfToOctFloat
12156
 
UINT16 Oct6100ApiDbAmpHalfToOctFloat(INT32 x)
12157
 
{
12158
 
        INT32 db_div6;
12159
 
        INT32 db_mod6;
12160
 
        UINT16 rval;
12161
 
        INT32 x_unsigned;
12162
 
 
12163
 
        if(x < 0)
12164
 
        {
12165
 
                x_unsigned = -x;
12166
 
        }
12167
 
        else
12168
 
        {
12169
 
                x_unsigned = x;
12170
 
        }
12171
 
 
12172
 
        db_div6 = x_unsigned / 6;
12173
 
        db_mod6 = x_unsigned % 6;
12174
 
 
12175
 
        if(x < 0)
12176
 
        {
12177
 
                if(db_mod6 == 0)
12178
 
                {
12179
 
                        /* Change nothing! */
12180
 
                        db_div6 = -db_div6;
12181
 
                }
12182
 
                else
12183
 
                {
12184
 
                        /* When we are negative, round down, and then adjust modulo. For example, if
12185
 
                         x is -1, then db_div6 is 0 and db_mod6 is 1. We adjust so db_div6 = -1 and
12186
 
                         db_mod6 = 5, which gives the correct adjustment. */
12187
 
                        db_div6 = -db_div6-1;
12188
 
                        db_mod6 = 6 - db_mod6;
12189
 
                }
12190
 
        }
12191
 
 
12192
 
        rval = (UINT16)(0x4100 + db_div6 * 0x100);
12193
 
 
12194
 
        if(db_mod6 == 0)
12195
 
        {
12196
 
                rval += 0x0000;
12197
 
        }
12198
 
        else if(db_mod6 == 1)
12199
 
        {
12200
 
                rval += 0x0020;
12201
 
        }               
12202
 
        else if(db_mod6 == 2)
12203
 
        {
12204
 
                rval += 0x0040;
12205
 
        }               
12206
 
        else if(db_mod6 == 3)
12207
 
        {
12208
 
                rval += 0x0070;
12209
 
        }               
12210
 
        else if(db_mod6 == 4)
12211
 
        {
12212
 
                rval += 0x0090;
12213
 
        }               
12214
 
        else /* if(db_mod6 == 5) */
12215
 
        {
12216
 
                rval += 0x00D0;
12217
 
        }
12218
 
 
12219
 
        return rval;
12220
 
}
12221
 
#endif
12222
 
 
12223
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12224
 
 
12225
 
Function:               Oct6100ApiWriteDebugChanMemory
12226
 
 
12227
 
Description:    This function configure a debug channel echo memory entry 
12228
 
                                in internal memory.and external memory.
12229
 
 
12230
 
-------------------------------------------------------------------------------
12231
 
|       Argument                |       Description
12232
 
-------------------------------------------------------------------------------
12233
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
12234
 
                                                the present state of the chip and all its resources.
12235
 
 
12236
 
f_pTdmConfig                    Pointer to a TDM configuration structure.
12237
 
f_pVqeConfig                    Pointer to a VQE configuration structure.
12238
 
f_pChannelOpen                  Pointer to a channel configuration structure.
12239
 
f_usChanIndex                   Index of the echo channel in the API instance.
12240
 
f_usEchoMemIndex                Index of the echo channel within the SSPX memory.
12241
 
f_usRinRoutTsiIndex             RIN/ROUT TSI index within the TSI chariot memory.
12242
 
f_usSinSoutTsiIndex             SIN/SOUT TSI index within the TSI chariot memory.
12243
 
 
12244
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12245
 
#if !SKIP_Oct6100ApiWriteDebugChanMemory
12246
 
UINT32 Oct6100ApiWriteDebugChanMemory( 
12247
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
12248
 
                                IN      tPOCT6100_CHANNEL_OPEN_TDM              f_pTdmConfig,
12249
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE              f_pVqeConfig,
12250
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen,
12251
 
                                IN      UINT16                                                  f_usChanIndex,
12252
 
                                IN      UINT16                                                  f_usEchoMemIndex,
12253
 
                                IN      UINT16                                                  f_usRinRoutTsiIndex,
12254
 
                                IN      UINT16                                                  f_usSinSoutTsiIndex )
12255
 
{
12256
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
12257
 
        UINT32                                  ulResult;
12258
 
 
12259
 
        /* Obtain pointer to local portion of the instance. */
12260
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
12261
 
 
12262
 
        /*==============================================================================*/
12263
 
        /* Write the VQE configuration of the debug channel. */
12264
 
 
12265
 
        ulResult = Oct6100ApiWriteVqeMemory( 
12266
 
                                                                                f_pApiInstance, 
12267
 
                                                                                f_pVqeConfig, 
12268
 
                                                                                f_pChannelOpen, 
12269
 
                                                                                f_usChanIndex,
12270
 
                                                                                f_usEchoMemIndex,
12271
 
                                                                                TRUE, 
12272
 
                                                                                FALSE );
12273
 
        if ( ulResult != cOCT6100_ERR_OK )
12274
 
                return ulResult;        
12275
 
 
12276
 
        /*==============================================================================*/
12277
 
 
12278
 
 
12279
 
        /*==============================================================================*/
12280
 
 
12281
 
        /* Write the echo memory configuration of the debug channel. */
12282
 
        ulResult = Oct6100ApiWriteEchoMemory(
12283
 
                                                                                f_pApiInstance,
12284
 
                                                                                f_pTdmConfig,
12285
 
                                                                                f_pChannelOpen,
12286
 
                                                                                f_usEchoMemIndex,
12287
 
                                                                                f_usRinRoutTsiIndex,
12288
 
                                                                                f_usSinSoutTsiIndex );
12289
 
        if ( ulResult != cOCT6100_ERR_OK )
12290
 
                return ulResult;        
12291
 
 
12292
 
        /*==============================================================================*/
12293
 
 
12294
 
        return cOCT6100_ERR_OK;
12295
 
}
12296
 
#endif
12297
 
 
12298
 
 
12299
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12300
 
 
12301
 
Function:               Oct6100ApiDebugChannelOpen
12302
 
 
12303
 
Description:    Internal function used to open a debug channel.
12304
 
 
12305
 
-------------------------------------------------------------------------------
12306
 
|       Argument                |       Description
12307
 
-------------------------------------------------------------------------------
12308
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
12309
 
                                                        the present state of the chip and all its resources.
12310
 
 
12311
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12312
 
#if !SKIP_Oct6100ApiDebugChannelOpen
12313
 
UINT32  Oct6100ApiDebugChannelOpen( 
12314
 
                                        IN      tPOCT6100_INSTANCE_API f_pApiInstance )
12315
 
{
12316
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
12317
 
        tOCT6100_CHANNEL_OPEN           TempChanOpen;
12318
 
        
12319
 
        UINT32  ulResult;
12320
 
        UINT16  usChanIndex;
12321
 
        UINT16  usDummyEchoIndex;
12322
 
 
12323
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
12324
 
 
12325
 
        /* Let's program the channel memory.*/
12326
 
        Oct6100ChannelOpenDef( &TempChanOpen );
12327
 
        
12328
 
        TempChanOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_HT_RESET;      /* Activate the channel in reset.*/
12329
 
        TempChanOpen.VqeConfig.fEnableNlp = FALSE;
12330
 
        TempChanOpen.VqeConfig.ulComfortNoiseMode = cOCT6100_COMFORT_NOISE_NORMAL;
12331
 
        TempChanOpen.VqeConfig.fSinDcOffsetRemoval = FALSE;
12332
 
        TempChanOpen.VqeConfig.fRinDcOffsetRemoval = FALSE;
12333
 
        TempChanOpen.VqeConfig.lDefaultErlDb = 0;
12334
 
        
12335
 
        /* Loop to reserve the proper entry for the debug channel */
12336
 
        for( usChanIndex = 0; usChanIndex < ( pSharedInfo->DebugInfo.usRecordChanIndex + 1 ); usChanIndex ++ )
12337
 
        {
12338
 
                ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, &usDummyEchoIndex );
12339
 
                if( ulResult != cOCT6100_ERR_OK )
12340
 
                        return ulResult;
12341
 
        }
12342
 
 
12343
 
        /* Loop to free all entries except the one for the debug channel */
12344
 
        for( usChanIndex = pSharedInfo->DebugInfo.usRecordChanIndex; usChanIndex > 0; ) 
12345
 
        {
12346
 
                usChanIndex--;
12347
 
                ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, usChanIndex );
12348
 
                if( ulResult != cOCT6100_ERR_OK )
12349
 
                        return ulResult;
12350
 
        }
12351
 
 
12352
 
        ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance,
12353
 
                                                                                  &TempChanOpen.TdmConfig,
12354
 
                                                                                  &TempChanOpen.VqeConfig,
12355
 
                                                                                  &TempChanOpen,
12356
 
                                                                                  pSharedInfo->DebugInfo.usRecordChanIndex,
12357
 
                                                                                  pSharedInfo->DebugInfo.usRecordMemIndex,
12358
 
                                                                                  pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex,
12359
 
                                                                                  pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex );
12360
 
        if ( ulResult != cOCT6100_ERR_OK )
12361
 
                return ulResult;
12362
 
 
12363
 
        return cOCT6100_ERR_OK;
12364
 
}
12365
 
#endif
12366
 
 
12367
 
 
12368
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12369
 
 
12370
 
Function:               Oct6100ApiMuteChannelPort
12371
 
 
12372
 
Description:    This function will verify if a input TSST is bound to the RIN and
12373
 
                                SIN port. If not, the port will be muted.
12374
 
 
12375
 
-------------------------------------------------------------------------------
12376
 
|       Argument                |       Description
12377
 
-------------------------------------------------------------------------------
12378
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
12379
 
                                                        the present state of the chip and all its resources.
12380
 
 
12381
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12382
 
#if !SKIP_Oct6100ApiMutePorts
12383
 
UINT32  Oct6100ApiMutePorts( 
12384
 
                                        IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
12385
 
                                        IN      UINT16                                          f_usEchoIndex,
12386
 
                                        IN      UINT16                                          f_usRinTsstIndex,
12387
 
                                        IN      UINT16                                          f_usSinTsstIndex,
12388
 
                                        IN      BOOL                                            f_fCheckBridgeIndex )
12389
 
{
12390
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
12391
 
        tPOCT6100_API_CHANNEL           pChanEntry;
12392
 
        tOCT6100_WRITE_PARAMS           WriteParams;
12393
 
        UINT32                                          ulResult;
12394
 
 
12395
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
12396
 
 
12397
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
12398
 
 
12399
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12400
 
 
12401
 
        /* Obtain a pointer to the new buffer's list entry. */
12402
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usEchoIndex );
12403
 
 
12404
 
        /* Mute the Rin port. */
12405
 
        if ( ( f_fCheckBridgeIndex == FALSE ) 
12406
 
                || ( ( f_fCheckBridgeIndex == TRUE ) && ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX ) ) )
12407
 
        {
12408
 
                /* If the channel is in bidir mode, do not create the Rin silence event!!! */
12409
 
                if ( pChanEntry->fBiDirChannel == FALSE )
12410
 
                {
12411
 
                        if ( ( ( f_usRinTsstIndex == cOCT6100_INVALID_INDEX ) || ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) ) 
12412
 
                                && ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) ) 
12413
 
                        {
12414
 
                                ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, 
12415
 
                                                                                                                         &pChanEntry->usRinSilenceEventIndex );
12416
 
                                if ( ulResult != cOCT6100_ERR_OK )
12417
 
                                        return ulResult;
12418
 
 
12419
 
                                /* Now, write the mixer event used to copy the RIN signal of the silence channel
12420
 
                                   into the RIN signal of the current channel. */
12421
 
 
12422
 
                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usRinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
12423
 
                                
12424
 
                                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
12425
 
                                WriteParams.usWriteData |= 1534;
12426
 
                                WriteParams.usWriteData |= cOCT6100_PCM_U_LAW << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
12427
 
 
12428
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12429
 
                                if ( ulResult != cOCT6100_ERR_OK )
12430
 
                                        return ulResult;
12431
 
 
12432
 
                                WriteParams.ulWriteAddress += 2;
12433
 
                                WriteParams.usWriteData = pChanEntry->usRinRoutTsiMemIndex;
12434
 
 
12435
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12436
 
                                if ( ulResult != cOCT6100_ERR_OK  )
12437
 
                                        return ulResult;
12438
 
 
12439
 
                                /*=======================================================================*/
12440
 
 
12441
 
 
12442
 
                                /*=======================================================================*/
12443
 
                                /* Now insert the Sin copy event into the list.*/
12444
 
 
12445
 
                                ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
12446
 
                                                                                                        pChanEntry->usRinSilenceEventIndex,
12447
 
                                                                                                        cOCT6100_EVENT_TYPE_SOUT_COPY,
12448
 
                                                                                                        f_usEchoIndex );
12449
 
                                if ( ulResult != cOCT6100_ERR_OK )
12450
 
                                        return ulResult;
12451
 
                        }
12452
 
                }
12453
 
        }
12454
 
 
12455
 
        /* Mute the Sin port. */
12456
 
        if ( ( ( f_usSinTsstIndex == cOCT6100_INVALID_INDEX ) || ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) 
12457
 
                && ( pChanEntry->usSinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
12458
 
        {
12459
 
                ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, 
12460
 
                                                                                                         &pChanEntry->usSinSilenceEventIndex );
12461
 
                if ( ulResult != cOCT6100_ERR_OK )
12462
 
                        return ulResult;
12463
 
 
12464
 
                /* Now, write the mixer event used to copy the SIN signal of the silence channel
12465
 
                   into the SIN signal of the current channel. */
12466
 
 
12467
 
                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
12468
 
                
12469
 
                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
12470
 
                WriteParams.usWriteData |= 1534;
12471
 
                WriteParams.usWriteData |= cOCT6100_PCM_U_LAW << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
12472
 
 
12473
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12474
 
                if ( ulResult != cOCT6100_ERR_OK )
12475
 
                        return ulResult;
12476
 
 
12477
 
                WriteParams.ulWriteAddress += 2;
12478
 
                WriteParams.usWriteData = pChanEntry->usSinSoutTsiMemIndex;
12479
 
 
12480
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12481
 
                if ( ulResult != cOCT6100_ERR_OK  )
12482
 
                        return ulResult;
12483
 
 
12484
 
                /*=======================================================================*/
12485
 
 
12486
 
 
12487
 
                /*=======================================================================*/
12488
 
                /* Now insert the Sin copy event into the list.*/
12489
 
 
12490
 
                ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
12491
 
                                                                                        pChanEntry->usSinSilenceEventIndex,
12492
 
                                                                                        cOCT6100_EVENT_TYPE_SOUT_COPY,
12493
 
                                                                                        f_usEchoIndex );
12494
 
                if ( ulResult != cOCT6100_ERR_OK )
12495
 
                        return ulResult;
12496
 
        }
12497
 
 
12498
 
        /* Unmute the Rin port if it was muted. */
12499
 
        if ( ( ( f_usRinTsstIndex != cOCT6100_INVALID_INDEX ) && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) == 0x0 ) ) 
12500
 
                && ( pChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX ) )
12501
 
        {
12502
 
                /* Remove the event from the list.*/
12503
 
                ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
12504
 
                                                                                                pChanEntry->usRinSilenceEventIndex,
12505
 
                                                                                                cOCT6100_EVENT_TYPE_SOUT_COPY );
12506
 
                if ( ulResult != cOCT6100_ERR_OK )
12507
 
                        return ulResult;
12508
 
 
12509
 
                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usRinSilenceEventIndex );
12510
 
                if ( ulResult != cOCT6100_ERR_OK  )
12511
 
                        return cOCT6100_ERR_FATAL_E1;
12512
 
 
12513
 
                pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
12514
 
        }
12515
 
 
12516
 
        /* Unmute the Sin port if it was muted. */
12517
 
        if ( ( ( f_usSinTsstIndex != cOCT6100_INVALID_INDEX ) && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) == 0x0 ) )
12518
 
                && ( pChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX ) )
12519
 
        {
12520
 
                /* Remove the event from the list.*/
12521
 
                ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
12522
 
                                                                                                pChanEntry->usSinSilenceEventIndex,
12523
 
                                                                                                cOCT6100_EVENT_TYPE_SOUT_COPY );
12524
 
                if ( ulResult != cOCT6100_ERR_OK )
12525
 
                        return ulResult;
12526
 
 
12527
 
                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usSinSilenceEventIndex );
12528
 
                if ( ulResult != cOCT6100_ERR_OK  )
12529
 
                        return cOCT6100_ERR_FATAL_E2;
12530
 
 
12531
 
                pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
12532
 
        }
12533
 
 
12534
 
        return cOCT6100_ERR_OK;
12535
 
}
12536
 
#endif
12537
 
 
12538
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12539
 
 
12540
 
Function:               Oct6100ApiSetChannelLevelControl
12541
 
 
12542
 
Description:    This function will configure the level control on a given
12543
 
                                channel.
12544
 
 
12545
 
-------------------------------------------------------------------------------
12546
 
|       Argument                |       Description
12547
 
-------------------------------------------------------------------------------
12548
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
12549
 
                                                the present state of the chip and all its resources.
12550
 
 
12551
 
f_pVqeConfig                    VQE config of the channel.
12552
 
f_usChanIndex                   Index of the channel within the API instance.
12553
 
f_usEchoMemIndex                Index of the echo channel within the SSPX memory.
12554
 
f_fClearAlcHlcStatusBit If this is set, the ALC-HLC status bit must be
12555
 
                                                incremented.
12556
 
 
12557
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12558
 
#if !SKIP_Oct6100ApiSetChannelLevelControl
12559
 
UINT32 Oct6100ApiSetChannelLevelControl(
12560
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
12561
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE      f_pVqeConfig,
12562
 
                                IN      UINT16                                          f_usChanIndex,
12563
 
                                IN      UINT16                                          f_usEchoMemIndex,
12564
 
                                IN      BOOL                                            f_fClearAlcHlcStatusBit )
12565
 
{
12566
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
12567
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
12568
 
        UINT32                                                  ulResult;
12569
 
        UINT32                                                  ulTempData;
12570
 
        UINT32                                                  ulBaseAddress;
12571
 
        UINT32                                                  ulFeatureBytesOffset;
12572
 
        UINT32                                                  ulFeatureBitOffset;
12573
 
        UINT32                                                  ulFeatureFieldLength;
12574
 
        UINT32                                                  ulMask;
12575
 
        UINT32                                                  i;
12576
 
        UINT16                                                  usTempData;
12577
 
        UINT8                                                   byLastStatus;
12578
 
        BOOL                                                    fDisableAlcFirst;
12579
 
        
12580
 
        /* Get local pointer to shared portion of the API instance. */
12581
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
12582
 
 
12583
 
        /* Obtain a pointer to the channel list entry. */
12584
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
12585
 
 
12586
 
        /* Before doing anything, check if the configuration has changed. */
12587
 
        if ( ( f_fClearAlcHlcStatusBit == TRUE )
12588
 
                || ( f_pVqeConfig->fRinLevelControl != pChanEntry->VqeConfig.fRinLevelControl ) 
12589
 
                || ( f_pVqeConfig->lRinLevelControlGainDb != pChanEntry->VqeConfig.chRinLevelControlGainDb ) 
12590
 
                || ( f_pVqeConfig->fRinAutomaticLevelControl != pChanEntry->VqeConfig.fRinAutomaticLevelControl ) 
12591
 
                || ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb != pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb ) 
12592
 
                || ( f_pVqeConfig->fRinHighLevelCompensation != pChanEntry->VqeConfig.fRinHighLevelCompensation ) 
12593
 
                || ( f_pVqeConfig->lRinHighLevelCompensationThresholdDb != pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb ) 
12594
 
                || ( f_pVqeConfig->fSoutLevelControl != pChanEntry->VqeConfig.fSoutLevelControl ) 
12595
 
                || ( f_pVqeConfig->lSoutLevelControlGainDb != pChanEntry->VqeConfig.chSoutLevelControlGainDb ) 
12596
 
                || ( f_pVqeConfig->fSoutAutomaticLevelControl != pChanEntry->VqeConfig.fSoutAutomaticLevelControl ) 
12597
 
                || ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb != pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb ) 
12598
 
                || ( f_pVqeConfig->fSoutNaturalListenerEnhancement != pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement ) 
12599
 
                || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb )
12600
 
                || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb )
12601
 
                || ( f_pVqeConfig->fResetRinAlcOnTones != pChanEntry->VqeConfig.fResetRinAlcOnTones )
12602
 
                || ( f_pVqeConfig->fResetSoutAlcOnTones != pChanEntry->VqeConfig.fResetSoutAlcOnTones ) 
12603
 
                || ( f_pVqeConfig->ulAlcNoiseBleedOutTime != pChanEntry->VqeConfig.usAlcNoiseBleedOutTime ) )
12604
 
        {
12605
 
                /* Calculate base address for manual level control configuration. */
12606
 
                ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
12607
 
 
12608
 
                /* Set the Level control on RIN port.*/
12609
 
                ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinLevelControlOfst.usDwordOffset * 4;
12610
 
                ulFeatureBitOffset       = pSharedInfo->MemoryMap.RinLevelControlOfst.byBitOffset;
12611
 
                ulFeatureFieldLength = pSharedInfo->MemoryMap.RinLevelControlOfst.byFieldSize;
12612
 
 
12613
 
                /* First read the DWORD where the field is located.*/
12614
 
                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
12615
 
                                                                                        pChanEntry,
12616
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
12617
 
                                                                                        &ulTempData,
12618
 
                                                                                        ulResult );
12619
 
                if ( ulResult != cOCT6100_ERR_OK )
12620
 
                        return ulResult;
12621
 
 
12622
 
                /* Clear previous value set in the feature field.*/
12623
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12624
 
 
12625
 
                ulTempData &= (~ulMask);
12626
 
 
12627
 
                if ( ( f_pVqeConfig->fRinLevelControl == TRUE ) 
12628
 
                        || ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) 
12629
 
                        || ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) )
12630
 
                {
12631
 
                        /* Set the level control value.*/
12632
 
                        if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) 
12633
 
                                || ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) )
12634
 
                                ulTempData |= ( 0xFF << ulFeatureBitOffset );
12635
 
                        else 
12636
 
                        {
12637
 
                                /* Convert the dB value into OctFloat format.*/
12638
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lRinLevelControlGainDb );
12639
 
                                usTempData -= 0x3800;
12640
 
                                usTempData &= 0x0FF0;
12641
 
                                usTempData >>= 4;
12642
 
 
12643
 
                                ulTempData |= ( usTempData << ulFeatureBitOffset ); 
12644
 
                        }
12645
 
                }
12646
 
                else /* ( ( f_pVqeConfig->fRinLevelControl == FALSE ) && ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) && ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) ) */
12647
 
                {
12648
 
                        ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
12649
 
                }
12650
 
 
12651
 
                /* Save the DWORD where the field is located.*/
12652
 
                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
12653
 
                                                                                pChanEntry,
12654
 
                                                                                ulBaseAddress + ulFeatureBytesOffset,
12655
 
                                                                                ulTempData,
12656
 
                                                                                ulResult );
12657
 
                if ( ulResult != cOCT6100_ERR_OK )
12658
 
                        return ulResult;        
12659
 
 
12660
 
                /* Set the Level control on SOUT port.*/
12661
 
                ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutLevelControlOfst.usDwordOffset * 4;
12662
 
                ulFeatureBitOffset       = pSharedInfo->MemoryMap.SoutLevelControlOfst.byBitOffset;
12663
 
                ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutLevelControlOfst.byFieldSize;
12664
 
 
12665
 
                /* First read the DWORD where the field is located.*/
12666
 
                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
12667
 
                                                                                        pChanEntry,
12668
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
12669
 
                                                                                        &ulTempData,
12670
 
                                                                                        ulResult );
12671
 
                if ( ulResult != cOCT6100_ERR_OK )
12672
 
                        return ulResult;
12673
 
 
12674
 
                /* Clear previous value set in the feature field.*/
12675
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12676
 
 
12677
 
                ulTempData &= (~ulMask);
12678
 
 
12679
 
                if ( ( f_pVqeConfig->fSoutLevelControl == TRUE ) 
12680
 
                        || ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
12681
 
                        || ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
12682
 
                        || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0x0 ) )
12683
 
                {
12684
 
                        /* Set the level control value.*/
12685
 
                        if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) 
12686
 
                                || ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE ) 
12687
 
                                || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0x0 ) )
12688
 
                                ulTempData |= ( 0xFF << ulFeatureBitOffset );
12689
 
                        else 
12690
 
                        {
12691
 
                                /* Convert the dB value into OctFloat format.*/
12692
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lSoutLevelControlGainDb );
12693
 
                                usTempData -= 0x3800;
12694
 
                                usTempData &= 0x0FF0;
12695
 
                                usTempData >>= 4;
12696
 
 
12697
 
                                ulTempData |= ( usTempData << ulFeatureBitOffset ); 
12698
 
                        }
12699
 
                }
12700
 
                else
12701
 
                {
12702
 
                        ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
12703
 
                }
12704
 
 
12705
 
                /* Save the DWORD where the field is located.*/
12706
 
                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
12707
 
                                                                                pChanEntry,
12708
 
                                                                                ulBaseAddress + ulFeatureBytesOffset,
12709
 
                                                                                ulTempData,
12710
 
                                                                                ulResult );
12711
 
                if ( ulResult != cOCT6100_ERR_OK )
12712
 
                        return ulResult;        
12713
 
                
12714
 
                /* Calculate base address for auto level control + high level compensation configuration. */
12715
 
                ulBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
12716
 
 
12717
 
                /* Configure the ALC bleed out time. */
12718
 
                if ( pSharedInfo->ImageInfo.fAlcNoiseBleedOutTime == TRUE )
12719
 
                {
12720
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AlcNoiseBleedOutTimeFieldOfst.usDwordOffset * 4;
12721
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AlcNoiseBleedOutTimeFieldOfst.byBitOffset;
12722
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AlcNoiseBleedOutTimeFieldOfst.byFieldSize;
12723
 
 
12724
 
                        /* First read the DWORD where the field is located.*/
12725
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
12726
 
                                                                                                pChanEntry,
12727
 
                                                                                                ulBaseAddress + ulFeatureBytesOffset,
12728
 
                                                                                                &ulTempData,
12729
 
                                                                                                ulResult );
12730
 
                        if ( ulResult != cOCT6100_ERR_OK )
12731
 
                                return ulResult;
12732
 
 
12733
 
                        /* Clear previous value set in the feature field.*/
12734
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12735
 
 
12736
 
                        ulTempData &= (~ulMask);
12737
 
 
12738
 
                        if ( f_pVqeConfig->ulAlcNoiseBleedOutTime != 0 )
12739
 
                        {
12740
 
                                /* Set ALC noise bleed out time. */
12741
 
                                usTempData = (UINT16)( f_pVqeConfig->ulAlcNoiseBleedOutTime / 250 );
12742
 
                                ulTempData |= ( usTempData << ulFeatureBitOffset ); 
12743
 
                        }
12744
 
                        else /* if ( f_pVqeConfig->ulAlcNoiseBleedOutTime == 0 ) */
12745
 
                        {
12746
 
                                /* Disable ALC noise bleed out. */
12747
 
                                ulTempData |= ( 0x0 << ulFeatureBitOffset ); 
12748
 
                        }
12749
 
 
12750
 
                        /* Save the DWORD where the field is located.*/
12751
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
12752
 
                                                                                        pChanEntry,
12753
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
12754
 
                                                                                        ulTempData,
12755
 
                                                                                        ulResult );
12756
 
                        if ( ulResult != cOCT6100_ERR_OK )
12757
 
                                return ulResult;        
12758
 
                }
12759
 
 
12760
 
                /* Check which one is to be disabled first. */
12761
 
                if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
12762
 
                        fDisableAlcFirst = FALSE;
12763
 
                else
12764
 
                        fDisableAlcFirst = TRUE;
12765
 
 
12766
 
                for ( i = 0; i < 2; i ++ )
12767
 
                {
12768
 
                        /* Set the auto level control target Db for the Rin port. */
12769
 
                        if ( ( ( i == 0 ) && ( fDisableAlcFirst == TRUE ) ) || ( ( i == 1 ) && ( fDisableAlcFirst == FALSE ) ) )
12770
 
                        {
12771
 
                                if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE )
12772
 
                                {
12773
 
                                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.usDwordOffset * 4;
12774
 
                                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byBitOffset;
12775
 
                                        ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byFieldSize;
12776
 
 
12777
 
                                        /* First read the DWORD where the field is located.*/
12778
 
                                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
12779
 
                                                                                                                pChanEntry,
12780
 
                                                                                                                ulBaseAddress + ulFeatureBytesOffset,
12781
 
                                                                                                                &ulTempData,
12782
 
                                                                                                                ulResult );
12783
 
                                        if ( ulResult != cOCT6100_ERR_OK )
12784
 
                                                return ulResult;
12785
 
 
12786
 
                                        /* Clear previous value set in the feature field.*/
12787
 
                                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12788
 
 
12789
 
                                        ulTempData &= (~ulMask);
12790
 
 
12791
 
                                        if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
12792
 
                                        {
12793
 
                                                /* Convert the dB value into OctFloat format.*/
12794
 
                                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinAutomaticLevelControlTargetDb );
12795
 
 
12796
 
                                                /* Set auto level control target on the Rin port. */
12797
 
                                                ulTempData |= ( usTempData << ulFeatureBitOffset ); 
12798
 
                                        }
12799
 
                                        else /* if ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) */
12800
 
                                        {
12801
 
                                                /* Disable auto level control. */
12802
 
                                                ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); 
12803
 
                                        }
12804
 
 
12805
 
                                        /* Save the DWORD where the field is located.*/
12806
 
                                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
12807
 
                                                                                                        pChanEntry,
12808
 
                                                                                                        ulBaseAddress + ulFeatureBytesOffset,
12809
 
                                                                                                        ulTempData,
12810
 
                                                                                                        ulResult );
12811
 
                                        if ( ulResult != cOCT6100_ERR_OK )
12812
 
                                                return ulResult;        
12813
 
                                }
12814
 
                        }
12815
 
                        else
12816
 
                        {
12817
 
                                /* Set the high level compensation threshold Db for the Rin port. */
12818
 
                                if ( pSharedInfo->ImageInfo.fRinHighLevelCompensation == TRUE )
12819
 
                                {
12820
 
                                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.usDwordOffset * 4;
12821
 
                                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byBitOffset;
12822
 
                                        ulFeatureFieldLength = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byFieldSize;
12823
 
 
12824
 
                                        /* First read the DWORD where the field is located.*/
12825
 
                                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
12826
 
                                                                                                                pChanEntry,
12827
 
                                                                                                                ulBaseAddress + ulFeatureBytesOffset,
12828
 
                                                                                                                &ulTempData,
12829
 
                                                                                                                ulResult );
12830
 
                                        if ( ulResult != cOCT6100_ERR_OK )
12831
 
                                                return ulResult;
12832
 
 
12833
 
                                        /* Clear previous value set in the feature field.*/
12834
 
                                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12835
 
 
12836
 
                                        ulTempData &= (~ulMask);
12837
 
 
12838
 
                                        if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
12839
 
                                        {
12840
 
                                                /* Convert the dB value into OctFloat format.*/
12841
 
                                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinHighLevelCompensationThresholdDb );
12842
 
 
12843
 
                                                /* Set high level compensation threshold on the Rin port. */
12844
 
                                                ulTempData |= ( usTempData << ulFeatureBitOffset ); 
12845
 
                                        }
12846
 
                                        else /* if ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) */
12847
 
                                        {
12848
 
                                                /* Disable high level compensation. */
12849
 
                                                ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); 
12850
 
                                        }
12851
 
 
12852
 
                                        /* Save the DWORD where the field is located.*/
12853
 
                                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
12854
 
                                                                                                        pChanEntry,
12855
 
                                                                                                        ulBaseAddress + ulFeatureBytesOffset,
12856
 
                                                                                                        ulTempData,
12857
 
                                                                                                        ulResult );
12858
 
                                        if ( ulResult != cOCT6100_ERR_OK )
12859
 
                                                return ulResult;        
12860
 
                                }
12861
 
                        }
12862
 
                }
12863
 
 
12864
 
                /* Set the auto level control target Db for the Sout port. */
12865
 
                if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE )
12866
 
                {
12867
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.usDwordOffset * 4;
12868
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byBitOffset;
12869
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byFieldSize;
12870
 
 
12871
 
                        /* First read the DWORD where the field is located.*/
12872
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
12873
 
                                                                                                pChanEntry,
12874
 
                                                                                                ulBaseAddress + ulFeatureBytesOffset,
12875
 
                                                                                                &ulTempData,
12876
 
                                                                                                ulResult );
12877
 
                        if ( ulResult != cOCT6100_ERR_OK )
12878
 
                                return ulResult;
12879
 
 
12880
 
                        /* Clear previous value set in the feature field.*/
12881
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12882
 
 
12883
 
                        ulTempData &= (~ulMask);
12884
 
 
12885
 
                        if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
12886
 
                        {
12887
 
                                /* Convert the dB value into OctFloat format.*/
12888
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lSoutAutomaticLevelControlTargetDb );
12889
 
 
12890
 
                                /* Set auto level control target on the Sout port. */
12891
 
                                ulTempData |= ( usTempData << ulFeatureBitOffset ); 
12892
 
                        }
12893
 
                        else /* if ( f_pVqeConfig->fSoutAutomaticLevelControl == FALSE ) */
12894
 
                        {
12895
 
                                /* Disable auto level control. */
12896
 
                                ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); 
12897
 
                        }
12898
 
 
12899
 
                        /* Save the DWORD where the field is located.*/
12900
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
12901
 
                                                                                        pChanEntry,
12902
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
12903
 
                                                                                        ulTempData,
12904
 
                                                                                        ulResult );
12905
 
                        if ( ulResult != cOCT6100_ERR_OK )
12906
 
                                return ulResult;        
12907
 
                }
12908
 
 
12909
 
                /* Set the reset Rin ALC on tones. */
12910
 
                if ( pSharedInfo->ImageInfo.fResetRinAlcOnTones == TRUE )
12911
 
                {
12912
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ResetRinAlcOnTonesFieldOfst.usDwordOffset * 4;
12913
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ResetRinAlcOnTonesFieldOfst.byBitOffset;
12914
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ResetRinAlcOnTonesFieldOfst.byFieldSize;
12915
 
 
12916
 
                        /* First read the DWORD where the field is located.*/
12917
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
12918
 
                                                                                                pChanEntry,
12919
 
                                                                                                ulBaseAddress + ulFeatureBytesOffset,
12920
 
                                                                                                &ulTempData,
12921
 
                                                                                                ulResult );
12922
 
                        if ( ulResult != cOCT6100_ERR_OK )
12923
 
                                return ulResult;
12924
 
 
12925
 
                        /* Clear previous value set in the feature field.*/
12926
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12927
 
 
12928
 
                        ulTempData &= (~ulMask);
12929
 
 
12930
 
                        if ( f_pVqeConfig->fResetRinAlcOnTones == TRUE )
12931
 
                        {
12932
 
                                ulTempData |= ( 1 << ulFeatureBitOffset );
12933
 
                        }
12934
 
                        else /* if ( f_pVqeConfig->fResetRinAlcOnTones == FALSE ) */
12935
 
                        {
12936
 
                                /* Disable ALC reset on tone detection. */
12937
 
                                ulTempData |= ( 0 << ulFeatureBitOffset ); 
12938
 
                        }
12939
 
 
12940
 
                        /* Save the DWORD where the field is located.*/
12941
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
12942
 
                                                                                        pChanEntry,
12943
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
12944
 
                                                                                        ulTempData,
12945
 
                                                                                        ulResult );
12946
 
                        if ( ulResult != cOCT6100_ERR_OK )
12947
 
                                return ulResult;        
12948
 
                }
12949
 
 
12950
 
                /* Set the reset Sout ALC on tones. */
12951
 
                if ( pSharedInfo->ImageInfo.fResetSoutAlcOnTones == TRUE )
12952
 
                {
12953
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ResetSoutAlcOnTonesFieldOfst.usDwordOffset * 4;
12954
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ResetSoutAlcOnTonesFieldOfst.byBitOffset;
12955
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ResetSoutAlcOnTonesFieldOfst.byFieldSize;
12956
 
 
12957
 
                        /* First read the DWORD where the field is located.*/
12958
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
12959
 
                                                                                                pChanEntry,
12960
 
                                                                                                ulBaseAddress + ulFeatureBytesOffset,
12961
 
                                                                                                &ulTempData,
12962
 
                                                                                                ulResult );
12963
 
                        if ( ulResult != cOCT6100_ERR_OK )
12964
 
                                return ulResult;
12965
 
 
12966
 
                        /* Clear previous value set in the feature field.*/
12967
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12968
 
 
12969
 
                        ulTempData &= (~ulMask);
12970
 
 
12971
 
                        if ( f_pVqeConfig->fResetSoutAlcOnTones == TRUE )
12972
 
                        {
12973
 
                                ulTempData |= ( 1 << ulFeatureBitOffset );
12974
 
                        }
12975
 
                        else /* if ( f_pVqeConfig->fResetSoutAlcOnTones == FALSE ) */
12976
 
                        {
12977
 
                                /* Disable ALC reset on tone detection. */
12978
 
                                ulTempData |= ( 0 << ulFeatureBitOffset ); 
12979
 
                        }
12980
 
 
12981
 
                        /* Save the DWORD where the field is located.*/
12982
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
12983
 
                                                                                        pChanEntry,
12984
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
12985
 
                                                                                        ulTempData,
12986
 
                                                                                        ulResult );
12987
 
                        if ( ulResult != cOCT6100_ERR_OK )
12988
 
                                return ulResult;        
12989
 
                }
12990
 
 
12991
 
                /* Set the high level compensation threshold Db for the Sout port. */
12992
 
                if ( pSharedInfo->ImageInfo.fSoutHighLevelCompensation == TRUE )
12993
 
                {
12994
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.usDwordOffset * 4;
12995
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byBitOffset;
12996
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byFieldSize;
12997
 
 
12998
 
                        /* First read the DWORD where the field is located.*/
12999
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
13000
 
                                                                                                pChanEntry,
13001
 
                                                                                                ulBaseAddress + ulFeatureBytesOffset,
13002
 
                                                                                                &ulTempData,
13003
 
                                                                                                ulResult );
13004
 
                        if ( ulResult != cOCT6100_ERR_OK )
13005
 
                                return ulResult;
13006
 
 
13007
 
                        /* Clear previous value set in the feature field.*/
13008
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13009
 
 
13010
 
                        ulTempData &= (~ulMask);
13011
 
 
13012
 
                        /* Disable high level compensation on Sout for now. */
13013
 
                        ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); 
13014
 
 
13015
 
                        /* Save the DWORD where the field is located.*/
13016
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
13017
 
                                                                                        pChanEntry,
13018
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
13019
 
                                                                                        ulTempData,
13020
 
                                                                                        ulResult );
13021
 
                        if ( ulResult != cOCT6100_ERR_OK )
13022
 
                                return ulResult;        
13023
 
                }
13024
 
 
13025
 
                /* Check if have to clear the ALC-HLC status. */
13026
 
                if ( ( pSharedInfo->ImageInfo.fAlcHlcStatus == TRUE ) 
13027
 
                        && ( ( f_fClearAlcHlcStatusBit == TRUE )
13028
 
 
13029
 
                                ) )
13030
 
                {
13031
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.usDwordOffset * 4;
13032
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byBitOffset;
13033
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byFieldSize;
13034
 
 
13035
 
                        /* First read the DWORD where the field is located.*/
13036
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
13037
 
                                                                                                pChanEntry,
13038
 
                                                                                                ulBaseAddress + ulFeatureBytesOffset,
13039
 
                                                                                                &ulTempData,
13040
 
                                                                                                ulResult );
13041
 
                        if ( ulResult != cOCT6100_ERR_OK )
13042
 
                                return ulResult;
13043
 
 
13044
 
                        /* Get previous value set in the feature field.*/
13045
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13046
 
 
13047
 
                        /* Retrieve last status. */
13048
 
                        byLastStatus = (UINT8)( ( ( ulTempData & ulMask ) >> ulFeatureBitOffset ) & 0xFF );
13049
 
 
13050
 
                        /* Increment to reset context. */
13051
 
                        byLastStatus ++;
13052
 
 
13053
 
                        /* Just in case, not to overwrite some context in external memory. */
13054
 
                        byLastStatus &= ( 0x1 << ulFeatureFieldLength ) - 1;
13055
 
 
13056
 
                        /* Clear last status. */
13057
 
                        ulTempData &= (~ulMask);
13058
 
 
13059
 
                        /* Set new status. */
13060
 
                        ulTempData |= ( byLastStatus << ulFeatureBitOffset ); 
13061
 
 
13062
 
                        /* Save the DWORD where the field is located.*/
13063
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
13064
 
                                                                                        pChanEntry,
13065
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
13066
 
                                                                                        ulTempData,
13067
 
                                                                                        ulResult );
13068
 
                        if ( ulResult != cOCT6100_ERR_OK )
13069
 
                                return ulResult;                        
13070
 
                }
13071
 
        }
13072
 
 
13073
 
        return cOCT6100_ERR_OK;
13074
 
}
13075
 
#endif
13076
 
 
13077
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13078
 
 
13079
 
Function:               Oct6100ApiSetChannelTailConfiguration
13080
 
 
13081
 
Description:    This function will configure the tail displacement and length
13082
 
                                on a given channel.
13083
 
 
13084
 
-------------------------------------------------------------------------------
13085
 
|       Argument                |       Description
13086
 
-------------------------------------------------------------------------------
13087
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
13088
 
                                                the present state of the chip and all its resources.
13089
 
 
13090
 
f_pVqeConfig                    VQE config of the channel.
13091
 
f_usChanIndex                   Index of the channel within the API instance.
13092
 
f_usEchoMemIndex                Index of the echo channel within the SSPX memory.
13093
 
f_fModifyOnly                   Function called from a modify or open?  
13094
 
 
13095
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13096
 
#if !SKIP_Oct6100ApiSetChannelTailConfiguration
13097
 
UINT32 Oct6100ApiSetChannelTailConfiguration(
13098
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
13099
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE      f_pVqeConfig,
13100
 
                                IN      UINT16                                          f_usChanIndex,
13101
 
                                IN      UINT16                                          f_usEchoMemIndex,
13102
 
                                IN      BOOL                                            f_fModifyOnly )
13103
 
{
13104
 
        tPOCT6100_API_CHANNEL   pChanEntry;
13105
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
13106
 
        UINT32                                  ulResult;
13107
 
        UINT32                                  ulTempData;
13108
 
        UINT32                                  ulNlpConfBaseAddress;
13109
 
        UINT32                                  ulAfConfBaseAddress;
13110
 
        UINT32                                  ulFeatureBytesOffset;
13111
 
        UINT32                                  ulFeatureBitOffset;
13112
 
        UINT32                                  ulFeatureFieldLength;
13113
 
        UINT32                                  ulMask;
13114
 
        UINT32                                  ulTailSum;
13115
 
        BOOL                                    fTailDisplacementModified = FALSE;
13116
 
        
13117
 
        /* Get local pointer to shared portion of the API instance. */
13118
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
13119
 
 
13120
 
        /* Obtain a pointer to the channel list entry. */
13121
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
13122
 
 
13123
 
        /* Calculate base addresses of NLP + AF configuration structure for the specified channel. */
13124
 
        ulNlpConfBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
13125
 
        ulAfConfBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
13126
 
 
13127
 
        /* Set the tail displacement.*/
13128
 
        if ( pSharedInfo->ImageInfo.fTailDisplacement == TRUE )
13129
 
        {
13130
 
                /* Check if the configuration has been changed. */
13131
 
                if ( ( f_fModifyOnly == FALSE )
13132
 
                        || ( ( f_fModifyOnly == TRUE ) 
13133
 
                                && ( ( f_pVqeConfig->fEnableTailDisplacement != pChanEntry->VqeConfig.fEnableTailDisplacement ) 
13134
 
                                        || ( f_pVqeConfig->ulTailDisplacement != pChanEntry->VqeConfig.usTailDisplacement ) 
13135
 
                                        || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
13136
 
                {
13137
 
                        /* Remember that the tail displacement parameters were changed. */
13138
 
                        fTailDisplacementModified = TRUE;
13139
 
 
13140
 
                        /* Check if we must set the tail displacement value. */
13141
 
                        if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE ) 
13142
 
                                && ( pSharedInfo->ImageInfo.fPerChannelTailDisplacement == TRUE ) )
13143
 
                        {
13144
 
                                ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.usDwordOffset * 4;
13145
 
                                ulFeatureBitOffset       = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byBitOffset;
13146
 
                                ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byFieldSize;
13147
 
 
13148
 
                                /* First read the DWORD where the field is located.*/
13149
 
                                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
13150
 
                                                                                                        pChanEntry,
13151
 
                                                                                                        ulNlpConfBaseAddress + ulFeatureBytesOffset,
13152
 
                                                                                                        &ulTempData,
13153
 
                                                                                                        ulResult );
13154
 
                                if ( ulResult != cOCT6100_ERR_OK )
13155
 
                                        return ulResult;
13156
 
 
13157
 
                                /* Clear previous value set in the feature field.*/
13158
 
                                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13159
 
 
13160
 
                                ulTempData &= (~ulMask);
13161
 
                                if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE ) 
13162
 
                                        && ( f_pVqeConfig->ulTailDisplacement != 0x0 ) )
13163
 
                                {
13164
 
                                        if ( pSharedInfo->ImageInfo.fAfTailDisplacement == FALSE )
13165
 
                                        {
13166
 
                                                if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13167
 
                                                {
13168
 
                                                        ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13169
 
                                                }
13170
 
                                                else
13171
 
                                                {
13172
 
                                                        ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13173
 
                                                }
13174
 
                                        }
13175
 
                                        else /* if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE ) */
13176
 
                                        {
13177
 
                                                /* If AEC is not activated, this must be set to the requested tail displacement. */
13178
 
                                                if ( f_pVqeConfig->fAcousticEcho == FALSE )
13179
 
                                                {
13180
 
                                                        if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13181
 
                                                        {
13182
 
                                                                ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement;
13183
 
                                                        }
13184
 
                                                        else
13185
 
                                                        {
13186
 
                                                                ulTailSum = f_pVqeConfig->ulTailDisplacement;
13187
 
                                                        }
13188
 
                                                        
13189
 
                                                        if ( ulTailSum == 0 )
13190
 
                                                        {
13191
 
                                                                ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13192
 
                                                        }
13193
 
                                                        else if ( ulTailSum <= 128 )
13194
 
                                                        {
13195
 
                                                                ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
13196
 
                                                        }
13197
 
                                                        else if ( ulTailSum <= 384 )
13198
 
                                                        {
13199
 
                                                                ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
13200
 
                                                        }
13201
 
                                                        else /* if ( ulTailSum <= 896 ) */
13202
 
                                                        {
13203
 
                                                                ulTempData |= ( ( 7 ) << ulFeatureBitOffset );
13204
 
                                                        }
13205
 
                                                }
13206
 
                                                else /* if ( f_pVqeConfig->fAcousticEcho == FALSE ) */
13207
 
                                                {
13208
 
                                                        /* Otherwise, the tail displacement is configured differently.  This field stays to 0. */
13209
 
                                                        ulTempData |= ( 0x0 << ulFeatureBitOffset );
13210
 
                                                }
13211
 
                                        }
13212
 
                                }
13213
 
 
13214
 
                                /* Then save the new DWORD where the field is located.*/
13215
 
                                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
13216
 
                                                                                                pChanEntry,
13217
 
                                                                                                ulNlpConfBaseAddress + ulFeatureBytesOffset,
13218
 
                                                                                                ulTempData,
13219
 
                                                                                                ulResult );
13220
 
                                if ( ulResult != cOCT6100_ERR_OK )
13221
 
                                        return ulResult;        
13222
 
                        }
13223
 
 
13224
 
                        if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE )
13225
 
                        {
13226
 
                                /* Set the tail displacement offset in the AF. */
13227
 
                                ulFeatureBytesOffset = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.usDwordOffset * 4;
13228
 
                                ulFeatureBitOffset       = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.byBitOffset;
13229
 
                                ulFeatureFieldLength = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.byFieldSize;
13230
 
 
13231
 
                                /* First read the DWORD where the field is located.*/
13232
 
                                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
13233
 
                                                                                                        pChanEntry,
13234
 
                                                                                                        ulAfConfBaseAddress + ulFeatureBytesOffset,
13235
 
                                                                                                        &ulTempData,
13236
 
                                                                                                        ulResult );
13237
 
                                if ( ulResult != cOCT6100_ERR_OK )
13238
 
                                        return ulResult;
13239
 
 
13240
 
                                /* Clear previous value set in the feature field.*/
13241
 
                                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13242
 
 
13243
 
                                ulTempData &= (~ulMask);
13244
 
 
13245
 
                                if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13246
 
                                {
13247
 
                                        ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13248
 
                                }
13249
 
                                else
13250
 
                                {
13251
 
                                        ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13252
 
                                }
13253
 
 
13254
 
                                /* Then save the DWORD where the field is located.*/
13255
 
                                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
13256
 
                                                                                                pChanEntry,
13257
 
                                                                                                ulAfConfBaseAddress + ulFeatureBytesOffset,
13258
 
                                                                                                ulTempData,
13259
 
                                                                                                ulResult );
13260
 
                                if ( ulResult != cOCT6100_ERR_OK )
13261
 
                                        return ulResult;
13262
 
                        }
13263
 
 
13264
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.TailDisplEnableOfst.usDwordOffset * 4;
13265
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.TailDisplEnableOfst.byBitOffset;
13266
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.TailDisplEnableOfst.byFieldSize;
13267
 
 
13268
 
                        /* First read the DWORD where the field is located.*/
13269
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
13270
 
                                                                                                pChanEntry,
13271
 
                                                                                                ulNlpConfBaseAddress + ulFeatureBytesOffset,
13272
 
                                                                                                &ulTempData,
13273
 
                                                                                                ulResult );
13274
 
                        if ( ulResult != cOCT6100_ERR_OK )
13275
 
                                return ulResult;
13276
 
 
13277
 
                        /* Clear previous value set in the feature field.*/
13278
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13279
 
 
13280
 
                        ulTempData &= (~ulMask);
13281
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fEnableTailDisplacement ) << ulFeatureBitOffset );
13282
 
 
13283
 
                        /* Then save the DWORD where the field is located.*/
13284
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
13285
 
                                                                                        pChanEntry,
13286
 
                                                                                        ulNlpConfBaseAddress + ulFeatureBytesOffset,
13287
 
                                                                                        ulTempData,
13288
 
                                                                                        ulResult );
13289
 
                        if ( ulResult != cOCT6100_ERR_OK )
13290
 
                                return ulResult;        
13291
 
                }
13292
 
        }
13293
 
 
13294
 
        /* Set the tail length. */
13295
 
        if ( pSharedInfo->ImageInfo.fPerChannelTailLength == TRUE )
13296
 
        {
13297
 
                /* Check if the configuration has been changed. */
13298
 
                if ( ( f_fModifyOnly == FALSE )
13299
 
                        || ( ( f_fModifyOnly == TRUE ) 
13300
 
                                && ( f_pVqeConfig->ulTailLength != pChanEntry->VqeConfig.usTailLength ) ) )
13301
 
                {
13302
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.usDwordOffset * 4;
13303
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byBitOffset;
13304
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byFieldSize;
13305
 
 
13306
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
13307
 
                                                                                                pChanEntry,
13308
 
                                                                                                ulAfConfBaseAddress + ulFeatureBytesOffset,
13309
 
                                                                                                &ulTempData, 
13310
 
                                                                                                ulResult );
13311
 
                        if ( ulResult != cOCT6100_ERR_OK )
13312
 
                                return ulResult;
13313
 
 
13314
 
                        /* Clear previous value set in the feature field.*/
13315
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13316
 
 
13317
 
                        ulTempData &= (~ulMask);
13318
 
                        /* Check if must automatically select maximum or if must use user specific value. */
13319
 
                        if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
13320
 
                        {
13321
 
                                ulTempData |= ( ( ( pSharedInfo->ImageInfo.usMaxTailLength - 32 ) / 4 )  << ulFeatureBitOffset );
13322
 
                        }
13323
 
                        else
13324
 
                        {
13325
 
                                ulTempData |= ( ( ( f_pVqeConfig->ulTailLength - 32 ) / 4 )  << ulFeatureBitOffset );
13326
 
                        }
13327
 
 
13328
 
                        /* Then save the DWORD where the field is located.*/
13329
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
13330
 
                                                                                        pChanEntry,
13331
 
                                                                                        ulAfConfBaseAddress + ulFeatureBytesOffset,
13332
 
                                                                                        ulTempData,
13333
 
                                                                                        ulResult );
13334
 
                        if ( ulResult != cOCT6100_ERR_OK )
13335
 
                                return ulResult;        
13336
 
                }
13337
 
        }
13338
 
 
13339
 
        /* Configure AEC tail length. */
13340
 
        if ( pSharedInfo->ImageInfo.fAecTailLength == TRUE )
13341
 
        {
13342
 
                /* Check if the configuration has been changed. */
13343
 
                if ( ( f_fModifyOnly == FALSE )
13344
 
                        || ( fTailDisplacementModified == TRUE )
13345
 
                        || ( ( f_fModifyOnly == TRUE ) 
13346
 
                                && ( ( f_pVqeConfig->ulAecTailLength != pChanEntry->VqeConfig.usAecTailLength ) 
13347
 
                                || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
13348
 
                {
13349
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.usDwordOffset * 4;
13350
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byBitOffset;
13351
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byFieldSize;
13352
 
 
13353
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
13354
 
                                                                                                pChanEntry,
13355
 
                                                                                                ulNlpConfBaseAddress + ulFeatureBytesOffset,
13356
 
                                                                                                &ulTempData,
13357
 
                                                                                                ulResult );
13358
 
                        if ( ulResult != cOCT6100_ERR_OK )
13359
 
                                return ulResult;
13360
 
                        
13361
 
                        /* Clear previous value set in the feature field.*/
13362
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13363
 
 
13364
 
                        ulTempData &= (~ulMask);
13365
 
 
13366
 
                        /* Set acoustic echo tail length. */
13367
 
                        if ( f_pVqeConfig->fAcousticEcho == TRUE )
13368
 
                        {
13369
 
                                switch( f_pVqeConfig->ulAecTailLength )
13370
 
                                {
13371
 
                                case 1024:
13372
 
                                        ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
13373
 
                                        break;
13374
 
                                case 512:
13375
 
                                        ulTempData |= ( ( 2 ) << ulFeatureBitOffset );
13376
 
                                        break;
13377
 
                                case 256:
13378
 
                                        ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
13379
 
                                        break;
13380
 
                                case 128:
13381
 
                                default:
13382
 
                                        ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13383
 
                                        break;
13384
 
                                }
13385
 
                        }
13386
 
                        else if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
13387
 
                        {
13388
 
                                /* No acoustic echo case. */
13389
 
 
13390
 
                                /* Start with requested tail displacement. */
13391
 
                                if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13392
 
                                {
13393
 
                                        ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement;
13394
 
                                }
13395
 
                                else
13396
 
                                {
13397
 
                                        ulTailSum = f_pVqeConfig->ulTailDisplacement;
13398
 
                                }
13399
 
 
13400
 
                                /* Add requested tail length. */
13401
 
                                if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
13402
 
                                {
13403
 
                                        ulTailSum += pSharedInfo->ImageInfo.usMaxTailLength;
13404
 
                                }
13405
 
                                else
13406
 
                                {
13407
 
                                        ulTailSum += f_pVqeConfig->ulTailLength;
13408
 
                                }
13409
 
 
13410
 
                                /* Round this value up. */
13411
 
                                if ( ulTailSum <= 128 )
13412
 
                                {
13413
 
                                        ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13414
 
                                }
13415
 
                                else if ( ulTailSum <= 256 )
13416
 
                                {
13417
 
                                        ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
13418
 
                                }
13419
 
                                else if ( ulTailSum <= 512 )
13420
 
                                {
13421
 
                                        ulTempData |= ( ( 2 ) << ulFeatureBitOffset );
13422
 
                                }
13423
 
                                else /* if ( ulTailSum <= 1024 ) */
13424
 
                                {
13425
 
                                        ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
13426
 
                                }
13427
 
                        }
13428
 
                        else
13429
 
                        {
13430
 
                                /* Keep this to zero. */
13431
 
                                ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13432
 
                        }
13433
 
                        
13434
 
                        /* Write the new DWORD where the field is located. */
13435
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
13436
 
                                                                                        pChanEntry,
13437
 
                                                                                        ulNlpConfBaseAddress + ulFeatureBytesOffset,
13438
 
                                                                                        ulTempData,
13439
 
                                                                                        ulResult );
13440
 
                        if ( ulResult != cOCT6100_ERR_OK )
13441
 
                                return ulResult;        
13442
 
                }
13443
 
        }
13444
 
 
13445
 
        return cOCT6100_ERR_OK;
13446
 
}
13447
 
#endif
13448
 
 
13449
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13450
 
 
13451
 
Function:               Oct6100ChannelMuteSer
13452
 
 
13453
 
Description:    This function will mute some of the ports on a given
13454
 
                                channel.
13455
 
 
13456
 
-------------------------------------------------------------------------------
13457
 
|       Argument                |       Description
13458
 
-------------------------------------------------------------------------------
13459
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
13460
 
                                                the present state of the chip and all its resources.
13461
 
 
13462
 
f_pChannelMute                  What channel/ports to mute.
13463
 
 
13464
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13465
 
#if !SKIP_Oct6100ChannelMuteSer
13466
 
UINT32 Oct6100ChannelMuteSer(
13467
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
13468
 
                                IN      tPOCT6100_CHANNEL_MUTE          f_pChannelMute )
13469
 
{
13470
 
        UINT32  ulResult;
13471
 
        UINT16  usChanIndex;
13472
 
        UINT16  usPortMask;
13473
 
 
13474
 
        /* Verify that all the parameters given match the state of the API. */
13475
 
        ulResult = Oct6100ApiAssertChannelMuteParams(   f_pApiInstance, 
13476
 
                                                                                                        f_pChannelMute, 
13477
 
                                                                                                        &usChanIndex,
13478
 
                                                                                                        &usPortMask );
13479
 
        if ( ulResult != cOCT6100_ERR_OK )
13480
 
                return ulResult;
13481
 
 
13482
 
        /* Call the actual channel mute ports function. */
13483
 
        ulResult = Oct6100ApiMuteChannelPorts(  f_pApiInstance, 
13484
 
                                                                                        usChanIndex,
13485
 
                                                                                        usPortMask,
13486
 
                                                                                        TRUE );
13487
 
        if ( ulResult != cOCT6100_ERR_OK )
13488
 
                return ulResult;
13489
 
 
13490
 
        return cOCT6100_ERR_OK;
13491
 
}
13492
 
#endif
13493
 
 
13494
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13495
 
 
13496
 
Function:               Oct6100ApiAssertChannelMuteParams
13497
 
 
13498
 
Description:    Check the user parameters passed to the channel mute function.
13499
 
 
13500
 
-------------------------------------------------------------------------------
13501
 
|       Argument                |       Description
13502
 
-------------------------------------------------------------------------------
13503
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
13504
 
                                                the present state of the chip and all its resources.
13505
 
 
13506
 
f_pChannelMute                  What channel/ports to mute.
13507
 
f_pusChanIndex                  Resulting channel index where the muting should
13508
 
                                                be applied.
13509
 
f_pusPorts                              Port mask on which to apply the muting.
13510
 
 
13511
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13512
 
#if !SKIP_Oct6100ApiAssertChannelMuteParams
13513
 
UINT32 Oct6100ApiAssertChannelMuteParams(       
13514
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance, 
13515
 
                                IN      tPOCT6100_CHANNEL_MUTE          f_pChannelMute, 
13516
 
                                OUT PUINT16                                             f_pusChanIndex,
13517
 
                                OUT PUINT16                                             f_pusPorts )
13518
 
{
13519
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
13520
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
13521
 
        UINT32                                                  ulEntryOpenCnt;
13522
 
 
13523
 
        /* Get local pointer(s). */
13524
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
13525
 
 
13526
 
        /* Check the provided handle. */
13527
 
        if ( (f_pChannelMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
13528
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13529
 
 
13530
 
        *f_pusChanIndex = (UINT16)( f_pChannelMute->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
13531
 
        if ( *f_pusChanIndex  >= pSharedInfo->ChipConfig.usMaxChannels )
13532
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13533
 
 
13534
 
        /*=======================================================================*/
13535
 
        /* Get a pointer to the channel's list entry. */
13536
 
 
13537
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex  )
13538
 
 
13539
 
        /* Extract the entry open count from the provided handle. */
13540
 
        ulEntryOpenCnt = ( f_pChannelMute->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
13541
 
 
13542
 
        /* Check for errors. */
13543
 
        if ( pChanEntry->fReserved != TRUE )
13544
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
13545
 
        if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
13546
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13547
 
        if ( pChanEntry->fBiDirChannel == TRUE )
13548
 
                return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL;
13549
 
 
13550
 
        /*=======================================================================*/
13551
 
 
13552
 
        /* Check the provided port mask. */
13553
 
 
13554
 
        if ( ( f_pChannelMute->ulPortMask &
13555
 
                ~(      cOCT6100_CHANNEL_MUTE_PORT_NONE | 
13556
 
                        cOCT6100_CHANNEL_MUTE_PORT_RIN |
13557
 
                        cOCT6100_CHANNEL_MUTE_PORT_ROUT |
13558
 
                        cOCT6100_CHANNEL_MUTE_PORT_SIN | 
13559
 
                        cOCT6100_CHANNEL_MUTE_PORT_SOUT |
13560
 
                        cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) ) != 0 )
13561
 
                return cOCT6100_ERR_CHANNEL_MUTE_MASK;
13562
 
 
13563
 
        /* Sin + Sin with features cannot be muted simultaneously. */
13564
 
        if ( ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
13565
 
                && ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) )
13566
 
                return cOCT6100_ERR_CHANNEL_MUTE_MASK_SIN;
13567
 
 
13568
 
        /* Check if Sin mute with features is supported by the firmware. */
13569
 
        if ( ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
13570
 
                && ( pSharedInfo->ImageInfo.fSinMute == FALSE ) )
13571
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_MUTE_FEATURES;
13572
 
 
13573
 
        /* Return the ports to the calling function. */
13574
 
        *f_pusPorts = (UINT16)( f_pChannelMute->ulPortMask & 0xFFFF );
13575
 
 
13576
 
        return cOCT6100_ERR_OK;
13577
 
}
13578
 
#endif
13579
 
 
13580
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13581
 
 
13582
 
Function:               Oct6100ChannelUnMuteSer
13583
 
 
13584
 
Description:    This function will unmute some of the ports on a given
13585
 
                                channel.
13586
 
 
13587
 
-------------------------------------------------------------------------------
13588
 
|       Argument                |       Description
13589
 
-------------------------------------------------------------------------------
13590
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
13591
 
                                                the present state of the chip and all its resources.
13592
 
 
13593
 
f_pChannelUnMute                What channel/ports to unmute.
13594
 
 
13595
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13596
 
#if !SKIP_Oct6100ChannelUnMuteSer
13597
 
UINT32 Oct6100ChannelUnMuteSer(
13598
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
13599
 
                                IN      tPOCT6100_CHANNEL_UNMUTE        f_pChannelUnMute )
13600
 
{
13601
 
        UINT32  ulResult;
13602
 
        UINT16  usChanIndex;
13603
 
        UINT16  usPortMask;
13604
 
 
13605
 
        /* Verify that all the parameters given match the state of the API. */
13606
 
        ulResult = Oct6100ApiAssertChannelUnMuteParams( f_pApiInstance, 
13607
 
                                                                                                        f_pChannelUnMute, 
13608
 
                                                                                                        &usChanIndex,
13609
 
                                                                                                        &usPortMask );
13610
 
        if ( ulResult != cOCT6100_ERR_OK )
13611
 
                return ulResult;
13612
 
 
13613
 
        /* Call the actual channel mute ports function. */
13614
 
        ulResult = Oct6100ApiMuteChannelPorts(  f_pApiInstance, 
13615
 
                                                                                        usChanIndex,
13616
 
                                                                                        usPortMask,
13617
 
                                                                                        FALSE );
13618
 
        if ( ulResult != cOCT6100_ERR_OK )
13619
 
                return ulResult;
13620
 
 
13621
 
        return cOCT6100_ERR_OK;
13622
 
}
13623
 
#endif
13624
 
 
13625
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13626
 
 
13627
 
Function:               Oct6100ApiAssertChannelUnMuteParams
13628
 
 
13629
 
Description:    Check the user parameters passed to the channel unmute function.
13630
 
 
13631
 
-------------------------------------------------------------------------------
13632
 
|       Argument                |       Description
13633
 
-------------------------------------------------------------------------------
13634
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
13635
 
                                                the present state of the chip and all its resources.
13636
 
 
13637
 
f_pChannelUnMute                What channel/ports to Unmute.
13638
 
f_pusChanIndex                  Resulting channel index where the muting should
13639
 
                                                be applied.
13640
 
f_pusPorts                              Port mask on which to apply the muting.
13641
 
 
13642
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13643
 
#if !SKIP_Oct6100ApiAssertChannelUnMuteParams
13644
 
UINT32 Oct6100ApiAssertChannelUnMuteParams(     
13645
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance, 
13646
 
                                IN      tPOCT6100_CHANNEL_UNMUTE        f_pChannelUnMute, 
13647
 
                                OUT PUINT16                                             f_pusChanIndex,
13648
 
                                OUT PUINT16                                             f_pusPorts )
13649
 
{
13650
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
13651
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
13652
 
        UINT32                                                  ulEntryOpenCnt;
13653
 
 
13654
 
        /* Get local pointer(s). */
13655
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
13656
 
 
13657
 
        /* Check the provided handle. */
13658
 
        if ( (f_pChannelUnMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
13659
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13660
 
 
13661
 
        *f_pusChanIndex = (UINT16)( f_pChannelUnMute->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
13662
 
        if ( *f_pusChanIndex  >= pSharedInfo->ChipConfig.usMaxChannels )
13663
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13664
 
 
13665
 
        /*=======================================================================*/
13666
 
        /* Get a pointer to the channel's list entry. */
13667
 
 
13668
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex  )
13669
 
 
13670
 
        /* Extract the entry open count from the provided handle. */
13671
 
        ulEntryOpenCnt = ( f_pChannelUnMute->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
13672
 
 
13673
 
        /* Check for errors. */
13674
 
        if ( pChanEntry->fReserved != TRUE )
13675
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
13676
 
        if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
13677
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13678
 
        if ( pChanEntry->fBiDirChannel == TRUE )
13679
 
                return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL;
13680
 
 
13681
 
        /*=======================================================================*/
13682
 
 
13683
 
        /* Check the provided port mask. */
13684
 
 
13685
 
        if ( ( f_pChannelUnMute->ulPortMask &
13686
 
                ~(      cOCT6100_CHANNEL_MUTE_PORT_NONE | 
13687
 
                        cOCT6100_CHANNEL_MUTE_PORT_RIN |
13688
 
                        cOCT6100_CHANNEL_MUTE_PORT_ROUT |
13689
 
                        cOCT6100_CHANNEL_MUTE_PORT_SIN | 
13690
 
                        cOCT6100_CHANNEL_MUTE_PORT_SOUT |
13691
 
                        cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) ) != 0 )
13692
 
                return cOCT6100_ERR_CHANNEL_MUTE_MASK;
13693
 
        
13694
 
        /* Return the ports to the calling function. */
13695
 
        *f_pusPorts = (UINT16)( f_pChannelUnMute->ulPortMask & 0xFFFF );
13696
 
 
13697
 
        return cOCT6100_ERR_OK;
13698
 
}
13699
 
#endif
13700
 
 
13701
 
 
13702
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13703
 
 
13704
 
Function:               Oct6100ApiMuteSinWithFeatures
13705
 
 
13706
 
Description:    Mute or Unmute the sin with features port.
13707
 
 
13708
 
-------------------------------------------------------------------------------
13709
 
|       Argument                |       Description
13710
 
-------------------------------------------------------------------------------
13711
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
13712
 
                                                        the present state of the chip and all its resources.
13713
 
 
13714
 
f_usChanIndex                           Resulting channel index where the muting should
13715
 
                                                        be applied.
13716
 
f_fEnableSinWithFeatures        Whether to enable the feature or not.
13717
 
 
13718
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13719
 
#if !SKIP_Oct6100ApiMuteSinWithFeatures
13720
 
UINT32 Oct6100ApiMuteSinWithFeatures(
13721
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
13722
 
                                IN      UINT16                                          f_usChanIndex,
13723
 
                                IN      BOOL                                            f_fEnableSinWithFeatures )
13724
 
{
13725
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
13726
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
13727
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
13728
 
        UINT32                                                  ulResult;
13729
 
 
13730
 
        UINT32                                                  ulTempData;
13731
 
        UINT32                                                  ulBaseAddress;
13732
 
        UINT32                                                  ulFeatureBytesOffset;
13733
 
        UINT32                                                  ulFeatureBitOffset;
13734
 
        UINT32                                                  ulFeatureFieldLength;
13735
 
        UINT32                                                  ulMask;
13736
 
        
13737
 
        /* Get local pointer(s). */
13738
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
13739
 
 
13740
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13741
 
 
13742
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
13743
 
 
13744
 
        /* Get a pointer to the channel's list entry. */
13745
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex  )
13746
 
 
13747
 
        ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
13748
 
        
13749
 
        if ( pSharedInfo->ImageInfo.fSinMute == TRUE )
13750
 
        {
13751
 
                ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinMuteOfst.usDwordOffset * 4;
13752
 
                ulFeatureBitOffset       = pSharedInfo->MemoryMap.SinMuteOfst.byBitOffset;
13753
 
                ulFeatureFieldLength = pSharedInfo->MemoryMap.SinMuteOfst.byFieldSize;
13754
 
 
13755
 
                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
13756
 
                                                                                        pChanEntry,
13757
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
13758
 
                                                                                        &ulTempData,
13759
 
                                                                                        ulResult );
13760
 
                if ( ulResult != cOCT6100_ERR_OK )
13761
 
                        return ulResult;        
13762
 
                
13763
 
                /* Clear previous value set in the feature field.*/
13764
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13765
 
 
13766
 
                /* Clear the mute flag. */
13767
 
                ulTempData &= (~ulMask);
13768
 
 
13769
 
                /* Set the mute flag on the Sin port.*/
13770
 
                if ( f_fEnableSinWithFeatures == TRUE )
13771
 
                        ulTempData |= ( 0x1 << ulFeatureBitOffset );
13772
 
 
13773
 
                /* Write the new DWORD where the field is located. */
13774
 
                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
13775
 
                                                                                pChanEntry,
13776
 
                                                                                ulBaseAddress + ulFeatureBytesOffset,
13777
 
                                                                                ulTempData,
13778
 
                                                                                ulResult );
13779
 
                if ( ulResult != cOCT6100_ERR_OK )
13780
 
                        return ulResult;        
13781
 
        }
13782
 
 
13783
 
        return cOCT6100_ERR_OK;
13784
 
}
13785
 
#endif
13786
 
 
13787
 
 
13788
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13789
 
 
13790
 
Function:               Oct6100ApiMuteChannelPorts
13791
 
 
13792
 
Description:    Mute or Unmute the specified ports, according to the mask.
13793
 
 
13794
 
-------------------------------------------------------------------------------
13795
 
|       Argument                |       Description
13796
 
-------------------------------------------------------------------------------
13797
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
13798
 
                                                the present state of the chip and all its resources.
13799
 
 
13800
 
f_usChanIndex                   Resulting channel index where the muting should
13801
 
                                                be applied.
13802
 
f_usPortMask                    Port mask on which to apply the muting/unmuting.
13803
 
 
13804
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13805
 
#if !SKIP_Oct6100ApiMuteChannelPorts
13806
 
UINT32 Oct6100ApiMuteChannelPorts(      
13807
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
13808
 
                                IN      UINT16                                          f_usChanIndex,
13809
 
                                IN      UINT16                                          f_usPortMask,
13810
 
                                IN      BOOL                                            f_fMute )
13811
 
{
13812
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
13813
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
13814
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
13815
 
        UINT32                                                  ulResult;
13816
 
        BOOL                                                    fDisableSinWithFeatures = FALSE;
13817
 
        BOOL                                                    fEnableSinWithFeatures = FALSE;
13818
 
        
13819
 
        /* Get local pointer(s). */
13820
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
13821
 
 
13822
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13823
 
 
13824
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
13825
 
 
13826
 
        /* Get a pointer to the channel's list entry. */
13827
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex  )
13828
 
 
13829
 
        /* Rin port. */
13830
 
        if ( ( f_fMute == TRUE )
13831
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 )
13832
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) == 0x0 ) )
13833
 
        {
13834
 
                /* Mute this port. */
13835
 
                pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_RIN;
13836
 
 
13837
 
                ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13838
 
                if ( ulResult != cOCT6100_ERR_OK )
13839
 
                {
13840
 
                        pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN;
13841
 
                        return ulResult;
13842
 
                }
13843
 
        }
13844
 
        else if ( ( f_fMute == FALSE ) 
13845
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 )
13846
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) )
13847
 
        {
13848
 
                /* Unmute this port. */
13849
 
                pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN;
13850
 
 
13851
 
                ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13852
 
                if ( ulResult != cOCT6100_ERR_OK )
13853
 
                        return ulResult;
13854
 
        }
13855
 
 
13856
 
        /* Rout port. */
13857
 
        if ( ( f_fMute == TRUE )
13858
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 )
13859
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 ) )
13860
 
        {
13861
 
                /* Mute this port. */
13862
 
 
13863
 
                if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
13864
 
                {
13865
 
                        /* Deactivate the TSST entry.*/
13866
 
                        WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usRoutTsstIndex  * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
13867
 
                        WriteParams.usWriteData  = 0x0000;
13868
 
 
13869
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13870
 
                        if ( ulResult != cOCT6100_ERR_OK )
13871
 
                                return ulResult;
13872
 
                }
13873
 
 
13874
 
                pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_ROUT;
13875
 
        }
13876
 
        else if ( ( f_fMute == FALSE ) 
13877
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 )
13878
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 ) )
13879
 
        {
13880
 
                /* Unmute this port. */
13881
 
 
13882
 
                if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
13883
 
                {
13884
 
                        ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
13885
 
                                                                                                                           pChanEntry->usRoutTsstIndex,
13886
 
                                                                                                                           pChanEntry->CodecConfig.byAdpcmNibblePosition,
13887
 
                                                                                                                           pChanEntry->TdmConfig.byRoutNumTssts,
13888
 
                                                                                                                           pChanEntry->usRinRoutTsiMemIndex );
13889
 
                        if ( ulResult != cOCT6100_ERR_OK )
13890
 
                                return ulResult;
13891
 
                }
13892
 
 
13893
 
                pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_ROUT;
13894
 
        }
13895
 
 
13896
 
        /* Sin port. */
13897
 
        if ( ( f_fMute == TRUE )
13898
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
13899
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) == 0x0 ) )
13900
 
        {
13901
 
                /* Mute this port. */
13902
 
                pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN;
13903
 
 
13904
 
                ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13905
 
                if ( ulResult != cOCT6100_ERR_OK )
13906
 
                {
13907
 
                        pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN;
13908
 
                        return ulResult;
13909
 
                }
13910
 
        }
13911
 
        else if ( 
13912
 
                        ( ( f_fMute == FALSE ) 
13913
 
                        && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
13914
 
                        && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) 
13915
 
                || 
13916
 
                        ( ( f_fMute == TRUE )  
13917
 
                        && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) 
13918
 
                        && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) )
13919
 
        {
13920
 
                /* Unmute this port. */
13921
 
                pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN;
13922
 
 
13923
 
                ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13924
 
                if ( ulResult != cOCT6100_ERR_OK )
13925
 
                        return ulResult;
13926
 
        }
13927
 
 
13928
 
        /* Sout port. */
13929
 
        if ( ( f_fMute == TRUE )
13930
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 )
13931
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 ) )
13932
 
        {
13933
 
                /* Mute this port. */
13934
 
 
13935
 
                if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
13936
 
                {
13937
 
                        /* Deactivate the TSST entry.*/
13938
 
                        WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usSoutTsstIndex  * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
13939
 
                        WriteParams.usWriteData  = 0x0000;
13940
 
 
13941
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13942
 
                        if ( ulResult != cOCT6100_ERR_OK  )
13943
 
                                return ulResult;
13944
 
                }
13945
 
 
13946
 
                pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SOUT;
13947
 
        }
13948
 
        else if ( ( f_fMute == FALSE ) 
13949
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 )
13950
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 ) )
13951
 
        {
13952
 
                /* Unmute this port. */
13953
 
 
13954
 
                if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
13955
 
                {
13956
 
                        ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
13957
 
                                                                                                                           pChanEntry->usSoutTsstIndex,
13958
 
                                                                                                                           pChanEntry->CodecConfig.byAdpcmNibblePosition,
13959
 
                                                                                                                           pChanEntry->TdmConfig.bySoutNumTssts,
13960
 
                                                                                                                           pChanEntry->usSinSoutTsiMemIndex );
13961
 
                        if ( ulResult != cOCT6100_ERR_OK )
13962
 
                                return ulResult;
13963
 
                }
13964
 
 
13965
 
                pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SOUT;
13966
 
        }
13967
 
 
13968
 
        /* Sin with features port. */
13969
 
        if ( ( f_fMute == TRUE )
13970
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
13971
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) == 0x0 ) )
13972
 
        {
13973
 
                /* Mute this port. */
13974
 
                pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES;
13975
 
                fEnableSinWithFeatures = TRUE;
13976
 
        }
13977
 
        else if ( 
13978
 
                        ( ( f_fMute == FALSE ) 
13979
 
                        && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
13980
 
                        && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) )
13981
 
                || 
13982
 
                        ( ( f_fMute == TRUE )  
13983
 
                        && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) 
13984
 
                        && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) ) )
13985
 
        {
13986
 
                /* Unmute this port. */
13987
 
                pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES;
13988
 
 
13989
 
                fDisableSinWithFeatures = TRUE;
13990
 
        }
13991
 
 
13992
 
        /* Check if must enable or disable SIN mute with features. */
13993
 
        if ( fDisableSinWithFeatures == TRUE || fEnableSinWithFeatures == TRUE )
13994
 
        {
13995
 
                ulResult = Oct6100ApiMuteSinWithFeatures( f_pApiInstance, f_usChanIndex, fEnableSinWithFeatures );
13996
 
                if ( ulResult != cOCT6100_ERR_OK )
13997
 
                        return ulResult;        
13998
 
        }
13999
 
 
14000
 
        return cOCT6100_ERR_OK;
14001
 
}
14002
 
#endif