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

« back to all changes in this revision

Viewing changes to drivers/dahdi/wct4xxp/base.c

  • 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:
163
163
static int pedanticpci = 1;
164
164
static int debug=0;
165
165
static int timingcable = 0;
166
 
static int highestorder;
167
166
static int t1e1override = -1; //0xFF; // -1 = jumper; 0xFF = E1
168
167
static int j1mode = 0;
169
168
static int sigmode = FRMR_MODE_NO_ADDR_CMP;
284
283
        struct work_struct swork;
285
284
#endif  
286
285
        struct dahdi_chan *chans[32];           /* Individual channels */
 
286
        struct dahdi_echocan_state *ec[32];     /* Echocan state for each channel */
287
287
};
288
288
 
289
289
struct t4 {
346
346
 
347
347
#define T4_VPM_PRESENT (1 << 28)
348
348
 
349
 
 
350
349
#ifdef VPM_SUPPORT
351
350
static void t4_vpm400_init(struct t4 *wc);
352
351
static void t4_vpm450_init(struct t4 *wc);
353
352
static void t4_vpm_set_dtmf_threshold(struct t4 *wc, unsigned int threshold);
 
353
 
 
354
static int echocan_create(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
 
355
                           struct dahdi_echocanparam *p, struct dahdi_echocan_state **ec);
 
356
static void echocan_free(struct dahdi_chan *chan, struct dahdi_echocan_state *ec);
 
357
 
 
358
static const struct dahdi_echocan_features vpm400m_ec_features = {
 
359
        .NLP_automatic = 1,
 
360
        .CED_tx_detect = 1,
 
361
        .CED_rx_detect = 1,
 
362
};
 
363
 
 
364
static const struct dahdi_echocan_features vpm450m_ec_features = {
 
365
        .NLP_automatic = 1,
 
366
        .CED_tx_detect = 1,
 
367
        .CED_rx_detect = 1,
 
368
};
 
369
 
 
370
static const struct dahdi_echocan_ops vpm400m_ec_ops = {
 
371
        .name = "VPM400M",
 
372
        .echocan_free = echocan_free,
 
373
};
 
374
 
 
375
static const struct dahdi_echocan_ops vpm450m_ec_ops = {
 
376
        .name = "VPM450M",
 
377
        .echocan_free = echocan_free,
 
378
};
354
379
#endif
 
380
 
355
381
static void __set_clear(struct t4 *wc, int span);
356
382
static int t4_startup(struct dahdi_span *span);
357
383
static int t4_shutdown(struct dahdi_span *span);
1090
1116
        return unit;
1091
1117
}
1092
1118
 
1093
 
static int t4_echocan(struct dahdi_chan *chan, int eclen)
 
1119
static int echocan_create(struct dahdi_chan *chan, struct dahdi_echocanparams *ecp,
 
1120
                          struct dahdi_echocanparam *p, struct dahdi_echocan_state **ec)
