1 /* Driver for USB scsi - include file
3 * (C) Michael Gee (michael@linuxspecific.com) 1999
5 * This driver is scitzoid - it make a USB scanner appear as both a SCSI device
6 * and a character device. The latter is only available if the device has an
7 * interrupt endpoint, and is used specifically to receive interrupt events.
9 * In order to support various 'strange' scanners, this module supports plug in
10 * device specific filter modules, which can do their own thing when required.
14 #include <linux/config.h>
16 #define USB_SCSI "usbscsi: "
18 extern int usbscsi_debug
;
20 #ifdef CONFIG_USB_SCSI_DEBUG
21 void us_show_command(Scsi_Cmnd
*srb
);
22 #define US_DEBUGP(x...) { if(usbscsi_debug) printk( KERN_DEBUG USB_SCSI ## x ); }
23 #define US_DEBUGPX(x...) { if(usbscsi_debug) printk( ## x ); }
24 #define US_DEBUG(x) { if(usbscsi_debug) x; }
26 #define US_DEBUGP(x...)
27 #define US_DEBUGPX(x...)
31 /* bit set if input */
32 extern unsigned char us_direction
[256/8];
33 #define US_DIRECTION(x) ((us_direction[x>>3] >> (x & 7)) & 1)
37 #define US_SC_RBC 1 /* Typically, flash devices */
38 #define US_SC_8020 2 /* CD-ROM */
39 #define US_SC_QIC 3 /* QIC-157 Tapes */
40 #define US_SC_UFI 4 /* Floppy */
41 #define US_SC_8070 5 /* Removable media */
42 #define US_SC_SCSI 6 /* Transparent */
43 #define US_SC_MIN US_SC_RBC
44 #define US_SC_MAX US_SC_SCSI
48 #define US_PR_CB 1 /* Control/Bulk w/o interrupt */
49 #define US_PR_CBI 0 /* Control/Bulk/Interrupt */
50 #define US_PR_ZIP 0x50 /* bulk only */
51 /* #define US_PR_BULK ?? */
54 * Bulk only data structures (Zip 100, for example)
58 __u32 Signature
; /* contains 'USBC' */
59 __u32 Tag
; /* unique per command id */
60 __u32 DataTransferLength
; /* size of data */
61 __u8 Flags
; /* direction in bit 0 */
62 __u8 Lun
; /* LUN normally 0 */
63 __u8 Length
; /* of of the CDB */
64 __u8 CDB
[16]; /* max command */
67 #define US_BULK_CB_WRAP_LEN 31
68 #define US_BULK_CB_SIGN 0x43425355
69 #define US_BULK_FLAG_IN 1
70 #define US_BULK_FLAG_OUT 0
73 __u32 Signature
; /* should = 'USBS' */
74 __u32 Tag
; /* same as original command */
75 __u32 Residue
; /* amount not transferred */
76 __u8 Status
; /* see below */
80 #define US_BULK_CS_WRAP_LEN 31
81 #define US_BULK_CS_SIGN 0x53425355
82 #define US_BULK_STAT_OK 0
83 #define US_BULK_STAT_FAIL 1
84 #define US_BULK_STAT_PHASE 2
86 #define US_BULK_RESET 0xff
87 #define US_BULK_RESET_SOFT 1
88 #define US_BULK_RESET_HARD 0
97 * Filter device definitions
99 struct usb_scsi_filter
{
101 struct usb_scsi_filter
* next
; /* usb_scsi driver only */
102 char *name
; /* not really required */
104 unsigned int flags
; /* Filter flags */
105 void * (* probe
) (struct usb_device
*, char *, char *, char *); /* probe device */
106 void (* release
)(void *); /* device gone */
107 int (* command
)(void *, Scsi_Cmnd
*); /* all commands */
110 #define GUID(x) __u32 x[3]
111 #define GUID_EQUAL(x, y) (x[0] == y[0] && x[1] == y[1] && x[2] == y[2])
112 #define GUID_CLEAR(x) x[0] = x[1] = x[2] = 0;
113 #define GUID_NONE(x) (!x[0] && !x[1] && !x[2])
114 #define GUID_FORMAT "%08x%08x%08x"
115 #define GUID_ARGS(x) x[0], x[1], x[2]
117 static inline void make_guid( __u32
*pg
, __u16 vendor
, __u16 product
, char *serial
)
119 pg
[0] = (vendor
<< 16) | product
;
123 pg
[1] |= pg
[2] >> 28;
126 *serial
-= 'a' - 'A';
127 pg
[2] |= (*serial
<= '9' && *serial
>= '0') ? *serial
- '0'
128 : *serial
- 'A' + 10;
133 /* Flag definitions */
134 #define US_FL_IP_STATUS 0x00000001 /* status uses interrupt */
135 #define US_FL_FIXED_COMMAND 0x00000002 /* expand commands to fixed size */
138 * Called by filters to register/unregister the mini driver
140 * WARNING - the supplied probe function may be called before exiting this fn
142 int usb_scsi_register(struct usb_scsi_filter
*);
143 void usb_scsi_deregister(struct usb_scsi_filter
*);
145 #ifdef CONFIG_USB_HP4100
146 int hp4100_init(void);