Debian Codegraph @

xpp/oct612x/octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c

raw
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_CHANNEL_OPEN_TDM pTdmConfig;
1504 tPOCT6100_CHANNEL_OPEN_CODEC pCodecConfig;
1505
1506 UINT32 ulResult;
1507 UINT32 ulTempVar;
1508 UINT32 ulFreeMixerEventCnt;
1509
1510 BOOL fRinTsstEntry = FALSE;
1511 BOOL fSinTsstEntry = FALSE;
1512 BOOL fRoutTsstEntry = FALSE;
1513 BOOL fSoutTsstEntry = FALSE;
1514
1515 BOOL fRinRoutTsiMemEntry = FALSE;
1516 BOOL fSinSoutTsiMemEntry = FALSE;
1517
1518 BOOL fEchoChanEntry = FALSE;
1519
1520 PUINT16 pusRinRoutConversionMemIndex = NULL;
1521 PUINT16 pusSinSoutConversionMemIndex = NULL;
1522 BOOL fRinRoutConversionMemEntry = FALSE;
1523 BOOL fSinSoutConversionMemEntry = FALSE;
1524
1525 BOOL fExtToneChanEntry = FALSE;
1526 BOOL fExtToneTsiEntry = FALSE;
1527 BOOL fExtToneMixerEntry = FALSE;
1528
1529 /* Obtain a local pointer to the configuration structures.*/
1530 pTdmConfig = &f_pChannelOpen->TdmConfig;
1531 pCodecConfig = &f_pChannelOpen->CodecConfig;
1532
1533 /*===============================================================================*/
1534 /* Reserve Echo and TSI entries. */
1535
1536 ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance,
1537 &f_pChanIndexConf->usEchoChanIndex );
1538 if ( ulResult == cOCT6100_ERR_OK )
1539 {
1540 fEchoChanEntry = TRUE;
1541
1542 /* Set the echo, encoder and decoder memory indexes.*/
1543 f_pChanIndexConf->usEchoMemIndex = f_pChanIndexConf->usEchoChanIndex;
1544
1545 /* Reserve an entry for the RIN/ROUT tsi chariot memory. */
1546 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
1547 &f_pChanIndexConf->usRinRoutTsiMemIndex );
1548 if ( ulResult == cOCT6100_ERR_OK )
1549 {
1550 fRinRoutTsiMemEntry = TRUE;
1551
1552 /* Reserve an entry for the SIN/SOUT tsi chariot memory. */
1553 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
1554 &f_pChanIndexConf->usSinSoutTsiMemIndex );
1555 if ( ulResult == cOCT6100_ERR_OK )
1556 {
1557 fSinSoutTsiMemEntry = TRUE;
1558
1559 /* Reserve an ADPCM memory block for compression if required.*/
1560 if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
1561 {
1562 pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex;
1563 }
1564 else if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT )
1565 {
1566 pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex;
1567 }
1568
1569 /* Reserve an ADPCM memory block for decompression if required.*/
1570 if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1571 {
1572 pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex;
1573 }
1574 else if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN )
1575 {
1576 pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex;
1577 }
1578
1579
1580 /* Reserve the conversion memories. */
1581 if ( pusRinRoutConversionMemIndex != NULL )
1582 {
1583 /* Reserve a conversion memory for the Rin/Rout stream. */
1584 ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance,
1585 pusRinRoutConversionMemIndex );
1586 if ( ulResult == cOCT6100_ERR_OK )
1587 {
1588 fRinRoutConversionMemEntry = TRUE;
1589 }
1590 }
1591 else
1592 {
1593 /* No conversion memory reserved.*/
1594 f_pChanIndexConf->usRinRoutConversionMemIndex = cOCT6100_INVALID_INDEX;
1595 }
1596
1597 if ( ( pusSinSoutConversionMemIndex != NULL ) &&
1598 ( ulResult == cOCT6100_ERR_OK ) )
1599 {
1600 /* Reserve a conversion memory for the Sin/Sout stream. */
1601 ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance,
1602 pusSinSoutConversionMemIndex );
1603 if ( ulResult == cOCT6100_ERR_OK )
1604 {
1605 fSinSoutConversionMemEntry = TRUE;
1606 }
1607 }
1608 else
1609 {
1610 /* No conversion memory reserved.*/
1611 f_pChanIndexConf->usSinSoutConversionMemIndex = cOCT6100_INVALID_INDEX;
1612 }
1613
1614 /* Reserve any resources required if the extended Tone detection is enabled.*/
1615 if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
1616 {
1617 ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance,
1618 &f_pChanIndexConf->usExtToneChanIndex );
1619 if ( ulResult == cOCT6100_ERR_OK )
1620 {
1621 fExtToneChanEntry = TRUE;
1622
1623 /* Reserve an entry for the TSI chariot memory for the additionnal channel. */
1624 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
1625 &f_pChanIndexConf->usExtToneTsiIndex );
1626 if ( ulResult == cOCT6100_ERR_OK )
1627 {
1628 fExtToneTsiEntry = TRUE;
1629
1630 /* Reserve an entry for the TSI chariot memory for the additionnal channel. */
1631 ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance,
1632 &f_pChanIndexConf->usExtToneMixerIndex );
1633 if ( ulResult == cOCT6100_ERR_OK )
1634 fExtToneMixerEntry = TRUE;
1635 }
1636 }
1637 }
1638 else
1639 {
1640 f_pChanIndexConf->usExtToneChanIndex = cOCT6100_INVALID_INDEX;
1641 f_pChanIndexConf->usExtToneMixerIndex = cOCT6100_INVALID_INDEX;
1642 f_pChanIndexConf->usExtToneTsiIndex = cOCT6100_INVALID_INDEX;
1643 }
1644 }
1645 else
1646 {
1647 /* Return an error other then a Fatal.*/
1648 ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY;
1649 }
1650 }
1651 else
1652 {
1653 /* Return an error other then a Fatal.*/
1654 ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY;
1655 }
1656 }
1657
1658 /*===============================================================================*/
1659
1660 /*===============================================================================*/
1661 /* Now reserve the TSST entries if required.*/
1662
1663 /* Reserve the Rin TSST entry */
1664 if ( (ulResult == cOCT6100_ERR_OK ) &&
1665 (pTdmConfig->ulRinTimeslot != cOCT6100_UNASSIGNED &&
1666 pTdmConfig->ulRinStream != cOCT6100_UNASSIGNED) )
1667 {
1668 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
1669 pTdmConfig->ulRinTimeslot,
1670 pTdmConfig->ulRinStream,
1671 pTdmConfig->ulRinNumTssts,
1672 cOCT6100_INPUT_TSST,
1673 &f_pChanIndexConf->usRinTsstIndex,
1674 NULL );
1675 if ( ulResult == cOCT6100_ERR_OK )
1676 fRinTsstEntry = TRUE;
1677 }
1678 else
1679 {
1680 f_pChanIndexConf->usRinTsstIndex = cOCT6100_INVALID_INDEX;
1681 }
1682
1683
1684 if ( (ulResult == cOCT6100_ERR_OK ) &&
1685 (pTdmConfig->ulSinTimeslot != cOCT6100_UNASSIGNED &&
1686 pTdmConfig->ulSinStream != cOCT6100_UNASSIGNED) )
1687 {
1688 /* Reserve the Sin TSST entry.*/
1689 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
1690 pTdmConfig->ulSinTimeslot,
1691 pTdmConfig->ulSinStream,
1692 pTdmConfig->ulSinNumTssts,
1693 cOCT6100_INPUT_TSST,
1694 &f_pChanIndexConf->usSinTsstIndex,
1695 NULL );
1696 if ( ulResult == cOCT6100_ERR_OK )
1697 fSinTsstEntry = TRUE;
1698 }
1699 else
1700 {
1701 f_pChanIndexConf->usSinTsstIndex = cOCT6100_INVALID_INDEX;
1702 }
1703
1704 if ( (ulResult == cOCT6100_ERR_OK ) &&
1705 (pTdmConfig->ulRoutTimeslot != cOCT6100_UNASSIGNED &&
1706 pTdmConfig->ulRoutStream != cOCT6100_UNASSIGNED) )
1707 {
1708 /* Reserve the Rout TSST entry.*/
1709 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
1710 pTdmConfig->ulRoutTimeslot,
1711 pTdmConfig->ulRoutStream,
1712 pTdmConfig->ulRoutNumTssts,
1713 cOCT6100_OUTPUT_TSST,
1714 &f_pChanIndexConf->usRoutTsstIndex,
1715 NULL );
1716 if ( ulResult == cOCT6100_ERR_OK )
1717 fRoutTsstEntry = TRUE;
1718 }
1719 else
1720 {
1721 f_pChanIndexConf->usRoutTsstIndex = cOCT6100_INVALID_INDEX;
1722 }
1723
1724
1725 if ( (ulResult == cOCT6100_ERR_OK ) &&
1726 (pTdmConfig->ulSoutTimeslot != cOCT6100_UNASSIGNED &&
1727 pTdmConfig->ulSoutStream != cOCT6100_UNASSIGNED) )
1728 {
1729 /* Reserve the Sout TSST entry.*/
1730 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
1731 pTdmConfig->ulSoutTimeslot,
1732 pTdmConfig->ulSoutStream,
1733 pTdmConfig->ulSoutNumTssts,
1734 cOCT6100_OUTPUT_TSST,
1735 &f_pChanIndexConf->usSoutTsstIndex,
1736 NULL );
1737 if ( ulResult == cOCT6100_ERR_OK )
1738 fSoutTsstEntry = TRUE;
1739 }
1740 else
1741 {
1742 f_pChanIndexConf->usSoutTsstIndex = cOCT6100_INVALID_INDEX;
1743 }
1744
1745 /*===============================================================================*/
1746
1747
1748 /*===============================================================================*/
1749 /* Check if there are a couple of mixer events available for us. */
1750
1751 if ( ulResult == cOCT6100_ERR_OK )
1752 {
1753 UINT32 ulMixerEventCntNeeded = 0;
1754
1755 /* Calculate how many mixer events are needed. */
1756 if ( f_pChanIndexConf->usRinTsstIndex == cOCT6100_INVALID_INDEX )
1757 ulMixerEventCntNeeded++;
1758
1759 if ( f_pChanIndexConf->usSinTsstIndex == cOCT6100_INVALID_INDEX )
1760 ulMixerEventCntNeeded++;
1761
1762 /* If at least 1 mixer event is needed, check if those are available. */
1763 if ( ulMixerEventCntNeeded != 0 )
1764 {
1765 ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt );
1766 if ( ulResult == cOCT6100_ERR_OK )
1767 {
1768 /* The API might need more mixer events if the ports have to be muted. */
1769 /* Check if these are available. */
1770 if ( ulFreeMixerEventCnt < ulMixerEventCntNeeded )
1771 {
1772 ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS;
1773 }
1774 }
1775 }
1776 }
1777
1778 /*===============================================================================*/
1779
1780
1781 /*===============================================================================*/
1782 /* Release the resources if something went wrong */
1783 if ( ulResult != cOCT6100_ERR_OK )
1784 {
1785 /*===============================================================================*/
1786 /* Release the previously reserved resources .*/
1787 if( fRinTsstEntry == TRUE )
1788 {
1789 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
1790 pTdmConfig->ulRinTimeslot,
1791 pTdmConfig->ulRinStream,
1792 pTdmConfig->ulRinNumTssts,
1793 cOCT6100_INPUT_TSST,
1794 cOCT6100_INVALID_INDEX );
1795 if ( ulTempVar != cOCT6100_ERR_OK )
1796 return ulTempVar;
1797 }
1798
1799 if( fSinTsstEntry == TRUE )
1800 {
1801 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
1802 pTdmConfig->ulSinTimeslot,
1803 pTdmConfig->ulSinStream,
1804 pTdmConfig->ulSinNumTssts,
1805 cOCT6100_INPUT_TSST,
1806 cOCT6100_INVALID_INDEX );
1807 if ( ulTempVar != cOCT6100_ERR_OK )
1808 return ulTempVar;
1809 }
1810
1811 if( fRoutTsstEntry == TRUE )
1812 {
1813 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
1814 pTdmConfig->ulRoutTimeslot,
1815 pTdmConfig->ulRoutStream,
1816 pTdmConfig->ulRoutNumTssts,
1817 cOCT6100_OUTPUT_TSST,
1818 cOCT6100_INVALID_INDEX );
1819 if ( ulTempVar != cOCT6100_ERR_OK )
1820 return ulTempVar;
1821 }
1822
1823 if( fSoutTsstEntry == TRUE )
1824 {
1825 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
1826 pTdmConfig->ulSoutTimeslot,
1827 pTdmConfig->ulSoutStream,
1828 pTdmConfig->ulSoutNumTssts,
1829 cOCT6100_OUTPUT_TSST,
1830 cOCT6100_INVALID_INDEX );
1831 if ( ulTempVar != cOCT6100_ERR_OK )
1832 return ulTempVar;
1833 }
1834
1835 if( fRinRoutTsiMemEntry == TRUE )
1836 {
1837 ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
1838 f_pChanIndexConf->usRinRoutTsiMemIndex );
1839 if ( ulTempVar != cOCT6100_ERR_OK )
1840 return ulTempVar;
1841 }
1842
1843 if( fSinSoutTsiMemEntry == TRUE )
1844 {
1845 ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
1846 f_pChanIndexConf->usSinSoutTsiMemIndex );
1847 if ( ulTempVar != cOCT6100_ERR_OK )
1848 return ulTempVar;
1849 }
1850
1851 /*===============================================================================*/
1852
1853 /*===============================================================================*/
1854 /* Release the previously reserved echo resources .*/
1855 if( fEchoChanEntry == TRUE )
1856 {
1857 ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance,
1858 f_pChanIndexConf->usEchoChanIndex );
1859 if ( ulTempVar != cOCT6100_ERR_OK )
1860 return ulTempVar;
1861 }
1862
1863 /*===============================================================================*/
1864
1865 /*===============================================================================*/
1866 /* Release the previously reserved resources for the extended tone detection.*/
1867 if( fExtToneChanEntry == TRUE )
1868 {
1869 ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance,
1870 f_pChanIndexConf->usExtToneChanIndex );
1871 if ( ulTempVar != cOCT6100_ERR_OK )
1872 return ulTempVar;
1873 }
1874
1875 if( fExtToneTsiEntry == TRUE )
1876 {
1877 ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
1878 f_pChanIndexConf->usExtToneTsiIndex );
1879 if ( ulTempVar != cOCT6100_ERR_OK )
1880 return ulTempVar;
1881 }
1882
1883 if( fExtToneMixerEntry == TRUE )
1884 {
1885 ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
1886 f_pChanIndexConf->usExtToneMixerIndex );
1887 if ( ulTempVar != cOCT6100_ERR_OK )
1888 return ulTempVar;
1889 }
1890 /*===============================================================================*/
1891
1892 /*===============================================================================*/
1893 /* Release the conversion resources. */
1894 if( fRinRoutConversionMemEntry == TRUE )
1895 {
1896 ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
1897 f_pChanIndexConf->usRinRoutConversionMemIndex );
1898 if ( ulTempVar != cOCT6100_ERR_OK )
1899 return ulTempVar;
1900 }
1901
1902 if( fSinSoutConversionMemEntry == TRUE )
1903 {
1904 ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
1905 f_pChanIndexConf->usSinSoutConversionMemIndex );
1906 if ( ulTempVar != cOCT6100_ERR_OK )
1907 return ulTempVar;
1908 }
1909
1910 /*===============================================================================*/
1911
1912 return ulResult;
1913 }
1914
1915 return cOCT6100_ERR_OK;
1916 }
1917 #endif
1918
1919
1920 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1921
1922 Function: Oct6100ApiWriteChannelStructs
1923
1924 Description: Performs all the required structure writes to configure the
1925 new echo cancellation channel.
1926
1927 -------------------------------------------------------------------------------
1928 | Argument | Description
1929 -------------------------------------------------------------------------------
1930 f_pApiInstance Pointer to API instance. This memory is used to keep the
1931 present state of the chip and all its resources.
1932
1933 f_pChannelOpen Pointer to echo cancellation channel configuration structure.
1934 f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes.
1935
1936 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1937 #if !SKIP_Oct6100ApiWriteChannelStructs
1938 UINT32 Oct6100ApiWriteChannelStructs(
1939 IN tPOCT6100_INSTANCE_API f_pApiInstance,
1940 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
1941 OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf )
1942 {
1943 tPOCT6100_SHARED_INFO pSharedInfo;
1944 tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig;
1945 tOCT6100_WRITE_PARAMS WriteParams;
1946 tPOCT6100_API_CHANNEL pChanEntry;
1947 UINT32 ulResult;
1948 UINT32 ulDwordAddress;
1949 UINT32 ulDwordData;
1950 BOOL fProgramAdpcmMem;
1951 UINT32 ulCompType = 0;
1952 UINT32 ulPcmLaw;
1953 UINT16 usTempTsiMemIndex;
1954 UINT16 usConversionMemIndex;
1955 UINT32 ulToneEventNumber;
1956 BOOL fSSTone;
1957
1958 /* Obtain local pointer to shared portion of instance. */
1959 pSharedInfo = f_pApiInstance->pSharedInfo;
1960
1961 /* Obtain a local pointer to the TDM configuration structure.*/
1962 pTdmConfig = &f_pChannelOpen->TdmConfig;
1963
1964 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1965
1966 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1967
1968 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex );
1969
1970 /*==============================================================================*/
1971 /* Configure the Input Tsst control memory.*/
1972
1973 /* Set the RIN Tsst control entry.*/
1974 if ( f_pChanIndexConf->usRinTsstIndex != cOCT6100_INVALID_INDEX )
1975 {
1976 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
1977 f_pChanIndexConf->usRinTsstIndex,
1978 f_pChanIndexConf->usRinRoutTsiMemIndex,
1979 pTdmConfig->ulRinPcmLaw );
1980 if ( ulResult != cOCT6100_ERR_OK )
1981 return ulResult;
1982 }
1983
1984 /* Set the SIN Tsst control entry.*/
1985 if ( f_pChanIndexConf->usSinTsstIndex != cOCT6100_INVALID_INDEX )
1986 {
1987 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
1988 f_pChanIndexConf->usSinTsstIndex,
1989 f_pChanIndexConf->usSinSoutTsiMemIndex,
1990 pTdmConfig->ulSinPcmLaw );
1991 if ( ulResult != cOCT6100_ERR_OK )
1992 return ulResult;
1993 }
1994
1995 /*==============================================================================*/
1996
1997 /*==============================================================================*/
1998 /* Configure the ADPCM control memory for the Decoder.*/
1999
2000 /* Set the codec state flags.*/
2001 f_pChanIndexConf->fRinRoutCodecActive = FALSE;
2002 f_pChanIndexConf->fSinSoutCodecActive = FALSE;
2003
2004 if ( f_pChannelOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING )
2005 {
2006 fProgramAdpcmMem = TRUE;
2007
2008 switch( f_pChannelOpen->CodecConfig.ulDecodingRate )
2009 {
2010 case cOCT6100_G711_64KBPS:
2011 ulCompType = 0x8;
2012 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
2013 {
2014 if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw )
2015 fProgramAdpcmMem = FALSE;
2016
2017 /* Check if both ports are assigned. If not, no law conversion needed here.. */
2018 if ( ( pTdmConfig->ulRinStream == cOCT6100_UNASSIGNED )
2019 || ( pTdmConfig->ulRoutStream == cOCT6100_UNASSIGNED ) )
2020 fProgramAdpcmMem = FALSE;
2021 }
2022 else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
2023 {
2024 if ( pTdmConfig->ulSinPcmLaw == pTdmConfig->ulSoutPcmLaw )
2025 fProgramAdpcmMem = FALSE;
2026
2027 if ( ( pTdmConfig->ulSinStream == cOCT6100_UNASSIGNED )
2028 || ( pTdmConfig->ulSoutStream == cOCT6100_UNASSIGNED ) )
2029 fProgramAdpcmMem = FALSE;
2030 }
2031 break;
2032 case cOCT6100_G726_40KBPS:
2033 ulCompType = 0x3;
2034 break;
2035
2036 case cOCT6100_G726_32KBPS:
2037 ulCompType = 0x2;
2038 break;
2039
2040 case cOCT6100_G726_24KBPS:
2041 ulCompType = 0x1;
2042 break;
2043
2044 case cOCT6100_G726_16KBPS:
2045 ulCompType = 0x0;
2046 break;
2047
2048 case cOCT6100_G727_2C_ENCODED:
2049 ulCompType = 0x4;
2050 break;
2051
2052 case cOCT6100_G727_3C_ENCODED:
2053 ulCompType = 0x5;
2054 break;
2055
2056 case cOCT6100_G727_4C_ENCODED:
2057 ulCompType = 0x6;
2058 break;
2059
2060 case cOCT6100_G726_ENCODED:
2061 ulCompType = 0x9;
2062 break;
2063
2064 case cOCT6100_G711_G726_ENCODED:
2065 ulCompType = 0xA;
2066 break;
2067
2068 case cOCT6100_G711_G727_2C_ENCODED:
2069 ulCompType = 0xC;
2070 break;
2071
2072 case cOCT6100_G711_G727_3C_ENCODED:
2073 ulCompType = 0xD;
2074 break;
2075
2076 case cOCT6100_G711_G727_4C_ENCODED:
2077 ulCompType = 0xE;
2078 break;
2079 default:
2080 return cOCT6100_ERR_FATAL_D4;
2081 }
2082
2083 if ( fProgramAdpcmMem == TRUE )
2084 {
2085 /* Set the chariot memory based on the selected port.*/
2086 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
2087 {
2088 usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
2089 ulPcmLaw = pTdmConfig->ulRoutPcmLaw; /* Set the law for later use */
2090
2091 /* Set the codec state flags.*/
2092 f_pChanIndexConf->fRinRoutCodecActive = TRUE;
2093
2094 /* Set the conversion memory index to use for decompression */
2095 usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
2096 }
2097 else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
2098 {
2099 usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
2100 ulPcmLaw = pTdmConfig->ulSoutPcmLaw; /* Set the law for later use */
2101
2102 /* Set the codec state flags.*/
2103 f_pChanIndexConf->fSinSoutCodecActive = TRUE;
2104
2105 /* Set the conversion memory index to use for decompression */
2106 usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
2107 }
2108
2109 ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance,
2110 usConversionMemIndex,
2111 ulCompType,
2112 usTempTsiMemIndex,
2113 ulPcmLaw,
2114 f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition );
2115 if ( ulResult != cOCT6100_ERR_OK )
2116 return ulResult;
2117 }
2118 }
2119 /*==============================================================================*/
2120
2121
2122 /*==============================================================================*/
2123 /* Configure the ADPCM control memory for the Encoder */
2124
2125 if ( f_pChannelOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING )
2126 {
2127 fProgramAdpcmMem = TRUE;
2128
2129 switch( f_pChannelOpen->CodecConfig.ulEncodingRate )
2130 {
2131 case cOCT6100_G711_64KBPS:
2132 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
2133 {
2134 if ( pTdmConfig->ulRoutPcmLaw == cOCT6100_PCM_U_LAW )
2135 ulCompType = 0x4;
2136 else
2137 ulCompType = 0x5;
2138
2139 /* Check for law conversion.*/
2140 if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw )
2141 fProgramAdpcmMem = FALSE;
2142
2143 /* Check if both ports are assigned. If not, no law conversion needed here.. */
2144 if ( ( pTdmConfig->ulRinStream == cOCT6100_UNASSIGNED )
2145 || ( pTdmConfig->ulRoutStream == cOCT6100_UNASSIGNED ) )
2146 fProgramAdpcmMem = FALSE;
2147 }
2148 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
2149 {
2150 if ( pTdmConfig->ulSoutPcmLaw == cOCT6100_PCM_U_LAW )
2151 ulCompType = 0x4;
2152 else
2153 ulCompType = 0x5;
2154
2155 /* Check for law conversion.*/
2156 if ( pTdmConfig->ulSinPcmLaw == pTdmConfig->ulSoutPcmLaw )
2157 fProgramAdpcmMem = FALSE;
2158
2159 /* Check if both ports are assigned. If not, no law conversion needed here.. */
2160 if ( ( pTdmConfig->ulSinStream == cOCT6100_UNASSIGNED )
2161 || ( pTdmConfig->ulSoutStream == cOCT6100_UNASSIGNED ) )
2162 fProgramAdpcmMem = FALSE;
2163 }
2164
2165 break;
2166 case cOCT6100_G726_40KBPS:
2167 ulCompType = 0x3;
2168 break;
2169
2170 case cOCT6100_G726_32KBPS:
2171 ulCompType = 0x2;
2172 break;
2173
2174 case cOCT6100_G726_24KBPS:
2175 ulCompType = 0x1;
2176 break;
2177
2178 case cOCT6100_G726_16KBPS:
2179 ulCompType = 0x0;
2180 break;
2181
2182 case cOCT6100_G727_40KBPS_4_1:
2183 ulCompType = 0xD;
2184 break;
2185
2186 case cOCT6100_G727_40KBPS_3_2:
2187 ulCompType = 0xA;
2188 break;
2189
2190 case cOCT6100_G727_40KBPS_2_3:
2191 ulCompType = 0x6;
2192 break;
2193
2194 case cOCT6100_G727_32KBPS_4_0:
2195 ulCompType = 0xE;
2196 break;
2197
2198 case cOCT6100_G727_32KBPS_3_1:
2199 ulCompType = 0xB;
2200 break;
2201
2202 case cOCT6100_G727_32KBPS_2_2:
2203 ulCompType = 0x7;
2204 break;
2205
2206 case cOCT6100_G727_24KBPS_3_0:
2207 ulCompType = 0xC;
2208 break;
2209
2210 case cOCT6100_G727_24KBPS_2_1:
2211 ulCompType = 0x8;
2212 break;
2213
2214 case cOCT6100_G727_16KBPS_2_0:
2215 ulCompType = 0x9;
2216 break;
2217
2218 default:
2219 return cOCT6100_ERR_FATAL_D5;
2220 }
2221
2222 /* Program the APDCM memory only if ADPCM is requried.*/
2223 if ( fProgramAdpcmMem == TRUE || f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
2224 {
2225 /* Set the chariot memory based on the selected port.*/
2226 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
2227 {
2228 usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
2229
2230 /* Set the codec state flags.*/
2231 f_pChanIndexConf->fRinRoutCodecActive = TRUE;
2232
2233 /* Set the conversion memory index to use for compression */
2234 usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
2235 }
2236
2237 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
2238 {
2239 usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
2240
2241 /* Set the codec state flags.*/
2242 f_pChanIndexConf->fSinSoutCodecActive = TRUE;
2243
2244 /* Set the conversion memory index to use for compression */
2245 usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
2246 }
2247
2248 ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance,
2249 usConversionMemIndex,
2250 ulCompType,
2251 usTempTsiMemIndex,
2252 f_pChannelOpen->CodecConfig.fEnableSilenceSuppression,
2253 f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
2254 f_pChanIndexConf->usPhasingTsstIndex,
2255 f_pChannelOpen->CodecConfig.ulPhasingType,
2256 f_pChannelOpen->CodecConfig.ulPhase );
2257 if ( ulResult != cOCT6100_ERR_OK )
2258 return ulResult;
2259 }
2260 }
2261 /*==============================================================================*/
2262
2263
2264 /*==============================================================================*/
2265 /* Clearing the tone events bit vector */
2266
2267 ulDwordAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usEchoChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
2268 ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
2269 ulDwordData = 0x00000000;
2270
2271 ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2272 if ( ulResult != cOCT6100_ERR_OK )
2273 return ulResult;
2274
2275 ulDwordAddress += 4;
2276
2277 ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2278 if ( ulResult != cOCT6100_ERR_OK )
2279 return ulResult;
2280
2281 /*==============================================================================*/
2282
2283
2284 /*==============================================================================*/
2285 /* Write the VQE memory */
2286
2287 ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance,
2288 &f_pChannelOpen->VqeConfig,
2289 f_pChannelOpen,
2290 f_pChanIndexConf->usEchoChanIndex,
2291 f_pChanIndexConf->usEchoMemIndex,
2292 TRUE,
2293 FALSE );
2294 if ( ulResult != cOCT6100_ERR_OK )
2295 return ulResult;
2296
2297 /*==============================================================================*/
2298
2299 /*==============================================================================*/
2300 /* Write the echo memory */
2301
2302 ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance,
2303 pTdmConfig,
2304 f_pChannelOpen,
2305 f_pChanIndexConf->usEchoMemIndex,
2306 f_pChanIndexConf->usRinRoutTsiMemIndex,
2307 f_pChanIndexConf->usSinSoutTsiMemIndex );
2308 if ( ulResult != cOCT6100_ERR_OK )
2309 return ulResult;
2310
2311 /*==============================================================================*/
2312
2313
2314
2315 /*==============================================================================*/
2316 /* Mute channel if required, this is done on a port basis */
2317
2318 /* Initialize the silence indexes to invalid for now. */
2319 pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
2320 pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
2321
2322 /* Set the TSI memory indexes. */
2323 pChanEntry->usRinRoutTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
2324 pChanEntry->usSinSoutTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
2325
2326 ulResult = Oct6100ApiMutePorts( f_pApiInstance,
2327 f_pChanIndexConf->usEchoChanIndex,
2328 f_pChanIndexConf->usRinTsstIndex,
2329 f_pChanIndexConf->usSinTsstIndex,
2330 FALSE );
2331 if ( ulResult != cOCT6100_ERR_OK )
2332 return ulResult;
2333
2334 /*==============================================================================*/
2335
2336
2337 /*==============================================================================*/
2338 /* Set the dominant speaker to unassigned, if required. */
2339
2340 if ( f_pApiInstance->pSharedInfo->ImageInfo.fDominantSpeakerEnabled == TRUE )
2341 {
2342 ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_pChanIndexConf->usEchoChanIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED );
2343 if ( ulResult != cOCT6100_ERR_OK )
2344 return ulResult;
2345 }
2346
2347 /*==============================================================================*/
2348
2349
2350 /*==============================================================================*/
2351 /* If necessary, configure the extended tone detection channel.*/
2352
2353 if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
2354 {
2355 UINT32 ulTempSinLaw;
2356 UINT32 ulTempSoutLaw;
2357 UINT32 ulTempEchoOpMode;
2358
2359 /* save the original law.*/
2360 ulTempSinLaw = pTdmConfig->ulSinPcmLaw;
2361 ulTempSoutLaw = pTdmConfig->ulSoutPcmLaw;
2362 ulTempEchoOpMode = f_pChannelOpen->ulEchoOperationMode;
2363
2364 /* Now, make sure the Sin and Sout law are the same as the Rin law.*/
2365
2366 pTdmConfig->ulSinPcmLaw = pTdmConfig->ulRinPcmLaw;
2367 pTdmConfig->ulSoutPcmLaw = pTdmConfig->ulRinPcmLaw;
2368
2369 f_pChannelOpen->ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_NORMAL;
2370
2371 /* Write the Echo and VQE memory of the extended channel.*/
2372
2373 ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance,
2374 pTdmConfig,
2375 &f_pChannelOpen->VqeConfig,
2376 f_pChannelOpen,
2377 f_pChanIndexConf->usExtToneChanIndex,
2378 f_pChanIndexConf->usExtToneChanIndex,
2379 cOCT6100_API_EXT_TONE_EXTRA_TSI,
2380 f_pChanIndexConf->usExtToneTsiIndex );
2381 if ( ulResult != cOCT6100_ERR_OK )
2382 return ulResult;
2383
2384 /* Now, write the mixer event used to copy the RIN signal of the original channel
2385 into the SIN signal of the exteded channel. */
2386
2387 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_pChanIndexConf->usExtToneMixerIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
2388
2389 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
2390 WriteParams.usWriteData |= f_pChanIndexConf->usRinRoutTsiMemIndex;
2391 WriteParams.usWriteData |= pTdmConfig->ulRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
2392
2393 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2394 if ( ulResult != cOCT6100_ERR_OK )
2395 return ulResult;
2396
2397 WriteParams.ulWriteAddress += 2;
2398 WriteParams.usWriteData = f_pChanIndexConf->usExtToneTsiIndex;
2399
2400 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2401 if ( ulResult != cOCT6100_ERR_OK )
2402 return ulResult;
2403
2404 /*=======================================================================*/
2405
2406
2407 /*=======================================================================*/
2408 /* Now insert the Sin copy event into the list.*/
2409
2410 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
2411 f_pChanIndexConf->usExtToneMixerIndex,
2412 cOCT6100_EVENT_TYPE_SIN_COPY,
2413 f_pChanIndexConf->usEchoChanIndex );
2414 if ( ulResult != cOCT6100_ERR_OK )
2415 return ulResult;
2416 /*=======================================================================*/
2417
2418 /*==============================================================================*/
2419 /* Clearing the tone events bit vector */
2420
2421 ulDwordAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
2422 ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
2423 ulDwordData = 0x00000000;
2424
2425 ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2426 if ( ulResult != cOCT6100_ERR_OK )
2427 return ulResult;
2428
2429 ulDwordAddress += 4;
2430
2431 ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2432 if ( ulResult != cOCT6100_ERR_OK )
2433 return ulResult;
2434
2435 /*==============================================================================*/
2436
2437 /* Write back the original values in the channel open structure.*/
2438
2439 pTdmConfig->ulSinPcmLaw = ulTempSinLaw;
2440 pTdmConfig->ulSoutPcmLaw = ulTempSoutLaw;
2441
2442 f_pChannelOpen->ulEchoOperationMode = ulTempEchoOpMode;
2443 }
2444
2445 /*==============================================================================*/
2446
2447
2448 /*==============================================================================*/
2449 /* If necessary, configure the SS tone detection. */
2450
2451 for ( ulToneEventNumber = 0; ulToneEventNumber < cOCT6100_MAX_TONE_EVENT; ulToneEventNumber++ )
2452 {
2453 /* Check if the current tone is a SS tone. */
2454 ulResult = Oct6100ApiIsSSTone(
2455 f_pApiInstance,
2456 f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID,
2457 &fSSTone );
2458 if ( ulResult != cOCT6100_ERR_OK )
2459 return ulResult;
2460
2461 if ( fSSTone == TRUE )
2462 {
2463 /* Write to all resources needed to activate tone detection on this SS tone. */
2464 ulResult = Oct6100ApiWriteToneDetectEvent(
2465 f_pApiInstance,
2466 f_pChanIndexConf->usEchoChanIndex,
2467 ulToneEventNumber,
2468
2469 cOCT6100_INVALID_INDEX );
2470 if ( ulResult != cOCT6100_ERR_OK )
2471 return ulResult;
2472 }
2473 }
2474
2475 /*==============================================================================*/
2476
2477
2478 /*==============================================================================*/
2479 /* Configure the Output Tsst control memory.*/
2480
2481 /* Set the ROUT Tsst control entry.*/
2482 if ( f_pChanIndexConf->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
2483 {
2484 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
2485 f_pChanIndexConf->usRoutTsstIndex,
2486 f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
2487 pTdmConfig->ulRoutNumTssts,
2488 f_pChanIndexConf->usRinRoutTsiMemIndex );
2489 if ( ulResult != cOCT6100_ERR_OK )
2490 return ulResult;
2491 }
2492
2493 /* Set the SOUT Tsst control entry.*/
2494 if ( f_pChanIndexConf->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
2495 {
2496 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
2497 f_pChanIndexConf->usSoutTsstIndex,
2498 f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
2499 pTdmConfig->ulSoutNumTssts,
2500 f_pChanIndexConf->usSinSoutTsiMemIndex );
2501 if ( ulResult != cOCT6100_ERR_OK )
2502 return ulResult;
2503 }
2504
2505 /*==============================================================================*/
2506
2507 return cOCT6100_ERR_OK;
2508 }
2509 #endif
2510
2511
2512
2513 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2514
2515 Function: Oct6100ApiUpdateChannelEntry
2516
2517 Description: Updates the new channel in the ECHO channel list.
2518
2519 -------------------------------------------------------------------------------
2520 | Argument | Description
2521 -------------------------------------------------------------------------------
2522 f_pApiInstance Pointer to API instance. This memory is used to keep
2523 the present state of the chip and all its resources.
2524
2525 f_pChannelOpen Pointer to echo cancellation channel configuration structure.
2526 f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes.
2527
2528 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2529 #if !SKIP_Oct6100ApiUpdateChannelEntry
2530 UINT32 Oct6100ApiUpdateChannelEntry(
2531 IN tPOCT6100_INSTANCE_API f_pApiInstance,
2532 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
2533 OUT tPOCT6100_API_ECHO_CHAN_INDEX f_pChanIndexConf )
2534 {
2535 tPOCT6100_API_CHANNEL pChanEntry;
2536 tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig;
2537 tPOCT6100_CHANNEL_OPEN_VQE pVqeConfig;
2538 tPOCT6100_CHANNEL_OPEN_CODEC pCodecConfig;
2539
2540 /* Obtain a pointer to the config structures of the tPOCT6100_CHANNEL_OPEN structure. */
2541 pTdmConfig = &f_pChannelOpen->TdmConfig;
2542 pVqeConfig = &f_pChannelOpen->VqeConfig;
2543 pCodecConfig = &f_pChannelOpen->CodecConfig;
2544
2545 /* Obtain a pointer to the new buffer's list entry. */
2546 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex )
2547
2548 /*=======================================================================*/
2549 /* Copy the channel's configuration and allocated resources. */
2550 pChanEntry->ulUserChanId = f_pChannelOpen->ulUserChanId;
2551 pChanEntry->byEchoOperationMode = (UINT8)( f_pChannelOpen->ulEchoOperationMode & 0xFF );
2552 pChanEntry->fEnableToneDisabler = (UINT8)( f_pChannelOpen->fEnableToneDisabler & 0xFF );
2553 pChanEntry->fEnableExtToneDetection = (UINT8)( f_pChannelOpen->fEnableExtToneDetection & 0xFF );
2554
2555 /* Save the VQE configuration.*/
2556 pChanEntry->VqeConfig.byComfortNoiseMode = (UINT8)( pVqeConfig->ulComfortNoiseMode & 0xFF );
2557 pChanEntry->VqeConfig.fEnableNlp = (UINT8)( pVqeConfig->fEnableNlp & 0xFF );
2558 pChanEntry->VqeConfig.fEnableTailDisplacement = (UINT8)( pVqeConfig->fEnableTailDisplacement );
2559 pChanEntry->VqeConfig.usTailDisplacement = (UINT16)( pVqeConfig->ulTailDisplacement & 0xFFFF );
2560 pChanEntry->VqeConfig.usTailLength = (UINT16)( pVqeConfig->ulTailLength & 0xFFFF );
2561
2562 pChanEntry->VqeConfig.fSinDcOffsetRemoval = (UINT8)( pVqeConfig->fSinDcOffsetRemoval & 0xFF );
2563 pChanEntry->VqeConfig.fRinDcOffsetRemoval = (UINT8)( pVqeConfig->fRinDcOffsetRemoval & 0xFF );
2564 pChanEntry->VqeConfig.fRinLevelControl = (UINT8)( pVqeConfig->fRinLevelControl & 0xFF );
2565 pChanEntry->VqeConfig.chRinLevelControlGainDb = (OCT_INT8)( pVqeConfig->lRinLevelControlGainDb & 0xFF );
2566 pChanEntry->VqeConfig.fSoutLevelControl = (UINT8)( pVqeConfig->fSoutLevelControl & 0xFF );
2567 pChanEntry->VqeConfig.chSoutLevelControlGainDb = (OCT_INT8)( pVqeConfig->lSoutLevelControlGainDb & 0xFF );
2568 pChanEntry->VqeConfig.fRinAutomaticLevelControl = (UINT8)( pVqeConfig->fRinAutomaticLevelControl & 0xFF );
2569 pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb = (OCT_INT8)( pVqeConfig->lRinAutomaticLevelControlTargetDb & 0xFF );
2570 pChanEntry->VqeConfig.fSoutAutomaticLevelControl = (UINT8)( pVqeConfig->fSoutAutomaticLevelControl & 0xFF );
2571 pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb = (OCT_INT8)( pVqeConfig->lSoutAutomaticLevelControlTargetDb & 0xFF );
2572 pChanEntry->VqeConfig.fRinHighLevelCompensation = (UINT8)( pVqeConfig->fRinHighLevelCompensation & 0xFF );
2573 pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb = (OCT_INT8)( pVqeConfig->lRinHighLevelCompensationThresholdDb & 0xFF );
2574 pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction = (UINT8)( pVqeConfig->fSoutAdaptiveNoiseReduction & 0xFF );
2575 pChanEntry->VqeConfig.fSoutNoiseBleaching = (UINT8)( pVqeConfig->fSoutNoiseBleaching & 0xFF );
2576 pChanEntry->VqeConfig.fSoutConferencingNoiseReduction = (UINT8)( pVqeConfig->fSoutConferencingNoiseReduction & 0xFF );
2577
2578 pChanEntry->VqeConfig.fAcousticEcho = (UINT8)( pVqeConfig->fAcousticEcho & 0xFF );
2579
2580 pChanEntry->VqeConfig.fDtmfToneRemoval = (UINT8)( pVqeConfig->fDtmfToneRemoval & 0xFF );
2581
2582 pChanEntry->VqeConfig.chDefaultErlDb = (OCT_INT8)( pVqeConfig->lDefaultErlDb & 0xFF );
2583 pChanEntry->VqeConfig.chAecDefaultErlDb = (OCT_INT8)( pVqeConfig->lAecDefaultErlDb & 0xFF );
2584 pChanEntry->VqeConfig.usAecTailLength = (UINT16)( pVqeConfig->ulAecTailLength & 0xFFFF );
2585 pChanEntry->VqeConfig.byNonLinearityBehaviorA = (UINT8)( pVqeConfig->ulNonLinearityBehaviorA & 0xFF );
2586 pChanEntry->VqeConfig.byNonLinearityBehaviorB = (UINT8)( pVqeConfig->ulNonLinearityBehaviorB & 0xFF );
2587 pChanEntry->VqeConfig.byDoubleTalkBehavior = (UINT8)( pVqeConfig->ulDoubleTalkBehavior & 0xFF );
2588 pChanEntry->VqeConfig.chAnrSnrEnhancementDb = (OCT_INT8)( pVqeConfig->lAnrSnrEnhancementDb & 0xFF );
2589 pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation = (UINT8)( pVqeConfig->ulAnrVoiceNoiseSegregation & 0xFF );
2590 pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay = (UINT16)( pVqeConfig->ulToneDisablerVqeActivationDelay & 0xFFFF );
2591
2592 pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb = (UINT8)( pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb & 0xFF );
2593 pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb = (UINT8)( pVqeConfig->ulSoutNaturalListenerEnhancementGainDb & 0xFF );
2594 pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement = (UINT8)( pVqeConfig->fSoutNaturalListenerEnhancement & 0xFF );
2595 pChanEntry->VqeConfig.fRoutNoiseReduction = (UINT8)( pVqeConfig->fRoutNoiseReduction & 0xFF );
2596 pChanEntry->VqeConfig.chRoutNoiseReductionLevelGainDb = (OCT_INT8) (pVqeConfig->lRoutNoiseReductionLevelGainDb & 0xFF);
2597 pChanEntry->VqeConfig.fEnableMusicProtection = (UINT8)( pVqeConfig->fEnableMusicProtection & 0xFF );
2598 pChanEntry->VqeConfig.fIdleCodeDetection = (UINT8)( pVqeConfig->fIdleCodeDetection & 0xFF );
2599
2600 /* Save the codec information.*/
2601 pChanEntry->CodecConfig.byAdpcmNibblePosition = (UINT8)( pCodecConfig->ulAdpcmNibblePosition & 0xFF );
2602
2603 pChanEntry->CodecConfig.byDecoderPort = (UINT8)( pCodecConfig->ulDecoderPort & 0xFF );
2604 pChanEntry->CodecConfig.byDecodingRate = (UINT8)( pCodecConfig->ulDecodingRate & 0xFF );
2605 pChanEntry->CodecConfig.byEncoderPort = (UINT8)( pCodecConfig->ulEncoderPort & 0xFF );
2606 pChanEntry->CodecConfig.byEncodingRate = (UINT8)( pCodecConfig->ulEncodingRate & 0xFF );
2607
2608 pChanEntry->CodecConfig.fEnableSilenceSuppression = (UINT8)( pCodecConfig->fEnableSilenceSuppression & 0xFF );
2609 pChanEntry->CodecConfig.byPhase = (UINT8)( pCodecConfig->ulPhase & 0xFF );
2610 pChanEntry->CodecConfig.byPhasingType = (UINT8)( pCodecConfig->ulPhasingType & 0xFF );
2611
2612 /* Save the RIN settings.*/
2613 pChanEntry->TdmConfig.byRinPcmLaw = (UINT8)( pTdmConfig->ulRinPcmLaw & 0xFF );
2614 pChanEntry->TdmConfig.usRinTimeslot = (UINT16)( pTdmConfig->ulRinTimeslot & 0xFFFF );
2615 pChanEntry->TdmConfig.usRinStream = (UINT16)( pTdmConfig->ulRinStream & 0xFFFF );
2616
2617 /* Save the SIN settings.*/
2618 pChanEntry->TdmConfig.bySinPcmLaw = (UINT8)( pTdmConfig->ulSinPcmLaw & 0xFF );
2619 pChanEntry->TdmConfig.usSinTimeslot = (UINT16)( pTdmConfig->ulSinTimeslot & 0xFFFF );
2620 pChanEntry->TdmConfig.usSinStream = (UINT16)( pTdmConfig->ulSinStream & 0xFFFF );
2621
2622 /* Save the ROUT settings.*/
2623 pChanEntry->TdmConfig.byRoutPcmLaw = (UINT8)( pTdmConfig->ulRoutPcmLaw & 0xFF );
2624 pChanEntry->TdmConfig.usRoutTimeslot = (UINT16)( pTdmConfig->ulRoutTimeslot & 0xFFFF );
2625 pChanEntry->TdmConfig.usRoutStream = (UINT16)( pTdmConfig->ulRoutStream & 0xFFFF );
2626
2627 pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
2628 pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0;
2629
2630 /* Save the SOUT settings.*/
2631 pChanEntry->TdmConfig.bySoutPcmLaw = (UINT8)( pTdmConfig->ulSoutPcmLaw & 0xFF );
2632 pChanEntry->TdmConfig.usSoutTimeslot = (UINT16)( pTdmConfig->ulSoutTimeslot & 0xFFFF );
2633 pChanEntry->TdmConfig.usSoutStream = (UINT16)( pTdmConfig->ulSoutStream & 0xFFFF );
2634
2635 pChanEntry->TdmConfig.byRinNumTssts = (UINT8)( pTdmConfig->ulRinNumTssts & 0xFF );
2636 pChanEntry->TdmConfig.bySinNumTssts = (UINT8)( pTdmConfig->ulSinNumTssts & 0xFF );
2637 pChanEntry->TdmConfig.byRoutNumTssts = (UINT8)( pTdmConfig->ulRoutNumTssts & 0xFF );
2638 pChanEntry->TdmConfig.bySoutNumTssts = (UINT8)( pTdmConfig->ulSoutNumTssts & 0xFF );
2639 pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
2640 pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry = 0;
2641
2642 /* Save the extended Tone detection information.*/
2643 pChanEntry->usExtToneChanIndex = f_pChanIndexConf->usExtToneChanIndex;
2644 pChanEntry->usExtToneMixerIndex = f_pChanIndexConf->usExtToneMixerIndex;
2645 pChanEntry->usExtToneTsiIndex = f_pChanIndexConf->usExtToneTsiIndex;
2646
2647 if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
2648 {
2649 tPOCT6100_API_CHANNEL pExtToneChanEntry;
2650
2651 /* Set the mode of the original channel. He is the channel performing detection on the
2652 SIN port. The extended channel will perform detection on the RIN port.*/
2653 pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_SIN_PORT_MODE;
2654
2655 /* Now, program the associated channel.*/
2656
2657 /* Obtain a pointer to the extended tone detection channel entry. */
2658 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pExtToneChanEntry, f_pChanIndexConf->usExtToneChanIndex );
2659
2660 pExtToneChanEntry->fReserved = TRUE;
2661 pExtToneChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_RIN_PORT_MODE; /* Detect on RIN port.*/
2662 pExtToneChanEntry->usExtToneChanIndex = f_pChanIndexConf->usEchoChanIndex;
2663
2664 pExtToneChanEntry->aulToneConf[ 0 ] = 0;
2665 pExtToneChanEntry->aulToneConf[ 1 ] = 0;
2666
2667 }
2668 else
2669 {
2670 /* No extended tone detection supported.*/
2671 pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED;
2672 }
2673
2674 /*=======================================================================*/
2675
2676 /*=======================================================================*/
2677 /* Store hardware related information.*/
2678 pChanEntry->usRinRoutTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
2679 pChanEntry->usSinSoutTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
2680 pChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
2681 pChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX;
2682
2683 /* We are not being tapped for now. */
2684 pChanEntry->fBeingTapped = FALSE;
2685
2686 pChanEntry->usTapChanIndex = cOCT6100_INVALID_INDEX;
2687 pChanEntry->usTapBridgeIndex = cOCT6100_INVALID_INDEX;
2688
2689 /* The copy event has not yet been created. */
2690 pChanEntry->fCopyEventCreated = FALSE;
2691
2692 pChanEntry->usRinRoutConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
2693 pChanEntry->usSinSoutConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
2694
2695 pChanEntry->usPhasingTsstIndex = f_pChanIndexConf->usPhasingTsstIndex;
2696
2697 pChanEntry->fSinSoutCodecActive = f_pChanIndexConf->fSinSoutCodecActive;
2698 pChanEntry->fRinRoutCodecActive = f_pChanIndexConf->fRinRoutCodecActive;
2699
2700
2701
2702 pChanEntry->usEchoMemIndex = f_pChanIndexConf->usEchoMemIndex;
2703
2704 pChanEntry->usRinTsstIndex = f_pChanIndexConf->usRinTsstIndex;
2705 pChanEntry->usSinTsstIndex = f_pChanIndexConf->usSinTsstIndex;
2706 pChanEntry->usRoutTsstIndex = f_pChanIndexConf->usRoutTsstIndex;
2707 pChanEntry->usSoutTsstIndex = f_pChanIndexConf->usSoutTsstIndex;
2708
2709 pChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
2710 pChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX;
2711
2712 /* Nothing muted for now. */
2713 pChanEntry->usMutedPorts = cOCT6100_CHANNEL_MUTE_PORT_NONE;
2714
2715 /* Set all the GW feature initial value.*/
2716 /* Bridge info */
2717 pChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
2718 pChanEntry->fMute = FALSE;
2719
2720 pChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX;
2721 pChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX;
2722
2723 /* Buffer playout info.*/
2724 pChanEntry->fRinBufPlaying = FALSE;
2725 pChanEntry->fSoutBufPlaying = FALSE;
2726
2727 /* Tone detection state. */
2728 /* This array is configured as follow.*/
2729 /* Index 0 contain event 0 to 31 (msb = event 31) and Index 1 contain index 32 - 55 */
2730 pChanEntry->aulToneConf[ 0 ] = 0;
2731 pChanEntry->aulToneConf[ 1 ] = 0;
2732 pChanEntry->ulLastSSToneDetected = (PTR_TYPE)cOCT6100_INVALID_VALUE;
2733 pChanEntry->ulLastSSToneTimestamp = (PTR_TYPE)cOCT6100_INVALID_VALUE;
2734
2735 /* Initialize the bidirectional flag.*/
2736 pChanEntry->fBiDirChannel = FALSE;
2737
2738 /*=======================================================================*/
2739 /* Init some of the stats.*/
2740
2741 pChanEntry->sMaxERL = cOCT6100_INVALID_SIGNED_STAT_W;
2742 pChanEntry->sMaxERLE = cOCT6100_INVALID_SIGNED_STAT_W;
2743 pChanEntry->usMaxEchoDelay = cOCT6100_INVALID_STAT_W;
2744 pChanEntry->usNumEchoPathChangesOfst = 0;
2745
2746 /*=======================================================================*/
2747
2748 /*=======================================================================*/
2749 /* Update the dependency of the phasing TSST if one is associated to the chanel.*/
2750
2751 if ( f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
2752 {
2753 tPOCT6100_API_PHASING_TSST pPhasingEntry;
2754
2755 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanIndexConf->usPhasingTsstIndex );
2756
2757 pPhasingEntry->usDependencyCnt++;
2758 }
2759 /*=======================================================================*/
2760
2761 /*=======================================================================*/
2762
2763 /* Form handle returned to user. */
2764 *f_pChannelOpen->pulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_pChanIndexConf->usEchoChanIndex;
2765
2766 /* Finally, mark the channel as open. */
2767 pChanEntry->fReserved = TRUE;
2768 pChanEntry->usExtraSinTsiDependencyCnt = 0;
2769
2770 /* Increment the number of channel open.*/
2771 f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels++;
2772
2773 /*=======================================================================*/
2774
2775 return cOCT6100_ERR_OK;
2776 }
2777 #endif
2778
2779
2780
2781
2782
2783
2784 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2785
2786 Function: Oct6100ChannelCloseSer
2787
2788 Description: Closes a echo cancellation channel.
2789
2790 -------------------------------------------------------------------------------
2791 | Argument | Description
2792 -------------------------------------------------------------------------------
2793 f_pApiInstance Pointer to API instance. This memory is used to keep the
2794 present state of the chip and all its resources.
2795
2796 f_pChannelClose Pointer to echo cancellation channel close structure.
2797
2798 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2799 #if !SKIP_Oct6100ChannelCloseSer
2800 UINT32 Oct6100ChannelCloseSer(
2801 IN tPOCT6100_INSTANCE_API f_pApiInstance,
2802 IN tPOCT6100_CHANNEL_CLOSE f_pChannelClose )
2803 {
2804 UINT16 usChannelIndex;
2805
2806
2807 UINT32 ulResult;
2808
2809 /* Verify that all the parameters given match the state of the API. */
2810 ulResult = Oct6100ApiAssertChannelParams( f_pApiInstance,
2811 f_pChannelClose,
2812
2813 &usChannelIndex );
2814 if ( ulResult != cOCT6100_ERR_OK )
2815 return ulResult;
2816
2817 /* Release all resources associated to the echo cancellation channel. */
2818 ulResult = Oct6100ApiInvalidateChannelStructs( f_pApiInstance,
2819
2820 usChannelIndex );
2821 if ( ulResult != cOCT6100_ERR_OK )
2822 return ulResult;
2823
2824 /* Release all resources associated to the echo cancellation channel. */
2825 ulResult = Oct6100ApiReleaseChannelResources( f_pApiInstance, usChannelIndex );
2826 if ( ulResult != cOCT6100_ERR_OK )
2827 return ulResult;
2828
2829 /* Invalidate the handle.*/
2830 f_pChannelClose->ulChannelHndl = cOCT6100_INVALID_HANDLE;
2831
2832 return cOCT6100_ERR_OK;
2833 }
2834 #endif
2835
2836 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2837
2838 Function: Oct6100ApiAssertChannelParams
2839
2840 Description: Validate the handle given by the user and verify the state of
2841 the channel about to be closed.
2842
2843 -------------------------------------------------------------------------------
2844 | Argument | Description
2845 -------------------------------------------------------------------------------
2846 f_pApiInstance Pointer to API instance. This memory is used to keep the
2847 present state of the chip and all its resources.
2848
2849 f_pChannelClose Pointer to echo cancellation channel close structure.
2850 f_pulFpgaChanIndex Pointer to the FPGA channel index associated to this channel.
2851 f_pusChanIndex Pointer to the index of the channel within the API instance.
2852
2853 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2854 #if !SKIP_Oct6100ApiAssertChannelParams
2855 UINT32 Oct6100ApiAssertChannelParams(
2856 IN tPOCT6100_INSTANCE_API f_pApiInstance,
2857 IN tPOCT6100_CHANNEL_CLOSE f_pChannelClose,
2858
2859 IN OUT PUINT16 f_pusChanIndex )
2860 {
2861 tPOCT6100_SHARED_INFO pSharedInfo;
2862 tPOCT6100_API_CHANNEL pChanEntry;
2863 UINT32 ulEntryOpenCnt;
2864
2865 /* Get local pointer(s). */
2866 pSharedInfo = f_pApiInstance->pSharedInfo;
2867
2868 /* Check the provided handle. */
2869 if ( (f_pChannelClose->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
2870 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2871
2872 *f_pusChanIndex = (UINT16)( f_pChannelClose->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
2873 if ( *f_pusChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
2874 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2875
2876 /*=======================================================================*/
2877 /* Get a pointer to the channel's list entry. */
2878
2879 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex )
2880
2881 /* Extract the entry open count from the provided handle. */
2882 ulEntryOpenCnt = ( f_pChannelClose->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
2883
2884 /* Check for errors. */
2885 if ( pChanEntry->fReserved != TRUE )
2886 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
2887 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
2888 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2889 if ( pChanEntry->fBiDirChannel == TRUE )
2890 return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL;
2891
2892 /*=======================================================================*/
2893
2894 /* Check if the channel is bound to a bridge. */
2895 if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
2896 return cOCT6100_ERR_CHANNEL_ACTIVE_DEPENDENCIES;
2897
2898
2899
2900 return cOCT6100_ERR_OK;
2901 }
2902 #endif
2903
2904 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2905
2906 Function: Oct6100ApiInvalidateChannelStructs
2907
2908 Description: Closes a echo cancellation channel.
2909
2910 -------------------------------------------------------------------------------
2911 | Argument | Description
2912 -------------------------------------------------------------------------------
2913 f_pApiInstance Pointer to API instance. This memory is used to keep the
2914 present state of the chip and all its resources.
2915
2916 f_ulFpgaChanIndex Index of the channel within the SCN_PLC FPGA.
2917 f_usChanIndex Index of the channel within the API instance.
2918
2919 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2920 #if !SKIP_Oct6100ApiInvalidateChannelStructs
2921 UINT32 Oct6100ApiInvalidateChannelStructs(
2922 IN tPOCT6100_INSTANCE_API f_pApiInstance,
2923
2924 IN UINT16 f_usChanIndex )
2925 {
2926 tPOCT6100_API_CHANNEL pChanEntry;
2927 tPOCT6100_API_CHANNEL_TDM pTdmConfig;
2928 tPOCT6100_API_TSST_ENTRY pTsstEntry;
2929 tOCT6100_BUFFER_PLAYOUT_STOP BufferPlayoutStop;
2930 tPOCT6100_SHARED_INFO pSharedInfo;
2931 tOCT6100_WRITE_PARAMS WriteParams;
2932 tOCT6100_WRITE_SMEAR_PARAMS SmearParams;
2933 UINT32 ulResult;
2934 UINT16 usCurrentEntry;
2935
2936 /* Obtain local pointer to shared portion of instance. */
2937 pSharedInfo = f_pApiInstance->pSharedInfo;
2938
2939 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
2940
2941 /* Obtain local pointer to the TDM configuration of the channel */
2942 pTdmConfig = &pChanEntry->TdmConfig;
2943
2944 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
2945
2946 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
2947
2948 SmearParams.pProcessContext = f_pApiInstance->pProcessContext;
2949
2950 SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
2951
2952 /* If this channel is currently debugged, automatically close the debug channel. */
2953 if ( ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
2954 && ( pSharedInfo->DebugInfo.usCurrentDebugChanIndex == f_usChanIndex ) )
2955 {
2956 tOCT6100_DEBUG_SELECT_CHANNEL SelectDebugChan;
2957
2958 /* Ensure forward compatibility. */
2959 Oct6100DebugSelectChannelDef( &SelectDebugChan );
2960
2961 /* Set the hot channel to an invalid handle to disable recording. */
2962 SelectDebugChan.ulChannelHndl = cOCT6100_INVALID_HANDLE;
2963
2964 /* Call the serialized fonction. */
2965 ulResult = Oct6100DebugSelectChannelSer( f_pApiInstance, &SelectDebugChan, FALSE );
2966 if ( ulResult != cOCT6100_ERR_OK )
2967 return ulResult;
2968 }
2969
2970 /* Deactivate the TSST control memory if used. */
2971
2972 /* RIN port.*/
2973 if ( pTdmConfig->usRinTimeslot != cOCT6100_UNASSIGNED )
2974 {
2975 /* Deactivate the TSST entry.*/
2976 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usRinTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
2977 WriteParams.usWriteData = 0x0000;
2978
2979 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2980 if ( ulResult != cOCT6100_ERR_OK )
2981 return ulResult;
2982 }
2983
2984 /* SIN port.*/
2985 if ( pTdmConfig->usSinTimeslot != cOCT6100_UNASSIGNED )
2986 {
2987 /* Deactivate the TSST entry.*/
2988 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usSinTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
2989 WriteParams.usWriteData = 0x0000;
2990
2991 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2992 if ( ulResult != cOCT6100_ERR_OK )
2993 return ulResult;
2994 }
2995
2996 /*=======================================================================*/
2997 /* ROUT port.*/
2998
2999 if ( pTdmConfig->usRoutTimeslot != cOCT6100_UNASSIGNED )
3000 {
3001 /* Deactivate the TSST entry.*/
3002 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usRoutTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3003 WriteParams.usWriteData = 0x0000;
3004
3005 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3006 if ( ulResult != cOCT6100_ERR_OK )
3007 return ulResult;
3008 }
3009
3010 /* Now the broadcast TSST.*/
3011 usCurrentEntry = pTdmConfig->usRoutBrdcastTsstFirstEntry;
3012 while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3013 {
3014 mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3015
3016 /* Deactivate the TSST entry.*/
3017 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pTsstEntry->usTsstMemoryIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3018 WriteParams.usWriteData = 0x0000;
3019
3020 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3021 if ( ulResult != cOCT6100_ERR_OK )
3022 return ulResult;
3023
3024 /* Move to the next entry.*/
3025 usCurrentEntry = pTsstEntry->usNextEntry;
3026 }
3027 /*=======================================================================*/
3028
3029 /*=======================================================================*/
3030 /* SOUT port.*/
3031
3032 if ( pTdmConfig->usSoutTimeslot != cOCT6100_UNASSIGNED )
3033 {
3034 /* Deactivate the TSST entry.*/
3035 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usSoutTsstIndex * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3036 WriteParams.usWriteData = 0x0000;
3037
3038 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3039 if ( ulResult != cOCT6100_ERR_OK )
3040 return ulResult;
3041 }
3042
3043 /* Now the broadcast TSST.*/
3044 usCurrentEntry = pTdmConfig->usSoutBrdcastTsstFirstEntry;
3045 while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3046 {
3047 mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3048
3049 /* Deactivate the TSST entry.*/
3050 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pTsstEntry->usTsstMemoryIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3051 WriteParams.usWriteData = 0x0000;
3052
3053 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3054 if ( ulResult != cOCT6100_ERR_OK )
3055 return ulResult;
3056
3057 /* Move to the next entry.*/
3058 usCurrentEntry = pTsstEntry->usNextEntry;
3059 }
3060 /*=======================================================================*/
3061
3062
3063 /*------------------------------------------------------------------------------*/
3064 /* Deactivate the ECHO control memory entry.*/
3065
3066 /* Set the input Echo control entry to unused.*/
3067 WriteParams.ulWriteAddress = cOCT6100_ECHO_CONTROL_MEM_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
3068 WriteParams.usWriteData = 0x85FF; /* TSI index 1535 reserved for power-down mode */
3069
3070 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3071 if ( ulResult != cOCT6100_ERR_OK )
3072 return ulResult;
3073
3074 WriteParams.ulWriteAddress += 2;
3075 WriteParams.usWriteData = 0xC5FF; /* TSI index 1535 reserved for power-down mode */
3076
3077 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3078 if ( ulResult != cOCT6100_ERR_OK )
3079 return ulResult;
3080 /*------------------------------------------------------------------------------*/
3081
3082 /*------------------------------------------------------------------------------*/
3083 /* Deactivate the conversion control memories if used. */
3084
3085 if ( pChanEntry->usRinRoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3086 {
3087 /* Rin/Rout stream conversion memory was used */
3088 ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, pChanEntry->usRinRoutConversionMemIndex );
3089 if ( ulResult != cOCT6100_ERR_OK )
3090 return ulResult;
3091 }
3092
3093 if ( pChanEntry->usSinSoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3094 {
3095 /* Sin/Sout stream conversion memory was used */
3096 ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance, pChanEntry->usSinSoutConversionMemIndex );
3097 if ( ulResult != cOCT6100_ERR_OK )
3098 return ulResult;
3099 }
3100
3101 /*------------------------------------------------------------------------------*/
3102
3103
3104 /*------------------------------------------------------------------------------*/
3105 /* Clear the silence copy events if they were created. */
3106
3107 /* Unmute the Rin port if it was muted. */
3108 if ( pChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
3109 {
3110 /* Remove the event from the list.*/
3111 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
3112 pChanEntry->usRinSilenceEventIndex,
3113 cOCT6100_EVENT_TYPE_SOUT_COPY );
3114 if ( ulResult != cOCT6100_ERR_OK )
3115 return ulResult;
3116
3117 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usRinSilenceEventIndex );
3118 if ( ulResult != cOCT6100_ERR_OK )
3119 return cOCT6100_ERR_FATAL_DF;
3120
3121 pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
3122 }
3123
3124 /* Unmute the Sin port if it was muted. */
3125 if ( pChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX )
3126 {
3127 /* Remove the event from the list.*/
3128 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
3129 pChanEntry->usSinSilenceEventIndex,
3130 cOCT6100_EVENT_TYPE_SOUT_COPY );
3131 if ( ulResult != cOCT6100_ERR_OK )
3132 return ulResult;
3133
3134 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usSinSilenceEventIndex );
3135 if ( ulResult != cOCT6100_ERR_OK )
3136 return cOCT6100_ERR_FATAL_E0;
3137
3138 pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
3139 }
3140
3141 /*------------------------------------------------------------------------------*/
3142
3143 /* Synch all the buffer playout field.*/
3144 if ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE )
3145 {
3146 Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
3147
3148 BufferPlayoutStop.ulChannelHndl = cOCT6100_INVALID_HANDLE;
3149 BufferPlayoutStop.fStopCleanly = FALSE;
3150
3151 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
3152 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
3153 f_pApiInstance,
3154 &BufferPlayoutStop,
3155 f_usChanIndex,
3156 pChanEntry->usEchoMemIndex
3157
3158 );
3159 if ( ulResult != cOCT6100_ERR_OK )
3160 return ulResult;
3161
3162 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
3163 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
3164 f_pApiInstance,
3165 &BufferPlayoutStop,
3166 f_usChanIndex,
3167 pChanEntry->usEchoMemIndex
3168
3169 );
3170 if ( ulResult != cOCT6100_ERR_OK )
3171 return ulResult;
3172 }
3173
3174
3175
3176
3177
3178 /* Free all resources reserved for extended tone detection.*/
3179 if ( pChanEntry->fEnableExtToneDetection == TRUE )
3180 {
3181 /*------------------------------------------------------------------------------*/
3182 /* Deactivate the ECHO control memory entry of the extended channel.*/
3183
3184 /* Set the input Echo control entry to unused.*/
3185 WriteParams.ulWriteAddress = cOCT6100_ECHO_CONTROL_MEM_BASE + ( pChanEntry->usExtToneChanIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
3186 WriteParams.usWriteData = 0x85FF; /* TSI index 1535 reserved for power-down mode */
3187
3188 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3189 if ( ulResult != cOCT6100_ERR_OK )
3190 return ulResult;
3191
3192 WriteParams.ulWriteAddress += 2;
3193 WriteParams.usWriteData = 0xC5FF; /* TSI index 1535 reserved for power-down mode */
3194
3195 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3196 if ( ulResult != cOCT6100_ERR_OK )
3197 return ulResult;
3198 /*------------------------------------------------------------------------------*/
3199
3200 /*------------------------------------------------------------------------------*/
3201 /* Remove the mixer event used to copy the RIN signal to the SIN port of the extended
3202 channel.*/
3203
3204 /* Clear the Copy event.*/
3205 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usExtToneMixerIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
3206 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
3207
3208 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3209 if ( ulResult != cOCT6100_ERR_OK )
3210 return ulResult;
3211
3212 /* Remove the event from the list.*/
3213 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
3214 pChanEntry->usExtToneMixerIndex,
3215 cOCT6100_EVENT_TYPE_SIN_COPY );
3216 if ( ulResult != cOCT6100_ERR_OK )
3217 return ulResult;
3218
3219 /*------------------------------------------------------------------------------*/
3220
3221 }
3222
3223 /*------------------------------------------------------------------------------*/
3224 /* Reset PGSP */
3225
3226 WriteParams.ulWriteAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
3227 WriteParams.usWriteData = 0x0800;
3228
3229 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3230 if ( ulResult != cOCT6100_ERR_OK )
3231 return ulResult;
3232
3233 /*------------------------------------------------------------------------------*/
3234
3235 /*------------------------------------------------------------------------------*/
3236 /* Clear the mute with feature bit. */
3237
3238 if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
3239 {
3240 ulResult = Oct6100ApiMuteSinWithFeatures( f_pApiInstance, f_usChanIndex, FALSE );
3241 if ( ulResult != cOCT6100_ERR_OK )
3242 return ulResult;
3243 }
3244
3245 /*------------------------------------------------------------------------------*/
3246
3247 /*------------------------------------------------------------------------------*/
3248 /* Clear the VQE memory. */
3249
3250 SmearParams.ulWriteAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst + 0x20;
3251 SmearParams.usWriteData = 0x0000;
3252 SmearParams.ulWriteLength = 2;
3253
3254 mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
3255 if ( ulResult != cOCT6100_ERR_OK )
3256 return ulResult;
3257
3258 /*------------------------------------------------------------------------------*/
3259 /*------------------------------------------------------------------------------*/
3260 /* Clear the NLP memory. */
3261
3262 SmearParams.ulWriteAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst + 0x28;
3263 SmearParams.usWriteData = 0x0000;
3264 SmearParams.ulWriteLength = 2;
3265
3266 mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
3267 if ( ulResult != cOCT6100_ERR_OK )
3268 return ulResult;
3269
3270 /*------------------------------------------------------------------------------*/
3271 /* Clear the AF information memory. */
3272
3273 SmearParams.ulWriteAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( pChanEntry->usEchoMemIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
3274 SmearParams.usWriteData = 0x0000;
3275 SmearParams.ulWriteLength = 12;
3276
3277 mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
3278 if ( ulResult != cOCT6100_ERR_OK )
3279 return ulResult;
3280
3281 /*Reset ALC status*/
3282 WriteParams.ulWriteAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( pChanEntry->usEchoMemIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + 0x3A;
3283 WriteParams.usWriteData = 0x0000;
3284
3285 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3286 if ( ulResult != cOCT6100_ERR_OK )
3287 return ulResult;
3288
3289 /*------------------------------------------------------------------------------*/
3290
3291 return cOCT6100_ERR_OK;
3292 }
3293 #endif
3294
3295 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3296
3297 Function: Oct6100ApiReleaseChannelResources
3298
3299 Description: Release and clear the API entry associated to the echo cancellation channel.
3300
3301 -------------------------------------------------------------------------------
3302 | Argument | Description
3303 -------------------------------------------------------------------------------
3304 f_pApiInstance Pointer to API instance. This memory is used to keep the
3305 present state of the chip and all its resources.
3306
3307 f_usChannelIndex Index of the echo cancellation channel in the API list.
3308
3309 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3310 #if !SKIP_Oct6100ApiReleaseChannelResources
3311 UINT32 Oct6100ApiReleaseChannelResources(
3312 IN tPOCT6100_INSTANCE_API f_pApiInstance,
3313 IN UINT16 f_usChannelIndex )
3314 {
3315 tPOCT6100_SHARED_INFO pSharedInfo;
3316 tPOCT6100_API_CHANNEL pChanEntry;
3317 tPOCT6100_API_CHANNEL_TDM pTdmConfig;
3318 tPOCT6100_API_TSST_ENTRY pTsstEntry;
3319 UINT32 ulResult;
3320 UINT16 usCurrentEntry;
3321 UINT32 ulTimeslot;
3322 UINT32 ulStream;
3323
3324 /* Obtain local pointer to shared portion of instance. */
3325 pSharedInfo = f_pApiInstance->pSharedInfo;
3326
3327 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChannelIndex );
3328
3329 /* Obtain local pointer to the TDM configurationof the channel */
3330 pTdmConfig = &pChanEntry->TdmConfig;
3331
3332 /* Release the two TSI chariot memory entries.*/
3333 ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usRinRoutTsiMemIndex );
3334 if ( ulResult != cOCT6100_ERR_OK )
3335 return cOCT6100_ERR_FATAL_2;
3336
3337 ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usSinSoutTsiMemIndex );
3338 if ( ulResult != cOCT6100_ERR_OK )
3339 return cOCT6100_ERR_FATAL_3;
3340
3341 /* Now release the ECHO channel and control memory entries.*/
3342 ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, f_usChannelIndex );
3343 if ( ulResult != cOCT6100_ERR_OK )
3344 return cOCT6100_ERR_FATAL_4;
3345
3346 /* Release the conversion resources.*/
3347 if ( pChanEntry->usRinRoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3348 {
3349 ulResult = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, pChanEntry->usRinRoutConversionMemIndex );
3350 if ( ulResult != cOCT6100_ERR_OK )
3351 return cOCT6100_ERR_FATAL_B9;
3352
3353 pChanEntry->usRinRoutConversionMemIndex = cOCT6100_INVALID_INDEX;
3354 }
3355
3356 if ( pChanEntry->usSinSoutConversionMemIndex != cOCT6100_INVALID_INDEX )
3357 {
3358 ulResult = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, pChanEntry->usSinSoutConversionMemIndex );
3359 if ( ulResult != cOCT6100_ERR_OK )
3360 return cOCT6100_ERR_FATAL_BA;
3361
3362 pChanEntry->usSinSoutConversionMemIndex = cOCT6100_INVALID_INDEX;
3363 }
3364
3365 /*=========================================================================*/
3366 /* Release the TSST control memory entries if any were reserved.*/
3367 if ( pTdmConfig->usRinTimeslot != cOCT6100_UNASSIGNED)
3368 {
3369 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3370 pTdmConfig->usRinTimeslot,
3371 pTdmConfig->usRinStream,
3372 pTdmConfig->byRinNumTssts,
3373 cOCT6100_INPUT_TSST,
3374 cOCT6100_INVALID_INDEX );
3375 if ( ulResult != cOCT6100_ERR_OK )
3376 return cOCT6100_ERR_FATAL_5;
3377 }
3378
3379 if ( pTdmConfig->usSinTimeslot != cOCT6100_UNASSIGNED)
3380 {
3381 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3382 pTdmConfig->usSinTimeslot,
3383 pTdmConfig->usSinStream,
3384 pTdmConfig->bySinNumTssts,
3385 cOCT6100_INPUT_TSST,
3386 cOCT6100_INVALID_INDEX );
3387 if ( ulResult != cOCT6100_ERR_OK )
3388 return cOCT6100_ERR_FATAL_6;
3389 }
3390
3391 /*=======================================================================*/
3392 /* Release all the TSSTs associated to the ROUT port of this channel. */
3393 if ( pTdmConfig->usRoutTimeslot != cOCT6100_UNASSIGNED)
3394 {
3395 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3396 pTdmConfig->usRoutTimeslot,
3397 pTdmConfig->usRoutStream,
3398 pTdmConfig->byRoutNumTssts,
3399 cOCT6100_OUTPUT_TSST,
3400 cOCT6100_INVALID_INDEX );
3401 if ( ulResult != cOCT6100_ERR_OK )
3402 return cOCT6100_ERR_FATAL_7;
3403 }
3404
3405 /* Now release the Broadcast TSSTs. */
3406 usCurrentEntry = pTdmConfig->usRoutBrdcastTsstFirstEntry;
3407 while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3408 {
3409 mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3410
3411 ulTimeslot = pTsstEntry->usTsstValue >> 5;
3412 ulStream = pTsstEntry->usTsstValue & 0x1F;
3413
3414 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3415 ulTimeslot,
3416 ulStream,
3417 cOCT6100_NUMBER_TSSTS_1,
3418 cOCT6100_OUTPUT_TSST,
3419 usCurrentEntry );
3420 if ( ulResult != cOCT6100_ERR_OK )
3421 return cOCT6100_ERR_FATAL_8;
3422
3423 /* Move to the next entry.*/
3424 usCurrentEntry = pTsstEntry->usNextEntry;
3425
3426 /* Invalidate the current entry.*/
3427 pTsstEntry->usTsstMemoryIndex = 0xFFFF;
3428 pTsstEntry->usTsstValue = 0xFFFF;
3429 pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
3430 }
3431
3432 /*=======================================================================*/
3433
3434
3435 /*=======================================================================*/
3436 /* Release all the TSSTs associated to the SOUT port of this channel. */
3437 if ( pTdmConfig->usSoutTimeslot != cOCT6100_UNASSIGNED)
3438 {
3439 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3440 pTdmConfig->usSoutTimeslot,
3441 pTdmConfig->usSoutStream,
3442 pTdmConfig->bySoutNumTssts,
3443 cOCT6100_OUTPUT_TSST,
3444 cOCT6100_INVALID_INDEX );
3445 if ( ulResult != cOCT6100_ERR_OK )
3446 return cOCT6100_ERR_FATAL_9;
3447 }
3448
3449 /* Now release the Broadcast TSSTs. */
3450 usCurrentEntry = pTdmConfig->usSoutBrdcastTsstFirstEntry;
3451 while( usCurrentEntry != cOCT6100_INVALID_INDEX )
3452 {
3453 mOCT6100_GET_TSST_LIST_ENTRY_PNT( pSharedInfo, pTsstEntry, usCurrentEntry );
3454
3455 ulTimeslot = pTsstEntry->usTsstValue >> 5;
3456 ulStream = pTsstEntry->usTsstValue & 0x1F;
3457
3458 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
3459 ulTimeslot,
3460 ulStream,
3461 cOCT6100_NUMBER_TSSTS_1,
3462 cOCT6100_OUTPUT_TSST,
3463 usCurrentEntry );
3464 if ( ulResult != cOCT6100_ERR_OK )
3465 return cOCT6100_ERR_FATAL_A;
3466
3467 /* Move to the next entry.*/
3468 usCurrentEntry = pTsstEntry->usNextEntry;
3469
3470 /* Invalidate the current entry.*/
3471 pTsstEntry->usTsstMemoryIndex = 0xFFFF;
3472 pTsstEntry->usTsstValue = 0xFFFF;
3473 pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
3474 }
3475 /*=======================================================================*/
3476
3477 /*=======================================================================*/
3478 /* Update the dependency of the phasing TSST if one is associated to the chanel.*/
3479
3480 if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
3481 {
3482 tPOCT6100_API_PHASING_TSST pPhasingEntry;
3483
3484 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, pChanEntry->usPhasingTsstIndex );
3485
3486 pPhasingEntry->usDependencyCnt--;
3487 }
3488 /*=======================================================================*/
3489
3490
3491 /*=======================================================================*/
3492 /* Release any resources reserved for the extended tone detection.*/
3493
3494 if ( pChanEntry->fEnableExtToneDetection == TRUE )
3495 {
3496 tPOCT6100_API_CHANNEL pExtToneChanEntry;
3497
3498 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pExtToneChanEntry, pChanEntry->usExtToneChanIndex );
3499
3500 /* Release the ECHO channel and control memory entries.*/
3501 ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, pChanEntry->usExtToneChanIndex );
3502 if ( ulResult != cOCT6100_ERR_OK )
3503 return cOCT6100_ERR_FATAL_C1;
3504
3505 ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pChanEntry->usExtToneTsiIndex );
3506 if ( ulResult != cOCT6100_ERR_OK )
3507 return cOCT6100_ERR_FATAL_C2;
3508
3509 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usExtToneMixerIndex );
3510 if ( ulResult != cOCT6100_ERR_OK )
3511 return cOCT6100_ERR_FATAL_C3;
3512
3513 /* Now release the channel entry */
3514 pExtToneChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED;
3515 pExtToneChanEntry->fReserved = FALSE;
3516
3517 /* Set the current entry to disable, just in case.*/
3518 pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED;
3519 }
3520 /*=======================================================================*/
3521
3522
3523 /*=======================================================================*/
3524 /* Update the channel's list entry. */
3525
3526 /* Clear the NLP dword array. */
3527 Oct6100UserMemSet( pChanEntry->aulNlpConfDword, 0, sizeof( pChanEntry->aulNlpConfDword ) );
3528
3529 /* Clear the echo operation mode. */
3530 pChanEntry->byEchoOperationMode = cOCT6100_ECHO_OP_MODE_POWER_DOWN;
3531
3532 /* Mark the channel as closed. */
3533 pChanEntry->fReserved = FALSE;
3534 pChanEntry->byEntryOpenCnt++;
3535
3536 /* Reset the port, the bridge and BidirInfo */
3537 pChanEntry->usMutedPorts = cOCT6100_CHANNEL_MUTE_PORT_NONE;
3538 pChanEntry->fBiDirChannel = FALSE;
3539 pChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
3540
3541 /* Decrement the number of channel open.*/
3542 f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels--;
3543
3544 /*=======================================================================*/
3545
3546 return cOCT6100_ERR_OK;
3547
3548 }
3549 #endif
3550
3551
3552
3553 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3554
3555 Function: Oct6100ChannelModifySer
3556
3557 Description: Modify an echo cancellation channel.
3558
3559 -------------------------------------------------------------------------------
3560 | Argument | Description
3561 -------------------------------------------------------------------------------
3562 f_pApiInstance Pointer to API instance. This memory is used to keep the
3563 present state of the chip and all its resources.
3564
3565 f_pChannelModify Pointer to channel configuration structure. The handle
3566 identifying the buffer in all future function calls is
3567 returned in this structure.
3568
3569 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3570 #if !SKIP_Oct6100ChannelModifySer
3571 UINT32 Oct6100ChannelModifySer(
3572 IN tPOCT6100_INSTANCE_API f_pApiInstance,
3573 IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify )
3574 {
3575 UINT16 usChanIndex;
3576 UINT32 ulResult;
3577 UINT16 usNewRinTsstIndex;
3578 UINT16 usNewSinTsstIndex;
3579 UINT16 usNewRoutTsstIndex;
3580 UINT16 usNewSoutTsstIndex;
3581 UINT8 fSinSoutCodecActive = FALSE;
3582 UINT8 fRinRoutCodecActive = FALSE;
3583 UINT16 usNewPhasingTsstIndex;
3584 tOCT6100_CHANNEL_OPEN *pTempChanOpen;
3585
3586 /* We don't want this 290 byte structure on the stack */
3587 pTempChanOpen = kmalloc(sizeof(*pTempChanOpen), GFP_ATOMIC);
3588 if (!pTempChanOpen)
3589 return cOCT6100_ERR_FATAL_0;
3590
3591 /* Check the user's configuration of the echo cancellation channel for errors. */
3592 ulResult = Oct6100ApiCheckChannelModify( f_pApiInstance,
3593 f_pChannelModify,
3594 pTempChanOpen,
3595 &usNewPhasingTsstIndex,
3596 &usChanIndex );
3597 if ( ulResult != cOCT6100_ERR_OK )
3598 goto out;
3599
3600 /* Reserve all resources needed by the echo cancellation channel. */
3601 ulResult = Oct6100ApiModifyChannelResources( f_pApiInstance,
3602 f_pChannelModify,
3603 usChanIndex,
3604 &usNewRinTsstIndex,
3605 &usNewSinTsstIndex,
3606 &usNewRoutTsstIndex,
3607 &usNewSoutTsstIndex );
3608 if ( ulResult != cOCT6100_ERR_OK )
3609 goto out;
3610
3611 /* Write all necessary structures to activate the echo cancellation channel. */
3612 ulResult = Oct6100ApiModifyChannelStructs( f_pApiInstance,
3613 f_pChannelModify,
3614 pTempChanOpen,
3615 usChanIndex,
3616 usNewPhasingTsstIndex,
3617 &fSinSoutCodecActive,
3618 &fRinRoutCodecActive,
3619 usNewRinTsstIndex,
3620 usNewSinTsstIndex,
3621 usNewRoutTsstIndex,
3622 usNewSoutTsstIndex );
3623 if ( ulResult != cOCT6100_ERR_OK )
3624 goto out;
3625
3626 /* Update the new echo cancellation channels's entry in the ECHO channel list. */
3627 ulResult = Oct6100ApiModifyChannelEntry( f_pApiInstance,
3628 f_pChannelModify,
3629 pTempChanOpen,
3630 usChanIndex,
3631 usNewPhasingTsstIndex,
3632 fSinSoutCodecActive,
3633 fRinRoutCodecActive,
3634 usNewRinTsstIndex,
3635 usNewSinTsstIndex,
3636 usNewRoutTsstIndex,
3637 usNewSoutTsstIndex );
3638 out:
3639 kfree(pTempChanOpen);
3640
3641 return ulResult;
3642 }
3643 #endif
3644
3645 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3646
3647 Function: Oct6100ApiCheckChannelModify
3648
3649 Description: Checks the user's echo cancellation channel modify structure for errors.
3650
3651 -------------------------------------------------------------------------------
3652 | Argument | Description
3653 -------------------------------------------------------------------------------
3654 f_pApiInstance Pointer to API instance. This memory is used to keep the
3655 present state of the chip and all its resources.
3656
3657 f_pChannelModify Pointer to echo cancellation channel modify structure.
3658 f_pTempChanOpen Pointer to a channel open structure.
3659 f_pusNewPhasingTsstIndex Pointer to a new phasing TSST index within the API instance.
3660 f_pusChanIndex Pointer to the channel index within the API instance channel list
3661
3662 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3663 #if !SKIP_Oct6100ApiCheckChannelModify
3664 UINT32 Oct6100ApiCheckChannelModify(
3665 IN tPOCT6100_INSTANCE_API f_pApiInstance,
3666 IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify,
3667 IN tPOCT6100_CHANNEL_OPEN f_pTempChanOpen,
3668 OUT PUINT16 f_pusNewPhasingTsstIndex,
3669 OUT PUINT16 f_pusChanIndex )
3670 {
3671 tPOCT6100_API_CHANNEL pChanEntry;
3672 UINT32 ulResult;
3673 UINT32 ulEntryOpenCnt;
3674 UINT32 ulDecoderNumTssts;
3675
3676 /* Check the provided handle. */
3677 if ( (f_pChannelModify->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
3678 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
3679
3680 *f_pusChanIndex = (UINT16)( f_pChannelModify->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
3681 if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
3682 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
3683
3684 /*=======================================================================*/
3685 /* Get a pointer to the channel's list entry. */
3686
3687 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
3688
3689 /* Extract the entry open count from the provided handle. */
3690 ulEntryOpenCnt = ( f_pChannelModify->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
3691
3692 /* Check for errors. */
3693 if ( pChanEntry->fReserved != TRUE )
3694 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
3695 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
3696 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
3697
3698 /*=======================================================================*/
3699
3700
3701 /*=======================================================================*/
3702 /* Check the general modify parameters. */
3703
3704 if ( f_pChannelModify->ulEchoOperationMode != cOCT6100_KEEP_PREVIOUS_SETTING &&
3705 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NORMAL &&
3706 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_FREEZE &&
3707 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET &&
3708 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN &&
3709 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL &&
3710 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION &&
3711 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
3712 return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE;
3713
3714 /* Check the 2100Hz echo disabling configuration.*/
3715 if ( f_pChannelModify->fEnableToneDisabler != cOCT6100_KEEP_PREVIOUS_SETTING &&
3716 f_pChannelModify->fEnableToneDisabler != TRUE &&
3717 f_pChannelModify->fEnableToneDisabler != FALSE )
3718 return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ENABLE;
3719
3720 /* Check the disable tone detection flag. */
3721 if ( f_pChannelModify->fDisableToneDetection != TRUE &&
3722 f_pChannelModify->fDisableToneDetection != FALSE )
3723 return cOCT6100_ERR_CHANNEL_DISABLE_TONE_DETECTION;
3724
3725 /* Check the stop buffer playout flag. */
3726 if ( f_pChannelModify->fStopBufferPlayout != TRUE &&
3727 f_pChannelModify->fStopBufferPlayout != FALSE )
3728 return cOCT6100_ERR_CHANNEL_STOP_BUFFER_PLAYOUT;
3729
3730 /* Check the remove conference bridge participant flag. */
3731 if ( f_pChannelModify->fRemoveConfBridgeParticipant != TRUE &&
3732 f_pChannelModify->fRemoveConfBridgeParticipant != FALSE )
3733 return cOCT6100_ERR_CHANNEL_REMOVE_CONF_BRIDGE_PARTICIPANT;
3734
3735 /* Check the remove broadcast timeslots flag. */
3736 if ( f_pChannelModify->fRemoveBroadcastTssts != TRUE &&
3737 f_pChannelModify->fRemoveBroadcastTssts != FALSE )
3738 return cOCT6100_ERR_CHANNEL_REMOVE_BROADCAST_TSSTS;
3739
3740 if ( f_pChannelModify->fCodecConfigModified != TRUE &&
3741 f_pChannelModify->fCodecConfigModified != FALSE )
3742 return cOCT6100_ERR_CHANNEL_MODIFY_CODEC_CONFIG;
3743
3744 if ( f_pChannelModify->fVqeConfigModified != TRUE &&
3745 f_pChannelModify->fVqeConfigModified != FALSE )
3746 return cOCT6100_ERR_CHANNEL_MODIFY_VQE_CONFIG;
3747
3748 if ( f_pChannelModify->fTdmConfigModified != TRUE &&
3749 f_pChannelModify->fTdmConfigModified != FALSE )
3750 return cOCT6100_ERR_CHANNEL_MODIFY_TDM_CONFIG;
3751
3752 /*=======================================================================*/
3753
3754 /*=======================================================================*/
3755 /* Verify if any law change was requested. If so reprogram all structures.*/
3756
3757 if (( f_pChannelModify->fTdmConfigModified == TRUE ) &&
3758 ( f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
3759 f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
3760 f_pChannelModify->TdmConfig.ulRoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
3761 f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ))
3762 {
3763 f_pChannelModify->fVqeConfigModified = TRUE;
3764 f_pChannelModify->fCodecConfigModified = TRUE;
3765 }
3766 /*=======================================================================*/
3767
3768 ulResult = Oct6100ApiUpdateOpenStruct( f_pApiInstance, f_pChannelModify, f_pTempChanOpen, pChanEntry );
3769 if ( ulResult != cOCT6100_ERR_OK )
3770 return ulResult;
3771
3772 /* All further check will now be performed using the TempOpenChan structure in order
3773 to reuse the checks written for the open channel structure.*/
3774
3775
3776
3777 /* Check the TDM config.*/
3778 if ( f_pChannelModify->fTdmConfigModified == TRUE )
3779 {
3780 tPOCT6100_CHANNEL_OPEN_TDM pOpenTdm;
3781
3782 pOpenTdm = &f_pTempChanOpen->TdmConfig;
3783
3784 ulResult = Oct6100ApiCheckTdmConfig( f_pApiInstance,
3785 pOpenTdm );
3786 if ( ulResult != cOCT6100_ERR_OK )
3787 return ulResult;
3788
3789 /* Check if that Stream and Timeslot values are valid.*/
3790
3791 /* Check the RIN port.*/
3792 if ( f_pChannelModify->TdmConfig.ulRinStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3793 f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3794 return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
3795
3796 if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3797 f_pChannelModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3798 return cOCT6100_ERR_CHANNEL_RIN_STREAM;
3799
3800 if ( pChanEntry->fBeingTapped == TRUE )
3801 {
3802 /* Check that the Rin stream + timeslot are not being assigned. */
3803 if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING )
3804 {
3805 if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_UNASSIGNED )
3806 return cOCT6100_ERR_CHANNEL_RIN_STREAM;
3807
3808 if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3809 return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
3810 }
3811 }
3812
3813 /* Check the SIN port.*/
3814 if ( f_pChannelModify->TdmConfig.ulSinStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3815 f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3816 return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT;
3817
3818 if ( f_pChannelModify->TdmConfig.ulSinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3819 f_pChannelModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3820 return cOCT6100_ERR_CHANNEL_SIN_STREAM;
3821
3822 /* Check the ROUT port.*/
3823 if ( f_pChannelModify->TdmConfig.ulRoutStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3824 f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3825 return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT;
3826
3827 if ( f_pChannelModify->TdmConfig.ulRoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3828 f_pChannelModify->TdmConfig.ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3829 return cOCT6100_ERR_CHANNEL_ROUT_STREAM;
3830
3831 /* Check the SOUT port.*/
3832 if ( f_pChannelModify->TdmConfig.ulSoutStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
3833 f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3834 return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
3835
3836 if ( f_pChannelModify->TdmConfig.ulSoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3837 f_pChannelModify->TdmConfig.ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3838 return cOCT6100_ERR_CHANNEL_SOUT_STREAM;
3839
3840 /* Verify if the channel is currently part of a bidirectional channel, and if */
3841 /* so perform the required checks. */
3842 if ( pChanEntry->fBiDirChannel == TRUE )
3843 {
3844 /* Check the ports that must remain unassigned.*/
3845 if ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3846 return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
3847 if ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED )
3848 return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
3849
3850 /* Check that no PCM law change is requested.*/
3851 if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
3852 return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
3853 if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
3854 return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
3855 }
3856
3857 /* If this channel is on a conference bridge, a few more things must be checked. */
3858 if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
3859 {
3860 /* If conferencing, law conversion cannot be applied. */
3861 /* This check is done only if both input and output ports are assigned. */
3862 if ( ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3863 && ( f_pTempChanOpen->TdmConfig.ulRoutTimeslot != cOCT6100_UNASSIGNED ) )
3864 {
3865 /* Laws must be the same! */
3866 if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
3867 return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
3868 }
3869
3870 /* Check for Sin. */
3871 if ( ( f_pTempChanOpen->TdmConfig.ulSinTimeslot != cOCT6100_UNASSIGNED )
3872 && ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED ) )
3873 {
3874 /* Laws must be the same! */
3875 if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
3876 return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
3877 }
3878
3879 /* Check if ADPCM is requested. */
3880 if ( f_pTempChanOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING &&
3881 f_pTempChanOpen->CodecConfig.ulEncodingRate != cOCT6100_G711_64KBPS )
3882 {
3883 /* No ADPCM in a conference bridge! */
3884 return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
3885 }
3886
3887 if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING &&
3888 f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS )
3889 {
3890 /* No ADPCM in a conference bridge! */
3891 return cOCT6100_ERR_CHANNEL_DECODING_RATE;
3892 }
3893 }
3894
3895 if ( f_pTempChanOpen->CodecConfig.ulEncoderPort == cOCT6100_NO_ENCODING ||
3896 f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_NO_DECODING )
3897 {
3898 /* Make sure no law conversion is attempted since it is not supported by the device.*/
3899 if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
3900 return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
3901 if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
3902 return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
3903 }
3904
3905 if ( pChanEntry->fEnableExtToneDetection == TRUE &&
3906 f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3907 return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT;
3908
3909 /* A few special checks must be done if the configuration is to be applied */
3910 /* to all opened channels. */
3911 if ( f_pChannelModify->fApplyToAllChannels == TRUE )
3912 {
3913 /* When the configuration to be applied is for all channels, */
3914 /* check that the stream and timeslot parameters are not being assigned. */
3915
3916 /* Check the Rout port. */
3917 if ( f_pChannelModify->TdmConfig.ulRoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3918 f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3919 {
3920 /* Check that the Rout ports is being unassigned. */
3921 if ( f_pTempChanOpen->TdmConfig.ulRoutStream != cOCT6100_UNASSIGNED )
3922 return cOCT6100_ERR_CHANNEL_ROUT_STREAM_UNASSIGN;
3923 if ( f_pTempChanOpen->TdmConfig.ulRoutTimeslot != cOCT6100_UNASSIGNED )
3924 return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT_UNASSIGN;
3925 }
3926
3927 /* Check the Rin port. */
3928 if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3929 f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3930 {
3931 /* Check that the Rin ports is being unassigned. */
3932 if ( f_pTempChanOpen->TdmConfig.ulRinStream != cOCT6100_UNASSIGNED )
3933 return cOCT6100_ERR_CHANNEL_RIN_STREAM_UNASSIGN;
3934 if ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
3935 return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT_UNASSIGN;
3936 }
3937
3938 /* Check the Sout port. */
3939 if ( f_pChannelModify->TdmConfig.ulSoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3940 f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3941 {
3942 /* Check that the Sout ports is being unassigned. */
3943 if ( f_pTempChanOpen->TdmConfig.ulSoutStream != cOCT6100_UNASSIGNED )
3944 return cOCT6100_ERR_CHANNEL_SOUT_STREAM_UNASSIGN;
3945 if ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED )
3946 return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT_UNASSIGN;
3947 }
3948
3949 /* Check the Sin port. */
3950 if ( f_pChannelModify->TdmConfig.ulSinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
3951 f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3952 {
3953 /* Check that the Sin ports is being unassigned. */
3954 if ( f_pTempChanOpen->TdmConfig.ulSinStream != cOCT6100_UNASSIGNED )
3955 return cOCT6100_ERR_CHANNEL_SIN_STREAM_UNASSIGN;
3956 if ( f_pTempChanOpen->TdmConfig.ulSinTimeslot != cOCT6100_UNASSIGNED )
3957 return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT_UNASSIGN;
3958 }
3959 }
3960 }
3961
3962 /* Check the VQE config.*/
3963 if ( f_pChannelModify->fVqeConfigModified == TRUE )
3964 {
3965 ulResult = Oct6100ApiCheckVqeConfig( f_pApiInstance,
3966 &f_pTempChanOpen->VqeConfig,
3967 f_pTempChanOpen->fEnableToneDisabler );
3968 if ( ulResult != cOCT6100_ERR_OK )
3969 return ulResult;
3970 }
3971
3972 /* Verify if the echo operation mode selected can be applied. */
3973 if ( ( f_pTempChanOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
3974 && ( f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE ) )
3975 return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
3976
3977 if ( ( f_pTempChanOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
3978 && ( f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE ) )
3979 return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
3980
3981 /* Comfort noise must be activated for speech recognition mode to work. */
3982 if ( ( f_pTempChanOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
3983 && ( f_pTempChanOpen->VqeConfig.ulComfortNoiseMode == cOCT6100_COMFORT_NOISE_OFF ) )
3984 return cOCT6100_ERR_CHANNEL_COMFORT_NOISE_REQUIRED;
3985
3986 /* Check the Codec config.*/
3987 if ( f_pChannelModify->fCodecConfigModified == TRUE )
3988 {
3989 if ( f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3990 ulDecoderNumTssts = f_pTempChanOpen->TdmConfig.ulRinNumTssts;
3991 else /* f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
3992 ulDecoderNumTssts = f_pTempChanOpen->TdmConfig.ulSinNumTssts;
3993
3994 ulResult = Oct6100ApiCheckCodecConfig( f_pApiInstance,
3995 &f_pTempChanOpen->CodecConfig,
3996 ulDecoderNumTssts,
3997 f_pusNewPhasingTsstIndex );
3998 if ( ulResult != cOCT6100_ERR_OK )
3999 return ulResult;
4000
4001
4002
4003 /* make sure that if silence suppression is activated, the NLP is enabled.*/
4004 if ( f_pTempChanOpen->CodecConfig.fEnableSilenceSuppression == TRUE && f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE )
4005 return cOCT6100_ERR_CHANNEL_SIL_SUP_NLP_MUST_BE_ENABLED;
4006
4007 /* Verify if the channel is currently part of a bidirectional channel, and if so perform
4008 the required checks.*/
4009 if ( pChanEntry->fBiDirChannel == TRUE )
4010 {
4011 /* Check the ports that must remain unassigned.*/
4012 if ( f_pTempChanOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING &&
4013 f_pTempChanOpen->CodecConfig.ulEncodingRate != cOCT6100_G711_64KBPS )
4014 return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
4015
4016 if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING &&
4017 f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS )
4018 return cOCT6100_ERR_CHANNEL_DECODING_RATE;
4019 }
4020
4021 }
4022 /*=======================================================================*/
4023
4024 return cOCT6100_ERR_OK;
4025 }
4026 #endif
4027
4028 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4029
4030 Function: Oct6100ApiModifyChannelResources
4031
4032 Description: Reserves any new resources needed for the channel
4033 -------------------------------------------------------------------------------
4034 | Argument | Description
4035 -------------------------------------------------------------------------------
4036 f_pApiInstance Pointer to API instance. This memory is used to keep the
4037 present state of the chip and all its resources.
4038
4039 f_pChannelModify Pointer to echo cancellation channel configuration structure.
4040 f_usChanIndex Allocated entry in ECHO channel list.
4041
4042 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4043 #if !SKIP_Oct6100ApiModifyChannelResources
4044 UINT32 Oct6100ApiModifyChannelResources(
4045 IN tPOCT6100_INSTANCE_API f_pApiInstance,
4046 IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify,
4047 IN UINT16 f_usChanIndex,
4048 OUT PUINT16 f_pusNewRinTsstIndex,
4049 OUT PUINT16 f_pusNewSinTsstIndex,
4050 OUT PUINT16 f_pusNewRoutTsstIndex,
4051 OUT PUINT16 f_pusNewSoutTsstIndex )
4052 {
4053 tPOCT6100_API_CHANNEL pChanEntry;
4054 tPOCT6100_SHARED_INFO pSharedInfo;
4055
4056 tPOCT6100_API_CHANNEL_TDM pApiTdmConf;
4057 tPOCT6100_CHANNEL_MODIFY_TDM pModifyTdmConf;
4058
4059 UINT32 ulResult = cOCT6100_ERR_OK;
4060 UINT32 ulTempVar = cOCT6100_ERR_OK;
4061 UINT32 ulFreeMixerEventCnt;
4062
4063 BOOL fRinReleased = FALSE;
4064 BOOL fSinReleased = FALSE;
4065 BOOL fRoutReleased = FALSE;
4066 BOOL fSoutReleased = FALSE;
4067
4068 BOOL fRinReserved = FALSE;
4069 BOOL fSinReserved = FALSE;
4070 BOOL fRoutReserved = FALSE;
4071 BOOL fSoutReserved = FALSE;
4072
4073 BOOL fReserveRin = FALSE;
4074 BOOL fReserveSin = FALSE;
4075 BOOL fReserveRout = FALSE;
4076 BOOL fReserveSout = FALSE;
4077
4078 BOOL fRinRoutConversionMemReserved = FALSE;
4079 BOOL fSinSoutConversionMemReserved = FALSE;
4080
4081
4082 UINT32 ulRinNumTssts = 1;
4083 UINT32 ulSinNumTssts = 1;
4084 UINT32 ulRoutNumTssts = 1;
4085 UINT32 ulSoutNumTssts = 1;
4086
4087 /* Obtain local pointer to shared portion of instance. */
4088 pSharedInfo = f_pApiInstance->pSharedInfo;
4089
4090 /* Obtain local pointer to the TDM configuration structure of the tPOCT6100_CHANNEL_MODIFY structure. */
4091 pModifyTdmConf = &f_pChannelModify->TdmConfig;
4092
4093 /*=======================================================================*/
4094 /* Get a pointer to the channel's list entry. */
4095 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
4096
4097 /* Obtain local pointer to the TDM configuration structure of the tPOCT6100_API_CHANNEL structure. */
4098 pApiTdmConf = &pChanEntry->TdmConfig;
4099
4100 /*===============================================================================*/
4101 /* Modify TSST resources if required.*/
4102 if ( f_pChannelModify->fTdmConfigModified == TRUE )
4103 {
4104 /* First release any entry that need to be released.*/
4105 if ( ( pModifyTdmConf->ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4106 || ( pModifyTdmConf->ulRinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4107 )
4108 {
4109 if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4110 {
4111 /* Release the previously reserved entry.*/
4112 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
4113 pChanEntry->TdmConfig.usRinTimeslot,
4114 pChanEntry->TdmConfig.usRinStream,
4115 pChanEntry->TdmConfig.byRinNumTssts,
4116 cOCT6100_INPUT_TSST,
4117 cOCT6100_INVALID_INDEX );
4118 if ( ulResult == cOCT6100_ERR_OK )
4119 {
4120 fRinReleased = TRUE;
4121 }
4122 }
4123
4124 fReserveRin = TRUE;
4125 }
4126
4127 /* Release SIN port.*/
4128 if ( ( ulResult == cOCT6100_ERR_OK )
4129 && ( ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4130 || ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4131 ) )
4132 {
4133 if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4134 {
4135 /* Release the previously reserved entry.*/
4136 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
4137 pChanEntry->TdmConfig.usSinTimeslot,
4138 pChanEntry->TdmConfig.usSinStream,
4139 pChanEntry->TdmConfig.bySinNumTssts,
4140 cOCT6100_INPUT_TSST,
4141 cOCT6100_INVALID_INDEX );
4142 if ( ulResult == cOCT6100_ERR_OK )
4143 {
4144 fSinReleased = TRUE;
4145 }
4146 }
4147
4148 fReserveSin = TRUE;
4149 }
4150
4151 /* Release ROUT port.*/
4152 if ( ( ulResult == cOCT6100_ERR_OK )
4153 && ( ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4154 || ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4155 ) )
4156 {
4157 if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
4158 {
4159 /* Release the previously reserved entry.*/
4160 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
4161 pChanEntry->TdmConfig.usRoutTimeslot,
4162 pChanEntry->TdmConfig.usRoutStream,
4163 pChanEntry->TdmConfig.byRoutNumTssts,
4164 cOCT6100_OUTPUT_TSST,
4165 cOCT6100_INVALID_INDEX );
4166 if ( ulResult == cOCT6100_ERR_OK )
4167 {
4168 fRoutReleased = TRUE;
4169 }
4170 }
4171
4172 fReserveRout = TRUE;
4173 }
4174
4175 /* Release the SOUT port.*/
4176 if ( ( ulResult == cOCT6100_ERR_OK )
4177 && ( ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4178 || ( pModifyTdmConf->ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4179 ) )
4180 {
4181 if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
4182 {
4183 /* Release the previously reserved entry.*/
4184 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
4185 pChanEntry->TdmConfig.usSoutTimeslot,
4186 pChanEntry->TdmConfig.usSoutStream,
4187 pChanEntry->TdmConfig.bySoutNumTssts,
4188 cOCT6100_OUTPUT_TSST,
4189 cOCT6100_INVALID_INDEX );
4190 if ( ulResult == cOCT6100_ERR_OK )
4191 {
4192 fSoutReleased = TRUE;
4193 }
4194 }
4195
4196 fReserveSout = TRUE;
4197 }
4198
4199 /* Now reserve any new entry required.*/
4200
4201 /* Modify RIN port.*/
4202 if ( ( fReserveRin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4203 {
4204 if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_UNASSIGNED )
4205 {
4206 /* Check what number of TSSTs should be reserved this time. */
4207 if ( pModifyTdmConf->ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4208 {
4209 ulRinNumTssts = pApiTdmConf->byRinNumTssts;
4210 }
4211 else /* if ( pModifyTdmConf->ulRinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4212 {
4213 /* New number of TSSTs. */
4214 ulRinNumTssts = pModifyTdmConf->ulRinNumTssts;
4215 }
4216
4217 if ( pModifyTdmConf->ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4218 {
4219 /* Reserve the new number of TSSTs. */
4220 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4221 pApiTdmConf->usRinTimeslot,
4222 pApiTdmConf->usRinStream,
4223 ulRinNumTssts,
4224 cOCT6100_INPUT_TSST,
4225 f_pusNewRinTsstIndex,
4226 NULL );
4227 }
4228 else /* if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4229 {
4230 /* Reserve the new TSST.*/
4231 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4232 pModifyTdmConf->ulRinTimeslot,
4233 pModifyTdmConf->ulRinStream,
4234 ulRinNumTssts,
4235 cOCT6100_INPUT_TSST,
4236 f_pusNewRinTsstIndex,
4237 NULL );
4238 if ( ulResult == cOCT6100_ERR_OK )
4239 {
4240 fRinReserved = TRUE;
4241 }
4242 }
4243 }
4244 else
4245 {
4246 *f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX;
4247 }
4248 }
4249 else
4250 {
4251 *f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX;
4252 }
4253
4254 /* Modify SIN port.*/
4255 if ( ( fReserveSin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4256 {
4257 if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_UNASSIGNED )
4258 {
4259 /* Check what number of TSSTs should be reserved this time. */
4260 if ( pModifyTdmConf->ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4261 {
4262 ulSinNumTssts = pApiTdmConf->bySinNumTssts;
4263 }
4264 else /* if ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4265 {
4266 /* New number of TSSTs. */
4267 ulSinNumTssts = pModifyTdmConf->ulSinNumTssts;
4268 }
4269
4270 if ( pModifyTdmConf->ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4271 {
4272 /* Reserve the new number of TSSTs. */
4273 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4274 pApiTdmConf->usSinTimeslot,
4275 pApiTdmConf->usSinStream,
4276 ulSinNumTssts,
4277 cOCT6100_INPUT_TSST,
4278 f_pusNewSinTsstIndex,
4279 NULL );
4280 }
4281 else /* if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4282 {
4283 /* Reserve the new TSST.*/
4284 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4285 pModifyTdmConf->ulSinTimeslot,
4286 pModifyTdmConf->ulSinStream,
4287 ulSinNumTssts,
4288 cOCT6100_INPUT_TSST,
4289 f_pusNewSinTsstIndex,
4290 NULL );
4291 if ( ulResult == cOCT6100_ERR_OK )
4292 {
4293 fSinReserved = TRUE;
4294 }
4295 }
4296 }
4297 else
4298 {
4299 *f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX;
4300 }
4301 }
4302 else
4303 {
4304 *f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX;
4305 }
4306
4307 /* Modify ROUT port.*/
4308 if ( ( fReserveRout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4309 {
4310 if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_UNASSIGNED )
4311 {
4312 /* Check what number of TSSTs should be reserved this time. */
4313 if ( pModifyTdmConf->ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4314 {
4315 ulRoutNumTssts = pApiTdmConf->byRoutNumTssts;
4316 }
4317 else /* if ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4318 {
4319 /* New number of TSSTs. */
4320 ulRoutNumTssts = pModifyTdmConf->ulRoutNumTssts;
4321 }
4322
4323 if ( pModifyTdmConf->ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4324 {
4325 /* Reserve the new number of TSSTs. */
4326 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4327 pApiTdmConf->usRoutTimeslot,
4328 pApiTdmConf->usRoutStream,
4329 ulRoutNumTssts,
4330 cOCT6100_OUTPUT_TSST,
4331 f_pusNewRoutTsstIndex,
4332 NULL );
4333 }
4334 else /* if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4335 {
4336 /* Reserve the new TSST.*/
4337 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4338 pModifyTdmConf->ulRoutTimeslot,
4339 pModifyTdmConf->ulRoutStream,
4340 ulRoutNumTssts,
4341 cOCT6100_OUTPUT_TSST,
4342 f_pusNewRoutTsstIndex,
4343 NULL );
4344 if ( ulResult == cOCT6100_ERR_OK )
4345 {
4346 fRoutReserved = TRUE;
4347 }
4348 }
4349 }
4350 else
4351 {
4352 *f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX;
4353 }
4354 }
4355 else
4356 {
4357 *f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX;
4358 }
4359
4360 /* Modify SOUT port.*/
4361 if ( ( fReserveSout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
4362 {
4363 if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_UNASSIGNED )
4364 {
4365 /* Check what number of TSSTs should be reserved this time. */
4366 if ( pModifyTdmConf->ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
4367 {
4368 ulSoutNumTssts = pApiTdmConf->bySoutNumTssts;
4369 }
4370 else /* if ( pModifyTdmConf->ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4371 {
4372 /* New number of TSSTs. */
4373 ulSoutNumTssts = pModifyTdmConf->ulSoutNumTssts;
4374 }
4375
4376 if ( pModifyTdmConf->ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
4377 {
4378 /* Reserve the new number of TSSTs. */
4379 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4380 pApiTdmConf->usSoutTimeslot,
4381 pApiTdmConf->usSoutStream,
4382 ulSoutNumTssts,
4383 cOCT6100_OUTPUT_TSST,
4384 f_pusNewSoutTsstIndex,
4385 NULL );
4386 }
4387 else /* if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
4388 {
4389 /* Reserve the new TSST.*/
4390 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
4391 pModifyTdmConf->ulSoutTimeslot,
4392 pModifyTdmConf->ulSoutStream,
4393 ulSoutNumTssts,
4394 cOCT6100_OUTPUT_TSST,
4395 f_pusNewSoutTsstIndex,
4396 NULL );
4397 if ( ulResult == cOCT6100_ERR_OK )
4398 {
4399 fSoutReserved = TRUE;
4400 }
4401 }
4402 }
4403 else
4404 {
4405 *f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX;
4406 }
4407 }
4408 else
4409 {
4410 *f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX;
4411 }
4412
4413
4414 }
4415
4416 if ( f_pChannelModify->fCodecConfigModified == TRUE )
4417 {
4418 if ( ulResult == cOCT6100_ERR_OK &&
4419 pChanEntry->usRinRoutConversionMemIndex == cOCT6100_INVALID_INDEX &&
4420 ( f_pChannelModify->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ||
4421 f_pChannelModify->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) )
4422 {
4423 /* Reserve an ADPCM memory block.*/
4424 ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usRinRoutConversionMemIndex );
4425 if ( ulResult == cOCT6100_ERR_OK )
4426 {
4427 fRinRoutConversionMemReserved = TRUE;
4428 }
4429 }
4430
4431 if ( ulResult == cOCT6100_ERR_OK &&
4432 pChanEntry->usSinSoutConversionMemIndex == cOCT6100_INVALID_INDEX &&
4433 ( f_pChannelModify->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT ||
4434 f_pChannelModify->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN ) )
4435 {
4436 /* Reserve an ADPCM memory block.*/
4437 ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usSinSoutConversionMemIndex );
4438 if ( ulResult == cOCT6100_ERR_OK )
4439 {
4440 fSinSoutConversionMemReserved = TRUE;
4441 }
4442 }
4443 }
4444
4445
4446 /*===============================================================================*/
4447 /* Check if there are a couple of mixer events available for us. */
4448
4449 if ( ulResult == cOCT6100_ERR_OK )
4450 {
4451 UINT32 ulMixerEventCntNeeded = 0;
4452
4453 /* Calculate how many mixer events are needed. */
4454 if ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX )
4455 {
4456 /* If the channel is in bidir mode, do not create the Rin silence event!!! */
4457 if ( pChanEntry->fBiDirChannel == FALSE )
4458 {
4459 if ( ( *f_pusNewRinTsstIndex == cOCT6100_INVALID_INDEX )
4460 && ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
4461 ulMixerEventCntNeeded++;
4462 }
4463 }
4464
4465 if ( ( *f_pusNewSinTsstIndex == cOCT6100_INVALID_INDEX )
4466 && ( pChanEntry->usSinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
4467 {
4468 ulMixerEventCntNeeded++;
4469 }
4470
4471 /* If at least 1 mixer event is needed, check if those are available. */
4472 if ( ulMixerEventCntNeeded != 0 )
4473 {
4474 ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt );
4475 if ( ulResult == cOCT6100_ERR_OK )
4476 {
4477 /* The API might need more mixer events if the ports have to be muted. */
4478 /* Check if these are available. */
4479 if ( ulFreeMixerEventCnt < ulMixerEventCntNeeded )
4480 {
4481 ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS;
4482 }
4483 }
4484 }
4485 }
4486
4487 /*===============================================================================*/
4488
4489 /* Verify if an error occured. */
4490 if ( ulResult != cOCT6100_ERR_OK )
4491 {
4492 /* Release any resources newly reserved.*/
4493 if ( fRinReserved == TRUE )
4494 {
4495 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
4496 pModifyTdmConf->ulRinTimeslot,
4497 pModifyTdmConf->ulRinStream,
4498 ulRinNumTssts,
4499 cOCT6100_INPUT_TSST,
4500 cOCT6100_INVALID_INDEX );
4501 if ( ulTempVar != cOCT6100_ERR_OK )
4502 return ulTempVar;
4503 }
4504
4505 /* For the SIN port.*/
4506 if ( fSinReserved == TRUE )
4507 {
4508 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
4509 pModifyTdmConf->ulSinTimeslot,
4510 pModifyTdmConf->ulSinStream,
4511 ulSinNumTssts,
4512 cOCT6100_INPUT_TSST,
4513 cOCT6100_INVALID_INDEX );
4514 if ( ulTempVar != cOCT6100_ERR_OK )
4515 return ulTempVar;
4516 }
4517
4518 /* For the ROUT port.*/
4519 if ( fRoutReserved == TRUE )
4520 {
4521 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
4522 pModifyTdmConf->ulRoutTimeslot,
4523 pModifyTdmConf->ulRoutStream,
4524 ulRoutNumTssts,
4525 cOCT6100_OUTPUT_TSST,
4526 cOCT6100_INVALID_INDEX );
4527 if ( ulTempVar != cOCT6100_ERR_OK )
4528 return ulTempVar;
4529 }
4530
4531 /* For the SOUT port.*/
4532 if ( fSoutReserved == TRUE )
4533 {
4534 ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
4535 pModifyTdmConf->ulSoutTimeslot,
4536 pModifyTdmConf->ulSoutStream,
4537 ulSoutNumTssts,
4538 cOCT6100_OUTPUT_TSST,
4539 cOCT6100_INVALID_INDEX );
4540 if ( ulTempVar != cOCT6100_ERR_OK )
4541 return ulTempVar;
4542 }
4543
4544 /* Now make sure any resources released gets reserved back again.*/
4545
4546 /* For the RIN port.*/
4547 if ( fRinReleased == TRUE )
4548 {
4549 /* Reserve the new TSST.*/
4550 ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance,
4551 pChanEntry->TdmConfig.usRinTimeslot,
4552 pChanEntry->TdmConfig.usRinStream,
4553 pChanEntry->TdmConfig.byRinNumTssts,
4554 cOCT6100_INPUT_TSST,
4555 &pChanEntry->usRinTsstIndex,
4556 NULL );
4557 if ( ulTempVar != cOCT6100_ERR_OK )
4558 return ulTempVar;
4559 }
4560
4561 /* For the SIN port.*/
4562 if ( fSinReleased == TRUE )
4563 {
4564 /* Reserve the new TSST.*/
4565 ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance,
4566 pChanEntry->TdmConfig.usSinTimeslot,
4567 pChanEntry->TdmConfig.usSinStream,
4568 pChanEntry->TdmConfig.bySinNumTssts,
4569 cOCT6100_INPUT_TSST,
4570 &pChanEntry->usSinTsstIndex,
4571 NULL );
4572 if ( ulTempVar != cOCT6100_ERR_OK )
4573 return ulTempVar;
4574 }
4575
4576 /* For the ROUT port.*/
4577 if ( fRoutReleased == TRUE )
4578 {
4579 /* Reserve the new TSST.*/
4580 ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance,
4581 pChanEntry->TdmConfig.usRoutTimeslot,
4582 pChanEntry->TdmConfig.usRoutStream,
4583 pChanEntry->TdmConfig.byRoutNumTssts,
4584 cOCT6100_OUTPUT_TSST,
4585 &pChanEntry->usRoutTsstIndex,
4586 NULL );
4587 if ( ulTempVar != cOCT6100_ERR_OK )
4588 return ulTempVar;
4589 }
4590
4591 /* For the SOUT port.*/
4592 if ( fSoutReleased == TRUE )
4593 {
4594 /* Reserve the new TSST.*/
4595 ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance,
4596 pChanEntry->TdmConfig.usSoutTimeslot,
4597 pChanEntry->TdmConfig.usSoutStream,
4598 pChanEntry->TdmConfig.bySoutNumTssts,
4599 cOCT6100_OUTPUT_TSST,
4600 &pChanEntry->usSoutTsstIndex,
4601 NULL );
4602 if ( ulTempVar != cOCT6100_ERR_OK )
4603 return ulTempVar;
4604 }
4605
4606 /* Release the conversion memories if they were reserved.*/
4607 if ( fRinRoutConversionMemReserved == TRUE )
4608 {
4609 ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
4610 pChanEntry->usRinRoutConversionMemIndex );
4611 if ( ulTempVar != cOCT6100_ERR_OK )
4612 return ulTempVar;
4613 }
4614
4615 if ( fSinSoutConversionMemReserved == TRUE )
4616 {
4617 ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
4618 pChanEntry->usSinSoutConversionMemIndex );
4619 if ( ulTempVar != cOCT6100_ERR_OK )
4620 return ulTempVar;
4621 }
4622
4623 /* Now return the error.*/
4624 return ulResult;
4625 }
4626
4627 return cOCT6100_ERR_OK;
4628 }
4629 #endif
4630
4631
4632 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4633
4634 Function: Oct6100ApiModifyChannelStructs
4635
4636 Description: Performs all the required structure writes to configure the
4637 echo cancellation channel based on the new modifications.
4638
4639 -------------------------------------------------------------------------------
4640 | Argument | Description
4641 -------------------------------------------------------------------------------
4642 f_pApiInstance Pointer to API instance. This memory is used to keep the
4643 present state of the chip and all its resources.
4644
4645 f_pChannelModify Pointer to echo cancellation channel configuration structure.
4646 f_pChannelOpen Pointer to a structure used to store the multiple resources indexes.
4647 f_usChanIndex Index of the channel within the API's channel list.
4648 f_usNewPhasingTsstIndex Index of the new phasing TSST.
4649 f_pfSinSoutCodecActive Pointer to the state of the SIN/SOUT codec.
4650 f_pfRinRoutCodecActive Pointer to the state of the RIN/ROUT codec.
4651 f_usNewRinTsstIndex New RIN TSST memory index.
4652 f_usNewSinTsstIndex New SIN TSST memory index.
4653 f_usNewRoutTsstIndex New ROUT TSST memory index.
4654 f_usNewSoutTsstIndex New SOUT TSST memory index.
4655
4656 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4657 #if !SKIP_Oct6100ApiModifyChannelStructs
4658 UINT32 Oct6100ApiModifyChannelStructs(
4659 IN tPOCT6100_INSTANCE_API f_pApiInstance,
4660 IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify,
4661 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
4662 IN UINT16 f_usChanIndex,
4663 IN UINT16 f_usNewPhasingTsstIndex,
4664 OUT PUINT8 f_pfSinSoutCodecActive,
4665 OUT PUINT8 f_pfRinRoutCodecActive,
4666 IN UINT16 f_usNewRinTsstIndex,
4667 IN UINT16 f_usNewSinTsstIndex,
4668 IN UINT16 f_usNewRoutTsstIndex,
4669 IN UINT16 f_usNewSoutTsstIndex )
4670 {
4671 tPOCT6100_API_CHANNEL pChanEntry;
4672 tPOCT6100_SHARED_INFO pSharedInfo;
4673 tOCT6100_READ_PARAMS ReadParams;
4674 tOCT6100_WRITE_PARAMS WriteParams;
4675 tPOCT6100_API_CHANNEL_CODEC pApiCodecConf;
4676 tPOCT6100_API_CHANNEL_TDM pApiTdmConf;
4677
4678 UINT32 ulResult;
4679 UINT16 usReadData;
4680
4681 UINT16 usSinTsstIndex;
4682 UINT16 usRinTsstIndex;
4683
4684 UINT32 ulToneConfIndex;
4685 BOOL fClearPlayoutPointers = FALSE;
4686
4687
4688
4689 /* Obtain local pointer to shared portion of instance. */
4690 pSharedInfo = f_pApiInstance->pSharedInfo;
4691
4692 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4693
4694 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
4695
4696 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
4697
4698 ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
4699 ReadParams.pusReadData = &usReadData;
4700
4701 /*=======================================================================*/
4702 /* Get a pointer to the channel's list entry. */
4703 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
4704
4705 /* Obtain local pointer to the configuration structures of the tPOCT6100_API_CHANNEL structure. */
4706 pApiCodecConf = &pChanEntry->CodecConfig;
4707 pApiTdmConf = &pChanEntry->TdmConfig;
4708
4709 /*=======================================================================*/
4710 /* Init the RIN and SIN TSST index */
4711
4712 usRinTsstIndex = pChanEntry->usRinTsstIndex;
4713 usSinTsstIndex = pChanEntry->usSinTsstIndex;
4714
4715
4716 /*==============================================================================*/
4717 /* Clear the TSST that will be release.*/
4718
4719 if ( f_pChannelModify->fTdmConfigModified == TRUE )
4720 {
4721 /* Modify RIN port.*/
4722 if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4723 {
4724 if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4725 {
4726 /* Clear the previous entry */
4727 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usRinTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4728 WriteParams.usWriteData = 0x0000;
4729
4730 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4731 if ( ulResult != cOCT6100_ERR_OK )
4732 return ulResult;
4733 }
4734 }
4735
4736 /* Modify SIN port.*/
4737 if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4738 {
4739 if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4740 {
4741 /* Clear the previous entry */
4742 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usSinTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4743 WriteParams.usWriteData = 0x0000;
4744
4745 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4746 if ( ulResult != cOCT6100_ERR_OK )
4747 return ulResult;
4748 }
4749 }
4750
4751 /* Modify ROUT port.*/
4752 if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4753 {
4754 if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
4755 {
4756 /* Clear the previous entry */
4757 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usRoutTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4758 WriteParams.usWriteData = 0x0000;
4759
4760 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4761 if ( ulResult != cOCT6100_ERR_OK )
4762 return ulResult;
4763 }
4764 }
4765
4766 /* Modify SOUT port.*/
4767 if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING)
4768 {
4769 if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
4770 {
4771 /* Clear the previous entry */
4772 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usSoutTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4773 WriteParams.usWriteData = 0x0000;
4774
4775 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4776 if ( ulResult != cOCT6100_ERR_OK )
4777 return ulResult;
4778 }
4779 }
4780 }
4781 /*==============================================================================*/
4782
4783
4784 /*==============================================================================*/
4785 /* Now, Configure the Tsst control memory.*/
4786
4787 if ( f_pChannelModify->fTdmConfigModified == TRUE )
4788 {
4789 /* Modify RIN port.*/
4790 if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4791 {
4792 usRinTsstIndex = f_usNewRinTsstIndex;
4793
4794 if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX )
4795 {
4796 if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX )
4797 {
4798 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4799 f_usNewRinTsstIndex,
4800 pChanEntry->usExtraRinTsiMemIndex,
4801 f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4802 if ( ulResult != cOCT6100_ERR_OK )
4803 return ulResult;
4804 }
4805 else
4806 {
4807 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4808 f_usNewRinTsstIndex,
4809 pChanEntry->usRinRoutTsiMemIndex,
4810 f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4811 if ( ulResult != cOCT6100_ERR_OK )
4812 return ulResult;
4813 }
4814 }
4815 }
4816 if ( f_pChannelModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING &&
4817 f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
4818 {
4819 if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX )
4820 {
4821 if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4822 {
4823 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4824 pChanEntry->usRinTsstIndex,
4825 pChanEntry->usExtraRinTsiMemIndex,
4826 f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4827 if ( ulResult != cOCT6100_ERR_OK )
4828 return ulResult;
4829 }
4830 }
4831 else
4832 {
4833 if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
4834 {
4835 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4836 pChanEntry->usRinTsstIndex,
4837 pChanEntry->usRinRoutTsiMemIndex,
4838 f_pChannelOpen->TdmConfig.ulRinPcmLaw );
4839 if ( ulResult != cOCT6100_ERR_OK )
4840 return ulResult;
4841 }
4842 }
4843 }
4844
4845 /* Modify SIN port.*/
4846 if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4847 {
4848 usSinTsstIndex = f_usNewSinTsstIndex;
4849
4850 if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX )
4851 {
4852 if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
4853 {
4854 /* Write the new entry now.*/
4855 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4856 f_usNewSinTsstIndex,
4857 pChanEntry->usExtraSinTsiMemIndex,
4858 f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4859 if ( ulResult != cOCT6100_ERR_OK )
4860 return ulResult;
4861 }
4862 else
4863 {
4864 /* Write the new entry now.*/
4865 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4866 f_usNewSinTsstIndex,
4867 pChanEntry->usSinSoutTsiMemIndex,
4868 f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4869 if ( ulResult != cOCT6100_ERR_OK )
4870 return ulResult;
4871 }
4872 }
4873 }
4874 if ( f_pChannelModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING &&
4875 f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
4876 {
4877 if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
4878 {
4879 if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4880 {
4881 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4882 pChanEntry->usSinTsstIndex ,
4883 pChanEntry->usExtraSinTsiMemIndex,
4884 f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4885 if ( ulResult != cOCT6100_ERR_OK )
4886 return ulResult;
4887 }
4888 }
4889 else
4890 {
4891 if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
4892 {
4893 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
4894 pChanEntry->usSinTsstIndex ,
4895 pChanEntry->usSinSoutTsiMemIndex,
4896 f_pChannelOpen->TdmConfig.ulSinPcmLaw );
4897 if ( ulResult != cOCT6100_ERR_OK )
4898 return ulResult;
4899 }
4900 }
4901 }
4902
4903 /* Modify ROUT port.*/
4904 if ( ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4905 || ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4906 )
4907 {
4908 if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX )
4909 {
4910 if ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4911 {
4912 /* If this output port is not muted. */
4913 if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 )
4914 {
4915 /* Write the new entry now.*/
4916 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
4917 f_usNewRoutTsstIndex,
4918 pApiCodecConf->byAdpcmNibblePosition,
4919 f_pChannelModify->TdmConfig.ulRoutNumTssts,
4920 pChanEntry->usRinRoutTsiMemIndex );
4921 if ( ulResult != cOCT6100_ERR_OK )
4922 return ulResult;
4923 }
4924 }
4925 else
4926 {
4927 /* If this output port is not muted. */
4928 if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 )
4929 {
4930 /* Write the new entry now.*/
4931 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
4932 f_usNewRoutTsstIndex,
4933 pApiCodecConf->byAdpcmNibblePosition,
4934 pApiTdmConf->byRoutNumTssts,
4935 pChanEntry->usRinRoutTsiMemIndex );
4936 if ( ulResult != cOCT6100_ERR_OK )
4937 return ulResult;
4938 }
4939 }
4940 }
4941 }
4942
4943 /* Modify SOUT port.*/
4944 if ( ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4945 || ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4946 )
4947 {
4948 if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX )
4949 {
4950 if ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
4951 {
4952 /* If this output port is not muted. */
4953 if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 )
4954 {
4955 /* Write the new entry now.*/
4956 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
4957 f_usNewSoutTsstIndex,
4958 pApiCodecConf->byAdpcmNibblePosition,
4959 f_pChannelModify->TdmConfig.ulSoutNumTssts,
4960 pChanEntry->usSinSoutTsiMemIndex );
4961
4962 if ( ulResult != cOCT6100_ERR_OK )
4963 return ulResult;
4964 }
4965 }
4966 else
4967 {
4968 /* If this output port is not muted. */
4969 if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 )
4970 {
4971 /* Write the new entry now.*/
4972 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
4973 f_usNewSoutTsstIndex,
4974 pApiCodecConf->byAdpcmNibblePosition,
4975 pApiTdmConf->bySoutNumTssts,
4976 pChanEntry->usSinSoutTsiMemIndex );
4977
4978 if ( ulResult != cOCT6100_ERR_OK )
4979 return ulResult;
4980 }
4981 }
4982 }
4983 }
4984
4985
4986
4987 }
4988
4989 /*==============================================================================*/
4990
4991
4992 /*==============================================================================*/
4993 /* Modify the Encoder/Decoder memory if required.*/
4994
4995 if ( f_pChannelModify->fCodecConfigModified == TRUE )
4996 {
4997 UINT32 ulCompType = 0;
4998 UINT16 usTempTsiMemIndex;
4999 UINT16 usDecoderMemIndex;
5000 UINT16 usEncoderMemIndex;
5001 UINT32 ulPcmLaw;
5002 UINT16 usPhasingIndex;
5003 BOOL fModifyAdpcmMem = TRUE;
5004
5005 /*==============================================================================*/
5006 /* Reprogram the Decoder memory.*/
5007
5008 if ( pChanEntry->CodecConfig.byDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5009 {
5010 usDecoderMemIndex = pChanEntry->usRinRoutConversionMemIndex;
5011 }
5012 else
5013 {
5014 usDecoderMemIndex = pChanEntry->usSinSoutConversionMemIndex;
5015 }
5016
5017 if ( pChanEntry->CodecConfig.byEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5018 {
5019 usEncoderMemIndex = pChanEntry->usRinRoutConversionMemIndex;
5020 }
5021 else
5022 {
5023 usEncoderMemIndex = pChanEntry->usSinSoutConversionMemIndex;
5024 }
5025
5026 if ( usDecoderMemIndex != cOCT6100_INVALID_INDEX )
5027 {
5028 switch( f_pChannelOpen->CodecConfig.ulDecodingRate )
5029 {
5030 case cOCT6100_G711_64KBPS:
5031 ulCompType = 0x8;
5032
5033 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5034 {
5035 if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw )
5036 fModifyAdpcmMem = FALSE;
5037
5038 /* Check if both ports are assigned. If not, no law conversion needed here.. */
5039 if ( ( f_pChannelOpen->TdmConfig.ulRinStream == cOCT6100_UNASSIGNED )
5040 || ( f_pChannelOpen->TdmConfig.ulRoutStream == cOCT6100_UNASSIGNED ) )
5041 fModifyAdpcmMem = FALSE;
5042 }
5043 else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
5044 {
5045 if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
5046 fModifyAdpcmMem = FALSE;
5047
5048 /* Check if both ports are assigned. If not, no law conversion needed here.. */
5049 if ( ( f_pChannelOpen->TdmConfig.ulSinStream == cOCT6100_UNASSIGNED )
5050 || ( f_pChannelOpen->TdmConfig.ulSoutStream == cOCT6100_UNASSIGNED ) )
5051 fModifyAdpcmMem = FALSE;
5052 }
5053
5054 break;
5055 case cOCT6100_G726_40KBPS:
5056 ulCompType = 0x3;
5057 break;
5058
5059 case cOCT6100_G726_32KBPS:
5060 ulCompType = 0x2;
5061 break;
5062
5063 case cOCT6100_G726_24KBPS:
5064 ulCompType = 0x1;
5065 break;
5066
5067 case cOCT6100_G726_16KBPS:
5068 ulCompType = 0x0;
5069 break;
5070
5071 case cOCT6100_G727_2C_ENCODED:
5072 ulCompType = 0x4;
5073 break;
5074
5075 case cOCT6100_G727_3C_ENCODED:
5076 ulCompType = 0x5;
5077 break;
5078
5079 case cOCT6100_G727_4C_ENCODED:
5080 ulCompType = 0x6;
5081 break;
5082
5083 case cOCT6100_G726_ENCODED:
5084 ulCompType = 0x9;
5085 break;
5086
5087 case cOCT6100_G711_G726_ENCODED:
5088 ulCompType = 0xA;
5089 break;
5090
5091 case cOCT6100_G711_G727_2C_ENCODED:
5092 ulCompType = 0xC;
5093 break;
5094
5095 case cOCT6100_G711_G727_3C_ENCODED:
5096 ulCompType = 0xD;
5097 break;
5098
5099 case cOCT6100_G711_G727_4C_ENCODED:
5100 ulCompType = 0xE;
5101 break;
5102
5103 default:
5104 return cOCT6100_ERR_FATAL_D6;
5105 }
5106
5107 if ( fModifyAdpcmMem == TRUE )
5108 {
5109 /* Set the chariot memory based on the selected port.*/
5110 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5111 {
5112 usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
5113 ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw; /* Set the law for later use */
5114
5115 /* Flag the entry as active.*/
5116 *f_pfRinRoutCodecActive = TRUE;
5117 }
5118 else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
5119 {
5120 usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
5121 ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw; /* Set the law for later use */
5122
5123 /* Flag the entry as active.*/
5124 *f_pfSinSoutCodecActive = TRUE;
5125 }
5126
5127 ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance,
5128 usDecoderMemIndex,
5129 ulCompType,
5130 usTempTsiMemIndex,
5131 ulPcmLaw,
5132 pApiCodecConf->byAdpcmNibblePosition );
5133 if ( ulResult != cOCT6100_ERR_OK )
5134 return ulResult;
5135 }
5136 else
5137 {
5138 ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance,
5139 usDecoderMemIndex );
5140 if ( ulResult != cOCT6100_ERR_OK )
5141 return ulResult;
5142
5143 /* Flag the entry as deactivated.*/
5144 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5145 {
5146 *f_pfRinRoutCodecActive = FALSE;
5147 }
5148 else
5149 {
5150 *f_pfSinSoutCodecActive = FALSE;
5151 }
5152 }
5153 }
5154
5155 /*==============================================================================*/
5156
5157
5158
5159
5160 /*==============================================================================*/
5161 /* Reprogram the Encoder memory.*/
5162
5163 if ( usEncoderMemIndex != cOCT6100_INVALID_INDEX )
5164 {
5165
5166 fModifyAdpcmMem = TRUE;
5167
5168 /* Set the chariot memory based on the selected port.*/
5169 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5170 {
5171 usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
5172 ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw; /* Set the law for later use */
5173 }
5174 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5175 {
5176 usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
5177 ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw; /* Set the law for later use */
5178 }
5179
5180 /* Set the phasing index .*/
5181 if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX )
5182 usPhasingIndex = f_usNewPhasingTsstIndex;
5183 else
5184 usPhasingIndex = pChanEntry->usPhasingTsstIndex;
5185
5186 switch( f_pChannelOpen->CodecConfig.ulEncodingRate )
5187 {
5188 case cOCT6100_G711_64KBPS:
5189 if ( ulPcmLaw == cOCT6100_PCM_U_LAW )
5190 ulCompType = 0x4;
5191 else /* ulPcmLaw == cOCT6100_PCM_A_LAW */
5192 ulCompType = 0x5;
5193
5194 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5195 {
5196 if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw )
5197 fModifyAdpcmMem = FALSE;
5198
5199 /* Check if both ports are assigned. If not, no law conversion needed here.. */
5200 if ( ( f_pChannelOpen->TdmConfig.ulRinStream == cOCT6100_UNASSIGNED )
5201 || ( f_pChannelOpen->TdmConfig.ulRoutStream == cOCT6100_UNASSIGNED ) )
5202 fModifyAdpcmMem = FALSE;
5203 }
5204 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5205 {
5206 if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
5207 fModifyAdpcmMem = FALSE;
5208
5209 /* Check if both ports are assigned. If not, no law conversion needed here.. */
5210 if ( ( f_pChannelOpen->TdmConfig.ulSinStream == cOCT6100_UNASSIGNED )
5211 || ( f_pChannelOpen->TdmConfig.ulSoutStream == cOCT6100_UNASSIGNED ) )
5212 fModifyAdpcmMem = FALSE;
5213 }
5214 break;
5215 case cOCT6100_G726_40KBPS:
5216 ulCompType = 0x3;
5217 break;
5218
5219 case cOCT6100_G726_32KBPS:
5220 ulCompType = 0x2;
5221 break;
5222
5223 case cOCT6100_G726_24KBPS:
5224 ulCompType = 0x1;
5225 break;
5226
5227 case cOCT6100_G726_16KBPS:
5228 ulCompType = 0x0;
5229 break;
5230
5231 case cOCT6100_G727_40KBPS_4_1:
5232 ulCompType = 0xD;
5233 break;
5234
5235 case cOCT6100_G727_40KBPS_3_2:
5236 ulCompType = 0xA;
5237 break;
5238
5239 case cOCT6100_G727_40KBPS_2_3:
5240 ulCompType = 0x6;
5241 break;
5242
5243 case cOCT6100_G727_32KBPS_4_0:
5244 ulCompType = 0xE;
5245 break;
5246
5247 case cOCT6100_G727_32KBPS_3_1:
5248 ulCompType = 0xB;
5249 break;
5250
5251 case cOCT6100_G727_32KBPS_2_2:
5252 ulCompType = 0x7;
5253 break;
5254
5255 case cOCT6100_G727_24KBPS_3_0:
5256 ulCompType = 0xC;
5257 break;
5258
5259 case cOCT6100_G727_24KBPS_2_1:
5260 ulCompType = 0x8;
5261 break;
5262
5263 case cOCT6100_G727_16KBPS_2_0:
5264 ulCompType = 0x9;
5265 break;
5266
5267 default:
5268 return cOCT6100_ERR_FATAL_D7;
5269 }
5270
5271 if ( fModifyAdpcmMem == TRUE )
5272 {
5273 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5274 {
5275 *f_pfRinRoutCodecActive = TRUE;
5276 }
5277 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5278 {
5279 *f_pfSinSoutCodecActive = TRUE;
5280 }
5281
5282 ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance,
5283 usEncoderMemIndex,
5284 ulCompType,
5285 usTempTsiMemIndex,
5286 f_pChannelOpen->CodecConfig.fEnableSilenceSuppression,
5287 pApiCodecConf->byAdpcmNibblePosition,
5288 usPhasingIndex,
5289 f_pChannelOpen->CodecConfig.ulPhasingType,
5290 f_pChannelOpen->CodecConfig.ulPhase );
5291
5292 if ( ulResult != cOCT6100_ERR_OK )
5293 return ulResult;
5294 }
5295 else
5296 {
5297 ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance,
5298 usEncoderMemIndex );
5299 if ( ulResult != cOCT6100_ERR_OK )
5300 return ulResult;
5301
5302 if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
5303 {
5304 *f_pfRinRoutCodecActive = FALSE;
5305 }
5306 else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
5307 {
5308 *f_pfSinSoutCodecActive = FALSE;
5309 }
5310 }
5311 }
5312
5313 /*==============================================================================*/
5314 }
5315
5316
5317
5318
5319 /*==============================================================================*/
5320 /* Modify the VQE parameter if required.*/
5321
5322 if ( ( f_pChannelModify->fVqeConfigModified == TRUE )
5323 || ( (UINT8)f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode )
5324 || ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) )
5325 {
5326 ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance,
5327 &f_pChannelOpen->VqeConfig,
5328 f_pChannelOpen,
5329 f_usChanIndex,
5330 pChanEntry->usEchoMemIndex,
5331 FALSE,
5332 TRUE );
5333 if ( ulResult != cOCT6100_ERR_OK )
5334 return ulResult;
5335 }
5336
5337 /*==============================================================================*/
5338 /* Modify the Echo memory if required.*/
5339 if ( f_pChannelModify->fEnableToneDisabler != cOCT6100_KEEP_PREVIOUS_SETTING ||
5340 f_pChannelModify->ulEchoOperationMode != cOCT6100_KEEP_PREVIOUS_SETTING ||
5341 f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
5342 f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
5343 f_pChannelModify->TdmConfig.ulRoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
5344 f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
5345 {
5346 ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance,
5347 &f_pChannelOpen->TdmConfig,
5348 f_pChannelOpen,
5349 pChanEntry->usEchoMemIndex,
5350 pChanEntry->usRinRoutTsiMemIndex,
5351 pChanEntry->usSinSoutTsiMemIndex );
5352 if ( ulResult != cOCT6100_ERR_OK )
5353 return ulResult;
5354
5355 /* Synch all the buffer playout field if needed by echo operation mode. */
5356 /* Note that Oct6100ApiWriteVqeMemory does not clear the playout pointers */
5357 /* since the flag is set to FALSE. */
5358 if ( ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE )
5359 && ( ( f_pChannelModify->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_HT_FREEZE )
5360 || ( f_pChannelModify->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_POWER_DOWN ) ) )
5361 {
5362 /* Buffer playout must be stopped. */
5363 fClearPlayoutPointers = TRUE;
5364 }
5365 }
5366
5367 /*==============================================================================*/
5368 /* Modify the Mixer events if law changes are requested. */
5369
5370 if ( pChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX &&
5371 f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
5372 {
5373 ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
5374
5375 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5376 if ( ulResult != cOCT6100_ERR_OK )
5377 return ulResult;
5378
5379 /* Modify the value according to the new law.*/
5380 if ( f_pChannelModify->TdmConfig.ulSinPcmLaw == cOCT6100_PCM_A_LAW )
5381 WriteParams.usWriteData = (UINT16)( usReadData | ( f_pChannelModify->TdmConfig.ulSinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET ));
5382 else
5383 WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )));
5384
5385 /* Write back the new value.*/
5386 WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
5387
5388 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5389 if ( ulResult != cOCT6100_ERR_OK )
5390 return ulResult;
5391 }
5392
5393 if ( pChanEntry->usSoutCopyEventIndex != cOCT6100_INVALID_INDEX &&
5394 f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
5395 {
5396 ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
5397
5398 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
5399 if ( ulResult != cOCT6100_ERR_OK )
5400 return ulResult;
5401
5402 /* Modify the value according to the new law.*/
5403 if ( f_pChannelModify->TdmConfig.ulSoutPcmLaw == cOCT6100_PCM_A_LAW )
5404 WriteParams.usWriteData = (UINT16)( usReadData | ( f_pChannelModify->TdmConfig.ulSoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET ));
5405 else
5406 WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )));
5407
5408 /* Write back the new value.*/
5409 WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
5410
5411 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
5412 if ( ulResult != cOCT6100_ERR_OK )
5413 return ulResult;
5414 }
5415
5416 /*==============================================================================*/
5417 /* Mute channel if required, this is done on a port basis */
5418
5419 ulResult = Oct6100ApiMutePorts( f_pApiInstance,
5420 f_usChanIndex,
5421 usRinTsstIndex,
5422 usSinTsstIndex,
5423 TRUE );
5424 if ( ulResult != cOCT6100_ERR_OK )
5425 return ulResult;
5426
5427 /*==============================================================================*/
5428
5429 /* Completely disable tone detection? */
5430 if ( f_pChannelModify->fDisableToneDetection == TRUE )
5431 {
5432 /* Check if tone detection has been enabled on this channel. */
5433 for (ulToneConfIndex = 0; ulToneConfIndex < ARRAY_SIZE(pChanEntry->aulToneConf); ulToneConfIndex++)
5434 {
5435 /* Check if some tone has been activated on this channel. */
5436 if ( pChanEntry->aulToneConf[ ulToneConfIndex ] != 0 )
5437 {
5438 tOCT6100_TONE_DETECTION_DISABLE ToneDetectDisable;
5439
5440 /* Call the default function to make sure all parameters are assigned default values. */
5441 ulResult = Oct6100ToneDetectionDisableDef( &ToneDetectDisable );
5442 if ( ulResult != cOCT6100_ERR_OK )
5443 return ulResult;
5444
5445 /* Form channel handle. */
5446 ToneDetectDisable.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5447
5448 /* Disable all tones activated on this channel. */
5449 ToneDetectDisable.fDisableAll = TRUE;
5450
5451 /* Call tone detection serialized function. */
5452 ulResult = Oct6100ToneDetectionDisableSer( f_pApiInstance, &ToneDetectDisable );
5453 if ( ulResult != cOCT6100_ERR_OK )
5454 return ulResult;
5455
5456 /* Get out of the loop, tone detection has been disabled! */
5457 break;
5458 }
5459 }
5460 }
5461
5462 /* Hard-stop buffer playout? */
5463 if ( f_pChannelModify->fStopBufferPlayout == TRUE )
5464 {
5465 /* Check if playout has been started on the Rout port. */
5466 if ( ( pChanEntry->fRinBufPlaying == TRUE ) || ( pChanEntry->fRinBufAdded == TRUE ) )
5467 {
5468 tOCT6100_BUFFER_PLAYOUT_STOP PlayoutStop;
5469
5470 /* Call the default function to make sure all parameters are assigned default values. */
5471 ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop );
5472 if ( ulResult != cOCT6100_ERR_OK )
5473 return ulResult;
5474
5475 /* Hard stop request. */
5476 PlayoutStop.fStopCleanly = FALSE;
5477
5478 /* Form channel handle. */
5479 PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5480
5481 /* For the Rout port. */
5482 PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
5483
5484 /* Call buffer playout stop serialized function. */
5485 ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop );
5486 if ( ulResult != cOCT6100_ERR_OK )
5487 return ulResult;
5488 }
5489 else
5490 {
5491 /* The chip might still be playing a last buffer. Make sure it hard-stops! */
5492 fClearPlayoutPointers = TRUE;
5493 }
5494
5495 /* Check if playout has been started on the Sout port. */
5496 if ( ( pChanEntry->fSoutBufPlaying == TRUE ) || ( pChanEntry->fSoutBufAdded == TRUE ) )
5497 {
5498 tOCT6100_BUFFER_PLAYOUT_STOP PlayoutStop;
5499
5500 /* Call the default function to make sure all parameters are assigned default values. */
5501 ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop );
5502 if ( ulResult != cOCT6100_ERR_OK )
5503 return ulResult;
5504
5505 /* Hard stop request. */
5506 PlayoutStop.fStopCleanly = FALSE;
5507
5508 /* Form channel handle. */
5509 PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5510
5511 /* For the Rout port. */
5512 PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
5513
5514 /* Call buffer playout stop serialized function. */
5515 ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop );
5516 if ( ulResult != cOCT6100_ERR_OK )
5517 return ulResult;
5518 }
5519 else
5520 {
5521 /* The chip might still be playing a last buffer. Make sure it hard-stops! */
5522 fClearPlayoutPointers = TRUE;
5523 }
5524 }
5525
5526 /* Remove participant from bridge? */
5527 if ( f_pChannelModify->fRemoveConfBridgeParticipant == TRUE )
5528 {
5529 /* Check if this channel is on a bridge. */
5530 if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
5531 {
5532 /* Channel is on a bridge, remove it. */
5533 tOCT6100_CONF_BRIDGE_CHAN_REMOVE BridgeChanRemove;
5534
5535 /* Call the default function to make sure all parameters are assigned default values. */
5536 ulResult = Oct6100ConfBridgeChanRemoveDef( &BridgeChanRemove );
5537 if ( ulResult != cOCT6100_ERR_OK )
5538 return ulResult;
5539
5540 /* Form channel handle. */
5541 BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5542
5543 /* Do not remove all channels, only the one specified. */
5544 BridgeChanRemove.fRemoveAll = FALSE;
5545
5546 /* No need to assign conference bridge handle, the remove function will figure it out. */
5547
5548 /* Call conference bridge channel remove serialized function. */
5549 ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
5550 if ( ulResult != cOCT6100_ERR_OK )
5551 {
5552 if ( ulResult == cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_DEPENDENCY )
5553 {
5554 tPOCT6100_API_CHANNEL pTapChanEntry;
5555
5556 /* Get a pointer to the tap channel's list entry. */
5557 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTapChanEntry, pChanEntry->usTapChanIndex )
5558
5559 /* Form tap channel handle. */
5560 BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pTapChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | pChanEntry->usTapChanIndex;
5561
5562 ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
5563 if ( ulResult != cOCT6100_ERR_OK )
5564 return ulResult;
5565
5566 /* Re-form original channel handle. */
5567 BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5568
5569 ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
5570 if ( ulResult != cOCT6100_ERR_OK )
5571 return ulResult;
5572 }
5573 else
5574 {
5575 return ulResult;
5576 }
5577 }
5578 }
5579 }
5580
5581 /* Remove all broadcast TSSTs? */
5582 if ( f_pChannelModify->fRemoveBroadcastTssts == TRUE )
5583 {
5584 /* Check if broadcast TSSTs were used on the Rout port. */
5585 if ( pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX )
5586 {
5587 tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE BroadcastTsstRemove;
5588
5589 ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove );
5590 if ( ulResult != cOCT6100_ERR_OK )
5591 return ulResult;
5592
5593 /* Form channel handle. */
5594 BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5595
5596 /* Remove all broadcast TSSTs associated to the current channel. */
5597 BroadcastTsstRemove.fRemoveAll = TRUE;
5598
5599 /* On the Rout port. */
5600 BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_ROUT;
5601
5602 ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove );
5603 if ( ulResult != cOCT6100_ERR_OK )
5604 return ulResult;
5605 }
5606
5607
5608 /* Check if broadcast TSSTs were used on the Sout port. */
5609 if ( pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX )
5610 {
5611 tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE BroadcastTsstRemove;
5612
5613 ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove );
5614 if ( ulResult != cOCT6100_ERR_OK )
5615 return ulResult;
5616
5617 /* Form channel handle. */
5618 BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
5619
5620 /* Remove all broadcast TSSTs associated to the current channel. */
5621 BroadcastTsstRemove.fRemoveAll = TRUE;
5622
5623 /* On the Sout port. */
5624 BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_SOUT;
5625
5626 ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove );
5627 if ( ulResult != cOCT6100_ERR_OK )
5628 return ulResult;
5629 }
5630 }
5631
5632 /* Check if have to make sure buffer playout is stopped. */
5633 if ( fClearPlayoutPointers == TRUE )
5634 {
5635 tOCT6100_BUFFER_PLAYOUT_STOP BufferPlayoutStop;
5636
5637 Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
5638
5639 BufferPlayoutStop.fStopCleanly = FALSE;
5640 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
5641
5642 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
5643 f_pApiInstance,
5644 &BufferPlayoutStop,
5645 f_usChanIndex,
5646 pChanEntry->usEchoMemIndex
5647
5648 );
5649 if ( ulResult != cOCT6100_ERR_OK )
5650 return ulResult;
5651
5652 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
5653 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
5654 f_pApiInstance,
5655 &BufferPlayoutStop,
5656 f_usChanIndex,
5657 pChanEntry->usEchoMemIndex
5658
5659 );
5660 if ( ulResult != cOCT6100_ERR_OK )
5661 return ulResult;
5662 }
5663
5664 return cOCT6100_ERR_OK;
5665 }
5666 #endif
5667
5668
5669
5670 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5671
5672 Function: Oct6100ApiModifyChannelEntry
5673
5674 Description: Updates the channel structure in the ECHO channel list.
5675
5676 -------------------------------------------------------------------------------
5677 | Argument | Description
5678 -------------------------------------------------------------------------------
5679 f_pApiInstance Pointer to API instance. This memory is used to keep
5680 the present state of the chip and all its resources.
5681
5682 f_pChannelModify Pointer to echo cancellation channel modify structure.
5683 f_pChannelOpen Pointer to echo cancellation channel configuration structure.
5684 f_usChanIndex Index of the channel within the API's channel list.
5685 f_usNewPhasingTsstIndex Index of the new phasing TSST.
5686 f_fSinSoutCodecActive State of the SIN/SOUT codec.
5687 f_fRinRoutCodecActive State of the RIN/ROUT codec.
5688 f_usNewRinTsstIndex New RIN TSST memory index.
5689 f_usNewSinTsstIndex New SIN TSST memory index.
5690 f_usNewRoutTsstIndex New ROUT TSST memory index.
5691 f_usNewSoutTsstIndex New SOUT TSST memory index.
5692
5693 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5694 #if !SKIP_Oct6100ApiModifyChannelEntry
5695 UINT32 Oct6100ApiModifyChannelEntry(
5696 IN tPOCT6100_INSTANCE_API f_pApiInstance,
5697 IN tPOCT6100_CHANNEL_MODIFY f_pChannelModify,
5698 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
5699 IN UINT16 f_usChanIndex,
5700 IN UINT16 f_usNewPhasingTsstIndex,
5701 IN UINT8 f_fSinSoutCodecActive,
5702 IN UINT8 f_fRinRoutCodecActive,
5703 IN UINT16 f_usNewRinTsstIndex,
5704 IN UINT16 f_usNewSinTsstIndex,
5705 IN UINT16 f_usNewRoutTsstIndex,
5706 IN UINT16 f_usNewSoutTsstIndex )
5707 {
5708 tPOCT6100_SHARED_INFO pSharedInfo;
5709 tPOCT6100_API_CHANNEL pChanEntry;
5710 tPOCT6100_API_CHANNEL_CODEC pApiCodecConf;
5711 tPOCT6100_API_CHANNEL_TDM pApiTdmConf;
5712 tPOCT6100_API_CHANNEL_VQE pApiVqeConf;
5713
5714 /* Obtain local pointer to shared portion of instance. */
5715 pSharedInfo = f_pApiInstance->pSharedInfo;
5716
5717 /*=======================================================================*/
5718 /* Get a pointer to the channel's list entry. */
5719 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
5720
5721 /* Obtain local pointer to the configuration structures of the tPOCT6100_API_CHANNEL structure. */
5722 pApiCodecConf = &pChanEntry->CodecConfig;
5723 pApiTdmConf = &pChanEntry->TdmConfig;
5724 pApiVqeConf = &pChanEntry->VqeConfig;
5725
5726 /*=======================================================================*/
5727 /* Copy the channel's general configuration. */
5728
5729 pChanEntry->ulUserChanId = f_pChannelOpen->ulUserChanId;
5730 pChanEntry->byEchoOperationMode = (UINT8)( f_pChannelOpen->ulEchoOperationMode & 0xFF );
5731 pChanEntry->fEnableToneDisabler = (UINT8)( f_pChannelOpen->fEnableToneDisabler & 0xFF );
5732
5733 /* Save the codec state.*/
5734 pChanEntry->fSinSoutCodecActive = (UINT8)( f_fSinSoutCodecActive & 0xFF );
5735 pChanEntry->fRinRoutCodecActive = (UINT8)( f_fRinRoutCodecActive & 0xFF );
5736
5737 /*=======================================================================*/
5738 /* Copy the channel's TDM configuration of all the modified fields. */
5739
5740 if ( f_pChannelModify->fTdmConfigModified == TRUE )
5741 {
5742 pApiTdmConf->byRinPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulRinPcmLaw & 0xFF );
5743 pApiTdmConf->bySinPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulSinPcmLaw & 0xFF );
5744 pApiTdmConf->byRoutPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulRoutPcmLaw & 0xFF );
5745 pApiTdmConf->bySoutPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulSoutPcmLaw & 0xFF );
5746
5747 pApiTdmConf->byRinNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulRinNumTssts & 0xFF );
5748 pApiTdmConf->bySinNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulSinNumTssts & 0xFF );
5749 pApiTdmConf->byRoutNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulRoutNumTssts & 0xFF );
5750 pApiTdmConf->bySoutNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulSoutNumTssts & 0xFF );
5751
5752 if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
5753 {
5754 if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX )
5755 {
5756 pApiTdmConf->usRinStream = (UINT16)( f_pChannelOpen->TdmConfig.ulRinStream & 0xFFFF );
5757 pApiTdmConf->usRinTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulRinTimeslot & 0xFFFF );
5758 pChanEntry->usRinTsstIndex = f_usNewRinTsstIndex;
5759 }
5760 else /* f_ulNewRinTsstIndex != cOCT6100_INVALID_INDEX */
5761 {
5762 pApiTdmConf->usRinStream = cOCT6100_UNASSIGNED;
5763 pApiTdmConf->usRinTimeslot = cOCT6100_UNASSIGNED;
5764 pChanEntry->usRinTsstIndex = cOCT6100_INVALID_INDEX;
5765 }
5766 }
5767
5768 if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
5769 {
5770 if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX )
5771 {
5772 pApiTdmConf->usSinStream = (UINT16)( f_pChannelOpen->TdmConfig.ulSinStream & 0xFFFF );
5773 pApiTdmConf->usSinTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulSinTimeslot & 0xFFFF );
5774 pChanEntry->usSinTsstIndex = f_usNewSinTsstIndex;
5775 }
5776 else /* f_ulNewSinTsstIndex != cOCT6100_INVALID_INDEX */
5777 {
5778 pApiTdmConf->usSinStream = cOCT6100_UNASSIGNED;
5779 pApiTdmConf->usSinTimeslot = cOCT6100_UNASSIGNED;
5780 pChanEntry->usSinTsstIndex = cOCT6100_INVALID_INDEX;
5781 }
5782 }
5783
5784 if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
5785 {
5786 if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX )
5787 {
5788 pApiTdmConf->usRoutStream = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutStream & 0xFFFF );
5789 pApiTdmConf->usRoutTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutTimeslot & 0xFFFF );
5790 pChanEntry->usRoutTsstIndex = f_usNewRoutTsstIndex;
5791 }
5792 else /* f_ulNewRoutTsstIndex != cOCT6100_INVALID_INDEX */
5793 {
5794 pApiTdmConf->usRoutStream = cOCT6100_UNASSIGNED;
5795 pApiTdmConf->usRoutTimeslot = cOCT6100_UNASSIGNED;
5796 pChanEntry->usRoutTsstIndex = cOCT6100_INVALID_INDEX;
5797 }
5798 }
5799
5800 if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
5801 {
5802 if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX )
5803 {
5804 pApiTdmConf->usSoutStream = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutStream & 0xFFFF );
5805 pApiTdmConf->usSoutTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutTimeslot & 0xFFFF );
5806 pChanEntry->usSoutTsstIndex = f_usNewSoutTsstIndex;
5807 }
5808 else /* f_ulNewSoutTsstIndex != cOCT6100_INVALID_INDEX */
5809 {
5810 pApiTdmConf->usSoutStream = cOCT6100_UNASSIGNED;
5811 pApiTdmConf->usSoutTimeslot = cOCT6100_UNASSIGNED;
5812 pChanEntry->usSoutTsstIndex = cOCT6100_INVALID_INDEX;
5813 }
5814 }
5815 }
5816
5817 /*=======================================================================*/
5818 /* Copy the channel's VQE configuration of all the modified fields. */
5819
5820 if ( f_pChannelModify->fVqeConfigModified == TRUE )
5821 {
5822 pApiVqeConf->fEnableNlp = (UINT8)( f_pChannelOpen->VqeConfig.fEnableNlp & 0xFF );
5823 pApiVqeConf->byComfortNoiseMode = (UINT8)( f_pChannelOpen->VqeConfig.ulComfortNoiseMode & 0xFF );
5824 pApiVqeConf->fSinDcOffsetRemoval = (UINT8)( f_pChannelOpen->VqeConfig.fSinDcOffsetRemoval & 0xFF );
5825 pApiVqeConf->fRinDcOffsetRemoval = (UINT8)( f_pChannelOpen->VqeConfig.fRinDcOffsetRemoval & 0xFF );
5826 pApiVqeConf->fRinLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fRinLevelControl & 0xFF );
5827 pApiVqeConf->fSoutLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fSoutLevelControl & 0xFF );
5828 pApiVqeConf->fRinAutomaticLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fRinAutomaticLevelControl & 0xFF );
5829 pApiVqeConf->fSoutAutomaticLevelControl = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAutomaticLevelControl & 0xFF );
5830 pApiVqeConf->fRinHighLevelCompensation = (UINT8)( f_pChannelOpen->VqeConfig.fRinHighLevelCompensation & 0xFF );
5831
5832 pApiVqeConf->fSoutAdaptiveNoiseReduction = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAdaptiveNoiseReduction & 0xFF );
5833 pApiVqeConf->fSoutNoiseBleaching = (UINT8)( f_pChannelOpen->VqeConfig.fSoutNoiseBleaching & 0xFF );
5834 pApiVqeConf->fSoutConferencingNoiseReduction = (UINT8)( f_pChannelOpen->VqeConfig.fSoutConferencingNoiseReduction & 0xFF );
5835 pApiVqeConf->chRinLevelControlGainDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lRinLevelControlGainDb & 0xFF );
5836 pApiVqeConf->chSoutLevelControlGainDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lSoutLevelControlGainDb & 0xFF );
5837 pApiVqeConf->chRinAutomaticLevelControlTargetDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lRinAutomaticLevelControlTargetDb & 0xFF );
5838 pApiVqeConf->chSoutAutomaticLevelControlTargetDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb & 0xFF );
5839 pApiVqeConf->chRinHighLevelCompensationThresholdDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lRinHighLevelCompensationThresholdDb & 0xFF );
5840 pApiVqeConf->fEnableTailDisplacement = (UINT8)( f_pChannelOpen->VqeConfig.fEnableTailDisplacement & 0xFF );
5841 pApiVqeConf->usTailDisplacement = (UINT16)( f_pChannelOpen->VqeConfig.ulTailDisplacement & 0xFFFF );
5842 pApiVqeConf->usTailLength = (UINT16)( f_pChannelOpen->VqeConfig.ulTailLength & 0xFFFF );
5843 pApiVqeConf->fAcousticEcho = (UINT8)( f_pChannelOpen->VqeConfig.fAcousticEcho & 0xFF );
5844 pApiVqeConf->fDtmfToneRemoval = (UINT8)( f_pChannelOpen->VqeConfig.fDtmfToneRemoval & 0xFF );
5845
5846 pApiVqeConf->chDefaultErlDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lDefaultErlDb & 0xFF );
5847 pApiVqeConf->chAecDefaultErlDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lAecDefaultErlDb & 0xFF );
5848 pApiVqeConf->usAecTailLength = (UINT16)( f_pChannelOpen->VqeConfig.ulAecTailLength & 0xFFFF );
5849 pApiVqeConf->chAnrSnrEnhancementDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lAnrSnrEnhancementDb & 0xFF );
5850 pApiVqeConf->byAnrVoiceNoiseSegregation = (UINT8)( f_pChannelOpen->VqeConfig.ulAnrVoiceNoiseSegregation & 0xFF );
5851 pApiVqeConf->usToneDisablerVqeActivationDelay = (UINT16)( f_pChannelOpen->VqeConfig.ulToneDisablerVqeActivationDelay & 0xFFFF );
5852 pApiVqeConf->byNonLinearityBehaviorA = (UINT8)( f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorA & 0xFF );
5853 pApiVqeConf->byNonLinearityBehaviorB = (UINT8)( f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorB & 0xFF );
5854 pApiVqeConf->byDoubleTalkBehavior = (UINT8)( f_pChannelOpen->VqeConfig.ulDoubleTalkBehavior & 0xFF );
5855 pApiVqeConf->bySoutAutomaticListenerEnhancementGainDb = (UINT8)( f_pChannelOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb & 0xFF );
5856 pApiVqeConf->bySoutNaturalListenerEnhancementGainDb = (UINT8)( f_pChannelOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb & 0xFF );
5857 pApiVqeConf->fSoutNaturalListenerEnhancement = (UINT8)( f_pChannelOpen->VqeConfig.fSoutNaturalListenerEnhancement & 0xFF );
5858 pApiVqeConf->fRoutNoiseReduction = (UINT8)( f_pChannelOpen->VqeConfig.fRoutNoiseReduction & 0xFF );
5859 pApiVqeConf->chRoutNoiseReductionLevelGainDb = (OCT_INT8)( f_pChannelOpen->VqeConfig.lRoutNoiseReductionLevelGainDb & 0xFF );
5860 pApiVqeConf->fEnableMusicProtection = (UINT8)( f_pChannelOpen->VqeConfig.fEnableMusicProtection & 0xFF );
5861 pApiVqeConf->fIdleCodeDetection = (UINT8)( f_pChannelOpen->VqeConfig.fIdleCodeDetection & 0xFF );
5862 }
5863
5864 /*=======================================================================*/
5865 /* Copy the channel's CODEC configuration of all the modified fields. */
5866 if ( f_pChannelModify->fCodecConfigModified == TRUE )
5867 {
5868 pApiCodecConf->byAdpcmNibblePosition = (UINT8)( f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition & 0xFF );
5869 pApiCodecConf->byEncoderPort = (UINT8)( f_pChannelOpen->CodecConfig.ulEncoderPort & 0xFF );
5870 pApiCodecConf->byEncodingRate = (UINT8)( f_pChannelOpen->CodecConfig.ulEncodingRate & 0xFF );
5871 pApiCodecConf->byDecoderPort = (UINT8)( f_pChannelOpen->CodecConfig.ulDecoderPort & 0xFF );
5872 pApiCodecConf->byDecodingRate = (UINT8)( f_pChannelOpen->CodecConfig.ulDecodingRate & 0xFF );
5873 pApiCodecConf->fEnableSilenceSuppression = (UINT8)( f_pChannelOpen->CodecConfig.fEnableSilenceSuppression & 0xFF );
5874 pApiCodecConf->byPhase = (UINT8)( f_pChannelOpen->CodecConfig.ulPhase & 0xFF );
5875 pApiCodecConf->byPhasingType = (UINT8)( f_pChannelOpen->CodecConfig.ulPhasingType & 0xFF );
5876
5877 /* Update the API phasing TSST structure */
5878 if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX )
5879 {
5880 tPOCT6100_API_PHASING_TSST pPhasingTsst;
5881
5882 /* Release the previous phasing TSST if the channel was already bound to one.*/
5883 if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
5884 {
5885 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, pChanEntry->usPhasingTsstIndex );
5886
5887 pPhasingTsst->usDependencyCnt--;
5888 }
5889
5890 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, f_usNewPhasingTsstIndex );
5891
5892 pPhasingTsst->usDependencyCnt++;
5893 pChanEntry->usPhasingTsstIndex = f_usNewPhasingTsstIndex;
5894
5895 }
5896 }
5897
5898
5899
5900 return cOCT6100_ERR_OK;
5901 }
5902 #endif
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5919
5920 Function: Oct6100ChannelBroadcastTsstAddSer
5921
5922 Description: Assign a TSST to one of the port of an echo cancellation channel.
5923
5924 -------------------------------------------------------------------------------
5925 | Argument | Description
5926 -------------------------------------------------------------------------------
5927 f_pApiInstance Pointer to API instance. This memory is used to keep the
5928 present state of the chip and all its resources.
5929
5930 f_pChannelTsstAdd Pointer to TSST assign structure.
5931
5932 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5933 #if !SKIP_Oct6100ChannelBroadcastTsstAddSer
5934 UINT32 Oct6100ChannelBroadcastTsstAddSer(
5935 IN tPOCT6100_INSTANCE_API f_pApiInstance,
5936 IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd )
5937 {
5938 UINT16 usChanIndex;
5939 UINT16 usNewTsstIndex;
5940 UINT16 usNewTsstEntry;
5941 UINT32 ulResult;
5942
5943 ulResult = Oct6100ApiCheckChanTsstAddParams( f_pApiInstance, f_pChannelTsstAdd, &usChanIndex );
5944 if ( ulResult != cOCT6100_ERR_OK )
5945 return ulResult;
5946
5947 ulResult = Oct6100ApiReserveTsstAddResources( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, &usNewTsstIndex, &usNewTsstEntry );
5948 if ( ulResult != cOCT6100_ERR_OK )
5949 return ulResult;
5950
5951 ulResult = Oct6100ApiWriteTsstAddStructs( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, usNewTsstIndex );
5952 if ( ulResult != cOCT6100_ERR_OK )
5953 return ulResult;
5954
5955 ulResult = Oct6100ApiUpdateTsstAddChanEntry( f_pApiInstance, f_pChannelTsstAdd, usChanIndex, usNewTsstIndex, usNewTsstEntry );
5956 if ( ulResult != cOCT6100_ERR_OK )
5957 return ulResult;
5958
5959 return cOCT6100_ERR_OK;
5960 }
5961 #endif
5962
5963 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5964
5965 Function: Oct6100ApiCheckChanTsstAddParams
5966
5967 Description: Verify the validity of the tPOCT6100_CHANNEL_BROADCAST_TSST_ADD
5968 structure.
5969
5970 -------------------------------------------------------------------------------
5971 | Argument | Description
5972 -------------------------------------------------------------------------------
5973 f_pApiInstance Pointer to API instance. This memory is used to keep the
5974 present state of the chip and all its resources.
5975
5976 f_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
5977 f_pusChanIndex Pointer to a structure used to store the multiple resources indexes.
5978
5979 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5980 #if !SKIP_Oct6100ApiCheckChanTsstAddParams
5981 UINT32 Oct6100ApiCheckChanTsstAddParams(
5982 IN tPOCT6100_INSTANCE_API f_pApiInstance,
5983 IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
5984 OUT PUINT16 f_pusChanIndex )
5985 {
5986 tPOCT6100_API_CHANNEL pChanEntry;
5987 UINT32 ulResult;
5988 UINT32 ulNumTssts = 1;
5989 UINT32 ulEntryOpenCnt;
5990
5991 /* Check the provided handle. */
5992 if ( (f_pChannelTsstAdd->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
5993 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
5994
5995 *f_pusChanIndex = (UINT16)( f_pChannelTsstAdd->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
5996 if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
5997 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
5998
5999 /*=======================================================================*/
6000 /* Get a pointer to the channel's list entry. */
6001
6002 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
6003
6004 /* Extract the entry open count from the provided handle. */
6005 ulEntryOpenCnt = ( f_pChannelTsstAdd->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
6006
6007 /* Check for errors. */
6008 if ( pChanEntry->fReserved != TRUE )
6009 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
6010 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
6011 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6012
6013 /*=======================================================================*/
6014
6015 /* validate the port parameter.*/
6016 if ( f_pChannelTsstAdd->ulPort != cOCT6100_CHANNEL_PORT_ROUT &&
6017 f_pChannelTsstAdd->ulPort != cOCT6100_CHANNEL_PORT_SOUT )
6018 return cOCT6100_ERR_CHANNEL_TSST_ADD_PORT;
6019
6020 /* Get the required number of TSST based on the port.*/
6021 switch( f_pChannelTsstAdd->ulPort )
6022 {
6023 case cOCT6100_CHANNEL_PORT_ROUT:
6024 ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6025 break;
6026 case cOCT6100_CHANNEL_PORT_SOUT:
6027 ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6028 break;
6029 default:
6030 return cOCT6100_ERR_FATAL_B;
6031 }
6032
6033 /* Check the validity of the timeslot and stream. */
6034 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
6035 ulNumTssts,
6036 f_pChannelTsstAdd->ulTimeslot,
6037 f_pChannelTsstAdd->ulStream,
6038 cOCT6100_OUTPUT_TSST );
6039 if ( ulResult != cOCT6100_ERR_OK )
6040 {
6041 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
6042 {
6043 return cOCT6100_ERR_CHANNEL_TSST_ADD_TIMESLOT;
6044 }
6045 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
6046 {
6047 return cOCT6100_ERR_CHANNEL_TSST_ADD_STREAM;
6048 }
6049 else
6050 {
6051 return ulResult;
6052 }
6053 }
6054
6055 return cOCT6100_ERR_OK;
6056 }
6057 #endif
6058
6059
6060 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6061
6062 Function: Oct6100ApiReserveTsstAddResources
6063
6064 Description: Reserve the entry for the new broadcast TSST.
6065
6066 -------------------------------------------------------------------------------
6067 | Argument | Description
6068 -------------------------------------------------------------------------------
6069 f_pApiInstance Pointer to API instance. This memory is used to keep the
6070 present state of the chip and all its resources.
6071
6072 f_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
6073 f_usChanIndex Channel index within the API's channel list.
6074 f_pusNewTsstIndex Pointer to the new TSST index within the API's TSST memory.
6075 f_pusNewTsstEntry Pointer to the new TSST entry within the API's TSST list.
6076
6077 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6078 #if !SKIP_Oct6100ApiReserveTsstAddResources
6079 UINT32 Oct6100ApiReserveTsstAddResources(
6080 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6081 IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
6082 IN UINT16 f_usChanIndex,
6083 OUT PUINT16 f_pusNewTsstIndex,
6084 OUT PUINT16 f_pusNewTsstEntry )
6085 {
6086 tPOCT6100_API_CHANNEL pChanEntry;
6087 UINT32 ulResult;
6088 UINT32 ulNumTssts = 1;
6089
6090 /*=======================================================================*/
6091 /* Get a pointer to the channel's list entry. */
6092
6093 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6094
6095 switch( f_pChannelTsstAdd->ulPort )
6096 {
6097 case cOCT6100_CHANNEL_PORT_ROUT:
6098 ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6099 break;
6100 case cOCT6100_CHANNEL_PORT_SOUT:
6101 ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6102 break;
6103 default:
6104 return cOCT6100_ERR_FATAL_C;
6105 }
6106
6107 /* Reserve the new entry.*/
6108 ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
6109 f_pChannelTsstAdd->ulTimeslot,
6110 f_pChannelTsstAdd->ulStream,
6111 ulNumTssts,
6112 cOCT6100_OUTPUT_TSST,
6113 f_pusNewTsstIndex,
6114 f_pusNewTsstEntry );
6115 if ( ulResult != cOCT6100_ERR_OK )
6116 return ulResult;
6117
6118 return cOCT6100_ERR_OK;
6119 }
6120 #endif
6121
6122
6123 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6124
6125 Function: Oct6100ApiWriteTsstAddStructs
6126
6127 Description: Configure the TSST control memory for the new TSST entry.
6128
6129 -------------------------------------------------------------------------------
6130 | Argument | Description
6131 -------------------------------------------------------------------------------
6132 f_pApiInstance Pointer to API instance. This memory is used to keep the
6133 present state of the chip and all its resources.
6134
6135 f_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
6136 f_usChanIndex Channel index.
6137 f_usNewTsstIndex Tsst index in the TSST control memory.
6138
6139 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6140 #if !SKIP_Oct6100ApiWriteTsstAddStructs
6141 UINT32 Oct6100ApiWriteTsstAddStructs(
6142 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6143 IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
6144 IN UINT16 f_usChanIndex,
6145 IN UINT16 f_usNewTsstIndex )
6146 {
6147 tPOCT6100_API_CHANNEL pChanEntry;
6148 tOCT6100_WRITE_PARAMS WriteParams;
6149 UINT32 ulResult = cOCT6100_ERR_OK;
6150 UINT16 usTsiMemIndex;
6151 UINT32 ulNumTssts = 1;
6152
6153
6154 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6155
6156 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6157
6158 /*=======================================================================*/
6159 /* Get a pointer to the channel's list entry. */
6160
6161 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6162
6163 switch( f_pChannelTsstAdd->ulPort )
6164 {
6165 case cOCT6100_CHANNEL_PORT_ROUT:
6166 usTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
6167 ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6168 break;
6169 case cOCT6100_CHANNEL_PORT_SOUT:
6170 usTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
6171 ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6172 break;
6173 default:
6174 return cOCT6100_ERR_FATAL_D;
6175 }
6176
6177
6178 /* Write the new entry now.*/
6179 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usNewTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6180
6181 WriteParams.usWriteData = cOCT6100_TSST_CONTROL_MEM_OUTPUT_TSST;
6182 WriteParams.usWriteData |= (UINT16)( pChanEntry->CodecConfig.byAdpcmNibblePosition << cOCT6100_TSST_CONTROL_MEM_NIBBLE_POS_OFFSET );
6183 WriteParams.usWriteData |= (UINT16)( (ulNumTssts - 1) << cOCT6100_TSST_CONTROL_MEM_TSST_NUM_OFFSET );
6184 WriteParams.usWriteData |= (UINT16)( usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK );
6185 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6186 if ( ulResult != cOCT6100_ERR_OK )
6187 return ulResult;
6188
6189 return cOCT6100_ERR_OK;
6190 }
6191 #endif
6192
6193
6194
6195
6196 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6197
6198 Function: Oct6100ApiUpdateTsstAddChanEntry
6199
6200 Description: Update the associated channel API entry to add the new broacast TSST.
6201
6202 -------------------------------------------------------------------------------
6203 | Argument | Description
6204 -------------------------------------------------------------------------------
6205 f_pApiInstance Pointer to API instance. This memory is used to keep the
6206 present state of the chip and all its resources.
6207
6208 f_pChannelTsstAdd Pointer to echo cancellation channel open configuration structure.
6209 f_usChanIndex Channel index.
6210 f_usNewTsstIndex TSST index within the TSST control memory.
6211 f_usNewTsstEntry TSST entry within the API TSST list.
6212
6213 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6214 #if !SKIP_Oct6100ApiUpdateTsstAddChanEntry
6215 UINT32 Oct6100ApiUpdateTsstAddChanEntry(
6216 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6217 IN tPOCT6100_CHANNEL_BROADCAST_TSST_ADD f_pChannelTsstAdd,
6218 IN UINT16 f_usChanIndex,
6219 IN UINT16 f_usNewTsstIndex,
6220 IN UINT16 f_usNewTsstEntry )
6221 {
6222 tPOCT6100_API_CHANNEL pChanEntry;
6223 tPOCT6100_API_TSST_ENTRY pTsstEntry;
6224
6225 /*=======================================================================*/
6226 /* Get a pointer to the channel's list entry. */
6227
6228 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6229 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, f_usNewTsstEntry );
6230
6231 /* Update the channel entry.*/
6232 if ( f_pChannelTsstAdd->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6233 {
6234 /* Add the new TSST entry to the broadcast list.*/
6235 pTsstEntry->usNextEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6236 pTsstEntry->usTsstMemoryIndex = (UINT16)f_usNewTsstIndex;
6237 pTsstEntry->usTsstValue = (UINT16)( (f_pChannelTsstAdd->ulTimeslot << 5) | f_pChannelTsstAdd->ulStream );
6238
6239 /* Modify the first entry pointer.*/
6240 pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = f_usNewTsstEntry;
6241
6242 /* Increment the number of broadcast TSST. */
6243 pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry++;
6244
6245 }
6246 else /* f_pChannelTsstAdd->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
6247 {
6248 /* Add the new TSST entry to the broadcast list.*/
6249 pTsstEntry->usNextEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6250 pTsstEntry->usTsstMemoryIndex = (UINT16)f_usNewTsstIndex;
6251 pTsstEntry->usTsstValue = (UINT16)( (f_pChannelTsstAdd->ulTimeslot << 5) | f_pChannelTsstAdd->ulStream );
6252
6253 /* Modify the first entry pointer.*/
6254 pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = f_usNewTsstEntry;
6255
6256 /* Increment the number of broadcast TSST. */
6257 pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry++;
6258 }
6259
6260 return cOCT6100_ERR_OK;
6261 }
6262 #endif
6263
6264
6265
6266
6267
6268
6269
6270
6271 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6272
6273 Function: Oct6100ChannelBroadcastTsstRemoveSer
6274
6275 Description: Removes a broadcast TSST from one of the output port of an
6276 echo cancellation channel.
6277
6278 -------------------------------------------------------------------------------
6279 | Argument | Description
6280 -------------------------------------------------------------------------------
6281 f_pApiInstance Pointer to API instance. This memory is used to keep the
6282 present state of the chip and all its resources.
6283
6284 f_pChannelTsstRemove Pointer to TSST remove structure.
6285
6286 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6287 #if !SKIP_Oct6100ChannelBroadcastTsstRemoveSer
6288 UINT32 Oct6100ChannelBroadcastTsstRemoveSer(
6289 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6290 IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove)
6291 {
6292 UINT16 usChanIndex;
6293 UINT16 usTsstIndex;
6294 UINT16 usTsstEntry;
6295 UINT16 usPrevTsstEntry;
6296 UINT32 ulResult;
6297
6298 ulResult = Oct6100ApiAssertChanTsstRemoveParams( f_pApiInstance, f_pChannelTsstRemove, &usChanIndex, &usTsstIndex, &usTsstEntry, &usPrevTsstEntry );
6299 if ( ulResult != cOCT6100_ERR_OK )
6300 return ulResult;
6301
6302 ulResult = Oct6100ApiInvalidateTsstRemoveStructs( f_pApiInstance, usChanIndex, usTsstIndex, f_pChannelTsstRemove->ulPort, f_pChannelTsstRemove->fRemoveAll );
6303 if ( ulResult != cOCT6100_ERR_OK )
6304 return ulResult;
6305
6306 ulResult = Oct6100ApiReleaseTsstRemoveResources( f_pApiInstance, f_pChannelTsstRemove, usChanIndex, usTsstIndex, usTsstEntry, usPrevTsstEntry );
6307 if ( ulResult != cOCT6100_ERR_OK )
6308 return ulResult;
6309
6310 return cOCT6100_ERR_OK;
6311 }
6312 #endif
6313
6314 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6315
6316 Function: Oct6100ApiAssertChanTsstRemoveParams
6317
6318 Description: Verify the validity of the tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE
6319 structure.
6320
6321 -------------------------------------------------------------------------------
6322 | Argument | Description
6323 -------------------------------------------------------------------------------
6324 f_pApiInstance Pointer to API instance. This memory is used to keep the
6325 present state of the chip and all its resources.
6326
6327 f_pChannelTsstRemove Pointer to echo cancellation channel open configuration structure.
6328 f_pulChanIndex Pointer to a channel index.
6329 f_pulNewTsstIndex Pointer to a TSST index within the TSST control memory.
6330 f_pulNewTsstEntry Pointer to a TSST entry within the API TSST list.
6331 f_pulPrevTsstEntry Pointer to the previous TSST entry.
6332
6333 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6334 #if !SKIP_Oct6100ApiAssertChanTsstRemoveParams
6335 UINT32 Oct6100ApiAssertChanTsstRemoveParams(
6336 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6337 IN tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove,
6338 OUT PUINT16 f_pusChanIndex,
6339 OUT PUINT16 f_pusTsstIndex,
6340 OUT PUINT16 f_pusTsstEntry,
6341 OUT PUINT16 f_pusPrevTsstEntry )
6342 {
6343 tPOCT6100_API_CHANNEL pChanEntry;
6344 tPOCT6100_API_TSST_ENTRY pTsstEntry;
6345 UINT32 ulResult;
6346 UINT32 ulNumTssts = 1;
6347 UINT32 ulEntryOpenCnt;
6348 UINT16 usCurrentEntry;
6349 UINT16 usTsstValue;
6350 UINT16 usNumEntry;
6351
6352 /* Check the provided handle. */
6353 if ( (f_pChannelTsstRemove->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
6354 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6355
6356 *f_pusChanIndex = (UINT16)( f_pChannelTsstRemove->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
6357 if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
6358 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6359
6360 /*=======================================================================*/
6361 /* Get a pointer to the channel's list entry. */
6362
6363 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
6364
6365 /* Extract the entry open count from the provided handle. */
6366 ulEntryOpenCnt = ( f_pChannelTsstRemove->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
6367
6368 /* Check for errors. */
6369 if ( pChanEntry->fReserved != TRUE )
6370 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
6371 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
6372 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6373
6374 /*=======================================================================*/
6375
6376 /* validate the port parameter.*/
6377 if ( f_pChannelTsstRemove->ulPort != cOCT6100_CHANNEL_PORT_ROUT &&
6378 f_pChannelTsstRemove->ulPort != cOCT6100_CHANNEL_PORT_SOUT )
6379 return cOCT6100_ERR_CHANNEL_TSST_REMOVE_PORT;
6380
6381 /* Verify that the requested entry is present in the channel's port broadcast TSST.*/
6382 if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6383 {
6384 usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6385 usNumEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry;
6386 }
6387 else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
6388 {
6389 usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6390 usNumEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry;
6391 }
6392
6393 /* Verify if at least one TSST is present on the channel port.*/
6394 if ( usNumEntry == 0 )
6395 return cOCT6100_ERR_CHANNEL_TSST_REMOVE_NO_BROADCAST_TSST;
6396
6397 /* Get the required number of TSST based on the port.*/
6398 switch( f_pChannelTsstRemove->ulPort )
6399 {
6400 case cOCT6100_CHANNEL_PORT_ROUT:
6401 ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6402 break;
6403 case cOCT6100_CHANNEL_PORT_SOUT:
6404 ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6405 break;
6406 default:
6407 return cOCT6100_ERR_FATAL_E;
6408 }
6409
6410 /* Initialize the TSST entry to invalid.*/
6411 *f_pusTsstEntry = cOCT6100_INVALID_INDEX;
6412 *f_pusPrevTsstEntry = cOCT6100_INVALID_INDEX;
6413 *f_pusTsstIndex = cOCT6100_INVALID_INDEX;
6414
6415 if ( f_pChannelTsstRemove->fRemoveAll != TRUE )
6416 {
6417 /* Check the validity of the timeslot and Stream.*/
6418 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
6419 ulNumTssts,
6420 f_pChannelTsstRemove->ulTimeslot,
6421 f_pChannelTsstRemove->ulStream,
6422 cOCT6100_OUTPUT_TSST );
6423 if ( ulResult != cOCT6100_ERR_OK )
6424 {
6425 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
6426 {
6427 return cOCT6100_ERR_CHANNEL_TSST_REMOVE_TIMESLOT;
6428 }
6429 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
6430 {
6431 return cOCT6100_ERR_CHANNEL_TSST_REMOVE_STREAM;
6432 }
6433 else
6434 {
6435 return ulResult;
6436 }
6437 }
6438
6439 /* Set the TSST value based on the timeslot and stream value.*/
6440 usTsstValue = (UINT16)( (f_pChannelTsstRemove->ulTimeslot << 5) | f_pChannelTsstRemove->ulStream );
6441
6442 while( usCurrentEntry != cOCT6100_INVALID_INDEX )
6443 {
6444 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6445
6446 if ( usTsstValue == pTsstEntry->usTsstValue )
6447 {
6448 /* A match was found.*/
6449 *f_pusTsstEntry = usCurrentEntry;
6450 *f_pusTsstIndex = pTsstEntry->usTsstMemoryIndex;
6451 break;
6452 }
6453
6454 /* Move on to the next entry.*/
6455 *f_pusPrevTsstEntry = usCurrentEntry;
6456 usCurrentEntry = pTsstEntry->usNextEntry;
6457 }
6458
6459 if ( *f_pusTsstEntry == cOCT6100_INVALID_INDEX )
6460 return cOCT6100_ERR_CHANNEL_TSST_REMOVE_INVALID_TSST;
6461 }
6462
6463 return cOCT6100_ERR_OK;
6464 }
6465 #endif
6466
6467
6468 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6469
6470 Function: Oct6100ApiInvalidateTsstRemoveStructs
6471
6472 Description: Invalidate the entry of the broadcast TSST.
6473
6474 -------------------------------------------------------------------------------
6475 | Argument | Description
6476 -------------------------------------------------------------------------------
6477 f_pApiInstance Pointer to API instance. This memory is used to keep the
6478 present state of the chip and all its resources.
6479
6480 f_usChanIndex Channel index.
6481 f_usTsstIndex TSST index within the TSST control memory.
6482 f_ulPort Channel port where the TSST are removed from. (only used if remove all == TRUE)
6483 f_fRemoveAll Remove all flag.
6484
6485 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6486 #if !SKIP_Oct6100ApiInvalidateTsstRemoveStructs
6487 UINT32 Oct6100ApiInvalidateTsstRemoveStructs(
6488 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6489 IN UINT16 f_usChanIndex,
6490 IN UINT16 f_usTsstIndex,
6491 IN UINT32 f_ulPort,
6492 IN BOOL f_fRemoveAll )
6493 {
6494 tOCT6100_WRITE_PARAMS WriteParams;
6495 UINT32 ulResult;
6496
6497 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6498
6499 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6500
6501 if ( f_fRemoveAll == FALSE )
6502 {
6503 /* Deactivate the entry now.*/
6504 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6505 WriteParams.usWriteData = 0x0000;
6506
6507 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6508 if ( ulResult != cOCT6100_ERR_OK )
6509 return ulResult;
6510 }
6511 else /* f_fRemoveAll == TRUE */
6512 {
6513 tPOCT6100_API_CHANNEL pChanEntry;
6514 tPOCT6100_API_TSST_ENTRY pTsstEntry;
6515 UINT16 usTsstEntry;
6516
6517 /*=======================================================================*/
6518 /* Get a pointer to the channel's list entry. */
6519
6520 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6521
6522 /* Clear all entry associated to the selected port.*/
6523 if ( f_ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6524 usTsstEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6525 else
6526 usTsstEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6527
6528 do
6529 {
6530 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usTsstEntry );
6531
6532 /* Deactivate the entry now.*/
6533 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( ( pTsstEntry->usTsstMemoryIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6534 WriteParams.usWriteData = 0x0000;
6535
6536 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6537 if ( ulResult != cOCT6100_ERR_OK )
6538 return ulResult;
6539
6540 usTsstEntry = pTsstEntry->usNextEntry;
6541
6542 } while ( usTsstEntry != cOCT6100_INVALID_INDEX );
6543 }
6544
6545 return cOCT6100_ERR_OK;
6546 }
6547 #endif
6548
6549
6550 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6551
6552 Function: Oct6100ApiReleaseTsstRemoveResources
6553
6554 Description: Release all API resources associated to the Removed TSST and
6555 update the channel entry accordingly.
6556
6557 -------------------------------------------------------------------------------
6558 | Argument | Description
6559 -------------------------------------------------------------------------------
6560 f_pApiInstance Pointer to API instance. This memory is used to keep the
6561 present state of the chip and all its resources.
6562
6563 f_pChannelTsstRemove Pointer to echo cancellation channel open configuration structure.
6564 f_usChanIndex Channel index.
6565 f_usTsstIndex TSST index within the TSST control memory.
6566 f_usTsstEntry TSST entry within the API's TSST list.
6567 f_usPrevTsstEntry Previous TSST entry within the API's TSST list.
6568
6569 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6570 #if !SKIP_Oct6100ApiReleaseTsstRemoveResources
6571 UINT32 Oct6100ApiReleaseTsstRemoveResources(
6572 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6573 IN tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove,
6574 IN UINT16 f_usChanIndex,
6575 IN UINT16 f_usTsstIndex,
6576 IN UINT16 f_usTsstEntry,
6577 IN UINT16 f_usPrevTsstEntry )
6578 {
6579 tPOCT6100_API_CHANNEL pChanEntry;
6580 tPOCT6100_API_TSST_ENTRY pTsstEntry;
6581 tPOCT6100_API_TSST_ENTRY pPrevTsstEntry;
6582 UINT16 usCurrentEntry;
6583 UINT32 ulResult;
6584 UINT32 ulTimeslot;
6585 UINT32 ulStream;
6586 /*=======================================================================*/
6587 /* Get a pointer to the channel's list entry. */
6588
6589 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
6590
6591 if ( f_pChannelTsstRemove->fRemoveAll == FALSE )
6592 {
6593 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, f_usTsstEntry );
6594
6595 /* Update the channel entry.*/
6596 if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6597 {
6598 /* Check if the entry was the first in the list.*/
6599 if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX )
6600 {
6601 pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry;
6602 }
6603 else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */
6604 {
6605 /* Get a pointer to the previous entry.*/
6606 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPrevTsstEntry, f_usPrevTsstEntry );
6607 pPrevTsstEntry->usNextEntry = pTsstEntry->usNextEntry;
6608 }
6609
6610 /* Decrement the number of entry.*/
6611 pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry--;
6612 }
6613 else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
6614 {
6615 /* Check if the entry was the first in the list.*/
6616 if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX )
6617 {
6618 pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry;
6619 }
6620 else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */
6621 {
6622 /* Get a pointer to the previous entry.*/
6623 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPrevTsstEntry, f_usPrevTsstEntry );
6624 pPrevTsstEntry->usNextEntry = pTsstEntry->usNextEntry;
6625 }
6626
6627 /* Decrement the number of entry.*/
6628 pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry--;
6629 }
6630
6631 ulTimeslot = pTsstEntry->usTsstValue >> 5;
6632 ulStream = pTsstEntry->usTsstValue & 0x1F;
6633
6634 /* Release the entry.*/
6635 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
6636 ulTimeslot,
6637 ulStream,
6638 cOCT6100_NUMBER_TSSTS_1,
6639 cOCT6100_OUTPUT_TSST,
6640 f_usTsstEntry );
6641 if ( ulResult != cOCT6100_ERR_OK )
6642 return ulResult;
6643 }
6644 else /* f_pChannelTsstRemove->fRemoveAll == TRUE */
6645 {
6646
6647 /* Update the channel entry.*/
6648 if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6649 usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6650 else
6651 usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6652
6653 do
6654 {
6655 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6656
6657 ulTimeslot = pTsstEntry->usTsstValue >> 5;
6658 ulStream = pTsstEntry->usTsstValue & 0x1F;
6659
6660 /* Release the entry.*/
6661 ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
6662 ulTimeslot,
6663 ulStream,
6664 cOCT6100_NUMBER_TSSTS_1,
6665 cOCT6100_OUTPUT_TSST,
6666 usCurrentEntry ); /* Release the entry.*/
6667 if ( ulResult != cOCT6100_ERR_OK )
6668 return ulResult;
6669
6670 usCurrentEntry = pTsstEntry->usNextEntry;
6671
6672 /* Clear the previous node.*/
6673 pTsstEntry->usTsstMemoryIndex = 0xFFFF;
6674 pTsstEntry->usTsstValue = 0xFFFF;
6675 pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
6676
6677 } while ( usCurrentEntry != cOCT6100_INVALID_INDEX );
6678
6679 /* Reset the channel status.*/
6680 if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
6681 {
6682 pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
6683 pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0;
6684 }
6685 else
6686 {
6687 pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
6688 pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry = 0;
6689 }
6690 }
6691 return cOCT6100_ERR_OK;
6692 }
6693 #endif
6694
6695
6696 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6697
6698 Function: Oct6100ApiChannelGetStatsSer
6699
6700 Description: Serialized function that returns all the stats of the specified
6701 channel.
6702
6703 -------------------------------------------------------------------------------
6704 | Argument | Description
6705 -------------------------------------------------------------------------------
6706 f_pApiInstance Pointer to API instance. This memory is used to keep the
6707 present state of the chip and all its resources.
6708
6709 f_pChannelStats Pointer to a channel stats structure.
6710 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6711 #if !SKIP_Oct6100ApiChannelGetStatsSer
6712 UINT32 Oct6100ApiChannelGetStatsSer(
6713 IN tPOCT6100_INSTANCE_API f_pApiInstance,
6714 IN tPOCT6100_CHANNEL_STATS f_pChannelStats )
6715 {
6716 tOCT6100_READ_PARAMS ReadParams;
6717 tOCT6100_READ_BURST_PARAMS BurstParams;
6718 tPOCT6100_API_CHANNEL pChanEntry;
6719 tPOCT6100_SHARED_INFO pSharedInfo;
6720 tPOCT6100_API_TSST_ENTRY pTsstEntry;
6721 UINT32 ulEntryOpenCnt;
6722 UINT16 usCurrentEntry;
6723 UINT16 usTsstCount;
6724 UINT32 ulBaseAddress;
6725 UINT32 ulFeatureBytesOffset;
6726 UINT32 ulFeatureBitOffset;
6727 UINT32 ulFeatureFieldLength;
6728 UINT32 ulTempData;
6729 UINT32 ulMask;
6730 UINT16 usChanIndex;
6731 UINT16 ausReadData[ 32 ];
6732
6733 BYTE byRinEnergyRaw;
6734 BYTE bySinEnergyRaw;
6735 BYTE bySoutEnergyRaw;
6736 INT32 lSoutEnergyIndB;
6737 BYTE byCnEnergyRaw;
6738 UINT16 usEchoDelayInFrames;
6739 UINT16 usErlRaw;
6740
6741 UINT32 ulResult;
6742 UINT16 usReadData;
6743
6744 /* Get local pointer to shared portion of instance. */
6745 pSharedInfo = f_pApiInstance->pSharedInfo;
6746
6747 BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
6748
6749 BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6750 BurstParams.pusReadData = ausReadData;
6751
6752 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
6753
6754 ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6755 ReadParams.pusReadData = &usReadData;
6756
6757 /* Check the reset stats flag.*/
6758 if ( f_pChannelStats->fResetStats != TRUE && f_pChannelStats->fResetStats != FALSE )
6759 return cOCT6100_ERR_CHANNEL_STATS_RESET;
6760
6761 /* Check the provided handle. */
6762 if ( cOCT6100_HNDL_TAG_CHANNEL != (f_pChannelStats->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) )
6763 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6764
6765 usChanIndex = (UINT16)( f_pChannelStats->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
6766 if ( usChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
6767 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6768
6769 /*=======================================================================*/
6770 /* Get a pointer to the channel's list entry. */
6771
6772 mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, usChanIndex )
6773
6774 /* Extract the entry open count from the provided handle. */
6775 ulEntryOpenCnt = ( f_pChannelStats->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
6776
6777 /* Check for errors. */
6778 if ( pChanEntry->fReserved != TRUE )
6779 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
6780 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
6781 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
6782
6783 /*=======================================================================*/
6784
6785 /* Check the value of the max broadcast tsst.*/
6786 if ( f_pChannelStats->TdmConfig.ulMaxBroadcastTssts > cOCT6100_MAX_TSSTS )
6787 return cOCT6100_ERR_CHANNEL_GET_STATS_MAX_BROADCAST_TSST;
6788
6789 if ( f_pChannelStats->TdmConfig.ulMaxBroadcastTssts != 0 )
6790 {
6791 /* Check if memory was allocated by the user for the stream and timeslot values.*/
6792 if ( f_pChannelStats->TdmConfig.pulRoutBroadcastTimeslot == NULL )
6793 return cOCT6100_ERR_CHANNEL_ROUT_BROADCAST_TIMESLOT;
6794
6795 if ( f_pChannelStats->TdmConfig.pulRoutBroadcastStream == NULL )
6796 return cOCT6100_ERR_CHANNEL_ROUT_BROADCAST_STREAM;
6797
6798 if ( f_pChannelStats->TdmConfig.pulSoutBroadcastTimeslot == NULL )
6799 return cOCT6100_ERR_CHANNEL_SOUT_BROADCAST_TIMESLOT;
6800
6801 if ( f_pChannelStats->TdmConfig.pulSoutBroadcastStream == NULL )
6802 return cOCT6100_ERR_CHANNEL_SOUT_BROADCAST_STREAM;
6803 }
6804
6805 /* Copy the general configuration.*/
6806 f_pChannelStats->ulUserChanId = pChanEntry->ulUserChanId;
6807 f_pChannelStats->ulEchoOperationMode = pChanEntry->byEchoOperationMode;
6808 f_pChannelStats->fEnableToneDisabler = pChanEntry->fEnableToneDisabler;
6809 f_pChannelStats->ulMutePortsMask = pChanEntry->usMutedPorts;
6810 f_pChannelStats->fEnableExtToneDetection = pChanEntry->fEnableExtToneDetection;
6811
6812
6813
6814 /* Copy the TDM configuration.*/
6815 f_pChannelStats->TdmConfig.ulNumRoutBroadcastTssts = pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry;
6816 f_pChannelStats->TdmConfig.ulNumSoutBroadcastTssts = pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry;
6817
6818 f_pChannelStats->TdmConfig.ulSinNumTssts = pChanEntry->TdmConfig.bySinNumTssts;
6819 f_pChannelStats->TdmConfig.ulSinTimeslot = pChanEntry->TdmConfig.usSinTimeslot;
6820 f_pChannelStats->TdmConfig.ulSinStream = pChanEntry->TdmConfig.usSinStream;
6821 f_pChannelStats->TdmConfig.ulSinPcmLaw = pChanEntry->TdmConfig.bySinPcmLaw;
6822
6823 f_pChannelStats->TdmConfig.ulSoutNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
6824 f_pChannelStats->TdmConfig.ulSoutTimeslot = pChanEntry->TdmConfig.usSoutTimeslot;
6825 f_pChannelStats->TdmConfig.ulSoutStream = pChanEntry->TdmConfig.usSoutStream;
6826 f_pChannelStats->TdmConfig.ulSoutPcmLaw = pChanEntry->TdmConfig.bySoutPcmLaw;
6827
6828 /* Copy the SOUT Broadcast TSST into the Stream and timeslot array.*/
6829 usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
6830 for( usTsstCount = 0; (usTsstCount < pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry) && (usTsstCount < f_pChannelStats->TdmConfig.ulMaxBroadcastTssts); usTsstCount++ )
6831 {
6832 if ( usCurrentEntry == cOCT6100_INVALID_INDEX )
6833 return cOCT6100_ERR_FATAL_F;
6834
6835 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6836
6837 f_pChannelStats->TdmConfig.pulSoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue & 0x1F;
6838 f_pChannelStats->TdmConfig.pulSoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue >> 5;
6839
6840 /* Obtain the index of the next entry.*/
6841 usCurrentEntry = pTsstEntry->usNextEntry;
6842 }
6843
6844 /* Check if all Sout Broadcast TSST were returned.*/
6845 if ( usTsstCount < pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry )
6846 {
6847 f_pChannelStats->TdmConfig.fMoreSoutBroadcastTssts = TRUE;
6848 }
6849 else /* usTsstCount >= pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry */
6850 {
6851 f_pChannelStats->TdmConfig.fMoreSoutBroadcastTssts = FALSE;
6852 }
6853
6854 f_pChannelStats->TdmConfig.ulRinNumTssts = pChanEntry->TdmConfig.byRinNumTssts;
6855 f_pChannelStats->TdmConfig.ulRinTimeslot = pChanEntry->TdmConfig.usRinTimeslot;
6856 f_pChannelStats->TdmConfig.ulRinStream = pChanEntry->TdmConfig.usRinStream;
6857 f_pChannelStats->TdmConfig.ulRinPcmLaw = pChanEntry->TdmConfig.byRinPcmLaw;
6858
6859 f_pChannelStats->TdmConfig.ulRoutNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
6860 f_pChannelStats->TdmConfig.ulRoutTimeslot = pChanEntry->TdmConfig.usRoutTimeslot;
6861 f_pChannelStats->TdmConfig.ulRoutStream = pChanEntry->TdmConfig.usRoutStream;
6862 f_pChannelStats->TdmConfig.ulRoutPcmLaw = pChanEntry->TdmConfig.byRoutPcmLaw;
6863
6864
6865 /* Copy the ROUT Broadcast TSST into the Stream and timeslot array.*/
6866 usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
6867 for( usTsstCount = 0; (usTsstCount < pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry) && (usTsstCount < f_pChannelStats->TdmConfig.ulMaxBroadcastTssts); usTsstCount++ )
6868 {
6869 if ( usCurrentEntry == cOCT6100_INVALID_INDEX )
6870 return cOCT6100_ERR_FATAL_10;
6871
6872 mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
6873
6874 f_pChannelStats->TdmConfig.pulRoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue & 0x1F;
6875 f_pChannelStats->TdmConfig.pulRoutBroadcastStream[ usTsstCount ] = pTsstEntry->usTsstValue >> 5;
6876
6877 /* Obtain the index of the next entry.*/
6878 usCurrentEntry = pTsstEntry->usNextEntry;
6879 }
6880
6881 /* Check if all Rout Broadcast TSST were returned.*/
6882 if ( usTsstCount < pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry )
6883 {
6884 f_pChannelStats->TdmConfig.fMoreRoutBroadcastTssts = TRUE;
6885 }
6886 else /* usTsstCount >= pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry */
6887 {
6888 f_pChannelStats->TdmConfig.fMoreRoutBroadcastTssts = FALSE;
6889 }
6890
6891 /* Copy the VQE configuration.*/
6892 f_pChannelStats->VqeConfig.fEnableNlp = pChanEntry->VqeConfig.fEnableNlp;
6893 f_pChannelStats->VqeConfig.ulComfortNoiseMode = pChanEntry->VqeConfig.byComfortNoiseMode;
6894 f_pChannelStats->VqeConfig.fEnableTailDisplacement = pChanEntry->VqeConfig.fEnableTailDisplacement;
6895 if ( pChanEntry->VqeConfig.usTailDisplacement != cOCT6100_AUTO_SELECT_TAIL )
6896 f_pChannelStats->VqeConfig.ulTailDisplacement = pChanEntry->VqeConfig.usTailDisplacement;
6897 else
6898 f_pChannelStats->VqeConfig.ulTailDisplacement = f_pApiInstance->pSharedInfo->ChipConfig.usTailDisplacement;
6899
6900 if ( pChanEntry->VqeConfig.usTailLength != cOCT6100_AUTO_SELECT_TAIL )
6901 f_pChannelStats->VqeConfig.ulTailLength = pChanEntry->VqeConfig.usTailLength;
6902 else
6903 f_pChannelStats->VqeConfig.ulTailLength = f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength;
6904
6905
6906
6907 f_pChannelStats->VqeConfig.fSinDcOffsetRemoval = pChanEntry->VqeConfig.fSinDcOffsetRemoval;
6908 f_pChannelStats->VqeConfig.fRinDcOffsetRemoval = pChanEntry->VqeConfig.fRinDcOffsetRemoval;
6909 f_pChannelStats->VqeConfig.fRinLevelControl = pChanEntry->VqeConfig.fRinLevelControl;
6910 f_pChannelStats->VqeConfig.fSoutLevelControl = pChanEntry->VqeConfig.fSoutLevelControl;
6911 f_pChannelStats->VqeConfig.fRinAutomaticLevelControl = pChanEntry->VqeConfig.fRinAutomaticLevelControl;
6912 f_pChannelStats->VqeConfig.fSoutAutomaticLevelControl = pChanEntry->VqeConfig.fSoutAutomaticLevelControl;
6913 f_pChannelStats->VqeConfig.fRinHighLevelCompensation = pChanEntry->VqeConfig.fRinHighLevelCompensation;
6914 f_pChannelStats->VqeConfig.fSoutAdaptiveNoiseReduction = pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction;
6915 f_pChannelStats->VqeConfig.fSoutNoiseBleaching = pChanEntry->VqeConfig.fSoutNoiseBleaching;
6916 f_pChannelStats->VqeConfig.fSoutConferencingNoiseReduction = pChanEntry->VqeConfig.fSoutConferencingNoiseReduction;
6917 f_pChannelStats->VqeConfig.lRinLevelControlGainDb = pChanEntry->VqeConfig.chRinLevelControlGainDb;
6918 f_pChannelStats->VqeConfig.lSoutLevelControlGainDb = pChanEntry->VqeConfig.chSoutLevelControlGainDb;
6919 f_pChannelStats->VqeConfig.lRinAutomaticLevelControlTargetDb = pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb;
6920 f_pChannelStats->VqeConfig.lSoutAutomaticLevelControlTargetDb = pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb;
6921 f_pChannelStats->VqeConfig.lRinHighLevelCompensationThresholdDb = pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb;
6922 f_pChannelStats->VqeConfig.fAcousticEcho = pChanEntry->VqeConfig.fAcousticEcho;
6923 f_pChannelStats->VqeConfig.fDtmfToneRemoval = pChanEntry->VqeConfig.fDtmfToneRemoval;
6924
6925 f_pChannelStats->VqeConfig.lDefaultErlDb = pChanEntry->VqeConfig.chDefaultErlDb;
6926 f_pChannelStats->VqeConfig.lAecDefaultErlDb = pChanEntry->VqeConfig.chAecDefaultErlDb;
6927 f_pChannelStats->VqeConfig.ulAecTailLength = pChanEntry->VqeConfig.usAecTailLength;
6928 f_pChannelStats->VqeConfig.lAnrSnrEnhancementDb = pChanEntry->VqeConfig.chAnrSnrEnhancementDb;
6929 f_pChannelStats->VqeConfig.ulAnrVoiceNoiseSegregation = pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation;
6930 f_pChannelStats->VqeConfig.ulToneDisablerVqeActivationDelay = pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay;
6931 f_pChannelStats->VqeConfig.ulNonLinearityBehaviorA = pChanEntry->VqeConfig.byNonLinearityBehaviorA;
6932 f_pChannelStats->VqeConfig.ulNonLinearityBehaviorB = pChanEntry->VqeConfig.byNonLinearityBehaviorB;
6933 f_pChannelStats->VqeConfig.ulDoubleTalkBehavior = pChanEntry->VqeConfig.byDoubleTalkBehavior;
6934 f_pChannelStats->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb;
6935 f_pChannelStats->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb;
6936 f_pChannelStats->VqeConfig.fSoutNaturalListenerEnhancement = pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement;
6937 f_pChannelStats->VqeConfig.fRoutNoiseReduction = pChanEntry->VqeConfig.fRoutNoiseReduction;
6938 f_pChannelStats->VqeConfig.lRoutNoiseReductionLevelGainDb = pChanEntry->VqeConfig.chRoutNoiseReductionLevelGainDb;
6939 f_pChannelStats->VqeConfig.fEnableMusicProtection = pChanEntry->VqeConfig.fEnableMusicProtection;
6940 f_pChannelStats->VqeConfig.fIdleCodeDetection = pChanEntry->VqeConfig.fIdleCodeDetection;
6941
6942 /* Copy the CODEC configuration.*/
6943 f_pChannelStats->CodecConfig.ulAdpcmNibblePosition = pChanEntry->CodecConfig.byAdpcmNibblePosition;
6944
6945 f_pChannelStats->CodecConfig.ulEncoderPort = pChanEntry->CodecConfig.byEncoderPort;
6946 f_pChannelStats->CodecConfig.ulEncodingRate = pChanEntry->CodecConfig.byEncodingRate;
6947
6948 f_pChannelStats->CodecConfig.ulDecoderPort = pChanEntry->CodecConfig.byDecoderPort;
6949 f_pChannelStats->CodecConfig.ulDecodingRate = pChanEntry->CodecConfig.byDecodingRate;
6950
6951 f_pChannelStats->CodecConfig.fEnableSilenceSuppression = pChanEntry->CodecConfig.fEnableSilenceSuppression;
6952 f_pChannelStats->CodecConfig.ulPhase = pChanEntry->CodecConfig.byPhase;
6953 f_pChannelStats->CodecConfig.ulPhasingType = pChanEntry->CodecConfig.byPhasingType;
6954
6955 if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
6956 {
6957 tPOCT6100_API_PHASING_TSST pPhasingTsstEntry;
6958
6959 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingTsstEntry, pChanEntry->usPhasingTsstIndex );
6960
6961 f_pChannelStats->CodecConfig.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingTsstEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pChanEntry->usPhasingTsstIndex;
6962 }
6963 else
6964 {
6965 f_pChannelStats->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
6966 }
6967
6968
6969 /* Reset the stats and exit if the reset flag is set.*/
6970 if ( f_pChannelStats->fResetStats == TRUE )
6971 {
6972 pChanEntry->sMaxERLE = cOCT6100_INVALID_SIGNED_STAT_W;
6973 pChanEntry->sMaxERL = cOCT6100_INVALID_SIGNED_STAT_W;
6974 pChanEntry->usMaxEchoDelay = cOCT6100_INVALID_STAT_W;
6975 }
6976
6977 /*---------------------------------------------------------------------*/
6978 /* Update the API internal stats.*/
6979
6980 BurstParams.ulReadAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
6981 BurstParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsOfst;
6982 BurstParams.ulReadLength = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsSize / 2; /* Length in words.*/
6983
6984 mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult );
6985 if ( ulResult != cOCT6100_ERR_OK )
6986 return ulResult;
6987
6988 /* Check if the energy stat are found in the new memory location. */
6989 if ( ( pSharedInfo->ImageInfo.fRinEnergyStat == TRUE )
6990 && ( pSharedInfo->ImageInfo.fSoutEnergyStat == TRUE ) )
6991 {
6992 ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.usDwordOffset * 4;
6993 ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.byBitOffset;
6994 ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst.byFieldSize;
6995
6996 ReadParams.ulReadAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
6997 ReadParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + ulFeatureBytesOffset;
6998
6999 /* Optimize this access by only reading the word we are interested in. */
7000 if ( ulFeatureBitOffset < 16 )
7001 ReadParams.ulReadAddress += 2;
7002
7003 /* Must read in memory directly since this value is changed by hardware */
7004 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
7005 if ( ulResult != cOCT6100_ERR_OK )
7006 return ulResult;
7007
7008 /* Move data at correct position according to what was read. */
7009 if ( ulFeatureBitOffset < 16 )
7010 ulTempData = usReadData;
7011 else
7012 ulTempData = usReadData << 16;
7013
7014 /* Clear previous value set in the feature field. */
7015 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7016
7017 ulTempData &= ulMask;
7018
7019 /* Shift to get value. */
7020 ulTempData = ulTempData >> ulFeatureBitOffset;
7021
7022 /* Overwrite value read the old way. */
7023 ausReadData[ 0 ] &= 0x00FF;
7024 ausReadData[ 0 ] |= (UINT16)( ( ulTempData << 8 ) & 0xFF00 );
7025
7026 ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.usDwordOffset * 4;
7027 ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.byBitOffset;
7028 ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst.byFieldSize;
7029
7030 ReadParams.ulReadAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + (usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
7031 ReadParams.ulReadAddress += f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst + ulFeatureBytesOffset;
7032
7033 /* Optimize this access by only reading the word we are interested in. */
7034 if ( ulFeatureBitOffset < 16 )
7035 ReadParams.ulReadAddress += 2;
7036
7037 /* Must read in memory directly since this value is changed by hardware */
7038 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
7039 if ( ulResult != cOCT6100_ERR_OK )
7040 return ulResult;
7041
7042 /* Move data at correct position according to what was read. */
7043 if ( ulFeatureBitOffset < 16 )
7044 ulTempData = usReadData;
7045 else
7046 ulTempData = usReadData << 16;
7047
7048 /* Clear previous value set in the feature field. */
7049 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7050
7051 ulTempData &= ulMask;
7052
7053 /* Shift to get value. */
7054 ulTempData = ulTempData >> ulFeatureBitOffset;
7055
7056 /* Overwrite value read the old way. */
7057 ausReadData[ 1 ] &= 0x00FF;
7058 ausReadData[ 1 ] |= (UINT16)( ( ulTempData << 8 ) & 0xFF00 );
7059 }
7060
7061 byRinEnergyRaw = (BYTE)(( ausReadData[ 0 ] >> 8 ) & 0xFF);
7062 bySinEnergyRaw = (BYTE)(( ausReadData[ 0 ] >> 0 ) & 0xFF);
7063 bySoutEnergyRaw = (BYTE)(( ausReadData[ 1 ] >> 8 ) & 0xFF);
7064 byCnEnergyRaw = (BYTE)(( ausReadData[ 5 ] >> 8 ) & 0xFF);
7065
7066 usEchoDelayInFrames = (UINT16)(ausReadData[ 4 ]);
7067 usErlRaw = ausReadData[ 2 ];
7068
7069 pChanEntry->byToneDisablerStatus = (UINT8)(( ausReadData[ 5 ] >> 0 ) & 0xFF);
7070 if ( f_pChannelStats->fResetStats == TRUE )
7071 {
7072 pChanEntry->usNumEchoPathChangesOfst = (UINT16)(ausReadData[ 3 ]);
7073 pChanEntry->usNumEchoPathChanges = 0;
7074 }
7075 else /* if ( f_pChannelStats->fResetStats == FALSE ) */
7076 {
7077 pChanEntry->usNumEchoPathChanges = (UINT16)( ausReadData[ 3 ] - pChanEntry->usNumEchoPathChangesOfst );
7078 }
7079
7080 pChanEntry->sComfortNoiseLevel = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( byCnEnergyRaw ) & 0xFFFF );
7081 pChanEntry->sComfortNoiseLevel -= 12;
7082 pChanEntry->sRinLevel = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( byRinEnergyRaw ) & 0xFFFF );
7083 pChanEntry->sRinLevel -= 12;
7084 pChanEntry->sSinLevel = (INT16)( Oct6100ApiOctFloatToDbEnergyByte( bySinEnergyRaw ) & 0xFFFF );
7085 pChanEntry->sSinLevel -= 12;
7086 lSoutEnergyIndB = Oct6100ApiOctFloatToDbEnergyByte( bySoutEnergyRaw );
7087 lSoutEnergyIndB -= 12;
7088
7089 /* Process some stats only if the channel is converged.*/
7090 if ( ( usEchoDelayInFrames != cOCT6100_INVALID_ECHO_DELAY )
7091 && ( pChanEntry->byEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN )
7092 && ( pChanEntry->byEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET ) )
7093 {
7094 /* Update the current ERL. */
7095 pChanEntry->sCurrentERL = (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( usErlRaw ) & 0xFFFF );
7096 pChanEntry->sCurrentERLE = (INT16)( ( lSoutEnergyIndB - pChanEntry->sSinLevel ) & 0xFFFF );
7097 pChanEntry->usCurrentEchoDelay = (UINT16)( usEchoDelayInFrames / 8 ); /* To convert in msec.*/
7098
7099 /* Update the max value if required.*/
7100 if ( pChanEntry->usCurrentEchoDelay > pChanEntry->usMaxEchoDelay ||
7101 pChanEntry->usMaxEchoDelay == cOCT6100_INVALID_STAT_W )
7102 {
7103 pChanEntry->usMaxEchoDelay = pChanEntry->usCurrentEchoDelay;
7104 }
7105
7106 if ( pChanEntry->sCurrentERL > pChanEntry->sMaxERL ||
7107 pChanEntry->sMaxERL == cOCT6100_INVALID_SIGNED_STAT_W )
7108 {
7109 pChanEntry->sMaxERL = pChanEntry->sCurrentERL;
7110 }
7111
7112 if ( pChanEntry->sCurrentERLE > pChanEntry->sMaxERLE ||
7113 pChanEntry->sMaxERLE == cOCT6100_INVALID_SIGNED_STAT_W )
7114 {
7115 pChanEntry->sMaxERLE = pChanEntry->sCurrentERLE;
7116 }
7117 }
7118 else
7119 {
7120 pChanEntry->sCurrentERLE = cOCT6100_INVALID_SIGNED_STAT_W;
7121 pChanEntry->sCurrentERL = cOCT6100_INVALID_SIGNED_STAT_W;
7122 pChanEntry->usCurrentEchoDelay = cOCT6100_INVALID_STAT_W;
7123 }
7124
7125 if ( f_pApiInstance->pSharedInfo->ImageInfo.fRinAppliedGainStat == TRUE )
7126 {
7127 /* Calculate base address for auto level control + high level compensation configuration. */
7128 ulBaseAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + ( usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
7129
7130 ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.usDwordOffset * 4;
7131 ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.byBitOffset;
7132 ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst.byFieldSize;
7133
7134 ReadParams.ulReadAddress = ulBaseAddress + ulFeatureBytesOffset;
7135
7136 /* Optimize this access by only reading the word we are interested in. */
7137 if ( ulFeatureBitOffset < 16 )
7138 ReadParams.ulReadAddress += 2;
7139
7140 /* Must read in memory directly since this value is changed by hardware */
7141 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
7142 if ( ulResult != cOCT6100_ERR_OK )
7143 return ulResult;
7144
7145 /* Move data at correct position according to what was read. */
7146 if ( ulFeatureBitOffset < 16 )
7147 ulTempData = usReadData;
7148 else
7149 ulTempData = usReadData << 16;
7150
7151 /* Clear previous value set in the feature field.*/
7152 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7153
7154 ulTempData &= ulMask;
7155
7156 /* Shift to get value. */
7157 ulTempData = ulTempData >> ulFeatureBitOffset;
7158
7159 pChanEntry->sRinAppliedGain = (INT16)( 2 * (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)( ulTempData & 0xFFFF ) ) & 0xFFFF ) );
7160 }
7161
7162 if ( f_pApiInstance->pSharedInfo->ImageInfo.fSoutAppliedGainStat == TRUE )
7163 {
7164 /* Calculate base address for auto level control + high level compensation configuration. */
7165 ulBaseAddress = f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase + ( usChanIndex * f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
7166
7167 ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.usDwordOffset * 4;
7168 ulFeatureBitOffset = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.byBitOffset;
7169 ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst.byFieldSize;
7170
7171 ReadParams.ulReadAddress = ulBaseAddress + ulFeatureBytesOffset;
7172
7173 /* Optimize this access by only reading the word we are interested in. */
7174 if ( ulFeatureBitOffset < 16 )
7175 ReadParams.ulReadAddress += 2;
7176
7177 /* Must read in memory directly since this value is changed by hardware */
7178 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
7179 if ( ulResult != cOCT6100_ERR_OK )
7180 return ulResult;
7181
7182 /* Move data at correct position according to what was read. */
7183 if ( ulFeatureBitOffset < 16 )
7184 ulTempData = usReadData;
7185 else
7186 ulTempData = usReadData << 16;
7187
7188 /* Clear previous value set in the feature field. */
7189 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7190
7191 ulTempData &= ulMask;
7192
7193 /* Shift to get value. */
7194 ulTempData = ulTempData >> ulFeatureBitOffset;
7195
7196 pChanEntry->sSoutAppliedGain = (INT16)( 2 * (INT16)( Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)( ulTempData & 0xFFFF ) ) & 0xFFFF ) );
7197 }
7198
7199 /*---------------------------------------------------------------------*/
7200 /* Return the real stats.*/
7201
7202 f_pChannelStats->ulNumEchoPathChanges = pChanEntry->usNumEchoPathChanges;
7203 if ( usEchoDelayInFrames != cOCT6100_INVALID_ECHO_DELAY )
7204 {
7205 f_pChannelStats->fEchoCancellerConverged = TRUE;
7206 }
7207 else
7208 {
7209 f_pChannelStats->fEchoCancellerConverged = FALSE;
7210 }
7211 if ( pChanEntry->sCurrentERL == cOCT6100_INVALID_SIGNED_STAT_W )
7212 f_pChannelStats->lCurrentERL = cOCT6100_INVALID_SIGNED_STAT;
7213 else
7214 f_pChannelStats->lCurrentERL = pChanEntry->sCurrentERL;
7215
7216 if ( pChanEntry->sMaxERL == cOCT6100_INVALID_SIGNED_STAT_W )
7217 f_pChannelStats->lMaxERL = cOCT6100_INVALID_SIGNED_STAT;
7218 else
7219 f_pChannelStats->lMaxERL = pChanEntry->sMaxERL;
7220
7221 if ( pChanEntry->usMaxEchoDelay == cOCT6100_INVALID_STAT_W )
7222 f_pChannelStats->ulMaxEchoDelay = cOCT6100_INVALID_STAT;
7223 else
7224 f_pChannelStats->ulMaxEchoDelay = pChanEntry->usMaxEchoDelay;
7225
7226 if ( pChanEntry->sRinLevel == cOCT6100_INVALID_SIGNED_STAT_W )
7227 f_pChannelStats->lRinLevel = cOCT6100_INVALID_SIGNED_STAT;
7228 else
7229 f_pChannelStats->lRinLevel = pChanEntry->sRinLevel;
7230
7231 if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
7232 {
7233 if ( pChanEntry->sSinLevel == cOCT6100_INVALID_SIGNED_STAT_W )
7234 f_pChannelStats->lSinLevel = cOCT6100_INVALID_SIGNED_STAT;
7235 else
7236 f_pChannelStats->lSinLevel = pChanEntry->sSinLevel;
7237 }
7238 else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
7239 {
7240 /* SIN level is not supported in this image. */
7241 f_pChannelStats->lSinLevel = cOCT6100_INVALID_SIGNED_STAT;
7242 }
7243
7244 f_pChannelStats->lRinAppliedGain = pChanEntry->VqeConfig.chRinLevelControlGainDb;
7245 if ( ( f_pApiInstance->pSharedInfo->ImageInfo.fRinAppliedGainStat == TRUE )
7246 && ( ( pChanEntry->VqeConfig.fRinAutomaticLevelControl == TRUE )
7247 || ( pChanEntry->VqeConfig.fRinHighLevelCompensation == TRUE ) ) )
7248 {
7249 f_pChannelStats->lRinAppliedGain = pChanEntry->sRinAppliedGain;
7250 }
7251
7252 f_pChannelStats->lSoutAppliedGain = pChanEntry->VqeConfig.chSoutLevelControlGainDb;
7253 if ( ( f_pApiInstance->pSharedInfo->ImageInfo.fSoutAppliedGainStat == TRUE )
7254 && ( pChanEntry->VqeConfig.fSoutAutomaticLevelControl == TRUE ) )
7255 {
7256 f_pChannelStats->lSoutAppliedGain = pChanEntry->sSoutAppliedGain;
7257 }
7258
7259 if ( pChanEntry->usCurrentEchoDelay == cOCT6100_INVALID_STAT_W )
7260 f_pChannelStats->ulCurrentEchoDelay = cOCT6100_INVALID_STAT;
7261 else
7262 f_pChannelStats->ulCurrentEchoDelay = pChanEntry->usCurrentEchoDelay;
7263
7264 if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
7265 {
7266 if ( pChanEntry->sCurrentERLE == cOCT6100_INVALID_SIGNED_STAT_W )
7267 f_pChannelStats->lCurrentERLE = cOCT6100_INVALID_SIGNED_STAT;
7268 else
7269 f_pChannelStats->lCurrentERLE = pChanEntry->sCurrentERLE;
7270 }
7271 else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
7272 {
7273 f_pChannelStats->lCurrentERLE = cOCT6100_INVALID_SIGNED_STAT;
7274 }
7275
7276 if ( pSharedInfo->ImageInfo.fSinLevel == TRUE )
7277 {
7278 if ( pChanEntry->sMaxERLE == cOCT6100_INVALID_SIGNED_STAT_W )
7279 f_pChannelStats->lMaxERLE = cOCT6100_INVALID_SIGNED_STAT;
7280 else
7281 f_pChannelStats->lMaxERLE = pChanEntry->sMaxERLE;
7282 }
7283 else /* if ( pSharedInfo->ImageInfo.fSinLevel != TRUE ) */
7284 {
7285 f_pChannelStats->lMaxERLE = cOCT6100_INVALID_SIGNED_STAT;
7286 }
7287
7288 f_pChannelStats->lComfortNoiseLevel = pChanEntry->sComfortNoiseLevel;
7289 f_pChannelStats->ulToneDisablerStatus = pChanEntry->byToneDisablerStatus;
7290
7291 if ( f_pApiInstance->pSharedInfo->ImageInfo.fSinVoiceDetectedStat == TRUE )
7292 {
7293 UINT32 ulVoiceDetectedBytesOfst = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.usDwordOffset * 4;
7294 UINT32 ulVoiceDetectedBitOfst = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.byBitOffset;
7295 UINT32 ulVoiceDetectedFieldSize = f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst.byFieldSize;
7296
7297 /* Set the channel root base address.*/
7298 UINT32 ulChannelRootBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( usChanIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanRootConfOfst;
7299
7300 ReadParams.ulReadAddress = ulChannelRootBaseAddress + ulVoiceDetectedBytesOfst;
7301
7302 /* Optimize this access by only reading the word we are interested in. */
7303 if ( ulVoiceDetectedBitOfst < 16 )
7304 ReadParams.ulReadAddress += 2;
7305
7306 /* Must read in memory directly since this value is changed by hardware */
7307 mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
7308 if ( ulResult != cOCT6100_ERR_OK )
7309 return ulResult;
7310
7311 /* Move data at correct position according to what was read. */
7312 if ( ulVoiceDetectedBitOfst < 16 )
7313 ulTempData = usReadData;
7314 else
7315 ulTempData = usReadData << 16;
7316
7317 mOCT6100_CREATE_FEATURE_MASK( ulVoiceDetectedFieldSize, ulVoiceDetectedBitOfst, &ulMask );
7318
7319 if ( ( ulTempData & ulMask ) != 0x0 )
7320 f_pChannelStats->fSinVoiceDetected = TRUE;
7321 else
7322 f_pChannelStats->fSinVoiceDetected = FALSE;
7323 }
7324
7325 /*---------------------------------------------------------------------*/
7326
7327 return cOCT6100_ERR_OK;
7328 }
7329 #endif
7330
7331
7332 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7333
7334 Function: Oct6100ApiReserveEchoEntry
7335
7336 Description: Reserves one of the echo channel API entry.
7337
7338 -------------------------------------------------------------------------------
7339 | Argument | Description
7340 -------------------------------------------------------------------------------
7341 f_pApiInstance Pointer to API instance. This memory is used to keep
7342 the present state of the chip and all its resources.
7343
7344 f_pusEchoIndex Resulting index reserved in the echo channel list.
7345
7346 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7347 #if !SKIP_Oct6100ApiReserveEchoEntry
7348 UINT32 Oct6100ApiReserveEchoEntry(
7349 IN tPOCT6100_INSTANCE_API f_pApiInstance,
7350 OUT PUINT16 f_pusEchoIndex )
7351 {
7352 tPOCT6100_SHARED_INFO pSharedInfo;
7353 PVOID pEchoAlloc;
7354 UINT32 ulResult;
7355 UINT32 ulEchoIndex;
7356
7357 /* Get local pointer to shared portion of instance. */
7358 pSharedInfo = f_pApiInstance->pSharedInfo;
7359
7360 mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc )
7361
7362 ulResult = OctapiLlmAllocAlloc( pEchoAlloc, &ulEchoIndex );
7363 if ( ulResult != cOCT6100_ERR_OK )
7364 {
7365 if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
7366 return cOCT6100_ERR_CHANNEL_ALL_CHANNELS_ARE_OPENED;
7367 else
7368 return cOCT6100_ERR_FATAL_11;
7369 }
7370
7371 *f_pusEchoIndex = (UINT16)( ulEchoIndex & 0xFFFF );
7372
7373 return cOCT6100_ERR_OK;
7374 }
7375 #endif
7376
7377
7378 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7379
7380 Function: Oct6100ApiReleaseEchoEntry
7381
7382 Description: Releases the specified ECHO channel API entry.
7383
7384 -------------------------------------------------------------------------------
7385 | Argument | Description
7386 -------------------------------------------------------------------------------
7387 f_pApiInstance Pointer to API instance. This memory is used to keep
7388 the present state of the chip and all its resources.
7389
7390 f_usEchoIndex Index reserved in the echo channel list.
7391
7392 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7393 #if !SKIP_Oct6100ApiReleaseEchoEntry
7394 UINT32 Oct6100ApiReleaseEchoEntry(
7395 IN tPOCT6100_INSTANCE_API f_pApiInstance,
7396 IN UINT16 f_usEchoIndex )
7397 {
7398 tPOCT6100_SHARED_INFO pSharedInfo;
7399 PVOID pEchoAlloc;
7400 UINT32 ulResult;
7401
7402 /* Get local pointer to shared portion of instance. */
7403 pSharedInfo = f_pApiInstance->pSharedInfo;
7404
7405 mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc )
7406
7407 ulResult = OctapiLlmAllocDealloc( pEchoAlloc, f_usEchoIndex );
7408 if ( ulResult != cOCT6100_ERR_OK )
7409 {
7410 return cOCT6100_ERR_FATAL_12;
7411 }
7412
7413 return cOCT6100_ERR_OK;
7414 }
7415 #endif
7416
7417
7418 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7419
7420 Function: Oct6100ApiReserveBiDirChanEntry
7421
7422 Description: Reserves one of the bidirectional channel API entry.
7423
7424 -------------------------------------------------------------------------------
7425 | Argument | Description
7426 -------------------------------------------------------------------------------
7427 f_pApiInstance Pointer to API instance. This memory is used to keep
7428 the present state of the chip and all its resources.
7429
7430 f_pusBiDirChanIndex Resulting index reserved in the bidir channel list.
7431
7432 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7433 #if !SKIP_Oct6100ApiReserveBiDirChanEntry
7434 UINT32 Oct6100ApiReserveBiDirChanEntry(
7435 IN tPOCT6100_INSTANCE_API f_pApiInstance,
7436 OUT PUINT16 f_pusBiDirChanIndex )
7437 {
7438 tPOCT6100_SHARED_INFO pSharedInfo;
7439 PVOID pChanAlloc;
7440 UINT32 ulResult;
7441 UINT32 ulBiDirChanIndex;
7442
7443 /* Get local pointer to shared portion of the API instance. */
7444 pSharedInfo = f_pApiInstance->pSharedInfo;
7445
7446 mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pChanAlloc )
7447
7448 ulResult = OctapiLlmAllocAlloc( pChanAlloc, &ulBiDirChanIndex );
7449 if ( ulResult != cOCT6100_ERR_OK )
7450 {
7451 if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
7452 return cOCT6100_ERR_CHANNEL_ALL_BIDIR_CHANNELS_ARE_OPENED;
7453 else
7454 return cOCT6100_ERR_FATAL_9F;
7455 }
7456
7457 *f_pusBiDirChanIndex = (UINT16)( ulBiDirChanIndex & 0xFFFF );
7458
7459 return cOCT6100_ERR_OK;
7460 }
7461 #endif
7462
7463
7464 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7465
7466 Function: Oct6100ApiReleaseBiDirChanEntry
7467
7468 Description: Releases the specified bidirectional channel API entry.
7469
7470 -------------------------------------------------------------------------------
7471 | Argument | Description
7472 -------------------------------------------------------------------------------
7473 f_pApiInstance Pointer to API instance. This memory is used to keep
7474 the present state of the chip and all its resources.
7475
7476 f_ulBiDirChanIndex Bidirectional channel index within the API's Bidir channel list.
7477
7478 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7479 #if !SKIP_Oct6100ApiReleaseBiDirChanEntry
7480 UINT32 Oct6100ApiReleaseBiDirChanEntry(
7481 IN tPOCT6100_INSTANCE_API f_pApiInstance,
7482 IN UINT32 f_ulBiDirChanIndex )
7483 {
7484 tPOCT6100_SHARED_INFO pSharedInfo;
7485 PVOID pChanAlloc;
7486 UINT32 ulResult;
7487
7488 /* Get local pointer to shared portion of instance. */
7489 pSharedInfo = f_pApiInstance->pSharedInfo;
7490
7491 mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pChanAlloc )
7492
7493 ulResult = OctapiLlmAllocDealloc( pChanAlloc, f_ulBiDirChanIndex );
7494 if ( ulResult != cOCT6100_ERR_OK )
7495 {
7496 return cOCT6100_ERR_FATAL_A0;
7497 }
7498
7499 return cOCT6100_ERR_OK;
7500 }
7501 #endif
7502
7503
7504
7505 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7506
7507 Function: Oct6100ApiCheckTdmConfig
7508
7509 Description: This function will check the validity of the TDM config parameter
7510 of an Open TDM config structure.
7511
7512 -------------------------------------------------------------------------------
7513 | Argument | Description
7514 -------------------------------------------------------------------------------
7515 f_pApiInstance Pointer to API instance. This memory is used to keep
7516 the present state of the chip and all its resources.
7517
7518 f_pTdmConfig TDM config of the channel.
7519
7520 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7521 #if !SKIP_Oct6100ApiCheckTdmConfig
7522 UINT32 Oct6100ApiCheckTdmConfig(
7523 IN tPOCT6100_INSTANCE_API f_pApiInstance,
7524 IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig )
7525 {
7526 UINT32 ulResult;
7527
7528 /*==============================================================================*/
7529 /* Check the TDM configuration parameters.*/
7530
7531 /* Check the validity of the timeslot and Stream only if it is defined.*/
7532 if ( f_pTdmConfig->ulRinTimeslot != cOCT6100_UNASSIGNED ||
7533 f_pTdmConfig->ulRinStream != cOCT6100_UNASSIGNED )
7534 {
7535 if ( f_pTdmConfig->ulRinNumTssts != 1 &&
7536 f_pTdmConfig->ulRinNumTssts != 2 )
7537 return cOCT6100_ERR_CHANNEL_RIN_NUM_TSSTS;
7538
7539 /* Check the RIN TDM streams, timeslots component for errors.*/
7540 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
7541 f_pTdmConfig->ulRinNumTssts,
7542 f_pTdmConfig->ulRinTimeslot,
7543 f_pTdmConfig->ulRinStream,
7544 cOCT6100_INPUT_TSST );
7545 if ( ulResult != cOCT6100_ERR_OK )
7546 {
7547 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7548 {
7549 return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
7550 }
7551 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7552 {
7553 return cOCT6100_ERR_CHANNEL_RIN_STREAM;
7554 }
7555 else
7556 {
7557 return ulResult;
7558 }
7559 }
7560 }
7561
7562 /* Check the validity of the timeslot and Stream only if it is defined.*/
7563 if ( f_pTdmConfig->ulRoutTimeslot != cOCT6100_UNASSIGNED ||
7564 f_pTdmConfig->ulRoutStream != cOCT6100_UNASSIGNED )
7565 {
7566 if ( f_pTdmConfig->ulRoutNumTssts != 1 &&
7567 f_pTdmConfig->ulRoutNumTssts != 2 )
7568 return cOCT6100_ERR_CHANNEL_ROUT_NUM_TSSTS;
7569
7570 /* Check the ROUT TDM streams, timeslots component for errors.*/
7571 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
7572 f_pTdmConfig->ulRoutNumTssts,
7573 f_pTdmConfig->ulRoutTimeslot,
7574 f_pTdmConfig->ulRoutStream,
7575 cOCT6100_OUTPUT_TSST );
7576 if ( ulResult != cOCT6100_ERR_OK )
7577 {
7578 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7579 {
7580 return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT;
7581 }
7582 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7583 {
7584 return cOCT6100_ERR_CHANNEL_ROUT_STREAM;
7585 }
7586 else
7587 {
7588 return ulResult;
7589 }
7590 }
7591 }
7592
7593 /* Check the validity of the timeslot and Stream only if it is defined.*/
7594 if ( f_pTdmConfig->ulSinTimeslot != cOCT6100_UNASSIGNED ||
7595 f_pTdmConfig->ulSinStream != cOCT6100_UNASSIGNED )
7596 {
7597 if ( f_pTdmConfig->ulSinNumTssts != 1 &&
7598 f_pTdmConfig->ulSinNumTssts != 2 )
7599 return cOCT6100_ERR_CHANNEL_SIN_NUM_TSSTS;
7600
7601 /* Check the SIN TDM streams, timeslots component for errors.*/
7602 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
7603 f_pTdmConfig->ulSinNumTssts,
7604 f_pTdmConfig->ulSinTimeslot,
7605 f_pTdmConfig->ulSinStream,
7606 cOCT6100_INPUT_TSST );
7607 if ( ulResult != cOCT6100_ERR_OK )
7608 {
7609 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7610 {
7611 return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT;
7612 }
7613 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7614 {
7615 return cOCT6100_ERR_CHANNEL_SIN_STREAM;
7616 }
7617 else
7618 {
7619 return ulResult;
7620 }
7621 }
7622 }
7623
7624 /* Check the validity of the timeslot and Stream only if it is defined.*/
7625 if ( f_pTdmConfig->ulSoutTimeslot != cOCT6100_UNASSIGNED ||
7626 f_pTdmConfig->ulSoutStream != cOCT6100_UNASSIGNED )
7627 {
7628 if ( f_pTdmConfig->ulSoutNumTssts != 1 &&
7629 f_pTdmConfig->ulSoutNumTssts != 2 )
7630 return cOCT6100_ERR_CHANNEL_SOUT_NUM_TSSTS;
7631
7632 /* Check the ROUT TDM streams, timeslots component for errors.*/
7633 ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
7634 f_pTdmConfig->ulSoutNumTssts,
7635 f_pTdmConfig->ulSoutTimeslot,
7636 f_pTdmConfig->ulSoutStream,
7637 cOCT6100_OUTPUT_TSST );
7638 if ( ulResult != cOCT6100_ERR_OK )
7639 {
7640 if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
7641 {
7642 return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
7643 }
7644 else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
7645 {
7646 return cOCT6100_ERR_CHANNEL_SOUT_STREAM;
7647 }
7648 else
7649 {
7650 return ulResult;
7651 }
7652 }
7653 }
7654
7655 /* Check the PCM law parameters.*/
7656 if ( f_pTdmConfig->ulRinPcmLaw != cOCT6100_PCM_U_LAW &&
7657 f_pTdmConfig->ulRinPcmLaw != cOCT6100_PCM_A_LAW )
7658 return cOCT6100_ERR_CHANNEL_RIN_PCM_LAW;
7659
7660 if ( f_pTdmConfig->ulSinPcmLaw != cOCT6100_PCM_U_LAW &&
7661 f_pTdmConfig->ulSinPcmLaw != cOCT6100_PCM_A_LAW )
7662 return cOCT6100_ERR_CHANNEL_SIN_PCM_LAW;
7663
7664 if ( f_pTdmConfig->ulRoutPcmLaw != cOCT6100_PCM_U_LAW &&
7665 f_pTdmConfig->ulRoutPcmLaw != cOCT6100_PCM_A_LAW )
7666 return cOCT6100_ERR_CHANNEL_ROUT_PCM_LAW;
7667
7668 if ( f_pTdmConfig->ulSoutPcmLaw != cOCT6100_PCM_U_LAW &&
7669 f_pTdmConfig->ulSoutPcmLaw != cOCT6100_PCM_A_LAW )
7670 return cOCT6100_ERR_CHANNEL_SOUT_PCM_LAW;
7671
7672 /*==============================================================================*/
7673
7674
7675
7676 return cOCT6100_ERR_OK;
7677 }
7678 #endif
7679
7680
7681 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7682
7683 Function: Oct6100ApiCheckVqeConfig
7684
7685 Description: This function will check the validity of the VQE config parameter
7686 of an Open VQE config structure.
7687
7688 -------------------------------------------------------------------------------
7689 | Argument | Description
7690 -------------------------------------------------------------------------------
7691 f_pApiInstance Pointer to API instance. This memory is used to keep
7692 the present state of the chip and all its resources.
7693
7694 f_pVqeConfig VQE config of the channel.
7695 f_fEnableToneDisabler Whether the tone disabler is active or not.
7696
7697 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7698 #if !SKIP_Oct6100ApiCheckVqeConfig
7699 UINT32 Oct6100ApiCheckVqeConfig(
7700 IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
7701 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
7702 IN BOOL f_fEnableToneDisabler )
7703 {
7704 tPOCT6100_API_IMAGE_INFO pImageInfo;
7705
7706 pImageInfo = &f_pApiInstance->pSharedInfo->ImageInfo;
7707
7708 if ( f_pVqeConfig->fEnableNlp != TRUE && f_pVqeConfig->fEnableNlp != FALSE )
7709 return cOCT6100_ERR_CHANNEL_ENABLE_NLP;
7710
7711 if ( f_pVqeConfig->fEnableNlp == TRUE && pImageInfo->fNlpControl == FALSE )
7712 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLP_CONTROL;
7713
7714
7715
7716 /* Check the comfort noise mode.*/
7717 if ( f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_OFF && pImageInfo->fComfortNoise == FALSE )
7718 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_BKG_NOISE_FREEZE;
7719
7720 if ( f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_NORMAL &&
7721 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_EXTENDED &&
7722 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_FAST_LATCH &&
7723 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_OFF )
7724 return cOCT6100_ERR_CHANNEL_COMFORT_NOISE_MODE;
7725
7726 /* Check the DC offset removal.*/
7727 if ( f_pVqeConfig->fSinDcOffsetRemoval != TRUE && f_pVqeConfig->fSinDcOffsetRemoval != FALSE )
7728 return cOCT6100_ERR_CHANNEL_SIN_DC_OFFSET_REM;
7729
7730 if ( f_pVqeConfig->fSinDcOffsetRemoval == TRUE && pImageInfo->fSinDcOffsetRemoval == FALSE )
7731 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_DC_OFFSET_REM;
7732
7733 if ( f_pVqeConfig->fRinDcOffsetRemoval != TRUE && f_pVqeConfig->fRinDcOffsetRemoval != FALSE )
7734 return cOCT6100_ERR_CHANNEL_RIN_DC_OFFSET_REM;
7735
7736 if ( f_pVqeConfig->fRinDcOffsetRemoval == TRUE && pImageInfo->fRinDcOffsetRemoval == FALSE )
7737 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_DC_OFFSET_REM;
7738
7739 /* Check the Level control.*/
7740 if ( f_pVqeConfig->fRinLevelControl != TRUE && f_pVqeConfig->fRinLevelControl != FALSE )
7741 return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL;
7742
7743 if ( f_pVqeConfig->fSoutLevelControl != TRUE && f_pVqeConfig->fSoutLevelControl != FALSE )
7744 return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL;
7745
7746 if ( ( f_pVqeConfig->lRinLevelControlGainDb < -24 ) || ( f_pVqeConfig->lRinLevelControlGainDb > 24 ) )
7747 return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL_GAIN;
7748
7749 if ( ( f_pVqeConfig->lSoutLevelControlGainDb < -24 ) || ( f_pVqeConfig->lSoutLevelControlGainDb > 24 ) )
7750 return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL_GAIN;
7751
7752 if ( ( f_pVqeConfig->fRinAutomaticLevelControl != TRUE ) && ( f_pVqeConfig->fRinAutomaticLevelControl != FALSE ) )
7753 return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL;
7754
7755 if ( ( f_pVqeConfig->fRinHighLevelCompensation != TRUE ) && ( f_pVqeConfig->fRinHighLevelCompensation != FALSE ) )
7756 return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP;
7757
7758 if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) && ( pImageInfo->fRinAutoLevelControl == FALSE ) )
7759 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_AUTO_LC;
7760
7761 if ( ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) && ( pImageInfo->fRinHighLevelCompensation == FALSE ) )
7762 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_HIGH_LEVEL_COMP;
7763
7764 if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
7765 {
7766 if ( f_pVqeConfig->fRinLevelControl == TRUE )
7767 return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_MANUAL;
7768
7769 if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
7770 return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_HIGH_LEVEL_COMP;
7771
7772 if ( ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lRinAutomaticLevelControlTargetDb > 0 ) )
7773 return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL_TARGET;
7774 }
7775
7776 if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
7777 {
7778 if ( f_pVqeConfig->fRinLevelControl == TRUE )
7779 return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_MANUAL;
7780
7781 if ( ( f_pVqeConfig->lRinHighLevelCompensationThresholdDb < -40 || f_pVqeConfig->lRinHighLevelCompensationThresholdDb > 0 ) )
7782 return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_THRESHOLD;
7783 }
7784
7785 if ( f_pVqeConfig->fSoutAutomaticLevelControl != TRUE && f_pVqeConfig->fSoutAutomaticLevelControl != FALSE )
7786 return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL;
7787
7788 if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) && ( pImageInfo->fSoutAutoLevelControl == FALSE ) )
7789 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SOUT_AUTO_LC;
7790
7791 if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
7792 {
7793 if ( f_pVqeConfig->fSoutLevelControl == TRUE )
7794 return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_MANUAL;
7795
7796 if ( ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lSoutAutomaticLevelControlTargetDb > 0 ) )
7797 return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL_TARGET;
7798 }
7799
7800 if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != TRUE &&
7801 f_pVqeConfig->fSoutAdaptiveNoiseReduction != FALSE )
7802 return cOCT6100_ERR_CHANNEL_SOUT_ADAPT_NOISE_REDUCTION;
7803
7804 if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE && pImageInfo->fAdaptiveNoiseReduction == FALSE )
7805 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR;
7806
7807 if ( f_pVqeConfig->fSoutConferencingNoiseReduction != TRUE &&
7808 f_pVqeConfig->fSoutConferencingNoiseReduction != FALSE )
7809 return cOCT6100_ERR_CHANNEL_SOUT_CONFERENCE_NOISE_REDUCTION;
7810
7811 if ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE && pImageInfo->fConferencingNoiseReduction == FALSE )
7812 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_CNR;
7813
7814 /* Validate Sout noise bleaching parameter. */
7815 if ( f_pVqeConfig->fSoutNoiseBleaching != TRUE &&
7816 f_pVqeConfig->fSoutNoiseBleaching != FALSE )
7817 return cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING;
7818
7819 /* Check if firmware supports Sout noise bleaching. */
7820 if ( f_pVqeConfig->fSoutNoiseBleaching == TRUE && pImageInfo->fSoutNoiseBleaching == FALSE )
7821 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NOISE_BLEACHING;
7822
7823 /* If Sout noise bleaching is requested, no ANR or CNR shall be activated. */
7824 if ( f_pVqeConfig->fSoutNoiseBleaching == TRUE )
7825 {
7826 /* No xNR! */
7827 if ( ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE )
7828 || ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE ) )
7829 return cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING_NR;
7830 }
7831
7832 /* Cannot activate both ANR and CNR when noise bleaching is present */
7833 if ( pImageInfo->fSoutNoiseBleaching == TRUE )
7834 {
7835 if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE &&
7836 f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE )
7837 return cOCT6100_ERR_CHANNEL_ANR_CNR_SIMULTANEOUSLY;
7838 }
7839
7840 /* Validate the DTMF tone removal parameter.*/
7841 if ( f_pVqeConfig->fDtmfToneRemoval != TRUE && f_pVqeConfig->fDtmfToneRemoval != FALSE )
7842 return cOCT6100_ERR_CHANNEL_TONE_REMOVAL;
7843
7844 if ( f_pVqeConfig->fDtmfToneRemoval == TRUE && pImageInfo->fToneRemoval == FALSE )
7845 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_REMOVAL;
7846
7847
7848
7849 /* Check the Tail displacement enable.*/
7850 if ( f_pVqeConfig->fEnableTailDisplacement != TRUE && f_pVqeConfig->fEnableTailDisplacement != FALSE )
7851 return cOCT6100_ERR_CHANNEL_ENABLE_TAIL_DISPLACEMENT;
7852
7853 if ( f_pVqeConfig->fEnableTailDisplacement == TRUE && pImageInfo->fTailDisplacement == FALSE )
7854 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_DISPLACEMENT;
7855
7856 /* Check the Tail displacement value.*/
7857 if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
7858 {
7859 if ( f_pVqeConfig->ulTailDisplacement != cOCT6100_AUTO_SELECT_TAIL )
7860 {
7861 /* Check if this feature is supported by the image. */
7862 if ( pImageInfo->fPerChannelTailDisplacement == FALSE )
7863 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_PER_CHAN_TAIL;
7864
7865 /* Check that this value is not greater then what the image supports. */
7866 if ( f_pVqeConfig->ulTailDisplacement > pImageInfo->usMaxTailDisplacement )
7867 return cOCT6100_ERR_CHANNEL_TAIL_DISPLACEMENT_INVALID;
7868 }
7869 }
7870
7871 /* Check the tail length value. */
7872 if ( f_pVqeConfig->ulTailLength != cOCT6100_AUTO_SELECT_TAIL )
7873 {
7874 /* Check if this feature is supported by the image. */
7875 if ( ( pImageInfo->fPerChannelTailLength == FALSE )
7876 && ( (UINT16)( f_pVqeConfig->ulTailLength & 0xFFFF ) != pImageInfo->usMaxTailLength ) )
7877 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_LENGTH;
7878
7879 if ( ( f_pVqeConfig->ulTailLength < 32 ) || ( f_pVqeConfig->ulTailLength > 128 )
7880 || ( ( f_pVqeConfig->ulTailLength % 4 ) != 0x0 ) )
7881 return cOCT6100_ERR_CHANNEL_TAIL_LENGTH;
7882
7883 /* Check if the requested tail length is supported by the chip. */
7884 if ( f_pVqeConfig->ulTailLength > pImageInfo->usMaxTailLength )
7885 return cOCT6100_ERR_CHANNEL_TAIL_LENGTH_INVALID;
7886 }
7887
7888 /* Validate the acoustic echo cancellation parameter.*/
7889 if ( f_pVqeConfig->fAcousticEcho != TRUE && f_pVqeConfig->fAcousticEcho != FALSE )
7890 return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO;
7891
7892 if ( f_pVqeConfig->fAcousticEcho == TRUE && pImageInfo->fAcousticEcho == FALSE )
7893 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO;
7894
7895 if ( f_pVqeConfig->fAcousticEcho == TRUE )
7896 {
7897 /* Check if acoustic echo tail length configuration is supported in the image. */
7898 if ( ( f_pVqeConfig->ulAecTailLength != 128 ) && ( pImageInfo->fAecTailLength == FALSE ) )
7899 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH;
7900
7901 /* Check the requested acoustic echo tail length. */
7902 if ( ( f_pVqeConfig->ulAecTailLength != 128 )
7903 && ( f_pVqeConfig->ulAecTailLength != 256 )
7904 && ( f_pVqeConfig->ulAecTailLength != 512 )
7905 && ( f_pVqeConfig->ulAecTailLength != 1024 ) )
7906 return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH;
7907
7908 if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
7909 {
7910 UINT32 ulTailSum;
7911
7912 /* Start with requested tail displacement. */
7913 if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
7914 {
7915 ulTailSum = f_pApiInstance->pSharedInfo->ChipConfig.usTailDisplacement;
7916 }
7917 else
7918 {
7919 ulTailSum = f_pVqeConfig->ulTailDisplacement;
7920 }
7921
7922 /* Add requested tail length. */
7923 if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
7924 {
7925 ulTailSum += f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength;
7926 }
7927 else
7928 {
7929 ulTailSum += f_pVqeConfig->ulTailLength;
7930 }
7931
7932 /* The tail sum must be smaller then the requested AEC tail length. */
7933 if ( ulTailSum > f_pVqeConfig->ulAecTailLength )
7934 return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_SUM;
7935 }
7936 }
7937
7938 /* Validate the Default ERL parameter.*/
7939 if ( f_pVqeConfig->lDefaultErlDb != -6 && pImageInfo->fDefaultErl == FALSE )
7940 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DEFAULT_ERL;
7941
7942 if ( ( f_pVqeConfig->lDefaultErlDb != 0 ) &&
7943 ( f_pVqeConfig->lDefaultErlDb != -3 ) &&
7944 ( f_pVqeConfig->lDefaultErlDb != -6 ) &&
7945 ( f_pVqeConfig->lDefaultErlDb != -9 ) &&
7946 ( f_pVqeConfig->lDefaultErlDb != -12 ) )
7947 return cOCT6100_ERR_CHANNEL_DEFAULT_ERL;
7948
7949 /* Validate the Default AEC ERL parameter.*/
7950 if ( f_pVqeConfig->lAecDefaultErlDb != 0 && pImageInfo->fAecDefaultErl == FALSE )
7951 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_AEC_DEFAULT_ERL;
7952
7953 if ( f_pVqeConfig->lAecDefaultErlDb != 0 && f_pVqeConfig->lAecDefaultErlDb != -3 && f_pVqeConfig->lAecDefaultErlDb != -6 )
7954 return cOCT6100_ERR_CHANNEL_AEC_DEFAULT_ERL;
7955
7956 /* Validate the non-linearity A parameter.*/
7957 if ( f_pVqeConfig->ulNonLinearityBehaviorA != 1 && pImageInfo->fNonLinearityBehaviorA == FALSE )
7958 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DOUBLE_TALK;
7959
7960 if ( f_pVqeConfig->ulNonLinearityBehaviorA >= 14 )
7961 return cOCT6100_ERR_CHANNEL_DOUBLE_TALK;
7962
7963 /* Validate the non-linearity B parameter.*/
7964 if ( f_pVqeConfig->ulNonLinearityBehaviorB != 0 && pImageInfo->fNonLinearityBehaviorB == FALSE )
7965 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NON_LINEARITY_B;
7966
7967 if ( f_pVqeConfig->ulNonLinearityBehaviorB >= 9 )
7968 return cOCT6100_ERR_CHANNEL_NON_LINEARITY_B;
7969
7970 /* Check if configuring the double talk behavior is supported in the firmware. */
7971 if ( f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_NORMAL && pImageInfo->fDoubleTalkBehavior == FALSE )
7972 return cOCT6100_ERR_NOT_SUPPORTED_DOUBLE_TALK_BEHAVIOR_MODE;
7973
7974 /* Validate the double talk behavior mode parameter. */
7975 if ( f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_NORMAL && f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_LESS_AGGRESSIVE )
7976 return cOCT6100_ERR_CHANNEL_DOUBLE_TALK_MODE;
7977
7978 /* Validate the Sout automatic listener enhancement ratio. */
7979 if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 && pImageInfo->fListenerEnhancement == FALSE )
7980 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ALE;
7981
7982 if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb > 30 )
7983 return cOCT6100_ERR_CHANNEL_ALE_RATIO;
7984
7985 /* Validate the Sout natural listener enhancement ratio. */
7986 if ( f_pVqeConfig->fSoutNaturalListenerEnhancement != TRUE && f_pVqeConfig->fSoutNaturalListenerEnhancement != FALSE )
7987 return cOCT6100_ERR_CHANNEL_NLE_FLAG;
7988
7989 if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE && pImageInfo->fListenerEnhancement == FALSE )
7990 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLE;
7991
7992 if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
7993 {
7994 if ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb > 30 )
7995 return cOCT6100_ERR_CHANNEL_NLE_RATIO;
7996 }
7997
7998 /* Both ALE and NLE cannot be activated simultaneously. */
7999 if ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 )
8000 && ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE ) )
8001 return cOCT6100_ERR_CHANNEL_ALE_NLE_SIMULTANEOUSLY;
8002
8003 /* Validate Rout noise reduction. */
8004 if ( f_pVqeConfig->fRoutNoiseReduction != TRUE && f_pVqeConfig->fRoutNoiseReduction != FALSE )
8005 return cOCT6100_ERR_CHANNEL_ROUT_NOISE_REDUCTION;
8006
8007 /* Check if Rout noise reduction is supported. */
8008 if ( f_pVqeConfig->fRoutNoiseReduction == TRUE && pImageInfo->fRoutNoiseReduction == FALSE )
8009 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ROUT_NR;
8010
8011 /*Check if noise reduction level gain is supported*/
8012 if ( ( pImageInfo->fRoutNoiseReductionLevel == FALSE ) && ( f_pVqeConfig->lRoutNoiseReductionLevelGainDb != -18 ) )
8013 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ROUT_NOISE_REDUCTION_GAIN;
8014
8015 if ( ( f_pVqeConfig->lRoutNoiseReductionLevelGainDb != 0 ) &&
8016 ( f_pVqeConfig->lRoutNoiseReductionLevelGainDb != -6 ) &&
8017 ( f_pVqeConfig->lRoutNoiseReductionLevelGainDb != -12 ) &&
8018 ( f_pVqeConfig->lRoutNoiseReductionLevelGainDb != -18 ) )
8019
8020 return cOCT6100_ERR_CHANNEL_ROUT_NOISE_REDUCTION_GAIN;
8021
8022 /* Check if ANR SNRE is supported. */
8023 if ( ( f_pVqeConfig->lAnrSnrEnhancementDb != -18 ) && ( pImageInfo->fAnrSnrEnhancement == FALSE ) )
8024 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SNR_ENHANCEMENT;
8025
8026 /* Validate Sout ANR SNR enhancement. */
8027 if ( ( f_pVqeConfig->lAnrSnrEnhancementDb != -9 )
8028 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -12 )
8029 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -15 )
8030 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -18 )
8031 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -21 )
8032 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -24 )
8033 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -27 )
8034 && ( f_pVqeConfig->lAnrSnrEnhancementDb != -30 ) )
8035 return cOCT6100_ERR_CHANNEL_ANR_SNR_ENHANCEMENT;
8036
8037 /* Validate ANR voice-noise segregation. */
8038 if ( f_pVqeConfig->ulAnrVoiceNoiseSegregation > 15 )
8039 return cOCT6100_ERR_CHANNEL_ANR_SEGREGATION;
8040
8041 /* Check if ANR VN segregation is supported. */
8042 if ( ( f_pVqeConfig->ulAnrVoiceNoiseSegregation != 6 ) && ( pImageInfo->fAnrVoiceNoiseSegregation == FALSE ) )
8043 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SEGREGATION;
8044
8045 /* Check if the loaded image supports tone disabler VQE activation delay. */
8046 if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != 300 )
8047 && ( pImageInfo->fToneDisablerVqeActivationDelay == FALSE ) )
8048 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY;
8049
8050 /* Check if the specified tone disabler VQE activation delay is correct. */
8051 if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay < 300 )
8052 || ( ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay - 300 ) % 512 ) != 0 ) )
8053 return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY;
8054
8055 /* Check the enable music protection flag. */
8056 if ( ( f_pVqeConfig->fEnableMusicProtection != TRUE ) && ( f_pVqeConfig->fEnableMusicProtection != FALSE ) )
8057 return cOCT6100_ERR_CHANNEL_ENABLE_MUSIC_PROTECTION;
8058
8059 /* The music protection module can only be activated if the image supports it. */
8060 if ( ( f_pVqeConfig->fEnableMusicProtection == TRUE ) &&
8061 ( pImageInfo->fMusicProtection == FALSE ) )
8062 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_MUSIC_PROTECTION;
8063
8064 /* Check the enable idle code detection flag. */
8065 if ( ( f_pVqeConfig->fIdleCodeDetection != TRUE ) && ( f_pVqeConfig->fIdleCodeDetection != FALSE ) )
8066 return cOCT6100_ERR_CHANNEL_IDLE_CODE_DETECTION;
8067
8068 /* The idle code detection module can only be activated if the image supports it. */
8069 if ( ( f_pVqeConfig->fIdleCodeDetection == TRUE ) && ( pImageInfo->fIdleCodeDetection == FALSE ) )
8070 return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION;
8071
8072 /* The idle code detection module can be disabled only if idle code detection configuration */
8073 /* is supported in the image. */
8074 if ( pImageInfo->fIdleCodeDetection == TRUE )
8075 {
8076 if ( ( f_pVqeConfig->fIdleCodeDetection == FALSE ) && ( pImageInfo->fIdleCodeDetectionConfiguration == FALSE ) )
8077 return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION_CONFIG;
8078 }
8079
8080 return cOCT6100_ERR_OK;
8081 }
8082 #endif
8083
8084 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8085
8086 Function: Oct6100ApiCheckCodecConfig
8087
8088 Description: This function will check the validity of the Codec config parameter
8089 of an Open Codec config structure.
8090
8091 -------------------------------------------------------------------------------
8092 | Argument | Description
8093 -------------------------------------------------------------------------------
8094 f_pApiInstance Pointer to API instance. This memory is used to keep
8095 the present state of the chip and all its resources.
8096
8097 f_pCodecConfig Codec config of the channel.
8098 f_ulDecoderNumTssts Number of TSST for the decoder.
8099 f_pusPhasingTsstIndex Pointer to the Phasing TSST index within the API's phasing TSST list.
8100
8101 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8102 #if !SKIP_Oct6100ApiCheckCodecConfig
8103 UINT32 Oct6100ApiCheckCodecConfig(
8104 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8105 IN tPOCT6100_CHANNEL_OPEN_CODEC f_pCodecConfig,
8106 IN UINT32 f_ulDecoderNumTssts,
8107 OUT PUINT16 f_pusPhasingTsstIndex )
8108 {
8109
8110 /* Verify the ADPCM nibble value.*/
8111 if ( f_pCodecConfig->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_LOW_BITS &&
8112 f_pCodecConfig->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_HIGH_BITS )
8113 return cOCT6100_ERR_CHANNEL_ADPCM_NIBBLE;
8114
8115 /* Verify the Encoder port.*/
8116 if ( f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_ROUT &&
8117 f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_SOUT &&
8118 f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
8119 return cOCT6100_ERR_CHANNEL_ENCODER_PORT;
8120
8121 /* Verify the Decoder port.*/
8122 if ( f_pCodecConfig->ulDecoderPort != cOCT6100_CHANNEL_PORT_RIN &&
8123 f_pCodecConfig->ulDecoderPort != cOCT6100_CHANNEL_PORT_SIN &&
8124 f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
8125 return cOCT6100_ERR_CHANNEL_DECODER_PORT;
8126
8127 /* The codec cannot be on the same stream.*/
8128 if ( f_pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT &&
8129 f_pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
8130 return cOCT6100_ERR_CHANNEL_INVALID_CODEC_POSITION;
8131
8132 if ( f_pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT &&
8133 f_pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN )
8134 return cOCT6100_ERR_CHANNEL_INVALID_CODEC_POSITION;
8135
8136 /* Verify if the requested functions are supported by the chip.*/
8137 if ( f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm == FALSE &&
8138 f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
8139 {
8140 if ( f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS )
8141 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ENCODING;
8142 }
8143
8144 if ( f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm == FALSE &&
8145 f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
8146 {
8147 if ( f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS )
8148 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DECODING;
8149 }
8150
8151 /* Check if encoder port has been specified when a rate has been set. */
8152 if ( f_pCodecConfig->ulEncoderPort == cOCT6100_NO_ENCODING &&
8153 f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS )
8154 return cOCT6100_ERR_CHANNEL_ENCODER_PORT;
8155
8156 /* Check if decoder port has been specified when a rate has been set. */
8157 if ( f_pCodecConfig->ulDecoderPort == cOCT6100_NO_DECODING &&
8158 f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS )
8159 return cOCT6100_ERR_CHANNEL_DECODER_PORT;
8160
8161 /* Check Encoder related parameter if one is used.*/
8162 if ( f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
8163 {
8164 /* Check the Encoder compression rate.*/
8165 if ( ( f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS ) &&
8166 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_40KBPS ) &&
8167 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_32KBPS ) &&
8168 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_24KBPS ) &&
8169 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G726_16KBPS ) &&
8170 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_40KBPS_4_1 ) &&
8171 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_40KBPS_3_2 ) &&
8172 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_40KBPS_2_3 ) &&
8173 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_32KBPS_4_0 ) &&
8174 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_32KBPS_3_1 ) &&
8175 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_32KBPS_2_2 ) &&
8176 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_24KBPS_3_0 ) &&
8177 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_24KBPS_2_1 ) &&
8178 ( f_pCodecConfig->ulEncodingRate != cOCT6100_G727_16KBPS_2_0 ) )
8179 return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
8180
8181 /* Verify phasing information.*/
8182 if ( f_pCodecConfig->ulPhasingType != cOCT6100_SINGLE_PHASING &&
8183 f_pCodecConfig->ulPhasingType != cOCT6100_DUAL_PHASING &&
8184 f_pCodecConfig->ulPhasingType != cOCT6100_NO_PHASING )
8185 return cOCT6100_ERR_CHANNEL_PHASING_TYPE;
8186
8187 /* Verify the silence suppression parameters.*/
8188 if ( f_pCodecConfig->fEnableSilenceSuppression != TRUE &&
8189 f_pCodecConfig->fEnableSilenceSuppression != FALSE )
8190 return cOCT6100_ERR_CHANNEL_SIL_SUP_ENABLE;
8191
8192 if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8193 f_pApiInstance->pSharedInfo->ImageInfo.fSilenceSuppression == FALSE )
8194 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIL_SUP;
8195
8196 if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8197 f_pCodecConfig->ulPhasingType == cOCT6100_NO_PHASING )
8198 return cOCT6100_ERR_CHANNEL_PHASE_TYPE_REQUIRED;
8199
8200 if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8201 f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE )
8202 return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED;
8203
8204 if ( f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE &&
8205 f_pCodecConfig->ulPhasingType != cOCT6100_NO_PHASING )
8206 return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED;
8207
8208 /* Silence suppression can only be performed if the encoder is using the SOUT port.*/
8209 if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
8210 f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_SOUT )
8211 return cOCT6100_ERR_CHANNEL_SIL_SUP_INVALID_ENCODER_PORT;
8212
8213 /* Check phasing TSST info if phasing is required.*/
8214 if ( f_pCodecConfig->ulPhasingTsstHndl != cOCT6100_INVALID_HANDLE )
8215 {
8216 tPOCT6100_API_PHASING_TSST pPhasingEntry;
8217 UINT32 ulEntryOpenCnt;
8218
8219 /* Check the provided handle. */
8220 if ( (f_pCodecConfig->ulPhasingTsstHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_PHASING_TSST )
8221 return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
8222
8223 *f_pusPhasingTsstIndex = (UINT16)( f_pCodecConfig->ulPhasingTsstHndl & cOCT6100_HNDL_INDEX_MASK );
8224 if ( *f_pusPhasingTsstIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxPhasingTssts )
8225 return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
8226
8227 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, *f_pusPhasingTsstIndex );
8228
8229 /* Extract the entry open count from the provided handle. */
8230 ulEntryOpenCnt = (f_pCodecConfig->ulPhasingTsstHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
8231
8232 /* Verify if the state of the phasing TSST.*/
8233 if ( pPhasingEntry->fReserved != TRUE )
8234 return cOCT6100_ERR_CHANNEL_PHASING_TSST_NOT_OPEN;
8235 if ( ulEntryOpenCnt != pPhasingEntry->byEntryOpenCnt )
8236 return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
8237
8238 /* Check the specified phase value against the phasing length of the phasing TSST.*/
8239 if ( ( f_pCodecConfig->ulPhase == 0 )
8240 || ( f_pCodecConfig->ulPhase >= pPhasingEntry->usPhasingLength ) )
8241 return cOCT6100_ERR_CHANNEL_PHASING_INVALID_PHASE;
8242 }
8243 else
8244 {
8245 *f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX;
8246 }
8247 }
8248 else
8249 {
8250 *f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX;
8251 }
8252
8253
8254 /* Check Decoder related parameter if one is used.*/
8255 if ( f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
8256 {
8257 /* Check the Decoding rate.*/
8258 if ( f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS &&
8259 f_pCodecConfig->ulDecodingRate != cOCT6100_G726_40KBPS &&
8260 f_pCodecConfig->ulDecodingRate != cOCT6100_G726_32KBPS &&
8261 f_pCodecConfig->ulDecodingRate != cOCT6100_G726_24KBPS &&
8262 f_pCodecConfig->ulDecodingRate != cOCT6100_G726_16KBPS &&
8263 f_pCodecConfig->ulDecodingRate != cOCT6100_G726_ENCODED &&
8264 f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G726_ENCODED &&
8265 f_pCodecConfig->ulDecodingRate != cOCT6100_G727_2C_ENCODED &&
8266 f_pCodecConfig->ulDecodingRate != cOCT6100_G727_3C_ENCODED &&
8267 f_pCodecConfig->ulDecodingRate != cOCT6100_G727_4C_ENCODED &&
8268 f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G727_2C_ENCODED &&
8269 f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G727_3C_ENCODED &&
8270 f_pCodecConfig->ulDecodingRate != cOCT6100_G711_G727_4C_ENCODED )
8271 return cOCT6100_ERR_CHANNEL_DECODING_RATE;
8272
8273 /* Make sure that two timeslot are allocated if PCM-ECHO encoded is selected.*/
8274 if ( (f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G726_ENCODED ||
8275 f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_2C_ENCODED ||
8276 f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_3C_ENCODED ||
8277 f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_4C_ENCODED ) &&
8278 f_ulDecoderNumTssts != 2 )
8279 return cOCT6100_ERR_CHANNEL_MISSING_TSST;
8280 }
8281
8282 return cOCT6100_ERR_OK;
8283 }
8284 #endif
8285
8286 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8287
8288 Function: Oct6100ApiWriteInputTsstControlMemory
8289
8290 Description: This function configure a TSST control memory entry in internal memory.
8291
8292 -------------------------------------------------------------------------------
8293 | Argument | Description
8294 -------------------------------------------------------------------------------
8295 f_pApiInstance Pointer to API instance. This memory is used to keep
8296 the present state of the chip and all its resources.
8297
8298 f_usTsstIndex TSST index within the TSST control memory.
8299 f_usTsiMemIndex TSI index within the TSI chariot memory.
8300 f_ulTsstInputLaw PCM law of the input TSST.
8301
8302 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8303 #if !SKIP_Oct6100ApiWriteInputTsstControlMemory
8304 UINT32 Oct6100ApiWriteInputTsstControlMemory(
8305 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8306 IN UINT16 f_usTsstIndex,
8307 IN UINT16 f_usTsiMemIndex,
8308 IN UINT32 f_ulTsstInputLaw )
8309 {
8310 tOCT6100_WRITE_PARAMS WriteParams;
8311 UINT32 ulResult;
8312
8313 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8314
8315 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8316
8317 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
8318
8319 WriteParams.usWriteData = cOCT6100_TSST_CONTROL_MEM_INPUT_TSST;
8320 WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8321
8322 /* Set the PCM law.*/
8323 WriteParams.usWriteData |= f_ulTsstInputLaw << cOCT6100_TSST_CONTROL_MEM_PCM_LAW_OFFSET;
8324
8325 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8326 if ( ulResult != cOCT6100_ERR_OK )
8327 return ulResult;
8328
8329 return cOCT6100_ERR_OK;
8330 }
8331 #endif
8332
8333
8334
8335 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8336
8337 Function: Oct6100ApiWriteOutputTsstControlMemory
8338
8339 Description: This function configure a TSST control memory entry in internal memory.
8340
8341 -------------------------------------------------------------------------------
8342 | Argument | Description
8343 -------------------------------------------------------------------------------
8344 f_pApiInstance Pointer to API instance. This memory is used to keep
8345 the present state of the chip and all its resources.
8346
8347 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8348 #if !SKIP_Oct6100ApiWriteOutputTsstControlMemory
8349 UINT32 Oct6100ApiWriteOutputTsstControlMemory(
8350 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8351 IN UINT16 f_usTsstIndex,
8352 IN UINT32 f_ulAdpcmNibblePosition,
8353 IN UINT32 f_ulNumTssts,
8354 IN UINT16 f_usTsiMemIndex )
8355 {
8356 tOCT6100_WRITE_PARAMS WriteParams;
8357 UINT32 ulResult;
8358
8359 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8360
8361 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8362
8363 WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
8364
8365 WriteParams.usWriteData = cOCT6100_TSST_CONTROL_MEM_OUTPUT_TSST;
8366 WriteParams.usWriteData |= f_ulAdpcmNibblePosition << cOCT6100_TSST_CONTROL_MEM_NIBBLE_POS_OFFSET;
8367 WriteParams.usWriteData |= (f_ulNumTssts - 1) << cOCT6100_TSST_CONTROL_MEM_TSST_NUM_OFFSET;
8368 WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8369
8370 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8371 if ( ulResult != cOCT6100_ERR_OK )
8372 return ulResult;
8373
8374 return cOCT6100_ERR_OK;
8375 }
8376 #endif
8377
8378
8379 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8380
8381 Function: Oct6100ApiWriteEncoderMemory
8382
8383 Description: This function configure a Encoded memory entry in internal memory.
8384
8385 -------------------------------------------------------------------------------
8386 | Argument | Description
8387 -------------------------------------------------------------------------------
8388 f_pApiInstance Pointer to API instance. This memory is used to keep
8389 the present state of the chip and all its resources.
8390
8391 f_ulEncoderIndex Index of the encoder block within the ADPCM context memory.
8392 f_ulCompType Compression rate of the encoder.
8393 f_usTsiMemIndex TSI index within the TSI chariot memory used by the encoder.
8394 f_ulEnableSilenceSuppression Silence suppression enable flag.
8395 f_ulAdpcmNibblePosition ADPCM nibble position.
8396 f_usPhasingTsstIndex Phasing TSST index within the API's Phassing TSST list.
8397 f_ulPhasingType Type of the Phasing TSST.
8398 f_ulPhase Phase used with this encoder.
8399
8400 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8401 #if !SKIP_Oct6100ApiWriteEncoderMemory
8402 UINT32 Oct6100ApiWriteEncoderMemory(
8403 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8404 IN UINT32 f_ulEncoderIndex,
8405 IN UINT32 f_ulCompType,
8406 IN UINT16 f_usTsiMemIndex,
8407 IN UINT32 f_ulEnableSilenceSuppression,
8408 IN UINT32 f_ulAdpcmNibblePosition,
8409 IN UINT16 f_usPhasingTsstIndex,
8410 IN UINT32 f_ulPhasingType,
8411 IN UINT32 f_ulPhase )
8412 {
8413 tOCT6100_WRITE_PARAMS WriteParams;
8414 UINT32 ulResult;
8415
8416 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8417
8418 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8419
8420 /*==============================================================================*/
8421 /* Conversion Control Base */
8422 WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_ulEncoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
8423
8424 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ENCODER;
8425 WriteParams.usWriteData |= f_ulCompType << cOCT6100_CONVERSION_CONTROL_MEM_COMP_OFFSET;
8426 WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8427
8428 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8429 if ( ulResult != cOCT6100_ERR_OK )
8430 return ulResult;
8431
8432 /*==============================================================================*/
8433 /* Conversion Control Base + 2 */
8434 WriteParams.ulWriteAddress += 2;
8435
8436 /* Set the phasing TSST number.*/
8437 if ( f_usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
8438 WriteParams.usWriteData = (UINT16)( f_usPhasingTsstIndex << cOCT6100_CONVERSION_CONTROL_MEM_PHASE_OFFSET );
8439 else
8440 WriteParams.usWriteData = 0;
8441
8442 /* Set the phasing type and the phase value if required.*/
8443 switch( f_ulPhasingType )
8444 {
8445 case cOCT6100_NO_PHASING:
8446 WriteParams.usWriteData |= 0x1 << 10;
8447 break;
8448 case cOCT6100_SINGLE_PHASING:
8449 WriteParams.usWriteData |= f_ulPhase;
8450 break;
8451 case cOCT6100_DUAL_PHASING:
8452 WriteParams.usWriteData |= 0x1 << 11;
8453 WriteParams.usWriteData |= f_ulPhase;
8454 break;
8455 default:
8456 /* No problem. */
8457 break;
8458 }
8459
8460 /* Set the silence suppression flag.*/
8461 WriteParams.usWriteData |= f_ulEnableSilenceSuppression << cOCT6100_CONVERSION_CONTROL_MEM_SIL_SUP_OFFSET;
8462
8463 /* Set the nibble position.*/
8464 WriteParams.usWriteData |= f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET;
8465
8466 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8467 if ( ulResult != cOCT6100_ERR_OK )
8468 return ulResult;
8469
8470 /*==============================================================================*/
8471 /* Conversion Control Base + 4 */
8472 WriteParams.ulWriteAddress += 2;
8473
8474 /* Set the reset mode */
8475 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR;
8476
8477 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8478 if ( ulResult != cOCT6100_ERR_OK )
8479 return ulResult;
8480
8481 /*==============================================================================*/
8482 /* Conversion Control Base + 6 */
8483 WriteParams.ulWriteAddress += 2;
8484
8485 /* Set the reset mode */
8486 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY;
8487
8488 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8489 if ( ulResult != cOCT6100_ERR_OK )
8490 return ulResult;
8491
8492 /*==============================================================================*/
8493 return cOCT6100_ERR_OK;
8494 }
8495 #endif
8496
8497
8498 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8499
8500 Function: Oct6100ApiWriteDecoderMemory
8501
8502 Description: This function configure a Decoder memory entry in internal memory.
8503
8504 -------------------------------------------------------------------------------
8505 | Argument | Description
8506 -------------------------------------------------------------------------------
8507 f_pApiInstance Pointer to API instance. This memory is used to keep
8508 the present state of the chip and all its resources.
8509
8510 f_usDecoderIndex Index of the decoder block within the ADPCM context memory.
8511 f_ulCompType Decompression rate of the decoder.
8512 f_usTsiMemIndex TSI index within the TSI chariot memory.
8513 f_ulPcmLaw PCM law of the decoded samples.
8514 f_ulAdpcmNibblePosition ADPCM nibble position.
8515
8516 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8517 #if !SKIP_Oct6100ApiWriteDecoderMemory
8518 UINT32 Oct6100ApiWriteDecoderMemory(
8519 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8520 IN UINT16 f_usDecoderIndex,
8521 IN UINT32 f_ulCompType,
8522 IN UINT16 f_usTsiMemIndex,
8523 IN UINT32 f_ulPcmLaw,
8524 IN UINT32 f_ulAdpcmNibblePosition )
8525 {
8526 tOCT6100_WRITE_PARAMS WriteParams;
8527 UINT32 ulResult;
8528
8529 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8530
8531 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8532
8533
8534 /*==============================================================================*/
8535 /* Conversion Control Base */
8536 WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_usDecoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
8537
8538 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_DECODER;
8539 WriteParams.usWriteData |= f_ulCompType << cOCT6100_CONVERSION_CONTROL_MEM_COMP_OFFSET;
8540 WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
8541
8542 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8543 if ( ulResult != cOCT6100_ERR_OK )
8544 return ulResult;
8545
8546 /*==============================================================================*/
8547 /* Conversion Control Base + 2 */
8548 WriteParams.ulWriteAddress += 2;
8549
8550 /* Set the nibble position.*/
8551 WriteParams.usWriteData = (UINT16)( f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET );
8552
8553 /* Set the law.*/
8554 WriteParams.usWriteData |= f_ulPcmLaw << cOCT6100_CONVERSION_CONTROL_MEM_LAW_OFFSET;
8555
8556 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8557 if ( ulResult != cOCT6100_ERR_OK )
8558 return ulResult;
8559
8560 /*==============================================================================*/
8561 /* Conversion Control Base + 4 */
8562 WriteParams.ulWriteAddress += 2;
8563
8564 /* Set the reset mode */
8565 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR;
8566
8567 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8568 if ( ulResult != cOCT6100_ERR_OK )
8569 return ulResult;
8570
8571 /*==============================================================================*/
8572 /* Conversion Control Base + 6 */
8573 WriteParams.ulWriteAddress += 2;
8574
8575 /* Set the reset mode */
8576 WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY;
8577
8578 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8579 if ( ulResult != cOCT6100_ERR_OK )
8580 return ulResult;
8581
8582 return cOCT6100_ERR_OK;
8583 }
8584 #endif
8585
8586
8587
8588 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8589
8590 Function: Oct6100ApiClearConversionMemory
8591
8592 Description: This function clears a conversion memory entry in internal
8593 memory.
8594
8595 -------------------------------------------------------------------------------
8596 | Argument | Description
8597 -------------------------------------------------------------------------------
8598 f_pApiInstance Pointer to API instance. This memory is used to keep
8599 the present state of the chip and all its resources.
8600
8601 f_usConversionMemIndex Index of the block within the conversion memory.
8602
8603 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8604 #if !SKIP_Oct6100ApiClearConversionMemory
8605 UINT32 Oct6100ApiClearConversionMemory(
8606 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8607 IN UINT16 f_usConversionMemIndex )
8608 {
8609 tOCT6100_WRITE_PARAMS WriteParams;
8610 tOCT6100_READ_PARAMS ReadParams;
8611 UINT32 ulResult;
8612 UINT32 ulBaseAddress;
8613 UINT16 usReadData;
8614
8615 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8616
8617 WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8618 WriteParams.usWriteData = 0;
8619
8620 ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
8621
8622 ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
8623 ReadParams.pusReadData = &usReadData;
8624
8625 /*==============================================================================*/
8626 /* Clear the entry */
8627 ulBaseAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_usConversionMemIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
8628 /* The "activate" bit at offset +6 must be cleared first. */
8629 WriteParams.ulWriteAddress = ulBaseAddress + 6;
8630
8631 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8632 if ( ulResult != cOCT6100_ERR_OK )
8633 return ulResult;
8634
8635 /* Read at 0x200 to make sure there is no corruption on channel 0. */
8636 ReadParams.ulReadAddress = 0x200;
8637 mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
8638 if ( ulResult != cOCT6100_ERR_OK )
8639 return ulResult;
8640
8641 /* Then clear the rest of the structure. */
8642 WriteParams.ulWriteAddress = ulBaseAddress + 4;
8643
8644 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8645 if ( ulResult != cOCT6100_ERR_OK )
8646 return ulResult;
8647
8648 WriteParams.ulWriteAddress = ulBaseAddress + 2;
8649
8650 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8651 if ( ulResult != cOCT6100_ERR_OK )
8652 return ulResult;
8653
8654 WriteParams.ulWriteAddress = ulBaseAddress;
8655
8656 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8657 if ( ulResult != cOCT6100_ERR_OK )
8658 return ulResult;
8659
8660 /*==============================================================================*/
8661
8662 return cOCT6100_ERR_OK;
8663 }
8664 #endif
8665
8666
8667 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8668
8669 Function: Oct6100ApiWriteVqeMemory
8670
8671 Description: This function configure an echo memory entry in internal memory and
8672 external memory.
8673
8674 -------------------------------------------------------------------------------
8675 | Argument | Description
8676 -------------------------------------------------------------------------------
8677 f_pApiInstance Pointer to API instance. This memory is used to keep
8678 the present state of the chip and all its resources.
8679
8680 f_pVqeConfig Pointer to a VQE config structure.
8681 f_pChannelOpen Pointer to a channel configuration structure.
8682 f_usChanIndex Index of the echo channel in the API instance.
8683 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
8684 f_fClearPlayoutPointers Flag indicating if the playout pointer should be cleared.
8685 f_fModifyOnly Flag indicating if the configuration should be
8686 modified only.
8687
8688 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8689 #if !SKIP_Oct6100ApiWriteVqeMemory
8690 UINT32 Oct6100ApiWriteVqeMemory(
8691 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8692 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
8693 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
8694 IN UINT16 f_usChanIndex,
8695 IN UINT16 f_usEchoMemIndex,
8696 IN BOOL f_fClearPlayoutPointers,
8697 IN BOOL f_fModifyOnly )
8698 {
8699 UINT32 ulResult;
8700
8701 /* Write the NLP software configuration structure. */
8702 ulResult = Oct6100ApiWriteVqeNlpMemory(
8703 f_pApiInstance,
8704 f_pVqeConfig,
8705 f_pChannelOpen,
8706 f_usChanIndex,
8707 f_usEchoMemIndex,
8708 f_fClearPlayoutPointers,
8709 f_fModifyOnly );
8710 if ( ulResult != cOCT6100_ERR_OK )
8711 return ulResult;
8712
8713 /* Write the AF software configuration structure. */
8714 ulResult = Oct6100ApiWriteVqeAfMemory(
8715 f_pApiInstance,
8716 f_pVqeConfig,
8717 f_pChannelOpen,
8718 f_usChanIndex,
8719 f_usEchoMemIndex,
8720 f_fClearPlayoutPointers,
8721 f_fModifyOnly );
8722 if ( ulResult != cOCT6100_ERR_OK )
8723 return ulResult;
8724
8725 return cOCT6100_ERR_OK;
8726 }
8727 #endif
8728
8729 UINT32 oct6100_retrieve_nlp_conf_dword(tPOCT6100_INSTANCE_API f_pApiInst,
8730 tPOCT6100_API_CHANNEL f_pChanEntry,
8731 UINT32 f_ulAddress,
8732 UINT32 *f_pulConfigDword)
8733 {
8734 tOCT6100_READ_PARAMS _ReadParams;
8735 UINT16 _usReadData;
8736 UINT32 ulResult = cOCT6100_ERR_FATAL_8E;
8737 (*f_pulConfigDword) = cOCT6100_INVALID_VALUE;
8738
8739 _ReadParams.pProcessContext = f_pApiInst->pProcessContext;
8740 mOCT6100_ASSIGN_USER_READ_WRITE_OBJ(f_pApiInst, _ReadParams);
8741 _ReadParams.ulUserChipId = f_pApiInst->pSharedInfo->ChipConfig.ulUserChipId;
8742 _ReadParams.pusReadData = &_usReadData;
8743
8744 /* Read the first 16 bits.*/
8745 _ReadParams.ulReadAddress = f_ulAddress;
8746 mOCT6100_DRIVER_READ_API(_ReadParams, ulResult);
8747 if (ulResult == cOCT6100_ERR_OK) {
8748 /* Save data.*/
8749 (*f_pulConfigDword) = _usReadData << 16;
8750
8751 /* Read the last 16 bits .*/
8752 _ReadParams.ulReadAddress += 2;
8753 mOCT6100_DRIVER_READ_API(_ReadParams, ulResult);
8754 if (ulResult == cOCT6100_ERR_OK) {
8755 /* Save data.*/
8756 (*f_pulConfigDword) |= _usReadData;
8757 ulResult = cOCT6100_ERR_OK;
8758 }
8759 }
8760 return ulResult;
8761 }
8762
8763 UINT32 oct6100_save_nlp_conf_dword(tPOCT6100_INSTANCE_API f_pApiInst,
8764 tPOCT6100_API_CHANNEL f_pChanEntry,
8765 UINT32 f_ulAddress,
8766 UINT32 f_ulConfigDword)
8767 {
8768 UINT32 ulResult;
8769
8770 /* Write the config DWORD. */
8771 tOCT6100_WRITE_PARAMS _WriteParams;
8772
8773 _WriteParams.pProcessContext = f_pApiInst->pProcessContext;
8774 mOCT6100_ASSIGN_USER_READ_WRITE_OBJ(f_pApiInst, _WriteParams)
8775 _WriteParams.ulUserChipId = f_pApiInst->pSharedInfo->ChipConfig.ulUserChipId;
8776
8777 /* Write the first 16 bits. */
8778 _WriteParams.ulWriteAddress = f_ulAddress;
8779 _WriteParams.usWriteData = (UINT16)((f_ulConfigDword >> 16) & 0xFFFF);
8780 mOCT6100_DRIVER_WRITE_API(_WriteParams, ulResult);
8781
8782 if (ulResult == cOCT6100_ERR_OK) {
8783 /* Write the last word. */
8784 _WriteParams.ulWriteAddress = f_ulAddress + 2;
8785 _WriteParams.usWriteData = (UINT16)(f_ulConfigDword & 0xFFFF);
8786 mOCT6100_DRIVER_WRITE_API(_WriteParams, ulResult);
8787 }
8788 return ulResult;
8789 }
8790
8791
8792
8793 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8794
8795 Function: Oct6100ApiWriteVqeNlpMemory
8796
8797 Description: This function configures the NLP related VQE features of an
8798 echo channel.
8799
8800 -------------------------------------------------------------------------------
8801 | Argument | Description
8802 -------------------------------------------------------------------------------
8803 f_pApiInstance Pointer to API instance. This memory is used to keep
8804 the present state of the chip and all its resources.
8805
8806 f_pVqeConfig Pointer to a VQE config structure.
8807 f_pChannelOpen Pointer to a channel configuration structure.
8808 f_usChanIndex Index of the echo channel in the API instance.
8809 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
8810 f_fClearPlayoutPointers Flag indicating if the playout pointer should be cleared.
8811 f_fModifyOnly Flag indicating if the configuration should be
8812 modified only.
8813
8814 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8815 #if !SKIP_Oct6100ApiWriteVqeNlpMemory
8816 UINT32 Oct6100ApiWriteVqeNlpMemory(
8817 IN tPOCT6100_INSTANCE_API f_pApiInstance,
8818 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
8819 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
8820 IN UINT16 f_usChanIndex,
8821 IN UINT16 f_usEchoMemIndex,
8822 IN BOOL f_fClearPlayoutPointers,
8823 IN BOOL f_fModifyOnly )
8824 {
8825 tPOCT6100_API_CHANNEL pChanEntry;
8826 tPOCT6100_SHARED_INFO pSharedInfo;
8827 tOCT6100_BUFFER_PLAYOUT_STOP BufferPlayoutStop;
8828 UINT32 ulResult;
8829 UINT32 ulTempData;
8830 UINT32 ulNlpConfigBaseAddress;
8831 UINT32 ulFeatureBytesOffset;
8832 UINT32 ulFeatureBitOffset;
8833 UINT32 ulFeatureFieldLength;
8834 UINT32 ulMask;
8835 UINT16 usTempData;
8836 BOOL fEchoOperationModeChanged;
8837
8838 pSharedInfo = f_pApiInstance->pSharedInfo;
8839
8840 /* Obtain a pointer to the new buffer's list entry. */
8841 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
8842
8843 /*==============================================================================*/
8844 /* Configure the CPU NLP configuration of the channel feature by feature.*/
8845
8846 ulNlpConfigBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
8847
8848 /* Set initial value to zero.*/
8849 ulTempData = 0;
8850
8851 /* Configure Adaptive Noise Reduction.*/
8852 if (pSharedInfo->ImageInfo.fAdaptiveNoiseReduction == TRUE) {
8853 /* Check if the configuration has been changed. */
8854 if ( ( f_fModifyOnly == FALSE )
8855 || ( ( f_fModifyOnly == TRUE )
8856 && ( ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction )
8857 || ( f_pVqeConfig->fSoutNoiseBleaching != pChanEntry->VqeConfig.fSoutNoiseBleaching )
8858 ) ) )
8859 {
8860 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.usDwordOffset * 4;
8861 ulFeatureBitOffset = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byBitOffset;
8862 ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byFieldSize;
8863
8864 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
8865 pChanEntry,
8866 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8867 &ulTempData);
8868 if ( ulResult != cOCT6100_ERR_OK )
8869 return ulResult;
8870
8871 /* Clear previous value set in the feature field.*/
8872 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8873
8874 ulTempData &= (~ulMask);
8875
8876 /* Set adaptive noise reduction on the SOUT port.*/
8877 ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutAdaptiveNoiseReduction ) << ulFeatureBitOffset );
8878
8879 /* If SOUT noise bleaching is requested, ANR must be activated. */
8880 ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutNoiseBleaching ) << ulFeatureBitOffset );
8881
8882 /* First read the DWORD where the field is located. */
8883 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
8884 pChanEntry,
8885 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8886 ulTempData);
8887 if ( ulResult != cOCT6100_ERR_OK )
8888 return ulResult;
8889 }
8890 }
8891
8892 /* Configure Rout Noise Reduction. */
8893 if (pSharedInfo->ImageInfo.fRoutNoiseReduction == TRUE) {
8894 /* Check if the configuration has been changed. */
8895 if ( ( f_fModifyOnly == FALSE )
8896 || ( ( f_fModifyOnly == TRUE )
8897 && ( f_pVqeConfig->fRoutNoiseReduction != pChanEntry->VqeConfig.fRoutNoiseReduction ) ) )
8898 {
8899 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAnrOfst.usDwordOffset * 4;
8900 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinAnrOfst.byBitOffset;
8901 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAnrOfst.byFieldSize;
8902
8903 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
8904 pChanEntry,
8905 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8906 &ulTempData);
8907 if ( ulResult != cOCT6100_ERR_OK )
8908 return ulResult;
8909
8910 /* Clear previous value set in the feature field.*/
8911 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8912
8913 ulTempData &= (~ulMask);
8914
8915 /* Set noise reduction on the Rout port. */
8916 ulTempData |= ( ( (UINT32)f_pVqeConfig->fRoutNoiseReduction ) << ulFeatureBitOffset );
8917
8918 /* Write the new DWORD where the field is located. */
8919 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
8920 pChanEntry,
8921 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8922 ulTempData);
8923 if ( ulResult != cOCT6100_ERR_OK )
8924 return ulResult;
8925 }
8926 }
8927
8928 if (pSharedInfo->ImageInfo.fRoutNoiseReductionLevel == TRUE)
8929 {
8930 /* Check if the configuration has been changed. */
8931 if ( ( f_fModifyOnly == FALSE )
8932 || ( ( f_fModifyOnly == TRUE )
8933 && ( (f_pVqeConfig->lRoutNoiseReductionLevelGainDb != pChanEntry->VqeConfig.chRoutNoiseReductionLevelGainDb )
8934 ||( f_pVqeConfig->fRoutNoiseReduction != pChanEntry->VqeConfig.fRoutNoiseReduction ) ) ) )
8935 {
8936 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAnrValOfst.usDwordOffset * 4;
8937 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinAnrValOfst.byBitOffset;
8938 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAnrValOfst.byFieldSize;
8939
8940 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
8941 pChanEntry,
8942 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8943 &ulTempData);
8944 if ( ulResult != cOCT6100_ERR_OK )
8945 return ulResult;
8946
8947 /* Clear previous value set in the feature field.*/
8948 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8949
8950 ulTempData &= (~ulMask);
8951
8952 if (f_pVqeConfig->fRoutNoiseReduction == TRUE)
8953 {
8954 switch( f_pVqeConfig->lRoutNoiseReductionLevelGainDb)
8955 {
8956 case 0: ulTempData |= ( 0 << ulFeatureBitOffset );
8957 break;
8958 case -6: ulTempData |= ( 1 << ulFeatureBitOffset );
8959 break;
8960 case -12: ulTempData |= ( 2 << ulFeatureBitOffset );
8961 break;
8962 case -18: ulTempData |= ( 3 << ulFeatureBitOffset );
8963 break;
8964 default: ulTempData |= ( 0 << ulFeatureBitOffset );
8965 break;
8966 }
8967 }
8968 else
8969 ulTempData |= ( 0 << ulFeatureBitOffset );
8970
8971 /* Write the new DWORD where the field is located. */
8972 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
8973 pChanEntry,
8974 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8975 ulTempData);
8976 if ( ulResult != cOCT6100_ERR_OK )
8977 return ulResult;
8978 }
8979
8980 }
8981
8982 /* Configure Sout ANR SNR enhancement. */
8983 if ( pSharedInfo->ImageInfo.fAnrSnrEnhancement == TRUE )
8984 {
8985 /* Check if the configuration has been changed. */
8986 if ( ( f_fModifyOnly == FALSE )
8987 || ( ( f_fModifyOnly == TRUE )
8988 && ( f_pVqeConfig->lAnrSnrEnhancementDb != pChanEntry->VqeConfig.chAnrSnrEnhancementDb ) ) )
8989 {
8990 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.usDwordOffset * 4;
8991 ulFeatureBitOffset = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byBitOffset;
8992 ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byFieldSize;
8993
8994 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
8995 pChanEntry,
8996 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
8997 &ulTempData);
8998 if ( ulResult != cOCT6100_ERR_OK )
8999 return ulResult;
9000
9001 /* Clear previous value set in the feature field.*/
9002 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9003
9004 ulTempData &= (~ulMask);
9005
9006 /* Set ANR SNR enhancement on the Sout port. */
9007 switch( f_pVqeConfig->lAnrSnrEnhancementDb )
9008 {
9009 case -9: ulTempData |= ( 7 << ulFeatureBitOffset );
9010 break;
9011 case -12: ulTempData |= ( 6 << ulFeatureBitOffset );
9012 break;
9013 case -15: ulTempData |= ( 5 << ulFeatureBitOffset );
9014 break;
9015 case -21: ulTempData |= ( 3 << ulFeatureBitOffset );
9016 break;
9017 case -24: ulTempData |= ( 2 << ulFeatureBitOffset );
9018 break;
9019 case -27: ulTempData |= ( 1 << ulFeatureBitOffset );
9020 break;
9021 case -30: ulTempData |= ( 0 << ulFeatureBitOffset );
9022 break;
9023 default: ulTempData |= ( 4 << ulFeatureBitOffset );
9024 /* -18 */
9025 break;
9026 }
9027
9028 /* Write the new DWORD where the field is located. */
9029 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9030 pChanEntry,
9031 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9032 ulTempData);
9033 if ( ulResult != cOCT6100_ERR_OK )
9034 return ulResult;
9035 }
9036 }
9037
9038 /* Configure Sout ANR voice-noise segregation. */
9039 if ( pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation == TRUE )
9040 {
9041 /* Check if the configuration has been changed. */
9042 if ( ( f_fModifyOnly == FALSE )
9043 || ( ( f_fModifyOnly == TRUE )
9044 && ( f_pVqeConfig->ulAnrVoiceNoiseSegregation != pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation ) ) )
9045 {
9046 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.usDwordOffset * 4;
9047 ulFeatureBitOffset = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byBitOffset;
9048 ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byFieldSize;
9049
9050 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9051 pChanEntry,
9052 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9053 &ulTempData);
9054 if ( ulResult != cOCT6100_ERR_OK )
9055 return ulResult;
9056
9057 /* Clear previous value set in the feature field.*/
9058 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9059
9060 ulTempData &= (~ulMask);
9061
9062 /* Set ANR voice-noise segregation on the Sout port. */
9063 ulTempData |= ( ( (UINT32)f_pVqeConfig->ulAnrVoiceNoiseSegregation ) << ulFeatureBitOffset );
9064
9065 /* Write the new DWORD where the field is located. */
9066 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9067 pChanEntry,
9068 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9069 ulTempData);
9070 if ( ulResult != cOCT6100_ERR_OK )
9071 return ulResult;
9072 }
9073 }
9074
9075 /* Configure the tone disabler VQE activation delay. */
9076 if ( pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay == TRUE )
9077 {
9078 /* Check if the configuration has been changed. */
9079 if ( ( f_fModifyOnly == FALSE )
9080 || ( ( f_fModifyOnly == TRUE )
9081 && ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay )
9082 || ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) ) ) )
9083 {
9084 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.usDwordOffset * 4;
9085 ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byBitOffset;
9086 ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byFieldSize;
9087
9088 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9089 pChanEntry,
9090 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9091 &ulTempData);
9092 if ( ulResult != cOCT6100_ERR_OK )
9093 return ulResult;
9094
9095 /* Clear previous value set in the feature field.*/
9096 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9097
9098 ulTempData &= (~ulMask);
9099
9100 /* Set the tone disabler VQE activation delay. The VQE activation delay */
9101 /* is only set if the tone disabler is activated. */
9102 if ( f_pChannelOpen->fEnableToneDisabler == TRUE )
9103 ulTempData |= ( ( (UINT32)( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay - 300 ) / 512 ) ) << ulFeatureBitOffset );
9104 else
9105 ulTempData |= ( 0 ) << ulFeatureBitOffset;
9106
9107 /* Write the new DWORD where the field is located. */
9108 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9109 pChanEntry,
9110 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9111 ulTempData);
9112 if ( ulResult != cOCT6100_ERR_OK )
9113 return ulResult;
9114 }
9115 }
9116
9117 /* Configure Conferencing Noise Reduction.*/
9118 if ( pSharedInfo->ImageInfo.fConferencingNoiseReduction == TRUE )
9119 {
9120 /* Check if the configuration has been changed. */
9121 if ( ( f_fModifyOnly == FALSE )
9122 || ( ( f_fModifyOnly == TRUE )
9123 && ( ( f_pVqeConfig->fSoutConferencingNoiseReduction != pChanEntry->VqeConfig.fSoutConferencingNoiseReduction )
9124 || ( f_pVqeConfig->fSoutNoiseBleaching != pChanEntry->VqeConfig.fSoutNoiseBleaching ) ) ) )
9125 {
9126 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.usDwordOffset * 4;
9127 ulFeatureBitOffset = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byBitOffset;
9128 ulFeatureFieldLength = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byFieldSize;
9129
9130 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9131 pChanEntry,
9132 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9133 &ulTempData);
9134 if ( ulResult != cOCT6100_ERR_OK )
9135 return ulResult;
9136
9137 /* Clear previous value set in the feature field.*/
9138 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9139
9140 ulTempData &= (~ulMask);
9141
9142 /* Set conferencing noise reduction on the SOUT port. */
9143 ulTempData |= (f_pVqeConfig->fSoutConferencingNoiseReduction << ulFeatureBitOffset );
9144
9145 /* If SOUT noise bleaching is requested, CNR must be activated. */
9146 ulTempData |= (f_pVqeConfig->fSoutNoiseBleaching << ulFeatureBitOffset );
9147
9148 /* Save the DWORD where the field is located. */
9149 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9150 pChanEntry,
9151 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9152 ulTempData);
9153 if ( ulResult != cOCT6100_ERR_OK )
9154 return ulResult;
9155 }
9156 }
9157
9158 /* Set the DC removal on RIN ports.*/
9159 if ( pSharedInfo->ImageInfo.fRinDcOffsetRemoval == TRUE )
9160 {
9161 /* Check if the configuration has been changed. */
9162 if ( ( f_fModifyOnly == FALSE )
9163 || ( ( f_fModifyOnly == TRUE )
9164 && ( f_pVqeConfig->fRinDcOffsetRemoval != pChanEntry->VqeConfig.fRinDcOffsetRemoval ) ) )
9165 {
9166 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.usDwordOffset * 4;
9167 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byBitOffset;
9168 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byFieldSize;
9169
9170 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9171 pChanEntry,
9172 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9173 &ulTempData);
9174 if ( ulResult != cOCT6100_ERR_OK )
9175 return ulResult;
9176
9177 /* Clear previous value set in the feature field.*/
9178 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9179
9180 ulTempData &= (~ulMask);
9181
9182 /* Set adaptive noise reduction on the SOUT port.*/
9183 ulTempData |= ( ( (UINT32)f_pVqeConfig->fRinDcOffsetRemoval ) << ulFeatureBitOffset );
9184
9185 /* The write the new DWORD where the field is located.*/
9186 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9187 pChanEntry,
9188 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9189 ulTempData);
9190 if ( ulResult != cOCT6100_ERR_OK )
9191 return ulResult;
9192 }
9193 }
9194
9195 /* Set the DC removal on SIN ports.*/
9196 if ( pSharedInfo->ImageInfo.fSinDcOffsetRemoval == TRUE )
9197 {
9198 /* Check if the configuration has been changed. */
9199 if ( ( f_fModifyOnly == FALSE )
9200 || ( ( f_fModifyOnly == TRUE )
9201 && ( f_pVqeConfig->fSinDcOffsetRemoval != pChanEntry->VqeConfig.fSinDcOffsetRemoval ) ) )
9202 {
9203 ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.usDwordOffset * 4;
9204 ulFeatureBitOffset = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byBitOffset;
9205 ulFeatureFieldLength = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byFieldSize;
9206
9207 /* First read the DWORD where the field is located.*/
9208 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9209 pChanEntry,
9210 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9211 &ulTempData);
9212 if ( ulResult != cOCT6100_ERR_OK )
9213 return ulResult;
9214
9215 /* Clear previous value set in the feature field.*/
9216 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9217
9218 ulTempData &= (~ulMask);
9219
9220 /* Set adaptive noise reduction on the SOUT port.*/
9221 ulTempData |= ( ( (UINT32)f_pVqeConfig->fSinDcOffsetRemoval ) << ulFeatureBitOffset );
9222
9223 /* Save the DWORD where the field is located.*/
9224 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9225 pChanEntry,
9226 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9227 ulTempData);
9228 if ( ulResult != cOCT6100_ERR_OK )
9229 return ulResult;
9230 }
9231 }
9232
9233 /* Set the level control. */
9234 if ( ( pChanEntry->byEchoOperationMode != f_pChannelOpen->ulEchoOperationMode )
9235 && ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NORMAL ) )
9236 fEchoOperationModeChanged = TRUE;
9237 else
9238 fEchoOperationModeChanged = FALSE;
9239
9240 /* If opening the channel, all level control configuration must be written. */
9241 if ( f_fModifyOnly == FALSE )
9242 fEchoOperationModeChanged = TRUE;
9243 ulResult = Oct6100ApiSetChannelLevelControl( f_pApiInstance,
9244 f_pVqeConfig,
9245 f_usChanIndex,
9246 f_usEchoMemIndex,
9247 fEchoOperationModeChanged );
9248 if ( ulResult != cOCT6100_ERR_OK )
9249 return ulResult;
9250
9251 /* Set the background noise freeze.*/
9252 if ( pSharedInfo->ImageInfo.fComfortNoise == TRUE )
9253 {
9254 /* Check if the configuration has been changed. */
9255 if ( ( f_fModifyOnly == FALSE )
9256 || ( ( f_fModifyOnly == TRUE )
9257 && ( f_pVqeConfig->ulComfortNoiseMode != pChanEntry->VqeConfig.byComfortNoiseMode ) ) )
9258 {
9259 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.usDwordOffset * 4;
9260 ulFeatureBitOffset = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byBitOffset;
9261 ulFeatureFieldLength = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byFieldSize;
9262
9263 /* First read the DWORD where the field is located.*/
9264 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9265 pChanEntry,
9266 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9267 &ulTempData);
9268 if ( ulResult != cOCT6100_ERR_OK )
9269 return ulResult;
9270
9271 /* Clear previous value set in the feature field.*/
9272 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9273
9274 ulTempData &= (~ulMask);
9275 ulTempData |= ( f_pVqeConfig->ulComfortNoiseMode << ulFeatureBitOffset );
9276
9277 /* Save the new DWORD where the field is located. */
9278 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9279 pChanEntry,
9280 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9281 ulTempData);
9282 if ( ulResult != cOCT6100_ERR_OK )
9283 return ulResult;
9284 }
9285 }
9286
9287 /* Set the state of the NLP */
9288 if ( pSharedInfo->ImageInfo.fNlpControl == TRUE )
9289 {
9290 /* Check if the configuration has been changed. */
9291 if ( ( f_fModifyOnly == FALSE )
9292 || ( ( f_fModifyOnly == TRUE )
9293 && ( f_pVqeConfig->fEnableNlp != pChanEntry->VqeConfig.fEnableNlp ) ) )
9294 {
9295 ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpControlFieldOfst.usDwordOffset * 4;
9296 ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpControlFieldOfst.byBitOffset;
9297 ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpControlFieldOfst.byFieldSize;
9298
9299 /* First read the DWORD where the field is located.*/
9300 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9301 pChanEntry,
9302 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9303 &ulTempData);
9304 if ( ulResult != cOCT6100_ERR_OK )
9305 return ulResult;
9306
9307 /* Clear previous value set in the feature field.*/
9308 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9309
9310 ulTempData &= (~ulMask);
9311
9312 if ( f_pVqeConfig->fEnableNlp == FALSE )
9313 ulTempData |= 0x1 << ulFeatureBitOffset;
9314
9315 /* Save the new DWORD where the field is located.*/
9316 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9317 pChanEntry,
9318 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9319 ulTempData);
9320 if ( ulResult != cOCT6100_ERR_OK )
9321 return ulResult;
9322 }
9323 }
9324
9325 /* Set the tail configuration. */
9326 ulResult = Oct6100ApiSetChannelTailConfiguration(
9327 f_pApiInstance,
9328 f_pVqeConfig,
9329 f_usChanIndex,
9330 f_usEchoMemIndex,
9331 f_fModifyOnly );
9332 if ( ulResult != cOCT6100_ERR_OK )
9333 return ulResult;
9334
9335 /* Set the Default ERL. */
9336 if ( ( pSharedInfo->ImageInfo.fDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == FALSE ) )
9337 {
9338 /* Check if the configuration has been changed. */
9339 if ( ( f_fModifyOnly == FALSE )
9340 || ( ( f_fModifyOnly == TRUE )
9341 && ( ( f_pVqeConfig->lDefaultErlDb != pChanEntry->VqeConfig.chDefaultErlDb )
9342 || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode )
9343 || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
9344 {
9345 ulFeatureBytesOffset = pSharedInfo->MemoryMap.DefaultErlFieldOfst.usDwordOffset * 4;
9346 ulFeatureBitOffset = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byBitOffset;
9347 ulFeatureFieldLength = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byFieldSize;
9348
9349 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9350 pChanEntry,
9351 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9352 &ulTempData);
9353 if ( ulResult != cOCT6100_ERR_OK )
9354 return ulResult;
9355
9356 /* Clear previous value set in the feature field.*/
9357 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9358
9359 ulTempData &= (~ulMask);
9360
9361 /* Convert the DB value to octasic's float format. (In energy) */
9362 if ( ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
9363 && ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9364 {
9365 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb );
9366 }
9367 else
9368 {
9369 /* Clear the defautl ERL when using the no echo cancellation operation mode. */
9370 usTempData = 0x0;
9371 }
9372
9373 if ( ulFeatureFieldLength < 16 )
9374 usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
9375
9376 ulTempData |= ( usTempData << ulFeatureBitOffset );
9377
9378 /* Save the new DWORD where the field is located.*/
9379 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9380 pChanEntry,
9381 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9382 ulTempData);
9383 if ( ulResult != cOCT6100_ERR_OK )
9384 return ulResult;
9385 }
9386 }
9387
9388 /* Set the Acoustic echo control.*/
9389 if ( pSharedInfo->ImageInfo.fAcousticEcho == TRUE )
9390 {
9391 /* Check if the configuration has been changed. */
9392 if ( ( f_fModifyOnly == FALSE )
9393 || ( ( f_fModifyOnly == TRUE )
9394 && ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) )
9395 {
9396 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecFieldOfst.usDwordOffset * 4;
9397 ulFeatureBitOffset = pSharedInfo->MemoryMap.AecFieldOfst.byBitOffset;
9398 ulFeatureFieldLength = pSharedInfo->MemoryMap.AecFieldOfst.byFieldSize;
9399
9400 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9401 pChanEntry,
9402 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9403 &ulTempData);
9404 if ( ulResult != cOCT6100_ERR_OK )
9405 return ulResult;
9406
9407 /* Clear previous value set in the feature field. */
9408 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9409
9410 ulTempData &= (~ulMask);
9411 ulTempData |= ( ( (UINT32)f_pVqeConfig->fAcousticEcho ) << ulFeatureBitOffset );
9412
9413 /* Then save the new DWORD where the field is located. */
9414 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9415 pChanEntry,
9416 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9417 ulTempData);
9418 if ( ulResult != cOCT6100_ERR_OK )
9419 return ulResult;
9420 }
9421 }
9422
9423 /* Set the Acoustic Echo Default ERL. */
9424 if ( ( pSharedInfo->ImageInfo.fAecDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == TRUE ) )
9425 {
9426 /* Check if the configuration has been changed. */
9427 if ( ( f_fModifyOnly == FALSE )
9428 || ( ( f_fModifyOnly == TRUE )
9429 && ( ( f_pVqeConfig->lAecDefaultErlDb != pChanEntry->VqeConfig.chAecDefaultErlDb )
9430 || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
9431 {
9432 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.usDwordOffset * 4;
9433 ulFeatureBitOffset = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byBitOffset;
9434 ulFeatureFieldLength = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byFieldSize;
9435
9436 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9437 pChanEntry,
9438 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9439 &ulTempData);
9440 if ( ulResult != cOCT6100_ERR_OK )
9441 return ulResult;
9442
9443 /* Clear previous value set in the feature field. */
9444 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9445
9446 ulTempData &= (~ulMask);
9447
9448 if ( ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
9449 && ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9450 {
9451 /* Convert the DB value to octasic's float format. (In energy) */
9452 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lAecDefaultErlDb );
9453 }
9454 else
9455 {
9456 /* Clear the AEC defautl ERL when using the no echo cancellation operation mode. */
9457 usTempData = 0x0;
9458 }
9459
9460 if ( ulFeatureFieldLength < 16 )
9461 usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
9462
9463 ulTempData |= ( usTempData << ulFeatureBitOffset );
9464
9465 /* Then save the DWORD where the field is located. */
9466 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9467 pChanEntry,
9468 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9469 ulTempData);
9470 if ( ulResult != cOCT6100_ERR_OK )
9471 return ulResult;
9472 }
9473 }
9474
9475 /* Set the DTMF tone removal bit.*/
9476 if ( pSharedInfo->ImageInfo.fToneRemoval == TRUE )
9477 {
9478 /* Check if the configuration has been changed. */
9479 if ( ( f_fModifyOnly == FALSE )
9480 || ( ( f_fModifyOnly == TRUE )
9481 && ( f_pVqeConfig->fDtmfToneRemoval != pChanEntry->VqeConfig.fDtmfToneRemoval ) ) )
9482 {
9483 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.usDwordOffset * 4;
9484 ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byBitOffset;
9485 ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byFieldSize;
9486
9487 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9488 pChanEntry,
9489 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9490 &ulTempData);
9491 if ( ulResult != cOCT6100_ERR_OK )
9492 return ulResult;
9493
9494 /* Clear previous value set in the feature field.*/
9495 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9496
9497 ulTempData &= (~ulMask);
9498 ulTempData |= ( ( (UINT32)f_pVqeConfig->fDtmfToneRemoval ) << ulFeatureBitOffset );
9499
9500 /* First read the DWORD where the field is located.*/
9501 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9502 pChanEntry,
9503 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9504 ulTempData);
9505 if ( ulResult != cOCT6100_ERR_OK )
9506 return ulResult;
9507 }
9508 }
9509
9510
9511
9512 /* Set the non-linear behavior A.*/
9513 if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorA == TRUE )
9514 {
9515 /* Check if the configuration has been changed. */
9516 if ( ( f_fModifyOnly == FALSE )
9517 || ( ( f_fModifyOnly == TRUE )
9518 && ( ( f_pVqeConfig->ulNonLinearityBehaviorA != pChanEntry->VqeConfig.byNonLinearityBehaviorA )
9519 || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
9520 {
9521 UINT16 ausLookupTable[ 14 ] = { 0x3663, 0x3906, 0x399C, 0x3A47, 0x3B06, 0x3B99, 0x3C47, 0x3D02, 0x3D99, 0x3E47, 0x3F00, 0x3F99, 0x4042, 0x4100 };
9522
9523 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PcmLeakFieldOfst.usDwordOffset * 4;
9524 ulFeatureBitOffset = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byBitOffset;
9525 ulFeatureFieldLength = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byFieldSize;
9526
9527 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9528 pChanEntry,
9529 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9530 &ulTempData);
9531 if ( ulResult != cOCT6100_ERR_OK )
9532 return ulResult;
9533
9534 /* Clear previous value set in the feature field.*/
9535 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9536
9537 ulTempData &= (~ulMask);
9538
9539 /*If we support ANR level the TLV is shared over 2 bits*/
9540 if (ulFeatureBitOffset == 18)
9541 {
9542 ulFeatureBitOffset -= 2;
9543 ausLookupTable[ f_pVqeConfig->ulNonLinearityBehaviorA ] &= 0xFFFC;
9544 }
9545
9546 if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
9547 || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9548 ulTempData |= ( 0x0 << ulFeatureBitOffset );
9549 else
9550 ulTempData |= ( ausLookupTable[ f_pVqeConfig->ulNonLinearityBehaviorA ] << ulFeatureBitOffset );
9551
9552 /* Then save the DWORD where the field is located.*/
9553 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9554 pChanEntry,
9555 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9556 ulTempData);
9557 if ( ulResult != cOCT6100_ERR_OK )
9558 return ulResult;
9559 }
9560 }
9561
9562 /* Synch all the buffer playout field.*/
9563 if ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE && f_fClearPlayoutPointers == TRUE )
9564 {
9565 Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
9566
9567 BufferPlayoutStop.ulChannelHndl = cOCT6100_INVALID_HANDLE;
9568 BufferPlayoutStop.fStopCleanly = TRUE;
9569
9570 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
9571 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
9572 f_pApiInstance,
9573 &BufferPlayoutStop,
9574 f_usChanIndex,
9575 f_usEchoMemIndex
9576
9577 );
9578 if ( ulResult != cOCT6100_ERR_OK )
9579 return ulResult;
9580
9581 BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
9582 ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
9583 f_pApiInstance,
9584 &BufferPlayoutStop,
9585 f_usChanIndex,
9586 f_usEchoMemIndex
9587
9588 );
9589 if ( ulResult != cOCT6100_ERR_OK )
9590 return ulResult;
9591 }
9592
9593 /*==============================================================================*/
9594 /* Write the 2100 Hz Echo Disabling mode */
9595
9596 /* Check if the configuration has been changed. */
9597 if ( ( f_fModifyOnly == FALSE )
9598 || ( ( f_fModifyOnly == TRUE )
9599 && ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) ) )
9600 {
9601 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerControlOfst.usDwordOffset * 4;
9602 ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byBitOffset;
9603 ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byFieldSize;
9604
9605 /* First read the DWORD where the field is located.*/
9606 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9607 pChanEntry,
9608 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9609 &ulTempData);
9610 if ( ulResult != cOCT6100_ERR_OK )
9611 return ulResult;
9612
9613 /* Clear previous value set in the feature field.*/
9614 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9615
9616 ulTempData &= (~ulMask);
9617
9618 /* This is a disable bit, so it must be set only if the enable flag is set to false. */
9619 if ( f_pChannelOpen->fEnableToneDisabler == FALSE )
9620 ulTempData |= 0x1 << ulFeatureBitOffset;
9621
9622 /* Save the DWORD where the field is located. */
9623 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9624 pChanEntry,
9625 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9626 ulTempData);
9627 if ( ulResult != cOCT6100_ERR_OK )
9628 return ulResult;
9629 }
9630 /*==============================================================================*/
9631
9632
9633 /*==============================================================================*/
9634 /* Write the Nlp Trivial enable flag. */
9635
9636 /* Check if the configuration has been changed. */
9637 if ( ( f_fModifyOnly == FALSE )
9638 || ( ( f_fModifyOnly == TRUE )
9639 && (
9640
9641 ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
9642 {
9643 ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.usDwordOffset * 4;
9644 ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byBitOffset;
9645 ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byFieldSize;
9646
9647 /* First read the DWORD where the field is located.*/
9648 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9649 pChanEntry,
9650 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9651 &ulTempData);
9652 if ( ulResult != cOCT6100_ERR_OK )
9653 return ulResult;
9654
9655 /* Clear previous value set in the feature field.*/
9656 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9657
9658 ulTempData &= (~ulMask);
9659 if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
9660 || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
9661 {
9662 ulTempData |= TRUE << ulFeatureBitOffset;
9663 }
9664
9665
9666 /* Then write the DWORD where the field is located. */
9667 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9668 pChanEntry,
9669 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9670 ulTempData);
9671 if ( ulResult != cOCT6100_ERR_OK )
9672 return ulResult;
9673 }
9674 /*==============================================================================*/
9675
9676
9677 /*==============================================================================*/
9678 /* Set the double talk behavior mode. */
9679 if ( pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst == TRUE )
9680 {
9681 /* Check if the configuration has been changed. */
9682 if ( ( f_fModifyOnly == FALSE )
9683 || ( ( f_fModifyOnly == TRUE )
9684 && ( f_pVqeConfig->ulDoubleTalkBehavior != pChanEntry->VqeConfig.byDoubleTalkBehavior ) ) )
9685 {
9686 /* The field is located in the CPURO structure. */
9687 ulFeatureBytesOffset = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.usDwordOffset * 4;
9688 ulFeatureBitOffset = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.byBitOffset;
9689 ulFeatureFieldLength = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.byFieldSize;
9690
9691 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9692 pChanEntry,
9693 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9694 &ulTempData);
9695 if ( ulResult != cOCT6100_ERR_OK )
9696 return ulResult;
9697
9698 /* Clear previous value set in the feature field.*/
9699 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9700
9701 ulTempData &= (~ulMask);
9702 ulTempData |= (f_pVqeConfig->ulDoubleTalkBehavior << ulFeatureBitOffset );
9703
9704 /* Then save the DWORD where the field is located.*/
9705 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9706 pChanEntry,
9707 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9708 ulTempData);
9709 if ( ulResult != cOCT6100_ERR_OK )
9710 return ulResult;
9711 }
9712 }
9713 /*==============================================================================*/
9714
9715
9716 /*==============================================================================*/
9717 /* Set the music protection enable. */
9718 if ( ( pSharedInfo->ImageInfo.fMusicProtection == TRUE )
9719 && ( pSharedInfo->ImageInfo.fMusicProtectionConfiguration == TRUE ) )
9720 {
9721 /* Check if the configuration has been changed. */
9722 if ( ( f_fModifyOnly == FALSE )
9723 || ( ( f_fModifyOnly == TRUE )
9724 && ( f_pVqeConfig->fEnableMusicProtection != pChanEntry->VqeConfig.fEnableMusicProtection ) ) )
9725 {
9726 ulFeatureBytesOffset = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.usDwordOffset * 4;
9727 ulFeatureBitOffset = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byBitOffset;
9728 ulFeatureFieldLength = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byFieldSize;
9729
9730 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9731 pChanEntry,
9732 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9733 &ulTempData);
9734 if ( ulResult != cOCT6100_ERR_OK )
9735 return ulResult;
9736
9737 /* Clear previous value set in the feature field.*/
9738 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9739
9740 ulTempData &= (~ulMask);
9741 if ( f_pVqeConfig->fEnableMusicProtection == TRUE )
9742 ulTempData |= ( 1 << ulFeatureBitOffset );
9743
9744 /* Then save the DWORD where the field is located.*/
9745 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9746 pChanEntry,
9747 ulNlpConfigBaseAddress + ulFeatureBytesOffset,
9748 ulTempData);
9749 if ( ulResult != cOCT6100_ERR_OK )
9750 return ulResult;
9751 }
9752 }
9753 /*==============================================================================*/
9754
9755 return cOCT6100_ERR_OK;
9756 }
9757 #endif
9758
9759 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9760
9761 Function: Oct6100ApiWriteVqeAfMemory
9762
9763 Description: This function configures the AF related VQE features of an
9764 echo channel.
9765
9766 -------------------------------------------------------------------------------
9767 | Argument | Description
9768 -------------------------------------------------------------------------------
9769 f_pApiInstance Pointer to API instance. This memory is used to keep
9770 the present state of the chip and all its resources.
9771
9772 f_pVqeConfig Pointer to a VQE config structure.
9773 f_pChannelOpen Pointer to a channel configuration structure.
9774 f_usChanIndex Index of the echo channel in the API instance.
9775 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
9776 f_fClearPlayoutPointers Flag indicating if the playout pointer should be cleared.
9777 f_fModifyOnly Flag indicating if the configuration should be
9778 modified only.
9779
9780 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9781 #if !SKIP_Oct6100ApiWriteVqeAfMemory
9782 UINT32 Oct6100ApiWriteVqeAfMemory(
9783 IN tPOCT6100_INSTANCE_API f_pApiInstance,
9784 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
9785 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
9786 IN UINT16 f_usChanIndex,
9787 IN UINT16 f_usEchoMemIndex,
9788 IN BOOL f_fClearPlayoutPointers,
9789 IN BOOL f_fModifyOnly )
9790 {
9791 tPOCT6100_API_CHANNEL pChanEntry;
9792 tPOCT6100_SHARED_INFO pSharedInfo;
9793 UINT32 ulResult;
9794 UINT32 ulTempData;
9795 UINT32 ulAfConfigBaseAddress;
9796 UINT32 ulFeatureBytesOffset;
9797 UINT32 ulFeatureBitOffset;
9798 UINT32 ulFeatureFieldLength;
9799 UINT32 ulMask;
9800 UINT16 usTempData;
9801
9802 pSharedInfo = f_pApiInstance->pSharedInfo;
9803
9804 /* Obtain a pointer to the new buffer's list entry. */
9805 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
9806
9807 /*==============================================================================*/
9808 /* Write the AF CPU configuration of the channel feature by feature.*/
9809
9810 /* Calculate AF CPU configuration base address. */
9811 ulAfConfigBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
9812
9813 /* Set initial value to zero.*/
9814 ulTempData = 0;
9815
9816 /*==============================================================================*/
9817 /* Program the Maximum echo point within the Main channel memory.*/
9818 if ( pSharedInfo->ImageInfo.fMaxEchoPoint == TRUE )
9819 {
9820 /* Check if the configuration has been changed. */
9821 if ( ( f_fModifyOnly == FALSE )
9822 || ( ( f_fModifyOnly == TRUE )
9823 && ( ( f_pVqeConfig->lDefaultErlDb != pChanEntry->VqeConfig.chDefaultErlDb )
9824 || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
9825 {
9826 /* Write the echo tail length */
9827 ulFeatureBytesOffset = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.usDwordOffset * 4;
9828 ulFeatureBitOffset = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.byBitOffset;
9829 ulFeatureFieldLength = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.byFieldSize;
9830
9831 /* First read the DWORD where the field is located.*/
9832 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9833 pChanEntry,
9834 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9835 &ulTempData);
9836 if ( ulResult != cOCT6100_ERR_OK )
9837 return ulResult;
9838
9839 /* Clear previous value set in the feature field.*/
9840 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9841
9842 ulTempData &= (~ulMask);
9843
9844 /* Convert the DB value to octasic's float format.*/
9845 if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
9846 {
9847 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb );
9848 }
9849 else
9850 {
9851 /* Clear max echo point. No echo cancellation here. */
9852 usTempData = 0x0;
9853 }
9854
9855 if ( ulFeatureFieldLength < 16 )
9856 usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
9857
9858 ulTempData |= usTempData << ulFeatureBitOffset;
9859
9860 /* First read the DWORD where the field is located.*/
9861 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9862 pChanEntry,
9863 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9864 ulTempData);
9865 if ( ulResult != cOCT6100_ERR_OK )
9866 return ulResult;
9867 }
9868 }
9869 /*==============================================================================*/
9870
9871
9872 /*==============================================================================*/
9873 /* Set the non-linear behavior B.*/
9874 if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorB == TRUE )
9875 {
9876 /* Check if the configuration has been changed. */
9877 if ( ( f_fModifyOnly == FALSE )
9878 || ( ( f_fModifyOnly == TRUE )
9879 && ( f_pVqeConfig->ulNonLinearityBehaviorB != pChanEntry->VqeConfig.byNonLinearityBehaviorB ) ) )
9880 {
9881 ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.usDwordOffset * 4;
9882 ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byBitOffset;
9883 ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byFieldSize;
9884
9885 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9886 pChanEntry,
9887 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9888 &ulTempData);
9889 if ( ulResult != cOCT6100_ERR_OK )
9890 return ulResult;
9891
9892 /* Clear previous value set in the feature field.*/
9893 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9894
9895 ulTempData &= (~ulMask);
9896 ulTempData |= (f_pVqeConfig->ulNonLinearityBehaviorB << ulFeatureBitOffset );
9897
9898 /* Then save the DWORD where the field is located.*/
9899 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9900 pChanEntry,
9901 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9902 ulTempData);
9903 if ( ulResult != cOCT6100_ERR_OK )
9904 return ulResult;
9905 }
9906 }
9907 /*==============================================================================*/
9908
9909
9910 /*==============================================================================*/
9911 /* Set the listener enhancement feature. */
9912 if ( pSharedInfo->ImageInfo.fListenerEnhancement == TRUE )
9913 {
9914 /* Check if the configuration has been changed. */
9915 if ( ( f_fModifyOnly == FALSE )
9916 || ( ( f_fModifyOnly == TRUE )
9917 && ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb )
9918 || ( f_pVqeConfig->fSoutNaturalListenerEnhancement != pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement )
9919 || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb ) ) ) )
9920 {
9921 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveAleOfst.usDwordOffset * 4;
9922 ulFeatureBitOffset = pSharedInfo->MemoryMap.AdaptiveAleOfst.byBitOffset;
9923 ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveAleOfst.byFieldSize;
9924
9925 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9926 pChanEntry,
9927 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9928 &ulTempData);
9929 if ( ulResult != cOCT6100_ERR_OK )
9930 return ulResult;
9931
9932 /* Clear previous value set in the feature field.*/
9933 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9934
9935 ulTempData &= (~ulMask);
9936
9937 if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 )
9938 {
9939 UINT32 ulGainDb;
9940
9941 ulGainDb = f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb / 3;
9942
9943 /* Round up. */
9944 if ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb % 3 ) != 0x0 )
9945 ulGainDb ++;
9946
9947 ulTempData |= ( ulGainDb << ulFeatureBitOffset );
9948 }
9949 else if ( f_pVqeConfig->fSoutNaturalListenerEnhancement != 0 )
9950 {
9951 UINT32 ulGainDb;
9952
9953 ulGainDb = f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb / 3;
9954
9955 /* Round up. */
9956 if ( ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb % 3 ) != 0x0 )
9957 ulGainDb ++;
9958
9959 ulTempData |= ( ( 0x80 | ulGainDb ) << ulFeatureBitOffset );
9960 }
9961
9962 /* Now write the DWORD where the field is located containing the new configuration. */
9963 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
9964 pChanEntry,
9965 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9966 ulTempData);
9967 if ( ulResult != cOCT6100_ERR_OK )
9968 return ulResult;
9969 }
9970 }
9971 /*==============================================================================*/
9972
9973
9974 /*==============================================================================*/
9975 /* Set the idle code detection enable. */
9976 if ( ( pSharedInfo->ImageInfo.fIdleCodeDetection == TRUE )
9977 && ( pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration == TRUE ) )
9978 {
9979 /* Check if the configuration has been changed. */
9980 if ( ( f_fModifyOnly == FALSE )
9981 || ( ( f_fModifyOnly == TRUE )
9982 && ( f_pVqeConfig->fIdleCodeDetection != pChanEntry->VqeConfig.fIdleCodeDetection ) ) )
9983 {
9984 /* Calculate base address in the AF software configuration. */
9985 ulFeatureBytesOffset = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.usDwordOffset * 4;
9986 ulFeatureBitOffset = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.byBitOffset;
9987 ulFeatureFieldLength = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.byFieldSize;
9988
9989 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
9990 pChanEntry,
9991 ulAfConfigBaseAddress + ulFeatureBytesOffset,
9992 &ulTempData);
9993 if ( ulResult != cOCT6100_ERR_OK )
9994 return ulResult;
9995
9996 /* Clear previous value set in the feature field.*/
9997 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9998
9999 ulTempData &= (~ulMask);
10000 if ( f_pVqeConfig->fIdleCodeDetection == FALSE )
10001 ulTempData |= ( 1 << ulFeatureBitOffset );
10002
10003 /* Then save the DWORD where the field is located.*/
10004 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
10005 pChanEntry,
10006 ulAfConfigBaseAddress + ulFeatureBytesOffset,
10007 ulTempData);
10008 if ( ulResult != cOCT6100_ERR_OK )
10009 return ulResult;
10010 }
10011 }
10012 /*==============================================================================*/
10013
10014
10015 /*==============================================================================*/
10016 /* Set the AFT control field. */
10017 if ( pSharedInfo->ImageInfo.fAftControl == TRUE )
10018 {
10019 /* Check if the configuration has been changed. */
10020 if ( ( f_fModifyOnly == FALSE )
10021 || ( ( f_fModifyOnly == TRUE )
10022 && ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) )
10023 {
10024 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AftControlOfst.usDwordOffset * 4;
10025 ulFeatureBitOffset = pSharedInfo->MemoryMap.AftControlOfst.byBitOffset;
10026 ulFeatureFieldLength = pSharedInfo->MemoryMap.AftControlOfst.byFieldSize;
10027
10028 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
10029 pChanEntry,
10030 ulAfConfigBaseAddress + ulFeatureBytesOffset,
10031 &ulTempData);
10032 if ( ulResult != cOCT6100_ERR_OK )
10033 return ulResult;
10034
10035 /* Clear previous value set in the feature field.*/
10036 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
10037
10038 ulTempData &= (~ulMask);
10039
10040 /* If the operation mode is no echo, set the field such that echo cancellation is disabled. */
10041 if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
10042 {
10043 ulTempData |= ( 0x1234 << ulFeatureBitOffset );
10044 }
10045 else if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
10046 {
10047 /* For clarity. */
10048 ulTempData |= ( 0x0 << ulFeatureBitOffset );
10049 }
10050
10051 /* Then save the DWORD where the field is located.*/
10052 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
10053 pChanEntry,
10054 ulAfConfigBaseAddress + ulFeatureBytesOffset,
10055 ulTempData);
10056 if ( ulResult != cOCT6100_ERR_OK )
10057 return ulResult;
10058 }
10059 }
10060 /*==============================================================================*/
10061
10062 return cOCT6100_ERR_OK;
10063 }
10064 #endif
10065
10066
10067
10068
10069 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10070
10071 Function: Oct6100ApiWriteEchoMemory
10072
10073 Description: This function configure an echo memory entry in internal memory.and
10074 external memory.
10075
10076 -------------------------------------------------------------------------------
10077 | Argument | Description
10078 -------------------------------------------------------------------------------
10079 f_pApiInstance Pointer to API instance. This memory is used to keep
10080 the present state of the chip and all its resources.
10081
10082 f_pTdmConfig Pointer to a TDM config structure.
10083 f_pChannelOpen Pointer to a channel configuration structure.
10084 f_usEchoIndex Echo channel index within the SSPX memory.
10085 f_usRinRoutTsiIndex RIN/ROUT TSI index within the TSI chariot memory
10086 f_usSinSoutTsiIndex SIN/SOUT TSI index within the TSI chariot memory
10087
10088 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10089 #if !SKIP_Oct6100ApiWriteEchoMemory
10090 UINT32 Oct6100ApiWriteEchoMemory(
10091 IN tPOCT6100_INSTANCE_API f_pApiInstance,
10092 IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig,
10093 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
10094 IN UINT16 f_usEchoIndex,
10095 IN UINT16 f_usRinRoutTsiIndex,
10096 IN UINT16 f_usSinSoutTsiIndex )
10097
10098 {
10099 tPOCT6100_SHARED_INFO pSharedInfo;
10100 tOCT6100_WRITE_PARAMS WriteParams;
10101 UINT32 ulResult;
10102 UINT32 ulTempData;
10103 UINT32 ulBaseAddress;
10104 UINT32 ulRinPcmLaw;
10105 UINT32 ulRoutPcmLaw;
10106 UINT32 ulSinPcmLaw;
10107 UINT32 ulSoutPcmLaw;
10108
10109 pSharedInfo = f_pApiInstance->pSharedInfo;
10110
10111 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
10112
10113 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
10114
10115 /* Set immediately the PCM law to be programmed in the SSPX and NLP memory.*/
10116 if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
10117 {
10118 ulRinPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;
10119 ulRoutPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;
10120 ulSinPcmLaw = f_pChannelOpen->TdmConfig.ulSinPcmLaw;
10121 ulSoutPcmLaw = f_pChannelOpen->TdmConfig.ulSinPcmLaw;
10122 }
10123 else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
10124 {
10125 ulRinPcmLaw = f_pChannelOpen->TdmConfig.ulRinPcmLaw;
10126 ulRoutPcmLaw = f_pChannelOpen->TdmConfig.ulRinPcmLaw;
10127 ulSinPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;
10128 ulSoutPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;
10129 }
10130
10131 /*==============================================================================*/
10132 /* Configure the Global Static Configuration of the channel.*/
10133
10134 ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET;
10135
10136 /* Set the PGSP context base address. */
10137 ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET;
10138
10139 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET;
10140 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10141
10142 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10143 if ( ulResult != cOCT6100_ERR_OK )
10144 return ulResult;
10145
10146 WriteParams.ulWriteAddress += 2;
10147 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10148
10149 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10150 if ( ulResult != cOCT6100_ERR_OK )
10151 return ulResult;
10152
10153 /* Set the PGSP init context base address. */
10154 ulTempData = ( cOCT6100_IMAGE_FILE_BASE + 0x200 ) & 0x07FFFFFF;
10155
10156 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET;
10157 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10158
10159 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10160 if ( ulResult != cOCT6100_ERR_OK )
10161 return ulResult;
10162
10163 WriteParams.ulWriteAddress += 2;
10164 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10165
10166 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10167 if ( ulResult != cOCT6100_ERR_OK )
10168 return ulResult;
10169
10170 /* Set the RIN circular buffer base address. */
10171 ulTempData = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst) & 0x07FFFF00;
10172 ulTempData |= ( ulRoutPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
10173
10174 /* Set the circular buffer size.*/
10175 if (( pSharedInfo->MemoryMap.ulChanMainRinCBMemSize & 0xFFFF00FF ) != 0 )
10176 return cOCT6100_ERR_CHANNEL_INVALID_RIN_CB_SIZE;
10177 ulTempData |= pSharedInfo->MemoryMap.ulChanMainRinCBMemSize >> 8;
10178
10179 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET;
10180 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10181
10182 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10183 if ( ulResult != cOCT6100_ERR_OK )
10184 return ulResult;
10185
10186 WriteParams.ulWriteAddress += 2;
10187 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10188
10189 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10190 if ( ulResult != cOCT6100_ERR_OK )
10191 return ulResult;
10192
10193 /* Set the SIN circular buffer base address. */
10194 ulTempData = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst) & 0x07FFFF00;
10195 ulTempData |= ( ulSinPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
10196
10197 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET;
10198 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10199
10200 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10201 if ( ulResult != cOCT6100_ERR_OK )
10202 return ulResult;
10203
10204 WriteParams.ulWriteAddress += 2;
10205 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10206
10207 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10208 if ( ulResult != cOCT6100_ERR_OK )
10209 return ulResult;
10210
10211 /* Set the SOUT circular buffer base address. */
10212 ulTempData = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst ) & 0x07FFFF00;
10213 ulTempData |= ( ulSoutPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
10214
10215 WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET;
10216 WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
10217
10218 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10219 if ( ulResult != cOCT6100_ERR_OK )
10220 return ulResult;
10221
10222 WriteParams.ulWriteAddress += 2;
10223 WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
10224
10225 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10226 if ( ulResult != cOCT6100_ERR_OK )
10227 return ulResult;
10228
10229 /*==============================================================================*/
10230
10231
10232 /*==============================================================================*/
10233 /* ECHO SSPX Memory configuration.*/
10234
10235 WriteParams.ulWriteAddress = cOCT6100_ECHO_CONTROL_MEM_BASE + ( f_usEchoIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
10236
10237 /* ECHO memory BASE + 2 */
10238 WriteParams.ulWriteAddress += 2;
10239 WriteParams.usWriteData = 0x0000;
10240
10241 /* Set the echo control field.*/
10242 if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
10243 || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
10244 {
10245 WriteParams.usWriteData |= cOCT6100_ECHO_OP_MODE_NORMAL << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL;
10246 }
10247 else if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL )
10248 {
10249 WriteParams.usWriteData |= f_pChannelOpen->ulEchoOperationMode << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL;
10250 }
10251
10252 /* Set the SIN/SOUT law.*/
10253 WriteParams.usWriteData |= ulSinPcmLaw << cOCT6100_ECHO_CONTROL_MEM_INPUT_LAW_OFFSET;
10254 WriteParams.usWriteData |= ulSoutPcmLaw << cOCT6100_ECHO_CONTROL_MEM_OUTPUT_LAW_OFFSET;
10255
10256 /* Set the TSI chariot memory field.*/
10257 WriteParams.usWriteData |= f_usSinSoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK;
10258
10259 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10260 if ( ulResult != cOCT6100_ERR_OK )
10261 return ulResult;
10262
10263 /* ECHO memory BASE */
10264 WriteParams.ulWriteAddress -= 2;
10265 WriteParams.usWriteData = cOCT6100_ECHO_CONTROL_MEM_ACTIVATE_ENTRY;
10266
10267 /* Set the RIN/ROUT law.*/
10268 WriteParams.usWriteData |= ulRinPcmLaw << cOCT6100_ECHO_CONTROL_MEM_INPUT_LAW_OFFSET;
10269 WriteParams.usWriteData |= ulRoutPcmLaw << cOCT6100_ECHO_CONTROL_MEM_OUTPUT_LAW_OFFSET;
10270
10271 /* Set the RIN external echo control bit.*/
10272 if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_EXTERNAL )
10273 WriteParams.usWriteData |= cOCT6100_ECHO_CONTROL_MEM_EXTERNAL_AF_CTRL;
10274
10275 /* Set the TSI chariot memory field.*/
10276 WriteParams.usWriteData |= f_usRinRoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK;
10277
10278 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
10279 if ( ulResult != cOCT6100_ERR_OK )
10280 return ulResult;
10281
10282 /*==============================================================================*/
10283
10284 return cOCT6100_ERR_OK;
10285 }
10286 #endif
10287
10288
10289 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10290
10291 Function: Oct6100ApiUpdateOpenStruct
10292
10293 Description: This function will copy the new parameter from the modify structure
10294 into a channel open structure to be processed later by the same path
10295 as the channel open function.
10296 If a parameter is set to keep previous, it's current value will be
10297 extracted from the channel entry in the API.
10298
10299 -------------------------------------------------------------------------------
10300 | Argument | Description
10301 -------------------------------------------------------------------------------
10302
10303 IN f_pApiInstance Pointer to an API instance structure.
10304 IN f_pChanModify Pointer to a channel modify structure.
10305 IN OUT f_pChanOpen Pointer to a channel open structure.
10306 IN f_pChanEntry Pointer to an API channel structure.
10307
10308 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10309 #if !SKIP_Oct6100ApiUpdateOpenStruct
10310 UINT32 Oct6100ApiUpdateOpenStruct(
10311 IN tPOCT6100_INSTANCE_API f_pApiInstance,
10312 IN tPOCT6100_CHANNEL_MODIFY f_pChanModify,
10313 IN OUT tPOCT6100_CHANNEL_OPEN f_pChanOpen,
10314 IN tPOCT6100_API_CHANNEL f_pChanEntry )
10315 {
10316
10317 /* Check the generic Echo parameters.*/
10318 if ( f_pChanModify->ulEchoOperationMode == cOCT6100_KEEP_PREVIOUS_SETTING )
10319 f_pChanOpen->ulEchoOperationMode = f_pChanEntry->byEchoOperationMode;
10320 else
10321 f_pChanOpen->ulEchoOperationMode = f_pChanModify->ulEchoOperationMode;
10322
10323
10324 if ( f_pChanModify->fEnableToneDisabler == cOCT6100_KEEP_PREVIOUS_SETTING )
10325 f_pChanOpen->fEnableToneDisabler = f_pChanEntry->fEnableToneDisabler;
10326 else
10327 f_pChanOpen->fEnableToneDisabler = f_pChanModify->fEnableToneDisabler;
10328
10329
10330 if ( f_pChanModify->ulUserChanId == cOCT6100_KEEP_PREVIOUS_SETTING )
10331 f_pChanOpen->ulUserChanId = f_pChanEntry->ulUserChanId;
10332 else
10333 f_pChanOpen->ulUserChanId = f_pChanModify->ulUserChanId;
10334
10335
10336
10337 /*======================================================================*/
10338 /* Now update the TDM config.*/
10339 /* Rin PCM LAW */
10340 if ( f_pChanModify->TdmConfig.ulRinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10341 f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanEntry->TdmConfig.byRinPcmLaw;
10342 else
10343 f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanModify->TdmConfig.ulRinPcmLaw;
10344
10345 /* Sin PCM LAW */
10346 if ( f_pChanModify->TdmConfig.ulSinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10347 f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanEntry->TdmConfig.bySinPcmLaw;
10348 else
10349 f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanModify->TdmConfig.ulSinPcmLaw;
10350
10351 /* Rout PCM LAW */
10352 if ( f_pChanModify->TdmConfig.ulRoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10353 f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanEntry->TdmConfig.byRoutPcmLaw;
10354 else
10355 f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanModify->TdmConfig.ulRoutPcmLaw;
10356
10357 /* Sout PCM LAW */
10358 if ( f_pChanModify->TdmConfig.ulSoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
10359 f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanEntry->TdmConfig.bySoutPcmLaw;
10360 else
10361 f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanModify->TdmConfig.ulSoutPcmLaw;
10362
10363
10364 /* Rin Timeslot */
10365 if ( f_pChanModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10366 f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanEntry->TdmConfig.usRinTimeslot;
10367 else
10368 f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanModify->TdmConfig.ulRinTimeslot;
10369
10370 /* Rin Stream */
10371 if ( f_pChanModify->TdmConfig.ulRinStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10372 f_pChanOpen->TdmConfig.ulRinStream = f_pChanEntry->TdmConfig.usRinStream;
10373 else
10374 f_pChanOpen->TdmConfig.ulRinStream = f_pChanModify->TdmConfig.ulRinStream;
10375
10376 /* Rin Num TSSTs */
10377 if ( f_pChanModify->TdmConfig.ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10378 f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanEntry->TdmConfig.byRinNumTssts;
10379 else
10380 f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanModify->TdmConfig.ulRinNumTssts;
10381
10382
10383 /* Sin Timeslot */
10384 if ( f_pChanModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10385 f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanEntry->TdmConfig.usSinTimeslot;
10386 else
10387 f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanModify->TdmConfig.ulSinTimeslot;
10388
10389 /* Sin Stream */
10390 if ( f_pChanModify->TdmConfig.ulSinStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10391 f_pChanOpen->TdmConfig.ulSinStream = f_pChanEntry->TdmConfig.usSinStream;
10392 else
10393 f_pChanOpen->TdmConfig.ulSinStream = f_pChanModify->TdmConfig.ulSinStream;
10394
10395 /* Sin Num TSSTs */
10396 if ( f_pChanModify->TdmConfig.ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10397 f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanEntry->TdmConfig.bySinNumTssts;
10398 else
10399 f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanModify->TdmConfig.ulSinNumTssts;
10400
10401
10402 /* Rout Timeslot */
10403 if ( f_pChanModify->TdmConfig.ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10404 f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanEntry->TdmConfig.usRoutTimeslot;
10405 else
10406 f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanModify->TdmConfig.ulRoutTimeslot;
10407
10408 /* Rout Stream */
10409 if ( f_pChanModify->TdmConfig.ulRoutStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10410 f_pChanOpen->TdmConfig.ulRoutStream = f_pChanEntry->TdmConfig.usRoutStream;
10411 else
10412 f_pChanOpen->TdmConfig.ulRoutStream = f_pChanModify->TdmConfig.ulRoutStream;
10413
10414 /* Rout Num TSSTs */
10415 if ( f_pChanModify->TdmConfig.ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10416 f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanEntry->TdmConfig.byRoutNumTssts;
10417 else
10418 f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanModify->TdmConfig.ulRoutNumTssts;
10419
10420
10421 /* Sout Timeslot */
10422 if ( f_pChanModify->TdmConfig.ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
10423 f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanEntry->TdmConfig.usSoutTimeslot;
10424 else
10425 f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanModify->TdmConfig.ulSoutTimeslot;
10426
10427 /* Sout Stream */
10428 if ( f_pChanModify->TdmConfig.ulSoutStream == cOCT6100_KEEP_PREVIOUS_SETTING )
10429 f_pChanOpen->TdmConfig.ulSoutStream = f_pChanEntry->TdmConfig.usSoutStream;
10430 else
10431 f_pChanOpen->TdmConfig.ulSoutStream = f_pChanModify->TdmConfig.ulSoutStream;
10432
10433 /* Sout Num TSSTs */
10434 if ( f_pChanModify->TdmConfig.ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
10435 f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanEntry->TdmConfig.bySoutNumTssts;
10436 else
10437 f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanModify->TdmConfig.ulSoutNumTssts;
10438
10439 /*======================================================================*/
10440
10441 /*======================================================================*/
10442 /* Now update the VQE config.*/
10443
10444 if ( f_pChanModify->VqeConfig.ulComfortNoiseMode == cOCT6100_KEEP_PREVIOUS_SETTING )
10445 f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanEntry->VqeConfig.byComfortNoiseMode;
10446 else
10447 f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanModify->VqeConfig.ulComfortNoiseMode;
10448
10449 if ( f_pChanModify->VqeConfig.fEnableNlp == cOCT6100_KEEP_PREVIOUS_SETTING )
10450 f_pChanOpen->VqeConfig.fEnableNlp = f_pChanEntry->VqeConfig.fEnableNlp;
10451 else
10452 f_pChanOpen->VqeConfig.fEnableNlp = f_pChanModify->VqeConfig.fEnableNlp;
10453
10454 if ( f_pChanModify->VqeConfig.fEnableTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING )
10455 f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanEntry->VqeConfig.fEnableTailDisplacement;
10456 else
10457 f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanModify->VqeConfig.fEnableTailDisplacement;
10458
10459 if ( f_pChanModify->VqeConfig.ulTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING )
10460 f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanEntry->VqeConfig.usTailDisplacement;
10461 else
10462 f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanModify->VqeConfig.ulTailDisplacement;
10463
10464 /* Tail length cannot be modifed. */
10465 f_pChanOpen->VqeConfig.ulTailLength = f_pChanEntry->VqeConfig.usTailLength;
10466
10467
10468
10469 if ( f_pChanModify->VqeConfig.fRinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
10470 f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanEntry->VqeConfig.fRinDcOffsetRemoval;
10471 else
10472 f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanModify->VqeConfig.fRinDcOffsetRemoval;
10473
10474
10475 if ( f_pChanModify->VqeConfig.fRinLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10476 f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanEntry->VqeConfig.fRinLevelControl;
10477 else
10478 f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanModify->VqeConfig.fRinLevelControl;
10479
10480
10481 if ( f_pChanModify->VqeConfig.fRinAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10482 f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanEntry->VqeConfig.fRinAutomaticLevelControl;
10483 else
10484 f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanModify->VqeConfig.fRinAutomaticLevelControl;
10485
10486
10487 if ( f_pChanModify->VqeConfig.fRinHighLevelCompensation == cOCT6100_KEEP_PREVIOUS_SETTING )
10488 f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanEntry->VqeConfig.fRinHighLevelCompensation;
10489 else
10490 f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanModify->VqeConfig.fRinHighLevelCompensation;
10491
10492
10493 if ( f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10494 f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb;
10495 else
10496 f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb;
10497
10498
10499 if ( f_pChanModify->VqeConfig.fSinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
10500 f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanEntry->VqeConfig.fSinDcOffsetRemoval;
10501 else
10502 f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanModify->VqeConfig.fSinDcOffsetRemoval;
10503
10504
10505 if ( f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
10506 f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction;
10507 else
10508 f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction;
10509
10510
10511 if ( f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
10512 f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanEntry->VqeConfig.fSoutConferencingNoiseReduction;
10513 else
10514 f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction;
10515
10516
10517 if ( f_pChanModify->VqeConfig.fSoutNoiseBleaching == cOCT6100_KEEP_PREVIOUS_SETTING )
10518 f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanEntry->VqeConfig.fSoutNoiseBleaching;
10519 else
10520 f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanModify->VqeConfig.fSoutNoiseBleaching;
10521
10522
10523 if ( f_pChanModify->VqeConfig.fSoutLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10524 f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanEntry->VqeConfig.fSoutLevelControl;
10525 else
10526 f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanModify->VqeConfig.fSoutLevelControl;
10527
10528
10529 if ( f_pChanModify->VqeConfig.fSoutAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
10530 f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanEntry->VqeConfig.fSoutAutomaticLevelControl;
10531 else
10532 f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanModify->VqeConfig.fSoutAutomaticLevelControl;
10533
10534
10535 if ( f_pChanModify->VqeConfig.lRinLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10536 f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanEntry->VqeConfig.chRinLevelControlGainDb;
10537 else
10538 f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanModify->VqeConfig.lRinLevelControlGainDb;
10539
10540
10541 if ( f_pChanModify->VqeConfig.lSoutLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10542 f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanEntry->VqeConfig.chSoutLevelControlGainDb;
10543 else
10544 f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanModify->VqeConfig.lSoutLevelControlGainDb;
10545
10546
10547 if ( f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10548 f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb;
10549 else
10550 f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb;
10551
10552
10553 if ( f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10554 f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb;
10555 else
10556 f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb;
10557
10558
10559 if ( f_pChanModify->VqeConfig.lDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10560 f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanEntry->VqeConfig.chDefaultErlDb;
10561 else
10562 f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanModify->VqeConfig.lDefaultErlDb;
10563
10564
10565 if ( f_pChanModify->VqeConfig.lAecDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
10566 f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanEntry->VqeConfig.chAecDefaultErlDb;
10567 else
10568 f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanModify->VqeConfig.lAecDefaultErlDb;
10569
10570
10571 if ( f_pChanModify->VqeConfig.ulAecTailLength == cOCT6100_KEEP_PREVIOUS_SETTING )
10572 f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanEntry->VqeConfig.usAecTailLength;
10573 else
10574 f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanModify->VqeConfig.ulAecTailLength;
10575
10576
10577 if ( f_pChanModify->VqeConfig.fAcousticEcho == cOCT6100_KEEP_PREVIOUS_SETTING )
10578 f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanEntry->VqeConfig.fAcousticEcho;
10579 else
10580 f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanModify->VqeConfig.fAcousticEcho;
10581
10582
10583 if ( f_pChanModify->VqeConfig.fDtmfToneRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
10584 f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanEntry->VqeConfig.fDtmfToneRemoval;
10585 else
10586 f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanModify->VqeConfig.fDtmfToneRemoval;
10587
10588
10589
10590
10591
10592 if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorA == cOCT6100_KEEP_PREVIOUS_SETTING )
10593 f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanEntry->VqeConfig.byNonLinearityBehaviorA;
10594 else
10595 f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanModify->VqeConfig.ulNonLinearityBehaviorA;
10596
10597
10598 if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorB == cOCT6100_KEEP_PREVIOUS_SETTING )
10599 f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanEntry->VqeConfig.byNonLinearityBehaviorB;
10600 else
10601 f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanModify->VqeConfig.ulNonLinearityBehaviorB;
10602
10603
10604 if ( f_pChanModify->VqeConfig.ulDoubleTalkBehavior == cOCT6100_KEEP_PREVIOUS_SETTING )
10605 f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanEntry->VqeConfig.byDoubleTalkBehavior;
10606 else
10607 f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanModify->VqeConfig.ulDoubleTalkBehavior;
10608
10609
10610 if ( f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10611 f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb;
10612 else
10613 f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb;
10614
10615
10616 if ( f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10617 f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb;
10618 else
10619 f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb;
10620
10621
10622 if ( f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement == cOCT6100_KEEP_PREVIOUS_SETTING )
10623 f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement;
10624 else
10625 f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement;
10626
10627
10628 if ( f_pChanModify->VqeConfig.fRoutNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
10629 f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanEntry->VqeConfig.fRoutNoiseReduction;
10630 else
10631 f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanModify->VqeConfig.fRoutNoiseReduction;
10632
10633 if ( f_pChanModify->VqeConfig.lRoutNoiseReductionLevelGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10634 f_pChanOpen->VqeConfig.lRoutNoiseReductionLevelGainDb = f_pChanEntry->VqeConfig.chRoutNoiseReductionLevelGainDb;
10635 else
10636 f_pChanOpen->VqeConfig.lRoutNoiseReductionLevelGainDb = f_pChanModify->VqeConfig.lRoutNoiseReductionLevelGainDb;
10637
10638
10639 if ( f_pChanModify->VqeConfig.lAnrSnrEnhancementDb == cOCT6100_KEEP_PREVIOUS_SETTING )
10640 f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanEntry->VqeConfig.chAnrSnrEnhancementDb;
10641 else
10642 f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanModify->VqeConfig.lAnrSnrEnhancementDb;
10643
10644
10645 if ( f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation == cOCT6100_KEEP_PREVIOUS_SETTING )
10646 f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation;
10647 else
10648 f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation;
10649
10650
10651 if ( f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay == cOCT6100_KEEP_PREVIOUS_SETTING )
10652 f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay;
10653 else
10654 f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay;
10655
10656
10657 if ( f_pChanModify->VqeConfig.fEnableMusicProtection == cOCT6100_KEEP_PREVIOUS_SETTING )
10658 f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanEntry->VqeConfig.fEnableMusicProtection;
10659 else
10660 f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanModify->VqeConfig.fEnableMusicProtection;
10661
10662
10663 if ( f_pChanModify->VqeConfig.fIdleCodeDetection == cOCT6100_KEEP_PREVIOUS_SETTING )
10664 f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanEntry->VqeConfig.fIdleCodeDetection;
10665 else
10666 f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanModify->VqeConfig.fIdleCodeDetection;
10667
10668 /*======================================================================*/
10669
10670
10671 /*======================================================================*/
10672 /* Finaly the codec config.*/
10673
10674 if ( f_pChanModify->CodecConfig.ulDecoderPort == cOCT6100_KEEP_PREVIOUS_SETTING )
10675 f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanEntry->CodecConfig.byDecoderPort;
10676 else
10677 f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanModify->CodecConfig.ulDecoderPort;
10678
10679
10680 if ( f_pChanModify->CodecConfig.ulDecodingRate == cOCT6100_KEEP_PREVIOUS_SETTING )
10681 f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanEntry->CodecConfig.byDecodingRate;
10682 else
10683 f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanModify->CodecConfig.ulDecodingRate;
10684
10685
10686 if ( f_pChanModify->CodecConfig.ulEncoderPort == cOCT6100_KEEP_PREVIOUS_SETTING )
10687 f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanEntry->CodecConfig.byEncoderPort;
10688 else
10689 f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanModify->CodecConfig.ulEncoderPort;
10690
10691
10692 if ( f_pChanModify->CodecConfig.ulEncodingRate == cOCT6100_KEEP_PREVIOUS_SETTING )
10693 f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanEntry->CodecConfig.byEncodingRate;
10694 else
10695 f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanModify->CodecConfig.ulEncodingRate;
10696
10697 if ( f_pChanModify->CodecConfig.fEnableSilenceSuppression == cOCT6100_KEEP_PREVIOUS_SETTING )
10698 f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanEntry->CodecConfig.fEnableSilenceSuppression;
10699 else
10700 f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanModify->CodecConfig.fEnableSilenceSuppression;
10701
10702 if ( f_pChanModify->CodecConfig.ulPhasingType == cOCT6100_KEEP_PREVIOUS_SETTING )
10703 f_pChanOpen->CodecConfig.ulPhasingType = f_pChanEntry->CodecConfig.byPhasingType;
10704 else
10705 f_pChanOpen->CodecConfig.ulPhasingType = f_pChanModify->CodecConfig.ulPhasingType;
10706
10707 if ( f_pChanModify->CodecConfig.ulPhase == cOCT6100_KEEP_PREVIOUS_SETTING )
10708 f_pChanOpen->CodecConfig.ulPhase = f_pChanEntry->CodecConfig.byPhase;
10709 else
10710 f_pChanOpen->CodecConfig.ulPhase = f_pChanModify->CodecConfig.ulPhase;
10711
10712 if ( f_pChanModify->CodecConfig.ulPhasingTsstHndl == cOCT6100_KEEP_PREVIOUS_SETTING )
10713 {
10714 if ( f_pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
10715 {
10716 tPOCT6100_API_PHASING_TSST pPhasingEntry;
10717
10718 mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanEntry->usPhasingTsstIndex );
10719
10720 /* Now recreate the Phasing TSST handle.*/
10721 f_pChanOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_pChanEntry->usPhasingTsstIndex;
10722 }
10723 else
10724 {
10725 f_pChanOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
10726 }
10727 }
10728 else
10729 {
10730 f_pChanOpen->CodecConfig.ulPhasingTsstHndl = f_pChanModify->CodecConfig.ulPhasingTsstHndl;
10731 }
10732
10733 f_pChanOpen->CodecConfig.ulAdpcmNibblePosition = f_pChanEntry->CodecConfig.byAdpcmNibblePosition;
10734 /*======================================================================*/
10735
10736 return cOCT6100_ERR_OK;
10737 }
10738 #endif
10739
10740
10741
10742
10743
10744
10745
10746 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10747
10748 Function: Oct6100ApiRetrieveNlpConfDword
10749
10750 Description: This function is used by the API to store on a per channel basis
10751 the various confguration DWORD from the device. The API performs
10752 less read to the chip that way since it is always in synch with the
10753 chip.
10754
10755 -------------------------------------------------------------------------------
10756 | Argument | Description
10757 -------------------------------------------------------------------------------
10758 f_pApiInstance Pointer to API instance. This memory is used to keep
10759 the present state of the chip and all its resources.
10760
10761 f_pChanEntry Pointer to an API channel structure..
10762 f_ulAddress Address that needs to be modified..
10763 f_pulConfigDword Pointer to the content stored in the API located at the
10764 desired address.
10765
10766 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10767 #if !SKIP_Oct6100ApiRetrieveNlpConfDword
10768 UINT32 Oct6100ApiRetrieveNlpConfDword(
10769
10770 IN tPOCT6100_INSTANCE_API f_pApiInstance,
10771 IN tPOCT6100_API_CHANNEL f_pChanEntry,
10772 IN UINT32 f_ulAddress,
10773 OUT PUINT32 f_pulConfigDword )
10774 {
10775 UINT32 ulResult;
10776 UINT32 ulFirstEmptyIndex = 0xFFFFFFFF;
10777 UINT32 i;
10778
10779 /* Search for the Dword.*/
10780 for ( i = 0; i < cOCT6100_MAX_NLP_CONF_DWORD; i++ )
10781 {
10782 if ( ( ulFirstEmptyIndex == 0xFFFFFFFF ) && ( f_pChanEntry->aulNlpConfDword[ i ][ 0 ] == 0x0 ) )
10783 ulFirstEmptyIndex = i;
10784
10785 if ( f_pChanEntry->aulNlpConfDword[ i ][ 0 ] == f_ulAddress )
10786 {
10787 /* We found the matching Dword.*/
10788 *f_pulConfigDword = f_pChanEntry->aulNlpConfDword[ i ][ 1 ];
10789 return cOCT6100_ERR_OK;
10790 }
10791 }
10792
10793 if ( i == cOCT6100_MAX_NLP_CONF_DWORD && ulFirstEmptyIndex == 0xFFFFFFFF )
10794 return cOCT6100_ERR_FATAL_8E;
10795
10796 /* We did not found any entry, let's create a new entry.*/
10797 f_pChanEntry->aulNlpConfDword[ ulFirstEmptyIndex ][ 0 ] = f_ulAddress;
10798
10799
10800 /* Read the DWORD where the field is located.*/
10801 ulResult = Oct6100ApiReadDword( f_pApiInstance,
10802 f_ulAddress,
10803 f_pulConfigDword );
10804 if ( ulResult != cOCT6100_ERR_OK )
10805 return ulResult;
10806
10807 return cOCT6100_ERR_OK;
10808 }
10809 #endif
10810
10811
10812 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10813
10814 Function: Oct6100ApiSaveNlpConfDword
10815
10816 Description: This function stores a configuration Dword within an API channel
10817 structure and then writes it into the chip.
10818
10819 -------------------------------------------------------------------------------
10820 | Argument | Description
10821 -------------------------------------------------------------------------------
10822 f_pApiInstance Pointer to API instance. This memory is used to keep
10823 the present state of the chip and all its resources.
10824
10825 f_pChanEntry Pointer to an API channel structure..
10826 f_ulAddress Address that needs to be modified..
10827 f_pulConfigDword content to be stored in the API located at the
10828 desired address.
10829
10830 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10831 #if !SKIP_Oct6100ApiSaveNlpConfDword
10832 UINT32 Oct6100ApiSaveNlpConfDword(
10833
10834 IN tPOCT6100_INSTANCE_API f_pApiInstance,
10835 IN tPOCT6100_API_CHANNEL f_pChanEntry,
10836 IN UINT32 f_ulAddress,
10837 IN UINT32 f_ulConfigDword )
10838 {
10839 UINT32 ulResult;
10840 UINT32 i;
10841
10842 /* Search for the Dword.*/
10843 for ( i = 0; i < cOCT6100_MAX_NLP_CONF_DWORD; i++ )
10844 {
10845
10846 if ( f_pChanEntry->aulNlpConfDword[ i ][ 0 ] == f_ulAddress )
10847 {
10848 /* We found the matching Dword.*/
10849 f_pChanEntry->aulNlpConfDword[ i ][ 1 ] = f_ulConfigDword;
10850 break;
10851 }
10852 }
10853
10854 if ( i == cOCT6100_MAX_NLP_CONF_DWORD )
10855 return cOCT6100_ERR_FATAL_8F;
10856
10857
10858 /* Write the config DWORD.*/
10859 ulResult = Oct6100ApiWriteDword( f_pApiInstance,
10860 f_ulAddress,
10861 f_ulConfigDword );
10862 if ( ulResult != cOCT6100_ERR_OK )
10863 return ulResult;
10864
10865 return cOCT6100_ERR_OK;
10866 }
10867 #endif
10868
10869 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10870
10871 Function: Oct6100ChannelCreateBiDirSer
10872
10873 Description: Creates a bidirectional echo cancellation channel.
10874
10875 -------------------------------------------------------------------------------
10876 | Argument | Description
10877 -------------------------------------------------------------------------------
10878 f_pApiInstance Pointer to API instance. This memory is used to keep the
10879 present state of the chip and all its resources.
10880
10881 f_pChannelCreateBiDir Pointer to a create bidirectionnal channel structure.
10882
10883 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10884 #if !SKIP_Oct6100ChannelCreateBiDirSer
10885 UINT32 Oct6100ChannelCreateBiDirSer(
10886 IN tPOCT6100_INSTANCE_API f_pApiInstance,
10887 IN OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir )
10888 {
10889 UINT16 usFirstChanIndex;
10890 UINT16 usFirstChanExtraTsiIndex;
10891 UINT16 usFirstChanSinCopyEventIndex;
10892 UINT16 usFirstChanSoutCopyEventIndex;
10893 UINT16 usSecondChanIndex;
10894 UINT16 usSecondChanExtraTsiIndex;
10895 UINT16 usSecondChanSinCopyEventIndex;
10896 UINT16 usSecondChanSoutCopyEventIndex;
10897 UINT16 usBiDirChanIndex;
10898 UINT32 ulResult;
10899
10900
10901 /* Check the user's configuration of the bidir channel for errors. */
10902 ulResult = Oct6100ApiCheckChannelCreateBiDirParams( f_pApiInstance,
10903 f_pChannelCreateBiDir,
10904 &usFirstChanIndex,
10905 &usFirstChanExtraTsiIndex,
10906 &usFirstChanSinCopyEventIndex,
10907 &usSecondChanIndex,
10908 &usSecondChanExtraTsiIndex,
10909 &usSecondChanSinCopyEventIndex
10910
10911 );
10912 if ( ulResult != cOCT6100_ERR_OK )
10913 return ulResult;
10914
10915 /* Reserve all resources needed by the bidir channel. */
10916 ulResult = Oct6100ApiReserveChannelCreateBiDirResources(f_pApiInstance,
10917
10918 &usBiDirChanIndex,
10919 &usFirstChanExtraTsiIndex,
10920 &usFirstChanSinCopyEventIndex,
10921 &usFirstChanSoutCopyEventIndex,
10922 &usSecondChanExtraTsiIndex,
10923 &usSecondChanSinCopyEventIndex,
10924 &usSecondChanSoutCopyEventIndex );
10925 if ( ulResult != cOCT6100_ERR_OK )
10926 return ulResult;
10927
10928 /* Write all necessary structures to activate the echo cancellation channel. */
10929 ulResult = Oct6100ApiWriteChannelCreateBiDirStructs( f_pApiInstance,
10930
10931 usFirstChanIndex,
10932 usFirstChanExtraTsiIndex,
10933 usFirstChanSinCopyEventIndex,
10934 usFirstChanSoutCopyEventIndex,
10935 usSecondChanIndex,
10936 usSecondChanExtraTsiIndex,
10937 usSecondChanSinCopyEventIndex,
10938 usSecondChanSoutCopyEventIndex );
10939 if ( ulResult != cOCT6100_ERR_OK )
10940 return ulResult;
10941
10942 /* Update the new echo cancellation channels's entry in the ECHO channel list. */
10943 ulResult = Oct6100ApiUpdateBiDirChannelEntry( f_pApiInstance,
10944 f_pChannelCreateBiDir,
10945 usBiDirChanIndex,
10946 usFirstChanIndex,
10947 usFirstChanExtraTsiIndex,
10948 usFirstChanSinCopyEventIndex,
10949 usFirstChanSoutCopyEventIndex,
10950 usSecondChanIndex,
10951 usSecondChanExtraTsiIndex,
10952 usSecondChanSinCopyEventIndex,
10953 usSecondChanSoutCopyEventIndex );
10954 if ( ulResult != cOCT6100_ERR_OK )
10955 return ulResult;
10956
10957 return cOCT6100_ERR_OK;
10958 }
10959 #endif
10960
10961
10962
10963
10964 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10965
10966 Function: Oct6100ApiCheckChannelCreateBiDirParams
10967
10968 Description: Checks the user's parameter passed to the create bidirectional channel
10969 function.
10970
10971 -------------------------------------------------------------------------------
10972 | Argument | Description
10973 -------------------------------------------------------------------------------
10974 f_pApiInstance Pointer to API instance. This memory is used to keep the
10975 present state of the chip and all its resources.
10976
10977 f_pChannelCreateBiDir Pointer to a create bidirectionnal channel structure.
10978 f_pusFirstChanIndex Pointer to the first channel index.
10979 f_pusFirstChanExtraTsiIndex Pointer to the first channel extra TSI index.
10980 f_pusFirstChanSinCopyEventIndex Pointer to the first channel Sin copy event index.
10981 f_pusSecondChanIndex Pointer to the second channel index.
10982 f_pusSecondChanExtraTsiIndex Pointer to the second channel extra TSI index.
10983 f_pusSecondChanSinCopyEventIndex Pointer to the second channel Sin copy event index.
10984
10985 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10986 #if !SKIP_Oct6100ApiCheckChannelCreateBiDirParams
10987 UINT32 Oct6100ApiCheckChannelCreateBiDirParams(
10988 IN tPOCT6100_INSTANCE_API f_pApiInstance,
10989 IN tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir,
10990 OUT PUINT16 f_pusFirstChanIndex,
10991 OUT PUINT16 f_pusFirstChanExtraTsiIndex,
10992 OUT PUINT16 f_pusFirstChanSinCopyEventIndex,
10993 OUT PUINT16 f_pusSecondChanIndex,
10994 OUT PUINT16 f_pusSecondChanExtraTsiIndex,
10995 OUT PUINT16 f_pusSecondChanSinCopyEventIndex
10996
10997 )
10998 {
10999 tPOCT6100_SHARED_INFO pSharedInfo;
11000 tPOCT6100_API_CHANNEL pFirstChanEntry;
11001 tPOCT6100_API_CHANNEL pSecondChanEntry;
11002 UINT32 ulEntryOpenCnt;
11003 BOOL fCheckTssts = TRUE;
11004
11005 /* Obtain shared resources pointer.*/
11006 pSharedInfo = f_pApiInstance->pSharedInfo;
11007
11008 /* validate the bidirectional channel handle memory.*/
11009 if ( f_pChannelCreateBiDir->pulBiDirChannelHndl == NULL )
11010 return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
11011
11012
11013
11014 /* Check if bi-dir channels are activated. */
11015 if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxBiDirChannels == 0 )
11016 return cOCT6100_ERR_CHANNEL_BIDIR_DISABLED;
11017
11018 /*=======================================================================*/
11019 /* Verify the first channel handle. */
11020
11021 if ( (f_pChannelCreateBiDir->ulFirstChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
11022 return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
11023
11024 *f_pusFirstChanIndex = (UINT16)( f_pChannelCreateBiDir->ulFirstChannelHndl & cOCT6100_HNDL_INDEX_MASK );
11025 if ( *f_pusFirstChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
11026 return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
11027
11028 /* Get a pointer to the channel's list entry. */
11029 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, *f_pusFirstChanIndex )
11030
11031 /* Extract the entry open count from the provided handle. */
11032 ulEntryOpenCnt = ( f_pChannelCreateBiDir->ulFirstChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
11033
11034 /* Check for errors. */
11035 if ( pFirstChanEntry->fReserved != TRUE )
11036 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
11037 if ( ulEntryOpenCnt != pFirstChanEntry->byEntryOpenCnt )
11038 return cOCT6100_ERR_CHANNEL_BIDIR_FIRST_CHANNEL_HANDLE;
11039
11040 /* Check the specific state of the channel.*/
11041 if ( pFirstChanEntry->fRinRoutCodecActive == TRUE && pFirstChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_ROUT)
11042 return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
11043 if ( pFirstChanEntry->fSinSoutCodecActive == TRUE && pFirstChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_SOUT)
11044 return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
11045 if ( pFirstChanEntry->fBiDirChannel == TRUE )
11046 return cOCT6100_ERR_CHANNEL_ALREADY_BIDIR;
11047
11048 if ( pFirstChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
11049 return cOCT6100_ERR_CHANNEL_FIRST_CHAN_IN_CONFERENCE;
11050
11051 if ( fCheckTssts == TRUE )
11052 {
11053 if ( pFirstChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
11054 return cOCT6100_ERR_CHANNEL_FIRST_CHAN_SOUT_PORT;
11055 if ( pFirstChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
11056 return cOCT6100_ERR_CHANNEL_FIRST_CHAN_RIN_PORT;
11057 }
11058
11059 /* Return the desired info.*/
11060 *f_pusFirstChanExtraTsiIndex = pFirstChanEntry->usExtraSinTsiMemIndex;
11061 *f_pusFirstChanSinCopyEventIndex = pFirstChanEntry->usSinCopyEventIndex;
11062 /*=======================================================================*/
11063
11064 /*=======================================================================*/
11065 /* Verify the second channel handle. */
11066
11067 if ( (f_pChannelCreateBiDir->ulSecondChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
11068 return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
11069
11070 *f_pusSecondChanIndex = (UINT16)( f_pChannelCreateBiDir->ulSecondChannelHndl & cOCT6100_HNDL_INDEX_MASK );
11071 if ( *f_pusSecondChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
11072 return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
11073
11074 /* Get a pointer to the channel's list entry. */
11075 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, *f_pusSecondChanIndex )
11076
11077 /* Extract the entry open count from the provided handle. */
11078 ulEntryOpenCnt = ( f_pChannelCreateBiDir->ulSecondChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
11079
11080 /* Check for errors. */
11081 if ( pSecondChanEntry->fReserved != TRUE )
11082 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
11083 if ( ulEntryOpenCnt != pSecondChanEntry->byEntryOpenCnt )
11084 return cOCT6100_ERR_CHANNEL_BIDIR_SECOND_CHANNEL_HANDLE;
11085
11086 /* Check the specific state of the channel.*/
11087 if ( pSecondChanEntry->fRinRoutCodecActive == TRUE && pSecondChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_ROUT)
11088 return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
11089 if ( pSecondChanEntry->fSinSoutCodecActive == TRUE && pSecondChanEntry->CodecConfig.byEncoderPort != cOCT6100_CHANNEL_PORT_SOUT)
11090 {
11091
11092 return cOCT6100_ERR_CHANNEL_CODEC_ACTIVATED;
11093 }
11094
11095 if ( pSecondChanEntry->fBiDirChannel == TRUE )
11096 return cOCT6100_ERR_CHANNEL_ALREADY_BIDIR;
11097
11098 if ( fCheckTssts == TRUE )
11099 {
11100 if ( pSecondChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
11101 return cOCT6100_ERR_CHANNEL_SECOND_CHAN_SOUT_PORT;
11102 if ( pSecondChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
11103 return cOCT6100_ERR_CHANNEL_SECOND_CHAN_RIN_PORT;
11104 }
11105
11106 if ( pSecondChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
11107 return cOCT6100_ERR_CHANNEL_SECOND_CHAN_IN_CONFERENCE;
11108
11109 /* Return the desired info.*/
11110 *f_pusSecondChanExtraTsiIndex = pSecondChanEntry->usExtraSinTsiMemIndex;
11111 *f_pusSecondChanSinCopyEventIndex = pSecondChanEntry->usSinCopyEventIndex;
11112 /*=======================================================================*/
11113
11114 /* Check the law compatibility.*/
11115 if ( pFirstChanEntry->TdmConfig.bySoutPcmLaw != pSecondChanEntry->TdmConfig.byRinPcmLaw ||
11116 pFirstChanEntry->TdmConfig.byRinPcmLaw != pSecondChanEntry->TdmConfig.bySoutPcmLaw )
11117 return cOCT6100_ERR_CHANNEL_BIDIR_PCM_LAW;
11118
11119 return cOCT6100_ERR_OK;
11120 }
11121 #endif
11122
11123 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11124
11125 Function: Oct6100ApiReserveChannelCreateBiDirResources
11126
11127 Description: Reserves all resources needed for the new bidirectional channel.
11128
11129 -------------------------------------------------------------------------------
11130 | Argument | Description
11131 -------------------------------------------------------------------------------
11132 f_pApiInstance Pointer to API instance. This memory is used to keep the
11133 present state of the chip and all its resources.
11134
11135 f_pusBiDirChanIndex Pointer to the index of the bidirectionnal channel within the API instance.
11136 f_pusFirstChanExtraTsiIndex Pointer to the first channel extra TSI index.
11137 f_pusFirstChanSinCopyEventIndex Pointer to the first channel Sin copy event index.
11138 f_pusFirstChanSoutCopyEventIndex Pointer to the first channel Sout copy event index.
11139 f_pusSecondChanExtraTsiIndex Pointer to the second channel extra TSI index.
11140 f_pusSecondChanSinCopyEventIndex Pointer to the second channel Sin copy event index.
11141 f_pusSecondChanSoutCopyEventIndex Pointer to the second channel Sout copy event index.
11142
11143 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11144 #if !SKIP_Oct6100ApiReserveChannelCreateBiDirResources
11145 UINT32 Oct6100ApiReserveChannelCreateBiDirResources(
11146 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11147
11148 OUT PUINT16 f_pusBiDirChanIndex,
11149 IN OUT PUINT16 f_pusFirstChanExtraTsiIndex,
11150 IN OUT PUINT16 f_pusFirstChanSinCopyEventIndex,
11151 OUT PUINT16 f_pusFirstChanSoutCopyEventIndex,
11152 IN OUT PUINT16 f_pusSecondChanExtraTsiIndex,
11153 IN OUT PUINT16 f_pusSecondChanSinCopyEventIndex,
11154 OUT PUINT16 f_pusSecondChanSoutCopyEventIndex )
11155 {
11156 tPOCT6100_SHARED_INFO pSharedInfo;
11157 UINT32 ulResult = cOCT6100_ERR_OK;
11158 UINT32 ulTempVar;
11159
11160 BOOL fBiDirChanIndex = FALSE;
11161 BOOL fFirstExtraTsi = FALSE;
11162 BOOL fSecondExtraTsi = FALSE;
11163 BOOL fFirstSinCopyEvent = FALSE;
11164 BOOL fSecondSinCopyEvent = FALSE;
11165 BOOL fFirstSoutCopyEvent = FALSE;
11166
11167 /* Obtain local pointer to shared portion of instance. */
11168 pSharedInfo = f_pApiInstance->pSharedInfo;
11169
11170 /*===============================================================================*/
11171 /* Verify and reserve the resources that might already by allocated. */
11172
11173
11174 {
11175 if ( *f_pusFirstChanExtraTsiIndex == cOCT6100_INVALID_INDEX )
11176 {
11177 /* Reserve the first Extra TSI memory entry */
11178 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
11179 f_pusFirstChanExtraTsiIndex );
11180 if ( ulResult == cOCT6100_ERR_OK )
11181 fFirstExtraTsi = TRUE;
11182 }
11183
11184 if ( *f_pusFirstChanSinCopyEventIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
11185 {
11186 /* Reserve the Sin copy event for the first channel.*/
11187 ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
11188 f_pusFirstChanSinCopyEventIndex );
11189 if ( ulResult == cOCT6100_ERR_OK )
11190 fFirstSinCopyEvent = TRUE;
11191 }
11192 }
11193
11194 if ( *f_pusSecondChanExtraTsiIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
11195 {
11196 /* Reserve the second Extra TSI memory entry */
11197 ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance,
11198 f_pusSecondChanExtraTsiIndex );
11199 if ( ulResult == cOCT6100_ERR_OK )
11200 fSecondExtraTsi = TRUE;
11201 }
11202
11203 if ( *f_pusSecondChanSinCopyEventIndex == cOCT6100_INVALID_INDEX && ulResult == cOCT6100_ERR_OK )
11204 {
11205 /* Reserve the Sin copy event for the second channel.*/
11206 ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
11207 f_pusSecondChanSinCopyEventIndex );
11208 if ( ulResult == cOCT6100_ERR_OK )
11209 fSecondSinCopyEvent = TRUE;
11210 }
11211 /*===============================================================================*/
11212
11213
11214 /*===============================================================================*/
11215 /* Now reserve all the resources specific to bidirectional channels */
11216
11217 if ( ulResult == cOCT6100_ERR_OK )
11218 {
11219 ulResult = Oct6100ApiReserveBiDirChanEntry( f_pApiInstance,
11220 f_pusBiDirChanIndex );
11221 if ( ulResult == cOCT6100_ERR_OK )
11222 {
11223 fBiDirChanIndex = TRUE;
11224
11225
11226 {
11227
11228 /* Reserve the first channel Sout copy mixer event.*/
11229 ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
11230 f_pusFirstChanSoutCopyEventIndex );
11231 }
11232
11233 if ( ulResult == cOCT6100_ERR_OK )
11234 {
11235 fFirstSoutCopyEvent = TRUE;
11236
11237 /* Reserve the second channel Sout copy mixer event.*/
11238 ulResult = Oct6100ApiReserveMixerEventEntry ( f_pApiInstance,
11239 f_pusSecondChanSoutCopyEventIndex );
11240 }
11241 }
11242 }
11243
11244 /*===============================================================================*/
11245
11246
11247 /*===============================================================================*/
11248 /* Release the resources if something went wrong */
11249 if ( ulResult != cOCT6100_ERR_OK )
11250 {
11251 /*===============================================================================*/
11252 /* Release the previously reserved echo resources .*/
11253 if ( fBiDirChanIndex == TRUE )
11254 {
11255 ulTempVar = Oct6100ApiReleaseBiDirChanEntry( f_pApiInstance,
11256 *f_pusBiDirChanIndex );
11257 if ( ulTempVar != cOCT6100_ERR_OK )
11258 return ulTempVar;
11259 }
11260
11261 if ( fFirstExtraTsi == TRUE )
11262 {
11263 ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
11264 *f_pusFirstChanExtraTsiIndex );
11265 if ( ulTempVar != cOCT6100_ERR_OK )
11266 return ulTempVar;
11267 }
11268
11269 if ( fSecondExtraTsi == TRUE )
11270 {
11271 ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
11272 *f_pusSecondChanExtraTsiIndex );
11273 if ( ulTempVar != cOCT6100_ERR_OK )
11274 return ulTempVar;
11275 }
11276
11277 if ( fFirstSinCopyEvent == TRUE )
11278 {
11279 ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
11280 *f_pusFirstChanSinCopyEventIndex );
11281 if ( ulTempVar != cOCT6100_ERR_OK )
11282 return ulTempVar;
11283 }
11284
11285 if ( fSecondSinCopyEvent == TRUE )
11286 {
11287 ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
11288 *f_pusSecondChanSinCopyEventIndex );
11289 if ( ulTempVar != cOCT6100_ERR_OK )
11290 return ulTempVar;
11291 }
11292
11293 if ( ( fFirstSoutCopyEvent == TRUE )
11294
11295 )
11296 {
11297 ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
11298 *f_pusFirstChanSoutCopyEventIndex );
11299 if ( ulTempVar != cOCT6100_ERR_OK )
11300 return ulTempVar;
11301 }
11302
11303 /*===============================================================================*/
11304
11305 return ulResult;
11306 }
11307
11308 return cOCT6100_ERR_OK;
11309 }
11310 #endif
11311
11312
11313 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11314
11315 Function: Oct6100ApiWriteChannelCreateBiDirStructs
11316
11317 Description: Performs all the required structure writes to configure the
11318 new echo cancellation channel.
11319
11320 -------------------------------------------------------------------------------
11321 | Argument | Description
11322 -------------------------------------------------------------------------------
11323 f_pApiInstance Pointer to API instance. This memory is used to keep the
11324 present state of the chip and all its resources.
11325
11326 f_usFirstChanIndex Pointer to the first channel index.
11327 f_usFirstChanExtraTsiIndex Pointer to the first channel extra TSI index.
11328 f_usFirstChanSinCopyEventIndex Pointer to the first channel Sin copy event index.
11329 f_usFirstChanSoutCopyEventIndex Pointer to the first channel Sout copy event index.
11330 f_usFirstChanIndex Pointer to the second channel index.
11331 f_usSecondChanExtraTsiIndex Pointer to the second channel extra TSI index.
11332 f_usSecondChanSinCopyEventIndex Pointer to the second channel Sin copy event index.
11333 f_usSecondChanSoutCopyEventIndex Pointer to the second channel Sout copy event index.
11334
11335 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11336 #if !SKIP_Oct6100ApiWriteChannelCreateBiDirStructs
11337 UINT32 Oct6100ApiWriteChannelCreateBiDirStructs(
11338 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11339
11340 IN UINT16 f_usFirstChanIndex,
11341 IN UINT16 f_usFirstChanExtraTsiIndex,
11342 IN UINT16 f_usFirstChanSinCopyEventIndex,
11343 IN UINT16 f_usFirstChanSoutCopyEventIndex,
11344 IN UINT16 f_usSecondChanIndex,
11345 IN UINT16 f_usSecondChanExtraTsiIndex,
11346 IN UINT16 f_usSecondChanSinCopyEventIndex,
11347 IN UINT16 f_usSecondChanSoutCopyEventIndex )
11348 {
11349 tPOCT6100_SHARED_INFO pSharedInfo;
11350 tPOCT6100_API_CHANNEL pFirstChanEntry;
11351 tPOCT6100_API_CHANNEL pSecondChanEntry;
11352
11353 tOCT6100_WRITE_PARAMS WriteParams;
11354 UINT32 ulResult;
11355
11356
11357 /* Obtain local pointer to shared portion of instance. */
11358 pSharedInfo = f_pApiInstance->pSharedInfo;
11359
11360 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
11361
11362 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
11363
11364 /*==============================================================================*/
11365 /* Get a pointer to the two channel entry.*/
11366
11367 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
11368 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
11369
11370
11371
11372
11373 {
11374 /*==============================================================================*/
11375 /* Configure the Tsst control memory and add the Sin copy event if necessary. */
11376
11377 /*=======================================================================*/
11378 /* Program the Sin Copy event.*/
11379 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11380
11381 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11382 WriteParams.usWriteData |= f_usFirstChanExtraTsiIndex;
11383 WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11384
11385 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11386 if ( ulResult != cOCT6100_ERR_OK )
11387 return ulResult;
11388
11389 WriteParams.ulWriteAddress += 2;
11390 WriteParams.usWriteData = (UINT16)( pFirstChanEntry->usSinSoutTsiMemIndex );
11391
11392 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11393 if ( ulResult != cOCT6100_ERR_OK )
11394 return ulResult;
11395
11396 /*=======================================================================*/
11397
11398 /* Configure the TSST memory.*/
11399 if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11400 {
11401 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11402 pFirstChanEntry->usSinTsstIndex,
11403 f_usFirstChanExtraTsiIndex,
11404 pFirstChanEntry->TdmConfig.bySinPcmLaw );
11405 if ( ulResult != cOCT6100_ERR_OK )
11406 return ulResult;
11407 }
11408
11409 /* Now insert the event into the event list.*/
11410 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11411 f_usFirstChanSinCopyEventIndex,
11412 cOCT6100_EVENT_TYPE_SIN_COPY,
11413 f_usFirstChanIndex );
11414 if ( ulResult != cOCT6100_ERR_OK )
11415 return ulResult;
11416
11417 /*==============================================================================*/
11418 }
11419
11420
11421
11422 /*==============================================================================*/
11423 /* Configure the Tsst control memory and add the Sin copy event if necessary.*/
11424
11425 /*=======================================================================*/
11426 /* Program the Sin Copy event.*/
11427 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSecondChanSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11428
11429 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11430 WriteParams.usWriteData |= f_usSecondChanExtraTsiIndex;
11431 WriteParams.usWriteData |= pSecondChanEntry->TdmConfig.bySinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11432
11433 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11434 if ( ulResult != cOCT6100_ERR_OK )
11435 return ulResult;
11436
11437 WriteParams.ulWriteAddress += 2;
11438 WriteParams.usWriteData = (UINT16)( pSecondChanEntry->usSinSoutTsiMemIndex );
11439
11440 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11441 if ( ulResult != cOCT6100_ERR_OK )
11442 return ulResult;
11443
11444 /*=======================================================================*/
11445
11446 /* Configure the TSST memory.*/
11447 if ( pSecondChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11448 {
11449
11450 {
11451 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11452 pSecondChanEntry->usSinTsstIndex,
11453 f_usSecondChanExtraTsiIndex,
11454 pSecondChanEntry->TdmConfig.bySinPcmLaw );
11455 }
11456 if ( ulResult != cOCT6100_ERR_OK )
11457 return ulResult;
11458 }
11459
11460 /* Now insert the event into the event list.*/
11461 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11462 f_usSecondChanSinCopyEventIndex,
11463 cOCT6100_EVENT_TYPE_SIN_COPY,
11464 f_usSecondChanIndex );
11465 if ( ulResult != cOCT6100_ERR_OK )
11466 return ulResult;
11467
11468 /*==============================================================================*/
11469
11470
11471
11472 /*==============================================================================*/
11473 /* Now, let's configure the two Sout copy events.*/
11474
11475
11476 /* First event.*/
11477 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usFirstChanSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11478
11479 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11480 WriteParams.usWriteData |= pFirstChanEntry->usSinSoutTsiMemIndex;
11481 WriteParams.usWriteData |= pFirstChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11482
11483 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11484 if ( ulResult != cOCT6100_ERR_OK )
11485 return ulResult;
11486
11487 WriteParams.ulWriteAddress += 2;
11488 WriteParams.usWriteData = pSecondChanEntry->usRinRoutTsiMemIndex;
11489
11490 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11491 if ( ulResult != cOCT6100_ERR_OK )
11492 return ulResult;
11493
11494 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11495 f_usFirstChanSoutCopyEventIndex,
11496 cOCT6100_EVENT_TYPE_SOUT_COPY,
11497 f_usFirstChanIndex );
11498 if ( ulResult != cOCT6100_ERR_OK )
11499 return ulResult;
11500
11501
11502 /* Second event.*/
11503 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSecondChanSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11504
11505 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
11506 WriteParams.usWriteData |= pSecondChanEntry->usSinSoutTsiMemIndex;
11507 WriteParams.usWriteData |= pSecondChanEntry->TdmConfig.bySoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
11508
11509 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11510 if ( ulResult != cOCT6100_ERR_OK )
11511 return ulResult;
11512
11513 WriteParams.ulWriteAddress += 2;
11514 WriteParams.usWriteData = pFirstChanEntry->usRinRoutTsiMemIndex;
11515
11516 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11517 if ( ulResult != cOCT6100_ERR_OK )
11518 return ulResult;
11519
11520
11521 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
11522 f_usSecondChanSoutCopyEventIndex,
11523 cOCT6100_EVENT_TYPE_SOUT_COPY,
11524 f_usSecondChanIndex );
11525 if ( ulResult != cOCT6100_ERR_OK )
11526 return ulResult;
11527
11528 /*==============================================================================*/
11529
11530
11531 /*==============================================================================*/
11532 /* Clear + release the silence events if they were created. */
11533
11534 if ( pFirstChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
11535 {
11536 /* Remove the event from the list.*/
11537 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
11538 pFirstChanEntry->usRinSilenceEventIndex,
11539 cOCT6100_EVENT_TYPE_SOUT_COPY );
11540 if ( ulResult != cOCT6100_ERR_OK )
11541 return ulResult;
11542
11543 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usRinSilenceEventIndex );
11544 if ( ulResult != cOCT6100_ERR_OK )
11545 return cOCT6100_ERR_FATAL_E0;
11546
11547 pFirstChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
11548 }
11549
11550 if ( ( pSecondChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX )
11551
11552 )
11553 {
11554 /* Remove the event from the list.*/
11555 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
11556 pSecondChanEntry->usRinSilenceEventIndex,
11557 cOCT6100_EVENT_TYPE_SOUT_COPY );
11558 if ( ulResult != cOCT6100_ERR_OK )
11559 return ulResult;
11560
11561 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usRinSilenceEventIndex );
11562 if ( ulResult != cOCT6100_ERR_OK )
11563 return cOCT6100_ERR_FATAL_E0;
11564
11565 pSecondChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
11566 }
11567
11568 /*==============================================================================*/
11569
11570 return cOCT6100_ERR_OK;
11571 }
11572 #endif
11573
11574
11575
11576 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11577
11578 Function: Oct6100ApiUpdateBiDirChannelEntry
11579
11580 Description: Updates the new bidir channel and the channel used to create that channel.
11581
11582 -------------------------------------------------------------------------------
11583 | Argument | Description
11584 -------------------------------------------------------------------------------
11585 f_pApiInstance Pointer to API instance. This memory is used to keep
11586 the present state of the chip and all its resources.
11587
11588 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11589 #if !SKIP_Oct6100ApiUpdateBiDirChannelEntry
11590 UINT32 Oct6100ApiUpdateBiDirChannelEntry(
11591 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11592 OUT tPOCT6100_CHANNEL_CREATE_BIDIR f_pChannelCreateBiDir,
11593 IN UINT16 f_usBiDirChanIndex,
11594 IN UINT16 f_usFirstChanIndex,
11595 IN UINT16 f_usFirstChanExtraTsiIndex,
11596 IN UINT16 f_usFirstChanSinCopyEventIndex,
11597 IN UINT16 f_usFirstChanSoutCopyEventIndex,
11598 IN UINT16 f_usSecondChanIndex,
11599 IN UINT16 f_usSecondChanExtraTsiIndex,
11600 IN UINT16 f_usSecondChanSinCopyEventIndex,
11601 IN UINT16 f_usSecondChanSoutCopyEventIndex )
11602 {
11603 tPOCT6100_SHARED_INFO pSharedInfo;
11604 tPOCT6100_API_CHANNEL pFirstChanEntry;
11605 tPOCT6100_API_CHANNEL pSecondChanEntry;
11606 tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
11607
11608 /* Obtain local pointer to shared portion of instance. */
11609 pSharedInfo = f_pApiInstance->pSharedInfo;
11610
11611 /* Obtain a pointer to the new buffer's list entry. */
11612 mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, f_usBiDirChanIndex );
11613 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
11614 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
11615
11616 /*=======================================================================*/
11617 /* Copy the channel's configuration and allocated resources. */
11618
11619 pFirstChanEntry->usExtraSinTsiMemIndex = f_usFirstChanExtraTsiIndex;
11620 pFirstChanEntry->usSinCopyEventIndex = f_usFirstChanSinCopyEventIndex;
11621 pFirstChanEntry->usSoutCopyEventIndex = f_usFirstChanSoutCopyEventIndex;
11622
11623 pSecondChanEntry->usExtraSinTsiMemIndex = f_usSecondChanExtraTsiIndex;
11624 pSecondChanEntry->usSinCopyEventIndex = f_usSecondChanSinCopyEventIndex;
11625 pSecondChanEntry->usSoutCopyEventIndex = f_usSecondChanSoutCopyEventIndex;
11626
11627 /* Save the channel info in the bidir channel.*/
11628 pBiDirChanEntry->usFirstChanIndex = f_usFirstChanIndex;
11629 pBiDirChanEntry->usSecondChanIndex = f_usSecondChanIndex;
11630
11631
11632
11633 /* Increment the extra TSI memory dependency count.*/
11634
11635 pFirstChanEntry->usExtraSinTsiDependencyCnt++;
11636 pSecondChanEntry->usExtraSinTsiDependencyCnt++;
11637
11638 /* Set the bidir flag in the channel structure.*/
11639 pFirstChanEntry->fBiDirChannel = TRUE;
11640 pSecondChanEntry->fBiDirChannel = TRUE;
11641
11642 /*=======================================================================*/
11643
11644 /* Form handle returned to user. */
11645 *f_pChannelCreateBiDir->pulBiDirChannelHndl = cOCT6100_HNDL_TAG_BIDIR_CHANNEL | (pBiDirChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_usBiDirChanIndex;
11646
11647 /* Finally, mark the channel as open. */
11648 pBiDirChanEntry->fReserved = TRUE;
11649
11650 /* Increment the number of channel open.*/
11651 f_pApiInstance->pSharedInfo->ChipStats.usNumberBiDirChannels++;
11652
11653 /*=======================================================================*/
11654
11655 return cOCT6100_ERR_OK;
11656 }
11657 #endif
11658
11659
11660
11661
11662
11663 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11664
11665 Function: Oct6100ChannelDestroyBiDirSer
11666
11667 Description: Closes a bidirectional channel.
11668
11669 -------------------------------------------------------------------------------
11670 | Argument | Description
11671 -------------------------------------------------------------------------------
11672 f_pApiInstance Pointer to API instance. This memory is used to keep the
11673 present state of the chip and all its resources.
11674
11675 f_pChannelDestroyBiDir Pointer to a destroy bidirectionnal channel structure.
11676
11677 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11678 #if !SKIP_Oct6100ChannelDestroyBiDirSer
11679 UINT32 Oct6100ChannelDestroyBiDirSer(
11680 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11681 IN tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir )
11682 {
11683 UINT16 usBiDirChanIndex;
11684 UINT16 usFirstChanIndex;
11685 UINT16 usSecondChanIndex;
11686
11687
11688 UINT32 ulResult;
11689
11690 /* Verify that all the parameters given match the state of the API. */
11691 ulResult = Oct6100ApiAssertDestroyBiDirChanParams( f_pApiInstance,
11692 f_pChannelDestroyBiDir,
11693 &usBiDirChanIndex,
11694
11695 &usFirstChanIndex,
11696 &usSecondChanIndex );
11697 if ( ulResult != cOCT6100_ERR_OK )
11698 return ulResult;
11699
11700 /* Release all resources associated to the echo cancellation channel. */
11701 ulResult = Oct6100ApiInvalidateBiDirChannelStructs( f_pApiInstance,
11702
11703 usFirstChanIndex,
11704 usSecondChanIndex );
11705 if ( ulResult != cOCT6100_ERR_OK )
11706 return ulResult;
11707
11708 /* Release all resources associated to the echo cancellation channel. */
11709 ulResult = Oct6100ApiReleaseBiDirChannelResources( f_pApiInstance,
11710 usBiDirChanIndex,
11711
11712 usFirstChanIndex,
11713 usSecondChanIndex );
11714 if ( ulResult != cOCT6100_ERR_OK )
11715 return ulResult;
11716
11717 /* Invalidate the handle.*/
11718 f_pChannelDestroyBiDir->ulBiDirChannelHndl = cOCT6100_INVALID_HANDLE;
11719
11720 return cOCT6100_ERR_OK;
11721 }
11722 #endif
11723
11724 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11725
11726 Function: Oct6100ApiAssertDestroyBiDirChanParams
11727
11728 Description: Validate the handle given by the user and verify the state of
11729 the channel about to be closed.
11730
11731 -------------------------------------------------------------------------------
11732 | Argument | Description
11733 -------------------------------------------------------------------------------
11734 f_pApiInstance Pointer to API instance. This memory is used to keep the
11735 present state of the chip and all its resources.
11736
11737 f_pChannelDestroyBiDir Pointer to a destroy bidirectional channel structure.
11738 f_pusBiDirChanIndex Pointer to the bidir channel entry within the API's list.
11739 f_pusFirstChanIndex Pointer to the first channel index part of the bidir channel.
11740 f_pusFirstChanIndex Pointer to the second channel index part of the bidir channel.
11741
11742 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11743 #if !SKIP_Oct6100ApiAssertDestroyBiDirChanParams
11744 UINT32 Oct6100ApiAssertDestroyBiDirChanParams(
11745 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11746 IN tPOCT6100_CHANNEL_DESTROY_BIDIR f_pChannelDestroyBiDir,
11747 IN OUT PUINT16 f_pusBiDirChanIndex,
11748
11749 IN OUT PUINT16 f_pusFirstChanIndex,
11750 IN OUT PUINT16 f_pusSecondChanIndex )
11751 {
11752 tPOCT6100_SHARED_INFO pSharedInfo;
11753 tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
11754 UINT32 ulEntryOpenCnt;
11755
11756 /* Get local pointer(s). */
11757 pSharedInfo = f_pApiInstance->pSharedInfo;
11758
11759 /* Check the provided handle. */
11760 if ( (f_pChannelDestroyBiDir->ulBiDirChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_BIDIR_CHANNEL )
11761 return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
11762
11763 *f_pusBiDirChanIndex = (UINT16)( f_pChannelDestroyBiDir->ulBiDirChannelHndl & cOCT6100_HNDL_INDEX_MASK );
11764 if ( *f_pusBiDirChanIndex >= pSharedInfo->ChipConfig.usMaxBiDirChannels )
11765 return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
11766
11767 /*=======================================================================*/
11768 /* Get a pointer to the bidir channel's list entry. */
11769
11770 mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, *f_pusBiDirChanIndex )
11771
11772 /* Extract the entry open count from the provided handle. */
11773 ulEntryOpenCnt = ( f_pChannelDestroyBiDir->ulBiDirChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
11774
11775 /* Check for errors. */
11776 if ( pBiDirChanEntry->fReserved != TRUE )
11777 return cOCT6100_ERR_CHANNEL_BIDIR_CHAN_NOT_OPEN;
11778 if ( ulEntryOpenCnt != pBiDirChanEntry->byEntryOpenCnt )
11779 return cOCT6100_ERR_CHANNEL_BIDIR_CHANNEL_HANDLE;
11780
11781 /*=======================================================================*/
11782
11783 /* Return the index of the channel used to create this bidirectional channel.*/
11784 *f_pusFirstChanIndex = pBiDirChanEntry->usFirstChanIndex;
11785 *f_pusSecondChanIndex = pBiDirChanEntry->usSecondChanIndex;
11786
11787
11788
11789 return cOCT6100_ERR_OK;
11790 }
11791 #endif
11792
11793 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11794
11795 Function: Oct6100ApiInvalidateBiDirChannelStructs
11796
11797 Description: Destroy the link between the two channels.
11798
11799 -------------------------------------------------------------------------------
11800 | Argument | Description
11801 -------------------------------------------------------------------------------
11802 f_pApiInstance Pointer to API instance. This memory is used to keep the
11803 present state of the chip and all its resources.
11804
11805 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11806 #if !SKIP_Oct6100ApiInvalidateBiDirChannelStructs
11807 UINT32 Oct6100ApiInvalidateBiDirChannelStructs(
11808 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11809
11810 IN UINT16 f_usFirstChanIndex,
11811 IN UINT16 f_usSecondChanIndex )
11812 {
11813 tPOCT6100_SHARED_INFO pSharedInfo;
11814 tPOCT6100_API_CHANNEL pFirstChanEntry;
11815 tPOCT6100_API_CHANNEL pSecondChanEntry;
11816
11817 tOCT6100_WRITE_PARAMS WriteParams;
11818 UINT32 ulResult;
11819
11820 /* Obtain local pointer to shared portion of instance. */
11821 pSharedInfo = f_pApiInstance->pSharedInfo;
11822
11823 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
11824
11825 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
11826
11827 /* Get pointers to the API entry of the two channel used to create the bidir channel.*/
11828 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
11829 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
11830
11831 /* Clear the SIN copy event of the first channel and release the Extra TSI memory if
11832 this feature was the only one using it. */
11833
11834 {
11835 if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 )
11836 {
11837 /*=======================================================================*/
11838 /* Clear the Sin Copy event.*/
11839 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11840 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
11841
11842 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11843 if ( ulResult != cOCT6100_ERR_OK )
11844 return ulResult;
11845
11846 /*=======================================================================*/
11847
11848 /* Configure the TSST memory.*/
11849 if ( pFirstChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11850 {
11851 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11852 pFirstChanEntry->usSinTsstIndex,
11853 pFirstChanEntry->usSinSoutTsiMemIndex,
11854 pFirstChanEntry->TdmConfig.bySinPcmLaw );
11855 if ( ulResult != cOCT6100_ERR_OK )
11856 return ulResult;
11857 }
11858
11859 /* Remove the event from the list.*/
11860 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
11861 pFirstChanEntry->usSinCopyEventIndex,
11862 cOCT6100_EVENT_TYPE_SIN_COPY );
11863 if ( ulResult != cOCT6100_ERR_OK )
11864 return ulResult;
11865
11866 }
11867 }
11868
11869 /* Clear the SIN copy event of the first channel and release the Extra TSI memory if
11870 this feature was the only one using it. */
11871 if ( pSecondChanEntry->usExtraSinTsiDependencyCnt == 1 )
11872 {
11873 /*=======================================================================*/
11874 /* Clear the Sin Copy event.*/
11875 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSecondChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11876 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
11877
11878 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11879 if ( ulResult != cOCT6100_ERR_OK )
11880 return ulResult;
11881
11882 /*=======================================================================*/
11883
11884 /* Configure the TSST memory.*/
11885 if ( pSecondChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
11886 {
11887 ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
11888 pSecondChanEntry->usSinTsstIndex,
11889 pSecondChanEntry->usSinSoutTsiMemIndex,
11890 pSecondChanEntry->TdmConfig.bySinPcmLaw );
11891 if ( ulResult != cOCT6100_ERR_OK )
11892 return ulResult;
11893 }
11894
11895 /* Remove the event from the list.*/
11896 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
11897 pSecondChanEntry->usSinCopyEventIndex,
11898 cOCT6100_EVENT_TYPE_SIN_COPY );
11899 if ( ulResult != cOCT6100_ERR_OK )
11900 return ulResult;
11901
11902 }
11903
11904 /* Now remove the sout copy of the first channel.*/
11905
11906
11907 {
11908 /*=======================================================================*/
11909 /* Clear the Sout Copy event of the first channel.*/
11910 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pFirstChanEntry->usSoutCopyEventIndex * 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 /* Remove the event from the list.*/
11919 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
11920 pFirstChanEntry->usSoutCopyEventIndex,
11921 cOCT6100_EVENT_TYPE_SOUT_COPY );
11922 if ( ulResult != cOCT6100_ERR_OK )
11923 return ulResult;
11924 }
11925
11926
11927
11928 /* Now remove the sout copy of the second channel.*/
11929
11930 /*=======================================================================*/
11931 /* Clear the Sout Copy event of the second channel.*/
11932 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSecondChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
11933 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
11934
11935 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11936 if ( ulResult != cOCT6100_ERR_OK )
11937 return ulResult;
11938 /*=======================================================================*/
11939
11940 /* Remove the event from the list.*/
11941 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
11942 pSecondChanEntry->usSoutCopyEventIndex,
11943 cOCT6100_EVENT_TYPE_SOUT_COPY );
11944 if ( ulResult != cOCT6100_ERR_OK )
11945 return ulResult;
11946
11947
11948
11949 return cOCT6100_ERR_OK;
11950 }
11951 #endif
11952
11953 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11954
11955 Function: Oct6100ApiReleaseBiDirChannelResources
11956
11957 Description: Release and clear the API entry associated to the bidirectional channel.
11958
11959 -------------------------------------------------------------------------------
11960 | Argument | Description
11961 -------------------------------------------------------------------------------
11962 f_pApiInstance Pointer to API instance. This memory is used to keep the
11963 present state of the chip and all its resources.
11964
11965 f_usBiDirChanIndex Index of the bidirectionnal channel in the API's bidir channel list.
11966 f_usFirstChanIndex Index of the first channel used to create the bidir channel.
11967 f_usSecondChanIndex Index of the second channel used to create the bidir channel.
11968
11969 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11970 #if !SKIP_Oct6100ApiReleaseBiDirChannelResources
11971 UINT32 Oct6100ApiReleaseBiDirChannelResources(
11972 IN tPOCT6100_INSTANCE_API f_pApiInstance,
11973 IN UINT16 f_usBiDirChanIndex,
11974
11975 IN UINT16 f_usFirstChanIndex,
11976 IN UINT16 f_usSecondChanIndex )
11977 {
11978 tPOCT6100_SHARED_INFO pSharedInfo;
11979 tPOCT6100_API_BIDIR_CHANNEL pBiDirChanEntry;
11980 tPOCT6100_API_CHANNEL pFirstChanEntry;
11981 tPOCT6100_API_CHANNEL pSecondChanEntry;
11982 tPOCT6100_API_MIXER_EVENT pTempEventEntry;
11983 UINT32 ulResult;
11984
11985 /* Obtain local pointer to shared portion of instance. */
11986 pSharedInfo = f_pApiInstance->pSharedInfo;
11987
11988 mOCT6100_GET_BIDIR_CHANNEL_ENTRY_PNT( pSharedInfo, pBiDirChanEntry, f_usBiDirChanIndex );
11989 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pFirstChanEntry, f_usFirstChanIndex );
11990 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pSecondChanEntry, f_usSecondChanIndex );
11991
11992 /* Release the bidir entry.*/
11993 ulResult = Oct6100ApiReleaseBiDirChanEntry( f_pApiInstance, f_usBiDirChanIndex );
11994 if ( ulResult != cOCT6100_ERR_OK )
11995 return cOCT6100_ERR_FATAL_AC;
11996
11997 /* Release the Extra TSI memory and the SIN copy event if required.*/
11998
11999 {
12000 if ( pFirstChanEntry->usExtraSinTsiDependencyCnt == 1 )
12001 {
12002 /* Release the two TSI chariot memory entries.*/
12003 ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pFirstChanEntry->usExtraSinTsiMemIndex );
12004 if ( ulResult != cOCT6100_ERR_OK )
12005 return cOCT6100_ERR_FATAL_A3;
12006
12007 /* Relese the SIN copy event.*/
12008 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSinCopyEventIndex );
12009 if ( ulResult != cOCT6100_ERR_OK )
12010 return cOCT6100_ERR_FATAL_A4;
12011
12012 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pFirstChanEntry->usSinCopyEventIndex );
12013
12014 /* Invalidate the entry.*/
12015 pTempEventEntry->fReserved = FALSE;
12016 pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
12017 pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12018
12019 pFirstChanEntry->usExtraSinTsiDependencyCnt--;
12020 pFirstChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
12021 pFirstChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
12022 }
12023 else
12024 {
12025 pFirstChanEntry->usExtraSinTsiDependencyCnt--;
12026 }
12027 }
12028
12029 if ( pSecondChanEntry->usExtraSinTsiDependencyCnt == 1 )
12030 {
12031 /* Release the two TSI chariot memory entries.*/
12032 ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pSecondChanEntry->usExtraSinTsiMemIndex );
12033 if ( ulResult != cOCT6100_ERR_OK )
12034 return cOCT6100_ERR_FATAL_A5;
12035
12036 /* Relese the SIN copy event.*/
12037 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usSinCopyEventIndex );
12038 if ( ulResult != cOCT6100_ERR_OK )
12039 return cOCT6100_ERR_FATAL_A6;
12040
12041 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pSecondChanEntry->usSinCopyEventIndex );
12042 /* Invalidate the entry.*/
12043 pTempEventEntry->fReserved = FALSE;
12044 pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
12045 pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12046
12047 pSecondChanEntry->usExtraSinTsiDependencyCnt--;
12048 pSecondChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
12049 pSecondChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
12050 }
12051 else
12052 {
12053 pSecondChanEntry->usExtraSinTsiDependencyCnt--;
12054 }
12055
12056
12057 {
12058 /* Release the SOUT copy event of the first channel.*/
12059 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pFirstChanEntry->usSoutCopyEventIndex );
12060 if ( ulResult != cOCT6100_ERR_OK )
12061 return cOCT6100_ERR_FATAL_A7;
12062
12063 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pFirstChanEntry->usSoutCopyEventIndex );
12064 /* Invalidate the entry.*/
12065 pTempEventEntry->fReserved = FALSE;
12066 pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
12067 pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12068 }
12069
12070 /* Release the SOUT copy event of the second channel.*/
12071 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pSecondChanEntry->usSoutCopyEventIndex );
12072 if ( ulResult != cOCT6100_ERR_OK )
12073 return cOCT6100_ERR_FATAL_A8;
12074
12075 mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, pSecondChanEntry->usSoutCopyEventIndex );
12076 /* Invalidate the entry.*/
12077 pTempEventEntry->fReserved = FALSE;
12078 pTempEventEntry->usEventType = cOCT6100_INVALID_EVENT;
12079 pTempEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
12080
12081
12082 /*=======================================================================*/
12083 /* Update the first channel's list entry. */
12084
12085 /* Mark the channel as closed. */
12086 pFirstChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX;
12087 pFirstChanEntry->fBiDirChannel = FALSE;
12088
12089 /*=======================================================================*/
12090
12091 /*=======================================================================*/
12092 /* Update the second channel's list entry. */
12093
12094 /* Mark the channel as closed. */
12095
12096 pSecondChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX;
12097 pSecondChanEntry->fBiDirChannel = FALSE;
12098
12099 /*=======================================================================*/
12100
12101 /*=======================================================================*/
12102 /* Update the bidirectional channel's list entry. */
12103
12104 /* Mark the channel as closed. */
12105 pBiDirChanEntry->fReserved = FALSE;
12106 pBiDirChanEntry->byEntryOpenCnt++;
12107
12108 pBiDirChanEntry->usFirstChanIndex = cOCT6100_INVALID_INDEX;
12109 pBiDirChanEntry->usSecondChanIndex = cOCT6100_INVALID_INDEX;
12110
12111 /* Decrement the number of channel open.*/
12112 f_pApiInstance->pSharedInfo->ChipStats.usNumberBiDirChannels--;
12113
12114 /*=======================================================================*/
12115
12116
12117 /*=======================================================================*/
12118 /* Check if some of the ports must be muted back. */
12119
12120 ulResult = Oct6100ApiMutePorts( f_pApiInstance,
12121 f_usFirstChanIndex,
12122 pFirstChanEntry->usRinTsstIndex,
12123 pFirstChanEntry->usSinTsstIndex,
12124 FALSE );
12125 if ( ulResult != cOCT6100_ERR_OK )
12126 return ulResult;
12127
12128 ulResult = Oct6100ApiMutePorts( f_pApiInstance,
12129 f_usSecondChanIndex,
12130 pSecondChanEntry->usRinTsstIndex,
12131 pSecondChanEntry->usSinTsstIndex,
12132 FALSE );
12133 if ( ulResult != cOCT6100_ERR_OK )
12134 return ulResult;
12135
12136 /*=======================================================================*/
12137
12138 return cOCT6100_ERR_OK;
12139 }
12140 #endif
12141
12142 #if !SKIP_Oct6100ApiOctFloatToDbEnergyByte
12143 INT32 Oct6100ApiOctFloatToDbEnergyByte(UINT8 x)
12144 {
12145 INT32 lResult;
12146
12147 lResult = Oct6100ApiOctFloatToDbEnergyHalf( (UINT16)(x << 8) );
12148 return lResult;
12149 }
12150 #endif
12151
12152 #if !SKIP_Oct6100ApiOctFloatToDbEnergyHalf
12153 INT32 Oct6100ApiOctFloatToDbEnergyHalf(UINT16 x)
12154 {
12155 INT32 y;
12156 UINT16 m;
12157
12158 y = (((x >> 8) & 0x7F) - 0x41) * 3;
12159
12160 m = (UINT16)((x & 0x00E0) >> 5);
12161 if (m < 2) y += 0;
12162 else if (m < 5) y += 1;
12163 else y += 2;
12164
12165 return y;
12166 }
12167 #endif
12168
12169 #if !SKIP_Oct6100ApiDbAmpHalfToOctFloat
12170 UINT16 Oct6100ApiDbAmpHalfToOctFloat(INT32 x)
12171 {
12172 INT32 db_div6;
12173 INT32 db_mod6;
12174 UINT16 rval;
12175 INT32 x_unsigned;
12176
12177 if(x < 0)
12178 {
12179 x_unsigned = -x;
12180 }
12181 else
12182 {
12183 x_unsigned = x;
12184 }
12185
12186 db_div6 = x_unsigned / 6;
12187 db_mod6 = x_unsigned % 6;
12188
12189 if(x < 0)
12190 {
12191 if(db_mod6 == 0)
12192 {
12193 /* Change nothing! */
12194 db_div6 = -db_div6;
12195 }
12196 else
12197 {
12198 /* When we are negative, round down, and then adjust modulo. For example, if
12199 x is -1, then db_div6 is 0 and db_mod6 is 1. We adjust so db_div6 = -1 and
12200 db_mod6 = 5, which gives the correct adjustment. */
12201 db_div6 = -db_div6-1;
12202 db_mod6 = 6 - db_mod6;
12203 }
12204 }
12205
12206 rval = (UINT16)(0x4100 + db_div6 * 0x100);
12207
12208 if(db_mod6 == 0)
12209 {
12210 rval += 0x0000;
12211 }
12212 else if(db_mod6 == 1)
12213 {
12214 rval += 0x0020;
12215 }
12216 else if(db_mod6 == 2)
12217 {
12218 rval += 0x0040;
12219 }
12220 else if(db_mod6 == 3)
12221 {
12222 rval += 0x0070;
12223 }
12224 else if(db_mod6 == 4)
12225 {
12226 rval += 0x0090;
12227 }
12228 else /* if(db_mod6 == 5) */
12229 {
12230 rval += 0x00D0;
12231 }
12232
12233 return rval;
12234 }
12235 #endif
12236
12237 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12238
12239 Function: Oct6100ApiWriteDebugChanMemory
12240
12241 Description: This function configure a debug channel echo memory entry
12242 in internal memory.and external memory.
12243
12244 -------------------------------------------------------------------------------
12245 | Argument | Description
12246 -------------------------------------------------------------------------------
12247 f_pApiInstance Pointer to API instance. This memory is used to keep
12248 the present state of the chip and all its resources.
12249
12250 f_pTdmConfig Pointer to a TDM configuration structure.
12251 f_pVqeConfig Pointer to a VQE configuration structure.
12252 f_pChannelOpen Pointer to a channel configuration structure.
12253 f_usChanIndex Index of the echo channel in the API instance.
12254 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
12255 f_usRinRoutTsiIndex RIN/ROUT TSI index within the TSI chariot memory.
12256 f_usSinSoutTsiIndex SIN/SOUT TSI index within the TSI chariot memory.
12257
12258 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12259 #if !SKIP_Oct6100ApiWriteDebugChanMemory
12260 UINT32 Oct6100ApiWriteDebugChanMemory(
12261 IN tPOCT6100_INSTANCE_API f_pApiInstance,
12262 IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig,
12263 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
12264 IN tPOCT6100_CHANNEL_OPEN f_pChannelOpen,
12265 IN UINT16 f_usChanIndex,
12266 IN UINT16 f_usEchoMemIndex,
12267 IN UINT16 f_usRinRoutTsiIndex,
12268 IN UINT16 f_usSinSoutTsiIndex )
12269 {
12270 UINT32 ulResult;
12271
12272 /*==============================================================================*/
12273 /* Write the VQE configuration of the debug channel. */
12274
12275 ulResult = Oct6100ApiWriteVqeMemory(
12276 f_pApiInstance,
12277 f_pVqeConfig,
12278 f_pChannelOpen,
12279 f_usChanIndex,
12280 f_usEchoMemIndex,
12281 TRUE,
12282 FALSE );
12283 if ( ulResult != cOCT6100_ERR_OK )
12284 return ulResult;
12285
12286 /*==============================================================================*/
12287
12288
12289 /*==============================================================================*/
12290
12291 /* Write the echo memory configuration of the debug channel. */
12292 ulResult = Oct6100ApiWriteEchoMemory(
12293 f_pApiInstance,
12294 f_pTdmConfig,
12295 f_pChannelOpen,
12296 f_usEchoMemIndex,
12297 f_usRinRoutTsiIndex,
12298 f_usSinSoutTsiIndex );
12299 if ( ulResult != cOCT6100_ERR_OK )
12300 return ulResult;
12301
12302 /*==============================================================================*/
12303
12304 return cOCT6100_ERR_OK;
12305 }
12306 #endif
12307
12308
12309 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12310
12311 Function: Oct6100ApiDebugChannelOpen
12312
12313 Description: Internal function used to open a debug channel.
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 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12322 #if !SKIP_Oct6100ApiDebugChannelOpen
12323 UINT32 Oct6100ApiDebugChannelOpen(
12324 IN tPOCT6100_INSTANCE_API f_pApiInstance )
12325 {
12326 tPOCT6100_SHARED_INFO pSharedInfo;
12327 tOCT6100_CHANNEL_OPEN TempChanOpen;
12328
12329 UINT32 ulResult;
12330 UINT16 usChanIndex;
12331 UINT16 usDummyEchoIndex;
12332
12333 pSharedInfo = f_pApiInstance->pSharedInfo;
12334
12335 /* Let's program the channel memory.*/
12336 Oct6100ChannelOpenDef( &TempChanOpen );
12337
12338 TempChanOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_HT_RESET; /* Activate the channel in reset.*/
12339 TempChanOpen.VqeConfig.fEnableNlp = FALSE;
12340 TempChanOpen.VqeConfig.ulComfortNoiseMode = cOCT6100_COMFORT_NOISE_NORMAL;
12341 TempChanOpen.VqeConfig.fSinDcOffsetRemoval = FALSE;
12342 TempChanOpen.VqeConfig.fRinDcOffsetRemoval = FALSE;
12343 TempChanOpen.VqeConfig.lDefaultErlDb = 0;
12344
12345 /* Loop to reserve the proper entry for the debug channel */
12346 for( usChanIndex = 0; usChanIndex < ( pSharedInfo->DebugInfo.usRecordChanIndex + 1 ); usChanIndex ++ )
12347 {
12348 ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, &usDummyEchoIndex );
12349 if( ulResult != cOCT6100_ERR_OK )
12350 return ulResult;
12351 }
12352
12353 /* Loop to free all entries except the one for the debug channel */
12354 for( usChanIndex = pSharedInfo->DebugInfo.usRecordChanIndex; usChanIndex > 0; )
12355 {
12356 usChanIndex--;
12357 ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, usChanIndex );
12358 if( ulResult != cOCT6100_ERR_OK )
12359 return ulResult;
12360 }
12361
12362 ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance,
12363 &TempChanOpen.TdmConfig,
12364 &TempChanOpen.VqeConfig,
12365 &TempChanOpen,
12366 pSharedInfo->DebugInfo.usRecordChanIndex,
12367 pSharedInfo->DebugInfo.usRecordMemIndex,
12368 pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex,
12369 pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex );
12370 if ( ulResult != cOCT6100_ERR_OK )
12371 return ulResult;
12372
12373 return cOCT6100_ERR_OK;
12374 }
12375 #endif
12376
12377
12378 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12379
12380 Function: Oct6100ApiMuteChannelPort
12381
12382 Description: This function will verify if a input TSST is bound to the RIN and
12383 SIN port. If not, the port will be muted.
12384
12385 -------------------------------------------------------------------------------
12386 | Argument | Description
12387 -------------------------------------------------------------------------------
12388 f_pApiInstance Pointer to API instance. This memory is used to keep
12389 the present state of the chip and all its resources.
12390
12391 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12392 #if !SKIP_Oct6100ApiMutePorts
12393 UINT32 Oct6100ApiMutePorts(
12394 IN tPOCT6100_INSTANCE_API f_pApiInstance,
12395 IN UINT16 f_usEchoIndex,
12396 IN UINT16 f_usRinTsstIndex,
12397 IN UINT16 f_usSinTsstIndex,
12398 IN BOOL f_fCheckBridgeIndex )
12399 {
12400 tPOCT6100_SHARED_INFO pSharedInfo;
12401 tPOCT6100_API_CHANNEL pChanEntry;
12402 tOCT6100_WRITE_PARAMS WriteParams;
12403 UINT32 ulResult;
12404
12405 pSharedInfo = f_pApiInstance->pSharedInfo;
12406
12407 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
12408
12409 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12410
12411 /* Obtain a pointer to the new buffer's list entry. */
12412 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usEchoIndex );
12413
12414 /* Mute the Rin port. */
12415 if ( ( f_fCheckBridgeIndex == FALSE )
12416 || ( ( f_fCheckBridgeIndex == TRUE ) && ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX ) ) )
12417 {
12418 /* If the channel is in bidir mode, do not create the Rin silence event!!! */
12419 if ( pChanEntry->fBiDirChannel == FALSE )
12420 {
12421 if ( ( ( f_usRinTsstIndex == cOCT6100_INVALID_INDEX ) || ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) )
12422 && ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
12423 {
12424 ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance,
12425 &pChanEntry->usRinSilenceEventIndex );
12426 if ( ulResult != cOCT6100_ERR_OK )
12427 return ulResult;
12428
12429 /* Now, write the mixer event used to copy the RIN signal of the silence channel
12430 into the RIN signal of the current channel. */
12431
12432 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usRinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
12433
12434 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
12435 WriteParams.usWriteData |= 1534;
12436 WriteParams.usWriteData |= cOCT6100_PCM_U_LAW << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
12437
12438 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12439 if ( ulResult != cOCT6100_ERR_OK )
12440 return ulResult;
12441
12442 WriteParams.ulWriteAddress += 2;
12443 WriteParams.usWriteData = pChanEntry->usRinRoutTsiMemIndex;
12444
12445 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12446 if ( ulResult != cOCT6100_ERR_OK )
12447 return ulResult;
12448
12449 /*=======================================================================*/
12450
12451
12452 /*=======================================================================*/
12453 /* Now insert the Sin copy event into the list.*/
12454
12455 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
12456 pChanEntry->usRinSilenceEventIndex,
12457 cOCT6100_EVENT_TYPE_SOUT_COPY,
12458 f_usEchoIndex );
12459 if ( ulResult != cOCT6100_ERR_OK )
12460 return ulResult;
12461 }
12462 }
12463 }
12464
12465 /* Mute the Sin port. */
12466 if ( ( ( f_usSinTsstIndex == cOCT6100_INVALID_INDEX ) || ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) )
12467 && ( pChanEntry->usSinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
12468 {
12469 ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance,
12470 &pChanEntry->usSinSilenceEventIndex );
12471 if ( ulResult != cOCT6100_ERR_OK )
12472 return ulResult;
12473
12474 /* Now, write the mixer event used to copy the SIN signal of the silence channel
12475 into the SIN signal of the current channel. */
12476
12477 WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
12478
12479 WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
12480 WriteParams.usWriteData |= 1534;
12481 WriteParams.usWriteData |= cOCT6100_PCM_U_LAW << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
12482
12483 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12484 if ( ulResult != cOCT6100_ERR_OK )
12485 return ulResult;
12486
12487 WriteParams.ulWriteAddress += 2;
12488 WriteParams.usWriteData = pChanEntry->usSinSoutTsiMemIndex;
12489
12490 mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12491 if ( ulResult != cOCT6100_ERR_OK )
12492 return ulResult;
12493
12494 /*=======================================================================*/
12495
12496
12497 /*=======================================================================*/
12498 /* Now insert the Sin copy event into the list.*/
12499
12500 ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
12501 pChanEntry->usSinSilenceEventIndex,
12502 cOCT6100_EVENT_TYPE_SOUT_COPY,
12503 f_usEchoIndex );
12504 if ( ulResult != cOCT6100_ERR_OK )
12505 return ulResult;
12506 }
12507
12508 /* Unmute the Rin port if it was muted. */
12509 if ( ( ( f_usRinTsstIndex != cOCT6100_INVALID_INDEX ) && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) == 0x0 ) )
12510 && ( pChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX ) )
12511 {
12512 /* Remove the event from the list.*/
12513 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
12514 pChanEntry->usRinSilenceEventIndex,
12515 cOCT6100_EVENT_TYPE_SOUT_COPY );
12516 if ( ulResult != cOCT6100_ERR_OK )
12517 return ulResult;
12518
12519 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usRinSilenceEventIndex );
12520 if ( ulResult != cOCT6100_ERR_OK )
12521 return cOCT6100_ERR_FATAL_E1;
12522
12523 pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
12524 }
12525
12526 /* Unmute the Sin port if it was muted. */
12527 if ( ( ( f_usSinTsstIndex != cOCT6100_INVALID_INDEX ) && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) == 0x0 ) )
12528 && ( pChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX ) )
12529 {
12530 /* Remove the event from the list.*/
12531 ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance,
12532 pChanEntry->usSinSilenceEventIndex,
12533 cOCT6100_EVENT_TYPE_SOUT_COPY );
12534 if ( ulResult != cOCT6100_ERR_OK )
12535 return ulResult;
12536
12537 ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usSinSilenceEventIndex );
12538 if ( ulResult != cOCT6100_ERR_OK )
12539 return cOCT6100_ERR_FATAL_E2;
12540
12541 pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
12542 }
12543
12544 return cOCT6100_ERR_OK;
12545 }
12546 #endif
12547
12548 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12549
12550 Function: Oct6100ApiSetChannelLevelControl
12551
12552 Description: This function will configure the level control on a given
12553 channel.
12554
12555 -------------------------------------------------------------------------------
12556 | Argument | Description
12557 -------------------------------------------------------------------------------
12558 f_pApiInstance Pointer to API instance. This memory is used to keep
12559 the present state of the chip and all its resources.
12560
12561 f_pVqeConfig VQE config of the channel.
12562 f_usChanIndex Index of the channel within the API instance.
12563 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
12564 f_fClearAlcHlcStatusBit If this is set, the ALC-HLC status bit must be
12565 incremented.
12566
12567 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12568 #if !SKIP_Oct6100ApiSetChannelLevelControl
12569 UINT32 Oct6100ApiSetChannelLevelControl(
12570 IN tPOCT6100_INSTANCE_API f_pApiInstance,
12571 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
12572 IN UINT16 f_usChanIndex,
12573 IN UINT16 f_usEchoMemIndex,
12574 IN BOOL f_fClearAlcHlcStatusBit )
12575 {
12576 tPOCT6100_API_CHANNEL pChanEntry;
12577 tPOCT6100_SHARED_INFO pSharedInfo;
12578 UINT32 ulResult;
12579 UINT32 ulTempData;
12580 UINT32 ulBaseAddress;
12581 UINT32 ulFeatureBytesOffset;
12582 UINT32 ulFeatureBitOffset;
12583 UINT32 ulFeatureFieldLength;
12584 UINT32 ulMask;
12585 UINT32 i;
12586 UINT16 usTempData;
12587 UINT8 byLastStatus;
12588 BOOL fDisableAlcFirst;
12589
12590 /* Get local pointer to shared portion of the API instance. */
12591 pSharedInfo = f_pApiInstance->pSharedInfo;
12592
12593 /* Obtain a pointer to the channel list entry. */
12594 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
12595
12596 /* Before doing anything, check if the configuration has changed. */
12597 if ( ( f_fClearAlcHlcStatusBit == TRUE )
12598 || ( f_pVqeConfig->fRinLevelControl != pChanEntry->VqeConfig.fRinLevelControl )
12599 || ( f_pVqeConfig->lRinLevelControlGainDb != pChanEntry->VqeConfig.chRinLevelControlGainDb )
12600 || ( f_pVqeConfig->fRinAutomaticLevelControl != pChanEntry->VqeConfig.fRinAutomaticLevelControl )
12601 || ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb != pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb )
12602 || ( f_pVqeConfig->fRinHighLevelCompensation != pChanEntry->VqeConfig.fRinHighLevelCompensation )
12603 || ( f_pVqeConfig->lRinHighLevelCompensationThresholdDb != pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb )
12604 || ( f_pVqeConfig->fSoutLevelControl != pChanEntry->VqeConfig.fSoutLevelControl )
12605 || ( f_pVqeConfig->lSoutLevelControlGainDb != pChanEntry->VqeConfig.chSoutLevelControlGainDb )
12606 || ( f_pVqeConfig->fSoutAutomaticLevelControl != pChanEntry->VqeConfig.fSoutAutomaticLevelControl )
12607 || ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb != pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb )
12608 || ( f_pVqeConfig->fSoutNaturalListenerEnhancement != pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement )
12609 || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb )
12610 || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb ) )
12611 {
12612 /* Calculate base address for manual level control configuration. */
12613 ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
12614
12615 /* Set the Level control on RIN port.*/
12616 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinLevelControlOfst.usDwordOffset * 4;
12617 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinLevelControlOfst.byBitOffset;
12618 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinLevelControlOfst.byFieldSize;
12619
12620 /* First read the DWORD where the field is located.*/
12621 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12622 pChanEntry,
12623 ulBaseAddress + ulFeatureBytesOffset,
12624 &ulTempData);
12625 if ( ulResult != cOCT6100_ERR_OK )
12626 return ulResult;
12627
12628 /* Clear previous value set in the feature field.*/
12629 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12630
12631 ulTempData &= (~ulMask);
12632
12633 if ( ( f_pVqeConfig->fRinLevelControl == TRUE )
12634 || ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
12635 || ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) )
12636 {
12637 /* Set the level control value.*/
12638 if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
12639 || ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) )
12640 ulTempData |= ( 0xFF << ulFeatureBitOffset );
12641 else
12642 {
12643 /* Convert the dB value into OctFloat format.*/
12644 usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lRinLevelControlGainDb );
12645 usTempData -= 0x3800;
12646 usTempData &= 0x0FF0;
12647 usTempData >>= 4;
12648
12649 ulTempData |= ( usTempData << ulFeatureBitOffset );
12650 }
12651 }
12652 else /* ( ( f_pVqeConfig->fRinLevelControl == FALSE ) && ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) && ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) ) */
12653 {
12654 ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
12655 }
12656
12657 /* Save the DWORD where the field is located.*/
12658 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12659 pChanEntry,
12660 ulBaseAddress + ulFeatureBytesOffset,
12661 ulTempData);
12662 if ( ulResult != cOCT6100_ERR_OK )
12663 return ulResult;
12664
12665 /* Set the Level control on SOUT port.*/
12666 ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutLevelControlOfst.usDwordOffset * 4;
12667 ulFeatureBitOffset = pSharedInfo->MemoryMap.SoutLevelControlOfst.byBitOffset;
12668 ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutLevelControlOfst.byFieldSize;
12669
12670 /* First read the DWORD where the field is located.*/
12671 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12672 pChanEntry,
12673 ulBaseAddress + ulFeatureBytesOffset,
12674 &ulTempData);
12675 if ( ulResult != cOCT6100_ERR_OK )
12676 return ulResult;
12677
12678 /* Clear previous value set in the feature field.*/
12679 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12680
12681 ulTempData &= (~ulMask);
12682
12683 if ( ( f_pVqeConfig->fSoutLevelControl == TRUE )
12684 || ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
12685 || ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
12686 || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0x0 ) )
12687 {
12688 /* Set the level control value.*/
12689 if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
12690 || ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
12691 || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0x0 ) )
12692 ulTempData |= ( 0xFF << ulFeatureBitOffset );
12693 else
12694 {
12695 /* Convert the dB value into OctFloat format.*/
12696 usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lSoutLevelControlGainDb );
12697 usTempData -= 0x3800;
12698 usTempData &= 0x0FF0;
12699 usTempData >>= 4;
12700
12701 ulTempData |= ( usTempData << ulFeatureBitOffset );
12702 }
12703 }
12704 else
12705 {
12706 ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
12707 }
12708
12709 /* Save the DWORD where the field is located.*/
12710 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12711 pChanEntry,
12712 ulBaseAddress + ulFeatureBytesOffset,
12713 ulTempData);
12714 if ( ulResult != cOCT6100_ERR_OK )
12715 return ulResult;
12716
12717 /* Calculate base address for auto level control + high level compensation configuration. */
12718 ulBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
12719
12720 /* Check which one is to be disabled first. */
12721 if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
12722 fDisableAlcFirst = FALSE;
12723 else
12724 fDisableAlcFirst = TRUE;
12725
12726 for ( i = 0; i < 2; i ++ )
12727 {
12728 /* Set the auto level control target Db for the Rin port. */
12729 if ( ( ( i == 0 ) && ( fDisableAlcFirst == TRUE ) ) || ( ( i == 1 ) && ( fDisableAlcFirst == FALSE ) ) )
12730 {
12731 if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE )
12732 {
12733 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.usDwordOffset * 4;
12734 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byBitOffset;
12735 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byFieldSize;
12736
12737 /* First read the DWORD where the field is located.*/
12738 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12739 pChanEntry,
12740 ulBaseAddress + ulFeatureBytesOffset,
12741 &ulTempData);
12742 if ( ulResult != cOCT6100_ERR_OK )
12743 return ulResult;
12744
12745 /* Clear previous value set in the feature field.*/
12746 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12747
12748 ulTempData &= (~ulMask);
12749
12750 if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
12751 {
12752 /* Convert the dB value into OctFloat format.*/
12753 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinAutomaticLevelControlTargetDb );
12754
12755 /* Set auto level control target on the Rin port. */
12756 ulTempData |= ( usTempData << ulFeatureBitOffset );
12757 }
12758 else /* if ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) */
12759 {
12760 /* Disable auto level control. */
12761 ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
12762 }
12763
12764 /* Save the DWORD where the field is located.*/
12765 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12766 pChanEntry,
12767 ulBaseAddress + ulFeatureBytesOffset,
12768 ulTempData);
12769 if ( ulResult != cOCT6100_ERR_OK )
12770 return ulResult;
12771 }
12772 }
12773 else
12774 {
12775 /* Set the high level compensation threshold Db for the Rin port. */
12776 if ( pSharedInfo->ImageInfo.fRinHighLevelCompensation == TRUE )
12777 {
12778 ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.usDwordOffset * 4;
12779 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byBitOffset;
12780 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byFieldSize;
12781
12782 /* First read the DWORD where the field is located.*/
12783 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12784 pChanEntry,
12785 ulBaseAddress + ulFeatureBytesOffset,
12786 &ulTempData);
12787 if ( ulResult != cOCT6100_ERR_OK )
12788 return ulResult;
12789
12790 /* Clear previous value set in the feature field.*/
12791 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12792
12793 ulTempData &= (~ulMask);
12794
12795 if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
12796 {
12797 /* Convert the dB value into OctFloat format.*/
12798 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinHighLevelCompensationThresholdDb );
12799
12800 /* Set high level compensation threshold on the Rin port. */
12801 ulTempData |= ( usTempData << ulFeatureBitOffset );
12802 }
12803 else /* if ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) */
12804 {
12805 /* Disable high level compensation. */
12806 ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
12807 }
12808
12809 /* Save the DWORD where the field is located.*/
12810 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12811 pChanEntry,
12812 ulBaseAddress + ulFeatureBytesOffset,
12813 ulTempData);
12814 if ( ulResult != cOCT6100_ERR_OK )
12815 return ulResult;
12816 }
12817 }
12818 }
12819
12820 /* Set the auto level control target Db for the Sout port. */
12821 if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE )
12822 {
12823 ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.usDwordOffset * 4;
12824 ulFeatureBitOffset = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byBitOffset;
12825 ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byFieldSize;
12826
12827 /* First read the DWORD where the field is located.*/
12828 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12829 pChanEntry,
12830 ulBaseAddress + ulFeatureBytesOffset,
12831 &ulTempData);
12832 if ( ulResult != cOCT6100_ERR_OK )
12833 return ulResult;
12834
12835 /* Clear previous value set in the feature field.*/
12836 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12837
12838 ulTempData &= (~ulMask);
12839
12840 if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
12841 {
12842 /* Convert the dB value into OctFloat format.*/
12843 usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lSoutAutomaticLevelControlTargetDb );
12844
12845 /* Set auto level control target on the Sout port. */
12846 ulTempData |= ( usTempData << ulFeatureBitOffset );
12847 }
12848 else /* if ( f_pVqeConfig->fSoutAutomaticLevelControl == FALSE ) */
12849 {
12850 /* Disable auto level control. */
12851 ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
12852 }
12853
12854 /* Save the DWORD where the field is located.*/
12855 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12856 pChanEntry,
12857 ulBaseAddress + ulFeatureBytesOffset,
12858 ulTempData);
12859 if ( ulResult != cOCT6100_ERR_OK )
12860 return ulResult;
12861 }
12862
12863 /* Set the high level compensation threshold Db for the Sout port. */
12864 if ( pSharedInfo->ImageInfo.fSoutHighLevelCompensation == TRUE )
12865 {
12866 ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.usDwordOffset * 4;
12867 ulFeatureBitOffset = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byBitOffset;
12868 ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byFieldSize;
12869
12870 /* First read the DWORD where the field is located.*/
12871 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12872 pChanEntry,
12873 ulBaseAddress + ulFeatureBytesOffset,
12874 &ulTempData);
12875 if ( ulResult != cOCT6100_ERR_OK )
12876 return ulResult;
12877
12878 /* Clear previous value set in the feature field.*/
12879 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12880
12881 ulTempData &= (~ulMask);
12882
12883 /* Disable high level compensation on Sout for now. */
12884 ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
12885
12886 /* Save the DWORD where the field is located.*/
12887 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12888 pChanEntry,
12889 ulBaseAddress + ulFeatureBytesOffset,
12890 ulTempData);
12891 if ( ulResult != cOCT6100_ERR_OK )
12892 return ulResult;
12893 }
12894
12895 /* Check if have to clear the ALC-HLC status. */
12896 if ( ( pSharedInfo->ImageInfo.fAlcHlcStatus == TRUE )
12897 && ( ( f_fClearAlcHlcStatusBit == TRUE )
12898
12899 ) )
12900 {
12901 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.usDwordOffset * 4;
12902 ulFeatureBitOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byBitOffset;
12903 ulFeatureFieldLength = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byFieldSize;
12904
12905 /* First read the DWORD where the field is located.*/
12906 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
12907 pChanEntry,
12908 ulBaseAddress + ulFeatureBytesOffset,
12909 &ulTempData);
12910 if ( ulResult != cOCT6100_ERR_OK )
12911 return ulResult;
12912
12913 /* Get previous value set in the feature field.*/
12914 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
12915
12916 /* Retrieve last status. */
12917 byLastStatus = (UINT8)( ( ( ulTempData & ulMask ) >> ulFeatureBitOffset ) & 0xFF );
12918
12919 /* Increment to reset context. */
12920 byLastStatus ++;
12921
12922 /* Just in case, not to overwrite some context in external memory. */
12923 byLastStatus &= ( 0x1 << ulFeatureFieldLength ) - 1;
12924
12925 /* Clear last status. */
12926 ulTempData &= (~ulMask);
12927
12928 /* Set new status. */
12929 ulTempData |= ( byLastStatus << ulFeatureBitOffset );
12930
12931 /* Save the DWORD where the field is located.*/
12932 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
12933 pChanEntry,
12934 ulBaseAddress + ulFeatureBytesOffset,
12935 ulTempData);
12936 if ( ulResult != cOCT6100_ERR_OK )
12937 return ulResult;
12938 }
12939 }
12940
12941 return cOCT6100_ERR_OK;
12942 }
12943 #endif
12944
12945 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12946
12947 Function: Oct6100ApiSetChannelTailConfiguration
12948
12949 Description: This function will configure the tail displacement and length
12950 on a given channel.
12951
12952 -------------------------------------------------------------------------------
12953 | Argument | Description
12954 -------------------------------------------------------------------------------
12955 f_pApiInstance Pointer to API instance. This memory is used to keep
12956 the present state of the chip and all its resources.
12957
12958 f_pVqeConfig VQE config of the channel.
12959 f_usChanIndex Index of the channel within the API instance.
12960 f_usEchoMemIndex Index of the echo channel within the SSPX memory.
12961 f_fModifyOnly Function called from a modify or open?
12962
12963 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12964 #if !SKIP_Oct6100ApiSetChannelTailConfiguration
12965 UINT32 Oct6100ApiSetChannelTailConfiguration(
12966 IN tPOCT6100_INSTANCE_API f_pApiInstance,
12967 IN tPOCT6100_CHANNEL_OPEN_VQE f_pVqeConfig,
12968 IN UINT16 f_usChanIndex,
12969 IN UINT16 f_usEchoMemIndex,
12970 IN BOOL f_fModifyOnly )
12971 {
12972 tPOCT6100_API_CHANNEL pChanEntry;
12973 tPOCT6100_SHARED_INFO pSharedInfo;
12974 UINT32 ulResult;
12975 UINT32 ulTempData;
12976 UINT32 ulNlpConfBaseAddress;
12977 UINT32 ulAfConfBaseAddress;
12978 UINT32 ulFeatureBytesOffset;
12979 UINT32 ulFeatureBitOffset;
12980 UINT32 ulFeatureFieldLength;
12981 UINT32 ulMask;
12982 UINT32 ulTailSum;
12983 BOOL fTailDisplacementModified = FALSE;
12984
12985 /* Get local pointer to shared portion of the API instance. */
12986 pSharedInfo = f_pApiInstance->pSharedInfo;
12987
12988 /* Obtain a pointer to the channel list entry. */
12989 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
12990
12991 /* Calculate base addresses of NLP + AF configuration structure for the specified channel. */
12992 ulNlpConfBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
12993 ulAfConfBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
12994
12995 /* Set the tail displacement.*/
12996 if ( pSharedInfo->ImageInfo.fTailDisplacement == TRUE )
12997 {
12998 /* Check if the configuration has been changed. */
12999 if ( ( f_fModifyOnly == FALSE )
13000 || ( ( f_fModifyOnly == TRUE )
13001 && ( ( f_pVqeConfig->fEnableTailDisplacement != pChanEntry->VqeConfig.fEnableTailDisplacement )
13002 || ( f_pVqeConfig->ulTailDisplacement != pChanEntry->VqeConfig.usTailDisplacement )
13003 || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
13004 {
13005 /* Remember that the tail displacement parameters were changed. */
13006 fTailDisplacementModified = TRUE;
13007
13008 /* Check if we must set the tail displacement value. */
13009 if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
13010 && ( pSharedInfo->ImageInfo.fPerChannelTailDisplacement == TRUE ) )
13011 {
13012 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.usDwordOffset * 4;
13013 ulFeatureBitOffset = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byBitOffset;
13014 ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byFieldSize;
13015
13016 /* First read the DWORD where the field is located.*/
13017 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13018 pChanEntry,
13019 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13020 &ulTempData);
13021 if ( ulResult != cOCT6100_ERR_OK )
13022 return ulResult;
13023
13024 /* Clear previous value set in the feature field.*/
13025 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13026
13027 ulTempData &= (~ulMask);
13028 if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
13029 && ( f_pVqeConfig->ulTailDisplacement != 0x0 ) )
13030 {
13031 if ( pSharedInfo->ImageInfo.fAfTailDisplacement == FALSE )
13032 {
13033 if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13034 {
13035 ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13036 }
13037 else
13038 {
13039 ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13040 }
13041 }
13042 else /* if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE ) */
13043 {
13044 /* If AEC is not activated, this must be set to the requested tail displacement. */
13045 if ( f_pVqeConfig->fAcousticEcho == FALSE )
13046 {
13047 if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13048 {
13049 ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement;
13050 }
13051 else
13052 {
13053 ulTailSum = f_pVqeConfig->ulTailDisplacement;
13054 }
13055
13056 if ( ulTailSum == 0 )
13057 {
13058 ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13059 }
13060 else if ( ulTailSum <= 128 )
13061 {
13062 ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
13063 }
13064 else if ( ulTailSum <= 384 )
13065 {
13066 ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
13067 }
13068 else /* if ( ulTailSum <= 896 ) */
13069 {
13070 ulTempData |= ( ( 7 ) << ulFeatureBitOffset );
13071 }
13072 }
13073 else /* if ( f_pVqeConfig->fAcousticEcho == FALSE ) */
13074 {
13075 /* Otherwise, the tail displacement is configured differently. This field stays to 0. */
13076 ulTempData |= ( 0x0 << ulFeatureBitOffset );
13077 }
13078 }
13079 }
13080
13081 /* Then save the new DWORD where the field is located.*/
13082 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13083 pChanEntry,
13084 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13085 ulTempData);
13086 if ( ulResult != cOCT6100_ERR_OK )
13087 return ulResult;
13088 }
13089
13090 if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE )
13091 {
13092 /* Set the tail displacement offset in the AF. */
13093 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.usDwordOffset * 4;
13094 ulFeatureBitOffset = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.byBitOffset;
13095 ulFeatureFieldLength = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.byFieldSize;
13096
13097 /* First read the DWORD where the field is located.*/
13098 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13099 pChanEntry,
13100 ulAfConfBaseAddress + ulFeatureBytesOffset,
13101 &ulTempData);
13102 if ( ulResult != cOCT6100_ERR_OK )
13103 return ulResult;
13104
13105 /* Clear previous value set in the feature field.*/
13106 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13107
13108 ulTempData &= (~ulMask);
13109
13110 if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13111 {
13112 ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13113 }
13114 else
13115 {
13116 ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset );
13117 }
13118
13119 /* Then save the DWORD where the field is located.*/
13120 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13121 pChanEntry,
13122 ulAfConfBaseAddress + ulFeatureBytesOffset,
13123 ulTempData);
13124 if ( ulResult != cOCT6100_ERR_OK )
13125 return ulResult;
13126 }
13127
13128 ulFeatureBytesOffset = pSharedInfo->MemoryMap.TailDisplEnableOfst.usDwordOffset * 4;
13129 ulFeatureBitOffset = pSharedInfo->MemoryMap.TailDisplEnableOfst.byBitOffset;
13130 ulFeatureFieldLength = pSharedInfo->MemoryMap.TailDisplEnableOfst.byFieldSize;
13131
13132 /* First read the DWORD where the field is located.*/
13133 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13134 pChanEntry,
13135 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13136 &ulTempData);
13137 if ( ulResult != cOCT6100_ERR_OK )
13138 return ulResult;
13139
13140 /* Clear previous value set in the feature field.*/
13141 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13142
13143 ulTempData &= (~ulMask);
13144 ulTempData |= ( ( (UINT32)f_pVqeConfig->fEnableTailDisplacement ) << ulFeatureBitOffset );
13145
13146 /* Then save the DWORD where the field is located.*/
13147 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13148 pChanEntry,
13149 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13150 ulTempData);
13151 if ( ulResult != cOCT6100_ERR_OK )
13152 return ulResult;
13153 }
13154 }
13155
13156 /* Set the tail length. */
13157 if ( pSharedInfo->ImageInfo.fPerChannelTailLength == TRUE )
13158 {
13159 /* Check if the configuration has been changed. */
13160 if ( ( f_fModifyOnly == FALSE )
13161 || ( ( f_fModifyOnly == TRUE )
13162 && ( f_pVqeConfig->ulTailLength != pChanEntry->VqeConfig.usTailLength ) ) )
13163 {
13164 ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.usDwordOffset * 4;
13165 ulFeatureBitOffset = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byBitOffset;
13166 ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byFieldSize;
13167
13168 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13169 pChanEntry,
13170 ulAfConfBaseAddress + ulFeatureBytesOffset,
13171 &ulTempData);
13172 if ( ulResult != cOCT6100_ERR_OK )
13173 return ulResult;
13174
13175 /* Clear previous value set in the feature field.*/
13176 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13177
13178 ulTempData &= (~ulMask);
13179 /* Check if must automatically select maximum or if must use user specific value. */
13180 if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
13181 {
13182 ulTempData |= ( ( ( pSharedInfo->ImageInfo.usMaxTailLength - 32 ) / 4 ) << ulFeatureBitOffset );
13183 }
13184 else
13185 {
13186 ulTempData |= ( ( ( f_pVqeConfig->ulTailLength - 32 ) / 4 ) << ulFeatureBitOffset );
13187 }
13188
13189 /* Then save the DWORD where the field is located.*/
13190 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13191 pChanEntry,
13192 ulAfConfBaseAddress + ulFeatureBytesOffset,
13193 ulTempData);
13194 if ( ulResult != cOCT6100_ERR_OK )
13195 return ulResult;
13196 }
13197 }
13198
13199 /* Configure AEC tail length. */
13200 if ( pSharedInfo->ImageInfo.fAecTailLength == TRUE )
13201 {
13202 /* Check if the configuration has been changed. */
13203 if ( ( f_fModifyOnly == FALSE )
13204 || ( fTailDisplacementModified == TRUE )
13205 || ( ( f_fModifyOnly == TRUE )
13206 && ( ( f_pVqeConfig->ulAecTailLength != pChanEntry->VqeConfig.usAecTailLength )
13207 || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
13208 {
13209 ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.usDwordOffset * 4;
13210 ulFeatureBitOffset = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byBitOffset;
13211 ulFeatureFieldLength = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byFieldSize;
13212
13213 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13214 pChanEntry,
13215 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13216 &ulTempData);
13217 if ( ulResult != cOCT6100_ERR_OK )
13218 return ulResult;
13219
13220 /* Clear previous value set in the feature field.*/
13221 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13222
13223 ulTempData &= (~ulMask);
13224
13225 /* Set acoustic echo tail length. */
13226 if ( f_pVqeConfig->fAcousticEcho == TRUE )
13227 {
13228 switch( f_pVqeConfig->ulAecTailLength )
13229 {
13230 case 1024:
13231 ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
13232 break;
13233 case 512:
13234 ulTempData |= ( ( 2 ) << ulFeatureBitOffset );
13235 break;
13236 case 256:
13237 ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
13238 break;
13239 case 128:
13240 default:
13241 ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13242 break;
13243 }
13244 }
13245 else if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
13246 {
13247 /* No acoustic echo case. */
13248
13249 /* Start with requested tail displacement. */
13250 if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
13251 {
13252 ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement;
13253 }
13254 else
13255 {
13256 ulTailSum = f_pVqeConfig->ulTailDisplacement;
13257 }
13258
13259 /* Add requested tail length. */
13260 if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
13261 {
13262 ulTailSum += pSharedInfo->ImageInfo.usMaxTailLength;
13263 }
13264 else
13265 {
13266 ulTailSum += f_pVqeConfig->ulTailLength;
13267 }
13268
13269 /* Round this value up. */
13270 if ( ulTailSum <= 128 )
13271 {
13272 ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13273 }
13274 else if ( ulTailSum <= 256 )
13275 {
13276 ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
13277 }
13278 else if ( ulTailSum <= 512 )
13279 {
13280 ulTempData |= ( ( 2 ) << ulFeatureBitOffset );
13281 }
13282 else /* if ( ulTailSum <= 1024 ) */
13283 {
13284 ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
13285 }
13286 }
13287 else
13288 {
13289 /* Keep this to zero. */
13290 ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
13291 }
13292
13293 /* Write the new DWORD where the field is located. */
13294 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13295 pChanEntry,
13296 ulNlpConfBaseAddress + ulFeatureBytesOffset,
13297 ulTempData);
13298 if ( ulResult != cOCT6100_ERR_OK )
13299 return ulResult;
13300 }
13301 }
13302
13303 return cOCT6100_ERR_OK;
13304 }
13305 #endif
13306
13307 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13308
13309 Function: Oct6100ChannelMuteSer
13310
13311 Description: This function will mute some of the ports on a given
13312 channel.
13313
13314 -------------------------------------------------------------------------------
13315 | Argument | Description
13316 -------------------------------------------------------------------------------
13317 f_pApiInstance Pointer to API instance. This memory is used to keep
13318 the present state of the chip and all its resources.
13319
13320 f_pChannelMute What channel/ports to mute.
13321
13322 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13323 #if !SKIP_Oct6100ChannelMuteSer
13324 UINT32 Oct6100ChannelMuteSer(
13325 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13326 IN tPOCT6100_CHANNEL_MUTE f_pChannelMute )
13327 {
13328 UINT32 ulResult;
13329 UINT16 usChanIndex;
13330 UINT16 usPortMask;
13331
13332 /* Verify that all the parameters given match the state of the API. */
13333 ulResult = Oct6100ApiAssertChannelMuteParams( f_pApiInstance,
13334 f_pChannelMute,
13335 &usChanIndex,
13336 &usPortMask );
13337 if ( ulResult != cOCT6100_ERR_OK )
13338 return ulResult;
13339
13340 /* Call the actual channel mute ports function. */
13341 ulResult = Oct6100ApiMuteChannelPorts( f_pApiInstance,
13342 usChanIndex,
13343 usPortMask,
13344 TRUE );
13345 if ( ulResult != cOCT6100_ERR_OK )
13346 return ulResult;
13347
13348 return cOCT6100_ERR_OK;
13349 }
13350 #endif
13351
13352 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13353
13354 Function: Oct6100ApiAssertChannelMuteParams
13355
13356 Description: Check the user parameters passed to the channel mute function.
13357
13358 -------------------------------------------------------------------------------
13359 | Argument | Description
13360 -------------------------------------------------------------------------------
13361 f_pApiInstance Pointer to API instance. This memory is used to keep
13362 the present state of the chip and all its resources.
13363
13364 f_pChannelMute What channel/ports to mute.
13365 f_pusChanIndex Resulting channel index where the muting should
13366 be applied.
13367 f_pusPorts Port mask on which to apply the muting.
13368
13369 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13370 #if !SKIP_Oct6100ApiAssertChannelMuteParams
13371 UINT32 Oct6100ApiAssertChannelMuteParams(
13372 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13373 IN tPOCT6100_CHANNEL_MUTE f_pChannelMute,
13374 OUT PUINT16 f_pusChanIndex,
13375 OUT PUINT16 f_pusPorts )
13376 {
13377 tPOCT6100_SHARED_INFO pSharedInfo;
13378 tPOCT6100_API_CHANNEL pChanEntry;
13379 UINT32 ulEntryOpenCnt;
13380
13381 /* Get local pointer(s). */
13382 pSharedInfo = f_pApiInstance->pSharedInfo;
13383
13384 /* Check the provided handle. */
13385 if ( (f_pChannelMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
13386 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13387
13388 *f_pusChanIndex = (UINT16)( f_pChannelMute->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
13389 if ( *f_pusChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
13390 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13391
13392 /*=======================================================================*/
13393 /* Get a pointer to the channel's list entry. */
13394
13395 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex )
13396
13397 /* Extract the entry open count from the provided handle. */
13398 ulEntryOpenCnt = ( f_pChannelMute->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
13399
13400 /* Check for errors. */
13401 if ( pChanEntry->fReserved != TRUE )
13402 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
13403 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
13404 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13405 if ( pChanEntry->fBiDirChannel == TRUE )
13406 return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL;
13407
13408 /*=======================================================================*/
13409
13410 /* Check the provided port mask. */
13411
13412 if ( ( f_pChannelMute->ulPortMask &
13413 ~( cOCT6100_CHANNEL_MUTE_PORT_NONE |
13414 cOCT6100_CHANNEL_MUTE_PORT_RIN |
13415 cOCT6100_CHANNEL_MUTE_PORT_ROUT |
13416 cOCT6100_CHANNEL_MUTE_PORT_SIN |
13417 cOCT6100_CHANNEL_MUTE_PORT_SOUT |
13418 cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) ) != 0 )
13419 return cOCT6100_ERR_CHANNEL_MUTE_MASK;
13420
13421 /* Sin + Sin with features cannot be muted simultaneously. */
13422 if ( ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
13423 && ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) )
13424 return cOCT6100_ERR_CHANNEL_MUTE_MASK_SIN;
13425
13426 /* Check if Sin mute with features is supported by the firmware. */
13427 if ( ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
13428 && ( pSharedInfo->ImageInfo.fSinMute == FALSE ) )
13429 return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_MUTE_FEATURES;
13430
13431 /* Return the ports to the calling function. */
13432 *f_pusPorts = (UINT16)( f_pChannelMute->ulPortMask & 0xFFFF );
13433
13434 return cOCT6100_ERR_OK;
13435 }
13436 #endif
13437
13438 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13439
13440 Function: Oct6100ChannelUnMuteSer
13441
13442 Description: This function will unmute some of the ports on a given
13443 channel.
13444
13445 -------------------------------------------------------------------------------
13446 | Argument | Description
13447 -------------------------------------------------------------------------------
13448 f_pApiInstance Pointer to API instance. This memory is used to keep
13449 the present state of the chip and all its resources.
13450
13451 f_pChannelUnMute What channel/ports to unmute.
13452
13453 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13454 #if !SKIP_Oct6100ChannelUnMuteSer
13455 UINT32 Oct6100ChannelUnMuteSer(
13456 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13457 IN tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute )
13458 {
13459 UINT32 ulResult;
13460 UINT16 usChanIndex;
13461 UINT16 usPortMask;
13462
13463 /* Verify that all the parameters given match the state of the API. */
13464 ulResult = Oct6100ApiAssertChannelUnMuteParams( f_pApiInstance,
13465 f_pChannelUnMute,
13466 &usChanIndex,
13467 &usPortMask );
13468 if ( ulResult != cOCT6100_ERR_OK )
13469 return ulResult;
13470
13471 /* Call the actual channel mute ports function. */
13472 ulResult = Oct6100ApiMuteChannelPorts( f_pApiInstance,
13473 usChanIndex,
13474 usPortMask,
13475 FALSE );
13476 if ( ulResult != cOCT6100_ERR_OK )
13477 return ulResult;
13478
13479 return cOCT6100_ERR_OK;
13480 }
13481 #endif
13482
13483 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13484
13485 Function: Oct6100ApiAssertChannelUnMuteParams
13486
13487 Description: Check the user parameters passed to the channel unmute function.
13488
13489 -------------------------------------------------------------------------------
13490 | Argument | Description
13491 -------------------------------------------------------------------------------
13492 f_pApiInstance Pointer to API instance. This memory is used to keep
13493 the present state of the chip and all its resources.
13494
13495 f_pChannelUnMute What channel/ports to Unmute.
13496 f_pusChanIndex Resulting channel index where the muting should
13497 be applied.
13498 f_pusPorts Port mask on which to apply the muting.
13499
13500 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13501 #if !SKIP_Oct6100ApiAssertChannelUnMuteParams
13502 UINT32 Oct6100ApiAssertChannelUnMuteParams(
13503 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13504 IN tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute,
13505 OUT PUINT16 f_pusChanIndex,
13506 OUT PUINT16 f_pusPorts )
13507 {
13508 tPOCT6100_SHARED_INFO pSharedInfo;
13509 tPOCT6100_API_CHANNEL pChanEntry;
13510 UINT32 ulEntryOpenCnt;
13511
13512 /* Get local pointer(s). */
13513 pSharedInfo = f_pApiInstance->pSharedInfo;
13514
13515 /* Check the provided handle. */
13516 if ( (f_pChannelUnMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
13517 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13518
13519 *f_pusChanIndex = (UINT16)( f_pChannelUnMute->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
13520 if ( *f_pusChanIndex >= pSharedInfo->ChipConfig.usMaxChannels )
13521 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13522
13523 /*=======================================================================*/
13524 /* Get a pointer to the channel's list entry. */
13525
13526 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex )
13527
13528 /* Extract the entry open count from the provided handle. */
13529 ulEntryOpenCnt = ( f_pChannelUnMute->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
13530
13531 /* Check for errors. */
13532 if ( pChanEntry->fReserved != TRUE )
13533 return cOCT6100_ERR_CHANNEL_NOT_OPEN;
13534 if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
13535 return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
13536 if ( pChanEntry->fBiDirChannel == TRUE )
13537 return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL;
13538
13539 /*=======================================================================*/
13540
13541 /* Check the provided port mask. */
13542
13543 if ( ( f_pChannelUnMute->ulPortMask &
13544 ~( cOCT6100_CHANNEL_MUTE_PORT_NONE |
13545 cOCT6100_CHANNEL_MUTE_PORT_RIN |
13546 cOCT6100_CHANNEL_MUTE_PORT_ROUT |
13547 cOCT6100_CHANNEL_MUTE_PORT_SIN |
13548 cOCT6100_CHANNEL_MUTE_PORT_SOUT |
13549 cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) ) != 0 )
13550 return cOCT6100_ERR_CHANNEL_MUTE_MASK;
13551
13552 /* Return the ports to the calling function. */
13553 *f_pusPorts = (UINT16)( f_pChannelUnMute->ulPortMask & 0xFFFF );
13554
13555 return cOCT6100_ERR_OK;
13556 }
13557 #endif
13558
13559
13560 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13561
13562 Function: Oct6100ApiMuteSinWithFeatures
13563
13564 Description: Mute or Unmute the sin with features port.
13565
13566 -------------------------------------------------------------------------------
13567 | Argument | Description
13568 -------------------------------------------------------------------------------
13569 f_pApiInstance Pointer to API instance. This memory is used to keep
13570 the present state of the chip and all its resources.
13571
13572 f_usChanIndex Resulting channel index where the muting should
13573 be applied.
13574 f_fEnableSinWithFeatures Whether to enable the feature or not.
13575
13576 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13577 #if !SKIP_Oct6100ApiMuteSinWithFeatures
13578 UINT32 Oct6100ApiMuteSinWithFeatures(
13579 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13580 IN UINT16 f_usChanIndex,
13581 IN BOOL f_fEnableSinWithFeatures )
13582 {
13583 tPOCT6100_SHARED_INFO pSharedInfo;
13584 tPOCT6100_API_CHANNEL pChanEntry;
13585 tOCT6100_WRITE_PARAMS WriteParams;
13586 UINT32 ulResult;
13587
13588 UINT32 ulTempData;
13589 UINT32 ulBaseAddress;
13590 UINT32 ulFeatureBytesOffset;
13591 UINT32 ulFeatureBitOffset;
13592 UINT32 ulFeatureFieldLength;
13593 UINT32 ulMask;
13594
13595 /* Get local pointer(s). */
13596 pSharedInfo = f_pApiInstance->pSharedInfo;
13597
13598 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13599
13600 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
13601
13602 /* Get a pointer to the channel's list entry. */
13603 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
13604
13605 ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
13606
13607 if ( pSharedInfo->ImageInfo.fSinMute == TRUE )
13608 {
13609 ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinMuteOfst.usDwordOffset * 4;
13610 ulFeatureBitOffset = pSharedInfo->MemoryMap.SinMuteOfst.byBitOffset;
13611 ulFeatureFieldLength = pSharedInfo->MemoryMap.SinMuteOfst.byFieldSize;
13612
13613 ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
13614 pChanEntry,
13615 ulBaseAddress + ulFeatureBytesOffset,
13616 &ulTempData);
13617 if ( ulResult != cOCT6100_ERR_OK )
13618 return ulResult;
13619
13620 /* Clear previous value set in the feature field.*/
13621 mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
13622
13623 /* Clear the mute flag. */
13624 ulTempData &= (~ulMask);
13625
13626 /* Set the mute flag on the Sin port.*/
13627 if ( f_fEnableSinWithFeatures == TRUE )
13628 ulTempData |= ( 0x1 << ulFeatureBitOffset );
13629
13630 /* Write the new DWORD where the field is located. */
13631 ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
13632 pChanEntry,
13633 ulBaseAddress + ulFeatureBytesOffset,
13634 ulTempData);
13635 if ( ulResult != cOCT6100_ERR_OK )
13636 return ulResult;
13637 }
13638
13639 return cOCT6100_ERR_OK;
13640 }
13641 #endif
13642
13643
13644 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13645
13646 Function: Oct6100ApiMuteChannelPorts
13647
13648 Description: Mute or Unmute the specified ports, according to the mask.
13649
13650 -------------------------------------------------------------------------------
13651 | Argument | Description
13652 -------------------------------------------------------------------------------
13653 f_pApiInstance Pointer to API instance. This memory is used to keep
13654 the present state of the chip and all its resources.
13655
13656 f_usChanIndex Resulting channel index where the muting should
13657 be applied.
13658 f_usPortMask Port mask on which to apply the muting/unmuting.
13659
13660 \*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13661 #if !SKIP_Oct6100ApiMuteChannelPorts
13662 UINT32 Oct6100ApiMuteChannelPorts(
13663 IN tPOCT6100_INSTANCE_API f_pApiInstance,
13664 IN UINT16 f_usChanIndex,
13665 IN UINT16 f_usPortMask,
13666 IN BOOL f_fMute )
13667 {
13668 tPOCT6100_SHARED_INFO pSharedInfo;
13669 tPOCT6100_API_CHANNEL pChanEntry;
13670 tOCT6100_WRITE_PARAMS WriteParams;
13671 UINT32 ulResult;
13672 BOOL fDisableSinWithFeatures = FALSE;
13673 BOOL fEnableSinWithFeatures = FALSE;
13674
13675 /* Get local pointer(s). */
13676 pSharedInfo = f_pApiInstance->pSharedInfo;
13677
13678 WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13679
13680 WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
13681
13682 /* Get a pointer to the channel's list entry. */
13683 mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
13684
13685 /* Rin port. */
13686 if ( ( f_fMute == TRUE )
13687 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 )
13688 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) == 0x0 ) )
13689 {
13690 /* Mute this port. */
13691 pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_RIN;
13692
13693 ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13694 if ( ulResult != cOCT6100_ERR_OK )
13695 {
13696 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN;
13697 return ulResult;
13698 }
13699 }
13700 else if ( ( f_fMute == FALSE )
13701 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 )
13702 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) )
13703 {
13704 /* Unmute this port. */
13705 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN;
13706
13707 ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13708 if ( ulResult != cOCT6100_ERR_OK )
13709 return ulResult;
13710 }
13711
13712 /* Rout port. */
13713 if ( ( f_fMute == TRUE )
13714 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 )
13715 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 ) )
13716 {
13717 /* Mute this port. */
13718
13719 if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
13720 {
13721 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
13722 pChanEntry->usRoutTsstIndex,
13723 pChanEntry->CodecConfig.byAdpcmNibblePosition,
13724 pChanEntry->TdmConfig.byRoutNumTssts,
13725 1534 );
13726 if ( ulResult != cOCT6100_ERR_OK )
13727 return ulResult;
13728 }
13729
13730 pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_ROUT;
13731 }
13732 else if ( ( f_fMute == FALSE )
13733 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 )
13734 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 ) )
13735 {
13736 /* Unmute this port. */
13737
13738 if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
13739 {
13740 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
13741 pChanEntry->usRoutTsstIndex,
13742 pChanEntry->CodecConfig.byAdpcmNibblePosition,
13743 pChanEntry->TdmConfig.byRoutNumTssts,
13744 pChanEntry->usRinRoutTsiMemIndex );
13745 if ( ulResult != cOCT6100_ERR_OK )
13746 return ulResult;
13747 }
13748
13749 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_ROUT;
13750 }
13751
13752 /* Sin port. */
13753 if ( ( f_fMute == TRUE )
13754 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
13755 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) == 0x0 ) )
13756 {
13757 /* Mute this port. */
13758 pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN;
13759
13760 ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13761 if ( ulResult != cOCT6100_ERR_OK )
13762 {
13763 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN;
13764 return ulResult;
13765 }
13766 }
13767 else if (
13768 ( ( f_fMute == FALSE )
13769 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
13770 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) )
13771 ||
13772 ( ( f_fMute == TRUE )
13773 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
13774 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) )
13775 {
13776 /* Unmute this port. */
13777 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN;
13778
13779 ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
13780 if ( ulResult != cOCT6100_ERR_OK )
13781 return ulResult;
13782 }
13783
13784 /* Sout port. */
13785 if ( ( f_fMute == TRUE )
13786 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 )
13787 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 ) )
13788 {
13789 /* Mute this port. */
13790
13791 if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
13792 {
13793 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
13794 pChanEntry->usSoutTsstIndex,
13795 pChanEntry->CodecConfig.byAdpcmNibblePosition,
13796 pChanEntry->TdmConfig.bySoutNumTssts,
13797 1534 );
13798 if ( ulResult != cOCT6100_ERR_OK )
13799 return ulResult;
13800 }
13801
13802 pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SOUT;
13803 }
13804 else if ( ( f_fMute == FALSE )
13805 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 )
13806 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 ) )
13807 {
13808 /* Unmute this port. */
13809
13810 if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
13811 {
13812 ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
13813 pChanEntry->usSoutTsstIndex,
13814 pChanEntry->CodecConfig.byAdpcmNibblePosition,
13815 pChanEntry->TdmConfig.bySoutNumTssts,
13816 pChanEntry->usSinSoutTsiMemIndex );
13817 if ( ulResult != cOCT6100_ERR_OK )
13818 return ulResult;
13819 }
13820
13821 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SOUT;
13822 }
13823
13824 /* Sin with features port. */
13825 if ( ( f_fMute == TRUE )
13826 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
13827 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) == 0x0 ) )
13828 {
13829 /* Mute this port. */
13830 pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES;
13831 fEnableSinWithFeatures = TRUE;
13832 }
13833 else if (
13834 ( ( f_fMute == FALSE )
13835 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
13836 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) )
13837 ||
13838 ( ( f_fMute == TRUE )
13839 && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
13840 && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) ) )
13841 {
13842 /* Unmute this port. */
13843 pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES;
13844
13845 fDisableSinWithFeatures = TRUE;
13846 }
13847
13848 /* Check if must enable or disable SIN mute with features. */
13849 if ( fDisableSinWithFeatures == TRUE || fEnableSinWithFeatures == TRUE )
13850 {
13851 ulResult = Oct6100ApiMuteSinWithFeatures( f_pApiInstance, f_usChanIndex, fEnableSinWithFeatures );
13852 if ( ulResult != cOCT6100_ERR_OK )
13853 return ulResult;
13854 }
13855
13856 return cOCT6100_ERR_OK;
13857 }
13858 #endif