1094
1121
{
1095
1122
        struct t4 *wc = chan->pvt;
 
1123
        struct t4_span *tspan = chan->span->pvt;
1096
1124
        int channel;
1097
 
        int unit;
1098
 
        
 
1125
        const struct dahdi_echocan_ops *ops;
 
1126
        const struct dahdi_echocan_features *features;
 
1127
 
1099
1128
        if (!wc->vpm)
1100
1129
                return -ENODEV;
1101
1130
 
1102
1131
        if (chan->span->offset >= vpmspans)
1103
1132
                return -ENODEV;
1104
1133
 
1105
 
        if (wc->t1e1)
1106
 
                channel = chan->chanpos;
1107
 
        else
1108
 
                channel = chan->chanpos + 4;
 
1134
        if (wc->vpm450m) {
 
1135
                ops = &vpm450m_ec_ops;
 
1136
                features = &vpm450m_ec_features;
 
1137
        } else {
 
1138
                ops = &vpm400m_ec_ops;
 
1139
                features = &vpm400m_ec_features;
 
1140
        }
 
1141
 
 
1142
        if (ecp->param_count > 0) {
 
1143
                printk(KERN_WARNING "%s echo canceller does not support parameters; failing request\n", ops->name);
 
1144
                return -EINVAL;
 
1145
        }
 
1146
 
 
1147
        *ec = tspan->ec[chan->chanpos - 1];
 
1148
        (*ec)->ops = ops;
 
1149
        (*ec)->features = *features;
 
1150
 
 
1151
        channel = wc->t1e1 ? chan->chanpos : chan->chanpos + 4;
 
1152
 
1109
1153
        if (wc->vpm450m) {
1110
1154
                channel = channel << 2;
1111
1155
                channel |= chan->span->offset;
1112
 
                if(debug & DEBUG_ECHOCAN) 
 
1156
                if (debug & DEBUG_ECHOCAN)
1113
1157
                        printk(KERN_DEBUG "echocan: Card is %d, Channel is %d, Span is %d, offset is %d length %d\n", 
1114
 
                                wc->num, chan->chanpos, chan->span->offset, channel, eclen);
1115
 
                vpm450m_setec(wc->vpm450m, channel, eclen);
1116
 
// Mark         msleep(10);
1117
 
//              msleep(100); // longer test
 
1158
                               wc->num, chan->chanpos, chan->span->offset, channel, ecp->tap_length);
 
1159
                vpm450m_setec(wc->vpm450m, channel, ecp->tap_length);
1118
1160
        } else {
1119
 
                unit = t4_vpm_unit(chan->span->offset, channel);
1120
 
                if(debug & DEBUG_ECHOCAN) 
 
1161
                int unit = t4_vpm_unit(chan->span->offset, channel);
 
1162
 
 
1163
                if (debug & DEBUG_ECHOCAN)
1121
1164
                        printk(KERN_DEBUG "echocan: Card is %d, Channel is %d, Span is %d, unit is %d, unit offset is %d length %d\n", 
1122
 
                                wc->num, chan->chanpos, chan->span->offset, unit, channel, eclen);
1123
 
                if (eclen)
1124
 
                        t4_vpm_out(wc,unit,channel,0x3e);
1125
 
                else
1126
 
                        t4_vpm_out(wc,unit,channel,0x01);
 
1165
                               wc->num, chan->chanpos, chan->span->offset, unit, channel, ecp->tap_length);
 
1166
                t4_vpm_out(wc, unit, channel, 0x3e);
1127
1167
        }
 
1168
 
1128
1169
        return 0;
1129
1170
}
 
1171
 
 
1172
static void echocan_free(struct dahdi_chan *chan, struct dahdi_echocan_state *ec)
 
1173
{
 
1174
        struct t4 *wc = chan->pvt;
 
1175
        int channel;
 
1176
 
 
1177
        memset(ec, 0, sizeof(*ec));
 
1178
 
 
1179
        channel = wc->t1e1 ? chan->chanpos : chan->chanpos + 4;
 
1180
 
 
1181
        if (wc->vpm450m) {
 
1182
                channel = channel << 2;
 
1183
                channel |= chan->span->offset;
 
1184
                if (debug & DEBUG_ECHOCAN)
 
1185
                        printk(KERN_DEBUG "echocan: Card is %d, Channel is %d, Span is %d, offset is %d length 0\n",
 
1186
                               wc->num, chan->chanpos, chan->span->offset, channel);
 
1187
                vpm450m_setec(wc->vpm450m, channel, 0);
 
1188
        } else {
 
1189
                int unit = t4_vpm_unit(chan->span->offset, channel);
 
1190
 
 
1191
                if (debug & DEBUG_ECHOCAN)
 
1192
                        printk(KERN_DEBUG "echocan: Card is %d, Channel is %d, Span is %d, unit is %d, unit offset is %d length 0\n",
 
1193
                               wc->num, chan->chanpos, chan->span->offset, unit, channel);
 
1194
                t4_vpm_out(wc, unit, channel, 0x01);
 
1195
        }
 
1196
}
1130
1197
#endif
1131
1198
 
1132
1199
static int t4_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long data)
1594
1661
                ts->span.hdlc_hard_xmit = t4_hdlc_hard_xmit;
1595
1662
                if (gen2) {
1596
1663
#ifdef VPM_SUPPORT
1597
 
                        ts->span.echocan = t4_echocan;
 
1664
                        if (vpmsupport)
 
1665
                                ts->span.echocan_create = echocan_create;
1598
1666
#endif                  
1599
1667
                        ts->span.dacs = t4_dacs;
1600
1668
                }
