~ubuntu-branches/ubuntu/saucy/sane-backends/saucy

« back to all changes in this revision

Viewing changes to backend/genesys_low.h

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2011-02-14 14:28:56 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110214142856-6gxjetg88q9zctid
Tags: 1.0.22-0ubuntu1
* New upstream release
* debian/control:
  - Use standards version 3.9.1
* debian/patches/allow_dll.d_symlinks.patch:
* debian/patches/fix_epson2_cancel.patch:
* debian/patches/fix_epson2_commands.patch:
* debian/patches/fix_xerox_mfp_color_mode.patch:
* debian/patches/genesys_disable_raw_data_log.patch:
* debian/patches/no_translations.patch:
* debian/patches/saned_exit_avahi_process.patch:
* debian/patches/scsi_perfection_2450.patch:
* debian/patches/scsi_scanjet_4c.patch:
* debian/patches/xerox_mfp_new_ids.patch:
  - Applied upstream
* debian/watch:
  - Dropped, the URL is not consistent between releases

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
    if (status != SANE_STATUS_GOOD) return status;      \
73
73
  } while (SANE_FALSE)
74
74
 
 
75
#define DBGSTART DBG (DBG_proc, "%s start\n", __FUNCTION__);
 
76
#define DBGCOMPLETED DBG (DBG_proc, "%s completed\n", __FUNCTION__);
75
77
 
76
78
/* Flags */
77
 
#define GENESYS_FLAG_UNTESTED     (1 << 0)      /* Print a warning for these scanners */
78
 
#define GENESYS_FLAG_14BIT_GAMMA  (1 << 1)      /* use 14bit Gamma table instead of 12 */
79
 
#define GENESYS_FLAG_LAZY_INIT    (1 << 2)      /* skip extensive ASIC test at init   */
 
79
#define GENESYS_FLAG_UNTESTED     (1 << 0)      /**> Print a warning for these scanners */
 
80
#define GENESYS_FLAG_14BIT_GAMMA  (1 << 1)      /**> use 14bit Gamma table instead of 12 */
 
81
#define GENESYS_FLAG_LAZY_INIT    (1 << 2)      /**> skip extensive ASIC test at init   */
80
82
#define GENESYS_FLAG_XPA          (1 << 3)
81
 
#define GENESYS_FLAG_SKIP_WARMUP  (1 << 4)      /* skip genesys_warmup()              */
82
 
#define GENESYS_FLAG_OFFSET_CALIBRATION   (1 << 5)      /* do offset calibration      */
83
 
#define GENESYS_FLAG_SEARCH_START (1 << 6)      /* do start search beofre scanning    */
84
 
#define GENESYS_FLAG_REPARK       (1 << 7)      /* repark head (and check for lock) by 
 
83
#define GENESYS_FLAG_SKIP_WARMUP  (1 << 4)      /**> skip genesys_warmup()              */
 
84
#define GENESYS_FLAG_OFFSET_CALIBRATION   (1 << 5)      /**> do offset calibration      */
 
85
#define GENESYS_FLAG_SEARCH_START (1 << 6)      /**> do start search before scanning    */
 
86
#define GENESYS_FLAG_REPARK       (1 << 7)      /**> repark head (and check for lock) by 
85
87
                                                   moving without scanning */
86
 
#define GENESYS_FLAG_DARK_CALIBRATION (1 << 8)  /* do dark calibration */
87
 
#define GENESYS_FLAG_STAGGERED_LINE   (1 << 9)  /* pixel columns are shifted vertically for hi-res modes */
88
 
 
89
 
#define GENESYS_FLAG_MUST_WAIT        (1 << 10) /* tells wether the scanner 
90
 
                                                   should wait 1 minute after 
91
 
                                                   init before doing anything 
92
 
                                                */
93
 
 
94
 
 
95
 
#define GENESYS_FLAG_ALT_SLOPE_CREATE (1 << 11) /* use alternative slope
96
 
                                                   creation function */
97
 
 
98
 
