line-distance correction and mustek 600 II N

Henning Meier-Geinitz (henningmg@gmx.de)
Tue, 14 Apr 1998 00:01:46 +0200

I looked into the line-distance correction code for the mustek 600 II
N in mustek.c. Some details are explained in an earlier article. With
the patch color works somewhat, but there are missing lines at the
end. The problem is: The scanner sends data one line after the other
in the following manner (Example):

R-R-R-R-B-B-R-B-G-R-B-G ... R-G-B-R-G-B

If n is the distance between two CCD lines, sane loses 3*n data lines
at the end of the scan. The line-distance code in sane asumes the
following:

R-R-R-R-B-B-R-B-G-R-B-G ... R-G-B-G-B-G-B-G-G-G

If I understood correctly, mustek.c would have to scan n more lines
then specified to get the full sized image. I don't know most
internals of mustek.c so I can't do this.

By the way: My 600 II N doesn't need the line-distance-fix, the
line-distance values which it sends are correct. I don't know, if this
applies for all 600 II N.

The following patch corrects the color scanning problem with the 600
II N as far as I can do it. It will (hopefully) fix the problem with
not ignoring empty lines in mustek.conf. And I put a usleep in
sanei_ab306.c. This will allow to run sane without turning on
debugging (which was the only way to get sane with the 600 II N to
work for me). I don't know, why it works, but it does.

diff -ru sane-0.72.orig/backend/mustek.c sane-0.72/backend/mustek.c
--- sane-0.72.orig/backend/mustek.c Tue Mar 3 04:02:43 1998
+++ sane-0.72/backend/mustek.c Mon Apr 13 21:25:53 1998
@@ -1394,7 +1394,7 @@
}
}

- num_saved_lines = s->ld.index[0] - s->ld.index[2];
+ num_saved_lines = s->ld.index[0] - s->ld.index[1];
if (num_saved_lines > 0)
/* restore the previously saved lines: */
memcpy (out, s->ld.buf[0], num_saved_lines * bpl);
@@ -1404,10 +1404,10 @@
if (++s->ld.lmod3 >= 3)
s->ld.lmod3 = 0;

- c = color_seq[s->ld.lmod3];
+ c = s->ld.lmod3;
if (s->ld.index[c] < 0)
++s->ld.index[c];
- else if (s->ld.index[c] < s->params.lines)
+ else /*if (s->ld.index[c] < s->params.lines)*/
{
s->ld.c[c].Qk += s->ld.peak_res;
if (s->ld.c[c].Qk > s->ld.max_value)
@@ -1421,17 +1421,17 @@
DBG (1, "fix_line_distance_pp: lmod3=%d, index=(%d,%d,%d)\n",
s->ld.lmod3,
s->ld.index[0], s->ld.index[1], s->ld.index[2]);
- num_lines = s->ld.index[2] - s->ld.ld_line;
+ num_lines = s->ld.index[1] - s->ld.ld_line;

/* copy away the lines with at least one missing
color component, so that we can interleave them
with new scan data on the next call */
- num_saved_lines = s->ld.index[0] - s->ld.index[2];
+ num_saved_lines = s->ld.index[0] - s->ld.index[1];
memcpy (s->ld.buf[0], out + num_lines * bpl,
num_saved_lines * bpl);

/* notice the number of lines we processed */
- s->ld.ld_line = s->ld.index[2];
+ s->ld.ld_line = s->ld.index[1];
/* return number of complete (r+g+b) lines */
return num_lines;
}
@@ -2048,11 +2048,11 @@
continue;

len = strlen (cp);
- if (cp[len - 1] == '\n')
- cp[--len] = '\0';
-
if (!len)
continue; /* ignore empty lines */
+
+ if (cp[len - 1] == '\n')
+ cp[--len] = '\0';

if (strncmp (cp, "option", 6) == 0 && isspace (cp[6]))
{
diff -ru sane-0.72.orig/sanei/sanei_ab306.c sane-0.72/sanei/sanei_ab306.c
--- sane-0.72.orig/sanei/sanei_ab306.c Tue Mar 3 03:13:25 1998
+++ sane-0.72/sanei/sanei_ab306.c Mon Apr 13 15:58:02 1998
@@ -196,6 +196,8 @@
ab306_inb (p, base + 1));
while ((ab306_inb (p, base + 1) & 0x20) == 0);

+ usleep(100000);
+
DBG(4, "ab306_write: writing data\n");
for (i = 0; i < len; ++i)
{

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