1795
1863
                                __t4_update_timing(cards[x]);
1796
1864
                        }
1797
1865
                }
1798
 
        } else
1799
 
                set_bit(T4_CHECK_TIMING, &cards[0]->checkflag);
 
1866
        }
 
1867
        __t4_update_timing(wc);
1800
1868
#endif  
1801
1869
        spin_unlock_irqrestore(&synclock, flags);
1802
1870
        return 0;
3495
3563
                        if (wc->tspans[x]->chans[y]) {
3496
3564
                                kfree(wc->tspans[x]->chans[y]);
3497
3565
                        }
 
3566
                        if (wc->tspans[x]->ec[y])
 
3567
                                kfree(wc->tspans[x]->ec[y]);
3498
3568
                }
3499
3569
                kfree(wc->tspans[x]);
3500
3570
        }
3631
3701
                                return -ENOMEM;
3632
3702
                        }
3633
3703
                        memset(wc->tspans[x]->chans[f], 0, sizeof(*wc->tspans[x]->chans[f]));
 
3704
                        if (!(wc->tspans[x]->ec[f] = kmalloc(sizeof(*wc->tspans[x]->ec[f]), GFP_KERNEL))) {
 
3705
                                free_wc(wc);
 
3706
                                return -ENOMEM;
 
3707
                        }
 
3708
                        memset(wc->tspans[x]->ec[f], 0, sizeof(*wc->tspans[x]->ec[f]));
3634
3709
                }
3635
3710
 
3636
3711
#ifdef ENABLE_WORKQUEUES
3659
3734
        }
3660
3735
        
3661
3736
        init_spans(wc);
3662
 
        
3663
 
        /* Launch cards as appropriate */
3664
 
        for (;;) {
3665
 
                /* Find a card to activate */
3666
 
                f = 0;
3667
 
                for (x = 0; cards[x]; x++) {
3668
 
                        if (cards[x]->order <= highestorder) {
3669
 
                                t4_launch(cards[x]);
3670
 
                                if (cards[x]->order == highestorder)
3671
 
                                        f = 1;
3672
 
                        }
 
3737
        /* get the current number of probed cards and run a slice of a tail
 
3738
         * insertion sort */
 
3739
        for (x = 0; x < MAX_T4_CARDS; x++) {
 
3740
                if (!cards[x+1])
 
3741
                        break;
 
3742
        }
 
3743
        for ( ; x > 0; x--) {
 
3744
                if (cards[x]->order < cards[x-1]->order) {
 
3745
                        struct t4 *tmp = cards[x];
 
3746
                        cards[x] = cards[x-1];
 
3747
                        cards[x-1] = tmp;
 
3748
                } else {
 
3749
                        /* if we're not moving it, we won't move any more
 
3750
                         * since all cards are sorted on addition */
 
3751
                        break;
3673
3752
                }
3674
 
                /* If we found at least one, increment the highest order and search again, otherwise stop */
3675
 
                if (f) 
3676
 
                        highestorder++;
3677
 
                else
3678
 
                        break;
3679
3753
        }
3680
3754
        
3681
3755
        printk(KERN_INFO "Found a Wildcard: %s\n", wc->variety);
3807
3881
        res = dahdi_pci_module(&t4_driver);
3808
3882
        if (res)
3809
3883
                return -ENODEV;
 
3884
        /* initialize cards since we have all of them */
 
3885
        /* warn for missing zero and duplicate numbers */
 
3886
        if (cards[0] && cards[0]->order != 0) {
 
3887
                printk(KERN_NOTICE "wct4xxp: Ident of first card is not zero (%d)\n",
 
3888
                        cards[0]->order);
 
3889
        }
 
3890
        for (res = 0; cards[res]; res++) {
 
3891
                /* warn the user of duplicate ident values it is probably
 
3892
                 * unintended */
 
3893
                if (debug && res < 15 && cards[res+1] &&
 
3894
                    cards[res]->order == cards[res+1]->order) {
 
3895
                        printk(KERN_NOTICE "wct4xxp: Duplicate ident value found (%d)\n",
 
3896
                                cards[res]->order);
 
3897
                }
 
3898
                t4_launch(cards[res]);
 
3899
        }
3810
3900
        return 0;
3811
3901
}
3812
3902