#define GENESYS_FLAG_DARK_WHITE_CALIBRATION (1 << 12) /* yet another calibration method. does white and dark shading in one run, depending on a black and a white strip*/
99
 
#define GENESYS_FLAG_CUSTOM_GAMMA     (1 << 13)       /* allow custom gamma tables */
100
 
#define GENESYS_FLAG_NO_CALIBRATION   (1 << 14)       /* allow scanners to use skip the calibration, needed for sheetfed scanners */
101
 
#define GENESYS_FLAG_HALF_CCD_MODE    (1 << 15)       /* scanner has setting for half ccd mode */
102
 
 
103
 
#define GENESYS_HAS_NO_BUTTONS       0              /* scanner has no supported button */
104
 
#define GENESYS_HAS_SCAN_SW          (1 << 0)       /* scanner has SCAN button */
105
 
#define GENESYS_HAS_FILE_SW          (1 << 1)       /* scanner has FILE button */
106
 
#define GENESYS_HAS_COPY_SW          (1 << 2)       /* scanner has COPY button */
107
 
#define GENESYS_HAS_EMAIL_SW         (1 << 3)       /* scanner has EMAIL button */
108
 
#define GENESYS_HAS_PAGE_LOADED_SW   (1 << 4)       /* scanner has paper in detection */
109
 
#define GENESYS_HAS_OCR_SW           (1 << 5)       /* scanner has OCR button */
110
 
#define GENESYS_HAS_POWER_SW         (1 << 6)       /* scanner has power button */
111
 
#define GENESYS_HAS_CALIBRATE        (1 << 7)       /* scanner has 'calibrate' software button to start calibration */
 
88
#define GENESYS_FLAG_DARK_CALIBRATION (1 << 8)  /**> do dark calibration */
 
89
#define GENESYS_FLAG_STAGGERED_LINE   (1 << 9)  /**> pixel columns are shifted vertically for hi-res modes */
 
90
 
 
91
#define GENESYS_FLAG_MUST_WAIT        (1 << 10) /**> tells wether the scanner must wait for the head when parking */
 
92
 
 
93
 
 
94
#define GENESYS_FLAG_ALT_SLOPE_CREATE (1 << 11) /**> use alternative slope creation function */
 
95
 
 
96
#define GENESYS_FLAG_DARK_WHITE_CALIBRATION (1 << 12) /**> yet another calibration method. does white and dark shading in one run, depending on a black and a white strip*/
 
97
#define GENESYS_FLAG_CUSTOM_GAMMA     (1 << 13)       /**> allow custom gamma tables */
 
98
#define GENESYS_FLAG_NO_CALIBRATION   (1 << 14)       /**> allow scanners to use skip the calibration, needed for sheetfed scanners */
 
99
#define GENESYS_FLAG_HALF_CCD_MODE    (1 << 15)       /**> scanner has setting for half ccd mode */
 
100
#define GENESYS_FLAG_ODD_EVEN_CIS     (1 << 16)       /**> scan odd and even pixels come in separated lines */
 
101
 
 
102
#define GENESYS_HAS_NO_BUTTONS       0              /**> scanner has no supported button */
 
103
#define GENESYS_HAS_SCAN_SW          (1 << 0)       /**> scanner has SCAN button */
 
104
#define GENESYS_HAS_FILE_SW          (1 << 1)       /**> scanner has FILE button */
 
105
#define GENESYS_HAS_COPY_SW          (1 << 2)       /**> scanner has COPY button */
 
106
#define GENESYS_HAS_EMAIL_SW         (1 << 3)       /**> scanner has EMAIL button */
 
107
#define GENESYS_HAS_PAGE_LOADED_SW   (1 << 4)       /**> scanner has paper in detection */
 
108
#define GENESYS_HAS_OCR_SW           (1 << 5)       /**> scanner has OCR button */
 
109
#define GENESYS_HAS_POWER_SW         (1 << 6)       /**> scanner has power button */
 
110
#define GENESYS_HAS_CALIBRATE        (1 << 7)       /**> scanner has 'calibrate' software button to start calibration */
112
111
 
