Index: channels/chan_dahdi.c =================================================================== --- channels/chan_dahdi.c (revision 278424) +++ channels/chan_dahdi.c (working copy) @@ -2744,6 +2744,17 @@ p->subs[SUB_REAL].needringing = value; } +static void my_set_polarity(void *pvt, int value) +{ + struct dahdi_pvt *p = pvt; + + if (p->channel == CHAN_PSEUDO) + return; + + ioctl(p->subs[SUB_REAL].dfd, DAHDI_SETPOLARITY, &value); +} + + static int my_start(void *pvt) { struct dahdi_pvt *p = pvt; @@ -3461,6 +3472,7 @@ .set_pulsedial = my_set_pulsedial, .get_orig_dialstring = my_get_orig_dialstring, .set_needringing = my_set_needringing, + .set_polarity = my_set_polarity, }; /*! Round robin search locations. */ Index: channels/sig_analog.c =================================================================== --- channels/sig_analog.c (revision 278424) +++ channels/sig_analog.c (working copy) @@ -530,6 +530,13 @@ } } +static void analog_set_polarity(struct analog_pvt *p, int value) +{ + if (p->calls->set_polarity) { + return p->calls->set_polarity(p->chan_pvt, value); + } +} + static int analog_dsp_set_digitmode(struct analog_pvt *p, enum analog_dsp_digitmode mode) { if (p->calls->dsp_set_digitmode) { @@ -1264,6 +1271,8 @@ case ANALOG_SIG_FXOGS: case ANALOG_SIG_FXOLS: case ANALOG_SIG_FXOKS: + ast_verb(0, "ALEC FXS analog hangup %s\n", ast->name); + analog_set_polarity(p, 0 ); /* If they're off hook, try playing congestion */ if (analog_is_off_hook(p)) { analog_play_tone(p, ANALOG_SUB_REAL, ANALOG_TONE_CONGESTION); @@ -1274,6 +1283,7 @@ case ANALOG_SIG_FXSGS: case ANALOG_SIG_FXSLS: case ANALOG_SIG_FXSKS: + ast_verb(0, "ALEC FXO analog hangup %s\n", ast->name); /* Make sure we're not made available for at least two seconds assuming we were actually used for an inbound or outbound call. */ if (ast->_state != AST_STATE_RESERVED) { @@ -1357,9 +1367,23 @@ p->owner = p->subs[ANALOG_SUB_REAL].owner; } } - if ((p->sig == ANALOG_SIG_FXSLS) || (p->sig == ANALOG_SIG_FXSKS) || (p->sig == ANALOG_SIG_FXSGS)) { + + switch (p->sig) { + case ANALOG_SIG_FXSLS: + case ANALOG_SIG_FXSKS: + case ANALOG_SIG_FXSGS: + ast_verb(0, "ALEC FXO analog answer %s\n", ast->name); analog_set_echocanceller(p, 1); analog_train_echocanceller(p); + break; + case ANALOG_SIG_FXOLS: + case ANALOG_SIG_FXOKS: + case ANALOG_SIG_FXOGS: + ast_verb(0, "ALEC FXS analog answer %s\n", ast->name); + analog_set_polarity(p, 1 ); + break; + default: + break; } break; default: Index: channels/sig_analog.h =================================================================== --- channels/sig_analog.h (revision 278424) +++ channels/sig_analog.h (working copy) @@ -147,6 +147,7 @@ /*! \brief Set channel off hook */ int (* const off_hook)(void *pvt); void (* const set_needringing)(void *pvt, int value); + void (* const set_polarity)(void *pvt, int value); /* We're assuming that we're going to only wink on ANALOG_SUB_REAL - even though in the code there's an argument to the index * function */ int (* const wink)(void *pvt, enum analog_sub sub);