1 |
1275 |
phoenix |
Copyright (C) 1999, 2000 David E. Nelson
|
2 |
|
|
Updated 2003 by Henning Meier-Geinitz
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
OVERVIEW
|
6 |
|
|
|
7 |
|
|
This README addresses issues regarding how to configure the kernel to access a
|
8 |
|
|
USB scanner. Although the driver was originally conceived for USB HP
|
9 |
|
|
scanners, it's general enough so that it can be used with most other USB
|
10 |
|
|
scanners. Also, one can pass the USB Vendor and Product IDs using module
|
11 |
|
|
parameters for unknown scanners.
|
12 |
|
|
|
13 |
|
|
There are two drivers for SCSI-over-USB scanners:
|
14 |
|
|
* The "hpusbscsi" module for Hewlett-Packard 53xx series, Hewlett-Packard 7400,
|
15 |
|
|
Minolta Scan Dual II, Minolta Elite II
|
16 |
|
|
* The "microtek" module for the Microtek Scanmaker X6
|
17 |
|
|
|
18 |
|
|
In addition to the kernel driver, user-space tools like SANE are necessary to
|
19 |
|
|
actually use the scanner. SANE ("Scanner Access Now Easy") provides drivers
|
20 |
|
|
for a variety of USB scanners. See the appropriate SANE man page for details,
|
21 |
|
|
e.g. man sane-usb and man sane-hp (for HP scanners).
|
22 |
|
|
|
23 |
|
|
NOTE: Just because a product is detected by this driver does not mean that
|
24 |
|
|
applications exist that support the product. It's in the hopes that this will
|
25 |
|
|
allow developers a means to produce applications that will support the listed
|
26 |
|
|
USB products.
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
ADDITIONAL INFORMATION
|
30 |
|
|
|
31 |
|
|
http://www.linux-usb.org/ (General information, mailing lists, links)
|
32 |
|
|
http://www.mostang.com/sane/ (SANE user-space tools)
|
33 |
|
|
http://www.meier-geinitz.de/kernel/ (USB scanner driver information and patches)
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
REQUIREMENTS
|
37 |
|
|
|
38 |
|
|
A host with a USB port. Ideally, either a UHCI (Intel), OHCI (Compaq and
|
39 |
|
|
others) or EHCI hardware should work.
|
40 |
|
|
|
41 |
|
|
Using "make menuconfig" or your preferred method for configuring the kernel,
|
42 |
|
|
select "Support for USB", "OHCI/UHCI/EHCI" depending on your hardware, "USB
|
43 |
|
|
Scanner support", and "Preliminary USB device filesystem". Compile and
|
44 |
|
|
install the modules (you may need to execute "depmod -a" to update the module
|
45 |
|
|
dependencies). If any of the USB sections were compiled into the kernel, a
|
46 |
|
|
reboot is necessary. NOTE: Updating the boot disk with "lilo" may also be
|
47 |
|
|
required. Testing was performed only as modules, YMMV.
|
48 |
|
|
|
49 |
|
|
Up to 16 scanners can be connected/used simultaneously. If devfs support is
|
50 |
|
|
enabled, see next section. Otherwise, the device files must be created
|
51 |
|
|
manually if they don't exist yet, either by MAKEDEV or mknod.
|
52 |
|
|
|
53 |
|
|
MAKEDEV method:
|
54 |
|
|
cd /dev
|
55 |
|
|
MAKEDEV usb
|
56 |
|
|
Check that the device files "/dev/usb/scanner0" - "/dev/usb/scanner15" have
|
57 |
|
|
been created.
|
58 |
|
|
|
59 |
|
|
mknod method:
|
60 |
|
|
mknod /dev/usb/scanner0 c 180 48
|
61 |
|
|
mknod /dev/usb/scanner1 c 180 49
|
62 |
|
|
.
|
63 |
|
|
.
|
64 |
|
|
mknod /dev/usb/scanner15 c 180 63
|
65 |
|
|
|
66 |
|
|
Set appropriate permissions for /dev/usb/scanner[0-15] (don't forget
|
67 |
|
|
about group and world permissions). Both read and write permissions
|
68 |
|
|
are required for proper operation. For example:
|
69 |
|
|
chmod 666 /dev/usb/scanner0
|
70 |
|
|
|
71 |
|
|
Load the appropriate modules (if compiled as modules):
|
72 |
|
|
|
73 |
|
|
modprobe usb-ohci (or uhci, usb-uhci, ehci)
|
74 |
|
|
modprobe scanner
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
DEVFS
|
78 |
|
|
|
79 |
|
|
The later versions of the Linux kernel (2.4.8'ish) included a dynamic
|
80 |
|
|
device filesystem call "devfs". With devfs, there is no need to
|
81 |
|
|
create the device files as explained above; instead, they are
|
82 |
|
|
dynamically created for you. For USB Scanner, the device is created
|
83 |
|
|
in /dev/usb/scannerX where X can range from 0 to 15 depending on the
|
84 |
|
|
number of scanners connected to the system.
|
85 |
|
|
|
86 |
|
|
To see if you have devfs, issue the command "cat /proc/filesytems".
|
87 |
|
|
If devfs is listed you should be ready to go. You should also have a
|
88 |
|
|
process running called "devfsd". In order to make sure, issue the
|
89 |
|
|
command "ps aux | grep '[d]evfsd'".
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
CONCLUSION
|
93 |
|
|
|
94 |
|
|
That's it. SANE should now be able to access the device. To make sure the
|
95 |
|
|
device was detected, use "cat /proc/bus/usb/devices". Your scanner should be
|
96 |
|
|
listed and the line starting with "I:" should look similar to this example:
|
97 |
|
|
|
98 |
|
|
I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=usbscanner
|
99 |
|
|
|
100 |
|
|
The important part is "Driver=usbscanner". If it reads "Driver=(none)", the
|
101 |
|
|
USB scanner driver didn't recognize the scanner. Have a look at the MODULE
|
102 |
|
|
PARAMETERS section for what to do in this case.
|
103 |
|
|
|
104 |
|
|
For more details on the format of "/proc/bus/usb/devices" see
|
105 |
|
|
Documentation/usb/proc_usb_info.txt.
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
MESSAGES
|
109 |
|
|
|
110 |
|
|
usb_control/bulk_msg: timeout -- On occasions this message will appear
|
111 |
|
|
in "/var/adm/messages", on the console, or both depending on how
|
112 |
|
|
your system is configured. This is a side effect that scanners are
|
113 |
|
|
sometimes very slow at warming up and/or initializing. In most cases,
|
114 |
|
|
however, only several of these messages should appear and is generally
|
115 |
|
|
considered to be normal.
|
116 |
|
|
|
117 |
|
|
excessive NAK's received -- This message should be considered abnormal
|
118 |
|
|
and generally indicates that the USB system is unable to communicate
|
119 |
|
|
with the scanner for some particular reason.
|
120 |
|
|
|
121 |
|
|
probe_scanner: Undetected endpoint -- The USB Scanner driver is fairly
|
122 |
|
|
general when it comes to communicating to scanners. Unfortunately,
|
123 |
|
|
some vendors have designed their scanners in one way or another that
|
124 |
|
|
this driver doesn't account for.
|
125 |
|
|
|
126 |
|
|
probe_scanner: Endpoint determination failed -- This means that the
|
127 |
|
|
driver is unable to detect a supported configuration for means to
|
128 |
|
|
communicate with the scanner. See also "probe_scanner: Undetected
|
129 |
|
|
endpoint".
|
130 |
|
|
|
131 |
|
|
funky result -- Most of the time the data flow between the computer
|
132 |
|
|
and the scanner goes smoothly. However, due to whatever reason,
|
133 |
|
|
whether it be solar flares or stray neutrons, sometimes the
|
134 |
|
|
communications don't work as expected. The driver tries to handle
|
135 |
|
|
most types of errors but not all. When this message is seen,
|
136 |
|
|
something weird happened. Please contact the mailing list (see
|
137 |
|
|
CONTACT section for details).
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
MODULE PARAMETERS
|
141 |
|
|
|
142 |
|
|
If you have a device that you wish to experiment with or try using
|
143 |
|
|
this driver with, but the Vendor and Product IDs are not coded in,
|
144 |
|
|
don't despair. If the driver was compiled as a module, you can pass
|
145 |
|
|
options to the driver. Simply add
|
146 |
|
|
|
147 |
|
|
options scanner vendor=0x#### product=0x****
|
148 |
|
|
|
149 |
|
|
to the /etc/modules.conf file replacing the #'s and the *'s with the
|
150 |
|
|
correct IDs. The IDs can be retrieved from the messages file or
|
151 |
|
|
using "cat /proc/bus/usb/devices".
|
152 |
|
|
|
153 |
|
|
If the default timeout is too low, i.e. there are frequent "timeout" messages,
|
154 |
|
|
you may want to increase the timeout manually by using the parameter
|
155 |
|
|
"read_timeout". The time is given in seconds. This is an example for
|
156 |
|
|
modules.conf with a timeout of 60 seconds:
|
157 |
|
|
|
158 |
|
|
options scanner read_timeout=60
|
159 |
|
|
|
160 |
|
|
If the "scanner" module is already loaded into memory, it must be reloaded for
|
161 |
|
|
the module parameters to take effect. In essence, "rmmod scanner; modprobe
|
162 |
|
|
scanner" must be performed.
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
BUGS
|
166 |
|
|
|
167 |
|
|
Just look at the list of fixes in the source files.
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
CONTACT
|
171 |
|
|
|
172 |
|
|
For asking about problems and fixes, use the linux-usb-users mailing list. For
|
173 |
|
|
patches, linux-usb-devel should be used. Information on both lists can be
|
174 |
|
|
found on http://www.linux-usb.org/.
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
CHANGES
|
178 |
|
|
|
179 |
|
|
- Added information about read_timeout
|
180 |
|
|
- Added more details about /proc/bus/usb/devices
|
181 |
|
|
- Added/updated links
|
182 |
|
|
- Added pointers two "special" scanner drivers
|
183 |
|
|
- Reordering, spell-checking, formatting
|
184 |
|
|
- Used /dev/usb/scanner[0-15] instead of /dev/usbscanner[0-15]
|
185 |
|
|
- Removed some basic USB configuration stuff
|
186 |
|
|
- Added EHCI
|
187 |
|
|
- Removed some more references to HP
|
188 |
|
|
- Amended for linux-2.4.12
|
189 |
|
|
- Updated devfs support
|
190 |
|
|
- Amended for linux-2.3.99-pre6-3
|
191 |
|
|
- Appended hp_scan.c to end of this README
|
192 |
|
|
- Removed most references to HP
|
193 |
|
|
- Updated uhci/ohci host controller info
|
194 |
|
|
- Updated support for multiple scanner support
|
195 |
|
|
- Updated supported scanners list
|
196 |
|
|
- Updated usbdevfs info
|
197 |
|
|
- Spellcheck
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
HP TEST PROGRAM
|
201 |
|
|
|
202 |
|
|
There is a small test program (hp_scan.c -- appended below) that can
|
203 |
|
|
be used to test the scanner device if it's an HP scanner that supports
|
204 |
|
|
SCL (Scanner Control Language). Known HP scanner that support SCL are
|
205 |
|
|
the 4100, 5200, 6200, the 6300 -- note that the 4200 is *not*
|
206 |
|
|
supported since it does not understand SCL; it's also strongly
|
207 |
|
|
suspected that the 3300 and the PhotoSmart S20 are not SCL compliant.
|
208 |
|
|
Hp_scan.c's purpose is to test the driver without having to
|
209 |
|
|
retrieve/configure SANE. Hp_scan.c will scan the entire bed and put
|
210 |
|
|
the output into a file called "out.dat" in the current directory. The
|
211 |
|
|
data in the file is raw data so it's not very useful for imaging.
|
212 |
|
|
|
213 |
|
|
--------------- snip -- hp_scan.c -- snip ---------------
|
214 |
|
|
/*
|
215 |
|
|
|
216 |
|
|
This is a really crude attempt at writing a short test program. It's
|
217 |
|
|
mostly only to be used to test connectivity with USB HP scanners that
|
218 |
|
|
understand SCL. Currently, the supported models are 4100C, 5200C,
|
219 |
|
|
6200C, and the 6300C. Note that the 4200C is *NOT* acceptable.
|
220 |
|
|
|
221 |
|
|
Copyright (C) David E. Nelson , 1999
|
222 |
|
|
|
223 |
|
|
This program is free software; you can redistribute it and/or modify
|
224 |
|
|
it under the terms of the GNU General Public License as published by
|
225 |
|
|
the Free Software Foundation; either version 2 of the License, or (at
|
226 |
|
|
your option) any later version.
|
227 |
|
|
|
228 |
|
|
*/
|
229 |
|
|
|
230 |
|
|
#include
|
231 |
|
|
#include
|
232 |
|
|
#include
|
233 |
|
|
#include
|
234 |
|
|
#include
|
235 |
|
|
|
236 |
|
|
/*
|
237 |
|
|
Gray Output produces about a 8945400 byte file.
|
238 |
|
|
Color Output produces a 26836200 byte file.
|
239 |
|
|
|
240 |
|
|
To compile: gcc -o hp_scan hp_scan.c
|
241 |
|
|
*/
|
242 |
|
|
|
243 |
|
|
// #define COLOR /* Undef to scan GrayScale */
|
244 |
|
|
|
245 |
|
|
int send_cmd(int, const char *, int);
|
246 |
|
|
int read_cmd(int, char *, int);
|
247 |
|
|
|
248 |
|
|
int
|
249 |
|
|
main(void) {
|
250 |
|
|
|
251 |
|
|
ssize_t cnt = 0, total_cnt = 0;
|
252 |
|
|
|
253 |
|
|
FILE *fpout;
|
254 |
|
|
|
255 |
|
|
int fp;
|
256 |
|
|
int data_size = 32768;
|
257 |
|
|
|
258 |
|
|
char *data;
|
259 |
|
|
|
260 |
|
|
static char reset_cmd[] = {'\x1b','E'};
|
261 |
|
|
|
262 |
|
|
#ifdef COLOR
|
263 |
|
|
static char data_type_cmd[] = {'\x1b','*','a','5','T'}; /* Color */
|
264 |
|
|
static char data_width_cmd[] = {'\x1b','*','a','2','4','G'}; /* 24 Bit Color */
|
265 |
|
|
#else
|
266 |
|
|
static char data_type_cmd[] = {'\x1b','*','a','4','T'}; /* Gray */
|
267 |
|
|
static char data_width_cmd[] = {'\x1b','*','a','8','G'}; /* 8 Bit Gray */
|
268 |
|
|
#endif
|
269 |
|
|
|
270 |
|
|
static char query_cmd[] = {'\x1b', '*', 's', '2', '5', '7', 'E'};
|
271 |
|
|
static char start_scan_cmd[] = {'\x1b','*','f','0','S'};
|
272 |
|
|
|
273 |
|
|
if(!(data=malloc(data_size))) {
|
274 |
|
|
perror("malloc failed");
|
275 |
|
|
exit (1);
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
if((fp=open("/dev/usb/scanner0", O_RDWR)) < 0) {
|
279 |
|
|
perror("Unable to open scanner device");
|
280 |
|
|
exit (1);
|
281 |
|
|
}
|
282 |
|
|
|
283 |
|
|
if((fpout=fopen("out.dat", "w+")) == NULL) {
|
284 |
|
|
perror("Unable to open ouput file");
|
285 |
|
|
exit(1);
|
286 |
|
|
}
|
287 |
|
|
|
288 |
|
|
send_cmd(fp, reset_cmd, sizeof(reset_cmd));
|
289 |
|
|
send_cmd(fp, data_type_cmd, sizeof(data_type_cmd));
|
290 |
|
|
send_cmd(fp, data_width_cmd, sizeof(data_width_cmd));
|
291 |
|
|
send_cmd(fp, start_scan_cmd, sizeof(start_scan_cmd));
|
292 |
|
|
|
293 |
|
|
while ((cnt = read(fp, data, data_size)) > 0) {
|
294 |
|
|
printf("Read: %u\n", cnt);
|
295 |
|
|
if(fwrite(data, sizeof(char), cnt, fpout) < 0) {
|
296 |
|
|
perror("Write to output file failed");
|
297 |
|
|
exit (1);
|
298 |
|
|
}
|
299 |
|
|
total_cnt += cnt;
|
300 |
|
|
}
|
301 |
|
|
if (cnt < 0) {
|
302 |
|
|
perror("Read from scanner failed");
|
303 |
|
|
exit (1);
|
304 |
|
|
}
|
305 |
|
|
|
306 |
|
|
printf("\nRead %lu bytes.\n", total_cnt);
|
307 |
|
|
|
308 |
|
|
send_cmd(fp, reset_cmd, sizeof(reset_cmd));
|
309 |
|
|
|
310 |
|
|
close(fp);
|
311 |
|
|
fclose(fpout);
|
312 |
|
|
return (0);
|
313 |
|
|
}
|
314 |
|
|
|
315 |
|
|
int
|
316 |
|
|
send_cmd(int fp, const char * cmd, int length) {
|
317 |
|
|
|
318 |
|
|
int result;
|
319 |
|
|
int x;
|
320 |
|
|
|
321 |
|
|
if((result = write(fp, cmd, length)) != length) {
|
322 |
|
|
printf ("Write warning: %d bytes requested, %d written\n");
|
323 |
|
|
} else if (result < 0) {
|
324 |
|
|
perror ("send_cmd failure");
|
325 |
|
|
exit (1);
|
326 |
|
|
}
|
327 |
|
|
return (result);
|
328 |
|
|
}
|
329 |
|
|
|
330 |
|
|
int
|
331 |
|
|
read_cmd(int fp, char * response, int length) {
|
332 |
|
|
|
333 |
|
|
return read(fp, response, length);
|
334 |
|
|
|
335 |
|
|
}
|