Author: kpfleming
Date: Thu Feb 28 09:05:40 2008
New Revision: 3901
URL: http://svn.digium.com/view/zaptel?view=rev&rev=3901
a>
Log:
copy battery debounce improvements to this driver
Modified:
team/kpfleming/battery_alarms/kernel/wctdm24xxp/base.c
team/kpfleming/battery_alarms/kernel/wctdm24xxp/wctdm24xxp.h
Modified:
team/kpfleming/battery_alarms/kernel/wctdm24xxp/base.c
URL: http://svn.digium.com/view/zaptel/tea
m/kpfleming/battery_alarms/kernel/wctdm24xxp/base.c?view=dif
f&rev=3901&r1=3900&r2=3901
============================================================
==================
--- team/kpfleming/battery_alarms/kernel/wctdm24xxp/base.c
(original)
+++ team/kpfleming/battery_alarms/kernel/wctdm24xxp/base.c
Thu Feb 28 09:05:40 2008
 -1408,56
+1408,88 
}
if (abs(b) < battthresh) {
-#if 0
- if (fxo->battery == BATTERY_PRESENT)
- printk("Battery loss: %d (%d debounce)n", b,
fxo->battdebounce);
-#endif
- if ((fxo->battery != BATTERY_LOST) &&
- (fxo->battdebounce == 0)) {
- if (debug & DEBUG_CARD)
- printk("NO BATTERY on %d/%d!n",
wc->span.spanno, card + 1);
- fxo->battery = BATTERY_LOST;
+ /* possible existing states:
+ battery lost, no debounce timer
+ battery lost, debounce timer (going to battery
present)
+ battery present or unknown, no debounce timer
+ battery present or unknown, debounce timer (going to
battery lost)
+ */
+
+ if (fxo->battery == BATTERY_LOST) {
+ if (fxo->battdebounce) {
+ /* we were going to BATTERY_PRESENT, but battery was
lost again,
+ so clear the debounce timer */
+ fxo->battdebounce = 0;
+ }
+ } else {
+ if (fxo->battdebounce) {
+ /* going to BATTERY_LOST, see if we are there yet */
+ if (--fxo->battdebounce == 0) {
+ fxo->battery = BATTERY_LOST;
+ if (debug)
+ printk("NO BATTERY on %d/%d!n",
wc->span.spanno, card + 1);
#ifdef JAPAN
- if ((!wc->ohdebounce) && wc->offhook) {
- zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
- if (debug & DEBUG_CARD)
- printk("Signalled On Hookn");
+ if (!wc->ohdebounce && wc->offhook) {
+ zt_hooksig(&wc->chans[card],
ZT_RXSIG_ONHOOK);
+ if (debug)
+ printk("Signalled On Hookn");
#ifdef ZERO_BATT_RING
- wc->onhook++;
-#endif
+ wc->onhook++;
+#endif
+ }
+#else
+ zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
+ /* set the alarm timer, taking into account that part
of its time
+ period has already passed while debouncing occurred
*/
+ fxo->battalarm = battalarm - battdebounce;
+#endif
+ }
+ } else {
+ /* start the debounce timer to verify that battery has
been lost */
+ fxo->battdebounce = battdebounce;
}
+ }
+ } else {
+ /* possible existing states:
+ battery lost or unknown, no debounce timer
+ battery lost or unknown, debounce timer (going to
battery present)
+ battery present, no debounce timer
+ battery present, debounce timer (going to battery
lost)
+ */
+
+ if (fxo->battery == BATTERY_PRESENT) {
+ if (fxo->battdebounce) {
+ /* we were going to BATTERY_LOST, but battery appeared
again,
+ so clear the debounce timer */
+ fxo->battdebounce = 0;
+ }
+ } else {
+ if (fxo->battdebounce) {
+ /* going to BATTERY_PRESENT, see if we are there yet
*/
+ if (--fxo->battdebounce == 0) {
+ fxo->battery = BATTERY_PRESENT;
+ if (debug)
+ printk("BATTERY on %d/%d (%s)!n",
wc->span.spanno, card + 1,
+ (b < 0) ? "-" :
"+");
+#ifdef ZERO_BATT_RING
+ if (wc->onhook) {
+ wc->onhook = 0;
+ zt_hooksig(&wc->chans[card],
ZT_RXSIG_OFFHOOK);
+ if (debug)
+ printk("Signalled Off Hookn");
+ }
#else
- zt_hooksig(&wc->chans[card], ZT_RXSIG_ONHOOK);
-#endif
- /* set the alarm timer, taking into account that part of
its time
- period has already passed while debouncing occurred
*/
- fxo->battalarm = battalarm - battdebounce;
- fxo->battdebounce = battdebounce;
- } else if (fxo->battery == BATTERY_LOST)
- fxo->battdebounce = battdebounce;
- } else if (abs(b) > battthresh) {
- if ((fxo->battery != BATTERY_PRESENT) &&
- (fxo->battdebounce == 0)) {
- if (debug & DEBUG_CARD)
- printk("BATTERY on %d/%d (%s)!n",
wc->span.spanno, card + 1,
- (b < 0) ? "-" : "+");
-#ifdef ZERO_BATT_RING
- if (wc->onhook) {
- wc->onhook = 0;
- zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
- if (debug & DEBUG_CARD)
- printk("Signalled Off Hookn");
+ zt_hooksig(&wc->chans[card],
ZT_RXSIG_OFFHOOK);
+#endif
+ /* set the alarm timer, taking into account that part
of its time
+ period has already passed while debouncing occurred
*/
+ fxo->battalarm = battalarm - battdebounce;
+ }
+ } else {
+ /* start the debounce timer to verify that battery has
appeared */
+ fxo->battdebounce = battdebounce;
}
-#else
- zt_hooksig(&wc->chans[card], ZT_RXSIG_OFFHOOK);
-#endif
- fxo->battery = BATTERY_PRESENT;
- /* set the alarm timer, taking into account that part of
its time
- period has already passed while debouncing occurred
*/
- fxo->battalarm = battalarm - battdebounce;
- fxo->battdebounce = battdebounce;
- } else if (fxo->battery == BATTERY_PRESENT)
- fxo->battdebounce = battdebounce;
+ }
if (fxo->lastpol >= 0) {
if (b < 0) {
 -1471,12
+1503,6 
fxo->polaritydebounce = POLARITY_DEBOUNCE;
}
}
- } else {
- /* It's something else... */
- fxo->battdebounce = battdebounce;
- }
- if (fxo->battdebounce) {
- fxo->battdebounce--;
}
if (fxo->battalarm) {
 -2216,9
+2242,6 
if(debug)
printk("DEBUG fxotxgain:%i.%i
fxorxgain:%i.%in", (wctdm_getreg(wc, card, 38)/16) ?
-(wctdm_getreg(wc, card, 38) - 16) : wctdm_getreg(wc, card,
38), (wctdm_getreg(wc, card, 40)/16) ? -(wctdm_getreg(wc,
card, 40) - 16) : wctdm_getreg(wc, card, 40),
(wctdm_getreg(wc, card, 39)/16) ? -(wctdm_getreg(wc, card,
39) - 16): wctdm_getreg(wc, card, 39), (wctdm_getreg(wc,
card, 41)/16)?-(wctdm_getreg(wc, card, 41) - 16) :
wctdm_getreg(wc, card, 41));
- /* battery state still unknown */
- wc->mods[card].fxo.battery = BATTERY_UNKNOWN;
-
return 0;
}
Modified:
team/kpfleming/battery_alarms/kernel/wctdm24xxp/wctdm24xxp.h
URL: http://svn.digium.com/view/zapt
el/team/kpfleming/battery_alarms/kernel/wctdm24xxp/wctdm24xx
p.h?view=diff&rev=3901&r1=3900&r2=3901
============================================================
==================
---
team/kpfleming/battery_alarms/kernel/wctdm24xxp/wctdm24xxp.h
(original)
+++
team/kpfleming/battery_alarms/kernel/wctdm24xxp/wctdm24xxp.h
Thu Feb 28 09:05:40 2008
 -175,7
+175,7 
};
enum battery_state {
- BATTERY_UNKNOWN,
+ BATTERY_UNKNOWN = 0,
BATTERY_PRESENT,
BATTERY_LOST,
};
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.c
om--
zaptel-commits mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/zaptel-commits
a>
|