1 /*
2 * Driver for USB Scanners (linux-2.4.0test1-ac7)
3 *
4 * Copyright (C) 1999, 2000 David E. Nelson
5 *
6 * David E. Nelson (dnelson@jump.net)
7 *
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.
12 *
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.
17 *
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.
21 *
22 */
23
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>
33 #include <linux/smp_lock.h>
34
35 // #define DEBUG
36
37 #include <linux/usb.h>
38
39 static __s32 vendor=-1, product=-1;
40
41 MODULE_AUTHOR("David E. Nelson, dnelson@jump.net, http://www.jump.net/~dnelson");
42 MODULE_DESCRIPTION("USB Scanner Driver");
43
44 MODULE_PARM(vendor, "i");
45 MODULE_PARM_DESC(vendor, "User specified USB idVendor");
46
47 MODULE_PARM(product, "i");
48 MODULE_PARM_DESC(product, "User specified USB idProduct");
49
50
51 /* Enable to activate the ioctl interface. This is mainly meant for */
52 /* development purposes until an ioctl number is officially registered */
53 // #define SCN_IOCTL
54
55 /* WARNING: These DATA_DUMP's can produce a lot of data. Caveat Emptor. */
56 // #define RD_DATA_DUMP /* Enable to dump data - limited to 24 bytes */
57 // #define WR_DATA_DUMP /* DEBUG does not have to be defined. */
58
59 #define IS_EP_BULK(ep) ((ep).bmAttributes == USB_ENDPOINT_XFER_BULK ? 1 : 0)
60 #define IS_EP_BULK_IN(ep) (IS_EP_BULK(ep) && ((ep).bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN)
61 #define IS_EP_BULK_OUT(ep) (IS_EP_BULK(ep) && ((ep).bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT)
62 #define IS_EP_INTR(ep) ((ep).bmAttributes == USB_ENDPOINT_XFER_INT ? 1 : 0)
63
64 #define USB_SCN_MINOR(X) MINOR((X)->i_rdev) - SCN_BASE_MNR
65
66 #ifdef DEBUG
67 #define SCN_DEBUG(X) X
68 #else
69 #define SCN_DEBUG(X)
70 #endif
71
72 #define IBUF_SIZE 32768
73 #define OBUF_SIZE 4096
74
75 /* read_scanner timeouts -- RD_NAK_TIMEOUT * RD_EXPIRE = Number of seconds */
76 #define RD_NAK_TIMEOUT (10*HZ) /* Number of X seconds to wait */
77 #define RD_EXPIRE 12 /* Number of attempts to wait X seconds */
78
79
80 /* FIXME: These are NOT registered ioctls()'s */
81 #define PV8630_IOCTL_INREQUEST 69
82 #define PV8630_IOCTL_OUTREQUEST 70
83
84 #define SCN_MAX_MNR 16 /* We're allocated 16 minors */
85 #define SCN_BASE_MNR 48 /* USB Scanners start at minor 48 */
86
87 struct scn_usb_data {
88 struct usb_device *scn_dev;
89 struct urb scn_irq;
90 unsigned int ifnum; /* Interface number of the USB device */
91 kdev_t scn_minor; /* Scanner minor - used in disconnect() */
92 unsigned char button; /* Front panel buffer */
93 char isopen; /* Not zero if the device is open */
94 char present; /* Not zero if device is present */
95 char *obuf, *ibuf; /* transfer buffers */
96 char bulk_in_ep, bulk_out_ep, intr_ep; /* Endpoint assignments */
97 wait_queue_head_t rd_wait_q; /* read timeouts */
98 struct semaphore gen_lock; /* lock to prevent concurrent reads or writes */
99 };
100
101 static struct scn_usb_data *p_scn_table[SCN_MAX_MNR] = { NULL, /* ... */};
102
103 static struct usb_driver scanner_driver;
104
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.