1 /* sane - Scanner Access Now Easy.
2 
3    Copyright (C) 1997, 1998, 1999, 2001, 2002, 2013  Franck Schnefra,
4    Michel Roelofs, Emmanuel Blot, Mikko Tyolajarvi, David Mosberger-Tang,
5    Wolfgang Goeller, Petter Reinholdtsen, Gary Plewa, Sebastien Sable,
6    Mikael Magnusson, Andrew Goodbody, Oliver Schwartz and Kevin Charter
7 
8    This file is part of the SANE package.
9 
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2 of the
13    License, or (at your option) any later version.
14 
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program.  If not, see <https://www.gnu.org/licenses/>.
22 
23    As a special exception, the authors of SANE give permission for
24    additional uses of the libraries contained in this release of SANE.
25 
26    The exception is that, if you link a SANE library with other files
27    to produce an executable, this does not by itself cause the
28    resulting executable to be covered by the GNU General Public
29    License.  Your use of that executable is in no way restricted on
30    account of linking the SANE library code into it.
31 
32    This exception does not, however, invalidate any other reasons why
33    the executable file might be covered by the GNU General Public
34    License.
35 
36    If you submit changes to SANE to the maintainers to be included in
37    a subsequent release, you agree by submitting the changes that
38    those changes may be distributed with this exception intact.
39 
40    If you write modifications of your own for SANE, it is your choice
41    whether to permit this exception to apply to your modifications.
42    If you do not wish that, delete this exception notice.
43 
44    This file is a component of the implementation of a backend for many
45    of the AGFA SnapScan and Acer Vuego/Prisa flatbed scanners.
46 */
47 
48 /*
49    SANE SnapScan backend
50 */
51 
52 #ifndef snapscan_h
53 #define snapscan_h
54 
55 #include "../include/sane/sane.h"
56 
57 #define UNREFERENCED_PARAMETER(x)           ((void) x)
58 
59 /* snapscan device field values */
60 
61 #define DEFAULT_DEVICE "/dev/scanner" /* Check this if config is missing */
62 #define SNAPSCAN_TYPE      "flatbed scanner"
63 #define SNAPSCAN_FS_TYPE   "film scanner"
64 #define TMP_FILE_PREFIX "/var/tmp/snapscan"
65 #define SNAPSCAN_CONFIG_FILE "snapscan.conf"
66 #define FIRMWARE_KW "firmware"
67 #define OPTIONS_KW "options"
68 
69 /* Define the colour channel order in arrays */
70 #define R_CHAN    0
71 #define G_CHAN    1
72 #define B_CHAN    2
73 
74 typedef enum
75 {
76   UNKNOWN_BUS,
77   SCSI,
78   USB
79 } SnapScan_Bus;
80 
81 typedef enum
82 {
83     UNKNOWN,
84     SNAPSCAN,           /* the original SnapScan */
85     SNAPSCAN300,        /* the SnapScan 300 */
86     SNAPSCAN310,        /* the SnapScan 310 */
87     SNAPSCAN600,        /* the SnapScan 600 */
88     SNAPSCAN1236,       /* the SnapScan 1236 */
89     SNAPSCAN1212U,
90     SNAPSCANE20,        /* SnapScan e20/e25, 600 DPI */
91     SNAPSCANE50,        /* SnapScan e40/e50, 1200 DPI */
92     SNAPSCANE52,        /* SnapScan e52, 1200 DPI, no quality calibration */
93     ACER300F,
94     PRISA310,           /* Acer ScanPrisa 310 - 300 DPI */
95     PRISA610,           /* Acer ScanPrisa 610 - 600 DPI */
96     PRISA620,           /* Acer ScanPrisa 620 - 600 DPI */
97     PRISA640,           /* Acer ScanPrisa 640 - 600 DPI */
98     PRISA1240,          /* Acer ScanPrisa 1240 - 1200 DPI */
99     PRISA4300,          /* Acer ScanPrisa 3300/4300 - 600 DPI */
100     PRISA4300_2,        /* Acer ScanPrisa 3300/4300 - 600 DPI, 42 bit*/
101     PRISA5000,          /* Acer ScanPrisa 5000 - 1200 DPI */
102     PRISA5000E,         /* Acer ScanPrisa 5000E/5000U - 1200 DPI */
103     PRISA5150,          /* Benq 5150 - 1200 DPI */
104     PRISA5300,          /* Acer ScanPrisa 5300 - 1200 DPI */
105     PERFECTION660,      /* Epson Perfection 660 - 1200 DPI */
106     PERFECTION1270,     /* Epson Perfection 1270 - 1600 DPI */
107     PERFECTION1670,     /* Epson Perfection 1670 - 1600 DPI */
108     PERFECTION2480,     /* Epson Perfection 2480 - 2400 DPI */
109     PERFECTION3490,     /* Epson Perfection 3490 - 3200 DPI */
110     STYLUS_CX1500,      /* Epson Stylus CX 1500 - 600 DPI */
111     ARCUS1200,          /* Agfa Arcus 1200 - 1200 DPI (rebadged Acer?) */
112     SCANWIT2720S        /* BenQ ScanWit 2720S film scanner 2700 DPI */
113 } SnapScan_Model;
114 
115 struct SnapScan_Driver_desc {
116     SnapScan_Model id;
117     char *driver_name;
118 };
119 
120 static struct SnapScan_Driver_desc drivers[] =
121 {
122     /* enum value -> Driver name */
123     {UNKNOWN,        "Unknown"},
124     {SNAPSCAN,       "SnapScan"},
125     {SNAPSCAN300,    "SnapScan300"},
126     {SNAPSCAN310,    "SnapScan310"},
127     {SNAPSCAN600,    "SnapScan600"},
128     {SNAPSCAN1236,   "SnapScan1236"},
129     {SNAPSCAN1212U,  "SnapScan1212"},
130     {SNAPSCANE20,    "SnapScanE20"},
131     {SNAPSCANE50,    "SnapScanE50"},
132     {SNAPSCANE52,    "SnapScanE52"},
133     {ACER300F,       "Acer300"},
134     {PRISA310,       "Acer310"},
135     {PRISA610,       "Acer610"},
136     {PRISA620,       "Acer620"},
137     {PRISA640,       "Acer640"},
138     {PRISA4300,      "Acer4300"},
139     {PRISA4300_2,    "Acer4300 (42 bit)"},
140     {PRISA1240,      "Acer1240"},
141     {PRISA5000E,     "Benq 5000E/5000U"},
142     {PRISA5000,      "Benq 5000"},
143     {PRISA5150,      "Benq 5150 / 5250"},
144     {PRISA5300,      "Benq 5300"},
145     {ARCUS1200,      "Arcus1200"},
146     {PERFECTION660,  "Perfection 660"},
147     {PERFECTION1270, "Perfection 1270"},
148     {PERFECTION1670, "Perfection 1670"},
149     {PERFECTION2480, "Perfection 2480"},
150     {PERFECTION3490, "Perfection 3490"},
151     {STYLUS_CX1500,  "Stylus CX 1500"},
152     {SCANWIT2720S,   "BenQ ScanWit 2720S"}
153 };
154 
155 #define known_drivers ((int) (sizeof(drivers)/sizeof(drivers[0])))
156 
157 struct SnapScan_Model_desc
158 {
159     char *scsi_name;
160     SnapScan_Model id;
161 };
162 
163 static struct SnapScan_Model_desc scanners[] =
164 {
165     /* SCSI model name -> enum value */
166     {"FlatbedScanner_2",    PRISA310},
167     {"FlatbedScanner_4",    PRISA610},
168     {"FlatbedScanner_5",    PRISA620},
169     {"FlatbedScanner_7",    PRISA310},
170     {"FlatbedScanner_9",    PRISA620},
171     {"FlatbedScanner13",    PRISA620},
172     {"FlatbedScanner16",    PRISA620},
173     {"FlatbedScanner17",    PRISA620},
174     {"FlatbedScanner18",    PRISA620},
175     {"FlatbedScanner19",    PRISA1240},
176     {"FlatbedScanner20",    PRISA640},
177     {"FlatbedScanner21",    PRISA4300},
178     {"FlatbedScanner22",    PRISA4300_2},
179     {"FlatbedScanner23",    PRISA4300_2},
180     {"FlatbedScanner24",    PRISA5300},
181     {"FlatbedScanner25",    PRISA5000E},/* 5000E/5000U */
182     {"FlatbedScanner40",    PRISA5150}, /* 5150 / 5250  */
183     {"FlatbedScanner42",    PRISA5000}, /* 5000 */
184     {"SNAPSCAN 1212U",      SNAPSCAN1212U},
185     {"SNAPSCAN 1212U_2",    SNAPSCAN1212U},
186     {"SNAPSCAN e10",        SNAPSCANE20},
187     {"SNAPSCAN e20",        SNAPSCANE20},
188     {"SNAPSCAN e25",        SNAPSCANE20},
189     {"SNAPSCAN e26",        SNAPSCANE20},
190     {"SNAPSCAN e40",        SNAPSCANE50},
191     {"SNAPSCAN e42",        SNAPSCANE52},
192     {"SNAPSCAN e50",        SNAPSCANE50},
193     {"SNAPSCAN e52",        SNAPSCANE52},
194     {"SNAPSCAN 1236",       SNAPSCAN1236},
195     {"SNAPSCAN 1236U",      SNAPSCAN1236},
196     {"SNAPSCAN 300",        SNAPSCAN300},
197     {"SNAPSCAN 310",        SNAPSCAN310},
198     {"SNAPSCAN 600",        SNAPSCAN600},
199     {"SnapScan",            SNAPSCAN},
200     {"ACERSCAN_A4____1",    ACER300F},
201     {"Perfection 660",      PERFECTION660},
202     {"EPSON Scanner",       PERFECTION1670}, /* dummy entry to detect scanner */
203     {"EPSON Scanner1",      PERFECTION2480}, /* dummy entry to detect scanner */
204     {"EPSON Scanner2",      PERFECTION3490}, /* dummy entry to detect scanner */
205     {"EPSON MFP00", 		STYLUS_CX1500},
206     {"ARCUS 1200",          ARCUS1200},
207     {"FilmScanner____1",    SCANWIT2720S}
208 };
209 
210 #define known_scanners ((int) (sizeof(scanners)/sizeof(scanners[0])))
211 
212 static char *vendors[] =
213 {
214     /* SCSI Vendor name */
215     "AGFA",
216     "COLOR",
217     "Color",
218     "ACERPER",
219     "EPSON"
220 };
221 #define known_vendors ((int) (sizeof(vendors)/sizeof(vendors[0])))
222 
223 /* Known vendor IDs */
224 #define USB_VENDOR_AGFA  0x06bd
225 #define USB_VENDOR_ACER  0x04a5
226 #define USB_VENDOR_EPSON 0x04b8
227 
228 /* Agfa product IDs */
229 #define USB_PRODUCT_1212U2 0x2061
230 /* Acer product IDs */
231 #define USB_PRODUCT_PRISA310 0x1a20
232 #define USB_PRODUCT_PRISA320 0x2022
233 /* Epson product IDs */
234 #define USB_PRODUCT_PERFECTION660  0x0114
235 #define USB_PRODUCT_PERFECTION1270 0x0120
236 #define USB_PRODUCT_PERFECTION1670 0x011f
237 #define USB_PRODUCT_PERFECTION2480 0x0121
238 #define USB_PRODUCT_PERFECTION3490 0x0122
239 
240 static SANE_Word usb_vendor_ids[] =
241 {
242     /* USB Vendor IDs */
243     USB_VENDOR_AGFA,     /* Agfa */
244     USB_VENDOR_ACER,     /* Acer */
245     USB_VENDOR_EPSON      /* Epson */
246 };
247 #define known_usb_vendor_ids ((int) (sizeof(usb_vendor_ids)/sizeof(usb_vendor_ids[0])))
248 
249 struct SnapScan_USB_Model_desc
250 {
251     SANE_Word vendor_id;
252     SANE_Word product_id;
253     SnapScan_Model id;
254 };
255 
256 static struct SnapScan_USB_Model_desc usb_scanners[] =
257 {
258     {USB_VENDOR_ACER, USB_PRODUCT_PRISA310, PRISA310},  /* Acer 310U */
259     {USB_VENDOR_ACER, USB_PRODUCT_PRISA320, PRISA310},  /* Acer 320U */
260     {USB_VENDOR_EPSON, USB_PRODUCT_PERFECTION660, PERFECTION660}, /* Epson Perfection 660 */
261     {USB_VENDOR_EPSON, USB_PRODUCT_PERFECTION1270, PERFECTION1270}, /* Epson Perfection 1270 */
262     {USB_VENDOR_EPSON, USB_PRODUCT_PERFECTION1670, PERFECTION1670}, /* Epson Perfection 1670 */
263     {USB_VENDOR_EPSON, USB_PRODUCT_PERFECTION2480, PERFECTION2480}, /* Epson Perfection 2480 */
264     {USB_VENDOR_EPSON, USB_PRODUCT_PERFECTION3490, PERFECTION3490} /* Epson Perfection 3490 */
265 };
266 #define known_usb_scanners ((int) (sizeof(usb_scanners)/sizeof(usb_scanners[0])))
267 
268 typedef enum
269 {
270     OPT_COUNT = 0,         /* option count */
271     OPT_MODE_GROUP,        /* scan mode group */
272     OPT_SCANRES,           /* scan resolution */
273     OPT_PREVIEW,           /* preview mode toggle */
274     OPT_MODE,              /* scan mode */
275     OPT_PREVIEW_MODE,      /* preview mode */
276     OPT_HIGHQUALITY,       /* scan quality (fast / high) */
277     OPT_SOURCE,            /* scan source (flatbed / TPO) */
278     OPT_FRAME_NO,          /* frame number for film scanner */
279     OPT_FOCUS_MODE,        /* manual or auto focus for film scanner */
280     OPT_FOCUS_POINT,       /* focus point for film scanner */
281     OPT_GEOMETRY_GROUP,    /* geometry group */
282     OPT_TLX,               /* top left x */
283     OPT_TLY,               /* top left y */
284     OPT_BRX,               /* bottom right x */
285     OPT_BRY,               /* bottom right y */
286     OPT_PREDEF_WINDOW,     /* predefined window configuration */
287     OPT_ENHANCEMENT_GROUP, /* enhancement group */
288     OPT_BIT_DEPTH,         /* 8/16 bit/pixel for colour scans */
289     OPT_QUALITY_CAL,       /* quality calibration */
290     OPT_HALFTONE,          /* halftone flag */
291     OPT_HALFTONE_PATTERN,  /* halftone matrix */
292     OPT_CUSTOM_GAMMA,      /* use custom gamma tables */
293     OPT_GAMMA_BIND,        /* use same gamma value for all colors */
294     OPT_GAMMA_GS,          /* gamma correction (greyscale) */
295     OPT_GAMMA_R,           /* gamma correction (red) */
296     OPT_GAMMA_G,           /* gamma correction (green) */
297     OPT_GAMMA_B,           /* gamma correction (blue) */
298     OPT_GAMMA_VECTOR_GS,   /* gamma correction vector (greyscale) */
299     OPT_GAMMA_VECTOR_R,    /* gamma correction vector (red) */
300     OPT_GAMMA_VECTOR_G,    /* gamma correction vector (green) */
301     OPT_GAMMA_VECTOR_B,    /* gamma correction vector (blue) */
302     OPT_NEGATIVE,          /* swap black and white */
303     OPT_THRESHOLD,         /* threshold for line art */
304     OPT_BRIGHTNESS,        /* brightness */
305     OPT_CONTRAST,          /* contrast */
306     OPT_ADVANCED_GROUP,    /* advanced group */
307     OPT_RGB_LPR,           /* lines per scsi read (RGB) */
308     OPT_GS_LPR,            /* lines per scsi read (GS) */
309     NUM_OPTS               /* dummy (gives number of options) */
310 } SnapScan_Options;
311 
312 typedef enum
313 {
314     MD_COLOUR = 0,       /* full colour */
315     MD_BILEVELCOLOUR,    /* 1-bit per channel colour */
316     MD_GREYSCALE,        /* grey scale */
317     MD_LINEART,          /* black and white */
318     MD_NUM_MODES
319 } SnapScan_Mode;
320 
321 typedef enum
322 {
323     SRC_FLATBED = 0,    /* Flatbed (normal) */
324     SRC_TPO,            /* Transparency unit */
325     SRC_ADF
326 } SnapScan_Source;
327 
328 typedef enum
329 {
330     ST_IDLE,            /* between scans */
331     ST_SCAN_INIT,        /* scan initialization */
332     ST_SCANNING,        /* actively scanning data */
333     ST_CANCEL_INIT        /* cancellation begun */
334 } SnapScan_State;
335 
336 typedef struct snapscan_device
337 {
338     SANE_Device dev;
339     SANE_Range x_range;           /* x dimension of scan area */
340     SANE_Range y_range;           /* y dimension of scan area */
341     SnapScan_Model model;         /* type of scanner */
342     SnapScan_Bus bus;             /* bus of the device usb/scsi */
343     SANE_Char *firmware_filename; /* The name of the firmware file for USB scanners */
344     struct snapscan_device *pnext;
345 }
346 SnapScan_Device;
347 
348 #define MD_AUTO     0
349 #define MD_MANUAL   1
350 
351 #define MAX_SCSI_CMD_LEN 256    /* not that large */
352 #define DEFAULT_SCANNER_BUF_SZ 1024*63
353 
354 typedef struct snapscan_scanner SnapScan_Scanner;
355 
356 #include <snapscan-sources.h>
357 
358 struct snapscan_scanner
359 {
360     SANE_String devname;          /* the scsi device name */
361     SnapScan_Device *pdev;        /* the device */
362     int fd;                       /* scsi file descriptor */
363     int opens;                    /* open count */
364     int rpipe[2];                 /* reader pipe descriptors */
365     int orig_rpipe_flags;         /* initial reader pipe flags */
366     SANE_Pid child;               /* child reader process pid */
367     SnapScan_Mode mode;           /* mode */
368     SnapScan_Mode preview_mode;   /* preview mode */
369     SnapScan_Source source;       /* scanning source */
370     SnapScan_State state;         /* scanner state */
371     u_char cmd[MAX_SCSI_CMD_LEN]; /* scsi command buffer */
372     u_char *buf;                  /* data buffer */
373     size_t phys_buf_sz;           /* physical buffer size */
374     size_t buf_sz;                /* effective buffer size */
375     size_t expected_read_bytes;   /* expected amount of data in a single read */
376     size_t read_bytes;            /* amount of actual data read */
377     size_t bytes_remaining;       /* remaining bytes expected from scanner */
378     size_t actual_res;            /* actual resolution */
379     size_t lines;                 /* number of scan lines */
380     size_t bytes_per_line;        /* bytes per scan line */
381     size_t pixels_per_line;       /* pixels per scan line */
382     u_char hconfig;               /* hardware configuration byte */
383     u_char hconfig_epson;         /* additional hw configuration for some Epson scanners */
384     u_char hwst;                  /* hardware status byte */
385     float ms_per_line;            /* speed: milliseconds per scan line */
386     SANE_Bool nonblocking;        /* wait on reads for data? */
387     char *sense_str;              /* sense string */
388     char *as_str;                 /* additional sense string */
389     u_char asi1;                  /* first additional sense info byte */
390     u_char asi2;                  /* second additional sense info byte */
391     SANE_Byte chroma_offset[3];   /* chroma offsets */
392     SANE_Int chroma;
393     Source *psrc;                 /* data source */
394     Source *preadersrc;                 /* data source for reader thread */
395     SANE_Option_Descriptor options[NUM_OPTS];  /* the option descriptors */
396     Option_Value val[NUM_OPTS];  /* the options themselves... */
397     SANE_Int res;                /* resolution */
398     SANE_Int bpp;                /* bit depth supported by scanner*/
399     SANE_Int bpp_scan;           /* bit depth used for scanning */
400     SANE_Bool preview;           /* preview mode toggle */
401     SANE_Bool highquality;       /* high quality mode toggle */
402     SANE_String mode_s;          /* scanning mode */
403     SANE_String source_s;        /* scanning source */
404     SANE_String preview_mode_s;  /* scanning mode for preview */
405     SANE_Fixed tlx;              /* window top left x */
406     SANE_Fixed tly;              /* window top left y */
407     SANE_Fixed brx;              /* window bottom right x */
408     SANE_Fixed bry;              /* window bottom right y */
409     int bright;                  /* brightness */
410     int contrast;                /* contrast */
411     SANE_String predef_window;   /* predefined window name */
412     SANE_Fixed gamma_gs;         /* gamma correction value (greyscale) */
413     SANE_Fixed gamma_r;          /* gamma correction value (red) */
414     SANE_Fixed gamma_g;          /* gamma correction value (green) */
415     SANE_Fixed gamma_b;          /* gamma correction value (blue) */
416     SANE_Int *gamma_tables;      /* gamma correction vectors */
417     SANE_Int *gamma_table_gs;    /* gamma correction vector (greyscale) */
418     SANE_Int *gamma_table_r;     /* gamma correction vector (red) */
419     SANE_Int *gamma_table_g;     /* gamma correction vector (green) */
420     SANE_Int *gamma_table_b;     /* gamma correction vector (blue) */
421     int gamma_length;            /* length of gamma vectors */
422     SANE_Bool halftone;          /* halftone toggle */
423     SANE_String dither_matrix;   /* the halftone dither matrix */
424     SANE_Bool negative;          /* swap black and white */
425     SANE_Int threshold;          /* threshold for line art */
426     SANE_Int rgb_lpr;            /* lines per scsi read (RGB) */
427     SANE_Int gs_lpr;             /* lines per scsi read (greyscale) */
428     SANE_Bool firmware_loaded;   /* true if firmware was downloaded */
429     SANE_Word usb_vendor;        /* USB vendor id */
430     SANE_Word usb_product;       /* USB product id */
431     SANE_Byte frame_no;          /* frame number for film scanner */
432     SANE_Int focus_mode;         /* focus mode value */
433     SANE_String focus_mode_s;    /* focus mode string */
434     SANE_Word focus;             /* focus point */
435 };
436 
437 #endif
438 
439 /*
440  * Revision 1.42  2008/05/15 12:50:24  ellert-guest
441  * Fix for bug #306751: sanei-thread with pthreads on 64 bit
442  *
443  * Revision 1.41  2006-02-02 21:28:05  oliver-guest
444  * Corrected USB ID for Benq 310
445  *
446  * Revision 1.40  2006/01/01 22:57:01  oliver-guest
447  * Added calibration data for Benq 5150 / 5250, preliminary support for Epson Stylus CX 1500
448  *
449  * Revision 1.39  2005/12/04 15:03:00  oliver-guest
450  * Some fixes for Benq 5150
451  *
452  * Revision 1.38  2005/10/31 21:08:47  oliver-guest
453  * Distinguish between Benq 5000/5000E/5000U
454  *
455  * Revision 1.37  2005/10/24 19:46:40  oliver-guest
456  * Preview and range fix for Epson 2480/2580
457  *
458  * Revision 1.36  2005/09/28 21:33:11  oliver-guest
459  * Added 16 bit option for Epson scanners (untested)
460  *
461  * Revision 1.35  2005/09/03 10:52:11  oliver-guest
462  * Fixed debugging code for epson scanners
463  *
464  * Revision 1.34  2005/08/15 18:06:37  oliver-guest
465  * Added support for Epson 3490/3590 (thanks to Matt Judge)
466  *
467  * Revision 1.33  2005/02/08 22:17:53  oliver-guest
468  * Added IDs for Benq 5250C and 5000S
469  *
470  * Revision 1.32  2005/01/18 20:36:13  oliver-guest
471  * Added ID for Benq 5250C
472  *
473  * Revision 1.31  2004/12/01 22:12:04  oliver-guest
474  * Added support for Epson 1270
475  *
476  * Revision 1.30  2004/09/02 20:59:12  oliver-guest
477  * Added support for Epson 2480
478  *
479  * Revision 1.29  2004/06/16 19:52:27  oliver-guest
480  * Don't enforce even number of URB packages on 1212u_2. Fixes bug #300753.
481  *
482  * Revision 1.28  2004/04/08 21:53:10  oliver-guest
483  * Use sanei_thread in snapscan backend
484  *
485  * Revision 1.27  2004/03/22 00:00:40  oliver-guest
486  * Added detection for Epson 660 by USB ID since new models use new ID strings
487  *
488  * Revision 1.26  2003/10/21 20:43:25  oliver-guest
489  * Bugfixes for SnapScan backend
490  *
491  * Revision 1.25  2003/10/07 19:41:34  oliver-guest
492  * Updates for Epson Perfection 1670
493  *
494  * Revision 1.24  2003/10/07 18:29:20  oliver-guest
495  * Initial support for Epson 1670, minor bugfix
496  *
497  * Revision 1.23  2003/09/12 16:10:33  hmg-guest
498  * Moved union Option_Value from backend header files to sanei_backend.h. No need
499  * to copy it over and over again. Changed header inclusion order in backend
500  * files to include backend.h after sanei_backend.h. Based on a patch from stef
501  * <stef-listes@wanadoo.fr>.
502  *
503  * Revision 1.22  2003/08/19 21:05:08  oliverschwartz
504  * Scanner ID cleanup
505  *
506  * Revision 1.21  2003/04/30 20:49:40  oliverschwartz
507  * SnapScan backend 1.4.26
508  *
509  * Revision 1.38  2003/04/30 20:42:22  oliverschwartz
510  * Added support for Agfa Arcus 1200 (supplied by Valtteri Vuorikoski)
511  *
512  * Revision 1.37  2003/02/05 22:11:11  oliverschwartz
513  * Added Epson Perfection 660
514  *
515  * Revision 1.36  2003/01/08 21:16:36  oliverschwartz
516  * Added support for Acer / Benq 310U
517  *
518  * Revision 1.35  2002/12/10 20:14:12  oliverschwartz
519  * Enable color offset correction for SnapScan300
520  *
521  * Revision 1.34  2002/10/12 10:40:48  oliverschwartz
522  * Added support for Snapscan e10
523  *
524  * Revision 1.33  2002/09/24 16:07:47  oliverschwartz
525  * Added support for Benq 5000
526  *
527  * Revision 1.32  2002/07/12 22:22:47  oliverschwartz
528  * Correct driver description for 4300_2
529  *
530  * Revision 1.31  2002/04/27 14:44:27  oliverschwartz
531  * - Remove SCSI debug options
532  *
533  * Revision 1.30  2002/04/23 22:51:00  oliverschwartz
534  * Cleanup, support for ADF
535  *
536  * Revision 1.29  2002/03/24 12:14:34  oliverschwartz
537  * Add Snapcan_Driver_desc
538  *
539  * Revision 1.28  2002/01/23 20:38:20  oliverschwartz
540  * Fix model ID for e42
541  * Improve recognition of Acer 320U
542  *
543  * Revision 1.27  2002/01/06 18:34:02  oliverschwartz
544  * Added support for Snapscan e42 thanks to Yari Ad� Petralanda
545  *
546  * Revision 1.26  2001/12/20 23:18:01  oliverschwartz
547  * Remove tmpfname
548  *
549  * Revision 1.25  2001/12/18 18:28:35  oliverschwartz
550  * Removed temporary file
551  *
552  * Revision 1.24  2001/12/12 19:44:59  oliverschwartz
553  * Clean up CVS log
554  *
555  * Revision 1.23  2001/11/25 18:51:41  oliverschwartz
556  * added support for SnapScan e52 thanks to Rui Lopes
557  *
558  * Revision 1.22  2001/11/16 20:56:47  oliverschwartz
559  * additional identification string for e26 added
560  *
561  * Revision 1.21  2001/11/16 20:28:35  oliverschwartz
562  * add support for Snapscan e26
563  *
564  * Revision 1.20  2001/11/16 20:23:16  oliverschwartz
565  * Merge with sane-1.0.6
566  *   - Check USB vendor IDs to avoid hanging scanners
567  *   - fix bug in dither matrix computation
568  *
569  * Revision 1.19  2001/10/11 14:02:10  oliverschwartz
570  * Distinguish between e20/e25 and e40/e50
571  *
572  * Revision 1.18  2001/10/10 10:11:10  oliverschwartz
573  * Add support for Snapscan e25 thanks to Rodolphe Suescun
574  *
575  * Revision 1.17  2001/10/08 18:22:02  oliverschwartz
576  * - Disable quality calibration for Acer Vuego 310F
577  * - Use sanei_scsi_max_request_size as scanner buffer size
578  *   for SCSI devices
579  * - Added new devices to snapscan.desc
580  *
581  * Revision 1.16  2001/09/28 13:39:16  oliverschwartz
582  * - Added "Snapscan 300" ID string
583  * - cleanup
584  * - more debugging messages in snapscan-sources.c
585  *
586  * Revision 1.15  2001/09/18 15:01:07  oliverschwartz
587  * - Read scanner id string again after firmware upload
588  *   to identify correct model
589  * - Make firmware upload work for AGFA scanners
590  * - Change copyright notice
591  *
592  * Revision 1.14  2001/09/17 10:01:08  sable
593  * Added model AGFA 1236U
594  *
595  * Revision 1.13  2001/09/09 20:39:52  oliverschwartz
596  * add identification for 620ST+
597  *
598  * Revision 1.12  2001/09/09 18:06:32  oliverschwartz
599  * add changes from Acer (new models; automatic firmware upload for USB scanners); fix distorted colour scans after greyscale scans (call set_window only in sane_start); code cleanup
600  *
601  * Revision 1.11  2001/04/10 12:38:21  sable
602  * Adding e20 support thanks to Steffen Hbner
603  *
604  * Revision 1.10  2001/04/10 11:04:31  sable
605  * Adding support for snapscan e40 an e50 thanks to Giuseppe Tanzilli
606  *
607  * Revision 1.9  2001/03/17 22:53:21  sable
608  * Applying Mikael Magnusson patch concerning Gamma correction
609  * Support for 1212U_2
610  *
611  * Revision 1.8  2000/11/10 01:01:59  sable
612  * USB (kind of) autodetection
613  *
614  * Revision 1.7  2000/11/01 01:26:43  sable
615  * Support for 1212U
616  *
617  * Revision 1.6  2000/10/28 14:06:35  sable
618  * Add support for Acer300f
619  *
620  * Revision 1.5  2000/10/15 17:54:58  cbagwell
621  * Adding USB files for optional USB compiles.
622  *
623  * Revision 1.4  2000/10/13 03:50:27  cbagwell
624  * Updating to source from SANE 1.0.3.  Calling this version 1.1
625  *
626  * Revision 1.3  2000/08/12 15:09:37  pere
627  * Merge devel (v1.0.3) into head branch.
628  *
629  * Revision 1.1.1.1.2.2  2000/07/13 04:47:50  pere
630  * New snapscan backend version dated 20000514 from Steve Underwood.
631  *
632  * Revision 1.2.1  2000/05/14 13:30:20  coppice
633  * Some reformatting a minor tidying.
634  *
635  * Revision 1.2  2000/03/05 13:55:21  pere
636  * Merged main branch with current DEVEL_1_9.
637  *
638  * Revision 1.1.1.1.2.1  1999/09/15 18:20:02  charter
639  * Early version 1.0 snapscan.h
640  *
641  * Revision 2.2  1999/09/09 18:25:02  charter
642  * Checkpoint. Removed references to snapscan-310.c stuff using
643  * "#ifdef OBSOLETE".
644  *
645  * Revision 2.1  1999/09/08 03:05:05  charter
646  * Start of branch 2; same as 1.30.
647  *
648  * Revision 1.30  1999/09/07 20:54:07  charter
649  * Changed expected_data_len to bytes_remaining.
650  *
651  * Revision 1.29  1999/09/02 05:29:46  charter
652  * Fixed the spelling of Petter's name (again).
653  *
654  * Revision 1.28  1999/09/02 05:28:50  charter
655  * Added Gary Plewa's name to the list of contributors.
656  *
657  * Revision 1.27  1999/09/02 04:48:25  charter
658  * Added models and strings for the Acer PRISA 620s (thanks to Gary Plewa).
659  *
660  * Revision 1.26  1999/09/02 02:01:46  charter
661  * Checking in rev 1.26 (for backend version 0.7) again.
662  * This is part of the recovery from the great disk crash of Sept 1, 1999.
663  *
664  * Revision 1.26  1999/07/09 20:54:34  charter
665  * Modifications for SnapScan 1236s (Petter Reinholdsten).
666  *
667  * Revision 1.25  1998/12/16 18:40:53  charter
668  * Commented the INOPERATIVE define to get rid of spurious brightness
669  * and contrast controls accidentally reintroduced previously.
670  *
671  * Revision 1.24  1998/09/07  06:04:58  charter
672  * Merged in Wolfgang Goeller's changes (Vuego 310S, bugfixes).
673  *
674  * Revision 1.23  1998/05/11  17:03:22  charter
675  * Added Mikko's threshold stuff
676  *
677  * Revision 1.22  1998/03/10 23:43:05  eblot
678  * Changing 310/600 models support (structure)
679  *
680  * Revision 1.21  1998/03/08 14:24:43  eblot
681  * Debugging
682  *
683  * Revision 1.20  1998/02/15  21:55:03  charter
684  * From Emmanuel Blot:
685  * Added rgb ring buffer to handle snapscan 310 data specs.
686  *
687  * Revision 1.19  1998/02/06  02:29:52  charter
688  * Added SnapScan_Mode and SnapScan_Model enums.
689  *
690  * Revision 1.18  1998/01/31  23:59:51  charter
691  * Changed window coordinates type to SANE_Fixed (what it should be
692  * for a length).
693  *
694  * Revision 1.17  1998/01/30  19:18:41  charter
695  * Added sense_str and as_str to SnapScan_Scanner; these are intended to
696  * be set by the sense handler.
697  *
698  * Revision 1.16  1998/01/30  11:02:17  charter
699  * Added opens to the SnapScan_Scanner to support open_scanner() and
700  * close_scanner().
701  *
702  * Revision 1.15  1998/01/25  09:57:32  charter
703  * Added more SCSI command options and a group for them.
704  *
705  * Revision 1.14  1998/01/25  08:50:49  charter
706  * Added preview mode option.
707  *
708  * Revision 1.13  1998/01/25  02:24:31  charter
709  * Added OPT_NEGATIVE and the extra sense data bytes.
710  *
711  * Revision 1.12  1998/01/24  05:14:56  charter
712  * Added stuff for RGB gamma correction and for BW mode halftoning.
713  *
714  * Revision 1.11  1998/01/23  13:02:45  charter
715  * Added rgb_lpr and gs_lpr so the user can tune scanning performance.
716  *
717  * Revision 1.10  1998/01/23  07:39:08  charter
718  * Reindented using GNU convention at David Mosberger-Tang's request.
719  * Added ms_per_line to SnapScan_Scanner.
720  *
721  * Revision 1.9  1998/01/22  05:14:23  charter
722  * The bit depth option has been replaced with a mode option. We support
723  * full color, greyscale and lineart modes.
724  *
725  * Revision 1.8  1998/01/21  20:40:13  charter
726  * Added copyright info; added the new SnapScan_State type and
727  * replaced the scanning member of SnapScan_Scanner with a state
728  * member. This is for supporting cancellation.
729  *
730  * Revision 1.7  1998/01/21  11:05:20  charter
731  * Inoperative options now #defined out.
732  *
733  * Revision 1.6  1997/11/26  15:40:24  charter
734  * Brightness and contrast added by Michel.
735  *
736  * Revision 1.5  1997/11/12  12:52:16  charter
737  * Added OPT_INQUIRY for the inquiry button.
738  *
739  * Revision 1.4  1997/11/10  05:51:45  charter
740  * Added stuff for the child reader process and pipe.
741  *
742  * Revision 1.3  1997/11/03  03:16:46  charter
743  * Added buffers and window parameter variables to the scanner structure.
744  *
745  * Revision 1.2  1997/10/14  05:59:53  charter
746  * Basic options and structures added.
747  *
748  * Revision 1.1  1997/10/13  02:25:54  charter
749  * Initial revision
750  * */
751