aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn
diff options
context:
space:
mode:
authorKarsten Keil <keil@b1-systems.de>2009-07-08 14:31:42 -0400
committerKarsten Keil <keil@b1-systems.de>2009-07-25 14:16:01 -0400
commitc38fc3bc2ecddd4f5278131603e6964cbed071b2 (patch)
tree3821cf2fc6226375bbbf8c338316eef33f5b899d /drivers/isdn
parent6bd4bcd3cd8affc09eaee7efbc037f65f4a71501 (diff)
ISDN: Add support for none reverse bitstreams to isdnhdc
The original isdnhdlc code was developed for devices which had reversed bitorder in the byte stream. Adding code to handle normal bitstreams as well. Signed-off-by: Karsten Keil <keil@b1-systems.de>
Diffstat (limited to 'drivers/isdn')
-rw-r--r--drivers/isdn/hisax/st5481_b.c5
-rw-r--r--drivers/isdn/hisax/st5481_d.c2
-rw-r--r--drivers/isdn/hisax/st5481_usb.c11
-rw-r--r--drivers/isdn/i4l/isdnhdlc.c70
4 files changed, 47 insertions, 41 deletions
diff --git a/drivers/isdn/hisax/st5481_b.c b/drivers/isdn/hisax/st5481_b.c
index 0074b600a0ef..95b1cdd97958 100644
--- a/drivers/isdn/hisax/st5481_b.c
+++ b/drivers/isdn/hisax/st5481_b.c
@@ -218,7 +218,10 @@ static void st5481B_mode(struct st5481_bcs *bcs, int mode)
218 if (bcs->mode != L1_MODE_NULL) { 218 if (bcs->mode != L1_MODE_NULL) {
219 // Open the B channel 219 // Open the B channel
220 if (bcs->mode != L1_MODE_TRANS) { 220 if (bcs->mode != L1_MODE_TRANS) {
221 isdnhdlc_out_init(&b_out->hdlc_state, 0, bcs->mode == L1_MODE_HDLC_56K); 221 u32 features = HDLC_BITREVERSE;
222 if (bcs->mode == L1_MODE_HDLC_56K)
223 features |= HDLC_56KBIT;
224 isdnhdlc_out_init(&b_out->hdlc_state, features);
222 } 225 }
223 st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2, NULL, NULL); 226 st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2, NULL, NULL);
224 227
diff --git a/drivers/isdn/hisax/st5481_d.c b/drivers/isdn/hisax/st5481_d.c
index 077991c1cd05..39e8e49cfd2d 100644
--- a/drivers/isdn/hisax/st5481_d.c
+++ b/drivers/isdn/hisax/st5481_d.c
@@ -417,7 +417,7 @@ static void dout_start_xmit(struct FsmInst *fsm, int event, void *arg)
417 417
418 DBG(2,"len=%d",skb->len); 418 DBG(2,"len=%d",skb->len);
419 419
420 isdnhdlc_out_init(&d_out->hdlc_state, 1, 0); 420 isdnhdlc_out_init(&d_out->hdlc_state, HDLC_DCHANNEL | HDLC_BITREVERSE);
421 421
422 if (test_and_set_bit(buf_nr, &d_out->busy)) { 422 if (test_and_set_bit(buf_nr, &d_out->busy)) {
423 WARNING("ep %d urb %d busy %#lx", EP_D_OUT, buf_nr, d_out->busy); 423 WARNING("ep %d urb %d busy %#lx", EP_D_OUT, buf_nr, d_out->busy);
diff --git a/drivers/isdn/hisax/st5481_usb.c b/drivers/isdn/hisax/st5481_usb.c
index 2b3a055059ea..10d41c5d73ed 100644
--- a/drivers/isdn/hisax/st5481_usb.c
+++ b/drivers/isdn/hisax/st5481_usb.c
@@ -637,10 +637,13 @@ void st5481_in_mode(struct st5481_in *in, int mode)
637 usb_unlink_urb(in->urb[1]); 637 usb_unlink_urb(in->urb[1]);
638 638
639 if (in->mode != L1_MODE_NULL) { 639 if (in->mode != L1_MODE_NULL) {
640 if (in->mode != L1_MODE_TRANS) 640 if (in->mode != L1_MODE_TRANS) {
641 isdnhdlc_rcv_init(&in->hdlc_state, 641 u32 features = HDLC_BITREVERSE;
642 in->mode == L1_MODE_HDLC_56K); 642
643 643 if (in->mode == L1_MODE_HDLC_56K)
644 features |= HDLC_56KBIT;
645 isdnhdlc_rcv_init(&in->hdlc_state, features);
646 }
644 st5481_usb_pipe_reset(in->adapter, in->ep, NULL, NULL); 647 st5481_usb_pipe_reset(in->adapter, in->ep, NULL, NULL);
645 st5481_usb_device_ctrl_msg(in->adapter, in->counter, 648 st5481_usb_device_ctrl_msg(in->adapter, in->counter,
646 in->packet_size, 649 in->packet_size,
diff --git a/drivers/isdn/i4l/isdnhdlc.c b/drivers/isdn/i4l/isdnhdlc.c
index b80e55ab8914..df345ce73f48 100644
--- a/drivers/isdn/i4l/isdnhdlc.c
+++ b/drivers/isdn/i4l/isdnhdlc.c
@@ -2,6 +2,7 @@
2 * isdnhdlc.c -- General purpose ISDN HDLC decoder. 2 * isdnhdlc.c -- General purpose ISDN HDLC decoder.
3 * 3 *
4 * Copyright (C) 4 * Copyright (C)
5 * 2009 Karsten Keil <keil@b1-systems.de>
5 * 2002 Wolfgang Mües <wolfgang@iksw-muees.de> 6 * 2002 Wolfgang Mües <wolfgang@iksw-muees.de>
6 * 2001 Frode Isaksen <fisaksen@bewan.com> 7 * 2001 Frode Isaksen <fisaksen@bewan.com>
7 * 2001 Kai Germaschewski <kai.germaschewski@gmx.de> 8 * 2001 Kai Germaschewski <kai.germaschewski@gmx.de>
@@ -25,6 +26,7 @@
25#include <linux/init.h> 26#include <linux/init.h>
26#include <linux/crc-ccitt.h> 27#include <linux/crc-ccitt.h>
27#include <linux/isdn/hdlc.h> 28#include <linux/isdn/hdlc.h>
29#include <linux/bitrev.h>
28 30
29/*-------------------------------------------------------------------*/ 31/*-------------------------------------------------------------------*/
30 32
@@ -48,35 +50,21 @@ enum {
48 HDLC_SENDFLAG_B1A6, HDLC_SENDFLAG_B7, STOPPED 50 HDLC_SENDFLAG_B1A6, HDLC_SENDFLAG_B7, STOPPED
49}; 51};
50 52
51void isdnhdlc_rcv_init(struct isdnhdlc_vars *hdlc, int do_adapt56) 53void isdnhdlc_rcv_init(struct isdnhdlc_vars *hdlc, u32 features)
52{ 54{
53 hdlc->bit_shift = 0; 55 memset(hdlc, 0, sizeof(struct isdnhdlc_vars));
54 hdlc->hdlc_bits1 = 0;
55 hdlc->data_bits = 0;
56 hdlc->ffbit_shift = 0;
57 hdlc->data_received = 0;
58 hdlc->state = HDLC_GET_DATA; 56 hdlc->state = HDLC_GET_DATA;
59 hdlc->do_adapt56 = do_adapt56; 57 if (features & HDLC_56KBIT)
60 hdlc->dchannel = 0; 58 hdlc->do_adapt56 = 1;
61 hdlc->crc = 0; 59 if (features & HDLC_BITREVERSE)
62 hdlc->cbin = 0; 60 hdlc->do_bitreverse = 1;
63 hdlc->shift_reg = 0;
64 hdlc->ffvalue = 0;
65 hdlc->dstpos = 0;
66} 61}
67EXPORT_SYMBOL(isdnhdlc_out_init); 62EXPORT_SYMBOL(isdnhdlc_out_init);
68 63
69void isdnhdlc_out_init(struct isdnhdlc_vars *hdlc, int is_d_channel, 64void isdnhdlc_out_init(struct isdnhdlc_vars *hdlc, u32 features)
70 int do_adapt56)
71{ 65{
72 hdlc->bit_shift = 0; 66 memset(hdlc, 0, sizeof(struct isdnhdlc_vars));
73 hdlc->hdlc_bits1 = 0; 67 if (features & HDLC_DCHANNEL) {
74 hdlc->data_bits = 0;
75 hdlc->ffbit_shift = 0;
76 hdlc->data_received = 0;
77 hdlc->do_closing = 0;
78 hdlc->ffvalue = 0;
79 if (is_d_channel) {
80 hdlc->dchannel = 1; 68 hdlc->dchannel = 1;
81 hdlc->state = HDLC_SEND_FIRST_FLAG; 69 hdlc->state = HDLC_SEND_FIRST_FLAG;
82 } else { 70 } else {
@@ -85,16 +73,13 @@ void isdnhdlc_out_init(struct isdnhdlc_vars *hdlc, int is_d_channel,
85 hdlc->ffvalue = 0x7e; 73 hdlc->ffvalue = 0x7e;
86 } 74 }
87 hdlc->cbin = 0x7e; 75 hdlc->cbin = 0x7e;
88 hdlc->bit_shift = 0; 76 if (features & HDLC_56KBIT) {
89 if (do_adapt56) {
90 hdlc->do_adapt56 = 1; 77 hdlc->do_adapt56 = 1;
91 hdlc->data_bits = 0;
92 hdlc->state = HDLC_SENDFLAG_B0; 78 hdlc->state = HDLC_SENDFLAG_B0;
93 } else { 79 } else
94 hdlc->do_adapt56 = 0;
95 hdlc->data_bits = 8; 80 hdlc->data_bits = 8;
96 } 81 if (features & HDLC_BITREVERSE)
97 hdlc->shift_reg = 0; 82 hdlc->do_bitreverse = 1;
98} 83}
99EXPORT_SYMBOL(isdnhdlc_rcv_init); 84EXPORT_SYMBOL(isdnhdlc_rcv_init);
100 85
@@ -188,7 +173,11 @@ int isdnhdlc_decode(struct isdnhdlc_vars *hdlc, const u8 *src, int slen,
188 173
189 while (slen > 0) { 174 while (slen > 0) {
190 if (hdlc->bit_shift == 0) { 175 if (hdlc->bit_shift == 0) {
191 hdlc->cbin = *src++; 176 /* the code is for bitreverse streams */
177 if (hdlc->do_bitreverse == 0)
178 hdlc->cbin = bitrev8(*src++);
179 else
180 hdlc->cbin = *src++;
192 slen--; 181 slen--;
193 hdlc->bit_shift = 8; 182 hdlc->bit_shift = 8;
194 if (hdlc->do_adapt56) 183 if (hdlc->do_adapt56)
@@ -405,12 +394,15 @@ int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen,
405 case STOPPED: 394 case STOPPED:
406 while (dsize--) 395 while (dsize--)
407 *dst++ = 0xff; 396 *dst++ = 0xff;
408
409 return dsize; 397 return dsize;
410 case HDLC_SEND_FAST_FLAG: 398 case HDLC_SEND_FAST_FLAG:
411 hdlc->do_closing = 0; 399 hdlc->do_closing = 0;
412 if (slen == 0) { 400 if (slen == 0) {
413 *dst++ = hdlc->ffvalue; 401 /* the code is for bitreverse streams */
402 if (hdlc->do_bitreverse == 0)
403 *dst++ = bitrev8(hdlc->ffvalue);
404 else
405 *dst++ = hdlc->ffvalue;
414 len++; 406 len++;
415 dsize--; 407 dsize--;
416 break; 408 break;
@@ -594,7 +586,11 @@ int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen,
594 hdlc->cbin = 0x7e; 586 hdlc->cbin = 0x7e;
595 hdlc->state = HDLC_SEND_FIRST_FLAG; 587 hdlc->state = HDLC_SEND_FIRST_FLAG;
596 } else { 588 } else {
597 *dst++ = hdlc->cbin; 589 /* the code is for bitreverse streams */
590 if (hdlc->do_bitreverse == 0)
591 *dst++ = bitrev8(hdlc->cbin);
592 else
593 *dst++ = hdlc->cbin;
598 hdlc->bit_shift = 0; 594 hdlc->bit_shift = 0;
599 hdlc->data_bits = 0; 595 hdlc->data_bits = 0;
600 len++; 596 len++;
@@ -612,7 +608,11 @@ int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen,
612 } 608 }
613 } 609 }
614 if (hdlc->data_bits == 8) { 610 if (hdlc->data_bits == 8) {
615 *dst++ = hdlc->cbin; 611 /* the code is for bitreverse streams */
612 if (hdlc->do_bitreverse == 0)
613 *dst++ = bitrev8(hdlc->cbin);
614 else
615 *dst++ = hdlc->cbin;
616 hdlc->data_bits = 0; 616 hdlc->data_bits = 0;
617 len++; 617 len++;
618 dsize--; 618 dsize--;