~xnox/debian/sid/dahdi-linux/nmu-659818

« back to all changes in this revision

Viewing changes to drivers/dahdi/ecdis.h

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell, Tzafrir Cohen, Victor Seva
  • Date: 2009-05-20 07:22:46 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090520072246-y1ba8ofc81ykgf8z
Tags: 1:2.2.0~dfsg~rc4-1
* New upstream release

[ Tzafrir Cohen ]
* NOT RELEASED YET
* Dropped qozap as wcb4xxp provides that functionality.
* New upstream RC.
* Actually build OpenVox drivers.
* opvxa1200.c: rev. 1.4.12.4 (battery fixes and such)
* Fix '${match}' in udev rules file (hardwire).
* no_firmware_download: Disable downloading a binary kernel module at 
  build time.

[ Victor Seva ]
* fix debian/watch. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
#include "biquad.h"
30
30
 
31
 
typedef struct
32
 
{
33
 
    biquad2_state_t notch;
34
 
    int notch_level;
35
 
    int channel_level;
36
 
    int tone_present;
37
 
    int tone_cycle_duration;
38
 
    int good_cycles;
39
 
    int hit;
40
 
} echo_can_disable_detector_state_t;
41
 
 
42
 
 
43
31
#define FALSE 0
44
32
#define TRUE (!FALSE)
45
33
 
65
53
/*- End of function --------------------------------------------------------*/
66
54
 
67
55
static inline int echo_can_disable_detector_update (echo_can_disable_detector_state_t *det,
68
 
                                      int16_t amp)
 
56
                                                    int16_t amp)
69
57
{
70
 
    int16_t notched;
71
 
    
 
58
        int16_t notched;
 
59
 
72
60
        notched = biquad2 (&det->notch, amp);
73
61
        /* Estimate the overall energy in the channel, and the energy in
74
62
           the notch (i.e. overall channel energy - tone energy => noise).
78
66
           blip every time the phase reverses */
79
67
        det->channel_level += ((abs(amp) - det->channel_level) >> 5);
80
68
        det->notch_level += ((abs(notched) - det->notch_level) >> 4);
81
 
        if (det->channel_level > 280)
82
 
        {
83
 
            /* There is adequate energy in the channel. Is it mostly at 2100Hz? */
84
 
            if (det->notch_level*6 < det->channel_level)
85
 
            {
86
 
                /* The notch says yes, so we have the tone. */
87
 
                if (!det->tone_present)
88
 
                {
89
 
                    /* Do we get a kick every 450+-25ms? */
90
 
                    if (det->tone_cycle_duration >= 425*8
91
 
                        &&
92
 
                        det->tone_cycle_duration <= 475*8)
93
 
                    {
94
 
                        det->good_cycles++;
95
 
                        if (det->good_cycles > 2)
96
 
                            det->hit = TRUE;
97
 
                    }
98
 
                    det->tone_cycle_duration = 0;
 
69
        if (det->channel_level >= 70) {
 
70
                /* There is adequate energy in the channel. Is it mostly at 2100Hz? */
 
71
                if (det->notch_level*6 < det->channel_level) {
 
72
                        det->tone_cycle_duration++;
 
73
                        /* The notch says yes, so we have the tone. */
 
74
                        if (!det->tone_present) {
 
75
                                /* Do we get a kick every 450+-25ms? */
 
76
                                if ((det->tone_cycle_duration >= (425 * 8)) &&
 
77
                                    (det->tone_cycle_duration <= (475 * 8))) {
 
78
                                        /* It's ANS/PR (CED with polarity reversals), so wait
 
79
                                           for at least three cycles before returning a hit. */
 
80
                                        det->good_cycles++;
 
81
                                        if (det->good_cycles > 2)
 
82
                                                det->hit = TRUE;
 
83
                                }
 
84
                                det->tone_cycle_duration = 0;
 
85
                                det->tone_present = TRUE;
 
86
                        } else if (det->tone_cycle_duration >= 600 * 8) {
 
87
                                /* It's ANS (CED without polarity reversals)
 
88
                                   so return a hit. */
 
89
                                det->hit = TRUE;
 
90
                        }
 
91
                } else {
 
92
                        det->tone_present = FALSE;
99
93
                }
100
 
                det->tone_present = TRUE;
101
 
            }
102
 
            else
103
 
            {
 
94
        } else {
104
95
                det->tone_present = FALSE;
105
 
            }
106
 
            det->tone_cycle_duration++;
107
 
        }
108
 
        else
109
 
        {
110
 
            det->tone_present = FALSE;
111
 
            det->tone_cycle_duration = 0;
112
 
            det->good_cycles = 0;
113
 
        }
114
 
    return  det->hit;
 
96
                det->tone_cycle_duration = 0;
 
97
                det->good_cycles = 0;
 
98
        }
 
99
 
 
100
        return  det->hit;
115
101
}
116
102
/*- End of function --------------------------------------------------------*/
117
103
/*- End of file ------------------------------------------------------------*/