libsangoma  1
Functions
libsangoma_hwec.c File Reference

Hardware Echo Canceller API Code Library for Sangoma AFT T1/E1/Analog/BRI hardware. More...

#include "libsangoma.h"
#include "libsangoma-pvt.h"
#include "wanpipe_includes.h"
#include "wanpipe_events.h"
#include "wanec_api.h"
#include "wanec_iface_api.h"
Include dependency graph for libsangoma_hwec.c:

Go to the source code of this file.

Functions

void _LIBSNG_CALL sangoma_hwec_initialize_custom_parameter_structure (wan_custom_param_t *custom_param, char *parameter_name, char *parameter_value)
 Initialize Custom Paramter structure. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_init (char *device_name, wan_custom_param_t custom_params[], unsigned int number_of_custom_params)
 Load Firmware image onto EC chip and allocated per-port resources in HWEC API. All chip-wide configuration paramters, if any, must be specified at the time of chip initialization. Note that Analog card is considered a "single-port" card by HWEC API. That means for Analog cards and for single-port digital cards only a single sangoma_hwec_config_init() call is required, all subsequent calls will have no effect. For multi-port cards, such as A102/A104/A108/A500, the sangoma_hwec_config_init() must be called for each port, at least one time. Only the first call will actually load the Firmware image onto EC chip, all subsequent calls (for other ports) will only add the Port to list of ports which use the HWEC API. Actions of sangoma_hwec_config_init() can be reversed by calling sangoma_hwec_config_release(). When Port is stopped, the HWEC API automatically releases per-port resources and removes the Port from list ports which use HWEC API. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_release (char *device_name)
 Release resources allocated by sangoma_hwec_config_init(). For single-port cards, such as A101 and A200 (A200 is an Analog card and considered sinle-port by HWEC API), a single call to sangoma_hwec_config_release() will free the per-chip resources. For multi-port cards, such as A102/A104/A108/A500, sangoma_hwec_config_release() can be called for each port to remove it from list Ports which are using HWEC API. When sangoma_hwec_config_release() is called for the last Port which was "configured/initialized by HWEC API", the per-chip resources will be freed. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_operation_mode (char *device_name, int mode, unsigned int fe_chan_map)
 Modify channel operation mode. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_power_on (char *device_name, unsigned int fe_chan_map)
 Set the channel state in the echo canceller to NORMAL/POWER ON. This enables echo cancelation logic inside the chip. The action is internal to EC chip itself, not related to AFT FPGA. This call is slow and should be used only on startup. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_power_off (char *device_name, unsigned int fe_chan_map)
 Set the channel state in the echo canceller to POWER OFF. This disables echo cancellatio logic inside the chip and data passes unmodified through the ec chip. The action is internal to EC chip itself, not related to AFT FPGA. This call is slow and should be used only on startup. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_enable (char *device_name, unsigned int fe_chan_map)
 Redirect audio stream from AFT FPGA to EC chip. This command effectively enables echo cancellation since data is now forced through the EC chip by the FPGA. Data will be modified by the echo canceller. This command is recommened for fast enabling of Echo Cancellation. Note 1: Chip must be configured and in POWER ON state for echo Chancellation to take place. Note 2: sangoma_tdm_enable_hwec() function can be used to achive the same funcitnality based on file descriptor versus channel map. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_disable (char *device_name, unsigned int fe_chan_map)
 Force AFT FPGA to bypass the echo canceller. This command effectively disables echo cancellation since data will not flowing through the ec chip. Data will not be modified by the echo canceller. This command is recommened for fast disabling of Echo Cancelation. Note: sangoma_tdm_disable_hwec() function can be use to achive the same functionality based on file descriptor versus channel map. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_channel_parameter (char *device_name, char *parameter, char *parameter_value, unsigned int channel_map)
 Modify channel configuration parameters. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_tone_detection (char *device_name, int tone_id, int enable, unsigned int fe_chan_map, unsigned char port_map)
 Enable/Disable tone detection (such as DTMF) of channels from channel map. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_print_statistics (char *device_name, int full, unsigned int fe_chan)
 Read and print Chip/Channel statistics from EC chip. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_audio_buffer_load (char *device_name, char *filename, char pcmlaw, int *out_buffer_id)
 Load audio buffer to EC chip. The buffer can be played out using the sangoma_hwec_audio_buffer_playout() function. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_audio_mem_buffer_load (char *device_name, unsigned char *buffer, unsigned int in_size, char pcmlaw, int *out_buffer_id)
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_audio_buffer_unload (char *device_name, int in_buffer_id)
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_audio_buffer_playout (char *device_name, unsigned int fe_chan_map, unsigned char port, int in_buffer_id, int start, int repeat_cnt, int duration)
 Start playing out an audio buffer previously loaded by sangoma_hwec_audio_buffer_load(). More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_verbosity (int verbosity_level)
 Set Verbosity level of EC API Driver and Library. The level controls amount of data printed to stdout and to wanpipelog.txt (Windows) or /var/log/messages (Linux) for diagnostic purposes. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_get_channel_statistics (sng_fd_t fd, unsigned int fe_chan, int *hwec_api_return_code, wanec_chan_stats_t *wanec_chan_stats, int verbose, int reset)
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_get_global_chip_statistics (sng_fd_t fd, int *hwec_api_return_code, wanec_chip_stats_t *wanec_chip_stats, int verbose, int reset)
 Get Global statistics from EC chip. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_get_chip_image_info (sng_fd_t fd, int *hwec_api_return_code, wanec_chip_image_t *wanec_chip_image, int verbose)
 Get information about Firmware Image of EC chip. More...
 
