summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Meyerriecks <rmeyerreicks@digium.com>2010-08-16 21:43:02 +0000
committerRuss Meyerriecks <rmeyerreicks@digium.com>2010-08-16 21:43:02 +0000
commit3f5401d777a967f003c9edadb8686932065e884d (patch)
tree67547370a8221ffc8a605009dfa0c844c25167ea
parent8fd93ada52728ce6d237adac71e18162fa657339 (diff)
wctdm24xxp: Set the companding mode on the analog ports in fixup.
Fixes a regression from 9101 'wctdm24xxp: Added "auto" companding option' where the analog modules were not defaulted to alaw properly when a digital module is on an Hx8. This could result in very poor audio since the modules were providing ulaw data, but dahdi-base believed the audio was in alaw when converting to signed linear. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9143 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/wctdm24xxp/base.c59
1 files changed, 25 insertions, 34 deletions
diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c
index 5b67726..4a7f1fd 100644
--- a/drivers/dahdi/wctdm24xxp/base.c
+++ b/drivers/dahdi/wctdm24xxp/base.c
@@ -2632,21 +2632,6 @@ static int wctdm_init_voicedaa(struct wctdm *wc, int card, int fast, int manual,
/* Wait just a bit */
wait_just_a_bit(HZ/10);
- if (wc->companding == DAHDI_LAW_DEFAULT) {
- if (wc->digi_mods)
- /* If we have a BRI module, Auto set to alaw */
- wctdm_setreg(wc, card, 33, 0x20);
- else
- /* Auto set to ulaw */
- wctdm_setreg(wc, card, 33, 0x28);
- } else if (wc->companding == DAHDI_LAW_ALAW) {
- /* Force everything to alaw */
- wctdm_setreg(wc, card, 33, 0x20);
- } else {
- /* Auto set to ulaw */
- wctdm_setreg(wc, card, 33, 0x28);
- }
-
/* Set On-hook speed, Ringer impedence, and ringer threshold */
reg16 |= (fxo_modes[_opermode].ohs << 6);
reg16 |= (fxo_modes[_opermode].rz << 1);
@@ -2875,21 +2860,6 @@ static int wctdm_init_proslic(struct wctdm *wc, int card, int fast, int manual,
}
#endif
- if (wc->companding == DAHDI_LAW_DEFAULT) {
- if (wc->digi_mods)
- /* If we have a BRI module, Auto set to alaw */
- wctdm_setreg(wc, card, 1, 0x20);
- else
- /* Auto set to ulaw */
- wctdm_setreg(wc, card, 1, 0x28);
- } else if (wc->companding == DAHDI_LAW_ALAW) {
- /* Force everything to alaw */
- wctdm_setreg(wc, card, 1, 0x20);
- } else {
- /* Auto set to ulaw */
- wctdm_setreg(wc, card, 1, 0x28);
- }
-
/* U-Law 8-bit interface */
wctdm_proslic_set_ts(wc, card, card);
@@ -3868,6 +3838,22 @@ static struct wctdm_span *wctdm_init_span(struct wctdm *wc, int spanno, int chan
return s;
}
+/**
+ * should_set_alaw() - Should be called after all the spans are initialized.
+ *
+ * Returns true if the module companding should be set to alaw, otherwise
+ * false.
+ */
+static bool should_set_alaw(const struct wctdm *wc)
+{
+ if (DAHDI_LAW_DEFAULT == wc->companding)
+ return (wc->digi_mods > 0);
+ else if (DAHDI_LAW_ALAW == wc->companding)
+ return true;
+ else
+ return false;
+}
+
static void wctdm_fixup_analog_span(struct wctdm *wc, int spanno)
{
struct dahdi_span *s;
@@ -3884,14 +3870,19 @@ static void wctdm_fixup_analog_span(struct wctdm *wc, int spanno)
"s->chans[%d]=%p\n", x, y, wc->modtype[x],
y, s->chans[y]);
}
- if (wc->modtype[x] == MOD_TYPE_FXO)
+ if (wc->modtype[x] == MOD_TYPE_FXO) {
s->chans[y++]->sigcap = DAHDI_SIG_FXSKS | DAHDI_SIG_FXSLS | DAHDI_SIG_SF | DAHDI_SIG_CLEAR;
- else if (wc->modtype[x] == MOD_TYPE_FXS)
+ wctdm_setreg(wc, x, 33,
+ (should_set_alaw(wc) ? 0x20 : 0x28));
+ } else if (wc->modtype[x] == MOD_TYPE_FXS) {
s->chans[y++]->sigcap = DAHDI_SIG_FXOKS | DAHDI_SIG_FXOLS | DAHDI_SIG_FXOGS | DAHDI_SIG_SF | DAHDI_SIG_EM | DAHDI_SIG_CLEAR;
- else if (wc->modtype[x] == MOD_TYPE_QRV)
+ wctdm_setreg(wc, x, 1,
+ (should_set_alaw(wc) ? 0x20 : 0x28));
+ } else if (wc->modtype[x] == MOD_TYPE_QRV) {
s->chans[y++]->sigcap = DAHDI_SIG_SF | DAHDI_SIG_EM | DAHDI_SIG_CLEAR;
- else
+ } else {
s->chans[y++]->sigcap = 0;
+ }
}
for (x = 0; x < MAX_SPANS; x++) {