Mustek scanner: success!

Norbert Mueller (mueller@uni-trier.de)
Thu, 26 Feb 1998 15:07:21 +0100 (MET)

For now almost half a year I own a Mustek scanner:

model name: 600 II SP SCANMAGIC

A check with "export SANE_DEBUG_MUSTEK=127; /usr/local/bin/scanimage -h"
gives the following result:

firmware revision 2.03
Mustek scanner model MFC-06000CZ (flatbed scanner), 1-pass

It is attachted to my computer via an old scsi card (Always IN 2000).

I used to have the usual problems (lost lines, colored stripes) that have
often been mentionend in this mailing list. In addition there were a few
unusual problems that twice almost lead to a almost fatal hardware damage
of the scanner. But after defining MUSTEK_FLAG_USE_EIGHTS for my model,
I was able at least to scan lineart or grayscale with (fixed) resolution of
600dpi.

Yesterday, I tested kernel 2.1.88 instead of 2.0.32, and suddenly, many
things changed!

-> The scanner started reacting to resolution changes (although a small patch
was neccessary to get full functionality).

-> From then on the line distance correction was ok.

-> The colored stripes are gone.

-> With additionally setting OPT_BACKTRACK to SANE_TRUE, even the lost lines
were gone.

Now my scanner is fully functional (as far as I can say)!

I would recommend three things to anyone having similar problems:

1) Try a newer kernel of the 2.1.xx-series,
the generic scsi driver (sg.c) is different

2) If you suffer from lost lines, try setting OPT_BACKTRACK to SANE_TRUE.
This worked for me, although the scanning now is slower.
Just an idea: Does anybody know whether there is a possibility to change
the fixed sized buffer in sg.c to a circular list of e.g. 20 buffers of
size such that the scanner may write to the list while at the same time
the application reads from the list? As usually most CPU's are capable to
read the data faster than the scanner can deliver, the circular list would
never be full and backtracking would no longer happen.

3) If you have the same model as I do, try MUSTEK_FLAG_USE_EIGHTS:
Using the standard SANE (regardless which one, up to 0.71), my scanner
went wild when scanning more than a few inches. This seems to be an overflow
in the computation of the number of lines, as if twelve bit(?) computation
was used internally in the scanner. So, sometimes, too few lines were scanned.
But sometimes, he tried to scan several 10000 lines (twice leading
to almost fatal hardware problems)...

Below you find the patches I made to the mustek backend.

-------------------------------------------------------------------------------
Norbert Mueller
Tel: ..49-(0)651-201-2845 http://www.informatik.uni-trier.de/~mueller/
Fax: ..49-(0)651-201-3805 email:mueller@uni-trier.de
-------------------------------------------------------------------------------
LG Stochastische Modellierung und Rechnernetze * FB IV - Abteilung Informatik
Universitaet Trier * D-54286 Trier (Germany)
-------------------------------------------------------------------------------

--- mustek.c-orig Thu Feb 26 14:09:15 1998
+++ mustek.c Thu Feb 26 14:46:42 1998
@@ -215,7 +215,8 @@
MUSTEK_SCSI_GET_IMAGE_STATUS, 0x00, 0x00, 0x00, 0x06, 0x00
};

-#define STORE16(p,v) \
+/* a small typo, but due to its use fortunately without consequences: */
+#define STORE16(cp,v) \
do { \
int value = (v); \
\
@@ -593,6 +594,8 @@
dev->x_range.max = SANE_FIX (220.0); /* measured */
dev->y_range.max = SANE_FIX (292.0); /* measured */
dev->dpi_range.max = SANE_FIX (600);
+/******* vital for 600 II SP SCANMAGIC: ****************************/
+ dev->flags |= MUSTEK_FLAG_USE_EIGHTS;
}
/* No documentation for these, but they do exist. Duh... */
else if (strncmp (model_name, "MFS-12000SP", 11) == 0)
@@ -852,7 +855,8 @@
mode_select (Mustek_Scanner *s, int color_code)
{
int grain_code, speed_code;
- u_int8_t mode[19], *cp;
+/**** three small changes to get working resolution changes: ****/
+ u_int8_t mode[20], *cp;

/* the scanners use a funky code for the grain size, let's compute it: */
grain_code = s->val[OPT_GRAIN_SIZE].w;
@@ -878,7 +882,8 @@
/* set command length and resolution code: */
if (s->hw->flags & MUSTEK_FLAG_SINGLE_PASS)
{
- mode[4] = 0x0d;
+ mode[4] = 0x0e;
+ mode[7] = 0;
cp = mode + 17;
STORE16 (cp, s->resolution_code);
}
@@ -1561,7 +1566,8 @@
s->opt[OPT_BACKTRACK].title = SANE_TITLE_BACKTRACK;
s->opt[OPT_BACKTRACK].desc = SANE_DESC_BACKTRACK;
s->opt[OPT_BACKTRACK].type = SANE_TYPE_BOOL;
- s->val[OPT_BACKTRACK].w = SANE_FALSE;
+/**** this helped me with the lost lines problem: ****/
+ s->val[OPT_BACKTRACK].w = SANE_TRUE;

/* preview */
s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW;

--
Source code, list archive, and docs: http://www.mostang.com/sane/
To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com