adt_lec.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * ADT Line Echo Canceller Parameter Parsing
  3. *
  4. * Copyright (C) 2008-2009 Digium, Inc.
  5. *
  6. * Kevin P. Fleming <kpfleming@digium.com>
  7. *
  8. * All rights reserved.
  9. *
  10. */
  11. /*
  12. * See http://www.asterisk.org for more information about
  13. * the Asterisk project. Please do not directly contact
  14. * any of the maintainers of this project for assistance;
  15. * the project provides a web site, mailing lists and IRC
  16. * channels for your use.
  17. *
  18. * This program is free software, distributed under the terms of
  19. * the GNU General Public License Version 2 as published by the
  20. * Free Software Foundation. See the LICENSE file included with
  21. * this program for more details.
  22. */
  23. #ifndef _ADT_LEC_C
  24. #define _ADT_LEC_C
  25. #include <linux/ctype.h>
  26. static inline void adt_lec_init_defaults(struct adt_lec_params *params, __u32 tap_length)
  27. {
  28. params->tap_length = tap_length;
  29. params->nlp_type = 0;
  30. params->nlp_max_suppress = 0;
  31. params->nlp_threshold = 0;
  32. }
  33. static int adt_lec_parse_params(struct adt_lec_params *params,
  34. struct dahdi_echocanparams *ecp, struct dahdi_echocanparam *p)
  35. {
  36. unsigned int x;
  37. char *c;
  38. params->tap_length = ecp->tap_length;
  39. for (x = 0; x < ecp->param_count; x++) {
  40. for (c = p[x].name; *c; c++)
  41. *c = tolower(*c);
  42. if (!strcmp(p[x].name, "nlp_type")) {
  43. switch (p[x].value) {
  44. case ADT_LEC_NLP_OFF:
  45. case ADT_LEC_NLP_MUTE:
  46. case ADT_LEC_RANDOM_NOISE:
  47. case ADT_LEC_HOTH_NOISE:
  48. case ADT_LEC_SUPPRESS:
  49. params->nlp_type = p[x].value;
  50. break;
  51. default:
  52. return -EINVAL;
  53. }
  54. } else if (!strcmp(p[x].name, "nlp_thresh")) {
  55. params->nlp_threshold = p[x].value;
  56. } else if (!strcmp(p[x].name, "nlp_suppress")) {
  57. params->nlp_max_suppress = p[x].value;
  58. } else {
  59. return -EINVAL;
  60. }
  61. }
  62. return 0;
  63. }
  64. #endif /* _ADT_LEC_C */