2. General Support and Interface Type
There are four predominant types of scanner interfaces available and discussed in this document: SCSI, USB, parallel port, IEEE 1394. Linux support exists for most scanners as pioneered by the SANE project. This is not the same thing as TWAIN, which you may be familiar with if you have used a scanner device under another operating system such as Microsoft Windows™. The latter protocol weds driver and user interface in a way that does not allow its use outside of that proprietary graphical environment. Thus SANE, or Scanner Access Now Easy, was conceived for use under (but is by no means limited to) the Un*x environment. The SANE standard allows for modularity where driver meets application and allows for much greater flexibility and portability. With SANE you can scan with your device using only the command line, you can design your own front-end application to use the SANE backend(s), access your scanner(s) over a network or even access your cameras and other video4linux devices to acquire photographs. As such SANE is SANE where TWAIN is not.
NOTE: Before reading any further you should check the SANE homepage at http://www.sane-project.org/sane-mfgs.html to see if your scanner device is supported. Alternatively you can use the sane supported scanners search engine.
If you have an integrated device, i.e., one that functions as a scanner, printer and/or fax, you can follow the steps below for the scanner functions using the appropriate interface just like a standard scanner. Those who own an HP officejet should consult the HP Officejet Linux Driver project site, which goes into excellent detail on how to get the various functions of this integrated device to work within Linux.
2.1. SCSI Scanners
These scanners are managed by an SCSI controller. In general, just about any scanner using an SCSI interface should work assuming the SCSI hardware is supported. You should check the SCSI controller list of the Hardware HOWTO if you are unsure if the SCSI controller is supported. If your SCSI controller came bundled with your scanner there is a chance your hardware may not be supported or is only partly supported, as the accompanying SCSI card may not function as a complete SCSI controller.
You should consult man sane-scsi, if you run into difficulty configuring your SCSI scanner at any point.
2.2. USB Scanners
You probably already know what a Universal Serial Bus (USB) connector looks like and where it plugs in. If you have a USB scanner your hardware is likely to be supported in Linux. Information on enabling the USB subsystem and USB scanner support is found in Section 2.5.
2.3. Parallel Port Scanners
Parallel-port scanners on the whole can be made to work if there is a backend that supports them, however if your device also has a USB port (which the vast majority of new scanners released nowadays do) and a working USB backend you are strongly encouraged to use that instead, as it may be more easily configured.
If your model has only a parallel-port interface and a proprietary or non-standard controller you could be out of luck. If you have found there is a supported backend for the parallel-port interface of your scanner, then you should see Section 2.8.
2.4. IEEE 1394 (Firewire™, i.Link™)
Some IEEE 1394 scanners are supported as of the time of this writing, particularly those manufactured by Nikon and Epson. The IEEE 1394 interface has been supported since the 2.4-series Linux kernel. IEEE 1394 scanners require your system be equipped with a IEEE 1394 PCI card or a mainboard IEEE 1394 port, as well as have IEEE 1394 support enabled in your kernel or as a loaded module. You should check the SANE supported devices by manufacturer link in Section 2 and read the manpage next to your hardware (if any) for any issues related to your specific hardware.
2.5. Operating System Support
If you don't have a USB scanner you should skip to Section 2.7, and if your equipment is of the parallel port variety you should go to Section 2.8.
2.6. USB Scanners and Libusb
This section was at one time entitled "USB Scanner Kernel Support," but the existence of libusb promises to make the need for a USB-scanner enabled kernel unnecessary. Libusb is a project to create a userspace (i.e., non-kernel) library to access USB devices regardless of operating system. For more information on the differences between these consult man sane-usb.
If you would prefer the more conventional kernel support for your USB Scanner, go on to Section 2.7.2, but be advised that kernel support for USB scanner devices is dropped in favor of libusb in kernel version 2.6.0 and higher. Most distributions at this point are offering libusb in their stable branches (and some install it by default), so if you don't already have kernel support for USB scanner devices then you may only have to install the libusb package in order to access your device. You must have USB device filesystem support enabled in your kernel, which most distributions do. To find out for sure, issue the following at the command line:
$ cat /proc/filesystems |
You should see (among others):
nodev usbdevfs nodev usbfs |
You may need to mount usbdevfs to enable it and see the device files, which you can do at the command line with mount -t usbdevfs none /proc/bus/usb. Don't try to use libusb while kernel scanner support is enabled either statically or the module loaded; you can only use one at at time.
You can obtain the libusb package in .rpm, .tgz or .deb format from your Linux distribution. If you are planning on compiling your own SANE binary from source with libusb support enabled you will require the libusb-dev package as well.
2.7. Linux Kernel Support of your Scanner Device
Kernel support is required for SCSI, USB and parallel-port generic interface support and USB scanner support (if not using libusb). Your stock kernel may already have support for what you need, and the way to tell is to use the dmesg command and look for an acknowledgement that the driver in question loaded at bootup. If you don't see it, the driver may be present (but not necessarily loaded) as a module. To find out you can type the following at the command line:
$ ls -R /lib/modules/X.XX/kernel/drivers |
Where 'X.XX' is your kernel version number. The following output is an example of what you would find in a USB scanner-enabled kernel (though all but the relevant lines have been edited for brevity):
./usb: scanner.o usbcore.o |
(A hint for newbies: if the info in dmesg or the above module list scrolls by too fast, you might try piping the output into 'less' (or 'more' if you don't have less): ls -R /lib/modules/X.XX/kernel/drivers | less or alternatively catching it in a file: ls -R /lib/modules/X.XX/kernel/drivers > file.txt, where 'file.txt' will contain the info that can then be accessed with cat [file] | less.)
The following information is arranged on the basis of scanner interface type. If your kernel doesn't contain the necessary support, you can always recompile your kernel. If you are unfamiliar with the process of compiling your own kernel, I direct you to the Kernel HOWTO for more information.
2.7.1. Kernel SCSI Support
If you have an SCSI-type interface, when invoking make config, make menuconfig or make xconfig etc., be aware that in addition to the option to support your particular SCSI adapter, generic SCSI device support is also required. Such generic devices are usually named /dev/sg0, /dev/sg1.... Since you probably already know if your card is supported from the supported SCSI controllers list, all that is required after confirming that your kernel supports your hardware and generic SCSI devices is to load the appropriate module(s):
# modprobe CARD_MODULE_NAME |
# modprobe sg |
...as root. Note there have been reports of ide-scsi emulation support (used for ATAPI-eide CDRW support) causing problems for scanner access; if you know your hardware is supported and you can't get things to work try unloading the ide-scsi module:
rmmod ide-scsi |
...though it has been reported to me that this has been fixed as of recent (2.4.20+) kernels.
2.7.2. Kernel USB and USB Scanner Support
For USB scanner support, you will need USB subsystem support in your kernel, whether usb-ohci, usb-ehci, or whatever protocol of USB driver your system prefers. USB support has been present in the Linux kernel since the late 2.2-series. For a more in-depth discussion of USB support in general, I direct you to the linux-usb project site. If you have a 2.4-series of kernel or earlier and wish to use the kernel USB-scanner support to access your scanner (instead of libusb outlined in Section 2.6) you will need to have 'USB scanner support' enabled, which, if present, is visible within dmesg, or by lsmod if a loaded module. If you want to find out which modules are loaded, at the command line or in an xterm type the following:
# lsmod |
As shown by the prompt above you will need to have root privileges to do this. You should get output including (but not limited to) the following:
cdrom 29312 0 (autoclean) [sr_mod] usb-ohci 17888 0 (unused) usbcore 56768 0 [scanner ibmcam usbvideo usb-ohci] scanner 8704 0 |
If you don't have scanner loaded, and you know you have USB scanner support in your kernel as a module, try loading it directly:
# modprobe -v scanner |
...at which point you should see something like the following:
Using /lib/modules/2.4.20/kernel/drivers/usb/scanner.o |
By placing the entry scanner in /etc/modules (note that this varies by distribution), you can have the module load at boot-time automatically. You can then confirm the module was loaded by checking the syslog or in the boot-time record with dmesg | less), where you should see an entry such as the following:
May 16 23:17:25 K7 kernel: usb.c: registered new driver usbscanner May 16 23:17:25 K7 kernel: scanner.c: 0.4.6:USB Scanner Driver |
2.8. Parallel Port Scanners
By now you've probably figured out that configuration of parallel port scanners may be problematic. Again, if your device has both a parallel port interface and a USB interface you should consider selecting USB to make the setup process easier.
2.8.1. Kernel Parport Support
For 2.2 and 2.4 kernel systems, parallel-port support must be enabled statically or as a module (stock kernels usually have this enabled by default). You may want to read more generic info about parallel-port device support under the Linux kernel before starting this process. To find out for sure if the module parport is loaded you can check the dmesg file or use lsmod as outlined above. Using dmesg | less you should see (among many other lines) the following:
Mar 3 08:00:25 K7 kernel: parport0: PC-style at 0x378 (0x778) [PCSPP,TRISTATE] Mar 3 08:00:25 K7 kernel: parport0: irq 7 detected |
If you are compiling your own kernel, enable 'Parallel Port support.' You should enable 'IEEE 1284 transfer modes,' and if you have x86 type architecture you should also enable 'PC-style hardware.'
If modprobe returns an error when you attempt to load the module note that you may need to determine and supply the hardware address when invoking modprobe. The most common address is 0x378 for an x86 system; 0x278 and 0x3BC are other possibilities for integrated or ISA parallel ports. Add-in PCI parallel ports may have unusual base addresses. One can also arrange multiple devices with either the parport_pc or parport_arc modules, though that topic is beyond the scope of this document. WARNING: Be sure you have the correct address before entering this information at the command line or else your machine may become unstable, crash or otherwise implode.
Your parallel port should be set to preferably "EPP" mode, or alternatively ECP/EPP. "Bidirectional" (also known as "BPP" or "PS/2") may work, albeit much more slowly. "Unidirectional" mode is unsuitable for scanning. The above setting can usually be accessed through your BIOS menu, at least on x86 systems.
Depending on whether your parallel port scanner requires SCSI support, you may need to patch your kernel for parport-SCSI support. You can find that suite of tools at www.torque.net/parport/ppscsi.html. If this is required you will also need to enable the following:
SCSI support
SCSI generic support
Support for the core module of your ppSCSI controller (t348 for the APA-348 and T348, t358 for the APA-358 and T358, epsa2 for the older Shuttle EPSA-2, epst for the Shuttle EPST and APA-1350, onscsi for the OnSpec 90c26, and sparcsi for the SparCSI and ParaSCSI)
Once these are compiled in, it's simply a matter of loading the appropriate modules.