Using a CanoScan LiDE20 USB scanner under FreeBSD 4.8

Grenville Armitage, October 2003

This documentation is largely for my own benefit, although I've written it in the hope it will be useful to others (like you, if you're reading this page and you aren't me).

Summary

I purchased a CanoScan LiDE20 USB scanner in January 2003, and was initially forced to use it under Windows. Then in 3Q 2003 I noticed that the SANE package of open-source support for scanners had evolved to support this type of scanner. My main home machine was running FreeBSD 4.8 at the time. The main complexity was two short kernel usb driver patches to recognize the LiDE20's vendor and product codes. There were also some problems with gamma settings for the LiDE20 - the community that supports this scanner was still working on identifying an optimal set of configuration codes in 4Q 2003. Nevertheless, my LiDE20 scanner is now connected by USB port to my FreeBSD 4.8 host and I'm scanning photos!

Introduction

There are three key components to this little saga:
My first step was to install SANE's "backends" (the user-space libraries to drive a range of different scanners). For simplicity I installed the FreeBSD package version with:

pkg_add -r sane-backends

(This pulled in sane-backends-1.0.11, the latest pre-built package under FreeBSD 4.8 at the time. As it turns out a later version was available through FreeBSD Ports, and was required in order to get good colour calibration from the LiDE20. See below for more details.)

With the scanner plugged into the FreeBSD host I ran sane-find-scanner, which reported the vendor (Canon, 0x04A9) and the model (0x220D).

Unfortunately FreeBSD 4.8's drivers recognize the vendor but not the model. When the scanner was first plugged into the USB port, the kernel's generic USB driver attached to it as ugen0:

ugen0: Canon CanoScan, rev 1.10/1.00, addr 2

The next step was to patch /usr/src/sys/dev/usb/usbdevs and /usr/src/sys/dev/usb/uscanner.c to recognize the new model, and upgrade sane-backends.

Patching the kernel
With the kernel patched, plugging the scanner into a USB port results in the kernel detecting it as:

uscanner0: Canon CanoScan, rev 1.10/1.00, addr 2

and attaching it to /dev/uscanner0

(Note that model 0x220D applies to three CanoScan models -
N670U, N676U and LiDE 20. This patch will enable the use of all three types of scanners under FreeBSD 4.8.)

[Dec 2003 update: I expect (although I have not tried) that the same two patches will work under FreeBSD 4.9, since Canon model 0x220D is similarly unrecognized by the 4.9 kernel.]

Configuring plustek.conf

The SANE plustek drivers provide the necessary support for LiDE20 scanners, so I editted /usr/local/etc/sane.d/plustek.conf to include the lines:

[usb]  0x04A9 0x220D

and

device /dev/uscanner0

SANE's "scanimage -L" command now finds the LiDE20 scanner.

To test the scanner I installed xsane, an X11-based scanner frontend, using the binary package method

pkg_add -r xsane

Xsane just worked out of the box, and I was quickly scanning images!

Upgrading sane-backends and the Plustek driver

Under sane-backends-1.0.11 the LiDE20 colour calibrations were pretty poor. I found a
beta-quality patch for the plustek USB sane-backend (plustek-0.46-TEST1.tar.gz) from the Plustek driver development community. that made a significant difference to my scan quality.

First I used FreeBSD's "portupgrade" and upgraded sane-backends to version 1.0.12_3 (the latest official FreeBSD port at the time, and one that used plustek backend 0.45).

Building from a port means the source code for sane-backends is sucked over and built locally. After letting portupgrade do its stuff (it can fix/upgrade dependencies along the way) I did two steps:
(Rebuilding sane-backeneds from the ports collection also means the plustek backend can automatically detect the Lide20 scanner without it being explicitly listed by device/vendor code in plustek.conf)

Adjusted gamma

I found that the following adjustment should be made within XSANE to get somewhat decent scanned photos:

Conclusion

The CanoScane LiDE20 USB scanner can be made to work reasonably well under FreeBSD 4.8 with two small kernel patches, the sane-backends-
1.0.12_2 port and the plustek-0.46-TEST1.tar.gz plustek backend patch.