scx-xx: Samsung SCX-4200 Scanner GPL driver

NOTE: This device is currently supported by xerox_mfp SANE driver; please use it instead. For list of compatible devices see SANE support of Samsung devices page.

This page is a result of my attempt to create open driver for Samsung SCX-4200 MFP Scanner. No information from Samsung was available, this driver is based only on usb traffic created by Samsung's Linux binary driver for this scanner.

LEGAL NOTE:
THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!

LICENSE:
This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


Introduction
SCX-4200 is a laser MFP with CIS flatbed scanner. Samsung offers a Linux driver for both the printer part as well as scanner part, but only in binary form. It is possible that more devices might use the same protocol - these ones seem to be supported by Samsung's driver (based on smfp.conf file):

However, this needs to be checked first.

Current status: preAlpha - developers only
So far, the only device tested is SCX-4200, which works fine.

NOTE: There is no user-friendly interface so far (only a trivial command line).

The output is written to stdout as raw data without any headers; actual image resoultion is written to stderr. You can either prepend PNM headers, or open it with GIMP and specify correct parameters there.

What you need to test it
SCX-4200 is USB-only device, and it is accessed using its printer interface - that is, /dev/usb/lp0 (this is hardcoded, so if you have it somewhere else, you have to change it first). You need kernel support for USB printers (module usblp on 2.6.x kernels) - should be included in any recent distro you can find these days. I don't know anything about connecting Parallel port scanners - but I would expect they use their printer interface directly as well.

Download

Protocol description
All commands sent to the scanner are 4 bytes long, except for scanning configuration which is longer. Most responses from scanner are 32 bytes long, except for DeviceInfo which is longer (and raw data, which are not considered as responses); however actual response length is stored in the response so we don't rely on this.

Commands identified so far:


Responses identified so far:

Currently, responses are identified only by bytes 2 and 4, its length (minus 3) is in byte 3. As you can see above, there can be some flags encoded further in the message...

Data ... responses: bytes 5-8 contain length of data that are ready to be sent to host, bytes 9-10 contain pixel width of this chunk, bytes 11-12 then pixel height of this chunk. Last bit of 4th byte indicates last chunk of data to be transferred.

In the Device Info response, plaintext "SAMSUNG ORION" can be seen. In addition, value 000027d8 is about 215.9mm for 1200dpi and value 000036d8 is about 297.18mm for 1200dpi - probably physical scannable area. Other fields are not known yet (and those that are are not used either).


Format of scan data:
Image data are transferred without any compression or special encoding, row-by-row:

There are 16 more bytes appended to the end of each chunk; we just discard them.


Sample session

Issues

  1. Image size
    It is not clear how big the image will be before we fetch all its chunks.

    Image width is clear from first received chunk, however we don't know full height. The problem is that you will get different height for exactly the same scanning area, but different color mode. An example:

    (The width can be different for BW modes, but we know that with first chunk.)

    This needs to be solved; I'm afraid that Samsung's binary driver does save raw data to /tmp first and then creates another image in /tmp with headers. Also Sane wants to know exact pixel size before it reads actual image data.

    (A4 in color means about 100MB of raw data that we need to store)


Contact
vlado {at} sane {dot} ksp {dot} sk