Debian Codegraph @

drivers/dahdi/oct612x/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c

raw symbols SCIP
1 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2
3 File: oct6100_channel.c
4
5 Copyright (c) 2001-2007 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-PR49 $
27
28 $Octasic_Revision: 492 $
29
30 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
31
32
33 /***************************** INCLUDE FILES *******************************/
34
35 #if defined(__FreeBSD__)
36 #include <sys/types.h>
37 #include <dahdi/compat/bsd.h>
38 #else
39 #ifndef __KERNEL__
40 #include <stdlib.h>
41 #include <stdio.h>
42 #define kmalloc(size, type) malloc(size)
43 #define kfree(ptr) free(ptr)
44 #define GFP_ATOMIC 0 /* Dummy */
45 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
46 #else
47 #include <linux/slab.h>
48 #include <linux/kernel.h>
49 #endif
50 #endif
51
52 #include "octdef.h"
53
54 #include "oct6100api/oct6100_defines.h"
55 #include "oct6100api/oct6100_errors.h"
56 #include "oct6100api/oct6100_apiud.h"
57
58 #include "apilib/octapi_llman.h"
59
60 #include "oct6100api/oct6100_tlv_inst.h"
61 #include "oct6100api/oct6100_chip_open_inst.h"
62 #include "oct6100api/oct6100_chip_stats_inst.h"
63 #include "oct6100api/oct6100_interrupts_inst.h"
64 #include "oct6100api/oct6100_remote_debug_inst.h"
65 #include "oct6100api/oct6100_debug_inst.h"
66 #include "oct6100api/oct6100_api_inst.h"
67 #include "oct6100api/oct6100_mixer_inst.h"
68 #include "oct6100api/oct6100_tsi_cnct_inst.h"
69 #include "oct6100api/oct6100_conf_bridge_inst.h"
70 #include "oct6100api/oct6100_tone_detection_inst.h"
71 #include "oct6100api/oct6100_phasing_tsst_inst.h"
72 #include "oct6100api/oct6100_tsst_inst.h"
73 #include "oct6100api/oct6100_channel_inst.h"
74
75 #include "oct6100api/oct6100_interrupts_pub.h"
76 #include "oct6100api/oct6100_chip_open_pub.h"
77 #include "oct6100api/oct6100_tsi_cnct_pub.h"
78 #include "oct6100api/oct6100_playout_buf_pub.h"
79 #include "oct6100api/oct6100_phasing_tsst_pub.h"
80 #include "oct6100api/oct6100_mixer_pub.h"
81 #include "oct6100api/oct6100_conf_bridge_pub.h"
82 #include "oct6100api/oct6100_tone_detection_pub.h"
83 #include "oct6100api/oct6100_channel_pub.h"
84 #include "oct6100api/oct6100_debug_pub.h"
85
86 #include "oct6100_chip_open_priv.h"
87 #include "oct6100_miscellaneous_priv.h"
88 #include "oct6100_memory_priv.h"
89 #include "oct6100_tsst_priv.h"
90 #include "oct6100_mixer_priv.h"
91 #include "oct6100_phasing_tsst_priv.h"
92 #include "oct6100_tsi_cnct_priv.h"
93 #include "oct6100_playout_buf_priv.h"
94 #include "oct6100_conf_bridge_priv.h"
95 #include "oct6100_tone_detection_priv.h"
96 #include "oct6100_channel_priv.h"
97 #include "oct6100_debug_priv.h"
98
99
100 /**************************** PUBLIC FUNCTIONS ****************************/
101
102 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
103
104 Function: Oct6100ChannelOpen
105
106 Description: This function opens a echo cancellation channel. An echo cancellation
107 channel is constituted of two voice stream (RIN/ROUT and SIN/SOUT), and
108 an echo cancelling core.
109
110 -------------------------------------------------------------------------------
111 | Argument | Description
112 -------------------------------------------------------------------------------
113 f_pApiInstance Pointer to API instance. This memory is used to keep the
114 present state of the chip and all its resources.
115
116 f_pChannelOpen Pointer to echo channel open structure.
117
118 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
119 #if !SKIP_Oct6100ChannelOpenDef
120 UINT32 Oct6100ChannelOpenDef(
121 IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen )
122 {
123 f_pChannelOpen->pulChannelHndl = NULL;
124 f_pChannelOpen->ulUserChanId = cOCT6100_INVALID_VALUE;
125 f_pChannelOpen->ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_POWER_DOWN;
126 f_pChannelOpen->fEnableToneDisabler = FALSE;
127 f_pChannelOpen->fEnableExtToneDetection = FALSE;
128
129 /* VQE configuration.*/
130 f_pChannelOpen->VqeConfig.fSinDcOffsetRemoval = TRUE;
131 f_pChannelOpen->VqeConfig.fRinDcOffsetRemoval = TRUE;
132 f_pChannelOpen->VqeConfig.fRinLevelControl = FALSE;
133 f_pChannelOpen->VqeConfig.lRinLevelControlGainDb = 0;
134 f_pChannelOpen->VqeConfig.fSoutLevelControl = FALSE;
135 f_pChannelOpen->VqeConfig.lSoutLevelControlGainDb = 0;
136 f_pChannelOpen->VqeConfig.fRinAutomaticLevelControl = FALSE;
137 f_pChannelOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = -20;
138 f_pChannelOpen->VqeConfig.fSoutAutomaticLevelControl = FALSE;
139 f_pChannelOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = -20;
140 f_pChannelOpen->VqeConfig.fRinHighLevelCompensation = FALSE;
141 f_pChannelOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = -10;
142 f_pChannelOpen->VqeConfig.fSoutAdaptiveNoiseReduction = FALSE;
143 f_pChannelOpen->VqeConfig.fSoutNoiseBleaching = FALSE;
144 f_pChannelOpen->VqeConfig.fSoutConferencingNoiseReduction = FALSE;
145 f_pChannelOpen->VqeConfig.ulComfortNoiseMode = cOCT6100_COMFORT_NOISE_NORMAL;
146 f_pChannelOpen->VqeConfig.fEnableNlp = TRUE;
147 f_pChannelOpen->VqeConfig.fEnableTailDisplacement = FALSE;
148 f_pChannelOpen->VqeConfig.ulTailDisplacement = cOCT6100_AUTO_SELECT_TAIL;
149 f_pChannelOpen->VqeConfig.ulTailLength = cOCT6100_AUTO_SELECT_TAIL;
150
151 f_pChannelOpen->VqeConfig.fDtmfToneRemoval = FALSE;
152
153 f_pChannelOpen->VqeConfig.fAcousticEcho = FALSE;
154 f_pChannelOpen->VqeConfig.lDefaultErlDb = -6;
155 f_pChannelOpen->VqeConfig.ulAecTailLength = 128;
156 f_pChannelOpen->VqeConfig.lAecDefaultErlDb = 0;
157 f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorA = 1;
158 f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorB = 0;
159 f_pChannelOpen->VqeConfig.ulDoubleTalkBehavior = cOCT6100_DOUBLE_TALK_BEH_NORMAL;
160 f_pChannelOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = 0;
161 f_pChannelOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = 0;
162 f_pChannelOpen->VqeConfig.fSoutNaturalListenerEnhancement = FALSE;
163 f_pChannelOpen->VqeConfig.fRoutNoiseReduction = FALSE;
164 f_pChannelOpen->VqeConfig.lRoutNoiseReductionLevelGainDb = -18;
165 f_pChannelOpen->VqeConfig.lAnrSnrEnhancementDb = -18;
166 f_pChannelOpen->VqeConfig.ulAnrVoiceNoiseSegregation = 6;
167 f_pChannelOpen->VqeConfig.ulToneDisablerVqeActivationDelay = 300;
168 f_pChannelOpen->VqeConfig.fEnableMusicProtection = FALSE;
169 /* Older images have idle code detection hard-coded to enabled. */
170 f_pChannelOpen->VqeConfig.fIdleCodeDetection = TRUE;
171
172 /* TDM configuration.*/
173 f_pChannelOpen->TdmConfig.ulRinNumTssts = 1;
174 f_pChannelOpen->TdmConfig.ulSinNumTssts = 1;
175 f_pChannelOpen->TdmConfig.ulRoutNumTssts = 1;
176 f_pChannelOpen->TdmConfig.ulSoutNumTssts = 1;
177
178 f_pChannelOpen->TdmConfig.ulRinTimeslot = cOCT6100_UNASSIGNED;
179 f_pChannelOpen->TdmConfig.ulRinStream = cOCT6100_UNASSIGNED;
180 f_pChannelOpen->TdmConfig.ulRinPcmLaw = cOCT6100_PCM_U_LAW;
181
182 f_pChannelOpen->TdmConfig.ulSinTimeslot = cOCT6100_UNASSIGNED;
183 f_pChannelOpen->TdmConfig.ulSinStream = cOCT6100_UNASSIGNED;
184 f_pChannelOpen->TdmConfig.ulSinPcmLaw = cOCT6100_PCM_U_LAW;
185
186 f_pChannelOpen->TdmConfig.ulRoutTimeslot = cOCT6100_UNASSIGNED;
187 f_pChannelOpen->TdmConfig.ulRoutStream = cOCT6100_UNASSIGNED;
188 f_pChannelOpen->TdmConfig.ulRoutPcmLaw = cOCT6100_PCM_U_LAW;
189
190 f_pChannelOpen->TdmConfig.ulSoutTimeslot = cOCT6100_UNASSIGNED;
191 f_pChannelOpen->TdmConfig.ulSoutStream = cOCT6100_UNASSIGNED;
192 f_pChannelOpen->TdmConfig.ulSoutPcmLaw = cOCT6100_PCM_U_LAW;
193
194 /* CODEC configuration.*/
195 f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition = cOCT6100_ADPCM_IN_LOW_BITS;
196
197 f_pChannelOpen->CodecConfig.ulEncoderPort = cOCT6100_CHANNEL_PORT_SOUT;
198 f_pChannelOpen->CodecConfig.ulEncodingRate = cOCT6100_G711_64KBPS;
199 f_pChannelOpen->CodecConfig.ulDecoderPort = cOCT6100_CHANNEL_PORT_RIN;
200 f_pChannelOpen->CodecConfig.ulDecodingRate = cOCT6100_G711_64KBPS;
201
202 f_pChannelOpen->CodecConfig.fEnableSilenceSuppression = FALSE;
203 f_pChannelOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
204 f_pChannelOpen->CodecConfig.ulPhase = 1;
205 f_pChannelOpen->CodecConfig.ulPhasingType = cOCT6100_NO_PHASING;
206
207
208 return cOCT6100_ERR_OK;
209 }
210 #endif
211
212 #if !SKIP_Oct6100ChannelOpen
213 UINT32 Oct6100ChannelOpen(
214 IN tPOCT6100_INSTANCE_API f_pApiInstance,
215 IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen )
216 {
217 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
218 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
219 UINT32 ulSerRes = cOCT6100_ERR_OK;
220 UINT32 ulFncRes = cOCT6100_ERR_OK;
221
222 /* Set the process context of the serialize structure.*/
223 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
224 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
225
226 /* Seize all list semaphores needed by this function. */
227 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
228 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
229 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
230 if ( ulSerRes == cOCT6100_ERR_OK )
231 {
232 /* Call the serialized function. */
233 ulFncRes = Oct6100ChannelOpenSer( f_pApiInstance, f_pChannelOpen );
234 }
235 else
236 {
237 return ulSerRes;
238 }
239
240 /* Release the seized semaphores. */
241 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
242 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
243
244 /* If an error occured then return the error code. */
245 if ( ulSerRes != cOCT6100_ERR_OK )
246 return ulSerRes;
247 if ( ulFncRes != cOCT6100_ERR_OK )
248 return ulFncRes;
249
250 return cOCT6100_ERR_OK;
251 }
252 #endif
253
254
255 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
256
257 Function: Oct6100ChannelClose
258
259 Description: This function closes an echo canceller channel
260
261 -------------------------------------------------------------------------------
262 | Argument | Description
263 -------------------------------------------------------------------------------
264 f_pApiInstance Pointer to API instance. This memory is used to keep the
265 present state of the chip and all its resources.
266
267 f_pChannelClose Pointer to channel close structure.
268
269 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
270 #if !SKIP_Oct6100ChannelCloseDef
271 UINT32 Oct6100ChannelCloseDef(
272 IN OUT tPOCT6100_CHANNEL_CLOSE f_pChannelClose )
273 {
274 f_pChannelClose->ulChannelHndl = cOCT6100_INVALID_HANDLE;
275
276 return cOCT6100_ERR_OK;
277 }
278 #endif
279
280 #if !SKIP_Oct6100ChannelClose
281 UINT32 Oct6100ChannelClose(
282 IN tPOCT6100_INSTANCE_API f_pApiInstance,
283 IN tPOCT6100_CHANNEL_CLOSE f_pChannelClose )
284 {
285 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
286 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
287 UINT32 ulSerRes = cOCT6100_ERR_OK;
288 UINT32 ulFncRes = cOCT6100_ERR_OK;
289
290 /* Set the process context of the serialize structure.*/
291 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
292 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
293
294 /* Seize all list semaphores needed by this function. */
295 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
296 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
297
298 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
299 if ( ulSerRes == cOCT6100_ERR_OK )
300 {
301 /* Call the serialized function. */
302 ulFncRes = Oct6100ChannelCloseSer( f_pApiInstance, f_pChannelClose );
303 }
304 else
305 {
306 return ulSerRes;
307 }
308
309 /* Release the seized semaphores. */
310 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
311 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
312
313 /* If an error occured then return the error code. */
314 if ( ulSerRes != cOCT6100_ERR_OK )
315 return ulSerRes;
316 if ( ulFncRes != cOCT6100_ERR_OK )
317 return ulFncRes;
318
319 return cOCT6100_ERR_OK;
320 }
321 #endif
322
323
324 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
325
326 Function: Oct6100ChannelModify
327
328 Description: This function will modify the parameter of an echo channel. If
329 the call to this channel allows the channel to go from power down
330 to enable, the API will activate it.
331
332 -------------------------------------------------------------------------------
333 | Argument | Description
334 -------------------------------------------------------------------------------
335 f_pApiInstance Pointer to API instance. This memory is used to keep the
336 present state of the chip and all its resources.
337
338 f_pChannelModify Pointer to echo channel change structure.
339
340 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
341 #if !SKIP_Oct6100ChannelModifyDef
342 UINT32 Oct6100ChannelModifyDef(
343 IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify )
344 {
345 f_pChannelModify->ulChannelHndl = cOCT6100_INVALID_HANDLE;
346 f_pChannelModify->ulUserChanId = cOCT6100_KEEP_PREVIOUS_SETTING;
347 f_pChannelModify->ulEchoOperationMode = cOCT6100_KEEP_PREVIOUS_SETTING;
348
349 f_pChannelModify->fEnableToneDisabler = cOCT6100_KEEP_PREVIOUS_SETTING;
350
351 f_pChannelModify->fApplyToAllChannels = FALSE;
352
353 f_pChannelModify->fDisableToneDetection = FALSE;
354 f_pChannelModify->fStopBufferPlayout = FALSE;
355 f_pChannelModify->fRemoveConfBridgeParticipant = FALSE;
356 f_pChannelModify->fRemoveBroadcastTssts = FALSE;
357
358 f_pChannelModify->fTdmConfigModified = FALSE;
359 f_pChannelModify->fVqeConfigModified = FALSE;
360 f_pChannelModify->fCodecConfigModified = FALSE;
361
362 /* VQE config. */
363 f_pChannelModify->VqeConfig.fSinDcOffsetRemoval = cOCT6100_KEEP_PREVIOUS_SETTING;
364 f_pChannelModify->VqeConfig.fRinDcOffsetRemoval = cOCT6100_KEEP_PREVIOUS_SETTING;
365 f_pChannelModify->VqeConfig.fRinLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
366 f_pChannelModify->VqeConfig.lRinLevelControlGainDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
367 f_pChannelModify->VqeConfig.fSoutLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
368 f_pChannelModify->VqeConfig.lSoutLevelControlGainDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
369 f_pChannelModify->VqeConfig.fRinAutomaticLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
370 f_pChannelModify->VqeConfig.lRinAutomaticLevelControlTargetDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
371 f_pChannelModify->VqeConfig.fSoutAutomaticLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
372 f_pChannelModify->VqeConfig.lSoutAutomaticLevelControlTargetDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
373 f_pChannelModify->VqeConfig.fRinHighLevelCompensation = cOCT6100_KEEP_PREVIOUS_SETTING;
374 f_pChannelModify->VqeConfig.lRinHighLevelCompensationThresholdDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
375 f_pChannelModify->VqeConfig.fSoutAdaptiveNoiseReduction = cOCT6100_KEEP_PREVIOUS_SETTING;
376 f_pChannelModify->VqeConfig.fSoutNoiseBleaching = cOCT6100_KEEP_PREVIOUS_SETTING;
377 f_pChannelModify->VqeConfig.fSoutConferencingNoiseReduction = cOCT6100_KEEP_PREVIOUS_SETTING;
378 f_pChannelModify->VqeConfig.ulComfortNoiseMode = cOCT6100_KEEP_PREVIOUS_SETTING;
379 f_pChannelModify->VqeConfig.fEnableNlp = cOCT6100_KEEP_PREVIOUS_SETTING;
380 f_pChannelModify->VqeConfig.fEnableTailDisplacement = cOCT6100_KEEP_PREVIOUS_SETTING;
381 f_pChannelModify->VqeConfig.ulTailDisplacement = cOCT6100_KEEP_PREVIOUS_SETTING;
382
383 f_pChannelModify->VqeConfig.fDtmfToneRemoval = cOCT6100_KEEP_PREVIOUS_SETTING;
384
385 f_pChannelModify->VqeConfig.fAcousticEcho = cOCT6100_KEEP_PREVIOUS_SETTING;
386 f_pChannelModify->VqeConfig.lDefaultErlDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
387 f_pChannelModify->VqeConfig.ulAecTailLength = cOCT6100_KEEP_PREVIOUS_SETTING;
388 f_pChannelModify->VqeConfig.lAecDefaultErlDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
389 f_pChannelModify->VqeConfig.ulNonLinearityBehaviorA = cOCT6100_KEEP_PREVIOUS_SETTING;
390 f_pChannelModify->VqeConfig.ulNonLinearityBehaviorB = cOCT6100_KEEP_PREVIOUS_SETTING;
391 f_pChannelModify->VqeConfig.ulDoubleTalkBehavior = cOCT6100_KEEP_PREVIOUS_SETTING;
392 f_pChannelModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = cOCT6100_KEEP_PREVIOUS_SETTING;
393 f_pChannelModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = cOCT6100_KEEP_PREVIOUS_SETTING;
394 f_pChannelModify->VqeConfig.fSoutNaturalListenerEnhancement = cOCT6100_KEEP_PREVIOUS_SETTING;
395 f_pChannelModify->VqeConfig.fRoutNoiseReduction = cOCT6100_KEEP_PREVIOUS_SETTING;
396 f_pChannelModify->VqeConfig.lRoutNoiseReductionLevelGainDb = cOCT6100_KEEP_PREVIOUS_SETTING;
397 f_pChannelModify->VqeConfig.lAnrSnrEnhancementDb = cOCT6100_KEEP_PREVIOUS_SETTING;
398 f_pChannelModify->VqeConfig.ulAnrVoiceNoiseSegregation = cOCT6100_KEEP_PREVIOUS_SETTING;
399 f_pChannelModify->VqeConfig.ulToneDisablerVqeActivationDelay = cOCT6100_KEEP_PREVIOUS_SETTING;
400 f_pChannelModify->VqeConfig.fEnableMusicProtection = cOCT6100_KEEP_PREVIOUS_SETTING;
401 f_pChannelModify->VqeConfig.fIdleCodeDetection = cOCT6100_KEEP_PREVIOUS_SETTING;
402
403 /* TDM config. */
404 f_pChannelModify->TdmConfig.ulRinNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
405 f_pChannelModify->TdmConfig.ulSinNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
406 f_pChannelModify->TdmConfig.ulRoutNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
407 f_pChannelModify->TdmConfig.ulSoutNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
408
409 f_pChannelModify->TdmConfig.ulRinTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
410 f_pChannelModify->TdmConfig.ulRinStream = cOCT6100_KEEP_PREVIOUS_SETTING;
411 f_pChannelModify->TdmConfig.ulRinPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
412
413 f_pChannelModify->TdmConfig.ulSinTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
414 f_pChannelModify->TdmConfig.ulSinStream = cOCT6100_KEEP_PREVIOUS_SETTING;
415 f_pChannelModify->TdmConfig.ulSinPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
416
417 f_pChannelModify->TdmConfig.ulRoutTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
418 f_pChannelModify->TdmConfig.ulRoutStream = cOCT6100_KEEP_PREVIOUS_SETTING;
419 f_pChannelModify->TdmConfig.ulRoutPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
420
421 f_pChannelModify->TdmConfig.ulSoutTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
422 f_pChannelModify->TdmConfig.ulSoutStream = cOCT6100_KEEP_PREVIOUS_SETTING;
423 f_pChannelModify->TdmConfig.ulSoutPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
424
425 /* CODEC config. */
426 f_pChannelModify->CodecConfig.ulEncoderPort = cOCT6100_KEEP_PREVIOUS_SETTING;
427 f_pChannelModify->CodecConfig.ulEncodingRate = cOCT6100_KEEP_PREVIOUS_SETTING;
428 f_pChannelModify->CodecConfig.ulDecoderPort = cOCT6100_KEEP_PREVIOUS_SETTING;
429 f_pChannelModify->CodecConfig.ulDecodingRate = cOCT6100_KEEP_PREVIOUS_SETTING;
430
431 f_pChannelModify->CodecConfig.fEnableSilenceSuppression = cOCT6100_KEEP_PREVIOUS_SETTING;
432 f_pChannelModify->CodecConfig.ulPhasingTsstHndl = cOCT6100_KEEP_PREVIOUS_SETTING;
433 f_pChannelModify->CodecConfig.ulPhase = cOCT6100_KEEP_PREVIOUS_SETTING;
434 f_pChannelModify->CodecConfig.ulPhasingType = cOCT6100_KEEP_PREVIOUS_SETTING;
435
436
437 return cOCT6100_ERR_OK;
438 }
439 #endif
440
441 #if !SKIP_Oct6100ChannelModify
442 UINT32 Oct6100ChannelModify(
443 IN tPOCT6100_INSTANCE_API f_pApiInstance,
444 IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify )
445 {
446 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
447 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
448 UINT32 ulSerRes = cOCT6100_ERR_OK;
449 UINT32 ulFncRes = cOCT6100_ERR_OK;
450
451 /* Set the process context of the serialize structure.*/
452 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
453 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
454
455 /* Seize all list semaphores needed by this function. */
456 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
457 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
458 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
459 if ( ulSerRes == cOCT6100_ERR_OK )
460 {
461 /* Check the apply to all channels flag first. */
462 if ( f_pChannelModify->fApplyToAllChannels != TRUE &&
463 f_pChannelModify->fApplyToAllChannels != FALSE )
464 return cOCT6100_ERR_CHANNEL_APPLY_TO_ALL_CHANNELS;
465
466 /* Check if must apply modification to all channels. */
467 if ( f_pChannelModify->fApplyToAllChannels == TRUE )
468 {
469 tPOCT6100_API_CHANNEL pChanEntry;
470 UINT16 usChanIndex;
471
472 /* Loop through all channels and look for the opened ones. */
473 for ( usChanIndex = 0; usChanIndex < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; usChanIndex++ )
474 {
475 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, usChanIndex );
476
477 /* Check if this one is opened. */
478 if ( pChanEntry->fReserved == TRUE )
479 {
480 /* Channel is opened. Form handle and call actual modify function. */
481 f_pChannelModify->ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | usChanIndex;
482
483 /* Call the serialized function. */
484 ulFncRes = Oct6100ChannelModifySer( f_pApiInstance, f_pChannelModify );
485 if ( ulFncRes != cOCT6100_ERR_OK )
486 break;
487 }
488 }
489 }
490 else /* if ( f_pChannelModify->fApplyToAllChannels == FALSE ) */
491 {
492 /* Call the serialized function. */
493 ulFncRes = Oct6100ChannelModifySer( f_pApiInstance, f_pChannelModify );
494 }
495 }
496 else
497 {
498 return ulSerRes;
499 }
500
501 /* Release the seized semaphores. */
502 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
503 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
504
505 /* If an error occured then return the error code. */
506 if ( ulSerRes != cOCT6100_ERR_OK )
507 return ulSerRes;
508 if ( ulFncRes != cOCT6100_ERR_OK )
509 return ulFncRes;
510
511 return cOCT6100_ERR_OK;
512 }
513 #endif
514
515
516 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
517
518 Function: Oct6100ChannelCreateBiDir
519
520 Description: This function creates a bidirectional channel using two standard
521 echo cancellation channel.
522
523 -------------------------------------------------------------------------------
524 | Argument | Description
525 -------------------------------------------------------------------------------
526 f_pApiInstance Pointer to API instance. This memory is used to keep the
527 present state of the chip and all its resources.
528
529 f_pChannelCreateBiDir Pointer to channel create BiDir structure.
530
531 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
532 #if !SKIP_Oct6100ChannelCreateBiDirDef
533 UINT32 Oct6100ChannelCreateBiDirDef(
534 IN OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir )
535 {
536 f_pChannelCreateBiDir->pulBiDirChannelHndl = NULL;
537
538 f_pChannelCreateBiDir->ulFirstChannelHndl = cOCT6100_INVALID_HANDLE;
539 f_pChannelCreateBiDir->ulSecondChannelHndl = cOCT6100_INVALID_HANDLE;
540
541
542 return cOCT6100_ERR_OK;
543 }
544 #endif
545
546 #if !SKIP_Oct6100ChannelCreateBiDir
547 UINT32 Oct6100ChannelCreateBiDir(
548 IN tPOCT6100_INSTANCE_API f_pApiInstance,
549 IN OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir )
550 {
551 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
552 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
553 UINT32 ulSerRes = cOCT6100_ERR_OK;
554 UINT32 ulFncRes = cOCT6100_ERR_OK;
555
556 /* Set the process context of the serialize structure.*/
557 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
558 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
559
560 /* Seize all list semaphores needed by this function. */
561 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
562 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
563 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
564 if ( ulSerRes == cOCT6100_ERR_OK )
565 {
566 /* Call the serialized function. */
567 ulFncRes = Oct6100ChannelCreateBiDirSer( f_pApiInstance, f_pChannelCreateBiDir );
568 }
569 else
570 {
571 return ulSerRes;
572 }
573
574 /* Release the seized semaphores. */
575 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
576 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
577
578 /* If an error occured then return the error code. */
579 if ( ulSerRes != cOCT6100_ERR_OK )
580 return ulSerRes;
581 if ( ulFncRes != cOCT6100_ERR_OK )
582 return ulFncRes;
583
584 return cOCT6100_ERR_OK;
585 }
586 #endif
587
588
589
590
591 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
592
593 Function: Oct6100ChannelDestroyBiDir
594
595 Description: This function destroys a bidirectional channel.
596
597 -------------------------------------------------------------------------------
598 | Argument | Description
599 -------------------------------------------------------------------------------
600 f_pApiInstance Pointer to API instance. This memory is used to keep the
601 present state of the chip and all its resources.
602
603 f_pChannelDestroyBiDir Pointer to channel destroy BiDir structure.
604
605 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
606 #if !SKIP_Oct6100ChannelDestroyBiDirDef
607 UINT32 Oct6100ChannelDestroyBiDirDef(
608 IN OUT tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir )
609 {
610 f_pChannelDestroyBiDir->ulBiDirChannelHndl = cOCT6100_INVALID_HANDLE;
611
612 return cOCT6100_ERR_OK;
613 }
614 #endif
615
616 #if !SKIP_Oct6100ChannelDestroyBiDir
617 UINT32 Oct6100ChannelDestroyBiDir(
618 IN tPOCT6100_INSTANCE_API f_pApiInstance,
619 IN OUT tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir )
620 {
621 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
622 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
623 UINT32 ulSerRes = cOCT6100_ERR_OK;
624 UINT32 ulFncRes = cOCT6100_ERR_OK;
625
626 /* Set the process context of the serialize structure.*/
627 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
628 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
629
630 /* Seize all list semaphores needed by this function. */
631 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
632 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
633 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
634 if ( ulSerRes == cOCT6100_ERR_OK )
635 {
636 /* Call the serialized function. */
637 ulFncRes = Oct6100ChannelDestroyBiDirSer( f_pApiInstance, f_pChannelDestroyBiDir );
638 }
639 else
640 {
641 return ulSerRes;
642 }
643
644 /* Release the seized semaphores. */
645 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
646 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
647
648 /* If an error occured then return the error code. */
649 if ( ulSerRes != cOCT6100_ERR_OK )
650 return ulSerRes;
651 if ( ulFncRes != cOCT6100_ERR_OK )
652 return ulFncRes;
653
654 return cOCT6100_ERR_OK;
655 }
656 #endif
657
658
659 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
660
661 Function: Oct6100ChannelBroadcastTsstAdd
662
663 Description: This function adds a TSST to one of the two output ports of a channel.
664 This TSST can never be modified by a call to Oct6100ChannelModify.
665
666 -------------------------------------------------------------------------------
667 | Argument | Description
668 -------------------------------------------------------------------------------
669 f_pApiInstance Pointer to API instance. This memory is used to keep
670 the present state of the chip and all its resources.
671
672 f_pChannelBroadcastTsstAdd Pointer to the an Add Broadcast TSST structure.
673
674 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
675 #if !SKIP_Oct6100ChannelBroadcastTsstAddDef
676 UINT32 Oct6100ChannelBroadcastTsstAddDef(
677 tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelBroadcastTsstAdd )
678 {
679 f_pChannelBroadcastTsstAdd->ulChannelHndl = cOCT6100_INVALID_HANDLE;
680
681 f_pChannelBroadcastTsstAdd->ulPort = cOCT6100_INVALID_PORT;
682 f_pChannelBroadcastTsstAdd->ulTimeslot = cOCT6100_INVALID_TIMESLOT;
683 f_pChannelBroadcastTsstAdd->ulStream = cOCT6100_INVALID_STREAM;
684
685 return cOCT6100_ERR_OK;
686
687 }
688 #endif
689
690 #if !SKIP_Oct6100ChannelBroadcastTsstAdd
691 UINT32 Oct6100ChannelBroadcastTsstAdd(
692 tPOCT6100_INSTANCE_API f_pApiInstance,
693 tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelBroadcastTsstAdd )
694 {
695 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
696 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
697 UINT32 ulSerRes = cOCT6100_ERR_OK;
698 UINT32 ulFncRes = cOCT6100_ERR_OK;
699
700 /* Set the process context of the serialize structure.*/
701 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
702 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
703
704 /* Seize all list semaphores needed by this function. */
705 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
706 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
707 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
708 if ( ulSerRes == cOCT6100_ERR_OK )
709 {
710 /* Call the serialized function. */
711 ulFncRes = Oct6100ChannelBroadcastTsstAddSer( f_pApiInstance, f_pChannelBroadcastTsstAdd );
712 }
713 else
714 {
715 return ulSerRes;
716 }
717
718 /* Release the seized semaphores. */
719 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
720 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
721
722 /* If an error occured then return the error code. */
723 if ( ulSerRes != cOCT6100_ERR_OK )
724 return ulSerRes;
725 if ( ulFncRes != cOCT6100_ERR_OK )
726 return ulFncRes;
727
728 return cOCT6100_ERR_OK;
729 }
730 #endif
731
732
733 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
734
735 Function: Oct6100ChannelBroadcastTsstRemove
736
737 Description: This function removes a TSST from one of the two output ports of a channel.
738
739 -------------------------------------------------------------------------------
740 | Argument | Description
741 -------------------------------------------------------------------------------
742 f_pApiInstance Pointer to API instance. This memory is used to keep
743 the present state of the chip and all its resources.
744
745 f_pChannelBroadcastTsstRemove Pointer to the a Remove Broadcast TSST structure.
746
747 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
748 #if !SKIP_Oct6100ChannelBroadcastTsstRemoveDef
749 UINT32 Oct6100ChannelBroadcastTsstRemoveDef(
750 tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelBroadcastTsstRemove )
751 {
752 f_pChannelBroadcastTsstRemove->ulChannelHndl = cOCT6100_INVALID_HANDLE;
753
754 f_pChannelBroadcastTsstRemove->ulPort = cOCT6100_INVALID_PORT;
755 f_pChannelBroadcastTsstRemove->ulTimeslot = cOCT6100_INVALID_TIMESLOT;
756 f_pChannelBroadcastTsstRemove->ulStream = cOCT6100_INVALID_STREAM;
757
758 f_pChannelBroadcastTsstRemove->fRemoveAll = FALSE;
759
760 return cOCT6100_ERR_OK;
761 }
762 #endif
763
764
765 #if !SKIP_Oct6100ChannelBroadcastTsstRemove
766 UINT32 Oct6100ChannelBroadcastTsstRemove(
767 tPOCT6100_INSTANCE_API f_pApiInstance,
768 tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelBroadcastTsstRemove )
769 {
770 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
771 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
772 UINT32 ulSerRes = cOCT6100_ERR_OK;
773 UINT32 ulFncRes = cOCT6100_ERR_OK;
774
775 /* Set the process context of the serialize structure.*/
776 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
777 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
778
779 /* Seize all list semaphores needed by this function. */
780 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
781 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
782 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
783 if ( ulSerRes == cOCT6100_ERR_OK )
784 {
785 /* Call the serialized function. */
786 ulFncRes = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, f_pChannelBroadcastTsstRemove );
787 }
788 else
789 {
790 return ulSerRes;
791 }
792
793 /* Release the seized semaphores. */
794 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
795 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
796
797 /* If an error occured then return the error code. */
798 if ( ulSerRes != cOCT6100_ERR_OK )
799 return ulSerRes;
800 if ( ulFncRes != cOCT6100_ERR_OK )
801 return ulFncRes;
802
803 return cOCT6100_ERR_OK;
804 }
805 #endif
806
807
808
809 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
810
811 Function: Oct6100ChannelGetStats
812
813 Description: This function retrieves all the config and stats related to the channel
814 designated by ulChannelHndl.
815
816 -------------------------------------------------------------------------------
817 | Argument | Description
818 -------------------------------------------------------------------------------
819 f_pApiInstance Pointer to API instance. This memory is used to keep the
820 present state of the chip and all its resources.
821
822 f_pChannelStats Pointer to a tOCT6100_CHANNEL_STATS structure.
823
824 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
825 #if !SKIP_Oct6100ChannelGetStatsDef
826 UINT32 Oct6100ChannelGetStatsDef(
827 IN OUT tPOCT6100_CHANNEL_STATS f_pChannelStats )
828 {
829 f_pChannelStats->fResetStats = FALSE;
830
831 f_pChannelStats->ulChannelHndl = cOCT6100_INVALID_HANDLE;
832 f_pChannelStats->ulUserChanId = cOCT6100_INVALID_STAT;
833 f_pChannelStats->ulEchoOperationMode = cOCT6100_INVALID_STAT;
834 f_pChannelStats->fEnableToneDisabler = FALSE;
835 f_pChannelStats->ulMutePortsMask = cOCT6100_CHANNEL_MUTE_PORT_NONE;
836 f_pChannelStats->fEnableExtToneDetection = FALSE;
837
838 /* VQE configuration.*/
839 f_pChannelStats->VqeConfig.fEnableNlp = FALSE;
840 f_pChannelStats->VqeConfig.fEnableTailDisplacement = FALSE;
841 f_pChannelStats->VqeConfig.ulTailDisplacement = cOCT6100_INVALID_STAT;
842 f_pChannelStats->VqeConfig.ulTailLength = cOCT6100_INVALID_STAT;
843
844 f_pChannelStats->VqeConfig.fSinDcOffsetRemoval = FALSE;
845 f_pChannelStats->VqeConfig.fRinDcOffsetRemoval = FALSE;
846 f_pChannelStats->VqeConfig.fRinLevelControl = FALSE;
847 f_pChannelStats->VqeConfig.fSoutLevelControl = FALSE;
848 f_pChannelStats->VqeConfig.fRinAutomaticLevelControl = FALSE;
849 f_pChannelStats->VqeConfig.fSoutAutomaticLevelControl = FALSE;
850 f_pChannelStats->VqeConfig.fRinHighLevelCompensation = FALSE;
851 f_pChannelStats->VqeConfig.fAcousticEcho = FALSE;
852 f_pChannelStats->VqeConfig.fSoutAdaptiveNoiseReduction = FALSE;
853 f_pChannelStats->VqeConfig.fDtmfToneRemoval = FALSE;
854
855 f_pChannelStats->VqeConfig.fSoutNoiseBleaching = FALSE;
856 f_pChannelStats->VqeConfig.fSoutConferencingNoiseReduction = FALSE;
857
858 f_pChannelStats->VqeConfig.ulComfortNoiseMode = cOCT6100_INVALID_STAT;
859 f_pChannelStats->VqeConfig.ulNonLinearityBehaviorA = cOCT6100_INVALID_STAT;
860 f_pChannelStats->VqeConfig.ulNonLinearityBehaviorB = cOCT6100_INVALID_STAT;
861 f_pChannelStats->VqeConfig.ulDoubleTalkBehavior = cOCT6100_INVALID_STAT;
862 f_pChannelStats->VqeConfig.lRinLevelControlGainDb = cOCT6100_INVALID_SIGNED_STAT;
863 f_pChannelStats->VqeConfig.lSoutLevelControlGainDb = cOCT6100_INVALID_SIGNED_STAT;
864 f_pChannelStats->VqeConfig.lRinAutomaticLevelControlTargetDb = cOCT6100_INVALID_SIGNED_STAT;
865 f_pChannelStats->VqeConfig.lSoutAutomaticLevelControlTargetDb = cOCT6100_INVALID_SIGNED_STAT;
866 f_pChannelStats->VqeConfig.lRinHighLevelCompensationThresholdDb = cOCT6100_INVALID_SIGNED_STAT;
867 f_pChannelStats->VqeConfig.lDefaultErlDb = cOCT6100_INVALID_SIGNED_STAT;
868 f_pChannelStats->VqeConfig.lAecDefaultErlDb = cOCT6100_INVALID_SIGNED_STAT;
869 f_pChannelStats->VqeConfig.ulAecTailLength = cOCT6100_INVALID_STAT;
870 f_pChannelStats->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = cOCT6100_INVALID_STAT;
871 f_pChannelStats->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = cOCT6100_INVALID_STAT;
872 f_pChannelStats->VqeConfig.fSoutNaturalListenerEnhancement = FALSE;
873 f_pChannelStats->VqeConfig.fRoutNoiseReduction = FALSE;
874 f_pChannelStats->VqeConfig.lRoutNoiseReductionLevelGainDb = cOCT6100_INVALID_SIGNED_STAT;
875 f_pChannelStats->VqeConfig.lAnrSnrEnhancementDb = cOCT6100_INVALID_SIGNED_STAT;
876 f_pChannelStats->VqeConfig.ulAnrVoiceNoiseSegregation = cOCT6100_INVALID_STAT;
877 f_pChannelStats->VqeConfig.ulToneDisablerVqeActivationDelay = cOCT6100_INVALID_STAT;
878 f_pChannelStats->VqeConfig.fEnableMusicProtection = FALSE;
879 f_pChannelStats->VqeConfig.fIdleCodeDetection = FALSE;
880
881
882
883 /* TDM configuration.*/
884 f_pChannelStats->TdmConfig.ulMaxBroadcastTssts = 0;
885 f_pChannelStats->TdmConfig.fMoreRoutBroadcastTssts = FALSE;
886 f_pChannelStats->TdmConfig.fMoreSoutBroadcastTssts = FALSE;
887
888 f_pChannelStats->TdmConfig.ulNumRoutBroadcastTssts = 0;
889 f_pChannelStats->TdmConfig.ulNumSoutBroadcastTssts = 0;
890
891 f_pChannelStats->TdmConfig.ulRinNumTssts = cOCT6100_INVALID_STAT;
892 f_pChannelStats->TdmConfig.ulSinNumTssts = cOCT6100_INVALID_STAT;
893 f_pChannelStats->TdmConfig.ulRoutNumTssts = cOCT6100_INVALID_STAT;
894 f_pChannelStats->TdmConfig.ulSoutNumTssts = cOCT6100_INVALID_STAT;
895
896 f_pChannelStats->TdmConfig.ulRinTimeslot = cOCT6100_INVALID_STAT;
897 f_pChannelStats->TdmConfig.ulRinStream = cOCT6100_INVALID_STAT;
898 f_pChannelStats->TdmConfig.ulRinPcmLaw = cOCT6100_INVALID_STAT;
899
900 f_pChannelStats->TdmConfig.ulSinTimeslot = cOCT6100_INVALID_STAT;
901 f_pChannelStats->TdmConfig.ulSinStream = cOCT6100_INVALID_STAT;
902 f_pChannelStats->TdmConfig.ulSinPcmLaw = cOCT6100_INVALID_STAT;
903
904 f_pChannelStats->TdmConfig.ulRoutTimeslot = cOCT6100_INVALID_STAT;
905 f_pChannelStats->TdmConfig.ulRoutStream = cOCT6100_INVALID_STAT;
906 f_pChannelStats->TdmConfig.ulRoutPcmLaw = cOCT6100_INVALID_STAT;
907
908 f_pChannelStats->TdmConfig.pulRoutBroadcastTimeslot = NULL;
909 f_pChannelStats->TdmConfig.pulRoutBroadcastStream = NULL;
910
911 f_pChannelStats->TdmConfig.ulSoutTimeslot = cOCT6100_INVALID_STAT;
912 f_pChannelStats->TdmConfig.ulSoutStream = cOCT6100_INVALID_STAT;
913 f_pChannelStats->TdmConfig.ulSoutPcmLaw = cOCT6100_INVALID_STAT;
914
915 f_pChannelStats->TdmConfig.pulSoutBroadcastTimeslot = NULL;
916 f_pChannelStats->TdmConfig.pulSoutBroadcastStream = NULL;
917
918
919 /* CODEC configuration.*/
920 f_pChannelStats->CodecConfig.ulAdpcmNibblePosition = cOCT6100_INVALID_STAT;
921
922 f_pChannelStats->CodecConfig.ulEncoderPort = cOCT6100_INVALID_STAT;
923 f_pChannelStats->CodecConfig.ulEncodingRate = cOCT6100_INVALID_STAT;
924 f_pChannelStats->CodecConfig.ulDecoderPort = cOCT6100_INVALID_STAT;
925 f_pChannelStats->CodecConfig.ulDecodingRate = cOCT6100_INVALID_STAT;
926
927 f_pChannelStats->CodecConfig.fEnableSilenceSuppression = FALSE;
928 f_pChannelStats->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_STAT;
929 f_pChannelStats->CodecConfig.ulPhase = cOCT6100_INVALID_STAT;
930 f_pChannelStats->CodecConfig.ulPhasingType = cOCT6100_INVALID_STAT;
931
932 f_pChannelStats->ulNumEchoPathChanges = cOCT6100_INVALID_STAT;
933 f_pChannelStats->ulToneDisablerStatus = cOCT6100_INVALID_STAT;
934 f_pChannelStats->fEchoCancellerConverged = FALSE;
935 f_pChannelStats->fSinVoiceDetected = FALSE;
936 f_pChannelStats->lCurrentERL = cOCT6100_INVALID_SIGNED_STAT;
937 f_pChannelStats->lCurrentERLE = cOCT6100_INVALID_SIGNED_STAT;
938 f_pChannelStats->ulCurrentEchoDelay = cOCT6100_INVALID_STAT;
939
940 f_pChannelStats->lMaxERL = cOCT6100_INVALID_SIGNED_STAT;
941 f_pChannelStats->lMaxERLE = cOCT6100_INVALID_SIGNED_STAT;
942 f_pChannelStats->ulMaxEchoDelay = cOCT6100_INVALID_STAT;
943
944 f_pChannelStats->lRinLevel = cOCT6100_INVALID_SIGNED_STAT;
945 f_pChannelStats->lSinLevel = cOCT6100_INVALID_SIGNED_STAT;
946 f_pChannelStats->lRinAppliedGain = cOCT6100_INVALID_SIGNED_STAT;
947 f_pChannelStats->lSoutAppliedGain = cOCT6100_INVALID_SIGNED_STAT;
948 f_pChannelStats->lComfortNoiseLevel = cOCT6100_INVALID_SIGNED_STAT;
949
950
951
952 return cOCT6100_ERR_OK;
953 }
954 #endif
955
956 #if !SKIP_Oct6100ChannelGetStats
957 UINT32 Oct6100ChannelGetStats(
958 IN tPOCT6100_INSTANCE_API f_pApiInstance,
959 IN OUT tPOCT6100_CHANNEL_STATS f_pChannelStats )
960 {
961 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
962 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
963 UINT32 ulSerRes = cOCT6100_ERR_OK;
964 UINT32 ulFncRes = cOCT6100_ERR_OK;
965
966 /* Set the process context of the serialize structure.*/
967 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
968 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
969
970 /* Seize all list semaphores needed by this function. */
971 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
972 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
973 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
974 if ( ulSerRes == cOCT6100_ERR_OK )
975 {
976 /* Call the serialized function. */
977 ulFncRes = Oct6100ApiChannelGetStatsSer( f_pApiInstance, f_pChannelStats );
978 }
979 else
980 {
981 return ulSerRes;
982 }
983
984 /* Release the seized semaphores. */
985 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
986 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
987
988 /* If an error occured then return the error code. */
989 if ( ulSerRes != cOCT6100_ERR_OK )
990 return ulSerRes;
991 if ( ulFncRes != cOCT6100_ERR_OK )
992 return ulFncRes;
993
994 return cOCT6100_ERR_OK;
995 }
996 #endif
997
998
999 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1000
1001 Function: Oct6100ChannelMute
1002
1003 Description: This function mutes some or all of the ports designated by
1004 ulChannelHndl.
1005
1006 -------------------------------------------------------------------------------
1007 | Argument | Description
1008 -------------------------------------------------------------------------------
1009 f_pApiInstance Pointer to API instance. This memory is used to keep the
1010 present state of the chip and all its resources.
1011
1012 f_pChannelMute Pointer to a tPOCT6100_CHANNEL_MUTE structure.
1013
1014 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1015 #if !SKIP_Oct6100ChannelMuteDef
1016 UINT32 Oct6100ChannelMuteDef(
1017 IN OUT tPOCT6100_CHANNEL_MUTE f_pChannelMute )
1018 {
1019 f_pChannelMute->ulChannelHndl = cOCT6100_INVALID_HANDLE;
1020 f_pChannelMute->ulPortMask = cOCT6100_CHANNEL_MUTE_PORT_NONE;
1021
1022 return cOCT6100_ERR_OK;
1023 }
1024 #endif
1025
1026 #if !SKIP_Oct6100ChannelMute
1027 UINT32 Oct6100ChannelMute(
1028 IN tPOCT6100_INSTANCE_API f_pApiInstance,
1029 IN OUT tPOCT6100_CHANNEL_MUTE f_pChannelMute )
1030 {
1031 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
1032 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
1033 UINT32 ulSerRes = cOCT6100_ERR_OK;
1034 UINT32 ulFncRes = cOCT6100_ERR_OK;
1035
1036 /* Set the process context of the serialize structure.*/
1037 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
1038 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
1039
1040 /* Seize all list semaphores needed by this function. */
1041 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
1042 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
1043 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
1044 if ( ulSerRes == cOCT6100_ERR_OK )
1045 {
1046 /* Call the serialized function. */
1047 ulFncRes = Oct6100ChannelMuteSer( f_pApiInstance, f_pChannelMute );
1048 }
1049 else
1050 {
1051 return ulSerRes;
1052 }
1053
1054 /* Release the seized semaphores. */
1055 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
1056 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
1057
1058 /* If an error occured then return the error code. */
1059 if ( ulSerRes != cOCT6100_ERR_OK )
1060 return ulSerRes;
1061 if ( ulFncRes != cOCT6100_ERR_OK )
1062 return ulFncRes;
1063
1064 return cOCT6100_ERR_OK;
1065 }
1066 #endif
1067
1068 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1069
1070 Function: Oct6100ChannelUnMute
1071
1072 Description: This function unmutes some or all of the ports designated by
1073 ulChannelHndl.
1074
1075 -------------------------------------------------------------------------------
1076 | Argument | Description
1077 -------------------------------------------------------------------------------
1078 f_pApiInstance Pointer to API instance. This memory is used to keep the
1079 present state of the chip and all its resources.
1080
1081 f_pChannelUnMute Pointer to a tPOCT6100_CHANNEL_UNMUTE structure.
1082
1083 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1084 #if !SKIP_Oct6100ChannelUnMuteDef
1085 UINT32 Oct6100ChannelUnMuteDef(
1086 IN OUT tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute )
1087 {
1088 f_pChannelUnMute->ulChannelHndl = cOCT6100_INVALID_HANDLE;
1089 f_pChannelUnMute->ulPortMask = cOCT6100_CHANNEL_MUTE_PORT_NONE;
1090
1091 return cOCT6100_ERR_OK;
1092 }
1093 #endif
1094
1095 #if !SKIP_Oct6100ChannelUnMute
1096 UINT32 Oct6100ChannelUnMute(
1097 IN tPOCT6100_INSTANCE_API f_pApiInstance,
1098 IN OUT tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute )
1099 {
1100 tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
1101 tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
1102 UINT32 ulSerRes = cOCT6100_ERR_OK;
1103 UINT32 ulFncRes = cOCT6100_ERR_OK;
1104
1105 /* Set the process context of the serialize structure.*/
1106 SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
1107 ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
1108
1109 /* Seize all list semaphores needed by this function. */
1110 SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
1111 SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
1112 ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
1113 if ( ulSerRes == cOCT6100_ERR_OK )
1114 {
1115 /* Call the serialized function. */
1116 ulFncRes = Oct6100ChannelUnMuteSer( f_pApiInstance, f_pChannelUnMute );
1117 }
1118 else
1119 {
1120 return ulSerRes;
1121 }
1122
1123 /* Release the seized semaphores. */
1124 ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
1125 ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
1126
1127 /* If an error occured then return the error code. */
1128 if ( ulSerRes != cOCT6100_ERR_OK )
1129 return ulSerRes;
1130 if ( ulFncRes != cOCT6100_ERR_OK )
1131 return ulFncRes;
1132
1133 return cOCT6100_ERR_OK;
1134 }
1135 #endif
1136
1137 /**************************** PRIVATE FUNCTIONS ****************************/
1138
1139 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1140
1141 Function: Oct6100ApiGetChannelsEchoSwSizes
1142
1143 Description: Gets the sizes of all portions of the API instance pertinent
1144 to the management of the ECHO memory.
1145
1146 -------------------------------------------------------------------------------
1147 | Argument | Description
1148 -------------------------------------------------------------------------------
1149 f_pOpenChip Pointer to chip configuration struct.
1150 f_pInstSizes Pointer to struct containing instance sizes.
1151
1152 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1153 #if !SKIP_Oct6100ApiGetChannelsEchoSwSizes
1154 UINT32 Oct6100ApiGetChannelsEchoSwSizes(
1155 IN tPOCT6100_CHIP_OPEN f_pOpenChip,
1156 OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
1157 {
1158 UINT32 ulTempVar;
1159 UINT32 ulResult;
1160 UINT32 ulMaxChannels;
1161
1162 ulMaxChannels = f_pOpenChip->ulMaxChannels;
1163
1164 if ( f_pOpenChip->fEnableChannelRecording == TRUE && ulMaxChannels != 672 )
1165 ulMaxChannels++;
1166
1167 /* Determine the amount of memory required for the API echo channel list.*/
1168 f_pInstSizes->ulChannelList = ulMaxChannels * sizeof( tOCT6100_API_CHANNEL ); /* Add one for the record channel.*/
1169 f_pInstSizes->ulBiDirChannelList = f_pOpenChip->ulMaxBiDirChannels * sizeof( tOCT6100_API_BIDIR_CHANNEL );
1170 if ( ulMaxChannels > 0 )
1171 {
1172 /* Calculate memory needed for ECHO memory allocation */
1173 ulResult = OctapiLlmAllocGetSize( ulMaxChannels, &f_pInstSizes->ulChannelAlloc );
1174 if ( ulResult != cOCT6100_ERR_OK )
1175 return cOCT6100_ERR_FATAL_0;
1176 }
1177 else
1178 {
1179 f_pInstSizes->ulChannelAlloc = 0;
1180 }
1181 if ( f_pOpenChip->ulMaxBiDirChannels > 0 )
1182 {
1183 /* Calculate memory needed for ECHO memory allocation */
1184 ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxBiDirChannels, &f_pInstSizes->ulBiDirChannelAlloc );
1185 if ( ulResult != cOCT6100_ERR_OK )
1186 return cOCT6100_ERR_FATAL_0;
1187 }
1188 else
1189 {
1190 f_pInstSizes->ulBiDirChannelAlloc = 0;
1191 }
1192
1193 mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulChannelList, ulTempVar )
1194 mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulChannelAlloc, ulTempVar )
1195 mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulBiDirChannelList, ulTempVar )
1196 mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulBiDirChannelAlloc, ulTempVar )
1197 return cOCT6100_ERR_OK;
1198 }
1199 #endif
1200
1201 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1202
1203 Function: Oct6100ApiChannelsEchoSwInit
1204
1205 Description: Initializes all elements of the instance structure associated
1206 to the ECHO memory.
1207
1208 -------------------------------------------------------------------------------
1209 | Argument | Description
1210 -------------------------------------------------------------------------------
1211 f_pApiInstance Pointer to API instance. This memory is used to keep
1212 the present state of the chip and all its resources.
1213
1214 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1215 #if !SKIP_Oct6100ApiChannelsEchoSwInit
1216 UINT32 Oct6100ApiChannelsEchoSwInit(
1217 IN tPOCT6100_INSTANCE_API f_pApiInstance )
1218 {
1219 tPOCT6100_API_CHANNEL pChannelsEchoList;
1220 tPOCT6100_API_BIDIR_CHANNEL pBiDirChannelsList;
1221 tPOCT6100_SHARED_INFO pSharedInfo;
1222 UINT16 usMaxChannels;
1223 PVOID pEchoChanAlloc;
1224 PVOID pBiDirChanAlloc;
1225 UINT32 ulResult;
1226
1227 /* Get local pointer to shared portion of the API instance. */
1228 pSharedInfo = f_pApiInstance->pSharedInfo;
1229
1230 /* Initialize the ECHO channel API list.*/
1231 usMaxChannels = pSharedInfo->ChipConfig.usMaxChannels;
1232
1233 /* add a channel to initialize if the recording is activated. */
1234 if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
1235 usMaxChannels++;
1236
1237 /* Set all entries in the ADCPM channel list to unused. */
1238 mOCT6100_GET_CHANNEL_LIST_PNT( pSharedInfo, pChannelsEchoList );
1239
1240 /* Initialize the API ECHO channels allocation software to "all free". */
1241 if ( usMaxChannels > 0 )
1242 {
1243 /* Clear the memory */
1244 Oct6100UserMemSet( pChannelsEchoList, 0x00, sizeof(tOCT6100_API_CHANNEL) * usMaxChannels );
1245
1246 mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoChanAlloc )
1247
1248 ulResult = OctapiLlmAllocInit( &pEchoChanAlloc, usMaxChannels );
1249 if ( ulResult != cOCT6100_ERR_OK )
1250 return cOCT6100_ERR_FATAL_1;
1251 }
1252
1253 mOCT6100_GET_BIDIR_CHANNEL_LIST_PNT( pSharedInfo, pBiDirChannelsList );
1254
1255 if ( pSharedInfo->ChipConfig.usMaxBiDirChannels > 0 )
1256 {
1257 /* Clear the memory */
1258 Oct6100UserMemSet( pBiDirChannelsList, 0x00, sizeof(tOCT6100_API_BIDIR_CHANNEL) * pSharedInfo->ChipConfig.usMaxBiDirChannels );
1259
1260 mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pBiDirChanAlloc )
1261
1262 ulResult = OctapiLlmAllocInit( &pBiDirChanAlloc, pSharedInfo->ChipConfig.usMaxBiDirChannels );
1263 if ( ulResult != cOCT6100_ERR_OK )
1264 return cOCT6100_ERR_FATAL_A9;
1265
1266 }
1267
1268 return cOCT6100_ERR_OK;
1269 }
1270 #endif
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1281
1282 Function: Oct6100ChannelOpenSer
1283
1284 Description: Opens a echo cancellation channel.
1285
1286 -------------------------------------------------------------------------------
1287 | Argument | Description
1288 -------------------------------------------------------------------------------
1289 f_pApiInstance Pointer to API instance. This memory is used to keep the
1290 present state of the chip and all its resources.
1291
1292 f_pChannelOpen Pointer to channel configuration structure. Then handle
1293 identifying the buffer in all future function calls is
1294 returned in this structure.
1295
1296 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1297 #if !SKIP_Oct6100ChannelOpenSer
1298 UINT32 Oct6100ChannelOpenSer(
1299 IN tPOCT6100_INSTANCE_API f_pApiInstance,
1300 IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen )
1301 {
1302 tOCT6100_API_ECHO_CHAN_INDEX *ChannelIndexConf;
1303 UINT32 ulResult;
1304
1305 ChannelIndexConf = kmalloc(sizeof(*ChannelIndexConf), GFP_ATOMIC);
1306
1307 if (!ChannelIndexConf)
1308 return cOCT6100_ERR_FATAL_0;
1309
1310 /* Check the user's configuration of the echo cancellation channel for errors. */
1311 ulResult = Oct6100ApiCheckChannelParams( f_pApiInstance, f_pChannelOpen, ChannelIndexConf );
1312 if ( ulResult != cOCT6100_ERR_OK )
1313 goto out;
1314
1315 /* Reserve all resources needed by the echo cancellation channel. */
1316 ulResult = Oct6100ApiReserveChannelResources( f_pApiInstance, f_pChannelOpen, ChannelIndexConf );
1317 if ( ulResult != cOCT6100_ERR_OK )
1318 goto out;
1319
1320 /* Write all necessary structures to activate the echo cancellation channel. */
1321 ulResult = Oct6100ApiWriteChannelStructs( f_pApiInstance, f_pChannelOpen, ChannelIndexConf );
1322 if ( ulResult != cOCT6100_ERR_OK )
1323 goto out;
1324
1325 /* Update the new echo cancellation channels's entry in the ECHO channel list. */
1326 ulResult = Oct6100ApiUpdateChannelEntry( f_pApiInstance, f_pChannelOpen, ChannelIndexConf );
1327 if ( ulResult != cOCT6100_ERR_OK )
1328 goto out;
1329
1330 kfree(ChannelIndexConf);
1331 return cOCT6100_ERR_OK;
1332
1333 out:
1334 kfree(ChannelIndexConf);
1335 return ulResult;
1336 }
1337 #endif
1338
1339 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1340
1341 Function: Oct6100ApiCheckChannelParams
1342
1343 Description: Checks the user's echo cancellation channel open configuration for errors.
1344
1345 -------------------------------------------------------------------------------
1346 | Argument | Description
1347 -------------------------------------------------------------------------------
1348 f_pApiInstance Pointer to API instance. This memory is used to keep the
1349 present state of the chip and all its resources.
1350
1351 f_pChannelOpen Pointer to echo cancellation channel open configuration structure.
1352 f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes.
1353
1354 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1355 #if !SKIP_Oct6100ApiCheckChannelParams
1356 UINT32 Oct6100ApiCheckChannelParams(
1357 IN tPOCT6100_INSTANCE_API f_pApiInstance,
1358 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
1359 OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf )
1360 {
1361 tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig;
1362 tPOCT6100_CHANNEL_OPEN_VQE pVqeConfig;
1363 tPOCT6100_CHANNEL_OPEN_CODEC pCodecConfig;
1364 UINT32 ulDecoderNumTssts;
1365 UINT32 ulResult;
1366
1367 /* Dereference the configuration structure for clearer code and faster access.*/
1368 pTdmConfig = &f_pChannelOpen->TdmConfig;
1369 pVqeConfig = &f_pChannelOpen->VqeConfig;
1370 pCodecConfig = &f_pChannelOpen->CodecConfig;
1371
1372 /* Check for errors. */
1373 if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels == 0 )
1374 return cOCT6100_ERR_CHANNEL_DISABLED;
1375
1376 if ( f_pChannelOpen->pulChannelHndl == NULL )
1377 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
1378
1379 if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NORMAL &&
1380 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_FREEZE &&
1381 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET &&
1382 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN &&
1383 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL &&
1384 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION &&
1385 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
1386 return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE;
1387
1388 /* Check the 2100Hz echo disabling configuration.*/
1389 if ( f_pChannelOpen->fEnableToneDisabler != TRUE &&
1390 f_pChannelOpen->fEnableToneDisabler != FALSE )
1391 return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ENABLE;
1392
1393 /* Check the extended Tone Detection flag value.*/
1394 if ( f_pChannelOpen->fEnableExtToneDetection != TRUE &&
1395 f_pChannelOpen->fEnableExtToneDetection != FALSE )
1396 return cOCT6100_ERR_CHANNEL_ENABLE_EXT_TONE_DETECTION;
1397
1398 /* Check that extented tone detection is actually enabled by the user. */
1399 if ( ( f_pChannelOpen->fEnableExtToneDetection == TRUE ) &&
1400 ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableExtToneDetection == FALSE ) )
1401 return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DISABLED;
1402
1403
1404
1405 /*==============================================================================*/
1406 /* Check the TDM configuration parameters.*/
1407
1408 ulResult = Oct6100ApiCheckTdmConfig( f_pApiInstance, pTdmConfig );
1409 if ( ulResult != cOCT6100_ERR_OK )
1410 return ulResult;
1411
1412 /*==============================================================================*/
1413
1414
1415 /*==============================================================================*/
1416 /* Now validate the VQE parameters */
1417
1418 ulResult = Oct6100ApiCheckVqeConfig( f_pApiInstance, pVqeConfig, f_pChannelOpen->fEnableToneDisabler );
1419 if ( ulResult != cOCT6100_ERR_OK )
1420 return ulResult;
1421
1422 /* Verify if the echo operation mode selected can be applied. */
1423 if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
1424 && ( pVqeConfig->fEnableNlp == FALSE ) )
1425 return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
1426
1427 if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
1428 && ( pVqeConfig->fEnableNlp == FALSE ) )
1429 return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
1430
1431 /* Comfort noise must be activated for speech recognition mode to work. */
1432 if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
1433 && ( pVqeConfig->ulComfortNoiseMode == cOCT6100_COMFORT_NOISE_OFF ) )
1434 return cOCT6100_ERR_CHANNEL_COMFORT_NOISE_REQUIRED;
1435
1436 /*==============================================================================*/
1437
1438 /*==============================================================================*/
1439 /* Finally, validate the CODEC configuration.*/
1440
1441 if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1442 ulDecoderNumTssts = pTdmConfig->ulRinNumTssts;
1443 else /* pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
1444 ulDecoderNumTssts = pTdmConfig->ulSinNumTssts;
1445
1446 ulResult = Oct6100ApiCheckCodecConfig( f_pApiInstance, pCodecConfig, ulDecoderNumTssts, &f_pChanIndexConf->usPhasingTsstIndex );
1447 if ( ulResult != cOCT6100_ERR_OK )
1448 return ulResult;
1449
1450
1451
1452 /* make sure that if silence suppression is activated, the NLP is enabled.*/
1453 if ( pCodecConfig->fEnableSilenceSuppression == TRUE && pVqeConfig->fEnableNlp == FALSE )
1454 return cOCT6100_ERR_CHANNEL_SIL_SUP_NLP_MUST_BE_ENABLED;
1455
1456 /* Verify if law conversion is allowed. */
1457 if ( pCodecConfig->ulEncoderPort == cOCT6100_NO_ENCODING ||
1458 pCodecConfig->ulDecoderPort == cOCT6100_NO_DECODING )
1459 {
1460 /* No law conversion can occurs if one ADPCM memory is not reserved.*/
1461 if ( pTdmConfig->ulRinPcmLaw != pTdmConfig->ulRoutPcmLaw )
1462 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_LAW_TRANSLATION;
1463
1464 if ( pTdmConfig->ulSinPcmLaw != pTdmConfig->ulSoutPcmLaw )
1465 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_LAW_TRANSLATION;
1466 }
1467
1468 /* Verify if the config supports extended tone detection.*/
1469 if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
1470 {
1471 if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1472 return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT;
1473 }
1474 /*==============================================================================*/
1475
1476 return cOCT6100_ERR_OK;
1477 }
1478 #endif
1479
1480 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1481
1482 Function: Oct6100ApiReserveChannelResources
1483
1484 Description: Reserves all resources needed for the new channel.
1485
1486 -------------------------------------------------------------------------------
1487 | Argument | Description
1488 -------------------------------------------------------------------------------
1489 f_pApiInstance Pointer to API instance. This memory is used to keep the
1490 present state of the chip and all its resources.
1491
1492 f_pChannelOpen Pointer to echo cancellation channel configuration structure.
1493 f_pulChannelIndex Allocated entry in ECHO channel list.
1494 f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes.
1495
1496 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1497 #if !SKIP_Oct6100ApiReserveChannelResources
1498 UINT32 Oct6100ApiReserveChannelResources(
1499 IN tPOCT6100_INSTANCE_API f_pApiInstance,
1500 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
1501 OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf )
1502 {
1503 tPOCT6100_SHARED_INFO pSharedInfo;
1504 tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig;
1505 tPOCT6100_CHANNEL_OPEN_CODEC pCodecConfig;
1506
1507 UINT32 ulResult;
1508 UINT32 ulTempVar;
1509 UINT32 ulFreeMixerEventCnt;
1510
1511 BOOL fRinTsstEntry = FALSE;
1512 BOOL fSinTsstEntry = FALSE;
1513 BOOL fRoutTsstEntry = FALSE;
1514 BOOL fSoutTsstEntry = FALSE;
1515
1516 BOOL fRinRoutTsiMemEntry = FALSE;
1517 BOOL fSinSoutTsiMemEntry = FALSE;
1518
1519 BOOL fEchoChanEntry = FALSE;
1520
1521 PUINT16 pusRinRoutConversionMemIndex = NULL;
1522 PUINT16 pusSinSoutConversionMemIndex = NULL;
1523 BOOL fRinRoutConversionMemEntry = FALSE;
1524 BOOL fSinSoutConversionMemEntry = FALSE;
1525
1526 BOOL fExtToneChanEntry = FALSE;
1527 BOOL fExtToneTsiEntry = FALSE;
1528 BOOL fExtToneMixerEntry = FALSE;
1529
1530 /* Obtain local pointer to shared portion of instance. */
1531 pSharedInfo = f_pApiInstance->pSharedInfo;
1532
1533 /* Obtain a local pointer to the configuration structures.*/
1534 pTdmConfig = &f_pChannelOpen->TdmConfig;
1535 pCodecConfig = &f_pChannelOpen->CodecConfig;
1536
1537 /*===============================================================================*/
1538 /* Reserve Echo and TSI entries. */
1539
1540 ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance,
1541 &f_pChanIndexConf->usEchoChanIndex );
1542 if ( ulResult == cOCT6100_ERR_OK )
1543 {
1544 fEchoChanEntry = TRUE;
1545
1546 /* Set the echo, encoder and decoder memory indexes.*/
1547 f_pChanIndexConf->usEchoMemIndex = f_pChanIndexConf->usEchoChanIndex;
1548
1549 /* Reserve an entry for the RIN/ROUT tsi chariot memory. */
1550 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
1551 &f_pChanIndexConf->usRinRoutTsiMemIndex );
1552 if ( ulResult == cOCT6100_ERR_OK )
1553 {
1554 fRinRoutTsiMemEntry = TRUE;
1555
1556 /* Reserve an entry for the SIN/SOUT tsi chariot memory. */
1557 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
1558 &f_pChanIndexConf->usSinSoutTsiMemIndex );
1559 if ( ulResult == cOCT6100_ERR_OK )
1560 {
1561 fSinSoutTsiMemEntry = TRUE;
1562
1563 /* Reserve an ADPCM memory block for compression if required.*/
1564 if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
1565 {
1566 pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex;
1567 }
1568 else if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT )
1569 {
1570 pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex;
1571 }
1572
1573 /* Reserve an ADPCM memory block for decompression if required.*/
1574 if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1575 {
1576 pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex;
1577 }
1578 else if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN )
1579 {
1580 pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex;
1581 }
1582
1583
1584 /* Reserve the conversion memories. */
1585 if ( pusRinRoutConversionMemIndex != NULL )
1586 {
1587 /* Reserve a conversion memory for the Rin/Rout stream. */
1588 ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance,
1589 pusRinRoutConversionMemIndex );
1590 if ( ulResult == cOCT6100_ERR_OK )
1591 {
1592 fRinRoutConversionMemEntry = TRUE;
1593 }
1594 }
1595 else
1596 {
1597 /* No conversion memory reserved.*/
1598 f_pChanIndexConf->usRinRoutConversionMemIndex = cOCT6100_INVALID_INDEX;
1599 }
1600
1601 if ( ( pusSinSoutConversionMemIndex != NULL ) &&
1602 ( ulResult == cOCT6100_ERR_OK ) )
1603 {
1604 /* Reserve a conversion memory for the Sin/Sout stream. */
1605 ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance,
1606 pusSinSoutConversionMemIndex );
1607 if ( ulResult == cOCT6100_ERR_OK )
1608 {
1609 fSinSoutConversionMemEntry = TRUE;
1610 }
1611 }
1612 else
1613 {
1614 /* No conversion memory reserved.*/
1615 f_pChanIndexConf->usSinSoutConversionMemIndex = cOCT6100_INVALID_INDEX;
1616 }
1617
1618 /* Reserve any resources required if the extended Tone detection is enabled.*/
1619 if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
1620 {
1621 ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance,
1622 &f_pChanIndexConf->usExtToneChanIndex );
1623 if ( ulResult == cOCT6100_ERR_OK )
1624 {
1625 fExtToneChanEntry = TRUE;
1626
1627 /* Reserve an entry for the TSI chariot memory for the additionnal channel. */
1628 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
1629 &f_pChanIndexConf->usExtToneTsiIndex );
1630 if ( ulResult == cOCT6100_ERR_OK )
1631 {
1632 fExtToneTsiEntry = TRUE;
1633
1634 /* Reserve an entry for the TSI chariot memory for the additionnal channel. */
1635 ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance,
1636 &f_pChanIndexConf->usExtToneMixerIndex );
1637 if ( ulResult == cOCT6100_ERR_OK )
1638 fExtToneMixerEntry = TRUE;
1639 }
1640 }
1641 }
1642 else
1643 {
1644 f_pChanIndexConf->usExtToneChanIndex = cOCT6100_INVALID_INDEX;
1645 f_pChanIndexConf->usExtToneMixerIndex = cOCT6100_INVALID_INDEX;
1646 f_pChanIndexConf->usExtToneTsiIndex = cOCT6100_INVALID_INDEX;
1647 }
1648 }
1649 else
1650 {
1651 /* Return an error other then a Fatal.*/
1652 ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY;
1653 }
1654 }
1655 else
1656 {
1657 /* Return an error other then a Fatal.*/
1658 ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY;
1659 }
1660 }
1661
1662 /*===============================================================================*/
1663
1664 /*===============================================================================*/
1665 /* Now reserve the TSST entries if required.*/
1666
1667 /* Reserve the Rin TSST entry */
1668 if ( (ulResult == cOCT6100_ERR_OK ) &&
1669 (pTdmConfig->ulRinTimeslot != cOCT6100_UNASSIGNED &&
1670 pTdmConfig->ulRinStream != cOCT6100_UNASSIGNED) )
1671 {
1672 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
1673 pTdmConfig->ulRinTimeslot,
1674 pTdmConfig->ulRinStream,
1675 pTdmConfig->ulRinNumTssts,
1676 cOCT6100_INPUT_TSST,
1677 &f_pChanIndexConf->usRinTsstIndex,
1678 NULL );
1679 if ( ulResult == cOCT6100_ERR_OK )
1680 fRinTsstEntry = TRUE;
1681 }
1682 else
1683 {
1684 f_pChanIndexConf->usRinTsstIndex = cOCT6100_INVALID_INDEX;
1685 }
1686
1687
1688 if ( (ulResult == cOCT6100_ERR_OK ) &&
1689 (pTdmConfig->ulSinTimeslot != cOCT6100_UNASSIGNED &&
1690 pTdmConfig->ulSinStream != cOCT6100_UNASSIGNED) )
1691 {
1692 /* Reserve the Sin TSST entry.*/
1693 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
1694 pTdmConfig->ulSinTimeslot,
1695 pTdmConfig->ulSinStream,
1696 pTdmConfig->ulSinNumTssts,
1697 cOCT6100_INPUT_TSST,
1698 &f_pChanIndexConf->usSinTsstIndex,
1699 NULL );
1700 if ( ulResult == cOCT6100_ERR_OK )
1701 fSinTsstEntry = TRUE;
1702 }
1703 else
1704 {
1705 f_pChanIndexConf->usSinTsstIndex = cOCT6100_INVALID_INDEX;
1706 }
1707
1708 if ( (ulResult == cOCT6100_ERR_OK ) &&
1709 (pTdmConfig->ulRoutTimeslot != cOCT6100_UNASSIGNED &&
1710 pTdmConfig->ulRoutStream != cOCT6100_UNASSIGNED) )
1711 {
1712 /* Reserve the Rout TSST entry.*/
1713 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
1714 pTdmConfig->ulRoutTimeslot,
1715 pTdmConfig->ulRoutStream,
1716 pTdmConfig->ulRoutNumTssts,
1717 cOCT6100_OUTPUT_TSST,
1718 &f_pChanIndexConf->usRoutTsstIndex,
1719 NULL );
1720 if ( ulResult == cOCT6100_ERR_OK )
1721 fRoutTsstEntry = TRUE;
1722 }
1723 else
1724 {
1725 f_pChanIndexConf->usRoutTsstIndex = cOCT6100_INVALID_INDEX;
1726 }
1727
1728
1729 if ( (ulResult == cOCT6100_ERR_OK ) &&
1730 (pTdmConfig->ulSoutTimeslot != cOCT6100_UNASSIGNED &&
1731 pTdmConfig->ulSoutStream != cOCT6100_UNASSIGNED) )
1732 {
1733 /* Reserve the Sout TSST entry.*/
1734 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
1735 pTdmConfig->ulSoutTimeslot,
1736 pTdmConfig->ulSoutStream,
1737 pTdmConfig->ulSoutNumTssts,
1738 cOCT6100_OUTPUT_TSST,
1739 &f_pChanIndexConf->usSoutTsstIndex,
1740 NULL );
1741 if ( ulResult == cOCT6100_ERR_OK )
1742 fSoutTsstEntry = TRUE;
1743 }
1744 else
1745 {
1746 f_pChanIndexConf->usSoutTsstIndex = cOCT6100_INVALID_INDEX;
1747 }
1748
1749 /*===============================================================================*/
1750
1751
1752 /*===============================================================================*/
1753 /* Check if there are a couple of mixer events available for us. */
1754
1755 if ( ulResult == cOCT6100_ERR_OK )
1756 {
1757 UINT32 ulMixerEventCntNeeded = 0;
1758
1759 /* Calculate how many mixer events are needed. */
1760 if ( f_pChanIndexConf->usRinTsstIndex == cOCT6100_INVALID_INDEX )
1761 ulMixerEventCntNeeded++;
1762
1763 if ( f_pChanIndexConf->usSinTsstIndex == cOCT6100_INVALID_INDEX )
1764 ulMixerEventCntNeeded++;
1765
1766 /* If at least 1 mixer event is needed, check if those are available. */
1767 if ( ulMixerEventCntNeeded != 0 )
1768 {
1769 ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt );
1770 if ( ulResult == cOCT6100_ERR_OK )
1771 {
1772 /* The API might need more mixer events if the ports have to be muted. */
1773 /* Check if these are available. */
1774 if ( ulFreeMixerEventCnt < ulMixerEventCntNeeded )
1775 {
1776 ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS;
1777 }
1778 }
1779 }
1780 }
1781
1782 /*===============================================================================*/
1783
1784
1785 /*===============================================================================*/
1786 /* Release the resources if something went wrong */
1787 if ( ulResult != cOCT6100_ERR_OK )
1788 {
1789 /*===============================================================================*/
1790 /* Release the previously reserved resources .*/
1791 if( fRinTsstEntry == TRUE )
1792 {
1793 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
1794 pTdmConfig->ulRinTimeslot,
1795 pTdmConfig->ulRinStream,
1796 pTdmConfig->ulRinNumTssts,
1797 cOCT6100_INPUT_TSST,
1798 cOCT6100_INVALID_INDEX );
1799 if ( ulTempVar != cOCT6100_ERR_OK )
1800 return ulTempVar;
1801 }
1802
1803 if( fSinTsstEntry == TRUE )
1804 {
1805 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
1806 pTdmConfig->ulSinTimeslot,
1807 pTdmConfig->ulSinStream,
1808 pTdmConfig->ulSinNumTssts,
1809 cOCT6100_INPUT_TSST,
1810 cOCT6100_INVALID_INDEX );
1811 if ( ulTempVar != cOCT6100_ERR_OK )
1812 return ulTempVar;
1813 }
1814
1815 if( fRoutTsstEntry == TRUE )
1816 {
1817 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
1818 pTdmConfig->ulRoutTimeslot,
1819 pTdmConfig->ulRoutStream,
1820 pTdmConfig->ulRoutNumTssts,
1821 cOCT6100_OUTPUT_TSST,
1822 cOCT6100_INVALID_INDEX );
1823 if ( ulTempVar != cOCT6100_ERR_OK )
1824 return ulTempVar;
1825 }
1826
1827 if( fSoutTsstEntry == TRUE )
1828 {
1829 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
1830 pTdmConfig->ulSoutTimeslot,
1831 pTdmConfig->ulSoutStream,
1832 pTdmConfig->ulSoutNumTssts,
1833 cOCT6100_OUTPUT_TSST,
1834 cOCT6100_INVALID_INDEX );
1835 if ( ulTempVar != cOCT6100_ERR_OK )
1836 return ulTempVar;
1837 }
1838
1839 if( fRinRoutTsiMemEntry == TRUE )
1840 {
1841 ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
1842 f_pChanIndexConf->usRinRoutTsiMemIndex );
1843 if ( ulTempVar != cOCT6100_ERR_OK )
1844 return ulTempVar;
1845 }
1846
1847 if( fSinSoutTsiMemEntry == TRUE )
1848 {
1849 ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
1850 f_pChanIndexConf->usSinSoutTsiMemIndex );
1851 if ( ulTempVar != cOCT6100_ERR_OK )
1852 return ulTempVar;
1853 }
1854
1855 /*===============================================================================*/
1856
1857 /*===============================================================================*/
1858 /* Release the previously reserved echo resources .*/
1859 if( fEchoChanEntry == TRUE )
1860 {
1861 ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance,
1862 f_pChanIndexConf->usEchoChanIndex );
1863 if ( ulTempVar != cOCT6100_ERR_OK )
1864 return ulTempVar;
1865 }
1866
1867 /*===============================================================================*/
1868
1869 /*===============================================================================*/
1870 /* Release the previously reserved resources for the extended tone detection.*/
1871 if( fExtToneChanEntry == TRUE )
1872 {
1873 ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance,
1874 f_pChanIndexConf->usExtToneChanIndex );
1875 if ( ulTempVar != cOCT6100_ERR_OK )
1876 return ulTempVar;
1877 }
1878
1879 if( fExtToneTsiEntry == TRUE )
1880 {
1881 ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
1882 f_pChanIndexConf->usExtToneTsiIndex );
1883 if ( ulTempVar != cOCT6100_ERR_OK )
1884 return ulTempVar;
1885 }
1886
1887 if( fExtToneMixerEntry == TRUE )
1888 {
1889 ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
1890 f_pChanIndexConf->usExtToneMixerIndex );
1891 if ( ulTempVar != cOCT6100_ERR_OK )
1892 return ulTempVar;
1893 }
1894 /*===============================================================================*/
1895
1896 /*===============================================================================*/
1897 /* Release the conversion resources. */
1898 if( fRinRoutConversionMemEntry == TRUE )
1899 {
1900 ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
1901 f_pChanIndexConf->usRinRoutConversionMemIndex );
1902 if ( ulTempVar != cOCT6100_ERR_OK )
1903 return ulTempVar;
1904 }
1905
1906 if( fSinSoutConversionMemEntry == TRUE )
1907 {
1908 ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
1909 f_pChanIndexConf->usSinSoutConversionMemIndex );
1910 if ( ulTempVar != cOCT6100_ERR_OK )
1911 return ulTempVar;
1912 }
1913
1914 /*===============================================================================*/
1915
1916 return ulResult;
1917 }
1918
1919 return cOCT6100_ERR_OK;
1920 }
1921 #endif
1922
1923
1924 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1925
1926 Function: Oct6100ApiWriteChannelStructs
1927
1928 Description: Performs all the required structure writes to configure the
1929 new echo cancellation channel.
1930
1931 -------------------------------------------------------------------------------
1932 | Argument | Description
1933 -------------------------------------------------------------------------------
1934 f_pApiInstance Pointer to API instance. This memory is used to keep the
1935 present state of the chip and all its resources.
1936
1937 f_pChannelOpen Pointer to echo cancellation channel configuration structure.
1938 f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes.
1939
1940 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1941 #if !SKIP_Oct6100ApiWriteChannelStructs
1942 UINT32 Oct6100ApiWriteChannelStructs(
1943 IN tPOCT6100_INSTANCE_API f_pApiInstance,
1944 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
1945 OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf )
1946 {
1947 tPOCT6100_SHARED_INFO pSharedInfo;
1948 tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig;
1949 tOCT6100_WRITE_PARAMS WriteParams;
1950 tPOCT6100_API_CHANNEL pChanEntry;
1951 UINT32 ulResult;
1952 UINT32 ulDwordAddress;
1953 UINT32 ulDwordData;
1954 BOOL fConversionEnabled = FALSE;
1955 BOOL fProgramAdpcmMem;
1956 UINT32 ulCompType = 0;
1957 UINT32 ulPcmLaw;
1958 UINT16 usTempTsiMemIndex;
1959 UINT16 usConversionMemIndex;
1960 UINT32 ulToneEventNumber;
1961 BOOL fSSTone;
1962
1963 /* Obtain local pointer to shared portion of instance. */
1964 pSharedInfo = f_pApiInstance->pSharedInfo;
1965
1966 /* Obtain a local pointer to the TDM configuration structure.*/
1967 pTdmConfig = &f_pChannelOpen->TdmConfig;
1968
1969 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1970
1971 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1972
1973 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex );
1974
1975 /*==============================================================================*/
1976 /* Configure the Input Tsst control memory.*/
1977
1978 /* Set the RIN Tsst control entry.*/
1979 if ( f_pChanIndexConf->usRinTsstIndex != cOCT6100_INVALID_INDEX )
1980 {
1981 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
1982 f_pChanIndexConf->usRinTsstIndex,
1983 f_pChanIndexConf->usRinRoutTsiMemIndex,
1984 pTdmConfig->ulRinPcmLaw );
1985 if ( ulResult != cOCT6100_ERR_OK )
1986 return ulResult;
1987 }
1988
1989 /* Set the SIN Tsst control entry.*/
1990 if ( f_pChanIndexConf->usSinTsstIndex != cOCT6100_INVALID_INDEX )
1991 {
1992 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
1993 f_pChanIndexConf->usSinTsstIndex,
1994 f_pChanIndexConf->usSinSoutTsiMemIndex,
1995 pTdmConfig->ulSinPcmLaw );
1996 if ( ulResult != cOCT6100_ERR_OK )
1997 return ulResult;
1998 }
1999
2000 /*==============================================================================*/
2001
2002 /*==============================================================================*/
2003 /* Configure the ADPCM control memory for the Decoder.*/
2004
2005 /* Set the codec state flags.*/
2006 f_pChanIndexConf->fRinRoutCodecActive = FALSE;
2007 f_pChanIndexConf->fSinSoutCodecActive = FALSE;
2008
2009 if ( f_pChannelOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING )
2010 {
2011 fProgramAdpcmMem = TRUE;
2012
2013 switch( f_pChannelOpen->CodecConfig.ulDecodingRate )
2014 {
2015 case cOCT6100_G711_64KBPS:
2016 ulCompType = 0x8;
2017 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
2018 {
2019 if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw )
2020 fProgramAdpcmMem = FALSE;
2021
2022 /* Check if both ports are assigned. If not, no law conversion needed here.. */
2023 if ( ( pTdmConfig->ulRinStream == cOCT6100_UNASSIGNED )
2024 || ( pTdmConfig->ulRoutStream == cOCT6100_UNASSIGNED ) )
2025 fProgramAdpcmMem = FALSE;
2026 }
2027 else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
2028 {
2029 if ( pTdmConfig->ulSinPcmLaw == pTdmConfig->ulSoutPcmLaw )
2030 fProgramAdpcmMem = FALSE;
2031
2032 if ( ( pTdmConfig->ulSinStream == cOCT6100_UNASSIGNED )
2033 || ( pTdmConfig->ulSoutStream == cOCT6100_UNASSIGNED ) )
2034 fProgramAdpcmMem = FALSE;
2035 }
2036 break;
2037 case cOCT6100_G726_40KBPS:
2038 ulCompType = 0x3;
2039 fConversionEnabled = TRUE;
2040 break;
2041
2042 case cOCT6100_G726_32KBPS:
2043 ulCompType = 0x2;
2044 fConversionEnabled = TRUE;
2045 break;
2046
2047 case cOCT6100_G726_24KBPS:
2048 ulCompType = 0x1;
2049 fConversionEnabled = TRUE;
2050 break;
2051
2052 case cOCT6100_G726_16KBPS:
2053 ulCompType = 0x0;
2054 fConversionEnabled = TRUE;
2055 break;
2056
2057 case cOCT6100_G727_2C_ENCODED:
2058 ulCompType = 0x4;
2059 fConversionEnabled = TRUE;
2060 break;
2061
2062 case cOCT6100_G727_3C_ENCODED:
2063 ulCompType = 0x5;
2064 fConversionEnabled = TRUE;
2065 break;
2066
2067 case cOCT6100_G727_4C_ENCODED:
2068 ulCompType = 0x6;
2069 fConversionEnabled = TRUE;
2070 break;
2071
2072 case cOCT6100_G726_ENCODED:
2073 ulCompType = 0x9;
2074 fConversionEnabled = TRUE;
2075 break;
2076
2077 case cOCT6100_G711_G726_ENCODED:
2078 ulCompType = 0xA;
2079 fConversionEnabled = TRUE;
2080 break;
2081
2082 case cOCT6100_G711_G727_2C_ENCODED:
2083 ulCompType = 0xC;
2084 fConversionEnabled = TRUE;
2085 break;
2086
2087 case cOCT6100_G711_G727_3C_ENCODED:
2088 ulCompType = 0xD;
2089 fConversionEnabled = TRUE;
2090 break;
2091
2092 case cOCT6100_G711_G727_4C_ENCODED:
2093 ulCompType = 0xE;
2094 fConversionEnabled = TRUE;
2095 break;
2096 default:
2097 return cOCT6100_ERR_FATAL_D4;
2098 }
2099
2100 if ( fProgramAdpcmMem == TRUE )
2101 {
2102 /* Set the chariot memory based on the selected port.*/
2103 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
2104 {
2105 usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
2106 ulPcmLaw = pTdmConfig->ulRoutPcmLaw; /* Set the law for later use */
2107
2108 /* Set the codec state flags.*/
2109 f_pChanIndexConf->fRinRoutCodecActive = TRUE;
2110
2111 /* Set the conversion memory index to use for decompression */
2112 usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
2113 }
2114 else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
2115 {
2116 usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
2117 ulPcmLaw = pTdmConfig->ulSoutPcmLaw; /* Set the law for later use */
2118
2119 /* Set the codec state flags.*/
2120 f_pChanIndexConf->fSinSoutCodecActive = TRUE;
2121
2122 /* Set the conversion memory index to use for decompression */
2123 usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
2124 }
2125
2126 ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance,
2127 usConversionMemIndex,
2128 ulCompType,
2129 usTempTsiMemIndex,
2130 ulPcmLaw,
2131 f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition );
2132 if ( ulResult != cOCT6100_ERR_OK )
2133 return ulResult;
2134 }
2135 }
2136 /*==============================================================================*/
2137
2138
2139 /*==============================================================================*/
2140 /* Configure the ADPCM control memory for the Encoder */
2141
2142 if ( f_pChannelOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING )
2143 {
2144 fProgramAdpcmMem = TRUE;
2145
2146 switch( f_pChannelOpen->CodecConfig.ulEncodingRate )
2147 {
2148 case cOCT6100_G711_64KBPS:
2149 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
2150 {
2151 if ( pTdmConfig->ulRoutPcmLaw == cOCT6100_PCM_U_LAW )
2152 ulCompType = 0x4;
2153 else
2154 ulCompType = 0x5;
2155
2156 /* Check for law conversion.*/
2157 if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw )
2158 fProgramAdpcmMem = FALSE;
2159
2160 /* Check if both ports are assigned. If not, no law conversion needed here.. */
2161 if ( ( pTdmConfig->ulRinStream == cOCT6100_UNASSIGNED )
2162 || ( pTdmConfig->ulRoutStream == cOCT6100_UNASSIGNED ) )
2163 fProgramAdpcmMem = FALSE;
2164 }
2165 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
2166 {
2167 if ( pTdmConfig->ulSoutPcmLaw == cOCT6100_PCM_U_LAW )
2168 ulCompType = 0x4;
2169 else
2170 ulCompType = 0x5;
2171
2172 /* Check for law conversion.*/
2173 if ( pTdmConfig->ulSinPcmLaw == pTdmConfig->ulSoutPcmLaw )
2174 fProgramAdpcmMem = FALSE;
2175
2176 /* Check if both ports are assigned. If not, no law conversion needed here.. */
2177 if ( ( pTdmConfig->ulSinStream == cOCT6100_UNASSIGNED )
2178 || ( pTdmConfig->ulSoutStream == cOCT6100_UNASSIGNED ) )
2179 fProgramAdpcmMem = FALSE;
2180 }
2181
2182 break;
2183 case cOCT6100_G726_40KBPS:
2184 ulCompType = 0x3;
2185 fConversionEnabled = TRUE;
2186 break;
2187
2188 case cOCT6100_G726_32KBPS:
2189 ulCompType = 0x2;
2190 fConversionEnabled = TRUE;
2191 break;
2192
2193 case cOCT6100_G726_24KBPS:
2194 ulCompType = 0x1;
2195 fConversionEnabled = TRUE;
2196 break;
2197
2198 case cOCT6100_G726_16KBPS:
2199 ulCompType = 0x0;
2200 fConversionEnabled = TRUE;
2201 break;
2202
2203 case cOCT6100_G727_40KBPS_4_1:
2204 ulCompType = 0xD;
2205 fConversionEnabled = TRUE;
2206 break;
2207
2208 case cOCT6100_G727_40KBPS_3_2:
2209 ulCompType = 0xA;
2210 fConversionEnabled = TRUE;
2211 break;
2212
2213 case cOCT6100_G727_40KBPS_2_3:
2214 ulCompType = 0x6;
2215 fConversionEnabled = TRUE;
2216 break;
2217
2218 case cOCT6100_G727_32KBPS_4_0:
2219 ulCompType = 0xE;
2220 fConversionEnabled = TRUE;
2221 break;
2222
2223 case cOCT6100_G727_32KBPS_3_1:
2224 ulCompType = 0xB;
2225 fConversionEnabled = TRUE;
2226 break;
2227
2228 case cOCT6100_G727_32KBPS_2_2:
2229 ulCompType = 0x7;
2230 fConversionEnabled = TRUE;
2231 break;
2232
2233 case cOCT6100_G727_24KBPS_3_0:
2234 ulCompType = 0xC;
2235 fConversionEnabled = TRUE;
2236 break;
2237
2238 case cOCT6100_G727_24KBPS_2_1:
2239 ulCompType = 0x8;
2240 fConversionEnabled = TRUE;
2241 break;
2242
2243 case cOCT6100_G727_16KBPS_2_0:
2244 ulCompType = 0x9;
2245 fConversionEnabled = TRUE;
2246 break;
2247
2248 default:
2249 return cOCT6100_ERR_FATAL_D5;
2250 }
2251
2252 /* Program the APDCM memory only if ADPCM is requried.*/
2253 if ( fProgramAdpcmMem == TRUE || f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
2254 {
2255 /* Set the chariot memory based on the selected port.*/
2256 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
2257 {
2258 usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
2259
2260 /* Set the codec state flags.*/
2261 f_pChanIndexConf->fRinRoutCodecActive = TRUE;
2262
2263 /* Set the conversion memory index to use for compression */
2264 usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
2265 }
2266
2267 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
2268 {
2269 usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
2270
2271 /* Set the codec state flags.*/
2272 f_pChanIndexConf->fSinSoutCodecActive = TRUE;
2273
2274 /* Set the conversion memory index to use for compression */
2275 usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
2276 }
2277
2278 ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance,
2279 usConversionMemIndex,
2280 ulCompType,
2281 usTempTsiMemIndex,
2282 f_pChannelOpen->CodecConfig.fEnableSilenceSuppression,
2283 f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
2284 f_pChanIndexConf->usPhasingTsstIndex,
2285 f_pChannelOpen->CodecConfig.ulPhasingType,
2286 f_pChannelOpen->CodecConfig.ulPhase );
2287 if ( ulResult != cOCT6100_ERR_OK )
2288 return ulResult;
2289 }
2290 }
2291 /*==============================================================================*/
2292
2293
2294 /*==============================================================================*/
2295 /* Clearing the tone events bit vector */
2296
2297 ulDwordAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usEchoChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
2298 ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
2299 ulDwordData = 0x00000000;
2300
2301 ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2302 if ( ulResult != cOCT6100_ERR_OK )
2303 return ulResult;
2304
2305 ulDwordAddress += 4;
2306
2307 ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2308 if ( ulResult != cOCT6100_ERR_OK )
2309 return ulResult;
2310
2311 /*==============================================================================*/
2312
2313
2314 /*==============================================================================*/
2315 /* Write the VQE memory */
2316
2317 ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance,
2318 &f_pChannelOpen->VqeConfig,
2319 f_pChannelOpen,
2320 f_pChanIndexConf->usEchoChanIndex,
2321 f_pChanIndexConf->usEchoMemIndex,
2322 TRUE,
2323 FALSE );
2324 if ( ulResult != cOCT6100_ERR_OK )
2325 return ulResult;
2326
2327 /*==============================================================================*/
2328
2329 /*==============================================================================*/
2330 /* Write the echo memory */
2331
2332 ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance,
2333 pTdmConfig,
2334 f_pChannelOpen,
2335 f_pChanIndexConf->usEchoMemIndex,
2336 f_pChanIndexConf->usRinRoutTsiMemIndex,
2337 f_pChanIndexConf->usSinSoutTsiMemIndex );
2338 if ( ulResult != cOCT6100_ERR_OK )
2339 return ulResult;
2340
2341 /*==============================================================================*/
2342
2343
2344
2345 /*==============================================================================*/
2346 /* Mute channel if required, this is done on a port basis */
2347
2348 /* Initialize the silence indexes to invalid for now. */
2349 pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
2350 pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
2351
2352 /* Set the TSI memory indexes. */
2353 pChanEntry->usRinRoutTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
2354 pChanEntry->usSinSoutTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
2355
2356 ulResult = Oct6100ApiMutePorts( f_pApiInstance,
2357 f_pChanIndexConf->usEchoChanIndex,
2358 f_pChanIndexConf->usRinTsstIndex,
2359 f_pChanIndexConf->usSinTsstIndex,
2360 FALSE );
2361 if ( ulResult != cOCT6100_ERR_OK )
2362 return ulResult;
2363
2364 /*==============================================================================*/
2365
2366
2367 /*==============================================================================*/
2368 /* Set the dominant speaker to unassigned, if required. */
2369
2370 if ( f_pApiInstance->pSharedInfo->ImageInfo.fDominantSpeakerEnabled == TRUE )
2371 {
2372 ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_pChanIndexConf->usEchoChanIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED );
2373 if ( ulResult != cOCT6100_ERR_OK )
2374 return ulResult;
2375 }
2376
2377 /*==============================================================================*/
2378
2379
2380 /*==============================================================================*/
2381 /* If necessary, configure the extended tone detection channel.*/
2382
2383 if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
2384 {
2385 UINT32 ulTempSinLaw;
2386 UINT32 ulTempSoutLaw;
2387 UINT32 ulTempEchoOpMode;
2388
2389 /* save the original law.*/
2390 ulTempSinLaw = pTdmConfig->ulSinPcmLaw;
2391 ulTempSoutLaw = pTdmConfig->ulSoutPcmLaw;
2392 ulTempEchoOpMode = f_pChannelOpen->ulEchoOperationMode;
2393
2394 /* Now, make sure the Sin and Sout law are the same as the Rin law.*/
2395
2396 pTdmConfig->ulSinPcmLaw = pTdmConfig->ulRinPcmLaw;
2397 pTdmConfig->ulSoutPcmLaw = pTdmConfig->ulRinPcmLaw;
2398
2399 f_pChannelOpen->ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_NORMAL;
2400
2401 /* Write the Echo and VQE memory of the extended channel.*/
2402
2403 ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance,
2404 pTdmConfig,
2405 &f_pChannelOpen->VqeConfig,
2406 f_pChannelOpen,
2407 f_pChanIndexConf->usExtToneChanIndex,
2408 f_pChanIndexConf->usExtToneChanIndex,
2409 cOCT6100_API_EXT_TONE_EXTRA_TSI,
2410 f_pChanIndexConf->usExtToneTsiIndex );
2411 if ( ulResult != cOCT6100_ERR_OK )
2412 return ulResult;
2413
2414 /* Now, write the mixer event used to copy the RIN signal of the original channel
2415 into the SIN signal of the exteded channel. */
2416
2417 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_pChanIndexConf->usExtToneMixerIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
2418
2419 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
2420 WriteParams.usWriteData |= f_pChanIndexConf->usRinRoutTsiMemIndex;
2421 WriteParams.usWriteData |= pTdmConfig->ulRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
2422
2423 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2424 if ( ulResult != cOCT6100_ERR_OK )
2425 return ulResult;
2426
2427 WriteParams.ulWriteAddress += 2;
2428 WriteParams.usWriteData = f_pChanIndexConf->usExtToneTsiIndex;
2429
2430 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2431 if ( ulResult != cOCT6100_ERR_OK )
2432 return ulResult;
2433
2434 /*=======================================================================*/
2435
2436
2437 /*=======================================================================*/
2438 /* Now insert the Sin copy event into the list.*/
2439
2440 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
2441 f_pChanIndexConf->usExtToneMixerIndex,
2442 cOCT6100_EVENT_TYPE_SIN_COPY,
2443 f_pChanIndexConf->usEchoChanIndex );
2444 if ( ulResult != cOCT6100_ERR_OK )
2445 return ulResult;
2446 /*=======================================================================*/
2447
2448 /*==============================================================================*/
2449 /* Clearing the tone events bit vector */
2450
2451 ulDwordAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
2452 ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
2453 ulDwordData = 0x00000000;
2454
2455 ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2456 if ( ulResult != cOCT6100_ERR_OK )
2457 return ulResult;
2458
2459 ulDwordAddress += 4;
2460
2461 ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2462 if ( ulResult != cOCT6100_ERR_OK )
2463 return ulResult;
2464
2465 /*==============================================================================*/
2466
2467 /* Write back the original values in the channel open structure.*/
2468
2469 pTdmConfig->ulSinPcmLaw = ulTempSinLaw;
2470 pTdmConfig->ulSoutPcmLaw = ulTempSoutLaw;
2471
2472 f_pChannelOpen->ulEchoOperationMode = ulTempEchoOpMode;
2473 }
2474
2475 /*==============================================================================*/
2476
2477
2478 /*==============================================================================*/
2479 /* If necessary, configure the SS tone detection. */
2480
2481 for ( ulToneEventNumber = 0; ulToneEventNumber < cOCT6100_MAX_TONE_EVENT; ulToneEventNumber++ )
2482 {
2483 /* Check if the current tone is a SS tone. */
2484 ulResult = Oct6100ApiIsSSTone(
2485 f_pApiInstance,
2486 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID,
2487 &fSSTone );
2488 if ( ulResult != cOCT6100_ERR_OK )
2489 return ulResult;
2490
2491 if ( fSSTone == TRUE )
2492 {
2493 /* Write to all resources needed to activate tone detection on this SS tone. */
2494 ulResult = Oct6100ApiWriteToneDetectEvent(
2495 f_pApiInstance,
2496 f_pChanIndexConf->usEchoChanIndex,
2497 ulToneEventNumber,
2498
2499 cOCT6100_INVALID_INDEX );
2500 if ( ulResult != cOCT6100_ERR_OK )
2501 return ulResult;
2502 }
2503 }
2504
2505 /*==============================================================================*/
2506
2507
2508 /*==============================================================================*/
2509 /* Configure the Output Tsst control memory.*/
2510
2511 /* Set the ROUT Tsst control entry.*/
2512 if ( f_pChanIndexConf->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
2513 {
2514 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
2515 f_pChanIndexConf->usRoutTsstIndex,
2516 f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
2517 pTdmConfig->ulRoutNumTssts,
2518 f_pChanIndexConf->usRinRoutTsiMemIndex );
2519 if ( ulResult != cOCT6100_ERR_OK )
2520 return ulResult;
2521 }
2522
2523 /* Set the SOUT Tsst control entry.*/
2524 if ( f_pChanIndexConf->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
2525 {
2526 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
2527 f_pChanIndexConf->usSoutTsstIndex,
2528 f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
2529 pTdmConfig->ulSoutNumTssts,
2530 f_pChanIndexConf->usSinSoutTsiMemIndex );
2531 if ( ulResult != cOCT6100_ERR_OK )
2532 return ulResult;
2533 }
2534
2535 /*==============================================================================*/
2536
2537 return cOCT6100_ERR_OK;
2538 }
2539 #endif
2540
2541
2542
2543 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2544
2545 Function: Oct6100ApiUpdateChannelEntry
2546
2547 Description: Updates the new channel in the ECHO channel list.
2548
2549 -------------------------------------------------------------------------------
2550 | Argument | Description
2551 -------------------------------------------------------------------------------
2552 f_pApiInstance Pointer to API instance. This memory is used to keep
2553 the present state of the chip and all its resources.
2554
2555 f_pChannelOpen Pointer to echo cancellation channel configuration structure.
2556 f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes.
2557
2558 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2559 #if !SKIP_Oct6100ApiUpdateChannelEntry
2560 UINT32 Oct6100ApiUpdateChannelEntry(
2561 IN tPOCT6100_INSTANCE_API f_pApiInstance,
2562 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
2563 OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf )
2564 {
2565 tPOCT6100_API_CHANNEL pChanEntry;
2566 tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig;
2567 tPOCT6100_CHANNEL_OPEN_VQE pVqeConfig;
2568 tPOCT6100_CHANNEL_OPEN_CODEC pCodecConfig;
2569
2570 /* Obtain a pointer to the config structures of the tPOCT6100_CHANNEL_OPEN structure. */
2571 pTdmConfig = &f_pChannelOpen->TdmConfig;
2572 pVqeConfig = &f_pChannelOpen->VqeConfig;
2573 pCodecConfig = &f_pChannelOpen->CodecConfig;
2574
2575 /* Obtain a pointer to the new buffer's list entry. */
2576 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex )
2577
2578 /*=======================================================================*/
2579 /* Copy the channel's configuration and allocated resources. */
2580 pChanEntry->ulUserChanId = f_pChannelOpen->ulUserChanId;
2581 pChanEntry->byEchoOperationMode = (UINT8)( f_pChannelOpen->ulEchoOperationMode & 0xFF );
2582 pChanEntry->fEnableToneDisabler = (UINT8)( f_pChannelOpen->fEnableToneDisabler & 0xFF );
2583 pChanEntry->fEnableExtToneDetection = (UINT8)( f_pChannelOpen->fEnableExtToneDetection & 0xFF );
2584
2585 /* Save the VQE configuration.*/
2586 pChanEntry->VqeConfig.byComfortNoiseMode = (UINT8)( pVqeConfig->ulComfortNoiseMode & 0xFF );
2587 pChanEntry->VqeConfig.fEnableNlp = (UINT8)( pVqeConfig->fEnableNlp & 0xFF );
2588 pChanEntry->VqeConfig.fEnableTailDisplacement = (UINT8)( pVqeConfig->fEnableTailDisplacement );
2589 pChanEntry->VqeConfig.usTailDisplacement = (UINT16)( pVqeConfig->ulTailDisplacement & 0xFFFF );
2590 pChanEntry->VqeConfig.usTailLength = (UINT16)( pVqeConfig->ulTailLength & 0xFFFF );
2591
2592 pChanEntry->VqeConfig.fSinDcOffsetRemoval = (UINT8)( pVqeConfig->fSinDcOffsetRemoval & 0xFF );
2593 pChanEntry->VqeConfig.fRinDcOffsetRemoval = (UINT8)( pVqeConfig->fRinDcOffsetRemoval & 0xFF );
2594 pChanEntry->VqeConfig.fRinLevelControl = (UINT8)( pVqeConfig->fRinLevelControl & 0xFF );
2595 pChanEntry->VqeConfig.chRinLevelControlGainDb = (OCT_INT8)( pVqeConfig->lRinLevelControlGainDb & 0xFF );
2596 pChanEntry->VqeConfig.fSoutLevelControl = (UINT8)( pVqeConfig->fSoutLevelControl & 0xFF );
2597 pChanEntry->VqeConfig.chSoutLevelControlGainDb = (OCT_INT8)( pVqeConfig->lSoutLevelControlGainDb & 0xFF );
2598 pChanEntry->VqeConfig.fRinAutomaticLevelControl = (UINT8)( pVqeConfig->fRinAutomaticLevelControl & 0xFF );
2599 pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb = (OCT_INT8)( pVqeConfig->lRinAutomaticLevelControlTargetDb & 0xFF );
2600 pChanEntry->VqeConfig.fSoutAutomaticLevelControl = (UINT8)( pVqeConfig->fSoutAutomaticLevelControl & 0xFF );
2601 pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb = (OCT_INT8)( pVqeConfig->lSoutAutomaticLevelControlTargetDb & 0xFF );
2602 pChanEntry->VqeConfig.fRinHighLevelCompensation = (UINT8)( pVqeConfig->fRinHighLevelCompensation & 0xFF );
2603 pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb = (OCT_INT8)( pVqeConfig->lRinHighLevelCompensationThresholdDb & 0xFF );
2604 pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction = (UINT8)( pVqeConfig->fSoutAdaptiveNoiseReduction & 0xFF );
2605 pChanEntry->VqeConfig.fSoutNoiseBleaching = (UINT8)( pVqeConfig->fSoutNoiseBleaching & 0xFF );
2606 pChanEntry->VqeConfig.fSoutConferencingNoiseReduction = (UINT8)( pVqeConfig->fSoutConferencingNoiseReduction & 0xFF );
2607
2608 pChanEntry->VqeConfig.fAcousticEcho = (UINT8)( pVqeConfig->fAcousticEcho & 0xFF );
2609
2610 pChanEntry->VqeConfig.fDtmfToneRemoval = (UINT8)( pVqeConfig->fDtmfToneRemoval & 0xFF );
2611
2612 pChanEntry->VqeConfig.chDefaultErlDb = (OCT_INT8)( pVqeConfig->lDefaultErlDb & 0xFF );
2613 pChanEntry->VqeConfig.chAecDefaultErlDb = (OCT_INT8)( pVqeConfig->lAecDefaultErlDb & 0xFF );
2614 pChanEntry->VqeConfig.usAecTailLength = (UINT16)( pVqeConfig->ulAecTailLength & 0xFFFF );
2615 pChanEntry->VqeConfig.byNonLinearityBehaviorA = (UINT8)( pVqeConfig->ulNonLinearityBehaviorA & 0xFF );
2616 pChanEntry->VqeConfig.byNonLinearityBehaviorB = (UINT8)( pVqeConfig->ulNonLinearityBehaviorB & 0xFF );
2617 pChanEntry->VqeConfig.byDoubleTalkBehavior = (UINT8)( pVqeConfig->ulDoubleTalkBehavior & 0xFF );
2618 pChanEntry->VqeConfig.chAnrSnrEnhancementDb = (OCT_INT8)( pVqeConfig->lAnrSnrEnhancementDb & 0xFF );
2619 pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation = (UINT8)( pVqeConfig->ulAnrVoiceNoiseSegregation & 0xFF );
2620 pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay = (UINT16)( pVqeConfig->ulToneDisablerVqeActivationDelay & 0xFFFF );
2621
2622 pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb = (UINT8)( pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb & 0xFF );
2623 pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb = (UINT8)( pVqeConfig->ulSoutNaturalListenerEnhancementGainDb & 0xFF );
2624 pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement = (UINT8)( pVqeConfig->fSoutNaturalListenerEnhancement & 0xFF );
2625 pChanEntry->VqeConfig.fRoutNoiseReduction = (UINT8)( pVqeConfig->fRoutNoiseReduction & 0xFF );
2626 pChanEntry->VqeConfig.chRoutNoiseReductionLevelGainDb = (OCT_INT8) (pVqeConfig->lRoutNoiseReductionLevelGainDb & 0xFF);
2627 pChanEntry->VqeConfig.fEnableMusicProtection = (UINT8)( pVqeConfig->fEnableMusicProtection & 0xFF );
2628 pChanEntry->VqeConfig.fIdleCodeDetection = (UINT8)( pVqeConfig->fIdleCodeDetection & 0xFF );
2629
2630 /* Save the codec information.*/
2631 pChanEntry->CodecConfig.byAdpcmNibblePosition = (UINT8)( pCodecConfig->ulAdpcmNibblePosition & 0xFF );
2632
2633 pChanEntry->CodecConfig.byDecoderPort = (UINT8)( pCodecConfig->ulDecoderPort & 0xFF );
2634 pChanEntry->CodecConfig.byDecodingRate = (UINT8)( pCodecConfig->ulDecodingRate & 0xFF );
2635 pChanEntry->CodecConfig.byEncoderPort = (UINT8)( pCodecConfig->ulEncoderPort & 0xFF );
2636 pChanEntry->CodecConfig.byEncodingRate = (UINT8)( pCodecConfig->ulEncodingRate & 0xFF );
2637
2638 pChanEntry->CodecConfig.fEnableSilenceSuppression = (UINT8)( pCodecConfig->fEnableSilenceSuppression & 0xFF );
2639 pChanEntry->CodecConfig.byPhase = (UINT8)( pCodecConfig->ulPhase & 0xFF );
2640 pChanEntry->CodecConfig.byPhasingType = (UINT8)( pCodecConfig->ulPhasingType & 0xFF );
2641
2642 /* Save the RIN settings.*/
2643 pChanEntry->TdmConfig.byRinPcmLaw = (UINT8)( pTdmConfig->ulRinPcmLaw & 0xFF );
2644 pChanEntry->TdmConfig.usRinTimeslot = (UINT16)( pTdmConfig->ulRinTimeslot & 0xFFFF );
2645 pChanEntry->TdmConfig.usRinStream = (UINT16)( pTdmConfig->ulRinStream & 0xFFFF );
2646
2647 /* Save the SIN settings.*/
2648 pChanEntry->TdmConfig.bySinPcmLaw = (UINT8)( pTdmConfig->ulSinPcmLaw & 0xFF );
2649 pChanEntry->TdmConfig.usSinTimeslot = (UINT16)( pTdmConfig->ulSinTimeslot & 0xFFFF );
2650 pChanEntry->TdmConfig.usSinStream = (UINT16)( pTdmConfig->ulSinStream & 0xFFFF );
2651
2652 /* Save the ROUT settings.*/
2653 pChanEntry->TdmConfig.byRoutPcmLaw = (UINT8)( pTdmConfig->ulRoutPcmLaw & 0xFF );
2654 pChanEntry->TdmConfig.usRoutTimeslot = (UINT16)( pTdmConfig->ulRoutTimeslot & 0xFFFF );
2655 pChanEntry->TdmConfig.usRoutStream = (UINT16)( pTdmConfig->ulRoutStream & 0xFFFF );
2656
2657 pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
2658 pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0;
2659
2660 /* Save the SOUT settings.*/
2661 pChanEntry->TdmConfig.bySoutPcmLaw = (UINT8)( pTdmConfig->ulSoutPcmLaw & 0xFF );
2662 pChanEntry->TdmConfig.usSoutTimeslot = (UINT16)( pTdmConfig->ulSoutTimeslot & 0xFFFF );
2663 pChanEntry->TdmConfig.usSoutStream = (UINT16)( pTdmConfig->ulSoutStream & 0xFFFF );
2664
2665 pChanEntry->TdmConfig.byRinNumTssts = (UINT8)( pTdmConfig->ulRinNumTssts & 0xFF );
2666 pChanEntry->TdmConfig.bySinNumTssts = (UINT8)( pTdmConfig->ulSinNumTssts & 0xFF );
2667 pChanEntry->TdmConfig.byRoutNumTssts = (UINT8)( pTdmConfig->ulRoutNumTssts & 0xFF );
2668 pChanEntry->TdmConfig.bySoutNumTssts = (UINT8)( pTdmConfig->ulSoutNumTssts & 0xFF );
2669 pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
2670 pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry = 0;
2671
2672 /* Save the extended Tone detection information.*/
2673 pChanEntry->usExtToneChanIndex = f_pChanIndexConf->usExtToneChanIndex;
2674 pChanEntry->usExtToneMixerIndex = f_pChanIndexConf->usExtToneMixerIndex;
2675 pChanEntry->usExtToneTsiIndex = f_pChanIndexConf->usExtToneTsiIndex;
2676
2677 if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
2678 {
2679 tPOCT6100_API_CHANNEL pExtToneChanEntry;
2680
2681 /* Set the mode of the original channel. He is the channel performing detection on the
2682 SIN port. The extended channel will perform detection on the RIN port.*/
2683 pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_SIN_PORT_MODE;
2684
2685 /* Now, program the associated channel.*/
2686
2687 /* Obtain a pointer to the extended tone detection channel entry. */
2688 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pExtToneChanEntry, f_pChanIndexConf->usExtToneChanIndex );
2689
2690 pExtToneChanEntry->fReserved = TRUE;
2691 pExtToneChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_RIN_PORT_MODE; /* Detect on RIN port.*/
2692 pExtToneChanEntry->usExtToneChanIndex = f_pChanIndexConf->usEchoChanIndex;
2693
2694 pExtToneChanEntry->aulToneConf[ 0 ] = 0;
2695 pExtToneChanEntry->aulToneConf[ 1 ] = 0;
2696
2697 }
2698 else
2699 {
2700 /* No extended tone detection supported.*/
2701 pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED;
2702 }
2703
2704 /*=======================================================================*/
2705
2706 /*=======================================================================*/
2707 /* Store hardware related information.*/
2708 pChanEntry->usRinRoutTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
2709 pChanEntry->usSinSoutTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
2710 pChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
2711 pChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX;
2712
2713 /* We are not being tapped for now. */
2714 pChanEntry->fBeingTapped = FALSE;
2715
2716 pChanEntry->usTapChanIndex = cOCT6100_INVALID_INDEX;
2717 pChanEntry->usTapBridgeIndex = cOCT6100_INVALID_INDEX;
2718
2719 /* The copy event has not yet been created. */
2720 pChanEntry->fCopyEventCreated = FALSE;
2721
2722 pChanEntry->usRinRoutConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
2723 pChanEntry->usSinSoutConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
2724
2725 pChanEntry->usPhasingTsstIndex = f_pChanIndexConf->usPhasingTsstIndex;
2726
2727 pChanEntry->fSinSoutCodecActive = f_pChanIndexConf->fSinSoutCodecActive;
2728 pChanEntry->fRinRoutCodecActive = f_pChanIndexConf->fRinRoutCodecActive;
2729
2730
2731
2732 pChanEntry->usEchoMemIndex = f_pChanIndexConf->usEchoMemIndex;
2733
2734 pChanEntry->usRinTsstIndex = f_pChanIndexConf->usRinTsstIndex;
2735 pChanEntry->usSinTsstIndex = f_pChanIndexConf->usSinTsstIndex;
2736 pChanEntry->usRoutTsstIndex = f_pChanIndexConf->usRoutTsstIndex;
2737 pChanEntry->usSoutTsstIndex = f_pChanIndexConf->usSoutTsstIndex;
2738
2739 pChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
2740 pChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX;
2741
2742 /* Nothing muted for now. */
2743 pChanEntry->usMutedPorts = cOCT6100_CHANNEL_MUTE_PORT_NONE;
2744
2745 /* Set all the GW feature initial value.*/
2746 /* Bridge info */
2747 pChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
2748 pChanEntry->fMute = FALSE;
2749
2750 pChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX;
2751 pChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX;
2752
2753 /* Buffer playout info.*/
2754 pChanEntry->fRinBufPlaying = FALSE;
2755 pChanEntry->fSoutBufPlaying = FALSE;
2756
2757 /* Tone detection state. */
2758 /* This array is configured as follow.*/
2759 /* Index 0 contain event 0 to 31 (msb = event 31) and Index 1 contain index 32 - 55 */
2760 pChanEntry->aulToneConf[ 0 ] = 0;
2761 pChanEntry->aulToneConf[ 1 ] = 0;
2762 pChanEntry->ulLastSSToneDetected = (PTR_TYPE)cOCT6100_INVALID_VALUE;
2763 pChanEntry->ulLastSSToneTimestamp = (PTR_TYPE)cOCT6100_INVALID_VALUE;
2764
2765 /* Initialize the bidirectional flag.*/
2766 pChanEntry->fBiDirChannel = FALSE;
2767
2768 /*=======================================================================*/
2769 /* Init some of the stats.*/
2770
2771 pChanEntry->sMaxERL = cOCT6100_INVALID_SIGNED_STAT_W;
2772 pChanEntry->sMaxERLE = cOCT6100_INVALID_SIGNED_STAT_W;
2773 pChanEntry->usMaxEchoDelay = cOCT6100_INVALID_STAT_W;
2774 pChanEntry->usNumEchoPathChangesOfst = 0;
2775
2776 /*=======================================================================*/
2777
2778 /*=======================================================================*/
2779 /* Update the dependency of the phasing TSST if one is associated to the chanel.*/
2780
2781 if ( f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
2782 {
2783 tPOCT6100_API_PHASING_TSST pPhasingEntry;
2784
2785 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanIndexConf->usPhasingTsstIndex );
2786
2787 pPhasingEntry->usDependencyCnt++;
2788 }
2789 /*=======================================================================*/
2790
2791 /*=======================================================================*/
2792
2793 /* Form handle returned to user. */
2794 *f_pChannelOpen->pulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_pChanIndexConf->usEchoChanIndex;
2795
2796 /* Finally, mark the channel as open. */
2797 pChanEntry->fReserved = TRUE;
2798 pChanEntry->usExtraSinTsiDependencyCnt = 0;
2799
2800 /* Increment the number of channel open.*/
2801 f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels++;
2802
2803 /*=======================================================================*/
2804
2805 return cOCT6100_ERR_OK;
2806 }
2807 #endif
2808
2809
2810
2811
2812
2813
2814 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2815
2816 Function: Oct6100ChannelCloseSer
2817
2818 Description: Closes a echo cancellation channel.
2819
2820 -------------------------------------------------------------------------------
2821 | Argument | Description
2822 -------------------------------------------------------------------------------
2823 f_pApiInstance Pointer to API instance. This memory is used to keep the
2824 present state of the chip and all its resources.
2825
2826 f_pChannelClose Pointer to echo cancellation channel close structure.
2827
2828 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2829 #if !SKIP_Oct6100ChannelCloseSer
2830 UINT32 Oct6100ChannelCloseSer(
2831 IN tPOCT6100_INSTANCE_API f_pApiInstance,
2832 IN tPOCT6100_CHANNEL_CLOSE f_pChannelClose )
2833 {
2834 UINT16 usChannelIndex;
2835
2836
2837 UINT32 ulResult;
2838
2839 /* Verify that all the parameters given match the state of the API. */
2840 ulResult = Oct6100ApiAssertChannelParams( f_pApiInstance,
2841 f_pChannelClose,
2842
2843 &usChannelIndex );
2844 if ( ulResult != cOCT6100_ERR_OK )
2845 return ulResult;
2846
2847 /* Release all resources associated to the echo cancellation channel. */
2848 ulResult = Oct6100ApiInvalidateChannelStructs( f_pApiInstance,
2849
2850 usChannelIndex );
2851 if ( ulResult != cOCT6100_ERR_OK )
2852 return ulResult;
2853
2854 /* Release all resources associated to the echo cancellation channel. */
2855 ulResult = Oct6100ApiReleaseChannelResources( f_pApiInstance, usChannelIndex );
2856 if ( ulResult != cOCT6100_ERR_OK )
2857 return ulResult;
2858
2859 /* Invalidate the handle.*/
2860 f_pChannelClose->ulChannelHndl = cOCT6100_INVALID_HANDLE;
2861
2862 return cOCT6100_ERR_OK;
2863 }
2864 #endif
2865
2866 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2867
2868 Function: Oct6100ApiAssertChannelParams
2869
2870 Description: Validate the handle given by the user and verify the state of
2871 the channel about to be closed.
2872
2873 -------------------------------------------------------------------------------
2874 | Argument | Description
2875 -------------------------------------------------------------------------------
2876 f_pApiInstance Pointer to API instance. This memory is used to keep the
2877 present state of the chip and all its resources.
2878
2879 f_pChannelClose Pointer to echo cancellation channel close structure.
2880 f_pulFpgaChanIndex Pointer to the FPGA channel index associated to this channel.
2881 f_pusChanIndex Pointer to the index of the channel within the API instance.
2882
2883 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2884 #if !SKIP_Oct6100ApiAssertChannelParams
2885 UINT32 Oct6100ApiAssertChannelParams(
2886 IN tPOCT6100_INSTANCE_API f_pApiInstance,
2887 IN tPOCT6100_CHANNEL_CLOSE f_pChannelClose,
2888
2889 IN OUT PUINT16 f_pusChanIndex )
2890 {
2891 tPOCT6100_SHARED_INFO pSharedInfo;
2892 tPOCT6100_API_CHANNEL pChanEntry;
2893 UINT32 ulEntryOpenCnt;
2894
2895 /* Get local pointer(s). */
2896 pSharedInfo = f_pApiInstance->pSharedInfo;
2897
2898 /* Check the provided handle. */
2899 if ( (f_pChannelClose->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
2900 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2901
2902 *f_pusChanIndex = (UINT16)( f_pChannelClose->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
2903 if ( *f_pusChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
2904 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2905
2906 /*=======================================================================*/
2907 /* Get a pointer to the channel's list entry. */
2908
2909 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex )
2910
2911 /* Extract the entry open count from the provided handle. */
2912 ulEntryOpenCnt = ( f_pChannelClose->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
2913
2914 /* Check for errors. */
2915 if ( pChanEntry->fReserved != TRUE )
2916 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
2917 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
2918 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2919 if ( pChanEntry->fBiDirChannel == TRUE )
2920 return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL;
2921
2922 /*=======================================================================*/
2923
2924 /* Check if the channel is bound to a bridge. */
2925 if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
2926 return cOCT6100_ERR_CHANNEL_ACTIVE_DEPENDENCIES;
2927
2928
2929
2930 return cOCT6100_ERR_OK;
2931 }
2932 #endif
2933
2934 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2935
2936 Function: Oct6100ApiInvalidateChannelStructs
2937
2938 Description: Closes a echo cancellation channel.
2939
2940 -------------------------------------------------------------------------------
2941 | Argument | Description
2942 -------------------------------------------------------------------------------
2943 f_pApiInstance Pointer to API instance. This memory is used to keep the
2944 present state of the chip and all its resources.
2945
2946 f_ulFpgaChanIndex Index of the channel within the SCN_PLC FPGA.
2947 f_usChanIndex Index of the channel within the API instance.
2948
2949 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2950 #if !SKIP_Oct6100ApiInvalidateChannelStructs
2951 UINT32 Oct6100ApiInvalidateChannelStructs(
2952 IN tPOCT6100_INSTANCE_API f_pApiInstance,
2953
2954 IN UINT16 f_usChanIndex )
2955 {
2956 tPOCT6100_API_CHANNEL pChanEntry;
2957 tPOCT6100_API_CHANNEL_TDM pTdmConfig;
2958 tPOCT6100_API_TSST_ENTRY pTsstEntry;
2959 tOCT6100_BUFFER_PLAYOUT_STOP BufferPlayoutStop;
2960 tPOCT6100_SHARED_INFO pSharedInfo;
2961 tOCT6100_WRITE_PARAMS WriteParams;
2962 tOCT6100_WRITE_SMEAR_PARAMS SmearParams;
2963 UINT32 ulResult;
2964 UINT16 usCurrentEntry;
2965
2966 /* Obtain local pointer to shared portion of instance. */
2967 pSharedInfo = f_pApiInstance->pSharedInfo;
2968
2969 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
2970
2971 /* Obtain local pointer to the TDM configuration of the channel */
2972 pTdmConfig = &pChanEntry->TdmConfig;
2973
2974 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
2975
2976 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
2977
2978 SmearParams.pProcessContext = f_pApiInstance->pProcessContext;
2979
2980 SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
2981
2982 /* If this channel is currently debugged, automatically close the debug channel. */
2983 if ( ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
2984 && ( pSharedInfo->DebugInfo.usCurrentDebugChanIndex == f_usChanIndex ) )
2985 {
2986 tOCT6100_DEBUG_SELECT_CHANNEL SelectDebugChan;
2987
2988 /* Ensure forward compatibility. */
2989 Oct6100DebugSelectChannelDef( &SelectDebugChan );
2990
2991 /* Set the hot channel to an invalid handle to disable recording. */
2992 SelectDebugChan.ulChannelHndl = cOCT6100_INVALID_HANDLE;
2993
2994 /* Call the serialized fonction. */
2995 ulResult = Oct6100DebugSelectChannelSer( f_pApiInstance, &SelectDebugChan, FALSE );
2996 if ( ulResult != cOCT6100_ERR_OK )
2997 return ulResult;
2998 }
2999
3000 /* Deactivate the TSST control memory if used. */
3001
3002 /* RIN port.*/
3003 if ( pTdmConfig->usRinTimeslot != cOCT6100_UNASSIGNED )
3004 {
3005 /* Deactivate the TSST entry.*/
3006 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usRinTsstIndex * 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
3014 /* SIN port.*/
3015 if ( pTdmConfig->usSinTimeslot != cOCT6100_UNASSIGNED )
3016 {
3017 /* Deactivate the TSST entry.*/
3018 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usSinTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3019 WriteParams.usWriteData = 0x0000;
3020
3021 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3022 if ( ulResult != cOCT6100_ERR_OK )
3023 return ulResult;
3024 }
3025
3026 /*=======================================================================*/
3027 /* ROUT port.*/
3028
3029 if ( pTdmConfig->usRoutTimeslot != cOCT6100_UNASSIGNED )
3030 {
3031 /* Deactivate the TSST entry.*/
3032 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usRoutTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3033 WriteParams.usWriteData = 0x0000;
3034
3035 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3036 if ( ulResult != cOCT6100_ERR_OK )
3037 return ulResult;
3038 }
3039
3040 /* Now the broadcast TSST.*/
3041 usCurrentEntry = pTdmConfig->usRoutBrdcastTsstFirstEntry;
3042 while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3043 {
3044 mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3045
3046 /* Deactivate the TSST entry.*/
3047 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pTsstEntry->usTsstMemoryIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3048 WriteParams.usWriteData = 0x0000;
3049
3050 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3051 if ( ulResult != cOCT6100_ERR_OK )
3052 return ulResult;
3053
3054 /* Move to the next entry.*/
3055 usCurrentEntry = pTsstEntry->usNextEntry;
3056 }
3057 /*=======================================================================*/
3058
3059 /*=======================================================================*/
3060 /* SOUT port.*/
3061
3062 if ( pTdmConfig->usSoutTimeslot != cOCT6100_UNASSIGNED )
3063 {
3064 /* Deactivate the TSST entry.*/
3065 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usSoutTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3066 WriteParams.usWriteData = 0x0000;
3067
3068 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3069 if ( ulResult != cOCT6100_ERR_OK )
3070 return ulResult;
3071 }
3072
3073 /* Now the broadcast TSST.*/
3074 usCurrentEntry = pTdmConfig->usSoutBrdcastTsstFirstEntry;
3075 while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3076 {
3077 mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3078
3079 /* Deactivate the TSST entry.*/
3080 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pTsstEntry->usTsstMemoryIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3081 WriteParams.usWriteData = 0x0000;
3082
3083 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3084 if ( ulResult != cOCT6100_ERR_OK )
3085 return ulResult;
3086
3087 /* Move to the next entry.*/
3088 usCurrentEntry = pTsstEntry->usNextEntry;
3089 }
3090 /*=======================================================================*/
3091
3092
3093 /*------------------------------------------------------------------------------*/
3094 /* Deactivate the ECHO control memory entry.*/
3095
3096 /* Set the input Echo control entry to unused.*/
3097 WriteParams.ulWriteAddress = cOCT6100_ECHO_CONTROL_MEM_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
3098 WriteParams.usWriteData = 0x85FF; /* TSI index 1535 reserved for power-down mode */
3099
3100 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3101 if ( ulResult != cOCT6100_ERR_OK )
3102 return ulResult;
3103
3104 WriteParams.ulWriteAddress += 2;
3105 WriteParams.usWriteData = 0xC5FF; /* TSI index 1535 reserved for power-down mode */
3106
3107 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3108 if ( ulResult != cOCT6100_ERR_OK )
3109 return ulResult;
3110 /*------------------------------------------------------------------------------*/
3111
3112 /*------------------------------------------------------------------------------*/
3113 /* Deactivate the conversion control memories if used. */
3114
3115 if ( pChanEntry->usRinRoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3116 {
3117 /* Rin/Rout stream conversion memory was used */
3118 ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, pChanEntry->usRinRoutConversionMemIndex );
3119 if ( ulResult != cOCT6100_ERR_OK )
3120 return ulResult;
3121 }
3122
3123 if ( pChanEntry->usSinSoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3124 {
3125 /* Sin/Sout stream conversion memory was used */
3126 ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, pChanEntry->usSinSoutConversionMemIndex );
3127 if ( ulResult != cOCT6100_ERR_OK )
3128 return ulResult;
3129 }
3130
3131 /*------------------------------------------------------------------------------*/
3132
3133
3134 /*------------------------------------------------------------------------------*/
3135 /* Clear the silence copy events if they were created. */
3136
3137 /* Unmute the Rin port if it was muted. */
3138 if ( pChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
3139 {
3140 /* Remove the event from the list.*/
3141 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
3142 pChanEntry->usRinSilenceEventIndex,
3143 cOCT6100_EVENT_TYPE_SOUT_COPY );
3144 if ( ulResult != cOCT6100_ERR_OK )
3145 return ulResult;
3146
3147 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usRinSilenceEventIndex );
3148 if ( ulResult != cOCT6100_ERR_OK )
3149 return cOCT6100_ERR_FATAL_DF;
3150
3151 pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
3152 }
3153
3154 /* Unmute the Sin port if it was muted. */
3155 if ( pChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX )
3156 {
3157 /* Remove the event from the list.*/
3158 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
3159 pChanEntry->usSinSilenceEventIndex,
3160 cOCT6100_EVENT_TYPE_SOUT_COPY );
3161 if ( ulResult != cOCT6100_ERR_OK )
3162 return ulResult;
3163
3164 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usSinSilenceEventIndex );
3165 if ( ulResult != cOCT6100_ERR_OK )
3166 return cOCT6100_ERR_FATAL_E0;
3167
3168 pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
3169 }
3170
3171 /*------------------------------------------------------------------------------*/
3172
3173 /* Synch all the buffer playout field.*/
3174 if ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE )
3175 {
3176 Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
3177
3178 BufferPlayoutStop.ulChannelHndl = cOCT6100_INVALID_HANDLE;
3179 BufferPlayoutStop.fStopCleanly = FALSE;
3180
3181 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
3182 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
3183 f_pApiInstance,
3184 &BufferPlayoutStop,
3185 f_usChanIndex,
3186 pChanEntry->usEchoMemIndex
3187
3188 );
3189 if ( ulResult != cOCT6100_ERR_OK )
3190 return ulResult;
3191
3192 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
3193 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
3194 f_pApiInstance,
3195 &BufferPlayoutStop,
3196 f_usChanIndex,
3197 pChanEntry->usEchoMemIndex
3198
3199 );
3200 if ( ulResult != cOCT6100_ERR_OK )
3201 return ulResult;
3202 }
3203
3204
3205
3206
3207
3208 /* Free all resources reserved for extended tone detection.*/
3209 if ( pChanEntry->fEnableExtToneDetection == TRUE )
3210 {
3211 /*------------------------------------------------------------------------------*/
3212 /* Deactivate the ECHO control memory entry of the extended channel.*/
3213
3214 /* Set the input Echo control entry to unused.*/
3215 WriteParams.ulWriteAddress = cOCT6100_ECHO_CONTROL_MEM_BASE + ( pChanEntry->usExtToneChanIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
3216 WriteParams.usWriteData = 0x85FF; /* TSI index 1535 reserved for power-down mode */
3217
3218 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3219 if ( ulResult != cOCT6100_ERR_OK )
3220 return ulResult;
3221
3222 WriteParams.ulWriteAddress += 2;
3223 WriteParams.usWriteData = 0xC5FF; /* TSI index 1535 reserved for power-down mode */
3224
3225 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3226 if ( ulResult != cOCT6100_ERR_OK )
3227 return ulResult;
3228 /*------------------------------------------------------------------------------*/
3229
3230 /*------------------------------------------------------------------------------*/
3231 /* Remove the mixer event used to copy the RIN signal to the SIN port of the extended
3232 channel.*/
3233
3234 /* Clear the Copy event.*/
3235 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usExtToneMixerIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
3236 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
3237
3238 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3239 if ( ulResult != cOCT6100_ERR_OK )
3240 return ulResult;
3241
3242 /* Remove the event from the list.*/
3243 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
3244 pChanEntry->usExtToneMixerIndex,
3245 cOCT6100_EVENT_TYPE_SIN_COPY );
3246 if ( ulResult != cOCT6100_ERR_OK )
3247 return ulResult;
3248
3249 /*------------------------------------------------------------------------------*/
3250
3251 }
3252
3253 /*------------------------------------------------------------------------------*/
3254 /* Reset PGSP */
3255
3256 WriteParams.ulWriteAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
3257 WriteParams.usWriteData = 0x0800;
3258
3259 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3260 if ( ulResult != cOCT6100_ERR_OK )
3261 return ulResult;
3262
3263 /*------------------------------------------------------------------------------*/
3264
3265 /*------------------------------------------------------------------------------*/
3266 /* Clear the mute with feature bit. */
3267
3268 if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
3269 {
3270 ulResult = Oct6100ApiMuteSinWithFeatures( f_pApiInstance, f_usChanIndex, FALSE );
3271 if ( ulResult != cOCT6100_ERR_OK )
3272 return ulResult;
3273 }
3274
3275 /*------------------------------------------------------------------------------*/
3276
3277 /*------------------------------------------------------------------------------*/
3278 /* Clear the VQE memory. */
3279
3280 SmearParams.ulWriteAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst + 0x20;
3281 SmearParams.usWriteData = 0x0000;
3282 SmearParams.ulWriteLength = 2;
3283
3284 mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
3285 if ( ulResult != cOCT6100_ERR_OK )
3286 return ulResult;
3287
3288 /*------------------------------------------------------------------------------*/
3289 /*------------------------------------------------------------------------------*/
3290 /* Clear the NLP memory. */
3291
3292 SmearParams.ulWriteAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst + 0x28;
3293 SmearParams.usWriteData = 0x0000;
3294 SmearParams.ulWriteLength = 2;
3295
3296 mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
3297 if ( ulResult != cOCT6100_ERR_OK )
3298 return ulResult;
3299
3300 /*------------------------------------------------------------------------------*/
3301 /* Clear the AF information memory. */
3302
3303 SmearParams.ulWriteAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( pChanEntry->usEchoMemIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
3304 SmearParams.usWriteData = 0x0000;
3305 SmearParams.ulWriteLength = 12;
3306
3307 mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
3308 if ( ulResult != cOCT6100_ERR_OK )
3309 return ulResult;
3310
3311 /*Reset ALC status*/
3312 WriteParams.ulWriteAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( pChanEntry->usEchoMemIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + 0x3A;
3313 WriteParams.usWriteData = 0x0000;
3314
3315 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3316 if ( ulResult != cOCT6100_ERR_OK )
3317 return ulResult;
3318
3319 /*------------------------------------------------------------------------------*/
3320
3321 return cOCT6100_ERR_OK;
3322 }
3323 #endif
3324
3325 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3326
3327 Function: Oct6100ApiReleaseChannelResources
3328
3329 Description: Release and clear the API entry associated to the echo cancellation channel.
3330
3331 -------------------------------------------------------------------------------
3332 | Argument | Description
3333 -------------------------------------------------------------------------------
3334 f_pApiInstance Pointer to API instance. This memory is used to keep the
3335 present state of the chip and all its resources.
3336
3337 f_usChannelIndex Index of the echo cancellation channel in the API list.
3338
3339 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3340 #if !SKIP_Oct6100ApiReleaseChannelResources
3341 UINT32 Oct6100ApiReleaseChannelResources(
3342 IN tPOCT6100_INSTANCE_API f_pApiInstance,
3343 IN UINT16 f_usChannelIndex )
3344 {
3345 tPOCT6100_SHARED_INFO pSharedInfo;
3346 tPOCT6100_API_CHANNEL pChanEntry;
3347 tPOCT6100_API_CHANNEL_TDM pTdmConfig;
3348 tPOCT6100_API_TSST_ENTRY pTsstEntry;
3349 UINT32 ulResult;
3350 UINT16 usCurrentEntry;
3351 UINT32 ulTimeslot;
3352 UINT32 ulStream;
3353
3354 /* Obtain local pointer to shared portion of instance. */
3355 pSharedInfo = f_pApiInstance->pSharedInfo;
3356
3357 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChannelIndex );
3358
3359 /* Obtain local pointer to the TDM configurationof the channel */
3360 pTdmConfig = &pChanEntry->TdmConfig;
3361
3362 /* Release the two TSI chariot memory entries.*/
3363 ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usRinRoutTsiMemIndex );
3364 if ( ulResult != cOCT6100_ERR_OK )
3365 return cOCT6100_ERR_FATAL_2;
3366
3367 ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usSinSoutTsiMemIndex );
3368 if ( ulResult != cOCT6100_ERR_OK )
3369 return cOCT6100_ERR_FATAL_3;
3370
3371 /* Now release the ECHO channel and control memory entries.*/
3372 ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, f_usChannelIndex );
3373 if ( ulResult != cOCT6100_ERR_OK )
3374 return cOCT6100_ERR_FATAL_4;
3375
3376 /* Release the conversion resources.*/
3377 if ( pChanEntry->usRinRoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3378 {
3379 ulResult = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, pChanEntry->usRinRoutConversionMemIndex );
3380 if ( ulResult != cOCT6100_ERR_OK )
3381 return cOCT6100_ERR_FATAL_B9;
3382
3383 pChanEntry->usRinRoutConversionMemIndex = cOCT6100_INVALID_INDEX;
3384 }
3385
3386 if ( pChanEntry->usSinSoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3387 {
3388 ulResult = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, pChanEntry->usSinSoutConversionMemIndex );
3389 if ( ulResult != cOCT6100_ERR_OK )
3390 return cOCT6100_ERR_FATAL_BA;
3391
3392 pChanEntry->usSinSoutConversionMemIndex = cOCT6100_INVALID_INDEX;
3393 }
3394
3395 /*=========================================================================*/
3396 /* Release the TSST control memory entries if any were reserved.*/
3397 if ( pTdmConfig->usRinTimeslot != cOCT6100_UNASSIGNED)
3398 {
3399 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3400 pTdmConfig->usRinTimeslot,
3401 pTdmConfig->usRinStream,
3402 pTdmConfig->byRinNumTssts,
3403 cOCT6100_INPUT_TSST,
3404 cOCT6100_INVALID_INDEX );
3405 if ( ulResult != cOCT6100_ERR_OK )
3406 return cOCT6100_ERR_FATAL_5;
3407 }
3408
3409 if ( pTdmConfig->usSinTimeslot != cOCT6100_UNASSIGNED)
3410 {
3411 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3412 pTdmConfig->usSinTimeslot,
3413 pTdmConfig->usSinStream,
3414 pTdmConfig->bySinNumTssts,
3415 cOCT6100_INPUT_TSST,
3416 cOCT6100_INVALID_INDEX );
3417 if ( ulResult != cOCT6100_ERR_OK )
3418 return cOCT6100_ERR_FATAL_6;
3419 }
3420
3421 /*=======================================================================*/
3422 /* Release all the TSSTs associated to the ROUT port of this channel. */
3423 if ( pTdmConfig->usRoutTimeslot != cOCT6100_UNASSIGNED)
3424 {
3425 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3426 pTdmConfig->usRoutTimeslot,
3427 pTdmConfig->usRoutStream,
3428 pTdmConfig->byRoutNumTssts,
3429 cOCT6100_OUTPUT_TSST,
3430 cOCT6100_INVALID_INDEX );
3431 if ( ulResult != cOCT6100_ERR_OK )
3432 return cOCT6100_ERR_FATAL_7;
3433 }
3434
3435 /* Now release the Broadcast TSSTs. */
3436 usCurrentEntry = pTdmConfig->usRoutBrdcastTsstFirstEntry;
3437 while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3438 {
3439 mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3440
3441 ulTimeslot = pTsstEntry->usTsstValue >> 5;
3442 ulStream = pTsstEntry->usTsstValue & 0x1F;
3443
3444 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3445 ulTimeslot,
3446 ulStream,
3447 cOCT6100_NUMBER_TSSTS_1,
3448 cOCT6100_OUTPUT_TSST,
3449 usCurrentEntry );
3450 if ( ulResult != cOCT6100_ERR_OK )
3451 return cOCT6100_ERR_FATAL_8;
3452
3453 /* Move to the next entry.*/
3454 usCurrentEntry = pTsstEntry->usNextEntry;
3455
3456 /* Invalidate the current entry.*/
3457 pTsstEntry->usTsstMemoryIndex = 0xFFFF;
3458 pTsstEntry->usTsstValue = 0xFFFF;
3459 pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
3460 }
3461
3462 /*=======================================================================*/
3463
3464
3465 /*=======================================================================*/
3466 /* Release all the TSSTs associated to the SOUT port of this channel. */
3467 if ( pTdmConfig->usSoutTimeslot != cOCT6100_UNASSIGNED)
3468 {
3469 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3470 pTdmConfig->usSoutTimeslot,
3471 pTdmConfig->usSoutStream,
3472 pTdmConfig->bySoutNumTssts,
3473 cOCT6100_OUTPUT_TSST,
3474 cOCT6100_INVALID_INDEX );
3475 if ( ulResult != cOCT6100_ERR_OK )
3476 return cOCT6100_ERR_FATAL_9;
3477 }
3478
3479 /* Now release the Broadcast TSSTs. */
3480 usCurrentEntry = pTdmConfig->usSoutBrdcastTsstFirstEntry;
3481 while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3482 {
3483 mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3484
3485 ulTimeslot = pTsstEntry->usTsstValue >> 5;
3486 ulStream = pTsstEntry->usTsstValue & 0x1F;
3487
3488 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3489 ulTimeslot,
3490 ulStream,
3491 cOCT6100_NUMBER_TSSTS_1,
3492 cOCT6100_OUTPUT_TSST,
3493 usCurrentEntry );
3494 if ( ulResult != cOCT6100_ERR_OK )
3495 return cOCT6100_ERR_FATAL_A;
3496
3497 /* Move to the next entry.*/
3498 usCurrentEntry = pTsstEntry->usNextEntry;
3499
3500 /* Invalidate the current entry.*/
3501 pTsstEntry->usTsstMemoryIndex = 0xFFFF;
3502 pTsstEntry->usTsstValue = 0xFFFF;
3503 pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
3504 }
3505 /*=======================================================================*/
3506
3507 /*=======================================================================*/
3508 /* Update the dependency of the phasing TSST if one is associated to the chanel.*/
3509
3510 if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
3511 {
3512 tPOCT6100_API_PHASING_TSST pPhasingEntry;
3513
3514 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, pChanEntry->usPhasingTsstIndex );
3515
3516 pPhasingEntry->usDependencyCnt--;
3517 }
3518 /*=======================================================================*/
3519
3520
3521 /*=======================================================================*/
3522 /* Release any resources reserved for the extended tone detection.*/
3523
3524 if ( pChanEntry->fEnableExtToneDetection == TRUE )
3525 {
3526 tPOCT6100_API_CHANNEL pExtToneChanEntry;
3527
3528 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pExtToneChanEntry, pChanEntry->usExtToneChanIndex );
3529
3530 /* Release the ECHO channel and control memory entries.*/
3531 ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, pChanEntry->usExtToneChanIndex );
3532 if ( ulResult != cOCT6100_ERR_OK )
3533 return cOCT6100_ERR_FATAL_C1;
3534
3535 ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usExtToneTsiIndex );
3536 if ( ulResult != cOCT6100_ERR_OK )
3537 return cOCT6100_ERR_FATAL_C2;
3538
3539 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usExtToneMixerIndex );
3540 if ( ulResult != cOCT6100_ERR_OK )
3541 return cOCT6100_ERR_FATAL_C3;
3542
3543 /* Now release the channel entry */
3544 pExtToneChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED;
3545 pExtToneChanEntry->fReserved = FALSE;
3546
3547 /* Set the current entry to disable, just in case.*/
3548 pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED;
3549 }
3550 /*=======================================================================*/
3551
3552
3553 /*=======================================================================*/
3554 /* Update the channel's list entry. */
3555
3556 /* Clear the NLP dword array. */
3557 Oct6100UserMemSet( pChanEntry->aulNlpConfDword, 0, sizeof( pChanEntry->aulNlpConfDword ) );
3558
3559 /* Clear the echo operation mode. */
3560 pChanEntry->byEchoOperationMode = cOCT6100_ECHO_OP_MODE_POWER_DOWN;
3561
3562 /* Mark the channel as closed. */
3563 pChanEntry->fReserved = FALSE;
3564 pChanEntry->byEntryOpenCnt++;
3565
3566 /* Reset the port, the bridge and BidirInfo */
3567 pChanEntry->usMutedPorts = cOCT6100_CHANNEL_MUTE_PORT_NONE;
3568 pChanEntry->fBiDirChannel = FALSE;
3569 pChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
3570
3571 /* Decrement the number of channel open.*/
3572 f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels--;
3573
3574 /*=======================================================================*/
3575
3576 return cOCT6100_ERR_OK;
3577
3578 }
3579 #endif
3580
3581
3582
3583 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3584
3585 Function: Oct6100ChannelModifySer
3586
3587 Description: Modify an echo cancellation channel.
3588
3589 -------------------------------------------------------------------------------
3590 | Argument | Description
3591 -------------------------------------------------------------------------------
3592 f_pApiInstance Pointer to API instance. This memory is used to keep the
3593 present state of the chip and all its resources.
3594
3595 f_pChannelModify Pointer to channel configuration structure. The handle
3596 identifying the buffer in all future function calls is
3597 returned in this structure.
3598
3599 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3600 #if !SKIP_Oct6100ChannelModifySer
3601 UINT32 Oct6100ChannelModifySer(
3602 IN tPOCT6100_INSTANCE_API f_pApiInstance,
3603 IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify )
3604 {
3605 UINT16 usChanIndex;
3606 UINT32 ulResult;
3607 UINT16 usNewRinTsstIndex;
3608 UINT16 usNewSinTsstIndex;
3609 UINT16 usNewRoutTsstIndex;
3610 UINT16 usNewSoutTsstIndex;
3611 UINT8 fSinSoutCodecActive = FALSE;
3612 UINT8 fRinRoutCodecActive = FALSE;
3613 UINT16 usNewPhasingTsstIndex;
3614 tOCT6100_CHANNEL_OPEN *pTempChanOpen;
3615
3616 /* We don't want this 290 byte structure on the stack */
3617 pTempChanOpen = kmalloc(sizeof(*pTempChanOpen), GFP_ATOMIC);
3618 if (!pTempChanOpen)
3619 return cOCT6100_ERR_FATAL_0;
3620
3621 /* Check the user's configuration of the echo cancellation channel for errors. */
3622 ulResult = Oct6100ApiCheckChannelModify( f_pApiInstance,
3623 f_pChannelModify,
3624 pTempChanOpen,
3625 &usNewPhasingTsstIndex,
3626 &usChanIndex );
3627 if ( ulResult != cOCT6100_ERR_OK )
3628 goto out;
3629
3630 /* Reserve all resources needed by the echo cancellation channel. */
3631 ulResult = Oct6100ApiModifyChannelResources( f_pApiInstance,
3632 f_pChannelModify,
3633 usChanIndex,
3634 &usNewRinTsstIndex,
3635 &usNewSinTsstIndex,
3636 &usNewRoutTsstIndex,
3637 &usNewSoutTsstIndex );
3638 if ( ulResult != cOCT6100_ERR_OK )
3639 goto out;
3640
3641 /* Write all necessary structures to activate the echo cancellation channel. */
3642 ulResult = Oct6100ApiModifyChannelStructs( f_pApiInstance,
3643 f_pChannelModify,
3644 pTempChanOpen,
3645 usChanIndex,
3646 usNewPhasingTsstIndex,
3647 &fSinSoutCodecActive,
3648 &fRinRoutCodecActive,
3649 usNewRinTsstIndex,
3650 usNewSinTsstIndex,
3651 usNewRoutTsstIndex,
3652 usNewSoutTsstIndex );
3653 if ( ulResult != cOCT6100_ERR_OK )
3654 goto out;
3655
3656 /* Update the new echo cancellation channels's entry in the ECHO channel list. */
3657 ulResult = Oct6100ApiModifyChannelEntry( f_pApiInstance,
3658 f_pChannelModify,
3659 pTempChanOpen,
3660 usChanIndex,
3661 usNewPhasingTsstIndex,
3662 fSinSoutCodecActive,
3663 fRinRoutCodecActive,
3664 usNewRinTsstIndex,
3665 usNewSinTsstIndex,
3666 usNewRoutTsstIndex,
3667 usNewSoutTsstIndex );
3668 out:
3669 kfree(pTempChanOpen);
3670
3671 return ulResult;
3672 }
3673 #endif
3674
3675 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3676
3677 Function: Oct6100ApiCheckChannelModify
3678
3679 Description: Checks the user's echo cancellation channel modify structure for errors.
3680
3681 -------------------------------------------------------------------------------
3682 | Argument | Description
3683 -------------------------------------------------------------------------------
3684 f_pApiInstance Pointer to API instance. This memory is used to keep the
3685 present state of the chip and all its resources.
3686
3687 f_pChannelModify Pointer to echo cancellation channel modify structure.
3688 f_pTempChanOpen Pointer to a channel open structure.
3689 f_pusNewPhasingTsstIndex Pointer to a new phasing TSST index within the API instance.
3690 f_pusChanIndex Pointer to the channel index within the API instance channel list
3691
3692 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3693 #if !SKIP_Oct6100ApiCheckChannelModify
3694 UINT32 Oct6100ApiCheckChannelModify(
3695 IN tPOCT6100_INSTANCE_API f_pApiInstance,
3696 IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify,
3697 IN tPOCT6100_CHANNEL_OPEN f_pTempChanOpen,
3698 OUT PUINT16 f_pusNewPhasingTsstIndex,
3699 OUT PUINT16 f_pusChanIndex )
3700 {
3701 tPOCT6100_API_CHANNEL pChanEntry;
3702 UINT32 ulResult;
3703 UINT32 ulEntryOpenCnt;
3704 UINT32 ulDecoderNumTssts;
3705
3706 /* Check the provided handle. */
3707 if ( (f_pChannelModify->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
3708 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
3709
3710 *f_pusChanIndex = (UINT16)( f_pChannelModify->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
3711 if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
3712 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
3713
3714 /*=======================================================================*/
3715 /* Get a pointer to the channel's list entry. */
3716
3717 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
3718
3719 /* Extract the entry open count from the provided handle. */
3720 ulEntryOpenCnt = ( f_pChannelModify->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
3721
3722 /* Check for errors. */
3723 if ( pChanEntry->fReserved != TRUE )
3724 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
3725 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
3726 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
3727
3728 /*=======================================================================*/
3729
3730
3731 /*=======================================================================*/
3732 /* Check the general modify parameters. */
3733
3734 if ( f_pChannelModify->ulEchoOperationMode != cOCT6100_KEEP_PREVIOUS_SETTING &&
3735 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NORMAL &&
3736 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_FREEZE &&
3737 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET &&
3738 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN &&
3739 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL &&
3740 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION &&
3741 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
3742 return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE;
3743
3744 /* Check the 2100Hz echo disabling configuration.*/
3745 if ( f_pChannelModify->fEnableToneDisabler != cOCT6100_KEEP_PREVIOUS_SETTING &&
3746 f_pChannelModify->fEnableToneDisabler != TRUE &&
3747 f_pChannelModify->fEnableToneDisabler != FALSE )
3748 return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ENABLE;
3749
3750 /* Check the disable tone detection flag. */
3751 if ( f_pChannelModify->fDisableToneDetection != TRUE &&
3752 f_pChannelModify->fDisableToneDetection != FALSE )
3753 return cOCT6100_ERR_CHANNEL_DISABLE_TONE_DETECTION;
3754
3755 /* Check the stop buffer playout flag. */
3756 if ( f_pChannelModify->fStopBufferPlayout != TRUE &&
3757 f_pChannelModify->fStopBufferPlayout != FALSE )
3758 return cOCT6100_ERR_CHANNEL_STOP_BUFFER_PLAYOUT;
3759
3760 /* Check the remove conference bridge participant flag. */
3761 if ( f_pChannelModify->fRemoveConfBridgeParticipant != TRUE &&
3762 f_pChannelModify->fRemoveConfBridgeParticipant != FALSE )
3763 return cOCT6100_ERR_CHANNEL_REMOVE_CONF_BRIDGE_PARTICIPANT;
3764
3765 /* Check the remove broadcast timeslots flag. */
3766 if ( f_pChannelModify->fRemoveBroadcastTssts != TRUE &&
3767 f_pChannelModify->fRemoveBroadcastTssts != FALSE )
3768 return cOCT6100_ERR_CHANNEL_REMOVE_BROADCAST_TSSTS;
3769
3770 if ( f_pChannelModify->fCodecConfigModified != TRUE &&
3771 f_pChannelModify->fCodecConfigModified != FALSE )
3772 return cOCT6100_ERR_CHANNEL_MODIFY_CODEC_CONFIG;
3773
3774 if ( f_pChannelModify->fVqeConfigModified != TRUE &&
3775 f_pChannelModify->fVqeConfigModified != FALSE )
3776 return cOCT6100_ERR_CHANNEL_MODIFY_VQE_CONFIG;
3777
3778 if ( f_pChannelModify->fTdmConfigModified != TRUE &&
3779 f_pChannelModify->fTdmConfigModified != FALSE )
3780 return cOCT6100_ERR_CHANNEL_MODIFY_TDM_CONFIG;
3781
3782 /*=======================================================================*/
3783
3784 /*=======================================================================*/
3785 /* Verify if any law change was requested. If so reprogram all structures.*/
3786
3787 if (( f_pChannelModify->fTdmConfigModified == TRUE ) &&
3788 ( f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
3789 f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
3790 f_pChannelModify->TdmConfig.ulRoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
3791 f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ))
3792 {
3793 f_pChannelModify->fVqeConfigModified = TRUE;
3794 f_pChannelModify->fCodecConfigModified = TRUE;
3795 }
3796 /*=======================================================================*/
3797
3798 ulResult = Oct6100ApiUpdateOpenStruct( f_pApiInstance, f_pChannelModify, f_pTempChanOpen, pChanEntry );
3799 if ( ulResult != cOCT6100_ERR_OK )
3800 return ulResult;
3801
3802 /* All further check will now be performed using the TempOpenChan structure in order
3803 to reuse the checks written for the open channel structure.*/
3804
3805
3806
3807 /* Check the TDM config.*/
3808 if ( f_pChannelModify->fTdmConfigModified == TRUE )
3809 {
3810 tPOCT6100_CHANNEL_MODIFY_TDM pModifyTdm;
3811 tPOCT6100_CHANNEL_OPEN_TDM pOpenTdm;
3812
3813 pModifyTdm = &f_pChannelModify->TdmConfig;
3814 pOpenTdm = &f_pTempChanOpen->TdmConfig;
3815
3816 ulResult = Oct6100ApiCheckTdmConfig( f_pApiInstance,
3817 pOpenTdm );
3818 if ( ulResult != cOCT6100_ERR_OK )
3819 return ulResult;
3820
3821 /* Check if that Stream and Timeslot values are valid.*/
3822
3823 /* Check the RIN port.*/
3824 if ( f_pChannelModify->TdmConfig.ulRinStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3825 f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3826 return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
3827
3828 if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3829 f_pChannelModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3830 return cOCT6100_ERR_CHANNEL_RIN_STREAM;
3831
3832 if ( pChanEntry->fBeingTapped == TRUE )
3833 {
3834 /* Check that the Rin stream + timeslot are not being assigned. */
3835 if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING )
3836 {
3837 if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_UNASSIGNED )
3838 return cOCT6100_ERR_CHANNEL_RIN_STREAM;
3839
3840 if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3841 return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
3842 }
3843 }
3844
3845 /* Check the SIN port.*/
3846 if ( f_pChannelModify->TdmConfig.ulSinStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3847 f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3848 return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT;
3849
3850 if ( f_pChannelModify->TdmConfig.ulSinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3851 f_pChannelModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3852 return cOCT6100_ERR_CHANNEL_SIN_STREAM;
3853
3854 /* Check the ROUT port.*/
3855 if ( f_pChannelModify->TdmConfig.ulRoutStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3856 f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3857 return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT;
3858
3859 if ( f_pChannelModify->TdmConfig.ulRoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3860 f_pChannelModify->TdmConfig.ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3861 return cOCT6100_ERR_CHANNEL_ROUT_STREAM;
3862
3863 /* Check the SOUT port.*/
3864 if ( f_pChannelModify->TdmConfig.ulSoutStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3865 f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3866 return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
3867
3868 if ( f_pChannelModify->TdmConfig.ulSoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3869 f_pChannelModify->TdmConfig.ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3870 return cOCT6100_ERR_CHANNEL_SOUT_STREAM;
3871
3872 /* Verify if the channel is currently part of a bidirectional channel, and if */
3873 /* so perform the required checks. */
3874 if ( pChanEntry->fBiDirChannel == TRUE )
3875 {
3876 /* Check the ports that must remain unassigned.*/
3877 if ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3878 return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
3879 if ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED )
3880 return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
3881
3882 /* Check that no PCM law change is requested.*/
3883 if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
3884 return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
3885 if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
3886 return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
3887 }
3888
3889 /* If this channel is on a conference bridge, a few more things must be checked. */
3890 if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
3891 {
3892 /* If conferencing, law conversion cannot be applied. */
3893 /* This check is done only if both input and output ports are assigned. */
3894 if ( ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3895 && ( f_pTempChanOpen->TdmConfig.ulRoutTimeslot != cOCT6100_UNASSIGNED ) )
3896 {
3897 /* Laws must be the same! */
3898 if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
3899 return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
3900 }
3901
3902 /* Check for Sin. */
3903 if ( ( f_pTempChanOpen->TdmConfig.ulSinTimeslot != cOCT6100_UNASSIGNED )
3904 && ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED ) )
3905 {
3906 /* Laws must be the same! */
3907 if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
3908 return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
3909 }
3910
3911 /* Check if ADPCM is requested. */
3912 if ( f_pTempChanOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING &&
3913 f_pTempChanOpen->CodecConfig.ulEncodingRate != cOCT6100_G711_64KBPS )
3914 {
3915 /* No ADPCM in a conference bridge! */
3916 return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
3917 }
3918
3919 if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING &&
3920 f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS )
3921 {
3922 /* No ADPCM in a conference bridge! */
3923 return cOCT6100_ERR_CHANNEL_DECODING_RATE;
3924 }
3925 }
3926
3927 if ( f_pTempChanOpen->CodecConfig.ulEncoderPort == cOCT6100_NO_ENCODING ||
3928 f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_NO_DECODING )
3929 {
3930 /* Make sure no law conversion is attempted since it is not supported by the device.*/
3931 if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
3932 return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
3933 if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
3934 return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
3935 }
3936
3937 if ( pChanEntry->fEnableExtToneDetection == TRUE &&
3938 f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3939 return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT;
3940
3941 /* A few special checks must be done if the configuration is to be applied */
3942 /* to all opened channels. */
3943 if ( f_pChannelModify->fApplyToAllChannels == TRUE )
3944 {
3945 /* When the configuration to be applied is for all channels, */
3946 /* check that the stream and timeslot parameters are not being assigned. */
3947
3948 /* Check the Rout port. */
3949 if ( f_pChannelModify->TdmConfig.ulRoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3950 f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3951 {
3952 /* Check that the Rout ports is being unassigned. */
3953 if ( f_pTempChanOpen->TdmConfig.ulRoutStream != cOCT6100_UNASSIGNED )
3954 return cOCT6100_ERR_CHANNEL_ROUT_STREAM_UNASSIGN;
3955 if ( f_pTempChanOpen->TdmConfig.ulRoutTimeslot != cOCT6100_UNASSIGNED )
3956 return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT_UNASSIGN;
3957 }
3958
3959 /* Check the Rin port. */
3960 if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3961 f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3962 {
3963 /* Check that the Rin ports is being unassigned. */
3964 if ( f_pTempChanOpen->TdmConfig.ulRinStream != cOCT6100_UNASSIGNED )
3965 return cOCT6100_ERR_CHANNEL_RIN_STREAM_UNASSIGN;
3966 if ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3967 return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT_UNASSIGN;
3968 }
3969
3970 /* Check the Sout port. */
3971 if ( f_pChannelModify->TdmConfig.ulSoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3972 f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3973 {
3974 /* Check that the Sout ports is being unassigned. */
3975 if ( f_pTempChanOpen->TdmConfig.ulSoutStream != cOCT6100_UNASSIGNED )
3976 return cOCT6100_ERR_CHANNEL_SOUT_STREAM_UNASSIGN;
3977 if ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED )
3978 return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT_UNASSIGN;
3979 }
3980
3981 /* Check the Sin port. */
3982 if ( f_pChannelModify->TdmConfig.ulSinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3983 f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3984 {
3985 /* Check that the Sin ports is being unassigned. */
3986 if ( f_pTempChanOpen->TdmConfig.ulSinStream != cOCT6100_UNASSIGNED )
3987 return cOCT6100_ERR_CHANNEL_SIN_STREAM_UNASSIGN;
3988 if ( f_pTempChanOpen->TdmConfig.ulSinTimeslot != cOCT6100_UNASSIGNED )
3989 return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT_UNASSIGN;
3990 }
3991 }
3992 }
3993
3994 /* Check the VQE config.*/
3995 if ( f_pChannelModify->fVqeConfigModified == TRUE )
3996 {
3997 ulResult = Oct6100ApiCheckVqeConfig( f_pApiInstance,
3998 &f_pTempChanOpen->VqeConfig,
3999 f_pTempChanOpen->fEnableToneDisabler );
4000 if ( ulResult != cOCT6100_ERR_OK )
4001 return ulResult;
4002 }
4003
4004 /* Verify if the echo operation mode selected can be applied. */
4005 if ( ( f_pTempChanOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
4006 && ( f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE ) )
4007 return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
4008
4009 if ( ( f_pTempChanOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
4010 && ( f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE ) )
4011 return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
4012
4013 /* Comfort noise must be activated for speech recognition mode to work. */
4014 if ( ( f_pTempChanOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
4015 && ( f_pTempChanOpen->VqeConfig.ulComfortNoiseMode == cOCT6100_COMFORT_NOISE_OFF ) )
4016 return cOCT6100_ERR_CHANNEL_COMFORT_NOISE_REQUIRED;
4017
4018 /* Check the Codec config.*/
4019 if ( f_pChannelModify->fCodecConfigModified == TRUE )
4020 {
4021 if ( f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
4022 ulDecoderNumTssts = f_pTempChanOpen->TdmConfig.ulRinNumTssts;
4023 else /* f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
4024 ulDecoderNumTssts = f_pTempChanOpen->TdmConfig.ulSinNumTssts;
4025
4026 ulResult = Oct6100ApiCheckCodecConfig( f_pApiInstance,
4027 &f_pTempChanOpen->CodecConfig,
4028 ulDecoderNumTssts,
4029 f_pusNewPhasingTsstIndex );
4030 if ( ulResult != cOCT6100_ERR_OK )
4031 return ulResult;
4032
4033
4034
4035 /* make sure that if silence suppression is activated, the NLP is enabled.*/
4036 if ( f_pTempChanOpen->CodecConfig.fEnableSilenceSuppression == TRUE && f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE )
4037 return cOCT6100_ERR_CHANNEL_SIL_SUP_NLP_MUST_BE_ENABLED;
4038
4039 /* Verify if the channel is currently part of a bidirectional channel, and if so perform
4040 the required checks.*/
4041 if ( pChanEntry->fBiDirChannel == TRUE )
4042 {
4043 /* Check the ports that must remain unassigned.*/
4044 if ( f_pTempChanOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING &&
4045 f_pTempChanOpen->CodecConfig.ulEncodingRate != cOCT6100_G711_64KBPS )
4046 return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
4047
4048 if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING &&
4049 f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS )
4050 return cOCT6100_ERR_CHANNEL_DECODING_RATE;
4051 }
4052
4053 }
4054 /*=======================================================================*/
4055
4056 return cOCT6100_ERR_OK;
4057 }
4058 #endif
4059
4060 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4061
4062 Function: Oct6100ApiModifyChannelResources
4063
4064 Description: Reserves any new resources needed for the channel
4065 -------------------------------------------------------------------------------
4066 | Argument | Description
4067 -------------------------------------------------------------------------------
4068 f_pApiInstance Pointer to API instance. This memory is used to keep the
4069 present state of the chip and all its resources.
4070
4071 f_pChannelModify Pointer to echo cancellation channel configuration structure.
4072 f_usChanIndex Allocated entry in ECHO channel list.
4073
4074 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4075 #if !SKIP_Oct6100ApiModifyChannelResources
4076 UINT32 Oct6100ApiModifyChannelResources(
4077 IN tPOCT6100_INSTANCE_API f_pApiInstance,
4078 IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify,
4079 IN UINT16 f_usChanIndex,
4080 OUT PUINT16 f_pusNewRinTsstIndex,
4081 OUT PUINT16 f_pusNewSinTsstIndex,
4082 OUT PUINT16 f_pusNewRoutTsstIndex,
4083 OUT PUINT16 f_pusNewSoutTsstIndex )
4084 {
4085 tPOCT6100_API_CHANNEL pChanEntry;
4086 tPOCT6100_SHARED_INFO pSharedInfo;
4087
4088 tPOCT6100_API_CHANNEL_TDM pApiTdmConf;
4089 tPOCT6100_CHANNEL_MODIFY_TDM pModifyTdmConf;
4090
4091 UINT32 ulResult = cOCT6100_ERR_OK;
4092 UINT32 ulTempVar = cOCT6100_ERR_OK;
4093 UINT32 ulFreeMixerEventCnt;
4094
4095 BOOL fRinReleased = FALSE;
4096 BOOL fSinReleased = FALSE;
4097 BOOL fRoutReleased = FALSE;
4098 BOOL fSoutReleased = FALSE;
4099
4100 BOOL fRinReserved = FALSE;
4101 BOOL fSinReserved = FALSE;
4102 BOOL fRoutReserved = FALSE;
4103 BOOL fSoutReserved = FALSE;
4104
4105 BOOL fReserveRin = FALSE;
4106 BOOL fReserveSin = FALSE;
4107 BOOL fReserveRout = FALSE;
4108 BOOL fReserveSout = FALSE;
4109
4110 BOOL fRinRoutConversionMemReserved = FALSE;
4111 BOOL fSinSoutConversionMemReserved = FALSE;
4112
4113
4114 UINT32 ulRinNumTssts = 1;
4115 UINT32 ulSinNumTssts = 1;
4116 UINT32 ulRoutNumTssts = 1;
4117 UINT32 ulSoutNumTssts = 1;
4118
4119 /* Obtain local pointer to shared portion of instance. */
4120 pSharedInfo = f_pApiInstance->pSharedInfo;
4121
4122 /* Obtain local pointer to the TDM configuration structure of the tPOCT6100_CHANNEL_MODIFY structure. */
4123 pModifyTdmConf = &f_pChannelModify->TdmConfig;
4124
4125 /*=======================================================================*/
4126 /* Get a pointer to the channel's list entry. */
4127 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
4128
4129 /* Obtain local pointer to the TDM configuration structure of the tPOCT6100_API_CHANNEL structure. */
4130 pApiTdmConf = &pChanEntry->TdmConfig;
4131
4132 /*===============================================================================*/
4133 /* Modify TSST resources if required.*/
4134 if ( f_pChannelModify->fTdmConfigModified == TRUE )
4135 {
4136 /* First release any entry that need to be released.*/
4137 if ( ( pModifyTdmConf->ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4138 || ( pModifyTdmConf->ulRinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4139 )
4140 {
4141 if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4142 {
4143 /* Release the previously reserved entry.*/
4144 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
4145 pChanEntry->TdmConfig.usRinTimeslot,
4146 pChanEntry->TdmConfig.usRinStream,
4147 pChanEntry->TdmConfig.byRinNumTssts,
4148 cOCT6100_INPUT_TSST,
4149 cOCT6100_INVALID_INDEX );
4150 if ( ulResult == cOCT6100_ERR_OK )
4151 {
4152 fRinReleased = TRUE;
4153 }
4154 }
4155
4156 fReserveRin = TRUE;
4157 }
4158
4159 /* Release SIN port.*/
4160 if ( ( ulResult == cOCT6100_ERR_OK )
4161 && ( ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4162 || ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4163 ) )
4164 {
4165 if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4166 {
4167 /* Release the previously reserved entry.*/
4168 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
4169 pChanEntry->TdmConfig.usSinTimeslot,
4170 pChanEntry->TdmConfig.usSinStream,
4171 pChanEntry->TdmConfig.bySinNumTssts,
4172 cOCT6100_INPUT_TSST,
4173 cOCT6100_INVALID_INDEX );
4174 if ( ulResult == cOCT6100_ERR_OK )
4175 {
4176 fSinReleased = TRUE;
4177 }
4178 }
4179
4180 fReserveSin = TRUE;
4181 }
4182
4183 /* Release ROUT port.*/
4184 if ( ( ulResult == cOCT6100_ERR_OK )
4185 && ( ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4186 || ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4187 ) )
4188 {
4189 if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
4190 {
4191 /* Release the previously reserved entry.*/
4192 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
4193 pChanEntry->TdmConfig.usRoutTimeslot,
4194 pChanEntry->TdmConfig.usRoutStream,
4195 pChanEntry->TdmConfig.byRoutNumTssts,
4196 cOCT6100_OUTPUT_TSST,
4197 cOCT6100_INVALID_INDEX );
4198 if ( ulResult == cOCT6100_ERR_OK )
4199 {
4200 fRoutReleased = TRUE;
4201 }
4202 }
4203
4204 fReserveRout = TRUE;
4205 }
4206
4207 /* Release the SOUT port.*/
4208 if ( ( ulResult == cOCT6100_ERR_OK )
4209 && ( ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4210 || ( pModifyTdmConf->ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4211 ) )
4212 {
4213 if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
4214 {
4215 /* Release the previously reserved entry.*/
4216 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
4217 pChanEntry->TdmConfig.usSoutTimeslot,
4218 pChanEntry->TdmConfig.usSoutStream,
4219 pChanEntry->TdmConfig.bySoutNumTssts,
4220 cOCT6100_OUTPUT_TSST,
4221 cOCT6100_INVALID_INDEX );
4222 if ( ulResult == cOCT6100_ERR_OK )
4223 {
4224 fSoutReleased = TRUE;
4225 }
4226 }
4227
4228 fReserveSout = TRUE;
4229 }
4230
4231 /* Now reserve any new entry required.*/
4232
4233 /* Modify RIN port.*/
4234 if ( ( fReserveRin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4235 {
4236 if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_UNASSIGNED )
4237 {
4238 /* Check what number of TSSTs should be reserved this time. */
4239 if ( pModifyTdmConf->ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4240 {
4241 ulRinNumTssts = pApiTdmConf->byRinNumTssts;
4242 }
4243 else /* if ( pModifyTdmConf->ulRinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4244 {
4245 /* New number of TSSTs. */
4246 ulRinNumTssts = pModifyTdmConf->ulRinNumTssts;
4247 }
4248
4249 if ( pModifyTdmConf->ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4250 {
4251 /* Reserve the new number of TSSTs. */
4252 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4253 pApiTdmConf->usRinTimeslot,
4254 pApiTdmConf->usRinStream,
4255 ulRinNumTssts,
4256 cOCT6100_INPUT_TSST,
4257 f_pusNewRinTsstIndex,
4258 NULL );
4259 }
4260 else /* if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4261 {
4262 /* Reserve the new TSST.*/
4263 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4264 pModifyTdmConf->ulRinTimeslot,
4265 pModifyTdmConf->ulRinStream,
4266 ulRinNumTssts,
4267 cOCT6100_INPUT_TSST,
4268 f_pusNewRinTsstIndex,
4269 NULL );
4270 if ( ulResult == cOCT6100_ERR_OK )
4271 {
4272 fRinReserved = TRUE;
4273 }
4274 }
4275 }
4276 else
4277 {
4278 *f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX;
4279 }
4280 }
4281 else
4282 {
4283 *f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX;
4284 }
4285
4286 /* Modify SIN port.*/
4287 if ( ( fReserveSin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4288 {
4289 if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_UNASSIGNED )
4290 {
4291 /* Check what number of TSSTs should be reserved this time. */
4292 if ( pModifyTdmConf->ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4293 {
4294 ulSinNumTssts = pApiTdmConf->bySinNumTssts;
4295 }
4296 else /* if ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4297 {
4298 /* New number of TSSTs. */
4299 ulSinNumTssts = pModifyTdmConf->ulSinNumTssts;
4300 }
4301
4302 if ( pModifyTdmConf->ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4303 {
4304 /* Reserve the new number of TSSTs. */
4305 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4306 pApiTdmConf->usSinTimeslot,
4307 pApiTdmConf->usSinStream,
4308 ulSinNumTssts,
4309 cOCT6100_INPUT_TSST,
4310 f_pusNewSinTsstIndex,
4311 NULL );
4312 }
4313 else /* if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4314 {
4315 /* Reserve the new TSST.*/
4316 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4317 pModifyTdmConf->ulSinTimeslot,
4318 pModifyTdmConf->ulSinStream,
4319 ulSinNumTssts,
4320 cOCT6100_INPUT_TSST,
4321 f_pusNewSinTsstIndex,
4322 NULL );
4323 if ( ulResult == cOCT6100_ERR_OK )
4324 {
4325 fSinReserved = TRUE;
4326 }
4327 }
4328 }
4329 else
4330 {
4331 *f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX;
4332 }
4333 }
4334 else
4335 {
4336 *f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX;
4337 }
4338
4339 /* Modify ROUT port.*/
4340 if ( ( fReserveRout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4341 {
4342 if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_UNASSIGNED )
4343 {
4344 /* Check what number of TSSTs should be reserved this time. */
4345 if ( pModifyTdmConf->ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4346 {
4347 ulRoutNumTssts = pApiTdmConf->byRoutNumTssts;
4348 }
4349 else /* if ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4350 {
4351 /* New number of TSSTs. */
4352 ulRoutNumTssts = pModifyTdmConf->ulRoutNumTssts;
4353 }
4354
4355 if ( pModifyTdmConf->ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4356 {
4357 /* Reserve the new number of TSSTs. */
4358 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4359 pApiTdmConf->usRoutTimeslot,
4360 pApiTdmConf->usRoutStream,
4361 ulRoutNumTssts,
4362 cOCT6100_OUTPUT_TSST,
4363 f_pusNewRoutTsstIndex,
4364 NULL );
4365 }
4366 else /* if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4367 {
4368 /* Reserve the new TSST.*/
4369 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4370 pModifyTdmConf->ulRoutTimeslot,
4371 pModifyTdmConf->ulRoutStream,
4372 ulRoutNumTssts,
4373 cOCT6100_OUTPUT_TSST,
4374 f_pusNewRoutTsstIndex,
4375 NULL );
4376 if ( ulResult == cOCT6100_ERR_OK )
4377 {
4378 fRoutReserved = TRUE;
4379 }
4380 }
4381 }
4382 else
4383 {
4384 *f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX;
4385 }
4386 }
4387 else
4388 {
4389 *f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX;
4390 }
4391
4392 /* Modify SOUT port.*/
4393 if ( ( fReserveSout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4394 {
4395 if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_UNASSIGNED )
4396 {
4397 /* Check what number of TSSTs should be reserved this time. */
4398 if ( pModifyTdmConf->ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4399 {
4400 ulSoutNumTssts = pApiTdmConf->bySoutNumTssts;
4401 }
4402 else /* if ( pModifyTdmConf->ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4403 {
4404 /* New number of TSSTs. */
4405 ulSoutNumTssts = pModifyTdmConf->ulSoutNumTssts;
4406 }
4407
4408 if ( pModifyTdmConf->ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4409 {
4410 /* Reserve the new number of TSSTs. */
4411 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4412 pApiTdmConf->usSoutTimeslot,
4413 pApiTdmConf->usSoutStream,
4414 ulSoutNumTssts,
4415 cOCT6100_OUTPUT_TSST,
4416 f_pusNewSoutTsstIndex,
4417 NULL );
4418 }
4419 else /* if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4420 {
4421 /* Reserve the new TSST.*/
4422 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4423 pModifyTdmConf->ulSoutTimeslot,
4424 pModifyTdmConf->ulSoutStream,
4425 ulSoutNumTssts,
4426 cOCT6100_OUTPUT_TSST,
4427 f_pusNewSoutTsstIndex,
4428 NULL );
4429 if ( ulResult == cOCT6100_ERR_OK )
4430 {
4431 fSoutReserved = TRUE;
4432 }
4433 }
4434 }
4435 else
4436 {
4437 *f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX;
4438 }
4439 }
4440 else
4441 {
4442 *f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX;
4443 }
4444
4445
4446 }
4447
4448 if ( f_pChannelModify->fCodecConfigModified == TRUE )
4449 {
4450 if ( ulResult == cOCT6100_ERR_OK &&
4451 pChanEntry->usRinRoutConversionMemIndex == cOCT6100_INVALID_INDEX &&
4452 ( f_pChannelModify->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ||
4453 f_pChannelModify->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) )
4454 {
4455 /* Reserve an ADPCM memory block.*/
4456 ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usRinRoutConversionMemIndex );
4457 if ( ulResult == cOCT6100_ERR_OK )
4458 {
4459 fRinRoutConversionMemReserved = TRUE;
4460 }
4461 }
4462
4463 if ( ulResult == cOCT6100_ERR_OK &&
4464 pChanEntry->usSinSoutConversionMemIndex == cOCT6100_INVALID_INDEX &&
4465 ( f_pChannelModify->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT ||
4466 f_pChannelModify->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN ) )
4467 {
4468 /* Reserve an ADPCM memory block.*/
4469 ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usSinSoutConversionMemIndex );
4470 if ( ulResult == cOCT6100_ERR_OK )
4471 {
4472 fSinSoutConversionMemReserved = TRUE;
4473 }
4474 }
4475 }
4476
4477
4478 /*===============================================================================*/
4479 /* Check if there are a couple of mixer events available for us. */
4480
4481 if ( ulResult == cOCT6100_ERR_OK )
4482 {
4483 UINT32 ulMixerEventCntNeeded = 0;
4484
4485 /* Calculate how many mixer events are needed. */
4486 if ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX )
4487 {
4488 /* If the channel is in bidir mode, do not create the Rin silence event!!! */
4489 if ( pChanEntry->fBiDirChannel == FALSE )
4490 {
4491 if ( ( *f_pusNewRinTsstIndex == cOCT6100_INVALID_INDEX )
4492 && ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
4493 ulMixerEventCntNeeded++;
4494 }
4495 }
4496
4497 if ( ( *f_pusNewSinTsstIndex == cOCT6100_INVALID_INDEX )
4498 && ( pChanEntry->usSinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
4499 {
4500 ulMixerEventCntNeeded++;
4501 }
4502
4503 /* If at least 1 mixer event is needed, check if those are available. */
4504 if ( ulMixerEventCntNeeded != 0 )
4505 {
4506 ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt );
4507 if ( ulResult == cOCT6100_ERR_OK )
4508 {
4509 /* The API might need more mixer events if the ports have to be muted. */
4510 /* Check if these are available. */
4511 if ( ulFreeMixerEventCnt < ulMixerEventCntNeeded )
4512 {
4513 ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS;
4514 }
4515 }
4516 }
4517 }
4518
4519 /*===============================================================================*/
4520
4521 /* Verify if an error occured. */
4522 if ( ulResult != cOCT6100_ERR_OK )
4523 {
4524 /* Release any resources newly reserved.*/
4525 if ( fRinReserved == TRUE )
4526 {
4527 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
4528 pModifyTdmConf->ulRinTimeslot,
4529 pModifyTdmConf->ulRinStream,
4530 ulRinNumTssts,
4531 cOCT6100_INPUT_TSST,
4532 cOCT6100_INVALID_INDEX );
4533 if ( ulTempVar != cOCT6100_ERR_OK )
4534 return ulTempVar;
4535 }
4536
4537 /* For the SIN port.*/
4538 if ( fSinReserved == TRUE )
4539 {
4540 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
4541 pModifyTdmConf->ulSinTimeslot,
4542 pModifyTdmConf->ulSinStream,
4543 ulSinNumTssts,
4544 cOCT6100_INPUT_TSST,
4545 cOCT6100_INVALID_INDEX );
4546 if ( ulTempVar != cOCT6100_ERR_OK )
4547 return ulTempVar;
4548 }
4549
4550 /* For the ROUT port.*/
4551 if ( fRoutReserved == TRUE )
4552 {
4553 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
4554 pModifyTdmConf->ulRoutTimeslot,
4555 pModifyTdmConf->ulRoutStream,
4556 ulRoutNumTssts,
4557 cOCT6100_OUTPUT_TSST,
4558 cOCT6100_INVALID_INDEX );
4559 if ( ulTempVar != cOCT6100_ERR_OK )
4560 return ulTempVar;
4561 }
4562
4563 /* For the SOUT port.*/
4564 if ( fSoutReserved == TRUE )
4565 {
4566 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
4567 pModifyTdmConf->ulSoutTimeslot,
4568 pModifyTdmConf->ulSoutStream,
4569 ulSoutNumTssts,
4570 cOCT6100_OUTPUT_TSST,
4571 cOCT6100_INVALID_INDEX );
4572 if ( ulTempVar != cOCT6100_ERR_OK )
4573 return ulTempVar;
4574 }
4575
4576 /* Now make sure any resources released gets reserved back again.*/
4577
4578 /* For the RIN port.*/
4579 if ( fRinReleased == TRUE )
4580 {
4581 /* Reserve the new TSST.*/
4582 ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance,
4583 pChanEntry->TdmConfig.usRinTimeslot,
4584 pChanEntry->TdmConfig.usRinStream,
4585 pChanEntry->TdmConfig.byRinNumTssts,
4586 cOCT6100_INPUT_TSST,
4587 &pChanEntry->usRinTsstIndex,
4588 NULL );
4589 if ( ulTempVar != cOCT6100_ERR_OK )
4590 return ulTempVar;
4591 }
4592
4593 /* For the SIN port.*/
4594 if ( fSinReleased == TRUE )
4595 {
4596 /* Reserve the new TSST.*/
4597 ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance,
4598 pChanEntry->TdmConfig.usSinTimeslot,
4599 pChanEntry->TdmConfig.usSinStream,
4600 pChanEntry->TdmConfig.bySinNumTssts,
4601 cOCT6100_INPUT_TSST,
4602 &pChanEntry->usSinTsstIndex,
4603 NULL );
4604 if ( ulTempVar != cOCT6100_ERR_OK )
4605 return ulTempVar;
4606 }
4607
4608 /* For the ROUT port.*/
4609 if ( fRoutReleased == TRUE )
4610 {
4611 /* Reserve the new TSST.*/
4612 ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance,
4613 pChanEntry->TdmConfig.usRoutTimeslot,
4614 pChanEntry->TdmConfig.usRoutStream,
4615 pChanEntry->TdmConfig.byRoutNumTssts,
4616 cOCT6100_OUTPUT_TSST,
4617 &pChanEntry->usRoutTsstIndex,
4618 NULL );
4619 if ( ulTempVar != cOCT6100_ERR_OK )
4620 return ulTempVar;
4621 }
4622
4623 /* For the SOUT port.*/
4624 if ( fSoutReleased == TRUE )
4625 {
4626 /* Reserve the new TSST.*/
4627 ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance,
4628 pChanEntry->TdmConfig.usSoutTimeslot,
4629 pChanEntry->TdmConfig.usSoutStream,
4630 pChanEntry->TdmConfig.bySoutNumTssts,
4631 cOCT6100_OUTPUT_TSST,
4632 &pChanEntry->usSoutTsstIndex,
4633 NULL );
4634 if ( ulTempVar != cOCT6100_ERR_OK )
4635 return ulTempVar;
4636 }
4637
4638 /* Release the conversion memories if they were reserved.*/
4639 if ( fRinRoutConversionMemReserved == TRUE )
4640 {
4641 ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
4642 pChanEntry->usRinRoutConversionMemIndex );
4643 if ( ulTempVar != cOCT6100_ERR_OK )
4644 return ulTempVar;
4645 }
4646
4647 if ( fSinSoutConversionMemReserved == TRUE )
4648 {
4649 ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
4650 pChanEntry->usSinSoutConversionMemIndex );
4651 if ( ulTempVar != cOCT6100_ERR_OK )
4652 return ulTempVar;
4653 }
4654
4655 /* Now return the error.*/
4656 return ulResult;
4657 }
4658
4659 return cOCT6100_ERR_OK;
4660 }
4661 #endif
4662
4663
4664 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4665
4666 Function: Oct6100ApiModifyChannelStructs
4667
4668 Description: Performs all the required structure writes to configure the
4669 echo cancellation channel based on the new modifications.
4670
4671 -------------------------------------------------------------------------------
4672 | Argument | Description
4673 -------------------------------------------------------------------------------
4674 f_pApiInstance Pointer to API instance. This memory is used to keep the
4675 present state of the chip and all its resources.
4676
4677 f_pChannelModify Pointer to echo cancellation channel configuration structure.
4678 f_pChannelOpen Pointer to a structure used to store the multiple resources indexes.
4679 f_usChanIndex Index of the channel within the API's channel list.
4680 f_usNewPhasingTsstIndex Index of the new phasing TSST.
4681 f_pfSinSoutCodecActive Pointer to the state of the SIN/SOUT codec.
4682 f_pfRinRoutCodecActive Pointer to the state of the RIN/ROUT codec.
4683 f_usNewRinTsstIndex New RIN TSST memory index.
4684 f_usNewSinTsstIndex New SIN TSST memory index.
4685 f_usNewRoutTsstIndex New ROUT TSST memory index.
4686 f_usNewSoutTsstIndex New SOUT TSST memory index.
4687
4688 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4689 #if !SKIP_Oct6100ApiModifyChannelStructs
4690 UINT32 Oct6100ApiModifyChannelStructs(
4691 IN tPOCT6100_INSTANCE_API f_pApiInstance,
4692 IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify,
4693 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
4694 IN UINT16 f_usChanIndex,
4695 IN UINT16 f_usNewPhasingTsstIndex,
4696 OUT PUINT8 f_pfSinSoutCodecActive,
4697 OUT PUINT8 f_pfRinRoutCodecActive,
4698 IN UINT16 f_usNewRinTsstIndex,
4699 IN UINT16 f_usNewSinTsstIndex,
4700 IN UINT16 f_usNewRoutTsstIndex,
4701 IN UINT16 f_usNewSoutTsstIndex )
4702 {
4703 tPOCT6100_API_CHANNEL pChanEntry;
4704 tPOCT6100_SHARED_INFO pSharedInfo;
4705 tOCT6100_READ_PARAMS ReadParams;
4706 tOCT6100_WRITE_PARAMS WriteParams;
4707 tPOCT6100_API_CHANNEL_CODEC pApiCodecConf;
4708 tPOCT6100_API_CHANNEL_TDM pApiTdmConf;
4709 tPOCT6100_API_CHANNEL_VQE pApiVqeConf;
4710
4711 UINT32 ulResult;
4712 UINT16 usReadData;
4713
4714 UINT16 usSinTsstIndex;
4715 UINT16 usRinTsstIndex;
4716
4717 UINT32 ulToneConfIndex;
4718 BOOL fClearPlayoutPointers = FALSE;
4719
4720 BOOL fConversionEnabled = FALSE;
4721
4722
4723
4724 /* Obtain local pointer to shared portion of instance. */
4725 pSharedInfo = f_pApiInstance->pSharedInfo;
4726
4727 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4728
4729 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
4730
4731 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
4732
4733 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
4734 ReadParams.pusReadData = &usReadData;
4735
4736 /*=======================================================================*/
4737 /* Get a pointer to the channel's list entry. */
4738 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
4739
4740 /* Obtain local pointer to the configuration structures of the tPOCT6100_API_CHANNEL structure. */
4741 pApiCodecConf = &pChanEntry->CodecConfig;
4742 pApiTdmConf = &pChanEntry->TdmConfig;
4743 pApiVqeConf = &pChanEntry->VqeConfig;
4744
4745 /*=======================================================================*/
4746 /* Init the RIN and SIN TSST index */
4747
4748 usRinTsstIndex = pChanEntry->usRinTsstIndex;
4749 usSinTsstIndex = pChanEntry->usSinTsstIndex;
4750
4751
4752 /*==============================================================================*/
4753 /* Clear the TSST that will be release.*/
4754
4755 if ( f_pChannelModify->fTdmConfigModified == TRUE )
4756 {
4757 /* Modify RIN port.*/
4758 if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4759 {
4760 if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4761 {
4762 /* Clear the previous entry */
4763 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usRinTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4764 WriteParams.usWriteData = 0x0000;
4765
4766 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4767 if ( ulResult != cOCT6100_ERR_OK )
4768 return ulResult;
4769 }
4770 }
4771
4772 /* Modify SIN port.*/
4773 if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4774 {
4775 if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4776 {
4777 /* Clear the previous entry */
4778 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usSinTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4779 WriteParams.usWriteData = 0x0000;
4780
4781 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4782 if ( ulResult != cOCT6100_ERR_OK )
4783 return ulResult;
4784 }
4785 }
4786
4787 /* Modify ROUT port.*/
4788 if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4789 {
4790 if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
4791 {
4792 /* Clear the previous entry */
4793 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usRoutTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4794 WriteParams.usWriteData = 0x0000;
4795
4796 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4797 if ( ulResult != cOCT6100_ERR_OK )
4798 return ulResult;
4799 }
4800 }
4801
4802 /* Modify SOUT port.*/
4803 if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING)
4804 {
4805 if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
4806 {
4807 /* Clear the previous entry */
4808 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usSoutTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4809 WriteParams.usWriteData = 0x0000;
4810
4811 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4812 if ( ulResult != cOCT6100_ERR_OK )
4813 return ulResult;
4814 }
4815 }
4816 }
4817 /*==============================================================================*/
4818
4819
4820 /*==============================================================================*/
4821 /* Now, Configure the Tsst control memory.*/
4822
4823 if ( f_pChannelModify->fTdmConfigModified == TRUE )
4824 {
4825 /* Modify RIN port.*/
4826 if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4827 {
4828 usRinTsstIndex = f_usNewRinTsstIndex;
4829
4830 if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX )
4831 {
4832 if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX )
4833 {
4834 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4835 f_usNewRinTsstIndex,
4836 pChanEntry->usExtraRinTsiMemIndex,
4837 f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4838 if ( ulResult != cOCT6100_ERR_OK )
4839 return ulResult;
4840 }
4841 else
4842 {
4843 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4844 f_usNewRinTsstIndex,
4845 pChanEntry->usRinRoutTsiMemIndex,
4846 f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4847 if ( ulResult != cOCT6100_ERR_OK )
4848 return ulResult;
4849 }
4850 }
4851 }
4852 if ( f_pChannelModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING &&
4853 f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
4854 {
4855 if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX )
4856 {
4857 if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4858 {
4859 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4860 pChanEntry->usRinTsstIndex,
4861 pChanEntry->usExtraRinTsiMemIndex,
4862 f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4863 if ( ulResult != cOCT6100_ERR_OK )
4864 return ulResult;
4865 }
4866 }
4867 else
4868 {
4869 if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4870 {
4871 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4872 pChanEntry->usRinTsstIndex,
4873 pChanEntry->usRinRoutTsiMemIndex,
4874 f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4875 if ( ulResult != cOCT6100_ERR_OK )
4876 return ulResult;
4877 }
4878 }
4879 }
4880
4881 /* Modify SIN port.*/
4882 if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4883 {
4884 usSinTsstIndex = f_usNewSinTsstIndex;
4885
4886 if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX )
4887 {
4888 if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
4889 {
4890 /* Write the new entry now.*/
4891 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4892 f_usNewSinTsstIndex,
4893 pChanEntry->usExtraSinTsiMemIndex,
4894 f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4895 if ( ulResult != cOCT6100_ERR_OK )
4896 return ulResult;
4897 }
4898 else
4899 {
4900 /* Write the new entry now.*/
4901 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4902 f_usNewSinTsstIndex,
4903 pChanEntry->usSinSoutTsiMemIndex,
4904 f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4905 if ( ulResult != cOCT6100_ERR_OK )
4906 return ulResult;
4907 }
4908 }
4909 }
4910 if ( f_pChannelModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING &&
4911 f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
4912 {
4913 if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
4914 {
4915 if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4916 {
4917 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4918 pChanEntry->usSinTsstIndex ,
4919 pChanEntry->usExtraSinTsiMemIndex,
4920 f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4921 if ( ulResult != cOCT6100_ERR_OK )
4922 return ulResult;
4923 }
4924 }
4925 else
4926 {
4927 if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4928 {
4929 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4930 pChanEntry->usSinTsstIndex ,
4931 pChanEntry->usSinSoutTsiMemIndex,
4932 f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4933 if ( ulResult != cOCT6100_ERR_OK )
4934 return ulResult;
4935 }
4936 }
4937 }
4938
4939 /* Modify ROUT port.*/
4940 if ( ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4941 || ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4942 )
4943 {
4944 if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX )
4945 {
4946 if ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4947 {
4948 /* If this output port is not muted. */
4949 if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 )
4950 {
4951 /* Write the new entry now.*/
4952 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
4953 f_usNewRoutTsstIndex,
4954 pApiCodecConf->byAdpcmNibblePosition,
4955 f_pChannelModify->TdmConfig.ulRoutNumTssts,
4956 pChanEntry->usRinRoutTsiMemIndex );
4957 if ( ulResult != cOCT6100_ERR_OK )
4958 return ulResult;
4959 }
4960 }
4961 else
4962 {
4963 /* If this output port is not muted. */
4964 if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 )
4965 {
4966 /* Write the new entry now.*/
4967 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
4968 f_usNewRoutTsstIndex,
4969 pApiCodecConf->byAdpcmNibblePosition,
4970 pApiTdmConf->byRoutNumTssts,
4971 pChanEntry->usRinRoutTsiMemIndex );
4972 if ( ulResult != cOCT6100_ERR_OK )
4973 return ulResult;
4974 }
4975 }
4976 }
4977 }
4978
4979 /* Modify SOUT port.*/
4980 if ( ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4981 || ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4982 )
4983 {
4984 if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX )
4985 {
4986 if ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4987 {
4988 /* If this output port is not muted. */
4989 if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 )
4990 {
4991 /* Write the new entry now.*/
4992 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
4993 f_usNewSoutTsstIndex,
4994 pApiCodecConf->byAdpcmNibblePosition,
4995 f_pChannelModify->TdmConfig.ulSoutNumTssts,
4996 pChanEntry->usSinSoutTsiMemIndex );
4997
4998 if ( ulResult != cOCT6100_ERR_OK )
4999 return ulResult;
5000 }
5001 }
5002 else
5003 {
5004 /* If this output port is not muted. */
5005 if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 )
5006 {
5007 /* Write the new entry now.*/
5008 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
5009 f_usNewSoutTsstIndex,
5010 pApiCodecConf->byAdpcmNibblePosition,
5011 pApiTdmConf->bySoutNumTssts,
5012 pChanEntry->usSinSoutTsiMemIndex );
5013
5014 if ( ulResult != cOCT6100_ERR_OK )
5015 return ulResult;
5016 }
5017 }
5018 }
5019 }
5020
5021
5022
5023 }
5024
5025 /*==============================================================================*/
5026
5027
5028 /*==============================================================================*/
5029 /* Modify the Encoder/Decoder memory if required.*/
5030
5031 if ( f_pChannelModify->fCodecConfigModified == TRUE )
5032 {
5033 UINT32 ulCompType = 0;
5034 UINT16 usTempTsiMemIndex;
5035 UINT16 usDecoderMemIndex;
5036 UINT16 usEncoderMemIndex;
5037 UINT32 ulPcmLaw;
5038 UINT16 usPhasingIndex;
5039 BOOL fModifyAdpcmMem = TRUE;
5040
5041 /*==============================================================================*/
5042 /* Reprogram the Decoder memory.*/
5043
5044 if ( pChanEntry->CodecConfig.byDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5045 {
5046 usDecoderMemIndex = pChanEntry->usRinRoutConversionMemIndex;
5047 }
5048 else
5049 {
5050 usDecoderMemIndex = pChanEntry->usSinSoutConversionMemIndex;
5051 }
5052
5053 if ( pChanEntry->CodecConfig.byEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5054 {
5055 usEncoderMemIndex = pChanEntry->usRinRoutConversionMemIndex;
5056 }
5057 else
5058 {
5059 usEncoderMemIndex = pChanEntry->usSinSoutConversionMemIndex;
5060 }
5061
5062 if ( usDecoderMemIndex != cOCT6100_INVALID_INDEX )
5063 {
5064 switch( f_pChannelOpen->CodecConfig.ulDecodingRate )
5065 {
5066 case cOCT6100_G711_64KBPS:
5067 ulCompType = 0x8;
5068
5069 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5070 {
5071 if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw )
5072 fModifyAdpcmMem = FALSE;
5073
5074 /* Check if both ports are assigned. If not, no law conversion needed here.. */
5075 if ( ( f_pChannelOpen->TdmConfig.ulRinStream == cOCT6100_UNASSIGNED )
5076 || ( f_pChannelOpen->TdmConfig.ulRoutStream == cOCT6100_UNASSIGNED ) )
5077 fModifyAdpcmMem = FALSE;
5078 }
5079 else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
5080 {
5081 if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
5082 fModifyAdpcmMem = FALSE;
5083
5084 /* Check if both ports are assigned. If not, no law conversion needed here.. */
5085 if ( ( f_pChannelOpen->TdmConfig.ulSinStream == cOCT6100_UNASSIGNED )
5086 || ( f_pChannelOpen->TdmConfig.ulSoutStream == cOCT6100_UNASSIGNED ) )
5087 fModifyAdpcmMem = FALSE;
5088 }
5089
5090 break;
5091 case cOCT6100_G726_40KBPS:
5092 ulCompType = 0x3;
5093 fConversionEnabled = TRUE;
5094 break;
5095
5096 case cOCT6100_G726_32KBPS:
5097 ulCompType = 0x2;
5098 fConversionEnabled = TRUE;
5099 break;
5100
5101 case cOCT6100_G726_24KBPS:
5102 ulCompType = 0x1;
5103 fConversionEnabled = TRUE;
5104 break;
5105
5106 case cOCT6100_G726_16KBPS:
5107 ulCompType = 0x0;
5108 fConversionEnabled = TRUE;
5109 break;
5110
5111 case cOCT6100_G727_2C_ENCODED:
5112 ulCompType = 0x4;
5113 fConversionEnabled = TRUE;
5114 break;
5115
5116 case cOCT6100_G727_3C_ENCODED:
5117 ulCompType = 0x5;
5118 fConversionEnabled = TRUE;
5119 break;
5120
5121 case cOCT6100_G727_4C_ENCODED:
5122 ulCompType = 0x6;
5123 fConversionEnabled = TRUE;
5124 break;
5125
5126 case cOCT6100_G726_ENCODED:
5127 ulCompType = 0x9;
5128 fConversionEnabled = TRUE;
5129 break;
5130
5131 case cOCT6100_G711_G726_ENCODED:
5132 ulCompType = 0xA;
5133 fConversionEnabled = TRUE;
5134 break;
5135
5136 case cOCT6100_G711_G727_2C_ENCODED:
5137 ulCompType = 0xC;
5138 fConversionEnabled = TRUE;
5139 break;
5140
5141 case cOCT6100_G711_G727_3C_ENCODED:
5142 ulCompType = 0xD;
5143 fConversionEnabled = TRUE;
5144 break;
5145
5146 case cOCT6100_G711_G727_4C_ENCODED:
5147 ulCompType = 0xE;
5148 fConversionEnabled = TRUE;
5149 break;
5150
5151 default:
5152 return cOCT6100_ERR_FATAL_D6;
5153 }
5154
5155 if ( fModifyAdpcmMem == TRUE )
5156 {
5157 /* Set the chariot memory based on the selected port.*/
5158 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5159 {
5160 usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
5161 ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw; /* Set the law for later use */
5162
5163 /* Flag the entry as active.*/
5164 *f_pfRinRoutCodecActive = TRUE;
5165 }
5166 else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
5167 {
5168 usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
5169 ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw; /* Set the law for later use */
5170
5171 /* Flag the entry as active.*/
5172 *f_pfSinSoutCodecActive = TRUE;
5173 }
5174
5175 ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance,
5176 usDecoderMemIndex,
5177 ulCompType,
5178 usTempTsiMemIndex,
5179 ulPcmLaw,
5180 pApiCodecConf->byAdpcmNibblePosition );
5181 if ( ulResult != cOCT6100_ERR_OK )
5182 return ulResult;
5183 }
5184 else
5185 {
5186 ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance,
5187 usDecoderMemIndex );
5188 if ( ulResult != cOCT6100_ERR_OK )
5189 return ulResult;
5190
5191 /* Flag the entry as deactivated.*/
5192 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5193 {
5194 *f_pfRinRoutCodecActive = FALSE;
5195 }
5196 else
5197 {
5198 *f_pfSinSoutCodecActive = FALSE;
5199 }
5200 }
5201 }
5202
5203 /*==============================================================================*/
5204
5205
5206
5207
5208 /*==============================================================================*/
5209 /* Reprogram the Encoder memory.*/
5210
5211 if ( usEncoderMemIndex != cOCT6100_INVALID_INDEX )
5212 {
5213
5214 fModifyAdpcmMem = TRUE;
5215
5216 /* Set the chariot memory based on the selected port.*/
5217 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5218 {
5219 usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
5220 ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw; /* Set the law for later use */
5221 }
5222 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5223 {
5224 usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
5225 ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw; /* Set the law for later use */
5226 }
5227
5228 /* Set the phasing index .*/
5229 if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX )
5230 usPhasingIndex = f_usNewPhasingTsstIndex;
5231 else
5232 usPhasingIndex = pChanEntry->usPhasingTsstIndex;
5233
5234 switch( f_pChannelOpen->CodecConfig.ulEncodingRate )
5235 {
5236 case cOCT6100_G711_64KBPS:
5237 if ( ulPcmLaw == cOCT6100_PCM_U_LAW )
5238 ulCompType = 0x4;
5239 else /* ulPcmLaw == cOCT6100_PCM_A_LAW */
5240 ulCompType = 0x5;
5241
5242 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5243 {
5244 if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw )
5245 fModifyAdpcmMem = FALSE;
5246
5247 /* Check if both ports are assigned. If not, no law conversion needed here.. */
5248 if ( ( f_pChannelOpen->TdmConfig.ulRinStream == cOCT6100_UNASSIGNED )
5249 || ( f_pChannelOpen->TdmConfig.ulRoutStream == cOCT6100_UNASSIGNED ) )
5250 fModifyAdpcmMem = FALSE;
5251 }
5252 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5253 {
5254 if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
5255 fModifyAdpcmMem = FALSE;
5256
5257 /* Check if both ports are assigned. If not, no law conversion needed here.. */
5258 if ( ( f_pChannelOpen->TdmConfig.ulSinStream == cOCT6100_UNASSIGNED )
5259 || ( f_pChannelOpen->TdmConfig.ulSoutStream == cOCT6100_UNASSIGNED ) )
5260 fModifyAdpcmMem = FALSE;
5261 }
5262 break;
5263 case cOCT6100_G726_40KBPS:
5264 ulCompType = 0x3;
5265 fConversionEnabled = TRUE;
5266 break;
5267
5268 case cOCT6100_G726_32KBPS:
5269 ulCompType = 0x2;
5270 fConversionEnabled = TRUE;
5271 break;
5272
5273 case cOCT6100_G726_24KBPS:
5274 ulCompType = 0x1;
5275 fConversionEnabled = TRUE;
5276 break;
5277
5278 case cOCT6100_G726_16KBPS:
5279 ulCompType = 0x0;
5280 fConversionEnabled = TRUE;
5281 break;
5282
5283 case cOCT6100_G727_40KBPS_4_1:
5284 ulCompType = 0xD;
5285 fConversionEnabled = TRUE;
5286 break;
5287
5288 case cOCT6100_G727_40KBPS_3_2:
5289 ulCompType = 0xA;
5290 fConversionEnabled = TRUE;
5291 break;
5292
5293 case cOCT6100_G727_40KBPS_2_3:
5294 ulCompType = 0x6;
5295 fConversionEnabled = TRUE;
5296 break;
5297
5298 case cOCT6100_G727_32KBPS_4_0:
5299 ulCompType = 0xE;
5300 fConversionEnabled = TRUE;
5301 break;
5302
5303 case cOCT6100_G727_32KBPS_3_1:
5304 ulCompType = 0xB;
5305 fConversionEnabled = TRUE;
5306 break;
5307
5308 case cOCT6100_G727_32KBPS_2_2:
5309 ulCompType = 0x7;
5310 fConversionEnabled = TRUE;
5311 break;
5312
5313 case cOCT6100_G727_24KBPS_3_0:
5314 ulCompType = 0xC;
5315 fConversionEnabled = TRUE;
5316 break;
5317
5318 case cOCT6100_G727_24KBPS_2_1:
5319 ulCompType = 0x8;
5320 fConversionEnabled = TRUE;
5321 break;
5322
5323 case cOCT6100_G727_16KBPS_2_0:
5324 ulCompType = 0x9;
5325 fConversionEnabled = TRUE;
5326 break;
5327
5328 default:
5329 return cOCT6100_ERR_FATAL_D7;
5330 }
5331
5332 if ( fModifyAdpcmMem == TRUE )
5333 {
5334 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5335 {
5336 *f_pfRinRoutCodecActive = TRUE;
5337 }
5338 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5339 {
5340 *f_pfSinSoutCodecActive = TRUE;
5341 }
5342
5343 ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance,
5344 usEncoderMemIndex,
5345 ulCompType,
5346 usTempTsiMemIndex,
5347 f_pChannelOpen->CodecConfig.fEnableSilenceSuppression,
5348 pApiCodecConf->byAdpcmNibblePosition,
5349 usPhasingIndex,
5350 f_pChannelOpen->CodecConfig.ulPhasingType,
5351 f_pChannelOpen->CodecConfig.ulPhase );
5352
5353 if ( ulResult != cOCT6100_ERR_OK )
5354 return ulResult;
5355 }
5356 else
5357 {
5358 ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance,
5359 usEncoderMemIndex );
5360 if ( ulResult != cOCT6100_ERR_OK )
5361 return ulResult;
5362
5363 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5364 {
5365 *f_pfRinRoutCodecActive = FALSE;
5366 }
5367 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5368 {
5369 *f_pfSinSoutCodecActive = FALSE;
5370 }
5371 }
5372 }
5373
5374 /*==============================================================================*/
5375 }
5376
5377
5378
5379
5380 /*==============================================================================*/
5381 /* Modify the VQE parameter if required.*/
5382
5383 if ( ( f_pChannelModify->fVqeConfigModified == TRUE )
5384 || ( (UINT8)f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode )
5385 || ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) )
5386 {
5387 ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance,
5388 &f_pChannelOpen->VqeConfig,
5389 f_pChannelOpen,
5390 f_usChanIndex,
5391 pChanEntry->usEchoMemIndex,
5392 FALSE,
5393 TRUE );
5394 if ( ulResult != cOCT6100_ERR_OK )
5395 return ulResult;
5396 }
5397
5398 /*==============================================================================*/
5399 /* Modify the Echo memory if required.*/
5400 if ( f_pChannelModify->fEnableToneDisabler != cOCT6100_KEEP_PREVIOUS_SETTING ||
5401 f_pChannelModify->ulEchoOperationMode != cOCT6100_KEEP_PREVIOUS_SETTING ||
5402 f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
5403 f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
5404 f_pChannelModify->TdmConfig.ulRoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
5405 f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
5406 {
5407 ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance,
5408 &f_pChannelOpen->TdmConfig,
5409 f_pChannelOpen,
5410 pChanEntry->usEchoMemIndex,
5411 pChanEntry->usRinRoutTsiMemIndex,
5412 pChanEntry->usSinSoutTsiMemIndex );
5413 if ( ulResult != cOCT6100_ERR_OK )
5414 return ulResult;
5415
5416 /* Synch all the buffer playout field if needed by echo operation mode. */
5417 /* Note that Oct6100ApiWriteVqeMemory does not clear the playout pointers */
5418 /* since the flag is set to FALSE. */
5419 if ( ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE )
5420 && ( ( f_pChannelModify->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_HT_FREEZE )
5421 || ( f_pChannelModify->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_POWER_DOWN ) ) )
5422 {
5423 /* Buffer playout must be stopped. */
5424 fClearPlayoutPointers = TRUE;
5425 }
5426 }
5427
5428 /*==============================================================================*/
5429 /* Modify the Mixer events if law changes are requested. */
5430
5431 if ( pChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX &&
5432 f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
5433 {
5434 ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
5435
5436 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5437 if ( ulResult != cOCT6100_ERR_OK )
5438 return ulResult;
5439
5440 /* Modify the value according to the new law.*/
5441 if ( f_pChannelModify->TdmConfig.ulSinPcmLaw == cOCT6100_PCM_A_LAW )
5442 WriteParams.usWriteData = (UINT16)( usReadData | ( f_pChannelModify->TdmConfig.ulSinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET ));
5443 else
5444 WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )));
5445
5446 /* Write back the new value.*/
5447 WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
5448
5449 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5450 if ( ulResult != cOCT6100_ERR_OK )
5451 return ulResult;
5452 }
5453
5454 if ( pChanEntry->usSoutCopyEventIndex != cOCT6100_INVALID_INDEX &&
5455 f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
5456 {
5457 ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
5458
5459 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5460 if ( ulResult != cOCT6100_ERR_OK )
5461 return ulResult;
5462
5463 /* Modify the value according to the new law.*/
5464 if ( f_pChannelModify->TdmConfig.ulSoutPcmLaw == cOCT6100_PCM_A_LAW )
5465 WriteParams.usWriteData = (UINT16)( usReadData | ( f_pChannelModify->TdmConfig.ulSoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET ));
5466 else
5467 WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )));
5468
5469 /* Write back the new value.*/
5470 WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
5471
5472 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5473 if ( ulResult != cOCT6100_ERR_OK )
5474 return ulResult;
5475 }
5476
5477 /*==============================================================================*/
5478 /* Mute channel if required, this is done on a port basis */
5479
5480 ulResult = Oct6100ApiMutePorts( f_pApiInstance,
5481 f_usChanIndex,
5482 usRinTsstIndex,
5483 usSinTsstIndex,
5484 TRUE );
5485 if ( ulResult != cOCT6100_ERR_OK )
5486 return ulResult;
5487
5488 /*==============================================================================*/
5489
5490 /* Completely disable tone detection? */
5491 if ( f_pChannelModify->fDisableToneDetection == TRUE )
5492 {
5493 /* Check if tone detection has been enabled on this channel. */
5494 for (ulToneConfIndex = 0; ulToneConfIndex < ARRAY_SIZE(pChanEntry->aulToneConf); ulToneConfIndex++)
5495 {
5496 /* Check if some tone has been activated on this channel. */
5497 if ( pChanEntry->aulToneConf[ ulToneConfIndex ] != 0 )
5498 {
5499 tOCT6100_TONE_DETECTION_DISABLE ToneDetectDisable;
5500
5501 /* Call the default function to make sure all parameters are assigned default values. */
5502 ulResult = Oct6100ToneDetectionDisableDef( &ToneDetectDisable );
5503 if ( ulResult != cOCT6100_ERR_OK )
5504 return ulResult;
5505
5506 /* Form channel handle. */
5507 ToneDetectDisable.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5508
5509 /* Disable all tones activated on this channel. */
5510 ToneDetectDisable.fDisableAll = TRUE;
5511
5512 /* Call tone detection serialized function. */
5513 ulResult = Oct6100ToneDetectionDisableSer( f_pApiInstance, &ToneDetectDisable );
5514 if ( ulResult != cOCT6100_ERR_OK )
5515 return ulResult;
5516
5517 /* Get out of the loop, tone detection has been disabled! */
5518 break;
5519 }
5520 }
5521 }
5522
5523 /* Hard-stop buffer playout? */
5524 if ( f_pChannelModify->fStopBufferPlayout == TRUE )
5525 {
5526 /* Check if playout has been started on the Rout port. */
5527 if ( ( pChanEntry->fRinBufPlaying == TRUE ) || ( pChanEntry->fRinBufAdded == TRUE ) )
5528 {
5529 tOCT6100_BUFFER_PLAYOUT_STOP PlayoutStop;
5530
5531 /* Call the default function to make sure all parameters are assigned default values. */
5532 ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop );
5533 if ( ulResult != cOCT6100_ERR_OK )
5534 return ulResult;
5535
5536 /* Hard stop request. */
5537 PlayoutStop.fStopCleanly = FALSE;
5538
5539 /* Form channel handle. */
5540 PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5541
5542 /* For the Rout port. */
5543 PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
5544
5545 /* Call buffer playout stop serialized function. */
5546 ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop );
5547 if ( ulResult != cOCT6100_ERR_OK )
5548 return ulResult;
5549 }
5550 else
5551 {
5552 /* The chip might still be playing a last buffer. Make sure it hard-stops! */
5553 fClearPlayoutPointers = TRUE;
5554 }
5555
5556 /* Check if playout has been started on the Sout port. */
5557 if ( ( pChanEntry->fSoutBufPlaying == TRUE ) || ( pChanEntry->fSoutBufAdded == TRUE ) )
5558 {
5559 tOCT6100_BUFFER_PLAYOUT_STOP PlayoutStop;
5560
5561 /* Call the default function to make sure all parameters are assigned default values. */
5562 ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop );
5563 if ( ulResult != cOCT6100_ERR_OK )
5564 return ulResult;
5565
5566 /* Hard stop request. */
5567 PlayoutStop.fStopCleanly = FALSE;
5568
5569 /* Form channel handle. */
5570 PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5571
5572 /* For the Rout port. */
5573 PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
5574
5575 /* Call buffer playout stop serialized function. */
5576 ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop );
5577 if ( ulResult != cOCT6100_ERR_OK )
5578 return ulResult;
5579 }
5580 else
5581 {
5582 /* The chip might still be playing a last buffer. Make sure it hard-stops! */
5583 fClearPlayoutPointers = TRUE;
5584 }
5585 }
5586
5587 /* Remove participant from bridge? */
5588 if ( f_pChannelModify->fRemoveConfBridgeParticipant == TRUE )
5589 {
5590 /* Check if this channel is on a bridge. */
5591 if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
5592 {
5593 /* Channel is on a bridge, remove it. */
5594 tOCT6100_CONF_BRIDGE_CHAN_REMOVE BridgeChanRemove;
5595
5596 /* Call the default function to make sure all parameters are assigned default values. */
5597 ulResult = Oct6100ConfBridgeChanRemoveDef( &BridgeChanRemove );
5598 if ( ulResult != cOCT6100_ERR_OK )
5599 return ulResult;
5600
5601 /* Form channel handle. */
5602 BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5603
5604 /* Do not remove all channels, only the one specified. */
5605 BridgeChanRemove.fRemoveAll = FALSE;
5606
5607 /* No need to assign conference bridge handle, the remove function will figure it out. */
5608
5609 /* Call conference bridge channel remove serialized function. */
5610 ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
5611 if ( ulResult != cOCT6100_ERR_OK )
5612 {
5613 if ( ulResult == cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_DEPENDENCY )
5614 {
5615 tPOCT6100_API_CHANNEL pTapChanEntry;
5616
5617 /* Get a pointer to the tap channel's list entry. */
5618 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTapChanEntry, pChanEntry->usTapChanIndex )
5619
5620 /* Form tap channel handle. */
5621 BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pTapChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | pChanEntry->usTapChanIndex;
5622
5623 ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
5624 if ( ulResult != cOCT6100_ERR_OK )
5625 return ulResult;
5626
5627 /* Re-form original channel handle. */
5628 BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5629
5630 ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
5631 if ( ulResult != cOCT6100_ERR_OK )
5632 return ulResult;
5633 }
5634 else
5635 {
5636 return ulResult;
5637 }
5638 }
5639 }
5640 }
5641
5642 /* Remove all broadcast TSSTs? */
5643 if ( f_pChannelModify->fRemoveBroadcastTssts == TRUE )
5644 {
5645 /* Check if broadcast TSSTs were used on the Rout port. */
5646 if ( pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX )
5647 {
5648 tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE BroadcastTsstRemove;
5649
5650 ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove );
5651 if ( ulResult != cOCT6100_ERR_OK )
5652 return ulResult;
5653
5654 /* Form channel handle. */
5655 BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5656
5657 /* Remove all broadcast TSSTs associated to the current channel. */
5658 BroadcastTsstRemove.fRemoveAll = TRUE;
5659
5660 /* On the Rout port. */
5661 BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_ROUT;
5662
5663 ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove );
5664 if ( ulResult != cOCT6100_ERR_OK )
5665 return ulResult;
5666 }
5667
5668
5669 /* Check if broadcast TSSTs were used on the Sout port. */
5670 if ( pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX )
5671 {
5672 tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE BroadcastTsstRemove;
5673
5674 ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove );
5675 if ( ulResult != cOCT6100_ERR_OK )
5676 return ulResult;
5677
5678 /* Form channel handle. */
5679 BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5680
5681 /* Remove all broadcast TSSTs associated to the current channel. */
5682 BroadcastTsstRemove.fRemoveAll = TRUE;
5683
5684 /* On the Sout port. */
5685 BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_SOUT;
5686
5687 ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove );
5688 if ( ulResult != cOCT6100_ERR_OK )
5689 return ulResult;
5690 }
5691 }
5692
5693 /* Check if have to make sure buffer playout is stopped. */
5694 if ( fClearPlayoutPointers == TRUE )
5695 {
5696 tOCT6100_BUFFER_PLAYOUT_STOP BufferPlayoutStop;
5697
5698 Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
5699
5700 BufferPlayoutStop.fStopCleanly = FALSE;
5701 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
5702
5703 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
5704 f_pApiInstance,
5705 &BufferPlayoutStop,
5706 f_usChanIndex,
5707 pChanEntry->usEchoMemIndex
5708
5709 );
5710 if ( ulResult != cOCT6100_ERR_OK )
5711 return ulResult;
5712
5713 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
5714 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
5715 f_pApiInstance,
5716 &BufferPlayoutStop,
5717 f_usChanIndex,
5718 pChanEntry->usEchoMemIndex
5719
5720 );
5721 if ( ulResult != cOCT6100_ERR_OK )
5722 return ulResult;
5723 }
5724
5725 return cOCT6100_ERR_OK;
5726 }
5727 #endif
5728
5729
5730
5731 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5732
5733 Function: Oct6100ApiModifyChannelEntry
5734
5735 Description: Updates the channel structure in the ECHO channel list.
5736
5737 -------------------------------------------------------------------------------
5738 | Argument | Description
5739 -------------------------------------------------------------------------------
5740 f_pApiInstance Pointer to API instance. This memory is used to keep
5741 the present state of the chip and all its resources.
5742
5743 f_pChannelModify Pointer to echo cancellation channel modify structure.
5744 f_pChannelOpen Pointer to echo cancellation channel configuration structure.
5745 f_usChanIndex Index of the channel within the API's channel list.
5746 f_usNewPhasingTsstIndex Index of the new phasing TSST.
5747 f_fSinSoutCodecActive State of the SIN/SOUT codec.
5748 f_fRinRoutCodecActive State of the RIN/ROUT codec.
5749 f_usNewRinTsstIndex New RIN TSST memory index.
5750 f_usNewSinTsstIndex New SIN TSST memory index.
5751 f_usNewRoutTsstIndex New ROUT TSST memory index.
5752 f_usNewSoutTsstIndex New SOUT TSST memory index.
5753
5754 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5755 #if !SKIP_Oct6100ApiModifyChannelEntry
5756 UINT32 Oct6100ApiModifyChannelEntry(
5757 IN tPOCT6100_INSTANCE_API f_pApiInstance,
5758 IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify,
5759 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
5760 IN UINT16 f_usChanIndex,
5761 IN UINT16 f_usNewPhasingTsstIndex,
5762 IN UINT8 f_fSinSoutCodecActive,
5763 IN UINT8 f_fRinRoutCodecActive,
5764 IN UINT16 f_usNewRinTsstIndex,
5765 IN UINT16 f_usNewSinTsstIndex,
5766 IN UINT16 f_usNewRoutTsstIndex,
5767 IN UINT16 f_usNewSoutTsstIndex )
5768 {
5769 tPOCT6100_SHARED_INFO pSharedInfo;
5770 tPOCT6100_API_CHANNEL pChanEntry;
5771 tPOCT6100_API_CHANNEL_CODEC pApiCodecConf;
5772 tPOCT6100_API_CHANNEL_TDM pApiTdmConf;
5773 tPOCT6100_API_CHANNEL_VQE pApiVqeConf;
5774
5775 /* Obtain local pointer to shared portion of instance. */
5776 pSharedInfo = f_pApiInstance->pSharedInfo;
5777
5778 /*=======================================================================*/
5779 /* Get a pointer to the channel's list entry. */
5780 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
5781
5782 /* Obtain local pointer to the configuration structures of the tPOCT6100_API_CHANNEL structure. */
5783 pApiCodecConf = &pChanEntry->CodecConfig;
5784 pApiTdmConf = &pChanEntry->TdmConfig;
5785 pApiVqeConf = &pChanEntry->VqeConfig;
5786
5787 /*=======================================================================*/
5788 /* Copy the channel's general configuration. */
5789
5790 pChanEntry->ulUserChanId = f_pChannelOpen->ulUserChanId;
5791 pChanEntry->byEchoOperationMode = (UINT8)( f_pChannelOpen->ulEchoOperationMode & 0xFF );
5792 pChanEntry->fEnableToneDisabler = (UINT8)( f_pChannelOpen->fEnableToneDisabler & 0xFF );
5793
5794 /* Save the codec state.*/
5795 pChanEntry->fSinSoutCodecActive = (UINT8)( f_fSinSoutCodecActive & 0xFF );
5796 pChanEntry->fRinRoutCodecActive = (UINT8)( f_fRinRoutCodecActive & 0xFF );
5797
5798 /*=======================================================================*/
5799 /* Copy the channel's TDM configuration of all the modified fields. */
5800
5801 if ( f_pChannelModify->fTdmConfigModified == TRUE )
5802 {
5803 pApiTdmConf->byRinPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulRinPcmLaw & 0xFF );
5804 pApiTdmConf->bySinPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulSinPcmLaw & 0xFF );
5805 pApiTdmConf->byRoutPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulRoutPcmLaw & 0xFF );
5806 pApiTdmConf->bySoutPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulSoutPcmLaw & 0xFF );
5807
5808 pApiTdmConf->byRinNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulRinNumTssts & 0xFF );
5809 pApiTdmConf->bySinNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulSinNumTssts & 0xFF );
5810 pApiTdmConf->byRoutNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulRoutNumTssts & 0xFF );
5811 pApiTdmConf->bySoutNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulSoutNumTssts & 0xFF );
5812
5813 if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
5814 {
5815 if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX )
5816 {
5817 pApiTdmConf->usRinStream = (UINT16)( f_pChannelOpen->TdmConfig.ulRinStream & 0xFFFF );
5818 pApiTdmConf->usRinTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulRinTimeslot & 0xFFFF );
5819 pChanEntry->usRinTsstIndex = f_usNewRinTsstIndex;
5820 }
5821 else /* f_ulNewRinTsstIndex != cOCT6100_INVALID_INDEX */
5822 {
5823 pApiTdmConf->usRinStream = cOCT6100_UNASSIGNED;
5824 pApiTdmConf->usRinTimeslot = cOCT6100_UNASSIGNED;
5825 pChanEntry->usRinTsstIndex = cOCT6100_INVALID_INDEX;
5826 }
5827 }
5828
5829 if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
5830 {
5831 if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX )
5832 {
5833 pApiTdmConf->usSinStream = (UINT16)( f_pChannelOpen->TdmConfig.ulSinStream & 0xFFFF );
5834 pApiTdmConf->usSinTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulSinTimeslot & 0xFFFF );
5835 pChanEntry->usSinTsstIndex = f_usNewSinTsstIndex;
5836 }
5837 else /* f_ulNewSinTsstIndex != cOCT6100_INVALID_INDEX */
5838 {
5839 pApiTdmConf->usSinStream = cOCT6100_UNASSIGNED;
5840 pApiTdmConf->usSinTimeslot = cOCT6100_UNASSIGNED;
5841 pChanEntry->usSinTsstIndex = cOCT6100_INVALID_INDEX;
5842 }
5843 }
5844
5845 if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
5846 {
5847 if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX )
5848 {
5849 pApiTdmConf->usRoutStream = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutStream & 0xFFFF );
5850 pApiTdmConf->usRoutTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutTimeslot & 0xFFFF );
5851 pChanEntry->usRoutTsstIndex = f_usNewRoutTsstIndex;
5852 }
5853 else /* f_ulNewRoutTsstIndex != cOCT6100_INVALID_INDEX */
5854 {
5855 pApiTdmConf->usRoutStream = cOCT6100_UNASSIGNED;
5856 pApiTdmConf->usRoutTimeslot = cOCT6100_UNASSIGNED;
5857 pChanEntry->usRoutTsstIndex = cOCT6100_INVALID_INDEX;
5858 }
5859 }
5860
5861 if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
5862 {
5863 if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX )
5864 {
5865 pApiTdmConf->usSoutStream = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutStream & 0xFFFF );
5866 pApiTdmConf->usSoutTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutTimeslot & 0xFFFF );
5867 pChanEntry->usSoutTsstIndex = f_usNewSoutTsstIndex;
5868 }
5869 else /* f_ulNewSoutTsstIndex != cOCT6100_INVALID_INDEX */
5870 {
5871 pApiTdmConf->usSoutStream = cOCT6100_UNASSIGNED;
5872 pApiTdmConf->usSoutTimeslot = cOCT6100_UNASSIGNED;
5873 pChanEntry->usSoutTsstIndex = cOCT6100_INVALID_INDEX;
5874 }
5875 }
5876 }
5877
5878 /*=======================================================================*/
5879 /* Copy the channel's VQE configuration of all the modified fields. */
5880
5881 if ( f_pChannelModify->fVqeConfigModified == TRUE )
5882 {
5883 pApiVqeConf->fEnableNlp = (UINT8)( f_pChannelOpen->VqeConfig.fEnableNlp & 0xFF );
5884 pApiVqeConf->byComfortNoiseMode = (UINT8)( f_pChannelOpen->VqeConfig.ulComfortNoiseMode & 0xFF );
5885 pApiVqeConf->fSinDcOffsetRemoval = (UINT8)( f_pChannelOpen->VqeConfig.fSinDcOffsetRemoval & 0xFF );
5886 pApiVqeConf->fRinDcOffsetRemoval = (UINT8)( f_pChannelOpen->VqeConfig.fRinDcOffsetRemoval & 0xFF );
5887 pApiVqeConf->fRinLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fRinLevelControl & 0xFF );
5888 pApiVqeConf->fSoutLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fSoutLevelControl & 0xFF );
5889 pApiVqeConf->fRinAutomaticLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fRinAutomaticLevelControl & 0xFF );
5890 pApiVqeConf->fSoutAutomaticLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAutomaticLevelControl & 0xFF );
5891 pApiVqeConf->fRinHighLevelCompensation = (UINT8)( f_pChannelOpen->VqeConfig.fRinHighLevelCompensation & 0xFF );
5892
5893 pApiVqeConf->fSoutAdaptiveNoiseReduction = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAdaptiveNoiseReduction & 0xFF );
5894 pApiVqeConf->fSoutNoiseBleaching = (UINT8)( f_pChannelOpen->VqeConfig.fSoutNoiseBleaching & 0xFF );
5895 pApiVqeConf->fSoutConferencingNoiseReduction = (UINT8)( f_pChannelOpen->VqeConfig.fSoutConferencingNoiseReduction & 0xFF );
5896 pApiVqeConf->chRinLevelControlGainDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lRinLevelControlGainDb & 0xFF );
5897 pApiVqeConf->chSoutLevelControlGainDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lSoutLevelControlGainDb & 0xFF );
5898 pApiVqeConf->chRinAutomaticLevelControlTargetDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lRinAutomaticLevelControlTargetDb & 0xFF );
5899 pApiVqeConf->chSoutAutomaticLevelControlTargetDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb & 0xFF );
5900 pApiVqeConf->chRinHighLevelCompensationThresholdDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lRinHighLevelCompensationThresholdDb & 0xFF );
5901 pApiVqeConf->fEnableTailDisplacement = (UINT8)( f_pChannelOpen->VqeConfig.fEnableTailDisplacement & 0xFF );
5902 pApiVqeConf->usTailDisplacement = (UINT16)( f_pChannelOpen->VqeConfig.ulTailDisplacement & 0xFFFF );
5903 pApiVqeConf->usTailLength = (UINT16)( f_pChannelOpen->VqeConfig.ulTailLength & 0xFFFF );
5904 pApiVqeConf->fAcousticEcho = (UINT8)( f_pChannelOpen->VqeConfig.fAcousticEcho & 0xFF );
5905 pApiVqeConf->fDtmfToneRemoval = (UINT8)( f_pChannelOpen->VqeConfig.fDtmfToneRemoval & 0xFF );
5906
5907 pApiVqeConf->chDefaultErlDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lDefaultErlDb & 0xFF );
5908 pApiVqeConf->chAecDefaultErlDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lAecDefaultErlDb & 0xFF );
5909 pApiVqeConf->usAecTailLength = (UINT16)( f_pChannelOpen->VqeConfig.ulAecTailLength & 0xFFFF );
5910 pApiVqeConf->chAnrSnrEnhancementDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lAnrSnrEnhancementDb & 0xFF );
5911 pApiVqeConf->byAnrVoiceNoiseSegregation = (UINT8)( f_pChannelOpen->VqeConfig.ulAnrVoiceNoiseSegregation & 0xFF );
5912 pApiVqeConf->usToneDisablerVqeActivationDelay = (UINT16)( f_pChannelOpen->VqeConfig.ulToneDisablerVqeActivationDelay & 0xFFFF );
5913 pApiVqeConf->byNonLinearityBehaviorA = (UINT8)( f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorA & 0xFF );
5914 pApiVqeConf->byNonLinearityBehaviorB = (UINT8)( f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorB & 0xFF );
5915 pApiVqeConf->byDoubleTalkBehavior = (UINT8)( f_pChannelOpen->VqeConfig.ulDoubleTalkBehavior & 0xFF );
5916 pApiVqeConf->bySoutAutomaticListenerEnhancementGainDb = (UINT8)( f_pChannelOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb & 0xFF );
5917 pApiVqeConf->bySoutNaturalListenerEnhancementGainDb = (UINT8)( f_pChannelOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb & 0xFF );
5918 pApiVqeConf->fSoutNaturalListenerEnhancement = (UINT8)( f_pChannelOpen->VqeConfig.fSoutNaturalListenerEnhancement & 0xFF );
5919 pApiVqeConf->fRoutNoiseReduction = (UINT8)( f_pChannelOpen->VqeConfig.fRoutNoiseReduction & 0xFF );
5920 pApiVqeConf->chRoutNoiseReductionLevelGainDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lRoutNoiseReductionLevelGainDb & 0xFF );
5921 pApiVqeConf->fEnableMusicProtection = (UINT8)( f_pChannelOpen->VqeConfig.fEnableMusicProtection & 0xFF );
5922 pApiVqeConf->fIdleCodeDetection = (UINT8)( f_pChannelOpen->VqeConfig.fIdleCodeDetection & 0xFF );
5923 }
5924
5925 /*=======================================================================*/
5926 /* Copy the channel's CODEC configuration of all the modified fields. */
5927 if ( f_pChannelModify->fCodecConfigModified == TRUE )
5928 {
5929 pApiCodecConf->byAdpcmNibblePosition = (UINT8)( f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition & 0xFF );
5930 pApiCodecConf->byEncoderPort = (UINT8)( f_pChannelOpen->CodecConfig.ulEncoderPort & 0xFF );
5931 pApiCodecConf->byEncodingRate = (UINT8)( f_pChannelOpen->CodecConfig.ulEncodingRate & 0xFF );
5932 pApiCodecConf->byDecoderPort = (UINT8)( f_pChannelOpen->CodecConfig.ulDecoderPort & 0xFF );
5933 pApiCodecConf->byDecodingRate = (UINT8)( f_pChannelOpen->CodecConfig.ulDecodingRate & 0xFF );
5934 pApiCodecConf->fEnableSilenceSuppression = (UINT8)( f_pChannelOpen->CodecConfig.fEnableSilenceSuppression & 0xFF );
5935 pApiCodecConf->byPhase = (UINT8)( f_pChannelOpen->CodecConfig.ulPhase & 0xFF );
5936 pApiCodecConf->byPhasingType = (UINT8)( f_pChannelOpen->CodecConfig.ulPhasingType & 0xFF );
5937
5938 /* Update the API phasing TSST structure */
5939 if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX )
5940 {
5941 tPOCT6100_API_PHASING_TSST pPhasingTsst;
5942
5943 /* Release the previous phasing TSST if the channel was already bound to one.*/
5944 if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
5945 {
5946 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, pChanEntry->usPhasingTsstIndex );
5947
5948 pPhasingTsst->usDependencyCnt--;
5949 }
5950
5951 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, f_usNewPhasingTsstIndex );
5952
5953 pPhasingTsst->usDependencyCnt++;
5954 pChanEntry->usPhasingTsstIndex = f_usNewPhasingTsstIndex;
5955
5956 }
5957 }
5958
5959
5960
5961 return cOCT6100_ERR_OK;
5962 }
5963 #endif
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5980
5981 Function: Oct6100ChannelBroadcastTsstAddSer
5982
5983 Description: Assign a TSST to one of the port of an echo cancellation channel.
5984
5985 -------------------------------------------------------------------------------
5986 | Argument | Description
5987 -------------------------------------------------------------------------------
5988 f_pApiInstance Pointer to API instance. This memory is used to keep the
5989 present state of the chip and all its resources.
5990
5991 f_pChannelTsstAdd Pointer to TSST assign structure.
5992
5993 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5994 #if !SKIP_Oct6100ChannelBroadcastTsstAddSer
5995 UINT32 Oct6100ChannelBroadcastTsstAddSer(
5996 IN tPOCT6100_INSTANCE_API f_pApiInstance,
5997 IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd )
5998 {
5999 UINT16 usChanIndex;
6000 UINT16 usNewTsstIndex;
6001 UINT16 usNewTsstEntry;
6002 UINT32 ulResult;
6003
6004 ulResult = Oct6100ApiCheckChanTsstAddParams( f_pApiInstance, f_pChannelTsstAdd, &usChanIndex );
6005 if ( ulResult != cOCT6100_ERR_OK )
6006 return ulResult;
6007
6008 ulResult = Oct6100ApiReserveTsstAddResources( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, &usNewTsstIndex, &usNewTsstEntry );
6009 if ( ulResult != cOCT6100_ERR_OK )
6010 return ulResult;
6011
6012 ulResult = Oct6100ApiWriteTsstAddStructs( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, usNewTsstIndex );
6013 if ( ulResult != cOCT6100_ERR_OK )
6014 return ulResult;
6015
6016 ulResult = Oct6100ApiUpdateTsstAddChanEntry( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, usNewTsstIndex, usNewTsstEntry );
6017 if ( ulResult != cOCT6100_ERR_OK )
6018 return ulResult;
6019
6020 return cOCT6100_ERR_OK;
6021 }
6022 #endif
6023
6024 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6025
6026 Function: Oct6100ApiCheckChanTsstAddParams
6027
6028 Description: Verify the validity of the tPOCT6100_CHANNEL_BROADCAST_TSST_ADD
6029 structure.
6030
6031 -------------------------------------------------------------------------------
6032 | Argument | Description
6033 -------------------------------------------------------------------------------
6034 f_pApiInstance Pointer to API instance. This memory is used to keep the
6035 present state of the chip and all its resources.
6036
6037 f_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
6038 f_pusChanIndex Pointer to a structure used to store the multiple resources indexes.
6039
6040 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6041 #if !SKIP_Oct6100ApiCheckChanTsstAddParams
6042 UINT32 Oct6100ApiCheckChanTsstAddParams(
6043 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6044 IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
6045 OUT PUINT16 f_pusChanIndex )
6046 {
6047 tPOCT6100_API_CHANNEL pChanEntry;
6048 UINT32 ulResult;
6049 UINT32 ulNumTssts = 1;
6050 UINT32 ulEntryOpenCnt;
6051
6052 /* Check the provided handle. */
6053 if ( (f_pChannelTsstAdd->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
6054 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6055
6056 *f_pusChanIndex = (UINT16)( f_pChannelTsstAdd->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
6057 if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
6058 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6059
6060 /*=======================================================================*/
6061 /* Get a pointer to the channel's list entry. */
6062
6063 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
6064
6065 /* Extract the entry open count from the provided handle. */
6066 ulEntryOpenCnt = ( f_pChannelTsstAdd->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
6067
6068 /* Check for errors. */
6069 if ( pChanEntry->fReserved != TRUE )
6070 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
6071 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
6072 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6073
6074 /*=======================================================================*/
6075
6076 /* validate the port parameter.*/
6077 if ( f_pChannelTsstAdd->ulPort != cOCT6100_CHANNEL_PORT_ROUT &&
6078 f_pChannelTsstAdd->ulPort != cOCT6100_CHANNEL_PORT_SOUT )
6079 return cOCT6100_ERR_CHANNEL_TSST_ADD_PORT;
6080
6081 /* Get the required number of TSST based on the port.*/
6082 switch( f_pChannelTsstAdd->ulPort )
6083 {
6084 case cOCT6100_CHANNEL_PORT_ROUT:
6085 ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6086 break;
6087 case cOCT6100_CHANNEL_PORT_SOUT:
6088 ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6089 break;
6090 default:
6091 return cOCT6100_ERR_FATAL_B;
6092 }
6093
6094 /* Check the validity of the timeslot and stream. */
6095 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
6096 ulNumTssts,
6097 f_pChannelTsstAdd->ulTimeslot,
6098 f_pChannelTsstAdd->ulStream,
6099 cOCT6100_OUTPUT_TSST );
6100 if ( ulResult != cOCT6100_ERR_OK )
6101 {
6102 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
6103 {
6104 return cOCT6100_ERR_CHANNEL_TSST_ADD_TIMESLOT;
6105 }
6106 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
6107 {
6108 return cOCT6100_ERR_CHANNEL_TSST_ADD_STREAM;
6109 }
6110 else
6111 {
6112 return ulResult;
6113 }
6114 }
6115
6116 return cOCT6100_ERR_OK;
6117 }
6118 #endif
6119
6120
6121 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6122
6123 Function: Oct6100ApiReserveTsstAddResources
6124
6125 Description: Reserve the entry for the new broadcast TSST.
6126
6127 -------------------------------------------------------------------------------
6128 | Argument | Description
6129 -------------------------------------------------------------------------------
6130 f_pApiInstance Pointer to API instance. This memory is used to keep the
6131 present state of the chip and all its resources.
6132
6133 f_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
6134 f_usChanIndex Channel index within the API's channel list.
6135 f_pusNewTsstIndex Pointer to the new TSST index within the API's TSST memory.
6136 f_pusNewTsstEntry Pointer to the new TSST entry within the API's TSST list.
6137
6138 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6139 #if !SKIP_Oct6100ApiReserveTsstAddResources
6140 UINT32 Oct6100ApiReserveTsstAddResources(
6141 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6142 IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
6143 IN UINT16 f_usChanIndex,
6144 OUT PUINT16 f_pusNewTsstIndex,
6145 OUT PUINT16 f_pusNewTsstEntry )
6146 {
6147 tPOCT6100_API_CHANNEL pChanEntry;
6148 UINT32 ulResult;
6149 UINT32 ulNumTssts = 1;
6150
6151 /*=======================================================================*/
6152 /* Get a pointer to the channel's list entry. */
6153
6154 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6155
6156 switch( f_pChannelTsstAdd->ulPort )
6157 {
6158 case cOCT6100_CHANNEL_PORT_ROUT:
6159 ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6160 break;
6161 case cOCT6100_CHANNEL_PORT_SOUT:
6162 ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6163 break;
6164 default:
6165 return cOCT6100_ERR_FATAL_C;
6166 }
6167
6168 /* Reserve the new entry.*/
6169 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
6170 f_pChannelTsstAdd->ulTimeslot,
6171 f_pChannelTsstAdd->ulStream,
6172 ulNumTssts,
6173 cOCT6100_OUTPUT_TSST,
6174 f_pusNewTsstIndex,
6175 f_pusNewTsstEntry );
6176 if ( ulResult != cOCT6100_ERR_OK )
6177 return ulResult;
6178
6179 return cOCT6100_ERR_OK;
6180 }
6181 #endif
6182
6183
6184 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6185
6186 Function: Oct6100ApiWriteTsstAddStructs
6187
6188 Description: Configure the TSST control memory for the new TSST entry.
6189
6190 -------------------------------------------------------------------------------
6191 | Argument | Description
6192 -------------------------------------------------------------------------------
6193 f_pApiInstance Pointer to API instance. This memory is used to keep the
6194 present state of the chip and all its resources.
6195
6196 f_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
6197 f_usChanIndex Channel index.
6198 f_usNewTsstIndex Tsst index in the TSST control memory.
6199
6200 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6201 #if !SKIP_Oct6100ApiWriteTsstAddStructs
6202 UINT32 Oct6100ApiWriteTsstAddStructs(
6203 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6204 IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
6205 IN UINT16 f_usChanIndex,
6206 IN UINT16 f_usNewTsstIndex )
6207 {
6208 tPOCT6100_API_CHANNEL pChanEntry;
6209 tOCT6100_WRITE_PARAMS WriteParams;
6210 UINT32 ulResult = cOCT6100_ERR_OK;
6211 UINT16 usTsiMemIndex;
6212 UINT32 ulNumTssts = 1;
6213
6214
6215 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6216
6217 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6218
6219 /*=======================================================================*/
6220 /* Get a pointer to the channel's list entry. */
6221
6222 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6223
6224 switch( f_pChannelTsstAdd->ulPort )
6225 {
6226 case cOCT6100_CHANNEL_PORT_ROUT:
6227 usTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
6228 ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6229 break;
6230 case cOCT6100_CHANNEL_PORT_SOUT:
6231 usTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
6232 ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6233 break;
6234 default:
6235 return cOCT6100_ERR_FATAL_D;
6236 }
6237
6238
6239 /* Write the new entry now.*/
6240 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usNewTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6241
6242 WriteParams.usWriteData = cOCT6100_TSST_CONTROL_MEM_OUTPUT_TSST;
6243 WriteParams.usWriteData |= (UINT16)( pChanEntry->CodecConfig.byAdpcmNibblePosition << cOCT6100_TSST_CONTROL_MEM_NIBBLE_POS_OFFSET );
6244 WriteParams.usWriteData |= (UINT16)( (ulNumTssts - 1) << cOCT6100_TSST_CONTROL_MEM_TSST_NUM_OFFSET );
6245 WriteParams.usWriteData |= (UINT16)( usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK );
6246 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6247 if ( ulResult != cOCT6100_ERR_OK )
6248 return ulResult;
6249
6250 return cOCT6100_ERR_OK;
6251 }
6252 #endif
6253
6254
6255
6256
6257 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6258
6259 Function: Oct6100ApiUpdateTsstAddChanEntry
6260
6261 Description: Update the associated channel API entry to add the new broacast TSST.
6262
6263 -------------------------------------------------------------------------------
6264 | Argument | Description
6265 -------------------------------------------------------------------------------
6266 f_pApiInstance Pointer to API instance. This memory is used to keep the
6267 present state of the chip and all its resources.
6268
6269 f_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
6270 f_usChanIndex Channel index.
6271 f_usNewTsstIndex TSST index within the TSST control memory.
6272 f_usNewTsstEntry TSST entry within the API TSST list.
6273
6274 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6275 #if !SKIP_Oct6100ApiUpdateTsstAddChanEntry
6276 UINT32 Oct6100ApiUpdateTsstAddChanEntry(
6277 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6278 IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
6279 IN UINT16 f_usChanIndex,
6280 IN UINT16 f_usNewTsstIndex,
6281 IN UINT16 f_usNewTsstEntry )
6282 {
6283 tPOCT6100_API_CHANNEL pChanEntry;
6284 tPOCT6100_API_TSST_ENTRY pTsstEntry;
6285
6286 /*=======================================================================*/
6287 /* Get a pointer to the channel's list entry. */
6288
6289 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6290 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, f_usNewTsstEntry );
6291
6292 /* Update the channel entry.*/
6293 if ( f_pChannelTsstAdd->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6294 {
6295 /* Add the new TSST entry to the broadcast list.*/
6296 pTsstEntry->usNextEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6297 pTsstEntry->usTsstMemoryIndex = (UINT16)f_usNewTsstIndex;
6298 pTsstEntry->usTsstValue = (UINT16)( (f_pChannelTsstAdd->ulTimeslot << 5) | f_pChannelTsstAdd->ulStream );
6299
6300 /* Modify the first entry pointer.*/
6301 pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = f_usNewTsstEntry;
6302
6303 /* Increment the number of broadcast TSST. */
6304 pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry++;
6305
6306 }
6307 else /* f_pChannelTsstAdd->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
6308 {
6309 /* Add the new TSST entry to the broadcast list.*/
6310 pTsstEntry->usNextEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6311 pTsstEntry->usTsstMemoryIndex = (UINT16)f_usNewTsstIndex;
6312 pTsstEntry->usTsstValue = (UINT16)( (f_pChannelTsstAdd->ulTimeslot << 5) | f_pChannelTsstAdd->ulStream );
6313
6314 /* Modify the first entry pointer.*/
6315 pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = f_usNewTsstEntry;
6316
6317 /* Increment the number of broadcast TSST. */
6318 pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry++;
6319 }
6320
6321 return cOCT6100_ERR_OK;
6322 }
6323 #endif
6324
6325
6326
6327
6328
6329
6330
6331
6332 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6333
6334 Function: Oct6100ChannelBroadcastTsstRemoveSer
6335
6336 Description: Removes a broadcast TSST from one of the output port of an
6337 echo cancellation channel.
6338
6339 -------------------------------------------------------------------------------
6340 | Argument | Description
6341 -------------------------------------------------------------------------------
6342 f_pApiInstance Pointer to API instance. This memory is used to keep the
6343 present state of the chip and all its resources.
6344
6345 f_pChannelTsstRemove Pointer to TSST remove structure.
6346
6347 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6348 #if !SKIP_Oct6100ChannelBroadcastTsstRemoveSer
6349 UINT32 Oct6100ChannelBroadcastTsstRemoveSer(
6350 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6351 IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove)
6352 {
6353 UINT16 usChanIndex;
6354 UINT16 usTsstIndex;
6355 UINT16 usTsstEntry;
6356 UINT16 usPrevTsstEntry;
6357 UINT32 ulResult;
6358
6359 ulResult = Oct6100ApiAssertChanTsstRemoveParams( f_pApiInstance, f_pChannelTsstRemove, &usChanIndex, &usTsstIndex, &usTsstEntry, &usPrevTsstEntry );
6360 if ( ulResult != cOCT6100_ERR_OK )
6361 return ulResult;
6362
6363 ulResult = Oct6100ApiInvalidateTsstRemoveStructs( f_pApiInstance, usChanIndex, usTsstIndex, f_pChannelTsstRemove->ulPort, f_pChannelTsstRemove->fRemoveAll );
6364 if ( ulResult != cOCT6100_ERR_OK )
6365 return ulResult;
6366
6367 ulResult = Oct6100ApiReleaseTsstRemoveResources( f_pApiInstance, f_pChannelTsstRemove, usChanIndex, usTsstIndex, usTsstEntry, usPrevTsstEntry );
6368 if ( ulResult != cOCT6100_ERR_OK )
6369 return ulResult;
6370
6371 return cOCT6100_ERR_OK;
6372 }
6373 #endif
6374
6375 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6376
6377 Function: Oct6100ApiAssertChanTsstRemoveParams
6378
6379 Description: Verify the validity of the tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE
6380 structure.
6381
6382 -------------------------------------------------------------------------------
6383 | Argument | Description
6384 -------------------------------------------------------------------------------
6385 f_pApiInstance Pointer to API instance. This memory is used to keep the
6386 present state of the chip and all its resources.
6387
6388 f_pChannelTsstRemove Pointer to echo cancellation channel open configuration structure.
6389 f_pulChanIndex Pointer to a channel index.
6390 f_pulNewTsstIndex Pointer to a TSST index within the TSST control memory.
6391 f_pulNewTsstEntry Pointer to a TSST entry within the API TSST list.
6392 f_pulPrevTsstEntry Pointer to the previous TSST entry.
6393
6394 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6395 #if !SKIP_Oct6100ApiAssertChanTsstRemoveParams
6396 UINT32 Oct6100ApiAssertChanTsstRemoveParams(
6397 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6398 IN tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove,
6399 OUT PUINT16 f_pusChanIndex,
6400 OUT PUINT16 f_pusTsstIndex,
6401 OUT PUINT16 f_pusTsstEntry,
6402 OUT PUINT16 f_pusPrevTsstEntry )
6403 {
6404 tPOCT6100_API_CHANNEL pChanEntry;
6405 tPOCT6100_API_TSST_ENTRY pTsstEntry;
6406 UINT32 ulResult;
6407 UINT32 ulNumTssts = 1;
6408 UINT32 ulEntryOpenCnt;
6409 UINT16 usCurrentEntry;
6410 UINT16 usTsstValue;
6411 UINT16 usNumEntry;
6412
6413 /* Check the provided handle. */
6414 if ( (f_pChannelTsstRemove->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
6415 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6416
6417 *f_pusChanIndex = (UINT16)( f_pChannelTsstRemove->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
6418 if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
6419 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6420
6421 /*=======================================================================*/
6422 /* Get a pointer to the channel's list entry. */
6423
6424 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
6425
6426 /* Extract the entry open count from the provided handle. */
6427 ulEntryOpenCnt = ( f_pChannelTsstRemove->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
6428
6429 /* Check for errors. */
6430 if ( pChanEntry->fReserved != TRUE )
6431 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
6432 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
6433 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6434
6435 /*=======================================================================*/
6436
6437 /* validate the port parameter.*/
6438 if ( f_pChannelTsstRemove->ulPort != cOCT6100_CHANNEL_PORT_ROUT &&
6439 f_pChannelTsstRemove->ulPort != cOCT6100_CHANNEL_PORT_SOUT )
6440 return cOCT6100_ERR_CHANNEL_TSST_REMOVE_PORT;
6441
6442 /* Verify that the requested entry is present in the channel's port broadcast TSST.*/
6443 if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6444 {
6445 usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6446 usNumEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry;
6447 }
6448 else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
6449 {
6450 usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6451 usNumEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry;
6452 }
6453
6454 /* Verify if at least one TSST is present on the channel port.*/
6455 if ( usNumEntry == 0 )
6456 return cOCT6100_ERR_CHANNEL_TSST_REMOVE_NO_BROADCAST_TSST;
6457
6458 /* Get the required number of TSST based on the port.*/
6459 switch( f_pChannelTsstRemove->ulPort )
6460 {
6461 case cOCT6100_CHANNEL_PORT_ROUT:
6462 ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6463 break;
6464 case cOCT6100_CHANNEL_PORT_SOUT:
6465 ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6466 break;
6467 default:
6468 return cOCT6100_ERR_FATAL_E;
6469 }
6470
6471 /* Initialize the TSST entry to invalid.*/
6472 *f_pusTsstEntry = cOCT6100_INVALID_INDEX;
6473 *f_pusPrevTsstEntry = cOCT6100_INVALID_INDEX;
6474 *f_pusTsstIndex = cOCT6100_INVALID_INDEX;
6475
6476 if ( f_pChannelTsstRemove->fRemoveAll != TRUE )
6477 {
6478 /* Check the validity of the timeslot and Stream.*/
6479 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
6480 ulNumTssts,
6481 f_pChannelTsstRemove->ulTimeslot,
6482 f_pChannelTsstRemove->ulStream,
6483 cOCT6100_OUTPUT_TSST );
6484 if ( ulResult != cOCT6100_ERR_OK )
6485 {
6486 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
6487 {
6488 return cOCT6100_ERR_CHANNEL_TSST_REMOVE_TIMESLOT;
6489 }
6490 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
6491 {
6492 return cOCT6100_ERR_CHANNEL_TSST_REMOVE_STREAM;
6493 }
6494 else
6495 {
6496 return ulResult;
6497 }
6498 }
6499
6500 /* Set the TSST value based on the timeslot and stream value.*/
6501 usTsstValue = (UINT16)( (f_pChannelTsstRemove->ulTimeslot << 5) | f_pChannelTsstRemove->ulStream );
6502
6503 while( usCurrentEntry != cOCT6100_INVALID_INDEX )
6504 {
6505 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6506
6507 if ( usTsstValue == pTsstEntry->usTsstValue )
6508 {
6509 /* A match was found.*/
6510 *f_pusTsstEntry = usCurrentEntry;
6511 *f_pusTsstIndex = pTsstEntry->usTsstMemoryIndex;
6512 break;
6513 }
6514
6515 /* Move on to the next entry.*/
6516 *f_pusPrevTsstEntry = usCurrentEntry;
6517 usCurrentEntry = pTsstEntry->usNextEntry;
6518 }
6519
6520 if ( *f_pusTsstEntry == cOCT6100_INVALID_INDEX )
6521 return cOCT6100_ERR_CHANNEL_TSST_REMOVE_INVALID_TSST;
6522 }
6523
6524 return cOCT6100_ERR_OK;
6525 }
6526 #endif
6527
6528
6529 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6530
6531 Function: Oct6100ApiInvalidateTsstRemoveStructs
6532
6533 Description: Invalidate the entry of the broadcast TSST.
6534
6535 -------------------------------------------------------------------------------
6536 | Argument | Description
6537 -------------------------------------------------------------------------------
6538 f_pApiInstance Pointer to API instance. This memory is used to keep the
6539 present state of the chip and all its resources.
6540
6541 f_usChanIndex Channel index.
6542 f_usTsstIndex TSST index within the TSST control memory.
6543 f_ulPort Channel port where the TSST are removed from. (only used if remove all == TRUE)
6544 f_fRemoveAll Remove all flag.
6545
6546 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6547 #if !SKIP_Oct6100ApiInvalidateTsstRemoveStructs
6548 UINT32 Oct6100ApiInvalidateTsstRemoveStructs(
6549 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6550 IN UINT16 f_usChanIndex,
6551 IN UINT16 f_usTsstIndex,
6552 IN UINT32 f_ulPort,
6553 IN BOOL f_fRemoveAll )
6554 {
6555 tOCT6100_WRITE_PARAMS WriteParams;
6556 UINT32 ulResult;
6557
6558 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6559
6560 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6561
6562 if ( f_fRemoveAll == FALSE )
6563 {
6564 /* Deactivate the entry now.*/
6565 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6566 WriteParams.usWriteData = 0x0000;
6567
6568 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6569 if ( ulResult != cOCT6100_ERR_OK )
6570 return ulResult;
6571 }
6572 else /* f_fRemoveAll == TRUE */
6573 {
6574 tPOCT6100_API_CHANNEL pChanEntry;
6575 tPOCT6100_API_TSST_ENTRY pTsstEntry;
6576 UINT16 usTsstEntry;
6577
6578 /*=======================================================================*/
6579 /* Get a pointer to the channel's list entry. */
6580
6581 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6582
6583 /* Clear all entry associated to the selected port.*/
6584 if ( f_ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6585 usTsstEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6586 else
6587 usTsstEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6588
6589 do
6590 {
6591 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usTsstEntry );
6592
6593 /* Deactivate the entry now.*/
6594 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( ( pTsstEntry->usTsstMemoryIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6595 WriteParams.usWriteData = 0x0000;
6596
6597 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6598 if ( ulResult != cOCT6100_ERR_OK )
6599 return ulResult;
6600
6601 usTsstEntry = pTsstEntry->usNextEntry;
6602
6603 } while ( usTsstEntry != cOCT6100_INVALID_INDEX );
6604 }
6605
6606 return cOCT6100_ERR_OK;
6607 }
6608 #endif
6609
6610
6611 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6612
6613 Function: Oct6100ApiReleaseTsstRemoveResources
6614
6615 Description: Release all API resources associated to the Removed TSST and
6616 update the channel entry accordingly.
6617
6618 -------------------------------------------------------------------------------
6619 | Argument | Description
6620 -------------------------------------------------------------------------------
6621 f_pApiInstance Pointer to API instance. This memory is used to keep the
6622 present state of the chip and all its resources.
6623
6624 f_pChannelTsstRemove Pointer to echo cancellation channel open configuration structure.
6625 f_usChanIndex Channel index.
6626 f_usTsstIndex TSST index within the TSST control memory.
6627 f_usTsstEntry TSST entry within the API's TSST list.
6628 f_usPrevTsstEntry Previous TSST entry within the API's TSST list.
6629
6630 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6631 #if !SKIP_Oct6100ApiReleaseTsstRemoveResources
6632 UINT32 Oct6100ApiReleaseTsstRemoveResources(
6633 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6634 IN tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove,
6635 IN UINT16 f_usChanIndex,
6636 IN UINT16 f_usTsstIndex,
6637 IN UINT16 f_usTsstEntry,
6638 IN UINT16 f_usPrevTsstEntry )
6639 {
6640 tPOCT6100_API_CHANNEL pChanEntry;
6641 tPOCT6100_API_TSST_ENTRY pTsstEntry;
6642 tPOCT6100_API_TSST_ENTRY pPrevTsstEntry;
6643 UINT16 usCurrentEntry;
6644 UINT32 ulResult;
6645 UINT32 ulTimeslot;
6646 UINT32 ulStream;
6647 /*=======================================================================*/
6648 /* Get a pointer to the channel's list entry. */
6649
6650 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6651
6652 if ( f_pChannelTsstRemove->fRemoveAll == FALSE )
6653 {
6654 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, f_usTsstEntry );
6655
6656 /* Update the channel entry.*/
6657 if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6658 {
6659 /* Check if the entry was the first in the list.*/
6660 if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX )
6661 {
6662 pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry;
6663 }
6664 else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */
6665 {
6666 /* Get a pointer to the previous entry.*/
6667 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPrevTsstEntry, f_usPrevTsstEntry );
6668 pPrevTsstEntry->usNextEntry = pTsstEntry->usNextEntry;
6669 }
6670
6671 /* Decrement the number of entry.*/
6672 pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry--;
6673 }
6674 else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
6675 {
6676 /* Check if the entry was the first in the list.*/
6677 if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX )
6678 {
6679 pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry;
6680 }
6681 else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */
6682 {
6683 /* Get a pointer to the previous entry.*/
6684 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPrevTsstEntry, f_usPrevTsstEntry );
6685 pPrevTsstEntry->usNextEntry = pTsstEntry->usNextEntry;
6686 }
6687
6688 /* Decrement the number of entry.*/
6689 pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry--;
6690 }
6691
6692 ulTimeslot = pTsstEntry->usTsstValue >> 5;
6693 ulStream = pTsstEntry->usTsstValue & 0x1F;
6694
6695 /* Release the entry.*/
6696 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
6697 ulTimeslot,
6698 ulStream,
6699 cOCT6100_NUMBER_TSSTS_1,
6700 cOCT6100_OUTPUT_TSST,
6701 f_usTsstEntry );
6702 if ( ulResult != cOCT6100_ERR_OK )
6703 return ulResult;
6704 }
6705 else /* f_pChannelTsstRemove->fRemoveAll == TRUE */
6706 {
6707
6708 /* Update the channel entry.*/
6709 if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6710 usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6711 else
6712 usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6713
6714 do
6715 {
6716 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6717
6718 ulTimeslot = pTsstEntry->usTsstValue >> 5;
6719 ulStream = pTsstEntry->usTsstValue & 0x1F;
6720
6721 /* Release the entry.*/
6722 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
6723 ulTimeslot,
6724 ulStream,
6725 cOCT6100_NUMBER_TSSTS_1,
6726 cOCT6100_OUTPUT_TSST,
6727 usCurrentEntry ); /* Release the entry.*/
6728 if ( ulResult != cOCT6100_ERR_OK )
6729 return ulResult;
6730
6731 usCurrentEntry = pTsstEntry->usNextEntry;
6732
6733 /* Clear the previous node.*/
6734 pTsstEntry->usTsstMemoryIndex = 0xFFFF;
6735 pTsstEntry->usTsstValue = 0xFFFF;
6736 pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
6737
6738 } while ( usCurrentEntry != cOCT6100_INVALID_INDEX );
6739
6740 /* Reset the channel status.*/
6741 if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6742 {
6743 pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
6744 pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0;
6745 }
6746 else
6747 {
6748 pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
6749 pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry = 0;
6750 }
6751 }
6752 return cOCT6100_ERR_OK;
6753 }
6754 #endif
6755
6756
6757 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6758
6759 Function: Oct6100ApiChannelGetStatsSer
6760
6761 Description: Serialized function that returns all the stats of the specified
6762 channel.
6763
6764 -------------------------------------------------------------------------------
6765 | Argument | Description
6766 -------------------------------------------------------------------------------
6767 f_pApiInstance Pointer to API instance. This memory is used to keep the
6768 present state of the chip and all its resources.
6769
6770 f_pChannelStats Pointer to a channel stats structure.
6771 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6772 #if !SKIP_Oct6100ApiChannelGetStatsSer
6773 UINT32 Oct6100ApiChannelGetStatsSer(
6774 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6775 IN tPOCT6100_CHANNEL_STATS f_pChannelStats )
6776 {
6777 tOCT6100_READ_PARAMS ReadParams;
6778 tOCT6100_READ_BURST_PARAMS BurstParams;
6779 tPOCT6100_API_CHANNEL pChanEntry;
6780 tPOCT6100_SHARED_INFO pSharedInfo;
6781 tPOCT6100_API_TSST_ENTRY pTsstEntry;
6782 UINT32 ulEntryOpenCnt;
6783 UINT16 usCurrentEntry;
6784 UINT16 usTsstCount;
6785 UINT32 ulBaseAddress;
6786 UINT32 ulFeatureBytesOffset;
6787 UINT32 ulFeatureBitOffset;
6788 UINT32 ulFeatureFieldLength;
6789 UINT32 ulTempData;
6790 UINT32 ulMask;
6791 UINT16 usChanIndex;
6792 UINT16 ausReadData[ 32 ];
6793
6794 BYTE byRinEnergyRaw;
6795 BYTE bySinEnergyRaw;
6796 BYTE bySoutEnergyRaw;
6797 INT32 lSoutEnergyIndB;
6798 BYTE byCnEnergyRaw;
6799 UINT16 usEchoDelayInFrames;
6800 UINT16 usErlRaw;
6801
6802 UINT32 ulResult;
6803 UINT16 usReadData;
6804
6805 /* Get local pointer to shared portion of instance. */
6806 pSharedInfo = f_pApiInstance->pSharedInfo;
6807
6808 BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
6809
6810 BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6811 BurstParams.pusReadData = ausReadData;
6812
6813 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
6814
6815 ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6816 ReadParams.pusReadData = &usReadData;
6817
6818 /* Check the reset stats flag.*/
6819 if ( f_pChannelStats->fResetStats != TRUE && f_pChannelStats->fResetStats != FALSE )
6820 return cOCT6100_ERR_CHANNEL_STATS_RESET;
6821
6822 /* Check the provided handle. */
6823 if ( cOCT6100_HNDL_TAG_CHANNEL != (f_pChannelStats->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) )
6824 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6825
6826 usChanIndex = (UINT16)( f_pChannelStats->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
6827 if ( usChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
6828 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6829
6830 /*=======================================================================*/
6831 /* Get a pointer to the channel's list entry. */
6832
6833 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, usChanIndex )
6834
6835 /* Extract the entry open count from the provided handle. */
6836 ulEntryOpenCnt = ( f_pChannelStats->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
6837
6838 /* Check for errors. */
6839 if ( pChanEntry->fReserved != TRUE )
6840 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
6841 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
6842 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6843
6844 /*=======================================================================*/
6845
6846 /* Check the value of the max broadcast tsst.*/
6847 if ( f_pChannelStats->TdmConfig.ulMaxBroadcastTssts > cOCT6100_MAX_TSSTS )
6848 return cOCT6100_ERR_CHANNEL_GET_STATS_MAX_BROADCAST_TSST;
6849
6850 if ( f_pChannelStats->TdmConfig.ulMaxBroadcastTssts != 0 )
6851 {
6852 /* Check if memory was allocated by the user for the stream and timeslot values.*/
6853 if ( f_pChannelStats->TdmConfig.pulRoutBroadcastTimeslot == NULL )
6854 return cOCT6100_ERR_CHANNEL_ROUT_BROADCAST_TIMESLOT;
6855
6856 if ( f_pChannelStats->TdmConfig.pulRoutBroadcastStream == NULL )
6857 return cOCT6100_ERR_CHANNEL_ROUT_BROADCAST_STREAM;
6858
6859 if ( f_pChannelStats->TdmConfig.pulSoutBroadcastTimeslot == NULL )
6860 return cOCT6100_ERR_CHANNEL_SOUT_BROADCAST_TIMESLOT;
6861
6862 if ( f_pChannelStats->TdmConfig.pulSoutBroadcastStream == NULL )
6863 return cOCT6100_ERR_CHANNEL_SOUT_BROADCAST_STREAM;
6864 }
6865
6866 /* Copy the general configuration.*/
6867 f_pChannelStats->ulUserChanId = pChanEntry->ulUserChanId;
6868 f_pChannelStats->ulEchoOperationMode = pChanEntry->byEchoOperationMode;
6869 f_pChannelStats->fEnableToneDisabler = pChanEntry->fEnableToneDisabler;
6870 f_pChannelStats->ulMutePortsMask = pChanEntry->usMutedPorts;
6871 f_pChannelStats->fEnableExtToneDetection = pChanEntry->fEnableExtToneDetection;
6872
6873
6874
6875 /* Copy the TDM configuration.*/
6876 f_pChannelStats->TdmConfig.ulNumRoutBroadcastTssts = pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry;
6877 f_pChannelStats->TdmConfig.ulNumSoutBroadcastTssts = pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry;
6878
6879 f_pChannelStats->TdmConfig.ulSinNumTssts = pChanEntry->TdmConfig.bySinNumTssts;
6880 f_pChannelStats->TdmConfig.ulSinTimeslot = pChanEntry->TdmConfig.usSinTimeslot;
6881 f_pChannelStats->TdmConfig.ulSinStream = pChanEntry->TdmConfig.usSinStream;
6882 f_pChannelStats->TdmConfig.ulSinPcmLaw = pChanEntry->TdmConfig.bySinPcmLaw;
6883
6884 f_pChannelStats->TdmConfig.ulSoutNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6885 f_pChannelStats->TdmConfig.ulSoutTimeslot = pChanEntry->TdmConfig.usSoutTimeslot;
6886 f_pChannelStats->TdmConfig.ulSoutStream = pChanEntry->TdmConfig.usSoutStream;
6887 f_pChannelStats->TdmConfig.ulSoutPcmLaw = pChanEntry->TdmConfig.bySoutPcmLaw;
6888
6889 /* Copy the SOUT Broadcast TSST into the Stream and timeslot array.*/
6890 usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6891 for( usTsstCount = 0; (usTsstCount < pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry) && (usTsstCount < f_pChannelStats->TdmConfig.ulMaxBroadcastTssts); usTsstCount++ )
6892 {
6893 if ( usCurrentEntry == cOCT6100_INVALID_INDEX )
6894 return cOCT6100_ERR_FATAL_F;
6895
6896 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6897
6898 f_pChannelStats->TdmConfig.pulSoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue & 0x1F;
6899 f_pChannelStats->TdmConfig.pulSoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue >> 5;
6900
6901 /* Obtain the index of the next entry.*/
6902 usCurrentEntry = pTsstEntry->usNextEntry;
6903 }
6904
6905 /* Check if all Sout Broadcast TSST were returned.*/
6906 if ( usTsstCount < pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry )
6907 {
6908 f_pChannelStats->TdmConfig.fMoreSoutBroadcastTssts = TRUE;
6909 }
6910 else /* usTsstCount >= pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry */
6911 {
6912 f_pChannelStats->TdmConfig.fMoreSoutBroadcastTssts = FALSE;
6913 }
6914
6915 f_pChannelStats->TdmConfig.ulRinNumTssts = pChanEntry->TdmConfig.byRinNumTssts;
6916 f_pChannelStats->TdmConfig.ulRinTimeslot = pChanEntry->TdmConfig.usRinTimeslot;
6917 f_pChannelStats->TdmConfig.ulRinStream = pChanEntry->TdmConfig.usRinStream;
6918 f_pChannelStats->TdmConfig.ulRinPcmLaw = pChanEntry->TdmConfig.byRinPcmLaw;
6919
6920 f_pChannelStats->TdmConfig.ulRoutNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6921 f_pChannelStats->TdmConfig.ulRoutTimeslot = pChanEntry->TdmConfig.usRoutTimeslot;
6922 f_pChannelStats->TdmConfig.ulRoutStream = pChanEntry->TdmConfig.usRoutStream;
6923 f_pChannelStats->TdmConfig.ulRoutPcmLaw = pChanEntry->TdmConfig.byRoutPcmLaw;
6924
6925
6926 /* Copy the ROUT Broadcast TSST into the Stream and timeslot array.*/
6927 usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6928 for( usTsstCount = 0; (usTsstCount < pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry) && (usTsstCount < f_pChannelStats->TdmConfig.ulMaxBroadcastTssts); usTsstCount++ )
6929 {
6930 if ( usCurrentEntry == cOCT6100_INVALID_INDEX )
6931 return cOCT6100_ERR_FATAL_10;
6932
6933 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6934
6935 f_pChannelStats->TdmConfig.pulRoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue & 0x1F;
6936 f_pChannelStats->TdmConfig.pulRoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue >> 5;
6937
6938 /* Obtain the index of the next entry.*/
6939 usCurrentEntry = pTsstEntry->usNextEntry;
6940 }
6941
6942 /* Check if all Rout Broadcast TSST were returned.*/
6943 if ( usTsstCount < pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry )
6944 {
6945 f_pChannelStats->TdmConfig.fMoreRoutBroadcastTssts = TRUE;
6946 }
6947 else /* usTsstCount >= pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry */
6948 {
6949 f_pChannelStats->TdmConfig.fMoreRoutBroadcastTssts = FALSE;
6950 }
6951
6952 /* Copy the VQE configuration.*/
6953 f_pChannelStats->VqeConfig.fEnableNlp = pChanEntry->VqeConfig.fEnableNlp;
6954 f_pChannelStats->VqeConfig.ulComfortNoiseMode = pChanEntry->VqeConfig.byComfortNoiseMode;
6955 f_pChannelStats->VqeConfig.fEnableTailDisplacement = pChanEntry->VqeConfig.fEnableTailDisplacement;
6956 if ( pChanEntry->VqeConfig.usTailDisplacement != cOCT6100_AUTO_SELECT_TAIL )
6957 f_pChannelStats->VqeConfig.ulTailDisplacement = pChanEntry->VqeConfig.usTailDisplacement;
6958 else
6959 f_pChannelStats->VqeConfig.ulTailDisplacement = f_pApiInstance->pSharedInfo->ChipConfig.usTailDisplacement;
6960
6961 if ( pChanEntry->VqeConfig.usTailLength != cOCT6100_AUTO_SELECT_TAIL )
6962 f_pChannelStats->VqeConfig.ulTailLength = pChanEntry->VqeConfig.usTailLength;
6963 else
6964 f_pChannelStats->VqeConfig.ulTailLength = f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength;
6965
6966
6967
6968 f_pChannelStats->VqeConfig.fSinDcOffsetRemoval = pChanEntry->VqeConfig.fSinDcOffsetRemoval;
6969 f_pChannelStats->VqeConfig.fRinDcOffsetRemoval = pChanEntry->VqeConfig.fRinDcOffsetRemoval;
6970 f_pChannelStats->VqeConfig.fRinLevelControl = pChanEntry->VqeConfig.fRinLevelControl;
6971 f_pChannelStats->VqeConfig.fSoutLevelControl = pChanEntry->VqeConfig.fSoutLevelControl;
6972 f_pChannelStats->VqeConfig.fRinAutomaticLevelControl = pChanEntry->VqeConfig.fRinAutomaticLevelControl;
6973 f_pChannelStats->VqeConfig.fSoutAutomaticLevelControl = pChanEntry->VqeConfig.fSoutAutomaticLevelControl;
6974 f_pChannelStats->VqeConfig.fRinHighLevelCompensation = pChanEntry->VqeConfig.fRinHighLevelCompensation;
6975 f_pChannelStats->VqeConfig.fSoutAdaptiveNoiseReduction = pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction;
6976 f_pChannelStats->VqeConfig.fSoutNoiseBleaching = pChanEntry->VqeConfig.fSoutNoiseBleaching;
6977 f_pChannelStats->VqeConfig.fSoutConferencingNoiseReduction = pChanEntry->VqeConfig.fSoutConferencingNoiseReduction;
6978 f_pChannelStats->VqeConfig.lRinLevelControlGainDb = pChanEntry->VqeConfig.chRinLevelControlGainDb;
6979 f_pChannelStats->VqeConfig.lSoutLevelControlGainDb = pChanEntry->VqeConfig.chSoutLevelControlGainDb;
6980 f_pChannelStats->VqeConfig.lRinAutomaticLevelControlTargetDb = pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb;
6981 f_pChannelStats->VqeConfig.lSoutAutomaticLevelControlTargetDb = pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb;
6982 f_pChannelStats->VqeConfig.lRinHighLevelCompensationThresholdDb = pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb;
6983 f_pChannelStats->VqeConfig.fAcousticEcho = pChanEntry->VqeConfig.fAcousticEcho;
6984 f_pChannelStats->VqeConfig.fDtmfToneRemoval = pChanEntry->VqeConfig.fDtmfToneRemoval;
6985
6986 f_pChannelStats->VqeConfig.lDefaultErlDb = pChanEntry->VqeConfig.chDefaultErlDb;
6987 f_pChannelStats->VqeConfig.lAecDefaultErlDb = pChanEntry->VqeConfig.chAecDefaultErlDb;
6988 f_pChannelStats->VqeConfig.ulAecTailLength = pChanEntry->VqeConfig.usAecTailLength;
6989 f_pChannelStats->VqeConfig.lAnrSnrEnhancementDb = pChanEntry->VqeConfig.chAnrSnrEnhancementDb;
6990 f_pChannelStats->VqeConfig.ulAnrVoiceNoiseSegregation = pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation;
6991 f_pChannelStats->VqeConfig.ulToneDisablerVqeActivationDelay = pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay;
6992 f_pChannelStats->VqeConfig.ulNonLinearityBehaviorA = pChanEntry->VqeConfig.byNonLinearityBehaviorA;
6993 f_pChannelStats->VqeConfig.ulNonLinearityBehaviorB = pChanEntry->VqeConfig.byNonLinearityBehaviorB;
6994 f_pChannelStats->VqeConfig.ulDoubleTalkBehavior = pChanEntry->VqeConfig.byDoubleTalkBehavior;
6995 f_pChannelStats->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb;
6996 f_pChannelStats->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb;
6997 f_pChannelStats->VqeConfig.fSoutNaturalListenerEnhancement = pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement;
6998 f_pChannelStats->VqeConfig.fRoutNoiseReduction = pChanEntry->VqeConfig.fRoutNoiseReduction;
6999 f_pChannelStats->VqeConfig.lRoutNoiseReductionLevelGainDb = pChanEntry->VqeConfig.chRoutNoiseReductionLevelGainDb;
7000 f_pChannelStats->VqeConfig.fEnableMusicProtection = pChanEntry->VqeConfig.fEnableMusicProtection;
7001 f_pChannelStats->VqeConfig.fIdleCodeDetection = pChanEntry->VqeConfig.fIdleCodeDetection;
7002
7003 /* Copy the CODEC configuration.*/
7004 f_pChannelStats->CodecConfig.ulAdpcmNibblePosition = pChanEntry->CodecConfig.byAdpcmNibblePosition;
7005
7006 f_pChannelStats->CodecConfig.ulEncoderPort = pChanEntry->CodecConfig.byEncoderPort;
7007 f_pChannelStats->CodecConfig.ulEncodingRate = pChanEntry->CodecConfig.byEncodingRate;
7008
7009 f_pChannelStats->CodecConfig.ulDecoderPort = pChanEntry->CodecConfig.byDecoderPort;
7010 f_pChannelStats->CodecConfig.ulDecodingRate = pChanEntry->CodecConfig.byDecodingRate;
7011
7012 f_pChannelStats->CodecConfig.fEnableSilenceSuppression = pChanEntry->CodecConfig.fEnableSilenceSuppression;
7013 f_pChannelStats->CodecConfig.ulPhase = pChanEntry->CodecConfig.byPhase;
7014 f_pChannelStats->CodecConfig.ulPhasingType = pChanEntry->CodecConfig.byPhasingType;
7015
7016 if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
7017 {
7018 tPOCT6100_API_PHASING_TSST pPhasingTsstEntry;
7019
7020 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingTsstEntry, pChanEntry->usPhasingTsstIndex );
7021
7022 f_pChannelStats->CodecConfig.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingTsstEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pChanEntry->usPhasingTsstIndex;
7023 }
7024 else
7025 {
7026 f_pChannelStats->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
7027 }
7028
7029
7030 /* Reset the stats and exit if the reset flag is set.*/
7031 if ( f_pChannelStats->fResetStats == TRUE )
7032 {
7033 pChanEntry->sMaxERLE = cOCT6100_INVALID_SIGNED_STAT_W;
7034 pChanEntry->sMaxERL = cOCT6100_INVALID_SIGNED_STAT_W;
7035 pChanEntry->usMaxEchoDelay = cOCT6100_INVALID_STAT_W;
7036 }
7037
7038 /*---------------------------------------------------------------------*/
7039 /* Update the API internal stats.*/
7040
7041 BurstParams.ulReadAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
7042 BurstParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsOfst;
7043 BurstParams.ulReadLength = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsSize / 2; /* Length in words.*/
7044
7045 mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult );
7046 if ( ulResult != cOCT6100_ERR_OK )
7047 return ulResult;
7048
7049 /* Check if the energy stat are found in the new memory location. */
7050 if ( ( pSharedInfo->ImageInfo.fRinEnergyStat == TRUE )
7051 && ( pSharedInfo->ImageInfo.fSoutEnergyStat == TRUE ) )
7052 {
7053 ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.usDwordOffset * 4;
7054 ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.byBitOffset;
7055 ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.byFieldSize;
7056
7057 ReadParams.ulReadAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
7058 ReadParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + ulFeatureBytesOffset;
7059
7060 /* Optimize this access by only reading the word we are interested in. */
7061 if ( ulFeatureBitOffset < 16 )
7062 ReadParams.ulReadAddress += 2;
7063
7064 /* Must read in memory directly since this value is changed by hardware */
7065 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
7066 if ( ulResult != cOCT6100_ERR_OK )
7067 return ulResult;
7068
7069 /* Move data at correct position according to what was read. */
7070 if ( ulFeatureBitOffset < 16 )
7071 ulTempData = usReadData;
7072 else
7073 ulTempData = usReadData << 16;
7074
7075 /* Clear previous value set in the feature field. */
7076 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7077
7078 ulTempData &= ulMask;
7079
7080 /* Shift to get value. */
7081 ulTempData = ulTempData >> ulFeatureBitOffset;
7082
7083 /* Overwrite value read the old way. */
7084 ausReadData[ 0 ] &= 0x00FF;
7085 ausReadData[ 0 ] |= (UINT16)( ( ulTempData << 8 ) & 0xFF00 );
7086
7087 ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.usDwordOffset * 4;
7088 ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.byBitOffset;
7089 ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.byFieldSize;
7090
7091 ReadParams.ulReadAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
7092 ReadParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + ulFeatureBytesOffset;
7093
7094 /* Optimize this access by only reading the word we are interested in. */
7095 if ( ulFeatureBitOffset < 16 )
7096 ReadParams.ulReadAddress += 2;
7097
7098 /* Must read in memory directly since this value is changed by hardware */
7099 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
7100 if ( ulResult != cOCT6100_ERR_OK )
7101 return ulResult;
7102
7103 /* Move data at correct position according to what was read. */
7104 if ( ulFeatureBitOffset < 16 )
7105 ulTempData = usReadData;
7106 else
7107 ulTempData = usReadData << 16;
7108
7109 /* Clear previous value set in the feature field. */
7110 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7111
7112 ulTempData &= ulMask;
7113
7114 /* Shift to get value. */
7115 ulTempData = ulTempData >> ulFeatureBitOffset;
7116
7117 /* Overwrite value read the old way. */
7118 ausReadData[ 1 ] &= 0x00FF;
7119 ausReadData[ 1 ] |= (UINT16)( ( ulTempData << 8 ) & 0xFF00 );
7120 }
7121
7122 byRinEnergyRaw = (BYTE)(( ausReadData[ 0 ] >> 8 ) & 0xFF);
7123 bySinEnergyRaw = (BYTE)(( ausReadData[ 0 ] >> 0 ) & 0xFF);
7124 bySoutEnergyRaw = (BYTE)(( ausReadData[ 1 ] >> 8 ) & 0xFF);
7125 byCnEnergyRaw = (BYTE)(( ausReadData[ 5 ] >> 8 ) & 0xFF);
7126
7127 usEchoDelayInFrames = (UINT16)(ausReadData[ 4 ]);
7128 usErlRaw = ausReadData[ 2 ];
7129
7130 pChanEntry->byToneDisablerStatus = (UINT8)(( ausReadData[ 5 ] >> 0 ) & 0xFF);
7131 if ( f_pChannelStats->fResetStats == TRUE )
7132 {
7133 pChanEntry->usNumEchoPathChangesOfst = (UINT16)(ausReadData[ 3 ]);
7134 pChanEntry->usNumEchoPathChanges = 0;
7135 }
7136 else /* if ( f_pChannelStats->fResetStats == FALSE ) */
7137 {
7138 pChanEntry->usNumEchoPathChanges = (UINT16)( ausReadData[ 3 ] - pChanEntry->usNumEchoPathChangesOfst );
7139 }
7140
7141 pChanEntry->sComfortNoiseLevel = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( byCnEnergyRaw ) & 0xFFFF );
7142 pChanEntry->sComfortNoiseLevel -= 12;
7143 pChanEntry->sRinLevel = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( byRinEnergyRaw ) & 0xFFFF );
7144 pChanEntry->sRinLevel -= 12;
7145 pChanEntry->sSinLevel = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( bySinEnergyRaw ) & 0xFFFF );
7146 pChanEntry->sSinLevel -= 12;
7147 lSoutEnergyIndB = Oct6100ApiOctFloatToDbEnergyByte( bySoutEnergyRaw );
7148 lSoutEnergyIndB -= 12;
7149
7150 /* Process some stats only if the channel is converged.*/
7151 if ( ( usEchoDelayInFrames != cOCT6100_INVALID_ECHO_DELAY )
7152 && ( pChanEntry->byEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN )
7153 && ( pChanEntry->byEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET ) )
7154 {
7155 /* Update the current ERL. */
7156 pChanEntry->sCurrentERL = (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( usErlRaw ) & 0xFFFF );
7157 pChanEntry->sCurrentERLE = (INT16)( ( lSoutEnergyIndB - pChanEntry->sSinLevel ) & 0xFFFF );
7158 pChanEntry->usCurrentEchoDelay = (UINT16)( usEchoDelayInFrames / 8 ); /* To convert in msec.*/
7159
7160 /* Update the max value if required.*/
7161 if ( pChanEntry->usCurrentEchoDelay > pChanEntry->usMaxEchoDelay ||
7162 pChanEntry->usMaxEchoDelay == cOCT6100_INVALID_STAT_W )
7163 {
7164 pChanEntry->usMaxEchoDelay = pChanEntry->usCurrentEchoDelay;
7165 }
7166
7167 if ( pChanEntry->sCurrentERL > pChanEntry->sMaxERL ||
7168 pChanEntry->sMaxERL == cOCT6100_INVALID_SIGNED_STAT_W )
7169 {
7170 pChanEntry->sMaxERL = pChanEntry->sCurrentERL;
7171 }
7172
7173 if ( pChanEntry->sCurrentERLE > pChanEntry->sMaxERLE ||
7174 pChanEntry->sMaxERLE == cOCT6100_INVALID_SIGNED_STAT_W )
7175 {
7176 pChanEntry->sMaxERLE = pChanEntry->sCurrentERLE;
7177 }
7178 }
7179 else
7180 {
7181 pChanEntry->sCurrentERLE = cOCT6100_INVALID_SIGNED_STAT_W;
7182 pChanEntry->sCurrentERL = cOCT6100_INVALID_SIGNED_STAT_W;
7183 pChanEntry->usCurrentEchoDelay = cOCT6100_INVALID_STAT_W;
7184 }
7185
7186 if ( f_pApiInstance->pSharedInfo->ImageInfo.fRinAppliedGainStat == TRUE )
7187 {
7188 /* Calculate base address for auto level control + high level compensation configuration. */
7189 ulBaseAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + ( usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
7190
7191 ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.usDwordOffset * 4;
7192 ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.byBitOffset;
7193 ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.byFieldSize;
7194
7195 ReadParams.ulReadAddress = ulBaseAddress + ulFeatureBytesOffset;
7196
7197 /* Optimize this access by only reading the word we are interested in. */
7198 if ( ulFeatureBitOffset < 16 )
7199 ReadParams.ulReadAddress += 2;
7200
7201 /* Must read in memory directly since this value is changed by hardware */
7202 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
7203 if ( ulResult != cOCT6100_ERR_OK )
7204 return ulResult;
7205
7206 /* Move data at correct position according to what was read. */
7207 if ( ulFeatureBitOffset < 16 )
7208 ulTempData = usReadData;
7209 else
7210 ulTempData = usReadData << 16;
7211
7212 /* Clear previous value set in the feature field.*/
7213 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7214
7215 ulTempData &= ulMask;
7216
7217 /* Shift to get value. */
7218 ulTempData = ulTempData >> ulFeatureBitOffset;
7219
7220 pChanEntry->sRinAppliedGain = (INT16)( 2 * (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)( ulTempData & 0xFFFF ) ) & 0xFFFF ) );
7221 }
7222
7223 if ( f_pApiInstance->pSharedInfo->ImageInfo.fSoutAppliedGainStat == TRUE )
7224 {
7225 /* Calculate base address for auto level control + high level compensation configuration. */
7226 ulBaseAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + ( usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
7227
7228 ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.usDwordOffset * 4;
7229 ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.byBitOffset;
7230 ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.byFieldSize;
7231
7232 ReadParams.ulReadAddress = ulBaseAddress + ulFeatureBytesOffset;
7233
7234 /* Optimize this access by only reading the word we are interested in. */
7235 if ( ulFeatureBitOffset < 16 )
7236 ReadParams.ulReadAddress += 2;
7237
7238 /* Must read in memory directly since this value is changed by hardware */
7239 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
7240 if ( ulResult != cOCT6100_ERR_OK )
7241 return ulResult;
7242
7243 /* Move data at correct position according to what was read. */
7244 if ( ulFeatureBitOffset < 16 )
7245 ulTempData = usReadData;
7246 else
7247 ulTempData = usReadData << 16;
7248
7249 /* Clear previous value set in the feature field. */
7250 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7251
7252 ulTempData &= ulMask;
7253
7254 /* Shift to get value. */
7255 ulTempData = ulTempData >> ulFeatureBitOffset;
7256
7257 pChanEntry->sSoutAppliedGain = (INT16)( 2 * (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)( ulTempData & 0xFFFF ) ) & 0xFFFF ) );
7258 }
7259
7260 /*---------------------------------------------------------------------*/
7261 /* Return the real stats.*/
7262
7263 f_pChannelStats->ulNumEchoPathChanges = pChanEntry->usNumEchoPathChanges;
7264 if ( usEchoDelayInFrames != cOCT6100_INVALID_ECHO_DELAY )
7265 {
7266 f_pChannelStats->fEchoCancellerConverged = TRUE;
7267 }
7268 else
7269 {
7270 f_pChannelStats->fEchoCancellerConverged = FALSE;
7271 }
7272 if ( pChanEntry->sCurrentERL == cOCT6100_INVALID_SIGNED_STAT_W )
7273 f_pChannelStats->lCurrentERL = cOCT6100_INVALID_SIGNED_STAT;
7274 else
7275 f_pChannelStats->lCurrentERL = pChanEntry->sCurrentERL;
7276
7277 if ( pChanEntry->sMaxERL == cOCT6100_INVALID_SIGNED_STAT_W )
7278 f_pChannelStats->lMaxERL = cOCT6100_INVALID_SIGNED_STAT;
7279 else
7280 f_pChannelStats->lMaxERL = pChanEntry->sMaxERL;
7281
7282 if ( pChanEntry->usMaxEchoDelay == cOCT6100_INVALID_STAT_W )
7283 f_pChannelStats->ulMaxEchoDelay = cOCT6100_INVALID_STAT;
7284 else
7285 f_pChannelStats->ulMaxEchoDelay = pChanEntry->usMaxEchoDelay;
7286
7287 if ( pChanEntry->sRinLevel == cOCT6100_INVALID_SIGNED_STAT_W )
7288 f_pChannelStats->lRinLevel = cOCT6100_INVALID_SIGNED_STAT;
7289 else
7290 f_pChannelStats->lRinLevel = pChanEntry->sRinLevel;
7291
7292 if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
7293 {
7294 if ( pChanEntry->sSinLevel == cOCT6100_INVALID_SIGNED_STAT_W )
7295 f_pChannelStats->lSinLevel = cOCT6100_INVALID_SIGNED_STAT;
7296 else
7297 f_pChannelStats->lSinLevel = pChanEntry->sSinLevel;
7298 }
7299 else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
7300 {
7301 /* SIN level is not supported in this image. */
7302 f_pChannelStats->lSinLevel = cOCT6100_INVALID_SIGNED_STAT;
7303 }
7304
7305 f_pChannelStats->lRinAppliedGain = pChanEntry->VqeConfig.chRinLevelControlGainDb;
7306 if ( ( f_pApiInstance->pSharedInfo->ImageInfo.fRinAppliedGainStat == TRUE )
7307 && ( ( pChanEntry->VqeConfig.fRinAutomaticLevelControl == TRUE )
7308 || ( pChanEntry->VqeConfig.fRinHighLevelCompensation == TRUE ) ) )
7309 {
7310 f_pChannelStats->lRinAppliedGain = pChanEntry->sRinAppliedGain;
7311 }
7312
7313 f_pChannelStats->lSoutAppliedGain = pChanEntry->VqeConfig.chSoutLevelControlGainDb;
7314 if ( ( f_pApiInstance->pSharedInfo->ImageInfo.fSoutAppliedGainStat == TRUE )
7315 && ( pChanEntry->VqeConfig.fSoutAutomaticLevelControl == TRUE ) )
7316 {
7317 f_pChannelStats->lSoutAppliedGain = pChanEntry->sSoutAppliedGain;
7318 }
7319
7320 if ( pChanEntry->usCurrentEchoDelay == cOCT6100_INVALID_STAT_W )
7321 f_pChannelStats->ulCurrentEchoDelay = cOCT6100_INVALID_STAT;
7322 else
7323 f_pChannelStats->ulCurrentEchoDelay = pChanEntry->usCurrentEchoDelay;
7324
7325 if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
7326 {
7327 if ( pChanEntry->sCurrentERLE == cOCT6100_INVALID_SIGNED_STAT_W )
7328 f_pChannelStats->lCurrentERLE = cOCT6100_INVALID_SIGNED_STAT;
7329 else
7330 f_pChannelStats->lCurrentERLE = pChanEntry->sCurrentERLE;
7331 }
7332 else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
7333 {
7334 f_pChannelStats->lCurrentERLE = cOCT6100_INVALID_SIGNED_STAT;
7335 }
7336
7337 if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
7338 {
7339 if ( pChanEntry->sMaxERLE == cOCT6100_INVALID_SIGNED_STAT_W )
7340 f_pChannelStats->lMaxERLE = cOCT6100_INVALID_SIGNED_STAT;
7341 else
7342 f_pChannelStats->lMaxERLE = pChanEntry->sMaxERLE;
7343 }
7344 else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
7345 {
7346 f_pChannelStats->lMaxERLE = cOCT6100_INVALID_SIGNED_STAT;
7347 }
7348
7349 f_pChannelStats->lComfortNoiseLevel = pChanEntry->sComfortNoiseLevel;
7350 f_pChannelStats->ulToneDisablerStatus = pChanEntry->byToneDisablerStatus;
7351
7352 if ( f_pApiInstance->pSharedInfo->ImageInfo.fSinVoiceDetectedStat == TRUE )
7353 {
7354 UINT32 ulVoiceDetectedBytesOfst = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.usDwordOffset * 4;
7355 UINT32 ulVoiceDetectedBitOfst = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.byBitOffset;
7356 UINT32 ulVoiceDetectedFieldSize = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.byFieldSize;
7357
7358 /* Set the channel root base address.*/
7359 UINT32 ulChannelRootBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( usChanIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanRootConfOfst;
7360
7361 ReadParams.ulReadAddress = ulChannelRootBaseAddress + ulVoiceDetectedBytesOfst;
7362
7363 /* Optimize this access by only reading the word we are interested in. */
7364 if ( ulVoiceDetectedBitOfst < 16 )
7365 ReadParams.ulReadAddress += 2;
7366
7367 /* Must read in memory directly since this value is changed by hardware */
7368 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
7369 if ( ulResult != cOCT6100_ERR_OK )
7370 return ulResult;
7371
7372 /* Move data at correct position according to what was read. */
7373 if ( ulVoiceDetectedBitOfst < 16 )
7374 ulTempData = usReadData;
7375 else
7376 ulTempData = usReadData << 16;
7377
7378 mOCT6100_CREATE_FEATURE_MASK( ulVoiceDetectedFieldSize, ulVoiceDetectedBitOfst, &ulMask );
7379
7380 if ( ( ulTempData & ulMask ) != 0x0 )
7381 f_pChannelStats->fSinVoiceDetected = TRUE;
7382 else
7383 f_pChannelStats->fSinVoiceDetected = FALSE;
7384 }
7385
7386 /*---------------------------------------------------------------------*/
7387
7388 return cOCT6100_ERR_OK;
7389 }
7390 #endif
7391
7392
7393 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7394
7395 Function: Oct6100ApiReserveEchoEntry
7396
7397 Description: Reserves one of the echo channel API entry.
7398
7399 -------------------------------------------------------------------------------
7400 | Argument | Description
7401 -------------------------------------------------------------------------------
7402 f_pApiInstance Pointer to API instance. This memory is used to keep
7403 the present state of the chip and all its resources.
7404
7405 f_pusEchoIndex Resulting index reserved in the echo channel list.
7406
7407 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7408 #if !SKIP_Oct6100ApiReserveEchoEntry
7409 UINT32 Oct6100ApiReserveEchoEntry(
7410 IN tPOCT6100_INSTANCE_API f_pApiInstance,
7411 OUT PUINT16 f_pusEchoIndex )
7412 {
7413 tPOCT6100_SHARED_INFO pSharedInfo;
7414 PVOID pEchoAlloc;
7415 UINT32 ulResult;
7416 UINT32 ulEchoIndex;
7417
7418 /* Get local pointer to shared portion of instance. */
7419 pSharedInfo = f_pApiInstance->pSharedInfo;
7420
7421 mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc )
7422
7423 ulResult = OctapiLlmAllocAlloc( pEchoAlloc, &ulEchoIndex );
7424 if ( ulResult != cOCT6100_ERR_OK )
7425 {
7426 if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
7427 return cOCT6100_ERR_CHANNEL_ALL_CHANNELS_ARE_OPENED;
7428 else
7429 return cOCT6100_ERR_FATAL_11;
7430 }
7431
7432 *f_pusEchoIndex = (UINT16)( ulEchoIndex & 0xFFFF );
7433
7434 return cOCT6100_ERR_OK;
7435 }
7436 #endif
7437
7438
7439 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7440
7441 Function: Oct6100ApiReleaseEchoEntry
7442
7443 Description: Releases the specified ECHO channel API entry.
7444
7445 -------------------------------------------------------------------------------
7446 | Argument | Description
7447 -------------------------------------------------------------------------------
7448 f_pApiInstance Pointer to API instance. This memory is used to keep
7449 the present state of the chip and all its resources.
7450
7451 f_usEchoIndex Index reserved in the echo channel list.
7452
7453 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7454 #if !SKIP_Oct6100ApiReleaseEchoEntry
7455 UINT32 Oct6100ApiReleaseEchoEntry(
7456 IN tPOCT6100_INSTANCE_API f_pApiInstance,
7457 IN UINT16 f_usEchoIndex )
7458 {
7459 tPOCT6100_SHARED_INFO pSharedInfo;
7460 PVOID pEchoAlloc;
7461 UINT32 ulResult;
7462
7463 /* Get local pointer to shared portion of instance. */
7464 pSharedInfo = f_pApiInstance->pSharedInfo;
7465
7466 mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc )
7467
7468 ulResult = OctapiLlmAllocDealloc( pEchoAlloc, f_usEchoIndex );
7469 if ( ulResult != cOCT6100_ERR_OK )
7470 {
7471 return cOCT6100_ERR_FATAL_12;
7472 }
7473
7474 return cOCT6100_ERR_OK;
7475 }
7476 #endif
7477
7478
7479 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7480
7481 Function: Oct6100ApiReserveBiDirChanEntry
7482
7483 Description: Reserves one of the bidirectional channel API entry.
7484
7485 -------------------------------------------------------------------------------
7486 | Argument | Description
7487 -------------------------------------------------------------------------------
7488 f_pApiInstance Pointer to API instance. This memory is used to keep
7489 the present state of the chip and all its resources.
7490
7491 f_pusBiDirChanIndex Resulting index reserved in the bidir channel list.
7492
7493 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7494 #if !SKIP_Oct6100ApiReserveBiDirChanEntry
7495 UINT32 Oct6100ApiReserveBiDirChanEntry(
7496 IN tPOCT6100_INSTANCE_API f_pApiInstance,
7497 OUT PUINT16 f_pusBiDirChanIndex )
7498 {
7499 tPOCT6100_SHARED_INFO pSharedInfo;
7500 PVOID pChanAlloc;
7501 UINT32 ulResult;
7502 UINT32 ulBiDirChanIndex;
7503
7504 /* Get local pointer to shared portion of the API instance. */
7505 pSharedInfo = f_pApiInstance->pSharedInfo;
7506
7507 mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pChanAlloc )
7508
7509 ulResult = OctapiLlmAllocAlloc( pChanAlloc, &ulBiDirChanIndex );
7510 if ( ulResult != cOCT6100_ERR_OK )
7511 {
7512 if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
7513 return cOCT6100_ERR_CHANNEL_ALL_BIDIR_CHANNELS_ARE_OPENED;
7514 else
7515 return cOCT6100_ERR_FATAL_9F;
7516 }
7517
7518 *f_pusBiDirChanIndex = (UINT16)( ulBiDirChanIndex & 0xFFFF );
7519
7520 return cOCT6100_ERR_OK;
7521 }
7522 #endif
7523
7524
7525 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7526
7527 Function: Oct6100ApiReleaseBiDirChanEntry
7528
7529 Description: Releases the specified bidirectional channel API entry.
7530
7531 -------------------------------------------------------------------------------
7532 | Argument | Description
7533 -------------------------------------------------------------------------------
7534 f_pApiInstance Pointer to API instance. This memory is used to keep
7535 the present state of the chip and all its resources.
7536
7537 f_ulBiDirChanIndex Bidirectional channel index within the API's Bidir channel list.
7538
7539 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7540 #if !SKIP_Oct6100ApiReleaseBiDirChanEntry
7541 UINT32 Oct6100ApiReleaseBiDirChanEntry(
7542 IN tPOCT6100_INSTANCE_API f_pApiInstance,
7543 IN UINT32 f_ulBiDirChanIndex )
7544 {
7545 tPOCT6100_SHARED_INFO pSharedInfo;
7546 PVOID pChanAlloc;
7547 UINT32 ulResult;
7548
7549 /* Get local pointer to shared portion of instance. */
7550 pSharedInfo = f_pApiInstance->pSharedInfo;
7551
7552 mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pChanAlloc )
7553
7554 ulResult = OctapiLlmAllocDealloc( pChanAlloc, f_ulBiDirChanIndex );
7555 if ( ulResult != cOCT6100_ERR_OK )
7556 {
7557 return cOCT6100_ERR_FATAL_A0;
7558 }
7559
7560 return cOCT6100_ERR_OK;
7561 }
7562 #endif
7563
7564
7565
7566 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7567
7568 Function: Oct6100ApiCheckTdmConfig
7569
7570 Description: This function will check the validity of the TDM config parameter
7571 of an Open TDM config structure.
7572
7573 -------------------------------------------------------------------------------
7574 | Argument | Description
7575 -------------------------------------------------------------------------------
7576 f_pApiInstance Pointer to API instance. This memory is used to keep
7577 the present state of the chip and all its resources.
7578
7579 f_pTdmConfig TDM config of the channel.
7580
7581 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7582 #if !SKIP_Oct6100ApiCheckTdmConfig
7583 UINT32 Oct6100ApiCheckTdmConfig(
7584 IN tPOCT6100_INSTANCE_API f_pApiInstance,
7585 IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig )
7586 {
7587 UINT32 ulResult;
7588
7589 /*==============================================================================*/
7590 /* Check the TDM configuration parameters.*/
7591
7592 /* Check the validity of the timeslot and Stream only if it is defined.*/
7593 if ( f_pTdmConfig->ulRinTimeslot != cOCT6100_UNASSIGNED ||
7594 f_pTdmConfig->ulRinStream != cOCT6100_UNASSIGNED )
7595 {
7596 if ( f_pTdmConfig->ulRinNumTssts != 1 &&
7597 f_pTdmConfig->ulRinNumTssts != 2 )
7598 return cOCT6100_ERR_CHANNEL_RIN_NUM_TSSTS;
7599
7600 /* Check the RIN TDM streams, timeslots component for errors.*/
7601 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
7602 f_pTdmConfig->ulRinNumTssts,
7603 f_pTdmConfig->ulRinTimeslot,
7604 f_pTdmConfig->ulRinStream,
7605 cOCT6100_INPUT_TSST );
7606 if ( ulResult != cOCT6100_ERR_OK )
7607 {
7608 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7609 {
7610 return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
7611 }
7612 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7613 {
7614 return cOCT6100_ERR_CHANNEL_RIN_STREAM;
7615 }
7616 else
7617 {
7618 return ulResult;
7619 }
7620 }
7621 }
7622
7623 /* Check the validity of the timeslot and Stream only if it is defined.*/
7624 if ( f_pTdmConfig->ulRoutTimeslot != cOCT6100_UNASSIGNED ||
7625 f_pTdmConfig->ulRoutStream != cOCT6100_UNASSIGNED )
7626 {
7627 if ( f_pTdmConfig->ulRoutNumTssts != 1 &&
7628 f_pTdmConfig->ulRoutNumTssts != 2 )
7629 return cOCT6100_ERR_CHANNEL_ROUT_NUM_TSSTS;
7630
7631 /* Check the ROUT TDM streams, timeslots component for errors.*/
7632 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
7633 f_pTdmConfig->ulRoutNumTssts,
7634 f_pTdmConfig->ulRoutTimeslot,
7635 f_pTdmConfig->ulRoutStream,
7636 cOCT6100_OUTPUT_TSST );
7637 if ( ulResult != cOCT6100_ERR_OK )
7638 {
7639 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7640 {
7641 return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT;
7642 }
7643 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7644 {
7645 return cOCT6100_ERR_CHANNEL_ROUT_STREAM;
7646 }
7647 else
7648 {
7649 return ulResult;
7650 }
7651 }
7652 }
7653
7654 /* Check the validity of the timeslot and Stream only if it is defined.*/
7655 if ( f_pTdmConfig->ulSinTimeslot != cOCT6100_UNASSIGNED ||
7656 f_pTdmConfig->ulSinStream != cOCT6100_UNASSIGNED )
7657 {
7658 if ( f_pTdmConfig->ulSinNumTssts != 1 &&
7659 f_pTdmConfig->ulSinNumTssts != 2 )
7660 return cOCT6100_ERR_CHANNEL_SIN_NUM_TSSTS;
7661
7662 /* Check the SIN TDM streams, timeslots component for errors.*/
7663 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
7664 f_pTdmConfig->ulSinNumTssts,
7665 f_pTdmConfig->ulSinTimeslot,
7666 f_pTdmConfig->ulSinStream,
7667 cOCT6100_INPUT_TSST );
7668 if ( ulResult != cOCT6100_ERR_OK )
7669 {
7670 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7671 {
7672 return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT;
7673 }
7674 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7675 {
7676 return cOCT6100_ERR_CHANNEL_SIN_STREAM;
7677 }
7678 else
7679 {
7680 return ulResult;
7681 }
7682 }
7683 }
7684
7685 /* Check the validity of the timeslot and Stream only if it is defined.*/
7686 if ( f_pTdmConfig->ulSoutTimeslot != cOCT6100_UNASSIGNED ||
7687 f_pTdmConfig->ulSoutStream != cOCT6100_UNASSIGNED )
7688 {
7689 if ( f_pTdmConfig->ulSoutNumTssts != 1 &&
7690 f_pTdmConfig->ulSoutNumTssts != 2 )
7691 return cOCT6100_ERR_CHANNEL_SOUT_NUM_TSSTS;
7692
7693 /* Check the ROUT TDM streams, timeslots component for errors.*/
7694 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
7695 f_pTdmConfig->ulSoutNumTssts,
7696 f_pTdmConfig->ulSoutTimeslot,
7697 f_pTdmConfig->ulSoutStream,
7698 cOCT6100_OUTPUT_TSST );
7699 if ( ulResult != cOCT6100_ERR_OK )
7700 {
7701 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7702 {
7703 return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
7704 }
7705 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7706 {
7707 return cOCT6100_ERR_CHANNEL_SOUT_STREAM;
7708 }
7709 else
7710 {
7711 return ulResult;
7712 }
7713 }
7714 }
7715
7716 /* Check the PCM law parameters.*/
7717 if ( f_pTdmConfig->ulRinPcmLaw != cOCT6100_PCM_U_LAW &&
7718 f_pTdmConfig->ulRinPcmLaw != cOCT6100_PCM_A_LAW )
7719 return cOCT6100_ERR_CHANNEL_RIN_PCM_LAW;
7720
7721 if ( f_pTdmConfig->ulSinPcmLaw != cOCT6100_PCM_U_LAW &&
7722 f_pTdmConfig->ulSinPcmLaw != cOCT6100_PCM_A_LAW )
7723 return cOCT6100_ERR_CHANNEL_SIN_PCM_LAW;
7724
7725 if ( f_pTdmConfig->ulRoutPcmLaw != cOCT6100_PCM_U_LAW &&
7726 f_pTdmConfig->ulRoutPcmLaw != cOCT6100_PCM_A_LAW )
7727 return cOCT6100_ERR_CHANNEL_ROUT_PCM_LAW;
7728
7729 if ( f_pTdmConfig->ulSoutPcmLaw != cOCT6100_PCM_U_LAW &&
7730 f_pTdmConfig->ulSoutPcmLaw != cOCT6100_PCM_A_LAW )
7731 return cOCT6100_ERR_CHANNEL_SOUT_PCM_LAW;
7732
7733 /*==============================================================================*/
7734
7735
7736
7737 return cOCT6100_ERR_OK;
7738 }
7739 #endif
7740
7741
7742 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7743
7744 Function: Oct6100ApiCheckVqeConfig
7745
7746 Description: This function will check the validity of the VQE config parameter
7747 of an Open VQE config structure.
7748
7749 -------------------------------------------------------------------------------
7750 | Argument | Description
7751 -------------------------------------------------------------------------------
7752 f_pApiInstance Pointer to API instance. This memory is used to keep
7753 the present state of the chip and all its resources.
7754
7755 f_pVqeConfig VQE config of the channel.
7756 f_fEnableToneDisabler Whether the tone disabler is active or not.
7757
7758 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7759 #if !SKIP_Oct6100ApiCheckVqeConfig
7760 UINT32 Oct6100ApiCheckVqeConfig(
7761 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
7762 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
7763 IN BOOL f_fEnableToneDisabler )
7764 {
7765 tPOCT6100_API_IMAGE_INFO pImageInfo;
7766
7767 pImageInfo = &f_pApiInstance->pSharedInfo->ImageInfo;
7768
7769 if ( f_pVqeConfig->fEnableNlp != TRUE && f_pVqeConfig->fEnableNlp != FALSE )
7770 return cOCT6100_ERR_CHANNEL_ENABLE_NLP;
7771
7772 if ( f_pVqeConfig->fEnableNlp == TRUE && pImageInfo->fNlpControl == FALSE )
7773 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLP_CONTROL;
7774
7775
7776
7777 /* Check the comfort noise mode.*/
7778 if ( f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_OFF && pImageInfo->fComfortNoise == FALSE )
7779 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_BKG_NOISE_FREEZE;
7780
7781 if ( f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_NORMAL &&
7782 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_EXTENDED &&
7783 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_FAST_LATCH &&
7784 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_OFF )
7785 return cOCT6100_ERR_CHANNEL_COMFORT_NOISE_MODE;
7786
7787 /* Check the DC offset removal.*/
7788 if ( f_pVqeConfig->fSinDcOffsetRemoval != TRUE && f_pVqeConfig->fSinDcOffsetRemoval != FALSE )
7789 return cOCT6100_ERR_CHANNEL_SIN_DC_OFFSET_REM;
7790
7791 if ( f_pVqeConfig->fSinDcOffsetRemoval == TRUE && pImageInfo->fSinDcOffsetRemoval == FALSE )
7792 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_DC_OFFSET_REM;
7793
7794 if ( f_pVqeConfig->fRinDcOffsetRemoval != TRUE && f_pVqeConfig->fRinDcOffsetRemoval != FALSE )
7795 return cOCT6100_ERR_CHANNEL_RIN_DC_OFFSET_REM;
7796
7797 if ( f_pVqeConfig->fRinDcOffsetRemoval == TRUE && pImageInfo->fRinDcOffsetRemoval == FALSE )
7798 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_DC_OFFSET_REM;
7799
7800 /* Check the Level control.*/
7801 if ( f_pVqeConfig->fRinLevelControl != TRUE && f_pVqeConfig->fRinLevelControl != FALSE )
7802 return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL;
7803
7804 if ( f_pVqeConfig->fSoutLevelControl != TRUE && f_pVqeConfig->fSoutLevelControl != FALSE )
7805 return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL;
7806
7807 if ( ( f_pVqeConfig->lRinLevelControlGainDb < -24 ) || ( f_pVqeConfig->lRinLevelControlGainDb > 24 ) )
7808 return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL_GAIN;
7809
7810 if ( ( f_pVqeConfig->lSoutLevelControlGainDb < -24 ) || ( f_pVqeConfig->lSoutLevelControlGainDb > 24 ) )
7811 return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL_GAIN;
7812
7813 if ( ( f_pVqeConfig->fRinAutomaticLevelControl != TRUE ) && ( f_pVqeConfig->fRinAutomaticLevelControl != FALSE ) )
7814 return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL;
7815
7816 if ( ( f_pVqeConfig->fRinHighLevelCompensation != TRUE ) && ( f_pVqeConfig->fRinHighLevelCompensation != FALSE ) )
7817 return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP;
7818
7819 if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) && ( pImageInfo->fRinAutoLevelControl == FALSE ) )
7820 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_AUTO_LC;
7821
7822 if ( ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) && ( pImageInfo->fRinHighLevelCompensation == FALSE ) )
7823 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_HIGH_LEVEL_COMP;
7824
7825 if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
7826 {
7827 if ( f_pVqeConfig->fRinLevelControl == TRUE )
7828 return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_MANUAL;
7829
7830 if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
7831 return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_HIGH_LEVEL_COMP;
7832
7833 if ( ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lRinAutomaticLevelControlTargetDb > 0 ) )
7834 return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL_TARGET;
7835 }
7836
7837 if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
7838 {
7839 if ( f_pVqeConfig->fRinLevelControl == TRUE )
7840 return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_MANUAL;
7841
7842 if ( ( f_pVqeConfig->lRinHighLevelCompensationThresholdDb < -40 || f_pVqeConfig->lRinHighLevelCompensationThresholdDb > 0 ) )
7843 return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_THRESHOLD;
7844 }
7845
7846 if ( f_pVqeConfig->fSoutAutomaticLevelControl != TRUE && f_pVqeConfig->fSoutAutomaticLevelControl != FALSE )
7847 return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL;
7848
7849 if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) && ( pImageInfo->fSoutAutoLevelControl == FALSE ) )
7850 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SOUT_AUTO_LC;
7851
7852 if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
7853 {
7854 if ( f_pVqeConfig->fSoutLevelControl == TRUE )
7855 return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_MANUAL;
7856
7857 if ( ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lSoutAutomaticLevelControlTargetDb > 0 ) )
7858 return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL_TARGET;
7859 }
7860
7861 if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != TRUE &&
7862 f_pVqeConfig->fSoutAdaptiveNoiseReduction != FALSE )
7863 return cOCT6100_ERR_CHANNEL_SOUT_ADAPT_NOISE_REDUCTION;
7864
7865 if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE && pImageInfo->fAdaptiveNoiseReduction == FALSE )
7866 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR;
7867
7868 if ( f_pVqeConfig->fSoutConferencingNoiseReduction != TRUE &&
7869 f_pVqeConfig->fSoutConferencingNoiseReduction != FALSE )
7870 return cOCT6100_ERR_CHANNEL_SOUT_CONFERENCE_NOISE_REDUCTION;
7871
7872 if ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE && pImageInfo->fConferencingNoiseReduction == FALSE )
7873 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_CNR;
7874
7875 /* Validate Sout noise bleaching parameter. */
7876 if ( f_pVqeConfig->fSoutNoiseBleaching != TRUE &&
7877 f_pVqeConfig->fSoutNoiseBleaching != FALSE )
7878 return cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING;
7879
7880 /* Check if firmware supports Sout noise bleaching. */
7881 if ( f_pVqeConfig->fSoutNoiseBleaching == TRUE && pImageInfo->fSoutNoiseBleaching == FALSE )
7882 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NOISE_BLEACHING;
7883
7884 /* If Sout noise bleaching is requested, no ANR or CNR shall be activated. */
7885 if ( f_pVqeConfig->fSoutNoiseBleaching == TRUE )
7886 {
7887 /* No xNR! */
7888 if ( ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE )
7889 || ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE ) )
7890 return cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING_NR;
7891 }
7892
7893 /* Cannot activate both ANR and CNR when noise bleaching is present */
7894 if ( pImageInfo->fSoutNoiseBleaching == TRUE )
7895 {
7896 if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE &&
7897 f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE )
7898 return cOCT6100_ERR_CHANNEL_ANR_CNR_SIMULTANEOUSLY;
7899 }
7900
7901 /* Validate the DTMF tone removal parameter.*/
7902 if ( f_pVqeConfig->fDtmfToneRemoval != TRUE && f_pVqeConfig->fDtmfToneRemoval != FALSE )
7903 return cOCT6100_ERR_CHANNEL_TONE_REMOVAL;
7904
7905 if ( f_pVqeConfig->fDtmfToneRemoval == TRUE && pImageInfo->fToneRemoval == FALSE )
7906 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_REMOVAL;
7907
7908
7909
7910 /* Check the Tail displacement enable.*/
7911 if ( f_pVqeConfig->fEnableTailDisplacement != TRUE && f_pVqeConfig->fEnableTailDisplacement != FALSE )
7912 return cOCT6100_ERR_CHANNEL_ENABLE_TAIL_DISPLACEMENT;
7913
7914 if ( f_pVqeConfig->fEnableTailDisplacement == TRUE && pImageInfo->fTailDisplacement == FALSE )
7915 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_DISPLACEMENT;
7916
7917 /* Check the Tail displacement value.*/
7918 if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
7919 {
7920 if ( f_pVqeConfig->ulTailDisplacement != cOCT6100_AUTO_SELECT_TAIL )
7921 {
7922 /* Check if this feature is supported by the image. */
7923 if ( pImageInfo->fPerChannelTailDisplacement == FALSE )
7924 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_PER_CHAN_TAIL;
7925
7926 /* Check that this value is not greater then what the image supports. */
7927 if ( f_pVqeConfig->ulTailDisplacement > pImageInfo->usMaxTailDisplacement )
7928 return cOCT6100_ERR_CHANNEL_TAIL_DISPLACEMENT_INVALID;
7929 }
7930 }
7931
7932 /* Check the tail length value. */
7933 if ( f_pVqeConfig->ulTailLength != cOCT6100_AUTO_SELECT_TAIL )
7934 {
7935 /* Check if this feature is supported by the image. */
7936 if ( ( pImageInfo->fPerChannelTailLength == FALSE )
7937 && ( (UINT16)( f_pVqeConfig->ulTailLength & 0xFFFF ) != pImageInfo->usMaxTailLength ) )
7938 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_LENGTH;
7939
7940 if ( ( f_pVqeConfig->ulTailLength < 32 ) || ( f_pVqeConfig->ulTailLength > 128 )
7941 || ( ( f_pVqeConfig->ulTailLength % 4 ) != 0x0 ) )
7942 return cOCT6100_ERR_CHANNEL_TAIL_LENGTH;
7943
7944 /* Check if the requested tail length is supported by the chip. */
7945 if ( f_pVqeConfig->ulTailLength > pImageInfo->usMaxTailLength )
7946 return cOCT6100_ERR_CHANNEL_TAIL_LENGTH_INVALID;
7947 }
7948
7949 /* Validate the acoustic echo cancellation parameter.*/
7950 if ( f_pVqeConfig->fAcousticEcho != TRUE && f_pVqeConfig->fAcousticEcho != FALSE )
7951 return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO;
7952
7953 if ( f_pVqeConfig->fAcousticEcho == TRUE && pImageInfo->fAcousticEcho == FALSE )
7954 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO;
7955
7956 if ( f_pVqeConfig->fAcousticEcho == TRUE )
7957 {
7958 /* Check if acoustic echo tail length configuration is supported in the image. */
7959 if ( ( f_pVqeConfig->ulAecTailLength != 128 ) && ( pImageInfo->fAecTailLength == FALSE ) )
7960 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH;
7961
7962 /* Check the requested acoustic echo tail length. */
7963 if ( ( f_pVqeConfig->ulAecTailLength != 128 )
7964 && ( f_pVqeConfig->ulAecTailLength != 256 )
7965 && ( f_pVqeConfig->ulAecTailLength != 512 )
7966 && ( f_pVqeConfig->ulAecTailLength != 1024 ) )
7967 return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH;
7968
7969 if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
7970 {
7971 UINT32 ulTailSum;
7972
7973 /* Start with requested tail displacement. */
7974 if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
7975 {
7976 ulTailSum = f_pApiInstance->pSharedInfo->ChipConfig.usTailDisplacement;
7977 }
7978 else
7979 {
7980 ulTailSum = f_pVqeConfig->ulTailDisplacement;
7981 }
7982
7983 /* Add requested tail length. */
7984 if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
7985 {
7986 ulTailSum += f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength;
7987 }
7988 else
7989 {
7990 ulTailSum += f_pVqeConfig->ulTailLength;
7991 }
7992
7993 /* The tail sum must be smaller then the requested AEC tail length. */
7994 if ( ulTailSum > f_pVqeConfig->ulAecTailLength )
7995 return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_SUM;
7996 }
7997 }
7998
7999 /* Validate the Default ERL parameter.*/
8000 if ( f_pVqeConfig->lDefaultErlDb != -6 && pImageInfo->fDefaultErl == FALSE )
8001 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DEFAULT_ERL;
8002
8003 if ( ( f_pVqeConfig->lDefaultErlDb != 0 ) &&
8004 ( f_pVqeConfig->lDefaultErlDb != -3 ) &&
8005 ( f_pVqeConfig->lDefaultErlDb != -6 ) &&
8006 ( f_pVqeConfig->lDefaultErlDb != -9 ) &&
8007 ( f_pVqeConfig->lDefaultErlDb != -12 ) )
8008 return cOCT6100_ERR_CHANNEL_DEFAULT_ERL;
8009
8010 /* Validate the Default AEC ERL parameter.*/
8011 if ( f_pVqeConfig->lAecDefaultErlDb != 0 && pImageInfo->fAecDefaultErl == FALSE )
8012 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_AEC_DEFAULT_ERL;
8013
8014 if ( f_pVqeConfig->lAecDefaultErlDb != 0 && f_pVqeConfig->lAecDefaultErlDb != -3 && f_pVqeConfig->lAecDefaultErlDb != -6 )
8015 return cOCT6100_ERR_CHANNEL_AEC_DEFAULT_ERL;
8016
8017 /* Validate the non-linearity A parameter.*/
8018 if ( f_pVqeConfig->ulNonLinearityBehaviorA != 1 && pImageInfo->fNonLinearityBehaviorA == FALSE )
8019 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DOUBLE_TALK;
8020
8021 if ( f_pVqeConfig->ulNonLinearityBehaviorA >= 14 )
8022 return cOCT6100_ERR_CHANNEL_DOUBLE_TALK;
8023
8024 /* Validate the non-linearity B parameter.*/
8025 if ( f_pVqeConfig->ulNonLinearityBehaviorB != 0 && pImageInfo->fNonLinearityBehaviorB == FALSE )
8026 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NON_LINEARITY_B;
8027
8028 if ( f_pVqeConfig->ulNonLinearityBehaviorB >= 9 )
8029 return cOCT6100_ERR_CHANNEL_NON_LINEARITY_B;
8030
8031 /* Check if configuring the double talk behavior is supported in the firmware. */
8032 if ( f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_NORMAL && pImageInfo->fDoubleTalkBehavior == FALSE )
8033 return cOCT6100_ERR_NOT_SUPPORTED_DOUBLE_TALK_BEHAVIOR_MODE;
8034
8035 /* Validate the double talk behavior mode parameter. */
8036 if ( f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_NORMAL && f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_LESS_AGGRESSIVE )
8037 return cOCT6100_ERR_CHANNEL_DOUBLE_TALK_MODE;
8038
8039 /* Validate the Sout automatic listener enhancement ratio. */
8040 if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 && pImageInfo->fListenerEnhancement == FALSE )
8041 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ALE;
8042
8043 if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb > 30 )
8044 return cOCT6100_ERR_CHANNEL_ALE_RATIO;
8045
8046 /* Validate the Sout natural listener enhancement ratio. */
8047 if ( f_pVqeConfig->fSoutNaturalListenerEnhancement != TRUE && f_pVqeConfig->fSoutNaturalListenerEnhancement != FALSE )
8048 return cOCT6100_ERR_CHANNEL_NLE_FLAG;
8049
8050 if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE && pImageInfo->fListenerEnhancement == FALSE )
8051 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLE;
8052
8053 if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
8054 {
8055 if ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb > 30 )
8056 return cOCT6100_ERR_CHANNEL_NLE_RATIO;
8057 }
8058
8059 /* Both ALE and NLE cannot be activated simultaneously. */
8060 if ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 )
8061 && ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE ) )
8062 return cOCT6100_ERR_CHANNEL_ALE_NLE_SIMULTANEOUSLY;
8063
8064 /* Validate Rout noise reduction. */
8065 if ( f_pVqeConfig->fRoutNoiseReduction != TRUE && f_pVqeConfig->fRoutNoiseReduction != FALSE )
8066 return cOCT6100_ERR_CHANNEL_ROUT_NOISE_REDUCTION;
8067
8068 /* Check if Rout noise reduction is supported. */
8069 if ( f_pVqeConfig->fRoutNoiseReduction == TRUE && pImageInfo->fRoutNoiseReduction == FALSE )
8070 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ROUT_NR;
8071
8072 /*Check if noise reduction level gain is supported*/
8073 if ( ( pImageInfo->fRoutNoiseReductionLevel == FALSE ) && ( f_pVqeConfig->lRoutNoiseReductionLevelGainDb != -18 ) )
8074 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ROUT_NOISE_REDUCTION_GAIN;
8075
8076 if ( ( f_pVqeConfig->lRoutNoiseReductionLevelGainDb != 0 ) &&
8077 ( f_pVqeConfig->lRoutNoiseReductionLevelGainDb != -6 ) &&
8078 ( f_pVqeConfig->lRoutNoiseReductionLevelGainDb != -12 ) &&
8079 ( f_pVqeConfig->lRoutNoiseReductionLevelGainDb != -18 ) )
8080
8081 return cOCT6100_ERR_CHANNEL_ROUT_NOISE_REDUCTION_GAIN;
8082
8083 /* Check if ANR SNRE is supported. */
8084 if ( ( f_pVqeConfig->lAnrSnrEnhancementDb != -18 ) && ( pImageInfo->fAnrSnrEnhancement == FALSE ) )
8085 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SNR_ENHANCEMENT;
8086
8087 /* Validate Sout ANR SNR enhancement. */
8088 if ( ( f_pVqeConfig->lAnrSnrEnhancementDb != -9 )
8089 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -12 )
8090 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -15 )
8091 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -18 )
8092 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -21 )
8093 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -24 )
8094 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -27 )
8095 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -30 ) )
8096 return cOCT6100_ERR_CHANNEL_ANR_SNR_ENHANCEMENT;
8097
8098 /* Validate ANR voice-noise segregation. */
8099 if ( f_pVqeConfig->ulAnrVoiceNoiseSegregation > 15 )
8100 return cOCT6100_ERR_CHANNEL_ANR_SEGREGATION;
8101
8102 /* Check if ANR VN segregation is supported. */
8103 if ( ( f_pVqeConfig->ulAnrVoiceNoiseSegregation != 6 ) && ( pImageInfo->fAnrVoiceNoiseSegregation == FALSE ) )
8104 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SEGREGATION;
8105
8106 /* Check if the loaded image supports tone disabler VQE activation delay. */
8107 if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != 300 )
8108 && ( pImageInfo->fToneDisablerVqeActivationDelay == FALSE ) )
8109 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY;
8110
8111 /* Check if the specified tone disabler VQE activation delay is correct. */
8112 if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay < 300 )
8113 || ( ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay - 300 ) % 512 ) != 0 ) )
8114 return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY;
8115
8116 /* Check the enable music protection flag. */
8117 if ( ( f_pVqeConfig->fEnableMusicProtection != TRUE ) && ( f_pVqeConfig->fEnableMusicProtection != FALSE ) )
8118 return cOCT6100_ERR_CHANNEL_ENABLE_MUSIC_PROTECTION;
8119
8120 /* The music protection module can only be activated if the image supports it. */
8121 if ( ( f_pVqeConfig->fEnableMusicProtection == TRUE ) &&
8122 ( pImageInfo->fMusicProtection == FALSE ) )
8123 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_MUSIC_PROTECTION;
8124
8125 /* Check the enable idle code detection flag. */
8126 if ( ( f_pVqeConfig->fIdleCodeDetection != TRUE ) && ( f_pVqeConfig->fIdleCodeDetection != FALSE ) )
8127 return cOCT6100_ERR_CHANNEL_IDLE_CODE_DETECTION;
8128
8129 /* The idle code detection module can only be activated if the image supports it. */
8130 if ( ( f_pVqeConfig->fIdleCodeDetection == TRUE ) && ( pImageInfo->fIdleCodeDetection == FALSE ) )
8131 return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION;
8132
8133 /* The idle code detection module can be disabled only if idle code detection configuration */
8134 /* is supported in the image. */
8135 if ( pImageInfo->fIdleCodeDetection == TRUE )
8136 {
8137 if ( ( f_pVqeConfig->fIdleCodeDetection == FALSE ) && ( pImageInfo->fIdleCodeDetectionConfiguration == FALSE ) )
8138 return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION_CONFIG;
8139 }
8140
8141 return cOCT6100_ERR_OK;
8142 }
8143 #endif
8144
8145 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8146
8147 Function: Oct6100ApiCheckCodecConfig
8148
8149 Description: This function will check the validity of the Codec config parameter
8150 of an Open Codec config structure.
8151
8152 -------------------------------------------------------------------------------
8153 | Argument | Description
8154 -------------------------------------------------------------------------------
8155 f_pApiInstance Pointer to API instance. This memory is used to keep
8156 the present state of the chip and all its resources.
8157
8158 f_pCodecConfig Codec config of the channel.
8159 f_ulDecoderNumTssts Number of TSST for the decoder.
8160 f_pusPhasingTsstIndex Pointer to the Phasing TSST index within the API's phasing TSST list.
8161
8162 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8163 #if !SKIP_Oct6100ApiCheckCodecConfig
8164 UINT32 Oct6100ApiCheckCodecConfig(
8165 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8166 IN tPOCT6100_CHANNEL_OPEN_CODEC f_pCodecConfig,
8167 IN UINT32 f_ulDecoderNumTssts,
8168 OUT PUINT16 f_pusPhasingTsstIndex )
8169 {
8170
8171 /* Verify the ADPCM nibble value.*/
8172 if ( f_pCodecConfig->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_LOW_BITS &&
8173 f_pCodecConfig->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_HIGH_BITS )
8174 return cOCT6100_ERR_CHANNEL_ADPCM_NIBBLE;
8175
8176 /* Verify the Encoder port.*/
8177 if ( f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_ROUT &&
8178 f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_SOUT &&
8179 f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
8180 return cOCT6100_ERR_CHANNEL_ENCODER_PORT;
8181
8182 /* Verify the Decoder port.*/
8183 if ( f_pCodecConfig->ulDecoderPort != cOCT6100_CHANNEL_PORT_RIN &&
8184 f_pCodecConfig->ulDecoderPort != cOCT6100_CHANNEL_PORT_SIN &&
8185 f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
8186 return cOCT6100_ERR_CHANNEL_DECODER_PORT;
8187
8188 /* The codec cannot be on the same stream.*/
8189 if ( f_pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT &&
8190 f_pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
8191 return cOCT6100_ERR_CHANNEL_INVALID_CODEC_POSITION;
8192
8193 if ( f_pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT &&
8194 f_pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN )
8195 return cOCT6100_ERR_CHANNEL_INVALID_CODEC_POSITION;
8196
8197 /* Verify if the requested functions are supported by the chip.*/
8198 if ( f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm == FALSE &&
8199 f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
8200 {
8201 if ( f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS )
8202 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ENCODING;
8203 }
8204
8205 if ( f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm == FALSE &&
8206 f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
8207 {
8208 if ( f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS )
8209 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DECODING;
8210 }
8211
8212 /* Check if encoder port has been specified when a rate has been set. */
8213 if ( f_pCodecConfig->ulEncoderPort == cOCT6100_NO_ENCODING &&
8214 f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS )
8215 return cOCT6100_ERR_CHANNEL_ENCODER_PORT;
8216
8217 /* Check if decoder port has been specified when a rate has been set. */
8218 if ( f_pCodecConfig->ulDecoderPort == cOCT6100_NO_DECODING &&
8219 f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS )
8220 return cOCT6100_ERR_CHANNEL_DECODER_PORT;
8221
8222 /* Check Encoder related parameter if one is used.*/
8223 if ( f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
8224 {
8225 /* Check the Encoder compression rate.*/
8226 if ( ( f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS ) &&
8227 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_40KBPS ) &&
8228 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_32KBPS ) &&
8229 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_24KBPS ) &&
8230 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_16KBPS ) &&
8231 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_40KBPS_4_1 ) &&
8232 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_40KBPS_3_2 ) &&
8233 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_40KBPS_2_3 ) &&
8234 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_32KBPS_4_0 ) &&
8235 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_32KBPS_3_1 ) &&
8236 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_32KBPS_2_2 ) &&
8237 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_24KBPS_3_0 ) &&
8238 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_24KBPS_2_1 ) &&
8239 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_16KBPS_2_0 ) )
8240 return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
8241
8242 /* Verify phasing information.*/
8243 if ( f_pCodecConfig->ulPhasingType != cOCT6100_SINGLE_PHASING &&
8244 f_pCodecConfig->ulPhasingType != cOCT6100_DUAL_PHASING &&
8245 f_pCodecConfig->ulPhasingType != cOCT6100_NO_PHASING )
8246 return cOCT6100_ERR_CHANNEL_PHASING_TYPE;
8247
8248 /* Verify the silence suppression parameters.*/
8249 if ( f_pCodecConfig->fEnableSilenceSuppression != TRUE &&
8250 f_pCodecConfig->fEnableSilenceSuppression != FALSE )
8251 return cOCT6100_ERR_CHANNEL_SIL_SUP_ENABLE;
8252
8253 if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8254 f_pApiInstance->pSharedInfo->ImageInfo.fSilenceSuppression == FALSE )
8255 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIL_SUP;
8256
8257 if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8258 f_pCodecConfig->ulPhasingType == cOCT6100_NO_PHASING )
8259 return cOCT6100_ERR_CHANNEL_PHASE_TYPE_REQUIRED;
8260
8261 if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8262 f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE )
8263 return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED;
8264
8265 if ( f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE &&
8266 f_pCodecConfig->ulPhasingType != cOCT6100_NO_PHASING )
8267 return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED;
8268
8269 /* Silence suppression can only be performed if the encoder is using the SOUT port.*/
8270 if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8271 f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_SOUT )
8272 return cOCT6100_ERR_CHANNEL_SIL_SUP_INVALID_ENCODER_PORT;
8273
8274 /* Check phasing TSST info if phasing is required.*/
8275 if ( f_pCodecConfig->ulPhasingTsstHndl != cOCT6100_INVALID_HANDLE )
8276 {
8277 tPOCT6100_API_PHASING_TSST pPhasingEntry;
8278 UINT32 ulEntryOpenCnt;
8279
8280 /* Check the provided handle. */
8281 if ( (f_pCodecConfig->ulPhasingTsstHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_PHASING_TSST )
8282 return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
8283
8284 *f_pusPhasingTsstIndex = (UINT16)( f_pCodecConfig->ulPhasingTsstHndl & cOCT6100_HNDL_INDEX_MASK );
8285 if ( *f_pusPhasingTsstIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxPhasingTssts )
8286 return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
8287
8288 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, *f_pusPhasingTsstIndex );
8289
8290 /* Extract the entry open count from the provided handle. */
8291 ulEntryOpenCnt = (f_pCodecConfig->ulPhasingTsstHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
8292
8293 /* Verify if the state of the phasing TSST.*/
8294 if ( pPhasingEntry->fReserved != TRUE )
8295 return cOCT6100_ERR_CHANNEL_PHASING_TSST_NOT_OPEN;
8296 if ( ulEntryOpenCnt != pPhasingEntry->byEntryOpenCnt )
8297 return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
8298
8299 /* Check the specified phase value against the phasing length of the phasing TSST.*/
8300 if ( ( f_pCodecConfig->ulPhase == 0 )
8301 || ( f_pCodecConfig->ulPhase >= pPhasingEntry->usPhasingLength ) )
8302 return cOCT6100_ERR_CHANNEL_PHASING_INVALID_PHASE;
8303 }
8304 else
8305 {
8306 *f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX;
8307 }
8308 }
8309 else
8310 {
8311 *f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX;
8312 }
8313
8314
8315 /* Check Decoder related parameter if one is used.*/
8316 if ( f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
8317 {
8318 /* Check the Decoding rate.*/
8319 if ( f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS &&
8320 f_pCodecConfig->ulDecodingRate != cOCT6100_G726_40KBPS &&
8321 f_pCodecConfig->ulDecodingRate != cOCT6100_G726_32KBPS &&
8322 f_pCodecConfig->ulDecodingRate != cOCT6100_G726_24KBPS &&
8323 f_pCodecConfig->ulDecodingRate != cOCT6100_G726_16KBPS &&
8324 f_pCodecConfig->ulDecodingRate != cOCT6100_G726_ENCODED &&
8325 f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G726_ENCODED &&
8326 f_pCodecConfig->ulDecodingRate != cOCT6100_G727_2C_ENCODED &&
8327 f_pCodecConfig->ulDecodingRate != cOCT6100_G727_3C_ENCODED &&
8328 f_pCodecConfig->ulDecodingRate != cOCT6100_G727_4C_ENCODED &&
8329 f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G727_2C_ENCODED &&
8330 f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G727_3C_ENCODED &&
8331 f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G727_4C_ENCODED )
8332 return cOCT6100_ERR_CHANNEL_DECODING_RATE;
8333
8334 /* Make sure that two timeslot are allocated if PCM-ECHO encoded is selected.*/
8335 if ( (f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G726_ENCODED ||
8336 f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_2C_ENCODED ||
8337 f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_3C_ENCODED ||
8338 f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_4C_ENCODED ) &&
8339 f_ulDecoderNumTssts != 2 )
8340 return cOCT6100_ERR_CHANNEL_MISSING_TSST;
8341 }
8342
8343 return cOCT6100_ERR_OK;
8344 }
8345 #endif
8346
8347 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8348
8349 Function: Oct6100ApiWriteInputTsstControlMemory
8350
8351 Description: This function configure a TSST control memory entry in internal memory.
8352
8353 -------------------------------------------------------------------------------
8354 | Argument | Description
8355 -------------------------------------------------------------------------------
8356 f_pApiInstance Pointer to API instance. This memory is used to keep
8357 the present state of the chip and all its resources.
8358
8359 f_usTsstIndex TSST index within the TSST control memory.
8360 f_usTsiMemIndex TSI index within the TSI chariot memory.
8361 f_ulTsstInputLaw PCM law of the input TSST.
8362
8363 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8364 #if !SKIP_Oct6100ApiWriteInputTsstControlMemory
8365 UINT32 Oct6100ApiWriteInputTsstControlMemory(
8366 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8367 IN UINT16 f_usTsstIndex,
8368 IN UINT16 f_usTsiMemIndex,
8369 IN UINT32 f_ulTsstInputLaw )
8370 {
8371 tOCT6100_WRITE_PARAMS WriteParams;
8372 UINT32 ulResult;
8373
8374 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8375
8376 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8377
8378 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
8379
8380 WriteParams.usWriteData = cOCT6100_TSST_CONTROL_MEM_INPUT_TSST;
8381 WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8382
8383 /* Set the PCM law.*/
8384 WriteParams.usWriteData |= f_ulTsstInputLaw << cOCT6100_TSST_CONTROL_MEM_PCM_LAW_OFFSET;
8385
8386 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8387 if ( ulResult != cOCT6100_ERR_OK )
8388 return ulResult;
8389
8390 return cOCT6100_ERR_OK;
8391 }
8392 #endif
8393
8394
8395
8396 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8397
8398 Function: Oct6100ApiWriteOutputTsstControlMemory
8399
8400 Description: This function configure a TSST control memory entry in internal memory.
8401
8402 -------------------------------------------------------------------------------
8403 | Argument | Description
8404 -------------------------------------------------------------------------------
8405 f_pApiInstance Pointer to API instance. This memory is used to keep
8406 the present state of the chip and all its resources.
8407
8408 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8409 #if !SKIP_Oct6100ApiWriteOutputTsstControlMemory
8410 UINT32 Oct6100ApiWriteOutputTsstControlMemory(
8411 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8412 IN UINT16 f_usTsstIndex,
8413 IN UINT32 f_ulAdpcmNibblePosition,
8414 IN UINT32 f_ulNumTssts,
8415 IN UINT16 f_usTsiMemIndex )
8416 {
8417 tOCT6100_WRITE_PARAMS WriteParams;
8418 UINT32 ulResult;
8419
8420 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8421
8422 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8423
8424 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
8425
8426 WriteParams.usWriteData = cOCT6100_TSST_CONTROL_MEM_OUTPUT_TSST;
8427 WriteParams.usWriteData |= f_ulAdpcmNibblePosition << cOCT6100_TSST_CONTROL_MEM_NIBBLE_POS_OFFSET;
8428 WriteParams.usWriteData |= (f_ulNumTssts - 1) << cOCT6100_TSST_CONTROL_MEM_TSST_NUM_OFFSET;
8429 WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8430
8431 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8432 if ( ulResult != cOCT6100_ERR_OK )
8433 return ulResult;
8434
8435 return cOCT6100_ERR_OK;
8436 }
8437 #endif
8438
8439
8440 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8441
8442 Function: Oct6100ApiWriteEncoderMemory
8443
8444 Description: This function configure a Encoded memory entry in internal memory.
8445
8446 -------------------------------------------------------------------------------
8447 | Argument | Description
8448 -------------------------------------------------------------------------------
8449 f_pApiInstance Pointer to API instance. This memory is used to keep
8450 the present state of the chip and all its resources.
8451
8452 f_ulEncoderIndex Index of the encoder block within the ADPCM context memory.
8453 f_ulCompType Compression rate of the encoder.
8454 f_usTsiMemIndex TSI index within the TSI chariot memory used by the encoder.
8455 f_ulEnableSilenceSuppression Silence suppression enable flag.
8456 f_ulAdpcmNibblePosition ADPCM nibble position.
8457 f_usPhasingTsstIndex Phasing TSST index within the API's Phassing TSST list.
8458 f_ulPhasingType Type of the Phasing TSST.
8459 f_ulPhase Phase used with this encoder.
8460
8461 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8462 #if !SKIP_Oct6100ApiWriteEncoderMemory
8463 UINT32 Oct6100ApiWriteEncoderMemory(
8464 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8465 IN UINT32 f_ulEncoderIndex,
8466 IN UINT32 f_ulCompType,
8467 IN UINT16 f_usTsiMemIndex,
8468 IN UINT32 f_ulEnableSilenceSuppression,
8469 IN UINT32 f_ulAdpcmNibblePosition,
8470 IN UINT16 f_usPhasingTsstIndex,
8471 IN UINT32 f_ulPhasingType,
8472 IN UINT32 f_ulPhase )
8473 {
8474 tOCT6100_WRITE_PARAMS WriteParams;
8475 UINT32 ulResult;
8476
8477 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8478
8479 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8480
8481 /*==============================================================================*/
8482 /* Conversion Control Base */
8483 WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_ulEncoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
8484
8485 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ENCODER;
8486 WriteParams.usWriteData |= f_ulCompType << cOCT6100_CONVERSION_CONTROL_MEM_COMP_OFFSET;
8487 WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8488
8489 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8490 if ( ulResult != cOCT6100_ERR_OK )
8491 return ulResult;
8492
8493 /*==============================================================================*/
8494 /* Conversion Control Base + 2 */
8495 WriteParams.ulWriteAddress += 2;
8496
8497 /* Set the phasing TSST number.*/
8498 if ( f_usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
8499 WriteParams.usWriteData = (UINT16)( f_usPhasingTsstIndex << cOCT6100_CONVERSION_CONTROL_MEM_PHASE_OFFSET );
8500 else
8501 WriteParams.usWriteData = 0;
8502
8503 /* Set the phasing type and the phase value if required.*/
8504 switch( f_ulPhasingType )
8505 {
8506 case cOCT6100_NO_PHASING:
8507 WriteParams.usWriteData |= 0x1 << 10;
8508 break;
8509 case cOCT6100_SINGLE_PHASING:
8510 WriteParams.usWriteData |= f_ulPhase;
8511 break;
8512 case cOCT6100_DUAL_PHASING:
8513 WriteParams.usWriteData |= 0x1 << 11;
8514 WriteParams.usWriteData |= f_ulPhase;
8515 break;
8516 default:
8517 /* No problem. */
8518 break;
8519 }
8520
8521 /* Set the silence suppression flag.*/
8522 WriteParams.usWriteData |= f_ulEnableSilenceSuppression << cOCT6100_CONVERSION_CONTROL_MEM_SIL_SUP_OFFSET;
8523
8524 /* Set the nibble position.*/
8525 WriteParams.usWriteData |= f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET;
8526
8527 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8528 if ( ulResult != cOCT6100_ERR_OK )
8529 return ulResult;
8530
8531 /*==============================================================================*/
8532 /* Conversion Control Base + 4 */
8533 WriteParams.ulWriteAddress += 2;
8534
8535 /* Set the reset mode */
8536 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR;
8537
8538 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8539 if ( ulResult != cOCT6100_ERR_OK )
8540 return ulResult;
8541
8542 /*==============================================================================*/
8543 /* Conversion Control Base + 6 */
8544 WriteParams.ulWriteAddress += 2;
8545
8546 /* Set the reset mode */
8547 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY;
8548
8549 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8550 if ( ulResult != cOCT6100_ERR_OK )
8551 return ulResult;
8552
8553 /*==============================================================================*/
8554 return cOCT6100_ERR_OK;
8555 }
8556 #endif
8557
8558
8559 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8560
8561 Function: Oct6100ApiWriteDecoderMemory
8562
8563 Description: This function configure a Decoder memory entry in internal memory.
8564
8565 -------------------------------------------------------------------------------
8566 | Argument | Description
8567 -------------------------------------------------------------------------------
8568 f_pApiInstance Pointer to API instance. This memory is used to keep
8569 the present state of the chip and all its resources.
8570
8571 f_usDecoderIndex Index of the decoder block within the ADPCM context memory.
8572 f_ulCompType Decompression rate of the decoder.
8573 f_usTsiMemIndex TSI index within the TSI chariot memory.
8574 f_ulPcmLaw PCM law of the decoded samples.
8575 f_ulAdpcmNibblePosition ADPCM nibble position.
8576
8577 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8578 #if !SKIP_Oct6100ApiWriteDecoderMemory
8579 UINT32 Oct6100ApiWriteDecoderMemory(
8580 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8581 IN UINT16 f_usDecoderIndex,
8582 IN UINT32 f_ulCompType,
8583 IN UINT16 f_usTsiMemIndex,
8584 IN UINT32 f_ulPcmLaw,
8585 IN UINT32 f_ulAdpcmNibblePosition )
8586 {
8587 tOCT6100_WRITE_PARAMS WriteParams;
8588 UINT32 ulResult;
8589
8590 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8591
8592 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8593
8594
8595 /*==============================================================================*/
8596 /* Conversion Control Base */
8597 WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_usDecoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
8598
8599 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_DECODER;
8600 WriteParams.usWriteData |= f_ulCompType << cOCT6100_CONVERSION_CONTROL_MEM_COMP_OFFSET;
8601 WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8602
8603 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8604 if ( ulResult != cOCT6100_ERR_OK )
8605 return ulResult;
8606
8607 /*==============================================================================*/
8608 /* Conversion Control Base + 2 */
8609 WriteParams.ulWriteAddress += 2;
8610
8611 /* Set the nibble position.*/
8612 WriteParams.usWriteData = (UINT16)( f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET );
8613
8614 /* Set the law.*/
8615 WriteParams.usWriteData |= f_ulPcmLaw << cOCT6100_CONVERSION_CONTROL_MEM_LAW_OFFSET;
8616
8617 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8618 if ( ulResult != cOCT6100_ERR_OK )
8619 return ulResult;
8620
8621 /*==============================================================================*/
8622 /* Conversion Control Base + 4 */
8623 WriteParams.ulWriteAddress += 2;
8624
8625 /* Set the reset mode */
8626 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR;
8627
8628 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8629 if ( ulResult != cOCT6100_ERR_OK )
8630 return ulResult;
8631
8632 /*==============================================================================*/
8633 /* Conversion Control Base + 6 */
8634 WriteParams.ulWriteAddress += 2;
8635
8636 /* Set the reset mode */
8637 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY;
8638
8639 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8640 if ( ulResult != cOCT6100_ERR_OK )
8641 return ulResult;
8642
8643 return cOCT6100_ERR_OK;
8644 }
8645 #endif
8646
8647
8648
8649 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8650
8651 Function: Oct6100ApiClearConversionMemory
8652
8653 Description: This function clears a conversion memory entry in internal
8654 memory.
8655
8656 -------------------------------------------------------------------------------
8657 | Argument | Description
8658 -------------------------------------------------------------------------------
8659 f_pApiInstance Pointer to API instance. This memory is used to keep
8660 the present state of the chip and all its resources.
8661
8662 f_usConversionMemIndex Index of the block within the conversion memory.
8663
8664 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8665 #if !SKIP_Oct6100ApiClearConversionMemory
8666 UINT32 Oct6100ApiClearConversionMemory(
8667 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8668 IN UINT16 f_usConversionMemIndex )
8669 {
8670 tOCT6100_WRITE_PARAMS WriteParams;
8671 tOCT6100_READ_PARAMS ReadParams;
8672 UINT32 ulResult;
8673 UINT32 ulBaseAddress;
8674 UINT16 usReadData;
8675
8676 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8677
8678 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8679 WriteParams.usWriteData = 0;
8680
8681 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
8682
8683 ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8684 ReadParams.pusReadData = &usReadData;
8685
8686 /*==============================================================================*/
8687 /* Clear the entry */
8688 ulBaseAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_usConversionMemIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
8689 /* The "activate" bit at offset +6 must be cleared first. */
8690 WriteParams.ulWriteAddress = ulBaseAddress + 6;
8691
8692 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8693 if ( ulResult != cOCT6100_ERR_OK )
8694 return ulResult;
8695
8696 /* Read at 0x200 to make sure there is no corruption on channel 0. */
8697 ReadParams.ulReadAddress = 0x200;
8698 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
8699 if ( ulResult != cOCT6100_ERR_OK )
8700 return ulResult;
8701
8702 /* Then clear the rest of the structure. */
8703 WriteParams.ulWriteAddress = ulBaseAddress + 4;
8704
8705 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8706 if ( ulResult != cOCT6100_ERR_OK )
8707 return ulResult;
8708
8709 WriteParams.ulWriteAddress = ulBaseAddress + 2;
8710
8711 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8712 if ( ulResult != cOCT6100_ERR_OK )
8713 return ulResult;
8714
8715 WriteParams.ulWriteAddress = ulBaseAddress;
8716
8717 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8718 if ( ulResult != cOCT6100_ERR_OK )
8719 return ulResult;
8720
8721 /*==============================================================================*/
8722
8723 return cOCT6100_ERR_OK;
8724 }
8725 #endif
8726
8727
8728 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8729
8730 Function: Oct6100ApiWriteVqeMemory
8731
8732 Description: This function configure an echo memory entry in internal memory and
8733 external memory.
8734
8735 -------------------------------------------------------------------------------
8736 | Argument | Description
8737 -------------------------------------------------------------------------------
8738 f_pApiInstance Pointer to API instance. This memory is used to keep
8739 the present state of the chip and all its resources.
8740
8741 f_pVqeConfig Pointer to a VQE config structure.
8742 f_pChannelOpen Pointer to a channel configuration structure.
8743 f_usChanIndex Index of the echo channel in the API instance.
8744 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
8745 f_fClearPlayoutPointers Flag indicating if the playout pointer should be cleared.
8746 f_fModifyOnly Flag indicating if the configuration should be
8747 modified only.
8748
8749 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8750 #if !SKIP_Oct6100ApiWriteVqeMemory
8751 UINT32 Oct6100ApiWriteVqeMemory(
8752 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8753 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
8754 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
8755 IN UINT16 f_usChanIndex,
8756 IN UINT16 f_usEchoMemIndex,
8757 IN BOOL f_fClearPlayoutPointers,
8758 IN BOOL f_fModifyOnly )
8759 {
8760 UINT32 ulResult;
8761
8762 /* Write the NLP software configuration structure. */
8763 ulResult = Oct6100ApiWriteVqeNlpMemory(
8764 f_pApiInstance,
8765 f_pVqeConfig,
8766 f_pChannelOpen,
8767 f_usChanIndex,
8768 f_usEchoMemIndex,
8769 f_fClearPlayoutPointers,
8770 f_fModifyOnly );
8771 if ( ulResult != cOCT6100_ERR_OK )
8772 return ulResult;
8773
8774 /* Write the AF software configuration structure. */
8775 ulResult = Oct6100ApiWriteVqeAfMemory(
8776 f_pApiInstance,
8777 f_pVqeConfig,
8778 f_pChannelOpen,
8779 f_usChanIndex,
8780 f_usEchoMemIndex,
8781 f_fClearPlayoutPointers,
8782 f_fModifyOnly );
8783 if ( ulResult != cOCT6100_ERR_OK )
8784 return ulResult;
8785
8786 return cOCT6100_ERR_OK;
8787 }
8788 #endif
8789
8790 UINT32 oct6100_retrieve_nlp_conf_dword(tPOCT6100_INSTANCE_API f_pApiInst,
8791 tPOCT6100_API_CHANNEL f_pChanEntry,
8792 UINT32 f_ulAddress,
8793 UINT32 *f_pulConfigDword)
8794 {
8795 tOCT6100_READ_PARAMS _ReadParams;
8796 UINT16 _usReadData;
8797 UINT32 ulResult = cOCT6100_ERR_FATAL_8E;
8798 (*f_pulConfigDword) = cOCT6100_INVALID_VALUE;
8799
8800 _ReadParams.pProcessContext = f_pApiInst->pProcessContext;
8801 mOCT6100_ASSIGN_USER_READ_WRITE_OBJ(f_pApiInst, _ReadParams);
8802 _ReadParams.ulUserChipId = f_pApiInst->pSharedInfo->ChipConfig.ulUserChipId;
8803 _ReadParams.pusReadData = &_usReadData;
8804
8805 /* Read the first 16 bits.*/
8806 _ReadParams.ulReadAddress = f_ulAddress;
8807 mOCT6100_DRIVER_READ_API(_ReadParams, ulResult);
8808 if (ulResult == cOCT6100_ERR_OK) {
8809 /* Save data.*/
8810 (*f_pulConfigDword) = _usReadData << 16;
8811
8812 /* Read the last 16 bits .*/
8813 _ReadParams.ulReadAddress += 2;
8814 mOCT6100_DRIVER_READ_API(_ReadParams, ulResult);
8815 if (ulResult == cOCT6100_ERR_OK) {
8816 /* Save data.*/
8817 (*f_pulConfigDword) |= _usReadData;
8818 ulResult = cOCT6100_ERR_OK;
8819 }
8820 }
8821 return ulResult;
8822 }
8823
8824 UINT32 oct6100_save_nlp_conf_dword(tPOCT6100_INSTANCE_API f_pApiInst,
8825 tPOCT6100_API_CHANNEL f_pChanEntry,
8826 UINT32 f_ulAddress,
8827 UINT32 f_ulConfigDword)
8828 {
8829 UINT32 ulResult;
8830
8831 /* Write the config DWORD. */
8832 tOCT6100_WRITE_PARAMS _WriteParams;
8833
8834 _WriteParams.pProcessContext = f_pApiInst->pProcessContext;
8835 mOCT6100_ASSIGN_USER_READ_WRITE_OBJ(f_pApiInst, _WriteParams)
8836 _WriteParams.ulUserChipId = f_pApiInst->pSharedInfo->ChipConfig.ulUserChipId;
8837
8838 /* Write the first 16 bits. */
8839 _WriteParams.ulWriteAddress = f_ulAddress;
8840 _WriteParams.usWriteData = (UINT16)((f_ulConfigDword >> 16) & 0xFFFF);
8841 mOCT6100_DRIVER_WRITE_API(_WriteParams, ulResult);
8842
8843 if (ulResult == cOCT6100_ERR_OK) {
8844 /* Write the last word. */
8845 _WriteParams.ulWriteAddress = f_ulAddress + 2;
8846 _WriteParams.usWriteData = (UINT16)(f_ulConfigDword & 0xFFFF);
8847 mOCT6100_DRIVER_WRITE_API(_WriteParams, ulResult);
8848 }
8849 return ulResult;
8850 }
8851
8852
8853
8854 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8855
8856 Function: Oct6100ApiWriteVqeNlpMemory
8857
8858 Description: This function configures the NLP related VQE features of an
8859 echo channel.
8860
8861 -------------------------------------------------------------------------------
8862 | Argument | Description
8863 -------------------------------------------------------------------------------
8864 f_pApiInstance Pointer to API instance. This memory is used to keep
8865 the present state of the chip and all its resources.
8866
8867 f_pVqeConfig Pointer to a VQE config structure.
8868 f_pChannelOpen Pointer to a channel configuration structure.
8869 f_usChanIndex Index of the echo channel in the API instance.
8870 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
8871 f_fClearPlayoutPointers Flag indicating if the playout pointer should be cleared.
8872 f_fModifyOnly Flag indicating if the configuration should be
8873 modified only.
8874
8875 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8876 #if !SKIP_Oct6100ApiWriteVqeNlpMemory
8877 UINT32 Oct6100ApiWriteVqeNlpMemory(
8878 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8879 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
8880 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
8881 IN UINT16 f_usChanIndex,
8882 IN UINT16 f_usEchoMemIndex,
8883 IN BOOL f_fClearPlayoutPointers,
8884 IN BOOL f_fModifyOnly )
8885 {
8886 tPOCT6100_API_CHANNEL pChanEntry;
8887 tPOCT6100_SHARED_INFO pSharedInfo;
8888 tOCT6100_WRITE_PARAMS WriteParams;
8889 tOCT6100_BUFFER_PLAYOUT_STOP BufferPlayoutStop;
8890 UINT32 ulResult;
8891 UINT32 ulTempData;
8892 UINT32 ulNlpConfigBaseAddress;
8893 UINT32 ulFeatureBytesOffset;
8894 UINT32 ulFeatureBitOffset;
8895 UINT32 ulFeatureFieldLength;
8896 UINT32 ulMask;
8897 UINT16 usTempData;
8898 BOOL fEchoOperationModeChanged;
8899
8900 pSharedInfo = f_pApiInstance->pSharedInfo;
8901
8902 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8903
8904 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
8905
8906 /* Obtain a pointer to the new buffer's list entry. */
8907 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
8908
8909 /*==============================================================================*/
8910 /* Configure the CPU NLP configuration of the channel feature by feature.*/
8911
8912 ulNlpConfigBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
8913
8914 /* Set initial value to zero.*/
8915 ulTempData = 0;
8916
8917 /* Configure Adaptive Noise Reduction.*/
8918 if (pSharedInfo->ImageInfo.fAdaptiveNoiseReduction == TRUE) {
8919 /* Check if the configuration has been changed. */
8920 if ( ( f_fModifyOnly == FALSE )
8921 || ( ( f_fModifyOnly == TRUE )
8922 && ( ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction )
8923 || ( f_pVqeConfig->fSoutNoiseBleaching != pChanEntry->VqeConfig.fSoutNoiseBleaching )
8924 ) ) )
8925 {
8926 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.usDwordOffset * 4;
8927 ulFeatureBitOffset = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byBitOffset;
8928 ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byFieldSize;
8929
8930 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
8931 pChanEntry,
8932 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8933 &ulTempData);
8934 if ( ulResult != cOCT6100_ERR_OK )
8935 return ulResult;
8936
8937 /* Clear previous value set in the feature field.*/
8938 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8939
8940 ulTempData &= (~ulMask);
8941
8942 /* Set adaptive noise reduction on the SOUT port.*/
8943 ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutAdaptiveNoiseReduction ) << ulFeatureBitOffset );
8944
8945 /* If SOUT noise bleaching is requested, ANR must be activated. */
8946 ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutNoiseBleaching ) << ulFeatureBitOffset );
8947
8948 /* First read the DWORD where the field is located. */
8949 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
8950 pChanEntry,
8951 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8952 ulTempData);
8953 if ( ulResult != cOCT6100_ERR_OK )
8954 return ulResult;
8955 }
8956 }
8957
8958 /* Configure Rout Noise Reduction. */
8959 if (pSharedInfo->ImageInfo.fRoutNoiseReduction == TRUE) {
8960 /* Check if the configuration has been changed. */
8961 if ( ( f_fModifyOnly == FALSE )
8962 || ( ( f_fModifyOnly == TRUE )
8963 && ( f_pVqeConfig->fRoutNoiseReduction != pChanEntry->VqeConfig.fRoutNoiseReduction ) ) )
8964 {
8965 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAnrOfst.usDwordOffset * 4;
8966 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinAnrOfst.byBitOffset;
8967 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAnrOfst.byFieldSize;
8968
8969 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
8970 pChanEntry,
8971 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8972 &ulTempData);
8973 if ( ulResult != cOCT6100_ERR_OK )
8974 return ulResult;
8975
8976 /* Clear previous value set in the feature field.*/
8977 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8978
8979 ulTempData &= (~ulMask);
8980
8981 /* Set noise reduction on the Rout port. */
8982 ulTempData |= ( ( (UINT32)f_pVqeConfig->fRoutNoiseReduction ) << ulFeatureBitOffset );
8983
8984 /* Write the new DWORD where the field is located. */
8985 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
8986 pChanEntry,
8987 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8988 ulTempData);
8989 if ( ulResult != cOCT6100_ERR_OK )
8990 return ulResult;
8991 }
8992 }
8993
8994 if (pSharedInfo->ImageInfo.fRoutNoiseReductionLevel == TRUE)
8995 {
8996 /* Check if the configuration has been changed. */
8997 if ( ( f_fModifyOnly == FALSE )
8998 || ( ( f_fModifyOnly == TRUE )
8999 && ( (f_pVqeConfig->lRoutNoiseReductionLevelGainDb != pChanEntry->VqeConfig.chRoutNoiseReductionLevelGainDb )
9000 ||( f_pVqeConfig->fRoutNoiseReduction != pChanEntry->VqeConfig.fRoutNoiseReduction ) ) ) )
9001 {
9002 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAnrValOfst.usDwordOffset * 4;
9003 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinAnrValOfst.byBitOffset;
9004 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAnrValOfst.byFieldSize;
9005
9006 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9007 pChanEntry,
9008 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9009 &ulTempData);
9010 if ( ulResult != cOCT6100_ERR_OK )
9011 return ulResult;
9012
9013 /* Clear previous value set in the feature field.*/
9014 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9015
9016 ulTempData &= (~ulMask);
9017
9018 if (f_pVqeConfig->fRoutNoiseReduction == TRUE)
9019 {
9020 switch( f_pVqeConfig->lRoutNoiseReductionLevelGainDb)
9021 {
9022 case 0: ulTempData |= ( 0 << ulFeatureBitOffset );
9023 break;
9024 case -6: ulTempData |= ( 1 << ulFeatureBitOffset );
9025 break;
9026 case -12: ulTempData |= ( 2 << ulFeatureBitOffset );
9027 break;
9028 case -18: ulTempData |= ( 3 << ulFeatureBitOffset );
9029 break;
9030 default: ulTempData |= ( 0 << ulFeatureBitOffset );
9031 break;
9032 }
9033 }
9034 else
9035 ulTempData |= ( 0 << ulFeatureBitOffset );
9036
9037 /* Write the new DWORD where the field is located. */
9038 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9039 pChanEntry,
9040 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9041 ulTempData);
9042 if ( ulResult != cOCT6100_ERR_OK )
9043 return ulResult;
9044 }
9045
9046 }
9047
9048 /* Configure Sout ANR SNR enhancement. */
9049 if ( pSharedInfo->ImageInfo.fAnrSnrEnhancement == TRUE )
9050 {
9051 /* Check if the configuration has been changed. */
9052 if ( ( f_fModifyOnly == FALSE )
9053 || ( ( f_fModifyOnly == TRUE )
9054 && ( f_pVqeConfig->lAnrSnrEnhancementDb != pChanEntry->VqeConfig.chAnrSnrEnhancementDb ) ) )
9055 {
9056 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.usDwordOffset * 4;
9057 ulFeatureBitOffset = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byBitOffset;
9058 ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byFieldSize;
9059
9060 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9061 pChanEntry,
9062 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9063 &ulTempData);
9064 if ( ulResult != cOCT6100_ERR_OK )
9065 return ulResult;
9066
9067 /* Clear previous value set in the feature field.*/
9068 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9069
9070 ulTempData &= (~ulMask);
9071
9072 /* Set ANR SNR enhancement on the Sout port. */
9073 switch( f_pVqeConfig->lAnrSnrEnhancementDb )
9074 {
9075 case -9: ulTempData |= ( 7 << ulFeatureBitOffset );
9076 break;
9077 case -12: ulTempData |= ( 6 << ulFeatureBitOffset );
9078 break;
9079 case -15: ulTempData |= ( 5 << ulFeatureBitOffset );
9080 break;
9081 case -21: ulTempData |= ( 3 << ulFeatureBitOffset );
9082 break;
9083 case -24: ulTempData |= ( 2 << ulFeatureBitOffset );
9084 break;
9085 case -27: ulTempData |= ( 1 << ulFeatureBitOffset );
9086 break;
9087 case -30: ulTempData |= ( 0 << ulFeatureBitOffset );
9088 break;
9089 default: ulTempData |= ( 4 << ulFeatureBitOffset );
9090 /* -18 */
9091 break;
9092 }
9093
9094 /* Write the new DWORD where the field is located. */
9095 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9096 pChanEntry,
9097 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9098 ulTempData);
9099 if ( ulResult != cOCT6100_ERR_OK )
9100 return ulResult;
9101 }
9102 }
9103
9104 /* Configure Sout ANR voice-noise segregation. */
9105 if ( pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation == TRUE )
9106 {
9107 /* Check if the configuration has been changed. */
9108 if ( ( f_fModifyOnly == FALSE )
9109 || ( ( f_fModifyOnly == TRUE )
9110 && ( f_pVqeConfig->ulAnrVoiceNoiseSegregation != pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation ) ) )
9111 {
9112 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.usDwordOffset * 4;
9113 ulFeatureBitOffset = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byBitOffset;
9114 ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byFieldSize;
9115
9116 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9117 pChanEntry,
9118 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9119 &ulTempData);
9120 if ( ulResult != cOCT6100_ERR_OK )
9121 return ulResult;
9122
9123 /* Clear previous value set in the feature field.*/
9124 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9125
9126 ulTempData &= (~ulMask);
9127
9128 /* Set ANR voice-noise segregation on the Sout port. */
9129 ulTempData |= ( ( (UINT32)f_pVqeConfig->ulAnrVoiceNoiseSegregation ) << ulFeatureBitOffset );
9130
9131 /* Write the new DWORD where the field is located. */
9132 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9133 pChanEntry,
9134 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9135 ulTempData);
9136 if ( ulResult != cOCT6100_ERR_OK )
9137 return ulResult;
9138 }
9139 }
9140
9141 /* Configure the tone disabler VQE activation delay. */
9142 if ( pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay == TRUE )
9143 {
9144 /* Check if the configuration has been changed. */
9145 if ( ( f_fModifyOnly == FALSE )
9146 || ( ( f_fModifyOnly == TRUE )
9147 && ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay )
9148 || ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) ) ) )
9149 {
9150 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.usDwordOffset * 4;
9151 ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byBitOffset;
9152 ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byFieldSize;
9153
9154 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9155 pChanEntry,
9156 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9157 &ulTempData);
9158 if ( ulResult != cOCT6100_ERR_OK )
9159 return ulResult;
9160
9161 /* Clear previous value set in the feature field.*/
9162 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9163
9164 ulTempData &= (~ulMask);
9165
9166 /* Set the tone disabler VQE activation delay. The VQE activation delay */
9167 /* is only set if the tone disabler is activated. */
9168 if ( f_pChannelOpen->fEnableToneDisabler == TRUE )
9169 ulTempData |= ( ( (UINT32)( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay - 300 ) / 512 ) ) << ulFeatureBitOffset );
9170 else
9171 ulTempData |= ( 0 ) << ulFeatureBitOffset;
9172
9173 /* Write the new DWORD where the field is located. */
9174 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9175 pChanEntry,
9176 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9177 ulTempData);
9178 if ( ulResult != cOCT6100_ERR_OK )
9179 return ulResult;
9180 }
9181 }
9182
9183 /* Configure Conferencing Noise Reduction.*/
9184 if ( pSharedInfo->ImageInfo.fConferencingNoiseReduction == TRUE )
9185 {
9186 /* Check if the configuration has been changed. */
9187 if ( ( f_fModifyOnly == FALSE )
9188 || ( ( f_fModifyOnly == TRUE )
9189 && ( ( f_pVqeConfig->fSoutConferencingNoiseReduction != pChanEntry->VqeConfig.fSoutConferencingNoiseReduction )
9190 || ( f_pVqeConfig->fSoutNoiseBleaching != pChanEntry->VqeConfig.fSoutNoiseBleaching ) ) ) )
9191 {
9192 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.usDwordOffset * 4;
9193 ulFeatureBitOffset = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byBitOffset;
9194 ulFeatureFieldLength = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byFieldSize;
9195
9196 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9197 pChanEntry,
9198 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9199 &ulTempData);
9200 if ( ulResult != cOCT6100_ERR_OK )
9201 return ulResult;
9202
9203 /* Clear previous value set in the feature field.*/
9204 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9205
9206 ulTempData &= (~ulMask);
9207
9208 /* Set conferencing noise reduction on the SOUT port. */
9209 ulTempData |= (f_pVqeConfig->fSoutConferencingNoiseReduction << ulFeatureBitOffset );
9210
9211 /* If SOUT noise bleaching is requested, CNR must be activated. */
9212 ulTempData |= (f_pVqeConfig->fSoutNoiseBleaching << ulFeatureBitOffset );
9213
9214 /* Save the DWORD where the field is located. */
9215 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9216 pChanEntry,
9217 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9218 ulTempData);
9219 if ( ulResult != cOCT6100_ERR_OK )
9220 return ulResult;
9221 }
9222 }
9223
9224 /* Set the DC removal on RIN ports.*/
9225 if ( pSharedInfo->ImageInfo.fRinDcOffsetRemoval == TRUE )
9226 {
9227 /* Check if the configuration has been changed. */
9228 if ( ( f_fModifyOnly == FALSE )
9229 || ( ( f_fModifyOnly == TRUE )
9230 && ( f_pVqeConfig->fRinDcOffsetRemoval != pChanEntry->VqeConfig.fRinDcOffsetRemoval ) ) )
9231 {
9232 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.usDwordOffset * 4;
9233 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byBitOffset;
9234 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byFieldSize;
9235
9236 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9237 pChanEntry,
9238 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9239 &ulTempData);
9240 if ( ulResult != cOCT6100_ERR_OK )
9241 return ulResult;
9242
9243 /* Clear previous value set in the feature field.*/
9244 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9245
9246 ulTempData &= (~ulMask);
9247
9248 /* Set adaptive noise reduction on the SOUT port.*/
9249 ulTempData |= ( ( (UINT32)f_pVqeConfig->fRinDcOffsetRemoval ) << ulFeatureBitOffset );
9250
9251 /* The write the new DWORD where the field is located.*/
9252 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9253 pChanEntry,
9254 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9255 ulTempData);
9256 if ( ulResult != cOCT6100_ERR_OK )
9257 return ulResult;
9258 }
9259 }
9260
9261 /* Set the DC removal on SIN ports.*/
9262 if ( pSharedInfo->ImageInfo.fSinDcOffsetRemoval == TRUE )
9263 {
9264 /* Check if the configuration has been changed. */
9265 if ( ( f_fModifyOnly == FALSE )
9266 || ( ( f_fModifyOnly == TRUE )
9267 && ( f_pVqeConfig->fSinDcOffsetRemoval != pChanEntry->VqeConfig.fSinDcOffsetRemoval ) ) )
9268 {
9269 ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.usDwordOffset * 4;
9270 ulFeatureBitOffset = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byBitOffset;
9271 ulFeatureFieldLength = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byFieldSize;
9272
9273 /* First read the DWORD where the field is located.*/
9274 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9275 pChanEntry,
9276 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9277 &ulTempData);
9278 if ( ulResult != cOCT6100_ERR_OK )
9279 return ulResult;
9280
9281 /* Clear previous value set in the feature field.*/
9282 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9283
9284 ulTempData &= (~ulMask);
9285
9286 /* Set adaptive noise reduction on the SOUT port.*/
9287 ulTempData |= ( ( (UINT32)f_pVqeConfig->fSinDcOffsetRemoval ) << ulFeatureBitOffset );
9288
9289 /* Save the DWORD where the field is located.*/
9290 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9291 pChanEntry,
9292 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9293 ulTempData);
9294 if ( ulResult != cOCT6100_ERR_OK )
9295 return ulResult;
9296 }
9297 }
9298
9299 /* Set the level control. */
9300 if ( ( pChanEntry->byEchoOperationMode != f_pChannelOpen->ulEchoOperationMode )
9301 && ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NORMAL ) )
9302 fEchoOperationModeChanged = TRUE;
9303 else
9304 fEchoOperationModeChanged = FALSE;
9305
9306 /* If opening the channel, all level control configuration must be written. */
9307 if ( f_fModifyOnly == FALSE )
9308 fEchoOperationModeChanged = TRUE;
9309 ulResult = Oct6100ApiSetChannelLevelControl( f_pApiInstance,
9310 f_pVqeConfig,
9311 f_usChanIndex,
9312 f_usEchoMemIndex,
9313 fEchoOperationModeChanged );
9314 if ( ulResult != cOCT6100_ERR_OK )
9315 return ulResult;
9316
9317 /* Set the background noise freeze.*/
9318 if ( pSharedInfo->ImageInfo.fComfortNoise == TRUE )
9319 {
9320 /* Check if the configuration has been changed. */
9321 if ( ( f_fModifyOnly == FALSE )
9322 || ( ( f_fModifyOnly == TRUE )
9323 && ( f_pVqeConfig->ulComfortNoiseMode != pChanEntry->VqeConfig.byComfortNoiseMode ) ) )
9324 {
9325 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.usDwordOffset * 4;
9326 ulFeatureBitOffset = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byBitOffset;
9327 ulFeatureFieldLength = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byFieldSize;
9328
9329 /* First read the DWORD where the field is located.*/
9330 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9331 pChanEntry,
9332 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9333 &ulTempData);
9334 if ( ulResult != cOCT6100_ERR_OK )
9335 return ulResult;
9336
9337 /* Clear previous value set in the feature field.*/
9338 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9339
9340 ulTempData &= (~ulMask);
9341 ulTempData |= ( f_pVqeConfig->ulComfortNoiseMode << ulFeatureBitOffset );
9342
9343 /* Save the new DWORD where the field is located. */
9344 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9345 pChanEntry,
9346 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9347 ulTempData);
9348 if ( ulResult != cOCT6100_ERR_OK )
9349 return ulResult;
9350 }
9351 }
9352
9353 /* Set the state of the NLP */
9354 if ( pSharedInfo->ImageInfo.fNlpControl == TRUE )
9355 {
9356 /* Check if the configuration has been changed. */
9357 if ( ( f_fModifyOnly == FALSE )
9358 || ( ( f_fModifyOnly == TRUE )
9359 && ( f_pVqeConfig->fEnableNlp != pChanEntry->VqeConfig.fEnableNlp ) ) )
9360 {
9361 ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpControlFieldOfst.usDwordOffset * 4;
9362 ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpControlFieldOfst.byBitOffset;
9363 ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpControlFieldOfst.byFieldSize;
9364
9365 /* First read the DWORD where the field is located.*/
9366 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9367 pChanEntry,
9368 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9369 &ulTempData);
9370 if ( ulResult != cOCT6100_ERR_OK )
9371 return ulResult;
9372
9373 /* Clear previous value set in the feature field.*/
9374 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9375
9376 ulTempData &= (~ulMask);
9377
9378 if ( f_pVqeConfig->fEnableNlp == FALSE )
9379 ulTempData |= 0x1 << ulFeatureBitOffset;
9380
9381 /* Save the new DWORD where the field is located.*/
9382 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9383 pChanEntry,
9384 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9385 ulTempData);
9386 if ( ulResult != cOCT6100_ERR_OK )
9387 return ulResult;
9388 }
9389 }
9390
9391 /* Set the tail configuration. */
9392 ulResult = Oct6100ApiSetChannelTailConfiguration(
9393 f_pApiInstance,
9394 f_pVqeConfig,
9395 f_usChanIndex,
9396 f_usEchoMemIndex,
9397 f_fModifyOnly );
9398 if ( ulResult != cOCT6100_ERR_OK )
9399 return ulResult;
9400
9401 /* Set the Default ERL. */
9402 if ( ( pSharedInfo->ImageInfo.fDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == FALSE ) )
9403 {
9404 /* Check if the configuration has been changed. */
9405 if ( ( f_fModifyOnly == FALSE )
9406 || ( ( f_fModifyOnly == TRUE )
9407 && ( ( f_pVqeConfig->lDefaultErlDb != pChanEntry->VqeConfig.chDefaultErlDb )
9408 || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode )
9409 || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
9410 {
9411 ulFeatureBytesOffset = pSharedInfo->MemoryMap.DefaultErlFieldOfst.usDwordOffset * 4;
9412 ulFeatureBitOffset = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byBitOffset;
9413 ulFeatureFieldLength = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byFieldSize;
9414
9415 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9416 pChanEntry,
9417 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9418 &ulTempData);
9419 if ( ulResult != cOCT6100_ERR_OK )
9420 return ulResult;
9421
9422 /* Clear previous value set in the feature field.*/
9423 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9424
9425 ulTempData &= (~ulMask);
9426
9427 /* Convert the DB value to octasic's float format. (In energy) */
9428 if ( ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
9429 && ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9430 {
9431 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb );
9432 }
9433 else
9434 {
9435 /* Clear the defautl ERL when using the no echo cancellation operation mode. */
9436 usTempData = 0x0;
9437 }
9438
9439 if ( ulFeatureFieldLength < 16 )
9440 usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
9441
9442 ulTempData |= ( usTempData << ulFeatureBitOffset );
9443
9444 /* Save the new DWORD where the field is located.*/
9445 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9446 pChanEntry,
9447 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9448 ulTempData);
9449 if ( ulResult != cOCT6100_ERR_OK )
9450 return ulResult;
9451 }
9452 }
9453
9454 /* Set the Acoustic echo control.*/
9455 if ( pSharedInfo->ImageInfo.fAcousticEcho == TRUE )
9456 {
9457 /* Check if the configuration has been changed. */
9458 if ( ( f_fModifyOnly == FALSE )
9459 || ( ( f_fModifyOnly == TRUE )
9460 && ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) )
9461 {
9462 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecFieldOfst.usDwordOffset * 4;
9463 ulFeatureBitOffset = pSharedInfo->MemoryMap.AecFieldOfst.byBitOffset;
9464 ulFeatureFieldLength = pSharedInfo->MemoryMap.AecFieldOfst.byFieldSize;
9465
9466 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9467 pChanEntry,
9468 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9469 &ulTempData);
9470 if ( ulResult != cOCT6100_ERR_OK )
9471 return ulResult;
9472
9473 /* Clear previous value set in the feature field. */
9474 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9475
9476 ulTempData &= (~ulMask);
9477 ulTempData |= ( ( (UINT32)f_pVqeConfig->fAcousticEcho ) << ulFeatureBitOffset );
9478
9479 /* Then save the new DWORD where the field is located. */
9480 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9481 pChanEntry,
9482 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9483 ulTempData);
9484 if ( ulResult != cOCT6100_ERR_OK )
9485 return ulResult;
9486 }
9487 }
9488
9489 /* Set the Acoustic Echo Default ERL. */
9490 if ( ( pSharedInfo->ImageInfo.fAecDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == TRUE ) )
9491 {
9492 /* Check if the configuration has been changed. */
9493 if ( ( f_fModifyOnly == FALSE )
9494 || ( ( f_fModifyOnly == TRUE )
9495 && ( ( f_pVqeConfig->lAecDefaultErlDb != pChanEntry->VqeConfig.chAecDefaultErlDb )
9496 || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
9497 {
9498 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.usDwordOffset * 4;
9499 ulFeatureBitOffset = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byBitOffset;
9500 ulFeatureFieldLength = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byFieldSize;
9501
9502 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9503 pChanEntry,
9504 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9505 &ulTempData);
9506 if ( ulResult != cOCT6100_ERR_OK )
9507 return ulResult;
9508
9509 /* Clear previous value set in the feature field. */
9510 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9511
9512 ulTempData &= (~ulMask);
9513
9514 if ( ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
9515 && ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9516 {
9517 /* Convert the DB value to octasic's float format. (In energy) */
9518 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lAecDefaultErlDb );
9519 }
9520 else
9521 {
9522 /* Clear the AEC defautl ERL when using the no echo cancellation operation mode. */
9523 usTempData = 0x0;
9524 }
9525
9526 if ( ulFeatureFieldLength < 16 )
9527 usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
9528
9529 ulTempData |= ( usTempData << ulFeatureBitOffset );
9530
9531 /* Then save the DWORD where the field is located. */
9532 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9533 pChanEntry,
9534 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9535 ulTempData);
9536 if ( ulResult != cOCT6100_ERR_OK )
9537 return ulResult;
9538 }
9539 }
9540
9541 /* Set the DTMF tone removal bit.*/
9542 if ( pSharedInfo->ImageInfo.fToneRemoval == TRUE )
9543 {
9544 /* Check if the configuration has been changed. */
9545 if ( ( f_fModifyOnly == FALSE )
9546 || ( ( f_fModifyOnly == TRUE )
9547 && ( f_pVqeConfig->fDtmfToneRemoval != pChanEntry->VqeConfig.fDtmfToneRemoval ) ) )
9548 {
9549 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.usDwordOffset * 4;
9550 ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byBitOffset;
9551 ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byFieldSize;
9552
9553 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9554 pChanEntry,
9555 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9556 &ulTempData);
9557 if ( ulResult != cOCT6100_ERR_OK )
9558 return ulResult;
9559
9560 /* Clear previous value set in the feature field.*/
9561 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9562
9563 ulTempData &= (~ulMask);
9564 ulTempData |= ( ( (UINT32)f_pVqeConfig->fDtmfToneRemoval ) << ulFeatureBitOffset );
9565
9566 /* First read the DWORD where the field is located.*/
9567 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9568 pChanEntry,
9569 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9570 ulTempData);
9571 if ( ulResult != cOCT6100_ERR_OK )
9572 return ulResult;
9573 }
9574 }
9575
9576
9577
9578 /* Set the non-linear behavior A.*/
9579 if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorA == TRUE )
9580 {
9581 /* Check if the configuration has been changed. */
9582 if ( ( f_fModifyOnly == FALSE )
9583 || ( ( f_fModifyOnly == TRUE )
9584 && ( ( f_pVqeConfig->ulNonLinearityBehaviorA != pChanEntry->VqeConfig.byNonLinearityBehaviorA )
9585 || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
9586 {
9587 UINT16 ausLookupTable[ 14 ] = { 0x3663, 0x3906, 0x399C, 0x3A47, 0x3B06, 0x3B99, 0x3C47, 0x3D02, 0x3D99, 0x3E47, 0x3F00, 0x3F99, 0x4042, 0x4100 };
9588
9589 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PcmLeakFieldOfst.usDwordOffset * 4;
9590 ulFeatureBitOffset = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byBitOffset;
9591 ulFeatureFieldLength = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byFieldSize;
9592
9593 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9594 pChanEntry,
9595 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9596 &ulTempData);
9597 if ( ulResult != cOCT6100_ERR_OK )
9598 return ulResult;
9599
9600 /* Clear previous value set in the feature field.*/
9601 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9602
9603 ulTempData &= (~ulMask);
9604
9605 /*If we support ANR level the TLV is shared over 2 bits*/
9606 if (ulFeatureBitOffset == 18)
9607 {
9608 ulFeatureBitOffset -= 2;
9609 ausLookupTable[ f_pVqeConfig->ulNonLinearityBehaviorA ] &= 0xFFFC;
9610 }
9611
9612 if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
9613 || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9614 ulTempData |= ( 0x0 << ulFeatureBitOffset );
9615 else
9616 ulTempData |= ( ausLookupTable[ f_pVqeConfig->ulNonLinearityBehaviorA ] << ulFeatureBitOffset );
9617
9618 /* Then save the DWORD where the field is located.*/
9619 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9620 pChanEntry,
9621 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9622 ulTempData);
9623 if ( ulResult != cOCT6100_ERR_OK )
9624 return ulResult;
9625 }
9626 }
9627
9628 /* Synch all the buffer playout field.*/
9629 if ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE && f_fClearPlayoutPointers == TRUE )
9630 {
9631 Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
9632
9633 BufferPlayoutStop.ulChannelHndl = cOCT6100_INVALID_HANDLE;
9634 BufferPlayoutStop.fStopCleanly = TRUE;
9635
9636 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
9637 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
9638 f_pApiInstance,
9639 &BufferPlayoutStop,
9640 f_usChanIndex,
9641 f_usEchoMemIndex
9642
9643 );
9644 if ( ulResult != cOCT6100_ERR_OK )
9645 return ulResult;
9646
9647 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
9648 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
9649 f_pApiInstance,
9650 &BufferPlayoutStop,
9651 f_usChanIndex,
9652 f_usEchoMemIndex
9653
9654 );
9655 if ( ulResult != cOCT6100_ERR_OK )
9656 return ulResult;
9657 }
9658
9659 /*==============================================================================*/
9660 /* Write the 2100 Hz Echo Disabling mode */
9661
9662 /* Check if the configuration has been changed. */
9663 if ( ( f_fModifyOnly == FALSE )
9664 || ( ( f_fModifyOnly == TRUE )
9665 && ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) ) )
9666 {
9667 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerControlOfst.usDwordOffset * 4;
9668 ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byBitOffset;
9669 ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byFieldSize;
9670
9671 /* First read the DWORD where the field is located.*/
9672 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9673 pChanEntry,
9674 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9675 &ulTempData);
9676 if ( ulResult != cOCT6100_ERR_OK )
9677 return ulResult;
9678
9679 /* Clear previous value set in the feature field.*/
9680 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9681
9682 ulTempData &= (~ulMask);
9683
9684 /* This is a disable bit, so it must be set only if the enable flag is set to false. */
9685 if ( f_pChannelOpen->fEnableToneDisabler == FALSE )
9686 ulTempData |= 0x1 << ulFeatureBitOffset;
9687
9688 /* Save the DWORD where the field is located. */
9689 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9690 pChanEntry,
9691 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9692 ulTempData);
9693 if ( ulResult != cOCT6100_ERR_OK )
9694 return ulResult;
9695 }
9696 /*==============================================================================*/
9697
9698
9699 /*==============================================================================*/
9700 /* Write the Nlp Trivial enable flag. */
9701
9702 /* Check if the configuration has been changed. */
9703 if ( ( f_fModifyOnly == FALSE )
9704 || ( ( f_fModifyOnly == TRUE )
9705 && (
9706
9707 ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
9708 {
9709 ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.usDwordOffset * 4;
9710 ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byBitOffset;
9711 ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byFieldSize;
9712
9713 /* First read the DWORD where the field is located.*/
9714 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9715 pChanEntry,
9716 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9717 &ulTempData);
9718 if ( ulResult != cOCT6100_ERR_OK )
9719 return ulResult;
9720
9721 /* Clear previous value set in the feature field.*/
9722 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9723
9724 ulTempData &= (~ulMask);
9725 if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
9726 || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9727 {
9728 ulTempData |= TRUE << ulFeatureBitOffset;
9729 }
9730
9731
9732 /* Then write the DWORD where the field is located. */
9733 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9734 pChanEntry,
9735 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9736 ulTempData);
9737 if ( ulResult != cOCT6100_ERR_OK )
9738 return ulResult;
9739 }
9740 /*==============================================================================*/
9741
9742
9743 /*==============================================================================*/
9744 /* Set the double talk behavior mode. */
9745 if ( pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst == TRUE )
9746 {
9747 /* Check if the configuration has been changed. */
9748 if ( ( f_fModifyOnly == FALSE )
9749 || ( ( f_fModifyOnly == TRUE )
9750 && ( f_pVqeConfig->ulDoubleTalkBehavior != pChanEntry->VqeConfig.byDoubleTalkBehavior ) ) )
9751 {
9752 /* The field is located in the CPURO structure. */
9753 ulFeatureBytesOffset = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.usDwordOffset * 4;
9754 ulFeatureBitOffset = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.byBitOffset;
9755 ulFeatureFieldLength = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.byFieldSize;
9756
9757 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9758 pChanEntry,
9759 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9760 &ulTempData);
9761 if ( ulResult != cOCT6100_ERR_OK )
9762 return ulResult;
9763
9764 /* Clear previous value set in the feature field.*/
9765 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9766
9767 ulTempData &= (~ulMask);
9768 ulTempData |= (f_pVqeConfig->ulDoubleTalkBehavior << ulFeatureBitOffset );
9769
9770 /* Then save the DWORD where the field is located.*/
9771 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9772 pChanEntry,
9773 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9774 ulTempData);
9775 if ( ulResult != cOCT6100_ERR_OK )
9776 return ulResult;
9777 }
9778 }
9779 /*==============================================================================*/
9780
9781
9782 /*==============================================================================*/
9783 /* Set the music protection enable. */
9784 if ( ( pSharedInfo->ImageInfo.fMusicProtection == TRUE )
9785 && ( pSharedInfo->ImageInfo.fMusicProtectionConfiguration == TRUE ) )
9786 {
9787 /* Check if the configuration has been changed. */
9788 if ( ( f_fModifyOnly == FALSE )
9789 || ( ( f_fModifyOnly == TRUE )
9790 && ( f_pVqeConfig->fEnableMusicProtection != pChanEntry->VqeConfig.fEnableMusicProtection ) ) )
9791 {
9792 ulFeatureBytesOffset = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.usDwordOffset * 4;
9793 ulFeatureBitOffset = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byBitOffset;
9794 ulFeatureFieldLength = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byFieldSize;
9795
9796 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9797 pChanEntry,
9798 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9799 &ulTempData);
9800 if ( ulResult != cOCT6100_ERR_OK )
9801 return ulResult;
9802
9803 /* Clear previous value set in the feature field.*/
9804 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9805
9806 ulTempData &= (~ulMask);
9807 if ( f_pVqeConfig->fEnableMusicProtection == TRUE )
9808 ulTempData |= ( 1 << ulFeatureBitOffset );
9809
9810 /* Then save the DWORD where the field is located.*/
9811 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9812 pChanEntry,
9813 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9814 ulTempData);
9815 if ( ulResult != cOCT6100_ERR_OK )
9816 return ulResult;
9817 }
9818 }
9819 /*==============================================================================*/
9820
9821 return cOCT6100_ERR_OK;
9822 }
9823 #endif
9824
9825 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9826
9827 Function: Oct6100ApiWriteVqeAfMemory
9828
9829 Description: This function configures the AF related VQE features of an
9830 echo channel.
9831
9832 -------------------------------------------------------------------------------
9833 | Argument | Description
9834 -------------------------------------------------------------------------------
9835 f_pApiInstance Pointer to API instance. This memory is used to keep
9836 the present state of the chip and all its resources.
9837
9838 f_pVqeConfig Pointer to a VQE config structure.
9839 f_pChannelOpen Pointer to a channel configuration structure.
9840 f_usChanIndex Index of the echo channel in the API instance.
9841 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
9842 f_fClearPlayoutPointers Flag indicating if the playout pointer should be cleared.
9843 f_fModifyOnly Flag indicating if the configuration should be
9844 modified only.
9845
9846 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9847 #if !SKIP_Oct6100ApiWriteVqeAfMemory
9848 UINT32 Oct6100ApiWriteVqeAfMemory(
9849 IN tPOCT6100_INSTANCE_API f_pApiInstance,
9850 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
9851 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
9852 IN UINT16 f_usChanIndex,
9853 IN UINT16 f_usEchoMemIndex,
9854 IN BOOL f_fClearPlayoutPointers,
9855 IN BOOL f_fModifyOnly )
9856 {
9857 tPOCT6100_API_CHANNEL pChanEntry;
9858 tPOCT6100_SHARED_INFO pSharedInfo;
9859 tOCT6100_WRITE_PARAMS WriteParams;
9860 UINT32 ulResult;
9861 UINT32 ulTempData;
9862 UINT32 ulAfConfigBaseAddress;
9863 UINT32 ulFeatureBytesOffset;
9864 UINT32 ulFeatureBitOffset;
9865 UINT32 ulFeatureFieldLength;
9866 UINT32 ulMask;
9867 UINT16 usTempData;
9868
9869 pSharedInfo = f_pApiInstance->pSharedInfo;
9870
9871 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
9872
9873 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
9874
9875 /* Obtain a pointer to the new buffer's list entry. */
9876 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
9877
9878 /*==============================================================================*/
9879 /* Write the AF CPU configuration of the channel feature by feature.*/
9880
9881 /* Calculate AF CPU configuration base address. */
9882 ulAfConfigBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
9883
9884 /* Set initial value to zero.*/
9885 ulTempData = 0;
9886
9887 /*==============================================================================*/
9888 /* Program the Maximum echo point within the Main channel memory.*/
9889 if ( pSharedInfo->ImageInfo.fMaxEchoPoint == TRUE )
9890 {
9891 /* Check if the configuration has been changed. */
9892 if ( ( f_fModifyOnly == FALSE )
9893 || ( ( f_fModifyOnly == TRUE )
9894 && ( ( f_pVqeConfig->lDefaultErlDb != pChanEntry->VqeConfig.chDefaultErlDb )
9895 || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
9896 {
9897 /* Write the echo tail length */
9898 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.usDwordOffset * 4;
9899 ulFeatureBitOffset = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.byBitOffset;
9900 ulFeatureFieldLength = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.byFieldSize;
9901
9902 /* First read the DWORD where the field is located.*/
9903 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9904 pChanEntry,
9905 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9906 &ulTempData);
9907 if ( ulResult != cOCT6100_ERR_OK )
9908 return ulResult;
9909
9910 /* Clear previous value set in the feature field.*/
9911 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9912
9913 ulTempData &= (~ulMask);
9914
9915 /* Convert the DB value to octasic's float format.*/
9916 if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
9917 {
9918 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb );
9919 }
9920 else
9921 {
9922 /* Clear max echo point. No echo cancellation here. */
9923 usTempData = 0x0;
9924 }
9925
9926 if ( ulFeatureFieldLength < 16 )
9927 usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
9928
9929 ulTempData |= usTempData << ulFeatureBitOffset;
9930
9931 /* First read the DWORD where the field is located.*/
9932 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9933 pChanEntry,
9934 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9935 ulTempData);
9936 if ( ulResult != cOCT6100_ERR_OK )
9937 return ulResult;
9938 }
9939 }
9940 /*==============================================================================*/
9941
9942
9943 /*==============================================================================*/
9944 /* Set the non-linear behavior B.*/
9945 if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorB == TRUE )
9946 {
9947 /* Check if the configuration has been changed. */
9948 if ( ( f_fModifyOnly == FALSE )
9949 || ( ( f_fModifyOnly == TRUE )
9950 && ( f_pVqeConfig->ulNonLinearityBehaviorB != pChanEntry->VqeConfig.byNonLinearityBehaviorB ) ) )
9951 {
9952 ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.usDwordOffset * 4;
9953 ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byBitOffset;
9954 ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byFieldSize;
9955
9956 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9957 pChanEntry,
9958 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9959 &ulTempData);
9960 if ( ulResult != cOCT6100_ERR_OK )
9961 return ulResult;
9962
9963 /* Clear previous value set in the feature field.*/
9964 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9965
9966 ulTempData &= (~ulMask);
9967 ulTempData |= (f_pVqeConfig->ulNonLinearityBehaviorB << ulFeatureBitOffset );
9968
9969 /* Then save the DWORD where the field is located.*/
9970 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9971 pChanEntry,
9972 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9973 ulTempData);
9974 if ( ulResult != cOCT6100_ERR_OK )
9975 return ulResult;
9976 }
9977 }
9978 /*==============================================================================*/
9979
9980
9981 /*==============================================================================*/
9982 /* Set the listener enhancement feature. */
9983 if ( pSharedInfo->ImageInfo.fListenerEnhancement == TRUE )
9984 {
9985 /* Check if the configuration has been changed. */
9986 if ( ( f_fModifyOnly == FALSE )
9987 || ( ( f_fModifyOnly == TRUE )
9988 && ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb )
9989 || ( f_pVqeConfig->fSoutNaturalListenerEnhancement != pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement )
9990 || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb ) ) ) )
9991 {
9992 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveAleOfst.usDwordOffset * 4;
9993 ulFeatureBitOffset = pSharedInfo->MemoryMap.AdaptiveAleOfst.byBitOffset;
9994 ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveAleOfst.byFieldSize;
9995
9996 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9997 pChanEntry,
9998 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9999 &ulTempData);
10000 if ( ulResult != cOCT6100_ERR_OK )
10001 return ulResult;
10002
10003 /* Clear previous value set in the feature field.*/
10004 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
10005
10006 ulTempData &= (~ulMask);
10007
10008 if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 )
10009 {
10010 UINT32 ulGainDb;
10011
10012 ulGainDb = f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb / 3;
10013
10014 /* Round up. */
10015 if ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb % 3 ) != 0x0 )
10016 ulGainDb ++;
10017
10018 ulTempData |= ( ulGainDb << ulFeatureBitOffset );
10019 }
10020 else if ( f_pVqeConfig->fSoutNaturalListenerEnhancement != 0 )
10021 {
10022 UINT32 ulGainDb;
10023
10024 ulGainDb = f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb / 3;
10025
10026 /* Round up. */
10027 if ( ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb % 3 ) != 0x0 )
10028 ulGainDb ++;
10029
10030 ulTempData |= ( ( 0x80 | ulGainDb ) << ulFeatureBitOffset );
10031 }
10032
10033 /* Now write the DWORD where the field is located containing the new configuration. */
10034 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
10035 pChanEntry,
10036 ulAfConfigBaseAddress + ulFeatureBytesOffset,
10037 ulTempData);
10038 if ( ulResult != cOCT6100_ERR_OK )
10039 return ulResult;
10040 }
10041 }
10042 /*==============================================================================*/
10043
10044
10045 /*==============================================================================*/
10046 /* Set the idle code detection enable. */
10047 if ( ( pSharedInfo->ImageInfo.fIdleCodeDetection == TRUE )
10048 && ( pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration == TRUE ) )
10049 {
10050 /* Check if the configuration has been changed. */
10051 if ( ( f_fModifyOnly == FALSE )
10052 || ( ( f_fModifyOnly == TRUE )
10053 && ( f_pVqeConfig->fIdleCodeDetection != pChanEntry->VqeConfig.fIdleCodeDetection ) ) )
10054 {
10055 /* Calculate base address in the AF software configuration. */
10056 ulFeatureBytesOffset = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.usDwordOffset * 4;
10057 ulFeatureBitOffset = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.byBitOffset;
10058 ulFeatureFieldLength = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.byFieldSize;
10059
10060 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
10061 pChanEntry,
10062 ulAfConfigBaseAddress + ulFeatureBytesOffset,
10063 &ulTempData);
10064 if ( ulResult != cOCT6100_ERR_OK )
10065 return ulResult;
10066
10067 /* Clear previous value set in the feature field.*/
10068 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
10069
10070 ulTempData &= (~ulMask);
10071 if ( f_pVqeConfig->fIdleCodeDetection == FALSE )
10072 ulTempData |= ( 1 << ulFeatureBitOffset );
10073
10074 /* Then save the DWORD where the field is located.*/
10075 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
10076 pChanEntry,
10077 ulAfConfigBaseAddress + ulFeatureBytesOffset,
10078 ulTempData);
10079 if ( ulResult != cOCT6100_ERR_OK )
10080 return ulResult;
10081 }
10082 }
10083 /*==============================================================================*/
10084
10085
10086 /*==============================================================================*/
10087 /* Set the AFT control field. */
10088 if ( pSharedInfo->ImageInfo.fAftControl == TRUE )
10089 {
10090 /* Check if the configuration has been changed. */
10091 if ( ( f_fModifyOnly == FALSE )
10092 || ( ( f_fModifyOnly == TRUE )
10093 && ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) )
10094 {
10095 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AftControlOfst.usDwordOffset * 4;
10096 ulFeatureBitOffset = pSharedInfo->MemoryMap.AftControlOfst.byBitOffset;
10097 ulFeatureFieldLength = pSharedInfo->MemoryMap.AftControlOfst.byFieldSize;
10098
10099 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
10100 pChanEntry,
10101 ulAfConfigBaseAddress + ulFeatureBytesOffset,
10102 &ulTempData);
10103 if ( ulResult != cOCT6100_ERR_OK )
10104 return ulResult;
10105
10106 /* Clear previous value set in the feature field.*/
10107 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
10108
10109 ulTempData &= (~ulMask);
10110
10111 /* If the operation mode is no echo, set the field such that echo cancellation is disabled. */
10112 if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
10113 {
10114 ulTempData |= ( 0x1234 << ulFeatureBitOffset );
10115 }
10116 else if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
10117 {
10118 /* For clarity. */
10119 ulTempData |= ( 0x0 << ulFeatureBitOffset );
10120 }
10121
10122 /* Then save the DWORD where the field is located.*/
10123 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
10124 pChanEntry,
10125 ulAfConfigBaseAddress + ulFeatureBytesOffset,
10126 ulTempData);
10127 if ( ulResult != cOCT6100_ERR_OK )
10128 return ulResult;
10129 }
10130 }
10131 /*==============================================================================*/
10132
10133 return cOCT6100_ERR_OK;
10134 }
10135 #endif
10136
10137
10138
10139
10140 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10141
10142 Function: Oct6100ApiWriteEchoMemory
10143
10144 Description: This function configure an echo memory entry in internal memory.and
10145 external memory.
10146
10147 -------------------------------------------------------------------------------
10148 | Argument | Description
10149 -------------------------------------------------------------------------------
10150 f_pApiInstance Pointer to API instance. This memory is used to keep
10151 the present state of the chip and all its resources.
10152
10153 f_pTdmConfig Pointer to a TDM config structure.
10154 f_pChannelOpen Pointer to a channel configuration structure.
10155 f_usEchoIndex Echo channel index within the SSPX memory.
10156 f_usRinRoutTsiIndex RIN/ROUT TSI index within the TSI chariot memory
10157 f_usSinSoutTsiIndex SIN/SOUT TSI index within the TSI chariot memory
10158
10159 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10160 #if !SKIP_Oct6100ApiWriteEchoMemory
10161 UINT32 Oct6100ApiWriteEchoMemory(
10162 IN tPOCT6100_INSTANCE_API f_pApiInstance,
10163 IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig,
10164 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
10165 IN UINT16 f_usEchoIndex,
10166 IN UINT16 f_usRinRoutTsiIndex,
10167 IN UINT16 f_usSinSoutTsiIndex )
10168
10169 {
10170 tPOCT6100_SHARED_INFO pSharedInfo;
10171 tOCT6100_WRITE_PARAMS WriteParams;
10172 UINT32 ulResult;
10173 UINT32 ulTempData;
10174 UINT32 ulBaseAddress;
10175 UINT32 ulRinPcmLaw;
10176 UINT32 ulRoutPcmLaw;
10177 UINT32 ulSinPcmLaw;
10178 UINT32 ulSoutPcmLaw;
10179
10180 pSharedInfo = f_pApiInstance->pSharedInfo;
10181
10182 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
10183
10184 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
10185
10186 /* Set immediately the PCM law to be programmed in the SSPX and NLP memory.*/
10187 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
10188 {
10189 ulRinPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;
10190 ulRoutPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;
10191 ulSinPcmLaw = f_pChannelOpen->TdmConfig.ulSinPcmLaw;
10192 ulSoutPcmLaw = f_pChannelOpen->TdmConfig.ulSinPcmLaw;
10193 }
10194 else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
10195 {
10196 ulRinPcmLaw = f_pChannelOpen->TdmConfig.ulRinPcmLaw;
10197 ulRoutPcmLaw = f_pChannelOpen->TdmConfig.ulRinPcmLaw;
10198 ulSinPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;
10199 ulSoutPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;
10200 }
10201
10202 /*==============================================================================*/
10203 /* Configure the Global Static Configuration of the channel.*/
10204
10205 ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET;
10206
10207 /* Set the PGSP context base address. */
10208 ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET;
10209
10210 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET;
10211 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10212
10213 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10214 if ( ulResult != cOCT6100_ERR_OK )
10215 return ulResult;
10216
10217 WriteParams.ulWriteAddress += 2;
10218 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10219
10220 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10221 if ( ulResult != cOCT6100_ERR_OK )
10222 return ulResult;
10223
10224 /* Set the PGSP init context base address. */
10225 ulTempData = ( cOCT6100_IMAGE_FILE_BASE + 0x200 ) & 0x07FFFFFF;
10226
10227 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET;
10228 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10229
10230 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10231 if ( ulResult != cOCT6100_ERR_OK )
10232 return ulResult;
10233
10234 WriteParams.ulWriteAddress += 2;
10235 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10236
10237 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10238 if ( ulResult != cOCT6100_ERR_OK )
10239 return ulResult;
10240
10241 /* Set the RIN circular buffer base address. */
10242 ulTempData = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst) & 0x07FFFF00;
10243 ulTempData |= ( ulRoutPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
10244
10245 /* Set the circular buffer size.*/
10246 if (( pSharedInfo->MemoryMap.ulChanMainRinCBMemSize & 0xFFFF00FF ) != 0 )
10247 return cOCT6100_ERR_CHANNEL_INVALID_RIN_CB_SIZE;
10248 ulTempData |= pSharedInfo->MemoryMap.ulChanMainRinCBMemSize >> 8;
10249
10250 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET;
10251 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10252
10253 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10254 if ( ulResult != cOCT6100_ERR_OK )
10255 return ulResult;
10256
10257 WriteParams.ulWriteAddress += 2;
10258 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10259
10260 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10261 if ( ulResult != cOCT6100_ERR_OK )
10262 return ulResult;
10263
10264 /* Set the SIN circular buffer base address. */
10265 ulTempData = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst) & 0x07FFFF00;
10266 ulTempData |= ( ulSinPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
10267
10268 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET;
10269 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10270
10271 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10272 if ( ulResult != cOCT6100_ERR_OK )
10273 return ulResult;
10274
10275 WriteParams.ulWriteAddress += 2;
10276 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10277
10278 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10279 if ( ulResult != cOCT6100_ERR_OK )
10280 return ulResult;
10281
10282 /* Set the SOUT circular buffer base address. */
10283 ulTempData = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst ) & 0x07FFFF00;
10284 ulTempData |= ( ulSoutPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
10285
10286 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET;
10287 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10288
10289 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10290 if ( ulResult != cOCT6100_ERR_OK )
10291 return ulResult;
10292
10293 WriteParams.ulWriteAddress += 2;
10294 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10295
10296 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10297 if ( ulResult != cOCT6100_ERR_OK )
10298 return ulResult;
10299
10300 /*==============================================================================*/
10301
10302
10303 /*==============================================================================*/
10304 /* ECHO SSPX Memory configuration.*/
10305
10306 WriteParams.ulWriteAddress = cOCT6100_ECHO_CONTROL_MEM_BASE + ( f_usEchoIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
10307
10308 /* ECHO memory BASE + 2 */
10309 WriteParams.ulWriteAddress += 2;
10310 WriteParams.usWriteData = 0x0000;
10311
10312 /* Set the echo control field.*/
10313 if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
10314 || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
10315 {
10316 WriteParams.usWriteData |= cOCT6100_ECHO_OP_MODE_NORMAL << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL;
10317 }
10318 else if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL )
10319 {
10320 WriteParams.usWriteData |= f_pChannelOpen->ulEchoOperationMode << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL;
10321 }
10322
10323 /* Set the SIN/SOUT law.*/
10324 WriteParams.usWriteData |= ulSinPcmLaw << cOCT6100_ECHO_CONTROL_MEM_INPUT_LAW_OFFSET;
10325 WriteParams.usWriteData |= ulSoutPcmLaw << cOCT6100_ECHO_CONTROL_MEM_OUTPUT_LAW_OFFSET;
10326
10327 /* Set the TSI chariot memory field.*/
10328 WriteParams.usWriteData |= f_usSinSoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK;
10329
10330 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10331 if ( ulResult != cOCT6100_ERR_OK )
10332 return ulResult;
10333
10334 /* ECHO memory BASE */
10335 WriteParams.ulWriteAddress -= 2;
10336 WriteParams.usWriteData = cOCT6100_ECHO_CONTROL_MEM_ACTIVATE_ENTRY;
10337
10338 /* Set the RIN/ROUT law.*/
10339 WriteParams.usWriteData |= ulRinPcmLaw << cOCT6100_ECHO_CONTROL_MEM_INPUT_LAW_OFFSET;
10340 WriteParams.usWriteData |= ulRoutPcmLaw << cOCT6100_ECHO_CONTROL_MEM_OUTPUT_LAW_OFFSET;
10341
10342 /* Set the RIN external echo control bit.*/
10343 if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_EXTERNAL )
10344 WriteParams.usWriteData |= cOCT6100_ECHO_CONTROL_MEM_EXTERNAL_AF_CTRL;
10345
10346 /* Set the TSI chariot memory field.*/
10347 WriteParams.usWriteData |= f_usRinRoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK;
10348
10349 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10350 if ( ulResult != cOCT6100_ERR_OK )
10351 return ulResult;
10352
10353 /*==============================================================================*/
10354
10355 return cOCT6100_ERR_OK;
10356 }
10357 #endif
10358
10359
10360 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10361
10362 Function: Oct6100ApiUpdateOpenStruct
10363
10364 Description: This function will copy the new parameter from the modify structure
10365 into a channel open structure to be processed later by the same path
10366 as the channel open function.
10367 If a parameter is set to keep previous, it's current value will be
10368 extracted from the channel entry in the API.
10369
10370 -------------------------------------------------------------------------------
10371 | Argument | Description
10372 -------------------------------------------------------------------------------
10373
10374 IN f_pApiInstance Pointer to an API instance structure.
10375 IN f_pChanModify Pointer to a channel modify structure.
10376 IN OUT f_pChanOpen Pointer to a channel open structure.
10377 IN f_pChanEntry Pointer to an API channel structure.
10378
10379 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10380 #if !SKIP_Oct6100ApiUpdateOpenStruct
10381 UINT32 Oct6100ApiUpdateOpenStruct(
10382 IN tPOCT6100_INSTANCE_API f_pApiInstance,
10383 IN tPOCT6100_CHANNEL_MODIFY f_pChanModify,
10384 IN OUT tPOCT6100_CHANNEL_OPEN f_pChanOpen,
10385 IN tPOCT6100_API_CHANNEL f_pChanEntry )
10386 {
10387
10388 /* Check the generic Echo parameters.*/
10389 if ( f_pChanModify->ulEchoOperationMode == cOCT6100_KEEP_PREVIOUS_SETTING )
10390 f_pChanOpen->ulEchoOperationMode = f_pChanEntry->byEchoOperationMode;
10391 else
10392 f_pChanOpen->ulEchoOperationMode = f_pChanModify->ulEchoOperationMode;
10393
10394
10395 if ( f_pChanModify->fEnableToneDisabler == cOCT6100_KEEP_PREVIOUS_SETTING )
10396 f_pChanOpen->fEnableToneDisabler = f_pChanEntry->fEnableToneDisabler;
10397 else
10398 f_pChanOpen->fEnableToneDisabler = f_pChanModify->fEnableToneDisabler;
10399
10400
10401 if ( f_pChanModify->ulUserChanId == cOCT6100_KEEP_PREVIOUS_SETTING )
10402 f_pChanOpen->ulUserChanId = f_pChanEntry->ulUserChanId;
10403 else
10404 f_pChanOpen->ulUserChanId = f_pChanModify->ulUserChanId;
10405
10406
10407
10408 /*======================================================================*/
10409 /* Now update the TDM config.*/
10410 /* Rin PCM LAW */
10411 if ( f_pChanModify->TdmConfig.ulRinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10412 f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanEntry->TdmConfig.byRinPcmLaw;
10413 else
10414 f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanModify->TdmConfig.ulRinPcmLaw;
10415
10416 /* Sin PCM LAW */
10417 if ( f_pChanModify->TdmConfig.ulSinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10418 f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanEntry->TdmConfig.bySinPcmLaw;
10419 else
10420 f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanModify->TdmConfig.ulSinPcmLaw;
10421
10422 /* Rout PCM LAW */
10423 if ( f_pChanModify->TdmConfig.ulRoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10424 f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanEntry->TdmConfig.byRoutPcmLaw;
10425 else
10426 f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanModify->TdmConfig.ulRoutPcmLaw;
10427
10428 /* Sout PCM LAW */
10429 if ( f_pChanModify->TdmConfig.ulSoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10430 f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanEntry->TdmConfig.bySoutPcmLaw;
10431 else
10432 f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanModify->TdmConfig.ulSoutPcmLaw;
10433
10434
10435 /* Rin Timeslot */
10436 if ( f_pChanModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10437 f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanEntry->TdmConfig.usRinTimeslot;
10438 else
10439 f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanModify->TdmConfig.ulRinTimeslot;
10440
10441 /* Rin Stream */
10442 if ( f_pChanModify->TdmConfig.ulRinStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10443 f_pChanOpen->TdmConfig.ulRinStream = f_pChanEntry->TdmConfig.usRinStream;
10444 else
10445 f_pChanOpen->TdmConfig.ulRinStream = f_pChanModify->TdmConfig.ulRinStream;
10446
10447 /* Rin Num TSSTs */
10448 if ( f_pChanModify->TdmConfig.ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10449 f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanEntry->TdmConfig.byRinNumTssts;
10450 else
10451 f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanModify->TdmConfig.ulRinNumTssts;
10452
10453
10454 /* Sin Timeslot */
10455 if ( f_pChanModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10456 f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanEntry->TdmConfig.usSinTimeslot;
10457 else
10458 f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanModify->TdmConfig.ulSinTimeslot;
10459
10460 /* Sin Stream */
10461 if ( f_pChanModify->TdmConfig.ulSinStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10462 f_pChanOpen->TdmConfig.ulSinStream = f_pChanEntry->TdmConfig.usSinStream;
10463 else
10464 f_pChanOpen->TdmConfig.ulSinStream = f_pChanModify->TdmConfig.ulSinStream;
10465
10466 /* Sin Num TSSTs */
10467 if ( f_pChanModify->TdmConfig.ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10468 f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanEntry->TdmConfig.bySinNumTssts;
10469 else
10470 f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanModify->TdmConfig.ulSinNumTssts;
10471
10472
10473 /* Rout Timeslot */
10474 if ( f_pChanModify->TdmConfig.ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10475 f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanEntry->TdmConfig.usRoutTimeslot;
10476 else
10477 f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanModify->TdmConfig.ulRoutTimeslot;
10478
10479 /* Rout Stream */
10480 if ( f_pChanModify->TdmConfig.ulRoutStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10481 f_pChanOpen->TdmConfig.ulRoutStream = f_pChanEntry->TdmConfig.usRoutStream;
10482 else
10483 f_pChanOpen->TdmConfig.ulRoutStream = f_pChanModify->TdmConfig.ulRoutStream;
10484
10485 /* Rout Num TSSTs */
10486 if ( f_pChanModify->TdmConfig.ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10487 f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanEntry->TdmConfig.byRoutNumTssts;
10488 else
10489 f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanModify->TdmConfig.ulRoutNumTssts;
10490
10491
10492 /* Sout Timeslot */
10493 if ( f_pChanModify->TdmConfig.ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10494 f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanEntry->TdmConfig.usSoutTimeslot;
10495 else
10496 f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanModify->TdmConfig.ulSoutTimeslot;
10497
10498 /* Sout Stream */
10499 if ( f_pChanModify->TdmConfig.ulSoutStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10500 f_pChanOpen->TdmConfig.ulSoutStream = f_pChanEntry->TdmConfig.usSoutStream;
10501 else
10502 f_pChanOpen->TdmConfig.ulSoutStream = f_pChanModify->TdmConfig.ulSoutStream;
10503
10504 /* Sout Num TSSTs */
10505 if ( f_pChanModify->TdmConfig.ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10506 f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanEntry->TdmConfig.bySoutNumTssts;
10507 else
10508 f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanModify->TdmConfig.ulSoutNumTssts;
10509
10510 /*======================================================================*/
10511
10512 /*======================================================================*/
10513 /* Now update the VQE config.*/
10514
10515 if ( f_pChanModify->VqeConfig.ulComfortNoiseMode == cOCT6100_KEEP_PREVIOUS_SETTING )
10516 f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanEntry->VqeConfig.byComfortNoiseMode;
10517 else
10518 f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanModify->VqeConfig.ulComfortNoiseMode;
10519
10520 if ( f_pChanModify->VqeConfig.fEnableNlp == cOCT6100_KEEP_PREVIOUS_SETTING )
10521 f_pChanOpen->VqeConfig.fEnableNlp = f_pChanEntry->VqeConfig.fEnableNlp;
10522 else
10523 f_pChanOpen->VqeConfig.fEnableNlp = f_pChanModify->VqeConfig.fEnableNlp;
10524
10525 if ( f_pChanModify->VqeConfig.fEnableTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING )
10526 f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanEntry->VqeConfig.fEnableTailDisplacement;
10527 else
10528 f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanModify->VqeConfig.fEnableTailDisplacement;
10529
10530 if ( f_pChanModify->VqeConfig.ulTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING )
10531 f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanEntry->VqeConfig.usTailDisplacement;
10532 else
10533 f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanModify->VqeConfig.ulTailDisplacement;
10534
10535 /* Tail length cannot be modifed. */
10536 f_pChanOpen->VqeConfig.ulTailLength = f_pChanEntry->VqeConfig.usTailLength;
10537
10538
10539
10540 if ( f_pChanModify->VqeConfig.fRinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
10541 f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanEntry->VqeConfig.fRinDcOffsetRemoval;
10542 else
10543 f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanModify->VqeConfig.fRinDcOffsetRemoval;
10544
10545
10546 if ( f_pChanModify->VqeConfig.fRinLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10547 f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanEntry->VqeConfig.fRinLevelControl;
10548 else
10549 f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanModify->VqeConfig.fRinLevelControl;
10550
10551
10552 if ( f_pChanModify->VqeConfig.fRinAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10553 f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanEntry->VqeConfig.fRinAutomaticLevelControl;
10554 else
10555 f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanModify->VqeConfig.fRinAutomaticLevelControl;
10556
10557
10558 if ( f_pChanModify->VqeConfig.fRinHighLevelCompensation == cOCT6100_KEEP_PREVIOUS_SETTING )
10559 f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanEntry->VqeConfig.fRinHighLevelCompensation;
10560 else
10561 f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanModify->VqeConfig.fRinHighLevelCompensation;
10562
10563
10564 if ( f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10565 f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb;
10566 else
10567 f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb;
10568
10569
10570 if ( f_pChanModify->VqeConfig.fSinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
10571 f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanEntry->VqeConfig.fSinDcOffsetRemoval;
10572 else
10573 f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanModify->VqeConfig.fSinDcOffsetRemoval;
10574
10575
10576 if ( f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
10577 f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction;
10578 else
10579 f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction;
10580
10581
10582 if ( f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
10583 f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanEntry->VqeConfig.fSoutConferencingNoiseReduction;
10584 else
10585 f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction;
10586
10587
10588 if ( f_pChanModify->VqeConfig.fSoutNoiseBleaching == cOCT6100_KEEP_PREVIOUS_SETTING )
10589 f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanEntry->VqeConfig.fSoutNoiseBleaching;
10590 else
10591 f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanModify->VqeConfig.fSoutNoiseBleaching;
10592
10593
10594 if ( f_pChanModify->VqeConfig.fSoutLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10595 f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanEntry->VqeConfig.fSoutLevelControl;
10596 else
10597 f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanModify->VqeConfig.fSoutLevelControl;
10598
10599
10600 if ( f_pChanModify->VqeConfig.fSoutAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10601 f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanEntry->VqeConfig.fSoutAutomaticLevelControl;
10602 else
10603 f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanModify->VqeConfig.fSoutAutomaticLevelControl;
10604
10605
10606 if ( f_pChanModify->VqeConfig.lRinLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10607 f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanEntry->VqeConfig.chRinLevelControlGainDb;
10608 else
10609 f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanModify->VqeConfig.lRinLevelControlGainDb;
10610
10611
10612 if ( f_pChanModify->VqeConfig.lSoutLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10613 f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanEntry->VqeConfig.chSoutLevelControlGainDb;
10614 else
10615 f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanModify->VqeConfig.lSoutLevelControlGainDb;
10616
10617
10618 if ( f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10619 f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb;
10620 else
10621 f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb;
10622
10623
10624 if ( f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10625 f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb;
10626 else
10627 f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb;
10628
10629
10630 if ( f_pChanModify->VqeConfig.lDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10631 f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanEntry->VqeConfig.chDefaultErlDb;
10632 else
10633 f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanModify->VqeConfig.lDefaultErlDb;
10634
10635
10636 if ( f_pChanModify->VqeConfig.lAecDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10637 f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanEntry->VqeConfig.chAecDefaultErlDb;
10638 else
10639 f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanModify->VqeConfig.lAecDefaultErlDb;
10640
10641
10642 if ( f_pChanModify->VqeConfig.ulAecTailLength == cOCT6100_KEEP_PREVIOUS_SETTING )
10643 f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanEntry->VqeConfig.usAecTailLength;
10644 else
10645 f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanModify->VqeConfig.ulAecTailLength;
10646
10647
10648 if ( f_pChanModify->VqeConfig.fAcousticEcho == cOCT6100_KEEP_PREVIOUS_SETTING )
10649 f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanEntry->VqeConfig.fAcousticEcho;
10650 else
10651 f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanModify->VqeConfig.fAcousticEcho;
10652
10653
10654 if ( f_pChanModify->VqeConfig.fDtmfToneRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
10655 f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanEntry->VqeConfig.fDtmfToneRemoval;
10656 else
10657 f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanModify->VqeConfig.fDtmfToneRemoval;
10658
10659
10660
10661
10662
10663 if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorA == cOCT6100_KEEP_PREVIOUS_SETTING )
10664 f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanEntry->VqeConfig.byNonLinearityBehaviorA;
10665 else
10666 f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanModify->VqeConfig.ulNonLinearityBehaviorA;
10667
10668
10669 if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorB == cOCT6100_KEEP_PREVIOUS_SETTING )
10670 f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanEntry->VqeConfig.byNonLinearityBehaviorB;
10671 else
10672 f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanModify->VqeConfig.ulNonLinearityBehaviorB;
10673
10674
10675 if ( f_pChanModify->VqeConfig.ulDoubleTalkBehavior == cOCT6100_KEEP_PREVIOUS_SETTING )
10676 f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanEntry->VqeConfig.byDoubleTalkBehavior;
10677 else
10678 f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanModify->VqeConfig.ulDoubleTalkBehavior;
10679
10680
10681 if ( f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10682 f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb;
10683 else
10684 f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb;
10685
10686
10687 if ( f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10688 f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb;
10689 else
10690 f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb;
10691
10692
10693 if ( f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement == cOCT6100_KEEP_PREVIOUS_SETTING )
10694 f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement;
10695 else
10696 f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement;
10697
10698
10699 if ( f_pChanModify->VqeConfig.fRoutNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
10700 f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanEntry->VqeConfig.fRoutNoiseReduction;
10701 else
10702 f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanModify->VqeConfig.fRoutNoiseReduction;
10703
10704 if ( f_pChanModify->VqeConfig.lRoutNoiseReductionLevelGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10705 f_pChanOpen->VqeConfig.lRoutNoiseReductionLevelGainDb = f_pChanEntry->VqeConfig.chRoutNoiseReductionLevelGainDb;
10706 else
10707 f_pChanOpen->VqeConfig.lRoutNoiseReductionLevelGainDb = f_pChanModify->VqeConfig.lRoutNoiseReductionLevelGainDb;
10708
10709
10710 if ( f_pChanModify->VqeConfig.lAnrSnrEnhancementDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10711 f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanEntry->VqeConfig.chAnrSnrEnhancementDb;
10712 else
10713 f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanModify->VqeConfig.lAnrSnrEnhancementDb;
10714
10715
10716 if ( f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation == cOCT6100_KEEP_PREVIOUS_SETTING )
10717 f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation;
10718 else
10719 f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation;
10720
10721
10722 if ( f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay == cOCT6100_KEEP_PREVIOUS_SETTING )
10723 f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay;
10724 else
10725 f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay;
10726
10727
10728 if ( f_pChanModify->VqeConfig.fEnableMusicProtection == cOCT6100_KEEP_PREVIOUS_SETTING )
10729 f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanEntry->VqeConfig.fEnableMusicProtection;
10730 else
10731 f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanModify->VqeConfig.fEnableMusicProtection;
10732
10733
10734 if ( f_pChanModify->VqeConfig.fIdleCodeDetection == cOCT6100_KEEP_PREVIOUS_SETTING )
10735 f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanEntry->VqeConfig.fIdleCodeDetection;
10736 else
10737 f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanModify->VqeConfig.fIdleCodeDetection;
10738
10739 /*======================================================================*/
10740
10741
10742 /*======================================================================*/
10743 /* Finaly the codec config.*/
10744
10745 if ( f_pChanModify->CodecConfig.ulDecoderPort == cOCT6100_KEEP_PREVIOUS_SETTING )
10746 f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanEntry->CodecConfig.byDecoderPort;
10747 else
10748 f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanModify->CodecConfig.ulDecoderPort;
10749
10750
10751 if ( f_pChanModify->CodecConfig.ulDecodingRate == cOCT6100_KEEP_PREVIOUS_SETTING )
10752 f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanEntry->CodecConfig.byDecodingRate;
10753 else
10754 f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanModify->CodecConfig.ulDecodingRate;
10755
10756
10757 if ( f_pChanModify->CodecConfig.ulEncoderPort == cOCT6100_KEEP_PREVIOUS_SETTING )
10758 f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanEntry->CodecConfig.byEncoderPort;
10759 else
10760 f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanModify->CodecConfig.ulEncoderPort;
10761
10762
10763 if ( f_pChanModify->CodecConfig.ulEncodingRate == cOCT6100_KEEP_PREVIOUS_SETTING )
10764 f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanEntry->CodecConfig.byEncodingRate;
10765 else
10766 f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanModify->CodecConfig.ulEncodingRate;
10767
10768 if ( f_pChanModify->CodecConfig.fEnableSilenceSuppression == cOCT6100_KEEP_PREVIOUS_SETTING )
10769 f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanEntry->CodecConfig.fEnableSilenceSuppression;
10770 else
10771 f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanModify->CodecConfig.fEnableSilenceSuppression;
10772
10773 if ( f_pChanModify->CodecConfig.ulPhasingType == cOCT6100_KEEP_PREVIOUS_SETTING )
10774 f_pChanOpen->CodecConfig.ulPhasingType = f_pChanEntry->CodecConfig.byPhasingType;
10775 else
10776 f_pChanOpen->CodecConfig.ulPhasingType = f_pChanModify->CodecConfig.ulPhasingType;
10777
10778 if ( f_pChanModify->CodecConfig.ulPhase == cOCT6100_KEEP_PREVIOUS_SETTING )
10779 f_pChanOpen->CodecConfig.ulPhase = f_pChanEntry->CodecConfig.byPhase;
10780 else
10781 f_pChanOpen->CodecConfig.ulPhase = f_pChanModify->CodecConfig.ulPhase;
10782
10783 if ( f_pChanModify->CodecConfig.ulPhasingTsstHndl == cOCT6100_KEEP_PREVIOUS_SETTING )
10784 {
10785 if ( f_pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
10786 {
10787 tPOCT6100_API_PHASING_TSST pPhasingEntry;
10788
10789 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanEntry->usPhasingTsstIndex );
10790
10791 /* Now recreate the Phasing TSST handle.*/
10792 f_pChanOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_pChanEntry->usPhasingTsstIndex;
10793 }
10794 else
10795 {
10796 f_pChanOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
10797 }
10798 }
10799 else
10800 {
10801 f_pChanOpen->CodecConfig.ulPhasingTsstHndl = f_pChanModify->CodecConfig.ulPhasingTsstHndl;
10802 }
10803
10804 f_pChanOpen->CodecConfig.ulAdpcmNibblePosition = f_pChanEntry->CodecConfig.byAdpcmNibblePosition;
10805 /*======================================================================*/
10806
10807 return cOCT6100_ERR_OK;
10808 }
10809 #endif
10810
10811
10812
10813
10814
10815
10816
10817 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10818
10819 Function: Oct6100ApiRetrieveNlpConfDword
10820
10821 Description: This function is used by the API to store on a per channel basis
10822 the various confguration DWORD from the device. The API performs
10823 less read to the chip that way since it is always in synch with the
10824 chip.
10825
10826 -------------------------------------------------------------------------------
10827 | Argument | Description
10828 -------------------------------------------------------------------------------
10829 f_pApiInstance Pointer to API instance. This memory is used to keep
10830 the present state of the chip and all its resources.
10831
10832 f_pChanEntry Pointer to an API channel structure..
10833 f_ulAddress Address that needs to be modified..
10834 f_pulConfigDword Pointer to the content stored in the API located at the
10835 desired address.
10836
10837 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10838 #if !SKIP_Oct6100ApiRetrieveNlpConfDword
10839 UINT32 Oct6100ApiRetrieveNlpConfDword(
10840
10841 IN tPOCT6100_INSTANCE_API f_pApiInstance,
10842 IN tPOCT6100_API_CHANNEL f_pChanEntry,
10843 IN UINT32 f_ulAddress,
10844 OUT PUINT32 f_pulConfigDword )
10845 {
10846 UINT32 ulResult;
10847 UINT32 ulFirstEmptyIndex = 0xFFFFFFFF;
10848 UINT32 i;
10849
10850 /* Search for the Dword.*/
10851 for ( i = 0; i < cOCT6100_MAX_NLP_CONF_DWORD; i++ )
10852 {
10853 if ( ( ulFirstEmptyIndex == 0xFFFFFFFF ) && ( f_pChanEntry->aulNlpConfDword[ i ][ 0 ] == 0x0 ) )
10854 ulFirstEmptyIndex = i;
10855
10856 if ( f_pChanEntry->aulNlpConfDword[ i ][ 0 ] == f_ulAddress )
10857 {
10858 /* We found the matching Dword.*/
10859 *f_pulConfigDword = f_pChanEntry->aulNlpConfDword[ i ][ 1 ];
10860 return cOCT6100_ERR_OK;
10861 }
10862 }
10863
10864 if ( i == cOCT6100_MAX_NLP_CONF_DWORD && ulFirstEmptyIndex == 0xFFFFFFFF )
10865 return cOCT6100_ERR_FATAL_8E;
10866
10867 /* We did not found any entry, let's create a new entry.*/
10868 f_pChanEntry->aulNlpConfDword[ ulFirstEmptyIndex ][ 0 ] = f_ulAddress;
10869
10870
10871 /* Read the DWORD where the field is located.*/
10872 ulResult = Oct6100ApiReadDword( f_pApiInstance,
10873 f_ulAddress,
10874 f_pulConfigDword );
10875 if ( ulResult != cOCT6100_ERR_OK )
10876 return ulResult;
10877
10878 return cOCT6100_ERR_OK;
10879 }
10880 #endif
10881
10882
10883 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10884
10885 Function: Oct6100ApiSaveNlpConfDword
10886
10887 Description: This function stores a configuration Dword within an API channel
10888 structure and then writes it into the chip.
10889
10890 -------------------------------------------------------------------------------
10891 | Argument | Description
10892 -------------------------------------------------------------------------------
10893 f_pApiInstance Pointer to API instance. This memory is used to keep
10894 the present state of the chip and all its resources.
10895
10896 f_pChanEntry Pointer to an API channel structure..
10897 f_ulAddress Address that needs to be modified..
10898 f_pulConfigDword content to be stored in the API located at the
10899 desired address.
10900
10901 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10902 #if !SKIP_Oct6100ApiSaveNlpConfDword
10903 UINT32 Oct6100ApiSaveNlpConfDword(
10904
10905 IN tPOCT6100_INSTANCE_API f_pApiInstance,
10906 IN tPOCT6100_API_CHANNEL f_pChanEntry,
10907 IN UINT32 f_ulAddress,
10908 IN UINT32 f_ulConfigDword )
10909 {
10910 UINT32 ulResult;
10911 UINT32 i;
10912
10913 /* Search for the Dword.*/
10914 for ( i = 0; i < cOCT6100_MAX_NLP_CONF_DWORD; i++ )
10915 {
10916
10917 if ( f_pChanEntry->aulNlpConfDword[ i ][ 0 ] == f_ulAddress )
10918 {
10919 /* We found the matching Dword.*/
10920 f_pChanEntry->aulNlpConfDword[ i ][ 1 ] = f_ulConfigDword;
10921 break;
10922 }
10923 }
10924
10925 if ( i == cOCT6100_MAX_NLP_CONF_DWORD )
10926 return cOCT6100_ERR_FATAL_8F;
10927
10928
10929 /* Write the config DWORD.*/
10930 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
10931 f_ulAddress,
10932 f_ulConfigDword );
10933 if ( ulResult != cOCT6100_ERR_OK )
10934 return ulResult;
10935
10936 return cOCT6100_ERR_OK;
10937 }
10938 #endif
10939
10940 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10941
10942 Function: Oct6100ChannelCreateBiDirSer
10943
10944 Description: Creates a bidirectional echo cancellation channel.
10945
10946 -------------------------------------------------------------------------------
10947 | Argument | Description
10948 -------------------------------------------------------------------------------
10949 f_pApiInstance Pointer to API instance. This memory is used to keep the
10950 present state of the chip and all its resources.
10951
10952 f_pChannelCreateBiDir Pointer to a create bidirectionnal channel structure.
10953
10954 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10955 #if !SKIP_Oct6100ChannelCreateBiDirSer
10956 UINT32 Oct6100ChannelCreateBiDirSer(
10957 IN tPOCT6100_INSTANCE_API f_pApiInstance,
10958 IN OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir )
10959 {
10960 UINT16 usFirstChanIndex;
10961 UINT16 usFirstChanExtraTsiIndex;
10962 UINT16 usFirstChanSinCopyEventIndex;
10963 UINT16 usFirstChanSoutCopyEventIndex;
10964 UINT16 usSecondChanIndex;
10965 UINT16 usSecondChanExtraTsiIndex;
10966 UINT16 usSecondChanSinCopyEventIndex;
10967 UINT16 usSecondChanSoutCopyEventIndex;
10968 UINT16 usBiDirChanIndex;
10969 UINT32 ulResult;
10970
10971
10972 /* Check the user's configuration of the bidir channel for errors. */
10973 ulResult = Oct6100ApiCheckChannelCreateBiDirParams( f_pApiInstance,
10974 f_pChannelCreateBiDir,
10975 &usFirstChanIndex,
10976 &usFirstChanExtraTsiIndex,
10977 &usFirstChanSinCopyEventIndex,
10978 &usSecondChanIndex,
10979 &usSecondChanExtraTsiIndex,
10980 &usSecondChanSinCopyEventIndex
10981
10982 );
10983 if ( ulResult != cOCT6100_ERR_OK )
10984 return ulResult;
10985
10986 /* Reserve all resources needed by the bidir channel. */
10987 ulResult = Oct6100ApiReserveChannelCreateBiDirResources(f_pApiInstance,
10988
10989 &usBiDirChanIndex,
10990 &usFirstChanExtraTsiIndex,
10991 &usFirstChanSinCopyEventIndex,
10992 &usFirstChanSoutCopyEventIndex,
10993 &usSecondChanExtraTsiIndex,
10994 &usSecondChanSinCopyEventIndex,
10995 &usSecondChanSoutCopyEventIndex );
10996 if ( ulResult != cOCT6100_ERR_OK )
10997 return ulResult;
10998
10999 /* Write all necessary structures to activate the echo cancellation channel. */
11000 ulResult = Oct6100ApiWriteChannelCreateBiDirStructs( f_pApiInstance,
11001
11002 usFirstChanIndex,
11003 usFirstChanExtraTsiIndex,
11004 usFirstChanSinCopyEventIndex,
11005 usFirstChanSoutCopyEventIndex,
11006 usSecondChanIndex,
11007 usSecondChanExtraTsiIndex,
11008 usSecondChanSinCopyEventIndex,
11009 usSecondChanSoutCopyEventIndex );
11010 if ( ulResult != cOCT6100_ERR_OK )
11011 return ulResult;
11012
11013 /* Update the new echo cancellation channels's entry in the ECHO channel list. */
11014 ulResult = Oct6100ApiUpdateBiDirChannelEntry( f_pApiInstance,
11015 f_pChannelCreateBiDir,
11016 usBiDirChanIndex,
11017 usFirstChanIndex,
11018 usFirstChanExtraTsiIndex,
11019 usFirstChanSinCopyEventIndex,
11020 usFirstChanSoutCopyEventIndex,
11021 usSecondChanIndex,
11022 usSecondChanExtraTsiIndex,
11023 usSecondChanSinCopyEventIndex,
11024 usSecondChanSoutCopyEventIndex );
11025 if ( ulResult != cOCT6100_ERR_OK )
11026 return ulResult;
11027
11028 return cOCT6100_ERR_OK;
11029 }
11030 #endif
11031
11032
11033
11034
11035 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11036
11037 Function: Oct6100ApiCheckChannelCreateBiDirParams
11038
11039 Description: Checks the user's parameter passed to the create bidirectional channel
11040 function.
11041
11042 -------------------------------------------------------------------------------
11043 | Argument | Description
11044 -------------------------------------------------------------------------------
11045 f_pApiInstance Pointer to API instance. This memory is used to keep the
11046 present state of the chip and all its resources.
11047
11048 f_pChannelCreateBiDir Pointer to a create bidirectionnal channel structure.
11049 f_pusFirstChanIndex Pointer to the first channel index.
11050 f_pusFirstChanExtraTsiIndex Pointer to the first channel extra TSI index.
11051 f_pusFirstChanSinCopyEventIndex Pointer to the first channel Sin copy event index.
11052 f_pusSecondChanIndex Pointer to the second channel index.
11053 f_pusSecondChanExtraTsiIndex Pointer to the second channel extra TSI index.
11054 f_pusSecondChanSinCopyEventIndex Pointer to the second channel Sin copy event index.
11055
11056 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11057 #if !SKIP_Oct6100ApiCheckChannelCreateBiDirParams
11058 UINT32 Oct6100ApiCheckChannelCreateBiDirParams(
11059 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11060 IN tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir,
11061 OUT PUINT16 f_pusFirstChanIndex,
11062 OUT PUINT16 f_pusFirstChanExtraTsiIndex,
11063 OUT PUINT16 f_pusFirstChanSinCopyEventIndex,
11064 OUT PUINT16 f_pusSecondChanIndex,
11065 OUT PUINT16 f_pusSecondChanExtraTsiIndex,
11066 OUT PUINT16 f_pusSecondChanSinCopyEventIndex
11067
11068 )
11069 {
11070 tPOCT6100_SHARED_INFO pSharedInfo;
11071 tPOCT6100_API_CHANNEL pFirstChanEntry;
11072 tPOCT6100_API_CHANNEL pSecondChanEntry;
11073 UINT32 ulEntryOpenCnt;
11074 BOOL fCheckTssts = TRUE;
11075
11076 /* Obtain shared resources pointer.*/
11077 pSharedInfo = f_pApiInstance->pSharedInfo;
11078
11079 /* validate the bidirectional channel handle memory.*/
11080 if ( f_pChannelCreateBiDir->pulBiDirChannelHndl == NULL )
11081 return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
11082
11083
11084
11085 /* Check if bi-dir channels are activated. */
11086 if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxBiDirChannels == 0 )
11087 return cOCT6100_ERR_CHANNEL_BIDIR_DISABLED;
11088
11089 /*=======================================================================*/
11090 /* Verify the first channel handle. */
11091
11092 if ( (f_pChannelCreateBiDir->ulFirstChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
11093 return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
11094
11095 *f_pusFirstChanIndex = (UINT16)( f_pChannelCreateBiDir->ulFirstChannelHndl & cOCT6100_HNDL_INDEX_MASK );
11096 if ( *f_pusFirstChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
11097 return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
11098
11099 /* Get a pointer to the channel's list entry. */
11100 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, *f_pusFirstChanIndex )
11101
11102 /* Extract the entry open count from the provided handle. */
11103 ulEntryOpenCnt = ( f_pChannelCreateBiDir->ulFirstChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
11104
11105 /* Check for errors. */
11106 if ( pFirstChanEntry->fReserved != TRUE )
11107 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
11108 if ( ulEntryOpenCnt != pFirstChanEntry->byEntryOpenCnt )
11109 return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
11110
11111 /* Check the specific state of the channel.*/
11112 if ( pFirstChanEntry->fRinRoutCodecActive == TRUE && pFirstChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_ROUT)
11113 return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
11114 if ( pFirstChanEntry->fSinSoutCodecActive == TRUE && pFirstChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_SOUT)
11115 return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
11116 if ( pFirstChanEntry->fBiDirChannel == TRUE )
11117 return cOCT6100_ERR_CHANNEL_ALREADY_BIDIR;
11118
11119 if ( pFirstChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
11120 return cOCT6100_ERR_CHANNEL_FIRST_CHAN_IN_CONFERENCE;
11121
11122 if ( fCheckTssts == TRUE )
11123 {
11124 if ( pFirstChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
11125 return cOCT6100_ERR_CHANNEL_FIRST_CHAN_SOUT_PORT;
11126 if ( pFirstChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
11127 return cOCT6100_ERR_CHANNEL_FIRST_CHAN_RIN_PORT;
11128 }
11129
11130 /* Return the desired info.*/
11131 *f_pusFirstChanExtraTsiIndex = pFirstChanEntry->usExtraSinTsiMemIndex;
11132 *f_pusFirstChanSinCopyEventIndex = pFirstChanEntry->usSinCopyEventIndex;
11133 /*=======================================================================*/
11134
11135 /*=======================================================================*/
11136 /* Verify the second channel handle. */
11137
11138 if ( (f_pChannelCreateBiDir->ulSecondChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
11139 return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
11140
11141 *f_pusSecondChanIndex = (UINT16)( f_pChannelCreateBiDir->ulSecondChannelHndl & cOCT6100_HNDL_INDEX_MASK );
11142 if ( *f_pusSecondChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
11143 return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
11144
11145 /* Get a pointer to the channel's list entry. */
11146 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, *f_pusSecondChanIndex )
11147
11148 /* Extract the entry open count from the provided handle. */
11149 ulEntryOpenCnt = ( f_pChannelCreateBiDir->ulSecondChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
11150
11151 /* Check for errors. */
11152 if ( pSecondChanEntry->fReserved != TRUE )
11153 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
11154 if ( ulEntryOpenCnt != pSecondChanEntry->byEntryOpenCnt )
11155 return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
11156
11157 /* Check the specific state of the channel.*/
11158 if ( pSecondChanEntry->fRinRoutCodecActive == TRUE && pSecondChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_ROUT)
11159 return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
11160 if ( pSecondChanEntry->fSinSoutCodecActive == TRUE && pSecondChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_SOUT)
11161 {
11162
11163 return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
11164 }
11165
11166 if ( pSecondChanEntry->fBiDirChannel == TRUE )
11167 return cOCT6100_ERR_CHANNEL_ALREADY_BIDIR;
11168
11169 if ( fCheckTssts == TRUE )
11170 {
11171 if ( pSecondChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
11172 return cOCT6100_ERR_CHANNEL_SECOND_CHAN_SOUT_PORT;
11173 if ( pSecondChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
11174 return cOCT6100_ERR_CHANNEL_SECOND_CHAN_RIN_PORT;
11175 }
11176
11177 if ( pSecondChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
11178 return cOCT6100_ERR_CHANNEL_SECOND_CHAN_IN_CONFERENCE;
11179
11180 /* Return the desired info.*/
11181 *f_pusSecondChanExtraTsiIndex = pSecondChanEntry->usExtraSinTsiMemIndex;
11182 *f_pusSecondChanSinCopyEventIndex = pSecondChanEntry->usSinCopyEventIndex;
11183 /*=======================================================================*/
11184
11185 /* Check the law compatibility.*/
11186 if ( pFirstChanEntry->TdmConfig.bySoutPcmLaw != pSecondChanEntry->TdmConfig.byRinPcmLaw ||
11187 pFirstChanEntry->TdmConfig.byRinPcmLaw != pSecondChanEntry->TdmConfig.bySoutPcmLaw )
11188 return cOCT6100_ERR_CHANNEL_BIDIR_PCM_LAW;
11189
11190 return cOCT6100_ERR_OK;
11191 }
11192 #endif
11193
11194 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11195
11196 Function: Oct6100ApiReserveChannelCreateBiDirResources
11197
11198 Description: Reserves all resources needed for the new bidirectional channel.
11199
11200 -------------------------------------------------------------------------------
11201 | Argument | Description
11202 -------------------------------------------------------------------------------
11203 f_pApiInstance Pointer to API instance. This memory is used to keep the
11204 present state of the chip and all its resources.
11205
11206 f_pusBiDirChanIndex Pointer to the index of the bidirectionnal channel within the API instance.
11207 f_pusFirstChanExtraTsiIndex Pointer to the first channel extra TSI index.
11208 f_pusFirstChanSinCopyEventIndex Pointer to the first channel Sin copy event index.
11209 f_pusFirstChanSoutCopyEventIndex Pointer to the first channel Sout copy event index.
11210 f_pusSecondChanExtraTsiIndex Pointer to the second channel extra TSI index.
11211 f_pusSecondChanSinCopyEventIndex Pointer to the second channel Sin copy event index.
11212 f_pusSecondChanSoutCopyEventIndex Pointer to the second channel Sout copy event index.
11213
11214 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11215 #if !SKIP_Oct6100ApiReserveChannelCreateBiDirResources
11216 UINT32 Oct6100ApiReserveChannelCreateBiDirResources(
11217 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11218
11219 OUT PUINT16 f_pusBiDirChanIndex,
11220 IN OUT PUINT16 f_pusFirstChanExtraTsiIndex,
11221 IN OUT PUINT16 f_pusFirstChanSinCopyEventIndex,
11222 OUT PUINT16 f_pusFirstChanSoutCopyEventIndex,
11223 IN OUT PUINT16 f_pusSecondChanExtraTsiIndex,
11224 IN OUT PUINT16 f_pusSecondChanSinCopyEventIndex,
11225 OUT PUINT16 f_pusSecondChanSoutCopyEventIndex )
11226 {
11227 tPOCT6100_SHARED_INFO pSharedInfo;
11228 UINT32 ulResult = cOCT6100_ERR_OK;
11229 UINT32 ulTempVar;
11230
11231 BOOL fBiDirChanIndex = FALSE;
11232 BOOL fFirstExtraTsi = FALSE;
11233 BOOL fSecondExtraTsi = FALSE;
11234 BOOL fFirstSinCopyEvent = FALSE;
11235 BOOL fSecondSinCopyEvent = FALSE;
11236 BOOL fFirstSoutCopyEvent = FALSE;
11237
11238 /* Obtain local pointer to shared portion of instance. */
11239 pSharedInfo = f_pApiInstance->pSharedInfo;
11240
11241 /*===============================================================================*/
11242 /* Verify and reserve the resources that might already by allocated. */
11243
11244
11245 {
11246 if ( *f_pusFirstChanExtraTsiIndex == cOCT6100_INVALID_INDEX )
11247 {
11248 /* Reserve the first Extra TSI memory entry */
11249 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
11250 f_pusFirstChanExtraTsiIndex );
11251 if ( ulResult == cOCT6100_ERR_OK )
11252 fFirstExtraTsi = TRUE;
11253 }
11254
11255 if ( *f_pusFirstChanSinCopyEventIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
11256 {
11257 /* Reserve the Sin copy event for the first channel.*/
11258 ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
11259 f_pusFirstChanSinCopyEventIndex );
11260 if ( ulResult == cOCT6100_ERR_OK )
11261 fFirstSinCopyEvent = TRUE;
11262 }
11263 }
11264
11265 if ( *f_pusSecondChanExtraTsiIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
11266 {
11267 /* Reserve the second Extra TSI memory entry */
11268 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
11269 f_pusSecondChanExtraTsiIndex );
11270 if ( ulResult == cOCT6100_ERR_OK )
11271 fSecondExtraTsi = TRUE;
11272 }
11273
11274 if ( *f_pusSecondChanSinCopyEventIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
11275 {
11276 /* Reserve the Sin copy event for the second channel.*/
11277 ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
11278 f_pusSecondChanSinCopyEventIndex );
11279 if ( ulResult == cOCT6100_ERR_OK )
11280 fSecondSinCopyEvent = TRUE;
11281 }
11282 /*===============================================================================*/
11283
11284
11285 /*===============================================================================*/
11286 /* Now reserve all the resources specific to bidirectional channels */
11287
11288 if ( ulResult == cOCT6100_ERR_OK )
11289 {
11290 ulResult = Oct6100ApiReserveBiDirChanEntry( f_pApiInstance,
11291 f_pusBiDirChanIndex );
11292 if ( ulResult == cOCT6100_ERR_OK )
11293 {
11294 fBiDirChanIndex = TRUE;
11295
11296
11297 {
11298
11299 /* Reserve the first channel Sout copy mixer event.*/
11300 ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
11301 f_pusFirstChanSoutCopyEventIndex );
11302 }
11303
11304 if ( ulResult == cOCT6100_ERR_OK )
11305 {
11306 fFirstSoutCopyEvent = TRUE;
11307
11308 /* Reserve the second channel Sout copy mixer event.*/
11309 ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
11310 f_pusSecondChanSoutCopyEventIndex );
11311 }
11312 }
11313 }
11314
11315 /*===============================================================================*/
11316
11317
11318 /*===============================================================================*/
11319 /* Release the resources if something went wrong */
11320 if ( ulResult != cOCT6100_ERR_OK )
11321 {
11322 /*===============================================================================*/
11323 /* Release the previously reserved echo resources .*/
11324 if ( fBiDirChanIndex == TRUE )
11325 {
11326 ulTempVar = Oct6100ApiReleaseBiDirChanEntry( f_pApiInstance,
11327 *f_pusBiDirChanIndex );
11328 if ( ulTempVar != cOCT6100_ERR_OK )
11329 return ulTempVar;
11330 }
11331
11332 if ( fFirstExtraTsi == TRUE )
11333 {
11334 ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
11335 *f_pusFirstChanExtraTsiIndex );
11336 if ( ulTempVar != cOCT6100_ERR_OK )
11337 return ulTempVar;
11338 }
11339
11340 if ( fSecondExtraTsi == TRUE )
11341 {
11342 ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
11343 *f_pusSecondChanExtraTsiIndex );
11344 if ( ulTempVar != cOCT6100_ERR_OK )
11345 return ulTempVar;
11346 }
11347
11348 if ( fFirstSinCopyEvent == TRUE )
11349 {
11350 ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
11351 *f_pusFirstChanSinCopyEventIndex );
11352 if ( ulTempVar != cOCT6100_ERR_OK )
11353 return ulTempVar;
11354 }
11355
11356 if ( fSecondSinCopyEvent == TRUE )
11357 {
11358 ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
11359 *f_pusSecondChanSinCopyEventIndex );
11360 if ( ulTempVar != cOCT6100_ERR_OK )
11361 return ulTempVar;
11362 }
11363
11364 if ( ( fFirstSoutCopyEvent == TRUE )
11365
11366 )
11367 {
11368 ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
11369 *f_pusFirstChanSoutCopyEventIndex );
11370 if ( ulTempVar != cOCT6100_ERR_OK )
11371 return ulTempVar;
11372 }
11373
11374 /*===============================================================================*/
11375
11376 return ulResult;
11377 }
11378
11379 return cOCT6100_ERR_OK;
11380 }
11381 #endif
11382
11383
11384 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11385
11386 Function: Oct6100ApiWriteChannelCreateBiDirStructs
11387
11388 Description: Performs all the required structure writes to configure the
11389 new echo cancellation channel.
11390
11391 -------------------------------------------------------------------------------
11392 | Argument | Description
11393 -------------------------------------------------------------------------------
11394 f_pApiInstance Pointer to API instance. This memory is used to keep the
11395 present state of the chip and all its resources.
11396
11397 f_usFirstChanIndex Pointer to the first channel index.
11398 f_usFirstChanExtraTsiIndex Pointer to the first channel extra TSI index.
11399 f_usFirstChanSinCopyEventIndex Pointer to the first channel Sin copy event index.
11400 f_usFirstChanSoutCopyEventIndex Pointer to the first channel Sout copy event index.
11401 f_usFirstChanIndex Pointer to the second channel index.
11402 f_usSecondChanExtraTsiIndex Pointer to the second channel extra TSI index.
11403 f_usSecondChanSinCopyEventIndex Pointer to the second channel Sin copy event index.
11404 f_usSecondChanSoutCopyEventIndex Pointer to the second channel Sout copy event index.
11405
11406 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11407 #if !SKIP_Oct6100ApiWriteChannelCreateBiDirStructs
11408 UINT32 Oct6100ApiWriteChannelCreateBiDirStructs(
11409 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11410
11411 IN UINT16 f_usFirstChanIndex,
11412 IN UINT16 f_usFirstChanExtraTsiIndex,
11413 IN UINT16 f_usFirstChanSinCopyEventIndex,
11414 IN UINT16 f_usFirstChanSoutCopyEventIndex,
11415 IN UINT16 f_usSecondChanIndex,
11416 IN UINT16 f_usSecondChanExtraTsiIndex,
11417 IN UINT16 f_usSecondChanSinCopyEventIndex,
11418 IN UINT16 f_usSecondChanSoutCopyEventIndex )
11419 {
11420 tPOCT6100_SHARED_INFO pSharedInfo;
11421 tPOCT6100_API_CHANNEL pFirstChanEntry;
11422 tPOCT6100_API_CHANNEL pSecondChanEntry;
11423
11424 tOCT6100_WRITE_PARAMS WriteParams;
11425 UINT32 ulResult;
11426
11427
11428 /* Obtain local pointer to shared portion of instance. */
11429 pSharedInfo = f_pApiInstance->pSharedInfo;
11430
11431 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
11432
11433 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
11434
11435 /*==============================================================================*/
11436 /* Get a pointer to the two channel entry.*/
11437
11438 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
11439 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
11440
11441
11442
11443
11444 {
11445 /*==============================================================================*/
11446 /* Configure the Tsst control memory and add the Sin copy event if necessary. */
11447
11448 /*=======================================================================*/
11449 /* Program the Sin Copy event.*/
11450 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11451
11452 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11453 WriteParams.usWriteData |= f_usFirstChanExtraTsiIndex;
11454 WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11455
11456 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11457 if ( ulResult != cOCT6100_ERR_OK )
11458 return ulResult;
11459
11460 WriteParams.ulWriteAddress += 2;
11461 WriteParams.usWriteData = (UINT16)( pFirstChanEntry->usSinSoutTsiMemIndex );
11462
11463 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11464 if ( ulResult != cOCT6100_ERR_OK )
11465 return ulResult;
11466
11467 /*=======================================================================*/
11468
11469 /* Configure the TSST memory.*/
11470 if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11471 {
11472 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11473 pFirstChanEntry->usSinTsstIndex,
11474 f_usFirstChanExtraTsiIndex,
11475 pFirstChanEntry->TdmConfig.bySinPcmLaw );
11476 if ( ulResult != cOCT6100_ERR_OK )
11477 return ulResult;
11478 }
11479
11480 /* Now insert the event into the event list.*/
11481 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11482 f_usFirstChanSinCopyEventIndex,
11483 cOCT6100_EVENT_TYPE_SIN_COPY,
11484 f_usFirstChanIndex );
11485 if ( ulResult != cOCT6100_ERR_OK )
11486 return ulResult;
11487
11488 /*==============================================================================*/
11489 }
11490
11491
11492
11493 /*==============================================================================*/
11494 /* Configure the Tsst control memory and add the Sin copy event if necessary.*/
11495
11496 /*=======================================================================*/
11497 /* Program the Sin Copy event.*/
11498 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSecondChanSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11499
11500 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11501 WriteParams.usWriteData |= f_usSecondChanExtraTsiIndex;
11502 WriteParams.usWriteData |= pSecondChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11503
11504 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11505 if ( ulResult != cOCT6100_ERR_OK )
11506 return ulResult;
11507
11508 WriteParams.ulWriteAddress += 2;
11509 WriteParams.usWriteData = (UINT16)( pSecondChanEntry->usSinSoutTsiMemIndex );
11510
11511 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11512 if ( ulResult != cOCT6100_ERR_OK )
11513 return ulResult;
11514
11515 /*=======================================================================*/
11516
11517 /* Configure the TSST memory.*/
11518 if ( pSecondChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11519 {
11520
11521 {
11522 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11523 pSecondChanEntry->usSinTsstIndex,
11524 f_usSecondChanExtraTsiIndex,
11525 pSecondChanEntry->TdmConfig.bySinPcmLaw );
11526 }
11527 if ( ulResult != cOCT6100_ERR_OK )
11528 return ulResult;
11529 }
11530
11531 /* Now insert the event into the event list.*/
11532 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11533 f_usSecondChanSinCopyEventIndex,
11534 cOCT6100_EVENT_TYPE_SIN_COPY,
11535 f_usSecondChanIndex );
11536 if ( ulResult != cOCT6100_ERR_OK )
11537 return ulResult;
11538
11539 /*==============================================================================*/
11540
11541
11542
11543 /*==============================================================================*/
11544 /* Now, let's configure the two Sout copy events.*/
11545
11546
11547 /* First event.*/
11548 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11549
11550 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11551 WriteParams.usWriteData |= pFirstChanEntry->usSinSoutTsiMemIndex;
11552 WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11553
11554 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11555 if ( ulResult != cOCT6100_ERR_OK )
11556 return ulResult;
11557
11558 WriteParams.ulWriteAddress += 2;
11559 WriteParams.usWriteData = pSecondChanEntry->usRinRoutTsiMemIndex;
11560
11561 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11562 if ( ulResult != cOCT6100_ERR_OK )
11563 return ulResult;
11564
11565 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11566 f_usFirstChanSoutCopyEventIndex,
11567 cOCT6100_EVENT_TYPE_SOUT_COPY,
11568 f_usFirstChanIndex );
11569 if ( ulResult != cOCT6100_ERR_OK )
11570 return ulResult;
11571
11572
11573 /* Second event.*/
11574 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSecondChanSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11575
11576 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11577 WriteParams.usWriteData |= pSecondChanEntry->usSinSoutTsiMemIndex;
11578 WriteParams.usWriteData |= pSecondChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11579
11580 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11581 if ( ulResult != cOCT6100_ERR_OK )
11582 return ulResult;
11583
11584 WriteParams.ulWriteAddress += 2;
11585 WriteParams.usWriteData = pFirstChanEntry->usRinRoutTsiMemIndex;
11586
11587 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11588 if ( ulResult != cOCT6100_ERR_OK )
11589 return ulResult;
11590
11591
11592 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11593 f_usSecondChanSoutCopyEventIndex,
11594 cOCT6100_EVENT_TYPE_SOUT_COPY,
11595 f_usSecondChanIndex );
11596 if ( ulResult != cOCT6100_ERR_OK )
11597 return ulResult;
11598
11599 /*==============================================================================*/
11600
11601
11602 /*==============================================================================*/
11603 /* Clear + release the silence events if they were created. */
11604
11605 if ( pFirstChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
11606 {
11607 /* Remove the event from the list.*/
11608 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
11609 pFirstChanEntry->usRinSilenceEventIndex,
11610 cOCT6100_EVENT_TYPE_SOUT_COPY );
11611 if ( ulResult != cOCT6100_ERR_OK )
11612 return ulResult;
11613
11614 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usRinSilenceEventIndex );
11615 if ( ulResult != cOCT6100_ERR_OK )
11616 return cOCT6100_ERR_FATAL_E0;
11617
11618 pFirstChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
11619 }
11620
11621 if ( ( pSecondChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
11622
11623 )
11624 {
11625 /* Remove the event from the list.*/
11626 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
11627 pSecondChanEntry->usRinSilenceEventIndex,
11628 cOCT6100_EVENT_TYPE_SOUT_COPY );
11629 if ( ulResult != cOCT6100_ERR_OK )
11630 return ulResult;
11631
11632 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usRinSilenceEventIndex );
11633 if ( ulResult != cOCT6100_ERR_OK )
11634 return cOCT6100_ERR_FATAL_E0;
11635
11636 pSecondChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
11637 }
11638
11639 /*==============================================================================*/
11640
11641 return cOCT6100_ERR_OK;
11642 }
11643 #endif
11644
11645
11646
11647 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11648
11649 Function: Oct6100ApiUpdateBiDirChannelEntry
11650
11651 Description: Updates the new bidir channel and the channel used to create that channel.
11652
11653 -------------------------------------------------------------------------------
11654 | Argument | Description
11655 -------------------------------------------------------------------------------
11656 f_pApiInstance Pointer to API instance. This memory is used to keep
11657 the present state of the chip and all its resources.
11658
11659 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11660 #if !SKIP_Oct6100ApiUpdateBiDirChannelEntry
11661 UINT32 Oct6100ApiUpdateBiDirChannelEntry(
11662 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11663 OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir,
11664 IN UINT16 f_usBiDirChanIndex,
11665 IN UINT16 f_usFirstChanIndex,
11666 IN UINT16 f_usFirstChanExtraTsiIndex,
11667 IN UINT16 f_usFirstChanSinCopyEventIndex,
11668 IN UINT16 f_usFirstChanSoutCopyEventIndex,
11669 IN UINT16 f_usSecondChanIndex,
11670 IN UINT16 f_usSecondChanExtraTsiIndex,
11671 IN UINT16 f_usSecondChanSinCopyEventIndex,
11672 IN UINT16 f_usSecondChanSoutCopyEventIndex )
11673 {
11674 tPOCT6100_SHARED_INFO pSharedInfo;
11675 tPOCT6100_API_CHANNEL pFirstChanEntry;
11676 tPOCT6100_API_CHANNEL pSecondChanEntry;
11677 tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
11678
11679 /* Obtain local pointer to shared portion of instance. */
11680 pSharedInfo = f_pApiInstance->pSharedInfo;
11681
11682 /* Obtain a pointer to the new buffer's list entry. */
11683 mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, f_usBiDirChanIndex );
11684 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
11685 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
11686
11687 /*=======================================================================*/
11688 /* Copy the channel's configuration and allocated resources. */
11689
11690 pFirstChanEntry->usExtraSinTsiMemIndex = f_usFirstChanExtraTsiIndex;
11691 pFirstChanEntry->usSinCopyEventIndex = f_usFirstChanSinCopyEventIndex;
11692 pFirstChanEntry->usSoutCopyEventIndex = f_usFirstChanSoutCopyEventIndex;
11693
11694 pSecondChanEntry->usExtraSinTsiMemIndex = f_usSecondChanExtraTsiIndex;
11695 pSecondChanEntry->usSinCopyEventIndex = f_usSecondChanSinCopyEventIndex;
11696 pSecondChanEntry->usSoutCopyEventIndex = f_usSecondChanSoutCopyEventIndex;
11697
11698 /* Save the channel info in the bidir channel.*/
11699 pBiDirChanEntry->usFirstChanIndex = f_usFirstChanIndex;
11700 pBiDirChanEntry->usSecondChanIndex = f_usSecondChanIndex;
11701
11702
11703
11704 /* Increment the extra TSI memory dependency count.*/
11705
11706 pFirstChanEntry->usExtraSinTsiDependencyCnt++;
11707 pSecondChanEntry->usExtraSinTsiDependencyCnt++;
11708
11709 /* Set the bidir flag in the channel structure.*/
11710 pFirstChanEntry->fBiDirChannel = TRUE;
11711 pSecondChanEntry->fBiDirChannel = TRUE;
11712
11713 /*=======================================================================*/
11714
11715 /* Form handle returned to user. */
11716 *f_pChannelCreateBiDir->pulBiDirChannelHndl = cOCT6100_HNDL_TAG_BIDIR_CHANNEL | (pBiDirChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_usBiDirChanIndex;
11717
11718 /* Finally, mark the channel as open. */
11719 pBiDirChanEntry->fReserved = TRUE;
11720
11721 /* Increment the number of channel open.*/
11722 f_pApiInstance->pSharedInfo->ChipStats.usNumberBiDirChannels++;
11723
11724 /*=======================================================================*/
11725
11726 return cOCT6100_ERR_OK;
11727 }
11728 #endif
11729
11730
11731
11732
11733
11734 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11735
11736 Function: Oct6100ChannelDestroyBiDirSer
11737
11738 Description: Closes a bidirectional channel.
11739
11740 -------------------------------------------------------------------------------
11741 | Argument | Description
11742 -------------------------------------------------------------------------------
11743 f_pApiInstance Pointer to API instance. This memory is used to keep the
11744 present state of the chip and all its resources.
11745
11746 f_pChannelDestroyBiDir Pointer to a destroy bidirectionnal channel structure.
11747
11748 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11749 #if !SKIP_Oct6100ChannelDestroyBiDirSer
11750 UINT32 Oct6100ChannelDestroyBiDirSer(
11751 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11752 IN tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir )
11753 {
11754 UINT16 usBiDirChanIndex;
11755 UINT16 usFirstChanIndex;
11756 UINT16 usSecondChanIndex;
11757
11758
11759 UINT32 ulResult;
11760
11761 /* Verify that all the parameters given match the state of the API. */
11762 ulResult = Oct6100ApiAssertDestroyBiDirChanParams( f_pApiInstance,
11763 f_pChannelDestroyBiDir,
11764 &usBiDirChanIndex,
11765
11766 &usFirstChanIndex,
11767 &usSecondChanIndex );
11768 if ( ulResult != cOCT6100_ERR_OK )
11769 return ulResult;
11770
11771 /* Release all resources associated to the echo cancellation channel. */
11772 ulResult = Oct6100ApiInvalidateBiDirChannelStructs( f_pApiInstance,
11773
11774 usFirstChanIndex,
11775 usSecondChanIndex );
11776 if ( ulResult != cOCT6100_ERR_OK )
11777 return ulResult;
11778
11779 /* Release all resources associated to the echo cancellation channel. */
11780 ulResult = Oct6100ApiReleaseBiDirChannelResources( f_pApiInstance,
11781 usBiDirChanIndex,
11782
11783 usFirstChanIndex,
11784 usSecondChanIndex );
11785 if ( ulResult != cOCT6100_ERR_OK )
11786 return ulResult;
11787
11788 /* Invalidate the handle.*/
11789 f_pChannelDestroyBiDir->ulBiDirChannelHndl = cOCT6100_INVALID_HANDLE;
11790
11791 return cOCT6100_ERR_OK;
11792 }
11793 #endif
11794
11795 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11796
11797 Function: Oct6100ApiAssertDestroyBiDirChanParams
11798
11799 Description: Validate the handle given by the user and verify the state of
11800 the channel about to be closed.
11801
11802 -------------------------------------------------------------------------------
11803 | Argument | Description
11804 -------------------------------------------------------------------------------
11805 f_pApiInstance Pointer to API instance. This memory is used to keep the
11806 present state of the chip and all its resources.
11807
11808 f_pChannelDestroyBiDir Pointer to a destroy bidirectional channel structure.
11809 f_pusBiDirChanIndex Pointer to the bidir channel entry within the API's list.
11810 f_pusFirstChanIndex Pointer to the first channel index part of the bidir channel.
11811 f_pusFirstChanIndex Pointer to the second channel index part of the bidir channel.
11812
11813 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11814 #if !SKIP_Oct6100ApiAssertDestroyBiDirChanParams
11815 UINT32 Oct6100ApiAssertDestroyBiDirChanParams(
11816 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11817 IN tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir,
11818 IN OUT PUINT16 f_pusBiDirChanIndex,
11819
11820 IN OUT PUINT16 f_pusFirstChanIndex,
11821 IN OUT PUINT16 f_pusSecondChanIndex )
11822 {
11823 tPOCT6100_SHARED_INFO pSharedInfo;
11824 tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
11825 UINT32 ulEntryOpenCnt;
11826
11827 /* Get local pointer(s). */
11828 pSharedInfo = f_pApiInstance->pSharedInfo;
11829
11830 /* Check the provided handle. */
11831 if ( (f_pChannelDestroyBiDir->ulBiDirChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_BIDIR_CHANNEL )
11832 return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
11833
11834 *f_pusBiDirChanIndex = (UINT16)( f_pChannelDestroyBiDir->ulBiDirChannelHndl & cOCT6100_HNDL_INDEX_MASK );
11835 if ( *f_pusBiDirChanIndex >= pSharedInfo->ChipConfig.usMaxBiDirChannels )
11836 return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
11837
11838 /*=======================================================================*/
11839 /* Get a pointer to the bidir channel's list entry. */
11840
11841 mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, *f_pusBiDirChanIndex )
11842
11843 /* Extract the entry open count from the provided handle. */
11844 ulEntryOpenCnt = ( f_pChannelDestroyBiDir->ulBiDirChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
11845
11846 /* Check for errors. */
11847 if ( pBiDirChanEntry->fReserved != TRUE )
11848 return cOCT6100_ERR_CHANNEL_BIDIR_CHAN_NOT_OPEN;
11849 if ( ulEntryOpenCnt != pBiDirChanEntry->byEntryOpenCnt )
11850 return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
11851
11852 /*=======================================================================*/
11853
11854 /* Return the index of the channel used to create this bidirectional channel.*/
11855 *f_pusFirstChanIndex = pBiDirChanEntry->usFirstChanIndex;
11856 *f_pusSecondChanIndex = pBiDirChanEntry->usSecondChanIndex;
11857
11858
11859
11860 return cOCT6100_ERR_OK;
11861 }
11862 #endif
11863
11864 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11865
11866 Function: Oct6100ApiInvalidateBiDirChannelStructs
11867
11868 Description: Destroy the link between the two channels.
11869
11870 -------------------------------------------------------------------------------
11871 | Argument | Description
11872 -------------------------------------------------------------------------------
11873 f_pApiInstance Pointer to API instance. This memory is used to keep the
11874 present state of the chip and all its resources.
11875
11876 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11877 #if !SKIP_Oct6100ApiInvalidateBiDirChannelStructs
11878 UINT32 Oct6100ApiInvalidateBiDirChannelStructs(
11879 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11880
11881 IN UINT16 f_usFirstChanIndex,
11882 IN UINT16 f_usSecondChanIndex )
11883 {
11884 tPOCT6100_SHARED_INFO pSharedInfo;
11885 tPOCT6100_API_CHANNEL pFirstChanEntry;
11886 tPOCT6100_API_CHANNEL pSecondChanEntry;
11887
11888 tOCT6100_WRITE_PARAMS WriteParams;
11889 UINT32 ulResult;
11890
11891 /* Obtain local pointer to shared portion of instance. */
11892 pSharedInfo = f_pApiInstance->pSharedInfo;
11893
11894 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
11895
11896 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
11897
11898 /* Get pointers to the API entry of the two channel used to create the bidir channel.*/
11899 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
11900 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
11901
11902 /* Clear the SIN copy event of the first channel and release the Extra TSI memory if
11903 this feature was the only one using it. */
11904
11905 {
11906 if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 )
11907 {
11908 /*=======================================================================*/
11909 /* Clear the Sin Copy event.*/
11910 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11911 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
11912
11913 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11914 if ( ulResult != cOCT6100_ERR_OK )
11915 return ulResult;
11916
11917 /*=======================================================================*/
11918
11919 /* Configure the TSST memory.*/
11920 if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11921 {
11922 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11923 pFirstChanEntry->usSinTsstIndex,
11924 pFirstChanEntry->usSinSoutTsiMemIndex,
11925 pFirstChanEntry->TdmConfig.bySinPcmLaw );
11926 if ( ulResult != cOCT6100_ERR_OK )
11927 return ulResult;
11928 }
11929
11930 /* Remove the event from the list.*/
11931 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
11932 pFirstChanEntry->usSinCopyEventIndex,
11933 cOCT6100_EVENT_TYPE_SIN_COPY );
11934 if ( ulResult != cOCT6100_ERR_OK )
11935 return ulResult;
11936
11937 }
11938 }
11939
11940 /* Clear the SIN copy event of the first channel and release the Extra TSI memory if
11941 this feature was the only one using it. */
11942 if ( pSecondChanEntry->usExtraSinTsiDependencyCnt == 1 )
11943 {
11944 /*=======================================================================*/
11945 /* Clear the Sin Copy event.*/
11946 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSecondChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11947 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
11948
11949 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11950 if ( ulResult != cOCT6100_ERR_OK )
11951 return ulResult;
11952
11953 /*=======================================================================*/
11954
11955 /* Configure the TSST memory.*/
11956 if ( pSecondChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11957 {
11958 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11959 pSecondChanEntry->usSinTsstIndex,
11960 pSecondChanEntry->usSinSoutTsiMemIndex,
11961 pSecondChanEntry->TdmConfig.bySinPcmLaw );
11962 if ( ulResult != cOCT6100_ERR_OK )
11963 return ulResult;
11964 }
11965
11966 /* Remove the event from the list.*/
11967 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
11968 pSecondChanEntry->usSinCopyEventIndex,
11969 cOCT6100_EVENT_TYPE_SIN_COPY );
11970 if ( ulResult != cOCT6100_ERR_OK )
11971 return ulResult;
11972
11973 }
11974
11975 /* Now remove the sout copy of the first channel.*/
11976
11977
11978 {
11979 /*=======================================================================*/
11980 /* Clear the Sout Copy event of the first channel.*/
11981 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11982 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
11983
11984 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11985 if ( ulResult != cOCT6100_ERR_OK )
11986 return ulResult;
11987 /*=======================================================================*/
11988
11989 /* Remove the event from the list.*/
11990 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
11991 pFirstChanEntry->usSoutCopyEventIndex,
11992 cOCT6100_EVENT_TYPE_SOUT_COPY );
11993 if ( ulResult != cOCT6100_ERR_OK )
11994 return ulResult;
11995 }
11996
11997
11998
11999 /* Now remove the sout copy of the second channel.*/
12000
12001 /*=======================================================================*/
12002 /* Clear the Sout Copy event of the second channel.*/
12003 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSecondChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
12004 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
12005
12006 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12007 if ( ulResult != cOCT6100_ERR_OK )
12008 return ulResult;
12009 /*=======================================================================*/
12010
12011 /* Remove the event from the list.*/
12012 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
12013 pSecondChanEntry->usSoutCopyEventIndex,
12014 cOCT6100_EVENT_TYPE_SOUT_COPY );
12015 if ( ulResult != cOCT6100_ERR_OK )
12016 return ulResult;
12017
12018
12019
12020 return cOCT6100_ERR_OK;
12021 }
12022 #endif
12023
12024 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12025
12026 Function: Oct6100ApiReleaseBiDirChannelResources
12027
12028 Description: Release and clear the API entry associated to the bidirectional channel.
12029
12030 -------------------------------------------------------------------------------
12031 | Argument | Description
12032 -------------------------------------------------------------------------------
12033 f_pApiInstance Pointer to API instance. This memory is used to keep the
12034 present state of the chip and all its resources.
12035
12036 f_usBiDirChanIndex Index of the bidirectionnal channel in the API's bidir channel list.
12037 f_usFirstChanIndex Index of the first channel used to create the bidir channel.
12038 f_usSecondChanIndex Index of the second channel used to create the bidir channel.
12039
12040 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12041 #if !SKIP_Oct6100ApiReleaseBiDirChannelResources
12042 UINT32 Oct6100ApiReleaseBiDirChannelResources(
12043 IN tPOCT6100_INSTANCE_API f_pApiInstance,
12044 IN UINT16 f_usBiDirChanIndex,
12045
12046 IN UINT16 f_usFirstChanIndex,
12047 IN UINT16 f_usSecondChanIndex )
12048 {
12049 tPOCT6100_SHARED_INFO pSharedInfo;
12050 tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
12051 tPOCT6100_API_CHANNEL pFirstChanEntry;
12052 tPOCT6100_API_CHANNEL pSecondChanEntry;
12053 tPOCT6100_API_MIXER_EVENT pTempEventEntry;
12054 UINT32 ulResult;
12055
12056 /* Obtain local pointer to shared portion of instance. */
12057 pSharedInfo = f_pApiInstance->pSharedInfo;
12058
12059 mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, f_usBiDirChanIndex );
12060 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
12061 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
12062
12063 /* Release the bidir entry.*/
12064 ulResult = Oct6100ApiReleaseBiDirChanEntry( f_pApiInstance, f_usBiDirChanIndex );
12065 if ( ulResult != cOCT6100_ERR_OK )
12066 return cOCT6100_ERR_FATAL_AC;
12067
12068 /* Release the Extra TSI memory and the SIN copy event if required.*/
12069
12070 {
12071 if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 )
12072 {
12073 /* Release the two TSI chariot memory entries.*/
12074 ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pFirstChanEntry->usExtraSinTsiMemIndex );
12075 if ( ulResult != cOCT6100_ERR_OK )
12076 return cOCT6100_ERR_FATAL_A3;
12077
12078 /* Relese the SIN copy event.*/
12079 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSinCopyEventIndex );
12080 if ( ulResult != cOCT6100_ERR_OK )
12081 return cOCT6100_ERR_FATAL_A4;
12082
12083 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pFirstChanEntry->usSinCopyEventIndex );
12084
12085 /* Invalidate the entry.*/
12086 pTempEventEntry->fReserved = FALSE;
12087 pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
12088 pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12089
12090 pFirstChanEntry->usExtraSinTsiDependencyCnt--;
12091 pFirstChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
12092 pFirstChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
12093 }
12094 else
12095 {
12096 pFirstChanEntry->usExtraSinTsiDependencyCnt--;
12097 }
12098 }
12099
12100 if ( pSecondChanEntry->usExtraSinTsiDependencyCnt == 1 )
12101 {
12102 /* Release the two TSI chariot memory entries.*/
12103 ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pSecondChanEntry->usExtraSinTsiMemIndex );
12104 if ( ulResult != cOCT6100_ERR_OK )
12105 return cOCT6100_ERR_FATAL_A5;
12106
12107 /* Relese the SIN copy event.*/
12108 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usSinCopyEventIndex );
12109 if ( ulResult != cOCT6100_ERR_OK )
12110 return cOCT6100_ERR_FATAL_A6;
12111
12112 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pSecondChanEntry->usSinCopyEventIndex );
12113 /* Invalidate the entry.*/
12114 pTempEventEntry->fReserved = FALSE;
12115 pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
12116 pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12117
12118 pSecondChanEntry->usExtraSinTsiDependencyCnt--;
12119 pSecondChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
12120 pSecondChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
12121 }
12122 else
12123 {
12124 pSecondChanEntry->usExtraSinTsiDependencyCnt--;
12125 }
12126
12127
12128 {
12129 /* Release the SOUT copy event of the first channel.*/
12130 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSoutCopyEventIndex );
12131 if ( ulResult != cOCT6100_ERR_OK )
12132 return cOCT6100_ERR_FATAL_A7;
12133
12134 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pFirstChanEntry->usSoutCopyEventIndex );
12135 /* Invalidate the entry.*/
12136 pTempEventEntry->fReserved = FALSE;
12137 pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
12138 pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12139 }
12140
12141 /* Release the SOUT copy event of the second channel.*/
12142 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usSoutCopyEventIndex );
12143 if ( ulResult != cOCT6100_ERR_OK )
12144 return cOCT6100_ERR_FATAL_A8;
12145
12146 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pSecondChanEntry->usSoutCopyEventIndex );
12147 /* Invalidate the entry.*/
12148 pTempEventEntry->fReserved = FALSE;
12149 pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
12150 pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12151
12152
12153 /*=======================================================================*/
12154 /* Update the first channel's list entry. */
12155
12156 /* Mark the channel as closed. */
12157 pFirstChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX;
12158 pFirstChanEntry->fBiDirChannel = FALSE;
12159
12160 /*=======================================================================*/
12161
12162 /*=======================================================================*/
12163 /* Update the second channel's list entry. */
12164
12165 /* Mark the channel as closed. */
12166
12167 pSecondChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX;
12168 pSecondChanEntry->fBiDirChannel = FALSE;
12169
12170 /*=======================================================================*/
12171
12172 /*=======================================================================*/
12173 /* Update the bidirectional channel's list entry. */
12174
12175 /* Mark the channel as closed. */
12176 pBiDirChanEntry->fReserved = FALSE;
12177 pBiDirChanEntry->byEntryOpenCnt++;
12178
12179 pBiDirChanEntry->usFirstChanIndex = cOCT6100_INVALID_INDEX;
12180 pBiDirChanEntry->usSecondChanIndex = cOCT6100_INVALID_INDEX;
12181
12182 /* Decrement the number of channel open.*/
12183 f_pApiInstance->pSharedInfo->ChipStats.usNumberBiDirChannels--;
12184
12185 /*=======================================================================*/
12186
12187
12188 /*=======================================================================*/
12189 /* Check if some of the ports must be muted back. */
12190
12191 ulResult = Oct6100ApiMutePorts( f_pApiInstance,
12192 f_usFirstChanIndex,
12193 pFirstChanEntry->usRinTsstIndex,
12194 pFirstChanEntry->usSinTsstIndex,
12195 FALSE );
12196 if ( ulResult != cOCT6100_ERR_OK )
12197 return ulResult;
12198
12199 ulResult = Oct6100ApiMutePorts( f_pApiInstance,
12200 f_usSecondChanIndex,
12201 pSecondChanEntry->usRinTsstIndex,
12202 pSecondChanEntry->usSinTsstIndex,
12203 FALSE );
12204 if ( ulResult != cOCT6100_ERR_OK )
12205 return ulResult;
12206
12207 /*=======================================================================*/
12208
12209 return cOCT6100_ERR_OK;
12210 }
12211 #endif
12212
12213 #if !SKIP_Oct6100ApiOctFloatToDbEnergyByte
12214 INT32 Oct6100ApiOctFloatToDbEnergyByte(UINT8 x)
12215 {
12216 INT32 lResult;
12217
12218 lResult = Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)(x << 8) );
12219 return lResult;
12220 }
12221 #endif
12222
12223 #if !SKIP_Oct6100ApiOctFloatToDbEnergyHalf
12224 INT32 Oct6100ApiOctFloatToDbEnergyHalf(UINT16 x)
12225 {
12226 INT32 y;
12227 UINT16 m;
12228
12229 y = (((x >> 8) & 0x7F) - 0x41) * 3;
12230
12231 m = (UINT16)((x & 0x00E0) >> 5);
12232 if (m < 2) y += 0;
12233 else if (m < 5) y += 1;
12234 else y += 2;
12235
12236 return y;
12237 }
12238 #endif
12239
12240 #if !SKIP_Oct6100ApiDbAmpHalfToOctFloat
12241 UINT16 Oct6100ApiDbAmpHalfToOctFloat(INT32 x)
12242 {
12243 INT32 db_div6;
12244 INT32 db_mod6;
12245 UINT16 rval;
12246 INT32 x_unsigned;
12247
12248 if(x < 0)
12249 {
12250 x_unsigned = -x;
12251 }
12252 else
12253 {
12254 x_unsigned = x;
12255 }
12256
12257 db_div6 = x_unsigned / 6;
12258 db_mod6 = x_unsigned % 6;
12259
12260 if(x < 0)
12261 {
12262 if(db_mod6 == 0)
12263 {
12264 /* Change nothing! */
12265 db_div6 = -db_div6;
12266 }
12267 else
12268 {
12269 /* When we are negative, round down, and then adjust modulo. For example, if
12270 x is -1, then db_div6 is 0 and db_mod6 is 1. We adjust so db_div6 = -1 and
12271 db_mod6 = 5, which gives the correct adjustment. */
12272 db_div6 = -db_div6-1;
12273 db_mod6 = 6 - db_mod6;
12274 }
12275 }
12276
12277 rval = (UINT16)(0x4100 + db_div6 * 0x100);
12278
12279 if(db_mod6 == 0)
12280 {
12281 rval += 0x0000;
12282 }
12283 else if(db_mod6 == 1)
12284 {
12285 rval += 0x0020;
12286 }
12287 else if(db_mod6 == 2)
12288 {
12289 rval += 0x0040;
12290 }
12291 else if(db_mod6 == 3)
12292 {
12293 rval += 0x0070;
12294 }
12295 else if(db_mod6 == 4)
12296 {
12297 rval += 0x0090;
12298 }
12299 else /* if(db_mod6 == 5) */
12300 {
12301 rval += 0x00D0;
12302 }
12303
12304 return rval;
12305 }
12306 #endif
12307
12308 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12309
12310 Function: Oct6100ApiWriteDebugChanMemory
12311
12312 Description: This function configure a debug channel echo memory entry
12313 in internal memory.and external memory.
12314
12315 -------------------------------------------------------------------------------
12316 | Argument | Description
12317 -------------------------------------------------------------------------------
12318 f_pApiInstance Pointer to API instance. This memory is used to keep
12319 the present state of the chip and all its resources.
12320
12321 f_pTdmConfig Pointer to a TDM configuration structure.
12322 f_pVqeConfig Pointer to a VQE configuration structure.
12323 f_pChannelOpen Pointer to a channel configuration structure.
12324 f_usChanIndex Index of the echo channel in the API instance.
12325 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
12326 f_usRinRoutTsiIndex RIN/ROUT TSI index within the TSI chariot memory.
12327 f_usSinSoutTsiIndex SIN/SOUT TSI index within the TSI chariot memory.
12328
12329 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12330 #if !SKIP_Oct6100ApiWriteDebugChanMemory
12331 UINT32 Oct6100ApiWriteDebugChanMemory(
12332 IN tPOCT6100_INSTANCE_API f_pApiInstance,
12333 IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig,
12334 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
12335 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
12336 IN UINT16 f_usChanIndex,
12337 IN UINT16 f_usEchoMemIndex,
12338 IN UINT16 f_usRinRoutTsiIndex,
12339 IN UINT16 f_usSinSoutTsiIndex )
12340 {
12341 tPOCT6100_SHARED_INFO pSharedInfo;
12342 UINT32 ulResult;
12343
12344 /* Obtain pointer to local portion of the instance. */
12345 pSharedInfo = f_pApiInstance->pSharedInfo;
12346
12347 /*==============================================================================*/
12348 /* Write the VQE configuration of the debug channel. */
12349
12350 ulResult = Oct6100ApiWriteVqeMemory(
12351 f_pApiInstance,
12352 f_pVqeConfig,
12353 f_pChannelOpen,
12354 f_usChanIndex,
12355 f_usEchoMemIndex,
12356 TRUE,
12357 FALSE );
12358 if ( ulResult != cOCT6100_ERR_OK )
12359 return ulResult;
12360
12361 /*==============================================================================*/
12362
12363
12364 /*==============================================================================*/
12365
12366 /* Write the echo memory configuration of the debug channel. */
12367 ulResult = Oct6100ApiWriteEchoMemory(
12368 f_pApiInstance,
12369 f_pTdmConfig,
12370 f_pChannelOpen,
12371 f_usEchoMemIndex,
12372 f_usRinRoutTsiIndex,
12373 f_usSinSoutTsiIndex );
12374 if ( ulResult != cOCT6100_ERR_OK )
12375 return ulResult;
12376
12377 /*==============================================================================*/
12378
12379 return cOCT6100_ERR_OK;
12380 }
12381 #endif
12382
12383
12384 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12385
12386 Function: Oct6100ApiDebugChannelOpen
12387
12388 Description: Internal function used to open a debug channel.
12389
12390 -------------------------------------------------------------------------------
12391 | Argument | Description
12392 -------------------------------------------------------------------------------
12393 f_pApiInstance Pointer to API instance. This memory is used to keep
12394 the present state of the chip and all its resources.
12395
12396 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12397 #if !SKIP_Oct6100ApiDebugChannelOpen
12398 UINT32 Oct6100ApiDebugChannelOpen(
12399 IN tPOCT6100_INSTANCE_API f_pApiInstance )
12400 {
12401 tPOCT6100_SHARED_INFO pSharedInfo;
12402 tOCT6100_CHANNEL_OPEN TempChanOpen;
12403
12404 UINT32 ulResult;
12405 UINT16 usChanIndex;
12406 UINT16 usDummyEchoIndex;
12407
12408 pSharedInfo = f_pApiInstance->pSharedInfo;
12409
12410 /* Let's program the channel memory.*/
12411 Oct6100ChannelOpenDef( &TempChanOpen );
12412
12413 TempChanOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_HT_RESET; /* Activate the channel in reset.*/
12414 TempChanOpen.VqeConfig.fEnableNlp = FALSE;
12415 TempChanOpen.VqeConfig.ulComfortNoiseMode = cOCT6100_COMFORT_NOISE_NORMAL;
12416 TempChanOpen.VqeConfig.fSinDcOffsetRemoval = FALSE;
12417 TempChanOpen.VqeConfig.fRinDcOffsetRemoval = FALSE;
12418 TempChanOpen.VqeConfig.lDefaultErlDb = 0;
12419
12420 /* Loop to reserve the proper entry for the debug channel */
12421 for( usChanIndex = 0; usChanIndex < ( pSharedInfo->DebugInfo.usRecordChanIndex + 1 ); usChanIndex ++ )
12422 {
12423 ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, &usDummyEchoIndex );
12424 if( ulResult != cOCT6100_ERR_OK )
12425 return ulResult;
12426 }
12427
12428 /* Loop to free all entries except the one for the debug channel */
12429 for( usChanIndex = pSharedInfo->DebugInfo.usRecordChanIndex; usChanIndex > 0; )
12430 {
12431 usChanIndex--;
12432 ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, usChanIndex );
12433 if( ulResult != cOCT6100_ERR_OK )
12434 return ulResult;
12435 }
12436
12437 ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance,
12438 &TempChanOpen.TdmConfig,
12439 &TempChanOpen.VqeConfig,
12440 &TempChanOpen,
12441 pSharedInfo->DebugInfo.usRecordChanIndex,
12442 pSharedInfo->DebugInfo.usRecordMemIndex,
12443 pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex,
12444 pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex );
12445 if ( ulResult != cOCT6100_ERR_OK )
12446 return ulResult;
12447
12448 return cOCT6100_ERR_OK;
12449 }
12450 #endif
12451
12452
12453 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12454
12455 Function: Oct6100ApiMuteChannelPort
12456
12457 Description: This function will verify if a input TSST is bound to the RIN and
12458 SIN port. If not, the port will be muted.
12459
12460 -------------------------------------------------------------------------------
12461 | Argument | Description
12462 -------------------------------------------------------------------------------
12463 f_pApiInstance Pointer to API instance. This memory is used to keep
12464 the present state of the chip and all its resources.
12465
12466 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12467 #if !SKIP_Oct6100ApiMutePorts
12468 UINT32 Oct6100ApiMutePorts(
12469 IN tPOCT6100_INSTANCE_API f_pApiInstance,
12470 IN UINT16 f_usEchoIndex,
12471 IN UINT16 f_usRinTsstIndex,
12472 IN UINT16 f_usSinTsstIndex,
12473 IN BOOL f_fCheckBridgeIndex )
12474 {
12475 tPOCT6100_SHARED_INFO pSharedInfo;
12476 tPOCT6100_API_CHANNEL pChanEntry;
12477 tOCT6100_WRITE_PARAMS WriteParams;
12478 UINT32 ulResult;
12479
12480 pSharedInfo = f_pApiInstance->pSharedInfo;
12481
12482 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
12483
12484 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12485
12486 /* Obtain a pointer to the new buffer's list entry. */
12487 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usEchoIndex );
12488
12489 /* Mute the Rin port. */
12490 if ( ( f_fCheckBridgeIndex == FALSE )
12491 || ( ( f_fCheckBridgeIndex == TRUE ) && ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX ) ) )
12492 {
12493 /* If the channel is in bidir mode, do not create the Rin silence event!!! */
12494 if ( pChanEntry->fBiDirChannel == FALSE )
12495 {
12496 if ( ( ( f_usRinTsstIndex == cOCT6100_INVALID_INDEX ) || ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) )
12497 && ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
12498 {
12499 ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance,
12500 &pChanEntry->usRinSilenceEventIndex );
12501 if ( ulResult != cOCT6100_ERR_OK )
12502 return ulResult;
12503
12504 /* Now, write the mixer event used to copy the RIN signal of the silence channel
12505 into the RIN signal of the current channel. */
12506
12507 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usRinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
12508
12509 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
12510 WriteParams.usWriteData |= 1534;
12511 WriteParams.usWriteData |= cOCT6100_PCM_U_LAW << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
12512
12513 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12514 if ( ulResult != cOCT6100_ERR_OK )
12515 return ulResult;
12516
12517 WriteParams.ulWriteAddress += 2;
12518 WriteParams.usWriteData = pChanEntry->usRinRoutTsiMemIndex;
12519
12520 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12521 if ( ulResult != cOCT6100_ERR_OK )
12522 return ulResult;
12523
12524 /*=======================================================================*/
12525
12526
12527 /*=======================================================================*/
12528 /* Now insert the Sin copy event into the list.*/
12529
12530 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
12531 pChanEntry->usRinSilenceEventIndex,
12532 cOCT6100_EVENT_TYPE_SOUT_COPY,
12533 f_usEchoIndex );
12534 if ( ulResult != cOCT6100_ERR_OK )
12535 return ulResult;
12536 }
12537 }
12538 }
12539
12540 /* Mute the Sin port. */
12541 if ( ( ( f_usSinTsstIndex == cOCT6100_INVALID_INDEX ) || ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) )
12542 && ( pChanEntry->usSinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
12543 {
12544 ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance,
12545 &pChanEntry->usSinSilenceEventIndex );
12546 if ( ulResult != cOCT6100_ERR_OK )
12547 return ulResult;
12548
12549 /* Now, write the mixer event used to copy the SIN signal of the silence channel
12550 into the SIN signal of the current channel. */
12551
12552 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
12553
12554 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
12555 WriteParams.usWriteData |= 1534;
12556 WriteParams.usWriteData |= cOCT6100_PCM_U_LAW << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
12557
12558 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12559 if ( ulResult != cOCT6100_ERR_OK )
12560 return ulResult;
12561
12562 WriteParams.ulWriteAddress += 2;
12563 WriteParams.usWriteData = pChanEntry->usSinSoutTsiMemIndex;
12564
12565 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12566 if ( ulResult != cOCT6100_ERR_OK )
12567 return ulResult;
12568
12569 /*=======================================================================*/
12570
12571
12572 /*=======================================================================*/
12573 /* Now insert the Sin copy event into the list.*/
12574
12575 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
12576 pChanEntry->usSinSilenceEventIndex,
12577 cOCT6100_EVENT_TYPE_SOUT_COPY,
12578 f_usEchoIndex );
12579 if ( ulResult != cOCT6100_ERR_OK )
12580 return ulResult;
12581 }
12582
12583 /* Unmute the Rin port if it was muted. */
12584 if ( ( ( f_usRinTsstIndex != cOCT6100_INVALID_INDEX ) && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) == 0x0 ) )
12585 && ( pChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX ) )
12586 {
12587 /* Remove the event from the list.*/
12588 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
12589 pChanEntry->usRinSilenceEventIndex,
12590 cOCT6100_EVENT_TYPE_SOUT_COPY );
12591 if ( ulResult != cOCT6100_ERR_OK )
12592 return ulResult;
12593
12594 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usRinSilenceEventIndex );
12595 if ( ulResult != cOCT6100_ERR_OK )
12596 return cOCT6100_ERR_FATAL_E1;
12597
12598 pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
12599 }
12600
12601 /* Unmute the Sin port if it was muted. */
12602 if ( ( ( f_usSinTsstIndex != cOCT6100_INVALID_INDEX ) && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) == 0x0 ) )
12603 && ( pChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX ) )
12604 {
12605 /* Remove the event from the list.*/
12606 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
12607 pChanEntry->usSinSilenceEventIndex,
12608 cOCT6100_EVENT_TYPE_SOUT_COPY );
12609 if ( ulResult != cOCT6100_ERR_OK )
12610 return ulResult;
12611
12612 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usSinSilenceEventIndex );
12613 if ( ulResult != cOCT6100_ERR_OK )
12614 return cOCT6100_ERR_FATAL_E2;
12615
12616 pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
12617 }
12618
12619 return cOCT6100_ERR_OK;
12620 }
12621 #endif
12622
12623 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12624
12625 Function: Oct6100ApiSetChannelLevelControl
12626
12627 Description: This function will configure the level control on a given
12628 channel.
12629
12630 -------------------------------------------------------------------------------
12631 | Argument | Description
12632 -------------------------------------------------------------------------------
12633 f_pApiInstance Pointer to API instance. This memory is used to keep
12634 the present state of the chip and all its resources.
12635
12636 f_pVqeConfig VQE config of the channel.
12637 f_usChanIndex Index of the channel within the API instance.
12638 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
12639 f_fClearAlcHlcStatusBit If this is set, the ALC-HLC status bit must be
12640 incremented.
12641
12642 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12643 #if !SKIP_Oct6100ApiSetChannelLevelControl
12644 UINT32 Oct6100ApiSetChannelLevelControl(
12645 IN tPOCT6100_INSTANCE_API f_pApiInstance,
12646 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
12647 IN UINT16 f_usChanIndex,
12648 IN UINT16 f_usEchoMemIndex,
12649 IN BOOL f_fClearAlcHlcStatusBit )
12650 {
12651 tPOCT6100_API_CHANNEL pChanEntry;
12652 tPOCT6100_SHARED_INFO pSharedInfo;
12653 UINT32 ulResult;
12654 UINT32 ulTempData;
12655 UINT32 ulBaseAddress;
12656 UINT32 ulFeatureBytesOffset;
12657 UINT32 ulFeatureBitOffset;
12658 UINT32 ulFeatureFieldLength;
12659 UINT32 ulMask;
12660 UINT32 i;
12661 UINT16 usTempData;
12662 UINT8 byLastStatus;
12663 BOOL fDisableAlcFirst;
12664
12665 /* Get local pointer to shared portion of the API instance. */
12666 pSharedInfo = f_pApiInstance->pSharedInfo;
12667
12668 /* Obtain a pointer to the channel list entry. */
12669 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
12670
12671 /* Before doing anything, check if the configuration has changed. */
12672 if ( ( f_fClearAlcHlcStatusBit == TRUE )
12673 || ( f_pVqeConfig->fRinLevelControl != pChanEntry->VqeConfig.fRinLevelControl )
12674 || ( f_pVqeConfig->lRinLevelControlGainDb != pChanEntry->VqeConfig.chRinLevelControlGainDb )
12675 || ( f_pVqeConfig->fRinAutomaticLevelControl != pChanEntry->VqeConfig.fRinAutomaticLevelControl )
12676 || ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb != pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb )
12677 || ( f_pVqeConfig->fRinHighLevelCompensation != pChanEntry->VqeConfig.fRinHighLevelCompensation )
12678 || ( f_pVqeConfig->lRinHighLevelCompensationThresholdDb != pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb )
12679 || ( f_pVqeConfig->fSoutLevelControl != pChanEntry->VqeConfig.fSoutLevelControl )
12680 || ( f_pVqeConfig->lSoutLevelControlGainDb != pChanEntry->VqeConfig.chSoutLevelControlGainDb )
12681 || ( f_pVqeConfig->fSoutAutomaticLevelControl != pChanEntry->VqeConfig.fSoutAutomaticLevelControl )
12682 || ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb != pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb )
12683 || ( f_pVqeConfig->fSoutNaturalListenerEnhancement != pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement )
12684 || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb )
12685 || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb ) )
12686 {
12687 /* Calculate base address for manual level control configuration. */
12688 ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
12689
12690 /* Set the Level control on RIN port.*/
12691 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinLevelControlOfst.usDwordOffset * 4;
12692 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinLevelControlOfst.byBitOffset;
12693 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinLevelControlOfst.byFieldSize;
12694
12695 /* First read the DWORD where the field is located.*/
12696 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12697 pChanEntry,
12698 ulBaseAddress + ulFeatureBytesOffset,
12699 &ulTempData);
12700 if ( ulResult != cOCT6100_ERR_OK )
12701 return ulResult;
12702
12703 /* Clear previous value set in the feature field.*/
12704 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12705
12706 ulTempData &= (~ulMask);
12707
12708 if ( ( f_pVqeConfig->fRinLevelControl == TRUE )
12709 || ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
12710 || ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) )
12711 {
12712 /* Set the level control value.*/
12713 if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
12714 || ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) )
12715 ulTempData |= ( 0xFF << ulFeatureBitOffset );
12716 else
12717 {
12718 /* Convert the dB value into OctFloat format.*/
12719 usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lRinLevelControlGainDb );
12720 usTempData -= 0x3800;
12721 usTempData &= 0x0FF0;
12722 usTempData >>= 4;
12723
12724 ulTempData |= ( usTempData << ulFeatureBitOffset );
12725 }
12726 }
12727 else /* ( ( f_pVqeConfig->fRinLevelControl == FALSE ) && ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) && ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) ) */
12728 {
12729 ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
12730 }
12731
12732 /* Save the DWORD where the field is located.*/
12733 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12734 pChanEntry,
12735 ulBaseAddress + ulFeatureBytesOffset,
12736 ulTempData);
12737 if ( ulResult != cOCT6100_ERR_OK )
12738 return ulResult;
12739
12740 /* Set the Level control on SOUT port.*/
12741 ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutLevelControlOfst.usDwordOffset * 4;
12742 ulFeatureBitOffset = pSharedInfo->MemoryMap.SoutLevelControlOfst.byBitOffset;
12743 ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutLevelControlOfst.byFieldSize;
12744
12745 /* First read the DWORD where the field is located.*/
12746 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12747 pChanEntry,
12748 ulBaseAddress + ulFeatureBytesOffset,
12749 &ulTempData);
12750 if ( ulResult != cOCT6100_ERR_OK )
12751 return ulResult;
12752
12753 /* Clear previous value set in the feature field.*/
12754 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12755
12756 ulTempData &= (~ulMask);
12757
12758 if ( ( f_pVqeConfig->fSoutLevelControl == TRUE )
12759 || ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
12760 || ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
12761 || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0x0 ) )
12762 {
12763 /* Set the level control value.*/
12764 if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
12765 || ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
12766 || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0x0 ) )
12767 ulTempData |= ( 0xFF << ulFeatureBitOffset );
12768 else
12769 {
12770 /* Convert the dB value into OctFloat format.*/
12771 usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lSoutLevelControlGainDb );
12772 usTempData -= 0x3800;
12773 usTempData &= 0x0FF0;
12774 usTempData >>= 4;
12775
12776 ulTempData |= ( usTempData << ulFeatureBitOffset );
12777 }
12778 }
12779 else
12780 {
12781 ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
12782 }
12783
12784 /* Save the DWORD where the field is located.*/
12785 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12786 pChanEntry,
12787 ulBaseAddress + ulFeatureBytesOffset,
12788 ulTempData);
12789 if ( ulResult != cOCT6100_ERR_OK )
12790 return ulResult;
12791
12792 /* Calculate base address for auto level control + high level compensation configuration. */
12793 ulBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
12794
12795 /* Check which one is to be disabled first. */
12796 if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
12797 fDisableAlcFirst = FALSE;
12798 else
12799 fDisableAlcFirst = TRUE;
12800
12801 for ( i = 0; i < 2; i ++ )
12802 {
12803 /* Set the auto level control target Db for the Rin port. */
12804 if ( ( ( i == 0 ) && ( fDisableAlcFirst == TRUE ) ) || ( ( i == 1 ) && ( fDisableAlcFirst == FALSE ) ) )
12805 {
12806 if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE )
12807 {
12808 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.usDwordOffset * 4;
12809 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byBitOffset;
12810 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byFieldSize;
12811
12812 /* First read the DWORD where the field is located.*/
12813 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12814 pChanEntry,
12815 ulBaseAddress + ulFeatureBytesOffset,
12816 &ulTempData);
12817 if ( ulResult != cOCT6100_ERR_OK )
12818 return ulResult;
12819
12820 /* Clear previous value set in the feature field.*/
12821 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12822
12823 ulTempData &= (~ulMask);
12824
12825 if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
12826 {
12827 /* Convert the dB value into OctFloat format.*/
12828 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinAutomaticLevelControlTargetDb );
12829
12830 /* Set auto level control target on the Rin port. */
12831 ulTempData |= ( usTempData << ulFeatureBitOffset );
12832 }
12833 else /* if ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) */
12834 {
12835 /* Disable auto level control. */
12836 ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
12837 }
12838
12839 /* Save the DWORD where the field is located.*/
12840 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12841 pChanEntry,
12842 ulBaseAddress + ulFeatureBytesOffset,
12843 ulTempData);
12844 if ( ulResult != cOCT6100_ERR_OK )
12845 return ulResult;
12846 }
12847 }
12848 else
12849 {
12850 /* Set the high level compensation threshold Db for the Rin port. */
12851 if ( pSharedInfo->ImageInfo.fRinHighLevelCompensation == TRUE )
12852 {
12853 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.usDwordOffset * 4;
12854 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byBitOffset;
12855 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byFieldSize;
12856
12857 /* First read the DWORD where the field is located.*/
12858 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12859 pChanEntry,
12860 ulBaseAddress + ulFeatureBytesOffset,
12861 &ulTempData);
12862 if ( ulResult != cOCT6100_ERR_OK )
12863 return ulResult;
12864
12865 /* Clear previous value set in the feature field.*/
12866 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12867
12868 ulTempData &= (~ulMask);
12869
12870 if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
12871 {
12872 /* Convert the dB value into OctFloat format.*/
12873 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinHighLevelCompensationThresholdDb );
12874
12875 /* Set high level compensation threshold on the Rin port. */
12876 ulTempData |= ( usTempData << ulFeatureBitOffset );
12877 }
12878 else /* if ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) */
12879 {
12880 /* Disable high level compensation. */
12881 ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
12882 }
12883
12884 /* Save the DWORD where the field is located.*/
12885 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12886 pChanEntry,
12887 ulBaseAddress + ulFeatureBytesOffset,
12888 ulTempData);
12889 if ( ulResult != cOCT6100_ERR_OK )
12890 return ulResult;
12891 }
12892 }
12893 }
12894
12895 /* Set the auto level control target Db for the Sout port. */
12896 if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE )
12897 {
12898 ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.usDwordOffset * 4;
12899 ulFeatureBitOffset = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byBitOffset;
12900 ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byFieldSize;
12901
12902 /* First read the DWORD where the field is located.*/
12903 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12904 pChanEntry,
12905 ulBaseAddress + ulFeatureBytesOffset,
12906 &ulTempData);
12907 if ( ulResult != cOCT6100_ERR_OK )
12908 return ulResult;
12909
12910 /* Clear previous value set in the feature field.*/
12911 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12912
12913 ulTempData &= (~ulMask);
12914
12915 if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
12916 {
12917 /* Convert the dB value into OctFloat format.*/
12918 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lSoutAutomaticLevelControlTargetDb );
12919
12920 /* Set auto level control target on the Sout port. */
12921 ulTempData |= ( usTempData << ulFeatureBitOffset );
12922 }
12923 else /* if ( f_pVqeConfig->fSoutAutomaticLevelControl == FALSE ) */
12924 {
12925 /* Disable auto level control. */
12926 ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
12927 }
12928
12929 /* Save the DWORD where the field is located.*/
12930 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12931 pChanEntry,
12932 ulBaseAddress + ulFeatureBytesOffset,
12933 ulTempData);
12934 if ( ulResult != cOCT6100_ERR_OK )
12935 return ulResult;
12936 }
12937
12938 /* Set the high level compensation threshold Db for the Sout port. */
12939 if ( pSharedInfo->ImageInfo.fSoutHighLevelCompensation == TRUE )
12940 {
12941 ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.usDwordOffset * 4;
12942 ulFeatureBitOffset = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byBitOffset;
12943 ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byFieldSize;
12944
12945 /* First read the DWORD where the field is located.*/
12946 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12947 pChanEntry,
12948 ulBaseAddress + ulFeatureBytesOffset,
12949 &ulTempData);
12950 if ( ulResult != cOCT6100_ERR_OK )
12951 return ulResult;
12952
12953 /* Clear previous value set in the feature field.*/
12954 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12955
12956 ulTempData &= (~ulMask);
12957
12958 /* Disable high level compensation on Sout for now. */
12959 ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
12960
12961 /* Save the DWORD where the field is located.*/
12962 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12963 pChanEntry,
12964 ulBaseAddress + ulFeatureBytesOffset,
12965 ulTempData);
12966 if ( ulResult != cOCT6100_ERR_OK )
12967 return ulResult;
12968 }
12969
12970 /* Check if have to clear the ALC-HLC status. */
12971 if ( ( pSharedInfo->ImageInfo.fAlcHlcStatus == TRUE )
12972 && ( ( f_fClearAlcHlcStatusBit == TRUE )
12973
12974 ) )
12975 {
12976 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.usDwordOffset * 4;
12977 ulFeatureBitOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byBitOffset;
12978 ulFeatureFieldLength = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byFieldSize;
12979
12980 /* First read the DWORD where the field is located.*/
12981 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12982 pChanEntry,
12983 ulBaseAddress + ulFeatureBytesOffset,
12984 &ulTempData);
12985 if ( ulResult != cOCT6100_ERR_OK )
12986 return ulResult;
12987
12988 /* Get previous value set in the feature field.*/
12989 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12990
12991 /* Retrieve last status. */
12992 byLastStatus = (UINT8)( ( ( ulTempData & ulMask ) >> ulFeatureBitOffset ) & 0xFF );
12993
12994 /* Increment to reset context. */
12995 byLastStatus ++;
12996
12997 /* Just in case, not to overwrite some context in external memory. */
12998 byLastStatus &= ( 0x1 << ulFeatureFieldLength ) - 1;
12999
13000 /* Clear last status. */
13001 ulTempData &= (~ulMask);
13002
13003 /* Set new status. */
13004 ulTempData |= ( byLastStatus << ulFeatureBitOffset );
13005
13006 /* Save the DWORD where the field is located.*/
13007 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13008 pChanEntry,
13009 ulBaseAddress + ulFeatureBytesOffset,
13010 ulTempData);
13011 if ( ulResult != cOCT6100_ERR_OK )
13012 return ulResult;
13013 }
13014 }
13015
13016 return cOCT6100_ERR_OK;
13017 }
13018 #endif
13019
13020 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13021
13022 Function: Oct6100ApiSetChannelTailConfiguration
13023
13024 Description: This function will configure the tail displacement and length
13025 on a given channel.
13026
13027 -------------------------------------------------------------------------------
13028 | Argument | Description
13029 -------------------------------------------------------------------------------
13030 f_pApiInstance Pointer to API instance. This memory is used to keep
13031 the present state of the chip and all its resources.
13032
13033 f_pVqeConfig VQE config of the channel.
13034 f_usChanIndex Index of the channel within the API instance.
13035 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
13036 f_fModifyOnly Function called from a modify or open?
13037
13038 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13039 #if !SKIP_Oct6100ApiSetChannelTailConfiguration
13040 UINT32 Oct6100ApiSetChannelTailConfiguration(
13041 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13042 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
13043 IN UINT16 f_usChanIndex,
13044 IN UINT16 f_usEchoMemIndex,
13045 IN BOOL f_fModifyOnly )
13046 {
13047 tPOCT6100_API_CHANNEL pChanEntry;
13048 tPOCT6100_SHARED_INFO pSharedInfo;
13049 UINT32 ulResult;
13050 UINT32 ulTempData;
13051 UINT32 ulNlpConfBaseAddress;
13052 UINT32 ulAfConfBaseAddress;
13053 UINT32 ulFeatureBytesOffset;
13054 UINT32 ulFeatureBitOffset;
13055 UINT32 ulFeatureFieldLength;
13056 UINT32 ulMask;
13057 UINT32 ulTailSum;
13058 BOOL fTailDisplacementModified = FALSE;
13059
13060 /* Get local pointer to shared portion of the API instance. */
13061 pSharedInfo = f_pApiInstance->pSharedInfo;
13062
13063 /* Obtain a pointer to the channel list entry. */
13064 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
13065
13066 /* Calculate base addresses of NLP + AF configuration structure for the specified channel. */
13067 ulNlpConfBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
13068 ulAfConfBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
13069
13070 /* Set the tail displacement.*/
13071 if ( pSharedInfo->ImageInfo.fTailDisplacement == TRUE )
13072 {
13073 /* Check if the configuration has been changed. */
13074 if ( ( f_fModifyOnly == FALSE )
13075 || ( ( f_fModifyOnly == TRUE )
13076 && ( ( f_pVqeConfig->fEnableTailDisplacement != pChanEntry->VqeConfig.fEnableTailDisplacement )
13077 || ( f_pVqeConfig->ulTailDisplacement != pChanEntry->VqeConfig.usTailDisplacement )
13078 || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
13079 {
13080 /* Remember that the tail displacement parameters were changed. */
13081 fTailDisplacementModified = TRUE;
13082
13083 /* Check if we must set the tail displacement value. */
13084 if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
13085 && ( pSharedInfo->ImageInfo.fPerChannelTailDisplacement == TRUE ) )
13086 {
13087 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.usDwordOffset * 4;
13088 ulFeatureBitOffset = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byBitOffset;
13089 ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byFieldSize;
13090
13091 /* First read the DWORD where the field is located.*/
13092 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13093 pChanEntry,
13094 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13095 &ulTempData);
13096 if ( ulResult != cOCT6100_ERR_OK )
13097 return ulResult;
13098
13099 /* Clear previous value set in the feature field.*/
13100 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13101
13102 ulTempData &= (~ulMask);
13103 if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
13104 && ( f_pVqeConfig->ulTailDisplacement != 0x0 ) )
13105 {
13106 if ( pSharedInfo->ImageInfo.fAfTailDisplacement == FALSE )
13107 {
13108 if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13109 {
13110 ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13111 }
13112 else
13113 {
13114 ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13115 }
13116 }
13117 else /* if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE ) */
13118 {
13119 /* If AEC is not activated, this must be set to the requested tail displacement. */
13120 if ( f_pVqeConfig->fAcousticEcho == FALSE )
13121 {
13122 if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13123 {
13124 ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement;
13125 }
13126 else
13127 {
13128 ulTailSum = f_pVqeConfig->ulTailDisplacement;
13129 }
13130
13131 if ( ulTailSum == 0 )
13132 {
13133 ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13134 }
13135 else if ( ulTailSum <= 128 )
13136 {
13137 ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
13138 }
13139 else if ( ulTailSum <= 384 )
13140 {
13141 ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
13142 }
13143 else /* if ( ulTailSum <= 896 ) */
13144 {
13145 ulTempData |= ( ( 7 ) << ulFeatureBitOffset );
13146 }
13147 }
13148 else /* if ( f_pVqeConfig->fAcousticEcho == FALSE ) */
13149 {
13150 /* Otherwise, the tail displacement is configured differently. This field stays to 0. */
13151 ulTempData |= ( 0x0 << ulFeatureBitOffset );
13152 }
13153 }
13154 }
13155
13156 /* Then save the new DWORD where the field is located.*/
13157 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13158 pChanEntry,
13159 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13160 ulTempData);
13161 if ( ulResult != cOCT6100_ERR_OK )
13162 return ulResult;
13163 }
13164
13165 if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE )
13166 {
13167 /* Set the tail displacement offset in the AF. */
13168 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.usDwordOffset * 4;
13169 ulFeatureBitOffset = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.byBitOffset;
13170 ulFeatureFieldLength = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.byFieldSize;
13171
13172 /* First read the DWORD where the field is located.*/
13173 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13174 pChanEntry,
13175 ulAfConfBaseAddress + ulFeatureBytesOffset,
13176 &ulTempData);
13177 if ( ulResult != cOCT6100_ERR_OK )
13178 return ulResult;
13179
13180 /* Clear previous value set in the feature field.*/
13181 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13182
13183 ulTempData &= (~ulMask);
13184
13185 if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13186 {
13187 ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13188 }
13189 else
13190 {
13191 ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13192 }
13193
13194 /* Then save the DWORD where the field is located.*/
13195 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13196 pChanEntry,
13197 ulAfConfBaseAddress + ulFeatureBytesOffset,
13198 ulTempData);
13199 if ( ulResult != cOCT6100_ERR_OK )
13200 return ulResult;
13201 }
13202
13203 ulFeatureBytesOffset = pSharedInfo->MemoryMap.TailDisplEnableOfst.usDwordOffset * 4;
13204 ulFeatureBitOffset = pSharedInfo->MemoryMap.TailDisplEnableOfst.byBitOffset;
13205 ulFeatureFieldLength = pSharedInfo->MemoryMap.TailDisplEnableOfst.byFieldSize;
13206
13207 /* First read the DWORD where the field is located.*/
13208 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13209 pChanEntry,
13210 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13211 &ulTempData);
13212 if ( ulResult != cOCT6100_ERR_OK )
13213 return ulResult;
13214
13215 /* Clear previous value set in the feature field.*/
13216 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13217
13218 ulTempData &= (~ulMask);
13219 ulTempData |= ( ( (UINT32)f_pVqeConfig->fEnableTailDisplacement ) << ulFeatureBitOffset );
13220
13221 /* Then save the DWORD where the field is located.*/
13222 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13223 pChanEntry,
13224 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13225 ulTempData);
13226 if ( ulResult != cOCT6100_ERR_OK )
13227 return ulResult;
13228 }
13229 }
13230
13231 /* Set the tail length. */
13232 if ( pSharedInfo->ImageInfo.fPerChannelTailLength == TRUE )
13233 {
13234 /* Check if the configuration has been changed. */
13235 if ( ( f_fModifyOnly == FALSE )
13236 || ( ( f_fModifyOnly == TRUE )
13237 && ( f_pVqeConfig->ulTailLength != pChanEntry->VqeConfig.usTailLength ) ) )
13238 {
13239 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.usDwordOffset * 4;
13240 ulFeatureBitOffset = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byBitOffset;
13241 ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byFieldSize;
13242
13243 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13244 pChanEntry,
13245 ulAfConfBaseAddress + ulFeatureBytesOffset,
13246 &ulTempData);
13247 if ( ulResult != cOCT6100_ERR_OK )
13248 return ulResult;
13249
13250 /* Clear previous value set in the feature field.*/
13251 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13252
13253 ulTempData &= (~ulMask);
13254 /* Check if must automatically select maximum or if must use user specific value. */
13255 if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
13256 {
13257 ulTempData |= ( ( ( pSharedInfo->ImageInfo.usMaxTailLength - 32 ) / 4 ) << ulFeatureBitOffset );
13258 }
13259 else
13260 {
13261 ulTempData |= ( ( ( f_pVqeConfig->ulTailLength - 32 ) / 4 ) << ulFeatureBitOffset );
13262 }
13263
13264 /* Then save the DWORD where the field is located.*/
13265 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13266 pChanEntry,
13267 ulAfConfBaseAddress + ulFeatureBytesOffset,
13268 ulTempData);
13269 if ( ulResult != cOCT6100_ERR_OK )
13270 return ulResult;
13271 }
13272 }
13273
13274 /* Configure AEC tail length. */
13275 if ( pSharedInfo->ImageInfo.fAecTailLength == TRUE )
13276 {
13277 /* Check if the configuration has been changed. */
13278 if ( ( f_fModifyOnly == FALSE )
13279 || ( fTailDisplacementModified == TRUE )
13280 || ( ( f_fModifyOnly == TRUE )
13281 && ( ( f_pVqeConfig->ulAecTailLength != pChanEntry->VqeConfig.usAecTailLength )
13282 || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
13283 {
13284 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.usDwordOffset * 4;
13285 ulFeatureBitOffset = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byBitOffset;
13286 ulFeatureFieldLength = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byFieldSize;
13287
13288 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13289 pChanEntry,
13290 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13291 &ulTempData);
13292 if ( ulResult != cOCT6100_ERR_OK )
13293 return ulResult;
13294
13295 /* Clear previous value set in the feature field.*/
13296 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13297
13298 ulTempData &= (~ulMask);
13299
13300 /* Set acoustic echo tail length. */
13301 if ( f_pVqeConfig->fAcousticEcho == TRUE )
13302 {
13303 switch( f_pVqeConfig->ulAecTailLength )
13304 {
13305 case 1024:
13306 ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
13307 break;
13308 case 512:
13309 ulTempData |= ( ( 2 ) << ulFeatureBitOffset );
13310 break;
13311 case 256:
13312 ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
13313 break;
13314 case 128:
13315 default:
13316 ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13317 break;
13318 }
13319 }
13320 else if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
13321 {
13322 /* No acoustic echo case. */
13323
13324 /* Start with requested tail displacement. */
13325 if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13326 {
13327 ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement;
13328 }
13329 else
13330 {
13331 ulTailSum = f_pVqeConfig->ulTailDisplacement;
13332 }
13333
13334 /* Add requested tail length. */
13335 if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
13336 {
13337 ulTailSum += pSharedInfo->ImageInfo.usMaxTailLength;
13338 }
13339 else
13340 {
13341 ulTailSum += f_pVqeConfig->ulTailLength;
13342 }
13343
13344 /* Round this value up. */
13345 if ( ulTailSum <= 128 )
13346 {
13347 ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13348 }
13349 else if ( ulTailSum <= 256 )
13350 {
13351 ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
13352 }
13353 else if ( ulTailSum <= 512 )
13354 {
13355 ulTempData |= ( ( 2 ) << ulFeatureBitOffset );
13356 }
13357 else /* if ( ulTailSum <= 1024 ) */
13358 {
13359 ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
13360 }
13361 }
13362 else
13363 {
13364 /* Keep this to zero. */
13365 ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13366 }
13367
13368 /* Write the new DWORD where the field is located. */
13369 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13370 pChanEntry,
13371 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13372 ulTempData);
13373 if ( ulResult != cOCT6100_ERR_OK )
13374 return ulResult;
13375 }
13376 }
13377
13378 return cOCT6100_ERR_OK;
13379 }
13380 #endif
13381
13382 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13383
13384 Function: Oct6100ChannelMuteSer
13385
13386 Description: This function will mute some of the ports on a given
13387 channel.
13388
13389 -------------------------------------------------------------------------------
13390 | Argument | Description
13391 -------------------------------------------------------------------------------
13392 f_pApiInstance Pointer to API instance. This memory is used to keep
13393 the present state of the chip and all its resources.
13394
13395 f_pChannelMute What channel/ports to mute.
13396
13397 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13398 #if !SKIP_Oct6100ChannelMuteSer
13399 UINT32 Oct6100ChannelMuteSer(
13400 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13401 IN tPOCT6100_CHANNEL_MUTE f_pChannelMute )
13402 {
13403 UINT32 ulResult;
13404 UINT16 usChanIndex;
13405 UINT16 usPortMask;
13406
13407 /* Verify that all the parameters given match the state of the API. */
13408 ulResult = Oct6100ApiAssertChannelMuteParams( f_pApiInstance,
13409 f_pChannelMute,
13410 &usChanIndex,
13411 &usPortMask );
13412 if ( ulResult != cOCT6100_ERR_OK )
13413 return ulResult;
13414
13415 /* Call the actual channel mute ports function. */
13416 ulResult = Oct6100ApiMuteChannelPorts( f_pApiInstance,
13417 usChanIndex,
13418 usPortMask,
13419 TRUE );
13420 if ( ulResult != cOCT6100_ERR_OK )
13421 return ulResult;
13422
13423 return cOCT6100_ERR_OK;
13424 }
13425 #endif
13426
13427 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13428
13429 Function: Oct6100ApiAssertChannelMuteParams
13430
13431 Description: Check the user parameters passed to the channel mute function.
13432
13433 -------------------------------------------------------------------------------
13434 | Argument | Description
13435 -------------------------------------------------------------------------------
13436 f_pApiInstance Pointer to API instance. This memory is used to keep
13437 the present state of the chip and all its resources.
13438
13439 f_pChannelMute What channel/ports to mute.
13440 f_pusChanIndex Resulting channel index where the muting should
13441 be applied.
13442 f_pusPorts Port mask on which to apply the muting.
13443
13444 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13445 #if !SKIP_Oct6100ApiAssertChannelMuteParams
13446 UINT32 Oct6100ApiAssertChannelMuteParams(
13447 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13448 IN tPOCT6100_CHANNEL_MUTE f_pChannelMute,
13449 OUT PUINT16 f_pusChanIndex,
13450 OUT PUINT16 f_pusPorts )
13451 {
13452 tPOCT6100_SHARED_INFO pSharedInfo;
13453 tPOCT6100_API_CHANNEL pChanEntry;
13454 UINT32 ulEntryOpenCnt;
13455
13456 /* Get local pointer(s). */
13457 pSharedInfo = f_pApiInstance->pSharedInfo;
13458
13459 /* Check the provided handle. */
13460 if ( (f_pChannelMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
13461 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13462
13463 *f_pusChanIndex = (UINT16)( f_pChannelMute->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
13464 if ( *f_pusChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
13465 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13466
13467 /*=======================================================================*/
13468 /* Get a pointer to the channel's list entry. */
13469
13470 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex )
13471
13472 /* Extract the entry open count from the provided handle. */
13473 ulEntryOpenCnt = ( f_pChannelMute->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
13474
13475 /* Check for errors. */
13476 if ( pChanEntry->fReserved != TRUE )
13477 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
13478 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
13479 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13480 if ( pChanEntry->fBiDirChannel == TRUE )
13481 return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL;
13482
13483 /*=======================================================================*/
13484
13485 /* Check the provided port mask. */
13486
13487 if ( ( f_pChannelMute->ulPortMask &
13488 ~( cOCT6100_CHANNEL_MUTE_PORT_NONE |
13489 cOCT6100_CHANNEL_MUTE_PORT_RIN |
13490 cOCT6100_CHANNEL_MUTE_PORT_ROUT |
13491 cOCT6100_CHANNEL_MUTE_PORT_SIN |
13492 cOCT6100_CHANNEL_MUTE_PORT_SOUT |
13493 cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) ) != 0 )
13494 return cOCT6100_ERR_CHANNEL_MUTE_MASK;
13495
13496 /* Sin + Sin with features cannot be muted simultaneously. */
13497 if ( ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
13498 && ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) )
13499 return cOCT6100_ERR_CHANNEL_MUTE_MASK_SIN;
13500
13501 /* Check if Sin mute with features is supported by the firmware. */
13502 if ( ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
13503 && ( pSharedInfo->ImageInfo.fSinMute == FALSE ) )
13504 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_MUTE_FEATURES;
13505
13506 /* Return the ports to the calling function. */
13507 *f_pusPorts = (UINT16)( f_pChannelMute->ulPortMask & 0xFFFF );
13508
13509 return cOCT6100_ERR_OK;
13510 }
13511 #endif
13512
13513 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13514
13515 Function: Oct6100ChannelUnMuteSer
13516
13517 Description: This function will unmute some of the ports on a given
13518 channel.
13519
13520 -------------------------------------------------------------------------------
13521 | Argument | Description
13522 -------------------------------------------------------------------------------
13523 f_pApiInstance Pointer to API instance. This memory is used to keep
13524 the present state of the chip and all its resources.
13525
13526 f_pChannelUnMute What channel/ports to unmute.
13527
13528 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13529 #if !SKIP_Oct6100ChannelUnMuteSer
13530 UINT32 Oct6100ChannelUnMuteSer(
13531 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13532 IN tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute )
13533 {
13534 UINT32 ulResult;
13535 UINT16 usChanIndex;
13536 UINT16 usPortMask;
13537
13538 /* Verify that all the parameters given match the state of the API. */
13539 ulResult = Oct6100ApiAssertChannelUnMuteParams( f_pApiInstance,
13540 f_pChannelUnMute,
13541 &usChanIndex,
13542 &usPortMask );
13543 if ( ulResult != cOCT6100_ERR_OK )
13544 return ulResult;
13545
13546 /* Call the actual channel mute ports function. */
13547 ulResult = Oct6100ApiMuteChannelPorts( f_pApiInstance,
13548 usChanIndex,
13549 usPortMask,
13550 FALSE );
13551 if ( ulResult != cOCT6100_ERR_OK )
13552 return ulResult;
13553
13554 return cOCT6100_ERR_OK;
13555 }
13556 #endif
13557
13558 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13559
13560 Function: Oct6100ApiAssertChannelUnMuteParams
13561
13562 Description: Check the user parameters passed to the channel unmute function.
13563
13564 -------------------------------------------------------------------------------
13565 | Argument | Description
13566 -------------------------------------------------------------------------------
13567 f_pApiInstance Pointer to API instance. This memory is used to keep
13568 the present state of the chip and all its resources.
13569
13570 f_pChannelUnMute What channel/ports to Unmute.
13571 f_pusChanIndex Resulting channel index where the muting should
13572 be applied.
13573 f_pusPorts Port mask on which to apply the muting.
13574
13575 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13576 #if !SKIP_Oct6100ApiAssertChannelUnMuteParams
13577 UINT32 Oct6100ApiAssertChannelUnMuteParams(
13578 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13579 IN tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute,
13580 OUT PUINT16 f_pusChanIndex,
13581 OUT PUINT16 f_pusPorts )
13582 {
13583 tPOCT6100_SHARED_INFO pSharedInfo;
13584 tPOCT6100_API_CHANNEL pChanEntry;
13585 UINT32 ulEntryOpenCnt;
13586
13587 /* Get local pointer(s). */
13588 pSharedInfo = f_pApiInstance->pSharedInfo;
13589
13590 /* Check the provided handle. */
13591 if ( (f_pChannelUnMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
13592 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13593
13594 *f_pusChanIndex = (UINT16)( f_pChannelUnMute->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
13595 if ( *f_pusChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
13596 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13597
13598 /*=======================================================================*/
13599 /* Get a pointer to the channel's list entry. */
13600
13601 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex )
13602
13603 /* Extract the entry open count from the provided handle. */
13604 ulEntryOpenCnt = ( f_pChannelUnMute->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
13605
13606 /* Check for errors. */
13607 if ( pChanEntry->fReserved != TRUE )
13608 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
13609 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
13610 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13611 if ( pChanEntry->fBiDirChannel == TRUE )
13612 return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL;
13613
13614 /*=======================================================================*/
13615
13616 /* Check the provided port mask. */
13617
13618 if ( ( f_pChannelUnMute->ulPortMask &
13619 ~( cOCT6100_CHANNEL_MUTE_PORT_NONE |
13620 cOCT6100_CHANNEL_MUTE_PORT_RIN |
13621 cOCT6100_CHANNEL_MUTE_PORT_ROUT |
13622 cOCT6100_CHANNEL_MUTE_PORT_SIN |
13623 cOCT6100_CHANNEL_MUTE_PORT_SOUT |
13624 cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) ) != 0 )
13625 return cOCT6100_ERR_CHANNEL_MUTE_MASK;
13626
13627 /* Return the ports to the calling function. */
13628 *f_pusPorts = (UINT16)( f_pChannelUnMute->ulPortMask & 0xFFFF );
13629
13630 return cOCT6100_ERR_OK;
13631 }
13632 #endif
13633
13634
13635 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13636
13637 Function: Oct6100ApiMuteSinWithFeatures
13638
13639 Description: Mute or Unmute the sin with features port.
13640
13641 -------------------------------------------------------------------------------
13642 | Argument | Description
13643 -------------------------------------------------------------------------------
13644 f_pApiInstance Pointer to API instance. This memory is used to keep
13645 the present state of the chip and all its resources.
13646
13647 f_usChanIndex Resulting channel index where the muting should
13648 be applied.
13649 f_fEnableSinWithFeatures Whether to enable the feature or not.
13650
13651 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13652 #if !SKIP_Oct6100ApiMuteSinWithFeatures
13653 UINT32 Oct6100ApiMuteSinWithFeatures(
13654 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13655 IN UINT16 f_usChanIndex,
13656 IN BOOL f_fEnableSinWithFeatures )
13657 {
13658 tPOCT6100_SHARED_INFO pSharedInfo;
13659 tPOCT6100_API_CHANNEL pChanEntry;
13660 tOCT6100_WRITE_PARAMS WriteParams;
13661 UINT32 ulResult;
13662
13663 UINT32 ulTempData;
13664 UINT32 ulBaseAddress;
13665 UINT32 ulFeatureBytesOffset;
13666 UINT32 ulFeatureBitOffset;
13667 UINT32 ulFeatureFieldLength;
13668 UINT32 ulMask;
13669
13670 /* Get local pointer(s). */
13671 pSharedInfo = f_pApiInstance->pSharedInfo;
13672
13673 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13674
13675 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
13676
13677 /* Get a pointer to the channel's list entry. */
13678 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
13679
13680 ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
13681
13682 if ( pSharedInfo->ImageInfo.fSinMute == TRUE )
13683 {
13684 ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinMuteOfst.usDwordOffset * 4;
13685 ulFeatureBitOffset = pSharedInfo->MemoryMap.SinMuteOfst.byBitOffset;
13686 ulFeatureFieldLength = pSharedInfo->MemoryMap.SinMuteOfst.byFieldSize;
13687
13688 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13689 pChanEntry,
13690 ulBaseAddress + ulFeatureBytesOffset,
13691 &ulTempData);
13692 if ( ulResult != cOCT6100_ERR_OK )
13693 return ulResult;
13694
13695 /* Clear previous value set in the feature field.*/
13696 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13697
13698 /* Clear the mute flag. */
13699 ulTempData &= (~ulMask);
13700
13701 /* Set the mute flag on the Sin port.*/
13702 if ( f_fEnableSinWithFeatures == TRUE )
13703 ulTempData |= ( 0x1 << ulFeatureBitOffset );
13704
13705 /* Write the new DWORD where the field is located. */
13706 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13707 pChanEntry,
13708 ulBaseAddress + ulFeatureBytesOffset,
13709 ulTempData);
13710 if ( ulResult != cOCT6100_ERR_OK )
13711 return ulResult;
13712 }
13713
13714 return cOCT6100_ERR_OK;
13715 }
13716 #endif
13717
13718
13719 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13720
13721 Function: Oct6100ApiMuteChannelPorts
13722
13723 Description: Mute or Unmute the specified ports, according to the mask.
13724
13725 -------------------------------------------------------------------------------
13726 | Argument | Description
13727 -------------------------------------------------------------------------------
13728 f_pApiInstance Pointer to API instance. This memory is used to keep
13729 the present state of the chip and all its resources.
13730
13731 f_usChanIndex Resulting channel index where the muting should
13732 be applied.
13733 f_usPortMask Port mask on which to apply the muting/unmuting.
13734
13735 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13736 #if !SKIP_Oct6100ApiMuteChannelPorts
13737 UINT32 Oct6100ApiMuteChannelPorts(
13738 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13739 IN UINT16 f_usChanIndex,
13740 IN UINT16 f_usPortMask,
13741 IN BOOL f_fMute )
13742 {
13743 tPOCT6100_SHARED_INFO pSharedInfo;
13744 tPOCT6100_API_CHANNEL pChanEntry;
13745 tOCT6100_WRITE_PARAMS WriteParams;
13746 UINT32 ulResult;
13747 BOOL fDisableSinWithFeatures = FALSE;
13748 BOOL fEnableSinWithFeatures = FALSE;
13749
13750 /* Get local pointer(s). */
13751 pSharedInfo = f_pApiInstance->pSharedInfo;
13752
13753 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13754
13755 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
13756
13757 /* Get a pointer to the channel's list entry. */
13758 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
13759
13760 /* Rin port. */
13761 if ( ( f_fMute == TRUE )
13762 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 )
13763 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) == 0x0 ) )
13764 {
13765 /* Mute this port. */
13766 pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_RIN;
13767
13768 ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13769 if ( ulResult != cOCT6100_ERR_OK )
13770 {
13771 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN;
13772 return ulResult;
13773 }
13774 }
13775 else if ( ( f_fMute == FALSE )
13776 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 )
13777 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) )
13778 {
13779 /* Unmute this port. */
13780 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN;
13781
13782 ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13783 if ( ulResult != cOCT6100_ERR_OK )
13784 return ulResult;
13785 }
13786
13787 /* Rout port. */
13788 if ( ( f_fMute == TRUE )
13789 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 )
13790 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 ) )
13791 {
13792 /* Mute this port. */
13793
13794 if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
13795 {
13796 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
13797 pChanEntry->usRoutTsstIndex,
13798 pChanEntry->CodecConfig.byAdpcmNibblePosition,
13799 pChanEntry->TdmConfig.byRoutNumTssts,
13800 1534 );
13801 if ( ulResult != cOCT6100_ERR_OK )
13802 return ulResult;
13803 }
13804
13805 pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_ROUT;
13806 }
13807 else if ( ( f_fMute == FALSE )
13808 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 )
13809 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 ) )
13810 {
13811 /* Unmute this port. */
13812
13813 if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
13814 {
13815 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
13816 pChanEntry->usRoutTsstIndex,
13817 pChanEntry->CodecConfig.byAdpcmNibblePosition,
13818 pChanEntry->TdmConfig.byRoutNumTssts,
13819 pChanEntry->usRinRoutTsiMemIndex );
13820 if ( ulResult != cOCT6100_ERR_OK )
13821 return ulResult;
13822 }
13823
13824 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_ROUT;
13825 }
13826
13827 /* Sin port. */
13828 if ( ( f_fMute == TRUE )
13829 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
13830 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) == 0x0 ) )
13831 {
13832 /* Mute this port. */
13833 pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN;
13834
13835 ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13836 if ( ulResult != cOCT6100_ERR_OK )
13837 {
13838 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN;
13839 return ulResult;
13840 }
13841 }
13842 else if (
13843 ( ( f_fMute == FALSE )
13844 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
13845 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) )
13846 ||
13847 ( ( f_fMute == TRUE )
13848 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
13849 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) )
13850 {
13851 /* Unmute this port. */
13852 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN;
13853
13854 ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13855 if ( ulResult != cOCT6100_ERR_OK )
13856 return ulResult;
13857 }
13858
13859 /* Sout port. */
13860 if ( ( f_fMute == TRUE )
13861 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 )
13862 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 ) )
13863 {
13864 /* Mute this port. */
13865
13866 if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
13867 {
13868 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
13869 pChanEntry->usSoutTsstIndex,
13870 pChanEntry->CodecConfig.byAdpcmNibblePosition,
13871 pChanEntry->TdmConfig.bySoutNumTssts,
13872 1534 );
13873 if ( ulResult != cOCT6100_ERR_OK )
13874 return ulResult;
13875 }
13876
13877 pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SOUT;
13878 }
13879 else if ( ( f_fMute == FALSE )
13880 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 )
13881 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 ) )
13882 {
13883 /* Unmute this port. */
13884
13885 if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
13886 {
13887 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
13888 pChanEntry->usSoutTsstIndex,
13889 pChanEntry->CodecConfig.byAdpcmNibblePosition,
13890 pChanEntry->TdmConfig.bySoutNumTssts,
13891 pChanEntry->usSinSoutTsiMemIndex );
13892 if ( ulResult != cOCT6100_ERR_OK )
13893 return ulResult;
13894 }
13895
13896 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SOUT;
13897 }
13898
13899 /* Sin with features port. */
13900 if ( ( f_fMute == TRUE )
13901 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
13902 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) == 0x0 ) )
13903 {
13904 /* Mute this port. */
13905 pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES;
13906 fEnableSinWithFeatures = TRUE;
13907 }
13908 else if (
13909 ( ( f_fMute == FALSE )
13910 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
13911 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) )
13912 ||
13913 ( ( f_fMute == TRUE )
13914 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
13915 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) ) )
13916 {
13917 /* Unmute this port. */
13918 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES;
13919
13920 fDisableSinWithFeatures = TRUE;
13921 }
13922
13923 /* Check if must enable or disable SIN mute with features. */
13924 if ( fDisableSinWithFeatures == TRUE || fEnableSinWithFeatures == TRUE )
13925 {
13926 ulResult = Oct6100ApiMuteSinWithFeatures( f_pApiInstance, f_usChanIndex, fEnableSinWithFeatures );
13927 if ( ulResult != cOCT6100_ERR_OK )
13928 return ulResult;
13929 }
13930
13931 return cOCT6100_ERR_OK;
13932 }
13933 #endif