sangoma_status_t _LIBSNG_CALL sangoma_hwec_set_hwdtmf_removal (sng_fd_t fd, unsigned int fe_chan, int *hwec_api_return_code, int enable, int verbose)
 

Detailed Description

Hardware Echo Canceller API Code Library for Sangoma AFT T1/E1/Analog/BRI hardware.

Author(s): David Rokhvarg david.nosp@m.r@sa.nosp@m.ngoma.nosp@m..com

Copyright: (c) 2005-2011 Sangoma Technologies Corporation

THIS SOFTWARE IS PROVIDED BY Sangoma Technologies ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Sangoma Technologies BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS

Definition in file libsangoma_hwec.c.

Function Documentation

void _LIBSNG_CALL sangoma_hwec_initialize_custom_parameter_structure ( wan_custom_param_t *  custom_param,
char *  parameter_name,
char *  parameter_value 
)

Initialize Custom Paramter structure.

Parameters
parameter_nameParameter Name
parameter_valueParameter Value
Returns
None

Definition at line 166 of file libsangoma_hwec.c.

Referenced by sangoma_hwec_config_channel_parameter().

167 {
168  memset(custom_param, 0x00, sizeof(*custom_param));
169 
170  strncpy( custom_param->name, parameter_name, sizeof(custom_param->name) );
171 
172  if (sangoma_hwec_is_numeric_parameter(parameter_name)) {
173  custom_param->dValue = atoi(parameter_value);
174  } else {
175  strncpy(custom_param->sValue, parameter_value, sizeof(custom_param->sValue));
176  }
177 }

Here is the caller graph for this function:

sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_init ( char *  device_name,
wan_custom_param_t  custom_params[],
unsigned int  number_of_custom_params 
)

Load Firmware image onto EC chip and allocated per-port resources in HWEC API. All chip-wide configuration paramters, if any, must be specified at the time of chip initialization. Note that Analog card is considered a "single-port" card by HWEC API. That means for Analog cards and for single-port digital cards only a single sangoma_hwec_config_init() call is required, all subsequent calls will have no effect. For multi-port cards, such as A102/A104/A108/A500, the sangoma_hwec_config_init() must be called for each port, at least one time. Only the first call will actually load the Firmware image onto EC chip, all subsequent calls (for other ports) will only add the Port to list of ports which use the HWEC API. Actions of sangoma_hwec_config_init() can be reversed by calling sangoma_hwec_config_release(). When Port is stopped, the HWEC API automatically releases per-port resources and removes the Port from list ports which use HWEC API.

Parameters
device_nameSangoma API device name. Windows: wanpipe1_if1, wanpipe2_if1... Note that wanpipe1_if1 and wanpipe1_if2 will access the same Port - wanpipe1. Linux: wanpipe1, wanpipe2...
custom_params[]- (optional) array of custom paramter structures.
This is list of Echo Cancellation chip parameters:

