1
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3
File: oct6100_adpcm_chan.c
5
Copyright (c) 2001-2005 Octasic Inc.
9
This file contains functions used to open and close ADPCM channels.
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.
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
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.
25
$Octasic_Release: OCT612xAPI-01.00-PR38 $
27
$Octasic_Revision: 15 $
29
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
32
/***************************** INCLUDE FILES *******************************/
36
#include "apilib/octapi_largmath.h"
38
#include "oct6100api/oct6100_defines.h"
39
#include "oct6100api/oct6100_errors.h"
40
#include "oct6100api/oct6100_apiud.h"
42
#include "apilib/octapi_llman.h"
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"
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"
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"
66
#include <linux/slab.h>
67
#include <linux/vmalloc.h>
68
#ifdef HOTPLUG_FIRMWARE
69
#include <linux/firmware.h>
72
/**************************** PRIVATE FUNCTIONS ****************************/
74
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
76
Function: Oct6100ApiGetAdpcmChanSwSizes
78
Description: Gets the sizes of all portions of the API instance pertinent
79
to the management of the ADPCM memory.
81
-------------------------------------------------------------------------------
82
| Argument | Description
83
-------------------------------------------------------------------------------
84
f_pOpenChip Pointer to chip configuration struct.
85
f_pInstSizes Pointer to struct containing instance sizes.
87
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
88
static UINT32 Oct6100ApiGetAdpcmChanSwSizes(
89
IN tPOCT6100_CHIP_OPEN f_pOpenChip,
90
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
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 );
98
if ( f_pOpenChip->ulMaxAdpcmChannels > 0 )
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;
107
f_pInstSizes->ulAdpcmChannelAlloc = 0;
110
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulAdpcmChannelList, ulTempVar )
111
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulAdpcmChannelAlloc, ulTempVar )
113
return cOCT6100_ERR_OK;
117
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
119
Function: Oct6100ApiAdpcmChanSwInit
121
Description: Initializes all elements of the instance structure associated
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.
130
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
131
static UINT32 Oct6100ApiAdpcmChanSwInit(
132
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
134
tPOCT6100_API_ADPCM_CHAN pChannelsTsiList;
135
tPOCT6100_SHARED_INFO pSharedInfo;
136
UINT32 ulMaxAdpcmChannels;
137
PVOID pAdpcmChannelsAlloc;
140
/* Get local pointer to shared portion of instance. */
141
pSharedInfo = f_pApiInstance->pSharedInfo;
143
/* Initialize the ADPCM channel API list.*/
144
ulMaxAdpcmChannels = pSharedInfo->ChipConfig.usMaxAdpcmChannels;
146
/* Set all entries in the ADPCM channel list to unused. */
147
mOCT6100_GET_ADPCM_CHAN_LIST_PNT( pSharedInfo, pChannelsTsiList )
149
/* Clear the memory */
150
Oct6100UserMemSet( pChannelsTsiList, 0x00, sizeof(tOCT6100_API_ADPCM_CHAN) * ulMaxAdpcmChannels );
152
/* Initialize the ADPCM channel allocation structures to "all free". */
153
if ( ulMaxAdpcmChannels > 0 )
155
mOCT6100_GET_ADPCM_CHAN_ALLOC_PNT( pSharedInfo, pAdpcmChannelsAlloc )
157
ulResult = OctapiLlmAllocInit( &pAdpcmChannelsAlloc, ulMaxAdpcmChannels );
158
if ( ulResult != cOCT6100_ERR_OK )
159
return cOCT6100_ERR_FATAL_BD;
162
return cOCT6100_ERR_OK;
166
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
168
File: oct6100_channel.c
170
Copyright (c) 2001-2005 Octasic Inc.
174
This file contains functions used to open, modify and close echo
175
cancellation channels.
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.
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
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.
191
$Octasic_Release: OCT612xAPI-01.00-PR38 $
193
$Octasic_Revision: 449 $
195
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
198
/***************************** INCLUDE FILES *******************************/
202
#include "oct6100api/oct6100_defines.h"
203
#include "oct6100api/oct6100_errors.h"
204
#include "oct6100api/oct6100_apiud.h"
206
#include "apilib/octapi_llman.h"
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"
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"
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"
246
/**************************** PUBLIC FUNCTIONS ****************************/
248
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
250
Function: Oct6100ChannelOpen
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.
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.
262
f_pChannelOpen Pointer to echo channel open structure.
264
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
265
static UINT32 Oct6100ChannelOpenDef(
266
IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen )
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;
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;
296
f_pChannelOpen->VqeConfig.fDtmfToneRemoval = FALSE;
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;
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;
322
f_pChannelOpen->TdmConfig.ulRinTimeslot = cOCT6100_UNASSIGNED;
323
f_pChannelOpen->TdmConfig.ulRinStream = cOCT6100_UNASSIGNED;
324
f_pChannelOpen->TdmConfig.ulRinPcmLaw = cOCT6100_PCM_U_LAW;
326
f_pChannelOpen->TdmConfig.ulSinTimeslot = cOCT6100_UNASSIGNED;
327
f_pChannelOpen->TdmConfig.ulSinStream = cOCT6100_UNASSIGNED;
328
f_pChannelOpen->TdmConfig.ulSinPcmLaw = cOCT6100_PCM_U_LAW;
330
f_pChannelOpen->TdmConfig.ulRoutTimeslot = cOCT6100_UNASSIGNED;
331
f_pChannelOpen->TdmConfig.ulRoutStream = cOCT6100_UNASSIGNED;
332
f_pChannelOpen->TdmConfig.ulRoutPcmLaw = cOCT6100_PCM_U_LAW;
334
f_pChannelOpen->TdmConfig.ulSoutTimeslot = cOCT6100_UNASSIGNED;
335
f_pChannelOpen->TdmConfig.ulSoutStream = cOCT6100_UNASSIGNED;
336
f_pChannelOpen->TdmConfig.ulSoutPcmLaw = cOCT6100_PCM_U_LAW;
338
/* CODEC configuration.*/
339
f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition = cOCT6100_ADPCM_IN_LOW_BITS;
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;
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;
352
return cOCT6100_ERR_OK;
355
static UINT32 Oct6100ChannelOpen(
356
IN tPOCT6100_INSTANCE_API f_pApiInstance,
357
IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen )
359
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
360
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
361
UINT32 ulSerRes = cOCT6100_ERR_OK;
362
UINT32 ulFncRes = cOCT6100_ERR_OK;
364
/* Set the process context of the serialize structure.*/
365
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
366
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
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 )
374
/* Call the serialized function. */
375
ulFncRes = Oct6100ChannelOpenSer( f_pApiInstance, f_pChannelOpen );
382
/* Release the seized semaphores. */
383
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
384
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
386
/* If an error occured then return the error code. */
387
if ( ulSerRes != cOCT6100_ERR_OK )
389
if ( ulFncRes != cOCT6100_ERR_OK )
392
return cOCT6100_ERR_OK;
396
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
398
Function: Oct6100ChannelModify
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.
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.
410
f_pChannelModify Pointer to echo channel change structure.
412
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
413
static UINT32 Oct6100ChannelModifyDef(
414
IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify )
416
f_pChannelModify->ulChannelHndl = cOCT6100_INVALID_HANDLE;
417
f_pChannelModify->ulUserChanId = cOCT6100_KEEP_PREVIOUS_SETTING;
418
f_pChannelModify->ulEchoOperationMode = cOCT6100_KEEP_PREVIOUS_SETTING;
420
f_pChannelModify->fEnableToneDisabler = cOCT6100_KEEP_PREVIOUS_SETTING;
422
f_pChannelModify->fApplyToAllChannels = FALSE;
424
f_pChannelModify->fDisableToneDetection = FALSE;
425
f_pChannelModify->fStopBufferPlayout = FALSE;
426
f_pChannelModify->fRemoveConfBridgeParticipant = FALSE;
427
f_pChannelModify->fRemoveBroadcastTssts = FALSE;
429
f_pChannelModify->fTdmConfigModified = FALSE;
430
f_pChannelModify->fVqeConfigModified = FALSE;
431
f_pChannelModify->fCodecConfigModified = FALSE;
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;
454
f_pChannelModify->VqeConfig.fDtmfToneRemoval = cOCT6100_KEEP_PREVIOUS_SETTING;
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;
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;
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;
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;
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;
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;
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;
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;
507
return cOCT6100_ERR_OK;
510
static UINT32 Oct6100ChannelModify(
511
IN tPOCT6100_INSTANCE_API f_pApiInstance,
512
IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify )
514
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
515
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
516
UINT32 ulSerRes = cOCT6100_ERR_OK;
517
UINT32 ulFncRes = cOCT6100_ERR_OK;
519
/* Set the process context of the serialize structure.*/
520
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
521
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
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 )
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;
534
/* Check if must apply modification to all channels. */
535
if ( f_pChannelModify->fApplyToAllChannels == TRUE )
537
tPOCT6100_API_CHANNEL pChanEntry;
540
/* Loop through all channels and look for the opened ones. */
541
for ( usChanIndex = 0; usChanIndex < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; usChanIndex++ )
543
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, usChanIndex );
545
/* Check if this one is opened. */
546
if ( pChanEntry->fReserved == TRUE )
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;
551
/* Call the serialized function. */
552
ulFncRes = Oct6100ChannelModifySer( f_pApiInstance, f_pChannelModify );
553
if ( ulFncRes != cOCT6100_ERR_OK )
558
else /* if ( f_pChannelModify->fApplyToAllChannels == FALSE ) */
560
/* Call the serialized function. */
561
ulFncRes = Oct6100ChannelModifySer( f_pApiInstance, f_pChannelModify );
569
/* Release the seized semaphores. */
570
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
571
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
573
/* If an error occured then return the error code. */
574
if ( ulSerRes != cOCT6100_ERR_OK )
576
if ( ulFncRes != cOCT6100_ERR_OK )
579
return cOCT6100_ERR_OK;
582
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
584
Function: Oct6100ChannelBroadcastTsstRemove
586
Description: This function removes a TSST from one of the two output ports of a channel.
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.
594
f_pChannelBroadcastTsstRemove Pointer to the a Remove Broadcast TSST structure.
596
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
597
static UINT32 Oct6100ChannelBroadcastTsstRemoveDef(
598
tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelBroadcastTsstRemove )
600
f_pChannelBroadcastTsstRemove->ulChannelHndl = cOCT6100_INVALID_HANDLE;
602
f_pChannelBroadcastTsstRemove->ulPort = cOCT6100_INVALID_PORT;
603
f_pChannelBroadcastTsstRemove->ulTimeslot = cOCT6100_INVALID_TIMESLOT;
604
f_pChannelBroadcastTsstRemove->ulStream = cOCT6100_INVALID_STREAM;
606
f_pChannelBroadcastTsstRemove->fRemoveAll = FALSE;
608
return cOCT6100_ERR_OK;
611
#if 0 /* unused functions */
613
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
615
Function: Oct6100ChannelMute
617
Description: This function mutes some or all of the ports designated by
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.
626
f_pChannelMute Pointer to a tPOCT6100_CHANNEL_MUTE structure.
628
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
629
static UINT32 Oct6100ChannelMuteDef(
630
IN OUT tPOCT6100_CHANNEL_MUTE f_pChannelMute )
632
f_pChannelMute->ulChannelHndl = cOCT6100_INVALID_HANDLE;
633
f_pChannelMute->ulPortMask = cOCT6100_CHANNEL_MUTE_PORT_NONE;
635
return cOCT6100_ERR_OK;
638
static UINT32 Oct6100ChannelMute(
639
IN tPOCT6100_INSTANCE_API f_pApiInstance,
640
IN OUT tPOCT6100_CHANNEL_MUTE f_pChannelMute )
642
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
643
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
644
UINT32 ulSerRes = cOCT6100_ERR_OK;
645
UINT32 ulFncRes = cOCT6100_ERR_OK;
647
/* Set the process context of the serialize structure.*/
648
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
649
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
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 )
657
/* Call the serialized function. */
658
ulFncRes = Oct6100ChannelMuteSer( f_pApiInstance, f_pChannelMute );
665
/* Release the seized semaphores. */
666
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
667
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
669
/* If an error occured then return the error code. */
670
if ( ulSerRes != cOCT6100_ERR_OK )
672
if ( ulFncRes != cOCT6100_ERR_OK )
675
return cOCT6100_ERR_OK;
678
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
680
Function: Oct6100ChannelUnMute
682
Description: This function unmutes some or all of the ports designated by
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.
691
f_pChannelUnMute Pointer to a tPOCT6100_CHANNEL_UNMUTE structure.
693
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
694
static UINT32 Oct6100ChannelUnMuteDef(
695
IN OUT tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute )
697
f_pChannelUnMute->ulChannelHndl = cOCT6100_INVALID_HANDLE;
698
f_pChannelUnMute->ulPortMask = cOCT6100_CHANNEL_MUTE_PORT_NONE;
700
return cOCT6100_ERR_OK;
703
static UINT32 Oct6100ChannelUnMute(
704
IN tPOCT6100_INSTANCE_API f_pApiInstance,
705
IN OUT tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute )
707
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
708
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
709
UINT32 ulSerRes = cOCT6100_ERR_OK;
710
UINT32 ulFncRes = cOCT6100_ERR_OK;
712
/* Set the process context of the serialize structure.*/
713
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
714
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
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 )
722
/* Call the serialized function. */
723
ulFncRes = Oct6100ChannelUnMuteSer( f_pApiInstance, f_pChannelUnMute );
730
/* Release the seized semaphores. */
731
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
732
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
734
/* If an error occured then return the error code. */
735
if ( ulSerRes != cOCT6100_ERR_OK )
737
if ( ulFncRes != cOCT6100_ERR_OK )
740
return cOCT6100_ERR_OK;
743
/**************************** PRIVATE FUNCTIONS ****************************/
745
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
747
Function: Oct6100ApiGetChannelsEchoSwSizes
749
Description: Gets the sizes of all portions of the API instance pertinent
750
to the management of the ECHO memory.
752
-------------------------------------------------------------------------------
753
| Argument | Description
754
-------------------------------------------------------------------------------
755
f_pOpenChip Pointer to chip configuration struct.
756
f_pInstSizes Pointer to struct containing instance sizes.
758
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
759
static UINT32 Oct6100ApiGetChannelsEchoSwSizes(
760
IN tPOCT6100_CHIP_OPEN f_pOpenChip,
761
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
765
UINT32 ulMaxChannels;
767
ulMaxChannels = f_pOpenChip->ulMaxChannels;
769
if ( f_pOpenChip->fEnableChannelRecording == TRUE && ulMaxChannels != 672 )
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 )
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;
784
f_pInstSizes->ulChannelAlloc = 0;
786
if ( f_pOpenChip->ulMaxBiDirChannels > 0 )
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;
795
f_pInstSizes->ulBiDirChannelAlloc = 0;
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;
805
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
807
Function: Oct6100ApiChannelsEchoSwInit
809
Description: Initializes all elements of the instance structure associated
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.
818
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
819
static UINT32 Oct6100ApiChannelsEchoSwInit(
820
IN tPOCT6100_INSTANCE_API f_pApiInstance )
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;
830
/* Get local pointer to shared portion of the API instance. */
831
pSharedInfo = f_pApiInstance->pSharedInfo;
833
/* Initialize the ECHO channel API list.*/
834
usMaxChannels = pSharedInfo->ChipConfig.usMaxChannels;
836
/* add a channel to initialize if the recording is activated. */
837
if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
840
/* Set all entries in the ADCPM channel list to unused. */
841
mOCT6100_GET_CHANNEL_LIST_PNT( pSharedInfo, pChannelsEchoList );
843
/* Initialize the API ECHO channels allocation software to "all free". */
844
if ( usMaxChannels > 0 )
846
/* Clear the memory */
847
Oct6100UserMemSet( pChannelsEchoList, 0x00, sizeof(tOCT6100_API_CHANNEL) * usMaxChannels );
849
mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoChanAlloc )
851
ulResult = OctapiLlmAllocInit( &pEchoChanAlloc, usMaxChannels );
852
if ( ulResult != cOCT6100_ERR_OK )
853
return cOCT6100_ERR_FATAL_1;
856
mOCT6100_GET_BIDIR_CHANNEL_LIST_PNT( pSharedInfo, pBiDirChannelsList );
858
if ( pSharedInfo->ChipConfig.usMaxBiDirChannels > 0 )
860
/* Clear the memory */
861
Oct6100UserMemSet( pBiDirChannelsList, 0x00, sizeof(tOCT6100_API_BIDIR_CHANNEL) * pSharedInfo->ChipConfig.usMaxBiDirChannels );
863
mOCT6100_GET_BIDIR_CHANNEL_ALLOC_PNT( pSharedInfo, pBiDirChanAlloc )
865
ulResult = OctapiLlmAllocInit( &pBiDirChanAlloc, pSharedInfo->ChipConfig.usMaxBiDirChannels );
866
if ( ulResult != cOCT6100_ERR_OK )
867
return cOCT6100_ERR_FATAL_A9;
871
return cOCT6100_ERR_OK;
882
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
884
Function: Oct6100ChannelOpenSer
886
Description: Opens a echo cancellation channel.
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.
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.
898
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
899
static UINT32 Oct6100ChannelOpenSer(
900
IN tPOCT6100_INSTANCE_API f_pApiInstance,
901
IN OUT tPOCT6100_CHANNEL_OPEN f_pChannelOpen )
903
tOCT6100_API_ECHO_CHAN_INDEX ChannelIndexConf;
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 )
911
/* Reserve all resources needed by the echo cancellation channel. */
912
ulResult = Oct6100ApiReserveChannelResources( f_pApiInstance, f_pChannelOpen, &ChannelIndexConf );
913
if ( ulResult != cOCT6100_ERR_OK )
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 )
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 )
926
return cOCT6100_ERR_OK;
929
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
931
Function: Oct6100ApiCheckChannelParams
933
Description: Checks the user's echo cancellation channel open configuration for errors.
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.
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.
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 )
950
tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig;
951
tPOCT6100_CHANNEL_OPEN_VQE pVqeConfig;
952
tPOCT6100_CHANNEL_OPEN_CODEC pCodecConfig;
953
UINT32 ulDecoderNumTssts;
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;
961
/* Check for errors. */
962
if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels == 0 )
963
return cOCT6100_ERR_CHANNEL_DISABLED;
965
if ( f_pChannelOpen->pulChannelHndl == NULL )
966
return cOCT6100_ERR_CHANNEL_INVALID_HANDLE;
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;
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;
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;
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;
994
/*==============================================================================*/
995
/* Check the TDM configuration parameters.*/
997
ulResult = Oct6100ApiCheckTdmConfig( f_pApiInstance, pTdmConfig );
998
if ( ulResult != cOCT6100_ERR_OK )
1001
/*==============================================================================*/
1004
/*==============================================================================*/
1005
/* Now validate the VQE parameters */
1007
ulResult = Oct6100ApiCheckVqeConfig( f_pApiInstance, pVqeConfig, f_pChannelOpen->fEnableToneDisabler );
1008
if ( ulResult != cOCT6100_ERR_OK )
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;
1016
/*==============================================================================*/
1018
/*==============================================================================*/
1019
/* Finally, validate the CODEC configuration.*/
1021
if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1022
ulDecoderNumTssts = pTdmConfig->ulRinNumTssts;
1023
else /* pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
1024
ulDecoderNumTssts = pTdmConfig->ulSinNumTssts;
1026
ulResult = Oct6100ApiCheckCodecConfig( f_pApiInstance, pCodecConfig, ulDecoderNumTssts, &f_pChanIndexConf->usPhasingTsstIndex );
1027
if ( ulResult != cOCT6100_ERR_OK )
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;
1036
/* Verify if law conversion is allowed. */
1037
if ( pCodecConfig->ulEncoderPort == cOCT6100_NO_ENCODING ||
1038
pCodecConfig->ulDecoderPort == cOCT6100_NO_DECODING )
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;
1044
if ( pTdmConfig->ulSinPcmLaw != pTdmConfig->ulSoutPcmLaw )
1045
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_LAW_TRANSLATION;
1048
/* Verify if the config supports extended tone detection.*/
1049
if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
1051
if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1052
return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT;
1054
/*==============================================================================*/
1056
return cOCT6100_ERR_OK;
1059
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1061
Function: Oct6100ApiReserveChannelResources
1063
Description: Reserves all resources needed for the new channel.
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.
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.
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 )
1081
tPOCT6100_SHARED_INFO pSharedInfo;
1082
tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig;
1083
tPOCT6100_CHANNEL_OPEN_CODEC pCodecConfig;
1087
UINT32 ulFreeMixerEventCnt;
1089
BOOL fRinTsstEntry = FALSE;
1090
BOOL fSinTsstEntry = FALSE;
1091
BOOL fRoutTsstEntry = FALSE;
1092
BOOL fSoutTsstEntry = FALSE;
1094
BOOL fRinRoutTsiMemEntry = FALSE;
1095
BOOL fSinSoutTsiMemEntry = FALSE;
1097
BOOL fEchoChanEntry = FALSE;
1099
PUINT16 pusRinRoutConversionMemIndex = NULL;
1100
PUINT16 pusSinSoutConversionMemIndex = NULL;
1101
BOOL fRinRoutConversionMemEntry = FALSE;
1102
BOOL fSinSoutConversionMemEntry = FALSE;
1104
BOOL fExtToneChanEntry = FALSE;
1105
BOOL fExtToneTsiEntry = FALSE;
1106
BOOL fExtToneMixerEntry = FALSE;
1108
/* Obtain local pointer to shared portion of instance. */
1109
pSharedInfo = f_pApiInstance->pSharedInfo;
1111
/* Obtain a local pointer to the configuration structures.*/
1112
pTdmConfig = &f_pChannelOpen->TdmConfig;
1113
pCodecConfig = &f_pChannelOpen->CodecConfig;
1115
/*===============================================================================*/
1116
/* Reserve Echo and TSI entries. */
1118
ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance,
1119
&f_pChanIndexConf->usEchoChanIndex );
1120
if ( ulResult == cOCT6100_ERR_OK )
1122
fEchoChanEntry = TRUE;
1124
/* Set the echo, encoder and decoder memory indexes.*/
1125
f_pChanIndexConf->usEchoMemIndex = f_pChanIndexConf->usEchoChanIndex;
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 )
1132
fRinRoutTsiMemEntry = TRUE;
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 )
1139
fSinSoutTsiMemEntry = TRUE;
1141
/* Reserve an ADPCM memory block for compression if required.*/
1142
if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
1144
pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex;
1146
else if ( pCodecConfig->ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT )
1148
pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex;
1151
/* Reserve an ADPCM memory block for decompression if required.*/
1152
if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1154
pusRinRoutConversionMemIndex = &f_pChanIndexConf->usRinRoutConversionMemIndex;
1156
else if ( pCodecConfig->ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN )
1158
pusSinSoutConversionMemIndex = &f_pChanIndexConf->usSinSoutConversionMemIndex;
1162
/* Reserve the conversion memories. */
1163
if ( pusRinRoutConversionMemIndex != NULL )
1165
/* Reserve a conversion memory for the Rin/Rout stream. */
1166
ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance,
1167
pusRinRoutConversionMemIndex );
1168
if ( ulResult == cOCT6100_ERR_OK )
1170
fRinRoutConversionMemEntry = TRUE;
1175
/* No conversion memory reserved.*/
1176
f_pChanIndexConf->usRinRoutConversionMemIndex = cOCT6100_INVALID_INDEX;
1179
if ( ( pusSinSoutConversionMemIndex != NULL ) &&
1180
( ulResult == cOCT6100_ERR_OK ) )
1182
/* Reserve a conversion memory for the Sin/Sout stream. */
1183
ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance,
1184
pusSinSoutConversionMemIndex );
1185
if ( ulResult == cOCT6100_ERR_OK )
1187
fSinSoutConversionMemEntry = TRUE;
1192
/* No conversion memory reserved.*/
1193
f_pChanIndexConf->usSinSoutConversionMemIndex = cOCT6100_INVALID_INDEX;
1196
/* Reserve any resources required if the extended Tone detection is enabled.*/
1197
if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
1199
ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance,
1200
&f_pChanIndexConf->usExtToneChanIndex );
1201
if ( ulResult == cOCT6100_ERR_OK )
1203
fExtToneChanEntry = TRUE;
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 )
1210
fExtToneTsiEntry = TRUE;
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;
1222
f_pChanIndexConf->usExtToneChanIndex = cOCT6100_INVALID_INDEX;
1223
f_pChanIndexConf->usExtToneMixerIndex = cOCT6100_INVALID_INDEX;
1224
f_pChanIndexConf->usExtToneTsiIndex = cOCT6100_INVALID_INDEX;
1229
/* Return an error other then a Fatal.*/
1230
ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY;
1235
/* Return an error other then a Fatal.*/
1236
ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_TSI_MEMORY;
1240
/*===============================================================================*/
1242
/*===============================================================================*/
1243
/* Now reserve the TSST entries if required.*/
1245
/* Reserve the Rin TSST entry */
1246
if ( (ulResult == cOCT6100_ERR_OK ) &&
1247
(pTdmConfig->ulRinTimeslot != cOCT6100_UNASSIGNED &&
1248
pTdmConfig->ulRinStream != cOCT6100_UNASSIGNED) )
1250
ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
1251
pTdmConfig->ulRinTimeslot,
1252
pTdmConfig->ulRinStream,
1253
pTdmConfig->ulRinNumTssts,
1254
cOCT6100_INPUT_TSST,
1255
&f_pChanIndexConf->usRinTsstIndex,
1257
if ( ulResult == cOCT6100_ERR_OK )
1258
fRinTsstEntry = TRUE;
1262
f_pChanIndexConf->usRinTsstIndex = cOCT6100_INVALID_INDEX;
1266
if ( (ulResult == cOCT6100_ERR_OK ) &&
1267
(pTdmConfig->ulSinTimeslot != cOCT6100_UNASSIGNED &&
1268
pTdmConfig->ulSinStream != cOCT6100_UNASSIGNED) )
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,
1278
if ( ulResult == cOCT6100_ERR_OK )
1279
fSinTsstEntry = TRUE;
1283
f_pChanIndexConf->usSinTsstIndex = cOCT6100_INVALID_INDEX;
1286
if ( (ulResult == cOCT6100_ERR_OK ) &&
1287
(pTdmConfig->ulRoutTimeslot != cOCT6100_UNASSIGNED &&
1288
pTdmConfig->ulRoutStream != cOCT6100_UNASSIGNED) )
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,
1298
if ( ulResult == cOCT6100_ERR_OK )
1299
fRoutTsstEntry = TRUE;
1303
f_pChanIndexConf->usRoutTsstIndex = cOCT6100_INVALID_INDEX;
1307
if ( (ulResult == cOCT6100_ERR_OK ) &&
1308
(pTdmConfig->ulSoutTimeslot != cOCT6100_UNASSIGNED &&
1309
pTdmConfig->ulSoutStream != cOCT6100_UNASSIGNED) )
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,
1319
if ( ulResult == cOCT6100_ERR_OK )
1320
fSoutTsstEntry = TRUE;
1324
f_pChanIndexConf->usSoutTsstIndex = cOCT6100_INVALID_INDEX;
1327
/*===============================================================================*/
1330
/*===============================================================================*/
1331
/* Check if there are a couple of mixer events available for us. */
1333
if ( ulResult == cOCT6100_ERR_OK )
1335
UINT32 ulMixerEventCntNeeded = 0;
1337
/* Calculate how many mixer events are needed. */
1338
if ( f_pChanIndexConf->usRinTsstIndex == cOCT6100_INVALID_INDEX )
1339
ulMixerEventCntNeeded++;
1341
if ( f_pChanIndexConf->usSinTsstIndex == cOCT6100_INVALID_INDEX )
1342
ulMixerEventCntNeeded++;
1344
/* If at least 1 mixer event is needed, check if those are available. */
1345
if ( ulMixerEventCntNeeded != 0 )
1347
ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt );
1348
if ( ulResult == cOCT6100_ERR_OK )
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 )
1354
ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS;
1360
/*===============================================================================*/
1363
/*===============================================================================*/
1364
/* Release the resources if something went wrong */
1365
if ( ulResult != cOCT6100_ERR_OK )
1367
/*===============================================================================*/
1368
/* Release the previously reserved resources .*/
1369
if( fRinTsstEntry == TRUE )
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 )
1381
if( fSinTsstEntry == TRUE )
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 )
1393
if( fRoutTsstEntry == TRUE )
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 )
1405
if( fSoutTsstEntry == TRUE )
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 )
1417
if( fRinRoutTsiMemEntry == TRUE )
1419
ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
1420
f_pChanIndexConf->usRinRoutTsiMemIndex );
1421
if ( ulTempVar != cOCT6100_ERR_OK )
1425
if( fSinSoutTsiMemEntry == TRUE )
1427
ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
1428
f_pChanIndexConf->usSinSoutTsiMemIndex );
1429
if ( ulTempVar != cOCT6100_ERR_OK )
1433
/*===============================================================================*/
1435
/*===============================================================================*/
1436
/* Release the previously reserved echo resources .*/
1437
if( fEchoChanEntry == TRUE )
1439
ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance,
1440
f_pChanIndexConf->usEchoChanIndex );
1441
if ( ulTempVar != cOCT6100_ERR_OK )
1445
/*===============================================================================*/
1447
/*===============================================================================*/
1448
/* Release the previously reserved resources for the extended tone detection.*/
1449
if( fExtToneChanEntry == TRUE )
1451
ulTempVar = Oct6100ApiReleaseEchoEntry( f_pApiInstance,
1452
f_pChanIndexConf->usExtToneChanIndex );
1453
if ( ulTempVar != cOCT6100_ERR_OK )
1457
if( fExtToneTsiEntry == TRUE )
1459
ulTempVar = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance,
1460
f_pChanIndexConf->usExtToneTsiIndex );
1461
if ( ulTempVar != cOCT6100_ERR_OK )
1465
if( fExtToneMixerEntry == TRUE )
1467
ulTempVar = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
1468
f_pChanIndexConf->usExtToneMixerIndex );
1469
if ( ulTempVar != cOCT6100_ERR_OK )
1472
/*===============================================================================*/
1474
/*===============================================================================*/
1475
/* Release the conversion resources. */
1476
if( fRinRoutConversionMemEntry == TRUE )
1478
ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
1479
f_pChanIndexConf->usRinRoutConversionMemIndex );
1480
if ( ulTempVar != cOCT6100_ERR_OK )
1484
if( fSinSoutConversionMemEntry == TRUE )
1486
ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
1487
f_pChanIndexConf->usSinSoutConversionMemIndex );
1488
if ( ulTempVar != cOCT6100_ERR_OK )
1492
/*===============================================================================*/
1497
return cOCT6100_ERR_OK;
1501
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
1503
Function: Oct6100ApiWriteChannelStructs
1505
Description: Performs all the required structure writes to configure the
1506
new echo cancellation channel.
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.
1514
f_pChannelOpen Pointer to echo cancellation channel configuration structure.
1515
f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes.
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 )
1523
tPOCT6100_SHARED_INFO pSharedInfo;
1524
tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig;
1525
tOCT6100_WRITE_PARAMS WriteParams;
1526
tPOCT6100_API_CHANNEL pChanEntry;
1528
UINT32 ulDwordAddress;
1530
BOOL fConversionEnabled = FALSE;
1531
BOOL fProgramAdpcmMem;
1532
UINT32 ulCompType = 0;
1534
UINT16 usTempTsiMemIndex;
1535
UINT16 usConversionMemIndex;
1536
UINT32 ulToneEventNumber;
1539
/* Obtain local pointer to shared portion of instance. */
1540
pSharedInfo = f_pApiInstance->pSharedInfo;
1542
/* Obtain a local pointer to the TDM configuration structure.*/
1543
pTdmConfig = &f_pChannelOpen->TdmConfig;
1545
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
1547
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
1549
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex );
1551
/*==============================================================================*/
1552
/* Configure the Tsst control memory.*/
1554
/* Set the RIN Tsst control entry.*/
1555
if ( f_pChanIndexConf->usRinTsstIndex != cOCT6100_INVALID_INDEX )
1557
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
1558
f_pChanIndexConf->usRinTsstIndex,
1559
f_pChanIndexConf->usRinRoutTsiMemIndex,
1560
pTdmConfig->ulRinPcmLaw );
1561
if ( ulResult != cOCT6100_ERR_OK )
1565
/* Set the ROUT Tsst control entry.*/
1566
if ( f_pChanIndexConf->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
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 )
1577
/* Set the SIN Tsst control entry.*/
1578
if ( f_pChanIndexConf->usSinTsstIndex != cOCT6100_INVALID_INDEX )
1580
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
1581
f_pChanIndexConf->usSinTsstIndex,
1582
f_pChanIndexConf->usSinSoutTsiMemIndex,
1583
pTdmConfig->ulSinPcmLaw );
1584
if ( ulResult != cOCT6100_ERR_OK )
1588
/* Set the SOUT Tsst control entry.*/
1589
if ( f_pChanIndexConf->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
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 )
1600
/*==============================================================================*/
1602
/*==============================================================================*/
1603
/* Configure the ADPCM control memory for the Decoder.*/
1605
/* Set the codec state flags.*/
1606
f_pChanIndexConf->fRinRoutCodecActive = FALSE;
1607
f_pChanIndexConf->fSinSoutCodecActive = FALSE;
1609
if ( f_pChannelOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING )
1611
fProgramAdpcmMem = TRUE;
1613
switch( f_pChannelOpen->CodecConfig.ulDecodingRate )
1615
case cOCT6100_G711_64KBPS:
1617
if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1619
if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw )
1620
fProgramAdpcmMem = FALSE;
1622
else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
1624
if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
1625
fProgramAdpcmMem = FALSE;
1628
case cOCT6100_G726_40KBPS:
1630
fConversionEnabled = TRUE;
1633
case cOCT6100_G726_32KBPS:
1635
fConversionEnabled = TRUE;
1638
case cOCT6100_G726_24KBPS:
1640
fConversionEnabled = TRUE;
1643
case cOCT6100_G726_16KBPS:
1645
fConversionEnabled = TRUE;
1648
case cOCT6100_G727_2C_ENCODED:
1650
fConversionEnabled = TRUE;
1653
case cOCT6100_G727_3C_ENCODED:
1655
fConversionEnabled = TRUE;
1658
case cOCT6100_G727_4C_ENCODED:
1660
fConversionEnabled = TRUE;
1663
case cOCT6100_G726_ENCODED:
1665
fConversionEnabled = TRUE;
1668
case cOCT6100_G711_G726_ENCODED:
1670
fConversionEnabled = TRUE;
1673
case cOCT6100_G711_G727_2C_ENCODED:
1675
fConversionEnabled = TRUE;
1678
case cOCT6100_G711_G727_3C_ENCODED:
1680
fConversionEnabled = TRUE;
1683
case cOCT6100_G711_G727_4C_ENCODED:
1685
fConversionEnabled = TRUE;
1688
return cOCT6100_ERR_FATAL_D4;
1691
if ( fProgramAdpcmMem == TRUE )
1693
/* Set the chariot memory based on the selected port.*/
1694
if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
1696
usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
1697
ulPcmLaw = pTdmConfig->ulRoutPcmLaw; /* Set the law for later use */
1699
/* Set the codec state flags.*/
1700
f_pChanIndexConf->fRinRoutCodecActive = TRUE;
1702
/* Set the conversion memory index to use for decompression */
1703
usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
1705
else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
1707
usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
1708
ulPcmLaw = pTdmConfig->ulSoutPcmLaw; /* Set the law for later use */
1710
/* Set the codec state flags.*/
1711
f_pChanIndexConf->fSinSoutCodecActive = TRUE;
1713
/* Set the conversion memory index to use for decompression */
1714
usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
1717
ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance,
1718
usConversionMemIndex,
1722
f_pChannelOpen->CodecConfig.ulAdpcmNibblePosition );
1723
if ( ulResult != cOCT6100_ERR_OK )
1727
/*==============================================================================*/
1730
/*==============================================================================*/
1731
/* Configure the ADPCM control memory for the Encoder */
1733
if ( f_pChannelOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING )
1735
fProgramAdpcmMem = TRUE;
1737
switch( f_pChannelOpen->CodecConfig.ulEncodingRate )
1739
case cOCT6100_G711_64KBPS:
1740
if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
1742
if ( pTdmConfig->ulRoutPcmLaw == cOCT6100_PCM_U_LAW )
1747
/* Check for law conversion.*/
1748
if ( pTdmConfig->ulRinPcmLaw == pTdmConfig->ulRoutPcmLaw )
1749
fProgramAdpcmMem = FALSE;
1751
else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
1753
if ( pTdmConfig->ulSoutPcmLaw == cOCT6100_PCM_U_LAW )
1758
/* Check for law conversion.*/
1759
if ( pTdmConfig->ulSinPcmLaw == pTdmConfig->ulSoutPcmLaw )
1760
fProgramAdpcmMem = FALSE;
1764
case cOCT6100_G726_40KBPS:
1766
fConversionEnabled = TRUE;
1769
case cOCT6100_G726_32KBPS:
1771
fConversionEnabled = TRUE;
1774
case cOCT6100_G726_24KBPS:
1776
fConversionEnabled = TRUE;
1779
case cOCT6100_G726_16KBPS:
1781
fConversionEnabled = TRUE;
1784
case cOCT6100_G727_40KBPS_4_1:
1786
fConversionEnabled = TRUE;
1789
case cOCT6100_G727_40KBPS_3_2:
1791
fConversionEnabled = TRUE;
1794
case cOCT6100_G727_40KBPS_2_3:
1796
fConversionEnabled = TRUE;
1799
case cOCT6100_G727_32KBPS_4_0:
1801
fConversionEnabled = TRUE;
1804
case cOCT6100_G727_32KBPS_3_1:
1806
fConversionEnabled = TRUE;
1809
case cOCT6100_G727_32KBPS_2_2:
1811
fConversionEnabled = TRUE;
1814
case cOCT6100_G727_24KBPS_3_0:
1816
fConversionEnabled = TRUE;
1819
case cOCT6100_G727_24KBPS_2_1:
1821
fConversionEnabled = TRUE;
1824
case cOCT6100_G727_16KBPS_2_0:
1826
fConversionEnabled = TRUE;
1830
return cOCT6100_ERR_FATAL_D5;
1833
/* Program the APDCM memory only if ADPCM is requried.*/
1834
if ( fProgramAdpcmMem == TRUE || f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
1836
/* Set the chariot memory based on the selected port.*/
1837
if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
1839
usTempTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
1841
/* Set the codec state flags.*/
1842
f_pChanIndexConf->fRinRoutCodecActive = TRUE;
1844
/* Set the conversion memory index to use for compression */
1845
usConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
1848
else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
1850
usTempTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
1852
/* Set the codec state flags.*/
1853
f_pChanIndexConf->fSinSoutCodecActive = TRUE;
1855
/* Set the conversion memory index to use for compression */
1856
usConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
1859
ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance,
1860
usConversionMemIndex,
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 )
1872
/*==============================================================================*/
1875
/*==============================================================================*/
1876
/* Clearing the tone events bit vector */
1878
ulDwordAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usEchoChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
1879
ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
1880
ulDwordData = 0x00000000;
1882
ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
1883
if ( ulResult != cOCT6100_ERR_OK )
1886
ulDwordAddress += 4;
1888
ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
1889
if ( ulResult != cOCT6100_ERR_OK )
1892
/*==============================================================================*/
1895
/*==============================================================================*/
1896
/* Write the VQE memory */
1898
ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance,
1899
&f_pChannelOpen->VqeConfig,
1901
f_pChanIndexConf->usEchoChanIndex,
1902
f_pChanIndexConf->usEchoMemIndex,
1905
if ( ulResult != cOCT6100_ERR_OK )
1908
/*==============================================================================*/
1910
/*==============================================================================*/
1911
/* Write the echo memory */
1913
ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance,
1916
f_pChanIndexConf->usEchoMemIndex,
1917
f_pChanIndexConf->usRinRoutTsiMemIndex,
1918
f_pChanIndexConf->usSinSoutTsiMemIndex );
1919
if ( ulResult != cOCT6100_ERR_OK )
1922
/*==============================================================================*/
1926
/*==============================================================================*/
1927
/* Mute channel if required, this is done on a port basis */
1929
/* Initialize the silence indexes to invalid for now. */
1930
pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
1931
pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
1933
/* Set the TSI memory indexes. */
1934
pChanEntry->usRinRoutTsiMemIndex = f_pChanIndexConf->usRinRoutTsiMemIndex;
1935
pChanEntry->usSinSoutTsiMemIndex = f_pChanIndexConf->usSinSoutTsiMemIndex;
1937
ulResult = Oct6100ApiMutePorts( f_pApiInstance,
1938
f_pChanIndexConf->usEchoChanIndex,
1939
f_pChanIndexConf->usRinTsstIndex,
1940
f_pChanIndexConf->usSinTsstIndex,
1942
if ( ulResult != cOCT6100_ERR_OK )
1945
/*==============================================================================*/
1948
/*==============================================================================*/
1949
/* Set the dominant speaker to unassigned, if required. */
1951
if ( f_pApiInstance->pSharedInfo->ImageInfo.fDominantSpeakerEnabled == TRUE )
1953
ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_pChanIndexConf->usEchoChanIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED );
1954
if ( ulResult != cOCT6100_ERR_OK )
1958
/*==============================================================================*/
1961
/*==============================================================================*/
1962
/* If necessary, configure the extended tone detection channel.*/
1964
if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
1966
UINT32 ulTempSinLaw;
1967
UINT32 ulTempSoutLaw;
1968
UINT32 ulTempEchoOpMode;
1970
/* save the original law.*/
1971
ulTempSinLaw = pTdmConfig->ulSinPcmLaw;
1972
ulTempSoutLaw = pTdmConfig->ulSoutPcmLaw;
1973
ulTempEchoOpMode = f_pChannelOpen->ulEchoOperationMode;
1975
/* Now, make sure the Sin and Sout law are the same as the Rin law.*/
1977
pTdmConfig->ulSinPcmLaw = pTdmConfig->ulRinPcmLaw;
1978
pTdmConfig->ulSoutPcmLaw = pTdmConfig->ulRinPcmLaw;
1980
f_pChannelOpen->ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_NORMAL;
1982
/* Write the Echo and VQE memory of the extended channel.*/
1984
ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance,
1986
&f_pChannelOpen->VqeConfig,
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 )
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. */
1998
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_pChanIndexConf->usExtToneMixerIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
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;
2004
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2005
if ( ulResult != cOCT6100_ERR_OK )
2008
WriteParams.ulWriteAddress += 2;
2009
WriteParams.usWriteData = f_pChanIndexConf->usExtToneTsiIndex;
2011
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
2012
if ( ulResult != cOCT6100_ERR_OK )
2015
/*=======================================================================*/
2018
/*=======================================================================*/
2019
/* Now insert the Sin copy event into the list.*/
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 )
2027
/*=======================================================================*/
2029
/*==============================================================================*/
2030
/* Clearing the tone events bit vector */
2032
ulDwordAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_pChanIndexConf->usExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
2033
ulDwordAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
2034
ulDwordData = 0x00000000;
2036
ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2037
if ( ulResult != cOCT6100_ERR_OK )
2040
ulDwordAddress += 4;
2042
ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulDwordAddress, ulDwordData );
2043
if ( ulResult != cOCT6100_ERR_OK )
2046
/*==============================================================================*/
2048
/* Write back the original values in the channel open structure.*/
2050
pTdmConfig->ulSinPcmLaw = ulTempSinLaw;
2051
pTdmConfig->ulSoutPcmLaw = ulTempSoutLaw;
2053
f_pChannelOpen->ulEchoOperationMode = ulTempEchoOpMode;
2056
/*==============================================================================*/
2059
/*==============================================================================*/
2060
/* If necessary, configure the SS tone detection. */
2062
for ( ulToneEventNumber = 0; ulToneEventNumber < cOCT6100_MAX_TONE_EVENT; ulToneEventNumber++ )
2064
/* Check if the current tone is a SS tone. */
2065
ulResult = Oct6100ApiIsSSTone(
2067
f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID,
2069
if ( ulResult != cOCT6100_ERR_OK )
2072
if ( fSSTone == TRUE )
2074
/* Write to all resources needed to activate tone detection on this SS tone. */
2075
ulResult = Oct6100ApiWriteToneDetectEvent(
2077
f_pChanIndexConf->usEchoChanIndex,
2080
cOCT6100_INVALID_INDEX );
2081
if ( ulResult != cOCT6100_ERR_OK )
2086
/*==============================================================================*/
2089
return cOCT6100_ERR_OK;
2094
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2096
Function: Oct6100ApiUpdateChannelEntry
2098
Description: Updates the new channel in the ECHO channel list.
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.
2106
f_pChannelOpen Pointer to echo cancellation channel configuration structure.
2107
f_pChanIndexConf Pointer to a structure used to store the multiple resources indexes.
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 )
2115
tPOCT6100_API_CHANNEL pChanEntry;
2116
tPOCT6100_CHANNEL_OPEN_TDM pTdmConfig;
2117
tPOCT6100_CHANNEL_OPEN_VQE pVqeConfig;
2118
tPOCT6100_CHANNEL_OPEN_CODEC pCodecConfig;
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;
2125
/* Obtain a pointer to the new buffer's list entry. */
2126
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_pChanIndexConf->usEchoChanIndex )
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 );
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 );
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 );
2158
pChanEntry->VqeConfig.fAcousticEcho = (UINT8)( pVqeConfig->fAcousticEcho & 0xFF );
2160
pChanEntry->VqeConfig.fDtmfToneRemoval = (UINT8)( pVqeConfig->fDtmfToneRemoval & 0xFF );
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 );
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 );
2179
/* Save the codec information.*/
2180
pChanEntry->CodecConfig.byAdpcmNibblePosition = (UINT8)( pCodecConfig->ulAdpcmNibblePosition & 0xFF );
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 );
2187
pChanEntry->CodecConfig.fEnableSilenceSuppression = (UINT8)( pCodecConfig->fEnableSilenceSuppression & 0xFF );
2188
pChanEntry->CodecConfig.byPhase = (UINT8)( pCodecConfig->ulPhase & 0xFF );
2189
pChanEntry->CodecConfig.byPhasingType = (UINT8)( pCodecConfig->ulPhasingType & 0xFF );
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 );
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 );
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 );
2206
pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
2207
pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0;
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 );
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;
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;
2226
if ( f_pChannelOpen->fEnableExtToneDetection == TRUE )
2228
tPOCT6100_API_CHANNEL pExtToneChanEntry;
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;
2234
/* Now, program the associated channel.*/
2236
/* Obtain a pointer to the extended tone detection channel entry. */
2237
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pExtToneChanEntry, f_pChanIndexConf->usExtToneChanIndex );
2239
pExtToneChanEntry->fReserved = TRUE;
2240
pExtToneChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_RIN_PORT_MODE; /* Detect on RIN port.*/
2241
pExtToneChanEntry->usExtToneChanIndex = f_pChanIndexConf->usEchoChanIndex;
2243
pExtToneChanEntry->aulToneConf[ 0 ] = 0;
2244
pExtToneChanEntry->aulToneConf[ 1 ] = 0;
2249
/* No extended tone detection supported.*/
2250
pChanEntry->ulExtToneChanMode = cOCT6100_API_EXT_TONE_DISABLED;
2253
/*=======================================================================*/
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;
2262
/* We are not being tapped for now. */
2263
pChanEntry->fBeingTapped = FALSE;
2265
pChanEntry->usTapChanIndex = cOCT6100_INVALID_INDEX;
2266
pChanEntry->usTapBridgeIndex = cOCT6100_INVALID_INDEX;
2268
/* The copy event has not yet been created. */
2269
pChanEntry->fCopyEventCreated = FALSE;
2271
pChanEntry->usRinRoutConversionMemIndex = f_pChanIndexConf->usRinRoutConversionMemIndex;
2272
pChanEntry->usSinSoutConversionMemIndex = f_pChanIndexConf->usSinSoutConversionMemIndex;
2274
pChanEntry->usPhasingTsstIndex = f_pChanIndexConf->usPhasingTsstIndex;
2276
pChanEntry->fSinSoutCodecActive = f_pChanIndexConf->fSinSoutCodecActive;
2277
pChanEntry->fRinRoutCodecActive = f_pChanIndexConf->fRinRoutCodecActive;
2281
pChanEntry->usEchoMemIndex = f_pChanIndexConf->usEchoMemIndex;
2283
pChanEntry->usRinTsstIndex = f_pChanIndexConf->usRinTsstIndex;
2284
pChanEntry->usSinTsstIndex = f_pChanIndexConf->usSinTsstIndex;
2285
pChanEntry->usRoutTsstIndex = f_pChanIndexConf->usRoutTsstIndex;
2286
pChanEntry->usSoutTsstIndex = f_pChanIndexConf->usSoutTsstIndex;
2288
pChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
2289
pChanEntry->usSoutCopyEventIndex = cOCT6100_INVALID_INDEX;
2291
/* Nothing muted for now. */
2292
pChanEntry->usMutedPorts = cOCT6100_CHANNEL_MUTE_PORT_NONE;
2294
/* Set all the GW feature initial value.*/
2296
pChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
2297
pChanEntry->fMute = FALSE;
2299
pChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX;
2300
pChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX;
2302
/* Buffer playout info.*/
2303
pChanEntry->fRinBufPlaying = FALSE;
2304
pChanEntry->fSoutBufPlaying = FALSE;
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;
2314
/* Initialize the bidirectional flag.*/
2315
pChanEntry->fBiDirChannel = FALSE;
2317
/*=======================================================================*/
2318
/* Init some of the stats.*/
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;
2325
/*=======================================================================*/
2327
/*=======================================================================*/
2328
/* Update the dependency of the phasing TSST if one is associated to the chanel.*/
2330
if ( f_pChanIndexConf->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
2332
tPOCT6100_API_PHASING_TSST pPhasingEntry;
2334
mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanIndexConf->usPhasingTsstIndex );
2336
pPhasingEntry->usDependencyCnt++;
2338
/*=======================================================================*/
2340
/*=======================================================================*/
2342
/* Form handle returned to user. */
2343
*f_pChannelOpen->pulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_pChanIndexConf->usEchoChanIndex;
2345
/* Finally, mark the channel as open. */
2346
pChanEntry->fReserved = TRUE;
2347
pChanEntry->usExtraSinTsiDependencyCnt = 0;
2349
/* Increment the number of channel open.*/
2350
f_pApiInstance->pSharedInfo->ChipStats.usNumberChannels++;
2352
/*=======================================================================*/
2354
return cOCT6100_ERR_OK;
2358
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2360
Function: Oct6100ChannelModifySer
2362
Description: Modify an echo cancellation channel.
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.
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.
2374
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
2375
static UINT32 Oct6100ChannelModifySer(
2376
IN tPOCT6100_INSTANCE_API f_pApiInstance,
2377
IN OUT tPOCT6100_CHANNEL_MODIFY f_pChannelModify )
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;
2390
/* We don't want this 290 byte structure on the stack */
2391
pTempChanOpen = (tOCT6100_CHANNEL_OPEN *)kmalloc(sizeof(tOCT6100_CHANNEL_OPEN),GFP_ATOMIC);
2393
return cOCT6100_ERR_CHANNEL_NOT_OPEN;
2395
/* Check the user's configuration of the echo cancellation channel for errors. */
2396
ulResult = Oct6100ApiCheckChannelModify( f_pApiInstance,
2399
&usNewPhasingTsstIndex,
2401
if ( ulResult != cOCT6100_ERR_OK )
2404
/* Reserve all resources needed by the echo cancellation channel. */
2405
ulResult = Oct6100ApiModifyChannelResources( f_pApiInstance,
2410
&usNewRoutTsstIndex,
2411
&usNewSoutTsstIndex );
2412
if ( ulResult != cOCT6100_ERR_OK )
2415
/* Write all necessary structures to activate the echo cancellation channel. */
2416
ulResult = Oct6100ApiModifyChannelStructs( f_pApiInstance,
2420
usNewPhasingTsstIndex,
2421
&fSinSoutCodecActive,
2422
&fRinRoutCodecActive,
2426
usNewSoutTsstIndex );
2427
if ( ulResult != cOCT6100_ERR_OK )
2430
/* Update the new echo cancellation channels's entry in the ECHO channel list. */
2431
ulResult = Oct6100ApiModifyChannelEntry( f_pApiInstance,
2435
usNewPhasingTsstIndex,
2436
fSinSoutCodecActive,
2437
fRinRoutCodecActive,
2441
usNewSoutTsstIndex );
2442
if ( ulResult != cOCT6100_ERR_OK )
2445
kfree(pTempChanOpen);
2447
return cOCT6100_ERR_OK;
2450
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2452
Function: Oct6100ApiCheckChannelModify
2454
Description: Checks the user's echo cancellation channel modify structure for errors.
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.
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
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 )
2475
tPOCT6100_API_CHANNEL pChanEntry;
2477
UINT32 ulEntryOpenCnt;
2478
UINT32 ulDecoderNumTssts;
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;
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;
2488
/*=======================================================================*/
2489
/* Get a pointer to the channel's list entry. */
2491
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
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;
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;
2502
/*=======================================================================*/
2505
/*=======================================================================*/
2506
/* Check the general modify parameters. */
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;
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;
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;
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;
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;
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;
2544
if ( f_pChannelModify->fCodecConfigModified != TRUE &&
2545
f_pChannelModify->fCodecConfigModified != FALSE )
2546
return cOCT6100_ERR_CHANNEL_MODIFY_CODEC_CONFIG;
2548
if ( f_pChannelModify->fVqeConfigModified != TRUE &&
2549
f_pChannelModify->fVqeConfigModified != FALSE )
2550
return cOCT6100_ERR_CHANNEL_MODIFY_VQE_CONFIG;
2552
if ( f_pChannelModify->fTdmConfigModified != TRUE &&
2553
f_pChannelModify->fTdmConfigModified != FALSE )
2554
return cOCT6100_ERR_CHANNEL_MODIFY_TDM_CONFIG;
2556
/*=======================================================================*/
2558
/*=======================================================================*/
2559
/* Verify if any law change was requested. If so reprogram all structures.*/
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 ))
2567
f_pChannelModify->fVqeConfigModified = TRUE;
2568
f_pChannelModify->fCodecConfigModified = TRUE;
2570
/*=======================================================================*/
2572
ulResult = Oct6100ApiUpdateOpenStruct( f_pApiInstance, f_pChannelModify, f_pTempChanOpen, pChanEntry );
2573
if ( ulResult != cOCT6100_ERR_OK )
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.*/
2581
/* Check the TDM config.*/
2582
if ( f_pChannelModify->fTdmConfigModified == TRUE )
2584
tPOCT6100_CHANNEL_MODIFY_TDM pModifyTdm;
2585
tPOCT6100_CHANNEL_OPEN_TDM pOpenTdm;
2587
pModifyTdm = &f_pChannelModify->TdmConfig;
2588
pOpenTdm = &f_pTempChanOpen->TdmConfig;
2590
ulResult = Oct6100ApiCheckTdmConfig( f_pApiInstance,
2592
if ( ulResult != cOCT6100_ERR_OK )
2595
/* Check if that Stream and Timeslot values are valid.*/
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;
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;
2606
if ( pChanEntry->fBeingTapped == TRUE )
2608
/* Check that the Rin stream + timeslot are not being assigned. */
2609
if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING )
2611
if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_UNASSIGNED )
2612
return cOCT6100_ERR_CHANNEL_RIN_STREAM;
2614
if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_UNASSIGNED )
2615
return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
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;
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;
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;
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;
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;
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;
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 )
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;
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;
2663
/* If this channel is on a conference bridge, a few more things must be checked. */
2664
if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
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 ) )
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;
2676
/* Check for Sin. */
2677
if ( ( f_pTempChanOpen->TdmConfig.ulSinTimeslot != cOCT6100_UNASSIGNED )
2678
&& ( f_pTempChanOpen->TdmConfig.ulSoutTimeslot != cOCT6100_UNASSIGNED ) )
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;
2685
/* Check if ADPCM is requested. */
2686
if ( f_pTempChanOpen->CodecConfig.ulEncoderPort != cOCT6100_NO_ENCODING &&
2687
f_pTempChanOpen->CodecConfig.ulEncodingRate != cOCT6100_G711_64KBPS )
2689
/* No ADPCM in a conference bridge! */
2690
return cOCT6100_ERR_CHANNEL_ENCODING_RATE;
2693
if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING &&
2694
f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS )
2696
/* No ADPCM in a conference bridge! */
2697
return cOCT6100_ERR_CHANNEL_DECODING_RATE;
2701
if ( f_pTempChanOpen->CodecConfig.ulEncoderPort == cOCT6100_NO_ENCODING ||
2702
f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_NO_DECODING )
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;
2711
if ( pChanEntry->fEnableExtToneDetection == TRUE &&
2712
f_pTempChanOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
2713
return cOCT6100_ERR_CHANNEL_EXT_TONE_DETECTION_DECODER_PORT;
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 )
2719
/* When the configuration to be applied is for all channels, */
2720
/* check that the stream and timeslot parameters are not being assigned. */
2722
/* Check the Rout port. */
2723
if ( f_pChannelModify->TdmConfig.ulRoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2724
f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
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;
2733
/* Check the Rin port. */
2734
if ( f_pChannelModify->TdmConfig.ulRinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2735
f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
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;
2744
/* Check the Sout port. */
2745
if ( f_pChannelModify->TdmConfig.ulSoutStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2746
f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
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;
2755
/* Check the Sin port. */
2756
if ( f_pChannelModify->TdmConfig.ulSinStream != cOCT6100_KEEP_PREVIOUS_SETTING &&
2757
f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
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;
2768
/* Check the VQE config.*/
2769
if ( f_pChannelModify->fVqeConfigModified == TRUE )
2771
ulResult = Oct6100ApiCheckVqeConfig( f_pApiInstance,
2772
&f_pTempChanOpen->VqeConfig,
2773
f_pTempChanOpen->fEnableToneDisabler );
2774
if ( ulResult != cOCT6100_ERR_OK )
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;
2783
/* Check the Codec config.*/
2784
if ( f_pChannelModify->fCodecConfigModified == TRUE )
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;
2791
ulResult = Oct6100ApiCheckCodecConfig( f_pApiInstance,
2792
&f_pTempChanOpen->CodecConfig,
2794
f_pusNewPhasingTsstIndex );
2795
if ( ulResult != cOCT6100_ERR_OK )
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;
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 )
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;
2813
if ( f_pTempChanOpen->CodecConfig.ulDecoderPort != cOCT6100_NO_DECODING &&
2814
f_pTempChanOpen->CodecConfig.ulDecodingRate != cOCT6100_G711_64KBPS )
2815
return cOCT6100_ERR_CHANNEL_DECODING_RATE;
2819
/*=======================================================================*/
2821
return cOCT6100_ERR_OK;
2824
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
2826
Function: Oct6100ApiModifyChannelResources
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.
2835
f_pChannelModify Pointer to echo cancellation channel configuration structure.
2836
f_usChanIndex Allocated entry in ECHO channel list.
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 )
2848
tPOCT6100_API_CHANNEL pChanEntry;
2849
tPOCT6100_SHARED_INFO pSharedInfo;
2851
tPOCT6100_API_CHANNEL_TDM pApiTdmConf;
2852
tPOCT6100_CHANNEL_MODIFY_TDM pModifyTdmConf;
2854
UINT32 ulResult = cOCT6100_ERR_OK;
2855
UINT32 ulTempVar = cOCT6100_ERR_OK;
2856
UINT32 ulFreeMixerEventCnt;
2858
BOOL fRinReleased = FALSE;
2859
BOOL fSinReleased = FALSE;
2860
BOOL fRoutReleased = FALSE;
2861
BOOL fSoutReleased = FALSE;
2863
BOOL fRinReserved = FALSE;
2864
BOOL fSinReserved = FALSE;
2865
BOOL fRoutReserved = FALSE;
2866
BOOL fSoutReserved = FALSE;
2868
BOOL fReserveRin = FALSE;
2869
BOOL fReserveSin = FALSE;
2870
BOOL fReserveRout = FALSE;
2871
BOOL fReserveSout = FALSE;
2873
BOOL fRinRoutConversionMemReserved = FALSE;
2874
BOOL fSinSoutConversionMemReserved = FALSE;
2877
UINT32 ulRinNumTssts = 1;
2878
UINT32 ulSinNumTssts = 1;
2879
UINT32 ulRoutNumTssts = 1;
2880
UINT32 ulSoutNumTssts = 1;
2882
/* Obtain local pointer to shared portion of instance. */
2883
pSharedInfo = f_pApiInstance->pSharedInfo;
2885
/* Obtain local pointer to the TDM configuration structure of the tPOCT6100_CHANNEL_MODIFY structure. */
2886
pModifyTdmConf = &f_pChannelModify->TdmConfig;
2888
/*=======================================================================*/
2889
/* Get a pointer to the channel's list entry. */
2890
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
2892
/* Obtain local pointer to the TDM configuration structure of the tPOCT6100_API_CHANNEL structure. */
2893
pApiTdmConf = &pChanEntry->TdmConfig;
2895
/*===============================================================================*/
2896
/* Modify TSST resources if required.*/
2897
if ( f_pChannelModify->fTdmConfigModified == TRUE )
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 )
2904
if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
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 )
2915
fRinReleased = TRUE;
2922
/* Release SIN port.*/
2923
if ( ( ulResult == cOCT6100_ERR_OK )
2924
&& ( ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2925
|| ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
2928
if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
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 )
2939
fSinReleased = TRUE;
2946
/* Release ROUT port.*/
2947
if ( ( ulResult == cOCT6100_ERR_OK )
2948
&& ( ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
2949
|| ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
2952
if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
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 )
2963
fRoutReleased = TRUE;
2967
fReserveRout = TRUE;
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 )
2976
if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
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 )
2987
fSoutReleased = TRUE;
2991
fReserveSout = TRUE;
2994
/* Now reserve any new entry required.*/
2996
/* Modify RIN port.*/
2997
if ( ( fReserveRin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
2999
if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_UNASSIGNED )
3001
/* Check what number of TSSTs should be reserved this time. */
3002
if ( pModifyTdmConf->ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
3004
ulRinNumTssts = pApiTdmConf->byRinNumTssts;
3006
else /* if ( pModifyTdmConf->ulRinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3008
/* New number of TSSTs. */
3009
ulRinNumTssts = pModifyTdmConf->ulRinNumTssts;
3012
if ( pModifyTdmConf->ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3014
/* Reserve the new number of TSSTs. */
3015
ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
3016
pApiTdmConf->usRinTimeslot,
3017
pApiTdmConf->usRinStream,
3019
cOCT6100_INPUT_TSST,
3020
f_pusNewRinTsstIndex,
3023
else /* if ( pModifyTdmConf->ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3025
/* Reserve the new TSST.*/
3026
ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
3027
pModifyTdmConf->ulRinTimeslot,
3028
pModifyTdmConf->ulRinStream,
3030
cOCT6100_INPUT_TSST,
3031
f_pusNewRinTsstIndex,
3033
if ( ulResult == cOCT6100_ERR_OK )
3035
fRinReserved = TRUE;
3041
*f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX;
3046
*f_pusNewRinTsstIndex = cOCT6100_INVALID_INDEX;
3049
/* Modify SIN port.*/
3050
if ( ( fReserveSin == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
3052
if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_UNASSIGNED )
3054
/* Check what number of TSSTs should be reserved this time. */
3055
if ( pModifyTdmConf->ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
3057
ulSinNumTssts = pApiTdmConf->bySinNumTssts;
3059
else /* if ( pModifyTdmConf->ulSinNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3061
/* New number of TSSTs. */
3062
ulSinNumTssts = pModifyTdmConf->ulSinNumTssts;
3065
if ( pModifyTdmConf->ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3067
/* Reserve the new number of TSSTs. */
3068
ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
3069
pApiTdmConf->usSinTimeslot,
3070
pApiTdmConf->usSinStream,
3072
cOCT6100_INPUT_TSST,
3073
f_pusNewSinTsstIndex,
3076
else /* if ( pModifyTdmConf->ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3078
/* Reserve the new TSST.*/
3079
ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
3080
pModifyTdmConf->ulSinTimeslot,
3081
pModifyTdmConf->ulSinStream,
3083
cOCT6100_INPUT_TSST,
3084
f_pusNewSinTsstIndex,
3086
if ( ulResult == cOCT6100_ERR_OK )
3088
fSinReserved = TRUE;
3094
*f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX;
3099
*f_pusNewSinTsstIndex = cOCT6100_INVALID_INDEX;
3102
/* Modify ROUT port.*/
3103
if ( ( fReserveRout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
3105
if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_UNASSIGNED )
3107
/* Check what number of TSSTs should be reserved this time. */
3108
if ( pModifyTdmConf->ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
3110
ulRoutNumTssts = pApiTdmConf->byRoutNumTssts;
3112
else /* if ( pModifyTdmConf->ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3114
/* New number of TSSTs. */
3115
ulRoutNumTssts = pModifyTdmConf->ulRoutNumTssts;
3118
if ( pModifyTdmConf->ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3120
/* Reserve the new number of TSSTs. */
3121
ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
3122
pApiTdmConf->usRoutTimeslot,
3123
pApiTdmConf->usRoutStream,
3125
cOCT6100_OUTPUT_TSST,
3126
f_pusNewRoutTsstIndex,
3129
else /* if ( pModifyTdmConf->ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3131
/* Reserve the new TSST.*/
3132
ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
3133
pModifyTdmConf->ulRoutTimeslot,
3134
pModifyTdmConf->ulRoutStream,
3136
cOCT6100_OUTPUT_TSST,
3137
f_pusNewRoutTsstIndex,
3139
if ( ulResult == cOCT6100_ERR_OK )
3141
fRoutReserved = TRUE;
3147
*f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX;
3152
*f_pusNewRoutTsstIndex = cOCT6100_INVALID_INDEX;
3155
/* Modify SOUT port.*/
3156
if ( ( fReserveSout == TRUE ) && ( ulResult == cOCT6100_ERR_OK ) )
3158
if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_UNASSIGNED )
3160
/* Check what number of TSSTs should be reserved this time. */
3161
if ( pModifyTdmConf->ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
3163
ulSoutNumTssts = pApiTdmConf->bySoutNumTssts;
3165
else /* if ( pModifyTdmConf->ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3167
/* New number of TSSTs. */
3168
ulSoutNumTssts = pModifyTdmConf->ulSoutNumTssts;
3171
if ( pModifyTdmConf->ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
3173
/* Reserve the new number of TSSTs. */
3174
ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
3175
pApiTdmConf->usSoutTimeslot,
3176
pApiTdmConf->usSoutStream,
3178
cOCT6100_OUTPUT_TSST,
3179
f_pusNewSoutTsstIndex,
3182
else /* if ( pModifyTdmConf->ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING ) */
3184
/* Reserve the new TSST.*/
3185
ulResult = Oct6100ApiReserveTsst( f_pApiInstance,
3186
pModifyTdmConf->ulSoutTimeslot,
3187
pModifyTdmConf->ulSoutStream,
3189
cOCT6100_OUTPUT_TSST,
3190
f_pusNewSoutTsstIndex,
3192
if ( ulResult == cOCT6100_ERR_OK )
3194
fSoutReserved = TRUE;
3200
*f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX;
3205
*f_pusNewSoutTsstIndex = cOCT6100_INVALID_INDEX;
3211
if ( f_pChannelModify->fCodecConfigModified == TRUE )
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 ) )
3218
/* Reserve an ADPCM memory block.*/
3219
ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usRinRoutConversionMemIndex );
3220
if ( ulResult == cOCT6100_ERR_OK )
3222
fRinRoutConversionMemReserved = TRUE;
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 ) )
3231
/* Reserve an ADPCM memory block.*/
3232
ulResult = Oct6100ApiReserveConversionMemEntry( f_pApiInstance, &pChanEntry->usSinSoutConversionMemIndex );
3233
if ( ulResult == cOCT6100_ERR_OK )
3235
fSinSoutConversionMemReserved = TRUE;
3241
/*===============================================================================*/
3242
/* Check if there are a couple of mixer events available for us. */
3244
if ( ulResult == cOCT6100_ERR_OK )
3246
UINT32 ulMixerEventCntNeeded = 0;
3248
/* Calculate how many mixer events are needed. */
3249
if ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX )
3251
/* If the channel is in bidir mode, do not create the Rin silence event!!! */
3252
if ( pChanEntry->fBiDirChannel == FALSE )
3254
if ( ( *f_pusNewRinTsstIndex == cOCT6100_INVALID_INDEX )
3255
&& ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
3256
ulMixerEventCntNeeded++;
3260
if ( ( *f_pusNewSinTsstIndex == cOCT6100_INVALID_INDEX )
3261
&& ( pChanEntry->usSinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
3263
ulMixerEventCntNeeded++;
3266
/* If at least 1 mixer event is needed, check if those are available. */
3267
if ( ulMixerEventCntNeeded != 0 )
3269
ulResult = Oct6100ApiGetFreeMixerEventCnt( f_pApiInstance, &ulFreeMixerEventCnt );
3270
if ( ulResult == cOCT6100_ERR_OK )
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 )
3276
ulResult = cOCT6100_ERR_CHANNEL_OUT_OF_MIXER_EVENTS;
3282
/*===============================================================================*/
3284
/* Verify if an error occured. */
3285
if ( ulResult != cOCT6100_ERR_OK )
3287
/* Release any resources newly reserved.*/
3288
if ( fRinReserved == TRUE )
3290
ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
3291
pModifyTdmConf->ulRinTimeslot,
3292
pModifyTdmConf->ulRinStream,
3294
cOCT6100_INPUT_TSST,
3295
cOCT6100_INVALID_INDEX );
3296
if ( ulTempVar != cOCT6100_ERR_OK )
3300
/* For the SIN port.*/
3301
if ( fSinReserved == TRUE )
3303
ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
3304
pModifyTdmConf->ulSinTimeslot,
3305
pModifyTdmConf->ulSinStream,
3307
cOCT6100_INPUT_TSST,
3308
cOCT6100_INVALID_INDEX );
3309
if ( ulTempVar != cOCT6100_ERR_OK )
3313
/* For the ROUT port.*/
3314
if ( fRoutReserved == TRUE )
3316
ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
3317
pModifyTdmConf->ulRoutTimeslot,
3318
pModifyTdmConf->ulRoutStream,
3320
cOCT6100_OUTPUT_TSST,
3321
cOCT6100_INVALID_INDEX );
3322
if ( ulTempVar != cOCT6100_ERR_OK )
3326
/* For the SOUT port.*/
3327
if ( fSoutReserved == TRUE )
3329
ulTempVar = Oct6100ApiReleaseTsst( f_pApiInstance,
3330
pModifyTdmConf->ulSoutTimeslot,
3331
pModifyTdmConf->ulSoutStream,
3333
cOCT6100_OUTPUT_TSST,
3334
cOCT6100_INVALID_INDEX );
3335
if ( ulTempVar != cOCT6100_ERR_OK )
3339
/* Now make sure any resources released gets reserved back again.*/
3341
/* For the RIN port.*/
3342
if ( fRinReleased == TRUE )
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,
3352
if ( ulTempVar != cOCT6100_ERR_OK )
3356
/* For the SIN port.*/
3357
if ( fSinReleased == TRUE )
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,
3367
if ( ulTempVar != cOCT6100_ERR_OK )
3371
/* For the ROUT port.*/
3372
if ( fRoutReleased == TRUE )
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,
3382
if ( ulTempVar != cOCT6100_ERR_OK )
3386
/* For the SOUT port.*/
3387
if ( fSoutReleased == TRUE )
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,
3397
if ( ulTempVar != cOCT6100_ERR_OK )
3401
/* Release the conversion memories if they were reserved.*/
3402
if ( fRinRoutConversionMemReserved == TRUE )
3404
ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
3405
pChanEntry->usRinRoutConversionMemIndex );
3406
if ( ulTempVar != cOCT6100_ERR_OK )
3410
if ( fSinSoutConversionMemReserved == TRUE )
3412
ulTempVar = Oct6100ApiReleaseConversionMemEntry( f_pApiInstance,
3413
pChanEntry->usSinSoutConversionMemIndex );
3414
if ( ulTempVar != cOCT6100_ERR_OK )
3418
/* Now return the error.*/
3422
return cOCT6100_ERR_OK;
3426
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
3428
Function: Oct6100ApiModifyChannelStructs
3430
Description: Performs all the required structure writes to configure the
3431
echo cancellation channel based on the new modifications.
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.
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.
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 )
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;
3475
UINT16 usSinTsstIndex;
3476
UINT16 usRinTsstIndex;
3478
UINT32 ulToneConfIndex;
3479
BOOL fClearPlayoutPointers = FALSE;
3481
BOOL fConversionEnabled = FALSE;
3485
/* Obtain local pointer to shared portion of instance. */
3486
pSharedInfo = f_pApiInstance->pSharedInfo;
3488
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
3490
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
3492
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
3494
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
3495
ReadParams.pusReadData = &usReadData;
3497
/*=======================================================================*/
3498
/* Get a pointer to the channel's list entry. */
3499
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
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;
3506
/*=======================================================================*/
3507
/* Init the RIN and SIN TSST index */
3509
usRinTsstIndex = pChanEntry->usRinTsstIndex;
3510
usSinTsstIndex = pChanEntry->usSinTsstIndex;
3513
/*==============================================================================*/
3514
/* Clear the TSST that will be release.*/
3516
if ( f_pChannelModify->fTdmConfigModified == TRUE )
3518
/* Modify RIN port.*/
3519
if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3521
if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
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;
3527
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3528
if ( ulResult != cOCT6100_ERR_OK )
3533
/* Modify SIN port.*/
3534
if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3536
if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
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;
3542
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3543
if ( ulResult != cOCT6100_ERR_OK )
3548
/* Modify ROUT port.*/
3549
if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3551
if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
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;
3557
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3558
if ( ulResult != cOCT6100_ERR_OK )
3563
/* Modify SOUT port.*/
3564
if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING)
3566
if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
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;
3572
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
3573
if ( ulResult != cOCT6100_ERR_OK )
3578
/*==============================================================================*/
3581
/*==============================================================================*/
3582
/* Now, Configure the Tsst control memory.*/
3584
if ( f_pChannelModify->fTdmConfigModified == TRUE )
3586
/* Modify RIN port.*/
3587
if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3589
usRinTsstIndex = f_usNewRinTsstIndex;
3591
if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX )
3593
if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX )
3595
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3596
f_usNewRinTsstIndex,
3597
pChanEntry->usExtraRinTsiMemIndex,
3598
f_pChannelOpen->TdmConfig.ulRinPcmLaw );
3599
if ( ulResult != cOCT6100_ERR_OK )
3604
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3605
f_usNewRinTsstIndex,
3606
pChanEntry->usRinRoutTsiMemIndex,
3607
f_pChannelOpen->TdmConfig.ulRinPcmLaw );
3608
if ( ulResult != cOCT6100_ERR_OK )
3613
if ( f_pChannelModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING &&
3614
f_pChannelModify->TdmConfig.ulRinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
3616
if ( pChanEntry->usExtraRinTsiMemIndex != cOCT6100_INVALID_INDEX )
3618
if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
3620
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3621
pChanEntry->usRinTsstIndex,
3622
pChanEntry->usExtraRinTsiMemIndex,
3623
f_pChannelOpen->TdmConfig.ulRinPcmLaw );
3624
if ( ulResult != cOCT6100_ERR_OK )
3630
if ( pChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
3632
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3633
pChanEntry->usRinTsstIndex,
3634
pChanEntry->usRinRoutTsiMemIndex,
3635
f_pChannelOpen->TdmConfig.ulRinPcmLaw );
3636
if ( ulResult != cOCT6100_ERR_OK )
3642
/* Modify SIN port.*/
3643
if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3645
usSinTsstIndex = f_usNewSinTsstIndex;
3647
if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX )
3649
if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
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 )
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 )
3671
if ( f_pChannelModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING &&
3672
f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
3674
if ( pChanEntry->usExtraSinTsiMemIndex != cOCT6100_INVALID_INDEX )
3676
if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
3678
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3679
pChanEntry->usSinTsstIndex ,
3680
pChanEntry->usExtraSinTsiMemIndex,
3681
f_pChannelOpen->TdmConfig.ulSinPcmLaw );
3682
if ( ulResult != cOCT6100_ERR_OK )
3688
if ( pChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
3690
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
3691
pChanEntry->usSinTsstIndex ,
3692
pChanEntry->usSinSoutTsiMemIndex,
3693
f_pChannelOpen->TdmConfig.ulSinPcmLaw );
3694
if ( ulResult != cOCT6100_ERR_OK )
3700
/* Modify ROUT port.*/
3701
if ( ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3702
|| ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
3705
if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX )
3707
if ( f_pChannelModify->TdmConfig.ulRoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
3709
/* If this output port is not muted. */
3710
if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 )
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 )
3724
/* If this output port is not muted. */
3725
if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 )
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 )
3740
/* Modify SOUT port.*/
3741
if ( ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
3742
|| ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
3745
if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX )
3747
if ( f_pChannelModify->TdmConfig.ulSoutNumTssts != cOCT6100_KEEP_PREVIOUS_SETTING )
3749
/* If this output port is not muted. */
3750
if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 )
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 );
3759
if ( ulResult != cOCT6100_ERR_OK )
3765
/* If this output port is not muted. */
3766
if ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 )
3768
/* Write the new entry now.*/
3769
ulResult = Oct6100ApiWriteOutputTsstControlMemory( f_pApiInstance,
3770
f_usNewSoutTsstIndex,
3771
pApiCodecConf->byAdpcmNibblePosition,
3772
pApiTdmConf->bySoutNumTssts,
3773
pChanEntry->usSinSoutTsiMemIndex );
3775
if ( ulResult != cOCT6100_ERR_OK )
3786
/*==============================================================================*/
3789
/*==============================================================================*/
3790
/* Modify the Encoder/Decoder memory if required.*/
3792
if ( f_pChannelModify->fCodecConfigModified == TRUE )
3794
UINT32 ulCompType = 0;
3795
UINT16 usTempTsiMemIndex;
3796
UINT16 usDecoderMemIndex;
3797
UINT16 usEncoderMemIndex;
3799
UINT16 usPhasingIndex;
3800
BOOL fModifyAdpcmMem = TRUE;
3802
/*==============================================================================*/
3803
/* Reprogram the Decoder memory.*/
3805
if ( pChanEntry->CodecConfig.byDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3807
usDecoderMemIndex = pChanEntry->usRinRoutConversionMemIndex;
3811
usDecoderMemIndex = pChanEntry->usSinSoutConversionMemIndex;
3814
if ( pChanEntry->CodecConfig.byEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
3816
usEncoderMemIndex = pChanEntry->usRinRoutConversionMemIndex;
3820
usEncoderMemIndex = pChanEntry->usSinSoutConversionMemIndex;
3823
if ( usDecoderMemIndex != cOCT6100_INVALID_INDEX )
3825
switch( f_pChannelOpen->CodecConfig.ulDecodingRate )
3827
case cOCT6100_G711_64KBPS:
3830
if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3832
if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw )
3833
fModifyAdpcmMem = FALSE;
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;
3840
else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
3842
if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
3843
fModifyAdpcmMem = FALSE;
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;
3852
case cOCT6100_G726_40KBPS:
3854
fConversionEnabled = TRUE;
3857
case cOCT6100_G726_32KBPS:
3859
fConversionEnabled = TRUE;
3862
case cOCT6100_G726_24KBPS:
3864
fConversionEnabled = TRUE;
3867
case cOCT6100_G726_16KBPS:
3869
fConversionEnabled = TRUE;
3872
case cOCT6100_G727_2C_ENCODED:
3874
fConversionEnabled = TRUE;
3877
case cOCT6100_G727_3C_ENCODED:
3879
fConversionEnabled = TRUE;
3882
case cOCT6100_G727_4C_ENCODED:
3884
fConversionEnabled = TRUE;
3887
case cOCT6100_G726_ENCODED:
3889
fConversionEnabled = TRUE;
3892
case cOCT6100_G711_G726_ENCODED:
3894
fConversionEnabled = TRUE;
3897
case cOCT6100_G711_G727_2C_ENCODED:
3899
fConversionEnabled = TRUE;
3902
case cOCT6100_G711_G727_3C_ENCODED:
3904
fConversionEnabled = TRUE;
3907
case cOCT6100_G711_G727_4C_ENCODED:
3909
fConversionEnabled = TRUE;
3913
return cOCT6100_ERR_FATAL_D6;
3916
if ( fModifyAdpcmMem == TRUE )
3918
/* Set the chariot memory based on the selected port.*/
3919
if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3921
usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
3922
ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw; /* Set the law for later use */
3924
/* Flag the entry as active.*/
3925
*f_pfRinRoutCodecActive = TRUE;
3927
else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
3929
usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
3930
ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw; /* Set the law for later use */
3932
/* Flag the entry as active.*/
3933
*f_pfSinSoutCodecActive = TRUE;
3936
ulResult = Oct6100ApiWriteDecoderMemory( f_pApiInstance,
3941
pApiCodecConf->byAdpcmNibblePosition );
3942
if ( ulResult != cOCT6100_ERR_OK )
3947
ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance,
3948
usDecoderMemIndex );
3949
if ( ulResult != cOCT6100_ERR_OK )
3952
/* Flag the entry as deactivated.*/
3953
if ( f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_RIN )
3955
*f_pfRinRoutCodecActive = FALSE;
3959
*f_pfSinSoutCodecActive = FALSE;
3964
/*==============================================================================*/
3969
/*==============================================================================*/
3970
/* Reprogram the Encoder memory.*/
3972
if ( usEncoderMemIndex != cOCT6100_INVALID_INDEX )
3975
fModifyAdpcmMem = TRUE;
3977
/* Set the chariot memory based on the selected port.*/
3978
if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
3980
usTempTsiMemIndex = pChanEntry->usRinRoutTsiMemIndex;
3981
ulPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw; /* Set the law for later use */
3983
else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
3985
usTempTsiMemIndex = pChanEntry->usSinSoutTsiMemIndex;
3986
ulPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw; /* Set the law for later use */
3989
/* Set the phasing index .*/
3990
if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX )
3991
usPhasingIndex = f_usNewPhasingTsstIndex;
3993
usPhasingIndex = pChanEntry->usPhasingTsstIndex;
3995
switch( f_pChannelOpen->CodecConfig.ulEncodingRate )
3997
case cOCT6100_G711_64KBPS:
3998
if ( ulPcmLaw == cOCT6100_PCM_U_LAW )
4000
else /* ulPcmLaw == cOCT6100_PCM_A_LAW */
4003
if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
4005
if ( f_pChannelOpen->TdmConfig.ulRinPcmLaw == f_pChannelOpen->TdmConfig.ulRoutPcmLaw )
4006
fModifyAdpcmMem = FALSE;
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;
4013
else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
4015
if ( f_pChannelOpen->TdmConfig.ulSinPcmLaw == f_pChannelOpen->TdmConfig.ulSoutPcmLaw )
4016
fModifyAdpcmMem = FALSE;
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;
4024
case cOCT6100_G726_40KBPS:
4026
fConversionEnabled = TRUE;
4029
case cOCT6100_G726_32KBPS:
4031
fConversionEnabled = TRUE;
4034
case cOCT6100_G726_24KBPS:
4036
fConversionEnabled = TRUE;
4039
case cOCT6100_G726_16KBPS:
4041
fConversionEnabled = TRUE;
4044
case cOCT6100_G727_40KBPS_4_1:
4046
fConversionEnabled = TRUE;
4049
case cOCT6100_G727_40KBPS_3_2:
4051
fConversionEnabled = TRUE;
4054
case cOCT6100_G727_40KBPS_2_3:
4056
fConversionEnabled = TRUE;
4059
case cOCT6100_G727_32KBPS_4_0:
4061
fConversionEnabled = TRUE;
4064
case cOCT6100_G727_32KBPS_3_1:
4066
fConversionEnabled = TRUE;
4069
case cOCT6100_G727_32KBPS_2_2:
4071
fConversionEnabled = TRUE;
4074
case cOCT6100_G727_24KBPS_3_0:
4076
fConversionEnabled = TRUE;
4079
case cOCT6100_G727_24KBPS_2_1:
4081
fConversionEnabled = TRUE;
4084
case cOCT6100_G727_16KBPS_2_0:
4086
fConversionEnabled = TRUE;
4090
return cOCT6100_ERR_FATAL_D7;
4093
if ( fModifyAdpcmMem == TRUE )
4095
if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
4097
*f_pfRinRoutCodecActive = TRUE;
4099
else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
4101
*f_pfSinSoutCodecActive = TRUE;
4104
ulResult = Oct6100ApiWriteEncoderMemory( f_pApiInstance,
4108
f_pChannelOpen->CodecConfig.fEnableSilenceSuppression,
4109
pApiCodecConf->byAdpcmNibblePosition,
4111
f_pChannelOpen->CodecConfig.ulPhasingType,
4112
f_pChannelOpen->CodecConfig.ulPhase );
4114
if ( ulResult != cOCT6100_ERR_OK )
4119
ulResult = Oct6100ApiClearConversionMemory( f_pApiInstance,
4120
usEncoderMemIndex );
4121
if ( ulResult != cOCT6100_ERR_OK )
4124
if ( f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_ROUT )
4126
*f_pfRinRoutCodecActive = FALSE;
4128
else /* f_pChannelOpen->CodecConfig.ulEncoderPort == cOCT6100_CHANNEL_PORT_SOUT */
4130
*f_pfSinSoutCodecActive = FALSE;
4135
/*==============================================================================*/
4141
/*==============================================================================*/
4142
/* Modify the VQE parameter if required.*/
4144
if ( ( f_pChannelModify->fVqeConfigModified == TRUE )
4145
|| ( (UINT8)f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode )
4146
|| ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) )
4148
ulResult = Oct6100ApiWriteVqeMemory( f_pApiInstance,
4149
&f_pChannelOpen->VqeConfig,
4152
pChanEntry->usEchoMemIndex,
4155
if ( ulResult != cOCT6100_ERR_OK )
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 )
4168
ulResult = Oct6100ApiWriteEchoMemory( f_pApiInstance,
4169
&f_pChannelOpen->TdmConfig,
4171
pChanEntry->usEchoMemIndex,
4172
pChanEntry->usRinRoutTsiMemIndex,
4173
pChanEntry->usSinSoutTsiMemIndex );
4174
if ( ulResult != cOCT6100_ERR_OK )
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 ) ) )
4184
/* Buffer playout must be stopped. */
4185
fClearPlayoutPointers = TRUE;
4189
/*==============================================================================*/
4190
/* Modify the Mixer events if law changes are requested. */
4192
if ( pChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX &&
4193
f_pChannelModify->TdmConfig.ulSinPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
4195
ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
4197
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
4198
if ( ulResult != cOCT6100_ERR_OK )
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 ));
4205
WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSinPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )));
4207
/* Write back the new value.*/
4208
WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
4210
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4211
if ( ulResult != cOCT6100_ERR_OK )
4215
if ( pChanEntry->usSoutCopyEventIndex != cOCT6100_INVALID_INDEX &&
4216
f_pChannelModify->TdmConfig.ulSoutPcmLaw != cOCT6100_KEEP_PREVIOUS_SETTING )
4218
ReadParams.ulReadAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSoutCopyEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
4220
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
4221
if ( ulResult != cOCT6100_ERR_OK )
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 ));
4228
WriteParams.usWriteData = (UINT16)( usReadData & (~( f_pChannelModify->TdmConfig.ulSoutPcmLaw << cOCT6100_MIXER_CONTROL_MEM_LAW_OFFSET )));
4230
/* Write back the new value.*/
4231
WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
4233
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4234
if ( ulResult != cOCT6100_ERR_OK )
4238
/*==============================================================================*/
4239
/* Mute channel if required, this is done on a port basis */
4241
ulResult = Oct6100ApiMutePorts( f_pApiInstance,
4246
if ( ulResult != cOCT6100_ERR_OK )
4249
/*==============================================================================*/
4251
/* Completely disable tone detection? */
4252
if ( f_pChannelModify->fDisableToneDetection == TRUE )
4254
/* Check if tone detection has been enabled on this channel. */
4255
for ( ulToneConfIndex = 0; ulToneConfIndex < ( sizeof( pChanEntry->aulToneConf ) / sizeof(UINT32) ); ulToneConfIndex ++ )
4257
/* Check if some tone has been activated on this channel. */
4258
if ( pChanEntry->aulToneConf[ ulToneConfIndex ] != 0 )
4260
tOCT6100_TONE_DETECTION_DISABLE ToneDetectDisable;
4262
/* Call the default function to make sure all parameters are assigned default values. */
4263
ulResult = Oct6100ToneDetectionDisableDef( &ToneDetectDisable );
4264
if ( ulResult != cOCT6100_ERR_OK )
4267
/* Form channel handle. */
4268
ToneDetectDisable.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4270
/* Disable all tones activated on this channel. */
4271
ToneDetectDisable.fDisableAll = TRUE;
4273
/* Call tone detection serialized function. */
4274
ulResult = Oct6100ToneDetectionDisableSer( f_pApiInstance, &ToneDetectDisable );
4275
if ( ulResult != cOCT6100_ERR_OK )
4278
/* Get out of the loop, tone detection has been disabled! */
4284
/* Hard-stop buffer playout? */
4285
if ( f_pChannelModify->fStopBufferPlayout == TRUE )
4287
/* Check if playout has been started on the Rout port. */
4288
if ( ( pChanEntry->fRinBufPlaying == TRUE ) || ( pChanEntry->fRinBufAdded == TRUE ) )
4290
tOCT6100_BUFFER_PLAYOUT_STOP PlayoutStop;
4292
/* Call the default function to make sure all parameters are assigned default values. */
4293
ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop );
4294
if ( ulResult != cOCT6100_ERR_OK )
4297
/* Hard stop request. */
4298
PlayoutStop.fStopCleanly = FALSE;
4300
/* Form channel handle. */
4301
PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4303
/* For the Rout port. */
4304
PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
4306
/* Call buffer playout stop serialized function. */
4307
ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop );
4308
if ( ulResult != cOCT6100_ERR_OK )
4313
/* The chip might still be playing a last buffer. Make sure it hard-stops! */
4314
fClearPlayoutPointers = TRUE;
4317
/* Check if playout has been started on the Sout port. */
4318
if ( ( pChanEntry->fSoutBufPlaying == TRUE ) || ( pChanEntry->fSoutBufAdded == TRUE ) )
4320
tOCT6100_BUFFER_PLAYOUT_STOP PlayoutStop;
4322
/* Call the default function to make sure all parameters are assigned default values. */
4323
ulResult = Oct6100BufferPlayoutStopDef( &PlayoutStop );
4324
if ( ulResult != cOCT6100_ERR_OK )
4327
/* Hard stop request. */
4328
PlayoutStop.fStopCleanly = FALSE;
4330
/* Form channel handle. */
4331
PlayoutStop.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4333
/* For the Rout port. */
4334
PlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
4336
/* Call buffer playout stop serialized function. */
4337
ulResult = Oct6100BufferPlayoutStopSer( f_pApiInstance, &PlayoutStop );
4338
if ( ulResult != cOCT6100_ERR_OK )
4343
/* The chip might still be playing a last buffer. Make sure it hard-stops! */
4344
fClearPlayoutPointers = TRUE;
4348
/* Remove participant from bridge? */
4349
if ( f_pChannelModify->fRemoveConfBridgeParticipant == TRUE )
4351
/* Check if this channel is on a bridge. */
4352
if ( pChanEntry->usBridgeIndex != cOCT6100_INVALID_INDEX )
4354
/* Channel is on a bridge, remove it. */
4355
tOCT6100_CONF_BRIDGE_CHAN_REMOVE BridgeChanRemove;
4357
/* Call the default function to make sure all parameters are assigned default values. */
4358
ulResult = Oct6100ConfBridgeChanRemoveDef( &BridgeChanRemove );
4359
if ( ulResult != cOCT6100_ERR_OK )
4362
/* Form channel handle. */
4363
BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4365
/* Do not remove all channels, only the one specified. */
4366
BridgeChanRemove.fRemoveAll = FALSE;
4368
/* No need to assign conference bridge handle, the remove function will figure it out. */
4370
/* Call conference bridge channel remove serialized function. */
4371
ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
4372
if ( ulResult != cOCT6100_ERR_OK )
4374
if ( ulResult == cOCT6100_ERR_CONF_BRIDGE_CHANNEL_TAP_DEPENDENCY )
4376
tPOCT6100_API_CHANNEL pTapChanEntry;
4378
/* Get a pointer to the tap channel's list entry. */
4379
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTapChanEntry, pChanEntry->usTapChanIndex )
4381
/* Form tap channel handle. */
4382
BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pTapChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | pChanEntry->usTapChanIndex;
4384
ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
4385
if ( ulResult != cOCT6100_ERR_OK )
4388
/* Re-form original channel handle. */
4389
BridgeChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4391
ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &BridgeChanRemove );
4392
if ( ulResult != cOCT6100_ERR_OK )
4403
/* Remove all broadcast TSSTs? */
4404
if ( f_pChannelModify->fRemoveBroadcastTssts == TRUE )
4406
/* Check if broadcast TSSTs were used on the Rout port. */
4407
if ( pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX )
4409
tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE BroadcastTsstRemove;
4411
ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove );
4412
if ( ulResult != cOCT6100_ERR_OK )
4415
/* Form channel handle. */
4416
BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4418
/* Remove all broadcast TSSTs associated to the current channel. */
4419
BroadcastTsstRemove.fRemoveAll = TRUE;
4421
/* On the Rout port. */
4422
BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_ROUT;
4424
ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove );
4425
if ( ulResult != cOCT6100_ERR_OK )
4430
/* Check if broadcast TSSTs were used on the Sout port. */
4431
if ( pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry != cOCT6100_INVALID_INDEX )
4433
tOCT6100_CHANNEL_BROADCAST_TSST_REMOVE BroadcastTsstRemove;
4435
ulResult = Oct6100ChannelBroadcastTsstRemoveDef( &BroadcastTsstRemove );
4436
if ( ulResult != cOCT6100_ERR_OK )
4439
/* Form channel handle. */
4440
BroadcastTsstRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | ( pChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT ) | f_usChanIndex;
4442
/* Remove all broadcast TSSTs associated to the current channel. */
4443
BroadcastTsstRemove.fRemoveAll = TRUE;
4445
/* On the Sout port. */
4446
BroadcastTsstRemove.ulPort = cOCT6100_CHANNEL_PORT_SOUT;
4448
ulResult = Oct6100ChannelBroadcastTsstRemoveSer( f_pApiInstance, &BroadcastTsstRemove );
4449
if ( ulResult != cOCT6100_ERR_OK )
4454
/* Check if have to make sure buffer playout is stopped. */
4455
if ( fClearPlayoutPointers == TRUE )
4457
tOCT6100_BUFFER_PLAYOUT_STOP BufferPlayoutStop;
4459
Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
4461
BufferPlayoutStop.fStopCleanly = FALSE;
4462
BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
4464
ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
4468
pChanEntry->usEchoMemIndex
4471
if ( ulResult != cOCT6100_ERR_OK )
4474
BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
4475
ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
4479
pChanEntry->usEchoMemIndex
4482
if ( ulResult != cOCT6100_ERR_OK )
4486
return cOCT6100_ERR_OK;
4491
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4493
Function: Oct6100ApiModifyChannelEntry
4495
Description: Updates the channel structure in the ECHO channel list.
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.
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.
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 )
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;
4534
/* Obtain local pointer to shared portion of instance. */
4535
pSharedInfo = f_pApiInstance->pSharedInfo;
4537
/*=======================================================================*/
4538
/* Get a pointer to the channel's list entry. */
4539
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
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;
4546
/*=======================================================================*/
4547
/* Copy the channel's general configuration. */
4549
pChanEntry->ulUserChanId = f_pChannelOpen->ulUserChanId;
4550
pChanEntry->byEchoOperationMode = (UINT8)( f_pChannelOpen->ulEchoOperationMode & 0xFF );
4551
pChanEntry->fEnableToneDisabler = (UINT8)( f_pChannelOpen->fEnableToneDisabler & 0xFF );
4553
/* Save the codec state.*/
4554
pChanEntry->fSinSoutCodecActive = (UINT8)( f_fSinSoutCodecActive & 0xFF );
4555
pChanEntry->fRinRoutCodecActive = (UINT8)( f_fRinRoutCodecActive & 0xFF );
4557
/*=======================================================================*/
4558
/* Copy the channel's TDM configuration of all the modified fields. */
4560
if ( f_pChannelModify->fTdmConfigModified == TRUE )
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 );
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 );
4572
if ( f_pChannelModify->TdmConfig.ulRinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4574
if ( f_usNewRinTsstIndex != cOCT6100_INVALID_INDEX )
4576
pApiTdmConf->usRinStream = (UINT16)( f_pChannelOpen->TdmConfig.ulRinStream & 0xFFFF );
4577
pApiTdmConf->usRinTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulRinTimeslot & 0xFFFF );
4578
pChanEntry->usRinTsstIndex = f_usNewRinTsstIndex;
4580
else /* f_ulNewRinTsstIndex != cOCT6100_INVALID_INDEX */
4582
pApiTdmConf->usRinStream = cOCT6100_UNASSIGNED;
4583
pApiTdmConf->usRinTimeslot = cOCT6100_UNASSIGNED;
4584
pChanEntry->usRinTsstIndex = cOCT6100_INVALID_INDEX;
4588
if ( f_pChannelModify->TdmConfig.ulSinTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4590
if ( f_usNewSinTsstIndex != cOCT6100_INVALID_INDEX )
4592
pApiTdmConf->usSinStream = (UINT16)( f_pChannelOpen->TdmConfig.ulSinStream & 0xFFFF );
4593
pApiTdmConf->usSinTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulSinTimeslot & 0xFFFF );
4594
pChanEntry->usSinTsstIndex = f_usNewSinTsstIndex;
4596
else /* f_ulNewSinTsstIndex != cOCT6100_INVALID_INDEX */
4598
pApiTdmConf->usSinStream = cOCT6100_UNASSIGNED;
4599
pApiTdmConf->usSinTimeslot = cOCT6100_UNASSIGNED;
4600
pChanEntry->usSinTsstIndex = cOCT6100_INVALID_INDEX;
4604
if ( f_pChannelModify->TdmConfig.ulRoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4606
if ( f_usNewRoutTsstIndex != cOCT6100_INVALID_INDEX )
4608
pApiTdmConf->usRoutStream = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutStream & 0xFFFF );
4609
pApiTdmConf->usRoutTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulRoutTimeslot & 0xFFFF );
4610
pChanEntry->usRoutTsstIndex = f_usNewRoutTsstIndex;
4612
else /* f_ulNewRoutTsstIndex != cOCT6100_INVALID_INDEX */
4614
pApiTdmConf->usRoutStream = cOCT6100_UNASSIGNED;
4615
pApiTdmConf->usRoutTimeslot = cOCT6100_UNASSIGNED;
4616
pChanEntry->usRoutTsstIndex = cOCT6100_INVALID_INDEX;
4620
if ( f_pChannelModify->TdmConfig.ulSoutTimeslot != cOCT6100_KEEP_PREVIOUS_SETTING )
4622
if ( f_usNewSoutTsstIndex != cOCT6100_INVALID_INDEX )
4624
pApiTdmConf->usSoutStream = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutStream & 0xFFFF );
4625
pApiTdmConf->usSoutTimeslot = (UINT16)( f_pChannelOpen->TdmConfig.ulSoutTimeslot & 0xFFFF );
4626
pChanEntry->usSoutTsstIndex = f_usNewSoutTsstIndex;
4628
else /* f_ulNewSoutTsstIndex != cOCT6100_INVALID_INDEX */
4630
pApiTdmConf->usSoutStream = cOCT6100_UNASSIGNED;
4631
pApiTdmConf->usSoutTimeslot = cOCT6100_UNASSIGNED;
4632
pChanEntry->usSoutTsstIndex = cOCT6100_INVALID_INDEX;
4637
/*=======================================================================*/
4638
/* Copy the channel's VQE configuration of all the modified fields. */
4640
if ( f_pChannelModify->fVqeConfigModified == TRUE )
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 );
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 );
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 );
4683
/*=======================================================================*/
4684
/* Copy the channel's CODEC configuration of all the modified fields. */
4685
if ( f_pChannelModify->fCodecConfigModified == TRUE )
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 );
4696
/* Update the API phasing TSST structure */
4697
if ( f_usNewPhasingTsstIndex != cOCT6100_INVALID_INDEX )
4699
tPOCT6100_API_PHASING_TSST pPhasingTsst;
4701
/* Release the previous phasing TSST if the channel was already bound to one.*/
4702
if ( pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
4704
mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, pChanEntry->usPhasingTsstIndex );
4706
pPhasingTsst->usDependencyCnt--;
4709
mOCT6100_GET_PHASING_TSST_ENTRY_PNT( pSharedInfo, pPhasingTsst, f_usNewPhasingTsstIndex );
4711
pPhasingTsst->usDependencyCnt++;
4712
pChanEntry->usPhasingTsstIndex = f_usNewPhasingTsstIndex;
4719
return cOCT6100_ERR_OK;
4724
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4726
Function: Oct6100ChannelBroadcastTsstRemoveSer
4728
Description: Removes a broadcast TSST from one of the output port of an
4729
echo cancellation channel.
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.
4737
f_pChannelTsstRemove Pointer to TSST remove structure.
4739
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4740
static UINT32 Oct6100ChannelBroadcastTsstRemoveSer(
4741
IN tPOCT6100_INSTANCE_API f_pApiInstance,
4742
IN OUT tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE f_pChannelTsstRemove)
4747
UINT16 usPrevTsstEntry;
4750
ulResult = Oct6100ApiAssertChanTsstRemoveParams( f_pApiInstance, f_pChannelTsstRemove, &usChanIndex, &usTsstIndex, &usTsstEntry, &usPrevTsstEntry );
4751
if ( ulResult != cOCT6100_ERR_OK )
4754
ulResult = Oct6100ApiInvalidateTsstRemoveStructs( f_pApiInstance, usChanIndex, usTsstIndex, f_pChannelTsstRemove->ulPort, f_pChannelTsstRemove->fRemoveAll );
4755
if ( ulResult != cOCT6100_ERR_OK )
4758
ulResult = Oct6100ApiReleaseTsstRemoveResources( f_pApiInstance, f_pChannelTsstRemove, usChanIndex, usTsstIndex, usTsstEntry, usPrevTsstEntry );
4759
if ( ulResult != cOCT6100_ERR_OK )
4762
return cOCT6100_ERR_OK;
4765
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4767
Function: Oct6100ApiAssertChanTsstRemoveParams
4769
Description: Verify the validity of the tPOCT6100_CHANNEL_BROADCAST_TSST_REMOVE
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.
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.
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 )
4793
tPOCT6100_API_CHANNEL pChanEntry;
4794
tPOCT6100_API_TSST_ENTRY pTsstEntry;
4796
UINT32 ulNumTssts = 1;
4797
UINT32 ulEntryOpenCnt;
4798
UINT16 usCurrentEntry;
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;
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;
4810
/*=======================================================================*/
4811
/* Get a pointer to the channel's list entry. */
4813
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, *f_pusChanIndex )
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;
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;
4824
/*=======================================================================*/
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;
4831
/* Verify that the requested entry is present in the channel's port broadcast TSST.*/
4832
if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
4834
usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
4835
usNumEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry;
4837
else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
4839
usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
4840
usNumEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry;
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;
4847
/* Get the required number of TSST based on the port.*/
4848
switch( f_pChannelTsstRemove->ulPort )
4850
case cOCT6100_CHANNEL_PORT_ROUT:
4851
ulNumTssts = pChanEntry->TdmConfig.byRoutNumTssts;
4853
case cOCT6100_CHANNEL_PORT_SOUT:
4854
ulNumTssts = pChanEntry->TdmConfig.bySoutNumTssts;
4857
return cOCT6100_ERR_FATAL_E;
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;
4865
if ( f_pChannelTsstRemove->fRemoveAll != TRUE )
4867
/* Check the validity of the timeslot and Stream.*/
4868
ulResult = Oct6100ApiValidateTsst( f_pApiInstance,
4870
f_pChannelTsstRemove->ulTimeslot,
4871
f_pChannelTsstRemove->ulStream,
4872
cOCT6100_OUTPUT_TSST );
4873
if ( ulResult != cOCT6100_ERR_OK )
4875
if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
4877
return cOCT6100_ERR_CHANNEL_TSST_REMOVE_TIMESLOT;
4879
else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
4881
return cOCT6100_ERR_CHANNEL_TSST_REMOVE_STREAM;
4889
/* Set the TSST value based on the timeslot and stream value.*/
4890
usTsstValue = (UINT16)( (f_pChannelTsstRemove->ulTimeslot << 5) | f_pChannelTsstRemove->ulStream );
4892
while( usCurrentEntry != cOCT6100_INVALID_INDEX )
4894
mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
4896
if ( usTsstValue == pTsstEntry->usTsstValue )
4898
/* A match was found.*/
4899
*f_pusTsstEntry = usCurrentEntry;
4900
*f_pusTsstIndex = pTsstEntry->usTsstMemoryIndex;
4904
/* Move on to the next entry.*/
4905
*f_pusPrevTsstEntry = usCurrentEntry;
4906
usCurrentEntry = pTsstEntry->usNextEntry;
4909
if ( *f_pusTsstEntry == cOCT6100_INVALID_INDEX )
4910
return cOCT6100_ERR_CHANNEL_TSST_REMOVE_INVALID_TSST;
4913
return cOCT6100_ERR_OK;
4917
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4919
Function: Oct6100ApiInvalidateTsstRemoveStructs
4921
Description: Invalidate the entry of the broadcast TSST.
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.
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.
4934
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
4935
static UINT32 Oct6100ApiInvalidateTsstRemoveStructs(
4936
IN tPOCT6100_INSTANCE_API f_pApiInstance,
4937
IN UINT16 f_usChanIndex,
4938
IN UINT16 f_usTsstIndex,
4940
IN BOOL f_fRemoveAll )
4942
tOCT6100_WRITE_PARAMS WriteParams;
4945
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
4947
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
4949
if ( f_fRemoveAll == FALSE )
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;
4955
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4956
if ( ulResult != cOCT6100_ERR_OK )
4959
else /* f_fRemoveAll == TRUE */
4961
tPOCT6100_API_CHANNEL pChanEntry;
4962
tPOCT6100_API_TSST_ENTRY pTsstEntry;
4965
/*=======================================================================*/
4966
/* Get a pointer to the channel's list entry. */
4968
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
4970
/* Clear all entry associated to the selected port.*/
4971
if ( f_ulPort == cOCT6100_CHANNEL_PORT_ROUT )
4972
usTsstEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
4974
usTsstEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
4978
mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usTsstEntry );
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;
4984
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
4985
if ( ulResult != cOCT6100_ERR_OK )
4988
usTsstEntry = pTsstEntry->usNextEntry;
4990
} while ( usTsstEntry != cOCT6100_INVALID_INDEX );
4993
return cOCT6100_ERR_OK;
4997
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
4999
Function: Oct6100ApiReleaseTsstRemoveResources
5001
Description: Release all API resources associated to the Removed TSST and
5002
update the channel entry accordingly.
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.
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.
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 )
5025
tPOCT6100_API_CHANNEL pChanEntry;
5026
tPOCT6100_API_TSST_ENTRY pTsstEntry;
5027
tPOCT6100_API_TSST_ENTRY pPrevTsstEntry;
5028
UINT16 usCurrentEntry;
5032
/*=======================================================================*/
5033
/* Get a pointer to the channel's list entry. */
5035
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pChanEntry, f_usChanIndex );
5037
if ( f_pChannelTsstRemove->fRemoveAll == FALSE )
5039
mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, f_usTsstEntry );
5041
/* Update the channel entry.*/
5042
if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
5044
/* Check if the entry was the first in the list.*/
5045
if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX )
5047
pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry;
5049
else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */
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;
5056
/* Decrement the number of entry.*/
5057
pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry--;
5059
else /* f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_SOUT */
5061
/* Check if the entry was the first in the list.*/
5062
if ( f_usPrevTsstEntry == cOCT6100_INVALID_INDEX )
5064
pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = pTsstEntry->usNextEntry;
5066
else /* f_ulPrevTsstEntry != cOCT6100_INVALID_INDEX */
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;
5073
/* Decrement the number of entry.*/
5074
pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry--;
5077
ulTimeslot = pTsstEntry->usTsstValue >> 5;
5078
ulStream = pTsstEntry->usTsstValue & 0x1F;
5080
/* Release the entry.*/
5081
ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
5084
cOCT6100_NUMBER_TSSTS_1,
5085
cOCT6100_OUTPUT_TSST,
5087
if ( ulResult != cOCT6100_ERR_OK )
5090
else /* f_pChannelTsstRemove->fRemoveAll == TRUE */
5093
/* Update the channel entry.*/
5094
if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
5095
usCurrentEntry = pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry;
5097
usCurrentEntry = pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry;
5101
mOCT6100_GET_TSST_LIST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTsstEntry, usCurrentEntry );
5103
ulTimeslot = pTsstEntry->usTsstValue >> 5;
5104
ulStream = pTsstEntry->usTsstValue & 0x1F;
5106
/* Release the entry.*/
5107
ulResult = Oct6100ApiReleaseTsst( f_pApiInstance,
5110
cOCT6100_NUMBER_TSSTS_1,
5111
cOCT6100_OUTPUT_TSST,
5112
usCurrentEntry ); /* Release the entry.*/
5113
if ( ulResult != cOCT6100_ERR_OK )
5116
usCurrentEntry = pTsstEntry->usNextEntry;
5118
/* Clear the previous node.*/
5119
pTsstEntry->usTsstMemoryIndex = 0xFFFF;
5120
pTsstEntry->usTsstValue = 0xFFFF;
5121
pTsstEntry->usNextEntry = cOCT6100_INVALID_INDEX;
5123
} while ( usCurrentEntry != cOCT6100_INVALID_INDEX );
5125
/* Reset the channel status.*/
5126
if ( f_pChannelTsstRemove->ulPort == cOCT6100_CHANNEL_PORT_ROUT )
5128
pChanEntry->TdmConfig.usRoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
5129
pChanEntry->TdmConfig.usRoutBrdcastTsstNumEntry = 0;
5133
pChanEntry->TdmConfig.usSoutBrdcastTsstFirstEntry = cOCT6100_INVALID_INDEX;
5134
pChanEntry->TdmConfig.usSoutBrdcastTsstNumEntry = 0;
5137
return cOCT6100_ERR_OK;
5141
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5143
Function: Oct6100ApiReserveEchoEntry
5145
Description: Reserves one of the echo channel API entry.
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.
5153
f_pusEchoIndex Resulting index reserved in the echo channel list.
5155
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5156
static UINT32 Oct6100ApiReserveEchoEntry(
5157
IN tPOCT6100_INSTANCE_API f_pApiInstance,
5158
OUT PUINT16 f_pusEchoIndex )
5160
tPOCT6100_SHARED_INFO pSharedInfo;
5165
/* Get local pointer to shared portion of instance. */
5166
pSharedInfo = f_pApiInstance->pSharedInfo;
5168
mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc )
5170
ulResult = OctapiLlmAllocAlloc( pEchoAlloc, &ulEchoIndex );
5171
if ( ulResult != cOCT6100_ERR_OK )
5173
if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
5174
return cOCT6100_ERR_CHANNEL_ALL_CHANNELS_ARE_OPENED;
5176
return cOCT6100_ERR_FATAL_11;
5179
*f_pusEchoIndex = (UINT16)( ulEchoIndex & 0xFFFF );
5181
return cOCT6100_ERR_OK;
5185
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5187
Function: Oct6100ApiReleaseEchoEntry
5189
Description: Releases the specified ECHO channel API entry.
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.
5197
f_usEchoIndex Index reserved in the echo channel list.
5199
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5200
static UINT32 Oct6100ApiReleaseEchoEntry(
5201
IN tPOCT6100_INSTANCE_API f_pApiInstance,
5202
IN UINT16 f_usEchoIndex )
5204
tPOCT6100_SHARED_INFO pSharedInfo;
5208
/* Get local pointer to shared portion of instance. */
5209
pSharedInfo = f_pApiInstance->pSharedInfo;
5211
mOCT6100_GET_CHANNEL_ALLOC_PNT( pSharedInfo, pEchoAlloc )
5213
ulResult = OctapiLlmAllocDealloc( pEchoAlloc, f_usEchoIndex );
5214
if ( ulResult != cOCT6100_ERR_OK )
5216
return cOCT6100_ERR_FATAL_12;
5219
return cOCT6100_ERR_OK;
5223
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5225
Function: Oct6100ApiCheckTdmConfig
5227
Description: This function will check the validity of the TDM config parameter
5228
of an Open TDM config structure.
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.
5236
f_pTdmConfig TDM config of the channel.
5238
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
5239
static UINT32 Oct6100ApiCheckTdmConfig(
5240
IN tPOCT6100_INSTANCE_API f_pApiInstance,
5241
IN tPOCT6100_CHANNEL_OPEN_TDM f_pTdmConfig )
5245
/*==============================================================================*/
5246
/* Check the TDM configuration parameters.*/
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 )
5252
if ( f_pTdmConfig->ulRinNumTssts != 1 &&
5253
f_pTdmConfig->ulRinNumTssts != 2 )
5254
return cOCT6100_ERR_CHANNEL_RIN_NUM_TSSTS;
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 )
5264
if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
5266
return cOCT6100_ERR_CHANNEL_RIN_TIMESLOT;
5268
else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
5270
return cOCT6100_ERR_CHANNEL_RIN_STREAM;
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 )
5283
if ( f_pTdmConfig->ulRoutNumTssts != 1 &&
5284
f_pTdmConfig->ulRoutNumTssts != 2 )
5285
return cOCT6100_ERR_CHANNEL_ROUT_NUM_TSSTS;
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 )
5295
if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
5297
return cOCT6100_ERR_CHANNEL_ROUT_TIMESLOT;
5299
else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
5301
return cOCT6100_ERR_CHANNEL_ROUT_STREAM;
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 )
5314
if ( f_pTdmConfig->ulSinNumTssts != 1 &&
5315
f_pTdmConfig->ulSinNumTssts != 2 )
5316
return cOCT6100_ERR_CHANNEL_SIN_NUM_TSSTS;
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 )
5326
if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
5328
return cOCT6100_ERR_CHANNEL_SIN_TIMESLOT;
5330
else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
5332
return cOCT6100_ERR_CHANNEL_SIN_STREAM;
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 )
5345
if ( f_pTdmConfig->ulSoutNumTssts != 1 &&
5346
f_pTdmConfig->ulSoutNumTssts != 2 )
5347
return cOCT6100_ERR_CHANNEL_SOUT_NUM_TSSTS;
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 )
5357
if ( ulResult == cOCT6100_ERR_TSST_TIMESLOT )
5359
return cOCT6100_ERR_CHANNEL_SOUT_TIMESLOT;
5361
else if ( ulResult == cOCT6100_ERR_TSST_STREAM )
5363
return cOCT6100_ERR_CHANNEL_SOUT_STREAM;
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;
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;
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;
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;
5389
/*==============================================================================*/
5393
return cOCT6100_ERR_OK;
5397
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5399
Function: Oct6100ApiCheckVqeConfig
5401
Description: This function will check the validity of the VQE config parameter
5402
of an Open VQE config structure.
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.
5410
f_pVqeConfig VQE config of the channel.
5411
f_fEnableToneDisabler Whether the tone disabler is active or not.
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 )
5419
tPOCT6100_API_IMAGE_INFO pImageInfo;
5421
pImageInfo = &f_pApiInstance->pSharedInfo->ImageInfo;
5423
if ( f_pVqeConfig->fEnableNlp != TRUE && f_pVqeConfig->fEnableNlp != FALSE )
5424
return cOCT6100_ERR_CHANNEL_ENABLE_NLP;
5426
if ( f_pVqeConfig->fEnableNlp == TRUE && pImageInfo->fNlpControl == FALSE )
5427
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLP_CONTROL;
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;
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;
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;
5445
if ( f_pVqeConfig->fSinDcOffsetRemoval == TRUE && pImageInfo->fSinDcOffsetRemoval == FALSE )
5446
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIN_DC_OFFSET_REM;
5448
if ( f_pVqeConfig->fRinDcOffsetRemoval != TRUE && f_pVqeConfig->fRinDcOffsetRemoval != FALSE )
5449
return cOCT6100_ERR_CHANNEL_RIN_DC_OFFSET_REM;
5451
if ( f_pVqeConfig->fRinDcOffsetRemoval == TRUE && pImageInfo->fRinDcOffsetRemoval == FALSE )
5452
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_DC_OFFSET_REM;
5454
/* Check the Level control.*/
5455
if ( f_pVqeConfig->fRinLevelControl != TRUE && f_pVqeConfig->fRinLevelControl != FALSE )
5456
return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL;
5458
if ( f_pVqeConfig->fSoutLevelControl != TRUE && f_pVqeConfig->fSoutLevelControl != FALSE )
5459
return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL;
5461
if ( ( f_pVqeConfig->lRinLevelControlGainDb < -24 ) || ( f_pVqeConfig->lRinLevelControlGainDb > 24 ) )
5462
return cOCT6100_ERR_CHANNEL_RIN_LEVEL_CONTROL_GAIN;
5464
if ( ( f_pVqeConfig->lSoutLevelControlGainDb < -24 ) || ( f_pVqeConfig->lSoutLevelControlGainDb > 24 ) )
5465
return cOCT6100_ERR_CHANNEL_SOUT_LEVEL_CONTROL_GAIN;
5467
if ( ( f_pVqeConfig->fRinAutomaticLevelControl != TRUE ) && ( f_pVqeConfig->fRinAutomaticLevelControl != FALSE ) )
5468
return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL;
5470
if ( ( f_pVqeConfig->fRinHighLevelCompensation != TRUE ) && ( f_pVqeConfig->fRinHighLevelCompensation != FALSE ) )
5471
return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP;
5473
if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE ) && ( pImageInfo->fRinAutoLevelControl == FALSE ) )
5474
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_AUTO_LC;
5476
if ( ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) && ( pImageInfo->fRinHighLevelCompensation == FALSE ) )
5477
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_RIN_HIGH_LEVEL_COMP;
5479
if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
5481
if ( f_pVqeConfig->fRinLevelControl == TRUE )
5482
return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_MANUAL;
5484
if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
5485
return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_HIGH_LEVEL_COMP;
5487
if ( ( f_pVqeConfig->lRinAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lRinAutomaticLevelControlTargetDb > 0 ) )
5488
return cOCT6100_ERR_CHANNEL_RIN_AUTO_LEVEL_CONTROL_TARGET;
5491
if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
5493
if ( f_pVqeConfig->fRinLevelControl == TRUE )
5494
return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_MANUAL;
5496
if ( ( f_pVqeConfig->lRinHighLevelCompensationThresholdDb < -40 || f_pVqeConfig->lRinHighLevelCompensationThresholdDb > 0 ) )
5497
return cOCT6100_ERR_CHANNEL_RIN_HIGH_LEVEL_COMP_THRESHOLD;
5500
if ( f_pVqeConfig->fSoutAutomaticLevelControl != TRUE && f_pVqeConfig->fSoutAutomaticLevelControl != FALSE )
5501
return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL;
5503
if ( ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE ) && ( pImageInfo->fSoutAutoLevelControl == FALSE ) )
5504
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SOUT_AUTO_LC;
5506
if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
5508
if ( f_pVqeConfig->fSoutLevelControl == TRUE )
5509
return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_MANUAL;
5511
if ( ( f_pVqeConfig->lSoutAutomaticLevelControlTargetDb < -40 || f_pVqeConfig->lSoutAutomaticLevelControlTargetDb > 0 ) )
5512
return cOCT6100_ERR_CHANNEL_SOUT_AUTO_LEVEL_CONTROL_TARGET;
5515
if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction != TRUE &&
5516
f_pVqeConfig->fSoutAdaptiveNoiseReduction != FALSE )
5517
return cOCT6100_ERR_CHANNEL_SOUT_ADAPT_NOISE_REDUCTION;
5519
if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE && pImageInfo->fAdaptiveNoiseReduction == FALSE )
5520
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ANR;
5522
if ( f_pVqeConfig->fSoutConferencingNoiseReduction != TRUE &&
5523
f_pVqeConfig->fSoutConferencingNoiseReduction != FALSE )
5524
return cOCT6100_ERR_CHANNEL_SOUT_CONFERENCE_NOISE_REDUCTION;
5526
if ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE && pImageInfo->fConferencingNoiseReduction == FALSE )
5527
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_CNR;
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;
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;
5538
/* If Sout noise bleaching is requested, no ANR or CNR shall be activated. */
5539
if ( f_pVqeConfig->fSoutNoiseBleaching == TRUE )
5542
if ( ( f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE )
5543
|| ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE ) )
5544
return cOCT6100_ERR_CHANNEL_SOUT_NOISE_BLEACHING_NR;
5547
/* Cannot activate both ANR and CNR when noise bleaching is present */
5548
if ( pImageInfo->fSoutNoiseBleaching == TRUE )
5550
if ( f_pVqeConfig->fSoutAdaptiveNoiseReduction == TRUE &&
5551
f_pVqeConfig->fSoutConferencingNoiseReduction == TRUE )
5552
return cOCT6100_ERR_CHANNEL_ANR_CNR_SIMULTANEOUSLY;
5555
/* Validate the DTMF tone removal parameter.*/
5556
if ( f_pVqeConfig->fDtmfToneRemoval != TRUE && f_pVqeConfig->fDtmfToneRemoval != FALSE )
5557
return cOCT6100_ERR_CHANNEL_TONE_REMOVAL;
5559
if ( f_pVqeConfig->fDtmfToneRemoval == TRUE && pImageInfo->fToneRemoval == FALSE )
5560
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TONE_REMOVAL;
5564
/* Check the Tail displacement enable.*/
5565
if ( f_pVqeConfig->fEnableTailDisplacement != TRUE && f_pVqeConfig->fEnableTailDisplacement != FALSE )
5566
return cOCT6100_ERR_CHANNEL_ENABLE_TAIL_DISPLACEMENT;
5568
if ( f_pVqeConfig->fEnableTailDisplacement == TRUE && pImageInfo->fTailDisplacement == FALSE )
5569
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_TAIL_DISPLACEMENT;
5571
/* Check the Tail displacement value.*/
5572
if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
5574
if ( f_pVqeConfig->ulTailDisplacement != cOCT6100_AUTO_SELECT_TAIL )
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;
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;
5586
/* Check the tail length value. */
5587
if ( f_pVqeConfig->ulTailLength != cOCT6100_AUTO_SELECT_TAIL )
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;
5594
if ( ( f_pVqeConfig->ulTailLength < 32 ) || ( f_pVqeConfig->ulTailLength > 128 )
5595
|| ( ( f_pVqeConfig->ulTailLength % 4 ) != 0x0 ) )
5596
return cOCT6100_ERR_CHANNEL_TAIL_LENGTH;
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;
5603
/* Validate the acoustic echo cancellation parameter.*/
5604
if ( f_pVqeConfig->fAcousticEcho != TRUE && f_pVqeConfig->fAcousticEcho != FALSE )
5605
return cOCT6100_ERR_CHANNEL_ACOUSTIC_ECHO;
5607
if ( f_pVqeConfig->fAcousticEcho == TRUE && pImageInfo->fAcousticEcho == FALSE )
5608
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ACOUSTIC_ECHO;
5610
if ( f_pVqeConfig->fAcousticEcho == TRUE )
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;
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;
5623
if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
5627
/* Start with requested tail displacement. */
5628
if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
5630
ulTailSum = f_pApiInstance->pSharedInfo->ChipConfig.usTailDisplacement;
5634
ulTailSum = f_pVqeConfig->ulTailDisplacement;
5637
/* Add requested tail length. */
5638
if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
5640
ulTailSum += f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength;
5644
ulTailSum += f_pVqeConfig->ulTailLength;
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;
5653
/* Validate the Default ERL parameter.*/
5654
if ( f_pVqeConfig->lDefaultErlDb != -6 && pImageInfo->fDefaultErl == FALSE )
5655
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DEFAULT_ERL;
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;
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;
5668
if ( f_pVqeConfig->lAecDefaultErlDb != 0 && f_pVqeConfig->lAecDefaultErlDb != -3 && f_pVqeConfig->lAecDefaultErlDb != -6 )
5669
return cOCT6100_ERR_CHANNEL_AEC_DEFAULT_ERL;
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;
5675
if ( f_pVqeConfig->ulNonLinearityBehaviorA >= 14 )
5676
return cOCT6100_ERR_CHANNEL_DOUBLE_TALK;
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;
5682
if ( f_pVqeConfig->ulNonLinearityBehaviorB >= 9 )
5683
return cOCT6100_ERR_CHANNEL_NON_LINEARITY_B;
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;
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;
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;
5697
if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb > 30 )
5698
return cOCT6100_ERR_CHANNEL_ALE_RATIO;
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;
5704
if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE && pImageInfo->fListenerEnhancement == FALSE )
5705
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_NLE;
5707
if ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
5709
if ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb > 30 )
5710
return cOCT6100_ERR_CHANNEL_NLE_RATIO;
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;
5718
/* Validate Rout noise reduction. */
5719
if ( f_pVqeConfig->fRoutNoiseReduction != TRUE && f_pVqeConfig->fRoutNoiseReduction != FALSE )
5720
return cOCT6100_ERR_CHANNEL_ROUT_NOISE_REDUCTION;
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;
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;
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;
5741
/* Validate ANR voice-noise segregation. */
5742
if ( f_pVqeConfig->ulAnrVoiceNoiseSegregation > 15 )
5743
return cOCT6100_ERR_CHANNEL_ANR_SEGREGATION;
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;
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;
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;
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;
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;
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;
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;
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;
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;
5786
return cOCT6100_ERR_OK;
5789
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5791
Function: Oct6100ApiCheckCodecConfig
5793
Description: This function will check the validity of the Codec config parameter
5794
of an Open Codec config structure.
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.
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.
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 )
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;
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;
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;
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;
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;
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 )
5844
if ( f_pCodecConfig->ulEncodingRate != cOCT6100_G711_64KBPS )
5845
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_ENCODING;
5848
if ( f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm == FALSE &&
5849
f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
5851
if ( f_pCodecConfig->ulDecodingRate != cOCT6100_G711_64KBPS )
5852
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_DECODING;
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;
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;
5865
/* Check Encoder related parameter if one is used.*/
5866
if ( f_pCodecConfig->ulEncoderPort != cOCT6100_NO_ENCODING )
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;
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;
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;
5896
if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
5897
f_pApiInstance->pSharedInfo->ImageInfo.fSilenceSuppression == FALSE )
5898
return cOCT6100_ERR_NOT_SUPPORTED_CHANNEL_SIL_SUP;
5900
if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
5901
f_pCodecConfig->ulPhasingType == cOCT6100_NO_PHASING )
5902
return cOCT6100_ERR_CHANNEL_PHASE_TYPE_REQUIRED;
5904
if ( f_pCodecConfig->fEnableSilenceSuppression == TRUE &&
5905
f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE )
5906
return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED;
5908
if ( f_pCodecConfig->ulPhasingTsstHndl == cOCT6100_INVALID_HANDLE &&
5909
f_pCodecConfig->ulPhasingType != cOCT6100_NO_PHASING )
5910
return cOCT6100_ERR_CHANNEL_PHASING_TSST_REQUIRED;
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;
5917
/* Check phasing TSST info if phasing is required.*/
5918
if ( f_pCodecConfig->ulPhasingTsstHndl != cOCT6100_INVALID_HANDLE )
5920
tPOCT6100_API_PHASING_TSST pPhasingEntry;
5921
UINT32 ulEntryOpenCnt;
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;
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;
5931
mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, *f_pusPhasingTsstIndex );
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;
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;
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;
5948
*f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX;
5953
*f_pusPhasingTsstIndex = cOCT6100_INVALID_INDEX;
5957
/* Check Decoder related parameter if one is used.*/
5958
if ( f_pCodecConfig->ulDecoderPort != cOCT6100_NO_DECODING )
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;
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;
5985
return cOCT6100_ERR_OK;
5988
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
5990
Function: Oct6100ApiWriteInputTsstControlMemory
5992
Description: This function configure a TSST control memory entry in internal memory.
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.
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.
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 )
6011
tOCT6100_WRITE_PARAMS WriteParams;
6014
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6016
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6018
WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
6020
WriteParams.usWriteData = cOCT6100_TSST_CONTROL_MEM_INPUT_TSST;
6021
WriteParams.usWriteData |= f_usTsiMemIndex & cOCT6100_TSST_CONTROL_MEM_TSI_MEM_MASK;
6023
/* Set the PCM law.*/
6024
WriteParams.usWriteData |= f_ulTsstInputLaw << cOCT6100_TSST_CONTROL_MEM_PCM_LAW_OFFSET;
6026
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6027
if ( ulResult != cOCT6100_ERR_OK )
6030
return cOCT6100_ERR_OK;
6035
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6037
Function: Oct6100ApiWriteOutputTsstControlMemory
6039
Description: This function configure a TSST control memory entry in internal memory.
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.
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 )
6055
tOCT6100_WRITE_PARAMS WriteParams;
6058
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6060
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6062
WriteParams.ulWriteAddress = cOCT6100_TSST_CONTROL_MEM_BASE + ( (f_usTsstIndex & cOCT6100_TSST_INDEX_MASK) * cOCT6100_TSST_CONTROL_MEM_ENTRY_SIZE );
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;
6069
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6070
if ( ulResult != cOCT6100_ERR_OK )
6073
return cOCT6100_ERR_OK;
6077
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6079
Function: Oct6100ApiWriteEncoderMemory
6081
Description: This function configure a Encoded memory entry in internal memory.
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.
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.
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 )
6110
tOCT6100_WRITE_PARAMS WriteParams;
6113
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6115
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6117
/*==============================================================================*/
6118
/* Conversion Control Base */
6119
WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_ulEncoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
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;
6125
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6126
if ( ulResult != cOCT6100_ERR_OK )
6129
/*==============================================================================*/
6130
/* Conversion Control Base + 2 */
6131
WriteParams.ulWriteAddress += 2;
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 );
6137
WriteParams.usWriteData = 0;
6139
/* Set the phasing type and the phase value if required.*/
6140
switch( f_ulPhasingType )
6142
case cOCT6100_NO_PHASING:
6143
WriteParams.usWriteData |= 0x1 << 10;
6145
case cOCT6100_SINGLE_PHASING:
6146
WriteParams.usWriteData |= f_ulPhase;
6148
case cOCT6100_DUAL_PHASING:
6149
WriteParams.usWriteData |= 0x1 << 11;
6150
WriteParams.usWriteData |= f_ulPhase;
6157
/* Set the silence suppression flag.*/
6158
WriteParams.usWriteData |= f_ulEnableSilenceSuppression << cOCT6100_CONVERSION_CONTROL_MEM_SIL_SUP_OFFSET;
6160
/* Set the nibble position.*/
6161
WriteParams.usWriteData |= f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET;
6163
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6164
if ( ulResult != cOCT6100_ERR_OK )
6167
/*==============================================================================*/
6168
/* Conversion Control Base + 4 */
6169
WriteParams.ulWriteAddress += 2;
6171
/* Set the reset mode */
6172
WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR;
6174
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6175
if ( ulResult != cOCT6100_ERR_OK )
6178
/*==============================================================================*/
6179
/* Conversion Control Base + 6 */
6180
WriteParams.ulWriteAddress += 2;
6182
/* Set the reset mode */
6183
WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY;
6185
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6186
if ( ulResult != cOCT6100_ERR_OK )
6189
/*==============================================================================*/
6190
return cOCT6100_ERR_OK;
6194
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6196
Function: Oct6100ApiWriteDecoderMemory
6198
Description: This function configure a Decoder memory entry in internal memory.
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.
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.
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 )
6221
tOCT6100_WRITE_PARAMS WriteParams;
6224
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6226
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6229
/*==============================================================================*/
6230
/* Conversion Control Base */
6231
WriteParams.ulWriteAddress = cOCT6100_CONVERSION_CONTROL_MEM_BASE + ( f_usDecoderIndex * cOCT6100_CONVERSION_CONTROL_MEM_ENTRY_SIZE );
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;
6237
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6238
if ( ulResult != cOCT6100_ERR_OK )
6241
/*==============================================================================*/
6242
/* Conversion Control Base + 2 */
6243
WriteParams.ulWriteAddress += 2;
6245
/* Set the nibble position.*/
6246
WriteParams.usWriteData = (UINT16)( f_ulAdpcmNibblePosition << cOCT6100_CONVERSION_CONTROL_MEM_NIBBLE_POS_OFFSET );
6249
WriteParams.usWriteData |= f_ulPcmLaw << cOCT6100_CONVERSION_CONTROL_MEM_LAW_OFFSET;
6251
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6252
if ( ulResult != cOCT6100_ERR_OK )
6255
/*==============================================================================*/
6256
/* Conversion Control Base + 4 */
6257
WriteParams.ulWriteAddress += 2;
6259
/* Set the reset mode */
6260
WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_RST_ON_NEXT_FR;
6262
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6263
if ( ulResult != cOCT6100_ERR_OK )
6266
/*==============================================================================*/
6267
/* Conversion Control Base + 6 */
6268
WriteParams.ulWriteAddress += 2;
6270
/* Set the reset mode */
6271
WriteParams.usWriteData = cOCT6100_CONVERSION_CONTROL_MEM_ACTIVATE_ENTRY;
6273
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6274
if ( ulResult != cOCT6100_ERR_OK )
6277
return cOCT6100_ERR_OK;
6282
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6284
Function: Oct6100ApiClearConversionMemory
6286
Description: This function clears a conversion memory entry in internal
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.
6295
f_usConversionMemIndex Index of the block within the conversion memory.
6297
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
6298
static UINT32 Oct6100ApiClearConversionMemory(
6299
IN tPOCT6100_INSTANCE_API f_pApiInstance,
6300
IN UINT16 f_usConversionMemIndex )
6302
tOCT6100_WRITE_PARAMS WriteParams;
6303
tOCT6100_READ_PARAMS ReadParams;
6305
UINT32 ulBaseAddress;
6308
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6310
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6311
WriteParams.usWriteData = 0;
6313
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
6315
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
6316
ReadParams.pusReadData = &usReadData;
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;
6324
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6325
if ( ulResult != cOCT6100_ERR_OK )
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 )
6334
/* Then clear the rest of the structure. */
6335
WriteParams.ulWriteAddress = ulBaseAddress + 4;
6337
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6338
if ( ulResult != cOCT6100_ERR_OK )
6341
WriteParams.ulWriteAddress = ulBaseAddress + 2;
6343
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6344
if ( ulResult != cOCT6100_ERR_OK )
6347
WriteParams.ulWriteAddress = ulBaseAddress;
6349
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
6350
if ( ulResult != cOCT6100_ERR_OK )
6353
/*==============================================================================*/
6355
return cOCT6100_ERR_OK;
6359
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6361
Function: Oct6100ApiWriteVqeMemory
6363
Description: This function configure an echo memory entry in internal memory and
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.
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
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 )
6392
/* Write the NLP software configuration structure. */
6393
ulResult = Oct6100ApiWriteVqeNlpMemory(
6399
f_fClearPlayoutPointers,
6401
if ( ulResult != cOCT6100_ERR_OK )
6404
/* Write the AF software configuration structure. */
6405
ulResult = Oct6100ApiWriteVqeAfMemory(
6411
f_fClearPlayoutPointers,
6413
if ( ulResult != cOCT6100_ERR_OK )
6416
return cOCT6100_ERR_OK;
6419
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
6421
Function: Oct6100ApiWriteVqeNlpMemory
6423
Description: This function configures the NLP related VQE features of an
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.
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
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 )
6450
tPOCT6100_API_CHANNEL pChanEntry;
6451
tPOCT6100_SHARED_INFO pSharedInfo;
6452
tOCT6100_WRITE_PARAMS WriteParams;
6453
tOCT6100_BUFFER_PLAYOUT_STOP BufferPlayoutStop;
6456
UINT32 ulNlpConfigBaseAddress;
6457
UINT32 ulFeatureBytesOffset;
6458
UINT32 ulFeatureBitOffset;
6459
UINT32 ulFeatureFieldLength;
6462
BOOL fEchoOperationModeChanged;
6464
pSharedInfo = f_pApiInstance->pSharedInfo;
6466
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
6468
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
6470
/* Obtain a pointer to the new buffer's list entry. */
6471
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
6473
/*==============================================================================*/
6474
/* Configure the CPU NLP configuration of the channel feature by feature.*/
6476
ulNlpConfigBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
6478
/* Set initial value to zero.*/
6481
/* Configure Adaptive Noise Reduction.*/
6482
if ( pSharedInfo->ImageInfo.fAdaptiveNoiseReduction == TRUE )
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 )
6491
ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.usDwordOffset * 4;
6492
ulFeatureBitOffset = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byBitOffset;
6493
ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst.byFieldSize;
6495
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6497
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6500
if ( ulResult != cOCT6100_ERR_OK )
6503
/* Clear previous value set in the feature field.*/
6504
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6506
ulTempData &= (~ulMask);
6508
/* Set adaptive noise reduction on the SOUT port.*/
6509
ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutAdaptiveNoiseReduction ) << ulFeatureBitOffset );
6511
/* If SOUT noise bleaching is requested, ANR must be activated. */
6512
ulTempData |= ( ( (UINT32)f_pVqeConfig->fSoutNoiseBleaching ) << ulFeatureBitOffset );
6514
/* First read the DWORD where the field is located. */
6515
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
6517
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6520
if ( ulResult != cOCT6100_ERR_OK )
6525
/* Configure Rout Noise Reduction. */
6526
if ( pSharedInfo->ImageInfo.fRoutNoiseReduction == TRUE )
6528
/* Check if the configuration has been changed. */
6529
if ( ( f_fModifyOnly == FALSE )
6530
|| ( ( f_fModifyOnly == TRUE )
6531
&& ( f_pVqeConfig->fRoutNoiseReduction != pChanEntry->VqeConfig.fRoutNoiseReduction ) ) )
6533
ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAnrOfst.usDwordOffset * 4;
6534
ulFeatureBitOffset = pSharedInfo->MemoryMap.RinAnrOfst.byBitOffset;
6535
ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAnrOfst.byFieldSize;
6537
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6539
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6542
if ( ulResult != cOCT6100_ERR_OK )
6545
/* Clear previous value set in the feature field.*/
6546
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6548
ulTempData &= (~ulMask);
6550
/* Set noise reduction on the Rout port. */
6551
ulTempData |= ( ( (UINT32)f_pVqeConfig->fRoutNoiseReduction ) << ulFeatureBitOffset );
6553
/* Write the new DWORD where the field is located. */
6554
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
6556
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6559
if ( ulResult != cOCT6100_ERR_OK )
6564
/* Configure Sout ANR SNR enhancement. */
6565
if ( pSharedInfo->ImageInfo.fAnrSnrEnhancement == TRUE )
6567
/* Check if the configuration has been changed. */
6568
if ( ( f_fModifyOnly == FALSE )
6569
|| ( ( f_fModifyOnly == TRUE )
6570
&& ( f_pVqeConfig->lAnrSnrEnhancementDb != pChanEntry->VqeConfig.chAnrSnrEnhancementDb ) ) )
6572
ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.usDwordOffset * 4;
6573
ulFeatureBitOffset = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byBitOffset;
6574
ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrSnrEnhancementOfst.byFieldSize;
6576
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6578
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6581
if ( ulResult != cOCT6100_ERR_OK )
6584
/* Clear previous value set in the feature field.*/
6585
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6587
ulTempData &= (~ulMask);
6589
/* Set ANR SNR enhancement on the Sout port. */
6590
switch( f_pVqeConfig->lAnrSnrEnhancementDb )
6592
case -9: ulTempData |= ( 7 << ulFeatureBitOffset );
6594
case -12: ulTempData |= ( 6 << ulFeatureBitOffset );
6596
case -15: ulTempData |= ( 5 << ulFeatureBitOffset );
6598
case -21: ulTempData |= ( 3 << ulFeatureBitOffset );
6600
case -24: ulTempData |= ( 2 << ulFeatureBitOffset );
6602
case -27: ulTempData |= ( 1 << ulFeatureBitOffset );
6604
case -30: ulTempData |= ( 0 << ulFeatureBitOffset );
6606
default: ulTempData |= ( 4 << ulFeatureBitOffset );
6611
/* Write the new DWORD where the field is located. */
6612
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
6614
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6617
if ( ulResult != cOCT6100_ERR_OK )
6622
/* Configure Sout ANR voice-noise segregation. */
6623
if ( pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation == TRUE )
6625
/* Check if the configuration has been changed. */
6626
if ( ( f_fModifyOnly == FALSE )
6627
|| ( ( f_fModifyOnly == TRUE )
6628
&& ( f_pVqeConfig->ulAnrVoiceNoiseSegregation != pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation ) ) )
6630
ulFeatureBytesOffset = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.usDwordOffset * 4;
6631
ulFeatureBitOffset = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byBitOffset;
6632
ulFeatureFieldLength = pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst.byFieldSize;
6634
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6636
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6639
if ( ulResult != cOCT6100_ERR_OK )
6642
/* Clear previous value set in the feature field.*/
6643
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6645
ulTempData &= (~ulMask);
6647
/* Set ANR voice-noise segregation on the Sout port. */
6648
ulTempData |= ( ( (UINT32)f_pVqeConfig->ulAnrVoiceNoiseSegregation ) << ulFeatureBitOffset );
6650
/* Write the new DWORD where the field is located. */
6651
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
6653
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6656
if ( ulResult != cOCT6100_ERR_OK )
6661
/* Configure the tone disabler VQE activation delay. */
6662
if ( pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay == TRUE )
6664
/* Check if the configuration has been changed. */
6665
if ( ( f_fModifyOnly == FALSE )
6666
|| ( ( f_fModifyOnly == TRUE )
6667
&& ( f_pVqeConfig->ulToneDisablerVqeActivationDelay != pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay ) ) )
6669
ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.usDwordOffset * 4;
6670
ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byBitOffset;
6671
ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst.byFieldSize;
6673
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6675
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6678
if ( ulResult != cOCT6100_ERR_OK )
6681
/* Clear previous value set in the feature field.*/
6682
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6684
ulTempData &= (~ulMask);
6686
/* Set the tone disabler VQE activation delay. */
6687
ulTempData |= ( ( (UINT32)( ( f_pVqeConfig->ulToneDisablerVqeActivationDelay - 300 ) / 512 ) ) << ulFeatureBitOffset );
6689
/* Write the new DWORD where the field is located. */
6690
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
6692
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6695
if ( ulResult != cOCT6100_ERR_OK )
6700
/* Configure Conferencing Noise Reduction.*/
6701
if ( pSharedInfo->ImageInfo.fConferencingNoiseReduction == TRUE )
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 ) ) ) )
6709
ulFeatureBytesOffset = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.usDwordOffset * 4;
6710
ulFeatureBitOffset = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byBitOffset;
6711
ulFeatureFieldLength = pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst.byFieldSize;
6713
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6715
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6718
if ( ulResult != cOCT6100_ERR_OK )
6721
/* Clear previous value set in the feature field.*/
6722
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6724
ulTempData &= (~ulMask);
6726
/* Set conferencing noise reduction on the SOUT port. */
6727
ulTempData |= (f_pVqeConfig->fSoutConferencingNoiseReduction << ulFeatureBitOffset );
6729
/* If SOUT noise bleaching is requested, CNR must be activated. */
6730
ulTempData |= (f_pVqeConfig->fSoutNoiseBleaching << ulFeatureBitOffset );
6732
/* Save the DWORD where the field is located. */
6733
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
6735
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6738
if ( ulResult != cOCT6100_ERR_OK )
6743
/* Set the DC removal on RIN ports.*/
6744
if ( pSharedInfo->ImageInfo.fRinDcOffsetRemoval == TRUE )
6746
/* Check if the configuration has been changed. */
6747
if ( ( f_fModifyOnly == FALSE )
6748
|| ( ( f_fModifyOnly == TRUE )
6749
&& ( f_pVqeConfig->fRinDcOffsetRemoval != pChanEntry->VqeConfig.fRinDcOffsetRemoval ) ) )
6751
ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.usDwordOffset * 4;
6752
ulFeatureBitOffset = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byBitOffset;
6753
ulFeatureFieldLength = pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst.byFieldSize;
6755
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6757
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6760
if ( ulResult != cOCT6100_ERR_OK )
6763
/* Clear previous value set in the feature field.*/
6764
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6766
ulTempData &= (~ulMask);
6768
/* Set adaptive noise reduction on the SOUT port.*/
6769
ulTempData |= ( ( (UINT32)f_pVqeConfig->fRinDcOffsetRemoval ) << ulFeatureBitOffset );
6771
/* The write the new DWORD where the field is located.*/
6772
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
6774
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6777
if ( ulResult != cOCT6100_ERR_OK )
6782
/* Set the DC removal on SIN ports.*/
6783
if ( pSharedInfo->ImageInfo.fSinDcOffsetRemoval == TRUE )
6785
/* Check if the configuration has been changed. */
6786
if ( ( f_fModifyOnly == FALSE )
6787
|| ( ( f_fModifyOnly == TRUE )
6788
&& ( f_pVqeConfig->fSinDcOffsetRemoval != pChanEntry->VqeConfig.fSinDcOffsetRemoval ) ) )
6790
ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.usDwordOffset * 4;
6791
ulFeatureBitOffset = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byBitOffset;
6792
ulFeatureFieldLength = pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst.byFieldSize;
6794
/* First read the DWORD where the field is located.*/
6795
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6797
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6800
if ( ulResult != cOCT6100_ERR_OK )
6803
/* Clear previous value set in the feature field.*/
6804
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6806
ulTempData &= (~ulMask);
6808
/* Set adaptive noise reduction on the SOUT port.*/
6809
ulTempData |= ( ( (UINT32)f_pVqeConfig->fSinDcOffsetRemoval ) << ulFeatureBitOffset );
6811
/* Save the DWORD where the field is located.*/
6812
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
6814
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6817
if ( ulResult != cOCT6100_ERR_OK )
6822
/* Set the level control. */
6823
if ( ( pChanEntry->byEchoOperationMode != f_pChannelOpen->ulEchoOperationMode )
6824
&& ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NORMAL ) )
6825
fEchoOperationModeChanged = TRUE;
6827
fEchoOperationModeChanged = FALSE;
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,
6836
fEchoOperationModeChanged );
6837
if ( ulResult != cOCT6100_ERR_OK )
6840
/* Set the background noise freeze.*/
6841
if ( pSharedInfo->ImageInfo.fComfortNoise == TRUE )
6843
/* Check if the configuration has been changed. */
6844
if ( ( f_fModifyOnly == FALSE )
6845
|| ( ( f_fModifyOnly == TRUE )
6846
&& ( f_pVqeConfig->ulComfortNoiseMode != pChanEntry->VqeConfig.byComfortNoiseMode ) ) )
6848
ulFeatureBytesOffset = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.usDwordOffset * 4;
6849
ulFeatureBitOffset = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byBitOffset;
6850
ulFeatureFieldLength = pSharedInfo->MemoryMap.ComfortNoiseModeOfst.byFieldSize;
6852
/* First read the DWORD where the field is located.*/
6853
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6855
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6858
if ( ulResult != cOCT6100_ERR_OK )
6861
/* Clear previous value set in the feature field.*/
6862
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6864
ulTempData &= (~ulMask);
6865
ulTempData |= ( f_pVqeConfig->ulComfortNoiseMode << ulFeatureBitOffset );
6867
/* Save the new DWORD where the field is located. */
6868
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
6870
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6873
if ( ulResult != cOCT6100_ERR_OK )
6878
/* Set the state of the NLP */
6879
if ( pSharedInfo->ImageInfo.fNlpControl == TRUE )
6881
/* Check if the configuration has been changed. */
6882
if ( ( f_fModifyOnly == FALSE )
6883
|| ( ( f_fModifyOnly == TRUE )
6884
&& ( f_pVqeConfig->fEnableNlp != pChanEntry->VqeConfig.fEnableNlp ) ) )
6886
ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpControlFieldOfst.usDwordOffset * 4;
6887
ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpControlFieldOfst.byBitOffset;
6888
ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpControlFieldOfst.byFieldSize;
6890
/* First read the DWORD where the field is located.*/
6891
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6893
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6896
if ( ulResult != cOCT6100_ERR_OK )
6899
/* Clear previous value set in the feature field.*/
6900
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6902
ulTempData &= (~ulMask);
6904
if ( f_pVqeConfig->fEnableNlp == FALSE )
6905
ulTempData |= 0x1 << ulFeatureBitOffset;
6907
/* Save the new DWORD where the field is located.*/
6908
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
6910
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6913
if ( ulResult != cOCT6100_ERR_OK )
6918
/* Set the tail configuration. */
6919
ulResult = Oct6100ApiSetChannelTailConfiguration(
6925
if ( ulResult != cOCT6100_ERR_OK )
6928
/* Set the Default ERL. */
6929
if ( ( pSharedInfo->ImageInfo.fDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == FALSE ) )
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 ) ) ) )
6938
ulFeatureBytesOffset = pSharedInfo->MemoryMap.DefaultErlFieldOfst.usDwordOffset * 4;
6939
ulFeatureBitOffset = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byBitOffset;
6940
ulFeatureFieldLength = pSharedInfo->MemoryMap.DefaultErlFieldOfst.byFieldSize;
6942
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6944
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6947
if ( ulResult != cOCT6100_ERR_OK )
6950
/* Clear previous value set in the feature field.*/
6951
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
6953
ulTempData &= (~ulMask);
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 ) )
6959
usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb );
6963
/* Clear the defautl ERL when using the no echo cancellation operation mode. */
6967
if ( ulFeatureFieldLength < 16 )
6968
usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
6970
ulTempData |= ( usTempData << ulFeatureBitOffset );
6972
/* Save the new DWORD where the field is located.*/
6973
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
6975
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
6978
if ( ulResult != cOCT6100_ERR_OK )
6983
/* Set the Acoustic echo control.*/
6984
if ( pSharedInfo->ImageInfo.fAcousticEcho == TRUE )
6986
/* Check if the configuration has been changed. */
6987
if ( ( f_fModifyOnly == FALSE )
6988
|| ( ( f_fModifyOnly == TRUE )
6989
&& ( f_pVqeConfig->fAcousticEcho != pChanEntry->VqeConfig.fAcousticEcho ) ) )
6991
ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecFieldOfst.usDwordOffset * 4;
6992
ulFeatureBitOffset = pSharedInfo->MemoryMap.AecFieldOfst.byBitOffset;
6993
ulFeatureFieldLength = pSharedInfo->MemoryMap.AecFieldOfst.byFieldSize;
6995
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
6997
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7000
if ( ulResult != cOCT6100_ERR_OK )
7003
/* Clear previous value set in the feature field. */
7004
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7006
ulTempData &= (~ulMask);
7007
ulTempData |= ( ( (UINT32)f_pVqeConfig->fAcousticEcho ) << ulFeatureBitOffset );
7009
/* Then save the new DWORD where the field is located. */
7010
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7012
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7015
if ( ulResult != cOCT6100_ERR_OK )
7020
/* Set the Acoustic Echo Default ERL. */
7021
if ( ( pSharedInfo->ImageInfo.fAecDefaultErl == TRUE ) && ( f_pVqeConfig->fAcousticEcho == TRUE ) )
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 ) ) ) )
7029
ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.usDwordOffset * 4;
7030
ulFeatureBitOffset = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byBitOffset;
7031
ulFeatureFieldLength = pSharedInfo->MemoryMap.AecDefaultErlFieldOfst.byFieldSize;
7033
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7035
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7038
if ( ulResult != cOCT6100_ERR_OK )
7041
/* Clear previous value set in the feature field. */
7042
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7044
ulTempData &= (~ulMask);
7046
if ( ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
7047
&& ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
7049
/* Convert the DB value to octasic's float format. (In energy) */
7050
usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lAecDefaultErlDb );
7054
/* Clear the AEC defautl ERL when using the no echo cancellation operation mode. */
7058
if ( ulFeatureFieldLength < 16 )
7059
usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
7061
ulTempData |= ( usTempData << ulFeatureBitOffset );
7063
/* Then save the DWORD where the field is located. */
7064
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7066
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7069
if ( ulResult != cOCT6100_ERR_OK )
7074
/* Set the DTMF tone removal bit.*/
7075
if ( pSharedInfo->ImageInfo.fToneRemoval == TRUE )
7077
/* Check if the configuration has been changed. */
7078
if ( ( f_fModifyOnly == FALSE )
7079
|| ( ( f_fModifyOnly == TRUE )
7080
&& ( f_pVqeConfig->fDtmfToneRemoval != pChanEntry->VqeConfig.fDtmfToneRemoval ) ) )
7082
ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.usDwordOffset * 4;
7083
ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byBitOffset;
7084
ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneRemovalFieldOfst.byFieldSize;
7086
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7088
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7091
if ( ulResult != cOCT6100_ERR_OK )
7094
/* Clear previous value set in the feature field.*/
7095
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7097
ulTempData &= (~ulMask);
7098
ulTempData |= ( ( (UINT32)f_pVqeConfig->fDtmfToneRemoval ) << ulFeatureBitOffset );
7100
/* First read the DWORD where the field is located.*/
7101
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7103
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7106
if ( ulResult != cOCT6100_ERR_OK )
7113
/* Set the non-linear behavior A.*/
7114
if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorA == TRUE )
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 ) ) ) )
7122
UINT16 ausLookupTable[ 14 ] = { 0x3663, 0x3906, 0x399C, 0x3A47, 0x3B06, 0x3B99, 0x3C47, 0x3D02, 0x3D99, 0x3E47, 0x3F00, 0x3F99, 0x4042, 0x4100 };
7124
ulFeatureBytesOffset = pSharedInfo->MemoryMap.PcmLeakFieldOfst.usDwordOffset * 4;
7125
ulFeatureBitOffset = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byBitOffset;
7126
ulFeatureFieldLength = pSharedInfo->MemoryMap.PcmLeakFieldOfst.byFieldSize;
7128
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7130
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7133
if ( ulResult != cOCT6100_ERR_OK )
7136
/* Clear previous value set in the feature field.*/
7137
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
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 );
7144
ulTempData |= ( ausLookupTable[ f_pVqeConfig->ulNonLinearityBehaviorA ] << ulFeatureBitOffset );
7146
/* Then save the DWORD where the field is located.*/
7147
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7149
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7152
if ( ulResult != cOCT6100_ERR_OK )
7157
/* Synch all the buffer playout field.*/
7158
if ( pSharedInfo->ImageInfo.fBufferPlayout == TRUE && f_fClearPlayoutPointers == TRUE )
7160
Oct6100BufferPlayoutStopDef( &BufferPlayoutStop );
7162
BufferPlayoutStop.ulChannelHndl = cOCT6100_INVALID_HANDLE;
7163
BufferPlayoutStop.fStopCleanly = TRUE;
7165
BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_ROUT;
7166
ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
7173
if ( ulResult != cOCT6100_ERR_OK )
7176
BufferPlayoutStop.ulPlayoutPort = cOCT6100_CHANNEL_PORT_SOUT;
7177
ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
7184
if ( ulResult != cOCT6100_ERR_OK )
7188
/*==============================================================================*/
7189
/* Write the 2100 Hz Echo Disabling mode */
7191
/* Check if the configuration has been changed. */
7192
if ( ( f_fModifyOnly == FALSE )
7193
|| ( ( f_fModifyOnly == TRUE )
7194
&& ( f_pChannelOpen->fEnableToneDisabler != pChanEntry->fEnableToneDisabler ) ) )
7196
ulFeatureBytesOffset = pSharedInfo->MemoryMap.ToneDisablerControlOfst.usDwordOffset * 4;
7197
ulFeatureBitOffset = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byBitOffset;
7198
ulFeatureFieldLength = pSharedInfo->MemoryMap.ToneDisablerControlOfst.byFieldSize;
7200
/* First read the DWORD where the field is located.*/
7201
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7203
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7206
if ( ulResult != cOCT6100_ERR_OK )
7209
/* Clear previous value set in the feature field.*/
7210
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7212
ulTempData &= (~ulMask);
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;
7218
/* Save the DWORD where the field is located. */
7219
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7221
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7224
if ( ulResult != cOCT6100_ERR_OK )
7227
/*==============================================================================*/
7230
/*==============================================================================*/
7231
/* Write the Nlp Trivial enable flag. */
7233
/* Check if the configuration has been changed. */
7234
if ( ( f_fModifyOnly == FALSE )
7235
|| ( ( f_fModifyOnly == TRUE )
7238
( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) ) )
7240
ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.usDwordOffset * 4;
7241
ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byBitOffset;
7242
ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpTrivialFieldOfst.byFieldSize;
7244
/* First read the DWORD where the field is located.*/
7245
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7247
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7250
if ( ulResult != cOCT6100_ERR_OK )
7253
/* Clear previous value set in the feature field.*/
7254
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7256
ulTempData &= (~ulMask);
7257
if ( ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_NO_ECHO )
7258
|| ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION ) )
7260
ulTempData |= TRUE << ulFeatureBitOffset;
7264
/* Then write the DWORD where the field is located. */
7265
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7267
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7270
if ( ulResult != cOCT6100_ERR_OK )
7273
/*==============================================================================*/
7276
/*==============================================================================*/
7277
/* Set the double talk behavior mode. */
7278
if ( pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst == TRUE )
7280
/* Check if the configuration has been changed. */
7281
if ( ( f_fModifyOnly == FALSE )
7282
|| ( ( f_fModifyOnly == TRUE )
7283
&& ( f_pVqeConfig->ulDoubleTalkBehavior != pChanEntry->VqeConfig.byDoubleTalkBehavior ) ) )
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;
7290
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7292
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7295
if ( ulResult != cOCT6100_ERR_OK )
7298
/* Clear previous value set in the feature field.*/
7299
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7301
ulTempData &= (~ulMask);
7302
ulTempData |= (f_pVqeConfig->ulDoubleTalkBehavior << ulFeatureBitOffset );
7304
/* Then save the DWORD where the field is located.*/
7305
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7307
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7310
if ( ulResult != cOCT6100_ERR_OK )
7314
/*==============================================================================*/
7317
/*==============================================================================*/
7318
/* Set the music protection enable. */
7319
if ( ( pSharedInfo->ImageInfo.fMusicProtection == TRUE )
7320
&& ( pSharedInfo->ImageInfo.fMusicProtectionConfiguration == TRUE ) )
7322
/* Check if the configuration has been changed. */
7323
if ( ( f_fModifyOnly == FALSE )
7324
|| ( ( f_fModifyOnly == TRUE )
7325
&& ( f_pVqeConfig->fEnableMusicProtection != pChanEntry->VqeConfig.fEnableMusicProtection ) ) )
7327
ulFeatureBytesOffset = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.usDwordOffset * 4;
7328
ulFeatureBitOffset = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byBitOffset;
7329
ulFeatureFieldLength = pSharedInfo->MemoryMap.MusicProtectionFieldOfst.byFieldSize;
7331
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7333
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7336
if ( ulResult != cOCT6100_ERR_OK )
7339
/* Clear previous value set in the feature field.*/
7340
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7342
ulTempData &= (~ulMask);
7343
if ( f_pVqeConfig->fEnableMusicProtection == TRUE )
7344
ulTempData |= ( 1 << ulFeatureBitOffset );
7346
/* Then save the DWORD where the field is located.*/
7347
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7349
ulNlpConfigBaseAddress + ulFeatureBytesOffset,
7352
if ( ulResult != cOCT6100_ERR_OK )
7356
/*==============================================================================*/
7358
return cOCT6100_ERR_OK;
7361
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7363
Function: Oct6100ApiWriteVqeAfMemory
7365
Description: This function configures the AF related VQE features of an
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.
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
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 )
7392
tPOCT6100_API_CHANNEL pChanEntry;
7393
tPOCT6100_SHARED_INFO pSharedInfo;
7394
tOCT6100_WRITE_PARAMS WriteParams;
7397
UINT32 ulAfConfigBaseAddress;
7398
UINT32 ulFeatureBytesOffset;
7399
UINT32 ulFeatureBitOffset;
7400
UINT32 ulFeatureFieldLength;
7404
pSharedInfo = f_pApiInstance->pSharedInfo;
7406
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
7408
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
7410
/* Obtain a pointer to the new buffer's list entry. */
7411
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
7413
/*==============================================================================*/
7414
/* Write the AF CPU configuration of the channel feature by feature.*/
7416
/* Calculate AF CPU configuration base address. */
7417
ulAfConfigBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst;
7419
/* Set initial value to zero.*/
7422
/*==============================================================================*/
7423
/* Program the Maximum echo point within the Main channel memory.*/
7424
if ( pSharedInfo->ImageInfo.fMaxEchoPoint == TRUE )
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 ) ) ) )
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;
7437
/* First read the DWORD where the field is located.*/
7438
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7440
ulAfConfigBaseAddress + ulFeatureBytesOffset,
7443
if ( ulResult != cOCT6100_ERR_OK )
7446
/* Clear previous value set in the feature field.*/
7447
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7449
ulTempData &= (~ulMask);
7451
/* Convert the DB value to octasic's float format.*/
7452
if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_NO_ECHO )
7454
usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lDefaultErlDb );
7458
/* Clear max echo point. No echo cancellation here. */
7462
if ( ulFeatureFieldLength < 16 )
7463
usTempData = (UINT16)( usTempData >> ( 16 - ulFeatureFieldLength ) );
7465
ulTempData |= usTempData << ulFeatureBitOffset;
7467
/* First read the DWORD where the field is located.*/
7468
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7470
ulAfConfigBaseAddress + ulFeatureBytesOffset,
7473
if ( ulResult != cOCT6100_ERR_OK )
7477
/*==============================================================================*/
7480
/*==============================================================================*/
7481
/* Set the non-linear behavior B.*/
7482
if ( pSharedInfo->ImageInfo.fNonLinearityBehaviorB == TRUE )
7484
/* Check if the configuration has been changed. */
7485
if ( ( f_fModifyOnly == FALSE )
7486
|| ( ( f_fModifyOnly == TRUE )
7487
&& ( f_pVqeConfig->ulNonLinearityBehaviorB != pChanEntry->VqeConfig.byNonLinearityBehaviorB ) ) )
7489
ulFeatureBytesOffset = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.usDwordOffset * 4;
7490
ulFeatureBitOffset = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byBitOffset;
7491
ulFeatureFieldLength = pSharedInfo->MemoryMap.NlpConvCapFieldOfst.byFieldSize;
7493
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7495
ulAfConfigBaseAddress + ulFeatureBytesOffset,
7498
if ( ulResult != cOCT6100_ERR_OK )
7501
/* Clear previous value set in the feature field.*/
7502
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7504
ulTempData &= (~ulMask);
7505
ulTempData |= (f_pVqeConfig->ulNonLinearityBehaviorB << ulFeatureBitOffset );
7507
/* Then save the DWORD where the field is located.*/
7508
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7510
ulAfConfigBaseAddress + ulFeatureBytesOffset,
7513
if ( ulResult != cOCT6100_ERR_OK )
7517
/*==============================================================================*/
7520
/*==============================================================================*/
7521
/* Set the listener enhancement feature. */
7522
if ( pSharedInfo->ImageInfo.fListenerEnhancement == TRUE )
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 ) ) ) )
7531
ulFeatureBytesOffset = pSharedInfo->MemoryMap.AdaptiveAleOfst.usDwordOffset * 4;
7532
ulFeatureBitOffset = pSharedInfo->MemoryMap.AdaptiveAleOfst.byBitOffset;
7533
ulFeatureFieldLength = pSharedInfo->MemoryMap.AdaptiveAleOfst.byFieldSize;
7535
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7537
ulAfConfigBaseAddress + ulFeatureBytesOffset,
7540
if ( ulResult != cOCT6100_ERR_OK )
7543
/* Clear previous value set in the feature field.*/
7544
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7546
ulTempData &= (~ulMask);
7548
if ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0 )
7552
ulGainDb = f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb / 3;
7555
if ( ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb % 3 ) != 0x0 )
7558
ulTempData |= ( ulGainDb << ulFeatureBitOffset );
7560
else if ( f_pVqeConfig->fSoutNaturalListenerEnhancement != 0 )
7564
ulGainDb = f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb / 3;
7567
if ( ( f_pVqeConfig->ulSoutNaturalListenerEnhancementGainDb % 3 ) != 0x0 )
7570
ulTempData |= ( ( 0x80 | ulGainDb ) << ulFeatureBitOffset );
7573
/* Now write the DWORD where the field is located containing the new configuration. */
7574
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7576
ulAfConfigBaseAddress + ulFeatureBytesOffset,
7579
if ( ulResult != cOCT6100_ERR_OK )
7583
/*==============================================================================*/
7586
/*==============================================================================*/
7587
/* Set the idle code detection enable. */
7588
if ( ( pSharedInfo->ImageInfo.fIdleCodeDetection == TRUE )
7589
&& ( pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration == TRUE ) )
7591
/* Check if the configuration has been changed. */
7592
if ( ( f_fModifyOnly == FALSE )
7593
|| ( ( f_fModifyOnly == TRUE )
7594
&& ( f_pVqeConfig->fIdleCodeDetection != pChanEntry->VqeConfig.fIdleCodeDetection ) ) )
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;
7601
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7603
ulAfConfigBaseAddress + ulFeatureBytesOffset,
7606
if ( ulResult != cOCT6100_ERR_OK )
7609
/* Clear previous value set in the feature field.*/
7610
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7612
ulTempData &= (~ulMask);
7613
if ( f_pVqeConfig->fIdleCodeDetection == FALSE )
7614
ulTempData |= ( 1 << ulFeatureBitOffset );
7616
/* Then save the DWORD where the field is located.*/
7617
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7619
ulAfConfigBaseAddress + ulFeatureBytesOffset,
7622
if ( ulResult != cOCT6100_ERR_OK )
7626
/*==============================================================================*/
7629
/*==============================================================================*/
7630
/* Set the AFT control field. */
7631
if ( pSharedInfo->ImageInfo.fAftControl == TRUE )
7633
/* Check if the configuration has been changed. */
7634
if ( ( f_fModifyOnly == FALSE )
7635
|| ( ( f_fModifyOnly == TRUE )
7636
&& ( f_pChannelOpen->ulEchoOperationMode != pChanEntry->byEchoOperationMode ) ) )
7638
ulFeatureBytesOffset = pSharedInfo->MemoryMap.AftControlOfst.usDwordOffset * 4;
7639
ulFeatureBitOffset = pSharedInfo->MemoryMap.AftControlOfst.byBitOffset;
7640
ulFeatureFieldLength = pSharedInfo->MemoryMap.AftControlOfst.byFieldSize;
7642
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
7644
ulAfConfigBaseAddress + ulFeatureBytesOffset,
7647
if ( ulResult != cOCT6100_ERR_OK )
7650
/* Clear previous value set in the feature field.*/
7651
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
7653
ulTempData &= (~ulMask);
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 )
7658
ulTempData |= ( 0x1234 << ulFeatureBitOffset );
7660
else if ( f_pChannelOpen->ulEchoOperationMode == cOCT6100_ECHO_OP_MODE_SPEECH_RECOGNITION )
7663
ulTempData |= ( 0x0 << ulFeatureBitOffset );
7666
/* Then save the DWORD where the field is located.*/
7667
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
7669
ulAfConfigBaseAddress + ulFeatureBytesOffset,
7672
if ( ulResult != cOCT6100_ERR_OK )
7676
/*==============================================================================*/
7678
return cOCT6100_ERR_OK;
7684
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7686
Function: Oct6100ApiWriteEchoMemory
7688
Description: This function configure an echo memory entry in internal memory.and
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.
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
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 )
7713
tPOCT6100_SHARED_INFO pSharedInfo;
7714
tOCT6100_WRITE_PARAMS WriteParams;
7717
UINT32 ulBaseAddress;
7719
UINT32 ulRoutPcmLaw;
7721
UINT32 ulSoutPcmLaw;
7723
pSharedInfo = f_pApiInstance->pSharedInfo;
7725
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
7727
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
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 )
7732
ulRinPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;
7733
ulRoutPcmLaw = f_pChannelOpen->TdmConfig.ulRoutPcmLaw;
7734
ulSinPcmLaw = f_pChannelOpen->TdmConfig.ulSinPcmLaw;
7735
ulSoutPcmLaw = f_pChannelOpen->TdmConfig.ulSinPcmLaw;
7737
else /* f_pChannelOpen->CodecConfig.ulDecoderPort == cOCT6100_CHANNEL_PORT_SIN */
7739
ulRinPcmLaw = f_pChannelOpen->TdmConfig.ulRinPcmLaw;
7740
ulRoutPcmLaw = f_pChannelOpen->TdmConfig.ulRinPcmLaw;
7741
ulSinPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;
7742
ulSoutPcmLaw = f_pChannelOpen->TdmConfig.ulSoutPcmLaw;
7745
/*==============================================================================*/
7746
/* Configure the Global Static Configuration of the channel.*/
7748
ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET;
7750
/* Set the PGSP context base address. */
7751
ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET;
7753
WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET;
7754
WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
7756
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7757
if ( ulResult != cOCT6100_ERR_OK )
7760
WriteParams.ulWriteAddress += 2;
7761
WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
7763
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7764
if ( ulResult != cOCT6100_ERR_OK )
7767
/* Set the PGSP init context base address. */
7768
ulTempData = ( cOCT6100_IMAGE_FILE_BASE + 0x200 ) & 0x07FFFFFF;
7770
WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET;
7771
WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
7773
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7774
if ( ulResult != cOCT6100_ERR_OK )
7777
WriteParams.ulWriteAddress += 2;
7778
WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
7780
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7781
if ( ulResult != cOCT6100_ERR_OK )
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 );
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;
7793
WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET;
7794
WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
7796
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7797
if ( ulResult != cOCT6100_ERR_OK )
7800
WriteParams.ulWriteAddress += 2;
7801
WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
7803
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7804
if ( ulResult != cOCT6100_ERR_OK )
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 );
7811
WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET;
7812
WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
7814
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7815
if ( ulResult != cOCT6100_ERR_OK )
7818
WriteParams.ulWriteAddress += 2;
7819
WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
7821
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7822
if ( ulResult != cOCT6100_ERR_OK )
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 );
7829
WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET;
7830
WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
7832
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7833
if ( ulResult != cOCT6100_ERR_OK )
7836
WriteParams.ulWriteAddress += 2;
7837
WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
7839
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7840
if ( ulResult != cOCT6100_ERR_OK )
7843
/*==============================================================================*/
7846
/*==============================================================================*/
7847
/* ECHO SSPX Memory configuration.*/
7849
WriteParams.ulWriteAddress = cOCT6100_ECHO_CONTROL_MEM_BASE + ( f_usEchoIndex * cOCT6100_ECHO_CONTROL_MEM_ENTRY_SIZE );
7851
/* ECHO memory BASE + 2 */
7852
WriteParams.ulWriteAddress += 2;
7853
WriteParams.usWriteData = 0x0000;
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 ) )
7859
WriteParams.usWriteData |= cOCT6100_ECHO_OP_MODE_NORMAL << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL;
7861
else if ( f_pChannelOpen->ulEchoOperationMode != cOCT6100_ECHO_OP_MODE_EXTERNAL )
7863
WriteParams.usWriteData |= f_pChannelOpen->ulEchoOperationMode << cOCT6100_ECHO_CONTROL_MEM_AF_CONTROL;
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;
7870
/* Set the TSI chariot memory field.*/
7871
WriteParams.usWriteData |= f_usSinSoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK;
7873
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7874
if ( ulResult != cOCT6100_ERR_OK )
7877
/* ECHO memory BASE */
7878
WriteParams.ulWriteAddress -= 2;
7879
WriteParams.usWriteData = cOCT6100_ECHO_CONTROL_MEM_ACTIVATE_ENTRY;
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;
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;
7889
/* Set the TSI chariot memory field.*/
7890
WriteParams.usWriteData |= f_usRinRoutTsiIndex & cOCT6100_ECHO_CONTROL_MEM_TSI_MEM_MASK;
7892
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
7893
if ( ulResult != cOCT6100_ERR_OK )
7896
/*==============================================================================*/
7898
return cOCT6100_ERR_OK;
7902
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
7904
Function: Oct6100ApiUpdateOpenStruct
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.
7912
-------------------------------------------------------------------------------
7913
| Argument | Description
7914
-------------------------------------------------------------------------------
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.
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 )
7929
/* Check the generic Echo parameters.*/
7930
if ( f_pChanModify->ulEchoOperationMode == cOCT6100_KEEP_PREVIOUS_SETTING )
7931
f_pChanOpen->ulEchoOperationMode = f_pChanEntry->byEchoOperationMode;
7933
f_pChanOpen->ulEchoOperationMode = f_pChanModify->ulEchoOperationMode;
7936
if ( f_pChanModify->fEnableToneDisabler == cOCT6100_KEEP_PREVIOUS_SETTING )
7937
f_pChanOpen->fEnableToneDisabler = f_pChanEntry->fEnableToneDisabler;
7939
f_pChanOpen->fEnableToneDisabler = f_pChanModify->fEnableToneDisabler;
7942
if ( f_pChanModify->ulUserChanId == cOCT6100_KEEP_PREVIOUS_SETTING )
7943
f_pChanOpen->ulUserChanId = f_pChanEntry->ulUserChanId;
7945
f_pChanOpen->ulUserChanId = f_pChanModify->ulUserChanId;
7949
/*======================================================================*/
7950
/* Now update the TDM config.*/
7952
if ( f_pChanModify->TdmConfig.ulRinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
7953
f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanEntry->TdmConfig.byRinPcmLaw;
7955
f_pChanOpen->TdmConfig.ulRinPcmLaw = f_pChanModify->TdmConfig.ulRinPcmLaw;
7958
if ( f_pChanModify->TdmConfig.ulSinPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
7959
f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanEntry->TdmConfig.bySinPcmLaw;
7961
f_pChanOpen->TdmConfig.ulSinPcmLaw = f_pChanModify->TdmConfig.ulSinPcmLaw;
7964
if ( f_pChanModify->TdmConfig.ulRoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
7965
f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanEntry->TdmConfig.byRoutPcmLaw;
7967
f_pChanOpen->TdmConfig.ulRoutPcmLaw = f_pChanModify->TdmConfig.ulRoutPcmLaw;
7970
if ( f_pChanModify->TdmConfig.ulSoutPcmLaw == cOCT6100_KEEP_PREVIOUS_SETTING )
7971
f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanEntry->TdmConfig.bySoutPcmLaw;
7973
f_pChanOpen->TdmConfig.ulSoutPcmLaw = f_pChanModify->TdmConfig.ulSoutPcmLaw;
7977
if ( f_pChanModify->TdmConfig.ulRinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
7978
f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanEntry->TdmConfig.usRinTimeslot;
7980
f_pChanOpen->TdmConfig.ulRinTimeslot = f_pChanModify->TdmConfig.ulRinTimeslot;
7983
if ( f_pChanModify->TdmConfig.ulRinStream == cOCT6100_KEEP_PREVIOUS_SETTING )
7984
f_pChanOpen->TdmConfig.ulRinStream = f_pChanEntry->TdmConfig.usRinStream;
7986
f_pChanOpen->TdmConfig.ulRinStream = f_pChanModify->TdmConfig.ulRinStream;
7989
if ( f_pChanModify->TdmConfig.ulRinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
7990
f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanEntry->TdmConfig.byRinNumTssts;
7992
f_pChanOpen->TdmConfig.ulRinNumTssts = f_pChanModify->TdmConfig.ulRinNumTssts;
7996
if ( f_pChanModify->TdmConfig.ulSinTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
7997
f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanEntry->TdmConfig.usSinTimeslot;
7999
f_pChanOpen->TdmConfig.ulSinTimeslot = f_pChanModify->TdmConfig.ulSinTimeslot;
8002
if ( f_pChanModify->TdmConfig.ulSinStream == cOCT6100_KEEP_PREVIOUS_SETTING )
8003
f_pChanOpen->TdmConfig.ulSinStream = f_pChanEntry->TdmConfig.usSinStream;
8005
f_pChanOpen->TdmConfig.ulSinStream = f_pChanModify->TdmConfig.ulSinStream;
8008
if ( f_pChanModify->TdmConfig.ulSinNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
8009
f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanEntry->TdmConfig.bySinNumTssts;
8011
f_pChanOpen->TdmConfig.ulSinNumTssts = f_pChanModify->TdmConfig.ulSinNumTssts;
8015
if ( f_pChanModify->TdmConfig.ulRoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
8016
f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanEntry->TdmConfig.usRoutTimeslot;
8018
f_pChanOpen->TdmConfig.ulRoutTimeslot = f_pChanModify->TdmConfig.ulRoutTimeslot;
8021
if ( f_pChanModify->TdmConfig.ulRoutStream == cOCT6100_KEEP_PREVIOUS_SETTING )
8022
f_pChanOpen->TdmConfig.ulRoutStream = f_pChanEntry->TdmConfig.usRoutStream;
8024
f_pChanOpen->TdmConfig.ulRoutStream = f_pChanModify->TdmConfig.ulRoutStream;
8026
/* Rout Num TSSTs */
8027
if ( f_pChanModify->TdmConfig.ulRoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
8028
f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanEntry->TdmConfig.byRoutNumTssts;
8030
f_pChanOpen->TdmConfig.ulRoutNumTssts = f_pChanModify->TdmConfig.ulRoutNumTssts;
8034
if ( f_pChanModify->TdmConfig.ulSoutTimeslot == cOCT6100_KEEP_PREVIOUS_SETTING )
8035
f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanEntry->TdmConfig.usSoutTimeslot;
8037
f_pChanOpen->TdmConfig.ulSoutTimeslot = f_pChanModify->TdmConfig.ulSoutTimeslot;
8040
if ( f_pChanModify->TdmConfig.ulSoutStream == cOCT6100_KEEP_PREVIOUS_SETTING )
8041
f_pChanOpen->TdmConfig.ulSoutStream = f_pChanEntry->TdmConfig.usSoutStream;
8043
f_pChanOpen->TdmConfig.ulSoutStream = f_pChanModify->TdmConfig.ulSoutStream;
8045
/* Sout Num TSSTs */
8046
if ( f_pChanModify->TdmConfig.ulSoutNumTssts == cOCT6100_KEEP_PREVIOUS_SETTING )
8047
f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanEntry->TdmConfig.bySoutNumTssts;
8049
f_pChanOpen->TdmConfig.ulSoutNumTssts = f_pChanModify->TdmConfig.ulSoutNumTssts;
8051
/*======================================================================*/
8053
/*======================================================================*/
8054
/* Now update the VQE config.*/
8056
if ( f_pChanModify->VqeConfig.ulComfortNoiseMode == cOCT6100_KEEP_PREVIOUS_SETTING )
8057
f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanEntry->VqeConfig.byComfortNoiseMode;
8059
f_pChanOpen->VqeConfig.ulComfortNoiseMode = f_pChanModify->VqeConfig.ulComfortNoiseMode;
8061
if ( f_pChanModify->VqeConfig.fEnableNlp == cOCT6100_KEEP_PREVIOUS_SETTING )
8062
f_pChanOpen->VqeConfig.fEnableNlp = f_pChanEntry->VqeConfig.fEnableNlp;
8064
f_pChanOpen->VqeConfig.fEnableNlp = f_pChanModify->VqeConfig.fEnableNlp;
8066
if ( f_pChanModify->VqeConfig.fEnableTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING )
8067
f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanEntry->VqeConfig.fEnableTailDisplacement;
8069
f_pChanOpen->VqeConfig.fEnableTailDisplacement = f_pChanModify->VqeConfig.fEnableTailDisplacement;
8071
if ( f_pChanModify->VqeConfig.ulTailDisplacement == cOCT6100_KEEP_PREVIOUS_SETTING )
8072
f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanEntry->VqeConfig.usTailDisplacement;
8074
f_pChanOpen->VqeConfig.ulTailDisplacement = f_pChanModify->VqeConfig.ulTailDisplacement;
8076
/* Tail length cannot be modifed. */
8077
f_pChanOpen->VqeConfig.ulTailLength = f_pChanEntry->VqeConfig.usTailLength;
8081
if ( f_pChanModify->VqeConfig.fRinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
8082
f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanEntry->VqeConfig.fRinDcOffsetRemoval;
8084
f_pChanOpen->VqeConfig.fRinDcOffsetRemoval = f_pChanModify->VqeConfig.fRinDcOffsetRemoval;
8087
if ( f_pChanModify->VqeConfig.fRinLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
8088
f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanEntry->VqeConfig.fRinLevelControl;
8090
f_pChanOpen->VqeConfig.fRinLevelControl = f_pChanModify->VqeConfig.fRinLevelControl;
8093
if ( f_pChanModify->VqeConfig.fRinAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
8094
f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanEntry->VqeConfig.fRinAutomaticLevelControl;
8096
f_pChanOpen->VqeConfig.fRinAutomaticLevelControl = f_pChanModify->VqeConfig.fRinAutomaticLevelControl;
8099
if ( f_pChanModify->VqeConfig.fRinHighLevelCompensation == cOCT6100_KEEP_PREVIOUS_SETTING )
8100
f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanEntry->VqeConfig.fRinHighLevelCompensation;
8102
f_pChanOpen->VqeConfig.fRinHighLevelCompensation = f_pChanModify->VqeConfig.fRinHighLevelCompensation;
8105
if ( f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb == cOCT6100_KEEP_PREVIOUS_SETTING )
8106
f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanEntry->VqeConfig.chRinHighLevelCompensationThresholdDb;
8108
f_pChanOpen->VqeConfig.lRinHighLevelCompensationThresholdDb = f_pChanModify->VqeConfig.lRinHighLevelCompensationThresholdDb;
8111
if ( f_pChanModify->VqeConfig.fSinDcOffsetRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
8112
f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanEntry->VqeConfig.fSinDcOffsetRemoval;
8114
f_pChanOpen->VqeConfig.fSinDcOffsetRemoval = f_pChanModify->VqeConfig.fSinDcOffsetRemoval;
8117
if ( f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
8118
f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanEntry->VqeConfig.fSoutAdaptiveNoiseReduction;
8120
f_pChanOpen->VqeConfig.fSoutAdaptiveNoiseReduction = f_pChanModify->VqeConfig.fSoutAdaptiveNoiseReduction;
8123
if ( f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
8124
f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanEntry->VqeConfig.fSoutConferencingNoiseReduction;
8126
f_pChanOpen->VqeConfig.fSoutConferencingNoiseReduction = f_pChanModify->VqeConfig.fSoutConferencingNoiseReduction;
8129
if ( f_pChanModify->VqeConfig.fSoutNoiseBleaching == cOCT6100_KEEP_PREVIOUS_SETTING )
8130
f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanEntry->VqeConfig.fSoutNoiseBleaching;
8132
f_pChanOpen->VqeConfig.fSoutNoiseBleaching = f_pChanModify->VqeConfig.fSoutNoiseBleaching;
8135
if ( f_pChanModify->VqeConfig.fSoutLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
8136
f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanEntry->VqeConfig.fSoutLevelControl;
8138
f_pChanOpen->VqeConfig.fSoutLevelControl = f_pChanModify->VqeConfig.fSoutLevelControl;
8141
if ( f_pChanModify->VqeConfig.fSoutAutomaticLevelControl == cOCT6100_KEEP_PREVIOUS_SETTING )
8142
f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanEntry->VqeConfig.fSoutAutomaticLevelControl;
8144
f_pChanOpen->VqeConfig.fSoutAutomaticLevelControl = f_pChanModify->VqeConfig.fSoutAutomaticLevelControl;
8147
if ( f_pChanModify->VqeConfig.lRinLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8148
f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanEntry->VqeConfig.chRinLevelControlGainDb;
8150
f_pChanOpen->VqeConfig.lRinLevelControlGainDb = f_pChanModify->VqeConfig.lRinLevelControlGainDb;
8153
if ( f_pChanModify->VqeConfig.lSoutLevelControlGainDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8154
f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanEntry->VqeConfig.chSoutLevelControlGainDb;
8156
f_pChanOpen->VqeConfig.lSoutLevelControlGainDb = f_pChanModify->VqeConfig.lSoutLevelControlGainDb;
8159
if ( f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8160
f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chRinAutomaticLevelControlTargetDb;
8162
f_pChanOpen->VqeConfig.lRinAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lRinAutomaticLevelControlTargetDb;
8165
if ( f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8166
f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanEntry->VqeConfig.chSoutAutomaticLevelControlTargetDb;
8168
f_pChanOpen->VqeConfig.lSoutAutomaticLevelControlTargetDb = f_pChanModify->VqeConfig.lSoutAutomaticLevelControlTargetDb;
8171
if ( f_pChanModify->VqeConfig.lDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8172
f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanEntry->VqeConfig.chDefaultErlDb;
8174
f_pChanOpen->VqeConfig.lDefaultErlDb = f_pChanModify->VqeConfig.lDefaultErlDb;
8177
if ( f_pChanModify->VqeConfig.lAecDefaultErlDb == ( (INT32)cOCT6100_KEEP_PREVIOUS_SETTING ) )
8178
f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanEntry->VqeConfig.chAecDefaultErlDb;
8180
f_pChanOpen->VqeConfig.lAecDefaultErlDb = f_pChanModify->VqeConfig.lAecDefaultErlDb;
8183
if ( f_pChanModify->VqeConfig.ulAecTailLength == cOCT6100_KEEP_PREVIOUS_SETTING )
8184
f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanEntry->VqeConfig.usAecTailLength;
8186
f_pChanOpen->VqeConfig.ulAecTailLength = f_pChanModify->VqeConfig.ulAecTailLength;
8189
if ( f_pChanModify->VqeConfig.fAcousticEcho == cOCT6100_KEEP_PREVIOUS_SETTING )
8190
f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanEntry->VqeConfig.fAcousticEcho;
8192
f_pChanOpen->VqeConfig.fAcousticEcho = f_pChanModify->VqeConfig.fAcousticEcho;
8195
if ( f_pChanModify->VqeConfig.fDtmfToneRemoval == cOCT6100_KEEP_PREVIOUS_SETTING )
8196
f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanEntry->VqeConfig.fDtmfToneRemoval;
8198
f_pChanOpen->VqeConfig.fDtmfToneRemoval = f_pChanModify->VqeConfig.fDtmfToneRemoval;
8204
if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorA == cOCT6100_KEEP_PREVIOUS_SETTING )
8205
f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanEntry->VqeConfig.byNonLinearityBehaviorA;
8207
f_pChanOpen->VqeConfig.ulNonLinearityBehaviorA = f_pChanModify->VqeConfig.ulNonLinearityBehaviorA;
8210
if ( f_pChanModify->VqeConfig.ulNonLinearityBehaviorB == cOCT6100_KEEP_PREVIOUS_SETTING )
8211
f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanEntry->VqeConfig.byNonLinearityBehaviorB;
8213
f_pChanOpen->VqeConfig.ulNonLinearityBehaviorB = f_pChanModify->VqeConfig.ulNonLinearityBehaviorB;
8216
if ( f_pChanModify->VqeConfig.ulDoubleTalkBehavior == cOCT6100_KEEP_PREVIOUS_SETTING )
8217
f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanEntry->VqeConfig.byDoubleTalkBehavior;
8219
f_pChanOpen->VqeConfig.ulDoubleTalkBehavior = f_pChanModify->VqeConfig.ulDoubleTalkBehavior;
8222
if ( f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
8223
f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutAutomaticListenerEnhancementGainDb;
8225
f_pChanOpen->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutAutomaticListenerEnhancementGainDb;
8228
if ( f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb == cOCT6100_KEEP_PREVIOUS_SETTING )
8229
f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanEntry->VqeConfig.bySoutNaturalListenerEnhancementGainDb;
8231
f_pChanOpen->VqeConfig.ulSoutNaturalListenerEnhancementGainDb = f_pChanModify->VqeConfig.ulSoutNaturalListenerEnhancementGainDb;
8234
if ( f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement == cOCT6100_KEEP_PREVIOUS_SETTING )
8235
f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanEntry->VqeConfig.fSoutNaturalListenerEnhancement;
8237
f_pChanOpen->VqeConfig.fSoutNaturalListenerEnhancement = f_pChanModify->VqeConfig.fSoutNaturalListenerEnhancement;
8240
if ( f_pChanModify->VqeConfig.fRoutNoiseReduction == cOCT6100_KEEP_PREVIOUS_SETTING )
8241
f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanEntry->VqeConfig.fRoutNoiseReduction;
8243
f_pChanOpen->VqeConfig.fRoutNoiseReduction = f_pChanModify->VqeConfig.fRoutNoiseReduction;
8246
if ( f_pChanModify->VqeConfig.lAnrSnrEnhancementDb == cOCT6100_KEEP_PREVIOUS_SETTING )
8247
f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanEntry->VqeConfig.chAnrSnrEnhancementDb;
8249
f_pChanOpen->VqeConfig.lAnrSnrEnhancementDb = f_pChanModify->VqeConfig.lAnrSnrEnhancementDb;
8252
if ( f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation == cOCT6100_KEEP_PREVIOUS_SETTING )
8253
f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanEntry->VqeConfig.byAnrVoiceNoiseSegregation;
8255
f_pChanOpen->VqeConfig.ulAnrVoiceNoiseSegregation = f_pChanModify->VqeConfig.ulAnrVoiceNoiseSegregation;
8258
if ( f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay == cOCT6100_KEEP_PREVIOUS_SETTING )
8259
f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanEntry->VqeConfig.usToneDisablerVqeActivationDelay;
8261
f_pChanOpen->VqeConfig.ulToneDisablerVqeActivationDelay = f_pChanModify->VqeConfig.ulToneDisablerVqeActivationDelay;
8264
if ( f_pChanModify->VqeConfig.fEnableMusicProtection == cOCT6100_KEEP_PREVIOUS_SETTING )
8265
f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanEntry->VqeConfig.fEnableMusicProtection;
8267
f_pChanOpen->VqeConfig.fEnableMusicProtection = f_pChanModify->VqeConfig.fEnableMusicProtection;
8270
if ( f_pChanModify->VqeConfig.fIdleCodeDetection == cOCT6100_KEEP_PREVIOUS_SETTING )
8271
f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanEntry->VqeConfig.fIdleCodeDetection;
8273
f_pChanOpen->VqeConfig.fIdleCodeDetection = f_pChanModify->VqeConfig.fIdleCodeDetection;
8275
/*======================================================================*/
8278
/*======================================================================*/
8279
/* Finaly the codec config.*/
8281
if ( f_pChanModify->CodecConfig.ulDecoderPort == cOCT6100_KEEP_PREVIOUS_SETTING )
8282
f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanEntry->CodecConfig.byDecoderPort;
8284
f_pChanOpen->CodecConfig.ulDecoderPort = f_pChanModify->CodecConfig.ulDecoderPort;
8287
if ( f_pChanModify->CodecConfig.ulDecodingRate == cOCT6100_KEEP_PREVIOUS_SETTING )
8288
f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanEntry->CodecConfig.byDecodingRate;
8290
f_pChanOpen->CodecConfig.ulDecodingRate = f_pChanModify->CodecConfig.ulDecodingRate;
8293
if ( f_pChanModify->CodecConfig.ulEncoderPort == cOCT6100_KEEP_PREVIOUS_SETTING )
8294
f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanEntry->CodecConfig.byEncoderPort;
8296
f_pChanOpen->CodecConfig.ulEncoderPort = f_pChanModify->CodecConfig.ulEncoderPort;
8299
if ( f_pChanModify->CodecConfig.ulEncodingRate == cOCT6100_KEEP_PREVIOUS_SETTING )
8300
f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanEntry->CodecConfig.byEncodingRate;
8302
f_pChanOpen->CodecConfig.ulEncodingRate = f_pChanModify->CodecConfig.ulEncodingRate;
8304
if ( f_pChanModify->CodecConfig.fEnableSilenceSuppression == cOCT6100_KEEP_PREVIOUS_SETTING )
8305
f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanEntry->CodecConfig.fEnableSilenceSuppression;
8307
f_pChanOpen->CodecConfig.fEnableSilenceSuppression = f_pChanModify->CodecConfig.fEnableSilenceSuppression;
8309
if ( f_pChanModify->CodecConfig.ulPhasingType == cOCT6100_KEEP_PREVIOUS_SETTING )
8310
f_pChanOpen->CodecConfig.ulPhasingType = f_pChanEntry->CodecConfig.byPhasingType;
8312
f_pChanOpen->CodecConfig.ulPhasingType = f_pChanModify->CodecConfig.ulPhasingType;
8314
if ( f_pChanModify->CodecConfig.ulPhase == cOCT6100_KEEP_PREVIOUS_SETTING )
8315
f_pChanOpen->CodecConfig.ulPhase = f_pChanEntry->CodecConfig.byPhase;
8317
f_pChanOpen->CodecConfig.ulPhase = f_pChanModify->CodecConfig.ulPhase;
8319
if ( f_pChanModify->CodecConfig.ulPhasingTsstHndl == cOCT6100_KEEP_PREVIOUS_SETTING )
8321
if ( f_pChanEntry->usPhasingTsstIndex != cOCT6100_INVALID_INDEX )
8323
tPOCT6100_API_PHASING_TSST pPhasingEntry;
8325
mOCT6100_GET_PHASING_TSST_ENTRY_PNT( f_pApiInstance->pSharedInfo, pPhasingEntry, f_pChanEntry->usPhasingTsstIndex );
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;
8332
f_pChanOpen->CodecConfig.ulPhasingTsstHndl = cOCT6100_INVALID_HANDLE;
8337
f_pChanOpen->CodecConfig.ulPhasingTsstHndl = f_pChanModify->CodecConfig.ulPhasingTsstHndl;
8340
f_pChanOpen->CodecConfig.ulAdpcmNibblePosition = f_pChanEntry->CodecConfig.byAdpcmNibblePosition;
8341
/*======================================================================*/
8343
return cOCT6100_ERR_OK;
8346
static UINT16 Oct6100ApiDbAmpHalfToOctFloat(INT32 x)
8362
db_div6 = x_unsigned / 6;
8363
db_mod6 = x_unsigned % 6;
8369
/* Change nothing! */
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;
8382
rval = (UINT16)(0x4100 + db_div6 * 0x100);
8388
else if(db_mod6 == 1)
8392
else if(db_mod6 == 2)
8396
else if(db_mod6 == 3)
8400
else if(db_mod6 == 4)
8404
else /* if(db_mod6 == 5) */
8412
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8414
Function: Oct6100ApiWriteDebugChanMemory
8416
Description: This function configure a debug channel echo memory entry
8417
in internal memory.and external memory.
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.
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.
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 )
8444
tPOCT6100_SHARED_INFO pSharedInfo;
8447
/* Obtain pointer to local portion of the instance. */
8448
pSharedInfo = f_pApiInstance->pSharedInfo;
8450
/*==============================================================================*/
8451
/* Write the VQE configuration of the debug channel. */
8453
ulResult = Oct6100ApiWriteVqeMemory(
8461
if ( ulResult != cOCT6100_ERR_OK )
8464
/*==============================================================================*/
8467
/*==============================================================================*/
8469
/* Write the echo memory configuration of the debug channel. */
8470
ulResult = Oct6100ApiWriteEchoMemory(
8475
f_usRinRoutTsiIndex,
8476
f_usSinSoutTsiIndex );
8477
if ( ulResult != cOCT6100_ERR_OK )
8480
/*==============================================================================*/
8482
return cOCT6100_ERR_OK;
8486
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8488
Function: Oct6100ApiDebugChannelOpen
8490
Description: Internal function used to open a debug channel.
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.
8498
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
8499
static UINT32 Oct6100ApiDebugChannelOpen(
8500
IN tPOCT6100_INSTANCE_API f_pApiInstance )
8502
tPOCT6100_SHARED_INFO pSharedInfo;
8503
tOCT6100_CHANNEL_OPEN TempChanOpen;
8507
UINT16 usDummyEchoIndex;
8509
pSharedInfo = f_pApiInstance->pSharedInfo;
8511
/* Let's program the channel memory.*/
8512
Oct6100ChannelOpenDef( &TempChanOpen );
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;
8521
/* Loop to reserve the proper entry for the debug channel */
8522
for( usChanIndex = 0; usChanIndex < ( pSharedInfo->DebugInfo.usRecordChanIndex + 1 ); usChanIndex ++ )
8524
ulResult = Oct6100ApiReserveEchoEntry( f_pApiInstance, &usDummyEchoIndex );
8525
if( ulResult != cOCT6100_ERR_OK )
8529
/* Loop to free all entries except the one for the debug channel */
8530
for( usChanIndex = pSharedInfo->DebugInfo.usRecordChanIndex; usChanIndex > 0; )
8533
ulResult = Oct6100ApiReleaseEchoEntry( f_pApiInstance, usChanIndex );
8534
if( ulResult != cOCT6100_ERR_OK )
8538
ulResult = Oct6100ApiWriteDebugChanMemory( f_pApiInstance,
8539
&TempChanOpen.TdmConfig,
8540
&TempChanOpen.VqeConfig,
8542
pSharedInfo->DebugInfo.usRecordChanIndex,
8543
pSharedInfo->DebugInfo.usRecordMemIndex,
8544
pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex,
8545
pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex );
8546
if ( ulResult != cOCT6100_ERR_OK )
8549
return cOCT6100_ERR_OK;
8553
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8555
Function: Oct6100ApiMuteChannelPort
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.
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.
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 )
8574
tPOCT6100_SHARED_INFO pSharedInfo;
8575
tPOCT6100_API_CHANNEL pChanEntry;
8576
tOCT6100_WRITE_PARAMS WriteParams;
8579
pSharedInfo = f_pApiInstance->pSharedInfo;
8581
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
8583
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
8585
/* Obtain a pointer to the new buffer's list entry. */
8586
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usEchoIndex );
8588
/* Mute the Rin port. */
8589
if ( ( f_fCheckBridgeIndex == FALSE )
8590
|| ( ( f_fCheckBridgeIndex == TRUE ) && ( pChanEntry->usBridgeIndex == cOCT6100_INVALID_INDEX ) ) )
8592
/* If the channel is in bidir mode, do not create the Rin silence event!!! */
8593
if ( pChanEntry->fBiDirChannel == FALSE )
8595
if ( ( ( f_usRinTsstIndex == cOCT6100_INVALID_INDEX ) || ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) )
8596
&& ( pChanEntry->usRinSilenceEventIndex == cOCT6100_INVALID_INDEX ) )
8598
ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance,
8599
&pChanEntry->usRinSilenceEventIndex );
8600
if ( ulResult != cOCT6100_ERR_OK )
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. */
8606
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usRinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
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;
8612
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8613
if ( ulResult != cOCT6100_ERR_OK )
8616
WriteParams.ulWriteAddress += 2;
8617
WriteParams.usWriteData = pChanEntry->usRinRoutTsiMemIndex;
8619
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8620
if ( ulResult != cOCT6100_ERR_OK )
8623
/*=======================================================================*/
8626
/*=======================================================================*/
8627
/* Now insert the Sin copy event into the list.*/
8629
ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
8630
pChanEntry->usRinSilenceEventIndex,
8631
cOCT6100_EVENT_TYPE_SOUT_COPY,
8633
if ( ulResult != cOCT6100_ERR_OK )
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 ) )
8643
ulResult = Oct6100ApiReserveMixerEventEntry( f_pApiInstance,
8644
&pChanEntry->usSinSilenceEventIndex );
8645
if ( ulResult != cOCT6100_ERR_OK )
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. */
8651
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
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;
8657
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8658
if ( ulResult != cOCT6100_ERR_OK )
8661
WriteParams.ulWriteAddress += 2;
8662
WriteParams.usWriteData = pChanEntry->usSinSoutTsiMemIndex;
8664
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
8665
if ( ulResult != cOCT6100_ERR_OK )
8668
/*=======================================================================*/
8671
/*=======================================================================*/
8672
/* Now insert the Sin copy event into the list.*/
8674
ulResult = Oct6100ApiMixerEventAdd( f_pApiInstance,
8675
pChanEntry->usSinSilenceEventIndex,
8676
cOCT6100_EVENT_TYPE_SOUT_COPY,
8678
if ( ulResult != cOCT6100_ERR_OK )
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 ) )
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 )
8693
ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usRinSilenceEventIndex );
8694
if ( ulResult != cOCT6100_ERR_OK )
8695
return cOCT6100_ERR_FATAL_E1;
8697
pChanEntry->usRinSilenceEventIndex = cOCT6100_INVALID_INDEX;
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 ) )
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 )
8711
ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pChanEntry->usSinSilenceEventIndex );
8712
if ( ulResult != cOCT6100_ERR_OK )
8713
return cOCT6100_ERR_FATAL_E2;
8715
pChanEntry->usSinSilenceEventIndex = cOCT6100_INVALID_INDEX;
8718
return cOCT6100_ERR_OK;
8721
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
8723
Function: Oct6100ApiSetChannelLevelControl
8725
Description: This function will configure the level control on a given
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.
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
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 )
8748
tPOCT6100_API_CHANNEL pChanEntry;
8749
tPOCT6100_SHARED_INFO pSharedInfo;
8752
UINT32 ulBaseAddress;
8753
UINT32 ulFeatureBytesOffset;
8754
UINT32 ulFeatureBitOffset;
8755
UINT32 ulFeatureFieldLength;
8760
BOOL fDisableAlcFirst;
8762
/* Get local pointer to shared portion of the API instance. */
8763
pSharedInfo = f_pApiInstance->pSharedInfo;
8765
/* Obtain a pointer to the channel list entry. */
8766
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
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 ) )
8784
/* Calculate base address for manual level control configuration. */
8785
ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
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;
8792
/* First read the DWORD where the field is located.*/
8793
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
8795
ulBaseAddress + ulFeatureBytesOffset,
8798
if ( ulResult != cOCT6100_ERR_OK )
8801
/* Clear previous value set in the feature field.*/
8802
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8804
ulTempData &= (~ulMask);
8806
if ( ( f_pVqeConfig->fRinLevelControl == TRUE )
8807
|| ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
8808
|| ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) )
8810
/* Set the level control value.*/
8811
if ( ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
8812
|| ( f_pVqeConfig->fRinHighLevelCompensation == TRUE ) )
8813
ulTempData |= ( 0xFF << ulFeatureBitOffset );
8816
/* Convert the dB value into OctFloat format.*/
8817
usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lRinLevelControlGainDb );
8818
usTempData -= 0x3800;
8819
usTempData &= 0x0FF0;
8822
ulTempData |= ( usTempData << ulFeatureBitOffset );
8825
else /* ( ( f_pVqeConfig->fRinLevelControl == FALSE ) && ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) && ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) ) */
8827
ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
8830
/* Save the DWORD where the field is located.*/
8831
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
8833
ulBaseAddress + ulFeatureBytesOffset,
8836
if ( ulResult != cOCT6100_ERR_OK )
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;
8844
/* First read the DWORD where the field is located.*/
8845
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
8847
ulBaseAddress + ulFeatureBytesOffset,
8850
if ( ulResult != cOCT6100_ERR_OK )
8853
/* Clear previous value set in the feature field.*/
8854
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8856
ulTempData &= (~ulMask);
8858
if ( ( f_pVqeConfig->fSoutLevelControl == TRUE )
8859
|| ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
8860
|| ( f_pVqeConfig->fSoutNaturalListenerEnhancement == TRUE )
8861
|| ( f_pVqeConfig->ulSoutAutomaticListenerEnhancementGainDb != 0x0 ) )
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 );
8870
/* Convert the dB value into OctFloat format.*/
8871
usTempData = Oct6100ApiDbAmpHalfToOctFloat( f_pVqeConfig->lSoutLevelControlGainDb );
8872
usTempData -= 0x3800;
8873
usTempData &= 0x0FF0;
8876
ulTempData |= ( usTempData << ulFeatureBitOffset );
8881
ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
8884
/* Save the DWORD where the field is located.*/
8885
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
8887
ulBaseAddress + ulFeatureBytesOffset,
8890
if ( ulResult != cOCT6100_ERR_OK )
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;
8896
/* Check which one is to be disabled first. */
8897
if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
8898
fDisableAlcFirst = FALSE;
8900
fDisableAlcFirst = TRUE;
8902
for ( i = 0; i < 2; i ++ )
8904
/* Set the auto level control target Db for the Rin port. */
8905
if ( ( ( i == 0 ) && ( fDisableAlcFirst == TRUE ) ) || ( ( i == 1 ) && ( fDisableAlcFirst == FALSE ) ) )
8907
if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE )
8909
ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.usDwordOffset * 4;
8910
ulFeatureBitOffset = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byBitOffset;
8911
ulFeatureFieldLength = pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst.byFieldSize;
8913
/* First read the DWORD where the field is located.*/
8914
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
8916
ulBaseAddress + ulFeatureBytesOffset,
8919
if ( ulResult != cOCT6100_ERR_OK )
8922
/* Clear previous value set in the feature field.*/
8923
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8925
ulTempData &= (~ulMask);
8927
if ( f_pVqeConfig->fRinAutomaticLevelControl == TRUE )
8929
/* Convert the dB value into OctFloat format.*/
8930
usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinAutomaticLevelControlTargetDb );
8932
/* Set auto level control target on the Rin port. */
8933
ulTempData |= ( usTempData << ulFeatureBitOffset );
8935
else /* if ( f_pVqeConfig->fRinAutomaticLevelControl == FALSE ) */
8937
/* Disable auto level control. */
8938
ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
8941
/* Save the DWORD where the field is located.*/
8942
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
8944
ulBaseAddress + ulFeatureBytesOffset,
8947
if ( ulResult != cOCT6100_ERR_OK )
8953
/* Set the high level compensation threshold Db for the Rin port. */
8954
if ( pSharedInfo->ImageInfo.fRinHighLevelCompensation == TRUE )
8956
ulFeatureBytesOffset = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.usDwordOffset * 4;
8957
ulFeatureBitOffset = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byBitOffset;
8958
ulFeatureFieldLength = pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst.byFieldSize;
8960
/* First read the DWORD where the field is located.*/
8961
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
8963
ulBaseAddress + ulFeatureBytesOffset,
8966
if ( ulResult != cOCT6100_ERR_OK )
8969
/* Clear previous value set in the feature field.*/
8970
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
8972
ulTempData &= (~ulMask);
8974
if ( f_pVqeConfig->fRinHighLevelCompensation == TRUE )
8976
/* Convert the dB value into OctFloat format.*/
8977
usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lRinHighLevelCompensationThresholdDb );
8979
/* Set high level compensation threshold on the Rin port. */
8980
ulTempData |= ( usTempData << ulFeatureBitOffset );
8982
else /* if ( f_pVqeConfig->fRinHighLevelCompensation == FALSE ) */
8984
/* Disable high level compensation. */
8985
ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
8988
/* Save the DWORD where the field is located.*/
8989
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
8991
ulBaseAddress + ulFeatureBytesOffset,
8994
if ( ulResult != cOCT6100_ERR_OK )
9000
/* Set the auto level control target Db for the Sout port. */
9001
if ( pSharedInfo->ImageInfo.fRinAutoLevelControl == TRUE )
9003
ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.usDwordOffset * 4;
9004
ulFeatureBitOffset = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byBitOffset;
9005
ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst.byFieldSize;
9007
/* First read the DWORD where the field is located.*/
9008
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
9010
ulBaseAddress + ulFeatureBytesOffset,
9013
if ( ulResult != cOCT6100_ERR_OK )
9016
/* Clear previous value set in the feature field.*/
9017
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9019
ulTempData &= (~ulMask);
9021
if ( f_pVqeConfig->fSoutAutomaticLevelControl == TRUE )
9023
/* Convert the dB value into OctFloat format.*/
9024
usTempData = Oct6100ApiDbAmpHalfToOctFloat( 2 * f_pVqeConfig->lSoutAutomaticLevelControlTargetDb );
9026
/* Set auto level control target on the Sout port. */
9027
ulTempData |= ( usTempData << ulFeatureBitOffset );
9029
else /* if ( f_pVqeConfig->fSoutAutomaticLevelControl == FALSE ) */
9031
/* Disable auto level control. */
9032
ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
9035
/* Save the DWORD where the field is located.*/
9036
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
9038
ulBaseAddress + ulFeatureBytesOffset,
9041
if ( ulResult != cOCT6100_ERR_OK )
9045
/* Set the high level compensation threshold Db for the Sout port. */
9046
if ( pSharedInfo->ImageInfo.fSoutHighLevelCompensation == TRUE )
9048
ulFeatureBytesOffset = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.usDwordOffset * 4;
9049
ulFeatureBitOffset = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byBitOffset;
9050
ulFeatureFieldLength = pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst.byFieldSize;
9052
/* First read the DWORD where the field is located.*/
9053
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
9055
ulBaseAddress + ulFeatureBytesOffset,
9058
if ( ulResult != cOCT6100_ERR_OK )
9061
/* Clear previous value set in the feature field.*/
9062
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9064
ulTempData &= (~ulMask);
9066
/* Disable high level compensation on Sout for now. */
9067
ulTempData |= ( 0xFFFF << ulFeatureBitOffset );
9069
/* Save the DWORD where the field is located.*/
9070
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
9072
ulBaseAddress + ulFeatureBytesOffset,
9075
if ( ulResult != cOCT6100_ERR_OK )
9079
/* Check if have to clear the ALC-HLC status. */
9080
if ( ( pSharedInfo->ImageInfo.fAlcHlcStatus == TRUE )
9081
&& ( f_fClearAlcHlcStatusBit == TRUE ) )
9083
ulFeatureBytesOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.usDwordOffset * 4;
9084
ulFeatureBitOffset = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byBitOffset;
9085
ulFeatureFieldLength = pSharedInfo->MemoryMap.AlcHlcStatusOfst.byFieldSize;
9087
/* First read the DWORD where the field is located.*/
9088
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
9090
ulBaseAddress + ulFeatureBytesOffset,
9093
if ( ulResult != cOCT6100_ERR_OK )
9096
/* Get previous value set in the feature field.*/
9097
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9099
/* Retrieve last status. */
9100
byLastStatus = (UINT8)( ( ( ulTempData & ulMask ) >> ulFeatureBitOffset ) & 0xFF );
9102
/* Increment to reset context. */
9105
/* Just in case, not to overwrite some context in external memory. */
9106
byLastStatus &= ( 0x1 << ulFeatureFieldLength ) - 1;
9108
/* Clear last status. */
9109
ulTempData &= (~ulMask);
9111
/* Set new status. */
9112
ulTempData |= ( byLastStatus << ulFeatureBitOffset );
9114
/* Save the DWORD where the field is located.*/
9115
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
9117
ulBaseAddress + ulFeatureBytesOffset,
9120
if ( ulResult != cOCT6100_ERR_OK )
9125
return cOCT6100_ERR_OK;
9128
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9130
Function: Oct6100ApiSetChannelTailConfiguration
9132
Description: This function will configure the tail displacement and length
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.
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?
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 )
9154
tPOCT6100_API_CHANNEL pChanEntry;
9155
tPOCT6100_SHARED_INFO pSharedInfo;
9158
UINT32 ulNlpConfBaseAddress;
9159
UINT32 ulAfConfBaseAddress;
9160
UINT32 ulFeatureBytesOffset;
9161
UINT32 ulFeatureBitOffset;
9162
UINT32 ulFeatureFieldLength;
9165
BOOL fTailDisplacementModified = FALSE;
9167
/* Get local pointer to shared portion of the API instance. */
9168
pSharedInfo = f_pApiInstance->pSharedInfo;
9170
/* Obtain a pointer to the channel list entry. */
9171
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex );
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;
9177
/* Set the tail displacement.*/
9178
if ( pSharedInfo->ImageInfo.fTailDisplacement == TRUE )
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 ) ) ) )
9187
/* Remember that the tail displacement parameters were changed. */
9188
fTailDisplacementModified = TRUE;
9190
/* Check if we must set the tail displacement value. */
9191
if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
9192
&& ( pSharedInfo->ImageInfo.fPerChannelTailDisplacement == TRUE ) )
9194
ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.usDwordOffset * 4;
9195
ulFeatureBitOffset = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byBitOffset;
9196
ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst.byFieldSize;
9198
/* First read the DWORD where the field is located.*/
9199
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
9201
ulNlpConfBaseAddress + ulFeatureBytesOffset,
9204
if ( ulResult != cOCT6100_ERR_OK )
9207
/* Clear previous value set in the feature field.*/
9208
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9210
ulTempData &= (~ulMask);
9211
if ( ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
9212
&& ( f_pVqeConfig->ulTailDisplacement != 0x0 ) )
9214
if ( pSharedInfo->ImageInfo.fAfTailDisplacement == FALSE )
9216
if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
9218
ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset );
9222
ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset );
9225
else /* if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE ) */
9227
/* If AEC is not activated, this must be set to the requested tail displacement. */
9228
if ( f_pVqeConfig->fAcousticEcho == FALSE )
9230
if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
9232
ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement;
9236
ulTailSum = f_pVqeConfig->ulTailDisplacement;
9239
if ( ulTailSum == 0 )
9241
ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
9243
else if ( ulTailSum <= 128 )
9245
ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
9247
else if ( ulTailSum <= 384 )
9249
ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
9251
else /* if ( ulTailSum <= 896 ) */
9253
ulTempData |= ( ( 7 ) << ulFeatureBitOffset );
9256
else /* if ( f_pVqeConfig->fAcousticEcho == FALSE ) */
9258
/* Otherwise, the tail displacement is configured differently. This field stays to 0. */
9259
ulTempData |= ( 0x0 << ulFeatureBitOffset );
9264
/* Then save the new DWORD where the field is located.*/
9265
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
9267
ulNlpConfBaseAddress + ulFeatureBytesOffset,
9270
if ( ulResult != cOCT6100_ERR_OK )
9274
if ( pSharedInfo->ImageInfo.fAfTailDisplacement == TRUE )
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;
9281
/* First read the DWORD where the field is located.*/
9282
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
9284
ulAfConfBaseAddress + ulFeatureBytesOffset,
9287
if ( ulResult != cOCT6100_ERR_OK )
9290
/* Clear previous value set in the feature field.*/
9291
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9293
ulTempData &= (~ulMask);
9295
if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
9297
ulTempData |= ( ( ( pSharedInfo->ChipConfig.usTailDisplacement / 16 ) ) << ulFeatureBitOffset );
9301
ulTempData |= ( ( ( f_pVqeConfig->ulTailDisplacement / 16 ) ) << ulFeatureBitOffset );
9304
/* Then save the DWORD where the field is located.*/
9305
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
9307
ulAfConfBaseAddress + ulFeatureBytesOffset,
9310
if ( ulResult != cOCT6100_ERR_OK )
9314
ulFeatureBytesOffset = pSharedInfo->MemoryMap.TailDisplEnableOfst.usDwordOffset * 4;
9315
ulFeatureBitOffset = pSharedInfo->MemoryMap.TailDisplEnableOfst.byBitOffset;
9316
ulFeatureFieldLength = pSharedInfo->MemoryMap.TailDisplEnableOfst.byFieldSize;
9318
/* First read the DWORD where the field is located.*/
9319
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
9321
ulNlpConfBaseAddress + ulFeatureBytesOffset,
9324
if ( ulResult != cOCT6100_ERR_OK )
9327
/* Clear previous value set in the feature field.*/
9328
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9330
ulTempData &= (~ulMask);
9331
ulTempData |= ( ( (UINT32)f_pVqeConfig->fEnableTailDisplacement ) << ulFeatureBitOffset );
9333
/* Then save the DWORD where the field is located.*/
9334
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
9336
ulNlpConfBaseAddress + ulFeatureBytesOffset,
9339
if ( ulResult != cOCT6100_ERR_OK )
9344
/* Set the tail length. */
9345
if ( pSharedInfo->ImageInfo.fPerChannelTailLength == TRUE )
9347
/* Check if the configuration has been changed. */
9348
if ( ( f_fModifyOnly == FALSE )
9349
|| ( ( f_fModifyOnly == TRUE )
9350
&& ( f_pVqeConfig->ulTailLength != pChanEntry->VqeConfig.usTailLength ) ) )
9352
ulFeatureBytesOffset = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.usDwordOffset * 4;
9353
ulFeatureBitOffset = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byBitOffset;
9354
ulFeatureFieldLength = pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst.byFieldSize;
9356
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
9358
ulAfConfBaseAddress + ulFeatureBytesOffset,
9361
if ( ulResult != cOCT6100_ERR_OK )
9364
/* Clear previous value set in the feature field.*/
9365
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
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 )
9371
ulTempData |= ( ( ( pSharedInfo->ImageInfo.usMaxTailLength - 32 ) / 4 ) << ulFeatureBitOffset );
9375
ulTempData |= ( ( ( f_pVqeConfig->ulTailLength - 32 ) / 4 ) << ulFeatureBitOffset );
9378
/* Then save the DWORD where the field is located.*/
9379
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
9381
ulAfConfBaseAddress + ulFeatureBytesOffset,
9384
if ( ulResult != cOCT6100_ERR_OK )
9389
/* Configure AEC tail length. */
9390
if ( pSharedInfo->ImageInfo.fAecTailLength == TRUE )
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 ) ) ) )
9399
ulFeatureBytesOffset = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.usDwordOffset * 4;
9400
ulFeatureBitOffset = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byBitOffset;
9401
ulFeatureFieldLength = pSharedInfo->MemoryMap.AecTailLengthFieldOfst.byFieldSize;
9403
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
9405
ulNlpConfBaseAddress + ulFeatureBytesOffset,
9408
if ( ulResult != cOCT6100_ERR_OK )
9411
/* Clear previous value set in the feature field.*/
9412
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9414
ulTempData &= (~ulMask);
9416
/* Set acoustic echo tail length. */
9417
if ( f_pVqeConfig->fAcousticEcho == TRUE )
9419
switch( f_pVqeConfig->ulAecTailLength )
9422
ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
9425
ulTempData |= ( ( 2 ) << ulFeatureBitOffset );
9428
ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
9432
ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
9436
else if ( f_pVqeConfig->fEnableTailDisplacement == TRUE )
9438
/* No acoustic echo case. */
9440
/* Start with requested tail displacement. */
9441
if ( f_pVqeConfig->ulTailDisplacement == cOCT6100_AUTO_SELECT_TAIL )
9443
ulTailSum = pSharedInfo->ChipConfig.usTailDisplacement;
9447
ulTailSum = f_pVqeConfig->ulTailDisplacement;
9450
/* Add requested tail length. */
9451
if ( f_pVqeConfig->ulTailLength == cOCT6100_AUTO_SELECT_TAIL )
9453
ulTailSum += pSharedInfo->ImageInfo.usMaxTailLength;
9457
ulTailSum += f_pVqeConfig->ulTailLength;
9460
/* Round this value up. */
9461
if ( ulTailSum <= 128 )
9463
ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
9465
else if ( ulTailSum <= 256 )
9467
ulTempData |= ( ( 1 ) << ulFeatureBitOffset );
9469
else if ( ulTailSum <= 512 )
9471
ulTempData |= ( ( 2 ) << ulFeatureBitOffset );
9473
else /* if ( ulTailSum <= 1024 ) */
9475
ulTempData |= ( ( 3 ) << ulFeatureBitOffset );
9480
/* Keep this to zero. */
9481
ulTempData |= ( ( 0 ) << ulFeatureBitOffset );
9484
/* Write the new DWORD where the field is located. */
9485
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
9487
ulNlpConfBaseAddress + ulFeatureBytesOffset,
9490
if ( ulResult != cOCT6100_ERR_OK )
9495
return cOCT6100_ERR_OK;
9498
#if 0 /* unused functions */
9499
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9501
Function: Oct6100ChannelMuteSer
9503
Description: This function will mute some of the ports on a given
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.
9512
f_pChannelMute What channel/ports to mute.
9514
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9515
static UINT32 Oct6100ChannelMuteSer(
9516
IN tPOCT6100_INSTANCE_API f_pApiInstance,
9517
IN tPOCT6100_CHANNEL_MUTE f_pChannelMute )
9523
/* Verify that all the parameters given match the state of the API. */
9524
ulResult = Oct6100ApiAssertChannelMuteParams( f_pApiInstance,
9528
if ( ulResult != cOCT6100_ERR_OK )
9531
/* Call the actual channel mute ports function. */
9532
ulResult = Oct6100ApiMuteChannelPorts( f_pApiInstance,
9536
if ( ulResult != cOCT6100_ERR_OK )
9539
return cOCT6100_ERR_OK;
9542
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9544
Function: Oct6100ApiAssertChannelMuteParams
9546
Description: Check the user parameters passed to the channel mute function.
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.
9554
f_pChannelMute What channel/ports to mute.
9555
f_pusChanIndex Resulting channel index where the muting should
9557
f_pusPorts Port mask on which to apply the muting.
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 )
9566
tPOCT6100_SHARED_INFO pSharedInfo;
9567
tPOCT6100_API_CHANNEL pChanEntry;
9568
UINT32 ulEntryOpenCnt;
9570
/* Get local pointer(s). */
9571
pSharedInfo = f_pApiInstance->pSharedInfo;
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;
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;
9581
/*=======================================================================*/
9582
/* Get a pointer to the channel's list entry. */
9584
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex )
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;
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;
9597
/*=======================================================================*/
9599
/* Check the provided port mask. */
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;
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;
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;
9620
/* Return the ports to the calling function. */
9621
*f_pusPorts = (UINT16)( f_pChannelMute->ulPortMask & 0xFFFF );
9623
return cOCT6100_ERR_OK;
9626
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9628
Function: Oct6100ChannelUnMuteSer
9630
Description: This function will unmute some of the ports on a given
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.
9639
f_pChannelUnMute What channel/ports to unmute.
9641
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9642
static UINT32 Oct6100ChannelUnMuteSer(
9643
IN tPOCT6100_INSTANCE_API f_pApiInstance,
9644
IN tPOCT6100_CHANNEL_UNMUTE f_pChannelUnMute )
9650
/* Verify that all the parameters given match the state of the API. */
9651
ulResult = Oct6100ApiAssertChannelUnMuteParams( f_pApiInstance,
9655
if ( ulResult != cOCT6100_ERR_OK )
9658
/* Call the actual channel mute ports function. */
9659
ulResult = Oct6100ApiMuteChannelPorts( f_pApiInstance,
9663
if ( ulResult != cOCT6100_ERR_OK )
9666
return cOCT6100_ERR_OK;
9669
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9671
Function: Oct6100ApiAssertChannelUnMuteParams
9673
Description: Check the user parameters passed to the channel unmute function.
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.
9681
f_pChannelUnMute What channel/ports to Unmute.
9682
f_pusChanIndex Resulting channel index where the muting should
9684
f_pusPorts Port mask on which to apply the muting.
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 )
9693
tPOCT6100_SHARED_INFO pSharedInfo;
9694
tPOCT6100_API_CHANNEL pChanEntry;
9695
UINT32 ulEntryOpenCnt;
9697
/* Get local pointer(s). */
9698
pSharedInfo = f_pApiInstance->pSharedInfo;
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;
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;
9708
/*=======================================================================*/
9709
/* Get a pointer to the channel's list entry. */
9711
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, *f_pusChanIndex )
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;
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;
9724
/*=======================================================================*/
9726
/* Check the provided port mask. */
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;
9737
/* Return the ports to the calling function. */
9738
*f_pusPorts = (UINT16)( f_pChannelUnMute->ulPortMask & 0xFFFF );
9740
return cOCT6100_ERR_OK;
9743
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9745
Function: Oct6100ApiMuteChannelPorts
9747
Description: Mute or Unmute the specified ports, according to the mask.
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.
9755
f_usChanIndex Resulting channel index where the muting should
9757
f_usPortMask Port mask on which to apply the muting/unmuting.
9759
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
9760
static UINT32 Oct6100ApiMuteChannelPorts(
9761
IN tPOCT6100_INSTANCE_API f_pApiInstance,
9762
IN UINT16 f_usChanIndex,
9763
IN UINT16 f_usPortMask,
9766
tPOCT6100_SHARED_INFO pSharedInfo;
9767
tPOCT6100_API_CHANNEL pChanEntry;
9768
tOCT6100_WRITE_PARAMS WriteParams;
9772
UINT32 ulBaseAddress;
9773
UINT32 ulFeatureBytesOffset;
9774
UINT32 ulFeatureBitOffset;
9775
UINT32 ulFeatureFieldLength;
9777
BOOL fDisableSinWithFeatures = FALSE;
9778
BOOL fEnableSinWithFeatures = FALSE;
9780
/* Get local pointer(s). */
9781
pSharedInfo = f_pApiInstance->pSharedInfo;
9783
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
9785
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
9787
/* Get a pointer to the channel's list entry. */
9788
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pChanEntry, f_usChanIndex )
9791
if ( ( f_fMute == TRUE )
9792
&& ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 )
9793
&& ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) == 0x0 ) )
9795
/* Mute this port. */
9796
pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_RIN;
9798
ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
9799
if ( ulResult != cOCT6100_ERR_OK )
9801
pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN;
9805
else if ( ( f_fMute == FALSE )
9806
&& ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 )
9807
&& ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_RIN ) != 0x0 ) )
9809
/* Unmute this port. */
9810
pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_RIN;
9812
ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
9813
if ( ulResult != cOCT6100_ERR_OK )
9818
if ( ( f_fMute == TRUE )
9819
&& ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 )
9820
&& ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) == 0x0 ) )
9822
/* Mute this port. */
9824
if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
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;
9830
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
9831
if ( ulResult != cOCT6100_ERR_OK )
9835
pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_ROUT;
9837
else if ( ( f_fMute == FALSE )
9838
&& ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 )
9839
&& ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_ROUT ) != 0x0 ) )
9841
/* Unmute this port. */
9843
if ( pChanEntry->usRoutTsstIndex != cOCT6100_INVALID_INDEX )
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 )
9854
pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_ROUT;
9858
if ( ( f_fMute == TRUE )
9859
&& ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
9860
&& ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) == 0x0 ) )
9862
/* Mute this port. */
9863
pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN;
9865
ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
9866
if ( ulResult != cOCT6100_ERR_OK )
9868
pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN;
9873
( ( f_fMute == FALSE )
9874
&& ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
9875
&& ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) )
9877
( ( f_fMute == TRUE )
9878
&& ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 )
9879
&& ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 ) ) )
9881
/* Unmute this port. */
9882
pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN;
9884
ulResult = Oct6100ApiMutePorts( f_pApiInstance, f_usChanIndex, pChanEntry->usRinTsstIndex, pChanEntry->usSinTsstIndex, TRUE );
9885
if ( ulResult != cOCT6100_ERR_OK )
9890
if ( ( f_fMute == TRUE )
9891
&& ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 )
9892
&& ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) == 0x0 ) )
9894
/* Mute this port. */
9896
if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
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;
9902
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
9903
if ( ulResult != cOCT6100_ERR_OK )
9907
pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SOUT;
9909
else if ( ( f_fMute == FALSE )
9910
&& ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 )
9911
&& ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SOUT ) != 0x0 ) )
9913
/* Unmute this port. */
9915
if ( pChanEntry->usSoutTsstIndex != cOCT6100_INVALID_INDEX )
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 )
9926
pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SOUT;
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 ) )
9934
/* Mute this port. */
9935
pChanEntry->usMutedPorts |= cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES;
9936
fEnableSinWithFeatures = TRUE;
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 ) )
9943
( ( f_fMute == TRUE )
9944
&& ( ( f_usPortMask & cOCT6100_CHANNEL_MUTE_PORT_SIN ) != 0x0 )
9945
&& ( ( pChanEntry->usMutedPorts & cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES ) != 0x0 ) ) )
9947
/* Unmute this port. */
9948
pChanEntry->usMutedPorts &= ~cOCT6100_CHANNEL_MUTE_PORT_SIN_WITH_FEATURES;
9950
fDisableSinWithFeatures = TRUE;
9953
/* Check if must enable or disable SIN mute with features. */
9954
if ( fDisableSinWithFeatures == TRUE || fEnableSinWithFeatures == TRUE )
9956
ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( pChanEntry->usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
9958
if ( pSharedInfo->ImageInfo.fSinMute == TRUE )
9960
ulFeatureBytesOffset = pSharedInfo->MemoryMap.SinMuteOfst.usDwordOffset * 4;
9961
ulFeatureBitOffset = pSharedInfo->MemoryMap.SinMuteOfst.byBitOffset;
9962
ulFeatureFieldLength = pSharedInfo->MemoryMap.SinMuteOfst.byFieldSize;
9964
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
9966
ulBaseAddress + ulFeatureBytesOffset,
9969
if ( ulResult != cOCT6100_ERR_OK )
9972
/* Clear previous value set in the feature field.*/
9973
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
9975
/* Clear the mute flag. */
9976
ulTempData &= (~ulMask);
9978
/* Set the mute flag on the Sin port.*/
9979
if ( fEnableSinWithFeatures == TRUE )
9980
ulTempData |= ( 0x1 << ulFeatureBitOffset );
9982
/* Write the new DWORD where the field is located. */
9983
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
9985
ulBaseAddress + ulFeatureBytesOffset,
9988
if ( ulResult != cOCT6100_ERR_OK )
9993
return cOCT6100_ERR_OK;
9997
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
9999
File: oct6100_chip_open.c
10001
Copyright (c) 2001-2005 Octasic Inc.
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.
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.
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
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.
10023
$Octasic_Release: OCT612xAPI-01.00-PR38 $
10025
$Octasic_Revision: 305 $
10027
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10030
/***************************** INCLUDE FILES *******************************/
10032
#include "octdef.h"
10034
#include "oct6100api/oct6100_defines.h"
10035
#include "oct6100api/oct6100_errors.h"
10037
#include "apilib/octapi_bt0.h"
10038
#include "apilib/octapi_llman.h"
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"
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"
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"
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"
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"
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"
10098
/**************************** PUBLIC FUNCTIONS *****************************/
10101
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10103
Function: Oct6100GetInstanceSizeDef
10105
Description: Retrieves the size of the required API instance structure.
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.
10113
f_pGetSize Structure containing API instance size.
10115
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10116
static UINT32 Oct6100GetInstanceSizeDef(
10117
tPOCT6100_GET_INSTANCE_SIZE f_pGetSize )
10119
return cOCT6100_ERR_OK;
10122
static UINT32 Oct6100GetInstanceSize(
10123
tPOCT6100_CHIP_OPEN f_pChipOpen,
10124
tPOCT6100_GET_INSTANCE_SIZE f_pGetSize )
10126
tOCT6100_API_INSTANCE_SIZES InstanceSizes;
10129
/* Check user configuration for errors and conflicts. */
10130
ulResult = Oct6100ApiCheckChipConfiguration( f_pChipOpen );
10131
if ( ulResult != cOCT6100_ERR_OK )
10134
/* Calculate the instance size required for user's configuration. */
10135
ulResult = Oct6100ApiCalculateInstanceSizes( f_pChipOpen, &InstanceSizes );
10136
if ( ulResult != cOCT6100_ERR_OK )
10139
/* Return required size to user. */
10140
f_pGetSize->ulApiInstanceSize = InstanceSizes.ulApiInstTotal;
10142
return cOCT6100_ERR_OK;
10146
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10148
Function: Oct6100ChipOpenDef
10150
Description: Inserts default chip configuration parameters into the
10151
structure pointed to by f_pChipOpen.
10153
-------------------------------------------------------------------------------
10154
| Argument | Description
10155
-------------------------------------------------------------------------------
10157
f_pChipOpen Structure containing user chip configuration.
10159
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10160
static UINT32 Oct6100ChipOpenDef(
10161
tPOCT6100_CHIP_OPEN f_pChipOpen )
10165
f_pChipOpen->ulUserChipId = 0;
10166
f_pChipOpen->fMultiProcessSystem = FALSE;
10167
f_pChipOpen->pProcessContext = NULL;
10169
f_pChipOpen->ulMaxRwAccesses = 8;
10171
f_pChipOpen->pbyImageFile = NULL;
10172
f_pChipOpen->ulImageSize = 0;
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;
10178
f_pChipOpen->ulMemoryType = cOCT6100_MEM_TYPE_DDR;
10179
f_pChipOpen->ulNumMemoryChips = 1;
10180
f_pChipOpen->ulMemoryChipSize = cOCT6100_MEMORY_CHIP_SIZE_64MB;
10182
/* Set the tail displacement to zero. */
10183
f_pChipOpen->ulTailDisplacement = 0;
10185
/* Disable acoustic echo by default. */
10186
f_pChipOpen->fEnableAcousticEcho = FALSE;
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;
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++ )
10202
f_pChipOpen->aulTimestampTimeslots[ i ] = cOCT6100_INVALID_TIMESLOT;
10203
f_pChipOpen->aulTimestampStreams[ i ] = cOCT6100_INVALID_STREAM;
10205
f_pChipOpen->fEnableFastH100Mode = FALSE;
10207
/* Configure the soft tone event buffer. */
10208
f_pChipOpen->ulSoftToneEventsBufSize = 2048;
10209
f_pChipOpen->fEnableExtToneDetection = FALSE;
10211
/* Configure the soft playout event buffer. */
10212
f_pChipOpen->ulSoftBufferPlayoutEventsBufSize = cOCT6100_INVALID_VALUE;
10214
/* Interrupt configuration. */
10215
f_pChipOpen->ulInterruptPolarity = cOCT6100_ACTIVE_LOW_POLARITY;
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;
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;
10235
f_pChipOpen->fEnableChannelRecording = FALSE;
10236
f_pChipOpen->fEnableProductionBist = FALSE;
10237
f_pChipOpen->ulNumProductionBistLoops = 1;
10239
return cOCT6100_ERR_OK;
10243
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10245
Function: Oct6100ChipOpen
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
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.
10258
f_pChipOpen Structure containing user chip configuration.
10260
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10261
static UINT32 Oct6100ChipOpen(
10262
tPOCT6100_INSTANCE_API f_pApiInstance,
10263
tPOCT6100_CHIP_OPEN f_pChipOpen )
10265
tOCT6100_API_INSTANCE_SIZES InstanceSizes;
10266
UINT32 ulStructSize;
10270
/* Check user chip configuration parameters for errors. */
10271
ulResult = Oct6100ApiCheckChipConfiguration( f_pChipOpen );
10272
if ( ulResult != cOCT6100_ERR_OK )
10275
/* Check if the host system is multi-process or not and adjust instance accordingly. */
10276
if ( f_pChipOpen->fMultiProcessSystem != TRUE )
10278
/* Set pointer to tOCT6100_SHARED_INFO structure within instance. */
10279
ulStructSize = sizeof( tOCT6100_INSTANCE_API );
10280
mOCT6100_ROUND_MEMORY_SIZE( ulStructSize, ulTempVar )
10282
f_pApiInstance->pSharedInfo = ( tPOCT6100_SHARED_INFO )(( PVOID )f_pApiInstance + ulStructSize);
10284
/* Save the process context specified by the user. */
10285
f_pApiInstance->pProcessContext = f_pChipOpen->pProcessContext;
10288
/* Create serialization object handles. */
10289
ulResult = Oct6100ApiCreateSerializeObjects( f_pApiInstance, f_pChipOpen->ulUserChipId );
10290
if ( ulResult != cOCT6100_ERR_OK )
10294
/* Copy the configuration structure. */
10295
ulResult = Oct6100ApiCopyChipConfiguration( f_pApiInstance, f_pChipOpen );
10296
if ( ulResult != cOCT6100_ERR_OK )
10299
/* Perform various calculations based on user chip configuration. */
10300
ulResult = Oct6100ApiInitializeMiscellaneousVariables( f_pApiInstance );
10301
if ( ulResult != cOCT6100_ERR_OK )
10304
/* Calculate the amount of memory needed for the API instance structure. */
10305
ulResult = Oct6100ApiCalculateInstanceSizes( f_pChipOpen, &InstanceSizes );
10306
if ( ulResult != cOCT6100_ERR_OK )
10309
/* Allocate the memory for the API instance structure internal pointers. */
10310
ulResult = Oct6100ApiAllocateInstanceMemory( f_pApiInstance, &InstanceSizes );
10311
if ( ulResult != cOCT6100_ERR_OK )
10314
/* Initialize the allocated instance structure memory. */
10315
ulResult = Oct6100ApiInitializeInstanceMemory( f_pApiInstance );
10316
if ( ulResult != cOCT6100_ERR_OK )
10319
/* Initialize the tone information structure. */
10320
ulResult = Oct6100ApiInitToneInfo( f_pApiInstance );
10321
if ( ulResult != cOCT6100_ERR_OK )
10324
/* Test the CPU registers. */
10325
ulResult = Oct6100ApiCpuRegisterBist( f_pApiInstance );
10326
if ( ulResult != cOCT6100_ERR_OK )
10329
/* Boot the FC2 PLL. */
10330
ulResult = Oct6100ApiBootFc2Pll( f_pApiInstance );
10331
if ( ulResult != cOCT6100_ERR_OK )
10334
/* Program the FC1 PLL. */
10335
ulResult = Oct6100ApiProgramFc1Pll( f_pApiInstance );
10336
if ( ulResult != cOCT6100_ERR_OK )
10339
/* Decode the key and bist internal memories. */
10340
ulResult = Oct6100ApiDecodeKeyAndBist( f_pApiInstance );
10341
if ( ulResult != cOCT6100_ERR_OK )
10344
/* Boot the FC1 PLL. */
10345
ulResult = Oct6100ApiBootFc1Pll( f_pApiInstance );
10346
if ( ulResult != cOCT6100_ERR_OK )
10349
/* Boot the SDRAM. */
10350
ulResult = Oct6100ApiBootSdram( f_pApiInstance );
10351
if ( ulResult != cOCT6100_ERR_OK )
10354
/* Bist the external memory. */
10355
ulResult = Oct6100ApiExternalMemoryBist( f_pApiInstance );
10356
if ( ulResult != cOCT6100_ERR_OK )
10359
/* Initialize the external memory. */
10360
ulResult = Oct6100ApiExternalMemoryInit( f_pApiInstance );
10361
if ( ulResult != cOCT6100_ERR_OK )
10364
/* Load the image into the chip. */
10365
ulResult = Oct6100ApiLoadImage( f_pApiInstance );
10366
if ( ulResult != cOCT6100_ERR_OK )
10369
/* Write the clock distribution registers. */
10370
ulResult = Oct6100ApiEnableClocks( f_pApiInstance );
10371
if ( ulResult != cOCT6100_ERR_OK )
10374
/* Program the NLP processor. */
10375
ulResult = Oct6100ApiProgramNLP( f_pApiInstance );
10376
if ( ulResult != cOCT6100_ERR_OK )
10378
if ( ulResult == cOCT6100_ERR_OPEN_EGO_TIMEOUT )
10379
ulResult = Oct6100ApiProgramNLP( f_pApiInstance );
10381
if ( ulResult != cOCT6100_ERR_OK )
10384
if ( f_pChipOpen->fEnableProductionBist == FALSE )
10386
/* Read all TLV fields present in external memory. */
10387
ulResult = Oct6100ApiProcessTlvRegion( f_pApiInstance );
10388
if ( ulResult != cOCT6100_ERR_OK )
10391
/* Configure the H.100 interface. */
10392
ulResult = Oct6100ApiSetH100Register( f_pApiInstance );
10393
if ( ulResult != cOCT6100_ERR_OK )
10397
/* Write miscellaneous registers. */
10398
ulResult = Oct6100ApiWriteMiscellaneousRegisters( f_pApiInstance );
10399
if ( ulResult != cOCT6100_ERR_OK )
10402
/* Proceed with the rest only if the production BIST has not been requested. */
10403
if ( f_pChipOpen->fEnableProductionBist == FALSE )
10405
/* Configure the interrupt registers. */
10406
ulResult = Oct6100ApiIsrHwInit( f_pApiInstance, &f_pChipOpen->InterruptConfig );
10407
if ( ulResult != cOCT6100_ERR_OK )
10410
/* Initialize the errors counters. */
10411
ulResult = Oct6100ApiChipStatsSwInit( f_pApiInstance );
10412
if ( ulResult != cOCT6100_ERR_OK )
10415
/* Configure all interrupts of the chip. */
10416
ulResult = Oct6100InterruptConfigureSer( f_pApiInstance, &f_pChipOpen->InterruptConfig, FALSE );
10417
if ( ulResult != cOCT6100_ERR_OK )
10420
/* Get revision number of chip. */
10421
ulResult = Oct6100ApiGetChipRevisionNum( f_pApiInstance );
10422
if ( ulResult != cOCT6100_ERR_OK )
10429
/* Initialize the channels. */
10430
ulResult = Oct6100ApiInitChannels( f_pApiInstance );
10431
if ( ulResult != cOCT6100_ERR_OK )
10434
/* Initialize the mixer memory. */
10435
ulResult = Oct6100ApiInitMixer( f_pApiInstance );
10436
if ( ulResult != cOCT6100_ERR_OK )
10439
/* Initialize the mixer memory. */
10440
ulResult = Oct6100ApiInitRecordResources( f_pApiInstance );
10441
if ( ulResult != cOCT6100_ERR_OK )
10444
/* Initialize free external memory for buffer playout. */
10445
ulResult = Oct6100ApiBufferPlayoutMemorySwInit( f_pApiInstance );
10446
if ( ulResult != cOCT6100_ERR_OK )
10453
return cOCT6100_ERR_OK;
10457
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10459
Function: Oct6100ChipCloseDef
10461
Description: Puts the chip into soft reset.
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.
10469
f_pChipClose Pointer to a tOCT6100_CHIP_CLOSE structure.
10471
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10472
static UINT32 Oct6100ChipCloseDef(
10473
tPOCT6100_CHIP_CLOSE f_pChipClose )
10475
f_pChipClose->ulDummyVariable = 0;
10477
return cOCT6100_ERR_OK;
10480
static UINT32 Oct6100ChipClose(
10481
tPOCT6100_INSTANCE_API f_pApiInstance,
10482
tPOCT6100_CHIP_CLOSE f_pChipClose )
10484
tOCT6100_WRITE_PARAMS WriteParams;
10487
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
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 )
10496
/* Destroy the allocated ressources used for serialization. */
10497
ulResult = Oct6100ApiDestroySerializeObjects( f_pApiInstance );
10498
if ( ulResult != cOCT6100_ERR_OK )
10501
return cOCT6100_ERR_OK;
10504
/*************************** PRIVATE FUNCTIONS *****************************/
10506
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10508
Function: Oct6100ApiStrStr
10510
Description: OCT6100 API version of strstr()
10512
-------------------------------------------------------------------------------
10513
| Argument | Description
10514
-------------------------------------------------------------------------------
10516
f_pszSource Source string to analyze.
10517
f_pszString String to look for.
10518
f_pszLastCharPtr Last character in the source string.
10520
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10521
static PUINT8 Oct6100ApiStrStr(
10522
IN PUINT8 f_pszSource,
10523
IN PUINT8 f_pszString,
10524
IN PUINT8 f_pszLastCharPtr )
10526
UINT32 ulCurrentPos;
10527
UINT32 ulStringLength;
10528
UINT32 ulNumMatchingCharFound = 0;
10529
PUINT8 pchFirstChar = NULL;
10530
UINT32 ulSourceLength;
10532
if ( f_pszLastCharPtr < f_pszSource )
10535
ulSourceLength = f_pszLastCharPtr - f_pszSource;
10536
ulStringLength = Oct6100ApiStrLen( f_pszString );
10538
for ( ulCurrentPos = 0; ulCurrentPos < ulSourceLength; ulCurrentPos++ )
10540
/* Check if the character matches. */
10541
if ( f_pszSource[ ulCurrentPos ] == f_pszString[ ulNumMatchingCharFound ] )
10543
if ( ulNumMatchingCharFound == 0 )
10544
pchFirstChar = ( f_pszSource + ulCurrentPos );
10546
ulNumMatchingCharFound++;
10548
/* Check if the whole string matched. */
10549
if ( ulNumMatchingCharFound == ulStringLength )
10552
else if ( ulNumMatchingCharFound != 0 )
10554
ulNumMatchingCharFound = 0;
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 ] )
10560
pchFirstChar = ( f_pszSource + ulCurrentPos );
10561
ulNumMatchingCharFound++;
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 )
10571
if ( ulCurrentPos == ulSourceLength )
10574
return pchFirstChar;
10578
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10580
Function: Oct6100ApiStrLen
10582
Description: OCT6100 API version of strlen()
10584
-------------------------------------------------------------------------------
10585
| Argument | Description
10586
-------------------------------------------------------------------------------
10588
f_pszString Source string to count length of.
10590
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10591
static UINT32 Oct6100ApiStrLen(
10592
IN PUINT8 f_pszString )
10594
UINT32 ulCount = 0;
10596
while( f_pszString[ ulCount ] != '\0' )
10603
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10605
Function: Oct6100ApiAsciiToHex
10607
Description: Convert an ASCII character to an hexadecimal value.
10609
-------------------------------------------------------------------------------
10610
| Argument | Description
10611
-------------------------------------------------------------------------------
10613
f_chCharacter ASCII character to convert.
10614
f_pulValue Resulting hexadecimal value.
10616
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10617
static UINT32 Oct6100ApiAsciiToHex(
10618
IN UINT8 f_chCharacter,
10619
OUT PUINT32 f_pulValue )
10621
switch ( f_chCharacter )
10624
(*f_pulValue) = 0x0;
10627
(*f_pulValue) = 0x1;
10630
(*f_pulValue) = 0x2;
10633
(*f_pulValue) = 0x3;
10636
(*f_pulValue) = 0x4;
10639
(*f_pulValue) = 0x5;
10642
(*f_pulValue) = 0x6;
10645
(*f_pulValue) = 0x7;
10648
(*f_pulValue) = 0x8;
10651
(*f_pulValue) = 0x9;
10655
(*f_pulValue) = 0xA;
10659
(*f_pulValue) = 0xB;
10663
(*f_pulValue) = 0xC;
10667
(*f_pulValue) = 0xD;
10671
(*f_pulValue) = 0xE;
10675
(*f_pulValue) = 0xF;
10678
(*f_pulValue) = 0x0;
10679
return cOCT6100_ERR_MISC_ASCII_CONVERSION_FAILED;
10682
return cOCT6100_ERR_OK;
10686
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10688
Function: Oct6100ApiHexToAscii
10690
Description: Convert an hexadecimal value to an ASCII character.
10692
-------------------------------------------------------------------------------
10693
| Argument | Description
10694
-------------------------------------------------------------------------------
10696
f_ulNumber Hexadecimal value to convert.
10698
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10699
static UINT8 Oct6100ApiHexToAscii(
10700
IN UINT32 f_ulNumber )
10702
if ( f_ulNumber >= 0xA )
10703
return (UINT8)( 55 + f_ulNumber ); /* Hex values from 0xA to 0xF */
10705
return (UINT8)( 48 + f_ulNumber ); /* Hex values from 0x0 to 0x9 */
10709
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10711
Function: Oct6100ApiRand
10713
Description: Random number generator.
10715
-------------------------------------------------------------------------------
10716
| Argument | Description
10717
-------------------------------------------------------------------------------
10719
f_ulRange Range of the random number to be generated.
10721
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10722
static UINT32 Oct6100ApiRand(
10723
IN UINT32 f_ulRange )
10725
static UINT32 ulRandomSeed = 0x12345678;
10729
UINT16 ulWithinRange = FALSE;
10731
UINT32 ulResult = cOCT6100_ERR_OK;
10734
UINT32 ulRangeMask;
10735
UINT32 ulAddedValue;
10746
for ( j = 1; j < i; j++ )
10749
ulRangeMask = ulRangeMask + ulAddedValue;
10751
if ( ulRangeMask >= f_ulRange )
10757
while ( !ulWithinRange )
10759
ulBit0 = ((ulRandomSeed >> 19) & 0x1) ^ ((ulRandomSeed >> 16) & 0x1);
10760
ulRandomSeed = ((ulRandomSeed << 1) & 0xFFFFF) | ulBit0;
10762
ulResult = ulRandomSeed & ulRangeMask;
10764
if ( ulResult <= f_ulRange )
10765
ulWithinRange = TRUE;
10773
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
10775
Function: Oct6100ApiCheckChipConfiguration
10777
Description: Checks the user chip configuration structure for errors.
10779
-------------------------------------------------------------------------------
10780
| Argument | Description
10781
-------------------------------------------------------------------------------
10783
f_pChipOpen Pointer to chip configuration structure.
10785
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
10786
static UINT32 Oct6100ApiCheckChipConfiguration(
10787
IN tPOCT6100_CHIP_OPEN f_pChipOpen )
10792
/*-----------------------------------------------------------------------------*/
10793
/* Check general parameters. */
10794
if ( f_pChipOpen->fMultiProcessSystem != TRUE &&
10795
f_pChipOpen->fMultiProcessSystem != FALSE )
10796
return cOCT6100_ERR_OPEN_MULTI_PROCESS_SYSTEM;
10798
if ( f_pChipOpen->ulMaxRwAccesses < 1 ||
10799
f_pChipOpen->ulMaxRwAccesses > 1024)
10800
return cOCT6100_ERR_OPEN_MAX_RW_ACCESSES;
10802
/* Check the clocks. */
10803
if ( f_pChipOpen->ulUpclkFreq != cOCT6100_UPCLK_FREQ_33_33_MHZ )
10804
return cOCT6100_ERR_OPEN_UP_CLK_FREQ;
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;
10816
if ( f_pChipOpen->fEnableMemClkOut != TRUE &&
10817
f_pChipOpen->fEnableMemClkOut != FALSE )
10818
return cOCT6100_ERR_OPEN_ENABLE_MEM_CLK_OUT;
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;
10825
if ( f_pChipOpen->pbyImageFile == NULL )
10826
return cOCT6100_ERR_OPEN_IMAGE_FILE;
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;
10833
/* Check the tail displacement parameter. */
10834
if ( f_pChipOpen->ulTailDisplacement > cOCT6100_MAX_TAIL_DISPLACEMENT )
10835
return cOCT6100_ERR_OPEN_TAIL_DISPLACEMENT;
10837
/*-----------------------------------------------------------------------------*/
10838
/* Check TDM bus configuration parameters. */
10839
for ( i = 0; i < 8; i++ )
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;
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;
10852
if ( f_pChipOpen->fEnableFastH100Mode != TRUE &&
10853
f_pChipOpen->fEnableFastH100Mode != FALSE )
10854
return cOCT6100_ERR_OPEN_FAST_H100_MODE;
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;
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;
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;
10874
if ( f_pChipOpen->ulNumMemoryChips < 1 ||
10875
f_pChipOpen->ulNumMemoryChips > cOCT6100_MAX_NUM_MEMORY_CHIP )
10876
return cOCT6100_ERR_OPEN_MEMORY_CHIPS_NUMBER;
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;
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;
10890
if ( f_pChipOpen->ulMaxTdmStreams > 8 &&
10891
f_pChipOpen->ulMemClkFreq == cOCT6100_MCLK_FREQ_75_MHZ )
10892
return cOCT6100_ERR_OPEN_MAX_TDM_STREAM;
10894
if ( f_pChipOpen->fUseSynchTimestamp != TRUE &&
10895
f_pChipOpen->fUseSynchTimestamp != FALSE )
10896
return cOCT6100_ERR_OPEN_USE_SYNCH_TIMESTAMP;
10898
if ( f_pChipOpen->fUseSynchTimestamp == TRUE )
10900
return cOCT6100_ERR_NOT_SUPPORTED_OPEN_USE_SYNCH_TIMESTAMP;
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;
10909
if ( f_pChipOpen->fEnableExtToneDetection != TRUE &&
10910
f_pChipOpen->fEnableExtToneDetection != FALSE )
10911
return cOCT6100_ERR_OPEN_ENABLE_EXT_TONE_DETECTION;
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;
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;
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;
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;
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;
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;
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;
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;
10954
if ( f_pChipOpen->InterruptConfig.ulErrorMemoryTimeout < 10 ||
10955
f_pChipOpen->InterruptConfig.ulErrorMemoryTimeout > 10000 )
10956
return cOCT6100_ERR_OPEN_ERROR_MEMORY_TIMEOUT;
10958
if ( f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsTimeout < 10 ||
10959
f_pChipOpen->InterruptConfig.ulErrorOverflowToneEventsTimeout > 10000 )
10960
return cOCT6100_ERR_OPEN_ERROR_OVERFLOW_TONE_EVENTS_TIMEOUT;
10962
if ( f_pChipOpen->InterruptConfig.ulErrorH100Timeout < 10 ||
10963
f_pChipOpen->InterruptConfig.ulErrorH100Timeout > 10000 )
10964
return cOCT6100_ERR_OPEN_ERROR_H100_TIMEOUT;
10966
/*-----------------------------------------------------------------------------*/
10967
/* Check maximum resources. */
10969
switch ( f_pChipOpen->ulMemClkFreq )
10996
return cOCT6100_ERR_FATAL_DA;
10999
if ( f_pChipOpen->ulMaxChannels > ulTempVar )
11000
return cOCT6100_ERR_OPEN_MAX_ECHO_CHANNELS;
11002
if ( f_pChipOpen->ulMaxTsiCncts > cOCT6100_MAX_TSI_CNCTS )
11003
return cOCT6100_ERR_OPEN_MAX_TSI_CNCTS;
11005
if ( f_pChipOpen->ulMaxBiDirChannels > (f_pChipOpen->ulMaxChannels / 2) )
11006
return cOCT6100_ERR_OPEN_MAX_BIDIR_CHANNELS;
11008
if ( f_pChipOpen->ulMaxConfBridges > cOCT6100_MAX_CONF_BRIDGE )
11009
return cOCT6100_ERR_OPEN_MAX_CONF_BRIDGES;
11011
if ( f_pChipOpen->ulMaxFlexibleConfParticipants > cOCT6100_MAX_FLEX_CONF_PARTICIPANTS )
11012
return cOCT6100_ERR_OPEN_MAX_FLEXIBLE_CONF_PARTICIPANTS;
11014
if ( f_pChipOpen->ulMaxPlayoutBuffers > cOCT6100_MAX_PLAYOUT_BUFFERS )
11015
return cOCT6100_ERR_OPEN_MAX_PLAYOUT_BUFFERS;
11019
if ( f_pChipOpen->ulMaxPhasingTssts > cOCT6100_MAX_PHASING_TSST )
11020
return cOCT6100_ERR_OPEN_MAX_PHASING_TSSTS;
11022
if ( f_pChipOpen->ulMaxAdpcmChannels > cOCT6100_MAX_ADPCM_CHANNELS )
11023
return cOCT6100_ERR_OPEN_MAX_ADPCM_CHANNELS;
11025
if ( f_pChipOpen->ulMaxRemoteDebugSessions > 256 )
11026
return cOCT6100_ERR_OPEN_MAX_REMOTE_DEBUG_SESSIONS;
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;
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;
11042
/* Check number of loops for the production BIST. */
11043
if ( f_pChipOpen->fEnableProductionBist == TRUE )
11045
if ( f_pChipOpen->ulNumProductionBistLoops == 0 )
11046
return cOCT6100_ERR_OPEN_NUM_PRODUCTION_BIST_LOOPS;
11049
/* If the production BIST has been requested, make sure all */
11050
/* other resources are disabled. */
11051
if ( f_pChipOpen->fEnableProductionBist == TRUE )
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;
11067
return cOCT6100_ERR_OK;
11071
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11073
Function: Oct6100ApiCopyChipConfiguration
11075
Description: Copies the chip configuration from the user supplied config
11076
structure to the instance structure.
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.
11084
f_pChipOpen Pointer to chip configuration structure.
11086
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11087
static UINT32 Oct6100ApiCopyChipConfiguration(
11088
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
11089
IN tPOCT6100_CHIP_OPEN f_pChipOpen )
11091
tPOCT6100_SHARED_INFO pSharedInfo;
11094
/* Get local pointer to shared portion of instance. */
11095
pSharedInfo = f_pApiInstance->pSharedInfo;
11097
pSharedInfo->ChipConfig.ulUserChipId = f_pChipOpen->ulUserChipId;
11098
pSharedInfo->ChipConfig.fMultiProcessSystem = (UINT8)( f_pChipOpen->fMultiProcessSystem & 0xFF );
11100
pSharedInfo->ChipConfig.usMaxRwAccesses = (UINT16)( f_pChipOpen->ulMaxRwAccesses & 0xFFFF );
11102
pSharedInfo->ChipConfig.pbyImageFile = f_pChipOpen->pbyImageFile;
11103
pSharedInfo->ChipConfig.ulImageSize = f_pChipOpen->ulImageSize;
11105
pSharedInfo->ChipConfig.ulMemClkFreq = f_pChipOpen->ulMemClkFreq;
11106
pSharedInfo->ChipConfig.ulUpclkFreq = f_pChipOpen->ulUpclkFreq;
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;
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 );
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 );
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++ )
11131
pSharedInfo->ChipConfig.ausTimestampTimeslots[ i ] = (UINT16)( f_pChipOpen->aulTimestampTimeslots[ i ] & 0xFFFF );
11132
pSharedInfo->ChipConfig.ausTimestampStreams[ i ] = (UINT16)( f_pChipOpen->aulTimestampStreams[ i ] & 0xFFFF );
11134
pSharedInfo->ChipConfig.byInterruptPolarity = (UINT8)( f_pChipOpen->ulInterruptPolarity & 0xFF );
11136
pSharedInfo->ChipConfig.byTdmSampling = (UINT8)( f_pChipOpen->ulTdmSampling & 0xFF );
11137
pSharedInfo->ChipConfig.fEnableFastH100Mode = (UINT8)( f_pChipOpen->fEnableFastH100Mode & 0xFF );
11139
for ( i = 0; i < cOCT6100_TDM_STREAM_MAX_GROUPS; i++ )
11141
if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
11142
pSharedInfo->ChipConfig.aulTdmStreamFreqs[ i ] = cOCT6100_TDM_STREAM_FREQ_16MHZ;
11144
pSharedInfo->ChipConfig.aulTdmStreamFreqs[ i ] = f_pChipOpen->aulTdmStreamFreqs[ i ];
11147
pSharedInfo->ChipConfig.fEnableFastH100Mode = (UINT8)( f_pChipOpen->fEnableFastH100Mode & 0xFF );
11148
pSharedInfo->ChipConfig.fEnableMemClkOut = (UINT8)( f_pChipOpen->fEnableMemClkOut & 0xFF );
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 );
11154
if ( f_pChipOpen->ulSoftBufferPlayoutEventsBufSize != cOCT6100_INVALID_VALUE )
11155
pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize = f_pChipOpen->ulSoftBufferPlayoutEventsBufSize + 1;
11157
pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize = 0;
11158
pSharedInfo->ChipConfig.usMaxRemoteDebugSessions = (UINT16)( f_pChipOpen->ulMaxRemoteDebugSessions & 0xFFFF );
11160
pSharedInfo->ChipConfig.fEnableChannelRecording = (UINT8)( f_pChipOpen->fEnableChannelRecording & 0xFF );
11164
pSharedInfo->ChipConfig.fEnableProductionBist = (UINT8)( f_pChipOpen->fEnableProductionBist & 0xFF );
11165
pSharedInfo->ChipConfig.ulNumProductionBistLoops = f_pChipOpen->ulNumProductionBistLoops;
11167
return cOCT6100_ERR_OK;
11171
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11173
Function: Oct6100ApiInitializeMiscellaneousVariables
11175
Description: Function where all the various parameters from the API instance
11176
are set to their defaults value.
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.
11184
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11185
static UINT32 Oct6100ApiInitializeMiscellaneousVariables(
11186
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
11188
tPOCT6100_SHARED_INFO pSharedInfo;
11191
/* Obtain pointer to shared portion of instance. */
11192
pSharedInfo = f_pApiInstance->pSharedInfo;
11194
/* Calculate the total memory available. */
11195
pSharedInfo->MiscVars.ulTotalMemSize = pSharedInfo->ChipConfig.ulMemoryChipSize * pSharedInfo->ChipConfig.byNumMemoryChips;
11197
/* Software buffers initialization. */
11200
pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0;
11201
pSharedInfo->SoftBufs.ulToneEventBufferReadPtr = 0;
11202
pSharedInfo->SoftBufs.ulToneEventBufferSize = pSharedInfo->ChipConfig.ulSoftToneEventsBufSize;
11203
pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt = 0;
11206
pSharedInfo->SoftBufs.ulBufPlayoutEventBufferWritePtr = 0;
11207
pSharedInfo->SoftBufs.ulBufPlayoutEventBufferReadPtr = 0;
11208
pSharedInfo->SoftBufs.ulBufPlayoutEventBufferSize = pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize;
11209
pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt = 0;
11211
/* Set the number of conference bridges opened to zero. */
11212
pSharedInfo->MiscVars.usNumBridgesOpened = 0;
11213
pSharedInfo->MiscVars.usFirstBridge = cOCT6100_INVALID_INDEX;
11215
/* Set the H.100 slave mode. */
11216
pSharedInfo->MiscVars.ulH100SlaveMode = cOCT6100_H100_TRACKA;
11218
/* Save the Mclk value.*/
11219
pSharedInfo->MiscVars.ulMclkFreq = pSharedInfo->ChipConfig.ulMemClkFreq;
11221
/* Init the NLP params. */
11222
pSharedInfo->MiscVars.usCodepoint = 0;
11223
pSharedInfo->MiscVars.usCpuLsuWritePtr = 0;
11225
/* Pouch counter not present until TLVs are read. */
11226
pSharedInfo->DebugInfo.fPouchCounter = FALSE;
11227
pSharedInfo->DebugInfo.fIsIsrCalledField = FALSE;
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;
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;
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;
11303
/* Set all tones to invalid. */
11304
pSharedInfo->ImageInfo.byNumToneDetectors = 0;
11305
for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ )
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 );
11311
/* Initialize the channel recording info. */
11312
pSharedInfo->DebugInfo.usRecordChanIndex = pSharedInfo->ChipConfig.usMaxChannels;
11313
pSharedInfo->DebugInfo.usRecordMemIndex = cOCT6100_INVALID_INDEX;
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;
11324
pSharedInfo->MixerInfo.usRecordCopyEventIndex = cOCT6100_INVALID_INDEX;
11325
pSharedInfo->MixerInfo.usRecordSinEventIndex = cOCT6100_INVALID_INDEX;
11327
return cOCT6100_ERR_OK;
11331
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11333
Function: Oct6100ApiCalculateInstanceSizes
11335
Description: Calculates the amount of memory needed for the instance
11336
structure memory block based on the user's configuration.
11338
-------------------------------------------------------------------------------
11339
| Argument | Description
11340
-------------------------------------------------------------------------------
11341
f_pChipOpen Pointer to user chip configuration structure.
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
11348
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11349
static UINT32 Oct6100ApiCalculateInstanceSizes(
11350
IN OUT tPOCT6100_CHIP_OPEN f_pChipOpen,
11351
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
11353
UINT32 ulApiInstProcessSpecific;
11357
/* Start with all instance sizes set to 0. */
11358
Oct6100UserMemSet( f_pInstSizes, 0x00, sizeof( tOCT6100_API_INSTANCE_SIZES ) );
11360
/* All memory sizes are rounded up to the next multiple of 64 bytes. */
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 )
11367
/* Calculate memory needed by pointers internal to the API instance. */
11369
/*-----------------------------------------------------------------------------*/
11370
/* Calculate memory needed for the EC channels. */
11371
ulResult = Oct6100ApiGetChannelsEchoSwSizes( f_pChipOpen, f_pInstSizes );
11372
if ( ulResult != cOCT6100_ERR_OK )
11375
/*-----------------------------------------------------------------------------*/
11376
/* Memory needed by the TSI structures. */
11377
ulResult = Oct6100ApiGetTsiCnctSwSizes( f_pChipOpen, f_pInstSizes );
11378
if ( ulResult != cOCT6100_ERR_OK )
11381
/*-----------------------------------------------------------------------------*/
11382
/* Calculate memory needed for the conference bridges. */
11383
ulResult = Oct6100ApiGetConfBridgeSwSizes( f_pChipOpen, f_pInstSizes );
11384
if ( ulResult != cOCT6100_ERR_OK )
11387
/*-----------------------------------------------------------------------------*/
11388
/* Memory needed by the buffer playout structures. */
11389
ulResult = Oct6100ApiGetPlayoutBufferSwSizes( f_pChipOpen, f_pInstSizes );
11390
if ( ulResult != cOCT6100_ERR_OK )
11395
/*-----------------------------------------------------------------------------*/
11396
/* Memory needed by soft Rx Event buffers. */
11397
ulResult = Oct6100ApiGetEventsSwSizes( f_pChipOpen, f_pInstSizes );
11398
if ( ulResult != cOCT6100_ERR_OK )
11401
/*-----------------------------------------------------------------------------*/
11402
/* Calculate memory needed for phasing tssts. */
11403
ulResult = Oct6100ApiGetPhasingTsstSwSizes( f_pChipOpen, f_pInstSizes );
11404
if ( ulResult != cOCT6100_ERR_OK )
11407
/*-----------------------------------------------------------------------------*/
11408
/* Calculate memory needed for the ADPCM channels. */
11409
ulResult = Oct6100ApiGetAdpcmChanSwSizes( f_pChipOpen, f_pInstSizes );
11410
if ( ulResult != cOCT6100_ERR_OK )
11413
/*-----------------------------------------------------------------------------*/
11414
/* Calculate memory needed for the management of TSSTs. */
11415
ulResult = Oct6100ApiGetTsstSwSizes( f_pInstSizes );
11416
if ( ulResult != cOCT6100_ERR_OK )
11419
/*-----------------------------------------------------------------------------*/
11420
/* Calculate memory needed for the management of the mixer. */
11421
ulResult = Oct6100ApiGetMixerSwSizes( f_pChipOpen, f_pInstSizes );
11422
if ( ulResult != cOCT6100_ERR_OK )
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 )
11433
/*-----------------------------------------------------------------------------*/
11434
/* Memory needed for remote debugging sessions. */
11435
ulResult = Oct6100ApiGetRemoteDebugSwSizes( f_pChipOpen, f_pInstSizes );
11436
if ( ulResult != cOCT6100_ERR_OK )
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. */
11446
ulApiInstProcessSpecific = sizeof( tOCT6100_INSTANCE_API );
11447
mOCT6100_ROUND_MEMORY_SIZE( ulApiInstProcessSpecific, ulTempVar )
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 +
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;
11486
return cOCT6100_ERR_OK;
11490
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11492
Function: Oct6100ApiAllocateInstanceMemory
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
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.
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
11510
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11511
static UINT32 Oct6100ApiAllocateInstanceMemory(
11512
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
11513
IN tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
11515
tPOCT6100_SHARED_INFO pSharedInfo;
11518
/* Get local pointer to shared portion of instance. */
11519
pSharedInfo = f_pApiInstance->pSharedInfo;
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;
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;
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;
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;
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;
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;
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;
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;
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;
11591
/*===================================================================*/
11592
/* Allocate memory for the conversion memory */
11593
pSharedInfo->ulConversionMemoryAllocOfst = ulOffset;
11594
ulOffset += f_pInstSizes->ulConversionMemoryAlloc;
11596
/*===================================================================*/
11597
/* Allocate memory for the TSI chariot memory */
11598
pSharedInfo->ulTsiMemoryAllocOfst = ulOffset;
11599
ulOffset += f_pInstSizes->ulTsiMemoryAlloc;
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;
11610
/*===================================================================*/
11611
pSharedInfo->SoftBufs.ulToneEventBufferMemOfst = ulOffset;
11612
ulOffset += f_pInstSizes->ulSoftToneEventsBuffer;
11614
pSharedInfo->SoftBufs.ulBufPlayoutEventBufferMemOfst = ulOffset;
11615
ulOffset += f_pInstSizes->ulSoftBufPlayoutEventsBuffer;
11616
/*===================================================================*/
11617
pSharedInfo->RemoteDebugInfo.ulSessionListOfst = ulOffset;
11618
ulOffset += f_pInstSizes->ulRemoteDebugList;
11620
pSharedInfo->RemoteDebugInfo.ulSessionTreeOfst = ulOffset;
11621
ulOffset += f_pInstSizes->ulRemoteDebugTree;
11623
pSharedInfo->RemoteDebugInfo.ulDataBufOfst = ulOffset;
11624
ulOffset += f_pInstSizes->ulRemoteDebugDataBuf;
11626
pSharedInfo->RemoteDebugInfo.ulPktCacheOfst = ulOffset;
11627
ulOffset += f_pInstSizes->ulRemoteDebugPktCache;
11628
/*===================================================================*/
11630
return cOCT6100_ERR_OK;
11634
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11636
Function: Oct6100ApiInitializeInstanceMemory
11638
Description: Initializes the various members of the structure f_pApiInstance
11639
to reflect the current state of the chip and its resources.
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.
11647
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11648
static UINT32 Oct6100ApiInitializeInstanceMemory(
11649
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
11653
/*-----------------------------------------------------------------------------*/
11654
/* Initialize API EC channels. */
11655
ulResult = Oct6100ApiChannelsEchoSwInit( f_pApiInstance );
11656
if ( ulResult != cOCT6100_ERR_OK )
11659
/*-----------------------------------------------------------------------------*/
11660
/* Initialize the API TSI connection structures. */
11661
ulResult = Oct6100ApiTsiCnctSwInit( f_pApiInstance );
11662
if ( ulResult != cOCT6100_ERR_OK )
11665
/*-----------------------------------------------------------------------------*/
11666
/* Initialize the API conference bridges. */
11667
ulResult = Oct6100ApiConfBridgeSwInit( f_pApiInstance );
11668
if ( ulResult != cOCT6100_ERR_OK )
11671
/*-----------------------------------------------------------------------------*/
11672
/* Initialize the API buffer playout structures. */
11673
ulResult = Oct6100ApiPlayoutBufferSwInit( f_pApiInstance );
11674
if ( ulResult != cOCT6100_ERR_OK )
11677
/*-----------------------------------------------------------------------------*/
11678
/* Initialize the API phasing tssts. */
11679
ulResult = Oct6100ApiPhasingTsstSwInit( f_pApiInstance );
11680
if ( ulResult != cOCT6100_ERR_OK )
11683
/*-----------------------------------------------------------------------------*/
11684
/* Initialize the API ADPCM channels. */
11685
ulResult = Oct6100ApiAdpcmChanSwInit( f_pApiInstance );
11686
if ( ulResult != cOCT6100_ERR_OK )
11689
/*-----------------------------------------------------------------------------*/
11690
/* Initialize the external memory management structures. */
11691
ulResult = Oct6100ApiMemorySwInit( f_pApiInstance );
11692
if ( ulResult != cOCT6100_ERR_OK )
11695
/*-----------------------------------------------------------------------------*/
11696
/* Initialize TSST management stuctures. */
11697
ulResult = Oct6100ApiTsstSwInit( f_pApiInstance );
11698
if ( ulResult != cOCT6100_ERR_OK )
11701
/*-----------------------------------------------------------------------------*/
11702
/* Initialize the mixer management stuctures. */
11703
ulResult = Oct6100ApiMixerSwInit( f_pApiInstance );
11704
if ( ulResult != cOCT6100_ERR_OK )
11707
/*-----------------------------------------------------------------------------*/
11708
/* Initialize the remote debugging session management variables. */
11709
ulResult = Oct6100ApiRemoteDebuggingSwInit( f_pApiInstance );
11710
if ( ulResult != cOCT6100_ERR_OK )
11713
/*-----------------------------------------------------------------------------*/
11714
/* Configure the interrupt registers. */
11715
ulResult = Oct6100ApiIsrSwInit( f_pApiInstance );
11716
if ( ulResult != cOCT6100_ERR_OK )
11719
return cOCT6100_ERR_OK;
11723
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11725
Function: Oct6100ApiGetChipRevisionNum
11727
Description: Reads the chip's revision number register.
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.
11735
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11736
static UINT32 Oct6100ApiGetChipRevisionNum(
11737
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
11739
tPOCT6100_SHARED_INFO pSharedInfo;
11740
tOCT6100_READ_PARAMS ReadParams;
11744
/* Get local pointer to shared portion of instance. */
11745
pSharedInfo = f_pApiInstance->pSharedInfo;
11747
/* Get the chip revision number. */
11748
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
11750
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
11751
ReadParams.ulReadAddress = cOCT6100_CHIP_ID_REVISION_REG;
11752
ReadParams.pusReadData = &usReadData;
11754
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
11755
if ( ulResult != cOCT6100_ERR_OK )
11758
/* Save the info in the API miscellaneous structure. */
11759
pSharedInfo->MiscVars.usChipId = (UINT16)( usReadData & 0xFF );
11760
pSharedInfo->MiscVars.usChipRevision = (UINT16)( usReadData >> 8 );
11762
return cOCT6100_ERR_OK;
11766
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11768
Function: Oct6100ApiDecodeKeyAndBist
11770
Description: This function decodes the key and runs the automatic BIST.
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.
11778
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11779
static UINT32 Oct6100ApiDecodeKeyAndBist(
11780
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
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 ];
11792
/* Get local pointer to shared portion of instance. */
11793
pSharedInfo = f_pApiInstance->pSharedInfo;
11795
/* Obtain a local pointer to the chip config structure */
11796
/* contained in the instance structure. */
11797
pChipConfig = &pSharedInfo->ChipConfig;
11799
/* Set the process context and user chip ID parameters once and for all. */
11800
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
11802
WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
11804
/* Set the process context and user chip ID parameters once and for all. */
11805
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
11807
ReadParams.ulUserChipId = pChipConfig->ulUserChipId;
11809
/* Write key in CPU internal memory. */
11812
WriteParams.ulWriteAddress = 0x150;
11813
WriteParams.usWriteData = 0x0000;
11814
if (( i % 2 ) == 0)
11816
WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 2]) << 8;
11817
WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 3]) << 0;
11821
WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 0]) << 8;
11822
WriteParams.usWriteData |= ((UINT16)pChipConfig->pbyImageFile[0x100 + ((i/2)*4) + 1]) << 0;
11825
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11826
if ( ulResult != cOCT6100_ERR_OK )
11829
WriteParams.ulWriteAddress = 0x152;
11830
WriteParams.usWriteData = (UINT16)( 0x8000 | i );
11832
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11833
if ( ulResult != cOCT6100_ERR_OK )
11837
/* Write one in CPU internal memory. */
11840
WriteParams.ulWriteAddress = 0x150;
11843
WriteParams.usWriteData = 0x0001;
11847
WriteParams.usWriteData = 0x0000;
11850
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11851
if ( ulResult != cOCT6100_ERR_OK )
11854
WriteParams.ulWriteAddress = 0x152;
11855
WriteParams.usWriteData = (UINT16)( 0x8000 | ( i + 8 ));
11857
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11858
if ( ulResult != cOCT6100_ERR_OK )
11862
/* Clear memory access registers: */
11863
WriteParams.ulWriteAddress = 0x150;
11864
WriteParams.usWriteData = 0x0000;
11866
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11867
if ( ulResult != cOCT6100_ERR_OK )
11870
WriteParams.ulWriteAddress = 0x152;
11872
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11873
if ( ulResult != cOCT6100_ERR_OK )
11876
/* Run BISTs and key decode. */
11877
WriteParams.ulWriteAddress = 0x160;
11878
WriteParams.usWriteData = 0x0081;
11880
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11881
if ( ulResult != cOCT6100_ERR_OK )
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;
11889
/* Read the key valid bit to make sure everything is ok. */
11890
ReadParams.ulReadAddress = 0x160;
11891
ReadParams.pusReadData = &usReadData;
11893
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
11894
if ( ulResult != cOCT6100_ERR_OK )
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;
11902
/* Read the result of the internal memory bist. */
11903
ReadParams.ulReadAddress = 0x110;
11904
ReadParams.pusReadData = &ausBistData[ 0 ];
11906
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
11907
if ( ulResult != cOCT6100_ERR_OK )
11910
ReadParams.ulReadAddress = 0x114;
11911
ReadParams.pusReadData = &ausBistData[ 1 ];
11913
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
11914
if ( ulResult != cOCT6100_ERR_OK )
11917
ReadParams.ulReadAddress = 0x118;
11918
ReadParams.pusReadData = &ausBistData[ 2 ];
11920
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
11921
if ( ulResult != cOCT6100_ERR_OK )
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;
11928
/* Put key decoder in powerdown. */
11929
WriteParams.ulWriteAddress = 0x160;
11930
WriteParams.usWriteData = 0x008A;
11932
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
11933
if ( ulResult != cOCT6100_ERR_OK )
11936
return cOCT6100_ERR_OK;
11940
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
11942
Function: Oct6100ApiBootFc2Pll
11944
Description: Configures the chip's FC2 PLL.
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.
11952
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
11953
static UINT32 Oct6100ApiBootFc2Pll(
11954
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
11956
tPOCT6100_SHARED_INFO pSharedInfo;
11957
tPOCT6100_API_CHIP_CONFIG pChipConfig;
11958
tOCT6100_WRITE_PARAMS WriteParams;
11959
UINT32 aulWaitTime[ 2 ];
11961
UINT32 ulFc2PllDivisor = 0;
11962
UINT32 ulMtDivisor = 0;
11963
UINT32 ulFcDivisor = 0;
11965
/* Get local pointer to shared portion of instance. */
11966
pSharedInfo = f_pApiInstance->pSharedInfo;
11968
/* Obtain local pointer to chip configuration structure. */
11969
pChipConfig = &pSharedInfo->ChipConfig;
11971
/* Set the process context and user chip ID parameters once and for all. */
11972
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
11974
WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
11976
/* First put the chip and main registers in soft-reset. */
11977
WriteParams.ulWriteAddress = 0x100;
11978
WriteParams.usWriteData = 0x0;
11980
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
11981
if ( ulResult != cOCT6100_ERR_OK )
11984
/* Select register configuration based on the memory frequency. */
11985
switch ( f_pApiInstance->pSharedInfo->ChipConfig.ulMemClkFreq )
11988
ulFc2PllDivisor = 0x1050;
11989
ulMtDivisor = 0x4300;
11990
ulFcDivisor = 0x4043;
11991
pSharedInfo->MiscVars.usMaxNumberOfChannels = 672;
11992
pSharedInfo->MiscVars.usMaxH100Speed = 124;
11994
if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
11995
pSharedInfo->MiscVars.usTdmClkBoundary = 0x050B;
11997
pSharedInfo->MiscVars.usTdmClkBoundary = 0x0516;
12001
ulFc2PllDivisor = 0x0F50;
12002
ulMtDivisor = 0x4300;
12003
ulFcDivisor = 0x4043;
12004
pSharedInfo->MiscVars.usMaxNumberOfChannels = 624;
12005
pSharedInfo->MiscVars.usMaxH100Speed = 116;
12007
if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12008
pSharedInfo->MiscVars.usTdmClkBoundary = 0x04CA;
12010
pSharedInfo->MiscVars.usTdmClkBoundary = 0x04D4;
12014
ulFc2PllDivisor = 0x0E50;
12015
ulMtDivisor = 0x4300;
12016
ulFcDivisor = 0x4043;
12017
pSharedInfo->MiscVars.usMaxNumberOfChannels = 576;
12018
pSharedInfo->MiscVars.usMaxH100Speed = 108;
12020
if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12021
pSharedInfo->MiscVars.usTdmClkBoundary = 0x0489;
12023
pSharedInfo->MiscVars.usTdmClkBoundary = 0x0492;
12027
ulFc2PllDivisor = 0x0D50;
12028
ulMtDivisor = 0x4300;
12029
ulFcDivisor = 0x4043;
12030
pSharedInfo->MiscVars.usMaxNumberOfChannels = 528;
12031
pSharedInfo->MiscVars.usMaxH100Speed = 99;
12033
if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12034
pSharedInfo->MiscVars.usTdmClkBoundary = 0x0408;
12036
pSharedInfo->MiscVars.usTdmClkBoundary = 0x0410;
12040
ulFc2PllDivisor = 0x0C50;
12041
ulMtDivisor = 0x4300;
12042
ulFcDivisor = 0x4043;
12043
pSharedInfo->MiscVars.usMaxNumberOfChannels = 480;
12044
pSharedInfo->MiscVars.usMaxH100Speed = 91;
12046
if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12047
pSharedInfo->MiscVars.usTdmClkBoundary = 0x03C8;
12049
pSharedInfo->MiscVars.usTdmClkBoundary = 0x03D0;
12053
ulFc2PllDivisor = 0x0B50;
12054
ulMtDivisor = 0x4300;
12055
ulFcDivisor = 0x4043;
12056
pSharedInfo->MiscVars.usMaxNumberOfChannels = 432;
12057
pSharedInfo->MiscVars.usMaxH100Speed = 83;
12059
if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12060
pSharedInfo->MiscVars.usTdmClkBoundary = 0x0387;
12062
pSharedInfo->MiscVars.usTdmClkBoundary = 0x038E;
12066
ulFc2PllDivisor = 0x0A50;
12067
ulMtDivisor = 0x4300;
12068
ulFcDivisor = 0x4043;
12069
pSharedInfo->MiscVars.usMaxNumberOfChannels = 384;
12070
pSharedInfo->MiscVars.usMaxH100Speed = 74;
12072
if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12073
pSharedInfo->MiscVars.usTdmClkBoundary = 0x0346;
12075
pSharedInfo->MiscVars.usTdmClkBoundary = 0x034C;
12079
ulFc2PllDivisor = 0x0950;
12080
ulMtDivisor = 0x4200;
12081
ulFcDivisor = 0x4043;
12082
pSharedInfo->MiscVars.usMaxNumberOfChannels = 336;
12083
pSharedInfo->MiscVars.usMaxH100Speed = 64;
12085
if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
12086
pSharedInfo->MiscVars.usTdmClkBoundary = 0x0306;
12088
pSharedInfo->MiscVars.usTdmClkBoundary = 0x030C;
12092
return cOCT6100_ERR_FATAL_DB;
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;
12099
/* Setup delay chains. */
12100
if ( (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) )
12103
WriteParams.ulWriteAddress = 0x1B0;
12104
WriteParams.usWriteData = 0x1003;
12106
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12107
if ( ulResult != cOCT6100_ERR_OK )
12110
WriteParams.ulWriteAddress = 0x1B2;
12111
WriteParams.usWriteData = 0x0021;
12113
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12114
if ( ulResult != cOCT6100_ERR_OK )
12117
WriteParams.ulWriteAddress = 0x1B4;
12118
WriteParams.usWriteData = 0x4030;
12120
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12121
if ( ulResult != cOCT6100_ERR_OK )
12124
WriteParams.ulWriteAddress = 0x1B6;
12125
WriteParams.usWriteData = 0x0021;
12127
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12128
if ( ulResult != cOCT6100_ERR_OK )
12131
else /* if ( cOCT6100_MEM_TYPE_DDR == pChipConfig->byMemoryType ) */
12134
WriteParams.ulWriteAddress = 0x1B0;
12135
WriteParams.usWriteData = 0x201F;
12137
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12138
if ( ulResult != cOCT6100_ERR_OK )
12141
WriteParams.ulWriteAddress = 0x1B2;
12142
WriteParams.usWriteData = 0x0021;
12144
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12145
if ( ulResult != cOCT6100_ERR_OK )
12148
WriteParams.ulWriteAddress = 0x1B4;
12149
WriteParams.usWriteData = 0x1000;
12151
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12152
if ( ulResult != cOCT6100_ERR_OK )
12155
WriteParams.ulWriteAddress = 0x1B6;
12156
WriteParams.usWriteData = 0x0021;
12158
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12159
if ( ulResult != cOCT6100_ERR_OK )
12164
WriteParams.ulWriteAddress = 0x1B8;
12165
WriteParams.usWriteData = 0x1003;
12167
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12168
if ( ulResult != cOCT6100_ERR_OK )
12171
WriteParams.ulWriteAddress = 0x1BA;
12172
WriteParams.usWriteData = 0x0021;
12174
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12175
if ( ulResult != cOCT6100_ERR_OK )
12179
WriteParams.ulWriteAddress = 0x1BC;
12180
WriteParams.usWriteData = 0x1000;
12182
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12183
if ( ulResult != cOCT6100_ERR_OK )
12186
WriteParams.ulWriteAddress = 0x1BE;
12187
WriteParams.usWriteData = 0x0021;
12189
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12190
if ( ulResult != cOCT6100_ERR_OK )
12193
WriteParams.ulWriteAddress = 0x12C;
12194
WriteParams.usWriteData = 0x0000;
12196
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12197
if ( ulResult != cOCT6100_ERR_OK )
12200
WriteParams.ulWriteAddress = 0x12E;
12201
WriteParams.usWriteData = 0x0000;
12203
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12204
if ( ulResult != cOCT6100_ERR_OK )
12207
/* Select fc2pll for fast_clk and mtsclk sources. Select mem_clk_i for afclk. */
12208
WriteParams.ulWriteAddress = 0x140;
12209
WriteParams.usWriteData = (UINT16)ulMtDivisor;
12211
if ( f_pApiInstance->pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
12212
WriteParams.usWriteData |= 0x0001;
12214
WriteParams.usWriteData |= 0x0004;
12216
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12217
if ( ulResult != cOCT6100_ERR_OK )
12220
WriteParams.ulWriteAddress = 0x144;
12221
WriteParams.usWriteData = (UINT16)ulFcDivisor;
12223
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12224
if ( ulResult != cOCT6100_ERR_OK )
12227
WriteParams.ulWriteAddress = 0x13E;
12228
WriteParams.usWriteData = 0x0001; /* Remove reset from above divisors */
12230
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12231
if ( ulResult != cOCT6100_ERR_OK )
12234
/* Select upclk directly as ref source for fc2pll. */
12235
WriteParams.ulWriteAddress = 0x134;
12236
if ( pChipConfig->ulUpclkFreq == cOCT6100_UPCLK_FREQ_33_33_MHZ )
12238
WriteParams.usWriteData = 0x0001;
12240
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12241
if ( ulResult != cOCT6100_ERR_OK )
12245
/* Setup fc2pll. */
12246
WriteParams.ulWriteAddress = 0x132;
12247
WriteParams.usWriteData = (UINT16)ulFc2PllDivisor;
12249
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12250
if ( ulResult != cOCT6100_ERR_OK )
12253
WriteParams.usWriteData |= 0x02; /* Raise fb divisor reset. */
12254
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12255
if ( ulResult != cOCT6100_ERR_OK )
12258
WriteParams.usWriteData |= 0x80; /* Raise IDDTN signal.*/
12259
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12260
if ( ulResult != cOCT6100_ERR_OK )
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 )
12270
/* Drive mem_clk_o out on proper interface. */
12271
if ( TRUE == pChipConfig->fEnableMemClkOut )
12273
if ( (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) )
12275
WriteParams.ulWriteAddress = 0x128;
12276
WriteParams.usWriteData = 0x0301;
12278
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12279
if ( ulResult != cOCT6100_ERR_OK )
12283
if ( pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_DDR || pChipConfig->byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
12285
WriteParams.ulWriteAddress = 0x12A;
12286
WriteParams.usWriteData = 0x000F;
12288
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12289
if ( ulResult != cOCT6100_ERR_OK )
12294
return cOCT6100_ERR_OK;
12298
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12300
Function: Oct6100ApiProgramFc1Pll
12302
Description: Configures the chip's FC1 PLL.
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.
12310
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12311
static UINT32 Oct6100ApiProgramFc1Pll(
12312
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
12314
tPOCT6100_SHARED_INFO pSharedInfo;
12315
tPOCT6100_API_CHIP_CONFIG pChipConfig;
12316
tOCT6100_WRITE_PARAMS WriteParams;
12317
UINT32 aulWaitTime[ 2 ];
12320
/* Get local pointer to shared portion of instance. */
12321
pSharedInfo = f_pApiInstance->pSharedInfo;
12323
/* Obtain local pointer to chip configuration structure. */
12324
pChipConfig = &pSharedInfo->ChipConfig;
12326
/* Set the process context and user chip ID parameters once and for all. */
12327
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
12329
WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
12331
/* Programm P/Z bits. */
12332
WriteParams.ulWriteAddress = 0x130;
12334
if ( f_pApiInstance->pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS )
12335
WriteParams.usWriteData = 0x0041;
12337
WriteParams.usWriteData = 0x0040;
12339
WriteParams.usWriteData |= ( pChipConfig->byMemoryType << 8 );
12341
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12342
if ( ulResult != cOCT6100_ERR_OK )
12345
/* Raise FB divisor. */
12346
WriteParams.usWriteData |= 0x0002;
12348
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12349
if ( ulResult != cOCT6100_ERR_OK )
12353
WriteParams.usWriteData |= 0x0080;
12355
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12356
if ( ulResult != cOCT6100_ERR_OK )
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 )
12366
/* Enable all the clock domains to do reset procedure. */
12367
WriteParams.ulWriteAddress = 0x186;
12368
WriteParams.usWriteData = 0x015F;
12370
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12371
if ( ulResult != cOCT6100_ERR_OK )
12374
aulWaitTime[ 0 ] = 15000;
12375
aulWaitTime[ 1 ] = 0;
12376
ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12377
if ( ulResult != cOCT6100_ERR_OK )
12380
return cOCT6100_ERR_OK;
12384
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12386
Function: Oct6100ApiBootFc1Pll
12388
Description: Boot the chip's FC1 PLL.
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.
12396
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12397
static UINT32 Oct6100ApiBootFc1Pll(
12398
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
12400
tPOCT6100_SHARED_INFO pSharedInfo;
12401
tPOCT6100_API_CHIP_CONFIG pChipConfig;
12402
tOCT6100_WRITE_PARAMS WriteParams;
12403
UINT32 aulWaitTime[ 2 ];
12406
/* Get local pointer to shared portion of instance. */
12407
pSharedInfo = f_pApiInstance->pSharedInfo;
12409
/* Obtain local pointer to chip configuration structure. */
12410
pChipConfig = &pSharedInfo->ChipConfig;
12412
/* Set the process context and user chip ID parameters once and for all. */
12413
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
12415
WriteParams.ulUserChipId = pChipConfig->ulUserChipId;
12417
/* Force bist_clk also (it too is used on resetable flops). */
12418
WriteParams.ulWriteAddress = 0x160;
12419
WriteParams.usWriteData = 0x0188;
12421
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12422
if ( ulResult != cOCT6100_ERR_OK )
12425
/* Force all cpu clocks on chariot controllers. */
12426
WriteParams.ulWriteAddress = 0x182;
12427
WriteParams.usWriteData = 0x0002;
12429
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12430
if ( ulResult != cOCT6100_ERR_OK )
12433
WriteParams.ulWriteAddress = 0x184;
12434
WriteParams.usWriteData = 0x0202;
12436
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12437
if ( ulResult != cOCT6100_ERR_OK )
12440
aulWaitTime[ 0 ] = 1000;
12441
aulWaitTime[ 1 ] = 0;
12442
ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12443
if ( ulResult != cOCT6100_ERR_OK )
12446
/* Remove the reset on the entire chip and disable CPU access caching. */
12447
WriteParams.ulWriteAddress = 0x100;
12448
WriteParams.usWriteData = 0x2003;
12450
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12451
if ( ulResult != cOCT6100_ERR_OK )
12454
/* Remove the bist_clk. It is no longer needed.*/
12455
WriteParams.ulWriteAddress = 0x160;
12456
WriteParams.usWriteData = 0x0088;
12458
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12459
if ( ulResult != cOCT6100_ERR_OK )
12462
/* Disable all clks to prepare for bist clock switchover. */
12463
WriteParams.ulWriteAddress = 0x182;
12464
WriteParams.usWriteData = 0x0001;
12466
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12467
if ( ulResult != cOCT6100_ERR_OK )
12470
WriteParams.ulWriteAddress = 0x186;
12471
WriteParams.usWriteData = 0x0000;
12473
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12474
if ( ulResult != cOCT6100_ERR_OK )
12477
WriteParams.ulWriteAddress = 0x184;
12478
WriteParams.usWriteData = 0x0101;
12480
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12481
if ( ulResult != cOCT6100_ERR_OK )
12484
ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12485
if ( ulResult != cOCT6100_ERR_OK )
12488
/* Deassert bist_active */
12489
WriteParams.ulWriteAddress = 0x160;
12490
WriteParams.usWriteData = 0x0008;
12492
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12493
if ( ulResult != cOCT6100_ERR_OK )
12496
/* Change CPU interface to normal mode (from boot mode). */
12497
WriteParams.ulWriteAddress = 0x154;
12498
WriteParams.usWriteData = 0x0000;
12500
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12501
if ( ulResult != cOCT6100_ERR_OK )
12504
ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12505
if ( ulResult != cOCT6100_ERR_OK )
12508
/* Give a couple of BIST clock cycles to turn off the BIST permanently. */
12509
WriteParams.ulWriteAddress = 0x160;
12510
WriteParams.usWriteData = 0x0108;
12512
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12513
if ( ulResult != cOCT6100_ERR_OK )
12516
ulResult = Oct6100ApiWaitForTime( f_pApiInstance, aulWaitTime );
12517
if ( ulResult != cOCT6100_ERR_OK )
12520
/* Turn BIST clock off for the last time. */
12521
WriteParams.ulWriteAddress = 0x160;
12522
WriteParams.usWriteData = 0x0008;
12524
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12525
if ( ulResult != cOCT6100_ERR_OK )
12528
/* Reset procedure done! */
12530
/* Enable mclk for cpu interface and external memory controller. */
12531
WriteParams.ulWriteAddress = 0x186;
12532
WriteParams.usWriteData = 0x0100;
12534
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12535
if ( ulResult != cOCT6100_ERR_OK )
12538
return cOCT6100_ERR_OK;
12542
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12544
Function: Oct6100ApiLoadImage
12546
Description: This function writes the firmware image in the external memory.
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.
12554
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12555
static UINT32 Oct6100ApiLoadImage(
12556
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
12558
tPOCT6100_SHARED_INFO pSharedInfo;
12559
tOCT6100_WRITE_BURST_PARAMS BurstParams;
12560
tOCT6100_READ_PARAMS ReadParams;
12563
UINT32 ulNumWrites;
12564
PUINT16 pusSuperArray;
12565
PUINT8 pbyImageFile;
12566
UINT32 ulByteCount = 0;
12568
UINT32 ulAddressOfst;
12571
/* Get local pointer to shared portion of instance. */
12572
pSharedInfo = f_pApiInstance->pSharedInfo;
12574
/* Set the process context and user chip ID parameters once and for all. */
12575
BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
12577
BurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12579
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
12581
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12582
ReadParams.pusReadData = &usReadData;
12584
/* Breakdown image into subcomponents. */
12585
ulTempPtr = cOCT6100_IMAGE_FILE_BASE + cOCT6100_IMAGE_AF_CST_OFFSET;
12587
for(i=0;i<cOCT6100_MAX_IMAGE_REGION;i++)
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 ];
12594
if (i == 0) /* AF constant. */
12596
pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF;
12597
pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = 0;
12599
ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 612 );
12601
else if (i == 1) /* NLP image */
12603
pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF;
12604
pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = 0;
12606
ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 2056 );
12610
pSharedInfo->ImageRegion[ i ].ulPart1BaseAddress = ulTempPtr & 0x07FFFFFF;
12611
ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart1Size * 2064 );
12613
pSharedInfo->ImageRegion[ i ].ulPart2BaseAddress = ulTempPtr & 0x07FFFFFF;
12614
ulTempPtr += ( pSharedInfo->ImageRegion[ i ].ulPart2Size * 2448 );
12618
/* Write the image in external memory. */
12619
ulNumWrites = pSharedInfo->ChipConfig.ulImageSize / 2;
12621
BurstParams.ulWriteAddress = cOCT6100_IMAGE_FILE_BASE;
12622
BurstParams.pusWriteData = pSharedInfo->MiscVars.ausSuperArray;
12624
pusSuperArray = pSharedInfo->MiscVars.ausSuperArray;
12625
pbyImageFile = pSharedInfo->ChipConfig.pbyImageFile;
12627
while ( ulNumWrites != 0 )
12629
if ( ulNumWrites >= pSharedInfo->ChipConfig.usMaxRwAccesses )
12630
BurstParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
12632
BurstParams.ulWriteLength = ulNumWrites;
12634
for ( i = 0; i < BurstParams.ulWriteLength; i++ )
12636
pusSuperArray[ i ] = ( UINT16 )(( pbyImageFile [ ulByteCount++ ]) << 8);
12637
pusSuperArray[ i ] |= ( UINT16 )pbyImageFile [ ulByteCount++ ];
12640
mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult )
12641
if ( ulResult != cOCT6100_ERR_OK )
12644
BurstParams.ulWriteAddress += 2 * BurstParams.ulWriteLength;
12645
ulNumWrites -= BurstParams.ulWriteLength;
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 )
12652
ReadParams.ulReadAddress = cOCT6100_IMAGE_FILE_BASE + ulAddressOfst;
12654
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
12655
if ( ulResult != cOCT6100_ERR_OK )
12658
if ( (usReadData >> 8) != pbyImageFile[ ulAddressOfst ] )
12659
return cOCT6100_ERR_OPEN_IMAGE_WRITE_FAILED;
12661
ulAddressOfst = (ulAddressOfst / 2) & 0xFFFFFFFE;
12664
return cOCT6100_ERR_OK;
12668
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12670
Function: Oct6100ApiCpuRegisterBist
12672
Description: Tests the operation of the CPU registers.
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.
12680
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12681
static UINT32 Oct6100ApiCpuRegisterBist(
12682
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
12684
tPOCT6100_SHARED_INFO pSharedInfo;
12685
tOCT6100_WRITE_PARAMS WriteParams;
12686
tOCT6100_READ_PARAMS ReadParams;
12691
/* Get local pointer to shared portion of instance. */
12692
pSharedInfo = f_pApiInstance->pSharedInfo;
12694
/* Set the process context and user chip ID parameters once and for all. */
12695
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
12697
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12699
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
12701
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12703
/* Assign read data pointer that will be used throughout the function. */
12704
ReadParams.pusReadData = &usReadData;
12706
/* Start with a walking bit test. */
12707
for ( i = 0; i < 16; i ++ )
12709
/* Write at address 0x150.*/
12710
WriteParams.ulWriteAddress = 0x150;
12711
WriteParams.usWriteData = (UINT16)( 0x1 << i );
12713
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12714
if ( ulResult != cOCT6100_ERR_OK )
12717
/* Write at address 0x180.*/
12718
WriteParams.ulWriteAddress = 0x180;
12719
WriteParams.usWriteData = (UINT16)( 0x1 << ( 15 - i ) );
12721
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12722
if ( ulResult != cOCT6100_ERR_OK )
12725
/* Now read back the two registers to make sure the acceses were successfull. */
12726
ReadParams.ulReadAddress = 0x150;
12728
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
12729
if ( ulResult != cOCT6100_ERR_OK )
12732
if ( usReadData != ( 0x1 << i ) )
12733
return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
12735
ReadParams.ulReadAddress = 0x180;
12737
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
12738
if ( ulResult != cOCT6100_ERR_OK )
12741
if ( usReadData != ( 0x1 << ( 15 - i ) ) )
12742
return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
12745
/* Write at address 0x150. */
12746
WriteParams.ulWriteAddress = 0x150;
12747
WriteParams.usWriteData = 0xCAFE;
12749
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12750
if ( ulResult != cOCT6100_ERR_OK )
12753
/* Write at address 0x180. */
12754
WriteParams.ulWriteAddress = 0x180;
12755
WriteParams.usWriteData = 0xDECA;
12757
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12758
if ( ulResult != cOCT6100_ERR_OK )
12761
/* Now read back the two registers to make sure the acceses were successfull. */
12762
ReadParams.ulReadAddress = 0x150;
12764
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
12765
if ( ulResult != cOCT6100_ERR_OK )
12768
if ( usReadData != 0xCAFE )
12769
return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
12771
ReadParams.ulReadAddress = 0x180;
12773
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
12774
if ( ulResult != cOCT6100_ERR_OK )
12777
if ( usReadData != 0xDECA )
12778
return cOCT6100_ERR_OPEN_CPU_REG_BIST_ERROR;
12780
return cOCT6100_ERR_OK;
12784
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
12786
Function: Oct6100ApiBootSdram
12788
Description: Configure and test the SDRAM.
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.
12796
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
12797
static UINT32 Oct6100ApiBootSdram(
12798
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
12800
tPOCT6100_SHARED_INFO pSharedInfo;
12801
tPOCT6100_API_CHIP_CONFIG pChipConfig;
12802
tOCT6100_WRITE_PARAMS WriteParams;
12803
tOCT6100_READ_PARAMS ReadParams;
12806
UINT16 usWriteData23E;
12807
UINT16 usWriteData230;
12810
/* Get local pointer to shared portion of instance. */
12811
pSharedInfo = f_pApiInstance->pSharedInfo;
12813
/* Get local pointer to the chip configuration structure.*/
12814
pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
12816
/* Set the process context and user chip ID parameters once and for all. */
12817
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
12819
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12821
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
12823
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
12824
ReadParams.pusReadData = &usReadData;
12826
usWriteData23E = 0x0000;
12827
usWriteData230 = 0x0000;
12829
if ( (pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR) || (pSharedInfo->ChipConfig.byMemoryType == cOCT6100_MEM_TYPE_SDR_PLL_BYPASS) )
12832
switch( pChipConfig->ulMemoryChipSize )
12834
case cOCT6100_MEMORY_CHIP_SIZE_8MB:
12835
usWriteData230 |= ( cOCT6100_16MB_MEMORY_BANKS << 2 );
12837
case cOCT6100_MEMORY_CHIP_SIZE_16MB:
12838
usWriteData230 |= ( cOCT6100_32MB_MEMORY_BANKS << 2 );
12840
case cOCT6100_MEMORY_CHIP_SIZE_32MB:
12841
usWriteData230 |= ( cOCT6100_64MB_MEMORY_BANKS << 2 );
12843
case cOCT6100_MEMORY_CHIP_SIZE_64MB:
12844
usWriteData230 |= ( cOCT6100_128MB_MEMORY_BANKS << 2 );
12847
return cOCT6100_ERR_FATAL_16;
12849
WriteParams.ulWriteAddress = 0x230;
12850
WriteParams.usWriteData = usWriteData230;
12852
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12853
if ( ulResult != cOCT6100_ERR_OK )
12856
/* Precharge all banks. */
12857
usWriteData230 &= 0x000C;
12858
usWriteData230 |= 0x0010;
12860
WriteParams.ulWriteAddress = 0x230;
12861
WriteParams.usWriteData = usWriteData230;
12863
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12864
if ( ulResult != cOCT6100_ERR_OK )
12867
usWriteData230 |= 0x0002;
12869
WriteParams.usWriteData = usWriteData230;
12871
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12872
if ( ulResult != cOCT6100_ERR_OK )
12875
WriteParams.ulWriteAddress = 0x23E;
12876
WriteParams.usWriteData = usWriteData23E;
12877
for ( i = 0; i < 5; i++ )
12880
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12881
if ( ulResult != cOCT6100_ERR_OK )
12885
/* Program the mode register. */
12886
usWriteData23E = 0x0030;
12887
WriteParams.usWriteData = usWriteData23E;
12889
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12890
if ( ulResult != cOCT6100_ERR_OK )
12893
usWriteData230 &= 0x000C;
12894
usWriteData230 |= 0x0000;
12896
WriteParams.ulWriteAddress = 0x230;
12897
WriteParams.usWriteData = usWriteData230;
12899
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12900
if ( ulResult != cOCT6100_ERR_OK )
12903
usWriteData230 |= 0x0002;
12905
WriteParams.usWriteData = usWriteData230;
12907
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12908
if ( ulResult != cOCT6100_ERR_OK )
12911
WriteParams.ulWriteAddress = 0x23E;
12912
WriteParams.usWriteData = usWriteData23E;
12913
for ( i = 0; i < 5; i++ )
12916
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12917
if ( ulResult != cOCT6100_ERR_OK )
12921
/* Do CBR refresh (twice) */
12922
usWriteData230 &= 0x000C;
12923
usWriteData230 |= 0x0040;
12925
WriteParams.ulWriteAddress = 0x230;
12926
WriteParams.usWriteData = usWriteData230;
12928
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12929
if ( ulResult != cOCT6100_ERR_OK )
12932
usWriteData230 |= 0x0002;
12934
WriteParams.usWriteData = usWriteData230;
12936
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12937
if ( ulResult != cOCT6100_ERR_OK )
12940
WriteParams.ulWriteAddress = 0x23E;
12941
WriteParams.usWriteData = usWriteData23E;
12942
for ( i = 0; i < 5; i++ )
12945
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12946
if ( ulResult != cOCT6100_ERR_OK )
12950
WriteParams.ulWriteAddress = 0x230;
12951
WriteParams.usWriteData = usWriteData230;
12953
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12954
if ( ulResult != cOCT6100_ERR_OK )
12957
WriteParams.ulWriteAddress = 0x23E;
12958
WriteParams.usWriteData = usWriteData23E;
12959
for ( i = 0; i < 5; i++ )
12962
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12963
if ( ulResult != cOCT6100_ERR_OK )
12970
switch( pChipConfig->ulMemoryChipSize )
12972
case cOCT6100_MEMORY_CHIP_SIZE_16MB:
12973
usWriteData230 |= ( cOCT6100_16MB_MEMORY_BANKS << 2 );
12975
case cOCT6100_MEMORY_CHIP_SIZE_32MB:
12976
usWriteData230 |= ( cOCT6100_32MB_MEMORY_BANKS << 2 );
12978
case cOCT6100_MEMORY_CHIP_SIZE_64MB:
12979
usWriteData230 |= ( cOCT6100_64MB_MEMORY_BANKS << 2 );
12981
case cOCT6100_MEMORY_CHIP_SIZE_128MB:
12982
usWriteData230 |= ( cOCT6100_128MB_MEMORY_BANKS << 2 );
12985
return cOCT6100_ERR_FATAL_17;
12987
WriteParams.ulWriteAddress = 0x230;
12988
WriteParams.usWriteData = usWriteData230;
12990
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
12991
if ( ulResult != cOCT6100_ERR_OK )
12994
/* Precharge all banks. */
12995
usWriteData230 &= 0x000C;
12996
usWriteData230 |= 0x0010;
12998
WriteParams.ulWriteAddress = 0x230;
12999
WriteParams.usWriteData = usWriteData230;
13001
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13002
if ( ulResult != cOCT6100_ERR_OK )
13005
usWriteData230 |= 0x0002;
13007
WriteParams.usWriteData = usWriteData230;
13009
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13010
if ( ulResult != cOCT6100_ERR_OK )
13013
WriteParams.ulWriteAddress = 0x23E;
13014
WriteParams.usWriteData = usWriteData23E;
13015
for ( i = 0; i < 5; i++ )
13018
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13019
if ( ulResult != cOCT6100_ERR_OK )
13023
/* Program DDR mode register. */
13024
usWriteData23E = 0x4000;
13026
WriteParams.ulWriteAddress = 0x23E;
13027
WriteParams.usWriteData = usWriteData23E;
13029
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13030
if ( ulResult != cOCT6100_ERR_OK )
13033
usWriteData230 &= 0x000C;
13034
usWriteData230 |= 0x0000;
13036
WriteParams.ulWriteAddress = 0x230;
13037
WriteParams.usWriteData = usWriteData230;
13039
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13040
if ( ulResult != cOCT6100_ERR_OK )
13043
usWriteData230 |= 0x0002;
13045
WriteParams.usWriteData = usWriteData230;
13047
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13048
if ( ulResult != cOCT6100_ERR_OK )
13051
WriteParams.ulWriteAddress = 0x23E;
13052
WriteParams.usWriteData = usWriteData23E;
13053
for ( i = 0; i < 5; i++ )
13056
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13057
if ( ulResult != cOCT6100_ERR_OK )
13061
/* Program SDR mode register. */
13062
usWriteData23E = 0x0161;
13064
WriteParams.ulWriteAddress = 0x23E;
13065
WriteParams.usWriteData = usWriteData23E;
13067
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13068
if ( ulResult != cOCT6100_ERR_OK )
13071
usWriteData230 &= 0x000C;
13072
usWriteData230 |= 0x0000;
13074
WriteParams.ulWriteAddress = 0x230;
13075
WriteParams.usWriteData = usWriteData230;
13077
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13078
if ( ulResult != cOCT6100_ERR_OK )
13081
usWriteData230 |= 0x0002;
13083
WriteParams.usWriteData = usWriteData230;
13085
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13086
if ( ulResult != cOCT6100_ERR_OK )
13089
WriteParams.ulWriteAddress = 0x23E;
13090
WriteParams.usWriteData = usWriteData23E;
13091
for ( i = 0; i < 5; i++ )
13094
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13095
if ( ulResult != cOCT6100_ERR_OK )
13099
/* Precharge all banks. */
13100
usWriteData23E = 0xFFFF;
13102
WriteParams.ulWriteAddress = 0x23E;
13103
WriteParams.usWriteData = usWriteData23E;
13105
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13106
if ( ulResult != cOCT6100_ERR_OK )
13109
usWriteData230 &= 0x000C;
13110
usWriteData230 |= 0x0010;
13112
WriteParams.ulWriteAddress = 0x230;
13113
WriteParams.usWriteData = usWriteData230;
13115
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13116
if ( ulResult != cOCT6100_ERR_OK )
13119
usWriteData230 |= 0x0002;
13121
WriteParams.usWriteData = usWriteData230;
13123
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13124
if ( ulResult != cOCT6100_ERR_OK )
13127
WriteParams.ulWriteAddress = 0x23E;
13128
WriteParams.usWriteData = usWriteData23E;
13129
for ( i = 0; i < 5; i++ )
13132
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13133
if ( ulResult != cOCT6100_ERR_OK )
13137
/* Do CBR refresh (twice) */
13138
usWriteData230 &= 0x000C;
13139
usWriteData230 |= 0x0040;
13141
WriteParams.ulWriteAddress = 0x230;
13142
WriteParams.usWriteData = usWriteData230;
13144
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13145
if ( ulResult != cOCT6100_ERR_OK )
13148
usWriteData230 |= 0x0002;
13150
WriteParams.usWriteData = usWriteData230;
13152
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13153
if ( ulResult != cOCT6100_ERR_OK )
13156
WriteParams.ulWriteAddress = 0x23E;
13157
WriteParams.usWriteData = usWriteData23E;
13158
for ( i = 0; i < 5; i++ )
13161
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13162
if ( ulResult != cOCT6100_ERR_OK )
13166
WriteParams.ulWriteAddress = 0x230;
13167
WriteParams.usWriteData = usWriteData230;
13169
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13170
if ( ulResult != cOCT6100_ERR_OK )
13173
WriteParams.ulWriteAddress = 0x23E;
13174
WriteParams.usWriteData = usWriteData23E;
13175
for ( i = 0; i < 5; i++ )
13178
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13179
if ( ulResult != cOCT6100_ERR_OK )
13183
/* Program SDR mode register. */
13184
usWriteData23E = 0x0061;
13186
WriteParams.ulWriteAddress = 0x23E;
13187
WriteParams.usWriteData = usWriteData23E;
13189
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13190
if ( ulResult != cOCT6100_ERR_OK )
13193
usWriteData230 &= 0x000C;
13194
usWriteData230 |= 0x0000;
13196
WriteParams.ulWriteAddress = 0x230;
13197
WriteParams.usWriteData = usWriteData230;
13199
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13200
if ( ulResult != cOCT6100_ERR_OK )
13203
usWriteData230 |= 0x0002;
13205
WriteParams.usWriteData = usWriteData230;
13207
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13208
if ( ulResult != cOCT6100_ERR_OK )
13211
WriteParams.ulWriteAddress = 0x23E;
13212
WriteParams.usWriteData = usWriteData23E;
13213
for ( i = 0; i < 5; i++ )
13216
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13217
if ( ulResult != cOCT6100_ERR_OK )
13222
/* Set the refresh frequency. */
13223
WriteParams.ulWriteAddress = 0x242;
13224
WriteParams.usWriteData = 0x0400;
13226
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13227
if ( ulResult != cOCT6100_ERR_OK )
13230
WriteParams.ulWriteAddress = 0x244;
13231
WriteParams.usWriteData = 0x0200;
13233
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13234
if ( ulResult != cOCT6100_ERR_OK )
13237
WriteParams.ulWriteAddress = 0x248;
13238
WriteParams.usWriteData = 0x800;
13240
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13241
if ( ulResult != cOCT6100_ERR_OK )
13244
WriteParams.ulWriteAddress = 0x246;
13245
WriteParams.usWriteData = 0x0012;
13247
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13248
if ( ulResult != cOCT6100_ERR_OK )
13251
/* Enable the SDRAM and refreshes. */
13252
usWriteData230 &= 0x000C;
13253
usWriteData230 |= 0x0001;
13255
WriteParams.ulWriteAddress = 0x230;
13256
WriteParams.usWriteData = usWriteData230;
13258
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13259
if ( ulResult != cOCT6100_ERR_OK )
13262
WriteParams.ulWriteAddress = 0x246;
13263
WriteParams.usWriteData = 0x0013;
13265
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13266
if ( ulResult != cOCT6100_ERR_OK )
13269
return cOCT6100_ERR_OK;
13273
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13275
Function: Oct6100ApiEnableClocks
13277
Description: This function will disable clock masking for all the modules
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.
13286
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13287
static UINT32 Oct6100ApiEnableClocks(
13288
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
13290
tOCT6100_WRITE_PARAMS WriteParams;
13293
/* Initialize the process context and user chip ID once and for all. */
13294
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13296
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
13298
/* Enable tdmie / adpcm mclk clocks. */
13299
WriteParams.ulWriteAddress = 0x186;
13300
WriteParams.usWriteData = 0x015F;
13302
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13303
if ( ulResult != cOCT6100_ERR_OK )
13306
/* Configure the DQS register for the DDR memory */
13307
WriteParams.ulWriteAddress = 0x180;
13308
WriteParams.usWriteData = 0xFF00;
13310
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13311
if ( ulResult != cOCT6100_ERR_OK )
13314
/* Enable pgsp chariot clocks */
13315
WriteParams.ulWriteAddress = 0x182;
13316
WriteParams.usWriteData = 0x0000;
13318
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13319
if ( ulResult != cOCT6100_ERR_OK )
13322
/* Enable af/mt chariot clocks */
13323
WriteParams.ulWriteAddress = 0x184;
13324
WriteParams.usWriteData = 0x0000;
13326
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13327
if ( ulResult != cOCT6100_ERR_OK )
13330
return cOCT6100_ERR_OK;
13334
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13336
Function: Oct6100ApiProgramNLP
13338
Description: This function will write image values to configure the NLP.
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.
13346
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13347
static UINT32 Oct6100ApiProgramNLP(
13348
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
13350
tOCT6100_WRITE_PARAMS WriteParams;
13351
tOCT6100_READ_PARAMS ReadParams;
13352
tPOCT6100_SHARED_INFO pSharedInfo;
13353
tPOCT6100_API_CHIP_CONFIG pChipConfig;
13356
UINT16 usReadHighData;
13358
UINT32 ulEgoEntry[4];
13359
UINT32 ulTempAddress;
13360
UINT32 ulAfCpuUp = FALSE;
13362
UINT32 ulLoopCounter = 0;
13364
/* Get local pointer to shared portion of instance. */
13365
pSharedInfo = f_pApiInstance->pSharedInfo;
13367
/* Get local pointer to the chip configuration structure.*/
13368
pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
13370
/* Initialize the process context and user chip ID once and for all. */
13371
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13373
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
13375
/* Initialize the process context and user chip ID once and for all. */
13376
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
13378
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
13379
ReadParams.pusReadData = &usReadData;
13381
if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
13384
UINT32 ulBitPattern;
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 ++ )
13392
ulBitPattern = 0x1;
13394
ulBitPattern = 0xFFFFFFFE;
13396
for ( j = 0; j < 32; j ++ )
13398
/* Write the DWORDs. */
13399
for ( i = 0; i < 64; i ++ )
13401
ulResult = Oct6100ApiWriteDword( f_pApiInstance, cOCT6100_POUCH_BASE + i * 4, ulBitPattern << j );
13402
if ( ulResult != cOCT6100_ERR_OK )
13406
/* Read the DWORDs. */
13407
for ( i = 0; i < 64; i ++ )
13409
ulResult = Oct6100ApiReadDword( f_pApiInstance, cOCT6100_POUCH_BASE + i * 4, &ulReadData );
13410
if ( ulResult != cOCT6100_ERR_OK )
13413
/* Check if the value matches. */
13414
if ( ( ulBitPattern << j ) != ulReadData )
13415
return cOCT6100_ERR_OPEN_PRODUCTION_BIST_POUCH_ERROR;
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 );
13425
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13426
if ( ulResult != cOCT6100_ERR_OK )
13429
WriteParams.ulWriteAddress += 2;
13430
WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ 0 ].ulPart1BaseAddress & 0xFFFF );
13432
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13433
if ( ulResult != cOCT6100_ERR_OK )
13436
for( i = 0; i < 8; i++ )
13438
if ( pSharedInfo->ImageRegion[ i + 2 ].ulPart1Size != 0 )
13440
WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC );
13441
WriteParams.usWriteData = (UINT16)(( pSharedInfo->ImageRegion[ i + 2 ].ulPart1BaseAddress >> 16 ) & 0xFFFF );
13443
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13444
if ( ulResult != cOCT6100_ERR_OK )
13447
WriteParams.ulWriteAddress += 2;
13448
WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ i + 2 ].ulPart1BaseAddress & 0xFFFF );
13450
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13451
if ( ulResult != cOCT6100_ERR_OK )
13455
if ( pSharedInfo->ImageRegion[ i + 2 ].ulPart2Size != 0 )
13457
WriteParams.ulWriteAddress = cOCT6100_PART1_END_STATICS_BASE + 0x4 + ( i * 0xC ) + 4;
13458
WriteParams.usWriteData = (UINT16)(( pSharedInfo->ImageRegion[ i + 2 ].ulPart2BaseAddress >> 16 ) & 0xFFFF );
13460
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13461
if ( ulResult != cOCT6100_ERR_OK )
13464
WriteParams.ulWriteAddress += 2;
13465
WriteParams.usWriteData = (UINT16)( pSharedInfo->ImageRegion[ i + 2 ].ulPart2BaseAddress & 0xFFFF );
13467
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13468
if ( ulResult != cOCT6100_ERR_OK )
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;
13477
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13478
if ( ulResult != cOCT6100_ERR_OK )
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;
13486
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13487
if ( ulResult != cOCT6100_ERR_OK )
13491
/* Put NLP in config mode. */
13492
WriteParams.ulWriteAddress = 0x2C2;
13493
WriteParams.usWriteData = 0x160E;
13495
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13496
if ( ulResult != cOCT6100_ERR_OK )
13499
WriteParams.ulWriteAddress = 0x692;
13500
WriteParams.usWriteData = 0x010A;
13502
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13503
if ( ulResult != cOCT6100_ERR_OK )
13506
/* Upload the up to 8 NLP pages + 1 AF page (for timing reasons). */
13507
for ( i = 0; i < pSharedInfo->ImageRegion[ 1 ].ulPart1Size; i++ )
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 )
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 )
13517
ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
13518
if ( ulResult != cOCT6100_ERR_OK )
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;
13526
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13527
if ( ulResult != cOCT6100_ERR_OK )
13530
ulResult = Oct6100ApiWaitForPcRegisterBit( f_pApiInstance, 0x692, 0, 0, 100000, &fBitEqual );
13531
if ( ulResult != cOCT6100_ERR_OK )
13533
if ( TRUE != fBitEqual )
13534
return cOCT6100_ERR_FATAL_1A;
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 )
13542
ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 1), 0x1480, 512, &(ulEgoEntry[2]));
13543
if ( ulResult != cOCT6100_ERR_OK )
13546
ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
13547
if ( ulResult != cOCT6100_ERR_OK )
13550
ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 2), 0x1680, 512, &(ulEgoEntry[0]));
13551
if ( ulResult != cOCT6100_ERR_OK )
13554
ulResult = Oct6100ApiCreateEgoEntry( cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + pSharedInfo->ImageRegion[ 2 ].ulPart1BaseAddress + (516 * 3), 0x1880, 512, &(ulEgoEntry[2]));
13555
if ( ulResult != cOCT6100_ERR_OK )
13558
ulResult = Oct6100ApiRunEgo( f_pApiInstance, FALSE, 2, ulEgoEntry );
13559
if ( ulResult != cOCT6100_ERR_OK )
13562
/* Write constant memory init context position in channel "672" for pgsp. */
13563
WriteParams.ulWriteAddress = 0x71A;
13564
WriteParams.usWriteData = 0x8000;
13566
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13567
if ( ulResult != cOCT6100_ERR_OK )
13570
/* Set fixed PGSP event_in base address to 800 on a 2k boundary */
13571
WriteParams.ulWriteAddress = 0x716;
13572
WriteParams.usWriteData = 0x800 >> 11;
13574
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13575
if ( ulResult != cOCT6100_ERR_OK )
13578
/* Set fixed PGSP event_out to 0x2C0000h on a 16k boundary */
13579
WriteParams.ulWriteAddress = 0x71C;
13580
WriteParams.usWriteData = 0x2C0000 >> 14;
13582
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13583
if ( ulResult != cOCT6100_ERR_OK )
13586
/* Give chariot control of the chip. */
13587
WriteParams.ulWriteAddress = 0x712;
13588
WriteParams.usWriteData = 0x0000;
13590
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13591
if ( ulResult != cOCT6100_ERR_OK )
13594
WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x2C0000 + 0xC;
13595
ulTempAddress = 0x300000 + 0x0800;
13596
WriteParams.usWriteData = (UINT16)( ( ulTempAddress >> 16 ) & 0x07FF );
13598
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13599
if ( ulResult != cOCT6100_ERR_OK )
13602
WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x2C0000 + 0xE;
13603
WriteParams.usWriteData = (UINT16)( ( ulTempAddress >> 0 ) & 0xFF00 );
13605
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13606
if ( ulResult != cOCT6100_ERR_OK )
13609
/* Write the init PGSP event in place. */
13610
WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x800;
13611
WriteParams.usWriteData = 0x0200;
13613
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13614
if ( ulResult != cOCT6100_ERR_OK )
13617
WriteParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS + 0x802;
13618
WriteParams.usWriteData = 0x02A0;
13620
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13621
if ( ulResult != cOCT6100_ERR_OK )
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;
13630
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13631
if ( ulResult != cOCT6100_ERR_OK )
13634
/* Start both processors in the NLP. */
13635
WriteParams.ulWriteAddress = 0x373FE;
13636
WriteParams.usWriteData = 0x00FF;
13638
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13639
if ( ulResult != cOCT6100_ERR_OK )
13642
WriteParams.ulWriteAddress = 0x37BFE;
13643
WriteParams.usWriteData = 0x00FE; /* Tell processor 1 to just go to sleep. */
13645
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13646
if ( ulResult != cOCT6100_ERR_OK )
13649
WriteParams.ulWriteAddress = 0x37FC6;
13650
WriteParams.usWriteData = 0x8004; /* First PC.*/
13652
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13653
if ( ulResult != cOCT6100_ERR_OK )
13656
WriteParams.ulWriteAddress = 0x37FD0;
13657
WriteParams.usWriteData = 0x0002; /* Take out of reset. */
13659
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13660
if ( ulResult != cOCT6100_ERR_OK )
13663
WriteParams.ulWriteAddress = 0x37FD2;
13664
WriteParams.usWriteData = 0x0002; /* Take out of reset. */
13666
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13667
if ( ulResult != cOCT6100_ERR_OK )
13670
/* Start processor in the AF. */
13671
for ( i = 0; i < 16; i ++ )
13673
WriteParams.ulWriteAddress = cOCT6100_POUCH_BASE + ( i * 2 );
13676
if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
13678
WriteParams.usWriteData = cOCT6100_PRODUCTION_BOOT_TYPE;
13682
WriteParams.usWriteData = cOCT6100_AF_BOOT_TYPE;
13686
WriteParams.usWriteData = 0x0000;
13688
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13689
if ( ulResult != cOCT6100_ERR_OK )
13693
/* Check if the production BIST mode was requested. */
13694
if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
13696
UINT32 ulTotalElements = 3;
13698
UINT32 aulMessage[ 4 ];
13699
UINT32 ulWriteAddress = 0x20 + cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
13702
aulMessage[ 0 ] = 0xCAFECAFE;
13704
aulMessage[ 1 ] = pSharedInfo->MiscVars.ulTotalMemSize;
13706
aulMessage[ 2 ] = pSharedInfo->ChipConfig.ulNumProductionBistLoops;
13707
/* CRC initialized. */
13708
aulMessage[ 3 ] = 0;
13710
ulResult = Oct6100ApiProductionCrc( f_pApiInstance, aulMessage, ulTotalElements, &ulCrcKey );
13711
if ( ulResult != cOCT6100_ERR_OK )
13714
aulMessage[ 3 ] = ulCrcKey;
13716
/* Write the message to the external memory. */
13717
for ( i = 0; i < ulTotalElements + 1; i ++ )
13719
ulResult = Oct6100ApiWriteDword( f_pApiInstance, ulWriteAddress + i * 4, aulMessage[ i ] );
13720
if ( ulResult != cOCT6100_ERR_OK )
13725
WriteParams.ulWriteAddress = 0xFFFC6;
13726
WriteParams.usWriteData = 0x1284; /* First PC.*/
13728
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13729
if ( ulResult != cOCT6100_ERR_OK )
13732
WriteParams.ulWriteAddress = 0xFFFD0;
13733
WriteParams.usWriteData = 0x0002; /* Take out of reset. */
13735
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13736
if ( ulResult != cOCT6100_ERR_OK )
13739
while ( ulAfCpuUp == FALSE )
13741
if ( ulAfCpuUp == FALSE )
13743
ReadParams.ulReadAddress = cOCT6100_POUCH_BASE;
13744
ReadParams.pusReadData = &usReadHighData;
13746
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
13747
if ( ulResult != cOCT6100_ERR_OK )
13750
ReadParams.ulReadAddress += 2;
13751
ReadParams.pusReadData = &usReadData;
13753
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
13754
if ( ulResult != cOCT6100_ERR_OK )
13757
if ( pSharedInfo->ChipConfig.fEnableProductionBist == TRUE )
13759
/* Should read 0x0007 when bisting. */
13760
if ( ( usReadHighData & 0xFFFF ) == cOCT6100_PRODUCTION_BOOT_TYPE )
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;
13771
else /* if ( pSharedInfo->ChipConfig.fEnableProductionBist == FALSE ) */
13773
if ( ( usReadHighData & 0xFFFF ) == cOCT6100_AF_BOOT_TYPE )
13775
/* Verify if the bist succeeded. */
13776
if ( ( usReadData & 0xFFFF ) != 0x0000 )
13777
return cOCT6100_ERR_OPEN_FUNCTIONAL_BIST_FAILED; /* Bad chip. */
13786
if ( ulLoopCounter == cOCT6100_MAX_LOOP_CPU_TIMEOUT )
13787
return cOCT6100_ERR_OPEN_AF_CPU_TIMEOUT;
13790
/* Return NLP in operationnal mode. */
13791
WriteParams.ulWriteAddress = 0x2C2;
13792
WriteParams.usWriteData = 0x060E;
13794
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13795
if ( ulResult != cOCT6100_ERR_OK )
13798
WriteParams.ulWriteAddress = 0x692;
13799
WriteParams.usWriteData = 0x0000;
13801
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13802
if ( ulResult != cOCT6100_ERR_OK )
13805
return cOCT6100_ERR_OK;
13809
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
13811
Function: Oct6100ApiSetH100Register
13813
Description: This function will configure the H.100 registers.
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.
13821
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
13822
static UINT32 Oct6100ApiSetH100Register(
13823
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
13825
tOCT6100_WRITE_PARAMS WriteParams;
13827
tPOCT6100_SHARED_INFO pSharedInfo;
13828
tPOCT6100_API_CHIP_CONFIG pChipConfig;
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};
13835
/* Get local pointer to shared portion of instance. */
13836
pSharedInfo = f_pApiInstance->pSharedInfo;
13838
/* Get local pointer to the chip configuration structure. */
13839
pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
13841
/* Initialize the process context and user chip ID once and for all. */
13842
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
13844
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
13846
/* Set the Global OE bit. */
13847
WriteParams.ulWriteAddress = 0x300;
13848
WriteParams.usWriteData = 0x0004;
13850
/* Set the number of streams. */
13851
switch( pChipConfig->byMaxTdmStreams )
13854
WriteParams.usWriteData |= ( 0 << 3 );
13857
WriteParams.usWriteData |= ( 1 << 3 );
13860
WriteParams.usWriteData |= ( 2 << 3 );
13863
WriteParams.usWriteData |= ( 3 << 3 );
13869
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13870
if ( ulResult != cOCT6100_ERR_OK )
13873
/* Configure the stream frequency. */
13874
WriteParams.ulWriteAddress = 0x330;
13875
WriteParams.usWriteData = 0x0000;
13876
for ( i = 0; i < (UINT32)(pChipConfig->byMaxTdmStreams / 4); i++)
13879
switch( pChipConfig->aulTdmStreamFreqs[ i ] )
13881
case cOCT6100_TDM_STREAM_FREQ_2MHZ:
13882
WriteParams.usWriteData |= ( 0x0 << ulOffset );
13884
case cOCT6100_TDM_STREAM_FREQ_4MHZ:
13885
WriteParams.usWriteData |= ( 0x1 << ulOffset );
13886
fAllStreamAt2Mhz = FALSE;
13888
case cOCT6100_TDM_STREAM_FREQ_8MHZ:
13889
WriteParams.usWriteData |= ( 0x2 << ulOffset );
13890
fAllStreamAt2Mhz = FALSE;
13897
/* Set the stream to 16 MHz if the fast H.100 mode is selected. */
13898
if ( pChipConfig->fEnableFastH100Mode == TRUE )
13900
fAllStreamAt2Mhz = FALSE;
13901
WriteParams.usWriteData = 0xFFFF;
13904
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13905
if ( ulResult != cOCT6100_ERR_OK )
13908
if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
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 )
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 )
13925
WriteParams.ulWriteAddress = 0x376;
13926
WriteParams.usWriteData = (UINT16)( pSharedInfo->MiscVars.usTdmClkBoundary );
13927
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13928
if ( ulResult != cOCT6100_ERR_OK )
13931
/* Select delay for early clock (90 and 110). */
13932
WriteParams.ulWriteAddress = 0x378;
13933
if ( pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
13934
WriteParams.usWriteData = 0x000A;
13937
/* Set the TDM sampling. */
13938
if ( pSharedInfo->ChipConfig.byTdmSampling == cOCT6100_TDM_SAMPLE_AT_RISING_EDGE )
13940
WriteParams.usWriteData = 0x0AF0;
13942
else if ( pSharedInfo->ChipConfig.byTdmSampling == cOCT6100_TDM_SAMPLE_AT_FALLING_EDGE )
13944
WriteParams.usWriteData = 0x0A0F;
13946
else /* pSharedInfo->ChipConfig.ulTdmSampling == cOCT6100_TDM_SAMPLE_AT_3_QUARTERS */
13948
WriteParams.usWriteData = 0x0A08;
13952
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13953
if ( ulResult != cOCT6100_ERR_OK )
13956
/* Protect chip by preventing too rapid timeslot arrival (mclk == 133 MHz). */
13957
WriteParams.ulWriteAddress = 0x37A;
13958
WriteParams.usWriteData = (UINT16)pSharedInfo->MiscVars.usMaxH100Speed;
13960
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13961
if ( ulResult != cOCT6100_ERR_OK )
13964
/* Allow H.100 TS to progress. */
13965
WriteParams.ulWriteAddress = 0x382;
13966
WriteParams.usWriteData = 0x0000;
13968
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13969
if ( ulResult != cOCT6100_ERR_OK )
13972
/* Set by-pass mode. */
13973
WriteParams.ulWriteAddress = 0x50E;
13974
WriteParams.usWriteData = 0x0001;
13976
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13977
if ( ulResult != cOCT6100_ERR_OK )
13981
WriteParams.ulWriteAddress = 0x500;
13982
WriteParams.usWriteData = 0x0003;
13984
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13985
if ( ulResult != cOCT6100_ERR_OK )
13988
/* Write normal ADPCM reset values in ADPCM context 1344. */
13991
WriteParams.ulWriteAddress = 0x140000 + ( 0x40 * 1344 ) + ( i * 2 );
13992
WriteParams.usWriteData = ausAdpcmResetContext[i];
13994
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
13995
if ( ulResult != cOCT6100_ERR_OK )
13999
/* Make sure delay flops are configured correctly if all streams are at 2 MHz. */
14000
if ( fAllStreamAt2Mhz == TRUE )
14002
/* Setup H.100 sampling to lowest value. */
14003
WriteParams.ulWriteAddress = 0x144;
14004
WriteParams.usWriteData = 0x4041;
14006
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14007
if ( ulResult != cOCT6100_ERR_OK )
14010
WriteParams.ulWriteAddress = 0x378;
14011
WriteParams.usWriteData = 0x0A00;
14013
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14014
if ( ulResult != cOCT6100_ERR_OK )
14018
return cOCT6100_ERR_OK;
14022
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14024
Function: Oct6100ApiWriteMiscellaneousRegisters
14026
Description: This function will write to various registers to activate the chip.
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.
14034
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14035
static UINT32 Oct6100ApiWriteMiscellaneousRegisters(
14036
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
14038
tOCT6100_WRITE_PARAMS WriteParams;
14041
/* Initialize the process context and user chip ID once and for all. */
14042
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
14044
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
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 )
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 )
14067
/* Write set second part5 time. */
14068
WriteParams.ulWriteAddress = 0x2C4;
14069
WriteParams.usWriteData = 0x04A0;
14071
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14072
if ( ulResult != cOCT6100_ERR_OK )
14075
/* Write CPU bucket timer to guarantee 200 cycles between each CPU access. */
14076
WriteParams.ulWriteAddress = 0x234;
14077
WriteParams.usWriteData = 0x0804;
14079
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14080
if ( ulResult != cOCT6100_ERR_OK )
14083
WriteParams.ulWriteAddress = 0x236;
14084
WriteParams.usWriteData = 0x0100;
14086
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14087
if ( ulResult != cOCT6100_ERR_OK )
14090
return cOCT6100_ERR_OK;
14094
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14096
Function: Oct6100ApiCreateSerializeObjects
14098
Description: Creates a handle to each serialization object used by the API.
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.
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.
14110
f_ulUserChipId User chip ID for this serialization object.
14112
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14113
static UINT32 Oct6100ApiCreateSerializeObjects(
14114
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
14115
IN UINT32 f_ulUserChipId )
14117
tOCT6100_CREATE_SERIALIZE_OBJECT CreateSerObj = { 0, };
14119
CHAR szSerObjName[ 64 ] = "Oct6100ApiXXXXXXXXApiSerObj";
14122
/* Set some parameters of the create structure once and for all. */
14123
CreateSerObj.pProcessContext = f_pApiInstance->pProcessContext;
14124
CreateSerObj.pszSerialObjName = szSerObjName;
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 );
14137
ulResult = Oct6100UserCreateSerializeObject( &CreateSerObj );
14138
if ( ulResult != cOCT6100_ERR_OK )
14140
f_pApiInstance->ulApiSerObj = CreateSerObj.ulSerialObjHndl;
14141
/*----------------------------------------------------------------------*/
14145
return cOCT6100_ERR_OK;
14149
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14151
Function: Oct6100ApiDestroySerializeObjects
14153
Description: Destroy handles to each serialization object used by the API.
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.
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.
14165
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14166
static UINT32 Oct6100ApiDestroySerializeObjects(
14167
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
14169
tOCT6100_DESTROY_SERIALIZE_OBJECT DestroySerObj;
14172
/* Set some parameters of the create structure once and for all. */
14173
DestroySerObj.pProcessContext = f_pApiInstance->pProcessContext;
14174
DestroySerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
14176
ulResult = Oct6100UserDestroySerializeObject( &DestroySerObj );
14177
if ( ulResult != cOCT6100_ERR_OK )
14180
return cOCT6100_ERR_OK;
14184
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14186
Function: Oct6100ApiRunEgo
14188
Description: Private function used to communicate with the internal processors.
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.
14196
f_fStoreFlag Type of access performed. (Load or Store)
14197
f_ulNumEntry Number of access.
14198
f_aulEntry Array of access to perform.
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 )
14207
tPOCT6100_SHARED_INFO pSharedInfo;
14208
tPOCT6100_API_CHIP_CONFIG pChipConfig;
14209
tOCT6100_WRITE_PARAMS WriteParams;
14210
tOCT6100_READ_PARAMS ReadParams;
14212
UINT32 aulCpuLsuCmd[ 2 ];
14215
BOOL fConditionFlag = TRUE;
14216
UINT32 ulLoopCounter = 0;
14218
/* Get local pointer to shared portion of instance. */
14219
pSharedInfo = f_pApiInstance->pSharedInfo;
14221
/* Get local pointer to the chip configuration structure. */
14222
pChipConfig = &f_pApiInstance->pSharedInfo->ChipConfig;
14224
/* Set the process context and user chip ID parameters once and for all. */
14225
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
14227
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
14229
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
14231
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
14232
ReadParams.pusReadData = &usReadData;
14234
/* No more than 2 entries may be requested. */
14235
if ( f_ulNumEntry > 2 )
14236
return cOCT6100_ERR_FATAL_1B;
14238
/* Write the requested entries at address reserved for CPU. */
14239
for( i = 0; i < f_ulNumEntry; i++ )
14241
WriteParams.ulWriteAddress = cOCT6100_PART1_API_SCRATCH_PAD + ( 0x8 * i );
14242
WriteParams.usWriteData = (UINT16)(( f_aulEntry[ i * 2 ] >> 16 ) & 0xFFFF );
14244
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14245
if ( ulResult != cOCT6100_ERR_OK )
14248
WriteParams.ulWriteAddress += 2;
14249
WriteParams.usWriteData = (UINT16)( f_aulEntry[ i * 2 ] & 0xFFFF );
14251
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14252
if ( ulResult != cOCT6100_ERR_OK )
14255
WriteParams.ulWriteAddress += 2;
14256
WriteParams.usWriteData = (UINT16)(( f_aulEntry[ (i * 2) + 1] >> 16 ) & 0xFFFF );
14258
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14259
if ( ulResult != cOCT6100_ERR_OK )
14262
WriteParams.ulWriteAddress += 2;
14263
WriteParams.usWriteData = (UINT16)( f_aulEntry[ (i * 2) + 1] & 0xFFFF );
14265
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14266
if ( ulResult != cOCT6100_ERR_OK )
14270
/* Preincrement code point. */
14271
pSharedInfo->MiscVars.usCodepoint++;
14273
/* Create DWORD 0 of command. */
14274
aulCpuLsuCmd[0] = 0x00000000;
14275
if ( f_fStoreFlag == FALSE )
14276
aulCpuLsuCmd[0] |= 0xC0000000; /* EGO load. */
14278
aulCpuLsuCmd[0] |= 0xE0000000; /* EGO store. */
14280
aulCpuLsuCmd[0] |= (f_ulNumEntry - 1) << 19;
14281
aulCpuLsuCmd[0] |= cOCT6100_PART1_API_SCRATCH_PAD;
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;
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 );
14292
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14293
if ( ulResult != cOCT6100_ERR_OK )
14296
WriteParams.ulWriteAddress += 2;
14297
WriteParams.usWriteData = (UINT16)( aulCpuLsuCmd[ 0 ] & 0xFFFF );
14299
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14300
if ( ulResult != cOCT6100_ERR_OK )
14303
WriteParams.ulWriteAddress += 2;
14304
WriteParams.usWriteData = (UINT16)(( aulCpuLsuCmd[ 1 ] >> 16 ) & 0xFFFF );
14306
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14307
if ( ulResult != cOCT6100_ERR_OK )
14310
WriteParams.ulWriteAddress += 2;
14311
WriteParams.usWriteData = (UINT16)( aulCpuLsuCmd[ 1 ] & 0xFFFF );
14313
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14314
if ( ulResult != cOCT6100_ERR_OK )
14317
/* Post increment the write pointer. */
14318
pSharedInfo->MiscVars.usCpuLsuWritePtr++;
14320
/* Indicate new write pointer position to HW. */
14321
WriteParams.ulWriteAddress = cOCT6100_PART1_EGO_REG + 0x5A;
14322
WriteParams.usWriteData = (UINT16)( pSharedInfo->MiscVars.usCpuLsuWritePtr & 0x7 );
14324
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14325
if ( ulResult != cOCT6100_ERR_OK )
14328
/* Wait for codepoint to be updated before returning. */
14329
while( fConditionFlag )
14331
ReadParams.ulReadAddress = cOCT6100_PART1_API_SCRATCH_PAD + 0x12;
14332
usReadData = (UINT16)( pSharedInfo->MiscVars.usCodepoint );
14334
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
14335
if ( ulResult != cOCT6100_ERR_OK )
14338
if ( usReadData == pSharedInfo->MiscVars.usCodepoint )
14339
fConditionFlag = FALSE;
14343
if ( ulLoopCounter == cOCT6100_MAX_LOOP )
14344
return cOCT6100_ERR_OPEN_EGO_TIMEOUT;
14347
/* CRC error bit must be zero. */
14348
ReadParams.ulReadAddress = 0x202;
14350
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
14351
if ( ulResult != cOCT6100_ERR_OK )
14354
if ( ( usReadData & 0x0400 ) != 0 )
14355
return cOCT6100_ERR_OPEN_CORRUPTED_IMAGE;
14357
return cOCT6100_ERR_OK;
14361
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14363
Function: Oct6100ApiCreateEgoEntry
14365
Description: Private function used to create an access structure to be sent
14366
to the internal processors.
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.
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 ] )
14383
f_aulEntry[0] = 0x80000000;
14384
f_aulEntry[0] |= f_ulExternalAddress & 0x07FFFFFC;
14386
f_aulEntry[1] = 0x0011C000;
14387
f_aulEntry[1] |= (f_ulNumBytes / 8) << 23;
14388
f_aulEntry[1] |= (f_ulInternalAddress >> 2) & 0x3FFF;
14390
return cOCT6100_ERR_OK;
14400
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14402
Function: Oct6100ApiInitChannels
14404
Description: This function will initialize all the channels to power down.
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.
14412
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14413
static UINT32 Oct6100ApiInitChannels(
14414
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
14416
tPOCT6100_SHARED_INFO pSharedInfo;
14419
tOCT6100_WRITE_BURST_PARAMS BurstParams;
14420
tOCT6100_WRITE_PARAMS WriteParams;
14421
tOCT6100_READ_PARAMS ReadParams;
14424
UINT32 ulBaseAddress;
14425
UINT32 ulFeatureBytesOffset;
14426
UINT32 ulFeatureBitOffset;
14427
UINT32 ulFeatureFieldLength;
14429
UINT16 ausWriteData[ 4 ];
14430
UINT16 usLoopCount = 0;
14431
UINT16 usWriteData = 0;
14433
UINT16 usLastMclkRead;
14435
UINT32 ulNumberOfCycleToWait;
14437
pSharedInfo = f_pApiInstance->pSharedInfo;
14439
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
14441
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
14443
BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
14445
BurstParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
14446
BurstParams.pusWriteData = ausWriteData;
14448
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
14450
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
14451
ReadParams.pusReadData = &usReadData;
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;
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;
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;
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;
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;
14475
/* Initialize the memory for all required channels. */
14476
for( i = 0; i < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; i++ )
14478
/*==============================================================================*/
14479
/* Configure the Global Static Configuration memory of the channel. */
14481
ulBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( i * cOCT6100_CHANNEL_ROOT_SIZE ) + cOCT6100_CHANNEL_ROOT_GLOBAL_CONF_OFFSET;
14483
/* Set the PGSP context base address. */
14484
ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + cOCT6100_CH_MAIN_PGSP_CONTEXT_OFFSET;
14486
WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_CONTEXT_BASE_ADD_OFFSET;
14487
WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
14489
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14490
if ( ulResult != cOCT6100_ERR_OK )
14493
WriteParams.ulWriteAddress += 2;
14494
WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
14496
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14497
if ( ulResult != cOCT6100_ERR_OK )
14500
/* Set the PGSP init context base address. */
14501
ulTempData = ( cOCT6100_IMAGE_FILE_BASE + 0x200 ) & 0x07FFFFFF;
14503
WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_PGSP_INIT_CONTEXT_BASE_ADD_OFFSET;
14504
WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
14506
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14507
if ( ulResult != cOCT6100_ERR_OK )
14510
WriteParams.ulWriteAddress += 2;
14511
WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
14513
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14514
if ( ulResult != cOCT6100_ERR_OK )
14517
/* Set the RIN circular buffer base address. */
14518
ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst;
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;
14526
WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_RIN_CIRC_BUFFER_BASE_ADD_OFFSET;
14527
WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
14529
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14530
if ( ulResult != cOCT6100_ERR_OK )
14533
WriteParams.ulWriteAddress += 2;
14534
WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
14536
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14537
if ( ulResult != cOCT6100_ERR_OK )
14540
/* Set the SIN circular buffer base address. */
14541
ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst;
14543
WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SIN_CIRC_BUFFER_BASE_ADD_OFFSET;
14544
WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
14546
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14547
if ( ulResult != cOCT6100_ERR_OK )
14550
WriteParams.ulWriteAddress += 2;
14551
WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
14553
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14554
if ( ulResult != cOCT6100_ERR_OK )
14557
/* Set the SOUT circular buffer base address. */
14558
ulTempData = pSharedInfo->MemoryMap.ulChanMainMemBase + ( i * pSharedInfo->MemoryMap.ulChanMainMemSize ) + pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst;;
14560
WriteParams.ulWriteAddress = ulBaseAddress + cOCT6100_GSC_SOUT_CIRC_BUFFER_BASE_ADD_OFFSET;
14561
WriteParams.usWriteData = (UINT16)( ulTempData >> 16 );
14563
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14564
if ( ulResult != cOCT6100_ERR_OK )
14567
WriteParams.ulWriteAddress += 2;
14568
WriteParams.usWriteData = (UINT16)( ulTempData & 0xFFFF );
14570
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14571
if ( ulResult != cOCT6100_ERR_OK )
14574
/*==============================================================================*/
14577
/* Put all channel in powerdown mode "3". */
14578
for( i = 0; i < f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels; i++ )
14580
WriteParams.ulWriteAddress = 0x014000 + (i*4) + 0;
14581
WriteParams.usWriteData = 0x85FF; /* TSI index 1535 reserved for power-down mode */
14583
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14584
if ( ulResult != cOCT6100_ERR_OK )
14587
WriteParams.ulWriteAddress = 0x014000 + (i*4) + 2;
14588
WriteParams.usWriteData = 0xC5FF; /* TSI index 1535 reserved for power-down mode */
14590
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14591
if ( ulResult != cOCT6100_ERR_OK )
14595
/* Set the maximum number of channels. */
14596
WriteParams.ulWriteAddress = 0x690;
14597
if ( pSharedInfo->ImageInfo.usMaxNumberOfChannels < 384 )
14598
WriteParams.usWriteData = 384;
14600
WriteParams.usWriteData = (UINT16)pSharedInfo->ImageInfo.usMaxNumberOfChannels;
14602
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14603
if ( ulResult != cOCT6100_ERR_OK )
14606
/* Set power-dowm TSI chariot memory to silence. */
14607
for( i = 0; i < 6; i++ )
14609
WriteParams.ulWriteAddress = 0x20000 + ( i * 0x1000 ) + ( 1534 * 2 );
14610
WriteParams.usWriteData = 0xFF;
14612
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14613
if ( ulResult != cOCT6100_ERR_OK )
14616
WriteParams.ulWriteAddress = 0x20000 + ( i * 0x1000 ) + ( 1535 * 2 );
14617
WriteParams.usWriteData = 0xFF;
14619
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14620
if ( ulResult != cOCT6100_ERR_OK )
14624
/* Remove chariot hold. */
14625
WriteParams.ulWriteAddress = 0x500;
14626
WriteParams.usWriteData = 0x0001;
14628
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14629
if ( ulResult != cOCT6100_ERR_OK )
14632
for( usLoopCount = 0; usLoopCount < 4096; usLoopCount++ )
14634
if ( (usLoopCount % 16) < 8 )
14636
usWriteData = (UINT16)((usLoopCount / 16) << 7);
14637
usWriteData |= (UINT16)((usLoopCount % 8));
14641
usWriteData = (UINT16)((usLoopCount / 16) << 7);
14642
usWriteData |= (UINT16)((usLoopCount % 8));
14643
usWriteData |= 0x78;
14646
/* Set timeslot pointer. */
14647
WriteParams.ulWriteAddress = 0x50E;
14648
WriteParams.usWriteData = 0x0003;
14649
WriteParams.usWriteData |= usWriteData << 2;
14651
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14652
if ( ulResult != cOCT6100_ERR_OK )
14655
/* Now read the mclk counter. */
14656
ReadParams.ulReadAddress = 0x30A;
14657
ReadParams.pusReadData = &usLastMclkRead;
14659
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
14660
if ( ulResult != cOCT6100_ERR_OK )
14664
ReadParams.pusReadData = &usMclkRead;
14666
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
14667
if ( ulResult != cOCT6100_ERR_OK )
14670
if ( ( usLoopCount % 16 ) != 15 )
14672
ulNumberOfCycleToWait = 133;
14676
ulNumberOfCycleToWait = 20000;
14679
/* Evaluate the difference. */
14680
usMclkDiff = (UINT16)(( usMclkRead - usLastMclkRead ) & 0xFFFF);
14682
} while( usMclkDiff <= ulNumberOfCycleToWait );
14685
/* Back to normal mode. */
14686
WriteParams.ulWriteAddress = 0x50E;
14687
WriteParams.usWriteData = 0x0000;
14689
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14690
if ( ulResult != cOCT6100_ERR_OK )
14693
/* Check for CRC errors. */
14694
ReadParams.pusReadData = &usReadData;
14695
ReadParams.ulReadAddress = 0x202;
14697
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
14698
if ( ulResult != cOCT6100_ERR_OK )
14701
if ( (usReadData & 0x400) != 0x0000 )
14702
return cOCT6100_ERR_OPEN_CRC_ERROR;
14704
/* Clear the error rol raised by manually moving the clocks. */
14705
WriteParams.ulWriteAddress = 0x502;
14706
WriteParams.usWriteData = 0x0002;
14708
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
14709
if ( ulResult != cOCT6100_ERR_OK )
14712
/*======================================================================*/
14713
/* Write the tail displacement value in external memory. */
14715
ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchTailDisplOfst.usDwordOffset * 4;
14716
ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchTailDisplOfst.byBitOffset;
14717
ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchTailDisplOfst.byFieldSize;
14719
ulResult = Oct6100ApiReadDword( f_pApiInstance,
14720
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14723
/* Clear previous value set in the feature field.*/
14724
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
14726
ulTempData &= (~ulMask);
14728
/* Set the tail displacement. */
14729
ulTempData |= (pSharedInfo->ChipConfig.usTailDisplacement << ulFeatureBitOffset );
14731
/* Write the DWORD where the field is located. */
14732
ulResult = Oct6100ApiWriteDword( f_pApiInstance,
14733
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14735
if ( ulResult != cOCT6100_ERR_OK )
14738
/*======================================================================*/
14741
/*======================================================================*/
14742
/* Clear the pouch counter, if present. */
14744
if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE )
14746
ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4;
14747
ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset;
14748
ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize;
14750
ulResult = Oct6100ApiReadDword( f_pApiInstance,
14751
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14754
/* Clear previous value set in the feature field.*/
14755
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
14757
/* Clear counter! */
14758
ulTempData &= (~ulMask);
14760
/* Write the DWORD where the field is located.*/
14761
ulResult = Oct6100ApiWriteDword( f_pApiInstance,
14762
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14764
if ( ulResult != cOCT6100_ERR_OK )
14768
/* The ISR has not yet been called. Set the appropriate bit in external memory. */
14769
if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE )
14771
ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4;
14772
ulFeatureBitOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset;
14773
ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize;
14775
ulResult = Oct6100ApiReadDword( f_pApiInstance,
14776
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14779
/* Read previous value set in the feature field.*/
14780
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
14782
/* Toggle the bit to '1'. */
14783
ulTempData |= 1 << ulFeatureBitOffset;
14785
/* Write the DWORD where the field is located.*/
14786
ulResult = Oct6100ApiWriteDword( f_pApiInstance,
14787
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
14789
if ( ulResult != cOCT6100_ERR_OK )
14793
/*======================================================================*/
14795
return cOCT6100_ERR_OK;
14799
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14801
Function: Oct6100ApiInitToneInfo
14803
Description: This function will parse the software image and retrieve
14804
the information about the tones that it supports.
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.
14812
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14813
static UINT32 Oct6100ApiInitToneInfo(
14814
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
14818
PUINT8 pszToneInfoStart = NULL;
14819
PUINT8 pszToneInfoEnd = NULL;
14821
PUINT8 pszCurrentInfo;
14822
PUINT8 pszNextInfo;
14824
UINT32 ulToneEventNumber;
14825
UINT32 ulTempValue;
14826
UINT32 ulNumCharForValue;
14827
UINT32 ulUniqueToneId;
14828
UINT32 ulToneNameSize;
14829
UINT32 ulOffset = 0;
14833
/* Init the tone detector parameter. */
14834
f_pApiInstance->pSharedInfo->ImageInfo.byNumToneDetectors = 0;
14836
/* Find the start and the end of the tone info section. */
14837
if ( f_pApiInstance->pSharedInfo->ChipConfig.ulImageSize > 4096 )
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. */
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 );
14848
/* Check if the information was found. */
14849
if ( pszToneInfoStart == NULL )
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 );
14860
if ( pszToneInfoStart == NULL )
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 );
14867
/* We have to return immediatly if no tones are found. */
14868
if ( pszToneInfoStart == NULL )
14869
return cOCT6100_ERR_OK;
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;
14878
/* Find and process all tone events within the region. */
14879
pszCurrentInfo = Oct6100ApiStrStr( pszToneInfoStart, (PUINT8)cOCT6100_TONE_INFO_EVENT_STRING, pszToneInfoEnd );
14881
while ( pszCurrentInfo != NULL )
14883
/* Skip the string. */
14884
pszCurrentInfo += ( Oct6100ApiStrLen( (PUINT8)cOCT6100_TONE_INFO_EVENT_STRING ) );
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;
14890
/* Retreive the event number */
14891
ulToneEventNumber = 0;
14892
for ( i = ulNumCharForValue; i > 0; i-- )
14894
ulResult = Oct6100ApiAsciiToHex( *pszCurrentInfo, &ulTempValue );
14895
if ( ulResult != cOCT6100_ERR_OK )
14898
ulToneEventNumber |= ( ulTempValue << (( i - 1) * 4 ) );
14902
if ( ulToneEventNumber >= cOCT6100_MAX_TONE_EVENT )
14903
return cOCT6100_ERR_OPEN_INVALID_TONE_EVENT;
14905
/* Skip the comma and the 0x. */
14906
pszCurrentInfo += 3;
14908
/*======================================================================*/
14909
/* Retreive the unique tone id. */
14910
ulUniqueToneId = 0;
14911
for ( i = 0; i < 8; i++ )
14913
ulResult = Oct6100ApiAsciiToHex( *pszCurrentInfo, &ulTempValue );
14914
if ( ulResult != cOCT6100_ERR_OK )
14917
ulOffset = 28 - ( i * 4 );
14918
ulUniqueToneId |= ( ulTempValue << ulOffset );
14922
/*======================================================================*/
14924
/* Skip the comma. */
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;
14932
/* Extract the name size. */
14933
ulToneNameSize = pszNextInfo - pszCurrentInfo - 2; /* - 2 for 0x0D and 0x0A.*/
14935
if ( ulToneNameSize > cOCT6100_TLV_MAX_TONE_NAME_SIZE )
14936
return cOCT6100_ERR_OPEN_INVALID_TONE_NAME;
14938
/* Copy the tone name into the image info structure. */
14939
ulResult = Oct6100UserMemCopy( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].aszToneName,
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 )
14951
f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_ROUT;
14955
f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_SIN;
14959
f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_SOUT;
14963
f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_CHANNEL_PORT_ROUT_SOUT;
14967
f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulDetectionPort = cOCT6100_INVALID_PORT;
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;
14976
f_pApiInstance->pSharedInfo->ImageInfo.byNumToneDetectors++;
14979
return cOCT6100_ERR_OK;
14983
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
14985
Function: Oct6100ApiExternalMemoryBist
14987
Description: Tests the functionality of the external memories.
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.
14995
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
14996
static UINT32 Oct6100ApiExternalMemoryBist(
14997
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
14999
tPOCT6100_SHARED_INFO pSharedInfo;
15000
UINT32 ulMemSize = 0;
15003
/* Get local pointer to shared portion of instance. */
15004
pSharedInfo = f_pApiInstance->pSharedInfo;
15006
/* Test the external memory. */
15007
switch ( pSharedInfo->ChipConfig.ulMemoryChipSize )
15009
case cOCT6100_MEMORY_CHIP_SIZE_8MB:
15010
ulMemSize = cOCT6100_SIZE_8M;
15012
case cOCT6100_MEMORY_CHIP_SIZE_16MB:
15013
ulMemSize = cOCT6100_SIZE_16M;
15015
case cOCT6100_MEMORY_CHIP_SIZE_32MB:
15016
ulMemSize = cOCT6100_SIZE_32M;
15018
case cOCT6100_MEMORY_CHIP_SIZE_64MB:
15019
ulMemSize = cOCT6100_SIZE_64M;
15021
case cOCT6100_MEMORY_CHIP_SIZE_128MB:
15022
ulMemSize = cOCT6100_SIZE_128M;
15025
return cOCT6100_ERR_FATAL_D9;
15028
ulMemSize *= pSharedInfo->ChipConfig.byNumMemoryChips;
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 )
15034
/* Make sure the user I/O functions are working as required. */
15035
ulResult = Oct6100ApiUserIoTest( f_pApiInstance );
15036
if ( ulResult != cOCT6100_ERR_OK )
15039
return cOCT6100_ERR_OK;
15043
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15045
Function: Oct6100ApiGenerateNumber
15047
Description: Generate a number using an index. Passing the same
15048
index generates the same number.
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.
15058
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15059
static UINT16 Oct6100ApiGenerateNumber(
15060
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
15061
IN UINT32 f_ulIndex,
15062
IN UINT32 f_ulDataMask )
15064
UINT16 usGeneratedNumber;
15066
usGeneratedNumber = (UINT16)( ( ( ~( f_ulIndex - 1 ) ) & 0xFF00 ) | ( ( f_ulIndex + 1 ) & 0xFF ) );
15068
return (UINT16)( usGeneratedNumber & f_ulDataMask );
15072
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15074
Function: Oct6100ApiRandomMemoryWrite
15076
Description: Writes to f_ulNumAccesses random locations in the indicated
15077
memory and read back to test the operation of that memory.
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.
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 )
15099
tPOCT6100_SHARED_INFO pSharedInfo;
15100
tOCT6100_WRITE_PARAMS WriteParams;
15101
tOCT6100_READ_PARAMS ReadParams;
15103
UINT32 ulResult, i, j;
15104
UINT32 ulBistAddress;
15107
/* Get local pointer to shared portion of instance. */
15108
pSharedInfo = f_pApiInstance->pSharedInfo;
15110
/* Set the process context and user chip ID parameters once and for all. */
15111
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
15113
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15115
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
15117
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
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;
15123
/* Determine mask for number of data bits. */
15124
ulDataMask = (1 << f_ulNumDataBits) - 1;
15126
/* Bist all data pin. */
15127
for ( i = 0; i < 32; i += 2 )
15129
WriteParams.ulWriteAddress = f_ulMemBase + i * 2;
15130
WriteParams.usWriteData = (UINT16)(0x1 << (i / 2));
15132
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
15133
if ( ulResult != cOCT6100_ERR_OK )
15136
WriteParams.ulWriteAddress = f_ulMemBase + i * 2 + 2;
15137
WriteParams.usWriteData = (UINT16)(0x1 << (i / 2));
15139
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
15140
if ( ulResult != cOCT6100_ERR_OK )
15144
/* Read back the data written. */
15145
for ( i = 0; i < 32; i += 2 )
15147
ReadParams.ulReadAddress = f_ulMemBase + i * 2;
15148
ReadParams.pusReadData = &usReadData;
15149
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
15150
if ( ulResult != cOCT6100_ERR_OK )
15153
if ( usReadData != (UINT16)(0x1 << (i / 2)) )
15154
return f_ulErrorCode;
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 )
15162
if ( usReadData != (UINT16)(0x1 << (i / 2)) )
15163
return f_ulErrorCode;
15166
/* Perform the first write at address 0 + mem base */
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 )
15174
/* Try each address line of the memory. */
15175
for ( i = 2, j = 1; i < f_ulMemSize; i <<= 1, j++ )
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 )
15184
for ( i = 0; i < j; i++ )
15187
ReadParams.ulReadAddress = ( f_ulMemBase + ( 0x1 << i ) );
15189
ReadParams.ulReadAddress = f_ulMemBase;
15190
ReadParams.pusReadData = &usReadData;
15191
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
15192
if ( ulResult != cOCT6100_ERR_OK )
15195
if ( usReadData != Oct6100ApiGenerateNumber( f_pApiInstance, i, ulDataMask ) )
15196
return f_ulErrorCode;
15199
/* Write to random addresses of the memory. */
15200
for ( i = 0; i < f_ulNumAccesses; i++ )
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;
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 )
15214
for ( i = 0; i < f_ulNumAccesses; i++ )
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;
15221
ReadParams.ulReadAddress = ulBistAddress;
15222
ReadParams.pusReadData = &usReadData;
15223
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
15224
if ( ulResult != cOCT6100_ERR_OK )
15227
if ( ( usReadData & ulDataMask ) != ( Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) & ulDataMask ) )
15228
return f_ulErrorCode;
15231
return cOCT6100_ERR_OK;
15235
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15237
Function: Oct6100ApiUserIoTest
15239
Description: This function will verify the correct functionality of
15240
the following user functions:
15242
- Oct6100UserDriverWriteBurstApi
15243
- Oct6100UserDriverWriteSmearApi
15244
- Oct6100UserDriverReadBurstApi
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.
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.
15256
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15257
static UINT32 Oct6100ApiUserIoTest(
15258
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
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;
15268
/* Get local pointer to shared portion of instance. */
15269
pSharedInfo = f_pApiInstance->pSharedInfo;
15271
/* Set the process context and user chip ID parameters once and for all. */
15272
WriteBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
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;
15279
WriteSmearParams.pProcessContext = f_pApiInstance->pProcessContext;
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;
15285
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
15287
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15288
ReadParams.pusReadData = &usReadData;
15290
ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
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;
15298
/*======================================================================*/
15299
/* Write burst check. */
15301
WriteBurstParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
15302
/* Set the random data to be written. */
15303
for ( i = 0; i < WriteBurstParams.ulWriteLength; i++ )
15305
WriteBurstParams.pusWriteData[ i ] = Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF );
15307
mOCT6100_DRIVER_WRITE_BURST_API( WriteBurstParams, ulResult )
15308
if ( ulResult != cOCT6100_ERR_OK )
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++ )
15315
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
15316
if ( ulResult != cOCT6100_ERR_OK )
15319
/* Check if the data matches. */
15320
if ( usReadData != WriteBurstParams.pusWriteData[ i ] )
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;
15326
/* Next address to check. */
15327
ReadParams.ulReadAddress += 2;
15330
/*======================================================================*/
15333
/*======================================================================*/
15334
/* Write smear check. */
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 )
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++ )
15347
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
15348
if ( ulResult != cOCT6100_ERR_OK )
15351
/* Check if the data matches. */
15352
if ( usReadData != WriteSmearParams.usWriteData )
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;
15358
/* Next address to check. */
15359
ReadParams.ulReadAddress += 2;
15362
/*======================================================================*/
15365
/*======================================================================*/
15366
/* Read burst check. */
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 )
15374
for ( i = 0; i < ReadBurstParams.ulReadLength; i++ )
15376
/* Check if the data matches. */
15377
if ( ReadBurstParams.pusReadData[ i ] != Oct6100ApiGenerateNumber( f_pApiInstance, i, 0xFFFF ) )
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;
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 )
15390
for ( i = 0; i < ReadBurstParams.ulReadLength; i++ )
15392
/* Check if the data matches. */
15393
if ( ReadBurstParams.pusReadData[ i ] != WriteSmearParams.usWriteData )
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;
15400
/*======================================================================*/
15402
return cOCT6100_ERR_OK;
15406
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15408
Function: Oct6100ApiExternalMemoryInit
15410
Description: Initialize the external memory before uploading the image.
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.
15418
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15419
static UINT32 Oct6100ApiExternalMemoryInit(
15420
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
15422
tPOCT6100_SHARED_INFO pSharedInfo;
15423
tOCT6100_WRITE_SMEAR_PARAMS SmearParams;
15424
UINT32 ulTotalWordToWrite;
15427
/* Get local pointer to shared portion of instance. */
15428
pSharedInfo = f_pApiInstance->pSharedInfo;
15430
SmearParams.pProcessContext = f_pApiInstance->pProcessContext;
15432
SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15434
/* Clear the first part of the memory. */
15435
ulTotalWordToWrite = 0x400;
15436
SmearParams.ulWriteAddress = cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
15438
while ( ulTotalWordToWrite != 0 )
15440
if ( ulTotalWordToWrite >= pSharedInfo->ChipConfig.usMaxRwAccesses )
15441
SmearParams.ulWriteLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
15443
SmearParams.ulWriteLength = ulTotalWordToWrite;
15445
SmearParams.usWriteData = 0x0;
15447
mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult );
15448
if ( ulResult != cOCT6100_ERR_OK )
15451
/* Update the number of words to write. */
15452
ulTotalWordToWrite -= SmearParams.ulWriteLength;
15453
/* Update the address. */
15454
SmearParams.ulWriteAddress += ( SmearParams.ulWriteLength * 2 );
15457
/* Clear the TLV flag.*/
15458
ulResult = Oct6100ApiWriteDword( f_pApiInstance, cOCT6100_TLV_BASE, 0x0 );
15459
if ( ulResult != cOCT6100_ERR_OK )
15462
return cOCT6100_ERR_OK;
15466
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15468
Function: Oct6100ApiInitMixer
15470
Description: This function will initialize the mixer memory.
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.
15478
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15479
static UINT32 Oct6100ApiInitMixer(
15480
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
15482
tPOCT6100_SHARED_INFO pSharedInfo;
15483
tOCT6100_WRITE_BURST_PARAMS BurstParams;
15484
UINT16 ausWriteData[ 4 ];
15487
pSharedInfo = f_pApiInstance->pSharedInfo;
15489
BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
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 )
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;
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;
15507
ausWriteData[ 0 ] = 0x0000;
15508
ausWriteData[ 1 ] = 0x0000;
15509
ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_TAIL_NODE & 0x7FF); /* Head node.*/
15510
ausWriteData[ 3 ] = 0x0000;
15512
mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
15513
if ( ulResult != cOCT6100_ERR_OK )
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;
15520
ausWriteData[ 0 ] = 0x0000;
15521
ausWriteData[ 1 ] = 0x0000;
15522
ausWriteData[ 2 ] = (UINT16)(pSharedInfo->MixerInfo.usRecordSinEventIndex & 0x7FF);
15523
ausWriteData[ 3 ] = 0x0000;
15525
mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
15526
if ( ulResult != cOCT6100_ERR_OK )
15529
/* Configure the head node. */
15530
BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE;
15531
BurstParams.ulWriteLength = 4;
15533
ausWriteData[ 0 ] = 0x0000;
15534
ausWriteData[ 1 ] = 0x0000;
15535
ausWriteData[ 2 ] = (UINT16)(pSharedInfo->MixerInfo.usRecordCopyEventIndex & 0x7FF);
15536
ausWriteData[ 3 ] = 0x0000;
15538
mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
15539
if ( ulResult != cOCT6100_ERR_OK )
15542
/* Init the mixer pointer */
15543
pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pSharedInfo->MixerInfo.usRecordSinEventIndex;
15547
/* Configure the head node. */
15548
BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE;
15549
BurstParams.ulWriteLength = 4;
15551
ausWriteData[ 0 ] = 0x0000;
15552
ausWriteData[ 1 ] = 0x0000;
15553
ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_TAIL_NODE & 0x7FF); /* Head node. */
15554
ausWriteData[ 3 ] = 0x0000;
15556
mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
15557
if ( ulResult != cOCT6100_ERR_OK )
15560
/* Configure the tail node. */
15561
BurstParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + 0x10;
15562
BurstParams.ulWriteLength = 4;
15564
ausWriteData[ 0 ] = 0x0000;
15565
ausWriteData[ 1 ] = 0x0000;
15566
ausWriteData[ 2 ] = (UINT16)(cOCT6100_MIXER_HEAD_NODE & 0x7FF); /* Head node. */
15567
ausWriteData[ 3 ] = 0x0000;
15569
mOCT6100_DRIVER_WRITE_BURST_API( BurstParams, ulResult );
15570
if ( ulResult != cOCT6100_ERR_OK )
15574
return cOCT6100_ERR_OK;
15578
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15580
Function: Oct6100ApiInitRecordResources
15582
Description: This function will initialize the resources required to
15583
perform recording on a debug channel.
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.
15591
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15592
static UINT32 Oct6100ApiInitRecordResources(
15593
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
15595
tPOCT6100_SHARED_INFO pSharedInfo;
15598
pSharedInfo = f_pApiInstance->pSharedInfo;
15600
/* Check if recording is enabled. */
15601
if ( pSharedInfo->ChipConfig.fEnableChannelRecording == FALSE )
15602
return cOCT6100_ERR_OK;
15604
if ( pSharedInfo->DebugInfo.usRecordMemIndex == cOCT6100_INVALID_INDEX )
15605
return cOCT6100_ERR_NOT_SUPPORTED_OPEN_DEBUG_RECORD;
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;
15611
/* Reserve the TSI entries for the channel. */
15612
ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pSharedInfo->DebugInfo.usRecordRinRoutTsiMemIndex );
15613
if ( ulResult != cOCT6100_ERR_OK )
15616
ulResult = Oct6100ApiReserveTsiMemEntry( f_pApiInstance, &pSharedInfo->DebugInfo.usRecordSinSoutTsiMemIndex );
15617
if ( ulResult != cOCT6100_ERR_OK )
15620
/* Open the debug channel. */
15621
ulResult = Oct6100ApiDebugChannelOpen( f_pApiInstance );
15622
if ( ulResult != cOCT6100_ERR_OK )
15625
return cOCT6100_ERR_OK;
15629
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15631
Function: Oct6100ApiProductionCrc
15633
Description: This function calculates the crc for a production BIST
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.
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.
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 )
15655
UINT32 ulWidth = 32;
15656
UINT32 ulKey, i, j;
15657
UINT32 ulRemainder = 0;
15659
/* CRC the message. */
15660
ulRemainder = f_pulMessage[ f_ulMessageLength - 1 ];
15661
for ( j = f_ulMessageLength - 1; j != 0xFFFFFFFF ; j-- )
15663
for ( i = 0; i < ulWidth; i++ )
15665
if ( ( ( ulRemainder >> 0x1F ) & 0x1 ) == 0x1 )
15667
/* Division is by something meaningful */
15668
ulKey = 0x8765DCBA;
15672
/* Remainder is less than our divisor */
15675
ulRemainder = ulRemainder ^ ulKey;
15677
ulRemainder = ulRemainder << 1;
15680
ulRemainder = ulRemainder | ( ( f_pulMessage[ j - 1 ] ) >> ( 0x1F - i ) );
15685
*f_pulCrcResult = ulRemainder;
15687
return cOCT6100_ERR_OK;
15690
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15692
File: oct6100_mixer.c
15694
Copyright (c) 2001-2005 Octasic Inc.
15698
This file contains the functions used to manage the allocation of mixer
15699
blocks in memories.
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.
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
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.
15715
$Octasic_Release: OCT612xAPI-01.00-PR38 $
15717
$Octasic_Revision: 42 $
15719
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15722
/***************************** INCLUDE FILES *******************************/
15724
#include "octdef.h"
15726
#include "oct6100api/oct6100_defines.h"
15727
#include "oct6100api/oct6100_errors.h"
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"
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"
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"
15751
/**************************** PRIVATE FUNCTIONS ****************************/
15754
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15756
Function: Oct6100ApiGetMixerSwSizes
15758
Description: Gets the sizes of all portions of the API instance pertinent
15759
to the management of mixer events.
15761
-------------------------------------------------------------------------------
15762
| Argument | Description
15763
-------------------------------------------------------------------------------
15765
f_pOpenChip User chip configuration.
15766
f_pInstSizes Pointer to struct containing instance sizes.
15768
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15769
static UINT32 Oct6100ApiGetMixerSwSizes(
15770
IN tPOCT6100_CHIP_OPEN f_pOpenChip,
15771
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
15776
/* Calculate the API memory required for the resource entry lists. */
15777
f_pInstSizes->ulMixerEventList = cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_MIXER_EVENT );
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;
15784
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulMixerEventList, ulTempVar )
15785
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulMixerEventAlloc, ulTempVar )
15788
f_pInstSizes->ulCopyEventList = cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_COPY_EVENT );
15790
ulResult = OctapiLlmAllocGetSize( cOCT6100_MAX_MIXER_EVENTS, &f_pInstSizes->ulCopyEventAlloc );
15791
if ( ulResult != cOCT6100_ERR_OK )
15792
return cOCT6100_ERR_FATAL_1D;
15794
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulCopyEventList, ulTempVar )
15795
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulCopyEventAlloc, ulTempVar )
15798
return cOCT6100_ERR_OK;
15801
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15803
Function: Oct6100ApiReserveMixerEventEntry
15805
Description: Reserves a free entry in the mixer event list.
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.
15813
f_pusEventIndex List entry reserved.
15815
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15816
static UINT32 Oct6100ApiReserveMixerEventEntry(
15817
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
15818
OUT PUINT16 f_pusEventIndex )
15820
PVOID pMixerEventAlloc;
15822
UINT32 ulEventIndex;
15824
mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc )
15826
ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulEventIndex );
15827
if ( ulResult != cOCT6100_ERR_OK )
15829
if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
15830
return cOCT6100_ERR_MIXER_ALL_MIXER_EVENT_ENTRY_OPENED;
15832
return cOCT6100_ERR_FATAL_2B;
15835
*f_pusEventIndex = (UINT16)( ulEventIndex & 0xFFFF );
15837
return cOCT6100_ERR_OK;
15840
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15842
Function: Oct6100ApiMixerSwInit
15844
Description: Initializes all elements of the instance structure associated
15845
to the mixer events.
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.
15853
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
15854
static UINT32 Oct6100ApiMixerSwInit(
15855
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
15857
tPOCT6100_SHARED_INFO pSharedInfo;
15858
tPOCT6100_API_MIXER_EVENT pMixerEventList;
15859
PVOID pMixerEventAlloc;
15860
PVOID pCopyEventAlloc;
15864
/* Get local pointer(s). */
15865
pSharedInfo = f_pApiInstance->pSharedInfo;
15867
/*===================================================================*/
15868
/* Initialize the mixer event list. */
15869
mOCT6100_GET_MIXER_EVENT_LIST_PNT( pSharedInfo, pMixerEventList );
15871
/* Initialize the mixer event allocation software to "all free". */
15872
Oct6100UserMemSet( pMixerEventList, 0x00, cOCT6100_MAX_MIXER_EVENTS * sizeof( tOCT6100_API_MIXER_EVENT ));
15874
mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( pSharedInfo, pMixerEventAlloc )
15876
ulResult = OctapiLlmAllocInit( &pMixerEventAlloc, cOCT6100_MAX_MIXER_EVENTS );
15877
if ( ulResult != cOCT6100_ERR_OK )
15878
return cOCT6100_ERR_FATAL_1F;
15880
/* Now reserve the first entry as the first node. */
15881
ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulTempVar );
15882
if ( ulResult != cOCT6100_ERR_OK )
15884
return cOCT6100_ERR_FATAL_20;
15887
/* Check that we obtain the first event. */
15888
if ( ulTempVar != 0 )
15889
return cOCT6100_ERR_FATAL_21;
15891
/* Now reserve the tail entry. */
15892
ulResult = OctapiLlmAllocAlloc( pMixerEventAlloc, &ulTempVar );
15893
if ( ulResult != cOCT6100_ERR_OK )
15895
return cOCT6100_ERR_FATAL_AA;
15897
/* Check that we obtain the first event. */
15898
if ( ulTempVar != 1 )
15899
return cOCT6100_ERR_FATAL_AB;
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;
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;
15911
/* Now reserve the entry used for channel recording if the feature is enabled. */
15912
if ( pSharedInfo->ChipConfig.fEnableChannelRecording == TRUE )
15914
UINT32 ulAllocIndex;
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 )
15920
return cOCT6100_ERR_FATAL_90;
15923
pSharedInfo->MixerInfo.usRecordCopyEventIndex = (UINT16)( ulAllocIndex & 0xFFFF );
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 )
15929
return cOCT6100_ERR_FATAL_90;
15932
pSharedInfo->MixerInfo.usRecordSinEventIndex = (UINT16)( ulAllocIndex & 0xFFFF );
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;
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;
15944
/* Program the head node. */
15945
pMixerEventList[ cOCT6100_MIXER_HEAD_NODE ].usNextEventPtr = pSharedInfo->MixerInfo.usRecordCopyEventIndex;
15948
/* Initialize the copy event list. */
15949
mOCT6100_GET_COPY_EVENT_ALLOC_PNT( pSharedInfo, pCopyEventAlloc )
15951
ulResult = OctapiLlmAllocInit( &pCopyEventAlloc, cOCT6100_MAX_MIXER_EVENTS );
15952
if ( ulResult != cOCT6100_ERR_OK )
15953
return cOCT6100_ERR_FATAL_B4;
15955
return cOCT6100_ERR_OK;
15958
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
15960
Function: Oct6100ApiMixerEventAdd
15962
Description: This function adds a mixer event event to the list of events
15963
based on the event type passed to the function.
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
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 )
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;
15988
UINT16 usTempEventIndex;
15990
/* Obtain local pointer to shared portion of instance. */
15991
pSharedInfo = f_pApiInstance->pSharedInfo;
15993
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
15995
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
15997
/* Get a pointer to the event entry. */
15998
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCurrentEventEntry, f_usEventIndex );
16000
/* Get a pointer to the destination channel entry. */
16001
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, f_usDestinationChanIndex );
16003
/* Now proceed according to the event type. */
16004
switch ( f_usEventType )
16006
case cOCT6100_EVENT_TYPE_SOUT_COPY:
16008
/* Now insert the Sin copy event */
16009
if ( pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
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;
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;
16019
else /* pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr != cOCT6100_INVALID_INDEX */
16021
usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
16022
pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = f_usEventIndex;
16027
case cOCT6100_EVENT_TYPE_SIN_COPY:
16029
/* Now insert the Sin copy event. */
16030
if ( pSharedInfo->MixerInfo.usFirstSinCopyEventPtr == cOCT6100_INVALID_INDEX )
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 )
16036
/* No event in the bridge section, now let's check in the Sout copy section. */
16037
if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
16039
/* The only node in the list then is the head node. */
16040
usTempEventIndex = cOCT6100_MIXER_HEAD_NODE;
16044
usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
16049
usTempEventIndex = pSharedInfo->MixerInfo.usLastBridgeEventPtr;
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;
16056
else /* pSharedInfo->MixerInfo.usFirstSinCopyEventPtr != cOCT6100_INVALID_INDEX */
16058
usTempEventIndex = pSharedInfo->MixerInfo.usLastSinCopyEventPtr;
16059
pSharedInfo->MixerInfo.usLastSinCopyEventPtr = f_usEventIndex;
16065
return cOCT6100_ERR_FATAL_AF;
16069
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
16071
/*=======================================================================*/
16072
/* Program the Copy event. */
16074
/* Set the Copy event first. */
16075
pCurrentEventEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_COPY;
16076
pCurrentEventEntry->usNextEventPtr = pTempEventEntry->usNextEventPtr;
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;
16082
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
16083
if ( ulResult != cOCT6100_ERR_OK )
16086
/*=======================================================================*/
16088
/*=======================================================================*/
16089
/* Modify the previous node. */
16091
/* Set the last Sub-store entry. */
16092
pTempEventEntry->usNextEventPtr = f_usEventIndex;
16094
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
16095
WriteParams.ulWriteAddress += 4;
16096
WriteParams.usWriteData = f_usEventIndex;
16098
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
16099
if ( ulResult != cOCT6100_ERR_OK )
16102
/*=======================================================================*/
16104
/* Save the destination channel index, needed when removing the event from the mixer. */
16105
pCurrentEventEntry->usDestinationChanIndex = f_usDestinationChanIndex;
16107
/* Mark the entry as reserved. */
16108
pCurrentEventEntry->fReserved = TRUE;
16110
/* Increment the event count on that particular destination channel */
16111
pDestinationEntry->usMixerEventCnt++;
16113
return cOCT6100_ERR_OK;
16116
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16118
Function: Oct6100ApiMixerEventRemove
16120
Description: This function removes a mixer event event from the list of events based
16121
on the event type passed to the function.
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.
16129
f_usEventIndex Index of event within the API's mixer event list.
16130
f_usEventType Type of mixer event.
16132
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16133
static UINT32 Oct6100ApiMixerEventRemove(
16134
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
16135
IN UINT16 f_usEventIndex,
16136
IN UINT16 f_usEventType )
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;
16146
UINT16 usTempEventIndex;
16147
UINT32 ulLoopCount = 0;
16148
UINT16 ausWriteData[ 4 ] = { 0 };
16150
/* Obtain local pointer to shared portion of instance. */
16151
pSharedInfo = f_pApiInstance->pSharedInfo;
16153
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
16155
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
16157
BurstWriteParams.pProcessContext = f_pApiInstance->pProcessContext;
16159
BurstWriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
16160
BurstWriteParams.pusWriteData = ausWriteData;
16161
BurstWriteParams.ulWriteLength = 4;
16163
/* Get a pointer to the event entry. */
16164
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCurrentEventEntry, f_usEventIndex );
16166
/* Get the pointer to the channel entry. */
16167
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pDestinationEntry, pCurrentEventEntry->usDestinationChanIndex );
16169
/* Now proceed according to the event type. */
16170
switch ( f_usEventType )
16172
case cOCT6100_EVENT_TYPE_SOUT_COPY:
16174
if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr )
16176
usTempEventIndex = cOCT6100_MIXER_HEAD_NODE;
16180
/* Now insert the Sin copy event. */
16181
usTempEventIndex = pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr;
16184
/* Find the copy entry before the entry to remove. */
16185
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
16187
while( pTempEventEntry->usNextEventPtr != f_usEventIndex )
16189
usTempEventIndex = pTempEventEntry->usNextEventPtr;
16191
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
16194
if ( ulLoopCount == cOCT6100_MAX_LOOP )
16195
return cOCT6100_ERR_FATAL_B2;
16198
/*=======================================================================*/
16199
/* Update the global mixer pointers. */
16200
if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr )
16202
if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSoutCopyEventPtr )
16204
/* This event was the only of the list.*/
16205
pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = cOCT6100_INVALID_INDEX;
16206
pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = cOCT6100_INVALID_INDEX;
16210
pSharedInfo->MixerInfo.usFirstSoutCopyEventPtr = pCurrentEventEntry->usNextEventPtr;
16213
else if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSoutCopyEventPtr )
16215
pSharedInfo->MixerInfo.usLastSoutCopyEventPtr = usTempEventIndex;
16217
/*=======================================================================*/
16222
case cOCT6100_EVENT_TYPE_SIN_COPY:
16224
if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSinCopyEventPtr )
16226
fFirstSinCopyEvent = TRUE;
16228
if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr != cOCT6100_INVALID_INDEX )
16230
usTempEventIndex = pSharedInfo->MixerInfo.usLastBridgeEventPtr;
16232
else if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr != cOCT6100_INVALID_INDEX )
16234
usTempEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
16238
usTempEventIndex = cOCT6100_MIXER_HEAD_NODE;
16243
/* Now insert the Sin copy event. */
16244
usTempEventIndex = pSharedInfo->MixerInfo.usFirstSinCopyEventPtr;
16247
/* Find the copy entry before the entry to remove. */
16248
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
16250
/* If we are not the first event of the Sin copy list. */
16251
if ( fFirstSinCopyEvent == FALSE )
16253
while( pTempEventEntry->usNextEventPtr != f_usEventIndex )
16255
usTempEventIndex = pTempEventEntry->usNextEventPtr;
16256
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEventEntry, usTempEventIndex );
16259
if ( ulLoopCount == cOCT6100_MAX_LOOP )
16260
return cOCT6100_ERR_FATAL_B1;
16264
/*=======================================================================*/
16265
/* Update the global mixer pointers. */
16266
if ( f_usEventIndex == pSharedInfo->MixerInfo.usFirstSinCopyEventPtr )
16268
if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSinCopyEventPtr )
16270
/* This event was the only of the list. */
16271
pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = cOCT6100_INVALID_INDEX;
16272
pSharedInfo->MixerInfo.usLastSinCopyEventPtr = cOCT6100_INVALID_INDEX;
16276
pSharedInfo->MixerInfo.usFirstSinCopyEventPtr = pCurrentEventEntry->usNextEventPtr;
16279
else if ( f_usEventIndex == pSharedInfo->MixerInfo.usLastSinCopyEventPtr )
16281
pSharedInfo->MixerInfo.usLastSinCopyEventPtr = usTempEventIndex;
16283
/*=======================================================================*/
16288
return cOCT6100_ERR_FATAL_B0;
16292
/*=======================================================================*/
16293
/* Modify the previous event. */
16295
pTempEventEntry->usNextEventPtr = pCurrentEventEntry->usNextEventPtr;
16297
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
16298
WriteParams.ulWriteAddress += 4;
16299
WriteParams.usWriteData = pTempEventEntry->usNextEventPtr;
16301
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
16302
if ( ulResult != cOCT6100_ERR_OK )
16305
/*=======================================================================*/
16308
/*=======================================================================*/
16309
/* Clear the current event. */
16311
BurstWriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( f_usEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
16313
mOCT6100_DRIVER_WRITE_BURST_API( BurstWriteParams, ulResult );
16314
if ( ulResult != cOCT6100_ERR_OK )
16317
/*=======================================================================*/
16320
/*=======================================================================*/
16321
/* Decrement the mixer event count active on that channel. */
16322
pDestinationEntry->usMixerEventCnt--;
16324
/*=======================================================================*/
16327
/*=======================================================================*/
16329
/* This index of this channel is not valid anymore! */
16330
pCurrentEventEntry->usDestinationChanIndex = cOCT6100_INVALID_INDEX;
16332
/* Mark this entry as free. */
16333
pCurrentEventEntry->fReserved = FALSE;
16335
return cOCT6100_ERR_OK;
16338
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16340
Function: Oct6100ApiGetFreeMixerEventCnt
16342
Description: Retrieve the number of events left in the list.
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.
16350
f_pulFreeEventCnt How many events left.
16352
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16353
static UINT32 Oct6100ApiGetFreeMixerEventCnt(
16354
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
16355
OUT PUINT32 f_pulFreeEventCnt )
16357
PVOID pMixerEventAlloc;
16359
UINT32 ulAllocatedEvents;
16360
UINT32 ulAvailableEvents;
16362
mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc )
16364
ulResult = OctapiLlmAllocInfo( pMixerEventAlloc, &ulAllocatedEvents, &ulAvailableEvents );
16365
if ( ulResult != cOCT6100_ERR_OK )
16366
return cOCT6100_ERR_FATAL_E8;
16368
/* Return number of free events. */
16369
*f_pulFreeEventCnt = ulAvailableEvents;
16371
return cOCT6100_ERR_OK;
16375
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16377
Function: Oct6100ApiWriteDword
16379
Description: Write a DWORD at specified address in external memory.
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.
16387
f_ulAddress DWORD address where to write.
16388
f_ulWriteData DWORD data to write.
16390
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16391
static UINT32 Oct6100ApiWriteDword(
16392
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
16393
IN UINT32 f_ulAddress,
16394
IN UINT32 f_ulWriteData )
16396
tOCT6100_WRITE_PARAMS WriteParams;
16399
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
16401
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
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 )
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 )
16417
return cOCT6100_ERR_OK;
16420
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16422
Function: Oct6100ApiReleaseTsiMemEntry
16424
Description: Releases a TSI chariot memory entry specified.
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.
16432
f_usTsiMemIndex Index reserved in the TSI chariot memory.
16434
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16435
static UINT32 Oct6100ApiReleaseTsiMemEntry(
16436
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
16437
IN UINT16 f_usTsiMemIndex )
16439
tPOCT6100_SHARED_INFO pSharedInfo;
16440
PVOID pTsiMemAlloc;
16444
/* Get local pointer to shared portion of instance. */
16445
pSharedInfo = f_pApiInstance->pSharedInfo;
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;
16451
ulIndex = f_usTsiMemIndex;
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;
16457
mOCT6100_GET_TSI_MEMORY_ALLOC_PNT( pSharedInfo, pTsiMemAlloc )
16459
ulResult = OctapiLlmAllocDealloc( pTsiMemAlloc, ulIndex );
16460
if ( ulResult != cOCT6100_ERR_OK )
16462
return cOCT6100_ERR_FATAL_93;
16465
return cOCT6100_ERR_OK;
16468
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16470
Function: Oct6100ApiReleaseMixerEventEntry
16472
Description: Release an entry from the mixer event list.
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.
16480
f_usEventIndex List entry reserved.
16482
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16483
static UINT32 Oct6100ApiReleaseMixerEventEntry(
16484
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
16485
IN UINT16 f_usEventIndex )
16487
PVOID pMixerEventAlloc;
16490
mOCT6100_GET_MIXER_EVENT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pMixerEventAlloc )
16492
ulResult = OctapiLlmAllocDealloc( pMixerEventAlloc, f_usEventIndex );
16493
if ( ulResult != cOCT6100_ERR_OK )
16494
return cOCT6100_ERR_FATAL_2C;
16496
return cOCT6100_ERR_OK;
16499
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16501
Function: Oct6100ApiWaitForPcRegisterBit
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.
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.
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.
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 )
16528
tOCT6100_READ_PARAMS ReadParams;
16529
tOCT6100_GET_TIME StartTime;
16530
tOCT6100_GET_TIME TimeoutTime;
16531
tOCT6100_GET_TIME CurrentTime;
16534
BOOL fConditionFlag = TRUE;
16536
/* Copy the process context. */
16537
StartTime.pProcessContext = f_pApiInstance->pProcessContext;
16538
CurrentTime.pProcessContext = f_pApiInstance->pProcessContext;
16540
/* Get the current system time. */
16541
ulResult = Oct6100UserGetTime( &StartTime );
16542
if ( ulResult != cOCT6100_ERR_OK )
16545
/* Mark the bit as not being equal, for now. */
16546
*f_pfBitEqual = FALSE;
16548
/* Determine the time at which the timeout has expired. */
16549
ulResult = octapi_lm_add(
16550
StartTime.aulWallTimeUs, 1,
16552
TimeoutTime.aulWallTimeUs, 1 );
16553
if ( ulResult != cOCT6100_ERR_OK )
16556
/* Prepare read structure. */
16557
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
16559
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
16560
ReadParams.ulReadAddress = f_ulPcRegAdd;
16561
ReadParams.pusReadData = &usReadData;
16563
/* Read the PC bit while the timeout period hasn't expired. */
16564
while ( fConditionFlag )
16566
/* Read the current time again to check for timeout. */
16567
ulResult = Oct6100UserGetTime( &CurrentTime );
16568
if ( ulResult != cOCT6100_ERR_OK )
16571
ulResult = Oct6100UserDriverReadApi( &ReadParams );
16572
if ( ulResult != cOCT6100_ERR_OK )
16575
if ( ( UINT16 )((usReadData >> f_ulPcBitNum) & 0x1) == ( UINT16 )f_ulValue )
16577
/* Mark the bit as being equal. */
16578
*f_pfBitEqual = TRUE;
16579
fConditionFlag = FALSE;
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;
16588
return cOCT6100_ERR_OK;
16591
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16593
Function: Oct6100ApiReleaseConversionMemEntry
16595
Description: Releases the conversion chariot memory entry specified.
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
16604
f_usConversionMemIndex Index reserved in the conversion chariot memory.
16606
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16607
static UINT32 Oct6100ApiReleaseConversionMemEntry(
16608
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
16609
IN UINT16 f_usConversionMemIndex )
16611
tPOCT6100_SHARED_INFO pSharedInfo;
16612
PVOID pConversionMemAlloc;
16615
/* Get local pointer to shared portion of instance. */
16616
pSharedInfo = f_pApiInstance->pSharedInfo;
16618
mOCT6100_GET_CONVERSION_MEMORY_ALLOC_PNT( pSharedInfo, pConversionMemAlloc )
16620
ulResult = OctapiLlmAllocDealloc( pConversionMemAlloc, f_usConversionMemIndex );
16621
if ( ulResult != cOCT6100_ERR_OK )
16623
return cOCT6100_ERR_FATAL_B7;
16626
return cOCT6100_ERR_OK;
16629
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16631
Function: Oct6100ApiReadDword
16633
Description: Read a DWORD at specified address in external memory.
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.
16641
f_ulAddress DWORD address where to read.
16642
f_pulReadData Resulting data.
16644
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16645
static UINT32 Oct6100ApiReadDword(
16646
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
16647
IN UINT32 f_ulAddress,
16648
OUT PUINT32 f_pulReadData )
16650
tOCT6100_READ_PARAMS ReadParams;
16656
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
16658
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
16659
ReadParams.pusReadData = &usReadData;
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 )
16669
ulTempData = usReadData << 16;
16671
/* Read the last 16 bits. */
16672
ReadParams.ulReadAddress += 2;
16673
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
16674
if ( ulResult != cOCT6100_ERR_OK )
16678
ulTempData |= usReadData;
16680
/*==================================================================================*/
16682
/* Return the read value.*/
16683
*f_pulReadData = ulTempData;
16685
return cOCT6100_ERR_OK;
16688
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16690
Function: Oct6100BufferPlayoutStop
16692
Description: This function disables playout of a buffer on the specified
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.
16701
f_pBufferPlayoutStop Pointer to buffer playout stop structure.
16703
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16704
static UINT32 Oct6100BufferPlayoutStopDef(
16705
tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop )
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;
16713
return cOCT6100_ERR_OK;
16716
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16718
Function: Oct6100ApiWaitForTime
16720
Description: Waits for the specified amount of time.
16722
-------------------------------------------------------------------------------
16723
| Argument | Description
16724
-------------------------------------------------------------------------------
16725
f_aulWaitTime[ 2 ] The amout of time to be waited.
16727
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16728
static UINT32 Oct6100ApiWaitForTime(
16729
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
16730
IN UINT32 f_aulWaitTime[ 2 ] )
16732
tOCT6100_GET_TIME StartTime;
16733
tOCT6100_GET_TIME CurrentTime;
16734
UINT32 aulTimeDelta[ 2 ];
16737
BOOL fConditionFlag = TRUE;
16739
/* Copy the process context. */
16740
StartTime.pProcessContext = f_pApiInstance->pProcessContext;
16741
CurrentTime.pProcessContext = f_pApiInstance->pProcessContext;
16743
ulResult = Oct6100UserGetTime( &StartTime );
16744
if ( ulResult != cOCT6100_ERR_OK )
16747
while ( fConditionFlag )
16749
ulResult = Oct6100UserGetTime( &CurrentTime );
16750
if ( ulResult != cOCT6100_ERR_OK )
16753
ulResult = octapi_lm_subtract(
16754
CurrentTime.aulWallTimeUs, 1,
16755
StartTime.aulWallTimeUs, 1,
16758
if ( ulResult != cOCT6100_ERR_OK )
16759
return cOCT6100_ERR_FATAL_37;
16761
if ( aulTimeDelta[ 1 ] >= f_aulWaitTime[ 1 ] &&
16762
aulTimeDelta[ 0 ] >= f_aulWaitTime[ 0 ] )
16763
fConditionFlag = FALSE;
16766
return cOCT6100_ERR_OK;
16769
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16771
Function: Oct6100ApiReserveTsiMemEntry
16773
Description: Reserves a TSI chariot memory entry.
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.
16781
f_pusTsiMemIndex Resulting index reserved in the TSI chariot memory.
16783
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16784
static UINT32 Oct6100ApiReserveTsiMemEntry(
16785
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
16786
OUT PUINT16 f_pusTsiMemIndex )
16788
tPOCT6100_SHARED_INFO pSharedInfo;
16789
PVOID pTsiMemAlloc;
16792
UINT32 ulNumTsiB4Timestamp;
16794
/* Get local pointer to shared portion of instance. */
16795
pSharedInfo = f_pApiInstance->pSharedInfo;
16797
mOCT6100_GET_TSI_MEMORY_ALLOC_PNT( pSharedInfo, pTsiMemAlloc )
16799
ulResult = OctapiLlmAllocAlloc( pTsiMemAlloc, &ulIndex );
16800
if ( ulResult != cOCT6100_ERR_OK )
16802
if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
16803
return cOCT6100_ERR_MEMORY_ALL_TSI_MEM_ENTRY_RESERVED;
16805
return cOCT6100_ERR_FATAL_92;
16809
if ( ulIndex >= cOCT6100_NUM_TSI_B4_PHASING )
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;
16814
if ( ulIndex >= ulNumTsiB4Timestamp )
16816
/* + 4 for the timestamp TSI entries.*/
16817
*f_pusTsiMemIndex = (UINT16)( pSharedInfo->ChipConfig.usMaxPhasingTssts + ulIndex + cOCT6100_TSI_MEM_FOR_TIMESTAMP );
16819
else /* ulIndex < ulNumTsiB4Timestamp */
16821
*f_pusTsiMemIndex = (UINT16)( pSharedInfo->ChipConfig.usMaxPhasingTssts + ulIndex );
16824
else /* ulIndex < ulNumTsiB4Timestamp */
16826
*f_pusTsiMemIndex = (UINT16)( ulIndex );
16829
return cOCT6100_ERR_OK;
16832
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16834
Function: Oct6100ApiReserveConversionMemEntry
16836
Description: Reserves one of the conversion memory entry
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
16845
f_pusConversionMemIndex Resulting index reserved in the conversion memory.
16847
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16848
static UINT32 Oct6100ApiReserveConversionMemEntry(
16849
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
16850
OUT PUINT16 f_pusConversionMemIndex )
16852
tPOCT6100_SHARED_INFO pSharedInfo;
16853
PVOID pConversionMemAlloc;
16854
UINT32 ulConversionMemIndex;
16857
/* Get local pointer to shared portion of instance. */
16858
pSharedInfo = f_pApiInstance->pSharedInfo;
16860
mOCT6100_GET_CONVERSION_MEMORY_ALLOC_PNT( pSharedInfo, pConversionMemAlloc )
16862
ulResult = OctapiLlmAllocAlloc( pConversionMemAlloc, &ulConversionMemIndex );
16863
if ( ulResult != cOCT6100_ERR_OK )
16865
if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
16866
return cOCT6100_ERR_MEMORY_ALL_CONVERSION_MEM_ENTRY_RESERVED;
16868
return cOCT6100_ERR_FATAL_B8;
16871
*f_pusConversionMemIndex = (UINT16)( ulConversionMemIndex & 0xFFFF );
16873
return cOCT6100_ERR_OK;
16876
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16878
Function: Oct6100ConfBridgeClose
16880
Description: This function closes a conference bridge. A conference
16881
bridge can only be closed if no participants are present on
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.
16890
f_pConfBridgeClose Pointer to conference bridge close structure.
16892
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16893
static UINT32 Oct6100ConfBridgeCloseDef(
16894
tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose )
16896
f_pConfBridgeClose->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE;
16898
return cOCT6100_ERR_OK;
16902
#include "apilib/octapi_largmath.h"
16904
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16907
| Function: OctApiLmSubtract.
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.
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
16926
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16927
static UINT32 OctApiLmSubtract(UINT32 * a,USHORT alen,UINT32 * bneg,USHORT blen,UINT32 * z,USHORT zlen,USHORT * neg)
16935
/* Check for array lengths.*/
16936
if (alen > zlen || blen > zlen) return(OCTAPI_LM_ARRAY_SIZE_MISMATCH);
16938
for(i=0;i<=zlen;i++)
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;
16944
/* Calculate carry for next time.*/
16946
if (temp < aprim) carry = 1; else carry = 0;
16948
if (temp <= aprim) carry = 1; else carry = 0;
16950
/* Write new value.*/
16954
/* Check for overflow, which means negative number!*/
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));
16962
OctApiLmAdd(&temp,0,z,zlen,z,zlen);
16965
return(GENERIC_OK);
16968
/* Result is positive.*/
16970
return(GENERIC_OK);
16973
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
16976
| Function: OctApiLmAdd.
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.
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).
16993
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
16994
static UINT32 OctApiLmAdd(UINT32 * a,USHORT alen,UINT32 * b,USHORT blen,UINT32 * z, USHORT zlen)
17002
/* Check for array lengths.*/
17003
if (alen > zlen || blen > zlen) return(OCTAPI_LM_ARRAY_SIZE_MISMATCH);
17005
for(i=0;i<=zlen;i++)
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;
17011
/* Calculate carry for next time.*/
17013
if (temp < aprim) carry = 1; else carry = 0;
17015
if (temp <= aprim) carry = 1; else carry = 0;
17017
/* Write new value.*/
17021
/* Check for overflow.*/
17022
if (carry == 1) return(OCTAPI_LM_OVERFLOW);
17025
return(GENERIC_OK);
17028
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17030
File: oct6100_chip_stats.c
17032
Copyright (c) 2001-2005 Octasic Inc.
17036
This file contains functions used to retreive the OCT6100 chip stats.
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.
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
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.
17052
$Octasic_Release: OCT612xAPI-01.00-PR38 $
17054
$Octasic_Revision: 85 $
17056
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17059
/***************************** INCLUDE FILES *******************************/
17062
#include "octdef.h"
17064
#include "oct6100api/oct6100_defines.h"
17065
#include "oct6100api/oct6100_errors.h"
17066
#include "oct6100api/oct6100_apiud.h"
17068
#include "apilib/octapi_llman.h"
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"
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"
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"
17088
/**************************** PUBLIC FUNCTIONS *****************************/
17091
/**************************** PRIVATE FUNCTIONS ****************************/
17093
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17095
Function: Oct6100ApiChipStatsSwInit
17097
Description: Initializes portions of API instance associated to chip stats.
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.
17105
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17106
static UINT32 Oct6100ApiChipStatsSwInit(
17107
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
17109
tPOCT6100_SHARED_INFO pSharedInfo;
17111
/* Get local pointer to shared portion of API instance. */
17112
pSharedInfo = f_pApiInstance->pSharedInfo;
17114
/* Initialize chip stats. */
17115
pSharedInfo->ErrorStats.fFatalChipError = FALSE;
17117
pSharedInfo->ErrorStats.ulH100ClkABadCnt = 0;
17118
pSharedInfo->ErrorStats.ulH100ClkBBadCnt = 0;
17119
pSharedInfo->ErrorStats.ulH100FrameABadCnt = 0;
17120
pSharedInfo->ErrorStats.ulH100OutOfSyncCnt = 0;
17122
pSharedInfo->ErrorStats.ulInternalReadTimeoutCnt = 0;
17123
pSharedInfo->ErrorStats.ulSdramRefreshTooLateCnt = 0;
17124
pSharedInfo->ErrorStats.ulPllJitterErrorCnt = 0;
17125
pSharedInfo->ErrorStats.ulOverflowToneEventsCnt = 0;
17129
pSharedInfo->ErrorStats.ulToneDetectorErrorCnt = 0;
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;
17141
pSharedInfo->ChipStats.usNumberPhasingTssts = 0;
17142
pSharedInfo->ChipStats.usNumberAdpcmChans = 0;
17144
return cOCT6100_ERR_OK;
17148
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17150
File: oct6100_conf_bridge.c
17152
Copyright (c) 2001-2005 Octasic Inc.
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
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.
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
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.
17175
$Octasic_Release: OCT612xAPI-01.00-PR38 $
17177
$Octasic_Revision: 145 $
17179
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17182
/***************************** INCLUDE FILES *******************************/
17184
#include "octdef.h"
17186
#include "oct6100api/oct6100_defines.h"
17187
#include "oct6100api/oct6100_errors.h"
17188
#include "oct6100api/oct6100_apiud.h"
17190
#include "apilib/octapi_llman.h"
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"
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"
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"
17218
/**************************** PUBLIC FUNCTIONS *****************************/
17220
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17222
Function: Oct6100ConfBridgeChanRemove
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.
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.
17234
f_pConfBridgeRemove Pointer to conference bridge channel removal structure.
17236
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17237
static UINT32 Oct6100ConfBridgeChanRemoveDef(
17238
tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove )
17240
f_pConfBridgeRemove->ulChannelHndl = cOCT6100_INVALID_HANDLE;
17241
f_pConfBridgeRemove->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE;
17242
f_pConfBridgeRemove->fRemoveAll = FALSE;
17244
return cOCT6100_ERR_OK;
17249
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17251
Function: Oct6100ApiGetConfBridgeSwSizes
17253
Description: Gets the sizes of all portions of the API instance pertinent
17254
to the management of conference bridges.
17256
-------------------------------------------------------------------------------
17257
| Argument | Description
17258
-------------------------------------------------------------------------------
17259
f_pOpenChip Pointer to chip configuration struct.
17260
f_pInstSizes Pointer to struct containing instance sizes.
17262
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17263
static UINT32 Oct6100ApiGetConfBridgeSwSizes(
17264
IN tPOCT6100_CHIP_OPEN f_pOpenChip,
17265
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
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 );
17275
/* Calculate memory needed for conference bridge allocation software. */
17276
if ( f_pOpenChip->ulMaxConfBridges > 0 )
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;
17283
/* Check if the user wants to build flexible conference bridges. */
17284
if ( f_pOpenChip->ulMaxFlexibleConfParticipants > 0 )
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 );
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 );
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;
17302
f_pInstSizes->ulFlexConfParticipantsList = 0;
17303
f_pInstSizes->ulFlexConfParticipantsAlloc = 0;
17308
f_pInstSizes->ulMixerEventList = 0;
17309
f_pInstSizes->ulMixerEventAlloc = 0;
17310
f_pInstSizes->ulConfBridgeAlloc = 0;
17312
/* Make sure flexible conferencing is not used. */
17313
f_pInstSizes->ulFlexConfParticipantsList = 0;
17314
f_pInstSizes->ulFlexConfParticipantsAlloc = 0;
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 )
17321
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulFlexConfParticipantsList, ulTempVar )
17322
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulFlexConfParticipantsAlloc, ulTempVar )
17324
return cOCT6100_ERR_OK;
17328
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17330
Function: Oct6100ApiConfBridgeSwInit
17332
Description: Initializes all elements of the instance structure associated
17333
to conference bridges.
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.
17341
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17342
static UINT32 Oct6100ApiConfBridgeSwInit(
17343
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
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;
17354
/* Get local pointer to shared portion of instance. */
17355
pSharedInfo = f_pApiInstance->pSharedInfo;
17357
/* Get the maximum number of conference bridges. */
17358
ulMaxConfBridges = pSharedInfo->ChipConfig.usMaxConfBridges;
17360
/*===================================================================*/
17361
/* Set all entries in the conference bridge list to unused. */
17363
mOCT6100_GET_CONF_BRIDGE_LIST_PNT( pSharedInfo, pConfBridgeList );
17365
/* Initialize the conference bridge allocation software to "all free". */
17366
if ( ulMaxConfBridges > 0 )
17368
/* Clear the bridge memory */
17369
Oct6100UserMemSet( pConfBridgeList, 0x00, ulMaxConfBridges * sizeof( tOCT6100_API_CONF_BRIDGE ));
17371
mOCT6100_GET_CONF_BRIDGE_ALLOC_PNT( pSharedInfo, pConfBridgeAlloc )
17373
ulResult = OctapiLlmAllocInit( &pConfBridgeAlloc, ulMaxConfBridges );
17374
if ( ulResult != cOCT6100_ERR_OK )
17375
return cOCT6100_ERR_FATAL_1E;
17377
/*===================================================================*/
17380
/*===================================================================*/
17381
/* Set all entries in the flexible conferencing participant list to unused. */
17383
/* Get the maximum number of flexible conferencing participants. */
17384
ulMaxFlexConfParicipants = pSharedInfo->ChipConfig.usMaxFlexibleConfParticipants;
17386
mOCT6100_GET_FLEX_CONF_PARTICIPANT_LIST_PNT( pSharedInfo, pFlexConfParticipantList );
17388
/* Initialize the flexible conferencing allocation software. */
17389
if ( ulMaxFlexConfParicipants > 0 )
17391
UINT32 i, ulEventIndex;
17393
/* Clear the participants memory */
17394
Oct6100UserMemSet( pFlexConfParticipantList, 0x00, ulMaxFlexConfParicipants * sizeof( tOCT6100_API_FLEX_CONF_PARTICIPANT ));
17396
mOCT6100_GET_FLEX_CONF_PARTICIPANT_ALLOC_PNT( pSharedInfo, pFlexConfPartipantsAlloc )
17398
ulResult = OctapiLlmAllocInit( &pFlexConfPartipantsAlloc, ulMaxFlexConfParicipants );
17399
if ( ulResult != cOCT6100_ERR_OK )
17400
return cOCT6100_ERR_FATAL_1E;
17402
/* Initialize the conferencing indexes. */
17403
for ( i = 0; i < ulMaxFlexConfParicipants; i ++ )
17405
for ( ulEventIndex = 0; ulEventIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulEventIndex ++ )
17406
pFlexConfParticipantList[ i ].ausLoadOrAccumulateEventIndex[ ulEventIndex ] = cOCT6100_INVALID_INDEX;
17410
/*===================================================================*/
17412
return cOCT6100_ERR_OK;
17417
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17419
Function: Oct6100ConfBridgeCloseSer
17421
Description: Closes a conference bridge. Note that no client must be present
17422
on the bridge for the bridge to be closed.
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.
17430
f_pConfBridgeClose Pointer to conference bridge close structure.
17432
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17433
static UINT32 Oct6100ConfBridgeCloseSer(
17434
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
17435
IN tPOCT6100_CONF_BRIDGE_CLOSE f_pConfBridgeClose )
17437
UINT16 usBridgeIndex;
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 )
17445
/* Release all resources associated to the conference bridge. */
17446
ulResult = Oct6100ApiReleaseBridgeResources( f_pApiInstance, usBridgeIndex );
17447
if ( ulResult != cOCT6100_ERR_OK )
17450
/* Invalidate the handle. */
17451
f_pConfBridgeClose->ulConfBridgeHndl = cOCT6100_INVALID_HANDLE;
17453
return cOCT6100_ERR_OK;
17457
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17459
Function: Oct6100ApiAssertBridgeParams
17461
Description: Checks the user's conference bridge close configuration for errors.
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.
17469
f_pConfBridgeClose Pointer to conference bridge close structure.
17470
f_pusBridgeIndex Pointer to API instance conference bridge index.
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 )
17478
tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
17479
UINT32 ulEntryOpenCnt;
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;
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;
17489
mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, *f_pusBridgeIndex )
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;
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;
17502
return cOCT6100_ERR_OK;
17506
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17508
Function: Oct6100ApiReleaseBridgeResources
17510
Description: Release all resources reserved for the conference bridge.
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.
17518
f_usBridgeIndex Allocated external memory block for the conference bridge.
17520
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17521
static UINT32 Oct6100ApiReleaseBridgeResources(
17522
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
17523
IN UINT16 f_usBridgeIndex )
17525
tPOCT6100_SHARED_INFO pSharedInfo;
17526
tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
17527
tPOCT6100_API_CONF_BRIDGE pTempBridgeEntry;
17530
/* Obtain local pointer to shared portion of instance. */
17531
pSharedInfo = f_pApiInstance->pSharedInfo;
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;
17538
mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, f_usBridgeIndex );
17540
/* Remove the bridge entry from the bridge list. */
17541
if ( pSharedInfo->MiscVars.usNumBridgesOpened == 1 )
17543
/* This bridge was the only one opened. */
17544
pSharedInfo->MiscVars.usFirstBridge = cOCT6100_INVALID_INDEX;
17546
else if ( pSharedInfo->MiscVars.usNumBridgesOpened > 1 )
17548
/* There are more then one bridge open, must update the list. */
17549
if ( pBridgeEntry->usPrevBridgePtr != cOCT6100_INVALID_INDEX )
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 );
17554
pTempBridgeEntry->usNextBridgePtr = pBridgeEntry->usNextBridgePtr;
17557
if ( pBridgeEntry->usNextBridgePtr != cOCT6100_INVALID_INDEX )
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 );
17562
pTempBridgeEntry->usPrevBridgePtr = pBridgeEntry->usPrevBridgePtr;
17565
if ( pSharedInfo->MiscVars.usFirstBridge == f_usBridgeIndex )
17567
/* This entry was the first of the list, make the next one be the first now. */
17568
pSharedInfo->MiscVars.usFirstBridge = pBridgeEntry->usNextBridgePtr;
17573
/* Variable has become out of sync. */
17574
return cOCT6100_ERR_FATAL_25;
17577
/*=============================================================*/
17578
/* Update the conference bridge's list entry. */
17580
/* Mark the bridge as closed. */
17581
pBridgeEntry->fFlexibleConferencing = FALSE;
17582
pBridgeEntry->fReserved = FALSE;
17583
pBridgeEntry->byEntryOpenCnt++;
17585
/* Decrement the number of conference bridges opened. */
17586
pSharedInfo->MiscVars.usNumBridgesOpened--;
17587
pSharedInfo->ChipStats.usNumberConfBridges--;
17589
/*=============================================================*/
17591
return cOCT6100_ERR_OK;
17595
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17597
Function: Oct6100ConfBridgeChanRemoveSer
17599
Description: Removes an echo channel from a conference bridge.
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.
17607
f_pConfBridgeRemove Pointer to conference bridge channel remove structure.
17609
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
17610
static UINT32 Oct6100ConfBridgeChanRemoveSer(
17611
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
17612
IN tPOCT6100_CONF_BRIDGE_CHAN_REMOVE f_pConfBridgeRemove )
17614
UINT16 usBridgeIndex;
17615
UINT16 usChanIndex=0;
17616
UINT16 usLoadEventIndex;
17617
UINT16 usSubStoreEventIndex;
17618
UINT16 usCopyEventIndex;
17620
UINT8 fFlexibleConfBridge;
17623
/* Check the validity of the channel and conference bridge given. */
17624
ulResult = Oct6100ApiCheckChanRemoveParams(
17626
f_pConfBridgeRemove,
17629
&fFlexibleConfBridge,
17632
&usSubStoreEventIndex,
17633
&usCopyEventIndex );
17634
if ( ulResult != cOCT6100_ERR_OK )
17637
/* Release all resources reserved for the conference bridge. */
17638
ulResult = Oct6100ApiReleaseChanEventResources(
17640
f_pConfBridgeRemove,
17643
fFlexibleConfBridge,
17645
usSubStoreEventIndex,
17646
usCopyEventIndex );
17647
if ( ulResult != cOCT6100_ERR_OK )
17650
/* Clear the memory entry for this channel within the bridge. */
17651
ulResult = Oct6100ApiBridgeEventRemove(
17653
f_pConfBridgeRemove,
17656
fFlexibleConfBridge,
17658
usSubStoreEventIndex,
17661
if ( ulResult != cOCT6100_ERR_OK )
17664
return cOCT6100_ERR_OK;
17668
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17670
Function: Oct6100ApiCheckChanRemoveParams
17672
Description: Check the validity of the channel and conference bridge given.
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.
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 )
17699
UINT32 ulEntryOpenCnt;
17700
tPOCT6100_API_CHANNEL pEchoChanEntry;
17701
tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
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;
17708
/* Check the channel handle only if the remove all flag is set to FALSE. */
17709
if ( f_pConfBridgeRemove->fRemoveAll == FALSE )
17711
/*=====================================================================*/
17712
/* Check the channel handle. */
17714
if ( (f_pConfBridgeRemove->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
17715
return cOCT6100_ERR_CONF_BRIDGE_INVALID_HANDLE;
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;
17721
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChanEntry, *f_pusChannelIndex )
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;
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;
17734
/*=====================================================================*/
17736
*f_pusBridgeIndex = pEchoChanEntry->usBridgeIndex;
17737
*f_pusLoadEventIndex = pEchoChanEntry->usLoadEventIndex;
17738
*f_pusSubStoreEventIndex = pEchoChanEntry->usSubStoreEventIndex;
17739
*f_pusCopyEventIndex = pEchoChanEntry->usSinCopyEventIndex;
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;
17745
mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, *f_pusBridgeIndex )
17747
/* Return whether this is a flexible bridge or not. */
17748
*f_pfFlexibleConfBridge = pBridgeEntry->fFlexibleConferencing;
17750
/* Return whether this is a tap or not. */
17751
*f_pfTap = pEchoChanEntry->fTap;
17753
else /* f_pConfBridgeRemove->fRemoveAll == TRUE */
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;
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;
17763
mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, *f_pusBridgeIndex )
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;
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;
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;
17779
/* Return whether this is a flexible bridge or not. */
17780
*f_pfFlexibleConfBridge = pBridgeEntry->fFlexibleConferencing;
17785
return cOCT6100_ERR_OK;
17789
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
17791
Function: Oct6100ApiReleaseChanEventResources
17793
Description: Release all resources reserved to the channel part of the
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.
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 )
17820
tPOCT6100_SHARED_INFO pSharedInfo;
17821
tPOCT6100_API_CHANNEL pEchoChanEntry;
17825
/* Obtain local pointer to shared portion of instance. */
17826
pSharedInfo = f_pApiInstance->pSharedInfo;
17828
if ( f_fFlexibleConfBridge == TRUE )
17830
tPOCT6100_API_FLEX_CONF_PARTICIPANT pParticipant;
17831
tPOCT6100_API_FLEX_CONF_PARTICIPANT pTempParticipant;
17833
if ( f_pConfBridgeRemove->fRemoveAll == FALSE )
17835
tPOCT6100_API_CHANNEL pTempEchoChanEntry;
17837
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
17838
mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex );
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 )
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 )
17851
ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usCopyEventIndex );
17852
if ( ulResult != cOCT6100_ERR_OK )
17858
/* This value can be 0 if the Rin port was used - no need to release. */
17859
if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
17861
/* Release the extra TSI entry.*/
17862
ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex );
17863
if ( ulResult != cOCT6100_ERR_OK )
17869
/* This value can be 0 if the Sout port was used - no need to release. */
17870
if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 )
17872
/* Release the extra TSI entry.*/
17873
ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraRinTsiMemIndex );
17874
if ( ulResult != cOCT6100_ERR_OK )
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. */
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++ )
17886
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, i );
17888
/* Channel reserved? */
17889
if ( ( i != f_usChanIndex ) && pTempEchoChanEntry->fReserved == TRUE )
17891
/* On current bridge? */
17892
if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
17894
mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
17896
/* Check if we can hear this participant. */
17897
if ( ( pParticipant->ulListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 )
17899
/* Must release the allocated mixer event. */
17900
ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] );
17901
if ( ulResult != cOCT6100_ERR_OK )
17906
pParticipant->ausLoadOrAccumulateEventIndex[ pTempParticipant->ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX;
17909
/* Check if this participant can hear us. */
17910
if ( ( pTempParticipant->ulListenerMask & ( 0x1 << pParticipant->ulListenerMaskIndex ) ) == 0x0 )
17912
/* Must release the allocated mixer event. */
17913
ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pTempParticipant->ausLoadOrAccumulateEventIndex[ pParticipant->ulListenerMaskIndex ] );
17914
if ( ulResult != cOCT6100_ERR_OK )
17919
pTempParticipant->ausLoadOrAccumulateEventIndex[ pParticipant->ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX;
17925
else /* f_pConfBridgeRemove->fRemoveAll == TRUE */
17927
UINT32 ulListenerMaskIndex;
17929
ulResult = cOCT6100_ERR_OK;
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++ )
17934
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i );
17936
/* Channel reserved? */
17937
if ( pEchoChanEntry->fReserved == TRUE )
17939
/* On current bridge? */
17940
if ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
17942
mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex );
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 )
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 )
17955
ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pEchoChanEntry->usSinCopyEventIndex );
17956
if ( ulResult != cOCT6100_ERR_OK )
17962
/* This value can be 0 if the Rin port was used - no need to release. */
17963
if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
17965
/* Release the extra TSI entry.*/
17966
ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex );
17967
if ( ulResult != cOCT6100_ERR_OK )
17973
/* This value can be 0 if the Sout port was used - no need to release. */
17974
if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 )
17976
/* Release the extra TSI entry.*/
17977
ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraRinTsiMemIndex );
17978
if ( ulResult != cOCT6100_ERR_OK )
17984
/* Check if something can be freed. */
17985
for ( ulListenerMaskIndex = 0; ulListenerMaskIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulListenerMaskIndex ++ )
17987
if ( pParticipant->ausLoadOrAccumulateEventIndex[ ulListenerMaskIndex ] != cOCT6100_INVALID_INDEX )
17989
/* Must release the allocated mixer event. */
17990
ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, pParticipant->ausLoadOrAccumulateEventIndex[ ulListenerMaskIndex ] );
17991
if ( ulResult != cOCT6100_ERR_OK )
17996
pParticipant->ausLoadOrAccumulateEventIndex[ ulListenerMaskIndex ] = cOCT6100_INVALID_INDEX;
18003
if ( ulResult != cOCT6100_ERR_OK )
18007
else /* if ( f_fFlexibleConfBridge == FALSE ) */
18009
if ( f_pConfBridgeRemove->fRemoveAll == FALSE )
18011
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
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 )
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 )
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 )
18031
ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance, f_usCopyEventIndex );
18032
if ( ulResult != cOCT6100_ERR_OK )
18038
/* This value can be 0 if the Rin port was used - no need to release. */
18039
if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
18041
/* Release the extra TSI entry. */
18042
ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex );
18043
if ( ulResult != cOCT6100_ERR_OK )
18049
else /* f_pConfBridgeRemove->fRemoveAll == TRUE */
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++ )
18054
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i );
18056
if ( pEchoChanEntry->fReserved == TRUE )
18058
if ( ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) && ( pEchoChanEntry->fTap == FALSE ) )
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 )
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 )
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 )
18080
ulResult = Oct6100ApiReleaseMixerEventEntry( f_pApiInstance,
18081
pEchoChanEntry->usSinCopyEventIndex );
18082
if ( ulResult != cOCT6100_ERR_OK )
18088
/* This value can be 0 if the Rin port was used - no need to release. */
18089
if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
18091
/* Release the extra TSI entry.*/
18092
ulResult = Oct6100ApiReleaseTsiMemEntry( f_pApiInstance, pEchoChanEntry->usExtraSinTsiMemIndex );
18093
if ( ulResult != cOCT6100_ERR_OK )
18104
return cOCT6100_ERR_OK;
18108
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
18110
Function: Oct6100ApiBridgeEventRemove
18112
Description: Remove the event from the global event list of the chip and
18113
update the bridge and channel structures.
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.
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,
18140
tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
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;
18147
tPOCT6100_API_CHANNEL pEchoChanEntry;
18148
tPOCT6100_API_CHANNEL pTempEchoChanEntry;
18150
tPOCT6100_SHARED_INFO pSharedInfo;
18151
tOCT6100_WRITE_PARAMS WriteParams;
18152
tOCT6100_READ_PARAMS ReadParams;
18155
UINT16 usPreviousEventIndex;
18156
UINT16 usTempEventIndex;
18157
UINT32 ulLoopCount = 0;
18159
UINT16 usChannelIndex;
18162
BOOL fRemoveSinCopy = FALSE;
18164
/* Obtain local pointer to shared portion of instance. */
18165
pSharedInfo = f_pApiInstance->pSharedInfo;
18167
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
18169
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
18171
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
18173
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
18174
ReadParams.pusReadData = &usReadData;
18176
mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pBridgeEntry, f_usBridgeIndex );
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;
18182
/* Make sure the dominant speaker feature is disabled first. */
18183
if ( pBridgeEntry->fDominantSpeakerSet == TRUE )
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 ) ) )
18189
/* Disable on all channels part of this conference. */
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++ )
18194
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
18196
if ( pTempEchoChanEntry->fReserved == TRUE )
18198
if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
18200
ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, usChannelIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED );
18201
if ( ulResult != cOCT6100_ERR_OK )
18207
/* Save this in the conference bridge structure. */
18208
pBridgeEntry->fDominantSpeakerSet = FALSE;
18209
pBridgeEntry->usDominantSpeakerChanIndex = cOCT6100_INVALID_INDEX;
18213
/* Only disable this current channel. */
18214
ulResult = Oct6100ApiBridgeSetDominantSpeaker( f_pApiInstance, f_usChanIndex, cOCT6100_CONF_DOMINANT_SPEAKER_UNASSIGNED );
18215
if ( ulResult != cOCT6100_ERR_OK )
18220
if ( f_fFlexibleConfBridge == TRUE )
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;
18227
for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ )
18228
ausMutePortChannelIndexes[ ulMutePortChannelIndex ] = cOCT6100_INVALID_INDEX;
18230
if ( f_pConfBridgeRemove->fRemoveAll == FALSE )
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 );
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++ )
18239
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
18241
if ( ( usChannelIndex != f_usChanIndex ) && ( pTempEchoChanEntry->fReserved == TRUE ) )
18243
if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
18245
mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
18247
/* Check if we can hear this participant. */
18248
if ( ( ( pParticipant->ulListenerMask & ( 0x1 << pTempParticipant->ulListenerMaskIndex ) ) == 0x0 )
18249
&& ( pParticipant->fFlexibleMixerCreated == TRUE )
18250
&& ( pTempEchoChanEntry->fMute == FALSE ) )
18252
/* First update the current channel's mixer. */
18253
ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel(
18259
if ( ulResult != cOCT6100_ERR_OK )
18263
/* Check if this participant can hear us. */
18264
if ( ( ( pTempParticipant->ulListenerMask & ( 0x1 << pParticipant->ulListenerMaskIndex ) ) == 0x0 )
18265
&& ( pTempParticipant->fFlexibleMixerCreated == TRUE )
18266
&& ( pEchoChanEntry->fMute == FALSE ) )
18268
/* Then update this channel's mixer. */
18269
ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel(
18275
if ( ulResult != cOCT6100_ERR_OK )
18278
/* Remember to mute the port on this channel. */
18279
for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ )
18281
if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == usChannelIndex )
18285
else if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX )
18287
ausMutePortChannelIndexes[ ulMutePortChannelIndex ] = usChannelIndex;
18296
/* Check if must manually clear the Sin copy event. */
18297
if ( ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
18298
&& ( pEchoChanEntry->fCopyEventCreated == TRUE ) )
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;
18304
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18305
if ( ulResult != cOCT6100_ERR_OK )
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 )
18313
pEchoChanEntry->fCopyEventCreated = FALSE;
18316
/* Release an entry for the participant. */
18317
ulResult = Oct6100ApiReleaseFlexConfParticipantEntry( f_pApiInstance, pEchoChanEntry->usFlexConfParticipantIndex );
18318
if ( ulResult != cOCT6100_ERR_OK )
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;
18331
/* Indicate that the extra SIN TSI is not needed anymore by the mixer. */
18332
if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
18334
pEchoChanEntry->usExtraSinTsiDependencyCnt--;
18335
pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
18338
/* Indicate that the extra RIN TSI is not needed anymore by the mixer. */
18339
if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 )
18341
pEchoChanEntry->usExtraRinTsiDependencyCnt--;
18342
pEchoChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX;
18345
/* Update the chip stats structure. */
18346
pSharedInfo->ChipStats.usNumEcChanUsingMixer--;
18348
pBridgeEntry->usNumClients--;
18350
/* For sure we have to mute the ports of this channel to be removed. */
18351
ulResult = Oct6100ApiMutePorts(
18354
pEchoChanEntry->usRinTsstIndex,
18355
pEchoChanEntry->usSinTsstIndex,
18357
if ( ulResult != cOCT6100_ERR_OK )
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 ++ )
18363
if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] != cOCT6100_INVALID_INDEX )
18365
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, ausMutePortChannelIndexes[ ulMutePortChannelIndex ] );
18367
mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
18369
if ( pTempParticipant->fFlexibleMixerCreated == FALSE )
18371
/* Check if the Rin port must be muted on this channel. */
18372
ulResult = Oct6100ApiMutePorts(
18374
ausMutePortChannelIndexes[ ulMutePortChannelIndex ],
18375
pTempEchoChanEntry->usRinTsstIndex,
18376
pTempEchoChanEntry->usSinTsstIndex,
18378
if ( ulResult != cOCT6100_ERR_OK )
18382
else /* if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX ) */
18384
/* No more channels to check for muting. */
18389
else /* if ( f_pConfBridgeRemove->fRemoveAll == TRUE ) */
18391
UINT16 usMainChannelIndex;
18393
for ( usMainChannelIndex = 0 ; usMainChannelIndex < pSharedInfo->ChipConfig.usMaxChannels ; usMainChannelIndex++ )
18395
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, usMainChannelIndex );
18397
/* If this channel is on the bridge we are closing all the channels. */
18398
if ( ( pEchoChanEntry->fReserved == TRUE ) && ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) )
18400
/* Remember to mute the port on this channel. */
18401
for( ulMutePortChannelIndex = 0; ulMutePortChannelIndex < cOCT6100_MAX_FLEX_CONF_PARTICIPANTS_PER_BRIDGE; ulMutePortChannelIndex ++ )
18403
if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == usMainChannelIndex )
18407
else if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX )
18409
ausMutePortChannelIndexes[ ulMutePortChannelIndex ] = usMainChannelIndex;
18414
mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pParticipant, pEchoChanEntry->usFlexConfParticipantIndex );
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++ )
18419
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
18420
if ( pTempEchoChanEntry->fReserved == TRUE )
18422
if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
18424
mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
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 ) )
18431
/* First update the current channel's mixer. */
18432
ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel(
18436
usMainChannelIndex,
18438
if ( ulResult != cOCT6100_ERR_OK )
18442
/* Check if this participant can hear us. */
18443
if ( ( ( pTempParticipant->ulListenerMask & ( 0x1 << pParticipant->ulListenerMaskIndex ) ) == 0x0 )
18444
&& ( pTempParticipant->fFlexibleMixerCreated == TRUE )
18445
&& ( pEchoChanEntry->fMute == FALSE ) )
18447
/* Then update this channel's mixer. */
18448
ulResult = Oct6100ApiBridgeRemoveParticipantFromChannel(
18451
usMainChannelIndex,
18454
if ( ulResult != cOCT6100_ERR_OK )
18461
/* Check if must manually clear the Sin copy event. */
18462
if ( ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
18463
&& ( pEchoChanEntry->fCopyEventCreated == TRUE ) )
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;
18469
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18470
if ( ulResult != cOCT6100_ERR_OK )
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 )
18478
pEchoChanEntry->fCopyEventCreated = FALSE;
18481
/* Release an entry for the participant. */
18482
ulResult = Oct6100ApiReleaseFlexConfParticipantEntry( f_pApiInstance, pEchoChanEntry->usFlexConfParticipantIndex );
18483
if ( ulResult != cOCT6100_ERR_OK )
18488
/*=======================================================================*/
18489
/* Update the event and channel API structure */
18491
pEchoChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
18493
pEchoChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX;
18494
pEchoChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX;
18495
pEchoChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
18497
/* Indicate that the Extra SIN TSI is not needed anymore by the mixer. */
18498
if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
18500
pEchoChanEntry->usExtraSinTsiDependencyCnt--;
18501
pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
18504
/* Indicate that the Extra RIN TSI is not needed anymore by the mixer. */
18505
if ( pEchoChanEntry->usExtraRinTsiDependencyCnt == 1 )
18507
pEchoChanEntry->usExtraRinTsiDependencyCnt--;
18508
pEchoChanEntry->usExtraRinTsiMemIndex = cOCT6100_INVALID_INDEX;
18511
/* Update the chip stats structure. */
18512
pSharedInfo->ChipStats.usNumEcChanUsingMixer--;
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 ++ )
18519
if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] != cOCT6100_INVALID_INDEX )
18521
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, ausMutePortChannelIndexes[ ulMutePortChannelIndex ] );
18523
mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
18525
if ( pTempParticipant->fFlexibleMixerCreated == FALSE )
18527
/* Check if the Rin port must be muted on this channel. */
18528
ulResult = Oct6100ApiMutePorts(
18530
ausMutePortChannelIndexes[ ulMutePortChannelIndex ],
18531
pTempEchoChanEntry->usRinTsstIndex,
18532
pTempEchoChanEntry->usSinTsstIndex,
18534
if ( ulResult != cOCT6100_ERR_OK )
18538
else /* if ( ausMutePortChannelIndexes[ ulMutePortChannelIndex ] == cOCT6100_INVALID_INDEX ) */
18540
/* No more channels to check for muting. */
18544
/* Clear the flexible conf bridge participant index. */
18545
pTempEchoChanEntry->usFlexConfParticipantIndex = cOCT6100_INVALID_INDEX;
18548
/* No more clients on bridge. */
18549
pBridgeEntry->usNumClients = 0;
18552
else /* if ( f_fFlexibleConfBridge == FALSE ) */
18554
if ( f_pConfBridgeRemove->fRemoveAll == FALSE )
18556
/* The channel index is valid. */
18557
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
18559
if ( f_fTap == TRUE )
18561
mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pBridgeEntry, pEchoChanEntry->usTapBridgeIndex );
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 );
18570
/*=======================================================================*/
18571
/* Check if have to modify the silence load event. */
18573
if ( pBridgeEntry->usNumClients != 1 )
18575
if ( pBridgeEntry->usSilenceLoadEventPtr != cOCT6100_INVALID_INDEX )
18577
if ( pBridgeEntry->usSilenceLoadEventPtr == f_usLoadEventIndex )
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 );
18582
WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_LOAD;
18583
WriteParams.usWriteData |= 1534; /* TSI index 1534 reserved for silence */
18585
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18586
if ( ulResult != cOCT6100_ERR_OK )
18589
/* Update the software model to remember the silence load. */
18590
pBridgeEntry->usSilenceLoadEventPtr = pLoadEventEntry->usNextEventPtr;
18594
/* Somebody else is the silence event, no need to worry. */
18599
/*=======================================================================*/
18602
/*=======================================================================*/
18603
/* Clear the Load event. */
18605
/* First verify if the event to be removed was a load event. */
18606
if ( f_usLoadEventIndex == pBridgeEntry->usLoadIndex )
18608
/* Change the next entry if one is present to a load event to keep the bridge alive. */
18609
if ( pBridgeEntry->usNumClients == 1 )
18611
/* There is no other entry on the bridge, no need to search for an Accumulate event. */
18612
pBridgeEntry->usLoadIndex = cOCT6100_INVALID_INDEX;
18614
/* Clear the silence event, for sure it's invalid. */
18615
pBridgeEntry->usSilenceLoadEventPtr = cOCT6100_INVALID_INDEX;
18619
/* Search for an accumulate event to tranform into a Load event. */
18620
usTempEventIndex = pLoadEventEntry->usNextEventPtr;
18623
/* Find the copy entry before the entry to remove. */
18624
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex );
18626
while( pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_SUB_STORE &&
18627
pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_STORE )
18629
if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE )
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 )
18637
WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
18638
WriteParams.usWriteData = (UINT16)(( usReadData & 0x1FFF ) | cOCT6100_MIXER_CONTROL_MEM_LOAD);
18640
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18641
if ( ulResult != cOCT6100_ERR_OK )
18644
/* Set this entry as the load index. */
18645
pBridgeEntry->usLoadIndex = usTempEventIndex;
18647
/* Update the software model. */
18648
pTempEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_LOAD;
18650
/* Stop searching. */
18654
/* Go to the next entry into the list. */
18655
usTempEventIndex = pTempEntry->usNextEventPtr;
18656
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex );
18659
if ( ulLoopCount == cOCT6100_MAX_LOOP )
18660
return cOCT6100_ERR_FATAL_9B;
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;
18668
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18669
if ( ulResult != cOCT6100_ERR_OK )
18672
/*=======================================================================*/
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;
18679
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18680
if ( ulResult != cOCT6100_ERR_OK )
18683
/*=======================================================================*/
18685
/*=======================================================================*/
18686
/* Clear the Copy event - if needed. */
18688
if ( f_usCopyEventIndex != cOCT6100_INVALID_INDEX )
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;
18694
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18695
if ( ulResult != cOCT6100_ERR_OK )
18698
if ( f_fTap == FALSE )
18700
/* Set remove Sin copy event flag to remove the event from the mixer's list. */
18701
fRemoveSinCopy = TRUE;
18703
/* Clear the copy event created flag. */
18704
pEchoChanEntry->fCopyEventCreated = FALSE;
18708
/*=======================================================================*/
18711
/*=======================================================================*/
18712
/* Now remove the event from the event list. */
18714
/* Look for the entry that is pointing at the first entry of our bridge. */
18715
if ( f_fTap == FALSE )
18717
ulResult = Oct6100ApiGetPrevLastSubStoreEvent( f_pApiInstance, f_usBridgeIndex, pBridgeEntry->usFirstLoadEventPtr, &usPreviousEventIndex );
18721
ulResult = Oct6100ApiGetPrevLastSubStoreEvent( f_pApiInstance, pEchoChanEntry->usTapBridgeIndex, pBridgeEntry->usFirstLoadEventPtr, &usPreviousEventIndex );
18724
if ( ulResult != cOCT6100_ERR_OK )
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 )
18729
if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
18731
/* No Sout copy, it has to be the head node. */
18732
usPreviousEventIndex = cOCT6100_MIXER_HEAD_NODE;
18736
/* Use the last Sout copy event. */
18737
usPreviousEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
18742
return cOCT6100_ERR_FATAL_27;
18746
if ( pBridgeEntry->usNumClients == 1 )
18748
/* An entry was found, now, modify it's value. */
18749
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex );
18751
/* Now modify the previous last Sub Store event from another bridge. */
18752
pTempEntry->usNextEventPtr = pSubStoreEventEntry->usNextEventPtr;
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;
18759
WriteParams.usWriteData = (UINT16)( pTempEntry->usNextEventPtr );
18761
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18762
if ( ulResult != cOCT6100_ERR_OK )
18765
/*=======================================================================*/
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;
18772
/*=======================================================================*/
18773
/* Update the global mixer pointers. */
18774
if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == f_usLoadEventIndex &&
18775
pSharedInfo->MixerInfo.usLastBridgeEventPtr == f_usSubStoreEventIndex )
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;
18781
else if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == f_usLoadEventIndex )
18783
pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pSubStoreEventEntry->usNextEventPtr;
18785
else if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == f_usSubStoreEventIndex )
18787
pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex;
18789
/*=======================================================================*/
18791
if ( f_fTap == TRUE )
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++ )
18798
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
18800
if ( pTempEchoChanEntry->usTapChanIndex == f_usChanIndex )
18802
tPOCT6100_API_CONF_BRIDGE pTempBridgeEntry;
18804
pTempEchoChanEntry->fBeingTapped = FALSE;
18805
pTempEchoChanEntry->usTapChanIndex = cOCT6100_INVALID_INDEX;
18807
mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( pSharedInfo, pTempBridgeEntry, f_usBridgeIndex );
18809
pTempBridgeEntry->usNumTappedClients--;
18811
/* Re-assign Rin TSST for tapped channel. */
18812
if ( pTempEchoChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
18814
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
18815
pTempEchoChanEntry->usRinTsstIndex,
18816
pTempEchoChanEntry->usRinRoutTsiMemIndex,
18817
pTempEchoChanEntry->TdmConfig.byRinPcmLaw );
18818
if ( ulResult != cOCT6100_ERR_OK )
18826
/* Check if our model is broken. */
18827
if ( usChannelIndex == pSharedInfo->ChipConfig.usMaxChannels )
18828
return cOCT6100_ERR_FATAL_D3;
18831
else /* pBridgeEntry->usNumClients > 1 */
18833
if ( pBridgeEntry->usFirstLoadEventPtr != f_usLoadEventIndex )
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 )
18841
/* Remove the load event to the list. */
18842
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex );
18844
/* Now modify the previous last Sub Store event from another bridge. */
18845
pTempEntry->usNextEventPtr = pLoadEventEntry->usNextEventPtr;
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;
18852
WriteParams.usWriteData = (UINT16)( pTempEntry->usNextEventPtr );
18854
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18855
if ( ulResult != cOCT6100_ERR_OK )
18858
/*=======================================================================*/
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 )
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 )
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 )
18876
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex );
18877
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, f_usSubStoreEventIndex );
18879
/* Now modify the last load event of the bridge. */
18880
pTempEntry->usNextEventPtr = pSubStoreEventEntry->usNextEventPtr;
18882
/*=======================================================================*/
18883
/* Modify the last node of the other bridge. */
18885
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18886
WriteParams.ulWriteAddress += 4;
18888
WriteParams.usWriteData = (UINT16)( pTempEntry->usNextEventPtr );
18890
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18891
if ( ulResult != cOCT6100_ERR_OK )
18894
/*=======================================================================*/
18896
/*=======================================================================*/
18897
/* Update the bridge pointers. */
18899
if ( pBridgeEntry->usFirstLoadEventPtr == f_usLoadEventIndex )
18900
pBridgeEntry->usFirstLoadEventPtr = pLoadEventEntry->usNextEventPtr;
18902
if ( pBridgeEntry->usFirstSubStoreEventPtr == f_usSubStoreEventIndex )
18903
pBridgeEntry->usFirstSubStoreEventPtr = pSubStoreEventEntry->usNextEventPtr;
18905
if ( pBridgeEntry->usLastSubStoreEventPtr == f_usSubStoreEventIndex )
18906
pBridgeEntry->usLastSubStoreEventPtr = usPreviousEventIndex;
18908
/*=======================================================================*/
18911
/*=======================================================================*/
18912
/* Update the global mixer pointers. */
18914
if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == f_usLoadEventIndex )
18916
pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pLoadEventEntry->usNextEventPtr;
18919
if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == f_usSubStoreEventIndex )
18921
pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex;
18923
/*=======================================================================*/
18927
/* Check if must remove the Sin copy event from the event list. */
18928
if ( fRemoveSinCopy == TRUE )
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 )
18936
/* Get the channel. */
18937
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_usChanIndex );
18939
/* Reprogram the TSST entry correctly if the Extra SIN TSI entry was released. */
18940
if ( ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 ) && ( f_fTap == FALSE ) )
18942
if ( pEchoChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
18944
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
18945
pEchoChanEntry->usSinTsstIndex,
18946
pEchoChanEntry->usSinSoutTsiMemIndex,
18947
pEchoChanEntry->TdmConfig.bySinPcmLaw );
18948
if ( ulResult != cOCT6100_ERR_OK )
18952
/* If the silence TSI is loaded on this port, update with the original sin TSI. */
18953
if ( pEchoChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX )
18955
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
18957
WriteParams.ulWriteAddress += 2;
18958
WriteParams.usWriteData = pEchoChanEntry->usSinSoutTsiMemIndex;
18960
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
18961
if ( ulResult != cOCT6100_ERR_OK )
18965
/* Set the event entries as free. */
18966
pLoadEventEntry->fReserved = FALSE;
18967
pLoadEventEntry->usEventType = cOCT6100_INVALID_INDEX;
18968
pLoadEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
18970
pSubStoreEventEntry->fReserved = FALSE;
18971
pSubStoreEventEntry->usEventType = cOCT6100_INVALID_INDEX;
18972
pSubStoreEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
18974
if ( pCopyEventEntry != NULL )
18976
pCopyEventEntry->fReserved = FALSE;
18977
pCopyEventEntry->usEventType = cOCT6100_INVALID_INDEX;
18978
pCopyEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
18981
pBridgeEntry->usNumClients--;
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;
18990
/* Indicate that the Extra SIN TSI is not needed anymore by the mixer. */
18991
if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
18993
pEchoChanEntry->usExtraSinTsiDependencyCnt--;
18994
pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
18997
/* Update the chip stats structure. */
18998
pSharedInfo->ChipStats.usNumEcChanUsingMixer--;
19000
if ( f_fTap == TRUE )
19002
/* Can now close the bridge. */
19003
tOCT6100_CONF_BRIDGE_CLOSE BridgeClose;
19005
Oct6100ConfBridgeCloseDef( &BridgeClose );
19007
BridgeClose.ulConfBridgeHndl = cOCT6100_HNDL_TAG_CONF_BRIDGE | (pBridgeEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pEchoChanEntry->usTapBridgeIndex;
19009
ulResult = Oct6100ConfBridgeCloseSer( f_pApiInstance, &BridgeClose );
19010
if ( ulResult != cOCT6100_ERR_OK )
19013
pEchoChanEntry->usTapBridgeIndex = cOCT6100_INVALID_INDEX;
19014
pEchoChanEntry->fTap = FALSE;
19017
/* Check if the Rin port must be muted. */
19018
ulResult = Oct6100ApiMutePorts(
19021
pEchoChanEntry->usRinTsstIndex,
19022
pEchoChanEntry->usSinTsstIndex,
19024
if ( ulResult != cOCT6100_ERR_OK )
19027
/*=======================================================================*/
19029
else /* f_ulBridgeChanRemove->fRemoveAll == TRUE ) */
19031
UINT16 usNextEventPtr;
19033
/* Save the next event pointer before invalidating everything. */
19034
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, pBridgeEntry->usLastSubStoreEventPtr );
19036
usNextEventPtr = pSubStoreEventEntry->usNextEventPtr;
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++ )
19041
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i );
19043
if ( pEchoChanEntry->fReserved == TRUE )
19045
if ( ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) && ( pEchoChanEntry->fTap == FALSE ) )
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 )
19051
tOCT6100_CONF_BRIDGE_CHAN_REMOVE ChanRemove;
19053
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, pEchoChanEntry->usTapChanIndex );
19055
ulResult = Oct6100ConfBridgeChanRemoveDef( &ChanRemove );
19056
if ( ulResult != cOCT6100_ERR_OK )
19059
ChanRemove.ulChannelHndl = cOCT6100_HNDL_TAG_CHANNEL | (pTempEchoChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | pEchoChanEntry->usTapChanIndex;
19061
ulResult = Oct6100ConfBridgeChanRemoveSer( f_pApiInstance, &ChanRemove );
19062
if ( ulResult != cOCT6100_ERR_OK )
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;
19071
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19072
if ( ulResult != cOCT6100_ERR_OK )
19075
/*=======================================================================*/
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;
19082
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19083
if ( ulResult != cOCT6100_ERR_OK )
19085
/*=======================================================================*/
19087
/*=======================================================================*/
19088
/* Clear the SIN copy event.*/
19090
if ( pEchoChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
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;
19096
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19097
if ( ulResult != cOCT6100_ERR_OK )
19100
/* Get a pointer to the event entry. */
19101
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, pEchoChanEntry->usSinCopyEventIndex );
19103
/* Update the next event pointer if required. */
19104
if ( usNextEventPtr == pEchoChanEntry->usSinCopyEventIndex )
19105
usNextEventPtr = pCopyEventEntry->usNextEventPtr;
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 )
19112
/* Clear the copy event created flag. */
19113
pEchoChanEntry->fCopyEventCreated = FALSE;
19116
/*=======================================================================*/
19119
/*=======================================================================*/
19120
/* Update the event and channel API structure */
19122
/* Reprogram the TSST entry correctly if the Extra SIN TSI entry was released.*/
19123
if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
19125
if ( pEchoChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
19127
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
19128
pEchoChanEntry->usSinTsstIndex,
19129
pEchoChanEntry->usSinSoutTsiMemIndex,
19130
pEchoChanEntry->TdmConfig.bySinPcmLaw );
19131
if ( ulResult != cOCT6100_ERR_OK )
19135
/* If the silence TSI is loaded on this port, update with the original Sin TSI. */
19136
if ( pEchoChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX )
19138
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pEchoChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19140
WriteParams.ulWriteAddress += 2;
19141
WriteParams.usWriteData = pEchoChanEntry->usSinSoutTsiMemIndex;
19143
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19144
if ( ulResult != cOCT6100_ERR_OK )
19149
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLoadEventEntry, pEchoChanEntry->usLoadEventIndex );
19150
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pSubStoreEventEntry, pEchoChanEntry->usSubStoreEventIndex );
19152
/* Set the event entries as free. */
19153
pLoadEventEntry->fReserved = FALSE;
19154
pLoadEventEntry->usEventType = cOCT6100_INVALID_EVENT;
19155
pLoadEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
19157
pSubStoreEventEntry->fReserved = FALSE;
19158
pSubStoreEventEntry->usEventType = cOCT6100_INVALID_EVENT;
19159
pSubStoreEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
19161
if ( pCopyEventEntry != NULL )
19163
pCopyEventEntry->fReserved = FALSE;
19164
pCopyEventEntry->usEventType = cOCT6100_INVALID_EVENT;
19165
pCopyEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
19168
/* Indicate that the Extra SIN TSI is not needed anymore by the mixer. */
19169
if ( pEchoChanEntry->usExtraSinTsiDependencyCnt == 1 )
19171
pEchoChanEntry->usExtraSinTsiDependencyCnt--;
19172
pEchoChanEntry->usExtraSinTsiMemIndex = cOCT6100_INVALID_INDEX;
19175
/* Invalidate the channel entry. */
19176
pEchoChanEntry->usLoadEventIndex = cOCT6100_INVALID_INDEX;
19177
pEchoChanEntry->usSubStoreEventIndex = cOCT6100_INVALID_INDEX;
19178
pEchoChanEntry->usSinCopyEventIndex = cOCT6100_INVALID_INDEX;
19180
/* Update the chip stats structure. */
19181
pSharedInfo->ChipStats.usNumEcChanUsingMixer--;
19183
/*=======================================================================*/
19188
ulResult = Oct6100ApiGetPrevLastSubStoreEvent( f_pApiInstance, f_usBridgeIndex, pBridgeEntry->usFirstLoadEventPtr, &usPreviousEventIndex );
19189
if ( ulResult != cOCT6100_ERR_OK )
19191
if ( cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND == ulResult )
19193
if ( pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
19195
usPreviousEventIndex = cOCT6100_MIXER_HEAD_NODE;
19199
usPreviousEventIndex = pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
19204
return cOCT6100_ERR_FATAL_28;
19208
/* An Entry was found, now, modify it's value. */
19209
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex );
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;
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;
19220
WriteParams.usWriteData = pTempEntry->usNextEventPtr;
19222
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19223
if ( ulResult != cOCT6100_ERR_OK )
19225
/*=======================================================================*/
19227
/*=======================================================================*/
19228
/* Update the global mixer pointers. */
19229
if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == pBridgeEntry->usFirstLoadEventPtr &&
19230
pSharedInfo->MixerInfo.usLastBridgeEventPtr == pBridgeEntry->usLastSubStoreEventPtr )
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;
19236
else if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == pBridgeEntry->usFirstLoadEventPtr )
19238
/* This bridge was the first bridge. */
19239
pSharedInfo->MixerInfo.usFirstBridgeEventPtr = usNextEventPtr;
19241
else if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == pBridgeEntry->usLastSubStoreEventPtr )
19243
/* This bridge was the last bridge.*/
19244
pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex;
19246
/*=======================================================================*/
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;
19254
pBridgeEntry->usSilenceLoadEventPtr = cOCT6100_INVALID_INDEX;
19256
/* Set the number of clients to 0. */
19257
pBridgeEntry->usNumClients = 0;
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++ )
19262
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, i );
19264
if ( pEchoChanEntry->fReserved == TRUE )
19266
if ( ( pEchoChanEntry->usBridgeIndex == f_usBridgeIndex ) && ( pEchoChanEntry->fTap == FALSE ) )
19268
pEchoChanEntry->usBridgeIndex = cOCT6100_INVALID_INDEX;
19270
/* Check if the Rin port must be muted. */
19271
ulResult = Oct6100ApiMutePorts(
19273
(UINT16)( i & 0xFFFF ),
19274
pEchoChanEntry->usRinTsstIndex,
19275
pEchoChanEntry->usSinTsstIndex,
19277
if ( ulResult != cOCT6100_ERR_OK )
19285
return cOCT6100_ERR_OK;
19289
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
19291
Function: Oct6100ApiBridgeRemoveParticipantFromChannel
19293
Description: This will remove a flexible conference participant from
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.
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 )
19314
tPOCT6100_API_CONF_BRIDGE pBridgeEntry;
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;
19324
tPOCT6100_API_CHANNEL pSourceChanEntry;
19325
tPOCT6100_API_CHANNEL pDestinationChanEntry;
19327
tPOCT6100_API_FLEX_CONF_PARTICIPANT pSourceParticipant;
19328
tPOCT6100_API_FLEX_CONF_PARTICIPANT pDestinationParticipant;
19330
tPOCT6100_SHARED_INFO pSharedInfo;
19331
tOCT6100_WRITE_PARAMS WriteParams;
19332
tOCT6100_READ_PARAMS ReadParams;
19335
UINT32 ulLoopCount;
19336
UINT16 usLastLoadEventIndex;
19337
UINT16 usLoadOrAccumulateEventIndex;
19338
UINT16 usTempEventIndex;
19339
UINT16 usPreviousEventIndex;
19340
UINT16 usLastEventIndex;
19343
BOOL fLastEvent = FALSE;
19344
BOOL fSoutCopyEvent = FALSE;
19346
/* Obtain local pointer to shared portion of instance. */
19347
pSharedInfo = f_pApiInstance->pSharedInfo;
19349
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
19351
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
19353
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
19355
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
19356
ReadParams.pusReadData = &usReadData;
19358
mOCT6100_GET_CONF_BRIDGE_ENTRY_PNT( f_pApiInstance->pSharedInfo, pBridgeEntry, f_usBridgeIndex );
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 );
19365
/* Check if the mixer has been created on this channel. */
19366
if ( pDestinationParticipant->fFlexibleMixerCreated == TRUE )
19368
/*=======================================================================*/
19369
/* Clear the Load or Accumulate event.*/
19371
usTempEventIndex = pDestinationChanEntry->usLoadEventIndex;
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 );
19379
pLastEventEntry = pLoadEventEntry;
19380
pLastLoadOrAccumulateEventEntry = pLoadEventEntry;
19381
usLastLoadEventIndex = usTempEventIndex;
19382
usLastEventIndex = usTempEventIndex;
19384
while( pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_SUB_STORE &&
19385
pTempEntry->usEventType != cOCT6100_MIXER_CONTROL_MEM_STORE )
19387
/* If this is the entry we are looking for. */
19388
if ( pTempEntry->usSourceChanIndex == f_usSourceChannelIndex )
19390
/* Check if this is a Load or Accumulate event. */
19391
if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_LOAD )
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 );
19397
if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE )
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 )
19405
WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
19406
WriteParams.usWriteData = (UINT16)(( usReadData & 0x1FFF ) | cOCT6100_MIXER_CONTROL_MEM_LOAD);
19408
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19409
if ( ulResult != cOCT6100_ERR_OK )
19412
/* Update the channel information with this new load event. */
19413
pDestinationChanEntry->usLoadEventIndex = pLoadTempEntry->usNextEventPtr;
19415
/* Update the software model. */
19416
pTempEntry->usEventType = cOCT6100_MIXER_CONTROL_MEM_LOAD;
19418
/* Get the previous event. */
19419
ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, cOCT6100_MIXER_HEAD_NODE, usTempEventIndex, 0, &usPreviousEventIndex );
19420
if ( ulResult != cOCT6100_ERR_OK )
19423
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLastEventEntry, usPreviousEventIndex );
19424
usLastEventIndex = usPreviousEventIndex;
19426
/* Stop searching. */
19429
else if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_STORE )
19431
/* Get back the event to remove. */
19432
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex );
19434
/* This is the only event on this channel so we can clear everything up. */
19437
/* Get the previous event. */
19438
ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, cOCT6100_MIXER_HEAD_NODE, usTempEventIndex, 0, &usPreviousEventIndex );
19439
if ( ulResult != cOCT6100_ERR_OK )
19442
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLastEventEntry, usPreviousEventIndex );
19443
usLastEventIndex = usPreviousEventIndex;
19445
/* Stop searching. */
19450
/* Software model is broken. */
19451
return cOCT6100_ERR_FATAL_C5;
19455
else if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_ACCUMULATE )
19457
/* Simply remove the entry. */
19459
/* Get the previous event. */
19460
ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, cOCT6100_MIXER_HEAD_NODE, usTempEventIndex, 0, &usPreviousEventIndex );
19461
if ( ulResult != cOCT6100_ERR_OK )
19464
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pLastEventEntry, usPreviousEventIndex );
19465
usLastEventIndex = usPreviousEventIndex;
19467
/* Stop searching. */
19472
/* Software model is broken. */
19473
return cOCT6100_ERR_FATAL_C6;
19477
pLastLoadOrAccumulateEventEntry = pTempEntry;
19478
usLastLoadEventIndex = usTempEventIndex;
19480
/* Go to the next entry into the list. */
19481
usTempEventIndex = pTempEntry->usNextEventPtr;
19482
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usTempEventIndex );
19485
if ( ulLoopCount == cOCT6100_MAX_LOOP )
19486
return cOCT6100_ERR_FATAL_C8;
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 )
19493
/* Software model is broken. */
19494
return cOCT6100_ERR_FATAL_C7;
19497
/*=======================================================================*/
19500
/*=======================================================================*/
19501
/* Clear the Store event - if needed. */
19503
if ( fLastEvent == TRUE )
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;
19508
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19509
if ( ulResult != cOCT6100_ERR_OK )
19513
/*=======================================================================*/
19516
/*=======================================================================*/
19517
/* Clear the Load or Accumulate event. */
19519
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usTempEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19520
WriteParams.usWriteData = cOCT6100_MIXER_CONTROL_MEM_NO_OP;
19522
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19523
if ( ulResult != cOCT6100_ERR_OK )
19526
/* Save this event index. It's the Load or Accumulate we want to remove from the list later. */
19527
usLoadOrAccumulateEventIndex = usTempEventIndex;
19529
/*=======================================================================*/
19532
/*=======================================================================*/
19533
/* Clear the Copy event - if needed. */
19535
if ( ( fLastEvent == TRUE ) && ( pDestinationChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) && ( f_fRemovePermanently == TRUE ) )
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;
19541
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19542
if ( ulResult != cOCT6100_ERR_OK )
19545
/* The event remove from the list will be done below. */
19547
/* Clear the copy event created flag. */
19548
pDestinationChanEntry->fCopyEventCreated = FALSE;
19551
/*=======================================================================*/
19554
/*=======================================================================*/
19555
/*=======================================================================*/
19556
/* Remove the events from the mixer event list.*/
19557
/*=======================================================================*/
19558
/*=======================================================================*/
19560
/*=======================================================================*/
19561
/* Remove the Load or Accumulate event from the event list. */
19563
if ( fLastEvent == FALSE )
19565
/*=======================================================================*/
19566
/* Remove the Accumulate event from the event list. */
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 );
19571
/* Now modify the previous last event. */
19572
pLastEventEntry->usNextEventPtr = pLoadEventEntry->usNextEventPtr;
19574
/* Modify the previous node. */
19575
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usLastEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19576
WriteParams.ulWriteAddress += 4;
19578
WriteParams.usWriteData = pLastEventEntry->usNextEventPtr;
19580
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19581
if ( ulResult != cOCT6100_ERR_OK )
19584
/* Check if this is the first load event on the bridge. */
19585
if ( pBridgeEntry->usFirstLoadEventPtr == usLoadOrAccumulateEventIndex )
19587
pBridgeEntry->usFirstLoadEventPtr = pLoadEventEntry->usNextEventPtr;
19590
/* Check if this was the first load of all bridges. */
19591
if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == usLoadOrAccumulateEventIndex )
19593
pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pLoadEventEntry->usNextEventPtr;
19596
/*=======================================================================*/
19598
else /* if ( fLastEvent == TRUE ) */
19600
/*=======================================================================*/
19601
/* Remove the Load event from the event list. */
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 )
19608
/* An Entry was found, now, modify it's value. */
19609
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pTempEntry, usPreviousEventIndex );
19611
/* Check if this is a Sout copy event. */
19612
if ( pTempEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_COPY )
19614
/* No more previous bridges. */
19615
fSoutCopyEvent = TRUE;
19618
/* Now modify the previous last Store or Sub-Store or Head-Node event from another bridge/channel. */
19619
pTempEntry->usNextEventPtr = pStoreEventEntry->usNextEventPtr;
19621
/*=======================================================================*/
19624
/*=======================================================================*/
19625
/* Modify the last node of the previous bridge/channel to point to the next bridge. */
19627
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( usPreviousEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19628
WriteParams.ulWriteAddress += 4;
19630
WriteParams.usWriteData = pTempEntry->usNextEventPtr;
19632
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19633
if ( ulResult != cOCT6100_ERR_OK )
19636
/*=======================================================================*/
19639
/*=======================================================================*/
19640
/* Set the event pointer info in the bridge stucture. */
19642
if ( pBridgeEntry->usFirstLoadEventPtr == pDestinationChanEntry->usLoadEventIndex )
19644
UINT16 usChannelIndex;
19645
tPOCT6100_API_CHANNEL pTempEchoChanEntry;
19647
pBridgeEntry->usFirstSubStoreEventPtr = cOCT6100_INVALID_INDEX;
19648
pBridgeEntry->usFirstLoadEventPtr = cOCT6100_INVALID_INDEX;
19650
/* Find the next channel in this conference that could give us valid values. */
19651
for ( usChannelIndex = 0; usChannelIndex < pSharedInfo->ChipConfig.usMaxChannels; usChannelIndex++ )
19653
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pTempEchoChanEntry, usChannelIndex );
19655
if ( ( usChannelIndex != f_usDestinationChannelIndex ) && ( pTempEchoChanEntry->fReserved == TRUE ) )
19657
if ( pTempEchoChanEntry->usBridgeIndex == f_usBridgeIndex )
19659
tPOCT6100_API_FLEX_CONF_PARTICIPANT pTempParticipant;
19661
mOCT6100_GET_FLEX_CONF_PARTICIPANT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempParticipant, pTempEchoChanEntry->usFlexConfParticipantIndex );
19663
if ( pTempParticipant->fFlexibleMixerCreated == TRUE )
19665
pBridgeEntry->usFirstSubStoreEventPtr = pTempEchoChanEntry->usSubStoreEventIndex;
19666
pBridgeEntry->usFirstLoadEventPtr = pTempEchoChanEntry->usLoadEventIndex;
19674
/* Reprogram the TSST entry correctly if the extra SIN TSI entry was released. */
19675
if ( ( pDestinationChanEntry->usExtraSinTsiDependencyCnt == 1 ) && ( f_fRemovePermanently == TRUE ) )
19677
if ( pDestinationChanEntry->usSinTsstIndex != cOCT6100_INVALID_INDEX )
19679
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
19680
pDestinationChanEntry->usSinTsstIndex,
19681
pDestinationChanEntry->usSinSoutTsiMemIndex,
19682
pDestinationChanEntry->TdmConfig.bySinPcmLaw );
19683
if ( ulResult != cOCT6100_ERR_OK )
19687
/* If the silence TSI is loaded on this port, update with the original sin TSI. */
19688
if ( pDestinationChanEntry->usSinSilenceEventIndex != cOCT6100_INVALID_INDEX )
19690
WriteParams.ulWriteAddress = cOCT6100_MIXER_CONTROL_MEM_BASE + ( pDestinationChanEntry->usSinSilenceEventIndex * cOCT6100_MIXER_CONTROL_MEM_ENTRY_SIZE );
19692
WriteParams.ulWriteAddress += 2;
19693
WriteParams.usWriteData = pDestinationChanEntry->usSinSoutTsiMemIndex;
19695
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
19696
if ( ulResult != cOCT6100_ERR_OK )
19701
/* Reprogram the TSST entry correctly if the extra RIN TSI entry was released. */
19702
if ( ( pDestinationChanEntry->usExtraRinTsiDependencyCnt == 1 ) && ( f_fRemovePermanently == TRUE ) )
19704
if ( pDestinationChanEntry->usRinTsstIndex != cOCT6100_INVALID_INDEX )
19706
ulResult = Oct6100ApiWriteInputTsstControlMemory( f_pApiInstance,
19707
pDestinationChanEntry->usRinTsstIndex,
19708
pDestinationChanEntry->usRinRoutTsiMemIndex,
19709
pDestinationChanEntry->TdmConfig.byRinPcmLaw );
19710
if ( ulResult != cOCT6100_ERR_OK )
19715
/*=======================================================================*/
19716
/* Update the global mixer pointers. */
19718
if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == usLoadOrAccumulateEventIndex &&
19719
pSharedInfo->MixerInfo.usLastBridgeEventPtr == pDestinationChanEntry->usSubStoreEventIndex )
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;
19725
else if ( pSharedInfo->MixerInfo.usFirstBridgeEventPtr == usLoadOrAccumulateEventIndex )
19727
pSharedInfo->MixerInfo.usFirstBridgeEventPtr = pStoreEventEntry->usNextEventPtr;
19729
else if ( pSharedInfo->MixerInfo.usLastBridgeEventPtr == pDestinationChanEntry->usSubStoreEventIndex )
19731
pSharedInfo->MixerInfo.usLastBridgeEventPtr = usPreviousEventIndex;
19734
/*=======================================================================*/
19737
/*=======================================================================*/
19738
/* Check if must remove the Sin copy event from the list. */
19740
if ( ( pDestinationChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX ) && ( f_fRemovePermanently == TRUE ) )
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 )
19748
/*=======================================================================*/
19752
/*=======================================================================*/
19754
if ( f_fRemovePermanently == TRUE )
19756
/* Set the event entries as free. */
19757
pLoadEventEntry->fReserved = FALSE;
19758
pLoadEventEntry->usEventType = cOCT6100_INVALID_EVENT;
19759
pLoadEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
19761
pStoreEventEntry->fReserved = FALSE;
19762
pStoreEventEntry->usEventType = cOCT6100_INVALID_EVENT;
19763
pStoreEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
19765
if ( pDestinationChanEntry->usSinCopyEventIndex != cOCT6100_INVALID_INDEX )
19767
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( pSharedInfo, pCopyEventEntry, pDestinationChanEntry->usSinCopyEventIndex );
19769
pCopyEventEntry->fReserved = FALSE;
19770
pCopyEventEntry->usEventType = cOCT6100_INVALID_EVENT;
19771
pCopyEventEntry->usNextEventPtr = cOCT6100_INVALID_INDEX;
19775
/* Flexible mixer for this channel not created anymore. */
19776
pDestinationParticipant->fFlexibleMixerCreated = FALSE;
19778
/*=======================================================================*/
19781
/*=======================================================================*/
19783
else /* if ( pDestinationChanEntry->fFlexibleMixerCreated == FALSE ) */
19785
/* This point should never be reached. */
19786
return cOCT6100_ERR_FATAL_C9;
19789
return cOCT6100_ERR_OK;
19794
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
19796
Function: Oct6100ApiReleaseBridgeEntry
19798
Description: Release an entry from the bridge list.
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.
19806
f_usBridgeIndex List entry reserved.
19808
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
19809
static UINT32 Oct6100ApiReleaseBridgeEntry(
19810
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
19811
IN UINT16 f_usBridgeIndex )
19813
PVOID pBridgeAlloc;
19816
mOCT6100_GET_CONF_BRIDGE_ALLOC_PNT( f_pApiInstance->pSharedInfo, pBridgeAlloc )
19818
ulResult = OctapiLlmAllocDealloc( pBridgeAlloc, f_usBridgeIndex );
19819
if ( ulResult != cOCT6100_ERR_OK )
19820
return cOCT6100_ERR_FATAL_2A;
19822
return cOCT6100_ERR_OK;
19826
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
19828
Function: Oct6100ApiGetPrevLastSubStoreEvent
19830
Description: This function will search for the first valid LastSubStoreEvent
19831
in a bridge located before the current bridge in the bridge
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.
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.
19844
f_pusBridgeEntry Bridge entry.
19845
f_usBridgeFirstLoadEventPtr Load index to check against.
19846
First valid sub store index.
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 )
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;
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 );
19867
/* Since we have flexible bridges, we have to */
19868
/* run down the list and check for the appropriate event. */
19870
/* Travel down the list for the last Store or Sub/Store event before the bridge. */
19872
if ( f_pApiInstance->pSharedInfo->MixerInfo.usLastSoutCopyEventPtr == cOCT6100_INVALID_INDEX )
19874
/* The only node in the list then is the head node.*/
19875
usHeadEventPtr = cOCT6100_MIXER_HEAD_NODE;
19879
usHeadEventPtr = f_pApiInstance->pSharedInfo->MixerInfo.usLastSoutCopyEventPtr;
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 )
19888
if ( ( pTempMixerEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_STORE )
19889
|| ( pTempMixerEntry->usEventType == cOCT6100_MIXER_CONTROL_MEM_SUB_STORE ) )
19891
usLastSubStoreEventPtr = usNextEventPtr;
19894
/* Next pointer. */
19895
usCurrentPtr = usNextEventPtr;
19896
usNextEventPtr = pTempMixerEntry->usNextEventPtr;
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;
19904
if ( usNextEventPtr != cOCT6100_INVALID_INDEX )
19905
mOCT6100_GET_MIXER_EVENT_ENTRY_PNT( f_pApiInstance->pSharedInfo, pTempMixerEntry, usNextEventPtr );
19908
if ( ulLoopCount == cOCT6100_MAX_LOOP )
19909
return cOCT6100_ERR_FATAL_CA;
19912
/* Return the result to the user. */
19913
*f_pusLastSubStoreEventIndex = usLastSubStoreEventPtr;
19919
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
19921
Function: Oct6100ApiGetPreviousEvent
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
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.
19933
f_usEntryIndex Event entry index.
19934
f_pusBridgeEntry Bridge entry.
19935
f_pusPreviousIndex Previous index.
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 )
19945
tPOCT6100_API_MIXER_EVENT pCurrentEntry;
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 );
19951
/* Avoid stack overflows. */
19952
if ( f_usLoopCnt == cOCT6100_MAX_MIXER_EVENTS )
19953
return cOCT6100_ERR_FATAL_E3;
19955
if ( pCurrentEntry->usNextEventPtr == cOCT6100_INVALID_INDEX )
19957
/* Event not found. */
19958
ulResult = cOCT6100_ERR_CONF_MIXER_EVENT_NOT_FOUND;
19960
else if ( pCurrentEntry->usNextEventPtr == f_usSearchedIndex )
19962
/* We found our node. */
19963
*f_pusPreviousIndex = f_usEntryIndex;
19964
ulResult = cOCT6100_ERR_OK;
19968
/* Keep searching.*/
19970
ulResult = Oct6100ApiGetPreviousEvent( f_pApiInstance, pCurrentEntry->usNextEventPtr, f_usSearchedIndex, f_usLoopCnt, f_pusPreviousIndex );
19977
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
19979
Function: Oct6100ApiBridgeSetDominantSpeaker
19981
Description: This function will set the index of the dominant speaker
19982
for the channel index specified.
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
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.
19996
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
19997
static UINT32 Oct6100ApiBridgeSetDominantSpeaker(
19998
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
19999
IN UINT16 f_usChannelIndex,
20000
IN UINT16 f_usDominantSpeakerIndex )
20002
UINT32 ulBaseAddress;
20003
UINT32 ulFeatureBytesOffset;
20004
UINT32 ulFeatureBitOffset;
20005
UINT32 ulFeatureFieldLength;
20010
tPOCT6100_API_CHANNEL pEchoChanEntry;
20012
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChanEntry, f_usChannelIndex );
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;
20019
/* Retrieve the current configuration. */
20020
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
20022
ulBaseAddress + ulFeatureBytesOffset,
20025
if ( ulResult != cOCT6100_ERR_OK )
20028
/* Clear previous value set in the feature field.*/
20029
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
20031
ulTempData &= (~ulMask);
20032
ulTempData |= ( ( f_usDominantSpeakerIndex ) << ulFeatureBitOffset );
20034
/* Save the new dominant speaker. */
20035
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
20037
ulBaseAddress + ulFeatureBytesOffset,
20040
if ( ulResult != cOCT6100_ERR_OK )
20043
return cOCT6100_ERR_OK;
20048
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20050
Function: Oct6100ApiReleaseFlexConfParticipantEntry
20052
Description: Release an entry from the flexible conferencing participant
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.
20061
f_usParticipantIndex List entry reserved.
20063
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20064
static UINT32 Oct6100ApiReleaseFlexConfParticipantEntry(
20065
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
20066
IN UINT16 f_usParticipantIndex )
20068
PVOID pParticipantAlloc;
20071
mOCT6100_GET_FLEX_CONF_PARTICIPANT_ALLOC_PNT( f_pApiInstance->pSharedInfo, pParticipantAlloc )
20073
ulResult = OctapiLlmAllocDealloc( pParticipantAlloc, f_usParticipantIndex );
20074
if ( ulResult != cOCT6100_ERR_OK )
20075
return cOCT6100_ERR_FATAL_2A;
20077
return cOCT6100_ERR_OK;
20079
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20081
File: oct6100_debug.c
20083
Copyright (c) 2001-2005 Octasic Inc.
20087
This file contains functions used to debug the OCT6100.
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.
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
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.
20103
$Octasic_Release: OCT612xAPI-01.00-PR38 $
20105
$Octasic_Revision: 58 $
20107
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20110
/***************************** INCLUDE FILES *******************************/
20112
#include "octdef.h"
20114
#include "oct6100api/oct6100_defines.h"
20115
#include "oct6100api/oct6100_errors.h"
20116
#include "oct6100api/oct6100_apiud.h"
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"
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"
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"
20141
/**************************** PRIVATE FUNCTIONS ****************************/
20143
#ifndef cOCT6100_REMOVE_EVENTS
20144
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20146
File: oct6100_events.c
20148
Copyright (c) 2001-2005 Octasic Inc.
20152
This file contains functions used to retrieve tone and playout events.
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.
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
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.
20168
$Octasic_Release: OCT612xAPI-01.00-PR38 $
20170
$Octasic_Revision: 79 $
20172
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20175
/***************************** INCLUDE FILES *******************************/
20177
#include "octdef.h"
20179
#include "oct6100api/oct6100_defines.h"
20180
#include "oct6100api/oct6100_errors.h"
20181
#include "oct6100api/oct6100_apiud.h"
20183
#include "apilib/octapi_llman.h"
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"
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"
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"
20211
/**************************** PUBLIC FUNCTIONS *****************************/
20213
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20215
Function: Oct6100EventGetTone
20217
Description: Retreives an array of tone events.
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.
20225
f_pEventGetTone Pointer to structure used to store the Tone events.
20227
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20228
static UINT32 Oct6100EventGetToneDef(
20229
tPOCT6100_EVENT_GET_TONE f_pEventGetTone )
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;
20237
return cOCT6100_ERR_OK;
20241
static UINT32 Oct6100EventGetTone(
20242
tPOCT6100_INSTANCE_API f_pApiInstance,
20243
tPOCT6100_EVENT_GET_TONE f_pEventGetTone )
20245
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
20246
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
20247
UINT32 ulSerRes = cOCT6100_ERR_OK;
20248
UINT32 ulFncRes = cOCT6100_ERR_OK;
20250
/* Set the process context of the serialize structure. */
20251
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
20252
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
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 )
20260
/* Call the serialized function. */
20261
ulFncRes = Oct6100EventGetToneSer( f_pApiInstance, f_pEventGetTone );
20268
/* Release the seized semaphores. */
20269
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
20270
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
20272
/* If an error occured then return the error code. */
20273
if ( ulSerRes != cOCT6100_ERR_OK )
20275
if ( ulFncRes != cOCT6100_ERR_OK )
20278
return cOCT6100_ERR_OK;
20283
/**************************** PRIVATE FUNCTIONS ****************************/
20285
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20287
Function: Oct6100ApiGetEventsSwSizes
20289
Description: Gets the sizes of all portions of the API instance pertinent
20290
to the management of the tone events and playout events
20293
-------------------------------------------------------------------------------
20294
| Argument | Description
20295
-------------------------------------------------------------------------------
20296
f_pOpenChip Pointer to chip configuration struct.
20297
f_pInstSizes Pointer to struct containing instance sizes.
20299
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20300
static UINT32 Oct6100ApiGetEventsSwSizes(
20301
IN tPOCT6100_CHIP_OPEN f_pOpenChip,
20302
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
20308
/* Memory needed by soft tone event buffers. */
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 );
20313
/* Round off the sizes of the soft buffers above. */
20314
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulSoftToneEventsBuffer, ulTempVar )
20320
/* Memory needed by soft playout stop event buffers. */
20321
if ( f_pOpenChip->ulSoftBufferPlayoutEventsBufSize != cOCT6100_INVALID_VALUE )
20323
f_pInstSizes->ulSoftBufPlayoutEventsBuffer = ( f_pOpenChip->ulSoftBufferPlayoutEventsBufSize + 1 ) * sizeof( tOCT6100_API_BUFFER_PLAYOUT_EVENT );
20325
/* Round off the sizes of the soft buffers above. */
20326
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulSoftBufPlayoutEventsBuffer, ulTempVar )
20328
else /* if ( f_pInstSizes->ulSoftBufferPlayoutEventsBufSize == cOCT6100_INVALID_VALUE ) */
20330
f_pInstSizes->ulSoftBufPlayoutEventsBuffer = 0;
20334
return cOCT6100_ERR_OK;
20338
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20340
Function: Oct6100EventGetToneSer
20342
Description: Retreives an array of tone event from the software event buffer.
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.
20350
f_pEventGetTone Pointer to structure which will contain the retreived
20353
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20354
static UINT32 Oct6100EventGetToneSer(
20355
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
20356
IN OUT tPOCT6100_EVENT_GET_TONE f_pEventGetTone )
20358
tPOCT6100_SHARED_INFO pSharedInfo;
20359
tPOCT6100_API_TONE_EVENT pSoftEvent;
20360
UINT32 ulSoftReadPnt;
20361
UINT32 ulSoftWritePnt;
20362
UINT32 ulSoftBufSize;
20363
UINT32 ulNumEventsReturned;
20366
/* Get local pointer(s). */
20367
pSharedInfo = f_pApiInstance->pSharedInfo;
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;
20374
/* Check max tones. */
20375
if ( f_pEventGetTone->ulMaxToneEvent > pSharedInfo->ChipConfig.ulSoftToneEventsBufSize )
20376
return cOCT6100_ERR_EVENTS_MAX_TONES;
20378
if ( f_pEventGetTone->fResetBufs == FALSE )
20380
/* Check if the events need to be fetched from the chip buffer. */
20381
ulSoftReadPnt = pSharedInfo->SoftBufs.ulToneEventBufferReadPtr;
20382
ulSoftWritePnt = pSharedInfo->SoftBufs.ulToneEventBufferWritePtr;
20384
if ( ulSoftReadPnt == ulSoftWritePnt )
20386
ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, f_pEventGetTone->fResetBufs );
20387
if ( ulResult != cOCT6100_ERR_OK )
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;
20397
if ( ulSoftReadPnt != ulSoftWritePnt )
20399
ulNumEventsReturned = 0;
20401
while( (ulSoftReadPnt != ulSoftWritePnt) && ( ulNumEventsReturned != f_pEventGetTone->ulMaxToneEvent) )
20403
/* Get a pointer to the first event in the buffer. */
20404
mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
20405
pSoftEvent += ulSoftReadPnt;
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;
20414
/* Update the pointers of the soft buffer. */
20416
if ( ulSoftReadPnt == ulSoftBufSize )
20419
ulNumEventsReturned++;
20422
pSharedInfo->SoftBufs.ulToneEventBufferReadPtr = ulSoftReadPnt;
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 ) */
20429
f_pEventGetTone->fMoreEvents = FALSE;
20431
/* Remember this state in the interrupt manager. */
20432
pSharedInfo->IntrptManage.fToneEventsPending = FALSE;
20435
f_pEventGetTone->ulNumValidToneEvent = ulNumEventsReturned;
20439
/* No valid tone.*/
20440
f_pEventGetTone->ulNumValidToneEvent = 0;
20441
f_pEventGetTone->fMoreEvents = FALSE;
20443
/* Remember this state in the interrupt manager. */
20444
pSharedInfo->IntrptManage.fToneEventsPending = FALSE;
20446
return cOCT6100_ERR_EVENTS_TONE_BUF_EMPTY;
20449
else /* ( f_pEventGetTone->fResetBufs == TRUE ) */
20451
/* Empty the hardware buffer. */
20452
ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, f_pEventGetTone->fResetBufs );
20453
if ( ulResult != cOCT6100_ERR_OK )
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;
20460
f_pEventGetTone->fMoreEvents = FALSE;
20461
f_pEventGetTone->ulNumValidToneEvent = 0;
20463
/* Remember this state in the interrupt manager. */
20464
pSharedInfo->IntrptManage.fToneEventsPending = FALSE;
20467
return cOCT6100_ERR_OK;
20471
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20473
Function: Oct6100ApiTransferToneEvents
20475
Description: Transfers all tone events from the PGSP event out chip buffer
20476
to the soft buffer.
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.
20484
f_ulResetBuf Reset flag.
20486
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20487
static UINT32 Oct6100ApiTransferToneEvents(
20488
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
20489
IN UINT32 f_ulResetBuf )
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;
20501
UINT32 usChannelIndex;
20502
UINT32 ulBaseTimestamp;
20504
UINT32 ulNumWordsToRead;
20509
UINT16 ausReadData[ cOCT6100_NUM_WORDS_PER_TONE_EVENT ];
20511
UINT32 ulExtToneDetectionPort;
20513
/* Get local pointer(s). */
20514
pSharedInfo = f_pApiInstance->pSharedInfo;
20516
/* If the buffer is to be reset then clear the overflow flag. */
20517
if ( f_ulResetBuf == TRUE )
20519
pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt = 0;
20522
/* Set some parameters of read struct. */
20523
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
20525
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
20526
ReadParams.pusReadData = &usReadData;
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 )
20534
ulChipReadPtr = usReadData;
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 )
20542
ulChipWritePtr = usReadData;
20544
ulChipBufFill = (( ulChipWritePtr - ulChipReadPtr ) & ( cOCT6100_NUM_PGSP_EVENT_OUT - 1 ));
20546
/* Set some parameters of write structs. */
20547
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
20549
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
20551
BurstParams.pProcessContext = f_pApiInstance->pProcessContext;
20553
BurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
20555
/* Read in the tone event one at a time. */
20556
for ( i = 0; i < ulChipBufFill; i++ )
20558
/* Skip the event processing if the buffer is to be reset. */
20559
if ( f_ulResetBuf == TRUE )
20561
/* Update the control variables of the buffer. */
20563
if ( cOCT6100_NUM_PGSP_EVENT_OUT == ulChipReadPtr )
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) )
20573
BurstParams.ulReadAddress = cOCT6100_PGSP_EVENT_OUT_BASE + ( ulChipReadPtr * cOCT6100_PGSP_TONE_EVENT_SIZE );
20574
BurstParams.pusReadData = ausReadData;
20576
ulNumWordsToRead = cOCT6100_PGSP_TONE_EVENT_SIZE / 2;
20578
while ( ulNumWordsToRead > 0 )
20580
if ( ulNumWordsToRead > pSharedInfo->ChipConfig.usMaxRwAccesses )
20582
BurstParams.ulReadLength = pSharedInfo->ChipConfig.usMaxRwAccesses;
20586
BurstParams.ulReadLength = ulNumWordsToRead;
20589
mOCT6100_DRIVER_READ_BURST_API( BurstParams, ulResult );
20590
if ( ulResult != cOCT6100_ERR_OK )
20593
BurstParams.pusReadData += BurstParams.ulReadLength;
20594
BurstParams.ulReadAddress += BurstParams.ulReadLength * 2;
20596
ulNumWordsToRead -= BurstParams.ulReadLength;
20599
/* Verify if the event is valid. */
20600
if ( ( ausReadData[ 0 ] & cOCT6100_VALID_TONE_EVENT ) == 0x0 )
20601
return cOCT6100_ERR_FATAL_2D;
20603
/* First extract the channel number of the tone event. */
20604
usChannelIndex = ausReadData[ 1 ] & 0x3FF;
20606
/* Now the timestamp. */
20607
ulBaseTimestamp = ausReadData[ 2 ] << 16;
20608
ulBaseTimestamp |= ausReadData[ 3 ];
20610
/* This timestamp is 256 in adwance, must remove 256 frames. */
20611
ulBaseTimestamp -= 256;
20613
/* Fetch the channel stucture to validate which event can be reported. */
20614
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, usChannelIndex );
20616
if ( pEchoChannel->fReserved != TRUE )
20618
/* Update the control variables of the buffer. */
20620
if ( ulChipReadPtr == cOCT6100_NUM_PGSP_EVENT_OUT )
20623
/* This channel has been closed since the generation of the event. */
20627
/* Extract the extended tone detection port if available. */
20628
if ( pEchoChannel->ulExtToneChanMode == cOCT6100_API_EXT_TONE_SIN_PORT_MODE )
20630
ulExtToneDetectionPort = cOCT6100_CHANNEL_PORT_SIN;
20632
else if ( pEchoChannel->ulExtToneChanMode == cOCT6100_API_EXT_TONE_RIN_PORT_MODE )
20634
ulExtToneDetectionPort = cOCT6100_CHANNEL_PORT_RIN;
20636
/* Modify the channel index. */
20637
usChannelIndex = pEchoChannel->usExtToneChanIndex;
20639
/* Change the channel entry to the original one for statistical purposes. */
20640
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, usChannelIndex );
20643
else /* pEchoChannel->ulExtToneChanMode == cOCT6100_API_EXT_TONE_DISABLED */
20645
ulExtToneDetectionPort = cOCT6100_INVALID_VALUE;
20649
/* Verify all the possible events that might have been detected. */
20650
for ( j = 4; j < cOCT6100_NUM_WORDS_PER_TONE_EVENT; j++ )
20652
if ( (( ausReadData[ j ] >> 8 ) & 0x7 ) != 0x0 )
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 )
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) )
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;
20665
/* Decode the event type. */
20666
switch(( ausReadData[ j ] >> 8 ) & 0x7 )
20669
pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT;
20672
pSoftEvent->ulEventType = cOCT6100_TONE_STOP;
20675
/* This one is a little tricky. We first */
20676
/* generate the "PRESENT" event and then generate the "STOP" event. */
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;
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;
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) )
20695
mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
20696
pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr;
20698
pSoftEvent->ulEventType = cOCT6100_TONE_STOP;
20702
/* Set the overflow flag of the buffer. */
20703
pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
20705
/* We continue in the loop in order to empty the hardware buffer. */
20711
pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT;
20714
pSharedInfo->ErrorStats.ulToneDetectorErrorCnt++;
20715
/* do not process this packet*/
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;
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;
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;
20736
/* Set the overflow flag of the buffer. */
20737
pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
20739
/* We continue in the loop in order to empty the hardware buffer. */
20746
ulResult = Oct6100ApiIsSSTone(
20748
pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID,
20750
if ( ulResult != cOCT6100_ERR_OK )
20753
if ( fSSTone == TRUE )
20755
/* Check if this is a "PRESENT" or "STOP" event */
20756
switch( ( ( ausReadData[ j ] >> 8 ) & 0x7 ) )
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 );
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;
20776
/* Check the other tone of this word. */
20777
if ( ( ausReadData[ j ] & 0x7 ) != 0x0 )
20779
if ((( pEchoChannel->aulToneConf[ ulToneCnt / 32 ] >> ( 31 - ( ulToneCnt % 32 ))) & 0x1) == 1 )
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) )
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;
20789
/* Decode the event type. */
20790
switch(( ausReadData[ j ] ) & 0x7 )
20793
pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT;
20796
pSoftEvent->ulEventType = cOCT6100_TONE_STOP;
20799
/* This one is a little tricky. We first */
20800
/* generate the "PRESENT" event and then generate the "STOP" event. */
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;
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;
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) )
20819
mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
20820
pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr;
20822
pSoftEvent->ulEventType = cOCT6100_TONE_STOP;
20826
/* Set the overflow flag of the buffer. */
20827
pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
20829
/* We continue in the loop in order to empty the hardware buffer. */
20835
pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT;
20838
pSharedInfo->ErrorStats.ulToneDetectorErrorCnt++;
20839
/* Do not process this packet. */
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;
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;
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;
20861
/* Set the overflow flag of the buffer. */
20862
pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
20864
/* We continue in the loop in order to empty the hardware buffer. */
20871
ulResult = Oct6100ApiIsSSTone(
20873
pSharedInfo->ImageInfo.aToneInfo[ ulToneCnt ].ulToneID,
20875
if ( ulResult != cOCT6100_ERR_OK )
20878
if ( fSSTone == TRUE )
20880
/* Check if this is a "PRESENT" event. */
20881
switch ( ( ausReadData[ j ] ) & 0x7 )
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 );
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;
20904
/* Set the overflow flag of the buffer. */
20905
pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
20907
/* We continue in the loop in order to empty the hardware buffer. */
20910
/* Update the control variables of the buffer. */
20912
if ( ulChipReadPtr == cOCT6100_NUM_PGSP_EVENT_OUT )
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 )
20926
return cOCT6100_ERR_OK;
20930
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
20932
Function: Oct6100BufferPlayoutTransferEvents
20934
Description: Check all channels that are currently playing a buffer and
20935
generate an event if a buffer has stopped playing.
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.
20943
f_ulResetBuf Reset flag.
20945
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
20946
static UINT32 Oct6100BufferPlayoutTransferEvents(
20947
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
20948
IN UINT32 f_ulResetBuf )
20950
tPOCT6100_SHARED_INFO pSharedInfo;
20951
tPOCT6100_API_CHANNEL pEchoChannel;
20953
UINT32 ulChannelIndex;
20955
UINT32 ulLastBufPlayoutEventBufferOverflowCnt;
20957
/* Get local pointer(s). */
20958
pSharedInfo = f_pApiInstance->pSharedInfo;
20960
/* If the buffer is to be reset then clear the overflow flag. */
20961
if ( f_ulResetBuf == TRUE )
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;
20969
/* Check if buffer playout has been activated on some ports. */
20970
if ( pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts == 0 )
20972
/* Buffer playout has not been activated on any channel, */
20973
/* let's not waste time here. */
20974
return cOCT6100_ERR_OK;
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;
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++ )
20983
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, ulChannelIndex );
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 )
20991
/* Read in the event only if there's enough room in the soft buffer. */
20992
if ( ulLastBufPlayoutEventBufferOverflowCnt == pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt )
20994
/* Check Rout buffer playout first. */
20995
if ( ( pEchoChannel->fRinBufPlayoutNotifyOnStop == TRUE )
20996
&& ( pEchoChannel->fRinBufPlaying == TRUE ) )
20998
ulResult = Oct6100BufferPlayoutCheckForSpecificEvent( f_pApiInstance, ulChannelIndex, cOCT6100_CHANNEL_PORT_ROUT, TRUE, NULL );
20999
if ( ulResult != cOCT6100_ERR_OK )
21003
else /* if ( ulLastBufPlayoutEventBufferOverflowCnt != pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt ) */
21005
/* Get out of the loop, no more events can be inserted in the soft buffer. */
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 )
21013
/* Check Sout buffer playout. */
21014
if ( ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == TRUE )
21015
&& ( pEchoChannel->fSoutBufPlaying == TRUE ) )
21017
ulResult = Oct6100BufferPlayoutCheckForSpecificEvent( f_pApiInstance, ulChannelIndex, cOCT6100_CHANNEL_PORT_SOUT, TRUE, NULL );
21018
if ( ulResult != cOCT6100_ERR_OK )
21022
else /* if ( ulLastBufPlayoutEventBufferOverflowCnt != pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt ) */
21024
/* Get out of the loop, no more events can be inserted in the soft buffer. */
21030
return cOCT6100_ERR_OK;
21034
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21036
Function: Oct6100BufferPlayoutCheckForSpecificEvent
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.
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.
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.
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 )
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;
21069
UINT32 ulReadPtrBytesOfst;
21070
UINT32 ulReadPtrBitOfst;
21071
UINT32 ulReadPtrFieldSize;
21073
UINT32 ulWritePtrBytesOfst;
21074
UINT32 ulWritePtrBitOfst;
21075
UINT32 ulWritePtrFieldSize;
21077
UINT32 ulPlayoutBaseAddress;
21082
UINT32 ulUserEventId;
21083
UINT32 ulEventType;
21085
/* Get local pointer(s). */
21086
pSharedInfo = f_pApiInstance->pSharedInfo;
21088
/* Compare the read and write pointers for matching. If they matched, playout stopped. */
21089
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, f_ulChannelIndex );
21091
/* Set the playout feature base address. */
21092
ulPlayoutBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_ulChannelIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
21094
if ( f_ulChannelPort == cOCT6100_CHANNEL_PORT_ROUT )
21096
/* Check on the Rout port. */
21097
ulUserEventId = pEchoChannel->ulRinUserBufPlayoutEventId;
21098
ulEventType = pEchoChannel->byRinPlayoutStopEventType;
21100
ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.usDwordOffset * 4;
21101
ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byBitOffset;
21102
ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byFieldSize;
21104
ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.usDwordOffset * 4;
21105
ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byBitOffset;
21106
ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byFieldSize;
21108
else /* if ( f_ulChannelPort == cOCT6100_CHANNEL_PORT_SOUT ) */
21110
/* Check on the Sout port. */
21111
ulUserEventId = pEchoChannel->ulSoutUserBufPlayoutEventId;
21112
ulEventType = pEchoChannel->bySoutPlayoutStopEventType;
21114
ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.usDwordOffset * 4;
21115
ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byBitOffset;
21116
ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byFieldSize;
21118
ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.usDwordOffset * 4;
21119
ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byBitOffset;
21120
ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byFieldSize;
21123
/* Retrieve the current write pointer. */
21124
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
21126
ulPlayoutBaseAddress + ulWritePtrBytesOfst,
21129
if ( ulResult != cOCT6100_ERR_OK )
21132
mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask );
21134
/* Store the write pointer.*/
21135
ulWritePtr = ( ulTempData & ulMask ) >> ulWritePtrBitOfst;
21137
/* Read the read pointer.*/
21138
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
21140
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
21141
ReadParams.pusReadData = &usReadData;
21142
ReadParams.ulReadAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst;
21144
/* Optimize this access by only reading the word we are interested in. */
21145
if ( ulReadPtrBitOfst < 16 )
21146
ReadParams.ulReadAddress += 2;
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 )
21153
/* Move data at correct position according to what was read. */
21154
if ( ulReadPtrBitOfst < 16 )
21155
ulTempData = usReadData;
21157
ulTempData = usReadData << 16;
21159
mOCT6100_CREATE_FEATURE_MASK( ulReadPtrFieldSize, ulReadPtrBitOfst, &ulMask );
21161
/* Store the read pointer. */
21162
ulReadPtr = ( ulTempData & ulMask ) >> ulReadPtrBitOfst;
21164
/* Playout has finished when the read pointer reaches the write pointer. */
21165
if ( ulReadPtr != ulWritePtr )
21167
/* Still playing -- do not generate an event. */
21168
if ( f_pfEventDetected != NULL )
21169
*f_pfEventDetected = FALSE;
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 ) )
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;
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;
21189
/* Generate millisecond timestamp. */
21190
GetTimeParms.pProcessContext = f_pApiInstance->pProcessContext;
21191
ulResult = Oct6100UserGetTime( &GetTimeParms );
21192
if ( ulResult != cOCT6100_ERR_OK )
21195
pSoftEvent->ulTimestamp = ( GetTimeParms.aulWallTimeUs[ 0 ] / 1000 );
21196
pSoftEvent->ulTimestamp += ( GetTimeParms.aulWallTimeUs[ 1 ] ) * ( 0xFFFFFFFF / 1000 );
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;
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;
21207
else if ( f_fSaveToSoftBuffer == TRUE )
21209
/* Set the overflow flag of the buffer. */
21210
pSharedInfo->SoftBufs.ulBufPlayoutEventBufferOverflowCnt++;
21213
/* Update the channel entry to set the playing flag to FALSE. */
21215
/* Select the port of interest. */
21216
if ( f_ulChannelPort == cOCT6100_CHANNEL_PORT_ROUT )
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--;
21222
pEchoChannel->fRinBufPlaying = FALSE;
21223
pEchoChannel->fRinBufPlayoutNotifyOnStop = FALSE;
21225
/* Clear optimization flag if possible. */
21226
if ( ( pEchoChannel->fSoutBufPlaying == FALSE )
21227
&& ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == FALSE ) )
21229
/* Buffer playout is no more active on this channel. */
21230
pEchoChannel->fBufPlayoutActive = FALSE;
21233
else /* f_ulChannelPort == cOCT6100_CHANNEL_PORT_SOUT */
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--;
21239
pEchoChannel->fSoutBufPlaying = FALSE;
21240
pEchoChannel->fSoutBufPlayoutNotifyOnStop = FALSE;
21242
/* Clear optimization flag if possible. */
21243
if ( ( pEchoChannel->fRinBufPlaying == FALSE )
21244
&& ( pEchoChannel->fRinBufPlayoutNotifyOnStop == FALSE ) )
21246
/* Buffer playout is no more active on this channel. */
21247
pEchoChannel->fBufPlayoutActive = FALSE;
21251
/* Return that an event was detected. */
21252
if ( f_pfEventDetected != NULL )
21253
*f_pfEventDetected = TRUE;
21256
return cOCT6100_ERR_OK;
21259
#endif /* cOCT6100_REMOVE_EVENTS */
21260
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21262
File: oct6100_interrupts.c
21264
Copyright (c) 2001-2005 Octasic Inc.
21268
This file contains the API's interrupt service routine and all of its
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.
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
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.
21285
$Octasic_Release: OCT612xAPI-01.00-PR38 $
21287
$Octasic_Revision: 71 $
21289
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21292
/***************************** INCLUDE FILES *******************************/
21294
#include "octdef.h"
21296
#include "oct6100api/oct6100_defines.h"
21297
#include "oct6100api/oct6100_errors.h"
21298
#include "oct6100api/oct6100_apiud.h"
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"
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"
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"
21320
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21322
Function: Oct6100InterruptServiceRoutine
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
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.
21336
f_pIntFlags Pointer to structure containing event flags returned
21339
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21340
static UINT32 Oct6100InterruptServiceRoutineDef(
21341
tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
21343
f_pIntFlags->fFatalGeneral = FALSE;
21344
f_pIntFlags->ulFatalGeneralFlags = 0x0;
21345
f_pIntFlags->fFatalReadTimeout = FALSE;
21347
f_pIntFlags->fErrorRefreshTooLate = FALSE;
21348
f_pIntFlags->fErrorPllJitter = FALSE;
21350
f_pIntFlags->fErrorOverflowToneEvents = FALSE;
21352
f_pIntFlags->fErrorH100OutOfSync = FALSE;
21353
f_pIntFlags->fErrorH100ClkA = FALSE;
21354
f_pIntFlags->fErrorH100ClkB = FALSE;
21355
f_pIntFlags->fErrorH100FrameA = FALSE;
21357
f_pIntFlags->fToneEventsPending = FALSE;
21358
f_pIntFlags->fBufferPlayoutEventsPending = FALSE;
21360
f_pIntFlags->fApiSynch = FALSE;
21364
return cOCT6100_ERR_OK;
21368
static UINT32 Oct6100InterruptServiceRoutine(
21369
tPOCT6100_INSTANCE_API f_pApiInstance,
21370
tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
21372
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
21373
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
21377
/* Set the process context of the serialize structure. */
21378
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
21379
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
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 )
21387
/* Call the serialized sub-function. */
21388
ulFncRes = Oct6100InterruptServiceRoutineSer( f_pApiInstance, f_pIntFlags );
21395
/* Release the serialization object. */
21396
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
21397
ulResult = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
21398
if ( ulResult != cOCT6100_ERR_OK )
21401
/* Check for an error in the sub-function. */
21402
if ( ulFncRes != cOCT6100_ERR_OK )
21405
return cOCT6100_ERR_OK;
21409
/**************************** PRIVATE FUNCTIONS ****************************/
21412
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21414
Function: Oct6100ApiIsrSwInit
21416
Description: Initializes portions of API instance associated to the API's
21417
interrupt service routine.
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.
21425
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21426
static UINT32 Oct6100ApiIsrSwInit(
21427
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
21429
tPOCT6100_SHARED_INFO pSharedInfo;
21431
/* Get local pointer to shared portion of instance. */
21432
pSharedInfo = f_pApiInstance->pSharedInfo;
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;
21442
/* Indicate that the mclk interrupt is not active at the moment. */
21443
pSharedInfo->IntrptManage.fMclkIntrptActive = FALSE;
21445
/* Indicate that no buffer playout events are pending for the moment. */
21446
pSharedInfo->IntrptManage.fBufferPlayoutEventsPending = FALSE;
21448
/* Indicate that no tone events are pending for the moment. */
21449
pSharedInfo->IntrptManage.fToneEventsPending = FALSE;
21451
/* The ISR has never been called. */
21452
pSharedInfo->IntrptManage.fIsrCalled = FALSE;
21454
return cOCT6100_ERR_OK;
21458
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21460
Function: Oct6100ApiIsrHwInit
21462
Description: Initializes the chip's interrupt registers.
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.
21470
f_pIntrptConfig Pointer to structure defining how the interrupts
21471
should be configured.
21473
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21474
static UINT32 Oct6100ApiIsrHwInit(
21475
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
21476
IN tPOCT6100_INTERRUPT_CONFIGURE f_pIntrptConfig )
21478
tOCT6100_WRITE_PARAMS WriteParams;
21481
/* Set some parameters of write struct. */
21482
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
21484
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
21486
/*==================================================================================*/
21487
/* Enable all the interrupts */
21489
WriteParams.ulWriteAddress = 0x104;
21490
WriteParams.usWriteData = 0x0001;
21491
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21492
if ( ulResult != cOCT6100_ERR_OK )
21495
WriteParams.ulWriteAddress = 0x204;
21496
WriteParams.usWriteData = 0x1C05;
21497
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21498
if ( ulResult != cOCT6100_ERR_OK )
21501
WriteParams.ulWriteAddress = 0x304;
21502
WriteParams.usWriteData = 0xFFFF;
21503
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21504
if ( ulResult != cOCT6100_ERR_OK )
21507
WriteParams.ulWriteAddress = 0x504;
21508
WriteParams.usWriteData = 0x0001;
21509
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21510
if ( ulResult != cOCT6100_ERR_OK )
21513
WriteParams.ulWriteAddress = 0x704;
21514
WriteParams.usWriteData = 0x0007;
21515
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
21516
if ( ulResult != cOCT6100_ERR_OK )
21519
/*==================================================================================*/
21521
/* Calculate the number of mclk cycles in 1 ms. */
21522
f_pApiInstance->pSharedInfo->IntrptManage.ulNumMclkCyclesIn1Ms = f_pApiInstance->pSharedInfo->MiscVars.ulMclkFreq / 1000;
21524
/* Configure the interrupt registers as requested by the user. */
21525
ulResult = Oct6100InterruptConfigureSer( f_pApiInstance, f_pIntrptConfig, TRUE );
21526
if ( ulResult != cOCT6100_ERR_OK )
21529
return cOCT6100_ERR_OK;
21533
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21535
Function: Oct6100InterruptConfigureSer
21537
Description: Configure the operation of interrupt groups.
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.
21545
f_pIntrptConfig Pointer to interrupt configuration structure.
21546
f_fCheckParams Check parameter enable flag.
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 )
21554
tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
21555
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
21558
/* Check for errors. */
21559
if ( f_fCheckParams == TRUE )
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;
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;
21595
/* Copy the configuration to the API instance. */
21596
pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
21597
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
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 );
21605
f_pIntrptConfig->ulFatalMemoryTimeout = ((f_pIntrptConfig->ulFatalMemoryTimeout + 9) / 10) * 10;
21606
pIntrptConfig->ulFatalMemoryTimeoutMclk = f_pIntrptConfig->ulFatalMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
21608
f_pIntrptConfig->ulErrorMemoryTimeout = ((f_pIntrptConfig->ulErrorMemoryTimeout + 9) / 10) * 10;
21609
pIntrptConfig->ulErrorMemoryTimeoutMclk = f_pIntrptConfig->ulErrorMemoryTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
21611
f_pIntrptConfig->ulErrorOverflowToneEventsTimeout = ((f_pIntrptConfig->ulErrorOverflowToneEventsTimeout + 9) / 10) * 10;
21612
pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk = f_pIntrptConfig->ulErrorOverflowToneEventsTimeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
21614
f_pIntrptConfig->ulErrorH100Timeout = ((f_pIntrptConfig->ulErrorH100Timeout + 9) / 10) * 10;
21615
pIntrptConfig->ulErrorH100TimeoutMclk = f_pIntrptConfig->ulErrorH100Timeout * pIntrptManage->ulNumMclkCyclesIn1Ms;
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. */
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;
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 ) */
21634
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_DISABLED )
21635
pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_ACTIVE;
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 ) */
21645
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_DISABLED )
21646
pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_ACTIVE;
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 ) */
21656
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_DISABLED )
21657
pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_ACTIVE;
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 ) */
21667
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_DISABLED )
21668
pIntrptManage->byErrorH100State = cOCT6100_INTRPT_ACTIVE;
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 )
21676
return cOCT6100_ERR_OK;
21680
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21682
Function: Oct6100InterruptServiceRoutineSer
21684
Description: Serialized sub-function of API's interrupt service routine.
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.
21692
f_pIntFlags Pointer to structure containing event flags returned
21695
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
21696
static UINT32 Oct6100InterruptServiceRoutineSer(
21697
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
21698
IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
21700
tPOCT6100_SHARED_INFO pSharedInfo;
21701
tOCT6100_READ_PARAMS ReadParams;
21702
tOCT6100_WRITE_PARAMS WriteParams;
21703
UINT32 ulRegister210h;
21707
/* Get local pointer(s). */
21708
pSharedInfo = f_pApiInstance->pSharedInfo;
21710
/* Must update the statistics. Set parameters in read and write structs. */
21711
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
21713
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
21715
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
21717
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
21718
ReadParams.pusReadData = &usReadData;
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 )
21725
ulRegister210h = usReadData;
21727
/* Update the extended mclk counter. */
21728
ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance );
21729
if ( ulResult != cOCT6100_ERR_OK )
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 )
21737
if ( (usReadData & 0x1) != 0 && pSharedInfo->IntrptManage.fMclkIntrptActive == TRUE )
21739
/* Update timeout periods. */
21740
ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance );
21741
if ( ulResult != cOCT6100_ERR_OK )
21744
f_pIntFlags->fApiSynch = TRUE;
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 )
21751
ulRegister210h = usReadData;
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 )
21759
/* Empty the tone buffer if any events are pending. */
21760
ulResult = Oct6100ApiTransferToneEvents( f_pApiInstance, FALSE );
21761
if ( ulResult != cOCT6100_ERR_OK )
21764
/* Set the tone events pending flag. */
21765
f_pIntFlags->fToneEventsPending = pSharedInfo->IntrptManage.fToneEventsPending;
21767
/* Check for buffer playout events and insert in the software queue -- if activated. */
21768
if ( pSharedInfo->ChipConfig.ulSoftBufPlayoutEventsBufSize != 0 )
21770
ulResult = Oct6100BufferPlayoutTransferEvents( f_pApiInstance, FALSE );
21771
if ( ulResult != cOCT6100_ERR_OK )
21774
/* Set the buffer playout events pending flag. */
21775
f_pIntFlags->fBufferPlayoutEventsPending = pSharedInfo->IntrptManage.fBufferPlayoutEventsPending;
21778
/* Update the states of each interrupt group. */
21779
ulResult = Oct6100ApiUpdateIntrptStates( f_pApiInstance, f_pIntFlags );
21780
if ( ulResult != cOCT6100_ERR_OK )
21783
/* Check the state of the NLP timestamp if required.*/
21784
ulResult = Oct6100ApiCheckProcessorState( f_pApiInstance, f_pIntFlags );
21785
if ( ulResult != cOCT6100_ERR_OK )
21788
/* Write to the necessary IE registers. */
21789
ulResult = Oct6100ApiWriteIntrptRegs( f_pApiInstance );
21790
if ( ulResult != cOCT6100_ERR_OK )
21793
/* Schedule the next mclk interrupt, if one is needed. */
21794
ulResult = Oct6100ApiScheduleNextMclkIntrptSer( f_pApiInstance );
21795
if ( ulResult != cOCT6100_ERR_OK )
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 )
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 )
21814
return cOCT6100_ERR_OK;
21818
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
21820
Function: Oct6100ApiReadIntrptRegs
21822
Description: Reads the interrupt registers of all modules currently
21823
indicating an interrupt condition.
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.
21831
f_pIntFlags Pointer to an interrupt flag structure.
21832
f_ulRegister210h Value of register 0x210.
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 )
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;
21848
UINT32 ulFeatureBytesOffset;
21849
UINT32 ulFeatureBitOffset;
21850
UINT32 ulFeatureFieldLength;
21851
UINT32 ulTempData = 0;
21852
UINT32 ulCounterValue;
21855
/* Get local pointer(s). */
21856
pSharedInfo = f_pApiInstance->pSharedInfo;
21857
pErrorStats = &pSharedInfo->ErrorStats;
21858
pIntrptManage = &pSharedInfo->IntrptManage;
21860
/* Set some parameters of read struct. */
21861
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
21863
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
21864
ReadParams.pusReadData = &usReadData;
21866
/* Set some parameters of write struct. */
21867
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
21869
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
21873
/* CPU registers. */
21874
if ( (f_ulRegister210h & 0x00001) != 0 )
21876
/*=======================================================================*/
21877
/* Read registers of this module. */
21878
ReadParams.ulReadAddress = 0x102;
21879
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
21880
if ( ulResult != cOCT6100_ERR_OK )
21883
/* Check which interrupt(s) were set. */
21884
if ( (usReadData & 0x0001) != 0 )
21886
f_pIntFlags->fFatalReadTimeout = TRUE;
21887
pErrorStats->ulInternalReadTimeoutCnt++;
21890
pIntrptManage->usRegister102h = usReadData;
21891
/*=======================================================================*/
21895
pIntrptManage->usRegister102h = 0x0;
21898
/* MAIN registers. */
21899
if ( (f_ulRegister210h & 0x00002) != 0 )
21901
/*=======================================================================*/
21902
/* Read registers of this module. */
21903
ReadParams.ulReadAddress = 0x202;
21904
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
21905
if ( ulResult != cOCT6100_ERR_OK )
21908
/* Save current value in instance. */
21909
pIntrptManage->usRegister202h = usReadData;
21911
/* Check which interrupts were set. */
21912
if ( (usReadData & 0x0001) != 0 )
21914
f_pIntFlags->fErrorRefreshTooLate = TRUE;
21915
pErrorStats->ulSdramRefreshTooLateCnt++;
21917
if ( (usReadData & 0x0800) != 0 )
21919
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_1;
21920
f_pIntFlags->fFatalGeneral = TRUE;
21921
pErrorStats->fFatalChipError = TRUE;
21923
if ( (usReadData & 0x1000) != 0 )
21925
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_2;
21926
f_pIntFlags->fFatalGeneral = TRUE;
21927
pErrorStats->fFatalChipError = TRUE;
21929
if ( (usReadData & 0x0400) != 0 )
21931
f_pIntFlags->fErrorPllJitter = TRUE;
21932
pErrorStats->ulPllJitterErrorCnt++;
21934
/* Update the PLL jitter error count here. */
21935
if ( pSharedInfo->DebugInfo.fPouchCounter == TRUE )
21937
ulFeatureBytesOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.usDwordOffset * 4;
21938
ulFeatureBitOffset = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byBitOffset;
21939
ulFeatureFieldLength = pSharedInfo->MemoryMap.PouchCounterFieldOfst.byFieldSize;
21941
ulResult = Oct6100ApiReadDword( f_pApiInstance,
21942
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
21945
/* Read previous value set in the feature field. */
21946
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
21948
/* Update counter. */
21949
ulCounterValue = ulTempData & ulMask;
21950
ulCounterValue = ulCounterValue >> ulFeatureBitOffset;
21952
/* Handle wrap around case. */
21953
ulCounterValue &= ( 1 << ulFeatureFieldLength ) - 1;
21955
/* Clear old counter value. */
21956
ulTempData &= (~ulMask);
21957
ulTempData |= ulCounterValue << ulFeatureBitOffset;
21959
/* Write the DWORD where the field is located.*/
21960
ulResult = Oct6100ApiWriteDword( f_pApiInstance,
21961
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
21963
if ( ulResult != cOCT6100_ERR_OK )
21968
/*=======================================================================*/
21972
pIntrptManage->usRegister202h = 0x0;
21975
/* H.100 registers. */
21976
if ( (f_ulRegister210h & 0x00004) != 0 )
21978
/*=======================================================================*/
21979
/* Read registers of this module. */
21980
ReadParams.ulReadAddress = 0x302;
21981
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
21982
if ( ulResult != cOCT6100_ERR_OK )
21985
/* Check which interrupts were set. */
21986
if ( (usReadData & 0x0100) != 0 )
21988
f_pIntFlags->fErrorH100OutOfSync = TRUE;
21989
pErrorStats->ulH100OutOfSyncCnt++;
21991
if ( (usReadData & 0x1000) != 0 )
21993
f_pIntFlags->fErrorH100FrameA = TRUE;
21994
pErrorStats->ulH100FrameABadCnt++;
21996
if ( (usReadData & 0x4000) != 0 )
21998
f_pIntFlags->fErrorH100ClkA = TRUE;
21999
pErrorStats->ulH100ClkABadCnt++;
22001
if ( (usReadData & 0x8000) != 0 )
22003
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
22005
f_pIntFlags->fErrorH100ClkB = TRUE;
22006
pErrorStats->ulH100ClkBBadCnt++;
22010
pIntrptManage->usRegister302h = usReadData;
22011
/*=======================================================================*/
22015
pIntrptManage->usRegister302h = 0x0;
22018
/* TDMIE registers. */
22019
if ( (f_ulRegister210h & 0x00010) != 0 )
22021
/*=======================================================================*/
22022
/* Read register. */
22023
ReadParams.ulReadAddress = 0x502;
22024
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22025
if ( ulResult != cOCT6100_ERR_OK )
22028
/* Check which interrupts were set. */
22029
if ( (usReadData & 0x0002) != 0 )
22031
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_3;
22032
f_pIntFlags->fFatalGeneral = TRUE;
22033
pErrorStats->fFatalChipError = TRUE;
22036
pIntrptManage->usRegister502h = usReadData;
22037
/*=======================================================================*/
22041
pIntrptManage->usRegister502h = 0x0;
22044
/* PGSP registers. */
22045
if ( (f_ulRegister210h & 0x00080) != 0 )
22047
/*=======================================================================*/
22048
/* Read register. */
22049
ReadParams.ulReadAddress = 0x702;
22050
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22051
if ( ulResult != cOCT6100_ERR_OK )
22054
/* Check which interrupts were set. */
22055
if ( (usReadData & 0x0002) != 0 )
22057
f_pIntFlags->fErrorOverflowToneEvents = TRUE;
22058
pErrorStats->ulOverflowToneEventsCnt++;
22061
pIntrptManage->usRegister702h = usReadData;
22062
/*=======================================================================*/
22066
pIntrptManage->usRegister702h = 0x0;
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 )
22075
/* Remember that we are being called. */
22076
pSharedInfo->IntrptManage.fIsrCalled = TRUE;
22078
if ( pSharedInfo->DebugInfo.fIsIsrCalledField == TRUE )
22080
ulFeatureBytesOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.usDwordOffset * 4;
22081
ulFeatureBitOffset = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byBitOffset;
22082
ulFeatureFieldLength = pSharedInfo->MemoryMap.IsIsrCalledFieldOfst.byFieldSize;
22084
ulResult = Oct6100ApiReadDword( f_pApiInstance,
22085
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
22088
/* Read previous value set in the feature field. */
22089
mOCT6100_CREATE_FEATURE_MASK( ulFeatureFieldLength, ulFeatureBitOffset, &ulMask );
22091
/* Clear the field. */
22092
ulTempData &= (~ulMask);
22094
/* Write the DWORD where the field is located.*/
22095
ulResult = Oct6100ApiWriteDword( f_pApiInstance,
22096
cOCT6100_POUCH_BASE + ulFeatureBytesOffset,
22098
if ( ulResult != cOCT6100_ERR_OK )
22103
return cOCT6100_ERR_OK;
22107
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22109
Function: Oct6100ApiUpdateIntrptStates
22111
Description: Updates the state of all interrupt register groups.
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.
22119
f_pIntFlags Interrupt flags.
22121
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22122
static UINT32 Oct6100ApiUpdateIntrptStates(
22123
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
22124
IN tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
22126
tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
22127
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
22129
pIntrptConfig = &f_pApiInstance->pSharedInfo->IntrptConfig;
22130
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
22132
/*-----------------------------------------------------------------------*/
22133
if ( ( f_pIntFlags->fFatalReadTimeout == TRUE) &&
22134
pIntrptConfig->byFatalMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
22135
pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22137
pIntrptManage->byFatalMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
22138
pIntrptManage->ulFatalMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
22139
pIntrptManage->ulFatalMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
22141
/*-----------------------------------------------------------------------*/
22142
if ( (f_pIntFlags->fErrorRefreshTooLate == TRUE ||
22143
f_pIntFlags->fErrorPllJitter == TRUE ) &&
22144
pIntrptConfig->byErrorMemoryConfig == cOCT6100_INTERRUPT_TIMEOUT &&
22145
pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
22147
pIntrptManage->byErrorMemoryState = cOCT6100_INTRPT_WILL_TIMEOUT;
22148
pIntrptManage->ulErrorMemoryDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
22149
pIntrptManage->ulErrorMemoryDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
22151
/*-----------------------------------------------------------------------*/
22152
if ( (f_pIntFlags->fErrorOverflowToneEvents == TRUE) &&
22153
pIntrptConfig->byErrorOverflowToneEventsConfig == cOCT6100_INTERRUPT_TIMEOUT &&
22154
pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
22156
pIntrptManage->byErrorOverflowToneEventsState = cOCT6100_INTRPT_WILL_TIMEOUT;
22157
pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
22158
pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
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 )
22168
pIntrptManage->byErrorH100State = cOCT6100_INTRPT_WILL_TIMEOUT;
22169
pIntrptManage->ulErrorH100DisableMclkHigh = pIntrptManage->ulRegMclkTimeHigh;
22170
pIntrptManage->ulErrorH100DisableMclkLow = pIntrptManage->ulRegMclkTimeLow;
22172
/*-----------------------------------------------------------------------*/
22174
return cOCT6100_ERR_OK;
22178
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22180
Function: Oct6100ApiWriteIntrptRegs
22182
Description: Writes to interrupt registers to clear interrupt condition, and
22183
writes to an interrupt's IE register if interrupt is to time
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.
22192
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22193
static UINT32 Oct6100ApiWriteIntrptRegs(
22194
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
22196
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
22197
tOCT6100_WRITE_PARAMS WriteParams;
22201
/* Get some local pointers. */
22202
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
22204
/* Set some parameters of write struct. */
22205
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
22207
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
22211
/*===========================================================================*/
22212
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
22214
WriteParams.ulWriteAddress = 0x104;
22215
WriteParams.usWriteData = 0x0000;
22217
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22218
if ( ulResult != cOCT6100_ERR_OK )
22221
if ( (pIntrptManage->usRegister102h & cOCT6100_INTRPT_MASK_REG_102H) != 0 )
22223
WriteParams.ulWriteAddress = 0x102;
22224
WriteParams.usWriteData = pIntrptManage->usRegister102h;
22225
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22226
if ( ulResult != cOCT6100_ERR_OK )
22229
/*===========================================================================*/
22231
/*===========================================================================*/
22232
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT ||
22233
pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_WILL_TIMEOUT )
22235
WriteParams.ulWriteAddress = 0x204;
22236
WriteParams.usWriteData = 0x0000;
22238
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22239
WriteParams.usWriteData |= 0x1800;
22241
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
22242
WriteParams.usWriteData |= 0x0401;
22244
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22245
if ( ulResult != cOCT6100_ERR_OK )
22248
if ( (pIntrptManage->usRegister202h & cOCT6100_INTRPT_MASK_REG_202H) != 0 )
22250
WriteParams.ulWriteAddress = 0x202;
22251
WriteParams.usWriteData = pIntrptManage->usRegister202h;
22252
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22253
if ( ulResult != cOCT6100_ERR_OK )
22256
/*===========================================================================*/
22258
/*===========================================================================*/
22259
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_WILL_TIMEOUT )
22261
WriteParams.ulWriteAddress = 0x304;
22262
WriteParams.usWriteData = 0x0000;
22264
if ( pIntrptManage->fMclkIntrptActive == TRUE )
22265
WriteParams.usWriteData |= 0x0001;
22267
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22268
if ( ulResult != cOCT6100_ERR_OK )
22271
if ( (pIntrptManage->usRegister302h & cOCT6100_INTRPT_MASK_REG_302H) != 0 )
22273
WriteParams.ulWriteAddress = 0x302;
22274
WriteParams.usWriteData = pIntrptManage->usRegister302h;
22275
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22276
if ( ulResult != cOCT6100_ERR_OK )
22279
/*===========================================================================*/
22281
/*===========================================================================*/
22282
if ( (pIntrptManage->usRegister502h & cOCT6100_INTRPT_MASK_REG_502H) != 0 )
22284
WriteParams.ulWriteAddress = 0x502;
22285
WriteParams.usWriteData = pIntrptManage->usRegister502h;
22286
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22287
if ( ulResult != cOCT6100_ERR_OK )
22290
/*===========================================================================*/
22292
/*===========================================================================*/
22293
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_WILL_TIMEOUT )
22295
WriteParams.ulWriteAddress = 0x704;
22296
WriteParams.usWriteData = 0x0000;
22298
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22299
if ( ulResult != cOCT6100_ERR_OK )
22302
if ( (pIntrptManage->usRegister702h & cOCT6100_INTRPT_MASK_REG_702H) != 0 )
22304
WriteParams.ulWriteAddress = 0x702;
22305
WriteParams.usWriteData = pIntrptManage->usRegister702h;
22306
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22307
if ( ulResult != cOCT6100_ERR_OK )
22310
/*===========================================================================*/
22314
return cOCT6100_ERR_OK;
22318
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22320
Function: Oct6100ApiWriteIeRegs
22322
Description: Writes the IE field of each interrupt register.
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.
22330
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22331
static UINT32 Oct6100ApiWriteIeRegs(
22332
tPOCT6100_INSTANCE_API f_pApiInstance )
22334
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
22335
tOCT6100_WRITE_PARAMS WriteParams;
22336
tOCT6100_READ_PARAMS ReadParams;
22339
/* Get some local pointers. */
22340
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
22342
/* Set some parameters of write struct. */
22343
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
22345
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
22348
/* Set some parameters of read struct. */
22349
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
22351
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
22353
/*==================================================================================*/
22354
WriteParams.ulWriteAddress = 0x104;
22355
WriteParams.usWriteData = 0x0000;
22357
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22358
WriteParams.usWriteData |= 0x0001;
22360
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22361
if ( ulResult != cOCT6100_ERR_OK )
22363
/*==================================================================================*/
22365
/*==================================================================================*/
22366
WriteParams.ulWriteAddress = 0x204;
22367
WriteParams.usWriteData = 0x0000;
22369
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22370
WriteParams.usWriteData |= 0x1800;
22371
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
22372
WriteParams.usWriteData |= 0x0401;
22374
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22375
if ( ulResult != cOCT6100_ERR_OK )
22377
/*==================================================================================*/
22379
/*==================================================================================*/
22380
WriteParams.ulWriteAddress = 0x304;
22381
WriteParams.usWriteData = 0x0000;
22383
if ( pIntrptManage->fMclkIntrptActive == TRUE )
22384
WriteParams.usWriteData |= 0x0001;
22385
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
22387
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
22388
WriteParams.usWriteData |= 0xD100;
22390
WriteParams.usWriteData |= 0x5100;
22393
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22394
if ( ulResult != cOCT6100_ERR_OK )
22396
/*==================================================================================*/
22398
/*==================================================================================*/
22399
WriteParams.ulWriteAddress = 0x504;
22400
WriteParams.usWriteData = 0x0000;
22402
if ( pIntrptManage->byFatalGeneralState == cOCT6100_INTRPT_ACTIVE )
22403
WriteParams.usWriteData |= 0x0002;
22405
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22406
if ( ulResult != cOCT6100_ERR_OK )
22408
/*==================================================================================*/
22410
/*==================================================================================*/
22411
WriteParams.ulWriteAddress = 0x704;
22412
WriteParams.usWriteData = 0x0000;
22414
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
22415
WriteParams.usWriteData |= 0x0002;
22417
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22418
if ( ulResult != cOCT6100_ERR_OK )
22420
/*==================================================================================*/
22423
/*==================================================================================*/
22424
/* Enable the GLOBAL IEs for the interrupt pin. */
22425
WriteParams.ulWriteAddress = 0x218;
22426
WriteParams.usWriteData = 0x00D7;
22428
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22429
if ( ulResult != cOCT6100_ERR_OK )
22431
/*==================================================================================*/
22433
return cOCT6100_ERR_OK;
22437
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22439
Function: Oct6100ApiReadChipMclkTime
22441
Description: Reads the chip's mclk cycle count to construct a chip time.
22442
The time is used to manage interrupts.
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.
22450
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22451
static UINT32 Oct6100ApiReadChipMclkTime(
22452
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
22454
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
22455
tPOCT6100_SHARED_INFO pSharedInfo;
22456
tOCT6100_READ_PARAMS ReadParams;
22457
UINT32 ulCheckData;
22462
/* Get local pointer(s). */
22463
pSharedInfo = f_pApiInstance->pSharedInfo;
22464
pIntrptManage = &pSharedInfo->IntrptManage;
22466
/* Assign memory for read data. */
22467
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
22469
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
22470
ReadParams.pusReadData = &usReadData;
22472
/* Perform reads. */
22473
for ( i = 0; i < 100; i++ )
22475
ReadParams.ulReadAddress = 0x306;
22476
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22477
if ( ulResult != cOCT6100_ERR_OK )
22479
pIntrptManage->ulRegMclkTimeHigh = usReadData & 0xFF;
22480
ulCheckData = usReadData;
22482
ReadParams.ulReadAddress = 0x308;
22483
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22484
if ( ulResult != cOCT6100_ERR_OK )
22486
pIntrptManage->ulRegMclkTimeLow = (usReadData & 0xFFFF) << 16;
22488
ReadParams.ulReadAddress = 0x306;
22489
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22490
if ( ulResult != cOCT6100_ERR_OK )
22492
if ( ulCheckData == usReadData )
22497
return cOCT6100_ERR_FATAL_2F;
22499
return cOCT6100_ERR_OK;
22503
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22505
Function: Oct6100ApiUpdateIntrptTimeouts
22507
Description: Checks which interrupt groups have finished their timeout
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.
22516
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22517
static UINT32 Oct6100ApiUpdateIntrptTimeouts(
22518
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
22520
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
22521
tOCT6100_WRITE_PARAMS WriteParams;
22522
UINT32 ulRegMclkTimePlus5MsHigh;
22523
UINT32 ulRegMclkTimePlus5MsLow;
22525
BOOL fFatalMemoryChange = FALSE;
22526
BOOL fDataErrMemoryChange = FALSE;
22527
BOOL fErrorOverflowToneEventsChange = FALSE;
22528
BOOL fH100ErrorChange = FALSE;
22530
/* Get local pointer to interrupt management structure. */
22531
pIntrptManage = &f_pApiInstance->pSharedInfo->IntrptManage;
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;
22540
/* Check which interrupts are timed out and need to be reenabled now. */
22541
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
22543
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulFatalMemoryDisableMclkHigh, pIntrptManage->ulFatalMemoryDisableMclkLow, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptManage->byFatalMemoryState, fFatalMemoryChange )
22545
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_IN_TIMEOUT )
22547
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorMemoryDisableMclkHigh, pIntrptManage->ulErrorMemoryDisableMclkLow, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptManage->byErrorMemoryState, fDataErrMemoryChange )
22549
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_IN_TIMEOUT )
22551
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorOverflowToneEventsDisableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsDisableMclkLow, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptManage->byErrorOverflowToneEventsState, fErrorOverflowToneEventsChange )
22553
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_IN_TIMEOUT )
22555
mOCT6100_CHECK_INTRPT_TIMEOUT( ulRegMclkTimePlus5MsHigh, ulRegMclkTimePlus5MsLow, pIntrptManage->ulErrorH100DisableMclkHigh, pIntrptManage->ulErrorH100DisableMclkLow, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptManage->byErrorH100State, fH100ErrorChange )
22558
/* Set some parameters of write struct. */
22559
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
22561
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
22563
/* Write to the IE registers which have changed. */
22565
/*==================================================================================*/
22566
if ( fFatalMemoryChange == TRUE )
22568
WriteParams.ulWriteAddress = 0x104;
22569
WriteParams.usWriteData = 0x0000;
22571
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22572
WriteParams.usWriteData |= 0x0001;
22574
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22575
if ( ulResult != cOCT6100_ERR_OK )
22579
/*==================================================================================*/
22581
/*==================================================================================*/
22582
if ( fFatalMemoryChange == TRUE ||
22583
fDataErrMemoryChange == TRUE )
22585
WriteParams.ulWriteAddress = 0x204;
22586
WriteParams.usWriteData = 0x0000;
22588
if ( pIntrptManage->byFatalMemoryState == cOCT6100_INTRPT_ACTIVE )
22589
WriteParams.usWriteData |= 0x1800;
22590
if ( pIntrptManage->byErrorMemoryState == cOCT6100_INTRPT_ACTIVE )
22591
WriteParams.usWriteData |= 0x0401;
22593
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22594
if ( ulResult != cOCT6100_ERR_OK )
22598
/*==================================================================================*/
22600
/*==================================================================================*/
22601
if ( pIntrptManage->fMclkIntrptActive == TRUE ||
22602
fH100ErrorChange == TRUE )
22604
WriteParams.ulWriteAddress = 0x304;
22605
WriteParams.usWriteData = 0x0000;
22607
if ( pIntrptManage->fMclkIntrptActive == TRUE )
22608
WriteParams.usWriteData |= 0x0001;
22610
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
22612
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
22613
WriteParams.usWriteData |= 0xD100;
22615
WriteParams.usWriteData |= 0x5100;
22618
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22619
if ( ulResult != cOCT6100_ERR_OK )
22623
/*==================================================================================*/
22626
/*==================================================================================*/
22627
if ( fErrorOverflowToneEventsChange == TRUE )
22629
WriteParams.ulWriteAddress = 0x704;
22630
WriteParams.usWriteData = 0x0000;
22632
if ( pIntrptManage->byErrorOverflowToneEventsState == cOCT6100_INTRPT_ACTIVE )
22633
WriteParams.usWriteData |= 0x0002;
22635
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22636
if ( ulResult != cOCT6100_ERR_OK )
22640
/*==================================================================================*/
22642
return cOCT6100_ERR_OK;
22646
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22648
Function: Oct6100ApiScheduleNextMclkIntrptSer
22650
Description: Serialized sub-function of Oct6100ApiScheduleNextMclkIntrpt.
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.
22658
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22659
static UINT32 Oct6100ApiScheduleNextMclkIntrptSer(
22660
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
22662
tPOCT6100_SHARED_INFO pSharedInfo;
22663
tPOCT6100_API_INTRPT_CONFIG pIntrptConfig;
22664
tPOCT6100_API_INTRPT_MANAGE pIntrptManage;
22665
tOCT6100_WRITE_PARAMS WriteParams;
22667
UINT32 ulRegMclkTimeHigh;
22668
UINT32 ulRegMclkTimeLow;
22670
BOOL fConditionFlag = TRUE;
22672
/* Get local pointer(s). */
22673
pSharedInfo = f_pApiInstance->pSharedInfo;
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;
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;
22686
while ( fConditionFlag )
22688
/* Indicate that no mclk interrupt is needed, yet. */
22689
ulTimeDiff = cOCT6100_INVALID_VALUE;
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 )
22696
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byFatalMemoryState, pIntrptManage->ulFatalMemoryEnableMclkHigh, pIntrptManage->ulFatalMemoryEnableMclkLow, pIntrptConfig->ulFatalMemoryTimeoutMclk, ulTimeDiff )
22698
if ( pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_ACTIVE &&
22699
pIntrptManage->byErrorMemoryState != cOCT6100_INTRPT_DISABLED )
22701
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorMemoryState, pIntrptManage->ulErrorMemoryEnableMclkHigh, pIntrptManage->ulErrorMemoryEnableMclkLow, pIntrptConfig->ulErrorMemoryTimeoutMclk, ulTimeDiff )
22703
if ( pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_ACTIVE &&
22704
pIntrptManage->byErrorOverflowToneEventsState != cOCT6100_INTRPT_DISABLED )
22706
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorOverflowToneEventsState, pIntrptManage->ulErrorOverflowToneEventsEnableMclkHigh, pIntrptManage->ulErrorOverflowToneEventsEnableMclkLow, pIntrptConfig->ulErrorOverflowToneEventsTimeoutMclk, ulTimeDiff )
22708
if ( pIntrptManage->byErrorH100State != cOCT6100_INTRPT_ACTIVE &&
22709
pIntrptManage->byErrorH100State != cOCT6100_INTRPT_DISABLED )
22711
mOCT6100_GET_INTRPT_ENABLE_TIME( ulRegMclkTimeHigh, ulRegMclkTimeLow, pIntrptManage->byErrorH100State, pIntrptManage->ulErrorH100EnableMclkHigh, pIntrptManage->ulErrorH100EnableMclkLow, pIntrptConfig->ulErrorH100TimeoutMclk, ulTimeDiff )
22714
/* Set some parameters of write struct. */
22715
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
22717
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
22719
/* Schedule next mclk interrupt, if any is needed. */
22720
if ( ulTimeDiff != cOCT6100_INVALID_VALUE )
22722
UINT32 ulMclkTimeTest;
22723
UINT32 ulAlarmTimeTest;
22724
UINT32 ulTimeDiffTest;
22725
BOOL fAlarmTimePassed;
22727
/* Indicate that an mclk interrupt is scheduled.*/
22728
pIntrptManage->fMclkIntrptActive = TRUE;
22730
pIntrptManage->ulNextMclkIntrptTimeLow = ulRegMclkTimeLow + ulTimeDiff;
22731
if ( pIntrptManage->ulNextMclkIntrptTimeLow < ulRegMclkTimeLow )
22732
pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh + 1;
22733
else /* ( pIntrptManage->ulNextMclkIntrptTimeLow >= ulRegMclkTimeLow ) */
22734
pIntrptManage->ulNextMclkIntrptTimeHigh = ulRegMclkTimeHigh;
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 )
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 )
22749
WriteParams.ulWriteAddress = 0x304;
22750
WriteParams.usWriteData = 0;
22752
if ( pIntrptManage->fMclkIntrptActive == TRUE )
22753
WriteParams.usWriteData = 0x0001;
22755
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
22757
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
22758
WriteParams.usWriteData |= 0xD100;
22760
WriteParams.usWriteData |= 0x5100;
22763
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22764
if ( ulResult != cOCT6100_ERR_OK )
22767
/* Disable the ROL if previously set. */
22768
WriteParams.ulWriteAddress = 0x302;
22769
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22770
if ( ulResult != cOCT6100_ERR_OK )
22773
/* Check if already passed the next interrupt time. */
22774
ulResult = Oct6100ApiReadChipMclkTime( f_pApiInstance );
22775
if ( ulResult != cOCT6100_ERR_OK )
22778
ulMclkTimeTest = (pIntrptManage->ulRegMclkTimeLow >> 16) & 0xFFFF;
22779
ulAlarmTimeTest = (pIntrptManage->ulNextMclkIntrptTimeLow >> 16) & 0xFFFF;
22781
/* Update the local Mlck timer values.*/
22782
ulRegMclkTimeHigh = pIntrptManage->ulRegMclkTimeHigh;
22783
ulRegMclkTimeLow = pIntrptManage->ulRegMclkTimeLow;
22785
fAlarmTimePassed = FALSE;
22787
if ( ulMclkTimeTest > ulAlarmTimeTest )
22789
ulTimeDiffTest = ulMclkTimeTest - ulAlarmTimeTest;
22790
if ( ulTimeDiffTest <= 0x8000 )
22791
fAlarmTimePassed = TRUE;
22793
else /* ( ulMclkTimeTest <= ulAlarmTimeTest ) */
22795
ulTimeDiffTest = ulAlarmTimeTest - ulMclkTimeTest;
22796
if ( ulTimeDiffTest > 0x8000 )
22797
fAlarmTimePassed = TRUE;
22800
if ( fAlarmTimePassed == TRUE )
22802
/* Passed the interrupt time. Schedule next interrupt (if needed). */
22803
ulResult = Oct6100ApiUpdateIntrptTimeouts( f_pApiInstance );
22804
if ( ulResult != cOCT6100_ERR_OK )
22811
fConditionFlag = FALSE;
22816
/* Indicate that no mclk interrupt is scheduled. */
22817
pIntrptManage->fMclkIntrptActive = FALSE;
22819
/* Insure that the mclk interrupt is not enabled. */
22820
WriteParams.ulWriteAddress = 0x304;
22821
WriteParams.usWriteData = 0x0000;
22822
if ( pIntrptManage->byErrorH100State == cOCT6100_INTRPT_ACTIVE )
22824
if ( f_pApiInstance->pSharedInfo->ChipConfig.fEnableFastH100Mode == TRUE )
22825
WriteParams.usWriteData |= 0xD100;
22827
WriteParams.usWriteData |= 0x5100;
22829
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult )
22830
if ( ulResult != cOCT6100_ERR_OK )
22833
fConditionFlag = FALSE;
22837
return cOCT6100_ERR_OK;
22841
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
22843
Function: Oct6100ApiCheckProcessorState
22845
Description: This function verifies if the NLP and AF processors are operating
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.
22854
f_pIntFlags Pointer to a tOCT6100_INTERRUPT_FLAGS structure.
22856
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
22857
static UINT32 Oct6100ApiCheckProcessorState(
22858
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
22859
IN OUT tPOCT6100_INTERRUPT_FLAGS f_pIntFlags )
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;
22872
UINT16 ausReadData[ 2 ];
22874
/* Get local pointer(s). */
22875
pSharedInfo = f_pApiInstance->pSharedInfo;
22877
/* Set some parameters of write struct. */
22878
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
22880
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
22881
ReadParams.pusReadData = &usReadData;
22883
/* Set some parameters of write struct. */
22884
ReadBurstParams.pProcessContext = f_pApiInstance->pProcessContext;
22886
ReadBurstParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
22887
ReadBurstParams.pusReadData = ausReadData;
22889
/*-----------------------------------------------------------------------*/
22890
/* Check if chip is in reset. */
22892
/* Read the main control register. */
22893
ReadParams.ulReadAddress = 0x100;
22895
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22896
if ( ulResult != cOCT6100_ERR_OK )
22899
if ( usReadData == 0x0000 )
22901
/* Chip was resetted. */
22902
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_4;
22903
f_pIntFlags->fFatalGeneral = TRUE;
22904
pSharedInfo->ErrorStats.fFatalChipError = TRUE;
22907
/*-----------------------------------------------------------------------*/
22910
/*-----------------------------------------------------------------------*/
22911
/* Reading the AF timestamp.*/
22913
for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
22915
/* Read the timestamp.*/
22916
ReadBurstParams.ulReadAddress = 0x082E0008;
22917
ReadBurstParams.ulReadLength = 2;
22919
mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
22920
if ( ulResult != cOCT6100_ERR_OK )
22923
/* Read the high part again to make sure it didn't wrap. */
22924
ReadParams.ulReadAddress = 0x082E0008;
22926
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22927
if ( ulResult != cOCT6100_ERR_OK )
22930
/* Check if the low part wrapped. */
22931
if ( ausReadData[ 0 ] == usReadData )
22935
if ( i == cOCT6100_MAX_LOOP )
22936
return cOCT6100_ERR_INTRPTS_AF_TIMESTAMP_READ_TIMEOUT;
22938
/* Save the AF timestamp. */
22939
ulAfTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
22941
/*-----------------------------------------------------------------------*/
22944
/*-----------------------------------------------------------------------*/
22945
/* Reading the NLP timestamp. */
22947
for ( i = 0; i < cOCT6100_MAX_LOOP; i++ )
22949
/* Read the timestamp. */
22950
ReadBurstParams.ulReadAddress = 0x08000008;
22951
ReadBurstParams.ulReadLength = 2;
22953
mOCT6100_DRIVER_READ_BURST_API( ReadBurstParams, ulResult )
22954
if ( ulResult != cOCT6100_ERR_OK )
22957
/* Read the high part again to make sure it didn't wrap. */
22958
ReadParams.ulReadAddress = 0x08000008;
22960
mOCT6100_DRIVER_READ_API( ReadParams, ulResult )
22961
if ( ulResult != cOCT6100_ERR_OK )
22964
/* Check if the low part wrapped. */
22965
if ( ausReadData[ 0 ] == usReadData )
22969
if ( i == cOCT6100_MAX_LOOP )
22970
return cOCT6100_ERR_INTRPTS_NLP_TIMESTAMP_READ_TIMEOUT;
22972
/* Save the NLP timestamp. */
22973
ulNlpTimestamp = (ausReadData[ 0 ] << 16) | ausReadData[ 1 ];
22975
/*-----------------------------------------------------------------------*/
22978
/*-----------------------------------------------------------------------*/
22979
/* Check the validity of the timestamp. */
22981
if ( ulAfTimestamp > ulNlpTimestamp )
22983
/* The NLP timestamp wrapped. */
22984
ulTimestampDiff = 0xFFFFFFFF - ulAfTimestamp + 1;
22985
ulTimestampDiff += ulNlpTimestamp;
22988
ulTimestampDiff = ulNlpTimestamp - ulAfTimestamp;
22990
if ( ulTimestampDiff > 0x1000 )
22992
f_pIntFlags->ulFatalGeneralFlags |= cOCT6100_FATAL_GENERAL_ERROR_TYPE_5;
22993
f_pIntFlags->fFatalGeneral = TRUE;
22994
pSharedInfo->ErrorStats.fFatalChipError = TRUE;
22997
/*-----------------------------------------------------------------------*/
22999
return cOCT6100_ERR_OK;
23003
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23005
File: oct6100_memory.c
23007
Copyright (c) 2001-2005 Octasic Inc.
23011
This file contains the functions used to manage the allocation of memory
23012
blocks in external memory.
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.
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
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.
23028
$Octasic_Release: OCT612xAPI-01.00-PR38 $
23030
$Octasic_Revision: 42 $
23032
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23035
/***************************** INCLUDE FILES *******************************/
23037
#include "octdef.h"
23039
#include "oct6100api/oct6100_defines.h"
23040
#include "oct6100api/oct6100_errors.h"
23042
#include "apilib/octapi_llman.h"
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"
23054
#include "oct6100api/oct6100_interrupts_pub.h"
23055
#include "oct6100api/oct6100_channel_pub.h"
23056
#include "oct6100api/oct6100_chip_open_pub.h"
23058
#include "oct6100_chip_open_priv.h"
23059
#include "oct6100_memory_priv.h"
23062
/**************************** PRIVATE FUNCTIONS ****************************/
23065
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23067
Function: Oct6100ApiGetMemorySwSizes
23069
Description: Gets the sizes of all portions of the API instance pertinent
23070
to the management of the memories.
23072
-------------------------------------------------------------------------------
23073
| Argument | Description
23074
-------------------------------------------------------------------------------
23075
f_pOpenChip Pointer to chip configuration struct.
23076
f_pInstSizes Pointer to struct containing instance sizes.
23078
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23079
static UINT32 Oct6100ApiGetMemorySwSizes(
23080
IN tPOCT6100_CHIP_OPEN f_pOpenChip,
23081
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
23085
UINT32 ulNumTsiChariots;
23087
/*=========================================================================*/
23088
/* Internal memory */
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;
23093
if ( f_pOpenChip->fEnableExtToneDetection == TRUE )
23094
ulNumTsiChariots--;
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;
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;
23106
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsiMemoryAlloc, ulTempVar );
23107
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulConversionMemoryAlloc, ulTempVar );
23109
return cOCT6100_ERR_OK;
23113
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23115
Function: Oct6100ApiMemorySwInit
23117
Description: Initializes all elements of the instance structure associated
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.
23126
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23127
static UINT32 Oct6100ApiMemorySwInit(
23128
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
23130
tPOCT6100_SHARED_INFO pSharedInfo;
23131
PVOID pTsiMemAlloc;
23135
/* Get local pointer(s). */
23136
pSharedInfo = f_pApiInstance->pSharedInfo;
23138
/*=========================================================================*/
23139
/* Internal memory */
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;
23144
if ( pSharedInfo->ChipConfig.fEnableExtToneDetection == TRUE )
23145
pSharedInfo->MemoryMap.ulNumTsiEntries--;
23147
mOCT6100_GET_TSI_MEMORY_ALLOC_PNT( pSharedInfo, pTsiMemAlloc );
23149
ulResult = OctapiLlmAllocInit( &pTsiMemAlloc, pSharedInfo->MemoryMap.ulNumTsiEntries );
23150
if ( ulResult != cOCT6100_ERR_OK )
23151
return cOCT6100_ERR_FATAL_95;
23153
/* Initialize the conversion memory allocation structure. */
23154
mOCT6100_GET_CONVERSION_MEMORY_ALLOC_PNT( pSharedInfo, pAllocPnt );
23156
ulResult = OctapiLlmAllocInit( &pAllocPnt, cOCT6100_MAX_CONVERSION_MEMORY_BLOCKS );
23157
if ( ulResult != cOCT6100_ERR_OK )
23158
return cOCT6100_ERR_FATAL_B6;
23160
return cOCT6100_ERR_OK;
23164
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23166
Function: Oct6100ApiBufferPlayoutMemorySwInit
23168
Description: Initialize the buffer playout memory allocation working
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.
23177
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23178
static UINT32 Oct6100ApiBufferPlayoutMemorySwInit(
23179
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
23181
tPOCT6100_SHARED_INFO pSharedInfo;
23182
tPOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE pNode;
23185
/* Get local pointer to shared portion of instance. */
23186
pSharedInfo = f_pApiInstance->pSharedInfo;
23188
/* Only if buffer playout will be used. */
23189
if ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers > 0 )
23191
mOCT6100_GET_BUFFER_MEMORY_NODE_LIST_PNT( pSharedInfo, pNode );
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;
23196
pNode->ulPrevious = 0;
23197
pNode->fAllocated = FALSE;
23198
pNode->ulStartAddress = pSharedInfo->MemoryMap.ulFreeMemBaseAddress;
23202
/* Now create the first node of the free list, i.e. nodes that can be used later for modeling the memory. */
23207
pNode->ulPrevious = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1;
23208
pNode->fAllocated = FALSE;
23209
pNode->ulStartAddress = 0;
23213
/* Link all the unused nodes. */
23214
for( i = 2; i < (UINT32)( ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1 ); i ++ )
23216
pNode->ulNext = i + 1;
23217
pNode->ulPrevious = i - 1;
23218
pNode->ulStartAddress = 0;
23220
pNode->fAllocated = FALSE;
23224
/* Last node of the unused list. */
23225
pNode->fAllocated = FALSE;
23226
pNode->ulPrevious = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 2;
23227
/* Free list head. */
23230
pNode->ulStartAddress = 0;
23232
/* Set roving pointer to first node ( which can be used! ) */
23233
pSharedInfo->PlayoutInfo.ulRovingNode = 0;
23235
/* First unused node. */
23236
pSharedInfo->PlayoutInfo.ulFirstUnusedNode = 1;
23238
/* Last unused node. */
23239
pSharedInfo->PlayoutInfo.ulLastUnusedNode = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1;
23241
/* Number of unused nodes. */
23242
pSharedInfo->PlayoutInfo.ulUnusedNodeCnt = ( pSharedInfo->ChipConfig.usMaxPlayoutBuffers * 2 ) - 1;
23246
pSharedInfo->PlayoutInfo.ulUnusedNodeCnt = 0;
23249
return cOCT6100_ERR_OK;
23254
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23256
File: oct6100_phasing_tsst.c
23258
Copyright (c) 2001-2005 Octasic Inc.
23262
This file contains functions used to open and close phasing TSSTs.
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.
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
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.
23278
$Octasic_Release: OCT612xAPI-01.00-PR38 $
23280
$Octasic_Revision: 42 $
23282
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23285
/***************************** INCLUDE FILES *******************************/
23287
#include "octdef.h"
23289
#include "oct6100api/oct6100_defines.h"
23290
#include "oct6100api/oct6100_errors.h"
23291
#include "oct6100api/oct6100_apiud.h"
23293
#include "apilib/octapi_llman.h"
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"
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"
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"
23316
/**************************** PUBLIC FUNCTIONS ****************************/
23319
/**************************** PRIVATE FUNCTIONS ****************************/
23321
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23323
Function: Oct6100ApiGetPhasingTsstSwSizes
23325
Description: Gets the sizes of all portions of the API instance pertinent
23326
to the management of Phasing TSSTs.
23328
-------------------------------------------------------------------------------
23329
| Argument | Description
23330
-------------------------------------------------------------------------------
23331
f_pOpenChip Pointer to chip configuration struct.
23332
f_pInstSizes Pointer to struct containing instance sizes.
23334
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23335
static UINT32 Oct6100ApiGetPhasingTsstSwSizes(
23336
IN tPOCT6100_CHIP_OPEN f_pOpenChip,
23337
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
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 );
23345
if ( f_pOpenChip->ulMaxPhasingTssts > 0 )
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;
23354
f_pInstSizes->ulPhasingTsstAlloc = 0;
23357
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPhasingTsstList, ulTempVar )
23358
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulPhasingTsstAlloc, ulTempVar )
23360
return cOCT6100_ERR_OK;
23364
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23366
Function: Oct6100ApiPhasingTsstSwInit
23368
Description: Initializes all elements of the instance structure associated
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.
23377
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23378
static UINT32 Oct6100ApiPhasingTsstSwInit(
23379
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
23381
tPOCT6100_API_PHASING_TSST pPhasingTsstList;
23382
tPOCT6100_SHARED_INFO pSharedInfo;
23383
UINT32 ulMaxPhasingTssts;
23384
PVOID pPhasingTsstAlloc;
23387
/* Get local pointer to shared portion of instance. */
23388
pSharedInfo = f_pApiInstance->pSharedInfo;
23390
/* Initialize the phasing TSST API list. */
23391
ulMaxPhasingTssts = pSharedInfo->ChipConfig.usMaxPhasingTssts;
23393
/* Set all entries in the phasing TSST list to unused. */
23394
mOCT6100_GET_PHASING_TSST_LIST_PNT( pSharedInfo, pPhasingTsstList )
23396
/* Clear the memory */
23397
Oct6100UserMemSet( pPhasingTsstList, 0x00, sizeof(tOCT6100_API_PHASING_TSST) * ulMaxPhasingTssts );
23399
/* Initialize the phasing TSST allocation software to "all free". */
23400
if ( ulMaxPhasingTssts > 0 )
23402
mOCT6100_GET_PHASING_TSST_ALLOC_PNT( pSharedInfo, pPhasingTsstAlloc )
23404
ulResult = OctapiLlmAllocInit( &pPhasingTsstAlloc, ulMaxPhasingTssts );
23405
if ( ulResult != cOCT6100_ERR_OK )
23406
return cOCT6100_ERR_FATAL_39;
23409
return cOCT6100_ERR_OK;
23413
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23415
File: oct6100_playout_buf.c
23417
Copyright (c) 2001-2005 Octasic Inc.
23421
This file contains functions used to manage buffer playout.
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.
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
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.
23437
$Octasic_Release: OCT612xAPI-01.00-PR38 $
23439
$Octasic_Revision: 109 $
23441
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23444
/***************************** INCLUDE FILES *******************************/
23446
#include "octdef.h"
23448
#include "oct6100api/oct6100_defines.h"
23449
#include "oct6100api/oct6100_errors.h"
23450
#include "oct6100api/oct6100_apiud.h"
23452
#include "apilib/octapi_llman.h"
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"
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"
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"
23477
/**************************** PUBLIC FUNCTIONS *****************************/
23479
/**************************** PRIVATE FUNCTIONS ****************************/
23481
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23483
Function: Oct6100ApiGetPlayoutBufferSwSizes
23485
Description: Gets the sizes of all portions of the API instance pertinent
23486
to the management of playout buffers.
23488
-------------------------------------------------------------------------------
23489
| Argument | Description
23490
-------------------------------------------------------------------------------
23491
f_pOpenChip Pointer to chip configuration struct.
23492
f_pInstSizes Pointer to struct containing instance sizes.
23494
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23495
static UINT32 Oct6100ApiGetPlayoutBufferSwSizes(
23496
IN tPOCT6100_CHIP_OPEN f_pOpenChip,
23497
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
23502
/* Calculate memory needed for playout buffer list. */
23503
f_pInstSizes->ulPlayoutBufList = f_pOpenChip->ulMaxPlayoutBuffers * sizeof( tOCT6100_API_BUFFER );
23505
f_pInstSizes->ulPlayoutBufMemoryNodeList = 0;
23507
/* Calculate memory needed for playout buffer allocation software. */
23508
if ( f_pOpenChip->ulMaxPlayoutBuffers > 0 )
23510
ulResult = OctapiLlmAllocGetSize( f_pOpenChip->ulMaxPlayoutBuffers, &f_pInstSizes->ulPlayoutBufAlloc );
23511
if ( ulResult != cOCT6100_ERR_OK )
23512
return cOCT6100_ERR_FATAL_3C;
23514
f_pInstSizes->ulPlayoutBufMemoryNodeList = 2 * f_pOpenChip->ulMaxPlayoutBuffers * sizeof( tOCT6100_API_BUFFER_PLAYOUT_MALLOC_NODE );
23518
f_pInstSizes->ulPlayoutBufAlloc = 0;
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 )
23526
return cOCT6100_ERR_OK;
23530
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23532
Function: Oct6100ApiPlayoutBufferSwInit
23534
Description: Initializes all elements of the instance structure associated
23535
to playout buffers.
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.
23543
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23544
static UINT32 Oct6100ApiPlayoutBufferSwInit(
23545
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
23547
tPOCT6100_SHARED_INFO pSharedInfo;
23548
tPOCT6100_API_BUFFER pBufferList;
23549
PVOID pBufferPlayoutAlloc;
23550
UINT32 ulMaxBufferPlayout;
23551
UINT32 ulResult, i;
23553
/* Get local pointer to shared portion of instance. */
23554
pSharedInfo = f_pApiInstance->pSharedInfo;
23556
/* Get the maximum number of buffer playout. */
23557
ulMaxBufferPlayout = pSharedInfo->ChipConfig.usMaxPlayoutBuffers;
23559
/* Set all entries in the buffer playout list to unused. */
23560
mOCT6100_GET_BUFFER_LIST_PNT( pSharedInfo, pBufferList )
23562
for ( i = 0; i < ulMaxBufferPlayout; i++ )
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;
23572
/* Initialize the buffer playout allocation software to "all free". */
23573
if ( ulMaxBufferPlayout > 0 )
23575
mOCT6100_GET_BUFFER_ALLOC_PNT( pSharedInfo, pBufferPlayoutAlloc )
23577
ulResult = OctapiLlmAllocInit( &pBufferPlayoutAlloc, ulMaxBufferPlayout );
23578
if ( ulResult != cOCT6100_ERR_OK )
23579
return cOCT6100_ERR_FATAL_3D;
23582
/* Initialize the amount of free memory used by playout. */
23583
f_pApiInstance->pSharedInfo->ChipStats.ulPlayoutMemUsed = 0;
23585
return cOCT6100_ERR_OK;
23590
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23592
Function: Oct6100BufferPlayoutStopSer
23594
Description: Stops buffer playout on a channel.
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.
23602
f_pBufferPlayoutStop Pointer to buffer playout stop structure.
23604
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
23605
static UINT32 Oct6100BufferPlayoutStopSer(
23606
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
23607
IN OUT tPOCT6100_BUFFER_PLAYOUT_STOP f_pBufferPlayoutStop )
23609
UINT32 ulChannelIndex;
23610
UINT16 usEchoMemIndex;
23613
/* Check the user's configuration of the buffer for errors. */
23614
ulResult = Oct6100ApiAssertPlayoutStopParams(
23616
f_pBufferPlayoutStop,
23619
if ( ulResult != cOCT6100_ERR_OK )
23622
/* Write to all resources needed to deactivate buffer playout. */
23623
ulResult = Oct6100ApiInvalidateChanPlayoutStructs(
23625
f_pBufferPlayoutStop,
23630
if ( ulResult != cOCT6100_ERR_OK )
23633
return cOCT6100_ERR_OK;
23637
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23639
Function: Oct6100ApiAssertPlayoutStopParams
23641
Description: Check the validity of the channel and buffer requested.
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.
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.
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 )
23660
tPOCT6100_API_CHANNEL pEchoChannel;
23661
UINT32 ulEntryOpenCnt;
23663
/* Check for errors. */
23664
if ( f_pApiInstance->pSharedInfo->ChipConfig.usMaxPlayoutBuffers == 0 )
23665
return cOCT6100_ERR_BUFFER_PLAYOUT_DISABLED;
23667
if ( f_pBufferPlayoutStop->ulChannelHndl == cOCT6100_INVALID_HANDLE )
23668
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
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;
23674
if ( f_pBufferPlayoutStop->fStopCleanly != TRUE && f_pBufferPlayoutStop->fStopCleanly != FALSE )
23675
return cOCT6100_ERR_BUFFER_PLAYOUT_STOP_CLEANLY;
23677
/*=====================================================================*/
23678
/* Check the channel handle. */
23680
if ( (f_pBufferPlayoutStop->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
23681
return cOCT6100_ERR_BUFFER_PLAYOUT_CHANNEL_HANDLE_INVALID;
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;
23687
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex )
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;
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;
23698
/* Return echo memory index. */
23699
*f_pusEchoMemIndex = pEchoChannel->usEchoMemIndex;
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;
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;
23712
/*=====================================================================*/
23714
return cOCT6100_ERR_OK;
23718
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
23720
Function: Oct6100ApiInvalidateChanPlayoutStructs
23722
Description: Write the buffer playout event in the channel main structure.
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.
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.
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
23743
tPOCT6100_API_CHANNEL pEchoChannel;
23744
tPOCT6100_SHARED_INFO pSharedInfo;
23745
tOCT6100_READ_PARAMS ReadParams;
23746
tOCT6100_WRITE_PARAMS WriteParams;
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;
23768
UINT32 ulReadPtr = 0;
23769
UINT32 ulCurrentPtr;
23771
UINT32 ulPlayoutBaseAddress;
23778
BOOL fCheckStop = FALSE;
23780
UINT32 ulEventBuffer;
23782
/* Obtain local pointer to shared portion of instance. */
23783
pSharedInfo = f_pApiInstance->pSharedInfo;
23785
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
23787
WriteParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
23789
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
23791
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
23792
ReadParams.pusReadData = &usReadData;
23794
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChannel, f_ulChannelIndex );
23796
/* Select the port of interest. */
23797
if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
23799
ulWritePtr = pEchoChannel->ulRinBufWritePtr;
23800
ulSkipPtr = ulWritePtr;
23802
ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.usDwordOffset * 4;
23803
ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byBitOffset;
23804
ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst.byFieldSize;
23806
ulSkipPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.usDwordOffset * 4;
23807
ulSkipPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byBitOffset;
23808
ulSkipPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst.byFieldSize;
23810
ulIgnoreBytesOfst = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.usDwordOffset * 4;
23811
ulIgnoreBitOfst = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byBitOffset;
23812
ulIgnoreFieldSize = pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst.byFieldSize;
23814
ulHardSkipBytesOfst = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.usDwordOffset * 4;
23815
ulHardSkipBitOfst = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byBitOffset;
23816
ulHardSkipFieldSize = pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst.byFieldSize;
23818
ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.usDwordOffset * 4;
23819
ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byBitOffset;
23820
ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst.byFieldSize;
23822
else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
23824
ulWritePtr = pEchoChannel->ulSoutBufWritePtr;
23825
ulSkipPtr = ulWritePtr;
23827
ulWritePtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.usDwordOffset * 4;
23828
ulWritePtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byBitOffset;
23829
ulWritePtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst.byFieldSize;
23831
ulSkipPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.usDwordOffset * 4;
23832
ulSkipPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byBitOffset;
23833
ulSkipPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst.byFieldSize;
23835
ulIgnoreBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.usDwordOffset * 4;
23836
ulIgnoreBitOfst = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byBitOffset;
23837
ulIgnoreFieldSize = pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst.byFieldSize;
23839
ulHardSkipBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.usDwordOffset * 4;
23840
ulHardSkipBitOfst = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byBitOffset;
23841
ulHardSkipFieldSize = pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst.byFieldSize;
23843
ulReadPtrBytesOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.usDwordOffset * 4;
23844
ulReadPtrBitOfst = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byBitOffset;
23845
ulReadPtrFieldSize = pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst.byFieldSize;
23848
/* Set the playout feature base address. */
23849
ulPlayoutBaseAddress = cOCT6100_CHANNEL_ROOT_BASE + ( f_usEchoMemIndex * cOCT6100_CHANNEL_ROOT_SIZE ) + pSharedInfo->MemoryMap.ulChanRootConfOfst;
23851
/* Check if something is currently playing. */
23852
if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
23854
if ( pEchoChannel->fRinBufPlaying == TRUE )
23856
/* Check if we are stopping it or if it stopped by itself. */
23862
if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL )
23863
*f_pBufferPlayoutStop->pfAlreadyStopped = TRUE;
23866
else /* if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT ) */
23868
if ( pEchoChannel->fSoutBufPlaying == TRUE )
23870
/* Check if we are stopping it or if it stopped by itself. */
23876
if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL )
23877
*f_pBufferPlayoutStop->pfAlreadyStopped = TRUE;
23881
if ( ( fCheckStop == TRUE ) || ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE ) )
23883
/* Read the read pointer. */
23884
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
23886
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
23887
ReadParams.pusReadData = &usReadData;
23888
ReadParams.ulReadAddress = ulPlayoutBaseAddress + ulReadPtrBytesOfst;
23890
/* Optimize this access by only reading the word we are interested in. */
23891
if ( ulReadPtrBitOfst < 16 )
23892
ReadParams.ulReadAddress += 2;
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 )
23899
/* Move data at correct position according to what was read. */
23900
if ( ulReadPtrBitOfst < 16 )
23901
ulTempData = usReadData;
23903
ulTempData = usReadData << 16;
23905
mOCT6100_CREATE_FEATURE_MASK( ulReadPtrFieldSize, ulReadPtrBitOfst, &ulMask );
23907
/* Store the read pointer. */
23908
ulReadPtr = ( ulTempData & ulMask ) >> ulReadPtrBitOfst;
23910
/* Playout has finished when the read pointer reaches the write pointer. */
23911
if ( f_pBufferPlayoutStop->pfAlreadyStopped != NULL )
23913
if ( ulReadPtr != ulWritePtr )
23914
*f_pBufferPlayoutStop->pfAlreadyStopped = FALSE;
23915
else /* if ( ulReadPtr == ulWritePtr ) */
23916
*f_pBufferPlayoutStop->pfAlreadyStopped = TRUE;
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 )
23924
if ( ulReadPtr != ulWritePtr )
23926
/* Get the write pointer in the chip. */
23927
ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst;
23929
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, pEchoChannel, ulAddress, &ulReadData, ulResult );
23930
if ( ulResult != cOCT6100_ERR_OK )
23933
mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask );
23935
/* Store the write pointer. */
23936
ulWritePtr = ( ulReadData & ulMask ) >> ulWritePtrBitOfst;
23937
ulSkipPtr = ulWritePtr;
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 ) ) )
23945
if ( ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE )
23946
|| ( ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
23947
&& ( ulWritePtr != ulReadPtr ) ) )
23949
if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
23951
ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst;
23953
else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
23955
ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst;
23958
/* Set the playout event base address. */
23959
if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE )
23960
&& ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) )
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 )));
23967
/* Old 31 events image. */
23968
ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + (cOCT6100_PLAYOUT_EVENT_MEM_SIZE * ( ( ulWritePtr - 1 ) & 0x1F));
23971
/* EVENT BASE + 4 */
23972
/* Playout configuration. */
23975
ReadParams.ulReadAddress = ulAddress;
23976
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
23977
if ( ulResult != cOCT6100_ERR_OK )
23980
/* Read-clear-write the new repeat bit. */
23981
usReadData &= 0x7FFF;
23983
WriteParams.ulWriteAddress = ulAddress;
23984
WriteParams.usWriteData = usReadData;
23985
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
23986
if ( ulResult != cOCT6100_ERR_OK )
23991
/* Write the skip to the value of the write pointer to stop buffer playout. */
23993
/*=======================================================================*/
23994
/* First set the ignore skip clean bit if required. */
23996
if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == FALSE )
23997
|| ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == FALSE ) )
23999
ulAddress = ulPlayoutBaseAddress + ulIgnoreBytesOfst;
24001
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
24006
if ( ulResult != cOCT6100_ERR_OK )
24009
mOCT6100_CREATE_FEATURE_MASK( ulIgnoreFieldSize, ulIgnoreBitOfst, &ulMask );
24011
ulTempData &= ( ~ulMask );
24013
/* Check if the skip need to be clean or not. */
24014
if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
24015
ulTempData |= 0x1 << ulIgnoreBitOfst;
24017
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
24022
if ( ulResult != cOCT6100_ERR_OK )
24026
/*=======================================================================*/
24029
/*=======================================================================*/
24030
/* Fetch and modify the write pointer. */
24032
ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst;
24034
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, pEchoChannel, ulAddress, &ulTempData, ulResult );
24035
if ( ulResult != cOCT6100_ERR_OK )
24038
mOCT6100_CREATE_FEATURE_MASK( ulWritePtrFieldSize, ulWritePtrBitOfst, &ulMask );
24040
ulTempData &= ( ~ulMask );
24041
ulTempData |= ulWritePtr << ulWritePtrBitOfst;
24043
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
24048
if ( ulResult != cOCT6100_ERR_OK )
24051
/*=======================================================================*/
24054
/*=======================================================================*/
24055
/* Fetch and modify the skip pointer. */
24057
ulAddress = ulPlayoutBaseAddress + ulSkipPtrBytesOfst;
24059
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
24064
if ( ulResult != cOCT6100_ERR_OK )
24067
mOCT6100_CREATE_FEATURE_MASK( ulSkipPtrFieldSize, ulSkipPtrBitOfst, &ulMask );
24069
ulTempData &= ( ~ulMask );
24070
ulTempData |= ulSkipPtr << ulSkipPtrBitOfst;
24072
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
24077
if ( ulResult != cOCT6100_ERR_OK )
24080
/*=======================================================================*/
24083
/*=======================================================================*/
24084
/* If in the new buffer playout case, things are in a different order. */
24086
if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE )
24088
if ( ( pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip == TRUE )
24089
&& ( pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip == TRUE ) )
24091
ulAddress = ulPlayoutBaseAddress + ulHardSkipBytesOfst;
24093
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
24098
if ( ulResult != cOCT6100_ERR_OK )
24101
mOCT6100_CREATE_FEATURE_MASK( ulHardSkipFieldSize, ulHardSkipBitOfst, &ulMask );
24103
ulTempData &= ( ~ulMask );
24105
/* Check if the skip need to be clean or not. */
24106
if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
24107
ulTempData |= 0x1 << ulHardSkipBitOfst;
24109
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
24114
if ( ulResult != cOCT6100_ERR_OK )
24117
/* Now is the appropriate time to skip! */
24118
ulAddress = ulPlayoutBaseAddress + ulIgnoreBytesOfst;
24120
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
24125
if ( ulResult != cOCT6100_ERR_OK )
24128
mOCT6100_CREATE_FEATURE_MASK( ulIgnoreFieldSize, ulIgnoreBitOfst, &ulMask );
24130
ulTempData &= ( ~ulMask );
24132
/* Set the skip bit. */
24133
ulTempData |= 0x1 << ulIgnoreBitOfst;
24135
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
24140
if ( ulResult != cOCT6100_ERR_OK )
24145
/*=======================================================================*/
24148
/*=======================================================================*/
24149
/* The API must set the skip bit in all the events that are queued. */
24151
if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
24153
if ( fCheckStop == TRUE )
24155
if ( ulReadPtr != ulWritePtr )
24157
if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
24159
ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst;
24161
else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
24163
ulEventBuffer = pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst;
24166
for ( ulCurrentPtr = ulReadPtr; ulCurrentPtr != ulWritePtr; )
24168
/* Set the playout event base address. */
24170
/* 127 or 31 events image. */
24171
ulAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_usEchoMemIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ) + ulEventBuffer + ( cOCT6100_PLAYOUT_EVENT_MEM_SIZE * ulCurrentPtr );
24173
ulCurrentPtr &= ( pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents - 1 );
24175
/* EVENT BASE + 0 playout configuration. */
24176
WriteParams.ulWriteAddress = ulAddress;
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 )
24190
/*=======================================================================*/
24191
/* If stop immediatly, wait the stop before leaving the function. */
24193
if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
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;
24202
/*=======================================================================*/
24203
/* Update the channel entry to set the playing flag to FALSE. */
24205
/* Select the port of interest. */
24206
if ( f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_ROUT )
24208
/* Check if the global ports active stat must be decremented. */
24209
if ( pEchoChannel->fRinBufPlaying == TRUE )
24211
/* Decrement the number of active buffer playout ports. */
24212
pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--;
24215
pEchoChannel->fRinBufPlaying = FALSE;
24217
/* Return user information. */
24218
if ( f_pBufferPlayoutStop->pfNotifyOnPlayoutStop != NULL )
24219
*f_pBufferPlayoutStop->pfNotifyOnPlayoutStop = pEchoChannel->fRinBufPlayoutNotifyOnStop;
24221
/* Make sure no new event is recorded for this channel/port. */
24222
pEchoChannel->fRinBufPlayoutNotifyOnStop = FALSE;
24223
if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
24225
pEchoChannel->ulRinBufSkipPtr = ulSkipPtr;
24226
pEchoChannel->ulRinBufWritePtr = ulWritePtr;
24228
else /* if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE ) */
24229
pEchoChannel->ulRinBufSkipPtr = pEchoChannel->ulRinBufWritePtr;
24231
/* The repeat flag can now be used. */
24232
pEchoChannel->fRinBufPlayoutRepeatUsed = FALSE;
24234
/* For sure, all buffers have now been cleared on the Rin port. */
24235
pEchoChannel->fRinBufAdded = FALSE;
24237
/* Clear optimization flag if possible. */
24238
if ( ( pEchoChannel->fSoutBufPlaying == FALSE )
24239
&& ( pEchoChannel->fSoutBufPlayoutNotifyOnStop == FALSE ) )
24241
/* Buffer playout is no more active on this channel. */
24242
pEchoChannel->fBufPlayoutActive = FALSE;
24245
else /* f_pBufferPlayoutStop->ulPlayoutPort == cOCT6100_CHANNEL_PORT_SOUT */
24247
/* Check if the global ports active stat must be decremented. */
24248
if ( pEchoChannel->fSoutBufPlaying == TRUE )
24250
/* Decrement the number of active buffer playout ports. */
24251
pSharedInfo->ChipStats.usNumberActiveBufPlayoutPorts--;
24254
pEchoChannel->fSoutBufPlaying = FALSE;
24256
/* Return user information. */
24257
if ( f_pBufferPlayoutStop->pfNotifyOnPlayoutStop != NULL )
24258
*f_pBufferPlayoutStop->pfNotifyOnPlayoutStop = pEchoChannel->fSoutBufPlayoutNotifyOnStop;
24260
/* Make sure no new event is recorded for this channel/port. */
24261
pEchoChannel->fSoutBufPlayoutNotifyOnStop = FALSE;
24262
if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == TRUE )
24264
pEchoChannel->ulSoutBufSkipPtr = ulSkipPtr;
24265
pEchoChannel->ulSoutBufWritePtr = ulWritePtr;
24267
else /* if ( pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents == FALSE ) */
24268
pEchoChannel->ulSoutBufSkipPtr = pEchoChannel->ulSoutBufWritePtr;
24270
/* The repeat flag can now be used. */
24271
pEchoChannel->fSoutBufPlayoutRepeatUsed = FALSE;
24273
/* For sure, all buffers have now been cleared on the Sout port. */
24274
pEchoChannel->fSoutBufAdded = FALSE;
24276
/* Clear optimization flag if possible. */
24277
if ( ( pEchoChannel->fRinBufPlaying == FALSE )
24278
&& ( pEchoChannel->fRinBufPlayoutNotifyOnStop == FALSE ) )
24280
/* Buffer playout is no more active on this channel. */
24281
pEchoChannel->fBufPlayoutActive = FALSE;
24285
/*=======================================================================*/
24289
return cOCT6100_ERR_OK;
24293
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24295
File: oct6100_remote_debug.c
24297
Copyright (c) 2001-2005 Octasic Inc.
24301
This file contains the routines used for remote debugging.
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.
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
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.
24317
$Octasic_Release: OCT612xAPI-01.00-PR38 $
24319
$Octasic_Revision: 35 $
24321
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
24324
/***************************** INCLUDE FILES *******************************/
24326
#include "octdef.h"
24328
#include "oct6100api/oct6100_defines.h"
24329
#include "oct6100api/oct6100_errors.h"
24331
#include "apilib/octapi_bt0.h"
24332
#include "apilib/octapi_largmath.h"
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"
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"
24350
#include "octrpc/rpc_protocol.h"
24351
#include "octrpc/oct6100_rpc_protocol.h"
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"
24360
/**************************** PRIVATE FUNCTIONS ****************************/
24363
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24365
Function: Oct6100ApiGetRemoteDebugSwSizes
24367
Description: Gets the sizes of all portions of the API instance pertinent
24368
to the management of remote debugging.
24370
-------------------------------------------------------------------------------
24371
| Argument | Description
24372
-------------------------------------------------------------------------------
24373
f_pChipOpen Pointer to chip configuration struct.
24374
f_pInstSizes Pointer to struct containing instance sizes.
24376
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
24377
static UINT32 Oct6100ApiGetRemoteDebugSwSizes(
24378
IN tPOCT6100_CHIP_OPEN f_pChipOpen,
24379
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
24384
/* Memory needed for remote debugging sessions. */
24385
if ( f_pChipOpen->ulMaxRemoteDebugSessions > 0 )
24387
f_pInstSizes->ulRemoteDebugList = f_pChipOpen->ulMaxRemoteDebugSessions * sizeof( tOCT6100_API_REMOTE_DEBUG_SESSION );
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;
24393
f_pInstSizes->ulRemoteDebugPktCache = cOCTRPC_MAX_PACKET_BYTE_LENGTH * f_pChipOpen->ulMaxRemoteDebugSessions;
24394
f_pInstSizes->ulRemoteDebugDataBuf = cOCTRPC_MAX_PACKET_BYTE_LENGTH * 4;
24398
f_pInstSizes->ulRemoteDebugList = 0;
24399
f_pInstSizes->ulRemoteDebugTree = 0;
24400
f_pInstSizes->ulRemoteDebugPktCache = 0;
24401
f_pInstSizes->ulRemoteDebugDataBuf = 0;
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 )
24410
return cOCT6100_ERR_OK;
24414
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24416
Function: Oct6100ApiRemoteDebuggingSwInit
24418
Description: Initializes all portions of the API instance associated to
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.
24427
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
24428
static UINT32 Oct6100ApiRemoteDebuggingSwInit(
24429
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
24431
tPOCT6100_SHARED_INFO pSharedInfo;
24432
PVOID pSessionTree;
24435
/* Get local pointer(s). */
24436
pSharedInfo = f_pApiInstance->pSharedInfo;
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;
24443
if ( pSharedInfo->ChipConfig.usMaxRemoteDebugSessions > 0 )
24445
mOCT6100_GET_REMOTE_DEBUG_TREE_PNT( pSharedInfo, pSessionTree )
24447
ulResult = octapi_bt0_init( ( ( PVOID* )&pSessionTree ), pSharedInfo->ChipConfig.usMaxRemoteDebugSessions, 4, 4 );
24448
if ( ulResult != cOCT6100_ERR_OK )
24449
return cOCT6100_ERR_FATAL_42;
24452
return cOCT6100_ERR_OK;
24455
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24457
File: oct6100_tlv.c
24459
Copyright (c) 2001-2005 Octasic Inc.
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.
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.
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
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.
24481
$Octasic_Release: OCT612xAPI-01.00-PR38 $
24483
$Octasic_Revision: 109 $
24485
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
24488
/***************************** INCLUDE FILES *******************************/
24490
#include "octdef.h"
24492
#include "oct6100api/oct6100_defines.h"
24493
#include "oct6100api/oct6100_errors.h"
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"
24504
#include "oct6100api/oct6100_interrupts_pub.h"
24506
#include "oct6100api/oct6100_channel_pub.h"
24507
#include "oct6100api/oct6100_chip_open_pub.h"
24509
#include "oct6100_chip_open_priv.h"
24510
#include "oct6100_miscellaneous_priv.h"
24511
#include "oct6100_tlv_priv.h"
24513
/**************************** PRIVATE FUNCTIONS ****************************/
24516
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24518
Function: Oct6100ApiProcessTlvRegion
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.
24524
The API will read this region until it finds a TLV type of 0 with
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.
24533
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
24534
static UINT32 Oct6100ApiProcessTlvRegion(
24535
tPOCT6100_INSTANCE_API f_pApiInstance )
24537
tOCT6100_READ_PARAMS ReadParams;
24541
UINT32 ulTlvTypeField;
24542
UINT32 ulTlvLengthField;
24543
UINT32 ulTlvWritingTimeoutCount = 0;
24544
UINT32 ulConditionFlag = TRUE;
24546
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
24548
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
24549
ReadParams.pusReadData = &usReadData;
24551
/* Set the address of the first TLV type. */
24552
ReadParams.ulReadAddress = cOCT6100_TLV_BASE;
24553
ReadParams.ulReadAddress += 2;
24555
/* Wait for the TLV configuration to be configured in memory. */
24556
while ( ulConditionFlag )
24558
/* Read the TLV write done flag. */
24559
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24560
if ( ulResult != cOCT6100_ERR_OK )
24563
if ( usReadData & 0x1 )
24566
ulTlvWritingTimeoutCount++;
24567
if ( ulTlvWritingTimeoutCount == 0x100000 )
24568
return cOCT6100_ERR_TLV_TIMEOUT;
24571
/*======================================================================*/
24572
/* Read the first 16 bits of the TLV type. */
24574
ReadParams.ulReadAddress += 2;
24575
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24576
if ( ulResult != cOCT6100_ERR_OK )
24580
ulTlvTypeField = usReadData << 16;
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 )
24589
ulTlvTypeField |= usReadData;
24591
/*======================================================================*/
24594
/*======================================================================*/
24595
/* Now, read the TLV field length. */
24597
ReadParams.ulReadAddress += 2;
24598
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24599
if ( ulResult != cOCT6100_ERR_OK )
24603
ulTlvLengthField = usReadData << 16;
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 )
24612
ulTlvLengthField |= usReadData;
24614
/* Modify the address to point at the TLV value field. */
24615
ReadParams.ulReadAddress += 2;
24617
/*======================================================================*/
24619
/* Read the TLV value until the end of TLV region is reached. */
24620
while( !((ulTlvTypeField == 0) && (ulTlvLengthField == 0)) )
24622
ulResult = Oct6100ApiInterpretTlvEntry( f_pApiInstance,
24625
ReadParams.ulReadAddress );
24626
if ( ulResult != cOCT6100_ERR_OK )
24629
/* Set the address to after the TLV value. */
24630
ReadParams.ulReadAddress += ulTlvLengthField;
24632
/*======================================================================*/
24633
/* Read the first 16 bits of the TLV type. */
24635
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24636
if ( ulResult != cOCT6100_ERR_OK )
24640
ulTlvTypeField = usReadData << 16;
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 )
24649
ulTlvTypeField |= usReadData;
24651
/*======================================================================*/
24654
/*======================================================================*/
24655
/* Now, read the TLV field length. */
24657
ReadParams.ulReadAddress += 2;
24658
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24659
if ( ulResult != cOCT6100_ERR_OK )
24663
ulTlvLengthField = usReadData << 16;
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 )
24672
ulTlvLengthField |= usReadData;
24674
ReadParams.ulReadAddress += 2;
24676
/*======================================================================*/
24679
return cOCT6100_ERR_OK;
24683
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
24685
Function: Oct6100ApiInterpretTlvEntry
24687
Description: This function will interpret a TLV entry from the chip. All
24688
known TLV types by the API are exhaustively listed here.
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.
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.
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 )
24707
tOCT6100_READ_PARAMS ReadParams;
24708
UINT32 ulResult = cOCT6100_ERR_OK;
24711
UINT32 ulTempValue = 0;
24713
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
24715
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
24716
ReadParams.pusReadData = &usReadData;
24718
/* Find out how to interpret the TLV value according to the TLV type. */
24719
switch( f_ulTlvFieldType )
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 )
24727
ReadParams.ulReadAddress = f_ulTlvValueAddress;
24729
for( i = 0; i < (f_ulTlvFieldLength/2); i++ )
24731
/* Perform the actual read. */
24732
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
24733
if ( ulResult != cOCT6100_ERR_OK )
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);
24739
/* Modify the address. */
24740
ReadParams.ulReadAddress += 2;
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 )
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 )
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 )
24766
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24767
f_ulTlvValueAddress,
24768
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase );
24769
if ( ulResult != cOCT6100_ERR_OK )
24772
f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase &= 0x0FFFFFFF;
24774
/* Modify the base address to incorporate the external memory offset. */
24775
f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemBase += cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
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 )
24785
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24786
f_ulTlvValueAddress,
24787
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainMemSize );
24788
if ( ulResult != cOCT6100_ERR_OK )
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 )
24799
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24800
f_ulTlvValueAddress,
24801
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoMemOfst );
24802
if ( ulResult != cOCT6100_ERR_OK )
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 )
24813
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24814
f_ulTlvValueAddress,
24815
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinCBMemOfst );
24816
if ( ulResult != cOCT6100_ERR_OK )
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 )
24827
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24828
f_ulTlvValueAddress,
24829
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinCBMemSize );
24830
if ( ulResult != cOCT6100_ERR_OK )
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 )
24841
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24842
f_ulTlvValueAddress,
24843
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSinCBMemOfst );
24844
if ( ulResult != cOCT6100_ERR_OK )
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 )
24855
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24856
f_ulTlvValueAddress,
24857
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSinCBMemSize );
24858
if ( ulResult != cOCT6100_ERR_OK )
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 )
24869
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24870
f_ulTlvValueAddress,
24871
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutCBMemOfst );
24872
if ( ulResult != cOCT6100_ERR_OK )
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 )
24883
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24884
f_ulTlvValueAddress,
24885
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutCBMemSize );
24886
if ( ulResult != cOCT6100_ERR_OK )
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 )
24897
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24898
f_ulTlvValueAddress,
24899
&f_pApiInstance->pSharedInfo->MemoryMap.ulFreeMemBaseAddress );
24900
if ( ulResult != cOCT6100_ERR_OK )
24903
f_pApiInstance->pSharedInfo->MemoryMap.ulFreeMemBaseAddress &= 0x0FFFFFFF;
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 )
24914
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24915
f_ulTlvValueAddress,
24916
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsOfst );
24917
if ( ulResult != cOCT6100_ERR_OK )
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 )
24928
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24929
f_ulTlvValueAddress,
24930
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainIoStatsSize );
24931
if ( ulResult != cOCT6100_ERR_OK )
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 )
24942
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24943
f_ulTlvValueAddress,
24944
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanRootConfOfst );
24945
if ( ulResult != cOCT6100_ERR_OK )
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 )
24957
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24958
f_ulTlvValueAddress,
24959
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemOfst );
24960
if ( ulResult != cOCT6100_ERR_OK )
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 )
24971
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24972
f_ulTlvValueAddress,
24973
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainRinPlayoutMemSize );
24974
if ( ulResult != cOCT6100_ERR_OK )
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 )
24985
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24986
f_ulTlvValueAddress,
24987
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemOfst );
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 )
24997
ulResult = Oct6100ApiReadDword( f_pApiInstance,
24998
f_ulTlvValueAddress,
24999
&f_pApiInstance->pSharedInfo->MemoryMap.ulChanMainSoutPlayoutMemSize );
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 )
25009
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25010
f_ulTlvValueAddress,
25011
&f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinWritePtrOfst );
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 )
25021
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25022
f_ulTlvValueAddress,
25023
&f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinIgnoreSkipCleanOfst );
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 )
25033
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25034
f_ulTlvValueAddress,
25035
&f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinSkipPtrOfst );
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 )
25045
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25046
f_ulTlvValueAddress,
25047
&f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutWritePtrOfst );
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 )
25057
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25058
f_ulTlvValueAddress,
25059
&f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutIgnoreSkipCleanOfst );
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 )
25069
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25070
f_ulTlvValueAddress,
25071
&f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutSkipPtrOfst );
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 )
25081
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25082
f_ulTlvValueAddress,
25083
&f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinReadPtrOfst );
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 )
25093
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25094
f_ulTlvValueAddress,
25095
&f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutReadPtrOfst );
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 )
25105
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25106
f_ulTlvValueAddress,
25107
&f_pApiInstance->pSharedInfo->MemoryMap.ConferencingNoiseReductionOfst );
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 )
25117
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25118
f_ulTlvValueAddress,
25119
&f_pApiInstance->pSharedInfo->MemoryMap.AdaptiveNoiseReductionOfst );
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 )
25129
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25130
f_ulTlvValueAddress,
25131
&f_pApiInstance->pSharedInfo->MemoryMap.RinDcOffsetRemovalOfst );
25133
/* Set flag indicating that the feature is present.*/
25134
f_pApiInstance->pSharedInfo->ImageInfo.fRinDcOffsetRemoval = TRUE;
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 )
25143
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25144
f_ulTlvValueAddress,
25145
&f_pApiInstance->pSharedInfo->MemoryMap.SinDcOffsetRemovalOfst );
25147
/* Set flag indicating that the feature is present.*/
25148
f_pApiInstance->pSharedInfo->ImageInfo.fSinDcOffsetRemoval = TRUE;
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 )
25157
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25158
f_ulTlvValueAddress,
25159
&f_pApiInstance->pSharedInfo->MemoryMap.RinLevelControlOfst );
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 )
25169
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25170
f_ulTlvValueAddress,
25171
&f_pApiInstance->pSharedInfo->MemoryMap.SoutLevelControlOfst );
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 )
25181
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25182
f_ulTlvValueAddress,
25183
&f_pApiInstance->pSharedInfo->MemoryMap.ComfortNoiseModeOfst );
25185
/* Set flag indicating that the feature is present.*/
25186
f_pApiInstance->pSharedInfo->ImageInfo.fComfortNoise = TRUE;
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 )
25195
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25196
f_ulTlvValueAddress,
25197
&f_pApiInstance->pSharedInfo->MemoryMap.NlpControlFieldOfst );
25199
/* Set flag indicating that the feature is present.*/
25200
f_pApiInstance->pSharedInfo->ImageInfo.fNlpControl = TRUE;
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 )
25209
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25210
f_ulTlvValueAddress,
25211
&f_pApiInstance->pSharedInfo->MemoryMap.VadControlFieldOfst );
25213
/* Set flag indicating that the feature is present.*/
25214
f_pApiInstance->pSharedInfo->ImageInfo.fSilenceSuppression = TRUE;
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 )
25223
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25224
f_ulTlvValueAddress,
25225
&f_pApiInstance->pSharedInfo->MemoryMap.PouchTailDisplOfst );
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 )
25235
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25236
f_ulTlvValueAddress,
25237
&f_pApiInstance->pSharedInfo->MemoryMap.PouchBootInstructionOfst );
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 )
25247
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25248
f_ulTlvValueAddress,
25249
&f_pApiInstance->pSharedInfo->MemoryMap.PouchBootResultOfst );
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 )
25259
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25260
f_ulTlvValueAddress,
25261
&f_pApiInstance->pSharedInfo->MemoryMap.ToneDisablerControlOfst );
25264
f_pApiInstance->pSharedInfo->ImageInfo.fToneDisabler = TRUE;
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 )
25273
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25274
f_ulTlvValueAddress,
25275
&f_pApiInstance->pSharedInfo->MemoryMap.TailDisplEnableOfst );
25278
f_pApiInstance->pSharedInfo->ImageInfo.fTailDisplacement = TRUE;
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 )
25287
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25288
f_ulTlvValueAddress,
25289
&f_pApiInstance->pSharedInfo->MemoryMap.NlpTrivialFieldOfst );
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 )
25300
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25301
f_ulTlvValueAddress,
25305
f_pApiInstance->pSharedInfo->DebugInfo.usRecordMemIndex = (UINT16)( ulTempValue & 0xFFFF );
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 )
25315
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25316
f_ulTlvValueAddress,
25320
if ( ulTempValue == 0 )
25321
f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm = FALSE;
25323
f_pApiInstance->pSharedInfo->ImageInfo.fAdpcm = TRUE;
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 )
25333
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25334
f_ulTlvValueAddress,
25338
if ( ulTempValue == 0 )
25339
f_pApiInstance->pSharedInfo->ImageInfo.fConferencing = FALSE;
25341
f_pApiInstance->pSharedInfo->ImageInfo.fConferencing = TRUE;
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 )
25351
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25352
f_ulTlvValueAddress,
25353
&f_pApiInstance->pSharedInfo->ImageInfo.ulToneProfileNumber );
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 )
25364
UINT32 ulTailDispTempValue = 0;
25365
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25366
f_ulTlvValueAddress,
25367
&ulTailDispTempValue );
25369
ulTailDispTempValue += 1; /* Convert the value into milliseconds.*/
25370
ulTailDispTempValue *= 16; /* value was given in multiple of 16 ms. */
25372
if ( ulTailDispTempValue >= 128 )
25373
f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailDisplacement = (UINT16)( ulTailDispTempValue - 128 );
25375
f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailDisplacement = 0;
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 )
25387
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25388
f_ulTlvValueAddress,
25389
&f_pApiInstance->pSharedInfo->MemoryMap.AecFieldOfst );
25392
/* Set the flag. */
25393
f_pApiInstance->pSharedInfo->ImageInfo.fAecEnabled = TRUE;
25395
/* Acoustic echo cancellation available! */
25396
f_pApiInstance->pSharedInfo->ImageInfo.fAcousticEcho = TRUE;
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 )
25406
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25407
f_ulTlvValueAddress,
25408
&f_pApiInstance->pSharedInfo->MemoryMap.PcmLeakFieldOfst );
25411
f_pApiInstance->pSharedInfo->ImageInfo.fNonLinearityBehaviorA = TRUE;
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 )
25420
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25421
f_ulTlvValueAddress,
25422
&f_pApiInstance->pSharedInfo->MemoryMap.DefaultErlFieldOfst );
25425
/* Set the flag. */
25426
f_pApiInstance->pSharedInfo->ImageInfo.fDefaultErl = TRUE;
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 )
25436
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25437
f_ulTlvValueAddress,
25438
&f_pApiInstance->pSharedInfo->MemoryMap.ToneRemovalFieldOfst );
25441
/* Set the flag. */
25442
f_pApiInstance->pSharedInfo->ImageInfo.fToneRemoval = TRUE;
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 )
25454
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25455
f_ulTlvValueAddress,
25456
&f_pApiInstance->pSharedInfo->MemoryMap.ChanMainIoMaxEchoPointOfst );
25459
/* Set the flag. */
25460
f_pApiInstance->pSharedInfo->ImageInfo.fMaxEchoPoint = TRUE;
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 )
25470
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25471
f_ulTlvValueAddress,
25472
&f_pApiInstance->pSharedInfo->MemoryMap.NlpConvCapFieldOfst );
25475
/* Set the flag. */
25476
f_pApiInstance->pSharedInfo->ImageInfo.fNonLinearityBehaviorB = TRUE;
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 )
25486
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25487
f_ulTlvValueAddress,
25488
&f_pApiInstance->pSharedInfo->DebugInfo.ulDebugEventSize );
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 )
25499
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25500
f_ulTlvValueAddress,
25503
f_pApiInstance->pSharedInfo->ImageInfo.fConferencingNoiseReduction = (UINT8)( ulTempValue & 0xFF );
25505
if ( f_pApiInstance->pSharedInfo->ImageInfo.fConferencingNoiseReduction == TRUE )
25507
/* Set flag indicating that the dominant speaker feature is present. */
25508
f_pApiInstance->pSharedInfo->ImageInfo.fDominantSpeakerEnabled = TRUE;
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 )
25520
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25521
f_ulTlvValueAddress,
25524
f_pApiInstance->pSharedInfo->ImageInfo.usMaxTailLength = (UINT16)( ulTempValue & 0xFFFF );
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 )
25535
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25536
f_ulTlvValueAddress,
25539
f_pApiInstance->pSharedInfo->ImageInfo.usMaxNumberOfChannels = (UINT16)( ulTempValue & 0xFFFF );
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 )
25550
/* Set flag indicating that the feature is present. */
25551
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25552
f_ulTlvValueAddress,
25554
f_pApiInstance->pSharedInfo->ImageInfo.fBufferPlayout = (UINT8)( ulTempValue & 0xFF );
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 )
25565
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25566
f_ulTlvValueAddress,
25567
&f_pApiInstance->pSharedInfo->MemoryMap.DominantSpeakerFieldOfst );
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 )
25578
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25579
f_ulTlvValueAddress,
25580
&f_pApiInstance->pSharedInfo->MemoryMap.PerChanTailDisplacementFieldOfst );
25582
f_pApiInstance->pSharedInfo->ImageInfo.fPerChannelTailDisplacement = TRUE;
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 )
25593
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25594
f_ulTlvValueAddress,
25597
f_pApiInstance->pSharedInfo->ImageInfo.fAdaptiveNoiseReduction = (UINT8)( ulTempValue & 0xFF );
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 )
25608
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25609
f_ulTlvValueAddress,
25612
f_pApiInstance->pSharedInfo->ImageInfo.fMusicProtection = (UINT8)( ulTempValue & 0xFF );
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 )
25623
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25624
f_ulTlvValueAddress,
25625
&f_pApiInstance->pSharedInfo->MemoryMap.AecDefaultErlFieldOfst );
25627
f_pApiInstance->pSharedInfo->ImageInfo.fAecDefaultErl = TRUE;
25632
case cOCT6100_TLV_TYPE_Z_ALC_TARGET_BOFF:
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 )
25639
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25640
f_ulTlvValueAddress,
25641
&f_pApiInstance->pSharedInfo->MemoryMap.RinAutoLevelControlTargetOfst );
25643
f_pApiInstance->pSharedInfo->ImageInfo.fRinAutoLevelControl = TRUE;
25648
case cOCT6100_TLV_TYPE_Y_ALC_TARGET_BOFF:
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 )
25655
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25656
f_ulTlvValueAddress,
25657
&f_pApiInstance->pSharedInfo->MemoryMap.SoutAutoLevelControlTargetOfst );
25659
f_pApiInstance->pSharedInfo->ImageInfo.fSoutAutoLevelControl = TRUE;
25664
case cOCT6100_TLV_TYPE_Z_HLC_TARGET_BOFF:
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 )
25671
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25672
f_ulTlvValueAddress,
25673
&f_pApiInstance->pSharedInfo->MemoryMap.RinHighLevelCompensationThresholdOfst );
25675
f_pApiInstance->pSharedInfo->ImageInfo.fRinHighLevelCompensation = TRUE;
25680
case cOCT6100_TLV_TYPE_Y_HLC_TARGET_BOFF:
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 )
25687
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25688
f_ulTlvValueAddress,
25689
&f_pApiInstance->pSharedInfo->MemoryMap.SoutHighLevelCompensationThresholdOfst );
25691
f_pApiInstance->pSharedInfo->ImageInfo.fSoutHighLevelCompensation = TRUE;
25696
case cOCT6100_TLV_TYPE_ALC_HLC_STATUS_BOFF:
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 )
25703
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25704
f_ulTlvValueAddress,
25705
&f_pApiInstance->pSharedInfo->MemoryMap.AlcHlcStatusOfst );
25707
f_pApiInstance->pSharedInfo->ImageInfo.fAlcHlcStatus = TRUE;
25712
case cOCT6100_TLV_TYPE_Z_PLAYOUT_HARD_SKIP_BOFF:
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 )
25719
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25720
f_ulTlvValueAddress,
25721
&f_pApiInstance->pSharedInfo->MemoryMap.PlayoutRinHardSkipOfst );
25723
f_pApiInstance->pSharedInfo->ImageInfo.fRinBufferPlayoutHardSkip = TRUE;
25728
case cOCT6100_TLV_TYPE_Y_PLAYOUT_HARD_SKIP_BOFF:
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 )
25735
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25736
f_ulTlvValueAddress,
25737
&f_pApiInstance->pSharedInfo->MemoryMap.PlayoutSoutHardSkipOfst );
25739
f_pApiInstance->pSharedInfo->ImageInfo.fSoutBufferPlayoutHardSkip = TRUE;
25744
case cOCT6100_TLV_TYPE_AFT_FIELD_BOFF:
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 )
25751
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25752
f_ulTlvValueAddress,
25753
&f_pApiInstance->pSharedInfo->MemoryMap.AftControlOfst );
25755
f_pApiInstance->pSharedInfo->ImageInfo.fAftControl = TRUE;
25760
case cOCT6100_TLV_TYPE_VOICE_DETECTED_STAT_BOFF:
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 )
25767
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25768
f_ulTlvValueAddress,
25769
&f_pApiInstance->pSharedInfo->MemoryMap.SinVoiceDetectedStatOfst );
25771
f_pApiInstance->pSharedInfo->ImageInfo.fSinVoiceDetectedStat = TRUE;
25776
case cOCT6100_TLV_TYPE_GAIN_APPLIED_RIN_STAT_BOFF:
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 )
25783
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25784
f_ulTlvValueAddress,
25785
&f_pApiInstance->pSharedInfo->MemoryMap.RinAppliedGainStatOfst );
25787
f_pApiInstance->pSharedInfo->ImageInfo.fRinAppliedGainStat = TRUE;
25792
case cOCT6100_TLV_TYPE_GAIN_APPLIED_SOUT_STAT_BOFF:
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 )
25799
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25800
f_ulTlvValueAddress,
25801
&f_pApiInstance->pSharedInfo->MemoryMap.SoutAppliedGainStatOfst );
25803
f_pApiInstance->pSharedInfo->ImageInfo.fSoutAppliedGainStat = TRUE;
25808
case cOCT6100_TLV_TYPE_MAX_ADAPT_ALE_BOFF:
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 )
25815
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25816
f_ulTlvValueAddress,
25817
&f_pApiInstance->pSharedInfo->MemoryMap.AdaptiveAleOfst );
25819
f_pApiInstance->pSharedInfo->ImageInfo.fListenerEnhancement = TRUE;
25824
case cOCT6100_TLV_TYPE_RIN_ANR_BOFF:
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 )
25831
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25832
f_ulTlvValueAddress,
25833
&f_pApiInstance->pSharedInfo->MemoryMap.RinAnrOfst );
25835
f_pApiInstance->pSharedInfo->ImageInfo.fRoutNoiseReduction = TRUE;
25840
case cOCT6100_TLV_TYPE_RIN_MUTE_BOFF:
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 )
25847
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25848
f_ulTlvValueAddress,
25849
&f_pApiInstance->pSharedInfo->MemoryMap.RinMuteOfst );
25851
f_pApiInstance->pSharedInfo->ImageInfo.fRinMute = TRUE;
25856
case cOCT6100_TLV_TYPE_SIN_MUTE_BOFF:
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 )
25863
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25864
f_ulTlvValueAddress,
25865
&f_pApiInstance->pSharedInfo->MemoryMap.SinMuteOfst );
25867
f_pApiInstance->pSharedInfo->ImageInfo.fSinMute = TRUE;
25872
case cOCT6100_TLV_TYPE_NUMBER_PLAYOUT_EVENTS:
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 )
25879
ulResult = Oct6100ApiReadDword( f_pApiInstance,
25880
f_ulTlvValueAddress,
25883
f_pApiInstance->pSharedInfo->ImageInfo.byMaxNumberPlayoutEvents = (UINT8)( ulTempValue & 0xFF );
25888
case cOCT6100_TLV_TYPE_ANR_SNR_IMPROVEMENT_BOFF:
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 )
25895
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25896
f_ulTlvValueAddress,
25897
&f_pApiInstance->pSharedInfo->MemoryMap.AnrSnrEnhancementOfst );
25899
f_pApiInstance->pSharedInfo->ImageInfo.fAnrSnrEnhancement = TRUE;
25904
case cOCT6100_TLV_TYPE_ANR_AGRESSIVITY_BOFF:
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 )
25911
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25912
f_ulTlvValueAddress,
25913
&f_pApiInstance->pSharedInfo->MemoryMap.AnrVoiceNoiseSegregationOfst );
25915
f_pApiInstance->pSharedInfo->ImageInfo.fAnrVoiceNoiseSegregation = TRUE;
25920
case cOCT6100_TLV_TYPE_CHAN_TAIL_LENGTH_BOFF:
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 )
25927
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25928
f_ulTlvValueAddress,
25929
&f_pApiInstance->pSharedInfo->MemoryMap.PerChanTailLengthFieldOfst );
25931
f_pApiInstance->pSharedInfo->ImageInfo.fPerChannelTailLength = TRUE;
25936
case cOCT6100_TLV_TYPE_CHAN_VQE_TONE_DISABLING_BOFF:
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 )
25943
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25944
f_ulTlvValueAddress,
25945
&f_pApiInstance->pSharedInfo->MemoryMap.ToneDisablerVqeActivationDelayOfst );
25947
f_pApiInstance->pSharedInfo->ImageInfo.fToneDisablerVqeActivationDelay = TRUE;
25952
case cOCT6100_TLV_TYPE_AF_TAIL_DISP_VALUE_BOFF:
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 )
25959
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25960
f_ulTlvValueAddress,
25961
&f_pApiInstance->pSharedInfo->MemoryMap.AfTailDisplacementFieldOfst );
25963
f_pApiInstance->pSharedInfo->ImageInfo.fAfTailDisplacement = TRUE;
25969
case cOCT6100_TLV_TYPE_POUCH_COUNTER_BOFF:
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 )
25976
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25977
f_ulTlvValueAddress,
25978
&f_pApiInstance->pSharedInfo->MemoryMap.PouchCounterFieldOfst );
25980
f_pApiInstance->pSharedInfo->DebugInfo.fPouchCounter = TRUE;
25985
case cOCT6100_TLV_TYPE_AEC_TAIL_LENGTH_BOFF:
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 )
25992
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
25993
f_ulTlvValueAddress,
25994
&f_pApiInstance->pSharedInfo->MemoryMap.AecTailLengthFieldOfst );
25996
f_pApiInstance->pSharedInfo->ImageInfo.fAecTailLength = TRUE;
26001
case cOCT6100_TLV_TYPE_MATRIX_DWORD_BASE:
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 )
26008
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26009
f_ulTlvValueAddress,
26010
&f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixBaseAddress );
26012
/* Mask the upper bits set by the firmware. */
26013
f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixBaseAddress &= 0x0FFFFFFF;
26015
/* Modify the base address to incorporate the external memory offset. */
26016
f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixBaseAddress += cOCT6100_EXTERNAL_MEM_BASE_ADDRESS;
26021
case cOCT6100_TLV_TYPE_DEBUG_CHAN_STATS_BYTE_SIZE:
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 )
26028
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26029
f_ulTlvValueAddress,
26030
&f_pApiInstance->pSharedInfo->DebugInfo.ulDebugChanStatsByteSize );
26035
case cOCT6100_TLV_TYPE_DEBUG_CHAN_LITE_STATS_BYTE_SIZE:
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 )
26042
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26043
f_ulTlvValueAddress,
26044
&f_pApiInstance->pSharedInfo->DebugInfo.ulDebugChanLiteStatsByteSize );
26049
case cOCT6100_TLV_TYPE_HOT_CHANNEL_SELECT_DWORD_BASE:
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 )
26056
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26057
f_ulTlvValueAddress,
26058
&f_pApiInstance->pSharedInfo->DebugInfo.ulHotChannelSelectBaseAddress );
26063
case cOCT6100_TLV_TYPE_MATRIX_TIMESTAMP_DWORD_BASE:
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 )
26070
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26071
f_ulTlvValueAddress,
26072
&f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixTimestampBaseAddress );
26077
case cOCT6100_TLV_TYPE_MATRIX_WP_DWORD_BASE:
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 )
26084
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26085
f_ulTlvValueAddress,
26086
&f_pApiInstance->pSharedInfo->DebugInfo.ulMatrixWpBaseAddress );
26091
case cOCT6100_TLV_TYPE_AF_WRITE_PTR_BYTE_OFFSET:
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 )
26098
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26099
f_ulTlvValueAddress,
26100
&f_pApiInstance->pSharedInfo->DebugInfo.ulAfWritePtrByteOffset );
26105
case cOCT6100_TLV_TYPE_RECORDED_PCM_EVENT_BYTE_SIZE:
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 )
26112
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26113
f_ulTlvValueAddress,
26114
&f_pApiInstance->pSharedInfo->DebugInfo.ulRecordedPcmEventByteSize );
26119
case cOCT6100_TLV_TYPE_IS_ISR_CALLED_BOFF:
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 )
26126
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26127
f_ulTlvValueAddress,
26128
&f_pApiInstance->pSharedInfo->MemoryMap.IsIsrCalledFieldOfst );
26130
f_pApiInstance->pSharedInfo->DebugInfo.fIsIsrCalledField = TRUE;
26135
case cOCT6100_TLV_TYPE_MUSIC_PROTECTION_ENABLE_BOFF:
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 )
26142
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26143
f_ulTlvValueAddress,
26144
&f_pApiInstance->pSharedInfo->MemoryMap.MusicProtectionFieldOfst );
26146
f_pApiInstance->pSharedInfo->ImageInfo.fMusicProtectionConfiguration = TRUE;
26151
case cOCT6100_TLV_TYPE_IDLE_CODE_DETECTION_ENABLE:
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 )
26158
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26159
f_ulTlvValueAddress,
26162
f_pApiInstance->pSharedInfo->ImageInfo.fIdleCodeDetection = (UINT8)( ulTempValue & 0xFF );
26167
case cOCT6100_TLV_TYPE_IDLE_CODE_DETECTION_BOFF:
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 )
26174
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26175
f_ulTlvValueAddress,
26176
&f_pApiInstance->pSharedInfo->MemoryMap.IdleCodeDetectionFieldOfst );
26178
f_pApiInstance->pSharedInfo->ImageInfo.fIdleCodeDetectionConfiguration = TRUE;
26183
case cOCT6100_TLV_TYPE_IMAGE_TYPE:
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 )
26190
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26191
f_ulTlvValueAddress,
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;
26199
f_pApiInstance->pSharedInfo->ImageInfo.byImageType = (UINT8)( ulTempValue & 0xFF );
26204
case cOCT6100_TLV_TYPE_MAX_WIRELINE_CHANNELS:
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 )
26211
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26212
f_ulTlvValueAddress,
26218
case cOCT6100_TLV_TYPE_AF_EVENT_CB_SIZE:
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 )
26225
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26226
f_ulTlvValueAddress,
26227
&f_pApiInstance->pSharedInfo->DebugInfo.ulAfEventCbByteSize );
26232
case cOCT6100_TLV_TYPE_BUFFER_PLAYOUT_SKIP_IN_EVENTS:
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 )
26239
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26240
f_ulTlvValueAddress,
26243
f_pApiInstance->pSharedInfo->ImageInfo.fBufferPlayoutSkipInEvents = TRUE;
26248
case cOCT6100_TLV_TYPE_ZZ_ENERGY_CHAN_STATS_BOFF:
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 )
26255
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26256
f_ulTlvValueAddress,
26257
&f_pApiInstance->pSharedInfo->MemoryMap.RinEnergyStatFieldOfst );
26259
f_pApiInstance->pSharedInfo->ImageInfo.fRinEnergyStat = TRUE;
26264
case cOCT6100_TLV_TYPE_YY_ENERGY_CHAN_STATS_BOFF:
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 )
26271
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26272
f_ulTlvValueAddress,
26273
&f_pApiInstance->pSharedInfo->MemoryMap.SoutEnergyStatFieldOfst );
26275
f_pApiInstance->pSharedInfo->ImageInfo.fSoutEnergyStat = TRUE;
26280
case cOCT6100_TLV_TYPE_DOUBLE_TALK_BEH_MODE:
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 )
26287
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26288
f_ulTlvValueAddress,
26291
if ( ulTempValue != 0 )
26292
f_pApiInstance->pSharedInfo->ImageInfo.fDoubleTalkBehavior = TRUE;
26294
f_pApiInstance->pSharedInfo->ImageInfo.fDoubleTalkBehavior = FALSE;
26300
case cOCT6100_TLV_TYPE_DOUBLE_TALK_BEH_MODE_BOFF:
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 )
26307
ulResult = Oct6100ApiTlvReadBitOffsetStruct( f_pApiInstance,
26308
f_ulTlvValueAddress,
26309
&f_pApiInstance->pSharedInfo->MemoryMap.DoubleTalkBehaviorFieldOfst );
26311
f_pApiInstance->pSharedInfo->ImageInfo.fDoubleTalkBehaviorFieldOfst = TRUE;
26316
case cOCT6100_TLV_TYPE_SOUT_NOISE_BLEACHING:
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 )
26323
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26324
f_ulTlvValueAddress,
26327
if ( ulTempValue != 0 )
26328
f_pApiInstance->pSharedInfo->ImageInfo.fSoutNoiseBleaching = TRUE;
26330
f_pApiInstance->pSharedInfo->ImageInfo.fSoutNoiseBleaching = FALSE;
26336
case cOCT6100_TLV_TYPE_NLP_STATISTICS:
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 )
26343
ulResult = Oct6100ApiReadDword( f_pApiInstance,
26344
f_ulTlvValueAddress,
26347
if ( ulTempValue != 0 )
26348
f_pApiInstance->pSharedInfo->ImageInfo.fSinLevel = TRUE;
26350
f_pApiInstance->pSharedInfo->ImageInfo.fSinLevel = FALSE;
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 );
26368
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26370
Function: Oct6100ApiTlvCheckLengthField
26372
Description: This function validates the TLV length field.
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.
26381
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26382
static UINT32 Oct6100ApiTlvCheckLengthField(
26383
IN UINT32 f_ulTlvFieldLength,
26384
IN UINT32 f_ulMinLengthValue,
26385
IN UINT32 f_ulMaxLengthValue )
26387
/* Check if the value is too small. */
26388
if ( f_ulTlvFieldLength < f_ulMinLengthValue )
26389
return ( cOCT6100_ERR_FATAL_59 );
26391
/* Check if the value is too big. */
26392
if ( f_ulTlvFieldLength > f_ulMaxLengthValue )
26393
return ( cOCT6100_ERR_FATAL_5A );
26395
/* Check if the value is dword aligned. */
26396
if ( ( f_ulTlvFieldLength % 4 ) != 0 )
26397
return ( cOCT6100_ERR_OPEN_INVALID_TLV_LENGTH );
26399
return cOCT6100_ERR_OK;
26403
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26405
Function: Oct6100ApiTlvReadBitOffsetStruct
26407
Description: This function extracts a bit offset structure from the TLV.
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.
26415
f_ulAddress Address where the read the TLV information.
26416
f_pBitOffsetStruct Pointer to a bit offset stucture.
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 )
26424
tOCT6100_READ_PARAMS ReadParams;
26428
UINT32 ulOffsetValue;
26429
UINT32 ulSizeValue;
26431
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
26433
ReadParams.ulUserChipId = f_pApiInstance->pSharedInfo->ChipConfig.ulUserChipId;
26434
ReadParams.pusReadData = &usReadData;
26436
/*======================================================================*/
26437
/* Read the first 16 bits of the TLV field. */
26439
ReadParams.ulReadAddress = f_ulAddress;
26440
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
26441
if ( ulResult != cOCT6100_ERR_OK )
26445
ulOffsetValue = usReadData << 16;
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 )
26454
ulOffsetValue |= usReadData;
26456
/*======================================================================*/
26459
/*======================================================================*/
26460
/* Read the first 16 bits of the TLV field. */
26462
ReadParams.ulReadAddress += 2;
26463
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
26464
if ( ulResult != cOCT6100_ERR_OK )
26468
ulSizeValue = usReadData << 16;
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 )
26477
ulSizeValue |= usReadData;
26479
/*======================================================================*/
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);
26486
return cOCT6100_ERR_OK;
26488
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26490
File: oct6100_tone_detection.c
26492
Copyright (c) 2001-2005 Octasic Inc.
26496
This file contains functions used to enable and disable tone detection on
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.
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
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.
26513
$Octasic_Release: OCT612xAPI-01.00-PR38 $
26515
$Octasic_Revision: 49 $
26517
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26520
/***************************** INCLUDE FILES *******************************/
26522
#include "octdef.h"
26524
#include "oct6100api/oct6100_defines.h"
26525
#include "oct6100api/oct6100_errors.h"
26526
#include "oct6100api/oct6100_apiud.h"
26528
#include "apilib/octapi_llman.h"
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"
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"
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"
26555
/**************************** PUBLIC FUNCTIONS *****************************/
26557
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26559
Function: Oct6100ToneDetectionEnable
26561
Description: This function enables the generation of event for a selected
26562
tone on the specified channel.
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.
26570
f_pToneDetectEnable Pointer to tone detection enable structure.
26572
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26573
static UINT32 Oct6100ToneDetectionEnableDef(
26574
tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable )
26576
f_pToneDetectEnable->ulChannelHndl = cOCT6100_INVALID_HANDLE;
26577
f_pToneDetectEnable->ulToneNumber = cOCT6100_INVALID_TONE;
26579
return cOCT6100_ERR_OK;
26582
static UINT32 Oct6100ToneDetectionEnable(
26583
tPOCT6100_INSTANCE_API f_pApiInstance,
26584
tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable )
26586
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj;
26587
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj;
26588
UINT32 ulSerRes = cOCT6100_ERR_OK;
26589
UINT32 ulFncRes = cOCT6100_ERR_OK;
26591
/* Set the process context of the serialize structure. */
26592
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext;
26593
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext;
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 )
26601
/* Call the serialized function. */
26602
ulFncRes = Oct6100ToneDetectionEnableSer( f_pApiInstance, f_pToneDetectEnable );
26609
/* Release the seized semaphores. */
26610
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj;
26611
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj );
26613
/* If an error occured then return the error code. */
26614
if ( ulSerRes != cOCT6100_ERR_OK )
26616
if ( ulFncRes != cOCT6100_ERR_OK )
26619
return cOCT6100_ERR_OK;
26623
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26625
Function: Oct6100ToneDetectionDisable
26627
Description: This function disables the detection of a tone for a specific
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.
26636
f_pToneDetectDisable Pointer to tone detection disable structure.
26638
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26639
static UINT32 Oct6100ToneDetectionDisableDef(
26640
tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable )
26642
f_pToneDetectDisable->ulChannelHndl = cOCT6100_INVALID_HANDLE;
26643
f_pToneDetectDisable->ulToneNumber = cOCT6100_INVALID_VALUE;
26644
f_pToneDetectDisable->fDisableAll = FALSE;
26646
return cOCT6100_ERR_OK;
26651
/**************************** PRIVATE FUNCTIONS ****************************/
26653
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26655
Function: Oct6100ToneDetectionEnableSer
26657
Description: Activate the detection of a tone on the specified channel.
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.
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
26670
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26671
static UINT32 Oct6100ToneDetectionEnableSer(
26672
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
26673
IN tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable )
26675
UINT32 ulChanIndex;
26676
UINT32 ulExtToneChanIndex;
26677
UINT32 ulToneEventNumber=0;
26681
/* Check the user's configuration of the tone detection for errors. */
26682
ulResult = Oct6100ApiCheckToneEnableParams(
26684
f_pToneDetectEnable,
26686
&ulToneEventNumber,
26688
&ulExtToneChanIndex );
26689
if ( ulResult != cOCT6100_ERR_OK )
26692
/* Write to all resources needed to enable tone detection. */
26693
ulResult = Oct6100ApiWriteToneDetectEvent(
26698
ulExtToneChanIndex );
26699
if ( ulResult != cOCT6100_ERR_OK )
26702
/* Update the channel entry to indicate that a new tone has been activated. */
26703
ulResult = Oct6100ApiUpdateChanToneDetectEntry(
26707
ulExtToneChanIndex );
26708
if ( ulResult != cOCT6100_ERR_OK )
26711
return cOCT6100_ERR_OK;
26715
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26717
Function: Oct6100ApiCheckToneEnableParams
26719
Description: Check the validity of the channel and tone requested.
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.
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.
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,
26739
OUT PUINT32 f_pulExtToneChanIndex )
26741
tPOCT6100_API_CHANNEL pEchoChannel;
26742
UINT32 ulEntryOpenCnt;
26745
/*=====================================================================*/
26746
/* Check the channel handle. */
26748
if ( (f_pToneDetectEnable->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
26749
return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID;
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;
26755
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex )
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;
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;
26766
/* Set the extended tone detection info if it is activated on the channel. */
26767
*f_pulExtToneChanIndex = pEchoChannel->usExtToneChanIndex;
26769
/*=====================================================================*/
26770
/* Check the tone information. */
26772
/* Find out if the tone is present in the build. */
26773
for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ )
26775
if ( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ i ].ulToneID == f_pToneDetectEnable->ulToneNumber )
26777
*f_pulToneEventNumber = i;
26782
/* Check if tone is present. */
26783
if ( i == cOCT6100_MAX_TONE_EVENT )
26784
return cOCT6100_ERR_NOT_SUPPORTED_TONE_NOT_PRESENT_IN_FIRMWARE;
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;
26792
/*=====================================================================*/
26794
return cOCT6100_ERR_OK;
26798
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26800
Function: Oct6100ApiWriteToneDetectEvent
26802
Description: Write the tone detection event in the channel main structure.
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.
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.
26814
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
26815
static UINT32 Oct6100ApiWriteToneDetectEvent(
26816
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
26817
IN UINT32 f_ulChannelIndex,
26818
IN UINT32 f_ulToneEventNumber,
26820
IN UINT32 f_ulExtToneChanIndex )
26822
tPOCT6100_SHARED_INFO pSharedInfo;
26823
tOCT6100_WRITE_PARAMS WriteParams;
26824
tOCT6100_READ_PARAMS ReadParams;
26828
/* Obtain local pointer to shared portion of instance. */
26829
pSharedInfo = f_pApiInstance->pSharedInfo;
26833
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
26835
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
26836
ReadParams.pusReadData = &usReadData;
26838
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
26840
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
26842
/*=======================================================================*/
26843
/* Read the current event config about to be modified. */
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;
26849
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
26850
if ( ulResult != cOCT6100_ERR_OK )
26853
/*=======================================================================*/
26854
/* Set the tone event in the channel main memory for the requested direction. */
26856
WriteParams.ulWriteAddress = ReadParams.ulReadAddress;
26857
WriteParams.usWriteData = usReadData;
26858
WriteParams.usWriteData |= ( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 )));
26860
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
26861
if ( ulResult != cOCT6100_ERR_OK )
26864
/*=======================================================================*/
26865
/* Also program the extended channel if one is present. */
26867
if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX )
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;
26874
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
26875
if ( ulResult != cOCT6100_ERR_OK )
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 )));
26883
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
26884
if ( ulResult != cOCT6100_ERR_OK )
26888
/*=======================================================================*/
26890
return cOCT6100_ERR_OK;
26894
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
26896
Function: Oct6100ApiUpdateChanToneDetectEntry
26898
Description: Update the echo channel entry to store the info about the tone
26899
being configured to generate detection events.
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.
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.
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 )
26918
tPOCT6100_API_CHANNEL pEchoChanEntry;
26919
tPOCT6100_SHARED_INFO pSharedInfo;
26920
UINT32 ulToneEntry;
26922
/* Obtain local pointer to shared portion of instance. */
26923
pSharedInfo = f_pApiInstance->pSharedInfo;
26925
/* Update the channel entry. */
26926
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulChannelIndex );
26928
/* Set the corresponding bit in the channel array. */
26929
ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ];
26931
/* Modify the entry. */
26932
ulToneEntry |= ( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 )));
26934
/* Copy back the new value. */
26935
pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry;
26937
/* Configure also the extended channel if necessary. */
26938
if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX )
26940
/* Update the channel entry. */
26941
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulExtToneChanIndex );
26943
/* Set the corresponding bit in the channel array. */
26944
ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ];
26946
/* Modify the entry. */
26947
ulToneEntry |= ( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 )));
26949
/* Copy back the new value. */
26950
pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry;
26953
/* Check for the SS tone events that could have been generated before. */
26954
if ( f_ulExtToneChanIndex == cOCT6100_INVALID_INDEX )
26959
ulResult = Oct6100ApiIsSSTone( f_pApiInstance, pSharedInfo->ImageInfo.aToneInfo[ f_ulToneEventNumber ].ulToneID, &fSSTone );
26960
if ( ulResult != cOCT6100_ERR_OK )
26963
/* Is this a signaling system tone? */
26964
if ( fSSTone == TRUE )
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 ) )
26970
/* Must write an event for this. */
26971
tPOCT6100_API_TONE_EVENT pSoftEvent;
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 ) )
26977
/* Form the event for this captured tone. */
26978
mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent )
26979
pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr;
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;
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;
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;
26999
/* Set the overflow flag of the buffer. */
27000
pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++;
27006
return cOCT6100_ERR_OK;
27010
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27012
Function: Oct6100ToneDetectionDisableSer
27014
Description: Disable the generation of events for a selected tone on the
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.
27023
f_pToneDetectDisable Pointer to tOCT6100_TONE_DETECTION_DISABLE structure.
27025
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27026
static UINT32 Oct6100ToneDetectionDisableSer(
27027
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
27028
IN tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable )
27030
UINT32 ulChanIndex;
27031
UINT32 ulExtToneChanIndex;
27032
UINT32 ulToneEventNumber;
27037
/* Check the user's configuration of the tone detection disable structure for errors. */
27038
ulResult = Oct6100ApiAssertToneDetectionParams(
27040
f_pToneDetectDisable,
27042
&ulToneEventNumber,
27043
&ulExtToneChanIndex,
27046
if ( ulResult != cOCT6100_ERR_OK )
27049
/* Clear the event to detect the specified tone. */
27050
ulResult = Oct6100ApiClearToneDetectionEvent(
27054
ulExtToneChanIndex,
27057
if ( ulResult != cOCT6100_ERR_OK )
27060
/* Update the channel structure to indicate that the tone is no longer detected. */
27061
ulResult = Oct6100ApiReleaseToneDetectionEvent(
27065
ulExtToneChanIndex,
27067
if ( ulResult != cOCT6100_ERR_OK )
27070
return cOCT6100_ERR_OK;
27074
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27076
Function: Oct6100ApiAssertToneDetectionParams
27078
Description: Check the validity of the tone detection disable command.
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.
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.
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,
27101
OUT PBOOL f_pfDisableAll )
27103
tPOCT6100_API_CHANNEL pEchoChannel;
27104
UINT32 ulEntryOpenCnt;
27107
/*=====================================================================*/
27108
/* Check the echo channel handle. */
27110
if ( (f_pToneDetectDisable->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL )
27111
return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID;
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;
27117
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex )
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;
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;
27128
/* Return the extended channel index. */
27129
*f_pulExtToneChanIndex = pEchoChannel->usExtToneChanIndex;
27131
/* Check the disable all flag. */
27132
if ( f_pToneDetectDisable->fDisableAll != TRUE && f_pToneDetectDisable->fDisableAll != FALSE )
27133
return cOCT6100_ERR_TONE_DETECTION_DISABLE_ALL;
27135
/*=====================================================================*/
27136
/* Check the tone information. */
27138
/* Find out if the tone is present in the build. */
27139
if ( f_pToneDetectDisable->fDisableAll == FALSE )
27141
for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ )
27143
if ( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ i ].ulToneID == f_pToneDetectDisable->ulToneNumber )
27145
*f_pulToneEventNumber = i;
27150
/* Check if tone is present. */
27151
if ( i == cOCT6100_MAX_TONE_EVENT )
27152
return cOCT6100_ERR_NOT_SUPPORTED_TONE_NOT_PRESENT_IN_FIRMWARE;
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;
27162
/*=====================================================================*/
27164
/* Return the disable all flag as requested. */
27165
*f_pfDisableAll = f_pToneDetectDisable->fDisableAll;
27167
return cOCT6100_ERR_OK;
27171
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27173
Function: Oct6100ApiClearToneDetectionEvent
27175
Description: Clear the buffer playout event in the channel main structure.
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.
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.
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,
27195
IN BOOL f_fDisableAll )
27197
tPOCT6100_SHARED_INFO pSharedInfo;
27198
tOCT6100_WRITE_PARAMS WriteParams;
27199
tOCT6100_READ_PARAMS ReadParams;
27200
tOCT6100_WRITE_SMEAR_PARAMS SmearParams;
27202
UINT32 ulToneEventBaseAddress;
27205
/* Obtain local pointer to shared portion of instance. */
27206
pSharedInfo = f_pApiInstance->pSharedInfo;
27210
ReadParams.pProcessContext = f_pApiInstance->pProcessContext;
27212
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
27213
ReadParams.pusReadData = &usReadData;
27215
WriteParams.pProcessContext = f_pApiInstance->pProcessContext;
27217
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
27219
SmearParams.pProcessContext = f_pApiInstance->pProcessContext;
27221
SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId;
27223
/*=======================================================================*/
27224
/* Read the current event config about to be modified. */
27226
ulToneEventBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulChannelIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
27227
ulToneEventBaseAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
27229
/* Check if must disable all tone events or not. */
27230
if ( f_fDisableAll == FALSE )
27232
ReadParams.ulReadAddress = ulToneEventBaseAddress;
27233
ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2;
27235
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
27236
if ( ulResult != cOCT6100_ERR_OK )
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 ))));
27244
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
27245
if ( ulResult != cOCT6100_ERR_OK )
27248
else /* if ( f_fDisableAll == TRUE ) */
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 )
27259
/*=======================================================================*/
27260
/* Also program the extended channel if one is present. */
27262
if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX )
27264
ulToneEventBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize );
27265
ulToneEventBaseAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET;
27267
/* Check if must disable all tone events or not. */
27268
if ( f_fDisableAll == FALSE )
27270
/* Read the current event config about to be modified. */
27271
ReadParams.ulReadAddress = ulToneEventBaseAddress;
27272
ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2;
27274
mOCT6100_DRIVER_READ_API( ReadParams, ulResult );
27275
if ( ulResult != cOCT6100_ERR_OK )
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 ))));
27283
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult );
27284
if ( ulResult != cOCT6100_ERR_OK )
27287
else /* if ( f_fDisableAll == TRUE ) */
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 )
27299
return cOCT6100_ERR_OK;
27303
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27305
Function: Oct6100ApiReleaseToneDetectionEvent
27307
Description: Clear the entry made for this tone in the channel tone
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.
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.
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 )
27329
tPOCT6100_API_CHANNEL pEchoChanEntry;
27330
tPOCT6100_SHARED_INFO pSharedInfo;
27331
UINT32 ulToneEntry;
27333
UINT32 ulToneEventNumber;
27336
/* Obtain local pointer to shared portion of instance. */
27337
pSharedInfo = f_pApiInstance->pSharedInfo;
27339
/* Update the channel entry. */
27340
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulChannelIndex );
27342
/* Check if must release all tone events. */
27343
if ( f_fDisableAll == FALSE )
27345
/* Set the corresponding bit in the channel array. */
27346
ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ];
27348
/* Modify the entry. */
27349
ulToneEntry &= (~( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 ))));
27351
/* Copy back the new value. */
27352
pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry;
27354
else /* if ( f_fDisableAll == TRUE ) */
27356
/* Clear all events. */
27357
Oct6100UserMemSet( pEchoChanEntry->aulToneConf, 0x00, sizeof( pEchoChanEntry->aulToneConf ) );
27360
/* Configure also the extended channel if necessary. */
27361
if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX )
27363
/* Update the channel entry. */
27364
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulExtToneChanIndex );
27366
/* Check if must release all tone events. */
27367
if ( f_fDisableAll == FALSE )
27369
/* Set the corresponding bit in the channel array. */
27370
ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ];
27372
/* Modify the entry. */
27373
ulToneEntry &= (~( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 ))));
27375
/* Copy back the new value. */
27376
pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry;
27378
else /* if ( f_fDisableAll == TRUE ) */
27380
/* Clear all events. */
27381
Oct6100UserMemSet( pEchoChanEntry->aulToneConf, 0x00, sizeof( pEchoChanEntry->aulToneConf ) );
27385
/* Re-enable the SS7 tones */
27386
for ( ulToneEventNumber = 0; ulToneEventNumber < cOCT6100_MAX_TONE_EVENT; ulToneEventNumber++ )
27388
/* Check if the current tone is a SS tone. */
27389
ulResult = Oct6100ApiIsSSTone(
27391
f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID,
27393
if ( ulResult != cOCT6100_ERR_OK )
27396
if ( fSSTone == TRUE )
27398
/* Write to all resources needed to activate tone detection on this SS tone. */
27399
ulResult = Oct6100ApiWriteToneDetectEvent(
27404
cOCT6100_INVALID_INDEX );
27405
if ( ulResult != cOCT6100_ERR_OK )
27410
return cOCT6100_ERR_OK;
27414
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27416
Function: Oct6100ApiIsSSTone
27418
Description: Check if specified tone number is a special signaling
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.
27427
f_ulToneEventNumber Tone event number to be checked against.
27429
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27430
static UINT32 Oct6100ApiIsSSTone(
27431
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance,
27432
IN UINT32 f_ulToneEventNumber,
27433
OUT PBOOL f_fSSTone )
27435
*f_fSSTone = FALSE;
27437
switch( f_ulToneEventNumber )
27439
case cOCT6100_TONE_SIN_SYSTEM7_2000:
27440
case cOCT6100_TONE_SIN_SYSTEM7_1780:
27447
return cOCT6100_ERR_OK;
27450
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27452
File: oct6100_tsi_cnct.c
27454
Copyright (c) 2001-2005 Octasic Inc.
27458
This file contains functions used to open and close TSI connections
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.
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
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.
27474
$Octasic_Release: OCT612xAPI-01.00-PR38 $
27476
$Octasic_Revision: 37 $
27478
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27481
/***************************** INCLUDE FILES *******************************/
27483
#include "octdef.h"
27485
#include "oct6100api/oct6100_defines.h"
27486
#include "oct6100api/oct6100_errors.h"
27487
#include "oct6100api/oct6100_apiud.h"
27489
#include "apilib/octapi_llman.h"
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"
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"
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 ****************************/
27514
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27516
Function: Oct6100ApiGetTsiCnctSwSizes
27518
Description: Gets the sizes of all portions of the API instance pertinent
27519
to the management the TSI memory.
27521
-------------------------------------------------------------------------------
27522
| Argument | Description
27523
-------------------------------------------------------------------------------
27524
f_pOpenChip Pointer to chip configuration struct.
27525
f_pInstSizes Pointer to struct containing instance sizes.
27527
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27528
static UINT32 Oct6100ApiGetTsiCnctSwSizes(
27529
IN tPOCT6100_CHIP_OPEN f_pOpenChip,
27530
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
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 );
27538
if ( f_pOpenChip->ulMaxTsiCncts > 0 )
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;
27547
f_pInstSizes->ulTsiCnctAlloc = 0;
27550
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsiCnctList, ulTempVar )
27551
mOCT6100_ROUND_MEMORY_SIZE( f_pInstSizes->ulTsiCnctAlloc, ulTempVar )
27553
return cOCT6100_ERR_OK;
27557
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27559
Function: Oct6100ApiTsiCnctSwInit
27561
Description: Initializes all elements of the instance structure associated
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.
27570
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27571
static UINT32 Oct6100ApiTsiCnctSwInit(
27572
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
27574
tPOCT6100_API_TSI_CNCT pChannelsTsiList;
27575
tPOCT6100_SHARED_INFO pSharedInfo;
27576
UINT32 ulMaxTsiChannels;
27577
PVOID pTsiChannelsAlloc;
27580
/* Get local pointer to shared portion of instance. */
27581
pSharedInfo = f_pApiInstance->pSharedInfo;
27583
/* Initialize the TSI connections API list. */
27584
ulMaxTsiChannels = pSharedInfo->ChipConfig.usMaxTsiCncts;
27586
mOCT6100_GET_TSI_CNCT_LIST_PNT( pSharedInfo, pChannelsTsiList )
27588
/* Clear the memory. */
27589
Oct6100UserMemSet( pChannelsTsiList, 0x00, sizeof(tOCT6100_API_TSI_CNCT) * ulMaxTsiChannels );
27591
/* Set all entries in the TSI connections list to unused. */
27592
if ( ulMaxTsiChannels > 0 )
27594
mOCT6100_GET_TSI_CNCT_ALLOC_PNT( pSharedInfo, pTsiChannelsAlloc )
27596
ulResult = OctapiLlmAllocInit( &pTsiChannelsAlloc, ulMaxTsiChannels );
27597
if ( ulResult != cOCT6100_ERR_OK )
27598
return cOCT6100_ERR_FATAL_49;
27601
return cOCT6100_ERR_OK;
27604
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27606
File: oct6100_tsst.c
27608
Copyright (c) 2001-2005 Octasic Inc.
27612
This file contains the functions used to manage the allocation of TSST
27613
control structures in internal memory.
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.
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
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.
27629
$Octasic_Release: OCT612xAPI-01.00-PR38 $
27631
$Octasic_Revision: 39 $
27633
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27636
/***************************** INCLUDE FILES *******************************/
27638
#include "octdef.h"
27640
#include "oct6100api/oct6100_defines.h"
27641
#include "oct6100api/oct6100_errors.h"
27643
#include "apilib/octapi_llman.h"
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"
27655
#include "oct6100api/oct6100_interrupts_pub.h"
27656
#include "oct6100api/oct6100_channel_pub.h"
27657
#include "oct6100api/oct6100_chip_open_pub.h"
27659
#include "oct6100_chip_open_priv.h"
27660
#include "oct6100_tsst_priv.h"
27663
/**************************** PRIVATE FUNCTIONS ****************************/
27666
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27668
Function: Oct6100ApiGetTsstSwSizes
27670
Description: Gets the sizes of all portions of the API instance pertinent
27671
to the management of TSSTs.
27673
-------------------------------------------------------------------------------
27674
| Argument | Description
27675
-------------------------------------------------------------------------------
27676
f_pInstSizes Pointer to struct containing instance sizes.
27678
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27679
static UINT32 Oct6100ApiGetTsstSwSizes(
27680
OUT tPOCT6100_API_INSTANCE_SIZES f_pInstSizes )
27685
/* Determine amount of TSST needed for TSST allocation table. */
27686
f_pInstSizes->ulTsstAlloc = 4096 / 8;
27688
/* Calculate the API memory required for the TSST entry list. */
27689
f_pInstSizes->ulTsstEntryList = cOCT6100_MAX_TSSTS * sizeof( tOCT6100_API_TSST_ENTRY );
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;
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 );
27700
return cOCT6100_ERR_OK;
27704
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27706
Function: Oct6100ApiTsstSwInit
27708
Description: Initializes all elements of the instance structure associated
27709
to the TSST control entries.
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.
27717
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
27718
static UINT32 Oct6100ApiTsstSwInit(
27719
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance )
27721
tPOCT6100_SHARED_INFO pSharedInfo;
27722
tPOCT6100_API_TSST_ENTRY pTsstList;
27723
PUINT32 pulTsstAlloc;
27724
PVOID pTsstListAlloc;
27727
/* Get local pointer(s). */
27728
pSharedInfo = f_pApiInstance->pSharedInfo;
27730
/* Initialize the TSST allocation table to "all free". */
27731
mOCT6100_GET_TSST_ALLOC_PNT( pSharedInfo, pulTsstAlloc );
27732
Oct6100UserMemSet( pulTsstAlloc, 0x00, 512 );
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) );
27738
/* Initialize the allocation list to manage the TSST entries.*/
27739
mOCT6100_GET_TSST_LIST_ALLOC_PNT( pSharedInfo, pTsstListAlloc )
27741
ulResult = OctapiLlmAllocInit( &pTsstListAlloc, cOCT6100_MAX_TSSTS );
27742
if ( ulResult != cOCT6100_ERR_OK )
27743
return cOCT6100_ERR_FATAL_4E;
27745
return cOCT6100_ERR_OK;
27749
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27751
Function: Oct6100ApiValidateTsst
27753
Description: Validates a timeslot, stream combination.
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.
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).
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 )
27774
tPOCT6100_SHARED_INFO pSharedInfo;
27775
tPOCT6100_API_CHIP_CONFIG pChipConfig;
27776
PUINT32 pulTsstAlloc;
27778
/* Obtain local pointer to shared portion of instance. */
27779
pSharedInfo = f_pApiInstance->pSharedInfo;
27781
mOCT6100_GET_TSST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pulTsstAlloc );
27783
/* Obtain local pointer to chip configuration. */
27784
pChipConfig = &pSharedInfo->ChipConfig;
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;
27791
if ( f_ulTimeslot != cOCT6100_UNASSIGNED &&
27792
f_ulStream == cOCT6100_UNASSIGNED )
27793
return cOCT6100_ERR_TSST_STREAM;
27795
if ( f_ulStream >= pChipConfig->byMaxTdmStreams )
27796
return cOCT6100_ERR_TSST_STREAM;
27798
/* Check timeslot value based on the frequenccy of the selected stream. */
27799
switch ( pChipConfig->aulTdmStreamFreqs[ f_ulStream / 4 ] )
27801
case cOCT6100_TDM_STREAM_FREQ_2MHZ:
27802
if ( f_ulTimeslot >= 32 )
27803
return cOCT6100_ERR_TSST_TIMESLOT;
27805
case cOCT6100_TDM_STREAM_FREQ_4MHZ:
27806
if ( f_ulTimeslot >= 64 )
27807
return cOCT6100_ERR_TSST_TIMESLOT;
27809
case cOCT6100_TDM_STREAM_FREQ_8MHZ:
27810
if ( f_ulTimeslot >= 128 )
27811
return cOCT6100_ERR_TSST_TIMESLOT;
27813
case cOCT6100_TDM_STREAM_FREQ_16MHZ:
27814
if ( f_ulTimeslot >= 256 )
27815
return cOCT6100_ERR_TSST_TIMESLOT;
27817
/* Check the stream value based on the direction. */
27818
if ( f_ulDirection == cOCT6100_INPUT_TSST && f_ulStream >= 16 )
27820
return cOCT6100_ERR_TSST_STREAM;
27822
else if( f_ulDirection == cOCT6100_OUTPUT_TSST && f_ulStream < 16 )
27824
return cOCT6100_ERR_TSST_STREAM;
27829
return cOCT6100_ERR_FATAL_DC;
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;
27836
return cOCT6100_ERR_OK;
27840
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
27842
Function: Oct6100ApiReserveTsst
27844
Description: Reserves a TSST, only one TSI entry can access a TSST at any one
27846
If the pointer f_pulTsstListIndex is set to NULL, no TSST list
27847
entry will be reserved.
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 ).
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.
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 )
27875
tPOCT6100_SHARED_INFO pSharedInfo;
27876
PVOID pTsstListAlloc;
27877
PUINT32 pulTsstAlloc;
27878
UINT32 ulResult = cOCT6100_ERR_OK;
27882
/* Get local pointer to shared portion of API instance structure. */
27883
pSharedInfo = f_pApiInstance->pSharedInfo;
27885
mOCT6100_GET_TSST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pulTsstAlloc );
27887
/*==================================================================================*/
27888
/* Now make the proper conversion to obtain the TSST value. */
27890
/* Save the timeslot and stream value received. */
27891
ulStream = f_ulStream;
27892
ulTimeslot = f_ulTimeslot;
27894
/* Set the TSST index associated to this stream, timeslot combination. */
27895
switch ( f_pApiInstance->pSharedInfo->ChipConfig.aulTdmStreamFreqs[ f_ulStream / 4 ] )
27897
case cOCT6100_TDM_STREAM_FREQ_16MHZ:
27898
if ( f_ulDirection == cOCT6100_INPUT_TSST )
27900
ulStream = f_ulStream + ( f_ulTimeslot % 2 ) * 16;
27901
ulTimeslot = f_ulTimeslot / 2;
27903
else /* f_ulDirection == cOCT6100_OUTPUT_TSST */
27905
ulStream = ( f_ulStream - 16 ) + ( f_ulTimeslot % 2 ) * 16;
27907
if ( f_ulStream < 28 && ((f_ulTimeslot % 2) == 1) )
27909
ulTimeslot = ((f_ulTimeslot / 2) + 4) % 128;
27913
ulTimeslot = f_ulTimeslot / 2 ;
27917
*f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 + ulStream );
27920
case cOCT6100_TDM_STREAM_FREQ_8MHZ:
27921
*f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 + ulStream );
27924
case cOCT6100_TDM_STREAM_FREQ_4MHZ:
27925
*f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 * 2 );
27926
if ( f_ulDirection == cOCT6100_OUTPUT_TSST )
27928
*f_pusTsstMemIndex = (UINT16)( *f_pusTsstMemIndex + ulStream );
27930
else /* if ( f_ulDirection == cOCT6100_INPUT_TSST ) */
27932
*f_pusTsstMemIndex = (UINT16)( ( 1 * 32 + ulStream ) + *f_pusTsstMemIndex );
27936
case cOCT6100_TDM_STREAM_FREQ_2MHZ:
27937
*f_pusTsstMemIndex = (UINT16)( ulTimeslot * 32 * 4 );
27938
if ( f_ulDirection == cOCT6100_OUTPUT_TSST )
27940
*f_pusTsstMemIndex = (UINT16)( ulStream + *f_pusTsstMemIndex );
27942
else /* if ( f_ulDirection == cOCT6100_INPUT_TSST ) */
27944
*f_pusTsstMemIndex = (UINT16)( ( 3 * 32 + ulStream ) + *f_pusTsstMemIndex );
27949
ulResult = cOCT6100_ERR_FATAL_8B;
27951
/*======================================================================*/
27954
/*======================================================================*/
27955
/* First reserve the TSST. */
27957
/* Get local pointer to TSST's entry in allocation table. */
27958
switch ( pSharedInfo->ChipConfig.aulTdmStreamFreqs[ ulStream / 4 ] )
27960
case cOCT6100_TDM_STREAM_FREQ_2MHZ:
27963
case cOCT6100_TDM_STREAM_FREQ_4MHZ:
27966
case cOCT6100_TDM_STREAM_FREQ_8MHZ:
27969
case cOCT6100_TDM_STREAM_FREQ_16MHZ:
27973
return cOCT6100_ERR_FATAL_DD;
27976
/* Check if entry is already reserved. */
27977
if ( ((pulTsstAlloc[ ulTimeslot ] >> ulStream) & 0x1) == 0x1 )
27978
return cOCT6100_ERR_TSST_TSST_RESERVED;
27980
/* Check and reserve the associated TSST if required. */
27981
if ( f_ulNumTsst == 2 )
27983
/* Check if entry is already reserved. */
27984
if ( ((pulTsstAlloc[ ulTimeslot ] >> (ulStream - 1) ) & 0x1) == 0x1 )
27985
return cOCT6100_ERR_TSST_ASSOCIATED_TSST_RESERVED;
27987
/* The entry is free, it won't anymore. */
27988
pulTsstAlloc[ ulTimeslot ] |= (0x1 << (ulStream - 1));
27991
/* The entry is free, it won't anymore.*/
27992
pulTsstAlloc[ ulTimeslot ] |= (0x1 << ulStream);
27994
/*======================================================================*/
27997
/*======================================================================*/
27998
/* Now reserve a TSST entry if requested. */
28000
if ( f_pusTsstListIndex != NULL && ulResult == cOCT6100_ERR_OK )
28002
UINT32 ulTsstListIndex;
28004
/* Reserve a TSST entry in the API TSST list. */
28005
mOCT6100_GET_TSST_LIST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pTsstListAlloc );
28007
ulResult = OctapiLlmAllocAlloc( pTsstListAlloc, &ulTsstListIndex );
28008
if ( ulResult != cOCT6100_ERR_OK )
28010
if ( ulResult == OCTAPI_LLM_NO_STRUCTURES_LEFT )
28011
ulResult = cOCT6100_ERR_TSST_ALL_TSSTS_ARE_OPENED;
28013
ulResult = cOCT6100_ERR_FATAL_52;
28016
*f_pusTsstListIndex = (UINT16)( ulTsstListIndex & 0xFFFF );
28018
/*======================================================================*/
28021
/*======================================================================*/
28022
/* Check the result of the TSST list reservation. */
28024
if ( ulResult != cOCT6100_ERR_OK )
28026
/* Release the previously reserved TSST. */
28027
if ( f_ulNumTsst == 2 )
28029
/* Clear the entry. */
28030
pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << (ulStream - 1) );
28034
/* Clear the entry. */
28035
pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << ulStream);
28038
/*======================================================================*/
28044
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28046
Function: Oct6100ApiReleaseTsst
28048
Description: Releases a TSST.
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.
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.
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.
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)
28074
tPOCT6100_SHARED_INFO pSharedInfo;
28075
PUINT32 pulTsstAlloc;
28076
PVOID pTsstListAlloc;
28081
/* Get local pointer to shared portion of API instance structure. */
28082
pSharedInfo = f_pApiInstance->pSharedInfo;
28084
if ( f_usTsstListIndex != cOCT6100_INVALID_INDEX )
28086
mOCT6100_GET_TSST_LIST_ALLOC_PNT( pSharedInfo, pTsstListAlloc )
28088
ulResult = OctapiLlmAllocDealloc( pTsstListAlloc, f_usTsstListIndex );
28089
if ( ulResult != cOCT6100_ERR_OK )
28091
return cOCT6100_ERR_FATAL_53;
28095
mOCT6100_GET_TSST_ALLOC_PNT( f_pApiInstance->pSharedInfo, pulTsstAlloc );
28097
/*==================================================================================*/
28098
/* Now make the proper conversion to obtain the TSST value. */
28100
/* Save the timeslot and stream value received. */
28101
ulStream = f_ulStream;
28102
ulTimeslot = f_ulTimeslot;
28104
/* Set the TSST index associated to this stream, timeslot combination. */
28105
if ( pSharedInfo->ChipConfig.aulTdmStreamFreqs[ f_ulStream / 4 ] == cOCT6100_TDM_STREAM_FREQ_16MHZ )
28107
if ( f_ulDirection == cOCT6100_INPUT_TSST )
28109
ulStream = f_ulStream + ( f_ulTimeslot % 2 ) * 16;
28110
ulTimeslot = f_ulTimeslot / 2;
28112
else /* f_ulDirection == cOCT6100_OUTPUT_TSST */
28114
ulStream = ( f_ulStream - 16 ) + ( f_ulTimeslot % 2 ) * 16;
28116
if ( f_ulStream < 28 && ((f_ulTimeslot % 2) == 1) )
28118
ulTimeslot = ((f_ulTimeslot / 2) + 4) % 128;
28122
ulTimeslot = f_ulTimeslot / 2 ;
28127
/* Get local pointer to TSST's entry in allocation table. */
28128
switch ( pSharedInfo->ChipConfig.aulTdmStreamFreqs[ ulStream / 4 ] )
28130
case cOCT6100_TDM_STREAM_FREQ_2MHZ:
28133
case cOCT6100_TDM_STREAM_FREQ_4MHZ:
28136
case cOCT6100_TDM_STREAM_FREQ_8MHZ:
28139
case cOCT6100_TDM_STREAM_FREQ_16MHZ:
28143
return cOCT6100_ERR_FATAL_DE;
28146
/* Check if entry is actualy reserved. */
28147
if ( ((pulTsstAlloc[ ulTimeslot ] >> ulStream) & 0x1) != 0x1 )
28148
return cOCT6100_ERR_FATAL_55;
28150
/*==================================================================================*/
28152
/* Clear the entry. */
28153
pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << ulStream);
28155
/* Check and release the associated TSST if required. */
28156
if ( f_ulNumTsst == 2 )
28158
/* Check if entry is actualy reserved. */
28159
if ( ((pulTsstAlloc[ ulTimeslot ] >> ( ulStream - 1)) & 0x1) != 0x1 )
28160
return cOCT6100_ERR_FATAL_54;
28162
/* Clear the entry. */
28163
pulTsstAlloc[ ulTimeslot ] &= ~(0x1 << (ulStream - 1));
28167
return cOCT6100_ERR_OK;
28169
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28171
File: octapi_llman.c
28173
Copyright (c) 2001-2005 Octasic Inc.
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.
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.
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
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.
28195
$Octasic_Release: OCT612xAPI-01.00-PR38 $
28197
$Octasic_Revision: 21 $
28199
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28200
#include "octapi_llman_private.h"
28201
#include "apilib/octapi_llman.h"
28202
#include "apilib/octapi_largmath.h"
28205
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28208
| Function: OctapiLlmAllocGetSize.
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.
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.
28220
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28221
static UINT32 OctapiLlmAllocGetSize(UINT32 number_of_items,UINT32 * l_size)
28223
if (number_of_items == 0) return(GENERIC_BAD_PARAM);
28225
*l_size = (sizeof(LLM_ALLOC)) + (number_of_items * sizeof(UINT32));
28227
return(GENERIC_OK);
28230
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28233
| Function: OctapiLlmAllocInit.
28235
| Description: This function intializes the LLM_ALLOC structure.
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.
28243
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28244
static UINT32 OctapiLlmAllocInit(void ** l,UINT32 number_of_items)
28249
/* Check the number of items required.*/
28250
if (number_of_items == 0) return(GENERIC_BAD_PARAM);
28252
/* If no memory has been allocated yet:*/
28253
if (*l == NULL) return(OCTAPI_LLM_MEMORY_NOT_ALLOCATED);
28255
/* Build the structure before starting.*/
28256
ls = (LLM_ALLOC *)(*l);
28257
ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC));
28259
ls->number_of_items = number_of_items;
28261
/* Linked list links all structures in ascending order.*/
28262
for(i=0;i<number_of_items;i++)
28264
ls->linked_list[i] = i+1;
28267
ls->linked_list[number_of_items - 1] = 0xFFFFFFFF; /* Invalid link.*/
28269
/* Next avail is 0.*/
28270
ls->next_avail_num = 0;
28272
/* Number of allocated items is null.*/
28273
ls->allocated_items = 0;
28275
return(GENERIC_OK);
28279
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28282
| Function: OctapiLlmAllocInfo.
28284
| Description: This function returns the number of free and allocated
28285
| block in the LLMAN list.
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.
28294
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28295
static UINT32 OctapiLlmAllocInfo(void * l,UINT32 * allocated_items,UINT32 * available_items)
28299
/* Build the structure before starting.*/
28300
ls = (LLM_ALLOC *)l;
28301
ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC));
28303
*allocated_items = ls->allocated_items;
28304
*available_items = ls->number_of_items - ls->allocated_items;
28305
return(GENERIC_OK);
28309
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28312
| Function: OctapiLlmAllocInfo.
28314
| Description: This function allocates the resource indicated by blocknum.
28315
| If the resource can be allocated then GENERIC_OK is returned.
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.
28324
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28325
static UINT32 OctapiLlmAllocAlloc(void * l,UINT32 * blocknum)
28328
UINT32 allocated_block;
28331
/* Build the structure before starting.*/
28332
ls = (LLM_ALLOC *)l;
28333
ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC));
28335
/* Get next available block number.*/
28336
allocated_block = ls->next_avail_num;
28338
/* Check if block is invalid.*/
28339
if (allocated_block == 0xFFFFFFFF)
28341
/* Make blocknum NULL.*/
28342
*blocknum = 0xFFFFFFFF;
28344
return(OCTAPI_LLM_NO_STRUCTURES_LEFT);
28347
node = &ls->linked_list[allocated_block];
28349
/* Copy next block number.*/
28350
ls->next_avail_num = *node;
28352
/* Tag as used the current block number.*/
28353
*node = 0xFFFFFFFE;
28355
/* Return proper block number.*/
28356
*blocknum = allocated_block;
28358
/* Update block usage number.*/
28359
ls->allocated_items++;
28361
return(GENERIC_OK);
28364
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28367
| Function: OctapiLlmAllocDealloc.
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.
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.
28379
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28380
static UINT32 OctapiLlmAllocDealloc(void * l,UINT32 blocknum)
28385
/* Build the structure before starting.*/
28386
ls = (LLM_ALLOC *)l;
28387
ls->linked_list = (UINT32 *)((BYTE *)ls + sizeof(LLM_ALLOC));
28389
/* Check for null item pointer.*/
28390
if (blocknum == 0xFFFFFFFF) return(GENERIC_OK);
28392
/* Check if blocknum is within specified item range.*/
28393
if (blocknum >= ls->number_of_items) return(OCTAPI_LLM_BLOCKNUM_OUT_OF_RANGE);
28395
node = &ls->linked_list[blocknum];
28397
/* Check if block is really used as of now.*/
28398
if (*node != 0xFFFFFFFE) return(OCTAPI_LLM_MEMORY_NOT_ALLOCATED);
28400
/* Add link to list.*/
28401
*node = ls->next_avail_num;
28403
/* Point to returned block.*/
28404
ls->next_avail_num = blocknum;
28406
/* Update block usage number.*/
28407
ls->allocated_items--;
28409
return(GENERIC_OK);
28412
/**************************************** llm_list section **********************************************/
28414
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
28418
Copyright (c) 2001-2005 Octasic Inc.
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.
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.
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
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.
28439
$Octasic_Release: OCT612xAPI-01.00-PR38 $
28441
$Octasic_Revision: 18 $
28443
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
28444
#include "apilib/octapi_bt0.h"
28445
#include "octapi_bt0_private.h"
28449
static UINT32 OctApiBt0GetSize(UINT32 number_of_items,UINT32 key_size, UINT32 data_size, UINT32 * b_size)
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);
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;
28460
return(GENERIC_OK);
28463
static UINT32 OctApiBt0Init(void ** b,UINT32 number_of_items,UINT32 key_size, UINT32 data_size)
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);
28472
/* If b is not already allocated.*/
28473
if (*b == NULL) return(OCTAPI_BT0_MALLOC_FAILED);
28475
bb = (OCTAPI_BT0 *)(*b);
28477
/* Initialize the tree to an empty one!*/
28478
bb->root_link.node_number = 0xFFFFFFFF;
28479
bb->root_link.depth = 0;
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;
28486
/* Initialize the next free node pointer.*/
28487
if (number_of_items != 0)
28488
bb->next_free_node = 0;
28490
bb->next_free_node = 0xFFFFFFFF;
28492
/* Setup the arrays.*/
28493
OctApiBt0CorrectPointers(bb);
28495
/* Initialize the Nodes to unused!*/
28496
for(i=0;i<number_of_items;i++)
28498
bb->node[i].next_free_node = i + 1;
28501
/* Last empty node points to invalid node.*/
28502
bb->node[number_of_items-1].next_free_node = 0xFFFFFFFF;
28504
bb->invalid_value = 0xFFFFFFFF;
28505
bb->no_smaller_key = OCTAPI_BT0_NO_SMALLER_KEY;
28507
return(GENERIC_OK);
28511
void OctApiBt0CorrectPointers(OCTAPI_BT0 * bb)
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));
28519
static UINT32 OctApiBt0AddNode2(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 new_node_number)
28523
if (link->node_number == 0xFFFFFFFF) /* We have an empty node. Here, we shall place the new node.*/
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;
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.*/
28534
return(GENERIC_OK);
28536
else /* Current node is used, check for a match and a direction.*/
28538
OCTAPI_BT0_NODE * this_node;
28541
/* Get a pointer to this node.*/
28542
this_node = &(bb->node[link->node_number]);
28544
/* Compare this node to the lkey.*/
28545
compare = OctApiBt0KeyCompare(bb,link,lkey);
28547
if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/
28549
result = OctApiBt0AddNode2(bb,&(this_node->l[0]), lkey, new_node_number);
28550
if (result != GENERIC_OK) return(result);
28552
else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/
28554
result = OctApiBt0AddNode2(bb,&(this_node->l[1]), lkey, new_node_number);
28555
if (result != GENERIC_OK) return(result);
28559
return(OCTAPI_BT0_KEY_ALREADY_IN_TREE);
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))
28566
OctApiBt0Rebalance(bb,link);
28569
/* Always update the OCTAPI_BT0_LINK depth before exiting.*/
28570
OctApiBt0UpdateLinkDepth(bb,link);
28572
return(GENERIC_OK);
28577
static UINT32 OctApiBt0AddNode3(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 *p_new_node_number)
28581
if (link->node_number == 0xFFFFFFFF) /* We have an empty node. Here, we shall place the new node.*/
28583
if ( *p_new_node_number == 0xFFFFFFFF )
28584
return(OCTAPI_BT0_NO_NODES_AVAILABLE);
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;
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.*/
28595
return(GENERIC_OK);
28597
else /* Current node is used, check for a match and a direction.*/
28599
OCTAPI_BT0_NODE * this_node;
28602
/* Get a pointer to this node.*/
28603
this_node = &(bb->node[link->node_number]);
28605
/* Compare this node to the lkey.*/
28606
compare = OctApiBt0KeyCompare(bb,link,lkey);
28608
if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/
28610
result = OctApiBt0AddNode3(bb,&(this_node->l[0]), lkey, p_new_node_number);
28611
if (result != GENERIC_OK) return(result);
28613
else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/
28615
result = OctApiBt0AddNode3(bb,&(this_node->l[1]), lkey, p_new_node_number);
28616
if (result != GENERIC_OK) return(result);
28620
*p_new_node_number = link->node_number;
28621
return(OCTAPI_BT0_KEY_ALREADY_IN_TREE);
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))
28628
OctApiBt0Rebalance(bb,link);
28631
/* Always update the OCTAPI_BT0_LINK depth before exiting.*/
28632
OctApiBt0UpdateLinkDepth(bb,link);
28634
return(GENERIC_OK);
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 )
28647
if (link->node_number == 0xFFFFFFFF) /* We have an empty node. Here, we shall place the new node.*/
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;
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.*/
28659
*p_prev_node_number = 0xFFFFFFFF;
28661
return(GENERIC_OK);
28663
else /* Current node is used, check for a match and a direction.*/
28665
OCTAPI_BT0_NODE * this_node;
28668
/* Get a pointer to this node.*/
28669
this_node = &(bb->node[link->node_number]);
28671
/* Compare this node to the lkey.*/
28672
compare = OctApiBt0KeyCompare(bb,link,lkey);
28674
if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/
28677
*p_prev_node_number = OCTAPI_BT0_NO_SMALLER_KEY;
28679
if ( *p_prev_node_number != OCTAPI_BT0_NO_SMALLER_KEY )
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 )
28687
if ( *nkey < *lkey )
28688
*p_prev_node_number = link->node_number;
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);
28695
else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/
28698
*p_prev_node_number = link->node_number;
28701
if ( *p_prev_node_number == OCTAPI_BT0_NO_SMALLER_KEY )
28702
*p_prev_node_number = link->node_number;
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 )
28711
if ( *nkey < *lkey )
28712
*p_prev_node_number = link->node_number;
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);
28722
*p_new_node_number = link->node_number;
28723
return(OCTAPI_BT0_KEY_ALREADY_IN_TREE);
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))
28730
OctApiBt0Rebalance(bb,link);
28733
/* Always update the OCTAPI_BT0_LINK depth before exiting.*/
28734
OctApiBt0UpdateLinkDepth(bb,link);
28736
return(GENERIC_OK);
28740
static UINT32 OctApiBt0KeyCompare(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link, UINT32 * lkey)
28745
/* Find the first UINT32 of the key.*/
28746
nkey = &(bb->key[bb->key_size * link->node_number]);
28748
for(i=0;i<bb->key_size;i++)
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);
28756
return(OCTAPI_BT0_LKEY_EQUAL);
28760
void OctApiBt0UpdateLinkDepth(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link)
28762
OCTAPI_BT0_NODE * this_node;
28764
/* Get a pointer to this node.*/
28765
this_node = &(bb->node[link->node_number]);
28767
if (this_node->l[0].depth > this_node->l[1].depth)
28768
link->depth = this_node->l[0].depth + 1;
28770
link->depth = this_node->l[1].depth + 1;
28773
void OctApiBt0Rebalance(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * root_link)
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.*/
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.*/
28780
OCTAPI_BT0_LINK * heavy_link;
28781
heavy_link = &(bb->node[root_link->node_number].l[0]);
28783
if (bb->node[heavy_link->node_number].l[1].depth > bb->node[heavy_link->node_number].l[0].depth)
28785
OctApiBt0ExternalHeavy(bb,heavy_link);
28789
/* Ready to do super rotation!*/
28791
OCTAPI_BT0_LINK init_root_link;
28792
OCTAPI_BT0_LINK init_heavy_link;
28793
OCTAPI_BT0_LINK init_leaf_tree[3];
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];
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];
28807
/* Reconstruct the depth of the branches.*/
28808
OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[1]));
28809
OctApiBt0UpdateLinkDepth(bb,root_link);
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.*/
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.*/
28817
OCTAPI_BT0_LINK * heavy_link;
28818
heavy_link = &(bb->node[root_link->node_number].l[1]);
28820
if (bb->node[heavy_link->node_number].l[0].depth > bb->node[heavy_link->node_number].l[1].depth)
28822
OctApiBt0ExternalHeavy(bb,heavy_link);
28826
/* Ready to do super rotation!*/
28828
OCTAPI_BT0_LINK init_root_link;
28829
OCTAPI_BT0_LINK init_heavy_link;
28830
OCTAPI_BT0_LINK init_leaf_tree[3];
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];
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];
28844
/* Reconstruct the depth of the branches.*/
28845
OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[0]));
28846
OctApiBt0UpdateLinkDepth(bb,root_link);
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)
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.*/
28857
OCTAPI_BT0_LINK init_root_link;
28858
OCTAPI_BT0_LINK init_heavy_link;
28859
OCTAPI_BT0_LINK init_leaf_tree[3];
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];
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];
28873
/* Reconstruct the depth of the branches.*/
28874
OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[0]));
28875
OctApiBt0UpdateLinkDepth(bb,root_link);
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.*/
28879
OCTAPI_BT0_LINK init_root_link;
28880
OCTAPI_BT0_LINK init_heavy_link;
28881
OCTAPI_BT0_LINK init_leaf_tree[3];
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];
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];
28895
/* Reconstruct the depth of the branches.*/
28896
OctApiBt0UpdateLinkDepth(bb,&(bb->node[root_link->node_number].l[1]));
28897
OctApiBt0UpdateLinkDepth(bb,root_link);
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)
28909
OCTAPI_BT0_NODE * this_node;
28911
/* Get a pointer to this node.*/
28912
this_node = &(bb->node[link->node_number]);
28916
if (link->node_number == 0xFFFFFFFF) /* We have an empty node. The node we were looking for does not exist.*/
28918
return(OCTAPI_BT0_KEY_NOT_IN_TREE);
28920
else /* Current node is used, check for a match and a direction.*/
28924
/* Compare this node to the lkey.*/
28925
compare = OctApiBt0KeyCompare(bb,link,lkey);
28927
if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/
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);
28932
else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/
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);
28939
link_to_removed_node = link;
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)
28944
/* Doe! No tree left! WHAT TO DO? */
28945
/* Just delete the current node. That's it.*/
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;
28951
link->node_number = 0xFFFFFFFF;
28954
return(GENERIC_OK);
28956
else if (bb->node[link->node_number].l[0].node_number != 0xFFFFFFFF) /* Left node is present. Go left, then permanently right.*/
28958
OCTAPI_BT0_NODE * removed_node_pnt;
28959
removed_node_pnt = &(bb->node[link->node_number]);
28961
result = OctApiBt0RemoveNode2(bb,&(removed_node_pnt->l[0]), lkey, link_to_removed_node, 1, link);
28962
if (result != GENERIC_OK) return(result);
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];*/
28968
else /* Right node is present. Go right, then permanently left.*/
28970
OCTAPI_BT0_NODE * removed_node_pnt;
28971
removed_node_pnt = &(bb->node[link->node_number]);
28973
result = OctApiBt0RemoveNode2(bb,&(removed_node_pnt->l[1]), lkey, link_to_removed_node, 2, link);
28974
if (result != GENERIC_OK) return(result);
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];*/
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))
28990
OCTAPI_BT0_LINK init_chosen_link;
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;
28996
/* Save the link to the chosen node, because it is about to be deleted.*/
28997
init_chosen_link = *link;
28999
/* Remove this node, and allow the tree to go on:*/
29001
OCTAPI_BT0_LINK init_child_link[2];
29003
init_child_link[0] = bb->node[link->node_number].l[0];
29004
init_child_link[1] = bb->node[link->node_number].l[1];
29007
*link = init_child_link[0];
29009
*link = init_child_link[1];
29012
/* Replace the removed node by this node.*/
29014
OCTAPI_BT0_LINK init_removed_child_link[2];
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];
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];
29024
return(GENERIC_OK);
29028
/* Keep on going, we have not found the center most node yet!*/
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);
29034
/* Refresh the link if our link is volatile.*/
29035
if (volatile_grandparent_link != NULL)
29037
link = &(bb->node[volatile_grandparent_link->node_number].l[0]);
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);
29045
/* Refresh the link if our link is volatile.*/
29046
if (volatile_grandparent_link != NULL)
29048
link = &(bb->node[volatile_grandparent_link->node_number].l[1]);
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))
29059
OctApiBt0Rebalance(bb,link);
29062
/* Always update the OCTAPI_BT0_LINK depth before exiting.*/
29063
OctApiBt0UpdateLinkDepth(bb,link);
29065
return(GENERIC_OK);
29068
static UINT32 OctApiBt0QueryNode2(OCTAPI_BT0 * bb,OCTAPI_BT0_LINK * link,UINT32 * lkey,UINT32 * node_number)
29072
if (link->node_number == 0xFFFFFFFF) /* We have an empty node. The node we were looking for does not exist.*/
29074
return(OCTAPI_BT0_KEY_NOT_IN_TREE);
29076
else /* Current node is used, check for a match and a direction.*/
29080
/* Compare this node to the lkey.*/
29081
compare = OctApiBt0KeyCompare(bb,link,lkey);
29083
if (compare == OCTAPI_BT0_LKEY_SMALLER) /* Go left.*/
29085
result = OctApiBt0QueryNode2(bb,&(bb->node[link->node_number].l[0]), lkey, node_number);
29086
if (result != GENERIC_OK) return(result);
29088
else if (compare == OCTAPI_BT0_LKEY_LARGER) /* Go right.*/
29090
result = OctApiBt0QueryNode2(bb,&(bb->node[link->node_number].l[1]), lkey, node_number);
29091
if (result != GENERIC_OK) return(result);
29096
*node_number = link->node_number;
29100
return(GENERIC_OK);
29104
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
29106
File: octapi_largmath.h
29108
Copyright (c) 2001-2005 Octasic Inc.
29112
Library used to perform arithmetic on integer values of an integer multiple
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.
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
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.
29129
$Octasic_Release: OCT612xAPI-01.00-PR38 $
29131
$Octasic_Revision: 10 $
29133
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
29134
#include "apilib/octapi_largmath.h"
29138
* Copyright (C) 2005-2006 Digium, Inc.
29140
* Mark Spencer <markster@digium.com>
29142
* All Rights Reserved
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"
29152
/* API for Octasic access */
29153
static UINT32 Oct6100UserGetTime(tPOCT6100_GET_TIME f_pTime)
29155
/* Why couldn't they just take a timeval like everyone else? */
29157
unsigned long long total_usecs;
29158
unsigned int mask = ~0;
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;
29168
static UINT32 Oct6100UserMemSet(PVOID f_pAddress, UINT32 f_ulPattern, UINT32 f_ulLength)
29170
memset(f_pAddress, f_ulPattern, f_ulLength);
29171
return cOCT6100_ERR_OK;
29174
static UINT32 Oct6100UserMemCopy(PVOID f_pDestination, PVOID f_pSource, UINT32 f_ulLength)
29176
memcpy(f_pDestination, f_pSource, f_ulLength);
29177
return cOCT6100_ERR_OK;
29180
static UINT32 Oct6100UserCreateSerializeObject(tPOCT6100_CREATE_SERIALIZE_OBJECT f_pCreate)
29182
return cOCT6100_ERR_OK;
29185
static UINT32 Oct6100UserDestroySerializeObject(tPOCT6100_DESTROY_SERIALIZE_OBJECT f_pDestroy)
29187
#ifdef OCTASIC_DEBUG
29188
printk("I should never be called! (destroy serialize object)\n");
29190
return cOCT6100_ERR_OK;
29193
static UINT32 Oct6100UserSeizeSerializeObject(tPOCT6100_SEIZE_SERIALIZE_OBJECT f_pSeize)
29196
return cOCT6100_ERR_OK;
29199
static UINT32 Oct6100UserReleaseSerializeObject(tPOCT6100_RELEASE_SERIALIZE_OBJECT f_pRelease)
29202
return cOCT6100_ERR_OK;
29205
static UINT32 Oct6100UserDriverWriteApi(tPOCT6100_WRITE_PARAMS f_pWriteParams)
29207
oct_set_reg(f_pWriteParams->pProcessContext, f_pWriteParams->ulWriteAddress, f_pWriteParams->usWriteData);
29208
return cOCT6100_ERR_OK;
29211
static UINT32 Oct6100UserDriverWriteSmearApi(tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams)
29214
for (x=0;x<f_pSmearParams->ulWriteLength;x++) {
29215
oct_set_reg(f_pSmearParams->pProcessContext, f_pSmearParams->ulWriteAddress + (x << 1), f_pSmearParams->usWriteData);
29217
return cOCT6100_ERR_OK;
29220
static UINT32 Oct6100UserDriverWriteBurstApi(tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams)
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]);
29226
return cOCT6100_ERR_OK;
29229
static UINT32 Oct6100UserDriverReadApi(tPOCT6100_READ_PARAMS f_pReadParams)
29231
*(f_pReadParams->pusReadData) = oct_get_reg(f_pReadParams->pProcessContext, f_pReadParams->ulReadAddress);
29232
return cOCT6100_ERR_OK;
29235
static UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams)
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));
29241
return cOCT6100_ERR_OK;
29244
#ifndef HOTPLUG_FIRMWARE
29245
#include "vpm450m_fw.h"
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
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
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
29289
#define cOCT6100_ECHO_OP_MODE_DIGITAL cOCT6100_ECHO_OP_MODE_HT_FREEZE
29291
#define cOCT6100_ECHO_OP_MODE_DIGITAL cOCT6100_ECHO_OP_MODE_POWER_DOWN
29295
tPOCT6100_INSTANCE_API pApiInstance;
29296
UINT32 aulEchoChanHndl[ 128 ];
29297
int chanflags[128];
29301
#define FLAG_DTMF (1 << 0)
29302
#define FLAG_MUTE (1 << 1)
29303
#define FLAG_ECHO (1 << 2)
29305
static unsigned int tones[] = {
29322
SOUT_G168_1100GB_ON,
29340
ROUT_G168_1100GB_ON,
29343
static void vpm450m_setecmode(struct vpm450m *vpm450m, int channel, int mode)
29345
tOCT6100_CHANNEL_MODIFY modify;
29348
if (vpm450m->ecmode[channel] == mode)
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);
29357
#ifdef OCTASIC_DEBUG
29358
printk("Echo can on channel %d set to %d\n", channel, mode);
29360
vpm450m->ecmode[channel] = mode;
29364
void vpm450m_setdtmf(struct vpm450m *vpm450m, int channel, int detect, int mute)
29366
tOCT6100_CHANNEL_MODIFY modify;
29369
Oct6100ChannelModifyDef(&modify);
29370
modify.ulChannelHndl = vpm450m->aulEchoChanHndl[channel];
29372
vpm450m->chanflags[channel] |= FLAG_MUTE;
29373
modify.VqeConfig.fDtmfToneRemoval = TRUE;
29375
vpm450m->chanflags[channel] &= ~FLAG_MUTE;
29376
modify.VqeConfig.fDtmfToneRemoval = FALSE;
29379
vpm450m->chanflags[channel] |= FLAG_DTMF;
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);
29388
if (!(vpm450m->chanflags[channel] & FLAG_ECHO))
29389
vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_DIGITAL);
29392
ulResult = Oct6100ChannelModify(vpm450m->pApiInstance, &modify);
29393
if (ulResult != GENERIC_OK) {
29394
printk("Failed to apply dtmf mute changes on channel %d!\n", channel);
29396
/* printk("VPM450m: Setting DTMF on channel %d: %s / %s\n", channel, (detect ? "DETECT" : "NO DETECT"), (mute ? "MUTE" : "NO MUTE")); */
29399
void vpm450m_setec(struct vpm450m *vpm450m, int channel, int 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);
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);
29411
vpm450m_setecmode(vpm450m, channel, cOCT6100_ECHO_OP_MODE_DIGITAL);
29413
/* printk("VPM450m: Setting EC on channel %d to %d\n", channel, eclen); */
29416
int vpm450m_checkirq(struct vpm450m *vpm450m)
29418
tOCT6100_INTERRUPT_FLAGS InterruptFlags;
29420
Oct6100InterruptServiceRoutineDef(&InterruptFlags);
29421
Oct6100InterruptServiceRoutine(vpm450m->pApiInstance, &InterruptFlags);
29422
if (InterruptFlags.fToneEventsPending) {
29423
printk("VPM450M: Tone events pending!\n");
29429
int vpm450m_getdtmf(struct vpm450m *vpm450m, int *channel, int *tone, int *start)
29431
tOCT6100_TONE_EVENT tonefound;
29432
tOCT6100_EVENT_GET_TONE tonesearch;
29435
Oct6100EventGetToneDef(&tonesearch);
29436
tonesearch.pToneEvent = &tonefound;
29437
tonesearch.ulMaxToneEvent = 1;
29438
ulResult = Oct6100EventGetTone(vpm450m->pApiInstance, &tonesearch);
29439
if (tonesearch.ulNumValidToneEvent) {
29441
*channel = tonefound.ulUserChanId;
29443
switch(tonefound.ulToneDetected) {
29480
case SOUT_DTMF_STAR:
29486
case SOUT_DTMF_POUND:
29492
case SOUT_G168_1100GB_ON:
29496
printk("Unknown tone value %08x\n", tonefound.ulToneDetected);
29502
*start = (tonefound.ulEventType == cOCT6100_TONE_PRESENT);
29508
#ifdef HOTPLUG_FIRMWARE
29509
struct vpm450m *init_vpm450m(void *wc, int *isalaw, const struct firmware *firmware)
29511
struct vpm450m *init_vpm450m(void *wc, int *isalaw)
29514
tOCT6100_CHIP_OPEN ChipOpen;
29515
tOCT6100_GET_INSTANCE_SIZE InstanceSize;
29516
tOCT6100_CHANNEL_OPEN ChannelOpen;
29518
struct vpm450m *vpm450m;
29521
vpm450m = kmalloc(sizeof(struct vpm450m), GFP_KERNEL);
29524
memset(vpm450m, 0, sizeof(struct vpm450m));
29525
for (x=0;x<128;x++)
29526
vpm450m->ecmode[x] = -1;
29528
Oct6100ChipOpenDef(&ChipOpen);
29530
/* Setup Chip Open Parameters */
29531
ChipOpen.ulUpclkFreq = cOCT6100_UPCLK_FREQ_33_33_MHZ;
29532
Oct6100GetInstanceSizeDef(&InstanceSize);
29534
ChipOpen.pProcessContext = wc;
29535
#ifdef HOTPLUG_FIRMWARE
29536
ChipOpen.pbyImageFile = firmware->data;
29537
ChipOpen.ulImageSize = firmware->size;
29539
ChipOpen.pbyImageFile = vpm450m_fw;
29540
ChipOpen.ulImageSize = sizeof(vpm450m_fw);
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;
29552
ChipOpen.fEnableAcousticEcho = TRUE;
29555
ulResult = Oct6100GetInstanceSize(&ChipOpen, &InstanceSize);
29556
if (ulResult != cOCT6100_ERR_OK) {
29557
printk("Failed to get instance size, code %08x!\n", ulResult);
29563
vpm450m->pApiInstance = vmalloc(InstanceSize.ulApiInstanceSize);
29564
if (!vpm450m->pApiInstance) {
29565
printk("Out of memory (can't allocate %d bytes)!\n", InstanceSize.ulApiInstanceSize);
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);
29578
for (x=0;x<128;x++) {
29579
if (isalaw[x >> 5])
29580
law = cOCT6100_PCM_A_LAW;
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;
29602
ChannelOpen.fEnableToneDisabler = TRUE;
29603
ChannelOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_DIGITAL;
29605
ulResult = Oct6100ChannelOpen(vpm450m->pApiInstance, &ChannelOpen);
29606
if (ulResult != GENERIC_OK) {
29607
printk("Failed to open channel %d!\n", x);
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);
29621
void release_vpm450m(struct vpm450m *vpm450m)
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);
29630
vfree(vpm450m->pApiInstance);