developer | e0cea0f | 2021-12-16 16:08:26 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */
|
| 2 | /*
|
| 3 | * Author(s):
|
| 4 | * cdp
|
| 5 | *
|
| 6 | * Distributed by:
|
| 7 | * Silicon Laboratories, Inc
|
| 8 | *
|
| 9 | * This file contains proprietary information.
|
| 10 | * No dissemination allowed without prior written permission from
|
| 11 | * Silicon Laboratories, Inc.
|
| 12 | *
|
| 13 | * File Description:
|
| 14 | * This is the header file for the inward test implementations.
|
| 15 | *
|
| 16 | */
|
| 17 | #ifndef PROSLIC_TSTIN_H
|
| 18 | #define PROSLIC_TSTIN_H
|
| 19 |
|
| 20 | #include "../config_inc/si_voice_datatypes.h"
|
| 21 | #include "proslic.h"
|
| 22 |
|
| 23 | /** @addtogroup DIAGNOSTICS
|
| 24 | * @{
|
| 25 | */
|
| 26 | /** @defgroup PROSLIC_TSTIN ProSLIC Inward Tests (Test-In)
|
| 27 | * This section documents functions and data structures related to the
|
| 28 | * ProSLIC/FXS inward test implementations.
|
| 29 | * @{
|
| 30 | */
|
| 31 |
|
| 32 | #define MIN_RINGING_SAMPLES 16 /**< Minimum number of ringing samples for measuring ring amplitude */
|
| 33 | #define MAX_RINGING_SAMPLES 255 /**< Maximum number of ringing samples for measuring ring amplitude */
|
| 34 | #define MIN_RINGING_SAMPLE_INTERVAL 1 /**< Minimum sample interval for measuring ring amplitude */
|
| 35 | #define MAX_RINGING_SAMPLE_INTERVAL 10 /**< Maximum sample interval for measuring ring amplitude */
|
| 36 |
|
| 37 | /**
|
| 38 | * Test-In results status
|
| 39 | */
|
| 40 | enum
|
| 41 | {
|
| 42 | TSTIN_RESULTS_INVALID,
|
| 43 | TSTIN_RESULTS_VALID
|
| 44 | };
|
| 45 |
|
| 46 | /**
|
| 47 | * PCM format options
|
| 48 | */
|
| 49 | enum
|
| 50 | {
|
| 51 | PCM_8BIT,
|
| 52 | PCM_16BIT
|
| 53 | };
|
| 54 |
|
| 55 | /**
|
| 56 | * Abort if Line-in-use option
|
| 57 | */
|
| 58 | enum
|
| 59 | {
|
| 60 | ABORT_LIU_DISABLED,
|
| 61 | ABORT_LIU_ENABLED
|
| 62 | };
|
| 63 |
|
| 64 | /**
|
| 65 | * Check for loop closure option
|
| 66 | */
|
| 67 | enum
|
| 68 | {
|
| 69 | LCR_CHECK_DISABLED,
|
| 70 | LCR_CHECK_ENABLED
|
| 71 | };
|
| 72 |
|
| 73 | /**
|
| 74 | * Check for ringtrip option
|
| 75 | */
|
| 76 | enum
|
| 77 | {
|
| 78 | RTP_CHECK_DISABLED,
|
| 79 | RTP_CHECK_ENABLED
|
| 80 | };
|
| 81 |
|
| 82 |
|
| 83 | /**
|
| 84 | * Defines generic test limit/value/status structure
|
| 85 | */
|
| 86 | typedef struct
|
| 87 | {
|
| 88 | int32 lowerLimit; /**< Lower test limit */
|
| 89 | int32 upperLimit; /**< Upper test limit */
|
| 90 | int32 value; /**< Numeric test result */
|
| 91 | uInt8 testResult; /**< 0 - Fail, 1 - pass */
|
| 92 | } proslicTestObj;
|
| 93 |
|
| 94 | /**
|
| 95 | * Defines structure for PCM Loopback Test
|
| 96 | */
|
| 97 | typedef struct
|
| 98 | {
|
| 99 | BOOLEAN testEnable; /**< Gate execution/updating of results with this flag */
|
| 100 | BOOLEAN pcmLpbkEnabled; /**< Indicates if test data is valid (1) or stale (0) */
|
| 101 | BOOLEAN pcm8BitLinear; /**< Set to use 8 bit linear mode (used if normally using ulaw or alaw) */
|
| 102 | uInt8 pcmModeSave; /**< Store entry PCMMODE value */
|
| 103 | uInt8 testResult; /**< OR of all test results in this structure */
|
| 104 | } proslicPcmLpbkTest;
|
| 105 |
|
| 106 |
|
| 107 | /**
|
| 108 | * Defines structure for DC Feed Test
|
| 109 | */
|
| 110 | typedef struct
|
| 111 | {
|
| 112 | BOOLEAN testEnable; /**< Gate execution/updating of results with this flag */
|
| 113 | BOOLEAN testDataValid; /**< Indicates if test data is valid (1) or stale (0) */
|
| 114 | BOOLEAN abortIfLineInUse; /**< Abort test if LCR set at the start of test. Leaves results invalid */
|
| 115 | BOOLEAN applyLcrThresh; /**< Apply alternate LCR thresholds to ensure LCR event occurs */
|
| 116 | uInt32
|
| 117 | altLcrOffThresh; /**< Optional LCROFFHK threshold to apply during test */
|
| 118 | uInt32 altLcrOnThresh; /**< Optional LCRONHK threshold to apply during test */
|
| 119 | BOOLEAN lcrStatus; /**< Indicates LCR status after applying test load */
|
| 120 | proslicTestObj dcfeedVtipOnhook; /**< On-hook VTIP test results */
|
| 121 | proslicTestObj dcfeedVringOnhook; /**< On-hook VRING test results */
|
| 122 | proslicTestObj dcfeedVloopOnhook; /**< On-hook VLOOP test results */
|
| 123 | proslicTestObj dcfeedVbatOnhook; /**< On-hook VBAT test results */
|
| 124 | proslicTestObj dcfeedItipOnhook; /**< On-hook ITIP test results */
|
| 125 | proslicTestObj dcfeedIringOnhook; /**< On-hook IRING test results */
|
| 126 | proslicTestObj dcfeedIloopOnhook; /**< On-hook ILOOP test results */
|
| 127 | proslicTestObj dcfeedIlongOnhook; /**< On-hook ILONG test results */
|
| 128 | proslicTestObj dcfeedVtipOffhook; /**< Off-hook VTIP test results */
|
| 129 | proslicTestObj dcfeedVringOffhook; /**< Off-hook VRING test results */
|
| 130 | proslicTestObj dcfeedVloopOffhook; /**< Off-hook VLOOP test results */
|
| 131 | proslicTestObj dcfeedVbatOffhook; /**< Off-hook VBAT test results */
|
| 132 | proslicTestObj dcfeedItipOffhook; /**< Off-hook ITIP test results */
|
| 133 | proslicTestObj dcfeedIringOffhook; /**< Off-hook IRING test results */
|
| 134 | proslicTestObj dcfeedIloopOffhook; /**< Off-hook ILOOP test results */
|
| 135 | proslicTestObj dcfeedIlongOffhook; /**< Off-hook ILONG test results */
|
| 136 | uInt8 testResult; /**< OR of all test results in this structure */
|
| 137 | } proslicDcFeedTest;
|
| 138 |
|
| 139 |
|
| 140 | /**
|
| 141 | * Defines structure for Ringing Test
|
| 142 | */
|
| 143 | typedef struct
|
| 144 | {
|
| 145 | BOOLEAN testEnable; /**< Gate execution/updating of results with this flag */
|
| 146 | BOOLEAN testDataValid; /**< Indicates if test data is valid (1) or stale (0) */
|
| 147 | BOOLEAN abortIfLineInUse; /**< Abort test if LCR set at the start of test. Leaves results invalid */
|
| 148 | uInt16 numSamples; /**< Number of samples taken */
|
| 149 | uInt8
|
| 150 | sampleInterval; /**< Sample interval (in ms - range 1 to 100) */
|
| 151 | BOOLEAN ringtripTestEnable; /**< Enable ringtrip test */
|
| 152 | BOOLEAN rtpStatus; /**< RTP Bit */
|
| 153 | proslicTestObj ringingVac; /**< Ringing AC Voltage test results */
|
| 154 | proslicTestObj ringingVdc; /**< Ringing DC Voltage test results */
|
| 155 | uInt8 testResult; /**< OR of all test results in this structure */
|
| 156 | } proslicRingingTest;
|
| 157 |
|
| 158 | /**
|
| 159 | * Defines structure for Battery Test
|
| 160 | */
|
| 161 | typedef struct
|
| 162 | {
|
| 163 | BOOLEAN testEnable; /**< Gate execution/updating of results with this flag */
|
| 164 | BOOLEAN testDataValid; /**< Indicates if test data is valid (1) or stale (0) */
|
| 165 | proslicTestObj vbat; /**< VBAT test results */
|
| 166 | uInt8 testResult; /**< OR of all test results in this structure */
|
| 167 | } proslicBatteryTest;
|
| 168 |
|
| 169 | /**
|
| 170 | * Defines structure for Audio Test
|
| 171 | */
|
| 172 | typedef struct
|
| 173 | {
|
| 174 | BOOLEAN testEnable; /**< Gate execution/updating of results with this flag */
|
| 175 | BOOLEAN testDataValid; /**< Indicates if test data is valid (1) or stale (0) */
|
| 176 | BOOLEAN abortIfLineInUse; /**< Abort test if LCR set at the start of test. Leaves results invalid */
|
| 177 | int32
|
| 178 | zerodBm_mVpk; /**< 0dBm voltage (in mVpk) of ref impedance */
|
| 179 | proslicTestObj txGain; /**< TX path gain test results */
|
| 180 | proslicTestObj rxGain; /**< RX path gain test results */
|
| 181 | uInt8 testResult; /**< OR of all test results in this structure */
|
| 182 | } proslicAudioTest;
|
| 183 |
|
| 184 |
|
| 185 | /**
|
| 186 | * Defines structure for all tests
|
| 187 | */
|
| 188 | typedef struct
|
| 189 | {
|
| 190 | proslicPcmLpbkTest pcmLpbkTest;
|
| 191 | proslicDcFeedTest dcFeedTest;
|
| 192 | proslicRingingTest ringingTest;
|
| 193 | proslicBatteryTest batteryTest;
|
| 194 | proslicAudioTest audioTest;
|
| 195 | } proslicTestInObjType;
|
| 196 |
|
| 197 | typedef proslicTestInObjType *proslicTestInObjType_ptr;
|
| 198 |
|
| 199 |
|
| 200 | /**
|
| 201 | * @brief
|
| 202 | * Allocate memory and initialize the given structure.
|
| 203 | *
|
| 204 | * @param[in,out] *pTstin - the structure to initialize
|
| 205 | * @param[in] num_objs - number of Testin structures to allocate.
|
| 206 | *
|
| 207 | * @retval int - error from @ref errorCodeType @ref RC_NONE indicates no error.
|
| 208 | * @sa ProSLIC_DestroyTestInObjs
|
| 209 | */
|
| 210 | int ProSLIC_createTestInObjs(proslicTestInObjType_ptr *pTstin, uInt32 num_objs);
|
| 211 | #define ProSLIC_createTestInObj(X) ProSLIC_createTestInObjs((X),1)
|
| 212 |
|
| 213 | /**
|
| 214 | * @brief
|
| 215 | * Free memory reserved by the given structure.
|
| 216 | *
|
| 217 | * @param[in,out] *pTstin - the structure to initialize
|
| 218 | *
|
| 219 | * @retval int - error from @ref errorCodeType @ref RC_NONE indicates no error.
|
| 220 | */
|
| 221 | int ProSLIC_destroyTestInObjs(proslicTestInObjType_ptr *pTstin);
|
| 222 | #define ProSLIC_destroyTestInObj ProSLIC_destroyTestInObjs
|
| 223 |
|
| 224 | /**
|
| 225 | * @brief
|
| 226 | * Enable PCM loopback.
|
| 227 | *
|
| 228 | * @param[in] pProslic - channel data structure
|
| 229 | * @param[in,out] pTstin - all control, limits, and results
|
| 230 | *
|
| 231 | * @retval int - error from @ref errorCodeType @ref RC_NONE indicates no error.
|
| 232 | */
|
| 233 | int ProSLIC_testInPCMLpbkEnable(proslicChanType_ptr pProslic,
|
| 234 | proslicTestInObjType_ptr pTstin);
|
| 235 |
|
| 236 |
|
| 237 | /**
|
| 238 | * @brief
|
| 239 | * Disable PCM loopback.
|
| 240 | *
|
| 241 | * @param[in] pProslic - channel data structure
|
| 242 | * @param[in,out] pTstin - all control, limits, and results
|
| 243 | *
|
| 244 | * @retval int - error from @ref errorCodeType @ref RC_NONE indicates no error.
|
| 245 | */
|
| 246 | int ProSLIC_testInPCMLpbkDisable(proslicChanType_ptr pProslic,
|
| 247 | proslicTestInObjType_ptr pTstin);
|
| 248 |
|
| 249 |
|
| 250 | /**
|
| 251 | * @brief
|
| 252 | * DC Feed Test - the pTstin->dcFeedTest contains control, limits and test result information.
|
| 253 | *
|
| 254 | * @param[in] pProslic - channel data structure
|
| 255 | * @param[in,out] pTstin - all control, limits, and results
|
| 256 | *
|
| 257 | * @retval int - error from @ref errorCodeType
|
| 258 | * @retval RC_TEST_PASSED indicates test completed and passed
|
| 259 | * @retval RC_TEST_FAILED indicates test completed and failed
|
| 260 | * @retval RC_UNSUPPORTED_FEATURE indicates feature not supported on this device
|
| 261 | * @retval RC_TEST_DISABLED indicates test has not been initialized/enabled
|
| 262 | * @retval RC_LINE_IN_USE indicates LCS already set
|
| 263 | *
|
| 264 | */
|
| 265 | int ProSLIC_testInDCFeed(proslicChanType_ptr pProslic,
|
| 266 | proslicTestInObjType_ptr pTstin);
|
| 267 |
|
| 268 |
|
| 269 | /**
|
| 270 | * @brief
|
| 271 | * Ringing and Ringtrip Test
|
| 272 | *
|
| 273 | * @param[in] pProslic - channel data structure
|
| 274 | * @param[in,out] pTstin - all control, limits, and results
|
| 275 | *
|
| 276 | * @retval int - error from @ref errorCodeType
|
| 277 | * @retval RC_TEST_PASSED indicates test completed and passed
|
| 278 | * @retval RC_TEST_FAILED indicates test completed and failed
|
| 279 | * @retval RC_UNSUPPORTED_FEATURE indicates feature not supported on this device
|
| 280 | * @retval RC_TEST_DISABLED indicates test has not been initialized/enabled
|
| 281 | * @retval RC_LINE_IN_USE indicates LCS already set
|
| 282 | *
|
| 283 | */
|
| 284 | int ProSLIC_testInRinging(proslicChanType_ptr pProslic,
|
| 285 | proslicTestInObjType_ptr pTstin);
|
| 286 |
|
| 287 | /**
|
| 288 | * @brief
|
| 289 | * Battery Test -
|
| 290 | * pTstin contains both the configuration data and test results.
|
| 291 | * See **pTstin->batteryTest.testResult - Pass/Fail result
|
| 292 | *
|
| 293 | * @param[in] pProslic - channel data structure
|
| 294 | * @param[in,out] pTstin - configuration and test results
|
| 295 | *
|
| 296 | * @retval int - error from @ref errorCodeType
|
| 297 | * @retval RC_TEST_PASSED indicates test completed and passed
|
| 298 | * @retval RC_TEST_FAILED indicates test completed and failed
|
| 299 | * @retval RC_UNSUPPORTED_FEATURE indicates feature not supported on this device
|
| 300 | * @retval RC_TEST_DISABLED indicates test has not been initialized/enabled
|
| 301 | *
|
| 302 | */
|
| 303 | int ProSLIC_testInBattery(proslicChanType_ptr pProslic,
|
| 304 | proslicTestInObjType_ptr pTstin);
|
| 305 |
|
| 306 | /**
|
| 307 | * @brief
|
| 308 | * Audio level inward test. pTstin->audioTest contains all control, limits and results.
|
| 309 | *
|
| 310 | * @param[in] pProslic - channel data structure
|
| 311 | * @param[in,out] pTstin - all control, limits, and results
|
| 312 | *
|
| 313 | * @retval int - error from @ref errorCodeType
|
| 314 | * @retval RC_TEST_PASSED indicates test completed and passed
|
| 315 | * @retval RC_TEST_FAILED indicates test completed and failed
|
| 316 | * @retval RC_UNSUPPORTED_FEATURE indicates feature not supported on this device
|
| 317 | * @retval RC_TEST_DISABLED indicates test has not been initialized/enabled
|
| 318 | * @retval RC_LINE_IN_USE indicates LCS already set
|
| 319 | *
|
| 320 | */
|
| 321 | int ProSLIC_testInAudio(proslicChanType_ptr pProslic,
|
| 322 | proslicTestInObjType_ptr pTstin);
|
| 323 |
|
| 324 | /**
|
| 325 | * @brief
|
| 326 | * Initialize/Enable PCM Loopback Test. Links test config/limits
|
| 327 | * to inward test data structure.
|
| 328 | *
|
| 329 | * @param[in,out] pTstin->pcmLpbkTest - all control, limits, and results
|
| 330 | * @param[in] pcmLpbkTest - test config and limits to link to pTstin->pcmLpbkTest
|
| 331 | *
|
| 332 | * @retval int - error from @ref errorCodeType @ref RC_NONE indicates no error.
|
| 333 | */
|
| 334 | int ProSLIC_testInPcmLpbkSetup(proslicTestInObjType *pTstin,
|
| 335 | proslicPcmLpbkTest *pcmLpbkTest);
|
| 336 |
|
| 337 | /**
|
| 338 | * @brief
|
| 339 | * Initialize/Enable DC Feed Test. Links test config/limits
|
| 340 | * to inward test data structure.
|
| 341 | *
|
| 342 | * @param[in,out] pTstin->dcFeedTest - all control, limits, and results
|
| 343 | * @param[in] dcFeedTest - test config and limits to link to pTstin->dcFeedTest
|
| 344 | *
|
| 345 | * @retval int - error from @ref errorCodeType @ref RC_NONE indicates no error.
|
| 346 | */
|
| 347 | int ProSLIC_testInDcFeedSetup(proslicTestInObjType *pTstin,
|
| 348 | proslicDcFeedTest *dcFeedTest);
|
| 349 |
|
| 350 | /**
|
| 351 | * @brief
|
| 352 | * Initialize/Enable Ringing Test. Links test config/limits
|
| 353 | * to inward test data structure.
|
| 354 | *
|
| 355 | * @param[in,out] pTstin->ringingTest - all control, limits, and results
|
| 356 | * @param[in] ringingTest - test config and limits to link to pTstin->ringingTest
|
| 357 | *
|
| 358 | * @retval int - error from @ref errorCodeType @ref RC_NONE indicates no error.
|
| 359 | */
|
| 360 | int ProSLIC_testInRingingSetup(proslicTestInObjType *pTstin,
|
| 361 | proslicRingingTest *ringingTest);
|
| 362 |
|
| 363 | /**
|
| 364 | * @brief
|
| 365 | * Initialize/Enable Battery Test. Links test config/limits
|
| 366 | * to inward test data structure.
|
| 367 | *
|
| 368 | * @param[in,out] pTstin->batteryTest - all control, limits, and results
|
| 369 | * @param[in] batteryTest - test config and limits to link to pTstin->batteryTest
|
| 370 | *
|
| 371 | * @retval int - error from @ref errorCodeType @ref RC_NONE indicates no error.
|
| 372 | */
|
| 373 | int ProSLIC_testInBatterySetup(proslicTestInObjType *pTstin,
|
| 374 | proslicBatteryTest *batteryTest);
|
| 375 |
|
| 376 | /**
|
| 377 | * @brief
|
| 378 | * Initialize/Enable Audio Test. Links test config/limits
|
| 379 | * to inward test data structure.
|
| 380 | *
|
| 381 | * @param[in,out] pTstin->audioTest - all control, limits, and results
|
| 382 | * @param[in] audioTest - test config and limits to link to pTstin->audioTest
|
| 383 | *
|
| 384 | * @retval int - error from @ref errorCodeType @ref RC_NONE indicates no error.
|
| 385 | */
|
| 386 | int ProSLIC_testInAudioSetup(proslicTestInObjType *pTstin,
|
| 387 | proslicAudioTest *audioTest);
|
| 388 |
|
| 389 |
|
| 390 | /**
|
| 391 | * @brief
|
| 392 | * Debug utility to log presently loaded test limits
|
| 393 | *
|
| 394 | * @param[in] pProslic - channel data structure
|
| 395 | * @param[in] pTstin - inward test data structure
|
| 396 | *
|
| 397 | * @retval int - error from @ref errorCodeType
|
| 398 | * @retval RC_NONE indicates no error.
|
| 399 | * @retval RC_UNSUPPORTED_FEATURE indicates feature not supported on this device
|
| 400 | */
|
| 401 | int ProSLIC_testInPrintLimits(proslicChanType *pProslic,
|
| 402 | proslicTestInObjType *pTstin);
|
| 403 |
|
| 404 | /**
|
| 405 | * @brief
|
| 406 | * Provide a simulated offhook using the ProSLIC test load. You would call
|
| 407 | * this function twice: once to enable the simulated test load
|
| 408 | * (is_testStart = TRUE) and check if the upper layer correctly detected
|
| 409 | * the hook state change and possibly pass some audio. After you have
|
| 410 | * completed this test/check, you would call the same function again to
|
| 411 | * restore the system to normal state (is_testStart = FALSE).
|
| 412 | *
|
| 413 | * @note This test can only be executed one at a time. Running this on
|
| 414 | * multiple channels that have different DC Feed and digital control
|
| 415 | * settings will cause problems. If the all the channels have the
|
| 416 | * same settings, this restriction can be loosened.
|
| 417 | *
|
| 418 | *
|
| 419 | * @param[in] pProslic - channel data structure
|
| 420 | * @param[in] is_testStart - is the the start or end of test.
|
| 421 | * @param[in] timeDelayMsec - how may mSec to delay prior to returning from
|
| 422 | the function.
|
| 423 | *
|
| 424 | * @retval int - error from @ref errorCodeType
|
| 425 | * @retval RC_NONE indicates no error.
|
| 426 | * @retval RC_UNSUPPORTED_FEATURE indicates feature not supported on this device
|
| 427 | */
|
| 428 |
|
| 429 | int ProSLIC_testLoadTest(
|
| 430 | SiVoiceChanType_ptr pProslic,
|
| 431 | BOOLEAN is_testStart,
|
| 432 | uint32_t timeDelayMsec);
|
| 433 |
|
| 434 | /** @} PROSLIC_TSTIN */
|
| 435 | /** @} DIAGNOSTICS */
|
| 436 | #endif
|
| 437 |
|