summaryrefslogtreecommitdiff
path: root/backend/mustek_usb2_high.h
blob: aec79bbbeaa798676b91c84ffa6673d999e0856d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/* sane - Scanner Access Now Easy.

   Copyright (C) 2005 Mustek.
   Originally maintained by Mustek
   Author:Jack Roy 2005.5.24

   This file is part of the SANE package.

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston,
   MA 02111-1307, USA.

   As a special exception, the authors of SANE give permission for
   additional uses of the libraries contained in this release of SANE.

   The exception is that, if you link a SANE library with other files
   to produce an executable, this does not by itself cause the
   resulting executable to be covered by the GNU General Public
   License.  Your use of that executable is in no way restricted on
   account of linking the SANE library code into it.

   This exception does not, however, invalidate any other reasons why
   the executable file might be covered by the GNU General Public
   License.

   If you submit changes to SANE to the maintainers to be included in
   a subsequent release, you agree by submitting the changes that
   those changes may be distributed with this exception intact.

   If you write modifications of your own for SANE, it is your choice
   whether to permit this exception to apply to your modifications.
   If you do not wish that, delete this exception notice.

   This file implements a SANE backend for the Mustek BearPaw 2448 TA Pro
   and similar USB2 scanners. */

#ifndef MUSTEK_USB2_HIGH_H
#define MUSTEK_USB2_HIGH_H

/* const use in structures*/

/*scan mode*/
typedef unsigned short SCANMODE, *LPSCANMODE;
#define SM_TEXT		0x00
#define SM_GRAY		0x01
#define SM_RGB24	0x02
#define SM_GRAY10	0x03
#define SM_RGB30	0x04
#define SM_GRAY12	0x05
#define SM_RGB36	0x06
#define SM_GRAY14	0x07
#define SM_RGB42	0x08
#define SM_GRAY16	0x09
#define SM_RGB48	0x0a

/*pixel flavor*/
typedef SANE_Byte PIXELFLAVOR, *LPPIXELFLAVOR;
#define PF_BlackIs0 0x00
#define PF_WhiteIs0 0x01

/*scan source*/
typedef SANE_Byte SCANSOURCE, *LPSCANSOURCE;
#define SS_Reflective	0x00
#define SS_Positive		0x01
#define SS_Negative		0x02
#define SS_ADF			0x03

/*RGB order*/
typedef unsigned short RGBORDER, *LPRGBORDER;
#define RO_RGB 0x00
#define RO_BGR 0x01

/* structures use in parameters of export function*/

typedef struct tagGAMMAINFO
{
  SCANMODE smScanMode;
  unsigned short wInputGammaBits;
  unsigned short wOutputGammaBits;
} GAMMAINFO, *LPGAMMAINFO;

typedef struct tagGETPARAMETERS
{
  unsigned short wSourceXDPI;
  unsigned short wSourceYDPI;
  unsigned int dwLineByteWidth;
  unsigned int dwLength;
} GETPARAMETERS, *LPGETPARAMETERS;

typedef struct tagFRAME
{
  unsigned short x1;
  unsigned short y1;
  unsigned short x2;
  unsigned short y2;
} FRAME, *LPFRAME;

typedef struct tagSETPARAMETERS
{
  FRAME fmArea;
  unsigned short wTargetDPI;
  SCANMODE smScanMode;
  unsigned short wLinearThreshold;	/*threshold for Line art mode */
  PIXELFLAVOR pfPixelFlavor;
  SCANSOURCE ssScanSource;
  unsigned short * pGammaTable;
} SETPARAMETERS, *LPSETPARAMETERS;

typedef struct tagIMAGEROWS
{
  RGBORDER roRgbOrder;
  unsigned short wWantedLineNum;
  unsigned short wXferedLineNum;
  SANE_Byte * pBuffer;
} IMAGEROWS, *LPIMAGEROWS;


/*Macro define*/

#define R_GAIN							0
#define G_GAIN                          0
#define B_GAIN                          0
#define R_OFFSET                        0
#define G_OFFSET                        0
#define B_OFFSET                        0
#define R_DIRECTION                     0
#define G_DIRECTION                     0
#define B_DIRECTION                     0

/* use for adjust AD's offset*/

