summaryrefslogtreecommitdiff
path: root/backend/canon.h
blob: 34f527b993b66c19dcd94ff4aef27e261290e6eb (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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
/* sane - Scanner Access Now Easy.
   Copyright (C) 1997 BYTEC GmbH Germany
   Written by Helmut Koeberle, Email: helmut.koeberle@bytec.de
   Modified by Manuel Panea <Manuel.Panea@rzg.mpg.de>,
   Markus Mertinat <Markus.Mertinat@Physik.Uni-Augsburg.DE>,
   and ULrich Deiters <ulrich.deiters@uni-koeln.de>

   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. */

#ifndef canon_h
#define canon_h 1

#ifdef __GNUC__
#define UNUSEDARG __attribute__ ((unused))
#else
#define UNUSEDARG
#endif

/* all the different possible model names. */
#define FB1200S "IX-12015E      "
#define FB620S  "IX-06035E      "
#define CS300   "IX-03035B      "
#define CS600   "IX-06015C      "
#define CS2700F "IX-27015C       "
#define IX_4025 "IX-4025        "
#define IX_4015 "IX-4015        "
#define IX_3010 "IX-3010        "

#include <sys/types.h>

#define AUTO_DOC_FEEDER_UNIT            0x01
#define TRANSPARENCY_UNIT               0x02
#define TRANSPARENCY_UNIT_FB1200        0x03
#define SCAN_CONTROL_CONDITIONS         0x20
#define SCAN_CONTROL_CON_FB1200         0x21
#define ALL_SCAN_MODE_PAGES             0x3F

#define RED   0
#define GREEN 1
#define BLUE  2

#define ADF_STAT_NONE		0
#define ADF_STAT_INACTIVE	1
#define ADF_STAT_ACTIVE		2
#define ADF_STAT_DISABLED	3

#define ADF_Status		(4+2)	/* byte positioning */
#define ADF_Settings		(4+3)	/* in data block    */

#define ADF_NOT_PRESENT		0x01	/* bit selection    */
#define ADF_PROBLEM		0x0E	/* from bytes in    */
#define ADF_PRIORITY		0x03	/* data block.      */
#define ADF_FEEDER		0x04	/*                  */

#define TPU_STAT_NONE		0
#define TPU_STAT_INACTIVE	1
#define TPU_STAT_ACTIVE		2

#define CS3_600  0		/* CanoScan 300/600 */
#define CS2700   1		/* CanoScan 2700F */
#define FB620    2		/* CanoScan FB620S */
#define FS2710   3		/* CanoScan FS2710S */
#define FB1200   4		/* CanoScan FB1200S */
#define IX4015   5		/* IX-4015 */

#ifndef MAX
#define MAX(A,B)	(((A) > (B))? (A) : (B))
#endif
#ifndef MIN
#define MIN(A,B)	(((A) < (B))? (A) : (B))
#endif
#ifndef SSIZE_MAX
#define SSIZE_MAX LONG_MAX
#endif

typedef struct
{
  SANE_Int Status;		/* Auto Document Feeder Unit Status */
  SANE_Int Problem;		/* ADF Problems list */
  SANE_Int Priority;		/* ADF Priority setting */
  SANE_Int Feeder;		/* ADF Feeder setting */

}
CANON_ADF;


typedef struct
{
  SANE_Int Status;		/* Transparency Unit Status */
  SANE_Bool PosNeg;		/* Negative/Positive Film */
  SANE_Int Transparency;	/* TPU Transparency */
  SANE_Int ControlMode;		/* TPU Density Control Mode */
  SANE_Int FilmType;		/* TPU Film Type */

}
CANON_TPU;


typedef enum
{
  OPT_NUM_OPTS = 0,

  OPT_MODE_GROUP,
  OPT_MODE,
  OPT_NEGATIVE,			/* Reverse image format */
  OPT_NEGATIVE_TYPE,		/* Negative film type */
  OPT_SCANNING_SPEED,

  OPT_RESOLUTION_GROUP,
  OPT_RESOLUTION_BIND,
  OPT_HW_RESOLUTION_ONLY,
  OPT_X_RESOLUTION,
  OPT_Y_RESOLUTION,

  OPT_ENHANCEMENT_GROUP,
  OPT_BRIGHTNESS,
  OPT_CONTRAST,
  OPT_THRESHOLD,

  OPT_MIRROR,

  OPT_CUSTOM_GAMMA,		/* use custom gamma tables? */
  OPT_CUSTOM_GAMMA_BIND,
  /* The gamma vectors MUST appear in the order gray, red, green, blue. */
  OPT_GAMMA_VECTOR,
  OPT_GAMMA_VECTOR_R,
  OPT_GAMMA_VECTOR_G,
  OPT_GAMMA_VECTOR_B,
  OPT_AE,			/* Auto Exposure */

  OPT_CALIBRATION_GROUP,	/* Calibration for FB620S */
  OPT_CALIBRATION_NOW,		/* Execute Calibration now for FB620S */
  OPT_SCANNER_SELF_DIAGNOSTIC,	/* Self diagnostic for FB620S */
  OPT_RESET_SCANNER,		/* Reset scanner for FB620S */

  OPT_EJECT_GROUP,
  OPT_EJECT_AFTERSCAN,
  OPT_EJECT_BEFOREEXIT,
  OPT_EJECT_NOW,

  OPT_FOCUS_GROUP,
  OPT_AF,			/* Auto Focus */
  OPT_AF_ONCE,			/* Auto Focus only once between ejects */
  OPT_FOCUS,			/* Manual focus position */

  OPT_MARGINS_GROUP,		/* scan margins */
  OPT_TL_X,			/* top-left x */
  OPT_TL_Y,			/* top-left y */
  OPT_BR_X,			/* bottom-right x */
  OPT_BR_Y,			/* bottom-right y */

  OPT_COLORS_GROUP,
  OPT_HNEGATIVE,		/* Reverse image format */
  OPT_BIND_HILO,		/* Same values vor highlight and shadow
				   points for red, green, blue */
  OPT_HILITE_R,			/* highlight point for red   */
  OPT_SHADOW_R,			/* shadow    point for red   */
  OPT_HILITE_G,			/* highlight point for green */
  OPT_SHADOW_G,			/* shadow    point for green */
  OPT_HILITE_B,			/* highlight point for blue  */
  OPT_SHADOW_B,			/* shadow    point for blue  */

  OPT_ADF_GROUP,		/* to allow display of options. */
  OPT_FLATBED_ONLY,		/* in case you have a sheetfeeder
				   but don't want to use it. */

  OPT_TPU_GROUP,
  OPT_TPU_ON,
  OPT_TPU_PN,
  OPT_TPU_DCM,
  OPT_TPU_TRANSPARENCY,
  OPT_TPU_FILMTYPE,

  OPT_PREVIEW,

  /* must come last: */
  NUM_OPTIONS
}
CANON_Option;


typedef struct CANON_Info
{
  int model;

  SANE_Range xres_range;
  SANE_Range yres_range;
  SANE_Range x_range;
  SANE_Range y_range;
  SANE_Range brightness_range;
  SANE_Range contrast_range;
  SANE_Range threshold_range;
  SANE_Range HiliteR_range;
  SANE_Range ShadowR_range;
  SANE_Range HiliteG_range;
  SANE_Range ShadowG_range;
  SANE_Range HiliteB_range;
  SANE_Range ShadowB_range;
  SANE_Range focus_range;

  SANE_Range x_adf_range;
  SANE_Range y_adf_range;
  SANE_Int xres_default;
  SANE_Int yres_default;
  SANE_Int bmu;
  SANE_Int mud;
  SANE_Range TPU_Transparency_range;
  SANE_Int TPU_Stat;

  SANE_Bool can_focus;			/* has got focus control */
  SANE_Bool can_autoexpose;		/* can do autoexposure by hardware */
  SANE_Bool can_calibrate;		/* has got calibration control */
  SANE_Bool can_diagnose;		/* has diagnostic command */
  SANE_Bool can_eject;			/* can eject medium */
  SANE_Bool can_mirror;			/* can mirror image by hardware */
  SANE_Bool is_filmscanner;
  SANE_Bool has_fixed_resolutions;	/* only a finite number possible */
}
CANON_Info;

typedef struct CANON_Device
{
  struct CANON_Device *next;
  SANE_Device sane;
  CANON_Info info;
  CANON_ADF adf;
  CANON_TPU tpu;
}
CANON_Device;

typedef struct CANON_Scanner
{
  struct CANON_Scanner *next;
  int fd;
  CANON_Device *hw;
  SANE_Option_Descriptor opt[NUM_OPTIONS];
  Option_Value val[NUM_OPTIONS];
  char *sense_str;		/* sense string */
  SANE_Int gamma_table[4][256];
  SANE_Parameters params;
  SANE_Bool AF_NOW;		/* To keep track of when to do AF */

  SANE_Int xres;
  SANE_Int yres;
  SANE_Int ulx;
  SANE_Int uly;
  SANE_Int width;
  SANE_Int length;
  SANE_Int brightness;
  SANE_Int contrast;
  SANE_Int threshold;
  SANE_Int image_composition;
  SANE_Int bpp;
  SANE_Bool RIF;		/* Reverse Image Format */
  SANE_Int negative_filmtype;
  SANE_Int scanning_speed;
  SANE_Bool GRC;		/* Gray Response Curve  */
  SANE_Bool Mirror;
  SANE_Bool AE;			/* Auto Exposure */
  SANE_Int HiliteR;
  SANE_Int ShadowR;
  SANE_Int HiliteG;
  SANE_Int ShadowG;
  SANE_Int HiliteB;
  SANE_Int ShadowB;

  /* 990320, ss: array for fixed resolutions */
  SANE_Word xres_word_list[16];
  SANE_Word yres_word_list[16];

  SANE_Byte *inbuffer;		/* modification for FB620S */
  SANE_Byte *outbuffer;		/* modification for FB620S */
  SANE_Int buf_used;		/* modification for FB620S */
  SANE_Int buf_pos;		/* modification for FB620S */
  time_t time0;			/* modification for FB620S */
  time_t time1;			/* modification for FB620S */
  int switch_preview;		/* modification for FB620S */
  int reset_flag;		/* modification for FB620S */

  int tmpfile;		        /* modification for FB1200S */

  size_t bytes_to_read;
  int scanning;

  u_char gamma_map[4][4096];	/* for FS2710S: */
  int colour;			/* index to gamma_map */
  int auxbuf_len;		/* size of auxiliary buffer */
  u_char *auxbuf;
}
CANON_Scanner;

static char *option_name[] = {
  "OPT_NUM_OPTS",

  "OPT_MODE_GROUP",
  "OPT_MODE",
  "OPT_NEGATIVE",
  "OPT_NEGATIVE_TYPE",
  "OPT_SCANNING_SPEED",

  "OPT_RESOLUTION_GROUP",
  "OPT_RESOLUTION_BIND",
  "OPT_HW_RESOLUTION_ONLY",
  "OPT_X_RESOLUTION",
  "OPT_Y_RESOLUTION",

  "OPT_ENHANCEMENT_GROUP",
  "OPT_BRIGHTNESS",
  "OPT_CONTRAST",
  "OPT_THRESHOLD",

  "OPT_MIRROR",

  "OPT_CUSTOM_GAMMA",
  "OPT_CUSTOM_GAMMA_BIND",
  "OPT_GAMMA_VECTOR",
  "OPT_GAMMA_VECTOR_R",
  "OPT_GAMMA_VECTOR_G",
  "OPT_GAMMA_VECTOR_B",
  "OPT_AE",

  "OPT_CALIBRATION_GROUP",
  "OPT_CALIBRATION_NOW",
  "OPT_SCANNER_SELF_DIAGNOSTIC",
  "OPT_RESET_SCANNER",

  "OPT_EJECT_GROUP",
  "OPT_EJECT_AFTERSCAN",
  "OPT_EJECT_BEFOREEXIT",
  "OPT_EJECT_NOW",

  "OPT_FOCUS_GROUP",
  "OPT_AF",
  "OPT_AF_ONCE",
  "OPT_FOCUS",

  "OPT_MARGINS_GROUP",
  "OPT_TL_X",
  "OPT_TL_Y",
  "OPT_BR_X",
  "OPT_BR_Y",

  "OPT_COLORS_GROUP",
  "OPT_HNEGATIVE",
  "OPT_BIND_HILO",

  "OPT_HILITE_R",
  "OPT_SHADOW_R",
  "OPT_HILITE_G",
  "OPT_SHADOW_G",
  "OPT_HILITE_B",
  "OPT_SHADOW_B",

  "OPT_ADF_GROUP",
  "OPT_FLATBED_ONLY",

  "OPT_TPU_GROUP",
  "OPT_TPU_ON",
  "OPT_TPU_PN",
  "OPT_TPU_DCM",
  "OPT_TPU_TRANSPARENCY",
  "OPT_TPU_FILMTYPE",

  "OPT_PREVIEW",

  "NUM_OPTIONS"
};




#endif /* not canon_h */