| 1 |
diff -rNu linux-2.4.29.old/drivers/Makefile linux-2.4.29/drivers/Makefile |
| 2 |
--- linux-2.4.29.old/drivers/Makefile 2005-03-22 14:47:41.000000000 +0100 |
| 3 |
+++ linux-2.4.29/drivers/Makefile 2005-03-22 15:15:20.012957872 +0100 |
| 4 |
@@ -38,7 +38,7 @@ |
| 5 |
subdir-$(CONFIG_MD) += md |
| 6 |
subdir-$(CONFIG_IEEE1394) += ieee1394 |
| 7 |
subdir-$(CONFIG_PNP) += pnp |
| 8 |
-subdir-$(CONFIG_ISDN_BOOL) += isdn |
| 9 |
+subdir-$(CONFIG_ISDN) += isdn |
| 10 |
subdir-$(CONFIG_ATM) += atm |
| 11 |
subdir-$(CONFIG_FC4) += fc4 |
| 12 |
|
| 13 |
diff -rNu linux-2.4.29.old/drivers/isdn/hisax/hfc_usb.c linux-2.4.29/drivers/isdn/hisax/hfc_usb.c |
| 14 |
--- linux-2.4.29.old/drivers/isdn/hisax/hfc_usb.c 2005-03-22 15:13:58.233390256 +0100 |
| 15 |
+++ linux-2.4.29/drivers/isdn/hisax/hfc_usb.c 2005-03-22 15:14:57.475384104 +0100 |
| 16 |
@@ -1,13 +1,11 @@ |
| 17 |
-/* $Id: hfc_usb.c,v 2.3 2001/07/06 21:30:11 werner Exp $ |
| 18 |
+/* |
| 19 |
+ * hfc_usb.c |
| 20 |
* |
| 21 |
+ * modular HiSax ISDN driver for Colognechip HFC-USB chip |
| 22 |
* |
| 23 |
- * |
| 24 |
- * Author (C) 2001 Werner Cornelius (werner@isdn-development.de) |
| 25 |
- * modular driver for Colognechip HFC-USB chip |
| 26 |
- * as plugin for HiSax isdn driver |
| 27 |
- * type approval valid for HFC-S USB based TAs |
| 28 |
- * |
| 29 |
- * Copyright 2001 by Werner Cornelius (werner@isdn-development.de) |
| 30 |
+ * Authors : Peter Sprenger (sprenger@moving-byters.de) |
| 31 |
+ * Martin Bachem (info@colognechip.com) |
| 32 |
+ * based on the first hfc_usb driver of Werner Cornelius (werner@isdn-development.de) |
| 33 |
* |
| 34 |
* This program is free software; you can redistribute it and/or modify |
| 35 |
* it under the terms of the GNU General Public License as published by |
| 36 |
@@ -23,70 +21,90 @@ |
| 37 |
* along with this program; if not, write to the Free Software |
| 38 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 39 |
* |
| 40 |
- */ |
| 41 |
+ * 2005_Mar_16 grsch |
| 42 |
+ * ported 2.6.8 hfc_usb.c to 2.4.20 format |
| 43 |
+ * Gregor Schaffrath <gschaff@ran-dom.org> |
| 44 |
+*/ |
| 45 |
+ |
| 46 |
|
| 47 |
#include <linux/types.h> |
| 48 |
#include <linux/stddef.h> |
| 49 |
#include <linux/timer.h> |
| 50 |
#include <linux/config.h> |
| 51 |
-#include <linux/isdn_compat.h> |
| 52 |
#include <linux/init.h> |
| 53 |
#include "hisax.h" |
| 54 |
#include <linux/module.h> |
| 55 |
#include <linux/kernel_stat.h> |
| 56 |
-#include <linux/tqueue.h> |
| 57 |
#include <linux/usb.h> |
| 58 |
#include <linux/kernel.h> |
| 59 |
#include <linux/smp_lock.h> |
| 60 |
#include <linux/sched.h> |
| 61 |
+#include "hisax_if.h" |
| 62 |
#include "hisax_loadable.h" |
| 63 |
|
| 64 |
+static const char *hfcusb_revision = "4.0"; |
| 65 |
+ |
| 66 |
+/* |
| 67 |
+ to enable much mire debug messages in this driver, define |
| 68 |
+ VERBOSE_USB_DEBUG and VERBOSE_ISDN_DEBUG |
| 69 |
+ below |
| 70 |
+*/ |
| 71 |
+ |
| 72 |
+#define VERBOSE_USB_DEBUG |
| 73 |
+#define VERBOSE_ISDN_DEBUG |
| 74 |
+ |
| 75 |
#define INCLUDE_INLINE_FUNCS |
| 76 |
|
| 77 |
+#define TRUE 1 |
| 78 |
+#define FALSE 0 |
| 79 |
+ |
| 80 |
+ |
| 81 |
/***********/ |
| 82 |
/* defines */ |
| 83 |
/***********/ |
| 84 |
-#define HFC_CTRL_TIMEOUT 5 /* 5ms timeout writing/reading regs */ |
| 85 |
-#define HFC_TIMER_T3 7000 /* timeout for l1 activation timer */ |
| 86 |
- |
| 87 |
-#define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */ |
| 88 |
-#define HFCUSB_L1_DRX 1 /* D-frame received */ |
| 89 |
-#define HFCUSB_L1_ERX 2 /* E-frame received */ |
| 90 |
-#define HFCUSB_L1_DTX 4 /* D-frames completed */ |
| 91 |
- |
| 92 |
-#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ |
| 93 |
- |
| 94 |
-#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */ |
| 95 |
-#define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */ |
| 96 |
- |
| 97 |
-#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */ |
| 98 |
-#define HFCUSB_CIRM 0x00 /* cirm register index */ |
| 99 |
-#define HFCUSB_USB_SIZE 0x07 /* int length register */ |
| 100 |
-#define HFCUSB_USB_SIZE_I 0x06 /* iso length register */ |
| 101 |
-#define HFCUSB_F_CROSS 0x0b /* bit order register */ |
| 102 |
-#define HFCUSB_CLKDEL 0x37 /* bit delay register */ |
| 103 |
-#define HFCUSB_CON_HDLC 0xfa /* channel connect register */ |
| 104 |
+#define HFC_CTRL_TIMEOUT 20 //(HZ * USB_CTRL_GET_TIMEOUT) |
| 105 |
+/* 5ms timeout writing/reading regs */ |
| 106 |
+#define HFC_TIMER_T3 8000 /* timeout for l1 activation timer */ |
| 107 |
+#define HFC_TIMER_T4 500 /* time for state change interval */ |
| 108 |
+ |
| 109 |
+#define HFCUSB_L1_STATECHANGE 0 /* L1 state changed */ |
| 110 |
+#define HFCUSB_L1_DRX 1 /* D-frame received */ |
| 111 |
+#define HFCUSB_L1_ERX 2 /* E-frame received */ |
| 112 |
+#define HFCUSB_L1_DTX 4 /* D-frames completed */ |
| 113 |
+ |
| 114 |
+#define MAX_BCH_SIZE 2048 /* allowed B-channel packet size */ |
| 115 |
+ |
| 116 |
+#define HFCUSB_RX_THRESHOLD 64 /* threshold for fifo report bit rx */ |
| 117 |
+#define HFCUSB_TX_THRESHOLD 64 /* threshold for fifo report bit tx */ |
| 118 |
+ |
| 119 |
+#define HFCUSB_CHIP_ID 0x16 /* Chip ID register index */ |
| 120 |
+#define HFCUSB_CIRM 0x00 /* cirm register index */ |
| 121 |
+#define HFCUSB_USB_SIZE 0x07 /* int length register */ |
| 122 |
+#define HFCUSB_USB_SIZE_I 0x06 /* iso length register */ |
| 123 |
+#define HFCUSB_F_CROSS 0x0b /* bit order register */ |
| 124 |
+#define HFCUSB_CLKDEL 0x37 /* bit delay register */ |
| 125 |
+#define HFCUSB_CON_HDLC 0xfa /* channel connect register */ |
| 126 |
#define HFCUSB_HDLC_PAR 0xfb |
| 127 |
-#define HFCUSB_SCTRL 0x31 /* S-bus control register (tx) */ |
| 128 |
-#define HFCUSB_SCTRL_E 0x32 /* same for E and special funcs */ |
| 129 |
-#define HFCUSB_SCTRL_R 0x33 /* S-bus control register (rx) */ |
| 130 |
-#define HFCUSB_F_THRES 0x0c /* threshold register */ |
| 131 |
-#define HFCUSB_FIFO 0x0f /* fifo select register */ |
| 132 |
-#define HFCUSB_F_USAGE 0x1a /* fifo usage register */ |
| 133 |
+#define HFCUSB_SCTRL 0x31 /* S-bus control register (tx) */ |
| 134 |
+#define HFCUSB_SCTRL_E 0x32 /* same for E and special funcs */ |
| 135 |
+#define HFCUSB_SCTRL_R 0x33 /* S-bus control register (rx) */ |
| 136 |
+#define HFCUSB_F_THRES 0x0c /* threshold register */ |
| 137 |
+#define HFCUSB_FIFO 0x0f /* fifo select register */ |
| 138 |
+#define HFCUSB_F_USAGE 0x1a /* fifo usage register */ |
| 139 |
#define HFCUSB_MST_MODE0 0x14 |
| 140 |
#define HFCUSB_MST_MODE1 0x15 |
| 141 |
#define HFCUSB_P_DATA 0x1f |
| 142 |
#define HFCUSB_INC_RES_F 0x0e |
| 143 |
#define HFCUSB_STATES 0x30 |
| 144 |
|
| 145 |
-#define HFCUSB_CHIPID 0x40 /* ID value of HFC-USB */ |
| 146 |
+#define HFCUSB_CHIPID 0x40 /* ID value of HFC-USB */ |
| 147 |
|
| 148 |
/******************/ |
| 149 |
/* fifo registers */ |
| 150 |
/******************/ |
| 151 |
-#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */ |
| 152 |
-#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */ |
| 153 |
-#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */ |
| 154 |
+#define HFCUSB_NUM_FIFOS 8 /* maximum number of fifos */ |
| 155 |
+#define HFCUSB_B1_TX 0 /* index for B1 transmit bulk/int */ |
| 156 |
+#define HFCUSB_B1_RX 1 /* index for B1 receive bulk/int */ |
| 157 |
#define HFCUSB_B2_TX 2 |
| 158 |
#define HFCUSB_B2_RX 3 |
| 159 |
#define HFCUSB_D_TX 4 |
| 160 |
@@ -94,198 +112,162 @@ |
| 161 |
#define HFCUSB_PCM_TX 6 |
| 162 |
#define HFCUSB_PCM_RX 7 |
| 163 |
|
| 164 |
-/************/ |
| 165 |
-/* LED mask */ |
| 166 |
-/************/ |
| 167 |
-#define LED_DRIVER 0x1 |
| 168 |
-#define LED_L1 0x2 |
| 169 |
-#define LED_BCH 0x4 |
| 170 |
+/* |
| 171 |
+* used to switch snd_transfer_mode for different TA modes e.g. the Billion USB TA just |
| 172 |
+* supports ISO out, while the Cologne Chip EVAL TA just supports BULK out |
| 173 |
+*/ |
| 174 |
+#define USB_INT 0 |
| 175 |
+#define USB_BULK 1 |
| 176 |
+#define USB_ISOC 2 |
| 177 |
+ |
| 178 |
+#define ISOC_PACKETS_D 8 |
| 179 |
+#define ISOC_PACKETS_B 8 |
| 180 |
+#define ISO_BUFFER_SIZE 128 |
| 181 |
+ |
| 182 |
+// ISO send definitions |
| 183 |
+#define SINK_MAX 68 |
| 184 |
+#define SINK_MIN 48 |
| 185 |
+#define SINK_DMIN 12 |
| 186 |
+#define SINK_DMAX 18 |
| 187 |
+#define BITLINE_INF (-64*8) |
| 188 |
+ |
| 189 |
+ |
| 190 |
+ |
| 191 |
|
| 192 |
/**********/ |
| 193 |
/* macros */ |
| 194 |
/**********/ |
| 195 |
-#define Write_hfc(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),0,0,HFC_CTRL_TIMEOUT) |
| 196 |
-#define Read_hfc(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT) |
| 197 |
- |
| 198 |
-#ifdef COMPAT_HAS_USB_IDTAB |
| 199 |
-/****************************************/ |
| 200 |
-/* data defining the devices to be used */ |
| 201 |
-/****************************************/ |
| 202 |
-static __devinitdata const struct usb_device_id hfc_usb_idtab[3] = { |
| 203 |
- {USB_DEVICE(0x959, 0x2bd0)}, /* Colognechip ROM */ |
| 204 |
- {USB_DEVICE(0x7b0, 0x0006)}, /* USB TA 128 */ |
| 205 |
- {} /* end with an all-zeroes entry */ |
| 206 |
-}; |
| 207 |
-#endif |
| 208 |
+#define write_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_out_pipe,0,0x40,(c),(b),NULL,0,HFC_CTRL_TIMEOUT) |
| 209 |
+#define read_usb(a,b,c) usb_control_msg((a)->dev,(a)->ctrl_in_pipe,1,0xC0,0,(b),(c),1,HFC_CTRL_TIMEOUT) |
| 210 |
|
| 211 |
/*************************************************/ |
| 212 |
/* entry and size of output/input control buffer */ |
| 213 |
/*************************************************/ |
| 214 |
#define HFC_CTRL_BUFSIZE 32 |
| 215 |
-typedef struct { |
| 216 |
+typedef struct |
| 217 |
+{ |
| 218 |
__u8 hfc_reg; /* register number */ |
| 219 |
__u8 reg_val; /* value to be written (or read) */ |
| 220 |
+ int action; /* data for action handler */ |
| 221 |
+ |
| 222 |
} ctrl_buft; |
| 223 |
|
| 224 |
+typedef struct |
| 225 |
+{ |
| 226 |
+ int vendor; // vendor id |
| 227 |
+ int prod_id; // product id |
| 228 |
+ char *vend_name; // vendor string |
| 229 |
+ __u8 led_scheme; // led display scheme |
| 230 |
+ __u8 led_invert; // invert led aux port settings |
| 231 |
+ __u8 led_bits[8]; // array of 8 possible LED bitmask settings |
| 232 |
+ |
| 233 |
+} vendor_data; |
| 234 |
+ |
| 235 |
/***************************************************************/ |
| 236 |
/* structure defining input+output fifos (interrupt/bulk mode) */ |
| 237 |
/***************************************************************/ |
| 238 |
-struct hfcusb_data; /* forward definition */ |
| 239 |
-typedef struct { |
| 240 |
- int fifonum; /* fifo index attached to this structure */ |
| 241 |
- __u8 fifo_mask; /* mask for this fifo */ |
| 242 |
- int active; /* fifo is currently active */ |
| 243 |
+ |
| 244 |
+struct usb_fifo; /* forward definition */ |
| 245 |
+typedef struct iso_urb_struct |
| 246 |
+{ |
| 247 |
+ struct urb *purb; |
| 248 |
+ __u8 buffer[ISO_BUFFER_SIZE]; /* buffer incoming/outgoing data */ |
| 249 |
+ struct usb_fifo *owner_fifo; // pointer to owner fifo |
| 250 |
+} iso_urb_struct; |
| 251 |
+ |
| 252 |
+ |
| 253 |
+struct hfcusb_data; /* forward definition */ |
| 254 |
+typedef struct usb_fifo |
| 255 |
+{ |
| 256 |
+ int fifonum; /* fifo index attached to this structure */ |
| 257 |
+ int active; /* fifo is currently active */ |
| 258 |
struct hfcusb_data *hfc; /* pointer to main structure */ |
| 259 |
- int pipe; /* address of endpoint */ |
| 260 |
- __u8 usb_maxlen; /* maximum length for usb transfer */ |
| 261 |
- int max_size; /* maximum size of receive/send packet */ |
| 262 |
- int transmode; /* transparent mode selected */ |
| 263 |
- int framenum; /* number of frame when last tx completed */ |
| 264 |
- int rx_offset; /* offset inside rx buffer */ |
| 265 |
- int next_complete; /* complete marker */ |
| 266 |
- __u8 *act_ptr; /* pointer to next data */ |
| 267 |
- __u8 intervall; /* interrupt interval */ |
| 268 |
- struct sk_buff *buff; /* actual used buffer */ |
| 269 |
- urb_t urb; /* transfer structure for usb routines */ |
| 270 |
- __u8 buffer[128]; /* buffer incoming/outgoing data */ |
| 271 |
+ int pipe; /* address of endpoint */ |
| 272 |
+ __u8 usb_packet_maxlen; /* maximum length for usb transfer */ |
| 273 |
+ unsigned int max_size; /* maximum size of receive/send packet */ |
| 274 |
+ __u8 intervall; /* interrupt interval */ |
| 275 |
+ struct sk_buff *skbuff; /* actual used buffer */ |
| 276 |
+ struct urb *urb; /* transfer structure for usb routines */ |
| 277 |
+ __u8 buffer[128]; /* buffer incoming/outgoing data */ |
| 278 |
+ int bit_line; /* how much bits are in the fifo? */ |
| 279 |
+ |
| 280 |
+ volatile __u8 usb_transfer_mode;/* switched between ISO and INT */ |
| 281 |
+ iso_urb_struct iso[2]; /* need two urbs to have one always for pending */ |
| 282 |
+ struct hisax_if *hif; /* hisax interface */ |
| 283 |
+ int delete_flg; /* only delete skbuff once */ |
| 284 |
+ int last_urblen; /* remember length of last packet */ |
| 285 |
+ |
| 286 |
} usb_fifo; |
| 287 |
|
| 288 |
+ |
| 289 |
/*********************************************/ |
| 290 |
/* structure holding all data for one device */ |
| 291 |
/*********************************************/ |
| 292 |
-typedef struct hfcusb_data { |
| 293 |
- struct hisax_drvreg regd; /* register data and callbacks */ |
| 294 |
- struct usb_device *dev; /* our device */ |
| 295 |
- int if_used; /* used interface number */ |
| 296 |
- int alt_used; /* used alternate config */ |
| 297 |
- int ctrl_paksize; /* control pipe packet size */ |
| 298 |
+typedef struct hfcusb_data |
| 299 |
+{ |
| 300 |
+ // HiSax Interface for loadable Layer1 drivers |
| 301 |
+ struct hisax_d_if d_if; /* see hisax_if.h */ |
| 302 |
+ struct hisax_b_if b_if[2]; /* see hisax_if.h */ |
| 303 |
+ int protocol; |
| 304 |
+ |
| 305 |
+ struct usb_device *dev; /* our device */ |
| 306 |
+ int if_used; /* used interface number */ |
| 307 |
+ int alt_used; /* used alternate config */ |
| 308 |
+ int ctrl_paksize; /* control pipe packet size */ |
| 309 |
int ctrl_in_pipe, ctrl_out_pipe; /* handles for control pipe */ |
| 310 |
+ int cfg_used; /* configuration index used */ |
| 311 |
+ int vend_idx; // vendor found |
| 312 |
+ |
| 313 |
+ int b_mode[2]; // B-channel mode |
| 314 |
+ |
| 315 |
+ int l1_activated; // layer 1 activated |
| 316 |
+ |
| 317 |
+ int packet_size,iso_packet_size; |
| 318 |
|
| 319 |
/* control pipe background handling */ |
| 320 |
ctrl_buft ctrl_buff[HFC_CTRL_BUFSIZE]; /* buffer holding queued data */ |
| 321 |
- volatile int ctrl_in_idx, ctrl_out_idx, ctrl_cnt; /* input/output pointer + count */ |
| 322 |
- urb_t ctrl_urb; /* transfer structure for control channel */ |
| 323 |
- devrequest ctrl_write; /* buffer for control write request */ |
| 324 |
- devrequest ctrl_read; /* same for read request */ |
| 325 |
- |
| 326 |
- volatile __u8 dfifo_fill; /* value read from tx d-fifo */ |
| 327 |
- volatile __u8 active_fifos; /* fifos currently active as bit mask */ |
| 328 |
- volatile __u8 threshold_mask; /* threshold actually reported */ |
| 329 |
- volatile __u8 service_request; /* fifo needs service from task */ |
| 330 |
- volatile __u8 ctrl_fifo; /* last selected fifo */ |
| 331 |
- volatile __u8 bch_enables; /* or mask for sctrl_r and sctrl register values */ |
| 332 |
- volatile __u8 led_req; /* request status of adapters leds */ |
| 333 |
- volatile __u8 led_act; /* active status of adapters leds */ |
| 334 |
+ volatile int ctrl_in_idx, ctrl_out_idx, |
| 335 |
+ ctrl_cnt; /* input/output pointer + count */ |
| 336 |
+ struct urb *ctrl_urb; /* transfer structure for control channel */ |
| 337 |
+ |
| 338 |
+ struct usb_ctrlrequest ctrl_write; /* buffer for control write request */ |
| 339 |
+ struct usb_ctrlrequest ctrl_read; /* same for read request */ |
| 340 |
+ |
| 341 |
+ __u8 led_state,led_new_data,led_b_active; |
| 342 |
+ |
| 343 |
+ volatile __u8 threshold_mask; /* threshold actually reported */ |
| 344 |
+ volatile __u8 bch_enables; /* or mask for sctrl_r and sctrl register values */ |
| 345 |
+ |
| 346 |
usb_fifo fifos[HFCUSB_NUM_FIFOS]; /* structure holding all fifo data */ |
| 347 |
|
| 348 |
- /* layer 1 activation/deactivation handling */ |
| 349 |
- volatile __u8 l1_state; /* actual l1 state */ |
| 350 |
- volatile ulong l1_event; /* event mask */ |
| 351 |
- struct tq_struct l1_tq; /* l1 bh structure */ |
| 352 |
- struct timer_list t3_timer; /* timer for activation/deactivation */ |
| 353 |
- struct timer_list t4_timer; /* timer for activation/deactivation */ |
| 354 |
+ volatile __u8 l1_state; /* actual l1 state */ |
| 355 |
+ struct timer_list t3_timer; /* timer 3 for activation/deactivation */ |
| 356 |
+ struct timer_list t4_timer; /* timer 4 for activation/deactivation */ |
| 357 |
+ struct timer_list led_timer; /* timer flashing leds */ |
| 358 |
+ |
| 359 |
} hfcusb_data; |
| 360 |
|
| 361 |
-#if 0 |
| 362 |
-static void |
| 363 |
-usb_dump_urb(purb_t purb) |
| 364 |
-{ |
| 365 |
- printk("urb :%p\n", purb); |
| 366 |
- printk("next :%p\n", purb->next); |
| 367 |
- printk("dev :%p\n", purb->dev); |
| 368 |
- printk("pipe :%08X\n", purb->pipe); |
| 369 |
- printk("status :%d\n", purb->status); |
| 370 |
- printk("transfer_flags :%08X\n", purb->transfer_flags); |
| 371 |
- printk("transfer_buffer :%p\n", purb->transfer_buffer); |
| 372 |
- printk("transfer_buffer_length:%d\n", |
| 373 |
- purb->transfer_buffer_length); |
| 374 |
- printk("actual_length :%d\n", purb->actual_length); |
| 375 |
- printk("setup_packet :%p\n", purb->setup_packet); |
| 376 |
- printk("start_frame :%d\n", purb->start_frame); |
| 377 |
- printk("number_of_packets :%d\n", purb->number_of_packets); |
| 378 |
- printk("interval :%d\n", purb->interval); |
| 379 |
- printk("error_count :%d\n", purb->error_count); |
| 380 |
- printk("context :%p\n", purb->context); |
| 381 |
- printk("complete :%p\n", purb->complete); |
| 382 |
-} |
| 383 |
-#endif |
| 384 |
|
| 385 |
-/*************************************************************************/ |
| 386 |
-/* bottom half handler for L1 activation/deactiavtaion + D-chan + E-chan */ |
| 387 |
-/*************************************************************************/ |
| 388 |
-static void |
| 389 |
-usb_l1d_bh(hfcusb_data * hfc) |
| 390 |
-{ |
| 391 |
+static void collect_rx_frame(usb_fifo *fifo,__u8 *data,int len,int finish); |
| 392 |
+ |
| 393 |
|
| 394 |
- while (hfc->l1_event) { |
| 395 |
- if (test_and_clear_bit |
| 396 |
- (HFCUSB_L1_STATECHANGE, &hfc->l1_event)) { |
| 397 |
- if (hfc->l1_state == 7) |
| 398 |
- hfc->led_req |= LED_L1; |
| 399 |
- else |
| 400 |
- hfc->led_req &= ~LED_L1; |
| 401 |
- if ((hfc->l1_state == 7) || |
| 402 |
- (hfc->l1_state == 3)) |
| 403 |
- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, |
| 404 |
- (hfc->l1_state == |
| 405 |
- 7) ? (PH_ACTIVATE | |
| 406 |
- INDICATION) |
| 407 |
- : (PH_DEACTIVATE | INDICATION), |
| 408 |
- NULL); |
| 409 |
- } |
| 410 |
- if (test_and_clear_bit(HFCUSB_L1_DRX, &hfc->l1_event)) { |
| 411 |
- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, |
| 412 |
- PH_DATA | INDICATION, |
| 413 |
- (void *) 0); |
| 414 |
- } |
| 415 |
- if (test_and_clear_bit(HFCUSB_L1_ERX, &hfc->l1_event)) { |
| 416 |
- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, |
| 417 |
- PH_DATA | INDICATION, |
| 418 |
- (void *) 1); |
| 419 |
- } |
| 420 |
- if (test_and_clear_bit(HFCUSB_L1_DTX, &hfc->l1_event)) { |
| 421 |
- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, |
| 422 |
- PH_DATA | CONFIRM, NULL); |
| 423 |
- } |
| 424 |
- } /* while */ |
| 425 |
-} /* usb_l1d_bh */ |
| 426 |
|
| 427 |
/******************************************************/ |
| 428 |
/* start next background transfer for control channel */ |
| 429 |
/******************************************************/ |
| 430 |
-static void |
| 431 |
-ctrl_start_transfer(hfcusb_data * hfc) |
| 432 |
+static void ctrl_start_transfer(hfcusb_data * hfc) |
| 433 |
{ |
| 434 |
- |
| 435 |
- if (hfc->ctrl_cnt) { |
| 436 |
- switch (hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg) { |
| 437 |
- case HFCUSB_F_USAGE: |
| 438 |
- hfc->ctrl_urb.pipe = hfc->ctrl_in_pipe; |
| 439 |
- hfc->ctrl_urb.setup_packet = |
| 440 |
- (u_char *) & hfc->ctrl_read; |
| 441 |
- hfc->ctrl_urb.transfer_buffer_length = 1; |
| 442 |
- hfc->ctrl_read.index = |
| 443 |
- hfc->ctrl_buff[hfc->ctrl_out_idx]. |
| 444 |
- hfc_reg; |
| 445 |
- hfc->ctrl_urb.transfer_buffer = |
| 446 |
- (char *) &hfc->dfifo_fill; |
| 447 |
- break; |
| 448 |
- |
| 449 |
- default: /* write register */ |
| 450 |
- hfc->ctrl_urb.pipe = hfc->ctrl_out_pipe; |
| 451 |
- hfc->ctrl_urb.setup_packet = |
| 452 |
- (u_char *) & hfc->ctrl_write; |
| 453 |
- hfc->ctrl_urb.transfer_buffer = NULL; |
| 454 |
- hfc->ctrl_urb.transfer_buffer_length = 0; |
| 455 |
- hfc->ctrl_write.index = |
| 456 |
- hfc->ctrl_buff[hfc->ctrl_out_idx]. |
| 457 |
- hfc_reg; |
| 458 |
- hfc->ctrl_write.value = |
| 459 |
- hfc->ctrl_buff[hfc->ctrl_out_idx]. |
| 460 |
- reg_val; |
| 461 |
- break; |
| 462 |
- } |
| 463 |
- usb_submit_urb(&hfc->ctrl_urb); /* start transfer */ |
| 464 |
+ int err; |
| 465 |
+ if(hfc->ctrl_cnt) |
| 466 |
+ { |
| 467 |
+ hfc->ctrl_urb->pipe = hfc->ctrl_out_pipe; |
| 468 |
+ hfc->ctrl_urb->setup_packet = (u_char *) & hfc->ctrl_write; |
| 469 |
+ hfc->ctrl_urb->transfer_buffer = NULL; |
| 470 |
+ hfc->ctrl_urb->transfer_buffer_length = 0; |
| 471 |
+ hfc->ctrl_write.wIndex = hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg; |
| 472 |
+ hfc->ctrl_write.wValue = hfc->ctrl_buff[hfc->ctrl_out_idx].reg_val; |
| 473 |
+ err = usb_submit_urb(hfc->ctrl_urb); /* start transfer */ |
| 474 |
+ printk(KERN_DEBUG "ctrl_start_transfer: submit %d\n", err); |
| 475 |
} |
| 476 |
} /* ctrl_start_transfer */ |
| 477 |
|
| 478 |
@@ -293,897 +275,1418 @@ |
| 479 |
/* queue a control transfer request */ |
| 480 |
/* return 0 on success. */ |
| 481 |
/************************************/ |
| 482 |
-static int |
| 483 |
-queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val) |
| 484 |
+static int queue_control_request(hfcusb_data * hfc, __u8 reg, __u8 val,int action) |
| 485 |
{ |
| 486 |
ctrl_buft *buf; |
| 487 |
|
| 488 |
- if (hfc->ctrl_cnt >= HFC_CTRL_BUFSIZE) |
| 489 |
- return (1); /* no space left */ |
| 490 |
- buf = hfc->ctrl_buff + hfc->ctrl_in_idx; /* pointer to new index */ |
| 491 |
+#ifdef VERBOSE_USB_DEBUG |
| 492 |
+ printk ("HFC_USB: queue_control_request reg: %x, val: %x\n", reg, val); |
| 493 |
+#endif |
| 494 |
+ |
| 495 |
+ if(hfc->ctrl_cnt >= HFC_CTRL_BUFSIZE) return(1); /* no space left */ |
| 496 |
+ buf = &hfc->ctrl_buff[hfc->ctrl_in_idx]; /* pointer to new index */ |
| 497 |
buf->hfc_reg = reg; |
| 498 |
buf->reg_val = val; |
| 499 |
+ buf->action=action; |
| 500 |
if (++hfc->ctrl_in_idx >= HFC_CTRL_BUFSIZE) |
| 501 |
hfc->ctrl_in_idx = 0; /* pointer wrap */ |
| 502 |
if (++hfc->ctrl_cnt == 1) |
| 503 |
ctrl_start_transfer(hfc); |
| 504 |
- return (0); |
| 505 |
-} /* queue_control_request */ |
| 506 |
+ return(0); |
| 507 |
+} /* queue_control_request */ |
| 508 |
|
| 509 |
-/**************************************/ |
| 510 |
-/* called when timer t3 or t4 expires */ |
| 511 |
-/**************************************/ |
| 512 |
-static void |
| 513 |
-l1_timer_expire(hfcusb_data * hfc) |
| 514 |
-{ |
| 515 |
- if (timer_pending(&hfc->t4_timer)) |
| 516 |
- del_timer(&hfc->t4_timer); |
| 517 |
- queue_control_request(hfc, HFCUSB_STATES, 0x40); |
| 518 |
- test_and_set_bit(HFCUSB_L1_STATECHANGE, |
| 519 |
- &hfc->l1_event); |
| 520 |
- queue_task(&hfc->l1_tq, &tq_immediate); |
| 521 |
- mark_bh(IMMEDIATE_BH); |
| 522 |
-} /* l1_timer_expire */ |
| 523 |
- |
| 524 |
-/**************************************************/ |
| 525 |
-/* (re)fills a tx-fifo urb. Queuing is done later */ |
| 526 |
-/**************************************************/ |
| 527 |
-static void |
| 528 |
-fill_tx_urb(usb_fifo * fifo) |
| 529 |
-{ |
| 530 |
- struct sk_buff *skb; |
| 531 |
- long flags; |
| 532 |
- int i, ii = 0; |
| 533 |
- |
| 534 |
- fifo->urb.dev = fifo->hfc->dev; |
| 535 |
- if ((fifo->buff) |
| 536 |
- && (fifo->urb.transfer_buffer_length < fifo->usb_maxlen)) { |
| 537 |
- switch (fifo->fifonum) { |
| 538 |
- case HFCUSB_B1_TX: |
| 539 |
- case HFCUSB_B2_TX: |
| 540 |
- skb = fifo->buff; |
| 541 |
- fifo->buff = NULL; |
| 542 |
- fifo->hfc->regd.bch_l1l2(fifo->hfc->regd. |
| 543 |
- arg_hisax, |
| 544 |
- (fifo->fifonum == |
| 545 |
- HFCUSB_B1_TX) ? 0 |
| 546 |
- : 1, |
| 547 |
- (PH_DATA | |
| 548 |
- CONFIRM), |
| 549 |
- (void *) skb); |
| 550 |
- fifo->hfc->service_request |= |
| 551 |
- fifo->fifo_mask; |
| 552 |
- return; |
| 553 |
- case HFCUSB_D_TX: |
| 554 |
- dev_kfree_skb_any(fifo->buff); |
| 555 |
- fifo->buff = NULL; |
| 556 |
- save_flags(flags); |
| 557 |
- cli(); |
| 558 |
- fifo->hfc->dfifo_fill = 0xff; /* currently invalid data */ |
| 559 |
- queue_control_request(fifo->hfc, |
| 560 |
- HFCUSB_FIFO, |
| 561 |
- HFCUSB_D_TX); |
| 562 |
- queue_control_request(fifo->hfc, |
| 563 |
- HFCUSB_F_USAGE, 0); |
| 564 |
- restore_flags(flags); |
| 565 |
- return; |
| 566 |
- default: |
| 567 |
- return; /* error, invalid fifo */ |
| 568 |
- } |
| 569 |
+ |
| 570 |
+static int control_action_handler(hfcusb_data *hfc,int reg,int val,int action) |
| 571 |
+{ |
| 572 |
+ if(!action) return(1); // no action defined |
| 573 |
+ |
| 574 |
+ return(0); |
| 575 |
+} |
| 576 |
+ |
| 577 |
+ |
| 578 |
+/***************************************************************/ |
| 579 |
+/* control completion routine handling background control cmds */ |
| 580 |
+/***************************************************************/ |
| 581 |
+static void ctrl_complete(struct urb *urb) |
| 582 |
+{ |
| 583 |
+ hfcusb_data *hfc = (hfcusb_data *) urb->context; |
| 584 |
+ ctrl_buft *buf; |
| 585 |
+ |
| 586 |
+ printk(KERN_DEBUG "ctrl_complete cnt %d\n", hfc->ctrl_cnt); |
| 587 |
+ urb->dev = hfc->dev; |
| 588 |
+ if(hfc->ctrl_cnt) |
| 589 |
+ { |
| 590 |
+ buf=&hfc->ctrl_buff[hfc->ctrl_out_idx]; |
| 591 |
+ control_action_handler(hfc,buf->hfc_reg,buf->reg_val,buf->action); |
| 592 |
+ |
| 593 |
+ hfc->ctrl_cnt--; /* decrement actual count */ |
| 594 |
+ if(++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE) hfc->ctrl_out_idx = 0; /* pointer wrap */ |
| 595 |
+ |
| 596 |
+ ctrl_start_transfer(hfc); /* start next transfer */ |
| 597 |
+ } |
| 598 |
+} /* ctrl_complete */ |
| 599 |
+ |
| 600 |
+ |
| 601 |
+ |
| 602 |
+#define LED_OFF 0 // no LED support |
| 603 |
+#define LED_SCHEME1 1 // LED standard scheme |
| 604 |
+#define LED_SCHEME2 2 // not used yet... |
| 605 |
+ |
| 606 |
+#define LED_POWER_ON 1 |
| 607 |
+#define LED_POWER_OFF 2 |
| 608 |
+#define LED_S0_ON 3 |
| 609 |
+#define LED_S0_OFF 4 |
| 610 |
+#define LED_B1_ON 5 |
| 611 |
+#define LED_B1_OFF 6 |
| 612 |
+#define LED_B1_DATA 7 |
| 613 |
+#define LED_B2_ON 8 |
| 614 |
+#define LED_B2_OFF 9 |
| 615 |
+#define LED_B2_DATA 10 |
| 616 |
+ |
| 617 |
+#define LED_NORMAL 0 // LEDs are normal |
| 618 |
+#define LED_INVERTED 1 // LEDs are inverted |
| 619 |
+ |
| 620 |
+// time for LED flashing |
| 621 |
+#define LED_TIME 250 |
| 622 |
+ |
| 623 |
+vendor_data vdata[]= |
| 624 |
+{ |
| 625 |
+ {0x959, 0x2bd0, "ISDN USB TA (Cologne Chip HFC-S USB based)", LED_OFF,LED_NORMAL,{4,0,2,1}}, /* CologneChip Eval TA */ |
| 626 |
+ {0x7b0, 0x0007, "Billion tiny USB ISDN TA 128", LED_SCHEME1, LED_INVERTED, {8,0x40,0x20,0x10}}, /* Billion TA */ |
| 627 |
+ {0x742, 0x2008, "Stollmann USB TA", LED_SCHEME1, LED_NORMAL, {4,0,2,1}}, /* Stollmann TA */ |
| 628 |
+ {0x8e3, 0x0301, "Olitec USB RNIS", LED_SCHEME1, LED_NORMAL, {2,0,1,4}}, /* Olitec TA */ |
| 629 |
+ {0x675, 0x1688, "DrayTec USB ISDN TA", LED_SCHEME1, LED_NORMAL, {4,0,2,1}}, /* Draytec TA */ |
| 630 |
+ {0x7fa, 0x0846, "Bewan Modem RNIS USB", LED_SCHEME1, LED_INVERTED, {8,0x40,0x20,0x10}}, /* Bewan TA */ |
| 631 |
+ {0} // EOL element |
| 632 |
+}; |
| 633 |
+ |
| 634 |
+/***************************************************/ |
| 635 |
+/* write led data to auxport & invert if necessary */ |
| 636 |
+/***************************************************/ |
| 637 |
+static void write_led(hfcusb_data * hfc,__u8 led_state) |
| 638 |
+{ |
| 639 |
+ if(led_state!=hfc->led_state) |
| 640 |
+ { |
| 641 |
+ hfc->led_state=led_state; |
| 642 |
+ queue_control_request(hfc, HFCUSB_P_DATA,(vdata[hfc->vend_idx].led_invert) ? ~led_state : led_state,1); |
| 643 |
+ } |
| 644 |
+} |
| 645 |
+ |
| 646 |
+/******************************************/ |
| 647 |
+/* invert B-channel LEDs if data is sent */ |
| 648 |
+/******************************************/ |
| 649 |
+static void led_timer(hfcusb_data * hfc) |
| 650 |
+{ |
| 651 |
+ static int cnt=0; |
| 652 |
+ __u8 led_state=hfc->led_state; |
| 653 |
+ |
| 654 |
+ if(cnt) |
| 655 |
+ { |
| 656 |
+ if(hfc->led_b_active&1) led_state|=vdata[hfc->vend_idx].led_bits[2]; |
| 657 |
+ if(hfc->led_b_active&2) led_state|=vdata[hfc->vend_idx].led_bits[3]; |
| 658 |
+ } |
| 659 |
+ else |
| 660 |
+ { |
| 661 |
+ if(!(hfc->led_b_active&1) || hfc->led_new_data&1) led_state&=~vdata[hfc->vend_idx].led_bits[2]; |
| 662 |
+ if(!(hfc->led_b_active&2) || hfc->led_new_data&2) led_state&=~vdata[hfc->vend_idx].led_bits[3]; |
| 663 |
} |
| 664 |
|
| 665 |
- /* check if new buffer needed */ |
| 666 |
- if (!fifo->buff) { |
| 667 |
- switch (fifo->fifonum) { |
| 668 |
- case HFCUSB_B1_TX: |
| 669 |
- if (fifo->hfc->regd.bsk[0]) |
| 670 |
- fifo->buff = *fifo->hfc->regd.bsk[0]; /* B1-channel tx buffer */ |
| 671 |
+ write_led(hfc,led_state); |
| 672 |
+ hfc->led_new_data=0; |
| 673 |
+ |
| 674 |
+ cnt=!cnt; |
| 675 |
+ // restart 4 hz timer |
| 676 |
+ hfc->led_timer.expires = jiffies + (LED_TIME * HZ) / 1000; |
| 677 |
+ if(!timer_pending(&hfc->led_timer)) add_timer(&hfc->led_timer); |
| 678 |
+} |
| 679 |
+ |
| 680 |
+/**************************/ |
| 681 |
+/* handle LED requests */ |
| 682 |
+/**************************/ |
| 683 |
+static void handle_led(hfcusb_data * hfc,int event) |
| 684 |
+{ |
| 685 |
+ __u8 led_state=hfc->led_state; |
| 686 |
+ |
| 687 |
+ // if no scheme -> no LED action |
| 688 |
+ if(vdata[hfc->vend_idx].led_scheme==LED_OFF) return; |
| 689 |
+ |
| 690 |
+ switch(event) |
| 691 |
+ { |
| 692 |
+ case LED_POWER_ON: |
| 693 |
+ led_state|=vdata[hfc->vend_idx].led_bits[0]; |
| 694 |
+ break; |
| 695 |
+ case LED_POWER_OFF: // no Power off handling |
| 696 |
+ break; |
| 697 |
+ case LED_S0_ON: |
| 698 |
+ led_state|=vdata[hfc->vend_idx].led_bits[1]; |
| 699 |
+ break; |
| 700 |
+ case LED_S0_OFF: |
| 701 |
+ led_state&=~vdata[hfc->vend_idx].led_bits[1]; |
| 702 |
break; |
| 703 |
- case HFCUSB_B2_TX: |
| 704 |
- if (fifo->hfc->regd.bsk[1]) |
| 705 |
- fifo->buff = *fifo->hfc->regd.bsk[1]; /* B2-channel tx buffer */ |
| 706 |
+ case LED_B1_ON: |
| 707 |
+ hfc->led_b_active|=1; |
| 708 |
break; |
| 709 |
- case HFCUSB_D_TX: |
| 710 |
- if (fifo->hfc->regd.dsq) |
| 711 |
- fifo->buff = skb_dequeue(fifo->hfc->regd.dsq); /* D-channel tx queue */ |
| 712 |
+ case LED_B1_OFF: |
| 713 |
+ hfc->led_b_active&=~1; |
| 714 |
break; |
| 715 |
- default: |
| 716 |
- return; /* error, invalid fifo */ |
| 717 |
+ case LED_B1_DATA: |
| 718 |
+ hfc->led_new_data|=1; |
| 719 |
+ break; |
| 720 |
+ case LED_B2_ON: |
| 721 |
+ hfc->led_b_active|=2; |
| 722 |
+ break; |
| 723 |
+ case LED_B2_OFF: |
| 724 |
+ hfc->led_b_active&=~2; |
| 725 |
+ break; |
| 726 |
+ case LED_B2_DATA: |
| 727 |
+ hfc->led_new_data|=2; |
| 728 |
+ break; |
| 729 |
+ } |
| 730 |
+ |
| 731 |
+ write_led(hfc,led_state); |
| 732 |
+} |
| 733 |
+ |
| 734 |
+/********************************/ |
| 735 |
+/* called when timer t3 expires */ |
| 736 |
+/********************************/ |
| 737 |
+static void l1_timer_expire_t3(hfcusb_data * hfc) |
| 738 |
+{ |
| 739 |
+ //printk (KERN_INFO "HFC-USB: l1_timer_expire_t3\n"); |
| 740 |
+ |
| 741 |
+ hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,PH_DEACTIVATE | INDICATION,NULL); |
| 742 |
+#ifdef VERBOSE_USB_DEBUG |
| 743 |
+ printk(KERN_INFO "PH_DEACTIVATE | INDICATION sent\n"); |
| 744 |
+#endif |
| 745 |
+ hfc->l1_activated=FALSE; |
| 746 |
+ handle_led(hfc,LED_S0_OFF); |
| 747 |
+} |
| 748 |
+ |
| 749 |
+/********************************/ |
| 750 |
+/* called when timer t4 expires */ |
| 751 |
+/********************************/ |
| 752 |
+static void l1_timer_expire_t4(hfcusb_data * hfc) |
| 753 |
+{ |
| 754 |
+ //printk (KERN_INFO "HFC-USB: l1_timer_expire_t4\n"); |
| 755 |
+ |
| 756 |
+ hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,PH_DEACTIVATE | INDICATION,NULL); |
| 757 |
+#ifdef VERBOSE_USB_DEBUG |
| 758 |
+ printk(KERN_INFO "PH_DEACTIVATE | INDICATION sent\n"); |
| 759 |
+#endif |
| 760 |
+ hfc->l1_activated=FALSE; |
| 761 |
+ handle_led(hfc,LED_S0_OFF); |
| 762 |
+} |
| 763 |
+ |
| 764 |
+/*****************************/ |
| 765 |
+/* handle S0 state changes */ |
| 766 |
+/*****************************/ |
| 767 |
+static void state_handler(hfcusb_data * hfc,__u8 state) |
| 768 |
+{ |
| 769 |
+ __u8 old_state; |
| 770 |
+ |
| 771 |
+ old_state=hfc->l1_state; |
| 772 |
+ |
| 773 |
+ // range check |
| 774 |
+ if(state==old_state || state<1 || state>8) return; |
| 775 |
+ |
| 776 |
+#ifdef VERBOSE_ISDN_DEBUG |
| 777 |
+ printk(KERN_INFO "HFC-USB: new S0 state:%d old_state:%d\n",state,old_state); |
| 778 |
+#endif |
| 779 |
+ |
| 780 |
+ if(state<4 || state==7 || state==8) |
| 781 |
+ { |
| 782 |
+ if(timer_pending(&hfc->t3_timer)) del_timer(&hfc->t3_timer); |
| 783 |
+ //printk(KERN_INFO "HFC-USB: T3 deactivated\n"); |
| 784 |
+ } |
| 785 |
+ |
| 786 |
+ if(state>=7) |
| 787 |
+ { |
| 788 |
+ if(timer_pending(&hfc->t4_timer)) del_timer(&hfc->t4_timer); |
| 789 |
+ //printk(KERN_INFO "HFC-USB: T4 deactivated\n"); |
| 790 |
+ } |
| 791 |
+ |
| 792 |
+ if(state==7 && !hfc->l1_activated) |
| 793 |
+ { |
| 794 |
+ hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,PH_ACTIVATE | INDICATION,NULL); |
| 795 |
+ //printk(KERN_INFO "HFC-USB: PH_ACTIVATE | INDICATION sent\n"); |
| 796 |
+ hfc->l1_activated=TRUE; |
| 797 |
+ handle_led(hfc,LED_S0_ON); |
| 798 |
+ } |
| 799 |
+ else |
| 800 |
+ if(state<=3 /* && activated*/) |
| 801 |
+ { |
| 802 |
+ if(old_state==7 || old_state==8) |
| 803 |
+ { |
| 804 |
+ //printk(KERN_INFO "HFC-USB: T4 activated\n"); |
| 805 |
+ hfc->t4_timer.expires = jiffies + (HFC_TIMER_T4 * HZ) / 1000; |
| 806 |
+ if(!timer_pending(&hfc->t4_timer)) add_timer(&hfc->t4_timer); |
| 807 |
} |
| 808 |
- if (!fifo->buff) { |
| 809 |
- fifo->active = 0; /* we are inactive now */ |
| 810 |
- fifo->hfc->active_fifos &= ~fifo->fifo_mask; |
| 811 |
- if (fifo->fifonum == HFCUSB_D_TX) { |
| 812 |
- test_and_set_bit(HFCUSB_L1_DTX, |
| 813 |
- &fifo->hfc->l1_event); |
| 814 |
- queue_task(&fifo->hfc->l1_tq, |
| 815 |
- &tq_immediate); |
| 816 |
- mark_bh(IMMEDIATE_BH); |
| 817 |
- } |
| 818 |
- return; |
| 819 |
+ else |
| 820 |
+ { |
| 821 |
+ hfc->d_if.ifc.l1l2(&hfc->d_if.ifc,PH_DEACTIVATE | INDICATION,NULL); |
| 822 |
+ //printk(KERN_INFO "HFC-USB: PH_DEACTIVATE | INDICATION sent\n"); |
| 823 |
+ hfc->l1_activated=FALSE; |
| 824 |
+ handle_led(hfc,LED_S0_OFF); |
| 825 |
} |
| 826 |
- fifo->act_ptr = fifo->buff->data; /* start of data */ |
| 827 |
- fifo->active = 1; |
| 828 |
- ii = 1; |
| 829 |
- fifo->hfc->active_fifos |= fifo->fifo_mask; |
| 830 |
- fifo->hfc->service_request &= ~fifo->fifo_mask; |
| 831 |
- } |
| 832 |
- /* fillup the send buffer */ |
| 833 |
- i = fifo->buff->len - (fifo->act_ptr - fifo->buff->data); /* remaining length */ |
| 834 |
- fifo->buffer[0] = !fifo->transmode; /* not eof */ |
| 835 |
- if (i > (fifo->usb_maxlen - ii)) { |
| 836 |
- i = fifo->usb_maxlen - ii; |
| 837 |
- } |
| 838 |
- if (i) |
| 839 |
- memcpy(fifo->buffer + ii, fifo->act_ptr, i); |
| 840 |
- fifo->urb.transfer_buffer_length = i + ii; |
| 841 |
- fifo->rx_offset = ii; |
| 842 |
-} /* fill_tx_urb */ |
| 843 |
- |
| 844 |
-/************************************************/ |
| 845 |
-/* transmit completion routine for all tx fifos */ |
| 846 |
-/************************************************/ |
| 847 |
-static void |
| 848 |
-tx_complete(purb_t urb) |
| 849 |
+ } |
| 850 |
+ |
| 851 |
+ hfc->l1_state=state; |
| 852 |
+} |
| 853 |
+ |
| 854 |
+ |
| 855 |
+/* prepare iso urb */ |
| 856 |
+static void fill_isoc_urb(struct urb *urb, struct usb_device *dev, unsigned int pipe, void *buf, |
| 857 |
+ int num_packets, int packet_size, int interval, usb_complete_t complete, void *context) |
| 858 |
{ |
| 859 |
- usb_fifo *fifo = (usb_fifo *) urb->context; /* pointer to our fifo */ |
| 860 |
+ int k; |
| 861 |
|
| 862 |
- fifo->hfc->service_request &= ~fifo->fifo_mask; /* no further handling */ |
| 863 |
- fifo->framenum = usb_get_current_frame_number(fifo->hfc->dev); |
| 864 |
+ spin_lock_init(&urb->lock); // do we really need spin_lock_init ? |
| 865 |
+ urb->dev = dev; |
| 866 |
+ urb->pipe = pipe; |
| 867 |
+ urb->complete = complete; |
| 868 |
+ urb->number_of_packets = num_packets; |
| 869 |
+ urb->transfer_buffer_length = packet_size * num_packets; |
| 870 |
+ urb->context = context; |
| 871 |
+ urb->transfer_buffer = buf; |
| 872 |
+ urb->transfer_flags = 0; |
| 873 |
+ urb->transfer_flags = USB_ISO_ASAP; |
| 874 |
+ urb->actual_length = 0; |
| 875 |
+ urb->interval = interval; |
| 876 |
+ for (k = 0; k < num_packets; k++) { |
| 877 |
+ urb->iso_frame_desc[k].offset = packet_size * k; |
| 878 |
+ urb->iso_frame_desc[k].length = packet_size; |
| 879 |
+ urb->iso_frame_desc[k].actual_length = 0; |
| 880 |
+ } |
| 881 |
+} |
| 882 |
|
| 883 |
- /* check for deactivation or error */ |
| 884 |
- if ((!fifo->active) || (urb->status)) { |
| 885 |
- fifo->hfc->active_fifos &= ~fifo->fifo_mask; /* we are inactive */ |
| 886 |
- fifo->active = 0; |
| 887 |
- if ((fifo->buff) && (fifo->fifonum == HFCUSB_D_TX)) { |
| 888 |
- dev_kfree_skb_any(fifo->buff); |
| 889 |
+/* allocs urbs and start isoc transfer with two pending urbs to avoid gaps in the transfer chain */ |
| 890 |
+static int start_isoc_chain(usb_fifo * fifo, int num_packets_per_urb,usb_complete_t complete,int packet_size) |
| 891 |
+{ |
| 892 |
+ int i, k, errcode; |
| 893 |
+ |
| 894 |
+#ifdef VERBOSE_USB_DEBUG |
| 895 |
+ printk(KERN_INFO "HFC-USB: starting ISO-chain for Fifo %i\n", fifo->fifonum); |
| 896 |
+#endif |
| 897 |
+ |
| 898 |
+ |
| 899 |
+ // allocate Memory for Iso out Urbs |
| 900 |
+ for (i = 0; i < 2; i++) { |
| 901 |
+ if (!(fifo->iso[i].purb)) { |
| 902 |
+ fifo->iso[i].purb = usb_alloc_urb(num_packets_per_urb); |
| 903 |
+ fifo->iso[i].owner_fifo = (struct usb_fifo *) fifo; |
| 904 |
+ |
| 905 |
+ // Init the first iso |
| 906 |
+ if (ISO_BUFFER_SIZE >= (fifo->usb_packet_maxlen * num_packets_per_urb)) |
| 907 |
+ { |
| 908 |
+ |
| 909 |
+ fill_isoc_urb(fifo->iso[i].purb, fifo->hfc->dev, fifo->pipe, fifo->iso[i].buffer, |
| 910 |
+ num_packets_per_urb, fifo->usb_packet_maxlen, fifo->intervall, |
| 911 |
+ complete, &fifo->iso[i]); |
| 912 |
+ |
| 913 |
+ memset(fifo->iso[i].buffer, 0, sizeof(fifo->iso[i].buffer)); |
| 914 |
+ |
| 915 |
+ // defining packet delimeters in fifo->buffer |
| 916 |
+ for(k = 0; k < num_packets_per_urb; k++) |
| 917 |
+ { |
| 918 |
+ fifo->iso[i].purb->iso_frame_desc[k].offset = k*packet_size; |
| 919 |
+ fifo->iso[i].purb->iso_frame_desc[k].length = packet_size; |
| 920 |
+ } |
| 921 |
+ } |
| 922 |
} |
| 923 |
- fifo->buff = NULL; |
| 924 |
- return; |
| 925 |
+ |
| 926 |
+ fifo->bit_line = BITLINE_INF; |
| 927 |
+ |
| 928 |
+ errcode = usb_submit_urb(fifo->iso[i].purb); |
| 929 |
+ fifo->active = (errcode >= 0) ? 1 : 0; |
| 930 |
+ if(errcode < 0) |
| 931 |
+ { |
| 932 |
+ printk(KERN_INFO "HFC-USB: error submitting ISO URB: %i.%i \n", errcode, i); |
| 933 |
+ }; |
| 934 |
+ |
| 935 |
} |
| 936 |
- fifo->act_ptr += (urb->transfer_buffer_length - fifo->rx_offset); /* adjust pointer */ |
| 937 |
- fill_tx_urb(fifo); /* refill the urb */ |
| 938 |
- fifo->hfc->threshold_mask |= fifo->fifo_mask; /* assume threshold reached */ |
| 939 |
- if (fifo->buff) |
| 940 |
- fifo->hfc->service_request |= fifo->fifo_mask; /* need to restart */ |
| 941 |
-} /* tx_complete */ |
| 942 |
|
| 943 |
-/***********************************************/ |
| 944 |
-/* receive completion routine for all rx fifos */ |
| 945 |
-/***********************************************/ |
| 946 |
-static void |
| 947 |
-rx_complete(purb_t urb) |
| 948 |
+ // errcode = (usb_submit_urb(fifo->iso[0].purb, GFP_KERNEL)); |
| 949 |
+ return(fifo->active); |
| 950 |
+} |
| 951 |
+ |
| 952 |
+/* stops running iso chain and frees their pending urbs */ |
| 953 |
+static void stop_isoc_chain(usb_fifo * fifo) |
| 954 |
{ |
| 955 |
- usb_fifo *fifo = (usb_fifo *) urb->context; /* pointer to our fifo */ |
| 956 |
- hfcusb_data *hfc = fifo->hfc; |
| 957 |
- usb_fifo *txfifo; |
| 958 |
- __u8 last_state; |
| 959 |
- int i, ii, currcnt, hdlci; |
| 960 |
- struct sk_buff *skb; |
| 961 |
- |
| 962 |
- urb->dev = hfc->dev; /* security init */ |
| 963 |
- if ((!fifo->active) || (urb->status)) { |
| 964 |
- hfc->service_request &= ~fifo->fifo_mask; /* no further handling */ |
| 965 |
- hfc->active_fifos &= ~fifo->fifo_mask; /* we are inactive */ |
| 966 |
- fifo->urb.interval = 0; /* cancel automatic rescheduling */ |
| 967 |
- if (fifo->buff) { |
| 968 |
- dev_kfree_skb_any(fifo->buff); |
| 969 |
- fifo->buff = NULL; |
| 970 |
+ int i; |
| 971 |
+ |
| 972 |
+ for(i = 0; i < 2; i++) |
| 973 |
+ { |
| 974 |
+ if(fifo->iso[i].purb) |
| 975 |
+ { |
| 976 |
+#ifdef VERBOSE_USB_DEBUG |
| 977 |
+ printk(KERN_INFO "HFC-USB: Stopping iso chain for fifo %i.%i\n", fifo->fifonum, i); |
| 978 |
+#endif |
| 979 |
+ usb_unlink_urb(fifo->iso[i].purb); |
| 980 |
+ usb_free_urb(fifo->iso[i].purb); |
| 981 |
+ fifo->iso[i].purb = NULL; |
| 982 |
} |
| 983 |
- return; |
| 984 |
} |
| 985 |
+ if (fifo->urb) { |
| 986 |
+ usb_unlink_urb(fifo->urb); |
| 987 |
+ usb_free_urb(fifo->urb); |
| 988 |
+ fifo->urb = NULL; |
| 989 |
+ } |
| 990 |
+ fifo->active = 0; |
| 991 |
+} |
| 992 |
|
| 993 |
- /* first check for any status changes */ |
| 994 |
- if ((urb->actual_length < fifo->rx_offset) |
| 995 |
- || (urb->actual_length > fifo->usb_maxlen)) |
| 996 |
- return; /* error condition */ |
| 997 |
- |
| 998 |
- if (fifo->rx_offset) { |
| 999 |
- hfc->threshold_mask = fifo->buffer[1]; /* update threshold status */ |
| 1000 |
- fifo->next_complete = fifo->buffer[0] & 1; |
| 1001 |
- if ((fifo->fifonum == HFCUSB_D_RX) && |
| 1002 |
- (hfc->led_req != hfc->led_act)) |
| 1003 |
- queue_control_request(hfc, HFCUSB_P_DATA, hfc->led_req); |
| 1004 |
- |
| 1005 |
- /* check if rescheduling needed */ |
| 1006 |
- if ((i = |
| 1007 |
- hfc->service_request & hfc->active_fifos & ~hfc-> |
| 1008 |
- threshold_mask)) { |
| 1009 |
- currcnt = |
| 1010 |
- usb_get_current_frame_number(hfc->dev); |
| 1011 |
- txfifo = hfc->fifos + HFCUSB_B1_TX; |
| 1012 |
- ii = 3; |
| 1013 |
- while (ii--) { |
| 1014 |
- if ((i & txfifo->fifo_mask) |
| 1015 |
- && (currcnt != txfifo->framenum)) { |
| 1016 |
- hfc->service_request &= |
| 1017 |
- ~txfifo->fifo_mask; |
| 1018 |
- if (!txfifo->buff) |
| 1019 |
- fill_tx_urb(txfifo); |
| 1020 |
- if (txfifo->buff) |
| 1021 |
- usb_submit_urb(&txfifo-> |
| 1022 |
- urb); |
| 1023 |
+// defines how much ISO packets are handled in one URB |
| 1024 |
+static int iso_packets[8]={ISOC_PACKETS_B,ISOC_PACKETS_B,ISOC_PACKETS_B,ISOC_PACKETS_B, |
| 1025 |
+ ISOC_PACKETS_D,ISOC_PACKETS_D,ISOC_PACKETS_D,ISOC_PACKETS_D}; |
| 1026 |
+ |
| 1027 |
+/*****************************************************/ |
| 1028 |
+/* transmit completion routine for all ISO tx fifos */ |
| 1029 |
+/*****************************************************/ |
| 1030 |
+static void tx_iso_complete(struct urb *urb) |
| 1031 |
+{ |
| 1032 |
+ iso_urb_struct *context_iso_urb = (iso_urb_struct *) urb->context; |
| 1033 |
+ usb_fifo *fifo = context_iso_urb->owner_fifo; |
| 1034 |
+ hfcusb_data *hfc = fifo->hfc; |
| 1035 |
+ int k, tx_offset, num_isoc_packets, sink, len, current_len,errcode,frame_complete,transp_mode,fifon; |
| 1036 |
+ __u8 threshbit; |
| 1037 |
+ __u8 threshtable[8] = { 1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; |
| 1038 |
+ |
| 1039 |
+ fifon=fifo->fifonum; |
| 1040 |
+ tx_offset=0; |
| 1041 |
+ // very weird error code when using ohci drivers, for now : ignore this error ... (MB) |
| 1042 |
+ if(urb->status == -EOVERFLOW) |
| 1043 |
+ { |
| 1044 |
+ urb->status = 0; |
| 1045 |
+#ifdef VERBOSE_USB_DEBUG |
| 1046 |
+ printk(KERN_INFO "HFC-USB: ignoring USB DATAOVERRUN for fifo %i \n",fifon); |
| 1047 |
+#endif |
| 1048 |
+ } |
| 1049 |
+ |
| 1050 |
+ if(fifo->active && !urb->status) |
| 1051 |
+ { |
| 1052 |
+ transp_mode=0; |
| 1053 |
+ if(fifon<4 && hfc->b_mode[fifon/2]==L1_MODE_TRANS) transp_mode=TRUE; |
| 1054 |
+ |
| 1055 |
+ threshbit = threshtable[fifon] & hfc->threshold_mask; // is threshold set for our channel? |
| 1056 |
+ num_isoc_packets=iso_packets[fifon]; |
| 1057 |
+ |
| 1058 |
+ if(fifon >= HFCUSB_D_TX) |
| 1059 |
+ { |
| 1060 |
+ sink = (threshbit) ? SINK_DMIN : SINK_DMAX; // how much bit go to the sink for D-channel? |
| 1061 |
+ } |
| 1062 |
+ else |
| 1063 |
+ { |
| 1064 |
+ sink = (threshbit) ? SINK_MIN : SINK_MAX; // how much bit go to the sink for B-channel? |
| 1065 |
+ } |
| 1066 |
+ |
| 1067 |
+ // prepare ISO Urb |
| 1068 |
+ fill_isoc_urb(urb, fifo->hfc->dev, fifo->pipe,context_iso_urb->buffer, num_isoc_packets, |
| 1069 |
+ fifo->usb_packet_maxlen, fifo->intervall, tx_iso_complete, urb->context); |
| 1070 |
+ memset(context_iso_urb->buffer, 0, sizeof(context_iso_urb->buffer)); |
| 1071 |
+ |
| 1072 |
+ frame_complete=FALSE; |
| 1073 |
+ |
| 1074 |
+ // Generate Iso Packets |
| 1075 |
+ for(k = 0; k < num_isoc_packets; ++k) |
| 1076 |
+ { |
| 1077 |
+ if(fifo->skbuff) |
| 1078 |
+ { |
| 1079 |
+ len = fifo->skbuff->len; // remaining length |
| 1080 |
+ |
| 1081 |
+ fifo->bit_line -= sink; // we lower data margin every msec |
| 1082 |
+ current_len = (0 - fifo->bit_line) / 8; |
| 1083 |
+ if(current_len > 14) current_len = 14; // maximum 15 byte for every ISO packet makes our life easier |
| 1084 |
+ current_len = (len <= current_len) ? len : current_len; |
| 1085 |
+ fifo->bit_line += current_len * 8; // how much bit do we put on the line? |
| 1086 |
+ |
| 1087 |
+ context_iso_urb->buffer[tx_offset] = 0; |
| 1088 |
+ if(current_len == len) |
| 1089 |
+ { |
| 1090 |
+ if(!transp_mode) |
| 1091 |
+ { |
| 1092 |
+ context_iso_urb->buffer[tx_offset] = 1; // here frame completion |
| 1093 |
+ fifo->bit_line += 32; // add 2 byte flags and 16bit CRC at end of ISDN frame |
| 1094 |
+ } |
| 1095 |
+ frame_complete = TRUE; |
| 1096 |
+ } |
| 1097 |
+ |
| 1098 |
+ // copy bytes from buffer into ISO_URB |
| 1099 |
+ memcpy(context_iso_urb->buffer+tx_offset+1,fifo->skbuff->data,current_len); |
| 1100 |
+ skb_pull(fifo->skbuff,current_len); |
| 1101 |
+ |
| 1102 |
+ // define packet delimeters within the URB buffer |
| 1103 |
+ urb->iso_frame_desc[k].offset = tx_offset; |
| 1104 |
+ urb->iso_frame_desc[k].length = current_len + 1; |
| 1105 |
+ |
| 1106 |
+ tx_offset += (current_len + 1); |
| 1107 |
+ // printk(KERN_INFO "HFC-USB: fifonum:%d,%d bytes to send, %d bytes ISO packet,bitline:%d,sink:%d,threshbit:%d,threshmask:%x\n",fifon,len,current_len,fifo->bit_line,sink,threshbit,hfc->threshold_mask); |
| 1108 |
+ if(!transp_mode) |
| 1109 |
+ { |
| 1110 |
+ if(fifon==HFCUSB_B1_TX) handle_led(hfc,LED_B1_DATA); |
| 1111 |
+ if(fifon==HFCUSB_B2_TX) handle_led(hfc,LED_B2_DATA); |
| 1112 |
+ } |
| 1113 |
+ } |
| 1114 |
+ else |
| 1115 |
+ { |
| 1116 |
+ // we have no more data - generate 1 byte ISO packets |
| 1117 |
+ urb->iso_frame_desc[k].offset = tx_offset++; |
| 1118 |
+ |
| 1119 |
+ urb->iso_frame_desc[k].length = 1; |
| 1120 |
+ fifo->bit_line -= sink; // we lower data margin every msec |
| 1121 |
+ |
| 1122 |
+ if(fifo->bit_line < BITLINE_INF) |
| 1123 |
+ { |
| 1124 |
+ fifo->bit_line = BITLINE_INF; |
| 1125 |
+ //printk (KERN_INFO "HFC-USB: BITLINE_INF underrun\n"); |
| 1126 |
} |
| 1127 |
- txfifo += 2; |
| 1128 |
} |
| 1129 |
- } |
| 1130 |
|
| 1131 |
- /* handle l1 events */ |
| 1132 |
- if ((fifo->buffer[0] >> 4) != hfc->l1_state) { |
| 1133 |
- last_state = hfc->l1_state; |
| 1134 |
- hfc->l1_state = fifo->buffer[0] >> 4; /* update status */ |
| 1135 |
- if (timer_pending(&hfc->t4_timer)) |
| 1136 |
- del_timer(&hfc->t4_timer); |
| 1137 |
- if (((hfc->l1_state == 3) && |
| 1138 |
- ((last_state == 7) || |
| 1139 |
- (last_state == 8))) || |
| 1140 |
- ((timer_pending(&hfc->t3_timer) && |
| 1141 |
- (hfc->l1_state == 8)))) { |
| 1142 |
- hfc->t4_timer.expires = jiffies + 2; |
| 1143 |
- add_timer(&hfc->t4_timer); |
| 1144 |
- } else { |
| 1145 |
- if (timer_pending(&hfc->t3_timer) |
| 1146 |
- && (hfc->l1_state == 7)) |
| 1147 |
- del_timer(&hfc->t3_timer); /* no longer needed */ |
| 1148 |
- test_and_set_bit(HFCUSB_L1_STATECHANGE, |
| 1149 |
- &hfc->l1_event); |
| 1150 |
- queue_task(&hfc->l1_tq, &tq_immediate); |
| 1151 |
- mark_bh(IMMEDIATE_BH); |
| 1152 |
+ if(frame_complete) |
| 1153 |
+ { |
| 1154 |
+ // delete the buffer only once, here or in hfc_usb_l2l1() in a PH_DATA|REQUEST |
| 1155 |
+ fifo->delete_flg=TRUE; |
| 1156 |
+ |
| 1157 |
+ fifo->hif->l1l2(fifo->hif,PH_DATA|CONFIRM,(void*)fifo->skbuff->truesize); |
| 1158 |
+ |
| 1159 |
+ if(fifo->skbuff && fifo->delete_flg) |
| 1160 |
+ { |
| 1161 |
+ dev_kfree_skb_any(fifo->skbuff); |
| 1162 |
+ //printk(KERN_INFO "HFC-USB: skbuff=NULL on fifo:%d\n",fifo->fifonum); |
| 1163 |
+ fifo->skbuff = NULL; |
| 1164 |
+ fifo->delete_flg=FALSE; |
| 1165 |
+ } |
| 1166 |
+ |
| 1167 |
+ frame_complete=FALSE; |
| 1168 |
} |
| 1169 |
+ } |
| 1170 |
+ |
| 1171 |
+ errcode = usb_submit_urb(urb); |
| 1172 |
+ if(errcode < 0) |
| 1173 |
+ { |
| 1174 |
+ printk(KERN_INFO "HFC-USB: error submitting ISO URB: %i \n", errcode); |
| 1175 |
+ } |
| 1176 |
+ } |
| 1177 |
+ else |
| 1178 |
+ { |
| 1179 |
+ if(urb->status) |
| 1180 |
+ { |
| 1181 |
+ printk(KERN_INFO "HFC-USB: tx_iso_complete : urb->status %i, fifonum %i\n", urb->status,fifon); |
| 1182 |
} |
| 1183 |
} |
| 1184 |
|
| 1185 |
- /* check the length for data and move if present */ |
| 1186 |
- if (fifo->next_complete || (urb->actual_length > fifo->rx_offset)) { |
| 1187 |
- i = fifo->buff->len + urb->actual_length - fifo->rx_offset; /* new total length */ |
| 1188 |
- hdlci = (fifo->transmode) ? 0 : 3; |
| 1189 |
- if (i <= (fifo->max_size + hdlci)) { |
| 1190 |
- memcpy(fifo->act_ptr, |
| 1191 |
- fifo->buffer + fifo->rx_offset, |
| 1192 |
- urb->actual_length - fifo->rx_offset); |
| 1193 |
- fifo->act_ptr += |
| 1194 |
- (urb->actual_length - fifo->rx_offset); |
| 1195 |
- fifo->buff->len += |
| 1196 |
- (urb->actual_length - fifo->rx_offset); |
| 1197 |
- } else |
| 1198 |
- fifo->buff->len = fifo->max_size + 4; /* mark frame as to long */ |
| 1199 |
- if (fifo->next_complete && (urb->actual_length < fifo->usb_maxlen)) { |
| 1200 |
- /* the frame is complete */ |
| 1201 |
- fifo->next_complete = 0; |
| 1202 |
- if (((!*(fifo->act_ptr - 1)) || fifo->transmode) && |
| 1203 |
- (fifo->buff->len >= (hdlci + 1)) |
| 1204 |
- && (fifo->buff->len <= |
| 1205 |
- (fifo->max_size + hdlci)) && |
| 1206 |
- ((skb = dev_alloc_skb(fifo->max_size + hdlci)) != NULL)) { |
| 1207 |
- fifo->buff->len -= hdlci; /* adjust size */ |
| 1208 |
- switch (fifo->fifonum) { |
| 1209 |
- case HFCUSB_D_RX: |
| 1210 |
- skb_queue_tail(hfc->regd. |
| 1211 |
- drq, |
| 1212 |
- fifo->buff); |
| 1213 |
- test_and_set_bit |
| 1214 |
- (HFCUSB_L1_DRX, |
| 1215 |
- &hfc->l1_event); |
| 1216 |
- queue_task(&hfc->l1_tq, |
| 1217 |
- &tq_immediate); |
| 1218 |
- mark_bh(IMMEDIATE_BH); |
| 1219 |
- break; |
| 1220 |
+} /* tx_iso_complete */ |
| 1221 |
|
| 1222 |
- case HFCUSB_B1_RX: |
| 1223 |
- if (hfc->regd.brq[0]) { |
| 1224 |
- skb_queue_tail |
| 1225 |
- (hfc->regd. |
| 1226 |
- brq[0], |
| 1227 |
- fifo->buff); |
| 1228 |
- hfc->regd. |
| 1229 |
- bch_l1l2(hfc-> |
| 1230 |
- regd. |
| 1231 |
- arg_hisax, |
| 1232 |
- 0, |
| 1233 |
- PH_DATA |
| 1234 |
- | |
| 1235 |
- INDICATION, |
| 1236 |
- (void *) |
| 1237 |
- fifo-> |
| 1238 |
- buff); |
| 1239 |
- } else |
| 1240 |
- dev_kfree_skb_any |
| 1241 |
- (fifo->buff); |
| 1242 |
- break; |
| 1243 |
- |
| 1244 |
- case HFCUSB_B2_RX: |
| 1245 |
- if (hfc->regd.brq[1]) { |
| 1246 |
- skb_queue_tail |
| 1247 |
- (hfc->regd. |
| 1248 |
- brq[1], |
| 1249 |
- fifo->buff); |
| 1250 |
- hfc->regd. |
| 1251 |
- bch_l1l2(hfc-> |
| 1252 |
- regd. |
| 1253 |
- arg_hisax, |
| 1254 |
- 1, |
| 1255 |
- PH_DATA |
| 1256 |
- | |
| 1257 |
- INDICATION, |
| 1258 |
- (void |
| 1259 |
- *) |
| 1260 |
- fifo-> |
| 1261 |
- buff); |
| 1262 |
- } else |
| 1263 |
- dev_kfree_skb_any |
| 1264 |
- (fifo->buff); |
| 1265 |
- break; |
| 1266 |
+/*****************************************************/ |
| 1267 |
+/* receive completion routine for all ISO tx fifos */ |
| 1268 |
+/*****************************************************/ |
| 1269 |
+static void rx_iso_complete(struct urb *urb) |
| 1270 |
+{ |
| 1271 |
+ iso_urb_struct *context_iso_urb = (iso_urb_struct *) urb->context; |
| 1272 |
+ usb_fifo *fifo = context_iso_urb->owner_fifo; |
| 1273 |
+ hfcusb_data *hfc = fifo->hfc; |
| 1274 |
+ int k, len, errcode, offset, num_isoc_packets,fifon; |
| 1275 |
+ __u8 *buf; |
| 1276 |
|
| 1277 |
- case HFCUSB_PCM_RX: |
| 1278 |
- skb_queue_tail(&hfc->regd. |
| 1279 |
- erq, |
| 1280 |
- fifo->buff); |
| 1281 |
- test_and_set_bit |
| 1282 |
- (HFCUSB_L1_ERX, |
| 1283 |
- &hfc->l1_event); |
| 1284 |
- queue_task(&hfc->l1_tq, |
| 1285 |
- &tq_immediate); |
| 1286 |
- mark_bh(IMMEDIATE_BH); |
| 1287 |
- break; |
| 1288 |
+ fifon=fifo->fifonum; |
| 1289 |
+ // very weird error code when using ohci drivers, for now : ignore this error ... (MB) |
| 1290 |
+ if(urb->status == -EOVERFLOW) |
| 1291 |
+ { |
| 1292 |
+ urb->status = 0; |
| 1293 |
+#ifdef VERBOSE_USB_DEBUG |
| 1294 |
+ printk(KERN_INFO "HFC-USB: ignoring USB DATAOVERRUN for fifo %i \n",fifon); |
| 1295 |
+#endif |
| 1296 |
+ } |
| 1297 |
|
| 1298 |
- default: |
| 1299 |
- dev_kfree_skb_any(fifo-> |
| 1300 |
- buff); |
| 1301 |
- break; |
| 1302 |
+ if(fifo->active && !urb->status) |
| 1303 |
+ { |
| 1304 |
+ num_isoc_packets=iso_packets[fifon]; |
| 1305 |
+ |
| 1306 |
+ // Generate D-Channel Iso Packets |
| 1307 |
+ for(k = 0; k < num_isoc_packets; ++k) |
| 1308 |
+ { |
| 1309 |
+ len=urb->iso_frame_desc[k].actual_length; |
| 1310 |
+ offset=urb->iso_frame_desc[k].offset; |
| 1311 |
+ buf=context_iso_urb->buffer+offset; |
| 1312 |
+ |
| 1313 |
+ if(fifo->last_urblen!=fifo->usb_packet_maxlen) |
| 1314 |
+ { |
| 1315 |
+ // the threshold mask is in the 2nd status byte |
| 1316 |
+ hfc->threshold_mask=buf[1]; |
| 1317 |
+ // the S0 state is in the upper half of the 1st status byte |
| 1318 |
+ state_handler(hfc,buf[0] >> 4); |
| 1319 |
+ // if we have more than the 2 status bytes -> collect data |
| 1320 |
+ if(len>2) collect_rx_frame(fifo,buf+2,len-2,buf[0]&1); |
| 1321 |
} |
| 1322 |
- fifo->buff = skb; |
| 1323 |
- } |
| 1324 |
- fifo->buff->len = 0; /* reset counter */ |
| 1325 |
- fifo->act_ptr = fifo->buff->data; /* and pointer */ |
| 1326 |
+ else collect_rx_frame(fifo,buf,len,0); |
| 1327 |
+ |
| 1328 |
+ fifo->last_urblen=len; |
| 1329 |
+ |
| 1330 |
+ } |
| 1331 |
+ |
| 1332 |
+ // prepare ISO Urb |
| 1333 |
+ fill_isoc_urb(urb, fifo->hfc->dev, fifo->pipe,context_iso_urb->buffer, num_isoc_packets, |
| 1334 |
+ fifo->usb_packet_maxlen, fifo->intervall, rx_iso_complete, urb->context); |
| 1335 |
+ |
| 1336 |
+ errcode = usb_submit_urb(urb); |
| 1337 |
+ if(errcode < 0) |
| 1338 |
+ { |
| 1339 |
+ printk(KERN_INFO "HFC-USB: error submitting ISO URB: %i \n", errcode); |
| 1340 |
+ } |
| 1341 |
+ } |
| 1342 |
+ else |
| 1343 |
+ { |
| 1344 |
+ if(urb->status) |
| 1345 |
+ { |
| 1346 |
+ printk(KERN_INFO "HFC-USB: rx_iso_complete : urb->status %i, fifonum %i\n", urb->status,fifon); |
| 1347 |
+ } |
| 1348 |
+ } |
| 1349 |
+} /* rx_iso_complete */ |
| 1350 |
+ |
| 1351 |
+ |
| 1352 |
+/*****************************************************/ |
| 1353 |
+/* collect data from interrupt or isochron in */ |
| 1354 |
+/*****************************************************/ |
| 1355 |
+static void collect_rx_frame(usb_fifo *fifo,__u8 *data,int len,int finish) |
| 1356 |
+{ |
| 1357 |
+ hfcusb_data *hfc = fifo->hfc; |
| 1358 |
+ int transp_mode,fifon; |
| 1359 |
+ |
| 1360 |
+ fifon=fifo->fifonum; |
| 1361 |
+ transp_mode=0; |
| 1362 |
+ if(fifon<4 && hfc->b_mode[fifon/2]==L1_MODE_TRANS) transp_mode=TRUE; |
| 1363 |
+ |
| 1364 |
+ //printk(KERN_INFO "HFC-USB: got %d bytes finish:%d max_size:%d fifo:%d\n",len,finish,fifo->max_size,fifon); |
| 1365 |
+ if(!fifo->skbuff) |
| 1366 |
+ { |
| 1367 |
+ // allocate sk buffer |
| 1368 |
+ fifo->skbuff=dev_alloc_skb(fifo->max_size + 3); |
| 1369 |
+ if(!fifo->skbuff) |
| 1370 |
+ { |
| 1371 |
+ printk(KERN_INFO "HFC-USB: cannot allocate buffer (dev_alloc_skb) fifo:%d\n",fifon); |
| 1372 |
+ return; |
| 1373 |
+ } |
| 1374 |
+ |
| 1375 |
+ } |
| 1376 |
+ |
| 1377 |
+ if(len && fifo->skbuff->len+len<fifo->max_size) |
| 1378 |
+ { |
| 1379 |
+ memcpy(skb_put(fifo->skbuff,len),data,len); |
| 1380 |
+ } |
| 1381 |
+ else printk(KERN_INFO "HCF-USB: got frame exceeded fifo->max_size:%d\n",fifo->max_size); |
| 1382 |
+ |
| 1383 |
+ // give transparent data up, when 128 byte are available |
| 1384 |
+ if(transp_mode && fifo->skbuff->len>=128) |
| 1385 |
+ { |
| 1386 |
+ fifo->hif->l1l2(fifo->hif,PH_DATA | INDICATION,fifo->skbuff); |
| 1387 |
+ fifo->skbuff = NULL; // buffer was freed from upper layer |
| 1388 |
+ return; |
| 1389 |
+ } |
| 1390 |
+ |
| 1391 |
+ // we have a complete hdlc packet |
| 1392 |
+ if(finish) |
| 1393 |
+ { |
| 1394 |
+ if(!fifo->skbuff->data[fifo->skbuff->len-1]) |
| 1395 |
+ { |
| 1396 |
+ skb_trim(fifo->skbuff,fifo->skbuff->len-3); // remove CRC & status |
| 1397 |
+ |
| 1398 |
+ //printk(KERN_INFO "HFC-USB: got frame %d bytes on fifo:%d\n",fifo->skbuff->len,fifon); |
| 1399 |
+ |
| 1400 |
+ if(fifon==HFCUSB_PCM_RX) fifo->hif->l1l2(fifo->hif,PH_DATA_E | INDICATION,fifo->skbuff); |
| 1401 |
+ else fifo->hif->l1l2(fifo->hif,PH_DATA | INDICATION,fifo->skbuff); |
| 1402 |
+ |
| 1403 |
+ fifo->skbuff = NULL; // buffer was freed from upper layer |
| 1404 |
+ } |
| 1405 |
+ else |
| 1406 |
+ { |
| 1407 |
+ printk(KERN_INFO "HFC-USB: got frame %d bytes but CRC ERROR!!!\n",fifo->skbuff->len); |
| 1408 |
+ |
| 1409 |
+ skb_trim(fifo->skbuff,0); // clear whole buffer |
| 1410 |
+ } |
| 1411 |
+ } |
| 1412 |
+ |
| 1413 |
+ // LED flashing only in HDLC mode |
| 1414 |
+ if(!transp_mode) |
| 1415 |
+ { |
| 1416 |
+ if(fifon==HFCUSB_B1_RX) handle_led(hfc,LED_B1_DATA); |
| 1417 |
+ if(fifon==HFCUSB_B2_RX) handle_led(hfc,LED_B2_DATA); |
| 1418 |
+ } |
| 1419 |
+} |
| 1420 |
+ |
| 1421 |
+/***********************************************/ |
| 1422 |
+/* receive completion routine for all rx fifos */ |
| 1423 |
+/***********************************************/ |
| 1424 |
+static void rx_complete(struct urb *urb) |
| 1425 |
+{ |
| 1426 |
+ int len; |
| 1427 |
+ __u8 *buf; |
| 1428 |
+ usb_fifo *fifo = (usb_fifo *) urb->context; /* pointer to our fifo */ |
| 1429 |
+ hfcusb_data *hfc = fifo->hfc; |
| 1430 |
+ |
| 1431 |
+ urb->dev = hfc->dev; /* security init */ |
| 1432 |
+ |
| 1433 |
+ if((!fifo->active) || (urb->status)) { |
| 1434 |
+#ifdef VERBOSE_USB_DEBUG |
| 1435 |
+ printk(KERN_INFO "HFC-USB: RX-Fifo %i is going down (%i)\n", fifo->fifonum, urb->status); |
| 1436 |
+#endif |
| 1437 |
+ fifo->urb->interval = 0; /* cancel automatic rescheduling */ |
| 1438 |
+ if(fifo->skbuff) { |
| 1439 |
+ dev_kfree_skb_any(fifo->skbuff); |
| 1440 |
+ fifo->skbuff = NULL; |
| 1441 |
} |
| 1442 |
+ return; |
| 1443 |
} |
| 1444 |
- fifo->rx_offset = (urb->actual_length < fifo->usb_maxlen) ? 2 : 0; |
| 1445 |
-} /* rx_complete */ |
| 1446 |
+ |
| 1447 |
+ len=urb->actual_length; |
| 1448 |
+ buf=fifo->buffer; |
| 1449 |
+ |
| 1450 |
+ if(fifo->last_urblen!=fifo->usb_packet_maxlen) { |
| 1451 |
+ // the threshold mask is in the 2nd status byte |
| 1452 |
+ hfc->threshold_mask=buf[1]; |
| 1453 |
+ // the S0 state is in the upper half of the 1st status byte |
| 1454 |
+ state_handler(hfc,buf[0] >> 4); |
| 1455 |
+ // if we have more than the 2 status bytes -> collect data |
| 1456 |
+ if(len>2) collect_rx_frame(fifo,buf+2,urb->actual_length-2,buf[0]&1); |
| 1457 |
+ } else |
| 1458 |
+ collect_rx_frame(fifo,buf,urb->actual_length,0); |
| 1459 |
+ |
| 1460 |
+ fifo->last_urblen=urb->actual_length; |
| 1461 |
+ |
| 1462 |
+ |
| 1463 |
+} /* rx_complete */ |
| 1464 |
+ |
| 1465 |
+ |
| 1466 |
|
| 1467 |
/***************************************************/ |
| 1468 |
/* start the interrupt transfer for the given fifo */ |
| 1469 |
/***************************************************/ |
| 1470 |
-static void |
| 1471 |
-start_rx_fifo(usb_fifo * fifo) |
| 1472 |
+static void start_int_fifo(usb_fifo * fifo) |
| 1473 |
{ |
| 1474 |
- if (fifo->buff) |
| 1475 |
- return; /* still active */ |
| 1476 |
- if (! |
| 1477 |
- (fifo->buff = |
| 1478 |
- dev_alloc_skb(fifo->max_size + (fifo->transmode ? 0 : 3)))) |
| 1479 |
- return; |
| 1480 |
- fifo->act_ptr = fifo->buff->data; |
| 1481 |
- FILL_INT_URB(&fifo->urb, fifo->hfc->dev, fifo->pipe, fifo->buffer, |
| 1482 |
- fifo->usb_maxlen, rx_complete, fifo, fifo->intervall); |
| 1483 |
- fifo->next_complete = 0; |
| 1484 |
- fifo->rx_offset = 2; |
| 1485 |
- fifo->active = 1; /* must be marked active */ |
| 1486 |
- fifo->hfc->active_fifos |= fifo->fifo_mask; |
| 1487 |
- if (usb_submit_urb(&fifo->urb)) { |
| 1488 |
+ int errcode; |
| 1489 |
+ |
| 1490 |
+#ifdef VERBOSE_USB_DEBUG |
| 1491 |
+ printk(KERN_INFO "HFC-USB: starting intr IN fifo:%d\n", fifo->fifonum); |
| 1492 |
+#endif |
| 1493 |
+ if (!fifo->urb) { |
| 1494 |
+ fifo->urb = usb_alloc_urb(0); |
| 1495 |
+ if (!fifo->urb) |
| 1496 |
+ return; |
| 1497 |
+ } |
| 1498 |
+ usb_fill_int_urb(fifo->urb, fifo->hfc->dev, fifo->pipe, fifo->buffer, |
| 1499 |
+ fifo->usb_packet_maxlen, rx_complete, fifo, fifo->intervall); |
| 1500 |
+ fifo->active = 1; /* must be marked active */ |
| 1501 |
+ errcode = usb_submit_urb(fifo->urb); |
| 1502 |
+ |
| 1503 |
+ if(errcode) |
| 1504 |
+ { |
| 1505 |
+ printk(KERN_INFO "HFC-USB: submit URB error(start_int_info): status:%i\n", errcode); |
| 1506 |
fifo->active = 0; |
| 1507 |
- fifo->hfc->active_fifos &= ~fifo->fifo_mask; |
| 1508 |
- dev_kfree_skb_any(fifo->buff); |
| 1509 |
- fifo->buff = NULL; |
| 1510 |
+ fifo->skbuff = NULL; |
| 1511 |
} |
| 1512 |
-} /* start_rx_fifo */ |
| 1513 |
+} /* start_int_fifo */ |
| 1514 |
|
| 1515 |
-/***************************************************************/ |
| 1516 |
-/* control completion routine handling background control cmds */ |
| 1517 |
-/***************************************************************/ |
| 1518 |
-static void |
| 1519 |
-ctrl_complete(purb_t urb) |
| 1520 |
+/*****************************/ |
| 1521 |
+/* set the B-channel mode */ |
| 1522 |
+/*****************************/ |
| 1523 |
+static void set_hfcmode(hfcusb_data *hfc,int channel,int mode) |
| 1524 |
{ |
| 1525 |
- hfcusb_data *hfc = (hfcusb_data *) urb->context; |
| 1526 |
+ __u8 val,idx_table[2]={0,2}; |
| 1527 |
|
| 1528 |
- urb->dev = hfc->dev; |
| 1529 |
- if (hfc->ctrl_cnt) { |
| 1530 |
- switch (hfc->ctrl_buff[hfc->ctrl_out_idx].hfc_reg) { |
| 1531 |
- case HFCUSB_FIFO: |
| 1532 |
- hfc->ctrl_fifo = |
| 1533 |
- hfc->ctrl_buff[hfc->ctrl_out_idx]. |
| 1534 |
- reg_val; |
| 1535 |
- break; |
| 1536 |
- case HFCUSB_F_USAGE: |
| 1537 |
- if (!hfc->dfifo_fill) { |
| 1538 |
- fill_tx_urb(hfc->fifos + |
| 1539 |
- HFCUSB_D_TX); |
| 1540 |
- if (hfc->fifos[HFCUSB_D_TX].buff) |
| 1541 |
- usb_submit_urb(&hfc-> |
| 1542 |
- fifos |
| 1543 |
- [HFCUSB_D_TX]. |
| 1544 |
- urb); |
| 1545 |
- } else { |
| 1546 |
- queue_control_request(hfc, |
| 1547 |
- HFCUSB_FIFO, |
| 1548 |
- HFCUSB_D_TX); |
| 1549 |
- queue_control_request(hfc, |
| 1550 |
- HFCUSB_F_USAGE, |
| 1551 |
- 0); |
| 1552 |
- } |
| 1553 |
- break; |
| 1554 |
- case HFCUSB_SCTRL_R: |
| 1555 |
- switch (hfc->ctrl_fifo) { |
| 1556 |
- case HFCUSB_B1_RX: |
| 1557 |
- if (hfc->bch_enables & 1) |
| 1558 |
- start_rx_fifo(hfc-> |
| 1559 |
- fifos |
| 1560 |
- + |
| 1561 |
- HFCUSB_B1_RX); |
| 1562 |
- break; |
| 1563 |
- case HFCUSB_B2_RX: |
| 1564 |
- if (hfc->bch_enables & 2) |
| 1565 |
- start_rx_fifo(hfc-> |
| 1566 |
- fifos |
| 1567 |
- + |
| 1568 |
- HFCUSB_B2_RX); |
| 1569 |
- break; |
| 1570 |
- } |
| 1571 |
- if (hfc->bch_enables & 3) |
| 1572 |
- hfc->led_req |= LED_BCH; |
| 1573 |
- else |
| 1574 |
- hfc->led_req &= ~LED_BCH; |
| 1575 |
- break; |
| 1576 |
- case HFCUSB_P_DATA: |
| 1577 |
- hfc->led_act = |
| 1578 |
- hfc->ctrl_buff[hfc->ctrl_out_idx]. |
| 1579 |
- reg_val; |
| 1580 |
- break; |
| 1581 |
- } |
| 1582 |
- hfc->ctrl_cnt--; /* decrement actual count */ |
| 1583 |
- if (++hfc->ctrl_out_idx >= HFC_CTRL_BUFSIZE) |
| 1584 |
- hfc->ctrl_out_idx = 0; /* pointer wrap */ |
| 1585 |
- ctrl_start_transfer(hfc); /* start next transfer */ |
| 1586 |
+#ifdef VERBOSE_ISDN_DEBUG |
| 1587 |
+ printk (KERN_INFO "HFC-USB: setting channel %d to mode %d\n",channel,mode); |
| 1588 |
+#endif |
| 1589 |
+ |
| 1590 |
+ hfc->b_mode[channel]=mode; |
| 1591 |
+ |
| 1592 |
+ // setup CON_HDLC |
| 1593 |
+ val=0; |
| 1594 |
+ if(mode!=L1_MODE_NULL) val=8; // enable fifo? |
| 1595 |
+ if(mode==L1_MODE_TRANS) val|=2; // set transparent bit |
| 1596 |
+ |
| 1597 |
+ queue_control_request(hfc,HFCUSB_FIFO,idx_table[channel],1); // set FIFO to transmit register |
| 1598 |
+ queue_control_request(hfc,HFCUSB_CON_HDLC,val,1); |
| 1599 |
+ queue_control_request(hfc,HFCUSB_INC_RES_F,2,1); // reset fifo |
| 1600 |
+ |
| 1601 |
+ queue_control_request(hfc,HFCUSB_FIFO,idx_table[channel]+1,1); // set FIFO to receive register |
| 1602 |
+ queue_control_request(hfc,HFCUSB_CON_HDLC,val,1); |
| 1603 |
+ queue_control_request(hfc,HFCUSB_INC_RES_F,2,1); // reset fifo |
| 1604 |
+ |
| 1605 |
+ val=0x40; |
| 1606 |
+ if(hfc->b_mode[0]) val|=1; |
| 1607 |
+ if(hfc->b_mode[1]) val|=2; |
| 1608 |
+ queue_control_request(hfc,HFCUSB_SCTRL,val,1); |
| 1609 |
+ |
| 1610 |
+ val=0; |
| 1611 |
+ if(hfc->b_mode[0]) val|=1; |
| 1612 |
+ if(hfc->b_mode[1]) val|=2; |
| 1613 |
+ queue_control_request(hfc,HFCUSB_SCTRL_R,val,1); |
| 1614 |
+ |
| 1615 |
+ if(mode==L1_MODE_NULL) |
| 1616 |
+ { |
| 1617 |
+ if(channel) handle_led(hfc,LED_B2_OFF); |
| 1618 |
+ else handle_led(hfc,LED_B1_OFF); |
| 1619 |
} |
| 1620 |
-} /* ctrl_complete */ |
| 1621 |
+ else |
| 1622 |
+ { |
| 1623 |
+ if(channel) handle_led(hfc,LED_B2_ON); |
| 1624 |
+ else handle_led(hfc,LED_B1_ON); |
| 1625 |
+ } |
| 1626 |
+} |
| 1627 |
|
| 1628 |
-/*****************************************/ |
| 1629 |
-/* Layer 1 + D channel access from HiSax */ |
| 1630 |
-/*****************************************/ |
| 1631 |
-static void |
| 1632 |
-hfcusb_l1_access(void *drvarg, int pr, void *arg) |
| 1633 |
-{ |
| 1634 |
- hfcusb_data *hfc = (hfcusb_data *) drvarg; |
| 1635 |
- |
| 1636 |
- switch (pr) { |
| 1637 |
- case (PH_DATA | REQUEST): |
| 1638 |
- case (PH_PULL | INDICATION): |
| 1639 |
- skb_queue_tail(hfc->regd.dsq, |
| 1640 |
- (struct sk_buff *) arg); |
| 1641 |
- if (!hfc->fifos[HFCUSB_D_TX].active |
| 1642 |
- && !hfc->dfifo_fill) { |
| 1643 |
- fill_tx_urb(hfc->fifos + HFCUSB_D_TX); |
| 1644 |
- hfc->active_fifos |= |
| 1645 |
- hfc->fifos[HFCUSB_D_TX].fifo_mask; |
| 1646 |
- usb_submit_urb(&hfc->fifos[HFCUSB_D_TX]. |
| 1647 |
- urb); |
| 1648 |
- } |
| 1649 |
- break; |
| 1650 |
- case (PH_ACTIVATE | REQUEST): |
| 1651 |
- switch (hfc->l1_state) { |
| 1652 |
- case 6: |
| 1653 |
- case 8: |
| 1654 |
- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, |
| 1655 |
- (PH_DEACTIVATE | |
| 1656 |
- INDICATION), NULL); |
| 1657 |
+/* |
| 1658 |
+ -------------------------------------------------------------------------------------- |
| 1659 |
+ from here : hisax_if callback routines : |
| 1660 |
+ - void hfc_usb_d_l2l1(struct hisax_if *hisax_d_if, int pr, void *arg) { |
| 1661 |
|
| 1662 |
- break; |
| 1663 |
- case 7: |
| 1664 |
- hfc->regd.dch_l1l2(hfc->regd.arg_hisax, |
| 1665 |
- (PH_ACTIVATE | |
| 1666 |
- INDICATION), NULL); |
| 1667 |
+ l1 to l2 routines : |
| 1668 |
+ - static void hfc_usb_l1l2(hfcusb_data * hfc) |
| 1669 |
|
| 1670 |
- break; |
| 1671 |
- default: |
| 1672 |
- queue_control_request(hfc, HFCUSB_STATES, 0x60); /* start activation */ |
| 1673 |
- hfc->t3_timer.expires = |
| 1674 |
- jiffies + (HFC_TIMER_T3 * HZ) / 1000; |
| 1675 |
- if (!timer_pending(&hfc->t3_timer)) |
| 1676 |
- add_timer(&hfc->t3_timer); |
| 1677 |
- break; |
| 1678 |
- } |
| 1679 |
- break; |
| 1680 |
+*/ |
| 1681 |
|
| 1682 |
- case (PH_DEACTIVATE | REQUEST): |
| 1683 |
- queue_control_request(hfc, HFCUSB_STATES, 0x40); /* start deactivation */ |
| 1684 |
- break; |
| 1685 |
- default: |
| 1686 |
- printk(KERN_INFO "unknown hfcusb l1_access 0x%x\n", |
| 1687 |
- pr); |
| 1688 |
- break; |
| 1689 |
- } |
| 1690 |
-} /* hfcusb_l1_access */ |
| 1691 |
- |
| 1692 |
-/*******************************/ |
| 1693 |
-/* B channel access from HiSax */ |
| 1694 |
-/*******************************/ |
| 1695 |
-static void |
| 1696 |
-hfcusb_bch_access(void *drvarg, int chan, int pr, void *arg) |
| 1697 |
-{ |
| 1698 |
- hfcusb_data *hfc = (hfcusb_data *) drvarg; |
| 1699 |
- usb_fifo *fifo = hfc->fifos + (chan ? HFCUSB_B2_TX : HFCUSB_B1_TX); |
| 1700 |
- long flags; |
| 1701 |
- |
| 1702 |
- switch (pr) { |
| 1703 |
- case (PH_DATA | REQUEST): |
| 1704 |
- case (PH_PULL | INDICATION): |
| 1705 |
- save_flags(flags); |
| 1706 |
- cli(); |
| 1707 |
- if (!fifo->active) { |
| 1708 |
- fill_tx_urb(fifo); |
| 1709 |
- hfc->active_fifos |= fifo->fifo_mask; |
| 1710 |
- usb_submit_urb(&fifo->urb); |
| 1711 |
- } |
| 1712 |
- restore_flags(flags); |
| 1713 |
- break; |
| 1714 |
- case (PH_ACTIVATE | REQUEST): |
| 1715 |
- if (!((int) arg)) { |
| 1716 |
- hfc->bch_enables &= ~(1 << chan); |
| 1717 |
- if (fifo->active) { |
| 1718 |
- fifo->active = 0; |
| 1719 |
- usb_unlink_urb(&fifo->urb); |
| 1720 |
+void hfc_usb_l2l1(struct hisax_if *my_hisax_if, int pr, void *arg) |
| 1721 |
+{ |
| 1722 |
+ usb_fifo *fifo = my_hisax_if->priv; |
| 1723 |
+ hfcusb_data *hfc = fifo->hfc; |
| 1724 |
+ |
| 1725 |
+ switch (pr) { |
| 1726 |
+ case PH_ACTIVATE | REQUEST: |
| 1727 |
+ if(fifo->fifonum==HFCUSB_D_TX) |
| 1728 |
+ { |
| 1729 |
+#ifdef VERBOSE_ISDN_DEBUG |
| 1730 |
+ printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_ACTIVATE | REQUEST\n"); |
| 1731 |
+#endif |
| 1732 |
+ queue_control_request(hfc, HFCUSB_STATES,0x60,1); /* make activation */ |
| 1733 |
+ hfc->t3_timer.expires = jiffies + (HFC_TIMER_T3 * HZ) / 1000; |
| 1734 |
+ if(!timer_pending(&hfc->t3_timer)) add_timer(&hfc->t3_timer); |
| 1735 |
} |
| 1736 |
- save_flags(flags); |
| 1737 |
- cli(); |
| 1738 |
- queue_control_request(hfc, HFCUSB_FIFO, |
| 1739 |
- fifo->fifonum); |
| 1740 |
- queue_control_request(hfc, |
| 1741 |
- HFCUSB_INC_RES_F, 2); |
| 1742 |
- queue_control_request(hfc, HFCUSB_CON_HDLC, |
| 1743 |
- 9); |
| 1744 |
- queue_control_request(hfc, HFCUSB_SCTRL, |
| 1745 |
- 0x40 + |
| 1746 |
- hfc->bch_enables); |
| 1747 |
- queue_control_request(hfc, HFCUSB_SCTRL_R, |
| 1748 |
- hfc->bch_enables); |
| 1749 |
- restore_flags(flags); |
| 1750 |
- fifo++; |
| 1751 |
- if (fifo->active) { |
| 1752 |
- fifo->active = 0; |
| 1753 |
- usb_unlink_urb(&fifo->urb); |
| 1754 |
+ else |
| 1755 |
+ { |
| 1756 |
+#ifdef VERBOSE_ISDN_DEBUG |
| 1757 |
+ printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_ACTIVATE | REQUEST\n"); |
| 1758 |
+#endif |
| 1759 |
+ set_hfcmode(hfc,(fifo->fifonum==HFCUSB_B1_TX) ? 0 : 1 ,(int)arg); |
| 1760 |
+ fifo->hif->l1l2(fifo->hif,PH_ACTIVATE | INDICATION, NULL); |
| 1761 |
} |
| 1762 |
- return; /* fifo deactivated */ |
| 1763 |
- } |
| 1764 |
- fifo->transmode = ((int) arg == L1_MODE_TRANS); |
| 1765 |
- fifo->max_size = |
| 1766 |
- ((fifo->transmode) ? fifo-> |
| 1767 |
- usb_maxlen : MAX_BCH_SIZE); |
| 1768 |
- (fifo + 1)->transmode = fifo->transmode; |
| 1769 |
- (fifo + 1)->max_size = fifo->max_size; |
| 1770 |
- hfc->bch_enables |= (1 << chan); |
| 1771 |
- save_flags(flags); |
| 1772 |
- cli(); |
| 1773 |
- queue_control_request(hfc, HFCUSB_FIFO, |
| 1774 |
- fifo->fifonum); |
| 1775 |
- queue_control_request(hfc, HFCUSB_CON_HDLC, |
| 1776 |
- ((!fifo-> |
| 1777 |
- transmode) ? 9 : 11)); |
| 1778 |
- queue_control_request(hfc, HFCUSB_INC_RES_F, 2); |
| 1779 |
- queue_control_request(hfc, HFCUSB_SCTRL, |
| 1780 |
- 0x40 + hfc->bch_enables); |
| 1781 |
- if ((int) arg == L1_MODE_HDLC) |
| 1782 |
- queue_control_request(hfc, HFCUSB_CON_HDLC, |
| 1783 |
- 8); |
| 1784 |
- queue_control_request(hfc, HFCUSB_FIFO, |
| 1785 |
- fifo->fifonum + 1); |
| 1786 |
- queue_control_request(hfc, HFCUSB_CON_HDLC, |
| 1787 |
- ((!fifo-> |
| 1788 |
- transmode) ? 8 : 10)); |
| 1789 |
- queue_control_request(hfc, HFCUSB_INC_RES_F, 2); |
| 1790 |
- queue_control_request(hfc, HFCUSB_SCTRL_R, |
| 1791 |
- hfc->bch_enables); |
| 1792 |
- restore_flags(flags); |
| 1793 |
- |
| 1794 |
- break; |
| 1795 |
- |
| 1796 |
- default: |
| 1797 |
- printk(KERN_INFO |
| 1798 |
- "unknown hfcusb bch_access chan %d 0x%x\n", |
| 1799 |
- chan, pr); |
| 1800 |
- break; |
| 1801 |
- } |
| 1802 |
-} /* hfcusb_bch_access */ |
| 1803 |
+ break; |
| 1804 |
+ case PH_DEACTIVATE | REQUEST: |
| 1805 |
+ if(fifo->fifonum==HFCUSB_D_TX) |
| 1806 |
+ { |
| 1807 |
+#ifdef VERBOSE_ISDN_DEBUG |
| 1808 |
+ printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DEACTIVATE | REQUEST\n"); |
| 1809 |
+#endif |
| 1810 |
+ printk (KERN_INFO "HFC-USB: ISDN TE device should not deativate...\n"); |
| 1811 |
+ } |
| 1812 |
+ else |
| 1813 |
+ { |
| 1814 |
+#ifdef VERBOSE_ISDN_DEBUG |
| 1815 |
+ printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DEACTIVATE | REQUEST\n"); |
| 1816 |
+#endif |
| 1817 |
+ set_hfcmode(hfc,(fifo->fifonum==HFCUSB_B1_TX) ? 0 : 1 ,(int)L1_MODE_NULL); |
| 1818 |
+ fifo->hif->l1l2(fifo->hif,PH_DEACTIVATE | INDICATION, NULL); |
| 1819 |
+ } |
| 1820 |
+ break; |
| 1821 |
+ case PH_DATA | REQUEST: |
| 1822 |
+ if(fifo->skbuff && fifo->delete_flg) |
| 1823 |
+ { |
| 1824 |
+ dev_kfree_skb_any(fifo->skbuff); |
| 1825 |
+ //printk(KERN_INFO "skbuff=NULL on fifo:%d\n",fifo->fifonum); |
| 1826 |
+ fifo->skbuff = NULL; |
| 1827 |
+ fifo->delete_flg=FALSE; |
| 1828 |
+ } |
| 1829 |
+ |
| 1830 |
+ fifo->skbuff=arg; // we have a new buffer |
| 1831 |
+ |
| 1832 |
+ //if(fifo->fifonum==HFCUSB_D_TX) printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 D-chan: PH_DATA | REQUEST\n"); |
| 1833 |
+ //else printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1 Bx-chan: PH_DATA | REQUEST\n"); |
| 1834 |
+ break; |
| 1835 |
+ default: |
| 1836 |
+ printk (KERN_INFO "HFC_USB: hfc_usb_d_l2l1: unkown state : %#x\n", pr); |
| 1837 |
+ break; |
| 1838 |
+ } |
| 1839 |
+} |
| 1840 |
+ |
| 1841 |
+// valid configurations |
| 1842 |
+#define CNF_4INT3ISO 1 // 4 INT IN, 3 ISO OUT |
| 1843 |
+#define CNF_3INT3ISO 2 // 3 INT IN, 3 ISO OUT |
| 1844 |
+#define CNF_4ISO3ISO 3 // 4 ISO IN, 3 ISO OUT |
| 1845 |
+#define CNF_3ISO3ISO 4 // 3 ISO IN, 3 ISO OUT |
| 1846 |
+ |
| 1847 |
+ |
| 1848 |
+/* |
| 1849 |
+ -------------------------------------------------------------------------------------- |
| 1850 |
+ From here on USB initialization and deactivation related routines are implemented : |
| 1851 |
+ |
| 1852 |
+ - hfc_usb_init : |
| 1853 |
+ is the main Entry Point for the USB Subsystem when the device get plugged |
| 1854 |
+ in. This function calls usb_register with usb_driver as parameter. |
| 1855 |
+ Here, further entry points for probing (hfc_usb_probe) and disconnecting |
| 1856 |
+ the device (hfc_usb_disconnect) are published, as the id_table |
| 1857 |
+ |
| 1858 |
+ - hfc_usb_probe |
| 1859 |
+ this function is called by the usb subsystem, and steps through the alternate |
| 1860 |
+ settings of the currently plugged in device to detect all Endpoints needed to |
| 1861 |
+ run an ISDN TA. |
| 1862 |
+ Needed EndPoints are |
| 1863 |
+ 3 (+1) IntIn EndPoints (D-in, E-in, B1-in, B2-in, (E-in)) or |
| 1864 |
+ 3 (+1) Isochron In Endpoints (D-out, B1-out, B2-out) and 3 IsoOut Endpoints |
| 1865 |
+ The currently used transfer mode of on the Out-Endpoints will be stored in |
| 1866 |
+ hfc->usb_transfer_mode and is either USB_INT or USB_ISO |
| 1867 |
+ When a valid alternate setting could be found, the usb_init (see blow) |
| 1868 |
+ function is called |
| 1869 |
+ |
| 1870 |
+ - usb_init |
| 1871 |
+ Here, the HFC_USB Chip itself gets initialized and the USB framework to send/receive |
| 1872 |
+ Data to/from the several EndPoints are initialized: |
| 1873 |
+ The E- and D-Channel Int-In chain gets started |
| 1874 |
+ The IsoChain for the Iso-Out traffic get started |
| 1875 |
+ |
| 1876 |
+ - hfc_usb_disconnect |
| 1877 |
+ this function is called by the usb subsystem and has to free all resources |
| 1878 |
+ and stop all usb traffic to allow a proper hotplugging disconnect. |
| 1879 |
+ |
| 1880 |
+*/ |
| 1881 |
|
| 1882 |
/***************************************************************************/ |
| 1883 |
/* usb_init is called once when a new matching device is detected to setup */ |
| 1884 |
-/* main parmeters. It registers the driver at the main hisax module. */ |
| 1885 |
+/* main parameters. It registers the driver at the main hisax module. */ |
| 1886 |
/* on success 0 is returned. */ |
| 1887 |
/***************************************************************************/ |
| 1888 |
-static int |
| 1889 |
-usb_init(hfcusb_data * hfc) |
| 1890 |
+static int usb_init(hfcusb_data * hfc) |
| 1891 |
{ |
| 1892 |
usb_fifo *fifo; |
| 1893 |
- int i; |
| 1894 |
+ int i, err; |
| 1895 |
u_char b; |
| 1896 |
- |
| 1897 |
+ struct hisax_b_if *p_b_if[2]; |
| 1898 |
+ |
| 1899 |
/* check the chip id */ |
| 1900 |
- if ((Read_hfc(hfc, HFCUSB_CHIP_ID, &b) != 1) || |
| 1901 |
- (b != HFCUSB_CHIPID)) { |
| 1902 |
+ printk(KERN_INFO "HFCUSB_CHIP_ID begin\n"); |
| 1903 |
+ if (read_usb(hfc, HFCUSB_CHIP_ID, &b) != 1) { |
| 1904 |
+ printk(KERN_INFO "HFC-USB: cannot read chip id\n"); |
| 1905 |
+ return(1); |
| 1906 |
+ } |
| 1907 |
+ printk(KERN_INFO "HFCUSB_CHIP_ID %x\n", b); |
| 1908 |
+ if (b != HFCUSB_CHIPID) { |
| 1909 |
printk(KERN_INFO "HFC-USB: Invalid chip id 0x%02x\n", b); |
| 1910 |
- return (1); |
| 1911 |
+ return(1); |
| 1912 |
} |
| 1913 |
|
| 1914 |
/* first set the needed config, interface and alternate */ |
| 1915 |
- usb_set_configuration(hfc->dev, 1); |
| 1916 |
- usb_set_interface(hfc->dev, hfc->if_used, hfc->alt_used); |
| 1917 |
+ printk(KERN_INFO "usb_init 1\n"); |
| 1918 |
+// usb_set_configuration(hfc->dev, 1); |
| 1919 |
+ printk(KERN_INFO "usb_init 2\n"); |
| 1920 |
+ err = usb_set_interface(hfc->dev, hfc->if_used, hfc->alt_used); |
| 1921 |
+ printk(KERN_INFO "usb_init usb_set_interface return %d\n", err); |
| 1922 |
+ /* now we initialize the chip */ |
| 1923 |
+ write_usb(hfc, HFCUSB_CIRM, 8); // do reset |
| 1924 |
+ write_usb(hfc, HFCUSB_CIRM, 0x10); // aux = output, reset off |
| 1925 |
|
| 1926 |
- /* init the led state request */ |
| 1927 |
- hfc->led_req = LED_DRIVER; |
| 1928 |
+ // set USB_SIZE to match the the wMaxPacketSize for INT or BULK transfers |
| 1929 |
+ write_usb(hfc, HFCUSB_USB_SIZE,(hfc->packet_size/8) | ((hfc->packet_size/8) << 4)); |
| 1930 |
|
| 1931 |
- /* now we initialise the chip */ |
| 1932 |
- Write_hfc(hfc, HFCUSB_CIRM, 0x10); /* aux = output, reset off */ |
| 1933 |
- Write_hfc(hfc, HFCUSB_P_DATA, 0); /* leds = off */ |
| 1934 |
- Write_hfc(hfc, HFCUSB_USB_SIZE, |
| 1935 |
- (hfc->fifos[HFCUSB_B1_TX].usb_maxlen >> 3) | |
| 1936 |
- ((hfc->fifos[HFCUSB_B1_RX].usb_maxlen >> 3) << 4)); |
| 1937 |
+ // set USB_SIZE_I to match the the wMaxPacketSize for ISO transfers |
| 1938 |
+ write_usb(hfc, HFCUSB_USB_SIZE_I, hfc->iso_packet_size); |
| 1939 |
|
| 1940 |
/* enable PCM/GCI master mode */ |
| 1941 |
- Write_hfc(hfc, HFCUSB_MST_MODE1, 0); /* set default values */ |
| 1942 |
- Write_hfc(hfc, HFCUSB_MST_MODE0, 1); /* enable master mode */ |
| 1943 |
+ write_usb(hfc, HFCUSB_MST_MODE1, 0); /* set default values */ |
| 1944 |
+ write_usb(hfc, HFCUSB_MST_MODE0, 1); /* enable master mode */ |
| 1945 |
|
| 1946 |
/* init the fifos */ |
| 1947 |
- Write_hfc(hfc, HFCUSB_F_THRES, (HFCUSB_TX_THRESHOLD >> 3) | |
| 1948 |
- ((HFCUSB_RX_THRESHOLD >> 3) << 4)); |
| 1949 |
+ write_usb(hfc, HFCUSB_F_THRES, (HFCUSB_TX_THRESHOLD/8) |((HFCUSB_RX_THRESHOLD/8) << 4)); |
| 1950 |
|
| 1951 |
- for (i = 0, fifo = hfc->fifos + i; i < HFCUSB_NUM_FIFOS; |
| 1952 |
- i++, fifo++) { |
| 1953 |
- Write_hfc(hfc, HFCUSB_FIFO, i); /* select the desired fifo */ |
| 1954 |
- |
| 1955 |
- fifo->transmode = 0; /* hdlc mode selected */ |
| 1956 |
- fifo->buff = NULL; /* init buffer pointer */ |
| 1957 |
- fifo->max_size = |
| 1958 |
- (i <= HFCUSB_B2_RX) ? MAX_BCH_SIZE : MAX_DFRAME_LEN; |
| 1959 |
- Write_hfc(hfc, HFCUSB_HDLC_PAR, ((i <= HFCUSB_B2_RX) ? 0 : 2)); /* data length */ |
| 1960 |
- Write_hfc(hfc, HFCUSB_CON_HDLC, ((i & 1) ? 0x08 : 0x09)); /* rx hdlc, tx fill 1 */ |
| 1961 |
- Write_hfc(hfc, HFCUSB_INC_RES_F, 2); /* reset the fifo */ |
| 1962 |
- } |
| 1963 |
- |
| 1964 |
- Write_hfc(hfc, HFCUSB_CLKDEL, 0x0f); /* clock delay value */ |
| 1965 |
- Write_hfc(hfc, HFCUSB_STATES, 3 | 0x10); /* set deactivated mode */ |
| 1966 |
- Write_hfc(hfc, HFCUSB_STATES, 3); /* enable state machine */ |
| 1967 |
+ fifo = hfc->fifos; |
| 1968 |
+ for(i = 0; i < HFCUSB_NUM_FIFOS; i++) |
| 1969 |
+ { |
| 1970 |
+ write_usb(hfc, HFCUSB_FIFO, i); /* select the desired fifo */ |
| 1971 |
+ fifo[i].skbuff = NULL; /* init buffer pointer */ |
| 1972 |
+ fifo[i].max_size = (i <= HFCUSB_B2_RX) ? MAX_BCH_SIZE : MAX_DFRAME_LEN; |
| 1973 |
+ fifo[i].last_urblen=0; |
| 1974 |
+ write_usb(hfc, HFCUSB_HDLC_PAR, ((i <= HFCUSB_B2_RX) ? 0 : 2)); // set 2 bit for D- & E-channel |
| 1975 |
+ write_usb(hfc, HFCUSB_CON_HDLC, ((i==HFCUSB_D_TX) ? 0x09 : 0x08)); // rx hdlc, enable IFF for D-channel |
| 1976 |
+ write_usb(hfc, HFCUSB_INC_RES_F, 2); /* reset the fifo */ |
| 1977 |
+ } |
| 1978 |
|
| 1979 |
- Write_hfc(hfc, HFCUSB_SCTRL_R, 0); /* disable both B receivers */ |
| 1980 |
- Write_hfc(hfc, HFCUSB_SCTRL, 0x40); /* disable B transmitters + cap mode */ |
| 1981 |
+ write_usb(hfc, HFCUSB_CLKDEL, 0x0f); /* clock delay value */ |
| 1982 |
+ write_usb(hfc, HFCUSB_STATES, 3 | 0x10); /* set deactivated mode */ |
| 1983 |
+ write_usb(hfc, HFCUSB_STATES, 3); /* enable state machine */ |
| 1984 |
+ |
| 1985 |
+ write_usb(hfc, HFCUSB_SCTRL_R, 0); /* disable both B receivers */ |
| 1986 |
+ write_usb(hfc, HFCUSB_SCTRL, 0x40); /* disable B transmitters + capacitive mode */ |
| 1987 |
+ |
| 1988 |
+ // set both B-channel to not connected |
| 1989 |
+ hfc->b_mode[0]=L1_MODE_NULL; |
| 1990 |
+ hfc->b_mode[1]=L1_MODE_NULL; |
| 1991 |
+ |
| 1992 |
+ hfc->l1_activated=FALSE; |
| 1993 |
+ hfc->led_state=0; |
| 1994 |
+ hfc->led_new_data=0; |
| 1995 |
|
| 1996 |
- /* init the l1 timer */ |
| 1997 |
+ /* init the t3 timer */ |
| 1998 |
init_timer(&hfc->t3_timer); |
| 1999 |
hfc->t3_timer.data = (long) hfc; |
| 2000 |
- hfc->t3_timer.function = (void *) l1_timer_expire; |
| 2001 |
+ hfc->t3_timer.function = (void *) l1_timer_expire_t3; |
| 2002 |
+ /* init the t4 timer */ |
| 2003 |
+ init_timer(&hfc->t4_timer); |
| 2004 |
hfc->t4_timer.data = (long) hfc; |
| 2005 |
- hfc->t4_timer.function = (void *) l1_timer_expire; |
| 2006 |
- hfc->l1_tq.routine = (void *) (void *) usb_l1d_bh; |
| 2007 |
- hfc->l1_tq.sync = 0; |
| 2008 |
- hfc->l1_tq.data = hfc; |
| 2009 |
- |
| 2010 |
- /* init the background control machinery */ |
| 2011 |
- hfc->ctrl_read.requesttype = 0xc0; |
| 2012 |
- hfc->ctrl_read.request = 1; |
| 2013 |
- hfc->ctrl_read.length = 1; |
| 2014 |
- hfc->ctrl_write.requesttype = 0x40; |
| 2015 |
- hfc->ctrl_write.request = 0; |
| 2016 |
- hfc->ctrl_write.length = 0; |
| 2017 |
- FILL_CONTROL_URB(&hfc->ctrl_urb, hfc->dev, hfc->ctrl_out_pipe, |
| 2018 |
- (u_char *) & hfc->ctrl_write, NULL, 0, |
| 2019 |
- ctrl_complete, hfc); |
| 2020 |
- |
| 2021 |
- /* init the TX-urbs */ |
| 2022 |
- fifo = hfc->fifos + HFCUSB_D_TX; |
| 2023 |
- FILL_BULK_URB(&fifo->urb, hfc->dev, fifo->pipe, |
| 2024 |
- (u_char *) fifo->buffer, 0, tx_complete, fifo); |
| 2025 |
- fifo = hfc->fifos + HFCUSB_B1_TX; |
| 2026 |
- FILL_BULK_URB(&fifo->urb, hfc->dev, fifo->pipe, |
| 2027 |
- (u_char *) fifo->buffer, 0, tx_complete, fifo); |
| 2028 |
- fifo = hfc->fifos + HFCUSB_B2_TX; |
| 2029 |
- FILL_BULK_URB(&fifo->urb, hfc->dev, fifo->pipe, |
| 2030 |
- (u_char *) fifo->buffer, 0, tx_complete, fifo); |
| 2031 |
- |
| 2032 |
- /* init the E-buffer */ |
| 2033 |
- skb_queue_head_init(&hfc->regd.erq); |
| 2034 |
- |
| 2035 |
- /* now register ourself at hisax */ |
| 2036 |
- hfc->regd.version = HISAX_LOAD_VERSION; /* set our version */ |
| 2037 |
- hfc->regd.cmd = HISAX_LOAD_REGISTER; /* register command */ |
| 2038 |
- hfc->regd.argl1 = (void *) hfc; /* argument for our local routine */ |
| 2039 |
- hfc->regd.dch_l2l1 = hfcusb_l1_access; |
| 2040 |
- hfc->regd.bch_l2l1 = hfcusb_bch_access; |
| 2041 |
- hfc->regd.drvname = "hfc_usb"; |
| 2042 |
- if (hisax_register_hfcusb(&hfc->regd)) { |
| 2043 |
- printk(KERN_INFO "HFC-USB failed to register at hisax\n"); |
| 2044 |
- Write_hfc(hfc, HFCUSB_CIRM, 0x08); /* aux = input, reset on */ |
| 2045 |
- return (1); |
| 2046 |
- } |
| 2047 |
- |
| 2048 |
- /* startup the D- and E-channel fifos */ |
| 2049 |
- start_rx_fifo(hfc->fifos + HFCUSB_D_RX); /* D-fifo */ |
| 2050 |
- if (hfc->fifos[HFCUSB_PCM_RX].pipe) |
| 2051 |
- start_rx_fifo(hfc->fifos + HFCUSB_PCM_RX); /* E-fifo */ |
| 2052 |
+ hfc->t4_timer.function = (void *) l1_timer_expire_t4; |
| 2053 |
+ /* init the led timer */ |
| 2054 |
+ init_timer(&hfc->led_timer); |
| 2055 |
+ hfc->led_timer.data = (long) hfc; |
| 2056 |
+ hfc->led_timer.function = (void *) led_timer; |
| 2057 |
+ // trigger 4 hz led timer |
| 2058 |
+ hfc->led_timer.expires = jiffies + (LED_TIME * HZ) / 1000; |
| 2059 |
+ if(!timer_pending(&hfc->led_timer)) add_timer(&hfc->led_timer); |
| 2060 |
+ |
| 2061 |
+ // init the background machinery for control requests |
| 2062 |
+ hfc->ctrl_read.bRequestType = 0xc0; |
| 2063 |
+ hfc->ctrl_read.bRequest = 1; |
| 2064 |
+ hfc->ctrl_read.wLength = 1; |
| 2065 |
+ hfc->ctrl_write.bRequestType = 0x40; |
| 2066 |
+ hfc->ctrl_write.bRequest = 0; |
| 2067 |
+ hfc->ctrl_write.wLength = 0; |
| 2068 |
+ usb_fill_control_urb(hfc->ctrl_urb, hfc->dev, hfc->ctrl_out_pipe,(u_char *) & hfc->ctrl_write, NULL, 0, ctrl_complete, hfc); |
| 2069 |
+ |
| 2070 |
+ /* Init All Fifos */ |
| 2071 |
+ for(i = 0; i < HFCUSB_NUM_FIFOS; i++) |
| 2072 |
+ { |
| 2073 |
+ hfc->fifos[i].iso[0].purb = NULL; |
| 2074 |
+ hfc->fifos[i].iso[1].purb = NULL; |
| 2075 |
+ hfc->fifos[i].active = 0; |
| 2076 |
+ } |
| 2077 |
+ |
| 2078 |
+ // register like Germaschewski : |
| 2079 |
+ hfc->d_if.owner = THIS_MODULE; |
| 2080 |
+ hfc->d_if.ifc.priv = &hfc->fifos[HFCUSB_D_TX]; |
| 2081 |
+ hfc->d_if.ifc.l2l1 = hfc_usb_l2l1; |
| 2082 |
+ |
| 2083 |
+ for (i=0; i<2; i++) |
| 2084 |
+ { |
| 2085 |
+ hfc->b_if[i].ifc.priv = &hfc->fifos[HFCUSB_B1_TX+i*2]; |
| 2086 |
+ hfc->b_if[i].ifc.l2l1 = hfc_usb_l2l1; |
| 2087 |
+ p_b_if[i] = &hfc->b_if[i]; |
| 2088 |
+ } |
| 2089 |
+ |
| 2090 |
+ hfc->protocol = 2; /* default EURO ISDN, should be a module_param */ |
| 2091 |
+ hisax_register(&hfc->d_if, p_b_if, "hfc_usb", hfc->protocol); |
| 2092 |
+ |
| 2093 |
+ for (i=0; i<4; i++) |
| 2094 |
+ hfc->fifos[i].hif=&p_b_if[i/2]->ifc; |
| 2095 |
+ for (i=4; i<8; i++) |
| 2096 |
+ hfc->fifos[i].hif=&hfc->d_if.ifc; |
| 2097 |
+ |
| 2098 |
+ // 3 (+1) INT IN + 3 ISO OUT |
| 2099 |
+ if(hfc->cfg_used == CNF_3INT3ISO || hfc->cfg_used == CNF_4INT3ISO) |
| 2100 |
+ { |
| 2101 |
+ start_int_fifo(hfc->fifos + HFCUSB_D_RX); // Int IN D-fifo |
| 2102 |
+ if(hfc->fifos[HFCUSB_PCM_RX].pipe) start_int_fifo(hfc->fifos + HFCUSB_PCM_RX); // E-fifo |
| 2103 |
+ start_int_fifo(hfc->fifos + HFCUSB_B1_RX); // Int IN B1-fifo |
| 2104 |
+ start_int_fifo(hfc->fifos + HFCUSB_B2_RX); // Int IN B2-fifo |
| 2105 |
+ } |
| 2106 |
+ |
| 2107 |
+ // 3 (+1) ISO IN + 3 ISO OUT |
| 2108 |
+ if(hfc->cfg_used==CNF_3ISO3ISO || hfc->cfg_used==CNF_4ISO3ISO) |
| 2109 |
+ { |
| 2110 |
+ start_isoc_chain(hfc->fifos + HFCUSB_D_RX, ISOC_PACKETS_D, rx_iso_complete,16); |
| 2111 |
+ if(hfc->fifos[HFCUSB_PCM_RX].pipe) start_isoc_chain(hfc->fifos + HFCUSB_PCM_RX, ISOC_PACKETS_D, rx_iso_complete,16); |
| 2112 |
+ start_isoc_chain(hfc->fifos + HFCUSB_B1_RX, ISOC_PACKETS_B, rx_iso_complete,16); |
| 2113 |
+ start_isoc_chain(hfc->fifos + HFCUSB_B2_RX, ISOC_PACKETS_B, rx_iso_complete,16); |
| 2114 |
+ } |
| 2115 |
+ |
| 2116 |
+ start_isoc_chain(hfc->fifos + HFCUSB_D_TX, ISOC_PACKETS_D, tx_iso_complete,1); |
| 2117 |
+ start_isoc_chain(hfc->fifos + HFCUSB_B1_TX, ISOC_PACKETS_B, tx_iso_complete,1); |
| 2118 |
+ start_isoc_chain(hfc->fifos + HFCUSB_B2_TX, ISOC_PACKETS_B, tx_iso_complete,1); |
| 2119 |
+ |
| 2120 |
+ handle_led(hfc,LED_POWER_ON); |
| 2121 |
+ |
| 2122 |
+ return(0); |
| 2123 |
+} /* usb_init */ |
| 2124 |
+ |
| 2125 |
+ |
| 2126 |
+/****************************************/ |
| 2127 |
+/* data defining the devices to be used */ |
| 2128 |
+/****************************************/ |
| 2129 |
+// static __devinitdata const struct usb_device_id hfc_usb_idtab[3] = { |
| 2130 |
+static struct usb_device_id hfc_usb_idtab[] = { |
| 2131 |
+ {USB_DEVICE(0x7b0, 0x0007)}, /* Billion USB TA 2 */ |
| 2132 |
+ {USB_DEVICE(0x742, 0x2008)}, /* Stollmann USB TA */ |
| 2133 |
+ {USB_DEVICE(0x959, 0x2bd0)}, /* Colognechip USB eval TA */ |
| 2134 |
+ {USB_DEVICE(0x8e3, 0x0301)}, /* OliTec ISDN USB */ |
| 2135 |
+ {USB_DEVICE(0x675, 0x1688)}, /* DrayTec ISDN USB */ |
| 2136 |
+ {USB_DEVICE(0x7fa, 0x0846)}, /* Bewan ISDN USB TA */ |
| 2137 |
+ {} /* end with an all-zeroes entry */ |
| 2138 |
+}; |
| 2139 |
+ |
| 2140 |
+MODULE_AUTHOR("Peter Sprenger (sprenger@moving-byters.de)/Martin Bachem (info@colognechip.com)"); |
| 2141 |
+MODULE_DESCRIPTION("HFC I4L USB driver"); |
| 2142 |
+MODULE_DEVICE_TABLE(usb, hfc_usb_idtab); |
| 2143 |
+MODULE_LICENSE("GPL"); |
| 2144 |
+ |
| 2145 |
+#define EP_NUL 1 // Endpoint at this position not allowed |
| 2146 |
+#define EP_NOP 2 // all type of endpoints allowed at this position |
| 2147 |
+#define EP_ISO 3 // Isochron endpoint mandatory at this position |
| 2148 |
+#define EP_BLK 4 // Bulk endpoint mandatory at this position |
| 2149 |
+#define EP_INT 5 // Interrupt endpoint mandatory at this position |
| 2150 |
+ |
| 2151 |
+// this array represents all endpoints possible in the HCF-USB |
| 2152 |
+// the last 2 entries are the configuration number and the minimum interval for Interrupt endpoints |
| 2153 |
+int validconf[][18]= |
| 2154 |
+{ |
| 2155 |
+ // INT in, ISO out config |
| 2156 |
+ {EP_NUL,EP_INT,EP_NUL,EP_INT,EP_NUL,EP_INT,EP_NOP,EP_INT,EP_ISO,EP_NUL,EP_ISO,EP_NUL,EP_ISO,EP_NUL,EP_NUL,EP_NUL,CNF_4INT3ISO,2}, |
| 2157 |
+ {EP_NUL,EP_INT,EP_NUL,EP_INT,EP_NUL,EP_INT,EP_NUL,EP_NUL,EP_ISO,EP_NUL,EP_ISO,EP_NUL,EP_ISO,EP_NUL,EP_NUL,EP_NUL,CNF_3INT3ISO,2}, |
| 2158 |
+ // ISO in, ISO out config |
| 2159 |
+ {EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_NOP,EP_ISO,CNF_4ISO3ISO,2}, |
| 2160 |
+ {EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_NUL,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_ISO,EP_NUL,EP_NUL,CNF_3ISO3ISO,2}, |
| 2161 |
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} // EOL element |
| 2162 |
+}; |
| 2163 |
+ |
| 2164 |
+// string description of chosen config |
| 2165 |
+char *conf_str[]= |
| 2166 |
+{ |
| 2167 |
+ "4 Interrupt IN + 3 Isochron OUT", |
| 2168 |
+ "3 Interrupt IN + 3 Isochron OUT", |
| 2169 |
+ "4 Isochron IN + 3 Isochron OUT", |
| 2170 |
+ "3 Isochron IN + 3 Isochron OUT" |
| 2171 |
+}; |
| 2172 |
|
| 2173 |
- return (0); |
| 2174 |
-} /* usb_init */ |
| 2175 |
|
| 2176 |
/*************************************************/ |
| 2177 |
/* function called to probe a new plugged device */ |
| 2178 |
/*************************************************/ |
| 2179 |
-static void * |
| 2180 |
-hfc_usb_probe(struct usb_device *dev, unsigned int interface |
| 2181 |
-#ifdef COMPAT_HAS_USB_IDTAB |
| 2182 |
- , const struct usb_device_id *id_table) |
| 2183 |
-#else |
| 2184 |
- ) |
| 2185 |
-#endif |
| 2186 |
+//static int hfc_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| 2187 |
+static void* hfc_usb_probe(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id) |
| 2188 |
{ |
| 2189 |
+ //struct usb_device *dev= interface_to_usbdev(intf); |
| 2190 |
+ struct usb_interface* intf = dev->actconfig->interface + ifnum; |
| 2191 |
hfcusb_data *context; |
| 2192 |
- struct usb_interface *ifp = dev->actconfig->interface + interface; |
| 2193 |
- struct usb_interface_descriptor *ifdp = |
| 2194 |
- ifp->altsetting + ifp->act_altsetting; |
| 2195 |
- struct usb_endpoint_descriptor *epd; |
| 2196 |
- int i, idx, ep_msk; |
| 2197 |
- |
| 2198 |
-#ifdef COMPAT_HAS_USB_IDTAB |
| 2199 |
- if (id_table && (dev->descriptor.idVendor == id_table->idVendor) && |
| 2200 |
- (dev->descriptor.idProduct == id_table->idProduct) && |
| 2201 |
-#else |
| 2202 |
- if ((((dev->descriptor.idVendor == 0x959) && |
| 2203 |
- (dev->descriptor.idProduct == 0x2bd0)) || |
| 2204 |
- ((dev->descriptor.idVendor == 0x7b0) && |
| 2205 |
- (dev->descriptor.idProduct == 0x0006))) && |
| 2206 |
-#endif |
| 2207 |
- (ifdp->bNumEndpoints >= 6) && (ifdp->bNumEndpoints <= 16)) { |
| 2208 |
- if (!(context = kmalloc(sizeof(hfcusb_data), GFP_KERNEL))) { |
| 2209 |
- return (NULL); /* got no mem */ |
| 2210 |
- }; |
| 2211 |
- memset(context, 0, sizeof(hfcusb_data)); /* clear the structure */ |
| 2212 |
- i = ifdp->bNumEndpoints; /* get number of endpoints */ |
| 2213 |
- ep_msk = 0; /* none found */ |
| 2214 |
- epd = ifdp->endpoint; /* first endpoint descriptor */ |
| 2215 |
- while (i-- && ((ep_msk & 0xcf) != 0xcf)) { |
| 2216 |
- |
| 2217 |
- idx = (((epd->bEndpointAddress & 0x7f) - 1) << 1); /* get endpoint base */ |
| 2218 |
- if (idx < 7) { |
| 2219 |
- switch (epd->bmAttributes) { |
| 2220 |
- case USB_ENDPOINT_XFER_INT: |
| 2221 |
- if (! |
| 2222 |
- (epd-> |
| 2223 |
- bEndpointAddress & |
| 2224 |
- 0x80)) |
| 2225 |
- break; /* only interrupt in allowed */ |
| 2226 |
- idx++; /* input index is odd */ |
| 2227 |
- context->fifos[idx].pipe = |
| 2228 |
- usb_rcvintpipe(dev, |
| 2229 |
- epd-> |
| 2230 |
- bEndpointAddress); |
| 2231 |
- break; |
| 2232 |
- |
| 2233 |
- case USB_ENDPOINT_XFER_BULK: |
| 2234 |
- if (epd-> |
| 2235 |
- bEndpointAddress & |
| 2236 |
- 0x80) |
| 2237 |
- break; /* only bulk out allowed */ |
| 2238 |
- context->fifos[idx].pipe = |
| 2239 |
- usb_sndbulkpipe(dev, |
| 2240 |
- epd-> |
| 2241 |
- bEndpointAddress); |
| 2242 |
- break; |
| 2243 |
- default: |
| 2244 |
- context->fifos[idx].pipe = 0; /* reset data */ |
| 2245 |
- } /* switch attribute */ |
| 2246 |
- |
| 2247 |
- if (context->fifos[idx].pipe) { |
| 2248 |
- context->fifos[idx].fifonum = idx; |
| 2249 |
- context->fifos[idx].fifo_mask = |
| 2250 |
- 1 << idx; |
| 2251 |
- context->fifos[idx].hfc = context; |
| 2252 |
- context->fifos[idx].usb_maxlen = |
| 2253 |
- epd->wMaxPacketSize; |
| 2254 |
- context->fifos[idx].intervall = |
| 2255 |
- epd->bInterval; |
| 2256 |
- ep_msk |= (1 << idx); |
| 2257 |
- } else |
| 2258 |
- ep_msk &= ~(1 << idx); |
| 2259 |
- } /* idx < 7 */ |
| 2260 |
- epd++; |
| 2261 |
- } |
| 2262 |
+ //struct usb_host_interface *iface = intf->cur_altsetting; |
| 2263 |
+ //struct usb_host_interface *iface_used = NULL; |
| 2264 |
+ //struct usb_host_endpoint *ep; |
| 2265 |
+ struct usb_endpoint_descriptor* ep; |
| 2266 |
+ //int ifnum = iface->desc.bInterfaceNumber; |
| 2267 |
+ struct usb_interface_descriptor* intfdesc = intf->altsetting + intf->act_altsetting; |
| 2268 |
+ struct usb_interface_descriptor* intfdesc_used = NULL; |
| 2269 |
+ int i, idx, alt_idx, probe_alt_setting, vend_idx, cfg_used, *vcf, attr, cfg_found, cidx, ep_addr; |
| 2270 |
+ int cmptbl[16],small_match,iso_packet_size,packet_size,alt_used=0; |
| 2271 |
+ |
| 2272 |
+// usb_show_device(dev); |
| 2273 |
+// usb_show_device_descriptor(&dev->descriptor); |
| 2274 |
+// usb_show_interface_descriptor(&iface->desc); |
| 2275 |
+ vend_idx=0xffff; |
| 2276 |
+ for(i=0;vdata[i].vendor;i++) |
| 2277 |
+ { |
| 2278 |
+ if(dev->descriptor.idVendor==vdata[i].vendor && dev->descriptor.idProduct==vdata[i].prod_id) vend_idx=i; |
| 2279 |
+ } |
| 2280 |
+ |
| 2281 |
|
| 2282 |
- if ((ep_msk & 0x3f) != 0x3f) { |
| 2283 |
- kfree(context); |
| 2284 |
- return (NULL); |
| 2285 |
- } |
| 2286 |
- MOD_INC_USE_COUNT; /* lock our module */ |
| 2287 |
- context->dev = dev; /* save device */ |
| 2288 |
- context->if_used = interface; /* save used interface */ |
| 2289 |
- context->alt_used = ifp->act_altsetting; /* and alternate config */ |
| 2290 |
- context->ctrl_paksize = dev->descriptor.bMaxPacketSize0; /* control size */ |
| 2291 |
- |
| 2292 |
- /* create the control pipes needed for register access */ |
| 2293 |
- context->ctrl_in_pipe = usb_rcvctrlpipe(context->dev, 0); |
| 2294 |
- context->ctrl_out_pipe = usb_sndctrlpipe(context->dev, 0); |
| 2295 |
- |
| 2296 |
- /* init the chip and register the driver */ |
| 2297 |
- if (usb_init(context)) { |
| 2298 |
- kfree(context); |
| 2299 |
- MOD_DEC_USE_COUNT; |
| 2300 |
- return (NULL); |
| 2301 |
- } |
| 2302 |
+#ifdef VERBOSE_USB_DEBUG |
| 2303 |
+ printk(KERN_INFO "HFC-USB: probing interface(%d) actalt(%d)\n", |
| 2304 |
+ ifnum, intfdesc->bAlternateSetting); |
| 2305 |
+ /* printk(KERN_INFO "HFC-USB: probing interface(%d) actalt(%d) minor(%d)\n", |
| 2306 |
+ ifnum, intfdesc->bAlternateSetting, intf->driver->minor); */ |
| 2307 |
+#endif |
| 2308 |
|
| 2309 |
- printk(KERN_INFO |
| 2310 |
- "HFC-USB: New device if=%d alt=%d registered\n", |
| 2311 |
- context->if_used, context->alt_used); |
| 2312 |
- return (context); |
| 2313 |
- } |
| 2314 |
+ if (vend_idx != 0xffff) { |
| 2315 |
+#ifdef VERBOSE_USB_DEBUG |
| 2316 |
+ printk(KERN_INFO "HFC-USB: found vendor idx:%d name:%s\n",vend_idx,vdata[vend_idx].vend_name); |
| 2317 |
+#endif |
| 2318 |
+ /* if vendor and product ID is OK, start probing a matching alternate setting ... */ |
| 2319 |
+ alt_idx = 0; |
| 2320 |
+ small_match=0xffff; |
| 2321 |
+ // default settings |
| 2322 |
+ iso_packet_size=16; |
| 2323 |
+ packet_size=64; |
| 2324 |
+ |
| 2325 |
+ while (alt_idx < intf->num_altsetting) { |
| 2326 |
+ //iface = intf->altsetting + alt_idx; |
| 2327 |
+ intfdesc = intf->altsetting + alt_idx; |
| 2328 |
+ probe_alt_setting = intfdesc->bAlternateSetting; |
| 2329 |
+ cfg_used=0; |
| 2330 |
|
| 2331 |
- return (NULL); /* no matching entry */ |
| 2332 |
-} /* hfc_usb_probe */ |
| 2333 |
+#ifdef VERBOSE_USB_DEBUG |
| 2334 |
+ printk(KERN_INFO "HFC-USB: test alt_setting %d\n", probe_alt_setting); |
| 2335 |
+#endif |
| 2336 |
+ // check for config EOL element |
| 2337 |
+ while (validconf[cfg_used][0]) { |
| 2338 |
+ cfg_found=TRUE; |
| 2339 |
+ vcf=validconf[cfg_used]; |
| 2340 |
+ ep = intfdesc->endpoint; /* first endpoint descriptor */ |
| 2341 |
+ |
| 2342 |
+#ifdef VERBOSE_USB_DEBUG |
| 2343 |
+ printk(KERN_INFO "HFC-USB: (if=%d alt=%d cfg_used=%d)\n", |
| 2344 |
+ ifnum, probe_alt_setting, cfg_used); |
| 2345 |
+#endif |
| 2346 |
+ // copy table |
| 2347 |
+ memcpy(cmptbl,vcf,16*sizeof(int)); |
| 2348 |
+ |
| 2349 |
+ // check for all endpoints in this alternate setting |
| 2350 |
+ for (i=0; i < intfdesc->bNumEndpoints; i++) { |
| 2351 |
+ ep_addr = ep->bEndpointAddress; |
| 2352 |
+ idx = ((ep_addr & 0x7f)-1)*2; /* get endpoint base */ |
| 2353 |
+ if (ep_addr & 0x80) |
| 2354 |
+ idx++; |
| 2355 |
+ attr = ep->bmAttributes; |
| 2356 |
+ |
| 2357 |
+ if (cmptbl[idx] == EP_NUL) { |
| 2358 |
+ printk(KERN_INFO "HFC-USB: cfg_found=FALSE in idx:%d attr:%d cmptbl[%d]:%d\n", |
| 2359 |
+ idx, attr, idx, cmptbl[idx]); |
| 2360 |
+ cfg_found = FALSE; |
| 2361 |
+ } |
| 2362 |
+ |
| 2363 |
+ if (attr == USB_ENDPOINT_XFER_INT && cmptbl[idx] == EP_INT) |
| 2364 |
+ cmptbl[idx] = EP_NUL; |
| 2365 |
+ if (attr == USB_ENDPOINT_XFER_BULK && cmptbl[idx] == EP_BLK) |
| 2366 |
+ cmptbl[idx] = EP_NUL; |
| 2367 |
+ if (attr == USB_ENDPOINT_XFER_ISOC && cmptbl[idx] == EP_ISO) |
| 2368 |
+ cmptbl[idx] = EP_NUL; |
| 2369 |
+ |
| 2370 |
+ // check if all INT endpoints match minimum interval |
| 2371 |
+ if (attr == USB_ENDPOINT_XFER_INT && ep->bInterval < vcf[17]) { |
| 2372 |
+#ifdef VERBOSE_USB_DEBUG |
| 2373 |
+ if (cfg_found) |
| 2374 |
+ printk(KERN_INFO "HFC-USB: Interrupt Endpoint interval < %d found - skipping config\n", |
| 2375 |
+ vcf[17]); |
| 2376 |
+#endif |
| 2377 |
+ cfg_found = FALSE; |
| 2378 |
+ } |
| 2379 |
+ |
| 2380 |
+ ep++; |
| 2381 |
+ } |
| 2382 |
+ |
| 2383 |
+ for (i = 0; i < 16; i++) { |
| 2384 |
+ // printk(KERN_INFO "HFC-USB: cmptbl[%d]:%d\n", i, cmptbl[i]); |
| 2385 |
+ |
| 2386 |
+ // all entries must be EP_NOP or EP_NUL for a valid config |
| 2387 |
+ if (cmptbl[i] != EP_NOP && cmptbl[i] != EP_NUL) |
| 2388 |
+ cfg_found = FALSE; |
| 2389 |
+ } |
| 2390 |
+ |
| 2391 |
+ // we check for smallest match, to provide configuration priority |
| 2392 |
+ // configurations with smaller index have higher priority |
| 2393 |
+ if (cfg_found) { |
| 2394 |
+ if (cfg_used < small_match) { |
| 2395 |
+ small_match = cfg_used; |
| 2396 |
+ alt_used = probe_alt_setting; |
| 2397 |
+ //iface_used = iface; |
| 2398 |
+ intfdesc_used = intfdesc; |
| 2399 |
+ } |
| 2400 |
+#ifdef VERBOSE_USB_DEBUG |
| 2401 |
+ printk(KERN_INFO "HFC-USB: small_match=%x %x\n", small_match, alt_used); |
| 2402 |
+#endif |
| 2403 |
+ } |
| 2404 |
+ |
| 2405 |
+ cfg_used++; |
| 2406 |
+ } |
| 2407 |
+ |
| 2408 |
+ alt_idx++; |
| 2409 |
+ } /* (alt_idx < intf->num_altsetting) */ |
| 2410 |
+#ifdef VERBOSE_USB_DEBUG |
| 2411 |
+ printk(KERN_INFO "HFC-USB: final small_match=%x alt_used=%x\n",small_match, alt_used); |
| 2412 |
+#endif |
| 2413 |
+ // yiipiee, we found a valid config |
| 2414 |
+ if (small_match != 0xffff) { |
| 2415 |
+ //iface = iface_used; |
| 2416 |
+ intfdesc = intfdesc_used; |
| 2417 |
+ |
| 2418 |
+ if (!(context = kmalloc(sizeof(hfcusb_data), GFP_KERNEL))) |
| 2419 |
+ return(NULL); /* got no mem */ |
| 2420 |
+ memset(context, 0, sizeof(hfcusb_data)); /* clear the structure */ |
| 2421 |
+ |
| 2422 |
+ ep = intfdesc->endpoint; /* first endpoint descriptor */ |
| 2423 |
+ vcf = validconf[small_match]; |
| 2424 |
+ |
| 2425 |
+ for (i = 0; i < intfdesc->bNumEndpoints; i++) { |
| 2426 |
+ ep_addr = ep->bEndpointAddress; |
| 2427 |
+ idx = ((ep_addr & 0x7f)-1)*2; /* get endpoint base */ |
| 2428 |
+ if (ep_addr & 0x80) |
| 2429 |
+ idx++; |
| 2430 |
+ cidx = idx & 7; |
| 2431 |
+ attr = ep->bmAttributes; |
| 2432 |
+ |
| 2433 |
+ // only initialize used endpoints |
| 2434 |
+ if (vcf[idx] != EP_NOP && vcf[idx] != EP_NUL) { |
| 2435 |
+ switch (attr) { |
| 2436 |
+ case USB_ENDPOINT_XFER_INT: |
| 2437 |
+ context->fifos[cidx].pipe = usb_rcvintpipe(dev, ep->bEndpointAddress); |
| 2438 |
+ context->fifos[cidx].usb_transfer_mode = USB_INT; |
| 2439 |
+ packet_size = ep->wMaxPacketSize; // remember max packet size |
| 2440 |
+#ifdef VERBOSE_USB_DEBUG |
| 2441 |
+ printk (KERN_INFO "HFC-USB: Interrupt-In Endpoint found %d ms(idx:%d cidx:%d)!\n", |
| 2442 |
+ ep->bInterval, idx, cidx); |
| 2443 |
+#endif |
| 2444 |
+ break; |
| 2445 |
+ case USB_ENDPOINT_XFER_BULK: |
| 2446 |
+ if (ep_addr & 0x80) |
| 2447 |
+ context->fifos[cidx].pipe = usb_rcvbulkpipe(dev, ep->bEndpointAddress); |
| 2448 |
+ else |
| 2449 |
+ context->fifos[cidx].pipe = usb_sndbulkpipe(dev, ep->bEndpointAddress); |
| 2450 |
+ context->fifos[cidx].usb_transfer_mode = USB_BULK; |
| 2451 |
+ packet_size = ep->wMaxPacketSize; // remember max packet size |
| 2452 |
+#ifdef VERBOSE_USB_DEBUG |
| 2453 |
+ printk (KERN_INFO "HFC-USB: Bulk Endpoint found (idx:%d cidx:%d)!\n", |
| 2454 |
+ idx, cidx); |
| 2455 |
+#endif |
| 2456 |
+ break; |
| 2457 |
+ case USB_ENDPOINT_XFER_ISOC: |
| 2458 |
+ if (ep_addr & 0x80) |
| 2459 |
+ context->fifos[cidx].pipe = usb_rcvisocpipe(dev, ep->bEndpointAddress); |
| 2460 |
+ else |
| 2461 |
+ context->fifos[cidx].pipe = usb_sndisocpipe(dev, ep->bEndpointAddress); |
| 2462 |
+ context->fifos[cidx].usb_transfer_mode = USB_ISOC; |
| 2463 |
+ iso_packet_size = ep->wMaxPacketSize; // remember max packet size |
| 2464 |
+#ifdef VERBOSE_USB_DEBUG |
| 2465 |
+ printk (KERN_INFO "HFC-USB: ISO Endpoint found (idx:%d cidx:%d)!\n", |
| 2466 |
+ idx, cidx); |
| 2467 |
+#endif |
| 2468 |
+ break; |
| 2469 |
+ default: |
| 2470 |
+ context->fifos[cidx].pipe = 0; /* reset data */ |
| 2471 |
+ } /* switch attribute */ |
| 2472 |
+ |
| 2473 |
+ if (context->fifos[cidx].pipe) { |
| 2474 |
+ context->fifos[cidx].fifonum = cidx; |
| 2475 |
+ context->fifos[cidx].hfc = context; |
| 2476 |
+ context->fifos[cidx].usb_packet_maxlen = ep->wMaxPacketSize; |
| 2477 |
+ context->fifos[cidx].intervall = ep->bInterval; |
| 2478 |
+ context->fifos[cidx].skbuff = NULL; |
| 2479 |
+#ifdef VERBOSE_USB_DEBUG |
| 2480 |
+ printk (KERN_INFO "HFC-USB: fifo%d pktlen %d interval %d\n", |
| 2481 |
+ context->fifos[cidx].fifonum, |
| 2482 |
+ context->fifos[cidx].usb_packet_maxlen, |
| 2483 |
+ context->fifos[cidx].intervall); |
| 2484 |
+#endif |
| 2485 |
+ } |
| 2486 |
+ } |
| 2487 |
+ |
| 2488 |
+ ep++; |
| 2489 |
+ } |
| 2490 |
+ |
| 2491 |
+ // now share our luck |
| 2492 |
+ context->dev = dev; /* save device */ |
| 2493 |
+ context->if_used = ifnum; /* save used interface */ |
| 2494 |
+ context->alt_used = alt_used; /* and alternate config */ |
| 2495 |
+ context->ctrl_paksize = dev->descriptor.bMaxPacketSize0; /* control size */ |
| 2496 |
+ context->cfg_used=vcf[16]; // store used config |
| 2497 |
+ context->vend_idx=vend_idx; // store found vendor |
| 2498 |
+ context->packet_size=packet_size; |
| 2499 |
+ context->iso_packet_size=iso_packet_size; |
| 2500 |
+ |
| 2501 |
+ /* create the control pipes needed for register access */ |
| 2502 |
+ context->ctrl_in_pipe = usb_rcvctrlpipe(context->dev, 0); |
| 2503 |
+ context->ctrl_out_pipe = usb_sndctrlpipe(context->dev, 0); |
| 2504 |
+ context->ctrl_urb = usb_alloc_urb(0); |
| 2505 |
+ |
| 2506 |
+ printk(KERN_INFO "HFC-USB: detected \"%s\" configuration: %s (if=%d alt=%d)\n", |
| 2507 |
+ vdata[vend_idx].vend_name, conf_str[small_match], context->if_used, context->alt_used); |
| 2508 |
+ |
| 2509 |
+ /* init the chip and register the driver */ |
| 2510 |
+ if (usb_init(context)) |
| 2511 |
+ { |
| 2512 |
+ if (context->ctrl_urb) { |
| 2513 |
+ usb_unlink_urb(context->ctrl_urb); |
| 2514 |
+ usb_free_urb(context->ctrl_urb); |
| 2515 |
+ context->ctrl_urb = NULL; |
| 2516 |
+ } |
| 2517 |
+ kfree(context); |
| 2518 |
+ return(NULL); |
| 2519 |
+ } |
| 2520 |
+ //usb_set_intfdata(intf, context); |
| 2521 |
+ //intf->private_data = context; |
| 2522 |
+ return(context); |
| 2523 |
+ } |
| 2524 |
+ } |
| 2525 |
+ return(NULL); |
| 2526 |
+} |
| 2527 |
|
| 2528 |
/****************************************************/ |
| 2529 |
/* function called when an active device is removed */ |
| 2530 |
/****************************************************/ |
| 2531 |
-static void |
| 2532 |
-hfc_usb_disconnect(struct usb_device *usbdev, void *drv_context) |
| 2533 |
+//static void hfc_usb_disconnect(struct usb_interface *intf) |
| 2534 |
+static void hfc_usb_disconnect(struct usb_device *usbdev, void* drv_context) |
| 2535 |
{ |
| 2536 |
- hfcusb_data *context = drv_context; |
| 2537 |
+ //hfcusb_data *context = intf->private_data; |
| 2538 |
+ hfcusb_data* context = drv_context; |
| 2539 |
int i; |
| 2540 |
- struct sk_buff *skb; |
| 2541 |
|
| 2542 |
- /* tell all fifos to terminate */ |
| 2543 |
- for (i = 0; i < HFCUSB_NUM_FIFOS; i++) |
| 2544 |
- if (context->fifos[i].active) { |
| 2545 |
- context->fifos[i].active = 0; |
| 2546 |
- usb_unlink_urb(&context->fifos[i].urb); |
| 2547 |
- } |
| 2548 |
- while (context->active_fifos) { |
| 2549 |
- set_current_state(TASK_INTERRUPTIBLE); |
| 2550 |
- /* Timeout 10ms */ |
| 2551 |
- schedule_timeout((10 * HZ) / 1000); |
| 2552 |
- } |
| 2553 |
+ printk(KERN_INFO "HFC-USB: device disconnect\n"); |
| 2554 |
+ |
| 2555 |
+ //intf->private_data = NULL; |
| 2556 |
+ if (!context) |
| 2557 |
+ return; |
| 2558 |
if (timer_pending(&context->t3_timer)) |
| 2559 |
del_timer(&context->t3_timer); |
| 2560 |
- context->regd.release_driver(context->regd.arg_hisax); |
| 2561 |
- while ((skb = skb_dequeue(&context->regd.erq)) != NULL) |
| 2562 |
- dev_kfree_skb_any(skb); |
| 2563 |
+ if (timer_pending(&context->t4_timer)) |
| 2564 |
+ del_timer(&context->t4_timer); |
| 2565 |
+ if (timer_pending(&context->led_timer)) |
| 2566 |
+ del_timer(&context->led_timer); |
| 2567 |
+ |
| 2568 |
+ hisax_unregister(&context->d_if); |
| 2569 |
|
| 2570 |
+ /* tell all fifos to terminate */ |
| 2571 |
+ for(i = 0; i < HFCUSB_NUM_FIFOS; i++) { |
| 2572 |
+ if(context->fifos[i].usb_transfer_mode == USB_ISOC) { |
| 2573 |
+ if(context->fifos[i].active > 0) { |
| 2574 |
+ stop_isoc_chain(&context->fifos[i]); |
| 2575 |
+#ifdef VERBOSE_USB_DEBUG |
| 2576 |
+ printk (KERN_INFO "HFC-USB: hfc_usb_disconnect: stopping ISOC chain Fifo no %i\n", i); |
| 2577 |
+#endif |
| 2578 |
+ } |
| 2579 |
+ } else { |
| 2580 |
+ if(context->fifos[i].active > 0) { |
| 2581 |
+ context->fifos[i].active = 0; |
| 2582 |
+#ifdef VERBOSE_USB_DEBUG |
| 2583 |
+ printk (KERN_INFO "HFC-USB: hfc_usb_disconnect: unlinking URB for Fifo no %i\n", i); |
| 2584 |
+#endif |
| 2585 |
+ } |
| 2586 |
+ if (context->fifos[i].urb) { |
| 2587 |
+ usb_unlink_urb(context->fifos[i].urb); |
| 2588 |
+ usb_free_urb(context->fifos[i].urb); |
| 2589 |
+ context->fifos[i].urb = NULL; |
| 2590 |
+ } |
| 2591 |
+ } |
| 2592 |
+ context->fifos[i].active = 0; |
| 2593 |
+ } |
| 2594 |
+ if (context->ctrl_urb) { |
| 2595 |
+ usb_unlink_urb(context->ctrl_urb); |
| 2596 |
+ usb_free_urb(context->ctrl_urb); |
| 2597 |
+ context->ctrl_urb = NULL; |
| 2598 |
+ } |
| 2599 |
kfree(context); /* free our structure again */ |
| 2600 |
- MOD_DEC_USE_COUNT; /* and decrement the usage counter */ |
| 2601 |
} /* hfc_usb_disconnect */ |
| 2602 |
|
| 2603 |
+ |
| 2604 |
/************************************/ |
| 2605 |
/* our driver information structure */ |
| 2606 |
/************************************/ |
| 2607 |
static struct usb_driver hfc_drv = { |
| 2608 |
name:"hfc_usb", |
| 2609 |
-#ifdef COMPAT_HAS_USB_IDTAB |
| 2610 |
id_table:hfc_usb_idtab, |
| 2611 |
-#endif |
| 2612 |
probe:hfc_usb_probe, |
| 2613 |
disconnect:hfc_usb_disconnect, |
| 2614 |
}; |
| 2615 |
|
| 2616 |
-static void __exit |
| 2617 |
-hfc_usb_exit(void) |
| 2618 |
-{ |
| 2619 |
|
| 2620 |
+static void __exit hfc_usb_exit(void) |
| 2621 |
+{ |
| 2622 |
+#ifdef VERBOSE_USB_DEBUG |
| 2623 |
+ printk ("HFC-USB: calling \"hfc_usb_exit\" ...\n"); |
| 2624 |
+#endif |
| 2625 |
usb_deregister(&hfc_drv); /* release our driver */ |
| 2626 |
printk(KERN_INFO "HFC-USB module removed\n"); |
| 2627 |
} |
| 2628 |
|
| 2629 |
-static int __init |
| 2630 |
-hfc_usb_init(void) |
| 2631 |
+static int __init hfc_usb_init(void) |
| 2632 |
{ |
| 2633 |
- struct hisax_drvreg drv; |
| 2634 |
+ printk ("HFC-USB: driver module revision %s loaded\n", hfcusb_revision); |
| 2635 |
|
| 2636 |
- drv.version = HISAX_LOAD_VERSION; /* set our version */ |
| 2637 |
- drv.cmd = HISAX_LOAD_CHKVER; /* check command only */ |
| 2638 |
- if (hisax_register_hfcusb(&drv)) { |
| 2639 |
- printk(KERN_INFO "HFC-USB <-> hisax version conflict\n"); |
| 2640 |
- return (-1); /* unable to register */ |
| 2641 |
- } |
| 2642 |
- if (usb_register(&hfc_drv)) { |
| 2643 |
- printk(KERN_INFO |
| 2644 |
- "Unable to register HFC-USB module at usb stack\n"); |
| 2645 |
- return (-1); /* unable to register */ |
| 2646 |
+ if(usb_register(&hfc_drv)) |
| 2647 |
+ { |
| 2648 |
+ printk(KERN_INFO "HFC-USB: Unable to register HFC-USB module at usb stack\n"); |
| 2649 |
+ return(-1); /* unable to register */ |
| 2650 |
} |
| 2651 |
- |
| 2652 |
- printk(KERN_INFO "HFC-USB module loaded\n"); |
| 2653 |
- return (0); |
| 2654 |
+ return(0); |
| 2655 |
} |
| 2656 |
|
| 2657 |
+ |
| 2658 |
+ |
| 2659 |
+ |
| 2660 |
+ |
| 2661 |
module_init(hfc_usb_init); |
| 2662 |
module_exit(hfc_usb_exit); |
| 2663 |
+ |