- pre2
[davej-history.git] / drivers / usb / scanner.h
blob7662f125e1f424a5cdba96086357e3b9c204d224
1 /*
2 * Driver for USB Scanners (linux-2.4.0test1-ac7)
4 * Copyright (C) 1999, 2000 David E. Nelson
6 * David E. Nelson (dnelson@jump.net)
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
24 #include <linux/module.h>
25 #include <linux/kernel.h>
26 #include <linux/errno.h>
27 #include <asm/uaccess.h>
28 #include <linux/init.h>
29 #include <linux/malloc.h>
30 #include <linux/delay.h>
31 #include <linux/ioctl.h>
32 #include <linux/sched.h>
34 // #define DEBUG
36 #include <linux/usb.h>
38 static __s32 vendor=-1, product=-1;
40 MODULE_AUTHOR("David E. Nelson, dnelson@jump.net, http://www.jump.net/~dnelson");
41 MODULE_DESCRIPTION("USB Scanner Driver");
43 MODULE_PARM(vendor, "i");
44 MODULE_PARM_DESC(vendor, "User specified USB idVendor");
46 MODULE_PARM(product, "i");
47 MODULE_PARM_DESC(product, "User specified USB idProduct");
50 /* Enable to activate the ioctl interface. This is mainly meant for */
51 /* development purposes until an ioctl number is officially registered */
52 // #define SCN_IOCTL
54 /* WARNING: These DATA_DUMP's can produce a lot of data. Caveat Emptor. */
55 // #define RD_DATA_DUMP /* Enable to dump data - limited to 24 bytes */
56 // #define WR_DATA_DUMP /* DEBUG does not have to be defined. */
58 #define IS_EP_BULK(ep) ((ep).bmAttributes == USB_ENDPOINT_XFER_BULK ? 1 : 0)
59 #define IS_EP_BULK_IN(ep) (IS_EP_BULK(ep) && ((ep).bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)
60 #define IS_EP_BULK_OUT(ep) (IS_EP_BULK(ep) && ((ep).bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT)
61 #define IS_EP_INTR(ep) ((ep).bmAttributes == USB_ENDPOINT_XFER_INT ? 1 : 0)
63 #define USB_SCN_MINOR(X) MINOR((X)->i_rdev) - SCN_BASE_MNR
65 #ifdef DEBUG
66 #define SCN_DEBUG(X) X
67 #else
68 #define SCN_DEBUG(X)
69 #endif
71 #define IBUF_SIZE 32768
72 #define OBUF_SIZE 4096
74 /* read_scanner timeouts -- RD_NAK_TIMEOUT * RD_EXPIRE = Number of seconds */
75 #define RD_NAK_TIMEOUT (10*HZ) /* Number of X seconds to wait */
76 #define RD_EXPIRE 12 /* Number of attempts to wait X seconds */
79 /* FIXME: These are NOT registered ioctls()'s */
80 #define PV8630_IOCTL_INREQUEST 69
81 #define PV8630_IOCTL_OUTREQUEST 70
83 #define SCN_MAX_MNR 16 /* We're allocated 16 minors */
84 #define SCN_BASE_MNR 48 /* USB Scanners start at minor 48 */
86 struct scn_usb_data {
87 struct usb_device *scn_dev;
88 struct urb scn_irq;
89 unsigned int ifnum; /* Interface number of the USB device */
90 kdev_t scn_minor; /* Scanner minor - used in disconnect() */
91 unsigned char button; /* Front panel buffer */
92 char isopen; /* Not zero if the device is open */
93 char present; /* Not zero if device is present */
94 char *obuf, *ibuf; /* transfer buffers */
95 char bulk_in_ep, bulk_out_ep, intr_ep; /* Endpoint assignments */
96 wait_queue_head_t rd_wait_q; /* read timeouts */
99 static struct scn_usb_data *p_scn_table[SCN_MAX_MNR] = { NULL, /* ... */};
101 /* table of scanners that may work with this driver */
102 static const struct scanner_device {
103 __u16 idVendor;
104 __u16 idProduct;
105 } scanner_device_ids [] = {
106 /* Acer */
107 { 0x04a5, 0x2060 }, /* Prisa Acerscan 620U & 640U (!) */
108 { 0x04a5, 0x2040 }, /* Prisa AcerScan 620U (!) */
109 /* Agfa */
110 { 0x06bd, 0x0001 }, /* SnapScan 1212U */
111 { 0x06bd, 0x2061 }, /* Another SnapScan 1212U (?) */
112 { 0x06bd, 0x0100 }, /* SnapScan Touch */
113 /* Colorado -- See Primax/Colorado below */
114 /* Epson -- See Seiko/Epson below */
115 /* Genius */
116 { 0x0458, 0x2001 }, /* ColorPage-Vivid Pro */
117 /* Hewlett Packard */
118 { 0x03f0, 0x0205 }, /* 3300C */
119 { 0x03f0, 0x0101 }, /* 4100C */
120 { 0x03f0, 0x0105 }, /* 4200C */
121 { 0x03f0, 0x0102 }, /* PhotoSmart S20 */
122 { 0x03f0, 0x0401 }, /* 5200C */
123 { 0x03f0, 0x0201 }, /* 6200C */
124 { 0x03f0, 0x0601 }, /* 6300C */
125 /* iVina */
126 { 0x0638, 0x0268 }, /* 1200U */
127 /* Microtek */
128 { 0x05da, 0x0099 }, /* ScanMaker X6 - X6U */
129 { 0x05da, 0x0094 }, /* Phantom 336CX - C3 */
130 { 0x05da, 0x00a0 }, /* Phantom 336CX - C3 #2 */
131 { 0x05da, 0x009a }, /* Phantom C6 */
132 { 0x05da, 0x00a3 }, /* ScanMaker V6USL */
133 { 0x05da, 0x80a3 }, /* ScanMaker V6USL #2 */
134 { 0x05da, 0x80ac }, /* ScanMaker V6UL - SpicyU */
135 /* Mustek */
136 { 0x055f, 0x0001 }, /* 1200 CU */
137 /* Primax/Colorado */
138 { 0x0461, 0x0300 }, /* G2-300 #1 */
139 { 0x0461, 0x0380 }, /* G2-600 #1 */
140 { 0x0461, 0x0301 }, /* G2E-300 #1 */
141 { 0x0461, 0x0381 }, /* ReadyScan 636i */
142 { 0x0461, 0x0302 }, /* G2-300 #2 */
143 { 0x0461, 0x0382 }, /* G2-600 #2 */
144 { 0x0461, 0x0303 }, /* G2E-300 #2 */
145 { 0x0461, 0x0383 }, /* G2E-600 */
146 { 0x0461, 0x0340 }, /* Colorado USB 9600 */
147 { 0x0461, 0x0360 }, /* Colorado USB 19200 */
148 { 0x0461, 0x0341 }, /* Colorado 600u */
149 { 0x0461, 0x0361 }, /* Colorado 1200u */
150 /* Seiko/Epson Corp. */
151 { 0x04b8, 0x0101 }, /* Perfection 636U and 636Photo */
152 { 0x04b8, 0x0103 }, /* Perfection 610 */
153 { 0x04b8, 0x0104 }, /* Perfection 1200U and 1200Photo */
154 /* Umax */
155 { 0x1606, 0x0010 }, /* Astra 1220U */
156 { 0x1606, 0x0002 }, /* Astra 1236U */
157 { 0x1606, 0x0030 }, /* Astra 2000U */
158 { 0x1606, 0x0230 }, /* Astra 2200U */
159 /* Visioneer */
160 { 0x04a7, 0x0221 }, /* OneTouch 5300 */
161 { 0x04a7, 0x0221 }, /* OneTouch 7600 duplicate ID (!) */
162 { 0x04a7, 0x0231 }, /* 6100 */
165 /* Forward declarations */
166 static struct usb_driver scanner_driver;