2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Driver for ST5481 USB ISDN modem
|
|
|
|
*
|
|
|
|
* Author Frode Isaksen
|
|
|
|
* Copyright 2001 by Frode Isaksen <fisaksen@bewan.com>
|
|
|
|
* 2001 by Kai Germaschewski <kai.germaschewski@gmx.de>
|
2012-02-20 03:52:38 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* This software may be used and distributed according to the terms
|
|
|
|
* of the GNU General Public License, incorporated herein by reference.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/gfp.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/netdevice.h>
|
2006-12-08 10:36:27 +00:00
|
|
|
#include <linux/bitrev.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include "st5481.h"
|
|
|
|
|
|
|
|
static inline void B_L1L2(struct st5481_bcs *bcs, int pr, void *arg)
|
|
|
|
{
|
|
|
|
struct hisax_if *ifc = (struct hisax_if *) &bcs->b_if;
|
|
|
|
|
|
|
|
ifc->l1l2(ifc, pr, arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Encode and transmit next frame.
|
|
|
|
*/
|
2012-02-20 03:52:38 +00:00
|
|
|
static void usb_b_out(struct st5481_bcs *bcs, int buf_nr)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct st5481_b_out *b_out = &bcs->b_out;
|
|
|
|
struct st5481_adapter *adapter = bcs->adapter;
|
|
|
|
struct urb *urb;
|
2012-02-20 03:52:38 +00:00
|
|
|
unsigned int packet_size, offset;
|
|
|
|
int len, buf_size, bytes_sent;
|
2005-04-16 22:20:36 +00:00
|
|
|
int i;
|
|
|
|
struct sk_buff *skb;
|
2012-02-20 03:52:38 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (test_and_set_bit(buf_nr, &b_out->busy)) {
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "ep %d urb %d busy", (bcs->channel + 1) * 2, buf_nr);
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
urb = b_out->urb[buf_nr];
|
|
|
|
|
|
|
|
// Adjust isoc buffer size according to flow state
|
2012-02-20 03:52:38 +00:00
|
|
|
if (b_out->flow_event & (OUT_DOWN | OUT_UNDERRUN)) {
|
|
|
|
buf_size = NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST;
|
2005-04-16 22:20:36 +00:00
|
|
|
packet_size = SIZE_ISO_PACKETS_B_OUT + B_FLOW_ADJUST;
|
2012-02-20 03:52:38 +00:00
|
|
|
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;
|
2005-04-16 22:20:36 +00:00
|
|
|
packet_size = SIZE_ISO_PACKETS_B_OUT - B_FLOW_ADJUST;
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "B%d,adjust flow,remove %d bytes", bcs->channel + 1, B_FLOW_ADJUST);
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
2012-02-20 03:52:38 +00:00
|
|
|
buf_size = NUM_ISO_PACKETS_B * SIZE_ISO_PACKETS_B_OUT;
|
2005-04-16 22:20:36 +00:00
|
|
|
packet_size = 8;
|
|
|
|
}
|
|
|
|
b_out->flow_event = 0;
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
while (len < buf_size) {
|
|
|
|
if ((skb = b_out->tx_skb)) {
|
|
|
|
DBG_SKB(0x100, skb);
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "B%d,len=%d", bcs->channel + 1, skb->len);
|
|
|
|
|
|
|
|
if (bcs->mode == L1_MODE_TRANS) {
|
2005-04-16 22:20:36 +00:00
|
|
|
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;
|
2012-02-20 03:52:38 +00:00
|
|
|
register unsigned char *dest = urb->transfer_buffer + len;
|
2005-04-16 22:20:36 +00:00
|
|
|
register unsigned int count;
|
|
|
|
for (count = 0; count < bytes_sent; count++)
|
2006-12-08 10:36:27 +00:00
|
|
|
*dest++ = bitrev8(*src++);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
len += bytes_sent;
|
|
|
|
} else {
|
|
|
|
len += isdnhdlc_encode(&b_out->hdlc_state,
|
|
|
|
skb->data, skb->len, &bytes_sent,
|
2012-02-20 03:52:38 +00:00
|
|
|
urb->transfer_buffer + len, buf_size-len);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
skb_pull(skb, bytes_sent);
|
|
|
|
|
|
|
|
if (!skb->len) {
|
|
|
|
// Frame sent
|
|
|
|
b_out->tx_skb = NULL;
|
2006-10-03 08:13:55 +00:00
|
|
|
B_L1L2(bcs, PH_DATA | CONFIRM, (void *)(unsigned long) skb->truesize);
|
2005-04-16 22:20:36 +00:00
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
|
2012-02-20 03:52:38 +00:00
|
|
|
/* if (!(bcs->tx_skb = skb_dequeue(&bcs->sq))) { */
|
|
|
|
/* st5481B_sched_event(bcs, B_XMTBUFREADY); */
|
|
|
|
/* } */
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (bcs->mode == L1_MODE_TRANS) {
|
2012-02-20 03:52:38 +00:00
|
|
|
memset(urb->transfer_buffer + len, 0xff, buf_size-len);
|
2005-04-16 22:20:36 +00:00
|
|
|
len = buf_size;
|
|
|
|
} else {
|
|
|
|
// Send flags
|
|
|
|
len += isdnhdlc_encode(&b_out->hdlc_state,
|
|
|
|
NULL, 0, &bytes_sent,
|
2012-02-20 03:52:38 +00:00
|
|
|
urb->transfer_buffer + len, buf_size-len);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2012-02-20 03:52:38 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare the URB
|
|
|
|
for (i = 0, offset = 0; offset < len; i++) {
|
|
|
|
urb->iso_frame_desc[i].offset = offset;
|
|
|
|
urb->iso_frame_desc[i].length = packet_size;
|
|
|
|
offset += packet_size;
|
|
|
|
packet_size = SIZE_ISO_PACKETS_B_OUT;
|
|
|
|
}
|
|
|
|
urb->transfer_buffer_length = len;
|
|
|
|
urb->number_of_packets = i;
|
|
|
|
urb->dev = adapter->usb_dev;
|
|
|
|
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG_ISO_PACKET(0x200, urb);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
SUBMIT_URB(urb, GFP_NOIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-03-31 01:57:33 +00:00
|
|
|
* Start transferring (flags or data) on the B channel, since
|
2005-04-16 22:20:36 +00:00
|
|
|
* FIFO counters has been set to a non-zero value.
|
|
|
|
*/
|
|
|
|
static void st5481B_start_xfer(void *context)
|
|
|
|
{
|
|
|
|
struct st5481_bcs *bcs = context;
|
|
|
|
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "B%d", bcs->channel + 1);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
// Start transmitting (flags or data) on B channel
|
|
|
|
|
2012-02-20 03:52:38 +00:00
|
|
|
usb_b_out(bcs, 0);
|
|
|
|
usb_b_out(bcs, 1);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the adapter has only 2 LEDs, the green
|
|
|
|
* LED will blink with a rate depending
|
|
|
|
* on the number of channels opened.
|
|
|
|
*/
|
|
|
|
static void led_blink(struct st5481_adapter *adapter)
|
|
|
|
{
|
|
|
|
u_char leds = adapter->leds;
|
|
|
|
|
|
|
|
// 50 frames/sec for each channel
|
|
|
|
if (++adapter->led_counter % 50) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (adapter->led_counter % 100) {
|
|
|
|
leds |= GREEN_LED;
|
|
|
|
} else {
|
|
|
|
leds &= ~GREEN_LED;
|
|
|
|
}
|
2012-02-20 03:52:38 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
st5481_usb_device_ctrl_msg(adapter, GPIO_OUT, leds, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static void usb_b_out_complete(struct urb *urb)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct st5481_bcs *bcs = urb->context;
|
|
|
|
struct st5481_b_out *b_out = &bcs->b_out;
|
|
|
|
struct st5481_adapter *adapter = bcs->adapter;
|
|
|
|
int buf_nr;
|
2012-02-20 03:52:38 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
buf_nr = get_buf_nr(b_out->urb, urb);
|
|
|
|
test_and_clear_bit(buf_nr, &b_out->busy);
|
|
|
|
|
|
|
|
if (unlikely(urb->status < 0)) {
|
2005-09-17 21:52:42 +00:00
|
|
|
switch (urb->status) {
|
2012-02-20 03:52:38 +00:00
|
|
|
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;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-20 03:52:38 +00:00
|
|
|
usb_b_out(bcs, buf_nr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (adapter->number_of_leds == 2)
|
|
|
|
led_blink(adapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start or stop the transfer on the B channel.
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "B%d,mode=%d", bcs->channel + 1, mode);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (bcs->mode == mode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bcs->mode = mode;
|
|
|
|
|
|
|
|
// Cancel all USB transfers on this B channel
|
|
|
|
usb_unlink_urb(b_out->urb[0]);
|
|
|
|
usb_unlink_urb(b_out->urb[1]);
|
|
|
|
b_out->busy = 0;
|
|
|
|
|
|
|
|
st5481_in_mode(&bcs->b_in, mode);
|
|
|
|
if (bcs->mode != L1_MODE_NULL) {
|
|
|
|
// Open the B channel
|
|
|
|
if (bcs->mode != L1_MODE_TRANS) {
|
2009-07-08 18:31:42 +00:00
|
|
|
u32 features = HDLC_BITREVERSE;
|
|
|
|
if (bcs->mode == L1_MODE_HDLC_56K)
|
|
|
|
features |= HDLC_56KBIT;
|
|
|
|
isdnhdlc_out_init(&b_out->hdlc_state, features);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2012-02-20 03:52:38 +00:00
|
|
|
st5481_usb_pipe_reset(adapter, (bcs->channel + 1) * 2, NULL, NULL);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
// Enable B channel interrupts
|
2012-02-20 03:52:38 +00:00
|
|
|
st5481_usb_device_ctrl_msg(adapter, FFMSK_B1 + (bcs->channel * 2),
|
|
|
|
OUT_UP + OUT_DOWN + OUT_UNDERRUN, NULL, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
// Enable B channel FIFOs
|
2012-02-20 03:52:38 +00:00
|
|
|
st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel * 2), 32, st5481B_start_xfer, bcs);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (adapter->number_of_leds == 4) {
|
|
|
|
if (bcs->channel == 0) {
|
|
|
|
adapter->leds |= B1_LED;
|
|
|
|
} else {
|
|
|
|
adapter->leds |= B2_LED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Disble B channel interrupts
|
2012-02-20 03:52:38 +00:00
|
|
|
st5481_usb_device_ctrl_msg(adapter, FFMSK_B1+(bcs->channel * 2), 0, NULL, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
// Disable B channel FIFOs
|
2012-02-20 03:52:38 +00:00
|
|
|
st5481_usb_device_ctrl_msg(adapter, OUT_B1_COUNTER+(bcs->channel * 2), 0, NULL, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (adapter->number_of_leds == 4) {
|
|
|
|
if (bcs->channel == 0) {
|
|
|
|
adapter->leds &= ~B1_LED;
|
|
|
|
} else {
|
|
|
|
adapter->leds &= ~B2_LED;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
st5481_usb_device_ctrl_msg(adapter, GPIO_OUT, adapter->leds, NULL, NULL);
|
|
|
|
}
|
|
|
|
if (b_out->tx_skb) {
|
|
|
|
dev_kfree_skb_any(b_out->tx_skb);
|
|
|
|
b_out->tx_skb = NULL;
|
|
|
|
}
|
2012-02-20 03:52:38 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int st5481_setup_b_out(struct st5481_bcs *bcs)
|
|
|
|
{
|
|
|
|
struct usb_device *dev = bcs->adapter->usb_dev;
|
|
|
|
struct usb_interface *intf;
|
|
|
|
struct usb_host_interface *altsetting = NULL;
|
|
|
|
struct usb_host_endpoint *endpoint;
|
2012-02-20 03:52:38 +00:00
|
|
|
struct st5481_b_out *b_out = &bcs->b_out;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
intf = usb_ifnum_to_if(dev, 0);
|
|
|
|
if (intf)
|
|
|
|
altsetting = usb_altnum_to_altsetting(intf, 3);
|
|
|
|
if (!altsetting)
|
|
|
|
return -ENXIO;
|
|
|
|
|
|
|
|
// Allocate URBs and buffers for the B channel out
|
|
|
|
endpoint = &altsetting->endpoint[EP_B1_OUT - 1 + bcs->channel * 2];
|
|
|
|
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "endpoint address=%02x,packet size=%d",
|
2005-04-16 22:20:36 +00:00
|
|
|
endpoint->desc.bEndpointAddress, le16_to_cpu(endpoint->desc.wMaxPacketSize));
|
|
|
|
|
|
|
|
// Allocate memory for 8000bytes/sec + extra bytes if underrun
|
2012-02-20 03:52:38 +00:00
|
|
|
return st5481_setup_isocpipes(b_out->urb, dev,
|
2005-04-16 22:20:36 +00:00
|
|
|
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,
|
|
|
|
usb_b_out_complete, bcs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void st5481_release_b_out(struct st5481_bcs *bcs)
|
|
|
|
{
|
|
|
|
struct st5481_b_out *b_out = &bcs->b_out;
|
|
|
|
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
st5481_release_isocpipes(b_out->urb);
|
|
|
|
}
|
|
|
|
|
|
|
|
int st5481_setup_b(struct st5481_bcs *bcs)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
retval = st5481_setup_b_out(bcs);
|
|
|
|
if (retval)
|
|
|
|
goto err;
|
|
|
|
bcs->b_in.bufsize = HSCX_BUFMAX;
|
|
|
|
bcs->b_in.num_packets = NUM_ISO_PACKETS_B;
|
|
|
|
bcs->b_in.packet_size = SIZE_ISO_PACKETS_B_IN;
|
|
|
|
bcs->b_in.ep = (bcs->channel ? EP_B2_IN : EP_B1_IN) | USB_DIR_IN;
|
|
|
|
bcs->b_in.counter = bcs->channel ? IN_B2_COUNTER : IN_B1_COUNTER;
|
|
|
|
bcs->b_in.adapter = bcs->adapter;
|
|
|
|
bcs->b_in.hisax_if = &bcs->b_if.ifc;
|
|
|
|
retval = st5481_setup_in(&bcs->b_in);
|
|
|
|
if (retval)
|
|
|
|
goto err_b_out;
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2012-02-20 03:52:38 +00:00
|
|
|
err_b_out:
|
2005-04-16 22:20:36 +00:00
|
|
|
st5481_release_b_out(bcs);
|
2012-02-20 03:52:38 +00:00
|
|
|
err:
|
2005-04-16 22:20:36 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release buffers and URBs for the B channels
|
|
|
|
*/
|
|
|
|
void st5481_release_b(struct st5481_bcs *bcs)
|
|
|
|
{
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
st5481_release_in(&bcs->b_in);
|
|
|
|
st5481_release_b_out(bcs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* st5481_b_l2l1 is the entry point for upper layer routines that want to
|
|
|
|
* transmit on the B channel. PH_DATA | REQUEST is a normal packet that
|
|
|
|
* we either start transmitting (if idle) or queue (if busy).
|
|
|
|
* PH_PULL | REQUEST can be called to request a callback message
|
|
|
|
* (PH_PULL | CONFIRM)
|
|
|
|
* once the link is idle. After a "pull" callback, the upper layer
|
|
|
|
* routines can use PH_PULL | INDICATION to send data.
|
|
|
|
*/
|
|
|
|
void st5481_b_l2l1(struct hisax_if *ifc, int pr, void *arg)
|
|
|
|
{
|
|
|
|
struct st5481_bcs *bcs = ifc->priv;
|
|
|
|
struct sk_buff *skb = arg;
|
2006-10-03 08:13:55 +00:00
|
|
|
long mode;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
DBG(4, "");
|
|
|
|
|
|
|
|
switch (pr) {
|
|
|
|
case PH_DATA | REQUEST:
|
2006-03-26 16:19:26 +00:00
|
|
|
BUG_ON(bcs->b_out.tx_skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
bcs->b_out.tx_skb = skb;
|
|
|
|
break;
|
|
|
|
case PH_ACTIVATE | REQUEST:
|
2006-10-03 08:13:55 +00:00
|
|
|
mode = (long) arg;
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "B%d,PH_ACTIVATE_REQUEST %ld", bcs->channel + 1, mode);
|
2005-04-16 22:20:36 +00:00
|
|
|
st5481B_mode(bcs, mode);
|
|
|
|
B_L1L2(bcs, PH_ACTIVATE | INDICATION, NULL);
|
|
|
|
break;
|
|
|
|
case PH_DEACTIVATE | REQUEST:
|
2012-02-20 03:52:38 +00:00
|
|
|
DBG(4, "B%d,PH_DEACTIVATE_REQUEST", bcs->channel + 1);
|
2005-04-16 22:20:36 +00:00
|
|
|
st5481B_mode(bcs, L1_MODE_NULL);
|
|
|
|
B_L1L2(bcs, PH_DEACTIVATE | INDICATION, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
2008-07-25 08:45:52 +00:00
|
|
|
WARNING("pr %#x\n", pr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|