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