Chip parameter                  Chip parameter value
=================               =======================
WANEC_TailDisplacement          0-896
WANEC_MaxPlayoutBuffers         0-4678
WANEC_EnableExtToneDetection    TRUE | FALSE
WANEC_EnableAcousticEcho        TRUE | FALSE
number_of_custom_params- (optional) number of structures in custom_params[]. Minimum value is 1, maximum is 4, if any other value the custom_params[] will be ignored.
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 215 of file libsangoma_hwec.c.

References SANG_STATUS_FAILED_ALLOCATE_MEMORY, and SANG_STATUS_SUCCESS.

216 {
218  wanec_api_config_t config;
219 
220  memset(&config, 0x00, sizeof(config));
221 
222  if (number_of_custom_params >= 1 && number_of_custom_params <= 4) {
223 
224  wan_custom_param_t *custom_parms_ptr;
225  unsigned int i, custom_params_memory_size;
226 
227  custom_params_memory_size = sizeof(wan_custom_param_t) * number_of_custom_params;
228 
229  /* Do NOT change memory at custom_params[] (it belongs to the caller).
230  * Instead allocate temporary buffer, and use information in custom_params[]
231  * for proper initialization the temproary buffer and
232  * and send if down to API driver. */
233  custom_parms_ptr = malloc(custom_params_memory_size);
234  if (!custom_parms_ptr) {
236  }
237 
238  memset(custom_parms_ptr, 0x00, custom_params_memory_size);
239 
240  for (i = 0; i < number_of_custom_params; i++) {
241 
242  strcpy( custom_parms_ptr[i].name, custom_params[i].name );
243 
244  if (sangoma_hwec_is_numeric_parameter(custom_params[i].name)) {
245  custom_parms_ptr[i].dValue = atoi(custom_params[i].sValue);
246  } else {
247  strcpy(custom_parms_ptr[i].sValue, custom_params[i].sValue);
248  }
249  } /* for() */
250 
251  config.conf.param_no = number_of_custom_params;
252  config.conf.params = custom_parms_ptr;
253 
254  }/* if() */
255 
256  /* Load firmware on EC chip AND apply configuration, if any. */
257  rc = wanec_api_config( device_name, libsng_hwec_verbosity_level, &config );
258 
259  if (config.conf.params) {
260  free(config.conf.params);
261  }
262 
263  return rc;
264 }
int32_t sangoma_status_t
return status from sangoma APIs
Definition: libsangoma.h:338
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_release ( char *  device_name)

Release resources allocated by sangoma_hwec_config_init(). For single-port cards, such as A101 and A200 (A200 is an Analog card and considered sinle-port by HWEC API), a single call to sangoma_hwec_config_release() will free the per-chip resources. For multi-port cards, such as A102/A104/A108/A500, sangoma_hwec_config_release() can be called for each port to remove it from list Ports which are using HWEC API. When sangoma_hwec_config_release() is called for the last Port which was "configured/initialized by HWEC API", the per-chip resources will be freed.

Parameters
device_nameSangoma API device name. Windows: wanpipe1_if1, wanpipe2_if1... Note that wanpipe1_if1 and wanpipe1_if2 will access the same Port - wanpipe1. Linux: wanpipe1, wanpipe2...
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 283 of file libsangoma_hwec.c.

284 {
285  sangoma_status_t rc;
286  wanec_api_release_t release;
287 
288  memset(&release, 0, sizeof(wanec_api_release_t));
289 
290  rc = wanec_api_release( device_name, libsng_hwec_verbosity_level, &release );
291 
292  return rc;
293 }
int32_t sangoma_status_t
return status from sangoma APIs
Definition: libsangoma.h:338
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_operation_mode ( char *  device_name,
int  mode,
unsigned int  fe_chan_map 
)

Modify channel operation mode.

Modify channel operation mode.

Parameters
modeOne of WANEC_API_OPMODE_? values defined in wanpipe_api_iface.h: WANEC_API_OPMODE_NORMAL, WANEC_API_OPMODE_HT_FREEZE, WANEC_API_OPMODE_HT_RESET, WANEC_API_OPMODE_POWER_DOWN, WANEC_API_OPMODE_NO_ECHO, WANEC_API_OPMODE_SPEECH_RECOGNITION.
fe_chan_mapBitmap of channels (timeslots for Digital, lines for Analog) where the call will take effect.
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 298 of file libsangoma_hwec.c.

Referenced by sangoma_hwec_config_power_off(), and sangoma_hwec_config_power_on().

