| 1 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 2 |
|
| 3 |
File: oct6100_tone_detection.c |
| 4 |
|
| 5 |
Copyright (c) 2001-2007 Octasic Inc. |
| 6 |
|
| 7 |
Description: |
| 8 |
|
| 9 |
This file contains functions used to enable and disable tone detection on |
| 10 |
an echo channel. |
| 11 |
|
| 12 |
This file is part of the Octasic OCT6100 GPL API . The OCT6100 GPL API is |
| 13 |
free software; you can redistribute it and/or modify it under the terms of |
| 14 |
the GNU General Public License as published by the Free Software Foundation; |
| 15 |
either version 2 of the License, or (at your option) any later version. |
| 16 |
|
| 17 |
The OCT6100 GPL API is distributed in the hope that it will be useful, but |
| 18 |
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 19 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License |
| 23 |
along with the OCT6100 GPL API; if not, write to the Free Software |
| 24 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 25 |
|
| 26 |
$Octasic_Release: OCT612xAPI-01.00-PR49 $ |
| 27 |
|
| 28 |
$Octasic_Revision: 51 $ |
| 29 |
|
| 30 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 31 |
|
| 32 |
|
| 33 |
/***************************** INCLUDE FILES *******************************/ |
| 34 |
|
| 35 |
#include "octdef.h" |
| 36 |
|
| 37 |
#include "oct6100api/oct6100_defines.h" |
| 38 |
#include "oct6100api/oct6100_errors.h" |
| 39 |
#include "oct6100api/oct6100_apiud.h" |
| 40 |
|
| 41 |
#include "apilib/octapi_llman.h" |
| 42 |
|
| 43 |
#include "oct6100api/oct6100_tlv_inst.h" |
| 44 |
#include "oct6100api/oct6100_chip_open_inst.h" |
| 45 |
#include "oct6100api/oct6100_chip_stats_inst.h" |
| 46 |
#include "oct6100api/oct6100_interrupts_inst.h" |
| 47 |
#include "oct6100api/oct6100_remote_debug_inst.h" |
| 48 |
#include "oct6100api/oct6100_debug_inst.h" |
| 49 |
#include "oct6100api/oct6100_api_inst.h" |
| 50 |
#include "oct6100api/oct6100_channel_inst.h" |
| 51 |
#include "oct6100api/oct6100_tone_detection_inst.h" |
| 52 |
#include "oct6100api/oct6100_events_inst.h" |
| 53 |
|
| 54 |
#include "oct6100api/oct6100_interrupts_pub.h" |
| 55 |
#include "oct6100api/oct6100_chip_open_pub.h" |
| 56 |
#include "oct6100api/oct6100_channel_pub.h" |
| 57 |
#include "oct6100api/oct6100_tone_detection_pub.h" |
| 58 |
#include "oct6100api/oct6100_events_pub.h" |
| 59 |
|
| 60 |
#include "oct6100_chip_open_priv.h" |
| 61 |
#include "oct6100_miscellaneous_priv.h" |
| 62 |
#include "oct6100_memory_priv.h" |
| 63 |
#include "oct6100_channel_priv.h" |
| 64 |
#include "oct6100_tone_detection_priv.h" |
| 65 |
#include "oct6100_events_priv.h" |
| 66 |
|
| 67 |
|
| 68 |
/**************************** PUBLIC FUNCTIONS *****************************/ |
| 69 |
|
| 70 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 71 |
|
| 72 |
Function: Oct6100ToneDetectionEnable |
| 73 |
|
| 74 |
Description: This function enables the generation of event for a selected |
| 75 |
tone on the specified channel. |
| 76 |
|
| 77 |
------------------------------------------------------------------------------- |
| 78 |
| Argument | Description |
| 79 |
------------------------------------------------------------------------------- |
| 80 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 81 |
present state of the chip and all its resources. |
| 82 |
|
| 83 |
f_pToneDetectEnable Pointer to tone detection enable structure. |
| 84 |
|
| 85 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 86 |
#if !SKIP_Oct6100ToneDetectionEnableDef |
| 87 |
UINT32 Oct6100ToneDetectionEnableDef( |
| 88 |
tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable ) |
| 89 |
{ |
| 90 |
f_pToneDetectEnable->ulChannelHndl = cOCT6100_INVALID_HANDLE; |
| 91 |
f_pToneDetectEnable->ulToneNumber = cOCT6100_INVALID_TONE; |
| 92 |
|
| 93 |
return cOCT6100_ERR_OK; |
| 94 |
} |
| 95 |
#endif |
| 96 |
|
| 97 |
#if !SKIP_Oct6100ToneDetectionEnable |
| 98 |
UINT32 Oct6100ToneDetectionEnable( |
| 99 |
tPOCT6100_INSTANCE_API f_pApiInstance, |
| 100 |
tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable ) |
| 101 |
{ |
| 102 |
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj; |
| 103 |
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj; |
| 104 |
UINT32 ulSerRes = cOCT6100_ERR_OK; |
| 105 |
UINT32 ulFncRes = cOCT6100_ERR_OK; |
| 106 |
|
| 107 |
/* Set the process context of the serialize structure. */ |
| 108 |
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext; |
| 109 |
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext; |
| 110 |
|
| 111 |
/* Seize all list semaphores needed by this function. */ |
| 112 |
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; |
| 113 |
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY; |
| 114 |
ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj ); |
| 115 |
if ( ulSerRes == cOCT6100_ERR_OK ) |
| 116 |
{ |
| 117 |
/* Call the serialized function. */ |
| 118 |
ulFncRes = Oct6100ToneDetectionEnableSer( f_pApiInstance, f_pToneDetectEnable ); |
| 119 |
} |
| 120 |
else |
| 121 |
{ |
| 122 |
return ulSerRes; |
| 123 |
} |
| 124 |
|
| 125 |
/* Release the seized semaphores. */ |
| 126 |
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; |
| 127 |
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj ); |
| 128 |
|
| 129 |
/* If an error occured then return the error code. */ |
| 130 |
if ( ulSerRes != cOCT6100_ERR_OK ) |
| 131 |
return ulSerRes; |
| 132 |
if ( ulFncRes != cOCT6100_ERR_OK ) |
| 133 |
return ulFncRes; |
| 134 |
|
| 135 |
return cOCT6100_ERR_OK; |
| 136 |
} |
| 137 |
#endif |
| 138 |
|
| 139 |
|
| 140 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 141 |
|
| 142 |
Function: Oct6100ToneDetectionDisable |
| 143 |
|
| 144 |
Description: This function disables the detection of a tone for a specific |
| 145 |
channel. |
| 146 |
|
| 147 |
------------------------------------------------------------------------------- |
| 148 |
| Argument | Description |
| 149 |
------------------------------------------------------------------------------- |
| 150 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 151 |
present state of the chip and all its resources. |
| 152 |
|
| 153 |
f_pToneDetectDisable Pointer to tone detection disable structure. |
| 154 |
|
| 155 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 156 |
#if !SKIP_Oct6100ToneDetectionDisableDef |
| 157 |
UINT32 Oct6100ToneDetectionDisableDef( |
| 158 |
tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable ) |
| 159 |
{ |
| 160 |
f_pToneDetectDisable->ulChannelHndl = cOCT6100_INVALID_HANDLE; |
| 161 |
f_pToneDetectDisable->ulToneNumber = cOCT6100_INVALID_VALUE; |
| 162 |
f_pToneDetectDisable->fDisableAll = FALSE; |
| 163 |
|
| 164 |
return cOCT6100_ERR_OK; |
| 165 |
} |
| 166 |
#endif |
| 167 |
|
| 168 |
|
| 169 |
#if !SKIP_Oct6100ToneDetectionDisable |
| 170 |
UINT32 Oct6100ToneDetectionDisable( |
| 171 |
tPOCT6100_INSTANCE_API f_pApiInstance, |
| 172 |
tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable ) |
| 173 |
{ |
| 174 |
tOCT6100_SEIZE_SERIALIZE_OBJECT SeizeSerObj; |
| 175 |
tOCT6100_RELEASE_SERIALIZE_OBJECT ReleaseSerObj; |
| 176 |
UINT32 ulSerRes = cOCT6100_ERR_OK; |
| 177 |
UINT32 ulFncRes = cOCT6100_ERR_OK; |
| 178 |
|
| 179 |
/* Set the process context of the serialize structure. */ |
| 180 |
SeizeSerObj.pProcessContext = f_pApiInstance->pProcessContext; |
| 181 |
ReleaseSerObj.pProcessContext = f_pApiInstance->pProcessContext; |
| 182 |
|
| 183 |
/* Seize all list semaphores needed by this function. */ |
| 184 |
SeizeSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; |
| 185 |
SeizeSerObj.ulTryTimeMs = cOCT6100_WAIT_INFINITELY; |
| 186 |
ulSerRes = Oct6100UserSeizeSerializeObject( &SeizeSerObj ); |
| 187 |
if ( ulSerRes == cOCT6100_ERR_OK ) |
| 188 |
{ |
| 189 |
/* Call the serialized function. */ |
| 190 |
ulFncRes = Oct6100ToneDetectionDisableSer( f_pApiInstance, f_pToneDetectDisable ); |
| 191 |
} |
| 192 |
else |
| 193 |
{ |
| 194 |
return ulSerRes; |
| 195 |
} |
| 196 |
|
| 197 |
/* Release the seized semaphores. */ |
| 198 |
ReleaseSerObj.ulSerialObjHndl = f_pApiInstance->ulApiSerObj; |
| 199 |
ulSerRes = Oct6100UserReleaseSerializeObject( &ReleaseSerObj ); |
| 200 |
|
| 201 |
/* If an error occured then return the error code. */ |
| 202 |
if ( ulSerRes != cOCT6100_ERR_OK ) |
| 203 |
return ulSerRes; |
| 204 |
if ( ulFncRes != cOCT6100_ERR_OK ) |
| 205 |
return ulFncRes; |
| 206 |
|
| 207 |
return cOCT6100_ERR_OK; |
| 208 |
} |
| 209 |
#endif |
| 210 |
|
| 211 |
|
| 212 |
/**************************** PRIVATE FUNCTIONS ****************************/ |
| 213 |
|
| 214 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 215 |
|
| 216 |
Function: Oct6100ToneDetectionEnableSer |
| 217 |
|
| 218 |
Description: Activate the detection of a tone on the specified channel. |
| 219 |
|
| 220 |
------------------------------------------------------------------------------- |
| 221 |
| Argument | Description |
| 222 |
------------------------------------------------------------------------------- |
| 223 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 224 |
present state of the chip and all its resources. |
| 225 |
|
| 226 |
f_pToneDetectEnable Pointer to tone detect enable structure. This structure |
| 227 |
contains, among other things, the tone ID to enable |
| 228 |
and the channel handle where detection should be |
| 229 |
enabled. |
| 230 |
|
| 231 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 232 |
#if !SKIP_Oct6100ToneDetectionEnableSer |
| 233 |
UINT32 Oct6100ToneDetectionEnableSer( |
| 234 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 235 |
IN tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable ) |
| 236 |
{ |
| 237 |
UINT32 ulChanIndex; |
| 238 |
UINT32 ulExtToneChanIndex; |
| 239 |
UINT32 ulToneEventNumber = 0; |
| 240 |
|
| 241 |
UINT32 ulResult; |
| 242 |
|
| 243 |
/* Check the user's configuration of the tone detection for errors. */ |
| 244 |
ulResult = Oct6100ApiCheckToneEnableParams( |
| 245 |
f_pApiInstance, |
| 246 |
f_pToneDetectEnable, |
| 247 |
&ulChanIndex, |
| 248 |
&ulToneEventNumber, |
| 249 |
|
| 250 |
&ulExtToneChanIndex ); |
| 251 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 252 |
return ulResult; |
| 253 |
|
| 254 |
/* Write to all resources needed to enable tone detection. */ |
| 255 |
ulResult = Oct6100ApiWriteToneDetectEvent( |
| 256 |
f_pApiInstance, |
| 257 |
ulChanIndex, |
| 258 |
ulToneEventNumber, |
| 259 |
|
| 260 |
ulExtToneChanIndex ); |
| 261 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 262 |
return ulResult; |
| 263 |
|
| 264 |
/* Update the channel entry to indicate that a new tone has been activated. */ |
| 265 |
ulResult = Oct6100ApiUpdateChanToneDetectEntry( |
| 266 |
f_pApiInstance, |
| 267 |
ulChanIndex, |
| 268 |
ulToneEventNumber, |
| 269 |
ulExtToneChanIndex ); |
| 270 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 271 |
return ulResult; |
| 272 |
|
| 273 |
return cOCT6100_ERR_OK; |
| 274 |
} |
| 275 |
#endif |
| 276 |
|
| 277 |
|
| 278 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 279 |
|
| 280 |
Function: Oct6100ApiCheckToneEnableParams |
| 281 |
|
| 282 |
Description: Check the validity of the channel and tone requested. |
| 283 |
|
| 284 |
------------------------------------------------------------------------------- |
| 285 |
| Argument | Description |
| 286 |
------------------------------------------------------------------------------- |
| 287 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 288 |
present state of the chip and all its resources. |
| 289 |
|
| 290 |
f_pToneDetectEnable Pointer to tone detection enable structure. |
| 291 |
f_pulChannelIndex Pointer to the channel index. |
| 292 |
f_pulToneEventNumber Pointer to the Index of the tone associated to the requested tone. |
| 293 |
f_pulExtToneChanIndex Pointer to the index of the extended channel index. |
| 294 |
|
| 295 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 296 |
#if !SKIP_Oct6100ApiCheckToneEnableParams |
| 297 |
UINT32 Oct6100ApiCheckToneEnableParams( |
| 298 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 299 |
IN tPOCT6100_TONE_DETECTION_ENABLE f_pToneDetectEnable, |
| 300 |
OUT PUINT32 f_pulChannelIndex, |
| 301 |
OUT PUINT32 f_pulToneEventNumber, |
| 302 |
|
| 303 |
OUT PUINT32 f_pulExtToneChanIndex ) |
| 304 |
{ |
| 305 |
tPOCT6100_API_CHANNEL pEchoChannel; |
| 306 |
UINT32 ulEntryOpenCnt; |
| 307 |
UINT32 i; |
| 308 |
|
| 309 |
/*=====================================================================*/ |
| 310 |
/* Check the channel handle. */ |
| 311 |
|
| 312 |
if ( (f_pToneDetectEnable->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL ) |
| 313 |
return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; |
| 314 |
|
| 315 |
*f_pulChannelIndex = f_pToneDetectEnable->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK; |
| 316 |
if ( *f_pulChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels ) |
| 317 |
return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; |
| 318 |
|
| 319 |
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex ) |
| 320 |
|
| 321 |
/* Extract the entry open count from the provided handle. */ |
| 322 |
ulEntryOpenCnt = (f_pToneDetectEnable->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; |
| 323 |
|
| 324 |
/* Check for errors. */ |
| 325 |
if ( pEchoChannel->fReserved != TRUE ) |
| 326 |
return cOCT6100_ERR_TONE_DETECTION_CHANNEL_NOT_OPEN; |
| 327 |
if ( ulEntryOpenCnt != pEchoChannel->byEntryOpenCnt ) |
| 328 |
return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; |
| 329 |
|
| 330 |
/* Set the extended tone detection info if it is activated on the channel. */ |
| 331 |
*f_pulExtToneChanIndex = pEchoChannel->usExtToneChanIndex; |
| 332 |
|
| 333 |
/*=====================================================================*/ |
| 334 |
/* Check the tone information. */ |
| 335 |
|
| 336 |
/* Find out if the tone is present in the build. */ |
| 337 |
for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ ) |
| 338 |
{ |
| 339 |
if ( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ i ].ulToneID == f_pToneDetectEnable->ulToneNumber ) |
| 340 |
{ |
| 341 |
*f_pulToneEventNumber = i; |
| 342 |
break; |
| 343 |
} |
| 344 |
} |
| 345 |
|
| 346 |
/* Check if tone is present. */ |
| 347 |
if ( i == cOCT6100_MAX_TONE_EVENT ) |
| 348 |
return cOCT6100_ERR_NOT_SUPPORTED_TONE_NOT_PRESENT_IN_FIRMWARE; |
| 349 |
|
| 350 |
/* Check if the requested tone is actually detected. */ |
| 351 |
if ((( pEchoChannel->aulToneConf[ *f_pulToneEventNumber / 32 ] >> ( 31 - ( *f_pulToneEventNumber % 32 ))) & 0x1) == 1 ) |
| 352 |
return cOCT6100_ERR_TONE_DETECTION_TONE_ACTIVATED; |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
/*=====================================================================*/ |
| 357 |
|
| 358 |
return cOCT6100_ERR_OK; |
| 359 |
} |
| 360 |
#endif |
| 361 |
|
| 362 |
|
| 363 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 364 |
|
| 365 |
Function: Oct6100ApiWriteToneDetectEvent |
| 366 |
|
| 367 |
Description: Write the tone detection event in the channel main structure. |
| 368 |
|
| 369 |
------------------------------------------------------------------------------- |
| 370 |
| Argument | Description |
| 371 |
------------------------------------------------------------------------------- |
| 372 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 373 |
present state of the chip and all its resources. |
| 374 |
|
| 375 |
f_ulChannelIndex Index of the channel within the API's channel list. |
| 376 |
f_ulToneEventNumber Event number of the tone to be activated. |
| 377 |
f_ulExtToneChanIndex Index of the extended tone detection channel. |
| 378 |
|
| 379 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 380 |
#if !SKIP_Oct6100ApiWriteToneDetectEvent |
| 381 |
UINT32 Oct6100ApiWriteToneDetectEvent( |
| 382 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 383 |
IN UINT32 f_ulChannelIndex, |
| 384 |
IN UINT32 f_ulToneEventNumber, |
| 385 |
|
| 386 |
IN UINT32 f_ulExtToneChanIndex ) |
| 387 |
{ |
| 388 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 389 |
tOCT6100_WRITE_PARAMS WriteParams; |
| 390 |
tOCT6100_READ_PARAMS ReadParams; |
| 391 |
UINT32 ulResult; |
| 392 |
UINT16 usReadData; |
| 393 |
|
| 394 |
/* Obtain local pointer to shared portion of instance. */ |
| 395 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
ReadParams.pProcessContext = f_pApiInstance->pProcessContext; |
| 400 |
|
| 401 |
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; |
| 402 |
ReadParams.pusReadData = &usReadData; |
| 403 |
|
| 404 |
WriteParams.pProcessContext = f_pApiInstance->pProcessContext; |
| 405 |
|
| 406 |
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; |
| 407 |
|
| 408 |
/*=======================================================================*/ |
| 409 |
/* Read the current event config about to be modified. */ |
| 410 |
|
| 411 |
ReadParams.ulReadAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulChannelIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ); |
| 412 |
ReadParams.ulReadAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET; |
| 413 |
ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2; |
| 414 |
|
| 415 |
mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); |
| 416 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 417 |
return ulResult; |
| 418 |
|
| 419 |
/*=======================================================================*/ |
| 420 |
/* Set the tone event in the channel main memory for the requested direction. */ |
| 421 |
|
| 422 |
WriteParams.ulWriteAddress = ReadParams.ulReadAddress; |
| 423 |
WriteParams.usWriteData = usReadData; |
| 424 |
WriteParams.usWriteData |= ( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 ))); |
| 425 |
|
| 426 |
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); |
| 427 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 428 |
return ulResult; |
| 429 |
|
| 430 |
/*=======================================================================*/ |
| 431 |
/* Also program the extended channel if one is present. */ |
| 432 |
|
| 433 |
if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX ) |
| 434 |
{ |
| 435 |
/* Read the current event config about to be modified. */ |
| 436 |
ReadParams.ulReadAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ); |
| 437 |
ReadParams.ulReadAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET; |
| 438 |
ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2; |
| 439 |
|
| 440 |
mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); |
| 441 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 442 |
return ulResult; |
| 443 |
|
| 444 |
/* Write the tone event in the channel main memory for the requested direction. */ |
| 445 |
WriteParams.ulWriteAddress = ReadParams.ulReadAddress; |
| 446 |
WriteParams.usWriteData = usReadData; |
| 447 |
WriteParams.usWriteData |= ( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 ))); |
| 448 |
|
| 449 |
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); |
| 450 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 451 |
return ulResult; |
| 452 |
} |
| 453 |
|
| 454 |
/*=======================================================================*/ |
| 455 |
|
| 456 |
return cOCT6100_ERR_OK; |
| 457 |
} |
| 458 |
#endif |
| 459 |
|
| 460 |
|
| 461 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 462 |
|
| 463 |
Function: Oct6100ApiUpdateChanToneDetectEntry |
| 464 |
|
| 465 |
Description: Update the echo channel entry to store the info about the tone |
| 466 |
being configured to generate detection events. |
| 467 |
|
| 468 |
------------------------------------------------------------------------------- |
| 469 |
| Argument | Description |
| 470 |
------------------------------------------------------------------------------- |
| 471 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 472 |
present state of the chip and all its resources. |
| 473 |
|
| 474 |
f_ulChannelIndex Index of the channel within the API's channel list. |
| 475 |
f_ulToneEventNumber Enabled tone event number. |
| 476 |
f_ulExtToneChanIndex Index of the extended tone detection channel. |
| 477 |
|
| 478 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 479 |
#if !SKIP_Oct6100ApiUpdateChanToneDetectEntry |
| 480 |
UINT32 Oct6100ApiUpdateChanToneDetectEntry ( |
| 481 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 482 |
IN UINT32 f_ulChannelIndex, |
| 483 |
IN UINT32 f_ulToneEventNumber, |
| 484 |
IN UINT32 f_ulExtToneChanIndex ) |
| 485 |
{ |
| 486 |
tPOCT6100_API_CHANNEL pEchoChanEntry; |
| 487 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 488 |
UINT32 ulToneEntry; |
| 489 |
|
| 490 |
/* Obtain local pointer to shared portion of instance. */ |
| 491 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 492 |
|
| 493 |
/* Update the channel entry. */ |
| 494 |
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulChannelIndex ); |
| 495 |
|
| 496 |
/* Set the corresponding bit in the channel array. */ |
| 497 |
ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ]; |
| 498 |
|
| 499 |
/* Modify the entry. */ |
| 500 |
ulToneEntry |= ( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 ))); |
| 501 |
|
| 502 |
/* Copy back the new value. */ |
| 503 |
pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry; |
| 504 |
|
| 505 |
/* Configure also the extended channel if necessary. */ |
| 506 |
if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX ) |
| 507 |
{ |
| 508 |
/* Update the channel entry. */ |
| 509 |
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulExtToneChanIndex ); |
| 510 |
|
| 511 |
/* Set the corresponding bit in the channel array. */ |
| 512 |
ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ]; |
| 513 |
|
| 514 |
/* Modify the entry. */ |
| 515 |
ulToneEntry |= ( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 ))); |
| 516 |
|
| 517 |
/* Copy back the new value. */ |
| 518 |
pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry; |
| 519 |
} |
| 520 |
|
| 521 |
/* Check for the SS tone events that could have been generated before. */ |
| 522 |
if ( f_ulExtToneChanIndex == cOCT6100_INVALID_INDEX ) |
| 523 |
{ |
| 524 |
BOOL fSSTone; |
| 525 |
UINT32 ulResult; |
| 526 |
|
| 527 |
ulResult = Oct6100ApiIsSSTone( f_pApiInstance, pSharedInfo->ImageInfo.aToneInfo[ f_ulToneEventNumber ].ulToneID, &fSSTone ); |
| 528 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 529 |
return ulResult; |
| 530 |
|
| 531 |
/* Is this a signaling system tone? */ |
| 532 |
if ( fSSTone == TRUE ) |
| 533 |
{ |
| 534 |
/* Check if must generate an event for the last detected SS tone. */ |
| 535 |
if ( ( pEchoChanEntry->ulLastSSToneDetected != cOCT6100_INVALID_INDEX ) |
| 536 |
&& ( pEchoChanEntry->ulLastSSToneDetected == pSharedInfo->ImageInfo.aToneInfo[ f_ulToneEventNumber ].ulToneID ) ) |
| 537 |
{ |
| 538 |
/* Must write an event for this. */ |
| 539 |
tPOCT6100_API_TONE_EVENT pSoftEvent; |
| 540 |
|
| 541 |
/* If enough space. */ |
| 542 |
if ( ( ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1 ) != pSharedInfo->SoftBufs.ulToneEventBufferReadPtr ) && |
| 543 |
( ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr + 1 ) != pSharedInfo->SoftBufs.ulToneEventBufferSize || pSharedInfo->SoftBufs.ulToneEventBufferReadPtr != 0 ) ) |
| 544 |
{ |
| 545 |
/* Form the event for this captured tone. */ |
| 546 |
mOCT6100_GET_TONE_EVENT_BUF_PNT( pSharedInfo, pSoftEvent ) |
| 547 |
pSoftEvent += pSharedInfo->SoftBufs.ulToneEventBufferWritePtr; |
| 548 |
|
| 549 |
pSoftEvent->ulChannelHandle = cOCT6100_HNDL_TAG_CHANNEL | (pEchoChanEntry->byEntryOpenCnt << cOCT6100_ENTRY_OPEN_CNT_SHIFT) | f_ulChannelIndex; |
| 550 |
pSoftEvent->ulUserChanId = pEchoChanEntry->ulUserChanId; |
| 551 |
pSoftEvent->ulToneDetected = pSharedInfo->ImageInfo.aToneInfo[ f_ulToneEventNumber ].ulToneID; |
| 552 |
pSoftEvent->ulTimestamp = pEchoChanEntry->ulLastSSToneTimestamp; |
| 553 |
pSoftEvent->ulExtToneDetectionPort = cOCT6100_INVALID_VALUE; |
| 554 |
pSoftEvent->ulEventType = cOCT6100_TONE_PRESENT; |
| 555 |
|
| 556 |
/* Update the control variables of the buffer. */ |
| 557 |
pSharedInfo->SoftBufs.ulToneEventBufferWritePtr++; |
| 558 |
if ( pSharedInfo->SoftBufs.ulToneEventBufferWritePtr == pSharedInfo->SoftBufs.ulToneEventBufferSize ) |
| 559 |
pSharedInfo->SoftBufs.ulToneEventBufferWritePtr = 0; |
| 560 |
|
| 561 |
/* Set the interrupt manager such that the user knows that some tone events */ |
| 562 |
/* are pending in the software Q. */ |
| 563 |
pSharedInfo->IntrptManage.fToneEventsPending = TRUE; |
| 564 |
} |
| 565 |
else |
| 566 |
{ |
| 567 |
/* Set the overflow flag of the buffer. */ |
| 568 |
pSharedInfo->SoftBufs.ulToneEventBufferOverflowCnt++; |
| 569 |
} |
| 570 |
} |
| 571 |
} |
| 572 |
} |
| 573 |
|
| 574 |
return cOCT6100_ERR_OK; |
| 575 |
} |
| 576 |
#endif |
| 577 |
|
| 578 |
|
| 579 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 580 |
|
| 581 |
Function: Oct6100ToneDetectionDisableSer |
| 582 |
|
| 583 |
Description: Disable the generation of events for a selected tone on the |
| 584 |
specified channel. |
| 585 |
|
| 586 |
------------------------------------------------------------------------------- |
| 587 |
| Argument | Description |
| 588 |
------------------------------------------------------------------------------- |
| 589 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 590 |
present state of the chip and all its resources. |
| 591 |
|
| 592 |
f_pToneDetectDisable Pointer to tOCT6100_TONE_DETECTION_DISABLE structure. |
| 593 |
|
| 594 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 595 |
#if !SKIP_Oct6100ToneDetectionDisableSer |
| 596 |
UINT32 Oct6100ToneDetectionDisableSer( |
| 597 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 598 |
IN tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable ) |
| 599 |
{ |
| 600 |
UINT32 ulChanIndex; |
| 601 |
UINT32 ulExtToneChanIndex; |
| 602 |
UINT32 ulToneEventNumber = 0; |
| 603 |
UINT32 ulResult; |
| 604 |
BOOL fDisableAll; |
| 605 |
|
| 606 |
|
| 607 |
/* Check the user's configuration of the tone detection disable structure for errors. */ |
| 608 |
ulResult = Oct6100ApiAssertToneDetectionParams( |
| 609 |
f_pApiInstance, |
| 610 |
f_pToneDetectDisable, |
| 611 |
&ulChanIndex, |
| 612 |
&ulToneEventNumber, |
| 613 |
&ulExtToneChanIndex, |
| 614 |
|
| 615 |
&fDisableAll ); |
| 616 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 617 |
return ulResult; |
| 618 |
|
| 619 |
/* Clear the event to detect the specified tone. */ |
| 620 |
ulResult = Oct6100ApiClearToneDetectionEvent( |
| 621 |
f_pApiInstance, |
| 622 |
ulChanIndex, |
| 623 |
ulToneEventNumber, |
| 624 |
ulExtToneChanIndex, |
| 625 |
|
| 626 |
fDisableAll ); |
| 627 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 628 |
return ulResult; |
| 629 |
|
| 630 |
/* Update the channel structure to indicate that the tone is no longer detected. */ |
| 631 |
ulResult = Oct6100ApiReleaseToneDetectionEvent( |
| 632 |
f_pApiInstance, |
| 633 |
ulChanIndex, |
| 634 |
ulToneEventNumber, |
| 635 |
ulExtToneChanIndex, |
| 636 |
fDisableAll ); |
| 637 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 638 |
return ulResult; |
| 639 |
|
| 640 |
return cOCT6100_ERR_OK; |
| 641 |
} |
| 642 |
#endif |
| 643 |
|
| 644 |
|
| 645 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 646 |
|
| 647 |
Function: Oct6100ApiAssertToneDetectionParams |
| 648 |
|
| 649 |
Description: Check the validity of the tone detection disable command. |
| 650 |
|
| 651 |
------------------------------------------------------------------------------- |
| 652 |
| Argument | Description |
| 653 |
------------------------------------------------------------------------------- |
| 654 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 655 |
present state of the chip and all its resources. |
| 656 |
|
| 657 |
f_pToneDetectDisable Pointer to tone detection disable structure. |
| 658 |
f_pulChannelIndex Pointer to the channel index |
| 659 |
f_pulToneEventNumber Pointer to the tone event number. |
| 660 |
f_pulExtToneChanIndex Pointer to the extended channel index. |
| 661 |
f_pfDisableAll Pointer to the flag specifying whether all tones |
| 662 |
should be disabled. |
| 663 |
|
| 664 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 665 |
#if !SKIP_Oct6100ApiAssertToneDetectionParams |
| 666 |
UINT32 Oct6100ApiAssertToneDetectionParams( |
| 667 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 668 |
IN tPOCT6100_TONE_DETECTION_DISABLE f_pToneDetectDisable, |
| 669 |
OUT PUINT32 f_pulChannelIndex, |
| 670 |
OUT PUINT32 f_pulToneEventNumber, |
| 671 |
OUT PUINT32 f_pulExtToneChanIndex, |
| 672 |
|
| 673 |
OUT PBOOL f_pfDisableAll ) |
| 674 |
{ |
| 675 |
tPOCT6100_API_CHANNEL pEchoChannel; |
| 676 |
UINT32 ulEntryOpenCnt; |
| 677 |
UINT32 i; |
| 678 |
|
| 679 |
/*=====================================================================*/ |
| 680 |
/* Check the echo channel handle. */ |
| 681 |
|
| 682 |
if ( (f_pToneDetectDisable->ulChannelHndl & cOCT6100_HNDL_TAG_MASK) != cOCT6100_HNDL_TAG_CHANNEL ) |
| 683 |
return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; |
| 684 |
|
| 685 |
*f_pulChannelIndex = f_pToneDetectDisable->ulChannelHndl & cOCT6100_HNDL_INDEX_MASK; |
| 686 |
if ( *f_pulChannelIndex >= f_pApiInstance->pSharedInfo->ChipConfig.usMaxChannels ) |
| 687 |
return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; |
| 688 |
|
| 689 |
mOCT6100_GET_CHANNEL_ENTRY_PNT( f_pApiInstance->pSharedInfo, pEchoChannel, *f_pulChannelIndex ) |
| 690 |
|
| 691 |
/* Extract the entry open count from the provided handle. */ |
| 692 |
ulEntryOpenCnt = (f_pToneDetectDisable->ulChannelHndl >> cOCT6100_ENTRY_OPEN_CNT_SHIFT) & cOCT6100_ENTRY_OPEN_CNT_MASK; |
| 693 |
|
| 694 |
/* Check for errors. */ |
| 695 |
if ( pEchoChannel->fReserved != TRUE ) |
| 696 |
return cOCT6100_ERR_TONE_DETECTION_CHANNEL_NOT_OPEN; |
| 697 |
if ( ulEntryOpenCnt != pEchoChannel->byEntryOpenCnt ) |
| 698 |
return cOCT6100_ERR_TONE_DETECTION_CHANNEL_HANDLE_INVALID; |
| 699 |
|
| 700 |
/* Return the extended channel index. */ |
| 701 |
*f_pulExtToneChanIndex = pEchoChannel->usExtToneChanIndex; |
| 702 |
|
| 703 |
/* Check the disable all flag. */ |
| 704 |
if ( f_pToneDetectDisable->fDisableAll != TRUE && f_pToneDetectDisable->fDisableAll != FALSE ) |
| 705 |
return cOCT6100_ERR_TONE_DETECTION_DISABLE_ALL; |
| 706 |
|
| 707 |
/*=====================================================================*/ |
| 708 |
/* Check the tone information. */ |
| 709 |
|
| 710 |
/* Find out if the tone is present in the build. */ |
| 711 |
if ( f_pToneDetectDisable->fDisableAll == FALSE ) |
| 712 |
{ |
| 713 |
for ( i = 0; i < cOCT6100_MAX_TONE_EVENT; i++ ) |
| 714 |
{ |
| 715 |
if ( f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ i ].ulToneID == f_pToneDetectDisable->ulToneNumber ) |
| 716 |
{ |
| 717 |
*f_pulToneEventNumber = i; |
| 718 |
break; |
| 719 |
} |
| 720 |
} |
| 721 |
|
| 722 |
/* Check if tone is present. */ |
| 723 |
if ( i == cOCT6100_MAX_TONE_EVENT ) |
| 724 |
return cOCT6100_ERR_NOT_SUPPORTED_TONE_NOT_PRESENT_IN_FIRMWARE; |
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
/* Check if the requested tone is actually detected. */ |
| 729 |
if ((( pEchoChannel->aulToneConf[ *f_pulToneEventNumber / 32 ] >> ( 31 - ( *f_pulToneEventNumber % 32 ))) & 0x1) == 0 ) |
| 730 |
return cOCT6100_ERR_TONE_DETECTION_TONE_NOT_ACTIVATED; |
| 731 |
} |
| 732 |
|
| 733 |
|
| 734 |
/*=====================================================================*/ |
| 735 |
|
| 736 |
/* Return the disable all flag as requested. */ |
| 737 |
*f_pfDisableAll = f_pToneDetectDisable->fDisableAll; |
| 738 |
|
| 739 |
return cOCT6100_ERR_OK; |
| 740 |
} |
| 741 |
#endif |
| 742 |
|
| 743 |
|
| 744 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 745 |
|
| 746 |
Function: Oct6100ApiClearToneDetectionEvent |
| 747 |
|
| 748 |
Description: Clear the buffer playout event in the channel main structure. |
| 749 |
|
| 750 |
------------------------------------------------------------------------------- |
| 751 |
| Argument | Description |
| 752 |
------------------------------------------------------------------------------- |
| 753 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 754 |
present state of the chip and all its resources. |
| 755 |
|
| 756 |
f_ulChannelIndex Index of the channel within the API's channel list. |
| 757 |
f_ulToneEventNumber Tone event number to be deactivated. |
| 758 |
f_ulExtToneChanIndex Index of the extended tone detection channel. |
| 759 |
f_fDisableAll Clear all activated tones. |
| 760 |
|
| 761 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 762 |
#if !SKIP_Oct6100ApiClearToneDetectionEvent |
| 763 |
UINT32 Oct6100ApiClearToneDetectionEvent( |
| 764 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 765 |
IN UINT32 f_ulChannelIndex, |
| 766 |
IN UINT32 f_ulToneEventNumber, |
| 767 |
IN UINT32 f_ulExtToneChanIndex, |
| 768 |
|
| 769 |
IN BOOL f_fDisableAll ) |
| 770 |
{ |
| 771 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 772 |
tOCT6100_WRITE_PARAMS WriteParams; |
| 773 |
tOCT6100_READ_PARAMS ReadParams; |
| 774 |
tOCT6100_WRITE_SMEAR_PARAMS SmearParams; |
| 775 |
UINT32 ulResult; |
| 776 |
UINT32 ulToneEventBaseAddress; |
| 777 |
UINT16 usReadData; |
| 778 |
|
| 779 |
/* Obtain local pointer to shared portion of instance. */ |
| 780 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
ReadParams.pProcessContext = f_pApiInstance->pProcessContext; |
| 785 |
|
| 786 |
ReadParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; |
| 787 |
ReadParams.pusReadData = &usReadData; |
| 788 |
|
| 789 |
WriteParams.pProcessContext = f_pApiInstance->pProcessContext; |
| 790 |
|
| 791 |
WriteParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; |
| 792 |
|
| 793 |
SmearParams.pProcessContext = f_pApiInstance->pProcessContext; |
| 794 |
|
| 795 |
SmearParams.ulUserChipId = pSharedInfo->ChipConfig.ulUserChipId; |
| 796 |
|
| 797 |
/*=======================================================================*/ |
| 798 |
/* Read the current event config about to be modified. */ |
| 799 |
|
| 800 |
ulToneEventBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulChannelIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ); |
| 801 |
ulToneEventBaseAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET; |
| 802 |
|
| 803 |
/* Check if must disable all tone events or not. */ |
| 804 |
if ( f_fDisableAll == FALSE ) |
| 805 |
{ |
| 806 |
ReadParams.ulReadAddress = ulToneEventBaseAddress; |
| 807 |
ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2; |
| 808 |
|
| 809 |
mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); |
| 810 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 811 |
return ulResult; |
| 812 |
|
| 813 |
/* Clear the event in the channel main memory.*/ |
| 814 |
WriteParams.ulWriteAddress = ReadParams.ulReadAddress; |
| 815 |
WriteParams.usWriteData = usReadData; |
| 816 |
WriteParams.usWriteData &= (~( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 )))); |
| 817 |
|
| 818 |
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); |
| 819 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 820 |
return ulResult; |
| 821 |
} |
| 822 |
else /* if ( f_fDisableAll == TRUE ) */ |
| 823 |
{ |
| 824 |
/* Clear all events in the channel main memory. */ |
| 825 |
SmearParams.ulWriteLength = 4; |
| 826 |
SmearParams.usWriteData = 0x0000; |
| 827 |
SmearParams.ulWriteAddress = ulToneEventBaseAddress; |
| 828 |
mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult ); |
| 829 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 830 |
return ulResult; |
| 831 |
} |
| 832 |
|
| 833 |
/*=======================================================================*/ |
| 834 |
/* Also program the extended channel if one is present. */ |
| 835 |
|
| 836 |
if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX ) |
| 837 |
{ |
| 838 |
ulToneEventBaseAddress = pSharedInfo->MemoryMap.ulChanMainMemBase + ( f_ulExtToneChanIndex * pSharedInfo->MemoryMap.ulChanMainMemSize ); |
| 839 |
ulToneEventBaseAddress += cOCT6100_CH_MAIN_TONE_EVENT_OFFSET; |
| 840 |
|
| 841 |
/* Check if must disable all tone events or not. */ |
| 842 |
if ( f_fDisableAll == FALSE ) |
| 843 |
{ |
| 844 |
/* Read the current event config about to be modified. */ |
| 845 |
ReadParams.ulReadAddress = ulToneEventBaseAddress; |
| 846 |
ReadParams.ulReadAddress += (f_ulToneEventNumber / 16) * 2; |
| 847 |
|
| 848 |
mOCT6100_DRIVER_READ_API( ReadParams, ulResult ); |
| 849 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 850 |
return ulResult; |
| 851 |
|
| 852 |
/* Clear the event in the channel main memory.*/ |
| 853 |
WriteParams.ulWriteAddress = ReadParams.ulReadAddress; |
| 854 |
WriteParams.usWriteData = usReadData; |
| 855 |
WriteParams.usWriteData &= (~( 0x1 << ( 15 - ( f_ulToneEventNumber % 16 )))); |
| 856 |
|
| 857 |
mOCT6100_DRIVER_WRITE_API( WriteParams, ulResult ); |
| 858 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 859 |
return ulResult; |
| 860 |
} |
| 861 |
else /* if ( f_fDisableAll == TRUE ) */ |
| 862 |
{ |
| 863 |
/* Clear all events in the channel main memory.*/ |
| 864 |
SmearParams.ulWriteLength = 4; |
| 865 |
SmearParams.usWriteData = 0x0000; |
| 866 |
SmearParams.ulWriteAddress = ulToneEventBaseAddress; |
| 867 |
mOCT6100_DRIVER_WRITE_SMEAR_API( SmearParams, ulResult ); |
| 868 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 869 |
return ulResult; |
| 870 |
} |
| 871 |
} |
| 872 |
|
| 873 |
return cOCT6100_ERR_OK; |
| 874 |
} |
| 875 |
#endif |
| 876 |
|
| 877 |
|
| 878 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 879 |
|
| 880 |
Function: Oct6100ApiReleaseToneDetectionEvent |
| 881 |
|
| 882 |
Description: Clear the entry made for this tone in the channel tone |
| 883 |
enable array. |
| 884 |
|
| 885 |
------------------------------------------------------------------------------- |
| 886 |
| Argument | Description |
| 887 |
------------------------------------------------------------------------------- |
| 888 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 889 |
present state of the chip and all its resources. |
| 890 |
|
| 891 |
f_ulChannelIndex Index of the channel within the API's channel list. |
| 892 |
f_ulToneEventNumber Tone event number to be deactivated. |
| 893 |
f_ulExtToneChanIndex Index of the extended tone detection channel. |
| 894 |
f_fDisableAll Release all activated tones. |
| 895 |
|
| 896 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 897 |
#if !SKIP_Oct6100ApiReleaseToneDetectionEvent |
| 898 |
UINT32 Oct6100ApiReleaseToneDetectionEvent ( |
| 899 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 900 |
IN UINT32 f_ulChannelIndex, |
| 901 |
IN UINT32 f_ulToneEventNumber, |
| 902 |
IN UINT32 f_ulExtToneChanIndex, |
| 903 |
IN BOOL f_fDisableAll ) |
| 904 |
{ |
| 905 |
tPOCT6100_API_CHANNEL pEchoChanEntry; |
| 906 |
tPOCT6100_SHARED_INFO pSharedInfo; |
| 907 |
UINT32 ulToneEntry; |
| 908 |
UINT32 ulResult; |
| 909 |
UINT32 ulToneEventNumber; |
| 910 |
BOOL fSSTone; |
| 911 |
|
| 912 |
/* Obtain local pointer to shared portion of instance. */ |
| 913 |
pSharedInfo = f_pApiInstance->pSharedInfo; |
| 914 |
|
| 915 |
/* Update the channel entry. */ |
| 916 |
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulChannelIndex ); |
| 917 |
|
| 918 |
/* Check if must release all tone events. */ |
| 919 |
if ( f_fDisableAll == FALSE ) |
| 920 |
{ |
| 921 |
/* Set the corresponding bit in the channel array. */ |
| 922 |
ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ]; |
| 923 |
|
| 924 |
/* Modify the entry. */ |
| 925 |
ulToneEntry &= (~( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 )))); |
| 926 |
|
| 927 |
/* Copy back the new value. */ |
| 928 |
pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry; |
| 929 |
} |
| 930 |
else /* if ( f_fDisableAll == TRUE ) */ |
| 931 |
{ |
| 932 |
/* Clear all events. */ |
| 933 |
Oct6100UserMemSet( pEchoChanEntry->aulToneConf, 0x00, sizeof( pEchoChanEntry->aulToneConf ) ); |
| 934 |
} |
| 935 |
|
| 936 |
/* Configure also the extended channel if necessary. */ |
| 937 |
if ( f_ulExtToneChanIndex != cOCT6100_INVALID_INDEX ) |
| 938 |
{ |
| 939 |
/* Update the channel entry. */ |
| 940 |
mOCT6100_GET_CHANNEL_ENTRY_PNT( pSharedInfo, pEchoChanEntry, f_ulExtToneChanIndex ); |
| 941 |
|
| 942 |
/* Check if must release all tone events. */ |
| 943 |
if ( f_fDisableAll == FALSE ) |
| 944 |
{ |
| 945 |
/* Set the corresponding bit in the channel array. */ |
| 946 |
ulToneEntry = pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ]; |
| 947 |
|
| 948 |
/* Modify the entry. */ |
| 949 |
ulToneEntry &= (~( 0x1 << ( 31 - ( f_ulToneEventNumber % 32 )))); |
| 950 |
|
| 951 |
/* Copy back the new value. */ |
| 952 |
pEchoChanEntry->aulToneConf[ f_ulToneEventNumber / 32 ] = ulToneEntry; |
| 953 |
} |
| 954 |
else /* if ( f_fDisableAll == TRUE ) */ |
| 955 |
{ |
| 956 |
/* Clear all events. */ |
| 957 |
Oct6100UserMemSet( pEchoChanEntry->aulToneConf, 0x00, sizeof( pEchoChanEntry->aulToneConf ) ); |
| 958 |
} |
| 959 |
} |
| 960 |
|
| 961 |
/* Re-enable the SS7 tones */ |
| 962 |
for ( ulToneEventNumber = 0; ulToneEventNumber < cOCT6100_MAX_TONE_EVENT; ulToneEventNumber++ ) |
| 963 |
{ |
| 964 |
/* Check if the current tone is a SS tone. */ |
| 965 |
ulResult = Oct6100ApiIsSSTone( |
| 966 |
f_pApiInstance, |
| 967 |
f_pApiInstance->pSharedInfo->ImageInfo.aToneInfo[ ulToneEventNumber ].ulToneID, |
| 968 |
&fSSTone ); |
| 969 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 970 |
return ulResult; |
| 971 |
|
| 972 |
if ( fSSTone == TRUE ) |
| 973 |
{ |
| 974 |
/* Write to all resources needed to activate tone detection on this SS tone. */ |
| 975 |
ulResult = Oct6100ApiWriteToneDetectEvent( |
| 976 |
f_pApiInstance, |
| 977 |
f_ulChannelIndex, |
| 978 |
ulToneEventNumber, |
| 979 |
|
| 980 |
cOCT6100_INVALID_INDEX ); |
| 981 |
if ( ulResult != cOCT6100_ERR_OK ) |
| 982 |
return ulResult; |
| 983 |
} |
| 984 |
} |
| 985 |
|
| 986 |
return cOCT6100_ERR_OK; |
| 987 |
} |
| 988 |
#endif |
| 989 |
|
| 990 |
|
| 991 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 992 |
|
| 993 |
Function: Oct6100ApiIsSSTone |
| 994 |
|
| 995 |
Description: Check if specified tone number is a special signaling |
| 996 |
system tone. |
| 997 |
|
| 998 |
------------------------------------------------------------------------------- |
| 999 |
| Argument | Description |
| 1000 |
------------------------------------------------------------------------------- |
| 1001 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 1002 |
present state of the chip and all its resources. |
| 1003 |
|
| 1004 |
f_ulToneEventNumber Tone event number to be checked against. |
| 1005 |
|
| 1006 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 1007 |
#if !SKIP_Oct6100ApiIsSSTone |
| 1008 |
UINT32 Oct6100ApiIsSSTone( |
| 1009 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 1010 |
IN UINT32 f_ulToneEventNumber, |
| 1011 |
OUT PBOOL f_fSSTone ) |
| 1012 |
{ |
| 1013 |
*f_fSSTone = FALSE; |
| 1014 |
|
| 1015 |
switch( f_ulToneEventNumber ) |
| 1016 |
{ |
| 1017 |
case cOCT6100_TONE_SIN_SYSTEM7_2000 : |
| 1018 |
case cOCT6100_TONE_SIN_SYSTEM7_1780 : |
| 1019 |
case cOCT6100_TONE_ROUT_G168_2100GB_ON : |
| 1020 |
case cOCT6100_TONE_ROUT_G168_2100GB_WSPR : |
| 1021 |
case cOCT6100_TONE_ROUT_G168_1100GB_ON : |
| 1022 |
case cOCT6100_TONE_ROUT_G168_2100GB_ON_WIDE_A : |
| 1023 |
case cOCT6100_TONE_ROUT_G168_2100GB_ON_WIDE_B : |
| 1024 |
case cOCT6100_TONE_ROUT_G168_2100GB_WSPR_WIDE : |
| 1025 |
case cOCT6100_TONE_SOUT_G168_2100GB_ON : |
| 1026 |
case cOCT6100_TONE_SOUT_G168_2100GB_WSPR : |
| 1027 |
case cOCT6100_TONE_SOUT_G168_1100GB_ON : |
| 1028 |
case cOCT6100_TONE_SOUT_G168_2100GB_ON_WIDE_A : |
| 1029 |
case cOCT6100_TONE_SOUT_G168_2100GB_ON_WIDE_B : |
| 1030 |
case cOCT6100_TONE_SOUT_G168_2100GB_WSPR_WIDE : |
| 1031 |
case cOCT6100_TONE_SIN_SYSTEM5_2400 : |
| 1032 |
case cOCT6100_TONE_SIN_SYSTEM5_2600 : |
| 1033 |
case cOCT6100_TONE_SIN_SYSTEM5_2400_2600 : |
| 1034 |
*f_fSSTone = TRUE; |
| 1035 |
break; |
| 1036 |
default: |
| 1037 |
break; |
| 1038 |
} |
| 1039 |
|
| 1040 |
return cOCT6100_ERR_OK; |
| 1041 |
} |
| 1042 |
#endif |
| 1043 |
|
| 1044 |
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\ |
| 1045 |
|
| 1046 |
Function: Oct6100ApiIsSSTone |
| 1047 |
|
| 1048 |
Description: Check if specified tone number is a 2100 special signaling |
| 1049 |
system tone. |
| 1050 |
|
| 1051 |
------------------------------------------------------------------------------- |
| 1052 |
| Argument | Description |
| 1053 |
------------------------------------------------------------------------------- |
| 1054 |
f_pApiInstance Pointer to API instance. This memory is used to keep the |
| 1055 |
present state of the chip and all its resources. |
| 1056 |
|
| 1057 |
f_ulToneEventNumber Tone event number to be checked against. |
| 1058 |
|
| 1059 |
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ |
| 1060 |
#if !SKIP_Oct6100ApiIs2100Tone |
| 1061 |
UINT32 Oct6100ApiIs2100Tone( |
| 1062 |
IN OUT tPOCT6100_INSTANCE_API f_pApiInstance, |
| 1063 |
IN UINT32 f_ulToneEventNumber, |
| 1064 |
OUT PBOOL f_fIs2100Tone ) |
| 1065 |
{ |
| 1066 |
*f_fIs2100Tone = FALSE; |
| 1067 |
|
| 1068 |
switch( f_ulToneEventNumber ) |
| 1069 |
{ |
| 1070 |
case cOCT6100_TONE_ROUT_G168_2100GB_ON : |
| 1071 |
case cOCT6100_TONE_ROUT_G168_2100GB_WSPR : |
| 1072 |
case cOCT6100_TONE_ROUT_G168_2100GB_ON_WIDE_A : |
| 1073 |
case cOCT6100_TONE_ROUT_G168_2100GB_ON_WIDE_B : |
| 1074 |
case cOCT6100_TONE_ROUT_G168_2100GB_WSPR_WIDE : |
| 1075 |
case cOCT6100_TONE_SOUT_G168_2100GB_ON : |
| 1076 |
case cOCT6100_TONE_SOUT_G168_2100GB_WSPR : |
| 1077 |
case cOCT6100_TONE_SOUT_G168_2100GB_ON_WIDE_A : |
| 1078 |
case cOCT6100_TONE_SOUT_G168_2100GB_ON_WIDE_B : |
| 1079 |
case cOCT6100_TONE_SOUT_G168_2100GB_WSPR_WIDE : |
| 1080 |
*f_fIs2100Tone = TRUE; |
| 1081 |
break; |
| 1082 |
default: |
| 1083 |
break; |
| 1084 |
} |
| 1085 |
|
| 1086 |
return cOCT6100_ERR_OK; |
| 1087 |
} |
| 1088 |
#endif |