72
72
if (status != SANE_STATUS_GOOD) return status; \
73
73
} while (SANE_FALSE)
75
#define DBGSTART DBG (DBG_proc, "%s start\n", __FUNCTION__);
76
#define DBGCOMPLETED DBG (DBG_proc, "%s completed\n", __FUNCTION__);
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 */
89
#define GENESYS_FLAG_MUST_WAIT (1 << 10) /* tells wether the scanner
90
should wait 1 minute after
91
init before doing anything
95
#define GENESYS_FLAG_ALT_SLOPE_CREATE (1 << 11) /* use alternative slope
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 */
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 */
91
#define GENESYS_FLAG_MUST_WAIT (1 << 10) /**> tells wether the scanner must wait for the head when parking */
94
#define GENESYS_FLAG_ALT_SLOPE_CREATE (1 << 11) /**> use alternative slope creation function */
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 */
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 */
113
112
/* USB control message values */
114
113
#define REQUEST_TYPE_IN (USB_TYPE_VENDOR | USB_DIR_IN)
146
146
#define AFE_SET 2
147
147
#define AFE_POWER_SAVE 4
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))
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
160
#define BUFEMPTY 0x40
166
#define MOTORENB 0x01
234
239
Genesys_Color_Order;
237
#define MAX_SCANNERS 30
242
#define MAX_SCANNERS 50
238
243
#define MAX_RESOLUTIONS 13
239
244
#define MAX_DPI 4
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
244
/*135 registers for gl841 + 1 null-reg*/
245
#define GENESYS_MAX_REGS 136
254
#define GENESYS_MAX_REGS 256
247
256
#define DAC_WOLFSON_UMAX 0
248
257
#define DAC_WOLFSON_ST12 1
613
656
Genesys_Calibration_Cache *calibration_cache;
615
658
struct Genesys_Device *next;
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 */
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 */
618
675
typedef struct Genesys_USB_Device_Entry
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,
712
sanei_genesys_write_hregister (Genesys_Device * dev, uint8_t reg,
715
extern SANE_Status sanei_genesys_write_0x8c (Genesys_Device * dev, uint8_t index, uint8_t val);
717
extern SANE_Status sanei_genesys_get_status (Genesys_Device * dev, uint8_t * status);
719
extern void sanei_genesys_print_status (uint8_t val);
722
sanei_genesys_write_ahb (SANE_Int dn, uint32_t addr, uint32_t size, uint8_t * data);
651
724
extern void sanei_genesys_init_fe (Genesys_Device * dev);
763
840
extern SANE_Status
764
841
sanei_genesys_buffer_consume(Genesys_Buffer * buf, size_t size);
844
sanei_genesys_set_double(Genesys_Register_Set *regs, SANE_Byte addr, uint16_t value);
847
sanei_genesys_set_triple(Genesys_Register_Set *regs, SANE_Byte addr, uint32_t value);
850
sanei_genesys_get_double(Genesys_Register_Set *regs, SANE_Byte addr, uint16_t *value);
853
sanei_genesys_get_triple(Genesys_Register_Set *regs, SANE_Byte addr, uint32_t *value);
856
sanei_genesys_wait_for_home(Genesys_Device *dev);
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);
773
867
#endif /* not GENESYS_LOW_H */