113
112
/* USB control message values */
114
113
#define REQUEST_TYPE_IN         (USB_TYPE_VENDOR | USB_DIR_IN)
123
122
#define GPIO_OUTPUT_ENABLE      0x89
124
123
#define GPIO_READ               0x8a
125
124
#define GPIO_WRITE              0x8b
 
125
#define VALUE_BUF_ENDACCESS     0x8c
 
126
#define VALUE_GET_REGISTER      0x8e
126
127
#define INDEX                   0x00
127
128
 
128
129
/* todo: used?
129
130
#define VALUE_READ_STATUS       0x86
130
 
#define VALUE_BUF_ENDACCESS     0x8C
131
131
*/
132
132
 
133
133
/* Read/write bulk data/registers */
146
146
#define AFE_SET        2
147
147
#define AFE_POWER_SAVE 4
148
148
 
149
 
#define LOWORD(x)  ((uint16_t)(x & 0xffff))
150
 
#define HIWORD(x)  ((uint16_t)(x >> 16))
 
149
#define LOWORD(x)  ((uint16_t)((x) & 0xffff))
 
150
#define HIWORD(x)  ((uint16_t)((x) >> 16))
151
151
#define LOBYTE(x)  ((uint8_t)((x) & 0xFF))
152
152
#define HIBYTE(x)  ((uint8_t)((x) >> 8))
153
153
 
154
154
/* Global constants */
155
 
/* todo: check if those are the same for every scanner */
156
 
#define SYSTEM_CLOCK            32      /* todo: ? */
 
155
/* TODO: emove this leftover of early backend days */
157
156
#define MOTOR_SPEED_MAX         350
158
 
                                                                                                              /*#define MOTOR_GEAR    *//*600 1200 * todo: base y res? --> model */
159
 
#define PIXEL_TIME              ((double) 24 / SYSTEM_CLOCK)
160
157
#define DARK_VALUE              0
161
158
 
 
159
#define PWRBIT          0x80
 
160
#define BUFEMPTY        0x40
 
161
#define FEEDFSH         0x20
 
162
#define SCANFSH         0x10
 
163
#define HOMESNR         0x08
 
164
#define LAMPSTS         0x04
 
165
#define FEBUSY          0x02
 
166
#define MOTORENB        0x01
162
167
 
163
168
typedef struct
164
169
{
234
239
Genesys_Color_Order;
235
240
 
236
241
 
237
 
#define MAX_SCANNERS 30
 
242
#define MAX_SCANNERS 50
238
243
#define MAX_RESOLUTIONS 13
239
244
#define MAX_DPI 4
240
245
 
241
246
#define GENESYS_GL646    646
242
247
#define GENESYS_GL841    841
 
248
#define GENESYS_GL843    843
 
249
#define GENESYS_GL846    846
 
250
#define GENESYS_GL847    847
 
251
#define GENESYS_GL848    848
 
252
#define GENESYS_GL124    124
243
253
 
244
 
/*135 registers for gl841 + 1 null-reg*/
245
 
#define GENESYS_MAX_REGS 136
 
254
#define GENESYS_MAX_REGS 256
246
255
 
247
256
#define DAC_WOLFSON_UMAX   0
248
257
#define DAC_WOLFSON_ST12   1
255
264
#define DAC_WOLFSON_XP300  8
256
265
#define DAC_WOLFSON_HP3670 9
257
266
#define DAC_WOLFSON_DSM600 10
 
267
#define DAC_CANONLIDE200   11
 
268
#define DAC_KVSS080        12
 
269
#define DAC_G4050          13
 
270
#define DAC_CANONLIDE110   14
 
271
#define DAC_PLUSTEK_3600   15
258
272
 
259
273
#define CCD_UMAX         0
260
274
#define CCD_ST12         1      /* SONY ILX548: 5340 Pixel  ??? */
271
285
#define CCD_DSMOBILE600  12
272
286
#define CCD_XP300        13
273
287
#define CCD_DP685        14
 
288
#define CIS_CANONLIDE200 15
 
289
#define CIS_CANONLIDE100 16
 
290
#define CCD_KVSS080      17
 
291
#define CCD_G4050        18
 
292
#define CIS_CANONLIDE110 19
 
293
#define CCD_PLUSTEK_3600 20
274
294
 
275
295
#define GPO_UMAX         0
276
296
#define GPO_ST12         1
284
304
#define GPO_HP3670       9
285
305
#define GPO_DP665        10
286
306
#define GPO_DP685        11
 
307
#define GPO_CANONLIDE200 12
 
308
#define GPO_KVSS080      13
 
309
#define GPO_G4050        14
 
310
#define GPO_CANONLIDE110 15
 
311
#define GPO_PLUSTEK_3600 16
287
312
 
288
313
#define MOTOR_UMAX       0
289
314
#define MOTOR_5345       1
297
322
#define MOTOR_DP665      10
298
323
#define MOTOR_ROADWARRIOR 11
299
324
#define MOTOR_DSMOBILE_600 12
 
325
#define MOTOR_CANONLIDE200 13
 
326
#define MOTOR_CANONLIDE100 14
 
327
#define MOTOR_KVSS080      15
 
328
#define MOTOR_G4050        16
 
329
#define MOTOR_CANONLIDE110 17
 
330
#define MOTOR_PLUSTEK_3600 18
300
331
 
301
332
 
302
333
/* Forward typedefs */
416
447
     * move scanning head to transparency adapter
417
448
     */
418
449
    SANE_Status (*move_to_ta) (Genesys_Device * dev);
 
450
 
 
451
    /**
 
452
     * write shading data calibration to ASIC
 
453
     */
 
454
    SANE_Status (*send_shading_data) (Genesys_Device * dev, uint8_t * data, int size);
 
455
 
419
456
} Genesys_Command_Set;
420
457
 
