• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef FUJITSU_H
2 #define FUJITSU_H
3 
4 /*
5  * Part of SANE - Scanner Access Now Easy.
6  * Please see opening comment in fujitsu.c
7  */
8 
9 /* -------------------------------------------------------------------------
10  * This option list has to contain all options for all scanners supported by
11  * this driver. If a certain scanner cannot handle a certain option, there's
12  * still the possibility to say so, later.
13  */
14 enum fujitsu_Option
15 {
16   OPT_NUM_OPTS = 0,
17 
18   OPT_STANDARD_GROUP,
19   OPT_SOURCE, /*fb/adf/front/back/duplex*/
20   OPT_MODE,   /*mono/gray/color*/
21   OPT_RES,    /*a range or a list*/
22 
23   OPT_GEOMETRY_GROUP,
24   OPT_PAGE_WIDTH,
25   OPT_PAGE_HEIGHT,
26   OPT_TL_X,
27   OPT_TL_Y,
28   OPT_BR_X,
29   OPT_BR_Y,
30 
31   OPT_ENHANCEMENT_GROUP,
32   OPT_BRIGHTNESS,
33   OPT_CONTRAST,
34   OPT_GAMMA,
35   OPT_THRESHOLD,
36 
37   /*IPC*/
38   OPT_RIF,
39   OPT_HT_TYPE,
40   OPT_HT_PATTERN,
41   OPT_OUTLINE,
42   OPT_EMPHASIS,
43   OPT_SEPARATION,
44   OPT_MIRRORING,
45   OPT_WL_FOLLOW,
46 
47   /*IPC/DTC*/
48   OPT_BP_FILTER,
49   OPT_SMOOTHING,
50   OPT_GAMMA_CURVE,
51   OPT_THRESHOLD_CURVE,
52   OPT_THRESHOLD_WHITE,
53   OPT_NOISE_REMOVAL,
54   OPT_MATRIX_5,
55   OPT_MATRIX_4,
56   OPT_MATRIX_3,
57   OPT_MATRIX_2,
58 
59   /*IPC/SDTC*/
60   OPT_VARIANCE,
61 
62   OPT_ADVANCED_GROUP,
63   OPT_AWD,
64   OPT_ALD,
65   OPT_COMPRESS,
66   OPT_COMPRESS_ARG,
67   OPT_DF_ACTION,
68   OPT_DF_SKEW,
69   OPT_DF_THICKNESS,
70   OPT_DF_LENGTH,
71   OPT_DF_DIFF,
72   OPT_DF_RECOVERY,
73   OPT_PAPER_PROTECT,
74   OPT_ADV_PAPER_PROT,
75   OPT_STAPLE_DETECT,
76   OPT_BG_COLOR,
77   OPT_DROPOUT_COLOR,
78   OPT_BUFF_MODE,
79   OPT_PREPICK,
80   OPT_OVERSCAN,
81   OPT_SLEEP_TIME,
82   OPT_OFF_TIME,
83   OPT_DUPLEX_OFFSET,
84   OPT_GREEN_OFFSET,
85   OPT_BLUE_OFFSET,
86   OPT_LOW_MEM,
87   OPT_SIDE,
88   OPT_HWDESKEWCROP,
89   OPT_SWDESKEW,
90   OPT_SWDESPECK,
91   OPT_SWCROP,
92   OPT_SWSKIP,
93   OPT_HALT_ON_CANCEL,
94 
95   OPT_ENDORSER_GROUP,
96   OPT_ENDORSER,
97   OPT_ENDORSER_BITS,
98   OPT_ENDORSER_VAL,
99   OPT_ENDORSER_STEP,
100   OPT_ENDORSER_Y,
101   OPT_ENDORSER_FONT,
102   OPT_ENDORSER_DIR,
103   OPT_ENDORSER_SIDE,
104   OPT_ENDORSER_STRING,
105 
106   OPT_SENSOR_GROUP,
107   OPT_TOP,
108   OPT_A3,
109   OPT_B4,
110   OPT_A4,
111   OPT_B5,
112   OPT_HOPPER,
113   OPT_OMR,
114   OPT_ADF_OPEN,
115   OPT_CARD_LOADED,
116   OPT_SLEEP,
117   OPT_SEND_SW,
118   OPT_MANUAL_FEED,
119   OPT_SCAN_SW,
120   OPT_FUNCTION,
121   OPT_INK_EMPTY,
122   OPT_DOUBLE_FEED,
123   OPT_ERROR_CODE,
124   OPT_SKEW_ANGLE,
125   OPT_INK_REMAIN,
126   OPT_DUPLEX_SW,
127   OPT_DENSITY_SW,
128 
129   /* must come last: */
130   NUM_OPTIONS
131 };
132 
133 /* used to control the max page-height, which varies by resolution */
134 struct y_size
135 {
136   int res;
137   int len;
138 };
139 
140 struct fujitsu
141 {
142   /* --------------------------------------------------------------------- */
143   /* immutable values which are set during init of scanner.                */
144   struct fujitsu *next;
145   char device_name[1024];             /* The name of the device from sanei */
146   int missing; 				/* used to mark unplugged scanners */
147 
148   /* --------------------------------------------------------------------- */
149   /* immutable values which are set during reading of config file.         */
150   int buffer_size;
151   int connection;               /* hardware interface type */
152 
153   /* --------------------------------------------------------------------- */
154   /* immutable values which are set during inquiry probing of the scanner. */
155   /* members in order found in scsi data...                                */
156   char vendor_name[9];          /* raw data as returned by SCSI inquiry.   */
157   char model_name[17];          /* raw data as returned by SCSI inquiry.   */
158   char version_name[5];         /* raw data as returned by SCSI inquiry.   */
159 
160   int color_raster_offset;      /* offset between r and b scan line and    */
161                                 /* between b and g scan line (0 or 4)      */
162 
163   int duplex_raster_offset;     /* offset between front and rear page when */
164                                 /* when scanning 3091 style duplex         */
165 
166   /* --------------------------------------------------------------------- */
167   /* immutable values which are set during std VPD probing of the scanner. */
168   /* members in order found in scsi data...                                */
169   int basic_x_res;
170   int basic_y_res;
171   int step_x_res[6]; /*one for each mode*/
172   int step_y_res[6]; /*one for each mode*/
173   int max_x_res;
174   int max_y_res;
175   int min_x_res;
176   int min_y_res;
177 
178   int std_res[16]; /*some scanners only support a few resolutions*/
179 
180   /* max scan size in pixels comes from scanner in basic res units */
181   int max_x_basic;
182   int max_y_basic;
183 
184   int can_overflow;
185   int can_mode[6]; /* mode specific */
186 
187   /* --------------------------------------------------------------------- */
188   /* immutable values which are set during vndr VPD probing of the scanner */
189   /* members in order found in scsi data...                                */
190   int has_adf;
191   int has_flatbed;
192   int has_transparency;
193   int has_duplex;
194   int has_endorser_b;
195   int has_barcode;
196   int has_operator_panel;
197   int has_endorser_f;
198 
199   int adbits;
200   int buffer_bytes;
201 
202   /*supported scsi commands*/
203   int has_cmd_msen10;
204   int has_cmd_msel10;
205 
206   int has_cmd_lsen;
207   int has_cmd_lsel;
208   int has_cmd_change;
209   int has_cmd_rbuff;
210   int has_cmd_wbuff;
211   int has_cmd_cav;
212   int has_cmd_comp;
213   int has_cmd_gdbs;
214 
215   int has_cmd_op;
216   int has_cmd_send;
217   int has_cmd_read;
218   int has_cmd_gwin;
219   int has_cmd_swin;
220   int has_cmd_sdiag;
221   int has_cmd_rdiag;
222   int has_cmd_scan;
223 
224   int has_cmd_msen6;
225   int has_cmd_copy;
226   int has_cmd_rel;
227   int has_cmd_runit;
228   int has_cmd_msel6;
229   int has_cmd_inq;
230   int has_cmd_rs;
231   int has_cmd_tur;
232 
233   /*FIXME: there are more vendor cmds? */
234   int has_cmd_subwindow;
235   int has_cmd_endorser;
236   int has_cmd_hw_status;
237   int has_cmd_hw_status_2;
238   int has_cmd_hw_status_3;
239   int has_cmd_scanner_ctl;
240   int has_cmd_device_restart;
241 
242   /*FIXME: do we need the vendor window param list? */
243 
244   int brightness_steps;
245   int threshold_steps;
246   int contrast_steps;
247 
248   int num_internal_gamma;
249   int num_download_gamma;
250   int num_internal_dither;
251   int num_download_dither;
252 
253   int has_df_recovery;
254   int has_paper_protect;
255   int has_adv_paper_prot;
256   int has_staple_detect;
257 
258   int has_rif;
259   int has_dtc;
260   int has_sdtc;
261   int has_outline;
262   int has_emphasis;
263   int has_autosep;
264   int has_mirroring;
265   int has_wl_follow;
266   int has_subwindow;
267   int has_diffusion;
268   int has_ipc3;
269   int has_rotation;
270   int has_hybrid_crop_deskew;
271   int has_off_mode;
272 
273   int has_comp_MH;
274   int has_comp_MR;
275   int has_comp_MMR;
276   int has_comp_JBIG;
277   int has_comp_JPG1;
278   int has_comp_JPG2;
279   int has_comp_JPG3;
280   int has_op_halt;
281   int has_return_path;
282 
283   /*FIXME: more endorser data? */
284   int endorser_type_f;
285   int endorser_type_b;
286 
287   /*FIXME: barcode data? */
288 
289   /* overscan size in pixels comes from scanner in basic res units */
290   int os_x_basic;
291   int os_y_basic;
292 
293   /* --------------------------------------------------------------------- */
294   /* immutable values which are gathered by mode_sense command     */
295 
296   int has_MS_autocolor;
297   int has_MS_prepick;
298   int has_MS_sleep;
299   int has_MS_duplex;
300   int has_MS_rand;
301   int has_MS_bg;
302   int has_MS_df;
303   int has_MS_dropout; /* dropout color specified in mode select data */
304   int has_MS_buff;
305   int has_MS_auto;
306   int has_MS_lamp;
307   int has_MS_jobsep;
308 
309   /* --------------------------------------------------------------------- */
310   /* immutable values which are hard coded because they are not in vpd     */
311   /* this section replaces all the old 'switch (s->model)' code            */
312 
313   /* the scan size in 1/1200th inches, NOT basic_units or sane units */
314   int max_x;
315   int max_y;
316   struct y_size max_y_by_res[4];
317   int min_x;
318   int min_y;
319   int max_x_fb;
320   int max_y_fb;
321 
322   int has_back;         /* not all duplex scanners can do adf back side only */
323   int color_interlace;  /* different models interlace colors differently     */
324   int duplex_interlace; /* different models interlace sides differently      */
325   int jpeg_interlace;   /* different models interlace jpeg sides differently */
326   int cropping_mode;    /* lower-end scanners don't crop from paper size      */
327   int ghs_in_rs;
328   int endorser_string_len;
329   int has_pixelsize;
330   int has_short_pixelsize; /* m3091/2 put weird stuff at end, ignore it */
331 
332   int broken_diag_serial;   /* some scanners are just plain borked */
333   int need_q_table;         /* some scanners won't work without these */
334   int need_diag_preread;
335   int hopper_before_op;     /* some scanners don't like OP when hopper empty */
336   int no_wait_after_op;     /* some scanners don't like TUR after OP */
337 
338   int has_vuid_mono;    /* mono set window data */
339   int has_vuid_3091;    /* 3091/2 set window data */
340   int has_vuid_color;   /* color set window data */
341 
342   int reverse_by_mode[6]; /* mode specific */
343   int ppl_mod_by_mode[6]; /* mode specific scanline length limitation */
344 
345   /* --------------------------------------------------------------------- */
346   /* immutable values which are set during serial number probing scanner   */
347   char serial_name[28];        /* 16 char model, ':', 10 byte serial, null */
348 
349   /* --------------------------------------------------------------------- */
350   /* struct with pointers to device/vendor/model names, and a type value */
351   /* used to inform sane frontend about the device */
352   SANE_Device sane;
353 
354   /* --------------------------------------------------------------------- */
355   /* changeable SANE_Option structs provide our interface to frontend.     */
356   /* some options require lists of strings or numbers, we keep them here   */
357   /* instead of in global vars so that they can differ for each scanner    */
358 
359   /* long array of option structs */
360   SANE_Option_Descriptor opt[NUM_OPTIONS];
361 
362   /*mode group*/
363   SANE_String_Const mode_list[7];
364   SANE_String_Const source_list[8];
365 
366   SANE_Int res_list[17];
367   SANE_Range res_range;
368 
369   /*geometry group*/
370   SANE_Range tl_x_range;
371   SANE_Range tl_y_range;
372   SANE_Range br_x_range;
373   SANE_Range br_y_range;
374   SANE_Range paper_x_range;
375   SANE_Range paper_y_range;
376 
377   /*enhancement group*/
378   SANE_Range brightness_range;
379   SANE_Range contrast_range;
380   SANE_Range gamma_range;
381   SANE_Range threshold_range;
382 
383   /*ipc group*/
384   SANE_String_Const ht_type_list[4];
385   SANE_Range ht_pattern_range;
386   SANE_Range emphasis_range;
387   SANE_String_Const wl_follow_list[4];
388   SANE_Range gamma_curve_range;
389   SANE_Range threshold_curve_range;
390   SANE_Range variance_range;
391 
392   /*advanced group*/
393   SANE_String_Const compress_list[3];
394   SANE_Range compress_arg_range;
395   SANE_String_Const df_action_list[4];
396   SANE_String_Const df_diff_list[5];
397   SANE_String_Const df_recovery_list[4];
398   SANE_String_Const paper_protect_list[4];
399   SANE_String_Const adv_paper_prot_list[4];
400   SANE_String_Const staple_detect_list[4];
401   SANE_String_Const bg_color_list[4];
402   SANE_String_Const do_color_list[5];
403   SANE_String_Const lamp_color_list[5];
404   SANE_String_Const buff_mode_list[4];
405   SANE_String_Const prepick_list[4];
406   SANE_String_Const overscan_list[4];
407   SANE_Range sleep_time_range;
408   SANE_Range off_time_range;
409   SANE_Range duplex_offset_range;
410   SANE_Range green_offset_range;
411   SANE_Range blue_offset_range;
412   SANE_Range swdespeck_range;
413   SANE_Range swskip_range;
414 
415   /*endorser group*/
416   SANE_Range endorser_bits_range;
417   SANE_Range endorser_val_range;
418   SANE_Range endorser_step_range;
419   SANE_Range endorser_y_range;
420   SANE_String_Const endorser_font_list[6];
421   SANE_String_Const endorser_dir_list[3];
422   SANE_String_Const endorser_side_list[3];
423 
424   /* --------------------------------------------------------------------- */
425   /* changeable vars to hold user input. modified by SANE_Options above    */
426 
427   /*mode group*/
428   int u_mode;         /*color,lineart,etc*/
429   int source;         /*fb,adf front,adf duplex,etc*/
430   int resolution_x;   /* X resolution in dpi                       */
431   int resolution_y;   /* Y resolution in dpi                       */
432 
433   /*geometry group*/
434   /* The desired size of the scan, all in 1/1200 inch */
435   int tl_x;
436   int tl_y;
437   int br_x;
438   int br_y;
439   int page_width;
440   int page_height;
441 
442   /*enhancement group*/
443   int brightness;
444   int contrast;
445   double gamma;
446   int threshold;
447 
448   /* ipc */
449   int rif;
450   int ht_type;
451   int ht_pattern;
452   int outline;
453   int emphasis;
454   int separation;
455   int mirroring;
456   int wl_follow;
457 
458   /* ipc_mode=DTC */
459   int bp_filter;
460   int smoothing;
461   int gamma_curve;
462   int threshold_curve;
463   int threshold_white;
464   int noise_removal;
465   int matrix_5;
466   int matrix_4;
467   int matrix_3;
468   int matrix_2;
469 
470   /* ipc_mode = SDTC */
471   int variance;
472 
473   /*advanced group*/
474   int awd;
475   int ald;
476   int compress;
477   int compress_arg;
478   int df_action;
479   int df_skew;
480   int df_thickness;
481   int df_length;
482   int df_diff;
483   int df_recovery;
484   int paper_protect;
485   int adv_paper_prot;
486   int staple_detect;
487   int bg_color;
488   int dropout_color;
489   int buff_mode;
490   int prepick;
491   int overscan;
492   int lamp_color;
493   int sleep_time;
494   int off_time;
495   int duplex_offset;
496   int green_offset;
497   int blue_offset;
498   int low_mem;
499   int hwdeskewcrop;
500   int swdeskew;
501   int swdespeck;
502   int swcrop;
503   double swskip;
504   int halt_on_cancel;
505 
506   /*endorser group*/
507   int u_endorser;
508   int u_endorser_bits;
509   int u_endorser_val;
510   int u_endorser_step;
511   int u_endorser_y;
512   int u_endorser_font;
513   int u_endorser_dir;
514   int u_endorser_side;
515   char u_endorser_string[81]; /*max length, plus null byte*/
516 
517   /* --------------------------------------------------------------------- */
518   /* values which are derived from setting the options above */
519   /* the user never directly modifies these */
520 
521   int s_mode; /*color,lineart,etc: sent to scanner*/
522   int window_gamma; /* depends on brightness/contrast and lut */
523 
524   /* this is defined in sane spec as a struct containing:
525 	SANE_Frame format;
526 	SANE_Bool last_frame;
527 	SANE_Int lines;
528 	SANE_Int depth; ( binary=1, gray=8, color=8 (!24) )
529 	SANE_Int pixels_per_line;
530 	SANE_Int bytes_per_line;
531   */
532   SANE_Parameters u_params;
533   SANE_Parameters s_params;
534 
535   /* --------------------------------------------------------------------- */
536   /* values which are set by scanning functions to keep track of pages, etc */
537   int started;
538   int reading;
539   int cancelled;
540   int side;
541 
542   /* total to read/write */
543   int bytes_tot[2];
544 
545   /* how far we have read */
546   int bytes_rx[2];
547   int lines_rx[2]; /*only used by 3091*/
548   int eof_rx[2];
549   int ili_rx[2];
550   int eom_rx;
551 
552   /* how far we have written */
553   int bytes_tx[2];
554   int eof_tx[2];
555 
556   /*size of buffers (can be smaller than above*/
557   int buff_tot[2];
558   int buff_rx[2];
559   int buff_tx[2];
560 
561   unsigned char * buffers[2];
562 
563   /* --------------------------------------------------------------------- */
564   /*hardware feature bookkeeping*/
565   int req_driv_crop;
566   int req_driv_lut;
567 
568   /* --------------------------------------------------------------------- */
569   /* values used by the software enhancement code (deskew, crop, etc)      */
570   SANE_Status deskew_stat;
571   int deskew_vals[2];
572   double deskew_slope;
573 
574   int crop_vals[4];
575 
576   /* --------------------------------------------------------------------- */
577   /* values used by the compression functions, esp. jpeg with duplex       */
578   int jpeg_stage;
579   int jpeg_ff_offset;
580   int jpeg_front_rst;
581   int jpeg_back_rst;
582   int jpeg_x_byte;
583 
584   /* --------------------------------------------------------------------- */
585   /* values which used by the command and data sending functions (scsi/usb)*/
586   int fd;                      /* The scanner device file descriptor.     */
587   size_t rs_info;
588   int rs_eom;
589   int rs_ili;
590 
591   /* --------------------------------------------------------------------- */
592   /* values which are used by the get hardware status command              */
593 
594   int hw_top;
595   int hw_A3;
596   int hw_B4;
597   int hw_A4;
598   int hw_B5;
599 
600   int hw_hopper;
601   int hw_omr;
602   int hw_adf_open;
603   int hw_card_loaded;
604 
605   int hw_sleep;
606   int hw_send_sw;
607   int hw_manual_feed;
608   int hw_scan_sw;
609 
610   int hw_function;
611 
612   int hw_ink_empty;
613   int hw_double_feed;
614 
615   int hw_error_code;
616   int hw_skew_angle;
617   int hw_ink_remain;
618 
619   int hw_duplex_sw;
620   int hw_density_sw;
621 
622   /* values which are used to track the frontend's access to sensors  */
623   char hw_data_avail[NUM_OPTIONS-OPT_TOP];
624 };
625 
626 #define CONNECTION_SCSI   0 /* SCSI interface */
627 #define CONNECTION_USB    1 /* USB interface */
628 
629 #define SIDE_FRONT 0
630 #define SIDE_BACK 1
631 
632 #define SOURCE_FLATBED 0
633 #define SOURCE_ADF_FRONT 1
634 #define SOURCE_ADF_BACK 2
635 #define SOURCE_ADF_DUPLEX 3
636 #define SOURCE_CARD_FRONT 4
637 #define SOURCE_CARD_BACK 5
638 #define SOURCE_CARD_DUPLEX 6
639 
640 #define COMP_NONE WD_cmp_NONE
641 #define COMP_JPEG WD_cmp_JPG1
642 
643 #define JPEG_STAGE_NONE 0
644 #define JPEG_STAGE_SOI 1
645 #define JPEG_STAGE_HEAD 2
646 #define JPEG_STAGE_SOF 3
647 #define JPEG_STAGE_SOS 4
648 #define JPEG_STAGE_FRONT 5
649 #define JPEG_STAGE_BACK 6
650 #define JPEG_STAGE_EOI 7
651 
652 #define JFIF_APP0_LENGTH 18
653 
654 /* these are same as scsi data to make code easier */
655 #define MODE_LINEART WD_comp_LA
656 #define MODE_HALFTONE WD_comp_HT
657 #define MODE_GRAYSCALE WD_comp_GS
658 #define MODE_COLOR_LINEART WD_comp_CL
659 #define MODE_COLOR_HALFTONE WD_comp_CH
660 #define MODE_COLOR WD_comp_CG
661 
662 /* these are same as dropout scsi data to make code easier */
663 #define COLOR_DEFAULT 0
664 #define COLOR_GREEN 8
665 #define COLOR_RED 9
666 #define COLOR_BLUE 11
667 
668 #define COLOR_WHITE 1
669 #define COLOR_BLACK 2
670 
671 #define COLOR_INTERLACE_UNK 0
672 #define COLOR_INTERLACE_RGB 1
673 #define COLOR_INTERLACE_BGR 2
674 #define COLOR_INTERLACE_RRGGBB 3
675 #define COLOR_INTERLACE_3091 4
676 
677 #define DUPLEX_INTERLACE_ALT 0
678 #define DUPLEX_INTERLACE_NONE 1
679 #define DUPLEX_INTERLACE_3091 2
680 
681 #define JPEG_INTERLACE_ALT 0
682 #define JPEG_INTERLACE_NONE 1
683 
684 #define CROP_RELATIVE 0
685 #define CROP_ABSOLUTE 1
686 
687 #define DF_DEFAULT 0
688 #define DF_CONTINUE 1
689 #define DF_STOP 2
690 
691 #define FONT_H  0
692 #define FONT_HB 1
693 #define FONT_HN 2
694 #define FONT_V  3
695 #define FONT_VB 4
696 
697 #define DIR_TTB 0
698 #define DIR_BTT 1
699 
700 /* endorser type, same as scsi inquiry data */
701 #define ET_OLD	0
702 #define ET_30	1
703 #define ET_40	2
704 
705 /* ------------------------------------------------------------------------- */
706 
707 #define MM_PER_UNIT_UNFIX SANE_UNFIX(SANE_FIX(MM_PER_INCH / 1200.0))
708 #define MM_PER_UNIT_FIX SANE_FIX(SANE_UNFIX(SANE_FIX(MM_PER_INCH / 1200.0)))
709 
710 #define SCANNER_UNIT_TO_FIXED_MM(number) SANE_FIX((number) * MM_PER_UNIT_UNFIX)
711 #define FIXED_MM_TO_SCANNER_UNIT(number) SANE_UNFIX(number) / MM_PER_UNIT_UNFIX
712 
713 #define FUJITSU_CONFIG_FILE "fujitsu.conf"
714 
715 #ifndef PATH_MAX
716 #  define PATH_MAX 1024
717 #endif
718 
719 /* ------------------------------------------------------------------------- */
720 
721 SANE_Status sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize);
722 
723 SANE_Status sane_get_devices (const SANE_Device *** device_list,
724                               SANE_Bool local_only);
725 
726 SANE_Status sane_open (SANE_String_Const name, SANE_Handle * handle);
727 
728 SANE_Status sane_set_io_mode (SANE_Handle h, SANE_Bool non_blocking);
729 
730 SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fdp);
731 
732 const SANE_Option_Descriptor * sane_get_option_descriptor (SANE_Handle handle,
733                                                           SANE_Int option);
734 
735 SANE_Status sane_control_option (SANE_Handle handle, SANE_Int option,
736                                  SANE_Action action, void *val,
737                                  SANE_Int * info);
738 
739 SANE_Status sane_start (SANE_Handle handle);
740 
741 SANE_Status sane_get_parameters (SANE_Handle handle,
742                                  SANE_Parameters * params);
743 
744 SANE_Status sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len,
745                        SANE_Int * len);
746 
747 void sane_cancel (SANE_Handle h);
748 
749 void sane_close (SANE_Handle h);
750 
751 void sane_exit (void);
752 
753 /* ------------------------------------------------------------------------- */
754 
755 static SANE_Status attach_one_scsi (const char *name);
756 static SANE_Status attach_one_usb (const char *name);
757 static SANE_Status attach_one (const char *devicename, int connType);
758 
759 static SANE_Status connect_fd (struct fujitsu *s);
760 static SANE_Status disconnect_fd (struct fujitsu *s);
761 
762 static SANE_Status sense_handler (int scsi_fd, u_char * result, void *arg);
763 
764 static SANE_Status init_inquire (struct fujitsu *s);
765 static SANE_Status init_vpd (struct fujitsu *s);
766 static SANE_Status init_ms (struct fujitsu *s);
767 static SANE_Status init_model (struct fujitsu *s);
768 static SANE_Status init_user (struct fujitsu *s);
769 static SANE_Status init_options (struct fujitsu *scanner);
770 static SANE_Status init_interlace (struct fujitsu *scanner);
771 static SANE_Status init_serial (struct fujitsu *scanner);
772 
773 static SANE_Status
774 do_cmd(struct fujitsu *s, int runRS, int shortTime,
775  unsigned char * cmdBuff, size_t cmdLen,
776  unsigned char * outBuff, size_t outLen,
777  unsigned char * inBuff, size_t * inLen
778 );
779 
780 static SANE_Status
781 do_scsi_cmd(struct fujitsu *s, int runRS, int shortTime,
782  unsigned char * cmdBuff, size_t cmdLen,
783  unsigned char * outBuff, size_t outLen,
784  unsigned char * inBuff, size_t * inLen
785 );
786 
787 static SANE_Status
788 do_usb_cmd(struct fujitsu *s, int runRS, int shortTime,
789  unsigned char * cmdBuff, size_t cmdLen,
790  unsigned char * outBuff, size_t outLen,
791  unsigned char * inBuff, size_t * inLen
792 );
793 
794 static SANE_Status wait_scanner (struct fujitsu *s);
795 
796 static SANE_Status object_position (struct fujitsu *s, int action);
797 
798 static SANE_Status scanner_control (struct fujitsu *s, int function);
799 static SANE_Status scanner_control_ric (struct fujitsu *s, int bytes, int side);
800 
801 static SANE_Status mode_select_df(struct fujitsu *s);
802 
803 static SANE_Status mode_select_dropout(struct fujitsu *s);
804 
805 static SANE_Status mode_select_bg(struct fujitsu *s);
806 
807 static SANE_Status mode_select_buff (struct fujitsu *s);
808 
809 static SANE_Status mode_select_prepick (struct fujitsu *s);
810 
811 static SANE_Status mode_select_auto (struct fujitsu *s);
812 
813 static SANE_Status set_sleep_mode(struct fujitsu *s);
814 static SANE_Status set_off_mode(struct fujitsu *s);
815 
816 static int must_downsample (struct fujitsu *s);
817 static int must_fully_buffer (struct fujitsu *s);
818 static int get_page_width (struct fujitsu *s);
819 static int get_page_height (struct fujitsu *s);
820 static int get_ipc_mode (struct fujitsu *s);
821 static int set_max_y (struct fujitsu *s);
822 
823 static SANE_Status send_lut (struct fujitsu *s);
824 static SANE_Status send_endorser (struct fujitsu *s);
825 static SANE_Status endorser (struct fujitsu *s);
826 static SANE_Status set_window (struct fujitsu *s);
827 static SANE_Status get_pixelsize(struct fujitsu *s, int actual);
828 
829 static SANE_Status update_params (struct fujitsu *s);
830 static SANE_Status update_u_params (struct fujitsu *s);
831 
832 static SANE_Status start_scan (struct fujitsu *s);
833 
834 static SANE_Status check_for_cancel(struct fujitsu *s);
835 
836 static SANE_Status read_from_JPEGduplex(struct fujitsu *s);
837 static SANE_Status read_from_3091duplex(struct fujitsu *s);
838 static SANE_Status read_from_scanner(struct fujitsu *s, int side);
839 
840 static SANE_Status copy_3091(struct fujitsu *s, unsigned char * buf, int len, int side);
841 static SANE_Status copy_JPEG(struct fujitsu *s, unsigned char * buf, int len, int side);
842 static SANE_Status copy_buffer(struct fujitsu *s, unsigned char * buf, int len, int side);
843 
844 static SANE_Status read_from_buffer(struct fujitsu *s, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len, int side);
845 static SANE_Status downsample_from_buffer(struct fujitsu *s, SANE_Byte * buf, SANE_Int max_len, SANE_Int * len, int side);
846 
847 static SANE_Status setup_buffers (struct fujitsu *s);
848 
849 static SANE_Status get_hardware_status (struct fujitsu *s, SANE_Int option);
850 
851 static SANE_Status buffer_deskew(struct fujitsu *s, int side);
852 static SANE_Status buffer_crop(struct fujitsu *s, int side);
853 static SANE_Status buffer_despeck(struct fujitsu *s, int side);
854 static int buffer_isblank(struct fujitsu *s, int side);
855 
856 static void hexdump (int level, char *comment, unsigned char *p, int l);
857 
858 static size_t maxStringSize (const SANE_String_Const strings[]);
859 
860 #endif /* FUJITSU_H */
861