sane-project-website/old-archive/1997-02/0052.html

394 wiersze
13 KiB
HTML

<!-- received="Thu Apr 17 11:58:33 1997 MST" -->
<!-- sent="Thu, 17 Apr 1997 11:41:45 -0700" -->
<!-- name="David Mosberger-Tang" -->
<!-- email="davidm@azstarnet.com" -->
<!-- subject="mustek 3-pass backend now working!" -->
<!-- id="199704171841.LAA23311@panda.mosberger" -->
<!-- inreplyto="" -->
<title>sane-devel: mustek 3-pass backend now working!</title>
<h1>mustek 3-pass backend now working!</h1>
<b>David Mosberger-Tang</b> (<a href="mailto:davidm@azstarnet.com"><i>davidm@azstarnet.com</i></a>)<br>
<i>Thu, 17 Apr 1997 11:41:45 -0700</i>
<p>
<ul>
<li> <b>Messages sorted by:</b> <a href="date.html#52">[ date ]</a><a href="index.html#52">[ thread ]</a><a href="subject.html#52">[ subject ]</a><a href="author.html#52">[ author ]</a>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0053.html">Mathias Weigt: "Re: mustek 3-pass backend now working!"</a>
<li> <b>Previous message:</b> <a href="0051.html">David Mosberger-Tang: "Re: MFS-12000CX"</a>
<!-- nextthread="start" -->
<li> <b>Next in thread:</b> <a href="0054.html">David Mosberger-Tang: "Re: mustek 3-pass backend now working!"</a>
<li> <b>Maybe reply:</b> <a href="0054.html">David Mosberger-Tang: "Re: mustek 3-pass backend now working!"</a>
<!-- reply="end" -->
</ul>
<!-- body="start" -->
OK, thanks to the patience of Mathias Weigt, 3-pass scanning with the<br>
Mustek backend now finally seems to work. Below is a patch relative<br>
to sane-0.53 that should get things working (until sane-0.54 comes<br>
out).<br>
<p>
If you have a 3-pass Mustek scanner, could you please try this patch<br>
and let me know if/how it works? If it works, could you send me the<br>
following info so I can update the README file?<br>
<p>
- Exact scanner type: label on front of scanner &amp; the SCSI id string &amp; firmware version<br>
<p>
- the SCSI card you're using<br>
<p>
The SCSI id and firmware rev can be obtained like this:<br>
<p>
SANE_DEBUG_MUSTEK=128 scan -h -d mustek &gt;/dev/null<br>
<p>
Enjoy,<br>
<p>
--david<br>
<pre>
--
--- sane-0.53/backend/mustek.c Fri Apr 11 22:23:38 1997
+++ sane-0.54/backend/mustek.c Thu Apr 17 09:03:49 1997
@@ -264,8 +264,9 @@
if (strncmp (model_name, "MFS-12000CX", 11) == 0)
{
dev-&gt;x_range.max = SANE_FIX (8.5 * MM_PER_INCH);
- dev-&gt;y_range.max = SANE_FIX (14.0 * MM_PER_INCH); /* is this correct? */
+ dev-&gt;y_range.max = SANE_FIX (14.0 * MM_PER_INCH);
dev-&gt;dpi_range.max = SANE_FIX (1200);
+ dev-&gt;flags |= MUSTEK_FLAG_USE_EIGHTS;
}
else if (strncmp (model_name, "MFS-06000CX", 11) == 0)
{
@@ -361,8 +362,11 @@
if (result[63] &amp; (1 &lt;&lt; 6))
dev-&gt;flags |= MUSTEK_FLAG_TA;
- DBG(3, "attach: found Mustek scanner model %s (%s)\n",
- dev-&gt;sane.model, dev-&gt;sane.type);
+ DBG(3, "attach: found Mustek scanner model %s (%s), %s%s%s\n",
+ dev-&gt;sane.model, dev-&gt;sane.type,
+ (dev-&gt;flags &amp; MUSTEK_FLAG_SINGLE_PASS) ? "1-pass" : "3-pass",
+ (dev-&gt;flags &amp; MUSTEK_FLAG_ADF) ? ", ADF" : "",
+ (dev-&gt;flags &amp; MUSTEK_FLAG_TA) ? ", TA" : "");
++num_devices;
dev-&gt;next = first_dev;
@@ -552,15 +556,17 @@
if (s-&gt;hw-&gt;flags &amp; MUSTEK_FLAG_USE_EIGHTS)
{
+ double eights_per_mm = 8 / MM_PER_INCH;
+
/*
* The MSF-06000CZ seems to lock-up if the pixel-unit is used.
* Using 1/8" works.
*/
*cp++ = ((s-&gt;mode &amp; MUSTEK_MODE_HALFTONE) ? 0x01 : 0x00);
- STORE16(cp, SANE_UNFIX(s-&gt;val[OPT_TL_X].w) * 8 / MM_PER_INCH + 0.5);
- STORE16(cp, SANE_UNFIX(s-&gt;val[OPT_TL_Y].w) * 8 / MM_PER_INCH + 0.5);
- STORE16(cp, SANE_UNFIX(s-&gt;val[OPT_BR_X].w) * 8 / MM_PER_INCH + 0.5);
- STORE16(cp, SANE_UNFIX(s-&gt;val[OPT_BR_Y].w) * 8 / MM_PER_INCH + 0.5);
+ STORE16(cp, SANE_UNFIX(s-&gt;val[OPT_TL_X].w) * eights_per_mm + 0.5);
+ STORE16(cp, SANE_UNFIX(s-&gt;val[OPT_TL_Y].w) * eights_per_mm + 0.5);
+ STORE16(cp, SANE_UNFIX(s-&gt;val[OPT_BR_X].w) * eights_per_mm + 0.5);
+ STORE16(cp, SANE_UNFIX(s-&gt;val[OPT_BR_Y].w) * eights_per_mm + 0.5);
}
else
{
@@ -690,7 +696,7 @@
if (s-&gt;hw-&gt;flags &amp; MUSTEK_FLAG_SINGLE_PASS)
start[4] |= 0x20;
else
- start[4] |= ((s-&gt;pass &lt;&lt; 3) + 1);
+ start[4] |= ((s-&gt;pass + 1) &lt;&lt; 3);
}
/* or in single/multi bit: */
start[4] |= (s-&gt;mode &amp; MUSTEK_MODE_MULTIBIT) ? (1 &lt;&lt; 6) : 0;
@@ -1315,55 +1321,53 @@
DBG(1, "reader_process: read_data failed with status=%d\n", status);
return 3;
}
+ DBG(3, "reader_process: read %d lines", lines_per_buffer);
/* convert to pixel-interleaved format: */
- if (s-&gt;mode &amp; MUSTEK_MODE_COLOR)
+ if ((s-&gt;mode &amp; MUSTEK_MODE_COLOR)
+ &amp;&amp; (s-&gt;hw-&gt;flags &amp; MUSTEK_FLAG_SINGLE_PASS))
{
- if (s-&gt;hw-&gt;flags &amp; MUSTEK_FLAG_SINGLE_PASS)
- {
- SANE_Byte *src;
+ SANE_Byte *src;
- if (s-&gt;hw-&gt;flags &amp; MUSTEK_FLAG_LD_MFS)
- fix_line_distance_mfs (s, lines_per_buffer, bpl, data, extra);
- else if (s-&gt;ld.max_value)
- /* need to correct for distance between r/g/b sensors: */
- fix_line_distance_normal (s, lines_per_buffer, bpl, data,
- extra);
- else
- memcpy (extra, data, lines_per_buffer * bpl);
+ if (s-&gt;hw-&gt;flags &amp; MUSTEK_FLAG_LD_MFS)
+ fix_line_distance_mfs (s, lines_per_buffer, bpl, data, extra);
+ else if (s-&gt;ld.max_value)
+ /* need to correct for distance between r/g/b sensors: */
+ fix_line_distance_normal (s, lines_per_buffer, bpl, data, extra);
+ else
+ memcpy (extra, data, lines_per_buffer * bpl);
- src = extra;
- if (s-&gt;mode &amp; MUSTEK_MODE_MULTIBIT)
+ src = extra;
+ if (s-&gt;mode &amp; MUSTEK_MODE_MULTIBIT)
+ {
+ /* each r/g/b sample is 8 bits in line-interleaved format */
+ for (y = 0; y &lt; lines_per_buffer; ++y)
{
- /* each r/g/b sample is 8 bits in line-interleaved format */
- for (y = 0; y &lt; lines_per_buffer; ++y)
+ for (x = 0; x &lt; bpl / 3; ++x)
{
- for (x = 0; x &lt; bpl / 3; ++x)
- {
- fputc (src[0 * bpl / 3 + x], fp);
- fputc (src[1 * bpl / 3 + x], fp);
- fputc (src[2 * bpl / 3 + x], fp);
- }
- src += bpl;
+ fputc (src[0 * bpl / 3 + x], fp);
+ fputc (src[1 * bpl / 3 + x], fp);
+ fputc (src[2 * bpl / 3 + x], fp);
}
+ src += bpl;
}
- else
+ }
+ else
+ {
+ /* each r/g/b/ sample is 1 bit in line-interleaved format */
+# define EXPAND(b, v) (((v) &amp; (1 &lt;&lt; (bit))) ? 0xff : 0x00)
+ for (y = 0; y &lt; lines_per_buffer; ++y)
{
- /* each r/g/b/ sample is 1 bit in line-interleaved format */
-# define EXPAND(b, v) (((v) &amp; (1 &lt;&lt; (bit))) ? 0xff : 0x00)
- for (y = 0; y &lt; lines_per_buffer; ++y)
+ for (x = 0; x &lt; bpl / 3; ++x)
{
- for (x = 0; x &lt; bpl / 3; ++x)
+ for (bit = 7; bit &gt;= 0; --bit)
{
- for (bit = 7; bit &gt;= 0; --bit)
- {
- fputc (EXPAND (bit, src[0 * bpl / 3 + x]), fp);
- fputc (EXPAND (bit, src[1 * bpl / 3 + x]), fp);
- fputc (EXPAND (bit, src[2 * bpl / 3 + x]), fp);
- }
+ fputc (EXPAND (bit, src[0 * bpl / 3 + x]), fp);
+ fputc (EXPAND (bit, src[1 * bpl / 3 + x]), fp);
+ fputc (EXPAND (bit, src[2 * bpl / 3 + x]), fp);
}
- src += bpl;
}
+ src += bpl;
}
}
}
@@ -1757,11 +1761,11 @@
sane_get_parameters (SANE_Handle handle, SANE_Parameters *params)
{
Mustek_Scanner *s = handle;
+ const char *mode;
if (!s-&gt;scanning)
{
double width, height, dpi;
- const char *mode;
memset (&amp;s-&gt;params, 0, sizeof (s-&gt;params));
@@ -1778,53 +1782,50 @@
s-&gt;params.pixels_per_line = width * dots_per_mm;
s-&gt;params.lines = height * dots_per_mm;
}
+ }
+ mode = s-&gt;val[OPT_MODE].s;
+ if (strcmp (mode, "Lineart") == 0 || strcmp (mode, "Halftone") == 0)
+ {
+ s-&gt;params.format = SANE_FRAME_GRAY;
+ s-&gt;params.bytes_per_line = (s-&gt;params.pixels_per_line + 7) / 8;
+ s-&gt;params.depth = 1;
+ }
+ else if (strcmp (mode, "Gray") == 0)
+ {
+ s-&gt;params.format = SANE_FRAME_GRAY;
+ s-&gt;params.bytes_per_line = s-&gt;params.pixels_per_line;
+ s-&gt;params.depth = 8;
+ }
+ else
+ {
+ /* it's one of the color modes... */
- mode = s-&gt;val[OPT_MODE].s;
- if (strcmp (mode, "Lineart") == 0 || strcmp (mode, "Halftone") == 0)
- {
- s-&gt;params.format = SANE_FRAME_GRAY;
- s-&gt;params.bytes_per_line = (s-&gt;params.pixels_per_line + 7) / 8;
- s-&gt;params.depth = 1;
- }
- else if (strcmp (mode, "Gray") == 0)
+ if (s-&gt;hw-&gt;flags &amp; MUSTEK_FLAG_SINGLE_PASS)
{
- s-&gt;params.format = SANE_FRAME_GRAY;
- s-&gt;params.bytes_per_line = s-&gt;params.pixels_per_line;
+ /* all color modes are treated the same since lineart and
+ halftoning with 1 bit color pixels still results in 3
+ bytes/pixel. */
+ s-&gt;params.format = SANE_FRAME_RGB;
+ s-&gt;params.bytes_per_line = 3 * s-&gt;params.pixels_per_line;
s-&gt;params.depth = 8;
}
else
{
- /* all color modes are treated the same since lineart with 1
- bit color pixels still results in 3 bytes/pixel. */
- if (s-&gt;hw-&gt;flags &amp; MUSTEK_FLAG_SINGLE_PASS)
+ s-&gt;params.format = SANE_FRAME_RED + s-&gt;pass;
+ if (strcmp (mode, "Color") == 0)
{
- s-&gt;params.format = SANE_FRAME_RGB;
- s-&gt;params.bytes_per_line = 3 * s-&gt;params.pixels_per_line;
+ s-&gt;params.bytes_per_line = s-&gt;params.pixels_per_line;
s-&gt;params.depth = 8;
}
else
{
- switch (s-&gt;pass)
- {
- case 0:
- s-&gt;params.format = SANE_FRAME_RED;
- break;
- case 1:
- s-&gt;params.format = SANE_FRAME_GREEN;
- break;
- case 2:
- s-&gt;params.format = SANE_FRAME_BLUE;
- break;
- default:
- break;
- }
- s-&gt;params.bytes_per_line = s-&gt;params.pixels_per_line;
- s-&gt;params.depth = 8;
+ s-&gt;params.bytes_per_line = (s-&gt;params.pixels_per_line + 7) / 8;
+ s-&gt;params.depth = 1;
}
}
- s-&gt;params.last_frame = (s-&gt;params.format != SANE_FRAME_RED
- &amp;&amp; s-&gt;params.format != SANE_FRAME_GREEN);
}
+ s-&gt;params.last_frame = (s-&gt;params.format != SANE_FRAME_RED
+ &amp;&amp; s-&gt;params.format != SANE_FRAME_GREEN);
if (params)
*params = s-&gt;params;
return SANE_STATUS_GOOD;
@@ -1843,18 +1844,9 @@
if (status != SANE_STATUS_GOOD)
return status;
- if (s-&gt;fd &gt;= 0)
- {
- /* this is the second or third pass... */
- status = wait_ready (s-&gt;fd);
- if (status != SANE_STATUS_GOOD)
- {
- DBG(1, "open: wait_ready() failed: %s\n", sane_strstatus (status));
- goto stop_scanner_and_return;
- }
- }
- else
+ if (s-&gt;fd &lt; 0)
{
+ /* this is the first (and maybe only) pass... */
const char *mode;
/* translate options into s-&gt;mode for convenient access: */
@@ -1883,34 +1875,34 @@
s-&gt;hw-&gt;sane.name, sane_strstatus (status));
return status;
}
+ }
- status = wait_ready (s-&gt;fd);
- if (status != SANE_STATUS_GOOD)
- {
- DBG(1, "open: wait_ready() failed: %s\n", sane_strstatus (status));
- goto stop_scanner_and_return;
- }
+ status = wait_ready (s-&gt;fd);
+ if (status != SANE_STATUS_GOOD)
+ {
+ DBG(1, "open: wait_ready() failed: %s\n", sane_strstatus (status));
+ goto stop_scanner_and_return;
+ }
- status = scan_area_and_windows (s);
- if (status != SANE_STATUS_GOOD)
- {
- DBG(1, "open: set scan area command failed: %s\n",
- sane_strstatus (status));
- goto stop_scanner_and_return;
- }
+ status = scan_area_and_windows (s);
+ if (status != SANE_STATUS_GOOD)
+ {
+ DBG(1, "open: set scan area command failed: %s\n",
+ sane_strstatus (status));
+ goto stop_scanner_and_return;
+ }
- status = request_sense (s);
- if (status != SANE_STATUS_GOOD)
- goto stop_scanner_and_return;
+ status = request_sense (s);
+ if (status != SANE_STATUS_GOOD)
+ goto stop_scanner_and_return;
- status = backtrack_and_adf (s);
- if (status != SANE_STATUS_GOOD)
- goto stop_scanner_and_return;
+ status = backtrack_and_adf (s);
+ if (status != SANE_STATUS_GOOD)
+ goto stop_scanner_and_return;
- status = request_sense (s);
- if (status != SANE_STATUS_GOOD)
- goto stop_scanner_and_return;
- }
+ status = request_sense (s);
+ if (status != SANE_STATUS_GOOD)
+ goto stop_scanner_and_return;
if (s-&gt;one_pass_color_scan)
{
@@ -2042,6 +2034,7 @@
*len = 0;
nread = read (s-&gt;pipe, buf, max_len);
+ DBG(3, "read %ld bytes\n", (long) nread);
if (!s-&gt;scanning)
return do_cancel (s);
<p>
<pre>
--
Source code, list archive, and docs: <a href="http://www.azstarnet.com/~axplinux/sane/">http://www.azstarnet.com/~axplinux/sane/</a>
To unsubscribe: mail -s unsubscribe <a href="mailto:sane-devel-request@listserv.azstarnet.com">sane-devel-request@listserv.azstarnet.com</a>
</pre>
<!-- body="end" -->
<p>
<ul>
<!-- next="start" -->
<li> <b>Next message:</b> <a href="0053.html">Mathias Weigt: "Re: mustek 3-pass backend now working!"</a>
<li> <b>Previous message:</b> <a href="0051.html">David Mosberger-Tang: "Re: MFS-12000CX"</a>
<!-- nextthread="start" -->
<li> <b>Next in thread:</b> <a href="0054.html">David Mosberger-Tang: "Re: mustek 3-pass backend now working!"</a>
<li> <b>Maybe reply:</b> <a href="0054.html">David Mosberger-Tang: "Re: mustek 3-pass backend now working!"</a>
<!-- reply="end" -->
</ul>