diff options
author | matteo <matteo@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2003-02-24 06:00:31 +0000 |
---|---|---|
committer | matteo <matteo@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2003-02-24 06:00:31 +0000 |
commit | b574418782d181cbd69a271704d8d3f3a3d38fb6 (patch) | |
tree | ad59f16dc60d92c9e6c8371347a9ab96c09ebc42 | |
parent | 29117b53a69aac3bd45cec6138603e36cd265fd0 (diff) |
Mon Feb 24 07:00:01 CET 2003
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@150 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rwxr-xr-x | tor2.c | 11 | ||||
-rwxr-xr-x | wct1xxp.c | 22 | ||||
-rwxr-xr-x | ztdummy.h | 14 | ||||
-rwxr-xr-x | ztmonitor.c | 36 |
4 files changed, 61 insertions, 22 deletions
@@ -648,8 +648,9 @@ static int tor2_rbsbits(struct zt_chan *chan, int bits) printk("Setting bits to %d on channel %s\n", bits, chan->name); #endif if (p->tor->cardtype == TYPE_E1) { /* do it E1 way */ - if (chan->chanpos > 30) return 0; /* cant do this for chan 31 */ + if (chan->chanpos == 16) return 0; n = chan->chanpos - 1; + if (chan->chanpos > 16) n--; k = p->span; b = (n % 15) + 1; c = p->tor->txsigs[k][b]; @@ -657,7 +658,7 @@ static int tor2_rbsbits(struct zt_chan *chan, int bits) c &= (15 << m); /* keep the other nibble */ c |= (bits & 15) << (4 - m); /* put our new nibble here */ p->tor->txsigs[k][b] = c; - /* output them into the chip */ + /* output them to the chip */ t1out(p->tor,k + 1,0x40 + b,c); return 0; } @@ -1190,10 +1191,10 @@ static void tor2_intr(int irq, void *dev_id, struct pt_regs *regs) for(k = 1; k <= 4; k++) { c = t1in(tor,k,0x31 + j); rxc = c & 15; - if (rxc != tor->spans[k - 1].chans[j + 15].rxsig) { + if (rxc != tor->spans[k - 1].chans[j + 16].rxsig) { /* Check for changes in received bits */ - if (!(tor->spans[k - 1].chans[j + 15].sig & ZT_SIG_CLEAR)) - zt_rbsbits(&tor->spans[k - 1].chans[j + 15], rxc); + if (!(tor->spans[k - 1].chans[j + 16].sig & ZT_SIG_CLEAR)) + zt_rbsbits(&tor->spans[k - 1].chans[j + 16], rxc); } rxc = c >> 4; if (rxc != tor->spans[k - 1].chans[j].rxsig) { @@ -555,13 +555,15 @@ static int t1xxp_rbsbits(struct zt_chan *chan, int bits) /* Byte offset */ spin_lock_irqsave(&wc->lock, flags); if (wc->ise1) { - if (chan->chanpos > 15) { - mask = (bits | (wc->chans[chan->chanpos - 15].txsig << 4)); - __t1_set_reg(wc, 0x41 + chan->chanpos - 15, mask); - } else if (chan->chanpos < 15) { - mask = ((bits << 4) | wc->chans[chan->chanpos + 15].txsig); - __t1_set_reg(wc, 0x41 + chan->chanpos, mask); + if (chan->chanpos < 16) { + mask = ((bits << 4) | wc->chans[chan->chanpos - 1 + 16].txsig); + __t1_set_reg(wc, 0x40 + chan->chanpos, mask); + } + else if (chan->chanpos > 16) { + mask = (bits | (wc->chans[chan->chanpos - 1 - 16].txsig << 4)); + __t1_set_reg(wc, 0x40 + chan->chanpos - 16, mask); } + wc->chans[chan->chanpos - 1].txsig = bits; } else { b = (chan->chanpos - 1) / 8; o = (chan->chanpos - 1) % 8; @@ -950,13 +952,13 @@ static void __t1xxp_check_sigbits(struct t1xxp *wc, int x) if (wc->ise1) { /* Read 5 registers at a time, loading 10 channels at a time */ - for (i = (x *5); i < (x * 5) + 5; i++) { + for (i = (x * 5); i < (x * 5) + 5; i++) { a = __t1_get_reg(wc, 0x31 + i); /* Get high channel in low bits */ rxs = (a & 0xf); - if (!(wc->chans[i+15].sig & ZT_SIG_CLEAR)) { - if (wc->chans[i+15].rxsig != rxs) - zt_rbsbits(&wc->chans[i+15], rxs); + if (!(wc->chans[i+16].sig & ZT_SIG_CLEAR)) { + if (wc->chans[i+16].rxsig != rxs) + zt_rbsbits(&wc->chans[i+16], rxs); } rxs = (a >> 4) & 0xf; if (!(wc->chans[i].sig & ZT_SIG_CLEAR)) { @@ -24,6 +24,11 @@ * */ +#include <linux/version.h> +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,19) +#define USB2420 +#endif + struct ztdummy { struct zt_span span; struct zt_chan chan; @@ -69,8 +74,13 @@ typedef struct { dma_addr_t setup_packet_dma; dma_addr_t transfer_buffer_dma; unsigned long started; - urb_t *next_queued_urb; // next queued urb for this EP - urb_t *prev_queued_urb; +#ifdef USB2420 + struct urb *next_queued_urb; // next queued urb for this EP + struct urb *prev_queued_urb; +#else + urb_t *next_queued_urb; + urb_t *prev_queued_urb; +#endif uhci_desc_t *bottom_qh; uhci_desc_t *next_qh; // next helper QH char use_loop; diff --git a/ztmonitor.c b/ztmonitor.c index da186ee..c226c33 100755 --- a/ztmonitor.c +++ b/ztmonitor.c @@ -51,6 +51,12 @@ #define FRAG_SIZE 8 +/* Put the ofh (output file handle) outside + * the main loop in case we ever add a signal + * hanlder. + */ +static FILE* ofh = 0; + static int stereo = 0; int audio_open(void) { @@ -191,18 +197,33 @@ int main(int argc, char *argv[]) int afd = -1, pfd, pfd2 = -1; short buf[8192]; short buf2[16384]; + char output_file[255]; int res, res2; int visual = 0; - int x; + int x,i; struct zt_confinfo zc; if ((argc < 2) || (atoi(argv[1]) < 1)) { - fprintf(stderr, "Usage: ztmonitor <channel num> [-v]\n"); + fprintf(stderr, "Usage: ztmonitor <channel num> [-v] [-f FILE]\n"); exit(1); } - if (argc > 2) { - if (!strcmp(argv[2], "-v")) - visual = 1; + for (i = 2; i < argc; ++i) { + if (!strcmp(argv[i], "-v")) + visual = 1; + else if (!strcmp(argv[i], "-f") && (i+1) < argc) { + ++i; /*we care about hte file name */ + if (strlen(argv[i]) < 255 ) { + strcpy(output_file, argv[i]); + fprintf(stderr, "Output to %s\n", output_file); + if ((ofh = fopen(output_file, "w"))<0) { + fprintf(stderr, "Could not open %s for writing: %s\n", output_file, strerror(errno)); + exit(0); + } + fprintf(stderr, "Run e.g., 'sox -r 8000 -s -w -c 1 file.raw file.wav' to convert.\n"); + } else { + fprintf(stderr, "File Name %s too long\n",argv[i+1]); + } + } } if (!visual) { /* Open audio */ @@ -253,7 +274,11 @@ int main(int argc, char *argv[]) visualize((short *)buf, (short *)buf2, res/2); else printf("Huh? res = %d, res2 = %d?\n", res, res2); + } else { + if (ofh) + fwrite(buf, 1, res, ofh); + if (stereo) { for (x=0;x<res;x++) buf2[x<<1] = buf2[(x<<1) + 1] = buf[x]; @@ -262,5 +287,6 @@ int main(int argc, char *argv[]) write(afd, buf, res); } } + if (ofh) fclose(ofh); /*Never Reached */ exit(0); } |