/* for Reflective*/
#define REFL_DARK_MAX_LEVEL             20
#define REFL_DARK_MIN_LEVEL             10
#define REFL_WHITE_MAX_LEVEL			220
#define REFL_WHITE_MIN_LEVEL			210
#define REFL_MAX_LEVEL_RANGE            210
#define REFL_MIN_LEVEL_RANGE            190

/*for Transparent*/
#define TRAN_DARK_MAX_LEVEL             20
#define TRAN_DARK_MIN_LEVEL             10
#define TRAN_WHITE_MAX_LEVEL            220
#define TRAN_WHITE_MIN_LEVEL            210
#define TRAN_MAX_LEVEL_RANGE            210
#define TRAN_MIN_LEVEL_RANGE            190


/* in 600 dpi*/
#define FIND_LEFT_TOP_WIDTH_IN_DIP          512
#define FIND_LEFT_TOP_HEIGHT_IN_DIP         180
#define FIND_LEFT_TOP_CALIBRATE_RESOLUTION  600

#define TA_FIND_LEFT_TOP_WIDTH_IN_DIP       2668
#define TA_FIND_LEFT_TOP_HEIGHT_IN_DIP      300

#define TA_MOTOR_BACK_STEP_AFTER_FIND_BOUNDARY             150
#define TA_MOTOR_FORWARD_STEP_AFTER_READ_WHITE_DATA        1100

/*must be 8x*/
#define LINE_CALIBRATION__16BITS_HEIGHT				40

/* the length from block bar to start Calibration position*/
#define BEFORE_SCANNING_MOTOR_FORWARD_PIXEL 40

#define PRE_MOVE_MOTOR_LENGTH_IN_DPI    1450

/* if the motor is 1/8 step, setup MOTOR_STEP_MULTI as 8
 if the motor is 1/4 step, setup MOTOR_STEP_MULTI as 4
 if the motor is full step, setup MOTOR_STEP_MULTI as 1
#define MOTOR_EIGHTH_STEP*/
#ifdef MOTOR_EIGHTH_STEP
#define MOTOR_STEP_MULTI                8
#define GPIO_95_Config                  0x68
#else
#define MOTOR_STEP_MULTI                4

#define GPIO_95_Config                  0x60
#endif

#define TRAN_START_POS					4550

/* in 300dpi*/
#define MAX_SCANNING_WIDTH               2550	/*just for A4 */
#define MAX_SCANNING_HEIGHT              3540	/*just for A4 */

#define INIFILENAME                         "./msam.ini"

/*enable gamma*/
#define ENABLE_GAMMA

/*save debug image*/
/*#define DEBUG_SAVE_IMAGE*/

/*type define*/
typedef unsigned char SCANTYPE;
#define ST_Reflective	0x00
#define ST_Transparent	0x01

typedef enum tagCOLORMODE
{
  CM_RGB48 = 0,
  CM_RGB42 = 1,
  CM_RGB36 = 2,
  CM_RGB30 = 3,
  CM_RGB24 = 4,
  CM_GRAY16 = 5,
  CM_GRAY14 = 6,
  CM_GRAY12 = 7,
  CM_GRAY10 = 8,
  CM_GRAY8 = 9,
  CM_TEXT = 10,
  CM_RGB48ext = 11,
  CM_RGB42ext = 12,
  CM_RGB36ext = 13,
  CM_RGB30ext = 14,
  CM_RGB24ext = 15,
  CM_GRAY16ext = 16,
  CM_GRAY14ext = 17,
  CM_GRAY12ext = 18,
  CM_GRAY10ext = 19,
  CM_GRAY8ext = 20,
  CM_TEXText = 21
} COLORMODE, *PCOLORMODE;

typedef struct tagTARGETIMAGE
{
  SANE_Bool isOptimalSpeed;
  COLORMODE cmColorMode;
  unsigned short wDpi;
  unsigned short wX;
  unsigned short wY;
  unsigned short wWidth;
  unsigned short wHeight;
  SANE_Byte bScanSource;
} TARGETIMAGE, *PTARGETIMAGE;

typedef struct tagSUGGESTSETTING
{
  COLORMODE cmScanMode;
  unsigned short wXDpi;
  unsigned short wYDpi;
  unsigned short wX;
  unsigned short wY;
  unsigned short wWidth;
  unsigned short wHeight;
  unsigned int dwBytesPerRow;
} SUGGESTSETTING, *PSUGGESTSETTING;



#endif