299 {
300  sangoma_status_t rc;
301  wanec_api_opmode_t opmode;
302 
303  memset(&opmode, 0, sizeof(wanec_api_opmode_t));
304 
305  opmode.mode = mode;
306  opmode.fe_chan_map = fe_chan_map;
307 
308  /* modes are:
309  WANEC_API_OPMODE_NORMAL,
310  WANEC_API_OPMODE_HT_FREEZE,
311  WANEC_API_OPMODE_HT_RESET,
312  WANEC_API_OPMODE_POWER_DOWN,
313  WANEC_API_OPMODE_NO_ECHO,
314  WANEC_API_OPMODE_SPEECH_RECOGNITION.
315  */
316  rc = wanec_api_opmode(device_name, libsng_hwec_verbosity_level, &opmode);
317 
318  return rc;
319 }
int32_t sangoma_status_t
return status from sangoma APIs
Definition: libsangoma.h:338

Here is the caller graph for this function:

sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_power_on ( char *  device_name,
unsigned int  fe_chan_map 
)

Set the channel state in the echo canceller to NORMAL/POWER ON. This enables echo cancelation logic inside the chip. The action is internal to EC chip itself, not related to AFT FPGA. This call is slow and should be used only on startup.

Parameters
device_nameSangoma API device name. Windows: wanpipe1_if1, wanpipe2_if1... Linux: wanpipe1, wanpipe2...
fe_chan_mapBitmap of channels (timeslots for Digital, lines for Analog) where the call will take effect.
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 338 of file libsangoma_hwec.c.

References sangoma_hwec_config_operation_mode().

339 {
340  return sangoma_hwec_config_operation_mode(device_name, WANEC_API_OPMODE_NORMAL, fe_chan_map);
341 }
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_operation_mode(char *device_name, int mode, unsigned int fe_chan_map)
Modify channel operation mode.

Here is the call graph for this function:

sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_power_off ( char *  device_name,
unsigned int  fe_chan_map 
)

Set the channel state in the echo canceller to POWER OFF. This disables echo cancellatio logic inside the chip and data passes unmodified through the ec chip. The action is internal to EC chip itself, not related to AFT FPGA. This call is slow and should be used only on startup.

Parameters
device_nameSangoma API device name. Windows: wanpipe1_if1, wanpipe2_if1... Linux: wanpipe1, wanpipe2...
fe_chan_mapBitmap of channels (timeslots for Digital, lines for Analog) where the call will take effect.
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 361 of file libsangoma_hwec.c.

References sangoma_hwec_config_operation_mode().

362 {
363  return sangoma_hwec_config_operation_mode(device_name, WANEC_API_OPMODE_POWER_DOWN, fe_chan_map);
364 }
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_operation_mode(char *device_name, int mode, unsigned int fe_chan_map)
Modify channel operation mode.

Here is the call graph for this function:

sangoma_status_t _LIBSNG_CALL sangoma_hwec_enable ( char *  device_name,
unsigned int  fe_chan_map 
)

Redirect audio stream from AFT FPGA to EC chip. This command effectively enables echo cancellation since data is now forced through the EC chip by the FPGA. Data will be modified by the echo canceller. This command is recommened for fast enabling of Echo Cancellation. Note 1: Chip must be configured and in POWER ON state for echo Chancellation to take place. Note 2: sangoma_tdm_enable_hwec() function can be used to achive the same funcitnality based on file descriptor versus channel map.

Redirect audio stream from AFT FPGA to EC chip. This command effectively enables echo cancellation since data is now forced through the EC chip by the FPGA. Data will be modified by the echo canceller. This command is recommened for fast enabling of Echo Cancellation. Note 1: Chip must be configured and in POWER ON state for echo Chancellation to take place. Note 2: sangoma_tdm_enable_hwec() function can be use to achive the same funcitnality based on file descriptor versus channel map.

Parameters
device_nameSangoma API device name. Windows: wanpipe1_if1, wanpipe2_if1... Linux: wanpipe1, wanpipe2...
fe_chan_mapBitmap of channels (timeslots for Digital, lines for Analog) where the call will take effect.
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 389 of file libsangoma_hwec.c.

390 {
391  return sangoma_hwec_bypass(device_name, 1 /* enable */, fe_chan_map);
392 }
sangoma_status_t _LIBSNG_CALL sangoma_hwec_disable ( char *  device_name,
unsigned int  fe_chan_map 
)

