3
3
Copyright (C) 2003 Oliver Rauch
4
4
Copyright (C) 2003, 2004 Henning Meier-Geinitz <henning@meier-geinitz.de>
5
5
Copyright (C) 2004, 2005 Gerhard Jaeger <gerhard@gjaeger.de>
6
Copyright (C) 2004-2010 St�phane Voltz <stef.dev@free.fr>
6
Copyright (C) 2004-2012 St�phane Voltz <stef.dev@free.fr>
7
7
Copyright (C) 2005-2009 Pierre Willenbrock <pierre@pirsoft.dnsalias.org>
8
8
Copyright (C) 2006 Laurent Charpentier <laurent_pubs@yahoo.com>
9
9
Parts of the structs have been taken from the gt68xx backend by
51
51
#ifndef GENESYS_LOW_H
52
52
#define GENESYS_LOW_H
55
#include "../include/sane/config.h"
54
63
#include <stddef.h>
55
64
#ifdef HAVE_SYS_TIME_H
56
65
#include <sys/time.h>
67
#ifdef HAVE_SYS_TYPES_H
68
#include <sys/types.h>
72
#include <sys/types.h>
58
75
#include "../include/sane/sane.h"
76
#include "../include/sane/sanei.h"
77
#include "../include/sane/saneopts.h"
79
#include "../include/sane/sanei_backend.h"
80
#include "../include/sane/sanei_usb.h"
82
#include "../include/_stdint.h"
60
84
#define DBG_error0 0 /* errors/warnings printed even with devuglevel 0 */
61
85
#define DBG_error 1 /* fatal errors */
81
105
#define GENESYS_FLAG_LAZY_INIT (1 << 2) /**> skip extensive ASIC test at init */
82
106
#define GENESYS_FLAG_XPA (1 << 3)
83
107
#define GENESYS_FLAG_SKIP_WARMUP (1 << 4) /**> skip genesys_warmup() */
84
#define GENESYS_FLAG_OFFSET_CALIBRATION (1 << 5) /**> do offset calibration */
108
/** @brief offset calibration flag
109
* signals that the scanner does offset calibration. In this case off_calibration() and
110
* coarse_gain_calibration() functions must be implemented
112
#define GENESYS_FLAG_OFFSET_CALIBRATION (1 << 5)
85
113
#define GENESYS_FLAG_SEARCH_START (1 << 6) /**> do start search before scanning */
86
114
#define GENESYS_FLAG_REPARK (1 << 7) /**> repark head (and check for lock) by
87
115
moving without scanning */
91
119
#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 */
122
#define GENESYS_FLAG_HAS_UTA (1 << 11) /**> scanner has a transparency adapter */
96
124
#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
125
#define GENESYS_FLAG_CUSTOM_GAMMA (1 << 13) /**> allow custom gamma tables */
98
126
#define GENESYS_FLAG_NO_CALIBRATION (1 << 14) /**> allow scanners to use skip the calibration, needed for sheetfed scanners */
99
127
#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 */
128
#define GENESYS_FLAG_SIS_SENSOR (1 << 16) /**> handling of multi-segments sensors in software */
129
#define GENESYS_FLAG_SHADING_NO_MOVE (1 << 17) /**> scanner doesn't move sensor during shading calibration */
130
#define GENESYS_FLAG_SHADING_REPARK (1 << 18) /**> repark head between shading scans */
102
132
#define GENESYS_HAS_NO_BUTTONS 0 /**> scanner has no supported button */
103
133
#define GENESYS_HAS_SCAN_SW (1 << 0) /**> scanner has SCAN button */
454
491
SANE_Status (*send_shading_data) (Genesys_Device * dev, uint8_t * data, int size);
494
* calculate current scan setup
496
SANE_Status (*calculate_current_setup) (Genesys_Device * dev);
456
498
} Genesys_Command_Set;
500
/** @brief structure to describe a scanner model
501
* This structure describes a model. It is composed of information on the
502
* sensor, the motor, scanner geometry and flags to drive operation.
458
504
typedef struct Genesys_Model
460
506
SANE_String_Const name;
641
696
Genesys_Buffer lines_buffer;
642
697
Genesys_Buffer shrink_buffer;
643
698
Genesys_Buffer out_buffer;
645
size_t read_bytes_left; /* bytes to read from scanner */
647
size_t total_bytes_read; /* total bytes read sent to frontend */
648
size_t total_bytes_to_read; /* total bytes read to be sent to frontend */
649
size_t wpl; /* asic's word per line */
699
Genesys_Buffer binarize_buffer; /**> buffer for digital lineart from gray data */
700
Genesys_Buffer local_buffer; /**> local buffer for gray data during dynamix lineart */
702
size_t read_bytes_left; /**> bytes to read from scanner */
704
size_t total_bytes_read; /**> total bytes read sent to frontend */
705
size_t total_bytes_to_read; /**> total bytes read to be sent to frontend */
706
size_t wpl; /**> asic's word per line */
651
708
Genesys_Current_Setup current_setup; /* contains the real used values */
658
715
struct Genesys_Device *next;
717
SANE_Int ld_shift_r; /**> used red line-distance shift*/
718
SANE_Int ld_shift_g; /**> used green line-distance shift*/
719
SANE_Int ld_shift_b; /**> used blue line-distance shift*/
660
720
int segnb; /**> number of segments composing the sensor */
661
721
int line_interp; /**> number of lines used in line interpolation */
662
722
int line_count; /**> number of scan lines used during scan */
663
723
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
724
size_t dist; /**> bytes distance between an odd and an even pixel */
666
725
size_t len; /**> number of even pixels */
667
726
size_t cur; /**> current pixel position within sub window */
727
size_t skip; /**> number of bytes to skip at start of line */
728
size_t *order; /**> array describing the order of the sub-segments of the sensor */
668
729
Genesys_Buffer oe_buffer; /**> buffer to handle even/odd data */
670
731
SANE_Bool buffer_image; /**> when true the scanned picture is first buffered
671
732
* to allow software image enhancements */
672
733
SANE_Byte *img_buffer; /**> image buffer where the scanned picture is stored */
735
FILE *binary; /**> binary logger file */
675
738
typedef struct Genesys_USB_Device_Entry
679
742
Genesys_Model *model; /**< Scanner model information */
680
743
} Genesys_USB_Device_Entry;
746
* structure for motor database
749
int motor_type; /**> motor id */
750
int exposure; /**> exposure for the slope table */
751
int step_type; /**> default step type for given exposure */
752
uint32_t *table; /**> 0 terminated slope table at full step */
757
#define QUARTER_STEP 2
758
#define EIGHTH_STEP 3
760
#define SLOPE_TABLE_SIZE 1024
762
#define SCAN_TABLE 0 /* table 1 at 0x4000 for gl124 */
763
#define BACKTRACK_TABLE 1 /* table 2 at 0x4800 for gl124 */
764
#define STOP_TABLE 2 /* table 3 at 0x5000 for gl124 */
765
#define FAST_TABLE 3 /* table 4 at 0x5800 for gl124 */
766
#define HOME_TABLE 4 /* table 5 at 0x6000 for gl124 */
768
#define SCAN_FLAG_SINGLE_LINE 0x001
769
#define SCAN_FLAG_DISABLE_SHADING 0x002
770
#define SCAN_FLAG_DISABLE_GAMMA 0x004
771
#define SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE 0x008
772
#define SCAN_FLAG_IGNORE_LINE_DISTANCE 0x010
773
#define SCAN_FLAG_USE_OPTICAL_RES 0x020
774
#define SCAN_FLAG_DISABLE_LAMP 0x040
775
#define SCAN_FLAG_DYNAMIC_LINEART 0x080
776
#define SCAN_FLAG_CALIBRATION 0x100
777
#define SCAN_FLAG_FEEDING 0x200
778
#define SCAN_FLAG_USE_XPA 0x400
780
#define MOTOR_FLAG_AUTO_GO_HOME 0x01
781
#define MOTOR_FLAG_DISABLE_BUFFER_FULL_MOVE 0x02
782
#define MOTOR_FLAG_FEED 0x04
783
#define MOTOR_FLAG_USE_XPA 0x08
785
#define OPTICAL_FLAG_DISABLE_GAMMA 0x01
786
#define OPTICAL_FLAG_DISABLE_SHADING 0x02
787
#define OPTICAL_FLAG_DISABLE_LAMP 0x04
788
#define OPTICAL_FLAG_ENABLE_LEDADD 0x08
789
#define OPTICAL_FLAG_DISABLE_DOUBLE 0x10
790
#define OPTICAL_FLAG_STAGGER 0x20
791
#define OPTICAL_FLAG_USE_XPA 0x40
682
793
/*--------------------------------------------------------------------------*/
683
794
/* common functions needed by low level specific functions */
684
795
/*--------------------------------------------------------------------------*/
855
966
extern SANE_Status
856
967
sanei_genesys_wait_for_home(Genesys_Device *dev);
970
int sanei_genesys_compute_dpihw(Genesys_Device *dev, int xres);
973
Motor_Profile *sanei_genesys_get_motor_profile(Motor_Profile *motors, int motor_type, int exposure);
976
int sanei_genesys_compute_step_type(Motor_Profile *motors, int motor_type, int exposure);
979
int sanei_genesys_slope_table(uint16_t *slope, int *steps, int dpi, int exposure, int base_dpi, int step_type, int factor, int motor_type, Motor_Profile *motors);
981
/** @brief find lowest motor resolution for the device.
982
* Parses the resolution list for motor and
983
* returns the lowest value.
984
* @param device for which to find the lowest motor resolution
985
* @return the lowest available motor resolution for the device
988
int sanei_genesys_get_lowest_ydpi(Genesys_Device *dev);
990
/** @brief find lowest resolution for the device.
991
* Parses the resolution list for motor and sensor and
992
* returns the lowest value.
993
* @param device for which to find the lowest resolution
994
* @return the lowest available resolution for the device
997
int sanei_genesys_get_lowest_dpi(Genesys_Device *dev);
1000
* reads previously cached calibration data
1004
sanei_genesys_read_calibration (Genesys_Device * dev);
1007
sanei_genesys_is_compatible_calibration (Genesys_Device * dev,
1008
Genesys_Calibration_Cache * cache,
1011
/** @brief compute maximum line distance shift
1012
* compute maximum line distance shift for the motor and sensor
1013
* combination. Line distance shift is the distance between different
1014
* color component of CCD sensors. Since these components aren't at
1015
* the same physical place, they scan diffrent lines. Software must
1016
* take this into account to accurately mix color data.
1017
* @param dev device session to compute max_shift for
1018
* @param channels number of color channels for the scan
1019
* @param yres motor resolution used for the scan
1020
* @param flags scan flags
1021
* @return 0 or line distance shift
1023
int sanei_genesys_compute_max_shift(Genesys_Device *dev,
858
1028
/*---------------------------------------------------------------------------*/
859
1029
/* ASIC specific functions declarations */
860
1030
/*---------------------------------------------------------------------------*/