The original document by Bertrik Sikken may be found there.

Hewlett-Packard Scanjet HP5400c under Linux info

(Last updated Saturday, January 11, 2003: added pointer to log file)

The HP5400/HP5470 types of scanner are color USB scanners with a resolution of 2400 dpi. They are not supported under Linux yet. The info on this page is aimed at making them work under Linux and similar operating systems. Scanners can be supported under Linux using the Sane package.

Transfer protocol

The transfer protocol allows reading/writing of command data by means of USB control transfers and reading/writing of bulk data (reading image data and writing gamma/calibration data) by means of USB bulk transfers.

Scanner commands

Command and response data is exchanged using USB control transfers. Each read or write takes several of them. The fields inside the USB control transfer are used as follows:

Reading command

Reading command date is done by sending a USB control transfer as shown above. The response to the control transfer contains the requested command response. Next 2 bytes are read with command 0xc500, which usually results in a response that contains the command of the actual read (although the low byte is 0x00).

Writing command

Writing command date is done by sending a USB control transfer containing the command data. Then, just like with reading a command, 2 bytes are read with command 0xc500.

Reading/writing bulk data

Reading and writing of bulk data is somewhat similar to how it is done on the HP3300c. Three pseudo-parallel port registers are written to prepare the bulk transfer:

Scanner commands overview

Low-level commands

00828Data transfer length
00831Data transfer register
00871Data direction register

High-level commands

0000W?Written with 0x01
01xxR1Returns 0x00
12xxR50Scanner version string and info
15xxW2DPI or LPI?
1bxxW1Written with either 0x00 or 0x40
20xxR2During replug: returned 00 00
23xxW10During replug: written with 03 00 00 00 00 3f 04 00 00 c3
25xxW32Scan settings: DPI, scan position, lighting?
2axxW3Written with 02 00 00
c0xxW4During replug: written with 02 03 03 3c
c5xxR2Previous command issued
d6xxW1Written with 0x04
f0xxRxRead UI texts
f1xxWxWrite UI texts
f2xxW1UI text pointer

12xx: scanner info

Example of data read using this command:
00 53 69 6c 69 74 65 6b 49 42 6c 69 7a 64 20 43	\SilitekIBlizd C
33 20 53 63 61 6e 6e 65 72 56 30 2e 38 34 09 60	3 ScannerV0.84
09 60 4f b0 6d b0 00 00 00 00 00 00 00 00 00 0a 	
00 64 	
0x0960=2400 in bytes 0x1e/0x1f and 0x20/0x21 show max resolution in x and y?
0x4fb0=20400 and 0x6db0=28080 is height and width in units of 1/2400 inch?

25xx: scan settings

An example of the data written with this command from an USB log
08 00 96 00 96 00 00 00 00 09 f6 0d b6 00 80 00 	
40 08 e8 00 00 64 00 64 00 64 00 00 00 00 00 00 	
0x0096=150 in bytes 0x01/0x02 and bytes 0x03/0x04 is probably the resolution (vertical and horizontal)
0x09f6=2550 and 0x0db6=3510 look like width and height respectively, in units of 1/300 inch. This corresponds to 21.59cm and 29.72cm.
0x0064=100 in bytes 0x14/0x15 and further could be something related to each color component (R,G,B), lighting or contrast perhaps?