Re: Missing mustek backend maintainer, got patches?

From: Henning Meier-Geinitz (henningmg@gmx.de)
Date: Wed Feb 16 2000 - 15:07:39 PST

  • Next message: Karl Heinz Kremer: "Re: 'scanimage -T' ?"

    Hi,

    > I am not qualified to apply and test these patches (I don't have a
    > supported scanner), and would really like someone else to keep the
    > mustek backend up to date. What should I do?

    I don't know much about the other Mustek scanners and don't have any
    documentation so I'm not sure if I can help here.

    As a interim solution I have reworked my patch a bit to avoid possible
    problems with other (non 600 II N) scanners as I don't want to break
    anything. So the bug "cancel during scan freezes scanner" isn't fixed. The
    remaining patch fixes a timeout problem for 600 II Ns and adds (working)
    color support for 600 II Ns firmware 1.01 (including documentation updates).
    It doesn't touch anything for non parallel port scanners so this should be
    ok.

    If this patch is included I could test the Mustek backend on a different
    Mustek scanner (belonging to a friend, IIRC a mfs 6000 cz SCSI scanner).
    I am on vacation next week so I can't do this before 2000-02-28.

    Anybody out there using the Mustek backend who could test the patch for not
    breaking anything?

    Some more information about the Mustek 600 II N can be found here:
    http://hmg.home.pages.de/sane/

    Bye, Henning

    cd sane-devel-20000213;patch -p1 </path/to/patch

    ----------------------- snip ------------------------------
    diff -u -r sane-1.0.1/backend/mustek.c sane-1.0.1.patched/backend/mustek.c
    --- sane-1.0.1/backend/mustek.c Sat Apr 3 07:02:21 1999
    +++ sane-1.0.1.patched/backend/mustek.c Wed Jan 26 23:07:08 2000
    @@ -1452,7 +1452,8 @@
     
       if (s->fd >= 0)
         {
    - if (status == SANE_STATUS_CANCELLED)
    + if ((status == SANE_STATUS_CANCELLED) &&
    + !(s->hw->flags & MUSTEK_FLAG_PP))
             {
               DBG(4, "do_stop: waiting for scanner to become ready\n");
               dev_wait_ready (s);
    @@ -1509,7 +1510,9 @@
                   /* According to Andreas Czechanowski, the line-distance
                      values returned for the parallel-port scanners are
                      garbage, so we have to fix things up manually. Not
    - good. */
    + good.
    + This is true for firmware 2.00. PP scanners with firmware
    + 1.01 don't need this fix. */
                   if (peak_res == 600)
                     {
                       if (res < 51)
    @@ -1851,9 +1854,10 @@
         }
     }
     
    +/* Mustek 600 II N firmware 2.00 */
     static int
    -fix_line_distance_pp (Mustek_Scanner *s, int num_lines, int bpl,
    - u_int8_t *raw, u_int8_t *out)
    +fix_line_distance_pp_2 (Mustek_Scanner *s, int num_lines, int bpl,
    + u_int8_t *raw, u_int8_t *out)
     {
       u_int8_t *out_end, *out_ptr, *raw_end = raw + num_lines * bpl;
       int c, num_saved_lines, line;
    @@ -1925,6 +1929,85 @@
         }
     }
     
    +/* Mustek 600 II N firmware 1.01; the last lines returned are ...rgbrgbrgb
    + not e.g. ...rgbgbgbbbbb so some lines are missing. The color sequence
    + is different form the one of 2.0.
    + Henning Meier-Geinitz <hmg@gmx.de> */
    +static int
    +fix_line_distance_pp_1 (Mustek_Scanner *s, int num_lines, int bpl,
    + u_int8_t *raw, u_int8_t *out)
    +{
    + u_int8_t *out_end, *out_ptr, *raw_end = raw + num_lines * bpl;
    + int c, num_saved_lines, line;
    +
    + if (!s->ld.buf[0])
    + {
    + /* This buffer must be big enough to hold maximum line distance
    + times max_bpl bytes. The maximum line distance for 600 dpi
    + parallel-port scanners is 23. We use 32 to play it safe... */
    + DBG(2, "fix_line_distance_pp: allocating temp buffer of %d*%d bytes\n",
    + 32, bpl);
    + s->ld.buf[0] = malloc (32 * (long) bpl);
    + if (!s->ld.buf[0])
    + {
    + DBG(1, "fix_line_distance_pp: failed to malloc temporary buffer\n");
    + return 0;
    + }
    + }
    +
    + 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);
    +
    + while (1)
    + {
    + if (++s->ld.lmod3 >= 3)
    + s->ld.lmod3 = 0;
    +
    + c = s->ld.lmod3;
    + if (s->ld.index[c] < 0)
    + ++s->ld.index[c];
    + else
    + {
    + s->ld.quant[c] += s->ld.peak_res;
    + if (s->ld.quant[c] > s->ld.max_value)
    + {
    + s->ld.quant[c] -= s->ld.max_value;
    + line = s->ld.index[c]++ - s->ld.ld_line;
    + out_ptr = out + line * bpl + c;
    + out_end = out_ptr + bpl;
    + while (out_ptr != out_end)
    + {
    + *out_ptr = *raw++;
    + out_ptr += 3;
    + }
    +
    + if (raw >= raw_end)
    + {
    + 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[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[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[1];
    + /* return number of complete (r+g+b) lines */
    + return num_lines;
    + }
    + }
    + }
    + }
    +}
    +
    +
     static int
     fix_line_distance_se (Mustek_Scanner *s, int num_lines, int bpl,
                           u_int8_t *raw, u_int8_t *out)
    @@ -2481,7 +2564,17 @@
           else if (s->ld.max_value)
             {
               if (s->hw->flags & MUSTEK_FLAG_PP)
    - num_lines = fix_line_distance_pp (s, num_lines, bpl, data, extra);
    + {
    + if (s->hw->flags & MUSTEK_FLAG_LD_FIX)
    + /* If we need manual line distance values it's probably a
    + scanner with firmware 2.00 */
    + num_lines = fix_line_distance_pp_2 (s, num_lines, bpl, data,
    + extra);
    + else
    + /* Otherwise it's firmware 1.01 or some other */
    + num_lines = fix_line_distance_pp_1 (s, num_lines, bpl, data,
    + extra);
    + }
               else
                 fix_line_distance_normal (s, num_lines, bpl, data, extra);
             }
    diff -u -r sane-1.0.1/backend/mustek.desc sane-1.0.1.patched/backend/mustek.desc
    --- sane-1.0.1/backend/mustek.desc Fri Oct 30 07:23:33 1998
    +++ sane-1.0.1.patched/backend/mustek.desc Wed Jan 26 23:04:24 2000
    @@ -41,6 +41,8 @@
     :comment "1 pass; (f/w == ? ; scsi id C03 S10IDW)"
     :model "SE-12000SP"
     :comment "1 pass; (f/w == 1.01; scsi id C06 S12IDW)"
    -
    +:model "600 II N"
    +:comment "1 pass; (f/w = 1.01 & 2.00; non SCSI; id MFC-06000CZ)"
    +:url "http://hmg.home.pages.de/sane/"
     ; :comment and :url specifiers are optional after :mfg, :model, :desc,
     ; and at the top-level.
    diff -u -r sane-1.0.1/doc/sane-mustek.man sane-1.0.1.patched/doc/sane-mustek.man
    --- sane-1.0.1/doc/sane-mustek.man Fri Oct 30 07:22:19 1998
    +++ sane-1.0.1.patched/doc/sane-mustek.man Wed Jan 26 23:04:24 2000
    @@ -95,7 +95,8 @@
     controllers (notably the ncr810 controller under Linux). If color
     scans have horizontal stripes and/or the colors are off, then it's
     likely that your controller suffers from this problem. Turning on
    -this option usually fixes the problem.
    +this option usually fixes the problem. The parallel port scanner 600
    +II N is a special case, see section PARALLEL PORT SCANNERS below.
     
     Option
     .B lineart-fix
    @@ -196,6 +197,13 @@
     brightness. However, the first image scanned after such a shutdown may
     have stripes and appear to be over-exposed. When this happens, just
     take another scan, and the image will be fine.
    +.PP
    +If your images have horizontal stripes in color mode, check option
    +linedistance-fix (see above). Apply this option for a scanner with
    +firmware version 2.00 and disable it for version 1.01. Please contact
    +the mailing list
    +.IR sane\-devel@mostang.com
    +if you have a 600 II N with a different firmware version.
     .SH FILES
     .TP
     .I @CONFIGDIR@/mustek.conf

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



    This archive was generated by hypermail 2b29 : Wed Feb 16 2000 - 23:38:40 PST