1 /* sane - Scanner Access Now Easy. 2 Copyright (C) 1997 BYTEC GmbH Germany 3 Written by Helmut Koeberle, Email: helmut.koeberle@bytec.de 4 Modified by Manuel Panea <Manuel.Panea@rzg.mpg.de>, 5 Markus Mertinat <Markus.Mertinat@Physik.Uni-Augsburg.DE>, 6 and ULrich Deiters <ulrich.deiters@uni-koeln.de> 7 8 This file is part of the SANE package. 9 10 This program is free software; you can redistribute it and/or 11 modify it under the terms of the GNU General Public License as 12 published by the Free Software Foundation; either version 2 of the 13 License, or (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, but 16 WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program. If not, see <https://www.gnu.org/licenses/>. 22 23 As a special exception, the authors of SANE give permission for 24 additional uses of the libraries contained in this release of SANE. 25 26 The exception is that, if you link a SANE library with other files 27 to produce an executable, this does not by itself cause the 28 resulting executable to be covered by the GNU General Public 29 License. Your use of that executable is in no way restricted on 30 account of linking the SANE library code into it. 31 32 This exception does not, however, invalidate any other reasons why 33 the executable file might be covered by the GNU General Public 34 License. 35 36 If you submit changes to SANE to the maintainers to be included in 37 a subsequent release, you agree by submitting the changes that 38 those changes may be distributed with this exception intact. 39 40 If you write modifications of your own for SANE, it is your choice 41 whether to permit this exception to apply to your modifications. 42 If you do not wish that, delete this exception notice. */ 43 44 #ifndef canon_h 45 #define canon_h 1 46 47 /* all the different possible model names. */ 48 #define FB1200S "IX-12015E " 49 #define FB620S "IX-06035E " 50 #define CS300 "IX-03035B " 51 #define CS600 "IX-06015C " 52 #define CS2700F "IX-27015C " 53 #define IX_4025 "IX-4025 " 54 #define IX_4015 "IX-4015 " 55 #define IX_3010 "IX-3010 " 56 57 #include <sys/types.h> 58 59 #define AUTO_DOC_FEEDER_UNIT 0x01 60 #define TRANSPARENCY_UNIT 0x02 61 #define TRANSPARENCY_UNIT_FB1200 0x03 62 #define SCAN_CONTROL_CONDITIONS 0x20 63 #define SCAN_CONTROL_CON_FB1200 0x21 64 #define ALL_SCAN_MODE_PAGES 0x3F 65 66 #define RED 0 67 #define GREEN 1 68 #define BLUE 2 69 70 #define ADF_STAT_NONE 0 71 #define ADF_STAT_INACTIVE 1 72 #define ADF_STAT_ACTIVE 2 73 #define ADF_STAT_DISABLED 3 74 75 #define ADF_Status (4+2) /* byte positioning */ 76 #define ADF_Settings (4+3) /* in data block */ 77 78 #define ADF_NOT_PRESENT 0x01 /* bit selection */ 79 #define ADF_PROBLEM 0x0E /* from bytes in */ 80 #define ADF_PRIORITY 0x03 /* data block. */ 81 #define ADF_FEEDER 0x04 /* */ 82 83 #define TPU_STAT_NONE 0 84 #define TPU_STAT_INACTIVE 1 85 #define TPU_STAT_ACTIVE 2 86 87 #define CS3_600 0 /* CanoScan 300/600 */ 88 #define CS2700 1 /* CanoScan 2700F */ 89 #define FB620 2 /* CanoScan FB620S */ 90 #define FS2710 3 /* CanoScan FS2710S */ 91 #define FB1200 4 /* CanoScan FB1200S */ 92 #define IX4015 5 /* IX-4015 */ 93 94 #ifndef MAX 95 #define MAX(A,B) (((A) > (B))? (A) : (B)) 96 #endif 97 #ifndef MIN 98 #define MIN(A,B) (((A) < (B))? (A) : (B)) 99 #endif 100 #ifndef SSIZE_MAX 101 #define SSIZE_MAX LONG_MAX 102 #endif 103 104 typedef struct 105 { 106 SANE_Int Status; /* Auto Document Feeder Unit Status */ 107 SANE_Int Problem; /* ADF Problems list */ 108 SANE_Int Priority; /* ADF Priority setting */ 109 SANE_Int Feeder; /* ADF Feeder setting */ 110 111 } 112 CANON_ADF; 113 114 115 typedef struct 116 { 117 SANE_Int Status; /* Transparency Unit Status */ 118 SANE_Bool PosNeg; /* Negative/Positive Film */ 119 SANE_Int Transparency; /* TPU Transparency */ 120 SANE_Int ControlMode; /* TPU Density Control Mode */ 121 SANE_Int FilmType; /* TPU Film Type */ 122 123 } 124 CANON_TPU; 125 126 127 typedef enum 128 { 129 OPT_NUM_OPTS = 0, 130 131 OPT_MODE_GROUP, 132 OPT_MODE, 133 OPT_NEGATIVE, /* Reverse image format */ 134 OPT_NEGATIVE_TYPE, /* Negative film type */ 135 OPT_SCANNING_SPEED, 136 137 OPT_RESOLUTION_GROUP, 138 OPT_RESOLUTION_BIND, 139 OPT_HW_RESOLUTION_ONLY, 140 OPT_X_RESOLUTION, 141 OPT_Y_RESOLUTION, 142 143 OPT_ENHANCEMENT_GROUP, 144 OPT_BRIGHTNESS, 145 OPT_CONTRAST, 146 OPT_THRESHOLD, 147 148 OPT_MIRROR, 149 150 OPT_CUSTOM_GAMMA, /* use custom gamma tables? */ 151 OPT_CUSTOM_GAMMA_BIND, 152 /* The gamma vectors MUST appear in the order gray, red, green, blue. */ 153 OPT_GAMMA_VECTOR, 154 OPT_GAMMA_VECTOR_R, 155 OPT_GAMMA_VECTOR_G, 156 OPT_GAMMA_VECTOR_B, 157 OPT_AE, /* Auto Exposure */ 158 159 OPT_CALIBRATION_GROUP, /* Calibration for FB620S */ 160 OPT_CALIBRATION_NOW, /* Execute Calibration now for FB620S */ 161 OPT_SCANNER_SELF_DIAGNOSTIC, /* Self diagnostic for FB620S */ 162 OPT_RESET_SCANNER, /* Reset scanner for FB620S */ 163 164 OPT_EJECT_GROUP, 165 OPT_EJECT_AFTERSCAN, 166 OPT_EJECT_BEFOREEXIT, 167 OPT_EJECT_NOW, 168 169 OPT_FOCUS_GROUP, 170 OPT_AF, /* Auto Focus */ 171 OPT_AF_ONCE, /* Auto Focus only once between ejects */ 172 OPT_FOCUS, /* Manual focus position */ 173 174 OPT_MARGINS_GROUP, /* scan margins */ 175 OPT_TL_X, /* top-left x */ 176 OPT_TL_Y, /* top-left y */ 177 OPT_BR_X, /* bottom-right x */ 178 OPT_BR_Y, /* bottom-right y */ 179 180 OPT_COLORS_GROUP, 181 OPT_HNEGATIVE, /* Reverse image format */ 182 OPT_BIND_HILO, /* Same values vor highlight and shadow 183 points for red, green, blue */ 184 OPT_HILITE_R, /* highlight point for red */ 185 OPT_SHADOW_R, /* shadow point for red */ 186 OPT_HILITE_G, /* highlight point for green */ 187 OPT_SHADOW_G, /* shadow point for green */ 188 OPT_HILITE_B, /* highlight point for blue */ 189 OPT_SHADOW_B, /* shadow point for blue */ 190 191 OPT_ADF_GROUP, /* to allow display of options. */ 192 OPT_FLATBED_ONLY, /* in case you have a sheetfeeder 193 but don't want to use it. */ 194 195 OPT_TPU_GROUP, 196 OPT_TPU_ON, 197 OPT_TPU_PN, 198 OPT_TPU_DCM, 199 OPT_TPU_TRANSPARENCY, 200 OPT_TPU_FILMTYPE, 201 202 OPT_PREVIEW, 203 204 /* must come last: */ 205 NUM_OPTIONS 206 } 207 CANON_Option; 208 209 210 typedef struct CANON_Info 211 { 212 int model; 213 214 SANE_Range xres_range; 215 SANE_Range yres_range; 216 SANE_Range x_range; 217 SANE_Range y_range; 218 SANE_Range brightness_range; 219 SANE_Range contrast_range; 220 SANE_Range threshold_range; 221 SANE_Range HiliteR_range; 222 SANE_Range ShadowR_range; 223 SANE_Range HiliteG_range; 224 SANE_Range ShadowG_range; 225 SANE_Range HiliteB_range; 226 SANE_Range ShadowB_range; 227 SANE_Range focus_range; 228 229 SANE_Range x_adf_range; 230 SANE_Range y_adf_range; 231 SANE_Int xres_default; 232 SANE_Int yres_default; 233 SANE_Int bmu; 234 SANE_Int mud; 235 SANE_Range TPU_Transparency_range; 236 SANE_Int TPU_Stat; 237 238 SANE_Bool can_focus; /* has got focus control */ 239 SANE_Bool can_autoexpose; /* can do autoexposure by hardware */ 240 SANE_Bool can_calibrate; /* has got calibration control */ 241 SANE_Bool can_diagnose; /* has diagnostic command */ 242 SANE_Bool can_eject; /* can eject medium */ 243 SANE_Bool can_mirror; /* can mirror image by hardware */ 244 SANE_Bool is_filmscanner; 245 SANE_Bool has_fixed_resolutions; /* only a finite number possible */ 246 } 247 CANON_Info; 248 249 typedef struct CANON_Device 250 { 251 struct CANON_Device *next; 252 SANE_Device sane; 253 CANON_Info info; 254 CANON_ADF adf; 255 CANON_TPU tpu; 256 } 257 CANON_Device; 258 259 typedef struct CANON_Scanner 260 { 261 struct CANON_Scanner *next; 262 int fd; 263 CANON_Device *hw; 264 SANE_Option_Descriptor opt[NUM_OPTIONS]; 265 Option_Value val[NUM_OPTIONS]; 266 char *sense_str; /* sense string */ 267 SANE_Int gamma_table[4][256]; 268 SANE_Parameters params; 269 SANE_Bool AF_NOW; /* To keep track of when to do AF */ 270 271 SANE_Int xres; 272 SANE_Int yres; 273 SANE_Int ulx; 274 SANE_Int uly; 275 SANE_Int width; 276 SANE_Int length; 277 SANE_Int brightness; 278 SANE_Int contrast; 279 SANE_Int threshold; 280 SANE_Int image_composition; 281 SANE_Int bpp; 282 SANE_Bool RIF; /* Reverse Image Format */ 283 SANE_Int negative_filmtype; 284 SANE_Int scanning_speed; 285 SANE_Bool GRC; /* Gray Response Curve */ 286 SANE_Bool Mirror; 287 SANE_Bool AE; /* Auto Exposure */ 288 SANE_Int HiliteR; 289 SANE_Int ShadowR; 290 SANE_Int HiliteG; 291 SANE_Int ShadowG; 292 SANE_Int HiliteB; 293 SANE_Int ShadowB; 294 295 /* 990320, ss: array for fixed resolutions */ 296 SANE_Word xres_word_list[16]; 297 SANE_Word yres_word_list[16]; 298 299 SANE_Byte *inbuffer; /* modification for FB620S */ 300 SANE_Byte *outbuffer; /* modification for FB620S */ 301 SANE_Int buf_used; /* modification for FB620S */ 302 SANE_Int buf_pos; /* modification for FB620S */ 303 time_t time0; /* modification for FB620S */ 304 time_t time1; /* modification for FB620S */ 305 int switch_preview; /* modification for FB620S */ 306 int reset_flag; /* modification for FB620S */ 307 308 int tmpfile; /* modification for FB1200S */ 309 310 size_t bytes_to_read; 311 int scanning; 312 313 u_char gamma_map[4][4096]; /* for FS2710S: */ 314 int colour; /* index to gamma_map */ 315 int auxbuf_len; /* size of auxiliary buffer */ 316 u_char *auxbuf; 317 } 318 CANON_Scanner; 319 320 static char *option_name[] = { 321 "OPT_NUM_OPTS", 322 323 "OPT_MODE_GROUP", 324 "OPT_MODE", 325 "OPT_NEGATIVE", 326 "OPT_NEGATIVE_TYPE", 327 "OPT_SCANNING_SPEED", 328 329 "OPT_RESOLUTION_GROUP", 330 "OPT_RESOLUTION_BIND", 331 "OPT_HW_RESOLUTION_ONLY", 332 "OPT_X_RESOLUTION", 333 "OPT_Y_RESOLUTION", 334 335 "OPT_ENHANCEMENT_GROUP", 336 "OPT_BRIGHTNESS", 337 "OPT_CONTRAST", 338 "OPT_THRESHOLD", 339 340 "OPT_MIRROR", 341 342 "OPT_CUSTOM_GAMMA", 343 "OPT_CUSTOM_GAMMA_BIND", 344 "OPT_GAMMA_VECTOR", 345 "OPT_GAMMA_VECTOR_R", 346 "OPT_GAMMA_VECTOR_G", 347 "OPT_GAMMA_VECTOR_B", 348 "OPT_AE", 349 350 "OPT_CALIBRATION_GROUP", 351 "OPT_CALIBRATION_NOW", 352 "OPT_SCANNER_SELF_DIAGNOSTIC", 353 "OPT_RESET_SCANNER", 354 355 "OPT_EJECT_GROUP", 356 "OPT_EJECT_AFTERSCAN", 357 "OPT_EJECT_BEFOREEXIT", 358 "OPT_EJECT_NOW", 359 360 "OPT_FOCUS_GROUP", 361 "OPT_AF", 362 "OPT_AF_ONCE", 363 "OPT_FOCUS", 364 365 "OPT_MARGINS_GROUP", 366 "OPT_TL_X", 367 "OPT_TL_Y", 368 "OPT_BR_X", 369 "OPT_BR_Y", 370 371 "OPT_COLORS_GROUP", 372 "OPT_HNEGATIVE", 373 "OPT_BIND_HILO", 374 375 "OPT_HILITE_R", 376 "OPT_SHADOW_R", 377 "OPT_HILITE_G", 378 "OPT_SHADOW_G", 379 "OPT_HILITE_B", 380 "OPT_SHADOW_B", 381 382 "OPT_ADF_GROUP", 383 "OPT_FLATBED_ONLY", 384 385 "OPT_TPU_GROUP", 386 "OPT_TPU_ON", 387 "OPT_TPU_PN", 388 "OPT_TPU_DCM", 389 "OPT_TPU_TRANSPARENCY", 390 "OPT_TPU_FILMTYPE", 391 392 "OPT_PREVIEW", 393 394 "NUM_OPTIONS" 395 }; 396 397 398 399 400 #endif /* not canon_h */ 401