421
458
typedef struct Genesys_Model
515
552
  /**> Disable interpolation for xres<yres*/
516
553
  int disable_interpolation;
517
554
 
 
555
  /**> Use double x resolution internally to provide better
 
556
   * quality */
 
557
  int double_xres;
 
558
 
518
559
  /**> true is lineart is generated from gray data by
519
560
   * the dynamic rasterization algo */
520
561
  int dynamic_lineart;
563
604
struct Genesys_Device
564
605
{
565
606
  SANE_Int dn;
 
607
  SANE_Bool usb_mode;
566
608
  SANE_String file_name;
567
609
  SANE_String calib_file;
568
610
  Genesys_Model *model;
569
611
 
570
 
  Genesys_Register_Set reg[GENESYS_MAX_REGS];
571
 
  Genesys_Register_Set calib_reg[GENESYS_MAX_REGS];
 
612
  Genesys_Register_Set reg[256];
 
613
  Genesys_Register_Set calib_reg[256];
572
614
  Genesys_Settings settings;
573
615
  Genesys_Frontend frontend;
574
616
  Genesys_Sensor sensor;
591
633
  SANE_Int lamp_off_time;
592
634
 
593
635
  SANE_Bool read_active;
 
636
  SANE_Bool parking;            /**> signal wether the park command has been issued */
594
637
  SANE_Bool document;           /**> for sheetfed scanner's, is TRUE when there
595
638
                                   is a document in the scanner */
596
639
 
613
656
  Genesys_Calibration_Cache *calibration_cache;
614
657
 
615
658
  struct Genesys_Device *next;
 
659
 
 
660
  int segnb;       /**> number of segments composing the sensor */
 
661
  int line_interp; /**> number of lines used in line interpolation */
 
662
  int line_count;  /**> number of scan lines used during scan */
 
663
  size_t bpl;      /**> bytes per full scan widthline */
 
664
  size_t skip;     /**> bytes to skip from start of line to get first required pixel */
 
665
  size_t dist;     /**> bytes distance between an odd and an even pixel */
 
666
  size_t len;      /**> number of even pixels */
 
667
  size_t cur;      /**> current pixel position within sub window */
 
668
  Genesys_Buffer oe_buffer; /**> buffer to handle even/odd data */
 
669
 
 
670
  SANE_Bool buffer_image; /**> when true the scanned picture is first buffered
 
671
                           * to allow software image enhancements */
 
672
  SANE_Byte *img_buffer; /**> image buffer where the scanned picture is stored */
616
673
};
617
674
 
