1 /* HP Scanjet 3900 series - Structures and global variables
2 
3    Copyright (C) 2005-2009 Jonathan Bravo Lopez <jkdsoft@gmail.com>
4 
5    This file is part of the SANE package.
6 
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License
9    as published by the Free Software Foundation; either version 2
10    of the License, or (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 
20    As a special exception, the authors of SANE give permission for
21    additional uses of the libraries contained in this release of SANE.
22 
23    The exception is that, if you link a SANE library with other files
24    to produce an executable, this does not by itself cause the
25    resulting executable to be covered by the GNU General Public
26    License.  Your use of that executable is in no way restricted on
27    account of linking the SANE library code into it.
28 
29    This exception does not, however, invalidate any other reasons why
30    the executable file might be covered by the GNU General Public
31    License.
32 
33    If you submit changes to SANE to the maintainers to be included in
34    a subsequent release, you agree by submitting the changes that
35    those changes may be distributed with this exception intact.
36 
37    If you write modifications of your own for SANE, it is your choice
38    whether to permit this exception to apply to your modifications.
39    If you do not wish that, delete this exception notice.
40 */
41 
42 /* devices */
43 #define DEVSCOUNT           0x09	/* Number of scanners supported by this backend */
44 
45 #define HP3970              0x00	/* rts8822l-01H  HP Scanjet 3970  */
46 #define HP4070              0x01	/* rts8822l-01H  HP Scanjet 4070  */
47 #define HP4370              0x02	/* rts8822l-02A  HP Scanjet 4370  */
48 #define UA4900              0x03	/* rts8822l-01H  UMAX Astra 4900  */
49 #define HP3800              0x04	/* rts8822bl-03A HP Scanjet 3800  */
50 #define HPG3010             0x05	/* rts8822l-02A  HP Scanjet G3010 */
51 #define BQ5550              0x06	/* rts8823l-01E  BenQ 5550        */
52 #define HPG2710             0x07	/* rts8822bl-03A HP Scanjet G2710 */
53 #define HPG3110             0x08	/* rts8822l-02A  HP Scanjet G3110 */
54 
55 /* chipset models */
56 #define RTS8822L_01H        0x00
57 #define RTS8822L_02A        0x01
58 #define RTS8822BL_03A       0x02
59 #define RTS8823L_01E        0x03
60 
61 /* chipset capabilities */
62 #define CAP_EEPROM          0x01
63 
64 /* acceleration types */
65 #define ACC_CURVE           0x00
66 #define DEC_CURVE           0x01
67 
68 /* curve types */
69 #define CRV_NORMALSCAN      0x00
70 #define CRV_PARKHOME        0x01
71 #define CRV_SMEARING        0x02
72 #define CRV_BUFFERFULL      0x03
73 
74 /* Sample rates */
75 #define PIXEL_RATE          0x00
76 #define LINE_RATE           0x01
77 
78 /* motor types */
79 #define MT_OUTPUTSTATE      0x00
80 #define MT_ONCHIP_PWM       0x01
81 
82 /* motor step types */
83 #define STT_FULL            0x00	/* 90    degrees */
84 #define STT_HALF            0x01	/* 45    degrees */
85 #define STT_QUART           0x02	/* 22.5  degrees */
86 #define STT_OCT             0x03	/* 11.25 degrees */
87 
88 /* motor options */
89 #define MTR_BACKWARD        0x00
90 #define MTR_FORWARD         0x08
91 #define MTR_ENABLED         0x00
92 #define MTR_DISABLED        0x10
93 
94 /* sensors */
95 #define CCD_SENSOR          0x01
96 #define CIS_SENSOR          0x00
97 
98 /* sony sensor models */
99 #define SNYS575             0x00
100 
101 /* toshiba sensor models */
102 #define TCD2952             0x01
103 #define TCD2958             0x02
104 #define TCD2905             0x03
105 
106 /* usb types */
107 #define USB20               0x01
108 #define USB11               0x00
109 
110 /* scan types */
111 #define ST_NEG              0x03
112 #define ST_TA               0x02
113 #define ST_NORMAL           0x01
114 
115 /* colour modes */
116 #define CM_COLOR            0x00
117 #define CM_GRAY             0x01
118 #define CM_LINEART          0x02
119 
120 /* colour channels */
121 #define CL_RED              0x00
122 #define CL_GREEN            0x01
123 #define CL_BLUE             0x02
124 
125 /* lamp types */
126 #define FLB_LAMP            0x01
127 #define TMA_LAMP            0x02
128 
129 #define IST_NORMAL          0x00
130 #define IST_TA              0x01
131 #define IST_NEG             0x02
132 
133 #define ICM_GRAY            0x00
134 #define ICM_LINEART         0x01
135 #define ICM_COLOR           0x02
136 
137 #define TRUE                0x01
138 #define FALSE               0x00
139 
140 /* function results */
141 #define OK                  0x00
142 #define ERROR              -1
143 
144 #define RT_BUFFER_LEN       0x71a
145 
146 #define FIX_BY_HARD         0x01
147 #define FIX_BY_SOFT         0x02
148 
149 #define REF_AUTODETECT      0x02
150 #define REF_TAKEFROMSCANNER 0x01
151 #define REF_NONE            0x00
152 
153 /* bulk operations */
154 #define BLK_WRITE           0x00
155 #define BLK_READ            0x01
156 
157 /* constants for resizing functions */
158 #define RSZ_NONE            0x00
159 #define RSZ_DECREASE        0x01
160 #define RSZ_INCREASE        0x02
161 
162 #define RSZ_GRAYL           0x00
163 #define RSZ_COLOURL         0x01
164 #define RSZ_COLOURH         0x02
165 #define RSZ_LINEART         0x03
166 #define RSZ_GRAYH           0x04
167 
168 /* Macros for managing data */
169 #define _B0(x)              ((SANE_Byte)((x) & 0xFF))
170 #define _B1(x)              ((SANE_Byte)((x) >> 0x08))
171 #define _B2(x)              ((SANE_Byte)((x) >> 0x10))
172 #define _B3(x)              ((SANE_Byte)((x) >> 0x18))
173 
174 /* operation constants used in RTS_GetImage */
175 #define OP_STATIC_HEAD      0x00000001
176 #define OP_COMPRESSION      0x00000004
177 #define OP_BACKWARD         0x00000010
178 #define OP_WHITE_SHAD       0x00000020
179 #define OP_USE_GAMMA        0x00000040
180 #define OP_BLACK_SHAD       0x00000080
181 #define OP_LAMP_ON          0x00000200
182 
183 /* data types */
184 
185 typedef unsigned short USHORT;
186 
187 #ifdef STANDALONE
188 /* Stand-alone*/
189 #define SANE_STATUS_GOOD 0x00
190 
191 typedef unsigned char SANE_Byte;
192 typedef int SANE_Int;
193 typedef usb_dev_handle *USB_Handle;
194 
195 #else
196 
197 /* SANE backend */
198 typedef SANE_Int USB_Handle;
199 
200 #endif
201 
202 /* structures */
203 
204 struct st_debug_opts
205 {
206   /* device capabilities */
207   SANE_Int dev_model;
208 
209   SANE_Byte SaveCalibFile;
210   SANE_Byte DumpShadingData;
211   SANE_Byte ScanWhiteBoard;
212   SANE_Byte EnableGamma;
213   SANE_Byte use_fixed_pwm;
214   SANE_Int dmabuffersize;
215   SANE_Int dmatransfersize;
216   SANE_Int dmasetlength;
217   SANE_Int usbtype;
218 
219   SANE_Int calibrate;
220   SANE_Int wshading;
221 
222   SANE_Int overdrive_flb;
223   SANE_Int overdrive_ta;
224   SANE_Byte warmup;
225 
226   SANE_Int shd;
227 };
228 
229 struct st_chip
230 {
231   SANE_Int model;
232   SANE_Int capabilities;
233   char *name;
234 };
235 
236 struct st_shading
237 {
238   double *rates;
239   SANE_Int count;
240   SANE_Int ptr;
241 };
242 
243 struct st_scanning
244 {
245   SANE_Byte *imagebuffer;
246   SANE_Byte *imagepointer;
247   SANE_Int bfsize;
248   SANE_Int channel_size;
249 
250   /* arrange line related variables */
251   SANE_Int arrange_hres;
252   SANE_Int arrange_compression;
253   SANE_Int arrange_sensor_evenodd_dist;
254   SANE_Int arrange_orderchannel;
255   SANE_Int arrange_size;
256 
257   /* Pointers to each channel colour */
258   SANE_Byte *pColour[3];
259   SANE_Byte *pColour1[3];
260   SANE_Byte *pColour2[3];
261 
262   /* Channel displacements */
263   SANE_Int desp[3];
264   SANE_Int desp1[3];
265   SANE_Int desp2[3];
266 };
267 
268 struct st_resize
269 {
270   SANE_Byte mode;
271   SANE_Int type;
272   SANE_Int fromwidth;
273   SANE_Int towidth;
274   SANE_Int bytesperline;
275   SANE_Int rescount;
276   SANE_Int resolution_x;
277   SANE_Int resolution_y;
278 
279   SANE_Byte *v3624;
280   SANE_Byte *v3628;
281   SANE_Byte *v362c;
282 };
283 
284 struct st_gammatables
285 {
286   SANE_Int depth;		/*0=0x100| 4=0x400 |8=0x1000 */
287   SANE_Byte *table[3];
288 };
289 
290 struct st_readimage
291 {
292   SANE_Int Size4Lines;
293 
294   SANE_Byte Starting;
295   SANE_Byte *DMABuffer;
296   SANE_Int DMABufferSize;
297   SANE_Byte *RDStart;
298   SANE_Int RDSize;
299   SANE_Int DMAAmount;
300   SANE_Int Channel_size;
301   SANE_Byte Channels_per_dot;
302   SANE_Int ImageSize;
303   SANE_Int Bytes_Available;
304   SANE_Int Max_Size;
305   SANE_Byte Cancel;
306 };
307 
308 struct st_gain_offset
309 {
310   /* 32 bytes 08be|08e0|3654
311      red green blue */
312   SANE_Int edcg1[3];		/* 08e0|08e2|08e4 *//*Even offset 1 */
313   SANE_Int edcg2[3];		/* 08e6|08e8|08ea *//*Even offset 2 */
314   SANE_Int odcg1[3];		/* 08ec|08ee|08f0 *//*Odd  offset 1 */
315   SANE_Int odcg2[3];		/* 08f2|08f4|08f6 *//*Odd  offset 2 */
316   SANE_Byte pag[3];		/* 08f8|08f9|08fa */
317   SANE_Byte vgag1[3];		/* 08fb|08fc|08fd */
318   SANE_Byte vgag2[3];		/* 08fe|08ff|0900 */
319 };
320 
321 struct st_calibration_config
322 {
323   SANE_Int WStripXPos;
324   SANE_Int WStripYPos;
325   SANE_Int BStripXPos;
326   SANE_Int BStripYPos;
327   SANE_Int WRef[3];
328   SANE_Int BRef[3];
329   SANE_Byte RefBitDepth;
330   double OffsetTargetMax;
331   double OffsetTargetMin;
332   double OffsetBoundaryRatio1;
333   double OffsetBoundaryRatio2;
334   double OffsetAvgRatio1;
335   double OffsetAvgRatio2;
336   SANE_Int CalibOffset10n;
337   SANE_Int CalibOffset20n;
338   SANE_Int AdcOffEvenOdd;
339   SANE_Int AdcOffQuickWay;
340   SANE_Int OffsetEven1[3];
341   SANE_Int OffsetOdd1[3];
342   SANE_Int OffsetEven2[3];
343   SANE_Int OffsetOdd2[3];
344   SANE_Byte OffsetHeight;
345   SANE_Int OffsetPixelStart;
346   SANE_Int OffsetNPixel;
347   SANE_Byte OffsetNSigma;
348   SANE_Int AdcOffPredictStart;
349   SANE_Int AdcOffPredictEnd;
350   SANE_Byte OffsetAvgTarget[3];
351   SANE_Byte OffsetTuneStep1;
352   SANE_Byte OffsetTuneStep2;
353   double GainTargetFactor;
354   SANE_Int CalibGain10n;
355   SANE_Int CalibGain20n;
356   SANE_Int CalibPAGOn;
357   SANE_Int GainHeight;
358   SANE_Int unk1[3];
359   SANE_Int unk2[3];
360   SANE_Byte PAG[3];
361   SANE_Byte Gain1[3];
362   SANE_Byte Gain2[3];
363   /* White Shading */
364   SANE_Int WShadingOn;
365   SANE_Int WShadingHeight;
366   SANE_Int WShadingPreDiff[3];
367   SANE_Int unknown;		/*?? */
368   double ShadingCut[3];
369   /* Black Shading */
370   SANE_Int BShadingOn;
371   SANE_Int BShadingHeight;
372   SANE_Int BShadingDefCutOff;
373   SANE_Int BShadingPreDiff[3];
374   double ExternBoundary;
375   SANE_Int EffectivePixel;
376   SANE_Byte TotShading;
377 };
378 
379 struct st_calibration
380 {
381   /* faac */
382   struct st_gain_offset gain_offset;	/* 0..35 */
383   USHORT *white_shading[3];	/* +36 +40 +44 */
384   USHORT *black_shading[3];	/* +48 +52 +56 */
385   SANE_Int WRef[3];		/* +60 +62 +64 */
386   SANE_Byte shading_type;	/* +66 */
387   SANE_Byte shading_enabled;	/* +67 */
388   SANE_Int first_position;	/* +68 */
389   SANE_Int shadinglength;	/* +72 */
390 };
391 
392 struct st_cal2
393 {
394   /* f9f8  35 bytes */
395   SANE_Int table_count;		/* +0  f9f8 */
396   SANE_Int shadinglength1;	/* +4  f9fc */
397   SANE_Int tables_size;		/* +8  fa00 */
398   SANE_Int shadinglength3;	/* +12 fa04 */
399   USHORT *tables[4];		/* +16+20+24+28  fa08 fa0c fa10 fa14 */
400   USHORT *table2;		/* +32 fa18 */
401 };
402 
403 struct st_coords
404 {
405   SANE_Int left;
406   SANE_Int width;
407   SANE_Int top;
408   SANE_Int height;
409 };
410 
411 struct params
412 {
413   SANE_Int scantype;
414   SANE_Int colormode;
415   SANE_Int resolution_x;
416   SANE_Int resolution_y;
417   struct st_coords coords;
418   SANE_Int depth;
419   SANE_Int channel;
420 };
421 
422 struct st_constrains
423 {
424   struct st_coords reflective;
425   struct st_coords negative;
426   struct st_coords slide;
427 };
428 
429 struct st_scanparams		/* 44 bytes size */
430 {
431   /* 760-78b|155c-1587|fa58-fa83|f0c4 */
432   SANE_Byte colormode;		/* [+00] 760 */
433   SANE_Byte depth;		/* [+01] 761 */
434   SANE_Byte samplerate;		/* [+02] 762 */
435   SANE_Byte timing;		/* [+03] 763 */
436   SANE_Int channel;		/* [+04] 764 */
437   SANE_Int sensorresolution;	/* [+06] 766 */
438   SANE_Int resolution_x;	/* [+08] 768 */
439   SANE_Int resolution_y;	/* [+10] 76a */
440   struct st_coords coord;	/* [+12] left */
441   /* [+16] width */
442   /* [+20] top */
443   /* [+24] height */
444   SANE_Int shadinglength;	/* [+28] 77c */
445   SANE_Int v157c;		/* [+32] 780 */
446   SANE_Int bytesperline;	/* [+36] 784 */
447   SANE_Int expt;		/* [+40] 788 */
448 
449   SANE_Int startpos;		/* [+44] 78c */
450   SANE_Int leftleading;		/* [+46] 78e */
451   SANE_Int ser;			/* [+48] 790 */
452   SANE_Int ler;			/* [+52] 794 */
453   SANE_Int scantype;		/* [+58] 79a */
454 };
455 
456 struct st_hwdconfig		/* 28 bytes size */
457 {
458   /* fa84-fa9f|f0ac-f0c7|e838-e853|f3a4-f3bf */
459   SANE_Int startpos;		/* +0 */
460   /* +1..7 */
461   SANE_Byte arrangeline;	/* +8 */
462   SANE_Byte scantype;		/* +9 */
463   SANE_Byte compression;	/* +10 */
464   SANE_Byte use_gamma_tables;	/* +11 */
465   SANE_Byte gamma_tablesize;	/* +12 */
466   SANE_Byte white_shading;	/* +13 */
467   SANE_Byte black_shading;	/* +14 */
468   SANE_Byte unk3;		/* +15 */
469   SANE_Byte motorplus;		/* +16 */
470   SANE_Byte static_head;	/* +17 */
471   SANE_Byte motor_direction;	/* +18 */
472   SANE_Byte dummy_scan;		/* +19 */
473   SANE_Byte highresolution;	/* +20 */
474   SANE_Byte sensorevenodddistance;	/* +21 */
475   /* +22..23 */
476   SANE_Int calibrate;		/* +24 */
477 };
478 
479 struct st_calibration_data
480 {
481   SANE_Byte Regs[RT_BUFFER_LEN];
482   struct st_scanparams scancfg;
483   struct st_gain_offset gain_offset;
484 };
485 
486 struct st_cph
487 {
488   double p1;
489   double p2;
490   SANE_Byte ps;
491   SANE_Byte ge;
492   SANE_Byte go;
493 };
494 
495 struct st_timing
496 {
497   SANE_Int sensorresolution;
498   SANE_Byte cnpp;
499   SANE_Byte cvtrp[3];		/* 3 transfer gates */
500   SANE_Byte cvtrw;
501   SANE_Byte cvtrfpw;
502   SANE_Byte cvtrbpw;
503   struct st_cph cph[6];		/* Linear Image Sensor Clocks */
504   SANE_Int cphbp2s;
505   SANE_Int cphbp2e;
506   SANE_Int clamps;
507   SANE_Int clampe;
508   SANE_Byte cdss[2];
509   SANE_Byte cdsc[2];
510   SANE_Byte cdscs[2];		/* Toshiba T958 ccd from hp4370 */
511   double adcclkp[2];
512   SANE_Int adcclkp2e;
513 };
514 
515 struct st_scanmode
516 {
517   SANE_Int scantype;
518   SANE_Int colormode;
519   SANE_Int resolution;
520 
521   SANE_Byte timing;
522   SANE_Int motorcurve;
523   SANE_Byte samplerate;
524   SANE_Byte systemclock;
525   SANE_Int ctpc;
526   SANE_Int motorbackstep;
527   SANE_Byte scanmotorsteptype;
528 
529   SANE_Byte dummyline;
530   SANE_Int expt[3];
531   SANE_Int mexpt[3];
532   SANE_Int motorplus;
533   SANE_Int multiexposurefor16bitmode;
534   SANE_Int multiexposureforfullspeed;
535   SANE_Int multiexposure;
536   SANE_Int mri;
537   SANE_Int msi;
538   SANE_Int mmtir;
539   SANE_Int mmtirh;
540   SANE_Int skiplinecount;
541 };
542 
543 struct st_motormove
544 {
545   SANE_Byte systemclock;
546   SANE_Int ctpc;
547   SANE_Byte scanmotorsteptype;
548   SANE_Int motorcurve;
549 };
550 
551 struct st_motorpos
552 {
553   SANE_Int coord_y;
554   SANE_Byte options;
555   SANE_Int v12e448;
556   SANE_Int v12e44c;
557 };
558 
559 struct st_find_edge
560 {
561   SANE_Int exposuretime;
562   SANE_Int scanystart;
563   SANE_Int scanylines;
564   SANE_Int findlermethod;
565   SANE_Int findlerstart;
566   SANE_Int findlerend;
567   SANE_Int checkoffsetser;
568   SANE_Int findserchecklines;
569   SANE_Int findserstart;
570   SANE_Int findserend;
571   SANE_Int findsermethod;
572   SANE_Int offsettoser;
573   SANE_Int offsettoler;
574 };
575 
576 struct st_curve
577 {
578   SANE_Int crv_speed;		/* acceleration or deceleration */
579   SANE_Int crv_type;
580   SANE_Int step_count;
581   SANE_Int *step;
582 };
583 
584 struct st_motorcurve
585 {
586   SANE_Int mri;
587   SANE_Int msi;
588   SANE_Int skiplinecount;
589   SANE_Int motorbackstep;
590   SANE_Int curve_count;
591   struct st_curve **curve;
592 };
593 
594 struct st_checkstable
595 {
596   double diff;
597   SANE_Int interval;
598   long tottime;
599 };
600 
601 struct st_sensorcfg
602 {
603   SANE_Int type;
604   SANE_Int name;
605   SANE_Int resolution;
606 
607   SANE_Int channel_color[3];
608   SANE_Int channel_gray[2];
609   SANE_Int rgb_order[3];
610 
611   SANE_Int line_distance;
612   SANE_Int evenodd_distance;
613 };
614 
615 struct st_autoref
616 {
617   SANE_Byte type;
618   SANE_Int offset_x;
619   SANE_Int offset_y;
620   SANE_Int resolution;
621   SANE_Int extern_boundary;
622 };
623 
624 struct st_motorcfg
625 {
626   SANE_Byte type;
627   SANE_Int resolution;
628   SANE_Byte pwmfrequency;
629   SANE_Int basespeedpps;
630   SANE_Int basespeedmotormove;
631   SANE_Int highspeedmotormove;
632   SANE_Int parkhomemotormove;
633   SANE_Byte changemotorcurrent;
634 };
635 
636 struct st_buttons
637 {
638   SANE_Int count;
639   SANE_Int mask[6];		/* up to 6 buttons */
640 };
641 
642 struct st_status
643 {
644   SANE_Byte warmup;
645   SANE_Byte parkhome;
646   SANE_Byte cancel;
647 };
648 
649 struct st_device
650 {
651   /* next var handles usb device, used for every usb operations */
652   USB_Handle usb_handle;
653 
654   /* next buffer will contain initial state registers of the chipset */
655   SANE_Byte *init_regs;
656 
657   /* next structure will contain information and capabilities about chipset */
658   struct st_chip *chipset;
659 
660   /* next structure will contain general configuration of stepper motor */
661   struct st_motorcfg *motorcfg;
662 
663   /* next structure will contain general configuration of ccd sensor */
664   struct st_sensorcfg *sensorcfg;
665 
666   /* next structure will contain all ccd timing values */
667   SANE_Int timings_count;
668   struct st_timing **timings;
669 
670   /* next structure will contain all possible motor movements */
671   SANE_Int motormove_count;
672   struct st_motormove **motormove;
673 
674   /* next structure will contain all motorcurve values */
675   SANE_Int mtrsetting_count;
676   struct st_motorcurve **mtrsetting;
677 
678   /* next structure will contain all possible scanning modes for one scanner */
679   SANE_Int scanmodes_count;
680   struct st_scanmode **scanmodes;
681 
682   /* next structure contains constrain values for one scanner */
683   struct st_constrains *constrains;
684 
685   /* next structure contains supported buttons and their order */
686   struct st_buttons *buttons;
687 
688   /* next structure will be used to resize scanned image */
689   struct st_resize *Resize;
690 
691   /* next structure will be used while reading image from device */
692   struct st_readimage *Reading;
693 
694   /* next structure will be used to arrange color channels while scanning */
695   struct st_scanning *scanning;
696 
697   /* next structure will contain some status which can be requested */
698   struct st_status *status;
699 };
700 
701 /* Unknown vars */
702 SANE_Int v14b4 = 0;
703 SANE_Byte *v1600 = NULL;	/* tabla */
704 SANE_Byte *v1604 = NULL;	/* tabla */
705 SANE_Byte *v1608 = NULL;	/* tabla */
706 SANE_Byte v160c_block_size;
707 SANE_Int mem_total;
708 SANE_Byte v1619;
709 SANE_Int v15f8;
710 
711 SANE_Int acccurvecount;		/* counter used y MotorSetup */
712 SANE_Int deccurvecount;		/* counter used y MotorSetup */
713 SANE_Int smearacccurvecount;	/* counter used y MotorSetup */
714 SANE_Int smeardeccurvecount;	/* counter used y MotorSetup */
715 
716 /* Known vars */
717 SANE_Int offset[3];
718 SANE_Byte gain[3];
719 
720 static SANE_Int usbfile = -1;
721 SANE_Int scantype;
722 
723 SANE_Byte pwmlamplevel;
724 
725 SANE_Byte arrangeline;
726 SANE_Byte binarythresholdh;
727 SANE_Byte binarythresholdl;
728 
729 SANE_Byte shadingbase;
730 SANE_Byte shadingfact[3];
731 SANE_Byte arrangeline;
732 SANE_Int compression;
733 
734 SANE_Byte linedarlampoff;
735 SANE_Int pixeldarklevel;
736 
737 SANE_Int bw_threshold = 0x00;
738 
739 /* SetScanParams */
740 struct st_scanparams scan;
741 struct st_scanparams scan2;
742 
743 SANE_Int bytesperline;		/* width * (3 colors [RGB]) */
744 SANE_Int imagewidth3;
745 SANE_Int lineart_width;
746 SANE_Int imagesize;		/* bytesperline * coords.height */
747 SANE_Int imageheight;
748 SANE_Int line_size;
749 SANE_Int v15b4;
750 SANE_Int v15bc;
751 SANE_Int waitforpwm;
752 
753 SANE_Byte WRef[3];
754 
755 USHORT *fixed_black_shading[3] = { NULL, NULL, NULL };
756 USHORT *fixed_white_shading[3] = { NULL, NULL, NULL };
757 
758 /* Calibration */
759 struct st_gain_offset mitabla2;	/* calibration table */
760 SANE_Int v0750;
761 
762 static SANE_Byte use_gamma_tables;
763 
764 SANE_Int read_v15b4 = 0;
765 
766 SANE_Int v35b8 = 0;
767 SANE_Int arrangeline2;
768 
769 SANE_Int v07c0 = 0;
770 
771 /* next structure contains coefficients for white shading correction */
772 struct st_shading *wshading;
773 
774 struct st_gammatables *hp_gamma;
775 struct st_gain_offset *default_gain_offset;
776 struct st_calibration_data *calibdata;
777 
778 struct st_debug_opts *RTS_Debug;
779 
780 /* testing */
781 SANE_Byte *jkd_black = NULL;
782 SANE_Int jkd_blackbpl;
783