• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* sane - Scanner Access Now Easy.
2 
3    Copyright (C) 2005 Mustek.
4    Originally maintained by Mustek
5    Author:Jack Roy 2005.5.24
6 
7    This file is part of the SANE package.
8 
9    This program is free software; you can redistribute it and/or
10    modify it under the terms of the GNU General Public License as
11    published by the Free Software Foundation; either version 2 of the
12    License, or (at your option) any later version.
13 
14    This program is distributed in the hope that it will be useful, but
15    WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    General Public License for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <https://www.gnu.org/licenses/>.
21 
22    As a special exception, the authors of SANE give permission for
23    additional uses of the libraries contained in this release of SANE.
24 
25    The exception is that, if you link a SANE library with other files
26    to produce an executable, this does not by itself cause the
27    resulting executable to be covered by the GNU General Public
28    License.  Your use of that executable is in no way restricted on
29    account of linking the SANE library code into it.
30 
31    This exception does not, however, invalidate any other reasons why
32    the executable file might be covered by the GNU General Public
33    License.
34 
35    If you submit changes to SANE to the maintainers to be included in
36    a subsequent release, you agree by submitting the changes that
37    those changes may be distributed with this exception intact.
38 
39    If you write modifications of your own for SANE, it is your choice
40    whether to permit this exception to apply to your modifications.
41    If you do not wish that, delete this exception notice.
42 
43    This file implements a SANE backend for the Mustek BearPaw 2448 TA Pro
44    and similar USB2 scanners. */
45 
46 #ifndef MUSTEK_USB2_HIGH_H
47 #define MUSTEK_USB2_HIGH_H
48 
49 /* const use in structures*/
50 
51 /*scan mode*/
52 typedef unsigned short SCANMODE, *LPSCANMODE;
53 #define SM_TEXT		0x00
54 #define SM_GRAY		0x01
55 #define SM_RGB24	0x02
56 #define SM_GRAY10	0x03
57 #define SM_RGB30	0x04
58 #define SM_GRAY12	0x05
59 #define SM_RGB36	0x06
60 #define SM_GRAY14	0x07
61 #define SM_RGB42	0x08
62 #define SM_GRAY16	0x09
63 #define SM_RGB48	0x0a
64 
65 /*pixel flavor*/
66 typedef SANE_Byte PIXELFLAVOR, *LPPIXELFLAVOR;
67 #define PF_BlackIs0 0x00
68 #define PF_WhiteIs0 0x01
69 
70 /*scan source*/
71 typedef SANE_Byte SCANSOURCE, *LPSCANSOURCE;
72 #define SS_Reflective	0x00
73 #define SS_Positive		0x01
74 #define SS_Negative		0x02
75 #define SS_ADF			0x03
76 
77 /*RGB order*/
78 typedef unsigned short RGBORDER, *LPRGBORDER;
79 #define RO_RGB 0x00
80 #define RO_BGR 0x01
81 
82 /* structures use in parameters of export function*/
83 
84 typedef struct tagGAMMAINFO
85 {
86   SCANMODE smScanMode;
87   unsigned short wInputGammaBits;
88   unsigned short wOutputGammaBits;
89 } GAMMAINFO, *LPGAMMAINFO;
90 
91 typedef struct tagGETPARAMETERS
92 {
93   unsigned short wSourceXDPI;
94   unsigned short wSourceYDPI;
95   unsigned int dwLineByteWidth;
96   unsigned int dwLength;
97 } GETPARAMETERS, *LPGETPARAMETERS;
98 
99 typedef struct tagFRAME
100 {
101   unsigned short x1;
102   unsigned short y1;
103   unsigned short x2;
104   unsigned short y2;
105 } FRAME, *LPFRAME;
106 
107 typedef struct tagSETPARAMETERS
108 {
109   FRAME fmArea;
110   unsigned short wTargetDPI;
111   SCANMODE smScanMode;
112   unsigned short wLinearThreshold;	/*threshold for Line art mode */
113   PIXELFLAVOR pfPixelFlavor;
114   SCANSOURCE ssScanSource;
115   unsigned short * pGammaTable;
116 } SETPARAMETERS, *LPSETPARAMETERS;
117 
118 typedef struct tagIMAGEROWS
119 {
120   RGBORDER roRgbOrder;
121   unsigned short wWantedLineNum;
122   unsigned short wXferedLineNum;
123   SANE_Byte * pBuffer;
124 } IMAGEROWS, *LPIMAGEROWS;
125 
126 
127 /*Macro define*/
128 
129 #define R_GAIN							0
130 #define G_GAIN                          0
131 #define B_GAIN                          0
132 #define R_OFFSET                        0
133 #define G_OFFSET                        0
134 #define B_OFFSET                        0
135 #define R_DIRECTION                     0
136 #define G_DIRECTION                     0
137 #define B_DIRECTION                     0
138 
139 /* use for adjust AD's offset*/
140 
141 /* for Reflective*/
142 #define REFL_DARK_MAX_LEVEL             20
143 #define REFL_DARK_MIN_LEVEL             10
144 #define REFL_WHITE_MAX_LEVEL			220
145 #define REFL_WHITE_MIN_LEVEL			210
146 #define REFL_MAX_LEVEL_RANGE            210
147 #define REFL_MIN_LEVEL_RANGE            190
148 
149 /*for Transparent*/
150 #define TRAN_DARK_MAX_LEVEL             20
151 #define TRAN_DARK_MIN_LEVEL             10
152 #define TRAN_WHITE_MAX_LEVEL            220
153 #define TRAN_WHITE_MIN_LEVEL            210
154 #define TRAN_MAX_LEVEL_RANGE            210
155 #define TRAN_MIN_LEVEL_RANGE            190
156 
157 
158 /* in 600 dpi*/
159 #define FIND_LEFT_TOP_WIDTH_IN_DIP          512
160 #define FIND_LEFT_TOP_HEIGHT_IN_DIP         180
161 #define FIND_LEFT_TOP_CALIBRATE_RESOLUTION  600
162 
163 #define TA_FIND_LEFT_TOP_WIDTH_IN_DIP       2668
164 #define TA_FIND_LEFT_TOP_HEIGHT_IN_DIP      300
165 
166 #define TA_MOTOR_BACK_STEP_AFTER_FIND_BOUNDARY             150
167 #define TA_MOTOR_FORWARD_STEP_AFTER_READ_WHITE_DATA        1100
168 
169 /*must be 8x*/
170 #define LINE_CALIBRATION__16BITS_HEIGHT				40
171 
172 /* the length from block bar to start Calibration position*/
173 #define BEFORE_SCANNING_MOTOR_FORWARD_PIXEL 40
174 
175 #define PRE_MOVE_MOTOR_LENGTH_IN_DPI    1450
176 
177 /* if the motor is 1/8 step, setup MOTOR_STEP_MULTI as 8
178  if the motor is 1/4 step, setup MOTOR_STEP_MULTI as 4
179  if the motor is full step, setup MOTOR_STEP_MULTI as 1
180 #define MOTOR_EIGHTH_STEP*/
181 #ifdef MOTOR_EIGHTH_STEP
182 #define MOTOR_STEP_MULTI                8
183 #define GPIO_95_Config                  0x68
184 #else
185 #define MOTOR_STEP_MULTI                4
186 
187 #define GPIO_95_Config                  0x60
188 #endif
189 
190 #define TRAN_START_POS					4550
191 
192 /* in 300dpi*/
193 #define MAX_SCANNING_WIDTH               2550	/*just for A4 */
194 #define MAX_SCANNING_HEIGHT              3540	/*just for A4 */
195 
196 #define INIFILENAME                         "./msam.ini"
197 
198 /*enable gamma*/
199 #define ENABLE_GAMMA
200 
201 /*save debug image*/
202 /*#define DEBUG_SAVE_IMAGE*/
203 
204 /*type define*/
205 typedef unsigned char SCANTYPE;
206 #define ST_Reflective	0x00
207 #define ST_Transparent	0x01
208 
209 typedef enum tagCOLORMODE
210 {
211   CM_RGB48 = 0,
212   CM_RGB42 = 1,
213   CM_RGB36 = 2,
214   CM_RGB30 = 3,
215   CM_RGB24 = 4,
216   CM_GRAY16 = 5,
217   CM_GRAY14 = 6,
218   CM_GRAY12 = 7,
219   CM_GRAY10 = 8,
220   CM_GRAY8 = 9,
221   CM_TEXT = 10,
222   CM_RGB48ext = 11,
223   CM_RGB42ext = 12,
224   CM_RGB36ext = 13,
225   CM_RGB30ext = 14,
226   CM_RGB24ext = 15,
227   CM_GRAY16ext = 16,
228   CM_GRAY14ext = 17,
229   CM_GRAY12ext = 18,
230   CM_GRAY10ext = 19,
231   CM_GRAY8ext = 20,
232   CM_TEXText = 21
233 } COLORMODE, *PCOLORMODE;
234 
235 typedef struct tagTARGETIMAGE
236 {
237   SANE_Bool isOptimalSpeed;
238   COLORMODE cmColorMode;
239   unsigned short wDpi;
240   unsigned short wX;
241   unsigned short wY;
242   unsigned short wWidth;
243   unsigned short wHeight;
244   SANE_Byte bScanSource;
245 } TARGETIMAGE, *PTARGETIMAGE;
246 
247 typedef struct tagSUGGESTSETTING
248 {
249   COLORMODE cmScanMode;
250   unsigned short wXDpi;
251   unsigned short wYDpi;
252   unsigned short wX;
253   unsigned short wY;
254   unsigned short wWidth;
255   unsigned short wHeight;
256   unsigned int dwBytesPerRow;
257 } SUGGESTSETTING, *PSUGGESTSETTING;
258 
259 
260 
261 #endif
262