Force AFT FPGA to bypass the echo canceller. This command effectively disables echo cancellation since data will not flowing through the ec chip. Data will not be modified by the echo canceller. This command is recommened for fast disabling of Echo Cancelation. Note: sangoma_tdm_disable_hwec() function can be use to achive the same functionality based on file descriptor versus channel map.

Force AFT FPGA to bypass the echo canceller. This command effectively disables echo cancellation since data will not be flowing through the ec chip. Data will not be modified by the echo canceller. This command is recommened for fast disabling of Echo Cancelation. Note: sangoma_tdm_disable_hwec() function can be used to achive the same functionality based on file descriptor versus channel map.

Parameters
device_nameSangoma API device name. Windows: wanpipe1_if1, wanpipe2_if1... Linux: wanpipe1, wanpipe2...
fe_chan_mapBitmap of channels (timeslots for Digital, lines for Analog) where the call will take effect.
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 416 of file libsangoma_hwec.c.

417 {
418  return sangoma_hwec_bypass(device_name, 0 /* disable */, fe_chan_map);;
419 }
sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_channel_parameter ( char *  device_name,
char *  parameter,
char *  parameter_value,
unsigned int  channel_map 
)

Modify channel configuration parameters.

Parameters
device_nameSangoma API device name. Windows: wanpipe1_if1, wanpipe2_if1... Linux: wanpipe1, wanpipe2...
parameterEcho Cancellation channel parameter

This channel parameters are listed under "Channel parameter":

Channel parameter Channel parameter value ================= ======================= WANEC_EnableNlp TRUE | FALSE WANEC_EnableTailDisplacement TRUE | FALSE WANEC_TailDisplacement 0-896 WANEC_SoutLevelControl TRUE | FALSE WANEC_RinAutomaticLevelControl TRUE | FALSE WANEC_SoutAutomaticLevelControl TRUE | FALSE WANEC_SoutAdaptiveNoiseReduction TRUE | FALSE WANEC_RoutNoiseReduction TRUE | FALSE WANEC_ComfortNoiseMode COMFORT_NOISE_NORMAL COMFORT_NOISE_FAST_LATCH COMFORT_NOISE_EXTENDED COMFORT_NOISE_OFF WANEC_DtmfToneRemoval TRUE | FALSE WANEC_AcousticEcho TRUE | FALSE WANEC_NonLinearityBehaviorA 0-13 WANEC_NonLinearityBehaviorB 0-8 WANEC_DoubleTalkBehavior DT_BEH_NORMAL DT_BEH_LESS_AGGRESSIVE WANEC_AecTailLength 128 (default), 256, 512 or 1024 WANEC_EnableToneDisabler TRUE | FALSE

Parameters
parameter_valuechannel parameter value, listed under "Channel parameter value"
fe_chan_mapBitmap of channels (timeslots for Digital, lines for Analog) where the call will take effect.
Returns
SANG_STATUS_SUCCESS: success, or error status
Parameters
device_nameSangoma API device name. Windows: wanpipe1_if1, wanpipe2_if1... Linux: wanpipe1, wanpipe2...
parameterEcho Cancellation channel parameter

This is list of Echo Cancellation channel parameters:

Channel parameter Channel parameter value ================= ======================= WANEC_EnableNlp TRUE | FALSE WANEC_EnableTailDisplacement TRUE | FALSE WANEC_TailDisplacement 0-896 WANEC_SoutLevelControl TRUE | FALSE WANEC_RinAutomaticLevelControl TRUE | FALSE WANEC_SoutAutomaticLevelControl TRUE | FALSE WANEC_SoutAdaptiveNoiseReduction TRUE | FALSE WANEC_RoutNoiseReduction TRUE | FALSE WANEC_ComfortNoiseMode COMFORT_NOISE_NORMAL COMFORT_NOISE_FAST_LATCH COMFORT_NOISE_EXTENDED COMFORT_NOISE_OFF WANEC_DtmfToneRemoval TRUE | FALSE WANEC_AcousticEcho TRUE | FALSE WANEC_NonLinearityBehaviorA 0-13 WANEC_NonLinearityBehaviorB 0-8 WANEC_DoubleTalkBehavior DT_BEH_NORMAL DT_BEH_LESS_AGGRESSIVE WANEC_AecTailLength 128 (default), 256, 512 or 1024 WANEC_EnableToneDisabler TRUE | FALSE