618
675
typedef struct Genesys_USB_Device_Entry
637
694
sanei_genesys_set_reg_from_set (Genesys_Register_Set * regs,
638
695
                                SANE_Byte address, SANE_Byte value);
639
696
 
 
697
extern SANE_Status sanei_genesys_init_cmd_set (Genesys_Device * dev);
 
698
 
640
699
extern SANE_Status
641
700
sanei_genesys_read_register (Genesys_Device * dev, uint8_t reg,
642
701
                             uint8_t * val);
646
705
                              uint8_t val);
647
706
 
648
707
extern SANE_Status
649
 
sanei_genesys_get_status (Genesys_Device * dev, uint8_t * status);
 
708
sanei_genesys_read_hregister (Genesys_Device * dev, uint8_t reg,
 
709
                             uint8_t * val);
 
710
 
 
711
extern SANE_Status
 
712
sanei_genesys_write_hregister (Genesys_Device * dev, uint8_t reg,
 
713
                              uint8_t val);
 
714
 
 
715
extern SANE_Status sanei_genesys_write_0x8c (Genesys_Device * dev, uint8_t index, uint8_t val);
 
716
 
 
717
extern SANE_Status sanei_genesys_get_status (Genesys_Device * dev, uint8_t * status);
 
718
 
 
719
extern void sanei_genesys_print_status (uint8_t val);
 
720
 
 
721
extern SANE_Status
 
722
sanei_genesys_write_ahb (SANE_Int dn, uint32_t addr, uint32_t size, uint8_t * data);
650
723
 
651
724
extern void sanei_genesys_init_fe (Genesys_Device * dev);
652
725
 
685
758
sanei_genesys_set_buffer_address (Genesys_Device * dev, uint32_t addr);
686
759
 
687
760
extern SANE_Status
 
761
sanei_genesys_fe_read_data (Genesys_Device * dev, uint8_t addr,
 
762
                            uint16_t *data);
 
763
 
 
764
extern SANE_Status
688
765
sanei_genesys_fe_write_data (Genesys_Device * dev, uint8_t addr,
689
766
                             uint16_t data);
690
767
 
763
840
extern SANE_Status
764
841
sanei_genesys_buffer_consume(Genesys_Buffer * buf, size_t size);
765
842
 
 
843
extern SANE_Status
 
844
sanei_genesys_set_double(Genesys_Register_Set *regs, SANE_Byte addr, uint16_t value);
 
845
 
 
846
extern SANE_Status
 
847
sanei_genesys_set_triple(Genesys_Register_Set *regs, SANE_Byte addr, uint32_t value);
 
848
 
 
849
extern SANE_Status
 
850
sanei_genesys_get_double(Genesys_Register_Set *regs, SANE_Byte addr, uint16_t *value);
 
851
 
 
852
extern SANE_Status
 
853
sanei_genesys_get_triple(Genesys_Register_Set *regs, SANE_Byte addr, uint32_t *value);
 
854
 
 
855
extern SANE_Status
 
856
sanei_genesys_wait_for_home(Genesys_Device *dev);
766
857
 
767
858
/*---------------------------------------------------------------------------*/
768
859
/*                ASIC specific functions declarations                       */
769
860
/*---------------------------------------------------------------------------*/
770
861
extern SANE_Status sanei_gl646_init_cmd_set (Genesys_Device * dev);
771
862
extern SANE_Status sanei_gl841_init_cmd_set (Genesys_Device * dev);
 
863
extern SANE_Status sanei_gl843_init_cmd_set (Genesys_Device * dev);
 
864
extern SANE_Status sanei_gl847_init_cmd_set (Genesys_Device * dev);
 
865
extern SANE_Status sanei_gl124_init_cmd_set (Genesys_Device * dev);
772
866
 
773
867
#endif /* not GENESYS_LOW_H */