Mustek-0.68: 600 II N patch

Andreas Czechanowski (andreas@inspc44c.ins.uni-stuttgart.de)
Tue, 23 Dec 1997 20:30:09 +0100 (MET)

Hi !

Here is a patch for the 600 II N part of the SANE backend.
It fixes :
- gamma correction is now possible
- lineart mode now produces more than an all-white image

Below is some general information about configuring SANE for use
with the Mustek Paragon 600 II N.

This scanner is not accessed as SCSI device, and does not have a
special device file in /dev assigned to it. The fontends access the
I/O ports directly. This can either be done through /dev/port
(may be too slow for some computers), or by running the frontend
programs (e.g. scanimage, xscanimage) as root or SUID root.

The AB 306 N interface supplied with the scanner can be configured to
use one of eight I/O address ranges. Each range includes 3 consecutive
I/O addresses (base+0 to base+2). Choose one of the addresses shown
below, depending on your hardware (I hope you know what addresses are
already in use !) :

0x26b
0x2ab
0x2eb
0x22b
0x32b
0x36b
0x3ab
0x3eb

Instead of "/dev/scanner" or the like, make an entry with the address
(in hexadecimal notation as shown above) on a line by itself into
the configuration file mustek.conf . The 600 II N also requires

option line_distance_fix

for proper scanning of color images. You may, before starting one
of the frontends, enter

export SANE_DEBUG_MUSTEK=2

(or something equivalent for csh), so that you get some debugging
information on stderr. I would like to know what firmware revisions
are out there (this is reported during inquiry by the scanner).

Now, here's the patch:

*** ./backend/mustek.c.orig Wed Dec 3 07:49:10 1997
--- ./backend/mustek.c Sun Dec 14 16:11:24 1997
***************
*** 895,900 ****
--- 895,928 ----
int i, j, table = 0, len, num_channels = 1;
u_int8_t gamma[3*256+10], val, *cp;

+ /* sigh! - the 600 II N needs a (dummy) table download even for
+ lineart and halftone mode, else it produces a completely
+ white image. Thank Mustek for their buggy firmware ! */
+ if ((s->hw->flags & MUSTEK_FLAG_PP)
+ && !(s->mode & MUSTEK_MODE_MULTIBIT))
+ {
+ memset (gamma, 0, sizeof (gamma));
+ gamma[0] = MUSTEK_SCSI_LOOKUP_TABLE;
+ #if 1
+ gamma[2] = 0x0; /* indicate any preloaded gamma table */
+ DBG(3, "gamma_correction: sending dummy gamma table select\n");
+ return dev_cmd (s, gamma, 6, 0, 0);
+ #else
+ /* try to send a custom gamma table, because brightness and
+ contrast adjustment don't change anything in the single-bit-modes
+ with the 600 II N. - does not work either :-( */
+ gamma[2] = 0x27; /* indicate any preloaded gamma table */
+ cp = gamma + 10;
+ for (j = 0; j < num_channels; ++j, ++table)
+ for (i = 0; i < 256; ++i)
+ {
+ *cp++ = (i > (128 + s->val[OPT_BRIGHTNESS].w) ? 255 : 0);
+ }
+ DBG(3, "gamma_correction: sending gamma table of %d bytes\n", len);
+ return dev_cmd (s, gamma, 10 + 3*256, 0, 0);
+ #endif
+ }
+
if (!s->val[OPT_CUSTOM_GAMMA].w
|| !(s->mode & MUSTEK_MODE_MULTIBIT))
return SANE_STATUS_GOOD;
*** ./sanei/sanei_ab306.c.orig Wed Nov 26 07:15:29 1997
--- ./sanei/sanei_ab306.c Sat Dec 13 14:57:50 1997
***************
*** 374,380 ****
break;
}

! status = ab306_write (p, src, cdb_size);
if (status != SANE_STATUS_GOOD)
return status;

--- 374,380 ----
break;
}

! status = ab306_write (p, src, 6 /* cdb_size */);
if (status != SANE_STATUS_GOOD)
return status;

---

Regards,

Andreas.

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