Parameters
fe_chan_mapBitmap of channels (timeslots for Digital, lines for Analog) where the call will take effect.
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 464 of file libsangoma_hwec.c.

References sangoma_hwec_initialize_custom_parameter_structure().

465 {
466  sangoma_status_t rc;
467  wanec_api_modify_t channelModify;
468  wan_custom_param_t custom_param;
469 
470  memset(&channelModify, 0x00, sizeof(channelModify));
471 
472  sangoma_hwec_initialize_custom_parameter_structure(&custom_param, parameter, parameter_value);
473 
474  channelModify.fe_chan_map = channel_map;
475  channelModify.conf.param_no = 1;
476  channelModify.conf.params = &custom_param;
477 
478  rc = wanec_api_modify( device_name, libsng_hwec_verbosity_level, &channelModify );
479 
480  return rc;
481 }
int32_t sangoma_status_t
return status from sangoma APIs
Definition: libsangoma.h:338
void _LIBSNG_CALL sangoma_hwec_initialize_custom_parameter_structure(wan_custom_param_t *custom_param, char *parameter_name, char *parameter_value)
Initialize Custom Paramter structure.

Here is the call graph for this function:

sangoma_status_t _LIBSNG_CALL sangoma_hwec_config_tone_detection ( char *  device_name,
int  tone_id,
int  enable,
unsigned int  fe_chan_map,
unsigned char  port_map 
)

Enable/Disable tone detection (such as DTMF) of channels from channel map.

Parameters
device_nameSangoma API device name. Windows: wanpipe1_if1, wanpipe2_if1... Linux: wanpipe1, wanpipe2...
tone_idSee wanpipe_api_iface.h for list of valid tones
enableA flag, if 1 - the specified tone will be detected, if 0 - specified tone will not be detected.
fe_chan_mapBitmap of channels (timeslots for Digital, lines for Analog) where the call will take effect.
port_mapPort of tone detection - Rx, Tx. See wanpipe_events.h for list of valid ports (WAN_EC_CHANNEL_PORT_SOUT...).
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 505 of file libsangoma_hwec.c.

506 {
507  sangoma_status_t rc;
508  wanec_api_tone_t tone;
509 
510  memset(&tone, 0, sizeof(wanec_api_tone_t));
511 
512  tone.id = tone_id;
513  tone.enable = enable;
514  tone.fe_chan_map = fe_chan_map;
515  tone.port_map = port_map;
516  tone.type_map = WAN_EC_TONE_PRESENT | WAN_EC_TONE_STOP;
517 
518  rc = wanec_api_tone( device_name, libsng_hwec_verbosity_level, &tone );
519 
520  return rc;
521 }
int32_t sangoma_status_t
return status from sangoma APIs
Definition: libsangoma.h:338
sangoma_status_t _LIBSNG_CALL sangoma_hwec_print_statistics ( char *  device_name,
int  full,
unsigned int  fe_chan_map 
)

Read and print Chip/Channel statistics from EC chip.

Parameters
device_nameSangoma API device name. Windows: wanpipe1_if1, wanpipe2_if1... Linux: wanpipe1, wanpipe2...
fullFlag to read full statistics, if set to 1.
fe_chanChannel number (a timeslot for Digital, a line for Analog) where the call will read statistics. Values from 1 to 31 will indicate the channel nuber. A value of zero will indicate request to print global chip statistics, not per-channel statistics.
Returns
SANG_STATUS_SUCCESS: success, or error status
Parameters
device_nameSangoma API device name. Windows: wanpipe1_if1, wanpipe2_if1... Linux: wanpipe1, wanpipe2...
fullFlag to read full statistics, if set to 1.
fe_chan_mapBitmap of channels (timeslots for Digital, lines for Analog) where the call will read statistics.
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 541 of file libsangoma_hwec.c.

542 {
543  sangoma_status_t rc;
544  wanec_api_stats_t stats;
545 
546  memset(&stats, 0, sizeof(wanec_api_stats_t));
547 
548  stats.full = full;
549  stats.fe_chan = fe_chan;
550  stats.reset = 0; /* do not reset */
551 
552  rc = wanec_api_stats( device_name, libsng_hwec_verbosity_level, &stats );
553 
554  return rc;
555 }
int32_t sangoma_status_t
return status from sangoma APIs
Definition: libsangoma.h:338
sangoma_status_t _LIBSNG_CALL sangoma_hwec_audio_buffer_load ( char *  device_name,
char *  filename,
char  pcmlaw,
int *  out_buffer_id 
)

