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

« back to all changes in this revision

Viewing changes to vpm450m.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2006-10-24 22:41:01 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20061024224101-464p4n2jk16n1jrh
Tags: 1:1.2.10.dfsg-2
* bristuff-0.3.0-PRE-1v
* Remove redundant GPL LICENCE text

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2
 
 
3
 
File: oct6100_adpcm_chan.c
4
 
 
5
 
    Copyright (c) 2001-2005 Octasic Inc.
6
 
    
7
 
Description: 
8
 
 
9
 
        This file contains functions used to open and close ADPCM channels.
10
 
 
11
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
12
 
free software; you can redistribute it and/or modify it under the terms of 
13
 
the GNU General Public License as published by the Free Software Foundation; 
14
 
either version 2 of the License, or (at your option) any later version.
15
 
 
16
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
17
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
18
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
19
 
for more details. 
20
 
 
21
 
You should have received a copy of the GNU General Public License 
22
 
along with the OCT6100 GPL API; if not, write to the Free Software 
23
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24
 
 
25
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
26
 
 
27
 
$Octasic_Revision: 15 $
28
 
 
29
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
30
 
 
31
 
 
32
 
/*****************************  INCLUDE FILES  *******************************/
33
 
 
34
 
#include "octdef.h"
35
 
 
36
 
#include "apilib/octapi_largmath.h"
37
 
 
38
 
#include "oct6100api/oct6100_defines.h"
39
 
#include "oct6100api/oct6100_errors.h"
40
 
#include "oct6100api/oct6100_apiud.h"
41
 
 
42
 
#include "apilib/octapi_llman.h"
43
 
 
44
 
#include "oct6100api/oct6100_tlv_inst.h"
45
 
#include "oct6100api/oct6100_chip_open_inst.h"
46
 
#include "oct6100api/oct6100_chip_stats_inst.h"
47
 
#include "oct6100api/oct6100_interrupts_inst.h"
48
 
#include "oct6100api/oct6100_channel_inst.h"
49
 
#include "oct6100api/oct6100_remote_debug_inst.h"
50
 
#include "oct6100api/oct6100_debug_inst.h"
51
 
#include "oct6100api/oct6100_api_inst.h"
52
 
#include "oct6100api/oct6100_adpcm_chan_inst.h"
53
 
 
54
 
#include "oct6100api/oct6100_interrupts_pub.h"
55
 
#include "oct6100api/oct6100_chip_open_pub.h"
56
 
#include "oct6100api/oct6100_channel_pub.h"
57
 
#include "oct6100api/oct6100_adpcm_chan_pub.h"
58
 
 
59
 
#include "oct6100_chip_open_priv.h"
60
 
#include "oct6100_miscellaneous_priv.h"
61
 
#include "oct6100_memory_priv.h"
62
 
#include "oct6100_tsst_priv.h"
63
 
#include "oct6100_channel_priv.h"
64
 
#include "oct6100_adpcm_chan_priv.h"
65
 
 
66
 
#include <linux/slab.h>
67
 
#include <linux/vmalloc.h>
68
 
#ifdef HOTPLUG_FIRMWARE
69
 
#include <linux/firmware.h>
70
 
#endif
71
 
 
72
 
/****************************  PRIVATE FUNCTIONS  ****************************/
73
 
 
74
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
75
 
 
76
 
Function:               Oct6100ApiGetAdpcmChanSwSizes
77
 
 
78
 
Description:    Gets the sizes of all portions of the API instance pertinent
79
 
                                to the management of the ADPCM memory.
80
 
 
81
 
-------------------------------------------------------------------------------
82
 
|       Argument                |       Description
83
 
-------------------------------------------------------------------------------
84
 
f_pOpenChip                             Pointer to chip configuration struct.
85
 
f_pInstSizes                    Pointer to struct containing instance sizes.
86
 
 
87
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
88
 
static UINT32 Oct6100ApiGetAdpcmChanSwSizes(
89
 
                                IN              tPOCT6100_CHIP_OPEN                             f_pOpenChip,
90
 
                                OUT             tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
91
 
{
92
 
        UINT32  ulTempVar;
93
 
        UINT32  ulResult;
94
 
        
95
 
        /* Determine the amount of memory required for the API ADPCM channel list.*/
96
 
        f_pInstSizes->ulAdpcmChannelList = f_pOpenChip->ulMaxAdpcmChannels * sizeof( tOCT6100_API_ADPCM_CHAN );
97
 
 
98
 
        if ( f_pOpenChip->ulMaxAdpcmChannels > 0 )
99
 
        {
100
 
                /* Calculate memory needed for ADPCM memory allocation */
101
 
                ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxAdpcmChannels, &f_pInstSizes->ulAdpcmChannelAlloc );
102
 
                if ( ulResult != cOCT6100_ERR_OK  )
103
 
                        return cOCT6100_ERR_FATAL_48;
104
 
        }
105
 
        else
106
 
        {
107
 
                f_pInstSizes->ulAdpcmChannelAlloc = 0;
108
 
        }
109
 
        
110
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulAdpcmChannelList, ulTempVar )
111
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulAdpcmChannelAlloc, ulTempVar )
112
 
 
113
 
        return cOCT6100_ERR_OK;
114
 
}
115
 
 
116
 
 
117
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
118
 
 
119
 
Function:               Oct6100ApiAdpcmChanSwInit
120
 
 
121
 
Description:    Initializes all elements of the instance structure associated
122
 
                                to the ADPCM memory.
123
 
 
124
 
-------------------------------------------------------------------------------
125
 
|       Argument                |       Description
126
 
-------------------------------------------------------------------------------
127
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
128
 
                                                the present state of the chip and all its resources.
129
 
 
130
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
131
 
static UINT32 Oct6100ApiAdpcmChanSwInit(
132
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance )
133
 
{
134
 
        tPOCT6100_API_ADPCM_CHAN        pChannelsTsiList;
135
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
136
 
        UINT32  ulMaxAdpcmChannels;
137
 
        PVOID   pAdpcmChannelsAlloc;
138
 
        UINT32  ulResult;
139
 
 
140
 
        /* Get local pointer to shared portion of instance. */
141
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
142
 
 
143
 
        /* Initialize the ADPCM channel API list.*/
144
 
        ulMaxAdpcmChannels = pSharedInfo->ChipConfig.usMaxAdpcmChannels;
145
 
 
146
 
        /* Set all entries in the ADPCM channel list to unused. */
147
 
        mOCT6100_GET_ADPCM_CHAN_LIST_PNT( pSharedInfo, pChannelsTsiList )
148
 
 
149
 
        /* Clear the memory */
150
 
        Oct6100UserMemSet( pChannelsTsiList, 0x00, sizeof(tOCT6100_API_ADPCM_CHAN) * ulMaxAdpcmChannels );
151
 
 
152
 
        /* Initialize the ADPCM channel allocation structures to "all free". */
153
 
        if ( ulMaxAdpcmChannels > 0 )
154
 
        {
155
 
                mOCT6100_GET_ADPCM_CHAN_ALLOC_PNT( pSharedInfo, pAdpcmChannelsAlloc )
156
 
                
157
 
                ulResult = OctapiLlmAllocInit( &pAdpcmChannelsAlloc, ulMaxAdpcmChannels );
158
 
                if ( ulResult != cOCT6100_ERR_OK  )
159
 
                        return cOCT6100_ERR_FATAL_BD;
160
 
        }
161
 
        
162
 
        return cOCT6100_ERR_OK;
163
 
}
164
 
 
165
 
 
166
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
167
 
 
168
 
File: oct6100_channel.c
169
 
 
170
 
    Copyright (c) 2001-2005 Octasic Inc.
171
 
    
172
 
Description: 
173
 
 
174
 
        This file contains functions used to open, modify and close echo 
175
 
        cancellation channels.
176
 
 
177
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
178
 
free software; you can redistribute it and/or modify it under the terms of 
179
 
the GNU General Public License as published by the Free Software Foundation; 
180
 
either version 2 of the License, or (at your option) any later version.
181
 
 
182
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
183
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
184
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
185
 
for more details. 
186
 
 
187
 
You should have received a copy of the GNU General Public License 
188
 
along with the OCT6100 GPL API; if not, write to the Free Software 
189
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
190
 
 
191
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
192
 
 
193
 
$Octasic_Revision: 449 $
194
 
 
195
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
196
 
 
197
 
 
198
 
/*****************************  INCLUDE FILES  *******************************/
199
 
 
200
 
#include "octdef.h"
201
 
 
202
 
#include "oct6100api/oct6100_defines.h"
203
 
#include "oct6100api/oct6100_errors.h"
204
 
#include "oct6100api/oct6100_apiud.h"
205
 
 
206
 
#include "apilib/octapi_llman.h"
207
 
 
208
 
#include "oct6100api/oct6100_tlv_inst.h"
209
 
#include "oct6100api/oct6100_chip_open_inst.h"
210
 
#include "oct6100api/oct6100_chip_stats_inst.h"
211
 
#include "oct6100api/oct6100_interrupts_inst.h"
212
 
#include "oct6100api/oct6100_remote_debug_inst.h"
213
 
#include "oct6100api/oct6100_debug_inst.h"
214
 
#include "oct6100api/oct6100_api_inst.h"
215
 
#include "oct6100api/oct6100_mixer_inst.h"
216
 
#include "oct6100api/oct6100_tsi_cnct_inst.h"
217
 
#include "oct6100api/oct6100_conf_bridge_inst.h"
218
 
#include "oct6100api/oct6100_tone_detection_inst.h"
219
 
#include "oct6100api/oct6100_phasing_tsst_inst.h"
220
 
#include "oct6100api/oct6100_tsst_inst.h"
221
 
#include "oct6100api/oct6100_channel_inst.h"
222
 
 
223
 
#include "oct6100api/oct6100_interrupts_pub.h"
224
 
#include "oct6100api/oct6100_chip_open_pub.h"
225
 
#include "oct6100api/oct6100_tsi_cnct_pub.h"
226
 
#include "oct6100api/oct6100_playout_buf_pub.h"
227
 
#include "oct6100api/oct6100_phasing_tsst_pub.h"
228
 
#include "oct6100api/oct6100_mixer_pub.h"
229
 
#include "oct6100api/oct6100_conf_bridge_pub.h"
230
 
#include "oct6100api/oct6100_tone_detection_pub.h"
231
 
#include "oct6100api/oct6100_channel_pub.h"
232
 
 
233
 
#include "oct6100_chip_open_priv.h"
234
 
#include "oct6100_miscellaneous_priv.h"
235
 
#include "oct6100_memory_priv.h"
236
 
#include "oct6100_tsst_priv.h"
237
 
#include "oct6100_mixer_priv.h"
238
 
#include "oct6100_phasing_tsst_priv.h"
239
 
#include "oct6100_tsi_cnct_priv.h"
240
 
#include "oct6100_playout_buf_priv.h"
241
 
#include "oct6100_conf_bridge_priv.h"
242
 
#include "oct6100_tone_detection_priv.h"
243
 
#include "oct6100_channel_priv.h"
244
 
 
245
 
 
246
 
/****************************  PUBLIC FUNCTIONS  ****************************/
247
 
 
248
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
249
 
 
250
 
Function:               Oct6100ChannelOpen
251
 
 
252
 
Description:    This function opens a echo cancellation channel. An echo cancellation
253
 
                                channel is constituted of two voice stream (RIN/ROUT and SIN/SOUT), and
254
 
                                an echo cancelling core.
255
 
 
256
 
-------------------------------------------------------------------------------
257
 
|       Argument                |       Description
258
 
-------------------------------------------------------------------------------
259
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
260
 
                                                present state of the chip and all its resources.
261
 
 
262
 
f_pChannelOpen                  Pointer to echo channel open structure.
263
 
 
264
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
265
 
static UINT32 Oct6100ChannelOpenDef(
266
 
                                IN OUT tPOCT6100_CHANNEL_OPEN                   f_pChannelOpen )
267
 
{
268
 
        f_pChannelOpen->pulChannelHndl                  = NULL;
269
 
        f_pChannelOpen->ulUserChanId                    = cOCT6100_INVALID_VALUE;
270
 
        f_pChannelOpen->ulEchoOperationMode             = cOCT6100_ECHO_OP_MODE_POWER_DOWN;
271
 
        f_pChannelOpen->fEnableToneDisabler             = FALSE;
272
 
        f_pChannelOpen->fEnableExtToneDetection         = FALSE;
273
 
 
274
 
        /* VQE configuration.*/
275
 
        f_pChannelOpen->VqeConfig.fSinDcOffsetRemoval = TRUE;
276
 
        f_pChannelOpen->VqeConfig.fRinDcOffsetRemoval = TRUE;
277
 
        f_pChannelOpen->VqeConfig.fRinLevelControl      = FALSE;
278
 
        f_pChannelOpen->VqeConfig.lRinLevelControlGainDb = 0;
279
 
        f_pChannelOpen->VqeConfig.fSoutLevelControl = FALSE;
280
 
        f_pChannelOpen->VqeConfig.lSoutLevelControlGainDb = 0;
281
 
        f_pChannelOpen->VqeConfig.fRinAutomaticLevelControl     = FALSE;
282
 
        f_pChannelOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = -20;
283
 
        f_pChannelOpen->VqeConfig.fSoutAutomaticLevelControl = FALSE;
284
 
        f_pChannelOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = -20;
285
 
        f_pChannelOpen->VqeConfig.fRinHighLevelCompensation = FALSE;
286
 
        f_pChannelOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = -10;
287
 
        f_pChannelOpen->VqeConfig.fSoutAdaptiveNoiseReduction = FALSE;
288
 
        f_pChannelOpen->VqeConfig.fSoutNoiseBleaching = FALSE;
289
 
        f_pChannelOpen->VqeConfig.fSoutConferencingNoiseReduction = FALSE;
290
 
        f_pChannelOpen->VqeConfig.ulComfortNoiseMode = cOCT6100_COMFORT_NOISE_NORMAL;
291
 
        f_pChannelOpen->VqeConfig.fEnableNlp = TRUE;
292
 
        f_pChannelOpen->VqeConfig.fEnableTailDisplacement = FALSE;
293
 
        f_pChannelOpen->VqeConfig.ulTailDisplacement = cOCT6100_AUTO_SELECT_TAIL;
294
 
        f_pChannelOpen->VqeConfig.ulTailLength = cOCT6100_AUTO_SELECT_TAIL;
295
 
 
296
 
        f_pChannelOpen->VqeConfig.fDtmfToneRemoval = FALSE;
297
 
 
298
 
        f_pChannelOpen->VqeConfig.fAcousticEcho = FALSE;
299
 
        f_pChannelOpen->VqeConfig.lDefaultErlDb = -6;
300
 
        f_pChannelOpen->VqeConfig.ulAecTailLength = 128;
301
 
        f_pChannelOpen->VqeConfig.lAecDefaultErlDb = 0;
302
 
        f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorA = 1;
303
 
        f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorB = 0;  
304
 
        f_pChannelOpen->VqeConfig.ulDoubleTalkBehavior = cOCT6100_DOUBLE_TALK_BEH_NORMAL;
305
 
        f_pChannelOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = 0;
306
 
        f_pChannelOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = 0;
307
 
        f_pChannelOpen->VqeConfig.fSoutNaturalListenerEnhancement = FALSE;
308
 
        f_pChannelOpen->VqeConfig.fRoutNoiseReduction = FALSE;
309
 
        f_pChannelOpen->VqeConfig.lAnrSnrEnhancementDb = -18;
310
 
        f_pChannelOpen->VqeConfig.ulAnrVoiceNoiseSegregation = 6;
311
 
        f_pChannelOpen->VqeConfig.ulToneDisablerVqeActivationDelay = 300;
312
 
        f_pChannelOpen->VqeConfig.fEnableMusicProtection = FALSE;
313
 
        /* Older images have idle code detection hard-coded to enabled. */
314
 
        f_pChannelOpen->VqeConfig.fIdleCodeDetection = TRUE;
315
 
 
316
 
        /* TDM configuration.*/
317
 
        f_pChannelOpen->TdmConfig.ulRinNumTssts = 1;
318
 
        f_pChannelOpen->TdmConfig.ulSinNumTssts = 1;
319
 
        f_pChannelOpen->TdmConfig.ulRoutNumTssts = 1;
320
 
        f_pChannelOpen->TdmConfig.ulSoutNumTssts = 1;
321
 
 
322
 
        f_pChannelOpen->TdmConfig.ulRinTimeslot = cOCT6100_UNASSIGNED;
323
 
        f_pChannelOpen->TdmConfig.ulRinStream = cOCT6100_UNASSIGNED;
324
 
        f_pChannelOpen->TdmConfig.ulRinPcmLaw = cOCT6100_PCM_U_LAW;
325
 
 
326
 
        f_pChannelOpen->TdmConfig.ulSinTimeslot = cOCT6100_UNASSIGNED;
327
 
        f_pChannelOpen->TdmConfig.ulSinStream = cOCT6100_UNASSIGNED;
328
 
        f_pChannelOpen->TdmConfig.ulSinPcmLaw = cOCT6100_PCM_U_LAW;
329
 
 
330
 
        f_pChannelOpen->TdmConfig.ulRoutTimeslot = cOCT6100_UNASSIGNED;
331
 
        f_pChannelOpen->TdmConfig.ulRoutStream = cOCT6100_UNASSIGNED;
332
 
        f_pChannelOpen->TdmConfig.ulRoutPcmLaw = cOCT6100_PCM_U_LAW;
333
 
 
334
 
        f_pChannelOpen->TdmConfig.ulSoutTimeslot = cOCT6100_UNASSIGNED;
335
 
        f_pChannelOpen->TdmConfig.ulSoutStream = cOCT6100_UNASSIGNED;
336
 
        f_pChannelOpen->TdmConfig.ulSoutPcmLaw = cOCT6100_PCM_U_LAW;
337
 
 
338
 
        /* CODEC configuration.*/
339
 
        f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition = cOCT6100_ADPCM_IN_LOW_BITS;
340
 
 
341
 
        f_pChannelOpen->CodecConfig.ulEncoderPort = cOCT6100_CHANNEL_PORT_SOUT;
342
 
        f_pChannelOpen->CodecConfig.ulEncodingRate = cOCT6100_G711_64KBPS;
343
 
        f_pChannelOpen->CodecConfig.ulDecoderPort = cOCT6100_CHANNEL_PORT_RIN;
344
 
        f_pChannelOpen->CodecConfig.ulDecodingRate = cOCT6100_G711_64KBPS;
345
 
 
346
 
        f_pChannelOpen->CodecConfig.fEnableSilenceSuppression = FALSE;
347
 
        f_pChannelOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
348
 
        f_pChannelOpen->CodecConfig.ulPhase = 0;
349
 
        f_pChannelOpen->CodecConfig.ulPhasingType = cOCT6100_NO_PHASING;
350
 
 
351
 
 
352
 
        return cOCT6100_ERR_OK;
353
 
}
354
 
 
355
 
static UINT32 Oct6100ChannelOpen(
356
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
357
 
                                IN OUT tPOCT6100_CHANNEL_OPEN                   f_pChannelOpen )
358
 
{
359
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
360
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
361
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
362
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
363
 
 
364
 
        /* Set the process context of the serialize structure.*/
365
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
366
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
367
 
 
368
 
        /* Seize all list semaphores needed by this function. */
369
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
370
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
371
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
372
 
        if ( ulSerRes == cOCT6100_ERR_OK )
373
 
        {
374
 
                /* Call the serialized function. */
375
 
                ulFncRes = Oct6100ChannelOpenSer( f_pApiInstance, f_pChannelOpen );
376
 
        }
377
 
        else
378
 
        {
379
 
                return ulSerRes;
380
 
        }
381
 
 
382
 
        /* Release the seized semaphores. */
383
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
384
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
385
 
 
386
 
        /* If an error occured then return the error code. */
387
 
        if ( ulSerRes != cOCT6100_ERR_OK )
388
 
                return ulSerRes;
389
 
        if ( ulFncRes != cOCT6100_ERR_OK )
390
 
                return ulFncRes;
391
 
 
392
 
        return cOCT6100_ERR_OK;
393
 
}
394
 
 
395
 
 
396
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
397
 
 
398
 
Function:               Oct6100ChannelModify
399
 
 
400
 
Description:    This function will modify the parameter of an echo channel. If 
401
 
                                the call to this channel allows the channel to go from power down
402
 
                                to enable, the API will activate it.
403
 
 
404
 
-------------------------------------------------------------------------------
405
 
|       Argument                |       Description
406
 
-------------------------------------------------------------------------------
407
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
408
 
                                                        present state of the chip and all its resources.
409
 
 
410
 
f_pChannelModify                        Pointer to echo channel change structure.
411
 
 
412
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
413
 
static UINT32 Oct6100ChannelModifyDef(
414
 
                                IN OUT tPOCT6100_CHANNEL_MODIFY                 f_pChannelModify )
415
 
{
416
 
        f_pChannelModify->ulChannelHndl = cOCT6100_INVALID_HANDLE;
417
 
        f_pChannelModify->ulUserChanId = cOCT6100_KEEP_PREVIOUS_SETTING;
418
 
        f_pChannelModify->ulEchoOperationMode = cOCT6100_KEEP_PREVIOUS_SETTING;
419
 
        
420
 
        f_pChannelModify->fEnableToneDisabler = cOCT6100_KEEP_PREVIOUS_SETTING;
421
 
 
422
 
        f_pChannelModify->fApplyToAllChannels = FALSE;
423
 
 
424
 
        f_pChannelModify->fDisableToneDetection = FALSE;
425
 
        f_pChannelModify->fStopBufferPlayout = FALSE;
426
 
        f_pChannelModify->fRemoveConfBridgeParticipant = FALSE;
427
 
        f_pChannelModify->fRemoveBroadcastTssts = FALSE;
428
 
 
429
 
        f_pChannelModify->fTdmConfigModified = FALSE;
430
 
        f_pChannelModify->fVqeConfigModified = FALSE;
431
 
        f_pChannelModify->fCodecConfigModified = FALSE;
432
 
 
433
 
        /* VQE config. */
434
 
        f_pChannelModify->VqeConfig.fSinDcOffsetRemoval = cOCT6100_KEEP_PREVIOUS_SETTING;
435
 
        f_pChannelModify->VqeConfig.fRinDcOffsetRemoval = cOCT6100_KEEP_PREVIOUS_SETTING;
436
 
        f_pChannelModify->VqeConfig.fRinLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
437
 
        f_pChannelModify->VqeConfig.lRinLevelControlGainDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
438
 
        f_pChannelModify->VqeConfig.fSoutLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
439
 
        f_pChannelModify->VqeConfig.lSoutLevelControlGainDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
440
 
        f_pChannelModify->VqeConfig.fRinAutomaticLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
441
 
        f_pChannelModify->VqeConfig.lRinAutomaticLevelControlTargetDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
442
 
        f_pChannelModify->VqeConfig.fSoutAutomaticLevelControl = cOCT6100_KEEP_PREVIOUS_SETTING;
443
 
        f_pChannelModify->VqeConfig.lSoutAutomaticLevelControlTargetDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
444
 
        f_pChannelModify->VqeConfig.fRinHighLevelCompensation = cOCT6100_KEEP_PREVIOUS_SETTING;
445
 
        f_pChannelModify->VqeConfig.lRinHighLevelCompensationThresholdDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
446
 
        f_pChannelModify->VqeConfig.fSoutAdaptiveNoiseReduction = cOCT6100_KEEP_PREVIOUS_SETTING;
447
 
        f_pChannelModify->VqeConfig.fSoutNoiseBleaching = cOCT6100_KEEP_PREVIOUS_SETTING;
448
 
        f_pChannelModify->VqeConfig.fSoutConferencingNoiseReduction     = cOCT6100_KEEP_PREVIOUS_SETTING;
449
 
        f_pChannelModify->VqeConfig.ulComfortNoiseMode = cOCT6100_KEEP_PREVIOUS_SETTING;
450
 
        f_pChannelModify->VqeConfig.fEnableNlp = cOCT6100_KEEP_PREVIOUS_SETTING;
451
 
        f_pChannelModify->VqeConfig.fEnableTailDisplacement = cOCT6100_KEEP_PREVIOUS_SETTING;
452
 
        f_pChannelModify->VqeConfig.ulTailDisplacement = cOCT6100_KEEP_PREVIOUS_SETTING;
453
 
 
454
 
        f_pChannelModify->VqeConfig.fDtmfToneRemoval = cOCT6100_KEEP_PREVIOUS_SETTING;
455
 
 
456
 
        f_pChannelModify->VqeConfig.fAcousticEcho = cOCT6100_KEEP_PREVIOUS_SETTING;
457
 
        f_pChannelModify->VqeConfig.lDefaultErlDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING; 
458
 
        f_pChannelModify->VqeConfig.ulAecTailLength = cOCT6100_KEEP_PREVIOUS_SETTING;
459
 
        f_pChannelModify->VqeConfig.lAecDefaultErlDb = (INT32)cOCT6100_KEEP_PREVIOUS_SETTING;
460
 
        f_pChannelModify->VqeConfig.ulNonLinearityBehaviorA = cOCT6100_KEEP_PREVIOUS_SETTING;
461
 
        f_pChannelModify->VqeConfig.ulNonLinearityBehaviorB = cOCT6100_KEEP_PREVIOUS_SETTING;
462
 
        f_pChannelModify->VqeConfig.ulDoubleTalkBehavior = cOCT6100_KEEP_PREVIOUS_SETTING;
463
 
        f_pChannelModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = cOCT6100_KEEP_PREVIOUS_SETTING;
464
 
        f_pChannelModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = cOCT6100_KEEP_PREVIOUS_SETTING;
465
 
        f_pChannelModify->VqeConfig.fSoutNaturalListenerEnhancement = cOCT6100_KEEP_PREVIOUS_SETTING;
466
 
        f_pChannelModify->VqeConfig.fRoutNoiseReduction = cOCT6100_KEEP_PREVIOUS_SETTING;
467
 
        f_pChannelModify->VqeConfig.lAnrSnrEnhancementDb = cOCT6100_KEEP_PREVIOUS_SETTING;
468
 
        f_pChannelModify->VqeConfig.ulAnrVoiceNoiseSegregation = cOCT6100_KEEP_PREVIOUS_SETTING;
469
 
        f_pChannelModify->VqeConfig.ulToneDisablerVqeActivationDelay = cOCT6100_KEEP_PREVIOUS_SETTING;
470
 
        f_pChannelModify->VqeConfig.fEnableMusicProtection = cOCT6100_KEEP_PREVIOUS_SETTING;
471
 
        f_pChannelModify->VqeConfig.fIdleCodeDetection = cOCT6100_KEEP_PREVIOUS_SETTING;
472
 
 
473
 
        /* TDM config. */
474
 
        f_pChannelModify->TdmConfig.ulRinNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
475
 
        f_pChannelModify->TdmConfig.ulSinNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
476
 
        f_pChannelModify->TdmConfig.ulRoutNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
477
 
        f_pChannelModify->TdmConfig.ulSoutNumTssts = cOCT6100_KEEP_PREVIOUS_SETTING;
478
 
 
479
 
        f_pChannelModify->TdmConfig.ulRinTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
480
 
        f_pChannelModify->TdmConfig.ulRinStream = cOCT6100_KEEP_PREVIOUS_SETTING;
481
 
        f_pChannelModify->TdmConfig.ulRinPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
482
 
 
483
 
        f_pChannelModify->TdmConfig.ulSinTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
484
 
        f_pChannelModify->TdmConfig.ulSinStream = cOCT6100_KEEP_PREVIOUS_SETTING;
485
 
        f_pChannelModify->TdmConfig.ulSinPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
486
 
 
487
 
        f_pChannelModify->TdmConfig.ulRoutTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
488
 
        f_pChannelModify->TdmConfig.ulRoutStream = cOCT6100_KEEP_PREVIOUS_SETTING;
489
 
        f_pChannelModify->TdmConfig.ulRoutPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
490
 
 
491
 
        f_pChannelModify->TdmConfig.ulSoutTimeslot = cOCT6100_KEEP_PREVIOUS_SETTING;
492
 
        f_pChannelModify->TdmConfig.ulSoutStream = cOCT6100_KEEP_PREVIOUS_SETTING;
493
 
        f_pChannelModify->TdmConfig.ulSoutPcmLaw = cOCT6100_KEEP_PREVIOUS_SETTING;
494
 
 
495
 
        /* CODEC config. */
496
 
        f_pChannelModify->CodecConfig.ulEncoderPort = cOCT6100_KEEP_PREVIOUS_SETTING;
497
 
        f_pChannelModify->CodecConfig.ulEncodingRate = cOCT6100_KEEP_PREVIOUS_SETTING;
498
 
        f_pChannelModify->CodecConfig.ulDecoderPort = cOCT6100_KEEP_PREVIOUS_SETTING;
499
 
        f_pChannelModify->CodecConfig.ulDecodingRate = cOCT6100_KEEP_PREVIOUS_SETTING;
500
 
 
501
 
        f_pChannelModify->CodecConfig.fEnableSilenceSuppression = cOCT6100_KEEP_PREVIOUS_SETTING;
502
 
        f_pChannelModify->CodecConfig.ulPhasingTsstHndl = cOCT6100_KEEP_PREVIOUS_SETTING;
503
 
        f_pChannelModify->CodecConfig.ulPhase = cOCT6100_KEEP_PREVIOUS_SETTING;
504
 
        f_pChannelModify->CodecConfig.ulPhasingType = cOCT6100_KEEP_PREVIOUS_SETTING;
505
 
 
506
 
 
507
 
        return cOCT6100_ERR_OK;
508
 
}
509
 
 
510
 
static UINT32 Oct6100ChannelModify(
511
 
                                IN tPOCT6100_INSTANCE_API               f_pApiInstance,
512
 
                                IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify )
513
 
{
514
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
515
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
516
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
517
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
518
 
 
519
 
        /* Set the process context of the serialize structure.*/
520
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
521
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
522
 
 
523
 
        /* Seize all list semaphores needed by this function. */
524
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
525
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
526
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
527
 
        if ( ulSerRes == cOCT6100_ERR_OK )
528
 
        {
529
 
                /* Check the apply to all channels flag first. */
530
 
                if ( f_pChannelModify->fApplyToAllChannels != TRUE &&
531
 
                        f_pChannelModify->fApplyToAllChannels != FALSE )
532
 
                        return cOCT6100_ERR_CHANNEL_APPLY_TO_ALL_CHANNELS;
533
 
 
534
 
                /* Check if must apply modification to all channels. */
535
 
                if ( f_pChannelModify->fApplyToAllChannels == TRUE )
536
 
                {
537
 
                        tPOCT6100_API_CHANNEL   pChanEntry;
538
 
                        UINT16                                  usChanIndex;
539
 
 
540
 
                        /* Loop through all channels and look for the opened ones. */
541
 
                        for ( usChanIndex = 0; usChanIndex < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; usChanIndex++ )
542
 
                        {
543
 
                                mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, usChanIndex );
544
 
 
545
 
                                /* Check if this one is opened. */
546
 
                                if ( pChanEntry->fReserved == TRUE )
547
 
                                {
548
 
                                        /* Channel is opened.  Form handle and call actual modify function. */
549
 
                                        f_pChannelModify->ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | usChanIndex;
550
 
 
551
 
                                        /* Call the serialized function. */
552
 
                                        ulFncRes = Oct6100ChannelModifySer( f_pApiInstance, f_pChannelModify );
553
 
                                        if ( ulFncRes != cOCT6100_ERR_OK )
554
 
                                                break;
555
 
                                }
556
 
                        }
557
 
                }
558
 
                else /* if ( f_pChannelModify->fApplyToAllChannels == FALSE ) */
559
 
                {
560
 
                        /* Call the serialized function. */
561
 
                        ulFncRes = Oct6100ChannelModifySer( f_pApiInstance, f_pChannelModify );
562
 
                }
563
 
        }
564
 
        else
565
 
        {
566
 
                return ulSerRes;
567
 
        }
568
 
 
569
 
        /* Release the seized semaphores. */
570
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
571
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
572
 
 
573
 
        /* If an error occured then return the error code. */
574
 
        if ( ulSerRes != cOCT6100_ERR_OK )
575
 
                return ulSerRes;
576
 
        if ( ulFncRes != cOCT6100_ERR_OK )
577
 
                return ulFncRes;
578
 
 
579
 
        return cOCT6100_ERR_OK;
580
 
}
581
 
 
582
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
583
 
 
584
 
Function:               Oct6100ChannelBroadcastTsstRemove
585
 
 
586
 
Description:    This function removes a TSST from one of the two output ports of a channel.
587
 
 
588
 
-------------------------------------------------------------------------------
589
 
|       Argument                |       Description
590
 
-------------------------------------------------------------------------------
591
 
f_pApiInstance                                  Pointer to API instance. This memory is used to keep
592
 
                                                                the present state of the chip and all its resources.
593
 
 
594
 
f_pChannelBroadcastTsstRemove   Pointer to the a Remove Broadcast TSST structure.
595
 
 
596
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
597
 
static UINT32 Oct6100ChannelBroadcastTsstRemoveDef(
598
 
                        tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE         f_pChannelBroadcastTsstRemove )
599
 
{
600
 
        f_pChannelBroadcastTsstRemove->ulChannelHndl = cOCT6100_INVALID_HANDLE;
601
 
 
602
 
        f_pChannelBroadcastTsstRemove->ulPort = cOCT6100_INVALID_PORT;
603
 
        f_pChannelBroadcastTsstRemove->ulTimeslot = cOCT6100_INVALID_TIMESLOT;
604
 
        f_pChannelBroadcastTsstRemove->ulStream = cOCT6100_INVALID_STREAM;
605
 
        
606
 
        f_pChannelBroadcastTsstRemove->fRemoveAll = FALSE;
607
 
 
608
 
        return cOCT6100_ERR_OK;
609
 
}
610
 
 
611
 
#if 0 /* unused functions */
612
 
 
613
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
614
 
 
615
 
Function:               Oct6100ChannelMute
616
 
 
617
 
Description:    This function mutes some or all of the ports designated by 
618
 
                                ulChannelHndl.
619
 
 
620
 
-------------------------------------------------------------------------------
621
 
|       Argument                |       Description
622
 
-------------------------------------------------------------------------------
623
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
624
 
                                                present state of the chip and all its resources.
625
 
 
626
 
f_pChannelMute                  Pointer to a tPOCT6100_CHANNEL_MUTE structure.
627
 
 
628
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
629
 
static UINT32 Oct6100ChannelMuteDef(
630
 
                                IN OUT tPOCT6100_CHANNEL_MUTE                   f_pChannelMute )
631
 
{
632
 
        f_pChannelMute->ulChannelHndl = cOCT6100_INVALID_HANDLE;
633
 
        f_pChannelMute->ulPortMask = cOCT6100_CHANNEL_MUTE_PORT_NONE;
634
 
 
635
 
        return cOCT6100_ERR_OK;
636
 
}
637
 
 
638
 
static UINT32 Oct6100ChannelMute(
639
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
640
 
                                IN OUT tPOCT6100_CHANNEL_MUTE                   f_pChannelMute )
641
 
{
642
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
643
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
644
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
645
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
646
 
 
647
 
        /* Set the process context of the serialize structure.*/
648
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
649
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
650
 
 
651
 
        /* Seize all list semaphores needed by this function. */
652
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
653
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
654
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
655
 
        if ( ulSerRes == cOCT6100_ERR_OK )
656
 
        {
657
 
                /* Call the serialized function. */
658
 
                ulFncRes = Oct6100ChannelMuteSer( f_pApiInstance, f_pChannelMute );
659
 
        }
660
 
        else
661
 
        {
662
 
                return ulSerRes;
663
 
        }
664
 
 
665
 
        /* Release the seized semaphores. */
666
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
667
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
668
 
 
669
 
        /* If an error occured then return the error code. */
670
 
        if ( ulSerRes != cOCT6100_ERR_OK )
671
 
                return ulSerRes;
672
 
        if ( ulFncRes != cOCT6100_ERR_OK )
673
 
                return ulFncRes;
674
 
 
675
 
        return cOCT6100_ERR_OK;
676
 
}
677
 
 
678
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
679
 
 
680
 
Function:               Oct6100ChannelUnMute
681
 
 
682
 
Description:    This function unmutes some or all of the ports designated by 
683
 
                                ulChannelHndl.
684
 
 
685
 
-------------------------------------------------------------------------------
686
 
|       Argument                |       Description
687
 
-------------------------------------------------------------------------------
688
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
689
 
                                                present state of the chip and all its resources.
690
 
 
691
 
f_pChannelUnMute                Pointer to a tPOCT6100_CHANNEL_UNMUTE structure.
692
 
 
693
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
694
 
static UINT32 Oct6100ChannelUnMuteDef(
695
 
                                IN OUT tPOCT6100_CHANNEL_UNMUTE                 f_pChannelUnMute )
696
 
{
697
 
        f_pChannelUnMute->ulChannelHndl = cOCT6100_INVALID_HANDLE;
698
 
        f_pChannelUnMute->ulPortMask = cOCT6100_CHANNEL_MUTE_PORT_NONE;
699
 
 
700
 
        return cOCT6100_ERR_OK;
701
 
}
702
 
 
703
 
static UINT32 Oct6100ChannelUnMute(
704
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
705
 
                                IN OUT tPOCT6100_CHANNEL_UNMUTE                 f_pChannelUnMute )
706
 
{
707
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
708
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
709
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
710
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
711
 
 
712
 
        /* Set the process context of the serialize structure.*/
713
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
714
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
715
 
 
716
 
        /* Seize all list semaphores needed by this function. */
717
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
718
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
719
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
720
 
        if ( ulSerRes == cOCT6100_ERR_OK )
721
 
        {
722
 
                /* Call the serialized function. */
723
 
                ulFncRes = Oct6100ChannelUnMuteSer( f_pApiInstance, f_pChannelUnMute );
724
 
        }
725
 
        else
726
 
        {
727
 
                return ulSerRes;
728
 
        }
729
 
 
730
 
        /* Release the seized semaphores. */
731
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
732
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
733
 
 
734
 
        /* If an error occured then return the error code. */
735
 
        if ( ulSerRes != cOCT6100_ERR_OK )
736
 
                return ulSerRes;
737
 
        if ( ulFncRes != cOCT6100_ERR_OK )
738
 
                return ulFncRes;
739
 
 
740
 
        return cOCT6100_ERR_OK;
741
 
}
742
 
#endif
743
 
/****************************  PRIVATE FUNCTIONS  ****************************/
744
 
 
745
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
746
 
 
747
 
Function:               Oct6100ApiGetChannelsEchoSwSizes
748
 
 
749
 
Description:    Gets the sizes of all portions of the API instance pertinent
750
 
                                to the management of the ECHO memory.
751
 
 
752
 
-------------------------------------------------------------------------------
753
 
|       Argument                |       Description
754
 
-------------------------------------------------------------------------------
755
 
f_pOpenChip                             Pointer to chip configuration struct.
756
 
f_pInstSizes                    Pointer to struct containing instance sizes.
757
 
 
758
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
759
 
static UINT32 Oct6100ApiGetChannelsEchoSwSizes(
760
 
                                IN      tPOCT6100_CHIP_OPEN                             f_pOpenChip,
761
 
                                OUT     tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
762
 
{
763
 
        UINT32  ulTempVar;
764
 
        UINT32  ulResult;
765
 
        UINT32  ulMaxChannels;
766
 
 
767
 
        ulMaxChannels = f_pOpenChip->ulMaxChannels;
768
 
 
769
 
        if ( f_pOpenChip->fEnableChannelRecording == TRUE && ulMaxChannels != 672 )
770
 
                ulMaxChannels++;
771
 
 
772
 
        /* Determine the amount of memory required for the API echo channel list.*/
773
 
        f_pInstSizes->ulChannelList                     = ulMaxChannels * sizeof( tOCT6100_API_CHANNEL );       /* Add one for the record channel.*/
774
 
        f_pInstSizes->ulBiDirChannelList        = f_pOpenChip->ulMaxBiDirChannels * sizeof( tOCT6100_API_BIDIR_CHANNEL );
775
 
        if ( ulMaxChannels > 0 )
776
 
        {
777
 
                /* Calculate memory needed for ECHO memory allocation */
778
 
                ulResult = OctapiLlmAllocGetSize( ulMaxChannels, &f_pInstSizes->ulChannelAlloc );
779
 
                if ( ulResult != cOCT6100_ERR_OK  )
780
 
                        return cOCT6100_ERR_FATAL_0;
781
 
        }
782
 
        else
783
 
        {
784
 
                f_pInstSizes->ulChannelAlloc = 0;
785
 
        }
786
 
        if ( f_pOpenChip->ulMaxBiDirChannels > 0 )
787
 
        {
788
 
                /* Calculate memory needed for ECHO memory allocation */
789
 
                ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxBiDirChannels, &f_pInstSizes->ulBiDirChannelAlloc );
790
 
                if ( ulResult != cOCT6100_ERR_OK  )
791
 
                        return cOCT6100_ERR_FATAL_0;
792
 
        }
793
 
        else
794
 
        {
795
 
                f_pInstSizes->ulBiDirChannelAlloc = 0;
796
 
        }
797
 
 
798
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulChannelList, ulTempVar )
799
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulChannelAlloc, ulTempVar )
800
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulBiDirChannelList, ulTempVar )
801
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulBiDirChannelAlloc, ulTempVar )
802
 
        return cOCT6100_ERR_OK;
803
 
}
804
 
 
805
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
806
 
 
807
 
Function:               Oct6100ApiChannelsEchoSwInit
808
 
 
809
 
Description:    Initializes all elements of the instance structure associated
810
 
                                to the ECHO memory.
811
 
 
812
 
-------------------------------------------------------------------------------
813
 
|       Argument                |       Description
814
 
-------------------------------------------------------------------------------
815
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
816
 
                                                the present state of the chip and all its resources.
817
 
 
818
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
819
 
static UINT32 Oct6100ApiChannelsEchoSwInit(
820
 
                                IN tPOCT6100_INSTANCE_API                       f_pApiInstance )
821
 
{
822
 
        tPOCT6100_API_CHANNEL                   pChannelsEchoList;
823
 
        tPOCT6100_API_BIDIR_CHANNEL             pBiDirChannelsList;
824
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
825
 
        UINT16  usMaxChannels;
826
 
        PVOID   pEchoChanAlloc;
827
 
        PVOID   pBiDirChanAlloc;
828
 
        UINT32  ulResult;
829
 
 
830
 
        /* Get local pointer to shared portion of the API instance. */
831
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
832
 
 
833
 
        /* Initialize the ECHO channel API list.*/
834
 
        usMaxChannels = pSharedInfo->ChipConfig.usMaxChannels;
835
 
 
836
 
        /* add a channel to initialize if the recording is activated. */
837
 
        if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
838
 
                usMaxChannels++;
839
 
 
840
 
        /* Set all entries in the ADCPM channel list to unused. */
841
 
        mOCT6100_GET_CHANNEL_LIST_PNT( pSharedInfo, pChannelsEchoList );
842
 
        
843
 
        /* Initialize the API ECHO channels allocation software to "all free". */
844
 
        if ( usMaxChannels > 0 )
845
 
        {
846
 
                /* Clear the memory */
847
 
                Oct6100UserMemSet( pChannelsEchoList, 0x00, sizeof(tOCT6100_API_CHANNEL) * usMaxChannels );
848
 
 
849
 
                mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoChanAlloc )
850
 
                
851
 
                ulResult = OctapiLlmAllocInit( &pEchoChanAlloc, usMaxChannels );
852
 
                if ( ulResult != cOCT6100_ERR_OK  )
853
 
                        return cOCT6100_ERR_FATAL_1;
854
 
        }
855
 
 
856
 
        mOCT6100_GET_BIDIR_CHANNEL_LIST_PNT( pSharedInfo, pBiDirChannelsList ); 
857
 
 
858
 
        if ( pSharedInfo->ChipConfig.usMaxBiDirChannels > 0 )
859
 
        {
860
 
                /* Clear the memory */
861
 
                Oct6100UserMemSet( pBiDirChannelsList, 0x00, sizeof(tOCT6100_API_BIDIR_CHANNEL) * pSharedInfo->ChipConfig.usMaxBiDirChannels );
862
 
                
863
 
                mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pBiDirChanAlloc )
864
 
                
865
 
                ulResult = OctapiLlmAllocInit( &pBiDirChanAlloc, pSharedInfo->ChipConfig.usMaxBiDirChannels );
866
 
                if ( ulResult != cOCT6100_ERR_OK  )
867
 
                        return cOCT6100_ERR_FATAL_A9;
868
 
                
869
 
        }
870
 
 
871
 
        return cOCT6100_ERR_OK;
872
 
}
873
 
 
874
 
 
875
 
 
876
 
 
877
 
 
878
 
 
879
 
 
880
 
 
881
 
 
882
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
883
 
 
884
 
Function:               Oct6100ChannelOpenSer
885
 
 
886
 
Description:    Opens a echo cancellation channel.
887
 
 
888
 
-------------------------------------------------------------------------------
889
 
|       Argument                |       Description
890
 
-------------------------------------------------------------------------------
891
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
892
 
                                                present state of the chip and all its resources.
893
 
 
894
 
f_pChannelOpen                  Pointer to channel configuration structure.  Then handle
895
 
                                                identifying the buffer in all future function calls is
896
 
                                                returned in this structure.
897
 
 
898
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
899
 
static UINT32 Oct6100ChannelOpenSer(
900
 
                                IN tPOCT6100_INSTANCE_API                       f_pApiInstance,
901
 
                                IN OUT tPOCT6100_CHANNEL_OPEN           f_pChannelOpen )
902
 
{
903
 
        tOCT6100_API_ECHO_CHAN_INDEX            ChannelIndexConf;
904
 
        UINT32  ulResult;
905
 
 
906
 
        /* Check the user's configuration of the echo cancellation channel for errors. */
907
 
        ulResult = Oct6100ApiCheckChannelParams( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf );
908
 
        if ( ulResult != cOCT6100_ERR_OK  )
909
 
                return ulResult;
910
 
 
911
 
        /* Reserve all resources needed by the echo cancellation channel. */
912
 
        ulResult = Oct6100ApiReserveChannelResources( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf );
913
 
        if ( ulResult != cOCT6100_ERR_OK  )
914
 
                return ulResult;
915
 
 
916
 
        /* Write all necessary structures to activate the echo cancellation channel. */
917
 
        ulResult = Oct6100ApiWriteChannelStructs( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf );
918
 
        if ( ulResult != cOCT6100_ERR_OK  )
919
 
                return ulResult;
920
 
 
921
 
        /* Update the new echo cancellation channels's entry in the ECHO channel list. */
922
 
        ulResult = Oct6100ApiUpdateChannelEntry( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf );
923
 
        if ( ulResult != cOCT6100_ERR_OK  )
924
 
                return ulResult;
925
 
 
926
 
        return cOCT6100_ERR_OK;
927
 
}
928
 
 
929
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
930
 
 
931
 
Function:               Oct6100ApiCheckChannelParams
932
 
 
933
 
Description:    Checks the user's echo cancellation channel open configuration for errors.
934
 
 
935
 
-------------------------------------------------------------------------------
936
 
|       Argument                |       Description
937
 
-------------------------------------------------------------------------------
938
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
939
 
                                                present state of the chip and all its resources.
940
 
 
941
 
f_pChannelOpen                  Pointer to echo cancellation channel open configuration structure.
942
 
f_pChanIndexConf                Pointer to a structure used to store the multiple resources indexes.
943
 
 
944
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
945
 
static UINT32 Oct6100ApiCheckChannelParams(
946
 
                                IN tPOCT6100_INSTANCE_API                               f_pApiInstance,
947
 
                                IN tPOCT6100_CHANNEL_OPEN                               f_pChannelOpen,
948
 
                                OUT tPOCT6100_API_ECHO_CHAN_INDEX               f_pChanIndexConf )
949
 
{
950
 
        tPOCT6100_CHANNEL_OPEN_TDM              pTdmConfig;
951
 
        tPOCT6100_CHANNEL_OPEN_VQE              pVqeConfig;
952
 
        tPOCT6100_CHANNEL_OPEN_CODEC    pCodecConfig;
953
 
        UINT32  ulDecoderNumTssts;
954
 
        UINT32  ulResult;
955
 
 
956
 
        /* Dereference the configuration structure for clearer code and faster access.*/
957
 
        pTdmConfig       = &f_pChannelOpen->TdmConfig;
958
 
        pVqeConfig       = &f_pChannelOpen->VqeConfig;
959
 
        pCodecConfig = &f_pChannelOpen->CodecConfig;
960
 
 
961
 
        /* Check for errors. */
962
 
        if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels == 0 )
963
 
                return cOCT6100_ERR_CHANNEL_DISABLED;
964
 
 
965
 
        if ( f_pChannelOpen->pulChannelHndl == NULL )
966
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
967
 
 
968
 
        if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NORMAL &&
969
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_FREEZE &&
970
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET &&
971
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN &&
972
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL &&
973
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION &&
974
 
                 f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
975
 
                return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE;
976
 
 
977
 
        /* Check the 2100Hz echo disabling configuration.*/
978
 
        if ( f_pChannelOpen->fEnableToneDisabler != TRUE && 
979
 
                 f_pChannelOpen->fEnableToneDisabler != FALSE  )
980
 
                return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ENABLE;
981
 
        
982
 
        /* Check the extended Tone Detection flag value.*/
983
 
        if ( f_pChannelOpen->fEnableExtToneDetection != TRUE &&
984
 
                 f_pChannelOpen->fEnableExtToneDetection != FALSE )
985
 
                return cOCT6100_ERR_CHANNEL_ENABLE_EXT_TONE_DETECTION;
986
 
 
987
 
        /* Check that extented tone detection is actually enabled by the user. */
988
 
        if ( ( f_pChannelOpen->fEnableExtToneDetection == TRUE ) &&
989
 
                ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableExtToneDetection == FALSE ) )
990
 
                return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DISABLED;
991
 
 
992
 
 
993
 
 
994
 
        /*==============================================================================*/
995
 
        /* Check the TDM configuration parameters.*/
996
 
 
997
 
        ulResult = Oct6100ApiCheckTdmConfig( f_pApiInstance, pTdmConfig );
998
 
        if ( ulResult != cOCT6100_ERR_OK )
999
 
                return ulResult;
1000
 
 
1001
 
        /*==============================================================================*/
1002
 
 
1003
 
 
1004
 
        /*==============================================================================*/
1005
 
        /* Now validate the VQE parameters */
1006
 
 
1007
 
        ulResult = Oct6100ApiCheckVqeConfig( f_pApiInstance, pVqeConfig, f_pChannelOpen->fEnableToneDisabler );
1008
 
        if ( ulResult != cOCT6100_ERR_OK )
1009
 
                return ulResult;
1010
 
 
1011
 
        /* Verify if the echo operation mode selected can be applied. */
1012
 
        if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
1013
 
                && ( pVqeConfig->fEnableNlp == FALSE ) )
1014
 
                return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
1015
 
 
1016
 
        /*==============================================================================*/
1017
 
 
1018
 
        /*==============================================================================*/
1019
 
        /* Finally, validate the CODEC configuration.*/
1020
 
 
1021
 
        if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1022
 
                ulDecoderNumTssts = pTdmConfig->ulRinNumTssts;
1023
 
        else /* pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
1024
 
                ulDecoderNumTssts  = pTdmConfig->ulSinNumTssts;
1025
 
        
1026
 
        ulResult = Oct6100ApiCheckCodecConfig( f_pApiInstance, pCodecConfig, ulDecoderNumTssts, &f_pChanIndexConf->usPhasingTsstIndex );
1027
 
        if ( ulResult != cOCT6100_ERR_OK )
1028
 
                return ulResult;
1029
 
 
1030
 
 
1031
 
 
1032
 
        /* make sure that if silence suppression is activated, the NLP is enabled.*/
1033
 
        if ( pCodecConfig->fEnableSilenceSuppression == TRUE && pVqeConfig->fEnableNlp == FALSE )
1034
 
                return cOCT6100_ERR_CHANNEL_SIL_SUP_NLP_MUST_BE_ENABLED;
1035
 
        
1036
 
        /* Verify if law conversion is allowed. */
1037
 
        if ( pCodecConfig->ulEncoderPort == cOCT6100_NO_ENCODING ||
1038
 
                 pCodecConfig->ulDecoderPort == cOCT6100_NO_DECODING )
1039
 
        {
1040
 
                /* No law conversion can occurs if one ADPCM memory is not reserved.*/
1041
 
                if ( pTdmConfig->ulRinPcmLaw != pTdmConfig->ulRoutPcmLaw )
1042
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_LAW_TRANSLATION;
1043
 
 
1044
 
                if ( pTdmConfig->ulSinPcmLaw != pTdmConfig->ulSoutPcmLaw )
1045
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_LAW_TRANSLATION;
1046
 
        }
1047
 
 
1048
 
        /* Verify if the config supports extended tone detection.*/
1049
 
        if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
1050
 
        {
1051
 
                if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1052
 
                        return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT;
1053
 
        }
1054
 
        /*==============================================================================*/
1055
 
 
1056
 
        return cOCT6100_ERR_OK;
1057
 
}
1058
 
 
1059
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1060
 
 
1061
 
Function:               Oct6100ApiReserveChannelResources
1062
 
 
1063
 
Description:    Reserves all resources needed for the new channel.
1064
 
 
1065
 
-------------------------------------------------------------------------------
1066
 
|       Argument                |       Description
1067
 
-------------------------------------------------------------------------------
1068
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
1069
 
                                                present state of the chip and all its resources.
1070
 
        
1071
 
f_pChannelOpen                  Pointer to echo cancellation channel configuration structure.
1072
 
f_pulChannelIndex               Allocated entry in ECHO channel list.
1073
 
f_pChanIndexConf                Pointer to a structure used to store the multiple resources indexes.
1074
 
 
1075
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1076
 
static UINT32 Oct6100ApiReserveChannelResources(        
1077
 
                                IN  tPOCT6100_INSTANCE_API                              f_pApiInstance,
1078
 
                                IN  tPOCT6100_CHANNEL_OPEN                              f_pChannelOpen,
1079
 
                                OUT tPOCT6100_API_ECHO_CHAN_INDEX               f_pChanIndexConf )
1080
 
{
1081
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
1082
 
        tPOCT6100_CHANNEL_OPEN_TDM              pTdmConfig;
1083
 
        tPOCT6100_CHANNEL_OPEN_CODEC    pCodecConfig;
1084
 
 
1085
 
        UINT32  ulResult;
1086
 
        UINT32  ulTempVar;
1087
 
        UINT32  ulFreeMixerEventCnt;
1088
 
 
1089
 
        BOOL    fRinTsstEntry = FALSE;
1090
 
        BOOL    fSinTsstEntry = FALSE;
1091
 
        BOOL    fRoutTsstEntry = FALSE;
1092
 
        BOOL    fSoutTsstEntry = FALSE;
1093
 
 
1094
 
        BOOL    fRinRoutTsiMemEntry = FALSE;
1095
 
        BOOL    fSinSoutTsiMemEntry = FALSE;
1096
 
 
1097
 
        BOOL    fEchoChanEntry = FALSE;
1098
 
 
1099
 
        PUINT16 pusRinRoutConversionMemIndex = NULL;
1100
 
        PUINT16 pusSinSoutConversionMemIndex = NULL;
1101
 
        BOOL    fRinRoutConversionMemEntry = FALSE;
1102
 
        BOOL    fSinSoutConversionMemEntry = FALSE;
1103
 
 
1104
 
        BOOL    fExtToneChanEntry       = FALSE;
1105
 
        BOOL    fExtToneTsiEntry        = FALSE;
1106
 
        BOOL    fExtToneMixerEntry      = FALSE;
1107
 
        
1108
 
        /* Obtain local pointer to shared portion of instance. */
1109
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
1110
 
 
1111
 
        /* Obtain a local pointer to the configuration structures.*/
1112
 
        pTdmConfig              = &f_pChannelOpen->TdmConfig;
1113
 
        pCodecConfig    = &f_pChannelOpen->CodecConfig;
1114
 
 
1115
 
        /*===============================================================================*/
1116
 
        /* Reserve Echo and TSI entries. */
1117
 
 
1118
 
        ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, 
1119
 
                                                                                   &f_pChanIndexConf->usEchoChanIndex );
1120
 
        if ( ulResult == cOCT6100_ERR_OK )
1121
 
        {
1122
 
                fEchoChanEntry = TRUE;
1123
 
 
1124
 
                /* Set the echo, encoder and decoder memory indexes.*/
1125
 
                f_pChanIndexConf->usEchoMemIndex = f_pChanIndexConf->usEchoChanIndex;
1126
 
                
1127
 
                /* Reserve an entry for the RIN/ROUT tsi chariot memory. */
1128
 
                ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, 
1129
 
                                                                                                 &f_pChanIndexConf->usRinRoutTsiMemIndex );
1130
 
                if ( ulResult == cOCT6100_ERR_OK )
1131
 
                {
1132
 
                        fRinRoutTsiMemEntry = TRUE;
1133
 
 
1134
 
                        /* Reserve an entry for the SIN/SOUT tsi chariot memory. */
1135
 
                        ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, 
1136
 
                                                                                                         &f_pChanIndexConf->usSinSoutTsiMemIndex );
1137
 
                        if ( ulResult == cOCT6100_ERR_OK )
1138
 
                        {
1139
 
                                fSinSoutTsiMemEntry = TRUE;
1140
 
 
1141
 
                                /* Reserve an ADPCM memory block for compression if required.*/
1142
 
                                if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
1143
 
                                {
1144
 
                                        pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex;
1145
 
                                }
1146
 
                                else if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT )
1147
 
                                {
1148
 
                                        pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex;
1149
 
                                }
1150
 
 
1151
 
                                /* Reserve an ADPCM memory block for decompression if required.*/
1152
 
                                if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1153
 
                                {
1154
 
                                        pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex;
1155
 
                                }
1156
 
                                else if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN )
1157
 
                                {
1158
 
                                        pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex;
1159
 
                                }
1160
 
 
1161
 
 
1162
 
                                /* Reserve the conversion memories. */
1163
 
                                if ( pusRinRoutConversionMemIndex != NULL )
1164
 
                                {
1165
 
                                        /* Reserve a conversion memory for the Rin/Rout stream. */
1166
 
                                        ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, 
1167
 
                                                                                                                                        pusRinRoutConversionMemIndex );
1168
 
                                        if ( ulResult == cOCT6100_ERR_OK )
1169
 
                                        {
1170
 
                                                fRinRoutConversionMemEntry = TRUE;
1171
 
                                        }
1172
 
                                }
1173
 
                                else
1174
 
                                {
1175
 
                                        /* No conversion memory reserved.*/
1176
 
                                        f_pChanIndexConf->usRinRoutConversionMemIndex = cOCT6100_INVALID_INDEX;
1177
 
                                }
1178
 
 
1179
 
                                if ( ( pusSinSoutConversionMemIndex != NULL ) && 
1180
 
                                         ( ulResult == cOCT6100_ERR_OK ) )
1181
 
                                {
1182
 
                                        /* Reserve a conversion memory for the Sin/Sout stream. */
1183
 
                                        ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, 
1184
 
                                                                                                                                        pusSinSoutConversionMemIndex );
1185
 
                                        if ( ulResult == cOCT6100_ERR_OK )
1186
 
                                        {
1187
 
                                                fSinSoutConversionMemEntry = TRUE;
1188
 
                                        }
1189
 
                                }
1190
 
                                else
1191
 
                                {
1192
 
                                        /* No conversion memory reserved.*/
1193
 
                                        f_pChanIndexConf->usSinSoutConversionMemIndex = cOCT6100_INVALID_INDEX;
1194
 
                                }
1195
 
 
1196
 
                                /* Reserve any resources required if the extended Tone detection is enabled.*/
1197
 
                                if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
1198
 
                                {
1199
 
                                        ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, 
1200
 
                                                                                                                   &f_pChanIndexConf->usExtToneChanIndex );
1201
 
                                        if ( ulResult == cOCT6100_ERR_OK )
1202
 
                                        {
1203
 
                                                fExtToneChanEntry = TRUE;
1204
 
                                                
1205
 
                                                /* Reserve an entry for the TSI chariot memory for the additionnal channel. */
1206
 
                                                ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, 
1207
 
                                                                                                                                 &f_pChanIndexConf->usExtToneTsiIndex );
1208
 
                                                if ( ulResult == cOCT6100_ERR_OK )
1209
 
                                                {
1210
 
                                                        fExtToneTsiEntry = TRUE;
1211
 
 
1212
 
                                                        /* Reserve an entry for the TSI chariot memory for the additionnal channel. */
1213
 
                                                        ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, 
1214
 
                                                                                                                                                 &f_pChanIndexConf->usExtToneMixerIndex );
1215
 
                                                        if ( ulResult == cOCT6100_ERR_OK )
1216
 
                                                                fExtToneMixerEntry = TRUE;
1217
 
                                                }
1218
 
                                        }
1219
 
                                }
1220
 
                                else
1221
 
                                {
1222
 
                                        f_pChanIndexConf->usExtToneChanIndex    = cOCT6100_INVALID_INDEX;
1223
 
                                        f_pChanIndexConf->usExtToneMixerIndex   = cOCT6100_INVALID_INDEX;
1224
 
                                        f_pChanIndexConf->usExtToneTsiIndex             = cOCT6100_INVALID_INDEX;
1225
 
                                }
1226
 
                        }
1227
 
                        else
1228
 
                        {
1229
 
                                /* Return an error other then a Fatal.*/
1230
 
                                ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY;
1231
 
                        }
1232
 
                }
1233
 
                else
1234
 
                {
1235
 
                        /* Return an error other then a Fatal.*/
1236
 
                        ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY;
1237
 
                }
1238
 
        }
1239
 
 
1240
 
        /*===============================================================================*/
1241
 
 
1242
 
        /*===============================================================================*/
1243
 
        /* Now reserve the TSST entries if required.*/
1244
 
 
1245
 
        /* Reserve the Rin TSST entry */        
1246
 
        if ( (ulResult == cOCT6100_ERR_OK ) &&
1247
 
                 (pTdmConfig->ulRinTimeslot != cOCT6100_UNASSIGNED && 
1248
 
                  pTdmConfig->ulRinStream != cOCT6100_UNASSIGNED) )
1249
 
        {
1250
 
                ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
1251
 
                                                                                  pTdmConfig->ulRinTimeslot, 
1252
 
                                                                                  pTdmConfig->ulRinStream, 
1253
 
                                                                                  pTdmConfig->ulRinNumTssts, 
1254
 
                                                                                  cOCT6100_INPUT_TSST,
1255
 
                                                                                  &f_pChanIndexConf->usRinTsstIndex, 
1256
 
                                                                                  NULL );
1257
 
                if ( ulResult == cOCT6100_ERR_OK )
1258
 
                        fRinTsstEntry = TRUE;
1259
 
        }
1260
 
        else
1261
 
        {
1262
 
                f_pChanIndexConf->usRinTsstIndex = cOCT6100_INVALID_INDEX;
1263
 
        }
1264
 
 
1265
 
                
1266
 
        if ( (ulResult == cOCT6100_ERR_OK ) &&
1267
 
                 (pTdmConfig->ulSinTimeslot != cOCT6100_UNASSIGNED && 
1268
 
                  pTdmConfig->ulSinStream != cOCT6100_UNASSIGNED) )
1269
 
        {
1270
 
                /* Reserve the Sin TSST entry.*/
1271
 
                ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
1272
 
                                                                                  pTdmConfig->ulSinTimeslot, 
1273
 
                                                                                  pTdmConfig->ulSinStream, 
1274
 
                                                                                  pTdmConfig->ulSinNumTssts, 
1275
 
                                                                                  cOCT6100_INPUT_TSST,
1276
 
                                                                                  &f_pChanIndexConf->usSinTsstIndex, 
1277
 
                                                                                  NULL );
1278
 
                if ( ulResult == cOCT6100_ERR_OK )
1279
 
                        fSinTsstEntry = TRUE;
1280
 
        }
1281
 
        else 
1282
 
        {
1283
 
                f_pChanIndexConf->usSinTsstIndex = cOCT6100_INVALID_INDEX;
1284
 
        }
1285
 
 
1286
 
        if ( (ulResult == cOCT6100_ERR_OK ) &&
1287
 
                 (pTdmConfig->ulRoutTimeslot != cOCT6100_UNASSIGNED && 
1288
 
                  pTdmConfig->ulRoutStream != cOCT6100_UNASSIGNED) )
1289
 
        {
1290
 
                /* Reserve the Rout TSST entry.*/
1291
 
                ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
1292
 
                                                                                  pTdmConfig->ulRoutTimeslot, 
1293
 
                                                                                  pTdmConfig->ulRoutStream, 
1294
 
                                                                                  pTdmConfig->ulRoutNumTssts, 
1295
 
                                                                                  cOCT6100_OUTPUT_TSST,
1296
 
                                                                                  &f_pChanIndexConf->usRoutTsstIndex, 
1297
 
                                                                                  NULL );
1298
 
                if ( ulResult == cOCT6100_ERR_OK )
1299
 
                        fRoutTsstEntry = TRUE;
1300
 
        }
1301
 
        else
1302
 
        {
1303
 
                f_pChanIndexConf->usRoutTsstIndex = cOCT6100_INVALID_INDEX;
1304
 
        }
1305
 
 
1306
 
                                
1307
 
        if ( (ulResult == cOCT6100_ERR_OK ) &&
1308
 
                 (pTdmConfig->ulSoutTimeslot != cOCT6100_UNASSIGNED && 
1309
 
                  pTdmConfig->ulSoutStream != cOCT6100_UNASSIGNED) )
1310
 
        {
1311
 
                /* Reserve the Sout TSST entry.*/
1312
 
                ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
1313
 
                                                                                  pTdmConfig->ulSoutTimeslot, 
1314
 
                                                                                  pTdmConfig->ulSoutStream, 
1315
 
                                                                                  pTdmConfig->ulSoutNumTssts, 
1316
 
                                                                                  cOCT6100_OUTPUT_TSST,
1317
 
                                                                                  &f_pChanIndexConf->usSoutTsstIndex, 
1318
 
                                                                                  NULL );
1319
 
                if ( ulResult == cOCT6100_ERR_OK )
1320
 
                        fSoutTsstEntry = TRUE;
1321
 
        }
1322
 
        else 
1323
 
        {
1324
 
                f_pChanIndexConf->usSoutTsstIndex = cOCT6100_INVALID_INDEX;
1325
 
        }
1326
 
 
1327
 
        /*===============================================================================*/
1328
 
        
1329
 
 
1330
 
        /*===============================================================================*/
1331
 
        /* Check if there are a couple of mixer events available for us. */
1332
 
 
1333
 
        if ( ulResult == cOCT6100_ERR_OK )
1334
 
        {
1335
 
                UINT32 ulMixerEventCntNeeded = 0;
1336
 
 
1337
 
                /* Calculate how many mixer events are needed. */
1338
 
                if ( f_pChanIndexConf->usRinTsstIndex == cOCT6100_INVALID_INDEX )
1339
 
                        ulMixerEventCntNeeded++;
1340
 
 
1341
 
                if ( f_pChanIndexConf->usSinTsstIndex == cOCT6100_INVALID_INDEX )
1342
 
                        ulMixerEventCntNeeded++;
1343
 
 
1344
 
                /* If at least 1 mixer event is needed, check if those are available. */
1345
 
                if ( ulMixerEventCntNeeded != 0 )
1346
 
                {
1347
 
                        ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt );
1348
 
                        if ( ulResult == cOCT6100_ERR_OK )
1349
 
                        {
1350
 
                                /* The API might need more mixer events if the ports have to be muted. */
1351
 
                                /* Check if these are available. */
1352
 
                                if ( ulFreeMixerEventCnt < ulMixerEventCntNeeded )
1353
 
                                {
1354
 
                                        ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS;
1355
 
                                }
1356
 
                        }
1357
 
                }
1358
 
        }
1359
 
 
1360
 
        /*===============================================================================*/
1361
 
 
1362
 
 
1363
 
        /*===============================================================================*/
1364
 
        /* Release the resources if something went wrong */             
1365
 
        if ( ulResult != cOCT6100_ERR_OK  )
1366
 
        {
1367
 
                /*===============================================================================*/
1368
 
                /* Release the previously reserved resources .*/
1369
 
                if( fRinTsstEntry == TRUE )
1370
 
                {
1371
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,  
1372
 
                                                                                           pTdmConfig->ulRinTimeslot,
1373
 
                                                                                           pTdmConfig->ulRinStream,
1374
 
                                                                                           pTdmConfig->ulRinNumTssts, 
1375
 
                                                                                           cOCT6100_INPUT_TSST,
1376
 
                                                                                           cOCT6100_INVALID_INDEX );
1377
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1378
 
                                return ulTempVar;
1379
 
                }
1380
 
 
1381
 
                if( fSinTsstEntry == TRUE )
1382
 
                {
1383
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,  
1384
 
                                                                                           pTdmConfig->ulSinTimeslot,
1385
 
                                                                                           pTdmConfig->ulSinStream,
1386
 
                                                                                           pTdmConfig->ulSinNumTssts, 
1387
 
                                                                                           cOCT6100_INPUT_TSST,
1388
 
                                                                                           cOCT6100_INVALID_INDEX );
1389
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1390
 
                                return ulTempVar;
1391
 
                }
1392
 
 
1393
 
                if( fRoutTsstEntry == TRUE )
1394
 
                {
1395
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,  
1396
 
                                                                                           pTdmConfig->ulRoutTimeslot,
1397
 
                                                                                           pTdmConfig->ulRoutStream,
1398
 
                                                                                           pTdmConfig->ulRoutNumTssts, 
1399
 
                                                                                           cOCT6100_OUTPUT_TSST,
1400
 
                                                                                           cOCT6100_INVALID_INDEX );
1401
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1402
 
                                return ulTempVar;
1403
 
                }
1404
 
 
1405
 
                if( fSoutTsstEntry == TRUE )
1406
 
                {
1407
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, 
1408
 
                                                                                           pTdmConfig->ulSoutTimeslot,
1409
 
                                                                                           pTdmConfig->ulSoutStream,
1410
 
                                                                                           pTdmConfig->ulSoutNumTssts, 
1411
 
                                                                                           cOCT6100_OUTPUT_TSST,
1412
 
                                                                                           cOCT6100_INVALID_INDEX );
1413
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1414
 
                                return ulTempVar;
1415
 
                }
1416
 
 
1417
 
                if( fRinRoutTsiMemEntry == TRUE )
1418
 
                {
1419
 
                        ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, 
1420
 
                                                                                                          f_pChanIndexConf->usRinRoutTsiMemIndex );
1421
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1422
 
                                return ulTempVar;
1423
 
                }
1424
 
 
1425
 
                if( fSinSoutTsiMemEntry == TRUE )
1426
 
                {
1427
 
                        ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, 
1428
 
                                                                                                          f_pChanIndexConf->usSinSoutTsiMemIndex );
1429
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1430
 
                                return ulTempVar;
1431
 
                }
1432
 
 
1433
 
                /*===============================================================================*/
1434
 
 
1435
 
                /*===============================================================================*/
1436
 
                /* Release the previously reserved echo resources .*/
1437
 
                if( fEchoChanEntry == TRUE )
1438
 
                {
1439
 
                        ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance, 
1440
 
                                                                                                        f_pChanIndexConf->usEchoChanIndex );
1441
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1442
 
                                return ulTempVar;
1443
 
                }
1444
 
 
1445
 
                /*===============================================================================*/
1446
 
        
1447
 
                /*===============================================================================*/
1448
 
                /* Release the previously reserved resources for the extended tone detection.*/
1449
 
                if( fExtToneChanEntry == TRUE )
1450
 
                {
1451
 
                        ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance, 
1452
 
                                                                                                        f_pChanIndexConf->usExtToneChanIndex );
1453
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1454
 
                                return ulTempVar;
1455
 
                }
1456
 
 
1457
 
                if( fExtToneTsiEntry == TRUE )
1458
 
                {
1459
 
                        ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, 
1460
 
                                                                                                          f_pChanIndexConf->usExtToneTsiIndex );
1461
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1462
 
                                return ulTempVar;
1463
 
                }
1464
 
 
1465
 
                if( fExtToneMixerEntry == TRUE )
1466
 
                {
1467
 
                        ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, 
1468
 
                                                                                                                 f_pChanIndexConf->usExtToneMixerIndex );
1469
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1470
 
                                return ulTempVar;
1471
 
                }
1472
 
                /*===============================================================================*/
1473
 
 
1474
 
                /*===============================================================================*/
1475
 
                /* Release the conversion resources. */
1476
 
                if( fRinRoutConversionMemEntry == TRUE )
1477
 
                {
1478
 
                        ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, 
1479
 
                                                                                                                        f_pChanIndexConf->usRinRoutConversionMemIndex );
1480
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1481
 
                                return ulTempVar;
1482
 
                }
1483
 
 
1484
 
                if( fSinSoutConversionMemEntry == TRUE )
1485
 
                {
1486
 
                        ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, 
1487
 
                                                                                                                        f_pChanIndexConf->usSinSoutConversionMemIndex );
1488
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
1489
 
                                return ulTempVar;
1490
 
                }
1491
 
 
1492
 
                /*===============================================================================*/
1493
 
                
1494
 
                return ulResult;
1495
 
        }
1496
 
 
1497
 
        return cOCT6100_ERR_OK;
1498
 
}
1499
 
 
1500
 
 
1501
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1502
 
 
1503
 
Function:               Oct6100ApiWriteChannelStructs
1504
 
 
1505
 
Description:    Performs all the required structure writes to configure the
1506
 
                                new echo cancellation channel.
1507
 
 
1508
 
-------------------------------------------------------------------------------
1509
 
|       Argument                |       Description
1510
 
-------------------------------------------------------------------------------
1511
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
1512
 
                                                present state of the chip and all its resources.
1513
 
        
1514
 
f_pChannelOpen                  Pointer to echo cancellation channel configuration structure.
1515
 
f_pChanIndexConf                Pointer to a structure used to store the multiple resources indexes.
1516
 
 
1517
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
1518
 
static UINT32 Oct6100ApiWriteChannelStructs(
1519
 
                                IN tPOCT6100_INSTANCE_API                       f_pApiInstance,
1520
 
                                IN tPOCT6100_CHANNEL_OPEN                       f_pChannelOpen,
1521
 
                                OUT tPOCT6100_API_ECHO_CHAN_INDEX       f_pChanIndexConf )
1522
 
{
1523
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
1524
 
        tPOCT6100_CHANNEL_OPEN_TDM              pTdmConfig;
1525
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
1526
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
1527
 
        UINT32  ulResult;
1528
 
        UINT32  ulDwordAddress;
1529
 
        UINT32  ulDwordData;
1530
 
        BOOL    fConversionEnabled = FALSE;
1531
 
        BOOL    fProgramAdpcmMem;
1532
 
        UINT32  ulCompType = 0;
1533
 
        UINT32  ulPcmLaw;
1534
 
        UINT16  usTempTsiMemIndex;
1535
 
        UINT16  usConversionMemIndex;
1536
 
        UINT32  ulToneEventNumber;
1537
 
        BOOL    fSSTone;
1538
 
 
1539
 
        /* Obtain local pointer to shared portion of instance. */
1540
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
1541
 
        
1542
 
        /* Obtain a local pointer to the TDM configuration structure.*/
1543
 
        pTdmConfig = &f_pChannelOpen->TdmConfig;
1544
 
 
1545
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1546
 
 
1547
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1548
 
 
1549
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex );
1550
 
 
1551
 
        /*==============================================================================*/
1552
 
        /* Configure the Tsst control memory.*/
1553
 
        
1554
 
        /* Set the RIN Tsst control entry.*/
1555
 
        if ( f_pChanIndexConf->usRinTsstIndex != cOCT6100_INVALID_INDEX )
1556
 
        {
1557
 
                ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
1558
 
                                                                                                                  f_pChanIndexConf->usRinTsstIndex,
1559
 
                                                                                                                  f_pChanIndexConf->usRinRoutTsiMemIndex,
1560
 
                                                                                                                  pTdmConfig->ulRinPcmLaw );
1561
 
                if ( ulResult != cOCT6100_ERR_OK )
1562
 
                        return ulResult;
1563
 
        }
1564
 
 
1565
 
        /* Set the ROUT Tsst control entry.*/
1566
 
        if ( f_pChanIndexConf->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
1567
 
        {
1568
 
                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
1569
 
                                                                                                                   f_pChanIndexConf->usRoutTsstIndex,
1570
 
                                                                                                                   f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
1571
 
                                                                                                                   pTdmConfig->ulRoutNumTssts,
1572
 
                                                                                                                   f_pChanIndexConf->usRinRoutTsiMemIndex );
1573
 
                if ( ulResult != cOCT6100_ERR_OK )
1574
 
                        return ulResult;
1575
 
        }
1576
 
 
1577
 
        /* Set the SIN Tsst control entry.*/
1578
 
        if ( f_pChanIndexConf->usSinTsstIndex != cOCT6100_INVALID_INDEX )
1579
 
        {
1580
 
                ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
1581
 
                                                                                                                  f_pChanIndexConf->usSinTsstIndex,
1582
 
                                                                                                                  f_pChanIndexConf->usSinSoutTsiMemIndex,
1583
 
                                                                                                                  pTdmConfig->ulSinPcmLaw );
1584
 
                if ( ulResult != cOCT6100_ERR_OK )
1585
 
                        return ulResult;
1586
 
        }
1587
 
 
1588
 
        /* Set the SOUT Tsst control entry.*/
1589
 
        if ( f_pChanIndexConf->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
1590
 
        {
1591
 
                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
1592
 
                                                                                                                   f_pChanIndexConf->usSoutTsstIndex,
1593
 
                                                                                                                   f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
1594
 
                                                                                                                   pTdmConfig->ulSoutNumTssts,
1595
 
                                                                                                                   f_pChanIndexConf->usSinSoutTsiMemIndex );
1596
 
                if ( ulResult != cOCT6100_ERR_OK )
1597
 
                        return ulResult;
1598
 
        }
1599
 
 
1600
 
        /*==============================================================================*/
1601
 
 
1602
 
        /*==============================================================================*/
1603
 
        /* Configure the ADPCM control memory for the Decoder.*/
1604
 
 
1605
 
        /* Set the codec state flags.*/
1606
 
        f_pChanIndexConf->fRinRoutCodecActive = FALSE;
1607
 
        f_pChanIndexConf->fSinSoutCodecActive = FALSE;
1608
 
 
1609
 
        if ( f_pChannelOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING )
1610
 
        {
1611
 
                fProgramAdpcmMem = TRUE;
1612
 
 
1613
 
                switch( f_pChannelOpen->CodecConfig.ulDecodingRate )
1614
 
                {
1615
 
                case cOCT6100_G711_64KBPS:                              
1616
 
                        ulCompType = 0x8;               
1617
 
                        if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1618
 
                        {
1619
 
                                if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw )
1620
 
                                        fProgramAdpcmMem = FALSE;
1621
 
                        }
1622
 
                        else /*  f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
1623
 
                        {
1624
 
                                if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
1625
 
                                        fProgramAdpcmMem = FALSE;
1626
 
                        }
1627
 
                        break;
1628
 
                case cOCT6100_G726_40KBPS:                              
1629
 
                        ulCompType = 0x3;               
1630
 
                        fConversionEnabled = TRUE;
1631
 
                        break;
1632
 
 
1633
 
                case cOCT6100_G726_32KBPS:                              
1634
 
                        ulCompType = 0x2;               
1635
 
                        fConversionEnabled = TRUE;
1636
 
                        break;
1637
 
 
1638
 
                case cOCT6100_G726_24KBPS:                              
1639
 
                        ulCompType = 0x1;               
1640
 
                        fConversionEnabled = TRUE;
1641
 
                        break;
1642
 
 
1643
 
                case cOCT6100_G726_16KBPS:                              
1644
 
                        ulCompType = 0x0;               
1645
 
                        fConversionEnabled = TRUE;
1646
 
                        break;          
1647
 
 
1648
 
                case cOCT6100_G727_2C_ENCODED:                  
1649
 
                        ulCompType = 0x4;               
1650
 
                        fConversionEnabled = TRUE;
1651
 
                        break;
1652
 
 
1653
 
                case cOCT6100_G727_3C_ENCODED:                  
1654
 
                        ulCompType = 0x5;               
1655
 
                        fConversionEnabled = TRUE;
1656
 
                        break;
1657
 
 
1658
 
                case cOCT6100_G727_4C_ENCODED:                  
1659
 
                        ulCompType = 0x6;               
1660
 
                        fConversionEnabled = TRUE;
1661
 
                        break;
1662
 
 
1663
 
                case cOCT6100_G726_ENCODED:                             
1664
 
                        ulCompType = 0x9;               
1665
 
                        fConversionEnabled = TRUE;
1666
 
                        break;
1667
 
 
1668
 
                case cOCT6100_G711_G726_ENCODED:                
1669
 
                        ulCompType = 0xA;               
1670
 
                        fConversionEnabled = TRUE;
1671
 
                        break;
1672
 
 
1673
 
                case cOCT6100_G711_G727_2C_ENCODED:             
1674
 
                        ulCompType = 0xC;               
1675
 
                        fConversionEnabled = TRUE;
1676
 
                        break;
1677
 
 
1678
 
                case cOCT6100_G711_G727_3C_ENCODED:             
1679
 
                        ulCompType = 0xD;               
1680
 
                        fConversionEnabled = TRUE;
1681
 
                        break;
1682
 
 
1683
 
                case cOCT6100_G711_G727_4C_ENCODED:             
1684
 
                        ulCompType = 0xE;               
1685
 
                        fConversionEnabled = TRUE;
1686
 
                        break;
1687
 
                default:
1688
 
                        return cOCT6100_ERR_FATAL_D4;
1689
 
                }
1690
 
 
1691
 
                if ( fProgramAdpcmMem == TRUE )
1692
 
                {
1693
 
                        /* Set the chariot memory based on the selected port.*/
1694
 
                        if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1695
 
                        {
1696
 
                                usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
1697
 
                                ulPcmLaw = pTdmConfig->ulRoutPcmLaw;            /* Set the law for later use */
1698
 
 
1699
 
                                /* Set the codec state flags.*/
1700
 
                                f_pChanIndexConf->fRinRoutCodecActive = TRUE;
1701
 
 
1702
 
                                /* Set the conversion memory index to use for decompression */
1703
 
                                usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
1704
 
                        }
1705
 
                        else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
1706
 
                        {
1707
 
                                usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
1708
 
                                ulPcmLaw = pTdmConfig->ulSoutPcmLaw;            /* Set the law for later use */
1709
 
 
1710
 
                                /* Set the codec state flags.*/
1711
 
                                f_pChanIndexConf->fSinSoutCodecActive = TRUE;
1712
 
 
1713
 
                                /* Set the conversion memory index to use for decompression */
1714
 
                                usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
1715
 
                        }
1716
 
 
1717
 
                        ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance,
1718
 
                                                                                                         usConversionMemIndex,
1719
 
                                                                                                         ulCompType,
1720
 
                                                                                                         usTempTsiMemIndex,
1721
 
                                                                                                         ulPcmLaw,
1722
 
                                                                                                         f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition );
1723
 
                        if ( ulResult != cOCT6100_ERR_OK )
1724
 
                                return ulResult;
1725
 
                }
1726
 
        }
1727
 
        /*==============================================================================*/
1728
 
 
1729
 
 
1730
 
        /*==============================================================================*/
1731
 
        /* Configure the ADPCM control memory for the Encoder */
1732
 
 
1733
 
        if ( f_pChannelOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING )
1734
 
        {
1735
 
                fProgramAdpcmMem = TRUE;
1736
 
 
1737
 
                switch( f_pChannelOpen->CodecConfig.ulEncodingRate )
1738
 
                {
1739
 
                case cOCT6100_G711_64KBPS:
1740
 
                        if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
1741
 
                        {
1742
 
                                if ( pTdmConfig->ulRoutPcmLaw == cOCT6100_PCM_U_LAW )
1743
 
                                        ulCompType = 0x4;
1744
 
                                else
1745
 
                                        ulCompType = 0x5;
1746
 
 
1747
 
                                /* Check for law conversion.*/
1748
 
                                if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw )
1749
 
                                        fProgramAdpcmMem = FALSE;
1750
 
                        }       
1751
 
                        else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
1752
 
                        {
1753
 
                                if ( pTdmConfig->ulSoutPcmLaw == cOCT6100_PCM_U_LAW )
1754
 
                                        ulCompType = 0x4;
1755
 
                                else
1756
 
                                        ulCompType = 0x5;
1757
 
 
1758
 
                                /* Check for law conversion.*/
1759
 
                                if ( pTdmConfig->ulSinPcmLaw == pTdmConfig->ulSoutPcmLaw )
1760
 
                                        fProgramAdpcmMem = FALSE;
1761
 
                        }       
1762
 
 
1763
 
                        break;
1764
 
                case cOCT6100_G726_40KBPS:                              
1765
 
                        ulCompType = 0x3;               
1766
 
                        fConversionEnabled = TRUE;
1767
 
                        break;
1768
 
 
1769
 
                case cOCT6100_G726_32KBPS:                              
1770
 
                        ulCompType = 0x2;               
1771
 
                        fConversionEnabled = TRUE;
1772
 
                        break;
1773
 
 
1774
 
                case cOCT6100_G726_24KBPS:                              
1775
 
                        ulCompType = 0x1;               
1776
 
                        fConversionEnabled = TRUE;
1777
 
                        break;
1778
 
 
1779
 
                case cOCT6100_G726_16KBPS:                              
1780
 
                        ulCompType = 0x0;               
1781
 
                        fConversionEnabled = TRUE;
1782
 
                        break;          
1783
 
 
1784
 
                case cOCT6100_G727_40KBPS_4_1:                  
1785
 
                        ulCompType = 0xD;               
1786
 
                        fConversionEnabled = TRUE;
1787
 
                        break;
1788
 
 
1789
 
                case cOCT6100_G727_40KBPS_3_2:                  
1790
 
                        ulCompType = 0xA;               
1791
 
                        fConversionEnabled = TRUE;
1792
 
                        break;
1793
 
 
1794
 
                case cOCT6100_G727_40KBPS_2_3:                  
1795
 
                        ulCompType = 0x6;               
1796
 
                        fConversionEnabled = TRUE;
1797
 
                        break;
1798
 
 
1799
 
                case cOCT6100_G727_32KBPS_4_0:                  
1800
 
                        ulCompType = 0xE;               
1801
 
                        fConversionEnabled = TRUE;
1802
 
                        break;
1803
 
 
1804
 
                case cOCT6100_G727_32KBPS_3_1:                  
1805
 
                        ulCompType = 0xB;               
1806
 
                        fConversionEnabled = TRUE;
1807
 
                        break;
1808
 
 
1809
 
                case cOCT6100_G727_32KBPS_2_2:                  
1810
 
                        ulCompType = 0x7;               
1811
 
                        fConversionEnabled = TRUE;
1812
 
                        break;
1813
 
 
1814
 
                case cOCT6100_G727_24KBPS_3_0:                  
1815
 
                        ulCompType = 0xC;               
1816
 
                        fConversionEnabled = TRUE;
1817
 
                        break;
1818
 
 
1819
 
                case cOCT6100_G727_24KBPS_2_1:                  
1820
 
                        ulCompType = 0x8;               
1821
 
                        fConversionEnabled = TRUE;
1822
 
                        break;
1823
 
 
1824
 
                case cOCT6100_G727_16KBPS_2_0:                  
1825
 
                        ulCompType = 0x9;               
1826
 
                        fConversionEnabled = TRUE;
1827
 
                        break;
1828
 
 
1829
 
                default:
1830
 
                        return cOCT6100_ERR_FATAL_D5;
1831
 
                }
1832
 
 
1833
 
                /* Program the APDCM memory only if ADPCM is requried.*/
1834
 
                if ( fProgramAdpcmMem == TRUE || f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
1835
 
                {
1836
 
                        /* Set the chariot memory based on the selected port.*/
1837
 
                        if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
1838
 
                        {
1839
 
                                usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
1840
 
 
1841
 
                                /* Set the codec state flags.*/
1842
 
                                f_pChanIndexConf->fRinRoutCodecActive = TRUE;
1843
 
 
1844
 
                                /* Set the conversion memory index to use for compression */
1845
 
                                usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
1846
 
                        }
1847
 
 
1848
 
                        else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
1849
 
                        {
1850
 
                                usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
1851
 
 
1852
 
                                /* Set the codec state flags.*/
1853
 
                                f_pChanIndexConf->fSinSoutCodecActive = TRUE;
1854
 
 
1855
 
                                /* Set the conversion memory index to use for compression */
1856
 
                                usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
1857
 
                        }
1858
 
 
1859
 
                        ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance,
1860
 
                                                                                                         usConversionMemIndex,
1861
 
                                                                                                         ulCompType,
1862
 
                                                                                                         usTempTsiMemIndex,
1863
 
                                                                                                         f_pChannelOpen->CodecConfig.fEnableSilenceSuppression,
1864
 
                                                                                                         f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition,
1865
 
                                                                                                         f_pChanIndexConf->usPhasingTsstIndex,
1866
 
                                                                                                         f_pChannelOpen->CodecConfig.ulPhasingType,
1867
 
                                                                                                         f_pChannelOpen->CodecConfig.ulPhase );
1868
 
                        if ( ulResult != cOCT6100_ERR_OK )
1869
 
                                return ulResult;
1870
 
                }
1871
 
        }
1872
 
        /*==============================================================================*/
1873
 
 
1874
 
        
1875
 
        /*==============================================================================*/
1876
 
        /* Clearing the tone events bit vector */
1877
 
 
1878
 
        ulDwordAddress  = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usEchoChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
1879
 
        ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
1880
 
        ulDwordData = 0x00000000;
1881
 
 
1882
 
        ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
1883
 
        if ( ulResult != cOCT6100_ERR_OK  )
1884
 
                return ulResult;
1885
 
 
1886
 
        ulDwordAddress += 4;
1887
 
 
1888
 
        ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
1889
 
        if ( ulResult != cOCT6100_ERR_OK  )
1890
 
                return ulResult;
1891
 
 
1892
 
        /*==============================================================================*/
1893
 
 
1894
 
        
1895
 
        /*==============================================================================*/
1896
 
        /*      Write the VQE memory */
1897
 
        
1898
 
        ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance,
1899
 
                                                                                  &f_pChannelOpen->VqeConfig,
1900
 
                                                                                  f_pChannelOpen,
1901
 
                                                                                  f_pChanIndexConf->usEchoChanIndex,    
1902
 
                                                                                  f_pChanIndexConf->usEchoMemIndex,
1903
 
                                                                                  TRUE,
1904
 
                                                                                  FALSE );
1905
 
        if ( ulResult != cOCT6100_ERR_OK )
1906
 
                return ulResult;
1907
 
 
1908
 
        /*==============================================================================*/
1909
 
 
1910
 
        /*==============================================================================*/
1911
 
        /*      Write the echo memory */
1912
 
 
1913
 
        ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance,
1914
 
                                                                                  pTdmConfig,
1915
 
                                                                                  f_pChannelOpen,
1916
 
                                                                                  f_pChanIndexConf->usEchoMemIndex,
1917
 
                                                                                  f_pChanIndexConf->usRinRoutTsiMemIndex,
1918
 
                                                                                  f_pChanIndexConf->usSinSoutTsiMemIndex );
1919
 
        if ( ulResult != cOCT6100_ERR_OK )
1920
 
                return ulResult;
1921
 
 
1922
 
        /*==============================================================================*/
1923
 
 
1924
 
 
1925
 
 
1926
 
        /*==============================================================================*/
1927
 
        /*      Mute channel if required, this is done on a port basis */
1928
 
 
1929
 
        /* Initialize the silence indexes to invalid for now. */
1930
 
        pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
1931
 
        pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
1932
 
 
1933
 
        /* Set the TSI memory indexes. */
1934
 
        pChanEntry->usRinRoutTsiMemIndex  = f_pChanIndexConf->usRinRoutTsiMemIndex;
1935
 
        pChanEntry->usSinSoutTsiMemIndex  = f_pChanIndexConf->usSinSoutTsiMemIndex;
1936
 
 
1937
 
        ulResult = Oct6100ApiMutePorts( f_pApiInstance,
1938
 
                                                                        f_pChanIndexConf->usEchoChanIndex,
1939
 
                                                                        f_pChanIndexConf->usRinTsstIndex,
1940
 
                                                                        f_pChanIndexConf->usSinTsstIndex,
1941
 
                                                                        FALSE );
1942
 
        if ( ulResult != cOCT6100_ERR_OK )
1943
 
                return ulResult;
1944
 
        
1945
 
        /*==============================================================================*/
1946
 
 
1947
 
        
1948
 
        /*==============================================================================*/
1949
 
        /* Set the dominant speaker to unassigned, if required. */
1950
 
 
1951
 
        if ( f_pApiInstance->pSharedInfo->ImageInfo.fDominantSpeakerEnabled == TRUE )
1952
 
        {
1953
 
                ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_pChanIndexConf->usEchoChanIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED );
1954
 
                if ( ulResult != cOCT6100_ERR_OK )
1955
 
                        return ulResult;
1956
 
        }
1957
 
        
1958
 
        /*==============================================================================*/
1959
 
 
1960
 
 
1961
 
        /*==============================================================================*/
1962
 
        /* If necessary, configure the extended tone detection channel.*/
1963
 
 
1964
 
        if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
1965
 
        {
1966
 
                UINT32  ulTempSinLaw;
1967
 
                UINT32  ulTempSoutLaw;
1968
 
                UINT32  ulTempEchoOpMode;
1969
 
 
1970
 
                /* save the original law.*/
1971
 
                ulTempSinLaw            = pTdmConfig->ulSinPcmLaw;
1972
 
                ulTempSoutLaw           = pTdmConfig->ulSoutPcmLaw;
1973
 
                ulTempEchoOpMode        = f_pChannelOpen->ulEchoOperationMode;
1974
 
 
1975
 
                /* Now, make sure the Sin and Sout law are the same as the Rin law.*/
1976
 
 
1977
 
                pTdmConfig->ulSinPcmLaw         = pTdmConfig->ulRinPcmLaw;
1978
 
                pTdmConfig->ulSoutPcmLaw        = pTdmConfig->ulRinPcmLaw;
1979
 
                
1980
 
                f_pChannelOpen->ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_NORMAL;
1981
 
 
1982
 
                /* Write the Echo and VQE memory of the extended channel.*/
1983
 
 
1984
 
                ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance,
1985
 
                                                                                                   pTdmConfig,
1986
 
                                                                                                   &f_pChannelOpen->VqeConfig,
1987
 
                                                                                                   f_pChannelOpen,
1988
 
                                                                                                   f_pChanIndexConf->usExtToneChanIndex,
1989
 
                                                                                                   f_pChanIndexConf->usExtToneChanIndex,
1990
 
                                                                                                   cOCT6100_API_EXT_TONE_EXTRA_TSI,
1991
 
                                                                                                   f_pChanIndexConf->usExtToneTsiIndex );
1992
 
                if ( ulResult != cOCT6100_ERR_OK )
1993
 
                        return ulResult;
1994
 
 
1995
 
                /* Now, write the mixer event used to copy the RIN signal of the original channel
1996
 
                   into the SIN signal of the exteded channel. */
1997
 
 
1998
 
                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_pChanIndexConf->usExtToneMixerIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
1999
 
                
2000
 
                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
2001
 
                WriteParams.usWriteData |= f_pChanIndexConf->usRinRoutTsiMemIndex;
2002
 
                WriteParams.usWriteData |= pTdmConfig->ulRinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
2003
 
 
2004
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2005
 
                if ( ulResult != cOCT6100_ERR_OK  )
2006
 
                        return ulResult;
2007
 
 
2008
 
                WriteParams.ulWriteAddress += 2;
2009
 
                WriteParams.usWriteData = f_pChanIndexConf->usExtToneTsiIndex;
2010
 
 
2011
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2012
 
                if ( ulResult != cOCT6100_ERR_OK  )
2013
 
                        return ulResult;
2014
 
 
2015
 
                /*=======================================================================*/
2016
 
 
2017
 
 
2018
 
                /*=======================================================================*/
2019
 
                /* Now insert the Sin copy event into the list.*/
2020
 
 
2021
 
                ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
2022
 
                                                                                        f_pChanIndexConf->usExtToneMixerIndex,
2023
 
                                                                                        cOCT6100_EVENT_TYPE_SIN_COPY,
2024
 
                                                                                        f_pChanIndexConf->usEchoChanIndex );
2025
 
                if ( ulResult != cOCT6100_ERR_OK )
2026
 
                        return ulResult;
2027
 
                /*=======================================================================*/
2028
 
 
2029
 
                /*==============================================================================*/
2030
 
                /* Clearing the tone events bit vector */
2031
 
 
2032
 
                ulDwordAddress  = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
2033
 
                ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
2034
 
                ulDwordData = 0x00000000;
2035
 
 
2036
 
                ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2037
 
                if ( ulResult != cOCT6100_ERR_OK  )
2038
 
                        return ulResult;
2039
 
 
2040
 
                ulDwordAddress += 4;
2041
 
 
2042
 
                ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2043
 
                if ( ulResult != cOCT6100_ERR_OK  )
2044
 
                        return ulResult;
2045
 
 
2046
 
                /*==============================================================================*/
2047
 
 
2048
 
                /* Write back the original values in the channel open structure.*/
2049
 
 
2050
 
                pTdmConfig->ulSinPcmLaw         = ulTempSinLaw;
2051
 
                pTdmConfig->ulSoutPcmLaw        = ulTempSoutLaw;
2052
 
                
2053
 
                f_pChannelOpen->ulEchoOperationMode = ulTempEchoOpMode;
2054
 
        }
2055
 
 
2056
 
        /*==============================================================================*/
2057
 
 
2058
 
 
2059
 
        /*==============================================================================*/
2060
 
        /* If necessary, configure the SS tone detection. */
2061
 
 
2062
 
        for ( ulToneEventNumber = 0; ulToneEventNumber < cOCT6100_MAX_TONE_EVENT; ulToneEventNumber++ )
2063
 
        {
2064
 
                /* Check if the current tone is a SS tone. */
2065
 
                ulResult = Oct6100ApiIsSSTone( 
2066
 
                                                                        f_pApiInstance, 
2067
 
                                                                        f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID, 
2068
 
                                                                        &fSSTone );
2069
 
                if ( ulResult != cOCT6100_ERR_OK )
2070
 
                        return ulResult;
2071
 
 
2072
 
                if ( fSSTone == TRUE )
2073
 
                {
2074
 
                        /* Write to all resources needed to activate tone detection on this SS tone. */
2075
 
                        ulResult = Oct6100ApiWriteToneDetectEvent( 
2076
 
                                                                                                        f_pApiInstance, 
2077
 
                                                                                                        f_pChanIndexConf->usEchoChanIndex, 
2078
 
                                                                                                        ulToneEventNumber,
2079
 
 
2080
 
                                                                                                        cOCT6100_INVALID_INDEX );
2081
 
                        if ( ulResult != cOCT6100_ERR_OK  )
2082
 
                                return ulResult;
2083
 
                }
2084
 
        }
2085
 
 
2086
 
        /*==============================================================================*/
2087
 
 
2088
 
 
2089
 
        return cOCT6100_ERR_OK;
2090
 
}
2091
 
 
2092
 
 
2093
 
 
2094
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2095
 
 
2096
 
Function:               Oct6100ApiUpdateChannelEntry
2097
 
 
2098
 
Description:    Updates the new channel in the ECHO channel list.
2099
 
 
2100
 
-------------------------------------------------------------------------------
2101
 
|       Argument                |       Description
2102
 
-------------------------------------------------------------------------------
2103
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
2104
 
                                                the present state of the chip and all its resources.
2105
 
 
2106
 
f_pChannelOpen                  Pointer to echo cancellation channel configuration structure.
2107
 
f_pChanIndexConf                Pointer to a structure used to store the multiple resources indexes.
2108
 
 
2109
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2110
 
static UINT32 Oct6100ApiUpdateChannelEntry(
2111
 
                                IN tPOCT6100_INSTANCE_API                       f_pApiInstance,
2112
 
                                IN tPOCT6100_CHANNEL_OPEN                       f_pChannelOpen,
2113
 
                                OUT tPOCT6100_API_ECHO_CHAN_INDEX       f_pChanIndexConf )
2114
 
{
2115
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
2116
 
        tPOCT6100_CHANNEL_OPEN_TDM              pTdmConfig;
2117
 
        tPOCT6100_CHANNEL_OPEN_VQE              pVqeConfig;
2118
 
        tPOCT6100_CHANNEL_OPEN_CODEC    pCodecConfig;
2119
 
 
2120
 
        /* Obtain a pointer to the config structures of the tPOCT6100_CHANNEL_OPEN structure. */
2121
 
        pTdmConfig   = &f_pChannelOpen->TdmConfig;
2122
 
        pVqeConfig   = &f_pChannelOpen->VqeConfig;
2123
 
        pCodecConfig = &f_pChannelOpen->CodecConfig;
2124
 
 
2125
 
        /* Obtain a pointer to the new buffer's list entry. */
2126
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex )
2127
 
        
2128
 
        /*=======================================================================*/
2129
 
        /* Copy the channel's configuration and allocated resources. */
2130
 
        pChanEntry->ulUserChanId = f_pChannelOpen->ulUserChanId;
2131
 
        pChanEntry->byEchoOperationMode = (UINT8)( f_pChannelOpen->ulEchoOperationMode & 0xFF );
2132
 
        pChanEntry->fEnableToneDisabler = (UINT8)( f_pChannelOpen->fEnableToneDisabler & 0xFF );
2133
 
        pChanEntry->fEnableExtToneDetection = (UINT8)( f_pChannelOpen->fEnableExtToneDetection & 0xFF );
2134
 
 
2135
 
        /* Save the VQE configuration.*/
2136
 
        pChanEntry->VqeConfig.byComfortNoiseMode = (UINT8)( pVqeConfig->ulComfortNoiseMode & 0xFF );
2137
 
        pChanEntry->VqeConfig.fEnableNlp = (UINT8)( pVqeConfig->fEnableNlp & 0xFF );
2138
 
        pChanEntry->VqeConfig.fEnableTailDisplacement = (UINT8)( pVqeConfig->fEnableTailDisplacement );
2139
 
        pChanEntry->VqeConfig.usTailDisplacement = (UINT16)( pVqeConfig->ulTailDisplacement & 0xFFFF );
2140
 
        pChanEntry->VqeConfig.usTailLength = (UINT16)( pVqeConfig->ulTailLength & 0xFFFF );
2141
 
 
2142
 
        pChanEntry->VqeConfig.fSinDcOffsetRemoval = (UINT8)( pVqeConfig->fSinDcOffsetRemoval & 0xFF );
2143
 
        pChanEntry->VqeConfig.fRinDcOffsetRemoval = (UINT8)( pVqeConfig->fRinDcOffsetRemoval & 0xFF );
2144
 
        pChanEntry->VqeConfig.fRinLevelControl = (UINT8)( pVqeConfig->fRinLevelControl & 0xFF );
2145
 
        pChanEntry->VqeConfig.chRinLevelControlGainDb = (INT8)( pVqeConfig->lRinLevelControlGainDb & 0xFF );
2146
 
        pChanEntry->VqeConfig.fSoutLevelControl = (UINT8)( pVqeConfig->fSoutLevelControl & 0xFF );
2147
 
        pChanEntry->VqeConfig.chSoutLevelControlGainDb = (INT8)( pVqeConfig->lSoutLevelControlGainDb & 0xFF );
2148
 
        pChanEntry->VqeConfig.fRinAutomaticLevelControl = (UINT8)( pVqeConfig->fRinAutomaticLevelControl & 0xFF );
2149
 
        pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb = (INT8)( pVqeConfig->lRinAutomaticLevelControlTargetDb & 0xFF );
2150
 
        pChanEntry->VqeConfig.fSoutAutomaticLevelControl = (UINT8)( pVqeConfig->fSoutAutomaticLevelControl & 0xFF );
2151
 
        pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb = (INT8)( pVqeConfig->lSoutAutomaticLevelControlTargetDb & 0xFF );
2152
 
        pChanEntry->VqeConfig.fRinHighLevelCompensation = (UINT8)( pVqeConfig->fRinHighLevelCompensation & 0xFF );
2153
 
        pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb = (INT8)( pVqeConfig->lRinHighLevelCompensationThresholdDb & 0xFF );
2154
 
        pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction = (UINT8)( pVqeConfig->fSoutAdaptiveNoiseReduction & 0xFF );
2155
 
        pChanEntry->VqeConfig.fSoutNoiseBleaching = (UINT8)( pVqeConfig->fSoutNoiseBleaching & 0xFF );
2156
 
        pChanEntry->VqeConfig.fSoutConferencingNoiseReduction = (UINT8)( pVqeConfig->fSoutConferencingNoiseReduction & 0xFF );
2157
 
 
2158
 
        pChanEntry->VqeConfig.fAcousticEcho             = (UINT8)( pVqeConfig->fAcousticEcho & 0xFF );
2159
 
 
2160
 
        pChanEntry->VqeConfig.fDtmfToneRemoval  = (UINT8)( pVqeConfig->fDtmfToneRemoval & 0xFF );
2161
 
 
2162
 
        pChanEntry->VqeConfig.chDefaultErlDb    = (INT8)( pVqeConfig->lDefaultErlDb & 0xFF );
2163
 
        pChanEntry->VqeConfig.chAecDefaultErlDb = (INT8)( pVqeConfig->lAecDefaultErlDb & 0xFF );
2164
 
        pChanEntry->VqeConfig.usAecTailLength = (UINT16)( pVqeConfig->ulAecTailLength & 0xFFFF );
2165
 
        pChanEntry->VqeConfig.byNonLinearityBehaviorA = (UINT8)( pVqeConfig->ulNonLinearityBehaviorA & 0xFF );
2166
 
        pChanEntry->VqeConfig.byNonLinearityBehaviorB = (UINT8)( pVqeConfig->ulNonLinearityBehaviorB & 0xFF );
2167
 
        pChanEntry->VqeConfig.byDoubleTalkBehavior = (UINT8)( pVqeConfig->ulDoubleTalkBehavior & 0xFF );
2168
 
        pChanEntry->VqeConfig.chAnrSnrEnhancementDb     = (INT8)( pVqeConfig->lAnrSnrEnhancementDb & 0xFF );
2169
 
        pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation = (UINT8)( pVqeConfig->ulAnrVoiceNoiseSegregation & 0xFF );
2170
 
        pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay = (UINT16)( pVqeConfig->ulToneDisablerVqeActivationDelay & 0xFFFF );
2171
 
 
2172
 
        pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb = (UINT8)( pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb & 0xFF );
2173
 
        pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb = (UINT8)( pVqeConfig->ulSoutNaturalListenerEnhancementGainDb & 0xFF );
2174
 
        pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement = (UINT8)( pVqeConfig->fSoutNaturalListenerEnhancement & 0xFF );
2175
 
        pChanEntry->VqeConfig.fRoutNoiseReduction = (UINT8)( pVqeConfig->fRoutNoiseReduction & 0xFF );
2176
 
        pChanEntry->VqeConfig.fEnableMusicProtection = (UINT8)( pVqeConfig->fEnableMusicProtection & 0xFF );
2177
 
        pChanEntry->VqeConfig.fIdleCodeDetection = (UINT8)( pVqeConfig->fIdleCodeDetection & 0xFF );
2178
 
 
2179
 
        /* Save the codec information.*/
2180
 
        pChanEntry->CodecConfig.byAdpcmNibblePosition = (UINT8)( pCodecConfig->ulAdpcmNibblePosition & 0xFF );
2181
 
 
2182
 
        pChanEntry->CodecConfig.byDecoderPort = (UINT8)( pCodecConfig->ulDecoderPort & 0xFF );
2183
 
        pChanEntry->CodecConfig.byDecodingRate = (UINT8)( pCodecConfig->ulDecodingRate & 0xFF );
2184
 
        pChanEntry->CodecConfig.byEncoderPort = (UINT8)( pCodecConfig->ulEncoderPort & 0xFF );
2185
 
        pChanEntry->CodecConfig.byEncodingRate = (UINT8)( pCodecConfig->ulEncodingRate & 0xFF );
2186
 
        
2187
 
        pChanEntry->CodecConfig.fEnableSilenceSuppression = (UINT8)( pCodecConfig->fEnableSilenceSuppression & 0xFF );
2188
 
        pChanEntry->CodecConfig.byPhase = (UINT8)( pCodecConfig->ulPhase & 0xFF );
2189
 
        pChanEntry->CodecConfig.byPhasingType = (UINT8)( pCodecConfig->ulPhasingType & 0xFF );
2190
 
        
2191
 
        /* Save the RIN settings.*/
2192
 
        pChanEntry->TdmConfig.byRinPcmLaw = (UINT8)( pTdmConfig->ulRinPcmLaw & 0xFF );
2193
 
        pChanEntry->TdmConfig.usRinTimeslot = (UINT16)( pTdmConfig->ulRinTimeslot & 0xFFFF );
2194
 
        pChanEntry->TdmConfig.usRinStream = (UINT16)( pTdmConfig->ulRinStream & 0xFFFF );
2195
 
        
2196
 
        /* Save the SIN settings.*/
2197
 
        pChanEntry->TdmConfig.bySinPcmLaw = (UINT8)( pTdmConfig->ulSinPcmLaw & 0xFF );
2198
 
        pChanEntry->TdmConfig.usSinTimeslot = (UINT16)( pTdmConfig->ulSinTimeslot & 0xFFFF );
2199
 
        pChanEntry->TdmConfig.usSinStream = (UINT16)( pTdmConfig->ulSinStream & 0xFFFF );
2200
 
 
2201
 
        /* Save the ROUT settings.*/
2202
 
        pChanEntry->TdmConfig.byRoutPcmLaw = (UINT8)( pTdmConfig->ulRoutPcmLaw & 0xFF );
2203
 
        pChanEntry->TdmConfig.usRoutTimeslot = (UINT16)( pTdmConfig->ulRoutTimeslot & 0xFFFF );
2204
 
        pChanEntry->TdmConfig.usRoutStream = (UINT16)( pTdmConfig->ulRoutStream & 0xFFFF );
2205
 
 
2206
 
        pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
2207
 
        pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0;
2208
 
 
2209
 
        /* Save the SOUT settings.*/
2210
 
        pChanEntry->TdmConfig.bySoutPcmLaw = (UINT8)( pTdmConfig->ulSoutPcmLaw & 0xFF );
2211
 
        pChanEntry->TdmConfig.usSoutTimeslot = (UINT16)( pTdmConfig->ulSoutTimeslot & 0xFFFF );
2212
 
        pChanEntry->TdmConfig.usSoutStream = (UINT16)( pTdmConfig->ulSoutStream & 0xFFFF );
2213
 
 
2214
 
        pChanEntry->TdmConfig.byRinNumTssts = (UINT8)( pTdmConfig->ulRinNumTssts & 0xFF );
2215
 
        pChanEntry->TdmConfig.bySinNumTssts = (UINT8)( pTdmConfig->ulSinNumTssts & 0xFF );
2216
 
        pChanEntry->TdmConfig.byRoutNumTssts = (UINT8)( pTdmConfig->ulRoutNumTssts & 0xFF );
2217
 
        pChanEntry->TdmConfig.bySoutNumTssts = (UINT8)( pTdmConfig->ulSoutNumTssts & 0xFF );
2218
 
        pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
2219
 
        pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry = 0;
2220
 
 
2221
 
        /* Save the extended Tone detection information.*/
2222
 
        pChanEntry->usExtToneChanIndex          = f_pChanIndexConf->usExtToneChanIndex;
2223
 
        pChanEntry->usExtToneMixerIndex         = f_pChanIndexConf->usExtToneMixerIndex;
2224
 
        pChanEntry->usExtToneTsiIndex           = f_pChanIndexConf->usExtToneTsiIndex;
2225
 
 
2226
 
        if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
2227
 
        {
2228
 
                tPOCT6100_API_CHANNEL                   pExtToneChanEntry;
2229
 
 
2230
 
                /* Set the mode of the original channel. He is the channel performing detection on the
2231
 
                   SIN port.  The extended channel will perform detection on the RIN port.*/
2232
 
                pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_SIN_PORT_MODE;
2233
 
 
2234
 
                /* Now, program the associated channel.*/
2235
 
                
2236
 
                /* Obtain a pointer to the extended tone detection channel entry. */
2237
 
                mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pExtToneChanEntry, f_pChanIndexConf->usExtToneChanIndex );
2238
 
 
2239
 
                pExtToneChanEntry->fReserved                    = TRUE;
2240
 
                pExtToneChanEntry->ulExtToneChanMode    = cOCT6100_API_EXT_TONE_RIN_PORT_MODE;  /* Detect on RIN port.*/
2241
 
                pExtToneChanEntry->usExtToneChanIndex   = f_pChanIndexConf->usEchoChanIndex;
2242
 
 
2243
 
                pExtToneChanEntry->aulToneConf[ 0 ] = 0;
2244
 
                pExtToneChanEntry->aulToneConf[ 1 ] = 0;
2245
 
 
2246
 
        }
2247
 
        else
2248
 
        {
2249
 
                /* No extended tone detection supported.*/
2250
 
                pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED;
2251
 
        }
2252
 
 
2253
 
        /*=======================================================================*/
2254
 
 
2255
 
        /*=======================================================================*/
2256
 
        /* Store hardware related information.*/
2257
 
        pChanEntry->usRinRoutTsiMemIndex  = f_pChanIndexConf->usRinRoutTsiMemIndex;
2258
 
        pChanEntry->usSinSoutTsiMemIndex  = f_pChanIndexConf->usSinSoutTsiMemIndex;
2259
 
        pChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
2260
 
        pChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX;
2261
 
 
2262
 
        /* We are not being tapped for now. */
2263
 
        pChanEntry->fBeingTapped = FALSE;
2264
 
 
2265
 
        pChanEntry->usTapChanIndex = cOCT6100_INVALID_INDEX;
2266
 
        pChanEntry->usTapBridgeIndex = cOCT6100_INVALID_INDEX;
2267
 
 
2268
 
        /* The copy event has not yet been created. */
2269
 
        pChanEntry->fCopyEventCreated = FALSE;
2270
 
 
2271
 
        pChanEntry->usRinRoutConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
2272
 
        pChanEntry->usSinSoutConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
2273
 
 
2274
 
        pChanEntry->usPhasingTsstIndex = f_pChanIndexConf->usPhasingTsstIndex;
2275
 
 
2276
 
        pChanEntry->fSinSoutCodecActive = f_pChanIndexConf->fSinSoutCodecActive;
2277
 
        pChanEntry->fRinRoutCodecActive = f_pChanIndexConf->fRinRoutCodecActive;
2278
 
        
2279
 
 
2280
 
 
2281
 
        pChanEntry->usEchoMemIndex = f_pChanIndexConf->usEchoMemIndex;
2282
 
 
2283
 
        pChanEntry->usRinTsstIndex = f_pChanIndexConf->usRinTsstIndex;
2284
 
        pChanEntry->usSinTsstIndex = f_pChanIndexConf->usSinTsstIndex;
2285
 
        pChanEntry->usRoutTsstIndex = f_pChanIndexConf->usRoutTsstIndex;
2286
 
        pChanEntry->usSoutTsstIndex = f_pChanIndexConf->usSoutTsstIndex;
2287
 
 
2288
 
        pChanEntry->usSinCopyEventIndex         = cOCT6100_INVALID_INDEX;
2289
 
        pChanEntry->usSoutCopyEventIndex        = cOCT6100_INVALID_INDEX;
2290
 
 
2291
 
        /* Nothing muted for now. */
2292
 
        pChanEntry->usMutedPorts                        = cOCT6100_CHANNEL_MUTE_PORT_NONE;
2293
 
 
2294
 
        /* Set all the GW feature initial value.*/
2295
 
        /* Bridge info */
2296
 
        pChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
2297
 
        pChanEntry->fMute = FALSE;
2298
 
 
2299
 
        pChanEntry->usLoadEventIndex            = cOCT6100_INVALID_INDEX;
2300
 
        pChanEntry->usSubStoreEventIndex        = cOCT6100_INVALID_INDEX;
2301
 
 
2302
 
        /* Buffer playout info.*/
2303
 
        pChanEntry->fRinBufPlaying = FALSE;
2304
 
        pChanEntry->fSoutBufPlaying = FALSE;
2305
 
 
2306
 
        /* Tone detection state. */
2307
 
        /* This array is configured as follow.*/
2308
 
        /* Index 0 contain event 0 to 31 (msb = event 31) and Index 1 contain index 32 - 55  */
2309
 
        pChanEntry->aulToneConf[ 0 ] = 0;
2310
 
        pChanEntry->aulToneConf[ 1 ] = 0;
2311
 
        pChanEntry->ulLastSSToneDetected = cOCT6100_INVALID_VALUE;
2312
 
        pChanEntry->ulLastSSToneTimestamp = cOCT6100_INVALID_VALUE;
2313
 
 
2314
 
        /* Initialize the bidirectional flag.*/
2315
 
        pChanEntry->fBiDirChannel = FALSE;
2316
 
 
2317
 
        /*=======================================================================*/
2318
 
        /* Init some of the stats.*/
2319
 
 
2320
 
        pChanEntry->sMaxERL                                             = cOCT6100_INVALID_SIGNED_STAT_W;
2321
 
        pChanEntry->sMaxERLE                                    = cOCT6100_INVALID_SIGNED_STAT_W;
2322
 
        pChanEntry->usMaxEchoDelay                              = cOCT6100_INVALID_STAT_W;
2323
 
        pChanEntry->usNumEchoPathChangesOfst    = 0;
2324
 
 
2325
 
        /*=======================================================================*/
2326
 
 
2327
 
        /*=======================================================================*/
2328
 
        /* Update the dependency of the phasing TSST if one is associated to the chanel.*/
2329
 
 
2330
 
        if ( f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
2331
 
        {
2332
 
                tPOCT6100_API_PHASING_TSST      pPhasingEntry;
2333
 
 
2334
 
                mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanIndexConf->usPhasingTsstIndex );
2335
 
 
2336
 
                pPhasingEntry->usDependencyCnt++;
2337
 
        }
2338
 
        /*=======================================================================*/
2339
 
 
2340
 
        /*=======================================================================*/
2341
 
        
2342
 
        /* Form handle returned to user. */
2343
 
        *f_pChannelOpen->pulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_pChanIndexConf->usEchoChanIndex;
2344
 
 
2345
 
        /* Finally, mark the channel as open. */
2346
 
        pChanEntry->fReserved = TRUE;
2347
 
        pChanEntry->usExtraSinTsiDependencyCnt = 0;
2348
 
        
2349
 
        /* Increment the number of channel open.*/
2350
 
        f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels++;
2351
 
 
2352
 
        /*=======================================================================*/
2353
 
 
2354
 
        return cOCT6100_ERR_OK;
2355
 
}
2356
 
 
2357
 
 
2358
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2359
 
 
2360
 
Function:               Oct6100ChannelModifySer
2361
 
 
2362
 
Description:    Modify an echo cancellation channel.
2363
 
 
2364
 
-------------------------------------------------------------------------------
2365
 
|       Argument                |       Description
2366
 
-------------------------------------------------------------------------------
2367
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
2368
 
                                                present state of the chip and all its resources.
2369
 
 
2370
 
f_pChannelModify                Pointer to channel configuration structure.  The handle
2371
 
                                                identifying the buffer in all future function calls is
2372
 
                                                returned in this structure.
2373
 
 
2374
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2375
 
static UINT32 Oct6100ChannelModifySer(
2376
 
                                IN              tPOCT6100_INSTANCE_API                                  f_pApiInstance,
2377
 
                                IN OUT  tPOCT6100_CHANNEL_MODIFY                                f_pChannelModify )
2378
 
{
2379
 
        UINT16  usChanIndex;
2380
 
        UINT32  ulResult;
2381
 
        UINT16  usNewRinTsstIndex;
2382
 
        UINT16  usNewSinTsstIndex;
2383
 
        UINT16  usNewRoutTsstIndex;
2384
 
        UINT16  usNewSoutTsstIndex;
2385
 
        UINT8   fSinSoutCodecActive = FALSE;
2386
 
        UINT8   fRinRoutCodecActive = FALSE;
2387
 
        UINT16  usNewPhasingTsstIndex;
2388
 
        tOCT6100_CHANNEL_OPEN   *pTempChanOpen;
2389
 
 
2390
 
        /* We don't want this 290 byte structure on the stack */
2391
 
        pTempChanOpen = (tOCT6100_CHANNEL_OPEN *)kmalloc(sizeof(tOCT6100_CHANNEL_OPEN),GFP_ATOMIC);
2392
 
        if(!pTempChanOpen)
2393
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
2394
 
 
2395
 
        /* Check the user's configuration of the echo cancellation channel for errors. */
2396
 
        ulResult = Oct6100ApiCheckChannelModify( f_pApiInstance, 
2397
 
                                                                                         f_pChannelModify, 
2398
 
                                                                                         pTempChanOpen, 
2399
 
                                                                                         &usNewPhasingTsstIndex,
2400
 
                                                                                         &usChanIndex );
2401
 
        if ( ulResult != cOCT6100_ERR_OK  )
2402
 
                return ulResult;
2403
 
 
2404
 
        /* Reserve all resources needed by the echo cancellation channel. */
2405
 
        ulResult = Oct6100ApiModifyChannelResources( f_pApiInstance, 
2406
 
                                                                                                 f_pChannelModify, 
2407
 
                                                                                                 usChanIndex, 
2408
 
                                                                                                 &usNewRinTsstIndex, 
2409
 
                                                                                                 &usNewSinTsstIndex, 
2410
 
                                                                                                 &usNewRoutTsstIndex, 
2411
 
                                                                                                 &usNewSoutTsstIndex );
2412
 
        if ( ulResult != cOCT6100_ERR_OK  )
2413
 
                return ulResult;
2414
 
 
2415
 
        /* Write all necessary structures to activate the echo cancellation channel. */
2416
 
        ulResult = Oct6100ApiModifyChannelStructs( f_pApiInstance, 
2417
 
                                                                                           f_pChannelModify, 
2418
 
                                                                                           pTempChanOpen, 
2419
 
                                                                                           usChanIndex, 
2420
 
                                                                                           usNewPhasingTsstIndex,
2421
 
                                                                                           &fSinSoutCodecActive,
2422
 
                                                                                           &fRinRoutCodecActive,
2423
 
                                                                                           usNewRinTsstIndex, 
2424
 
                                                                                           usNewSinTsstIndex, 
2425
 
                                                                                           usNewRoutTsstIndex, 
2426
 
                                                                                           usNewSoutTsstIndex );
2427
 
        if ( ulResult != cOCT6100_ERR_OK  )
2428
 
                return ulResult;
2429
 
 
2430
 
        /* Update the new echo cancellation channels's entry in the ECHO channel list. */
2431
 
        ulResult = Oct6100ApiModifyChannelEntry( f_pApiInstance, 
2432
 
                                                                                         f_pChannelModify, 
2433
 
                                                                                         pTempChanOpen, 
2434
 
                                                                                         usChanIndex,  
2435
 
                                                                                         usNewPhasingTsstIndex,
2436
 
                                                                                         fSinSoutCodecActive,
2437
 
                                                                                         fRinRoutCodecActive,
2438
 
                                                                                         usNewRinTsstIndex, 
2439
 
                                                                                         usNewSinTsstIndex, 
2440
 
                                                                                         usNewRoutTsstIndex, 
2441
 
                                                                                         usNewSoutTsstIndex  );
2442
 
        if ( ulResult != cOCT6100_ERR_OK  )
2443
 
                return ulResult;
2444
 
        
2445
 
        kfree(pTempChanOpen);
2446
 
 
2447
 
        return cOCT6100_ERR_OK;
2448
 
}
2449
 
 
2450
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2451
 
 
2452
 
Function:               Oct6100ApiCheckChannelModify
2453
 
 
2454
 
Description:    Checks the user's echo cancellation channel modify structure for errors.
2455
 
 
2456
 
-------------------------------------------------------------------------------
2457
 
|       Argument                |       Description
2458
 
-------------------------------------------------------------------------------
2459
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
2460
 
                                                present state of the chip and all its resources.
2461
 
 
2462
 
f_pChannelModify                Pointer to echo cancellation channel modify structure.
2463
 
f_pTempChanOpen                 Pointer to a channel open structure.
2464
 
f_pusNewPhasingTsstIndex        Pointer to a new phasing TSST index within the API instance.
2465
 
f_pusChanIndex                  Pointer to the channel index within the API instance channel list
2466
 
 
2467
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2468
 
static UINT32 Oct6100ApiCheckChannelModify(
2469
 
                                IN              tPOCT6100_INSTANCE_API                                  f_pApiInstance,
2470
 
                                IN OUT  tPOCT6100_CHANNEL_MODIFY                                f_pChannelModify,
2471
 
                                IN              tPOCT6100_CHANNEL_OPEN                                  f_pTempChanOpen,
2472
 
                                OUT             PUINT16                                                                 f_pusNewPhasingTsstIndex,
2473
 
                                OUT             PUINT16                                                                 f_pusChanIndex )
2474
 
{
2475
 
        tPOCT6100_API_CHANNEL           pChanEntry;
2476
 
        UINT32  ulResult;
2477
 
        UINT32  ulEntryOpenCnt;
2478
 
        UINT32  ulDecoderNumTssts;
2479
 
 
2480
 
        /* Check the provided handle. */
2481
 
        if ( (f_pChannelModify->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
2482
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2483
 
 
2484
 
        *f_pusChanIndex = (UINT16)( f_pChannelModify->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
2485
 
        if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
2486
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2487
 
 
2488
 
        /*=======================================================================*/
2489
 
        /* Get a pointer to the channel's list entry. */
2490
 
 
2491
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
2492
 
 
2493
 
        /* Extract the entry open count from the provided handle. */
2494
 
        ulEntryOpenCnt = ( f_pChannelModify->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
2495
 
 
2496
 
        /* Check for errors. */
2497
 
        if ( pChanEntry->fReserved != TRUE )
2498
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
2499
 
        if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
2500
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
2501
 
 
2502
 
        /*=======================================================================*/
2503
 
 
2504
 
 
2505
 
        /*=======================================================================*/
2506
 
        /* Check the general modify parameters. */
2507
 
        
2508
 
        if ( f_pChannelModify->ulEchoOperationMode != cOCT6100_KEEP_PREVIOUS_SETTING &&
2509
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NORMAL &&
2510
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_FREEZE &&
2511
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_HT_RESET &&
2512
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_POWER_DOWN &&
2513
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL &&
2514
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION &&
2515
 
                 f_pChannelModify->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
2516
 
                return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE;
2517
 
 
2518
 
        /* Check the 2100Hz echo disabling configuration.*/
2519
 
        if ( f_pChannelModify->fEnableToneDisabler != cOCT6100_KEEP_PREVIOUS_SETTING &&
2520
 
                 f_pChannelModify->fEnableToneDisabler != TRUE && 
2521
 
                 f_pChannelModify->fEnableToneDisabler != FALSE )
2522
 
                return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ENABLE;
2523
 
 
2524
 
        /* Check the disable tone detection flag. */
2525
 
        if ( f_pChannelModify->fDisableToneDetection != TRUE &&
2526
 
                f_pChannelModify->fDisableToneDetection != FALSE )
2527
 
                return cOCT6100_ERR_CHANNEL_DISABLE_TONE_DETECTION;
2528
 
 
2529
 
        /* Check the stop buffer playout flag. */
2530
 
        if ( f_pChannelModify->fStopBufferPlayout != TRUE &&
2531
 
                f_pChannelModify->fStopBufferPlayout != FALSE )
2532
 
                return cOCT6100_ERR_CHANNEL_STOP_BUFFER_PLAYOUT;
2533
 
 
2534
 
        /* Check the remove conference bridge participant flag. */
2535
 
        if ( f_pChannelModify->fRemoveConfBridgeParticipant != TRUE &&
2536
 
                f_pChannelModify->fRemoveConfBridgeParticipant != FALSE )
2537
 
                return cOCT6100_ERR_CHANNEL_REMOVE_CONF_BRIDGE_PARTICIPANT;
2538
 
 
2539
 
        /* Check the remove broadcast timeslots flag. */
2540
 
        if ( f_pChannelModify->fRemoveBroadcastTssts != TRUE &&
2541
 
                f_pChannelModify->fRemoveBroadcastTssts != FALSE )
2542
 
                return cOCT6100_ERR_CHANNEL_REMOVE_BROADCAST_TSSTS;
2543
 
 
2544
 
        if ( f_pChannelModify->fCodecConfigModified != TRUE && 
2545
 
                 f_pChannelModify->fCodecConfigModified != FALSE )
2546
 
                return cOCT6100_ERR_CHANNEL_MODIFY_CODEC_CONFIG;
2547
 
 
2548
 
        if ( f_pChannelModify->fVqeConfigModified != TRUE && 
2549
 
                 f_pChannelModify->fVqeConfigModified != FALSE )
2550
 
                return cOCT6100_ERR_CHANNEL_MODIFY_VQE_CONFIG;
2551
 
 
2552
 
        if ( f_pChannelModify->fTdmConfigModified != TRUE && 
2553
 
                 f_pChannelModify->fTdmConfigModified != FALSE )
2554
 
                return cOCT6100_ERR_CHANNEL_MODIFY_TDM_CONFIG;
2555
 
 
2556
 
        /*=======================================================================*/
2557
 
 
2558
 
        /*=======================================================================*/
2559
 
        /* Verify if any law change was requested. If so reprogram all structures.*/
2560
 
 
2561
 
        if (( f_pChannelModify->fTdmConfigModified == TRUE ) &&
2562
 
                ( f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
2563
 
                  f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
2564
 
                  f_pChannelModify->TdmConfig.ulRoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ||
2565
 
                  f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING ))
2566
 
        {
2567
 
                f_pChannelModify->fVqeConfigModified = TRUE;
2568
 
                f_pChannelModify->fCodecConfigModified = TRUE;
2569
 
        }
2570
 
        /*=======================================================================*/
2571
 
        
2572
 
        ulResult = Oct6100ApiUpdateOpenStruct( f_pApiInstance, f_pChannelModify, f_pTempChanOpen, pChanEntry );
2573
 
        if ( ulResult != cOCT6100_ERR_OK )
2574
 
                return ulResult;
2575
 
 
2576
 
        /* All further check will now be performed using the TempOpenChan structure in order
2577
 
           to reuse the checks written for the open channel structure.*/
2578
 
        
2579
 
 
2580
 
 
2581
 
        /* Check the TDM config.*/
2582
 
        if ( f_pChannelModify->fTdmConfigModified == TRUE )
2583
 
        {
2584
 
                tPOCT6100_CHANNEL_MODIFY_TDM            pModifyTdm;
2585
 
                tPOCT6100_CHANNEL_OPEN_TDM                      pOpenTdm;
2586
 
 
2587
 
                pModifyTdm = &f_pChannelModify->TdmConfig;
2588
 
                pOpenTdm = &f_pTempChanOpen->TdmConfig;
2589
 
 
2590
 
                ulResult = Oct6100ApiCheckTdmConfig( f_pApiInstance,
2591
 
                                                                                         pOpenTdm );
2592
 
                if ( ulResult != cOCT6100_ERR_OK )
2593
 
                        return ulResult;
2594
 
 
2595
 
                /* Check if that Stream and Timeslot values are valid.*/
2596
 
                
2597
 
                /* Check the RIN port.*/
2598
 
                if ( f_pChannelModify->TdmConfig.ulRinStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
2599
 
                        f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2600
 
                        return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
2601
 
 
2602
 
                if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2603
 
                        f_pChannelModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
2604
 
                        return cOCT6100_ERR_CHANNEL_RIN_STREAM;
2605
 
                 
2606
 
                if ( pChanEntry->fBeingTapped == TRUE )
2607
 
                {
2608
 
                        /* Check that the Rin stream + timeslot are not being assigned. */
2609
 
                        if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING )
2610
 
                        {
2611
 
                                if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_UNASSIGNED )
2612
 
                                        return cOCT6100_ERR_CHANNEL_RIN_STREAM;
2613
 
 
2614
 
                                if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
2615
 
                                        return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
2616
 
                        }
2617
 
                }
2618
 
 
2619
 
                /* Check the SIN port.*/
2620
 
                if ( f_pChannelModify->TdmConfig.ulSinStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
2621
 
                        f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2622
 
                        return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT;
2623
 
 
2624
 
                if ( f_pChannelModify->TdmConfig.ulSinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2625
 
                        f_pChannelModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
2626
 
                        return cOCT6100_ERR_CHANNEL_SIN_STREAM;
2627
 
 
2628
 
                /* Check the ROUT port.*/
2629
 
                if ( f_pChannelModify->TdmConfig.ulRoutStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
2630
 
                        f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2631
 
                        return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT;
2632
 
 
2633
 
                if ( f_pChannelModify->TdmConfig.ulRoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2634
 
                        f_pChannelModify->TdmConfig.ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
2635
 
                        return cOCT6100_ERR_CHANNEL_ROUT_STREAM;
2636
 
 
2637
 
                /* Check the SOUT port.*/
2638
 
                if ( f_pChannelModify->TdmConfig.ulSoutStream == cOCT6100_KEEP_PREVIOUS_SETTING &&
2639
 
                        f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2640
 
                        return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
2641
 
 
2642
 
                if ( f_pChannelModify->TdmConfig.ulSoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2643
 
                        f_pChannelModify->TdmConfig.ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
2644
 
                        return cOCT6100_ERR_CHANNEL_SOUT_STREAM;
2645
 
 
2646
 
                /* Verify if the channel is currently part of a bidirectional channel, and if */
2647
 
                /* so perform the required checks. */
2648
 
                if ( pChanEntry->fBiDirChannel == TRUE )
2649
 
                {
2650
 
                        /* Check the ports that must remain unassigned.*/
2651
 
                        if ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
2652
 
                                return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
2653
 
                        if ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED )
2654
 
                                return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
2655
 
                        
2656
 
                        /* Check that no PCM law change is requested.*/
2657
 
                        if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
2658
 
                                return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
2659
 
                        if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
2660
 
                                return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
2661
 
                }
2662
 
 
2663
 
                /* If this channel is on a conference bridge, a few more things must be checked. */
2664
 
                if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
2665
 
                {
2666
 
                        /* If conferencing, law conversion cannot be applied. */
2667
 
                        /* This check is done only if both input and output ports are assigned. */
2668
 
                        if ( ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
2669
 
                                && ( f_pTempChanOpen->TdmConfig.ulRoutTimeslot != cOCT6100_UNASSIGNED ) )
2670
 
                        {
2671
 
                                /* Laws must be the same! */
2672
 
                                if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
2673
 
                                        return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
2674
 
                        }
2675
 
 
2676
 
                        /* Check for Sin. */
2677
 
                        if ( ( f_pTempChanOpen->TdmConfig.ulSinTimeslot != cOCT6100_UNASSIGNED )
2678
 
                                && ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED ) )
2679
 
                        {
2680
 
                                /* Laws must be the same! */
2681
 
                                if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
2682
 
                                        return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
2683
 
                        }
2684
 
 
2685
 
                        /* Check if ADPCM is requested. */
2686
 
                        if ( f_pTempChanOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING &&
2687
 
                                 f_pTempChanOpen->CodecConfig.ulEncodingRate != cOCT6100_G711_64KBPS )
2688
 
                        {
2689
 
                                /* No ADPCM in a conference bridge! */
2690
 
                                return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
2691
 
                        }
2692
 
 
2693
 
                        if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING &&
2694
 
                                 f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS )
2695
 
                        {
2696
 
                                /* No ADPCM in a conference bridge! */
2697
 
                                return cOCT6100_ERR_CHANNEL_DECODING_RATE;
2698
 
                        }
2699
 
                }
2700
 
 
2701
 
                if ( f_pTempChanOpen->CodecConfig.ulEncoderPort == cOCT6100_NO_ENCODING || 
2702
 
                        f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_NO_DECODING )
2703
 
                {
2704
 
                        /* Make sure no law conversion is attempted since it is not supported by the device.*/
2705
 
                        if ( f_pTempChanOpen->TdmConfig.ulRinPcmLaw != f_pTempChanOpen->TdmConfig.ulRoutPcmLaw )
2706
 
                                return cOCT6100_ERR_CHANNEL_RIN_ROUT_LAW_CONVERSION;
2707
 
                        if ( f_pTempChanOpen->TdmConfig.ulSinPcmLaw != f_pTempChanOpen->TdmConfig.ulSoutPcmLaw )
2708
 
                                return cOCT6100_ERR_CHANNEL_SIN_SOUT_LAW_CONVERSION;
2709
 
                }
2710
 
 
2711
 
                if ( pChanEntry->fEnableExtToneDetection == TRUE && 
2712
 
                         f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
2713
 
                        return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT;
2714
 
 
2715
 
                /* A few special checks must be done if the configuration is to be applied */
2716
 
                /* to all opened channels. */
2717
 
                if ( f_pChannelModify->fApplyToAllChannels == TRUE )
2718
 
                {
2719
 
                        /* When the configuration to be applied is for all channels, */
2720
 
                        /* check that the stream and timeslot parameters are not being assigned. */
2721
 
 
2722
 
                        /* Check the Rout port. */
2723
 
                        if ( f_pChannelModify->TdmConfig.ulRoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2724
 
                                f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2725
 
                        {
2726
 
                                /* Check that the Rout ports is being unassigned. */
2727
 
                                if ( f_pTempChanOpen->TdmConfig.ulRoutStream != cOCT6100_UNASSIGNED )
2728
 
                                        return cOCT6100_ERR_CHANNEL_ROUT_STREAM_UNASSIGN;
2729
 
                                if ( f_pTempChanOpen->TdmConfig.ulRoutTimeslot != cOCT6100_UNASSIGNED )
2730
 
                                        return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT_UNASSIGN;
2731
 
                        }
2732
 
 
2733
 
                        /* Check the Rin port. */
2734
 
                        if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2735
 
                                f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2736
 
                        {
2737
 
                                /* Check that the Rin ports is being unassigned. */
2738
 
                                if ( f_pTempChanOpen->TdmConfig.ulRinStream != cOCT6100_UNASSIGNED )
2739
 
                                        return cOCT6100_ERR_CHANNEL_RIN_STREAM_UNASSIGN;
2740
 
                                if ( f_pTempChanOpen->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
2741
 
                                        return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT_UNASSIGN;
2742
 
                        }
2743
 
 
2744
 
                        /* Check the Sout port. */
2745
 
                        if ( f_pChannelModify->TdmConfig.ulSoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2746
 
                                f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2747
 
                        {
2748
 
                                /* Check that the Sout ports is being unassigned. */
2749
 
                                if ( f_pTempChanOpen->TdmConfig.ulSoutStream != cOCT6100_UNASSIGNED )
2750
 
                                        return cOCT6100_ERR_CHANNEL_SOUT_STREAM_UNASSIGN;
2751
 
                                if ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED )
2752
 
                                        return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT_UNASSIGN;
2753
 
                        }
2754
 
 
2755
 
                        /* Check the Sin port. */
2756
 
                        if ( f_pChannelModify->TdmConfig.ulSinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2757
 
                                f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2758
 
                        {
2759
 
                                /* Check that the Sin ports is being unassigned. */
2760
 
                                if ( f_pTempChanOpen->TdmConfig.ulSinStream != cOCT6100_UNASSIGNED )
2761
 
                                        return cOCT6100_ERR_CHANNEL_SIN_STREAM_UNASSIGN;
2762
 
                                if ( f_pTempChanOpen->TdmConfig.ulSinTimeslot != cOCT6100_UNASSIGNED )
2763
 
                                        return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT_UNASSIGN;
2764
 
                        }
2765
 
                }
2766
 
        }
2767
 
 
2768
 
        /* Check the VQE config.*/
2769
 
        if ( f_pChannelModify->fVqeConfigModified == TRUE )
2770
 
        {
2771
 
                ulResult = Oct6100ApiCheckVqeConfig( f_pApiInstance,
2772
 
                                                                                         &f_pTempChanOpen->VqeConfig,
2773
 
                                                                                         f_pTempChanOpen->fEnableToneDisabler );
2774
 
                if ( ulResult != cOCT6100_ERR_OK )
2775
 
                        return ulResult;
2776
 
        }
2777
 
 
2778
 
        /* Verify if the echo operation mode selected can be applied. */
2779
 
        if ( ( f_pTempChanOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
2780
 
                && ( f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE ) )
2781
 
                return cOCT6100_ERR_CHANNEL_ECHO_OP_MODE_NLP_REQUIRED;
2782
 
 
2783
 
        /* Check the Codec config.*/
2784
 
        if ( f_pChannelModify->fCodecConfigModified == TRUE )
2785
 
        {
2786
 
                if ( f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
2787
 
                        ulDecoderNumTssts = f_pTempChanOpen->TdmConfig.ulRinNumTssts;
2788
 
                else /* f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
2789
 
                        ulDecoderNumTssts  = f_pTempChanOpen->TdmConfig.ulSinNumTssts;
2790
 
 
2791
 
                ulResult = Oct6100ApiCheckCodecConfig( f_pApiInstance,
2792
 
                                                                                           &f_pTempChanOpen->CodecConfig,
2793
 
                                                                                           ulDecoderNumTssts,
2794
 
                                                                                           f_pusNewPhasingTsstIndex );
2795
 
                if ( ulResult != cOCT6100_ERR_OK )
2796
 
                        return ulResult;
2797
 
 
2798
 
 
2799
 
 
2800
 
                /* make sure that if silence suppression is activated, the NLP is enabled.*/
2801
 
                if ( f_pTempChanOpen->CodecConfig.fEnableSilenceSuppression == TRUE && f_pTempChanOpen->VqeConfig.fEnableNlp == FALSE )
2802
 
                        return cOCT6100_ERR_CHANNEL_SIL_SUP_NLP_MUST_BE_ENABLED;
2803
 
 
2804
 
                /* Verify if the channel is currently part of a bidirectional channel, and if so perform
2805
 
                    the required checks.*/
2806
 
                if ( pChanEntry->fBiDirChannel == TRUE )
2807
 
                {
2808
 
                        /* Check the ports that must remain unassigned.*/
2809
 
                        if ( f_pTempChanOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING && 
2810
 
                                 f_pTempChanOpen->CodecConfig.ulEncodingRate != cOCT6100_G711_64KBPS )
2811
 
                                return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
2812
 
 
2813
 
                        if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING && 
2814
 
                                 f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS )
2815
 
                                return cOCT6100_ERR_CHANNEL_DECODING_RATE;
2816
 
                }
2817
 
 
2818
 
        }
2819
 
        /*=======================================================================*/
2820
 
 
2821
 
        return cOCT6100_ERR_OK;
2822
 
}
2823
 
 
2824
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2825
 
 
2826
 
Function:               Oct6100ApiModifyChannelResources
2827
 
 
2828
 
Description:    Reserves any new resources needed for the channel
2829
 
-------------------------------------------------------------------------------
2830
 
|       Argument                |       Description
2831
 
-------------------------------------------------------------------------------
2832
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
2833
 
                                                present state of the chip and all its resources.
2834
 
        
2835
 
f_pChannelModify                Pointer to echo cancellation channel configuration structure.
2836
 
f_usChanIndex                   Allocated entry in ECHO channel list.
2837
 
 
2838
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2839
 
static UINT32 Oct6100ApiModifyChannelResources( 
2840
 
                                IN  tPOCT6100_INSTANCE_API                              f_pApiInstance,
2841
 
                                IN  tPOCT6100_CHANNEL_MODIFY                    f_pChannelModify,
2842
 
                                IN      UINT16                                                          f_usChanIndex,
2843
 
                                OUT     PUINT16                                                         f_pusNewRinTsstIndex,
2844
 
                                OUT     PUINT16                                                         f_pusNewSinTsstIndex,
2845
 
                                OUT     PUINT16                                                         f_pusNewRoutTsstIndex,
2846
 
                                OUT     PUINT16                                                         f_pusNewSoutTsstIndex )
2847
 
{
2848
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
2849
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
2850
 
 
2851
 
        tPOCT6100_API_CHANNEL_TDM               pApiTdmConf;
2852
 
        tPOCT6100_CHANNEL_MODIFY_TDM    pModifyTdmConf;
2853
 
 
2854
 
        UINT32  ulResult = cOCT6100_ERR_OK;
2855
 
        UINT32  ulTempVar = cOCT6100_ERR_OK;
2856
 
        UINT32  ulFreeMixerEventCnt;
2857
 
        
2858
 
        BOOL    fRinReleased = FALSE;
2859
 
        BOOL    fSinReleased = FALSE;
2860
 
        BOOL    fRoutReleased = FALSE;
2861
 
        BOOL    fSoutReleased = FALSE;
2862
 
 
2863
 
        BOOL    fRinReserved = FALSE;
2864
 
        BOOL    fSinReserved = FALSE;
2865
 
        BOOL    fRoutReserved = FALSE;
2866
 
        BOOL    fSoutReserved = FALSE;
2867
 
 
2868
 
        BOOL    fReserveRin = FALSE;
2869
 
        BOOL    fReserveSin = FALSE;
2870
 
        BOOL    fReserveRout = FALSE;
2871
 
        BOOL    fReserveSout = FALSE;
2872
 
 
2873
 
        BOOL    fRinRoutConversionMemReserved = FALSE;
2874
 
        BOOL    fSinSoutConversionMemReserved = FALSE;
2875
 
 
2876
 
 
2877
 
        UINT32  ulRinNumTssts = 1;
2878
 
        UINT32  ulSinNumTssts = 1;
2879
 
        UINT32  ulRoutNumTssts = 1;
2880
 
        UINT32  ulSoutNumTssts = 1;
2881
 
 
2882
 
        /* Obtain local pointer to shared portion of instance. */
2883
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
2884
 
 
2885
 
        /* Obtain local pointer to the TDM configuration structure of the tPOCT6100_CHANNEL_MODIFY structure. */
2886
 
        pModifyTdmConf   = &f_pChannelModify->TdmConfig;
2887
 
 
2888
 
        /*=======================================================================*/
2889
 
        /* Get a pointer to the channel's list entry. */
2890
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
2891
 
 
2892
 
        /* Obtain local pointer to the TDM configuration structure of the tPOCT6100_API_CHANNEL structure. */
2893
 
        pApiTdmConf   = &pChanEntry->TdmConfig;
2894
 
 
2895
 
        /*===============================================================================*/
2896
 
        /* Modify TSST resources if required.*/
2897
 
        if ( f_pChannelModify->fTdmConfigModified == TRUE )
2898
 
        {
2899
 
                /* First release any entry that need to be released.*/
2900
 
                if ( ( pModifyTdmConf->ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2901
 
                        || ( pModifyTdmConf->ulRinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) 
2902
 
                        )
2903
 
                {
2904
 
                        if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
2905
 
                        {
2906
 
                                /* Release the previously reserved entry.*/
2907
 
                                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
2908
 
                                                                                                  pChanEntry->TdmConfig.usRinTimeslot,
2909
 
                                                                                                  pChanEntry->TdmConfig.usRinStream, 
2910
 
                                                                                                  pChanEntry->TdmConfig.byRinNumTssts, 
2911
 
                                                                                                  cOCT6100_INPUT_TSST,
2912
 
                                                                                                  cOCT6100_INVALID_INDEX );
2913
 
                                if ( ulResult == cOCT6100_ERR_OK  )
2914
 
                                {
2915
 
                                        fRinReleased = TRUE;
2916
 
                                }
2917
 
                        }
2918
 
 
2919
 
                        fReserveRin = TRUE;
2920
 
                }
2921
 
 
2922
 
                /* Release SIN port.*/
2923
 
                if ( ( ulResult == cOCT6100_ERR_OK ) 
2924
 
                        && ( ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2925
 
                                || ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
2926
 
                                ) )
2927
 
                {
2928
 
                        if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
2929
 
                        {
2930
 
                                /* Release the previously reserved entry.*/
2931
 
                                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
2932
 
                                                                                                  pChanEntry->TdmConfig.usSinTimeslot,
2933
 
                                                                                                  pChanEntry->TdmConfig.usSinStream, 
2934
 
                                                                                                  pChanEntry->TdmConfig.bySinNumTssts, 
2935
 
                                                                                                  cOCT6100_INPUT_TSST,
2936
 
                                                                                                  cOCT6100_INVALID_INDEX );
2937
 
                                if ( ulResult == cOCT6100_ERR_OK  )
2938
 
                                {
2939
 
                                        fSinReleased = TRUE;
2940
 
                                }
2941
 
                        }
2942
 
 
2943
 
                        fReserveSin = TRUE;
2944
 
                }
2945
 
 
2946
 
                /* Release ROUT port.*/
2947
 
                if ( ( ulResult == cOCT6100_ERR_OK ) 
2948
 
                        && ( ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2949
 
                                || ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) 
2950
 
                                ) )
2951
 
                {
2952
 
                        if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
2953
 
                        {
2954
 
                                /* Release the previously reserved entry.*/
2955
 
                                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
2956
 
                                                                                                  pChanEntry->TdmConfig.usRoutTimeslot,
2957
 
                                                                                                  pChanEntry->TdmConfig.usRoutStream, 
2958
 
                                                                                                  pChanEntry->TdmConfig.byRoutNumTssts, 
2959
 
                                                                                                  cOCT6100_OUTPUT_TSST,
2960
 
                                                                                                  cOCT6100_INVALID_INDEX );
2961
 
                                if ( ulResult == cOCT6100_ERR_OK  )
2962
 
                                {
2963
 
                                        fRoutReleased = TRUE;
2964
 
                                }
2965
 
                        }
2966
 
 
2967
 
                        fReserveRout = TRUE;
2968
 
                }
2969
 
 
2970
 
                /* Release the SOUT port.*/
2971
 
                if ( ( ulResult == cOCT6100_ERR_OK ) 
2972
 
                        && ( ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2973
 
                                || ( pModifyTdmConf->ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) 
2974
 
                                ) )
2975
 
                {
2976
 
                        if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
2977
 
                        {
2978
 
                                /* Release the previously reserved entry.*/
2979
 
                                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
2980
 
                                                                                                  pChanEntry->TdmConfig.usSoutTimeslot,
2981
 
                                                                                                  pChanEntry->TdmConfig.usSoutStream, 
2982
 
                                                                                                  pChanEntry->TdmConfig.bySoutNumTssts, 
2983
 
                                                                                                  cOCT6100_OUTPUT_TSST,
2984
 
                                                                                                  cOCT6100_INVALID_INDEX );
2985
 
                                if ( ulResult == cOCT6100_ERR_OK  )
2986
 
                                {
2987
 
                                        fSoutReleased = TRUE;
2988
 
                                }
2989
 
                        }
2990
 
 
2991
 
                        fReserveSout = TRUE;
2992
 
                }
2993
 
 
2994
 
                /* Now reserve any new entry required.*/
2995
 
                
2996
 
                /* Modify RIN port.*/
2997
 
                if ( ( fReserveRin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
2998
 
                {
2999
 
                        if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_UNASSIGNED )
3000
 
                        {
3001
 
                                /* Check what number of TSSTs should be reserved this time. */
3002
 
                                if ( pModifyTdmConf->ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
3003
 
                                {
3004
 
                                        ulRinNumTssts = pApiTdmConf->byRinNumTssts;
3005
 
                                }
3006
 
                                else /* if ( pModifyTdmConf->ulRinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3007
 
                                {
3008
 
                                        /* New number of TSSTs. */
3009
 
                                        ulRinNumTssts = pModifyTdmConf->ulRinNumTssts;
3010
 
                                }
3011
 
 
3012
 
                                if ( pModifyTdmConf->ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3013
 
                                {
3014
 
                                        /* Reserve the new number of TSSTs. */
3015
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
3016
 
                                                                                                  pApiTdmConf->usRinTimeslot, 
3017
 
                                                                                                  pApiTdmConf->usRinStream, 
3018
 
                                                                                                  ulRinNumTssts, 
3019
 
                                                                                                  cOCT6100_INPUT_TSST,
3020
 
                                                                                                  f_pusNewRinTsstIndex, 
3021
 
                                                                                                  NULL );
3022
 
                                }
3023
 
                                else /* if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3024
 
                                {
3025
 
                                        /* Reserve the new TSST.*/
3026
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
3027
 
                                                                                                  pModifyTdmConf->ulRinTimeslot, 
3028
 
                                                                                                  pModifyTdmConf->ulRinStream, 
3029
 
                                                                                                  ulRinNumTssts, 
3030
 
                                                                                                  cOCT6100_INPUT_TSST,
3031
 
                                                                                                  f_pusNewRinTsstIndex, 
3032
 
                                                                                                  NULL );
3033
 
                                        if ( ulResult == cOCT6100_ERR_OK  )
3034
 
                                        {
3035
 
                                                fRinReserved = TRUE;
3036
 
                                        }
3037
 
                                }
3038
 
                        }
3039
 
                        else
3040
 
                        {
3041
 
                                *f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX;
3042
 
                        }
3043
 
                }
3044
 
                else
3045
 
                {
3046
 
                        *f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX;
3047
 
                }
3048
 
 
3049
 
                /* Modify SIN port.*/
3050
 
                if ( ( fReserveSin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
3051
 
                {
3052
 
                        if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_UNASSIGNED )
3053
 
                        {
3054
 
                                /* Check what number of TSSTs should be reserved this time. */
3055
 
                                if ( pModifyTdmConf->ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
3056
 
                                {
3057
 
                                        ulSinNumTssts = pApiTdmConf->bySinNumTssts;
3058
 
                                }
3059
 
                                else /* if ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3060
 
                                {
3061
 
                                        /* New number of TSSTs. */
3062
 
                                        ulSinNumTssts = pModifyTdmConf->ulSinNumTssts;
3063
 
                                }
3064
 
 
3065
 
                                if ( pModifyTdmConf->ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3066
 
                                {
3067
 
                                        /* Reserve the new number of TSSTs. */
3068
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
3069
 
                                                                                                  pApiTdmConf->usSinTimeslot, 
3070
 
                                                                                                  pApiTdmConf->usSinStream, 
3071
 
                                                                                                  ulSinNumTssts, 
3072
 
                                                                                                  cOCT6100_INPUT_TSST,
3073
 
                                                                                                  f_pusNewSinTsstIndex, 
3074
 
                                                                                                  NULL );
3075
 
                                }
3076
 
                                else /* if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3077
 
                                {
3078
 
                                        /* Reserve the new TSST.*/
3079
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
3080
 
                                                                                                  pModifyTdmConf->ulSinTimeslot, 
3081
 
                                                                                                  pModifyTdmConf->ulSinStream, 
3082
 
                                                                                                  ulSinNumTssts, 
3083
 
                                                                                                  cOCT6100_INPUT_TSST,
3084
 
                                                                                                  f_pusNewSinTsstIndex, 
3085
 
                                                                                                  NULL );
3086
 
                                        if ( ulResult == cOCT6100_ERR_OK )
3087
 
                                        {
3088
 
                                                fSinReserved = TRUE;
3089
 
                                        }
3090
 
                                }
3091
 
                        }
3092
 
                        else
3093
 
                        {
3094
 
                                *f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX;
3095
 
                        }
3096
 
                }
3097
 
                else
3098
 
                {
3099
 
                        *f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX;
3100
 
                }
3101
 
 
3102
 
                /* Modify ROUT port.*/
3103
 
                if ( ( fReserveRout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
3104
 
                {
3105
 
                        if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_UNASSIGNED )
3106
 
                        {
3107
 
                                /* Check what number of TSSTs should be reserved this time. */
3108
 
                                if ( pModifyTdmConf->ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
3109
 
                                {
3110
 
                                        ulRoutNumTssts = pApiTdmConf->byRoutNumTssts;
3111
 
                                }
3112
 
                                else /* if ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3113
 
                                {
3114
 
                                        /* New number of TSSTs. */
3115
 
                                        ulRoutNumTssts = pModifyTdmConf->ulRoutNumTssts;
3116
 
                                }
3117
 
 
3118
 
                                if ( pModifyTdmConf->ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3119
 
                                {
3120
 
                                        /* Reserve the new number of TSSTs. */
3121
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
3122
 
                                                                                                  pApiTdmConf->usRoutTimeslot, 
3123
 
                                                                                                  pApiTdmConf->usRoutStream, 
3124
 
                                                                                                  ulRoutNumTssts, 
3125
 
                                                                                                  cOCT6100_OUTPUT_TSST,
3126
 
                                                                                                  f_pusNewRoutTsstIndex, 
3127
 
                                                                                                  NULL );
3128
 
                                }
3129
 
                                else /* if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3130
 
                                {
3131
 
                                        /* Reserve the new TSST.*/
3132
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
3133
 
                                                                                                  pModifyTdmConf->ulRoutTimeslot, 
3134
 
                                                                                                  pModifyTdmConf->ulRoutStream, 
3135
 
                                                                                                  ulRoutNumTssts, 
3136
 
                                                                                                  cOCT6100_OUTPUT_TSST,
3137
 
                                                                                                  f_pusNewRoutTsstIndex, 
3138
 
                                                                                                  NULL );
3139
 
                                        if ( ulResult == cOCT6100_ERR_OK  )
3140
 
                                        {
3141
 
                                                fRoutReserved = TRUE;
3142
 
                                        }
3143
 
                                }
3144
 
                        }
3145
 
                        else
3146
 
                        {
3147
 
                                *f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX;
3148
 
                        }
3149
 
                }
3150
 
                else
3151
 
                {
3152
 
                        *f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX;
3153
 
                }
3154
 
 
3155
 
                /* Modify SOUT port.*/
3156
 
                if ( ( fReserveSout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
3157
 
                {
3158
 
                        if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_UNASSIGNED )
3159
 
                        {
3160
 
                                /* Check what number of TSSTs should be reserved this time. */
3161
 
                                if ( pModifyTdmConf->ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
3162
 
                                {
3163
 
                                        ulSoutNumTssts = pApiTdmConf->bySoutNumTssts;
3164
 
                                }
3165
 
                                else /* if ( pModifyTdmConf->ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3166
 
                                {
3167
 
                                        /* New number of TSSTs. */
3168
 
                                        ulSoutNumTssts = pModifyTdmConf->ulSoutNumTssts;
3169
 
                                }
3170
 
 
3171
 
                                if ( pModifyTdmConf->ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3172
 
                                {
3173
 
                                        /* Reserve the new number of TSSTs. */
3174
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
3175
 
                                                                                                  pApiTdmConf->usSoutTimeslot, 
3176
 
                                                                                                  pApiTdmConf->usSoutStream, 
3177
 
                                                                                                  ulSoutNumTssts, 
3178
 
                                                                                                  cOCT6100_OUTPUT_TSST,
3179
 
                                                                                                  f_pusNewSoutTsstIndex, 
3180
 
                                                                                                  NULL );
3181
 
                                }
3182
 
                                else /* if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3183
 
                                {
3184
 
                                        /* Reserve the new TSST.*/
3185
 
                                        ulResult = Oct6100ApiReserveTsst( f_pApiInstance, 
3186
 
                                                                                                  pModifyTdmConf->ulSoutTimeslot, 
3187
 
                                                                                                  pModifyTdmConf->ulSoutStream, 
3188
 
                                                                                                  ulSoutNumTssts, 
3189
 
                                                                                                  cOCT6100_OUTPUT_TSST,
3190
 
                                                                                                  f_pusNewSoutTsstIndex, 
3191
 
                                                                                                  NULL );
3192
 
                                        if ( ulResult == cOCT6100_ERR_OK  )
3193
 
                                        {
3194
 
                                                fSoutReserved = TRUE;
3195
 
                                        }
3196
 
                                }
3197
 
                        }
3198
 
                        else
3199
 
                        {
3200
 
                                *f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX;
3201
 
                        }
3202
 
                }
3203
 
                else
3204
 
                {
3205
 
                        *f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX;
3206
 
                }
3207
 
 
3208
 
 
3209
 
        }
3210
 
 
3211
 
        if ( f_pChannelModify->fCodecConfigModified == TRUE )
3212
 
        {
3213
 
                if (   ulResult == cOCT6100_ERR_OK &&
3214
 
                           pChanEntry->usRinRoutConversionMemIndex == cOCT6100_INVALID_INDEX &&
3215
 
                         ( f_pChannelModify->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT ||
3216
 
                           f_pChannelModify->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN ) )
3217
 
                {
3218
 
                        /* Reserve an ADPCM memory block.*/
3219
 
                        ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usRinRoutConversionMemIndex );
3220
 
                        if ( ulResult == cOCT6100_ERR_OK  )
3221
 
                        {
3222
 
                                fRinRoutConversionMemReserved = TRUE;
3223
 
                        }
3224
 
                }
3225
 
 
3226
 
                if (   ulResult == cOCT6100_ERR_OK && 
3227
 
                           pChanEntry->usSinSoutConversionMemIndex == cOCT6100_INVALID_INDEX &&
3228
 
                         ( f_pChannelModify->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT ||
3229
 
                           f_pChannelModify->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN ) )
3230
 
                {
3231
 
                        /* Reserve an ADPCM memory block.*/
3232
 
                        ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usSinSoutConversionMemIndex );
3233
 
                        if ( ulResult == cOCT6100_ERR_OK  )
3234
 
                        {
3235
 
                                fSinSoutConversionMemReserved = TRUE;
3236
 
                        }
3237
 
                }
3238
 
        }
3239
 
 
3240
 
 
3241
 
        /*===============================================================================*/
3242
 
        /* Check if there are a couple of mixer events available for us. */
3243
 
 
3244
 
        if ( ulResult == cOCT6100_ERR_OK )
3245
 
        {
3246
 
                UINT32 ulMixerEventCntNeeded = 0;
3247
 
 
3248
 
                /* Calculate how many mixer events are needed. */
3249
 
                if ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX )
3250
 
                {
3251
 
                        /* If the channel is in bidir mode, do not create the Rin silence event!!! */
3252
 
                        if ( pChanEntry->fBiDirChannel == FALSE )
3253
 
                        {
3254
 
                                if ( ( *f_pusNewRinTsstIndex == cOCT6100_INVALID_INDEX )
3255
 
                                        && ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
3256
 
                                        ulMixerEventCntNeeded++;
3257
 
                        }
3258
 
                }
3259
 
 
3260
 
                if ( ( *f_pusNewSinTsstIndex == cOCT6100_INVALID_INDEX )
3261
 
                        && ( pChanEntry->usSinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
3262
 
                {
3263
 
                        ulMixerEventCntNeeded++;
3264
 
                }
3265
 
 
3266
 
                /* If at least 1 mixer event is needed, check if those are available. */
3267
 
                if ( ulMixerEventCntNeeded != 0 )
3268
 
                {
3269
 
                        ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt );
3270
 
                        if ( ulResult == cOCT6100_ERR_OK )
3271
 
                        {
3272
 
                                /* The API might need more mixer events if the ports have to be muted. */
3273
 
                                /* Check if these are available. */
3274
 
                                if ( ulFreeMixerEventCnt < ulMixerEventCntNeeded )
3275
 
                                {
3276
 
                                        ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS;
3277
 
                                }
3278
 
                        }
3279
 
                }
3280
 
        }
3281
 
 
3282
 
        /*===============================================================================*/
3283
 
 
3284
 
        /* Verify if an error occured. */
3285
 
        if ( ulResult != cOCT6100_ERR_OK )
3286
 
        {
3287
 
                /* Release any resources newly reserved.*/
3288
 
                if ( fRinReserved == TRUE )
3289
 
                {
3290
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, 
3291
 
                                                                                          pModifyTdmConf->ulRinTimeslot,
3292
 
                                                                                          pModifyTdmConf->ulRinStream, 
3293
 
                                                                                          ulRinNumTssts, 
3294
 
                                                                                          cOCT6100_INPUT_TSST,
3295
 
                                                                                          cOCT6100_INVALID_INDEX );
3296
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
3297
 
                                return ulTempVar;
3298
 
                }
3299
 
 
3300
 
                /* For the SIN port.*/
3301
 
                if ( fSinReserved == TRUE )
3302
 
                {
3303
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, 
3304
 
                                                                                          pModifyTdmConf->ulSinTimeslot,
3305
 
                                                                                          pModifyTdmConf->ulSinStream, 
3306
 
                                                                                          ulSinNumTssts, 
3307
 
                                                                                          cOCT6100_INPUT_TSST,
3308
 
                                                                                          cOCT6100_INVALID_INDEX );
3309
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
3310
 
                                return ulTempVar;
3311
 
                }
3312
 
 
3313
 
                /* For the ROUT port.*/
3314
 
                if ( fRoutReserved == TRUE )
3315
 
                {
3316
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, 
3317
 
                                                                                          pModifyTdmConf->ulRoutTimeslot,
3318
 
                                                                                          pModifyTdmConf->ulRoutStream, 
3319
 
                                                                                          ulRoutNumTssts, 
3320
 
                                                                                          cOCT6100_OUTPUT_TSST,
3321
 
                                                                                          cOCT6100_INVALID_INDEX );
3322
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
3323
 
                                return ulTempVar;
3324
 
                }
3325
 
 
3326
 
                /* For the SOUT port.*/
3327
 
                if ( fSoutReserved == TRUE )
3328
 
                {
3329
 
                        ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance, 
3330
 
                                                                                          pModifyTdmConf->ulSoutTimeslot,
3331
 
                                                                                          pModifyTdmConf->ulSoutStream, 
3332
 
                                                                                          ulSoutNumTssts, 
3333
 
                                                                                          cOCT6100_OUTPUT_TSST,
3334
 
                                                                                          cOCT6100_INVALID_INDEX );
3335
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
3336
 
                                return ulTempVar;
3337
 
                }
3338
 
 
3339
 
                /* Now make sure any resources released gets reserved back again.*/
3340
 
 
3341
 
                /* For the RIN port.*/
3342
 
                if ( fRinReleased == TRUE )
3343
 
                {
3344
 
                        /* Reserve the new TSST.*/
3345
 
                        ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, 
3346
 
                                                                                          pChanEntry->TdmConfig.usRinTimeslot, 
3347
 
                                                                                          pChanEntry->TdmConfig.usRinStream, 
3348
 
                                                                                          pChanEntry->TdmConfig.byRinNumTssts, 
3349
 
                                                                                          cOCT6100_INPUT_TSST,
3350
 
                                                                                          &pChanEntry->usRinTsstIndex, 
3351
 
                                                                                          NULL );
3352
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
3353
 
                                return ulTempVar;
3354
 
                }
3355
 
 
3356
 
                /* For the SIN port.*/
3357
 
                if ( fSinReleased == TRUE )
3358
 
                {
3359
 
                        /* Reserve the new TSST.*/
3360
 
                        ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, 
3361
 
                                                                                          pChanEntry->TdmConfig.usSinTimeslot, 
3362
 
                                                                                          pChanEntry->TdmConfig.usSinStream, 
3363
 
                                                                                          pChanEntry->TdmConfig.bySinNumTssts, 
3364
 
                                                                                          cOCT6100_INPUT_TSST,
3365
 
                                                                                          &pChanEntry->usSinTsstIndex, 
3366
 
                                                                                          NULL );
3367
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
3368
 
                                return ulTempVar;
3369
 
                }
3370
 
 
3371
 
                /* For the ROUT port.*/
3372
 
                if ( fRoutReleased == TRUE )
3373
 
                {
3374
 
                        /* Reserve the new TSST.*/
3375
 
                        ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, 
3376
 
                                                                                          pChanEntry->TdmConfig.usRoutTimeslot, 
3377
 
                                                                                          pChanEntry->TdmConfig.usRoutStream, 
3378
 
                                                                                          pChanEntry->TdmConfig.byRoutNumTssts, 
3379
 
                                                                                          cOCT6100_OUTPUT_TSST,
3380
 
                                                                                          &pChanEntry->usRoutTsstIndex, 
3381
 
                                                                                          NULL );
3382
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
3383
 
                                return ulTempVar;
3384
 
                }
3385
 
 
3386
 
                /* For the SOUT port.*/
3387
 
                if ( fSoutReleased == TRUE )
3388
 
                {
3389
 
                        /* Reserve the new TSST.*/
3390
 
                        ulTempVar = Oct6100ApiReserveTsst( f_pApiInstance, 
3391
 
                                                                                          pChanEntry->TdmConfig.usSoutTimeslot, 
3392
 
                                                                                          pChanEntry->TdmConfig.usSoutStream, 
3393
 
                                                                                          pChanEntry->TdmConfig.bySoutNumTssts, 
3394
 
                                                                                          cOCT6100_OUTPUT_TSST,
3395
 
                                                                                          &pChanEntry->usSoutTsstIndex, 
3396
 
                                                                                          NULL );
3397
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
3398
 
                                return ulTempVar;
3399
 
                }
3400
 
 
3401
 
                /* Release the conversion memories if they were reserved.*/
3402
 
                if ( fRinRoutConversionMemReserved == TRUE )
3403
 
                {
3404
 
                        ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, 
3405
 
                                                                                                            pChanEntry->usRinRoutConversionMemIndex );
3406
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
3407
 
                                return ulTempVar;
3408
 
                }
3409
 
 
3410
 
                if ( fSinSoutConversionMemReserved == TRUE )
3411
 
                {
3412
 
                        ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance, 
3413
 
                                                                                                            pChanEntry->usSinSoutConversionMemIndex );
3414
 
                        if ( ulTempVar != cOCT6100_ERR_OK )
3415
 
                                return ulTempVar;
3416
 
                }
3417
 
                
3418
 
                /* Now return the error.*/
3419
 
                return ulResult;
3420
 
        }
3421
 
 
3422
 
        return cOCT6100_ERR_OK;
3423
 
}
3424
 
 
3425
 
 
3426
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3427
 
 
3428
 
Function:               Oct6100ApiModifyChannelStructs
3429
 
 
3430
 
Description:    Performs all the required structure writes to configure the
3431
 
                                echo cancellation channel based on the new modifications.
3432
 
 
3433
 
-------------------------------------------------------------------------------
3434
 
|       Argument                |       Description
3435
 
-------------------------------------------------------------------------------
3436
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
3437
 
                                                        present state of the chip and all its resources.
3438
 
                                        
3439
 
f_pChannelModify                        Pointer to echo cancellation channel configuration structure.
3440
 
f_pChannelOpen                          Pointer to a structure used to store the multiple resources indexes.
3441
 
f_usChanIndex                           Index of the channel within the API's channel list.
3442
 
f_usNewPhasingTsstIndex         Index of the new phasing TSST.
3443
 
f_pfSinSoutCodecActive          Pointer to the state of the SIN/SOUT codec.
3444
 
f_pfRinRoutCodecActive          Pointer to the state of the RIN/ROUT codec.
3445
 
f_usNewRinTsstIndex                     New RIN TSST memory index.
3446
 
f_usNewSinTsstIndex                     New SIN TSST memory index.
3447
 
f_usNewRoutTsstIndex            New ROUT TSST memory index.
3448
 
f_usNewSoutTsstIndex            New SOUT TSST memory index.
3449
 
 
3450
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
3451
 
static UINT32 Oct6100ApiModifyChannelStructs(
3452
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
3453
 
                                IN      tPOCT6100_CHANNEL_MODIFY                f_pChannelModify, 
3454
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen, 
3455
 
                                IN      UINT16                                                  f_usChanIndex,
3456
 
                                IN      UINT16                                                  f_usNewPhasingTsstIndex,
3457
 
                                OUT     PUINT8                                                  f_pfSinSoutCodecActive,
3458
 
                                OUT     PUINT8                                                  f_pfRinRoutCodecActive,
3459
 
                                IN      UINT16                                                  f_usNewRinTsstIndex,
3460
 
                                IN      UINT16                                                  f_usNewSinTsstIndex,
3461
 
                                IN      UINT16                                                  f_usNewRoutTsstIndex,
3462
 
                                IN      UINT16                                                  f_usNewSoutTsstIndex )
3463
 
{
3464
 
        tPOCT6100_API_CHANNEL           pChanEntry;
3465
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
3466
 
        tOCT6100_READ_PARAMS    ReadParams;
3467
 
        tOCT6100_WRITE_PARAMS   WriteParams;
3468
 
        tPOCT6100_API_CHANNEL_CODEC     pApiCodecConf;
3469
 
        tPOCT6100_API_CHANNEL_TDM       pApiTdmConf;
3470
 
        tPOCT6100_API_CHANNEL_VQE       pApiVqeConf;
3471
 
 
3472
 
        UINT32  ulResult;
3473
 
        UINT16  usReadData;
3474
 
 
3475
 
        UINT16  usSinTsstIndex;
3476
 
        UINT16  usRinTsstIndex;
3477
 
 
3478
 
        UINT32  ulToneConfIndex;
3479
 
        BOOL    fClearPlayoutPointers = FALSE;
3480
 
 
3481
 
        BOOL    fConversionEnabled = FALSE;
3482
 
 
3483
 
 
3484
 
 
3485
 
        /* Obtain local pointer to shared portion of instance. */
3486
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
3487
 
 
3488
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
3489
 
 
3490
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
3491
 
 
3492
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
3493
 
 
3494
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
3495
 
        ReadParams.pusReadData = &usReadData;
3496
 
 
3497
 
        /*=======================================================================*/
3498
 
        /* Get a pointer to the channel's list entry. */
3499
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
3500
 
 
3501
 
        /* Obtain local pointer to the configuration structures of the tPOCT6100_API_CHANNEL structure. */
3502
 
        pApiCodecConf = &pChanEntry->CodecConfig;
3503
 
        pApiTdmConf   = &pChanEntry->TdmConfig;
3504
 
        pApiVqeConf   = &pChanEntry->VqeConfig;
3505
 
 
3506
 
        /*=======================================================================*/
3507
 
        /* Init the RIN and SIN TSST index */
3508
 
        
3509
 
        usRinTsstIndex = pChanEntry->usRinTsstIndex;
3510
 
        usSinTsstIndex = pChanEntry->usSinTsstIndex;
3511
 
 
3512
 
 
3513
 
        /*==============================================================================*/
3514
 
        /* Clear the TSST that will be release.*/
3515
 
 
3516
 
        if ( f_pChannelModify->fTdmConfigModified == TRUE )     
3517
 
        {
3518
 
                /* Modify RIN port.*/
3519
 
                if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3520
 
                {
3521
 
                        if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
3522
 
                        {
3523
 
                                /* Clear the previous entry  */
3524
 
                                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usRinTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3525
 
                                WriteParams.usWriteData  = 0x0000;
3526
 
 
3527
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3528
 
                                if ( ulResult != cOCT6100_ERR_OK  )
3529
 
                                        return ulResult;
3530
 
                        }
3531
 
                }
3532
 
 
3533
 
                /* Modify SIN port.*/
3534
 
                if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3535
 
                {
3536
 
                        if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
3537
 
                        {
3538
 
                                /* Clear the previous entry  */
3539
 
                                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usSinTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3540
 
                                WriteParams.usWriteData  = 0x0000;
3541
 
 
3542
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3543
 
                                if ( ulResult != cOCT6100_ERR_OK  )
3544
 
                                        return ulResult;
3545
 
                        }
3546
 
                }
3547
 
 
3548
 
                /* Modify ROUT port.*/
3549
 
                if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3550
 
                {
3551
 
                        if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
3552
 
                        {
3553
 
                                /* Clear the previous entry  */
3554
 
                                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usRoutTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3555
 
                                WriteParams.usWriteData  = 0x0000;
3556
 
 
3557
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3558
 
                                if ( ulResult != cOCT6100_ERR_OK  )
3559
 
                                        return ulResult;
3560
 
                        }
3561
 
                }
3562
 
 
3563
 
                /* Modify SOUT port.*/
3564
 
                if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING)
3565
 
                {
3566
 
                        if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
3567
 
                        {
3568
 
                                /* Clear the previous entry  */
3569
 
                                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (pChanEntry->usSoutTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
3570
 
                                WriteParams.usWriteData  = 0x0000;
3571
 
 
3572
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3573
 
                                if ( ulResult != cOCT6100_ERR_OK  )
3574
 
                                        return ulResult;
3575
 
                        }
3576
 
                }
3577
 
        }
3578
 
        /*==============================================================================*/
3579
 
 
3580
 
        
3581
 
        /*==============================================================================*/
3582
 
        /* Now, Configure the Tsst control memory.*/
3583
 
 
3584
 
        if ( f_pChannelModify->fTdmConfigModified == TRUE )     
3585
 
        {
3586
 
                /* Modify RIN port.*/
3587
 
                if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3588
 
                {
3589
 
                        usRinTsstIndex = f_usNewRinTsstIndex;
3590
 
 
3591
 
                        if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX )
3592
 
                        {
3593
 
                                if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX )
3594
 
                                {
3595
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3596
 
                                                                                                                                          f_usNewRinTsstIndex,
3597
 
                                                                                                                                          pChanEntry->usExtraRinTsiMemIndex,
3598
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulRinPcmLaw );
3599
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
3600
 
                                                return ulResult;
3601
 
                                }
3602
 
                                else
3603
 
                                {
3604
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3605
 
                                                                                                                                          f_usNewRinTsstIndex,
3606
 
                                                                                                                                          pChanEntry->usRinRoutTsiMemIndex,
3607
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulRinPcmLaw );
3608
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
3609
 
                                                return ulResult;
3610
 
                                }
3611
 
                        }
3612
 
                }
3613
 
                if ( f_pChannelModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING &&
3614
 
                         f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
3615
 
                {
3616
 
                        if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX )
3617
 
                        {
3618
 
                                if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
3619
 
                                {
3620
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3621
 
                                                                                                                                          pChanEntry->usRinTsstIndex,
3622
 
                                                                                                                                          pChanEntry->usExtraRinTsiMemIndex,
3623
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulRinPcmLaw );
3624
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
3625
 
                                                return ulResult;
3626
 
                                }
3627
 
                        }
3628
 
                        else
3629
 
                        {
3630
 
                                if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
3631
 
                                {
3632
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3633
 
                                                                                                                                          pChanEntry->usRinTsstIndex,
3634
 
                                                                                                                                          pChanEntry->usRinRoutTsiMemIndex,
3635
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulRinPcmLaw );
3636
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
3637
 
                                                return ulResult;
3638
 
                                }
3639
 
                        }
3640
 
                }
3641
 
 
3642
 
                /* Modify SIN port.*/
3643
 
                if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3644
 
                {
3645
 
                        usSinTsstIndex = f_usNewSinTsstIndex;
3646
 
 
3647
 
                        if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX )
3648
 
                        {
3649
 
                                if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
3650
 
                                {
3651
 
                                        /* Write the new entry now.*/
3652
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3653
 
                                                                                                                                          f_usNewSinTsstIndex,
3654
 
                                                                                                                                          pChanEntry->usExtraSinTsiMemIndex,
3655
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulSinPcmLaw );
3656
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
3657
 
                                                return ulResult;
3658
 
                                }
3659
 
                                else
3660
 
                                {
3661
 
                                        /* Write the new entry now.*/
3662
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3663
 
                                                                                                                                          f_usNewSinTsstIndex,
3664
 
                                                                                                                                          pChanEntry->usSinSoutTsiMemIndex,
3665
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulSinPcmLaw );
3666
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
3667
 
                                                return ulResult;
3668
 
                                }
3669
 
                        }
3670
 
                }
3671
 
                if ( f_pChannelModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING &&
3672
 
                         f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
3673
 
                {
3674
 
                        if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
3675
 
                        {
3676
 
                                if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
3677
 
                                {
3678
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3679
 
                                                                                                                                          pChanEntry->usSinTsstIndex ,
3680
 
                                                                                                                                          pChanEntry->usExtraSinTsiMemIndex,
3681
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulSinPcmLaw );
3682
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
3683
 
                                                return ulResult;
3684
 
                                }
3685
 
                        }
3686
 
                        else
3687
 
                        {
3688
 
                                if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
3689
 
                                {
3690
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3691
 
                                                                                                                                          pChanEntry->usSinTsstIndex ,
3692
 
                                                                                                                                          pChanEntry->usSinSoutTsiMemIndex,
3693
 
                                                                                                                                          f_pChannelOpen->TdmConfig.ulSinPcmLaw );
3694
 
                                        if ( ulResult != cOCT6100_ERR_OK  )
3695
 
                                                return ulResult;
3696
 
                                }
3697
 
                        }
3698
 
                }
3699
 
 
3700
 
                /* Modify ROUT port.*/
3701
 
                if ( ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3702
 
                        || ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) 
3703
 
                        )
3704
 
                {
3705
 
                        if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX )
3706
 
                        {
3707
 
                                if ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
3708
 
                                {
3709
 
                                        /* If this output port is not muted. */
3710
 
                                        if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 )
3711
 
                                        {
3712
 
                                                /* Write the new entry now.*/
3713
 
                                                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
3714
 
                                                                                                                                           f_usNewRoutTsstIndex,
3715
 
                                                                                                                                           pApiCodecConf->byAdpcmNibblePosition,
3716
 
                                                                                                                                           f_pChannelModify->TdmConfig.ulRoutNumTssts,
3717
 
                                                                                                                                           pChanEntry->usRinRoutTsiMemIndex );
3718
 
                                                if ( ulResult != cOCT6100_ERR_OK  )
3719
 
                                                        return ulResult;
3720
 
                                        }
3721
 
                                }
3722
 
                                else
3723
 
                                {
3724
 
                                        /* If this output port is not muted. */
3725
 
                                        if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 )
3726
 
                                        {
3727
 
                                                /* Write the new entry now.*/
3728
 
                                                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
3729
 
                                                                                                                                   f_usNewRoutTsstIndex,
3730
 
                                                                                                                                   pApiCodecConf->byAdpcmNibblePosition,
3731
 
                                                                                                                                   pApiTdmConf->byRoutNumTssts,
3732
 
                                                                                                                                   pChanEntry->usRinRoutTsiMemIndex );
3733
 
                                                if ( ulResult != cOCT6100_ERR_OK  )
3734
 
                                                        return ulResult;
3735
 
                                        }
3736
 
                                }
3737
 
                        }
3738
 
                }
3739
 
 
3740
 
                /* Modify SOUT port.*/
3741
 
                if ( ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3742
 
                        || ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) 
3743
 
                        )
3744
 
                {
3745
 
                        if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX )
3746
 
                        {
3747
 
                                if ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
3748
 
                                {
3749
 
                                        /* If this output port is not muted. */
3750
 
                                        if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 )
3751
 
                                        {
3752
 
                                                /* Write the new entry now.*/
3753
 
                                                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
3754
 
                                                                                                                                           f_usNewSoutTsstIndex,
3755
 
                                                                                                                                           pApiCodecConf->byAdpcmNibblePosition,
3756
 
                                                                                                                                           f_pChannelModify->TdmConfig.ulSoutNumTssts,
3757
 
                                                                                                                                           pChanEntry->usSinSoutTsiMemIndex );
3758
 
 
3759
 
                                                if ( ulResult != cOCT6100_ERR_OK  )
3760
 
                                                        return ulResult;
3761
 
                                        }
3762
 
                                }
3763
 
                                else
3764
 
                                {
3765
 
                                        /* If this output port is not muted. */
3766
 
                                        if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 )
3767
 
                                        {
3768
 
                                                /* Write the new entry now.*/
3769
 
                                                ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
3770
 
                                                                                                                                   f_usNewSoutTsstIndex,
3771
 
                                                                                                                                   pApiCodecConf->byAdpcmNibblePosition,
3772
 
                                                                                                                                   pApiTdmConf->bySoutNumTssts,
3773
 
                                                                                                                                   pChanEntry->usSinSoutTsiMemIndex );
3774
 
 
3775
 
                                                if ( ulResult != cOCT6100_ERR_OK  )
3776
 
                                                        return ulResult;
3777
 
                                        }
3778
 
                                }
3779
 
                        }
3780
 
                }
3781
 
 
3782
 
 
3783
 
 
3784
 
        }
3785
 
 
3786
 
        /*==============================================================================*/
3787
 
 
3788
 
 
3789
 
        /*==============================================================================*/
3790
 
        /* Modify the Encoder/Decoder memory if required.*/
3791
 
 
3792
 
        if ( f_pChannelModify->fCodecConfigModified == TRUE )
3793
 
        {
3794
 
                UINT32  ulCompType = 0;
3795
 
                UINT16  usTempTsiMemIndex;
3796
 
                UINT16  usDecoderMemIndex;
3797
 
                UINT16  usEncoderMemIndex;
3798
 
                UINT32  ulPcmLaw;
3799
 
                UINT16  usPhasingIndex;
3800
 
                BOOL    fModifyAdpcmMem = TRUE;
3801
 
 
3802
 
                /*==============================================================================*/
3803
 
                /* Reprogram the Decoder memory.*/
3804
 
 
3805
 
                if ( pChanEntry->CodecConfig.byDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3806
 
                {
3807
 
                        usDecoderMemIndex = pChanEntry->usRinRoutConversionMemIndex;
3808
 
                }
3809
 
                else
3810
 
                {
3811
 
                        usDecoderMemIndex = pChanEntry->usSinSoutConversionMemIndex;
3812
 
                }
3813
 
 
3814
 
                if ( pChanEntry->CodecConfig.byEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
3815
 
                {
3816
 
                        usEncoderMemIndex = pChanEntry->usRinRoutConversionMemIndex;
3817
 
                }
3818
 
                else
3819
 
                {
3820
 
                        usEncoderMemIndex = pChanEntry->usSinSoutConversionMemIndex;
3821
 
                }
3822
 
 
3823
 
                if ( usDecoderMemIndex != cOCT6100_INVALID_INDEX  )
3824
 
                {
3825
 
                        switch( f_pChannelOpen->CodecConfig.ulDecodingRate )
3826
 
                        {
3827
 
                        case cOCT6100_G711_64KBPS:                              
3828
 
                                ulCompType = 0x8;
3829
 
                                
3830
 
                                if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3831
 
                                {
3832
 
                                        if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw )
3833
 
                                                fModifyAdpcmMem = FALSE;
3834
 
 
3835
 
                                        /* Check if both ports are assigned.  If not, no law conversion needed here.. */
3836
 
                                        if ( ( f_pChannelOpen->TdmConfig.ulRinStream == cOCT6100_UNASSIGNED ) 
3837
 
                                                || ( f_pChannelOpen->TdmConfig.ulRoutStream == cOCT6100_UNASSIGNED ) )
3838
 
                                                fModifyAdpcmMem = FALSE;
3839
 
                                }
3840
 
                                else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
3841
 
                                {
3842
 
                                        if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
3843
 
                                                fModifyAdpcmMem = FALSE;
3844
 
 
3845
 
                                        /* Check if both ports are assigned.  If not, no law conversion needed here.. */
3846
 
                                        if ( ( f_pChannelOpen->TdmConfig.ulSinStream == cOCT6100_UNASSIGNED ) 
3847
 
                                                || ( f_pChannelOpen->TdmConfig.ulSoutStream == cOCT6100_UNASSIGNED ) )
3848
 
                                                fModifyAdpcmMem = FALSE;
3849
 
                                }
3850
 
 
3851
 
                                break;
3852
 
                        case cOCT6100_G726_40KBPS:                              
3853
 
                                ulCompType = 0x3;               
3854
 
                                fConversionEnabled = TRUE;
3855
 
                                break;
3856
 
 
3857
 
                        case cOCT6100_G726_32KBPS:                              
3858
 
                                ulCompType = 0x2;               
3859
 
                                fConversionEnabled = TRUE;
3860
 
                                break;
3861
 
 
3862
 
                        case cOCT6100_G726_24KBPS:                              
3863
 
                                ulCompType = 0x1;               
3864
 
                                fConversionEnabled = TRUE;
3865
 
                                break;
3866
 
 
3867
 
                        case cOCT6100_G726_16KBPS:                              
3868
 
                                ulCompType = 0x0;               
3869
 
                                fConversionEnabled = TRUE;
3870
 
                                break;          
3871
 
 
3872
 
                        case cOCT6100_G727_2C_ENCODED:                  
3873
 
                                ulCompType = 0x4;               
3874
 
                                fConversionEnabled = TRUE;
3875
 
                                break;
3876
 
 
3877
 
                        case cOCT6100_G727_3C_ENCODED:                  
3878
 
                                ulCompType = 0x5;               
3879
 
                                fConversionEnabled = TRUE;
3880
 
                                break;
3881
 
 
3882
 
                        case cOCT6100_G727_4C_ENCODED:                  
3883
 
                                ulCompType = 0x6;               
3884
 
                                fConversionEnabled = TRUE;
3885
 
                                break;
3886
 
 
3887
 
                        case cOCT6100_G726_ENCODED:                             
3888
 
                                ulCompType = 0x9;               
3889
 
                                fConversionEnabled = TRUE;
3890
 
                                break;
3891
 
 
3892
 
                        case cOCT6100_G711_G726_ENCODED:                
3893
 
                                ulCompType = 0xA;               
3894
 
                                fConversionEnabled = TRUE;
3895
 
                                break;
3896
 
 
3897
 
                        case cOCT6100_G711_G727_2C_ENCODED:             
3898
 
                                ulCompType = 0xC;               
3899
 
                                fConversionEnabled = TRUE;
3900
 
                                break;
3901
 
 
3902
 
                        case cOCT6100_G711_G727_3C_ENCODED:             
3903
 
                                ulCompType = 0xD;               
3904
 
                                fConversionEnabled = TRUE;
3905
 
                                break;
3906
 
 
3907
 
                        case cOCT6100_G711_G727_4C_ENCODED:             
3908
 
                                ulCompType = 0xE;               
3909
 
                                fConversionEnabled = TRUE;
3910
 
                                break;
3911
 
 
3912
 
                        default:
3913
 
                                return cOCT6100_ERR_FATAL_D6;
3914
 
                        }
3915
 
 
3916
 
                        if ( fModifyAdpcmMem == TRUE )
3917
 
                        {
3918
 
                                /* Set the chariot memory based on the selected port.*/
3919
 
                                if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3920
 
                                {
3921
 
                                        usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
3922
 
                                        ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;              /* Set the law for later use */
3923
 
                                        
3924
 
                                        /* Flag the entry as active.*/
3925
 
                                        *f_pfRinRoutCodecActive = TRUE;
3926
 
                                }
3927
 
                                else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
3928
 
                                {
3929
 
                                        usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
3930
 
                                        ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;              /* Set the law for later use */
3931
 
 
3932
 
                                        /* Flag the entry as active.*/
3933
 
                                        *f_pfSinSoutCodecActive = TRUE;
3934
 
                                }
3935
 
 
3936
 
                                ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance,
3937
 
                                                                                                                 usDecoderMemIndex,
3938
 
                                                                                                                 ulCompType,
3939
 
                                                                                                                 usTempTsiMemIndex,
3940
 
                                                                                                                 ulPcmLaw,
3941
 
                                                                                                                 pApiCodecConf->byAdpcmNibblePosition );
3942
 
                                if ( ulResult != cOCT6100_ERR_OK )
3943
 
                                        return ulResult;
3944
 
                        }
3945
 
                        else
3946
 
                        {
3947
 
                                ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance,
3948
 
                                                                                                                 usDecoderMemIndex );
3949
 
                                if ( ulResult != cOCT6100_ERR_OK )
3950
 
                                        return ulResult;
3951
 
 
3952
 
                                /* Flag the entry as deactivated.*/
3953
 
                                if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3954
 
                                {
3955
 
                                        *f_pfRinRoutCodecActive = FALSE;
3956
 
                                }
3957
 
                                else
3958
 
                                {
3959
 
                                        *f_pfSinSoutCodecActive = FALSE;
3960
 
                                }
3961
 
                        }
3962
 
                }
3963
 
 
3964
 
                /*==============================================================================*/
3965
 
 
3966
 
 
3967
 
 
3968
 
 
3969
 
                /*==============================================================================*/
3970
 
                /* Reprogram the Encoder memory.*/
3971
 
        
3972
 
                if ( usEncoderMemIndex != cOCT6100_INVALID_INDEX )
3973
 
                {
3974
 
 
3975
 
                        fModifyAdpcmMem = TRUE;
3976
 
                        
3977
 
                        /* Set the chariot memory based on the selected port.*/
3978
 
                        if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
3979
 
                        {
3980
 
                                usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
3981
 
                                ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;              /* Set the law for later use */
3982
 
                        }
3983
 
                        else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
3984
 
                        {
3985
 
                                usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
3986
 
                                ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;              /* Set the law for later use */
3987
 
                        }
3988
 
 
3989
 
                        /* Set the phasing index .*/
3990
 
                        if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX )
3991
 
                                usPhasingIndex = f_usNewPhasingTsstIndex;
3992
 
                        else
3993
 
                                usPhasingIndex = pChanEntry->usPhasingTsstIndex;
3994
 
 
3995
 
                        switch( f_pChannelOpen->CodecConfig.ulEncodingRate )
3996
 
                        {
3997
 
                                case cOCT6100_G711_64KBPS:
3998
 
                                        if ( ulPcmLaw == cOCT6100_PCM_U_LAW )
3999
 
                                                ulCompType = 0x4;
4000
 
                                        else /* ulPcmLaw  == cOCT6100_PCM_A_LAW */
4001
 
                                                ulCompType = 0x5;
4002
 
                                        
4003
 
                                        if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
4004
 
                                        {
4005
 
                                                if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw )
4006
 
                                                        fModifyAdpcmMem = FALSE;
4007
 
 
4008
 
                                                /* Check if both ports are assigned.  If not, no law conversion needed here.. */
4009
 
                                                if ( ( f_pChannelOpen->TdmConfig.ulRinStream == cOCT6100_UNASSIGNED ) 
4010
 
                                                        || ( f_pChannelOpen->TdmConfig.ulRoutStream == cOCT6100_UNASSIGNED ) )
4011
 
                                                        fModifyAdpcmMem = FALSE;
4012
 
                                        }
4013
 
                                        else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
4014
 
                                        {
4015
 
                                                if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
4016
 
                                                        fModifyAdpcmMem = FALSE;
4017
 
 
4018
 
                                                /* Check if both ports are assigned.  If not, no law conversion needed here.. */
4019
 
                                                if ( ( f_pChannelOpen->TdmConfig.ulSinStream == cOCT6100_UNASSIGNED ) 
4020
 
                                                        || ( f_pChannelOpen->TdmConfig.ulSoutStream == cOCT6100_UNASSIGNED ) )
4021
 
                                                        fModifyAdpcmMem = FALSE;
4022
 
                                        }
4023
 
                                        break;
4024
 
                                case cOCT6100_G726_40KBPS:                              
4025
 
                                        ulCompType = 0x3;               
4026
 
                                        fConversionEnabled = TRUE;
4027
 
                                        break;
4028
 
 
4029
 
                                case cOCT6100_G726_32KBPS:                              
4030
 
                                        ulCompType = 0x2;               
4031
 
                                        fConversionEnabled = TRUE;
4032
 
                                        break;
4033
 
 
4034
 
                                case cOCT6100_G726_24KBPS:                              
4035
 
                                        ulCompType = 0x1;               
4036
 
                                        fConversionEnabled = TRUE;
4037
 
                                        break;
4038
 
 
4039
 
                                case cOCT6100_G726_16KBPS:                              
4040
 
                                        ulCompType = 0x0;               
4041
 
                                        fConversionEnabled = TRUE;
4042
 
                                        break;          
4043
 
 
4044
 
                                case cOCT6100_G727_40KBPS_4_1:                  
4045
 
                                        ulCompType = 0xD;               
4046
 
                                        fConversionEnabled = TRUE;
4047
 
                                        break;
4048
 
 
4049
 
                                case cOCT6100_G727_40KBPS_3_2:                  
4050
 
                                        ulCompType = 0xA;               
4051
 
                                        fConversionEnabled = TRUE;
4052
 
                                        break;
4053
 
 
4054
 
                                case cOCT6100_G727_40KBPS_2_3:                  
4055
 
                                        ulCompType = 0x6;               
4056
 
                                        fConversionEnabled = TRUE;
4057
 
                                        break;
4058
 
 
4059
 
                                case cOCT6100_G727_32KBPS_4_0:                  
4060
 
                                        ulCompType = 0xE;               
4061
 
                                        fConversionEnabled = TRUE;
4062
 
                                        break;
4063
 
 
4064
 
                                case cOCT6100_G727_32KBPS_3_1:                  
4065
 
                                        ulCompType = 0xB;               
4066
 
                                        fConversionEnabled = TRUE;
4067
 
                                        break;
4068
 
 
4069
 
                                case cOCT6100_G727_32KBPS_2_2:                  
4070
 
                                        ulCompType = 0x7;               
4071
 
                                        fConversionEnabled = TRUE;
4072
 
                                        break;
4073
 
 
4074
 
                                case cOCT6100_G727_24KBPS_3_0:                  
4075
 
                                        ulCompType = 0xC;               
4076
 
                                        fConversionEnabled = TRUE;
4077
 
                                        break;
4078
 
 
4079
 
                                case cOCT6100_G727_24KBPS_2_1:                  
4080
 
                                        ulCompType = 0x8;               
4081
 
                                        fConversionEnabled = TRUE;
4082
 
                                        break;
4083
 
 
4084
 
                                case cOCT6100_G727_16KBPS_2_0:                  
4085
 
                                        ulCompType = 0x9;               
4086
 
                                        fConversionEnabled = TRUE;
4087
 
                                        break;
4088
 
 
4089
 
                                default:
4090
 
                                        return cOCT6100_ERR_FATAL_D7;
4091
 
                        }
4092
 
 
4093
 
                        if ( fModifyAdpcmMem == TRUE )
4094
 
                        {
4095
 
                                if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
4096
 
                                {
4097
 
                                        *f_pfRinRoutCodecActive = TRUE;
4098
 
                                }
4099
 
                                else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
4100
 
                                {
4101
 
                                        *f_pfSinSoutCodecActive = TRUE;
4102
 
                                }
4103
 
                                
4104
 
                                ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance,
4105
 
                                                                                                                 usEncoderMemIndex,
4106
 
                                                                                                                 ulCompType,
4107
 
                                                                                                                 usTempTsiMemIndex,
4108
 
                                                                                                                 f_pChannelOpen->CodecConfig.fEnableSilenceSuppression,
4109
 
                                                                                                                 pApiCodecConf->byAdpcmNibblePosition,
4110
 
                                                                                                                 usPhasingIndex,
4111
 
                                                                                                                 f_pChannelOpen->CodecConfig.ulPhasingType,
4112
 
                                                                                                                 f_pChannelOpen->CodecConfig.ulPhase );
4113
 
                                                                                                         
4114
 
                                if ( ulResult != cOCT6100_ERR_OK )
4115
 
                                        return ulResult;
4116
 
                        }
4117
 
                        else
4118
 
                        {
4119
 
                                ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance,
4120
 
                                                                                                                        usEncoderMemIndex );
4121
 
                                if ( ulResult != cOCT6100_ERR_OK )
4122
 
                                        return ulResult;
4123
 
 
4124
 
                                if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
4125
 
                                {
4126
 
                                        *f_pfRinRoutCodecActive = FALSE;
4127
 
                                }
4128
 
                                else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
4129
 
                                {
4130
 
                                        *f_pfSinSoutCodecActive = FALSE;
4131
 
                                }
4132
 
                        }
4133
 
                }
4134
 
 
4135
 
                /*==============================================================================*/
4136
 
        }
4137
 
 
4138
 
 
4139
 
 
4140
 
        
4141
 
        /*==============================================================================*/
4142
 
        /* Modify the VQE parameter if required.*/
4143
 
 
4144
 
        if ( ( f_pChannelModify->fVqeConfigModified == TRUE )
4145
 
                || ( (UINT8)f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode )
4146
 
                || ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) )
4147
 
        {
4148
 
                ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance,
4149
 
                                                                                          &f_pChannelOpen->VqeConfig,
4150
 
                                                                                          f_pChannelOpen,
4151
 
                                                                                          f_usChanIndex,
4152
 
                                                                                          pChanEntry->usEchoMemIndex,
4153
 
                                                                                          FALSE,
4154
 
                                                                                          TRUE );
4155
 
                if ( ulResult != cOCT6100_ERR_OK )
4156
 
                        return ulResult;
4157
 
        }
4158
 
 
4159
 
        /*==============================================================================*/
4160
 
        /* Modify the Echo memory if required.*/
4161
 
        if ( f_pChannelModify->fEnableToneDisabler               != cOCT6100_KEEP_PREVIOUS_SETTING ||
4162
 
                 f_pChannelModify->ulEchoOperationMode       != cOCT6100_KEEP_PREVIOUS_SETTING ||
4163
 
                 f_pChannelModify->TdmConfig.ulRinPcmLaw         != cOCT6100_KEEP_PREVIOUS_SETTING ||
4164
 
                 f_pChannelModify->TdmConfig.ulSinPcmLaw         != cOCT6100_KEEP_PREVIOUS_SETTING ||
4165
 
                 f_pChannelModify->TdmConfig.ulRoutPcmLaw        != cOCT6100_KEEP_PREVIOUS_SETTING ||
4166
 
                 f_pChannelModify->TdmConfig.ulSoutPcmLaw        != cOCT6100_KEEP_PREVIOUS_SETTING )
4167
 
        {
4168
 
                ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance,
4169
 
                                                                                          &f_pChannelOpen->TdmConfig,
4170
 
                                                                                          f_pChannelOpen,
4171
 
                                                                                          pChanEntry->usEchoMemIndex,
4172
 
                                                                                          pChanEntry->usRinRoutTsiMemIndex,
4173
 
                                                                                          pChanEntry->usSinSoutTsiMemIndex );
4174
 
                if ( ulResult != cOCT6100_ERR_OK )
4175
 
                        return ulResult;
4176
 
                
4177
 
                /* Synch all the buffer playout field if needed by echo operation mode. */
4178
 
                /* Note that Oct6100ApiWriteVqeMemory does not clear the playout pointers */
4179
 
                /* since the flag is set to FALSE. */
4180
 
                if ( ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE ) 
4181
 
                        && ( ( f_pChannelModify->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_HT_FREEZE )
4182
 
                                || ( f_pChannelModify->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_POWER_DOWN ) ) )
4183
 
                {       
4184
 
                        /* Buffer playout must be stopped. */
4185
 
                        fClearPlayoutPointers = TRUE;
4186
 
                }
4187
 
        }
4188
 
 
4189
 
        /*==============================================================================*/
4190
 
        /* Modify the Mixer events if law changes are requested. */
4191
 
        
4192
 
        if ( pChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX && 
4193
 
                 f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
4194
 
        {
4195
 
                ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
4196
 
 
4197
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
4198
 
                if ( ulResult != cOCT6100_ERR_OK )
4199
 
                        return ulResult;
4200
 
 
4201
 
                /* Modify the value according to the new law.*/
4202
 
                if ( f_pChannelModify->TdmConfig.ulSinPcmLaw == cOCT6100_PCM_A_LAW )
4203
 
                        WriteParams.usWriteData = (UINT16)( usReadData | ( f_pChannelModify->TdmConfig.ulSinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET ));
4204
 
                else
4205
 
                        WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )));
4206
 
 
4207
 
                /* Write back the new value.*/
4208
 
                WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
4209
 
 
4210
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4211
 
                if ( ulResult != cOCT6100_ERR_OK )
4212
 
                        return ulResult;
4213
 
        }
4214
 
 
4215
 
        if ( pChanEntry->usSoutCopyEventIndex != cOCT6100_INVALID_INDEX && 
4216
 
                 f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
4217
 
        {
4218
 
                ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
4219
 
 
4220
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
4221
 
                if ( ulResult != cOCT6100_ERR_OK )
4222
 
                        return ulResult;
4223
 
 
4224
 
                /* Modify the value according to the new law.*/
4225
 
                if ( f_pChannelModify->TdmConfig.ulSoutPcmLaw == cOCT6100_PCM_A_LAW )
4226
 
                        WriteParams.usWriteData = (UINT16)( usReadData | ( f_pChannelModify->TdmConfig.ulSoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET ));
4227
 
                else
4228
 
                        WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )));
4229
 
 
4230
 
                /* Write back the new value.*/
4231
 
                WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
4232
 
 
4233
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4234
 
                if ( ulResult != cOCT6100_ERR_OK )
4235
 
                        return ulResult;
4236
 
        }
4237
 
 
4238
 
        /*==============================================================================*/
4239
 
        /*      Mute channel if required, this is done on a port basis */
4240
 
        
4241
 
        ulResult = Oct6100ApiMutePorts( f_pApiInstance,
4242
 
                                                                        f_usChanIndex,
4243
 
                                                                        usRinTsstIndex,
4244
 
                                                                        usSinTsstIndex,
4245
 
                                                                        TRUE );
4246
 
        if ( ulResult != cOCT6100_ERR_OK )
4247
 
                return ulResult;
4248
 
 
4249
 
        /*==============================================================================*/
4250
 
 
4251
 
        /* Completely disable tone detection? */
4252
 
        if ( f_pChannelModify->fDisableToneDetection == TRUE )
4253
 
        {
4254
 
                /* Check if tone detection has been enabled on this channel. */
4255
 
                for ( ulToneConfIndex = 0; ulToneConfIndex < ( sizeof( pChanEntry->aulToneConf ) / sizeof(UINT32) ); ulToneConfIndex ++ )
4256
 
                {
4257
 
                        /* Check if some tone has been activated on this channel. */
4258
 
                        if ( pChanEntry->aulToneConf[ ulToneConfIndex ] != 0 )
4259
 
                        {
4260
 
                                tOCT6100_TONE_DETECTION_DISABLE         ToneDetectDisable;
4261
 
 
4262
 
                                /* Call the default function to make sure all parameters are assigned default values. */
4263
 
                                ulResult = Oct6100ToneDetectionDisableDef( &ToneDetectDisable );
4264
 
                                if ( ulResult != cOCT6100_ERR_OK )
4265
 
                                        return ulResult;
4266
 
                                
4267
 
                                /* Form channel handle. */
4268
 
                                ToneDetectDisable.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4269
 
 
4270
 
                                /* Disable all tones activated on this channel. */
4271
 
                                ToneDetectDisable.fDisableAll = TRUE;
4272
 
 
4273
 
                                /* Call tone detection serialized function. */
4274
 
                                ulResult = Oct6100ToneDetectionDisableSer( f_pApiInstance, &ToneDetectDisable );
4275
 
                                if ( ulResult != cOCT6100_ERR_OK )
4276
 
                                        return ulResult;
4277
 
 
4278
 
                                /* Get out of the loop, tone detection has been disabled! */
4279
 
                                break;
4280
 
                        }
4281
 
                }
4282
 
        }
4283
 
 
4284
 
        /* Hard-stop buffer playout? */
4285
 
        if ( f_pChannelModify->fStopBufferPlayout == TRUE )
4286
 
        {
4287
 
                /* Check if playout has been started on the Rout port. */
4288
 
                if ( ( pChanEntry->fRinBufPlaying == TRUE ) || ( pChanEntry->fRinBufAdded == TRUE ) )
4289
 
                {
4290
 
                        tOCT6100_BUFFER_PLAYOUT_STOP    PlayoutStop;
4291
 
 
4292
 
                        /* Call the default function to make sure all parameters are assigned default values. */
4293
 
                        ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop );
4294
 
                        if ( ulResult != cOCT6100_ERR_OK )
4295
 
                                return ulResult;
4296
 
 
4297
 
                        /* Hard stop request. */
4298
 
                        PlayoutStop.fStopCleanly = FALSE;
4299
 
 
4300
 
                        /* Form channel handle. */
4301
 
                        PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4302
 
 
4303
 
                        /* For the Rout port. */
4304
 
                        PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
4305
 
 
4306
 
                        /* Call buffer playout stop serialized function. */
4307
 
                        ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop );
4308
 
                        if ( ulResult != cOCT6100_ERR_OK )
4309
 
                                return ulResult;
4310
 
                }
4311
 
                else
4312
 
                {
4313
 
                        /* The chip might still be playing a last buffer.  Make sure it hard-stops! */
4314
 
                        fClearPlayoutPointers = TRUE;
4315
 
                }
4316
 
 
4317
 
                /* Check if playout has been started on the Sout port. */
4318
 
                if ( ( pChanEntry->fSoutBufPlaying == TRUE ) || ( pChanEntry->fSoutBufAdded == TRUE ) )
4319
 
                {
4320
 
                        tOCT6100_BUFFER_PLAYOUT_STOP    PlayoutStop;
4321
 
 
4322
 
                        /* Call the default function to make sure all parameters are assigned default values. */
4323
 
                        ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop );
4324
 
                        if ( ulResult != cOCT6100_ERR_OK )
4325
 
                                return ulResult;
4326
 
                        
4327
 
                        /* Hard stop request. */
4328
 
                        PlayoutStop.fStopCleanly = FALSE;
4329
 
 
4330
 
                        /* Form channel handle. */
4331
 
                        PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4332
 
 
4333
 
                        /* For the Rout port. */
4334
 
                        PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
4335
 
 
4336
 
                        /* Call buffer playout stop serialized function. */
4337
 
                        ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop );
4338
 
                        if ( ulResult != cOCT6100_ERR_OK )
4339
 
                                return ulResult;
4340
 
                }
4341
 
                else
4342
 
                {
4343
 
                        /* The chip might still be playing a last buffer.  Make sure it hard-stops! */
4344
 
                        fClearPlayoutPointers = TRUE;
4345
 
                }
4346
 
        }
4347
 
 
4348
 
        /* Remove participant from bridge? */
4349
 
        if ( f_pChannelModify->fRemoveConfBridgeParticipant == TRUE )
4350
 
        {
4351
 
                /* Check if this channel is on a bridge. */
4352
 
                if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
4353
 
                {
4354
 
                        /* Channel is on a bridge, remove it. */
4355
 
                        tOCT6100_CONF_BRIDGE_CHAN_REMOVE        BridgeChanRemove;
4356
 
 
4357
 
                        /* Call the default function to make sure all parameters are assigned default values. */
4358
 
                        ulResult = Oct6100ConfBridgeChanRemoveDef( &BridgeChanRemove );
4359
 
                        if ( ulResult != cOCT6100_ERR_OK )
4360
 
                                return ulResult;
4361
 
                        
4362
 
                        /* Form channel handle. */
4363
 
                        BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4364
 
 
4365
 
                        /* Do not remove all channels, only the one specified. */
4366
 
                        BridgeChanRemove.fRemoveAll = FALSE;
4367
 
 
4368
 
                        /* No need to assign conference bridge handle, the remove function will figure it out. */
4369
 
 
4370
 
                        /* Call conference bridge channel remove serialized function. */
4371
 
                        ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
4372
 
                        if ( ulResult != cOCT6100_ERR_OK )
4373
 
                        {
4374
 
                                if ( ulResult == cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_DEPENDENCY )
4375
 
                                {
4376
 
                                        tPOCT6100_API_CHANNEL           pTapChanEntry;
4377
 
 
4378
 
                                        /* Get a pointer to the tap channel's list entry. */
4379
 
                                        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTapChanEntry, pChanEntry->usTapChanIndex )
4380
 
 
4381
 
                                        /* Form tap channel handle. */
4382
 
                                        BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pTapChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | pChanEntry->usTapChanIndex;
4383
 
 
4384
 
                                        ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
4385
 
                                        if ( ulResult != cOCT6100_ERR_OK )
4386
 
                                                return ulResult;
4387
 
 
4388
 
                                        /* Re-form original channel handle. */
4389
 
                                        BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4390
 
 
4391
 
                                        ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
4392
 
                                        if ( ulResult != cOCT6100_ERR_OK )
4393
 
                                                return ulResult;
4394
 
                                }
4395
 
                                else
4396
 
                                {
4397
 
                                        return ulResult;
4398
 
                                }
4399
 
                        }
4400
 
                }
4401
 
        }
4402
 
 
4403
 
        /* Remove all broadcast TSSTs? */
4404
 
        if ( f_pChannelModify->fRemoveBroadcastTssts == TRUE )
4405
 
        {
4406
 
                /* Check if broadcast TSSTs were used on the Rout port. */
4407
 
                if ( pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX )
4408
 
                {
4409
 
                        tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE  BroadcastTsstRemove;
4410
 
 
4411
 
                        ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove );
4412
 
                        if ( ulResult != cOCT6100_ERR_OK )
4413
 
                                return ulResult;
4414
 
                        
4415
 
                        /* Form channel handle. */
4416
 
                        BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4417
 
 
4418
 
                        /* Remove all broadcast TSSTs associated to the current channel. */
4419
 
                        BroadcastTsstRemove.fRemoveAll = TRUE;
4420
 
 
4421
 
                        /* On the Rout port. */
4422
 
                        BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_ROUT; 
4423
 
 
4424
 
                        ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove );
4425
 
                        if ( ulResult != cOCT6100_ERR_OK )
4426
 
                                return ulResult;
4427
 
                }
4428
 
 
4429
 
 
4430
 
                /* Check if broadcast TSSTs were used on the Sout port. */
4431
 
                if ( pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX )
4432
 
                {
4433
 
                        tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE  BroadcastTsstRemove;
4434
 
 
4435
 
                        ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove );
4436
 
                        if ( ulResult != cOCT6100_ERR_OK )
4437
 
                                return ulResult;
4438
 
                        
4439
 
                        /* Form channel handle. */
4440
 
                        BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4441
 
 
4442
 
                        /* Remove all broadcast TSSTs associated to the current channel. */
4443
 
                        BroadcastTsstRemove.fRemoveAll = TRUE;
4444
 
 
4445
 
                        /* On the Sout port. */
4446
 
                        BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_SOUT;
4447
 
 
4448
 
                        ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove );
4449
 
                        if ( ulResult != cOCT6100_ERR_OK )
4450
 
                                return ulResult;
4451
 
                }
4452
 
        }
4453
 
 
4454
 
        /* Check if have to make sure buffer playout is stopped. */
4455
 
        if ( fClearPlayoutPointers == TRUE )
4456
 
        {       
4457
 
                tOCT6100_BUFFER_PLAYOUT_STOP    BufferPlayoutStop;
4458
 
 
4459
 
                Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
4460
 
 
4461
 
                BufferPlayoutStop.fStopCleanly = FALSE;
4462
 
                BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
4463
 
 
4464
 
                ulResult = Oct6100ApiInvalidateChanPlayoutStructs( 
4465
 
                                                                                                        f_pApiInstance, 
4466
 
                                                                                                        &BufferPlayoutStop, 
4467
 
                                                                                                        f_usChanIndex, 
4468
 
                                                                                                        pChanEntry->usEchoMemIndex 
4469
 
 
4470
 
                                                                                                        );
4471
 
                if ( ulResult != cOCT6100_ERR_OK )
4472
 
                        return ulResult;
4473
 
                
4474
 
                BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
4475
 
                ulResult = Oct6100ApiInvalidateChanPlayoutStructs( 
4476
 
                                                                                                        f_pApiInstance, 
4477
 
                                                                                                        &BufferPlayoutStop, 
4478
 
                                                                                                        f_usChanIndex, 
4479
 
                                                                                                        pChanEntry->usEchoMemIndex 
4480
 
 
4481
 
                                                                                                        );
4482
 
                if ( ulResult != cOCT6100_ERR_OK )
4483
 
                        return ulResult;
4484
 
        }
4485
 
 
4486
 
        return cOCT6100_ERR_OK;
4487
 
}
4488
 
 
4489
 
 
4490
 
 
4491
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4492
 
 
4493
 
Function:               Oct6100ApiModifyChannelEntry
4494
 
 
4495
 
Description:    Updates the channel structure in the ECHO channel list.
4496
 
 
4497
 
-------------------------------------------------------------------------------
4498
 
|       Argument                |       Description
4499
 
-------------------------------------------------------------------------------
4500
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
4501
 
                                                        the present state of the chip and all its resources.
4502
 
 
4503
 
f_pChannelModify                        Pointer to echo cancellation channel modify structure.
4504
 
f_pChannelOpen                          Pointer to echo cancellation channel configuration structure.
4505
 
f_usChanIndex                           Index of the channel within the API's channel list.
4506
 
f_usNewPhasingTsstIndex         Index of the new phasing TSST.
4507
 
f_fSinSoutCodecActive           State of the SIN/SOUT codec.
4508
 
f_fRinRoutCodecActive           State of the RIN/ROUT codec.
4509
 
f_usNewRinTsstIndex                     New RIN TSST memory index.
4510
 
f_usNewSinTsstIndex                     New SIN TSST memory index.
4511
 
f_usNewRoutTsstIndex            New ROUT TSST memory index.
4512
 
f_usNewSoutTsstIndex            New SOUT TSST memory index.
4513
 
 
4514
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4515
 
static UINT32 Oct6100ApiModifyChannelEntry(
4516
 
                                IN tPOCT6100_INSTANCE_API                       f_pApiInstance,
4517
 
                                IN tPOCT6100_CHANNEL_MODIFY                     f_pChannelModify,
4518
 
                                IN tPOCT6100_CHANNEL_OPEN                       f_pChannelOpen,
4519
 
                                IN UINT16                                                       f_usChanIndex,
4520
 
                                IN UINT16                                                       f_usNewPhasingTsstIndex,
4521
 
                                IN UINT8                                                        f_fSinSoutCodecActive,
4522
 
                                IN UINT8                                                        f_fRinRoutCodecActive,
4523
 
                                IN UINT16                                                       f_usNewRinTsstIndex,
4524
 
                                IN UINT16                                                       f_usNewSinTsstIndex,
4525
 
                                IN UINT16                                                       f_usNewRoutTsstIndex,
4526
 
                                IN UINT16                                                       f_usNewSoutTsstIndex )
4527
 
{
4528
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
4529
 
        tPOCT6100_API_CHANNEL           pChanEntry;
4530
 
        tPOCT6100_API_CHANNEL_CODEC     pApiCodecConf;
4531
 
        tPOCT6100_API_CHANNEL_TDM       pApiTdmConf;
4532
 
        tPOCT6100_API_CHANNEL_VQE       pApiVqeConf;
4533
 
 
4534
 
        /* Obtain local pointer to shared portion of instance. */
4535
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
4536
 
 
4537
 
        /*=======================================================================*/
4538
 
        /* Get a pointer to the channel's list entry. */
4539
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
4540
 
 
4541
 
        /* Obtain local pointer to the configuration structures of the tPOCT6100_API_CHANNEL structure. */
4542
 
        pApiCodecConf = &pChanEntry->CodecConfig;
4543
 
        pApiTdmConf   = &pChanEntry->TdmConfig;
4544
 
        pApiVqeConf   = &pChanEntry->VqeConfig;
4545
 
 
4546
 
        /*=======================================================================*/
4547
 
        /* Copy the channel's general configuration. */
4548
 
 
4549
 
        pChanEntry->ulUserChanId = f_pChannelOpen->ulUserChanId;
4550
 
        pChanEntry->byEchoOperationMode = (UINT8)( f_pChannelOpen->ulEchoOperationMode & 0xFF );
4551
 
        pChanEntry->fEnableToneDisabler = (UINT8)( f_pChannelOpen->fEnableToneDisabler & 0xFF );
4552
 
 
4553
 
        /* Save the codec state.*/
4554
 
        pChanEntry->fSinSoutCodecActive = (UINT8)( f_fSinSoutCodecActive & 0xFF );
4555
 
        pChanEntry->fRinRoutCodecActive = (UINT8)( f_fRinRoutCodecActive & 0xFF );
4556
 
 
4557
 
        /*=======================================================================*/
4558
 
        /* Copy the channel's TDM configuration of all the modified fields. */
4559
 
 
4560
 
        if ( f_pChannelModify->fTdmConfigModified == TRUE )
4561
 
        {
4562
 
                pApiTdmConf->byRinPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulRinPcmLaw & 0xFF );
4563
 
                pApiTdmConf->bySinPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulSinPcmLaw & 0xFF );
4564
 
                pApiTdmConf->byRoutPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulRoutPcmLaw & 0xFF );
4565
 
                pApiTdmConf->bySoutPcmLaw = (UINT8)( f_pChannelOpen->TdmConfig.ulSoutPcmLaw & 0xFF );
4566
 
 
4567
 
                pApiTdmConf->byRinNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulRinNumTssts & 0xFF );
4568
 
                pApiTdmConf->bySinNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulSinNumTssts & 0xFF );
4569
 
                pApiTdmConf->byRoutNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulRoutNumTssts & 0xFF );
4570
 
                pApiTdmConf->bySoutNumTssts = (UINT8)( f_pChannelOpen->TdmConfig.ulSoutNumTssts & 0xFF );
4571
 
 
4572
 
                if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) 
4573
 
                {
4574
 
                        if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX )
4575
 
                        {
4576
 
                                pApiTdmConf->usRinStream        = (UINT16)( f_pChannelOpen->TdmConfig.ulRinStream & 0xFFFF );
4577
 
                                pApiTdmConf->usRinTimeslot      = (UINT16)( f_pChannelOpen->TdmConfig.ulRinTimeslot & 0xFFFF );
4578
 
                                pChanEntry->usRinTsstIndex      = f_usNewRinTsstIndex;
4579
 
                        }
4580
 
                        else /* f_ulNewRinTsstIndex != cOCT6100_INVALID_INDEX */
4581
 
                        {
4582
 
                                pApiTdmConf->usRinStream        = cOCT6100_UNASSIGNED;
4583
 
                                pApiTdmConf->usRinTimeslot      = cOCT6100_UNASSIGNED;
4584
 
                                pChanEntry->usRinTsstIndex      = cOCT6100_INVALID_INDEX;
4585
 
                        }
4586
 
                }
4587
 
 
4588
 
                if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) 
4589
 
                {
4590
 
                        if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX )
4591
 
                        {
4592
 
                                pApiTdmConf->usSinStream        = (UINT16)( f_pChannelOpen->TdmConfig.ulSinStream & 0xFFFF );
4593
 
                                pApiTdmConf->usSinTimeslot      = (UINT16)( f_pChannelOpen->TdmConfig.ulSinTimeslot & 0xFFFF );
4594
 
                                pChanEntry->usSinTsstIndex      = f_usNewSinTsstIndex;
4595
 
                        }
4596
 
                        else /* f_ulNewSinTsstIndex != cOCT6100_INVALID_INDEX */
4597
 
                        {
4598
 
                                pApiTdmConf->usSinStream        = cOCT6100_UNASSIGNED;
4599
 
                                pApiTdmConf->usSinTimeslot      = cOCT6100_UNASSIGNED;
4600
 
                                pChanEntry->usSinTsstIndex      = cOCT6100_INVALID_INDEX;
4601
 
                        }
4602
 
                }
4603
 
 
4604
 
                if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) 
4605
 
                {
4606
 
                        if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX )
4607
 
                        {
4608
 
                                pApiTdmConf->usRoutStream       = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutStream & 0xFFFF );
4609
 
                                pApiTdmConf->usRoutTimeslot     = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutTimeslot & 0xFFFF );
4610
 
                                pChanEntry->usRoutTsstIndex     = f_usNewRoutTsstIndex;
4611
 
                        }
4612
 
                        else /* f_ulNewRoutTsstIndex != cOCT6100_INVALID_INDEX */
4613
 
                        {
4614
 
                                pApiTdmConf->usRoutStream       = cOCT6100_UNASSIGNED;
4615
 
                                pApiTdmConf->usRoutTimeslot     = cOCT6100_UNASSIGNED;
4616
 
                                pChanEntry->usRoutTsstIndex     = cOCT6100_INVALID_INDEX;
4617
 
                        }
4618
 
                }
4619
 
 
4620
 
                if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) 
4621
 
                {
4622
 
                        if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX )
4623
 
                        {
4624
 
                                pApiTdmConf->usSoutStream       = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutStream & 0xFFFF );
4625
 
                                pApiTdmConf->usSoutTimeslot     = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutTimeslot & 0xFFFF );
4626
 
                                pChanEntry->usSoutTsstIndex     = f_usNewSoutTsstIndex;
4627
 
                        }
4628
 
                        else /* f_ulNewSoutTsstIndex != cOCT6100_INVALID_INDEX */
4629
 
                        {
4630
 
                                pApiTdmConf->usSoutStream       = cOCT6100_UNASSIGNED;
4631
 
                                pApiTdmConf->usSoutTimeslot     = cOCT6100_UNASSIGNED;
4632
 
                                pChanEntry->usSoutTsstIndex     = cOCT6100_INVALID_INDEX;
4633
 
                        }
4634
 
                }
4635
 
        }
4636
 
        
4637
 
        /*=======================================================================*/
4638
 
        /* Copy the channel's VQE configuration of all the modified fields. */
4639
 
 
4640
 
        if ( f_pChannelModify->fVqeConfigModified == TRUE )
4641
 
        {
4642
 
                pApiVqeConf->fEnableNlp                                                                 = (UINT8)( f_pChannelOpen->VqeConfig.fEnableNlp & 0xFF );
4643
 
                pApiVqeConf->byComfortNoiseMode                                                 = (UINT8)( f_pChannelOpen->VqeConfig.ulComfortNoiseMode & 0xFF );
4644
 
                pApiVqeConf->fSinDcOffsetRemoval                                                = (UINT8)( f_pChannelOpen->VqeConfig.fSinDcOffsetRemoval & 0xFF );
4645
 
                pApiVqeConf->fRinDcOffsetRemoval                                                = (UINT8)( f_pChannelOpen->VqeConfig.fRinDcOffsetRemoval & 0xFF );
4646
 
                pApiVqeConf->fRinLevelControl                                                   = (UINT8)( f_pChannelOpen->VqeConfig.fRinLevelControl & 0xFF );
4647
 
                pApiVqeConf->fSoutLevelControl                                                  = (UINT8)( f_pChannelOpen->VqeConfig.fSoutLevelControl & 0xFF );
4648
 
                pApiVqeConf->fRinAutomaticLevelControl                                  = (UINT8)( f_pChannelOpen->VqeConfig.fRinAutomaticLevelControl & 0xFF );
4649
 
                pApiVqeConf->fSoutAutomaticLevelControl                                 = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAutomaticLevelControl & 0xFF );
4650
 
                pApiVqeConf->fRinHighLevelCompensation                                  = (UINT8)( f_pChannelOpen->VqeConfig.fRinHighLevelCompensation & 0xFF );
4651
 
 
4652
 
                pApiVqeConf->fSoutAdaptiveNoiseReduction                                = (UINT8)( f_pChannelOpen->VqeConfig.fSoutAdaptiveNoiseReduction & 0xFF );
4653
 
                pApiVqeConf->fSoutNoiseBleaching                                                = (UINT8)( f_pChannelOpen->VqeConfig.fSoutNoiseBleaching & 0xFF );
4654
 
                pApiVqeConf->fSoutConferencingNoiseReduction                    = (UINT8)( f_pChannelOpen->VqeConfig.fSoutConferencingNoiseReduction & 0xFF );
4655
 
                pApiVqeConf->chRinLevelControlGainDb                                    = (INT8)( f_pChannelOpen->VqeConfig.lRinLevelControlGainDb & 0xFF );
4656
 
                pApiVqeConf->chSoutLevelControlGainDb                                   = (INT8)( f_pChannelOpen->VqeConfig.lSoutLevelControlGainDb & 0xFF );
4657
 
                pApiVqeConf->chRinAutomaticLevelControlTargetDb                 = (INT8)( f_pChannelOpen->VqeConfig.lRinAutomaticLevelControlTargetDb & 0xFF );
4658
 
                pApiVqeConf->chSoutAutomaticLevelControlTargetDb                = (INT8)( f_pChannelOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb & 0xFF );
4659
 
                pApiVqeConf->chRinHighLevelCompensationThresholdDb              = (INT8)( f_pChannelOpen->VqeConfig.lRinHighLevelCompensationThresholdDb & 0xFF );
4660
 
                pApiVqeConf->fEnableTailDisplacement                                    = (UINT8)( f_pChannelOpen->VqeConfig.fEnableTailDisplacement & 0xFF );
4661
 
                pApiVqeConf->usTailDisplacement                                                 = (UINT16)( f_pChannelOpen->VqeConfig.ulTailDisplacement & 0xFFFF );
4662
 
                pApiVqeConf->usTailLength                                                               = (UINT16)( f_pChannelOpen->VqeConfig.ulTailLength & 0xFFFF );
4663
 
                pApiVqeConf->fAcousticEcho                                                              = (UINT8)( f_pChannelOpen->VqeConfig.fAcousticEcho & 0xFF );
4664
 
                pApiVqeConf->fDtmfToneRemoval                                                   = (UINT8)( f_pChannelOpen->VqeConfig.fDtmfToneRemoval & 0xFF );
4665
 
 
4666
 
                pApiVqeConf->chDefaultErlDb                                                             = (INT8)( f_pChannelOpen->VqeConfig.lDefaultErlDb & 0xFF );
4667
 
                pApiVqeConf->chAecDefaultErlDb                                                  = (INT8)( f_pChannelOpen->VqeConfig.lAecDefaultErlDb & 0xFF );
4668
 
                pApiVqeConf->usAecTailLength                                                    = (UINT16)( f_pChannelOpen->VqeConfig.ulAecTailLength & 0xFFFF );
4669
 
                pApiVqeConf->chAnrSnrEnhancementDb                                              = (INT8)( f_pChannelOpen->VqeConfig.lAnrSnrEnhancementDb & 0xFF );
4670
 
                pApiVqeConf->byAnrVoiceNoiseSegregation                                 = (UINT8)( f_pChannelOpen->VqeConfig.ulAnrVoiceNoiseSegregation & 0xFF );
4671
 
                pApiVqeConf->usToneDisablerVqeActivationDelay                   = (UINT16)( f_pChannelOpen->VqeConfig.ulToneDisablerVqeActivationDelay & 0xFFFF );
4672
 
                pApiVqeConf->byNonLinearityBehaviorA                                    = (UINT8)( f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorA & 0xFF );
4673
 
                pApiVqeConf->byNonLinearityBehaviorB                                    = (UINT8)( f_pChannelOpen->VqeConfig.ulNonLinearityBehaviorB & 0xFF );
4674
 
                pApiVqeConf->byDoubleTalkBehavior                                               = (UINT8)( f_pChannelOpen->VqeConfig.ulDoubleTalkBehavior & 0xFF );
4675
 
                pApiVqeConf->bySoutAutomaticListenerEnhancementGainDb   = (UINT8)( f_pChannelOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb & 0xFF );
4676
 
                pApiVqeConf->bySoutNaturalListenerEnhancementGainDb             = (UINT8)( f_pChannelOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb & 0xFF );
4677
 
                pApiVqeConf->fSoutNaturalListenerEnhancement                    = (UINT8)( f_pChannelOpen->VqeConfig.fSoutNaturalListenerEnhancement & 0xFF );
4678
 
                pApiVqeConf->fRoutNoiseReduction                                                = (UINT8)( f_pChannelOpen->VqeConfig.fRoutNoiseReduction & 0xFF );
4679
 
                pApiVqeConf->fEnableMusicProtection                                             = (UINT8)( f_pChannelOpen->VqeConfig.fEnableMusicProtection & 0xFF );
4680
 
                pApiVqeConf->fIdleCodeDetection                                                 = (UINT8)( f_pChannelOpen->VqeConfig.fIdleCodeDetection & 0xFF );
4681
 
        }
4682
 
 
4683
 
        /*=======================================================================*/
4684
 
        /* Copy the channel's CODEC configuration of all the modified fields. */
4685
 
        if ( f_pChannelModify->fCodecConfigModified == TRUE )
4686
 
        {
4687
 
                pApiCodecConf->byAdpcmNibblePosition            = (UINT8)( f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition & 0xFF );
4688
 
                pApiCodecConf->byEncoderPort                            = (UINT8)( f_pChannelOpen->CodecConfig.ulEncoderPort & 0xFF );
4689
 
                pApiCodecConf->byEncodingRate                           = (UINT8)( f_pChannelOpen->CodecConfig.ulEncodingRate & 0xFF );
4690
 
                pApiCodecConf->byDecoderPort                            = (UINT8)( f_pChannelOpen->CodecConfig.ulDecoderPort & 0xFF );
4691
 
                pApiCodecConf->byDecodingRate                           = (UINT8)( f_pChannelOpen->CodecConfig.ulDecodingRate & 0xFF );
4692
 
                pApiCodecConf->fEnableSilenceSuppression        = (UINT8)( f_pChannelOpen->CodecConfig.fEnableSilenceSuppression & 0xFF );
4693
 
                pApiCodecConf->byPhase                                          = (UINT8)( f_pChannelOpen->CodecConfig.ulPhase & 0xFF );
4694
 
                pApiCodecConf->byPhasingType                            = (UINT8)( f_pChannelOpen->CodecConfig.ulPhasingType & 0xFF );
4695
 
 
4696
 
                /* Update the API phasing TSST structure */
4697
 
                if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX )
4698
 
                {
4699
 
                        tPOCT6100_API_PHASING_TSST      pPhasingTsst;
4700
 
 
4701
 
                        /* Release the previous phasing TSST if the channel was already bound to one.*/
4702
 
                        if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
4703
 
                        {
4704
 
                                mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, pChanEntry->usPhasingTsstIndex );
4705
 
 
4706
 
                                pPhasingTsst->usDependencyCnt--;
4707
 
                        }
4708
 
                        
4709
 
                        mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, f_usNewPhasingTsstIndex );
4710
 
 
4711
 
                        pPhasingTsst->usDependencyCnt++;
4712
 
                        pChanEntry->usPhasingTsstIndex = f_usNewPhasingTsstIndex;
4713
 
 
4714
 
                }
4715
 
        }
4716
 
 
4717
 
 
4718
 
 
4719
 
        return cOCT6100_ERR_OK;
4720
 
}
4721
 
 
4722
 
 
4723
 
 
4724
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4725
 
 
4726
 
Function:               Oct6100ChannelBroadcastTsstRemoveSer
4727
 
 
4728
 
Description:    Removes a broadcast TSST from one of the output port of an 
4729
 
                                echo cancellation channel.
4730
 
 
4731
 
-------------------------------------------------------------------------------
4732
 
|       Argument                |       Description
4733
 
-------------------------------------------------------------------------------
4734
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
4735
 
                                                present state of the chip and all its resources.
4736
 
 
4737
 
f_pChannelTsstRemove    Pointer to TSST remove structure.  
4738
 
 
4739
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4740
 
static UINT32 Oct6100ChannelBroadcastTsstRemoveSer(
4741
 
                                IN tPOCT6100_INSTANCE_API                                               f_pApiInstance,
4742
 
                                IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE  f_pChannelTsstRemove)
4743
 
{
4744
 
        UINT16  usChanIndex;
4745
 
        UINT16  usTsstIndex;
4746
 
        UINT16  usTsstEntry;
4747
 
        UINT16  usPrevTsstEntry;
4748
 
        UINT32  ulResult;
4749
 
 
4750
 
        ulResult = Oct6100ApiAssertChanTsstRemoveParams( f_pApiInstance, f_pChannelTsstRemove, &usChanIndex, &usTsstIndex, &usTsstEntry, &usPrevTsstEntry );
4751
 
        if ( ulResult != cOCT6100_ERR_OK  )
4752
 
                return ulResult;
4753
 
 
4754
 
        ulResult = Oct6100ApiInvalidateTsstRemoveStructs( f_pApiInstance, usChanIndex, usTsstIndex, f_pChannelTsstRemove->ulPort, f_pChannelTsstRemove->fRemoveAll );
4755
 
        if ( ulResult != cOCT6100_ERR_OK  )
4756
 
                return ulResult;
4757
 
 
4758
 
        ulResult = Oct6100ApiReleaseTsstRemoveResources( f_pApiInstance, f_pChannelTsstRemove, usChanIndex, usTsstIndex, usTsstEntry, usPrevTsstEntry );
4759
 
        if ( ulResult != cOCT6100_ERR_OK  )
4760
 
                return ulResult;
4761
 
 
4762
 
        return cOCT6100_ERR_OK;
4763
 
}
4764
 
 
4765
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4766
 
 
4767
 
Function:               Oct6100ApiAssertChanTsstRemoveParams
4768
 
 
4769
 
Description:    Verify the validity of the tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE
4770
 
                                structure.
4771
 
 
4772
 
-------------------------------------------------------------------------------
4773
 
|       Argument                |       Description
4774
 
-------------------------------------------------------------------------------
4775
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
4776
 
                                                present state of the chip and all its resources.
4777
 
 
4778
 
f_pChannelTsstRemove    Pointer to echo cancellation channel open configuration structure.
4779
 
f_pulChanIndex                  Pointer to a channel index.
4780
 
f_pulNewTsstIndex               Pointer to a TSST index within the TSST control memory.
4781
 
f_pulNewTsstEntry               Pointer to a TSST entry within the API TSST list.
4782
 
f_pulPrevTsstEntry              Pointer to the previous TSST entry.
4783
 
 
4784
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4785
 
static UINT32 Oct6100ApiAssertChanTsstRemoveParams(
4786
 
                                IN  tPOCT6100_INSTANCE_API                                      f_pApiInstance,
4787
 
                                IN  tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE     f_pChannelTsstRemove, 
4788
 
                                OUT PUINT16                                                                     f_pusChanIndex,
4789
 
                                OUT     PUINT16                                                                 f_pusTsstIndex,
4790
 
                                OUT     PUINT16                                                                 f_pusTsstEntry,
4791
 
                                OUT     PUINT16                                                                 f_pusPrevTsstEntry )
4792
 
{
4793
 
        tPOCT6100_API_CHANNEL           pChanEntry;
4794
 
        tPOCT6100_API_TSST_ENTRY        pTsstEntry;
4795
 
        UINT32  ulResult;
4796
 
        UINT32  ulNumTssts = 1;
4797
 
        UINT32  ulEntryOpenCnt;
4798
 
        UINT16  usCurrentEntry;
4799
 
        UINT16  usTsstValue;
4800
 
        UINT16  usNumEntry;
4801
 
        
4802
 
        /* Check the provided handle. */
4803
 
        if ( (f_pChannelTsstRemove->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
4804
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
4805
 
 
4806
 
        *f_pusChanIndex = (UINT16)( f_pChannelTsstRemove->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
4807
 
        if ( *f_pusChanIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
4808
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
4809
 
 
4810
 
        /*=======================================================================*/
4811
 
        /* Get a pointer to the channel's list entry. */
4812
 
 
4813
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
4814
 
 
4815
 
        /* Extract the entry open count from the provided handle. */
4816
 
        ulEntryOpenCnt = ( f_pChannelTsstRemove->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
4817
 
 
4818
 
        /* Check for errors. */
4819
 
        if ( pChanEntry->fReserved != TRUE )
4820
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
4821
 
        if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
4822
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
4823
 
 
4824
 
        /*=======================================================================*/
4825
 
 
4826
 
        /* validate the port parameter.*/
4827
 
        if ( f_pChannelTsstRemove->ulPort != cOCT6100_CHANNEL_PORT_ROUT &&
4828
 
                 f_pChannelTsstRemove->ulPort != cOCT6100_CHANNEL_PORT_SOUT )
4829
 
                return cOCT6100_ERR_CHANNEL_TSST_REMOVE_PORT;
4830
 
 
4831
 
        /* Verify that the requested entry is present in the channel's port broadcast TSST.*/
4832
 
        if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
4833
 
        {
4834
 
                usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
4835
 
                usNumEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry;
4836
 
        }
4837
 
        else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
4838
 
        {
4839
 
                usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
4840
 
                usNumEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry;
4841
 
        }
4842
 
 
4843
 
        /* Verify if at least one TSST is present on the channel port.*/
4844
 
        if ( usNumEntry == 0 )
4845
 
                return cOCT6100_ERR_CHANNEL_TSST_REMOVE_NO_BROADCAST_TSST;
4846
 
 
4847
 
        /* Get the required number of TSST based on the port.*/
4848
 
        switch( f_pChannelTsstRemove->ulPort )
4849
 
        {
4850
 
        case cOCT6100_CHANNEL_PORT_ROUT:
4851
 
                ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
4852
 
                break;
4853
 
        case cOCT6100_CHANNEL_PORT_SOUT:
4854
 
                ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
4855
 
                break;
4856
 
        default:
4857
 
                return cOCT6100_ERR_FATAL_E;
4858
 
        }
4859
 
 
4860
 
        /* Initialize the TSST entry to invalid.*/
4861
 
        *f_pusTsstEntry         = cOCT6100_INVALID_INDEX;
4862
 
        *f_pusPrevTsstEntry     = cOCT6100_INVALID_INDEX;
4863
 
        *f_pusTsstIndex         = cOCT6100_INVALID_INDEX;
4864
 
 
4865
 
        if ( f_pChannelTsstRemove->fRemoveAll != TRUE )
4866
 
        {
4867
 
                /* Check the validity of the timeslot and Stream.*/
4868
 
                ulResult = Oct6100ApiValidateTsst( f_pApiInstance, 
4869
 
                                                                                   ulNumTssts,
4870
 
                                                                                   f_pChannelTsstRemove->ulTimeslot, 
4871
 
                                                                                   f_pChannelTsstRemove->ulStream,
4872
 
                                                                                   cOCT6100_OUTPUT_TSST );
4873
 
                if ( ulResult != cOCT6100_ERR_OK  )
4874
 
                {
4875
 
                        if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
4876
 
                        {
4877
 
                                return cOCT6100_ERR_CHANNEL_TSST_REMOVE_TIMESLOT;
4878
 
                        }
4879
 
                        else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
4880
 
                        {
4881
 
                                return cOCT6100_ERR_CHANNEL_TSST_REMOVE_STREAM;
4882
 
                        }
4883
 
                        else
4884
 
                        {
4885
 
                                return ulResult;
4886
 
                        }
4887
 
                }
4888
 
        
4889
 
                /* Set the TSST value based on the timeslot and stream value.*/
4890
 
                usTsstValue = (UINT16)( (f_pChannelTsstRemove->ulTimeslot << 5) | f_pChannelTsstRemove->ulStream );
4891
 
 
4892
 
                while( usCurrentEntry != cOCT6100_INVALID_INDEX )
4893
 
                {
4894
 
                        mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
4895
 
 
4896
 
                        if ( usTsstValue == pTsstEntry->usTsstValue )
4897
 
                        {
4898
 
                                /* A match was found.*/
4899
 
                                *f_pusTsstEntry = usCurrentEntry;
4900
 
                                *f_pusTsstIndex = pTsstEntry->usTsstMemoryIndex;
4901
 
                                break;
4902
 
                        }
4903
 
 
4904
 
                        /* Move on to the next entry.*/
4905
 
                        *f_pusPrevTsstEntry = usCurrentEntry;
4906
 
                        usCurrentEntry = pTsstEntry->usNextEntry;
4907
 
                }
4908
 
 
4909
 
                if ( *f_pusTsstEntry == cOCT6100_INVALID_INDEX )
4910
 
                        return cOCT6100_ERR_CHANNEL_TSST_REMOVE_INVALID_TSST;
4911
 
        }
4912
 
        
4913
 
        return cOCT6100_ERR_OK;
4914
 
}       
4915
 
 
4916
 
 
4917
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4918
 
 
4919
 
Function:               Oct6100ApiInvalidateTsstRemoveStructs
4920
 
 
4921
 
Description:    Invalidate the entry of the broadcast TSST.
4922
 
 
4923
 
-------------------------------------------------------------------------------
4924
 
|       Argument                |       Description
4925
 
-------------------------------------------------------------------------------
4926
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
4927
 
                                                present state of the chip and all its resources.
4928
 
 
4929
 
f_usChanIndex                   Channel index.
4930
 
f_usTsstIndex                   TSST index within the TSST control memory.
4931
 
f_ulPort                                Channel port where the TSST are removed from. (only used if remove all == TRUE)
4932
 
f_fRemoveAll                    Remove all flag.
4933
 
 
4934
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4935
 
static UINT32 Oct6100ApiInvalidateTsstRemoveStructs(
4936
 
                                IN  tPOCT6100_INSTANCE_API                                      f_pApiInstance,
4937
 
                                IN      UINT16                                                                  f_usChanIndex,
4938
 
                                IN      UINT16                                                                  f_usTsstIndex,
4939
 
                                IN      UINT32                                                                  f_ulPort,
4940
 
                                IN      BOOL                                                                    f_fRemoveAll )
4941
 
{
4942
 
        tOCT6100_WRITE_PARAMS           WriteParams;
4943
 
        UINT32  ulResult;
4944
 
 
4945
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4946
 
 
4947
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4948
 
 
4949
 
        if ( f_fRemoveAll == FALSE )
4950
 
        {
4951
 
                /* Deactivate the entry now.*/
4952
 
                WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4953
 
                WriteParams.usWriteData  = 0x0000;
4954
 
 
4955
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4956
 
                if ( ulResult != cOCT6100_ERR_OK  )
4957
 
                        return ulResult;
4958
 
        }
4959
 
        else /* f_fRemoveAll == TRUE */
4960
 
        {
4961
 
                tPOCT6100_API_CHANNEL           pChanEntry;
4962
 
                tPOCT6100_API_TSST_ENTRY        pTsstEntry;
4963
 
                UINT16                                          usTsstEntry;
4964
 
 
4965
 
                /*=======================================================================*/
4966
 
                /* Get a pointer to the channel's list entry. */
4967
 
 
4968
 
                mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
4969
 
 
4970
 
                /* Clear all entry associated to the selected port.*/
4971
 
                if ( f_ulPort == cOCT6100_CHANNEL_PORT_ROUT )
4972
 
                        usTsstEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
4973
 
                else
4974
 
                        usTsstEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
4975
 
 
4976
 
                do
4977
 
                {
4978
 
                        mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usTsstEntry );
4979
 
 
4980
 
                        /* Deactivate the entry now.*/
4981
 
                        WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( ( pTsstEntry->usTsstMemoryIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
4982
 
                        WriteParams.usWriteData  = 0x0000;
4983
 
 
4984
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4985
 
                        if ( ulResult != cOCT6100_ERR_OK  )
4986
 
                                return ulResult;
4987
 
 
4988
 
                        usTsstEntry = pTsstEntry->usNextEntry;
4989
 
                
4990
 
                } while ( usTsstEntry != cOCT6100_INVALID_INDEX );
4991
 
        }
4992
 
 
4993
 
        return cOCT6100_ERR_OK;
4994
 
}       
4995
 
 
4996
 
 
4997
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4998
 
 
4999
 
Function:               Oct6100ApiReleaseTsstRemoveResources
5000
 
 
5001
 
Description:    Release all API resources associated to the Removed TSST and 
5002
 
                                update the channel entry accordingly.
5003
 
 
5004
 
-------------------------------------------------------------------------------
5005
 
|       Argument                |       Description
5006
 
-------------------------------------------------------------------------------
5007
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
5008
 
                                                present state of the chip and all its resources.
5009
 
 
5010
 
f_pChannelTsstRemove    Pointer to echo cancellation channel open configuration structure.
5011
 
f_usChanIndex                   Channel index.
5012
 
f_usTsstIndex                   TSST index within the TSST control memory.
5013
 
f_usTsstEntry                   TSST entry within the API's TSST list.
5014
 
f_usPrevTsstEntry               Previous TSST entry within the API's TSST list.
5015
 
 
5016
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5017
 
static UINT32 Oct6100ApiReleaseTsstRemoveResources(
5018
 
                                IN  tPOCT6100_INSTANCE_API                                      f_pApiInstance,
5019
 
                                IN  tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE     f_pChannelTsstRemove, 
5020
 
                                IN      UINT16                                                                  f_usChanIndex,
5021
 
                                IN      UINT16                                                                  f_usTsstIndex,
5022
 
                                IN      UINT16                                                                  f_usTsstEntry,
5023
 
                                IN      UINT16                                                                  f_usPrevTsstEntry )
5024
 
{
5025
 
        tPOCT6100_API_CHANNEL           pChanEntry;
5026
 
        tPOCT6100_API_TSST_ENTRY        pTsstEntry;
5027
 
        tPOCT6100_API_TSST_ENTRY        pPrevTsstEntry;
5028
 
        UINT16  usCurrentEntry;
5029
 
        UINT32  ulResult;
5030
 
        UINT32  ulTimeslot;
5031
 
        UINT32  ulStream;
5032
 
        /*=======================================================================*/
5033
 
        /* Get a pointer to the channel's list entry. */
5034
 
 
5035
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
5036
 
 
5037
 
        if ( f_pChannelTsstRemove->fRemoveAll == FALSE )
5038
 
        {
5039
 
                mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, f_usTsstEntry );
5040
 
 
5041
 
                /* Update the channel entry.*/
5042
 
                if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
5043
 
                {
5044
 
                        /* Check if the entry was the first in the list.*/
5045
 
                        if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX )
5046
 
                        {
5047
 
                                pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry;
5048
 
                        }
5049
 
                        else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */
5050
 
                        {
5051
 
                                /* Get a pointer to the previous entry.*/
5052
 
                                mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPrevTsstEntry, f_usPrevTsstEntry );
5053
 
                                pPrevTsstEntry->usNextEntry = pTsstEntry->usNextEntry;
5054
 
                        }
5055
 
 
5056
 
                        /* Decrement the number of entry.*/
5057
 
                        pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry--;
5058
 
                }
5059
 
                else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
5060
 
                {
5061
 
                        /* Check if the entry was the first in the list.*/
5062
 
                        if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX )
5063
 
                        {
5064
 
                                pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry;
5065
 
                        }
5066
 
                        else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */
5067
 
                        {
5068
 
                                /* Get a pointer to the previous entry.*/
5069
 
                                mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPrevTsstEntry, f_usPrevTsstEntry );
5070
 
                                pPrevTsstEntry->usNextEntry = pTsstEntry->usNextEntry;
5071
 
                        }
5072
 
 
5073
 
                        /* Decrement the number of entry.*/
5074
 
                        pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry--;
5075
 
                }
5076
 
 
5077
 
                ulTimeslot = pTsstEntry->usTsstValue >> 5;
5078
 
                ulStream = pTsstEntry->usTsstValue & 0x1F;
5079
 
 
5080
 
                /* Release the  entry.*/
5081
 
                ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
5082
 
                                                                                  ulTimeslot,
5083
 
                                                                                  ulStream,
5084
 
                                                                              cOCT6100_NUMBER_TSSTS_1,
5085
 
                                                                                  cOCT6100_OUTPUT_TSST,
5086
 
                                                                                  f_usTsstEntry );
5087
 
                if ( ulResult != cOCT6100_ERR_OK  )
5088
 
                        return ulResult;
5089
 
        }
5090
 
        else /* f_pChannelTsstRemove->fRemoveAll == TRUE */
5091
 
        {
5092
 
 
5093
 
                /* Update the channel entry.*/
5094
 
                if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
5095
 
                        usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
5096
 
                else
5097
 
                        usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
5098
 
 
5099
 
                do
5100
 
                {
5101
 
                        mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
5102
 
 
5103
 
                        ulTimeslot = pTsstEntry->usTsstValue >> 5;
5104
 
                        ulStream = pTsstEntry->usTsstValue & 0x1F;
5105
 
 
5106
 
                        /* Release the  entry.*/
5107
 
                        ulResult = Oct6100ApiReleaseTsst( f_pApiInstance, 
5108
 
                                                                                          ulTimeslot,
5109
 
                                                                                          ulStream,
5110
 
                                                                                          cOCT6100_NUMBER_TSSTS_1,
5111
 
                                                                                          cOCT6100_OUTPUT_TSST,
5112
 
                                                                                          usCurrentEntry );                     /* Release the  entry.*/
5113
 
                        if ( ulResult != cOCT6100_ERR_OK  )
5114
 
                                return ulResult;
5115
 
 
5116
 
                        usCurrentEntry = pTsstEntry->usNextEntry;
5117
 
 
5118
 
                        /* Clear the previous node.*/
5119
 
                        pTsstEntry->usTsstMemoryIndex = 0xFFFF;
5120
 
                        pTsstEntry->usTsstValue = 0xFFFF;
5121
 
                        pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
5122
 
 
5123
 
                } while ( usCurrentEntry != cOCT6100_INVALID_INDEX );
5124
 
                
5125
 
                /* Reset the channel status.*/
5126
 
                if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
5127
 
                {
5128
 
                        pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
5129
 
                        pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0;
5130
 
                }
5131
 
                else
5132
 
                {
5133
 
                        pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
5134
 
                        pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry = 0;
5135
 
                }
5136
 
        }
5137
 
        return cOCT6100_ERR_OK;
5138
 
}       
5139
 
 
5140
 
 
5141
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5142
 
 
5143
 
Function:               Oct6100ApiReserveEchoEntry
5144
 
 
5145
 
Description:    Reserves one of the echo channel API entry.
5146
 
 
5147
 
-------------------------------------------------------------------------------
5148
 
|       Argument                |       Description
5149
 
-------------------------------------------------------------------------------
5150
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
5151
 
                                                the present state of the chip and all its resources.
5152
 
 
5153
 
f_pusEchoIndex                  Resulting index reserved in the echo channel list.
5154
 
 
5155
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5156
 
static UINT32 Oct6100ApiReserveEchoEntry(
5157
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
5158
 
                                OUT     PUINT16                                         f_pusEchoIndex )
5159
 
{
5160
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
5161
 
        PVOID   pEchoAlloc;
5162
 
        UINT32  ulResult;
5163
 
        UINT32  ulEchoIndex;
5164
 
 
5165
 
        /* Get local pointer to shared portion of instance. */
5166
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
5167
 
 
5168
 
        mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc )
5169
 
        
5170
 
        ulResult = OctapiLlmAllocAlloc( pEchoAlloc, &ulEchoIndex );
5171
 
        if ( ulResult != cOCT6100_ERR_OK  )
5172
 
        {
5173
 
                if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
5174
 
                        return cOCT6100_ERR_CHANNEL_ALL_CHANNELS_ARE_OPENED;
5175
 
                else
5176
 
                        return cOCT6100_ERR_FATAL_11;
5177
 
        }
5178
 
 
5179
 
        *f_pusEchoIndex = (UINT16)( ulEchoIndex & 0xFFFF );
5180
 
 
5181
 
        return cOCT6100_ERR_OK;
5182
 
}
5183
 
 
5184
 
 
5185
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5186
 
 
5187
 
Function:               Oct6100ApiReleaseEchoEntry
5188
 
 
5189
 
Description:    Releases the specified ECHO channel API entry.
5190
 
 
5191
 
-------------------------------------------------------------------------------
5192
 
|       Argument                |       Description
5193
 
-------------------------------------------------------------------------------
5194
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
5195
 
                                                the present state of the chip and all its resources.
5196
 
 
5197
 
f_usEchoIndex                   Index reserved in the echo channel list.
5198
 
 
5199
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5200
 
static UINT32 Oct6100ApiReleaseEchoEntry(
5201
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
5202
 
                                IN      UINT16                                          f_usEchoIndex )
5203
 
{
5204
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
5205
 
        PVOID   pEchoAlloc;
5206
 
        UINT32  ulResult;
5207
 
 
5208
 
        /* Get local pointer to shared portion of instance. */
5209
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
5210
 
 
5211
 
        mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc )
5212
 
        
5213
 
        ulResult = OctapiLlmAllocDealloc( pEchoAlloc, f_usEchoIndex );
5214
 
        if ( ulResult != cOCT6100_ERR_OK  )
5215
 
        {
5216
 
                return cOCT6100_ERR_FATAL_12;
5217
 
        }
5218
 
 
5219
 
        return cOCT6100_ERR_OK;
5220
 
}
5221
 
 
5222
 
 
5223
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5224
 
 
5225
 
Function:               Oct6100ApiCheckTdmConfig
5226
 
 
5227
 
Description:    This function will check the validity of the TDM config parameter
5228
 
                                of an Open TDM config structure.
5229
 
 
5230
 
-------------------------------------------------------------------------------
5231
 
|       Argument                |       Description
5232
 
-------------------------------------------------------------------------------
5233
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
5234
 
                                                the present state of the chip and all its resources.
5235
 
 
5236
 
f_pTdmConfig                    TDM config of the channel.
5237
 
 
5238
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5239
 
static UINT32 Oct6100ApiCheckTdmConfig( 
5240
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
5241
 
                                IN      tPOCT6100_CHANNEL_OPEN_TDM              f_pTdmConfig )
5242
 
{
5243
 
        UINT32  ulResult;
5244
 
 
5245
 
        /*==============================================================================*/
5246
 
        /* Check the TDM configuration parameters.*/
5247
 
 
5248
 
        /* Check the validity of the timeslot and Stream only if it is defined.*/
5249
 
        if ( f_pTdmConfig->ulRinTimeslot != cOCT6100_UNASSIGNED || 
5250
 
                 f_pTdmConfig->ulRinStream != cOCT6100_UNASSIGNED )
5251
 
        {
5252
 
                if ( f_pTdmConfig->ulRinNumTssts != 1 &&
5253
 
                         f_pTdmConfig->ulRinNumTssts != 2 )
5254
 
                        return cOCT6100_ERR_CHANNEL_RIN_NUM_TSSTS;
5255
 
 
5256
 
                /* Check the RIN TDM streams, timeslots component for errors.*/
5257
 
                ulResult = Oct6100ApiValidateTsst( f_pApiInstance, 
5258
 
                                                                                   f_pTdmConfig->ulRinNumTssts,
5259
 
                                                                                   f_pTdmConfig->ulRinTimeslot, 
5260
 
                                                                                   f_pTdmConfig->ulRinStream,
5261
 
                                                                                   cOCT6100_INPUT_TSST );
5262
 
                if ( ulResult != cOCT6100_ERR_OK  )
5263
 
                {
5264
 
                        if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
5265
 
                        {
5266
 
                                return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
5267
 
                        }
5268
 
                        else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
5269
 
                        {
5270
 
                                return cOCT6100_ERR_CHANNEL_RIN_STREAM;
5271
 
                        }
5272
 
                        else
5273
 
                        {
5274
 
                                return ulResult;
5275
 
                        }
5276
 
                }
5277
 
        }
5278
 
 
5279
 
        /* Check the validity of the timeslot and Stream only if it is defined.*/
5280
 
        if ( f_pTdmConfig->ulRoutTimeslot != cOCT6100_UNASSIGNED || 
5281
 
                 f_pTdmConfig->ulRoutStream != cOCT6100_UNASSIGNED )
5282
 
        {
5283
 
                if ( f_pTdmConfig->ulRoutNumTssts != 1 &&
5284
 
                         f_pTdmConfig->ulRoutNumTssts != 2 )
5285
 
                        return cOCT6100_ERR_CHANNEL_ROUT_NUM_TSSTS;
5286
 
 
5287
 
                /* Check the ROUT TDM streams, timeslots component for errors.*/
5288
 
                ulResult = Oct6100ApiValidateTsst( f_pApiInstance, 
5289
 
                                                                                   f_pTdmConfig->ulRoutNumTssts,
5290
 
                                                                                   f_pTdmConfig->ulRoutTimeslot, 
5291
 
                                                                                   f_pTdmConfig->ulRoutStream,
5292
 
                                                                                   cOCT6100_OUTPUT_TSST );
5293
 
                if ( ulResult != cOCT6100_ERR_OK  )
5294
 
                {
5295
 
                        if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
5296
 
                        {
5297
 
                                return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT;
5298
 
                        }
5299
 
                        else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
5300
 
                        {
5301
 
                                return cOCT6100_ERR_CHANNEL_ROUT_STREAM;
5302
 
                        }
5303
 
                        else
5304
 
                        {
5305
 
                                return ulResult;
5306
 
                        }
5307
 
                }
5308
 
        }
5309
 
 
5310
 
        /* Check the validity of the timeslot and Stream only if it is defined.*/
5311
 
        if ( f_pTdmConfig->ulSinTimeslot != cOCT6100_UNASSIGNED || 
5312
 
                 f_pTdmConfig->ulSinStream != cOCT6100_UNASSIGNED )
5313
 
        {
5314
 
                if ( f_pTdmConfig->ulSinNumTssts != 1 &&
5315
 
                         f_pTdmConfig->ulSinNumTssts != 2 )
5316
 
                        return cOCT6100_ERR_CHANNEL_SIN_NUM_TSSTS;
5317
 
 
5318
 
                /* Check the SIN TDM streams, timeslots component for errors.*/
5319
 
                ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
5320
 
                                                                                   f_pTdmConfig->ulSinNumTssts, 
5321
 
                                                                                   f_pTdmConfig->ulSinTimeslot, 
5322
 
                                                                                   f_pTdmConfig->ulSinStream,
5323
 
                                                                                   cOCT6100_INPUT_TSST );
5324
 
                if ( ulResult != cOCT6100_ERR_OK  )
5325
 
                {
5326
 
                        if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
5327
 
                        {
5328
 
                                return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT;
5329
 
                        }
5330
 
                        else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
5331
 
                        {
5332
 
                                return cOCT6100_ERR_CHANNEL_SIN_STREAM;
5333
 
                        }
5334
 
                        else
5335
 
                        {
5336
 
                                return ulResult;
5337
 
                        }
5338
 
                }
5339
 
        }
5340
 
 
5341
 
        /* Check the validity of the timeslot and Stream only if it is defined.*/
5342
 
        if ( f_pTdmConfig->ulSoutTimeslot != cOCT6100_UNASSIGNED || 
5343
 
                 f_pTdmConfig->ulSoutStream != cOCT6100_UNASSIGNED )
5344
 
        {
5345
 
                if ( f_pTdmConfig->ulSoutNumTssts != 1 &&
5346
 
                         f_pTdmConfig->ulSoutNumTssts != 2 )
5347
 
                        return cOCT6100_ERR_CHANNEL_SOUT_NUM_TSSTS;
5348
 
 
5349
 
                /* Check the ROUT TDM streams, timeslots component for errors.*/
5350
 
                ulResult = Oct6100ApiValidateTsst( f_pApiInstance, 
5351
 
                                                                                   f_pTdmConfig->ulSoutNumTssts,
5352
 
                                                                                   f_pTdmConfig->ulSoutTimeslot, 
5353
 
                                                                                   f_pTdmConfig->ulSoutStream,
5354
 
                                                                                   cOCT6100_OUTPUT_TSST );
5355
 
                if ( ulResult != cOCT6100_ERR_OK  )
5356
 
                {
5357
 
                        if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
5358
 
                        {
5359
 
                                return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
5360
 
                        }
5361
 
                        else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
5362
 
                        {
5363
 
                                return cOCT6100_ERR_CHANNEL_SOUT_STREAM;
5364
 
                        }
5365
 
                        else
5366
 
                        {
5367
 
                                return ulResult;
5368
 
                        }
5369
 
                }
5370
 
        }       
5371
 
        
5372
 
        /* Check the PCM law parameters.*/
5373
 
        if ( f_pTdmConfig->ulRinPcmLaw != cOCT6100_PCM_U_LAW && 
5374
 
                 f_pTdmConfig->ulRinPcmLaw != cOCT6100_PCM_A_LAW )
5375
 
                return cOCT6100_ERR_CHANNEL_RIN_PCM_LAW;
5376
 
 
5377
 
        if ( f_pTdmConfig->ulSinPcmLaw != cOCT6100_PCM_U_LAW && 
5378
 
                 f_pTdmConfig->ulSinPcmLaw != cOCT6100_PCM_A_LAW )
5379
 
                return cOCT6100_ERR_CHANNEL_SIN_PCM_LAW;
5380
 
 
5381
 
        if ( f_pTdmConfig->ulRoutPcmLaw != cOCT6100_PCM_U_LAW && 
5382
 
                 f_pTdmConfig->ulRoutPcmLaw != cOCT6100_PCM_A_LAW )
5383
 
                return cOCT6100_ERR_CHANNEL_ROUT_PCM_LAW;
5384
 
 
5385
 
        if ( f_pTdmConfig->ulSoutPcmLaw != cOCT6100_PCM_U_LAW && 
5386
 
                 f_pTdmConfig->ulSoutPcmLaw != cOCT6100_PCM_A_LAW )
5387
 
                return cOCT6100_ERR_CHANNEL_SOUT_PCM_LAW;
5388
 
        
5389
 
        /*==============================================================================*/
5390
 
 
5391
 
 
5392
 
 
5393
 
        return cOCT6100_ERR_OK;
5394
 
}
5395
 
 
5396
 
 
5397
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5398
 
 
5399
 
Function:               Oct6100ApiCheckVqeConfig
5400
 
 
5401
 
Description:    This function will check the validity of the VQE config parameter
5402
 
                                of an Open VQE config structure.
5403
 
 
5404
 
-------------------------------------------------------------------------------
5405
 
|       Argument                |       Description
5406
 
-------------------------------------------------------------------------------
5407
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
5408
 
                                                the present state of the chip and all its resources.
5409
 
 
5410
 
f_pVqeConfig                    VQE config of the channel.
5411
 
f_fEnableToneDisabler   Whether the tone disabler is active or not.
5412
 
 
5413
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5414
 
static UINT32 Oct6100ApiCheckVqeConfig( 
5415
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
5416
 
                                IN              tPOCT6100_CHANNEL_OPEN_VQE              f_pVqeConfig,
5417
 
                                IN              BOOL                                                    f_fEnableToneDisabler )
5418
 
{
5419
 
        tPOCT6100_API_IMAGE_INFO                pImageInfo;
5420
 
 
5421
 
        pImageInfo = &f_pApiInstance->pSharedInfo->ImageInfo;
5422
 
 
5423
 
        if ( f_pVqeConfig->fEnableNlp != TRUE && f_pVqeConfig->fEnableNlp != FALSE )
5424
 
                return cOCT6100_ERR_CHANNEL_ENABLE_NLP;
5425
 
 
5426
 
        if ( f_pVqeConfig->fEnableNlp == TRUE && pImageInfo->fNlpControl == FALSE )
5427
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLP_CONTROL;
5428
 
        
5429
 
 
5430
 
 
5431
 
        /* Check the comfort noise mode.*/
5432
 
        if ( f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_OFF && pImageInfo->fComfortNoise == FALSE )
5433
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_BKG_NOISE_FREEZE;
5434
 
 
5435
 
        if ( f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_NORMAL && 
5436
 
                 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_EXTENDED &&
5437
 
                 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_FAST_LATCH &&
5438
 
                 f_pVqeConfig->ulComfortNoiseMode != cOCT6100_COMFORT_NOISE_OFF )
5439
 
                return cOCT6100_ERR_CHANNEL_COMFORT_NOISE_MODE;
5440
 
 
5441
 
        /* Check the DC offset removal.*/
5442
 
        if ( f_pVqeConfig->fSinDcOffsetRemoval != TRUE && f_pVqeConfig->fSinDcOffsetRemoval != FALSE )
5443
 
                return cOCT6100_ERR_CHANNEL_SIN_DC_OFFSET_REM;
5444
 
 
5445
 
        if ( f_pVqeConfig->fSinDcOffsetRemoval == TRUE && pImageInfo->fSinDcOffsetRemoval == FALSE )
5446
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_DC_OFFSET_REM;
5447
 
 
5448
 
        if ( f_pVqeConfig->fRinDcOffsetRemoval != TRUE && f_pVqeConfig->fRinDcOffsetRemoval != FALSE )
5449
 
                return cOCT6100_ERR_CHANNEL_RIN_DC_OFFSET_REM;
5450
 
 
5451
 
        if ( f_pVqeConfig->fRinDcOffsetRemoval == TRUE && pImageInfo->fRinDcOffsetRemoval == FALSE )
5452
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_DC_OFFSET_REM;
5453
 
 
5454
 
        /* Check the Level control.*/
5455
 
        if ( f_pVqeConfig->fRinLevelControl != TRUE && f_pVqeConfig->fRinLevelControl != FALSE )
5456
 
                return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL;
5457
 
 
5458
 
        if ( f_pVqeConfig->fSoutLevelControl != TRUE && f_pVqeConfig->fSoutLevelControl != FALSE )
5459
 
                return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL;
5460
 
 
5461
 
        if ( ( f_pVqeConfig->lRinLevelControlGainDb < -24 ) || ( f_pVqeConfig->lRinLevelControlGainDb >  24 ) )
5462
 
                return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL_GAIN;
5463
 
 
5464
 
        if ( ( f_pVqeConfig->lSoutLevelControlGainDb < -24 ) || ( f_pVqeConfig->lSoutLevelControlGainDb >  24 ) )
5465
 
                return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL_GAIN;
5466
 
 
5467
 
        if ( ( f_pVqeConfig->fRinAutomaticLevelControl != TRUE ) && ( f_pVqeConfig->fRinAutomaticLevelControl != FALSE ) )
5468
 
                return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL;
5469
 
 
5470
 
        if ( ( f_pVqeConfig->fRinHighLevelCompensation != TRUE ) && ( f_pVqeConfig->fRinHighLevelCompensation != FALSE ) )
5471
 
                return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP;
5472
 
 
5473
 
        if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) && ( pImageInfo->fRinAutoLevelControl == FALSE ) ) 
5474
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_AUTO_LC;
5475
 
 
5476
 
        if ( ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) && ( pImageInfo->fRinHighLevelCompensation == FALSE ) )
5477
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_HIGH_LEVEL_COMP;
5478
 
 
5479
 
        if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
5480
 
        {
5481
 
                if ( f_pVqeConfig->fRinLevelControl == TRUE )
5482
 
                        return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_MANUAL;
5483
 
 
5484
 
                if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
5485
 
                        return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_HIGH_LEVEL_COMP;
5486
 
 
5487
 
                if ( ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lRinAutomaticLevelControlTargetDb > 0 ) )
5488
 
                        return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL_TARGET;
5489
 
        }
5490
 
 
5491
 
        if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
5492
 
        {
5493
 
                if ( f_pVqeConfig->fRinLevelControl == TRUE )
5494
 
                        return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_MANUAL;
5495
 
 
5496
 
                if ( ( f_pVqeConfig->lRinHighLevelCompensationThresholdDb < -40 || f_pVqeConfig->lRinHighLevelCompensationThresholdDb > 0 ) )
5497
 
                        return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_THRESHOLD;
5498
 
        }
5499
 
 
5500
 
        if ( f_pVqeConfig->fSoutAutomaticLevelControl != TRUE && f_pVqeConfig->fSoutAutomaticLevelControl != FALSE )
5501
 
                return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL;
5502
 
 
5503
 
        if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) && ( pImageInfo->fSoutAutoLevelControl == FALSE ) ) 
5504
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SOUT_AUTO_LC;
5505
 
 
5506
 
        if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
5507
 
        {
5508
 
                if ( f_pVqeConfig->fSoutLevelControl == TRUE )
5509
 
                        return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_MANUAL;
5510
 
 
5511
 
                if ( ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lSoutAutomaticLevelControlTargetDb > 0 ) )
5512
 
                        return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL_TARGET;
5513
 
        }
5514
 
 
5515
 
        if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != TRUE && 
5516
 
                 f_pVqeConfig->fSoutAdaptiveNoiseReduction != FALSE )
5517
 
                return cOCT6100_ERR_CHANNEL_SOUT_ADAPT_NOISE_REDUCTION;
5518
 
 
5519
 
        if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE && pImageInfo->fAdaptiveNoiseReduction == FALSE )
5520
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR;
5521
 
 
5522
 
        if ( f_pVqeConfig->fSoutConferencingNoiseReduction != TRUE && 
5523
 
                 f_pVqeConfig->fSoutConferencingNoiseReduction != FALSE )
5524
 
                return cOCT6100_ERR_CHANNEL_SOUT_CONFERENCE_NOISE_REDUCTION;
5525
 
 
5526
 
        if ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE && pImageInfo->fConferencingNoiseReduction == FALSE )
5527
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_CNR;
5528
 
 
5529
 
        /* Validate Sout noise bleaching parameter. */
5530
 
        if ( f_pVqeConfig->fSoutNoiseBleaching != TRUE && 
5531
 
                 f_pVqeConfig->fSoutNoiseBleaching != FALSE )
5532
 
                return cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING;
5533
 
 
5534
 
        /* Check if firmware supports Sout noise bleaching. */
5535
 
        if ( f_pVqeConfig->fSoutNoiseBleaching == TRUE && pImageInfo->fSoutNoiseBleaching == FALSE )
5536
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NOISE_BLEACHING;
5537
 
 
5538
 
        /* If Sout noise bleaching is requested, no ANR or CNR shall be activated. */
5539
 
        if ( f_pVqeConfig->fSoutNoiseBleaching == TRUE )
5540
 
        {
5541
 
                /* No xNR! */
5542
 
                if ( ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE )
5543
 
                        || ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE ) )
5544
 
                        return cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING_NR;
5545
 
        }
5546
 
 
5547
 
        /* Cannot activate both ANR and CNR when noise bleaching is present */
5548
 
        if ( pImageInfo->fSoutNoiseBleaching == TRUE )
5549
 
        {
5550
 
                if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE && 
5551
 
                        f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE )
5552
 
                        return cOCT6100_ERR_CHANNEL_ANR_CNR_SIMULTANEOUSLY;
5553
 
        }
5554
 
 
5555
 
        /* Validate the DTMF tone removal parameter.*/
5556
 
        if ( f_pVqeConfig->fDtmfToneRemoval != TRUE && f_pVqeConfig->fDtmfToneRemoval != FALSE )
5557
 
                return cOCT6100_ERR_CHANNEL_TONE_REMOVAL;
5558
 
 
5559
 
        if ( f_pVqeConfig->fDtmfToneRemoval == TRUE && pImageInfo->fToneRemoval == FALSE )
5560
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_REMOVAL;
5561
 
 
5562
 
 
5563
 
 
5564
 
        /* Check the Tail displacement enable.*/
5565
 
        if ( f_pVqeConfig->fEnableTailDisplacement != TRUE && f_pVqeConfig->fEnableTailDisplacement != FALSE )
5566
 
                return cOCT6100_ERR_CHANNEL_ENABLE_TAIL_DISPLACEMENT;
5567
 
 
5568
 
        if ( f_pVqeConfig->fEnableTailDisplacement == TRUE && pImageInfo->fTailDisplacement == FALSE )
5569
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_DISPLACEMENT;
5570
 
 
5571
 
        /* Check the Tail displacement value.*/
5572
 
        if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
5573
 
        {
5574
 
                if ( f_pVqeConfig->ulTailDisplacement != cOCT6100_AUTO_SELECT_TAIL )
5575
 
                {
5576
 
                        /* Check if this feature is supported by the image. */
5577
 
                        if ( pImageInfo->fPerChannelTailDisplacement == FALSE )
5578
 
                                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_PER_CHAN_TAIL;
5579
 
 
5580
 
                        /* Check that this value is not greater then what the image supports. */
5581
 
                        if ( f_pVqeConfig->ulTailDisplacement > pImageInfo->usMaxTailDisplacement )
5582
 
                                return cOCT6100_ERR_CHANNEL_TAIL_DISPLACEMENT_INVALID;
5583
 
                }
5584
 
        }
5585
 
 
5586
 
        /* Check the tail length value. */
5587
 
        if ( f_pVqeConfig->ulTailLength != cOCT6100_AUTO_SELECT_TAIL )
5588
 
        {
5589
 
                /* Check if this feature is supported by the image. */
5590
 
                if ( ( pImageInfo->fPerChannelTailLength == FALSE )
5591
 
                        && ( (UINT16)( f_pVqeConfig->ulTailLength & 0xFFFF ) != pImageInfo->usMaxTailLength ) )
5592
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_LENGTH;
5593
 
 
5594
 
                if ( ( f_pVqeConfig->ulTailLength < 32 ) || ( f_pVqeConfig->ulTailLength > 128 ) 
5595
 
                        || ( ( f_pVqeConfig->ulTailLength % 4 ) != 0x0 ) )
5596
 
                        return cOCT6100_ERR_CHANNEL_TAIL_LENGTH;
5597
 
 
5598
 
                /* Check if the requested tail length is supported by the chip. */
5599
 
                if ( f_pVqeConfig->ulTailLength > pImageInfo->usMaxTailLength )
5600
 
                        return cOCT6100_ERR_CHANNEL_TAIL_LENGTH_INVALID;
5601
 
        }
5602
 
 
5603
 
        /* Validate the acoustic echo cancellation parameter.*/
5604
 
        if ( f_pVqeConfig->fAcousticEcho != TRUE && f_pVqeConfig->fAcousticEcho != FALSE )
5605
 
                return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO;
5606
 
 
5607
 
        if ( f_pVqeConfig->fAcousticEcho == TRUE && pImageInfo->fAcousticEcho == FALSE )
5608
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO;
5609
 
 
5610
 
        if ( f_pVqeConfig->fAcousticEcho == TRUE )
5611
 
        {
5612
 
                /* Check if acoustic echo tail length configuration is supported in the image. */
5613
 
                if ( ( f_pVqeConfig->ulAecTailLength != 128 ) && ( pImageInfo->fAecTailLength == FALSE ) )
5614
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH;
5615
 
 
5616
 
                /* Check the requested acoustic echo tail length. */
5617
 
                if ( ( f_pVqeConfig->ulAecTailLength != 128 )
5618
 
                        && ( f_pVqeConfig->ulAecTailLength != 256 ) 
5619
 
                        && ( f_pVqeConfig->ulAecTailLength != 512 )
5620
 
                        && ( f_pVqeConfig->ulAecTailLength != 1024 ) )
5621
 
                        return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_LENGTH;
5622
 
 
5623
 
                if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
5624
 
                {
5625
 
                        UINT32 ulTailSum;
5626
 
 
5627
 
                        /* Start with requested tail displacement. */
5628
 
                        if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
5629
 
                        {
5630
 
                                ulTailSum = f_pApiInstance->pSharedInfo->ChipConfig.usTailDisplacement;
5631
 
                        }
5632
 
                        else
5633
 
                        {
5634
 
                                ulTailSum = f_pVqeConfig->ulTailDisplacement;
5635
 
                        }
5636
 
 
5637
 
                        /* Add requested tail length. */
5638
 
                        if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
5639
 
                        {
5640
 
                                ulTailSum += f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength;
5641
 
                        }
5642
 
                        else
5643
 
                        {
5644
 
                                ulTailSum += f_pVqeConfig->ulTailLength;
5645
 
                        }
5646
 
 
5647
 
                        /* The tail sum must be smaller then the requested AEC tail length. */
5648
 
                        if ( ulTailSum > f_pVqeConfig->ulAecTailLength )
5649
 
                                return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO_TAIL_SUM;
5650
 
                }
5651
 
        }
5652
 
        
5653
 
        /* Validate the Default ERL parameter.*/
5654
 
        if ( f_pVqeConfig->lDefaultErlDb != -6 && pImageInfo->fDefaultErl == FALSE )
5655
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DEFAULT_ERL;
5656
 
 
5657
 
        if ( ( f_pVqeConfig->lDefaultErlDb != 0 ) && 
5658
 
                ( f_pVqeConfig->lDefaultErlDb != -3 ) && 
5659
 
                ( f_pVqeConfig->lDefaultErlDb != -6 ) &&
5660
 
                ( f_pVqeConfig->lDefaultErlDb != -9 ) &&
5661
 
                ( f_pVqeConfig->lDefaultErlDb != -12 ) )
5662
 
                return cOCT6100_ERR_CHANNEL_DEFAULT_ERL;
5663
 
 
5664
 
        /* Validate the Default AEC ERL parameter.*/
5665
 
        if ( f_pVqeConfig->lAecDefaultErlDb != 0 && pImageInfo->fAecDefaultErl == FALSE )
5666
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_AEC_DEFAULT_ERL;
5667
 
 
5668
 
        if ( f_pVqeConfig->lAecDefaultErlDb != 0 && f_pVqeConfig->lAecDefaultErlDb != -3 && f_pVqeConfig->lAecDefaultErlDb != -6 )
5669
 
                return cOCT6100_ERR_CHANNEL_AEC_DEFAULT_ERL;
5670
 
 
5671
 
        /* Validate the non-linearity A parameter.*/
5672
 
        if ( f_pVqeConfig->ulNonLinearityBehaviorA != 1 && pImageInfo->fNonLinearityBehaviorA == FALSE )
5673
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DOUBLE_TALK;
5674
 
 
5675
 
        if ( f_pVqeConfig->ulNonLinearityBehaviorA >= 14 )
5676
 
                return cOCT6100_ERR_CHANNEL_DOUBLE_TALK;
5677
 
 
5678
 
        /* Validate the non-linearity B parameter.*/
5679
 
        if ( f_pVqeConfig->ulNonLinearityBehaviorB != 0 && pImageInfo->fNonLinearityBehaviorB == FALSE )
5680
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NON_LINEARITY_B;
5681
 
 
5682
 
        if ( f_pVqeConfig->ulNonLinearityBehaviorB >= 9 )
5683
 
                return cOCT6100_ERR_CHANNEL_NON_LINEARITY_B;
5684
 
 
5685
 
        /* Check if configuring the double talk behavior is supported in the firmware. */
5686
 
        if ( f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_NORMAL && pImageInfo->fDoubleTalkBehavior == FALSE )
5687
 
                return cOCT6100_ERR_NOT_SUPPORTED_DOUBLE_TALK_BEHAVIOR_MODE;
5688
 
        
5689
 
        /* Validate the double talk behavior mode parameter. */
5690
 
        if ( f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_NORMAL && f_pVqeConfig->ulDoubleTalkBehavior != cOCT6100_DOUBLE_TALK_BEH_LESS_AGGRESSIVE )
5691
 
                return cOCT6100_ERR_CHANNEL_DOUBLE_TALK_MODE;
5692
 
 
5693
 
        /* Validate the Sout automatic listener enhancement ratio. */
5694
 
        if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 && pImageInfo->fListenerEnhancement == FALSE )
5695
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ALE;
5696
 
 
5697
 
        if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb > 30 )
5698
 
                return cOCT6100_ERR_CHANNEL_ALE_RATIO;
5699
 
 
5700
 
        /* Validate the Sout natural listener enhancement ratio. */
5701
 
        if ( f_pVqeConfig->fSoutNaturalListenerEnhancement != TRUE && f_pVqeConfig->fSoutNaturalListenerEnhancement != FALSE )
5702
 
                return cOCT6100_ERR_CHANNEL_NLE_FLAG;
5703
 
 
5704
 
        if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE && pImageInfo->fListenerEnhancement == FALSE )
5705
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLE;
5706
 
 
5707
 
        if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
5708
 
        {
5709
 
                if ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb > 30 )
5710
 
                        return cOCT6100_ERR_CHANNEL_NLE_RATIO;
5711
 
        }
5712
 
 
5713
 
        /* Both ALE and NLE cannot be activated simultaneously. */
5714
 
        if ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 )
5715
 
                && ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE ) )
5716
 
                return cOCT6100_ERR_CHANNEL_ALE_NLE_SIMULTANEOUSLY;
5717
 
        
5718
 
        /* Validate Rout noise reduction. */
5719
 
        if ( f_pVqeConfig->fRoutNoiseReduction != TRUE && f_pVqeConfig->fRoutNoiseReduction != FALSE )
5720
 
                return cOCT6100_ERR_CHANNEL_ROUT_NOISE_REDUCTION;
5721
 
 
5722
 
        /* Check if Rout noise reduction is supported. */
5723
 
        if ( f_pVqeConfig->fRoutNoiseReduction == TRUE && pImageInfo->fRoutNoiseReduction == FALSE )
5724
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ROUT_NR;
5725
 
 
5726
 
        /* Check if ANR SNRE is supported. */
5727
 
        if ( ( f_pVqeConfig->lAnrSnrEnhancementDb != -18 ) && ( pImageInfo->fAnrSnrEnhancement == FALSE ) )
5728
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SNR_ENHANCEMENT;
5729
 
 
5730
 
        /* Validate Sout ANR SNR enhancement. */
5731
 
        if ( ( f_pVqeConfig->lAnrSnrEnhancementDb != -9 )
5732
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -12 ) 
5733
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -15 )
5734
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -18 )
5735
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -21 )
5736
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -24 )
5737
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -27 )
5738
 
                && ( f_pVqeConfig->lAnrSnrEnhancementDb != -30 ) )
5739
 
                return cOCT6100_ERR_CHANNEL_ANR_SNR_ENHANCEMENT;
5740
 
        
5741
 
        /* Validate ANR voice-noise segregation. */
5742
 
        if ( f_pVqeConfig->ulAnrVoiceNoiseSegregation > 15 )
5743
 
                return cOCT6100_ERR_CHANNEL_ANR_SEGREGATION;
5744
 
 
5745
 
        /* Check if ANR VN segregation is supported. */
5746
 
        if ( ( f_pVqeConfig->ulAnrVoiceNoiseSegregation != 6 ) && ( pImageInfo->fAnrVoiceNoiseSegregation == FALSE ) )
5747
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR_SEGREGATION;
5748
 
 
5749
 
        /* Check if the loaded image supports tone disabler VQE activation delay. */
5750
 
        if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != 300 )
5751
 
                && ( pImageInfo->fToneDisablerVqeActivationDelay == FALSE ) )
5752
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY;
5753
 
 
5754
 
        /* Check if the specified tone disabler VQE activation delay is correct. */
5755
 
        if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay < 300 )
5756
 
                || ( ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay - 300 ) % 512 ) != 0 ) )
5757
 
                return cOCT6100_ERR_CHANNEL_TONE_DISABLER_ACTIVATION_DELAY;
5758
 
 
5759
 
        /* Check if the tone disabler is activated when the user requests a different activation delay. */
5760
 
        if ( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != 300 )
5761
 
                && ( f_fEnableToneDisabler == FALSE ) )
5762
 
                return cOCT6100_ERR_CHANNEL_MUST_ENABLE_TONE_DISABLER;
5763
 
 
5764
 
        /* Check the enable music protection flag. */
5765
 
        if ( ( f_pVqeConfig->fEnableMusicProtection != TRUE ) && ( f_pVqeConfig->fEnableMusicProtection != FALSE ) )
5766
 
                return cOCT6100_ERR_CHANNEL_ENABLE_MUSIC_PROTECTION;
5767
 
 
5768
 
        /* The music protection module can only be activated if the image supports it. */
5769
 
        if ( ( f_pVqeConfig->fEnableMusicProtection == TRUE ) &&
5770
 
                ( pImageInfo->fMusicProtection == FALSE ) )
5771
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_MUSIC_PROTECTION;
5772
 
 
5773
 
        /* Check the enable idle code detection flag. */
5774
 
        if ( ( f_pVqeConfig->fIdleCodeDetection != TRUE ) && ( f_pVqeConfig->fIdleCodeDetection != FALSE ) )
5775
 
                return cOCT6100_ERR_CHANNEL_IDLE_CODE_DETECTION;
5776
 
 
5777
 
        /* The idle code detection module can only be activated if the image supports it. */
5778
 
        if ( ( f_pVqeConfig->fIdleCodeDetection == TRUE ) && ( pImageInfo->fIdleCodeDetection == FALSE ) )
5779
 
                return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION;
5780
 
 
5781
 
        /* The idle code detection module can be disabled only if idle code detection configuration */
5782
 
        /* is supported in the image. */
5783
 
        if ( ( f_pVqeConfig->fIdleCodeDetection == FALSE ) && ( pImageInfo->fIdleCodeDetectionConfiguration == FALSE ) )
5784
 
                return cOCT6100_ERR_NOT_SUPPORTED_IDLE_CODE_DETECTION_CONFIG;
5785
 
 
5786
 
        return cOCT6100_ERR_OK;
5787
 
}
5788
 
 
5789
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5790
 
 
5791
 
Function:               Oct6100ApiCheckCodecConfig
5792
 
 
5793
 
Description:    This function will check the validity of the Codec config parameter
5794
 
                                of an Open Codec config structure.
5795
 
 
5796
 
-------------------------------------------------------------------------------
5797
 
|       Argument                |       Description
5798
 
-------------------------------------------------------------------------------
5799
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
5800
 
                                                the present state of the chip and all its resources.
5801
 
 
5802
 
f_pCodecConfig                  Codec config of the channel.
5803
 
f_ulDecoderNumTssts             Number of TSST for the decoder.
5804
 
f_pusPhasingTsstIndex   Pointer to the Phasing TSST index within the API's phasing TSST list.
5805
 
 
5806
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5807
 
static UINT32 Oct6100ApiCheckCodecConfig( 
5808
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
5809
 
                                IN      tPOCT6100_CHANNEL_OPEN_CODEC    f_pCodecConfig,
5810
 
                                IN  UINT32                                                      f_ulDecoderNumTssts,
5811
 
                                OUT PUINT16                                                     f_pusPhasingTsstIndex )
5812
 
{
5813
 
        
5814
 
        /* Verify the ADPCM nibble value.*/
5815
 
        if ( f_pCodecConfig->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_LOW_BITS && 
5816
 
                 f_pCodecConfig->ulAdpcmNibblePosition != cOCT6100_ADPCM_IN_HIGH_BITS )
5817
 
                return cOCT6100_ERR_CHANNEL_ADPCM_NIBBLE;
5818
 
 
5819
 
        /* Verify the Encoder port.*/
5820
 
        if ( f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_ROUT && 
5821
 
                 f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_SOUT &&
5822
 
                 f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
5823
 
                return cOCT6100_ERR_CHANNEL_ENCODER_PORT;
5824
 
        
5825
 
        /* Verify the Decoder port.*/
5826
 
        if ( f_pCodecConfig->ulDecoderPort != cOCT6100_CHANNEL_PORT_RIN && 
5827
 
                 f_pCodecConfig->ulDecoderPort != cOCT6100_CHANNEL_PORT_SIN &&
5828
 
                 f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
5829
 
                return cOCT6100_ERR_CHANNEL_DECODER_PORT;
5830
 
 
5831
 
        /* The codec cannot be on the same stream.*/
5832
 
        if ( f_pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT && 
5833
 
                 f_pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
5834
 
                return cOCT6100_ERR_CHANNEL_INVALID_CODEC_POSITION;
5835
 
 
5836
 
        if ( f_pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT && 
5837
 
                 f_pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN )
5838
 
                return cOCT6100_ERR_CHANNEL_INVALID_CODEC_POSITION;
5839
 
 
5840
 
        /* Verify if the requested functions are supported by the chip.*/
5841
 
        if ( f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm == FALSE &&
5842
 
                 f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
5843
 
        {
5844
 
                if ( f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS )
5845
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ENCODING;
5846
 
        }
5847
 
 
5848
 
        if ( f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm == FALSE &&
5849
 
                 f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
5850
 
        {
5851
 
                if ( f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS )
5852
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DECODING;
5853
 
        }
5854
 
        
5855
 
        /* Check if encoder port has been specified when a rate has been set. */
5856
 
        if ( f_pCodecConfig->ulEncoderPort == cOCT6100_NO_ENCODING && 
5857
 
                f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS )
5858
 
                return cOCT6100_ERR_CHANNEL_ENCODER_PORT;
5859
 
 
5860
 
        /* Check if decoder port has been specified when a rate has been set. */
5861
 
        if ( f_pCodecConfig->ulDecoderPort == cOCT6100_NO_DECODING && 
5862
 
                f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS )
5863
 
                return cOCT6100_ERR_CHANNEL_DECODER_PORT;
5864
 
 
5865
 
        /* Check Encoder related parameter if one is used.*/
5866
 
        if ( f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
5867
 
        {
5868
 
                /* Check the Encoder compression rate.*/
5869
 
                if ( ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G711_64KBPS ) && 
5870
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G726_40KBPS ) &&
5871
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G726_32KBPS ) &&
5872
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G726_24KBPS ) &&
5873
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G726_16KBPS ) &&
5874
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_40KBPS_4_1 ) &&
5875
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_40KBPS_3_2 ) &&
5876
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_40KBPS_2_3 ) &&
5877
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_32KBPS_4_0 ) &&
5878
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_32KBPS_3_1 ) &&
5879
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_32KBPS_2_2 ) &&
5880
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_24KBPS_3_0 ) &&
5881
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_24KBPS_2_1 ) &&
5882
 
                         ( f_pCodecConfig->ulEncodingRate  != cOCT6100_G727_16KBPS_2_0 ) )
5883
 
                        return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
5884
 
 
5885
 
                /* Verify phasing information.*/
5886
 
                if ( f_pCodecConfig->ulPhasingType != cOCT6100_SINGLE_PHASING && 
5887
 
                         f_pCodecConfig->ulPhasingType != cOCT6100_DUAL_PHASING &&
5888
 
                         f_pCodecConfig->ulPhasingType != cOCT6100_NO_PHASING )
5889
 
                        return cOCT6100_ERR_CHANNEL_PHASING_TYPE;
5890
 
 
5891
 
                /* Verify the silence suppression parameters.*/
5892
 
                if ( f_pCodecConfig->fEnableSilenceSuppression != TRUE && 
5893
 
                         f_pCodecConfig->fEnableSilenceSuppression != FALSE )
5894
 
                        return cOCT6100_ERR_CHANNEL_SIL_SUP_ENABLE;
5895
 
 
5896
 
                if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
5897
 
                         f_pApiInstance->pSharedInfo->ImageInfo.fSilenceSuppression == FALSE )
5898
 
                        return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIL_SUP;
5899
 
 
5900
 
                if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
5901
 
                         f_pCodecConfig->ulPhasingType == cOCT6100_NO_PHASING )
5902
 
                        return cOCT6100_ERR_CHANNEL_PHASE_TYPE_REQUIRED;
5903
 
 
5904
 
                if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
5905
 
                         f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE )
5906
 
                        return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED;
5907
 
 
5908
 
                if ( f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE &&
5909
 
                         f_pCodecConfig->ulPhasingType != cOCT6100_NO_PHASING )
5910
 
                        return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED;
5911
 
 
5912
 
                /* Silence suppression can only be performed if the encoder is using the SOUT port.*/
5913
 
                if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
5914
 
                         f_pCodecConfig->ulEncoderPort != cOCT6100_CHANNEL_PORT_SOUT )
5915
 
                        return cOCT6100_ERR_CHANNEL_SIL_SUP_INVALID_ENCODER_PORT;
5916
 
 
5917
 
                /* Check phasing TSST info if phasing is required.*/
5918
 
                if ( f_pCodecConfig->ulPhasingTsstHndl != cOCT6100_INVALID_HANDLE )
5919
 
                {
5920
 
                        tPOCT6100_API_PHASING_TSST      pPhasingEntry;
5921
 
                        UINT32                                          ulEntryOpenCnt;
5922
 
 
5923
 
                        /* Check the provided handle. */
5924
 
                        if ( (f_pCodecConfig->ulPhasingTsstHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_PHASING_TSST )
5925
 
                                return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
5926
 
 
5927
 
                        *f_pusPhasingTsstIndex = (UINT16)( f_pCodecConfig->ulPhasingTsstHndl & cOCT6100_HNDL_INDEX_MASK );
5928
 
                        if ( *f_pusPhasingTsstIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxPhasingTssts )
5929
 
                                return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
5930
 
 
5931
 
                        mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, *f_pusPhasingTsstIndex );
5932
 
 
5933
 
                        /* Extract the entry open count from the provided handle. */
5934
 
                        ulEntryOpenCnt = (f_pCodecConfig->ulPhasingTsstHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
5935
 
                        
5936
 
                        /* Verify if the state of the phasing TSST.*/
5937
 
                        if ( pPhasingEntry->fReserved != TRUE )
5938
 
                                return cOCT6100_ERR_CHANNEL_PHASING_TSST_NOT_OPEN;
5939
 
                        if ( ulEntryOpenCnt != pPhasingEntry->byEntryOpenCnt )
5940
 
                                return cOCT6100_ERR_CHANNEL_INVALID_PHASING_HANDLE;
5941
 
                        
5942
 
                        /* Check the specified phase value against the phasing length of the phasing TSST.*/
5943
 
                        if ( f_pCodecConfig->ulPhase >= pPhasingEntry->usPhasingLength )
5944
 
                                return cOCT6100_ERR_CHANNEL_PHASING_INVALID_PHASE;
5945
 
                }
5946
 
                else
5947
 
                {
5948
 
                        *f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX;
5949
 
                }
5950
 
        }
5951
 
        else
5952
 
        {
5953
 
                *f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX;
5954
 
        }
5955
 
 
5956
 
 
5957
 
        /* Check Decoder related parameter if one is used.*/
5958
 
        if ( f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
5959
 
        {
5960
 
                /* Check the Decoding rate.*/
5961
 
                if ( f_pCodecConfig->ulDecodingRate  != cOCT6100_G711_64KBPS &&
5962
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G726_40KBPS &&
5963
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G726_32KBPS &&
5964
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G726_24KBPS &&
5965
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G726_16KBPS &&
5966
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G726_ENCODED &&
5967
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G711_G726_ENCODED &&
5968
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G727_2C_ENCODED &&
5969
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G727_3C_ENCODED &&
5970
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G727_4C_ENCODED &&
5971
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G711_G727_2C_ENCODED &&
5972
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G711_G727_3C_ENCODED &&
5973
 
                         f_pCodecConfig->ulDecodingRate  != cOCT6100_G711_G727_4C_ENCODED )
5974
 
                        return cOCT6100_ERR_CHANNEL_DECODING_RATE;
5975
 
 
5976
 
                /* Make sure that two timeslot are allocated if PCM-ECHO encoded is selected.*/
5977
 
                if ( (f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G726_ENCODED ||
5978
 
                          f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_2C_ENCODED ||
5979
 
                          f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_3C_ENCODED ||
5980
 
                          f_pCodecConfig->ulDecodingRate == cOCT6100_G711_G727_4C_ENCODED ) &&
5981
 
                          f_ulDecoderNumTssts != 2 )
5982
 
                        return cOCT6100_ERR_CHANNEL_MISSING_TSST;
5983
 
        }
5984
 
 
5985
 
        return cOCT6100_ERR_OK;
5986
 
}
5987
 
 
5988
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5989
 
 
5990
 
Function:               Oct6100ApiWriteInputTsstControlMemory
5991
 
 
5992
 
Description:    This function configure a TSST control memory entry in internal memory.
5993
 
 
5994
 
-------------------------------------------------------------------------------
5995
 
|       Argument                |       Description
5996
 
-------------------------------------------------------------------------------
5997
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
5998
 
                                                the present state of the chip and all its resources.
5999
 
 
6000
 
f_usTsstIndex                   TSST index within the TSST control memory.
6001
 
f_usTsiMemIndex                 TSI index within the TSI chariot memory.
6002
 
f_ulTsstInputLaw                PCM law of the input TSST.
6003
 
 
6004
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6005
 
static UINT32 Oct6100ApiWriteInputTsstControlMemory( 
6006
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
6007
 
                                IN      UINT16                                                  f_usTsstIndex,
6008
 
                                IN      UINT16                                                  f_usTsiMemIndex,
6009
 
                                IN      UINT32                                                  f_ulTsstInputLaw )
6010
 
{
6011
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
6012
 
        UINT32                                                  ulResult;
6013
 
 
6014
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6015
 
 
6016
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6017
 
 
6018
 
        WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6019
 
        
6020
 
        WriteParams.usWriteData  = cOCT6100_TSST_CONTROL_MEM_INPUT_TSST;
6021
 
        WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
6022
 
 
6023
 
        /* Set the PCM law.*/
6024
 
        WriteParams.usWriteData |= f_ulTsstInputLaw << cOCT6100_TSST_CONTROL_MEM_PCM_LAW_OFFSET;
6025
 
 
6026
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6027
 
        if ( ulResult != cOCT6100_ERR_OK  )
6028
 
                return ulResult;
6029
 
 
6030
 
        return cOCT6100_ERR_OK;
6031
 
}
6032
 
 
6033
 
 
6034
 
 
6035
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6036
 
 
6037
 
Function:               Oct6100ApiWriteOutputTsstControlMemory
6038
 
 
6039
 
Description:    This function configure a TSST control memory entry in internal memory.
6040
 
 
6041
 
-------------------------------------------------------------------------------
6042
 
|       Argument                |       Description
6043
 
-------------------------------------------------------------------------------
6044
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
6045
 
                                                the present state of the chip and all its resources.
6046
 
 
6047
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6048
 
static UINT32 Oct6100ApiWriteOutputTsstControlMemory( 
6049
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
6050
 
                                IN      UINT16                                                  f_usTsstIndex,
6051
 
                                IN      UINT32                                                  f_ulAdpcmNibblePosition,
6052
 
                                IN      UINT32                                                  f_ulNumTssts,
6053
 
                                IN      UINT16                                                  f_usTsiMemIndex )
6054
 
{
6055
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
6056
 
        UINT32                                                  ulResult;
6057
 
 
6058
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6059
 
 
6060
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6061
 
 
6062
 
        WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6063
 
        
6064
 
        WriteParams.usWriteData  = cOCT6100_TSST_CONTROL_MEM_OUTPUT_TSST;
6065
 
        WriteParams.usWriteData |= f_ulAdpcmNibblePosition << cOCT6100_TSST_CONTROL_MEM_NIBBLE_POS_OFFSET;
6066
 
        WriteParams.usWriteData |= (f_ulNumTssts - 1) << cOCT6100_TSST_CONTROL_MEM_TSST_NUM_OFFSET;
6067
 
        WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
6068
 
 
6069
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6070
 
        if ( ulResult != cOCT6100_ERR_OK  )
6071
 
                return ulResult;
6072
 
 
6073
 
        return cOCT6100_ERR_OK;
6074
 
}
6075
 
 
6076
 
 
6077
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6078
 
 
6079
 
Function:               Oct6100ApiWriteEncoderMemory
6080
 
 
6081
 
Description:    This function configure a Encoded memory entry in internal memory.
6082
 
 
6083
 
-------------------------------------------------------------------------------
6084
 
|       Argument                |       Description
6085
 
-------------------------------------------------------------------------------
6086
 
f_pApiInstance                                  Pointer to API instance. This memory is used to keep
6087
 
                                                                the present state of the chip and all its resources.
6088
 
 
6089
 
f_ulEncoderIndex                                Index of the encoder block within the ADPCM context memory.
6090
 
f_ulCompType                                    Compression rate of the encoder.
6091
 
f_usTsiMemIndex                                 TSI index within the TSI chariot memory used by the encoder.
6092
 
f_ulEnableSilenceSuppression    Silence suppression enable flag.
6093
 
f_ulAdpcmNibblePosition                 ADPCM nibble position.
6094
 
f_usPhasingTsstIndex                    Phasing TSST index within the API's Phassing TSST list.
6095
 
f_ulPhasingType                                 Type of the Phasing TSST.
6096
 
f_ulPhase                                               Phase used with this encoder.
6097
 
 
6098
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6099
 
static UINT32 Oct6100ApiWriteEncoderMemory( 
6100
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
6101
 
                                IN      UINT32                                                  f_ulEncoderIndex,
6102
 
                                IN      UINT32                                                  f_ulCompType,
6103
 
                                IN      UINT16                                                  f_usTsiMemIndex,
6104
 
                                IN      UINT32                                                  f_ulEnableSilenceSuppression,
6105
 
                                IN      UINT32                                                  f_ulAdpcmNibblePosition,
6106
 
                                IN  UINT16                                                      f_usPhasingTsstIndex,
6107
 
                                IN      UINT32                                                  f_ulPhasingType,
6108
 
                                IN      UINT32                                                  f_ulPhase )
6109
 
{
6110
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
6111
 
        UINT32                                                  ulResult;
6112
 
 
6113
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6114
 
 
6115
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6116
 
 
6117
 
        /*==============================================================================*/
6118
 
        /* Conversion Control Base */
6119
 
        WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_ulEncoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
6120
 
        
6121
 
        WriteParams.usWriteData  = cOCT6100_CONVERSION_CONTROL_MEM_ENCODER;
6122
 
        WriteParams.usWriteData |= f_ulCompType << cOCT6100_CONVERSION_CONTROL_MEM_COMP_OFFSET;
6123
 
        WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
6124
 
 
6125
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6126
 
        if ( ulResult != cOCT6100_ERR_OK  )
6127
 
                return ulResult;
6128
 
        
6129
 
        /*==============================================================================*/
6130
 
        /* Conversion Control Base + 2 */
6131
 
        WriteParams.ulWriteAddress += 2;
6132
 
 
6133
 
        /* Set the phasing TSST number.*/
6134
 
        if ( f_usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
6135
 
                WriteParams.usWriteData = (UINT16)( f_usPhasingTsstIndex << cOCT6100_CONVERSION_CONTROL_MEM_PHASE_OFFSET );
6136
 
        else
6137
 
                WriteParams.usWriteData = 0;
6138
 
        
6139
 
        /* Set the phasing type and the phase value if required.*/
6140
 
        switch( f_ulPhasingType )
6141
 
        {
6142
 
        case cOCT6100_NO_PHASING:
6143
 
                WriteParams.usWriteData |= 0x1 << 10;
6144
 
                break;
6145
 
        case cOCT6100_SINGLE_PHASING:
6146
 
                WriteParams.usWriteData |= f_ulPhase;
6147
 
                break;
6148
 
        case cOCT6100_DUAL_PHASING:
6149
 
                WriteParams.usWriteData |= 0x1 << 11;
6150
 
                WriteParams.usWriteData |= f_ulPhase;
6151
 
                break;
6152
 
        default:
6153
 
                /* No problem. */
6154
 
                break;
6155
 
        }
6156
 
 
6157
 
        /* Set the silence suppression flag.*/
6158
 
        WriteParams.usWriteData |= f_ulEnableSilenceSuppression << cOCT6100_CONVERSION_CONTROL_MEM_SIL_SUP_OFFSET;
6159
 
 
6160
 
        /* Set the nibble position.*/
6161
 
        WriteParams.usWriteData |= f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET;
6162
 
        
6163
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6164
 
        if ( ulResult != cOCT6100_ERR_OK  )
6165
 
                return ulResult;
6166
 
 
6167
 
        /*==============================================================================*/
6168
 
        /* Conversion Control Base + 4 */
6169
 
        WriteParams.ulWriteAddress += 2;
6170
 
                
6171
 
        /* Set the reset mode */
6172
 
        WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR;
6173
 
 
6174
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6175
 
        if ( ulResult != cOCT6100_ERR_OK  )
6176
 
                return ulResult;
6177
 
 
6178
 
        /*==============================================================================*/
6179
 
        /* Conversion Control Base + 6 */
6180
 
        WriteParams.ulWriteAddress += 2;
6181
 
                
6182
 
        /* Set the reset mode */
6183
 
        WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY;
6184
 
 
6185
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6186
 
        if ( ulResult != cOCT6100_ERR_OK  )
6187
 
                return ulResult;
6188
 
 
6189
 
        /*==============================================================================*/
6190
 
        return cOCT6100_ERR_OK;
6191
 
}
6192
 
 
6193
 
 
6194
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6195
 
 
6196
 
Function:               Oct6100ApiWriteDecoderMemory
6197
 
 
6198
 
Description:    This function configure a Decoder memory entry in internal memory.
6199
 
 
6200
 
-------------------------------------------------------------------------------
6201
 
|       Argument                |       Description
6202
 
-------------------------------------------------------------------------------
6203
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
6204
 
                                                the present state of the chip and all its resources.
6205
 
 
6206
 
f_usDecoderIndex                Index of the decoder block within the ADPCM context memory.
6207
 
f_ulCompType                    Decompression rate of the decoder.
6208
 
f_usTsiMemIndex                 TSI index within the TSI chariot memory.
6209
 
f_ulPcmLaw                              PCM law of the decoded samples.
6210
 
f_ulAdpcmNibblePosition ADPCM nibble position.
6211
 
 
6212
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6213
 
static UINT32 Oct6100ApiWriteDecoderMemory( 
6214
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
6215
 
                                IN      UINT16                                                  f_usDecoderIndex,
6216
 
                                IN      UINT32                                                  f_ulCompType,
6217
 
                                IN      UINT16                                                  f_usTsiMemIndex,
6218
 
                                IN      UINT32                                                  f_ulPcmLaw,
6219
 
                                IN      UINT32                                                  f_ulAdpcmNibblePosition )
6220
 
{
6221
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
6222
 
        UINT32                                                  ulResult;
6223
 
 
6224
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6225
 
 
6226
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6227
 
 
6228
 
 
6229
 
        /*==============================================================================*/
6230
 
        /* Conversion Control Base */
6231
 
        WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_usDecoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
6232
 
        
6233
 
        WriteParams.usWriteData  = cOCT6100_CONVERSION_CONTROL_MEM_DECODER;
6234
 
        WriteParams.usWriteData |= f_ulCompType << cOCT6100_CONVERSION_CONTROL_MEM_COMP_OFFSET;
6235
 
        WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
6236
 
 
6237
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6238
 
        if ( ulResult != cOCT6100_ERR_OK  )
6239
 
                return ulResult;
6240
 
        
6241
 
        /*==============================================================================*/
6242
 
        /* Conversion Control Base + 2 */
6243
 
        WriteParams.ulWriteAddress += 2;
6244
 
 
6245
 
        /* Set the nibble position.*/
6246
 
        WriteParams.usWriteData = (UINT16)( f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET );
6247
 
 
6248
 
        /* Set the law.*/
6249
 
        WriteParams.usWriteData |= f_ulPcmLaw << cOCT6100_CONVERSION_CONTROL_MEM_LAW_OFFSET;
6250
 
        
6251
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6252
 
        if ( ulResult != cOCT6100_ERR_OK  )
6253
 
                return ulResult;
6254
 
 
6255
 
        /*==============================================================================*/
6256
 
        /* Conversion Control Base + 4 */
6257
 
        WriteParams.ulWriteAddress += 2;
6258
 
                
6259
 
        /* Set the reset mode */
6260
 
        WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR;
6261
 
 
6262
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6263
 
        if ( ulResult != cOCT6100_ERR_OK  )
6264
 
                return ulResult;
6265
 
 
6266
 
        /*==============================================================================*/
6267
 
        /* Conversion Control Base + 6 */
6268
 
        WriteParams.ulWriteAddress += 2;
6269
 
                
6270
 
        /* Set the reset mode */
6271
 
        WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY;
6272
 
 
6273
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6274
 
        if ( ulResult != cOCT6100_ERR_OK  )
6275
 
                return ulResult;
6276
 
 
6277
 
        return cOCT6100_ERR_OK;
6278
 
}
6279
 
 
6280
 
 
6281
 
 
6282
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6283
 
 
6284
 
Function:               Oct6100ApiClearConversionMemory
6285
 
 
6286
 
Description:    This function clears a conversion memory entry in internal 
6287
 
                                memory.
6288
 
 
6289
 
-------------------------------------------------------------------------------
6290
 
|       Argument                |       Description
6291
 
-------------------------------------------------------------------------------
6292
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep 
6293
 
                                                the present state of the chip and all its resources.
6294
 
 
6295
 
f_usConversionMemIndex  Index of the block within the conversion memory.
6296
 
 
6297
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6298
 
static UINT32 Oct6100ApiClearConversionMemory( 
6299
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
6300
 
                                IN      UINT16                                                  f_usConversionMemIndex )
6301
 
{
6302
 
        tOCT6100_WRITE_PARAMS           WriteParams;
6303
 
        tOCT6100_READ_PARAMS            ReadParams;
6304
 
        UINT32                                          ulResult;
6305
 
        UINT32                                          ulBaseAddress;
6306
 
        UINT16                                          usReadData;
6307
 
 
6308
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6309
 
 
6310
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6311
 
        WriteParams.usWriteData = 0;
6312
 
 
6313
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
6314
 
 
6315
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6316
 
        ReadParams.pusReadData = &usReadData;
6317
 
 
6318
 
        /*==============================================================================*/
6319
 
        /* Clear the entry */
6320
 
        ulBaseAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_usConversionMemIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
6321
 
        /* The "activate" bit at offset +6 must be cleared first. */
6322
 
        WriteParams.ulWriteAddress = ulBaseAddress + 6;
6323
 
 
6324
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6325
 
        if ( ulResult != cOCT6100_ERR_OK  )
6326
 
                return ulResult;
6327
 
        
6328
 
        /* Read at 0x200 to make sure there is no corruption on channel 0. */
6329
 
        ReadParams.ulReadAddress = 0x200;
6330
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
6331
 
        if ( ulResult != cOCT6100_ERR_OK  )
6332
 
                return ulResult;        
6333
 
 
6334
 
        /* Then clear the rest of the structure. */
6335
 
        WriteParams.ulWriteAddress = ulBaseAddress + 4;
6336
 
 
6337
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6338
 
        if ( ulResult != cOCT6100_ERR_OK  )
6339
 
                return ulResult;
6340
 
 
6341
 
        WriteParams.ulWriteAddress = ulBaseAddress + 2;
6342
 
 
6343
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6344
 
        if ( ulResult != cOCT6100_ERR_OK  )
6345
 
                return ulResult;
6346
 
 
6347
 
        WriteParams.ulWriteAddress = ulBaseAddress;
6348
 
 
6349
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6350
 
        if ( ulResult != cOCT6100_ERR_OK  )
6351
 
                return ulResult;
6352
 
        
6353
 
        /*==============================================================================*/
6354
 
        
6355
 
        return cOCT6100_ERR_OK;
6356
 
}
6357
 
 
6358
 
 
6359
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6360
 
 
6361
 
Function:               Oct6100ApiWriteVqeMemory
6362
 
 
6363
 
Description:    This function configure an echo memory entry in internal memory and
6364
 
                                external memory.
6365
 
 
6366
 
-------------------------------------------------------------------------------
6367
 
|       Argument                |       Description
6368
 
-------------------------------------------------------------------------------
6369
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
6370
 
                                                        the present state of the chip and all its resources.
6371
 
 
6372
 
f_pVqeConfig                            Pointer to a VQE config structure.
6373
 
f_pChannelOpen                          Pointer to a channel configuration structure.
6374
 
f_usChanIndex                           Index of the echo channel in the API instance.
6375
 
f_usEchoMemIndex                        Index of the echo channel within the SSPX memory.
6376
 
f_fClearPlayoutPointers         Flag indicating if the playout pointer should be cleared.
6377
 
f_fModifyOnly                           Flag indicating if the configuration should be
6378
 
                                                        modified only.
6379
 
 
6380
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6381
 
static UINT32 Oct6100ApiWriteVqeMemory( 
6382
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
6383
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE              f_pVqeConfig,
6384
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen,
6385
 
                                IN      UINT16                                                  f_usChanIndex,
6386
 
                                IN      UINT16                                                  f_usEchoMemIndex,
6387
 
                                IN      BOOL                                                    f_fClearPlayoutPointers,
6388
 
                                IN      BOOL                                                    f_fModifyOnly )
6389
 
{
6390
 
        UINT32  ulResult;
6391
 
 
6392
 
        /* Write the NLP software configuration structure. */
6393
 
        ulResult = Oct6100ApiWriteVqeNlpMemory(
6394
 
                                                        f_pApiInstance,
6395
 
                                                        f_pVqeConfig,
6396
 
                                                        f_pChannelOpen,
6397
 
                                                        f_usChanIndex,
6398
 
                                                        f_usEchoMemIndex,
6399
 
                                                        f_fClearPlayoutPointers,
6400
 
                                                        f_fModifyOnly );
6401
 
        if ( ulResult != cOCT6100_ERR_OK )
6402
 
                return ulResult;
6403
 
 
6404
 
        /* Write the AF software configuration structure. */
6405
 
        ulResult = Oct6100ApiWriteVqeAfMemory(
6406
 
                                                        f_pApiInstance,
6407
 
                                                        f_pVqeConfig,
6408
 
                                                        f_pChannelOpen,
6409
 
                                                        f_usChanIndex,
6410
 
                                                        f_usEchoMemIndex,
6411
 
                                                        f_fClearPlayoutPointers,
6412
 
                                                        f_fModifyOnly );
6413
 
        if ( ulResult != cOCT6100_ERR_OK )
6414
 
                return ulResult;
6415
 
 
6416
 
        return cOCT6100_ERR_OK;
6417
 
}
6418
 
 
6419
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6420
 
 
6421
 
Function:               Oct6100ApiWriteVqeNlpMemory
6422
 
 
6423
 
Description:    This function configures the NLP related VQE features of an 
6424
 
                                echo channel.
6425
 
 
6426
 
-------------------------------------------------------------------------------
6427
 
|       Argument                |       Description
6428
 
-------------------------------------------------------------------------------
6429
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
6430
 
                                                        the present state of the chip and all its resources.
6431
 
 
6432
 
f_pVqeConfig                            Pointer to a VQE config structure.
6433
 
f_pChannelOpen                          Pointer to a channel configuration structure.
6434
 
f_usChanIndex                           Index of the echo channel in the API instance.
6435
 
f_usEchoMemIndex                        Index of the echo channel within the SSPX memory.
6436
 
f_fClearPlayoutPointers         Flag indicating if the playout pointer should be cleared.
6437
 
f_fModifyOnly                           Flag indicating if the configuration should be
6438
 
                                                        modified only.
6439
 
 
6440
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6441
 
static UINT32 Oct6100ApiWriteVqeNlpMemory( 
6442
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
6443
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE              f_pVqeConfig,
6444
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen,
6445
 
                                IN      UINT16                                                  f_usChanIndex,
6446
 
                                IN      UINT16                                                  f_usEchoMemIndex,
6447
 
                                IN      BOOL                                                    f_fClearPlayoutPointers,
6448
 
                                IN      BOOL                                                    f_fModifyOnly )
6449
 
{
6450
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
6451
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
6452
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
6453
 
        tOCT6100_BUFFER_PLAYOUT_STOP    BufferPlayoutStop;
6454
 
        UINT32                                                  ulResult;
6455
 
        UINT32                                                  ulTempData;
6456
 
        UINT32                                                  ulNlpConfigBaseAddress;
6457
 
        UINT32                                                  ulFeatureBytesOffset;
6458
 
        UINT32                                                  ulFeatureBitOffset;
6459
 
        UINT32                                                  ulFeatureFieldLength;
6460
 
        UINT32                                                  ulMask;
6461
 
        UINT16                                                  usTempData;
6462
 
        BOOL                                                    fEchoOperationModeChanged;
6463
 
        
6464
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
6465
 
 
6466
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6467
 
 
6468
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6469
 
 
6470
 
        /* Obtain a pointer to the new buffer's list entry. */
6471
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
6472
 
 
6473
 
        /*==============================================================================*/
6474
 
        /*      Configure the CPU NLP configuration of the channel feature by feature.*/
6475
 
 
6476
 
        ulNlpConfigBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
6477
 
        
6478
 
        /* Set initial value to zero.*/
6479
 
        ulTempData = 0;
6480
 
 
6481
 
        /* Configure Adaptive Noise Reduction.*/
6482
 
        if ( pSharedInfo->ImageInfo.fAdaptiveNoiseReduction == TRUE )
6483
 
        {
6484
 
                /* Check if the configuration has been changed. */
6485
 
                if ( ( f_fModifyOnly == FALSE ) 
6486
 
                        || ( ( f_fModifyOnly == TRUE ) 
6487
 
                                && ( ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction ) 
6488
 
                                        || ( f_pVqeConfig->fSoutNoiseBleaching != pChanEntry->VqeConfig.fSoutNoiseBleaching )
6489
 
                                        ) ) )
6490
 
                {
6491
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.usDwordOffset * 4;
6492
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byBitOffset;
6493
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byFieldSize;
6494
 
 
6495
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6496
 
                                                                                                pChanEntry,
6497
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6498
 
                                                                                                &ulTempData, 
6499
 
                                                                                                ulResult );
6500
 
                        if ( ulResult != cOCT6100_ERR_OK )
6501
 
                                return ulResult;
6502
 
                        
6503
 
                        /* Clear previous value set in the feature field.*/
6504
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6505
 
 
6506
 
                        ulTempData &= (~ulMask);
6507
 
 
6508
 
                        /* Set adaptive noise reduction on the SOUT port.*/
6509
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutAdaptiveNoiseReduction ) << ulFeatureBitOffset );
6510
 
 
6511
 
                        /* If SOUT noise bleaching is requested, ANR must be activated. */
6512
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutNoiseBleaching ) << ulFeatureBitOffset );
6513
 
 
6514
 
                        /* First read the DWORD where the field is located. */
6515
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
6516
 
                                                                                        pChanEntry,
6517
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6518
 
                                                                                        ulTempData,
6519
 
                                                                                        ulResult );
6520
 
                        if ( ulResult != cOCT6100_ERR_OK )
6521
 
                                return ulResult;        
6522
 
                }
6523
 
        }
6524
 
 
6525
 
        /* Configure Rout Noise Reduction. */
6526
 
        if ( pSharedInfo->ImageInfo.fRoutNoiseReduction == TRUE )
6527
 
        {
6528
 
                /* Check if the configuration has been changed. */
6529
 
                if ( ( f_fModifyOnly == FALSE )
6530
 
                        || ( ( f_fModifyOnly == TRUE ) 
6531
 
                                && ( f_pVqeConfig->fRoutNoiseReduction != pChanEntry->VqeConfig.fRoutNoiseReduction ) ) )
6532
 
                {
6533
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAnrOfst.usDwordOffset * 4;
6534
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.RinAnrOfst.byBitOffset;
6535
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAnrOfst.byFieldSize;
6536
 
 
6537
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6538
 
                                                                                                pChanEntry,
6539
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6540
 
                                                                                                &ulTempData,
6541
 
                                                                                                ulResult );
6542
 
                        if ( ulResult != cOCT6100_ERR_OK )
6543
 
                                return ulResult;
6544
 
                        
6545
 
                        /* Clear previous value set in the feature field.*/
6546
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6547
 
 
6548
 
                        ulTempData &= (~ulMask);
6549
 
 
6550
 
                        /* Set noise reduction on the Rout port. */
6551
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fRoutNoiseReduction ) << ulFeatureBitOffset );
6552
 
 
6553
 
                        /* Write the new DWORD where the field is located. */
6554
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
6555
 
                                                                                        pChanEntry,
6556
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6557
 
                                                                                        ulTempData,
6558
 
                                                                                        ulResult );
6559
 
                        if ( ulResult != cOCT6100_ERR_OK )
6560
 
                                return ulResult;        
6561
 
                }
6562
 
        }
6563
 
 
6564
 
        /* Configure Sout ANR SNR enhancement. */
6565
 
        if ( pSharedInfo->ImageInfo.fAnrSnrEnhancement == TRUE )
6566
 
        {
6567
 
                /* Check if the configuration has been changed. */
6568
 
                if ( ( f_fModifyOnly == FALSE )
6569
 
                        || ( ( f_fModifyOnly == TRUE ) 
6570
 
                                && ( f_pVqeConfig->lAnrSnrEnhancementDb != pChanEntry->VqeConfig.chAnrSnrEnhancementDb ) ) )
6571
 
                {
6572
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.usDwordOffset * 4;
6573
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byBitOffset;
6574
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byFieldSize;
6575
 
 
6576
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6577
 
                                                                                                pChanEntry,
6578
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6579
 
                                                                                                &ulTempData,
6580
 
                                                                                                ulResult );
6581
 
                        if ( ulResult != cOCT6100_ERR_OK )
6582
 
                                return ulResult;
6583
 
                        
6584
 
                        /* Clear previous value set in the feature field.*/
6585
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6586
 
 
6587
 
                        ulTempData &= (~ulMask);
6588
 
 
6589
 
                        /* Set ANR SNR enhancement on the Sout port. */
6590
 
                        switch( f_pVqeConfig->lAnrSnrEnhancementDb )
6591
 
                        {
6592
 
                        case -9:        ulTempData |= ( 7 << ulFeatureBitOffset );
6593
 
                                break;
6594
 
                        case -12:       ulTempData |= ( 6 << ulFeatureBitOffset );
6595
 
                                break;
6596
 
                        case -15:       ulTempData |= ( 5 << ulFeatureBitOffset );
6597
 
                                break;
6598
 
                        case -21:       ulTempData |= ( 3 << ulFeatureBitOffset );
6599
 
                                break;
6600
 
                        case -24:       ulTempData |= ( 2 << ulFeatureBitOffset );
6601
 
                                break;
6602
 
                        case -27:       ulTempData |= ( 1 << ulFeatureBitOffset );
6603
 
                                break;
6604
 
                        case -30:       ulTempData |= ( 0 << ulFeatureBitOffset );
6605
 
                                break;
6606
 
                        default:        ulTempData |= ( 4 << ulFeatureBitOffset );
6607
 
                                /* -18 */
6608
 
                                break;
6609
 
                        }
6610
 
 
6611
 
                        /* Write the new DWORD where the field is located. */
6612
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
6613
 
                                                                                        pChanEntry,
6614
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6615
 
                                                                                        ulTempData,
6616
 
                                                                                        ulResult );
6617
 
                        if ( ulResult != cOCT6100_ERR_OK )
6618
 
                                return ulResult;        
6619
 
                }
6620
 
        }
6621
 
 
6622
 
        /* Configure Sout ANR voice-noise segregation. */
6623
 
        if ( pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation == TRUE )
6624
 
        {
6625
 
                /* Check if the configuration has been changed. */
6626
 
                if ( ( f_fModifyOnly == FALSE )
6627
 
                        || ( ( f_fModifyOnly == TRUE ) 
6628
 
                                && ( f_pVqeConfig->ulAnrVoiceNoiseSegregation != pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation ) ) )
6629
 
                {
6630
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.usDwordOffset * 4;
6631
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byBitOffset;
6632
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byFieldSize;
6633
 
 
6634
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6635
 
                                                                                                pChanEntry,
6636
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6637
 
                                                                                                &ulTempData,
6638
 
                                                                                                ulResult );
6639
 
                        if ( ulResult != cOCT6100_ERR_OK )
6640
 
                                return ulResult;
6641
 
                        
6642
 
                        /* Clear previous value set in the feature field.*/
6643
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6644
 
 
6645
 
                        ulTempData &= (~ulMask);
6646
 
 
6647
 
                        /* Set ANR voice-noise segregation on the Sout port. */
6648
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->ulAnrVoiceNoiseSegregation ) << ulFeatureBitOffset );
6649
 
 
6650
 
                        /* Write the new DWORD where the field is located. */
6651
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
6652
 
                                                                                        pChanEntry,
6653
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6654
 
                                                                                        ulTempData,
6655
 
                                                                                        ulResult );
6656
 
                        if ( ulResult != cOCT6100_ERR_OK )
6657
 
                                return ulResult;        
6658
 
                }
6659
 
        }
6660
 
 
6661
 
        /* Configure the tone disabler VQE activation delay. */
6662
 
        if ( pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay == TRUE )
6663
 
        {
6664
 
                /* Check if the configuration has been changed. */
6665
 
                if ( ( f_fModifyOnly == FALSE )
6666
 
                        || ( ( f_fModifyOnly == TRUE ) 
6667
 
                                && ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay ) ) )
6668
 
                {
6669
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.usDwordOffset * 4;
6670
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byBitOffset;
6671
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byFieldSize;
6672
 
 
6673
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6674
 
                                                                                                pChanEntry,
6675
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6676
 
                                                                                                &ulTempData,
6677
 
                                                                                                ulResult );
6678
 
                        if ( ulResult != cOCT6100_ERR_OK )
6679
 
                                return ulResult;
6680
 
                        
6681
 
                        /* Clear previous value set in the feature field.*/
6682
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6683
 
 
6684
 
                        ulTempData &= (~ulMask);
6685
 
 
6686
 
                        /* Set the tone disabler VQE activation delay. */
6687
 
                        ulTempData |= ( ( (UINT32)( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay - 300 ) / 512 ) ) << ulFeatureBitOffset );
6688
 
 
6689
 
                        /* Write the new DWORD where the field is located. */
6690
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
6691
 
                                                                                        pChanEntry,
6692
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6693
 
                                                                                        ulTempData,
6694
 
                                                                                        ulResult );
6695
 
                        if ( ulResult != cOCT6100_ERR_OK )
6696
 
                                return ulResult;        
6697
 
                }
6698
 
        }
6699
 
 
6700
 
        /* Configure Conferencing Noise Reduction.*/
6701
 
        if ( pSharedInfo->ImageInfo.fConferencingNoiseReduction == TRUE )
6702
 
        {
6703
 
                /* Check if the configuration has been changed. */
6704
 
                if ( ( f_fModifyOnly == FALSE )
6705
 
                        || ( ( f_fModifyOnly == TRUE ) 
6706
 
                                && ( ( f_pVqeConfig->fSoutConferencingNoiseReduction != pChanEntry->VqeConfig.fSoutConferencingNoiseReduction ) 
6707
 
                                        || ( f_pVqeConfig->fSoutNoiseBleaching != pChanEntry->VqeConfig.fSoutNoiseBleaching ) ) ) )
6708
 
                {
6709
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.usDwordOffset * 4;
6710
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byBitOffset;
6711
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byFieldSize;
6712
 
 
6713
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6714
 
                                                                                                pChanEntry,
6715
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6716
 
                                                                                                &ulTempData,
6717
 
                                                                                                ulResult );
6718
 
                        if ( ulResult != cOCT6100_ERR_OK )
6719
 
                                return ulResult;
6720
 
                        
6721
 
                        /* Clear previous value set in the feature field.*/
6722
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6723
 
 
6724
 
                        ulTempData &= (~ulMask);
6725
 
 
6726
 
                        /* Set conferencing noise reduction on the SOUT port. */
6727
 
                        ulTempData |= (f_pVqeConfig->fSoutConferencingNoiseReduction << ulFeatureBitOffset );
6728
 
 
6729
 
                        /* If SOUT noise bleaching is requested, CNR must be activated. */
6730
 
                        ulTempData |= (f_pVqeConfig->fSoutNoiseBleaching << ulFeatureBitOffset );
6731
 
 
6732
 
                        /* Save the DWORD where the field is located. */
6733
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
6734
 
                                                                                        pChanEntry,
6735
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6736
 
                                                                                        ulTempData,
6737
 
                                                                                        ulResult );
6738
 
                        if ( ulResult != cOCT6100_ERR_OK )
6739
 
                                return ulResult;
6740
 
                }
6741
 
        }
6742
 
        
6743
 
        /* Set the DC removal on RIN ports.*/
6744
 
        if ( pSharedInfo->ImageInfo.fRinDcOffsetRemoval == TRUE )
6745
 
        {
6746
 
                /* Check if the configuration has been changed. */
6747
 
                if ( ( f_fModifyOnly == FALSE )
6748
 
                        || ( ( f_fModifyOnly == TRUE ) 
6749
 
                                && ( f_pVqeConfig->fRinDcOffsetRemoval != pChanEntry->VqeConfig.fRinDcOffsetRemoval ) ) )
6750
 
                {
6751
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.usDwordOffset * 4;
6752
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byBitOffset;
6753
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byFieldSize;
6754
 
 
6755
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6756
 
                                                                                                pChanEntry,
6757
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6758
 
                                                                                                &ulTempData, 
6759
 
                                                                                                ulResult );
6760
 
                        if ( ulResult != cOCT6100_ERR_OK )
6761
 
                                return ulResult;
6762
 
 
6763
 
                        /* Clear previous value set in the feature field.*/
6764
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6765
 
 
6766
 
                        ulTempData &= (~ulMask);
6767
 
 
6768
 
                        /* Set adaptive noise reduction on the SOUT port.*/
6769
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fRinDcOffsetRemoval ) << ulFeatureBitOffset );
6770
 
 
6771
 
                        /* The write the new DWORD where the field is located.*/
6772
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
6773
 
                                                                                        pChanEntry,
6774
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6775
 
                                                                                        ulTempData,
6776
 
                                                                                        ulResult );
6777
 
                        if ( ulResult != cOCT6100_ERR_OK )
6778
 
                                return ulResult;        
6779
 
                }
6780
 
        }
6781
 
 
6782
 
        /* Set the DC removal on SIN ports.*/
6783
 
        if ( pSharedInfo->ImageInfo.fSinDcOffsetRemoval == TRUE )
6784
 
        {
6785
 
                /* Check if the configuration has been changed. */
6786
 
                if ( ( f_fModifyOnly == FALSE )
6787
 
                        || ( ( f_fModifyOnly == TRUE ) 
6788
 
                                && ( f_pVqeConfig->fSinDcOffsetRemoval != pChanEntry->VqeConfig.fSinDcOffsetRemoval ) ) )
6789
 
                {
6790
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.usDwordOffset * 4;
6791
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byBitOffset;
6792
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byFieldSize;
6793
 
 
6794
 
                        /* First read the DWORD where the field is located.*/
6795
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6796
 
                                                                                                pChanEntry,
6797
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6798
 
                                                                                                &ulTempData,
6799
 
                                                                                                ulResult );
6800
 
                        if ( ulResult != cOCT6100_ERR_OK )
6801
 
                                return ulResult;
6802
 
 
6803
 
                        /* Clear previous value set in the feature field.*/
6804
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6805
 
 
6806
 
                        ulTempData &= (~ulMask);
6807
 
 
6808
 
                        /* Set adaptive noise reduction on the SOUT port.*/
6809
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fSinDcOffsetRemoval ) << ulFeatureBitOffset );
6810
 
 
6811
 
                        /* Save the DWORD where the field is located.*/
6812
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
6813
 
                                                                                        pChanEntry,
6814
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6815
 
                                                                                        ulTempData,
6816
 
                                                                                        ulResult );
6817
 
                        if ( ulResult != cOCT6100_ERR_OK )
6818
 
                                return ulResult;        
6819
 
                }
6820
 
        }
6821
 
 
6822
 
        /* Set the level control. */
6823
 
        if ( ( pChanEntry->byEchoOperationMode != f_pChannelOpen->ulEchoOperationMode )
6824
 
                && ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NORMAL ) )
6825
 
                fEchoOperationModeChanged = TRUE;
6826
 
        else
6827
 
                fEchoOperationModeChanged = FALSE;
6828
 
 
6829
 
        /* If opening the channel, all level control configuration must be written. */
6830
 
        if ( f_fModifyOnly == FALSE )
6831
 
                fEchoOperationModeChanged = TRUE;
6832
 
        ulResult = Oct6100ApiSetChannelLevelControl( f_pApiInstance, 
6833
 
                                                                                                 f_pVqeConfig, 
6834
 
                                                                                                 f_usChanIndex,
6835
 
                                                                                                 f_usEchoMemIndex,
6836
 
                                                                                                 fEchoOperationModeChanged );
6837
 
        if ( ulResult != cOCT6100_ERR_OK )
6838
 
                return ulResult;
6839
 
 
6840
 
        /* Set the background noise freeze.*/
6841
 
        if ( pSharedInfo->ImageInfo.fComfortNoise == TRUE )
6842
 
        {
6843
 
                /* Check if the configuration has been changed. */
6844
 
                if ( ( f_fModifyOnly == FALSE )
6845
 
                        || ( ( f_fModifyOnly == TRUE ) 
6846
 
                                && ( f_pVqeConfig->ulComfortNoiseMode != pChanEntry->VqeConfig.byComfortNoiseMode ) ) )
6847
 
                {
6848
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.usDwordOffset * 4;
6849
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byBitOffset;
6850
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byFieldSize;
6851
 
 
6852
 
                        /* First read the DWORD where the field is located.*/
6853
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6854
 
                                                                                                pChanEntry,
6855
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6856
 
                                                                                                &ulTempData,
6857
 
                                                                                                ulResult );
6858
 
                        if ( ulResult != cOCT6100_ERR_OK )
6859
 
                                return ulResult;
6860
 
 
6861
 
                        /* Clear previous value set in the feature field.*/
6862
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6863
 
 
6864
 
                        ulTempData &= (~ulMask);
6865
 
                        ulTempData |= ( f_pVqeConfig->ulComfortNoiseMode << ulFeatureBitOffset );
6866
 
 
6867
 
                        /* Save the new DWORD where the field is located. */
6868
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
6869
 
                                                                                        pChanEntry,
6870
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6871
 
                                                                                        ulTempData,
6872
 
                                                                                        ulResult );
6873
 
                        if ( ulResult != cOCT6100_ERR_OK )
6874
 
                                return ulResult;        
6875
 
                }
6876
 
        }
6877
 
 
6878
 
        /* Set the state of the NLP */
6879
 
        if ( pSharedInfo->ImageInfo.fNlpControl == TRUE )
6880
 
        {
6881
 
                /* Check if the configuration has been changed. */
6882
 
                if ( ( f_fModifyOnly == FALSE )
6883
 
                        || ( ( f_fModifyOnly == TRUE ) 
6884
 
                                && ( f_pVqeConfig->fEnableNlp != pChanEntry->VqeConfig.fEnableNlp ) ) )
6885
 
                {
6886
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpControlFieldOfst.usDwordOffset * 4;
6887
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.NlpControlFieldOfst.byBitOffset;
6888
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpControlFieldOfst.byFieldSize;
6889
 
 
6890
 
                        /* First read the DWORD where the field is located.*/
6891
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6892
 
                                                                                                pChanEntry,
6893
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6894
 
                                                                                                &ulTempData,
6895
 
                                                                                                ulResult );
6896
 
                        if ( ulResult != cOCT6100_ERR_OK )
6897
 
                                return ulResult;
6898
 
 
6899
 
                        /* Clear previous value set in the feature field.*/
6900
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6901
 
 
6902
 
                        ulTempData &= (~ulMask);
6903
 
 
6904
 
                        if ( f_pVqeConfig->fEnableNlp == FALSE )
6905
 
                                ulTempData |= 0x1 << ulFeatureBitOffset;
6906
 
 
6907
 
                        /* Save the new DWORD where the field is located.*/
6908
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
6909
 
                                                                                        pChanEntry,
6910
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6911
 
                                                                                        ulTempData,
6912
 
                                                                                        ulResult );
6913
 
                        if ( ulResult != cOCT6100_ERR_OK )
6914
 
                                return ulResult;
6915
 
                }
6916
 
        }
6917
 
 
6918
 
        /* Set the tail configuration. */
6919
 
        ulResult = Oct6100ApiSetChannelTailConfiguration(
6920
 
                                                                                                f_pApiInstance,
6921
 
                                                                                                f_pVqeConfig,
6922
 
                                                                                                f_usChanIndex,
6923
 
                                                                                                f_usEchoMemIndex,
6924
 
                                                                                                f_fModifyOnly );
6925
 
        if ( ulResult != cOCT6100_ERR_OK )
6926
 
                return ulResult;
6927
 
 
6928
 
        /* Set the Default ERL. */
6929
 
        if ( ( pSharedInfo->ImageInfo.fDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == FALSE ) )
6930
 
        {
6931
 
                /* Check if the configuration has been changed. */
6932
 
                if ( ( f_fModifyOnly == FALSE )
6933
 
                        || ( ( f_fModifyOnly == TRUE ) 
6934
 
                                && ( ( f_pVqeConfig->lDefaultErlDb != pChanEntry->VqeConfig.chDefaultErlDb ) 
6935
 
                                        || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) 
6936
 
                                        || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
6937
 
                {
6938
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.DefaultErlFieldOfst.usDwordOffset * 4;
6939
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byBitOffset;
6940
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byFieldSize;
6941
 
 
6942
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6943
 
                                                                                                pChanEntry,
6944
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6945
 
                                                                                                &ulTempData,
6946
 
                                                                                                ulResult );
6947
 
                        if ( ulResult != cOCT6100_ERR_OK )
6948
 
                                return ulResult;
6949
 
 
6950
 
                        /* Clear previous value set in the feature field.*/
6951
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6952
 
 
6953
 
                        ulTempData &= (~ulMask);
6954
 
 
6955
 
                        /* Convert the DB value to octasic's float format. (In energy) */
6956
 
                        if ( ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
6957
 
                                && ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
6958
 
                        {
6959
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb );
6960
 
                        }
6961
 
                        else
6962
 
                        {
6963
 
                                /* Clear the defautl ERL when using the no echo cancellation operation mode. */
6964
 
                                usTempData = 0x0;
6965
 
                        }
6966
 
 
6967
 
                        if ( ulFeatureFieldLength < 16 )
6968
 
                                usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
6969
 
 
6970
 
                        ulTempData |= ( usTempData << ulFeatureBitOffset );
6971
 
 
6972
 
                        /* Save the new DWORD where the field is located.*/
6973
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
6974
 
                                                                                        pChanEntry,
6975
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6976
 
                                                                                        ulTempData,
6977
 
                                                                                        ulResult );
6978
 
                        if ( ulResult != cOCT6100_ERR_OK )
6979
 
                                return ulResult;        
6980
 
                }
6981
 
        }
6982
 
 
6983
 
        /* Set the Acoustic echo control.*/
6984
 
        if ( pSharedInfo->ImageInfo.fAcousticEcho == TRUE )
6985
 
        {
6986
 
                /* Check if the configuration has been changed. */
6987
 
                if ( ( f_fModifyOnly == FALSE )
6988
 
                        || ( ( f_fModifyOnly == TRUE ) 
6989
 
                                && ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) )
6990
 
                {
6991
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecFieldOfst.usDwordOffset * 4;
6992
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AecFieldOfst.byBitOffset;
6993
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AecFieldOfst.byFieldSize;
6994
 
 
6995
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
6996
 
                                                                                                pChanEntry,
6997
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6998
 
                                                                                                &ulTempData,
6999
 
                                                                                                ulResult );
7000
 
                        if ( ulResult != cOCT6100_ERR_OK )
7001
 
                                return ulResult;
7002
 
 
7003
 
                        /* Clear previous value set in the feature field. */
7004
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7005
 
 
7006
 
                        ulTempData &= (~ulMask);
7007
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fAcousticEcho ) << ulFeatureBitOffset );
7008
 
 
7009
 
                        /* Then save the new DWORD where the field is located. */
7010
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7011
 
                                                                                        pChanEntry,
7012
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7013
 
                                                                                        ulTempData,
7014
 
                                                                                        ulResult );
7015
 
                        if ( ulResult != cOCT6100_ERR_OK )
7016
 
                                return ulResult;        
7017
 
                }
7018
 
        }
7019
 
 
7020
 
        /* Set the Acoustic Echo Default ERL. */
7021
 
        if ( ( pSharedInfo->ImageInfo.fAecDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == TRUE ) )
7022
 
        {
7023
 
                /* Check if the configuration has been changed. */
7024
 
                if ( ( f_fModifyOnly == FALSE )
7025
 
                        || ( ( f_fModifyOnly == TRUE ) 
7026
 
                                && ( ( f_pVqeConfig->lAecDefaultErlDb != pChanEntry->VqeConfig.chAecDefaultErlDb ) 
7027
 
                                        || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
7028
 
                {
7029
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.usDwordOffset * 4;
7030
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byBitOffset;
7031
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byFieldSize;
7032
 
 
7033
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7034
 
                                                                                                pChanEntry,
7035
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7036
 
                                                                                                &ulTempData,
7037
 
                                                                                                ulResult );
7038
 
                        if ( ulResult != cOCT6100_ERR_OK )
7039
 
                                return ulResult;
7040
 
 
7041
 
                        /* Clear previous value set in the feature field. */
7042
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7043
 
 
7044
 
                        ulTempData &= (~ulMask);
7045
 
                        
7046
 
                        if ( ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
7047
 
                                && ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
7048
 
                        {
7049
 
                                /* Convert the DB value to octasic's float format. (In energy) */
7050
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lAecDefaultErlDb );
7051
 
                        }
7052
 
                        else
7053
 
                        {
7054
 
                                /* Clear the AEC defautl ERL when using the no echo cancellation operation mode. */
7055
 
                                usTempData = 0x0;
7056
 
                        }
7057
 
 
7058
 
                        if ( ulFeatureFieldLength < 16 )
7059
 
                                usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
7060
 
 
7061
 
                        ulTempData |= ( usTempData << ulFeatureBitOffset );
7062
 
 
7063
 
                        /* Then save the DWORD where the field is located. */
7064
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7065
 
                                                                                        pChanEntry,
7066
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7067
 
                                                                                        ulTempData,
7068
 
                                                                                        ulResult );
7069
 
                        if ( ulResult != cOCT6100_ERR_OK )
7070
 
                                return ulResult;        
7071
 
                }
7072
 
        }
7073
 
 
7074
 
        /* Set the DTMF tone removal bit.*/
7075
 
        if ( pSharedInfo->ImageInfo.fToneRemoval == TRUE )
7076
 
        {
7077
 
                /* Check if the configuration has been changed. */
7078
 
                if ( ( f_fModifyOnly == FALSE )
7079
 
                        || ( ( f_fModifyOnly == TRUE ) 
7080
 
                                && ( f_pVqeConfig->fDtmfToneRemoval != pChanEntry->VqeConfig.fDtmfToneRemoval ) ) )
7081
 
                {
7082
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.usDwordOffset * 4;
7083
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byBitOffset;
7084
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byFieldSize;
7085
 
 
7086
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7087
 
                                                                                                pChanEntry,
7088
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7089
 
                                                                                                &ulTempData,
7090
 
                                                                                                ulResult );
7091
 
                        if ( ulResult != cOCT6100_ERR_OK )
7092
 
                                return ulResult;
7093
 
 
7094
 
                        /* Clear previous value set in the feature field.*/
7095
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7096
 
 
7097
 
                        ulTempData &= (~ulMask);
7098
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fDtmfToneRemoval ) << ulFeatureBitOffset );
7099
 
 
7100
 
                        /* First read the DWORD where the field is located.*/
7101
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7102
 
                                                                                        pChanEntry,
7103
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7104
 
                                                                                        ulTempData,
7105
 
                                                                                        ulResult );
7106
 
                        if ( ulResult != cOCT6100_ERR_OK )
7107
 
                                return ulResult;        
7108
 
                }
7109
 
        }
7110
 
 
7111
 
 
7112
 
 
7113
 
        /* Set the non-linear behavior A.*/
7114
 
        if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorA == TRUE )
7115
 
        {
7116
 
                /* Check if the configuration has been changed. */
7117
 
                if ( ( f_fModifyOnly == FALSE )
7118
 
                        || ( ( f_fModifyOnly == TRUE ) 
7119
 
                                && ( ( f_pVqeConfig->ulNonLinearityBehaviorA != pChanEntry->VqeConfig.byNonLinearityBehaviorA ) 
7120
 
                                        || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
7121
 
                {
7122
 
                        UINT16  ausLookupTable[ 14 ] = { 0x3663, 0x3906, 0x399C, 0x3A47, 0x3B06, 0x3B99, 0x3C47, 0x3D02, 0x3D99, 0x3E47, 0x3F00, 0x3F99, 0x4042, 0x4100 };
7123
 
                        
7124
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.PcmLeakFieldOfst.usDwordOffset * 4;
7125
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byBitOffset;
7126
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byFieldSize;
7127
 
 
7128
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7129
 
                                                                                                pChanEntry,
7130
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7131
 
                                                                                                &ulTempData,
7132
 
                                                                                                ulResult );
7133
 
                        if ( ulResult != cOCT6100_ERR_OK )
7134
 
                                return ulResult;
7135
 
 
7136
 
                        /* Clear previous value set in the feature field.*/
7137
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7138
 
 
7139
 
                        ulTempData &= (~ulMask);
7140
 
                        if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
7141
 
                                || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
7142
 
                                ulTempData |= ( 0x0 << ulFeatureBitOffset );
7143
 
                        else
7144
 
                                ulTempData |= ( ausLookupTable[ f_pVqeConfig->ulNonLinearityBehaviorA ] << ulFeatureBitOffset );
7145
 
 
7146
 
                        /* Then save the DWORD where the field is located.*/
7147
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7148
 
                                                                                        pChanEntry,
7149
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7150
 
                                                                                        ulTempData,
7151
 
                                                                                        ulResult );
7152
 
                        if ( ulResult != cOCT6100_ERR_OK )
7153
 
                                return ulResult;
7154
 
                }
7155
 
        }
7156
 
        
7157
 
        /* Synch all the buffer playout field.*/
7158
 
        if ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE && f_fClearPlayoutPointers == TRUE )
7159
 
        {       
7160
 
                Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
7161
 
 
7162
 
                BufferPlayoutStop.ulChannelHndl = cOCT6100_INVALID_HANDLE;
7163
 
                BufferPlayoutStop.fStopCleanly = TRUE;
7164
 
                
7165
 
                BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
7166
 
                ulResult = Oct6100ApiInvalidateChanPlayoutStructs( 
7167
 
                                                                                                                f_pApiInstance, 
7168
 
                                                                                                                &BufferPlayoutStop, 
7169
 
                                                                                                                f_usChanIndex, 
7170
 
                                                                                                                f_usEchoMemIndex 
7171
 
 
7172
 
                                                                                                                );
7173
 
                if ( ulResult != cOCT6100_ERR_OK )
7174
 
                        return ulResult;
7175
 
                
7176
 
                BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
7177
 
                ulResult = Oct6100ApiInvalidateChanPlayoutStructs( 
7178
 
                                                                                                                f_pApiInstance, 
7179
 
                                                                                                                &BufferPlayoutStop, 
7180
 
                                                                                                                f_usChanIndex, 
7181
 
                                                                                                                f_usEchoMemIndex 
7182
 
 
7183
 
                                                                                                                );
7184
 
                if ( ulResult != cOCT6100_ERR_OK )
7185
 
                        return ulResult;
7186
 
        }
7187
 
 
7188
 
        /*==============================================================================*/
7189
 
        /* Write the 2100 Hz Echo Disabling mode */
7190
 
 
7191
 
        /* Check if the configuration has been changed. */
7192
 
        if ( ( f_fModifyOnly == FALSE )
7193
 
                || ( ( f_fModifyOnly == TRUE ) 
7194
 
                        && ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) ) )
7195
 
        {
7196
 
                ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerControlOfst.usDwordOffset * 4;
7197
 
                ulFeatureBitOffset       = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byBitOffset;
7198
 
                ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byFieldSize;
7199
 
 
7200
 
                /* First read the DWORD where the field is located.*/
7201
 
                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7202
 
                                                                                        pChanEntry,
7203
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7204
 
                                                                                        &ulTempData,
7205
 
                                                                                        ulResult );
7206
 
                if ( ulResult != cOCT6100_ERR_OK )
7207
 
                        return ulResult;
7208
 
 
7209
 
                /* Clear previous value set in the feature field.*/
7210
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7211
 
 
7212
 
                ulTempData &= (~ulMask);
7213
 
                
7214
 
                /* This is a disable bit, so it must be set only if the enable flag is set to false. */
7215
 
                if ( f_pChannelOpen->fEnableToneDisabler == FALSE )
7216
 
                        ulTempData |= 0x1 << ulFeatureBitOffset;
7217
 
 
7218
 
                /* Save the DWORD where the field is located. */
7219
 
                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7220
 
                                                                                pChanEntry,
7221
 
                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7222
 
                                                                                ulTempData,
7223
 
                                                                                ulResult );
7224
 
                if ( ulResult != cOCT6100_ERR_OK )
7225
 
                        return ulResult;        
7226
 
        }
7227
 
        /*==============================================================================*/
7228
 
 
7229
 
 
7230
 
        /*==============================================================================*/
7231
 
        /* Write the Nlp Trivial enable flag. */
7232
 
 
7233
 
        /* Check if the configuration has been changed. */
7234
 
        if ( ( f_fModifyOnly == FALSE )
7235
 
                || ( ( f_fModifyOnly == TRUE ) 
7236
 
                        && ( 
7237
 
 
7238
 
                                ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
7239
 
        {
7240
 
                ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.usDwordOffset * 4;
7241
 
                ulFeatureBitOffset       = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byBitOffset;
7242
 
                ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byFieldSize;
7243
 
 
7244
 
                /* First read the DWORD where the field is located.*/
7245
 
                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7246
 
                                                                                        pChanEntry,
7247
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7248
 
                                                                                        &ulTempData,
7249
 
                                                                                        ulResult );
7250
 
                if ( ulResult != cOCT6100_ERR_OK )
7251
 
                        return ulResult;
7252
 
 
7253
 
                /* Clear previous value set in the feature field.*/
7254
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7255
 
 
7256
 
                ulTempData &= (~ulMask);
7257
 
                if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
7258
 
                        || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
7259
 
                {
7260
 
                        ulTempData |= TRUE << ulFeatureBitOffset;
7261
 
                }
7262
 
 
7263
 
 
7264
 
                /* Then write the DWORD where the field is located. */
7265
 
                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7266
 
                                                                                pChanEntry,
7267
 
                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7268
 
                                                                                ulTempData,
7269
 
                                                                                ulResult );
7270
 
                if ( ulResult != cOCT6100_ERR_OK )
7271
 
                        return ulResult;        
7272
 
        }
7273
 
        /*==============================================================================*/
7274
 
 
7275
 
 
7276
 
        /*==============================================================================*/
7277
 
        /* Set the double talk behavior mode. */
7278
 
        if ( pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst == TRUE )
7279
 
        {
7280
 
                /* Check if the configuration has been changed. */
7281
 
                if ( ( f_fModifyOnly == FALSE )
7282
 
                        || ( ( f_fModifyOnly == TRUE ) 
7283
 
                                && ( f_pVqeConfig->ulDoubleTalkBehavior != pChanEntry->VqeConfig.byDoubleTalkBehavior ) ) )
7284
 
                {
7285
 
                        /* The field is located in the CPURO structure. */
7286
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.usDwordOffset * 4;
7287
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.byBitOffset;
7288
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst.byFieldSize;
7289
 
 
7290
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7291
 
                                                                                                pChanEntry,
7292
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7293
 
                                                                                                &ulTempData, 
7294
 
                                                                                                ulResult );
7295
 
                        if ( ulResult != cOCT6100_ERR_OK )
7296
 
                                return ulResult;
7297
 
 
7298
 
                        /* Clear previous value set in the feature field.*/
7299
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7300
 
 
7301
 
                        ulTempData &= (~ulMask);
7302
 
                        ulTempData |= (f_pVqeConfig->ulDoubleTalkBehavior  << ulFeatureBitOffset );
7303
 
 
7304
 
                        /* Then save the DWORD where the field is located.*/
7305
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7306
 
                                                                                        pChanEntry,
7307
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7308
 
                                                                                        ulTempData,
7309
 
                                                                                        ulResult );
7310
 
                        if ( ulResult != cOCT6100_ERR_OK )
7311
 
                                return ulResult;        
7312
 
                }                       
7313
 
        }
7314
 
        /*==============================================================================*/
7315
 
 
7316
 
 
7317
 
        /*==============================================================================*/
7318
 
        /* Set the music protection enable. */
7319
 
        if ( ( pSharedInfo->ImageInfo.fMusicProtection == TRUE )
7320
 
                && ( pSharedInfo->ImageInfo.fMusicProtectionConfiguration == TRUE ) )
7321
 
        {
7322
 
                /* Check if the configuration has been changed. */
7323
 
                if ( ( f_fModifyOnly == FALSE )
7324
 
                        || ( ( f_fModifyOnly == TRUE ) 
7325
 
                                && ( f_pVqeConfig->fEnableMusicProtection != pChanEntry->VqeConfig.fEnableMusicProtection ) ) )
7326
 
                {
7327
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.usDwordOffset * 4;
7328
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byBitOffset;
7329
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byFieldSize;
7330
 
 
7331
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7332
 
                                                                                                pChanEntry,
7333
 
                                                                                                ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7334
 
                                                                                                &ulTempData, 
7335
 
                                                                                                ulResult );
7336
 
                        if ( ulResult != cOCT6100_ERR_OK )
7337
 
                                return ulResult;
7338
 
 
7339
 
                        /* Clear previous value set in the feature field.*/
7340
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7341
 
 
7342
 
                        ulTempData &= (~ulMask);
7343
 
                        if ( f_pVqeConfig->fEnableMusicProtection == TRUE )
7344
 
                                ulTempData |= ( 1 << ulFeatureBitOffset );
7345
 
 
7346
 
                        /* Then save the DWORD where the field is located.*/
7347
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7348
 
                                                                                        pChanEntry,
7349
 
                                                                                        ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7350
 
                                                                                        ulTempData,
7351
 
                                                                                        ulResult );
7352
 
                        if ( ulResult != cOCT6100_ERR_OK )
7353
 
                                return ulResult;        
7354
 
                }
7355
 
        }
7356
 
        /*==============================================================================*/
7357
 
 
7358
 
        return cOCT6100_ERR_OK;
7359
 
}
7360
 
 
7361
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7362
 
 
7363
 
Function:               Oct6100ApiWriteVqeAfMemory
7364
 
 
7365
 
Description:    This function configures the AF related VQE features of an 
7366
 
                                echo channel.
7367
 
 
7368
 
-------------------------------------------------------------------------------
7369
 
|       Argument                |       Description
7370
 
-------------------------------------------------------------------------------
7371
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
7372
 
                                                        the present state of the chip and all its resources.
7373
 
 
7374
 
f_pVqeConfig                            Pointer to a VQE config structure.
7375
 
f_pChannelOpen                          Pointer to a channel configuration structure.
7376
 
f_usChanIndex                           Index of the echo channel in the API instance.
7377
 
f_usEchoMemIndex                        Index of the echo channel within the SSPX memory.
7378
 
f_fClearPlayoutPointers         Flag indicating if the playout pointer should be cleared.
7379
 
f_fModifyOnly                           Flag indicating if the configuration should be
7380
 
                                                        modified only.
7381
 
 
7382
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7383
 
static UINT32 Oct6100ApiWriteVqeAfMemory( 
7384
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
7385
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE              f_pVqeConfig,
7386
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen,
7387
 
                                IN      UINT16                                                  f_usChanIndex,
7388
 
                                IN      UINT16                                                  f_usEchoMemIndex,
7389
 
                                IN      BOOL                                                    f_fClearPlayoutPointers,
7390
 
                                IN      BOOL                                                    f_fModifyOnly )
7391
 
{
7392
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
7393
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
7394
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
7395
 
        UINT32                                                  ulResult;
7396
 
        UINT32                                                  ulTempData;
7397
 
        UINT32                                                  ulAfConfigBaseAddress;
7398
 
        UINT32                                                  ulFeatureBytesOffset;
7399
 
        UINT32                                                  ulFeatureBitOffset;
7400
 
        UINT32                                                  ulFeatureFieldLength;
7401
 
        UINT32                                                  ulMask;
7402
 
        UINT16                                                  usTempData;
7403
 
        
7404
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
7405
 
 
7406
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
7407
 
 
7408
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
7409
 
 
7410
 
        /* Obtain a pointer to the new buffer's list entry. */
7411
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
7412
 
 
7413
 
        /*==============================================================================*/
7414
 
        /*      Write the AF CPU configuration of the channel feature by feature.*/
7415
 
 
7416
 
        /* Calculate AF CPU configuration base address. */
7417
 
        ulAfConfigBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
7418
 
        
7419
 
        /* Set initial value to zero.*/
7420
 
        ulTempData = 0;
7421
 
 
7422
 
        /*==============================================================================*/
7423
 
        /* Program the Maximum echo point within the Main channel memory.*/
7424
 
        if ( pSharedInfo->ImageInfo.fMaxEchoPoint == TRUE )
7425
 
        {
7426
 
                /* Check if the configuration has been changed. */
7427
 
                if ( ( f_fModifyOnly == FALSE )
7428
 
                        || ( ( f_fModifyOnly == TRUE ) 
7429
 
                                && ( ( f_pVqeConfig->lDefaultErlDb != pChanEntry->VqeConfig.chDefaultErlDb ) 
7430
 
                                        || ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
7431
 
                {
7432
 
                        /* Write the echo tail length */
7433
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.usDwordOffset * 4;
7434
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.byBitOffset;
7435
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst.byFieldSize;
7436
 
 
7437
 
                        /* First read the DWORD where the field is located.*/
7438
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7439
 
                                                                                                pChanEntry,
7440
 
                                                                                                ulAfConfigBaseAddress + ulFeatureBytesOffset,
7441
 
                                                                                                &ulTempData,
7442
 
                                                                                                ulResult );
7443
 
                        if ( ulResult != cOCT6100_ERR_OK )
7444
 
                                return ulResult;
7445
 
 
7446
 
                        /* Clear previous value set in the feature field.*/
7447
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7448
 
 
7449
 
                        ulTempData &= (~ulMask);
7450
 
 
7451
 
                        /* Convert the DB value to octasic's float format.*/
7452
 
                        if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
7453
 
                        {
7454
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb );
7455
 
                        }
7456
 
                        else
7457
 
                        {
7458
 
                                /* Clear max echo point.  No echo cancellation here. */
7459
 
                                usTempData = 0x0;
7460
 
                        }
7461
 
 
7462
 
                        if ( ulFeatureFieldLength < 16 )
7463
 
                                usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
7464
 
 
7465
 
                        ulTempData |= usTempData << ulFeatureBitOffset;
7466
 
 
7467
 
                        /* First read the DWORD where the field is located.*/
7468
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7469
 
                                                                                        pChanEntry,
7470
 
                                                                                        ulAfConfigBaseAddress + ulFeatureBytesOffset,
7471
 
                                                                                        ulTempData,
7472
 
                                                                                        ulResult );
7473
 
                        if ( ulResult != cOCT6100_ERR_OK )
7474
 
                                return ulResult;        
7475
 
                }
7476
 
        }
7477
 
        /*==============================================================================*/
7478
 
 
7479
 
 
7480
 
        /*==============================================================================*/
7481
 
        /* Set the non-linear behavior B.*/
7482
 
        if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorB == TRUE )
7483
 
        {
7484
 
                /* Check if the configuration has been changed. */
7485
 
                if ( ( f_fModifyOnly == FALSE )
7486
 
                        || ( ( f_fModifyOnly == TRUE ) 
7487
 
                                && ( f_pVqeConfig->ulNonLinearityBehaviorB != pChanEntry->VqeConfig.byNonLinearityBehaviorB ) ) )
7488
 
                {
7489
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.usDwordOffset * 4;
7490
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byBitOffset;
7491
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byFieldSize;
7492
 
 
7493
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7494
 
                                                                                                pChanEntry,
7495
 
                                                                                                ulAfConfigBaseAddress + ulFeatureBytesOffset,
7496
 
                                                                                                &ulTempData, 
7497
 
                                                                                                ulResult );
7498
 
                        if ( ulResult != cOCT6100_ERR_OK )
7499
 
                                return ulResult;
7500
 
 
7501
 
                        /* Clear previous value set in the feature field.*/
7502
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7503
 
 
7504
 
                        ulTempData &= (~ulMask);
7505
 
                        ulTempData |= (f_pVqeConfig->ulNonLinearityBehaviorB  << ulFeatureBitOffset );
7506
 
 
7507
 
                        /* Then save the DWORD where the field is located.*/
7508
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7509
 
                                                                                        pChanEntry,
7510
 
                                                                                        ulAfConfigBaseAddress + ulFeatureBytesOffset,
7511
 
                                                                                        ulTempData,
7512
 
                                                                                        ulResult );
7513
 
                        if ( ulResult != cOCT6100_ERR_OK )
7514
 
                                return ulResult;        
7515
 
                }
7516
 
        }
7517
 
        /*==============================================================================*/
7518
 
 
7519
 
        
7520
 
        /*==============================================================================*/
7521
 
        /* Set the listener enhancement feature. */
7522
 
        if ( pSharedInfo->ImageInfo.fListenerEnhancement == TRUE )
7523
 
        {
7524
 
                /* Check if the configuration has been changed. */
7525
 
                if ( ( f_fModifyOnly == FALSE )
7526
 
                        || ( ( f_fModifyOnly == TRUE ) 
7527
 
                                && ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb ) 
7528
 
                                        || ( f_pVqeConfig->fSoutNaturalListenerEnhancement != pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement ) 
7529
 
                                        || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb ) ) ) )
7530
 
                {
7531
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveAleOfst.usDwordOffset * 4;
7532
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AdaptiveAleOfst.byBitOffset;
7533
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveAleOfst.byFieldSize;
7534
 
 
7535
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7536
 
                                                                                                pChanEntry,
7537
 
                                                                                                ulAfConfigBaseAddress + ulFeatureBytesOffset,
7538
 
                                                                                                &ulTempData,
7539
 
                                                                                                ulResult );
7540
 
                        if ( ulResult != cOCT6100_ERR_OK )
7541
 
                                return ulResult;
7542
 
 
7543
 
                        /* Clear previous value set in the feature field.*/
7544
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7545
 
                        
7546
 
                        ulTempData &= (~ulMask);
7547
 
 
7548
 
                        if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 )
7549
 
                        {
7550
 
                                UINT32 ulGainDb;
7551
 
 
7552
 
                                ulGainDb = f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb / 3;
7553
 
 
7554
 
                                /* Round up. */
7555
 
                                if ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb % 3 ) != 0x0 )
7556
 
                                        ulGainDb ++;
7557
 
 
7558
 
                                ulTempData |= ( ulGainDb << ulFeatureBitOffset );
7559
 
                        }
7560
 
                        else if ( f_pVqeConfig->fSoutNaturalListenerEnhancement != 0 )
7561
 
                        {
7562
 
                                UINT32 ulGainDb;
7563
 
 
7564
 
                                ulGainDb = f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb / 3;
7565
 
 
7566
 
                                /* Round up. */
7567
 
                                if ( ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb % 3 ) != 0x0 )
7568
 
                                        ulGainDb ++;
7569
 
 
7570
 
                                ulTempData |= ( ( 0x80 | ulGainDb ) << ulFeatureBitOffset );
7571
 
                        }
7572
 
 
7573
 
                        /* Now write the DWORD where the field is located containing the new configuration. */
7574
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7575
 
                                                                                        pChanEntry,
7576
 
                                                                                        ulAfConfigBaseAddress + ulFeatureBytesOffset,
7577
 
                                                                                        ulTempData,
7578
 
                                                                                        ulResult );
7579
 
                        if ( ulResult != cOCT6100_ERR_OK )
7580
 
                                return ulResult;        
7581
 
                }
7582
 
        }
7583
 
        /*==============================================================================*/
7584
 
 
7585
 
 
7586
 
        /*==============================================================================*/
7587
 
        /* Set the idle code detection enable. */
7588
 
        if ( ( pSharedInfo->ImageInfo.fIdleCodeDetection == TRUE )
7589
 
                && ( pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration == TRUE ) )
7590
 
        {
7591
 
                /* Check if the configuration has been changed. */
7592
 
                if ( ( f_fModifyOnly == FALSE )
7593
 
                        || ( ( f_fModifyOnly == TRUE ) 
7594
 
                                && ( f_pVqeConfig->fIdleCodeDetection != pChanEntry->VqeConfig.fIdleCodeDetection ) ) )
7595
 
                {
7596
 
                        /* Calculate base address in the AF software configuration. */
7597
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.usDwordOffset * 4;
7598
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.byBitOffset;
7599
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst.byFieldSize;
7600
 
 
7601
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7602
 
                                                                                                pChanEntry,
7603
 
                                                                                                ulAfConfigBaseAddress + ulFeatureBytesOffset,
7604
 
                                                                                                &ulTempData, 
7605
 
                                                                                                ulResult );
7606
 
                        if ( ulResult != cOCT6100_ERR_OK )
7607
 
                                return ulResult;
7608
 
 
7609
 
                        /* Clear previous value set in the feature field.*/
7610
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7611
 
 
7612
 
                        ulTempData &= (~ulMask);
7613
 
                        if ( f_pVqeConfig->fIdleCodeDetection == FALSE )
7614
 
                                ulTempData |= ( 1 << ulFeatureBitOffset );
7615
 
 
7616
 
                        /* Then save the DWORD where the field is located.*/
7617
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7618
 
                                                                                        pChanEntry,
7619
 
                                                                                        ulAfConfigBaseAddress + ulFeatureBytesOffset,
7620
 
                                                                                        ulTempData,
7621
 
                                                                                        ulResult );
7622
 
                        if ( ulResult != cOCT6100_ERR_OK )
7623
 
                                return ulResult;        
7624
 
                }
7625
 
        }
7626
 
        /*==============================================================================*/
7627
 
 
7628
 
 
7629
 
        /*==============================================================================*/
7630
 
        /* Set the AFT control field. */
7631
 
        if ( pSharedInfo->ImageInfo.fAftControl == TRUE )
7632
 
        {
7633
 
                /* Check if the configuration has been changed. */
7634
 
                if ( ( f_fModifyOnly == FALSE )
7635
 
                        || ( ( f_fModifyOnly == TRUE ) 
7636
 
                                && ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) )
7637
 
                {
7638
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AftControlOfst.usDwordOffset * 4;
7639
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AftControlOfst.byBitOffset;
7640
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AftControlOfst.byFieldSize;
7641
 
 
7642
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
7643
 
                                                                                                pChanEntry,
7644
 
                                                                                                ulAfConfigBaseAddress + ulFeatureBytesOffset,
7645
 
                                                                                                &ulTempData,
7646
 
                                                                                                ulResult );
7647
 
                        if ( ulResult != cOCT6100_ERR_OK )
7648
 
                                return ulResult;
7649
 
 
7650
 
                        /* Clear previous value set in the feature field.*/
7651
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7652
 
 
7653
 
                        ulTempData &= (~ulMask);
7654
 
                        
7655
 
                        /* If the operation mode is no echo, set the field such that echo cancellation is disabled. */
7656
 
                        if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
7657
 
                        {
7658
 
                                ulTempData |= ( 0x1234 << ulFeatureBitOffset );
7659
 
                        }
7660
 
                        else if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
7661
 
                        {
7662
 
                                /* For clarity. */
7663
 
                                ulTempData |= ( 0x0 << ulFeatureBitOffset );
7664
 
                        }
7665
 
 
7666
 
                        /* Then save the DWORD where the field is located.*/
7667
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
7668
 
                                                                                        pChanEntry,
7669
 
                                                                                        ulAfConfigBaseAddress + ulFeatureBytesOffset,
7670
 
                                                                                        ulTempData,
7671
 
                                                                                        ulResult );
7672
 
                        if ( ulResult != cOCT6100_ERR_OK )
7673
 
                                return ulResult;        
7674
 
                }
7675
 
        }
7676
 
        /*==============================================================================*/
7677
 
 
7678
 
        return cOCT6100_ERR_OK;
7679
 
}
7680
 
 
7681
 
 
7682
 
 
7683
 
 
7684
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7685
 
 
7686
 
Function:               Oct6100ApiWriteEchoMemory
7687
 
 
7688
 
Description:    This function configure an echo memory entry in internal memory.and
7689
 
                                external memory.
7690
 
 
7691
 
-------------------------------------------------------------------------------
7692
 
|       Argument                |       Description
7693
 
-------------------------------------------------------------------------------
7694
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
7695
 
                                                the present state of the chip and all its resources.
7696
 
 
7697
 
f_pTdmConfig                    Pointer to a TDM config structure.
7698
 
f_pChannelOpen                  Pointer to a channel configuration structure.
7699
 
f_usEchoIndex                   Echo channel index within the SSPX memory.
7700
 
f_usRinRoutTsiIndex             RIN/ROUT TSI index within the TSI chariot memory
7701
 
f_usSinSoutTsiIndex             SIN/SOUT TSI index within the TSI chariot memory
7702
 
 
7703
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7704
 
static UINT32 Oct6100ApiWriteEchoMemory( 
7705
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
7706
 
                                IN      tPOCT6100_CHANNEL_OPEN_TDM              f_pTdmConfig,
7707
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen,
7708
 
                                IN      UINT16                                                  f_usEchoIndex,
7709
 
                                IN      UINT16                                                  f_usRinRoutTsiIndex,
7710
 
                                IN      UINT16                                                  f_usSinSoutTsiIndex )
7711
 
 
7712
 
{
7713
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
7714
 
        tOCT6100_WRITE_PARAMS           WriteParams;
7715
 
        UINT32                                          ulResult;
7716
 
        UINT32                                          ulTempData;
7717
 
        UINT32                                          ulBaseAddress;
7718
 
        UINT32                                          ulRinPcmLaw;
7719
 
        UINT32                                          ulRoutPcmLaw;
7720
 
        UINT32                                          ulSinPcmLaw;
7721
 
        UINT32                                          ulSoutPcmLaw;
7722
 
 
7723
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
7724
 
 
7725
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
7726
 
 
7727
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
7728
 
 
7729
 
        /* Set immediately the PCM law to be programmed in the SSPX and NLP memory.*/
7730
 
        if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
7731
 
        {
7732
 
                ulRinPcmLaw             = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;
7733
 
                ulRoutPcmLaw    = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;
7734
 
                ulSinPcmLaw             = f_pChannelOpen->TdmConfig.ulSinPcmLaw;
7735
 
                ulSoutPcmLaw    = f_pChannelOpen->TdmConfig.ulSinPcmLaw;
7736
 
        }
7737
 
        else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
7738
 
        {
7739
 
                ulRinPcmLaw             = f_pChannelOpen->TdmConfig.ulRinPcmLaw;
7740
 
                ulRoutPcmLaw    = f_pChannelOpen->TdmConfig.ulRinPcmLaw;
7741
 
                ulSinPcmLaw             = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;
7742
 
                ulSoutPcmLaw    = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;
7743
 
        }
7744
 
 
7745
 
        /*==============================================================================*/
7746
 
        /*      Configure the Global Static Configuration of the channel.*/
7747
 
 
7748
 
        ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET;
7749
 
 
7750
 
        /* Set the PGSP context base address. */
7751
 
        ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET;
7752
 
        
7753
 
        WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET;
7754
 
        WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
7755
 
 
7756
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7757
 
        if ( ulResult != cOCT6100_ERR_OK  )
7758
 
                return ulResult;
7759
 
 
7760
 
        WriteParams.ulWriteAddress += 2;
7761
 
        WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
7762
 
 
7763
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7764
 
        if ( ulResult != cOCT6100_ERR_OK  )
7765
 
                return ulResult;
7766
 
 
7767
 
        /* Set the PGSP init context base address. */
7768
 
        ulTempData = ( cOCT6100_IMAGE_FILE_BASE + 0x200 ) & 0x07FFFFFF;
7769
 
        
7770
 
        WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET;
7771
 
        WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
7772
 
 
7773
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7774
 
        if ( ulResult != cOCT6100_ERR_OK  )
7775
 
                return ulResult;
7776
 
 
7777
 
        WriteParams.ulWriteAddress += 2;
7778
 
        WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
7779
 
 
7780
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7781
 
        if ( ulResult != cOCT6100_ERR_OK  )
7782
 
                return ulResult;
7783
 
        
7784
 
        /* Set the RIN circular buffer base address. */
7785
 
        ulTempData  = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst) & 0x07FFFF00;
7786
 
        ulTempData |= ( ulRoutPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
7787
 
        
7788
 
        /* Set the circular buffer size.*/
7789
 
        if (( pSharedInfo->MemoryMap.ulChanMainRinCBMemSize & 0xFFFF00FF ) != 0 )
7790
 
                return cOCT6100_ERR_CHANNEL_INVALID_RIN_CB_SIZE;
7791
 
        ulTempData |= pSharedInfo->MemoryMap.ulChanMainRinCBMemSize >> 8;
7792
 
                
7793
 
        WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET;
7794
 
        WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
7795
 
 
7796
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7797
 
        if ( ulResult != cOCT6100_ERR_OK  )
7798
 
                return ulResult;
7799
 
 
7800
 
        WriteParams.ulWriteAddress += 2;
7801
 
        WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
7802
 
 
7803
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7804
 
        if ( ulResult != cOCT6100_ERR_OK  )
7805
 
                return ulResult;
7806
 
 
7807
 
        /* Set the SIN circular buffer base address. */
7808
 
        ulTempData  = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst) & 0x07FFFF00;
7809
 
        ulTempData |= ( ulSinPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
7810
 
 
7811
 
        WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET;
7812
 
        WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
7813
 
 
7814
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7815
 
        if ( ulResult != cOCT6100_ERR_OK  )
7816
 
                return ulResult;
7817
 
 
7818
 
        WriteParams.ulWriteAddress += 2;
7819
 
        WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
7820
 
 
7821
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7822
 
        if ( ulResult != cOCT6100_ERR_OK  )
7823
 
                return ulResult;
7824
 
 
7825
 
        /* Set the SOUT circular buffer base address. */
7826
 
        ulTempData  = ( pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst ) & 0x07FFFF00;
7827
 
        ulTempData |= ( ulSoutPcmLaw << cOCT6100_GSC_BUFFER_LAW_OFFSET );
7828
 
 
7829
 
        WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET;
7830
 
        WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
7831
 
 
7832
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7833
 
        if ( ulResult != cOCT6100_ERR_OK  )
7834
 
                return ulResult;
7835
 
 
7836
 
        WriteParams.ulWriteAddress += 2;
7837
 
        WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
7838
 
 
7839
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7840
 
        if ( ulResult != cOCT6100_ERR_OK  )
7841
 
                return ulResult;
7842
 
 
7843
 
        /*==============================================================================*/
7844
 
 
7845
 
        
7846
 
        /*==============================================================================*/
7847
 
        /*      ECHO SSPX Memory configuration.*/
7848
 
        
7849
 
        WriteParams.ulWriteAddress  = cOCT6100_ECHO_CONTROL_MEM_BASE + ( f_usEchoIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
7850
 
 
7851
 
        /* ECHO memory BASE + 2 */
7852
 
        WriteParams.ulWriteAddress += 2;
7853
 
        WriteParams.usWriteData = 0x0000;
7854
 
 
7855
 
        /* Set the echo control field.*/
7856
 
        if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
7857
 
                || ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
7858
 
        {
7859
 
                WriteParams.usWriteData |= cOCT6100_ECHO_OP_MODE_NORMAL << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL;
7860
 
        }
7861
 
        else if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL )
7862
 
        {
7863
 
                WriteParams.usWriteData |= f_pChannelOpen->ulEchoOperationMode << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL;
7864
 
        }
7865
 
 
7866
 
        /* Set the SIN/SOUT law.*/
7867
 
        WriteParams.usWriteData |= ulSinPcmLaw << cOCT6100_ECHO_CONTROL_MEM_INPUT_LAW_OFFSET;
7868
 
        WriteParams.usWriteData |= ulSoutPcmLaw << cOCT6100_ECHO_CONTROL_MEM_OUTPUT_LAW_OFFSET;
7869
 
 
7870
 
        /* Set the TSI chariot memory field.*/
7871
 
        WriteParams.usWriteData |= f_usSinSoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK; 
7872
 
 
7873
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7874
 
        if ( ulResult != cOCT6100_ERR_OK  )
7875
 
                return ulResult;
7876
 
 
7877
 
        /* ECHO memory BASE */
7878
 
        WriteParams.ulWriteAddress -= 2;
7879
 
        WriteParams.usWriteData  = cOCT6100_ECHO_CONTROL_MEM_ACTIVATE_ENTRY;
7880
 
 
7881
 
        /* Set the RIN/ROUT law.*/
7882
 
        WriteParams.usWriteData |= ulRinPcmLaw << cOCT6100_ECHO_CONTROL_MEM_INPUT_LAW_OFFSET;
7883
 
        WriteParams.usWriteData |= ulRoutPcmLaw << cOCT6100_ECHO_CONTROL_MEM_OUTPUT_LAW_OFFSET;
7884
 
 
7885
 
        /* Set the RIN external echo control bit.*/
7886
 
        if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_EXTERNAL )
7887
 
                WriteParams.usWriteData |= cOCT6100_ECHO_CONTROL_MEM_EXTERNAL_AF_CTRL;
7888
 
 
7889
 
        /* Set the TSI chariot memory field.*/
7890
 
        WriteParams.usWriteData |= f_usRinRoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK; 
7891
 
 
7892
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7893
 
        if ( ulResult != cOCT6100_ERR_OK  )
7894
 
                return ulResult;
7895
 
 
7896
 
        /*==============================================================================*/
7897
 
 
7898
 
        return cOCT6100_ERR_OK;
7899
 
}
7900
 
 
7901
 
 
7902
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7903
 
 
7904
 
Function:               Oct6100ApiUpdateOpenStruct
7905
 
 
7906
 
Description:    This function will copy the new parameter from the modify structure 
7907
 
                                into a channel open structure to be processed later by the same path 
7908
 
                                as the channel open function.  
7909
 
                                If a parameter is set to keep previous, it's current value will be 
7910
 
                                extracted from the channel entry in the API.
7911
 
 
7912
 
-------------------------------------------------------------------------------
7913
 
|       Argument                |       Description
7914
 
-------------------------------------------------------------------------------
7915
 
 
7916
 
IN              f_pApiInstance                          Pointer to an API instance structure.
7917
 
IN              f_pChanModify                   Pointer to a channel modify structure.
7918
 
IN OUT  f_pChanOpen                             Pointer to a channel open structure.
7919
 
IN              f_pChanEntry                    Pointer to an API channel structure.
7920
 
 
7921
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
7922
 
static UINT32 Oct6100ApiUpdateOpenStruct( 
7923
 
                                IN              tPOCT6100_INSTANCE_API                  f_pApiInstance,
7924
 
                                IN              tPOCT6100_CHANNEL_MODIFY                f_pChanModify,
7925
 
                                IN OUT  tPOCT6100_CHANNEL_OPEN                  f_pChanOpen,
7926
 
                                IN              tPOCT6100_API_CHANNEL                   f_pChanEntry )
7927
 
{
7928
 
        
7929
 
        /* Check the generic Echo parameters.*/
7930
 
        if ( f_pChanModify->ulEchoOperationMode == cOCT6100_KEEP_PREVIOUS_SETTING )
7931
 
                f_pChanOpen->ulEchoOperationMode = f_pChanEntry->byEchoOperationMode;
7932
 
        else
7933
 
                f_pChanOpen->ulEchoOperationMode = f_pChanModify->ulEchoOperationMode;
7934
 
 
7935
 
 
7936
 
        if ( f_pChanModify->fEnableToneDisabler == cOCT6100_KEEP_PREVIOUS_SETTING )
7937
 
                f_pChanOpen->fEnableToneDisabler = f_pChanEntry->fEnableToneDisabler;
7938
 
        else
7939
 
                f_pChanOpen->fEnableToneDisabler = f_pChanModify->fEnableToneDisabler;
7940
 
 
7941
 
 
7942
 
        if ( f_pChanModify->ulUserChanId == cOCT6100_KEEP_PREVIOUS_SETTING )
7943
 
                f_pChanOpen->ulUserChanId = f_pChanEntry->ulUserChanId;
7944
 
        else
7945
 
                f_pChanOpen->ulUserChanId = f_pChanModify->ulUserChanId;
7946
 
 
7947
 
 
7948
 
        
7949
 
        /*======================================================================*/
7950
 
        /* Now update the TDM config.*/
7951
 
        /* Rin PCM LAW */
7952
 
        if ( f_pChanModify->TdmConfig.ulRinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
7953
 
                f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanEntry->TdmConfig.byRinPcmLaw;
7954
 
        else
7955
 
                f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanModify->TdmConfig.ulRinPcmLaw;
7956
 
        
7957
 
        /* Sin PCM LAW */
7958
 
        if ( f_pChanModify->TdmConfig.ulSinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
7959
 
                f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanEntry->TdmConfig.bySinPcmLaw;
7960
 
        else
7961
 
                f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanModify->TdmConfig.ulSinPcmLaw;
7962
 
        
7963
 
        /* Rout PCM LAW */
7964
 
        if ( f_pChanModify->TdmConfig.ulRoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
7965
 
                f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanEntry->TdmConfig.byRoutPcmLaw;
7966
 
        else
7967
 
                f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanModify->TdmConfig.ulRoutPcmLaw;
7968
 
 
7969
 
        /* Sout PCM LAW */
7970
 
        if ( f_pChanModify->TdmConfig.ulSoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
7971
 
                f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanEntry->TdmConfig.bySoutPcmLaw;
7972
 
        else
7973
 
                f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanModify->TdmConfig.ulSoutPcmLaw;
7974
 
 
7975
 
 
7976
 
        /* Rin Timeslot */
7977
 
        if ( f_pChanModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
7978
 
                f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanEntry->TdmConfig.usRinTimeslot;
7979
 
        else
7980
 
                f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanModify->TdmConfig.ulRinTimeslot;
7981
 
        
7982
 
        /* Rin Stream */
7983
 
        if ( f_pChanModify->TdmConfig.ulRinStream == cOCT6100_KEEP_PREVIOUS_SETTING )
7984
 
                f_pChanOpen->TdmConfig.ulRinStream = f_pChanEntry->TdmConfig.usRinStream;
7985
 
        else
7986
 
                f_pChanOpen->TdmConfig.ulRinStream = f_pChanModify->TdmConfig.ulRinStream;
7987
 
 
7988
 
        /* Rin Num TSSTs */
7989
 
        if ( f_pChanModify->TdmConfig.ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
7990
 
                f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanEntry->TdmConfig.byRinNumTssts;
7991
 
        else
7992
 
                f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanModify->TdmConfig.ulRinNumTssts;
7993
 
 
7994
 
 
7995
 
        /* Sin Timeslot */
7996
 
        if ( f_pChanModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
7997
 
                f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanEntry->TdmConfig.usSinTimeslot;
7998
 
        else
7999
 
                f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanModify->TdmConfig.ulSinTimeslot;
8000
 
        
8001
 
        /* Sin Stream */
8002
 
        if ( f_pChanModify->TdmConfig.ulSinStream == cOCT6100_KEEP_PREVIOUS_SETTING )
8003
 
                f_pChanOpen->TdmConfig.ulSinStream = f_pChanEntry->TdmConfig.usSinStream;
8004
 
        else
8005
 
                f_pChanOpen->TdmConfig.ulSinStream = f_pChanModify->TdmConfig.ulSinStream;
8006
 
 
8007
 
        /* Sin Num TSSTs */
8008
 
        if ( f_pChanModify->TdmConfig.ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
8009
 
                f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanEntry->TdmConfig.bySinNumTssts;
8010
 
        else
8011
 
                f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanModify->TdmConfig.ulSinNumTssts;
8012
 
 
8013
 
 
8014
 
        /* Rout Timeslot */
8015
 
        if ( f_pChanModify->TdmConfig.ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
8016
 
                f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanEntry->TdmConfig.usRoutTimeslot;
8017
 
        else
8018
 
                f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanModify->TdmConfig.ulRoutTimeslot;
8019
 
        
8020
 
        /* Rout Stream */
8021
 
        if ( f_pChanModify->TdmConfig.ulRoutStream == cOCT6100_KEEP_PREVIOUS_SETTING )
8022
 
                f_pChanOpen->TdmConfig.ulRoutStream = f_pChanEntry->TdmConfig.usRoutStream;
8023
 
        else
8024
 
                f_pChanOpen->TdmConfig.ulRoutStream = f_pChanModify->TdmConfig.ulRoutStream;
8025
 
 
8026
 
        /* Rout Num TSSTs */
8027
 
        if ( f_pChanModify->TdmConfig.ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
8028
 
                f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanEntry->TdmConfig.byRoutNumTssts;
8029
 
        else
8030
 
                f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanModify->TdmConfig.ulRoutNumTssts;
8031
 
 
8032
 
 
8033
 
        /* Sout Timeslot */
8034
 
        if ( f_pChanModify->TdmConfig.ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
8035
 
                f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanEntry->TdmConfig.usSoutTimeslot;
8036
 
        else
8037
 
                f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanModify->TdmConfig.ulSoutTimeslot;
8038
 
        
8039
 
        /* Sout Stream */
8040
 
        if ( f_pChanModify->TdmConfig.ulSoutStream == cOCT6100_KEEP_PREVIOUS_SETTING )
8041
 
                f_pChanOpen->TdmConfig.ulSoutStream = f_pChanEntry->TdmConfig.usSoutStream;
8042
 
        else
8043
 
                f_pChanOpen->TdmConfig.ulSoutStream = f_pChanModify->TdmConfig.ulSoutStream;
8044
 
 
8045
 
        /* Sout Num TSSTs */
8046
 
        if ( f_pChanModify->TdmConfig.ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
8047
 
                f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanEntry->TdmConfig.bySoutNumTssts;
8048
 
        else
8049
 
                f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanModify->TdmConfig.ulSoutNumTssts;
8050
 
 
8051
 
        /*======================================================================*/
8052
 
        
8053
 
        /*======================================================================*/
8054
 
        /* Now update the VQE config.*/
8055
 
        
8056
 
        if ( f_pChanModify->VqeConfig.ulComfortNoiseMode == cOCT6100_KEEP_PREVIOUS_SETTING )
8057
 
                f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanEntry->VqeConfig.byComfortNoiseMode;
8058
 
        else
8059
 
                f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanModify->VqeConfig.ulComfortNoiseMode;
8060
 
 
8061
 
        if ( f_pChanModify->VqeConfig.fEnableNlp == cOCT6100_KEEP_PREVIOUS_SETTING )
8062
 
                f_pChanOpen->VqeConfig.fEnableNlp = f_pChanEntry->VqeConfig.fEnableNlp;
8063
 
        else
8064
 
                f_pChanOpen->VqeConfig.fEnableNlp = f_pChanModify->VqeConfig.fEnableNlp;
8065
 
        
8066
 
        if ( f_pChanModify->VqeConfig.fEnableTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING )
8067
 
                f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanEntry->VqeConfig.fEnableTailDisplacement;
8068
 
        else
8069
 
                f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanModify->VqeConfig.fEnableTailDisplacement;
8070
 
 
8071
 
        if ( f_pChanModify->VqeConfig.ulTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING )
8072
 
                f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanEntry->VqeConfig.usTailDisplacement;
8073
 
        else
8074
 
                f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanModify->VqeConfig.ulTailDisplacement;
8075
 
 
8076
 
        /* Tail length cannot be modifed. */
8077
 
        f_pChanOpen->VqeConfig.ulTailLength = f_pChanEntry->VqeConfig.usTailLength;
8078
 
 
8079
 
 
8080
 
        
8081
 
        if ( f_pChanModify->VqeConfig.fRinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
8082
 
                f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanEntry->VqeConfig.fRinDcOffsetRemoval;
8083
 
        else
8084
 
                f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanModify->VqeConfig.fRinDcOffsetRemoval;
8085
 
        
8086
 
 
8087
 
        if ( f_pChanModify->VqeConfig.fRinLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
8088
 
                f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanEntry->VqeConfig.fRinLevelControl;
8089
 
        else
8090
 
                f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanModify->VqeConfig.fRinLevelControl;
8091
 
 
8092
 
 
8093
 
        if ( f_pChanModify->VqeConfig.fRinAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
8094
 
                f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanEntry->VqeConfig.fRinAutomaticLevelControl;
8095
 
        else
8096
 
                f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanModify->VqeConfig.fRinAutomaticLevelControl;
8097
 
 
8098
 
 
8099
 
        if ( f_pChanModify->VqeConfig.fRinHighLevelCompensation == cOCT6100_KEEP_PREVIOUS_SETTING )
8100
 
                f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanEntry->VqeConfig.fRinHighLevelCompensation;
8101
 
        else
8102
 
                f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanModify->VqeConfig.fRinHighLevelCompensation;
8103
 
 
8104
 
 
8105
 
        if ( f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb == cOCT6100_KEEP_PREVIOUS_SETTING )
8106
 
                f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb;
8107
 
        else
8108
 
                f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb;
8109
 
 
8110
 
        
8111
 
        if ( f_pChanModify->VqeConfig.fSinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
8112
 
                f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanEntry->VqeConfig.fSinDcOffsetRemoval;
8113
 
        else
8114
 
                f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanModify->VqeConfig.fSinDcOffsetRemoval;
8115
 
        
8116
 
 
8117
 
        if ( f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
8118
 
                f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction;
8119
 
        else
8120
 
                f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction;
8121
 
 
8122
 
        
8123
 
        if ( f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
8124
 
                f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanEntry->VqeConfig.fSoutConferencingNoiseReduction;
8125
 
        else
8126
 
                f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction;
8127
 
 
8128
 
 
8129
 
        if ( f_pChanModify->VqeConfig.fSoutNoiseBleaching == cOCT6100_KEEP_PREVIOUS_SETTING )
8130
 
                f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanEntry->VqeConfig.fSoutNoiseBleaching;
8131
 
        else
8132
 
                f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanModify->VqeConfig.fSoutNoiseBleaching;
8133
 
        
8134
 
 
8135
 
        if ( f_pChanModify->VqeConfig.fSoutLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
8136
 
                f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanEntry->VqeConfig.fSoutLevelControl;
8137
 
        else
8138
 
                f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanModify->VqeConfig.fSoutLevelControl;
8139
 
 
8140
 
 
8141
 
        if ( f_pChanModify->VqeConfig.fSoutAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
8142
 
                f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanEntry->VqeConfig.fSoutAutomaticLevelControl;
8143
 
        else
8144
 
                f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanModify->VqeConfig.fSoutAutomaticLevelControl;
8145
 
        
8146
 
 
8147
 
        if ( f_pChanModify->VqeConfig.lRinLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8148
 
                f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanEntry->VqeConfig.chRinLevelControlGainDb;
8149
 
        else
8150
 
                f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanModify->VqeConfig.lRinLevelControlGainDb;
8151
 
        
8152
 
 
8153
 
        if ( f_pChanModify->VqeConfig.lSoutLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8154
 
                f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanEntry->VqeConfig.chSoutLevelControlGainDb;
8155
 
        else
8156
 
                f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanModify->VqeConfig.lSoutLevelControlGainDb;
8157
 
 
8158
 
 
8159
 
        if ( f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8160
 
                f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb;
8161
 
        else
8162
 
                f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb;
8163
 
        
8164
 
 
8165
 
        if ( f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8166
 
                f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb;
8167
 
        else
8168
 
                f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb;
8169
 
 
8170
 
 
8171
 
        if ( f_pChanModify->VqeConfig.lDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8172
 
                f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanEntry->VqeConfig.chDefaultErlDb;
8173
 
        else
8174
 
                f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanModify->VqeConfig.lDefaultErlDb;
8175
 
 
8176
 
 
8177
 
        if ( f_pChanModify->VqeConfig.lAecDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8178
 
                f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanEntry->VqeConfig.chAecDefaultErlDb;
8179
 
        else
8180
 
                f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanModify->VqeConfig.lAecDefaultErlDb;
8181
 
 
8182
 
 
8183
 
        if ( f_pChanModify->VqeConfig.ulAecTailLength == cOCT6100_KEEP_PREVIOUS_SETTING )
8184
 
                f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanEntry->VqeConfig.usAecTailLength;
8185
 
        else
8186
 
                f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanModify->VqeConfig.ulAecTailLength;
8187
 
 
8188
 
 
8189
 
        if ( f_pChanModify->VqeConfig.fAcousticEcho == cOCT6100_KEEP_PREVIOUS_SETTING )
8190
 
                f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanEntry->VqeConfig.fAcousticEcho;
8191
 
        else
8192
 
                f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanModify->VqeConfig.fAcousticEcho;
8193
 
 
8194
 
 
8195
 
        if ( f_pChanModify->VqeConfig.fDtmfToneRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
8196
 
                f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanEntry->VqeConfig.fDtmfToneRemoval;
8197
 
        else
8198
 
                f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanModify->VqeConfig.fDtmfToneRemoval;
8199
 
 
8200
 
 
8201
 
 
8202
 
 
8203
 
 
8204
 
        if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorA == cOCT6100_KEEP_PREVIOUS_SETTING )
8205
 
                f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanEntry->VqeConfig.byNonLinearityBehaviorA;
8206
 
        else
8207
 
                f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanModify->VqeConfig.ulNonLinearityBehaviorA;
8208
 
 
8209
 
 
8210
 
        if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorB == cOCT6100_KEEP_PREVIOUS_SETTING )
8211
 
                f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanEntry->VqeConfig.byNonLinearityBehaviorB;
8212
 
        else
8213
 
                f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanModify->VqeConfig.ulNonLinearityBehaviorB;
8214
 
 
8215
 
 
8216
 
        if ( f_pChanModify->VqeConfig.ulDoubleTalkBehavior == cOCT6100_KEEP_PREVIOUS_SETTING )
8217
 
                f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanEntry->VqeConfig.byDoubleTalkBehavior;
8218
 
        else
8219
 
                f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanModify->VqeConfig.ulDoubleTalkBehavior;
8220
 
 
8221
 
 
8222
 
        if ( f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
8223
 
                f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb;
8224
 
        else
8225
 
                f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb;
8226
 
 
8227
 
 
8228
 
        if ( f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
8229
 
                f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb;
8230
 
        else
8231
 
                f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb;
8232
 
 
8233
 
 
8234
 
        if ( f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement == cOCT6100_KEEP_PREVIOUS_SETTING )
8235
 
                f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement;
8236
 
        else
8237
 
                f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement;
8238
 
 
8239
 
 
8240
 
        if ( f_pChanModify->VqeConfig.fRoutNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
8241
 
                f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanEntry->VqeConfig.fRoutNoiseReduction;
8242
 
        else
8243
 
                f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanModify->VqeConfig.fRoutNoiseReduction;
8244
 
 
8245
 
 
8246
 
        if ( f_pChanModify->VqeConfig.lAnrSnrEnhancementDb == cOCT6100_KEEP_PREVIOUS_SETTING )
8247
 
                f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanEntry->VqeConfig.chAnrSnrEnhancementDb;
8248
 
        else
8249
 
                f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanModify->VqeConfig.lAnrSnrEnhancementDb;
8250
 
 
8251
 
 
8252
 
        if ( f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation == cOCT6100_KEEP_PREVIOUS_SETTING )
8253
 
                f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation;
8254
 
        else
8255
 
                f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation;
8256
 
 
8257
 
 
8258
 
        if ( f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay == cOCT6100_KEEP_PREVIOUS_SETTING )
8259
 
                f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay;
8260
 
        else
8261
 
                f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay;
8262
 
 
8263
 
 
8264
 
        if ( f_pChanModify->VqeConfig.fEnableMusicProtection == cOCT6100_KEEP_PREVIOUS_SETTING )
8265
 
                f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanEntry->VqeConfig.fEnableMusicProtection;
8266
 
        else
8267
 
                f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanModify->VqeConfig.fEnableMusicProtection;
8268
 
 
8269
 
 
8270
 
        if ( f_pChanModify->VqeConfig.fIdleCodeDetection == cOCT6100_KEEP_PREVIOUS_SETTING )
8271
 
                f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanEntry->VqeConfig.fIdleCodeDetection;
8272
 
        else
8273
 
                f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanModify->VqeConfig.fIdleCodeDetection;
8274
 
 
8275
 
        /*======================================================================*/
8276
 
 
8277
 
 
8278
 
        /*======================================================================*/
8279
 
        /* Finaly the codec config.*/
8280
 
 
8281
 
        if ( f_pChanModify->CodecConfig.ulDecoderPort == cOCT6100_KEEP_PREVIOUS_SETTING )
8282
 
                f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanEntry->CodecConfig.byDecoderPort;
8283
 
        else
8284
 
                f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanModify->CodecConfig.ulDecoderPort;
8285
 
        
8286
 
 
8287
 
        if ( f_pChanModify->CodecConfig.ulDecodingRate == cOCT6100_KEEP_PREVIOUS_SETTING )
8288
 
                f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanEntry->CodecConfig.byDecodingRate;
8289
 
        else
8290
 
                f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanModify->CodecConfig.ulDecodingRate;
8291
 
        
8292
 
 
8293
 
        if ( f_pChanModify->CodecConfig.ulEncoderPort == cOCT6100_KEEP_PREVIOUS_SETTING )
8294
 
                f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanEntry->CodecConfig.byEncoderPort;
8295
 
        else
8296
 
                f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanModify->CodecConfig.ulEncoderPort;
8297
 
        
8298
 
 
8299
 
        if ( f_pChanModify->CodecConfig.ulEncodingRate == cOCT6100_KEEP_PREVIOUS_SETTING )
8300
 
                f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanEntry->CodecConfig.byEncodingRate;
8301
 
        else
8302
 
                f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanModify->CodecConfig.ulEncodingRate;
8303
 
 
8304
 
        if ( f_pChanModify->CodecConfig.fEnableSilenceSuppression == cOCT6100_KEEP_PREVIOUS_SETTING )
8305
 
                f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanEntry->CodecConfig.fEnableSilenceSuppression;
8306
 
        else
8307
 
                f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanModify->CodecConfig.fEnableSilenceSuppression;
8308
 
 
8309
 
        if ( f_pChanModify->CodecConfig.ulPhasingType == cOCT6100_KEEP_PREVIOUS_SETTING )
8310
 
                f_pChanOpen->CodecConfig.ulPhasingType = f_pChanEntry->CodecConfig.byPhasingType;
8311
 
        else
8312
 
                f_pChanOpen->CodecConfig.ulPhasingType = f_pChanModify->CodecConfig.ulPhasingType;
8313
 
 
8314
 
        if ( f_pChanModify->CodecConfig.ulPhase == cOCT6100_KEEP_PREVIOUS_SETTING )
8315
 
                f_pChanOpen->CodecConfig.ulPhase = f_pChanEntry->CodecConfig.byPhase;
8316
 
        else
8317
 
                f_pChanOpen->CodecConfig.ulPhase = f_pChanModify->CodecConfig.ulPhase;
8318
 
        
8319
 
        if ( f_pChanModify->CodecConfig.ulPhasingTsstHndl == cOCT6100_KEEP_PREVIOUS_SETTING )
8320
 
        {
8321
 
                if ( f_pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
8322
 
                {
8323
 
                        tPOCT6100_API_PHASING_TSST      pPhasingEntry;
8324
 
 
8325
 
                        mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanEntry->usPhasingTsstIndex );
8326
 
 
8327
 
                        /* Now recreate the Phasing TSST handle.*/
8328
 
                        f_pChanOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_HNDL_TAG_PHASING_TSST | (pPhasingEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_pChanEntry->usPhasingTsstIndex;
8329
 
                }
8330
 
                else
8331
 
                {
8332
 
                        f_pChanOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
8333
 
                }
8334
 
        }
8335
 
        else
8336
 
        {
8337
 
                f_pChanOpen->CodecConfig.ulPhasingTsstHndl              = f_pChanModify->CodecConfig.ulPhasingTsstHndl;
8338
 
        }
8339
 
        
8340
 
        f_pChanOpen->CodecConfig.ulAdpcmNibblePosition  = f_pChanEntry->CodecConfig.byAdpcmNibblePosition;
8341
 
        /*======================================================================*/
8342
 
 
8343
 
        return cOCT6100_ERR_OK;
8344
 
}
8345
 
 
8346
 
static UINT16 Oct6100ApiDbAmpHalfToOctFloat(INT32 x)
8347
 
{
8348
 
        INT32 db_div6;
8349
 
        INT32 db_mod6;
8350
 
        UINT16 rval;
8351
 
        INT32 x_unsigned;
8352
 
 
8353
 
        if(x < 0)
8354
 
        {
8355
 
                x_unsigned = -x;
8356
 
        }
8357
 
        else
8358
 
        {
8359
 
                x_unsigned = x;
8360
 
        }
8361
 
 
8362
 
        db_div6 = x_unsigned / 6;
8363
 
        db_mod6 = x_unsigned % 6;
8364
 
 
8365
 
        if(x < 0)
8366
 
        {
8367
 
                if(db_mod6 == 0)
8368
 
                {
8369
 
                        /* Change nothing! */
8370
 
                        db_div6 = -db_div6;
8371
 
                }
8372
 
                else
8373
 
                {
8374
 
                        /* When we are negative, round down, and then adjust modulo. For example, if
8375
 
                         x is -1, then db_div6 is 0 and db_mod6 is 1. We adjust so db_div6 = -1 and
8376
 
                         db_mod6 = 5, which gives the correct adjustment. */
8377
 
                        db_div6 = -db_div6-1;
8378
 
                        db_mod6 = 6 - db_mod6;
8379
 
                }
8380
 
        }
8381
 
 
8382
 
        rval = (UINT16)(0x4100 + db_div6 * 0x100);
8383
 
 
8384
 
        if(db_mod6 == 0)
8385
 
        {
8386
 
                rval += 0x0000;
8387
 
        }
8388
 
        else if(db_mod6 == 1)
8389
 
        {
8390
 
                rval += 0x0020;
8391
 
        }               
8392
 
        else if(db_mod6 == 2)
8393
 
        {
8394
 
                rval += 0x0040;
8395
 
        }               
8396
 
        else if(db_mod6 == 3)
8397
 
        {
8398
 
                rval += 0x0070;
8399
 
        }               
8400
 
        else if(db_mod6 == 4)
8401
 
        {
8402
 
                rval += 0x0090;
8403
 
        }               
8404
 
        else /* if(db_mod6 == 5) */
8405
 
        {
8406
 
                rval += 0x00D0;
8407
 
        }
8408
 
 
8409
 
        return rval;
8410
 
}
8411
 
 
8412
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8413
 
 
8414
 
Function:               Oct6100ApiWriteDebugChanMemory
8415
 
 
8416
 
Description:    This function configure a debug channel echo memory entry 
8417
 
                                in internal memory.and external memory.
8418
 
 
8419
 
-------------------------------------------------------------------------------
8420
 
|       Argument                |       Description
8421
 
-------------------------------------------------------------------------------
8422
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
8423
 
                                                the present state of the chip and all its resources.
8424
 
 
8425
 
f_pTdmConfig                    Pointer to a TDM configuration structure.
8426
 
f_pVqeConfig                    Pointer to a VQE configuration structure.
8427
 
f_pChannelOpen                  Pointer to a channel configuration structure.
8428
 
f_usChanIndex                   Index of the echo channel in the API instance.
8429
 
f_usEchoMemIndex                Index of the echo channel within the SSPX memory.
8430
 
f_usRinRoutTsiIndex             RIN/ROUT TSI index within the TSI chariot memory.
8431
 
f_usSinSoutTsiIndex             SIN/SOUT TSI index within the TSI chariot memory.
8432
 
 
8433
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8434
 
static UINT32 Oct6100ApiWriteDebugChanMemory( 
8435
 
                                IN      tPOCT6100_INSTANCE_API                  f_pApiInstance,
8436
 
                                IN      tPOCT6100_CHANNEL_OPEN_TDM              f_pTdmConfig,
8437
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE              f_pVqeConfig,
8438
 
                                IN      tPOCT6100_CHANNEL_OPEN                  f_pChannelOpen,
8439
 
                                IN      UINT16                                                  f_usChanIndex,
8440
 
                                IN      UINT16                                                  f_usEchoMemIndex,
8441
 
                                IN      UINT16                                                  f_usRinRoutTsiIndex,
8442
 
                                IN      UINT16                                                  f_usSinSoutTsiIndex )
8443
 
{
8444
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
8445
 
        UINT32                                  ulResult;
8446
 
 
8447
 
        /* Obtain pointer to local portion of the instance. */
8448
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
8449
 
 
8450
 
        /*==============================================================================*/
8451
 
        /* Write the VQE configuration of the debug channel. */
8452
 
 
8453
 
        ulResult = Oct6100ApiWriteVqeMemory( 
8454
 
                                                                                f_pApiInstance, 
8455
 
                                                                                f_pVqeConfig, 
8456
 
                                                                                f_pChannelOpen, 
8457
 
                                                                                f_usChanIndex,
8458
 
                                                                                f_usEchoMemIndex,
8459
 
                                                                                TRUE, 
8460
 
                                                                                FALSE );
8461
 
        if ( ulResult != cOCT6100_ERR_OK )
8462
 
                return ulResult;        
8463
 
 
8464
 
        /*==============================================================================*/
8465
 
 
8466
 
 
8467
 
        /*==============================================================================*/
8468
 
 
8469
 
        /* Write the echo memory configuration of the debug channel. */
8470
 
        ulResult = Oct6100ApiWriteEchoMemory(
8471
 
                                                                                f_pApiInstance,
8472
 
                                                                                f_pTdmConfig,
8473
 
                                                                                f_pChannelOpen,
8474
 
                                                                                f_usEchoMemIndex,
8475
 
                                                                                f_usRinRoutTsiIndex,
8476
 
                                                                                f_usSinSoutTsiIndex );
8477
 
        if ( ulResult != cOCT6100_ERR_OK )
8478
 
                return ulResult;        
8479
 
 
8480
 
        /*==============================================================================*/
8481
 
 
8482
 
        return cOCT6100_ERR_OK;
8483
 
}
8484
 
 
8485
 
 
8486
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8487
 
 
8488
 
Function:               Oct6100ApiDebugChannelOpen
8489
 
 
8490
 
Description:    Internal function used to open a debug channel.
8491
 
 
8492
 
-------------------------------------------------------------------------------
8493
 
|       Argument                |       Description
8494
 
-------------------------------------------------------------------------------
8495
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
8496
 
                                                        the present state of the chip and all its resources.
8497
 
 
8498
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8499
 
static UINT32   Oct6100ApiDebugChannelOpen( 
8500
 
                                        IN      tPOCT6100_INSTANCE_API f_pApiInstance )
8501
 
{
8502
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
8503
 
        tOCT6100_CHANNEL_OPEN           TempChanOpen;
8504
 
        
8505
 
        UINT32  ulResult;
8506
 
        UINT16  usChanIndex;
8507
 
        UINT16  usDummyEchoIndex;
8508
 
 
8509
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
8510
 
 
8511
 
        /* Let's program the channel memory.*/
8512
 
        Oct6100ChannelOpenDef( &TempChanOpen );
8513
 
        
8514
 
        TempChanOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_HT_RESET;      /* Activate the channel in reset.*/
8515
 
        TempChanOpen.VqeConfig.fEnableNlp = FALSE;
8516
 
        TempChanOpen.VqeConfig.ulComfortNoiseMode = cOCT6100_COMFORT_NOISE_NORMAL;
8517
 
        TempChanOpen.VqeConfig.fSinDcOffsetRemoval = FALSE;
8518
 
        TempChanOpen.VqeConfig.fRinDcOffsetRemoval = FALSE;
8519
 
        TempChanOpen.VqeConfig.lDefaultErlDb = 0;
8520
 
        
8521
 
        /* Loop to reserve the proper entry for the debug channel */
8522
 
        for( usChanIndex = 0; usChanIndex < ( pSharedInfo->DebugInfo.usRecordChanIndex + 1 ); usChanIndex ++ )
8523
 
        {
8524
 
                ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, &usDummyEchoIndex );
8525
 
                if( ulResult != cOCT6100_ERR_OK )
8526
 
                        return ulResult;
8527
 
        }
8528
 
 
8529
 
        /* Loop to free all entries except the one for the debug channel */
8530
 
        for( usChanIndex = pSharedInfo->DebugInfo.usRecordChanIndex; usChanIndex > 0; ) 
8531
 
        {
8532
 
                usChanIndex--;
8533
 
                ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, usChanIndex );
8534
 
                if( ulResult != cOCT6100_ERR_OK )
8535
 
                        return ulResult;
8536
 
        }
8537
 
 
8538
 
        ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance,
8539
 
                                                                                  &TempChanOpen.TdmConfig,
8540
 
                                                                                  &TempChanOpen.VqeConfig,
8541
 
                                                                                  &TempChanOpen,
8542
 
                                                                                  pSharedInfo->DebugInfo.usRecordChanIndex,
8543
 
                                                                                  pSharedInfo->DebugInfo.usRecordMemIndex,
8544
 
                                                                                  pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex,
8545
 
                                                                                  pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex );
8546
 
        if ( ulResult != cOCT6100_ERR_OK )
8547
 
                return ulResult;
8548
 
 
8549
 
        return cOCT6100_ERR_OK;
8550
 
}
8551
 
 
8552
 
 
8553
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8554
 
 
8555
 
Function:               Oct6100ApiMuteChannelPort
8556
 
 
8557
 
Description:    This function will verify if a input TSST is bound to the RIN and
8558
 
                                SIN port. If not, the port will be muted.
8559
 
 
8560
 
-------------------------------------------------------------------------------
8561
 
|       Argument                |       Description
8562
 
-------------------------------------------------------------------------------
8563
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep
8564
 
                                                        the present state of the chip and all its resources.
8565
 
 
8566
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8567
 
static UINT32   Oct6100ApiMutePorts( 
8568
 
                                        IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
8569
 
                                        IN      UINT16                                          f_usEchoIndex,
8570
 
                                        IN      UINT16                                          f_usRinTsstIndex,
8571
 
                                        IN      UINT16                                          f_usSinTsstIndex,
8572
 
                                        IN      BOOL                                            f_fCheckBridgeIndex )
8573
 
{
8574
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
8575
 
        tPOCT6100_API_CHANNEL           pChanEntry;
8576
 
        tOCT6100_WRITE_PARAMS           WriteParams;
8577
 
        UINT32                                          ulResult;
8578
 
 
8579
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
8580
 
 
8581
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8582
 
 
8583
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
8584
 
 
8585
 
        /* Obtain a pointer to the new buffer's list entry. */
8586
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usEchoIndex );
8587
 
 
8588
 
        /* Mute the Rin port. */
8589
 
        if ( ( f_fCheckBridgeIndex == FALSE ) 
8590
 
                || ( ( f_fCheckBridgeIndex == TRUE ) && ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX ) ) )
8591
 
        {
8592
 
                /* If the channel is in bidir mode, do not create the Rin silence event!!! */
8593
 
                if ( pChanEntry->fBiDirChannel == FALSE )
8594
 
                {
8595
 
                        if ( ( ( f_usRinTsstIndex == cOCT6100_INVALID_INDEX ) || ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) ) 
8596
 
                                && ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) ) 
8597
 
                        {
8598
 
                                ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, 
8599
 
                                                                                                                         &pChanEntry->usRinSilenceEventIndex );
8600
 
                                if ( ulResult != cOCT6100_ERR_OK )
8601
 
                                        return ulResult;
8602
 
 
8603
 
                                /* Now, write the mixer event used to copy the RIN signal of the silence channel
8604
 
                                   into the RIN signal of the current channel. */
8605
 
 
8606
 
                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usRinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
8607
 
                                
8608
 
                                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
8609
 
                                WriteParams.usWriteData |= 1534;
8610
 
                                WriteParams.usWriteData |= cOCT6100_PCM_U_LAW << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
8611
 
 
8612
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8613
 
                                if ( ulResult != cOCT6100_ERR_OK )
8614
 
                                        return ulResult;
8615
 
 
8616
 
                                WriteParams.ulWriteAddress += 2;
8617
 
                                WriteParams.usWriteData = pChanEntry->usRinRoutTsiMemIndex;
8618
 
 
8619
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8620
 
                                if ( ulResult != cOCT6100_ERR_OK  )
8621
 
                                        return ulResult;
8622
 
 
8623
 
                                /*=======================================================================*/
8624
 
 
8625
 
 
8626
 
                                /*=======================================================================*/
8627
 
                                /* Now insert the Sin copy event into the list.*/
8628
 
 
8629
 
                                ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
8630
 
                                                                                                        pChanEntry->usRinSilenceEventIndex,
8631
 
                                                                                                        cOCT6100_EVENT_TYPE_SOUT_COPY,
8632
 
                                                                                                        f_usEchoIndex );
8633
 
                                if ( ulResult != cOCT6100_ERR_OK )
8634
 
                                        return ulResult;
8635
 
                        }
8636
 
                }
8637
 
        }
8638
 
 
8639
 
        /* Mute the Sin port. */
8640
 
        if ( ( ( f_usSinTsstIndex == cOCT6100_INVALID_INDEX ) || ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) 
8641
 
                && ( pChanEntry->usSinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
8642
 
        {
8643
 
                ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance, 
8644
 
                                                                                                         &pChanEntry->usSinSilenceEventIndex );
8645
 
                if ( ulResult != cOCT6100_ERR_OK )
8646
 
                        return ulResult;
8647
 
 
8648
 
                /* Now, write the mixer event used to copy the SIN signal of the silence channel
8649
 
                   into the SIN signal of the current channel. */
8650
 
 
8651
 
                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
8652
 
                
8653
 
                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_COPY;
8654
 
                WriteParams.usWriteData |= 1534;
8655
 
                WriteParams.usWriteData |= cOCT6100_PCM_U_LAW << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET;
8656
 
 
8657
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8658
 
                if ( ulResult != cOCT6100_ERR_OK )
8659
 
                        return ulResult;
8660
 
 
8661
 
                WriteParams.ulWriteAddress += 2;
8662
 
                WriteParams.usWriteData = pChanEntry->usSinSoutTsiMemIndex;
8663
 
 
8664
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8665
 
                if ( ulResult != cOCT6100_ERR_OK  )
8666
 
                        return ulResult;
8667
 
 
8668
 
                /*=======================================================================*/
8669
 
 
8670
 
 
8671
 
                /*=======================================================================*/
8672
 
                /* Now insert the Sin copy event into the list.*/
8673
 
 
8674
 
                ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
8675
 
                                                                                        pChanEntry->usSinSilenceEventIndex,
8676
 
                                                                                        cOCT6100_EVENT_TYPE_SOUT_COPY,
8677
 
                                                                                        f_usEchoIndex );
8678
 
                if ( ulResult != cOCT6100_ERR_OK )
8679
 
                        return ulResult;
8680
 
        }
8681
 
 
8682
 
        /* Unmute the Rin port if it was muted. */
8683
 
        if ( ( ( f_usRinTsstIndex != cOCT6100_INVALID_INDEX ) && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) == 0x0 ) ) 
8684
 
                && ( pChanEntry->usRinSilenceEventIndex != cOCT6100_INVALID_INDEX ) )
8685
 
        {
8686
 
                /* Remove the event from the list.*/
8687
 
                ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
8688
 
                                                                                                pChanEntry->usRinSilenceEventIndex,
8689
 
                                                                                                cOCT6100_EVENT_TYPE_SOUT_COPY );
8690
 
                if ( ulResult != cOCT6100_ERR_OK )
8691
 
                        return ulResult;
8692
 
 
8693
 
                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usRinSilenceEventIndex );
8694
 
                if ( ulResult != cOCT6100_ERR_OK  )
8695
 
                        return cOCT6100_ERR_FATAL_E1;
8696
 
 
8697
 
                pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
8698
 
        }
8699
 
 
8700
 
        /* Unmute the Sin port if it was muted. */
8701
 
        if ( ( ( f_usSinTsstIndex != cOCT6100_INVALID_INDEX ) && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) == 0x0 ) )
8702
 
                && ( pChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX ) )
8703
 
        {
8704
 
                /* Remove the event from the list.*/
8705
 
                ulResult = Oct6100ApiMixerEventRemove(  f_pApiInstance,
8706
 
                                                                                                pChanEntry->usSinSilenceEventIndex,
8707
 
                                                                                                cOCT6100_EVENT_TYPE_SOUT_COPY );
8708
 
                if ( ulResult != cOCT6100_ERR_OK )
8709
 
                        return ulResult;
8710
 
 
8711
 
                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usSinSilenceEventIndex );
8712
 
                if ( ulResult != cOCT6100_ERR_OK  )
8713
 
                        return cOCT6100_ERR_FATAL_E2;
8714
 
 
8715
 
                pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
8716
 
        }
8717
 
 
8718
 
        return cOCT6100_ERR_OK;
8719
 
}
8720
 
 
8721
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8722
 
 
8723
 
Function:               Oct6100ApiSetChannelLevelControl
8724
 
 
8725
 
Description:    This function will configure the level control on a given
8726
 
                                channel.
8727
 
 
8728
 
-------------------------------------------------------------------------------
8729
 
|       Argument                |       Description
8730
 
-------------------------------------------------------------------------------
8731
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
8732
 
                                                the present state of the chip and all its resources.
8733
 
 
8734
 
f_pVqeConfig                    VQE config of the channel.
8735
 
f_usChanIndex                   Index of the channel within the API instance.
8736
 
f_usEchoMemIndex                Index of the echo channel within the SSPX memory.
8737
 
f_fClearAlcHlcStatusBit If this is set, the ALC-HLC status bit must be
8738
 
                                                incremented.
8739
 
 
8740
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8741
 
static UINT32 Oct6100ApiSetChannelLevelControl(
8742
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
8743
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE      f_pVqeConfig,
8744
 
                                IN      UINT16                                          f_usChanIndex,
8745
 
                                IN      UINT16                                          f_usEchoMemIndex,
8746
 
                                IN      BOOL                                            f_fClearAlcHlcStatusBit )
8747
 
{
8748
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
8749
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
8750
 
        UINT32                                                  ulResult;
8751
 
        UINT32                                                  ulTempData;
8752
 
        UINT32                                                  ulBaseAddress;
8753
 
        UINT32                                                  ulFeatureBytesOffset;
8754
 
        UINT32                                                  ulFeatureBitOffset;
8755
 
        UINT32                                                  ulFeatureFieldLength;
8756
 
        UINT32                                                  ulMask;
8757
 
        UINT32                                                  i;
8758
 
        UINT16                                                  usTempData;
8759
 
        UINT8                                                   byLastStatus;
8760
 
        BOOL                                                    fDisableAlcFirst;
8761
 
        
8762
 
        /* Get local pointer to shared portion of the API instance. */
8763
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
8764
 
 
8765
 
        /* Obtain a pointer to the channel list entry. */
8766
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
8767
 
 
8768
 
        /* Before doing anything, check if the configuration has changed. */
8769
 
        if ( ( f_fClearAlcHlcStatusBit == TRUE )
8770
 
                || ( f_pVqeConfig->fRinLevelControl != pChanEntry->VqeConfig.fRinLevelControl ) 
8771
 
                || ( f_pVqeConfig->lRinLevelControlGainDb != pChanEntry->VqeConfig.chRinLevelControlGainDb ) 
8772
 
                || ( f_pVqeConfig->fRinAutomaticLevelControl != pChanEntry->VqeConfig.fRinAutomaticLevelControl ) 
8773
 
                || ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb != pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb ) 
8774
 
                || ( f_pVqeConfig->fRinHighLevelCompensation != pChanEntry->VqeConfig.fRinHighLevelCompensation ) 
8775
 
                || ( f_pVqeConfig->lRinHighLevelCompensationThresholdDb != pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb ) 
8776
 
                || ( f_pVqeConfig->fSoutLevelControl != pChanEntry->VqeConfig.fSoutLevelControl ) 
8777
 
                || ( f_pVqeConfig->lSoutLevelControlGainDb != pChanEntry->VqeConfig.chSoutLevelControlGainDb ) 
8778
 
                || ( f_pVqeConfig->fSoutAutomaticLevelControl != pChanEntry->VqeConfig.fSoutAutomaticLevelControl ) 
8779
 
                || ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb != pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb ) 
8780
 
                || ( f_pVqeConfig->fSoutNaturalListenerEnhancement != pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement ) 
8781
 
                || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb )
8782
 
                || ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb != pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb ) )
8783
 
        {
8784
 
                /* Calculate base address for manual level control configuration. */
8785
 
                ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
8786
 
 
8787
 
                /* Set the Level control on RIN port.*/
8788
 
                ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinLevelControlOfst.usDwordOffset * 4;
8789
 
                ulFeatureBitOffset       = pSharedInfo->MemoryMap.RinLevelControlOfst.byBitOffset;
8790
 
                ulFeatureFieldLength = pSharedInfo->MemoryMap.RinLevelControlOfst.byFieldSize;
8791
 
 
8792
 
                /* First read the DWORD where the field is located.*/
8793
 
                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
8794
 
                                                                                        pChanEntry,
8795
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
8796
 
                                                                                        &ulTempData,
8797
 
                                                                                        ulResult );
8798
 
                if ( ulResult != cOCT6100_ERR_OK )
8799
 
                        return ulResult;
8800
 
 
8801
 
                /* Clear previous value set in the feature field.*/
8802
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8803
 
 
8804
 
                ulTempData &= (~ulMask);
8805
 
 
8806
 
                if ( ( f_pVqeConfig->fRinLevelControl == TRUE ) 
8807
 
                        || ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) 
8808
 
                        || ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) )
8809
 
                {
8810
 
                        /* Set the level control value.*/
8811
 
                        if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) 
8812
 
                                || ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) )
8813
 
                                ulTempData |= ( 0xFF << ulFeatureBitOffset );
8814
 
                        else 
8815
 
                        {
8816
 
                                /* Convert the dB value into OctFloat format.*/
8817
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lRinLevelControlGainDb );
8818
 
                                usTempData -= 0x3800;
8819
 
                                usTempData &= 0x0FF0;
8820
 
                                usTempData >>= 4;
8821
 
 
8822
 
                                ulTempData |= ( usTempData << ulFeatureBitOffset ); 
8823
 
                        }
8824
 
                }
8825
 
                else /* ( ( f_pVqeConfig->fRinLevelControl == FALSE ) && ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) && ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) ) */
8826
 
                {
8827
 
                        ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
8828
 
                }
8829
 
 
8830
 
                /* Save the DWORD where the field is located.*/
8831
 
                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
8832
 
                                                                                pChanEntry,
8833
 
                                                                                ulBaseAddress + ulFeatureBytesOffset,
8834
 
                                                                                ulTempData,
8835
 
                                                                                ulResult );
8836
 
                if ( ulResult != cOCT6100_ERR_OK )
8837
 
                        return ulResult;        
8838
 
 
8839
 
                /* Set the Level control on SOUT port.*/
8840
 
                ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutLevelControlOfst.usDwordOffset * 4;
8841
 
                ulFeatureBitOffset       = pSharedInfo->MemoryMap.SoutLevelControlOfst.byBitOffset;
8842
 
                ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutLevelControlOfst.byFieldSize;
8843
 
 
8844
 
                /* First read the DWORD where the field is located.*/
8845
 
                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
8846
 
                                                                                        pChanEntry,
8847
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
8848
 
                                                                                        &ulTempData,
8849
 
                                                                                        ulResult );
8850
 
                if ( ulResult != cOCT6100_ERR_OK )
8851
 
                        return ulResult;
8852
 
 
8853
 
                /* Clear previous value set in the feature field.*/
8854
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8855
 
 
8856
 
                ulTempData &= (~ulMask);
8857
 
 
8858
 
                if ( ( f_pVqeConfig->fSoutLevelControl == TRUE ) 
8859
 
                        || ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
8860
 
                        || ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
8861
 
                        || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0x0 ) )
8862
 
                {
8863
 
                        /* Set the level control value.*/
8864
 
                        if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) 
8865
 
                                || ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE ) 
8866
 
                                || ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0x0 ) )
8867
 
                                ulTempData |= ( 0xFF << ulFeatureBitOffset );
8868
 
                        else 
8869
 
                        {
8870
 
                                /* Convert the dB value into OctFloat format.*/
8871
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lSoutLevelControlGainDb );
8872
 
                                usTempData -= 0x3800;
8873
 
                                usTempData &= 0x0FF0;
8874
 
                                usTempData >>= 4;
8875
 
 
8876
 
                                ulTempData |= ( usTempData << ulFeatureBitOffset ); 
8877
 
                        }
8878
 
                }
8879
 
                else
8880
 
                {
8881
 
                        ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
8882
 
                }
8883
 
 
8884
 
                /* Save the DWORD where the field is located.*/
8885
 
                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
8886
 
                                                                                pChanEntry,
8887
 
                                                                                ulBaseAddress + ulFeatureBytesOffset,
8888
 
                                                                                ulTempData,
8889
 
                                                                                ulResult );
8890
 
                if ( ulResult != cOCT6100_ERR_OK )
8891
 
                        return ulResult;        
8892
 
                
8893
 
                /* Calculate base address for auto level control + high level compensation configuration. */
8894
 
                ulBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
8895
 
 
8896
 
                /* Check which one is to be disabled first. */
8897
 
                if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
8898
 
                        fDisableAlcFirst = FALSE;
8899
 
                else
8900
 
                        fDisableAlcFirst = TRUE;
8901
 
 
8902
 
                for ( i = 0; i < 2; i ++ )
8903
 
                {
8904
 
                        /* Set the auto level control target Db for the Rin port. */
8905
 
                        if ( ( ( i == 0 ) && ( fDisableAlcFirst == TRUE ) ) || ( ( i == 1 ) && ( fDisableAlcFirst == FALSE ) ) )
8906
 
                        {
8907
 
                                if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE )
8908
 
                                {
8909
 
                                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.usDwordOffset * 4;
8910
 
                                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byBitOffset;
8911
 
                                        ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byFieldSize;
8912
 
 
8913
 
                                        /* First read the DWORD where the field is located.*/
8914
 
                                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
8915
 
                                                                                                                pChanEntry,
8916
 
                                                                                                                ulBaseAddress + ulFeatureBytesOffset,
8917
 
                                                                                                                &ulTempData,
8918
 
                                                                                                                ulResult );
8919
 
                                        if ( ulResult != cOCT6100_ERR_OK )
8920
 
                                                return ulResult;
8921
 
 
8922
 
                                        /* Clear previous value set in the feature field.*/
8923
 
                                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8924
 
 
8925
 
                                        ulTempData &= (~ulMask);
8926
 
 
8927
 
                                        if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
8928
 
                                        {
8929
 
                                                /* Convert the dB value into OctFloat format.*/
8930
 
                                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinAutomaticLevelControlTargetDb );
8931
 
 
8932
 
                                                /* Set auto level control target on the Rin port. */
8933
 
                                                ulTempData |= ( usTempData << ulFeatureBitOffset ); 
8934
 
                                        }
8935
 
                                        else /* if ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) */
8936
 
                                        {
8937
 
                                                /* Disable auto level control. */
8938
 
                                                ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); 
8939
 
                                        }
8940
 
 
8941
 
                                        /* Save the DWORD where the field is located.*/
8942
 
                                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
8943
 
                                                                                                        pChanEntry,
8944
 
                                                                                                        ulBaseAddress + ulFeatureBytesOffset,
8945
 
                                                                                                        ulTempData,
8946
 
                                                                                                        ulResult );
8947
 
                                        if ( ulResult != cOCT6100_ERR_OK )
8948
 
                                                return ulResult;        
8949
 
                                }
8950
 
                        }
8951
 
                        else
8952
 
                        {
8953
 
                                /* Set the high level compensation threshold Db for the Rin port. */
8954
 
                                if ( pSharedInfo->ImageInfo.fRinHighLevelCompensation == TRUE )
8955
 
                                {
8956
 
                                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.usDwordOffset * 4;
8957
 
                                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byBitOffset;
8958
 
                                        ulFeatureFieldLength = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byFieldSize;
8959
 
 
8960
 
                                        /* First read the DWORD where the field is located.*/
8961
 
                                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
8962
 
                                                                                                                pChanEntry,
8963
 
                                                                                                                ulBaseAddress + ulFeatureBytesOffset,
8964
 
                                                                                                                &ulTempData,
8965
 
                                                                                                                ulResult );
8966
 
                                        if ( ulResult != cOCT6100_ERR_OK )
8967
 
                                                return ulResult;
8968
 
 
8969
 
                                        /* Clear previous value set in the feature field.*/
8970
 
                                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8971
 
 
8972
 
                                        ulTempData &= (~ulMask);
8973
 
 
8974
 
                                        if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
8975
 
                                        {
8976
 
                                                /* Convert the dB value into OctFloat format.*/
8977
 
                                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinHighLevelCompensationThresholdDb );
8978
 
 
8979
 
                                                /* Set high level compensation threshold on the Rin port. */
8980
 
                                                ulTempData |= ( usTempData << ulFeatureBitOffset ); 
8981
 
                                        }
8982
 
                                        else /* if ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) */
8983
 
                                        {
8984
 
                                                /* Disable high level compensation. */
8985
 
                                                ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); 
8986
 
                                        }
8987
 
 
8988
 
                                        /* Save the DWORD where the field is located.*/
8989
 
                                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
8990
 
                                                                                                        pChanEntry,
8991
 
                                                                                                        ulBaseAddress + ulFeatureBytesOffset,
8992
 
                                                                                                        ulTempData,
8993
 
                                                                                                        ulResult );
8994
 
                                        if ( ulResult != cOCT6100_ERR_OK )
8995
 
                                                return ulResult;        
8996
 
                                }
8997
 
                        }
8998
 
                }
8999
 
 
9000
 
                /* Set the auto level control target Db for the Sout port. */
9001
 
                if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE )
9002
 
                {
9003
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.usDwordOffset * 4;
9004
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byBitOffset;
9005
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byFieldSize;
9006
 
 
9007
 
                        /* First read the DWORD where the field is located.*/
9008
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9009
 
                                                                                                pChanEntry,
9010
 
                                                                                                ulBaseAddress + ulFeatureBytesOffset,
9011
 
                                                                                                &ulTempData,
9012
 
                                                                                                ulResult );
9013
 
                        if ( ulResult != cOCT6100_ERR_OK )
9014
 
                                return ulResult;
9015
 
 
9016
 
                        /* Clear previous value set in the feature field.*/
9017
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9018
 
 
9019
 
                        ulTempData &= (~ulMask);
9020
 
 
9021
 
                        if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
9022
 
                        {
9023
 
                                /* Convert the dB value into OctFloat format.*/
9024
 
                                usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lSoutAutomaticLevelControlTargetDb );
9025
 
 
9026
 
                                /* Set auto level control target on the Sout port. */
9027
 
                                ulTempData |= ( usTempData << ulFeatureBitOffset ); 
9028
 
                        }
9029
 
                        else /* if ( f_pVqeConfig->fSoutAutomaticLevelControl == FALSE ) */
9030
 
                        {
9031
 
                                /* Disable auto level control. */
9032
 
                                ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); 
9033
 
                        }
9034
 
 
9035
 
                        /* Save the DWORD where the field is located.*/
9036
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9037
 
                                                                                        pChanEntry,
9038
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
9039
 
                                                                                        ulTempData,
9040
 
                                                                                        ulResult );
9041
 
                        if ( ulResult != cOCT6100_ERR_OK )
9042
 
                                return ulResult;        
9043
 
                }
9044
 
 
9045
 
                /* Set the high level compensation threshold Db for the Sout port. */
9046
 
                if ( pSharedInfo->ImageInfo.fSoutHighLevelCompensation == TRUE )
9047
 
                {
9048
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.usDwordOffset * 4;
9049
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byBitOffset;
9050
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byFieldSize;
9051
 
 
9052
 
                        /* First read the DWORD where the field is located.*/
9053
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9054
 
                                                                                                pChanEntry,
9055
 
                                                                                                ulBaseAddress + ulFeatureBytesOffset,
9056
 
                                                                                                &ulTempData,
9057
 
                                                                                                ulResult );
9058
 
                        if ( ulResult != cOCT6100_ERR_OK )
9059
 
                                return ulResult;
9060
 
 
9061
 
                        /* Clear previous value set in the feature field.*/
9062
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9063
 
 
9064
 
                        ulTempData &= (~ulMask);
9065
 
 
9066
 
                        /* Disable high level compensation on Sout for now. */
9067
 
                        ulTempData |= ( 0xFFFF << ulFeatureBitOffset ); 
9068
 
 
9069
 
                        /* Save the DWORD where the field is located.*/
9070
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9071
 
                                                                                        pChanEntry,
9072
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
9073
 
                                                                                        ulTempData,
9074
 
                                                                                        ulResult );
9075
 
                        if ( ulResult != cOCT6100_ERR_OK )
9076
 
                                return ulResult;        
9077
 
                }
9078
 
 
9079
 
                /* Check if have to clear the ALC-HLC status. */
9080
 
                if ( ( pSharedInfo->ImageInfo.fAlcHlcStatus == TRUE ) 
9081
 
                        && ( f_fClearAlcHlcStatusBit == TRUE ) )
9082
 
                {
9083
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.usDwordOffset * 4;
9084
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byBitOffset;
9085
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byFieldSize;
9086
 
 
9087
 
                        /* First read the DWORD where the field is located.*/
9088
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9089
 
                                                                                                pChanEntry,
9090
 
                                                                                                ulBaseAddress + ulFeatureBytesOffset,
9091
 
                                                                                                &ulTempData,
9092
 
                                                                                                ulResult );
9093
 
                        if ( ulResult != cOCT6100_ERR_OK )
9094
 
                                return ulResult;
9095
 
 
9096
 
                        /* Get previous value set in the feature field.*/
9097
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9098
 
 
9099
 
                        /* Retrieve last status. */
9100
 
                        byLastStatus = (UINT8)( ( ( ulTempData & ulMask ) >> ulFeatureBitOffset ) & 0xFF );
9101
 
 
9102
 
                        /* Increment to reset context. */
9103
 
                        byLastStatus ++;
9104
 
 
9105
 
                        /* Just in case, not to overwrite some context in external memory. */
9106
 
                        byLastStatus &= ( 0x1 << ulFeatureFieldLength ) - 1;
9107
 
 
9108
 
                        /* Clear last status. */
9109
 
                        ulTempData &= (~ulMask);
9110
 
 
9111
 
                        /* Set new status. */
9112
 
                        ulTempData |= ( byLastStatus << ulFeatureBitOffset ); 
9113
 
 
9114
 
                        /* Save the DWORD where the field is located.*/
9115
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9116
 
                                                                                        pChanEntry,
9117
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
9118
 
                                                                                        ulTempData,
9119
 
                                                                                        ulResult );
9120
 
                        if ( ulResult != cOCT6100_ERR_OK )
9121
 
                                return ulResult;                        
9122
 
                }
9123
 
        }
9124
 
 
9125
 
        return cOCT6100_ERR_OK;
9126
 
}
9127
 
 
9128
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9129
 
 
9130
 
Function:               Oct6100ApiSetChannelTailConfiguration
9131
 
 
9132
 
Description:    This function will configure the tail displacement and length
9133
 
                                on a given channel.
9134
 
 
9135
 
-------------------------------------------------------------------------------
9136
 
|       Argument                |       Description
9137
 
-------------------------------------------------------------------------------
9138
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
9139
 
                                                the present state of the chip and all its resources.
9140
 
 
9141
 
f_pVqeConfig                    VQE config of the channel.
9142
 
f_usChanIndex                   Index of the channel within the API instance.
9143
 
f_usEchoMemIndex                Index of the echo channel within the SSPX memory.
9144
 
f_fModifyOnly                   Function called from a modify or open?  
9145
 
 
9146
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9147
 
static UINT32 Oct6100ApiSetChannelTailConfiguration(
9148
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
9149
 
                                IN      tPOCT6100_CHANNEL_OPEN_VQE      f_pVqeConfig,
9150
 
                                IN      UINT16                                          f_usChanIndex,
9151
 
                                IN      UINT16                                          f_usEchoMemIndex,
9152
 
                                IN      BOOL                                            f_fModifyOnly )
9153
 
{
9154
 
        tPOCT6100_API_CHANNEL   pChanEntry;
9155
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
9156
 
        UINT32                                  ulResult;
9157
 
        UINT32                                  ulTempData;
9158
 
        UINT32                                  ulNlpConfBaseAddress;
9159
 
        UINT32                                  ulAfConfBaseAddress;
9160
 
        UINT32                                  ulFeatureBytesOffset;
9161
 
        UINT32                                  ulFeatureBitOffset;
9162
 
        UINT32                                  ulFeatureFieldLength;
9163
 
        UINT32                                  ulMask;
9164
 
        UINT32                                  ulTailSum;
9165
 
        BOOL                                    fTailDisplacementModified = FALSE;
9166
 
        
9167
 
        /* Get local pointer to shared portion of the API instance. */
9168
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
9169
 
 
9170
 
        /* Obtain a pointer to the channel list entry. */
9171
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
9172
 
 
9173
 
        /* Calculate base addresses of NLP + AF configuration structure for the specified channel. */
9174
 
        ulNlpConfBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
9175
 
        ulAfConfBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
9176
 
 
9177
 
        /* Set the tail displacement.*/
9178
 
        if ( pSharedInfo->ImageInfo.fTailDisplacement == TRUE )
9179
 
        {
9180
 
                /* Check if the configuration has been changed. */
9181
 
                if ( ( f_fModifyOnly == FALSE )
9182
 
                        || ( ( f_fModifyOnly == TRUE ) 
9183
 
                                && ( ( f_pVqeConfig->fEnableTailDisplacement != pChanEntry->VqeConfig.fEnableTailDisplacement ) 
9184
 
                                        || ( f_pVqeConfig->ulTailDisplacement != pChanEntry->VqeConfig.usTailDisplacement ) 
9185
 
                                        || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
9186
 
                {
9187
 
                        /* Remember that the tail displacement parameters were changed. */
9188
 
                        fTailDisplacementModified = TRUE;
9189
 
 
9190
 
                        /* Check if we must set the tail displacement value. */
9191
 
                        if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE ) 
9192
 
                                && ( pSharedInfo->ImageInfo.fPerChannelTailDisplacement == TRUE ) )
9193
 
                        {
9194
 
                                ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.usDwordOffset * 4;
9195
 
                                ulFeatureBitOffset       = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byBitOffset;
9196
 
                                ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byFieldSize;
9197
 
 
9198
 
                                /* First read the DWORD where the field is located.*/
9199
 
                                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9200
 
                                                                                                        pChanEntry,
9201
 
                                                                                                        ulNlpConfBaseAddress + ulFeatureBytesOffset,
9202
 
                                                                                                        &ulTempData,
9203
 
                                                                                                        ulResult );
9204
 
                                if ( ulResult != cOCT6100_ERR_OK )
9205
 
                                        return ulResult;
9206
 
 
9207
 
                                /* Clear previous value set in the feature field.*/
9208
 
                                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9209
 
 
9210
 
                                ulTempData &= (~ulMask);
9211
 
                                if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE ) 
9212
 
                                        && ( f_pVqeConfig->ulTailDisplacement != 0x0 ) )
9213
 
                                {
9214
 
                                        if ( pSharedInfo->ImageInfo.fAfTailDisplacement == FALSE )
9215
 
                                        {
9216
 
                                                if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
9217
 
                                                {
9218
 
                                                        ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset );
9219
 
                                                }
9220
 
                                                else
9221
 
                                                {
9222
 
                                                        ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset );
9223
 
                                                }
9224
 
                                        }
9225
 
                                        else /* if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE ) */
9226
 
                                        {
9227
 
                                                /* If AEC is not activated, this must be set to the requested tail displacement. */
9228
 
                                                if ( f_pVqeConfig->fAcousticEcho == FALSE )
9229
 
                                                {
9230
 
                                                        if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
9231
 
                                                        {
9232
 
                                                                ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement;
9233
 
                                                        }
9234
 
                                                        else
9235
 
                                                        {
9236
 
                                                                ulTailSum = f_pVqeConfig->ulTailDisplacement;
9237
 
                                                        }
9238
 
                                                        
9239
 
                                                        if ( ulTailSum == 0 )
9240
 
                                                        {
9241
 
                                                                ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
9242
 
                                                        }
9243
 
                                                        else if ( ulTailSum <= 128 )
9244
 
                                                        {
9245
 
                                                                ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
9246
 
                                                        }
9247
 
                                                        else if ( ulTailSum <= 384 )
9248
 
                                                        {
9249
 
                                                                ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
9250
 
                                                        }
9251
 
                                                        else /* if ( ulTailSum <= 896 ) */
9252
 
                                                        {
9253
 
                                                                ulTempData |= ( ( 7 ) << ulFeatureBitOffset );
9254
 
                                                        }
9255
 
                                                }
9256
 
                                                else /* if ( f_pVqeConfig->fAcousticEcho == FALSE ) */
9257
 
                                                {
9258
 
                                                        /* Otherwise, the tail displacement is configured differently.  This field stays to 0. */
9259
 
                                                        ulTempData |= ( 0x0 << ulFeatureBitOffset );
9260
 
                                                }
9261
 
                                        }
9262
 
                                }
9263
 
 
9264
 
                                /* Then save the new DWORD where the field is located.*/
9265
 
                                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9266
 
                                                                                                pChanEntry,
9267
 
                                                                                                ulNlpConfBaseAddress + ulFeatureBytesOffset,
9268
 
                                                                                                ulTempData,
9269
 
                                                                                                ulResult );
9270
 
                                if ( ulResult != cOCT6100_ERR_OK )
9271
 
                                        return ulResult;        
9272
 
                        }
9273
 
 
9274
 
                        if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE )
9275
 
                        {
9276
 
                                /* Set the tail displacement offset in the AF. */
9277
 
                                ulFeatureBytesOffset = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.usDwordOffset * 4;
9278
 
                                ulFeatureBitOffset       = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.byBitOffset;
9279
 
                                ulFeatureFieldLength = pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst.byFieldSize;
9280
 
 
9281
 
                                /* First read the DWORD where the field is located.*/
9282
 
                                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9283
 
                                                                                                        pChanEntry,
9284
 
                                                                                                        ulAfConfBaseAddress + ulFeatureBytesOffset,
9285
 
                                                                                                        &ulTempData,
9286
 
                                                                                                        ulResult );
9287
 
                                if ( ulResult != cOCT6100_ERR_OK )
9288
 
                                        return ulResult;
9289
 
 
9290
 
                                /* Clear previous value set in the feature field.*/
9291
 
                                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9292
 
 
9293
 
                                ulTempData &= (~ulMask);
9294
 
 
9295
 
                                if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
9296
 
                                {
9297
 
                                        ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset );
9298
 
                                }
9299
 
                                else
9300
 
                                {
9301
 
                                        ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset );
9302
 
                                }
9303
 
 
9304
 
                                /* Then save the DWORD where the field is located.*/
9305
 
                                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9306
 
                                                                                                pChanEntry,
9307
 
                                                                                                ulAfConfBaseAddress + ulFeatureBytesOffset,
9308
 
                                                                                                ulTempData,
9309
 
                                                                                                ulResult );
9310
 
                                if ( ulResult != cOCT6100_ERR_OK )
9311
 
                                        return ulResult;
9312
 
                        }
9313
 
 
9314
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.TailDisplEnableOfst.usDwordOffset * 4;
9315
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.TailDisplEnableOfst.byBitOffset;
9316
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.TailDisplEnableOfst.byFieldSize;
9317
 
 
9318
 
                        /* First read the DWORD where the field is located.*/
9319
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9320
 
                                                                                                pChanEntry,
9321
 
                                                                                                ulNlpConfBaseAddress + ulFeatureBytesOffset,
9322
 
                                                                                                &ulTempData,
9323
 
                                                                                                ulResult );
9324
 
                        if ( ulResult != cOCT6100_ERR_OK )
9325
 
                                return ulResult;
9326
 
 
9327
 
                        /* Clear previous value set in the feature field.*/
9328
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9329
 
 
9330
 
                        ulTempData &= (~ulMask);
9331
 
                        ulTempData |= ( ( (UINT32)f_pVqeConfig->fEnableTailDisplacement ) << ulFeatureBitOffset );
9332
 
 
9333
 
                        /* Then save the DWORD where the field is located.*/
9334
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9335
 
                                                                                        pChanEntry,
9336
 
                                                                                        ulNlpConfBaseAddress + ulFeatureBytesOffset,
9337
 
                                                                                        ulTempData,
9338
 
                                                                                        ulResult );
9339
 
                        if ( ulResult != cOCT6100_ERR_OK )
9340
 
                                return ulResult;        
9341
 
                }
9342
 
        }
9343
 
 
9344
 
        /* Set the tail length. */
9345
 
        if ( pSharedInfo->ImageInfo.fPerChannelTailLength == TRUE )
9346
 
        {
9347
 
                /* Check if the configuration has been changed. */
9348
 
                if ( ( f_fModifyOnly == FALSE )
9349
 
                        || ( ( f_fModifyOnly == TRUE ) 
9350
 
                                && ( f_pVqeConfig->ulTailLength != pChanEntry->VqeConfig.usTailLength ) ) )
9351
 
                {
9352
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.usDwordOffset * 4;
9353
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byBitOffset;
9354
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byFieldSize;
9355
 
 
9356
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9357
 
                                                                                                pChanEntry,
9358
 
                                                                                                ulAfConfBaseAddress + ulFeatureBytesOffset,
9359
 
                                                                                                &ulTempData, 
9360
 
                                                                                                ulResult );
9361
 
                        if ( ulResult != cOCT6100_ERR_OK )
9362
 
                                return ulResult;
9363
 
 
9364
 
                        /* Clear previous value set in the feature field.*/
9365
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9366
 
 
9367
 
                        ulTempData &= (~ulMask);
9368
 
                        /* Check if must automatically select maximum or if must use user specific value. */
9369
 
                        if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
9370
 
                        {
9371
 
                                ulTempData |= ( ( ( pSharedInfo->ImageInfo.usMaxTailLength - 32 ) / 4 )  << ulFeatureBitOffset );
9372
 
                        }
9373
 
                        else
9374
 
                        {
9375
 
                                ulTempData |= ( ( ( f_pVqeConfig->ulTailLength - 32 ) / 4 )  << ulFeatureBitOffset );
9376
 
                        }
9377
 
 
9378
 
                        /* Then save the DWORD where the field is located.*/
9379
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9380
 
                                                                                        pChanEntry,
9381
 
                                                                                        ulAfConfBaseAddress + ulFeatureBytesOffset,
9382
 
                                                                                        ulTempData,
9383
 
                                                                                        ulResult );
9384
 
                        if ( ulResult != cOCT6100_ERR_OK )
9385
 
                                return ulResult;        
9386
 
                }
9387
 
        }
9388
 
 
9389
 
        /* Configure AEC tail length. */
9390
 
        if ( pSharedInfo->ImageInfo.fAecTailLength == TRUE )
9391
 
        {
9392
 
                /* Check if the configuration has been changed. */
9393
 
                if ( ( f_fModifyOnly == FALSE )
9394
 
                        || ( fTailDisplacementModified == TRUE )
9395
 
                        || ( ( f_fModifyOnly == TRUE ) 
9396
 
                                && ( ( f_pVqeConfig->ulAecTailLength != pChanEntry->VqeConfig.usAecTailLength ) 
9397
 
                                || ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) ) )
9398
 
                {
9399
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.usDwordOffset * 4;
9400
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byBitOffset;
9401
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byFieldSize;
9402
 
 
9403
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9404
 
                                                                                                pChanEntry,
9405
 
                                                                                                ulNlpConfBaseAddress + ulFeatureBytesOffset,
9406
 
                                                                                                &ulTempData,
9407
 
                                                                                                ulResult );
9408
 
                        if ( ulResult != cOCT6100_ERR_OK )
9409
 
                                return ulResult;
9410
 
                        
9411
 
                        /* Clear previous value set in the feature field.*/
9412
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9413
 
 
9414
 
                        ulTempData &= (~ulMask);
9415
 
 
9416
 
                        /* Set acoustic echo tail length. */
9417
 
                        if ( f_pVqeConfig->fAcousticEcho == TRUE )
9418
 
                        {
9419
 
                                switch( f_pVqeConfig->ulAecTailLength )
9420
 
                                {
9421
 
                                case 1024:
9422
 
                                        ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
9423
 
                                        break;
9424
 
                                case 512:
9425
 
                                        ulTempData |= ( ( 2 ) << ulFeatureBitOffset );
9426
 
                                        break;
9427
 
                                case 256:
9428
 
                                        ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
9429
 
                                        break;
9430
 
                                case 128:
9431
 
                                default:
9432
 
                                        ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
9433
 
                                        break;
9434
 
                                }
9435
 
                        }
9436
 
                        else if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
9437
 
                        {
9438
 
                                /* No acoustic echo case. */
9439
 
 
9440
 
                                /* Start with requested tail displacement. */
9441
 
                                if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
9442
 
                                {
9443
 
                                        ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement;
9444
 
                                }
9445
 
                                else
9446
 
                                {
9447
 
                                        ulTailSum = f_pVqeConfig->ulTailDisplacement;
9448
 
                                }
9449
 
 
9450
 
                                /* Add requested tail length. */
9451
 
                                if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
9452
 
                                {
9453
 
                                        ulTailSum += pSharedInfo->ImageInfo.usMaxTailLength;
9454
 
                                }
9455
 
                                else
9456
 
                                {
9457
 
                                        ulTailSum += f_pVqeConfig->ulTailLength;
9458
 
                                }
9459
 
 
9460
 
                                /* Round this value up. */
9461
 
                                if ( ulTailSum <= 128 )
9462
 
                                {
9463
 
                                        ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
9464
 
                                }
9465
 
                                else if ( ulTailSum <= 256 )
9466
 
                                {
9467
 
                                        ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
9468
 
                                }
9469
 
                                else if ( ulTailSum <= 512 )
9470
 
                                {
9471
 
                                        ulTempData |= ( ( 2 ) << ulFeatureBitOffset );
9472
 
                                }
9473
 
                                else /* if ( ulTailSum <= 1024 ) */
9474
 
                                {
9475
 
                                        ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
9476
 
                                }
9477
 
                        }
9478
 
                        else
9479
 
                        {
9480
 
                                /* Keep this to zero. */
9481
 
                                ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
9482
 
                        }
9483
 
                        
9484
 
                        /* Write the new DWORD where the field is located. */
9485
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9486
 
                                                                                        pChanEntry,
9487
 
                                                                                        ulNlpConfBaseAddress + ulFeatureBytesOffset,
9488
 
                                                                                        ulTempData,
9489
 
                                                                                        ulResult );
9490
 
                        if ( ulResult != cOCT6100_ERR_OK )
9491
 
                                return ulResult;        
9492
 
                }
9493
 
        }
9494
 
 
9495
 
        return cOCT6100_ERR_OK;
9496
 
}
9497
 
 
9498
 
#if 0 /* unused functions */
9499
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9500
 
 
9501
 
Function:               Oct6100ChannelMuteSer
9502
 
 
9503
 
Description:    This function will mute some of the ports on a given
9504
 
                                channel.
9505
 
 
9506
 
-------------------------------------------------------------------------------
9507
 
|       Argument                |       Description
9508
 
-------------------------------------------------------------------------------
9509
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
9510
 
                                                the present state of the chip and all its resources.
9511
 
 
9512
 
f_pChannelMute                  What channel/ports to mute.
9513
 
 
9514
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9515
 
static UINT32 Oct6100ChannelMuteSer(
9516
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
9517
 
                                IN      tPOCT6100_CHANNEL_MUTE          f_pChannelMute )
9518
 
{
9519
 
        UINT32  ulResult;
9520
 
        UINT16  usChanIndex;
9521
 
        UINT16  usPortMask;
9522
 
 
9523
 
        /* Verify that all the parameters given match the state of the API. */
9524
 
        ulResult = Oct6100ApiAssertChannelMuteParams(   f_pApiInstance, 
9525
 
                                                                                                        f_pChannelMute, 
9526
 
                                                                                                        &usChanIndex,
9527
 
                                                                                                        &usPortMask );
9528
 
        if ( ulResult != cOCT6100_ERR_OK )
9529
 
                return ulResult;
9530
 
 
9531
 
        /* Call the actual channel mute ports function. */
9532
 
        ulResult = Oct6100ApiMuteChannelPorts(  f_pApiInstance, 
9533
 
                                                                                        usChanIndex,
9534
 
                                                                                        usPortMask,
9535
 
                                                                                        TRUE );
9536
 
        if ( ulResult != cOCT6100_ERR_OK )
9537
 
                return ulResult;
9538
 
 
9539
 
        return cOCT6100_ERR_OK;
9540
 
}
9541
 
 
9542
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9543
 
 
9544
 
Function:               Oct6100ApiAssertChannelMuteParams
9545
 
 
9546
 
Description:    Check the user parameters passed to the channel mute function.
9547
 
 
9548
 
-------------------------------------------------------------------------------
9549
 
|       Argument                |       Description
9550
 
-------------------------------------------------------------------------------
9551
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
9552
 
                                                the present state of the chip and all its resources.
9553
 
 
9554
 
f_pChannelMute                  What channel/ports to mute.
9555
 
f_pusChanIndex                  Resulting channel index where the muting should
9556
 
                                                be applied.
9557
 
f_pusPorts                              Port mask on which to apply the muting.
9558
 
 
9559
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9560
 
static UINT32 Oct6100ApiAssertChannelMuteParams(        
9561
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance, 
9562
 
                                IN      tPOCT6100_CHANNEL_MUTE          f_pChannelMute, 
9563
 
                                OUT PUINT16                                             f_pusChanIndex,
9564
 
                                OUT PUINT16                                             f_pusPorts )
9565
 
{
9566
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
9567
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
9568
 
        UINT32                                                  ulEntryOpenCnt;
9569
 
 
9570
 
        /* Get local pointer(s). */
9571
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
9572
 
 
9573
 
        /* Check the provided handle. */
9574
 
        if ( (f_pChannelMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
9575
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
9576
 
 
9577
 
        *f_pusChanIndex = (UINT16)( f_pChannelMute->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
9578
 
        if ( *f_pusChanIndex  >= pSharedInfo->ChipConfig.usMaxChannels )
9579
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
9580
 
 
9581
 
        /*=======================================================================*/
9582
 
        /* Get a pointer to the channel's list entry. */
9583
 
 
9584
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex  )
9585
 
 
9586
 
        /* Extract the entry open count from the provided handle. */
9587
 
        ulEntryOpenCnt = ( f_pChannelMute->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
9588
 
 
9589
 
        /* Check for errors. */
9590
 
        if ( pChanEntry->fReserved != TRUE )
9591
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
9592
 
        if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
9593
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
9594
 
        if ( pChanEntry->fBiDirChannel == TRUE )
9595
 
                return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL;
9596
 
 
9597
 
        /*=======================================================================*/
9598
 
 
9599
 
        /* Check the provided port mask. */
9600
 
 
9601
 
        if ( ( f_pChannelMute->ulPortMask &
9602
 
                ~(      cOCT6100_CHANNEL_MUTE_PORT_NONE | 
9603
 
                        cOCT6100_CHANNEL_MUTE_PORT_RIN |
9604
 
                        cOCT6100_CHANNEL_MUTE_PORT_ROUT |
9605
 
                        cOCT6100_CHANNEL_MUTE_PORT_SIN | 
9606
 
                        cOCT6100_CHANNEL_MUTE_PORT_SOUT |
9607
 
                        cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) ) != 0 )
9608
 
                return cOCT6100_ERR_CHANNEL_MUTE_MASK;
9609
 
 
9610
 
        /* Sin + Sin with features cannot be muted simultaneously. */
9611
 
        if ( ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
9612
 
                && ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) )
9613
 
                return cOCT6100_ERR_CHANNEL_MUTE_MASK_SIN;
9614
 
 
9615
 
        /* Check if Sin mute with features is supported by the firmware. */
9616
 
        if ( ( ( f_pChannelMute->ulPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
9617
 
                && ( pSharedInfo->ImageInfo.fSinMute == FALSE ) )
9618
 
                return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_MUTE_FEATURES;
9619
 
 
9620
 
        /* Return the ports to the calling function. */
9621
 
        *f_pusPorts = (UINT16)( f_pChannelMute->ulPortMask & 0xFFFF );
9622
 
 
9623
 
        return cOCT6100_ERR_OK;
9624
 
}
9625
 
 
9626
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9627
 
 
9628
 
Function:               Oct6100ChannelUnMuteSer
9629
 
 
9630
 
Description:    This function will unmute some of the ports on a given
9631
 
                                channel.
9632
 
 
9633
 
-------------------------------------------------------------------------------
9634
 
|       Argument                |       Description
9635
 
-------------------------------------------------------------------------------
9636
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
9637
 
                                                the present state of the chip and all its resources.
9638
 
 
9639
 
f_pChannelUnMute                What channel/ports to unmute.
9640
 
 
9641
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9642
 
static UINT32 Oct6100ChannelUnMuteSer(
9643
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
9644
 
                                IN      tPOCT6100_CHANNEL_UNMUTE        f_pChannelUnMute )
9645
 
{
9646
 
        UINT32  ulResult;
9647
 
        UINT16  usChanIndex;
9648
 
        UINT16  usPortMask;
9649
 
 
9650
 
        /* Verify that all the parameters given match the state of the API. */
9651
 
        ulResult = Oct6100ApiAssertChannelUnMuteParams( f_pApiInstance, 
9652
 
                                                                                                        f_pChannelUnMute, 
9653
 
                                                                                                        &usChanIndex,
9654
 
                                                                                                        &usPortMask );
9655
 
        if ( ulResult != cOCT6100_ERR_OK )
9656
 
                return ulResult;
9657
 
 
9658
 
        /* Call the actual channel mute ports function. */
9659
 
        ulResult = Oct6100ApiMuteChannelPorts(  f_pApiInstance, 
9660
 
                                                                                        usChanIndex,
9661
 
                                                                                        usPortMask,
9662
 
                                                                                        FALSE );
9663
 
        if ( ulResult != cOCT6100_ERR_OK )
9664
 
                return ulResult;
9665
 
 
9666
 
        return cOCT6100_ERR_OK;
9667
 
}
9668
 
 
9669
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9670
 
 
9671
 
Function:               Oct6100ApiAssertChannelUnMuteParams
9672
 
 
9673
 
Description:    Check the user parameters passed to the channel unmute function.
9674
 
 
9675
 
-------------------------------------------------------------------------------
9676
 
|       Argument                |       Description
9677
 
-------------------------------------------------------------------------------
9678
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
9679
 
                                                the present state of the chip and all its resources.
9680
 
 
9681
 
f_pChannelUnMute                What channel/ports to Unmute.
9682
 
f_pusChanIndex                  Resulting channel index where the muting should
9683
 
                                                be applied.
9684
 
f_pusPorts                              Port mask on which to apply the muting.
9685
 
 
9686
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9687
 
static UINT32 Oct6100ApiAssertChannelUnMuteParams(      
9688
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance, 
9689
 
                                IN      tPOCT6100_CHANNEL_UNMUTE        f_pChannelUnMute, 
9690
 
                                OUT PUINT16                                             f_pusChanIndex,
9691
 
                                OUT PUINT16                                             f_pusPorts )
9692
 
{
9693
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
9694
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
9695
 
        UINT32                                                  ulEntryOpenCnt;
9696
 
 
9697
 
        /* Get local pointer(s). */
9698
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
9699
 
 
9700
 
        /* Check the provided handle. */
9701
 
        if ( (f_pChannelUnMute->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
9702
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
9703
 
 
9704
 
        *f_pusChanIndex = (UINT16)( f_pChannelUnMute->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
9705
 
        if ( *f_pusChanIndex  >= pSharedInfo->ChipConfig.usMaxChannels )
9706
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
9707
 
 
9708
 
        /*=======================================================================*/
9709
 
        /* Get a pointer to the channel's list entry. */
9710
 
 
9711
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex  )
9712
 
 
9713
 
        /* Extract the entry open count from the provided handle. */
9714
 
        ulEntryOpenCnt = ( f_pChannelUnMute->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
9715
 
 
9716
 
        /* Check for errors. */
9717
 
        if ( pChanEntry->fReserved != TRUE )
9718
 
                return cOCT6100_ERR_CHANNEL_NOT_OPEN;
9719
 
        if ( ulEntryOpenCnt != pChanEntry->byEntryOpenCnt )
9720
 
                return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
9721
 
        if ( pChanEntry->fBiDirChannel == TRUE )
9722
 
                return cOCT6100_ERR_CHANNEL_PART_OF_BIDIR_CHANNEL;
9723
 
 
9724
 
        /*=======================================================================*/
9725
 
 
9726
 
        /* Check the provided port mask. */
9727
 
 
9728
 
        if ( ( f_pChannelUnMute->ulPortMask &
9729
 
                ~(      cOCT6100_CHANNEL_MUTE_PORT_NONE | 
9730
 
                        cOCT6100_CHANNEL_MUTE_PORT_RIN |
9731
 
                        cOCT6100_CHANNEL_MUTE_PORT_ROUT |
9732
 
                        cOCT6100_CHANNEL_MUTE_PORT_SIN | 
9733
 
                        cOCT6100_CHANNEL_MUTE_PORT_SOUT |
9734
 
                        cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) ) != 0 )
9735
 
                return cOCT6100_ERR_CHANNEL_MUTE_MASK;
9736
 
        
9737
 
        /* Return the ports to the calling function. */
9738
 
        *f_pusPorts = (UINT16)( f_pChannelUnMute->ulPortMask & 0xFFFF );
9739
 
 
9740
 
        return cOCT6100_ERR_OK;
9741
 
}
9742
 
 
9743
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9744
 
 
9745
 
Function:               Oct6100ApiMuteChannelPorts
9746
 
 
9747
 
Description:    Mute or Unmute the specified ports, according to the mask.
9748
 
 
9749
 
-------------------------------------------------------------------------------
9750
 
|       Argument                |       Description
9751
 
-------------------------------------------------------------------------------
9752
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
9753
 
                                                the present state of the chip and all its resources.
9754
 
 
9755
 
f_usChanIndex                   Resulting channel index where the muting should
9756
 
                                                be applied.
9757
 
f_usPortMask                    Port mask on which to apply the muting/unmuting.
9758
 
 
9759
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9760
 
static UINT32 Oct6100ApiMuteChannelPorts(       
9761
 
                                IN      tPOCT6100_INSTANCE_API          f_pApiInstance,
9762
 
                                IN      UINT16                                          f_usChanIndex,
9763
 
                                IN      UINT16                                          f_usPortMask,
9764
 
                                IN      BOOL                                            f_fMute )
9765
 
{
9766
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
9767
 
        tPOCT6100_API_CHANNEL                   pChanEntry;
9768
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
9769
 
        UINT32                                                  ulResult;
9770
 
 
9771
 
        UINT32                                                  ulTempData;
9772
 
        UINT32                                                  ulBaseAddress;
9773
 
        UINT32                                                  ulFeatureBytesOffset;
9774
 
        UINT32                                                  ulFeatureBitOffset;
9775
 
        UINT32                                                  ulFeatureFieldLength;
9776
 
        UINT32                                                  ulMask;
9777
 
        BOOL                                                    fDisableSinWithFeatures = FALSE;
9778
 
        BOOL                                                    fEnableSinWithFeatures = FALSE;
9779
 
        
9780
 
        /* Get local pointer(s). */
9781
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
9782
 
 
9783
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
9784
 
 
9785
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
9786
 
 
9787
 
        /* Get a pointer to the channel's list entry. */
9788
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex  )
9789
 
 
9790
 
        /* Rin port. */
9791
 
        if ( ( f_fMute == TRUE )
9792
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 )
9793
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) == 0x0 ) )
9794
 
        {
9795
 
                /* Mute this port. */
9796
 
                pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_RIN;
9797
 
 
9798
 
                ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
9799
 
                if ( ulResult != cOCT6100_ERR_OK )
9800
 
                {
9801
 
                        pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN;
9802
 
                        return ulResult;
9803
 
                }
9804
 
        }
9805
 
        else if ( ( f_fMute == FALSE ) 
9806
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 )
9807
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) )
9808
 
        {
9809
 
                /* Unmute this port. */
9810
 
                pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN;
9811
 
 
9812
 
                ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
9813
 
                if ( ulResult != cOCT6100_ERR_OK )
9814
 
                        return ulResult;
9815
 
        }
9816
 
 
9817
 
        /* Rout port. */
9818
 
        if ( ( f_fMute == TRUE )
9819
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 )
9820
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 ) )
9821
 
        {
9822
 
                /* Mute this port. */
9823
 
 
9824
 
                if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
9825
 
                {
9826
 
                        /* Deactivate the TSST entry.*/
9827
 
                        WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usRoutTsstIndex  * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
9828
 
                        WriteParams.usWriteData  = 0x0000;
9829
 
 
9830
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
9831
 
                        if ( ulResult != cOCT6100_ERR_OK )
9832
 
                                return ulResult;
9833
 
                }
9834
 
 
9835
 
                pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_ROUT;
9836
 
        }
9837
 
        else if ( ( f_fMute == FALSE ) 
9838
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 )
9839
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 ) )
9840
 
        {
9841
 
                /* Unmute this port. */
9842
 
 
9843
 
                if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
9844
 
                {
9845
 
                        ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
9846
 
                                                                                                                           pChanEntry->usRoutTsstIndex,
9847
 
                                                                                                                           pChanEntry->CodecConfig.byAdpcmNibblePosition,
9848
 
                                                                                                                           pChanEntry->TdmConfig.byRoutNumTssts,
9849
 
                                                                                                                           pChanEntry->usRinRoutTsiMemIndex );
9850
 
                        if ( ulResult != cOCT6100_ERR_OK )
9851
 
                                return ulResult;
9852
 
                }
9853
 
 
9854
 
                pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_ROUT;
9855
 
        }
9856
 
 
9857
 
        /* Sin port. */
9858
 
        if ( ( f_fMute == TRUE )
9859
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
9860
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) == 0x0 ) )
9861
 
        {
9862
 
                /* Mute this port. */
9863
 
                pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN;
9864
 
 
9865
 
                ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
9866
 
                if ( ulResult != cOCT6100_ERR_OK )
9867
 
                {
9868
 
                        pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN;
9869
 
                        return ulResult;
9870
 
                }
9871
 
        }
9872
 
        else if ( 
9873
 
                        ( ( f_fMute == FALSE ) 
9874
 
                        && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
9875
 
                        && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) 
9876
 
                || 
9877
 
                        ( ( f_fMute == TRUE )  
9878
 
                        && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) 
9879
 
                        && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) )
9880
 
        {
9881
 
                /* Unmute this port. */
9882
 
                pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN;
9883
 
 
9884
 
                ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
9885
 
                if ( ulResult != cOCT6100_ERR_OK )
9886
 
                        return ulResult;
9887
 
        }
9888
 
 
9889
 
        /* Sout port. */
9890
 
        if ( ( f_fMute == TRUE )
9891
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 )
9892
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 ) )
9893
 
        {
9894
 
                /* Mute this port. */
9895
 
 
9896
 
                if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
9897
 
                {
9898
 
                        /* Deactivate the TSST entry.*/
9899
 
                        WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( pChanEntry->usSoutTsstIndex  * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
9900
 
                        WriteParams.usWriteData  = 0x0000;
9901
 
 
9902
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
9903
 
                        if ( ulResult != cOCT6100_ERR_OK  )
9904
 
                                return ulResult;
9905
 
                }
9906
 
 
9907
 
                pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SOUT;
9908
 
        }
9909
 
        else if ( ( f_fMute == FALSE ) 
9910
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 )
9911
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 ) )
9912
 
        {
9913
 
                /* Unmute this port. */
9914
 
 
9915
 
                if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
9916
 
                {
9917
 
                        ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
9918
 
                                                                                                                           pChanEntry->usSoutTsstIndex,
9919
 
                                                                                                                           pChanEntry->CodecConfig.byAdpcmNibblePosition,
9920
 
                                                                                                                           pChanEntry->TdmConfig.bySoutNumTssts,
9921
 
                                                                                                                           pChanEntry->usSinSoutTsiMemIndex );
9922
 
                        if ( ulResult != cOCT6100_ERR_OK )
9923
 
                                return ulResult;
9924
 
                }
9925
 
 
9926
 
                pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SOUT;
9927
 
        }
9928
 
 
9929
 
        /* Sin with features port. */
9930
 
        if ( ( f_fMute == TRUE )
9931
 
                && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
9932
 
                && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) == 0x0 ) )
9933
 
        {
9934
 
                /* Mute this port. */
9935
 
                pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES;
9936
 
                fEnableSinWithFeatures = TRUE;
9937
 
        }
9938
 
        else if ( 
9939
 
                        ( ( f_fMute == FALSE ) 
9940
 
                        && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
9941
 
                        && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) )
9942
 
                || 
9943
 
                        ( ( f_fMute == TRUE )  
9944
 
                        && ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) 
9945
 
                        && ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) ) )
9946
 
        {
9947
 
                /* Unmute this port. */
9948
 
                pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES;
9949
 
 
9950
 
                fDisableSinWithFeatures = TRUE;
9951
 
        }
9952
 
 
9953
 
        /* Check if must enable or disable SIN mute with features. */
9954
 
        if ( fDisableSinWithFeatures == TRUE || fEnableSinWithFeatures == TRUE )
9955
 
        {
9956
 
                ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
9957
 
                
9958
 
                if ( pSharedInfo->ImageInfo.fSinMute == TRUE )
9959
 
                {
9960
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinMuteOfst.usDwordOffset * 4;
9961
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.SinMuteOfst.byBitOffset;
9962
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.SinMuteOfst.byFieldSize;
9963
 
 
9964
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
9965
 
                                                                                                pChanEntry,
9966
 
                                                                                                ulBaseAddress + ulFeatureBytesOffset,
9967
 
                                                                                                &ulTempData,
9968
 
                                                                                                ulResult );
9969
 
                        if ( ulResult != cOCT6100_ERR_OK )
9970
 
                                return ulResult;        
9971
 
                        
9972
 
                        /* Clear previous value set in the feature field.*/
9973
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9974
 
 
9975
 
                        /* Clear the mute flag. */
9976
 
                        ulTempData &= (~ulMask);
9977
 
 
9978
 
                        /* Set the mute flag on the Sin port.*/
9979
 
                        if ( fEnableSinWithFeatures == TRUE )
9980
 
                                ulTempData |= ( 0x1 << ulFeatureBitOffset );
9981
 
 
9982
 
                        /* Write the new DWORD where the field is located. */
9983
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
9984
 
                                                                                        pChanEntry,
9985
 
                                                                                        ulBaseAddress + ulFeatureBytesOffset,
9986
 
                                                                                        ulTempData,
9987
 
                                                                                        ulResult );
9988
 
                        if ( ulResult != cOCT6100_ERR_OK )
9989
 
                                return ulResult;        
9990
 
                }
9991
 
        }
9992
 
 
9993
 
        return cOCT6100_ERR_OK;
9994
 
}
9995
 
#endif
9996
 
 
9997
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9998
 
 
9999
 
File: oct6100_chip_open.c
10000
 
 
10001
 
    Copyright (c) 2001-2005 Octasic Inc.
10002
 
    
10003
 
Description: 
10004
 
 
10005
 
        This file contains the functions used to power-up the chip according to the
10006
 
        user's configuration.  Also, the API instance is initialized to reflect the
10007
 
        desired configuration.
10008
 
 
10009
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
10010
 
free software; you can redistribute it and/or modify it under the terms of 
10011
 
the GNU General Public License as published by the Free Software Foundation; 
10012
 
either version 2 of the License, or (at your option) any later version.
10013
 
 
10014
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
10015
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
10016
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
10017
 
for more details. 
10018
 
 
10019
 
You should have received a copy of the GNU General Public License 
10020
 
along with the OCT6100 GPL API; if not, write to the Free Software 
10021
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
10022
 
 
10023
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
10024
 
 
10025
 
$Octasic_Revision: 305 $
10026
 
 
10027
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10028
 
 
10029
 
 
10030
 
/*****************************  INCLUDE FILES  *******************************/
10031
 
 
10032
 
#include "octdef.h"
10033
 
 
10034
 
#include "oct6100api/oct6100_defines.h"
10035
 
#include "oct6100api/oct6100_errors.h"
10036
 
 
10037
 
#include "apilib/octapi_bt0.h"
10038
 
#include "apilib/octapi_llman.h"
10039
 
 
10040
 
#include "oct6100api/oct6100_apiud.h"
10041
 
#include "oct6100api/oct6100_chip_stats_inst.h"
10042
 
#include "oct6100api/oct6100_tsi_cnct_inst.h"
10043
 
#include "oct6100api/oct6100_events_inst.h"
10044
 
#include "oct6100api/oct6100_conf_bridge_inst.h"
10045
 
#include "oct6100api/oct6100_playout_buf_inst.h"
10046
 
 
10047
 
#include "oct6100api/oct6100_mixer_inst.h"
10048
 
#include "oct6100api/oct6100_channel_inst.h"
10049
 
#include "oct6100api/oct6100_adpcm_chan_inst.h"
10050
 
#include "oct6100api/oct6100_phasing_tsst_inst.h"
10051
 
#include "oct6100api/oct6100_interrupts_inst.h"
10052
 
#include "oct6100api/oct6100_remote_debug_inst.h"
10053
 
#include "oct6100api/oct6100_debug_inst.h"
10054
 
#include "oct6100api/oct6100_tlv_inst.h"
10055
 
#include "oct6100api/oct6100_chip_open_inst.h"
10056
 
#include "oct6100api/oct6100_api_inst.h"
10057
 
 
10058
 
#include "oct6100api/oct6100_chip_stats_pub.h"
10059
 
#include "oct6100api/oct6100_interrupts_pub.h"
10060
 
#include "oct6100api/oct6100_tsi_cnct_pub.h"
10061
 
#include "oct6100api/oct6100_events_pub.h"
10062
 
#include "oct6100api/oct6100_conf_bridge_pub.h"
10063
 
#include "oct6100api/oct6100_playout_buf_pub.h"
10064
 
 
10065
 
#include "oct6100api/oct6100_channel_pub.h"
10066
 
#include "oct6100api/oct6100_adpcm_chan_pub.h"
10067
 
#include "oct6100api/oct6100_phasing_tsst_pub.h"
10068
 
#include "oct6100api/oct6100_remote_debug_pub.h"
10069
 
#include "oct6100api/oct6100_chip_open_pub.h"
10070
 
#include "oct6100api/oct6100_mixer_pub.h"
10071
 
#include "oct6100api/oct6100_channel_pub.h"
10072
 
#include "oct6100api/oct6100_debug_pub.h"
10073
 
 
10074
 
#include "oct6100_chip_open_priv.h"
10075
 
#include "oct6100_interrupts_priv.h"
10076
 
#include "oct6100_chip_stats_priv.h"
10077
 
#include "octrpc/rpc_protocol.h"
10078
 
#include "oct6100_remote_debug_priv.h"
10079
 
#include "oct6100_miscellaneous_priv.h"
10080
 
#include "oct6100_memory_priv.h"
10081
 
#include "oct6100_tsst_priv.h"
10082
 
#include "oct6100_tsi_cnct_priv.h"
10083
 
#include "oct6100_mixer_priv.h"
10084
 
#include "oct6100_events_priv.h"
10085
 
#include "oct6100_conf_bridge_priv.h"
10086
 
#include "oct6100_playout_buf_priv.h"
10087
 
 
10088
 
#include "oct6100_channel_priv.h"
10089
 
#include "oct6100_adpcm_chan_priv.h"
10090
 
#include "oct6100_phasing_tsst_priv.h"
10091
 
#include "oct6100_tlv_priv.h"
10092
 
#include "oct6100_debug_priv.h"
10093
 
#include "oct6100_version.h"
10094
 
 
10095
 
 
10096
 
 
10097
 
 
10098
 
/****************************  PUBLIC FUNCTIONS  *****************************/
10099
 
 
10100
 
 
10101
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10102
 
 
10103
 
Function:               Oct6100GetInstanceSizeDef
10104
 
 
10105
 
Description:    Retrieves the size of the required API instance structure.
10106
 
 
10107
 
-------------------------------------------------------------------------------
10108
 
|       Argument                |       Description
10109
 
-------------------------------------------------------------------------------
10110
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
10111
 
                                        present state of the chip and all its resources.
10112
 
 
10113
 
f_pGetSize                      Structure containing API instance size. 
10114
 
 
10115
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10116
 
static UINT32 Oct6100GetInstanceSizeDef(
10117
 
                                tPOCT6100_GET_INSTANCE_SIZE             f_pGetSize )
10118
 
{
10119
 
        return cOCT6100_ERR_OK;
10120
 
}
10121
 
 
10122
 
static UINT32 Oct6100GetInstanceSize(
10123
 
                                tPOCT6100_CHIP_OPEN                             f_pChipOpen,
10124
 
                                tPOCT6100_GET_INSTANCE_SIZE             f_pGetSize )
10125
 
{
10126
 
        tOCT6100_API_INSTANCE_SIZES     InstanceSizes;
10127
 
        UINT32                                          ulResult;
10128
 
 
10129
 
        /* Check user configuration for errors and conflicts. */
10130
 
        ulResult = Oct6100ApiCheckChipConfiguration( f_pChipOpen );
10131
 
        if ( ulResult != cOCT6100_ERR_OK  )
10132
 
                return ulResult;
10133
 
 
10134
 
        /* Calculate the instance size required for user's configuration. */
10135
 
        ulResult = Oct6100ApiCalculateInstanceSizes( f_pChipOpen, &InstanceSizes );
10136
 
        if ( ulResult != cOCT6100_ERR_OK  )
10137
 
                return ulResult;
10138
 
 
10139
 
        /* Return required size to user. */
10140
 
        f_pGetSize->ulApiInstanceSize = InstanceSizes.ulApiInstTotal;
10141
 
 
10142
 
        return cOCT6100_ERR_OK;
10143
 
}
10144
 
 
10145
 
 
10146
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10147
 
 
10148
 
Function:               Oct6100ChipOpenDef
10149
 
 
10150
 
Description:    Inserts default chip configuration parameters into the
10151
 
                                structure pointed to by f_pChipOpen.
10152
 
 
10153
 
-------------------------------------------------------------------------------
10154
 
|       Argument                |       Description
10155
 
-------------------------------------------------------------------------------
10156
 
 
10157
 
f_pChipOpen                     Structure containing user chip configuration. 
10158
 
 
10159
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10160
 
static UINT32 Oct6100ChipOpenDef(
10161
 
                                tPOCT6100_CHIP_OPEN     f_pChipOpen )
10162
 
{
10163
 
        UINT32  i;
10164
 
 
10165
 
        f_pChipOpen->ulUserChipId = 0;
10166
 
        f_pChipOpen->fMultiProcessSystem = FALSE;
10167
 
        f_pChipOpen->pProcessContext = NULL;
10168
 
 
10169
 
        f_pChipOpen->ulMaxRwAccesses = 8;
10170
 
 
10171
 
        f_pChipOpen->pbyImageFile = NULL;
10172
 
        f_pChipOpen->ulImageSize = 0;
10173
 
        
10174
 
        f_pChipOpen->ulMemClkFreq = 133000000;                                                  /* 133 Mhz */
10175
 
        f_pChipOpen->ulUpclkFreq = cOCT6100_UPCLK_FREQ_33_33_MHZ;               /* 33.33  Mhz */
10176
 
        f_pChipOpen->fEnableMemClkOut = TRUE;
10177
 
 
10178
 
        f_pChipOpen->ulMemoryType = cOCT6100_MEM_TYPE_DDR;
10179
 
        f_pChipOpen->ulNumMemoryChips = 1;
10180
 
        f_pChipOpen->ulMemoryChipSize = cOCT6100_MEMORY_CHIP_SIZE_64MB;
10181
 
 
10182
 
        /* Set the tail displacement to zero. */
10183
 
        f_pChipOpen->ulTailDisplacement = 0;
10184
 
        
10185
 
        /* Disable acoustic echo by default. */
10186
 
        f_pChipOpen->fEnableAcousticEcho = FALSE;
10187
 
 
10188
 
        /* Resource allocation parameters. */
10189
 
        f_pChipOpen->ulMaxChannels = 672;
10190
 
        f_pChipOpen->ulMaxTsiCncts = 0;
10191
 
        f_pChipOpen->ulMaxBiDirChannels = 0;
10192
 
        f_pChipOpen->ulMaxConfBridges = 0;
10193
 
        f_pChipOpen->ulMaxFlexibleConfParticipants = 0;
10194
 
        f_pChipOpen->ulMaxPlayoutBuffers = 0;
10195
 
 
10196
 
        f_pChipOpen->ulMaxPhasingTssts  = 0;
10197
 
        f_pChipOpen->ulMaxAdpcmChannels = 0;
10198
 
        f_pChipOpen->ulMaxTdmStreams = 32;
10199
 
        f_pChipOpen->fUseSynchTimestamp = FALSE;
10200
 
        for ( i = 0; i < 4; i++ )
10201
 
        {
10202
 
                f_pChipOpen->aulTimestampTimeslots[ i ] = cOCT6100_INVALID_TIMESLOT;
10203
 
                f_pChipOpen->aulTimestampStreams[ i ] = cOCT6100_INVALID_STREAM;
10204
 
        }
10205
 
        f_pChipOpen->fEnableFastH100Mode = FALSE;
10206
 
 
10207
 
        /* Configure the soft tone event buffer. */
10208
 
        f_pChipOpen->ulSoftToneEventsBufSize = 2048;
10209
 
        f_pChipOpen->fEnableExtToneDetection = FALSE;
10210
 
 
10211
 
        /* Configure the soft playout event buffer. */
10212
 
        f_pChipOpen->ulSoftBufferPlayoutEventsBufSize = cOCT6100_INVALID_VALUE;
10213
 
 
10214
 
        /* Interrupt configuration. */
10215
 
        f_pChipOpen->ulInterruptPolarity = cOCT6100_ACTIVE_LOW_POLARITY;
10216
 
 
10217
 
        f_pChipOpen->InterruptConfig.ulErrorMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
10218
 
        f_pChipOpen->InterruptConfig.ulFatalGeneralConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
10219
 
        f_pChipOpen->InterruptConfig.ulFatalMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
10220
 
        f_pChipOpen->InterruptConfig.ulFatalMemoryConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
10221
 
        f_pChipOpen->InterruptConfig.ulErrorH100Config = cOCT6100_INTERRUPT_NO_TIMEOUT;
10222
 
        f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig = cOCT6100_INTERRUPT_NO_TIMEOUT;
10223
 
 
10224
 
        f_pChipOpen->InterruptConfig.ulErrorMemoryTimeout = 100;
10225
 
        f_pChipOpen->InterruptConfig.ulFatalMemoryTimeout = 100;
10226
 
        f_pChipOpen->InterruptConfig.ulErrorH100Timeout = 100;
10227
 
        f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsTimeout = 100;
10228
 
        f_pChipOpen->ulMaxRemoteDebugSessions = 1;
10229
 
        f_pChipOpen->ulTdmSampling = cOCT6100_TDM_SAMPLE_AT_3_QUARTERS;
10230
 
        for ( i = 0; i < cOCT6100_TDM_STREAM_MAX_GROUPS; i++ )
10231
 
                f_pChipOpen->aulTdmStreamFreqs[ i ] = cOCT6100_TDM_STREAM_FREQ_8MHZ;
10232
 
 
10233
 
 
10234
 
 
10235
 
        f_pChipOpen->fEnableChannelRecording = FALSE;
10236
 
        f_pChipOpen->fEnableProductionBist = FALSE;
10237
 
        f_pChipOpen->ulNumProductionBistLoops = 1;
10238
 
 
10239
 
        return cOCT6100_ERR_OK;
10240
 
}
10241
 
 
10242
 
 
10243
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10244
 
 
10245
 
Function:               Oct6100ChipOpen
10246
 
 
10247
 
Description:    Configures the chip according to the user specified
10248
 
                                configuration f_pChipOpen. This function will perform all I/O
10249
 
                                accesses necessary and initialize the API instance to reflect
10250
 
                                the configuration.
10251
 
 
10252
 
-------------------------------------------------------------------------------
10253
 
|       Argument                |       Description
10254
 
-------------------------------------------------------------------------------
10255
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
10256
 
                                                present state of the chip and all its resources.
10257
 
 
10258
 
f_pChipOpen                             Structure containing user chip configuration. 
10259
 
 
10260
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10261
 
static UINT32 Oct6100ChipOpen(
10262
 
                                tPOCT6100_INSTANCE_API  f_pApiInstance,
10263
 
                                tPOCT6100_CHIP_OPEN             f_pChipOpen )
10264
 
{
10265
 
        tOCT6100_API_INSTANCE_SIZES     InstanceSizes;
10266
 
        UINT32                                          ulStructSize;
10267
 
        UINT32                                          ulResult;
10268
 
        UINT32                                          ulTempVar;
10269
 
 
10270
 
        /* Check user chip configuration parameters for errors. */
10271
 
        ulResult = Oct6100ApiCheckChipConfiguration( f_pChipOpen );
10272
 
        if ( ulResult != cOCT6100_ERR_OK )
10273
 
                return ulResult;
10274
 
 
10275
 
        /* Check if the host system is multi-process or not and adjust instance accordingly. */
10276
 
        if ( f_pChipOpen->fMultiProcessSystem != TRUE )
10277
 
        {
10278
 
                /* Set pointer to tOCT6100_SHARED_INFO structure within instance. */
10279
 
                ulStructSize = sizeof( tOCT6100_INSTANCE_API );
10280
 
                mOCT6100_ROUND_MEMORY_SIZE( ulStructSize, ulTempVar )
10281
 
 
10282
 
                f_pApiInstance->pSharedInfo = ( tPOCT6100_SHARED_INFO )(( PVOID )f_pApiInstance + ulStructSize);
10283
 
 
10284
 
                /* Save the process context specified by the user. */
10285
 
                f_pApiInstance->pProcessContext = f_pChipOpen->pProcessContext;
10286
 
 
10287
 
 
10288
 
                /* Create serialization object handles. */
10289
 
                ulResult = Oct6100ApiCreateSerializeObjects( f_pApiInstance, f_pChipOpen->ulUserChipId );
10290
 
                if ( ulResult != cOCT6100_ERR_OK )
10291
 
                        return ulResult;
10292
 
        }
10293
 
 
10294
 
        /* Copy the configuration structure. */
10295
 
        ulResult = Oct6100ApiCopyChipConfiguration( f_pApiInstance, f_pChipOpen );
10296
 
        if ( ulResult != cOCT6100_ERR_OK )
10297
 
                return ulResult;
10298
 
 
10299
 
        /* Perform various calculations based on user chip configuration. */
10300
 
        ulResult = Oct6100ApiInitializeMiscellaneousVariables( f_pApiInstance );
10301
 
        if ( ulResult != cOCT6100_ERR_OK )
10302
 
                return ulResult;
10303
 
 
10304
 
        /* Calculate the amount of memory needed for the API instance structure. */
10305
 
        ulResult = Oct6100ApiCalculateInstanceSizes( f_pChipOpen, &InstanceSizes );
10306
 
        if ( ulResult != cOCT6100_ERR_OK )
10307
 
                return ulResult;
10308
 
 
10309
 
        /* Allocate the memory for the API instance structure internal pointers. */
10310
 
        ulResult = Oct6100ApiAllocateInstanceMemory( f_pApiInstance, &InstanceSizes );
10311
 
        if ( ulResult != cOCT6100_ERR_OK )
10312
 
                return ulResult;
10313
 
 
10314
 
        /* Initialize the allocated instance structure memory. */
10315
 
        ulResult = Oct6100ApiInitializeInstanceMemory( f_pApiInstance );
10316
 
        if ( ulResult != cOCT6100_ERR_OK )
10317
 
                return ulResult;
10318
 
 
10319
 
        /* Initialize the tone information structure. */
10320
 
        ulResult = Oct6100ApiInitToneInfo( f_pApiInstance );
10321
 
        if ( ulResult != cOCT6100_ERR_OK )
10322
 
                return ulResult;
10323
 
 
10324
 
        /* Test the CPU registers. */
10325
 
        ulResult = Oct6100ApiCpuRegisterBist( f_pApiInstance );
10326
 
        if ( ulResult != cOCT6100_ERR_OK )
10327
 
                return ulResult;
10328
 
 
10329
 
        /* Boot the FC2 PLL. */
10330
 
        ulResult = Oct6100ApiBootFc2Pll( f_pApiInstance );
10331
 
        if ( ulResult != cOCT6100_ERR_OK )
10332
 
                return ulResult;
10333
 
        
10334
 
        /* Program the FC1 PLL. */
10335
 
        ulResult = Oct6100ApiProgramFc1Pll( f_pApiInstance );
10336
 
        if ( ulResult != cOCT6100_ERR_OK )
10337
 
                return ulResult;
10338
 
 
10339
 
        /* Decode the key and bist internal memories. */
10340
 
        ulResult = Oct6100ApiDecodeKeyAndBist( f_pApiInstance );
10341
 
        if ( ulResult != cOCT6100_ERR_OK )
10342
 
                return ulResult;
10343
 
        
10344
 
        /* Boot the FC1 PLL. */
10345
 
        ulResult = Oct6100ApiBootFc1Pll( f_pApiInstance );
10346
 
        if ( ulResult != cOCT6100_ERR_OK )
10347
 
                return ulResult;
10348
 
        
10349
 
        /* Boot the SDRAM. */
10350
 
        ulResult = Oct6100ApiBootSdram( f_pApiInstance );
10351
 
        if ( ulResult != cOCT6100_ERR_OK )
10352
 
                return ulResult;
10353
 
 
10354
 
        /* Bist the external memory. */
10355
 
        ulResult = Oct6100ApiExternalMemoryBist( f_pApiInstance );
10356
 
        if ( ulResult != cOCT6100_ERR_OK )
10357
 
                return ulResult;
10358
 
 
10359
 
        /* Initialize the external memory. */
10360
 
        ulResult = Oct6100ApiExternalMemoryInit( f_pApiInstance );
10361
 
        if ( ulResult != cOCT6100_ERR_OK )
10362
 
                return ulResult;
10363
 
 
10364
 
        /* Load the image into the chip. */
10365
 
        ulResult = Oct6100ApiLoadImage( f_pApiInstance );
10366
 
        if ( ulResult != cOCT6100_ERR_OK )
10367
 
                return ulResult;
10368
 
 
10369
 
        /* Write the clock distribution registers. */
10370
 
        ulResult = Oct6100ApiEnableClocks( f_pApiInstance );
10371
 
        if ( ulResult != cOCT6100_ERR_OK )
10372
 
                return ulResult;
10373
 
 
10374
 
        /* Program the NLP processor. */
10375
 
        ulResult = Oct6100ApiProgramNLP( f_pApiInstance );
10376
 
        if ( ulResult != cOCT6100_ERR_OK )
10377
 
        {               
10378
 
                if ( ulResult == cOCT6100_ERR_OPEN_EGO_TIMEOUT )
10379
 
                        ulResult = Oct6100ApiProgramNLP( f_pApiInstance );
10380
 
        }
10381
 
        if ( ulResult != cOCT6100_ERR_OK )
10382
 
                return ulResult;        
10383
 
 
10384
 
        if ( f_pChipOpen->fEnableProductionBist == FALSE )
10385
 
        {
10386
 
                /* Read all TLV fields present in external memory. */
10387
 
                ulResult = Oct6100ApiProcessTlvRegion( f_pApiInstance );
10388
 
                if ( ulResult != cOCT6100_ERR_OK )
10389
 
                        return ulResult;        
10390
 
                
10391
 
                /* Configure the H.100 interface. */
10392
 
                ulResult = Oct6100ApiSetH100Register( f_pApiInstance );
10393
 
                if ( ulResult != cOCT6100_ERR_OK )
10394
 
                        return ulResult;
10395
 
        }
10396
 
 
10397
 
        /* Write miscellaneous registers. */
10398
 
        ulResult = Oct6100ApiWriteMiscellaneousRegisters( f_pApiInstance );
10399
 
        if ( ulResult != cOCT6100_ERR_OK )
10400
 
                return ulResult;
10401
 
        
10402
 
        /* Proceed with the rest only if the production BIST has not been requested. */
10403
 
        if ( f_pChipOpen->fEnableProductionBist == FALSE )
10404
 
        {
10405
 
                /* Configure the interrupt registers. */
10406
 
                ulResult = Oct6100ApiIsrHwInit( f_pApiInstance, &f_pChipOpen->InterruptConfig );
10407
 
                if ( ulResult != cOCT6100_ERR_OK )
10408
 
                        return ulResult;
10409
 
 
10410
 
                /* Initialize the errors counters. */
10411
 
                ulResult = Oct6100ApiChipStatsSwInit( f_pApiInstance );
10412
 
                if ( ulResult != cOCT6100_ERR_OK )
10413
 
                        return ulResult;
10414
 
 
10415
 
                /* Configure all interrupts of the chip. */
10416
 
                ulResult = Oct6100InterruptConfigureSer( f_pApiInstance, &f_pChipOpen->InterruptConfig, FALSE );
10417
 
                if ( ulResult != cOCT6100_ERR_OK )
10418
 
                        return ulResult;
10419
 
 
10420
 
                /* Get revision number of chip. */
10421
 
                ulResult = Oct6100ApiGetChipRevisionNum( f_pApiInstance );
10422
 
                if ( ulResult != cOCT6100_ERR_OK )
10423
 
                        return ulResult;
10424
 
 
10425
 
 
10426
 
                
10427
 
 
10428
 
 
10429
 
                /* Initialize the channels. */
10430
 
                ulResult = Oct6100ApiInitChannels( f_pApiInstance );
10431
 
                if ( ulResult != cOCT6100_ERR_OK )
10432
 
                        return ulResult;
10433
 
 
10434
 
                /* Initialize the mixer memory. */
10435
 
                ulResult = Oct6100ApiInitMixer( f_pApiInstance );
10436
 
                if ( ulResult != cOCT6100_ERR_OK )
10437
 
                        return ulResult;
10438
 
 
10439
 
                /* Initialize the mixer memory. */
10440
 
                ulResult = Oct6100ApiInitRecordResources( f_pApiInstance );
10441
 
                if ( ulResult != cOCT6100_ERR_OK )
10442
 
                        return ulResult;
10443
 
 
10444
 
                /* Initialize free external memory for buffer playout. */
10445
 
                ulResult = Oct6100ApiBufferPlayoutMemorySwInit( f_pApiInstance );
10446
 
                if ( ulResult != cOCT6100_ERR_OK )
10447
 
                        return ulResult;
10448
 
 
10449
 
 
10450
 
 
10451
 
        }
10452
 
 
10453
 
        return cOCT6100_ERR_OK;
10454
 
}
10455
 
 
10456
 
 
10457
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10458
 
 
10459
 
Function:               Oct6100ChipCloseDef
10460
 
 
10461
 
Description:    Puts the chip into soft reset.
10462
 
 
10463
 
-------------------------------------------------------------------------------
10464
 
|       Argument                |       Description
10465
 
-------------------------------------------------------------------------------
10466
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
10467
 
                                                present state of the chip and all its resources.
10468
 
 
10469
 
f_pChipClose                    Pointer to a tOCT6100_CHIP_CLOSE structure.
10470
 
 
10471
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10472
 
static UINT32 Oct6100ChipCloseDef(
10473
 
                                tPOCT6100_CHIP_CLOSE    f_pChipClose )
10474
 
{
10475
 
        f_pChipClose->ulDummyVariable = 0;
10476
 
 
10477
 
        return cOCT6100_ERR_OK;
10478
 
}
10479
 
 
10480
 
static UINT32 Oct6100ChipClose(
10481
 
                                tPOCT6100_INSTANCE_API  f_pApiInstance,
10482
 
                                tPOCT6100_CHIP_CLOSE    f_pChipClose )
10483
 
{
10484
 
        tOCT6100_WRITE_PARAMS   WriteParams;
10485
 
        UINT32  ulResult;
10486
 
 
10487
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
10488
 
 
10489
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
10490
 
        WriteParams.ulWriteAddress = 0x100;
10491
 
        WriteParams.usWriteData = 0x0000;
10492
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
10493
 
        if ( ulResult != cOCT6100_ERR_OK )
10494
 
                return ulResult;
10495
 
 
10496
 
        /* Destroy the allocated ressources used for serialization. */
10497
 
        ulResult = Oct6100ApiDestroySerializeObjects( f_pApiInstance );
10498
 
        if ( ulResult != cOCT6100_ERR_OK )
10499
 
                return ulResult;
10500
 
 
10501
 
        return cOCT6100_ERR_OK;
10502
 
}
10503
 
 
10504
 
/***************************  PRIVATE FUNCTIONS  *****************************/
10505
 
 
10506
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10507
 
 
10508
 
Function:               Oct6100ApiStrStr
10509
 
 
10510
 
Description:    OCT6100 API version of strstr()
10511
 
 
10512
 
-------------------------------------------------------------------------------
10513
 
|       Argument                |       Description
10514
 
-------------------------------------------------------------------------------
10515
 
 
10516
 
f_pszSource                             Source string to analyze.
10517
 
f_pszString                             String to look for.
10518
 
f_pszLastCharPtr                Last character in the source string.
10519
 
 
10520
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10521
 
static PUINT8 Oct6100ApiStrStr(
10522
 
                                IN              PUINT8                          f_pszSource,
10523
 
                                IN              PUINT8                          f_pszString,
10524
 
                                IN              PUINT8                          f_pszLastCharPtr )
10525
 
{
10526
 
        UINT32  ulCurrentPos;
10527
 
        UINT32  ulStringLength;
10528
 
        UINT32  ulNumMatchingCharFound = 0;
10529
 
        PUINT8  pchFirstChar = NULL;
10530
 
        UINT32  ulSourceLength;
10531
 
 
10532
 
        if ( f_pszLastCharPtr < f_pszSource )
10533
 
                return NULL;
10534
 
 
10535
 
        ulSourceLength = f_pszLastCharPtr - f_pszSource;
10536
 
        ulStringLength = Oct6100ApiStrLen( f_pszString );
10537
 
 
10538
 
        for ( ulCurrentPos = 0; ulCurrentPos < ulSourceLength; ulCurrentPos++ )
10539
 
        {
10540
 
                /* Check if the character matches. */
10541
 
                if ( f_pszSource[ ulCurrentPos ] == f_pszString[ ulNumMatchingCharFound ] )
10542
 
                {
10543
 
                        if ( ulNumMatchingCharFound == 0 )
10544
 
                                pchFirstChar = ( f_pszSource + ulCurrentPos );
10545
 
 
10546
 
                        ulNumMatchingCharFound++;
10547
 
 
10548
 
                        /* Check if the whole string matched. */
10549
 
                        if ( ulNumMatchingCharFound == ulStringLength )
10550
 
                                break;
10551
 
                }
10552
 
                else if ( ulNumMatchingCharFound != 0 )
10553
 
                {
10554
 
                        ulNumMatchingCharFound = 0;
10555
 
 
10556
 
                        /* Reset the search, but take a look at the current character.  It might */
10557
 
                        /* be the beginning of the string we are looking for. */
10558
 
                        if ( f_pszSource[ ulCurrentPos ] == f_pszString[ ulNumMatchingCharFound ] )
10559
 
                        {
10560
 
                                pchFirstChar = ( f_pszSource + ulCurrentPos );
10561
 
                                ulNumMatchingCharFound++;
10562
 
 
10563
 
                                /* Check if the whole string matched. */
10564
 
                                /* This check must be done in case we have the 1 character strstr */
10565
 
                                if ( ulNumMatchingCharFound == ulStringLength )
10566
 
                                        break;
10567
 
                        }
10568
 
                }
10569
 
        }
10570
 
 
10571
 
        if ( ulCurrentPos == ulSourceLength )
10572
 
                return NULL;
10573
 
        else
10574
 
                return pchFirstChar;
10575
 
}
10576
 
 
10577
 
 
10578
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10579
 
 
10580
 
Function:               Oct6100ApiStrLen
10581
 
 
10582
 
Description:    OCT6100 API version of strlen()
10583
 
 
10584
 
-------------------------------------------------------------------------------
10585
 
|       Argument                |       Description
10586
 
-------------------------------------------------------------------------------
10587
 
 
10588
 
f_pszString                             Source string to count length of.
10589
 
 
10590
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10591
 
static UINT32 Oct6100ApiStrLen(
10592
 
                                IN              PUINT8          f_pszString )
10593
 
{
10594
 
        UINT32  ulCount = 0;
10595
 
 
10596
 
        while( f_pszString[ ulCount ] != '\0' )
10597
 
                ulCount++;
10598
 
 
10599
 
        return ulCount;
10600
 
}
10601
 
 
10602
 
 
10603
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10604
 
 
10605
 
Function:               Oct6100ApiAsciiToHex
10606
 
 
10607
 
Description:    Convert an ASCII character to an hexadecimal value.
10608
 
 
10609
 
-------------------------------------------------------------------------------
10610
 
|       Argument                |       Description
10611
 
-------------------------------------------------------------------------------
10612
 
 
10613
 
f_chCharacter                   ASCII character to convert.
10614
 
f_pulValue                              Resulting hexadecimal value.
10615
 
 
10616
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10617
 
static UINT32 Oct6100ApiAsciiToHex(
10618
 
                                IN              UINT8           f_chCharacter,
10619
 
                                OUT             PUINT32         f_pulValue )
10620
 
{
10621
 
        switch ( f_chCharacter )
10622
 
        {
10623
 
        case '0':
10624
 
                (*f_pulValue) = 0x0;
10625
 
                break;
10626
 
        case '1':
10627
 
                (*f_pulValue) = 0x1;
10628
 
                break;
10629
 
        case '2':
10630
 
                (*f_pulValue) = 0x2;
10631
 
                break;
10632
 
        case '3':
10633
 
                (*f_pulValue) = 0x3;
10634
 
                break;
10635
 
        case '4':
10636
 
                (*f_pulValue) = 0x4;
10637
 
                break;
10638
 
        case '5':
10639
 
                (*f_pulValue) = 0x5;
10640
 
                break;
10641
 
        case '6':
10642
 
                (*f_pulValue) = 0x6;
10643
 
                break;
10644
 
        case '7':
10645
 
                (*f_pulValue) = 0x7;
10646
 
                break;
10647
 
        case '8':
10648
 
                (*f_pulValue) = 0x8;
10649
 
                break;
10650
 
        case '9':
10651
 
                (*f_pulValue) = 0x9;
10652
 
                break;
10653
 
        case 'A':
10654
 
        case 'a':
10655
 
                (*f_pulValue) = 0xA;
10656
 
                break;
10657
 
        case 'B':
10658
 
        case 'b':
10659
 
                (*f_pulValue) = 0xB;
10660
 
                break;
10661
 
        case 'C':
10662
 
        case 'c':
10663
 
                (*f_pulValue) = 0xC;
10664
 
                break;
10665
 
        case 'D':
10666
 
        case 'd':
10667
 
                (*f_pulValue) = 0xD;
10668
 
                break;
10669
 
        case 'E':
10670
 
        case 'e':
10671
 
                (*f_pulValue) = 0xE;
10672
 
                break;
10673
 
        case 'F':
10674
 
        case 'f':
10675
 
                (*f_pulValue) = 0xF;
10676
 
                break;
10677
 
        default:
10678
 
                (*f_pulValue) = 0x0;
10679
 
                return cOCT6100_ERR_MISC_ASCII_CONVERSION_FAILED;
10680
 
        }
10681
 
 
10682
 
        return cOCT6100_ERR_OK;
10683
 
}
10684
 
 
10685
 
 
10686
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10687
 
 
10688
 
Function:               Oct6100ApiHexToAscii
10689
 
 
10690
 
Description:    Convert an hexadecimal value to an ASCII character.
10691
 
 
10692
 
-------------------------------------------------------------------------------
10693
 
|       Argument                |       Description
10694
 
-------------------------------------------------------------------------------
10695
 
 
10696
 
f_ulNumber                              Hexadecimal value to convert.
10697
 
 
10698
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10699
 
static UINT8 Oct6100ApiHexToAscii(
10700
 
                                IN              UINT32  f_ulNumber )
10701
 
{
10702
 
        if ( f_ulNumber >= 0xA )
10703
 
                return (UINT8)( 55 + f_ulNumber );              /* Hex values from 0xA to 0xF */
10704
 
        else
10705
 
                return (UINT8)( 48 + f_ulNumber );              /* Hex values from 0x0 to 0x9 */
10706
 
}
10707
 
 
10708
 
 
10709
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10710
 
 
10711
 
Function:               Oct6100ApiRand
10712
 
 
10713
 
Description:    Random number generator.
10714
 
 
10715
 
-------------------------------------------------------------------------------
10716
 
|       Argument                |       Description
10717
 
-------------------------------------------------------------------------------
10718
 
 
10719
 
f_ulRange                               Range of the random number to be generated.
10720
 
 
10721
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10722
 
static UINT32 Oct6100ApiRand(
10723
 
                                IN              UINT32                          f_ulRange )
10724
 
{
10725
 
        static UINT32   ulRandomSeed = 0x12345678;
10726
 
        UINT32                  ulBit0;
10727
 
 
10728
 
        UINT32                  i, j;
10729
 
        UINT16                  ulWithinRange = FALSE;
10730
 
 
10731
 
        UINT32                  ulResult = cOCT6100_ERR_OK;
10732
 
        UINT16                  ulLoop;
10733
 
 
10734
 
        UINT32                  ulRangeMask;
10735
 
        UINT32                  ulAddedValue;
10736
 
 
10737
 
 
10738
 
        ulRangeMask = 1;
10739
 
        ulLoop = TRUE;
10740
 
        i = 1;
10741
 
 
10742
 
        while ( ulLoop )
10743
 
        {
10744
 
 
10745
 
                ulAddedValue = 2;
10746
 
                for ( j = 1; j < i; j++ )
10747
 
                        ulAddedValue *= 2;
10748
 
 
10749
 
                ulRangeMask = ulRangeMask + ulAddedValue;
10750
 
 
10751
 
                if ( ulRangeMask >= f_ulRange )
10752
 
                        ulLoop = FALSE;
10753
 
 
10754
 
                i++;
10755
 
        }
10756
 
 
10757
 
        while ( !ulWithinRange )
10758
 
        {
10759
 
                ulBit0 = ((ulRandomSeed >> 19) & 0x1) ^ ((ulRandomSeed >> 16) & 0x1);
10760
 
                ulRandomSeed = ((ulRandomSeed << 1) & 0xFFFFF) | ulBit0;
10761
 
 
10762
 
                ulResult = ulRandomSeed & ulRangeMask;
10763
 
 
10764
 
                if ( ulResult <= f_ulRange )
10765
 
                        ulWithinRange = TRUE;
10766
 
        }
10767
 
 
10768
 
        return ulResult;
10769
 
}
10770
 
 
10771
 
 
10772
 
 
10773
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10774
 
 
10775
 
Function:               Oct6100ApiCheckChipConfiguration
10776
 
 
10777
 
Description:    Checks the user chip configuration structure for errors.
10778
 
 
10779
 
-------------------------------------------------------------------------------
10780
 
|       Argument                |       Description
10781
 
-------------------------------------------------------------------------------
10782
 
 
10783
 
f_pChipOpen                     Pointer to chip configuration structure.
10784
 
 
10785
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10786
 
static UINT32 Oct6100ApiCheckChipConfiguration(
10787
 
                                IN              tPOCT6100_CHIP_OPEN             f_pChipOpen )
10788
 
{
10789
 
        UINT32  ulTempVar;
10790
 
        UINT32  i;
10791
 
        
10792
 
        /*-----------------------------------------------------------------------------*/
10793
 
        /* Check general parameters. */
10794
 
        if ( f_pChipOpen->fMultiProcessSystem != TRUE &&
10795
 
                 f_pChipOpen->fMultiProcessSystem != FALSE )
10796
 
                return cOCT6100_ERR_OPEN_MULTI_PROCESS_SYSTEM;
10797
 
 
10798
 
        if ( f_pChipOpen->ulMaxRwAccesses < 1 ||
10799
 
                 f_pChipOpen->ulMaxRwAccesses > 1024)
10800
 
                return cOCT6100_ERR_OPEN_MAX_RW_ACCESSES;
10801
 
 
10802
 
        /* Check the clocks. */
10803
 
        if ( f_pChipOpen->ulUpclkFreq != cOCT6100_UPCLK_FREQ_33_33_MHZ )
10804
 
                return cOCT6100_ERR_OPEN_UP_CLK_FREQ;
10805
 
 
10806
 
        if ( f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_133_MHZ &&
10807
 
                 f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_125_MHZ &&
10808
 
                 f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_117_MHZ &&
10809
 
                 f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_108_MHZ &&
10810
 
                 f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_100_MHZ &&
10811
 
                 f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_92_MHZ &&
10812
 
                 f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_83_MHZ &&
10813
 
                 f_pChipOpen->ulMemClkFreq != cOCT6100_MCLK_FREQ_75_MHZ )
10814
 
                return cOCT6100_ERR_OPEN_MEM_CLK_FREQ;
10815
 
 
10816
 
        if ( f_pChipOpen->fEnableMemClkOut != TRUE &&
10817
 
                 f_pChipOpen->fEnableMemClkOut != FALSE )
10818
 
                return cOCT6100_ERR_OPEN_ENABLE_MEM_CLK_OUT;
10819
 
 
10820
 
        /* Check the image file. */
10821
 
        if ( f_pChipOpen->ulImageSize < cOCT6100_MIN_IMAGE_SIZE ||
10822
 
                 f_pChipOpen->ulImageSize > cOCT6100_MAX_IMAGE_SIZE )
10823
 
                return cOCT6100_ERR_OPEN_IMAGE_SIZE;
10824
 
 
10825
 
        if ( f_pChipOpen->pbyImageFile == NULL )
10826
 
                return cOCT6100_ERR_OPEN_IMAGE_FILE;
10827
 
 
10828
 
        /* Check the acoustic echo activation flag. */
10829
 
        if ( f_pChipOpen->fEnableAcousticEcho != TRUE && 
10830
 
                f_pChipOpen->fEnableAcousticEcho != FALSE )
10831
 
                return cOCT6100_ERR_OPEN_ENABLE_ACOUSTIC_ECHO;
10832
 
 
10833
 
        /* Check the tail displacement parameter. */
10834
 
        if ( f_pChipOpen->ulTailDisplacement > cOCT6100_MAX_TAIL_DISPLACEMENT )
10835
 
                return cOCT6100_ERR_OPEN_TAIL_DISPLACEMENT;
10836
 
 
10837
 
        /*-----------------------------------------------------------------------------*/
10838
 
        /* Check TDM bus configuration parameters. */
10839
 
        for ( i = 0; i < 8; i++ )
10840
 
        {
10841
 
                if ( f_pChipOpen->aulTdmStreamFreqs[ i ] != cOCT6100_TDM_STREAM_FREQ_2MHZ &&
10842
 
                         f_pChipOpen->aulTdmStreamFreqs[ i ] != cOCT6100_TDM_STREAM_FREQ_4MHZ &&
10843
 
                         f_pChipOpen->aulTdmStreamFreqs[ i ] != cOCT6100_TDM_STREAM_FREQ_8MHZ)
10844
 
                        return cOCT6100_ERR_OPEN_TDM_STREAM_FREQS;
10845
 
        }
10846
 
 
10847
 
        if ( f_pChipOpen->ulTdmSampling != cOCT6100_TDM_SAMPLE_AT_3_QUARTERS &&
10848
 
                 f_pChipOpen->ulTdmSampling != cOCT6100_TDM_SAMPLE_AT_RISING_EDGE &&
10849
 
                 f_pChipOpen->ulTdmSampling != cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE )
10850
 
                return cOCT6100_ERR_OPEN_TDM_SAMPLING;
10851
 
 
10852
 
        if ( f_pChipOpen->fEnableFastH100Mode != TRUE && 
10853
 
                 f_pChipOpen->fEnableFastH100Mode != FALSE )
10854
 
                return cOCT6100_ERR_OPEN_FAST_H100_MODE;
10855
 
 
10856
 
        /*-----------------------------------------------------------------------------*/
10857
 
        /* Check external memory configuration parameters. */
10858
 
        if ( f_pChipOpen->ulMemoryType != cOCT6100_MEM_TYPE_SDR &&
10859
 
                 f_pChipOpen->ulMemoryType != cOCT6100_MEM_TYPE_DDR &&
10860
 
                 f_pChipOpen->ulMemoryType != cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
10861
 
                return cOCT6100_ERR_OPEN_MEMORY_TYPE;
10862
 
        
10863
 
        if ( f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_8MB &&
10864
 
                 f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_16MB &&
10865
 
                 f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_32MB &&
10866
 
                 f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_64MB &&
10867
 
                 f_pChipOpen->ulMemoryChipSize != cOCT6100_MEMORY_CHIP_SIZE_128MB )
10868
 
                return cOCT6100_ERR_OPEN_MEMORY_CHIP_SIZE;
10869
 
        
10870
 
        if ( f_pChipOpen->ulMemoryChipSize == cOCT6100_MEMORY_CHIP_SIZE_8MB &&
10871
 
                 f_pChipOpen->ulMemoryType == cOCT6100_MEM_TYPE_DDR )
10872
 
                return cOCT6100_ERR_OPEN_MEMORY_CHIP_SIZE;
10873
 
 
10874
 
        if ( f_pChipOpen->ulNumMemoryChips < 1 ||
10875
 
                 f_pChipOpen->ulNumMemoryChips > cOCT6100_MAX_NUM_MEMORY_CHIP )
10876
 
                return cOCT6100_ERR_OPEN_MEMORY_CHIPS_NUMBER;
10877
 
 
10878
 
        /* Check the total memory size. */
10879
 
        ulTempVar = f_pChipOpen->ulMemoryChipSize * f_pChipOpen->ulNumMemoryChips;
10880
 
        if ( ulTempVar < cOCT6100_MEMORY_CHIP_SIZE_16MB ||
10881
 
                 ulTempVar > cOCT6100_MEMORY_CHIP_SIZE_128MB )
10882
 
                return cOCT6100_ERR_OPEN_TOTAL_MEMORY_SIZE;
10883
 
 
10884
 
        if ( f_pChipOpen->ulMaxTdmStreams != 4 &&
10885
 
                 f_pChipOpen->ulMaxTdmStreams != 8 &&
10886
 
                 f_pChipOpen->ulMaxTdmStreams != 16 &&
10887
 
                 f_pChipOpen->ulMaxTdmStreams != 32 )
10888
 
                return cOCT6100_ERR_OPEN_MAX_TDM_STREAM;
10889
 
 
10890
 
        if ( f_pChipOpen->ulMaxTdmStreams > 8 && 
10891
 
                 f_pChipOpen->ulMemClkFreq == cOCT6100_MCLK_FREQ_75_MHZ )
10892
 
                return cOCT6100_ERR_OPEN_MAX_TDM_STREAM;
10893
 
 
10894
 
        if ( f_pChipOpen->fUseSynchTimestamp != TRUE &&
10895
 
                 f_pChipOpen->fUseSynchTimestamp != FALSE )
10896
 
                return cOCT6100_ERR_OPEN_USE_SYNCH_TIMESTAMP;
10897
 
 
10898
 
        if ( f_pChipOpen->fUseSynchTimestamp == TRUE )
10899
 
        {
10900
 
                return cOCT6100_ERR_NOT_SUPPORTED_OPEN_USE_SYNCH_TIMESTAMP;
10901
 
        }
10902
 
 
10903
 
        /*-----------------------------------------------------------------------------*/
10904
 
        /* Check soft buffer for tone events size. */
10905
 
        if ( f_pChipOpen->ulSoftToneEventsBufSize < cOCT6100_NUM_PGSP_EVENT_OUT ||
10906
 
                 f_pChipOpen->ulSoftToneEventsBufSize > cOCT6100_ABSOLUTE_MAX_NUM_PGSP_EVENT_OUT )
10907
 
                return cOCT6100_ERR_OPEN_SOFT_TONE_EVENT_SIZE;
10908
 
 
10909
 
        if ( f_pChipOpen->fEnableExtToneDetection != TRUE && 
10910
 
                 f_pChipOpen->fEnableExtToneDetection != FALSE )
10911
 
                return cOCT6100_ERR_OPEN_ENABLE_EXT_TONE_DETECTION;
10912
 
 
10913
 
        /* Check soft buffer for playout events size. */
10914
 
        if ( ( f_pChipOpen->ulSoftBufferPlayoutEventsBufSize != cOCT6100_INVALID_VALUE )
10915
 
                && ( f_pChipOpen->ulSoftBufferPlayoutEventsBufSize < cOCT6100_MIN_BUFFER_PLAYOUT_EVENT ||
10916
 
                 f_pChipOpen->ulSoftBufferPlayoutEventsBufSize > cOCT6100_MAX_BUFFER_PLAYOUT_EVENT ) )
10917
 
                return cOCT6100_ERR_OPEN_SOFT_PLAYOUT_STOP_EVENT_SIZE;
10918
 
 
10919
 
        /*-----------------------------------------------------------------------------*/
10920
 
        /* Check interrupt configuration parameters. */
10921
 
        if ( f_pChipOpen->ulInterruptPolarity != cOCT6100_ACTIVE_LOW_POLARITY &&
10922
 
                 f_pChipOpen->ulInterruptPolarity != cOCT6100_ACTIVE_HIGH_POLARITY )
10923
 
                return cOCT6100_ERR_OPEN_INTERRUPT_POLARITY;
10924
 
 
10925
 
        if ( f_pChipOpen->InterruptConfig.ulFatalGeneralConfig != cOCT6100_INTERRUPT_NO_TIMEOUT &&
10926
 
                 f_pChipOpen->InterruptConfig.ulFatalGeneralConfig != cOCT6100_INTERRUPT_DISABLE )
10927
 
                return cOCT6100_ERR_OPEN_FATAL_GENERAL_CONFIG;
10928
 
 
10929
 
        if ( f_pChipOpen->InterruptConfig.ulFatalMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT &&
10930
 
                 f_pChipOpen->InterruptConfig.ulFatalMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
10931
 
                 f_pChipOpen->InterruptConfig.ulFatalMemoryConfig != cOCT6100_INTERRUPT_DISABLE )
10932
 
                return cOCT6100_ERR_OPEN_FATAL_MEMORY_CONFIG;
10933
 
 
10934
 
        if ( f_pChipOpen->InterruptConfig.ulErrorMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT &&
10935
 
                 f_pChipOpen->InterruptConfig.ulErrorMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
10936
 
                 f_pChipOpen->InterruptConfig.ulErrorMemoryConfig != cOCT6100_INTERRUPT_DISABLE )
10937
 
                return cOCT6100_ERR_OPEN_ERROR_MEMORY_CONFIG;
10938
 
 
10939
 
        if ( f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_NO_TIMEOUT &&
10940
 
                 f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_TIMEOUT &&
10941
 
                 f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_DISABLE )
10942
 
                return cOCT6100_ERR_OPEN_ERROR_OVERFLOW_TONE_EVENTS_CONFIG;
10943
 
 
10944
 
        if ( f_pChipOpen->InterruptConfig.ulErrorH100Config != cOCT6100_INTERRUPT_NO_TIMEOUT &&
10945
 
                 f_pChipOpen->InterruptConfig.ulErrorH100Config != cOCT6100_INTERRUPT_TIMEOUT &&
10946
 
                 f_pChipOpen->InterruptConfig.ulErrorH100Config != cOCT6100_INTERRUPT_DISABLE )
10947
 
                return cOCT6100_ERR_OPEN_ERROR_H100_CONFIG;
10948
 
 
10949
 
        /* Check the timeout value. */
10950
 
        if ( f_pChipOpen->InterruptConfig.ulFatalMemoryTimeout < 10 ||
10951
 
                 f_pChipOpen->InterruptConfig.ulFatalMemoryTimeout > 10000 )
10952
 
                return cOCT6100_ERR_OPEN_FATAL_MEMORY_TIMEOUT;
10953
 
 
10954
 
        if ( f_pChipOpen->InterruptConfig.ulErrorMemoryTimeout < 10 ||
10955
 
                 f_pChipOpen->InterruptConfig.ulErrorMemoryTimeout > 10000 )
10956
 
                return cOCT6100_ERR_OPEN_ERROR_MEMORY_TIMEOUT;
10957
 
 
10958
 
        if ( f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsTimeout < 10 ||
10959
 
                 f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsTimeout > 10000 )
10960
 
                return cOCT6100_ERR_OPEN_ERROR_OVERFLOW_TONE_EVENTS_TIMEOUT;
10961
 
 
10962
 
        if ( f_pChipOpen->InterruptConfig.ulErrorH100Timeout < 10 ||
10963
 
                 f_pChipOpen->InterruptConfig.ulErrorH100Timeout > 10000 )
10964
 
                return cOCT6100_ERR_OPEN_ERROR_H100_TIMEOUT;
10965
 
 
10966
 
        /*-----------------------------------------------------------------------------*/
10967
 
        /* Check maximum resources. */
10968
 
 
10969
 
        switch ( f_pChipOpen->ulMemClkFreq )
10970
 
        {
10971
 
        case 133000000:
10972
 
                ulTempVar = 672;
10973
 
                break;
10974
 
        case 125000000:
10975
 
                ulTempVar = 624;
10976
 
                break;
10977
 
        case 117000000:
10978
 
                ulTempVar = 576;
10979
 
                break;
10980
 
        case 108000000:
10981
 
                ulTempVar = 528;
10982
 
                break;
10983
 
        case 100000000:
10984
 
                ulTempVar = 480;
10985
 
                break;
10986
 
        case 92000000:
10987
 
                ulTempVar = 432;
10988
 
                break;
10989
 
        case 83000000:
10990
 
                ulTempVar = 384;
10991
 
                break;
10992
 
        case 75000000:
10993
 
                ulTempVar = 336;
10994
 
                break;
10995
 
        default:
10996
 
                return cOCT6100_ERR_FATAL_DA;
10997
 
        }
10998
 
 
10999
 
        if ( f_pChipOpen->ulMaxChannels > ulTempVar )
11000
 
                return cOCT6100_ERR_OPEN_MAX_ECHO_CHANNELS;
11001
 
 
11002
 
        if ( f_pChipOpen->ulMaxTsiCncts > cOCT6100_MAX_TSI_CNCTS )
11003
 
                return cOCT6100_ERR_OPEN_MAX_TSI_CNCTS;
11004
 
 
11005
 
        if ( f_pChipOpen->ulMaxBiDirChannels > (f_pChipOpen->ulMaxChannels / 2) )
11006
 
                return cOCT6100_ERR_OPEN_MAX_BIDIR_CHANNELS;
11007
 
 
11008
 
        if ( f_pChipOpen->ulMaxConfBridges > cOCT6100_MAX_CONF_BRIDGE )
11009
 
                return cOCT6100_ERR_OPEN_MAX_CONF_BRIDGES;
11010
 
 
11011
 
        if ( f_pChipOpen->ulMaxFlexibleConfParticipants > cOCT6100_MAX_FLEX_CONF_PARTICIPANTS )
11012
 
                return cOCT6100_ERR_OPEN_MAX_FLEXIBLE_CONF_PARTICIPANTS;
11013
 
 
11014
 
        if ( f_pChipOpen->ulMaxPlayoutBuffers > cOCT6100_MAX_PLAYOUT_BUFFERS )
11015
 
                return cOCT6100_ERR_OPEN_MAX_PLAYOUT_BUFFERS;
11016
 
 
11017
 
 
11018
 
 
11019
 
        if ( f_pChipOpen->ulMaxPhasingTssts > cOCT6100_MAX_PHASING_TSST )
11020
 
                return cOCT6100_ERR_OPEN_MAX_PHASING_TSSTS;
11021
 
 
11022
 
        if ( f_pChipOpen->ulMaxAdpcmChannels > cOCT6100_MAX_ADPCM_CHANNELS )
11023
 
                return cOCT6100_ERR_OPEN_MAX_ADPCM_CHANNELS;
11024
 
 
11025
 
        if ( f_pChipOpen->ulMaxRemoteDebugSessions > 256 )
11026
 
                return cOCT6100_ERR_OPEN_MAX_REMOTE_DEBUG_SESSIONS;
11027
 
 
11028
 
 
11029
 
 
11030
 
 
11031
 
 
11032
 
        /* Check the channel recording flag. */
11033
 
        if ( f_pChipOpen->fEnableChannelRecording != TRUE &&
11034
 
                 f_pChipOpen->fEnableChannelRecording != FALSE )
11035
 
                return cOCT6100_ERR_OPEN_DEBUG_CHANNEL_RECORDING;
11036
 
 
11037
 
        /* Check the enable production BIST flag. */
11038
 
        if ( ( f_pChipOpen->fEnableProductionBist != TRUE )
11039
 
                && ( f_pChipOpen->fEnableProductionBist != FALSE ) )
11040
 
                return cOCT6100_ERR_OPEN_ENABLE_PRODUCTION_BIST;
11041
 
 
11042
 
        /* Check number of loops for the production BIST. */
11043
 
        if ( f_pChipOpen->fEnableProductionBist == TRUE )
11044
 
        {
11045
 
                if ( f_pChipOpen->ulNumProductionBistLoops == 0 )
11046
 
                        return cOCT6100_ERR_OPEN_NUM_PRODUCTION_BIST_LOOPS;
11047
 
        }
11048
 
 
11049
 
        /* If the production BIST has been requested, make sure all */
11050
 
        /* other resources are disabled. */
11051
 
        if ( f_pChipOpen->fEnableProductionBist == TRUE )
11052
 
        {
11053
 
                /* All must be disabled. */
11054
 
                f_pChipOpen->ulMaxChannels = 0;
11055
 
                f_pChipOpen->ulMaxTsiCncts = 0;
11056
 
                f_pChipOpen->fEnableChannelRecording = FALSE;
11057
 
                f_pChipOpen->ulMaxBiDirChannels = 0;
11058
 
                f_pChipOpen->ulMaxConfBridges = 0;
11059
 
                f_pChipOpen->ulMaxPlayoutBuffers = 0;
11060
 
                f_pChipOpen->ulSoftBufferPlayoutEventsBufSize = cOCT6100_INVALID_VALUE;
11061
 
                f_pChipOpen->ulMaxPhasingTssts = 0;
11062
 
                f_pChipOpen->ulMaxAdpcmChannels = 0;
11063
 
 
11064
 
 
11065
 
        }
11066
 
 
11067
 
        return cOCT6100_ERR_OK;
11068
 
}
11069
 
 
11070
 
 
11071
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11072
 
 
11073
 
Function:               Oct6100ApiCopyChipConfiguration
11074
 
 
11075
 
Description:    Copies the chip configuration from the user supplied config
11076
 
                                structure to the instance structure.
11077
 
 
11078
 
-------------------------------------------------------------------------------
11079
 
|       Argument                |       Description
11080
 
-------------------------------------------------------------------------------
11081
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
11082
 
                                                present state of the chip and all its resources.
11083
 
 
11084
 
f_pChipOpen                             Pointer to chip configuration structure.
11085
 
 
11086
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11087
 
static UINT32 Oct6100ApiCopyChipConfiguration(
11088
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance,
11089
 
                                IN              tPOCT6100_CHIP_OPEN             f_pChipOpen )
11090
 
{
11091
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
11092
 
        UINT32  i;
11093
 
 
11094
 
        /* Get local pointer to shared portion of instance. */
11095
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11096
 
 
11097
 
        pSharedInfo->ChipConfig.ulUserChipId = f_pChipOpen->ulUserChipId;
11098
 
        pSharedInfo->ChipConfig.fMultiProcessSystem = (UINT8)( f_pChipOpen->fMultiProcessSystem & 0xFF );
11099
 
 
11100
 
        pSharedInfo->ChipConfig.usMaxRwAccesses = (UINT16)( f_pChipOpen->ulMaxRwAccesses & 0xFFFF );
11101
 
 
11102
 
        pSharedInfo->ChipConfig.pbyImageFile = f_pChipOpen->pbyImageFile;
11103
 
        pSharedInfo->ChipConfig.ulImageSize = f_pChipOpen->ulImageSize; 
11104
 
        
11105
 
        pSharedInfo->ChipConfig.ulMemClkFreq = f_pChipOpen->ulMemClkFreq;
11106
 
        pSharedInfo->ChipConfig.ulUpclkFreq = f_pChipOpen->ulUpclkFreq;
11107
 
 
11108
 
        pSharedInfo->ChipConfig.byMemoryType = (UINT8)( f_pChipOpen->ulMemoryType & 0xFF );
11109
 
        pSharedInfo->ChipConfig.byNumMemoryChips = (UINT8)( f_pChipOpen->ulNumMemoryChips & 0xFF );
11110
 
        pSharedInfo->ChipConfig.ulMemoryChipSize = f_pChipOpen->ulMemoryChipSize;
11111
 
 
11112
 
        pSharedInfo->ChipConfig.usTailDisplacement = (UINT16)( f_pChipOpen->ulTailDisplacement & 0xFFFF );
11113
 
        pSharedInfo->ChipConfig.fEnableAcousticEcho = (UINT8)( f_pChipOpen->fEnableAcousticEcho & 0xFF );
11114
 
        /* Resource allocation parameters. */
11115
 
        if ( f_pChipOpen->fEnableChannelRecording == TRUE && f_pChipOpen->ulMaxChannels == 672 )
11116
 
                pSharedInfo->ChipConfig.usMaxChannels = (UINT16)( ( f_pChipOpen->ulMaxChannels - 1 ) & 0xFFFF );
11117
 
        else
11118
 
                pSharedInfo->ChipConfig.usMaxChannels = (UINT16)( f_pChipOpen->ulMaxChannels & 0xFFFF );
11119
 
        pSharedInfo->ChipConfig.usMaxTsiCncts = (UINT16)( f_pChipOpen->ulMaxTsiCncts & 0xFFFF );
11120
 
        pSharedInfo->ChipConfig.usMaxBiDirChannels = (UINT16)( f_pChipOpen->ulMaxBiDirChannels & 0xFFFF );
11121
 
        pSharedInfo->ChipConfig.usMaxConfBridges = (UINT16)( f_pChipOpen->ulMaxConfBridges & 0xFFFF );
11122
 
        pSharedInfo->ChipConfig.usMaxFlexibleConfParticipants = (UINT16)( f_pChipOpen->ulMaxFlexibleConfParticipants & 0xFFFF );
11123
 
        pSharedInfo->ChipConfig.usMaxPlayoutBuffers = (UINT16)( f_pChipOpen->ulMaxPlayoutBuffers & 0xFFFF );
11124
 
 
11125
 
        pSharedInfo->ChipConfig.usMaxPhasingTssts = (UINT16)( f_pChipOpen->ulMaxPhasingTssts & 0xFFFF );
11126
 
        pSharedInfo->ChipConfig.usMaxAdpcmChannels = (UINT16)( f_pChipOpen->ulMaxAdpcmChannels & 0xFFFF );
11127
 
        pSharedInfo->ChipConfig.byMaxTdmStreams = (UINT8)( f_pChipOpen->ulMaxTdmStreams & 0xFF );
11128
 
        pSharedInfo->ChipConfig.fUseSynchTimestamp = (UINT8)( f_pChipOpen->fUseSynchTimestamp & 0xFF );
11129
 
        for ( i = 0; i < 4; i++ )
11130
 
        {
11131
 
                pSharedInfo->ChipConfig.ausTimestampTimeslots[ i ] = (UINT16)( f_pChipOpen->aulTimestampTimeslots[ i ] & 0xFFFF );
11132
 
                pSharedInfo->ChipConfig.ausTimestampStreams[ i ]  = (UINT16)( f_pChipOpen->aulTimestampStreams[ i ] & 0xFFFF );
11133
 
        }
11134
 
        pSharedInfo->ChipConfig.byInterruptPolarity = (UINT8)( f_pChipOpen->ulInterruptPolarity & 0xFF );
11135
 
 
11136
 
        pSharedInfo->ChipConfig.byTdmSampling = (UINT8)( f_pChipOpen->ulTdmSampling & 0xFF );
11137
 
        pSharedInfo->ChipConfig.fEnableFastH100Mode = (UINT8)( f_pChipOpen->fEnableFastH100Mode & 0xFF );
11138
 
 
11139
 
        for ( i = 0; i < cOCT6100_TDM_STREAM_MAX_GROUPS; i++ )
11140
 
        {
11141
 
                if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
11142
 
                        pSharedInfo->ChipConfig.aulTdmStreamFreqs[ i ] = cOCT6100_TDM_STREAM_FREQ_16MHZ;
11143
 
                else
11144
 
                        pSharedInfo->ChipConfig.aulTdmStreamFreqs[ i ] = f_pChipOpen->aulTdmStreamFreqs[ i ];
11145
 
        }
11146
 
        
11147
 
        pSharedInfo->ChipConfig.fEnableFastH100Mode = (UINT8)( f_pChipOpen->fEnableFastH100Mode & 0xFF );
11148
 
        pSharedInfo->ChipConfig.fEnableMemClkOut = (UINT8)( f_pChipOpen->fEnableMemClkOut & 0xFF );
11149
 
 
11150
 
        /* Add 1 to the circular buffer such that all user requested events can fit in the circular queue. */
11151
 
        pSharedInfo->ChipConfig.ulSoftToneEventsBufSize = f_pChipOpen->ulSoftToneEventsBufSize + 1;
11152
 
        pSharedInfo->ChipConfig.fEnableExtToneDetection = (UINT8)( f_pChipOpen->fEnableExtToneDetection & 0xFF );
11153
 
 
11154
 
        if ( f_pChipOpen->ulSoftBufferPlayoutEventsBufSize != cOCT6100_INVALID_VALUE )
11155
 
                pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize = f_pChipOpen->ulSoftBufferPlayoutEventsBufSize + 1;
11156
 
        else
11157
 
                pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize = 0;
11158
 
        pSharedInfo->ChipConfig.usMaxRemoteDebugSessions = (UINT16)( f_pChipOpen->ulMaxRemoteDebugSessions & 0xFFFF );
11159
 
 
11160
 
        pSharedInfo->ChipConfig.fEnableChannelRecording = (UINT8)( f_pChipOpen->fEnableChannelRecording & 0xFF );
11161
 
 
11162
 
 
11163
 
 
11164
 
        pSharedInfo->ChipConfig.fEnableProductionBist = (UINT8)( f_pChipOpen->fEnableProductionBist & 0xFF );
11165
 
        pSharedInfo->ChipConfig.ulNumProductionBistLoops  = f_pChipOpen->ulNumProductionBistLoops;
11166
 
 
11167
 
        return cOCT6100_ERR_OK;
11168
 
}
11169
 
 
11170
 
 
11171
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11172
 
 
11173
 
Function:               Oct6100ApiInitializeMiscellaneousVariables
11174
 
 
11175
 
Description:    Function where all the various parameters from the API instance 
11176
 
                                are set to their defaults value.
11177
 
 
11178
 
-------------------------------------------------------------------------------
11179
 
|       Argument                |       Description
11180
 
-------------------------------------------------------------------------------
11181
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
11182
 
                                                present state of the chip and all its resources.
11183
 
 
11184
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11185
 
static UINT32 Oct6100ApiInitializeMiscellaneousVariables(
11186
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
11187
 
{
11188
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
11189
 
        UINT32  i;
11190
 
 
11191
 
        /* Obtain pointer to shared portion of instance. */
11192
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11193
 
 
11194
 
        /* Calculate the total memory available. */
11195
 
        pSharedInfo->MiscVars.ulTotalMemSize = pSharedInfo->ChipConfig.ulMemoryChipSize * pSharedInfo->ChipConfig.byNumMemoryChips;
11196
 
 
11197
 
        /* Software buffers initialization. */
11198
 
 
11199
 
        /* Tones */
11200
 
        pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0;
11201
 
        pSharedInfo->SoftBufs.ulToneEventBufferReadPtr = 0;
11202
 
        pSharedInfo->SoftBufs.ulToneEventBufferSize = pSharedInfo->ChipConfig.ulSoftToneEventsBufSize;
11203
 
        pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt = 0;
11204
 
 
11205
 
        /* Playout */
11206
 
        pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr = 0;
11207
 
        pSharedInfo->SoftBufs.ulBufPlayoutEventBufferReadPtr = 0;
11208
 
        pSharedInfo->SoftBufs.ulBufPlayoutEventBufferSize = pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize;
11209
 
        pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt = 0;
11210
 
 
11211
 
        /* Set the number of conference bridges opened to zero. */
11212
 
        pSharedInfo->MiscVars.usNumBridgesOpened = 0;
11213
 
        pSharedInfo->MiscVars.usFirstBridge = cOCT6100_INVALID_INDEX;
11214
 
        
11215
 
        /* Set the H.100 slave mode. */
11216
 
        pSharedInfo->MiscVars.ulH100SlaveMode = cOCT6100_H100_TRACKA;
11217
 
 
11218
 
        /* Save the Mclk value.*/
11219
 
        pSharedInfo->MiscVars.ulMclkFreq = pSharedInfo->ChipConfig.ulMemClkFreq;
11220
 
 
11221
 
        /* Init the NLP params. */
11222
 
        pSharedInfo->MiscVars.usCodepoint = 0;
11223
 
        pSharedInfo->MiscVars.usCpuLsuWritePtr = 0;
11224
 
 
11225
 
        /* Pouch counter not present until TLVs are read. */
11226
 
        pSharedInfo->DebugInfo.fPouchCounter = FALSE;
11227
 
        pSharedInfo->DebugInfo.fIsIsrCalledField = FALSE;
11228
 
 
11229
 
        /* Initialize the image info parameters */
11230
 
        pSharedInfo->ImageInfo.fAdaptiveNoiseReduction          = FALSE;
11231
 
        pSharedInfo->ImageInfo.fSoutNoiseBleaching                      = FALSE;
11232
 
        pSharedInfo->ImageInfo.fComfortNoise                            = FALSE;
11233
 
        pSharedInfo->ImageInfo.fBufferPlayout                           = TRUE;
11234
 
        pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip       = FALSE; 
11235
 
        pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip        = FALSE;
11236
 
        pSharedInfo->ImageInfo.fNlpControl                                      = FALSE;
11237
 
        pSharedInfo->ImageInfo.fRinAutoLevelControl                     = FALSE;
11238
 
        pSharedInfo->ImageInfo.fSoutAutoLevelControl            = FALSE;
11239
 
        pSharedInfo->ImageInfo.fRinHighLevelCompensation        = FALSE;
11240
 
        pSharedInfo->ImageInfo.fSoutHighLevelCompensation       = FALSE;
11241
 
        pSharedInfo->ImageInfo.fAlcHlcStatus                            = FALSE;
11242
 
        pSharedInfo->ImageInfo.fRinDcOffsetRemoval                      = FALSE;
11243
 
        pSharedInfo->ImageInfo.fSilenceSuppression                      = FALSE;
11244
 
        pSharedInfo->ImageInfo.fSinDcOffsetRemoval                      = FALSE;
11245
 
        pSharedInfo->ImageInfo.fToneDisabler                            = FALSE;
11246
 
        pSharedInfo->ImageInfo.fAdpcm                                           = FALSE;
11247
 
        pSharedInfo->ImageInfo.fTailDisplacement                        = FALSE;
11248
 
        pSharedInfo->ImageInfo.fConferencing                            = FALSE;
11249
 
        pSharedInfo->ImageInfo.fConferencingNoiseReduction      = FALSE;
11250
 
        pSharedInfo->ImageInfo.fDominantSpeakerEnabled          = FALSE;
11251
 
        pSharedInfo->ImageInfo.fAecEnabled                                      = FALSE;
11252
 
        pSharedInfo->ImageInfo.fAcousticEcho                            = FALSE;
11253
 
        pSharedInfo->ImageInfo.fToneRemoval                                     = FALSE;
11254
 
 
11255
 
        pSharedInfo->ImageInfo.fDefaultErl                                      = FALSE;
11256
 
        pSharedInfo->ImageInfo.fMaxEchoPoint                            = FALSE;
11257
 
        pSharedInfo->ImageInfo.fNonLinearityBehaviorA           = FALSE;
11258
 
        pSharedInfo->ImageInfo.fNonLinearityBehaviorB           = FALSE;
11259
 
        pSharedInfo->ImageInfo.fPerChannelTailDisplacement      = FALSE;
11260
 
        pSharedInfo->ImageInfo.fPerChannelTailLength            = FALSE;
11261
 
        pSharedInfo->ImageInfo.fAfTailDisplacement                      = FALSE;
11262
 
        pSharedInfo->ImageInfo.fMusicProtection                         = FALSE;
11263
 
        pSharedInfo->ImageInfo.fAftControl                                      = FALSE;
11264
 
        pSharedInfo->ImageInfo.fSinVoiceDetectedStat            = FALSE;
11265
 
        pSharedInfo->ImageInfo.fRinAppliedGainStat                      = FALSE;
11266
 
        pSharedInfo->ImageInfo.fSoutAppliedGainStat                     = FALSE;
11267
 
        pSharedInfo->ImageInfo.fListenerEnhancement                     = FALSE;
11268
 
        pSharedInfo->ImageInfo.fRoutNoiseReduction                      = FALSE;
11269
 
        pSharedInfo->ImageInfo.fAnrSnrEnhancement                       = FALSE;
11270
 
        pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation        = FALSE;
11271
 
        pSharedInfo->ImageInfo.fRinMute                                         = FALSE;
11272
 
        pSharedInfo->ImageInfo.fSinMute                                         = FALSE;
11273
 
        pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay = FALSE;
11274
 
        pSharedInfo->ImageInfo.fAecTailLength                           = FALSE;
11275
 
        pSharedInfo->ImageInfo.fMusicProtectionConfiguration= FALSE;
11276
 
        pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents       = FALSE;
11277
 
        pSharedInfo->ImageInfo.fRinEnergyStat                           = FALSE;
11278
 
        pSharedInfo->ImageInfo.fSoutEnergyStat                          = FALSE;
11279
 
        pSharedInfo->ImageInfo.fDoubleTalkBehavior                      = FALSE;
11280
 
        pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst     = FALSE;
11281
 
        pSharedInfo->ImageInfo.fIdleCodeDetection                       = TRUE;
11282
 
        pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration = FALSE;
11283
 
        pSharedInfo->ImageInfo.fSinLevel                                        = TRUE;
11284
 
 
11285
 
        pSharedInfo->ImageInfo.usMaxNumberOfChannels            = 0;
11286
 
        pSharedInfo->ImageInfo.ulToneProfileNumber                      = cOCT6100_INVALID_VALUE;
11287
 
        pSharedInfo->ImageInfo.ulBuildId                                        = cOCT6100_INVALID_VALUE;
11288
 
        pSharedInfo->ImageInfo.byImageType                                      = cOCT6100_IMAGE_TYPE_WIRELINE;
11289
 
        pSharedInfo->ImageInfo.usMaxTailDisplacement            = 0;
11290
 
        pSharedInfo->ImageInfo.usMaxTailLength                          = cOCT6100_TAIL_LENGTH_128MS;
11291
 
        pSharedInfo->DebugInfo.ulDebugEventSize                         = 0x100;
11292
 
        pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents         = 32;
11293
 
        pSharedInfo->DebugInfo.ulMatrixBaseAddress                      = cOCT6100_MATRIX_DWORD_BASE;
11294
 
        pSharedInfo->DebugInfo.ulDebugChanStatsByteSize         = cOCT6100_DEBUG_CHAN_STATS_EVENT_BYTE_SIZE;
11295
 
        pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize     = cOCT6100_DEBUG_CHAN_STATS_LITE_EVENT_BYTE_SIZE;
11296
 
        pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress= cOCT6100_MATRIX_CHAN_SELECT_DWORD_ADD;
11297
 
        pSharedInfo->DebugInfo.ulMatrixTimestampBaseAddress = cOCT6100_MATRIX_TIMESTAMP_DWORD_ADD;
11298
 
        pSharedInfo->DebugInfo.ulMatrixWpBaseAddress            = cOCT6100_MATRIX_WRITE_PTR_DWORD_ADD;
11299
 
        pSharedInfo->DebugInfo.ulAfWritePtrByteOffset           = 206;
11300
 
        pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize       = 4096;
11301
 
        pSharedInfo->DebugInfo.ulAfEventCbByteSize                      = 0x100000;
11302
 
 
11303
 
        /* Set all tones to invalid. */
11304
 
        pSharedInfo->ImageInfo.byNumToneDetectors = 0;
11305
 
        for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ )
11306
 
        {
11307
 
                pSharedInfo->ImageInfo.aToneInfo[ i ].ulToneID = cOCT6100_INVALID_VALUE;
11308
 
                pSharedInfo->ImageInfo.aToneInfo[ i ].ulDetectionPort = cOCT6100_INVALID_PORT;
11309
 
                Oct6100UserMemSet( pSharedInfo->ImageInfo.aToneInfo[ i ].aszToneName, 0x00, cOCT6100_TLV_MAX_TONE_NAME_SIZE );
11310
 
        }
11311
 
        /* Initialize the channel recording info. */
11312
 
        pSharedInfo->DebugInfo.usRecordChanIndex = pSharedInfo->ChipConfig.usMaxChannels;
11313
 
        pSharedInfo->DebugInfo.usRecordMemIndex = cOCT6100_INVALID_INDEX;
11314
 
        
11315
 
        pSharedInfo->DebugInfo.usCurrentDebugChanIndex = cOCT6100_INVALID_INDEX;
11316
 
        /* Initialize the mixer information. */
11317
 
        pSharedInfo->MixerInfo.usFirstBridgeEventPtr    = cOCT6100_INVALID_INDEX;
11318
 
        pSharedInfo->MixerInfo.usFirstSinCopyEventPtr   = cOCT6100_INVALID_INDEX;
11319
 
        pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr  = cOCT6100_INVALID_INDEX;
11320
 
        pSharedInfo->MixerInfo.usLastBridgeEventPtr             = cOCT6100_INVALID_INDEX;
11321
 
        pSharedInfo->MixerInfo.usLastSinCopyEventPtr    = cOCT6100_INVALID_INDEX;
11322
 
        pSharedInfo->MixerInfo.usLastSoutCopyEventPtr   = cOCT6100_INVALID_INDEX;
11323
 
        
11324
 
        pSharedInfo->MixerInfo.usRecordCopyEventIndex   = cOCT6100_INVALID_INDEX;
11325
 
        pSharedInfo->MixerInfo.usRecordSinEventIndex    = cOCT6100_INVALID_INDEX;
11326
 
 
11327
 
        return cOCT6100_ERR_OK;
11328
 
}
11329
 
 
11330
 
 
11331
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11332
 
 
11333
 
Function:               Oct6100ApiCalculateInstanceSizes
11334
 
 
11335
 
Description:    Calculates the amount of memory needed for the instance
11336
 
                                structure memory block based on the user's configuration.  
11337
 
 
11338
 
-------------------------------------------------------------------------------
11339
 
|       Argument                |       Description
11340
 
-------------------------------------------------------------------------------
11341
 
f_pChipOpen                     Pointer to user chip configuration structure.
11342
 
 
11343
 
f_pInstSizes            Pointer to structure containing the size of memory needed
11344
 
                                        by all pointers internal to the API instance.  The memory
11345
 
                                        is needed to keep track of the present state of all the
11346
 
                                        chip's resources.
11347
 
 
11348
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11349
 
static UINT32 Oct6100ApiCalculateInstanceSizes(
11350
 
                                IN OUT  tPOCT6100_CHIP_OPEN                             f_pChipOpen,
11351
 
                                OUT             tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
11352
 
{
11353
 
        UINT32  ulApiInstProcessSpecific;
11354
 
        UINT32  ulTempVar;
11355
 
        UINT32  ulResult;
11356
 
 
11357
 
        /* Start with all instance sizes set to 0. */
11358
 
        Oct6100UserMemSet( f_pInstSizes, 0x00, sizeof( tOCT6100_API_INSTANCE_SIZES ) );
11359
 
 
11360
 
        /* All memory sizes are rounded up to the next multiple of 64 bytes. */
11361
 
 
11362
 
        /*-----------------------------------------------------------------------------*/
11363
 
        /* Obtain size of static members of API instance. */
11364
 
        f_pInstSizes->ulApiInstStatic = sizeof( tOCT6100_SHARED_INFO );
11365
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulApiInstStatic, ulTempVar )
11366
 
 
11367
 
        /* Calculate memory needed by pointers internal to the API instance. */
11368
 
 
11369
 
        /*-----------------------------------------------------------------------------*/
11370
 
        /* Calculate memory needed for the EC channels. */
11371
 
        ulResult = Oct6100ApiGetChannelsEchoSwSizes( f_pChipOpen, f_pInstSizes );
11372
 
        if ( ulResult != cOCT6100_ERR_OK )
11373
 
                return ulResult;
11374
 
 
11375
 
        /*-----------------------------------------------------------------------------*/
11376
 
        /* Memory needed by the TSI structures. */
11377
 
        ulResult = Oct6100ApiGetTsiCnctSwSizes( f_pChipOpen, f_pInstSizes );
11378
 
        if ( ulResult != cOCT6100_ERR_OK )
11379
 
                return ulResult;
11380
 
 
11381
 
        /*-----------------------------------------------------------------------------*/
11382
 
        /* Calculate memory needed for the conference bridges. */
11383
 
        ulResult = Oct6100ApiGetConfBridgeSwSizes( f_pChipOpen, f_pInstSizes );
11384
 
        if ( ulResult != cOCT6100_ERR_OK )
11385
 
                return ulResult;
11386
 
 
11387
 
        /*-----------------------------------------------------------------------------*/
11388
 
        /* Memory needed by the buffer playout structures. */
11389
 
        ulResult = Oct6100ApiGetPlayoutBufferSwSizes( f_pChipOpen, f_pInstSizes );
11390
 
        if ( ulResult != cOCT6100_ERR_OK )
11391
 
                return ulResult;
11392
 
 
11393
 
 
11394
 
 
11395
 
        /*-----------------------------------------------------------------------------*/
11396
 
        /* Memory needed by soft Rx Event buffers. */
11397
 
        ulResult = Oct6100ApiGetEventsSwSizes( f_pChipOpen, f_pInstSizes );
11398
 
        if ( ulResult != cOCT6100_ERR_OK )
11399
 
                return ulResult;
11400
 
 
11401
 
        /*-----------------------------------------------------------------------------*/
11402
 
        /* Calculate memory needed for phasing tssts. */
11403
 
        ulResult = Oct6100ApiGetPhasingTsstSwSizes( f_pChipOpen, f_pInstSizes );
11404
 
        if ( ulResult != cOCT6100_ERR_OK )
11405
 
                return ulResult;
11406
 
 
11407
 
        /*-----------------------------------------------------------------------------*/
11408
 
        /* Calculate memory needed for the ADPCM channels. */
11409
 
        ulResult = Oct6100ApiGetAdpcmChanSwSizes( f_pChipOpen, f_pInstSizes );
11410
 
        if ( ulResult != cOCT6100_ERR_OK )
11411
 
                return ulResult;
11412
 
 
11413
 
        /*-----------------------------------------------------------------------------*/
11414
 
        /* Calculate memory needed for the management of TSSTs. */
11415
 
        ulResult = Oct6100ApiGetTsstSwSizes( f_pInstSizes );
11416
 
        if ( ulResult != cOCT6100_ERR_OK )
11417
 
                return ulResult;
11418
 
 
11419
 
        /*-----------------------------------------------------------------------------*/
11420
 
        /* Calculate memory needed for the management of the mixer. */
11421
 
        ulResult = Oct6100ApiGetMixerSwSizes( f_pChipOpen, f_pInstSizes );
11422
 
        if ( ulResult != cOCT6100_ERR_OK )
11423
 
                return ulResult;
11424
 
 
11425
 
        /*-----------------------------------------------------------------------------*/
11426
 
        /* Determine amount of memory needed for memory allocation softwares.  These
11427
 
                pieces of software will be responsible for the allocation of the chip's
11428
 
                external memory and API memory. */
11429
 
        ulResult = Oct6100ApiGetMemorySwSizes( f_pChipOpen, f_pInstSizes );
11430
 
        if ( ulResult != cOCT6100_ERR_OK )
11431
 
                return ulResult;
11432
 
        
11433
 
        /*-----------------------------------------------------------------------------*/
11434
 
        /* Memory needed for remote debugging sessions. */
11435
 
        ulResult = Oct6100ApiGetRemoteDebugSwSizes( f_pChipOpen, f_pInstSizes );
11436
 
        if ( ulResult != cOCT6100_ERR_OK )
11437
 
                return ulResult;
11438
 
        
11439
 
        /*-----------------------------------------------------------------------------*/
11440
 
        /* Calculate total memory needed by pointers internal to API instance.  The
11441
 
                total contains both the process specific portion of the instance
11442
 
                (tOCT6100_INSTANCE_API) and the shared portion (tOCT6100_SHARED_INFO).  The
11443
 
                process specific portion will be used only in the case where the host system
11444
 
                is a single-process one. */
11445
 
 
11446
 
        ulApiInstProcessSpecific = sizeof( tOCT6100_INSTANCE_API );
11447
 
        mOCT6100_ROUND_MEMORY_SIZE( ulApiInstProcessSpecific, ulTempVar )
11448
 
 
11449
 
        f_pInstSizes->ulApiInstTotal = 
11450
 
                                                                        f_pInstSizes->ulChannelList +
11451
 
                                                                        f_pInstSizes->ulChannelAlloc +
11452
 
                                                                        f_pInstSizes->ulTsiCnctList +
11453
 
                                                                        f_pInstSizes->ulTsiCnctAlloc +
11454
 
                                                                        f_pInstSizes->ulSoftToneEventsBuffer + 
11455
 
                                                                        f_pInstSizes->ulSoftBufPlayoutEventsBuffer +
11456
 
                                                                        f_pInstSizes->ulBiDirChannelList +
11457
 
                                                                        f_pInstSizes->ulBiDirChannelAlloc +
11458
 
                                                                        f_pInstSizes->ulConfBridgeList +
11459
 
                                                                        f_pInstSizes->ulConfBridgeAlloc +
11460
 
                                                                        f_pInstSizes->ulFlexConfParticipantsList +
11461
 
                                                                        f_pInstSizes->ulFlexConfParticipantsAlloc +
11462
 
                                                                        f_pInstSizes->ulPlayoutBufList +
11463
 
                                                                        f_pInstSizes->ulPlayoutBufAlloc +
11464
 
                                                                        f_pInstSizes->ulPlayoutBufMemoryNodeList +
11465
 
 
11466
 
                                                                        f_pInstSizes->ulCopyEventList +
11467
 
                                                                        f_pInstSizes->ulCopyEventAlloc +
11468
 
                                                                        f_pInstSizes->ulMixerEventList +
11469
 
                                                                        f_pInstSizes->ulMixerEventAlloc +
11470
 
                                                                        f_pInstSizes->ulPhasingTsstList +
11471
 
                                                                        f_pInstSizes->ulPhasingTsstAlloc +
11472
 
                                                                        f_pInstSizes->ulAdpcmChannelList + 
11473
 
                                                                        f_pInstSizes->ulAdpcmChannelAlloc + 
11474
 
                                                                        f_pInstSizes->ulConversionMemoryAlloc +
11475
 
                                                                        f_pInstSizes->ulTsiMemoryAlloc +
11476
 
                                                                        f_pInstSizes->ulRemoteDebugList +
11477
 
                                                                        f_pInstSizes->ulRemoteDebugTree +
11478
 
                                                                        f_pInstSizes->ulRemoteDebugPktCache +
11479
 
                                                                        f_pInstSizes->ulRemoteDebugDataBuf +
11480
 
                                                                        f_pInstSizes->ulTsstEntryList +
11481
 
                                                                        f_pInstSizes->ulTsstEntryAlloc +                                                                        
11482
 
                                                                        f_pInstSizes->ulTsstAlloc + 
11483
 
                                                                        f_pInstSizes->ulApiInstStatic + 
11484
 
                                                                        ulApiInstProcessSpecific;
11485
 
        
11486
 
        return cOCT6100_ERR_OK;
11487
 
}
11488
 
 
11489
 
 
11490
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11491
 
 
11492
 
Function:               Oct6100ApiAllocateInstanceMemory
11493
 
 
11494
 
Description:    Allocates the API instance memory to the various members of
11495
 
                                the structure f_pApiInstance according to the sizes contained
11496
 
                                in f_pInstSizes.  No initialization of this memory is
11497
 
                                performed.
11498
 
 
11499
 
-------------------------------------------------------------------------------
11500
 
|       Argument                |       Description
11501
 
-------------------------------------------------------------------------------
11502
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
11503
 
                                        present state of the chip and all its resources.
11504
 
 
11505
 
f_pInstSizes            Pointer to structure containing the size of memory needed
11506
 
                                        by all pointers internal to the API instance.  The memory
11507
 
                                        is needed to keep track of the present state of all the
11508
 
                                        chip's resources.
11509
 
 
11510
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11511
 
static UINT32 Oct6100ApiAllocateInstanceMemory(
11512
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
11513
 
                                IN              tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
11514
 
{
11515
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
11516
 
        UINT32  ulOffset;
11517
 
 
11518
 
        /* Get local pointer to shared portion of instance. */
11519
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11520
 
 
11521
 
        /* Get address of first UINT32 of memory in API instance structure following */
11522
 
        /* the static members of the API instance structure. */
11523
 
        ulOffset = f_pInstSizes->ulApiInstStatic;
11524
 
 
11525
 
        /*===================================================================*/
11526
 
        /* Allocate memory for the echo channels.*/
11527
 
        pSharedInfo->ulChannelListOfst = ulOffset;
11528
 
        ulOffset += f_pInstSizes->ulChannelList;
11529
 
        pSharedInfo->ulChannelAllocOfst = ulOffset;
11530
 
        ulOffset += f_pInstSizes->ulChannelAlloc;
11531
 
 
11532
 
        /*===================================================================*/
11533
 
        /* Allocate memory for the TSI connections */
11534
 
        pSharedInfo->ulTsiCnctListOfst = ulOffset;
11535
 
        ulOffset += f_pInstSizes->ulTsiCnctList;
11536
 
        pSharedInfo->ulTsiCnctAllocOfst = ulOffset;
11537
 
        ulOffset += f_pInstSizes->ulTsiCnctAlloc;
11538
 
        pSharedInfo->ulMixerEventListOfst = ulOffset;
11539
 
        ulOffset += f_pInstSizes->ulMixerEventList;
11540
 
        pSharedInfo->ulMixerEventAllocOfst = ulOffset;
11541
 
        ulOffset += f_pInstSizes->ulMixerEventAlloc;
11542
 
 
11543
 
        pSharedInfo->ulBiDirChannelListOfst = ulOffset;
11544
 
        ulOffset += f_pInstSizes->ulBiDirChannelList;
11545
 
        pSharedInfo->ulBiDirChannelAllocOfst = ulOffset;
11546
 
        ulOffset += f_pInstSizes->ulBiDirChannelAlloc;
11547
 
        pSharedInfo->ulCopyEventListOfst = ulOffset;
11548
 
        ulOffset += f_pInstSizes->ulCopyEventList;
11549
 
        pSharedInfo->ulCopyEventAllocOfst = ulOffset;
11550
 
        ulOffset += f_pInstSizes->ulCopyEventAlloc;
11551
 
 
11552
 
        /*===================================================================*/
11553
 
        /* Allocate memory for the conference bridges */
11554
 
        pSharedInfo->ulConfBridgeListOfst = ulOffset;
11555
 
        ulOffset += f_pInstSizes->ulConfBridgeList;
11556
 
        pSharedInfo->ulConfBridgeAllocOfst = ulOffset;
11557
 
        ulOffset += f_pInstSizes->ulConfBridgeAlloc;
11558
 
 
11559
 
        /*===================================================================*/
11560
 
        /* Allocate memory for the flexible conferencing participants. */
11561
 
        pSharedInfo->ulFlexConfParticipantListOfst = ulOffset;
11562
 
        ulOffset += f_pInstSizes->ulFlexConfParticipantsList;
11563
 
        pSharedInfo->ulFlexConfParticipantAllocOfst = ulOffset;
11564
 
        ulOffset += f_pInstSizes->ulFlexConfParticipantsAlloc;
11565
 
 
11566
 
        /*===================================================================*/
11567
 
        /* Allocate memory for the play-out buffers */
11568
 
        pSharedInfo->ulPlayoutBufListOfst = ulOffset;
11569
 
        ulOffset += f_pInstSizes->ulPlayoutBufList;
11570
 
        pSharedInfo->ulPlayoutBufAllocOfst = ulOffset;
11571
 
        ulOffset += f_pInstSizes->ulPlayoutBufAlloc;
11572
 
        pSharedInfo->ulPlayoutBufMemoryNodeListOfst = ulOffset;
11573
 
        ulOffset += f_pInstSizes->ulPlayoutBufMemoryNodeList;
11574
 
 
11575
 
 
11576
 
        
11577
 
        /*===================================================================*/
11578
 
        /* Allocate memory for the phasing TSSTs */
11579
 
        pSharedInfo->ulPhasingTsstListOfst = ulOffset;
11580
 
        ulOffset += f_pInstSizes->ulPhasingTsstList;
11581
 
        pSharedInfo->ulPhasingTsstAllocOfst = ulOffset;
11582
 
        ulOffset += f_pInstSizes->ulPhasingTsstAlloc;
11583
 
 
11584
 
        /*===================================================================*/
11585
 
        /* Allocate memory for the ADPCM channel */
11586
 
        pSharedInfo->ulAdpcmChanAllocOfst = ulOffset;
11587
 
        ulOffset += f_pInstSizes->ulAdpcmChannelAlloc;
11588
 
        pSharedInfo->ulAdpcmChanListOfst = ulOffset;
11589
 
        ulOffset += f_pInstSizes->ulAdpcmChannelList;
11590
 
        
11591
 
        /*===================================================================*/
11592
 
        /* Allocate memory for the conversion memory */
11593
 
        pSharedInfo->ulConversionMemoryAllocOfst = ulOffset;
11594
 
        ulOffset += f_pInstSizes->ulConversionMemoryAlloc;
11595
 
 
11596
 
        /*===================================================================*/
11597
 
        /* Allocate memory for the TSI chariot memory */
11598
 
        pSharedInfo->ulTsiMemoryAllocOfst = ulOffset;
11599
 
        ulOffset += f_pInstSizes->ulTsiMemoryAlloc;
11600
 
        
11601
 
        /*===================================================================*/
11602
 
        /* Allocate memory for the TSST management */
11603
 
        pSharedInfo->ulTsstAllocOfst = ulOffset;
11604
 
        ulOffset += f_pInstSizes->ulTsstAlloc;
11605
 
        pSharedInfo->ulTsstListOfst = ulOffset;
11606
 
        ulOffset += f_pInstSizes->ulTsstEntryList;
11607
 
        pSharedInfo->ulTsstListAllocOfst = ulOffset;
11608
 
        ulOffset += f_pInstSizes->ulTsstEntryAlloc;
11609
 
 
11610
 
        /*===================================================================*/
11611
 
        pSharedInfo->SoftBufs.ulToneEventBufferMemOfst = ulOffset;
11612
 
        ulOffset += f_pInstSizes->ulSoftToneEventsBuffer;
11613
 
 
11614
 
        pSharedInfo->SoftBufs.ulBufPlayoutEventBufferMemOfst = ulOffset;
11615
 
        ulOffset += f_pInstSizes->ulSoftBufPlayoutEventsBuffer;
11616
 
        /*===================================================================*/
11617
 
        pSharedInfo->RemoteDebugInfo.ulSessionListOfst = ulOffset;
11618
 
        ulOffset += f_pInstSizes->ulRemoteDebugList;
11619
 
 
11620
 
        pSharedInfo->RemoteDebugInfo.ulSessionTreeOfst = ulOffset;
11621
 
        ulOffset += f_pInstSizes->ulRemoteDebugTree;
11622
 
 
11623
 
        pSharedInfo->RemoteDebugInfo.ulDataBufOfst = ulOffset;
11624
 
        ulOffset += f_pInstSizes->ulRemoteDebugDataBuf;
11625
 
 
11626
 
        pSharedInfo->RemoteDebugInfo.ulPktCacheOfst = ulOffset;
11627
 
        ulOffset += f_pInstSizes->ulRemoteDebugPktCache;
11628
 
        /*===================================================================*/
11629
 
 
11630
 
        return cOCT6100_ERR_OK;
11631
 
}
11632
 
 
11633
 
 
11634
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11635
 
 
11636
 
Function:               Oct6100ApiInitializeInstanceMemory
11637
 
 
11638
 
Description:    Initializes the various members of the structure f_pApiInstance
11639
 
                                to reflect the current state of the chip and its resources.
11640
 
 
11641
 
-------------------------------------------------------------------------------
11642
 
|       Argument                |       Description
11643
 
-------------------------------------------------------------------------------
11644
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
11645
 
                                        present state of the chip and all its resources.
11646
 
 
11647
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11648
 
static UINT32 Oct6100ApiInitializeInstanceMemory(
11649
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
11650
 
{
11651
 
        UINT32  ulResult;
11652
 
 
11653
 
        /*-----------------------------------------------------------------------------*/
11654
 
        /* Initialize API EC channels. */
11655
 
        ulResult = Oct6100ApiChannelsEchoSwInit( f_pApiInstance );
11656
 
        if ( ulResult != cOCT6100_ERR_OK )
11657
 
                return ulResult;
11658
 
 
11659
 
        /*-----------------------------------------------------------------------------*/
11660
 
        /* Initialize the API TSI connection structures. */
11661
 
        ulResult = Oct6100ApiTsiCnctSwInit( f_pApiInstance );
11662
 
        if ( ulResult != cOCT6100_ERR_OK )
11663
 
                return ulResult;
11664
 
 
11665
 
        /*-----------------------------------------------------------------------------*/
11666
 
        /* Initialize the API conference bridges. */
11667
 
        ulResult = Oct6100ApiConfBridgeSwInit( f_pApiInstance );
11668
 
        if ( ulResult != cOCT6100_ERR_OK )
11669
 
                return ulResult;
11670
 
 
11671
 
        /*-----------------------------------------------------------------------------*/
11672
 
        /* Initialize the API buffer playout structures. */
11673
 
        ulResult = Oct6100ApiPlayoutBufferSwInit( f_pApiInstance );
11674
 
        if ( ulResult != cOCT6100_ERR_OK )
11675
 
                return ulResult;
11676
 
 
11677
 
        /*-----------------------------------------------------------------------------*/
11678
 
        /* Initialize the API phasing tssts. */
11679
 
        ulResult = Oct6100ApiPhasingTsstSwInit( f_pApiInstance );
11680
 
        if ( ulResult != cOCT6100_ERR_OK )
11681
 
                return ulResult;
11682
 
 
11683
 
        /*-----------------------------------------------------------------------------*/
11684
 
        /* Initialize the API ADPCM channels. */
11685
 
        ulResult = Oct6100ApiAdpcmChanSwInit( f_pApiInstance );
11686
 
        if ( ulResult != cOCT6100_ERR_OK )
11687
 
                return ulResult;
11688
 
 
11689
 
        /*-----------------------------------------------------------------------------*/
11690
 
        /* Initialize the external memory management structures. */
11691
 
        ulResult = Oct6100ApiMemorySwInit( f_pApiInstance );
11692
 
        if ( ulResult != cOCT6100_ERR_OK )
11693
 
                return ulResult;
11694
 
 
11695
 
        /*-----------------------------------------------------------------------------*/
11696
 
        /* Initialize TSST management stuctures. */
11697
 
        ulResult = Oct6100ApiTsstSwInit( f_pApiInstance );
11698
 
        if ( ulResult != cOCT6100_ERR_OK )
11699
 
                return ulResult;
11700
 
 
11701
 
        /*-----------------------------------------------------------------------------*/
11702
 
        /* Initialize the mixer management stuctures. */
11703
 
        ulResult = Oct6100ApiMixerSwInit( f_pApiInstance );
11704
 
        if ( ulResult != cOCT6100_ERR_OK )
11705
 
                return ulResult;
11706
 
 
11707
 
        /*-----------------------------------------------------------------------------*/
11708
 
        /* Initialize the remote debugging session management variables. */
11709
 
        ulResult = Oct6100ApiRemoteDebuggingSwInit( f_pApiInstance );
11710
 
        if ( ulResult != cOCT6100_ERR_OK )
11711
 
                return ulResult;
11712
 
 
11713
 
        /*-----------------------------------------------------------------------------*/
11714
 
        /* Configure the interrupt registers. */
11715
 
        ulResult = Oct6100ApiIsrSwInit( f_pApiInstance );
11716
 
        if ( ulResult != cOCT6100_ERR_OK )
11717
 
                return ulResult;
11718
 
 
11719
 
        return cOCT6100_ERR_OK;
11720
 
}
11721
 
 
11722
 
 
11723
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11724
 
 
11725
 
Function:               Oct6100ApiGetChipRevisionNum
11726
 
 
11727
 
Description:    Reads the chip's revision number register.
11728
 
 
11729
 
-------------------------------------------------------------------------------
11730
 
|       Argument                |       Description
11731
 
-------------------------------------------------------------------------------
11732
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
11733
 
                                                the present state of the chip and all its resources.
11734
 
 
11735
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11736
 
static UINT32 Oct6100ApiGetChipRevisionNum(
11737
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
11738
 
{
11739
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
11740
 
        tOCT6100_READ_PARAMS    ReadParams;
11741
 
        UINT32                                  ulResult;
11742
 
        UINT16                                  usReadData;
11743
 
 
11744
 
        /* Get local pointer to shared portion of instance. */
11745
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11746
 
 
11747
 
        /* Get the chip revision number. */
11748
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
11749
 
 
11750
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
11751
 
        ReadParams.ulReadAddress = cOCT6100_CHIP_ID_REVISION_REG;
11752
 
        ReadParams.pusReadData = &usReadData;
11753
 
 
11754
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
11755
 
        if ( ulResult != cOCT6100_ERR_OK )
11756
 
                return ulResult;
11757
 
 
11758
 
        /* Save the info in the API miscellaneous structure. */
11759
 
        pSharedInfo->MiscVars.usChipId = (UINT16)( usReadData & 0xFF );
11760
 
        pSharedInfo->MiscVars.usChipRevision = (UINT16)( usReadData >> 8 );
11761
 
 
11762
 
        return cOCT6100_ERR_OK;
11763
 
}
11764
 
 
11765
 
 
11766
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11767
 
 
11768
 
Function:               Oct6100ApiDecodeKeyAndBist
11769
 
 
11770
 
Description:    This function decodes the key and runs the automatic BIST.
11771
 
 
11772
 
-------------------------------------------------------------------------------
11773
 
|       Argument                |       Description
11774
 
-------------------------------------------------------------------------------
11775
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
11776
 
                                        present state of the chip and all its resources.
11777
 
 
11778
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11779
 
static UINT32 Oct6100ApiDecodeKeyAndBist(
11780
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
11781
 
{
11782
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
11783
 
        tPOCT6100_API_CHIP_CONFIG       pChipConfig;
11784
 
        tOCT6100_WRITE_PARAMS           WriteParams;
11785
 
        tOCT6100_READ_PARAMS            ReadParams;
11786
 
        UINT16                                          ausBistData[ 3 ];
11787
 
        UINT16                                          usReadData;
11788
 
        UINT32                                          ulResult;
11789
 
        BOOL                                            fBitEqual;
11790
 
        UINT32                                          i;
11791
 
 
11792
 
        /* Get local pointer to shared portion of instance. */
11793
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11794
 
 
11795
 
        /* Obtain a local pointer to the chip config structure */
11796
 
        /* contained in the instance structure. */
11797
 
        pChipConfig = &pSharedInfo->ChipConfig;
11798
 
 
11799
 
        /* Set the process context and user chip ID parameters once and for all. */
11800
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
11801
 
 
11802
 
        WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
11803
 
 
11804
 
        /* Set the process context and user chip ID parameters once and for all. */
11805
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
11806
 
 
11807
 
        ReadParams.ulUserChipId = pChipConfig->ulUserChipId;
11808
 
 
11809
 
        /* Write key in CPU internal memory. */
11810
 
        for(i=0; i<8; i++)
11811
 
        {
11812
 
                WriteParams.ulWriteAddress = 0x150;
11813
 
                WriteParams.usWriteData = 0x0000;
11814
 
                if (( i % 2 ) == 0)
11815
 
                {
11816
 
                        WriteParams.usWriteData  |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 2]) << 8;
11817
 
                        WriteParams.usWriteData  |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 3]) << 0;
11818
 
                }
11819
 
                else
11820
 
                {
11821
 
                        WriteParams.usWriteData  |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 0]) << 8;
11822
 
                        WriteParams.usWriteData  |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 1]) << 0;
11823
 
                }
11824
 
 
11825
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11826
 
                if ( ulResult != cOCT6100_ERR_OK )
11827
 
                        return ulResult;
11828
 
                
11829
 
                WriteParams.ulWriteAddress = 0x152;
11830
 
                WriteParams.usWriteData = (UINT16)( 0x8000 | i );
11831
 
 
11832
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11833
 
                if ( ulResult != cOCT6100_ERR_OK )
11834
 
                        return ulResult;
11835
 
        }
11836
 
 
11837
 
        /* Write one in CPU internal memory. */
11838
 
        for(i=0; i<8; i++)
11839
 
        {
11840
 
                WriteParams.ulWriteAddress = 0x150;
11841
 
                if (i == 0) 
11842
 
                {
11843
 
                        WriteParams.usWriteData = 0x0001;
11844
 
                }
11845
 
                else
11846
 
                {
11847
 
                        WriteParams.usWriteData = 0x0000;
11848
 
                }
11849
 
 
11850
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11851
 
                if ( ulResult != cOCT6100_ERR_OK )
11852
 
                        return ulResult;
11853
 
 
11854
 
                WriteParams.ulWriteAddress = 0x152;
11855
 
                WriteParams.usWriteData = (UINT16)( 0x8000 | ( i + 8 ));
11856
 
 
11857
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11858
 
                if ( ulResult != cOCT6100_ERR_OK )
11859
 
                        return ulResult;
11860
 
        }
11861
 
 
11862
 
        /* Clear memory access registers: */
11863
 
        WriteParams.ulWriteAddress = 0x150;
11864
 
        WriteParams.usWriteData = 0x0000;
11865
 
 
11866
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11867
 
        if ( ulResult != cOCT6100_ERR_OK )
11868
 
                return ulResult;
11869
 
 
11870
 
        WriteParams.ulWriteAddress = 0x152;
11871
 
 
11872
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11873
 
        if ( ulResult != cOCT6100_ERR_OK )
11874
 
                return ulResult;
11875
 
 
11876
 
        /* Run BISTs and key decode. */
11877
 
        WriteParams.ulWriteAddress = 0x160;
11878
 
        WriteParams.usWriteData = 0x0081;
11879
 
 
11880
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11881
 
        if ( ulResult != cOCT6100_ERR_OK )
11882
 
                return ulResult;
11883
 
 
11884
 
        /* Wait for the key decode PC to clear. */
11885
 
        ulResult = Oct6100ApiWaitForPcRegisterBit( f_pApiInstance, 0x160, 0, 0, 100000, &fBitEqual );
11886
 
        if ( TRUE != fBitEqual )
11887
 
                return cOCT6100_ERR_FATAL_13;
11888
 
 
11889
 
        /* Read the key valid bit to make sure everything is ok. */
11890
 
        ReadParams.ulReadAddress = 0x160;
11891
 
        ReadParams.pusReadData = &usReadData;
11892
 
 
11893
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
11894
 
        if ( ulResult != cOCT6100_ERR_OK )
11895
 
                return ulResult;
11896
 
 
11897
 
        /* Either the firmware image was not loaded correctly (from pointer given by user) */
11898
 
        /* or the channel capacity pins of the chip do not match what the firmware is expecting. */
11899
 
        if ( ( usReadData & 0x4 ) == 0 )
11900
 
                return cOCT6100_ERR_OPEN_INVALID_FIRMWARE_OR_CAPACITY_PINS;
11901
 
 
11902
 
        /* Read the result of the internal memory bist. */
11903
 
        ReadParams.ulReadAddress = 0x110;
11904
 
        ReadParams.pusReadData = &ausBistData[ 0 ];
11905
 
 
11906
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
11907
 
        if ( ulResult != cOCT6100_ERR_OK )
11908
 
                return ulResult;
11909
 
 
11910
 
        ReadParams.ulReadAddress = 0x114;
11911
 
        ReadParams.pusReadData = &ausBistData[ 1 ];
11912
 
 
11913
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
11914
 
        if ( ulResult != cOCT6100_ERR_OK )
11915
 
                return ulResult;
11916
 
        
11917
 
        ReadParams.ulReadAddress = 0x118;
11918
 
        ReadParams.pusReadData = &ausBistData[ 2 ];
11919
 
 
11920
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
11921
 
        if ( ulResult != cOCT6100_ERR_OK )
11922
 
                return ulResult;
11923
 
 
11924
 
        /* Check if an error was reported. */
11925
 
        if (ausBistData[0] != 0x0000 || ausBistData[1] != 0x0000 || ausBistData[2] != 0x0000)
11926
 
                return cOCT6100_ERR_OPEN_INTERNAL_MEMORY_BIST;
11927
 
 
11928
 
        /* Put key decoder in powerdown. */
11929
 
        WriteParams.ulWriteAddress = 0x160;
11930
 
        WriteParams.usWriteData = 0x008A;
11931
 
 
11932
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11933
 
        if ( ulResult != cOCT6100_ERR_OK )
11934
 
                return ulResult;
11935
 
 
11936
 
        return cOCT6100_ERR_OK;
11937
 
}
11938
 
 
11939
 
 
11940
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11941
 
 
11942
 
Function:               Oct6100ApiBootFc2Pll
11943
 
 
11944
 
Description:    Configures the chip's FC2 PLL.
11945
 
 
11946
 
-------------------------------------------------------------------------------
11947
 
|       Argument                |       Description
11948
 
-------------------------------------------------------------------------------
11949
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
11950
 
                                        present state of the chip and all its resources.
11951
 
 
11952
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11953
 
static UINT32 Oct6100ApiBootFc2Pll(
11954
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
11955
 
{
11956
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
11957
 
        tPOCT6100_API_CHIP_CONFIG       pChipConfig;
11958
 
        tOCT6100_WRITE_PARAMS           WriteParams;
11959
 
        UINT32                                          aulWaitTime[ 2 ];
11960
 
        UINT32                                          ulResult;
11961
 
        UINT32                                          ulFc2PllDivisor = 0;
11962
 
        UINT32                                          ulMtDivisor = 0;
11963
 
        UINT32                                          ulFcDivisor = 0;
11964
 
 
11965
 
        /* Get local pointer to shared portion of instance. */
11966
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
11967
 
 
11968
 
        /* Obtain local pointer to chip configuration structure. */
11969
 
        pChipConfig = &pSharedInfo->ChipConfig;
11970
 
 
11971
 
        /* Set the process context and user chip ID parameters once and for all. */
11972
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
11973
 
 
11974
 
        WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
11975
 
 
11976
 
        /* First put the chip and main registers in soft-reset. */
11977
 
        WriteParams.ulWriteAddress = 0x100;
11978
 
        WriteParams.usWriteData = 0x0;
11979
 
 
11980
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11981
 
        if ( ulResult != cOCT6100_ERR_OK )
11982
 
                return ulResult;
11983
 
 
11984
 
        /* Select register configuration based on the memory frequency. */
11985
 
        switch ( f_pApiInstance->pSharedInfo->ChipConfig.ulMemClkFreq )
11986
 
        {
11987
 
        case 133000000:
11988
 
                ulFc2PllDivisor = 0x1050;
11989
 
                ulMtDivisor = 0x4300;
11990
 
                ulFcDivisor = 0x4043;
11991
 
                pSharedInfo->MiscVars.usMaxNumberOfChannels = 672;
11992
 
                pSharedInfo->MiscVars.usMaxH100Speed = 124;
11993
 
 
11994
 
                if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
11995
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x050B;
11996
 
                else
11997
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x0516;
11998
 
 
11999
 
                break;
12000
 
        case 125000000:
12001
 
                ulFc2PllDivisor = 0x0F50;
12002
 
                ulMtDivisor = 0x4300;
12003
 
                ulFcDivisor = 0x4043;
12004
 
                pSharedInfo->MiscVars.usMaxNumberOfChannels = 624;
12005
 
                pSharedInfo->MiscVars.usMaxH100Speed = 116;
12006
 
 
12007
 
                if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12008
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x04CA;
12009
 
                else
12010
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x04D4;
12011
 
 
12012
 
                break;
12013
 
        case 117000000:
12014
 
                ulFc2PllDivisor = 0x0E50;
12015
 
                ulMtDivisor = 0x4300;
12016
 
                ulFcDivisor = 0x4043;
12017
 
                pSharedInfo->MiscVars.usMaxNumberOfChannels = 576;
12018
 
                pSharedInfo->MiscVars.usMaxH100Speed = 108;
12019
 
 
12020
 
                if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12021
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x0489;
12022
 
                else
12023
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x0492;
12024
 
 
12025
 
                break;
12026
 
        case 108000000:
12027
 
                ulFc2PllDivisor = 0x0D50;
12028
 
                ulMtDivisor = 0x4300;
12029
 
                ulFcDivisor = 0x4043;
12030
 
                pSharedInfo->MiscVars.usMaxNumberOfChannels = 528;
12031
 
                pSharedInfo->MiscVars.usMaxH100Speed = 99;
12032
 
 
12033
 
                if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12034
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x0408;
12035
 
                else
12036
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x0410;
12037
 
 
12038
 
                break;
12039
 
        case 100000000:
12040
 
                ulFc2PllDivisor = 0x0C50;
12041
 
                ulMtDivisor = 0x4300;
12042
 
                ulFcDivisor = 0x4043;
12043
 
                pSharedInfo->MiscVars.usMaxNumberOfChannels = 480;
12044
 
                pSharedInfo->MiscVars.usMaxH100Speed = 91;
12045
 
 
12046
 
                if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12047
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x03C8;
12048
 
                else
12049
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x03D0;
12050
 
 
12051
 
                break;
12052
 
        case 92000000:
12053
 
                ulFc2PllDivisor = 0x0B50;
12054
 
                ulMtDivisor = 0x4300;
12055
 
                ulFcDivisor = 0x4043;
12056
 
                pSharedInfo->MiscVars.usMaxNumberOfChannels = 432;
12057
 
                pSharedInfo->MiscVars.usMaxH100Speed = 83;
12058
 
 
12059
 
                if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12060
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x0387;
12061
 
                else
12062
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x038E;
12063
 
 
12064
 
                break;
12065
 
        case 83000000:
12066
 
                ulFc2PllDivisor = 0x0A50;
12067
 
                ulMtDivisor = 0x4300;
12068
 
                ulFcDivisor = 0x4043;
12069
 
                pSharedInfo->MiscVars.usMaxNumberOfChannels = 384;
12070
 
                pSharedInfo->MiscVars.usMaxH100Speed = 74;
12071
 
 
12072
 
                if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12073
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x0346;
12074
 
                else
12075
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x034C;
12076
 
 
12077
 
                break;
12078
 
        case 75000000:
12079
 
                ulFc2PllDivisor = 0x0950;
12080
 
                ulMtDivisor = 0x4200;
12081
 
                ulFcDivisor = 0x4043;
12082
 
                pSharedInfo->MiscVars.usMaxNumberOfChannels = 336;
12083
 
                pSharedInfo->MiscVars.usMaxH100Speed = 64;
12084
 
 
12085
 
                if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12086
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x0306;
12087
 
                else
12088
 
                        pSharedInfo->MiscVars.usTdmClkBoundary = 0x030C;
12089
 
 
12090
 
                break;
12091
 
        default:
12092
 
                return cOCT6100_ERR_FATAL_DB;
12093
 
        }
12094
 
 
12095
 
        /* Verify that the max channel is not too big based on the chip frequency. */
12096
 
        if ( pSharedInfo->ChipConfig.usMaxChannels > pSharedInfo->MiscVars.usMaxNumberOfChannels )
12097
 
                return cOCT6100_ERR_OPEN_MAX_ECHO_CHANNELS;
12098
 
        
12099
 
        /* Setup delay chains. */
12100
 
        if ( (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR) ||  (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) )
12101
 
        {
12102
 
                /* SDRAM */
12103
 
                WriteParams.ulWriteAddress = 0x1B0;
12104
 
                WriteParams.usWriteData = 0x1003;
12105
 
 
12106
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12107
 
                if ( ulResult != cOCT6100_ERR_OK )
12108
 
                        return ulResult;
12109
 
 
12110
 
                WriteParams.ulWriteAddress = 0x1B2;
12111
 
                WriteParams.usWriteData = 0x0021;
12112
 
 
12113
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12114
 
                if ( ulResult != cOCT6100_ERR_OK )
12115
 
                        return ulResult;
12116
 
 
12117
 
                WriteParams.ulWriteAddress = 0x1B4;
12118
 
                WriteParams.usWriteData = 0x4030;
12119
 
 
12120
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12121
 
                if ( ulResult != cOCT6100_ERR_OK )
12122
 
                        return ulResult;
12123
 
 
12124
 
                WriteParams.ulWriteAddress = 0x1B6;
12125
 
                WriteParams.usWriteData = 0x0021;
12126
 
 
12127
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12128
 
                if ( ulResult != cOCT6100_ERR_OK )
12129
 
                        return ulResult;
12130
 
        }
12131
 
        else /* if ( cOCT6100_MEM_TYPE_DDR == pChipConfig->byMemoryType ) */
12132
 
        {
12133
 
                /* DDR */
12134
 
                WriteParams.ulWriteAddress = 0x1B0;
12135
 
                WriteParams.usWriteData = 0x201F;
12136
 
 
12137
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12138
 
                if ( ulResult != cOCT6100_ERR_OK )
12139
 
                        return ulResult;
12140
 
 
12141
 
                WriteParams.ulWriteAddress = 0x1B2;
12142
 
                WriteParams.usWriteData = 0x0021;
12143
 
 
12144
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12145
 
                if ( ulResult != cOCT6100_ERR_OK )
12146
 
                        return ulResult;
12147
 
 
12148
 
                WriteParams.ulWriteAddress = 0x1B4;
12149
 
                WriteParams.usWriteData = 0x1000;
12150
 
 
12151
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12152
 
                if ( ulResult != cOCT6100_ERR_OK )
12153
 
                        return ulResult;
12154
 
 
12155
 
                WriteParams.ulWriteAddress = 0x1B6;
12156
 
                WriteParams.usWriteData = 0x0021;
12157
 
 
12158
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12159
 
                if ( ulResult != cOCT6100_ERR_OK )
12160
 
                        return ulResult;
12161
 
        }
12162
 
 
12163
 
        /* udqs */
12164
 
        WriteParams.ulWriteAddress = 0x1B8;
12165
 
        WriteParams.usWriteData = 0x1003;
12166
 
 
12167
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12168
 
        if ( ulResult != cOCT6100_ERR_OK )
12169
 
                return ulResult;
12170
 
 
12171
 
        WriteParams.ulWriteAddress = 0x1BA;
12172
 
        WriteParams.usWriteData = 0x0021;
12173
 
 
12174
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12175
 
        if ( ulResult != cOCT6100_ERR_OK )
12176
 
                return ulResult;
12177
 
 
12178
 
        /* ldqs */
12179
 
        WriteParams.ulWriteAddress = 0x1BC;
12180
 
        WriteParams.usWriteData = 0x1000;
12181
 
 
12182
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12183
 
        if ( ulResult != cOCT6100_ERR_OK )
12184
 
                return ulResult;
12185
 
 
12186
 
        WriteParams.ulWriteAddress = 0x1BE;
12187
 
        WriteParams.usWriteData = 0x0021;
12188
 
 
12189
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12190
 
        if ( ulResult != cOCT6100_ERR_OK )
12191
 
                return ulResult;
12192
 
 
12193
 
        WriteParams.ulWriteAddress = 0x12C;
12194
 
        WriteParams.usWriteData = 0x0000;
12195
 
 
12196
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12197
 
        if ( ulResult != cOCT6100_ERR_OK )
12198
 
                return ulResult;
12199
 
 
12200
 
        WriteParams.ulWriteAddress = 0x12E;
12201
 
        WriteParams.usWriteData = 0x0000;
12202
 
 
12203
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12204
 
        if ( ulResult != cOCT6100_ERR_OK )
12205
 
                return ulResult;
12206
 
 
12207
 
        /* Select fc2pll for fast_clk and mtsclk sources. Select mem_clk_i for afclk. */
12208
 
        WriteParams.ulWriteAddress = 0x140;
12209
 
        WriteParams.usWriteData = (UINT16)ulMtDivisor;
12210
 
 
12211
 
        if ( f_pApiInstance->pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
12212
 
                WriteParams.usWriteData |= 0x0001;
12213
 
        else
12214
 
                WriteParams.usWriteData |= 0x0004;
12215
 
 
12216
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12217
 
        if ( ulResult != cOCT6100_ERR_OK )
12218
 
                return ulResult;
12219
 
 
12220
 
        WriteParams.ulWriteAddress = 0x144;
12221
 
        WriteParams.usWriteData = (UINT16)ulFcDivisor;
12222
 
 
12223
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12224
 
        if ( ulResult != cOCT6100_ERR_OK )
12225
 
                return ulResult;
12226
 
 
12227
 
        WriteParams.ulWriteAddress = 0x13E;
12228
 
        WriteParams.usWriteData = 0x0001;       /*  Remove reset from above divisors */
12229
 
 
12230
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12231
 
        if ( ulResult != cOCT6100_ERR_OK )
12232
 
                return ulResult;
12233
 
 
12234
 
        /* Select upclk directly as ref source for fc2pll. */
12235
 
        WriteParams.ulWriteAddress = 0x134;
12236
 
        if ( pChipConfig->ulUpclkFreq == cOCT6100_UPCLK_FREQ_33_33_MHZ )
12237
 
        {
12238
 
                WriteParams.usWriteData = 0x0001;
12239
 
                        
12240
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12241
 
                if ( ulResult != cOCT6100_ERR_OK )
12242
 
                        return ulResult;
12243
 
        }
12244
 
 
12245
 
        /* Setup fc2pll. */
12246
 
        WriteParams.ulWriteAddress = 0x132;
12247
 
        WriteParams.usWriteData = (UINT16)ulFc2PllDivisor;
12248
 
                
12249
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12250
 
        if ( ulResult != cOCT6100_ERR_OK )
12251
 
                return ulResult;
12252
 
 
12253
 
        WriteParams.usWriteData |= 0x02;        /* Raise fb divisor reset. */
12254
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12255
 
        if ( ulResult != cOCT6100_ERR_OK )
12256
 
                return ulResult;
12257
 
 
12258
 
        WriteParams.usWriteData |= 0x80;        /* Raise IDDTN signal.*/
12259
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12260
 
        if ( ulResult != cOCT6100_ERR_OK )
12261
 
                return ulResult;
12262
 
 
12263
 
        /* Wait for fc2pll to stabilize. */
12264
 
        aulWaitTime[ 0 ] = 2000;
12265
 
        aulWaitTime[ 1 ] = 0;
12266
 
        ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12267
 
        if ( ulResult != cOCT6100_ERR_OK )
12268
 
                return ulResult;
12269
 
 
12270
 
        /* Drive mem_clk_o out on proper interface. */
12271
 
        if ( TRUE == pChipConfig->fEnableMemClkOut )
12272
 
        {
12273
 
                if ( (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS)  )
12274
 
                {
12275
 
                        WriteParams.ulWriteAddress = 0x128;
12276
 
                        WriteParams.usWriteData = 0x0301;
12277
 
 
12278
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12279
 
                        if ( ulResult != cOCT6100_ERR_OK )
12280
 
                                return ulResult;
12281
 
                }
12282
 
        
12283
 
                if ( pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_DDR || pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
12284
 
                {
12285
 
                        WriteParams.ulWriteAddress = 0x12A;
12286
 
                        WriteParams.usWriteData = 0x000F;
12287
 
                        
12288
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12289
 
                        if ( ulResult != cOCT6100_ERR_OK )
12290
 
                                return ulResult;
12291
 
                }
12292
 
        }
12293
 
 
12294
 
        return cOCT6100_ERR_OK;
12295
 
}
12296
 
 
12297
 
 
12298
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12299
 
 
12300
 
Function:               Oct6100ApiProgramFc1Pll
12301
 
 
12302
 
Description:    Configures the chip's FC1 PLL.
12303
 
 
12304
 
-------------------------------------------------------------------------------
12305
 
|       Argument                |       Description
12306
 
-------------------------------------------------------------------------------
12307
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
12308
 
                                        present state of the chip and all its resources.
12309
 
 
12310
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12311
 
static UINT32 Oct6100ApiProgramFc1Pll(
12312
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
12313
 
{
12314
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
12315
 
        tPOCT6100_API_CHIP_CONFIG       pChipConfig;
12316
 
        tOCT6100_WRITE_PARAMS           WriteParams;
12317
 
        UINT32                                          aulWaitTime[ 2 ];
12318
 
        UINT32                                          ulResult;
12319
 
 
12320
 
        /* Get local pointer to shared portion of instance. */
12321
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
12322
 
 
12323
 
        /* Obtain local pointer to chip configuration structure. */
12324
 
        pChipConfig = &pSharedInfo->ChipConfig;
12325
 
 
12326
 
        /* Set the process context and user chip ID parameters once and for all. */
12327
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
12328
 
 
12329
 
        WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
12330
 
 
12331
 
        /* Programm P/Z bits. */
12332
 
        WriteParams.ulWriteAddress = 0x130;
12333
 
        
12334
 
        if ( f_pApiInstance->pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
12335
 
                WriteParams.usWriteData  = 0x0041;
12336
 
        else
12337
 
                WriteParams.usWriteData  = 0x0040;
12338
 
 
12339
 
        WriteParams.usWriteData |= ( pChipConfig->byMemoryType << 8 );
12340
 
        
12341
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12342
 
        if ( ulResult != cOCT6100_ERR_OK )
12343
 
                return ulResult;
12344
 
        
12345
 
        /* Raise FB divisor. */
12346
 
        WriteParams.usWriteData |= 0x0002;
12347
 
        
12348
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12349
 
        if ( ulResult != cOCT6100_ERR_OK )
12350
 
                return ulResult;
12351
 
        
12352
 
        /* Raise IDDTN. */
12353
 
        WriteParams.usWriteData |= 0x0080;
12354
 
        
12355
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12356
 
        if ( ulResult != cOCT6100_ERR_OK )
12357
 
                return ulResult;
12358
 
 
12359
 
        /* Wait for fc1pll to stabilize. */ 
12360
 
        aulWaitTime[ 0 ] = 2000;
12361
 
        aulWaitTime[ 1 ] = 0;
12362
 
        ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12363
 
        if ( ulResult != cOCT6100_ERR_OK )
12364
 
                return ulResult;
12365
 
 
12366
 
        /* Enable all the clock domains to do reset procedure. */
12367
 
        WriteParams.ulWriteAddress = 0x186;
12368
 
        WriteParams.usWriteData  = 0x015F;
12369
 
        
12370
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12371
 
        if ( ulResult != cOCT6100_ERR_OK )
12372
 
                return ulResult;
12373
 
 
12374
 
        aulWaitTime[ 0 ] = 15000;
12375
 
        aulWaitTime[ 1 ] = 0;
12376
 
        ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12377
 
        if ( ulResult != cOCT6100_ERR_OK )
12378
 
                return ulResult;
12379
 
 
12380
 
        return cOCT6100_ERR_OK;
12381
 
}
12382
 
 
12383
 
 
12384
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12385
 
 
12386
 
Function:               Oct6100ApiBootFc1Pll
12387
 
 
12388
 
Description:    Boot the chip's FC1 PLL.
12389
 
 
12390
 
-------------------------------------------------------------------------------
12391
 
|       Argument                |       Description
12392
 
-------------------------------------------------------------------------------
12393
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
12394
 
                                        present state of the chip and all its resources.
12395
 
 
12396
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12397
 
static UINT32 Oct6100ApiBootFc1Pll(
12398
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
12399
 
{
12400
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
12401
 
        tPOCT6100_API_CHIP_CONFIG       pChipConfig;
12402
 
        tOCT6100_WRITE_PARAMS           WriteParams;
12403
 
        UINT32                                          aulWaitTime[ 2 ];
12404
 
        UINT32                                          ulResult;
12405
 
 
12406
 
        /* Get local pointer to shared portion of instance. */
12407
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
12408
 
 
12409
 
        /* Obtain local pointer to chip configuration structure. */
12410
 
        pChipConfig = &pSharedInfo->ChipConfig;
12411
 
 
12412
 
        /* Set the process context and user chip ID parameters once and for all. */
12413
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
12414
 
 
12415
 
        WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
12416
 
 
12417
 
        /* Force bist_clk also (it too is used on resetable flops). */
12418
 
        WriteParams.ulWriteAddress = 0x160;
12419
 
        WriteParams.usWriteData  = 0x0188;
12420
 
        
12421
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12422
 
        if ( ulResult != cOCT6100_ERR_OK )
12423
 
                return ulResult;
12424
 
 
12425
 
        /* Force all cpu clocks on chariot controllers. */
12426
 
        WriteParams.ulWriteAddress = 0x182;
12427
 
        WriteParams.usWriteData  = 0x0002;
12428
 
        
12429
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12430
 
        if ( ulResult != cOCT6100_ERR_OK )
12431
 
                return ulResult;
12432
 
 
12433
 
        WriteParams.ulWriteAddress = 0x184;
12434
 
        WriteParams.usWriteData  = 0x0202;
12435
 
        
12436
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12437
 
        if ( ulResult != cOCT6100_ERR_OK )
12438
 
                return ulResult;
12439
 
 
12440
 
        aulWaitTime[ 0 ] = 1000;
12441
 
        aulWaitTime[ 1 ] = 0;
12442
 
        ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12443
 
        if ( ulResult != cOCT6100_ERR_OK )
12444
 
                return ulResult;
12445
 
 
12446
 
        /* Remove the reset on the entire chip and disable CPU access caching. */
12447
 
        WriteParams.ulWriteAddress = 0x100;
12448
 
        WriteParams.usWriteData  = 0x2003;
12449
 
        
12450
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12451
 
        if ( ulResult != cOCT6100_ERR_OK )
12452
 
                return ulResult;
12453
 
 
12454
 
        /* Remove the bist_clk. It is no longer needed.*/
12455
 
        WriteParams.ulWriteAddress = 0x160;
12456
 
        WriteParams.usWriteData  = 0x0088;
12457
 
        
12458
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12459
 
        if ( ulResult != cOCT6100_ERR_OK )
12460
 
                return ulResult;
12461
 
 
12462
 
        /* Disable all clks to prepare for bist clock switchover. */
12463
 
        WriteParams.ulWriteAddress = 0x182;
12464
 
        WriteParams.usWriteData  = 0x0001;
12465
 
        
12466
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12467
 
        if ( ulResult != cOCT6100_ERR_OK )
12468
 
                return ulResult;
12469
 
 
12470
 
        WriteParams.ulWriteAddress = 0x186;
12471
 
        WriteParams.usWriteData  = 0x0000;
12472
 
        
12473
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12474
 
        if ( ulResult != cOCT6100_ERR_OK )
12475
 
                return ulResult;
12476
 
 
12477
 
        WriteParams.ulWriteAddress = 0x184;
12478
 
        WriteParams.usWriteData  = 0x0101;
12479
 
        
12480
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12481
 
        if ( ulResult != cOCT6100_ERR_OK )
12482
 
                return ulResult;
12483
 
 
12484
 
        ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12485
 
        if ( ulResult != cOCT6100_ERR_OK )
12486
 
                return ulResult;
12487
 
 
12488
 
        /* Deassert bist_active */
12489
 
        WriteParams.ulWriteAddress = 0x160;
12490
 
        WriteParams.usWriteData  = 0x0008;
12491
 
        
12492
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12493
 
        if ( ulResult != cOCT6100_ERR_OK )
12494
 
                return ulResult;
12495
 
 
12496
 
        /* Change CPU interface to normal mode (from boot mode). */
12497
 
        WriteParams.ulWriteAddress = 0x154;
12498
 
        WriteParams.usWriteData  = 0x0000;
12499
 
        
12500
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12501
 
        if ( ulResult != cOCT6100_ERR_OK )
12502
 
                return ulResult;
12503
 
 
12504
 
        ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12505
 
        if ( ulResult != cOCT6100_ERR_OK )
12506
 
                return ulResult;
12507
 
 
12508
 
        /* Give a couple of BIST clock cycles to turn off the BIST permanently. */
12509
 
        WriteParams.ulWriteAddress = 0x160;
12510
 
        WriteParams.usWriteData  = 0x0108;
12511
 
        
12512
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12513
 
        if ( ulResult != cOCT6100_ERR_OK )
12514
 
                return ulResult;
12515
 
 
12516
 
        ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12517
 
        if ( ulResult != cOCT6100_ERR_OK )
12518
 
                return ulResult;
12519
 
 
12520
 
        /* Turn BIST clock off for the last time. */
12521
 
        WriteParams.ulWriteAddress = 0x160;
12522
 
        WriteParams.usWriteData  = 0x0008;
12523
 
        
12524
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12525
 
        if ( ulResult != cOCT6100_ERR_OK )
12526
 
                return ulResult;
12527
 
 
12528
 
        /* Reset procedure done! */
12529
 
 
12530
 
        /* Enable mclk for cpu interface and external memory controller. */
12531
 
        WriteParams.ulWriteAddress = 0x186;
12532
 
        WriteParams.usWriteData  = 0x0100;
12533
 
        
12534
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12535
 
        if ( ulResult != cOCT6100_ERR_OK )
12536
 
                return ulResult;
12537
 
 
12538
 
        return cOCT6100_ERR_OK;
12539
 
}
12540
 
 
12541
 
 
12542
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12543
 
 
12544
 
Function:               Oct6100ApiLoadImage
12545
 
 
12546
 
Description:    This function writes the firmware image in the external memory.
12547
 
 
12548
 
-------------------------------------------------------------------------------
12549
 
|       Argument                |       Description
12550
 
-------------------------------------------------------------------------------
12551
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
12552
 
                                        present state of the chip and all its resources.
12553
 
 
12554
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12555
 
static UINT32 Oct6100ApiLoadImage(
12556
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
12557
 
{
12558
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
12559
 
        tOCT6100_WRITE_BURST_PARAMS     BurstParams;
12560
 
        tOCT6100_READ_PARAMS            ReadParams;
12561
 
        UINT32                                          ulResult;
12562
 
        UINT32                                          ulTempPtr;
12563
 
        UINT32                                          ulNumWrites;
12564
 
        PUINT16                                         pusSuperArray;
12565
 
        PUINT8                                          pbyImageFile;
12566
 
        UINT32                                          ulByteCount = 0;
12567
 
        UINT16                                          usReadData;
12568
 
        UINT32                                          ulAddressOfst;
12569
 
        UINT32                                          i;
12570
 
 
12571
 
        /* Get local pointer to shared portion of instance. */
12572
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
12573
 
 
12574
 
        /* Set the process context and user chip ID parameters once and for all. */
12575
 
        BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
12576
 
 
12577
 
        BurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12578
 
 
12579
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
12580
 
 
12581
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12582
 
        ReadParams.pusReadData = &usReadData;
12583
 
 
12584
 
        /* Breakdown image into subcomponents. */
12585
 
        ulTempPtr = cOCT6100_IMAGE_FILE_BASE + cOCT6100_IMAGE_AF_CST_OFFSET;
12586
 
 
12587
 
        for(i=0;i<cOCT6100_MAX_IMAGE_REGION;i++)
12588
 
        {
12589
 
                pSharedInfo->ImageRegion[ i ].ulPart1Size = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 0 ];
12590
 
                pSharedInfo->ImageRegion[ i ].ulPart2Size = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 1 ];
12591
 
                pSharedInfo->ImageRegion[ i ].ulClockInfo = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 2 ];
12592
 
                pSharedInfo->ImageRegion[ i ].ulReserved  = pSharedInfo->ChipConfig.pbyImageFile[ 0x110 + ( i * 4 ) + 3 ];
12593
 
 
12594
 
                if (i == 0)             /* AF constant. */
12595
 
                {
12596
 
                        pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF;
12597
 
                        pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = 0;
12598
 
 
12599
 
                        ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 612 );
12600
 
                }
12601
 
                else if (i == 1)        /* NLP image */
12602
 
                {
12603
 
                        pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF;
12604
 
                        pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = 0;
12605
 
 
12606
 
                        ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 2056 );
12607
 
                }
12608
 
                else    /* Others */
12609
 
                {
12610
 
                        pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF;
12611
 
                        ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 2064 );
12612
 
 
12613
 
                        pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = ulTempPtr & 0x07FFFFFF;
12614
 
                        ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart2Size * 2448 );
12615
 
                }
12616
 
        }
12617
 
 
12618
 
        /* Write the image in external memory. */
12619
 
        ulNumWrites = pSharedInfo->ChipConfig.ulImageSize / 2;
12620
 
 
12621
 
        BurstParams.ulWriteAddress = cOCT6100_IMAGE_FILE_BASE;
12622
 
        BurstParams.pusWriteData = pSharedInfo->MiscVars.ausSuperArray;
12623
 
        
12624
 
        pusSuperArray = pSharedInfo->MiscVars.ausSuperArray;
12625
 
        pbyImageFile = pSharedInfo->ChipConfig.pbyImageFile;
12626
 
 
12627
 
        while ( ulNumWrites != 0 )
12628
 
        {
12629
 
                if ( ulNumWrites >= pSharedInfo->ChipConfig.usMaxRwAccesses )
12630
 
                        BurstParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
12631
 
                else
12632
 
                        BurstParams.ulWriteLength = ulNumWrites;
12633
 
 
12634
 
                for ( i = 0; i < BurstParams.ulWriteLength; i++ )
12635
 
                {
12636
 
                        pusSuperArray[ i ]  = ( UINT16 )(( pbyImageFile [ ulByteCount++ ]) << 8);
12637
 
                        pusSuperArray[ i ] |= ( UINT16 )pbyImageFile [ ulByteCount++ ];
12638
 
                }
12639
 
 
12640
 
                mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult )
12641
 
                if ( ulResult != cOCT6100_ERR_OK )
12642
 
                        return ulResult;
12643
 
 
12644
 
                BurstParams.ulWriteAddress += 2 * BurstParams.ulWriteLength;
12645
 
                ulNumWrites -= BurstParams.ulWriteLength;
12646
 
        }
12647
 
 
12648
 
        /* Perform a serie of reads to make sure the image was correclty written into memory. */
12649
 
        ulAddressOfst = ( pSharedInfo->ChipConfig.ulImageSize / 2 ) & 0xFFFFFFFE;
12650
 
        while ( ulAddressOfst != 0 )
12651
 
        {
12652
 
                ReadParams.ulReadAddress = cOCT6100_IMAGE_FILE_BASE + ulAddressOfst;
12653
 
 
12654
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
12655
 
                if ( ulResult != cOCT6100_ERR_OK )
12656
 
                        return ulResult;
12657
 
 
12658
 
                if ( (usReadData >> 8) != pbyImageFile[ ulAddressOfst ] )
12659
 
                        return cOCT6100_ERR_OPEN_IMAGE_WRITE_FAILED;
12660
 
 
12661
 
                ulAddressOfst = (ulAddressOfst / 2) & 0xFFFFFFFE;
12662
 
        }
12663
 
 
12664
 
        return cOCT6100_ERR_OK;
12665
 
}
12666
 
 
12667
 
 
12668
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12669
 
 
12670
 
Function:               Oct6100ApiCpuRegisterBist
12671
 
 
12672
 
Description:    Tests the operation of the CPU registers.
12673
 
 
12674
 
-------------------------------------------------------------------------------
12675
 
|       Argument                |       Description
12676
 
-------------------------------------------------------------------------------
12677
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
12678
 
                                        present state of the chip and all its resources.
12679
 
 
12680
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12681
 
static UINT32 Oct6100ApiCpuRegisterBist(
12682
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
12683
 
{
12684
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
12685
 
        tOCT6100_WRITE_PARAMS   WriteParams;
12686
 
        tOCT6100_READ_PARAMS    ReadParams;
12687
 
        UINT32  ulResult;
12688
 
        UINT16  i;
12689
 
        UINT16  usReadData;
12690
 
 
12691
 
        /* Get local pointer to shared portion of instance. */
12692
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
12693
 
 
12694
 
        /* Set the process context and user chip ID parameters once and for all. */
12695
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
12696
 
 
12697
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12698
 
 
12699
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
12700
 
 
12701
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12702
 
 
12703
 
        /* Assign read data pointer that will be used throughout the function. */
12704
 
        ReadParams.pusReadData = &usReadData;
12705
 
 
12706
 
        /* Start with a walking bit test. */
12707
 
        for ( i = 0; i < 16; i ++ )
12708
 
        {
12709
 
                /* Write at address 0x150.*/
12710
 
                WriteParams.ulWriteAddress = 0x150;
12711
 
                WriteParams.usWriteData = (UINT16)( 0x1 << i );
12712
 
 
12713
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12714
 
                if ( ulResult != cOCT6100_ERR_OK )
12715
 
                        return ulResult;
12716
 
 
12717
 
                /* Write at address 0x180.*/
12718
 
                WriteParams.ulWriteAddress = 0x180;
12719
 
                WriteParams.usWriteData = (UINT16)( 0x1 << ( 15 - i ) );
12720
 
 
12721
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12722
 
                if ( ulResult != cOCT6100_ERR_OK )
12723
 
                        return ulResult;
12724
 
 
12725
 
                /* Now read back the two registers to make sure the acceses were successfull. */
12726
 
                ReadParams.ulReadAddress = 0x150;
12727
 
 
12728
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
12729
 
                if ( ulResult != cOCT6100_ERR_OK )
12730
 
                        return ulResult;
12731
 
 
12732
 
                if ( usReadData != ( 0x1 << i ) )
12733
 
                        return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
12734
 
 
12735
 
                ReadParams.ulReadAddress = 0x180;
12736
 
 
12737
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
12738
 
                if ( ulResult != cOCT6100_ERR_OK )
12739
 
                        return ulResult;
12740
 
 
12741
 
                if ( usReadData != ( 0x1 << ( 15 - i ) ) )
12742
 
                        return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
12743
 
        }
12744
 
 
12745
 
        /* Write at address 0x150. */
12746
 
        WriteParams.ulWriteAddress = 0x150;
12747
 
        WriteParams.usWriteData = 0xCAFE;
12748
 
 
12749
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12750
 
        if ( ulResult != cOCT6100_ERR_OK )
12751
 
                return ulResult;
12752
 
 
12753
 
        /* Write at address 0x180. */
12754
 
        WriteParams.ulWriteAddress = 0x180;
12755
 
        WriteParams.usWriteData = 0xDECA;
12756
 
 
12757
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12758
 
        if ( ulResult != cOCT6100_ERR_OK )
12759
 
                return ulResult;
12760
 
 
12761
 
        /* Now read back the two registers to make sure the acceses were successfull. */
12762
 
        ReadParams.ulReadAddress = 0x150;
12763
 
 
12764
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
12765
 
        if ( ulResult != cOCT6100_ERR_OK )
12766
 
                return ulResult;
12767
 
 
12768
 
        if ( usReadData != 0xCAFE )
12769
 
                return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
12770
 
 
12771
 
        ReadParams.ulReadAddress = 0x180;
12772
 
 
12773
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
12774
 
        if ( ulResult != cOCT6100_ERR_OK )
12775
 
                return ulResult;
12776
 
 
12777
 
        if ( usReadData != 0xDECA )
12778
 
                return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
12779
 
 
12780
 
        return cOCT6100_ERR_OK;
12781
 
}
12782
 
 
12783
 
 
12784
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12785
 
 
12786
 
Function:               Oct6100ApiBootSdram
12787
 
 
12788
 
Description:    Configure and test the SDRAM.
12789
 
 
12790
 
-------------------------------------------------------------------------------
12791
 
|       Argument                |       Description
12792
 
-------------------------------------------------------------------------------
12793
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
12794
 
                                        present state of the chip and all its resources.
12795
 
 
12796
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12797
 
static UINT32 Oct6100ApiBootSdram(
12798
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
12799
 
{
12800
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
12801
 
        tPOCT6100_API_CHIP_CONFIG       pChipConfig;
12802
 
        tOCT6100_WRITE_PARAMS           WriteParams;
12803
 
        tOCT6100_READ_PARAMS            ReadParams;
12804
 
        UINT32  ulResult;
12805
 
        UINT16  usReadData;
12806
 
        UINT16  usWriteData23E;
12807
 
        UINT16  usWriteData230;
12808
 
        UINT32  i;
12809
 
 
12810
 
        /* Get local pointer to shared portion of instance. */
12811
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
12812
 
 
12813
 
        /* Get local pointer to the chip configuration structure.*/
12814
 
        pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
12815
 
 
12816
 
        /* Set the process context and user chip ID parameters once and for all. */
12817
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
12818
 
 
12819
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12820
 
 
12821
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
12822
 
 
12823
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12824
 
        ReadParams.pusReadData = &usReadData;
12825
 
 
12826
 
        usWriteData23E = 0x0000;
12827
 
        usWriteData230 = 0x0000;
12828
 
 
12829
 
        if ( (pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS)  )
12830
 
        {
12831
 
                /* SDRAM: */
12832
 
                switch( pChipConfig->ulMemoryChipSize )
12833
 
                {
12834
 
                case cOCT6100_MEMORY_CHIP_SIZE_8MB:
12835
 
                        usWriteData230 |= ( cOCT6100_16MB_MEMORY_BANKS << 2 );
12836
 
                        break;
12837
 
                case cOCT6100_MEMORY_CHIP_SIZE_16MB:
12838
 
                        usWriteData230 |= ( cOCT6100_32MB_MEMORY_BANKS << 2 );
12839
 
                        break;
12840
 
                case cOCT6100_MEMORY_CHIP_SIZE_32MB:
12841
 
                        usWriteData230 |= ( cOCT6100_64MB_MEMORY_BANKS << 2 );
12842
 
                        break;
12843
 
                case cOCT6100_MEMORY_CHIP_SIZE_64MB:
12844
 
                        usWriteData230 |= ( cOCT6100_128MB_MEMORY_BANKS << 2 );
12845
 
                        break;
12846
 
                default:
12847
 
                        return cOCT6100_ERR_FATAL_16;
12848
 
                }
12849
 
                WriteParams.ulWriteAddress = 0x230;
12850
 
                WriteParams.usWriteData = usWriteData230;
12851
 
 
12852
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12853
 
                if ( ulResult != cOCT6100_ERR_OK )
12854
 
                        return ulResult;
12855
 
                
12856
 
                /* Precharge all banks. */
12857
 
                usWriteData230 &= 0x000C;
12858
 
                usWriteData230 |= 0x0010;
12859
 
 
12860
 
                WriteParams.ulWriteAddress = 0x230;
12861
 
                WriteParams.usWriteData = usWriteData230;
12862
 
                
12863
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12864
 
                if ( ulResult != cOCT6100_ERR_OK )
12865
 
                        return ulResult;
12866
 
 
12867
 
                usWriteData230 |= 0x0002;
12868
 
 
12869
 
                WriteParams.usWriteData = usWriteData230;
12870
 
                
12871
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12872
 
                if ( ulResult != cOCT6100_ERR_OK )
12873
 
                        return ulResult;
12874
 
 
12875
 
                WriteParams.ulWriteAddress = 0x23E;
12876
 
                WriteParams.usWriteData = usWriteData23E;
12877
 
                for ( i = 0; i < 5; i++ )
12878
 
                {
12879
 
                        /* Wait cycle. */
12880
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12881
 
                        if ( ulResult != cOCT6100_ERR_OK )
12882
 
                                return ulResult;
12883
 
                }
12884
 
 
12885
 
                /* Program the mode register. */
12886
 
                usWriteData23E = 0x0030;
12887
 
                WriteParams.usWriteData = usWriteData23E;
12888
 
                
12889
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12890
 
                if ( ulResult != cOCT6100_ERR_OK )
12891
 
                        return ulResult;
12892
 
 
12893
 
                usWriteData230 &= 0x000C;
12894
 
                usWriteData230 |= 0x0000;
12895
 
 
12896
 
                WriteParams.ulWriteAddress = 0x230;
12897
 
                WriteParams.usWriteData = usWriteData230;
12898
 
                
12899
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12900
 
                if ( ulResult != cOCT6100_ERR_OK )
12901
 
                        return ulResult;
12902
 
 
12903
 
                usWriteData230 |= 0x0002;
12904
 
 
12905
 
                WriteParams.usWriteData = usWriteData230;
12906
 
                
12907
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12908
 
                if ( ulResult != cOCT6100_ERR_OK )
12909
 
                        return ulResult;
12910
 
 
12911
 
                WriteParams.ulWriteAddress = 0x23E;
12912
 
                WriteParams.usWriteData = usWriteData23E;
12913
 
                for ( i = 0; i < 5; i++ )
12914
 
                {
12915
 
                        /* Wait cycle. */
12916
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12917
 
                        if ( ulResult != cOCT6100_ERR_OK )
12918
 
                                return ulResult;
12919
 
                }
12920
 
                
12921
 
                /* Do CBR refresh (twice) */
12922
 
                usWriteData230 &= 0x000C;
12923
 
                usWriteData230 |= 0x0040;
12924
 
 
12925
 
                WriteParams.ulWriteAddress = 0x230;
12926
 
                WriteParams.usWriteData = usWriteData230;
12927
 
                
12928
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12929
 
                if ( ulResult != cOCT6100_ERR_OK )
12930
 
                        return ulResult;
12931
 
 
12932
 
                usWriteData230 |= 0x0002;
12933
 
 
12934
 
                WriteParams.usWriteData = usWriteData230;
12935
 
                
12936
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12937
 
                if ( ulResult != cOCT6100_ERR_OK )
12938
 
                        return ulResult;
12939
 
 
12940
 
                WriteParams.ulWriteAddress = 0x23E;
12941
 
                WriteParams.usWriteData = usWriteData23E;
12942
 
                for ( i = 0; i < 5; i++ )
12943
 
                {
12944
 
                        /* Wait cycle. */
12945
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12946
 
                        if ( ulResult != cOCT6100_ERR_OK )
12947
 
                                return ulResult;
12948
 
                }
12949
 
 
12950
 
                WriteParams.ulWriteAddress = 0x230;
12951
 
                WriteParams.usWriteData = usWriteData230;
12952
 
                
12953
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12954
 
                if ( ulResult != cOCT6100_ERR_OK )
12955
 
                        return ulResult;
12956
 
 
12957
 
                WriteParams.ulWriteAddress = 0x23E;
12958
 
                WriteParams.usWriteData = usWriteData23E;
12959
 
                for ( i = 0; i < 5; i++ )
12960
 
                {
12961
 
                        /* Wait cycle. */
12962
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12963
 
                        if ( ulResult != cOCT6100_ERR_OK )
12964
 
                                return ulResult;
12965
 
                }
12966
 
        }
12967
 
        else
12968
 
        {
12969
 
                /* DDR: */
12970
 
                switch( pChipConfig->ulMemoryChipSize )
12971
 
                {
12972
 
                case cOCT6100_MEMORY_CHIP_SIZE_16MB:
12973
 
                        usWriteData230 |= ( cOCT6100_16MB_MEMORY_BANKS << 2 );
12974
 
                        break;
12975
 
                case cOCT6100_MEMORY_CHIP_SIZE_32MB:
12976
 
                        usWriteData230 |= ( cOCT6100_32MB_MEMORY_BANKS << 2 );
12977
 
                        break;
12978
 
                case cOCT6100_MEMORY_CHIP_SIZE_64MB:
12979
 
                        usWriteData230 |= ( cOCT6100_64MB_MEMORY_BANKS << 2 );
12980
 
                        break;
12981
 
                case cOCT6100_MEMORY_CHIP_SIZE_128MB:
12982
 
                        usWriteData230 |= ( cOCT6100_128MB_MEMORY_BANKS << 2 );
12983
 
                        break;
12984
 
                default:
12985
 
                        return cOCT6100_ERR_FATAL_17;
12986
 
                }
12987
 
                WriteParams.ulWriteAddress = 0x230;
12988
 
                WriteParams.usWriteData = usWriteData230;
12989
 
 
12990
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12991
 
                if ( ulResult != cOCT6100_ERR_OK )
12992
 
                        return ulResult;
12993
 
 
12994
 
                /* Precharge all banks. */
12995
 
                usWriteData230 &= 0x000C;
12996
 
                usWriteData230 |= 0x0010;
12997
 
 
12998
 
                WriteParams.ulWriteAddress = 0x230;
12999
 
                WriteParams.usWriteData = usWriteData230;
13000
 
                
13001
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13002
 
                if ( ulResult != cOCT6100_ERR_OK )
13003
 
                        return ulResult;
13004
 
 
13005
 
                usWriteData230 |= 0x0002;
13006
 
        
13007
 
                WriteParams.usWriteData = usWriteData230;
13008
 
                
13009
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13010
 
                if ( ulResult != cOCT6100_ERR_OK )
13011
 
                        return ulResult;
13012
 
 
13013
 
                WriteParams.ulWriteAddress = 0x23E;
13014
 
                WriteParams.usWriteData = usWriteData23E;
13015
 
                for ( i = 0; i < 5; i++ )
13016
 
                {
13017
 
                        /* Wait cycle. */
13018
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13019
 
                        if ( ulResult != cOCT6100_ERR_OK )
13020
 
                                return ulResult;
13021
 
                }
13022
 
 
13023
 
                /* Program DDR mode register. */
13024
 
                usWriteData23E = 0x4000;
13025
 
                
13026
 
                WriteParams.ulWriteAddress = 0x23E;
13027
 
                WriteParams.usWriteData = usWriteData23E;
13028
 
 
13029
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13030
 
                if ( ulResult != cOCT6100_ERR_OK )
13031
 
                        return ulResult;
13032
 
 
13033
 
                usWriteData230 &= 0x000C;
13034
 
                usWriteData230 |= 0x0000;
13035
 
 
13036
 
                WriteParams.ulWriteAddress = 0x230;
13037
 
                WriteParams.usWriteData = usWriteData230;
13038
 
                
13039
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13040
 
                if ( ulResult != cOCT6100_ERR_OK )
13041
 
                        return ulResult;
13042
 
 
13043
 
                usWriteData230 |= 0x0002;
13044
 
        
13045
 
                WriteParams.usWriteData = usWriteData230;
13046
 
                
13047
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13048
 
                if ( ulResult != cOCT6100_ERR_OK )
13049
 
                        return ulResult;
13050
 
 
13051
 
                WriteParams.ulWriteAddress = 0x23E;
13052
 
                WriteParams.usWriteData = usWriteData23E;
13053
 
                for ( i = 0; i < 5; i++ )
13054
 
                {
13055
 
                        /* Wait cycle. */
13056
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13057
 
                        if ( ulResult != cOCT6100_ERR_OK )
13058
 
                                return ulResult;
13059
 
                }
13060
 
                
13061
 
                /* Program SDR mode register. */
13062
 
                usWriteData23E = 0x0161;
13063
 
 
13064
 
                WriteParams.ulWriteAddress = 0x23E;
13065
 
                WriteParams.usWriteData = usWriteData23E;
13066
 
 
13067
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13068
 
                if ( ulResult != cOCT6100_ERR_OK )
13069
 
                        return ulResult;
13070
 
 
13071
 
                usWriteData230 &= 0x000C;
13072
 
                usWriteData230 |= 0x0000;
13073
 
 
13074
 
                WriteParams.ulWriteAddress = 0x230;
13075
 
                WriteParams.usWriteData = usWriteData230;
13076
 
                
13077
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13078
 
                if ( ulResult != cOCT6100_ERR_OK )
13079
 
                        return ulResult;
13080
 
 
13081
 
                usWriteData230 |= 0x0002;
13082
 
        
13083
 
                WriteParams.usWriteData = usWriteData230;
13084
 
                
13085
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13086
 
                if ( ulResult != cOCT6100_ERR_OK )
13087
 
                        return ulResult;
13088
 
 
13089
 
                WriteParams.ulWriteAddress = 0x23E;
13090
 
                WriteParams.usWriteData = usWriteData23E;
13091
 
                for ( i = 0; i < 5; i++ )
13092
 
                {
13093
 
                        /* Wait cycle. */
13094
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13095
 
                        if ( ulResult != cOCT6100_ERR_OK )
13096
 
                                return ulResult;
13097
 
                }
13098
 
                
13099
 
                /* Precharge all banks. */
13100
 
                usWriteData23E = 0xFFFF;
13101
 
 
13102
 
                WriteParams.ulWriteAddress = 0x23E;
13103
 
                WriteParams.usWriteData = usWriteData23E;
13104
 
 
13105
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13106
 
                if ( ulResult != cOCT6100_ERR_OK )
13107
 
                        return ulResult;
13108
 
 
13109
 
                usWriteData230 &= 0x000C;
13110
 
                usWriteData230 |= 0x0010;
13111
 
 
13112
 
                WriteParams.ulWriteAddress = 0x230;
13113
 
                WriteParams.usWriteData = usWriteData230;
13114
 
                
13115
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13116
 
                if ( ulResult != cOCT6100_ERR_OK )
13117
 
                        return ulResult;
13118
 
 
13119
 
                usWriteData230 |= 0x0002;
13120
 
        
13121
 
                WriteParams.usWriteData = usWriteData230;
13122
 
                
13123
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13124
 
                if ( ulResult != cOCT6100_ERR_OK )
13125
 
                        return ulResult;
13126
 
 
13127
 
                WriteParams.ulWriteAddress = 0x23E;
13128
 
                WriteParams.usWriteData = usWriteData23E;
13129
 
                for ( i = 0; i < 5; i++ )
13130
 
                {
13131
 
                        /* Wait cycle. */
13132
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13133
 
                        if ( ulResult != cOCT6100_ERR_OK )
13134
 
                                return ulResult;
13135
 
                }
13136
 
 
13137
 
                /* Do CBR refresh (twice) */
13138
 
                usWriteData230 &= 0x000C;
13139
 
                usWriteData230 |= 0x0040;
13140
 
 
13141
 
                WriteParams.ulWriteAddress = 0x230;
13142
 
                WriteParams.usWriteData = usWriteData230;
13143
 
                
13144
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13145
 
                if ( ulResult != cOCT6100_ERR_OK )
13146
 
                        return ulResult;
13147
 
 
13148
 
                usWriteData230 |= 0x0002;
13149
 
        
13150
 
                WriteParams.usWriteData = usWriteData230;
13151
 
                
13152
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13153
 
                if ( ulResult != cOCT6100_ERR_OK )
13154
 
                        return ulResult;
13155
 
 
13156
 
                WriteParams.ulWriteAddress = 0x23E;
13157
 
                WriteParams.usWriteData = usWriteData23E;
13158
 
                for ( i = 0; i < 5; i++ )
13159
 
                {
13160
 
                        /* Wait cycle. */
13161
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13162
 
                        if ( ulResult != cOCT6100_ERR_OK )
13163
 
                                return ulResult;
13164
 
                }
13165
 
 
13166
 
                WriteParams.ulWriteAddress = 0x230;
13167
 
                WriteParams.usWriteData = usWriteData230;
13168
 
                
13169
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13170
 
                if ( ulResult != cOCT6100_ERR_OK )
13171
 
                        return ulResult;
13172
 
 
13173
 
                WriteParams.ulWriteAddress = 0x23E;
13174
 
                WriteParams.usWriteData = usWriteData23E;
13175
 
                for ( i = 0; i < 5; i++ )
13176
 
                {
13177
 
                        /* Wait cycle.*/
13178
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13179
 
                        if ( ulResult != cOCT6100_ERR_OK )
13180
 
                                return ulResult;
13181
 
                }
13182
 
 
13183
 
                /* Program SDR mode register. */
13184
 
                usWriteData23E = 0x0061;
13185
 
 
13186
 
                WriteParams.ulWriteAddress = 0x23E;
13187
 
                WriteParams.usWriteData = usWriteData23E;
13188
 
 
13189
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13190
 
                if ( ulResult != cOCT6100_ERR_OK )
13191
 
                        return ulResult;
13192
 
 
13193
 
                usWriteData230 &= 0x000C;
13194
 
                usWriteData230 |= 0x0000;
13195
 
 
13196
 
                WriteParams.ulWriteAddress = 0x230;
13197
 
                WriteParams.usWriteData = usWriteData230;
13198
 
                
13199
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13200
 
                if ( ulResult != cOCT6100_ERR_OK )
13201
 
                        return ulResult;
13202
 
 
13203
 
                usWriteData230 |= 0x0002;
13204
 
        
13205
 
                WriteParams.usWriteData = usWriteData230;
13206
 
                
13207
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13208
 
                if ( ulResult != cOCT6100_ERR_OK )
13209
 
                        return ulResult;
13210
 
 
13211
 
                WriteParams.ulWriteAddress = 0x23E;
13212
 
                WriteParams.usWriteData = usWriteData23E;
13213
 
                for ( i = 0; i < 5; i++ )
13214
 
                {
13215
 
                        /* Wait cycle. */
13216
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13217
 
                        if ( ulResult != cOCT6100_ERR_OK )
13218
 
                                return ulResult;
13219
 
                }
13220
 
        }
13221
 
 
13222
 
        /* Set the refresh frequency. */
13223
 
        WriteParams.ulWriteAddress = 0x242;
13224
 
        WriteParams.usWriteData = 0x0400;
13225
 
        
13226
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13227
 
        if ( ulResult != cOCT6100_ERR_OK )
13228
 
                return ulResult;
13229
 
 
13230
 
        WriteParams.ulWriteAddress = 0x244;
13231
 
        WriteParams.usWriteData = 0x0200;
13232
 
        
13233
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13234
 
        if ( ulResult != cOCT6100_ERR_OK )
13235
 
                return ulResult;
13236
 
 
13237
 
        WriteParams.ulWriteAddress = 0x248;
13238
 
        WriteParams.usWriteData = 0x800;
13239
 
        
13240
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13241
 
        if ( ulResult != cOCT6100_ERR_OK )
13242
 
                return ulResult;
13243
 
 
13244
 
        WriteParams.ulWriteAddress = 0x246;
13245
 
        WriteParams.usWriteData = 0x0012;
13246
 
        
13247
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13248
 
        if ( ulResult != cOCT6100_ERR_OK )
13249
 
                return ulResult;
13250
 
 
13251
 
        /* Enable the SDRAM and refreshes. */
13252
 
        usWriteData230 &= 0x000C;
13253
 
        usWriteData230 |= 0x0001;
13254
 
 
13255
 
        WriteParams.ulWriteAddress = 0x230;
13256
 
        WriteParams.usWriteData = usWriteData230;
13257
 
        
13258
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13259
 
        if ( ulResult != cOCT6100_ERR_OK )
13260
 
                return ulResult;
13261
 
 
13262
 
        WriteParams.ulWriteAddress = 0x246;
13263
 
        WriteParams.usWriteData = 0x0013;
13264
 
        
13265
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13266
 
        if ( ulResult != cOCT6100_ERR_OK )
13267
 
                return ulResult;
13268
 
 
13269
 
        return cOCT6100_ERR_OK;
13270
 
}
13271
 
 
13272
 
 
13273
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13274
 
 
13275
 
Function:               Oct6100ApiEnableClocks
13276
 
 
13277
 
Description:    This function will disable clock masking for all the modules
13278
 
                                of the chip. 
13279
 
 
13280
 
-------------------------------------------------------------------------------
13281
 
|       Argument                |       Description
13282
 
-------------------------------------------------------------------------------
13283
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
13284
 
                                        present state of the chip and all its resources.
13285
 
 
13286
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13287
 
static UINT32 Oct6100ApiEnableClocks(
13288
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
13289
 
{
13290
 
        tOCT6100_WRITE_PARAMS   WriteParams;
13291
 
        UINT32  ulResult;
13292
 
 
13293
 
        /* Initialize the process context and user chip ID once and for all. */
13294
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13295
 
 
13296
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
13297
 
 
13298
 
        /* Enable tdmie / adpcm mclk clocks. */
13299
 
        WriteParams.ulWriteAddress = 0x186;
13300
 
        WriteParams.usWriteData = 0x015F;
13301
 
 
13302
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13303
 
        if ( ulResult != cOCT6100_ERR_OK )
13304
 
                return ulResult;
13305
 
 
13306
 
        /* Configure the DQS register for the DDR memory */
13307
 
        WriteParams.ulWriteAddress = 0x180;
13308
 
        WriteParams.usWriteData = 0xFF00;
13309
 
 
13310
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13311
 
        if ( ulResult != cOCT6100_ERR_OK )
13312
 
                return ulResult;
13313
 
 
13314
 
        /* Enable pgsp chariot clocks */
13315
 
        WriteParams.ulWriteAddress = 0x182;
13316
 
        WriteParams.usWriteData = 0x0000;
13317
 
 
13318
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13319
 
        if ( ulResult != cOCT6100_ERR_OK )
13320
 
                return ulResult;
13321
 
        
13322
 
        /* Enable af/mt chariot clocks */
13323
 
        WriteParams.ulWriteAddress = 0x184;
13324
 
        WriteParams.usWriteData = 0x0000;
13325
 
 
13326
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13327
 
        if ( ulResult != cOCT6100_ERR_OK )
13328
 
                return ulResult;
13329
 
 
13330
 
        return cOCT6100_ERR_OK;
13331
 
}
13332
 
 
13333
 
 
13334
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13335
 
 
13336
 
Function:               Oct6100ApiProgramNLP
13337
 
 
13338
 
Description:    This function will write image values to configure the NLP.
13339
 
 
13340
 
-------------------------------------------------------------------------------
13341
 
|       Argument                |       Description
13342
 
-------------------------------------------------------------------------------
13343
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
13344
 
                                        present state of the chip and all its resources.
13345
 
 
13346
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13347
 
static UINT32 Oct6100ApiProgramNLP(
13348
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
13349
 
{
13350
 
        tOCT6100_WRITE_PARAMS           WriteParams;
13351
 
        tOCT6100_READ_PARAMS            ReadParams;
13352
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
13353
 
        tPOCT6100_API_CHIP_CONFIG       pChipConfig;
13354
 
        UINT32  ulResult;
13355
 
        UINT16  usReadData;
13356
 
        UINT16  usReadHighData;
13357
 
        BOOL    fBitEqual;
13358
 
        UINT32  ulEgoEntry[4];
13359
 
        UINT32  ulTempAddress;
13360
 
        UINT32  ulAfCpuUp = FALSE;
13361
 
        UINT32  i;
13362
 
        UINT32  ulLoopCounter = 0;
13363
 
 
13364
 
        /* Get local pointer to shared portion of instance. */
13365
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
13366
 
 
13367
 
        /* Get local pointer to the chip configuration structure.*/
13368
 
        pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
13369
 
 
13370
 
        /* Initialize the process context and user chip ID once and for all. */
13371
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13372
 
 
13373
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
13374
 
 
13375
 
        /* Initialize the process context and user chip ID once and for all. */
13376
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
13377
 
 
13378
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
13379
 
        ReadParams.pusReadData = &usReadData;
13380
 
 
13381
 
        if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
13382
 
        {
13383
 
                UINT32  ulReadData;
13384
 
                UINT32  ulBitPattern;
13385
 
                UINT32  j, k;
13386
 
 
13387
 
                /* Since the pouch section (256 bytes) will not be tested by the firmware, */
13388
 
                /* the API has to make sure this section is working correctly. */
13389
 
                for ( k = 0; k < 2; k ++ )
13390
 
                {
13391
 
                        if ( k == 0 )
13392
 
                                ulBitPattern = 0x1;
13393
 
                        else
13394
 
                                ulBitPattern = 0xFFFFFFFE;
13395
 
 
13396
 
                        for ( j = 0; j < 32; j ++ )
13397
 
                        {
13398
 
                                /* Write the DWORDs. */
13399
 
                                for ( i = 0; i < 64; i ++ )
13400
 
                                {
13401
 
                                        ulResult = Oct6100ApiWriteDword( f_pApiInstance, cOCT6100_POUCH_BASE + i * 4, ulBitPattern << j );
13402
 
                                        if ( ulResult != cOCT6100_ERR_OK )
13403
 
                                                return ulResult;
13404
 
                                }
13405
 
 
13406
 
                                /* Read the DWORDs. */
13407
 
                                for ( i = 0; i < 64; i ++ )
13408
 
                                {
13409
 
                                        ulResult = Oct6100ApiReadDword( f_pApiInstance, cOCT6100_POUCH_BASE + i * 4, &ulReadData );
13410
 
                                        if ( ulResult != cOCT6100_ERR_OK )
13411
 
                                                return ulResult;
13412
 
 
13413
 
                                        /* Check if the value matches. */
13414
 
                                        if ( ( ulBitPattern << j ) != ulReadData )
13415
 
                                                return cOCT6100_ERR_OPEN_PRODUCTION_BIST_POUCH_ERROR;
13416
 
                                }
13417
 
                        }
13418
 
                }
13419
 
        }
13420
 
 
13421
 
        /* Write the image info in the chip. */
13422
 
        WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE;
13423
 
        WriteParams.usWriteData = (UINT16)( ( pSharedInfo->ImageRegion[ 0 ].ulPart1BaseAddress >> 16 ) & 0xFFFF );
13424
 
 
13425
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13426
 
        if ( ulResult != cOCT6100_ERR_OK )
13427
 
                return ulResult;
13428
 
 
13429
 
        WriteParams.ulWriteAddress += 2;
13430
 
        WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ 0 ].ulPart1BaseAddress & 0xFFFF );
13431
 
 
13432
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13433
 
        if ( ulResult != cOCT6100_ERR_OK )
13434
 
                return ulResult;
13435
 
 
13436
 
        for( i = 0; i < 8; i++ )
13437
 
        {
13438
 
                if ( pSharedInfo->ImageRegion[ i + 2 ].ulPart1Size != 0 )
13439
 
                {
13440
 
                        WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC );
13441
 
                        WriteParams.usWriteData = (UINT16)(( pSharedInfo->ImageRegion[ i + 2 ].ulPart1BaseAddress >> 16 ) & 0xFFFF );
13442
 
 
13443
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13444
 
                        if ( ulResult != cOCT6100_ERR_OK )
13445
 
                                return ulResult;
13446
 
 
13447
 
                        WriteParams.ulWriteAddress += 2;
13448
 
                        WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ i + 2 ].ulPart1BaseAddress & 0xFFFF );
13449
 
 
13450
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13451
 
                        if ( ulResult != cOCT6100_ERR_OK )
13452
 
                                return ulResult;
13453
 
                }
13454
 
 
13455
 
                if ( pSharedInfo->ImageRegion[ i + 2 ].ulPart2Size != 0 )
13456
 
                {
13457
 
                        WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC ) + 4;
13458
 
                        WriteParams.usWriteData = (UINT16)(( pSharedInfo->ImageRegion[ i + 2 ].ulPart2BaseAddress >> 16 ) & 0xFFFF );
13459
 
 
13460
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13461
 
                        if ( ulResult != cOCT6100_ERR_OK )
13462
 
                                return ulResult;
13463
 
 
13464
 
                        WriteParams.ulWriteAddress += 2;
13465
 
                        WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ i + 2 ].ulPart2BaseAddress & 0xFFFF );
13466
 
 
13467
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13468
 
                        if ( ulResult != cOCT6100_ERR_OK )
13469
 
                                return ulResult;
13470
 
                }
13471
 
 
13472
 
                WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC ) + 8;
13473
 
                WriteParams.usWriteData  = 0x0000;
13474
 
                WriteParams.usWriteData |= ( pSharedInfo->ImageRegion[ i + 2 ].ulPart1Size << 8 );
13475
 
                WriteParams.usWriteData |= pSharedInfo->ImageRegion[ i + 2 ].ulPart2Size;
13476
 
 
13477
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13478
 
                if ( ulResult != cOCT6100_ERR_OK )
13479
 
                        return ulResult;
13480
 
 
13481
 
                WriteParams.ulWriteAddress += 2;
13482
 
                WriteParams.usWriteData  = 0x0000;
13483
 
                WriteParams.usWriteData |= ( pSharedInfo->ImageRegion[ i + 2 ].ulClockInfo << 8 );
13484
 
                WriteParams.usWriteData |= pSharedInfo->ImageRegion[ i + 2 ].ulReserved;
13485
 
 
13486
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13487
 
                if ( ulResult != cOCT6100_ERR_OK )
13488
 
                        return ulResult;
13489
 
        }
13490
 
 
13491
 
        /* Put NLP in config mode. */
13492
 
        WriteParams.ulWriteAddress = 0x2C2;
13493
 
        WriteParams.usWriteData = 0x160E;
13494
 
 
13495
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13496
 
        if ( ulResult != cOCT6100_ERR_OK )
13497
 
                return ulResult;
13498
 
 
13499
 
        WriteParams.ulWriteAddress = 0x692;
13500
 
        WriteParams.usWriteData = 0x010A;
13501
 
 
13502
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13503
 
        if ( ulResult != cOCT6100_ERR_OK )
13504
 
                return ulResult;
13505
 
 
13506
 
        /* Upload the up to 8 NLP pages + 1 AF page (for timing reasons). */
13507
 
        for ( i = 0; i < pSharedInfo->ImageRegion[ 1 ].ulPart1Size; i++ )
13508
 
        {
13509
 
                ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 1 ].ulPart1BaseAddress + 1028 * ( i * 2 ), 0x1280, 1024, &(ulEgoEntry[0]));
13510
 
                if ( ulResult != cOCT6100_ERR_OK )
13511
 
                        return ulResult;
13512
 
 
13513
 
                ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 1 ].ulPart1BaseAddress + 1028 * (( i * 2 ) + 1 ), 0x1680, 1024, &(ulEgoEntry[2]));
13514
 
                if ( ulResult != cOCT6100_ERR_OK )
13515
 
                        return ulResult;
13516
 
 
13517
 
                ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
13518
 
                if ( ulResult != cOCT6100_ERR_OK )
13519
 
                        return ulResult;
13520
 
                
13521
 
                /* Shift mt chariot memories. This process will complete by the time */
13522
 
                /* the next LSU transfer is done. */
13523
 
                WriteParams.ulWriteAddress = 0x692;
13524
 
                WriteParams.usWriteData = 0x010B;
13525
 
 
13526
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13527
 
                if ( ulResult != cOCT6100_ERR_OK )
13528
 
                        return ulResult;
13529
 
 
13530
 
                ulResult = Oct6100ApiWaitForPcRegisterBit( f_pApiInstance, 0x692, 0, 0, 100000, &fBitEqual );
13531
 
                if ( ulResult != cOCT6100_ERR_OK )
13532
 
                        return ulResult;
13533
 
                if ( TRUE != fBitEqual )
13534
 
                        return cOCT6100_ERR_FATAL_1A;
13535
 
        }
13536
 
 
13537
 
        /* 1 AF page (for timing reasons). */
13538
 
        ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 0), 0x1280, 512, &(ulEgoEntry[0]));
13539
 
        if ( ulResult != cOCT6100_ERR_OK )
13540
 
                return ulResult;
13541
 
 
13542
 
        ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 1), 0x1480, 512, &(ulEgoEntry[2]));
13543
 
        if ( ulResult != cOCT6100_ERR_OK )
13544
 
                return ulResult;
13545
 
 
13546
 
        ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
13547
 
        if ( ulResult != cOCT6100_ERR_OK )
13548
 
                return ulResult;
13549
 
 
13550
 
        ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 2), 0x1680, 512, &(ulEgoEntry[0]));
13551
 
        if ( ulResult != cOCT6100_ERR_OK )
13552
 
                return ulResult;
13553
 
 
13554
 
        ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 3), 0x1880, 512, &(ulEgoEntry[2]));
13555
 
        if ( ulResult != cOCT6100_ERR_OK )
13556
 
                return ulResult;
13557
 
 
13558
 
        ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
13559
 
        if ( ulResult != cOCT6100_ERR_OK )
13560
 
                return ulResult;
13561
 
 
13562
 
        /* Write constant memory init context position in channel "672" for pgsp. */
13563
 
        WriteParams.ulWriteAddress = 0x71A;
13564
 
        WriteParams.usWriteData = 0x8000;
13565
 
 
13566
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13567
 
        if ( ulResult != cOCT6100_ERR_OK )
13568
 
                return ulResult;
13569
 
 
13570
 
        /* Set fixed PGSP event_in base address to 800 on a 2k boundary */
13571
 
        WriteParams.ulWriteAddress = 0x716;
13572
 
        WriteParams.usWriteData = 0x800 >> 11;
13573
 
 
13574
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13575
 
        if ( ulResult != cOCT6100_ERR_OK )
13576
 
                return ulResult;
13577
 
 
13578
 
        /* Set fixed PGSP event_out to 0x2C0000h on a 16k boundary */
13579
 
        WriteParams.ulWriteAddress = 0x71C;
13580
 
        WriteParams.usWriteData = 0x2C0000 >> 14;
13581
 
 
13582
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13583
 
        if ( ulResult != cOCT6100_ERR_OK )
13584
 
                return ulResult;
13585
 
 
13586
 
        /* Give chariot control of the chip. */
13587
 
        WriteParams.ulWriteAddress = 0x712;
13588
 
        WriteParams.usWriteData = 0x0000;
13589
 
 
13590
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13591
 
        if ( ulResult != cOCT6100_ERR_OK )
13592
 
                return ulResult;
13593
 
 
13594
 
        WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x2C0000 + 0xC;
13595
 
        ulTempAddress = 0x300000 + 0x0800;
13596
 
        WriteParams.usWriteData = (UINT16)( ( ulTempAddress >> 16 ) & 0x07FF );
13597
 
 
13598
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13599
 
        if ( ulResult != cOCT6100_ERR_OK )
13600
 
                return ulResult;
13601
 
 
13602
 
        WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x2C0000 + 0xE;
13603
 
        WriteParams.usWriteData = (UINT16)( ( ulTempAddress >> 0 ) & 0xFF00 );
13604
 
 
13605
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13606
 
        if ( ulResult != cOCT6100_ERR_OK )
13607
 
                return ulResult;
13608
 
 
13609
 
        /* Write the init PGSP event in place. */
13610
 
        WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x800;
13611
 
        WriteParams.usWriteData = 0x0200;
13612
 
 
13613
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13614
 
        if ( ulResult != cOCT6100_ERR_OK )
13615
 
                return ulResult;
13616
 
 
13617
 
        WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x802;
13618
 
        WriteParams.usWriteData = 0x02A0;
13619
 
 
13620
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13621
 
        if ( ulResult != cOCT6100_ERR_OK )
13622
 
                return ulResult;
13623
 
 
13624
 
        /* Also write the register 710, which tells PGSP how many tones are supported. */
13625
 
        WriteParams.ulWriteAddress = 0x710;
13626
 
        WriteParams.usWriteData = 0x0000;
13627
 
        WriteParams.usWriteData |= pChipConfig->pbyImageFile[ 0x7FA ] << 8;
13628
 
        WriteParams.usWriteData |= pChipConfig->pbyImageFile[ 0x7FB ] << 0;
13629
 
 
13630
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13631
 
        if ( ulResult != cOCT6100_ERR_OK )
13632
 
                return ulResult;
13633
 
 
13634
 
        /* Start both processors in the NLP. */
13635
 
        WriteParams.ulWriteAddress = 0x373FE;
13636
 
        WriteParams.usWriteData = 0x00FF;
13637
 
 
13638
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13639
 
        if ( ulResult != cOCT6100_ERR_OK )
13640
 
                return ulResult;
13641
 
 
13642
 
        WriteParams.ulWriteAddress = 0x37BFE;
13643
 
        WriteParams.usWriteData = 0x00FE;       /* Tell processor 1 to just go to sleep. */
13644
 
 
13645
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13646
 
        if ( ulResult != cOCT6100_ERR_OK )
13647
 
                return ulResult;
13648
 
 
13649
 
        WriteParams.ulWriteAddress = 0x37FC6;
13650
 
        WriteParams.usWriteData = 0x8004;       /* First PC.*/
13651
 
 
13652
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13653
 
        if ( ulResult != cOCT6100_ERR_OK )
13654
 
                return ulResult;
13655
 
 
13656
 
        WriteParams.ulWriteAddress = 0x37FD0;
13657
 
        WriteParams.usWriteData = 0x0002;       /* Take out of reset. */
13658
 
 
13659
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13660
 
        if ( ulResult != cOCT6100_ERR_OK )
13661
 
                return ulResult;
13662
 
 
13663
 
        WriteParams.ulWriteAddress = 0x37FD2;
13664
 
        WriteParams.usWriteData = 0x0002;       /* Take out of reset. */
13665
 
 
13666
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13667
 
        if ( ulResult != cOCT6100_ERR_OK )
13668
 
                return ulResult;
13669
 
 
13670
 
        /* Start processor in the AF. */
13671
 
        for ( i = 0; i < 16; i ++ )
13672
 
        {
13673
 
                WriteParams.ulWriteAddress = cOCT6100_POUCH_BASE + ( i * 2 );
13674
 
                if ( i == 9 )
13675
 
                {
13676
 
                        if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
13677
 
                        {
13678
 
                                WriteParams.usWriteData = cOCT6100_PRODUCTION_BOOT_TYPE;
13679
 
                        }
13680
 
                        else
13681
 
                        {
13682
 
                                WriteParams.usWriteData = cOCT6100_AF_BOOT_TYPE;
13683
 
                        }
13684
 
                }
13685
 
                else
13686
 
                        WriteParams.usWriteData = 0x0000;
13687
 
 
13688
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13689
 
                if ( ulResult != cOCT6100_ERR_OK )
13690
 
                        return ulResult;
13691
 
        }
13692
 
 
13693
 
        /* Check if the production BIST mode was requested. */
13694
 
        if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
13695
 
        {
13696
 
                UINT32  ulTotalElements = 3;
13697
 
                UINT32  ulCrcKey;
13698
 
                UINT32  aulMessage[ 4 ];
13699
 
                UINT32  ulWriteAddress = 0x20 + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
13700
 
 
13701
 
                /* Magic key. */
13702
 
                aulMessage[ 0 ] = 0xCAFECAFE; 
13703
 
                /* Memory size. */
13704
 
                aulMessage[ 1 ] = pSharedInfo->MiscVars.ulTotalMemSize;
13705
 
                /* Loop count. */
13706
 
                aulMessage[ 2 ] = pSharedInfo->ChipConfig.ulNumProductionBistLoops;
13707
 
                /* CRC initialized. */
13708
 
                aulMessage[ 3 ] = 0;
13709
 
 
13710
 
                ulResult = Oct6100ApiProductionCrc( f_pApiInstance, aulMessage, ulTotalElements, &ulCrcKey );
13711
 
                if ( ulResult != cOCT6100_ERR_OK )
13712
 
                        return ulResult;
13713
 
 
13714
 
                aulMessage[ 3 ] = ulCrcKey;
13715
 
 
13716
 
                /* Write the message to the external memory. */
13717
 
                for ( i = 0; i < ulTotalElements + 1; i ++ )
13718
 
                {
13719
 
                        ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulWriteAddress + i * 4, aulMessage[ i ] );
13720
 
                        if ( ulResult != cOCT6100_ERR_OK )
13721
 
                                return ulResult;
13722
 
                }
13723
 
        }
13724
 
 
13725
 
        WriteParams.ulWriteAddress = 0xFFFC6;
13726
 
        WriteParams.usWriteData = 0x1284;       /* First PC.*/
13727
 
 
13728
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13729
 
        if ( ulResult != cOCT6100_ERR_OK )
13730
 
                return ulResult;
13731
 
        
13732
 
        WriteParams.ulWriteAddress = 0xFFFD0;
13733
 
        WriteParams.usWriteData = 0x0002;       /* Take out of reset. */
13734
 
 
13735
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13736
 
        if ( ulResult != cOCT6100_ERR_OK )
13737
 
                return ulResult;
13738
 
 
13739
 
        while ( ulAfCpuUp == FALSE )
13740
 
        {
13741
 
                if ( ulAfCpuUp == FALSE )
13742
 
                {
13743
 
                        ReadParams.ulReadAddress = cOCT6100_POUCH_BASE;
13744
 
                        ReadParams.pusReadData = &usReadHighData;
13745
 
 
13746
 
                        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
13747
 
                        if ( ulResult != cOCT6100_ERR_OK )
13748
 
                                return ulResult;
13749
 
 
13750
 
                        ReadParams.ulReadAddress += 2;
13751
 
                        ReadParams.pusReadData = &usReadData;
13752
 
 
13753
 
                        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
13754
 
                        if ( ulResult != cOCT6100_ERR_OK )
13755
 
                                return ulResult;
13756
 
 
13757
 
                        if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
13758
 
                        {
13759
 
                                /* Should read 0x0007 when bisting. */
13760
 
                                if ( ( usReadHighData & 0xFFFF ) == cOCT6100_PRODUCTION_BOOT_TYPE )
13761
 
                                {
13762
 
                                        /* Verify if the bist has started successfully. */
13763
 
                                        if ( ( usReadData & 0xFFFF ) == 0x0002 )
13764
 
                                                return cOCT6100_ERR_OPEN_PRODUCTION_BIST_CONF_FAILED;
13765
 
                                        else if ( ( usReadData & 0xFFFF ) != 0xEEEE )
13766
 
                                                return cOCT6100_ERR_OPEN_PRODUCTION_BOOT_FAILED;
13767
 
 
13768
 
                                        ulAfCpuUp = TRUE;
13769
 
                                }
13770
 
                        }
13771
 
                        else /* if ( pSharedInfo->ChipConfig.fEnableProductionBist == FALSE ) */
13772
 
                        {
13773
 
                                if ( ( usReadHighData & 0xFFFF ) == cOCT6100_AF_BOOT_TYPE )
13774
 
                                {
13775
 
                                        /* Verify if the bist succeeded. */
13776
 
                                        if ( ( usReadData & 0xFFFF ) != 0x0000 )
13777
 
                                                return cOCT6100_ERR_OPEN_FUNCTIONAL_BIST_FAILED;        /* Bad chip. */
13778
 
 
13779
 
                                        ulAfCpuUp = TRUE;
13780
 
                                }
13781
 
                        }
13782
 
                }
13783
 
 
13784
 
                ulLoopCounter++;
13785
 
 
13786
 
                if ( ulLoopCounter == cOCT6100_MAX_LOOP_CPU_TIMEOUT )
13787
 
                        return cOCT6100_ERR_OPEN_AF_CPU_TIMEOUT;
13788
 
        }
13789
 
 
13790
 
        /* Return NLP in operationnal mode. */
13791
 
        WriteParams.ulWriteAddress = 0x2C2;
13792
 
        WriteParams.usWriteData = 0x060E;
13793
 
 
13794
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13795
 
        if ( ulResult != cOCT6100_ERR_OK )
13796
 
                return ulResult;
13797
 
 
13798
 
        WriteParams.ulWriteAddress = 0x692;
13799
 
        WriteParams.usWriteData = 0x0000;
13800
 
 
13801
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13802
 
        if ( ulResult != cOCT6100_ERR_OK )
13803
 
                return ulResult;
13804
 
 
13805
 
        return cOCT6100_ERR_OK;
13806
 
}
13807
 
 
13808
 
 
13809
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13810
 
 
13811
 
Function:               Oct6100ApiSetH100Register
13812
 
 
13813
 
Description:    This function will configure the H.100 registers.
13814
 
 
13815
 
-------------------------------------------------------------------------------
13816
 
|       Argument                |       Description
13817
 
-------------------------------------------------------------------------------
13818
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
13819
 
                                        present state of the chip and all its resources.
13820
 
 
13821
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13822
 
static UINT32 Oct6100ApiSetH100Register(
13823
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
13824
 
{
13825
 
        tOCT6100_WRITE_PARAMS           WriteParams;
13826
 
        UINT32                                          ulResult;
13827
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
13828
 
        tPOCT6100_API_CHIP_CONFIG       pChipConfig;
13829
 
        UINT32                                          i;
13830
 
        UINT32                                          ulOffset;
13831
 
        BOOL                                            fAllStreamAt2Mhz = TRUE;
13832
 
        const UINT16    ausAdpcmResetContext[32] = { 0x1100, 0x0220, 0x0000, 0x0000, 0x0000, 0x0020, 0x0000, 0x0000, 0x0008, 0x0000, 0x0000, 0x0100, 0x0000, 0x0020, 0x0000, 0x0000, 0x0000, 0x0002, 0x0000, 0x0000, 0x0040, 
13833
 
                                                                                                 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x0000, 0x0010, 0x0000, 0x0000, 0x0000};
13834
 
 
13835
 
        /* Get local pointer to shared portion of instance. */
13836
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
13837
 
 
13838
 
        /* Get local pointer to the chip configuration structure. */
13839
 
        pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
13840
 
 
13841
 
        /* Initialize the process context and user chip ID once and for all. */
13842
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13843
 
 
13844
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
13845
 
 
13846
 
        /* Set the Global OE bit. */
13847
 
        WriteParams.ulWriteAddress = 0x300;
13848
 
        WriteParams.usWriteData = 0x0004;
13849
 
 
13850
 
        /* Set the number of streams. */
13851
 
        switch( pChipConfig->byMaxTdmStreams )
13852
 
        {
13853
 
        case 32:
13854
 
                WriteParams.usWriteData |= ( 0 << 3 );
13855
 
                break;
13856
 
        case 16:
13857
 
                WriteParams.usWriteData |= ( 1 << 3 );
13858
 
                break;
13859
 
        case 8:
13860
 
                WriteParams.usWriteData |= ( 2 << 3 );
13861
 
                break;
13862
 
        case 4:
13863
 
                WriteParams.usWriteData |= ( 3 << 3 );
13864
 
                break;
13865
 
        default:
13866
 
                break;
13867
 
        }
13868
 
 
13869
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13870
 
        if ( ulResult != cOCT6100_ERR_OK )
13871
 
                return ulResult;
13872
 
 
13873
 
        /* Configure the stream frequency. */
13874
 
        WriteParams.ulWriteAddress = 0x330;
13875
 
        WriteParams.usWriteData = 0x0000;
13876
 
        for ( i = 0; i < (UINT32)(pChipConfig->byMaxTdmStreams / 4); i++)
13877
 
        {
13878
 
                ulOffset = i*2;
13879
 
                switch( pChipConfig->aulTdmStreamFreqs[ i ] )
13880
 
                {
13881
 
                case cOCT6100_TDM_STREAM_FREQ_2MHZ:
13882
 
                        WriteParams.usWriteData |= ( 0x0 << ulOffset );
13883
 
                        break;
13884
 
                case cOCT6100_TDM_STREAM_FREQ_4MHZ:
13885
 
                        WriteParams.usWriteData |= ( 0x1 << ulOffset );
13886
 
                        fAllStreamAt2Mhz = FALSE;
13887
 
                        break;
13888
 
                case cOCT6100_TDM_STREAM_FREQ_8MHZ:
13889
 
                        WriteParams.usWriteData |= ( 0x2 << ulOffset );
13890
 
                        fAllStreamAt2Mhz = FALSE;
13891
 
                        break;
13892
 
                default:
13893
 
                        break;
13894
 
                }
13895
 
        }
13896
 
 
13897
 
        /* Set the stream to 16 MHz if the fast H.100 mode is selected. */
13898
 
        if ( pChipConfig->fEnableFastH100Mode == TRUE )
13899
 
        {
13900
 
                fAllStreamAt2Mhz = FALSE;
13901
 
                WriteParams.usWriteData = 0xFFFF;
13902
 
        }
13903
 
 
13904
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13905
 
        if ( ulResult != cOCT6100_ERR_OK )
13906
 
                return ulResult;
13907
 
 
13908
 
        if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
13909
 
        {
13910
 
                /* Make the chip track both clock A and B to perform fast H.100 mode. */
13911
 
                WriteParams.ulWriteAddress = 0x322;
13912
 
                WriteParams.usWriteData = 0x0004;
13913
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13914
 
                if ( ulResult != cOCT6100_ERR_OK )
13915
 
                        return ulResult;
13916
 
 
13917
 
                /* Enable the fast H.100 mode. */
13918
 
                WriteParams.ulWriteAddress = 0x332;
13919
 
                WriteParams.usWriteData = 0x0003;
13920
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13921
 
                if ( ulResult != cOCT6100_ERR_OK )
13922
 
                        return ulResult;
13923
 
        }
13924
 
 
13925
 
        WriteParams.ulWriteAddress = 0x376;
13926
 
        WriteParams.usWriteData = (UINT16)( pSharedInfo->MiscVars.usTdmClkBoundary );
13927
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13928
 
        if ( ulResult != cOCT6100_ERR_OK )
13929
 
                return ulResult;
13930
 
 
13931
 
        /* Select delay for early clock (90 and 110). */
13932
 
        WriteParams.ulWriteAddress = 0x378;
13933
 
        if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
13934
 
                WriteParams.usWriteData = 0x000A;
13935
 
        else
13936
 
        {
13937
 
                /* Set the TDM sampling. */
13938
 
                if ( pSharedInfo->ChipConfig.byTdmSampling == cOCT6100_TDM_SAMPLE_AT_RISING_EDGE )
13939
 
                {
13940
 
                        WriteParams.usWriteData = 0x0AF0;
13941
 
                }
13942
 
                else if ( pSharedInfo->ChipConfig.byTdmSampling == cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE )
13943
 
                {
13944
 
                        WriteParams.usWriteData = 0x0A0F;
13945
 
                }
13946
 
                else /* pSharedInfo->ChipConfig.ulTdmSampling == cOCT6100_TDM_SAMPLE_AT_3_QUARTERS */
13947
 
                {
13948
 
                        WriteParams.usWriteData = 0x0A08;
13949
 
                }
13950
 
        }
13951
 
 
13952
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13953
 
        if ( ulResult != cOCT6100_ERR_OK )
13954
 
                return ulResult;
13955
 
 
13956
 
        /* Protect chip by preventing too rapid timeslot arrival (mclk == 133 MHz). */
13957
 
        WriteParams.ulWriteAddress = 0x37A;
13958
 
        WriteParams.usWriteData = (UINT16)pSharedInfo->MiscVars.usMaxH100Speed;
13959
 
 
13960
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13961
 
        if ( ulResult != cOCT6100_ERR_OK )
13962
 
                return ulResult;
13963
 
 
13964
 
        /* Allow H.100 TS to progress. */
13965
 
        WriteParams.ulWriteAddress = 0x382;
13966
 
        WriteParams.usWriteData = 0x0000;
13967
 
 
13968
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13969
 
        if ( ulResult != cOCT6100_ERR_OK )
13970
 
                return ulResult;
13971
 
 
13972
 
        /* Set by-pass mode. */
13973
 
        WriteParams.ulWriteAddress = 0x50E;
13974
 
        WriteParams.usWriteData = 0x0001;
13975
 
 
13976
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13977
 
        if ( ulResult != cOCT6100_ERR_OK )
13978
 
                return ulResult;
13979
 
 
13980
 
        /* TDMIE bits. */
13981
 
        WriteParams.ulWriteAddress = 0x500;
13982
 
        WriteParams.usWriteData = 0x0003;
13983
 
 
13984
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13985
 
        if ( ulResult != cOCT6100_ERR_OK )
13986
 
                return ulResult;
13987
 
 
13988
 
        /* Write normal ADPCM reset values in ADPCM context 1344. */
13989
 
        for(i=0;i<32;i++)
13990
 
        {
13991
 
                WriteParams.ulWriteAddress = 0x140000 + ( 0x40 * 1344 ) + ( i * 2 );
13992
 
                WriteParams.usWriteData = ausAdpcmResetContext[i];
13993
 
 
13994
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13995
 
                if ( ulResult != cOCT6100_ERR_OK )
13996
 
                        return ulResult;
13997
 
        }
13998
 
 
13999
 
        /* Make sure delay flops are configured correctly if all streams are at 2 MHz. */
14000
 
        if ( fAllStreamAt2Mhz == TRUE )
14001
 
        {
14002
 
                /* Setup H.100 sampling to lowest value. */
14003
 
                WriteParams.ulWriteAddress = 0x144;
14004
 
                WriteParams.usWriteData = 0x4041;
14005
 
 
14006
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14007
 
                if ( ulResult != cOCT6100_ERR_OK  )
14008
 
                        return ulResult;
14009
 
 
14010
 
                WriteParams.ulWriteAddress = 0x378;
14011
 
                WriteParams.usWriteData = 0x0A00;
14012
 
 
14013
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14014
 
                if ( ulResult != cOCT6100_ERR_OK  )
14015
 
                        return ulResult;
14016
 
        }
14017
 
        
14018
 
        return cOCT6100_ERR_OK;
14019
 
}
14020
 
 
14021
 
 
14022
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14023
 
 
14024
 
Function:               Oct6100ApiWriteMiscellaneousRegisters
14025
 
 
14026
 
Description:    This function will write to various registers to activate the chip.
14027
 
 
14028
 
-------------------------------------------------------------------------------
14029
 
|       Argument                |       Description
14030
 
-------------------------------------------------------------------------------
14031
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
14032
 
                                        present state of the chip and all its resources.
14033
 
 
14034
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14035
 
static UINT32 Oct6100ApiWriteMiscellaneousRegisters(
14036
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
14037
 
{
14038
 
        tOCT6100_WRITE_PARAMS   WriteParams;
14039
 
        UINT32  ulResult;
14040
 
 
14041
 
        /* Initialize the process context and user chip ID once and for all. */
14042
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
14043
 
 
14044
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
14045
 
 
14046
 
        /* Free the interrupt pin of the chip (i.e. remove minimum time requirement between interrupts). */
14047
 
        WriteParams.ulWriteAddress = 0x214;
14048
 
        WriteParams.usWriteData = 0x0000;
14049
 
        if ( f_pApiInstance->pSharedInfo->ChipConfig.byInterruptPolarity == cOCT6100_ACTIVE_HIGH_POLARITY )
14050
 
                WriteParams.usWriteData |= 0x4000;
14051
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
14052
 
        if ( ulResult != cOCT6100_ERR_OK )
14053
 
                return ulResult;
14054
 
 
14055
 
        /* Write MT chariot interval */
14056
 
        WriteParams.ulWriteAddress = 0x2C2;
14057
 
        if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels > 640 )
14058
 
                WriteParams.usWriteData = 0x05EA;
14059
 
        else if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels > 513 )
14060
 
                WriteParams.usWriteData = 0x0672;
14061
 
        else /* if ( f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels <= 513 ) */
14062
 
                WriteParams.usWriteData = 0x0750;
14063
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14064
 
        if ( ulResult != cOCT6100_ERR_OK )
14065
 
                return ulResult;
14066
 
 
14067
 
        /* Write set second part5 time. */
14068
 
        WriteParams.ulWriteAddress = 0x2C4;
14069
 
        WriteParams.usWriteData = 0x04A0;
14070
 
 
14071
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14072
 
        if ( ulResult != cOCT6100_ERR_OK )
14073
 
                return ulResult;
14074
 
 
14075
 
        /* Write CPU bucket timer to guarantee 200 cycles between each CPU access. */
14076
 
        WriteParams.ulWriteAddress = 0x234;
14077
 
        WriteParams.usWriteData = 0x0804;       
14078
 
 
14079
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14080
 
        if ( ulResult != cOCT6100_ERR_OK )
14081
 
                return ulResult;
14082
 
 
14083
 
        WriteParams.ulWriteAddress = 0x236;
14084
 
        WriteParams.usWriteData = 0x0100;
14085
 
 
14086
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14087
 
        if ( ulResult != cOCT6100_ERR_OK )
14088
 
                return ulResult;
14089
 
 
14090
 
        return cOCT6100_ERR_OK;
14091
 
}
14092
 
 
14093
 
 
14094
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14095
 
 
14096
 
Function:               Oct6100ApiCreateSerializeObjects
14097
 
 
14098
 
Description:    Creates a handle to each serialization object used by the API.
14099
 
 
14100
 
                                Note that in a multi-process system the user's process context
14101
 
                                structure pointer is needed by this function.  Thus, the
14102
 
                                pointer must be valid.
14103
 
 
14104
 
-------------------------------------------------------------------------------
14105
 
|       Argument                |       Description
14106
 
-------------------------------------------------------------------------------
14107
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
14108
 
                                        present state of the chip and all its resources.
14109
 
 
14110
 
f_ulUserChipId          User chip ID for this serialization object.
14111
 
 
14112
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14113
 
static UINT32 Oct6100ApiCreateSerializeObjects(
14114
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance,
14115
 
                                IN              UINT32                                  f_ulUserChipId )
14116
 
{
14117
 
        tOCT6100_CREATE_SERIALIZE_OBJECT        CreateSerObj = { 0, };
14118
 
        UINT32  ulResult;
14119
 
        CHAR    szSerObjName[ 64 ] = "Oct6100ApiXXXXXXXXApiSerObj";
14120
 
 
14121
 
 
14122
 
        /* Set some parameters of the create structure once and for all. */
14123
 
        CreateSerObj.pProcessContext = f_pApiInstance->pProcessContext;
14124
 
        CreateSerObj.pszSerialObjName = szSerObjName;
14125
 
 
14126
 
        /*----------------------------------------------------------------------*/
14127
 
        /* Set the chip ID in the semaphore name. */
14128
 
        szSerObjName[ 10 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 28 ) & 0xFF );
14129
 
        szSerObjName[ 11 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 24 ) & 0xFF );
14130
 
        szSerObjName[ 12 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 20 ) & 0xFF );
14131
 
        szSerObjName[ 13 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 16 ) & 0xFF );
14132
 
        szSerObjName[ 14 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >> 12 ) & 0xFF );
14133
 
        szSerObjName[ 15 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >>  8 ) & 0xFF );
14134
 
        szSerObjName[ 16 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >>  4 ) & 0xFF );
14135
 
        szSerObjName[ 17 ] = (CHAR) Oct6100ApiHexToAscii( (f_ulUserChipId >>  0 ) & 0xFF );
14136
 
 
14137
 
        ulResult = Oct6100UserCreateSerializeObject( &CreateSerObj );
14138
 
        if ( ulResult != cOCT6100_ERR_OK )
14139
 
                return ulResult;
14140
 
        f_pApiInstance->ulApiSerObj = CreateSerObj.ulSerialObjHndl;
14141
 
        /*----------------------------------------------------------------------*/
14142
 
 
14143
 
 
14144
 
 
14145
 
        return cOCT6100_ERR_OK;
14146
 
}
14147
 
 
14148
 
 
14149
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14150
 
 
14151
 
Function:               Oct6100ApiDestroySerializeObjects
14152
 
 
14153
 
Description:    Destroy handles to each serialization object used by the API.
14154
 
 
14155
 
                                Note that in a multi-process system the user's process context
14156
 
                                structure pointer is needed by this function.  Thus, the
14157
 
                                pointer must be valid.
14158
 
 
14159
 
-------------------------------------------------------------------------------
14160
 
|       Argument                |       Description
14161
 
-------------------------------------------------------------------------------
14162
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
14163
 
                                        present state of the chip and all its resources.
14164
 
 
14165
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14166
 
static UINT32 Oct6100ApiDestroySerializeObjects(
14167
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
14168
 
{
14169
 
        tOCT6100_DESTROY_SERIALIZE_OBJECT       DestroySerObj;
14170
 
        UINT32  ulResult;
14171
 
 
14172
 
        /* Set some parameters of the create structure once and for all. */
14173
 
        DestroySerObj.pProcessContext = f_pApiInstance->pProcessContext;
14174
 
        DestroySerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;    
14175
 
 
14176
 
        ulResult = Oct6100UserDestroySerializeObject( &DestroySerObj );
14177
 
        if ( ulResult != cOCT6100_ERR_OK )
14178
 
                return ulResult;
14179
 
 
14180
 
        return cOCT6100_ERR_OK;
14181
 
}
14182
 
 
14183
 
 
14184
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14185
 
 
14186
 
Function:               Oct6100ApiRunEgo
14187
 
 
14188
 
Description:    Private function used to communicate with the internal processors.
14189
 
 
14190
 
-------------------------------------------------------------------------------
14191
 
|       Argument                |       Description
14192
 
-------------------------------------------------------------------------------
14193
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
14194
 
                                        present state of the chip and all its resources.
14195
 
 
14196
 
f_fStoreFlag            Type of access performed. (Load or Store)
14197
 
f_ulNumEntry            Number of access.
14198
 
f_aulEntry                      Array of access to perform.
14199
 
 
14200
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14201
 
static UINT32 Oct6100ApiRunEgo( 
14202
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance, 
14203
 
                                IN              BOOL                                                    f_fStoreFlag, 
14204
 
                                IN              UINT32                                                  f_ulNumEntry, 
14205
 
                                OUT             PUINT32                                                 f_aulEntry )
14206
 
{
14207
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
14208
 
        tPOCT6100_API_CHIP_CONFIG       pChipConfig;
14209
 
        tOCT6100_WRITE_PARAMS           WriteParams;
14210
 
        tOCT6100_READ_PARAMS            ReadParams;
14211
 
        UINT32  ulResult;
14212
 
        UINT32  aulCpuLsuCmd[ 2 ];
14213
 
        UINT16  usReadData;
14214
 
        UINT32  i;
14215
 
        BOOL    fConditionFlag = TRUE;
14216
 
        UINT32  ulLoopCounter = 0;
14217
 
 
14218
 
        /* Get local pointer to shared portion of instance. */
14219
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
14220
 
 
14221
 
        /* Get local pointer to the chip configuration structure. */
14222
 
        pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
14223
 
 
14224
 
        /* Set the process context and user chip ID parameters once and for all. */
14225
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
14226
 
 
14227
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
14228
 
 
14229
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
14230
 
 
14231
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
14232
 
        ReadParams.pusReadData = &usReadData;
14233
 
 
14234
 
        /* No more than 2 entries may be requested. */
14235
 
        if ( f_ulNumEntry > 2 )
14236
 
                return cOCT6100_ERR_FATAL_1B;
14237
 
 
14238
 
        /* Write the requested entries at address reserved for CPU. */
14239
 
        for( i = 0; i < f_ulNumEntry; i++ )
14240
 
        {
14241
 
                WriteParams.ulWriteAddress = cOCT6100_PART1_API_SCRATCH_PAD + ( 0x8 * i );
14242
 
                WriteParams.usWriteData = (UINT16)(( f_aulEntry[ i * 2 ] >> 16 ) & 0xFFFF );
14243
 
 
14244
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14245
 
                if ( ulResult != cOCT6100_ERR_OK )
14246
 
                        return ulResult;
14247
 
 
14248
 
                WriteParams.ulWriteAddress += 2;
14249
 
                WriteParams.usWriteData = (UINT16)( f_aulEntry[ i * 2 ] & 0xFFFF );
14250
 
 
14251
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14252
 
                if ( ulResult != cOCT6100_ERR_OK )
14253
 
                        return ulResult;
14254
 
 
14255
 
                WriteParams.ulWriteAddress += 2;
14256
 
                WriteParams.usWriteData = (UINT16)(( f_aulEntry[ (i * 2) + 1] >> 16 ) & 0xFFFF );
14257
 
 
14258
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14259
 
                if ( ulResult != cOCT6100_ERR_OK )
14260
 
                        return ulResult;
14261
 
 
14262
 
                WriteParams.ulWriteAddress += 2;
14263
 
                WriteParams.usWriteData = (UINT16)( f_aulEntry[ (i * 2) + 1] & 0xFFFF );
14264
 
 
14265
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14266
 
                if ( ulResult != cOCT6100_ERR_OK )
14267
 
                        return ulResult;
14268
 
        }
14269
 
 
14270
 
        /* Preincrement code point. */
14271
 
        pSharedInfo->MiscVars.usCodepoint++;
14272
 
 
14273
 
        /* Create DWORD 0 of command. */
14274
 
        aulCpuLsuCmd[0] = 0x00000000;
14275
 
        if ( f_fStoreFlag == FALSE )
14276
 
                aulCpuLsuCmd[0] |= 0xC0000000;  /* EGO load. */
14277
 
        else
14278
 
                aulCpuLsuCmd[0] |= 0xE0000000;  /* EGO store. */
14279
 
 
14280
 
        aulCpuLsuCmd[0] |= (f_ulNumEntry - 1) << 19;
14281
 
        aulCpuLsuCmd[0] |= cOCT6100_PART1_API_SCRATCH_PAD;
14282
 
 
14283
 
        /* Create DWORD 1 of command. */
14284
 
        aulCpuLsuCmd[1] = 0x00000000;
14285
 
        aulCpuLsuCmd[1] |= ( ( cOCT6100_PART1_API_SCRATCH_PAD + 0x10 ) & 0xFFFF ) << 16;
14286
 
        aulCpuLsuCmd[1] |= pSharedInfo->MiscVars.usCodepoint;
14287
 
 
14288
 
        /* Write the EGO command in the LSU CB. */
14289
 
        WriteParams.ulWriteAddress = cOCT6100_PART1_CPU_LSU_CB_BASE + ((pSharedInfo->MiscVars.usCpuLsuWritePtr & 0x7) * 0x8 );
14290
 
        WriteParams.usWriteData = (UINT16)(( aulCpuLsuCmd[ 0 ] >> 16 ) & 0xFFFF );
14291
 
 
14292
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14293
 
        if ( ulResult != cOCT6100_ERR_OK )
14294
 
                return ulResult;
14295
 
        
14296
 
        WriteParams.ulWriteAddress += 2;
14297
 
        WriteParams.usWriteData = (UINT16)( aulCpuLsuCmd[ 0 ] & 0xFFFF );
14298
 
 
14299
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14300
 
        if ( ulResult != cOCT6100_ERR_OK )
14301
 
                return ulResult;
14302
 
 
14303
 
        WriteParams.ulWriteAddress += 2;
14304
 
        WriteParams.usWriteData = (UINT16)(( aulCpuLsuCmd[ 1 ] >> 16 ) & 0xFFFF );
14305
 
 
14306
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14307
 
        if ( ulResult != cOCT6100_ERR_OK )
14308
 
                return ulResult;
14309
 
 
14310
 
        WriteParams.ulWriteAddress += 2;
14311
 
        WriteParams.usWriteData = (UINT16)( aulCpuLsuCmd[ 1 ] & 0xFFFF );
14312
 
 
14313
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14314
 
        if ( ulResult != cOCT6100_ERR_OK )
14315
 
                return ulResult;
14316
 
 
14317
 
        /* Post increment the write pointer. */
14318
 
        pSharedInfo->MiscVars.usCpuLsuWritePtr++;
14319
 
 
14320
 
        /* Indicate new write pointer position to HW. */
14321
 
        WriteParams.ulWriteAddress = cOCT6100_PART1_EGO_REG + 0x5A;
14322
 
        WriteParams.usWriteData = (UINT16)( pSharedInfo->MiscVars.usCpuLsuWritePtr & 0x7 );
14323
 
 
14324
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14325
 
        if ( ulResult != cOCT6100_ERR_OK )
14326
 
                return ulResult;
14327
 
 
14328
 
        /* Wait for codepoint to be updated before returning. */
14329
 
        while( fConditionFlag )
14330
 
        {
14331
 
                ReadParams.ulReadAddress = cOCT6100_PART1_API_SCRATCH_PAD + 0x12;
14332
 
                usReadData = (UINT16)( pSharedInfo->MiscVars.usCodepoint );
14333
 
 
14334
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
14335
 
                if ( ulResult != cOCT6100_ERR_OK )
14336
 
                        return ulResult;
14337
 
        
14338
 
                if ( usReadData == pSharedInfo->MiscVars.usCodepoint )
14339
 
                        fConditionFlag = FALSE;
14340
 
 
14341
 
                ulLoopCounter++;
14342
 
 
14343
 
                if ( ulLoopCounter == cOCT6100_MAX_LOOP )
14344
 
                        return cOCT6100_ERR_OPEN_EGO_TIMEOUT;
14345
 
        }
14346
 
 
14347
 
        /* CRC error bit must be zero. */
14348
 
        ReadParams.ulReadAddress = 0x202;
14349
 
 
14350
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
14351
 
        if ( ulResult != cOCT6100_ERR_OK )
14352
 
                return ulResult;
14353
 
 
14354
 
        if ( ( usReadData & 0x0400 ) != 0 )
14355
 
                return cOCT6100_ERR_OPEN_CORRUPTED_IMAGE;
14356
 
        
14357
 
        return cOCT6100_ERR_OK;
14358
 
}
14359
 
 
14360
 
 
14361
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14362
 
 
14363
 
Function:               Oct6100ApiCreateEgoEntry
14364
 
 
14365
 
Description:    Private function used to create an access structure to be sent
14366
 
                                to the internal processors.
14367
 
 
14368
 
-------------------------------------------------------------------------------
14369
 
|       Argument                |       Description
14370
 
-------------------------------------------------------------------------------
14371
 
f_ulExternalAddress             External memory address for the access.
14372
 
f_ulInternalAddress             Which process should receive the command.
14373
 
f_ulNumBytes                    Number of bytes associated to the access.
14374
 
f_aulEntry                      Array of access to perform.
14375
 
 
14376
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14377
 
static UINT32 Oct6100ApiCreateEgoEntry( 
14378
 
                                IN              UINT32                                          f_ulExternalAddress, 
14379
 
                                IN              UINT32                                          f_ulInternalAddress, 
14380
 
                                IN              UINT32                                          f_ulNumBytes, 
14381
 
                                OUT             UINT32                                          f_aulEntry[ 2 ] )
14382
 
{
14383
 
        f_aulEntry[0] = 0x80000000;
14384
 
        f_aulEntry[0] |= f_ulExternalAddress & 0x07FFFFFC;
14385
 
        
14386
 
        f_aulEntry[1] = 0x0011C000;
14387
 
        f_aulEntry[1] |= (f_ulNumBytes / 8) << 23;
14388
 
        f_aulEntry[1] |= (f_ulInternalAddress >> 2) & 0x3FFF;
14389
 
 
14390
 
        return cOCT6100_ERR_OK;
14391
 
}
14392
 
 
14393
 
 
14394
 
 
14395
 
 
14396
 
 
14397
 
 
14398
 
 
14399
 
 
14400
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14401
 
 
14402
 
Function:               Oct6100ApiInitChannels
14403
 
 
14404
 
Description:    This function will initialize all the channels to power down.
14405
 
 
14406
 
-------------------------------------------------------------------------------
14407
 
|       Argument                |       Description
14408
 
-------------------------------------------------------------------------------
14409
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
14410
 
                                        present state of the chip and all its resources.
14411
 
 
14412
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14413
 
static UINT32 Oct6100ApiInitChannels(
14414
 
                                IN OUT  tPOCT6100_INSTANCE_API f_pApiInstance )
14415
 
{
14416
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
14417
 
        UINT32 i;
14418
 
        UINT32 ulResult;
14419
 
        tOCT6100_WRITE_BURST_PARAMS     BurstParams;
14420
 
        tOCT6100_WRITE_PARAMS           WriteParams;
14421
 
        tOCT6100_READ_PARAMS            ReadParams;
14422
 
        UINT16                                          usReadData;
14423
 
        UINT32                                          ulTempData;
14424
 
        UINT32                                          ulBaseAddress;
14425
 
        UINT32                                          ulFeatureBytesOffset;
14426
 
        UINT32                                          ulFeatureBitOffset;
14427
 
        UINT32                                          ulFeatureFieldLength;
14428
 
        UINT32                                          ulMask;
14429
 
        UINT16                                          ausWriteData[ 4 ];
14430
 
        UINT16                                          usLoopCount = 0;
14431
 
        UINT16                                          usWriteData = 0;
14432
 
        UINT16                                          usMclkRead;
14433
 
        UINT16                                          usLastMclkRead;
14434
 
        UINT16                                          usMclkDiff;
14435
 
        UINT32                                          ulNumberOfCycleToWait;
14436
 
 
14437
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
14438
 
 
14439
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
14440
 
 
14441
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
14442
 
 
14443
 
        BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
14444
 
 
14445
 
        BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
14446
 
        BurstParams.pusWriteData = ausWriteData;
14447
 
 
14448
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
14449
 
 
14450
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
14451
 
        ReadParams.pusReadData = &usReadData;
14452
 
        
14453
 
        /* Verify that the image has enough memory to work correctly. */
14454
 
        if ( ( pSharedInfo->MiscVars.ulTotalMemSize + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) < pSharedInfo->MemoryMap.ulFreeMemBaseAddress )
14455
 
                return cOCT6100_ERR_OPEN_INSUFFICIENT_EXTERNAL_MEMORY;
14456
 
 
14457
 
        /* Verify that the tail length is supported by the device.*/
14458
 
        if ( pSharedInfo->ChipConfig.usTailDisplacement > pSharedInfo->ImageInfo.usMaxTailDisplacement )
14459
 
                return cOCT6100_ERR_NOT_SUPPORTED_OPEN_TAIL_DISPLACEMENT_VALUE;
14460
 
 
14461
 
        /* Verify that acoustic echo is supported by the device. */
14462
 
        if ( pSharedInfo->ChipConfig.fEnableAcousticEcho == TRUE && pSharedInfo->ImageInfo.fAcousticEcho == FALSE )
14463
 
                return cOCT6100_ERR_NOT_SUPPORTED_OPEN_ACOUSTIC_ECHO;
14464
 
        
14465
 
        /* Verify that the image supports all the requested channels. */
14466
 
        if ( pSharedInfo->ChipConfig.usMaxChannels > pSharedInfo->ImageInfo.usMaxNumberOfChannels )
14467
 
                return cOCT6100_ERR_NOT_SUPPORTED_OPEN_MAX_ECHO_CHANNELS_VALUE;
14468
 
 
14469
 
        /* Max number of channels the image supports + 1 for channel recording, if requested */
14470
 
        if ( ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
14471
 
          && ( pSharedInfo->ImageInfo.usMaxNumberOfChannels < cOCT6100_MAX_ECHO_CHANNELS )
14472
 
          && ( pSharedInfo->ChipConfig.usMaxChannels == pSharedInfo->ImageInfo.usMaxNumberOfChannels ) )
14473
 
                return cOCT6100_ERR_NOT_SUPPORTED_OPEN_MAX_ECHO_CHANNELS_VALUE; 
14474
 
        
14475
 
        /* Initialize the memory for all required channels. */
14476
 
        for( i = 0; i < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; i++ )
14477
 
        {
14478
 
                /*==============================================================================*/
14479
 
                /*      Configure the Global Static Configuration memory of the channel. */
14480
 
 
14481
 
                ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( i * cOCT6100_CHANNEL_ROOT_SIZE ) + cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET;
14482
 
 
14483
 
                /* Set the PGSP context base address. */
14484
 
                ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET;
14485
 
                
14486
 
                WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET;
14487
 
                WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
14488
 
 
14489
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14490
 
                if ( ulResult != cOCT6100_ERR_OK )
14491
 
                        return ulResult;
14492
 
 
14493
 
                WriteParams.ulWriteAddress += 2;
14494
 
                WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
14495
 
 
14496
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14497
 
                if ( ulResult != cOCT6100_ERR_OK )
14498
 
                        return ulResult;
14499
 
 
14500
 
                /* Set the PGSP init context base address. */
14501
 
                ulTempData = ( cOCT6100_IMAGE_FILE_BASE + 0x200 ) & 0x07FFFFFF;
14502
 
                
14503
 
                WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET;
14504
 
                WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
14505
 
 
14506
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14507
 
                if ( ulResult != cOCT6100_ERR_OK )
14508
 
                        return ulResult;
14509
 
 
14510
 
                WriteParams.ulWriteAddress += 2;
14511
 
                WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
14512
 
 
14513
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14514
 
                if ( ulResult != cOCT6100_ERR_OK )
14515
 
                        return ulResult;
14516
 
                
14517
 
                /* Set the RIN circular buffer base address. */
14518
 
                ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst;
14519
 
 
14520
 
                /* Set the circular buffer size. */
14521
 
                ulTempData &= 0xFFFFFF00;
14522
 
                if (( pSharedInfo->MemoryMap.ulChanMainRinCBMemSize & 0xFFFF00FF ) != 0 )
14523
 
                        return cOCT6100_ERR_CHANNEL_INVALID_RIN_CB_SIZE;
14524
 
                ulTempData |= pSharedInfo->MemoryMap.ulChanMainRinCBMemSize >> 8;
14525
 
                        
14526
 
                WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET;
14527
 
                WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
14528
 
 
14529
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14530
 
                if ( ulResult != cOCT6100_ERR_OK )
14531
 
                        return ulResult;
14532
 
 
14533
 
                WriteParams.ulWriteAddress += 2;
14534
 
                WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
14535
 
 
14536
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14537
 
                if ( ulResult != cOCT6100_ERR_OK )
14538
 
                        return ulResult;
14539
 
 
14540
 
                /* Set the SIN circular buffer base address. */
14541
 
                ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst;
14542
 
 
14543
 
                WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET;
14544
 
                WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
14545
 
 
14546
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14547
 
                if ( ulResult != cOCT6100_ERR_OK )
14548
 
                        return ulResult;
14549
 
 
14550
 
                WriteParams.ulWriteAddress += 2;
14551
 
                WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
14552
 
 
14553
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14554
 
                if ( ulResult != cOCT6100_ERR_OK )
14555
 
                        return ulResult;
14556
 
 
14557
 
                /* Set the SOUT circular buffer base address. */
14558
 
                ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst;;
14559
 
 
14560
 
                WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET;
14561
 
                WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
14562
 
 
14563
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14564
 
                if ( ulResult != cOCT6100_ERR_OK )
14565
 
                        return ulResult;
14566
 
 
14567
 
                WriteParams.ulWriteAddress += 2;
14568
 
                WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
14569
 
 
14570
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14571
 
                if ( ulResult != cOCT6100_ERR_OK  )
14572
 
                        return ulResult;
14573
 
 
14574
 
                /*==============================================================================*/
14575
 
        }
14576
 
 
14577
 
        /* Put all channel in powerdown mode "3". */
14578
 
        for( i = 0; i < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; i++ )
14579
 
        {
14580
 
                WriteParams.ulWriteAddress = 0x014000 + (i*4) + 0;
14581
 
                WriteParams.usWriteData = 0x85FF;               /* TSI index 1535 reserved for power-down mode */
14582
 
 
14583
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14584
 
                if ( ulResult != cOCT6100_ERR_OK )
14585
 
                        return ulResult;
14586
 
 
14587
 
                WriteParams.ulWriteAddress = 0x014000 + (i*4) + 2;
14588
 
                WriteParams.usWriteData = 0xC5FF;               /* TSI index 1535 reserved for power-down mode */
14589
 
 
14590
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14591
 
                if ( ulResult != cOCT6100_ERR_OK )
14592
 
                        return ulResult;
14593
 
        }
14594
 
 
14595
 
        /* Set the maximum number of channels. */
14596
 
        WriteParams.ulWriteAddress = 0x690;
14597
 
        if ( pSharedInfo->ImageInfo.usMaxNumberOfChannels < 384 )
14598
 
                WriteParams.usWriteData = 384;
14599
 
        else
14600
 
                WriteParams.usWriteData = (UINT16)pSharedInfo->ImageInfo.usMaxNumberOfChannels;
14601
 
 
14602
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14603
 
        if ( ulResult != cOCT6100_ERR_OK )
14604
 
                return ulResult;
14605
 
        
14606
 
        /* Set power-dowm TSI chariot memory to silence. */
14607
 
        for( i = 0; i < 6; i++ )
14608
 
        {
14609
 
                WriteParams.ulWriteAddress = 0x20000 + ( i * 0x1000 ) + ( 1534 * 2 );
14610
 
                WriteParams.usWriteData = 0xFF;
14611
 
 
14612
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14613
 
                if ( ulResult != cOCT6100_ERR_OK )
14614
 
                        return ulResult;
14615
 
 
14616
 
                WriteParams.ulWriteAddress = 0x20000 + ( i * 0x1000 ) + ( 1535 * 2 );
14617
 
                WriteParams.usWriteData = 0xFF;
14618
 
 
14619
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14620
 
                if ( ulResult != cOCT6100_ERR_OK )
14621
 
                        return ulResult;        
14622
 
        }
14623
 
 
14624
 
        /* Remove chariot hold. */
14625
 
        WriteParams.ulWriteAddress = 0x500;
14626
 
        WriteParams.usWriteData = 0x0001;
14627
 
 
14628
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14629
 
        if ( ulResult != cOCT6100_ERR_OK )
14630
 
                return ulResult;
14631
 
 
14632
 
        for( usLoopCount = 0; usLoopCount < 4096; usLoopCount++ )
14633
 
        {
14634
 
                if ( (usLoopCount % 16) < 8 )
14635
 
                {
14636
 
                        usWriteData  = (UINT16)((usLoopCount / 16) << 7);
14637
 
                        usWriteData |= (UINT16)((usLoopCount % 8));
14638
 
                }
14639
 
                else
14640
 
                {
14641
 
                        usWriteData  = (UINT16)((usLoopCount / 16) << 7);
14642
 
                        usWriteData |= (UINT16)((usLoopCount % 8));
14643
 
                        usWriteData |= 0x78;
14644
 
                }
14645
 
 
14646
 
                /* Set timeslot pointer. */
14647
 
                WriteParams.ulWriteAddress = 0x50E;
14648
 
                WriteParams.usWriteData  = 0x0003;
14649
 
                WriteParams.usWriteData |= usWriteData << 2;
14650
 
 
14651
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14652
 
                if ( ulResult != cOCT6100_ERR_OK )
14653
 
                        return ulResult;
14654
 
 
14655
 
                /* Now read the mclk counter. */
14656
 
                ReadParams.ulReadAddress = 0x30A;
14657
 
                ReadParams.pusReadData = &usLastMclkRead;
14658
 
 
14659
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
14660
 
                if ( ulResult != cOCT6100_ERR_OK )
14661
 
                        return ulResult;
14662
 
 
14663
 
                do {
14664
 
                        ReadParams.pusReadData = &usMclkRead;
14665
 
 
14666
 
                        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
14667
 
                        if ( ulResult != cOCT6100_ERR_OK )
14668
 
                                return ulResult;
14669
 
 
14670
 
                        if ( ( usLoopCount % 16 ) != 15 )
14671
 
                        {
14672
 
                                ulNumberOfCycleToWait = 133;
14673
 
                        }
14674
 
                        else
14675
 
                        {
14676
 
                                ulNumberOfCycleToWait = 20000;
14677
 
                        }
14678
 
 
14679
 
                        /* Evaluate the difference. */
14680
 
                        usMclkDiff = (UINT16)(( usMclkRead - usLastMclkRead ) & 0xFFFF);
14681
 
                        
14682
 
                } while( usMclkDiff <= ulNumberOfCycleToWait );
14683
 
        }
14684
 
        
14685
 
        /* Back to normal mode. */
14686
 
        WriteParams.ulWriteAddress = 0x50E;
14687
 
        WriteParams.usWriteData  = 0x0000;
14688
 
 
14689
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14690
 
        if ( ulResult != cOCT6100_ERR_OK )
14691
 
                return ulResult;
14692
 
 
14693
 
        /* Check for CRC errors. */
14694
 
        ReadParams.pusReadData = &usReadData;
14695
 
        ReadParams.ulReadAddress = 0x202;
14696
 
 
14697
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
14698
 
        if ( ulResult != cOCT6100_ERR_OK )
14699
 
                return ulResult;
14700
 
 
14701
 
        if ( (usReadData & 0x400) != 0x0000 )
14702
 
                return cOCT6100_ERR_OPEN_CRC_ERROR;
14703
 
 
14704
 
        /* Clear the error rol raised by manually moving the clocks. */
14705
 
        WriteParams.ulWriteAddress = 0x502;
14706
 
        WriteParams.usWriteData  = 0x0002;
14707
 
 
14708
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14709
 
        if ( ulResult != cOCT6100_ERR_OK )
14710
 
                return ulResult;
14711
 
 
14712
 
        /*======================================================================*/
14713
 
        /* Write the tail displacement value in external memory. */
14714
 
 
14715
 
        ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchTailDisplOfst.usDwordOffset * 4;
14716
 
        ulFeatureBitOffset       = pSharedInfo->MemoryMap.PouchTailDisplOfst.byBitOffset;
14717
 
        ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchTailDisplOfst.byFieldSize;
14718
 
 
14719
 
        ulResult = Oct6100ApiReadDword( f_pApiInstance,
14720
 
                                                                        cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14721
 
                                                                        &ulTempData );
14722
 
        
14723
 
        /* Clear previous value set in the feature field.*/
14724
 
        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
14725
 
 
14726
 
        ulTempData &= (~ulMask);
14727
 
 
14728
 
        /* Set the tail displacement. */
14729
 
        ulTempData |= (pSharedInfo->ChipConfig.usTailDisplacement << ulFeatureBitOffset );
14730
 
 
14731
 
        /* Write the DWORD where the field is located. */
14732
 
        ulResult = Oct6100ApiWriteDword( f_pApiInstance,
14733
 
                                                                         cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14734
 
                                                                         ulTempData );
14735
 
        if ( ulResult != cOCT6100_ERR_OK )
14736
 
                return ulResult;        
14737
 
 
14738
 
        /*======================================================================*/
14739
 
 
14740
 
 
14741
 
        /*======================================================================*/
14742
 
        /* Clear the pouch counter, if present. */
14743
 
        
14744
 
        if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE )
14745
 
        {
14746
 
                ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4;
14747
 
                ulFeatureBitOffset       = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset;
14748
 
                ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize;
14749
 
 
14750
 
                ulResult = Oct6100ApiReadDword( f_pApiInstance,
14751
 
                                                                                cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14752
 
                                                                                &ulTempData );
14753
 
                
14754
 
                /* Clear previous value set in the feature field.*/
14755
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
14756
 
 
14757
 
                /* Clear counter! */
14758
 
                ulTempData &= (~ulMask);
14759
 
 
14760
 
                /* Write the DWORD where the field is located.*/
14761
 
                ulResult = Oct6100ApiWriteDword( f_pApiInstance,
14762
 
                                                                                 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14763
 
                                                                                 ulTempData );
14764
 
                if ( ulResult != cOCT6100_ERR_OK )
14765
 
                        return ulResult;        
14766
 
        }
14767
 
 
14768
 
        /* The ISR has not yet been called.  Set the appropriate bit in external memory. */
14769
 
        if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE )
14770
 
        {
14771
 
                ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4;
14772
 
                ulFeatureBitOffset       = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset;
14773
 
                ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize;
14774
 
 
14775
 
                ulResult = Oct6100ApiReadDword( f_pApiInstance,
14776
 
                                                                                cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14777
 
                                                                                &ulTempData );
14778
 
                
14779
 
                /* Read previous value set in the feature field.*/
14780
 
                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
14781
 
 
14782
 
                /* Toggle the bit to '1'. */
14783
 
                ulTempData |= 1 << ulFeatureBitOffset;
14784
 
 
14785
 
                /* Write the DWORD where the field is located.*/
14786
 
                ulResult = Oct6100ApiWriteDword( f_pApiInstance,
14787
 
                                                                                 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14788
 
                                                                                 ulTempData );
14789
 
                if ( ulResult != cOCT6100_ERR_OK )
14790
 
                        return ulResult;        
14791
 
        }
14792
 
 
14793
 
        /*======================================================================*/
14794
 
 
14795
 
        return cOCT6100_ERR_OK;
14796
 
}
14797
 
 
14798
 
 
14799
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14800
 
 
14801
 
Function:               Oct6100ApiInitToneInfo
14802
 
 
14803
 
Description:    This function will parse the software image and retrieve 
14804
 
                                the information about the tones that it supports.
14805
 
 
14806
 
-------------------------------------------------------------------------------
14807
 
|       Argument                |       Description
14808
 
-------------------------------------------------------------------------------
14809
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
14810
 
                                        present state of the chip and all its resources.
14811
 
 
14812
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14813
 
static UINT32 Oct6100ApiInitToneInfo(
14814
 
                                IN OUT  tPOCT6100_INSTANCE_API f_pApiInstance )
14815
 
{
14816
 
        UINT32  ulResult;
14817
 
        
14818
 
        PUINT8  pszToneInfoStart = NULL;
14819
 
        PUINT8  pszToneInfoEnd = NULL;
14820
 
        
14821
 
        PUINT8  pszCurrentInfo;
14822
 
        PUINT8  pszNextInfo;
14823
 
        
14824
 
        UINT32  ulToneEventNumber;
14825
 
        UINT32  ulTempValue;
14826
 
        UINT32  ulNumCharForValue;
14827
 
        UINT32  ulUniqueToneId;
14828
 
        UINT32  ulToneNameSize;
14829
 
        UINT32  ulOffset = 0;
14830
 
 
14831
 
        UINT32  i;
14832
 
 
14833
 
        /* Init the tone detector parameter. */
14834
 
        f_pApiInstance->pSharedInfo->ImageInfo.byNumToneDetectors = 0;
14835
 
 
14836
 
        /* Find the start and the end of the tone info section. */
14837
 
        if ( f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize > 4096 )
14838
 
        {
14839
 
                /* For performance reasons, and since the tone detector information */
14840
 
                /* is always located at the end of the image file, try to start from the end */
14841
 
                /* of the buffer. */
14842
 
 
14843
 
                ulOffset = f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize - 2048;
14844
 
                pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + ulOffset,
14845
 
                                                                                 (PUINT8)cOCT6100_TONE_INFO_START_STRING,
14846
 
                                                                                 f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
14847
 
 
14848
 
                /* Check if the information was found. */
14849
 
                if ( pszToneInfoStart == NULL )
14850
 
                {
14851
 
                        /* Try again, but giving a larger string to search. */
14852
 
                        ulOffset = f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize - 4096;
14853
 
                        pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + ulOffset,
14854
 
                                                                                         (PUINT8)cOCT6100_TONE_INFO_START_STRING,
14855
 
                                                                                         f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
14856
 
 
14857
 
                }
14858
 
        }
14859
 
 
14860
 
        if ( pszToneInfoStart == NULL )
14861
 
        {
14862
 
                /* Travel through the whole file buffer. */
14863
 
                pszToneInfoStart = Oct6100ApiStrStr( f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile,
14864
 
                                                                                 (PUINT8)cOCT6100_TONE_INFO_START_STRING,
14865
 
                                                                                 f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
14866
 
        }
14867
 
        /* We have to return immediatly if no tones are found. */
14868
 
        if ( pszToneInfoStart == NULL )
14869
 
                return cOCT6100_ERR_OK;
14870
 
 
14871
 
        /* The end of the tone detector information is after the beginning of the tone information. */
14872
 
        pszToneInfoEnd = Oct6100ApiStrStr(       pszToneInfoStart,
14873
 
                                                                                 (PUINT8)cOCT6100_TONE_INFO_STOP_STRING,
14874
 
                                                                                 f_pApiInstance->pSharedInfo->ChipConfig.pbyImageFile + f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize );
14875
 
        if ( pszToneInfoEnd == NULL )
14876
 
                return cOCT6100_ERR_OPEN_TONE_INFO_STOP_TAG_NOT_FOUND;
14877
 
 
14878
 
        /* Find and process all tone events within the region. */
14879
 
        pszCurrentInfo = Oct6100ApiStrStr( pszToneInfoStart, (PUINT8)cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd );
14880
 
 
14881
 
        while ( pszCurrentInfo != NULL )
14882
 
        {
14883
 
                /* Skip the string. */
14884
 
                pszCurrentInfo += ( Oct6100ApiStrLen( (PUINT8)cOCT6100_TONE_INFO_EVENT_STRING ) );
14885
 
 
14886
 
                /* Extract the number of char used to represent the tone event number ( 1 or 2 ). */
14887
 
                pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo, (PUINT8)",", pszToneInfoEnd );
14888
 
                ulNumCharForValue = pszNextInfo - pszCurrentInfo;
14889
 
                
14890
 
                /* Retreive the event number */
14891
 
                ulToneEventNumber = 0;
14892
 
                for ( i = ulNumCharForValue; i > 0; i-- )
14893
 
                {
14894
 
                        ulResult = Oct6100ApiAsciiToHex( *pszCurrentInfo, &ulTempValue );
14895
 
                        if ( ulResult != cOCT6100_ERR_OK )
14896
 
                                return ulResult;
14897
 
 
14898
 
                        ulToneEventNumber |= ( ulTempValue << (( i - 1) * 4 ) );
14899
 
                        pszCurrentInfo++;
14900
 
                }
14901
 
 
14902
 
                if ( ulToneEventNumber >= cOCT6100_MAX_TONE_EVENT )
14903
 
                        return cOCT6100_ERR_OPEN_INVALID_TONE_EVENT;
14904
 
                
14905
 
                /* Skip the comma and the 0x. */
14906
 
                pszCurrentInfo += 3;
14907
 
 
14908
 
                /*======================================================================*/
14909
 
                /* Retreive the unique tone id. */
14910
 
                ulUniqueToneId = 0;
14911
 
                for ( i = 0; i < 8; i++ )
14912
 
                {
14913
 
                        ulResult = Oct6100ApiAsciiToHex( *pszCurrentInfo, &ulTempValue );
14914
 
                        if ( ulResult != cOCT6100_ERR_OK )
14915
 
                                return ulResult;
14916
 
 
14917
 
                        ulOffset = 28 - ( i * 4 );
14918
 
                        ulUniqueToneId |= ( ulTempValue << ulOffset );
14919
 
                        pszCurrentInfo++;
14920
 
                }
14921
 
                
14922
 
                /*======================================================================*/
14923
 
 
14924
 
                /* Skip the comma. */
14925
 
                pszCurrentInfo++;
14926
 
                
14927
 
                /* Find out where the next event info starts */
14928
 
                pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo,(PUINT8) cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd );
14929
 
                if ( pszNextInfo == NULL )
14930
 
                        pszNextInfo = pszToneInfoEnd;
14931
 
 
14932
 
                /* Extract the name size. */
14933
 
                ulToneNameSize = pszNextInfo - pszCurrentInfo - 2;      /* - 2 for 0x0D and 0x0A.*/
14934
 
 
14935
 
                if ( ulToneNameSize > cOCT6100_TLV_MAX_TONE_NAME_SIZE )
14936
 
                        return cOCT6100_ERR_OPEN_INVALID_TONE_NAME;
14937
 
 
14938
 
                /* Copy the tone name into the image info structure. */
14939
 
                ulResult = Oct6100UserMemCopy( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].aszToneName,
14940
 
                                                                           pszCurrentInfo,
14941
 
                                                                           ulToneNameSize );
14942
 
 
14943
 
 
14944
 
 
14945
 
                /* Update the tone info into the image info structure. */
14946
 
                f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID = ulUniqueToneId;
14947
 
                /* Find out the port on which this tone detector is associated. */
14948
 
                switch( (ulUniqueToneId >> 28) & 0xF )
14949
 
                {
14950
 
                case 1:
14951
 
                        f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_ROUT;
14952
 
                        break;
14953
 
 
14954
 
                case 2:
14955
 
                        f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_SIN;
14956
 
                        break;
14957
 
 
14958
 
                case 4:
14959
 
                        f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_SOUT;
14960
 
                        break;
14961
 
 
14962
 
                case 5:
14963
 
                        f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_ROUT_SOUT;
14964
 
                        break;
14965
 
                
14966
 
                default:
14967
 
                        f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_INVALID_PORT;
14968
 
                        break;
14969
 
                }
14970
 
                
14971
 
                /* Find out where the next event info starts */
14972
 
                pszNextInfo = Oct6100ApiStrStr( pszCurrentInfo,(PUINT8) cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd );
14973
 
                /* Update the current info pointer. */
14974
 
                pszCurrentInfo = pszNextInfo;
14975
 
 
14976
 
                f_pApiInstance->pSharedInfo->ImageInfo.byNumToneDetectors++;
14977
 
        }
14978
 
 
14979
 
        return  cOCT6100_ERR_OK;
14980
 
}
14981
 
 
14982
 
 
14983
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14984
 
 
14985
 
Function:               Oct6100ApiExternalMemoryBist
14986
 
 
14987
 
Description:    Tests the functionality of the external memories.
14988
 
 
14989
 
-------------------------------------------------------------------------------
14990
 
|       Argument                |       Description
14991
 
-------------------------------------------------------------------------------
14992
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
14993
 
                                        present state of the chip and all its resources.
14994
 
 
14995
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14996
 
static UINT32 Oct6100ApiExternalMemoryBist(
14997
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
14998
 
{
14999
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
15000
 
        UINT32  ulMemSize = 0;
15001
 
        UINT32  ulResult;
15002
 
 
15003
 
        /* Get local pointer to shared portion of instance. */
15004
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
15005
 
 
15006
 
        /* Test the external memory. */
15007
 
        switch ( pSharedInfo->ChipConfig.ulMemoryChipSize )
15008
 
        {
15009
 
        case cOCT6100_MEMORY_CHIP_SIZE_8MB:                     
15010
 
                ulMemSize = cOCT6100_SIZE_8M;           
15011
 
                break;
15012
 
        case cOCT6100_MEMORY_CHIP_SIZE_16MB:            
15013
 
                ulMemSize = cOCT6100_SIZE_16M;          
15014
 
                break;
15015
 
        case cOCT6100_MEMORY_CHIP_SIZE_32MB:            
15016
 
                ulMemSize = cOCT6100_SIZE_32M;          
15017
 
                break;
15018
 
        case cOCT6100_MEMORY_CHIP_SIZE_64MB:            
15019
 
                ulMemSize = cOCT6100_SIZE_64M;          
15020
 
                break;
15021
 
        case cOCT6100_MEMORY_CHIP_SIZE_128MB:           
15022
 
                ulMemSize = cOCT6100_SIZE_128M;         
15023
 
                break;
15024
 
        default:                                                                        
15025
 
                return cOCT6100_ERR_FATAL_D9;
15026
 
        }
15027
 
 
15028
 
        ulMemSize *= pSharedInfo->ChipConfig.byNumMemoryChips;
15029
 
 
15030
 
        ulResult = Oct6100ApiRandomMemoryWrite( f_pApiInstance, cOCT6100_EXTERNAL_MEM_BASE_ADDRESS, ulMemSize, 16, 1000, cOCT6100_ERR_OPEN_EXTERNAL_MEM_BIST_FAILED );
15031
 
        if ( ulResult != cOCT6100_ERR_OK )
15032
 
                return ulResult;
15033
 
        
15034
 
        /* Make sure the user I/O functions are working as required. */
15035
 
        ulResult = Oct6100ApiUserIoTest( f_pApiInstance );
15036
 
        if ( ulResult != cOCT6100_ERR_OK )
15037
 
                return ulResult;
15038
 
 
15039
 
        return cOCT6100_ERR_OK;
15040
 
}
15041
 
 
15042
 
 
15043
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15044
 
 
15045
 
Function:               Oct6100ApiGenerateNumber
15046
 
 
15047
 
Description:    Generate a number using an index.  Passing the same
15048
 
                                index generates the same number.
15049
 
 
15050
 
-------------------------------------------------------------------------------
15051
 
|       Argument                |       Description
15052
 
-------------------------------------------------------------------------------
15053
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
15054
 
                                        present state of the chip and all its resources.
15055
 
f_ulIndex                       Index used to generate the random number.
15056
 
f_ulDataMask            Data mask to apply to generated number.
15057
 
 
15058
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15059
 
static UINT16 Oct6100ApiGenerateNumber( 
15060
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance,
15061
 
                                IN              UINT32                                  f_ulIndex,
15062
 
                                IN              UINT32                                  f_ulDataMask )
15063
 
{
15064
 
        UINT16 usGeneratedNumber;
15065
 
 
15066
 
        usGeneratedNumber = (UINT16)( ( ( ~( f_ulIndex - 1 ) ) & 0xFF00 ) | ( ( f_ulIndex + 1 ) & 0xFF ) );
15067
 
 
15068
 
        return (UINT16)( usGeneratedNumber & f_ulDataMask );
15069
 
}
15070
 
 
15071
 
 
15072
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15073
 
 
15074
 
Function:               Oct6100ApiRandomMemoryWrite
15075
 
 
15076
 
Description:    Writes to f_ulNumAccesses random locations in the indicated 
15077
 
                                memory and read back to test the operation of that memory.
15078
 
 
15079
 
-------------------------------------------------------------------------------
15080
 
|       Argument                |       Description
15081
 
-------------------------------------------------------------------------------
15082
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
15083
 
                                        present state of the chip and all its resources.
15084
 
f_ulMemBase                     Base address of the memory access.
15085
 
f_ulMemSize                     Size of the memory to be tested.
15086
 
f_ulNumDataBits         Number of data bits.
15087
 
f_ulNumAccesses         Number of random access to be perform.
15088
 
f_ulErrorCode           Error code to be returned if the bist fails.
15089
 
 
15090
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15091
 
static UINT32 Oct6100ApiRandomMemoryWrite(
15092
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance,
15093
 
                                IN              UINT32                                  f_ulMemBase,
15094
 
                                IN              UINT32                                  f_ulMemSize,
15095
 
                                IN              UINT32                                  f_ulNumDataBits,
15096
 
                                IN              UINT32                                  f_ulNumAccesses,
15097
 
                                IN              UINT32                                  f_ulErrorCode )
15098
 
{
15099
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
15100
 
        tOCT6100_WRITE_PARAMS   WriteParams;
15101
 
        tOCT6100_READ_PARAMS    ReadParams;
15102
 
        UINT32  ulDataMask;
15103
 
        UINT32  ulResult, i, j;
15104
 
        UINT32  ulBistAddress;
15105
 
        UINT16  usReadData;
15106
 
 
15107
 
        /* Get local pointer to shared portion of instance. */
15108
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
15109
 
 
15110
 
        /* Set the process context and user chip ID parameters once and for all. */
15111
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
15112
 
 
15113
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15114
 
 
15115
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
15116
 
 
15117
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15118
 
 
15119
 
        /* Make sure we don't perform more access then the size of our BIST resources. */
15120
 
        if ( f_ulNumAccesses > 1024 )
15121
 
                return cOCT6100_ERR_FATAL_C0;
15122
 
 
15123
 
        /* Determine mask for number of data bits. */
15124
 
        ulDataMask = (1 << f_ulNumDataBits) - 1;
15125
 
        
15126
 
        /* Bist all data pin. */
15127
 
        for ( i = 0; i < 32; i += 2 )
15128
 
        {
15129
 
                WriteParams.ulWriteAddress = f_ulMemBase + i * 2;
15130
 
                WriteParams.usWriteData = (UINT16)(0x1 << (i / 2));
15131
 
 
15132
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
15133
 
                if ( ulResult != cOCT6100_ERR_OK )
15134
 
                        return ulResult;
15135
 
 
15136
 
                WriteParams.ulWriteAddress = f_ulMemBase + i * 2 + 2;
15137
 
                WriteParams.usWriteData = (UINT16)(0x1 << (i / 2));
15138
 
 
15139
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
15140
 
                if ( ulResult != cOCT6100_ERR_OK )
15141
 
                        return ulResult;
15142
 
        }
15143
 
 
15144
 
        /* Read back the data written. */
15145
 
        for ( i = 0; i < 32; i += 2 )
15146
 
        {
15147
 
                ReadParams.ulReadAddress = f_ulMemBase + i * 2;
15148
 
                ReadParams.pusReadData = &usReadData;
15149
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
15150
 
                if ( ulResult != cOCT6100_ERR_OK )
15151
 
                        return ulResult;
15152
 
 
15153
 
                if ( usReadData != (UINT16)(0x1 << (i / 2)) )
15154
 
                        return f_ulErrorCode;
15155
 
 
15156
 
                ReadParams.ulReadAddress = f_ulMemBase + i * 2 + 2;
15157
 
                ReadParams.pusReadData = &usReadData;
15158
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
15159
 
                if ( ulResult != cOCT6100_ERR_OK )
15160
 
                        return ulResult;
15161
 
 
15162
 
                if ( usReadData != (UINT16)(0x1 << (i / 2)) )
15163
 
                        return f_ulErrorCode;
15164
 
        }
15165
 
 
15166
 
        /* Perform the first write at address 0 + mem base */
15167
 
        j = 0;
15168
 
        WriteParams.ulWriteAddress = f_ulMemBase;
15169
 
        WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, j, ulDataMask );
15170
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
15171
 
        if ( ulResult != cOCT6100_ERR_OK )
15172
 
                return ulResult;
15173
 
 
15174
 
        /* Try each address line of the memory. */
15175
 
        for ( i = 2, j = 1; i < f_ulMemSize; i <<= 1, j++ )
15176
 
        {
15177
 
                WriteParams.ulWriteAddress = ( f_ulMemBase + i );
15178
 
                WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, j, ulDataMask );
15179
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
15180
 
                if ( ulResult != cOCT6100_ERR_OK )
15181
 
                        return ulResult;
15182
 
        }
15183
 
 
15184
 
        for ( i = 0; i < j; i++ )
15185
 
        {
15186
 
                if ( i > 0 )
15187
 
                        ReadParams.ulReadAddress = ( f_ulMemBase + ( 0x1 << i ) );
15188
 
                else
15189
 
                        ReadParams.ulReadAddress = f_ulMemBase;
15190
 
                ReadParams.pusReadData = &usReadData;
15191
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
15192
 
                if ( ulResult != cOCT6100_ERR_OK )
15193
 
                        return ulResult;
15194
 
 
15195
 
                if ( usReadData != Oct6100ApiGenerateNumber( f_pApiInstance, i, ulDataMask ) )
15196
 
                        return f_ulErrorCode;
15197
 
        }
15198
 
 
15199
 
        /* Write to random addresses of the memory. */
15200
 
        for ( i = 0; i < f_ulNumAccesses; i++ )
15201
 
        {
15202
 
                ulBistAddress  = (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) << 16;
15203
 
                ulBistAddress |= (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
15204
 
                ulBistAddress &= f_ulMemSize - 2;
15205
 
                ulBistAddress |= f_ulMemBase;
15206
 
 
15207
 
                WriteParams.ulWriteAddress = ulBistAddress;
15208
 
                WriteParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
15209
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
15210
 
                if ( ulResult != cOCT6100_ERR_OK )
15211
 
                        return ulResult;
15212
 
        }
15213
 
 
15214
 
        for ( i = 0; i < f_ulNumAccesses; i++ )
15215
 
        {
15216
 
                ulBistAddress  = (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) << 16;
15217
 
                ulBistAddress |= (UINT16)Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
15218
 
                ulBistAddress &= f_ulMemSize - 2;
15219
 
                ulBistAddress |= f_ulMemBase;
15220
 
 
15221
 
                ReadParams.ulReadAddress = ulBistAddress;
15222
 
                ReadParams.pusReadData = &usReadData;
15223
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
15224
 
                if ( ulResult != cOCT6100_ERR_OK )
15225
 
                        return ulResult;
15226
 
 
15227
 
                if ( ( usReadData & ulDataMask ) != ( Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) & ulDataMask ) )
15228
 
                        return f_ulErrorCode;
15229
 
        }
15230
 
        
15231
 
        return cOCT6100_ERR_OK;
15232
 
}
15233
 
 
15234
 
 
15235
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15236
 
 
15237
 
Function:               Oct6100ApiUserIoTest
15238
 
 
15239
 
Description:    This function will verify the correct functionality of 
15240
 
                                the following user functions:
15241
 
 
15242
 
                                - Oct6100UserDriverWriteBurstApi
15243
 
                                - Oct6100UserDriverWriteSmearApi
15244
 
                                - Oct6100UserDriverReadBurstApi
15245
 
 
15246
 
                                The Oct6100UserDriverWriteApi and Oct6100UserDriverReadApi
15247
 
                                functions do not need to be tested here as this has be done in 
15248
 
                                the external memory bisting function above.
15249
 
 
15250
 
-------------------------------------------------------------------------------
15251
 
|       Argument                |       Description
15252
 
-------------------------------------------------------------------------------
15253
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
15254
 
                                        present state of the chip and all its resources.
15255
 
 
15256
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15257
 
static UINT32 Oct6100ApiUserIoTest( 
15258
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
15259
 
{
15260
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
15261
 
        tOCT6100_WRITE_BURST_PARAMS     WriteBurstParams;
15262
 
        tOCT6100_WRITE_SMEAR_PARAMS     WriteSmearParams;
15263
 
        tOCT6100_READ_PARAMS            ReadParams;
15264
 
        tOCT6100_READ_BURST_PARAMS      ReadBurstParams;
15265
 
        UINT32  ulResult, i;
15266
 
        UINT16  usReadData;
15267
 
 
15268
 
        /* Get local pointer to shared portion of instance. */
15269
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
15270
 
 
15271
 
        /* Set the process context and user chip ID parameters once and for all. */
15272
 
        WriteBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
15273
 
 
15274
 
        WriteBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15275
 
        /* Test what the user has specified is the maximum that can be used for a burst. */
15276
 
        WriteBurstParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
15277
 
        WriteBurstParams.pusWriteData = pSharedInfo->MiscVars.ausSuperArray;
15278
 
 
15279
 
        WriteSmearParams.pProcessContext = f_pApiInstance->pProcessContext;
15280
 
 
15281
 
        WriteSmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15282
 
        /* Test what the user has specified is the maximum that can be used for a smear. */
15283
 
        WriteSmearParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
15284
 
 
15285
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
15286
 
 
15287
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15288
 
        ReadParams.pusReadData = &usReadData;
15289
 
 
15290
 
        ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
15291
 
 
15292
 
        ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15293
 
        /* Test what the user has specified is the maximum that can be used for a burst. */
15294
 
        ReadBurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
15295
 
        ReadBurstParams.pusReadData = pSharedInfo->MiscVars.ausSuperArray;
15296
 
 
15297
 
 
15298
 
        /*======================================================================*/
15299
 
        /* Write burst check. */
15300
 
 
15301
 
        WriteBurstParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
15302
 
        /* Set the random data to be written. */
15303
 
        for ( i = 0; i < WriteBurstParams.ulWriteLength; i++ )
15304
 
        {
15305
 
                WriteBurstParams.pusWriteData[ i ] = Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
15306
 
        }
15307
 
        mOCT6100_DRIVER_WRITE_BURST_API( WriteBurstParams, ulResult )
15308
 
        if ( ulResult != cOCT6100_ERR_OK )
15309
 
                return ulResult;
15310
 
 
15311
 
        /* Read back pattern using simple read function and make sure we are reading what's expected. */
15312
 
        ReadParams.ulReadAddress = WriteBurstParams.ulWriteAddress;
15313
 
        for ( i = 0; i < WriteBurstParams.ulWriteLength; i++ )
15314
 
        {
15315
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
15316
 
                if ( ulResult != cOCT6100_ERR_OK )
15317
 
                        return ulResult;
15318
 
 
15319
 
                /* Check if the data matches. */
15320
 
                if ( usReadData != WriteBurstParams.pusWriteData[ i ] )
15321
 
                {
15322
 
                        /* The values do not match.  Something seems to be wrong with the WriteBurst user function. */
15323
 
                        return cOCT6100_ERR_OPEN_USER_WRITE_BURST_FAILED;
15324
 
                }
15325
 
 
15326
 
                /* Next address to check. */
15327
 
                ReadParams.ulReadAddress += 2;
15328
 
        }
15329
 
 
15330
 
        /*======================================================================*/
15331
 
 
15332
 
 
15333
 
        /*======================================================================*/
15334
 
        /* Write smear check. */
15335
 
 
15336
 
        WriteSmearParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + ( WriteBurstParams.ulWriteLength * 2 );
15337
 
        /* Set the random data to be written. */
15338
 
        WriteSmearParams.usWriteData = Oct6100ApiGenerateNumber( f_pApiInstance, Oct6100ApiRand( 0xFFFF ), 0xFFFF );
15339
 
        mOCT6100_DRIVER_WRITE_SMEAR_API( WriteSmearParams, ulResult )
15340
 
        if ( ulResult != cOCT6100_ERR_OK )
15341
 
                return ulResult;
15342
 
 
15343
 
        /* Read back pattern using simple read function and make sure we are reading what's expected. */
15344
 
        ReadParams.ulReadAddress = WriteSmearParams.ulWriteAddress;
15345
 
        for ( i = 0; i < WriteSmearParams.ulWriteLength; i++ )
15346
 
        {
15347
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
15348
 
                if ( ulResult != cOCT6100_ERR_OK )
15349
 
                        return ulResult;
15350
 
 
15351
 
                /* Check if the data matches. */
15352
 
                if ( usReadData != WriteSmearParams.usWriteData )
15353
 
                {
15354
 
                        /* The values do not match.  Something seems to be wrong with the WriteSmear user function. */
15355
 
                        return cOCT6100_ERR_OPEN_USER_WRITE_SMEAR_FAILED;
15356
 
                }
15357
 
 
15358
 
                /* Next address to check. */
15359
 
                ReadParams.ulReadAddress += 2;
15360
 
        }
15361
 
 
15362
 
        /*======================================================================*/
15363
 
 
15364
 
 
15365
 
        /*======================================================================*/
15366
 
        /* Read burst check. */
15367
 
 
15368
 
        /* First check with what the WriteBurst function wrote. */
15369
 
        ReadBurstParams.ulReadAddress = WriteBurstParams.ulWriteAddress;
15370
 
        mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
15371
 
        if ( ulResult != cOCT6100_ERR_OK )
15372
 
                return ulResult;
15373
 
 
15374
 
        for ( i = 0; i < ReadBurstParams.ulReadLength; i++ )
15375
 
        {
15376
 
                /* Check if the data matches. */
15377
 
                if ( ReadBurstParams.pusReadData[ i ] != Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) )
15378
 
                {
15379
 
                        /* The values do not match.  Something seems to be wrong with the ReadBurst user function. */
15380
 
                        return cOCT6100_ERR_OPEN_USER_READ_BURST_FAILED;
15381
 
                }
15382
 
        }
15383
 
 
15384
 
        /* Then check with what the WriteSmear function wrote. */
15385
 
        ReadBurstParams.ulReadAddress = WriteSmearParams.ulWriteAddress;
15386
 
        mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
15387
 
        if ( ulResult != cOCT6100_ERR_OK )
15388
 
                return ulResult;
15389
 
 
15390
 
        for ( i = 0; i < ReadBurstParams.ulReadLength; i++ )
15391
 
        {
15392
 
                /* Check if the data matches. */
15393
 
                if ( ReadBurstParams.pusReadData[ i ] != WriteSmearParams.usWriteData )
15394
 
                {
15395
 
                        /* The values do not match.  Something seems to be wrong with the ReadBurst user function. */
15396
 
                        return cOCT6100_ERR_OPEN_USER_READ_BURST_FAILED;
15397
 
                }
15398
 
        }
15399
 
 
15400
 
        /*======================================================================*/
15401
 
        
15402
 
        return cOCT6100_ERR_OK;
15403
 
}
15404
 
 
15405
 
 
15406
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15407
 
 
15408
 
Function:               Oct6100ApiExternalMemoryInit
15409
 
 
15410
 
Description:    Initialize the external memory before uploading the image.
15411
 
 
15412
 
-------------------------------------------------------------------------------
15413
 
|       Argument                |       Description
15414
 
-------------------------------------------------------------------------------
15415
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
15416
 
                                        present state of the chip and all its resources.
15417
 
 
15418
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15419
 
static UINT32 Oct6100ApiExternalMemoryInit(
15420
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
15421
 
{
15422
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
15423
 
        tOCT6100_WRITE_SMEAR_PARAMS             SmearParams;
15424
 
        UINT32  ulTotalWordToWrite;
15425
 
        UINT32  ulResult;
15426
 
 
15427
 
        /* Get local pointer to shared portion of instance. */
15428
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
15429
 
 
15430
 
        SmearParams.pProcessContext = f_pApiInstance->pProcessContext;
15431
 
 
15432
 
        SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15433
 
 
15434
 
        /* Clear the first part of the memory. */
15435
 
        ulTotalWordToWrite = 0x400;
15436
 
        SmearParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
15437
 
 
15438
 
        while ( ulTotalWordToWrite != 0 )
15439
 
        {
15440
 
                if ( ulTotalWordToWrite >= pSharedInfo->ChipConfig.usMaxRwAccesses )
15441
 
                        SmearParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
15442
 
                else
15443
 
                        SmearParams.ulWriteLength = ulTotalWordToWrite;
15444
 
 
15445
 
                SmearParams.usWriteData = 0x0;
15446
 
 
15447
 
                mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
15448
 
                if ( ulResult != cOCT6100_ERR_OK )
15449
 
                        return ulResult;
15450
 
 
15451
 
                /* Update the number of words to write. */
15452
 
                ulTotalWordToWrite -= SmearParams.ulWriteLength;
15453
 
                /* Update the address. */
15454
 
                SmearParams.ulWriteAddress += ( SmearParams.ulWriteLength * 2 );
15455
 
        }
15456
 
 
15457
 
        /* Clear the TLV flag.*/
15458
 
        ulResult = Oct6100ApiWriteDword( f_pApiInstance, cOCT6100_TLV_BASE, 0x0 );
15459
 
        if ( ulResult != cOCT6100_ERR_OK )
15460
 
                return ulResult;
15461
 
 
15462
 
        return cOCT6100_ERR_OK;
15463
 
}
15464
 
 
15465
 
 
15466
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15467
 
 
15468
 
Function:               Oct6100ApiInitMixer
15469
 
 
15470
 
Description:    This function will initialize the mixer memory.
15471
 
 
15472
 
-------------------------------------------------------------------------------
15473
 
|       Argument                |       Description
15474
 
-------------------------------------------------------------------------------
15475
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
15476
 
                                        present state of the chip and all its resources.
15477
 
 
15478
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15479
 
static UINT32 Oct6100ApiInitMixer(
15480
 
                                IN OUT  tPOCT6100_INSTANCE_API f_pApiInstance )
15481
 
{
15482
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
15483
 
        tOCT6100_WRITE_BURST_PARAMS     BurstParams;
15484
 
        UINT16                                          ausWriteData[ 4 ];
15485
 
        UINT32                                          ulResult;
15486
 
 
15487
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
15488
 
 
15489
 
        BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
15490
 
 
15491
 
        BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
15492
 
        BurstParams.pusWriteData = ausWriteData;
15493
 
        /*======================================================================*/
15494
 
        /* Initialize the mixer memory if required. */
15495
 
        if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
15496
 
        {
15497
 
                /* Modify the mixer pointer by adding the record event into the link list. */
15498
 
                pSharedInfo->MixerInfo.usFirstSinCopyEventPtr   = pSharedInfo->MixerInfo.usRecordSinEventIndex;
15499
 
                pSharedInfo->MixerInfo.usLastSinCopyEventPtr    = pSharedInfo->MixerInfo.usRecordSinEventIndex;
15500
 
                pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr  = pSharedInfo->MixerInfo.usRecordCopyEventIndex; 
15501
 
                pSharedInfo->MixerInfo.usLastSoutCopyEventPtr   = pSharedInfo->MixerInfo.usRecordCopyEventIndex;
15502
 
 
15503
 
                /* Program the Sin copy event. */
15504
 
                BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordSinEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
15505
 
                BurstParams.ulWriteLength = 4;
15506
 
 
15507
 
                ausWriteData[ 0 ] = 0x0000;
15508
 
                ausWriteData[ 1 ] = 0x0000;
15509
 
                ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_TAIL_NODE & 0x7FF); /* Head node.*/
15510
 
                ausWriteData[ 3 ] = 0x0000;
15511
 
 
15512
 
                mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
15513
 
                if ( ulResult != cOCT6100_ERR_OK )
15514
 
                        return ulResult;
15515
 
 
15516
 
                /* Program the Sout copy event. */
15517
 
                BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pSharedInfo->MixerInfo.usRecordCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
15518
 
                BurstParams.ulWriteLength = 4;
15519
 
 
15520
 
                ausWriteData[ 0 ] = 0x0000;
15521
 
                ausWriteData[ 1 ] = 0x0000;
15522
 
                ausWriteData[ 2 ] = (UINT16)(pSharedInfo->MixerInfo.usRecordSinEventIndex & 0x7FF);
15523
 
                ausWriteData[ 3 ] = 0x0000;
15524
 
 
15525
 
                mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
15526
 
                if ( ulResult != cOCT6100_ERR_OK )
15527
 
                        return ulResult;
15528
 
                
15529
 
                /* Configure the head node. */
15530
 
                BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE;
15531
 
                BurstParams.ulWriteLength = 4;
15532
 
 
15533
 
                ausWriteData[ 0 ] = 0x0000;
15534
 
                ausWriteData[ 1 ] = 0x0000;
15535
 
                ausWriteData[ 2 ] = (UINT16)(pSharedInfo->MixerInfo.usRecordCopyEventIndex & 0x7FF);
15536
 
                ausWriteData[ 3 ] = 0x0000;
15537
 
 
15538
 
                mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
15539
 
                if ( ulResult != cOCT6100_ERR_OK )
15540
 
                        return ulResult;
15541
 
 
15542
 
                /* Init the mixer pointer */
15543
 
                pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex;
15544
 
        }
15545
 
        else
15546
 
        {
15547
 
                /* Configure the head node. */
15548
 
                BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE;
15549
 
                BurstParams.ulWriteLength = 4;
15550
 
 
15551
 
                ausWriteData[ 0 ] = 0x0000;
15552
 
                ausWriteData[ 1 ] = 0x0000;
15553
 
                ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_TAIL_NODE & 0x7FF); /* Head node. */
15554
 
                ausWriteData[ 3 ] = 0x0000;
15555
 
 
15556
 
                mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
15557
 
                if ( ulResult != cOCT6100_ERR_OK )
15558
 
                        return ulResult;
15559
 
 
15560
 
                /* Configure the tail node. */
15561
 
                BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + 0x10;
15562
 
                BurstParams.ulWriteLength = 4;
15563
 
 
15564
 
                ausWriteData[ 0 ] = 0x0000;
15565
 
                ausWriteData[ 1 ] = 0x0000;
15566
 
                ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_HEAD_NODE & 0x7FF); /* Head node. */
15567
 
                ausWriteData[ 3 ] = 0x0000;
15568
 
 
15569
 
                mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
15570
 
                if ( ulResult != cOCT6100_ERR_OK )
15571
 
                        return ulResult;
15572
 
        }
15573
 
 
15574
 
        return cOCT6100_ERR_OK;
15575
 
}
15576
 
 
15577
 
 
15578
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15579
 
 
15580
 
Function:               Oct6100ApiInitRecordResources
15581
 
 
15582
 
Description:    This function will initialize the resources required to 
15583
 
                                perform recording on a debug channel.
15584
 
 
15585
 
-------------------------------------------------------------------------------
15586
 
|       Argument                |       Description
15587
 
-------------------------------------------------------------------------------
15588
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
15589
 
                                        present state of the chip and all its resources.
15590
 
 
15591
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15592
 
static UINT32 Oct6100ApiInitRecordResources(
15593
 
                                IN OUT  tPOCT6100_INSTANCE_API f_pApiInstance )
15594
 
{
15595
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
15596
 
        UINT32                                  ulResult;
15597
 
 
15598
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
15599
 
 
15600
 
        /* Check if recording is enabled. */
15601
 
        if ( pSharedInfo->ChipConfig.fEnableChannelRecording == FALSE )
15602
 
                return cOCT6100_ERR_OK;
15603
 
 
15604
 
        if ( pSharedInfo->DebugInfo.usRecordMemIndex == cOCT6100_INVALID_INDEX )
15605
 
                return cOCT6100_ERR_NOT_SUPPORTED_OPEN_DEBUG_RECORD;
15606
 
        
15607
 
        /* Check the provided recording memory index within the SSPX. */
15608
 
        if ( pSharedInfo->DebugInfo.usRecordMemIndex != ( pSharedInfo->ImageInfo.usMaxNumberOfChannels - 1 ) )
15609
 
                return cOCT6100_ERR_OPEN_DEBUG_MEM_INDEX;
15610
 
 
15611
 
        /* Reserve the TSI entries for the channel. */
15612
 
        ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex );
15613
 
        if ( ulResult != cOCT6100_ERR_OK )
15614
 
                return ulResult;
15615
 
 
15616
 
        ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex );
15617
 
        if ( ulResult != cOCT6100_ERR_OK )
15618
 
                return ulResult;
15619
 
 
15620
 
        /* Open the debug channel. */
15621
 
        ulResult = Oct6100ApiDebugChannelOpen( f_pApiInstance );
15622
 
        if ( ulResult != cOCT6100_ERR_OK )
15623
 
                return ulResult;
15624
 
 
15625
 
        return cOCT6100_ERR_OK;
15626
 
}
15627
 
 
15628
 
 
15629
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15630
 
 
15631
 
Function:               Oct6100ApiProductionCrc
15632
 
 
15633
 
Description:    This function calculates the crc for a production BIST
15634
 
                                message.
15635
 
 
15636
 
-------------------------------------------------------------------------------
15637
 
|       Argument                |       Description
15638
 
-------------------------------------------------------------------------------
15639
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
15640
 
                                                the present state of the chip and all its resources.
15641
 
 
15642
 
f_pulMessage                    Message to be exchanged with the firmware.  The CRC
15643
 
                                                will be calculated on this.
15644
 
f_ulMessageLength               Length of the message to be exchanged.  This value
15645
 
                                                does not include the CRC value at the end
15646
 
f_pulCrcResult                  Resulting calculated CRC value.
15647
 
 
15648
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15649
 
static UINT32 Oct6100ApiProductionCrc(
15650
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance,
15651
 
                                IN              PUINT32                                         f_pulMessage,
15652
 
                                IN              UINT32                                          f_ulMessageLength,
15653
 
                                OUT             PUINT32                                         f_pulCrcResult )
15654
 
{
15655
 
        UINT32  ulWidth = 32;
15656
 
        UINT32  ulKey, i, j;
15657
 
        UINT32  ulRemainder = 0;
15658
 
        
15659
 
        /* CRC the message. */
15660
 
        ulRemainder = f_pulMessage[ f_ulMessageLength - 1 ]; 
15661
 
        for ( j = f_ulMessageLength - 1; j != 0xFFFFFFFF ; j-- ) 
15662
 
        {
15663
 
                for ( i = 0; i < ulWidth; i++ )
15664
 
                {                       
15665
 
                        if ( ( ( ulRemainder >> 0x1F ) & 0x1 ) == 0x1 ) 
15666
 
                        {
15667
 
                                /* Division is by something meaningful */
15668
 
                                ulKey = 0x8765DCBA;
15669
 
                        }
15670
 
                        else    
15671
 
                        {
15672
 
                                /* Remainder is less than our divisor */
15673
 
                                ulKey = 0;
15674
 
                        }
15675
 
                        ulRemainder = ulRemainder ^ ulKey;
15676
 
                        
15677
 
                        ulRemainder = ulRemainder << 1;
15678
 
                        if ( j != 0 )
15679
 
                        {
15680
 
                                ulRemainder = ulRemainder | ( ( f_pulMessage[ j - 1 ] ) >> ( 0x1F - i ) );
15681
 
                        }
15682
 
                }
15683
 
        }
15684
 
 
15685
 
        *f_pulCrcResult = ulRemainder;
15686
 
 
15687
 
        return cOCT6100_ERR_OK;
15688
 
}
15689
 
 
15690
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15691
 
 
15692
 
File: oct6100_mixer.c
15693
 
 
15694
 
    Copyright (c) 2001-2005 Octasic Inc.
15695
 
 
15696
 
Description:
15697
 
 
15698
 
        This file contains the functions used to manage the allocation of mixer
15699
 
        blocks in memories.
15700
 
 
15701
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is
15702
 
free software; you can redistribute it and/or modify it under the terms of
15703
 
the GNU General Public License as published by the Free Software Foundation;
15704
 
either version 2 of the License, or (at your option) any later version.
15705
 
 
15706
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but
15707
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15708
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15709
 
for more details.
15710
 
 
15711
 
You should have received a copy of the GNU General Public License
15712
 
along with the OCT6100 GPL API; if not, write to the Free Software
15713
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
15714
 
 
15715
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
15716
 
 
15717
 
$Octasic_Revision: 42 $
15718
 
 
15719
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15720
 
 
15721
 
 
15722
 
/*****************************  INCLUDE FILES  *******************************/
15723
 
 
15724
 
#include "octdef.h"
15725
 
 
15726
 
#include "oct6100api/oct6100_defines.h"
15727
 
#include "oct6100api/oct6100_errors.h"
15728
 
 
15729
 
#include "apilib/octapi_llman.h"
15730
 
#include "oct6100api/oct6100_apiud.h"
15731
 
#include "oct6100api/oct6100_tlv_inst.h"
15732
 
#include "oct6100api/oct6100_chip_open_inst.h"
15733
 
#include "oct6100api/oct6100_chip_stats_inst.h"
15734
 
#include "oct6100api/oct6100_interrupts_inst.h"
15735
 
#include "oct6100api/oct6100_remote_debug_inst.h"
15736
 
#include "oct6100api/oct6100_debug_inst.h"
15737
 
#include "oct6100api/oct6100_api_inst.h"
15738
 
#include "oct6100api/oct6100_channel_inst.h"
15739
 
#include "oct6100api/oct6100_mixer_inst.h"
15740
 
 
15741
 
#include "oct6100api/oct6100_interrupts_pub.h"
15742
 
#include "oct6100api/oct6100_chip_open_pub.h"
15743
 
#include "oct6100api/oct6100_channel_pub.h"
15744
 
#include "oct6100api/oct6100_mixer_pub.h"
15745
 
 
15746
 
#include "oct6100_chip_open_priv.h"
15747
 
#include "oct6100_miscellaneous_priv.h"
15748
 
#include "oct6100_channel_priv.h"
15749
 
#include "oct6100_mixer_priv.h"
15750
 
 
15751
 
/****************************  PRIVATE FUNCTIONS  ****************************/
15752
 
 
15753
 
 
15754
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15755
 
 
15756
 
Function:               Oct6100ApiGetMixerSwSizes
15757
 
 
15758
 
Description:    Gets the sizes of all portions of the API instance pertinent
15759
 
                                to the management of mixer events.
15760
 
 
15761
 
-------------------------------------------------------------------------------
15762
 
|       Argument                |       Description
15763
 
-------------------------------------------------------------------------------
15764
 
 
15765
 
f_pOpenChip                             User chip configuration.
15766
 
f_pInstSizes                    Pointer to struct containing instance sizes.
15767
 
 
15768
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15769
 
static UINT32 Oct6100ApiGetMixerSwSizes(
15770
 
                                IN              tPOCT6100_CHIP_OPEN                             f_pOpenChip,
15771
 
                                OUT             tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
15772
 
{
15773
 
        UINT32  ulTempVar;
15774
 
        UINT32  ulResult;
15775
 
 
15776
 
        /* Calculate the API memory required for the resource entry lists. */
15777
 
        f_pInstSizes->ulMixerEventList = cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_MIXER_EVENT );
15778
 
 
15779
 
        /* Calculate memory needed for mixers entry allocation. */
15780
 
        ulResult = OctapiLlmAllocGetSize( cOCT6100_MAX_MIXER_EVENTS, &f_pInstSizes->ulMixerEventAlloc );
15781
 
        if ( ulResult != cOCT6100_ERR_OK )
15782
 
                return cOCT6100_ERR_FATAL_1D;
15783
 
 
15784
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulMixerEventList, ulTempVar )
15785
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulMixerEventAlloc, ulTempVar )
15786
 
 
15787
 
 
15788
 
        f_pInstSizes->ulCopyEventList = cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_COPY_EVENT );
15789
 
 
15790
 
        ulResult = OctapiLlmAllocGetSize( cOCT6100_MAX_MIXER_EVENTS, &f_pInstSizes->ulCopyEventAlloc );
15791
 
        if ( ulResult != cOCT6100_ERR_OK )
15792
 
                return cOCT6100_ERR_FATAL_1D;
15793
 
 
15794
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulCopyEventList, ulTempVar )
15795
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulCopyEventAlloc, ulTempVar )
15796
 
 
15797
 
 
15798
 
        return cOCT6100_ERR_OK;
15799
 
}
15800
 
 
15801
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15802
 
 
15803
 
Function:               Oct6100ApiReserveMixerEventEntry
15804
 
 
15805
 
Description:    Reserves a free entry in the mixer event list.
15806
 
 
15807
 
-------------------------------------------------------------------------------
15808
 
|       Argument                |       Description
15809
 
-------------------------------------------------------------------------------
15810
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
15811
 
                                        present state of the chip and all its resources.
15812
 
 
15813
 
f_pusEventIndex         List entry reserved.
15814
 
 
15815
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15816
 
static UINT32 Oct6100ApiReserveMixerEventEntry(
15817
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
15818
 
                                OUT             PUINT16                                                 f_pusEventIndex )
15819
 
{
15820
 
        PVOID   pMixerEventAlloc;
15821
 
        UINT32  ulResult;
15822
 
        UINT32  ulEventIndex;
15823
 
 
15824
 
        mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc )
15825
 
 
15826
 
        ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulEventIndex );
15827
 
        if ( ulResult != cOCT6100_ERR_OK )
15828
 
        {
15829
 
                if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
15830
 
                        return cOCT6100_ERR_MIXER_ALL_MIXER_EVENT_ENTRY_OPENED;
15831
 
                else
15832
 
                        return cOCT6100_ERR_FATAL_2B;
15833
 
        }
15834
 
 
15835
 
        *f_pusEventIndex = (UINT16)( ulEventIndex & 0xFFFF );
15836
 
 
15837
 
        return cOCT6100_ERR_OK;
15838
 
}
15839
 
 
15840
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15841
 
 
15842
 
Function:               Oct6100ApiMixerSwInit
15843
 
 
15844
 
Description:    Initializes all elements of the instance structure associated
15845
 
                                to the mixer events.
15846
 
 
15847
 
-------------------------------------------------------------------------------
15848
 
|       Argument                |       Description
15849
 
-------------------------------------------------------------------------------
15850
 
f_pApiInstance                  Pointer to API instance. This mixer is used to keep
15851
 
                                                the present state of the chip and all its resources.
15852
 
 
15853
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15854
 
static UINT32 Oct6100ApiMixerSwInit(
15855
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance )
15856
 
{
15857
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
15858
 
        tPOCT6100_API_MIXER_EVENT               pMixerEventList;
15859
 
        PVOID   pMixerEventAlloc;
15860
 
        PVOID   pCopyEventAlloc;
15861
 
        UINT32  ulTempVar;
15862
 
        UINT32  ulResult;
15863
 
 
15864
 
        /* Get local pointer(s). */
15865
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
15866
 
 
15867
 
        /*===================================================================*/
15868
 
        /* Initialize the mixer event list. */
15869
 
        mOCT6100_GET_MIXER_EVENT_LIST_PNT( pSharedInfo, pMixerEventList );
15870
 
 
15871
 
        /* Initialize the mixer event allocation software to "all free". */
15872
 
        Oct6100UserMemSet( pMixerEventList, 0x00, cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_MIXER_EVENT ));
15873
 
 
15874
 
        mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( pSharedInfo, pMixerEventAlloc )
15875
 
        
15876
 
        ulResult = OctapiLlmAllocInit( &pMixerEventAlloc, cOCT6100_MAX_MIXER_EVENTS );
15877
 
        if ( ulResult != cOCT6100_ERR_OK )
15878
 
                return cOCT6100_ERR_FATAL_1F;
15879
 
 
15880
 
        /* Now reserve the first entry as the first node. */
15881
 
        ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulTempVar );
15882
 
        if ( ulResult != cOCT6100_ERR_OK )
15883
 
        {
15884
 
                return cOCT6100_ERR_FATAL_20;
15885
 
        }
15886
 
 
15887
 
        /* Check that we obtain the first event. */
15888
 
        if ( ulTempVar != 0 )
15889
 
                return cOCT6100_ERR_FATAL_21;
15890
 
 
15891
 
        /* Now reserve the tail entry. */
15892
 
        ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulTempVar );
15893
 
        if ( ulResult != cOCT6100_ERR_OK )
15894
 
        {
15895
 
                return cOCT6100_ERR_FATAL_AA;
15896
 
        }
15897
 
        /* Check that we obtain the first event. */
15898
 
        if ( ulTempVar != 1 )
15899
 
                return cOCT6100_ERR_FATAL_AB;
15900
 
 
15901
 
        /* Program the head node. */
15902
 
        pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].fReserved = TRUE;
15903
 
        pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].usNextEventPtr = cOCT6100_MIXER_TAIL_NODE;
15904
 
        pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
15905
 
 
15906
 
        /* Program the tail node. */
15907
 
        pMixerEventList[ cOCT6100_MIXER_TAIL_NODE ].fReserved = TRUE;
15908
 
        pMixerEventList[ cOCT6100_MIXER_TAIL_NODE ].usNextEventPtr = cOCT6100_INVALID_INDEX;
15909
 
        pMixerEventList[ cOCT6100_MIXER_TAIL_NODE ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
15910
 
 
15911
 
        /* Now reserve the entry used for channel recording if the feature is enabled. */
15912
 
        if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
15913
 
        {
15914
 
                UINT32 ulAllocIndex;
15915
 
 
15916
 
                /* Reserve an entry to copy the desire SOUT signal to the SIN signal of the recording channel. */
15917
 
                ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulAllocIndex );
15918
 
                if ( ulResult != cOCT6100_ERR_OK )
15919
 
                {
15920
 
                        return cOCT6100_ERR_FATAL_90;
15921
 
                }
15922
 
 
15923
 
                pSharedInfo->MixerInfo.usRecordCopyEventIndex = (UINT16)( ulAllocIndex & 0xFFFF );
15924
 
 
15925
 
                /* Reserve an entry to copy the saved SIN signal of the debugged channel into it's original location. */
15926
 
                ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulAllocIndex );
15927
 
                if ( ulResult != cOCT6100_ERR_OK )
15928
 
                {
15929
 
                        return cOCT6100_ERR_FATAL_90;
15930
 
                }
15931
 
 
15932
 
                pSharedInfo->MixerInfo.usRecordSinEventIndex = (UINT16)( ulAllocIndex & 0xFFFF );
15933
 
        
15934
 
                /* Configure the SIN event. */
15935
 
                pMixerEventList[ pSharedInfo->MixerInfo.usRecordSinEventIndex ].fReserved = TRUE;
15936
 
                pMixerEventList[ pSharedInfo->MixerInfo.usRecordSinEventIndex ].usNextEventPtr = cOCT6100_MIXER_TAIL_NODE;
15937
 
                pMixerEventList[ pSharedInfo->MixerInfo.usRecordSinEventIndex ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
15938
 
 
15939
 
                /* Configure the SOUT copy event. */
15940
 
                pMixerEventList[ pSharedInfo->MixerInfo.usRecordCopyEventIndex ].fReserved = TRUE;
15941
 
                pMixerEventList[ pSharedInfo->MixerInfo.usRecordCopyEventIndex ].usNextEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex;
15942
 
                pMixerEventList[ pSharedInfo->MixerInfo.usRecordCopyEventIndex ].usEventType = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
15943
 
                
15944
 
                /* Program the head node. */
15945
 
                pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].usNextEventPtr = pSharedInfo->MixerInfo.usRecordCopyEventIndex;
15946
 
        }
15947
 
 
15948
 
        /* Initialize the copy event list. */
15949
 
        mOCT6100_GET_COPY_EVENT_ALLOC_PNT( pSharedInfo, pCopyEventAlloc )
15950
 
        
15951
 
        ulResult = OctapiLlmAllocInit( &pCopyEventAlloc, cOCT6100_MAX_MIXER_EVENTS );
15952
 
        if ( ulResult != cOCT6100_ERR_OK )
15953
 
                return cOCT6100_ERR_FATAL_B4;
15954
 
 
15955
 
        return cOCT6100_ERR_OK;
15956
 
}
15957
 
 
15958
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15959
 
 
15960
 
Function:               Oct6100ApiMixerEventAdd
15961
 
 
15962
 
Description:    This function adds a mixer event event to the list of events 
15963
 
                                based on the event type passed to the function.
15964
 
 
15965
 
-------------------------------------------------------------------------------
15966
 
|       Argument                |       Description
15967
 
-------------------------------------------------------------------------------
15968
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep 
15969
 
                                                        the present state of the chip and all its resources.
15970
 
f_usEventIndex                          Index of the event within the API's mixer event list.
15971
 
f_usEventType                           Type of mixer event.
15972
 
f_usDestinationChanIndex        Index of the destination channel within the API's 
15973
 
                                                        channel list.
15974
 
 
15975
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15976
 
static UINT32   Oct6100ApiMixerEventAdd( 
15977
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
15978
 
                                IN              UINT16                                                  f_usEventIndex,
15979
 
                                IN              UINT16                                                  f_usEventType,
15980
 
                                IN              UINT16                                                  f_usDestinationChanIndex )
15981
 
{
15982
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
15983
 
        tPOCT6100_API_MIXER_EVENT               pCurrentEventEntry;
15984
 
        tPOCT6100_API_MIXER_EVENT               pTempEventEntry;
15985
 
        tPOCT6100_API_CHANNEL                   pDestinationEntry;
15986
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
15987
 
        UINT32  ulResult;
15988
 
        UINT16  usTempEventIndex;
15989
 
 
15990
 
        /* Obtain local pointer to shared portion of instance. */
15991
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
15992
 
 
15993
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
15994
 
 
15995
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15996
 
 
15997
 
        /* Get a pointer to the event entry. */
15998
 
        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCurrentEventEntry, f_usEventIndex );
15999
 
 
16000
 
        /* Get a pointer to the destination channel entry. */
16001
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, f_usDestinationChanIndex );
16002
 
 
16003
 
        /* Now proceed according to the event type. */
16004
 
        switch ( f_usEventType )
16005
 
        {
16006
 
        case cOCT6100_EVENT_TYPE_SOUT_COPY:
16007
 
 
16008
 
                /* Now insert the Sin copy event */
16009
 
                if ( pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
16010
 
                {
16011
 
                        /* The only node in the list before the point where the node needs to */
16012
 
                        /* be inserted is the head node. */
16013
 
                        usTempEventIndex = cOCT6100_MIXER_HEAD_NODE;
16014
 
 
16015
 
                        /* This node will be the first one in the Sout copy section. */
16016
 
                        pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = f_usEventIndex;
16017
 
                        pSharedInfo->MixerInfo.usLastSoutCopyEventPtr  = f_usEventIndex;
16018
 
                }
16019
 
                else /* pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr != cOCT6100_INVALID_INDEX */
16020
 
                {
16021
 
                        usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
16022
 
                        pSharedInfo->MixerInfo.usLastSoutCopyEventPtr  = f_usEventIndex;
16023
 
                }
16024
 
 
16025
 
                break;
16026
 
 
16027
 
        case cOCT6100_EVENT_TYPE_SIN_COPY:
16028
 
 
16029
 
                /* Now insert the Sin copy event. */
16030
 
                if ( pSharedInfo->MixerInfo.usFirstSinCopyEventPtr == cOCT6100_INVALID_INDEX )
16031
 
                {
16032
 
                        /* This is the first Sin copy event. We must find the event that comes before */
16033
 
                        /* the event we want to add. First let's check for a bridge event. */
16034
 
                        if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == cOCT6100_INVALID_INDEX )
16035
 
                        {
16036
 
                                /* No event in the bridge section, now let's check in the Sout copy section. */
16037
 
                                if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
16038
 
                                {
16039
 
                                        /* The only node in the list then is the head node. */
16040
 
                                        usTempEventIndex = cOCT6100_MIXER_HEAD_NODE;
16041
 
                                }
16042
 
                                else
16043
 
                                {
16044
 
                                        usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
16045
 
                                }
16046
 
                        }
16047
 
                        else
16048
 
                        {
16049
 
                                usTempEventIndex = pSharedInfo->MixerInfo.usLastBridgeEventPtr;
16050
 
                        }
16051
 
 
16052
 
                        /* This node will be the first one in the Sin copy section. */
16053
 
                        pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = f_usEventIndex;
16054
 
                        pSharedInfo->MixerInfo.usLastSinCopyEventPtr  = f_usEventIndex;
16055
 
                }
16056
 
                else /* pSharedInfo->MixerInfo.usFirstSinCopyEventPtr != cOCT6100_INVALID_INDEX */
16057
 
                {
16058
 
                        usTempEventIndex = pSharedInfo->MixerInfo.usLastSinCopyEventPtr;
16059
 
                        pSharedInfo->MixerInfo.usLastSinCopyEventPtr = f_usEventIndex;
16060
 
                }
16061
 
 
16062
 
                break;
16063
 
 
16064
 
        default:
16065
 
                return cOCT6100_ERR_FATAL_AF;
16066
 
 
16067
 
        }
16068
 
 
16069
 
        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
16070
 
 
16071
 
        /*=======================================================================*/
16072
 
        /* Program the Copy event. */
16073
 
 
16074
 
        /* Set the Copy event first. */
16075
 
        pCurrentEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_COPY;
16076
 
        pCurrentEventEntry->usNextEventPtr = pTempEventEntry->usNextEventPtr;
16077
 
 
16078
 
        WriteParams.ulWriteAddress  = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
16079
 
        WriteParams.ulWriteAddress += 4;
16080
 
        WriteParams.usWriteData         = pCurrentEventEntry->usNextEventPtr;
16081
 
        
16082
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
16083
 
        if ( ulResult != cOCT6100_ERR_OK )
16084
 
                return ulResult;
16085
 
 
16086
 
        /*=======================================================================*/
16087
 
 
16088
 
        /*=======================================================================*/
16089
 
        /* Modify the previous node. */
16090
 
 
16091
 
        /* Set the last Sub-store entry. */
16092
 
        pTempEventEntry->usNextEventPtr = f_usEventIndex;
16093
 
 
16094
 
        WriteParams.ulWriteAddress  = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
16095
 
        WriteParams.ulWriteAddress += 4;
16096
 
        WriteParams.usWriteData         = f_usEventIndex;
16097
 
        
16098
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
16099
 
        if ( ulResult != cOCT6100_ERR_OK )
16100
 
                return ulResult;
16101
 
 
16102
 
        /*=======================================================================*/     
16103
 
 
16104
 
        /* Save the destination channel index, needed when removing the event from the mixer. */
16105
 
        pCurrentEventEntry->usDestinationChanIndex = f_usDestinationChanIndex;
16106
 
 
16107
 
        /* Mark the entry as reserved. */
16108
 
        pCurrentEventEntry->fReserved = TRUE;
16109
 
 
16110
 
        /* Increment the event count on that particular destination channel */
16111
 
        pDestinationEntry->usMixerEventCnt++;
16112
 
 
16113
 
        return cOCT6100_ERR_OK;
16114
 
}
16115
 
 
16116
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16117
 
 
16118
 
Function:               Oct6100ApiMixerEventRemove
16119
 
 
16120
 
Description:    This function removes a mixer event event from the list of events based
16121
 
                                on the event type passed to the function.
16122
 
 
16123
 
-------------------------------------------------------------------------------
16124
 
|       Argument                |       Description
16125
 
-------------------------------------------------------------------------------
16126
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
16127
 
                                                present state of the chip and all its resources.
16128
 
 
16129
 
f_usEventIndex                  Index of event within the API's mixer event list.
16130
 
f_usEventType                   Type of mixer event.
16131
 
 
16132
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16133
 
static UINT32 Oct6100ApiMixerEventRemove( 
16134
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
16135
 
                                IN              UINT16                                                  f_usEventIndex,
16136
 
                                IN              UINT16                                                  f_usEventType )
16137
 
{
16138
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
16139
 
        tPOCT6100_API_MIXER_EVENT               pCurrentEventEntry;
16140
 
        tPOCT6100_API_MIXER_EVENT               pTempEventEntry;
16141
 
        tPOCT6100_API_CHANNEL                   pDestinationEntry;
16142
 
        tOCT6100_WRITE_BURST_PARAMS             BurstWriteParams;
16143
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
16144
 
        BOOL    fFirstSinCopyEvent = FALSE;
16145
 
        UINT32  ulResult;
16146
 
        UINT16  usTempEventIndex;
16147
 
        UINT32  ulLoopCount = 0;
16148
 
        UINT16  ausWriteData[ 4 ] = { 0 };
16149
 
 
16150
 
        /* Obtain local pointer to shared portion of instance. */
16151
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
16152
 
 
16153
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
16154
 
 
16155
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
16156
 
 
16157
 
        BurstWriteParams.pProcessContext = f_pApiInstance->pProcessContext;
16158
 
 
16159
 
        BurstWriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
16160
 
        BurstWriteParams.pusWriteData = ausWriteData;
16161
 
        BurstWriteParams.ulWriteLength = 4;
16162
 
 
16163
 
        /* Get a pointer to the event entry. */
16164
 
        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCurrentEventEntry, f_usEventIndex );
16165
 
 
16166
 
        /* Get the pointer to the channel entry. */
16167
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, pCurrentEventEntry->usDestinationChanIndex );
16168
 
 
16169
 
        /* Now proceed according to the event type. */
16170
 
        switch ( f_usEventType )
16171
 
        {
16172
 
        case cOCT6100_EVENT_TYPE_SOUT_COPY:
16173
 
 
16174
 
                if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr )
16175
 
                {
16176
 
                        usTempEventIndex = cOCT6100_MIXER_HEAD_NODE;
16177
 
                }
16178
 
                else
16179
 
                {
16180
 
                        /* Now insert the Sin copy event. */
16181
 
                        usTempEventIndex = pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr;
16182
 
                }
16183
 
 
16184
 
                /* Find the copy entry before the entry to remove. */
16185
 
                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
16186
 
 
16187
 
                while( pTempEventEntry->usNextEventPtr != f_usEventIndex )
16188
 
                {
16189
 
                        usTempEventIndex = pTempEventEntry->usNextEventPtr;
16190
 
 
16191
 
                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
16192
 
 
16193
 
                        ulLoopCount++;
16194
 
                        if ( ulLoopCount == cOCT6100_MAX_LOOP )
16195
 
                                return cOCT6100_ERR_FATAL_B2;
16196
 
                }
16197
 
 
16198
 
                /*=======================================================================*/
16199
 
                /* Update the global mixer pointers. */
16200
 
                if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr )
16201
 
                {
16202
 
                        if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSoutCopyEventPtr )
16203
 
                        {
16204
 
                                /* This event was the only of the list.*/
16205
 
                                pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = cOCT6100_INVALID_INDEX;
16206
 
                                pSharedInfo->MixerInfo.usLastSoutCopyEventPtr  = cOCT6100_INVALID_INDEX;
16207
 
                        }
16208
 
                        else
16209
 
                        {
16210
 
                                pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = pCurrentEventEntry->usNextEventPtr;
16211
 
                        }
16212
 
                }
16213
 
                else if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSoutCopyEventPtr )
16214
 
                {
16215
 
                        pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = usTempEventIndex;
16216
 
                }
16217
 
                /*=======================================================================*/
16218
 
 
16219
 
                break;
16220
 
 
16221
 
 
16222
 
        case cOCT6100_EVENT_TYPE_SIN_COPY:
16223
 
 
16224
 
                if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSinCopyEventPtr )
16225
 
                {
16226
 
                        fFirstSinCopyEvent = TRUE;
16227
 
 
16228
 
                        if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr != cOCT6100_INVALID_INDEX )
16229
 
                        {
16230
 
                                usTempEventIndex = pSharedInfo->MixerInfo.usLastBridgeEventPtr;
16231
 
                        }
16232
 
                        else if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr != cOCT6100_INVALID_INDEX )
16233
 
                        {
16234
 
                                usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
16235
 
                        }
16236
 
                        else
16237
 
                        {
16238
 
                                usTempEventIndex = cOCT6100_MIXER_HEAD_NODE;
16239
 
                        }       
16240
 
                }
16241
 
                else
16242
 
                {
16243
 
                        /* Now insert the Sin copy event. */
16244
 
                        usTempEventIndex = pSharedInfo->MixerInfo.usFirstSinCopyEventPtr;
16245
 
                }
16246
 
 
16247
 
                /* Find the copy entry before the entry to remove. */
16248
 
                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
16249
 
                
16250
 
                /* If we are not the first event of the Sin copy list. */
16251
 
                if ( fFirstSinCopyEvent == FALSE )
16252
 
                {
16253
 
                        while( pTempEventEntry->usNextEventPtr != f_usEventIndex )
16254
 
                        {
16255
 
                                usTempEventIndex = pTempEventEntry->usNextEventPtr;
16256
 
                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
16257
 
 
16258
 
                                ulLoopCount++;
16259
 
                                if ( ulLoopCount == cOCT6100_MAX_LOOP )
16260
 
                                        return cOCT6100_ERR_FATAL_B1;
16261
 
                        }
16262
 
                }
16263
 
 
16264
 
                /*=======================================================================*/
16265
 
                /* Update the global mixer pointers. */
16266
 
                if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSinCopyEventPtr )
16267
 
                {
16268
 
                        if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSinCopyEventPtr )
16269
 
                        {
16270
 
                                /* This event was the only of the list. */
16271
 
                                pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = cOCT6100_INVALID_INDEX;
16272
 
                                pSharedInfo->MixerInfo.usLastSinCopyEventPtr  = cOCT6100_INVALID_INDEX;
16273
 
                        }
16274
 
                        else
16275
 
                        {
16276
 
                                pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pCurrentEventEntry->usNextEventPtr;
16277
 
                        }
16278
 
                }
16279
 
                else if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSinCopyEventPtr )
16280
 
                {
16281
 
                        pSharedInfo->MixerInfo.usLastSinCopyEventPtr = usTempEventIndex;
16282
 
                }
16283
 
                /*=======================================================================*/
16284
 
 
16285
 
                break;
16286
 
 
16287
 
        default:
16288
 
                return cOCT6100_ERR_FATAL_B0;
16289
 
 
16290
 
        }
16291
 
        
16292
 
        /*=======================================================================*/
16293
 
        /* Modify the previous event. */
16294
 
 
16295
 
        pTempEventEntry->usNextEventPtr = pCurrentEventEntry->usNextEventPtr;
16296
 
 
16297
 
        WriteParams.ulWriteAddress  = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
16298
 
        WriteParams.ulWriteAddress += 4;
16299
 
        WriteParams.usWriteData         = pTempEventEntry->usNextEventPtr;
16300
 
        
16301
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
16302
 
        if ( ulResult != cOCT6100_ERR_OK )
16303
 
                return ulResult;
16304
 
 
16305
 
        /*=======================================================================*/
16306
 
 
16307
 
 
16308
 
        /*=======================================================================*/
16309
 
        /* Clear the current event. */
16310
 
 
16311
 
        BurstWriteParams.ulWriteAddress  = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
16312
 
        
16313
 
        mOCT6100_DRIVER_WRITE_BURST_API( BurstWriteParams, ulResult );
16314
 
        if ( ulResult != cOCT6100_ERR_OK )
16315
 
                return ulResult;
16316
 
 
16317
 
        /*=======================================================================*/
16318
 
 
16319
 
 
16320
 
        /*=======================================================================*/
16321
 
        /* Decrement the mixer event count active on that channel. */
16322
 
        pDestinationEntry->usMixerEventCnt--;
16323
 
 
16324
 
        /*=======================================================================*/
16325
 
 
16326
 
        
16327
 
        /*=======================================================================*/
16328
 
 
16329
 
        /* This index of this channel is not valid anymore! */
16330
 
        pCurrentEventEntry->usDestinationChanIndex = cOCT6100_INVALID_INDEX;
16331
 
 
16332
 
        /* Mark this entry as free. */
16333
 
        pCurrentEventEntry->fReserved = FALSE;
16334
 
 
16335
 
        return cOCT6100_ERR_OK;
16336
 
}
16337
 
 
16338
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16339
 
 
16340
 
Function:               Oct6100ApiGetFreeMixerEventCnt
16341
 
 
16342
 
Description:    Retrieve the number of events left in the list.
16343
 
 
16344
 
-------------------------------------------------------------------------------
16345
 
|       Argument                |       Description
16346
 
-------------------------------------------------------------------------------
16347
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
16348
 
                                                present state of the chip and all its resources.
16349
 
 
16350
 
f_pulFreeEventCnt               How many events left.
16351
 
 
16352
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16353
 
static UINT32 Oct6100ApiGetFreeMixerEventCnt(
16354
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
16355
 
                                OUT             PUINT32                                                 f_pulFreeEventCnt )
16356
 
{
16357
 
        PVOID   pMixerEventAlloc;
16358
 
        UINT32  ulResult;
16359
 
        UINT32  ulAllocatedEvents;
16360
 
        UINT32  ulAvailableEvents;
16361
 
 
16362
 
        mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc )
16363
 
 
16364
 
        ulResult = OctapiLlmAllocInfo( pMixerEventAlloc, &ulAllocatedEvents, &ulAvailableEvents );
16365
 
        if ( ulResult != cOCT6100_ERR_OK )
16366
 
                return cOCT6100_ERR_FATAL_E8;
16367
 
 
16368
 
        /* Return number of free events. */
16369
 
        *f_pulFreeEventCnt = ulAvailableEvents;
16370
 
 
16371
 
        return cOCT6100_ERR_OK;
16372
 
}
16373
 
 
16374
 
 
16375
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16376
 
 
16377
 
Function:               Oct6100ApiWriteDword
16378
 
 
16379
 
Description:    Write a DWORD at specified address in external memory.
16380
 
 
16381
 
-------------------------------------------------------------------------------
16382
 
|       Argument                |       Description
16383
 
-------------------------------------------------------------------------------
16384
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
16385
 
                                                present state of the chip and all its resources.
16386
 
 
16387
 
f_ulAddress                             DWORD address where to write.
16388
 
f_ulWriteData                   DWORD data to write.
16389
 
 
16390
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16391
 
static UINT32 Oct6100ApiWriteDword( 
16392
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance,
16393
 
                                IN              UINT32                                          f_ulAddress,
16394
 
                                IN              UINT32                                          f_ulWriteData )
16395
 
{
16396
 
        tOCT6100_WRITE_PARAMS   WriteParams;
16397
 
        UINT32  ulResult;
16398
 
 
16399
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
16400
 
 
16401
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
16402
 
 
16403
 
        /* Write the first 16 bits. */
16404
 
        WriteParams.ulWriteAddress = f_ulAddress;
16405
 
        WriteParams.usWriteData = (UINT16)((f_ulWriteData >> 16) & 0xFFFF);
16406
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
16407
 
        if ( ulResult != cOCT6100_ERR_OK )
16408
 
                return ulResult;
16409
 
        
16410
 
        /* Write the last word. */
16411
 
        WriteParams.ulWriteAddress += 2;
16412
 
        WriteParams.usWriteData = (UINT16)(f_ulWriteData & 0xFFFF);
16413
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
16414
 
        if ( ulResult != cOCT6100_ERR_OK )
16415
 
                return ulResult;
16416
 
 
16417
 
        return cOCT6100_ERR_OK;
16418
 
}
16419
 
 
16420
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16421
 
 
16422
 
Function:               Oct6100ApiReleaseTsiMemEntry
16423
 
 
16424
 
Description:    Releases a TSI chariot memory entry specified.
16425
 
 
16426
 
-------------------------------------------------------------------------------
16427
 
|       Argument                |       Description
16428
 
-------------------------------------------------------------------------------
16429
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
16430
 
                                                the present state of the chip and all its resources.
16431
 
 
16432
 
f_usTsiMemIndex                 Index reserved in the TSI chariot memory.
16433
 
 
16434
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16435
 
static UINT32 Oct6100ApiReleaseTsiMemEntry(
16436
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance,
16437
 
                                IN              UINT16                                          f_usTsiMemIndex )
16438
 
{
16439
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
16440
 
        PVOID   pTsiMemAlloc;
16441
 
        UINT32  ulResult;
16442
 
        UINT32  ulIndex;
16443
 
 
16444
 
        /* Get local pointer to shared portion of instance. */
16445
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
16446
 
 
16447
 
        /* Check if the entry programmed is greater then the timestamp entries. */
16448
 
        if ( f_usTsiMemIndex > cOCT6100_TSST_CONTROL_TIMESTAMP_BASE_ENTRY )
16449
 
                ulIndex = f_usTsiMemIndex - cOCT6100_TSI_MEM_FOR_TIMESTAMP;
16450
 
        else
16451
 
                ulIndex = f_usTsiMemIndex;
16452
 
 
16453
 
        /* Check if the entry programmed is greater then the phasing TSST entries. */
16454
 
        if ( ulIndex > cOCT6100_TSST_CONTROL_PHASING_TSST_BASE_ENTRY )
16455
 
                ulIndex -= pSharedInfo->ChipConfig.usMaxPhasingTssts;
16456
 
 
16457
 
        mOCT6100_GET_TSI_MEMORY_ALLOC_PNT( pSharedInfo, pTsiMemAlloc )
16458
 
        
16459
 
        ulResult = OctapiLlmAllocDealloc( pTsiMemAlloc, ulIndex );
16460
 
        if ( ulResult != cOCT6100_ERR_OK )
16461
 
        {
16462
 
                return cOCT6100_ERR_FATAL_93;
16463
 
        }
16464
 
 
16465
 
        return cOCT6100_ERR_OK;
16466
 
}
16467
 
 
16468
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16469
 
 
16470
 
Function:               Oct6100ApiReleaseMixerEventEntry
16471
 
 
16472
 
Description:    Release an entry from the mixer event list.
16473
 
 
16474
 
-------------------------------------------------------------------------------
16475
 
|       Argument                |       Description
16476
 
-------------------------------------------------------------------------------
16477
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
16478
 
                                        present state of the chip and all its resources.
16479
 
 
16480
 
f_usEventIndex          List entry reserved.
16481
 
 
16482
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16483
 
static UINT32 Oct6100ApiReleaseMixerEventEntry(
16484
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
16485
 
                                IN              UINT16                                                  f_usEventIndex )
16486
 
{
16487
 
        PVOID   pMixerEventAlloc;
16488
 
        UINT32  ulResult;
16489
 
 
16490
 
        mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc )
16491
 
 
16492
 
        ulResult = OctapiLlmAllocDealloc( pMixerEventAlloc, f_usEventIndex );
16493
 
        if ( ulResult != cOCT6100_ERR_OK )
16494
 
                return cOCT6100_ERR_FATAL_2C;
16495
 
 
16496
 
        return cOCT6100_ERR_OK;
16497
 
}
16498
 
 
16499
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16500
 
 
16501
 
Function:               Oct6100ApiWaitForPcRegisterBit
16502
 
 
16503
 
Description:    Polls the specified PC register bit.  The function exits once
16504
 
                                the bit is cleared by hardware, or when the specified timeout
16505
 
                                period has been expired.
16506
 
 
16507
 
-------------------------------------------------------------------------------
16508
 
|       Argument                |       Description
16509
 
-------------------------------------------------------------------------------
16510
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
16511
 
                                                present state of the chip and all its resources.
16512
 
 
16513
 
f_ulPcRegAdd                    Address of the register containing the PC bit.
16514
 
f_ulPcBitNum                    Number of the PC bit within the register.
16515
 
f_ulValue                               Expected value of the bit.
16516
 
f_ulTimeoutUs                   The timeout period, in usec.
16517
 
f_pfBitEqual                    Pointer to the result of the bit comparison.
16518
 
 
16519
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16520
 
static UINT32 Oct6100ApiWaitForPcRegisterBit(
16521
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance,
16522
 
                                IN              UINT32                                  f_ulPcRegAdd,
16523
 
                                IN              UINT32                                  f_ulPcBitNum,
16524
 
                                IN              UINT32                                  f_ulValue,
16525
 
                                IN              UINT32                                  f_ulTimeoutUs,
16526
 
                                OUT             PBOOL                                   f_pfBitEqual )
16527
 
{
16528
 
        tOCT6100_READ_PARAMS    ReadParams;
16529
 
        tOCT6100_GET_TIME               StartTime;
16530
 
        tOCT6100_GET_TIME               TimeoutTime;
16531
 
        tOCT6100_GET_TIME               CurrentTime;
16532
 
        UINT32                                  ulResult;
16533
 
        UINT16                                  usReadData;
16534
 
        BOOL                                    fConditionFlag = TRUE;
16535
 
 
16536
 
        /* Copy the process context. */
16537
 
        StartTime.pProcessContext       = f_pApiInstance->pProcessContext;
16538
 
        CurrentTime.pProcessContext     = f_pApiInstance->pProcessContext;
16539
 
 
16540
 
        /* Get the current system time. */
16541
 
        ulResult = Oct6100UserGetTime( &StartTime );
16542
 
        if ( ulResult != cOCT6100_ERR_OK )
16543
 
                return ulResult;
16544
 
 
16545
 
        /* Mark the bit as not being equal, for now. */
16546
 
        *f_pfBitEqual = FALSE;
16547
 
 
16548
 
        /* Determine the time at which the timeout has expired. */
16549
 
        ulResult = octapi_lm_add(
16550
 
                                                StartTime.aulWallTimeUs, 1,
16551
 
                                                &f_ulTimeoutUs, 0,
16552
 
                                                TimeoutTime.aulWallTimeUs, 1 );
16553
 
        if ( ulResult != cOCT6100_ERR_OK )
16554
 
                return ulResult;
16555
 
 
16556
 
        /* Prepare read structure. */
16557
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
16558
 
 
16559
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
16560
 
        ReadParams.ulReadAddress = f_ulPcRegAdd;
16561
 
        ReadParams.pusReadData = &usReadData;
16562
 
 
16563
 
        /* Read the PC bit while the timeout period hasn't expired. */
16564
 
        while ( fConditionFlag )
16565
 
        {
16566
 
                /* Read the current time again to check for timeout. */
16567
 
                ulResult = Oct6100UserGetTime( &CurrentTime );
16568
 
                if ( ulResult != cOCT6100_ERR_OK )
16569
 
                        return ulResult;
16570
 
 
16571
 
                ulResult = Oct6100UserDriverReadApi( &ReadParams );
16572
 
                if ( ulResult != cOCT6100_ERR_OK )
16573
 
                        return ulResult;
16574
 
 
16575
 
                if ( ( UINT16 )((usReadData >> f_ulPcBitNum) & 0x1) == ( UINT16 )f_ulValue )
16576
 
                {
16577
 
                        /* Mark the bit as being equal. */
16578
 
                        *f_pfBitEqual = TRUE;
16579
 
                        fConditionFlag = FALSE;
16580
 
                }
16581
 
 
16582
 
                if ( CurrentTime.aulWallTimeUs[ 1 ] > TimeoutTime.aulWallTimeUs[ 1 ] ||
16583
 
                         (CurrentTime.aulWallTimeUs[ 1 ] == TimeoutTime.aulWallTimeUs[ 1 ] &&
16584
 
                          CurrentTime.aulWallTimeUs[ 0 ] >= TimeoutTime.aulWallTimeUs[ 0 ]) )
16585
 
                        fConditionFlag = FALSE;
16586
 
        }
16587
 
 
16588
 
        return cOCT6100_ERR_OK;
16589
 
}
16590
 
 
16591
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16592
 
 
16593
 
Function:               Oct6100ApiReleaseConversionMemEntry
16594
 
 
16595
 
Description:    Releases the conversion chariot memory entry specified.
16596
 
 
16597
 
-------------------------------------------------------------------------------
16598
 
|       Argument                |       Description
16599
 
-------------------------------------------------------------------------------
16600
 
f_pApiInstance                  Pointer to API instance. This memory is used to 
16601
 
                                                keep the present state of the chip and all its 
16602
 
                                                resources.
16603
 
 
16604
 
f_usConversionMemIndex  Index reserved in the conversion chariot memory.
16605
 
 
16606
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16607
 
static UINT32 Oct6100ApiReleaseConversionMemEntry(
16608
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance,
16609
 
                                IN              UINT16                                          f_usConversionMemIndex )
16610
 
{
16611
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
16612
 
        PVOID                                           pConversionMemAlloc;
16613
 
        UINT32                                          ulResult;
16614
 
 
16615
 
        /* Get local pointer to shared portion of instance. */
16616
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
16617
 
 
16618
 
        mOCT6100_GET_CONVERSION_MEMORY_ALLOC_PNT( pSharedInfo, pConversionMemAlloc )
16619
 
        
16620
 
        ulResult = OctapiLlmAllocDealloc( pConversionMemAlloc, f_usConversionMemIndex );
16621
 
        if ( ulResult != cOCT6100_ERR_OK )
16622
 
        {
16623
 
                return cOCT6100_ERR_FATAL_B7;
16624
 
        }
16625
 
 
16626
 
        return cOCT6100_ERR_OK;
16627
 
}
16628
 
 
16629
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16630
 
 
16631
 
Function:               Oct6100ApiReadDword
16632
 
 
16633
 
Description:    Read a DWORD at specified address in external memory.
16634
 
 
16635
 
-------------------------------------------------------------------------------
16636
 
|       Argument                |       Description
16637
 
-------------------------------------------------------------------------------
16638
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
16639
 
                                                present state of the chip and all its resources.
16640
 
 
16641
 
f_ulAddress                             DWORD address where to read.
16642
 
f_pulReadData                   Resulting data.
16643
 
 
16644
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16645
 
static UINT32 Oct6100ApiReadDword( 
16646
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance,
16647
 
                                IN              UINT32                                          f_ulAddress,
16648
 
                                OUT             PUINT32                                         f_pulReadData )
16649
 
{
16650
 
        tOCT6100_READ_PARAMS    ReadParams;
16651
 
        UINT16  usReadData;
16652
 
        
16653
 
        UINT32  ulResult;
16654
 
        UINT32  ulTempData;
16655
 
 
16656
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
16657
 
 
16658
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
16659
 
        ReadParams.pusReadData = &usReadData;
16660
 
 
16661
 
        /*==================================================================================*/
16662
 
        /* Read the first 16 bits. */
16663
 
        ReadParams.ulReadAddress = f_ulAddress;
16664
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
16665
 
        if ( ulResult != cOCT6100_ERR_OK )
16666
 
                return ulResult;
16667
 
        
16668
 
        /* Save data. */
16669
 
        ulTempData = usReadData << 16;
16670
 
 
16671
 
        /* Read the last 16 bits. */
16672
 
        ReadParams.ulReadAddress += 2;
16673
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
16674
 
        if ( ulResult != cOCT6100_ERR_OK )
16675
 
                return ulResult;
16676
 
 
16677
 
        /* Save data. */
16678
 
        ulTempData |= usReadData;
16679
 
                
16680
 
        /*==================================================================================*/
16681
 
        
16682
 
        /* Return the read value.*/
16683
 
        *f_pulReadData = ulTempData;
16684
 
        
16685
 
        return cOCT6100_ERR_OK;
16686
 
}
16687
 
 
16688
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16689
 
 
16690
 
Function:               Oct6100BufferPlayoutStop
16691
 
 
16692
 
Description:    This function disables playout of a buffer on the specified 
16693
 
                                channel.
16694
 
 
16695
 
-------------------------------------------------------------------------------
16696
 
|       Argument                |       Description
16697
 
-------------------------------------------------------------------------------
16698
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
16699
 
                                                present state of the chip and all its resources.
16700
 
 
16701
 
f_pBufferPlayoutStop    Pointer to buffer playout stop structure.
16702
 
 
16703
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16704
 
static UINT32 Oct6100BufferPlayoutStopDef(
16705
 
                                tPOCT6100_BUFFER_PLAYOUT_STOP   f_pBufferPlayoutStop )
16706
 
{
16707
 
        f_pBufferPlayoutStop->ulChannelHndl = cOCT6100_INVALID_HANDLE;
16708
 
        f_pBufferPlayoutStop->ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
16709
 
        f_pBufferPlayoutStop->fStopCleanly = TRUE;
16710
 
        f_pBufferPlayoutStop->pfAlreadyStopped = NULL;
16711
 
        f_pBufferPlayoutStop->pfNotifyOnPlayoutStop = NULL;
16712
 
 
16713
 
        return cOCT6100_ERR_OK;
16714
 
}
16715
 
 
16716
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16717
 
 
16718
 
Function:               Oct6100ApiWaitForTime
16719
 
 
16720
 
Description:    Waits for the specified amount of time.
16721
 
 
16722
 
-------------------------------------------------------------------------------
16723
 
|       Argument                |       Description
16724
 
-------------------------------------------------------------------------------
16725
 
f_aulWaitTime[ 2 ]      The amout of time to be waited.
16726
 
 
16727
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16728
 
static UINT32 Oct6100ApiWaitForTime(
16729
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance,
16730
 
                                IN              UINT32                                          f_aulWaitTime[ 2 ] )
16731
 
{
16732
 
        tOCT6100_GET_TIME       StartTime;
16733
 
        tOCT6100_GET_TIME       CurrentTime;
16734
 
        UINT32                          aulTimeDelta[ 2 ];
16735
 
        UINT32                          ulResult;
16736
 
        UINT16                          usTempVar;
16737
 
        BOOL                            fConditionFlag = TRUE;
16738
 
 
16739
 
        /* Copy the process context. */
16740
 
        StartTime.pProcessContext       = f_pApiInstance->pProcessContext;
16741
 
        CurrentTime.pProcessContext     = f_pApiInstance->pProcessContext;
16742
 
 
16743
 
        ulResult = Oct6100UserGetTime( &StartTime );
16744
 
        if ( ulResult != cOCT6100_ERR_OK )
16745
 
                return ulResult;
16746
 
 
16747
 
        while ( fConditionFlag )
16748
 
        {
16749
 
                ulResult = Oct6100UserGetTime( &CurrentTime );
16750
 
                if ( ulResult != cOCT6100_ERR_OK )
16751
 
                        return ulResult;
16752
 
 
16753
 
                ulResult = octapi_lm_subtract(
16754
 
                                                                CurrentTime.aulWallTimeUs, 1,
16755
 
                                                                StartTime.aulWallTimeUs, 1,
16756
 
                                                                aulTimeDelta, 1,
16757
 
                                                                &usTempVar );
16758
 
                if ( ulResult != cOCT6100_ERR_OK )
16759
 
                        return cOCT6100_ERR_FATAL_37;
16760
 
 
16761
 
                if ( aulTimeDelta[ 1 ] >= f_aulWaitTime[ 1 ] &&
16762
 
                         aulTimeDelta[ 0 ] >= f_aulWaitTime[ 0 ] )
16763
 
                        fConditionFlag = FALSE;
16764
 
        }
16765
 
 
16766
 
        return cOCT6100_ERR_OK;
16767
 
}
16768
 
 
16769
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16770
 
 
16771
 
Function:               Oct6100ApiReserveTsiMemEntry
16772
 
 
16773
 
Description:    Reserves a TSI chariot memory entry.
16774
 
 
16775
 
-------------------------------------------------------------------------------
16776
 
|       Argument                |       Description
16777
 
-------------------------------------------------------------------------------
16778
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
16779
 
                                                the present state of the chip and all its resources.
16780
 
 
16781
 
f_pusTsiMemIndex                Resulting index reserved in the TSI chariot memory.
16782
 
 
16783
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16784
 
static UINT32 Oct6100ApiReserveTsiMemEntry(
16785
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance,
16786
 
                                OUT             PUINT16                                         f_pusTsiMemIndex )
16787
 
{
16788
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
16789
 
        PVOID   pTsiMemAlloc;
16790
 
        UINT32  ulResult;
16791
 
        UINT32  ulIndex;
16792
 
        UINT32  ulNumTsiB4Timestamp;
16793
 
 
16794
 
        /* Get local pointer to shared portion of instance. */
16795
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
16796
 
 
16797
 
        mOCT6100_GET_TSI_MEMORY_ALLOC_PNT( pSharedInfo, pTsiMemAlloc )
16798
 
        
16799
 
        ulResult = OctapiLlmAllocAlloc( pTsiMemAlloc, &ulIndex );
16800
 
        if ( ulResult != cOCT6100_ERR_OK )
16801
 
        {
16802
 
                if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
16803
 
                        return cOCT6100_ERR_MEMORY_ALL_TSI_MEM_ENTRY_RESERVED;
16804
 
                else
16805
 
                        return cOCT6100_ERR_FATAL_92;
16806
 
        }
16807
 
 
16808
 
 
16809
 
        if ( ulIndex >= cOCT6100_NUM_TSI_B4_PHASING )
16810
 
        {
16811
 
                /* Evaluate the number of TSI memory before the timestamp TSI. */
16812
 
                ulNumTsiB4Timestamp = cOCT6100_NUM_TSI_B4_PHASING + cOCT6100_MAX_TSI_B4_TIMESTAMP - pSharedInfo->ChipConfig.usMaxPhasingTssts;
16813
 
                
16814
 
                if ( ulIndex >= ulNumTsiB4Timestamp )
16815
 
                {
16816
 
                        /* + 4 for the timestamp TSI entries.*/
16817
 
                        *f_pusTsiMemIndex = (UINT16)( pSharedInfo->ChipConfig.usMaxPhasingTssts + ulIndex + cOCT6100_TSI_MEM_FOR_TIMESTAMP );
16818
 
                }
16819
 
                else /* ulIndex < ulNumTsiB4Timestamp */
16820
 
                {
16821
 
                        *f_pusTsiMemIndex = (UINT16)( pSharedInfo->ChipConfig.usMaxPhasingTssts + ulIndex );
16822
 
                }
16823
 
        }
16824
 
        else /* ulIndex < ulNumTsiB4Timestamp */
16825
 
        {
16826
 
                *f_pusTsiMemIndex = (UINT16)( ulIndex );
16827
 
        }
16828
 
 
16829
 
        return cOCT6100_ERR_OK;
16830
 
}
16831
 
 
16832
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16833
 
 
16834
 
Function:               Oct6100ApiReserveConversionMemEntry
16835
 
 
16836
 
Description:    Reserves one of the conversion memory entry 
16837
 
 
16838
 
-------------------------------------------------------------------------------
16839
 
|       Argument                |       Description
16840
 
-------------------------------------------------------------------------------
16841
 
f_pApiInstance                  Pointer to API instance. This memory is used to 
16842
 
                                                keep the present state of the chip and all its 
16843
 
                                                resources.
16844
 
 
16845
 
f_pusConversionMemIndex Resulting index reserved in the conversion memory.
16846
 
 
16847
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16848
 
static UINT32 Oct6100ApiReserveConversionMemEntry(
16849
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance,
16850
 
                                OUT             PUINT16                                         f_pusConversionMemIndex )
16851
 
{
16852
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
16853
 
        PVOID   pConversionMemAlloc;
16854
 
        UINT32  ulConversionMemIndex;
16855
 
        UINT32  ulResult;
16856
 
 
16857
 
        /* Get local pointer to shared portion of instance. */
16858
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
16859
 
 
16860
 
        mOCT6100_GET_CONVERSION_MEMORY_ALLOC_PNT( pSharedInfo, pConversionMemAlloc )
16861
 
        
16862
 
        ulResult = OctapiLlmAllocAlloc( pConversionMemAlloc, &ulConversionMemIndex );
16863
 
        if ( ulResult != cOCT6100_ERR_OK )
16864
 
        {
16865
 
                if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
16866
 
                        return cOCT6100_ERR_MEMORY_ALL_CONVERSION_MEM_ENTRY_RESERVED;
16867
 
                else
16868
 
                        return cOCT6100_ERR_FATAL_B8;
16869
 
        }
16870
 
 
16871
 
        *f_pusConversionMemIndex = (UINT16)( ulConversionMemIndex & 0xFFFF );
16872
 
 
16873
 
        return cOCT6100_ERR_OK;
16874
 
}
16875
 
 
16876
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16877
 
 
16878
 
Function:               Oct6100ConfBridgeClose
16879
 
 
16880
 
Description:    This function closes a conference bridge.  A conference
16881
 
                                bridge can only be closed if no participants are present on 
16882
 
                                the bridge.
16883
 
 
16884
 
-------------------------------------------------------------------------------
16885
 
|       Argument                |       Description
16886
 
-------------------------------------------------------------------------------
16887
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
16888
 
                                                present state of the chip and all its resources.
16889
 
 
16890
 
f_pConfBridgeClose              Pointer to conference bridge close structure.
16891
 
 
16892
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16893
 
static UINT32 Oct6100ConfBridgeCloseDef(
16894
 
                                tPOCT6100_CONF_BRIDGE_CLOSE                     f_pConfBridgeClose )
16895
 
{
16896
 
        f_pConfBridgeClose->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE;
16897
 
 
16898
 
        return cOCT6100_ERR_OK;
16899
 
}
16900
 
 
16901
 
 
16902
 
#include "apilib/octapi_largmath.h"
16903
 
 
16904
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16905
 
|       API UTILITIES
16906
 
|
16907
 
|       Function:               OctApiLmSubtract.
16908
 
|
16909
 
|       Description:    This function subtracts 2 numbers, a and b.  Number a is 
16910
 
|                                       (alen + 1) * 32 bits long; b is (blen + 1) * 32 bits long.  The result
16911
 
|                                       is (zlen + 1) * 32 bits long.  It the function succeeds it returns
16912
 
|                                       GENERIC_OK, else GENERIC_ERROR.
16913
 
|
16914
 
|  -----------------------------------------------------------------------  
16915
 
|  |   Variable        |     Type     |          Description                
16916
 
|  -----------------------------------------------------------------------  
16917
 
|       *a                                      UINT32                  The array containing the first number.
16918
 
|       alen                            USHORT                  The length of array a, minus 1 (0 - 99).
16919
 
|       *bneg                           UINT32                  The array containing the second number.
16920
 
|       blen                            USHORT                  The length of array b, minus 1 (0 - 99).
16921
 
|       *z                                      UINT32                  The array containing the resulting number.
16922
 
|       zlen                            USHORT                  The length of array z, minus 1 (0 - 99).
16923
 
|       *neg                            USHORT                  Indicates if the result is negative 
16924
 
|                                                                               (TRUE/FALSE).
16925
 
|
16926
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16927
 
static UINT32 OctApiLmSubtract(UINT32 * a,USHORT alen,UINT32 * bneg,USHORT blen,UINT32 * z,USHORT zlen,USHORT * neg)
16928
 
{
16929
 
        USHORT i;
16930
 
        UINT32 temp;
16931
 
        UINT32 carry=1;
16932
 
        UINT32 aprim;
16933
 
        UINT32 bprim;
16934
 
 
16935
 
        /* Check for array lengths.*/
16936
 
        if (alen > zlen || blen > zlen) return(OCTAPI_LM_ARRAY_SIZE_MISMATCH);
16937
 
 
16938
 
        for(i=0;i<=zlen;i++)
16939
 
        {
16940
 
                if (i <= alen) aprim = *(a+i); else aprim = 0;
16941
 
                if (i <= blen) bprim = ~(*(bneg+i)); else bprim = 0xFFFFFFFF;
16942
 
                temp = aprim + bprim + carry;
16943
 
 
16944
 
                /* Calculate carry for next time.*/
16945
 
                if (carry == 0)
16946
 
                        if (temp < aprim) carry = 1; else carry = 0;
16947
 
                else
16948
 
                        if (temp <= aprim) carry = 1; else carry = 0;
16949
 
 
16950
 
                /* Write new value.*/
16951
 
                *(z+i) = temp;
16952
 
        }
16953
 
 
16954
 
        /* Check for overflow, which means negative number!*/
16955
 
        if (carry == 0)
16956
 
        {
16957
 
                /* Number is not of right neg. Invert and add one to correct neg.*/
16958
 
                for(i=0;i<=zlen;i++)
16959
 
                        *(z+i) = ~(*(z+i));
16960
 
 
16961
 
                temp = 1;
16962
 
                OctApiLmAdd(&temp,0,z,zlen,z,zlen);
16963
 
 
16964
 
                *neg = TRUE;
16965
 
                return(GENERIC_OK);
16966
 
        }
16967
 
 
16968
 
        /* Result is positive.*/
16969
 
        *neg = FALSE;
16970
 
        return(GENERIC_OK);
16971
 
}
16972
 
 
16973
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16974
 
|       API UTILITIES
16975
 
|
16976
 
|       Function:               OctApiLmAdd.
16977
 
|
16978
 
|       Description:    This function adds 2 numbers, a and b.  Number a is 
16979
 
|                                       (alen + 1) * 32 bits long; b is (blen + 1) * 32 bits long.  The
16980
 
|                                       result is (zlen + 1) * 32 bits long.  It the function succeeds it returns
16981
 
|                                       GENERIC_OK, else GENERIC_ERROR.
16982
 
|
16983
 
|  -----------------------------------------------------------------------  
16984
 
|  |   Variable        |     Type     |          Description                
16985
 
|  -----------------------------------------------------------------------  
16986
 
|       *a                                      UINT32                  The array containing the first number.
16987
 
|       alen                            USHORT                  The length of array a, minus 1 (0 - 99).
16988
 
|       *b                                      UINT32                  The array containing the second number.
16989
 
|       blen                            USHORT                  The length of array b, minus 1 (0 - 99).
16990
 
|       *z                                      UINT32                  The array containing the resulting number.
16991
 
|       zlen                            USHORT                  The length of array z, minus 1 (0 - 99).
16992
 
|
16993
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16994
 
static UINT32 OctApiLmAdd(UINT32 * a,USHORT alen,UINT32 * b,USHORT blen,UINT32 * z, USHORT zlen)
16995
 
{
16996
 
        USHORT i;
16997
 
        UINT32 temp;
16998
 
        UINT32 carry=0;
16999
 
        UINT32 aprim;
17000
 
        UINT32 bprim;
17001
 
 
17002
 
        /* Check for array lengths.*/
17003
 
        if (alen > zlen || blen > zlen) return(OCTAPI_LM_ARRAY_SIZE_MISMATCH);
17004
 
 
17005
 
        for(i=0;i<=zlen;i++)
17006
 
        {
17007
 
                if (i <= alen) aprim = *(a+i); else aprim = 0;
17008
 
                if (i <= blen) bprim = *(b+i); else bprim = 0;
17009
 
                temp = aprim + bprim + carry;
17010
 
 
17011
 
                /* Calculate carry for next time.*/
17012
 
                if (carry == 0)
17013
 
                        if (temp < aprim) carry = 1; else carry = 0;
17014
 
                else
17015
 
                        if (temp <= aprim) carry = 1; else carry = 0;
17016
 
 
17017
 
                /* Write new value.*/
17018
 
                *(z+i) = temp;
17019
 
        }
17020
 
 
17021
 
        /* Check for overflow.*/
17022
 
        if (carry == 1) return(OCTAPI_LM_OVERFLOW);
17023
 
 
17024
 
        /* All is well.*/
17025
 
        return(GENERIC_OK);
17026
 
}
17027
 
 
17028
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17029
 
 
17030
 
File: oct6100_chip_stats.c
17031
 
 
17032
 
    Copyright (c) 2001-2005 Octasic Inc.
17033
 
    
17034
 
Description: 
17035
 
 
17036
 
        This file contains functions used to retreive the OCT6100 chip stats.
17037
 
 
17038
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
17039
 
free software; you can redistribute it and/or modify it under the terms of 
17040
 
the GNU General Public License as published by the Free Software Foundation; 
17041
 
either version 2 of the License, or (at your option) any later version.
17042
 
 
17043
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
17044
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
17045
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
17046
 
for more details. 
17047
 
 
17048
 
You should have received a copy of the GNU General Public License 
17049
 
along with the OCT6100 GPL API; if not, write to the Free Software 
17050
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17051
 
 
17052
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
17053
 
 
17054
 
$Octasic_Revision: 85 $
17055
 
 
17056
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17057
 
 
17058
 
 
17059
 
/*****************************  INCLUDE FILES  *******************************/
17060
 
 
17061
 
 
17062
 
#include "octdef.h"
17063
 
 
17064
 
#include "oct6100api/oct6100_defines.h"
17065
 
#include "oct6100api/oct6100_errors.h"
17066
 
#include "oct6100api/oct6100_apiud.h"
17067
 
 
17068
 
#include "apilib/octapi_llman.h"
17069
 
 
17070
 
#include "oct6100api/oct6100_tlv_inst.h"
17071
 
#include "oct6100api/oct6100_chip_open_inst.h"
17072
 
#include "oct6100api/oct6100_chip_stats_inst.h"
17073
 
#include "oct6100api/oct6100_interrupts_inst.h"
17074
 
#include "oct6100api/oct6100_remote_debug_inst.h"
17075
 
#include "oct6100api/oct6100_debug_inst.h"
17076
 
#include "oct6100api/oct6100_api_inst.h"
17077
 
 
17078
 
#include "oct6100api/oct6100_interrupts_pub.h"
17079
 
#include "oct6100api/oct6100_chip_open_pub.h"
17080
 
#include "oct6100api/oct6100_channel_pub.h"
17081
 
#include "oct6100api/oct6100_chip_stats_pub.h"
17082
 
 
17083
 
#include "oct6100_chip_open_priv.h"
17084
 
#include "oct6100_chip_stats_priv.h"
17085
 
#include "oct6100_miscellaneous_priv.h"
17086
 
#include "oct6100_chip_stats_priv.h"
17087
 
 
17088
 
/****************************  PUBLIC FUNCTIONS  *****************************/
17089
 
 
17090
 
 
17091
 
/****************************  PRIVATE FUNCTIONS  ****************************/
17092
 
 
17093
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17094
 
 
17095
 
Function:               Oct6100ApiChipStatsSwInit
17096
 
 
17097
 
Description:    Initializes portions of API instance associated to chip stats.
17098
 
 
17099
 
-------------------------------------------------------------------------------
17100
 
|       Argument                |       Description
17101
 
-------------------------------------------------------------------------------
17102
 
f_pApiInstance          Pointer to API instance. This memory is used to keep
17103
 
                                        the present state of the chip and all its resources.
17104
 
 
17105
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17106
 
static UINT32 Oct6100ApiChipStatsSwInit(
17107
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance )
17108
 
{
17109
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
17110
 
 
17111
 
        /* Get local pointer to shared portion of API instance. */
17112
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
17113
 
 
17114
 
        /* Initialize chip stats. */
17115
 
        pSharedInfo->ErrorStats.fFatalChipError = FALSE;
17116
 
 
17117
 
        pSharedInfo->ErrorStats.ulH100ClkABadCnt = 0;
17118
 
        pSharedInfo->ErrorStats.ulH100ClkBBadCnt = 0;
17119
 
        pSharedInfo->ErrorStats.ulH100FrameABadCnt = 0;
17120
 
        pSharedInfo->ErrorStats.ulH100OutOfSyncCnt = 0;
17121
 
 
17122
 
        pSharedInfo->ErrorStats.ulInternalReadTimeoutCnt = 0;
17123
 
        pSharedInfo->ErrorStats.ulSdramRefreshTooLateCnt = 0;
17124
 
        pSharedInfo->ErrorStats.ulPllJitterErrorCnt     = 0;
17125
 
        pSharedInfo->ErrorStats.ulOverflowToneEventsCnt = 0;
17126
 
 
17127
 
 
17128
 
        
17129
 
        pSharedInfo->ErrorStats.ulToneDetectorErrorCnt = 0;
17130
 
 
17131
 
        /* Init the chip stats. */
17132
 
        pSharedInfo->ChipStats.usNumberChannels = 0;
17133
 
        pSharedInfo->ChipStats.usNumberBiDirChannels = 0;
17134
 
        pSharedInfo->ChipStats.usNumberTsiCncts = 0;
17135
 
        pSharedInfo->ChipStats.usNumberConfBridges = 0;
17136
 
        pSharedInfo->ChipStats.usNumberPlayoutBuffers = 0;
17137
 
        pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts = 0;
17138
 
        pSharedInfo->ChipStats.ulPlayoutMemUsed = 0;
17139
 
        pSharedInfo->ChipStats.usNumEcChanUsingMixer = 0;
17140
 
 
17141
 
        pSharedInfo->ChipStats.usNumberPhasingTssts = 0;
17142
 
        pSharedInfo->ChipStats.usNumberAdpcmChans       = 0;
17143
 
 
17144
 
        return cOCT6100_ERR_OK;
17145
 
}
17146
 
 
17147
 
 
17148
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17149
 
 
17150
 
File: oct6100_conf_bridge.c
17151
 
 
17152
 
    Copyright (c) 2001-2005 Octasic Inc.
17153
 
    
17154
 
Description: 
17155
 
 
17156
 
        This file contains all functions related to a conference bridge.  Procedures
17157
 
        needed to open/close a bridge, add/remove a participant to a conference 
17158
 
        bridge, mute/unmute a participant, etc..  are all present in this source 
17159
 
        file.
17160
 
 
17161
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
17162
 
free software; you can redistribute it and/or modify it under the terms of 
17163
 
the GNU General Public License as published by the Free Software Foundation; 
17164
 
either version 2 of the License, or (at your option) any later version.
17165
 
 
17166
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
17167
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
17168
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
17169
 
for more details. 
17170
 
 
17171
 
You should have received a copy of the GNU General Public License 
17172
 
along with the OCT6100 GPL API; if not, write to the Free Software 
17173
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17174
 
 
17175
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
17176
 
 
17177
 
$Octasic_Revision: 145 $
17178
 
 
17179
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17180
 
 
17181
 
 
17182
 
/*****************************  INCLUDE FILES  *******************************/
17183
 
 
17184
 
#include "octdef.h"
17185
 
 
17186
 
#include "oct6100api/oct6100_defines.h"
17187
 
#include "oct6100api/oct6100_errors.h"
17188
 
#include "oct6100api/oct6100_apiud.h"
17189
 
 
17190
 
#include "apilib/octapi_llman.h"
17191
 
 
17192
 
#include "oct6100api/oct6100_tlv_inst.h"
17193
 
#include "oct6100api/oct6100_chip_open_inst.h"
17194
 
#include "oct6100api/oct6100_chip_stats_inst.h"
17195
 
#include "oct6100api/oct6100_interrupts_inst.h"
17196
 
#include "oct6100api/oct6100_remote_debug_inst.h"
17197
 
#include "oct6100api/oct6100_debug_inst.h"
17198
 
#include "oct6100api/oct6100_api_inst.h"
17199
 
#include "oct6100api/oct6100_channel_inst.h"
17200
 
#include "oct6100api/oct6100_mixer_inst.h"
17201
 
#include "oct6100api/oct6100_conf_bridge_inst.h"
17202
 
 
17203
 
#include "oct6100api/oct6100_interrupts_pub.h"
17204
 
#include "oct6100api/oct6100_chip_open_pub.h"
17205
 
#include "oct6100api/oct6100_channel_pub.h"
17206
 
#include "oct6100api/oct6100_mixer_pub.h"
17207
 
#include "oct6100api/oct6100_conf_bridge_pub.h"
17208
 
 
17209
 
#include "oct6100_chip_open_priv.h"
17210
 
#include "oct6100_miscellaneous_priv.h"
17211
 
#include "oct6100_memory_priv.h"
17212
 
#include "oct6100_tsst_priv.h"
17213
 
#include "oct6100_channel_priv.h"
17214
 
#include "oct6100_mixer_priv.h"
17215
 
#include "oct6100_conf_bridge_priv.h"
17216
 
 
17217
 
 
17218
 
/****************************  PUBLIC FUNCTIONS  *****************************/
17219
 
 
17220
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17221
 
 
17222
 
Function:               Oct6100ConfBridgeChanRemove
17223
 
 
17224
 
Description:    This function removes an echo channel (participant) from a 
17225
 
                                conference bridge.  All participants can be removed from
17226
 
                                the bridge if a special flag (fRemoveAll) is set to TRUE.
17227
 
 
17228
 
-------------------------------------------------------------------------------
17229
 
|       Argument                |       Description
17230
 
-------------------------------------------------------------------------------
17231
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
17232
 
                                                present state of the chip and all its resources.
17233
 
 
17234
 
f_pConfBridgeRemove             Pointer to conference bridge channel removal structure.
17235
 
 
17236
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17237
 
static UINT32 Oct6100ConfBridgeChanRemoveDef(
17238
 
                                tPOCT6100_CONF_BRIDGE_CHAN_REMOVE       f_pConfBridgeRemove )
17239
 
{
17240
 
        f_pConfBridgeRemove->ulChannelHndl = cOCT6100_INVALID_HANDLE;
17241
 
        f_pConfBridgeRemove->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE;
17242
 
        f_pConfBridgeRemove->fRemoveAll = FALSE;
17243
 
 
17244
 
        return cOCT6100_ERR_OK;
17245
 
}
17246
 
 
17247
 
 
17248
 
 
17249
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17250
 
 
17251
 
Function:               Oct6100ApiGetConfBridgeSwSizes
17252
 
 
17253
 
Description:    Gets the sizes of all portions of the API instance pertinent
17254
 
                                to the management of conference bridges.
17255
 
 
17256
 
-------------------------------------------------------------------------------
17257
 
|       Argument                |       Description
17258
 
-------------------------------------------------------------------------------
17259
 
f_pOpenChip                             Pointer to chip configuration struct.
17260
 
f_pInstSizes                    Pointer to struct containing instance sizes.
17261
 
 
17262
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17263
 
static UINT32 Oct6100ApiGetConfBridgeSwSizes(
17264
 
                                IN              tPOCT6100_CHIP_OPEN                             f_pOpenChip,
17265
 
                                OUT             tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
17266
 
{
17267
 
        UINT32  ulTempVar;
17268
 
        UINT32  ulResult;
17269
 
 
17270
 
        /* Calculate memory needed for conference bridge list. */
17271
 
        if ( f_pOpenChip->ulMaxConfBridges == 0 && f_pOpenChip->fEnableChannelRecording == TRUE )
17272
 
                f_pOpenChip->ulMaxConfBridges = 1;
17273
 
        f_pInstSizes->ulConfBridgeList = f_pOpenChip->ulMaxConfBridges * sizeof( tOCT6100_API_CONF_BRIDGE );
17274
 
        
17275
 
        /* Calculate memory needed for conference bridge allocation software. */
17276
 
        if ( f_pOpenChip->ulMaxConfBridges > 0 )
17277
 
        {
17278
 
                /* Get size of bridge allocation memory */
17279
 
                ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxConfBridges, &f_pInstSizes->ulConfBridgeAlloc );
17280
 
                if ( ulResult != cOCT6100_ERR_OK )
17281
 
                        return cOCT6100_ERR_FATAL_1C;
17282
 
 
17283
 
                /* Check if the user wants to build flexible conference bridges. */
17284
 
                if ( f_pOpenChip->ulMaxFlexibleConfParticipants > 0 )
17285
 
                {
17286
 
                        /* Allocate the lowest quantity according to what the user requested. */
17287
 
                        if ( f_pOpenChip->ulMaxFlexibleConfParticipants < ( f_pOpenChip->ulMaxConfBridges * cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE ) )
17288
 
                                f_pInstSizes->ulFlexConfParticipantsList = f_pOpenChip->ulMaxFlexibleConfParticipants * sizeof( tOCT6100_API_FLEX_CONF_PARTICIPANT );
17289
 
                        else
17290
 
                        {
17291
 
                                f_pOpenChip->ulMaxFlexibleConfParticipants = f_pOpenChip->ulMaxConfBridges * cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE;
17292
 
                                f_pInstSizes->ulFlexConfParticipantsList = f_pOpenChip->ulMaxConfBridges * cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE * sizeof( tOCT6100_API_FLEX_CONF_PARTICIPANT );
17293
 
                        }
17294
 
 
17295
 
                        /* Get size of flexible conferencing participants allocation memory */
17296
 
                        ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxFlexibleConfParticipants, &f_pInstSizes->ulFlexConfParticipantsAlloc );
17297
 
                        if ( ulResult != cOCT6100_ERR_OK )
17298
 
                                return cOCT6100_ERR_FATAL_1C;
17299
 
                }
17300
 
                else
17301
 
                {
17302
 
                        f_pInstSizes->ulFlexConfParticipantsList  = 0;
17303
 
                        f_pInstSizes->ulFlexConfParticipantsAlloc  = 0;
17304
 
                }
17305
 
        }
17306
 
        else
17307
 
        {
17308
 
                f_pInstSizes->ulMixerEventList = 0;             
17309
 
                f_pInstSizes->ulMixerEventAlloc  = 0;
17310
 
                f_pInstSizes->ulConfBridgeAlloc  = 0;
17311
 
 
17312
 
                /* Make sure flexible conferencing is not used. */
17313
 
                f_pInstSizes->ulFlexConfParticipantsList  = 0;
17314
 
                f_pInstSizes->ulFlexConfParticipantsAlloc  = 0;
17315
 
        }
17316
 
 
17317
 
        /* Calculate memory needed for list and allocation software serialization. */
17318
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulConfBridgeList, ulTempVar )
17319
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulConfBridgeAlloc, ulTempVar )
17320
 
 
17321
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulFlexConfParticipantsList, ulTempVar )
17322
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulFlexConfParticipantsAlloc, ulTempVar )
17323
 
 
17324
 
        return cOCT6100_ERR_OK;
17325
 
}
17326
 
 
17327
 
 
17328
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17329
 
 
17330
 
Function:               Oct6100ApiConfBridgeSwInit
17331
 
 
17332
 
Description:    Initializes all elements of the instance structure associated
17333
 
                                to conference bridges.
17334
 
 
17335
 
-------------------------------------------------------------------------------
17336
 
|       Argument                |       Description
17337
 
-------------------------------------------------------------------------------
17338
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
17339
 
                                                the present state of the chip and all its resources.
17340
 
 
17341
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17342
 
static UINT32 Oct6100ApiConfBridgeSwInit(
17343
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance )
17344
 
{
17345
 
        tPOCT6100_SHARED_INFO                           pSharedInfo;
17346
 
        tPOCT6100_API_CONF_BRIDGE                       pConfBridgeList;
17347
 
        tPOCT6100_API_FLEX_CONF_PARTICIPANT     pFlexConfParticipantList;
17348
 
        PVOID   pFlexConfPartipantsAlloc;
17349
 
        UINT32  ulMaxFlexConfParicipants;
17350
 
        PVOID   pConfBridgeAlloc;
17351
 
        UINT32  ulMaxConfBridges;
17352
 
        UINT32  ulResult;
17353
 
 
17354
 
        /* Get local pointer to shared portion of instance. */
17355
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
17356
 
 
17357
 
        /* Get the maximum number of conference bridges. */
17358
 
        ulMaxConfBridges = pSharedInfo->ChipConfig.usMaxConfBridges;
17359
 
        
17360
 
        /*===================================================================*/
17361
 
        /* Set all entries in the conference bridge list to unused. */
17362
 
 
17363
 
        mOCT6100_GET_CONF_BRIDGE_LIST_PNT( pSharedInfo, pConfBridgeList );
17364
 
 
17365
 
        /* Initialize the conference bridge allocation software to "all free". */
17366
 
        if ( ulMaxConfBridges > 0 )
17367
 
        {
17368
 
                /* Clear the bridge memory */   
17369
 
                Oct6100UserMemSet( pConfBridgeList, 0x00, ulMaxConfBridges * sizeof( tOCT6100_API_CONF_BRIDGE ));
17370
 
 
17371
 
                mOCT6100_GET_CONF_BRIDGE_ALLOC_PNT( pSharedInfo, pConfBridgeAlloc )
17372
 
                
17373
 
                ulResult = OctapiLlmAllocInit( &pConfBridgeAlloc, ulMaxConfBridges );
17374
 
                if ( ulResult != cOCT6100_ERR_OK )
17375
 
                        return cOCT6100_ERR_FATAL_1E;
17376
 
        }
17377
 
        /*===================================================================*/
17378
 
 
17379
 
 
17380
 
        /*===================================================================*/
17381
 
        /* Set all entries in the flexible conferencing participant list to unused. */
17382
 
 
17383
 
        /* Get the maximum number of flexible conferencing participants. */
17384
 
        ulMaxFlexConfParicipants = pSharedInfo->ChipConfig.usMaxFlexibleConfParticipants;
17385
 
 
17386
 
        mOCT6100_GET_FLEX_CONF_PARTICIPANT_LIST_PNT( pSharedInfo, pFlexConfParticipantList );
17387
 
 
17388
 
        /* Initialize the flexible conferencing allocation software. */
17389
 
        if ( ulMaxFlexConfParicipants > 0 )
17390
 
        {
17391
 
                UINT32 i, ulEventIndex;
17392
 
                
17393
 
                /* Clear the participants memory */     
17394
 
                Oct6100UserMemSet( pFlexConfParticipantList, 0x00, ulMaxFlexConfParicipants * sizeof( tOCT6100_API_FLEX_CONF_PARTICIPANT ));
17395
 
 
17396
 
                mOCT6100_GET_FLEX_CONF_PARTICIPANT_ALLOC_PNT( pSharedInfo, pFlexConfPartipantsAlloc )
17397
 
                
17398
 
                ulResult = OctapiLlmAllocInit( &pFlexConfPartipantsAlloc, ulMaxFlexConfParicipants );
17399
 
                if ( ulResult != cOCT6100_ERR_OK )
17400
 
                        return cOCT6100_ERR_FATAL_1E;
17401
 
 
17402
 
                /* Initialize the conferencing indexes. */
17403
 
                for ( i = 0; i < ulMaxFlexConfParicipants; i ++ )
17404
 
                {
17405
 
                        for ( ulEventIndex = 0; ulEventIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulEventIndex ++ )
17406
 
                                pFlexConfParticipantList[ i ].ausLoadOrAccumulateEventIndex[ ulEventIndex ] = cOCT6100_INVALID_INDEX;
17407
 
                }
17408
 
        }
17409
 
        
17410
 
        /*===================================================================*/
17411
 
        
17412
 
        return cOCT6100_ERR_OK;
17413
 
}
17414
 
 
17415
 
 
17416
 
 
17417
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17418
 
 
17419
 
Function:               Oct6100ConfBridgeCloseSer
17420
 
 
17421
 
Description:    Closes a conference bridge. Note that no client must be present
17422
 
                                on the bridge for the bridge to be closed.
17423
 
 
17424
 
-------------------------------------------------------------------------------
17425
 
|       Argument                |       Description
17426
 
-------------------------------------------------------------------------------
17427
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
17428
 
                                                present state of the chip and all its resources.
17429
 
 
17430
 
f_pConfBridgeClose              Pointer to conference bridge close structure.
17431
 
 
17432
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17433
 
static UINT32 Oct6100ConfBridgeCloseSer(
17434
 
                                IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
17435
 
                                IN              tPOCT6100_CONF_BRIDGE_CLOSE                     f_pConfBridgeClose )
17436
 
{
17437
 
        UINT16  usBridgeIndex;
17438
 
        UINT32  ulResult;
17439
 
 
17440
 
        /* Verify that all the parameters given match the state of the API. */
17441
 
        ulResult = Oct6100ApiAssertBridgeParams( f_pApiInstance, f_pConfBridgeClose, &usBridgeIndex );
17442
 
        if ( ulResult != cOCT6100_ERR_OK  )
17443
 
                return ulResult;
17444
 
 
17445
 
        /* Release all resources associated to the conference bridge. */
17446
 
        ulResult = Oct6100ApiReleaseBridgeResources( f_pApiInstance, usBridgeIndex );
17447
 
        if ( ulResult != cOCT6100_ERR_OK  )
17448
 
                return ulResult;
17449
 
 
17450
 
        /* Invalidate the handle. */
17451
 
        f_pConfBridgeClose->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE;
17452
 
 
17453
 
        return cOCT6100_ERR_OK;
17454
 
}
17455
 
 
17456
 
 
17457
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17458
 
 
17459
 
Function:               Oct6100ApiAssertBridgeParams
17460
 
 
17461
 
Description:    Checks the user's conference bridge close configuration for errors.
17462
 
 
17463
 
-------------------------------------------------------------------------------
17464
 
|       Argument                |       Description
17465
 
-------------------------------------------------------------------------------
17466
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
17467
 
                                                present state of the chip and all its resources.
17468
 
 
17469
 
f_pConfBridgeClose              Pointer to conference bridge close structure.
17470
 
f_pusBridgeIndex                Pointer to API instance conference bridge index.
17471
 
 
17472
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17473
 
static UINT32 Oct6100ApiAssertBridgeParams(
17474
 
                                IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
17475
 
                                IN              tPOCT6100_CONF_BRIDGE_CLOSE                     f_pConfBridgeClose,
17476
 
                                OUT             PUINT16                                                         f_pusBridgeIndex )
17477
 
{
17478
 
        tPOCT6100_API_CONF_BRIDGE       pBridgeEntry;
17479
 
        UINT32                                          ulEntryOpenCnt;
17480
 
 
17481
 
        /* Check the provided handle. */
17482
 
        if ( (f_pConfBridgeClose->ulConfBridgeHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CONF_BRIDGE )
17483
 
                return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
17484
 
 
17485
 
        *f_pusBridgeIndex = (UINT16)( f_pConfBridgeClose->ulConfBridgeHndl & cOCT6100_HNDL_INDEX_MASK );
17486
 
        if ( *f_pusBridgeIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges )
17487
 
                return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
17488
 
 
17489
 
        mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, *f_pusBridgeIndex )
17490
 
 
17491
 
        /* Extract the entry open count from the provided handle. */
17492
 
        ulEntryOpenCnt = (f_pConfBridgeClose->ulConfBridgeHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
17493
 
 
17494
 
        /* Check for errors. */
17495
 
        if ( pBridgeEntry->fReserved != TRUE )
17496
 
                return cOCT6100_ERR_CONF_BRIDGE_NOT_OPEN;
17497
 
        if ( pBridgeEntry->usNumClients != 0 )
17498
 
                return cOCT6100_ERR_CONF_BRIDGE_ACTIVE_DEPENDENCIES;
17499
 
        if ( ulEntryOpenCnt != pBridgeEntry->byEntryOpenCnt )
17500
 
                return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
17501
 
 
17502
 
        return cOCT6100_ERR_OK;
17503
 
}
17504
 
 
17505
 
 
17506
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17507
 
 
17508
 
Function:               Oct6100ApiReleaseBridgeResources
17509
 
 
17510
 
Description:    Release all resources reserved for the conference bridge.
17511
 
 
17512
 
-------------------------------------------------------------------------------
17513
 
|       Argument                |       Description
17514
 
-------------------------------------------------------------------------------
17515
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
17516
 
                                                present state of the chip and all its resources.
17517
 
 
17518
 
f_usBridgeIndex                 Allocated external memory block for the conference bridge.
17519
 
 
17520
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17521
 
static UINT32 Oct6100ApiReleaseBridgeResources(
17522
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
17523
 
                                IN              UINT16                                                  f_usBridgeIndex )
17524
 
{
17525
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
17526
 
        tPOCT6100_API_CONF_BRIDGE       pBridgeEntry;
17527
 
        tPOCT6100_API_CONF_BRIDGE       pTempBridgeEntry;
17528
 
        UINT32  ulResult;
17529
 
 
17530
 
        /* Obtain local pointer to shared portion of instance. */
17531
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
17532
 
 
17533
 
        /* Release the entry from the conference bridge list. */
17534
 
        ulResult = Oct6100ApiReleaseBridgeEntry( f_pApiInstance, f_usBridgeIndex );
17535
 
        if ( ulResult != cOCT6100_ERR_OK )
17536
 
                return cOCT6100_ERR_FATAL_24;
17537
 
 
17538
 
        mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, f_usBridgeIndex );
17539
 
 
17540
 
        /* Remove the bridge entry from the bridge list. */
17541
 
        if ( pSharedInfo->MiscVars.usNumBridgesOpened == 1 )
17542
 
        {
17543
 
                /* This bridge was the only one opened. */
17544
 
                pSharedInfo->MiscVars.usFirstBridge = cOCT6100_INVALID_INDEX;
17545
 
        }
17546
 
        else if ( pSharedInfo->MiscVars.usNumBridgesOpened > 1 )
17547
 
        {
17548
 
                /* There are more then one bridge open, must update the list. */
17549
 
                if ( pBridgeEntry->usPrevBridgePtr != cOCT6100_INVALID_INDEX )
17550
 
                {
17551
 
                        /* There is a valid entry before this bridge, let's update this entry. */
17552
 
                        mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempBridgeEntry, pBridgeEntry->usPrevBridgePtr );
17553
 
                        
17554
 
                        pTempBridgeEntry->usNextBridgePtr = pBridgeEntry->usNextBridgePtr;
17555
 
                }
17556
 
 
17557
 
                if ( pBridgeEntry->usNextBridgePtr != cOCT6100_INVALID_INDEX )
17558
 
                {
17559
 
                        /* There is a valid entry after this bridge, let's update this entry. */
17560
 
                        mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempBridgeEntry, pBridgeEntry->usNextBridgePtr );
17561
 
 
17562
 
                        pTempBridgeEntry->usPrevBridgePtr = pBridgeEntry->usPrevBridgePtr;
17563
 
                }
17564
 
 
17565
 
                if ( pSharedInfo->MiscVars.usFirstBridge == f_usBridgeIndex )
17566
 
                {
17567
 
                        /* This entry was the first of the list, make the next one be the first now. */
17568
 
                        pSharedInfo->MiscVars.usFirstBridge = pBridgeEntry->usNextBridgePtr;
17569
 
                }
17570
 
        }
17571
 
        else
17572
 
        {
17573
 
                /* Variable has become out of sync. */
17574
 
                return cOCT6100_ERR_FATAL_25;
17575
 
        }
17576
 
 
17577
 
        /*=============================================================*/
17578
 
        /* Update the conference bridge's list entry. */
17579
 
 
17580
 
        /* Mark the bridge as closed. */
17581
 
        pBridgeEntry->fFlexibleConferencing = FALSE;
17582
 
        pBridgeEntry->fReserved = FALSE;
17583
 
        pBridgeEntry->byEntryOpenCnt++;
17584
 
 
17585
 
        /* Decrement the number of conference bridges opened. */
17586
 
        pSharedInfo->MiscVars.usNumBridgesOpened--;
17587
 
        pSharedInfo->ChipStats.usNumberConfBridges--;
17588
 
 
17589
 
        /*=============================================================*/
17590
 
 
17591
 
        return cOCT6100_ERR_OK;
17592
 
}
17593
 
 
17594
 
 
17595
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17596
 
 
17597
 
Function:               Oct6100ConfBridgeChanRemoveSer
17598
 
 
17599
 
Description:    Removes an echo channel from a conference bridge. 
17600
 
 
17601
 
-------------------------------------------------------------------------------
17602
 
|       Argument                |       Description
17603
 
-------------------------------------------------------------------------------
17604
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
17605
 
                                                present state of the chip and all its resources.
17606
 
 
17607
 
f_pConfBridgeRemove             Pointer to conference bridge channel remove structure.  
17608
 
 
17609
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17610
 
static UINT32 Oct6100ConfBridgeChanRemoveSer(
17611
 
                                IN OUT  tPOCT6100_INSTANCE_API                                  f_pApiInstance,
17612
 
                                IN              tPOCT6100_CONF_BRIDGE_CHAN_REMOVE               f_pConfBridgeRemove )
17613
 
{
17614
 
        UINT16  usBridgeIndex;
17615
 
        UINT16  usChanIndex=0;
17616
 
        UINT16  usLoadEventIndex;
17617
 
        UINT16  usSubStoreEventIndex;
17618
 
        UINT16  usCopyEventIndex;
17619
 
        UINT32  ulResult;
17620
 
        UINT8   fFlexibleConfBridge;
17621
 
        UINT8   fTap;
17622
 
 
17623
 
        /* Check the validity of the channel and conference bridge given. */
17624
 
        ulResult = Oct6100ApiCheckChanRemoveParams(
17625
 
                                                                                f_pApiInstance, 
17626
 
                                                                                f_pConfBridgeRemove, 
17627
 
                                                                                &usBridgeIndex, 
17628
 
                                                                                &usChanIndex, 
17629
 
                                                                                &fFlexibleConfBridge, 
17630
 
                                                                                &fTap,
17631
 
                                                                                &usLoadEventIndex, 
17632
 
                                                                                &usSubStoreEventIndex, 
17633
 
                                                                                &usCopyEventIndex );
17634
 
        if ( ulResult != cOCT6100_ERR_OK )
17635
 
                return ulResult;
17636
 
 
17637
 
        /* Release all resources reserved for the conference bridge. */
17638
 
        ulResult = Oct6100ApiReleaseChanEventResources( 
17639
 
                                                                                f_pApiInstance, 
17640
 
                                                                                f_pConfBridgeRemove, 
17641
 
                                                                                usBridgeIndex, 
17642
 
                                                                                usChanIndex, 
17643
 
                                                                                fFlexibleConfBridge, 
17644
 
                                                                                usLoadEventIndex, 
17645
 
                                                                                usSubStoreEventIndex, 
17646
 
                                                                                usCopyEventIndex );
17647
 
        if ( ulResult != cOCT6100_ERR_OK )
17648
 
                return ulResult;
17649
 
 
17650
 
        /* Clear the memory entry for this channel within the bridge. */
17651
 
        ulResult = Oct6100ApiBridgeEventRemove( 
17652
 
                                                                                f_pApiInstance, 
17653
 
                                                                                f_pConfBridgeRemove, 
17654
 
                                                                                usBridgeIndex, 
17655
 
                                                                                usChanIndex, 
17656
 
                                                                                fFlexibleConfBridge, 
17657
 
                                                                                usLoadEventIndex, 
17658
 
                                                                                usSubStoreEventIndex, 
17659
 
                                                                                usCopyEventIndex,
17660
 
                                                                                fTap );
17661
 
        if ( ulResult != cOCT6100_ERR_OK )
17662
 
                return ulResult;
17663
 
 
17664
 
        return cOCT6100_ERR_OK;
17665
 
}
17666
 
 
17667
 
 
17668
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17669
 
 
17670
 
Function:               Oct6100ApiCheckChanRemoveParams
17671
 
 
17672
 
Description:    Check the validity of the channel and conference bridge given.
17673
 
 
17674
 
-------------------------------------------------------------------------------
17675
 
|       Argument                |       Description
17676
 
-------------------------------------------------------------------------------
17677
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
17678
 
                                                        present state of the chip and all its resources.
17679
 
f_pConfBridgeRemove                     Pointer to conference bridge channenl add structure.  
17680
 
f_pusBridgeIndex                        Pointer to the bridge index.
17681
 
f_pfFlexibleConfBridge          If this is a flexible conference bridge
17682
 
f_pusChannelIndex                       Pointer to the channel index to be added to the bridge.
17683
 
f_pusLoadEventIndex                     Pointer to the load mixer event.
17684
 
f_pusSubStoreEventIndex         Pointer to the sub-store mixer event.
17685
 
f_pusCopyEventIndex                     Pointer to the copy mixer event.
17686
 
 
17687
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17688
 
static UINT32 Oct6100ApiCheckChanRemoveParams(
17689
 
                                IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
17690
 
                                IN              tPOCT6100_CONF_BRIDGE_CHAN_REMOVE       f_pConfBridgeRemove,
17691
 
                                OUT             PUINT16                                                         f_pusBridgeIndex, 
17692
 
                                OUT             PUINT16                                                         f_pusChannelIndex,
17693
 
                                OUT             PUINT8                                                          f_pfFlexibleConfBridge,
17694
 
                                OUT             PUINT8                                                          f_pfTap,
17695
 
                                OUT             PUINT16                                                         f_pusLoadEventIndex,
17696
 
                                OUT             PUINT16                                                         f_pusSubStoreEventIndex,
17697
 
                                OUT             PUINT16                                                         f_pusCopyEventIndex )
17698
 
{
17699
 
        UINT32                                          ulEntryOpenCnt;
17700
 
        tPOCT6100_API_CHANNEL           pEchoChanEntry;
17701
 
        tPOCT6100_API_CONF_BRIDGE       pBridgeEntry;
17702
 
 
17703
 
        /* Verify if the remove all flag is valid. */
17704
 
        if ( f_pConfBridgeRemove->fRemoveAll != TRUE && 
17705
 
                 f_pConfBridgeRemove->fRemoveAll != FALSE )
17706
 
                return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_REMOVE_ALL;
17707
 
 
17708
 
        /* Check the channel handle only if the remove all flag is set to FALSE. */
17709
 
        if ( f_pConfBridgeRemove->fRemoveAll == FALSE )
17710
 
        {
17711
 
                /*=====================================================================*/
17712
 
                /* Check the channel handle. */
17713
 
 
17714
 
                if ( (f_pConfBridgeRemove->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
17715
 
                        return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
17716
 
 
17717
 
                *f_pusChannelIndex = (UINT16)( f_pConfBridgeRemove->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK );
17718
 
                if ( *f_pusChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
17719
 
                        return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
17720
 
 
17721
 
                mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChanEntry, *f_pusChannelIndex )
17722
 
 
17723
 
                /* Extract the entry open count from the provided handle. */
17724
 
                ulEntryOpenCnt = (f_pConfBridgeRemove->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
17725
 
 
17726
 
                /* Check for errors. */
17727
 
                if ( pEchoChanEntry->fReserved != TRUE )
17728
 
                        return cOCT6100_ERR_CONF_BRIDGE_NOT_OPEN;
17729
 
                if ( ulEntryOpenCnt != pEchoChanEntry->byEntryOpenCnt )
17730
 
                        return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
17731
 
                if ( pEchoChanEntry->fBeingTapped == TRUE )
17732
 
                        return cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_DEPENDENCY;
17733
 
 
17734
 
                /*=====================================================================*/
17735
 
 
17736
 
                *f_pusBridgeIndex = pEchoChanEntry->usBridgeIndex;
17737
 
                *f_pusLoadEventIndex = pEchoChanEntry->usLoadEventIndex;
17738
 
                *f_pusSubStoreEventIndex = pEchoChanEntry->usSubStoreEventIndex;
17739
 
                *f_pusCopyEventIndex = pEchoChanEntry->usSinCopyEventIndex;
17740
 
 
17741
 
                /* Check if the channel is really part of the bridge. */
17742
 
                if ( *f_pusBridgeIndex == cOCT6100_INVALID_INDEX )
17743
 
                        return cOCT6100_ERR_CONF_BRIDGE_CHAN_NOT_ON_BRIDGE;
17744
 
 
17745
 
                mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, *f_pusBridgeIndex )
17746
 
 
17747
 
                /* Return whether this is a flexible bridge or not. */
17748
 
                *f_pfFlexibleConfBridge = pBridgeEntry->fFlexibleConferencing;
17749
 
 
17750
 
                /* Return whether this is a tap or not. */
17751
 
                *f_pfTap = pEchoChanEntry->fTap;
17752
 
        }
17753
 
        else /* f_pConfBridgeRemove->fRemoveAll == TRUE */
17754
 
        {
17755
 
                /* Check the provided handle. */
17756
 
                if ( (f_pConfBridgeRemove->ulConfBridgeHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CONF_BRIDGE )
17757
 
                        return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
17758
 
 
17759
 
                *f_pusBridgeIndex = (UINT16)( f_pConfBridgeRemove->ulConfBridgeHndl & cOCT6100_HNDL_INDEX_MASK );
17760
 
                if ( *f_pusBridgeIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxConfBridges )
17761
 
                        return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
17762
 
 
17763
 
                mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, *f_pusBridgeIndex )
17764
 
 
17765
 
                /* Extract the entry open count from the provided handle. */
17766
 
                ulEntryOpenCnt = (f_pConfBridgeRemove->ulConfBridgeHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
17767
 
 
17768
 
                /* Check for errors. */
17769
 
                if ( pBridgeEntry->fReserved != TRUE )
17770
 
                        return cOCT6100_ERR_CONF_BRIDGE_NOT_OPEN;
17771
 
                if ( ulEntryOpenCnt != pBridgeEntry->byEntryOpenCnt )
17772
 
                        return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
17773
 
 
17774
 
                /* This information is not currently available. */
17775
 
                *f_pusLoadEventIndex = cOCT6100_INVALID_INDEX;
17776
 
                *f_pusSubStoreEventIndex = cOCT6100_INVALID_INDEX;
17777
 
                *f_pusCopyEventIndex = cOCT6100_INVALID_INDEX;
17778
 
 
17779
 
                /* Return whether this is a flexible bridge or not. */
17780
 
                *f_pfFlexibleConfBridge = pBridgeEntry->fFlexibleConferencing;
17781
 
 
17782
 
                *f_pfTap = FALSE;
17783
 
        }
17784
 
 
17785
 
        return cOCT6100_ERR_OK;
17786
 
}
17787
 
 
17788
 
 
17789
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17790
 
 
17791
 
Function:               Oct6100ApiReleaseChanEventResources
17792
 
 
17793
 
Description:    Release all resources reserved to the channel part of the 
17794
 
                                conference bridge.
17795
 
 
17796
 
-------------------------------------------------------------------------------
17797
 
|       Argument                |       Description
17798
 
-------------------------------------------------------------------------------
17799
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
17800
 
                                                        present state of the chip and all its resources.
17801
 
f_pConfBridgeRemove                     Pointer to conference bridge channel add structure.  
17802
 
f_usBridgeIndex                         Index of the bridge structure within the API's bridge list.
17803
 
f_usChanIndex                           Index of the channel structure within the API's channel list
17804
 
f_fFlexibleConfBridge           If this is a flexible conference bridge.
17805
 
f_usLoadEventIndex                      Index of the load mixer event.
17806
 
f_usSubStoreEventIndex          Index of the sub-store mixer event.
17807
 
f_usCopyEventIndex                      Index of the copy mixer event.
17808
 
 
17809
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17810
 
static UINT32 Oct6100ApiReleaseChanEventResources(
17811
 
                                IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
17812
 
                                IN              tPOCT6100_CONF_BRIDGE_CHAN_REMOVE       f_pConfBridgeRemove,
17813
 
                                IN              UINT16                                                          f_usBridgeIndex, 
17814
 
                                IN              UINT16                                                          f_usChanIndex,
17815
 
                                IN              UINT8                                                           f_fFlexibleConfBridge,
17816
 
                                IN              UINT16                                                          f_usLoadEventIndex,
17817
 
                                IN              UINT16                                                          f_usSubStoreEventIndex,
17818
 
                                IN              UINT16                                                          f_usCopyEventIndex )
17819
 
{
17820
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
17821
 
        tPOCT6100_API_CHANNEL           pEchoChanEntry;
17822
 
        UINT32  ulResult;
17823
 
        UINT32  i;
17824
 
 
17825
 
        /* Obtain local pointer to shared portion of instance. */
17826
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
17827
 
 
17828
 
        if ( f_fFlexibleConfBridge == TRUE )
17829
 
        {
17830
 
                tPOCT6100_API_FLEX_CONF_PARTICIPANT pParticipant;
17831
 
                tPOCT6100_API_FLEX_CONF_PARTICIPANT pTempParticipant;
17832
 
 
17833
 
                if ( f_pConfBridgeRemove->fRemoveAll == FALSE )
17834
 
                {
17835
 
                        tPOCT6100_API_CHANNEL           pTempEchoChanEntry;
17836
 
 
17837
 
                        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
17838
 
                        mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex );
17839
 
 
17840
 
                        /* Release an entry for the store event in the mixer memory. */
17841
 
                        ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usSubStoreEventIndex );
17842
 
                        if ( ulResult != cOCT6100_ERR_OK )
17843
 
                        {
17844
 
                                return ulResult;
17845
 
                        }
17846
 
 
17847
 
                        /* Release an entry for the Sin copy event in the mixer memory. */
17848
 
                        /* This value can be invalid if the Rin port was used - no need to release. */
17849
 
                        if ( f_usCopyEventIndex != cOCT6100_INVALID_INDEX )
17850
 
                        {
17851
 
                                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usCopyEventIndex );
17852
 
                                if ( ulResult != cOCT6100_ERR_OK )
17853
 
                                {
17854
 
                                        return ulResult;
17855
 
                                }
17856
 
                        }
17857
 
 
17858
 
                        /* This value can be 0 if the Rin port was used - no need to release. */
17859
 
                        if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
17860
 
                        {
17861
 
                                /* Release the extra TSI entry.*/
17862
 
                                ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex );
17863
 
                                if ( ulResult != cOCT6100_ERR_OK )
17864
 
                                {
17865
 
                                        return ulResult;
17866
 
                                }
17867
 
                        }
17868
 
 
17869
 
                        /* This value can be 0 if the Sout port was used - no need to release. */
17870
 
                        if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 )
17871
 
                        {
17872
 
                                /* Release the extra TSI entry.*/
17873
 
                                ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraRinTsiMemIndex );
17874
 
                                if ( ulResult != cOCT6100_ERR_OK )
17875
 
                                {
17876
 
                                        return ulResult;
17877
 
                                }
17878
 
                        }
17879
 
 
17880
 
                        /* Must travel all clients of this conference and release the load or accumulate events for */
17881
 
                        /* all participants which can hear us and vice versa. */
17882
 
 
17883
 
                        /* Search through the list of API channel entry for the ones on to this bridge. */
17884
 
                        for ( i = 0; ( i < pSharedInfo->ChipConfig.usMaxChannels ) && ( ulResult == cOCT6100_ERR_OK ); i++ )
17885
 
                        {
17886
 
                                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, i );
17887
 
                        
17888
 
                                /* Channel reserved? */
17889
 
                                if ( ( i != f_usChanIndex ) && pTempEchoChanEntry->fReserved == TRUE )
17890
 
                                {
17891
 
                                        /* On current bridge? */
17892
 
                                        if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
17893
 
                                        {
17894
 
                                                mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
17895
 
 
17896
 
                                                /* Check if we can hear this participant. */
17897
 
                                                if ( ( pParticipant->ulListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 )
17898
 
                                                {
17899
 
                                                        /* Must release the allocated mixer event. */
17900
 
                                                        ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] );
17901
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
17902
 
                                                        {
17903
 
                                                                return ulResult;
17904
 
                                                        }
17905
 
                                                        
17906
 
                                                        pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX;
17907
 
                                                }
17908
 
 
17909
 
                                                /* Check if this participant can hear us. */
17910
 
                                                if ( ( pTempParticipant->ulListenerMask & ( 0x1 << pParticipant->ulListenerMaskIndex ) ) == 0x0 )
17911
 
                                                {
17912
 
                                                        /* Must release the allocated mixer event. */
17913
 
                                                        ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pTempParticipant->ausLoadOrAccumulateEventIndex[ pParticipant->ulListenerMaskIndex ] );
17914
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
17915
 
                                                        {
17916
 
                                                                return ulResult;
17917
 
                                                        }
17918
 
 
17919
 
                                                        pTempParticipant->ausLoadOrAccumulateEventIndex[ pParticipant->ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX;
17920
 
                                                }
17921
 
                                        }
17922
 
                                }
17923
 
                        }
17924
 
                }
17925
 
                else /* f_pConfBridgeRemove->fRemoveAll == TRUE */
17926
 
                {
17927
 
                        UINT32 ulListenerMaskIndex;
17928
 
 
17929
 
                        ulResult = cOCT6100_ERR_OK;
17930
 
                        
17931
 
                        /* Search through the list of API channel entry for the ones on to this bridge.*/
17932
 
                        for ( i = 0; ( i < pSharedInfo->ChipConfig.usMaxChannels ) && ( ulResult == cOCT6100_ERR_OK ); i++ )
17933
 
                        {
17934
 
                                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i );
17935
 
                                
17936
 
                                /* Channel reserved? */
17937
 
                                if ( pEchoChanEntry->fReserved == TRUE )
17938
 
                                {
17939
 
                                        /* On current bridge? */
17940
 
                                        if ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
17941
 
                                        {
17942
 
                                                mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex );
17943
 
 
17944
 
                                                /* Release an entry for the Store event in the Mixer memory. */
17945
 
                                                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pEchoChanEntry->usSubStoreEventIndex );
17946
 
                                                if ( ulResult != cOCT6100_ERR_OK )
17947
 
                                                {
17948
 
                                                        return ulResult;
17949
 
                                                }
17950
 
 
17951
 
                                                /* Release an entry for the Sin copy event in the Mixer memory. */
17952
 
                                                /* This value can be invalid if the Rin port was used - no need to release. */
17953
 
                                                if ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
17954
 
                                                {
17955
 
                                                        ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pEchoChanEntry->usSinCopyEventIndex );
17956
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
17957
 
                                                        {
17958
 
                                                                return ulResult;
17959
 
                                                        }
17960
 
                                                }
17961
 
 
17962
 
                                                /* This value can be 0 if the Rin port was used - no need to release. */
17963
 
                                                if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
17964
 
                                                {
17965
 
                                                        /* Release the extra TSI entry.*/
17966
 
                                                        ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex );
17967
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
17968
 
                                                        {
17969
 
                                                                return ulResult;
17970
 
                                                        }
17971
 
                                                }
17972
 
 
17973
 
                                                /* This value can be 0 if the Sout port was used - no need to release. */
17974
 
                                                if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 )
17975
 
                                                {
17976
 
                                                        /* Release the extra TSI entry.*/
17977
 
                                                        ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraRinTsiMemIndex );
17978
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
17979
 
                                                        {
17980
 
                                                                return ulResult;
17981
 
                                                        }
17982
 
                                                }
17983
 
 
17984
 
                                                /* Check if something can be freed. */
17985
 
                                                for ( ulListenerMaskIndex = 0; ulListenerMaskIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulListenerMaskIndex ++ )
17986
 
                                                {
17987
 
                                                        if ( pParticipant->ausLoadOrAccumulateEventIndex[ ulListenerMaskIndex ] != cOCT6100_INVALID_INDEX )
17988
 
                                                        {
17989
 
                                                                /* Must release the allocated mixer event. */
17990
 
                                                                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pParticipant->ausLoadOrAccumulateEventIndex[ ulListenerMaskIndex ] );
17991
 
                                                                if ( ulResult != cOCT6100_ERR_OK )
17992
 
                                                                {
17993
 
                                                                        return ulResult;
17994
 
                                                                }
17995
 
                                                                
17996
 
                                                                pParticipant->ausLoadOrAccumulateEventIndex[ ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX;
17997
 
                                                        }
17998
 
                                                }
17999
 
                                        }
18000
 
                                }
18001
 
                        }
18002
 
 
18003
 
                        if ( ulResult != cOCT6100_ERR_OK )
18004
 
                                return ulResult;
18005
 
                }
18006
 
        }
18007
 
        else /* if ( f_fFlexibleConfBridge == FALSE ) */
18008
 
        {
18009
 
                if ( f_pConfBridgeRemove->fRemoveAll == FALSE )
18010
 
                {
18011
 
                        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
18012
 
                        
18013
 
                        /* Release the entry for the load event in the mixer memory. */
18014
 
                        ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usLoadEventIndex );
18015
 
                        if ( ulResult != cOCT6100_ERR_OK )
18016
 
                        {
18017
 
                                return ulResult;
18018
 
                        }
18019
 
 
18020
 
                        /* Release an entry for the substract and store event in the mixer memory. */
18021
 
                        ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usSubStoreEventIndex );
18022
 
                        if ( ulResult != cOCT6100_ERR_OK )
18023
 
                        {
18024
 
                                return ulResult;
18025
 
                        }
18026
 
 
18027
 
                        /* Release an entry for the Sin copy event in the Mixer memory. */
18028
 
                        /* This value can be invalid if the Rin port was used - no need to release. */
18029
 
                        if ( f_usCopyEventIndex != cOCT6100_INVALID_INDEX )
18030
 
                        {
18031
 
                                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usCopyEventIndex );
18032
 
                                if ( ulResult != cOCT6100_ERR_OK )
18033
 
                                {
18034
 
                                        return ulResult;
18035
 
                                }
18036
 
                        }
18037
 
 
18038
 
                        /* This value can be 0 if the Rin port was used - no need to release. */
18039
 
                        if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
18040
 
                        {
18041
 
                                /* Release the extra TSI entry. */
18042
 
                                ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex );
18043
 
                                if ( ulResult != cOCT6100_ERR_OK )
18044
 
                                {
18045
 
                                        return ulResult;
18046
 
                                }
18047
 
                        }
18048
 
                }
18049
 
                else /* f_pConfBridgeRemove->fRemoveAll == TRUE */
18050
 
                {
18051
 
                        /* Search through the list of API channel entry for the ones on to the specified bridge.*/
18052
 
                        for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i++ )
18053
 
                        {
18054
 
                                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i );
18055
 
                                
18056
 
                                if ( pEchoChanEntry->fReserved == TRUE )
18057
 
                                {
18058
 
                                        if ( ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) && ( pEchoChanEntry->fTap == FALSE ) )
18059
 
                                        {
18060
 
                                                /* Release the entry for the load event in the mixer memory. */
18061
 
                                                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, 
18062
 
                                                                                                                                          pEchoChanEntry->usLoadEventIndex );
18063
 
                                                if ( ulResult != cOCT6100_ERR_OK )
18064
 
                                                {
18065
 
                                                        return ulResult;
18066
 
                                                }
18067
 
 
18068
 
                                                /* Release an entry for the substract and store event in the Mixer memory. */
18069
 
                                                ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, 
18070
 
                                                                                                                                          pEchoChanEntry->usSubStoreEventIndex );
18071
 
                                                if ( ulResult != cOCT6100_ERR_OK )
18072
 
                                                {
18073
 
                                                        return ulResult;
18074
 
                                                }
18075
 
 
18076
 
                                                /* Release an entry for the Sin copy event in the Mixer memory. */
18077
 
                                                /* This value can be invalid if the Rin port was used - no need to release. */
18078
 
                                                if ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
18079
 
                                                {
18080
 
                                                        ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, 
18081
 
                                                                                                                                                  pEchoChanEntry->usSinCopyEventIndex );
18082
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
18083
 
                                                        {
18084
 
                                                                return ulResult;
18085
 
                                                        }
18086
 
                                                }
18087
 
 
18088
 
                                                /* This value can be 0 if the Rin port was used - no need to release. */
18089
 
                                                if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
18090
 
                                                {
18091
 
                                                        /* Release the extra TSI entry.*/
18092
 
                                                        ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex );
18093
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
18094
 
                                                        {
18095
 
                                                                return ulResult;
18096
 
                                                        }
18097
 
                                                }
18098
 
                                        }
18099
 
                                }
18100
 
                        }
18101
 
                }
18102
 
        }
18103
 
 
18104
 
        return cOCT6100_ERR_OK;
18105
 
}
18106
 
 
18107
 
 
18108
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
18109
 
 
18110
 
Function:               Oct6100ApiBridgeEventRemove
18111
 
 
18112
 
Description:    Remove the event from the global event list of the chip and 
18113
 
                                update the bridge and channel structures.
18114
 
 
18115
 
-------------------------------------------------------------------------------
18116
 
|       Argument                |       Description
18117
 
-------------------------------------------------------------------------------
18118
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
18119
 
                                                        present state of the chip and all its resources.
18120
 
f_pConfBridgeRemove                     Pointer to a conference bridge channel remove structure.
18121
 
f_usBridgeIndex                         Index of the current bridge in the API list.
18122
 
f_usChanIndex                           Index of the current channel in the API list.
18123
 
f_fFlexibleConfBridge           If this is a flexible conference bridge.
18124
 
f_usLoadEventIndex                      Allocated entry for the Load event of the channel.
18125
 
f_usSubStoreEventIndex          Allocated entry for the substract and store event of the channel.
18126
 
f_usCopyEventIndex                      Allocated entry for the copy event of the channel.
18127
 
 
18128
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
18129
 
static UINT32 Oct6100ApiBridgeEventRemove (
18130
 
                                IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
18131
 
                                IN              tPOCT6100_CONF_BRIDGE_CHAN_REMOVE       f_pConfBridgeRemove,
18132
 
                                IN              UINT16                                                          f_usBridgeIndex, 
18133
 
                                IN              UINT16                                                          f_usChanIndex,
18134
 
                                IN              UINT8                                                           f_fFlexibleConfBridge,
18135
 
                                IN              UINT16                                                          f_usLoadEventIndex,
18136
 
                                IN              UINT16                                                          f_usSubStoreEventIndex,
18137
 
                                IN              UINT16                                                          f_usCopyEventIndex,
18138
 
                                IN              UINT8                                                           f_fTap )
18139
 
{
18140
 
        tPOCT6100_API_CONF_BRIDGE               pBridgeEntry;
18141
 
 
18142
 
        tPOCT6100_API_MIXER_EVENT               pLoadEventEntry;
18143
 
        tPOCT6100_API_MIXER_EVENT               pSubStoreEventEntry;
18144
 
        tPOCT6100_API_MIXER_EVENT               pCopyEventEntry = NULL;
18145
 
        tPOCT6100_API_MIXER_EVENT               pTempEntry;
18146
 
 
18147
 
        tPOCT6100_API_CHANNEL                   pEchoChanEntry;
18148
 
        tPOCT6100_API_CHANNEL                   pTempEchoChanEntry;
18149
 
 
18150
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
18151
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
18152
 
        tOCT6100_READ_PARAMS                    ReadParams;
18153
 
 
18154
 
        UINT32  ulResult;
18155
 
        UINT16  usPreviousEventIndex;
18156
 
        UINT16  usTempEventIndex;
18157
 
        UINT32  ulLoopCount = 0;
18158
 
        UINT16  usReadData;
18159
 
        UINT16  usChannelIndex;
18160
 
        UINT32  i;
18161
 
 
18162
 
        BOOL    fRemoveSinCopy = FALSE;
18163
 
 
18164
 
        /* Obtain local pointer to shared portion of instance. */
18165
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
18166
 
        
18167
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
18168
 
 
18169
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
18170
 
 
18171
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
18172
 
 
18173
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
18174
 
        ReadParams.pusReadData = &usReadData;
18175
 
        
18176
 
        mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pBridgeEntry, f_usBridgeIndex );
18177
 
        
18178
 
        /* If no client on the bridge, and the remove all option is specified, return here. */
18179
 
        if ( ( pBridgeEntry->usNumClients == 0 ) && ( f_pConfBridgeRemove->fRemoveAll == TRUE ) )
18180
 
                return cOCT6100_ERR_OK;
18181
 
 
18182
 
        /* Make sure the dominant speaker feature is disabled first. */
18183
 
        if ( pBridgeEntry->fDominantSpeakerSet == TRUE )
18184
 
        {
18185
 
                /* If all channels are to be removed or if the dominant speaker is the current channel to be removed. */
18186
 
                if ( ( f_pConfBridgeRemove->fRemoveAll == TRUE )
18187
 
                        || ( ( f_pConfBridgeRemove->fRemoveAll == FALSE ) && ( pBridgeEntry->usDominantSpeakerChanIndex == f_usChanIndex ) ) )
18188
 
                {
18189
 
                        /* Disable on all channels part of this conference. */
18190
 
 
18191
 
                        /* Search through the list of API channel entry for the ones on to this bridge. */
18192
 
                        for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ )
18193
 
                        {
18194
 
                                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
18195
 
                                
18196
 
                                if ( pTempEchoChanEntry->fReserved == TRUE )
18197
 
                                {
18198
 
                                        if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
18199
 
                                        {
18200
 
                                                ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, usChannelIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED );
18201
 
                                                if ( ulResult != cOCT6100_ERR_OK )
18202
 
                                                        return ulResult;
18203
 
                                        }
18204
 
                                }
18205
 
                        }
18206
 
 
18207
 
                        /* Save this in the conference bridge structure. */
18208
 
                        pBridgeEntry->fDominantSpeakerSet = FALSE;
18209
 
                        pBridgeEntry->usDominantSpeakerChanIndex = cOCT6100_INVALID_INDEX;
18210
 
                }
18211
 
                else
18212
 
                {
18213
 
                        /* Only disable this current channel. */
18214
 
                        ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_usChanIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED );
18215
 
                        if ( ulResult != cOCT6100_ERR_OK )
18216
 
                                return ulResult;
18217
 
                }
18218
 
        }
18219
 
 
18220
 
        if ( f_fFlexibleConfBridge == TRUE )
18221
 
        {
18222
 
                tPOCT6100_API_FLEX_CONF_PARTICIPANT pParticipant;
18223
 
                tPOCT6100_API_FLEX_CONF_PARTICIPANT pTempParticipant;
18224
 
                UINT16  ausMutePortChannelIndexes[ cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE ];
18225
 
                UINT32  ulMutePortChannelIndex;
18226
 
 
18227
 
                for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ )
18228
 
                        ausMutePortChannelIndexes[ ulMutePortChannelIndex ] = cOCT6100_INVALID_INDEX;
18229
 
 
18230
 
                if ( f_pConfBridgeRemove->fRemoveAll == FALSE )
18231
 
                {
18232
 
                        /* The channel index is valid. */
18233
 
                        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
18234
 
                        mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex );
18235
 
 
18236
 
                        /* Search through the list of API channel entry for the ones on to this bridge. */
18237
 
                        for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ )
18238
 
                        {
18239
 
                                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
18240
 
 
18241
 
                                if ( ( usChannelIndex != f_usChanIndex ) && ( pTempEchoChanEntry->fReserved == TRUE ) )
18242
 
                                {
18243
 
                                        if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
18244
 
                                        {
18245
 
                                                mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
18246
 
 
18247
 
                                                /* Check if we can hear this participant. */
18248
 
                                                if ( ( ( pParticipant->ulListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 )
18249
 
                                                        && ( pParticipant->fFlexibleMixerCreated == TRUE ) 
18250
 
                                                        && ( pTempEchoChanEntry->fMute == FALSE ) )
18251
 
                                                {
18252
 
                                                        /* First update the current channel's mixer. */
18253
 
                                                        ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel(
18254
 
                                                                                                                f_pApiInstance,
18255
 
                                                                                                                f_usBridgeIndex,
18256
 
                                                                                                                usChannelIndex,
18257
 
                                                                                                                f_usChanIndex,
18258
 
                                                                                                                TRUE );
18259
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
18260
 
                                                                return ulResult;
18261
 
                                                }
18262
 
 
18263
 
                                                /* Check if this participant can hear us. */
18264
 
                                                if ( ( ( pTempParticipant->ulListenerMask & ( 0x1 << pParticipant->ulListenerMaskIndex ) ) == 0x0 )
18265
 
                                                        && ( pTempParticipant->fFlexibleMixerCreated == TRUE ) 
18266
 
                                                        && ( pEchoChanEntry->fMute == FALSE ) )
18267
 
                                                {
18268
 
                                                        /* Then update this channel's mixer. */
18269
 
                                                        ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel(
18270
 
                                                                                                                f_pApiInstance,
18271
 
                                                                                                                f_usBridgeIndex,
18272
 
                                                                                                                f_usChanIndex,
18273
 
                                                                                                                usChannelIndex,
18274
 
                                                                                                                TRUE );
18275
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
18276
 
                                                                return ulResult;
18277
 
 
18278
 
                                                        /* Remember to mute the port on this channel. */
18279
 
                                                        for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ )
18280
 
                                                        {
18281
 
                                                                if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == usChannelIndex )
18282
 
                                                                {
18283
 
                                                                        break;
18284
 
                                                                }
18285
 
                                                                else if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX )
18286
 
                                                                {
18287
 
                                                                        ausMutePortChannelIndexes[ ulMutePortChannelIndex ] = usChannelIndex;
18288
 
                                                                        break;
18289
 
                                                                }
18290
 
                                                        }
18291
 
                                                }
18292
 
                                        }
18293
 
                                }
18294
 
                        }
18295
 
 
18296
 
                        /* Check if must manually clear the Sin copy event. */
18297
 
                        if ( ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
18298
 
                                && ( pEchoChanEntry->fCopyEventCreated == TRUE ) )
18299
 
                        {
18300
 
                                /* Transform event into no-operation. */
18301
 
                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18302
 
                                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
18303
 
 
18304
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18305
 
                                if ( ulResult != cOCT6100_ERR_OK )
18306
 
                                        return ulResult;
18307
 
 
18308
 
                                /* Now remove the copy event from the event list. */
18309
 
                                ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, pEchoChanEntry->usSinCopyEventIndex, cOCT6100_EVENT_TYPE_SIN_COPY );
18310
 
                                if ( ulResult != cOCT6100_ERR_OK )
18311
 
                                        return ulResult;
18312
 
 
18313
 
                                pEchoChanEntry->fCopyEventCreated = FALSE;
18314
 
                        }
18315
 
 
18316
 
                        /* Release an entry for the participant. */
18317
 
                        ulResult = Oct6100ApiReleaseFlexConfParticipantEntry( f_pApiInstance, pEchoChanEntry->usFlexConfParticipantIndex );
18318
 
                        if ( ulResult != cOCT6100_ERR_OK )
18319
 
                        {
18320
 
                                return ulResult;
18321
 
                        }
18322
 
 
18323
 
                        /*=======================================================================*/
18324
 
                        /* Update the event and channel API structure */
18325
 
                        pEchoChanEntry->usFlexConfParticipantIndex = cOCT6100_INVALID_INDEX;
18326
 
                        pEchoChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
18327
 
                        pEchoChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX;
18328
 
                        pEchoChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX;
18329
 
                        pEchoChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
18330
 
 
18331
 
                        /* Indicate that the extra SIN TSI is not needed anymore by the mixer. */
18332
 
                        if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
18333
 
                        {
18334
 
                                pEchoChanEntry->usExtraSinTsiDependencyCnt--;
18335
 
                                pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
18336
 
                        }
18337
 
                        
18338
 
                        /* Indicate that the extra RIN TSI is not needed anymore by the mixer. */
18339
 
                        if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 )
18340
 
                        {
18341
 
                                pEchoChanEntry->usExtraRinTsiDependencyCnt--;
18342
 
                                pEchoChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX;
18343
 
                        }
18344
 
 
18345
 
                        /* Update the chip stats structure. */
18346
 
                        pSharedInfo->ChipStats.usNumEcChanUsingMixer--;
18347
 
 
18348
 
                        pBridgeEntry->usNumClients--;
18349
 
 
18350
 
                        /* For sure we have to mute the ports of this channel to be removed. */
18351
 
                        ulResult = Oct6100ApiMutePorts( 
18352
 
                                                                        f_pApiInstance, 
18353
 
                                                                        f_usChanIndex, 
18354
 
                                                                        pEchoChanEntry->usRinTsstIndex, 
18355
 
                                                                        pEchoChanEntry->usSinTsstIndex,
18356
 
                                                                        FALSE );
18357
 
                        if ( ulResult != cOCT6100_ERR_OK )
18358
 
                                return ulResult;
18359
 
 
18360
 
                        /* Travel through the channels that were heard by the participant removed and check if their Rin port must be muted. */
18361
 
                        for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ )
18362
 
                        {
18363
 
                                if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] != cOCT6100_INVALID_INDEX )
18364
 
                                {
18365
 
                                        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, ausMutePortChannelIndexes[ ulMutePortChannelIndex ] );
18366
 
 
18367
 
                                        mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
18368
 
                                        
18369
 
                                        if ( pTempParticipant->fFlexibleMixerCreated == FALSE )
18370
 
                                        {
18371
 
                                                /* Check if the Rin port must be muted on this channel. */
18372
 
                                                ulResult = Oct6100ApiMutePorts( 
18373
 
                                                                                                f_pApiInstance, 
18374
 
                                                                                                ausMutePortChannelIndexes[ ulMutePortChannelIndex ], 
18375
 
                                                                                                pTempEchoChanEntry->usRinTsstIndex, 
18376
 
                                                                                                pTempEchoChanEntry->usSinTsstIndex,
18377
 
                                                                                                FALSE );
18378
 
                                                if ( ulResult != cOCT6100_ERR_OK )
18379
 
                                                        return ulResult;
18380
 
                                        }
18381
 
                                }
18382
 
                                else /* if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX ) */
18383
 
                                {
18384
 
                                        /* No more channels to check for muting. */
18385
 
                                        break;
18386
 
                                }
18387
 
                        }
18388
 
                }
18389
 
                else /* if ( f_pConfBridgeRemove->fRemoveAll == TRUE ) */
18390
 
                {
18391
 
                        UINT16 usMainChannelIndex;
18392
 
 
18393
 
                        for ( usMainChannelIndex = 0 ; usMainChannelIndex < pSharedInfo->ChipConfig.usMaxChannels ; usMainChannelIndex++ )
18394
 
                        {
18395
 
                                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, usMainChannelIndex );
18396
 
 
18397
 
                                /* If this channel is on the bridge we are closing all the channels. */
18398
 
                                if ( ( pEchoChanEntry->fReserved == TRUE ) && ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) )
18399
 
                                {
18400
 
                                        /* Remember to mute the port on this channel. */
18401
 
                                        for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ )
18402
 
                                        {
18403
 
                                                if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == usMainChannelIndex )
18404
 
                                                {
18405
 
                                                        break;
18406
 
                                                }
18407
 
                                                else if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX )
18408
 
                                                {
18409
 
                                                        ausMutePortChannelIndexes[ ulMutePortChannelIndex ] = usMainChannelIndex;
18410
 
                                                        break;
18411
 
                                                }
18412
 
                                        }
18413
 
 
18414
 
                                        mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex );
18415
 
 
18416
 
                                        /* Search through the list of API channel entry for the ones on to this bridge. */
18417
 
                                        for ( usChannelIndex = (UINT16)( usMainChannelIndex + 1 ); usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ )
18418
 
                                        {
18419
 
                                                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
18420
 
                                                if ( pTempEchoChanEntry->fReserved == TRUE )
18421
 
                                                {
18422
 
                                                        if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
18423
 
                                                        {
18424
 
                                                                mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
18425
 
 
18426
 
                                                                /* Everyone that we can hear must be removed. */
18427
 
                                                                if ( ( ( pParticipant->ulListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 )
18428
 
                                                                        && ( pParticipant->fFlexibleMixerCreated == TRUE ) 
18429
 
                                                                        && ( pTempEchoChanEntry->fMute == FALSE ) )
18430
 
                                                                {
18431
 
                                                                        /* First update the current channel's mixer. */
18432
 
                                                                        ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel(
18433
 
                                                                                                                                f_pApiInstance,
18434
 
                                                                                                                                f_usBridgeIndex,
18435
 
                                                                                                                                usChannelIndex,
18436
 
                                                                                                                                usMainChannelIndex,
18437
 
                                                                                                                                TRUE );
18438
 
                                                                        if ( ulResult != cOCT6100_ERR_OK )
18439
 
                                                                                return ulResult;
18440
 
                                                                }
18441
 
 
18442
 
                                                                /* Check if this participant can hear us. */
18443
 
                                                                if ( ( ( pTempParticipant->ulListenerMask & ( 0x1 << pParticipant->ulListenerMaskIndex ) ) == 0x0 )
18444
 
                                                                        && ( pTempParticipant->fFlexibleMixerCreated == TRUE ) 
18445
 
                                                                        && ( pEchoChanEntry->fMute == FALSE ) )
18446
 
                                                                {
18447
 
                                                                        /* Then update this channel's mixer. */
18448
 
                                                                        ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel(
18449
 
                                                                                                                                f_pApiInstance,
18450
 
                                                                                                                                f_usBridgeIndex,
18451
 
                                                                                                                                usMainChannelIndex,
18452
 
                                                                                                                                usChannelIndex,
18453
 
                                                                                                                                TRUE );
18454
 
                                                                        if ( ulResult != cOCT6100_ERR_OK )
18455
 
                                                                                return ulResult;
18456
 
                                                                }
18457
 
                                                        }
18458
 
                                                }
18459
 
                                        }
18460
 
 
18461
 
                                        /* Check if must manually clear the Sin copy event. */
18462
 
                                        if ( ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
18463
 
                                                && ( pEchoChanEntry->fCopyEventCreated == TRUE ) )
18464
 
                                        {
18465
 
                                                /* Transform event into no-operation. */
18466
 
                                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18467
 
                                                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
18468
 
 
18469
 
                                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18470
 
                                                if ( ulResult != cOCT6100_ERR_OK )
18471
 
                                                        return ulResult;
18472
 
 
18473
 
                                                /* Now remove the copy event from the event list. */
18474
 
                                                ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, pEchoChanEntry->usSinCopyEventIndex, cOCT6100_EVENT_TYPE_SIN_COPY );
18475
 
                                                if ( ulResult != cOCT6100_ERR_OK )
18476
 
                                                        return ulResult;
18477
 
 
18478
 
                                                pEchoChanEntry->fCopyEventCreated = FALSE;
18479
 
                                        }
18480
 
 
18481
 
                                        /* Release an entry for the participant. */
18482
 
                                        ulResult = Oct6100ApiReleaseFlexConfParticipantEntry( f_pApiInstance, pEchoChanEntry->usFlexConfParticipantIndex );
18483
 
                                        if ( ulResult != cOCT6100_ERR_OK )
18484
 
                                        {
18485
 
                                                return ulResult;
18486
 
                                        }
18487
 
 
18488
 
                                        /*=======================================================================*/
18489
 
                                        /* Update the event and channel API structure */
18490
 
 
18491
 
                                        pEchoChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
18492
 
 
18493
 
                                        pEchoChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX;
18494
 
                                        pEchoChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX;
18495
 
                                        pEchoChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
18496
 
 
18497
 
                                        /* Indicate that the Extra SIN TSI is not needed anymore by the mixer. */
18498
 
                                        if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
18499
 
                                        {
18500
 
                                                pEchoChanEntry->usExtraSinTsiDependencyCnt--;
18501
 
                                                pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
18502
 
                                        }
18503
 
                                        
18504
 
                                        /* Indicate that the Extra RIN TSI is not needed anymore by the mixer. */
18505
 
                                        if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 )
18506
 
                                        {
18507
 
                                                pEchoChanEntry->usExtraRinTsiDependencyCnt--;
18508
 
                                                pEchoChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX;
18509
 
                                        }
18510
 
 
18511
 
                                        /* Update the chip stats structure. */
18512
 
                                        pSharedInfo->ChipStats.usNumEcChanUsingMixer--;
18513
 
                                }
18514
 
                        }
18515
 
 
18516
 
                        /* Travel through the channels that were heard by the participant removed and check if their Rin port must be muted. */
18517
 
                        for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ )
18518
 
                        {
18519
 
                                if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] != cOCT6100_INVALID_INDEX )
18520
 
                                {
18521
 
                                        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, ausMutePortChannelIndexes[ ulMutePortChannelIndex ] );
18522
 
 
18523
 
                                        mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
18524
 
                                        
18525
 
                                        if ( pTempParticipant->fFlexibleMixerCreated == FALSE )
18526
 
                                        {
18527
 
                                                /* Check if the Rin port must be muted on this channel. */
18528
 
                                                ulResult = Oct6100ApiMutePorts( 
18529
 
                                                                                                f_pApiInstance, 
18530
 
                                                                                                ausMutePortChannelIndexes[ ulMutePortChannelIndex ], 
18531
 
                                                                                                pTempEchoChanEntry->usRinTsstIndex, 
18532
 
                                                                                                pTempEchoChanEntry->usSinTsstIndex,
18533
 
                                                                                                FALSE );
18534
 
                                                if ( ulResult != cOCT6100_ERR_OK )
18535
 
                                                        return ulResult;
18536
 
                                        }
18537
 
                                }
18538
 
                                else /* if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX ) */
18539
 
                                {
18540
 
                                        /* No more channels to check for muting. */
18541
 
                                        break;
18542
 
                                }
18543
 
 
18544
 
                                /* Clear the flexible conf bridge participant index. */
18545
 
                                pTempEchoChanEntry->usFlexConfParticipantIndex = cOCT6100_INVALID_INDEX;
18546
 
                        }
18547
 
 
18548
 
                        /* No more clients on bridge. */
18549
 
                        pBridgeEntry->usNumClients = 0;
18550
 
                }
18551
 
        }
18552
 
        else /* if ( f_fFlexibleConfBridge == FALSE ) */
18553
 
        {
18554
 
                if ( f_pConfBridgeRemove->fRemoveAll == FALSE )
18555
 
                {
18556
 
                        /* The channel index is valid. */
18557
 
                        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
18558
 
 
18559
 
                        if ( f_fTap == TRUE )
18560
 
                        {
18561
 
                                mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pBridgeEntry, pEchoChanEntry->usTapBridgeIndex );
18562
 
                        }
18563
 
 
18564
 
                        /* Get a pointer to the event entry. */
18565
 
                        if ( f_usCopyEventIndex != cOCT6100_INVALID_INDEX )
18566
 
                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, f_usCopyEventIndex );
18567
 
                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, f_usSubStoreEventIndex );
18568
 
                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, f_usLoadEventIndex );
18569
 
 
18570
 
                        /*=======================================================================*/
18571
 
                        /* Check if have to modify the silence load event. */
18572
 
 
18573
 
                        if ( pBridgeEntry->usNumClients != 1 )
18574
 
                        {
18575
 
                                if ( pBridgeEntry->usSilenceLoadEventPtr != cOCT6100_INVALID_INDEX )
18576
 
                                {
18577
 
                                        if ( pBridgeEntry->usSilenceLoadEventPtr == f_usLoadEventIndex )
18578
 
                                        {
18579
 
                                                /* Make sure the next event becomes the silence event. */
18580
 
                                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pLoadEventEntry->usNextEventPtr * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18581
 
 
18582
 
                                                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_LOAD;
18583
 
                                                WriteParams.usWriteData |= 1534; /* TSI index 1534 reserved for silence */
18584
 
 
18585
 
                                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18586
 
                                                if ( ulResult != cOCT6100_ERR_OK )
18587
 
                                                        return ulResult;
18588
 
                                                
18589
 
                                                /* Update the software model to remember the silence load. */
18590
 
                                                pBridgeEntry->usSilenceLoadEventPtr = pLoadEventEntry->usNextEventPtr;
18591
 
                                        }
18592
 
                                        else
18593
 
                                        {
18594
 
                                                /* Somebody else is the silence event, no need to worry. */
18595
 
                                        }
18596
 
                                }
18597
 
                        }
18598
 
 
18599
 
                        /*=======================================================================*/
18600
 
 
18601
 
 
18602
 
                        /*=======================================================================*/
18603
 
                        /* Clear the Load event. */
18604
 
 
18605
 
                        /* First verify if the event to be removed was a load event. */
18606
 
                        if ( f_usLoadEventIndex == pBridgeEntry->usLoadIndex )
18607
 
                        {
18608
 
                                /* Change the next entry if one is present to a load event to keep the bridge alive. */
18609
 
                                if ( pBridgeEntry->usNumClients == 1 )
18610
 
                                {
18611
 
                                        /* There is no other entry on the bridge, no need to search for an Accumulate event. */
18612
 
                                        pBridgeEntry->usLoadIndex = cOCT6100_INVALID_INDEX;
18613
 
 
18614
 
                                        /* Clear the silence event, for sure it's invalid. */
18615
 
                                        pBridgeEntry->usSilenceLoadEventPtr = cOCT6100_INVALID_INDEX;
18616
 
                                }
18617
 
                                else
18618
 
                                {
18619
 
                                        /* Search for an accumulate event to tranform into a Load event. */
18620
 
                                        usTempEventIndex = pLoadEventEntry->usNextEventPtr;
18621
 
                                        ulLoopCount = 0;
18622
 
 
18623
 
                                        /* Find the copy entry before the entry to remove. */
18624
 
                                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex );
18625
 
 
18626
 
                                        while( pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_SUB_STORE && 
18627
 
                                                   pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_STORE )
18628
 
                                        {
18629
 
                                                if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE )
18630
 
                                                {
18631
 
                                                        /* Change this entry into a load event. */
18632
 
                                                        ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18633
 
                                                        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
18634
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
18635
 
                                                                return ulResult;
18636
 
 
18637
 
                                                        WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
18638
 
                                                        WriteParams.usWriteData = (UINT16)(( usReadData & 0x1FFF ) | cOCT6100_MIXER_CONTROL_MEM_LOAD);
18639
 
 
18640
 
                                                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18641
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
18642
 
                                                                return ulResult;
18643
 
                                                        
18644
 
                                                        /* Set this entry as the load index. */
18645
 
                                                        pBridgeEntry->usLoadIndex = usTempEventIndex;
18646
 
 
18647
 
                                                        /* Update the software model. */
18648
 
                                                        pTempEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_LOAD;
18649
 
 
18650
 
                                                        /* Stop searching. */
18651
 
                                                        break;
18652
 
                                                }
18653
 
                                                
18654
 
                                                /* Go to the next entry into the list. */
18655
 
                                                usTempEventIndex = pTempEntry->usNextEventPtr;
18656
 
                                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex );
18657
 
 
18658
 
                                                ulLoopCount++;
18659
 
                                                if ( ulLoopCount == cOCT6100_MAX_LOOP )
18660
 
                                                        return cOCT6100_ERR_FATAL_9B;
18661
 
                                        }
18662
 
                                }
18663
 
                        }
18664
 
                        
18665
 
                        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usLoadEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18666
 
                        WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
18667
 
 
18668
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18669
 
                        if ( ulResult != cOCT6100_ERR_OK )
18670
 
                                return ulResult;
18671
 
 
18672
 
                        /*=======================================================================*/
18673
 
                        
18674
 
                        /*=======================================================================*/
18675
 
                        /* Clear the substract and store event. */
18676
 
                        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usSubStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18677
 
                        WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
18678
 
                        
18679
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18680
 
                        if ( ulResult != cOCT6100_ERR_OK )
18681
 
                                return ulResult;
18682
 
 
18683
 
                        /*=======================================================================*/
18684
 
 
18685
 
                        /*=======================================================================*/
18686
 
                        /* Clear the Copy event - if needed. */
18687
 
 
18688
 
                        if ( f_usCopyEventIndex != cOCT6100_INVALID_INDEX )
18689
 
                        {
18690
 
                                /* Transform event into no-operation. */
18691
 
                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18692
 
                                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
18693
 
 
18694
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18695
 
                                if ( ulResult != cOCT6100_ERR_OK )
18696
 
                                        return ulResult;
18697
 
                                
18698
 
                                if ( f_fTap == FALSE )
18699
 
                                {
18700
 
                                        /* Set remove Sin copy event flag to remove the event from the mixer's list. */
18701
 
                                        fRemoveSinCopy = TRUE;
18702
 
 
18703
 
                                        /* Clear the copy event created flag. */
18704
 
                                        pEchoChanEntry->fCopyEventCreated = FALSE;
18705
 
                                }
18706
 
                        }
18707
 
 
18708
 
                        /*=======================================================================*/
18709
 
                
18710
 
                        
18711
 
                        /*=======================================================================*/
18712
 
                        /* Now remove the event from the event list. */
18713
 
                        
18714
 
                        /* Look for the entry that is pointing at the first entry of our bridge. */
18715
 
                        if ( f_fTap == FALSE )
18716
 
                        {
18717
 
                                ulResult = Oct6100ApiGetPrevLastSubStoreEvent( f_pApiInstance, f_usBridgeIndex, pBridgeEntry->usFirstLoadEventPtr, &usPreviousEventIndex );
18718
 
                        }
18719
 
                        else
18720
 
                        {
18721
 
                                ulResult = Oct6100ApiGetPrevLastSubStoreEvent( f_pApiInstance, pEchoChanEntry->usTapBridgeIndex, pBridgeEntry->usFirstLoadEventPtr, &usPreviousEventIndex );
18722
 
                        }
18723
 
                        
18724
 
                        if ( ulResult != cOCT6100_ERR_OK )
18725
 
                        {
18726
 
                                /* If the entry was not found, we now check for the Sout copy event section/list. */
18727
 
                                if ( ulResult == cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND )
18728
 
                                {
18729
 
                                        if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
18730
 
                                        {
18731
 
                                                /* No Sout copy, it has to be the head node. */
18732
 
                                                usPreviousEventIndex = cOCT6100_MIXER_HEAD_NODE;
18733
 
                                        }
18734
 
                                        else
18735
 
                                        {
18736
 
                                                /* Use the last Sout copy event. */
18737
 
                                                usPreviousEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
18738
 
                                        }
18739
 
                                }
18740
 
                                else
18741
 
                                {
18742
 
                                        return cOCT6100_ERR_FATAL_27;
18743
 
                                }
18744
 
                        }
18745
 
 
18746
 
                        if ( pBridgeEntry->usNumClients == 1 )
18747
 
                        {
18748
 
                                /* An entry was found, now, modify it's value. */
18749
 
                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex );
18750
 
 
18751
 
                                /* Now modify the previous last Sub Store event from another bridge. */
18752
 
                                pTempEntry->usNextEventPtr = pSubStoreEventEntry->usNextEventPtr;
18753
 
 
18754
 
                                /*=======================================================================*/
18755
 
                                /* Modify the last node of the previous bridge to point to the next bridge. */
18756
 
                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18757
 
                                WriteParams.ulWriteAddress += 4;
18758
 
 
18759
 
                                WriteParams.usWriteData = (UINT16)( pTempEntry->usNextEventPtr );
18760
 
                                
18761
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18762
 
                                if ( ulResult != cOCT6100_ERR_OK )
18763
 
                                        return ulResult;
18764
 
 
18765
 
                                /*=======================================================================*/
18766
 
                                
18767
 
                                /* Set the event pointer info in the bridge stucture. */
18768
 
                                pBridgeEntry->usFirstLoadEventPtr = cOCT6100_INVALID_INDEX;
18769
 
                                pBridgeEntry->usFirstSubStoreEventPtr = cOCT6100_INVALID_INDEX;
18770
 
                                pBridgeEntry->usLastSubStoreEventPtr = cOCT6100_INVALID_INDEX;
18771
 
 
18772
 
                                /*=======================================================================*/
18773
 
                                /* Update the global mixer pointers. */
18774
 
                                if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == f_usLoadEventIndex &&
18775
 
                                         pSharedInfo->MixerInfo.usLastBridgeEventPtr  == f_usSubStoreEventIndex )
18776
 
                                {
18777
 
                                        /* There is no more bridge entry in the mixer link list. */
18778
 
                                        pSharedInfo->MixerInfo.usFirstBridgeEventPtr = cOCT6100_INVALID_INDEX;
18779
 
                                        pSharedInfo->MixerInfo.usLastBridgeEventPtr  = cOCT6100_INVALID_INDEX;
18780
 
                                }
18781
 
                                else if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == f_usLoadEventIndex )
18782
 
                                {
18783
 
                                        pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pSubStoreEventEntry->usNextEventPtr;
18784
 
                                }
18785
 
                                else if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == f_usSubStoreEventIndex )
18786
 
                                {
18787
 
                                        pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex;
18788
 
                                }
18789
 
                                /*=======================================================================*/
18790
 
 
18791
 
                                if ( f_fTap == TRUE )
18792
 
                                {
18793
 
                                        /* The channel being tapped is not tapped anymore.  */
18794
 
                                        /* There is no direct way of finding the tap, so loop through all channels and find the */
18795
 
                                        /* tapped channel index. */
18796
 
                                        for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ )
18797
 
                                        {
18798
 
                                                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
18799
 
 
18800
 
                                                if ( pTempEchoChanEntry->usTapChanIndex == f_usChanIndex )
18801
 
                                                {
18802
 
                                                        tPOCT6100_API_CONF_BRIDGE       pTempBridgeEntry;
18803
 
 
18804
 
                                                        pTempEchoChanEntry->fBeingTapped = FALSE;
18805
 
                                                        pTempEchoChanEntry->usTapChanIndex = cOCT6100_INVALID_INDEX;
18806
 
 
18807
 
                                                        mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pTempBridgeEntry, f_usBridgeIndex );
18808
 
 
18809
 
                                                        pTempBridgeEntry->usNumTappedClients--;
18810
 
                                                        
18811
 
                                                        /* Re-assign Rin TSST for tapped channel. */
18812
 
                                                        if ( pTempEchoChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
18813
 
                                                        {
18814
 
                                                                ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
18815
 
                                                                                                                                                                  pTempEchoChanEntry->usRinTsstIndex,
18816
 
                                                                                                                                                                  pTempEchoChanEntry->usRinRoutTsiMemIndex,
18817
 
                                                                                                                                                                  pTempEchoChanEntry->TdmConfig.byRinPcmLaw );
18818
 
                                                                if ( ulResult != cOCT6100_ERR_OK )
18819
 
                                                                        return ulResult;
18820
 
                                                        }
18821
 
 
18822
 
                                                        break;
18823
 
                                                }
18824
 
                                        }
18825
 
 
18826
 
                                        /* Check if our model is broken. */
18827
 
                                        if ( usChannelIndex == pSharedInfo->ChipConfig.usMaxChannels )
18828
 
                                                return cOCT6100_ERR_FATAL_D3;
18829
 
                                }
18830
 
                        }
18831
 
                        else /* pBridgeEntry->usNumClients > 1 */
18832
 
                        {
18833
 
                                if ( pBridgeEntry->usFirstLoadEventPtr != f_usLoadEventIndex )
18834
 
                                {
18835
 
                                        /* Now find the load entry of this bridge pointing at this load event */
18836
 
                                        ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, pBridgeEntry->usFirstLoadEventPtr, f_usLoadEventIndex, 0, &usPreviousEventIndex );
18837
 
                                        if ( ulResult != cOCT6100_ERR_OK )
18838
 
                                                return ulResult;
18839
 
                                }
18840
 
 
18841
 
                                /* Remove the load event to the list. */
18842
 
                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex );
18843
 
                                
18844
 
                                /* Now modify the previous last Sub Store event from another bridge. */
18845
 
                                pTempEntry->usNextEventPtr = pLoadEventEntry->usNextEventPtr;
18846
 
 
18847
 
                                /*=======================================================================*/
18848
 
                                /* Modify the previous node. */
18849
 
                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18850
 
                                WriteParams.ulWriteAddress += 4;
18851
 
 
18852
 
                                WriteParams.usWriteData = (UINT16)( pTempEntry->usNextEventPtr );
18853
 
                                
18854
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18855
 
                                if ( ulResult != cOCT6100_ERR_OK )
18856
 
                                        return ulResult;
18857
 
 
18858
 
                                /*=======================================================================*/
18859
 
 
18860
 
                                /* Now find the last load entry of this bridge ( the one pointing at the first sub-store event ). */
18861
 
                                if ( pBridgeEntry->usFirstSubStoreEventPtr == f_usSubStoreEventIndex )
18862
 
                                {
18863
 
                                        /* Must start with the first load to get the entry before the first sub store. */
18864
 
                                        ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, pBridgeEntry->usFirstLoadEventPtr, f_usSubStoreEventIndex, 0, &usPreviousEventIndex );
18865
 
                                        if ( ulResult != cOCT6100_ERR_OK )
18866
 
                                                return ulResult;
18867
 
                                }
18868
 
                                else
18869
 
                                {
18870
 
                                        /* Must start with the first load to get the entry before the first sub store. */
18871
 
                                        ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, pBridgeEntry->usFirstSubStoreEventPtr, f_usSubStoreEventIndex, 0, &usPreviousEventIndex );
18872
 
                                        if ( ulResult != cOCT6100_ERR_OK )
18873
 
                                                return ulResult;
18874
 
                                }
18875
 
 
18876
 
                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex );
18877
 
                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, f_usSubStoreEventIndex );
18878
 
 
18879
 
                                /* Now modify the last load event of the bridge. */
18880
 
                                pTempEntry->usNextEventPtr = pSubStoreEventEntry->usNextEventPtr;
18881
 
 
18882
 
                                /*=======================================================================*/
18883
 
                                /* Modify the last node of the other bridge. */
18884
 
 
18885
 
                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18886
 
                                WriteParams.ulWriteAddress += 4;
18887
 
 
18888
 
                                WriteParams.usWriteData = (UINT16)( pTempEntry->usNextEventPtr );
18889
 
                                
18890
 
                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18891
 
                                if ( ulResult != cOCT6100_ERR_OK )
18892
 
                                        return ulResult;
18893
 
 
18894
 
                                /*=======================================================================*/
18895
 
 
18896
 
                                /*=======================================================================*/
18897
 
                                /* Update the bridge pointers. */
18898
 
 
18899
 
                                if ( pBridgeEntry->usFirstLoadEventPtr == f_usLoadEventIndex )
18900
 
                                        pBridgeEntry->usFirstLoadEventPtr = pLoadEventEntry->usNextEventPtr;
18901
 
 
18902
 
                                if ( pBridgeEntry->usFirstSubStoreEventPtr == f_usSubStoreEventIndex )
18903
 
                                        pBridgeEntry->usFirstSubStoreEventPtr = pSubStoreEventEntry->usNextEventPtr;
18904
 
 
18905
 
                                if ( pBridgeEntry->usLastSubStoreEventPtr == f_usSubStoreEventIndex )
18906
 
                                        pBridgeEntry->usLastSubStoreEventPtr = usPreviousEventIndex;
18907
 
                        
18908
 
                                /*=======================================================================*/
18909
 
 
18910
 
 
18911
 
                                /*=======================================================================*/
18912
 
                                /* Update the global mixer pointers. */
18913
 
 
18914
 
                                if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == f_usLoadEventIndex )
18915
 
                                {
18916
 
                                        pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pLoadEventEntry->usNextEventPtr;
18917
 
                                }
18918
 
 
18919
 
                                if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == f_usSubStoreEventIndex )
18920
 
                                {
18921
 
                                        pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex;
18922
 
                                }
18923
 
                                /*=======================================================================*/
18924
 
 
18925
 
                        }
18926
 
 
18927
 
                        /* Check if must remove the Sin copy event from the event list. */
18928
 
                        if ( fRemoveSinCopy == TRUE )
18929
 
                        {
18930
 
                                /* Now remove the copy event from the event list. */
18931
 
                                ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, f_usCopyEventIndex, cOCT6100_EVENT_TYPE_SIN_COPY );
18932
 
                                if ( ulResult != cOCT6100_ERR_OK )
18933
 
                                        return ulResult;
18934
 
                        }
18935
 
 
18936
 
                        /* Get the channel. */
18937
 
                        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
18938
 
 
18939
 
                        /* Reprogram the TSST entry correctly if the Extra SIN TSI entry was released. */
18940
 
                        if ( ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) && ( f_fTap == FALSE ) )
18941
 
                        {
18942
 
                                if ( pEchoChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
18943
 
                                {
18944
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
18945
 
                                                                                                                                          pEchoChanEntry->usSinTsstIndex,
18946
 
                                                                                                                                          pEchoChanEntry->usSinSoutTsiMemIndex,
18947
 
                                                                                                                                          pEchoChanEntry->TdmConfig.bySinPcmLaw );
18948
 
                                        if ( ulResult != cOCT6100_ERR_OK )
18949
 
                                                return ulResult;
18950
 
                                }
18951
 
 
18952
 
                                /* If the silence TSI is loaded on this port, update with the original sin TSI. */
18953
 
                                if ( pEchoChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX )
18954
 
                                {
18955
 
                                        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18956
 
 
18957
 
                                        WriteParams.ulWriteAddress += 2;
18958
 
                                        WriteParams.usWriteData = pEchoChanEntry->usSinSoutTsiMemIndex;
18959
 
 
18960
 
                                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18961
 
                                        if ( ulResult != cOCT6100_ERR_OK )
18962
 
                                                return ulResult;
18963
 
                                }
18964
 
                        }
18965
 
                        /* Set the event entries as free. */
18966
 
                        pLoadEventEntry->fReserved              = FALSE;
18967
 
                        pLoadEventEntry->usEventType    = cOCT6100_INVALID_INDEX;
18968
 
                        pLoadEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
18969
 
 
18970
 
                        pSubStoreEventEntry->fReserved          = FALSE;
18971
 
                        pSubStoreEventEntry->usEventType        = cOCT6100_INVALID_INDEX;
18972
 
                        pSubStoreEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
18973
 
 
18974
 
                        if ( pCopyEventEntry != NULL )
18975
 
                        {
18976
 
                                pCopyEventEntry->fReserved              = FALSE;
18977
 
                                pCopyEventEntry->usEventType    = cOCT6100_INVALID_INDEX;
18978
 
                                pCopyEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
18979
 
                        }
18980
 
 
18981
 
                        pBridgeEntry->usNumClients--;
18982
 
 
18983
 
                        /*=======================================================================*/
18984
 
                        /* Update the event and channel API structure */
18985
 
                        pEchoChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
18986
 
                        pEchoChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX;
18987
 
                        pEchoChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX;
18988
 
                        pEchoChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
18989
 
 
18990
 
                        /* Indicate that the Extra SIN TSI is not needed anymore by the mixer. */
18991
 
                        if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
18992
 
                        {
18993
 
                                pEchoChanEntry->usExtraSinTsiDependencyCnt--;
18994
 
                                pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
18995
 
                        }
18996
 
 
18997
 
                        /* Update the chip stats structure. */
18998
 
                        pSharedInfo->ChipStats.usNumEcChanUsingMixer--;
18999
 
 
19000
 
                        if ( f_fTap == TRUE )
19001
 
                        {
19002
 
                                /* Can now close the bridge. */
19003
 
                                tOCT6100_CONF_BRIDGE_CLOSE      BridgeClose;
19004
 
 
19005
 
                                Oct6100ConfBridgeCloseDef( &BridgeClose );
19006
 
 
19007
 
                                BridgeClose.ulConfBridgeHndl = cOCT6100_HNDL_TAG_CONF_BRIDGE | (pBridgeEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pEchoChanEntry->usTapBridgeIndex;
19008
 
 
19009
 
                                ulResult = Oct6100ConfBridgeCloseSer( f_pApiInstance, &BridgeClose );
19010
 
                                if ( ulResult != cOCT6100_ERR_OK )
19011
 
                                        return ulResult;
19012
 
 
19013
 
                                pEchoChanEntry->usTapBridgeIndex = cOCT6100_INVALID_INDEX;
19014
 
                                pEchoChanEntry->fTap = FALSE;
19015
 
                        }
19016
 
 
19017
 
                        /* Check if the Rin port must be muted. */
19018
 
                        ulResult = Oct6100ApiMutePorts( 
19019
 
                                                                        f_pApiInstance, 
19020
 
                                                                        f_usChanIndex, 
19021
 
                                                                        pEchoChanEntry->usRinTsstIndex, 
19022
 
                                                                        pEchoChanEntry->usSinTsstIndex,
19023
 
                                                                        FALSE );
19024
 
                        if ( ulResult != cOCT6100_ERR_OK )
19025
 
                                return ulResult;
19026
 
 
19027
 
                        /*=======================================================================*/
19028
 
                }
19029
 
                else /* f_ulBridgeChanRemove->fRemoveAll == TRUE ) */
19030
 
                {
19031
 
                        UINT16 usNextEventPtr;
19032
 
 
19033
 
                        /* Save the next event pointer before invalidating everything. */
19034
 
                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, pBridgeEntry->usLastSubStoreEventPtr );
19035
 
 
19036
 
                        usNextEventPtr = pSubStoreEventEntry->usNextEventPtr;
19037
 
 
19038
 
                        /* Search through the list of API channel entry for the ones on to the specified bridge. */
19039
 
                        for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i++ )
19040
 
                        {
19041
 
                                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i );
19042
 
                                
19043
 
                                if ( pEchoChanEntry->fReserved == TRUE )
19044
 
                                {
19045
 
                                        if ( ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) && ( pEchoChanEntry->fTap == FALSE ) )
19046
 
                                        {
19047
 
                                                /* Check if we are being tapped.  If so, remove the channel that taps us from the conference. */
19048
 
                                                /* The removal of the channel will make sure the Rin TSST is re-assigned. */
19049
 
                                                if ( pEchoChanEntry->fBeingTapped == TRUE )
19050
 
                                                {
19051
 
                                                        tOCT6100_CONF_BRIDGE_CHAN_REMOVE        ChanRemove;
19052
 
 
19053
 
                                                        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, pEchoChanEntry->usTapChanIndex );
19054
 
 
19055
 
                                                        ulResult = Oct6100ConfBridgeChanRemoveDef( &ChanRemove );
19056
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
19057
 
                                                                return ulResult;
19058
 
                                                        
19059
 
                                                        ChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pTempEchoChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pEchoChanEntry->usTapChanIndex;
19060
 
 
19061
 
                                                        ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &ChanRemove );
19062
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
19063
 
                                                                return ulResult;
19064
 
                                                }
19065
 
                                        
19066
 
                                                /*=======================================================================*/
19067
 
                                                /* Clear the Load event. */
19068
 
                                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usLoadEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19069
 
                                                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
19070
 
 
19071
 
                                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19072
 
                                                if ( ulResult != cOCT6100_ERR_OK )
19073
 
                                                        return ulResult;
19074
 
 
19075
 
                                                /*=======================================================================*/
19076
 
                                                
19077
 
                                                /*=======================================================================*/
19078
 
                                                /* Clear the Substract and store event. */
19079
 
                                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSubStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19080
 
                                                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
19081
 
                                                
19082
 
                                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19083
 
                                                if ( ulResult != cOCT6100_ERR_OK )
19084
 
                                                        return ulResult;
19085
 
                                                /*=======================================================================*/
19086
 
 
19087
 
                                                /*=======================================================================*/
19088
 
                                                /* Clear the SIN copy event.*/
19089
 
                                                
19090
 
                                                if ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
19091
 
                                                {
19092
 
                                                        /* Transform event into no-operation. */
19093
 
                                                        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19094
 
                                                        WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
19095
 
                                                        
19096
 
                                                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19097
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
19098
 
                                                                return ulResult;
19099
 
 
19100
 
                                                        /* Get a pointer to the event entry. */
19101
 
                                                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, pEchoChanEntry->usSinCopyEventIndex );
19102
 
 
19103
 
                                                        /* Update the next event pointer if required. */
19104
 
                                                        if ( usNextEventPtr == pEchoChanEntry->usSinCopyEventIndex )
19105
 
                                                                usNextEventPtr = pCopyEventEntry->usNextEventPtr;
19106
 
 
19107
 
                                                        /* Now remove the copy event from the event list. */
19108
 
                                                        ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, pEchoChanEntry->usSinCopyEventIndex, cOCT6100_EVENT_TYPE_SIN_COPY );
19109
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
19110
 
                                                                return ulResult;
19111
 
 
19112
 
                                                        /* Clear the copy event created flag. */
19113
 
                                                        pEchoChanEntry->fCopyEventCreated = FALSE;
19114
 
                                                }
19115
 
 
19116
 
                                                /*=======================================================================*/
19117
 
 
19118
 
 
19119
 
                                                /*=======================================================================*/
19120
 
                                                /* Update the event and channel API structure */
19121
 
 
19122
 
                                                /* Reprogram the TSST entry correctly if the Extra SIN TSI entry was released.*/
19123
 
                                                if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
19124
 
                                                {
19125
 
                                                        if ( pEchoChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
19126
 
                                                        {
19127
 
                                                                ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
19128
 
                                                                                                                                                                  pEchoChanEntry->usSinTsstIndex,
19129
 
                                                                                                                                                                  pEchoChanEntry->usSinSoutTsiMemIndex,
19130
 
                                                                                                                                                                  pEchoChanEntry->TdmConfig.bySinPcmLaw );
19131
 
                                                                if ( ulResult != cOCT6100_ERR_OK )
19132
 
                                                                        return ulResult;
19133
 
                                                        }
19134
 
 
19135
 
                                                        /* If the silence TSI is loaded on this port, update with the original Sin TSI. */
19136
 
                                                        if ( pEchoChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX )
19137
 
                                                        {
19138
 
                                                                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19139
 
 
19140
 
                                                                WriteParams.ulWriteAddress += 2;
19141
 
                                                                WriteParams.usWriteData = pEchoChanEntry->usSinSoutTsiMemIndex;
19142
 
 
19143
 
                                                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19144
 
                                                                if ( ulResult != cOCT6100_ERR_OK )
19145
 
                                                                        return ulResult;
19146
 
                                                        }
19147
 
                                                }
19148
 
 
19149
 
                                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, pEchoChanEntry->usLoadEventIndex );
19150
 
                                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, pEchoChanEntry->usSubStoreEventIndex );
19151
 
 
19152
 
                                                /* Set the event entries as free. */
19153
 
                                                pLoadEventEntry->fReserved              = FALSE;
19154
 
                                                pLoadEventEntry->usEventType    = cOCT6100_INVALID_EVENT;
19155
 
                                                pLoadEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
19156
 
 
19157
 
                                                pSubStoreEventEntry->fReserved          = FALSE;
19158
 
                                                pSubStoreEventEntry->usEventType        = cOCT6100_INVALID_EVENT;
19159
 
                                                pSubStoreEventEntry->usNextEventPtr     = cOCT6100_INVALID_INDEX;
19160
 
 
19161
 
                                                if ( pCopyEventEntry != NULL )
19162
 
                                                {
19163
 
                                                        pCopyEventEntry->fReserved              = FALSE;
19164
 
                                                        pCopyEventEntry->usEventType    = cOCT6100_INVALID_EVENT;
19165
 
                                                        pCopyEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
19166
 
                                                }
19167
 
 
19168
 
                                                /* Indicate that the Extra SIN TSI is not needed anymore by the mixer. */
19169
 
                                                if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
19170
 
                                                {
19171
 
                                                        pEchoChanEntry->usExtraSinTsiDependencyCnt--;
19172
 
                                                        pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
19173
 
                                                }
19174
 
 
19175
 
                                                /* Invalidate the channel entry. */
19176
 
                                                pEchoChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX;
19177
 
                                                pEchoChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX;
19178
 
                                                pEchoChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
19179
 
 
19180
 
                                                /* Update the chip stats structure. */
19181
 
                                                pSharedInfo->ChipStats.usNumEcChanUsingMixer--;
19182
 
 
19183
 
                                                /*=======================================================================*/
19184
 
                                        }
19185
 
                                }
19186
 
                        }
19187
 
                
19188
 
                        ulResult = Oct6100ApiGetPrevLastSubStoreEvent( f_pApiInstance, f_usBridgeIndex, pBridgeEntry->usFirstLoadEventPtr, &usPreviousEventIndex );
19189
 
                        if ( ulResult != cOCT6100_ERR_OK )
19190
 
                        {
19191
 
                                if ( cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND == ulResult )
19192
 
                                {
19193
 
                                        if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
19194
 
                                        {
19195
 
                                                usPreviousEventIndex = cOCT6100_MIXER_HEAD_NODE;
19196
 
                                        }
19197
 
                                        else
19198
 
                                        {
19199
 
                                                usPreviousEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
19200
 
                                        }
19201
 
                                }
19202
 
                                else
19203
 
                                {
19204
 
                                        return cOCT6100_ERR_FATAL_28;
19205
 
                                }
19206
 
                        }
19207
 
 
19208
 
                        /* An Entry was found, now, modify it's value. */
19209
 
                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex );
19210
 
 
19211
 
                        /* Now modify the previous last Sub Store event from another bridge.*/
19212
 
                        /* It will now point at the next bridge, or copy events. */
19213
 
                        pTempEntry->usNextEventPtr = usNextEventPtr;
19214
 
 
19215
 
                        /*=======================================================================*/
19216
 
                        /* Modify the last node of the other bridge. */
19217
 
                        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19218
 
                        WriteParams.ulWriteAddress += 4;
19219
 
 
19220
 
                        WriteParams.usWriteData = pTempEntry->usNextEventPtr;
19221
 
                        
19222
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19223
 
                        if ( ulResult != cOCT6100_ERR_OK )
19224
 
                                return ulResult;
19225
 
                        /*=======================================================================*/
19226
 
                        
19227
 
                        /*=======================================================================*/
19228
 
                        /* Update the global mixer pointers. */
19229
 
                        if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == pBridgeEntry->usFirstLoadEventPtr &&
19230
 
                                 pSharedInfo->MixerInfo.usLastBridgeEventPtr  == pBridgeEntry->usLastSubStoreEventPtr )
19231
 
                        {
19232
 
                                /* This bridge was the only one with event in the list. */
19233
 
                                pSharedInfo->MixerInfo.usFirstBridgeEventPtr = cOCT6100_INVALID_INDEX;
19234
 
                                pSharedInfo->MixerInfo.usLastBridgeEventPtr  = cOCT6100_INVALID_INDEX;
19235
 
                        }
19236
 
                        else if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == pBridgeEntry->usFirstLoadEventPtr )
19237
 
                        {
19238
 
                                /* This bridge was the first bridge. */
19239
 
                                pSharedInfo->MixerInfo.usFirstBridgeEventPtr = usNextEventPtr;
19240
 
                        }
19241
 
                        else if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == pBridgeEntry->usLastSubStoreEventPtr )
19242
 
                        {
19243
 
                                /* This bridge was the last bridge.*/
19244
 
                                pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex;
19245
 
                        }
19246
 
                        /*=======================================================================*/
19247
 
 
19248
 
                        /* Set the event pointer info in the bridge stucture. */
19249
 
                        pBridgeEntry->usFirstLoadEventPtr = cOCT6100_INVALID_INDEX;
19250
 
                        pBridgeEntry->usFirstSubStoreEventPtr = cOCT6100_INVALID_INDEX;
19251
 
                        pBridgeEntry->usLastSubStoreEventPtr = cOCT6100_INVALID_INDEX;
19252
 
                        pBridgeEntry->usLoadIndex = cOCT6100_INVALID_INDEX;
19253
 
 
19254
 
                        pBridgeEntry->usSilenceLoadEventPtr = cOCT6100_INVALID_INDEX;
19255
 
 
19256
 
                        /* Set the number of clients to 0. */
19257
 
                        pBridgeEntry->usNumClients = 0;
19258
 
 
19259
 
                        /* Search through the list of API channel entry for the ones on to the specified bridge. */
19260
 
                        for ( i = 0; i < pSharedInfo->ChipConfig.usMaxChannels; i++ )
19261
 
                        {
19262
 
                                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i );
19263
 
                                
19264
 
                                if ( pEchoChanEntry->fReserved == TRUE )
19265
 
                                {
19266
 
                                        if ( ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) && ( pEchoChanEntry->fTap == FALSE ) )
19267
 
                                        {
19268
 
                                                pEchoChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
19269
 
 
19270
 
                                                /* Check if the Rin port must be muted. */
19271
 
                                                ulResult = Oct6100ApiMutePorts( 
19272
 
                                                                                                f_pApiInstance, 
19273
 
                                                                                                (UINT16)( i & 0xFFFF ), 
19274
 
                                                                                                pEchoChanEntry->usRinTsstIndex, 
19275
 
                                                                                                pEchoChanEntry->usSinTsstIndex,
19276
 
                                                                                                FALSE );
19277
 
                                                if ( ulResult != cOCT6100_ERR_OK )
19278
 
                                                        return ulResult;
19279
 
                                        }
19280
 
                                }
19281
 
                        }
19282
 
                }
19283
 
        }
19284
 
 
19285
 
        return cOCT6100_ERR_OK;
19286
 
}
19287
 
 
19288
 
 
19289
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
19290
 
 
19291
 
Function:               Oct6100ApiBridgeRemoveParticipantFromChannel
19292
 
 
19293
 
Description:    This will remove a flexible conference participant from
19294
 
                                a channel.
19295
 
 
19296
 
-------------------------------------------------------------------------------
19297
 
|       Argument                |       Description
19298
 
-------------------------------------------------------------------------------
19299
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
19300
 
                                                        present state of the chip and all its resources.
19301
 
f_usBridgeIndex                         Bridge index where this channel is located.
19302
 
f_usSourceChannelIndex          Source channel to copy voice from.
19303
 
f_usDestinationChannelIndex     Destination channel to store resulting voice to.
19304
 
f_fRemovePermanently            Whether to remove permanently this participant.
19305
 
 
19306
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
19307
 
static UINT32 Oct6100ApiBridgeRemoveParticipantFromChannel(
19308
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance, 
19309
 
                                IN              UINT16                                  f_usBridgeIndex,
19310
 
                                IN              UINT16                                  f_usSourceChannelIndex,
19311
 
                                IN              UINT16                                  f_usDestinationChannelIndex,
19312
 
                                IN              UINT8                                   f_fRemovePermanently )
19313
 
{
19314
 
        tPOCT6100_API_CONF_BRIDGE                       pBridgeEntry;
19315
 
 
19316
 
        tPOCT6100_API_MIXER_EVENT                       pLoadEventEntry;
19317
 
        tPOCT6100_API_MIXER_EVENT                       pStoreEventEntry;
19318
 
        tPOCT6100_API_MIXER_EVENT                       pCopyEventEntry;
19319
 
        tPOCT6100_API_MIXER_EVENT                       pTempEntry;
19320
 
        tPOCT6100_API_MIXER_EVENT                       pLoadTempEntry;
19321
 
        tPOCT6100_API_MIXER_EVENT                       pLastEventEntry;
19322
 
        tPOCT6100_API_MIXER_EVENT                       pLastLoadOrAccumulateEventEntry;
19323
 
 
19324
 
        tPOCT6100_API_CHANNEL                           pSourceChanEntry;
19325
 
        tPOCT6100_API_CHANNEL                           pDestinationChanEntry;
19326
 
 
19327
 
        tPOCT6100_API_FLEX_CONF_PARTICIPANT     pSourceParticipant;
19328
 
        tPOCT6100_API_FLEX_CONF_PARTICIPANT     pDestinationParticipant;
19329
 
 
19330
 
        tPOCT6100_SHARED_INFO                           pSharedInfo;
19331
 
        tOCT6100_WRITE_PARAMS                           WriteParams;
19332
 
        tOCT6100_READ_PARAMS                            ReadParams;
19333
 
 
19334
 
        UINT32                                                          ulResult;
19335
 
        UINT32                                                          ulLoopCount;
19336
 
        UINT16                                                          usLastLoadEventIndex;
19337
 
        UINT16                                                          usLoadOrAccumulateEventIndex;
19338
 
        UINT16                                                          usTempEventIndex;
19339
 
        UINT16                                                          usPreviousEventIndex;
19340
 
        UINT16                                                          usLastEventIndex;
19341
 
 
19342
 
        UINT16                                                          usReadData;
19343
 
        BOOL                                                            fLastEvent = FALSE;
19344
 
        BOOL                                                            fSoutCopyEvent = FALSE;
19345
 
 
19346
 
        /* Obtain local pointer to shared portion of instance. */
19347
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
19348
 
        
19349
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
19350
 
 
19351
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
19352
 
 
19353
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
19354
 
 
19355
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
19356
 
        ReadParams.pusReadData = &usReadData;
19357
 
 
19358
 
        mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, f_usBridgeIndex );
19359
 
 
19360
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pSourceChanEntry, f_usSourceChannelIndex );
19361
 
        mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pSourceParticipant, pSourceChanEntry->usFlexConfParticipantIndex );
19362
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pDestinationChanEntry, f_usDestinationChannelIndex );
19363
 
        mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pDestinationParticipant, pDestinationChanEntry->usFlexConfParticipantIndex );
19364
 
 
19365
 
        /* Check if the mixer has been created on this channel. */
19366
 
        if ( pDestinationParticipant->fFlexibleMixerCreated == TRUE )
19367
 
        {
19368
 
                /*=======================================================================*/
19369
 
                /* Clear the Load or Accumulate event.*/
19370
 
 
19371
 
                usTempEventIndex = pDestinationChanEntry->usLoadEventIndex;
19372
 
                ulLoopCount = 0;
19373
 
 
19374
 
                /* Find the Load or Accumulate event entry. */
19375
 
                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, usTempEventIndex );
19376
 
                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pStoreEventEntry, pDestinationChanEntry->usSubStoreEventIndex );
19377
 
                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex );
19378
 
 
19379
 
                pLastEventEntry = pLoadEventEntry;
19380
 
                pLastLoadOrAccumulateEventEntry = pLoadEventEntry;
19381
 
                usLastLoadEventIndex = usTempEventIndex;
19382
 
                usLastEventIndex = usTempEventIndex;
19383
 
 
19384
 
                while( pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_SUB_STORE && 
19385
 
                           pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_STORE )
19386
 
                {
19387
 
                        /* If this is the entry we are looking for. */
19388
 
                        if ( pTempEntry->usSourceChanIndex == f_usSourceChannelIndex )
19389
 
                        {
19390
 
                                /* Check if this is a Load or Accumulate event. */
19391
 
                                if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_LOAD )
19392
 
                                {
19393
 
                                        /* This is the first entry.  Check if next entry is an accumulate. */
19394
 
                                        pLoadTempEntry = pTempEntry;
19395
 
                                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, pTempEntry->usNextEventPtr );
19396
 
 
19397
 
                                        if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE )
19398
 
                                        {
19399
 
                                                /* Change this entry into a Load event. */
19400
 
                                                ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pLoadTempEntry->usNextEventPtr * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19401
 
                                                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
19402
 
                                                if ( ulResult != cOCT6100_ERR_OK )
19403
 
                                                        return ulResult;
19404
 
 
19405
 
                                                WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
19406
 
                                                WriteParams.usWriteData = (UINT16)(( usReadData & 0x1FFF ) | cOCT6100_MIXER_CONTROL_MEM_LOAD);
19407
 
 
19408
 
                                                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19409
 
                                                if ( ulResult != cOCT6100_ERR_OK )
19410
 
                                                        return ulResult;
19411
 
                                                
19412
 
                                                /* Update the channel information with this new load event. */
19413
 
                                                pDestinationChanEntry->usLoadEventIndex = pLoadTempEntry->usNextEventPtr;
19414
 
 
19415
 
                                                /* Update the software model. */
19416
 
                                                pTempEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_LOAD;
19417
 
 
19418
 
                                                /* Get the previous event. */
19419
 
                                                ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, cOCT6100_MIXER_HEAD_NODE, usTempEventIndex, 0, &usPreviousEventIndex );
19420
 
                                                if ( ulResult != cOCT6100_ERR_OK )
19421
 
                                                        return ulResult;
19422
 
 
19423
 
                                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLastEventEntry, usPreviousEventIndex );
19424
 
                                                usLastEventIndex = usPreviousEventIndex;
19425
 
 
19426
 
                                                /* Stop searching. */
19427
 
                                                break;
19428
 
                                        }
19429
 
                                        else if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_STORE )
19430
 
                                        {
19431
 
                                                /* Get back the event to remove. */
19432
 
                                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex );
19433
 
 
19434
 
                                                /* This is the only event on this channel so we can clear everything up. */
19435
 
                                                fLastEvent = TRUE;
19436
 
 
19437
 
                                                /* Get the previous event. */
19438
 
                                                ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, cOCT6100_MIXER_HEAD_NODE, usTempEventIndex, 0, &usPreviousEventIndex );
19439
 
                                                if ( ulResult != cOCT6100_ERR_OK )
19440
 
                                                        return ulResult;
19441
 
 
19442
 
                                                mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLastEventEntry, usPreviousEventIndex );
19443
 
                                                usLastEventIndex = usPreviousEventIndex;
19444
 
 
19445
 
                                                /* Stop searching. */
19446
 
                                                break;
19447
 
                                        }
19448
 
                                        else
19449
 
                                        {
19450
 
                                                /* Software model is broken. */
19451
 
                                                return cOCT6100_ERR_FATAL_C5;
19452
 
                                        }
19453
 
                                        
19454
 
                                }
19455
 
                                else if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE )
19456
 
                                {
19457
 
                                        /* Simply remove the entry. */
19458
 
 
19459
 
                                        /* Get the previous event. */
19460
 
                                        ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, cOCT6100_MIXER_HEAD_NODE, usTempEventIndex, 0, &usPreviousEventIndex );
19461
 
                                        if ( ulResult != cOCT6100_ERR_OK )
19462
 
                                                return ulResult;
19463
 
 
19464
 
                                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLastEventEntry, usPreviousEventIndex );
19465
 
                                        usLastEventIndex = usPreviousEventIndex;
19466
 
 
19467
 
                                        /* Stop searching. */
19468
 
                                        break;
19469
 
                                }
19470
 
                                else
19471
 
                                {
19472
 
                                        /* Software model is broken. */
19473
 
                                        return cOCT6100_ERR_FATAL_C6;
19474
 
                                }
19475
 
                        }
19476
 
 
19477
 
                        pLastLoadOrAccumulateEventEntry = pTempEntry;
19478
 
                        usLastLoadEventIndex = usTempEventIndex;
19479
 
 
19480
 
                        /* Go to the next entry into the list. */
19481
 
                        usTempEventIndex = pTempEntry->usNextEventPtr;
19482
 
                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex );
19483
 
 
19484
 
                        ulLoopCount++;
19485
 
                        if ( ulLoopCount == cOCT6100_MAX_LOOP )
19486
 
                                return cOCT6100_ERR_FATAL_C8;
19487
 
                }
19488
 
 
19489
 
                /* Check if we found what we were looking for. */
19490
 
                if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_STORE 
19491
 
                        || pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_SUB_STORE )
19492
 
                {
19493
 
                        /* Software model is broken. */
19494
 
                        return cOCT6100_ERR_FATAL_C7;
19495
 
                }
19496
 
 
19497
 
                /*=======================================================================*/
19498
 
 
19499
 
 
19500
 
                /*=======================================================================*/
19501
 
                /* Clear the Store event - if needed. */
19502
 
 
19503
 
                if ( fLastEvent == TRUE )
19504
 
                {
19505
 
                        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pDestinationChanEntry->usSubStoreEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19506
 
                        WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
19507
 
                        
19508
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19509
 
                        if ( ulResult != cOCT6100_ERR_OK )
19510
 
                                return ulResult;
19511
 
                }
19512
 
 
19513
 
                /*=======================================================================*/
19514
 
 
19515
 
 
19516
 
                /*=======================================================================*/
19517
 
                /* Clear the Load or Accumulate event. */
19518
 
 
19519
 
                WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19520
 
                WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
19521
 
 
19522
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19523
 
                if ( ulResult != cOCT6100_ERR_OK )
19524
 
                        return ulResult;
19525
 
 
19526
 
                /* Save this event index.  It's the Load or Accumulate we want to remove from the list later. */
19527
 
                usLoadOrAccumulateEventIndex = usTempEventIndex;
19528
 
 
19529
 
                /*=======================================================================*/
19530
 
 
19531
 
 
19532
 
                /*=======================================================================*/
19533
 
                /* Clear the Copy event - if needed. */
19534
 
                
19535
 
                if ( ( fLastEvent == TRUE ) && ( pDestinationChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) && ( f_fRemovePermanently == TRUE ) )
19536
 
                {
19537
 
                        /* Transform event into no-operation. */
19538
 
                        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pDestinationChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19539
 
                        WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
19540
 
 
19541
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19542
 
                        if ( ulResult != cOCT6100_ERR_OK )
19543
 
                                return ulResult;
19544
 
 
19545
 
                        /* The event remove from the list will be done below. */
19546
 
 
19547
 
                        /* Clear the copy event created flag. */
19548
 
                        pDestinationChanEntry->fCopyEventCreated = FALSE;
19549
 
                }
19550
 
 
19551
 
                /*=======================================================================*/
19552
 
 
19553
 
 
19554
 
                /*=======================================================================*/
19555
 
                /*=======================================================================*/
19556
 
                /* Remove the events from the mixer event list.*/
19557
 
                /*=======================================================================*/
19558
 
                /*=======================================================================*/
19559
 
 
19560
 
                /*=======================================================================*/
19561
 
                /* Remove the Load or Accumulate event from the event list. */
19562
 
                
19563
 
                if ( fLastEvent == FALSE )
19564
 
                {
19565
 
                        /*=======================================================================*/
19566
 
                        /* Remove the Accumulate event from the event list. */
19567
 
 
19568
 
                        /* We saved the Load or Accumulate event above.  We also saved the previous event.  Use those. */
19569
 
                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, usLoadOrAccumulateEventIndex );
19570
 
                        
19571
 
                        /* Now modify the previous last event. */
19572
 
                        pLastEventEntry->usNextEventPtr = pLoadEventEntry->usNextEventPtr;
19573
 
 
19574
 
                        /* Modify the previous node. */
19575
 
                        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usLastEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19576
 
                        WriteParams.ulWriteAddress += 4;
19577
 
 
19578
 
                        WriteParams.usWriteData = pLastEventEntry->usNextEventPtr;
19579
 
                        
19580
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19581
 
                        if ( ulResult != cOCT6100_ERR_OK )
19582
 
                                return ulResult;
19583
 
                        
19584
 
                        /* Check if this is the first load event on the bridge. */
19585
 
                        if ( pBridgeEntry->usFirstLoadEventPtr == usLoadOrAccumulateEventIndex )
19586
 
                        {
19587
 
                                pBridgeEntry->usFirstLoadEventPtr = pLoadEventEntry->usNextEventPtr;
19588
 
                        }
19589
 
 
19590
 
                        /* Check if this was the first load of all bridges. */
19591
 
                        if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == usLoadOrAccumulateEventIndex )
19592
 
                        {
19593
 
                                pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pLoadEventEntry->usNextEventPtr;
19594
 
                        }
19595
 
 
19596
 
                        /*=======================================================================*/
19597
 
                }
19598
 
                else /* if ( fLastEvent == TRUE ) */
19599
 
                {
19600
 
                        /*=======================================================================*/
19601
 
                        /* Remove the Load event from the event list. */
19602
 
 
19603
 
                        /* Look for the entry that is pointing at the first entry of our mixer. */
19604
 
                        ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, cOCT6100_MIXER_HEAD_NODE, usLoadOrAccumulateEventIndex, 0, &usPreviousEventIndex );
19605
 
                        if ( ulResult != cOCT6100_ERR_OK )
19606
 
                                return ulResult;
19607
 
 
19608
 
                        /* An Entry was found, now, modify it's value. */
19609
 
                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex );
19610
 
 
19611
 
                        /* Check if this is a Sout copy event. */
19612
 
                        if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_COPY )
19613
 
                        {
19614
 
                                /* No more previous bridges. */
19615
 
                                fSoutCopyEvent = TRUE;
19616
 
                        }
19617
 
 
19618
 
                        /* Now modify the previous last Store or Sub-Store or Head-Node event from another bridge/channel. */
19619
 
                        pTempEntry->usNextEventPtr = pStoreEventEntry->usNextEventPtr;
19620
 
 
19621
 
                        /*=======================================================================*/
19622
 
 
19623
 
 
19624
 
                        /*=======================================================================*/
19625
 
                        /* Modify the last node of the previous bridge/channel to point to the next bridge. */
19626
 
 
19627
 
                        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19628
 
                        WriteParams.ulWriteAddress += 4;
19629
 
 
19630
 
                        WriteParams.usWriteData = pTempEntry->usNextEventPtr;
19631
 
                        
19632
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19633
 
                        if ( ulResult != cOCT6100_ERR_OK )
19634
 
                                return ulResult;
19635
 
 
19636
 
                        /*=======================================================================*/
19637
 
                        
19638
 
                        
19639
 
                        /*=======================================================================*/
19640
 
                        /* Set the event pointer info in the bridge stucture. */
19641
 
 
19642
 
                        if ( pBridgeEntry->usFirstLoadEventPtr == pDestinationChanEntry->usLoadEventIndex )
19643
 
                        {
19644
 
                                UINT16                                  usChannelIndex;
19645
 
                                tPOCT6100_API_CHANNEL   pTempEchoChanEntry;
19646
 
 
19647
 
                                pBridgeEntry->usFirstSubStoreEventPtr = cOCT6100_INVALID_INDEX;
19648
 
                                pBridgeEntry->usFirstLoadEventPtr = cOCT6100_INVALID_INDEX;
19649
 
 
19650
 
                                /* Find the next channel in this conference that could give us valid values. */
19651
 
                                for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ )
19652
 
                                {
19653
 
                                        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
19654
 
 
19655
 
                                        if ( ( usChannelIndex != f_usDestinationChannelIndex ) && ( pTempEchoChanEntry->fReserved == TRUE ) )
19656
 
                                        {
19657
 
                                                if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
19658
 
                                                {
19659
 
                                                        tPOCT6100_API_FLEX_CONF_PARTICIPANT     pTempParticipant;
19660
 
 
19661
 
                                                        mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
19662
 
 
19663
 
                                                        if ( pTempParticipant->fFlexibleMixerCreated == TRUE )
19664
 
                                                        {
19665
 
                                                                pBridgeEntry->usFirstSubStoreEventPtr = pTempEchoChanEntry->usSubStoreEventIndex;
19666
 
                                                                pBridgeEntry->usFirstLoadEventPtr = pTempEchoChanEntry->usLoadEventIndex;
19667
 
                                                                break;
19668
 
                                                        }
19669
 
                                                }
19670
 
                                        }
19671
 
                                }
19672
 
                        }
19673
 
 
19674
 
                        /* Reprogram the TSST entry correctly if the extra SIN TSI entry was released. */
19675
 
                        if ( ( pDestinationChanEntry->usExtraSinTsiDependencyCnt == 1 ) && ( f_fRemovePermanently == TRUE ) )
19676
 
                        {
19677
 
                                if ( pDestinationChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
19678
 
                                {
19679
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
19680
 
                                                                                                                                          pDestinationChanEntry->usSinTsstIndex,
19681
 
                                                                                                                                          pDestinationChanEntry->usSinSoutTsiMemIndex,
19682
 
                                                                                                                                          pDestinationChanEntry->TdmConfig.bySinPcmLaw );
19683
 
                                        if ( ulResult != cOCT6100_ERR_OK )
19684
 
                                                return ulResult;
19685
 
                                }
19686
 
 
19687
 
                                /* If the silence TSI is loaded on this port, update with the original sin TSI. */
19688
 
                                if ( pDestinationChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX )
19689
 
                                {
19690
 
                                        WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pDestinationChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19691
 
 
19692
 
                                        WriteParams.ulWriteAddress += 2;
19693
 
                                        WriteParams.usWriteData = pDestinationChanEntry->usSinSoutTsiMemIndex;
19694
 
 
19695
 
                                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19696
 
                                        if ( ulResult != cOCT6100_ERR_OK )
19697
 
                                                return ulResult;
19698
 
                                }
19699
 
                        }
19700
 
 
19701
 
                        /* Reprogram the TSST entry correctly if the extra RIN TSI entry was released. */
19702
 
                        if ( ( pDestinationChanEntry->usExtraRinTsiDependencyCnt == 1 ) && ( f_fRemovePermanently == TRUE ) )
19703
 
                        {
19704
 
                                if ( pDestinationChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
19705
 
                                {
19706
 
                                        ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
19707
 
                                                                                                                                          pDestinationChanEntry->usRinTsstIndex,
19708
 
                                                                                                                                          pDestinationChanEntry->usRinRoutTsiMemIndex,
19709
 
                                                                                                                                          pDestinationChanEntry->TdmConfig.byRinPcmLaw );
19710
 
                                        if ( ulResult != cOCT6100_ERR_OK )
19711
 
                                                return ulResult;
19712
 
                                }
19713
 
                        }
19714
 
 
19715
 
                        /*=======================================================================*/
19716
 
                        /* Update the global mixer pointers. */
19717
 
 
19718
 
                        if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == usLoadOrAccumulateEventIndex &&
19719
 
                                 pSharedInfo->MixerInfo.usLastBridgeEventPtr  == pDestinationChanEntry->usSubStoreEventIndex )
19720
 
                        {
19721
 
                                /* There is no more bridge entry in the mixer link list. */
19722
 
                                pSharedInfo->MixerInfo.usFirstBridgeEventPtr = cOCT6100_INVALID_INDEX;
19723
 
                                pSharedInfo->MixerInfo.usLastBridgeEventPtr  = cOCT6100_INVALID_INDEX;
19724
 
                        }
19725
 
                        else if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == usLoadOrAccumulateEventIndex )
19726
 
                        {
19727
 
                                pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pStoreEventEntry->usNextEventPtr;
19728
 
                        }
19729
 
                        else if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == pDestinationChanEntry->usSubStoreEventIndex )
19730
 
                        {
19731
 
                                pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex;
19732
 
                        }
19733
 
 
19734
 
                        /*=======================================================================*/
19735
 
 
19736
 
 
19737
 
                        /*=======================================================================*/
19738
 
                        /* Check if must remove the Sin copy event from the list. */
19739
 
 
19740
 
                        if ( ( pDestinationChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) && ( f_fRemovePermanently == TRUE ) )
19741
 
                        {
19742
 
                                /* Now remove the copy event from the event list. */
19743
 
                                ulResult = Oct6100ApiMixerEventRemove( f_pApiInstance, pDestinationChanEntry->usSinCopyEventIndex, cOCT6100_EVENT_TYPE_SIN_COPY );
19744
 
                                if ( ulResult != cOCT6100_ERR_OK )
19745
 
                                        return ulResult;
19746
 
                        }
19747
 
 
19748
 
                        /*=======================================================================*/
19749
 
 
19750
 
 
19751
 
 
19752
 
                        /*=======================================================================*/
19753
 
 
19754
 
                        if ( f_fRemovePermanently == TRUE )
19755
 
                        {
19756
 
                                /* Set the event entries as free. */
19757
 
                                pLoadEventEntry->fReserved              = FALSE;
19758
 
                                pLoadEventEntry->usEventType    = cOCT6100_INVALID_EVENT;
19759
 
                                pLoadEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
19760
 
 
19761
 
                                pStoreEventEntry->fReserved             = FALSE;
19762
 
                                pStoreEventEntry->usEventType   = cOCT6100_INVALID_EVENT;
19763
 
                                pStoreEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
19764
 
 
19765
 
                                if ( pDestinationChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
19766
 
                                {
19767
 
                                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, pDestinationChanEntry->usSinCopyEventIndex );
19768
 
                                        
19769
 
                                        pCopyEventEntry->fReserved              = FALSE;
19770
 
                                        pCopyEventEntry->usEventType    = cOCT6100_INVALID_EVENT;
19771
 
                                        pCopyEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
19772
 
                                }
19773
 
                        }
19774
 
 
19775
 
                        /* Flexible mixer for this channel not created anymore. */
19776
 
                        pDestinationParticipant->fFlexibleMixerCreated = FALSE;
19777
 
 
19778
 
                        /*=======================================================================*/
19779
 
                }
19780
 
 
19781
 
                /*=======================================================================*/
19782
 
        }
19783
 
        else /* if ( pDestinationChanEntry->fFlexibleMixerCreated == FALSE ) */
19784
 
        {
19785
 
                /* This point should never be reached. */
19786
 
                return cOCT6100_ERR_FATAL_C9;
19787
 
        }
19788
 
 
19789
 
        return cOCT6100_ERR_OK;
19790
 
}
19791
 
 
19792
 
 
19793
 
 
19794
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
19795
 
 
19796
 
Function:               Oct6100ApiReleaseBridgeEntry
19797
 
 
19798
 
Description:    Release an entry from the bridge list.
19799
 
 
19800
 
-------------------------------------------------------------------------------
19801
 
|       Argument                |       Description
19802
 
-------------------------------------------------------------------------------
19803
 
f_pApiInstance          Pointer to API instance. This memory is used to keep the
19804
 
                                        present state of the chip and all its resources.
19805
 
 
19806
 
f_usBridgeIndex         List entry reserved.
19807
 
 
19808
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
19809
 
static UINT32 Oct6100ApiReleaseBridgeEntry(
19810
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
19811
 
                                IN              UINT16                                                  f_usBridgeIndex )
19812
 
{
19813
 
        PVOID   pBridgeAlloc;
19814
 
        UINT32  ulResult;
19815
 
 
19816
 
        mOCT6100_GET_CONF_BRIDGE_ALLOC_PNT( f_pApiInstance->pSharedInfo, pBridgeAlloc )
19817
 
 
19818
 
        ulResult = OctapiLlmAllocDealloc( pBridgeAlloc, f_usBridgeIndex );
19819
 
        if ( ulResult != cOCT6100_ERR_OK )
19820
 
                return cOCT6100_ERR_FATAL_2A;
19821
 
 
19822
 
        return cOCT6100_ERR_OK;
19823
 
}
19824
 
 
19825
 
 
19826
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
19827
 
 
19828
 
Function:               Oct6100ApiGetPrevLastSubStoreEvent
19829
 
 
19830
 
Description:    This function will search for the first valid LastSubStoreEvent 
19831
 
                                in a bridge located before the current bridge in the bridge 
19832
 
                                link list.
19833
 
                                
19834
 
                                If the function does not find an event before reaching the end
19835
 
                                of the mixers list, then the event head node will be used as the
19836
 
                                last Store or SubStore event.
19837
 
 
19838
 
-------------------------------------------------------------------------------
19839
 
|       Argument                |       Description
19840
 
-------------------------------------------------------------------------------
19841
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
19842
 
                                                        present state of the chip and all its resources.
19843
 
 
19844
 
f_pusBridgeEntry                        Bridge entry.
19845
 
f_usBridgeFirstLoadEventPtr     Load index to check against.
19846
 
First                                           valid sub store index.
19847
 
 
19848
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
19849
 
static UINT32 Oct6100ApiGetPrevLastSubStoreEvent(
19850
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
19851
 
                                IN              UINT16                                                  f_usBridgeIndex,
19852
 
                                IN              UINT16                                                  f_usBridgeFirstLoadEventPtr,
19853
 
                                OUT             PUINT16                                                 f_pusLastSubStoreEventIndex )
19854
 
{
19855
 
        tPOCT6100_API_CONF_BRIDGE       pBridgeEntry;
19856
 
        tPOCT6100_API_MIXER_EVENT       pTempMixerEntry;
19857
 
        UINT16                                          usNextEventPtr;
19858
 
        UINT16                                          usHeadEventPtr;
19859
 
        UINT16                                          usLastSubStoreEventPtr;
19860
 
        UINT32                                          ulLoopCount = 0;
19861
 
        UINT16                                          usCurrentPtr;
19862
 
        UINT32                                          ulResult = cOCT6100_ERR_OK;
19863
 
 
19864
 
        /* Get current entry to obtain the link to the previous entry.*/
19865
 
        mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, f_usBridgeIndex );
19866
 
 
19867
 
        /* Since we have flexible bridges, we have to */
19868
 
        /* run down the list and check for the appropriate event. */
19869
 
 
19870
 
        /* Travel down the list for the last Store or Sub/Store event before the bridge. */
19871
 
 
19872
 
        if ( f_pApiInstance->pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
19873
 
        {
19874
 
                /* The only node in the list then is the head node.*/
19875
 
                usHeadEventPtr = cOCT6100_MIXER_HEAD_NODE;
19876
 
        }
19877
 
        else
19878
 
        {
19879
 
                usHeadEventPtr = f_pApiInstance->pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
19880
 
        }
19881
 
 
19882
 
        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempMixerEntry, usHeadEventPtr );
19883
 
        usLastSubStoreEventPtr = usHeadEventPtr;
19884
 
        usNextEventPtr = pTempMixerEntry->usNextEventPtr;
19885
 
        usCurrentPtr = usHeadEventPtr;
19886
 
        while( usCurrentPtr != f_usBridgeFirstLoadEventPtr )
19887
 
        {
19888
 
                if ( ( pTempMixerEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_STORE )
19889
 
                        || ( pTempMixerEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_SUB_STORE ) )
19890
 
                {
19891
 
                        usLastSubStoreEventPtr = usNextEventPtr;
19892
 
                }
19893
 
 
19894
 
                /* Next pointer. */
19895
 
                usCurrentPtr = usNextEventPtr;
19896
 
                usNextEventPtr = pTempMixerEntry->usNextEventPtr;
19897
 
 
19898
 
                /* Check if next event pointer is valid. */
19899
 
                if ( ( ( f_usBridgeFirstLoadEventPtr != usCurrentPtr ) 
19900
 
                        && ( pTempMixerEntry->usNextEventPtr == cOCT6100_INVALID_INDEX ) )
19901
 
                                || ( pTempMixerEntry->usNextEventPtr == cOCT6100_MIXER_HEAD_NODE ) )
19902
 
                        return cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND;
19903
 
 
19904
 
                if ( usNextEventPtr != cOCT6100_INVALID_INDEX )
19905
 
                        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempMixerEntry, usNextEventPtr );
19906
 
                
19907
 
                ulLoopCount++;
19908
 
                if ( ulLoopCount == cOCT6100_MAX_LOOP )
19909
 
                        return cOCT6100_ERR_FATAL_CA;
19910
 
        }
19911
 
        
19912
 
        /* Return the result to the user. */
19913
 
        *f_pusLastSubStoreEventIndex = usLastSubStoreEventPtr;
19914
 
 
19915
 
        return ulResult;
19916
 
}
19917
 
 
19918
 
 
19919
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
19920
 
 
19921
 
Function:               Oct6100ApiGetPreviousEvent
19922
 
 
19923
 
Description:    This is a recursive function, it requires an entry event index and 
19924
 
                                will run down the list until it finds the node just before the one
19925
 
                                required.
19926
 
 
19927
 
-------------------------------------------------------------------------------
19928
 
|       Argument                |       Description
19929
 
-------------------------------------------------------------------------------
19930
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
19931
 
                                                present state of the chip and all its resources.
19932
 
 
19933
 
f_usEntryIndex                  Event entry index.
19934
 
f_pusBridgeEntry                Bridge entry.
19935
 
f_pusPreviousIndex              Previous index.
19936
 
 
19937
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
19938
 
static UINT32 Oct6100ApiGetPreviousEvent(
19939
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
19940
 
                                IN              UINT16                                                  f_usEntryIndex,
19941
 
                                IN              UINT16                                                  f_usSearchedIndex,
19942
 
                                IN              UINT16                                                  f_usLoopCnt,
19943
 
                                OUT             PUINT16                                                 f_pusPreviousIndex )
19944
 
{
19945
 
        tPOCT6100_API_MIXER_EVENT       pCurrentEntry;
19946
 
        UINT32  ulResult;
19947
 
 
19948
 
        /* Get current entry to obtain the link to the previous entry. */
19949
 
        mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pCurrentEntry, f_usEntryIndex );
19950
 
 
19951
 
        /* Avoid stack overflows. */
19952
 
        if ( f_usLoopCnt == cOCT6100_MAX_MIXER_EVENTS )
19953
 
                return cOCT6100_ERR_FATAL_E3;
19954
 
 
19955
 
        if ( pCurrentEntry->usNextEventPtr == cOCT6100_INVALID_INDEX )
19956
 
        {
19957
 
                /* Event not found. */
19958
 
                ulResult = cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND;
19959
 
        }
19960
 
        else if ( pCurrentEntry->usNextEventPtr == f_usSearchedIndex )
19961
 
        {
19962
 
                /* We found our node. */
19963
 
                *f_pusPreviousIndex = f_usEntryIndex;
19964
 
                ulResult = cOCT6100_ERR_OK; 
19965
 
        }
19966
 
        else
19967
 
        {
19968
 
                /* Keep searching.*/
19969
 
                f_usLoopCnt++;
19970
 
                ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, pCurrentEntry->usNextEventPtr, f_usSearchedIndex, f_usLoopCnt, f_pusPreviousIndex );
19971
 
        }
19972
 
 
19973
 
        return ulResult;
19974
 
}
19975
 
 
19976
 
 
19977
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
19978
 
 
19979
 
Function:               Oct6100ApiBridgeSetDominantSpeaker
19980
 
 
19981
 
Description:    This function will set the index of the dominant speaker
19982
 
                                for the channel index specified.
19983
 
 
19984
 
-------------------------------------------------------------------------------
19985
 
|       Argument                |       Description
19986
 
-------------------------------------------------------------------------------
19987
 
f_pApiInstance                                  Pointer to API instance. This memory is used to 
19988
 
                                                                keep the present state of the chip and all its 
19989
 
                                                                resources.
19990
 
 
19991
 
f_usChannelIndex                                Index of the channel where the API must set the
19992
 
                                                                current dominant speaker for the conference.
19993
 
f_usDominantSpeakerIndex                Index of the channel which is the dominant
19994
 
                                                                speaker in the conference.
19995
 
 
19996
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
19997
 
static UINT32 Oct6100ApiBridgeSetDominantSpeaker(
19998
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
19999
 
                                IN              UINT16                                                  f_usChannelIndex,
20000
 
                                IN              UINT16                                                  f_usDominantSpeakerIndex )
20001
 
{
20002
 
        UINT32  ulBaseAddress;
20003
 
        UINT32  ulFeatureBytesOffset;
20004
 
        UINT32  ulFeatureBitOffset;
20005
 
        UINT32  ulFeatureFieldLength;
20006
 
        UINT32  ulResult;
20007
 
        UINT32  ulTempData;
20008
 
        UINT32  ulMask;
20009
 
 
20010
 
        tPOCT6100_API_CHANNEL   pEchoChanEntry;
20011
 
 
20012
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChanEntry, f_usChannelIndex );
20013
 
 
20014
 
        ulBaseAddress            = cOCT6100_CHANNEL_ROOT_BASE + ( f_usChannelIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanRootConfOfst;
20015
 
        ulFeatureBytesOffset = f_pApiInstance->pSharedInfo->MemoryMap.DominantSpeakerFieldOfst.usDwordOffset * 4;
20016
 
        ulFeatureBitOffset       = f_pApiInstance->pSharedInfo->MemoryMap.DominantSpeakerFieldOfst.byBitOffset;
20017
 
        ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.DominantSpeakerFieldOfst.byFieldSize;
20018
 
 
20019
 
        /* Retrieve the current configuration. */
20020
 
        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
20021
 
                                                                                pEchoChanEntry,
20022
 
                                                                                ulBaseAddress + ulFeatureBytesOffset,
20023
 
                                                                                &ulTempData,
20024
 
                                                                                ulResult );
20025
 
        if ( ulResult != cOCT6100_ERR_OK )
20026
 
                return ulResult;
20027
 
 
20028
 
        /* Clear previous value set in the feature field.*/
20029
 
        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
20030
 
 
20031
 
        ulTempData &= (~ulMask);
20032
 
        ulTempData |= ( ( f_usDominantSpeakerIndex ) << ulFeatureBitOffset );
20033
 
 
20034
 
        /* Save the new dominant speaker. */
20035
 
        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
20036
 
                                                                        pEchoChanEntry,
20037
 
                                                                        ulBaseAddress + ulFeatureBytesOffset,
20038
 
                                                                        ulTempData,
20039
 
                                                                        ulResult );
20040
 
        if ( ulResult != cOCT6100_ERR_OK )
20041
 
                return ulResult;        
20042
 
 
20043
 
        return cOCT6100_ERR_OK;
20044
 
}
20045
 
 
20046
 
 
20047
 
 
20048
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20049
 
 
20050
 
Function:               Oct6100ApiReleaseFlexConfParticipantEntry
20051
 
 
20052
 
Description:    Release an entry from the flexible conferencing participant 
20053
 
                                list.
20054
 
 
20055
 
-------------------------------------------------------------------------------
20056
 
|       Argument                |       Description
20057
 
-------------------------------------------------------------------------------
20058
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
20059
 
                                                present state of the chip and all its resources.
20060
 
 
20061
 
f_usParticipantIndex    List entry reserved.
20062
 
 
20063
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20064
 
static UINT32 Oct6100ApiReleaseFlexConfParticipantEntry(
20065
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
20066
 
                                IN              UINT16                                                  f_usParticipantIndex )
20067
 
{
20068
 
        PVOID   pParticipantAlloc;
20069
 
        UINT32  ulResult;
20070
 
 
20071
 
        mOCT6100_GET_FLEX_CONF_PARTICIPANT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pParticipantAlloc )
20072
 
 
20073
 
        ulResult = OctapiLlmAllocDealloc( pParticipantAlloc, f_usParticipantIndex );
20074
 
        if ( ulResult != cOCT6100_ERR_OK )
20075
 
                return cOCT6100_ERR_FATAL_2A;
20076
 
 
20077
 
        return cOCT6100_ERR_OK;
20078
 
}
20079
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20080
 
 
20081
 
File: oct6100_debug.c
20082
 
 
20083
 
    Copyright (c) 2001-2005 Octasic Inc.
20084
 
    
20085
 
Description: 
20086
 
 
20087
 
        This file contains functions used to debug the OCT6100.
20088
 
 
20089
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
20090
 
free software; you can redistribute it and/or modify it under the terms of 
20091
 
the GNU General Public License as published by the Free Software Foundation; 
20092
 
either version 2 of the License, or (at your option) any later version.
20093
 
 
20094
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
20095
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
20096
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
20097
 
for more details. 
20098
 
 
20099
 
You should have received a copy of the GNU General Public License 
20100
 
along with the OCT6100 GPL API; if not, write to the Free Software 
20101
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20102
 
 
20103
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
20104
 
 
20105
 
$Octasic_Revision: 58 $
20106
 
 
20107
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20108
 
 
20109
 
 
20110
 
/*****************************  INCLUDE FILES  *******************************/
20111
 
 
20112
 
#include "octdef.h"
20113
 
 
20114
 
#include "oct6100api/oct6100_defines.h"
20115
 
#include "oct6100api/oct6100_errors.h"
20116
 
#include "oct6100api/oct6100_apiud.h"
20117
 
 
20118
 
#include "oct6100api/oct6100_apiud.h"
20119
 
#include "oct6100api/oct6100_tlv_inst.h"
20120
 
#include "oct6100api/oct6100_chip_open_inst.h"
20121
 
#include "oct6100api/oct6100_chip_stats_inst.h"
20122
 
#include "oct6100api/oct6100_interrupts_inst.h"
20123
 
#include "oct6100api/oct6100_remote_debug_inst.h"
20124
 
#include "oct6100api/oct6100_debug_inst.h"
20125
 
#include "oct6100api/oct6100_api_inst.h"
20126
 
#include "oct6100api/oct6100_channel_inst.h"
20127
 
 
20128
 
#include "oct6100api/oct6100_interrupts_pub.h"
20129
 
#include "oct6100api/oct6100_chip_open_pub.h"
20130
 
#include "oct6100api/oct6100_channel_pub.h"
20131
 
#include "oct6100api/oct6100_debug_pub.h"
20132
 
 
20133
 
#include "oct6100_chip_open_priv.h"
20134
 
#include "oct6100_channel_priv.h"
20135
 
#include "oct6100_miscellaneous_priv.h"
20136
 
#include "oct6100_memory_priv.h"
20137
 
#include "oct6100_debug_priv.h"
20138
 
#include "oct6100_version.h"
20139
 
 
20140
 
 
20141
 
/****************************  PRIVATE FUNCTIONS  ****************************/
20142
 
 
20143
 
#ifndef cOCT6100_REMOVE_EVENTS
20144
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20145
 
 
20146
 
File: oct6100_events.c
20147
 
 
20148
 
    Copyright (c) 2001-2005 Octasic Inc.
20149
 
    
20150
 
Description: 
20151
 
 
20152
 
        This file contains functions used to retrieve tone and playout events.
20153
 
 
20154
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
20155
 
free software; you can redistribute it and/or modify it under the terms of 
20156
 
the GNU General Public License as published by the Free Software Foundation; 
20157
 
either version 2 of the License, or (at your option) any later version.
20158
 
 
20159
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
20160
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
20161
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
20162
 
for more details. 
20163
 
 
20164
 
You should have received a copy of the GNU General Public License 
20165
 
along with the OCT6100 GPL API; if not, write to the Free Software 
20166
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20167
 
 
20168
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
20169
 
 
20170
 
$Octasic_Revision: 79 $
20171
 
 
20172
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20173
 
 
20174
 
 
20175
 
/*****************************  INCLUDE FILES  *******************************/
20176
 
 
20177
 
#include "octdef.h"
20178
 
 
20179
 
#include "oct6100api/oct6100_defines.h"
20180
 
#include "oct6100api/oct6100_errors.h"
20181
 
#include "oct6100api/oct6100_apiud.h"
20182
 
 
20183
 
#include "apilib/octapi_llman.h"
20184
 
 
20185
 
#include "oct6100api/oct6100_tlv_inst.h"
20186
 
#include "oct6100api/oct6100_chip_open_inst.h"
20187
 
#include "oct6100api/oct6100_chip_stats_inst.h"
20188
 
#include "oct6100api/oct6100_interrupts_inst.h"
20189
 
#include "oct6100api/oct6100_remote_debug_inst.h"
20190
 
#include "oct6100api/oct6100_debug_inst.h"
20191
 
#include "oct6100api/oct6100_api_inst.h"
20192
 
#include "oct6100api/oct6100_channel_inst.h"
20193
 
#include "oct6100api/oct6100_events_inst.h"
20194
 
#include "oct6100api/oct6100_tone_detection_inst.h"
20195
 
#include "oct6100api/oct6100_playout_buf_inst.h"
20196
 
 
20197
 
#include "oct6100api/oct6100_interrupts_pub.h"
20198
 
#include "oct6100api/oct6100_chip_open_pub.h"
20199
 
#include "oct6100api/oct6100_channel_pub.h"
20200
 
#include "oct6100api/oct6100_events_pub.h"
20201
 
#include "oct6100api/oct6100_tone_detection_pub.h"
20202
 
#include "oct6100api/oct6100_playout_buf_pub.h"
20203
 
 
20204
 
#include "oct6100_chip_open_priv.h"
20205
 
#include "oct6100_miscellaneous_priv.h"
20206
 
#include "oct6100_channel_priv.h"
20207
 
#include "oct6100_events_priv.h"
20208
 
#include "oct6100_tone_detection_priv.h"
20209
 
#include "oct6100_playout_buf_priv.h"
20210
 
 
20211
 
/****************************  PUBLIC FUNCTIONS  *****************************/
20212
 
 
20213
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20214
 
 
20215
 
Function:               Oct6100EventGetTone
20216
 
 
20217
 
Description:    Retreives an array of tone events.
20218
 
 
20219
 
-------------------------------------------------------------------------------
20220
 
|       Argument                |       Description
20221
 
-------------------------------------------------------------------------------
20222
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
20223
 
                                                the present state of the chip and all its resources.
20224
 
 
20225
 
f_pEventGetTone                 Pointer to structure used to store the Tone events.                                             
20226
 
 
20227
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20228
 
static UINT32 Oct6100EventGetToneDef(
20229
 
                                tPOCT6100_EVENT_GET_TONE                f_pEventGetTone )
20230
 
{
20231
 
        f_pEventGetTone->pToneEvent = NULL;
20232
 
        f_pEventGetTone->ulMaxToneEvent = 1;
20233
 
        f_pEventGetTone->ulNumValidToneEvent = cOCT6100_INVALID_VALUE;
20234
 
        f_pEventGetTone->fMoreEvents = FALSE;
20235
 
        f_pEventGetTone->fResetBufs = FALSE;
20236
 
 
20237
 
        return cOCT6100_ERR_OK; 
20238
 
}
20239
 
 
20240
 
 
20241
 
static UINT32 Oct6100EventGetTone(
20242
 
                                tPOCT6100_INSTANCE_API                  f_pApiInstance,
20243
 
                                tPOCT6100_EVENT_GET_TONE                f_pEventGetTone )
20244
 
{
20245
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
20246
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
20247
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
20248
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
20249
 
 
20250
 
        /* Set the process context of the serialize structure. */
20251
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
20252
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
20253
 
 
20254
 
        /* Seize all list semaphores needed by this function. */
20255
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
20256
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
20257
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
20258
 
        if ( ulSerRes == cOCT6100_ERR_OK )
20259
 
        {
20260
 
                /* Call the serialized function. */
20261
 
                ulFncRes = Oct6100EventGetToneSer( f_pApiInstance, f_pEventGetTone );
20262
 
        }
20263
 
        else
20264
 
        {
20265
 
                return ulSerRes;
20266
 
        }
20267
 
 
20268
 
        /* Release the seized semaphores. */
20269
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
20270
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
20271
 
 
20272
 
        /* If an error occured then return the error code. */
20273
 
        if ( ulSerRes != cOCT6100_ERR_OK )
20274
 
                return ulSerRes;
20275
 
        if ( ulFncRes != cOCT6100_ERR_OK )
20276
 
                return ulFncRes;
20277
 
 
20278
 
        return cOCT6100_ERR_OK;
20279
 
}
20280
 
 
20281
 
 
20282
 
 
20283
 
/****************************  PRIVATE FUNCTIONS  ****************************/
20284
 
 
20285
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20286
 
 
20287
 
Function:               Oct6100ApiGetEventsSwSizes
20288
 
 
20289
 
Description:    Gets the sizes of all portions of the API instance pertinent
20290
 
                                to the management of the tone events and playout events
20291
 
                                software buffers.
20292
 
 
20293
 
-------------------------------------------------------------------------------
20294
 
|       Argument                |       Description
20295
 
-------------------------------------------------------------------------------
20296
 
f_pOpenChip                             Pointer to chip configuration struct.
20297
 
f_pInstSizes                    Pointer to struct containing instance sizes.
20298
 
 
20299
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20300
 
static UINT32 Oct6100ApiGetEventsSwSizes(
20301
 
                                IN              tPOCT6100_CHIP_OPEN                             f_pOpenChip,
20302
 
                                OUT             tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
20303
 
{
20304
 
 
20305
 
        {
20306
 
                UINT32  ulTempVar;
20307
 
                
20308
 
                /* Memory needed by soft tone event buffers. */
20309
 
 
20310
 
                /* Add 1 to the circular buffer such that all user requested events can fit in the circular queue. */
20311
 
                f_pInstSizes->ulSoftToneEventsBuffer = ( f_pOpenChip->ulSoftToneEventsBufSize + 1 ) * sizeof( tOCT6100_API_TONE_EVENT );
20312
 
 
20313
 
                /* Round off the sizes of the soft buffers above. */
20314
 
                mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulSoftToneEventsBuffer, ulTempVar )
20315
 
        }
20316
 
 
20317
 
        {
20318
 
                UINT32  ulTempVar;
20319
 
 
20320
 
                /* Memory needed by soft playout stop event buffers. */
20321
 
                if ( f_pOpenChip->ulSoftBufferPlayoutEventsBufSize != cOCT6100_INVALID_VALUE )
20322
 
                {
20323
 
                        f_pInstSizes->ulSoftBufPlayoutEventsBuffer = ( f_pOpenChip->ulSoftBufferPlayoutEventsBufSize + 1 ) * sizeof( tOCT6100_API_BUFFER_PLAYOUT_EVENT );
20324
 
 
20325
 
                        /* Round off the sizes of the soft buffers above. */
20326
 
                        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulSoftBufPlayoutEventsBuffer, ulTempVar )
20327
 
                }
20328
 
                else /* if ( f_pInstSizes->ulSoftBufferPlayoutEventsBufSize == cOCT6100_INVALID_VALUE ) */
20329
 
                {
20330
 
                        f_pInstSizes->ulSoftBufPlayoutEventsBuffer = 0;
20331
 
                }
20332
 
        }
20333
 
 
20334
 
        return cOCT6100_ERR_OK;
20335
 
}
20336
 
 
20337
 
 
20338
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20339
 
 
20340
 
Function:               Oct6100EventGetToneSer
20341
 
 
20342
 
Description:    Retreives an array of tone event from the software event buffer.
20343
 
 
20344
 
-------------------------------------------------------------------------------
20345
 
|       Argument                |       Description
20346
 
-------------------------------------------------------------------------------
20347
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
20348
 
                                                the present state of the chip and all its resources.
20349
 
 
20350
 
f_pEventGetTone                 Pointer to structure which will contain the retreived
20351
 
                                                events.
20352
 
 
20353
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20354
 
static UINT32 Oct6100EventGetToneSer(
20355
 
                                IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
20356
 
                                IN OUT  tPOCT6100_EVENT_GET_TONE                        f_pEventGetTone )
20357
 
{
20358
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
20359
 
        tPOCT6100_API_TONE_EVENT        pSoftEvent;
20360
 
        UINT32  ulSoftReadPnt;
20361
 
        UINT32  ulSoftWritePnt;
20362
 
        UINT32  ulSoftBufSize;
20363
 
        UINT32  ulNumEventsReturned;
20364
 
        UINT32  ulResult;
20365
 
 
20366
 
        /* Get local pointer(s). */
20367
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
20368
 
 
20369
 
        /* Check the parameters given by the user. */
20370
 
        if ( f_pEventGetTone->fResetBufs != TRUE &&
20371
 
                 f_pEventGetTone->fResetBufs != FALSE )
20372
 
                return cOCT6100_ERR_EVENTS_GET_TONE_RESET_BUFS;
20373
 
        
20374
 
        /* Check max tones. */
20375
 
        if ( f_pEventGetTone->ulMaxToneEvent > pSharedInfo->ChipConfig.ulSoftToneEventsBufSize )
20376
 
                return cOCT6100_ERR_EVENTS_MAX_TONES;
20377
 
 
20378
 
        if ( f_pEventGetTone->fResetBufs == FALSE )
20379
 
        {
20380
 
                /* Check if the events need to be fetched from the chip buffer. */
20381
 
                ulSoftReadPnt = pSharedInfo->SoftBufs.ulToneEventBufferReadPtr;
20382
 
                ulSoftWritePnt = pSharedInfo->SoftBufs.ulToneEventBufferWritePtr;
20383
 
 
20384
 
                if ( ulSoftReadPnt == ulSoftWritePnt )
20385
 
                {
20386
 
                        ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, f_pEventGetTone->fResetBufs );
20387
 
                        if ( ulResult != cOCT6100_ERR_OK )
20388
 
                                return ulResult;
20389
 
                }
20390
 
 
20391
 
                /* If there are no events in the soft buffer then there are none in the chip */
20392
 
                /* either, so return the empty case.  Else, return the events in the buffer. */
20393
 
                ulSoftReadPnt = pSharedInfo->SoftBufs.ulToneEventBufferReadPtr;
20394
 
                ulSoftWritePnt = pSharedInfo->SoftBufs.ulToneEventBufferWritePtr;
20395
 
                ulSoftBufSize = pSharedInfo->SoftBufs.ulToneEventBufferSize;
20396
 
 
20397
 
                if ( ulSoftReadPnt != ulSoftWritePnt )
20398
 
                {
20399
 
                        ulNumEventsReturned = 0;
20400
 
 
20401
 
                        while( (ulSoftReadPnt != ulSoftWritePnt) && ( ulNumEventsReturned != f_pEventGetTone->ulMaxToneEvent) )
20402
 
                        {
20403
 
                                /* Get a pointer to the first event in the buffer. */
20404
 
                                mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
20405
 
                                pSoftEvent += ulSoftReadPnt;
20406
 
                                
20407
 
                                f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulChannelHndl = pSoftEvent->ulChannelHandle;
20408
 
                                f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulUserChanId = pSoftEvent->ulUserChanId;
20409
 
                                f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulTimestamp = pSoftEvent->ulTimestamp;
20410
 
                                f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulEventType = pSoftEvent->ulEventType;
20411
 
                                f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulToneDetected = pSoftEvent->ulToneDetected;
20412
 
                                f_pEventGetTone->pToneEvent[ ulNumEventsReturned ].ulExtToneDetectionPort = pSoftEvent->ulExtToneDetectionPort;
20413
 
 
20414
 
                                /* Update the pointers of the soft buffer. */
20415
 
                                ulSoftReadPnt++;
20416
 
                                if ( ulSoftReadPnt == ulSoftBufSize )
20417
 
                                        ulSoftReadPnt = 0;
20418
 
 
20419
 
                                ulNumEventsReturned++;
20420
 
                        }
20421
 
 
20422
 
                        pSharedInfo->SoftBufs.ulToneEventBufferReadPtr = ulSoftReadPnt;
20423
 
 
20424
 
                        /* Detemine if there are more events pending in the soft buffer. */
20425
 
                        if ( ulSoftReadPnt != ulSoftWritePnt )
20426
 
                                f_pEventGetTone->fMoreEvents = TRUE;
20427
 
                        else /* ( ulSoftReadPnt == ulSoftWritePnt ) */
20428
 
                        {
20429
 
                                f_pEventGetTone->fMoreEvents = FALSE;
20430
 
                                
20431
 
                                /* Remember this state in the interrupt manager. */
20432
 
                                pSharedInfo->IntrptManage.fToneEventsPending = FALSE;
20433
 
                        }
20434
 
 
20435
 
                        f_pEventGetTone->ulNumValidToneEvent = ulNumEventsReturned;
20436
 
                }
20437
 
                else
20438
 
                {
20439
 
                        /* No valid tone.*/
20440
 
                        f_pEventGetTone->ulNumValidToneEvent = 0;
20441
 
                        f_pEventGetTone->fMoreEvents = FALSE;
20442
 
 
20443
 
                        /* Remember this state in the interrupt manager. */
20444
 
                        pSharedInfo->IntrptManage.fToneEventsPending = FALSE;
20445
 
                        
20446
 
                        return cOCT6100_ERR_EVENTS_TONE_BUF_EMPTY;
20447
 
                }
20448
 
        }
20449
 
        else /* ( f_pEventGetTone->fResetBufs == TRUE ) */
20450
 
        {
20451
 
                /* Empty the hardware buffer. */
20452
 
                ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, f_pEventGetTone->fResetBufs );
20453
 
                if ( ulResult != cOCT6100_ERR_OK )
20454
 
                        return ulResult;
20455
 
 
20456
 
                /* If the buffers are to be reset then update the pointers and full flag. */
20457
 
                pSharedInfo->SoftBufs.ulToneEventBufferReadPtr = 0;
20458
 
                pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0;
20459
 
 
20460
 
                f_pEventGetTone->fMoreEvents = FALSE;
20461
 
                f_pEventGetTone->ulNumValidToneEvent = 0;
20462
 
 
20463
 
                /* Remember this state in the interrupt manager. */
20464
 
                pSharedInfo->IntrptManage.fToneEventsPending = FALSE;
20465
 
        }
20466
 
 
20467
 
        return cOCT6100_ERR_OK;
20468
 
}
20469
 
 
20470
 
 
20471
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20472
 
 
20473
 
Function:               Oct6100ApiTransferToneEvents
20474
 
 
20475
 
Description:    Transfers all tone events from the PGSP event out chip buffer 
20476
 
                                to the soft buffer.
20477
 
 
20478
 
-------------------------------------------------------------------------------
20479
 
|       Argument                |       Description
20480
 
-------------------------------------------------------------------------------
20481
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
20482
 
                                                the present state of the chip and all its resources.
20483
 
 
20484
 
f_ulResetBuf                    Reset flag.
20485
 
 
20486
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20487
 
static UINT32 Oct6100ApiTransferToneEvents(
20488
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
20489
 
                                IN              UINT32                                                  f_ulResetBuf )
20490
 
{
20491
 
        tPOCT6100_SHARED_INFO                           pSharedInfo;
20492
 
        tPOCT6100_API_TONE_EVENT                        pSoftEvent;
20493
 
        tPOCT6100_API_CHANNEL                   pEchoChannel;
20494
 
        tOCT6100_WRITE_PARAMS                           WriteParams;
20495
 
        tOCT6100_READ_PARAMS                            ReadParams;
20496
 
        tOCT6100_READ_BURST_PARAMS                      BurstParams;
20497
 
        UINT32  ulChipBufFill;
20498
 
        UINT32  ulChipWritePtr = 0;
20499
 
        UINT32  ulChipReadPtr = 0;
20500
 
        
20501
 
        UINT32  usChannelIndex;
20502
 
        UINT32  ulBaseTimestamp;
20503
 
        UINT32  ulToneCnt;
20504
 
        UINT32  ulNumWordsToRead;
20505
 
 
20506
 
        UINT32  ulResult;
20507
 
        UINT32  i, j;
20508
 
        UINT16  usReadData;
20509
 
        UINT16  ausReadData[ cOCT6100_NUM_WORDS_PER_TONE_EVENT ];
20510
 
 
20511
 
        UINT32  ulExtToneDetectionPort;
20512
 
 
20513
 
        /* Get local pointer(s). */
20514
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
20515
 
 
20516
 
        /* If the buffer is to be reset then clear the overflow flag. */
20517
 
        if ( f_ulResetBuf == TRUE )
20518
 
        {
20519
 
                pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt = 0;
20520
 
        }
20521
 
 
20522
 
        /* Set some parameters of read struct. */
20523
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
20524
 
 
20525
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
20526
 
        ReadParams.pusReadData = &usReadData;
20527
 
        
20528
 
        /* Get the current read pointer of the chip buffer. */
20529
 
        ReadParams.ulReadAddress = cOCT6100_TONE_EVENT_READ_PTR_REG;
20530
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
20531
 
        if ( ulResult != cOCT6100_ERR_OK )
20532
 
                return ulResult;
20533
 
 
20534
 
        ulChipReadPtr = usReadData;
20535
 
 
20536
 
        /* Now get the current write pointer. */
20537
 
        ReadParams.ulReadAddress = cOCT6100_TONE_EVENT_WRITE_PTR_REG;
20538
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
20539
 
        if ( ulResult != cOCT6100_ERR_OK )
20540
 
                return ulResult;
20541
 
 
20542
 
        ulChipWritePtr = usReadData;
20543
 
 
20544
 
        ulChipBufFill = (( ulChipWritePtr - ulChipReadPtr ) & ( cOCT6100_NUM_PGSP_EVENT_OUT - 1 ));
20545
 
 
20546
 
        /* Set some parameters of write structs. */
20547
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
20548
 
 
20549
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
20550
 
 
20551
 
        BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
20552
 
 
20553
 
        BurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
20554
 
 
20555
 
        /* Read in the tone event one at a time. */
20556
 
        for ( i = 0; i < ulChipBufFill; i++ )
20557
 
        {
20558
 
                /* Skip the event processing if the buffer is to be reset. */
20559
 
                if ( f_ulResetBuf == TRUE )
20560
 
                {
20561
 
                        /* Update the control variables of the buffer. */
20562
 
                        ulChipReadPtr++;
20563
 
                        if ( cOCT6100_NUM_PGSP_EVENT_OUT == ulChipReadPtr )
20564
 
                                ulChipReadPtr = 0;
20565
 
                }
20566
 
                else
20567
 
                {
20568
 
                        /* Read in the event only if there's enough room in the soft buffer, and */
20569
 
                        /* the chip buffer is NOT to be reset. */
20570
 
                        if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) &&
20571
 
                                 ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) )
20572
 
                        {
20573
 
                                BurstParams.ulReadAddress = cOCT6100_PGSP_EVENT_OUT_BASE + ( ulChipReadPtr * cOCT6100_PGSP_TONE_EVENT_SIZE );
20574
 
                                BurstParams.pusReadData = ausReadData;
20575
 
 
20576
 
                                ulNumWordsToRead = cOCT6100_PGSP_TONE_EVENT_SIZE / 2;
20577
 
                                
20578
 
                                while ( ulNumWordsToRead > 0 )
20579
 
                                {
20580
 
                                        if ( ulNumWordsToRead > pSharedInfo->ChipConfig.usMaxRwAccesses )
20581
 
                                        {                               
20582
 
                                                BurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
20583
 
                                        }
20584
 
                                        else
20585
 
                                        {
20586
 
                                                BurstParams.ulReadLength = ulNumWordsToRead;
20587
 
                                        }
20588
 
 
20589
 
                                        mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult );
20590
 
                                        if ( ulResult != cOCT6100_ERR_OK )
20591
 
                                                return ulResult;
20592
 
 
20593
 
                                        BurstParams.pusReadData         += BurstParams.ulReadLength;
20594
 
                                        BurstParams.ulReadAddress       += BurstParams.ulReadLength * 2;
20595
 
 
20596
 
                                        ulNumWordsToRead -= BurstParams.ulReadLength;
20597
 
                                }
20598
 
 
20599
 
                                /* Verify if the event is valid. */
20600
 
                                if ( ( ausReadData[ 0 ] & cOCT6100_VALID_TONE_EVENT ) == 0x0 )
20601
 
                                        return cOCT6100_ERR_FATAL_2D;
20602
 
 
20603
 
                                /* First extract the channel number of the tone event. */
20604
 
                                usChannelIndex = ausReadData[ 1 ] & 0x3FF;
20605
 
 
20606
 
                                /* Now the timestamp. */
20607
 
                                ulBaseTimestamp  = ausReadData[ 2 ] << 16;
20608
 
                                ulBaseTimestamp |= ausReadData[ 3 ];
20609
 
                                
20610
 
                                /* This timestamp is 256 in adwance, must remove 256 frames. */
20611
 
                                ulBaseTimestamp -= 256;
20612
 
 
20613
 
                                /* Fetch the channel stucture to validate which event can be reported. */
20614
 
                                mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, usChannelIndex );
20615
 
 
20616
 
                                if ( pEchoChannel->fReserved != TRUE )
20617
 
                                {
20618
 
                                        /* Update the control variables of the buffer. */
20619
 
                                        ulChipReadPtr++;
20620
 
                                        if ( ulChipReadPtr == cOCT6100_NUM_PGSP_EVENT_OUT )
20621
 
                                                ulChipReadPtr = 0;
20622
 
                                        
20623
 
                                        /* This channel has been closed since the generation of the event. */
20624
 
                                        continue;
20625
 
                                }
20626
 
 
20627
 
                                /* Extract the extended tone detection port if available. */
20628
 
                                if ( pEchoChannel->ulExtToneChanMode == cOCT6100_API_EXT_TONE_SIN_PORT_MODE )
20629
 
                                {
20630
 
                                        ulExtToneDetectionPort = cOCT6100_CHANNEL_PORT_SIN;
20631
 
                                }
20632
 
                                else if ( pEchoChannel->ulExtToneChanMode == cOCT6100_API_EXT_TONE_RIN_PORT_MODE )
20633
 
                                {
20634
 
                                        ulExtToneDetectionPort = cOCT6100_CHANNEL_PORT_RIN;
20635
 
 
20636
 
                                        /* Modify the channel index. */
20637
 
                                        usChannelIndex = pEchoChannel->usExtToneChanIndex;
20638
 
 
20639
 
                                        /* Change the channel entry to the original one for statistical purposes. */
20640
 
                                        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, usChannelIndex );
20641
 
 
20642
 
                                }
20643
 
                                else /* pEchoChannel->ulExtToneChanMode == cOCT6100_API_EXT_TONE_DISABLED */
20644
 
                                {
20645
 
                                        ulExtToneDetectionPort = cOCT6100_INVALID_VALUE;
20646
 
                                }
20647
 
 
20648
 
                                ulToneCnt = 0;
20649
 
                                /* Verify all the possible events that might have been detected. */
20650
 
                                for ( j = 4; j < cOCT6100_NUM_WORDS_PER_TONE_EVENT; j++ )
20651
 
                                {
20652
 
                                        if ( (( ausReadData[ j ] >> 8 ) & 0x7 ) != 0x0 )
20653
 
                                        {
20654
 
                                                /* This tone generated an event, now check if event is masked for the channel. */
20655
 
                                                if ((( pEchoChannel->aulToneConf[ ulToneCnt / 32 ] >> ( 31 - ( ulToneCnt % 32 ))) & 0x1) == 1 )
20656
 
                                                {
20657
 
                                                        /* If enough space. */
20658
 
                                                        if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) &&
20659
 
                                                                ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) )
20660
 
                                                        {
20661
 
                                                                /* The tone event is not masked, The API can create a soft tone event. */
20662
 
                                                                mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
20663
 
                                                                pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr;
20664
 
 
20665
 
                                                                /* Decode the event type. */
20666
 
                                                                switch(( ausReadData[ j ] >> 8 ) & 0x7 ) 
20667
 
                                                                {
20668
 
                                                                case 1:
20669
 
                                                                        pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT;
20670
 
                                                                        break;
20671
 
                                                                case 2:
20672
 
                                                                        pSoftEvent->ulEventType = cOCT6100_TONE_STOP;
20673
 
                                                                        break;
20674
 
                                                                case 3:
20675
 
                                                                        /* This one is a little tricky.  We first */
20676
 
                                                                        /* generate the "PRESENT" event and then generate the "STOP" event. */
20677
 
 
20678
 
                                                                        pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT;
20679
 
                                                                        pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; 
20680
 
                                                                        pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId;
20681
 
                                                                        pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID;
20682
 
                                                                        /* We want the timestamp not to be equal to the "STOP" event, so we subtract one to the detector's value. */
20683
 
                                                                        pSoftEvent->ulTimestamp = ( ulBaseTimestamp + ((( ausReadData[ j ] >> 13 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ) ) - 1;
20684
 
                                                                        pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort;
20685
 
 
20686
 
                                                                        /* Update the control variables of the buffer. */
20687
 
                                                                        pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++;
20688
 
                                                                        if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize )
20689
 
                                                                                pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0;
20690
 
 
20691
 
                                                                        /* If enough space for the "STOP" event. */
20692
 
                                                                        if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) &&
20693
 
                                                                                ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) )
20694
 
                                                                        {
20695
 
                                                                                mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
20696
 
                                                                                pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr;
20697
 
 
20698
 
                                                                                pSoftEvent->ulEventType = cOCT6100_TONE_STOP;
20699
 
                                                                        }
20700
 
                                                                        else
20701
 
                                                                        {
20702
 
                                                                                /* Set the overflow flag of the buffer. */
20703
 
                                                                                pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
20704
 
 
20705
 
                                                                                /* We continue in the loop in order to empty the hardware buffer. */
20706
 
                                                                                continue;
20707
 
                                                                        }
20708
 
                                                                        
20709
 
                                                                        break;
20710
 
                                                                case 4:
20711
 
                                                                        pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT;
20712
 
                                                                        break;
20713
 
                                                                default:
20714
 
                                                                        pSharedInfo->ErrorStats.ulToneDetectorErrorCnt++;
20715
 
                                                                        /* do not process this packet*/
20716
 
                                                                        continue;
20717
 
                                                                }
20718
 
 
20719
 
                                                                pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; 
20720
 
                                                                pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId;
20721
 
                                                                pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID;
20722
 
                                                                pSoftEvent->ulTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 13 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT );
20723
 
                                                                pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort;
20724
 
 
20725
 
                                                                /* Update the control variables of the buffer. */
20726
 
                                                                pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++;
20727
 
                                                                if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize )
20728
 
                                                                        pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0;
20729
 
 
20730
 
                                                                /* Set the interrupt manager such that the user knows that some tone events */
20731
 
                                                                /* are pending in the software Q. */
20732
 
                                                                pSharedInfo->IntrptManage.fToneEventsPending = TRUE;
20733
 
                                                        }
20734
 
                                                        else
20735
 
                                                        {
20736
 
                                                                /* Set the overflow flag of the buffer. */
20737
 
                                                                pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
20738
 
 
20739
 
                                                                /* We continue in the loop in order to empty the hardware buffer. */
20740
 
                                                        }
20741
 
                                                }
20742
 
                                                else
20743
 
                                                {
20744
 
                                                        BOOL fSSTone;
20745
 
 
20746
 
                                                        ulResult = Oct6100ApiIsSSTone( 
20747
 
                                                                                                                f_pApiInstance, 
20748
 
                                                                                                                pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID, 
20749
 
                                                                                                                &fSSTone );
20750
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
20751
 
                                                                return ulResult;
20752
 
 
20753
 
                                                        if ( fSSTone == TRUE )
20754
 
                                                        {
20755
 
                                                                /* Check if this is a "PRESENT" or "STOP" event */
20756
 
                                                                switch( ( ( ausReadData[ j ] >> 8 ) & 0x7 ) )
20757
 
                                                                {
20758
 
                                                                case 1:
20759
 
                                                                        /* This is a signaling system present event.  Keep this in the instance memory. */
20760
 
                                                                        pEchoChannel->ulLastSSToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID;
20761
 
                                                                        pEchoChannel->ulLastSSToneTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 13 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT );
20762
 
                                                                        break;
20763
 
                                                                case 2:
20764
 
                                                                        /* This is the "STOP" event, invalidate the last value.  The user does not want to know about this. */
20765
 
                                                                        pEchoChannel->ulLastSSToneDetected = cOCT6100_INVALID_VALUE;
20766
 
                                                                        pEchoChannel->ulLastSSToneTimestamp = cOCT6100_INVALID_VALUE;
20767
 
                                                                        break;
20768
 
                                                                default:
20769
 
                                                                        break;
20770
 
                                                                }
20771
 
                                                        }
20772
 
                                                }
20773
 
                                        }
20774
 
                                        ulToneCnt++;
20775
 
 
20776
 
                                        /* Check the other tone of this word. */
20777
 
                                        if ( ( ausReadData[ j ] & 0x7 ) != 0x0 )
20778
 
                                        {
20779
 
                                                if ((( pEchoChannel->aulToneConf[ ulToneCnt / 32 ] >> ( 31 - ( ulToneCnt % 32 ))) & 0x1) == 1 )
20780
 
                                                {
20781
 
                                                        /* If enough space. */
20782
 
                                                        if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) &&
20783
 
                                                                ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) )
20784
 
                                                        {
20785
 
                                                                /* The tone event is not masked, The API can create a soft tone event. */
20786
 
                                                                mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
20787
 
                                                                pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr;
20788
 
 
20789
 
                                                                /* Decode the event type. */
20790
 
                                                                switch(( ausReadData[ j ] ) & 0x7 ) 
20791
 
                                                                {
20792
 
                                                                case 1:
20793
 
                                                                        pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT;
20794
 
                                                                        break;
20795
 
                                                                case 2:
20796
 
                                                                        pSoftEvent->ulEventType = cOCT6100_TONE_STOP;
20797
 
                                                                        break;
20798
 
                                                                case 3:
20799
 
                                                                        /* This one is a little tricky.  We first */
20800
 
                                                                        /* generate the "PRESENT" event and then generate the "STOP" event. */
20801
 
 
20802
 
                                                                        pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT;
20803
 
                                                                        pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; 
20804
 
                                                                        pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId;
20805
 
                                                                        pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID;
20806
 
                                                                        /* We want the timestamp not to be equal to the "STOP" event, so we subtract one to the detector's value. */
20807
 
                                                                        pSoftEvent->ulTimestamp = ( ulBaseTimestamp + ((( ausReadData[ j ] >> 5 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT ) ) - 1;
20808
 
                                                                        pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort;
20809
 
 
20810
 
                                                                        /* Update the control variables of the buffer. */
20811
 
                                                                        pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++;
20812
 
                                                                        if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize )
20813
 
                                                                                pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0;
20814
 
 
20815
 
                                                                        /* If enough space for the "STOP" event. */
20816
 
                                                                        if ( ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr) &&
20817
 
                                                                                ((pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0) )
20818
 
                                                                        {
20819
 
                                                                                mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
20820
 
                                                                                pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr;
20821
 
 
20822
 
                                                                                pSoftEvent->ulEventType = cOCT6100_TONE_STOP;
20823
 
                                                                        }
20824
 
                                                                        else
20825
 
                                                                        {
20826
 
                                                                                /* Set the overflow flag of the buffer. */
20827
 
                                                                                pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
20828
 
 
20829
 
                                                                                /* We continue in the loop in order to empty the hardware buffer. */
20830
 
                                                                                continue;
20831
 
                                                                        }
20832
 
                                                                        
20833
 
                                                                        break;
20834
 
                                                                case 4:
20835
 
                                                                        pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT;
20836
 
                                                                        break;
20837
 
                                                                default:
20838
 
                                                                        pSharedInfo->ErrorStats.ulToneDetectorErrorCnt++;
20839
 
                                                                        /* Do not process this packet. */
20840
 
                                                                        continue;
20841
 
                                                                }
20842
 
 
20843
 
                                                                pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | usChannelIndex; 
20844
 
                                                                pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId;
20845
 
                                                                pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID;
20846
 
                                                                pSoftEvent->ulTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 5 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT );
20847
 
                                                                pSoftEvent->ulExtToneDetectionPort = ulExtToneDetectionPort;
20848
 
 
20849
 
                                                                /* Update the control variables of the buffer. */
20850
 
                                                                pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++;
20851
 
                                                                if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize )
20852
 
                                                                        pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0;
20853
 
 
20854
 
                                                                /* Set the interrupt manager such that the user knows that some tone events */
20855
 
                                                                /* are pending in the software Q. */
20856
 
                                                                pSharedInfo->IntrptManage.fToneEventsPending = TRUE;
20857
 
 
20858
 
                                                        }
20859
 
                                                        else
20860
 
                                                        {
20861
 
                                                                /* Set the overflow flag of the buffer. */
20862
 
                                                                pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
20863
 
 
20864
 
                                                                /* We continue in the loop in order to empty the hardware buffer. */
20865
 
                                                        }
20866
 
                                                }
20867
 
                                                else
20868
 
                                                {
20869
 
                                                        BOOL fSSTone;
20870
 
 
20871
 
                                                        ulResult = Oct6100ApiIsSSTone( 
20872
 
                                                                                                                f_pApiInstance, 
20873
 
                                                                                                                pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID, 
20874
 
                                                                                                                &fSSTone );
20875
 
                                                        if ( ulResult != cOCT6100_ERR_OK )
20876
 
                                                                return ulResult;
20877
 
 
20878
 
                                                        if ( fSSTone == TRUE )
20879
 
                                                        {
20880
 
                                                                /* Check if this is a "PRESENT" event. */
20881
 
                                                                switch ( ( ausReadData[ j ] ) & 0x7 ) 
20882
 
                                                                {
20883
 
                                                                case 1:
20884
 
                                                                        /* This is a signaling system present event.  Keep this in the instance memory. */
20885
 
                                                                        pEchoChannel->ulLastSSToneDetected = pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID;
20886
 
                                                                        pEchoChannel->ulLastSSToneTimestamp = ulBaseTimestamp + ((( ausReadData[ j ] >> 5 ) & 0x7) * cOCT6100_LOCAL_TIMESTAMP_INCREMENT );
20887
 
                                                                        break;
20888
 
                                                                case 2:
20889
 
                                                                        /* This is the "STOP" event, invalidate the last value.  The user does not want to know about this. */
20890
 
                                                                        pEchoChannel->ulLastSSToneDetected = cOCT6100_INVALID_VALUE;
20891
 
                                                                        pEchoChannel->ulLastSSToneTimestamp = cOCT6100_INVALID_VALUE;
20892
 
                                                                        break;
20893
 
                                                                default:
20894
 
                                                                        break;
20895
 
                                                                }
20896
 
                                                        }
20897
 
                                                }
20898
 
                                        }
20899
 
                                        ulToneCnt++;
20900
 
                                }
20901
 
                        }
20902
 
                        else
20903
 
                        {
20904
 
                                /* Set the overflow flag of the buffer. */
20905
 
                                pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
20906
 
 
20907
 
                                /* We continue in the loop in order to empty the hardware buffer. */
20908
 
                        }
20909
 
 
20910
 
                        /* Update the control variables of the buffer. */
20911
 
                        ulChipReadPtr++;
20912
 
                        if ( ulChipReadPtr == cOCT6100_NUM_PGSP_EVENT_OUT )
20913
 
                                ulChipReadPtr = 0;
20914
 
                }
20915
 
        }
20916
 
 
20917
 
        /* Write the value of the new Read pointer.*/
20918
 
        WriteParams.ulWriteAddress = cOCT6100_TONE_EVENT_READ_PTR_REG;
20919
 
        WriteParams.usWriteData = (UINT16)( ulChipReadPtr );
20920
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
20921
 
        if ( ulResult != cOCT6100_ERR_OK )
20922
 
                return ulResult;
20923
 
 
20924
 
 
20925
 
 
20926
 
        return cOCT6100_ERR_OK;
20927
 
}
20928
 
 
20929
 
 
20930
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20931
 
 
20932
 
Function:               Oct6100BufferPlayoutTransferEvents
20933
 
 
20934
 
Description:    Check all channels that are currently playing a buffer and 
20935
 
                                generate an event if a buffer has stopped playing.
20936
 
 
20937
 
-------------------------------------------------------------------------------
20938
 
|       Argument                |       Description
20939
 
-------------------------------------------------------------------------------
20940
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
20941
 
                                                the present state of the chip and all its resources.
20942
 
 
20943
 
f_ulResetBuf                    Reset flag.
20944
 
 
20945
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20946
 
static UINT32 Oct6100BufferPlayoutTransferEvents(
20947
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
20948
 
                                IN              UINT32                                                  f_ulResetBuf )
20949
 
{
20950
 
        tPOCT6100_SHARED_INFO                           pSharedInfo;
20951
 
        tPOCT6100_API_CHANNEL                           pEchoChannel;
20952
 
 
20953
 
        UINT32  ulChannelIndex;
20954
 
        UINT32  ulResult;
20955
 
        UINT32  ulLastBufPlayoutEventBufferOverflowCnt;
20956
 
 
20957
 
        /* Get local pointer(s). */
20958
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
20959
 
 
20960
 
        /* If the buffer is to be reset then clear the overflow flag. */
20961
 
        if ( f_ulResetBuf == TRUE )
20962
 
        {
20963
 
                pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt = 0;
20964
 
                /* We are done for now. */
20965
 
                /* No need to check for new events since the user requested to empty the soft buffer. */
20966
 
                return cOCT6100_ERR_OK;
20967
 
        }
20968
 
 
20969
 
        /* Check if buffer playout has been activated on some ports. */
20970
 
        if ( pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts == 0 )
20971
 
        {
20972
 
                /* Buffer playout has not been activated on any channel, */
20973
 
                /* let's not waste time here. */
20974
 
                return cOCT6100_ERR_OK;
20975
 
        }
20976
 
 
20977
 
        /* Save the current overflow count.  We want to know if an overflow occured to get out of the loop. */
20978
 
        ulLastBufPlayoutEventBufferOverflowCnt = pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt;
20979
 
 
20980
 
        /* Search through the list of API channel entry for the ones that need playout event checking. */
20981
 
        for ( ulChannelIndex = 0; ulChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; ulChannelIndex++ )
20982
 
        {
20983
 
                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, ulChannelIndex );
20984
 
                
20985
 
                /* Check if buffer playout is active on this channel, using the optimization flag. */
20986
 
                /* This flag is redundant of other flags used for playout, but will make the above loop */
20987
 
                /* much faster.  This is needed since this function is called very frequently on systems */
20988
 
                /* which use buffer playout stop events. */
20989
 
                if ( pEchoChannel->fBufPlayoutActive == TRUE )
20990
 
                {
20991
 
                        /* Read in the event only if there's enough room in the soft buffer. */
20992
 
                        if ( ulLastBufPlayoutEventBufferOverflowCnt == pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt )
20993
 
                        {
20994
 
                                /* Check Rout buffer playout first. */
20995
 
                                if ( ( pEchoChannel->fRinBufPlayoutNotifyOnStop == TRUE )
20996
 
                                        && ( pEchoChannel->fRinBufPlaying == TRUE ) )
20997
 
                                {
20998
 
                                        ulResult = Oct6100BufferPlayoutCheckForSpecificEvent( f_pApiInstance, ulChannelIndex, cOCT6100_CHANNEL_PORT_ROUT, TRUE, NULL );
20999
 
                                        if ( ulResult != cOCT6100_ERR_OK )
21000
 
                                                return ulResult;
21001
 
                                }
21002
 
                        }
21003
 
                        else /* if ( ulLastBufPlayoutEventBufferOverflowCnt != pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt ) */
21004
 
                        {
21005
 
                                /* Get out of the loop, no more events can be inserted in the soft buffer. */
21006
 
                                break;
21007
 
                        }
21008
 
 
21009
 
                        /* An overflow might have been detected in the lower level function. */
21010
 
                        /* Check the overflow count once again to make sure there might be room for a next event. */
21011
 
                        if ( ulLastBufPlayoutEventBufferOverflowCnt == pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt )
21012
 
                        {
21013
 
                                /* Check Sout buffer playout. */
21014
 
                                if ( ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == TRUE )
21015
 
                                        && ( pEchoChannel->fSoutBufPlaying == TRUE ) )
21016
 
                                {
21017
 
                                        ulResult = Oct6100BufferPlayoutCheckForSpecificEvent( f_pApiInstance, ulChannelIndex, cOCT6100_CHANNEL_PORT_SOUT, TRUE, NULL );
21018
 
                                        if ( ulResult != cOCT6100_ERR_OK )
21019
 
                                                return ulResult;
21020
 
                                }
21021
 
                        }
21022
 
                        else /* if ( ulLastBufPlayoutEventBufferOverflowCnt != pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt ) */
21023
 
                        {
21024
 
                                /* Get out of the loop, no more events can be inserted in the soft buffer. */
21025
 
                                break;
21026
 
                        }
21027
 
                }
21028
 
        }
21029
 
 
21030
 
        return cOCT6100_ERR_OK;
21031
 
}
21032
 
 
21033
 
 
21034
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21035
 
 
21036
 
Function:               Oct6100BufferPlayoutCheckForSpecificEvent
21037
 
 
21038
 
Description:    Check a specific channel/port for playout buffer events.
21039
 
                                If asked to, save this event to the software event buffer.
21040
 
                                Return a flag specifying whether the event was detected or not.
21041
 
 
21042
 
-------------------------------------------------------------------------------
21043
 
|       Argument                |       Description
21044
 
-------------------------------------------------------------------------------
21045
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
21046
 
                                                the present state of the chip and all its resources.
21047
 
 
21048
 
f_ulChannelIndex                Index of the channel to be checked.
21049
 
f_ulChannelPort                 Port of the channel to be checked.
21050
 
f_fSaveToSoftBuffer             Save event to software buffer. 
21051
 
f_pfEventDetected               Whether or not an event was detected.
21052
 
 
21053
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21054
 
static UINT32 Oct6100BufferPlayoutCheckForSpecificEvent(
21055
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
21056
 
                                IN              UINT32                                                  f_ulChannelIndex,
21057
 
                                IN              UINT32                                                  f_ulChannelPort,
21058
 
                                IN              BOOL                                                    f_fSaveToSoftBuffer,
21059
 
                                OUT             PBOOL                                                   f_pfEventDetected )
21060
 
{
21061
 
        tPOCT6100_SHARED_INFO                           pSharedInfo;
21062
 
        tPOCT6100_API_BUFFER_PLAYOUT_EVENT      pSoftEvent;
21063
 
        tPOCT6100_API_CHANNEL                           pEchoChannel;
21064
 
        tOCT6100_READ_PARAMS                            ReadParams;
21065
 
        tOCT6100_GET_TIME                                       GetTimeParms;
21066
 
 
21067
 
        UINT32  ulResult;
21068
 
        UINT16  usReadData;
21069
 
        UINT32  ulReadPtrBytesOfst;
21070
 
        UINT32  ulReadPtrBitOfst;
21071
 
        UINT32  ulReadPtrFieldSize;
21072
 
 
21073
 
        UINT32  ulWritePtrBytesOfst;
21074
 
        UINT32  ulWritePtrBitOfst;
21075
 
        UINT32  ulWritePtrFieldSize;
21076
 
 
21077
 
        UINT32  ulPlayoutBaseAddress;
21078
 
        UINT32  ulTempData;
21079
 
        UINT32  ulReadPtr;
21080
 
        UINT32  ulMask;
21081
 
        UINT32  ulWritePtr;
21082
 
        UINT32  ulUserEventId;
21083
 
        UINT32  ulEventType;
21084
 
 
21085
 
        /* Get local pointer(s). */
21086
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
21087
 
 
21088
 
        /* Compare the read and write pointers for matching.  If they matched, playout stopped. */
21089
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, f_ulChannelIndex );
21090
 
 
21091
 
        /* Set the playout feature base address. */
21092
 
        ulPlayoutBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_ulChannelIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
21093
 
 
21094
 
        if ( f_ulChannelPort == cOCT6100_CHANNEL_PORT_ROUT )
21095
 
        {
21096
 
                /* Check on the Rout port. */
21097
 
                ulUserEventId = pEchoChannel->ulRinUserBufPlayoutEventId;
21098
 
                ulEventType = pEchoChannel->byRinPlayoutStopEventType;
21099
 
 
21100
 
                ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.usDwordOffset * 4;
21101
 
                ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byBitOffset;
21102
 
                ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byFieldSize;
21103
 
 
21104
 
                ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.usDwordOffset * 4;
21105
 
                ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byBitOffset;
21106
 
                ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byFieldSize;
21107
 
        }
21108
 
        else /* if ( f_ulChannelPort == cOCT6100_CHANNEL_PORT_SOUT ) */
21109
 
        {
21110
 
                /* Check on the Sout port. */
21111
 
                ulUserEventId = pEchoChannel->ulSoutUserBufPlayoutEventId;
21112
 
                ulEventType = pEchoChannel->bySoutPlayoutStopEventType;
21113
 
 
21114
 
                ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.usDwordOffset * 4;
21115
 
                ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byBitOffset;
21116
 
                ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byFieldSize;
21117
 
 
21118
 
                ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.usDwordOffset * 4;
21119
 
                ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byBitOffset;
21120
 
                ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byFieldSize;
21121
 
        }
21122
 
 
21123
 
        /* Retrieve the current write pointer. */
21124
 
        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance, 
21125
 
                                                                                pEchoChannel, 
21126
 
                                                                                ulPlayoutBaseAddress + ulWritePtrBytesOfst, 
21127
 
                                                                                &ulTempData,
21128
 
                                                                                ulResult );
21129
 
        if ( ulResult != cOCT6100_ERR_OK )
21130
 
                return ulResult;
21131
 
 
21132
 
        mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask );
21133
 
 
21134
 
        /* Store the write pointer.*/
21135
 
        ulWritePtr = ( ulTempData & ulMask ) >> ulWritePtrBitOfst;
21136
 
 
21137
 
        /* Read the read pointer.*/
21138
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
21139
 
 
21140
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
21141
 
        ReadParams.pusReadData = &usReadData;
21142
 
        ReadParams.ulReadAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst;
21143
 
 
21144
 
        /* Optimize this access by only reading the word we are interested in. */
21145
 
        if ( ulReadPtrBitOfst < 16 )
21146
 
                ReadParams.ulReadAddress += 2;
21147
 
 
21148
 
        /* Must read in memory directly since this value is changed by hardware */
21149
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
21150
 
        if ( ulResult != cOCT6100_ERR_OK )
21151
 
                return ulResult;
21152
 
 
21153
 
        /* Move data at correct position according to what was read. */
21154
 
        if ( ulReadPtrBitOfst < 16 )
21155
 
                ulTempData = usReadData;
21156
 
        else
21157
 
                ulTempData = usReadData << 16;
21158
 
        
21159
 
        mOCT6100_CREATE_FEATURE_MASK( ulReadPtrFieldSize, ulReadPtrBitOfst, &ulMask );
21160
 
        
21161
 
        /* Store the read pointer. */
21162
 
        ulReadPtr = ( ulTempData & ulMask ) >> ulReadPtrBitOfst;
21163
 
 
21164
 
        /* Playout has finished when the read pointer reaches the write pointer. */
21165
 
        if ( ulReadPtr != ulWritePtr )
21166
 
        {
21167
 
                /* Still playing -- do not generate an event. */
21168
 
                if ( f_pfEventDetected != NULL )
21169
 
                        *f_pfEventDetected = FALSE;
21170
 
        }
21171
 
        else
21172
 
        {
21173
 
                /* Buffer stopped playing, generate an event here, if asked. */
21174
 
                if ( ( f_fSaveToSoftBuffer == TRUE ) 
21175
 
                                && ( ( pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr + 1 ) != pSharedInfo->SoftBufs.ulBufPlayoutEventBufferReadPtr ) 
21176
 
                                && ( ( pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr + 1 ) != pSharedInfo->SoftBufs.ulBufPlayoutEventBufferSize || pSharedInfo->SoftBufs.ulBufPlayoutEventBufferReadPtr != 0 ) )
21177
 
                {
21178
 
                        /* The API can create a soft buffer playout event. */
21179
 
                        mOCT6100_GET_BUFFER_PLAYOUT_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
21180
 
                        pSoftEvent += pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr;
21181
 
 
21182
 
                        pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChannel->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_ulChannelIndex; 
21183
 
                        pSoftEvent->ulUserChanId = pEchoChannel->ulUserChanId;
21184
 
                        pSoftEvent->ulUserEventId = ulUserEventId;
21185
 
                        pSoftEvent->ulChannelPort = f_ulChannelPort;
21186
 
                        /* For now, only this type of event is available. */
21187
 
                        pSoftEvent->ulEventType = ulEventType;
21188
 
                        
21189
 
                        /* Generate millisecond timestamp. */
21190
 
                        GetTimeParms.pProcessContext = f_pApiInstance->pProcessContext;
21191
 
                        ulResult = Oct6100UserGetTime( &GetTimeParms );
21192
 
                        if ( ulResult != cOCT6100_ERR_OK )
21193
 
                                return ulResult;
21194
 
 
21195
 
                        pSoftEvent->ulTimestamp = ( GetTimeParms.aulWallTimeUs[ 0 ] / 1000 );
21196
 
                        pSoftEvent->ulTimestamp += ( GetTimeParms.aulWallTimeUs[ 1 ] ) * ( 0xFFFFFFFF / 1000 );
21197
 
 
21198
 
                        /* Update the control variables of the buffer. */
21199
 
                        pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr++;
21200
 
                        if ( pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr == pSharedInfo->SoftBufs.ulBufPlayoutEventBufferSize )
21201
 
                                pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr = 0;
21202
 
 
21203
 
                        /* Set the interrupt manager such that the user knows that some playout events */
21204
 
                        /* are pending in the software Q. */
21205
 
                        pSharedInfo->IntrptManage.fBufferPlayoutEventsPending = TRUE;
21206
 
                }
21207
 
                else if ( f_fSaveToSoftBuffer == TRUE ) 
21208
 
                {
21209
 
                        /* Set the overflow flag of the buffer. */
21210
 
                        pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt++;
21211
 
                }
21212
 
 
21213
 
                /* Update the channel entry to set the playing flag to FALSE. */
21214
 
 
21215
 
                /* Select the port of interest. */
21216
 
                if ( f_ulChannelPort == cOCT6100_CHANNEL_PORT_ROUT )
21217
 
                {
21218
 
                        /* Decrement the number of active buffer playout ports. */
21219
 
                        /* No need to check anything here, it's been done in the calling function. */
21220
 
                        pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--;
21221
 
 
21222
 
                        pEchoChannel->fRinBufPlaying = FALSE;
21223
 
                        pEchoChannel->fRinBufPlayoutNotifyOnStop = FALSE;
21224
 
 
21225
 
                        /* Clear optimization flag if possible. */
21226
 
                        if ( ( pEchoChannel->fSoutBufPlaying == FALSE )
21227
 
                                && ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == FALSE ) )
21228
 
                        {
21229
 
                                /* Buffer playout is no more active on this channel. */
21230
 
                                pEchoChannel->fBufPlayoutActive = FALSE;
21231
 
                        }
21232
 
                }
21233
 
                else /* f_ulChannelPort == cOCT6100_CHANNEL_PORT_SOUT */
21234
 
                {
21235
 
                        /* Decrement the number of active buffer playout ports. */
21236
 
                        /* No need to check anything here, it's been done in the calling function. */
21237
 
                        pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--;
21238
 
 
21239
 
                        pEchoChannel->fSoutBufPlaying = FALSE;
21240
 
                        pEchoChannel->fSoutBufPlayoutNotifyOnStop = FALSE;
21241
 
 
21242
 
                        /* Clear optimization flag if possible. */
21243
 
                        if ( ( pEchoChannel->fRinBufPlaying == FALSE )
21244
 
                                && ( pEchoChannel->fRinBufPlayoutNotifyOnStop == FALSE ) )
21245
 
                        {
21246
 
                                /* Buffer playout is no more active on this channel. */
21247
 
                                pEchoChannel->fBufPlayoutActive = FALSE;
21248
 
                        }
21249
 
                }
21250
 
 
21251
 
                /* Return that an event was detected. */
21252
 
                if ( f_pfEventDetected != NULL )
21253
 
                        *f_pfEventDetected = TRUE;
21254
 
        }
21255
 
        
21256
 
        return cOCT6100_ERR_OK;
21257
 
}
21258
 
 
21259
 
#endif /* cOCT6100_REMOVE_EVENTS */
21260
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21261
 
 
21262
 
File: oct6100_interrupts.c
21263
 
 
21264
 
    Copyright (c) 2001-2005 Octasic Inc.
21265
 
    
21266
 
Description: 
21267
 
 
21268
 
        This file contains the API's interrupt service routine and all of its
21269
 
        sub-functions.
21270
 
 
21271
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
21272
 
free software; you can redistribute it and/or modify it under the terms of 
21273
 
the GNU General Public License as published by the Free Software Foundation; 
21274
 
either version 2 of the License, or (at your option) any later version.
21275
 
 
21276
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
21277
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
21278
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
21279
 
for more details. 
21280
 
 
21281
 
You should have received a copy of the GNU General Public License 
21282
 
along with the OCT6100 GPL API; if not, write to the Free Software 
21283
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21284
 
 
21285
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
21286
 
 
21287
 
$Octasic_Revision: 71 $
21288
 
 
21289
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21290
 
 
21291
 
 
21292
 
/*****************************  INCLUDE FILES  *******************************/
21293
 
 
21294
 
#include "octdef.h"
21295
 
 
21296
 
#include "oct6100api/oct6100_defines.h"
21297
 
#include "oct6100api/oct6100_errors.h"
21298
 
#include "oct6100api/oct6100_apiud.h"
21299
 
 
21300
 
#include "oct6100api/oct6100_tlv_inst.h"
21301
 
#include "oct6100api/oct6100_chip_open_inst.h"
21302
 
#include "oct6100api/oct6100_chip_stats_inst.h"
21303
 
#include "oct6100api/oct6100_interrupts_inst.h"
21304
 
#include "oct6100api/oct6100_remote_debug_inst.h"
21305
 
#include "oct6100api/oct6100_debug_inst.h"
21306
 
#include "oct6100api/oct6100_api_inst.h"
21307
 
 
21308
 
#include "oct6100api/oct6100_interrupts_pub.h"
21309
 
#include "oct6100api/oct6100_chip_open_pub.h"
21310
 
#include "oct6100api/oct6100_events_pub.h"
21311
 
#include "oct6100api/oct6100_channel_pub.h"
21312
 
#include "oct6100api/oct6100_interrupts_pub.h"
21313
 
 
21314
 
#include "oct6100_chip_open_priv.h"
21315
 
#include "oct6100_miscellaneous_priv.h"
21316
 
#include "oct6100_events_priv.h"
21317
 
#include "oct6100_interrupts_priv.h"
21318
 
 
21319
 
 
21320
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21321
 
 
21322
 
Function:               Oct6100InterruptServiceRoutine
21323
 
 
21324
 
Description:    The API's interrupt service routine.  This function clears all
21325
 
                                register ROLs which have generated an interrupt and report the
21326
 
                                events in the user supplied structure.  Also, the tone event
21327
 
                                and/or playout event buffer will be emptied if valid events 
21328
 
                                are present.
21329
 
 
21330
 
-------------------------------------------------------------------------------
21331
 
|       Argument                |       Description
21332
 
-------------------------------------------------------------------------------
21333
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
21334
 
                                                the present state of the chip and all its resources.
21335
 
 
21336
 
f_pIntFlags                             Pointer to structure containing event flags returned
21337
 
                                                to user.
21338
 
 
21339
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21340
 
static UINT32 Oct6100InterruptServiceRoutineDef(
21341
 
                                tPOCT6100_INTERRUPT_FLAGS                       f_pIntFlags )
21342
 
{
21343
 
        f_pIntFlags->fFatalGeneral = FALSE;
21344
 
        f_pIntFlags->ulFatalGeneralFlags = 0x0;
21345
 
        f_pIntFlags->fFatalReadTimeout = FALSE;
21346
 
        
21347
 
        f_pIntFlags->fErrorRefreshTooLate = FALSE;
21348
 
        f_pIntFlags->fErrorPllJitter = FALSE;
21349
 
        
21350
 
        f_pIntFlags->fErrorOverflowToneEvents = FALSE;
21351
 
 
21352
 
        f_pIntFlags->fErrorH100OutOfSync = FALSE;
21353
 
        f_pIntFlags->fErrorH100ClkA = FALSE;
21354
 
        f_pIntFlags->fErrorH100ClkB = FALSE;
21355
 
        f_pIntFlags->fErrorH100FrameA = FALSE;
21356
 
 
21357
 
        f_pIntFlags->fToneEventsPending = FALSE;
21358
 
        f_pIntFlags->fBufferPlayoutEventsPending = FALSE;
21359
 
 
21360
 
        f_pIntFlags->fApiSynch = FALSE;
21361
 
 
21362
 
 
21363
 
 
21364
 
        return cOCT6100_ERR_OK;
21365
 
}
21366
 
 
21367
 
 
21368
 
static UINT32 Oct6100InterruptServiceRoutine(
21369
 
                                tPOCT6100_INSTANCE_API                          f_pApiInstance,
21370
 
                                tPOCT6100_INTERRUPT_FLAGS                       f_pIntFlags )
21371
 
{
21372
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
21373
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
21374
 
        UINT32  ulResult;
21375
 
        UINT32  ulFncRes;
21376
 
 
21377
 
        /* Set the process context of the serialize structure. */
21378
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
21379
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
21380
 
 
21381
 
        /* Seize the serialization object for the ISR. */
21382
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
21383
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
21384
 
        ulResult = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
21385
 
        if ( ulResult == cOCT6100_ERR_OK )
21386
 
        {       
21387
 
                /* Call the serialized sub-function. */
21388
 
                ulFncRes = Oct6100InterruptServiceRoutineSer( f_pApiInstance, f_pIntFlags );
21389
 
        }
21390
 
        else
21391
 
        {
21392
 
                return ulResult;
21393
 
        }
21394
 
 
21395
 
        /* Release the serialization object. */
21396
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
21397
 
        ulResult = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
21398
 
        if ( ulResult != cOCT6100_ERR_OK )
21399
 
                return ulResult;
21400
 
 
21401
 
        /* Check for an error in the sub-function. */
21402
 
        if ( ulFncRes != cOCT6100_ERR_OK )
21403
 
                return ulFncRes;
21404
 
 
21405
 
        return cOCT6100_ERR_OK;
21406
 
}
21407
 
 
21408
 
 
21409
 
/****************************  PRIVATE FUNCTIONS  ****************************/
21410
 
 
21411
 
 
21412
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21413
 
 
21414
 
Function:               Oct6100ApiIsrSwInit
21415
 
 
21416
 
Description:    Initializes portions of API instance associated to the API's 
21417
 
                                interrupt service routine.
21418
 
 
21419
 
-------------------------------------------------------------------------------
21420
 
|       Argument                |       Description
21421
 
-------------------------------------------------------------------------------
21422
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
21423
 
                                                the present state of the chip and all its resources.
21424
 
 
21425
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21426
 
static UINT32 Oct6100ApiIsrSwInit(
21427
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
21428
 
{
21429
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
21430
 
 
21431
 
        /* Get local pointer to shared portion of instance. */
21432
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
21433
 
 
21434
 
        /* Set the state of each interrupt group to disabled.  The state will */
21435
 
        /* be updated to the true configuration once the configure interrupts function is called. */
21436
 
        pSharedInfo->IntrptManage.byFatalGeneralState = cOCT6100_INTRPT_DISABLED;
21437
 
        pSharedInfo->IntrptManage.byFatalMemoryState = cOCT6100_INTRPT_DISABLED;
21438
 
        pSharedInfo->IntrptManage.byErrorMemoryState = cOCT6100_INTRPT_DISABLED;
21439
 
        pSharedInfo->IntrptManage.byErrorH100State = cOCT6100_INTRPT_DISABLED;
21440
 
        pSharedInfo->IntrptManage.byErrorOverflowToneEventsState = cOCT6100_INTRPT_DISABLED;
21441
 
 
21442
 
        /* Indicate that the mclk interrupt is not active at the moment. */
21443
 
        pSharedInfo->IntrptManage.fMclkIntrptActive = FALSE;
21444
 
 
21445
 
        /* Indicate that no buffer playout events are pending for the moment. */
21446
 
        pSharedInfo->IntrptManage.fBufferPlayoutEventsPending = FALSE;
21447
 
 
21448
 
        /* Indicate that no tone events are pending for the moment. */
21449
 
        pSharedInfo->IntrptManage.fToneEventsPending = FALSE;
21450
 
 
21451
 
        /* The ISR has never been called. */
21452
 
        pSharedInfo->IntrptManage.fIsrCalled = FALSE;
21453
 
 
21454
 
        return cOCT6100_ERR_OK;
21455
 
}
21456
 
 
21457
 
 
21458
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21459
 
 
21460
 
Function:               Oct6100ApiIsrHwInit
21461
 
 
21462
 
Description:    Initializes the chip's interrupt registers.
21463
 
 
21464
 
-------------------------------------------------------------------------------
21465
 
|       Argument                |       Description
21466
 
-------------------------------------------------------------------------------
21467
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
21468
 
                                                the present state of the chip and all its resources.
21469
 
 
21470
 
f_pIntrptConfig                 Pointer to structure defining how the interrupts
21471
 
                                                should be configured.
21472
 
 
21473
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21474
 
static UINT32 Oct6100ApiIsrHwInit(
21475
 
                        IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
21476
 
                        IN              tPOCT6100_INTERRUPT_CONFIGURE           f_pIntrptConfig )
21477
 
{
21478
 
        tOCT6100_WRITE_PARAMS   WriteParams;
21479
 
        UINT32  ulResult;
21480
 
 
21481
 
        /* Set some parameters of write struct. */
21482
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
21483
 
 
21484
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
21485
 
 
21486
 
        /*==================================================================================*/
21487
 
        /* Enable all the interrupts */
21488
 
        
21489
 
        WriteParams.ulWriteAddress = 0x104;
21490
 
        WriteParams.usWriteData = 0x0001;
21491
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21492
 
        if ( ulResult != cOCT6100_ERR_OK )
21493
 
                return ulResult;
21494
 
 
21495
 
        WriteParams.ulWriteAddress = 0x204;
21496
 
        WriteParams.usWriteData = 0x1C05;
21497
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21498
 
        if ( ulResult != cOCT6100_ERR_OK )
21499
 
                return ulResult;
21500
 
 
21501
 
        WriteParams.ulWriteAddress = 0x304;
21502
 
        WriteParams.usWriteData = 0xFFFF;
21503
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21504
 
        if ( ulResult != cOCT6100_ERR_OK )
21505
 
                return ulResult;
21506
 
 
21507
 
        WriteParams.ulWriteAddress = 0x504;
21508
 
        WriteParams.usWriteData = 0x0001;
21509
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21510
 
        if ( ulResult != cOCT6100_ERR_OK )
21511
 
                return ulResult;
21512
 
 
21513
 
        WriteParams.ulWriteAddress = 0x704;
21514
 
        WriteParams.usWriteData = 0x0007;
21515
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21516
 
        if ( ulResult != cOCT6100_ERR_OK )
21517
 
                return ulResult;
21518
 
        
21519
 
        /*==================================================================================*/
21520
 
 
21521
 
        /* Calculate the number of mclk cycles in 1 ms. */
21522
 
        f_pApiInstance->pSharedInfo->IntrptManage.ulNumMclkCyclesIn1Ms = f_pApiInstance->pSharedInfo->MiscVars.ulMclkFreq / 1000;
21523
 
 
21524
 
        /* Configure the interrupt registers as requested by the user. */
21525
 
        ulResult = Oct6100InterruptConfigureSer( f_pApiInstance, f_pIntrptConfig, TRUE );
21526
 
        if ( ulResult != cOCT6100_ERR_OK )
21527
 
                return ulResult;
21528
 
 
21529
 
        return cOCT6100_ERR_OK;
21530
 
}
21531
 
 
21532
 
 
21533
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21534
 
 
21535
 
Function:               Oct6100InterruptConfigureSer
21536
 
 
21537
 
Description:    Configure the operation of interrupt groups.
21538
 
 
21539
 
-------------------------------------------------------------------------------
21540
 
|       Argument                |       Description
21541
 
-------------------------------------------------------------------------------
21542
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
21543
 
                                                the present state of the chip and all its resources.
21544
 
 
21545
 
f_pIntrptConfig                 Pointer to interrupt configuration structure.
21546
 
f_fCheckParams                  Check parameter enable flag.
21547
 
 
21548
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21549
 
static UINT32 Oct6100InterruptConfigureSer(
21550
 
                        IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
21551
 
                        IN              tPOCT6100_INTERRUPT_CONFIGURE           f_pIntrptConfig,
21552
 
                        IN              BOOL                                                            f_fCheckParams )
21553
 
{
21554
 
        tPOCT6100_API_INTRPT_CONFIG     pIntrptConfig;
21555
 
        tPOCT6100_API_INTRPT_MANAGE     pIntrptManage;
21556
 
        UINT32  ulResult;
21557
 
 
21558
 
        /* Check for errors. */
21559
 
        if ( f_fCheckParams == TRUE )
21560
 
        {
21561
 
                if ( f_pIntrptConfig->ulFatalGeneralConfig != cOCT6100_INTERRUPT_DISABLE &&
21562
 
                         f_pIntrptConfig->ulFatalGeneralConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
21563
 
                        return cOCT6100_ERR_INTRPTS_FATAL_GENERAL_CONFIG;
21564
 
                if ( f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_DISABLE &&
21565
 
                         f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
21566
 
                         f_pIntrptConfig->ulFatalMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
21567
 
                        return cOCT6100_ERR_INTRPTS_FATAL_MEMORY_CONFIG;
21568
 
                if ( f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_DISABLE &&
21569
 
                         f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_TIMEOUT &&
21570
 
                         f_pIntrptConfig->ulErrorMemoryConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
21571
 
                        return cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_CONFIG;
21572
 
                if ( f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_DISABLE &&
21573
 
                         f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_TIMEOUT &&
21574
 
                         f_pIntrptConfig->ulErrorOverflowToneEventsConfig != cOCT6100_INTERRUPT_NO_TIMEOUT )
21575
 
                        return cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_CONFIG;
21576
 
                if ( f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_DISABLE &&
21577
 
                         f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_TIMEOUT &&
21578
 
                         f_pIntrptConfig->ulErrorH100Config != cOCT6100_INTERRUPT_NO_TIMEOUT )
21579
 
                        return cOCT6100_ERR_INTRPTS_H100_ERROR_CONFIG;
21580
 
 
21581
 
                if ( f_pIntrptConfig->ulFatalMemoryTimeout < 10 ||
21582
 
                         f_pIntrptConfig->ulFatalMemoryTimeout > 10000 )
21583
 
                        return cOCT6100_ERR_INTRPTS_FATAL_MEMORY_TIMEOUT;
21584
 
                if ( f_pIntrptConfig->ulErrorMemoryTimeout < 10 ||
21585
 
                         f_pIntrptConfig->ulErrorMemoryTimeout > 10000 )
21586
 
                        return cOCT6100_ERR_INTRPTS_DATA_ERR_MEMORY_TIMEOUT;
21587
 
                if ( f_pIntrptConfig->ulErrorOverflowToneEventsTimeout < 10 ||
21588
 
                         f_pIntrptConfig->ulErrorOverflowToneEventsTimeout > 10000 )
21589
 
                        return cOCT6100_ERR_INTRPTS_OVERFLOW_TONE_EVENTS_TIMEOUT;
21590
 
                if ( f_pIntrptConfig->ulErrorH100Timeout < 10 ||
21591
 
                         f_pIntrptConfig->ulErrorH100Timeout > 10000 )
21592
 
                        return cOCT6100_ERR_INTRPTS_H100_ERROR_TIMEOUT;
21593
 
        }
21594
 
 
21595
 
        /* Copy the configuration to the API instance. */
21596
 
        pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
21597
 
        pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
21598
 
 
21599
 
        pIntrptConfig->byFatalGeneralConfig = (UINT8)( f_pIntrptConfig->ulFatalGeneralConfig & 0xFF );
21600
 
        pIntrptConfig->byFatalMemoryConfig = (UINT8)( f_pIntrptConfig->ulFatalMemoryConfig & 0xFF );
21601
 
        pIntrptConfig->byErrorMemoryConfig = (UINT8)( f_pIntrptConfig->ulErrorMemoryConfig & 0xFF );
21602
 
        pIntrptConfig->byErrorOverflowToneEventsConfig = (UINT8)( f_pIntrptConfig->ulErrorOverflowToneEventsConfig & 0xFF );
21603
 
        pIntrptConfig->byErrorH100Config = (UINT8)( f_pIntrptConfig->ulErrorH100Config & 0xFF );
21604
 
 
21605
 
        f_pIntrptConfig->ulFatalMemoryTimeout = ((f_pIntrptConfig->ulFatalMemoryTimeout + 9) / 10) * 10;
21606
 
        pIntrptConfig->ulFatalMemoryTimeoutMclk = f_pIntrptConfig->ulFatalMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
21607
 
 
21608
 
        f_pIntrptConfig->ulErrorMemoryTimeout = ((f_pIntrptConfig->ulErrorMemoryTimeout + 9) / 10) * 10;
21609
 
        pIntrptConfig->ulErrorMemoryTimeoutMclk = f_pIntrptConfig->ulErrorMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
21610
 
 
21611
 
        f_pIntrptConfig->ulErrorOverflowToneEventsTimeout = ((f_pIntrptConfig->ulErrorOverflowToneEventsTimeout + 9) / 10) * 10;
21612
 
        pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk = f_pIntrptConfig->ulErrorOverflowToneEventsTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
21613
 
 
21614
 
        f_pIntrptConfig->ulErrorH100Timeout = ((f_pIntrptConfig->ulErrorH100Timeout + 9) / 10) * 10;
21615
 
        pIntrptConfig->ulErrorH100TimeoutMclk = f_pIntrptConfig->ulErrorH100Timeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
21616
 
 
21617
 
        /* Before writing the new configuration to the chip's registers, make sure that any */
21618
 
        /* interrupts which are either disabled or have no timeout period are not on the */
21619
 
        /* disabled interrupt list. */
21620
 
 
21621
 
        /*==================================================================================*/
21622
 
        if ( pIntrptConfig->byFatalGeneralConfig == cOCT6100_INTERRUPT_DISABLE )
21623
 
                pIntrptManage->byFatalGeneralState = cOCT6100_INTRPT_DISABLED;
21624
 
        else /* pIntrptConfig->byFatalGeneralConfig == cOCT6100_INTERRUPT_NO_TIMEOUT */
21625
 
                pIntrptManage->byFatalGeneralState = cOCT6100_INTRPT_ACTIVE;
21626
 
 
21627
 
        /*==================================================================================*/
21628
 
        if ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_DISABLE )
21629
 
                pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_DISABLED;
21630
 
        else if ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
21631
 
                pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_ACTIVE;
21632
 
        else /* ( pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
21633
 
        {
21634
 
                if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_DISABLED )
21635
 
                        pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_ACTIVE;
21636
 
        }
21637
 
 
21638
 
        /*==================================================================================*/
21639
 
        if ( pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_DISABLE )
21640
 
                pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_DISABLED;
21641
 
        else if ( pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
21642
 
                pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_ACTIVE;
21643
 
        else /* (pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
21644
 
        {
21645
 
                if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_DISABLED )
21646
 
                        pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_ACTIVE;
21647
 
        }
21648
 
 
21649
 
        /*==================================================================================*/
21650
 
        if ( pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_DISABLE )
21651
 
                pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_DISABLED;
21652
 
        else if ( pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_NO_TIMEOUT )
21653
 
                pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_ACTIVE;
21654
 
        else /* (pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT ) */
21655
 
        {
21656
 
                if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_DISABLED )
21657
 
                        pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_ACTIVE;
21658
 
        }
21659
 
 
21660
 
        /*==================================================================================*/
21661
 
        if ( pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_DISABLE )
21662
 
                pIntrptManage->byErrorH100State = cOCT6100_INTRPT_DISABLED;
21663
 
        else if ( pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_NO_TIMEOUT )
21664
 
                pIntrptManage->byErrorH100State = cOCT6100_INTRPT_ACTIVE;
21665
 
        else /* (pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_TIMEOUT ) */
21666
 
        {
21667
 
                if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_DISABLED )
21668
 
                        pIntrptManage->byErrorH100State = cOCT6100_INTRPT_ACTIVE;
21669
 
        }
21670
 
 
21671
 
        /* Write to the interrupt registers to update the state of each interrupt group. */
21672
 
        ulResult = Oct6100ApiWriteIeRegs( f_pApiInstance );
21673
 
        if ( ulResult != cOCT6100_ERR_OK )
21674
 
                return ulResult;
21675
 
 
21676
 
        return cOCT6100_ERR_OK;
21677
 
}
21678
 
 
21679
 
 
21680
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21681
 
 
21682
 
Function:               Oct6100InterruptServiceRoutineSer
21683
 
 
21684
 
Description:    Serialized sub-function of API's interrupt service routine.
21685
 
 
21686
 
-------------------------------------------------------------------------------
21687
 
|       Argument                |       Description
21688
 
-------------------------------------------------------------------------------
21689
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
21690
 
                                                the present state of the chip and all its resources.
21691
 
 
21692
 
f_pIntFlags                             Pointer to structure containing event flags returned
21693
 
                                                to user.
21694
 
 
21695
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21696
 
static UINT32 Oct6100InterruptServiceRoutineSer(
21697
 
                        IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
21698
 
                        IN              tPOCT6100_INTERRUPT_FLAGS                       f_pIntFlags )
21699
 
{
21700
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
21701
 
        tOCT6100_READ_PARAMS    ReadParams;
21702
 
        tOCT6100_WRITE_PARAMS   WriteParams;
21703
 
        UINT32  ulRegister210h;
21704
 
        UINT32  ulResult;
21705
 
        UINT16  usReadData;
21706
 
 
21707
 
        /* Get local pointer(s). */
21708
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
21709
 
 
21710
 
        /* Must update the statistics.  Set parameters in read and write structs. */
21711
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
21712
 
 
21713
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
21714
 
 
21715
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
21716
 
 
21717
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
21718
 
        ReadParams.pusReadData = &usReadData;
21719
 
 
21720
 
        /* Start by reading registers 210h to determine if any modules have flagged an interrupt. */
21721
 
        ReadParams.ulReadAddress = 0x210;
21722
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
21723
 
        if ( ulResult != cOCT6100_ERR_OK )
21724
 
                return ulResult;
21725
 
        ulRegister210h = usReadData;
21726
 
 
21727
 
        /* Update the extended mclk counter. */
21728
 
        ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance );
21729
 
        if ( ulResult != cOCT6100_ERR_OK )
21730
 
                return ulResult;
21731
 
 
21732
 
        /* If the mclk interrupt is active then check which interrupt timeout periods have expired. */
21733
 
        ReadParams.ulReadAddress = 0x302;
21734
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
21735
 
        if ( ulResult != cOCT6100_ERR_OK )
21736
 
                return ulResult;
21737
 
        if ( (usReadData & 0x1) != 0 && pSharedInfo->IntrptManage.fMclkIntrptActive == TRUE )
21738
 
        {
21739
 
                /* Update timeout periods. */
21740
 
                ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance );
21741
 
                if ( ulResult != cOCT6100_ERR_OK )
21742
 
                        return ulResult;
21743
 
 
21744
 
                f_pIntFlags->fApiSynch = TRUE;
21745
 
 
21746
 
                /* Read registers 210h and 212h again to determine if any modules have flagged an interrupt. */
21747
 
                ReadParams.ulReadAddress = 0x210;
21748
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
21749
 
                if ( ulResult != cOCT6100_ERR_OK )
21750
 
                        return ulResult;
21751
 
                ulRegister210h = usReadData;
21752
 
        }
21753
 
 
21754
 
        /* Read the interrupt registers to determine what interrupt conditions have occured. */
21755
 
        ulResult = Oct6100ApiReadIntrptRegs( f_pApiInstance, f_pIntFlags, ulRegister210h );
21756
 
        if ( ulResult != cOCT6100_ERR_OK )
21757
 
                return ulResult;
21758
 
 
21759
 
        /* Empty the tone buffer if any events are pending. */
21760
 
        ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, FALSE );
21761
 
        if ( ulResult != cOCT6100_ERR_OK )
21762
 
                return ulResult;
21763
 
 
21764
 
        /* Set the tone events pending flag. */
21765
 
        f_pIntFlags->fToneEventsPending = pSharedInfo->IntrptManage.fToneEventsPending;
21766
 
 
21767
 
        /* Check for buffer playout events and insert in the software queue -- if activated. */
21768
 
        if ( pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize != 0 )
21769
 
        {
21770
 
                ulResult = Oct6100BufferPlayoutTransferEvents( f_pApiInstance, FALSE );
21771
 
                if ( ulResult != cOCT6100_ERR_OK )
21772
 
                        return ulResult;
21773
 
 
21774
 
                /* Set the buffer playout events pending flag. */
21775
 
                f_pIntFlags->fBufferPlayoutEventsPending = pSharedInfo->IntrptManage.fBufferPlayoutEventsPending;
21776
 
        }
21777
 
 
21778
 
        /* Update the states of each interrupt group. */
21779
 
        ulResult = Oct6100ApiUpdateIntrptStates( f_pApiInstance, f_pIntFlags );
21780
 
        if ( ulResult != cOCT6100_ERR_OK )
21781
 
                return ulResult;
21782
 
 
21783
 
        /* Check the state of the NLP timestamp if required.*/
21784
 
        ulResult = Oct6100ApiCheckProcessorState( f_pApiInstance, f_pIntFlags );
21785
 
        if ( ulResult != cOCT6100_ERR_OK )
21786
 
                return ulResult;
21787
 
 
21788
 
        /* Write to the necessary IE registers. */
21789
 
        ulResult = Oct6100ApiWriteIntrptRegs( f_pApiInstance );
21790
 
        if ( ulResult != cOCT6100_ERR_OK )
21791
 
                return ulResult;
21792
 
 
21793
 
        /* Schedule the next mclk interrupt, if one is needed. */
21794
 
        ulResult = Oct6100ApiScheduleNextMclkIntrptSer( f_pApiInstance );
21795
 
        if ( ulResult != cOCT6100_ERR_OK )
21796
 
                return ulResult;
21797
 
 
21798
 
        /* Free the interrupt pin of the chip (i.e. remove minimum time requirement between interrupts). */
21799
 
        WriteParams.ulWriteAddress = 0x214;
21800
 
        WriteParams.usWriteData = 0x0000;
21801
 
        if ( pSharedInfo->ChipConfig.byInterruptPolarity == cOCT6100_ACTIVE_HIGH_POLARITY )
21802
 
                WriteParams.usWriteData |= 0x4000;
21803
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21804
 
        if ( ulResult != cOCT6100_ERR_OK )
21805
 
                return ulResult;
21806
 
 
21807
 
        /* Indicate that the interrupt ROLs have been treated. */
21808
 
        WriteParams.ulWriteAddress = 0x212;
21809
 
        WriteParams.usWriteData = 0x8000;
21810
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21811
 
        if ( ulResult != cOCT6100_ERR_OK )
21812
 
                return ulResult;
21813
 
 
21814
 
        return cOCT6100_ERR_OK;
21815
 
}
21816
 
 
21817
 
 
21818
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21819
 
 
21820
 
Function:               Oct6100ApiReadIntrptRegs
21821
 
 
21822
 
Description:    Reads the interrupt registers of all modules currently
21823
 
                                indicating an interrupt condition.
21824
 
 
21825
 
-------------------------------------------------------------------------------
21826
 
|       Argument                |       Description
21827
 
-------------------------------------------------------------------------------
21828
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
21829
 
                                                the present state of the chip and all its resources.
21830
 
 
21831
 
f_pIntFlags                             Pointer to an interrupt flag structure.
21832
 
f_ulRegister210h                Value of register 0x210.
21833
 
 
21834
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21835
 
static UINT32 Oct6100ApiReadIntrptRegs(
21836
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
21837
 
                                OUT             tPOCT6100_INTERRUPT_FLAGS               f_pIntFlags,
21838
 
                                IN              UINT32                                                  f_ulRegister210h )
21839
 
{
21840
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
21841
 
        tPOCT6100_API_CHIP_ERROR_STATS  pErrorStats;
21842
 
        tPOCT6100_API_INTRPT_MANAGE             pIntrptManage;
21843
 
        tOCT6100_READ_PARAMS                    ReadParams;
21844
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
21845
 
 
21846
 
        UINT32  ulResult;
21847
 
        UINT16  usReadData;
21848
 
        UINT32  ulFeatureBytesOffset;
21849
 
        UINT32  ulFeatureBitOffset;
21850
 
        UINT32  ulFeatureFieldLength;
21851
 
        UINT32  ulTempData = 0;
21852
 
        UINT32  ulCounterValue;
21853
 
        UINT32  ulMask;
21854
 
 
21855
 
        /* Get local pointer(s). */
21856
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
21857
 
        pErrorStats = &pSharedInfo->ErrorStats;
21858
 
        pIntrptManage = &pSharedInfo->IntrptManage;
21859
 
 
21860
 
        /* Set some parameters of read struct. */
21861
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
21862
 
 
21863
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
21864
 
        ReadParams.pusReadData = &usReadData;
21865
 
 
21866
 
        /* Set some parameters of write struct. */
21867
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
21868
 
 
21869
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
21870
 
 
21871
 
 
21872
 
 
21873
 
        /* CPU registers. */
21874
 
        if ( (f_ulRegister210h & 0x00001) != 0 )
21875
 
        {
21876
 
                /*=======================================================================*/
21877
 
                /* Read registers of this module. */
21878
 
                ReadParams.ulReadAddress = 0x102;
21879
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
21880
 
                if ( ulResult != cOCT6100_ERR_OK )
21881
 
                        return ulResult;
21882
 
 
21883
 
                /* Check which interrupt(s) were set. */
21884
 
                if ( (usReadData & 0x0001) != 0 )
21885
 
                {
21886
 
                        f_pIntFlags->fFatalReadTimeout = TRUE;
21887
 
                        pErrorStats->ulInternalReadTimeoutCnt++;
21888
 
                }
21889
 
 
21890
 
                pIntrptManage->usRegister102h = usReadData;
21891
 
                /*=======================================================================*/
21892
 
        }
21893
 
        else
21894
 
        {
21895
 
                pIntrptManage->usRegister102h = 0x0;
21896
 
        }
21897
 
 
21898
 
        /* MAIN registers. */
21899
 
        if ( (f_ulRegister210h & 0x00002) != 0 )
21900
 
        {
21901
 
                /*=======================================================================*/
21902
 
                /* Read registers of this module. */
21903
 
                ReadParams.ulReadAddress = 0x202;
21904
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
21905
 
                if ( ulResult != cOCT6100_ERR_OK )
21906
 
                        return ulResult;
21907
 
 
21908
 
                /* Save current value in instance. */
21909
 
                pIntrptManage->usRegister202h = usReadData;
21910
 
 
21911
 
                /* Check which interrupts were set. */
21912
 
                if ( (usReadData & 0x0001) != 0 )
21913
 
                {
21914
 
                        f_pIntFlags->fErrorRefreshTooLate = TRUE;
21915
 
                        pErrorStats->ulSdramRefreshTooLateCnt++;
21916
 
                }
21917
 
                if ( (usReadData & 0x0800) != 0 )
21918
 
                {
21919
 
                        f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_1;
21920
 
                        f_pIntFlags->fFatalGeneral = TRUE;
21921
 
                        pErrorStats->fFatalChipError = TRUE;
21922
 
                }
21923
 
                if ( (usReadData & 0x1000) != 0 )
21924
 
                {
21925
 
                        f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_2;
21926
 
                        f_pIntFlags->fFatalGeneral = TRUE;
21927
 
                        pErrorStats->fFatalChipError = TRUE;
21928
 
                }
21929
 
                if ( (usReadData & 0x0400) != 0 )
21930
 
                {
21931
 
                        f_pIntFlags->fErrorPllJitter = TRUE;
21932
 
                        pErrorStats->ulPllJitterErrorCnt++;
21933
 
 
21934
 
                        /* Update the PLL jitter error count here. */
21935
 
                        if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE )
21936
 
                        {
21937
 
                                ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4;
21938
 
                                ulFeatureBitOffset       = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset;
21939
 
                                ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize;
21940
 
 
21941
 
                                ulResult = Oct6100ApiReadDword( f_pApiInstance,
21942
 
                                                                                                cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
21943
 
                                                                                                &ulTempData );
21944
 
                                
21945
 
                                /* Read previous value set in the feature field. */
21946
 
                                mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
21947
 
 
21948
 
                                /* Update counter. */
21949
 
                                ulCounterValue = ulTempData & ulMask;
21950
 
                                ulCounterValue = ulCounterValue >> ulFeatureBitOffset;
21951
 
                                ulCounterValue ++;
21952
 
                                /* Handle wrap around case. */
21953
 
                                ulCounterValue &= ( 1 << ulFeatureFieldLength ) - 1;
21954
 
 
21955
 
                                /* Clear old counter value. */
21956
 
                                ulTempData &= (~ulMask);
21957
 
                                ulTempData |= ulCounterValue << ulFeatureBitOffset;
21958
 
 
21959
 
                                /* Write the DWORD where the field is located.*/
21960
 
                                ulResult = Oct6100ApiWriteDword( f_pApiInstance,
21961
 
                                                                                                 cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
21962
 
                                                                                                 ulTempData );
21963
 
                                if ( ulResult != cOCT6100_ERR_OK )
21964
 
                                        return ulResult;        
21965
 
                        }
21966
 
                }
21967
 
 
21968
 
                /*=======================================================================*/
21969
 
        }
21970
 
        else
21971
 
        {
21972
 
                pIntrptManage->usRegister202h = 0x0;
21973
 
        }
21974
 
 
21975
 
        /* H.100 registers. */
21976
 
        if ( (f_ulRegister210h & 0x00004) != 0 )
21977
 
        {
21978
 
                /*=======================================================================*/
21979
 
                /* Read registers of this module. */
21980
 
                ReadParams.ulReadAddress = 0x302;
21981
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
21982
 
                if ( ulResult != cOCT6100_ERR_OK )
21983
 
                        return ulResult;
21984
 
 
21985
 
                /* Check which interrupts were set. */
21986
 
                if ( (usReadData & 0x0100) != 0 )
21987
 
                {
21988
 
                        f_pIntFlags->fErrorH100OutOfSync = TRUE;
21989
 
                        pErrorStats->ulH100OutOfSyncCnt++;
21990
 
                }
21991
 
                if ( (usReadData & 0x1000) != 0 )
21992
 
                {
21993
 
                        f_pIntFlags->fErrorH100FrameA = TRUE;
21994
 
                        pErrorStats->ulH100FrameABadCnt++;
21995
 
                }
21996
 
                if ( (usReadData & 0x4000) != 0 )
21997
 
                {
21998
 
                        f_pIntFlags->fErrorH100ClkA = TRUE;
21999
 
                        pErrorStats->ulH100ClkABadCnt++;
22000
 
                }
22001
 
                if ( (usReadData & 0x8000) != 0 )
22002
 
                {
22003
 
                        if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
22004
 
                        {
22005
 
                                f_pIntFlags->fErrorH100ClkB = TRUE;
22006
 
                                pErrorStats->ulH100ClkBBadCnt++;
22007
 
                        }
22008
 
                }
22009
 
 
22010
 
                pIntrptManage->usRegister302h = usReadData;
22011
 
                /*=======================================================================*/
22012
 
        }
22013
 
        else
22014
 
        {
22015
 
                pIntrptManage->usRegister302h = 0x0;
22016
 
        }
22017
 
 
22018
 
        /* TDMIE registers. */
22019
 
        if ( (f_ulRegister210h & 0x00010) != 0 )
22020
 
        {
22021
 
                /*=======================================================================*/
22022
 
                /* Read register. */
22023
 
                ReadParams.ulReadAddress = 0x502;
22024
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22025
 
                if ( ulResult != cOCT6100_ERR_OK )
22026
 
                        return ulResult;
22027
 
 
22028
 
                /* Check which interrupts were set. */
22029
 
                if ( (usReadData & 0x0002) != 0 )
22030
 
                {
22031
 
                        f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_3;
22032
 
                        f_pIntFlags->fFatalGeneral = TRUE;
22033
 
                        pErrorStats->fFatalChipError = TRUE;
22034
 
                }
22035
 
 
22036
 
                pIntrptManage->usRegister502h = usReadData;
22037
 
                /*=======================================================================*/
22038
 
        }
22039
 
        else
22040
 
        {
22041
 
                pIntrptManage->usRegister502h = 0x0;
22042
 
        }
22043
 
 
22044
 
        /* PGSP registers. */
22045
 
        if ( (f_ulRegister210h & 0x00080) != 0 )
22046
 
        {
22047
 
                /*=======================================================================*/
22048
 
                /* Read register. */
22049
 
                ReadParams.ulReadAddress = 0x702;
22050
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22051
 
                if ( ulResult != cOCT6100_ERR_OK )
22052
 
                        return ulResult;
22053
 
 
22054
 
                /* Check which interrupts were set. */
22055
 
                if ( (usReadData & 0x0002) != 0 )
22056
 
                {
22057
 
                        f_pIntFlags->fErrorOverflowToneEvents = TRUE;
22058
 
                        pErrorStats->ulOverflowToneEventsCnt++;
22059
 
                }
22060
 
        
22061
 
                pIntrptManage->usRegister702h = usReadData;
22062
 
                /*=======================================================================*/
22063
 
        }
22064
 
        else
22065
 
        {
22066
 
                pIntrptManage->usRegister702h = 0x0;
22067
 
        }
22068
 
        
22069
 
 
22070
 
 
22071
 
        /* If this is the first time the ISR is called, clear the ISR is not called bit */
22072
 
        /* in external memory to signal the remote client that we are called. */
22073
 
        if ( pSharedInfo->IntrptManage.fIsrCalled == FALSE )
22074
 
        {
22075
 
                /* Remember that we are being called. */
22076
 
                pSharedInfo->IntrptManage.fIsrCalled = TRUE;
22077
 
 
22078
 
                if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE )
22079
 
                {
22080
 
                        ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4;
22081
 
                        ulFeatureBitOffset       = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset;
22082
 
                        ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize;
22083
 
 
22084
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
22085
 
                                                                                        cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
22086
 
                                                                                        &ulTempData );
22087
 
                        
22088
 
                        /* Read previous value set in the feature field. */
22089
 
                        mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
22090
 
 
22091
 
                        /* Clear the field. */
22092
 
                        ulTempData &= (~ulMask);
22093
 
 
22094
 
                        /* Write the DWORD where the field is located.*/
22095
 
                        ulResult = Oct6100ApiWriteDword( f_pApiInstance,
22096
 
                                                                                         cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
22097
 
                                                                                         ulTempData );
22098
 
                        if ( ulResult != cOCT6100_ERR_OK )
22099
 
                                return ulResult;        
22100
 
                }
22101
 
        }
22102
 
 
22103
 
        return cOCT6100_ERR_OK;
22104
 
}
22105
 
 
22106
 
 
22107
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22108
 
 
22109
 
Function:               Oct6100ApiUpdateIntrptStates
22110
 
 
22111
 
Description:    Updates the state of all interrupt register groups.
22112
 
 
22113
 
-------------------------------------------------------------------------------
22114
 
|       Argument                |       Description
22115
 
-------------------------------------------------------------------------------
22116
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
22117
 
                                                the present state of the chip and all its resources.
22118
 
 
22119
 
f_pIntFlags                             Interrupt flags.
22120
 
 
22121
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22122
 
static UINT32 Oct6100ApiUpdateIntrptStates(
22123
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
22124
 
                                IN              tPOCT6100_INTERRUPT_FLAGS               f_pIntFlags )
22125
 
{
22126
 
        tPOCT6100_API_INTRPT_CONFIG     pIntrptConfig;
22127
 
        tPOCT6100_API_INTRPT_MANAGE     pIntrptManage;
22128
 
 
22129
 
        pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
22130
 
        pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
22131
 
 
22132
 
        /*-----------------------------------------------------------------------*/
22133
 
        if ( ( f_pIntFlags->fFatalReadTimeout == TRUE) &&
22134
 
                 pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
22135
 
                 pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22136
 
        {
22137
 
                pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
22138
 
                pIntrptManage->ulFatalMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
22139
 
                pIntrptManage->ulFatalMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
22140
 
        }
22141
 
        /*-----------------------------------------------------------------------*/
22142
 
        if ( (f_pIntFlags->fErrorRefreshTooLate == TRUE || 
22143
 
                  f_pIntFlags->fErrorPllJitter == TRUE ) &&
22144
 
                 pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
22145
 
                 pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
22146
 
        {
22147
 
                pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
22148
 
                pIntrptManage->ulErrorMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
22149
 
                pIntrptManage->ulErrorMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
22150
 
        }
22151
 
        /*-----------------------------------------------------------------------*/
22152
 
        if ( (f_pIntFlags->fErrorOverflowToneEvents == TRUE) &&
22153
 
                 pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT &&
22154
 
                 pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
22155
 
        {
22156
 
                pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_WILL_TIMEOUT;
22157
 
                pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
22158
 
                pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
22159
 
        }
22160
 
        /*-----------------------------------------------------------------------*/
22161
 
        if ( (f_pIntFlags->fErrorH100OutOfSync == TRUE ||
22162
 
                  f_pIntFlags->fErrorH100ClkA == TRUE ||
22163
 
                  f_pIntFlags->fErrorH100ClkB == TRUE ||
22164
 
                  f_pIntFlags->fErrorH100FrameA == TRUE ) &&
22165
 
                 pIntrptConfig->byErrorH100Config == cOCT6100_INTERRUPT_TIMEOUT &&
22166
 
                 pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
22167
 
        {
22168
 
                pIntrptManage->byErrorH100State = cOCT6100_INTRPT_WILL_TIMEOUT;
22169
 
                pIntrptManage->ulErrorH100DisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
22170
 
                pIntrptManage->ulErrorH100DisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
22171
 
        }
22172
 
        /*-----------------------------------------------------------------------*/
22173
 
 
22174
 
        return cOCT6100_ERR_OK;
22175
 
}
22176
 
 
22177
 
 
22178
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22179
 
 
22180
 
Function:               Oct6100ApiWriteIntrptRegs
22181
 
 
22182
 
Description:    Writes to interrupt registers to clear interrupt condition, and
22183
 
                                writes to an interrupt's IE register if interrupt is to time
22184
 
                                out.
22185
 
 
22186
 
-------------------------------------------------------------------------------
22187
 
|       Argument                |       Description
22188
 
-------------------------------------------------------------------------------
22189
 
f_pApiInstance          Pointer to API instance. This memory is used to keep
22190
 
                                        the present state of the chip and all its resources.
22191
 
 
22192
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22193
 
static UINT32 Oct6100ApiWriteIntrptRegs(
22194
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance )
22195
 
{
22196
 
        tPOCT6100_API_INTRPT_MANAGE     pIntrptManage;
22197
 
        tOCT6100_WRITE_PARAMS           WriteParams;
22198
 
 
22199
 
        UINT32  ulResult;
22200
 
 
22201
 
        /* Get some local pointers. */
22202
 
        pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
22203
 
 
22204
 
        /* Set some parameters of write struct. */
22205
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
22206
 
 
22207
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
22208
 
 
22209
 
 
22210
 
 
22211
 
        /*===========================================================================*/
22212
 
        if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
22213
 
        {
22214
 
                WriteParams.ulWriteAddress = 0x104;
22215
 
                WriteParams.usWriteData = 0x0000;
22216
 
 
22217
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22218
 
                if ( ulResult != cOCT6100_ERR_OK )
22219
 
                        return ulResult;
22220
 
        }
22221
 
        if ( (pIntrptManage->usRegister102h & cOCT6100_INTRPT_MASK_REG_102H) != 0 )
22222
 
        {
22223
 
                WriteParams.ulWriteAddress = 0x102;
22224
 
                WriteParams.usWriteData = pIntrptManage->usRegister102h;
22225
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22226
 
                if ( ulResult != cOCT6100_ERR_OK )
22227
 
                        return ulResult;
22228
 
        }
22229
 
        /*===========================================================================*/
22230
 
 
22231
 
        /*===========================================================================*/
22232
 
        if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT ||
22233
 
                 pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
22234
 
        {
22235
 
                WriteParams.ulWriteAddress = 0x204;
22236
 
                WriteParams.usWriteData = 0x0000;
22237
 
 
22238
 
                if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22239
 
                        WriteParams.usWriteData |= 0x1800;
22240
 
 
22241
 
                if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
22242
 
                        WriteParams.usWriteData |= 0x0401;
22243
 
 
22244
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22245
 
                if ( ulResult != cOCT6100_ERR_OK )
22246
 
                        return ulResult;
22247
 
        }
22248
 
        if ( (pIntrptManage->usRegister202h & cOCT6100_INTRPT_MASK_REG_202H) != 0 )
22249
 
        {
22250
 
                WriteParams.ulWriteAddress = 0x202;
22251
 
                WriteParams.usWriteData = pIntrptManage->usRegister202h;
22252
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22253
 
                if ( ulResult != cOCT6100_ERR_OK )
22254
 
                        return ulResult;
22255
 
        }
22256
 
        /*===========================================================================*/
22257
 
 
22258
 
        /*===========================================================================*/
22259
 
        if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_WILL_TIMEOUT )
22260
 
        {
22261
 
                WriteParams.ulWriteAddress = 0x304;
22262
 
                WriteParams.usWriteData = 0x0000;
22263
 
 
22264
 
                if ( pIntrptManage->fMclkIntrptActive == TRUE )
22265
 
                        WriteParams.usWriteData |= 0x0001;
22266
 
 
22267
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22268
 
                if ( ulResult != cOCT6100_ERR_OK )
22269
 
                        return ulResult;
22270
 
        }
22271
 
        if ( (pIntrptManage->usRegister302h & cOCT6100_INTRPT_MASK_REG_302H) != 0 )
22272
 
        {
22273
 
                WriteParams.ulWriteAddress = 0x302;
22274
 
                WriteParams.usWriteData = pIntrptManage->usRegister302h;
22275
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22276
 
                if ( ulResult != cOCT6100_ERR_OK )
22277
 
                        return ulResult;
22278
 
        }
22279
 
        /*===========================================================================*/
22280
 
 
22281
 
        /*===========================================================================*/
22282
 
        if ( (pIntrptManage->usRegister502h & cOCT6100_INTRPT_MASK_REG_502H) != 0 )
22283
 
        {
22284
 
                WriteParams.ulWriteAddress = 0x502;
22285
 
                WriteParams.usWriteData = pIntrptManage->usRegister502h;
22286
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22287
 
                if ( ulResult != cOCT6100_ERR_OK )
22288
 
                        return ulResult;
22289
 
        }
22290
 
        /*===========================================================================*/
22291
 
 
22292
 
        /*===========================================================================*/
22293
 
        if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_WILL_TIMEOUT )
22294
 
        {
22295
 
                WriteParams.ulWriteAddress = 0x704;
22296
 
                WriteParams.usWriteData = 0x0000;
22297
 
 
22298
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22299
 
                if ( ulResult != cOCT6100_ERR_OK )
22300
 
                        return ulResult;
22301
 
        }
22302
 
        if ( (pIntrptManage->usRegister702h & cOCT6100_INTRPT_MASK_REG_702H) != 0 )
22303
 
        {
22304
 
                WriteParams.ulWriteAddress = 0x702;
22305
 
                WriteParams.usWriteData = pIntrptManage->usRegister702h;
22306
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22307
 
                if ( ulResult != cOCT6100_ERR_OK )
22308
 
                        return ulResult;
22309
 
        }
22310
 
        /*===========================================================================*/
22311
 
 
22312
 
 
22313
 
 
22314
 
        return cOCT6100_ERR_OK;
22315
 
}
22316
 
 
22317
 
 
22318
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22319
 
 
22320
 
Function:               Oct6100ApiWriteIeRegs
22321
 
 
22322
 
Description:    Writes the IE field of each interrupt register.
22323
 
 
22324
 
-------------------------------------------------------------------------------
22325
 
|       Argument                |       Description
22326
 
-------------------------------------------------------------------------------
22327
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
22328
 
                                                the present state of the chip and all its resources.
22329
 
 
22330
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22331
 
static UINT32 Oct6100ApiWriteIeRegs(
22332
 
                                tPOCT6100_INSTANCE_API                  f_pApiInstance )
22333
 
{
22334
 
        tPOCT6100_API_INTRPT_MANAGE     pIntrptManage;
22335
 
        tOCT6100_WRITE_PARAMS           WriteParams;
22336
 
        tOCT6100_READ_PARAMS            ReadParams;
22337
 
        UINT32  ulResult;
22338
 
 
22339
 
        /* Get some local pointers. */
22340
 
        pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
22341
 
 
22342
 
        /* Set some parameters of write struct. */
22343
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
22344
 
 
22345
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
22346
 
 
22347
 
 
22348
 
        /* Set some parameters of read struct. */
22349
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
22350
 
 
22351
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
22352
 
        
22353
 
        /*==================================================================================*/
22354
 
        WriteParams.ulWriteAddress = 0x104;
22355
 
        WriteParams.usWriteData = 0x0000;
22356
 
 
22357
 
        if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22358
 
                WriteParams.usWriteData |= 0x0001;
22359
 
 
22360
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22361
 
        if ( ulResult != cOCT6100_ERR_OK )
22362
 
                return ulResult;
22363
 
        /*==================================================================================*/
22364
 
 
22365
 
        /*==================================================================================*/
22366
 
        WriteParams.ulWriteAddress = 0x204;
22367
 
        WriteParams.usWriteData = 0x0000;
22368
 
 
22369
 
        if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22370
 
                WriteParams.usWriteData |= 0x1800;
22371
 
        if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
22372
 
                WriteParams.usWriteData |= 0x0401;
22373
 
 
22374
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22375
 
        if ( ulResult != cOCT6100_ERR_OK )
22376
 
                return ulResult;
22377
 
        /*==================================================================================*/
22378
 
 
22379
 
        /*==================================================================================*/
22380
 
        WriteParams.ulWriteAddress = 0x304;
22381
 
        WriteParams.usWriteData = 0x0000;
22382
 
 
22383
 
        if ( pIntrptManage->fMclkIntrptActive == TRUE )
22384
 
                WriteParams.usWriteData |= 0x0001;
22385
 
        if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
22386
 
        {
22387
 
                if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
22388
 
                        WriteParams.usWriteData |= 0xD100;
22389
 
                else
22390
 
                        WriteParams.usWriteData |= 0x5100;
22391
 
        }
22392
 
 
22393
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22394
 
        if ( ulResult != cOCT6100_ERR_OK )
22395
 
                return ulResult;
22396
 
        /*==================================================================================*/
22397
 
 
22398
 
        /*==================================================================================*/
22399
 
        WriteParams.ulWriteAddress = 0x504;
22400
 
        WriteParams.usWriteData = 0x0000;
22401
 
 
22402
 
        if ( pIntrptManage->byFatalGeneralState == cOCT6100_INTRPT_ACTIVE )
22403
 
                WriteParams.usWriteData |= 0x0002;
22404
 
 
22405
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22406
 
        if ( ulResult != cOCT6100_ERR_OK )
22407
 
                return ulResult;
22408
 
        /*==================================================================================*/
22409
 
 
22410
 
        /*==================================================================================*/
22411
 
        WriteParams.ulWriteAddress = 0x704;
22412
 
        WriteParams.usWriteData = 0x0000;
22413
 
 
22414
 
        if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
22415
 
                WriteParams.usWriteData |= 0x0002;
22416
 
 
22417
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22418
 
        if ( ulResult != cOCT6100_ERR_OK )
22419
 
                return ulResult;
22420
 
        /*==================================================================================*/
22421
 
 
22422
 
 
22423
 
        /*==================================================================================*/
22424
 
        /* Enable the GLOBAL IEs for the interrupt pin. */
22425
 
        WriteParams.ulWriteAddress = 0x218;
22426
 
        WriteParams.usWriteData = 0x00D7;
22427
 
 
22428
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22429
 
        if ( ulResult != cOCT6100_ERR_OK )
22430
 
                return ulResult;
22431
 
        /*==================================================================================*/
22432
 
        
22433
 
        return cOCT6100_ERR_OK;
22434
 
}
22435
 
 
22436
 
 
22437
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22438
 
 
22439
 
Function:               Oct6100ApiReadChipMclkTime
22440
 
 
22441
 
Description:    Reads the chip's mclk cycle count to construct a chip time.
22442
 
                                The time is used to manage interrupts.
22443
 
 
22444
 
-------------------------------------------------------------------------------
22445
 
|       Argument                |       Description
22446
 
-------------------------------------------------------------------------------
22447
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
22448
 
                                                the present state of the chip and all its resources.
22449
 
 
22450
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22451
 
static UINT32 Oct6100ApiReadChipMclkTime(
22452
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance )
22453
 
{
22454
 
        tPOCT6100_API_INTRPT_MANAGE     pIntrptManage;
22455
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
22456
 
        tOCT6100_READ_PARAMS            ReadParams;
22457
 
        UINT32  ulCheckData;
22458
 
        UINT32  ulResult;
22459
 
        UINT32  i;
22460
 
        UINT16  usReadData;
22461
 
 
22462
 
        /* Get local pointer(s). */
22463
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
22464
 
        pIntrptManage = &pSharedInfo->IntrptManage;
22465
 
 
22466
 
        /* Assign memory for read data. */
22467
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
22468
 
 
22469
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
22470
 
        ReadParams.pusReadData = &usReadData;
22471
 
 
22472
 
        /* Perform reads. */
22473
 
        for ( i = 0; i < 100; i++ )
22474
 
        {
22475
 
                ReadParams.ulReadAddress = 0x306;
22476
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22477
 
                if ( ulResult != cOCT6100_ERR_OK )
22478
 
                        return ulResult;
22479
 
                pIntrptManage->ulRegMclkTimeHigh = usReadData & 0xFF;
22480
 
                ulCheckData = usReadData;
22481
 
 
22482
 
                ReadParams.ulReadAddress = 0x308;
22483
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22484
 
                if ( ulResult != cOCT6100_ERR_OK )
22485
 
                        return ulResult;
22486
 
                pIntrptManage->ulRegMclkTimeLow = (usReadData & 0xFFFF) << 16;
22487
 
 
22488
 
                ReadParams.ulReadAddress = 0x306;
22489
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22490
 
                if ( ulResult != cOCT6100_ERR_OK )
22491
 
                        return ulResult;
22492
 
                if ( ulCheckData == usReadData )
22493
 
                        break;
22494
 
        }
22495
 
 
22496
 
        if ( i == 100 )
22497
 
                return cOCT6100_ERR_FATAL_2F;
22498
 
 
22499
 
        return cOCT6100_ERR_OK;
22500
 
}
22501
 
 
22502
 
 
22503
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22504
 
 
22505
 
Function:               Oct6100ApiUpdateIntrptTimeouts
22506
 
 
22507
 
Description:    Checks which interrupt groups have finished their timeout
22508
 
                                period.
22509
 
 
22510
 
-------------------------------------------------------------------------------
22511
 
|       Argument                |       Description
22512
 
-------------------------------------------------------------------------------
22513
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
22514
 
                                                the present state of the chip and all its resources.
22515
 
 
22516
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22517
 
static UINT32 Oct6100ApiUpdateIntrptTimeouts(
22518
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance )
22519
 
{
22520
 
        tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
22521
 
        tOCT6100_WRITE_PARAMS           WriteParams;
22522
 
        UINT32  ulRegMclkTimePlus5MsHigh;
22523
 
        UINT32  ulRegMclkTimePlus5MsLow;
22524
 
        UINT32  ulResult;
22525
 
        BOOL    fFatalMemoryChange = FALSE;
22526
 
        BOOL    fDataErrMemoryChange = FALSE;
22527
 
        BOOL    fErrorOverflowToneEventsChange = FALSE;
22528
 
        BOOL    fH100ErrorChange = FALSE;
22529
 
 
22530
 
        /* Get local pointer to interrupt management structure. */
22531
 
        pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
22532
 
 
22533
 
        /* Calculate mclk time + 5 ms. */
22534
 
        ulRegMclkTimePlus5MsLow = pIntrptManage->ulRegMclkTimeLow + (5 * pIntrptManage->ulNumMclkCyclesIn1Ms);
22535
 
        if ( ulRegMclkTimePlus5MsLow < pIntrptManage->ulRegMclkTimeLow )
22536
 
                ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh + 1;
22537
 
        else /* ( ulRegMclkTimePlus5MsLow >= pIntrptManage->ulRegMclkTimeLow ) */
22538
 
                ulRegMclkTimePlus5MsHigh = pIntrptManage->ulRegMclkTimeHigh;
22539
 
 
22540
 
        /* Check which interrupts are timed out and need to be reenabled now. */
22541
 
        if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
22542
 
        {
22543
 
                mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulFatalMemoryDisableMclkHigh, pIntrptManage->ulFatalMemoryDisableMclkLow, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptManage->byFatalMemoryState, fFatalMemoryChange )
22544
 
        }
22545
 
        if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
22546
 
        {
22547
 
                mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorMemoryDisableMclkHigh, pIntrptManage->ulErrorMemoryDisableMclkLow, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptManage->byErrorMemoryState, fDataErrMemoryChange )
22548
 
        }
22549
 
        if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_IN_TIMEOUT )
22550
 
        {
22551
 
                mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptManage->byErrorOverflowToneEventsState, fErrorOverflowToneEventsChange )
22552
 
        }
22553
 
        if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_IN_TIMEOUT )
22554
 
        {
22555
 
                mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorH100DisableMclkHigh, pIntrptManage->ulErrorH100DisableMclkLow, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptManage->byErrorH100State, fH100ErrorChange )
22556
 
        }
22557
 
 
22558
 
        /* Set some parameters of write struct. */
22559
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
22560
 
 
22561
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
22562
 
        
22563
 
        /* Write to the IE registers which have changed. */
22564
 
 
22565
 
        /*==================================================================================*/
22566
 
        if ( fFatalMemoryChange == TRUE )
22567
 
        {
22568
 
                WriteParams.ulWriteAddress = 0x104;
22569
 
                WriteParams.usWriteData = 0x0000;
22570
 
 
22571
 
                if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22572
 
                        WriteParams.usWriteData |= 0x0001;
22573
 
 
22574
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22575
 
                if ( ulResult != cOCT6100_ERR_OK )
22576
 
                        return ulResult;
22577
 
 
22578
 
        }
22579
 
        /*==================================================================================*/
22580
 
 
22581
 
        /*==================================================================================*/
22582
 
        if ( fFatalMemoryChange == TRUE || 
22583
 
                 fDataErrMemoryChange == TRUE )
22584
 
        {
22585
 
                WriteParams.ulWriteAddress = 0x204;
22586
 
                WriteParams.usWriteData = 0x0000;
22587
 
 
22588
 
                if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22589
 
                        WriteParams.usWriteData |= 0x1800;
22590
 
                if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
22591
 
                        WriteParams.usWriteData |= 0x0401;
22592
 
 
22593
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22594
 
                if ( ulResult != cOCT6100_ERR_OK )
22595
 
                        return ulResult;
22596
 
 
22597
 
        }
22598
 
        /*==================================================================================*/
22599
 
 
22600
 
        /*==================================================================================*/
22601
 
        if ( pIntrptManage->fMclkIntrptActive == TRUE ||
22602
 
                 fH100ErrorChange == TRUE )
22603
 
        {
22604
 
                WriteParams.ulWriteAddress = 0x304;
22605
 
                WriteParams.usWriteData = 0x0000;
22606
 
 
22607
 
                if ( pIntrptManage->fMclkIntrptActive == TRUE )
22608
 
                        WriteParams.usWriteData |= 0x0001;
22609
 
                
22610
 
                if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
22611
 
                {
22612
 
                        if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
22613
 
                                WriteParams.usWriteData |= 0xD100;
22614
 
                        else
22615
 
                                WriteParams.usWriteData |= 0x5100;
22616
 
                }
22617
 
 
22618
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22619
 
                if ( ulResult != cOCT6100_ERR_OK )
22620
 
                        return ulResult;
22621
 
        
22622
 
        }
22623
 
        /*==================================================================================*/
22624
 
 
22625
 
 
22626
 
        /*==================================================================================*/
22627
 
        if ( fErrorOverflowToneEventsChange == TRUE )
22628
 
        {
22629
 
                WriteParams.ulWriteAddress = 0x704;
22630
 
                WriteParams.usWriteData = 0x0000;
22631
 
 
22632
 
                if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
22633
 
                        WriteParams.usWriteData |= 0x0002;
22634
 
 
22635
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22636
 
                if ( ulResult != cOCT6100_ERR_OK )
22637
 
                        return ulResult;
22638
 
        
22639
 
        }
22640
 
        /*==================================================================================*/
22641
 
 
22642
 
        return cOCT6100_ERR_OK;
22643
 
}
22644
 
 
22645
 
 
22646
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22647
 
 
22648
 
Function:               Oct6100ApiScheduleNextMclkIntrptSer
22649
 
 
22650
 
Description:    Serialized sub-function of Oct6100ApiScheduleNextMclkIntrpt.
22651
 
 
22652
 
-------------------------------------------------------------------------------
22653
 
|       Argument                |       Description
22654
 
-------------------------------------------------------------------------------
22655
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
22656
 
                                                the present state of the chip and all its resources.
22657
 
 
22658
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22659
 
static UINT32 Oct6100ApiScheduleNextMclkIntrptSer(
22660
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance )
22661
 
{
22662
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
22663
 
        tPOCT6100_API_INTRPT_CONFIG     pIntrptConfig;
22664
 
        tPOCT6100_API_INTRPT_MANAGE     pIntrptManage;
22665
 
        tOCT6100_WRITE_PARAMS           WriteParams;
22666
 
        UINT32  ulTimeDiff;
22667
 
        UINT32  ulRegMclkTimeHigh;
22668
 
        UINT32  ulRegMclkTimeLow;
22669
 
        UINT32  ulResult;
22670
 
        BOOL    fConditionFlag = TRUE;
22671
 
        
22672
 
        /* Get local pointer(s). */
22673
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
22674
 
        
22675
 
        /* Obtain temporary pointers to reduce indirection, thus speeding up processing. */
22676
 
        pIntrptConfig = &pSharedInfo->IntrptConfig;
22677
 
        pIntrptManage = &pSharedInfo->IntrptManage;
22678
 
        ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh;
22679
 
        ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow;
22680
 
 
22681
 
        /* First, check if any interrupts have just been disabled.  If there are any, */
22682
 
        /* determine the time at which they should be reenabled. */
22683
 
        pIntrptManage->ulNextMclkIntrptTimeHigh = cOCT6100_INVALID_VALUE;
22684
 
        pIntrptManage->ulNextMclkIntrptTimeLow = cOCT6100_INVALID_VALUE;
22685
 
 
22686
 
        while ( fConditionFlag )
22687
 
        {
22688
 
                /* Indicate that no mclk interrupt is needed, yet. */
22689
 
                ulTimeDiff = cOCT6100_INVALID_VALUE;
22690
 
 
22691
 
                /* Check each interrupt category to see if an mclk interrupt is needed to */
22692
 
                /* reenable an interrupt at a later time. */
22693
 
                if ( pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_ACTIVE &&
22694
 
                         pIntrptManage->byFatalMemoryState != cOCT6100_INTRPT_DISABLED )
22695
 
                {
22696
 
                        mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byFatalMemoryState, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptConfig->ulFatalMemoryTimeoutMclk, ulTimeDiff )
22697
 
                }
22698
 
                if ( pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_ACTIVE &&
22699
 
                         pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_DISABLED )
22700
 
                {
22701
 
                        mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorMemoryState, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptConfig->ulErrorMemoryTimeoutMclk, ulTimeDiff )
22702
 
                }
22703
 
                if ( pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_ACTIVE &&
22704
 
                         pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_DISABLED )
22705
 
                {        
22706
 
                        mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorOverflowToneEventsState, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk, ulTimeDiff )
22707
 
                }
22708
 
                if ( pIntrptManage->byErrorH100State != cOCT6100_INTRPT_ACTIVE &&
22709
 
                         pIntrptManage->byErrorH100State != cOCT6100_INTRPT_DISABLED )
22710
 
                {
22711
 
                        mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorH100State, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptConfig->ulErrorH100TimeoutMclk, ulTimeDiff )
22712
 
                }
22713
 
 
22714
 
                /* Set some parameters of write struct. */
22715
 
                WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
22716
 
 
22717
 
                WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
22718
 
 
22719
 
                /* Schedule next mclk interrupt, if any is needed. */
22720
 
                if ( ulTimeDiff != cOCT6100_INVALID_VALUE )
22721
 
                {
22722
 
                        UINT32  ulMclkTimeTest;
22723
 
                        UINT32  ulAlarmTimeTest;
22724
 
                        UINT32  ulTimeDiffTest;
22725
 
                        BOOL    fAlarmTimePassed;
22726
 
 
22727
 
                        /* Indicate that an mclk interrupt is scheduled.*/
22728
 
                        pIntrptManage->fMclkIntrptActive = TRUE;
22729
 
 
22730
 
                        pIntrptManage->ulNextMclkIntrptTimeLow = ulRegMclkTimeLow + ulTimeDiff;
22731
 
                        if ( pIntrptManage->ulNextMclkIntrptTimeLow < ulRegMclkTimeLow )
22732
 
                                pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh + 1;
22733
 
                        else /* ( pIntrptManage->ulNextMclkIntrptTimeLow >= ulRegMclkTimeLow ) */
22734
 
                                pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh;
22735
 
                        
22736
 
                        WriteParams.ulWriteAddress = 0x30C;
22737
 
                        WriteParams.usWriteData  = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 24) & 0xFF );
22738
 
                        WriteParams.usWriteData |= (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeHigh & 0xFF) << 8 );
22739
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22740
 
                        if ( ulResult != cOCT6100_ERR_OK )
22741
 
                                return ulResult;
22742
 
                        
22743
 
                        WriteParams.ulWriteAddress = 0x30E;
22744
 
                        WriteParams.usWriteData = (UINT16)( (pIntrptManage->ulNextMclkIntrptTimeLow >> 8) & 0xFFFF );
22745
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22746
 
                        if ( ulResult != cOCT6100_ERR_OK )
22747
 
                                return ulResult;
22748
 
                        
22749
 
                        WriteParams.ulWriteAddress = 0x304;
22750
 
                        WriteParams.usWriteData = 0;
22751
 
                        
22752
 
                        if ( pIntrptManage->fMclkIntrptActive == TRUE )
22753
 
                                WriteParams.usWriteData = 0x0001;
22754
 
 
22755
 
                        if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
22756
 
                        {
22757
 
                                if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
22758
 
                                        WriteParams.usWriteData |= 0xD100;
22759
 
                                else
22760
 
                                        WriteParams.usWriteData |= 0x5100;
22761
 
                        }
22762
 
                        
22763
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22764
 
                        if ( ulResult != cOCT6100_ERR_OK )
22765
 
                                return ulResult;
22766
 
 
22767
 
                        /* Disable the ROL if previously set. */
22768
 
                        WriteParams.ulWriteAddress = 0x302;
22769
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22770
 
                        if ( ulResult != cOCT6100_ERR_OK )
22771
 
                                return ulResult;
22772
 
 
22773
 
                        /* Check if already passed the next interrupt time. */
22774
 
                        ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance );
22775
 
                        if ( ulResult != cOCT6100_ERR_OK )
22776
 
                                return ulResult;
22777
 
 
22778
 
                        ulMclkTimeTest  = (pIntrptManage->ulRegMclkTimeLow >> 16) & 0xFFFF;
22779
 
                        ulAlarmTimeTest = (pIntrptManage->ulNextMclkIntrptTimeLow >> 16) & 0xFFFF;
22780
 
 
22781
 
                        /* Update the local Mlck timer values.*/
22782
 
                        ulRegMclkTimeHigh       = pIntrptManage->ulRegMclkTimeHigh;
22783
 
                        ulRegMclkTimeLow        = pIntrptManage->ulRegMclkTimeLow;
22784
 
 
22785
 
                        fAlarmTimePassed = FALSE;
22786
 
 
22787
 
                        if ( ulMclkTimeTest > ulAlarmTimeTest )
22788
 
                        {
22789
 
                                ulTimeDiffTest = ulMclkTimeTest - ulAlarmTimeTest;
22790
 
                                if ( ulTimeDiffTest <= 0x8000 )
22791
 
                                        fAlarmTimePassed = TRUE;
22792
 
                        }
22793
 
                        else /* ( ulMclkTimeTest <= ulAlarmTimeTest ) */
22794
 
                        {
22795
 
                                ulTimeDiffTest = ulAlarmTimeTest - ulMclkTimeTest;
22796
 
                                if ( ulTimeDiffTest > 0x8000 )
22797
 
                                        fAlarmTimePassed = TRUE;
22798
 
                        }
22799
 
                        
22800
 
                        if ( fAlarmTimePassed == TRUE )
22801
 
                        {
22802
 
                                /* Passed the interrupt time.  Schedule next interrupt (if needed). */
22803
 
                                ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance );
22804
 
                                if ( ulResult != cOCT6100_ERR_OK )
22805
 
                                        return ulResult;
22806
 
 
22807
 
                                continue;
22808
 
                        }
22809
 
                        else
22810
 
                        {
22811
 
                                fConditionFlag = FALSE;
22812
 
                        }
22813
 
                }
22814
 
                else
22815
 
                {
22816
 
                        /* Indicate that no mclk interrupt is scheduled. */
22817
 
                        pIntrptManage->fMclkIntrptActive = FALSE;
22818
 
 
22819
 
                        /* Insure that the mclk interrupt is not enabled. */
22820
 
                        WriteParams.ulWriteAddress = 0x304;
22821
 
                        WriteParams.usWriteData = 0x0000;
22822
 
                        if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
22823
 
                        {
22824
 
                                if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
22825
 
                                        WriteParams.usWriteData |= 0xD100;
22826
 
                                else
22827
 
                                        WriteParams.usWriteData |= 0x5100;
22828
 
                        }
22829
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22830
 
                        if ( ulResult != cOCT6100_ERR_OK )
22831
 
                                return ulResult;
22832
 
 
22833
 
                        fConditionFlag = FALSE;
22834
 
                }
22835
 
        }
22836
 
 
22837
 
        return cOCT6100_ERR_OK;
22838
 
}
22839
 
 
22840
 
 
22841
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22842
 
 
22843
 
Function:               Oct6100ApiCheckProcessorState
22844
 
 
22845
 
Description:    This function verifies if the NLP and AF processors are operating
22846
 
                                correctly.
22847
 
 
22848
 
-------------------------------------------------------------------------------
22849
 
|       Argument                |       Description
22850
 
-------------------------------------------------------------------------------
22851
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
22852
 
                                                the present state of the chip and all its resources.
22853
 
 
22854
 
f_pIntFlags                             Pointer to a tOCT6100_INTERRUPT_FLAGS structure.
22855
 
 
22856
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22857
 
static UINT32   Oct6100ApiCheckProcessorState(
22858
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
22859
 
                                IN OUT  tPOCT6100_INTERRUPT_FLAGS               f_pIntFlags )
22860
 
{
22861
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
22862
 
        tOCT6100_READ_PARAMS                    ReadParams;
22863
 
        tOCT6100_READ_BURST_PARAMS              ReadBurstParams;
22864
 
        UINT32          ulNlpTimestamp;
22865
 
        UINT32          ulAfTimestamp;
22866
 
        UINT32          ulTimestampDiff;
22867
 
 
22868
 
        UINT32          ulResult;
22869
 
        UINT32          i;
22870
 
        
22871
 
        UINT16          usReadData;
22872
 
        UINT16          ausReadData[ 2 ];
22873
 
        
22874
 
        /* Get local pointer(s). */
22875
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
22876
 
 
22877
 
        /* Set some parameters of write struct. */
22878
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
22879
 
 
22880
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
22881
 
        ReadParams.pusReadData = &usReadData;
22882
 
 
22883
 
        /* Set some parameters of write struct. */
22884
 
        ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
22885
 
 
22886
 
        ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
22887
 
        ReadBurstParams.pusReadData = ausReadData;
22888
 
 
22889
 
        /*-----------------------------------------------------------------------*/
22890
 
        /* Check if chip is in reset. */
22891
 
 
22892
 
        /* Read the main control register. */
22893
 
        ReadParams.ulReadAddress = 0x100;
22894
 
 
22895
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22896
 
        if ( ulResult != cOCT6100_ERR_OK )
22897
 
                return ulResult;
22898
 
 
22899
 
        if ( usReadData == 0x0000 )
22900
 
        {
22901
 
                /* Chip was resetted. */
22902
 
                f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_4;
22903
 
                f_pIntFlags->fFatalGeneral = TRUE;
22904
 
                pSharedInfo->ErrorStats.fFatalChipError = TRUE;
22905
 
        }
22906
 
 
22907
 
        /*-----------------------------------------------------------------------*/
22908
 
 
22909
 
 
22910
 
        /*-----------------------------------------------------------------------*/
22911
 
        /* Reading the AF timestamp.*/
22912
 
 
22913
 
        for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
22914
 
        {
22915
 
                /* Read the timestamp.*/
22916
 
                ReadBurstParams.ulReadAddress   = 0x082E0008;
22917
 
                ReadBurstParams.ulReadLength    = 2;
22918
 
 
22919
 
                mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
22920
 
                if ( ulResult != cOCT6100_ERR_OK )
22921
 
                        return ulResult;
22922
 
 
22923
 
                /* Read the high part again to make sure it didn't wrap. */
22924
 
                ReadParams.ulReadAddress                = 0x082E0008;
22925
 
 
22926
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22927
 
                if ( ulResult != cOCT6100_ERR_OK )
22928
 
                        return ulResult;
22929
 
 
22930
 
                /* Check if the low part wrapped. */
22931
 
                if ( ausReadData[ 0 ] == usReadData )
22932
 
                        break;
22933
 
        }
22934
 
 
22935
 
        if ( i == cOCT6100_MAX_LOOP )
22936
 
                return cOCT6100_ERR_INTRPTS_AF_TIMESTAMP_READ_TIMEOUT;
22937
 
 
22938
 
        /* Save the AF timestamp. */
22939
 
        ulAfTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
22940
 
 
22941
 
        /*-----------------------------------------------------------------------*/
22942
 
 
22943
 
        
22944
 
        /*-----------------------------------------------------------------------*/
22945
 
        /* Reading the NLP timestamp. */
22946
 
 
22947
 
        for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
22948
 
        {
22949
 
                /* Read the timestamp. */
22950
 
                ReadBurstParams.ulReadAddress   = 0x08000008;
22951
 
                ReadBurstParams.ulReadLength    = 2;
22952
 
 
22953
 
                mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
22954
 
                if ( ulResult != cOCT6100_ERR_OK )
22955
 
                        return ulResult;
22956
 
 
22957
 
                /* Read the high part again to make sure it didn't wrap. */
22958
 
                ReadParams.ulReadAddress                = 0x08000008;
22959
 
 
22960
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22961
 
                if ( ulResult != cOCT6100_ERR_OK )
22962
 
                        return ulResult;
22963
 
 
22964
 
                /* Check if the low part wrapped. */
22965
 
                if ( ausReadData[ 0 ] == usReadData )
22966
 
                        break;
22967
 
        }
22968
 
 
22969
 
        if ( i == cOCT6100_MAX_LOOP )
22970
 
                return cOCT6100_ERR_INTRPTS_NLP_TIMESTAMP_READ_TIMEOUT;
22971
 
 
22972
 
        /* Save the NLP timestamp. */
22973
 
        ulNlpTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
22974
 
 
22975
 
        /*-----------------------------------------------------------------------*/
22976
 
 
22977
 
 
22978
 
        /*-----------------------------------------------------------------------*/
22979
 
        /* Check the validity of the timestamp. */
22980
 
 
22981
 
        if ( ulAfTimestamp > ulNlpTimestamp )
22982
 
        {
22983
 
                /* The NLP timestamp wrapped. */
22984
 
                ulTimestampDiff  = 0xFFFFFFFF - ulAfTimestamp + 1;
22985
 
                ulTimestampDiff += ulNlpTimestamp;
22986
 
        }
22987
 
        else
22988
 
                ulTimestampDiff = ulNlpTimestamp - ulAfTimestamp;
22989
 
 
22990
 
        if ( ulTimestampDiff > 0x1000 )
22991
 
        {
22992
 
                f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_5;
22993
 
                f_pIntFlags->fFatalGeneral = TRUE;
22994
 
                pSharedInfo->ErrorStats.fFatalChipError = TRUE;
22995
 
        }
22996
 
 
22997
 
        /*-----------------------------------------------------------------------*/
22998
 
 
22999
 
        return cOCT6100_ERR_OK;
23000
 
}
23001
 
 
23002
 
 
23003
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23004
 
 
23005
 
File: oct6100_memory.c
23006
 
 
23007
 
    Copyright (c) 2001-2005 Octasic Inc.
23008
 
    
23009
 
Description: 
23010
 
 
23011
 
        This file contains the functions used to manage the allocation of memory
23012
 
        blocks in external memory.
23013
 
 
23014
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
23015
 
free software; you can redistribute it and/or modify it under the terms of 
23016
 
the GNU General Public License as published by the Free Software Foundation; 
23017
 
either version 2 of the License, or (at your option) any later version.
23018
 
 
23019
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
23020
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
23021
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
23022
 
for more details. 
23023
 
 
23024
 
You should have received a copy of the GNU General Public License 
23025
 
along with the OCT6100 GPL API; if not, write to the Free Software 
23026
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23027
 
 
23028
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
23029
 
 
23030
 
$Octasic_Revision: 42 $
23031
 
 
23032
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23033
 
 
23034
 
 
23035
 
/*****************************  INCLUDE FILES  *******************************/
23036
 
 
23037
 
#include "octdef.h"
23038
 
 
23039
 
#include "oct6100api/oct6100_defines.h"
23040
 
#include "oct6100api/oct6100_errors.h"
23041
 
 
23042
 
#include "apilib/octapi_llman.h"
23043
 
 
23044
 
#include "oct6100api/oct6100_apiud.h"
23045
 
#include "oct6100api/oct6100_tlv_inst.h"
23046
 
#include "oct6100api/oct6100_chip_open_inst.h"
23047
 
#include "oct6100api/oct6100_chip_stats_inst.h"
23048
 
#include "oct6100api/oct6100_interrupts_inst.h"
23049
 
#include "oct6100api/oct6100_remote_debug_inst.h"
23050
 
#include "oct6100api/oct6100_debug_inst.h"
23051
 
#include "oct6100api/oct6100_playout_buf_inst.h"
23052
 
#include "oct6100api/oct6100_api_inst.h"
23053
 
 
23054
 
#include "oct6100api/oct6100_interrupts_pub.h"
23055
 
#include "oct6100api/oct6100_channel_pub.h"
23056
 
#include "oct6100api/oct6100_chip_open_pub.h"
23057
 
 
23058
 
#include "oct6100_chip_open_priv.h"
23059
 
#include "oct6100_memory_priv.h"
23060
 
 
23061
 
 
23062
 
/****************************  PRIVATE FUNCTIONS  ****************************/
23063
 
 
23064
 
 
23065
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23066
 
 
23067
 
Function:               Oct6100ApiGetMemorySwSizes
23068
 
 
23069
 
Description:    Gets the sizes of all portions of the API instance pertinent
23070
 
                                to the management of the memories.
23071
 
 
23072
 
-------------------------------------------------------------------------------
23073
 
|       Argument                |       Description
23074
 
-------------------------------------------------------------------------------
23075
 
f_pOpenChip                             Pointer to chip configuration struct.
23076
 
f_pInstSizes                    Pointer to struct containing instance sizes.
23077
 
 
23078
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23079
 
static UINT32 Oct6100ApiGetMemorySwSizes(
23080
 
                                IN              tPOCT6100_CHIP_OPEN                             f_pOpenChip,
23081
 
                                OUT             tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
23082
 
{
23083
 
        UINT32  ulTempVar;
23084
 
        UINT32  ulResult;
23085
 
        UINT32  ulNumTsiChariots;
23086
 
 
23087
 
        /*=========================================================================*/
23088
 
        /* Internal memory */
23089
 
 
23090
 
        /* Evaluate the number of available TSI memory after reserving the ones used by channels. */
23091
 
        ulNumTsiChariots = cOCT6100_TOTAL_TSI_CONTROL_MEM_ENTRY - f_pOpenChip->ulMaxPhasingTssts - cOCT6100_TSI_MEM_FOR_TIMESTAMP;
23092
 
 
23093
 
        if ( f_pOpenChip->fEnableExtToneDetection == TRUE )
23094
 
                ulNumTsiChariots--;
23095
 
 
23096
 
        /* Calculate memory needed for TSI memory allocation. */
23097
 
        ulResult = OctapiLlmAllocGetSize( ulNumTsiChariots, &f_pInstSizes->ulTsiMemoryAlloc );
23098
 
        if ( ulResult != cOCT6100_ERR_OK )
23099
 
                return cOCT6100_ERR_FATAL_94;
23100
 
        
23101
 
        /* Calculate memory needed for conversion memory allocation. */
23102
 
        ulResult = OctapiLlmAllocGetSize( cOCT6100_MAX_CONVERSION_MEMORY_BLOCKS, &f_pInstSizes->ulConversionMemoryAlloc );
23103
 
        if ( ulResult != cOCT6100_ERR_OK )
23104
 
                return cOCT6100_ERR_FATAL_B5;
23105
 
 
23106
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsiMemoryAlloc, ulTempVar );
23107
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulConversionMemoryAlloc, ulTempVar );
23108
 
 
23109
 
        return cOCT6100_ERR_OK;
23110
 
}
23111
 
 
23112
 
 
23113
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23114
 
 
23115
 
Function:               Oct6100ApiMemorySwInit
23116
 
 
23117
 
Description:    Initializes all elements of the instance structure associated
23118
 
                                to memories.
23119
 
 
23120
 
-------------------------------------------------------------------------------
23121
 
|       Argument                |       Description
23122
 
-------------------------------------------------------------------------------
23123
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
23124
 
                                                the present state of the chip and all its resources.
23125
 
 
23126
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23127
 
static UINT32 Oct6100ApiMemorySwInit(
23128
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance )
23129
 
{
23130
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
23131
 
        PVOID   pTsiMemAlloc;
23132
 
        PVOID   pAllocPnt;
23133
 
        UINT32  ulResult;
23134
 
 
23135
 
        /* Get local pointer(s). */
23136
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
23137
 
 
23138
 
        /*=========================================================================*/
23139
 
        /* Internal memory */
23140
 
        
23141
 
        /* Initialize the TSI memory allocation structure. */
23142
 
        pSharedInfo->MemoryMap.ulNumTsiEntries = cOCT6100_TOTAL_TSI_CONTROL_MEM_ENTRY - pSharedInfo->ChipConfig.usMaxPhasingTssts - cOCT6100_TSI_MEM_FOR_TIMESTAMP;
23143
 
 
23144
 
        if ( pSharedInfo->ChipConfig.fEnableExtToneDetection == TRUE )
23145
 
                pSharedInfo->MemoryMap.ulNumTsiEntries--;
23146
 
 
23147
 
        mOCT6100_GET_TSI_MEMORY_ALLOC_PNT( pSharedInfo, pTsiMemAlloc );
23148
 
        
23149
 
        ulResult = OctapiLlmAllocInit( &pTsiMemAlloc, pSharedInfo->MemoryMap.ulNumTsiEntries );
23150
 
        if ( ulResult != cOCT6100_ERR_OK )
23151
 
                return cOCT6100_ERR_FATAL_95;
23152
 
 
23153
 
        /* Initialize the conversion memory allocation structure. */
23154
 
        mOCT6100_GET_CONVERSION_MEMORY_ALLOC_PNT( pSharedInfo, pAllocPnt );
23155
 
        
23156
 
        ulResult = OctapiLlmAllocInit( &pAllocPnt, cOCT6100_MAX_CONVERSION_MEMORY_BLOCKS );
23157
 
        if ( ulResult != cOCT6100_ERR_OK )
23158
 
                return cOCT6100_ERR_FATAL_B6;
23159
 
 
23160
 
        return cOCT6100_ERR_OK;
23161
 
}
23162
 
 
23163
 
 
23164
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23165
 
 
23166
 
Function:               Oct6100ApiBufferPlayoutMemorySwInit
23167
 
 
23168
 
Description:    Initialize the buffer playout memory allocation working 
23169
 
                                structures.
23170
 
 
23171
 
-------------------------------------------------------------------------------
23172
 
|       Argument                |       Description
23173
 
-------------------------------------------------------------------------------
23174
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
23175
 
                                                the present state of the chip and all its resources.
23176
 
 
23177
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23178
 
static UINT32 Oct6100ApiBufferPlayoutMemorySwInit(
23179
 
                                IN OUT  tPOCT6100_INSTANCE_API  f_pApiInstance )
23180
 
{
23181
 
        tPOCT6100_SHARED_INFO                                           pSharedInfo;
23182
 
        tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE        pNode;
23183
 
        UINT32                                                                          i;
23184
 
 
23185
 
        /* Get local pointer to shared portion of instance. */
23186
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
23187
 
 
23188
 
        /* Only if buffer playout will be used. */
23189
 
        if ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers > 0 )
23190
 
        {
23191
 
                mOCT6100_GET_BUFFER_MEMORY_NODE_LIST_PNT( pSharedInfo, pNode );
23192
 
 
23193
 
                /* First node contains all free memory at beginning. This node is not used, but represents the memory. */
23194
 
                pNode->ulSize = ( pSharedInfo->MiscVars.ulTotalMemSize + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS ) - pSharedInfo->MemoryMap.ulFreeMemBaseAddress;
23195
 
                pNode->ulNext = 0; 
23196
 
                pNode->ulPrevious = 0; 
23197
 
                pNode->fAllocated = FALSE;
23198
 
                pNode->ulStartAddress = pSharedInfo->MemoryMap.ulFreeMemBaseAddress;
23199
 
 
23200
 
                pNode++;
23201
 
 
23202
 
                /* Now create the first node of the free list, i.e. nodes that can be used later for modeling the memory. */
23203
 
                pNode->ulSize = 0;
23204
 
                /* Next free. */
23205
 
                pNode->ulNext = 2;
23206
 
                /* Last. */
23207
 
                pNode->ulPrevious = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1;
23208
 
                pNode->fAllocated = FALSE;
23209
 
                pNode->ulStartAddress = 0;
23210
 
 
23211
 
                pNode++;
23212
 
 
23213
 
                /* Link all the unused nodes. */
23214
 
                for( i = 2; i < (UINT32)( ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1 ); i ++ )
23215
 
                {
23216
 
                        pNode->ulNext = i + 1;
23217
 
                        pNode->ulPrevious = i - 1;
23218
 
                        pNode->ulStartAddress = 0;
23219
 
                        pNode->ulSize = 0;
23220
 
                        pNode->fAllocated = FALSE;
23221
 
                        pNode++;
23222
 
                }
23223
 
 
23224
 
                /* Last node of the unused list. */
23225
 
                pNode->fAllocated = FALSE;
23226
 
                pNode->ulPrevious = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 2;
23227
 
                /* Free list head. */
23228
 
                pNode->ulNext = 1; 
23229
 
                pNode->ulSize = 0;
23230
 
                pNode->ulStartAddress = 0;
23231
 
 
23232
 
                /* Set roving pointer to first node ( which can be used! ) */
23233
 
                pSharedInfo->PlayoutInfo.ulRovingNode = 0;
23234
 
 
23235
 
                /* First unused node. */
23236
 
                pSharedInfo->PlayoutInfo.ulFirstUnusedNode = 1;
23237
 
 
23238
 
                /* Last unused node. */
23239
 
                pSharedInfo->PlayoutInfo.ulLastUnusedNode = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1;
23240
 
 
23241
 
                /* Number of unused nodes. */
23242
 
                pSharedInfo->PlayoutInfo.ulUnusedNodeCnt = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1;
23243
 
        }
23244
 
        else
23245
 
        {
23246
 
                pSharedInfo->PlayoutInfo.ulUnusedNodeCnt = 0;
23247
 
        }
23248
 
 
23249
 
        return cOCT6100_ERR_OK;
23250
 
}
23251
 
 
23252
 
 
23253
 
 
23254
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23255
 
 
23256
 
File: oct6100_phasing_tsst.c
23257
 
 
23258
 
    Copyright (c) 2001-2005 Octasic Inc.
23259
 
    
23260
 
Description: 
23261
 
 
23262
 
        This file contains functions used to open and close phasing TSSTs.
23263
 
 
23264
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
23265
 
free software; you can redistribute it and/or modify it under the terms of 
23266
 
the GNU General Public License as published by the Free Software Foundation; 
23267
 
either version 2 of the License, or (at your option) any later version.
23268
 
 
23269
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
23270
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
23271
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
23272
 
for more details. 
23273
 
 
23274
 
You should have received a copy of the GNU General Public License 
23275
 
along with the OCT6100 GPL API; if not, write to the Free Software 
23276
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23277
 
 
23278
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
23279
 
 
23280
 
$Octasic_Revision: 42 $
23281
 
 
23282
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23283
 
 
23284
 
 
23285
 
/*****************************  INCLUDE FILES  *******************************/
23286
 
 
23287
 
#include "octdef.h"
23288
 
 
23289
 
#include "oct6100api/oct6100_defines.h"
23290
 
#include "oct6100api/oct6100_errors.h"
23291
 
#include "oct6100api/oct6100_apiud.h"
23292
 
 
23293
 
#include "apilib/octapi_llman.h"
23294
 
 
23295
 
#include "oct6100api/oct6100_tlv_inst.h"
23296
 
#include "oct6100api/oct6100_chip_open_inst.h"
23297
 
#include "oct6100api/oct6100_chip_stats_inst.h"
23298
 
#include "oct6100api/oct6100_interrupts_inst.h"
23299
 
#include "oct6100api/oct6100_remote_debug_inst.h"
23300
 
#include "oct6100api/oct6100_debug_inst.h"
23301
 
#include "oct6100api/oct6100_api_inst.h"
23302
 
#include "oct6100api/oct6100_phasing_tsst_inst.h"
23303
 
 
23304
 
#include "oct6100api/oct6100_interrupts_pub.h"
23305
 
#include "oct6100api/oct6100_chip_open_pub.h"
23306
 
#include "oct6100api/oct6100_channel_pub.h"
23307
 
#include "oct6100api/oct6100_phasing_tsst_pub.h"
23308
 
 
23309
 
#include "oct6100_chip_open_priv.h"
23310
 
#include "oct6100_miscellaneous_priv.h"
23311
 
#include "oct6100_memory_priv.h"
23312
 
#include "oct6100_tsst_priv.h"
23313
 
#include "oct6100_phasing_tsst_priv.h"
23314
 
 
23315
 
 
23316
 
/****************************  PUBLIC FUNCTIONS  ****************************/
23317
 
 
23318
 
 
23319
 
/****************************  PRIVATE FUNCTIONS  ****************************/
23320
 
 
23321
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23322
 
 
23323
 
Function:               Oct6100ApiGetPhasingTsstSwSizes
23324
 
 
23325
 
Description:    Gets the sizes of all portions of the API instance pertinent
23326
 
                                to the management of Phasing TSSTs.
23327
 
 
23328
 
-------------------------------------------------------------------------------
23329
 
|       Argument                |       Description
23330
 
-------------------------------------------------------------------------------
23331
 
f_pOpenChip                             Pointer to chip configuration struct.
23332
 
f_pInstSizes                    Pointer to struct containing instance sizes.
23333
 
 
23334
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23335
 
static UINT32 Oct6100ApiGetPhasingTsstSwSizes(
23336
 
                                IN              tPOCT6100_CHIP_OPEN                             f_pOpenChip,
23337
 
                                OUT             tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
23338
 
{
23339
 
        UINT32  ulTempVar;
23340
 
        UINT32  ulResult;
23341
 
        
23342
 
        /* Determine the amount of memory required for the API phasing TSST list. */
23343
 
        f_pInstSizes->ulPhasingTsstList = f_pOpenChip->ulMaxPhasingTssts * sizeof( tOCT6100_API_PHASING_TSST );
23344
 
 
23345
 
        if ( f_pOpenChip->ulMaxPhasingTssts > 0 )
23346
 
        {
23347
 
                /* Calculate memory needed for Phasing TSST API memory allocation */
23348
 
                ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxPhasingTssts, &f_pInstSizes->ulPhasingTsstAlloc );
23349
 
                if ( ulResult != cOCT6100_ERR_OK )
23350
 
                        return cOCT6100_ERR_FATAL_38;
23351
 
        }
23352
 
        else
23353
 
        {
23354
 
                f_pInstSizes->ulPhasingTsstAlloc = 0;
23355
 
        }
23356
 
 
23357
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPhasingTsstList, ulTempVar )
23358
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPhasingTsstAlloc, ulTempVar )
23359
 
 
23360
 
        return cOCT6100_ERR_OK;
23361
 
}
23362
 
 
23363
 
 
23364
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23365
 
 
23366
 
Function:               Oct6100ApiPhasingTsstSwInit
23367
 
 
23368
 
Description:    Initializes all elements of the instance structure associated
23369
 
                                to phasing TSST.
23370
 
 
23371
 
-------------------------------------------------------------------------------
23372
 
|       Argument                |       Description
23373
 
-------------------------------------------------------------------------------
23374
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
23375
 
                                                the present state of the chip and all its resources.
23376
 
 
23377
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23378
 
static UINT32 Oct6100ApiPhasingTsstSwInit(
23379
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance )
23380
 
{
23381
 
        tPOCT6100_API_PHASING_TSST      pPhasingTsstList;
23382
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
23383
 
        UINT32  ulMaxPhasingTssts;
23384
 
        PVOID   pPhasingTsstAlloc;
23385
 
        UINT32  ulResult;
23386
 
 
23387
 
        /* Get local pointer to shared portion of instance. */
23388
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
23389
 
 
23390
 
        /* Initialize the phasing TSST API list. */
23391
 
        ulMaxPhasingTssts = pSharedInfo->ChipConfig.usMaxPhasingTssts;
23392
 
 
23393
 
        /* Set all entries in the phasing TSST list to unused. */
23394
 
        mOCT6100_GET_PHASING_TSST_LIST_PNT( pSharedInfo, pPhasingTsstList )
23395
 
 
23396
 
        /* Clear the memory */
23397
 
        Oct6100UserMemSet( pPhasingTsstList, 0x00, sizeof(tOCT6100_API_PHASING_TSST) * ulMaxPhasingTssts );
23398
 
 
23399
 
        /* Initialize the phasing TSST allocation software to "all free". */
23400
 
        if ( ulMaxPhasingTssts > 0 )
23401
 
        {
23402
 
                mOCT6100_GET_PHASING_TSST_ALLOC_PNT( pSharedInfo, pPhasingTsstAlloc )
23403
 
                
23404
 
                ulResult = OctapiLlmAllocInit( &pPhasingTsstAlloc, ulMaxPhasingTssts );
23405
 
                if ( ulResult != cOCT6100_ERR_OK )
23406
 
                        return cOCT6100_ERR_FATAL_39;
23407
 
        }
23408
 
        
23409
 
        return cOCT6100_ERR_OK;
23410
 
}
23411
 
 
23412
 
 
23413
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23414
 
 
23415
 
File: oct6100_playout_buf.c
23416
 
 
23417
 
    Copyright (c) 2001-2005 Octasic Inc.
23418
 
    
23419
 
Description: 
23420
 
 
23421
 
        This file contains functions used to manage buffer playout.
23422
 
 
23423
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
23424
 
free software; you can redistribute it and/or modify it under the terms of 
23425
 
the GNU General Public License as published by the Free Software Foundation; 
23426
 
either version 2 of the License, or (at your option) any later version.
23427
 
 
23428
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
23429
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
23430
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
23431
 
for more details. 
23432
 
 
23433
 
You should have received a copy of the GNU General Public License 
23434
 
along with the OCT6100 GPL API; if not, write to the Free Software 
23435
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23436
 
 
23437
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
23438
 
 
23439
 
$Octasic_Revision: 109 $
23440
 
 
23441
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23442
 
 
23443
 
 
23444
 
/*****************************  INCLUDE FILES  *******************************/
23445
 
 
23446
 
#include "octdef.h"
23447
 
 
23448
 
#include "oct6100api/oct6100_defines.h"
23449
 
#include "oct6100api/oct6100_errors.h"
23450
 
#include "oct6100api/oct6100_apiud.h"
23451
 
 
23452
 
#include "apilib/octapi_llman.h"
23453
 
 
23454
 
#include "oct6100api/oct6100_tlv_inst.h"
23455
 
#include "oct6100api/oct6100_chip_open_inst.h"
23456
 
#include "oct6100api/oct6100_chip_stats_inst.h"
23457
 
#include "oct6100api/oct6100_interrupts_inst.h"
23458
 
#include "oct6100api/oct6100_remote_debug_inst.h"
23459
 
#include "oct6100api/oct6100_debug_inst.h"
23460
 
#include "oct6100api/oct6100_api_inst.h"
23461
 
#include "oct6100api/oct6100_channel_inst.h"
23462
 
#include "oct6100api/oct6100_playout_buf_inst.h"
23463
 
 
23464
 
#include "oct6100api/oct6100_interrupts_pub.h"
23465
 
#include "oct6100api/oct6100_chip_open_pub.h"
23466
 
#include "oct6100api/oct6100_channel_pub.h"
23467
 
#include "oct6100api/oct6100_events_pub.h"
23468
 
#include "oct6100api/oct6100_playout_buf_pub.h"
23469
 
 
23470
 
#include "oct6100_chip_open_priv.h"
23471
 
#include "oct6100_miscellaneous_priv.h"
23472
 
#include "oct6100_memory_priv.h"
23473
 
#include "oct6100_channel_priv.h"
23474
 
#include "oct6100_events_priv.h"
23475
 
#include "oct6100_playout_buf_priv.h"
23476
 
 
23477
 
/****************************  PUBLIC FUNCTIONS  *****************************/
23478
 
 
23479
 
/****************************  PRIVATE FUNCTIONS  ****************************/
23480
 
 
23481
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23482
 
 
23483
 
Function:               Oct6100ApiGetPlayoutBufferSwSizes
23484
 
 
23485
 
Description:    Gets the sizes of all portions of the API instance pertinent
23486
 
                                to the management of playout buffers.
23487
 
 
23488
 
-------------------------------------------------------------------------------
23489
 
|       Argument                |       Description
23490
 
-------------------------------------------------------------------------------
23491
 
f_pOpenChip                             Pointer to chip configuration struct.
23492
 
f_pInstSizes                    Pointer to struct containing instance sizes.
23493
 
 
23494
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23495
 
static UINT32 Oct6100ApiGetPlayoutBufferSwSizes(
23496
 
                                IN              tPOCT6100_CHIP_OPEN                             f_pOpenChip,
23497
 
                                OUT             tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
23498
 
{
23499
 
        UINT32  ulTempVar;
23500
 
        UINT32  ulResult;
23501
 
 
23502
 
        /* Calculate memory needed for playout buffer list. */
23503
 
        f_pInstSizes->ulPlayoutBufList = f_pOpenChip->ulMaxPlayoutBuffers * sizeof( tOCT6100_API_BUFFER );
23504
 
 
23505
 
        f_pInstSizes->ulPlayoutBufMemoryNodeList = 0;
23506
 
        
23507
 
        /* Calculate memory needed for playout buffer allocation software. */
23508
 
        if ( f_pOpenChip->ulMaxPlayoutBuffers > 0 )
23509
 
        {
23510
 
                ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxPlayoutBuffers, &f_pInstSizes->ulPlayoutBufAlloc );
23511
 
                if ( ulResult != cOCT6100_ERR_OK )
23512
 
                        return cOCT6100_ERR_FATAL_3C;
23513
 
                
23514
 
                f_pInstSizes->ulPlayoutBufMemoryNodeList = 2 * f_pOpenChip->ulMaxPlayoutBuffers * sizeof( tOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE );
23515
 
        }
23516
 
        else
23517
 
        {
23518
 
                f_pInstSizes->ulPlayoutBufAlloc  = 0;
23519
 
        }
23520
 
 
23521
 
        /* Calculate memory needed for list and allocation software serialization. */
23522
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPlayoutBufList, ulTempVar )
23523
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPlayoutBufAlloc, ulTempVar )
23524
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPlayoutBufMemoryNodeList, ulTempVar )
23525
 
 
23526
 
        return cOCT6100_ERR_OK;
23527
 
}
23528
 
 
23529
 
 
23530
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23531
 
 
23532
 
Function:               Oct6100ApiPlayoutBufferSwInit
23533
 
 
23534
 
Description:    Initializes all elements of the instance structure associated
23535
 
                                to playout buffers.
23536
 
 
23537
 
-------------------------------------------------------------------------------
23538
 
|       Argument                |       Description
23539
 
-------------------------------------------------------------------------------
23540
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
23541
 
                                                the present state of the chip and all its resources.
23542
 
 
23543
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23544
 
static UINT32 Oct6100ApiPlayoutBufferSwInit(
23545
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance )
23546
 
{
23547
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
23548
 
        tPOCT6100_API_BUFFER                    pBufferList;
23549
 
        PVOID   pBufferPlayoutAlloc;
23550
 
        UINT32  ulMaxBufferPlayout;
23551
 
        UINT32  ulResult, i;
23552
 
 
23553
 
        /* Get local pointer to shared portion of instance. */
23554
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
23555
 
 
23556
 
        /* Get the maximum number of buffer playout. */
23557
 
        ulMaxBufferPlayout = pSharedInfo->ChipConfig.usMaxPlayoutBuffers;
23558
 
 
23559
 
        /* Set all entries in the buffer playout list to unused. */
23560
 
        mOCT6100_GET_BUFFER_LIST_PNT( pSharedInfo, pBufferList )
23561
 
 
23562
 
        for ( i = 0; i < ulMaxBufferPlayout; i++ )
23563
 
        {
23564
 
                pBufferList[ i ].fReserved = FALSE;
23565
 
                pBufferList[ i ].ulBufferSize = 0;
23566
 
                pBufferList[ i ].ulBufferBase = cOCT6100_INVALID_VALUE;
23567
 
                pBufferList[ i ].usDependencyCnt = 0;
23568
 
                pBufferList[ i ].byBufferPcmLaw = cOCT6100_PCM_U_LAW;
23569
 
                
23570
 
        }
23571
 
 
23572
 
        /* Initialize the buffer playout allocation software to "all free". */
23573
 
        if ( ulMaxBufferPlayout > 0 )
23574
 
        {
23575
 
                mOCT6100_GET_BUFFER_ALLOC_PNT( pSharedInfo, pBufferPlayoutAlloc )
23576
 
                
23577
 
                ulResult = OctapiLlmAllocInit( &pBufferPlayoutAlloc, ulMaxBufferPlayout );
23578
 
                if ( ulResult != cOCT6100_ERR_OK )
23579
 
                        return cOCT6100_ERR_FATAL_3D;
23580
 
        }
23581
 
 
23582
 
        /* Initialize the amount of free memory used by playout. */
23583
 
        f_pApiInstance->pSharedInfo->ChipStats.ulPlayoutMemUsed = 0;
23584
 
 
23585
 
        return cOCT6100_ERR_OK;
23586
 
}
23587
 
 
23588
 
 
23589
 
 
23590
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23591
 
 
23592
 
Function:               Oct6100BufferPlayoutStopSer
23593
 
 
23594
 
Description:    Stops buffer playout on a channel.
23595
 
 
23596
 
-------------------------------------------------------------------------------
23597
 
|       Argument                |       Description
23598
 
-------------------------------------------------------------------------------
23599
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
23600
 
                                                present state of the chip and all its resources.
23601
 
 
23602
 
f_pBufferPlayoutStop    Pointer to buffer playout stop structure.
23603
 
 
23604
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23605
 
static UINT32 Oct6100BufferPlayoutStopSer(
23606
 
                                IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
23607
 
                                IN OUT  tPOCT6100_BUFFER_PLAYOUT_STOP           f_pBufferPlayoutStop )
23608
 
{
23609
 
        UINT32  ulChannelIndex;
23610
 
        UINT16  usEchoMemIndex;
23611
 
        UINT32  ulResult;
23612
 
 
23613
 
        /* Check the user's configuration of the buffer for errors. */
23614
 
        ulResult = Oct6100ApiAssertPlayoutStopParams( 
23615
 
                                                                                                f_pApiInstance, 
23616
 
                                                                                                f_pBufferPlayoutStop, 
23617
 
                                                                                                &ulChannelIndex, 
23618
 
                                                                                                &usEchoMemIndex );
23619
 
        if ( ulResult != cOCT6100_ERR_OK )
23620
 
                return ulResult;
23621
 
 
23622
 
        /* Write to  all resources needed to deactivate buffer playout. */
23623
 
        ulResult = Oct6100ApiInvalidateChanPlayoutStructs( 
23624
 
                                                                                                f_pApiInstance, 
23625
 
                                                                                                f_pBufferPlayoutStop, 
23626
 
                                                                                                ulChannelIndex, 
23627
 
                                                                                                usEchoMemIndex 
23628
 
 
23629
 
                                                                                                );
23630
 
        if ( ulResult != cOCT6100_ERR_OK )
23631
 
                return ulResult;
23632
 
 
23633
 
        return cOCT6100_ERR_OK;
23634
 
}
23635
 
 
23636
 
 
23637
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23638
 
 
23639
 
Function:               Oct6100ApiAssertPlayoutStopParams
23640
 
 
23641
 
Description:    Check the validity of the channel and buffer requested.
23642
 
 
23643
 
-------------------------------------------------------------------------------
23644
 
|       Argument                |       Description
23645
 
-------------------------------------------------------------------------------
23646
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
23647
 
                                                present state of the chip and all its resources.
23648
 
 
23649
 
f_pBufferPlayoutStop    Pointer to buffer playout stop structure.  
23650
 
f_pulChannelIndex               Pointer to the channel index on which playout is to be stopped.
23651
 
f_pusEchoMemIndex               Pointer to the echo mem index on which playout is to be stopped.
23652
 
 
23653
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23654
 
static UINT32 Oct6100ApiAssertPlayoutStopParams(
23655
 
                                IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
23656
 
                                IN              tPOCT6100_BUFFER_PLAYOUT_STOP           f_pBufferPlayoutStop,
23657
 
                                OUT             PUINT32                                                         f_pulChannelIndex,
23658
 
                                OUT             PUINT16                                                         f_pusEchoMemIndex )
23659
 
{
23660
 
        tPOCT6100_API_CHANNEL           pEchoChannel;
23661
 
        UINT32  ulEntryOpenCnt;
23662
 
 
23663
 
        /* Check for errors. */
23664
 
        if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers == 0 )
23665
 
                return cOCT6100_ERR_BUFFER_PLAYOUT_DISABLED;
23666
 
        
23667
 
        if ( f_pBufferPlayoutStop->ulChannelHndl == cOCT6100_INVALID_HANDLE )
23668
 
                return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
23669
 
 
23670
 
        if ( f_pBufferPlayoutStop->ulPlayoutPort != cOCT6100_CHANNEL_PORT_ROUT && 
23671
 
                 f_pBufferPlayoutStop->ulPlayoutPort != cOCT6100_CHANNEL_PORT_SOUT )
23672
 
                return cOCT6100_ERR_BUFFER_PLAYOUT_PLAYOUT_PORT;
23673
 
 
23674
 
        if ( f_pBufferPlayoutStop->fStopCleanly != TRUE && f_pBufferPlayoutStop->fStopCleanly != FALSE )
23675
 
                return cOCT6100_ERR_BUFFER_PLAYOUT_STOP_CLEANLY;
23676
 
        
23677
 
        /*=====================================================================*/
23678
 
        /* Check the channel handle. */
23679
 
 
23680
 
        if ( (f_pBufferPlayoutStop->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
23681
 
                return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
23682
 
 
23683
 
        *f_pulChannelIndex = f_pBufferPlayoutStop->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK;
23684
 
        if ( *f_pulChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
23685
 
                return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
23686
 
 
23687
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex )
23688
 
 
23689
 
        /* Extract the entry open count from the provided handle. */
23690
 
        ulEntryOpenCnt = (f_pBufferPlayoutStop->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
23691
 
 
23692
 
        /* Check for errors. */
23693
 
        if ( pEchoChannel->fReserved != TRUE )
23694
 
                return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_NOT_OPEN;
23695
 
        if ( ulEntryOpenCnt != pEchoChannel->byEntryOpenCnt )
23696
 
                return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
23697
 
 
23698
 
        /* Return echo memory index. */
23699
 
        *f_pusEchoMemIndex = pEchoChannel->usEchoMemIndex;
23700
 
 
23701
 
        /* Check if buffer playout is active for the selected port. */
23702
 
        if ( ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
23703
 
                && ( pEchoChannel->fRinBufPlaying == FALSE )
23704
 
                && ( pEchoChannel->fRinBufAdded == FALSE ) )
23705
 
                return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_STARTED;
23706
 
 
23707
 
        if ( ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT )
23708
 
                && ( pEchoChannel->fSoutBufPlaying == FALSE )
23709
 
                 && ( pEchoChannel->fSoutBufAdded == FALSE ) )
23710
 
                return cOCT6100_ERR_BUFFER_PLAYOUT_NOT_STARTED;
23711
 
        
23712
 
        /*=====================================================================*/
23713
 
 
23714
 
        return cOCT6100_ERR_OK;
23715
 
}
23716
 
 
23717
 
 
23718
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23719
 
 
23720
 
Function:               Oct6100ApiInvalidateChanPlayoutStructs
23721
 
 
23722
 
Description:    Write the buffer playout event in the channel main structure.
23723
 
 
23724
 
-------------------------------------------------------------------------------
23725
 
|       Argument                |       Description
23726
 
-------------------------------------------------------------------------------
23727
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
23728
 
                                                        present state of the chip and all its resources.
23729
 
        
23730
 
f_pBufferPlayoutStop            Pointer to buffer playout stop structure.  
23731
 
f_ulChannelIndex                        Index of the channel within the API's channel list.
23732
 
f_usEchoMemIndex                        Index of the echo channel in hardware memory.
23733
 
 
23734
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23735
 
static UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
23736
 
                                IN OUT  tPOCT6100_INSTANCE_API                          f_pApiInstance,
23737
 
                                IN              tPOCT6100_BUFFER_PLAYOUT_STOP           f_pBufferPlayoutStop,
23738
 
                                IN              UINT32                                                          f_ulChannelIndex,
23739
 
                                IN              UINT16                                                          f_usEchoMemIndex
23740
 
 
23741
 
                                )
23742
 
{
23743
 
        tPOCT6100_API_CHANNEL   pEchoChannel;
23744
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
23745
 
        tOCT6100_READ_PARAMS    ReadParams;
23746
 
        tOCT6100_WRITE_PARAMS   WriteParams;
23747
 
 
23748
 
        UINT32  ulResult;
23749
 
 
23750
 
        UINT32  ulWritePtrBytesOfst;
23751
 
        UINT32  ulWritePtrBitOfst;
23752
 
        UINT32  ulWritePtrFieldSize;
23753
 
        UINT32  ulSkipPtrBytesOfst;
23754
 
        UINT32  ulSkipPtrBitOfst;
23755
 
        UINT32  ulSkipPtrFieldSize;
23756
 
        UINT32  ulIgnoreBytesOfst;
23757
 
        UINT32  ulIgnoreBitOfst;
23758
 
        UINT32  ulIgnoreFieldSize;
23759
 
        UINT32  ulHardSkipBytesOfst;
23760
 
        UINT32  ulHardSkipBitOfst;
23761
 
        UINT32  ulHardSkipFieldSize;
23762
 
        UINT32  ulReadPtrBytesOfst;
23763
 
        UINT32  ulReadPtrBitOfst;
23764
 
        UINT32  ulReadPtrFieldSize;
23765
 
 
23766
 
        UINT32  ulSkipPtr;
23767
 
        UINT32  ulWritePtr;
23768
 
        UINT32  ulReadPtr = 0;
23769
 
        UINT32  ulCurrentPtr;
23770
 
 
23771
 
        UINT32  ulPlayoutBaseAddress;
23772
 
        UINT32  ulAddress;
23773
 
        UINT32  ulTempData;
23774
 
        UINT32  ulMask;
23775
 
        UINT32  ulReadData;
23776
 
 
23777
 
        UINT16  usReadData;     
23778
 
        BOOL    fCheckStop = FALSE;
23779
 
 
23780
 
        UINT32  ulEventBuffer;
23781
 
 
23782
 
        /* Obtain local pointer to shared portion of instance. */
23783
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
23784
 
 
23785
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
23786
 
 
23787
 
        WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
23788
 
 
23789
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
23790
 
 
23791
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
23792
 
        ReadParams.pusReadData = &usReadData;
23793
 
 
23794
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, f_ulChannelIndex );
23795
 
 
23796
 
        /* Select the port of interest. */
23797
 
        if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
23798
 
        {
23799
 
                ulWritePtr = pEchoChannel->ulRinBufWritePtr; 
23800
 
                ulSkipPtr  = ulWritePtr;
23801
 
 
23802
 
                ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.usDwordOffset * 4;
23803
 
                ulWritePtrBitOfst       = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byBitOffset;
23804
 
                ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byFieldSize;
23805
 
 
23806
 
                ulSkipPtrBytesOfst  = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.usDwordOffset * 4;
23807
 
                ulSkipPtrBitOfst        = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byBitOffset;
23808
 
                ulSkipPtrFieldSize      = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byFieldSize;
23809
 
 
23810
 
                ulIgnoreBytesOfst       = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.usDwordOffset * 4;
23811
 
                ulIgnoreBitOfst         = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byBitOffset;
23812
 
                ulIgnoreFieldSize       = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byFieldSize;
23813
 
 
23814
 
                ulHardSkipBytesOfst     = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.usDwordOffset * 4;
23815
 
                ulHardSkipBitOfst       = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byBitOffset;
23816
 
                ulHardSkipFieldSize     = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byFieldSize;
23817
 
 
23818
 
                ulReadPtrBytesOfst      = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.usDwordOffset * 4;
23819
 
                ulReadPtrBitOfst        = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byBitOffset;
23820
 
                ulReadPtrFieldSize      = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byFieldSize;
23821
 
        }
23822
 
        else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
23823
 
        {
23824
 
                ulWritePtr = pEchoChannel->ulSoutBufWritePtr; 
23825
 
                ulSkipPtr  = ulWritePtr;
23826
 
 
23827
 
                ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.usDwordOffset * 4;
23828
 
                ulWritePtrBitOfst       = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byBitOffset;
23829
 
                ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byFieldSize;
23830
 
 
23831
 
                ulSkipPtrBytesOfst  = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.usDwordOffset * 4;
23832
 
                ulSkipPtrBitOfst        = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byBitOffset;
23833
 
                ulSkipPtrFieldSize      = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byFieldSize;
23834
 
 
23835
 
                ulIgnoreBytesOfst       = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.usDwordOffset * 4;
23836
 
                ulIgnoreBitOfst         = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byBitOffset;
23837
 
                ulIgnoreFieldSize       = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byFieldSize;
23838
 
 
23839
 
                ulHardSkipBytesOfst     = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.usDwordOffset * 4;
23840
 
                ulHardSkipBitOfst       = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byBitOffset;
23841
 
                ulHardSkipFieldSize     = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byFieldSize;
23842
 
 
23843
 
                ulReadPtrBytesOfst      = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.usDwordOffset * 4;
23844
 
                ulReadPtrBitOfst        = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byBitOffset;
23845
 
                ulReadPtrFieldSize      = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byFieldSize;
23846
 
        }
23847
 
 
23848
 
        /* Set the playout feature base address. */
23849
 
        ulPlayoutBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
23850
 
 
23851
 
        /* Check if something is currently playing. */
23852
 
        if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
23853
 
        {
23854
 
                if ( pEchoChannel->fRinBufPlaying == TRUE )
23855
 
                {
23856
 
                        /* Check if we are stopping it or if it stopped by itself. */
23857
 
                        fCheckStop = TRUE;
23858
 
                }
23859
 
                else
23860
 
                {
23861
 
                        /* Not playing! */
23862
 
                        if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL )
23863
 
                                *f_pBufferPlayoutStop->pfAlreadyStopped = TRUE;
23864
 
                }
23865
 
        }
23866
 
        else /* if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */
23867
 
        {
23868
 
                if ( pEchoChannel->fSoutBufPlaying == TRUE )
23869
 
                {
23870
 
                        /* Check if we are stopping it or if it stopped by itself. */
23871
 
                        fCheckStop = TRUE;
23872
 
                }
23873
 
                else
23874
 
                {
23875
 
                        /* Not playing! */
23876
 
                        if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL )
23877
 
                                *f_pBufferPlayoutStop->pfAlreadyStopped = TRUE;
23878
 
                }
23879
 
        }
23880
 
 
23881
 
        if ( ( fCheckStop == TRUE ) || ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE ) )
23882
 
        {
23883
 
                /* Read the read pointer. */
23884
 
                ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
23885
 
 
23886
 
                ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
23887
 
                ReadParams.pusReadData = &usReadData;
23888
 
                ReadParams.ulReadAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst;
23889
 
 
23890
 
                /* Optimize this access by only reading the word we are interested in. */
23891
 
                if ( ulReadPtrBitOfst < 16 )
23892
 
                        ReadParams.ulReadAddress += 2;
23893
 
 
23894
 
                /* Must read in memory directly since this value is changed by hardware */
23895
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
23896
 
                if ( ulResult != cOCT6100_ERR_OK )
23897
 
                        return ulResult;
23898
 
 
23899
 
                /* Move data at correct position according to what was read. */
23900
 
                if ( ulReadPtrBitOfst < 16 )
23901
 
                        ulTempData = usReadData;
23902
 
                else
23903
 
                        ulTempData = usReadData << 16;
23904
 
                
23905
 
                mOCT6100_CREATE_FEATURE_MASK( ulReadPtrFieldSize, ulReadPtrBitOfst, &ulMask );
23906
 
                
23907
 
                /* Store the read pointer. */
23908
 
                ulReadPtr = ( ulTempData & ulMask ) >> ulReadPtrBitOfst;
23909
 
 
23910
 
                /* Playout has finished when the read pointer reaches the write pointer. */
23911
 
                if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL )
23912
 
                {
23913
 
                        if ( ulReadPtr != ulWritePtr )
23914
 
                                *f_pBufferPlayoutStop->pfAlreadyStopped = FALSE;
23915
 
                        else /* if ( ulReadPtr == ulWritePtr ) */
23916
 
                                *f_pBufferPlayoutStop->pfAlreadyStopped = TRUE;
23917
 
                }
23918
 
        }
23919
 
 
23920
 
        /* If the skip bits are located in the event itself, the playout is stopped by setting the */
23921
 
        /* skip pointer to the hardware chip write pointer.  Read it directly from the NLP configuration. */
23922
 
        if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
23923
 
        {
23924
 
                if ( ulReadPtr != ulWritePtr )
23925
 
                {
23926
 
                        /* Get the write pointer in the chip. */
23927
 
                        ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst;
23928
 
 
23929
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, pEchoChannel, ulAddress, &ulReadData, ulResult );
23930
 
                        if ( ulResult != cOCT6100_ERR_OK )
23931
 
                                return ulResult;
23932
 
 
23933
 
                        mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask );
23934
 
 
23935
 
                        /* Store the write pointer. */
23936
 
                        ulWritePtr = ( ulReadData & ulMask ) >> ulWritePtrBitOfst;
23937
 
                        ulSkipPtr = ulWritePtr;
23938
 
                }
23939
 
        }
23940
 
 
23941
 
        /* Check if must clear repeat bit. */
23942
 
        if ( ( ( pEchoChannel->fRinBufPlayoutRepeatUsed == TRUE ) && ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT ) )
23943
 
                || ( ( pEchoChannel->fSoutBufPlayoutRepeatUsed == TRUE ) && ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) ) )
23944
 
        {
23945
 
                if ( ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE )
23946
 
                        || ( ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
23947
 
                                && ( ulWritePtr != ulReadPtr ) ) )
23948
 
                {
23949
 
                        if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
23950
 
                        {
23951
 
                                ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst;
23952
 
                        }
23953
 
                        else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
23954
 
                        {
23955
 
                                ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst;
23956
 
                        }
23957
 
 
23958
 
                        /* Set the playout event base address. */
23959
 
                        if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE )
23960
 
                                && ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) )
23961
 
                        {
23962
 
                                /* 127 or 31 events image. */
23963
 
                                ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + (cOCT6100_PLAYOUT_EVENT_MEM_SIZE * ( ( ulWritePtr - 1 ) & ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 )));
23964
 
                        }
23965
 
                        else
23966
 
                        {
23967
 
                                /* Old 31 events image. */
23968
 
                                ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + (cOCT6100_PLAYOUT_EVENT_MEM_SIZE * ( ( ulWritePtr - 1 ) & 0x1F));
23969
 
                        }
23970
 
 
23971
 
                        /* EVENT BASE + 4 */
23972
 
                        /* Playout configuration. */
23973
 
                        ulAddress += 4;
23974
 
 
23975
 
                        ReadParams.ulReadAddress = ulAddress;
23976
 
                        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
23977
 
                        if ( ulResult != cOCT6100_ERR_OK )
23978
 
                                return ulResult;
23979
 
 
23980
 
                        /* Read-clear-write the new repeat bit. */
23981
 
                        usReadData &= 0x7FFF;
23982
 
 
23983
 
                        WriteParams.ulWriteAddress = ulAddress;
23984
 
                        WriteParams.usWriteData = usReadData;
23985
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
23986
 
                        if ( ulResult != cOCT6100_ERR_OK )
23987
 
                                return ulResult;
23988
 
                }
23989
 
        }
23990
 
 
23991
 
        /* Write the skip to the value of the write pointer to stop buffer playout. */
23992
 
 
23993
 
        /*=======================================================================*/
23994
 
        /* First set the ignore skip clean bit if required. */  
23995
 
 
23996
 
        if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == FALSE )
23997
 
                || ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == FALSE ) )
23998
 
        {
23999
 
                ulAddress = ulPlayoutBaseAddress + ulIgnoreBytesOfst;
24000
 
 
24001
 
                mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
24002
 
                                                                                        pEchoChannel,
24003
 
                                                                                        ulAddress,
24004
 
                                                                                        &ulTempData,
24005
 
                                                                                        ulResult );
24006
 
                if ( ulResult != cOCT6100_ERR_OK )
24007
 
                        return ulResult;
24008
 
                
24009
 
                mOCT6100_CREATE_FEATURE_MASK( ulIgnoreFieldSize, ulIgnoreBitOfst, &ulMask );
24010
 
                
24011
 
                ulTempData &= ( ~ulMask );
24012
 
 
24013
 
                /* Check if the skip need to be clean or not. */
24014
 
                if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
24015
 
                        ulTempData |= 0x1 << ulIgnoreBitOfst;
24016
 
                
24017
 
                mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
24018
 
                                                                                pEchoChannel,
24019
 
                                                                                ulAddress,
24020
 
                                                                                ulTempData,
24021
 
                                                                                ulResult );
24022
 
                if ( ulResult != cOCT6100_ERR_OK )
24023
 
                        return ulResult;
24024
 
        }
24025
 
 
24026
 
        /*=======================================================================*/
24027
 
 
24028
 
        
24029
 
        /*=======================================================================*/
24030
 
        /* Fetch and modify the write pointer. */       
24031
 
 
24032
 
        ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst;
24033
 
 
24034
 
        mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, pEchoChannel, ulAddress, &ulTempData, ulResult );
24035
 
        if ( ulResult != cOCT6100_ERR_OK )
24036
 
                return ulResult;
24037
 
        
24038
 
        mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask );
24039
 
        
24040
 
        ulTempData &= ( ~ulMask );
24041
 
        ulTempData |= ulWritePtr << ulWritePtrBitOfst;
24042
 
        
24043
 
        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
24044
 
                                                                        pEchoChannel,
24045
 
                                                                        ulAddress,
24046
 
                                                                        ulTempData,
24047
 
                                                                        ulResult );
24048
 
        if ( ulResult != cOCT6100_ERR_OK )
24049
 
                return ulResult;
24050
 
        
24051
 
        /*=======================================================================*/
24052
 
 
24053
 
        
24054
 
        /*=======================================================================*/
24055
 
        /* Fetch and modify the skip pointer. */        
24056
 
 
24057
 
        ulAddress = ulPlayoutBaseAddress + ulSkipPtrBytesOfst;
24058
 
 
24059
 
        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
24060
 
                                                                                pEchoChannel,
24061
 
                                                                                ulAddress,
24062
 
                                                                                &ulTempData,
24063
 
                                                                                ulResult );
24064
 
        if ( ulResult != cOCT6100_ERR_OK )
24065
 
                return ulResult;
24066
 
        
24067
 
        mOCT6100_CREATE_FEATURE_MASK( ulSkipPtrFieldSize, ulSkipPtrBitOfst, &ulMask );
24068
 
        
24069
 
        ulTempData &= ( ~ulMask );
24070
 
        ulTempData |= ulSkipPtr << ulSkipPtrBitOfst;
24071
 
        
24072
 
        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
24073
 
                                                                        pEchoChannel,
24074
 
                                                                        ulAddress,
24075
 
                                                                        ulTempData,
24076
 
                                                                        ulResult );
24077
 
        if ( ulResult != cOCT6100_ERR_OK )
24078
 
                return ulResult;
24079
 
        
24080
 
        /*=======================================================================*/
24081
 
        
24082
 
 
24083
 
        /*=======================================================================*/
24084
 
        /* If in the new buffer playout case, things are in a different order. */       
24085
 
 
24086
 
        if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE )
24087
 
        {
24088
 
                if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE )
24089
 
                        && ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) )
24090
 
                {
24091
 
                        ulAddress = ulPlayoutBaseAddress + ulHardSkipBytesOfst;
24092
 
 
24093
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
24094
 
                                                                                                pEchoChannel,
24095
 
                                                                                                ulAddress,
24096
 
                                                                                                &ulTempData,
24097
 
                                                                                                ulResult );
24098
 
                        if ( ulResult != cOCT6100_ERR_OK )
24099
 
                                return ulResult;
24100
 
                        
24101
 
                        mOCT6100_CREATE_FEATURE_MASK( ulHardSkipFieldSize, ulHardSkipBitOfst, &ulMask );
24102
 
                        
24103
 
                        ulTempData &= ( ~ulMask );
24104
 
 
24105
 
                        /* Check if the skip need to be clean or not. */
24106
 
                        if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
24107
 
                                ulTempData |= 0x1 << ulHardSkipBitOfst;
24108
 
                        
24109
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
24110
 
                                                                                        pEchoChannel,
24111
 
                                                                                        ulAddress,
24112
 
                                                                                        ulTempData,
24113
 
                                                                                        ulResult );
24114
 
                        if ( ulResult != cOCT6100_ERR_OK )
24115
 
                                return ulResult;
24116
 
 
24117
 
                        /* Now is the appropriate time to skip! */
24118
 
                        ulAddress = ulPlayoutBaseAddress + ulIgnoreBytesOfst;
24119
 
 
24120
 
                        mOCT6100_RETRIEVE_NLP_CONF_DWORD(       f_pApiInstance,
24121
 
                                                                                                pEchoChannel,
24122
 
                                                                                                ulAddress,
24123
 
                                                                                                &ulTempData,
24124
 
                                                                                                ulResult );
24125
 
                        if ( ulResult != cOCT6100_ERR_OK )
24126
 
                                return ulResult;
24127
 
                        
24128
 
                        mOCT6100_CREATE_FEATURE_MASK( ulIgnoreFieldSize, ulIgnoreBitOfst, &ulMask );
24129
 
 
24130
 
                        ulTempData &= ( ~ulMask );
24131
 
 
24132
 
                        /* Set the skip bit. */
24133
 
                        ulTempData |= 0x1 << ulIgnoreBitOfst;
24134
 
                        
24135
 
                        mOCT6100_SAVE_NLP_CONF_DWORD(   f_pApiInstance,
24136
 
                                                                                        pEchoChannel,
24137
 
                                                                                        ulAddress,
24138
 
                                                                                        ulTempData,
24139
 
                                                                                        ulResult );
24140
 
                        if ( ulResult != cOCT6100_ERR_OK )
24141
 
                                return ulResult;
24142
 
                }
24143
 
        }
24144
 
 
24145
 
        /*=======================================================================*/
24146
 
 
24147
 
 
24148
 
        /*=======================================================================*/
24149
 
        /* The API must set the skip bit in all the events that are queued. */
24150
 
 
24151
 
        if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
24152
 
        {
24153
 
                if ( fCheckStop == TRUE )
24154
 
                {
24155
 
                        if ( ulReadPtr != ulWritePtr )
24156
 
                        {
24157
 
                                if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
24158
 
                                {
24159
 
                                        ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst;
24160
 
                                }
24161
 
                                else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
24162
 
                                {
24163
 
                                        ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst;
24164
 
                                }
24165
 
 
24166
 
                                for ( ulCurrentPtr = ulReadPtr; ulCurrentPtr != ulWritePtr; )
24167
 
                                {
24168
 
                                        /* Set the playout event base address. */
24169
 
                                        
24170
 
                                        /* 127 or 31 events image. */
24171
 
                                        ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + ( cOCT6100_PLAYOUT_EVENT_MEM_SIZE * ulCurrentPtr );
24172
 
                                        ulCurrentPtr++;
24173
 
                                        ulCurrentPtr &= ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 );
24174
 
 
24175
 
                                        /* EVENT BASE + 0 playout configuration. */
24176
 
                                        WriteParams.ulWriteAddress = ulAddress;
24177
 
 
24178
 
                                        /* Set skip bit + hard-skip bit. */
24179
 
                                        WriteParams.usWriteData = 0x8000;
24180
 
                                        if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
24181
 
                                                WriteParams.usWriteData |= 0x4000;
24182
 
                                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
24183
 
                                        if ( ulResult != cOCT6100_ERR_OK )
24184
 
                                                return ulResult;
24185
 
                                }
24186
 
                        }
24187
 
                }
24188
 
        }
24189
 
 
24190
 
        /*=======================================================================*/
24191
 
        /* If stop immediatly, wait the stop before leaving the function. */
24192
 
 
24193
 
        if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
24194
 
        {
24195
 
                /* Remember that an "hard stop" was used for the next start. */
24196
 
                if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
24197
 
                        pEchoChannel->fRinHardStop = TRUE;
24198
 
                else /* if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */
24199
 
                        pEchoChannel->fSoutHardStop = TRUE;
24200
 
        }
24201
 
 
24202
 
        /*=======================================================================*/
24203
 
        /* Update the channel entry to set the playing flag to FALSE. */
24204
 
 
24205
 
        /* Select the port of interest. */
24206
 
        if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
24207
 
        {
24208
 
                /* Check if the global ports active stat must be decremented. */
24209
 
                if ( pEchoChannel->fRinBufPlaying == TRUE )
24210
 
                {
24211
 
                        /* Decrement the number of active buffer playout ports. */
24212
 
                        pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--;
24213
 
                }
24214
 
 
24215
 
                pEchoChannel->fRinBufPlaying = FALSE;
24216
 
 
24217
 
                /* Return user information. */
24218
 
                if ( f_pBufferPlayoutStop->pfNotifyOnPlayoutStop != NULL )
24219
 
                        *f_pBufferPlayoutStop->pfNotifyOnPlayoutStop = pEchoChannel->fRinBufPlayoutNotifyOnStop;
24220
 
 
24221
 
                /* Make sure no new event is recorded for this channel/port. */
24222
 
                pEchoChannel->fRinBufPlayoutNotifyOnStop = FALSE;
24223
 
                if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
24224
 
                {
24225
 
                        pEchoChannel->ulRinBufSkipPtr = ulSkipPtr;
24226
 
                        pEchoChannel->ulRinBufWritePtr = ulWritePtr;
24227
 
                }
24228
 
                else /* if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE ) */
24229
 
                        pEchoChannel->ulRinBufSkipPtr = pEchoChannel->ulRinBufWritePtr;
24230
 
 
24231
 
                /* The repeat flag can now be used. */
24232
 
                pEchoChannel->fRinBufPlayoutRepeatUsed = FALSE;
24233
 
 
24234
 
                /* For sure, all buffers have now been cleared on the Rin port. */
24235
 
                pEchoChannel->fRinBufAdded = FALSE;
24236
 
 
24237
 
                /* Clear optimization flag if possible. */
24238
 
                if ( ( pEchoChannel->fSoutBufPlaying == FALSE )
24239
 
                        && ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == FALSE ) )
24240
 
                {
24241
 
                        /* Buffer playout is no more active on this channel. */
24242
 
                        pEchoChannel->fBufPlayoutActive = FALSE;
24243
 
                }
24244
 
        }
24245
 
        else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
24246
 
        {
24247
 
                /* Check if the global ports active stat must be decremented. */
24248
 
                if ( pEchoChannel->fSoutBufPlaying == TRUE )
24249
 
                {
24250
 
                        /* Decrement the number of active buffer playout ports. */
24251
 
                        pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--;
24252
 
                }
24253
 
 
24254
 
                pEchoChannel->fSoutBufPlaying = FALSE;
24255
 
 
24256
 
                /* Return user information. */
24257
 
                if ( f_pBufferPlayoutStop->pfNotifyOnPlayoutStop != NULL )
24258
 
                        *f_pBufferPlayoutStop->pfNotifyOnPlayoutStop = pEchoChannel->fSoutBufPlayoutNotifyOnStop;
24259
 
 
24260
 
                /* Make sure no new event is recorded for this channel/port. */
24261
 
                pEchoChannel->fSoutBufPlayoutNotifyOnStop = FALSE;
24262
 
                if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
24263
 
                {
24264
 
                        pEchoChannel->ulSoutBufSkipPtr = ulSkipPtr;
24265
 
                        pEchoChannel->ulSoutBufWritePtr = ulWritePtr;
24266
 
                }
24267
 
                else /* if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE ) */
24268
 
                        pEchoChannel->ulSoutBufSkipPtr = pEchoChannel->ulSoutBufWritePtr;
24269
 
 
24270
 
                /* The repeat flag can now be used. */
24271
 
                pEchoChannel->fSoutBufPlayoutRepeatUsed = FALSE;
24272
 
 
24273
 
                /* For sure, all buffers have now been cleared on the Sout port. */
24274
 
                pEchoChannel->fSoutBufAdded = FALSE;
24275
 
 
24276
 
                /* Clear optimization flag if possible. */
24277
 
                if ( ( pEchoChannel->fRinBufPlaying == FALSE )
24278
 
                        && ( pEchoChannel->fRinBufPlayoutNotifyOnStop == FALSE ) )
24279
 
                {
24280
 
                        /* Buffer playout is no more active on this channel. */
24281
 
                        pEchoChannel->fBufPlayoutActive = FALSE;
24282
 
                }
24283
 
        }
24284
 
 
24285
 
        /*=======================================================================*/
24286
 
 
24287
 
 
24288
 
 
24289
 
        return cOCT6100_ERR_OK;
24290
 
}
24291
 
 
24292
 
 
24293
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24294
 
 
24295
 
File: oct6100_remote_debug.c
24296
 
 
24297
 
    Copyright (c) 2001-2005 Octasic Inc.
24298
 
    
24299
 
Description: 
24300
 
 
24301
 
        This file contains the routines used for remote debugging.
24302
 
 
24303
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
24304
 
free software; you can redistribute it and/or modify it under the terms of 
24305
 
the GNU General Public License as published by the Free Software Foundation; 
24306
 
either version 2 of the License, or (at your option) any later version.
24307
 
 
24308
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
24309
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
24310
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
24311
 
for more details. 
24312
 
 
24313
 
You should have received a copy of the GNU General Public License 
24314
 
along with the OCT6100 GPL API; if not, write to the Free Software 
24315
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24316
 
 
24317
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
24318
 
 
24319
 
$Octasic_Revision: 35 $
24320
 
 
24321
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
24322
 
 
24323
 
 
24324
 
/*****************************  INCLUDE FILES  *******************************/
24325
 
 
24326
 
#include "octdef.h"
24327
 
 
24328
 
#include "oct6100api/oct6100_defines.h"
24329
 
#include "oct6100api/oct6100_errors.h"
24330
 
 
24331
 
#include "apilib/octapi_bt0.h"
24332
 
#include "apilib/octapi_largmath.h"
24333
 
 
24334
 
#include "oct6100api/oct6100_apiud.h"
24335
 
#include "oct6100api/oct6100_tlv_inst.h"
24336
 
#include "oct6100api/oct6100_chip_open_inst.h"
24337
 
#include "oct6100api/oct6100_chip_stats_inst.h"
24338
 
#include "oct6100api/oct6100_interrupts_inst.h"
24339
 
#include "oct6100api/oct6100_channel_inst.h"
24340
 
#include "oct6100api/oct6100_remote_debug_inst.h"
24341
 
#include "oct6100api/oct6100_debug_inst.h"
24342
 
#include "oct6100api/oct6100_api_inst.h"
24343
 
 
24344
 
#include "oct6100api/oct6100_interrupts_pub.h"
24345
 
#include "oct6100api/oct6100_chip_open_pub.h"
24346
 
#include "oct6100api/oct6100_debug_pub.h"
24347
 
#include "oct6100api/oct6100_channel_pub.h"
24348
 
#include "oct6100api/oct6100_remote_debug_pub.h"
24349
 
 
24350
 
#include "octrpc/rpc_protocol.h"
24351
 
#include "octrpc/oct6100_rpc_protocol.h"
24352
 
 
24353
 
#include "oct6100_miscellaneous_priv.h"
24354
 
#include "oct6100_chip_open_priv.h"
24355
 
#include "oct6100_channel_priv.h"
24356
 
#include "oct6100_debug_priv.h"
24357
 
#include "oct6100_remote_debug_priv.h"
24358
 
 
24359
 
 
24360
 
/****************************  PRIVATE FUNCTIONS  ****************************/
24361
 
 
24362
 
 
24363
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24364
 
 
24365
 
Function:               Oct6100ApiGetRemoteDebugSwSizes
24366
 
 
24367
 
Description:    Gets the sizes of all portions of the API instance pertinent
24368
 
                                to the management of remote debugging.
24369
 
 
24370
 
-------------------------------------------------------------------------------
24371
 
|       Argument                |       Description
24372
 
-------------------------------------------------------------------------------
24373
 
f_pChipOpen                             Pointer to chip configuration struct.
24374
 
f_pInstSizes                    Pointer to struct containing instance sizes.
24375
 
 
24376
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
24377
 
static UINT32 Oct6100ApiGetRemoteDebugSwSizes(
24378
 
                                IN              tPOCT6100_CHIP_OPEN                             f_pChipOpen,
24379
 
                                OUT             tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
24380
 
{
24381
 
        UINT32  ulTempVar;
24382
 
        UINT32  ulResult;
24383
 
 
24384
 
        /* Memory needed for remote debugging sessions. */
24385
 
        if ( f_pChipOpen->ulMaxRemoteDebugSessions > 0 )
24386
 
        {
24387
 
                f_pInstSizes->ulRemoteDebugList = f_pChipOpen->ulMaxRemoteDebugSessions * sizeof( tOCT6100_API_REMOTE_DEBUG_SESSION );
24388
 
 
24389
 
                ulResult = octapi_bt0_get_size( f_pChipOpen->ulMaxRemoteDebugSessions, 4, 4, &f_pInstSizes->ulRemoteDebugTree );
24390
 
                if ( ulResult != cOCT6100_ERR_OK )
24391
 
                        return cOCT6100_ERR_FATAL_41;
24392
 
 
24393
 
                f_pInstSizes->ulRemoteDebugPktCache = cOCTRPC_MAX_PACKET_BYTE_LENGTH * f_pChipOpen->ulMaxRemoteDebugSessions;
24394
 
                f_pInstSizes->ulRemoteDebugDataBuf = cOCTRPC_MAX_PACKET_BYTE_LENGTH * 4;
24395
 
        }
24396
 
        else
24397
 
        {
24398
 
                f_pInstSizes->ulRemoteDebugList = 0;
24399
 
                f_pInstSizes->ulRemoteDebugTree = 0;
24400
 
                f_pInstSizes->ulRemoteDebugPktCache = 0;
24401
 
                f_pInstSizes->ulRemoteDebugDataBuf = 0;
24402
 
        }
24403
 
 
24404
 
        /* Round off the size. */
24405
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulRemoteDebugList, ulTempVar )
24406
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulRemoteDebugTree, ulTempVar )
24407
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulRemoteDebugPktCache, ulTempVar )
24408
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulRemoteDebugDataBuf, ulTempVar )
24409
 
 
24410
 
        return cOCT6100_ERR_OK;
24411
 
}
24412
 
 
24413
 
 
24414
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24415
 
 
24416
 
Function:               Oct6100ApiRemoteDebuggingSwInit
24417
 
 
24418
 
Description:    Initializes all portions of the API instance associated to
24419
 
                                remote debugging.
24420
 
 
24421
 
-------------------------------------------------------------------------------
24422
 
|       Argument                |       Description
24423
 
-------------------------------------------------------------------------------
24424
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
24425
 
                                                the present state of the chip and all its resources.
24426
 
 
24427
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
24428
 
static UINT32 Oct6100ApiRemoteDebuggingSwInit(
24429
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance )
24430
 
{
24431
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
24432
 
        PVOID   pSessionTree;
24433
 
        UINT32  ulResult;
24434
 
 
24435
 
        /* Get local pointer(s). */
24436
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
24437
 
 
24438
 
        pSharedInfo->RemoteDebugInfo.ulNumSessionsOpen = 0;
24439
 
        pSharedInfo->RemoteDebugInfo.ulMaxSessionsOpen = pSharedInfo->ChipConfig.usMaxRemoteDebugSessions;
24440
 
        pSharedInfo->RemoteDebugInfo.ulSessionListHead = cOCT6100_INVALID_VALUE;
24441
 
        pSharedInfo->RemoteDebugInfo.ulSessionListTail = cOCT6100_INVALID_VALUE;
24442
 
 
24443
 
        if ( pSharedInfo->ChipConfig.usMaxRemoteDebugSessions > 0 )
24444
 
        {
24445
 
                mOCT6100_GET_REMOTE_DEBUG_TREE_PNT( pSharedInfo, pSessionTree )
24446
 
        
24447
 
                ulResult = octapi_bt0_init( ( ( PVOID* )&pSessionTree ), pSharedInfo->ChipConfig.usMaxRemoteDebugSessions, 4, 4 );
24448
 
                if ( ulResult != cOCT6100_ERR_OK )
24449
 
                        return cOCT6100_ERR_FATAL_42;
24450
 
        }
24451
 
 
24452
 
        return cOCT6100_ERR_OK;
24453
 
}
24454
 
 
24455
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24456
 
 
24457
 
File: oct6100_tlv.c
24458
 
 
24459
 
    Copyright (c) 2001-2005 Octasic Inc.
24460
 
    
24461
 
Description: 
24462
 
 
24463
 
        This file contains the functions used to read information allowing the 
24464
 
        API to know where all the features supported by this API version are 
24465
 
        located in the chip's external memory.
24466
 
 
24467
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
24468
 
free software; you can redistribute it and/or modify it under the terms of 
24469
 
the GNU General Public License as published by the Free Software Foundation; 
24470
 
either version 2 of the License, or (at your option) any later version.
24471
 
 
24472
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
24473
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
24474
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
24475
 
for more details. 
24476
 
 
24477
 
You should have received a copy of the GNU General Public License 
24478
 
along with the OCT6100 GPL API; if not, write to the Free Software 
24479
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24480
 
 
24481
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
24482
 
 
24483
 
$Octasic_Revision: 109 $
24484
 
 
24485
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
24486
 
 
24487
 
 
24488
 
/*****************************  INCLUDE FILES  *******************************/
24489
 
 
24490
 
#include "octdef.h"
24491
 
 
24492
 
#include "oct6100api/oct6100_defines.h"
24493
 
#include "oct6100api/oct6100_errors.h"
24494
 
 
24495
 
#include "oct6100api/oct6100_apiud.h"
24496
 
#include "oct6100api/oct6100_tlv_inst.h"
24497
 
#include "oct6100api/oct6100_chip_open_inst.h"
24498
 
#include "oct6100api/oct6100_chip_stats_inst.h"
24499
 
#include "oct6100api/oct6100_interrupts_inst.h"
24500
 
#include "oct6100api/oct6100_remote_debug_inst.h"
24501
 
#include "oct6100api/oct6100_debug_inst.h"
24502
 
#include "oct6100api/oct6100_api_inst.h"
24503
 
 
24504
 
#include "oct6100api/oct6100_interrupts_pub.h"
24505
 
 
24506
 
#include "oct6100api/oct6100_channel_pub.h"
24507
 
#include "oct6100api/oct6100_chip_open_pub.h"
24508
 
 
24509
 
#include "oct6100_chip_open_priv.h"
24510
 
#include "oct6100_miscellaneous_priv.h"
24511
 
#include "oct6100_tlv_priv.h"
24512
 
 
24513
 
/****************************  PRIVATE FUNCTIONS  ****************************/
24514
 
 
24515
 
 
24516
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24517
 
 
24518
 
Function:               Oct6100ApiProcessTlvRegion
24519
 
 
24520
 
Description:    This function will read and interpret the TLV memory of the     chip
24521
 
                                to obtain memory offsets and features available of the image
24522
 
                                loaded into the chip.
24523
 
 
24524
 
                                The API will read this region until it finds a TLV type of 0 with 
24525
 
                                a length of 0.
24526
 
 
24527
 
-------------------------------------------------------------------------------
24528
 
|       Argument                |       Description
24529
 
-------------------------------------------------------------------------------
24530
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
24531
 
                                                the present state of the chip and all its resources.
24532
 
 
24533
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
24534
 
static UINT32 Oct6100ApiProcessTlvRegion(
24535
 
                                tPOCT6100_INSTANCE_API                  f_pApiInstance )
24536
 
{
24537
 
        tOCT6100_READ_PARAMS    ReadParams;
24538
 
        UINT16  usReadData;
24539
 
        UINT32  ulResult;
24540
 
 
24541
 
        UINT32  ulTlvTypeField;
24542
 
        UINT32  ulTlvLengthField;
24543
 
        UINT32  ulTlvWritingTimeoutCount = 0;
24544
 
        UINT32  ulConditionFlag = TRUE;
24545
 
 
24546
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
24547
 
 
24548
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
24549
 
        ReadParams.pusReadData = &usReadData;
24550
 
 
24551
 
        /* Set the address of the first TLV type. */
24552
 
        ReadParams.ulReadAddress  = cOCT6100_TLV_BASE;
24553
 
        ReadParams.ulReadAddress += 2;
24554
 
 
24555
 
        /* Wait for the TLV configuration to be configured in memory. */
24556
 
        while ( ulConditionFlag )
24557
 
        {
24558
 
                /* Read the TLV write done flag. */
24559
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24560
 
                if ( ulResult != cOCT6100_ERR_OK )
24561
 
                        return ulResult;
24562
 
 
24563
 
                if ( usReadData & 0x1 ) 
24564
 
                        break;
24565
 
 
24566
 
                ulTlvWritingTimeoutCount++;
24567
 
                if ( ulTlvWritingTimeoutCount == 0x100000 )
24568
 
                        return cOCT6100_ERR_TLV_TIMEOUT;
24569
 
        }
24570
 
 
24571
 
        /*======================================================================*/
24572
 
        /* Read the first 16 bits of the TLV type. */
24573
 
 
24574
 
        ReadParams.ulReadAddress += 2;
24575
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24576
 
        if ( ulResult != cOCT6100_ERR_OK )
24577
 
                return ulResult;
24578
 
        
24579
 
        /* Save data. */
24580
 
        ulTlvTypeField = usReadData << 16;
24581
 
 
24582
 
        /* Read the last word of the TLV type. */
24583
 
        ReadParams.ulReadAddress += 2;
24584
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24585
 
        if ( ulResult != cOCT6100_ERR_OK )
24586
 
                return ulResult;
24587
 
 
24588
 
        /* Save data. */
24589
 
        ulTlvTypeField |= usReadData;
24590
 
                
24591
 
        /*======================================================================*/
24592
 
        
24593
 
 
24594
 
        /*======================================================================*/
24595
 
        /* Now, read the TLV field length. */
24596
 
 
24597
 
        ReadParams.ulReadAddress += 2;
24598
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24599
 
        if ( ulResult != cOCT6100_ERR_OK )
24600
 
                return ulResult;
24601
 
        
24602
 
        /* Save data. */
24603
 
        ulTlvLengthField = usReadData << 16;
24604
 
 
24605
 
        /* Read the last word of the TLV length. */
24606
 
        ReadParams.ulReadAddress += 2;
24607
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24608
 
        if ( ulResult != cOCT6100_ERR_OK )
24609
 
                return ulResult;
24610
 
 
24611
 
        /* Save data. */
24612
 
        ulTlvLengthField |= usReadData;
24613
 
 
24614
 
        /* Modify the address to point at the TLV value field. */
24615
 
        ReadParams.ulReadAddress += 2;
24616
 
                
24617
 
        /*======================================================================*/
24618
 
 
24619
 
        /* Read the TLV value until the end of TLV region is reached. */
24620
 
        while( !((ulTlvTypeField == 0) && (ulTlvLengthField == 0)) )
24621
 
        {
24622
 
                ulResult = Oct6100ApiInterpretTlvEntry( f_pApiInstance, 
24623
 
                                                                                            ulTlvTypeField, 
24624
 
                                                                                    ulTlvLengthField,
24625
 
                                                                                                ReadParams.ulReadAddress );
24626
 
                if ( ulResult != cOCT6100_ERR_OK )
24627
 
                        return ulResult;
24628
 
 
24629
 
                /* Set the address to after the TLV value. */
24630
 
                ReadParams.ulReadAddress += ulTlvLengthField;
24631
 
 
24632
 
                /*======================================================================*/
24633
 
                /* Read the first 16 bits of the TLV type. */
24634
 
 
24635
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24636
 
                if ( ulResult != cOCT6100_ERR_OK )
24637
 
                        return ulResult;
24638
 
                
24639
 
                /* Save data. */
24640
 
                ulTlvTypeField = usReadData << 16;
24641
 
 
24642
 
                /* Read the last word of the TLV type. */
24643
 
                ReadParams.ulReadAddress += 2;
24644
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24645
 
                if ( ulResult != cOCT6100_ERR_OK )
24646
 
                        return ulResult;
24647
 
 
24648
 
                /* Save data. */
24649
 
                ulTlvTypeField |= usReadData;
24650
 
                        
24651
 
                /*======================================================================*/
24652
 
 
24653
 
                
24654
 
                /*======================================================================*/
24655
 
                /* Now, read the TLV field length. */
24656
 
 
24657
 
                ReadParams.ulReadAddress += 2;
24658
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24659
 
                if ( ulResult != cOCT6100_ERR_OK )
24660
 
                        return ulResult;
24661
 
                
24662
 
                /* Save data. */
24663
 
                ulTlvLengthField = usReadData << 16;
24664
 
 
24665
 
                /* Read the last word of the TLV length. */
24666
 
                ReadParams.ulReadAddress += 2;
24667
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24668
 
                if ( ulResult != cOCT6100_ERR_OK )
24669
 
                        return ulResult;
24670
 
 
24671
 
                /* Save data. */
24672
 
                ulTlvLengthField |= usReadData;
24673
 
 
24674
 
                ReadParams.ulReadAddress += 2;
24675
 
 
24676
 
                /*======================================================================*/
24677
 
        }
24678
 
 
24679
 
        return cOCT6100_ERR_OK;
24680
 
}
24681
 
 
24682
 
 
24683
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24684
 
 
24685
 
Function:               Oct6100ApiInterpretTlvEntry
24686
 
 
24687
 
Description:    This function will interpret a TLV entry from the chip.  All
24688
 
                                known TLV types by the API are exhaustively listed here.
24689
 
 
24690
 
-------------------------------------------------------------------------------
24691
 
|       Argument                |       Description
24692
 
-------------------------------------------------------------------------------
24693
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
24694
 
                                                the present state of the chip and all its resources.
24695
 
 
24696
 
f_ulTlvFieldType                Type of the TLV field to interpret.
24697
 
f_ulTlvFieldLength              Byte length of the TLV field.
24698
 
f_ulTlvValueAddress             Address where the data of the TLV block starts.
24699
 
 
24700
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
24701
 
static UINT32 Oct6100ApiInterpretTlvEntry(
24702
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
24703
 
                                IN              UINT32                                                  f_ulTlvFieldType,
24704
 
                                IN              UINT32                                                  f_ulTlvFieldLength,
24705
 
                                IN              UINT32                                                  f_ulTlvValueAddress )
24706
 
{
24707
 
        tOCT6100_READ_PARAMS    ReadParams;
24708
 
        UINT32  ulResult = cOCT6100_ERR_OK;
24709
 
        UINT16  usReadData;
24710
 
        UINT32  i;
24711
 
        UINT32  ulTempValue = 0;
24712
 
 
24713
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
24714
 
 
24715
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
24716
 
        ReadParams.pusReadData = &usReadData;
24717
 
 
24718
 
        /* Find out how to interpret the TLV value according to the TLV type. */
24719
 
        switch( f_ulTlvFieldType )
24720
 
        {
24721
 
        case cOCT6100_TLV_TYPE_VERSION_NUMBER:
24722
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24723
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_VERSION_NUMBER, 
24724
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_VERSION_NUMBER );
24725
 
                if ( ulResult == cOCT6100_ERR_OK )
24726
 
                {
24727
 
                        ReadParams.ulReadAddress = f_ulTlvValueAddress;
24728
 
 
24729
 
                        for( i = 0; i < (f_ulTlvFieldLength/2); i++ )
24730
 
                        {
24731
 
                                /* Perform the actual read. */
24732
 
                                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24733
 
                                if ( ulResult != cOCT6100_ERR_OK )
24734
 
                                        return ulResult;
24735
 
 
24736
 
                                f_pApiInstance->pSharedInfo->ImageInfo.szVersionNumber[ (i * 2) ] = (UINT8)((usReadData >> 8) & 0xFF);
24737
 
                                f_pApiInstance->pSharedInfo->ImageInfo.szVersionNumber[ (i * 2) + 1 ] = (UINT8)((usReadData >> 0) & 0xFF);
24738
 
 
24739
 
                                /* Modify the address. */
24740
 
                                ReadParams.ulReadAddress += 2;
24741
 
                        }
24742
 
                }
24743
 
                break;
24744
 
 
24745
 
        case cOCT6100_TLV_TYPE_CUSTOMER_PROJECT_ID:
24746
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24747
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CUSTOMER_PROJECT_ID, 
24748
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CUSTOMER_PROJECT_ID );
24749
 
                if ( ulResult == cOCT6100_ERR_OK )
24750
 
                {
24751
 
                        /* Perform the actual read. */
24752
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24753
 
                                                                                           f_ulTlvValueAddress, 
24754
 
                                                                                           &f_pApiInstance->pSharedInfo->ImageInfo.ulBuildId );
24755
 
                        if ( ulResult != cOCT6100_ERR_OK )
24756
 
                                return ulResult;
24757
 
                }
24758
 
                break;
24759
 
 
24760
 
        case cOCT6100_TLV_TYPE_CH0_MAIN_BASE_ADDRESS:
24761
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24762
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CH0_MAIN_BASE_ADDRESS, 
24763
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CH0_MAIN_BASE_ADDRESS );
24764
 
                if ( ulResult == cOCT6100_ERR_OK )
24765
 
                {
24766
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24767
 
                                                                                           f_ulTlvValueAddress, 
24768
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase );
24769
 
                        if ( ulResult != cOCT6100_ERR_OK )
24770
 
                                return ulResult;
24771
 
 
24772
 
                        f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase &= 0x0FFFFFFF;                 
24773
 
 
24774
 
                        /* Modify the base address to incorporate the external memory offset. */
24775
 
                        f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase += cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
24776
 
                }
24777
 
                break;
24778
 
 
24779
 
        case cOCT6100_TLV_TYPE_CH_MAIN_SIZE:
24780
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24781
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CH_MAIN_SIZE, 
24782
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CH_MAIN_SIZE );
24783
 
                if ( ulResult == cOCT6100_ERR_OK )
24784
 
                {
24785
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24786
 
                                                                                           f_ulTlvValueAddress, 
24787
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
24788
 
                        if ( ulResult != cOCT6100_ERR_OK )
24789
 
                                return ulResult;
24790
 
                }
24791
 
                break;
24792
 
 
24793
 
        case cOCT6100_TLV_TYPE_CH_MAIN_IO_OFFSET:
24794
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24795
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CH_MAIN_IO_OFFSET, 
24796
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CH_MAIN_IO_OFFSET );
24797
 
                if ( ulResult == cOCT6100_ERR_OK )
24798
 
                {
24799
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24800
 
                                                                                           f_ulTlvValueAddress, 
24801
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst );
24802
 
                        if ( ulResult != cOCT6100_ERR_OK )
24803
 
                                return ulResult;
24804
 
                }
24805
 
                break;
24806
 
 
24807
 
        case cOCT6100_TLV_TYPE_CH_MAIN_ZCB_OFFSET:
24808
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24809
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CH_MAIN_ZCB_OFFSET, 
24810
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CH_MAIN_ZCB_OFFSET );
24811
 
                if ( ulResult == cOCT6100_ERR_OK )
24812
 
                {
24813
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24814
 
                                                                                           f_ulTlvValueAddress, 
24815
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst );
24816
 
                        if ( ulResult != cOCT6100_ERR_OK )
24817
 
                                return ulResult;
24818
 
                }
24819
 
                break;
24820
 
 
24821
 
        case cOCT6100_TLV_TYPE_CH_MAIN_ZCB_SIZE:
24822
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24823
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CH_MAIN_ZCB_SIZE, 
24824
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CH_MAIN_ZCB_SIZE );
24825
 
                if ( ulResult == cOCT6100_ERR_OK )
24826
 
                {
24827
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24828
 
                                                                                           f_ulTlvValueAddress, 
24829
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinCBMemSize );
24830
 
                        if ( ulResult != cOCT6100_ERR_OK )
24831
 
                                return ulResult;
24832
 
                }
24833
 
                break;
24834
 
 
24835
 
        case cOCT6100_TLV_TYPE_CH_MAIN_XCB_OFFSET:
24836
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24837
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CH_MAIN_XCB_OFFSET, 
24838
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CH_MAIN_XCB_OFFSET );
24839
 
                if ( ulResult == cOCT6100_ERR_OK )
24840
 
                {
24841
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24842
 
                                                                                           f_ulTlvValueAddress, 
24843
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst );
24844
 
                        if ( ulResult != cOCT6100_ERR_OK )
24845
 
                                return ulResult;
24846
 
                }
24847
 
                break;
24848
 
 
24849
 
        case cOCT6100_TLV_TYPE_CH_MAIN_XCB_SIZE:
24850
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24851
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CH_MAIN_XCB_SIZE, 
24852
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CH_MAIN_XCB_SIZE );
24853
 
                if ( ulResult == cOCT6100_ERR_OK )
24854
 
                {
24855
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24856
 
                                                                                           f_ulTlvValueAddress, 
24857
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSinCBMemSize );
24858
 
                        if ( ulResult != cOCT6100_ERR_OK )
24859
 
                                return ulResult;
24860
 
                }
24861
 
                break;
24862
 
 
24863
 
        case cOCT6100_TLV_TYPE_CH_MAIN_YCB_OFFSET:
24864
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24865
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CH_MAIN_YCB_OFFSET, 
24866
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CH_MAIN_YCB_OFFSET );
24867
 
                if ( ulResult == cOCT6100_ERR_OK )
24868
 
                {
24869
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24870
 
                                                                                           f_ulTlvValueAddress, 
24871
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst );
24872
 
                        if ( ulResult != cOCT6100_ERR_OK )
24873
 
                                return ulResult;
24874
 
                }
24875
 
                break;
24876
 
 
24877
 
        case cOCT6100_TLV_TYPE_CH_MAIN_YCB_SIZE:
24878
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24879
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CH_MAIN_YCB_SIZE, 
24880
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CH_MAIN_YCB_SIZE );
24881
 
                if ( ulResult == cOCT6100_ERR_OK )
24882
 
                {
24883
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24884
 
                                                                                           f_ulTlvValueAddress, 
24885
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutCBMemSize );
24886
 
                        if ( ulResult != cOCT6100_ERR_OK )
24887
 
                                return ulResult;
24888
 
                }
24889
 
                break;
24890
 
 
24891
 
        case cOCT6100_TLV_TYPE_FREE_MEM_BASE_ADDRESS:
24892
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24893
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_FREE_MEM_BASE_ADDRESS, 
24894
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_FREE_MEM_BASE_ADDRESS );
24895
 
                if ( ulResult == cOCT6100_ERR_OK )
24896
 
                {
24897
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24898
 
                                                                                           f_ulTlvValueAddress, 
24899
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulFreeMemBaseAddress );
24900
 
                        if ( ulResult != cOCT6100_ERR_OK )
24901
 
                                return ulResult;
24902
 
 
24903
 
                        f_pApiInstance->pSharedInfo->MemoryMap.ulFreeMemBaseAddress &= 0x0FFFFFFF;
24904
 
 
24905
 
                }
24906
 
                break;
24907
 
 
24908
 
        case cOCT6100_TLV_TYPE_CHAN_MAIN_IO_STATS_OFFSET:
24909
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24910
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CHAN_MAIN_IO_STATS_OFFSET, 
24911
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CHAN_MAIN_IO_STATS_OFFSET );
24912
 
                if ( ulResult == cOCT6100_ERR_OK )
24913
 
                {
24914
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24915
 
                                                                                           f_ulTlvValueAddress, 
24916
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsOfst );
24917
 
                        if ( ulResult != cOCT6100_ERR_OK )
24918
 
                                return ulResult;
24919
 
                }
24920
 
                break;
24921
 
 
24922
 
        case cOCT6100_TLV_TYPE_CHAN_MAIN_IO_STATS_SIZE:
24923
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24924
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CHAN_MAIN_IO_STATS_OFFSET, 
24925
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CHAN_MAIN_IO_STATS_OFFSET );
24926
 
                if ( ulResult == cOCT6100_ERR_OK )
24927
 
                {
24928
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24929
 
                                                                                           f_ulTlvValueAddress, 
24930
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsSize );
24931
 
                        if ( ulResult != cOCT6100_ERR_OK )
24932
 
                                return ulResult;
24933
 
                }
24934
 
                break;
24935
 
 
24936
 
        case cOCT6100_TLV_TYPE_CH_ROOT_CONF_OFFSET:
24937
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24938
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CH_ROOT_CONF_OFFSET, 
24939
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CH_ROOT_CONF_OFFSET );
24940
 
                if ( ulResult == cOCT6100_ERR_OK )
24941
 
                {
24942
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24943
 
                                                                                           f_ulTlvValueAddress, 
24944
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanRootConfOfst );
24945
 
                        if ( ulResult != cOCT6100_ERR_OK )
24946
 
                                return ulResult;
24947
 
                }
24948
 
                break;
24949
 
 
24950
 
        
24951
 
        case cOCT6100_TLV_TYPE_POA_CH_MAIN_ZPO_OFFSET:
24952
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24953
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_ZPO_OFFSET, 
24954
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_ZPO_OFFSET );
24955
 
                if ( ulResult == cOCT6100_ERR_OK )
24956
 
                {
24957
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24958
 
                                                                                           f_ulTlvValueAddress, 
24959
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst );
24960
 
                        if ( ulResult != cOCT6100_ERR_OK )
24961
 
                                return ulResult;
24962
 
                }
24963
 
                break;
24964
 
 
24965
 
        case cOCT6100_TLV_TYPE_POA_CH_MAIN_ZPO_SIZE:
24966
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24967
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_ZPO_SIZE, 
24968
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_ZPO_SIZE );
24969
 
                if ( ulResult == cOCT6100_ERR_OK )
24970
 
                {
24971
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24972
 
                                                                                           f_ulTlvValueAddress, 
24973
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemSize );
24974
 
                        if ( ulResult != cOCT6100_ERR_OK )
24975
 
                                return ulResult;
24976
 
                }
24977
 
                break;
24978
 
 
24979
 
        case cOCT6100_TLV_TYPE_POA_CH_MAIN_YPO_OFFSET:
24980
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24981
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_YPO_OFFSET, 
24982
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_YPO_OFFSET );
24983
 
                if ( ulResult == cOCT6100_ERR_OK )
24984
 
                {
24985
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24986
 
                                                                                           f_ulTlvValueAddress, 
24987
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst );
24988
 
                }
24989
 
                break;
24990
 
 
24991
 
        case cOCT6100_TLV_TYPE_POA_CH_MAIN_YPO_SIZE:
24992
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
24993
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_CH_MAIN_YPO_SIZE, 
24994
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_CH_MAIN_YPO_SIZE );
24995
 
                if ( ulResult == cOCT6100_ERR_OK )
24996
 
                {
24997
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
24998
 
                                                                                           f_ulTlvValueAddress, 
24999
 
                                                                                           &f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemSize );
25000
 
                }
25001
 
                break;
25002
 
 
25003
 
        case cOCT6100_TLV_TYPE_POA_BOFF_RW_ZWP:
25004
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25005
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_ZWP, 
25006
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_ZWP );
25007
 
                if ( ulResult == cOCT6100_ERR_OK )
25008
 
                {
25009
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25010
 
                                                                                                                 f_ulTlvValueAddress, 
25011
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst );
25012
 
                }
25013
 
                break;
25014
 
 
25015
 
        case cOCT6100_TLV_TYPE_POA_BOFF_RW_ZIS:
25016
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25017
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_ZIS, 
25018
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_ZIS );
25019
 
                if ( ulResult == cOCT6100_ERR_OK )
25020
 
                {
25021
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25022
 
                                                                                                                 f_ulTlvValueAddress, 
25023
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst );
25024
 
                }
25025
 
                break;
25026
 
 
25027
 
        case cOCT6100_TLV_TYPE_POA_BOFF_RW_ZSP:
25028
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25029
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_ZSP, 
25030
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_ZSP );
25031
 
                if ( ulResult == cOCT6100_ERR_OK )
25032
 
                {
25033
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25034
 
                                                                                                                 f_ulTlvValueAddress, 
25035
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst );
25036
 
                }
25037
 
                break;
25038
 
 
25039
 
        case cOCT6100_TLV_TYPE_POA_BOFF_RW_YWP:
25040
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25041
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_YWP, 
25042
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_YWP );
25043
 
                if ( ulResult == cOCT6100_ERR_OK )
25044
 
                {
25045
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25046
 
                                                                                                                 f_ulTlvValueAddress, 
25047
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst );
25048
 
                }
25049
 
                break;
25050
 
 
25051
 
        case cOCT6100_TLV_TYPE_POA_BOFF_RW_YIS:
25052
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25053
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_YIS, 
25054
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_YIS );
25055
 
                if ( ulResult == cOCT6100_ERR_OK )
25056
 
                {
25057
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25058
 
                                                                                                                 f_ulTlvValueAddress, 
25059
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst );
25060
 
                }
25061
 
                break;
25062
 
 
25063
 
        case cOCT6100_TLV_TYPE_POA_BOFF_RW_YSP:
25064
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25065
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RW_YSP, 
25066
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RW_YSP );
25067
 
                if ( ulResult == cOCT6100_ERR_OK )
25068
 
                {
25069
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25070
 
                                                                                                                 f_ulTlvValueAddress, 
25071
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst );
25072
 
                }
25073
 
                break;
25074
 
 
25075
 
        case cOCT6100_TLV_TYPE_POA_BOFF_RO_ZRP:
25076
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25077
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RO_ZRP, 
25078
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RO_ZRP );
25079
 
                if ( ulResult == cOCT6100_ERR_OK )
25080
 
                {
25081
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25082
 
                                                                                                                 f_ulTlvValueAddress, 
25083
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst );
25084
 
                }
25085
 
                break;
25086
 
 
25087
 
        case cOCT6100_TLV_TYPE_POA_BOFF_RO_YRP:
25088
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25089
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POA_BOFF_RO_YRP, 
25090
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POA_BOFF_RO_YRP );
25091
 
                if ( ulResult == cOCT6100_ERR_OK )
25092
 
                {
25093
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25094
 
                                                                                                                 f_ulTlvValueAddress, 
25095
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst );
25096
 
                }
25097
 
                break;
25098
 
 
25099
 
        case cOCT6100_TLV_TYPE_CNR_CONF_BOFF_RW_ENABLE:
25100
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25101
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CNR_CONF_BOFF_RW_ENABLE, 
25102
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CNR_CONF_BOFF_RW_ENABLE );
25103
 
                if ( ulResult == cOCT6100_ERR_OK )
25104
 
                {
25105
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25106
 
                                                                                                                 f_ulTlvValueAddress, 
25107
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst );
25108
 
                }
25109
 
                break;
25110
 
 
25111
 
        case cOCT6100_TLV_TYPE_ANR_CONF_BOFF_RW_ENABLE:
25112
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25113
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_ANR_CONF_BOFF_RW_ENABLE, 
25114
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_ANR_CONF_BOFF_RW_ENABLE );
25115
 
                if ( ulResult == cOCT6100_ERR_OK )
25116
 
                {
25117
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25118
 
                                                                                                                 f_ulTlvValueAddress, 
25119
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst );
25120
 
                }
25121
 
                break;
25122
 
 
25123
 
        case cOCT6100_TLV_TYPE_HZ_CONF_BOFF_RW_ENABLE:
25124
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25125
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_HZ_CONF_BOFF_RW_ENABLE, 
25126
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_HZ_CONF_BOFF_RW_ENABLE );
25127
 
                if ( ulResult == cOCT6100_ERR_OK )
25128
 
                {
25129
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25130
 
                                                                                                                 f_ulTlvValueAddress, 
25131
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst );
25132
 
                }
25133
 
                /* Set flag indicating that the feature is present.*/
25134
 
                f_pApiInstance->pSharedInfo->ImageInfo.fRinDcOffsetRemoval = TRUE;
25135
 
                break;
25136
 
 
25137
 
        case cOCT6100_TLV_TYPE_HX_CONF_BOFF_RW_ENABLE:
25138
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25139
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_HX_CONF_BOFF_RW_ENABLE, 
25140
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_HX_CONF_BOFF_RW_ENABLE );
25141
 
                if ( ulResult == cOCT6100_ERR_OK )
25142
 
                {
25143
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25144
 
                                                                                                                 f_ulTlvValueAddress, 
25145
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst );
25146
 
                }
25147
 
                /* Set flag indicating that the feature is present.*/
25148
 
                f_pApiInstance->pSharedInfo->ImageInfo.fSinDcOffsetRemoval = TRUE;
25149
 
                break;
25150
 
 
25151
 
        case cOCT6100_TLV_TYPE_LCA_Z_CONF_BOFF_RW_GAIN:
25152
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25153
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_LCA_Z_CONF_BOFF_RW_GAIN, 
25154
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_LCA_Z_CONF_BOFF_RW_GAIN );
25155
 
                if ( ulResult == cOCT6100_ERR_OK )
25156
 
                {
25157
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25158
 
                                                                                                                 f_ulTlvValueAddress, 
25159
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.RinLevelControlOfst );
25160
 
                }
25161
 
                break;
25162
 
 
25163
 
        case cOCT6100_TLV_TYPE_LCA_Y_CONF_BOFF_RW_GAIN:
25164
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25165
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_LCA_Y_CONF_BOFF_RW_GAIN, 
25166
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_LCA_Y_CONF_BOFF_RW_GAIN );
25167
 
                if ( ulResult == cOCT6100_ERR_OK )
25168
 
                {
25169
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25170
 
                                                                                                                 f_ulTlvValueAddress, 
25171
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.SoutLevelControlOfst );
25172
 
                }
25173
 
                break;
25174
 
 
25175
 
        case cOCT6100_TLV_TYPE_CNA_CONF_BOFF_RW_ENABLE:
25176
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25177
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CNA_CONF_BOFF_RW_ENABLE, 
25178
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CNA_CONF_BOFF_RW_ENABLE );
25179
 
                if ( ulResult == cOCT6100_ERR_OK )
25180
 
                {
25181
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25182
 
                                                                                                                 f_ulTlvValueAddress, 
25183
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.ComfortNoiseModeOfst );
25184
 
                }
25185
 
                /* Set flag indicating that the feature is present.*/
25186
 
                f_pApiInstance->pSharedInfo->ImageInfo.fComfortNoise = TRUE;
25187
 
                break;
25188
 
 
25189
 
        case cOCT6100_TLV_TYPE_NOA_CONF_BOFF_RW_ENABLE:
25190
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25191
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_NOA_CONF_BOFF_RW_ENABLE, 
25192
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_NOA_CONF_BOFF_RW_ENABLE );
25193
 
                if ( ulResult == cOCT6100_ERR_OK )
25194
 
                {
25195
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25196
 
                                                                                                                 f_ulTlvValueAddress, 
25197
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.NlpControlFieldOfst );
25198
 
                }
25199
 
                /* Set flag indicating that the feature is present.*/
25200
 
                f_pApiInstance->pSharedInfo->ImageInfo.fNlpControl = TRUE;
25201
 
                break;
25202
 
 
25203
 
        case cOCT6100_TLV_TYPE_VFA_CONF_BOFF_RW_ENABLE:
25204
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25205
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_VFA_CONF_BOFF_RW_ENABLE, 
25206
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_VFA_CONF_BOFF_RW_ENABLE );
25207
 
                if ( ulResult == cOCT6100_ERR_OK )
25208
 
                {
25209
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25210
 
                                                                                                                 f_ulTlvValueAddress, 
25211
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.VadControlFieldOfst );
25212
 
                }
25213
 
                /* Set flag indicating that the feature is present.*/
25214
 
                f_pApiInstance->pSharedInfo->ImageInfo.fSilenceSuppression = TRUE;
25215
 
                break;
25216
 
 
25217
 
        case cOCT6100_TLV_TYPE_TLA_MAIN_IO_BOFF_RW_TAIL_DISP:
25218
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25219
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_TLA_MAIN_IO_BOFF_RW_TAIL_DISP, 
25220
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_TLA_MAIN_IO_BOFF_RW_TAIL_DISP );
25221
 
                if ( ulResult == cOCT6100_ERR_OK )
25222
 
                {
25223
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25224
 
                                                                                                                 f_ulTlvValueAddress, 
25225
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PouchTailDisplOfst );
25226
 
                }
25227
 
                break;
25228
 
 
25229
 
        case cOCT6100_TLV_TYPE_BOOTA_POUCH_BOFF_RW_BOOT_INST:
25230
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25231
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_INST, 
25232
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_INST );
25233
 
                if ( ulResult == cOCT6100_ERR_OK )
25234
 
                {
25235
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25236
 
                                                                                                                 f_ulTlvValueAddress, 
25237
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PouchBootInstructionOfst );
25238
 
                }
25239
 
                break;
25240
 
 
25241
 
        case cOCT6100_TLV_TYPE_BOOTA_POUCH_BOFF_RW_BOOT_RESULT:
25242
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25243
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_RESULT, 
25244
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_BOOTA_POUCH_BOFF_RW_BOOT_RESULT );
25245
 
                if ( ulResult == cOCT6100_ERR_OK )
25246
 
                {
25247
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25248
 
                                                                                                                 f_ulTlvValueAddress, 
25249
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PouchBootResultOfst );
25250
 
                }
25251
 
                break;
25252
 
 
25253
 
        case cOCT6100_TLV_TYPE_TDM_CONF_BOFF_RW_ENABLE:
25254
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25255
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_TDM_CONF_BOFF_RW_ENABLE, 
25256
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_TDM_CONF_BOFF_RW_ENABLE );
25257
 
                if ( ulResult == cOCT6100_ERR_OK )
25258
 
                {
25259
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25260
 
                                                                                                                 f_ulTlvValueAddress, 
25261
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.ToneDisablerControlOfst );
25262
 
                }
25263
 
 
25264
 
                f_pApiInstance->pSharedInfo->ImageInfo.fToneDisabler = TRUE;
25265
 
                break;
25266
 
        
25267
 
        case cOCT6100_TLV_TYPE_DIS_CONF_BOFF_RW_ENABLE:
25268
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25269
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_DIS_CONF_BOFF_RW_ENABLE, 
25270
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_DIS_CONF_BOFF_RW_ENABLE );
25271
 
                if ( ulResult == cOCT6100_ERR_OK )
25272
 
                {
25273
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25274
 
                                                                                                                 f_ulTlvValueAddress, 
25275
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.TailDisplEnableOfst );
25276
 
                }
25277
 
 
25278
 
                f_pApiInstance->pSharedInfo->ImageInfo.fTailDisplacement = TRUE;
25279
 
                break;
25280
 
        
25281
 
        case cOCT6100_TLV_TYPE_NT_CONF_BOFF_RW_ENABLE:
25282
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25283
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_NT_CONF_BOFF_RW_ENABLE, 
25284
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_NT_CONF_BOFF_RW_ENABLE );
25285
 
                if ( ulResult == cOCT6100_ERR_OK )
25286
 
                {
25287
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25288
 
                                                                                                                 f_ulTlvValueAddress, 
25289
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.NlpTrivialFieldOfst );
25290
 
                }
25291
 
 
25292
 
                break;
25293
 
 
25294
 
        case cOCT6100_TLV_TYPE_DEBUG_CHAN_INDEX_VALUE:
25295
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25296
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_DEBUG_CHAN_INDEX_VALUE, 
25297
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_DEBUG_CHAN_INDEX_VALUE );
25298
 
                if ( ulResult == cOCT6100_ERR_OK )
25299
 
                {
25300
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25301
 
                                                                                        f_ulTlvValueAddress, 
25302
 
                                                                                        &ulTempValue );
25303
 
                }
25304
 
 
25305
 
                f_pApiInstance->pSharedInfo->DebugInfo.usRecordMemIndex = (UINT16)( ulTempValue & 0xFFFF );
25306
 
 
25307
 
                break;
25308
 
 
25309
 
        case cOCT6100_TLV_TYPE_ADPCM_ENABLE:
25310
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25311
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_ADPCM_ENABLE, 
25312
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_ADPCM_ENABLE );
25313
 
                if ( ulResult == cOCT6100_ERR_OK )
25314
 
                {
25315
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25316
 
                                                                                        f_ulTlvValueAddress, 
25317
 
                                                                                        &ulTempValue );
25318
 
                }
25319
 
 
25320
 
                if ( ulTempValue == 0 )
25321
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm = FALSE;
25322
 
                else
25323
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm = TRUE;
25324
 
                
25325
 
                break;
25326
 
 
25327
 
        case cOCT6100_TLV_TYPE_CONFERENCING_ENABLE:
25328
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25329
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CONFERENCING_ENABLE, 
25330
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CONFERENCING_ENABLE );
25331
 
                if ( ulResult == cOCT6100_ERR_OK )
25332
 
                {
25333
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25334
 
                                                                                        f_ulTlvValueAddress, 
25335
 
                                                                                        &ulTempValue );
25336
 
                }
25337
 
 
25338
 
                if ( ulTempValue == 0 )
25339
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fConferencing = FALSE;
25340
 
                else
25341
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fConferencing = TRUE;
25342
 
                
25343
 
                break;
25344
 
 
25345
 
        case cOCT6100_TLV_TYPE_TONE_DETECTOR_PROFILE:
25346
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25347
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_TONE_DETECTOR_PROFILE, 
25348
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_TONE_DETECTOR_PROFILE );
25349
 
                if ( ulResult == cOCT6100_ERR_OK )
25350
 
                {
25351
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25352
 
                                                                                        f_ulTlvValueAddress, 
25353
 
                                                                                        &f_pApiInstance->pSharedInfo->ImageInfo.ulToneProfileNumber );
25354
 
                }
25355
 
 
25356
 
                break;
25357
 
 
25358
 
        case cOCT6100_TLV_TYPE_MAX_TAIL_DISPLACEMENT:
25359
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25360
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_MAX_TAIL_DISPLACEMENT, 
25361
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_MAX_TAIL_DISPLACEMENT );
25362
 
                if ( ulResult == cOCT6100_ERR_OK )
25363
 
                {
25364
 
                        UINT32  ulTailDispTempValue = 0;
25365
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25366
 
                                                                                        f_ulTlvValueAddress, 
25367
 
                                                                                        &ulTailDispTempValue );
25368
 
 
25369
 
                        ulTailDispTempValue += 1;               /* Convert the value into milliseconds.*/
25370
 
                        ulTailDispTempValue *= 16;              /* value was given in multiple of 16 ms. */
25371
 
 
25372
 
                        if ( ulTailDispTempValue >= 128 )
25373
 
                                f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailDisplacement = (UINT16)( ulTailDispTempValue - 128 );
25374
 
                        else
25375
 
                                f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailDisplacement = 0;
25376
 
 
25377
 
                }       
25378
 
 
25379
 
                break;
25380
 
 
25381
 
        case cOCT6100_TLV_TYPE_AEC_CONF_BOFF_RW_ENABLE:
25382
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25383
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_AEC_CONF_BOFF_RW_ENABLE, 
25384
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_AEC_CONF_BOFF_RW_ENABLE );
25385
 
                if ( ulResult == cOCT6100_ERR_OK )
25386
 
                {
25387
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25388
 
                                                                                                                 f_ulTlvValueAddress, 
25389
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.AecFieldOfst );
25390
 
                }
25391
 
        
25392
 
                /* Set the flag. */
25393
 
                f_pApiInstance->pSharedInfo->ImageInfo.fAecEnabled = TRUE;
25394
 
 
25395
 
                /* Acoustic echo cancellation available! */
25396
 
                f_pApiInstance->pSharedInfo->ImageInfo.fAcousticEcho = TRUE;
25397
 
 
25398
 
                break;
25399
 
 
25400
 
        case cOCT6100_TLV_TYPE_PCM_LEAK_CONF_BOFF_RW:
25401
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25402
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_PCM_LEAK_CONF_BOFF_RW, 
25403
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_PCM_LEAK_CONF_BOFF_RW );
25404
 
                if ( ulResult == cOCT6100_ERR_OK )
25405
 
                {
25406
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25407
 
                                                                                                                 f_ulTlvValueAddress, 
25408
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PcmLeakFieldOfst );
25409
 
                }
25410
 
 
25411
 
                f_pApiInstance->pSharedInfo->ImageInfo.fNonLinearityBehaviorA = TRUE;
25412
 
                break;
25413
 
 
25414
 
        case cOCT6100_TLV_TYPE_DEFAULT_ERL_CONF_BOFF_RW:
25415
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25416
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_DEFAULT_ERL_CONF_BOFF_RW, 
25417
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_DEFAULT_ERL_CONF_BOFF_RW );
25418
 
                if ( ulResult == cOCT6100_ERR_OK )
25419
 
                {
25420
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25421
 
                                                                                                                 f_ulTlvValueAddress, 
25422
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.DefaultErlFieldOfst );
25423
 
                }
25424
 
        
25425
 
                /* Set the flag. */
25426
 
                f_pApiInstance->pSharedInfo->ImageInfo.fDefaultErl = TRUE;
25427
 
 
25428
 
                break;
25429
 
 
25430
 
        case cOCT6100_TLV_TYPE_TONE_REM_CONF_BOFF_RW_ENABLE:
25431
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25432
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_TONE_REM_CONF_BOFF_RW_ENABLE, 
25433
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_TONE_REM_CONF_BOFF_RW_ENABLE );
25434
 
                if ( ulResult == cOCT6100_ERR_OK )
25435
 
                {
25436
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25437
 
                                                                                                                 f_ulTlvValueAddress, 
25438
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.ToneRemovalFieldOfst );
25439
 
                }
25440
 
        
25441
 
                /* Set the flag. */
25442
 
                f_pApiInstance->pSharedInfo->ImageInfo.fToneRemoval = TRUE;
25443
 
 
25444
 
                break;
25445
 
 
25446
 
 
25447
 
 
25448
 
        case cOCT6100_TLV_TYPE_TLA_MAIN_IO_BOFF_RW_MAX_ECHO_POINT:
25449
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25450
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_TLA_MAIN_IO_BOFF_RW_MAX_ECHO_POINT, 
25451
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_TLA_MAIN_IO_BOFF_RW_MAX_ECHO_POINT );
25452
 
                if ( ulResult == cOCT6100_ERR_OK )
25453
 
                {
25454
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25455
 
                                                                                                                 f_ulTlvValueAddress, 
25456
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst );
25457
 
                }
25458
 
        
25459
 
                /* Set the flag. */
25460
 
                f_pApiInstance->pSharedInfo->ImageInfo.fMaxEchoPoint = TRUE;
25461
 
 
25462
 
                break;
25463
 
 
25464
 
        case cOCT6100_TLV_TYPE_NLP_CONV_CAP_CONF_BOFF_RW:
25465
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25466
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_NLP_CONV_CAP_CONF_BOFF_RW, 
25467
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_NLP_CONV_CAP_CONF_BOFF_RW );
25468
 
                if ( ulResult == cOCT6100_ERR_OK )
25469
 
                {
25470
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25471
 
                                                                                                                 f_ulTlvValueAddress, 
25472
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.NlpConvCapFieldOfst );
25473
 
                }
25474
 
        
25475
 
                /* Set the flag. */
25476
 
                f_pApiInstance->pSharedInfo->ImageInfo.fNonLinearityBehaviorB = TRUE;
25477
 
 
25478
 
                break;
25479
 
 
25480
 
        case cOCT6100_TLV_TYPE_MATRIX_EVENT_SIZE:
25481
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25482
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_MATRIX_EVENT_SIZE, 
25483
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_MATRIX_EVENT_SIZE );
25484
 
                if ( ulResult == cOCT6100_ERR_OK )
25485
 
                {
25486
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25487
 
                                                                                        f_ulTlvValueAddress, 
25488
 
                                                                                        &f_pApiInstance->pSharedInfo->DebugInfo.ulDebugEventSize );
25489
 
                }
25490
 
 
25491
 
                break;
25492
 
 
25493
 
        case cOCT6100_TLV_TYPE_CNR_RW_ENABLE:
25494
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25495
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CNR_RW_ENABLE, 
25496
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CNR_RW_ENABLE );
25497
 
                if ( ulResult == cOCT6100_ERR_OK )
25498
 
                {
25499
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25500
 
                                                                                        f_ulTlvValueAddress, 
25501
 
                                                                                        &ulTempValue );
25502
 
 
25503
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fConferencingNoiseReduction = (UINT8)( ulTempValue & 0xFF );
25504
 
 
25505
 
                        if ( f_pApiInstance->pSharedInfo->ImageInfo.fConferencingNoiseReduction == TRUE )
25506
 
                        {
25507
 
                                /* Set flag indicating that the dominant speaker feature is present. */
25508
 
                                f_pApiInstance->pSharedInfo->ImageInfo.fDominantSpeakerEnabled = TRUE;
25509
 
                        }
25510
 
                }
25511
 
 
25512
 
                break;
25513
 
 
25514
 
        case cOCT6100_TLV_TYPE_MAX_TAIL_LENGTH_RW_ENABLE:
25515
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25516
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_MAX_TAIL_LENGTH_RW_ENABLE, 
25517
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_MAX_TAIL_LENGTH_RW_ENABLE );
25518
 
                if ( ulResult == cOCT6100_ERR_OK )
25519
 
                {
25520
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25521
 
                                                                                        f_ulTlvValueAddress, 
25522
 
                                                                                        &ulTempValue );
25523
 
 
25524
 
                        f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength = (UINT16)( ulTempValue & 0xFFFF );
25525
 
                }
25526
 
 
25527
 
                break;
25528
 
                
25529
 
        case cOCT6100_TLV_TYPE_MAX_NUMBER_OF_CHANNELS:
25530
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25531
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_MAX_NUMBER_OF_CHANNELS, 
25532
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_MAX_NUMBER_OF_CHANNELS );
25533
 
                if ( ulResult == cOCT6100_ERR_OK )
25534
 
                {
25535
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25536
 
                                                                                        f_ulTlvValueAddress, 
25537
 
                                                                                        &ulTempValue );
25538
 
 
25539
 
                        f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels = (UINT16)( ulTempValue & 0xFFFF );
25540
 
                }
25541
 
 
25542
 
                break;
25543
 
 
25544
 
        case cOCT6100_TLV_TYPE_PLAYOUT_ENABLE:
25545
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25546
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_PLAYOUT_ENABLE, 
25547
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_PLAYOUT_ENABLE );
25548
 
                if ( ulResult == cOCT6100_ERR_OK )
25549
 
                {
25550
 
                        /* Set flag indicating that the feature is present. */
25551
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25552
 
                                                                                        f_ulTlvValueAddress, 
25553
 
                                                                                        &ulTempValue );
25554
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fBufferPlayout = (UINT8)( ulTempValue & 0xFF );
25555
 
                }
25556
 
 
25557
 
                break;
25558
 
 
25559
 
        case cOCT6100_TLV_TYPE_DOMINANT_SPEAKER_BOFF_RW_ENABLE:
25560
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25561
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_DOMINANT_SPEAKER_BOFF_RW_ENABLE, 
25562
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_DOMINANT_SPEAKER_BOFF_RW_ENABLE );
25563
 
                if ( ulResult == cOCT6100_ERR_OK )
25564
 
                {
25565
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25566
 
                                                                                                                 f_ulTlvValueAddress, 
25567
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.DominantSpeakerFieldOfst );
25568
 
                }
25569
 
 
25570
 
                break;
25571
 
                
25572
 
        case cOCT6100_TLV_TYPE_TAIL_DISP_CONF_BOFF_RW_ENABLE:
25573
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25574
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_TAIL_DISP_CONF_BOFF_RW_ENABLE, 
25575
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_TAIL_DISP_CONF_BOFF_RW_ENABLE );
25576
 
                if ( ulResult == cOCT6100_ERR_OK )
25577
 
                {
25578
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25579
 
                                                                                                                 f_ulTlvValueAddress, 
25580
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst );
25581
 
 
25582
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fPerChannelTailDisplacement = TRUE;
25583
 
                }
25584
 
                
25585
 
                break;
25586
 
 
25587
 
        case cOCT6100_TLV_TYPE_ANR_RW_ENABLE:
25588
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25589
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_ANR_RW_ENABLE, 
25590
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_ANR_RW_ENABLE );
25591
 
                if ( ulResult == cOCT6100_ERR_OK )
25592
 
                {
25593
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25594
 
                                                                                        f_ulTlvValueAddress, 
25595
 
                                                                                        &ulTempValue );
25596
 
 
25597
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fAdaptiveNoiseReduction = (UINT8)( ulTempValue & 0xFF );
25598
 
                }
25599
 
 
25600
 
                break;
25601
 
 
25602
 
        case cOCT6100_TLV_TYPE_MUSIC_PROTECTION_RW_ENABLE:
25603
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25604
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_MUSIC_PROTECTION_RW_ENABLE, 
25605
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_MUSIC_PROTECTION_RW_ENABLE );
25606
 
                if ( ulResult == cOCT6100_ERR_OK )
25607
 
                {
25608
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25609
 
                                                                                        f_ulTlvValueAddress, 
25610
 
                                                                                        &ulTempValue );
25611
 
 
25612
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fMusicProtection = (UINT8)( ulTempValue & 0xFF );
25613
 
                }
25614
 
 
25615
 
                break;
25616
 
 
25617
 
        case cOCT6100_TLV_TYPE_AEC_DEFAULT_ERL_BOFF:
25618
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25619
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_AEC_DEFAULT_ERL_BOFF_RW_ENABLE, 
25620
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_AEC_DEFAULT_ERL_BOFF_RW_ENABLE );
25621
 
                if ( ulResult == cOCT6100_ERR_OK )
25622
 
                {
25623
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25624
 
                                                                                                                 f_ulTlvValueAddress, 
25625
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.AecDefaultErlFieldOfst );
25626
 
 
25627
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fAecDefaultErl = TRUE;
25628
 
                }
25629
 
 
25630
 
                break;
25631
 
 
25632
 
        case cOCT6100_TLV_TYPE_Z_ALC_TARGET_BOFF:
25633
 
 
25634
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25635
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_Z_ALC_TARGET_BOFF_RW_ENABLE, 
25636
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_Z_ALC_TARGET_BOFF_RW_ENABLE );
25637
 
                if ( ulResult == cOCT6100_ERR_OK )
25638
 
                {
25639
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25640
 
                                                                                                                 f_ulTlvValueAddress, 
25641
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst );
25642
 
 
25643
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fRinAutoLevelControl = TRUE;
25644
 
                }
25645
 
 
25646
 
                break;
25647
 
 
25648
 
        case cOCT6100_TLV_TYPE_Y_ALC_TARGET_BOFF:
25649
 
 
25650
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25651
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_Y_ALC_TARGET_BOFF_RW_ENABLE, 
25652
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_Y_ALC_TARGET_BOFF_RW_ENABLE );
25653
 
                if ( ulResult == cOCT6100_ERR_OK )
25654
 
                {
25655
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25656
 
                                                                                                                 f_ulTlvValueAddress, 
25657
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst );
25658
 
 
25659
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fSoutAutoLevelControl = TRUE;
25660
 
                }
25661
 
 
25662
 
                break;
25663
 
 
25664
 
        case cOCT6100_TLV_TYPE_Z_HLC_TARGET_BOFF:
25665
 
 
25666
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25667
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_Z_HLC_TARGET_BOFF_RW_ENABLE, 
25668
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_Z_HLC_TARGET_BOFF_RW_ENABLE );
25669
 
                if ( ulResult == cOCT6100_ERR_OK )
25670
 
                {
25671
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25672
 
                                                                                                                 f_ulTlvValueAddress, 
25673
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst );
25674
 
 
25675
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fRinHighLevelCompensation = TRUE;
25676
 
                }
25677
 
 
25678
 
                break;
25679
 
 
25680
 
        case cOCT6100_TLV_TYPE_Y_HLC_TARGET_BOFF:
25681
 
 
25682
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25683
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_Y_HLC_TARGET_BOFF_RW_ENABLE, 
25684
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_Y_HLC_TARGET_BOFF_RW_ENABLE );
25685
 
                if ( ulResult == cOCT6100_ERR_OK )
25686
 
                {
25687
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25688
 
                                                                                                                 f_ulTlvValueAddress, 
25689
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst );
25690
 
 
25691
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fSoutHighLevelCompensation = TRUE;
25692
 
                }
25693
 
 
25694
 
                break;
25695
 
 
25696
 
        case cOCT6100_TLV_TYPE_ALC_HLC_STATUS_BOFF:
25697
 
 
25698
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25699
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_ALC_HLC_STATUS_BOFF_RW_ENABLE, 
25700
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_ALC_HLC_STATUS_BOFF_RW_ENABLE );
25701
 
                if ( ulResult == cOCT6100_ERR_OK )
25702
 
                {
25703
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25704
 
                                                                                                                 f_ulTlvValueAddress, 
25705
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.AlcHlcStatusOfst );
25706
 
 
25707
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fAlcHlcStatus = TRUE;
25708
 
                }
25709
 
 
25710
 
                break;
25711
 
 
25712
 
        case cOCT6100_TLV_TYPE_Z_PLAYOUT_HARD_SKIP_BOFF:
25713
 
 
25714
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25715
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_Z_PLAYOUT_HARD_SKIP_BOFF_RW, 
25716
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_Z_PLAYOUT_HARD_SKIP_BOFF_RW );
25717
 
                if ( ulResult == cOCT6100_ERR_OK )
25718
 
                {
25719
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25720
 
                                                                                                                 f_ulTlvValueAddress, 
25721
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst );
25722
 
 
25723
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip = TRUE;
25724
 
                }
25725
 
 
25726
 
                break;
25727
 
 
25728
 
        case cOCT6100_TLV_TYPE_Y_PLAYOUT_HARD_SKIP_BOFF:
25729
 
 
25730
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25731
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_Y_PLAYOUT_HARD_SKIP_BOFF_RW, 
25732
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_Y_PLAYOUT_HARD_SKIP_BOFF_RW );
25733
 
                if ( ulResult == cOCT6100_ERR_OK )
25734
 
                {
25735
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25736
 
                                                                                                                 f_ulTlvValueAddress, 
25737
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst );
25738
 
 
25739
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip = TRUE;
25740
 
                }
25741
 
 
25742
 
                break;
25743
 
                
25744
 
        case cOCT6100_TLV_TYPE_AFT_FIELD_BOFF:
25745
 
 
25746
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25747
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_AFT_FIELD_BOFF_RW, 
25748
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_AFT_FIELD_BOFF_RW );
25749
 
                if ( ulResult == cOCT6100_ERR_OK )
25750
 
                {
25751
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25752
 
                                                                                                                 f_ulTlvValueAddress, 
25753
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.AftControlOfst );
25754
 
 
25755
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fAftControl = TRUE;
25756
 
                }
25757
 
 
25758
 
                break;
25759
 
 
25760
 
        case cOCT6100_TLV_TYPE_VOICE_DETECTED_STAT_BOFF:
25761
 
 
25762
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25763
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_VOICE_DETECTED_STAT_BOFF_RW, 
25764
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_VOICE_DETECTED_STAT_BOFF_RW );
25765
 
                if ( ulResult == cOCT6100_ERR_OK )
25766
 
                {
25767
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25768
 
                                                                                                                 f_ulTlvValueAddress, 
25769
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst );
25770
 
 
25771
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fSinVoiceDetectedStat = TRUE;
25772
 
                }
25773
 
 
25774
 
                break;
25775
 
 
25776
 
        case cOCT6100_TLV_TYPE_GAIN_APPLIED_RIN_STAT_BOFF:
25777
 
 
25778
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25779
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_GAIN_APPLIED_RIN_STAT_BOFF_RW, 
25780
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_GAIN_APPLIED_RIN_STAT_BOFF_RW );
25781
 
                if ( ulResult == cOCT6100_ERR_OK )
25782
 
                {
25783
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25784
 
                                                                                                                 f_ulTlvValueAddress, 
25785
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst );
25786
 
 
25787
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fRinAppliedGainStat = TRUE;
25788
 
                }
25789
 
 
25790
 
                break;
25791
 
 
25792
 
        case cOCT6100_TLV_TYPE_GAIN_APPLIED_SOUT_STAT_BOFF:
25793
 
 
25794
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25795
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_GAIN_APPLIED_SOUT_STAT_BOFF_RW, 
25796
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_GAIN_APPLIED_SOUT_STAT_BOFF_RW );
25797
 
                if ( ulResult == cOCT6100_ERR_OK )
25798
 
                {
25799
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25800
 
                                                                                                                 f_ulTlvValueAddress, 
25801
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst );
25802
 
 
25803
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fSoutAppliedGainStat = TRUE;
25804
 
                }
25805
 
 
25806
 
                break;
25807
 
                
25808
 
        case cOCT6100_TLV_TYPE_MAX_ADAPT_ALE_BOFF:
25809
 
 
25810
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25811
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_MAX_ADAPT_ALE_BOFF_RW, 
25812
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_MAX_ADAPT_ALE_BOFF_RW );
25813
 
                if ( ulResult == cOCT6100_ERR_OK )
25814
 
                {
25815
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25816
 
                                                                                                                 f_ulTlvValueAddress, 
25817
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.AdaptiveAleOfst );
25818
 
 
25819
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fListenerEnhancement = TRUE;
25820
 
                }
25821
 
 
25822
 
                break;
25823
 
                
25824
 
        case cOCT6100_TLV_TYPE_RIN_ANR_BOFF:
25825
 
 
25826
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25827
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_RIN_ANR_BOFF_RW, 
25828
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_RIN_ANR_BOFF_RW );
25829
 
                if ( ulResult == cOCT6100_ERR_OK )
25830
 
                {
25831
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25832
 
                                                                                                                 f_ulTlvValueAddress, 
25833
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.RinAnrOfst );
25834
 
 
25835
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fRoutNoiseReduction = TRUE;
25836
 
                }
25837
 
 
25838
 
                break;
25839
 
                
25840
 
        case cOCT6100_TLV_TYPE_RIN_MUTE_BOFF:
25841
 
 
25842
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25843
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_RIN_MUTE_BOFF_RW, 
25844
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_RIN_MUTE_BOFF_RW );
25845
 
                if ( ulResult == cOCT6100_ERR_OK )
25846
 
                {
25847
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25848
 
                                                                                                                 f_ulTlvValueAddress, 
25849
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.RinMuteOfst );
25850
 
 
25851
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fRinMute = TRUE;
25852
 
                }
25853
 
 
25854
 
                break;
25855
 
 
25856
 
        case cOCT6100_TLV_TYPE_SIN_MUTE_BOFF:
25857
 
 
25858
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25859
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_SIN_MUTE_BOFF_RW, 
25860
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_SIN_MUTE_BOFF_RW );
25861
 
                if ( ulResult == cOCT6100_ERR_OK )
25862
 
                {
25863
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25864
 
                                                                                                                 f_ulTlvValueAddress, 
25865
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.SinMuteOfst );
25866
 
 
25867
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fSinMute = TRUE;
25868
 
                }
25869
 
 
25870
 
                break;
25871
 
                
25872
 
        case cOCT6100_TLV_TYPE_NUMBER_PLAYOUT_EVENTS:
25873
 
                
25874
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25875
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_NUMBER_PLAYOUT_EVENTS, 
25876
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_NUMBER_PLAYOUT_EVENTS );
25877
 
                if ( ulResult == cOCT6100_ERR_OK )
25878
 
                {
25879
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
25880
 
                                                                                        f_ulTlvValueAddress, 
25881
 
                                                                                        &ulTempValue );
25882
 
 
25883
 
                        f_pApiInstance->pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents = (UINT8)( ulTempValue & 0xFF );
25884
 
                }
25885
 
 
25886
 
                break;
25887
 
 
25888
 
        case cOCT6100_TLV_TYPE_ANR_SNR_IMPROVEMENT_BOFF:
25889
 
 
25890
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25891
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_ANR_SNR_IMPROVEMENT_BOFF_RW, 
25892
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_ANR_SNR_IMPROVEMENT_BOFF_RW );
25893
 
                if ( ulResult == cOCT6100_ERR_OK )
25894
 
                {
25895
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25896
 
                                                                                                                 f_ulTlvValueAddress, 
25897
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.AnrSnrEnhancementOfst );
25898
 
 
25899
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fAnrSnrEnhancement = TRUE;
25900
 
                }
25901
 
 
25902
 
                break;
25903
 
 
25904
 
        case cOCT6100_TLV_TYPE_ANR_AGRESSIVITY_BOFF:
25905
 
 
25906
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25907
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_ANR_AGRESSIVITY_BOFF_RW, 
25908
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_ANR_AGRESSIVITY_BOFF_RW );
25909
 
                if ( ulResult == cOCT6100_ERR_OK )
25910
 
                {
25911
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25912
 
                                                                                                                 f_ulTlvValueAddress, 
25913
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst );
25914
 
 
25915
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation = TRUE;
25916
 
                }
25917
 
 
25918
 
                break;
25919
 
 
25920
 
        case cOCT6100_TLV_TYPE_CHAN_TAIL_LENGTH_BOFF:
25921
 
 
25922
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25923
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CHAN_TAIL_LENGTH_BOFF, 
25924
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CHAN_TAIL_LENGTH_BOFF );
25925
 
                if ( ulResult == cOCT6100_ERR_OK )
25926
 
                {
25927
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25928
 
                                                                                                                 f_ulTlvValueAddress, 
25929
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst );
25930
 
 
25931
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fPerChannelTailLength = TRUE;
25932
 
                }
25933
 
 
25934
 
                break;
25935
 
 
25936
 
        case cOCT6100_TLV_TYPE_CHAN_VQE_TONE_DISABLING_BOFF:
25937
 
 
25938
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25939
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_CHAN_VQE_TONE_DIS_BOFF, 
25940
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_CHAN_VQE_TONE_DIS_BOFF );
25941
 
                if ( ulResult == cOCT6100_ERR_OK )
25942
 
                {
25943
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25944
 
                                                                                                                 f_ulTlvValueAddress, 
25945
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst );
25946
 
 
25947
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay = TRUE;
25948
 
                }
25949
 
 
25950
 
                break;
25951
 
 
25952
 
        case cOCT6100_TLV_TYPE_AF_TAIL_DISP_VALUE_BOFF:
25953
 
 
25954
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25955
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_AF_TAIL_DISP_VALUE_BOFF, 
25956
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_AF_TAIL_DISP_VALUE_BOFF );
25957
 
                if ( ulResult == cOCT6100_ERR_OK )
25958
 
                {
25959
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25960
 
                                                                                                                 f_ulTlvValueAddress, 
25961
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst );
25962
 
 
25963
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fAfTailDisplacement = TRUE;
25964
 
                }
25965
 
 
25966
 
                break;
25967
 
 
25968
 
 
25969
 
        case cOCT6100_TLV_TYPE_POUCH_COUNTER_BOFF:
25970
 
 
25971
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25972
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_POUCH_COUNTER_BOFF, 
25973
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_POUCH_COUNTER_BOFF );
25974
 
                if ( ulResult == cOCT6100_ERR_OK )
25975
 
                {
25976
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25977
 
                                                                                                                 f_ulTlvValueAddress, 
25978
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.PouchCounterFieldOfst );
25979
 
 
25980
 
                        f_pApiInstance->pSharedInfo->DebugInfo.fPouchCounter = TRUE;
25981
 
                }
25982
 
 
25983
 
                break;
25984
 
 
25985
 
        case cOCT6100_TLV_TYPE_AEC_TAIL_LENGTH_BOFF:
25986
 
 
25987
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
25988
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_AEC_TAIL_BOFF, 
25989
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_AEC_TAIL_BOFF );
25990
 
                if ( ulResult == cOCT6100_ERR_OK )
25991
 
                {
25992
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25993
 
                                                                                                                 f_ulTlvValueAddress, 
25994
 
                                                                                                                 &f_pApiInstance->pSharedInfo->MemoryMap.AecTailLengthFieldOfst );
25995
 
 
25996
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fAecTailLength = TRUE;
25997
 
                }
25998
 
 
25999
 
                break;
26000
 
 
26001
 
        case cOCT6100_TLV_TYPE_MATRIX_DWORD_BASE:
26002
 
                
26003
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26004
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_MATRIX_DWORD_BASE, 
26005
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_MATRIX_DWORD_BASE );
26006
 
                if ( ulResult == cOCT6100_ERR_OK )
26007
 
                {
26008
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26009
 
                                                                                        f_ulTlvValueAddress, 
26010
 
                                                                                        &f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixBaseAddress );
26011
 
 
26012
 
                        /* Mask the upper bits set by the firmware. */
26013
 
                        f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixBaseAddress &= 0x0FFFFFFF;                       
26014
 
 
26015
 
                        /* Modify the base address to incorporate the external memory offset. */
26016
 
                        f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixBaseAddress += cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
26017
 
                }
26018
 
 
26019
 
                break;
26020
 
 
26021
 
        case cOCT6100_TLV_TYPE_DEBUG_CHAN_STATS_BYTE_SIZE:
26022
 
                
26023
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26024
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_DEBUG_CHAN_STATS_BYTE_SIZE, 
26025
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_DEBUG_CHAN_STATS_BYTE_SIZE );
26026
 
                if ( ulResult == cOCT6100_ERR_OK )
26027
 
                {
26028
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26029
 
                                                                                        f_ulTlvValueAddress, 
26030
 
                                                                                        &f_pApiInstance->pSharedInfo->DebugInfo.ulDebugChanStatsByteSize );
26031
 
                }
26032
 
 
26033
 
                break;
26034
 
 
26035
 
        case cOCT6100_TLV_TYPE_DEBUG_CHAN_LITE_STATS_BYTE_SIZE:
26036
 
                
26037
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26038
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_DEBUG_CHAN_LITE_STATS_BYTE_SIZE, 
26039
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_DEBUG_CHAN_LITE_STATS_BYTE_SIZE );
26040
 
                if ( ulResult == cOCT6100_ERR_OK )
26041
 
                {
26042
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26043
 
                                                                                        f_ulTlvValueAddress, 
26044
 
                                                                                        &f_pApiInstance->pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize );
26045
 
                }
26046
 
 
26047
 
                break;
26048
 
 
26049
 
        case cOCT6100_TLV_TYPE_HOT_CHANNEL_SELECT_DWORD_BASE:
26050
 
                
26051
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26052
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_HOT_CHANNEL_SELECT_DWORD_BASE, 
26053
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_HOT_CHANNEL_SELECT_DWORD_BASE );
26054
 
                if ( ulResult == cOCT6100_ERR_OK )
26055
 
                {
26056
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26057
 
                                                                                        f_ulTlvValueAddress, 
26058
 
                                                                                        &f_pApiInstance->pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress );
26059
 
                }
26060
 
 
26061
 
                break;
26062
 
 
26063
 
        case cOCT6100_TLV_TYPE_MATRIX_TIMESTAMP_DWORD_BASE:
26064
 
                
26065
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26066
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_TIMESTAMP_DWORD_BASE, 
26067
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_TIMESTAMP_DWORD_BASE );
26068
 
                if ( ulResult == cOCT6100_ERR_OK )
26069
 
                {
26070
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26071
 
                                                                                        f_ulTlvValueAddress, 
26072
 
                                                                                        &f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixTimestampBaseAddress );
26073
 
                }
26074
 
 
26075
 
                break;
26076
 
 
26077
 
        case cOCT6100_TLV_TYPE_MATRIX_WP_DWORD_BASE:
26078
 
                
26079
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26080
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_MATRIX_WP_DWORD_BASE, 
26081
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_MATRIX_WP_DWORD_BASE );
26082
 
                if ( ulResult == cOCT6100_ERR_OK )
26083
 
                {
26084
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26085
 
                                                                                        f_ulTlvValueAddress, 
26086
 
                                                                                        &f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixWpBaseAddress );
26087
 
                }
26088
 
 
26089
 
                break;
26090
 
 
26091
 
        case cOCT6100_TLV_TYPE_AF_WRITE_PTR_BYTE_OFFSET:
26092
 
                
26093
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26094
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_AF_WRITE_PTR_BYTE_OFFSET, 
26095
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_AF_WRITE_PTR_BYTE_OFFSET );
26096
 
                if ( ulResult == cOCT6100_ERR_OK )
26097
 
                {
26098
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26099
 
                                                                                        f_ulTlvValueAddress, 
26100
 
                                                                                        &f_pApiInstance->pSharedInfo->DebugInfo.ulAfWritePtrByteOffset );
26101
 
                }
26102
 
 
26103
 
                break;
26104
 
 
26105
 
        case cOCT6100_TLV_TYPE_RECORDED_PCM_EVENT_BYTE_SIZE:
26106
 
                
26107
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26108
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_RECORDED_PCM_EVENT_BYTE_SIZE, 
26109
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_RECORDED_PCM_EVENT_BYTE_SIZE );
26110
 
                if ( ulResult == cOCT6100_ERR_OK )
26111
 
                {
26112
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26113
 
                                                                                        f_ulTlvValueAddress, 
26114
 
                                                                                        &f_pApiInstance->pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize );
26115
 
                }
26116
 
 
26117
 
                break;
26118
 
 
26119
 
        case cOCT6100_TLV_TYPE_IS_ISR_CALLED_BOFF:
26120
 
                
26121
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26122
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_IS_ISR_CALLED_BOFF, 
26123
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_IS_ISR_CALLED_BOFF );
26124
 
                if ( ulResult == cOCT6100_ERR_OK )
26125
 
                {
26126
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26127
 
                                                                                        f_ulTlvValueAddress, 
26128
 
                                                                                        &f_pApiInstance->pSharedInfo->MemoryMap.IsIsrCalledFieldOfst );
26129
 
 
26130
 
                        f_pApiInstance->pSharedInfo->DebugInfo.fIsIsrCalledField = TRUE;
26131
 
                }
26132
 
 
26133
 
                break;
26134
 
 
26135
 
        case cOCT6100_TLV_TYPE_MUSIC_PROTECTION_ENABLE_BOFF:
26136
 
                
26137
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26138
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_MUSIC_PROTECTION_ENABLE_BOFF, 
26139
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_MUSIC_PROTECTION_ENABLE_BOFF );
26140
 
                if ( ulResult == cOCT6100_ERR_OK )
26141
 
                {
26142
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26143
 
                                                                                        f_ulTlvValueAddress, 
26144
 
                                                                                        &f_pApiInstance->pSharedInfo->MemoryMap.MusicProtectionFieldOfst );
26145
 
 
26146
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fMusicProtectionConfiguration = TRUE;
26147
 
                }
26148
 
 
26149
 
                break;
26150
 
 
26151
 
        case cOCT6100_TLV_TYPE_IDLE_CODE_DETECTION_ENABLE:
26152
 
                
26153
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26154
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_IDLE_CODE_DETECTION, 
26155
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_IDLE_CODE_DETECTION );
26156
 
                if ( ulResult == cOCT6100_ERR_OK )
26157
 
                {
26158
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26159
 
                                                                                        f_ulTlvValueAddress, 
26160
 
                                                                                        &ulTempValue );
26161
 
 
26162
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fIdleCodeDetection = (UINT8)( ulTempValue & 0xFF );
26163
 
                }
26164
 
 
26165
 
                break;
26166
 
                
26167
 
        case cOCT6100_TLV_TYPE_IDLE_CODE_DETECTION_BOFF:
26168
 
                
26169
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26170
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_IDLE_CODE_DETECTION_BOFF, 
26171
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_IDLE_CODE_DETECTION_BOFF );
26172
 
                if ( ulResult == cOCT6100_ERR_OK )
26173
 
                {
26174
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26175
 
                                                                                        f_ulTlvValueAddress, 
26176
 
                                                                                        &f_pApiInstance->pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst );
26177
 
 
26178
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration = TRUE;
26179
 
                }
26180
 
 
26181
 
                break;
26182
 
 
26183
 
        case cOCT6100_TLV_TYPE_IMAGE_TYPE:
26184
 
                
26185
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26186
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_IMAGE_TYPE, 
26187
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_IMAGE_TYPE );
26188
 
                if ( ulResult == cOCT6100_ERR_OK )
26189
 
                {
26190
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26191
 
                                                                                        f_ulTlvValueAddress, 
26192
 
                                                                                        &ulTempValue );
26193
 
 
26194
 
                        /* Check if read image type value is what's expected. */
26195
 
                        if ( ( ulTempValue != cOCT6100_IMAGE_TYPE_WIRELINE )
26196
 
                                && ( ulTempValue != cOCT6100_IMAGE_TYPE_COMBINED ) )
26197
 
                                return cOCT6100_ERR_FATAL_E9;
26198
 
 
26199
 
                        f_pApiInstance->pSharedInfo->ImageInfo.byImageType = (UINT8)( ulTempValue & 0xFF );
26200
 
                }
26201
 
 
26202
 
                break;
26203
 
 
26204
 
        case cOCT6100_TLV_TYPE_MAX_WIRELINE_CHANNELS:
26205
 
                
26206
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26207
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_MAX_WIRELINE_CHANNELS, 
26208
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_MAX_WIRELINE_CHANNELS );
26209
 
                if ( ulResult == cOCT6100_ERR_OK )
26210
 
                {
26211
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26212
 
                                                                                        f_ulTlvValueAddress, 
26213
 
                                                                                        &ulTempValue );
26214
 
                }
26215
 
 
26216
 
                break;
26217
 
                
26218
 
        case cOCT6100_TLV_TYPE_AF_EVENT_CB_SIZE:
26219
 
                
26220
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26221
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_AF_EVENT_CB_BYTE_SIZE, 
26222
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_AF_EVENT_CB_BYTE_SIZE );
26223
 
                if ( ulResult == cOCT6100_ERR_OK )
26224
 
                {
26225
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26226
 
                                                                                        f_ulTlvValueAddress, 
26227
 
                                                                                        &f_pApiInstance->pSharedInfo->DebugInfo.ulAfEventCbByteSize );
26228
 
                }
26229
 
 
26230
 
                break;
26231
 
 
26232
 
        case cOCT6100_TLV_TYPE_BUFFER_PLAYOUT_SKIP_IN_EVENTS:
26233
 
                
26234
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26235
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_BUFFER_PLAYOUT_SKIP_IN_EVENTS, 
26236
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_BUFFER_PLAYOUT_SKIP_IN_EVENTS );
26237
 
                if ( ulResult == cOCT6100_ERR_OK )
26238
 
                {
26239
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26240
 
                                                                                        f_ulTlvValueAddress, 
26241
 
                                                                                        &ulTempValue );
26242
 
 
26243
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents = TRUE;
26244
 
                }
26245
 
 
26246
 
                break;
26247
 
                
26248
 
        case cOCT6100_TLV_TYPE_ZZ_ENERGY_CHAN_STATS_BOFF:
26249
 
                
26250
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26251
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_ZZ_ENERGY_CHAN_STATS_BOFF, 
26252
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_ZZ_ENERGY_CHAN_STATS_BOFF );
26253
 
                if ( ulResult == cOCT6100_ERR_OK )
26254
 
                {
26255
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26256
 
                                                                                        f_ulTlvValueAddress, 
26257
 
                                                                                        &f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst );
26258
 
 
26259
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fRinEnergyStat = TRUE;
26260
 
                }
26261
 
 
26262
 
                break;
26263
 
 
26264
 
        case cOCT6100_TLV_TYPE_YY_ENERGY_CHAN_STATS_BOFF:
26265
 
                
26266
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26267
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_YY_ENERGY_CHAN_STATS_BOFF, 
26268
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_YY_ENERGY_CHAN_STATS_BOFF );
26269
 
                if ( ulResult == cOCT6100_ERR_OK )
26270
 
                {
26271
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26272
 
                                                                                        f_ulTlvValueAddress, 
26273
 
                                                                                        &f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst );
26274
 
 
26275
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fSoutEnergyStat = TRUE;
26276
 
                }
26277
 
 
26278
 
                break;
26279
 
 
26280
 
        case cOCT6100_TLV_TYPE_DOUBLE_TALK_BEH_MODE:
26281
 
                
26282
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26283
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_DOUBLE_TALK_BEH_MODE, 
26284
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_DOUBLE_TALK_BEH_MODE );
26285
 
                if ( ulResult == cOCT6100_ERR_OK )
26286
 
                {
26287
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26288
 
                                                                                        f_ulTlvValueAddress, 
26289
 
                                                                                        &ulTempValue );
26290
 
 
26291
 
                        if ( ulTempValue != 0 )
26292
 
                                f_pApiInstance->pSharedInfo->ImageInfo.fDoubleTalkBehavior = TRUE;
26293
 
                        else
26294
 
                                f_pApiInstance->pSharedInfo->ImageInfo.fDoubleTalkBehavior = FALSE;
26295
 
 
26296
 
                }
26297
 
 
26298
 
                break;
26299
 
 
26300
 
        case cOCT6100_TLV_TYPE_DOUBLE_TALK_BEH_MODE_BOFF:
26301
 
                
26302
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26303
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_DOUBLE_TALK_BEH_MODE_BOFF, 
26304
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_DOUBLE_TALK_BEH_MODE_BOFF );
26305
 
                if ( ulResult == cOCT6100_ERR_OK )
26306
 
                {
26307
 
                        ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26308
 
                                                                                        f_ulTlvValueAddress, 
26309
 
                                                                                        &f_pApiInstance->pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst );
26310
 
 
26311
 
                        f_pApiInstance->pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst = TRUE;
26312
 
                }
26313
 
 
26314
 
                break;
26315
 
 
26316
 
        case cOCT6100_TLV_TYPE_SOUT_NOISE_BLEACHING:
26317
 
 
26318
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26319
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_SOUT_NOISE_BLEACHING, 
26320
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_SOUT_NOISE_BLEACHING );
26321
 
                if ( ulResult == cOCT6100_ERR_OK )
26322
 
                {
26323
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26324
 
                                                                                        f_ulTlvValueAddress, 
26325
 
                                                                                        &ulTempValue );
26326
 
 
26327
 
                        if ( ulTempValue != 0 )
26328
 
                                f_pApiInstance->pSharedInfo->ImageInfo.fSoutNoiseBleaching = TRUE;
26329
 
                        else
26330
 
                                f_pApiInstance->pSharedInfo->ImageInfo.fSoutNoiseBleaching = FALSE;
26331
 
 
26332
 
                }
26333
 
 
26334
 
                break;
26335
 
 
26336
 
        case cOCT6100_TLV_TYPE_NLP_STATISTICS:
26337
 
 
26338
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength, 
26339
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_NLP_STATISTICS, 
26340
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_NLP_STATISTICS );
26341
 
                if ( ulResult == cOCT6100_ERR_OK )
26342
 
                {
26343
 
                        ulResult = Oct6100ApiReadDword( f_pApiInstance,
26344
 
                                                                                        f_ulTlvValueAddress, 
26345
 
                                                                                        &ulTempValue );
26346
 
 
26347
 
                        if ( ulTempValue != 0 )
26348
 
                                f_pApiInstance->pSharedInfo->ImageInfo.fSinLevel = TRUE;
26349
 
                        else
26350
 
                                f_pApiInstance->pSharedInfo->ImageInfo.fSinLevel = FALSE;
26351
 
 
26352
 
                }
26353
 
 
26354
 
                break;
26355
 
 
26356
 
        default:        
26357
 
                /* Unknown TLV type field... check default length and nothing else. */
26358
 
                ulResult = Oct6100ApiTlvCheckLengthField( f_ulTlvFieldLength,
26359
 
                                                                                                  cOCT6100_TLV_MIN_LENGTH_DEFAULT,
26360
 
                                                                                                  cOCT6100_TLV_MAX_LENGTH_DEFAULT );
26361
 
                break;
26362
 
        }
26363
 
        
26364
 
        return ulResult;
26365
 
}
26366
 
 
26367
 
 
26368
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26369
 
 
26370
 
Function:               Oct6100ApiTlvCheckLengthField
26371
 
 
26372
 
Description:    This function validates the TLV length field.
26373
 
 
26374
 
-------------------------------------------------------------------------------
26375
 
|       Argument                |       Description
26376
 
-------------------------------------------------------------------------------
26377
 
f_ulTlvFieldLength              Length field read from the TLV.
26378
 
f_ulMinLengthValue              Minimum value supported for the TLV.
26379
 
f_ulMaxLengthValue              Maximum value supported for the TLV.
26380
 
 
26381
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26382
 
static UINT32 Oct6100ApiTlvCheckLengthField( 
26383
 
                                IN              UINT32                          f_ulTlvFieldLength,
26384
 
                                IN              UINT32                          f_ulMinLengthValue,
26385
 
                                IN              UINT32                          f_ulMaxLengthValue )
26386
 
{
26387
 
        /* Check if the value is too small. */
26388
 
        if ( f_ulTlvFieldLength < f_ulMinLengthValue )
26389
 
                return ( cOCT6100_ERR_FATAL_59 );
26390
 
 
26391
 
        /* Check if the value is too big. */
26392
 
        if ( f_ulTlvFieldLength > f_ulMaxLengthValue )
26393
 
                return ( cOCT6100_ERR_FATAL_5A );
26394
 
 
26395
 
        /* Check if the value is dword aligned. */
26396
 
        if ( ( f_ulTlvFieldLength % 4 ) != 0 )
26397
 
                return ( cOCT6100_ERR_OPEN_INVALID_TLV_LENGTH );
26398
 
        
26399
 
        return cOCT6100_ERR_OK;
26400
 
}
26401
 
 
26402
 
 
26403
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26404
 
 
26405
 
Function:               Oct6100ApiTlvReadBitOffsetStruct
26406
 
 
26407
 
Description:    This function extracts a bit offset structure from the TLV.
26408
 
 
26409
 
-------------------------------------------------------------------------------
26410
 
|       Argument                |       Description
26411
 
-------------------------------------------------------------------------------
26412
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
26413
 
                                                present state of the chip and all its resources.
26414
 
 
26415
 
f_ulAddress                             Address where the read the TLV information.
26416
 
f_pBitOffsetStruct              Pointer to a bit offset stucture.
26417
 
 
26418
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26419
 
static UINT32 Oct6100ApiTlvReadBitOffsetStruct( 
26420
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance,
26421
 
                                IN              UINT32                                                  f_ulAddress,
26422
 
                                OUT             tPOCT6100_TLV_OFFSET                    f_pBitOffsetStruct )
26423
 
{
26424
 
        tOCT6100_READ_PARAMS    ReadParams;
26425
 
        UINT16  usReadData;
26426
 
        
26427
 
        UINT32  ulResult;
26428
 
        UINT32  ulOffsetValue;
26429
 
        UINT32  ulSizeValue;
26430
 
 
26431
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
26432
 
 
26433
 
        ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
26434
 
        ReadParams.pusReadData = &usReadData;
26435
 
 
26436
 
        /*======================================================================*/
26437
 
        /* Read the first 16 bits of the TLV field. */
26438
 
 
26439
 
        ReadParams.ulReadAddress = f_ulAddress;
26440
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
26441
 
        if ( ulResult != cOCT6100_ERR_OK )
26442
 
                return ulResult;
26443
 
        
26444
 
        /* Save data. */
26445
 
        ulOffsetValue = usReadData << 16;
26446
 
 
26447
 
        /* Read the last word of the TLV type. */
26448
 
        ReadParams.ulReadAddress += 2;
26449
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
26450
 
        if ( ulResult != cOCT6100_ERR_OK )
26451
 
                return ulResult;
26452
 
 
26453
 
        /* Save data. */
26454
 
        ulOffsetValue |= usReadData;
26455
 
                
26456
 
        /*======================================================================*/
26457
 
        
26458
 
 
26459
 
        /*======================================================================*/
26460
 
        /* Read the first 16 bits of the TLV field. */
26461
 
 
26462
 
        ReadParams.ulReadAddress += 2;
26463
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
26464
 
        if ( ulResult != cOCT6100_ERR_OK )
26465
 
                return ulResult;
26466
 
        
26467
 
        /* Save data. */
26468
 
        ulSizeValue = usReadData << 16;
26469
 
 
26470
 
        /* Read the last word of the TLV type. */
26471
 
        ReadParams.ulReadAddress += 2;
26472
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
26473
 
        if ( ulResult != cOCT6100_ERR_OK )
26474
 
                return ulResult;
26475
 
 
26476
 
        /* Save data. */
26477
 
        ulSizeValue |= usReadData;
26478
 
 
26479
 
        /*======================================================================*/
26480
 
 
26481
 
        /* Set the structure fields. */
26482
 
        f_pBitOffsetStruct->usDwordOffset = (UINT16)(ulOffsetValue / 32);
26483
 
        f_pBitOffsetStruct->byBitOffset   = (UINT8) (32 - (ulOffsetValue % 32) - ulSizeValue);
26484
 
        f_pBitOffsetStruct->byFieldSize   = (UINT8) (ulSizeValue);
26485
 
 
26486
 
        return cOCT6100_ERR_OK;
26487
 
}
26488
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26489
 
 
26490
 
File: oct6100_tone_detection.c
26491
 
 
26492
 
    Copyright (c) 2001-2005 Octasic Inc.
26493
 
    
26494
 
Description: 
26495
 
 
26496
 
        This file contains functions used to enable and disable tone detection on 
26497
 
        an echo channel.
26498
 
 
26499
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
26500
 
free software; you can redistribute it and/or modify it under the terms of 
26501
 
the GNU General Public License as published by the Free Software Foundation; 
26502
 
either version 2 of the License, or (at your option) any later version.
26503
 
 
26504
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
26505
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
26506
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
26507
 
for more details. 
26508
 
 
26509
 
You should have received a copy of the GNU General Public License 
26510
 
along with the OCT6100 GPL API; if not, write to the Free Software 
26511
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26512
 
 
26513
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
26514
 
 
26515
 
$Octasic_Revision: 49 $
26516
 
 
26517
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26518
 
 
26519
 
 
26520
 
/*****************************  INCLUDE FILES  *******************************/
26521
 
 
26522
 
#include "octdef.h"
26523
 
 
26524
 
#include "oct6100api/oct6100_defines.h"
26525
 
#include "oct6100api/oct6100_errors.h"
26526
 
#include "oct6100api/oct6100_apiud.h"
26527
 
 
26528
 
#include "apilib/octapi_llman.h"
26529
 
 
26530
 
#include "oct6100api/oct6100_tlv_inst.h"
26531
 
#include "oct6100api/oct6100_chip_open_inst.h"
26532
 
#include "oct6100api/oct6100_chip_stats_inst.h"
26533
 
#include "oct6100api/oct6100_interrupts_inst.h"
26534
 
#include "oct6100api/oct6100_remote_debug_inst.h"
26535
 
#include "oct6100api/oct6100_debug_inst.h"
26536
 
#include "oct6100api/oct6100_api_inst.h"
26537
 
#include "oct6100api/oct6100_channel_inst.h"
26538
 
#include "oct6100api/oct6100_tone_detection_inst.h"
26539
 
#include "oct6100api/oct6100_events_inst.h"
26540
 
 
26541
 
#include "oct6100api/oct6100_interrupts_pub.h"
26542
 
#include "oct6100api/oct6100_chip_open_pub.h"
26543
 
#include "oct6100api/oct6100_channel_pub.h"
26544
 
#include "oct6100api/oct6100_tone_detection_pub.h"
26545
 
#include "oct6100api/oct6100_events_pub.h"
26546
 
 
26547
 
#include "oct6100_chip_open_priv.h"
26548
 
#include "oct6100_miscellaneous_priv.h"
26549
 
#include "oct6100_memory_priv.h"
26550
 
#include "oct6100_channel_priv.h"
26551
 
#include "oct6100_tone_detection_priv.h"
26552
 
#include "oct6100_events_priv.h"
26553
 
 
26554
 
 
26555
 
/****************************  PUBLIC FUNCTIONS  *****************************/
26556
 
 
26557
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26558
 
 
26559
 
Function:               Oct6100ToneDetectionEnable
26560
 
 
26561
 
Description:    This function enables the generation of event for a selected 
26562
 
                                tone on the specified channel.
26563
 
 
26564
 
-------------------------------------------------------------------------------
26565
 
|       Argument                |       Description
26566
 
-------------------------------------------------------------------------------
26567
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
26568
 
                                                present state of the chip and all its resources.
26569
 
 
26570
 
f_pToneDetectEnable             Pointer to tone detection enable structure.
26571
 
 
26572
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26573
 
static UINT32 Oct6100ToneDetectionEnableDef(
26574
 
                                tPOCT6100_TONE_DETECTION_ENABLE                 f_pToneDetectEnable )
26575
 
{
26576
 
        f_pToneDetectEnable->ulChannelHndl = cOCT6100_INVALID_HANDLE;
26577
 
        f_pToneDetectEnable->ulToneNumber = cOCT6100_INVALID_TONE;
26578
 
 
26579
 
        return cOCT6100_ERR_OK;
26580
 
}
26581
 
 
26582
 
static UINT32 Oct6100ToneDetectionEnable(
26583
 
                                tPOCT6100_INSTANCE_API                                  f_pApiInstance,
26584
 
                                tPOCT6100_TONE_DETECTION_ENABLE                 f_pToneDetectEnable )
26585
 
{
26586
 
        tOCT6100_SEIZE_SERIALIZE_OBJECT         SeizeSerObj;
26587
 
        tOCT6100_RELEASE_SERIALIZE_OBJECT       ReleaseSerObj;
26588
 
        UINT32                                                          ulSerRes = cOCT6100_ERR_OK;
26589
 
        UINT32                                                          ulFncRes = cOCT6100_ERR_OK;
26590
 
 
26591
 
        /* Set the process context of the serialize structure. */
26592
 
        SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
26593
 
        ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
26594
 
 
26595
 
        /* Seize all list semaphores needed by this function. */
26596
 
        SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
26597
 
        SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY;
26598
 
        ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj );
26599
 
        if ( ulSerRes == cOCT6100_ERR_OK )
26600
 
        {
26601
 
                /* Call the serialized function. */
26602
 
                ulFncRes = Oct6100ToneDetectionEnableSer( f_pApiInstance, f_pToneDetectEnable );
26603
 
        }
26604
 
        else
26605
 
        {
26606
 
                return ulSerRes;
26607
 
        }
26608
 
 
26609
 
        /* Release the seized semaphores. */
26610
 
        ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
26611
 
        ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
26612
 
 
26613
 
        /* If an error occured then return the error code. */
26614
 
        if ( ulSerRes != cOCT6100_ERR_OK )
26615
 
                return ulSerRes;
26616
 
        if ( ulFncRes != cOCT6100_ERR_OK )
26617
 
                return ulFncRes;
26618
 
 
26619
 
        return cOCT6100_ERR_OK;
26620
 
}
26621
 
 
26622
 
 
26623
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26624
 
 
26625
 
Function:               Oct6100ToneDetectionDisable
26626
 
 
26627
 
Description:    This function disables the detection of a tone for a specific 
26628
 
                                channel.
26629
 
 
26630
 
-------------------------------------------------------------------------------
26631
 
|       Argument                |       Description
26632
 
-------------------------------------------------------------------------------
26633
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
26634
 
                                                present state of the chip and all its resources.
26635
 
 
26636
 
f_pToneDetectDisable    Pointer to tone detection disable structure.
26637
 
 
26638
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26639
 
static UINT32 Oct6100ToneDetectionDisableDef(
26640
 
                                tPOCT6100_TONE_DETECTION_DISABLE                        f_pToneDetectDisable )
26641
 
{
26642
 
        f_pToneDetectDisable->ulChannelHndl = cOCT6100_INVALID_HANDLE;
26643
 
        f_pToneDetectDisable->ulToneNumber = cOCT6100_INVALID_VALUE;
26644
 
        f_pToneDetectDisable->fDisableAll = FALSE;
26645
 
 
26646
 
        return cOCT6100_ERR_OK;
26647
 
}
26648
 
 
26649
 
 
26650
 
 
26651
 
/****************************  PRIVATE FUNCTIONS  ****************************/
26652
 
 
26653
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26654
 
 
26655
 
Function:               Oct6100ToneDetectionEnableSer
26656
 
 
26657
 
Description:    Activate the detection of a tone on the specified channel.
26658
 
 
26659
 
-------------------------------------------------------------------------------
26660
 
|       Argument                |       Description
26661
 
-------------------------------------------------------------------------------
26662
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
26663
 
                                                present state of the chip and all its resources.
26664
 
 
26665
 
f_pToneDetectEnable             Pointer to tone detect enable structure.  This structure
26666
 
                                                contains, among other things, the tone ID to enable
26667
 
                                                and the channel handle where detection should be
26668
 
                                                enabled.
26669
 
 
26670
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26671
 
static UINT32 Oct6100ToneDetectionEnableSer(
26672
 
                                IN OUT  tPOCT6100_INSTANCE_API                                  f_pApiInstance,
26673
 
                                IN              tPOCT6100_TONE_DETECTION_ENABLE                 f_pToneDetectEnable )
26674
 
{
26675
 
        UINT32  ulChanIndex;
26676
 
        UINT32  ulExtToneChanIndex;
26677
 
        UINT32  ulToneEventNumber=0;
26678
 
 
26679
 
        UINT32  ulResult;
26680
 
 
26681
 
        /* Check the user's configuration of the tone detection for errors. */
26682
 
        ulResult = Oct6100ApiCheckToneEnableParams( 
26683
 
                                                                                        f_pApiInstance, 
26684
 
                                                                                        f_pToneDetectEnable, 
26685
 
                                                                                        &ulChanIndex, 
26686
 
                                                                                        &ulToneEventNumber, 
26687
 
 
26688
 
                                                                                        &ulExtToneChanIndex );
26689
 
        if ( ulResult != cOCT6100_ERR_OK )
26690
 
                return ulResult;
26691
 
 
26692
 
        /* Write to  all resources needed to enable tone detection. */
26693
 
        ulResult = Oct6100ApiWriteToneDetectEvent( 
26694
 
                                                                                        f_pApiInstance, 
26695
 
                                                                                        ulChanIndex, 
26696
 
                                                                                        ulToneEventNumber, 
26697
 
 
26698
 
                                                                                        ulExtToneChanIndex );
26699
 
        if ( ulResult != cOCT6100_ERR_OK )
26700
 
                return ulResult;
26701
 
 
26702
 
        /* Update the channel entry to indicate that a new tone has been activated. */
26703
 
        ulResult = Oct6100ApiUpdateChanToneDetectEntry( 
26704
 
                                                                                        f_pApiInstance, 
26705
 
                                                                                        ulChanIndex, 
26706
 
                                                                                        ulToneEventNumber, 
26707
 
                                                                                        ulExtToneChanIndex );
26708
 
        if ( ulResult != cOCT6100_ERR_OK )
26709
 
                return ulResult;
26710
 
 
26711
 
        return cOCT6100_ERR_OK;
26712
 
}
26713
 
 
26714
 
 
26715
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26716
 
 
26717
 
Function:               Oct6100ApiCheckToneEnableParams
26718
 
 
26719
 
Description:    Check the validity of the channel and tone requested.
26720
 
 
26721
 
-------------------------------------------------------------------------------
26722
 
|       Argument                |       Description
26723
 
-------------------------------------------------------------------------------
26724
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
26725
 
                                                present state of the chip and all its resources.
26726
 
 
26727
 
f_pToneDetectEnable             Pointer to tone detection enable structure.  
26728
 
f_pulChannelIndex               Pointer to the channel index.
26729
 
f_pulToneEventNumber    Pointer to the Index of the tone associated to the requested tone.
26730
 
f_pulExtToneChanIndex   Pointer to the index of the extended channel index.
26731
 
 
26732
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26733
 
static UINT32 Oct6100ApiCheckToneEnableParams(
26734
 
                                IN OUT  tPOCT6100_INSTANCE_API                                  f_pApiInstance,
26735
 
                                IN              tPOCT6100_TONE_DETECTION_ENABLE                 f_pToneDetectEnable,
26736
 
                                OUT             PUINT32                                                                 f_pulChannelIndex,
26737
 
                                OUT             PUINT32                                                                 f_pulToneEventNumber,
26738
 
 
26739
 
                                OUT             PUINT32                                                                 f_pulExtToneChanIndex )
26740
 
{
26741
 
        tPOCT6100_API_CHANNEL           pEchoChannel;
26742
 
        UINT32  ulEntryOpenCnt;
26743
 
        UINT32  i;
26744
 
 
26745
 
        /*=====================================================================*/
26746
 
        /* Check the channel handle. */
26747
 
 
26748
 
        if ( (f_pToneDetectEnable->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
26749
 
                return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID;
26750
 
 
26751
 
        *f_pulChannelIndex = f_pToneDetectEnable->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK;
26752
 
        if ( *f_pulChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
26753
 
                return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID;
26754
 
 
26755
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex )
26756
 
 
26757
 
        /* Extract the entry open count from the provided handle. */
26758
 
        ulEntryOpenCnt = (f_pToneDetectEnable->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
26759
 
 
26760
 
        /* Check for errors. */
26761
 
        if ( pEchoChannel->fReserved != TRUE )
26762
 
                return cOCT6100_ERR_TONE_DETECTION_CHANNEL_NOT_OPEN;
26763
 
        if ( ulEntryOpenCnt != pEchoChannel->byEntryOpenCnt )
26764
 
                return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID;
26765
 
 
26766
 
        /* Set the extended tone detection info if it is activated on the channel. */
26767
 
        *f_pulExtToneChanIndex = pEchoChannel->usExtToneChanIndex;
26768
 
 
26769
 
        /*=====================================================================*/
26770
 
        /* Check the tone information. */
26771
 
 
26772
 
        /* Find out if the tone is present in the build. */
26773
 
        for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ )
26774
 
        {
26775
 
                if ( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ i ].ulToneID == f_pToneDetectEnable->ulToneNumber )
26776
 
                {
26777
 
                        *f_pulToneEventNumber = i;
26778
 
                        break;
26779
 
                }
26780
 
        }
26781
 
        
26782
 
        /* Check if tone is present. */
26783
 
        if ( i == cOCT6100_MAX_TONE_EVENT )
26784
 
                return cOCT6100_ERR_NOT_SUPPORTED_TONE_NOT_PRESENT_IN_FIRMWARE;
26785
 
 
26786
 
        /* Check if the requested tone is actually detected. */
26787
 
        if ((( pEchoChannel->aulToneConf[ *f_pulToneEventNumber / 32 ] >> ( 31 - ( *f_pulToneEventNumber % 32 ))) & 0x1) == 1 )
26788
 
                return cOCT6100_ERR_TONE_DETECTION_TONE_ACTIVATED;
26789
 
 
26790
 
 
26791
 
        
26792
 
        /*=====================================================================*/
26793
 
 
26794
 
        return cOCT6100_ERR_OK;
26795
 
}
26796
 
 
26797
 
 
26798
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26799
 
 
26800
 
Function:               Oct6100ApiWriteToneDetectEvent
26801
 
 
26802
 
Description:    Write the tone detection event in the channel main structure.
26803
 
 
26804
 
-------------------------------------------------------------------------------
26805
 
|       Argument                |       Description
26806
 
-------------------------------------------------------------------------------
26807
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
26808
 
                                                present state of the chip and all its resources.
26809
 
 
26810
 
f_ulChannelIndex                Index of the channel within the API's channel list.
26811
 
f_ulToneEventNumber             Event number of the tone to be activated.
26812
 
f_ulExtToneChanIndex    Index of the extended tone detection channel.
26813
 
 
26814
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26815
 
static UINT32 Oct6100ApiWriteToneDetectEvent(
26816
 
                                IN OUT  tPOCT6100_INSTANCE_API                                  f_pApiInstance,
26817
 
                                IN              UINT32                                                                  f_ulChannelIndex,
26818
 
                                IN              UINT32                                                                  f_ulToneEventNumber,
26819
 
 
26820
 
                                IN              UINT32                                                                  f_ulExtToneChanIndex )
26821
 
{
26822
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
26823
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
26824
 
        tOCT6100_READ_PARAMS                    ReadParams;
26825
 
        UINT32  ulResult;
26826
 
        UINT16  usReadData;
26827
 
 
26828
 
        /* Obtain local pointer to shared portion of instance. */
26829
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
26830
 
 
26831
 
 
26832
 
 
26833
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
26834
 
 
26835
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
26836
 
        ReadParams.pusReadData = &usReadData;
26837
 
 
26838
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
26839
 
 
26840
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
26841
 
 
26842
 
        /*=======================================================================*/
26843
 
        /* Read the current event config about to be modified. */
26844
 
 
26845
 
        ReadParams.ulReadAddress  = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulChannelIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
26846
 
        ReadParams.ulReadAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
26847
 
        ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2;
26848
 
 
26849
 
        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
26850
 
        if ( ulResult != cOCT6100_ERR_OK )
26851
 
                return ulResult;
26852
 
        
26853
 
        /*=======================================================================*/
26854
 
        /* Set the tone event in the channel main memory for the requested direction. */
26855
 
        
26856
 
        WriteParams.ulWriteAddress  = ReadParams.ulReadAddress;
26857
 
        WriteParams.usWriteData  = usReadData;
26858
 
        WriteParams.usWriteData |= ( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 )));
26859
 
 
26860
 
        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
26861
 
        if ( ulResult != cOCT6100_ERR_OK )
26862
 
                return ulResult;
26863
 
        
26864
 
        /*=======================================================================*/
26865
 
        /* Also program the extended channel if one is present. */
26866
 
 
26867
 
        if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX )
26868
 
        {
26869
 
                /* Read the current event config about to be modified. */
26870
 
                ReadParams.ulReadAddress  = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
26871
 
                ReadParams.ulReadAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
26872
 
                ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2;
26873
 
 
26874
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
26875
 
                if ( ulResult != cOCT6100_ERR_OK )
26876
 
                        return ulResult;
26877
 
                
26878
 
                /* Write the tone event in the channel main memory for the requested direction. */
26879
 
                WriteParams.ulWriteAddress  = ReadParams.ulReadAddress;
26880
 
                WriteParams.usWriteData  = usReadData;
26881
 
                WriteParams.usWriteData |= ( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 )));
26882
 
 
26883
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
26884
 
                if ( ulResult != cOCT6100_ERR_OK )
26885
 
                        return ulResult;
26886
 
        }
26887
 
 
26888
 
        /*=======================================================================*/
26889
 
 
26890
 
        return cOCT6100_ERR_OK;
26891
 
}
26892
 
 
26893
 
 
26894
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26895
 
 
26896
 
Function:               Oct6100ApiUpdateChanToneDetectEntry
26897
 
 
26898
 
Description:    Update the echo channel entry to store the info about the tone
26899
 
                                being configured to generate detection events.
26900
 
 
26901
 
-------------------------------------------------------------------------------
26902
 
|       Argument                |       Description
26903
 
-------------------------------------------------------------------------------
26904
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
26905
 
                                                present state of the chip and all its resources.
26906
 
        
26907
 
f_ulChannelIndex                Index of the channel within the API's channel list.
26908
 
f_ulToneEventNumber             Enabled tone event number.
26909
 
f_ulExtToneChanIndex    Index of the extended tone detection channel.
26910
 
 
26911
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26912
 
static UINT32 Oct6100ApiUpdateChanToneDetectEntry (
26913
 
                                IN OUT  tPOCT6100_INSTANCE_API                                  f_pApiInstance,
26914
 
                                IN              UINT32                                                                  f_ulChannelIndex,
26915
 
                                IN              UINT32                                                                  f_ulToneEventNumber,
26916
 
                                IN              UINT32                                                                  f_ulExtToneChanIndex )
26917
 
{
26918
 
        tPOCT6100_API_CHANNEL           pEchoChanEntry;
26919
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
26920
 
        UINT32  ulToneEntry;
26921
 
 
26922
 
        /* Obtain local pointer to shared portion of instance. */
26923
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
26924
 
 
26925
 
        /* Update the channel entry. */
26926
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulChannelIndex );
26927
 
 
26928
 
        /* Set the corresponding bit in the channel array. */
26929
 
        ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ];
26930
 
 
26931
 
        /* Modify the entry. */
26932
 
        ulToneEntry |= ( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 )));
26933
 
 
26934
 
        /* Copy back the new value. */
26935
 
        pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry;
26936
 
        
26937
 
        /* Configure also the extended channel if necessary. */
26938
 
        if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX )
26939
 
        {
26940
 
                /* Update the channel entry. */
26941
 
                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulExtToneChanIndex );
26942
 
 
26943
 
                /* Set the corresponding bit in the channel array. */
26944
 
                ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ];
26945
 
 
26946
 
                /* Modify the entry. */
26947
 
                ulToneEntry |= ( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 )));
26948
 
 
26949
 
                /* Copy back the new value. */
26950
 
                pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry;
26951
 
        }
26952
 
 
26953
 
        /* Check for the SS tone events that could have been generated before. */
26954
 
        if ( f_ulExtToneChanIndex == cOCT6100_INVALID_INDEX )
26955
 
        {
26956
 
                BOOL fSSTone;
26957
 
                UINT32 ulResult;
26958
 
 
26959
 
                ulResult = Oct6100ApiIsSSTone( f_pApiInstance, pSharedInfo->ImageInfo.aToneInfo[ f_ulToneEventNumber ].ulToneID, &fSSTone );
26960
 
                if ( ulResult != cOCT6100_ERR_OK )
26961
 
                        return ulResult;
26962
 
 
26963
 
                /* Is this a signaling system tone? */
26964
 
                if ( fSSTone == TRUE )
26965
 
                {
26966
 
                        /* Check if must generate an event for the last detected SS tone. */
26967
 
                        if ( ( pEchoChanEntry->ulLastSSToneDetected != cOCT6100_INVALID_INDEX )
26968
 
                                && ( pEchoChanEntry->ulLastSSToneDetected == pSharedInfo->ImageInfo.aToneInfo[ f_ulToneEventNumber ].ulToneID ) )
26969
 
                        {
26970
 
                                /* Must write an event for this. */
26971
 
                                tPOCT6100_API_TONE_EVENT pSoftEvent;
26972
 
                                
26973
 
                                /* If enough space. */
26974
 
                                if ( ( ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1 ) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr ) &&
26975
 
                                        ( ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1 ) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0 ) )
26976
 
                                {
26977
 
                                        /* Form the event for this captured tone. */
26978
 
                                        mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
26979
 
                                        pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr;
26980
 
 
26981
 
                                        pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_ulChannelIndex; 
26982
 
                                        pSoftEvent->ulUserChanId = pEchoChanEntry->ulUserChanId;
26983
 
                                        pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ f_ulToneEventNumber ].ulToneID;
26984
 
                                        pSoftEvent->ulTimestamp = pEchoChanEntry->ulLastSSToneTimestamp;
26985
 
                                        pSoftEvent->ulExtToneDetectionPort = cOCT6100_INVALID_VALUE;
26986
 
                                        pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT;
26987
 
 
26988
 
                                        /* Update the control variables of the buffer. */
26989
 
                                        pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++;
26990
 
                                        if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize )
26991
 
                                                pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0;
26992
 
 
26993
 
                                        /* Set the interrupt manager such that the user knows that some tone events */
26994
 
                                        /* are pending in the software Q. */
26995
 
                                        pSharedInfo->IntrptManage.fToneEventsPending = TRUE;
26996
 
                                }
26997
 
                                else
26998
 
                                {
26999
 
                                        /* Set the overflow flag of the buffer. */
27000
 
                                        pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
27001
 
                                }
27002
 
                        }
27003
 
                }
27004
 
        }
27005
 
 
27006
 
        return cOCT6100_ERR_OK;
27007
 
}
27008
 
 
27009
 
 
27010
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27011
 
 
27012
 
Function:               Oct6100ToneDetectionDisableSer
27013
 
 
27014
 
Description:    Disable the generation of events for a selected tone on the 
27015
 
                                specified channel.
27016
 
 
27017
 
-------------------------------------------------------------------------------
27018
 
|       Argument                |       Description
27019
 
-------------------------------------------------------------------------------
27020
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
27021
 
                                                present state of the chip and all its resources.
27022
 
 
27023
 
f_pToneDetectDisable    Pointer to tOCT6100_TONE_DETECTION_DISABLE structure.
27024
 
 
27025
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27026
 
static UINT32 Oct6100ToneDetectionDisableSer(
27027
 
                                IN OUT  tPOCT6100_INSTANCE_API                                  f_pApiInstance,
27028
 
                                IN              tPOCT6100_TONE_DETECTION_DISABLE                f_pToneDetectDisable )
27029
 
{
27030
 
        UINT32  ulChanIndex;
27031
 
        UINT32  ulExtToneChanIndex;
27032
 
        UINT32  ulToneEventNumber;
27033
 
        UINT32  ulResult;
27034
 
        BOOL    fDisableAll;
27035
 
 
27036
 
 
27037
 
        /* Check the user's configuration of the tone detection disable structure for errors. */
27038
 
        ulResult = Oct6100ApiAssertToneDetectionParams( 
27039
 
                                                                                                f_pApiInstance, 
27040
 
                                                                                                f_pToneDetectDisable, 
27041
 
                                                                                                &ulChanIndex, 
27042
 
                                                                                                &ulToneEventNumber, 
27043
 
                                                                                                &ulExtToneChanIndex, 
27044
 
 
27045
 
                                                                                                &fDisableAll );
27046
 
        if ( ulResult != cOCT6100_ERR_OK )
27047
 
                return ulResult;
27048
 
 
27049
 
        /* Clear the event to detect the specified tone. */
27050
 
        ulResult = Oct6100ApiClearToneDetectionEvent( 
27051
 
                                                                                                f_pApiInstance, 
27052
 
                                                                                                ulChanIndex, 
27053
 
                                                                                                ulToneEventNumber, 
27054
 
                                                                                                ulExtToneChanIndex, 
27055
 
 
27056
 
                                                                                                fDisableAll );
27057
 
        if ( ulResult != cOCT6100_ERR_OK )
27058
 
                return ulResult;
27059
 
 
27060
 
        /* Update the channel structure to indicate that the tone is no longer detected. */
27061
 
        ulResult = Oct6100ApiReleaseToneDetectionEvent( 
27062
 
                                                                                                f_pApiInstance, 
27063
 
                                                                                                ulChanIndex, 
27064
 
                                                                                                ulToneEventNumber, 
27065
 
                                                                                                ulExtToneChanIndex, 
27066
 
                                                                                                fDisableAll );
27067
 
        if ( ulResult != cOCT6100_ERR_OK )
27068
 
                return ulResult;
27069
 
 
27070
 
        return cOCT6100_ERR_OK;
27071
 
}
27072
 
 
27073
 
 
27074
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27075
 
 
27076
 
Function:               Oct6100ApiAssertToneDetectionParams
27077
 
 
27078
 
Description:    Check the validity of the tone detection disable command.
27079
 
 
27080
 
-------------------------------------------------------------------------------
27081
 
|       Argument                |       Description
27082
 
-------------------------------------------------------------------------------
27083
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
27084
 
                                                present state of the chip and all its resources.
27085
 
 
27086
 
f_pToneDetectDisable    Pointer to tone detection disable structure.  
27087
 
f_pulChannelIndex               Pointer to the channel index
27088
 
f_pulToneEventNumber    Pointer to the tone event number.
27089
 
f_pulExtToneChanIndex   Pointer to the extended channel index.
27090
 
f_pfDisableAll                  Pointer to the flag specifying whether all tones
27091
 
                                                should be disabled.
27092
 
 
27093
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27094
 
static UINT32 Oct6100ApiAssertToneDetectionParams(
27095
 
                                IN OUT  tPOCT6100_INSTANCE_API                                  f_pApiInstance,
27096
 
                                IN              tPOCT6100_TONE_DETECTION_DISABLE                f_pToneDetectDisable,
27097
 
                                OUT             PUINT32                                                                 f_pulChannelIndex,
27098
 
                                OUT             PUINT32                                                                 f_pulToneEventNumber,
27099
 
                                OUT             PUINT32                                                                 f_pulExtToneChanIndex,
27100
 
 
27101
 
                                OUT             PBOOL                                                                   f_pfDisableAll )
27102
 
{
27103
 
        tPOCT6100_API_CHANNEL           pEchoChannel;
27104
 
        UINT32  ulEntryOpenCnt;
27105
 
        UINT32  i;
27106
 
 
27107
 
        /*=====================================================================*/
27108
 
        /* Check the echo channel handle. */
27109
 
 
27110
 
        if ( (f_pToneDetectDisable->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
27111
 
                return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID;
27112
 
 
27113
 
        *f_pulChannelIndex = f_pToneDetectDisable->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK;
27114
 
        if ( *f_pulChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels )
27115
 
                return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID;
27116
 
 
27117
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex )
27118
 
 
27119
 
        /* Extract the entry open count from the provided handle. */
27120
 
        ulEntryOpenCnt = (f_pToneDetectDisable->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK;
27121
 
 
27122
 
        /* Check for errors. */
27123
 
        if ( pEchoChannel->fReserved != TRUE )
27124
 
                return cOCT6100_ERR_TONE_DETECTION_CHANNEL_NOT_OPEN;
27125
 
        if ( ulEntryOpenCnt != pEchoChannel->byEntryOpenCnt )
27126
 
                return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID;
27127
 
 
27128
 
        /* Return the extended channel index. */
27129
 
        *f_pulExtToneChanIndex = pEchoChannel->usExtToneChanIndex;
27130
 
 
27131
 
        /* Check the disable all flag. */
27132
 
        if ( f_pToneDetectDisable->fDisableAll != TRUE && f_pToneDetectDisable->fDisableAll != FALSE )
27133
 
                return cOCT6100_ERR_TONE_DETECTION_DISABLE_ALL;
27134
 
        
27135
 
        /*=====================================================================*/
27136
 
        /* Check the tone information. */
27137
 
 
27138
 
        /* Find out if the tone is present in the build. */
27139
 
        if ( f_pToneDetectDisable->fDisableAll == FALSE )
27140
 
        {
27141
 
                for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ )
27142
 
                {
27143
 
                        if ( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ i ].ulToneID == f_pToneDetectDisable->ulToneNumber )
27144
 
                        {
27145
 
                                *f_pulToneEventNumber = i;
27146
 
                                break;
27147
 
                        }
27148
 
                }
27149
 
                
27150
 
                /* Check if tone is present. */
27151
 
                if ( i == cOCT6100_MAX_TONE_EVENT )
27152
 
                        return cOCT6100_ERR_NOT_SUPPORTED_TONE_NOT_PRESENT_IN_FIRMWARE;
27153
 
 
27154
 
 
27155
 
 
27156
 
                /* Check if the requested tone is actually detected. */
27157
 
                if ((( pEchoChannel->aulToneConf[ *f_pulToneEventNumber / 32 ] >> ( 31 - ( *f_pulToneEventNumber % 32 ))) & 0x1) == 0 )
27158
 
                        return cOCT6100_ERR_TONE_DETECTION_TONE_NOT_ACTIVATED;
27159
 
        }
27160
 
 
27161
 
        
27162
 
        /*=====================================================================*/
27163
 
 
27164
 
        /* Return the disable all flag as requested. */
27165
 
        *f_pfDisableAll = f_pToneDetectDisable->fDisableAll;
27166
 
 
27167
 
        return cOCT6100_ERR_OK;
27168
 
}
27169
 
 
27170
 
 
27171
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27172
 
 
27173
 
Function:               Oct6100ApiClearToneDetectionEvent
27174
 
 
27175
 
Description:    Clear the buffer playout event in the channel main structure.
27176
 
 
27177
 
-------------------------------------------------------------------------------
27178
 
|       Argument                |       Description
27179
 
-------------------------------------------------------------------------------
27180
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
27181
 
                                                        present state of the chip and all its resources.
27182
 
 
27183
 
f_ulChannelIndex                        Index of the channel within the API's channel list.
27184
 
f_ulToneEventNumber                     Tone event number to be deactivated.
27185
 
f_ulExtToneChanIndex            Index of the extended tone detection channel.
27186
 
f_fDisableAll                           Clear all activated tones.
27187
 
 
27188
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27189
 
static UINT32 Oct6100ApiClearToneDetectionEvent(
27190
 
                                IN OUT  tPOCT6100_INSTANCE_API                                  f_pApiInstance,
27191
 
                                IN              UINT32                                                                  f_ulChannelIndex,
27192
 
                                IN              UINT32                                                                  f_ulToneEventNumber,
27193
 
                                IN              UINT32                                                                  f_ulExtToneChanIndex,
27194
 
 
27195
 
                                IN              BOOL                                                                    f_fDisableAll )
27196
 
{
27197
 
        tPOCT6100_SHARED_INFO                   pSharedInfo;
27198
 
        tOCT6100_WRITE_PARAMS                   WriteParams;
27199
 
        tOCT6100_READ_PARAMS                    ReadParams;
27200
 
        tOCT6100_WRITE_SMEAR_PARAMS             SmearParams;
27201
 
        UINT32  ulResult;
27202
 
        UINT32  ulToneEventBaseAddress;
27203
 
        UINT16  usReadData;
27204
 
 
27205
 
        /* Obtain local pointer to shared portion of instance. */
27206
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
27207
 
 
27208
 
 
27209
 
                
27210
 
        ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
27211
 
 
27212
 
        ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
27213
 
        ReadParams.pusReadData = &usReadData;
27214
 
 
27215
 
        WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
27216
 
 
27217
 
        WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
27218
 
 
27219
 
        SmearParams.pProcessContext = f_pApiInstance->pProcessContext;
27220
 
 
27221
 
        SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
27222
 
 
27223
 
        /*=======================================================================*/
27224
 
        /* Read the current event config about to be modified. */
27225
 
 
27226
 
        ulToneEventBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulChannelIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
27227
 
        ulToneEventBaseAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
27228
 
 
27229
 
        /* Check if must disable all tone events or not. */
27230
 
        if ( f_fDisableAll == FALSE )
27231
 
        {
27232
 
                ReadParams.ulReadAddress  = ulToneEventBaseAddress;
27233
 
                ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2;
27234
 
 
27235
 
                mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
27236
 
                if ( ulResult != cOCT6100_ERR_OK )
27237
 
                        return ulResult;
27238
 
                
27239
 
                /* Clear the event in the channel main memory.*/
27240
 
                WriteParams.ulWriteAddress  = ReadParams.ulReadAddress;
27241
 
                WriteParams.usWriteData  = usReadData;
27242
 
                WriteParams.usWriteData &= (~( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 ))));
27243
 
 
27244
 
                mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
27245
 
                if ( ulResult != cOCT6100_ERR_OK )
27246
 
                        return ulResult;
27247
 
        }
27248
 
        else /* if ( f_fDisableAll == TRUE ) */
27249
 
        {
27250
 
                /* Clear all events in the channel main memory. */
27251
 
                SmearParams.ulWriteLength = 4;
27252
 
                SmearParams.usWriteData = 0x0000;
27253
 
                SmearParams.ulWriteAddress = ulToneEventBaseAddress;
27254
 
                mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
27255
 
                if ( ulResult != cOCT6100_ERR_OK )
27256
 
                        return ulResult;
27257
 
        }
27258
 
        
27259
 
        /*=======================================================================*/
27260
 
        /* Also program the extended channel if one is present. */
27261
 
 
27262
 
        if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX )
27263
 
        {
27264
 
                ulToneEventBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
27265
 
                ulToneEventBaseAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
27266
 
 
27267
 
                /* Check if must disable all tone events or not. */
27268
 
                if ( f_fDisableAll == FALSE )
27269
 
                {
27270
 
                        /* Read the current event config about to be modified. */
27271
 
                        ReadParams.ulReadAddress  = ulToneEventBaseAddress;
27272
 
                        ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2;
27273
 
 
27274
 
                        mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
27275
 
                        if ( ulResult != cOCT6100_ERR_OK )
27276
 
                                return ulResult;
27277
 
                        
27278
 
                        /* Clear the event in the channel main memory.*/
27279
 
                        WriteParams.ulWriteAddress  = ReadParams.ulReadAddress;
27280
 
                        WriteParams.usWriteData  = usReadData;
27281
 
                        WriteParams.usWriteData &= (~( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 ))));
27282
 
 
27283
 
                        mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
27284
 
                        if ( ulResult != cOCT6100_ERR_OK )
27285
 
                                return ulResult;
27286
 
                }
27287
 
                else /* if ( f_fDisableAll == TRUE ) */
27288
 
                {
27289
 
                        /* Clear all events in the channel main memory.*/
27290
 
                        SmearParams.ulWriteLength = 4;
27291
 
                        SmearParams.usWriteData = 0x0000;
27292
 
                        SmearParams.ulWriteAddress = ulToneEventBaseAddress;
27293
 
                        mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
27294
 
                        if ( ulResult != cOCT6100_ERR_OK )
27295
 
                                return ulResult;
27296
 
                }
27297
 
        }
27298
 
 
27299
 
        return cOCT6100_ERR_OK;
27300
 
}
27301
 
 
27302
 
 
27303
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27304
 
 
27305
 
Function:               Oct6100ApiReleaseToneDetectionEvent
27306
 
 
27307
 
Description:    Clear the entry made for this tone in the channel tone 
27308
 
                                enable array. 
27309
 
 
27310
 
-------------------------------------------------------------------------------
27311
 
|       Argument                |       Description
27312
 
-------------------------------------------------------------------------------
27313
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep the
27314
 
                                                present state of the chip and all its resources.
27315
 
 
27316
 
f_ulChannelIndex                Index of the channel within the API's channel list.
27317
 
f_ulToneEventNumber             Tone event number to be deactivated.
27318
 
f_ulExtToneChanIndex    Index of the extended tone detection channel.
27319
 
f_fDisableAll                   Release all activated tones.
27320
 
 
27321
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27322
 
static UINT32 Oct6100ApiReleaseToneDetectionEvent (
27323
 
                                IN OUT  tPOCT6100_INSTANCE_API                                  f_pApiInstance,
27324
 
                                IN              UINT32                                                                  f_ulChannelIndex,
27325
 
                                IN              UINT32                                                                  f_ulToneEventNumber,
27326
 
                                IN              UINT32                                                                  f_ulExtToneChanIndex,
27327
 
                                IN              BOOL                                                                    f_fDisableAll )
27328
 
{
27329
 
        tPOCT6100_API_CHANNEL           pEchoChanEntry;
27330
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
27331
 
        UINT32                                          ulToneEntry;
27332
 
        UINT32                                          ulResult;
27333
 
        UINT32                                          ulToneEventNumber;
27334
 
        BOOL                                            fSSTone;
27335
 
 
27336
 
        /* Obtain local pointer to shared portion of instance. */
27337
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
27338
 
 
27339
 
        /* Update the channel entry. */
27340
 
        mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulChannelIndex );
27341
 
 
27342
 
        /* Check if must release all tone events. */
27343
 
        if ( f_fDisableAll == FALSE )
27344
 
        {
27345
 
                /* Set the corresponding bit in the channel array. */
27346
 
                ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ];
27347
 
 
27348
 
                /* Modify the entry. */
27349
 
                ulToneEntry &= (~( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 ))));
27350
 
 
27351
 
                /* Copy back the new value. */
27352
 
                pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry;
27353
 
        }
27354
 
        else /* if ( f_fDisableAll == TRUE ) */
27355
 
        {
27356
 
                /* Clear all events. */
27357
 
                Oct6100UserMemSet( pEchoChanEntry->aulToneConf, 0x00, sizeof( pEchoChanEntry->aulToneConf ) );
27358
 
        }
27359
 
 
27360
 
        /* Configure also the extended channel if necessary. */
27361
 
        if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX )
27362
 
        {
27363
 
                /* Update the channel entry. */
27364
 
                mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulExtToneChanIndex );
27365
 
 
27366
 
                /* Check if must release all tone events. */
27367
 
                if ( f_fDisableAll == FALSE )
27368
 
                {
27369
 
                        /* Set the corresponding bit in the channel array. */
27370
 
                        ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ];
27371
 
 
27372
 
                        /* Modify the entry. */
27373
 
                        ulToneEntry &= (~( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 ))));
27374
 
 
27375
 
                        /* Copy back the new value. */
27376
 
                        pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry;
27377
 
                }
27378
 
                else /* if ( f_fDisableAll == TRUE ) */
27379
 
                {
27380
 
                        /* Clear all events. */
27381
 
                        Oct6100UserMemSet( pEchoChanEntry->aulToneConf, 0x00, sizeof( pEchoChanEntry->aulToneConf ) );
27382
 
                }
27383
 
        }
27384
 
        
27385
 
        /* Re-enable the SS7 tones */
27386
 
        for ( ulToneEventNumber = 0; ulToneEventNumber < cOCT6100_MAX_TONE_EVENT; ulToneEventNumber++ )
27387
 
        {
27388
 
                /* Check if the current tone is a SS tone. */
27389
 
                ulResult = Oct6100ApiIsSSTone( 
27390
 
                                                                        f_pApiInstance, 
27391
 
                                                                        f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID, 
27392
 
                                                                        &fSSTone );
27393
 
                if ( ulResult != cOCT6100_ERR_OK )
27394
 
                        return ulResult;
27395
 
 
27396
 
                if ( fSSTone == TRUE )
27397
 
                {
27398
 
                        /* Write to all resources needed to activate tone detection on this SS tone. */
27399
 
                        ulResult = Oct6100ApiWriteToneDetectEvent( 
27400
 
                                                                                                        f_pApiInstance, 
27401
 
                                                                                                        f_ulChannelIndex, 
27402
 
                                                                                                        ulToneEventNumber,
27403
 
 
27404
 
                                                                                                        cOCT6100_INVALID_INDEX );
27405
 
                        if ( ulResult != cOCT6100_ERR_OK  )
27406
 
                                return ulResult;
27407
 
                }
27408
 
        }
27409
 
 
27410
 
        return cOCT6100_ERR_OK;
27411
 
}
27412
 
 
27413
 
 
27414
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27415
 
 
27416
 
Function:               Oct6100ApiIsSSTone
27417
 
 
27418
 
Description:    Check if specified tone number is a special signaling
27419
 
                                system tone.
27420
 
 
27421
 
-------------------------------------------------------------------------------
27422
 
|       Argument                |       Description
27423
 
-------------------------------------------------------------------------------
27424
 
f_pApiInstance                          Pointer to API instance. This memory is used to keep the
27425
 
                                                        present state of the chip and all its resources.
27426
 
 
27427
 
f_ulToneEventNumber                     Tone event number to be checked against.
27428
 
 
27429
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27430
 
static UINT32 Oct6100ApiIsSSTone(
27431
 
                                IN OUT  tPOCT6100_INSTANCE_API                                  f_pApiInstance,
27432
 
                                IN              UINT32                                                                  f_ulToneEventNumber,
27433
 
                                OUT             PBOOL                                                                   f_fSSTone )
27434
 
{
27435
 
        *f_fSSTone = FALSE;
27436
 
 
27437
 
        switch( f_ulToneEventNumber )
27438
 
        {
27439
 
        case cOCT6100_TONE_SIN_SYSTEM7_2000:
27440
 
        case cOCT6100_TONE_SIN_SYSTEM7_1780:
27441
 
                *f_fSSTone = TRUE;
27442
 
                break;
27443
 
        default:
27444
 
                break;
27445
 
        }
27446
 
 
27447
 
        return cOCT6100_ERR_OK;
27448
 
}
27449
 
 
27450
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27451
 
 
27452
 
File: oct6100_tsi_cnct.c
27453
 
 
27454
 
    Copyright (c) 2001-2005 Octasic Inc.
27455
 
    
27456
 
Description: 
27457
 
 
27458
 
        This file contains functions used to open and close TSI connections
27459
 
 
27460
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
27461
 
free software; you can redistribute it and/or modify it under the terms of 
27462
 
the GNU General Public License as published by the Free Software Foundation; 
27463
 
either version 2 of the License, or (at your option) any later version.
27464
 
 
27465
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
27466
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
27467
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
27468
 
for more details. 
27469
 
 
27470
 
You should have received a copy of the GNU General Public License 
27471
 
along with the OCT6100 GPL API; if not, write to the Free Software 
27472
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27473
 
 
27474
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
27475
 
 
27476
 
$Octasic_Revision: 37 $
27477
 
 
27478
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27479
 
 
27480
 
 
27481
 
/*****************************  INCLUDE FILES  *******************************/
27482
 
 
27483
 
#include "octdef.h"
27484
 
 
27485
 
#include "oct6100api/oct6100_defines.h"
27486
 
#include "oct6100api/oct6100_errors.h"
27487
 
#include "oct6100api/oct6100_apiud.h"
27488
 
 
27489
 
#include "apilib/octapi_llman.h"
27490
 
 
27491
 
#include "oct6100api/oct6100_tlv_inst.h"
27492
 
#include "oct6100api/oct6100_chip_open_inst.h"
27493
 
#include "oct6100api/oct6100_chip_stats_inst.h"
27494
 
#include "oct6100api/oct6100_interrupts_inst.h"
27495
 
#include "oct6100api/oct6100_channel_inst.h"
27496
 
#include "oct6100api/oct6100_remote_debug_inst.h"
27497
 
#include "oct6100api/oct6100_debug_inst.h"
27498
 
#include "oct6100api/oct6100_api_inst.h"
27499
 
#include "oct6100api/oct6100_tsi_cnct_inst.h"
27500
 
 
27501
 
#include "oct6100api/oct6100_interrupts_pub.h"
27502
 
#include "oct6100api/oct6100_chip_open_pub.h"
27503
 
#include "oct6100api/oct6100_channel_pub.h"
27504
 
#include "oct6100api/oct6100_tsi_cnct_pub.h"
27505
 
 
27506
 
#include "oct6100_chip_open_priv.h"
27507
 
#include "oct6100_miscellaneous_priv.h"
27508
 
#include "oct6100_memory_priv.h"
27509
 
#include "oct6100_tsst_priv.h"
27510
 
#include "oct6100_channel_priv.h"
27511
 
#include "oct6100_tsi_cnct_priv.h"
27512
 
/****************************  PRIVATE FUNCTIONS  ****************************/
27513
 
 
27514
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27515
 
 
27516
 
Function:               Oct6100ApiGetTsiCnctSwSizes
27517
 
 
27518
 
Description:    Gets the sizes of all portions of the API instance pertinent
27519
 
                                to the management the TSI memory.
27520
 
 
27521
 
-------------------------------------------------------------------------------
27522
 
|       Argument                |       Description
27523
 
-------------------------------------------------------------------------------
27524
 
f_pOpenChip                             Pointer to chip configuration struct.
27525
 
f_pInstSizes                    Pointer to struct containing instance sizes.
27526
 
 
27527
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27528
 
static UINT32 Oct6100ApiGetTsiCnctSwSizes(
27529
 
                                IN              tPOCT6100_CHIP_OPEN                             f_pOpenChip,
27530
 
                                OUT             tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
27531
 
{
27532
 
        UINT32  ulTempVar;
27533
 
        UINT32  ulResult;
27534
 
        
27535
 
        /* Determine the amount of memory required for the API TSI connection list. */
27536
 
        f_pInstSizes->ulTsiCnctList = f_pOpenChip->ulMaxTsiCncts * sizeof( tOCT6100_API_TSI_CNCT );
27537
 
 
27538
 
        if ( f_pOpenChip->ulMaxTsiCncts > 0 )
27539
 
        {
27540
 
                /* Calculate memory needed for TSI memory allocation. */
27541
 
                ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxTsiCncts, &f_pInstSizes->ulTsiCnctAlloc );
27542
 
                if ( ulResult != cOCT6100_ERR_OK  )
27543
 
                        return cOCT6100_ERR_FATAL_48;
27544
 
        }
27545
 
        else
27546
 
        {
27547
 
                f_pInstSizes->ulTsiCnctAlloc = 0;
27548
 
        }
27549
 
        
27550
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsiCnctList, ulTempVar )
27551
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsiCnctAlloc, ulTempVar )
27552
 
 
27553
 
        return cOCT6100_ERR_OK;
27554
 
}
27555
 
 
27556
 
 
27557
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27558
 
 
27559
 
Function:               Oct6100ApiTsiCnctSwInit
27560
 
 
27561
 
Description:    Initializes all elements of the instance structure associated
27562
 
                                to the TSI memory.
27563
 
 
27564
 
-------------------------------------------------------------------------------
27565
 
|       Argument                |       Description
27566
 
-------------------------------------------------------------------------------
27567
 
f_pApiInstance                  Pointer to API instance. This memory is used to keep
27568
 
                                                the present state of the chip and all its resources.
27569
 
 
27570
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27571
 
static UINT32 Oct6100ApiTsiCnctSwInit(
27572
 
                                IN OUT  tPOCT6100_INSTANCE_API                  f_pApiInstance )
27573
 
{
27574
 
        tPOCT6100_API_TSI_CNCT  pChannelsTsiList;
27575
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
27576
 
        UINT32  ulMaxTsiChannels;
27577
 
        PVOID   pTsiChannelsAlloc;
27578
 
        UINT32  ulResult;
27579
 
 
27580
 
        /* Get local pointer to shared portion of instance. */
27581
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
27582
 
 
27583
 
        /* Initialize the TSI connections API list. */
27584
 
        ulMaxTsiChannels = pSharedInfo->ChipConfig.usMaxTsiCncts;
27585
 
 
27586
 
        mOCT6100_GET_TSI_CNCT_LIST_PNT( pSharedInfo, pChannelsTsiList )
27587
 
 
27588
 
        /* Clear the memory. */
27589
 
        Oct6100UserMemSet( pChannelsTsiList, 0x00, sizeof(tOCT6100_API_TSI_CNCT) * ulMaxTsiChannels );
27590
 
 
27591
 
        /* Set all entries in the TSI connections list to unused. */
27592
 
        if ( ulMaxTsiChannels > 0 )
27593
 
        {
27594
 
                mOCT6100_GET_TSI_CNCT_ALLOC_PNT( pSharedInfo, pTsiChannelsAlloc )
27595
 
                
27596
 
                ulResult = OctapiLlmAllocInit( &pTsiChannelsAlloc, ulMaxTsiChannels );
27597
 
                if ( ulResult != cOCT6100_ERR_OK )
27598
 
                        return cOCT6100_ERR_FATAL_49;
27599
 
        }
27600
 
        
27601
 
        return cOCT6100_ERR_OK;
27602
 
}
27603
 
 
27604
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27605
 
 
27606
 
File: oct6100_tsst.c
27607
 
 
27608
 
    Copyright (c) 2001-2005 Octasic Inc.
27609
 
    
27610
 
Description: 
27611
 
 
27612
 
        This file contains the functions used to manage the allocation of TSST
27613
 
        control structures in internal memory.
27614
 
 
27615
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
27616
 
free software; you can redistribute it and/or modify it under the terms of 
27617
 
the GNU General Public License as published by the Free Software Foundation; 
27618
 
either version 2 of the License, or (at your option) any later version.
27619
 
 
27620
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
27621
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
27622
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
27623
 
for more details. 
27624
 
 
27625
 
You should have received a copy of the GNU General Public License 
27626
 
along with the OCT6100 GPL API; if not, write to the Free Software 
27627
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27628
 
 
27629
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
27630
 
 
27631
 
$Octasic_Revision: 39 $
27632
 
 
27633
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27634
 
 
27635
 
 
27636
 
/*****************************  INCLUDE FILES  *******************************/
27637
 
 
27638
 
#include "octdef.h"
27639
 
 
27640
 
#include "oct6100api/oct6100_defines.h"
27641
 
#include "oct6100api/oct6100_errors.h"
27642
 
 
27643
 
#include "apilib/octapi_llman.h"
27644
 
 
27645
 
#include "oct6100api/oct6100_apiud.h"
27646
 
#include "oct6100api/oct6100_tlv_inst.h"
27647
 
#include "oct6100api/oct6100_chip_open_inst.h"
27648
 
#include "oct6100api/oct6100_chip_stats_inst.h"
27649
 
#include "oct6100api/oct6100_interrupts_inst.h"
27650
 
#include "oct6100api/oct6100_remote_debug_inst.h"
27651
 
#include "oct6100api/oct6100_debug_inst.h"
27652
 
#include "oct6100api/oct6100_api_inst.h"
27653
 
#include "oct6100api/oct6100_tsst_inst.h"
27654
 
 
27655
 
#include "oct6100api/oct6100_interrupts_pub.h"
27656
 
#include "oct6100api/oct6100_channel_pub.h"
27657
 
#include "oct6100api/oct6100_chip_open_pub.h"
27658
 
 
27659
 
#include "oct6100_chip_open_priv.h"
27660
 
#include "oct6100_tsst_priv.h"
27661
 
 
27662
 
 
27663
 
/****************************  PRIVATE FUNCTIONS  ****************************/
27664
 
 
27665
 
 
27666
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27667
 
 
27668
 
Function:               Oct6100ApiGetTsstSwSizes
27669
 
 
27670
 
Description:    Gets the sizes of all portions of the API instance pertinent
27671
 
                                to the management of TSSTs.
27672
 
 
27673
 
-------------------------------------------------------------------------------
27674
 
|       Argument                |       Description
27675
 
-------------------------------------------------------------------------------
27676
 
f_pInstSizes                    Pointer to struct containing instance sizes.
27677
 
 
27678
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27679
 
static UINT32 Oct6100ApiGetTsstSwSizes(
27680
 
                                OUT             tPOCT6100_API_INSTANCE_SIZES    f_pInstSizes )
27681
 
{
27682
 
        UINT32  ulTempVar;
27683
 
        UINT32  ulResult;
27684
 
 
27685
 
        /* Determine amount of TSST needed for TSST allocation table. */
27686
 
        f_pInstSizes->ulTsstAlloc = 4096 / 8;
27687
 
 
27688
 
        /* Calculate the API memory required for the TSST entry list. */
27689
 
        f_pInstSizes->ulTsstEntryList = cOCT6100_MAX_TSSTS * sizeof( tOCT6100_API_TSST_ENTRY );
27690
 
 
27691
 
        /* Calculate memory needed for TSST entry allocation. */
27692
 
        ulResult = OctapiLlmAllocGetSize( cOCT6100_MAX_TSSTS, &f_pInstSizes->ulTsstEntryAlloc );
27693
 
        if ( ulResult != cOCT6100_ERR_OK )
27694
 
                return cOCT6100_ERR_FATAL_4D;
27695
 
        
27696
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsstAlloc, ulTempVar );
27697
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsstEntryList, ulTempVar );
27698
 
        mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsstEntryAlloc, ulTempVar );
27699
 
 
27700
 
        return cOCT6100_ERR_OK;
27701
 
}
27702
 
 
27703
 
 
27704
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27705
 
 
27706
 
Function:               Oct6100ApiTsstSwInit
27707
 
 
27708
 
Description:    Initializes all elements of the instance structure associated
27709
 
                                to the TSST control entries.
27710
 
 
27711
 
-------------------------------------------------------------------------------
27712
 
|       Argument                |       Description
27713
 
-------------------------------------------------------------------------------
27714
 
f_pApiInstance                  Pointer to API instance. This tsst is used to keep
27715
 
                                                the present state of the chip and all its resources.
27716
 
 
27717
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27718
 
static UINT32 Oct6100ApiTsstSwInit(
27719
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance )
27720
 
{
27721
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
27722
 
        tPOCT6100_API_TSST_ENTRY        pTsstList;
27723
 
        PUINT32 pulTsstAlloc;
27724
 
        PVOID   pTsstListAlloc;
27725
 
        UINT32  ulResult;
27726
 
 
27727
 
        /* Get local pointer(s). */
27728
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
27729
 
 
27730
 
        /* Initialize the TSST allocation table to "all free". */
27731
 
        mOCT6100_GET_TSST_ALLOC_PNT( pSharedInfo, pulTsstAlloc );
27732
 
        Oct6100UserMemSet( pulTsstAlloc, 0x00, 512 );
27733
 
 
27734
 
        /* Initialize all the TSST list entries. */
27735
 
        mOCT6100_GET_TSST_LIST_PNT( pSharedInfo, pTsstList );
27736
 
        Oct6100UserMemSet( pTsstList, 0xFF, cOCT6100_MAX_TSSTS * sizeof(tOCT6100_API_TSST_ENTRY) );
27737
 
 
27738
 
        /* Initialize the allocation list to manage the TSST entries.*/
27739
 
        mOCT6100_GET_TSST_LIST_ALLOC_PNT( pSharedInfo, pTsstListAlloc )
27740
 
        
27741
 
        ulResult = OctapiLlmAllocInit( &pTsstListAlloc, cOCT6100_MAX_TSSTS );
27742
 
        if ( ulResult != cOCT6100_ERR_OK )
27743
 
                return cOCT6100_ERR_FATAL_4E;
27744
 
 
27745
 
        return cOCT6100_ERR_OK;
27746
 
}
27747
 
 
27748
 
 
27749
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27750
 
 
27751
 
Function:               Oct6100ApiValidateTsst
27752
 
 
27753
 
Description:    Validates a timeslot, stream combination.
27754
 
 
27755
 
-------------------------------------------------------------------------------
27756
 
|       Argument                |       Description
27757
 
-------------------------------------------------------------------------------
27758
 
f_pApiInstance                  Pointer to API instance. This tsst is used to keep
27759
 
                                                the present state of the chip and all its resources.
27760
 
 
27761
 
f_ulTimeslot                    Timeslot component of the TDM TSST.
27762
 
f_ulStream                              Stream component of the TDM TSST.
27763
 
f_ulNumTssts                    Number of TSST required.
27764
 
f_ulDirection                   Direction of the TSST (Input or Output).
27765
 
 
27766
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27767
 
static UINT32 Oct6100ApiValidateTsst( 
27768
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance,
27769
 
                                IN              UINT32                                          f_ulNumTssts,
27770
 
                                IN              UINT32                                          f_ulTimeslot,
27771
 
                                IN              UINT32                                          f_ulStream,
27772
 
                                IN              UINT32                                          f_ulDirection )
27773
 
{
27774
 
        tPOCT6100_SHARED_INFO           pSharedInfo;
27775
 
        tPOCT6100_API_CHIP_CONFIG       pChipConfig;    
27776
 
        PUINT32                                         pulTsstAlloc;
27777
 
        
27778
 
        /* Obtain local pointer to shared portion of instance. */
27779
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
27780
 
        
27781
 
        mOCT6100_GET_TSST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pulTsstAlloc );
27782
 
 
27783
 
        /* Obtain local pointer to chip configuration. */
27784
 
        pChipConfig = &pSharedInfo->ChipConfig;
27785
 
 
27786
 
        /* Check the TDM streams, timeslots component for errors. */
27787
 
        if ( f_ulTimeslot == cOCT6100_UNASSIGNED &&
27788
 
                 f_ulStream != cOCT6100_UNASSIGNED )
27789
 
                return cOCT6100_ERR_TSST_TIMESLOT;
27790
 
 
27791
 
        if ( f_ulTimeslot != cOCT6100_UNASSIGNED &&
27792
 
                 f_ulStream == cOCT6100_UNASSIGNED )
27793
 
                return cOCT6100_ERR_TSST_STREAM;
27794
 
 
27795
 
        if ( f_ulStream >= pChipConfig->byMaxTdmStreams )
27796
 
                return cOCT6100_ERR_TSST_STREAM;
27797
 
 
27798
 
        /* Check timeslot value based on the frequenccy of the selected stream. */
27799
 
        switch ( pChipConfig->aulTdmStreamFreqs[ f_ulStream / 4 ] )
27800
 
        {
27801
 
        case cOCT6100_TDM_STREAM_FREQ_2MHZ:
27802
 
                if ( f_ulTimeslot >= 32 )
27803
 
                        return cOCT6100_ERR_TSST_TIMESLOT;
27804
 
                break;
27805
 
        case cOCT6100_TDM_STREAM_FREQ_4MHZ:
27806
 
                if ( f_ulTimeslot >= 64 )
27807
 
                        return cOCT6100_ERR_TSST_TIMESLOT;
27808
 
                break;
27809
 
        case cOCT6100_TDM_STREAM_FREQ_8MHZ:
27810
 
                if ( f_ulTimeslot >= 128 )
27811
 
                        return cOCT6100_ERR_TSST_TIMESLOT;
27812
 
                break;
27813
 
        case cOCT6100_TDM_STREAM_FREQ_16MHZ:
27814
 
                if ( f_ulTimeslot >= 256 )
27815
 
                        return cOCT6100_ERR_TSST_TIMESLOT;
27816
 
 
27817
 
                /* Check the stream value based on the direction. */
27818
 
                if ( f_ulDirection == cOCT6100_INPUT_TSST && f_ulStream >= 16 )
27819
 
                {
27820
 
                        return cOCT6100_ERR_TSST_STREAM;
27821
 
                }
27822
 
                else if( f_ulDirection == cOCT6100_OUTPUT_TSST && f_ulStream < 16 )
27823
 
                {
27824
 
                        return cOCT6100_ERR_TSST_STREAM;
27825
 
                }
27826
 
 
27827
 
                break;
27828
 
        default:
27829
 
                return cOCT6100_ERR_FATAL_DC;
27830
 
        }
27831
 
 
27832
 
        /* Stream must be odd if two TSSTs are required. */
27833
 
        if ( f_ulNumTssts == 2 && ( ( f_ulStream & 0x1) != 0x1 ) )
27834
 
                return cOCT6100_ERR_TSST_STREAM;
27835
 
 
27836
 
        return cOCT6100_ERR_OK;
27837
 
}
27838
 
 
27839
 
 
27840
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27841
 
 
27842
 
Function:               Oct6100ApiReserveTsst
27843
 
 
27844
 
Description:    Reserves a TSST, only one TSI entry can access a TSST at any one
27845
 
                                time.
27846
 
                                If the pointer f_pulTsstListIndex is set to NULL, no TSST list
27847
 
                                entry will be reserved.
27848
 
 
27849
 
                                The index in TSST control memory returned is based on the frequency
27850
 
                                of the streams where the TSST is located and on the direction of 
27851
 
                                the TSST ( input or output ).
27852
 
 
27853
 
-------------------------------------------------------------------------------
27854
 
|       Argument                |       Description
27855
 
-------------------------------------------------------------------------------
27856
 
f_pApiInstance                  Pointer to API instance. This tsst is used to keep
27857
 
                                                the present state of the chip and all its resources.
27858
 
 
27859
 
f_ulTimeslot                    Timeslot component of the TDM TSST.
27860
 
f_ulNumTssts                    Number of TSSTs required.
27861
 
f_ulStream                              Stream component of the TDM TSST.
27862
 
f_ulDirection                   Whether the TSST in and input TSST or output TSST.
27863
 
f_pusTsstMemIndex               Index of the resulting TSST in the TSST control memory.
27864
 
f_pusTsstListIndex              Index in the TSST list of the current entry.
27865
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27866
 
static UINT32 Oct6100ApiReserveTsst( 
27867
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance,
27868
 
                                IN              UINT32                                          f_ulTimeslot,
27869
 
                                IN              UINT32                                          f_ulStream,
27870
 
                                IN              UINT32                                          f_ulNumTsst,
27871
 
                                IN              UINT32                                          f_ulDirection,
27872
 
                                OUT             PUINT16                                         f_pusTsstMemIndex,
27873
 
                                OUT             PUINT16                                         f_pusTsstListIndex )
27874
 
{
27875
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
27876
 
        PVOID   pTsstListAlloc;
27877
 
        PUINT32 pulTsstAlloc;
27878
 
        UINT32  ulResult = cOCT6100_ERR_OK;
27879
 
        UINT32  ulStream;
27880
 
        UINT32  ulTimeslot;
27881
 
 
27882
 
        /* Get local pointer to shared portion of API instance structure. */
27883
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
27884
 
 
27885
 
        mOCT6100_GET_TSST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pulTsstAlloc );
27886
 
 
27887
 
        /*==================================================================================*/
27888
 
        /* Now make the proper conversion to obtain the TSST value. */
27889
 
 
27890
 
        /* Save the timeslot and stream value received. */
27891
 
        ulStream        = f_ulStream;
27892
 
        ulTimeslot      = f_ulTimeslot;
27893
 
 
27894
 
        /* Set the TSST index associated to this stream, timeslot combination. */
27895
 
        switch ( f_pApiInstance->pSharedInfo->ChipConfig.aulTdmStreamFreqs[ f_ulStream / 4 ] )
27896
 
        {
27897
 
        case cOCT6100_TDM_STREAM_FREQ_16MHZ:
27898
 
                if ( f_ulDirection == cOCT6100_INPUT_TSST )
27899
 
                {
27900
 
                        ulStream        = f_ulStream + ( f_ulTimeslot % 2 ) * 16;
27901
 
                        ulTimeslot      = f_ulTimeslot / 2;
27902
 
                }
27903
 
                else /* f_ulDirection == cOCT6100_OUTPUT_TSST */
27904
 
                {
27905
 
                        ulStream        = ( f_ulStream - 16 ) + ( f_ulTimeslot % 2 ) * 16;
27906
 
                        
27907
 
                        if ( f_ulStream < 28 && ((f_ulTimeslot % 2) == 1) )
27908
 
                        {
27909
 
                                ulTimeslot      = ((f_ulTimeslot / 2) + 4) % 128;
27910
 
                        }
27911
 
                        else
27912
 
                        {
27913
 
                                ulTimeslot      = f_ulTimeslot / 2 ;
27914
 
                        }
27915
 
                }
27916
 
 
27917
 
                *f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 + ulStream );
27918
 
                break;
27919
 
 
27920
 
        case cOCT6100_TDM_STREAM_FREQ_8MHZ:
27921
 
                *f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 + ulStream );
27922
 
                break;
27923
 
        
27924
 
        case cOCT6100_TDM_STREAM_FREQ_4MHZ:
27925
 
                *f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 * 2 );
27926
 
                if ( f_ulDirection == cOCT6100_OUTPUT_TSST )
27927
 
                {
27928
 
                        *f_pusTsstMemIndex = (UINT16)( *f_pusTsstMemIndex + ulStream );
27929
 
                }
27930
 
                else /* if ( f_ulDirection == cOCT6100_INPUT_TSST ) */
27931
 
                {
27932
 
                        *f_pusTsstMemIndex = (UINT16)( ( 1 * 32 + ulStream ) + *f_pusTsstMemIndex );
27933
 
                }
27934
 
                break;
27935
 
        
27936
 
        case cOCT6100_TDM_STREAM_FREQ_2MHZ:
27937
 
                *f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 * 4 );
27938
 
                if ( f_ulDirection == cOCT6100_OUTPUT_TSST )
27939
 
                {
27940
 
                        *f_pusTsstMemIndex = (UINT16)( ulStream + *f_pusTsstMemIndex );
27941
 
                }
27942
 
                else /* if ( f_ulDirection == cOCT6100_INPUT_TSST ) */
27943
 
                {
27944
 
                        *f_pusTsstMemIndex = (UINT16)( ( 3 * 32 + ulStream ) + *f_pusTsstMemIndex );
27945
 
                }
27946
 
                break;
27947
 
        
27948
 
        default:
27949
 
                ulResult =  cOCT6100_ERR_FATAL_8B;
27950
 
        }
27951
 
        /*======================================================================*/
27952
 
 
27953
 
 
27954
 
        /*======================================================================*/
27955
 
        /* First reserve the TSST. */
27956
 
 
27957
 
        /* Get local pointer to TSST's entry in allocation table. */
27958
 
        switch ( pSharedInfo->ChipConfig.aulTdmStreamFreqs[ ulStream / 4 ] )
27959
 
        {
27960
 
        case cOCT6100_TDM_STREAM_FREQ_2MHZ:             
27961
 
                ulTimeslot *= 4;        
27962
 
                break;
27963
 
        case cOCT6100_TDM_STREAM_FREQ_4MHZ:             
27964
 
                ulTimeslot *= 2;        
27965
 
                break;
27966
 
        case cOCT6100_TDM_STREAM_FREQ_8MHZ:             
27967
 
                ulTimeslot *= 1;        
27968
 
                break;
27969
 
        case cOCT6100_TDM_STREAM_FREQ_16MHZ:    
27970
 
                ulTimeslot *= 1;        
27971
 
                break;
27972
 
        default:
27973
 
                return cOCT6100_ERR_FATAL_DD;
27974
 
        }
27975
 
 
27976
 
        /* Check if entry is already reserved. */
27977
 
        if ( ((pulTsstAlloc[ ulTimeslot ] >> ulStream) & 0x1) == 0x1 )
27978
 
                return cOCT6100_ERR_TSST_TSST_RESERVED;
27979
 
        
27980
 
        /* Check and reserve the associated TSST if required. */
27981
 
        if ( f_ulNumTsst == 2 )
27982
 
        {
27983
 
                /* Check if entry is already reserved. */
27984
 
                if ( ((pulTsstAlloc[ ulTimeslot ] >> (ulStream - 1) ) & 0x1) == 0x1 )
27985
 
                        return cOCT6100_ERR_TSST_ASSOCIATED_TSST_RESERVED;
27986
 
 
27987
 
                /* The entry is free, it won't anymore. */
27988
 
                pulTsstAlloc[ ulTimeslot ] |= (0x1 << (ulStream - 1));
27989
 
        }
27990
 
 
27991
 
        /* The entry is free, it won't anymore.*/
27992
 
        pulTsstAlloc[ ulTimeslot ] |= (0x1 << ulStream);
27993
 
 
27994
 
        /*======================================================================*/
27995
 
 
27996
 
        
27997
 
        /*======================================================================*/
27998
 
        /* Now reserve a TSST entry if requested. */
27999
 
 
28000
 
        if ( f_pusTsstListIndex != NULL && ulResult == cOCT6100_ERR_OK )
28001
 
        {
28002
 
                UINT32 ulTsstListIndex;
28003
 
 
28004
 
                /* Reserve a TSST entry in the API TSST list. */
28005
 
                mOCT6100_GET_TSST_LIST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pTsstListAlloc );
28006
 
 
28007
 
                ulResult = OctapiLlmAllocAlloc( pTsstListAlloc, &ulTsstListIndex );
28008
 
                if ( ulResult != cOCT6100_ERR_OK )
28009
 
                {
28010
 
                        if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
28011
 
                                ulResult = cOCT6100_ERR_TSST_ALL_TSSTS_ARE_OPENED;
28012
 
                        else
28013
 
                                ulResult = cOCT6100_ERR_FATAL_52;
28014
 
                }
28015
 
 
28016
 
                *f_pusTsstListIndex = (UINT16)( ulTsstListIndex & 0xFFFF );
28017
 
        }
28018
 
        /*======================================================================*/
28019
 
        
28020
 
 
28021
 
        /*======================================================================*/
28022
 
        /* Check the result of the TSST list reservation. */
28023
 
 
28024
 
        if ( ulResult != cOCT6100_ERR_OK )
28025
 
        {
28026
 
                /* Release the previously reserved TSST. */
28027
 
                if ( f_ulNumTsst == 2  )
28028
 
                {
28029
 
                        /* Clear the entry. */
28030
 
                        pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << (ulStream - 1) );
28031
 
 
28032
 
                }
28033
 
 
28034
 
                /* Clear the entry. */
28035
 
                pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << ulStream);
28036
 
        }
28037
 
 
28038
 
        /*======================================================================*/
28039
 
 
28040
 
        return ulResult;
28041
 
}
28042
 
 
28043
 
 
28044
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28045
 
 
28046
 
Function:               Oct6100ApiReleaseTsst
28047
 
 
28048
 
Description:    Releases a TSST.
28049
 
 
28050
 
                                If f_usTsstListIndex is set to cOCT6100_INVALID_INDEX, the API
28051
 
                                will assume that no TSST list entry was reserved for this TSST.
28052
 
 
28053
 
-------------------------------------------------------------------------------
28054
 
|       Argument                |       Description
28055
 
-------------------------------------------------------------------------------
28056
 
f_pApiInstance                  Pointer to API instance. This tsst is used to keep
28057
 
                                                the present state of the chip and all its resources.
28058
 
 
28059
 
f_ulNumTssts                    Number of TSSTs to be released.
28060
 
f_ulStream                              Stream component of the TDM TSST.
28061
 
f_ulTimeslot                    Timeslot component of the TDM TSST.
28062
 
f_ulDirection                   Whether the TSST is an input TSST or output TSST.
28063
 
f_usTsstListIndex               Index in the TSST list of the current entry.
28064
 
 
28065
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28066
 
static UINT32 Oct6100ApiReleaseTsst( 
28067
 
                                IN OUT  tPOCT6100_INSTANCE_API          f_pApiInstance,
28068
 
                                IN              UINT32                                          f_ulTimeslot,
28069
 
                                IN              UINT32                                          f_ulStream,
28070
 
                                IN              UINT32                                          f_ulNumTsst,
28071
 
                                IN              UINT32                                          f_ulDirection,
28072
 
                                IN              UINT16                                          f_usTsstListIndex)
28073
 
{
28074
 
        tPOCT6100_SHARED_INFO   pSharedInfo;
28075
 
        PUINT32 pulTsstAlloc;
28076
 
        PVOID   pTsstListAlloc;
28077
 
        UINT32  ulResult;
28078
 
        UINT32  ulStream;
28079
 
        UINT32  ulTimeslot;
28080
 
 
28081
 
        /* Get local pointer to shared portion of API instance structure. */
28082
 
        pSharedInfo = f_pApiInstance->pSharedInfo;
28083
 
 
28084
 
        if ( f_usTsstListIndex != cOCT6100_INVALID_INDEX )
28085
 
        {
28086
 
                mOCT6100_GET_TSST_LIST_ALLOC_PNT( pSharedInfo, pTsstListAlloc )
28087
 
        
28088
 
                ulResult = OctapiLlmAllocDealloc( pTsstListAlloc, f_usTsstListIndex );
28089
 
                if ( ulResult != cOCT6100_ERR_OK )
28090
 
                {
28091
 
                        return cOCT6100_ERR_FATAL_53;
28092
 
                }
28093
 
        }
28094
 
 
28095
 
        mOCT6100_GET_TSST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pulTsstAlloc );
28096
 
 
28097
 
        /*==================================================================================*/
28098
 
        /* Now make the proper conversion to obtain the TSST value. */
28099
 
 
28100
 
        /* Save the timeslot and stream value received. */
28101
 
        ulStream        = f_ulStream;
28102
 
        ulTimeslot      = f_ulTimeslot;
28103
 
        
28104
 
        /* Set the TSST index associated to this stream, timeslot combination. */
28105
 
        if ( pSharedInfo->ChipConfig.aulTdmStreamFreqs[ f_ulStream / 4 ] == cOCT6100_TDM_STREAM_FREQ_16MHZ )
28106
 
        {
28107
 
                if ( f_ulDirection == cOCT6100_INPUT_TSST )
28108
 
                {
28109
 
                        ulStream        = f_ulStream + ( f_ulTimeslot % 2 ) * 16;
28110
 
                        ulTimeslot      = f_ulTimeslot / 2;
28111
 
                }
28112
 
                else /* f_ulDirection == cOCT6100_OUTPUT_TSST */
28113
 
                {
28114
 
                        ulStream        = ( f_ulStream - 16 ) + ( f_ulTimeslot % 2 ) * 16;
28115
 
                        
28116
 
                        if ( f_ulStream < 28 && ((f_ulTimeslot % 2) == 1) )
28117
 
                        {
28118
 
                                ulTimeslot      = ((f_ulTimeslot / 2) + 4) % 128;
28119
 
                        }
28120
 
                        else
28121
 
                        {
28122
 
                                ulTimeslot      = f_ulTimeslot / 2 ;
28123
 
                        }
28124
 
                }
28125
 
        }
28126
 
 
28127
 
        /* Get local pointer to TSST's entry in allocation table. */
28128
 
        switch ( pSharedInfo->ChipConfig.aulTdmStreamFreqs[ ulStream / 4 ] )
28129
 
        {
28130
 
        case cOCT6100_TDM_STREAM_FREQ_2MHZ:             
28131
 
                ulTimeslot *= 4;        
28132
 
                break;
28133
 
        case cOCT6100_TDM_STREAM_FREQ_4MHZ:             
28134
 
                ulTimeslot *= 2;        
28135
 
                break;
28136
 
        case cOCT6100_TDM_STREAM_FREQ_8MHZ:             
28137
 
                ulTimeslot *= 1;        
28138
 
                break;
28139
 
        case cOCT6100_TDM_STREAM_FREQ_16MHZ:    
28140
 
                ulTimeslot *= 1;        
28141
 
                break;
28142
 
        default:
28143
 
                return cOCT6100_ERR_FATAL_DE;
28144
 
        }
28145
 
 
28146
 
        /* Check if entry is actualy reserved. */
28147
 
        if ( ((pulTsstAlloc[ ulTimeslot ] >> ulStream) & 0x1) != 0x1 )
28148
 
                return cOCT6100_ERR_FATAL_55;
28149
 
 
28150
 
        /*==================================================================================*/
28151
 
 
28152
 
        /* Clear the entry. */
28153
 
        pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << ulStream);
28154
 
 
28155
 
        /* Check and release the associated TSST if required. */
28156
 
        if ( f_ulNumTsst == 2 )
28157
 
        {
28158
 
                /* Check if entry is actualy reserved. */
28159
 
                if ( ((pulTsstAlloc[ ulTimeslot ] >> ( ulStream - 1)) & 0x1) != 0x1 )
28160
 
                        return cOCT6100_ERR_FATAL_54;
28161
 
                
28162
 
                /* Clear the entry. */
28163
 
                pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << (ulStream - 1));
28164
 
 
28165
 
        }
28166
 
 
28167
 
        return cOCT6100_ERR_OK;
28168
 
}
28169
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28170
 
 
28171
 
File:  octapi_llman.c
28172
 
 
28173
 
    Copyright (c) 2001-2005 Octasic Inc.
28174
 
    
28175
 
Description: 
28176
 
 
28177
 
        Library used to manage allocation tables and linked lists.  The library is
28178
 
        made such that only a block of contiguous memory is needed for the
28179
 
        management of the linked list/allocation table.
28180
 
 
28181
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
28182
 
free software; you can redistribute it and/or modify it under the terms of 
28183
 
the GNU General Public License as published by the Free Software Foundation; 
28184
 
either version 2 of the License, or (at your option) any later version.
28185
 
 
28186
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
28187
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
28188
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
28189
 
for more details. 
28190
 
 
28191
 
You should have received a copy of the GNU General Public License 
28192
 
along with the OCT6100 GPL API; if not, write to the Free Software 
28193
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28194
 
 
28195
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
28196
 
 
28197
 
$Octasic_Revision: 21 $
28198
 
 
28199
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28200
 
#include "octapi_llman_private.h"
28201
 
#include "apilib/octapi_llman.h"
28202
 
#include "apilib/octapi_largmath.h"
28203
 
 
28204
 
 
28205
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28206
 
|       API UTILITIES
28207
 
|
28208
 
|       Function:               OctapiLlmAllocGetSize.
28209
 
|
28210
 
|       Description:    This function determines the amount of memory needed to
28211
 
|                                       manage the allocation of a fixed amount of resources.
28212
 
|                                       The memory is measured in bytes.
28213
 
|
28214
 
|  -----------------------------------------------------------------------  
28215
 
|  |   Variable        |     Type     |          Description                
28216
 
|  -----------------------------------------------------------------------  
28217
 
|       number_of_items         UINT32                  The number of resources to be allocated.
28218
 
|       *l_size UINT32          UINT32                  The amount of memory needed, returned.
28219
 
|
28220
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28221
 
static UINT32 OctapiLlmAllocGetSize(UINT32 number_of_items,UINT32 * l_size)
28222
 
{
28223
 
        if (number_of_items == 0) return(GENERIC_BAD_PARAM);
28224
 
 
28225
 
        *l_size = (sizeof(LLM_ALLOC)) + (number_of_items * sizeof(UINT32));
28226
 
 
28227
 
        return(GENERIC_OK);
28228
 
}
28229
 
 
28230
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28231
 
|       API UTILITIES
28232
 
|
28233
 
|       Function:               OctapiLlmAllocInit.
28234
 
|
28235
 
|       Description:    This function intializes the LLM_ALLOC structure.
28236
 
|
28237
 
|  -----------------------------------------------------------------------  
28238
 
|  |   Variable        |     Type     |          Description                
28239
 
|  -----------------------------------------------------------------------  
28240
 
|       **l                                     void                    The memory used by the LLM_ALLOC structure.
28241
 
|       number_of_items         UINT32                  The number of resources to be allocated.
28242
 
|
28243
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28244
 
static UINT32 OctapiLlmAllocInit(void ** l,UINT32 number_of_items)
28245
 
{
28246
 
        LLM_ALLOC* ls;
28247
 
        UINT32 i;
28248
 
 
28249
 
        /* Check the number of items required.*/
28250
 
        if (number_of_items == 0) return(GENERIC_BAD_PARAM);
28251
 
 
28252
 
        /* If no memory has been allocated yet:*/
28253
 
        if (*l == NULL) return(OCTAPI_LLM_MEMORY_NOT_ALLOCATED);
28254
 
 
28255
 
        /* Build the structure before starting.*/
28256
 
        ls = (LLM_ALLOC *)(*l);
28257
 
        ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC));
28258
 
 
28259
 
        ls->number_of_items = number_of_items;
28260
 
 
28261
 
        /* Linked list links all structures in ascending order.*/
28262
 
        for(i=0;i<number_of_items;i++)
28263
 
        {
28264
 
                ls->linked_list[i] = i+1;
28265
 
        }
28266
 
 
28267
 
        ls->linked_list[number_of_items - 1] = 0xFFFFFFFF; /* Invalid link.*/
28268
 
 
28269
 
        /* Next avail is 0.*/
28270
 
        ls->next_avail_num = 0;
28271
 
 
28272
 
        /* Number of allocated items is null.*/
28273
 
        ls->allocated_items = 0;
28274
 
 
28275
 
        return(GENERIC_OK);
28276
 
}
28277
 
 
28278
 
 
28279
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28280
 
|       API UTILITIES
28281
 
|
28282
 
|       Function:               OctapiLlmAllocInfo.
28283
 
|
28284
 
|       Description:    This function returns the number of free and allocated
28285
 
|                                       block in the LLMAN list.
28286
 
|
28287
 
|  -----------------------------------------------------------------------  
28288
 
|  |   Variable        |     Type     |          Description                
28289
 
|  -----------------------------------------------------------------------  
28290
 
|       *l                                      void                    The memory used by the LLM_ALLOC structure.
28291
 
|       *allocated_items        UINT32                  Number of allocated items.
28292
 
|       *available_items        UINT32                  Number of available items.
28293
 
|
28294
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28295
 
static UINT32 OctapiLlmAllocInfo(void * l,UINT32 * allocated_items,UINT32 * available_items)
28296
 
{
28297
 
        LLM_ALLOC* ls;
28298
 
 
28299
 
        /* Build the structure before starting.*/
28300
 
        ls = (LLM_ALLOC *)l;
28301
 
        ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC));
28302
 
 
28303
 
        *allocated_items = ls->allocated_items;
28304
 
        *available_items = ls->number_of_items - ls->allocated_items;
28305
 
        return(GENERIC_OK);
28306
 
}
28307
 
 
28308
 
 
28309
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28310
 
|       API UTILITIES
28311
 
|
28312
 
|       Function:               OctapiLlmAllocInfo.
28313
 
|
28314
 
|       Description:    This function allocates the resource indicated by blocknum.
28315
 
|                                       If the resource can be allocated then GENERIC_OK is returned.  
28316
 
|                                       Else an error.
28317
 
|
28318
 
|  -----------------------------------------------------------------------  
28319
 
|  |   Variable        |     Type     |          Description                
28320
 
|  -----------------------------------------------------------------------  
28321
 
|       *l                                      void                    The memory used by the LLM_ALLOC structure.
28322
 
|       *block_num                      UINT32                  The resource to be allocated.
28323
 
|
28324
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28325
 
static UINT32 OctapiLlmAllocAlloc(void * l,UINT32 * blocknum)
28326
 
{
28327
 
        LLM_ALLOC* ls;
28328
 
        UINT32 allocated_block;
28329
 
        UINT32* node;
28330
 
 
28331
 
        /* Build the structure before starting.*/
28332
 
        ls = (LLM_ALLOC *)l;
28333
 
        ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC));
28334
 
 
28335
 
        /* Get next available block number.*/
28336
 
        allocated_block = ls->next_avail_num;
28337
 
 
28338
 
        /* Check if block is invalid.*/
28339
 
        if (allocated_block == 0xFFFFFFFF)
28340
 
        {
28341
 
                /* Make blocknum NULL.*/
28342
 
                *blocknum = 0xFFFFFFFF;
28343
 
 
28344
 
                return(OCTAPI_LLM_NO_STRUCTURES_LEFT);
28345
 
        }
28346
 
 
28347
 
        node = &ls->linked_list[allocated_block];
28348
 
 
28349
 
        /* Copy next block number.*/
28350
 
        ls->next_avail_num = *node;
28351
 
 
28352
 
        /* Tag as used the current block number.*/
28353
 
        *node = 0xFFFFFFFE;
28354
 
 
28355
 
        /* Return proper block number.*/
28356
 
        *blocknum = allocated_block;
28357
 
 
28358
 
        /* Update block usage number.*/
28359
 
        ls->allocated_items++;
28360
 
 
28361
 
        return(GENERIC_OK);
28362
 
}
28363
 
 
28364
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28365
 
|       API UTILITIES
28366
 
|
28367
 
|       Function:               OctapiLlmAllocDealloc.
28368
 
|
28369
 
|       Description:    This function deallocates the resource indicated by blocknum.
28370
 
|                                       If the resource is not already allocated an error is returned.
28371
 
|                                       Else GENERIC_OK is returned.
28372
 
|
28373
 
|  -----------------------------------------------------------------------  
28374
 
|  |   Variable        |     Type     |          Description                
28375
 
|  -----------------------------------------------------------------------  
28376
 
|       *l                                      void                    The memory used by the LLM_ALLOC structure.
28377
 
|       block_num                       UINT32                  The resource to be deallocated.
28378
 
|
28379
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28380
 
static UINT32 OctapiLlmAllocDealloc(void * l,UINT32 blocknum)
28381
 
{
28382
 
        LLM_ALLOC* ls;
28383
 
        UINT32* node;
28384
 
 
28385
 
        /* Build the structure before starting.*/
28386
 
        ls = (LLM_ALLOC *)l;
28387
 
        ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC));
28388
 
        
28389
 
        /* Check for null item pointer.*/
28390
 
        if (blocknum == 0xFFFFFFFF) return(GENERIC_OK);
28391
 
 
28392
 
        /* Check if blocknum is within specified item range.*/
28393
 
        if (blocknum >= ls->number_of_items) return(OCTAPI_LLM_BLOCKNUM_OUT_OF_RANGE);
28394
 
 
28395
 
        node = &ls->linked_list[blocknum];
28396
 
 
28397
 
        /* Check if block is really used as of now.*/
28398
 
        if (*node != 0xFFFFFFFE) return(OCTAPI_LLM_MEMORY_NOT_ALLOCATED);
28399
 
 
28400
 
        /* Add link to list.*/
28401
 
        *node = ls->next_avail_num;
28402
 
 
28403
 
        /* Point to returned block.*/
28404
 
        ls->next_avail_num = blocknum;
28405
 
 
28406
 
        /* Update block usage number.*/
28407
 
        ls->allocated_items--;
28408
 
 
28409
 
        return(GENERIC_OK);
28410
 
}
28411
 
 
28412
 
/**************************************** llm_list section **********************************************/
28413
 
 
28414
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28415
 
 
28416
 
File:  octapi_bt0.c
28417
 
 
28418
 
    Copyright (c) 2001-2005 Octasic Inc.
28419
 
    
28420
 
Description: 
28421
 
 
28422
 
        Library used to manage a binary tree of variable max size.  Library is
28423
 
        made to use one block of contiguous memory to manage the tree.
28424
 
 
28425
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
28426
 
free software; you can redistribute it and/or modify it under the terms of 
28427
 
the GNU General Public License as published by the Free Software Foundation; 
28428
 
either version 2 of the License, or (at your option) any later version.
28429
 
 
28430
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
28431
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
28432
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
28433
 
for more details. 
28434
 
 
28435
 
You should have received a copy of the GNU General Public License 
28436
 
along with the OCT6100 GPL API; if not, write to the Free Software 
28437
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28438
 
 
28439
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
28440
 
 
28441
 
$Octasic_Revision: 18 $
28442
 
 
28443
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28444
 
#include "apilib/octapi_bt0.h"
28445
 
#include "octapi_bt0_private.h"
28446
 
 
28447
 
 
28448
 
 
28449
 
static UINT32 OctApiBt0GetSize(UINT32 number_of_items,UINT32 key_size, UINT32 data_size, UINT32 * b_size)
28450
 
{
28451
 
        if ((key_size % 4) != 0) return(OCTAPI_BT0_KEY_SIZE_NOT_MUTLIPLE_OF_UINT32);
28452
 
        if ((data_size % 4) != 0) return(OCTAPI_BT0_DATA_SIZE_NOT_MUTLIPLE_OF_UINT32);
28453
 
 
28454
 
        *b_size = 0;
28455
 
        *b_size += sizeof(OCTAPI_BT0);
28456
 
        *b_size += sizeof(OCTAPI_BT0_NODE) * number_of_items;
28457
 
        *b_size += key_size * number_of_items;
28458
 
        *b_size += data_size * number_of_items;
28459
 
 
28460
 
        return(GENERIC_OK);
28461
 
}
28462
 
 
28463
 
static UINT32 OctApiBt0Init(void ** b,UINT32 number_of_items,UINT32 key_size, UINT32 data_size)
28464
 
{
28465
 
        UINT32 i;
28466
 
        OCTAPI_BT0 * bb;
28467
 
 
28468
 
        /* Check input parameters.*/
28469
 
        if ((key_size % 4) != 0) return(OCTAPI_BT0_KEY_SIZE_NOT_MUTLIPLE_OF_UINT32);
28470
 
        if ((data_size % 4) != 0) return(OCTAPI_BT0_DATA_SIZE_NOT_MUTLIPLE_OF_UINT32);
28471
 
 
28472
 
        /* If b is not already allocated.*/
28473
 
        if (*b == NULL) return(OCTAPI_BT0_MALLOC_FAILED);
28474
 
 
28475
 
        bb = (OCTAPI_BT0 *)(*b);
28476
 
 
28477
 
        /* Initialize the tree to an empty one!*/
28478
 
        bb->root_link.node_number = 0xFFFFFFFF;
28479
 
        bb->root_link.depth = 0;
28480
 
 
28481
 
        /* Initialize tree parameters.*/
28482
 
        bb->number_of_items = number_of_items;
28483
 
        bb->key_size = key_size / 4;
28484
 
        bb->data_size = data_size / 4;
28485
 
 
28486
 
        /* Initialize the next free node pointer.*/
28487
 
        if (number_of_items != 0)
28488
 
                bb->next_free_node = 0;
28489
 
        else
28490
 
                bb->next_free_node = 0xFFFFFFFF;
28491
 
 
28492
 
        /* Setup the arrays.*/
28493
 
        OctApiBt0CorrectPointers(bb);
28494
 
 
28495
 
        /* Initialize the Nodes to unused!*/
28496
 
        for(i=0;i<number_of_items;i++)
28497
 
        {
28498
 
                bb->node[i].next_free_node = i + 1;
28499
 
        }
28500
 
 
28501
 
        /* Last empty node points to invalid node.*/
28502
 
        bb->node[number_of_items-1].next_free_node = 0xFFFFFFFF;
28503
 
 
28504
 
        bb->invalid_value = 0xFFFFFFFF;
28505
 
        bb->no_smaller_key = OCTAPI_BT0_NO_SMALLER_KEY;
28506
 
 
28507
 
        return(GENERIC_OK);
28508
 
}
28509
 
 
28510
 
 
28511
 
void OctApiBt0CorrectPointers(OCTAPI_BT0 * bb)
28512
 
{
28513
 
        bb->node = (OCTAPI_BT0_NODE *)(((BYTE *)bb) + sizeof(OCTAPI_BT0));
28514
 
        bb->key = (UINT32 *)(((BYTE *)bb->node) + (sizeof(OCTAPI_BT0_NODE) * bb->number_of_items));
28515
 
        bb->data = (UINT32 *)(((BYTE *)bb->key) + (sizeof(UINT32) * bb->number_of_items * bb->key_size));
28516
 
}
28517
 
 
28518
 
 
28519
 
static UINT32 OctApiBt0AddNode2(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 new_node_number)
28520
 
{
28521
 
        UINT32 result;
28522
 
 
28523
 
        if (link->node_number == 0xFFFFFFFF) /* We have an empty node. Here, we shall place the new node.*/
28524
 
        {
28525
 
                bb->node[new_node_number].l[0].node_number = 0xFFFFFFFF;
28526
 
                bb->node[new_node_number].l[0].depth = 0;
28527
 
                bb->node[new_node_number].l[1].node_number = 0xFFFFFFFF;
28528
 
                bb->node[new_node_number].l[1].depth = 0;
28529
 
 
28530
 
                /* OCTAPI_BT0_LINK to parent!*/
28531
 
                link->node_number = new_node_number;
28532
 
                link->depth = 1;                                /* We are a leaf, last OCTAPI_BT0_LINK depth is 1.*/
28533
 
 
28534
 
                return(GENERIC_OK);
28535
 
        }
28536
 
        else /* Current node is used, check for a match and a direction.*/
28537
 
        {
28538
 
                OCTAPI_BT0_NODE * this_node;
28539
 
                UINT32 compare;
28540
 
 
28541
 
                /* Get a pointer to this node.*/
28542
 
                this_node = &(bb->node[link->node_number]);
28543
 
 
28544
 
                /* Compare this node to the lkey.*/
28545
 
                compare = OctApiBt0KeyCompare(bb,link,lkey);
28546
 
 
28547
 
                if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/
28548
 
                {
28549
 
                        result = OctApiBt0AddNode2(bb,&(this_node->l[0]), lkey, new_node_number);
28550
 
                        if (result != GENERIC_OK) return(result);
28551
 
                }
28552
 
                else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/
28553
 
                {
28554
 
                        result = OctApiBt0AddNode2(bb,&(this_node->l[1]), lkey, new_node_number);
28555
 
                        if (result != GENERIC_OK) return(result);
28556
 
                }
28557
 
                else
28558
 
                {
28559
 
                        return(OCTAPI_BT0_KEY_ALREADY_IN_TREE);
28560
 
                }
28561
 
 
28562
 
                /* Check if this node is unbalanced by 2. If so, rebalance it:*/
28563
 
                if (this_node->l[0].depth > (this_node->l[1].depth + 1) || 
28564
 
                                this_node->l[1].depth > (this_node->l[0].depth + 1))
28565
 
                {
28566
 
                        OctApiBt0Rebalance(bb,link);
28567
 
                }
28568
 
 
28569
 
                /* Always update the OCTAPI_BT0_LINK depth before exiting.*/
28570
 
                OctApiBt0UpdateLinkDepth(bb,link);
28571
 
 
28572
 
                return(GENERIC_OK);
28573
 
        }
28574
 
}
28575
 
 
28576
 
 
28577
 
static UINT32 OctApiBt0AddNode3(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 *p_new_node_number)
28578
 
{
28579
 
        UINT32 result;
28580
 
 
28581
 
        if (link->node_number == 0xFFFFFFFF) /* We have an empty node. Here, we shall place the new node.*/
28582
 
        {
28583
 
                if ( *p_new_node_number == 0xFFFFFFFF )
28584
 
                        return(OCTAPI_BT0_NO_NODES_AVAILABLE);
28585
 
 
28586
 
                bb->node[*p_new_node_number].l[0].node_number = 0xFFFFFFFF;
28587
 
                bb->node[*p_new_node_number].l[0].depth = 0;
28588
 
                bb->node[*p_new_node_number].l[1].node_number = 0xFFFFFFFF;
28589
 
                bb->node[*p_new_node_number].l[1].depth = 0;
28590
 
 
28591
 
                /* OCTAPI_BT0_LINK to parent!*/
28592
 
                link->node_number = *p_new_node_number;
28593
 
                link->depth = 1;                                /* We are a leaf, last OCTAPI_BT0_LINK depth is 1.*/
28594
 
 
28595
 
                return(GENERIC_OK);
28596
 
        }
28597
 
        else /* Current node is used, check for a match and a direction.*/
28598
 
        {
28599
 
                OCTAPI_BT0_NODE * this_node;
28600
 
                UINT32 compare;
28601
 
 
28602
 
                /* Get a pointer to this node.*/
28603
 
                this_node = &(bb->node[link->node_number]);
28604
 
 
28605
 
                /* Compare this node to the lkey.*/
28606
 
                compare = OctApiBt0KeyCompare(bb,link,lkey);
28607
 
 
28608
 
                if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/
28609
 
                {
28610
 
                        result = OctApiBt0AddNode3(bb,&(this_node->l[0]), lkey, p_new_node_number);
28611
 
                        if (result != GENERIC_OK) return(result);
28612
 
                }
28613
 
                else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/
28614
 
                {
28615
 
                        result = OctApiBt0AddNode3(bb,&(this_node->l[1]), lkey, p_new_node_number);
28616
 
                        if (result != GENERIC_OK) return(result);
28617
 
                }
28618
 
                else
28619
 
                {
28620
 
                        *p_new_node_number = link->node_number;
28621
 
                        return(OCTAPI_BT0_KEY_ALREADY_IN_TREE);
28622
 
                }
28623
 
 
28624
 
                /* Check if this node is unbalanced by 2. If so, rebalance it:*/
28625
 
                if (this_node->l[0].depth > (this_node->l[1].depth + 1) || 
28626
 
                                this_node->l[1].depth > (this_node->l[0].depth + 1))
28627
 
                {
28628
 
                        OctApiBt0Rebalance(bb,link);
28629
 
                }
28630
 
 
28631
 
                /* Always update the OCTAPI_BT0_LINK depth before exiting.*/
28632
 
                OctApiBt0UpdateLinkDepth(bb,link);
28633
 
 
28634
 
                return(GENERIC_OK);
28635
 
        }
28636
 
}
28637
 
 
28638
 
/* state 
28639
 
0 -> first call to the function.
28640
 
1 -> recursive call.*/
28641
 
static UINT32 OctApiBt0AddNode4(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 *p_new_node_number, UINT32 *p_prev_node_number, UINT32 state )
28642
 
{
28643
 
        UINT32 result;
28644
 
        UINT32 *nkey;
28645
 
        UINT32 *okey;
28646
 
 
28647
 
        if (link->node_number == 0xFFFFFFFF) /* We have an empty node. Here, we shall place the new node.*/
28648
 
        {
28649
 
                bb->node[*p_new_node_number].l[0].node_number = 0xFFFFFFFF;
28650
 
                bb->node[*p_new_node_number].l[0].depth = 0;
28651
 
                bb->node[*p_new_node_number].l[1].node_number = 0xFFFFFFFF;
28652
 
                bb->node[*p_new_node_number].l[1].depth = 0;
28653
 
 
28654
 
                /* OCTAPI_BT0_LINK to parent!*/
28655
 
                link->node_number = *p_new_node_number;
28656
 
                link->depth = 1;                                /* We are a leaf, last OCTAPI_BT0_LINK depth is 1.*/
28657
 
 
28658
 
                if ( state == 0 )
28659
 
                        *p_prev_node_number = 0xFFFFFFFF;
28660
 
 
28661
 
                return(GENERIC_OK);
28662
 
        }
28663
 
        else /* Current node is used, check for a match and a direction.*/
28664
 
        {
28665
 
                OCTAPI_BT0_NODE * this_node;
28666
 
                UINT32 compare;
28667
 
 
28668
 
                /* Get a pointer to this node.*/
28669
 
                this_node = &(bb->node[link->node_number]);
28670
 
 
28671
 
                /* Compare this node to the lkey.*/
28672
 
                compare = OctApiBt0KeyCompare(bb,link,lkey);
28673
 
 
28674
 
                if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/
28675
 
                {
28676
 
                        if ( state == 0 )
28677
 
                                *p_prev_node_number = OCTAPI_BT0_NO_SMALLER_KEY;
28678
 
                        
28679
 
                        if ( *p_prev_node_number != OCTAPI_BT0_NO_SMALLER_KEY )
28680
 
                        {
28681
 
                                /* Check if the key is the smallest one encountered yet.*/
28682
 
                                okey = &(bb->key[bb->key_size * (*p_prev_node_number)]);
28683
 
                                nkey = &(bb->key[bb->key_size * link->node_number]);
28684
 
                                /* If the node is key smaller then the old small one, change the value.*/
28685
 
                                if ( *nkey > *okey )
28686
 
                                {
28687
 
                                        if ( *nkey < *lkey      )
28688
 
                                                *p_prev_node_number = link->node_number;
28689
 
                                }
28690
 
                        }
28691
 
 
28692
 
                        result = OctApiBt0AddNode4(bb,&(this_node->l[0]), lkey, p_new_node_number, p_prev_node_number, 1);
28693
 
                        if (result != GENERIC_OK) return(result);
28694
 
                }
28695
 
                else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/
28696
 
                {
28697
 
                        if ( state == 0 )
28698
 
                                *p_prev_node_number = link->node_number;
28699
 
                        else
28700
 
                        {
28701
 
                                if ( *p_prev_node_number  == OCTAPI_BT0_NO_SMALLER_KEY )
28702
 
                                        *p_prev_node_number = link->node_number;
28703
 
                                else
28704
 
                                {
28705
 
                                        /* Check if the key is the smallest one encountered yet.*/
28706
 
                                        okey = &(bb->key[bb->key_size * (*p_prev_node_number)]);
28707
 
                                        nkey = &(bb->key[bb->key_size * link->node_number]);
28708
 
                                        /* If the node is key smaller then the old small one, change the value.*/
28709
 
                                        if ( *nkey > *okey )
28710
 
                                        {
28711
 
                                                if ( *nkey < *lkey      )
28712
 
                                                        *p_prev_node_number = link->node_number;
28713
 
                                        }
28714
 
                                }
28715
 
                        }
28716
 
 
28717
 
                        result = OctApiBt0AddNode4(bb,&(this_node->l[1]), lkey, p_new_node_number, p_prev_node_number, 1);
28718
 
                        if (result != GENERIC_OK) return(result);
28719
 
                }
28720
 
                else
28721
 
                {
28722
 
                        *p_new_node_number = link->node_number;
28723
 
                        return(OCTAPI_BT0_KEY_ALREADY_IN_TREE);
28724
 
                }
28725
 
 
28726
 
                /* Check if this node is unbalanced by 2. If so, rebalance it:*/
28727
 
                if (this_node->l[0].depth > (this_node->l[1].depth + 1) || 
28728
 
                                this_node->l[1].depth > (this_node->l[0].depth + 1))
28729
 
                {
28730
 
                        OctApiBt0Rebalance(bb,link);
28731
 
                }
28732
 
 
28733
 
                /* Always update the OCTAPI_BT0_LINK depth before exiting.*/
28734
 
                OctApiBt0UpdateLinkDepth(bb,link);
28735
 
 
28736
 
                return(GENERIC_OK);
28737
 
        }
28738
 
}
28739
 
 
28740
 
static UINT32 OctApiBt0KeyCompare(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link, UINT32 * lkey)
28741
 
{
28742
 
        UINT32 * nkey;
28743
 
        UINT32 i;
28744
 
 
28745
 
        /* Find the first UINT32 of the key.*/
28746
 
        nkey = &(bb->key[bb->key_size * link->node_number]);
28747
 
 
28748
 
        for(i=0;i<bb->key_size;i++)
28749
 
        {
28750
 
                if (lkey[i] < nkey[i])
28751
 
                        return(OCTAPI_BT0_LKEY_SMALLER);
28752
 
                else if (lkey[i] > nkey[i])
28753
 
                        return(OCTAPI_BT0_LKEY_LARGER);
28754
 
        }       
28755
 
        
28756
 
        return(OCTAPI_BT0_LKEY_EQUAL);
28757
 
}
28758
 
 
28759
 
 
28760
 
void OctApiBt0UpdateLinkDepth(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link)
28761
 
{
28762
 
        OCTAPI_BT0_NODE * this_node;
28763
 
 
28764
 
        /* Get a pointer to this node.*/
28765
 
        this_node = &(bb->node[link->node_number]);
28766
 
 
28767
 
        if (this_node->l[0].depth > this_node->l[1].depth)
28768
 
                link->depth = this_node->l[0].depth + 1;
28769
 
        else
28770
 
                link->depth = this_node->l[1].depth + 1;
28771
 
}
28772
 
 
28773
 
void OctApiBt0Rebalance(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * root_link)
28774
 
{
28775
 
        if (bb->node[root_link->node_number].l[0].depth > (bb->node[root_link->node_number].l[1].depth + 1))    /* Heavy to the left.*/
28776
 
        {
28777
 
                /* Check if the right child of the heavy child node is causing a problem.*/
28778
 
                /* If so, do a left rotate in order to make the left most child the longer one.*/
28779
 
                {
28780
 
                        OCTAPI_BT0_LINK * heavy_link;
28781
 
                        heavy_link = &(bb->node[root_link->node_number].l[0]);
28782
 
 
28783
 
                        if (bb->node[heavy_link->node_number].l[1].depth > bb->node[heavy_link->node_number].l[0].depth)
28784
 
                        {
28785
 
                                OctApiBt0ExternalHeavy(bb,heavy_link);
28786
 
                        }
28787
 
                }
28788
 
 
28789
 
                /* Ready to do super rotation!*/
28790
 
                {
28791
 
                        OCTAPI_BT0_LINK init_root_link;
28792
 
                        OCTAPI_BT0_LINK init_heavy_link;
28793
 
                        OCTAPI_BT0_LINK init_leaf_tree[3];
28794
 
 
28795
 
                        /* Save pertinent initial OCTAPI_BT0_LINK information.*/
28796
 
                        init_root_link = *root_link;
28797
 
                        init_heavy_link = bb->node[root_link->node_number].l[0];
28798
 
                        init_leaf_tree[2] = bb->node[root_link->node_number].l[1];
28799
 
                        init_leaf_tree[0] = bb->node[bb->node[root_link->node_number].l[0].node_number].l[0];
28800
 
                        init_leaf_tree[1] = bb->node[bb->node[root_link->node_number].l[0].node_number].l[1];
28801
 
 
28802
 
                        /* Restructure the tree.*/
28803
 
                        *root_link = init_heavy_link;
28804
 
                        bb->node[init_heavy_link.node_number].l[1] = init_root_link;
28805
 
                        bb->node[init_root_link.node_number].l[0] = init_leaf_tree[1];
28806
 
 
28807
 
                        /* Reconstruct the depth of the branches.*/
28808
 
                        OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[1]));
28809
 
                        OctApiBt0UpdateLinkDepth(bb,root_link);
28810
 
                }
28811
 
        }
28812
 
        else if (bb->node[root_link->node_number].l[1].depth > (bb->node[root_link->node_number].l[0].depth + 1))       /* Heavy to the right.*/
28813
 
        {
28814
 
                /* Check if the right child of the heavy child node is causing a problem.*/
28815
 
                /* If so, do a left rotate in order to make the left most child the longer one.*/
28816
 
                {
28817
 
                        OCTAPI_BT0_LINK * heavy_link;
28818
 
                        heavy_link = &(bb->node[root_link->node_number].l[1]);
28819
 
 
28820
 
                        if (bb->node[heavy_link->node_number].l[0].depth > bb->node[heavy_link->node_number].l[1].depth)
28821
 
                        {
28822
 
                                OctApiBt0ExternalHeavy(bb,heavy_link);
28823
 
                        }
28824
 
                }
28825
 
 
28826
 
                /* Ready to do super rotation!*/
28827
 
                {
28828
 
                        OCTAPI_BT0_LINK init_root_link;
28829
 
                        OCTAPI_BT0_LINK init_heavy_link;
28830
 
                        OCTAPI_BT0_LINK init_leaf_tree[3];
28831
 
 
28832
 
                        /* Save pertinent initial OCTAPI_BT0_LINK information.*/
28833
 
                        init_root_link = *root_link;
28834
 
                        init_heavy_link = bb->node[root_link->node_number].l[1];
28835
 
                        init_leaf_tree[2] = bb->node[root_link->node_number].l[0];
28836
 
                        init_leaf_tree[0] = bb->node[bb->node[root_link->node_number].l[1].node_number].l[1];
28837
 
                        init_leaf_tree[1] = bb->node[bb->node[root_link->node_number].l[1].node_number].l[0];
28838
 
 
28839
 
                        /* Restructure the tree.*/
28840
 
                        *root_link = init_heavy_link;
28841
 
                        bb->node[init_heavy_link.node_number].l[0] = init_root_link;
28842
 
                        bb->node[init_root_link.node_number].l[1] = init_leaf_tree[1];
28843
 
 
28844
 
                        /* Reconstruct the depth of the branches.*/
28845
 
                        OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[0]));
28846
 
                        OctApiBt0UpdateLinkDepth(bb,root_link);
28847
 
                }
28848
 
        }
28849
 
}
28850
 
 
28851
 
/* This function does a rotation towards the outside of the tree*/
28852
 
/* in order to keep the heavy branches towards the outside.*/
28853
 
void OctApiBt0ExternalHeavy(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * root_link)
28854
 
{
28855
 
        if (bb->node[root_link->node_number].l[1].depth > bb->node[root_link->node_number].l[0].depth)  /* Exterior of tree is towards the left.*/
28856
 
        {
28857
 
                OCTAPI_BT0_LINK init_root_link;
28858
 
                OCTAPI_BT0_LINK init_heavy_link;
28859
 
                OCTAPI_BT0_LINK init_leaf_tree[3];
28860
 
 
28861
 
                /* Save pertinent initial OCTAPI_BT0_LINK information.*/
28862
 
                init_root_link = *root_link;
28863
 
                init_leaf_tree[0] = bb->node[root_link->node_number].l[0];
28864
 
                init_heavy_link = bb->node[root_link->node_number].l[1];
28865
 
                init_leaf_tree[1] = bb->node[bb->node[root_link->node_number].l[1].node_number].l[0];
28866
 
                init_leaf_tree[2] = bb->node[bb->node[root_link->node_number].l[1].node_number].l[1];
28867
 
 
28868
 
                /* Restructure the tree.*/
28869
 
                *root_link = init_heavy_link;
28870
 
                bb->node[init_heavy_link.node_number].l[0] = init_root_link;
28871
 
                bb->node[init_root_link.node_number].l[1] = init_leaf_tree[1];
28872
 
 
28873
 
                /* Reconstruct the depth of the branches.*/
28874
 
                OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[0]));
28875
 
                OctApiBt0UpdateLinkDepth(bb,root_link);
28876
 
        }
28877
 
        else if (bb->node[root_link->node_number].l[0].depth > bb->node[root_link->node_number].l[1].depth)     /* Exterior of tree is towards the right.*/
28878
 
        {
28879
 
                OCTAPI_BT0_LINK init_root_link;
28880
 
                OCTAPI_BT0_LINK init_heavy_link;
28881
 
                OCTAPI_BT0_LINK init_leaf_tree[3];
28882
 
 
28883
 
                /* Save pertinent initial OCTAPI_BT0_LINK information.*/
28884
 
                init_root_link = *root_link;
28885
 
                init_leaf_tree[0] = bb->node[root_link->node_number].l[1];
28886
 
                init_heavy_link = bb->node[root_link->node_number].l[0];
28887
 
                init_leaf_tree[1] = bb->node[bb->node[root_link->node_number].l[0].node_number].l[1];
28888
 
                init_leaf_tree[2] = bb->node[bb->node[root_link->node_number].l[0].node_number].l[0];
28889
 
 
28890
 
                /* Restructure the tree.*/
28891
 
                *root_link = init_heavy_link;
28892
 
                bb->node[init_heavy_link.node_number].l[1] = init_root_link;
28893
 
                bb->node[init_root_link.node_number].l[0] = init_leaf_tree[1];
28894
 
 
28895
 
                /* Reconstruct the depth of the branches.*/
28896
 
                OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[1]));
28897
 
                OctApiBt0UpdateLinkDepth(bb,root_link);
28898
 
        }
28899
 
}
28900
 
 
28901
 
 
28902
 
/* State:*/
28903
 
/* 0 = seeking node to be removed.*/
28904
 
/* 1 = node found, left branch taken.*/
28905
 
/* 2 = node found, right branch taken.*/
28906
 
static UINT32 OctApiBt0RemoveNode2(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link, UINT32 * lkey, OCTAPI_BT0_LINK * link_to_removed_node, UINT32 state, OCTAPI_BT0_LINK * volatile_grandparent_link)
28907
 
{
28908
 
        UINT32 result;
28909
 
        OCTAPI_BT0_NODE * this_node;
28910
 
 
28911
 
        /* Get a pointer to this node.*/
28912
 
        this_node = &(bb->node[link->node_number]);
28913
 
 
28914
 
        if (state == 0)
28915
 
        {
28916
 
                if (link->node_number == 0xFFFFFFFF) /* We have an empty node. The node we were looking for does not exist.*/
28917
 
                {
28918
 
                        return(OCTAPI_BT0_KEY_NOT_IN_TREE);
28919
 
                }
28920
 
                else /* Current node is used, check for a match and a direction.*/
28921
 
                {
28922
 
                        UINT32 compare;
28923
 
 
28924
 
                        /* Compare this node to the lkey.*/
28925
 
                        compare = OctApiBt0KeyCompare(bb,link,lkey);
28926
 
 
28927
 
                        if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/
28928
 
                        {
28929
 
                                result = OctApiBt0RemoveNode2(bb,&(bb->node[link->node_number].l[0]), lkey, link_to_removed_node, 0, NULL);
28930
 
                                if (result != GENERIC_OK) return(result);
28931
 
                        }
28932
 
                        else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/
28933
 
                        {
28934
 
                                result = OctApiBt0RemoveNode2(bb,&(bb->node[link->node_number].l[1]), lkey, link_to_removed_node, 0, NULL);
28935
 
                                if (result != GENERIC_OK) return(result);
28936
 
                        }
28937
 
                        else
28938
 
                        {
28939
 
                                link_to_removed_node = link;
28940
 
 
28941
 
                                /* Keep on going down to find a replacement node.*/
28942
 
                                if (bb->node[link->node_number].l[0].node_number == 0xFFFFFFFF && bb->node[link->node_number].l[1].node_number == 0xFFFFFFFF)
28943
 
                                {
28944
 
                                        /* Doe! No tree left! WHAT TO DO?          */
28945
 
                                        /* Just delete the current node. That's it.*/
28946
 
 
28947
 
                                        /* Release the current node (restore free node link-list)*/
28948
 
                                        bb->node[link->node_number].next_free_node = bb->next_free_node;
28949
 
                                        bb->next_free_node = link->node_number;
28950
 
 
28951
 
                                        link->node_number = 0xFFFFFFFF;
28952
 
                                        link->depth = 0;
28953
 
 
28954
 
                                        return(GENERIC_OK);
28955
 
                                }
28956
 
                                else if (bb->node[link->node_number].l[0].node_number != 0xFFFFFFFF)    /* Left node is present. Go left, then permanently right.*/
28957
 
                                {
28958
 
                                        OCTAPI_BT0_NODE * removed_node_pnt;
28959
 
                                        removed_node_pnt = &(bb->node[link->node_number]);
28960
 
 
28961
 
                                        result = OctApiBt0RemoveNode2(bb,&(removed_node_pnt->l[0]), lkey, link_to_removed_node, 1, link);
28962
 
                                        if (result != GENERIC_OK) return(result);
28963
 
 
28964
 
                                        /* Caution! Once we are here, the link->node_pnt->l[0] has been modified,*/
28965
 
                                        /* but is about to be discarded! Save it quickly!*/
28966
 
                                        /* bb->node[link->node_number].l[0] = removed_node_pnt->l[0];*/
28967
 
                                }
28968
 
                                else /* Right node is present. Go right, then permanently left.*/
28969
 
                                {
28970
 
                                        OCTAPI_BT0_NODE * removed_node_pnt;
28971
 
                                        removed_node_pnt = &(bb->node[link->node_number]);
28972
 
 
28973
 
                                        result = OctApiBt0RemoveNode2(bb,&(removed_node_pnt->l[1]), lkey, link_to_removed_node, 2, link);
28974
 
                                        if (result != GENERIC_OK) return(result);
28975
 
 
28976
 
                                        /* Caution! Once we are here, the link->node_pnt->l[0] has been modified,*/
28977
 
                                        /* but is about to be discarded! Save it quickly!*/
28978
 
                                        /* bb->node[link->node_number].l[1] = removed_node_pnt->l[1];*/
28979
 
                                }
28980
 
                        }
28981
 
                }
28982
 
        }
28983
 
        else
28984
 
        {
28985
 
                /* Left side, Right-most node found! OR*/
28986
 
                /* Right side, Left-most node found!*/
28987
 
                if ((state == 1 && bb->node[link->node_number].l[1].node_number == 0xFFFFFFFF) ||
28988
 
                        (state == 2 && bb->node[link->node_number].l[0].node_number == 0xFFFFFFFF))
28989
 
                {
28990
 
                        OCTAPI_BT0_LINK init_chosen_link;
28991
 
 
28992
 
                        /* Release the current node (restore free node link-list)*/
28993
 
                        bb->node[link_to_removed_node->node_number].next_free_node = bb->next_free_node;
28994
 
                        bb->next_free_node = link_to_removed_node->node_number;
28995
 
 
28996
 
                        /* Save the link to the chosen node, because it is about to be deleted.*/
28997
 
                        init_chosen_link = *link;
28998
 
 
28999
 
                        /* Remove this node, and allow the tree to go on:*/
29000
 
                        {
29001
 
                                OCTAPI_BT0_LINK init_child_link[2];
29002
 
 
29003
 
                                init_child_link[0] = bb->node[link->node_number].l[0];
29004
 
                                init_child_link[1] = bb->node[link->node_number].l[1];
29005
 
 
29006
 
                                if (state == 1)
29007
 
                                        *link = init_child_link[0];
29008
 
                                else
29009
 
                                        *link = init_child_link[1];
29010
 
                        }
29011
 
 
29012
 
                        /* Replace the removed node by this node.*/
29013
 
                        {
29014
 
                                OCTAPI_BT0_LINK init_removed_child_link[2];
29015
 
 
29016
 
                                init_removed_child_link[0] = bb->node[link_to_removed_node->node_number].l[0];
29017
 
                                init_removed_child_link[1] = bb->node[link_to_removed_node->node_number].l[1];
29018
 
 
29019
 
                                *link_to_removed_node = init_chosen_link;
29020
 
                                bb->node[init_chosen_link.node_number].l[0] = init_removed_child_link[0];
29021
 
                                bb->node[init_chosen_link.node_number].l[1] = init_removed_child_link[1];
29022
 
                        }
29023
 
 
29024
 
                        return(GENERIC_OK);
29025
 
                }
29026
 
                else
29027
 
                {
29028
 
                        /* Keep on going, we have not found the center most node yet!*/
29029
 
                        if (state == 1)
29030
 
                        {
29031
 
                                result = OctApiBt0RemoveNode2(bb,&(bb->node[link->node_number].l[1]), lkey, link_to_removed_node, state, NULL);
29032
 
                                if (result != GENERIC_OK) return(result);
29033
 
 
29034
 
                                /* Refresh the link if our link is volatile.*/
29035
 
                                if (volatile_grandparent_link != NULL)
29036
 
                                {
29037
 
                                        link = &(bb->node[volatile_grandparent_link->node_number].l[0]);
29038
 
                                }
29039
 
                        }
29040
 
                        else
29041
 
                        {
29042
 
                                result = OctApiBt0RemoveNode2(bb,&(bb->node[link->node_number].l[0]), lkey, link_to_removed_node, state, NULL);
29043
 
                                if (result != GENERIC_OK) return(result);
29044
 
 
29045
 
                                /* Refresh the link if our link is volatile.*/
29046
 
                                if (volatile_grandparent_link != NULL)
29047
 
                                {
29048
 
                                        link = &(bb->node[volatile_grandparent_link->node_number].l[1]);
29049
 
                                }
29050
 
                        }
29051
 
                }
29052
 
        }
29053
 
 
29054
 
        /* We may have messed up the tree. So patch it!*/
29055
 
        /* Check if this node is unbalanced by 2. If so, rebalance it:*/
29056
 
        if (this_node->l[0].depth > (this_node->l[1].depth + 1) || 
29057
 
                        this_node->l[1].depth > (this_node->l[0].depth + 1))
29058
 
        {
29059
 
                OctApiBt0Rebalance(bb,link);
29060
 
        }
29061
 
 
29062
 
        /* Always update the OCTAPI_BT0_LINK depth before exiting.*/
29063
 
        OctApiBt0UpdateLinkDepth(bb,link);
29064
 
 
29065
 
        return(GENERIC_OK);
29066
 
}
29067
 
 
29068
 
static UINT32 OctApiBt0QueryNode2(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 * node_number)
29069
 
{
29070
 
        UINT32 result;
29071
 
 
29072
 
        if (link->node_number == 0xFFFFFFFF) /* We have an empty node. The node we were looking for does not exist.*/
29073
 
        {
29074
 
                return(OCTAPI_BT0_KEY_NOT_IN_TREE);
29075
 
        }
29076
 
        else /* Current node is used, check for a match and a direction.*/
29077
 
        {
29078
 
                UINT32 compare;
29079
 
 
29080
 
                /* Compare this node to the lkey.*/
29081
 
                compare = OctApiBt0KeyCompare(bb,link,lkey);
29082
 
 
29083
 
                if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/
29084
 
                {
29085
 
                        result = OctApiBt0QueryNode2(bb,&(bb->node[link->node_number].l[0]), lkey, node_number);
29086
 
                        if (result != GENERIC_OK) return(result);
29087
 
                }
29088
 
                else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/
29089
 
                {
29090
 
                        result = OctApiBt0QueryNode2(bb,&(bb->node[link->node_number].l[1]), lkey, node_number);
29091
 
                        if (result != GENERIC_OK) return(result);
29092
 
                }
29093
 
                else
29094
 
                {
29095
 
                        /* A match!*/
29096
 
                        *node_number = link->node_number;
29097
 
                }
29098
 
        }
29099
 
 
29100
 
        return(GENERIC_OK);
29101
 
}
29102
 
 
29103
 
 
29104
 
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
29105
 
 
29106
 
File:  octapi_largmath.h
29107
 
 
29108
 
    Copyright (c) 2001-2005 Octasic Inc.
29109
 
    
29110
 
Description: 
29111
 
 
29112
 
        Library used to perform arithmetic on integer values of an integer multiple
29113
 
        of 32-bits.
29114
 
 
29115
 
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API  is 
29116
 
free software; you can redistribute it and/or modify it under the terms of 
29117
 
the GNU General Public License as published by the Free Software Foundation; 
29118
 
either version 2 of the License, or (at your option) any later version.
29119
 
 
29120
 
The OCT6100 GPL API is distributed in the hope that it will be useful, but 
29121
 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
29122
 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
29123
 
for more details. 
29124
 
 
29125
 
You should have received a copy of the GNU General Public License 
29126
 
along with the OCT6100 GPL API; if not, write to the Free Software 
29127
 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29128
 
 
29129
 
$Octasic_Release: OCT612xAPI-01.00-PR38 $
29130
 
 
29131
 
$Octasic_Revision: 10 $
29132
 
 
29133
 
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
29134
 
#include "apilib/octapi_largmath.h"
29135
 
 
29136
 
 
29137
 
/*
29138
 
 * Copyright (C) 2005-2006 Digium, Inc.
29139
 
 *
29140
 
 * Mark Spencer <markster@digium.com>
29141
 
 *
29142
 
 * All Rights Reserved
29143
 
 */
29144
 
 
29145
 
#include "oct6100_api.h"
29146
 
#include <linux/string.h>
29147
 
#include <linux/time.h>
29148
 
//#include <linux/slab.h>
29149
 
//#include <linux/vmalloc.h>
29150
 
#include "vpm450m.h"
29151
 
 
29152
 
/* API for Octasic access */
29153
 
static UINT32 Oct6100UserGetTime(tPOCT6100_GET_TIME f_pTime)
29154
 
{
29155
 
        /* Why couldn't they just take a timeval like everyone else? */
29156
 
        struct timeval tv;
29157
 
        unsigned long long total_usecs;
29158
 
        unsigned int mask = ~0;
29159
 
        
29160
 
        do_gettimeofday(&tv);
29161
 
        total_usecs = (((unsigned long long)(tv.tv_sec)) * 1000000) + 
29162
 
                                  (((unsigned long long)(tv.tv_usec)));
29163
 
        f_pTime->aulWallTimeUs[0] = (total_usecs & mask);
29164
 
        f_pTime->aulWallTimeUs[1] = (total_usecs >> 32);
29165
 
        return cOCT6100_ERR_OK;
29166
 
}
29167
 
 
29168
 
static UINT32 Oct6100UserMemSet(PVOID f_pAddress, UINT32 f_ulPattern, UINT32 f_ulLength)
29169
 
{
29170
 
        memset(f_pAddress, f_ulPattern, f_ulLength);
29171
 
        return cOCT6100_ERR_OK;
29172
 
}
29173
 
 
29174
 
static UINT32 Oct6100UserMemCopy(PVOID f_pDestination, PVOID f_pSource, UINT32 f_ulLength)
29175
 
{
29176
 
        memcpy(f_pDestination, f_pSource, f_ulLength);
29177
 
        return cOCT6100_ERR_OK;
29178
 
}
29179
 
 
29180
 
static UINT32 Oct6100UserCreateSerializeObject(tPOCT6100_CREATE_SERIALIZE_OBJECT f_pCreate)
29181
 
{
29182
 
        return cOCT6100_ERR_OK;
29183
 
}
29184
 
 
29185
 
static UINT32 Oct6100UserDestroySerializeObject(tPOCT6100_DESTROY_SERIALIZE_OBJECT f_pDestroy)
29186
 
{
29187
 
#ifdef OCTASIC_DEBUG
29188
 
        printk("I should never be called! (destroy serialize object)\n");
29189
 
#endif
29190
 
        return cOCT6100_ERR_OK;
29191
 
}
29192
 
 
29193
 
static UINT32 Oct6100UserSeizeSerializeObject(tPOCT6100_SEIZE_SERIALIZE_OBJECT f_pSeize)
29194
 
{
29195
 
        /* Not needed */
29196
 
        return cOCT6100_ERR_OK;
29197
 
}
29198
 
 
29199
 
static UINT32 Oct6100UserReleaseSerializeObject(tPOCT6100_RELEASE_SERIALIZE_OBJECT f_pRelease)
29200
 
{
29201
 
        /* Not needed */
29202
 
        return cOCT6100_ERR_OK;
29203
 
}
29204
 
 
29205
 
static UINT32 Oct6100UserDriverWriteApi(tPOCT6100_WRITE_PARAMS f_pWriteParams)
29206
 
{
29207
 
        oct_set_reg(f_pWriteParams->pProcessContext, f_pWriteParams->ulWriteAddress, f_pWriteParams->usWriteData);
29208
 
        return cOCT6100_ERR_OK;
29209
 
}
29210
 
 
29211
 
static UINT32 Oct6100UserDriverWriteSmearApi(tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams)
29212
 
{
29213
 
        unsigned int x;
29214
 
        for (x=0;x<f_pSmearParams->ulWriteLength;x++) {
29215
 
                oct_set_reg(f_pSmearParams->pProcessContext, f_pSmearParams->ulWriteAddress + (x << 1), f_pSmearParams->usWriteData);
29216
 
        }
29217
 
        return cOCT6100_ERR_OK;
29218
 
}
29219
 
 
29220
 
static UINT32 Oct6100UserDriverWriteBurstApi(tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams)
29221
 
{
29222
 
        unsigned int x;
29223
 
        for (x=0;x<f_pBurstParams->ulWriteLength;x++) {
29224
 
                oct_set_reg(f_pBurstParams->pProcessContext, f_pBurstParams->ulWriteAddress + (x << 1), f_pBurstParams->pusWriteData[x]);
29225
 
        }
29226
 
        return cOCT6100_ERR_OK;
29227
 
}
29228
 
 
29229
 
static UINT32 Oct6100UserDriverReadApi(tPOCT6100_READ_PARAMS f_pReadParams)
29230
 
{
29231
 
        *(f_pReadParams->pusReadData) = oct_get_reg(f_pReadParams->pProcessContext, f_pReadParams->ulReadAddress);
29232
 
        return cOCT6100_ERR_OK;
29233
 
}
29234
 
 
29235
 
static UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams)
29236
 
{
29237
 
        unsigned int x;
29238
 
        for (x=0;x<f_pBurstParams->ulReadLength;x++) {
29239
 
                f_pBurstParams->pusReadData[x] = oct_get_reg(f_pBurstParams->pProcessContext, f_pBurstParams->ulReadAddress + (x << 1));
29240
 
        }
29241
 
        return cOCT6100_ERR_OK;
29242
 
}
29243
 
 
29244
 
#ifndef HOTPLUG_FIRMWARE
29245
 
#include "vpm450m_fw.h"
29246
 
#endif
29247
 
 
29248
 
#define SOUT_G168_1100GB_ON 0x40000004
29249
 
#define SOUT_DTMF_1 0x40000011
29250
 
#define SOUT_DTMF_2 0x40000012
29251
 
#define SOUT_DTMF_3 0x40000013
29252
 
#define SOUT_DTMF_A 0x4000001A
29253
 
#define SOUT_DTMF_4 0x40000014
29254
 
#define SOUT_DTMF_5 0x40000015
29255
 
#define SOUT_DTMF_6 0x40000016
29256
 
#define SOUT_DTMF_B 0x4000001B
29257
 
#define SOUT_DTMF_7 0x40000017
29258
 
#define SOUT_DTMF_8 0x40000018
29259
 
#define SOUT_DTMF_9 0x40000019
29260
 
#define SOUT_DTMF_C 0x4000001C
29261
 
#define SOUT_DTMF_STAR 0x4000001E
29262
 
#define SOUT_DTMF_0 0x40000010
29263
 
#define SOUT_DTMF_POUND 0x4000001F
29264
 
#define SOUT_DTMF_D 0x4000001D
29265
 
 
29266
 
#define ROUT_G168_2100GB_ON 0x10000000
29267
 
#define ROUT_G168_2100GB_WSPR 0x10000002
29268
 
#define ROUT_SOUT_G168_2100HB_END 0x50000003
29269
 
#define ROUT_G168_1100GB_ON 0x10000004
29270
 
 
29271
 
#define ROUT_DTMF_1 0x10000011
29272
 
#define ROUT_DTMF_2 0x10000012
29273
 
#define ROUT_DTMF_3 0x10000013
29274
 
#define ROUT_DTMF_A 0x1000001A
29275
 
#define ROUT_DTMF_4 0x10000014
29276
 
#define ROUT_DTMF_5 0x10000015
29277
 
#define ROUT_DTMF_6 0x10000016
29278
 
#define ROUT_DTMF_B 0x1000001B
29279
 
#define ROUT_DTMF_7 0x10000017
29280
 
#define ROUT_DTMF_8 0x10000018
29281
 
#define ROUT_DTMF_9 0x10000019
29282
 
#define ROUT_DTMF_C 0x1000001C
29283
 
#define ROUT_DTMF_STAR 0x1000001E
29284
 
#define ROUT_DTMF_0 0x10000010
29285
 
#define ROUT_DTMF_POUND 0x1000001F
29286
 
#define ROUT_DTMF_D 0x1000001D
29287
 
 
29288
 
#if 0 
29289
 
#define cOCT6100_ECHO_OP_MODE_DIGITAL cOCT6100_ECHO_OP_MODE_HT_FREEZE
29290
 
#else
29291
 
#define cOCT6100_ECHO_OP_MODE_DIGITAL cOCT6100_ECHO_OP_MODE_POWER_DOWN
29292
 
#endif
29293
 
 
29294
 
struct vpm450m {
29295
 
        tPOCT6100_INSTANCE_API pApiInstance;
29296
 
        UINT32 aulEchoChanHndl[ 128 ];
29297
 
        int chanflags[128];
29298
 
        int ecmode[128];
29299
 
};
29300
 
 
29301
 
#define FLAG_DTMF        (1 << 0)
29302
 
#define FLAG_MUTE        (1 << 1)
29303
 
#define FLAG_ECHO        (1 << 2)
29304
 
 
29305
 
static unsigned int tones[] = {
29306
 
        SOUT_DTMF_1,
29307
 
        SOUT_DTMF_2,
29308
 
        SOUT_DTMF_3,
29309
 
        SOUT_DTMF_A,
29310
 
        SOUT_DTMF_4,
29311
 
        SOUT_DTMF_5,
29312
 
        SOUT_DTMF_6,
29313
 
        SOUT_DTMF_B,
29314
 
        SOUT_DTMF_7,
29315
 
        SOUT_DTMF_8,
29316
 
        SOUT_DTMF_9,
29317
 
        SOUT_DTMF_C,
29318
 
        SOUT_DTMF_STAR,
29319
 
        SOUT_DTMF_0,
29320
 
        SOUT_DTMF_POUND,
29321
 
        SOUT_DTMF_D,
29322
 
        SOUT_G168_1100GB_ON,
29323
 
 
29324
 
        ROUT_DTMF_1,
29325
 
        ROUT_DTMF_2,
29326
 
        ROUT_DTMF_3,
29327
 
        ROUT_DTMF_A,
29328
 
        ROUT_DTMF_4,
29329
 
        ROUT_DTMF_5,
29330
 
        ROUT_DTMF_6,
29331
 
        ROUT_DTMF_B,
29332
 
        ROUT_DTMF_7,
29333
 
        ROUT_DTMF_8,
29334
 
        ROUT_DTMF_9,
29335
 
        ROUT_DTMF_C,
29336
 
        ROUT_DTMF_STAR,
29337
 
        ROUT_DTMF_0,
29338
 
        ROUT_DTMF_POUND,
29339
 
        ROUT_DTMF_D,
29340
 
        ROUT_G168_1100GB_ON,
29341
 
};
29342
 
 
29343
 
static void vpm450m_setecmode(struct vpm450m *vpm450m, int channel, int mode)
29344
 
{
29345
 
        tOCT6100_CHANNEL_MODIFY modify;
29346
 
        UINT32 ulResult;
29347
 
 
29348
 
        if (vpm450m->ecmode[channel] == mode)
29349
 
                return;
29350
 
        Oct6100ChannelModifyDef(&modify);
29351
 
        modify.ulEchoOperationMode = mode;
29352
 
        modify.ulChannelHndl = vpm450m->aulEchoChanHndl[channel];
29353
 
        ulResult = Oct6100ChannelModify(vpm450m->pApiInstance, &modify);
29354
 
        if (ulResult != GENERIC_OK) {
29355
 
                printk("Failed to apply echo can changes on channel %d!\n", channel);
29356
 
        } else {
29357
 
#ifdef OCTASIC_DEBUG
29358
 
                printk("Echo can on channel %d set to %d\n", channel, mode);
29359
 
#endif
29360
 
                vpm450m->ecmode[channel] = mode;
29361
 
        }
29362
 
}
29363
 
 
29364
 
void vpm450m_setdtmf(struct vpm450m *vpm450m, int channel, int detect, int mute)
29365
 
{
29366
 
        tOCT6100_CHANNEL_MODIFY modify;
29367
 
        UINT32 ulResult;
29368
 
 
29369
 
        Oct6100ChannelModifyDef(&modify);
29370
 
        modify.ulChannelHndl = vpm450m->aulEchoChanHndl[channel];
29371
 
        if (mute) {
29372
 
                vpm450m->chanflags[channel] |= FLAG_MUTE;
29373
 
                modify.VqeConfig.fDtmfToneRemoval = TRUE;
29374
 
        } else {
29375
 
                vpm450m->chanflags[channel] &= ~FLAG_MUTE;
29376
 
                modify.VqeConfig.fDtmfToneRemoval = FALSE;
29377
 
        }
29378
 
        if (detect)
29379
 
                vpm450m->chanflags[channel] |= FLAG_DTMF;
29380
 
        else
29381
 
                vpm450m->chanflags[channel] &= ~FLAG_DTMF;
29382
 
        if (vpm450m->chanflags[channel] & (FLAG_DTMF|FLAG_MUTE)) {
29383
 
                if (!(vpm450m->chanflags[channel] & FLAG_ECHO)) {
29384
 
                        vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_HT_RESET);
29385
 
                        vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_HT_FREEZE);
29386
 
                }
29387
 
        } else {
29388
 
                if (!(vpm450m->chanflags[channel] & FLAG_ECHO))
29389
 
                        vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_DIGITAL);
29390
 
        }
29391
 
 
29392
 
        ulResult = Oct6100ChannelModify(vpm450m->pApiInstance, &modify);
29393
 
        if (ulResult != GENERIC_OK) {
29394
 
                printk("Failed to apply dtmf mute changes on channel %d!\n", channel);
29395
 
        }
29396
 
/*      printk("VPM450m: Setting DTMF on channel %d: %s / %s\n", channel, (detect ? "DETECT" : "NO DETECT"), (mute ? "MUTE" : "NO MUTE")); */
29397
 
}
29398
 
 
29399
 
void vpm450m_setec(struct vpm450m *vpm450m, int channel, int eclen)
29400
 
{
29401
 
        if (eclen) {
29402
 
                vpm450m->chanflags[channel] |= FLAG_ECHO;
29403
 
                vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_HT_RESET);
29404
 
                vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_NORMAL);
29405
 
        } else {
29406
 
                vpm450m->chanflags[channel] &= ~FLAG_ECHO;
29407
 
                if (vpm450m->chanflags[channel] & (FLAG_DTMF | FLAG_MUTE)) {
29408
 
                        vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_HT_RESET);
29409
 
                        vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_HT_FREEZE);
29410
 
                } else
29411
 
                        vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_DIGITAL);
29412
 
        }
29413
 
/*      printk("VPM450m: Setting EC on channel %d to %d\n", channel, eclen); */
29414
 
}
29415
 
 
29416
 
int vpm450m_checkirq(struct vpm450m *vpm450m)
29417
 
{
29418
 
        tOCT6100_INTERRUPT_FLAGS InterruptFlags;
29419
 
        
29420
 
        Oct6100InterruptServiceRoutineDef(&InterruptFlags);
29421
 
        Oct6100InterruptServiceRoutine(vpm450m->pApiInstance, &InterruptFlags);
29422
 
        if (InterruptFlags.fToneEventsPending) {
29423
 
                printk("VPM450M: Tone events pending!\n");
29424
 
                return 1;
29425
 
        }
29426
 
        return 0;
29427
 
}
29428
 
 
29429
 
int vpm450m_getdtmf(struct vpm450m *vpm450m, int *channel, int *tone, int *start)
29430
 
{
29431
 
        tOCT6100_TONE_EVENT tonefound;
29432
 
        tOCT6100_EVENT_GET_TONE tonesearch;
29433
 
        UINT32 ulResult;
29434
 
        
29435
 
        Oct6100EventGetToneDef(&tonesearch);
29436
 
        tonesearch.pToneEvent = &tonefound;
29437
 
        tonesearch.ulMaxToneEvent = 1;
29438
 
        ulResult = Oct6100EventGetTone(vpm450m->pApiInstance, &tonesearch);
29439
 
        if (tonesearch.ulNumValidToneEvent) {
29440
 
                if (channel)
29441
 
                        *channel = tonefound.ulUserChanId;
29442
 
                if (tone) {
29443
 
                        switch(tonefound.ulToneDetected) {
29444
 
                        case SOUT_DTMF_1:
29445
 
                                *tone = '1';
29446
 
                                break;
29447
 
                        case SOUT_DTMF_2:
29448
 
                                *tone = '2';
29449
 
                                break;
29450
 
                        case SOUT_DTMF_3:
29451
 
                                *tone = '3';
29452
 
                                break;
29453
 
                        case SOUT_DTMF_A:
29454
 
                                *tone = 'A';
29455
 
                                break;
29456
 
                        case SOUT_DTMF_4:
29457
 
                                *tone = '4';
29458
 
                                break;
29459
 
                        case SOUT_DTMF_5:
29460
 
                                *tone = '5';
29461
 
                                break;
29462
 
                        case SOUT_DTMF_6:
29463
 
                                *tone = '6';
29464
 
                                break;
29465
 
                        case SOUT_DTMF_B:
29466
 
                                *tone = 'B';
29467
 
                                break;
29468
 
                        case SOUT_DTMF_7:
29469
 
                                *tone = '7';
29470
 
                                break;
29471
 
                        case SOUT_DTMF_8:
29472
 
                                *tone = '8';
29473
 
                                break;
29474
 
                        case SOUT_DTMF_9:
29475
 
                                *tone = '9';
29476
 
                                break;
29477
 
                        case SOUT_DTMF_C:
29478
 
                                *tone = 'C';
29479
 
                                break;
29480
 
                        case SOUT_DTMF_STAR:
29481
 
                                *tone = '*';
29482
 
                                break;
29483
 
                        case SOUT_DTMF_0:
29484
 
                                *tone = '0';
29485
 
                                break;
29486
 
                        case SOUT_DTMF_POUND:
29487
 
                                *tone = '#';
29488
 
                                break;
29489
 
                        case SOUT_DTMF_D:
29490
 
                                *tone = 'D';
29491
 
                                break;
29492
 
                        case SOUT_G168_1100GB_ON:
29493
 
                                *tone = 'f';
29494
 
                                break;
29495
 
                        default:
29496
 
                                printk("Unknown tone value %08x\n", tonefound.ulToneDetected);
29497
 
                                *tone = 'u';
29498
 
                                break;
29499
 
                        }
29500
 
                }
29501
 
                if (start)
29502
 
                        *start = (tonefound.ulEventType == cOCT6100_TONE_PRESENT);
29503
 
                return 1;
29504
 
        }
29505
 
        return 0;
29506
 
}
29507
 
 
29508
 
#ifdef HOTPLUG_FIRMWARE
29509
 
struct vpm450m *init_vpm450m(void *wc, int *isalaw, const struct firmware *firmware)
29510
 
#else
29511
 
struct vpm450m *init_vpm450m(void *wc, int *isalaw)
29512
 
#endif
29513
 
{
29514
 
        tOCT6100_CHIP_OPEN ChipOpen;
29515
 
        tOCT6100_GET_INSTANCE_SIZE InstanceSize;
29516
 
        tOCT6100_CHANNEL_OPEN ChannelOpen;
29517
 
        UINT32 ulResult;
29518
 
        struct vpm450m *vpm450m;
29519
 
        int x,y,law;
29520
 
        
29521
 
        vpm450m = kmalloc(sizeof(struct vpm450m), GFP_KERNEL);
29522
 
        if (!vpm450m)
29523
 
                return NULL;
29524
 
        memset(vpm450m, 0, sizeof(struct vpm450m));
29525
 
        for (x=0;x<128;x++)
29526
 
                vpm450m->ecmode[x] = -1;
29527
 
                
29528
 
        Oct6100ChipOpenDef(&ChipOpen);
29529
 
 
29530
 
        /* Setup Chip Open Parameters */
29531
 
        ChipOpen.ulUpclkFreq = cOCT6100_UPCLK_FREQ_33_33_MHZ;
29532
 
        Oct6100GetInstanceSizeDef(&InstanceSize);
29533
 
 
29534
 
        ChipOpen.pProcessContext = wc;
29535
 
#ifdef HOTPLUG_FIRMWARE
29536
 
        ChipOpen.pbyImageFile = firmware->data;
29537
 
        ChipOpen.ulImageSize = firmware->size;
29538
 
#else
29539
 
        ChipOpen.pbyImageFile = vpm450m_fw;
29540
 
        ChipOpen.ulImageSize = sizeof(vpm450m_fw);
29541
 
#endif  
29542
 
        ChipOpen.fEnableMemClkOut = TRUE;
29543
 
        ChipOpen.ulMemClkFreq = cOCT6100_MCLK_FREQ_133_MHZ;
29544
 
        ChipOpen.ulMaxChannels = 128;
29545
 
        ChipOpen.ulMemoryType = cOCT6100_MEM_TYPE_DDR;
29546
 
        ChipOpen.ulMemoryChipSize = cOCT6100_MEMORY_CHIP_SIZE_32MB;
29547
 
        ChipOpen.ulNumMemoryChips = 1;
29548
 
        ChipOpen.ulMaxTdmStreams = 4;
29549
 
        ChipOpen.aulTdmStreamFreqs[0] = cOCT6100_TDM_STREAM_FREQ_8MHZ;
29550
 
        ChipOpen.ulTdmSampling = cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE;
29551
 
#if 0
29552
 
        ChipOpen.fEnableAcousticEcho = TRUE;
29553
 
#endif          
29554
 
 
29555
 
        ulResult = Oct6100GetInstanceSize(&ChipOpen, &InstanceSize);
29556
 
        if (ulResult != cOCT6100_ERR_OK) {
29557
 
                printk("Failed to get instance size, code %08x!\n", ulResult);
29558
 
                kfree(vpm450m);
29559
 
                return NULL;
29560
 
        }
29561
 
        
29562
 
        
29563
 
        vpm450m->pApiInstance = vmalloc(InstanceSize.ulApiInstanceSize);
29564
 
        if (!vpm450m->pApiInstance) {
29565
 
                printk("Out of memory (can't allocate %d bytes)!\n", InstanceSize.ulApiInstanceSize);
29566
 
                kfree(vpm450m);
29567
 
                return NULL;
29568
 
        }
29569
 
 
29570
 
        printk("Before chip open!\n");
29571
 
        ulResult = Oct6100ChipOpen(vpm450m->pApiInstance, &ChipOpen);
29572
 
        printk("After chip open!\n");
29573
 
        if (ulResult != cOCT6100_ERR_OK) {
29574
 
                printk("Failed to open chip, code %08x!\n", ulResult);
29575
 
                kfree(vpm450m);
29576
 
                return NULL;
29577
 
        }
29578
 
        for (x=0;x<128;x++) {
29579
 
                if (isalaw[x >> 5])
29580
 
                        law = cOCT6100_PCM_A_LAW;
29581
 
                else
29582
 
                        law = cOCT6100_PCM_U_LAW;
29583
 
                Oct6100ChannelOpenDef(&ChannelOpen);
29584
 
                ChannelOpen.pulChannelHndl = &vpm450m->aulEchoChanHndl[x];
29585
 
                ChannelOpen.ulUserChanId = x;
29586
 
                ChannelOpen.TdmConfig.ulRinPcmLaw = law;
29587
 
                ChannelOpen.TdmConfig.ulRinStream = 0;
29588
 
                ChannelOpen.TdmConfig.ulRinTimeslot = x;
29589
 
                ChannelOpen.TdmConfig.ulSinPcmLaw = law;
29590
 
                ChannelOpen.TdmConfig.ulSinStream = 1;
29591
 
                ChannelOpen.TdmConfig.ulSinTimeslot = x;
29592
 
                ChannelOpen.TdmConfig.ulSoutPcmLaw = law;
29593
 
                ChannelOpen.TdmConfig.ulSoutStream = 2;
29594
 
                ChannelOpen.TdmConfig.ulSoutTimeslot = x;
29595
 
                ChannelOpen.TdmConfig.ulRoutPcmLaw = law;
29596
 
                ChannelOpen.TdmConfig.ulRoutStream = 3;
29597
 
                ChannelOpen.TdmConfig.ulRoutTimeslot = x;
29598
 
                ChannelOpen.VqeConfig.fEnableNlp = TRUE;
29599
 
                ChannelOpen.VqeConfig.fRinDcOffsetRemoval = TRUE;
29600
 
                ChannelOpen.VqeConfig.fSinDcOffsetRemoval = TRUE;
29601
 
                
29602
 
                ChannelOpen.fEnableToneDisabler = TRUE;
29603
 
                ChannelOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_DIGITAL;
29604
 
                
29605
 
                ulResult = Oct6100ChannelOpen(vpm450m->pApiInstance, &ChannelOpen);
29606
 
                if (ulResult != GENERIC_OK) {
29607
 
                        printk("Failed to open channel %d!\n", x);
29608
 
                }
29609
 
                for (y=0;y<sizeof(tones) / sizeof(tones[0]); y++) {
29610
 
                        tOCT6100_TONE_DETECTION_ENABLE enable;
29611
 
                        Oct6100ToneDetectionEnableDef(&enable);
29612
 
                        enable.ulChannelHndl = vpm450m->aulEchoChanHndl[x];
29613
 
                        enable.ulToneNumber = tones[y];
29614
 
                        if (Oct6100ToneDetectionEnable(vpm450m->pApiInstance, &enable) != GENERIC_OK) 
29615
 
                                printk("Failed to enable tone detection on channel %d for tone %d!\n", x, y);
29616
 
                }
29617
 
        }
29618
 
        return vpm450m;
29619
 
}
29620
 
 
29621
 
void release_vpm450m(struct vpm450m *vpm450m)
29622
 
{
29623
 
        UINT32 ulResult;
29624
 
        tOCT6100_CHIP_CLOSE ChipClose;
29625
 
        Oct6100ChipCloseDef(&ChipClose);
29626
 
        ulResult = Oct6100ChipClose(vpm450m->pApiInstance, &ChipClose);
29627
 
        if (ulResult != cOCT6100_ERR_OK) {
29628
 
                printk("Failed to close chip, code %08x!\n", ulResult);
29629
 
        }
29630
 
        vfree(vpm450m->pApiInstance);
29631
 
        kfree(vpm450m);
29632
 
}