diff options
Diffstat (limited to 'drivers/isdn/hisax/st5481_b.c')
-rw-r--r-- | drivers/isdn/hisax/st5481_b.c | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/drivers/isdn/hisax/st5481_b.c b/drivers/isdn/hisax/st5481_b.c index ed4bc564dc6..40984916583 100644 --- a/drivers/isdn/hisax/st5481_b.c +++ b/drivers/isdn/hisax/st5481_b.c @@ -4,7 +4,7 @@ * Author Frode Isaksen * Copyright 2001 by Frode Isaksen <fisaksen@bewan.com> * 2001 by Kai Germaschewski <kai.germaschewski@gmx.de> - * + * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * @@ -27,33 +27,33 @@ static inline void B_L1L2(struct st5481_bcs *bcs, int pr, void *arg) /* * Encode and transmit next frame. */ -static void usb_b_out(struct st5481_bcs *bcs,int buf_nr) +static void usb_b_out(struct st5481_bcs *bcs, int buf_nr) { struct st5481_b_out *b_out = &bcs->b_out; struct st5481_adapter *adapter = bcs->adapter; struct urb *urb; - unsigned int packet_size,offset; - int len,buf_size,bytes_sent; + unsigned int packet_size, offset; + int len, buf_size, bytes_sent; int i; struct sk_buff *skb; - + if (test_and_set_bit(buf_nr, &b_out->busy)) { - DBG(4,"ep %d urb %d busy",(bcs->channel+1)*2,buf_nr); + DBG(4, "ep %d urb %d busy", (bcs->channel + 1) * 2, buf_nr); return; } urb = b_out->urb[buf_nr]; // Adjust isoc buffer size according to flow state - if(b_out->flow_event & (OUT_DOWN | OUT_UNDERRUN)) { - buf_size = NUM_ISO_PACKETS_B*SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST; + if (b_out->flow_event & (OUT_DOWN | OUT_UNDERRUN)) { + buf_size = NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST; packet_size = SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST; - DBG(4,"B%d,adjust flow,add %d bytes",bcs->channel+1,B_FLOW_ADJUST); - } else if(b_out->flow_event & OUT_UP){ - buf_size = NUM_ISO_PACKETS_B*SIZE_ISO_PACKETS_B_OUT - B_FLOW_ADJUST; + DBG(4, "B%d,adjust flow,add %d bytes", bcs->channel + 1, B_FLOW_ADJUST); + } else if (b_out->flow_event & OUT_UP) { + buf_size = NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT - B_FLOW_ADJUST; packet_size = SIZE_ISO_PACKETS_B_OUT - B_FLOW_ADJUST; - DBG(4,"B%d,adjust flow,remove %d bytes",bcs->channel+1,B_FLOW_ADJUST); + DBG(4, "B%d,adjust flow,remove %d bytes", bcs->channel + 1, B_FLOW_ADJUST); } else { - buf_size = NUM_ISO_PACKETS_B*SIZE_ISO_PACKETS_B_OUT; + buf_size = NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT; packet_size = 8; } b_out->flow_event = 0; @@ -62,15 +62,15 @@ static void usb_b_out(struct st5481_bcs *bcs,int buf_nr) while (len < buf_size) { if ((skb = b_out->tx_skb)) { DBG_SKB(0x100, skb); - DBG(4,"B%d,len=%d",bcs->channel+1,skb->len); - - if (bcs->mode == L1_MODE_TRANS) { + DBG(4, "B%d,len=%d", bcs->channel + 1, skb->len); + + if (bcs->mode == L1_MODE_TRANS) { bytes_sent = buf_size - len; if (skb->len < bytes_sent) bytes_sent = skb->len; { /* swap tx bytes to get hearable audio data */ register unsigned char *src = skb->data; - register unsigned char *dest = urb->transfer_buffer+len; + register unsigned char *dest = urb->transfer_buffer + len; register unsigned int count; for (count = 0; count < bytes_sent; count++) *dest++ = bitrev8(*src++); @@ -79,7 +79,7 @@ static void usb_b_out(struct st5481_bcs *bcs,int buf_nr) } else { len += isdnhdlc_encode(&b_out->hdlc_state, skb->data, skb->len, &bytes_sent, - urb->transfer_buffer+len, buf_size-len); + urb->transfer_buffer + len, buf_size-len); } skb_pull(skb, bytes_sent); @@ -90,21 +90,21 @@ static void usb_b_out(struct st5481_bcs *bcs,int buf_nr) B_L1L2(bcs, PH_DATA | CONFIRM, (void *)(unsigned long) skb->truesize); dev_kfree_skb_any(skb); -/* if (!(bcs->tx_skb = skb_dequeue(&bcs->sq))) { */ -/* st5481B_sched_event(bcs, B_XMTBUFREADY); */ -/* } */ +/* if (!(bcs->tx_skb = skb_dequeue(&bcs->sq))) { */ +/* st5481B_sched_event(bcs, B_XMTBUFREADY); */ +/* } */ } } else { if (bcs->mode == L1_MODE_TRANS) { - memset(urb->transfer_buffer+len, 0xff, buf_size-len); + memset(urb->transfer_buffer + len, 0xff, buf_size-len); len = buf_size; } else { // Send flags len += isdnhdlc_encode(&b_out->hdlc_state, NULL, 0, &bytes_sent, - urb->transfer_buffer+len, buf_size-len); + urb->transfer_buffer + len, buf_size-len); } - } + } } // Prepare the URB @@ -118,7 +118,7 @@ static void usb_b_out(struct st5481_bcs *bcs,int buf_nr) urb->number_of_packets = i; urb->dev = adapter->usb_dev; - DBG_ISO_PACKET(0x200,urb); + DBG_ISO_PACKET(0x200, urb); SUBMIT_URB(urb, GFP_NOIO); } @@ -131,12 +131,12 @@ static void st5481B_start_xfer(void *context) { struct st5481_bcs *bcs = context; - DBG(4,"B%d",bcs->channel+1); + DBG(4, "B%d", bcs->channel + 1); // Start transmitting (flags or data) on B channel - usb_b_out(bcs,0); - usb_b_out(bcs,1); + usb_b_out(bcs, 0); + usb_b_out(bcs, 1); } /* @@ -158,7 +158,7 @@ static void led_blink(struct st5481_adapter *adapter) } else { leds &= ~GREEN_LED; } - + st5481_usb_device_ctrl_msg(adapter, GPIO_OUT, leds, NULL, NULL); } @@ -168,27 +168,27 @@ static void usb_b_out_complete(struct urb *urb) struct st5481_b_out *b_out = &bcs->b_out; struct st5481_adapter *adapter = bcs->adapter; int buf_nr; - + buf_nr = get_buf_nr(b_out->urb, urb); test_and_clear_bit(buf_nr, &b_out->busy); if (unlikely(urb->status < 0)) { switch (urb->status) { - case -ENOENT: - case -ESHUTDOWN: - case -ECONNRESET: - DBG(4,"urb killed status %d", urb->status); - return; // Give up - default: - WARNING("urb status %d",urb->status); - if (b_out->busy == 0) { - st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2 | USB_DIR_OUT, NULL, NULL); - } - break; + case -ENOENT: + case -ESHUTDOWN: + case -ECONNRESET: + DBG(4, "urb killed status %d", urb->status); + return; // Give up + default: + WARNING("urb status %d", urb->status); + if (b_out->busy == 0) { + st5481_usb_pipe_reset(adapter, (bcs->channel + 1) * 2 | USB_DIR_OUT, NULL, NULL); + } + break; } } - usb_b_out(bcs,buf_nr); + usb_b_out(bcs, buf_nr); if (adapter->number_of_leds == 2) led_blink(adapter); @@ -202,7 +202,7 @@ static void st5481B_mode(struct st5481_bcs *bcs, int mode) struct st5481_b_out *b_out = &bcs->b_out; struct st5481_adapter *adapter = bcs->adapter; - DBG(4,"B%d,mode=%d", bcs->channel + 1, mode); + DBG(4, "B%d,mode=%d", bcs->channel + 1, mode); if (bcs->mode == mode) return; @@ -223,14 +223,14 @@ static void st5481B_mode(struct st5481_bcs *bcs, int mode) features |= HDLC_56KBIT; isdnhdlc_out_init(&b_out->hdlc_state, features); } - st5481_usb_pipe_reset(adapter, (bcs->channel+1)*2, NULL, NULL); - + st5481_usb_pipe_reset(adapter, (bcs->channel + 1) * 2, NULL, NULL); + // Enable B channel interrupts - st5481_usb_device_ctrl_msg(adapter, FFMSK_B1+(bcs->channel*2), - OUT_UP+OUT_DOWN+OUT_UNDERRUN, NULL, NULL); + st5481_usb_device_ctrl_msg(adapter, FFMSK_B1 + (bcs->channel * 2), + OUT_UP + OUT_DOWN + OUT_UNDERRUN, NULL, NULL); // Enable B channel FIFOs - st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel*2), 32, st5481B_start_xfer, bcs); + st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel * 2), 32, st5481B_start_xfer, bcs); if (adapter->number_of_leds == 4) { if (bcs->channel == 0) { adapter->leds |= B1_LED; @@ -240,10 +240,10 @@ static void st5481B_mode(struct st5481_bcs *bcs, int mode) } } else { // Disble B channel interrupts - st5481_usb_device_ctrl_msg(adapter, FFMSK_B1+(bcs->channel*2), 0, NULL, NULL); + st5481_usb_device_ctrl_msg(adapter, FFMSK_B1+(bcs->channel * 2), 0, NULL, NULL); // Disable B channel FIFOs - st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel*2), 0, NULL, NULL); + st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel * 2), 0, NULL, NULL); if (adapter->number_of_leds == 4) { if (bcs->channel == 0) { @@ -258,7 +258,7 @@ static void st5481B_mode(struct st5481_bcs *bcs, int mode) dev_kfree_skb_any(b_out->tx_skb); b_out->tx_skb = NULL; } - + } } @@ -268,9 +268,9 @@ static int st5481_setup_b_out(struct st5481_bcs *bcs) struct usb_interface *intf; struct usb_host_interface *altsetting = NULL; struct usb_host_endpoint *endpoint; - struct st5481_b_out *b_out = &bcs->b_out; + struct st5481_b_out *b_out = &bcs->b_out; - DBG(4,""); + DBG(4, ""); intf = usb_ifnum_to_if(dev, 0); if (intf) @@ -281,11 +281,11 @@ static int st5481_setup_b_out(struct st5481_bcs *bcs) // Allocate URBs and buffers for the B channel out endpoint = &altsetting->endpoint[EP_B1_OUT - 1 + bcs->channel * 2]; - DBG(4,"endpoint address=%02x,packet size=%d", + DBG(4, "endpoint address=%02x,packet size=%d", endpoint->desc.bEndpointAddress, le16_to_cpu(endpoint->desc.wMaxPacketSize)); // Allocate memory for 8000bytes/sec + extra bytes if underrun - return st5481_setup_isocpipes(b_out->urb, dev, + return st5481_setup_isocpipes(b_out->urb, dev, usb_sndisocpipe(dev, endpoint->desc.bEndpointAddress), NUM_ISO_PACKETS_B, SIZE_ISO_PACKETS_B_OUT, NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST, @@ -296,7 +296,7 @@ static void st5481_release_b_out(struct st5481_bcs *bcs) { struct st5481_b_out *b_out = &bcs->b_out; - DBG(4,""); + DBG(4, ""); st5481_release_isocpipes(b_out->urb); } @@ -305,7 +305,7 @@ int st5481_setup_b(struct st5481_bcs *bcs) { int retval; - DBG(4,""); + DBG(4, ""); retval = st5481_setup_b_out(bcs); if (retval) @@ -324,9 +324,9 @@ int st5481_setup_b(struct st5481_bcs *bcs) return 0; - err_b_out: +err_b_out: st5481_release_b_out(bcs); - err: +err: return retval; } @@ -335,7 +335,7 @@ int st5481_setup_b(struct st5481_bcs *bcs) */ void st5481_release_b(struct st5481_bcs *bcs) { - DBG(4,""); + DBG(4, ""); st5481_release_in(&bcs->b_in); st5481_release_b_out(bcs); @@ -365,12 +365,12 @@ void st5481_b_l2l1(struct hisax_if *ifc, int pr, void *arg) break; case PH_ACTIVATE | REQUEST: mode = (long) arg; - DBG(4,"B%d,PH_ACTIVATE_REQUEST %ld", bcs->channel + 1, mode); + DBG(4, "B%d,PH_ACTIVATE_REQUEST %ld", bcs->channel + 1, mode); st5481B_mode(bcs, mode); B_L1L2(bcs, PH_ACTIVATE | INDICATION, NULL); break; case PH_DEACTIVATE | REQUEST: - DBG(4,"B%d,PH_DEACTIVATE_REQUEST", bcs->channel + 1); + DBG(4, "B%d,PH_DEACTIVATE_REQUEST", bcs->channel + 1); st5481B_mode(bcs, L1_MODE_NULL); B_L1L2(bcs, PH_DEACTIVATE | INDICATION, NULL); break; |