Load audio buffer to EC chip. The buffer can be played out using the sangoma_hwec_audio_buffer_playout() function.

Parameters
filenamename of the audio file (without the extension). Actual file must have .pcm extension. Location: Windows: SystemRoot% (ex: c:) Linux: /etc/wanpipe/buffers
out_buffer_idwhen the buffer is loaded on the chip, it is assigned an ID. This ID should be used when requesting to play out the buffer.
Returns
SANG_STATUS_SUCCESS: success, or error status
Parameters
bufferPointer to in memory buffer to be loaded on the chip.
sizeSize of buffer.
out_buffer_idwhen the buffer is loaded on the chip, it is assigned an ID. This ID should be used when requesting to play out the buffer.
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 574 of file libsangoma_hwec.c.

References SANG_STATUS_SUCCESS.

575 {
576  sangoma_status_t rc;
577  wanec_api_bufferload_t bufferload;
578 
579  memset(&bufferload, 0, sizeof(wanec_api_bufferload_t));
580  *out_buffer_id = -1;
581 
582  bufferload.buffer = filename;
583  bufferload.pcmlaw = pcmlaw;
584 
585  rc = wanec_api_buffer_load( device_name, libsng_hwec_verbosity_level, &bufferload );
586  if( rc ) {
587  return rc;
588  }
589 
590  *out_buffer_id = bufferload.buffer_id;
591 
592  return SANG_STATUS_SUCCESS;
593 }
int32_t sangoma_status_t
return status from sangoma APIs
Definition: libsangoma.h:338
sangoma_status_t _LIBSNG_CALL sangoma_hwec_audio_buffer_playout ( char *  device_name,
unsigned int  fe_chan_map,
unsigned char  port_map,
int  buffer_id,
int  start,
int  repeat_cnt,
int  duration 
)

Start playing out an audio buffer previously loaded by sangoma_hwec_audio_buffer_load().

Parameters
fe_chan_mapBitmap of channels (timeslots for Digital, lines for Analog) where the call will take effect.
port_mapPort where the buffer will be played out. This is the channel port on which the buffer will be played (WAN_EC_CHANNEL_PORT_SOUT or WAN_EC_CHANNEL_PORT_ROUT)
in_buffer_idID of the buffer which will be unloaded. The ID must be initialized by sangoma_hwec_audio_bufferload().
startIf 1 - start the play out, 0 - stop the play out
repeat_cntNumber of times to play out the same buffer
durationMaximum duration of the playout, in milliseconds. If it takes less then 'duration' to play out the whole buffer, it will be repeated to fill 'duration' amount of time. If 'duration' is set to non-zero, this parameter overrides the repeat_cnt flag.
Returns
SANG_STATUS_SUCCESS: success, or error status

Definition at line 677 of file libsangoma_hwec.c.

References start().

680 {
681  sangoma_status_t rc;
682  wanec_api_playout_t playout;
683 
684  memset(&playout, 0, sizeof(wanec_api_playout_t));
685 
686  playout.start = start;
687  playout.fe_chan = fe_chan_map;
688  playout.buffer_id = in_buffer_id;
689  playout.port = port;
690  playout.notifyonstop = 1;
691  playout.user_event_id = 0xA5; /* dummy value */
692  playout.repeat_cnt = repeat_cnt;
693  playout.duration = (duration) ? duration : cOCT6100_INVALID_VALUE; /* default is no duration */
694 
695  rc = wanec_api_playout( device_name, libsng_hwec_verbosity_level, &playout);
696 
697  return rc;
698 }
int32_t sangoma_status_t
return status from sangoma APIs
Definition: libsangoma.h:338
int start(sangoma_interface *sang_if)
Run the main sangoma interface hanlder code.
Definition: sample.cpp:153

Here is the call graph for this function:

void _LIBSNG_CALL sangoma_hwec_config_verbosity ( int  verbosity_level)

Set Verbosity level of EC API Driver and Library. The level controls amount of data printed to stdout and to wanpipelog.txt (Windows) or /var/log/messages (Linux) for diagnostic purposes.

Set Verbosity level of EC API. The level controls amount of data printed to stdout and wanpipelog.txt for diagnostic purposes.

Parameters
verbosity_levelValid values are from 0 to 3.
Returns
SANG_STATUS_SUCCESS: success, or error status
Parameters
verbosity_levelValid values are from 0 to 3.
Returns
SANG_STATUS_SUCCESS: success - the level was changed to 'verbosity_level', SANG_STATUS_INVALID_PARAMETER: error - the level was not changed because new level is invalid

Definition at line 712 of file libsangoma_hwec.c.

References SANG_STATUS_INVALID_PARAMETER, and SANG_STATUS_SUCCESS.

713 {
714  if (verbosity_level >= 0 || verbosity_level <= 3) {
715  libsng_hwec_verbosity_level = verbosity_level;
716  wanec_api_set_lib_verbosity(verbosity_level);
717  return SANG_STATUS_SUCCESS;
718  }
720 }
sangoma_status_t _LIBSNG_CALL sangoma_hwec_get_global_chip_statistics ( sng_fd_t  fd,
int *  hwec_api_return_code,
wanec_chip_stats_t *  wanec_chip_stats,
int  verbose,
int  reset 
)

Get Global statistics from EC chip.

Parameters
fddevice file descriptor
hwec_api_return_codewill contain one of WAN_EC_API_RC_x codes which are defined in wanec_iface_api.h
wanec_chip_statsstructure will be filled with HWEC channel statistics.
verboseFlag indicating to the Driver to print additional information about the command into Wanpipe Log file.
resetFlag to reset (flush) global statistics to zero, if set to 1.
Returns
SANG_STATUS_SUCCESS: success, or error status of IOCTL

Definition at line 793 of file libsangoma_hwec.c.

References SANG_STATUS_SUCCESS.

795 {
796 
797  sangoma_status_t err;
798  wan_ec_api_t ec_api;
799 
800  memset(&ec_api, 0x00, sizeof(ec_api));
801 
802  ec_api.cmd = WAN_EC_API_CMD_STATS_FULL;
803 
804  ec_api.verbose = verbose;
805 
806  /* indicate to Driver to get chip stats, not channel stats, by setting fe_chan_map to zero */
807  ec_api.fe_chan_map = 0;
808 
809  /* user may want to reset (clear) Chip statistics */
810  ec_api.u_chip_stats.reset = reset;
811 
812  err = sangoma_hwec_ioctl(fd, &ec_api);
813  if (err) {
814  /* error in IOCTL */
815  return err;
816  }
817 
818  /* copy stats from driver buffer to user buffer */
819  memcpy(wanec_chip_stats, &ec_api.u_chip_stats, sizeof(*wanec_chip_stats));
820 
821  *hwec_api_return_code = ec_api.err;
822 
823  return SANG_STATUS_SUCCESS;
824 
825 }
int32_t sangoma_status_t
return status from sangoma APIs
Definition: libsangoma.h:338
sangoma_status_t _LIBSNG_CALL sangoma_hwec_get_chip_image_info ( sng_fd_t  fd,
int *  hwec_api_return_code,
wanec_chip_image_t *  wanec_chip_image,
int  verbose 
)

Get information about Firmware Image of EC chip.

Parameters
fddevice file descriptor
hwec_api_return_codewill contain one of WAN_EC_API_RC_x codes which are defined in wanec_iface_api.h
wanec_chip_image_tstructure will be filled with HWEC channel statistics.
verboseFlag indicating to the Driver to print additional information about the command into Wanpipe Log file.
Returns
SANG_STATUS_SUCCESS: success, or error status of IOCTL

Definition at line 843 of file libsangoma_hwec.c.

References SANG_STATUS_SUCCESS.

845 {
846  sangoma_status_t err;
847  wan_ec_api_t ec_api;
848 
849  memset(&ec_api, 0x00, sizeof(ec_api));
850 
851  ec_api.cmd = WAN_EC_API_CMD_STATS_IMAGE;
852 
853  ec_api.verbose = verbose;
854 
855  /* driver will copy image information into wanec_chip_image->f_ChipImageInfo */
856  ec_api.u_chip_image.f_ChipImageInfo = wanec_chip_image->f_ChipImageInfo;
857 
858  err = sangoma_hwec_ioctl(fd, &ec_api);
859  if (err) {
860  /* error in IOCTL */
861  return err;
862  }
863 
864  *hwec_api_return_code = ec_api.err;
865 
866  return SANG_STATUS_SUCCESS;
867 }
int32_t sangoma_status_t
return status from sangoma APIs
Definition: libsangoma.h:338