1 /* sane - Scanner Access Now Easy.
2
3 Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt>
4
5 This file is part of the SANE package.
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>.
19
20 As a special exception, the authors of SANE give permission for
21 additional uses of the libraries contained in this release of SANE.
22
23 The exception is that, if you link a SANE library with other files
24 to produce an executable, this does not by itself cause the
25 resulting executable to be covered by the GNU General Public
26 License. Your use of that executable is in no way restricted on
27 account of linking the SANE library code into it.
28
29 This exception does not, however, invalidate any other reasons why
30 the executable file might be covered by the GNU General Public
31 License.
32
33 If you submit changes to SANE to the maintainers to be included in
34 a subsequent release, you agree by submitting the changes that
35 those changes may be distributed with this exception intact.
36
37 If you write modifications of your own for SANE, it is your choice
38 whether to permit this exception to apply to your modifications.
39 If you do not wish that, delete this exception notice.
40 */
41
42 #ifndef BACKEND_GENESYS_ENUMS_H
43 #define BACKEND_GENESYS_ENUMS_H
44
45 #include <iostream>
46 #include "serialize.h"
47
48 namespace genesys {
49
50 enum class ScanMethod : unsigned {
51 // normal scan method
52 FLATBED = 0,
53 // scan using transparency adaptor
54 TRANSPARENCY = 1,
55 // scan using transparency adaptor via infrared channel
56 TRANSPARENCY_INFRARED = 2
57 };
58
59 inline std::ostream& operator<<(std::ostream& out, ScanMethod mode)
60 {
61 switch (mode) {
62 case ScanMethod::FLATBED: out << "FLATBED"; return out;
63 case ScanMethod::TRANSPARENCY: out << "TRANSPARENCY"; return out;
64 case ScanMethod::TRANSPARENCY_INFRARED: out << "TRANSPARENCY_INFRARED"; return out;
65 }
66 return out;
67 }
68
serialize(std::istream & str,ScanMethod & x)69 inline void serialize(std::istream& str, ScanMethod& x)
70 {
71 unsigned value;
72 serialize(str, value);
73 x = static_cast<ScanMethod>(value);
74 }
75
serialize(std::ostream & str,ScanMethod & x)76 inline void serialize(std::ostream& str, ScanMethod& x)
77 {
78 unsigned value = static_cast<unsigned>(x);
79 serialize(str, value);
80 }
81
82 const char* scan_method_to_option_string(ScanMethod method);
83 ScanMethod option_string_to_scan_method(const std::string& str);
84
85 enum class ScanColorMode : unsigned {
86 LINEART = 0,
87 HALFTONE,
88 GRAY,
89 COLOR_SINGLE_PASS
90 };
91
92 inline std::ostream& operator<<(std::ostream& out, ScanColorMode mode)
93 {
94 switch (mode) {
95 case ScanColorMode::LINEART: out << "LINEART"; return out;
96 case ScanColorMode::HALFTONE: out << "HALFTONE"; return out;
97 case ScanColorMode::GRAY: out << "GRAY"; return out;
98 case ScanColorMode::COLOR_SINGLE_PASS: out << "COLOR_SINGLE_PASS"; return out;
99 }
100 return out;
101 }
102
serialize(std::istream & str,ScanColorMode & x)103 inline void serialize(std::istream& str, ScanColorMode& x)
104 {
105 unsigned value;
106 serialize(str, value);
107 x = static_cast<ScanColorMode>(value);
108 }
109
serialize(std::ostream & str,ScanColorMode & x)110 inline void serialize(std::ostream& str, ScanColorMode& x)
111 {
112 unsigned value = static_cast<unsigned>(x);
113 serialize(str, value);
114 }
115
116 const char* scan_color_mode_to_option_string(ScanColorMode mode);
117 ScanColorMode option_string_to_scan_color_mode(const std::string& str);
118
119
120 enum class ScanHeadId : unsigned {
121 NONE = 0,
122 PRIMARY = 1 << 0,
123 SECONDARY = 1 << 1,
124 ALL = PRIMARY | SECONDARY,
125 };
126
127 inline ScanHeadId operator|(ScanHeadId left, ScanHeadId right)
128 {
129 return static_cast<ScanHeadId>(static_cast<unsigned>(left) | static_cast<unsigned>(right));
130 }
131
132 inline ScanHeadId operator&(ScanHeadId left, ScanHeadId right)
133 {
134 return static_cast<ScanHeadId>(static_cast<unsigned>(left) & static_cast<unsigned>(right));
135 }
136
137
138 enum class ColorFilter : unsigned {
139 RED = 0,
140 GREEN,
141 BLUE,
142 NONE
143 };
144
145 std::ostream& operator<<(std::ostream& out, ColorFilter mode);
146
serialize(std::istream & str,ColorFilter & x)147 inline void serialize(std::istream& str, ColorFilter& x)
148 {
149 unsigned value;
150 serialize(str, value);
151 x = static_cast<ColorFilter>(value);
152 }
153
serialize(std::ostream & str,ColorFilter & x)154 inline void serialize(std::ostream& str, ColorFilter& x)
155 {
156 unsigned value = static_cast<unsigned>(x);
157 serialize(str, value);
158 }
159
160 enum class ColorOrder
161 {
162 RGB,
163 GBR,
164 BGR,
165 };
166
167 /* Enum value naming conventions:
168 Full name must be included with the following exceptions:
169
170 Canon scanners omit "Canoscan" if present
171 */
172 enum class ModelId : unsigned
173 {
174 UNKNOWN = 0,
175 CANON_4400F,
176 CANON_5600F,
177 CANON_8400F,
178 CANON_8600F,
179 CANON_IMAGE_FORMULA_101,
180 CANON_LIDE_50,
181 CANON_LIDE_60,
182 CANON_LIDE_80,
183 CANON_LIDE_90,
184 CANON_LIDE_100,
185 CANON_LIDE_110,
186 CANON_LIDE_120,
187 CANON_LIDE_200,
188 CANON_LIDE_210,
189 CANON_LIDE_220,
190 CANON_LIDE_700F,
191 DCT_DOCKETPORT_487,
192 HP_SCANJET_2300C,
193 HP_SCANJET_2400C,
194 HP_SCANJET_3670,
195 HP_SCANJET_4850C,
196 HP_SCANJET_G4010,
197 HP_SCANJET_G4050,
198 HP_SCANJET_N6310,
199 MEDION_MD5345,
200 PANASONIC_KV_SS080,
201 PENTAX_DSMOBILE_600,
202 PLUSTEK_OPTICBOOK_3800,
203 PLUSTEK_OPTICFILM_7200,
204 PLUSTEK_OPTICFILM_7200I,
205 PLUSTEK_OPTICFILM_7300,
206 PLUSTEK_OPTICFILM_7400,
207 PLUSTEK_OPTICFILM_7500I,
208 PLUSTEK_OPTICFILM_8200I,
209 PLUSTEK_OPTICPRO_3600,
210 PLUSTEK_OPTICPRO_ST12,
211 PLUSTEK_OPTICPRO_ST24,
212 SYSCAN_DOCKETPORT_465,
213 SYSCAN_DOCKETPORT_467,
214 SYSCAN_DOCKETPORT_485,
215 SYSCAN_DOCKETPORT_665,
216 SYSCAN_DOCKETPORT_685,
217 UMAX_ASTRA_4500,
218 VISIONEER_7100,
219 VISIONEER_ROADWARRIOR,
220 VISIONEER_STROBE_XP100_REVISION3,
221 VISIONEER_STROBE_XP200,
222 VISIONEER_STROBE_XP300,
223 XEROX_2400,
224 XEROX_TRAVELSCANNER_100,
225 };
226
serialize(std::istream & str,ModelId & x)227 inline void serialize(std::istream& str, ModelId& x)
228 {
229 unsigned value;
230 serialize(str, value);
231 x = static_cast<ModelId>(value);
232 }
233
serialize(std::ostream & str,ModelId & x)234 inline void serialize(std::ostream& str, ModelId& x)
235 {
236 unsigned value = static_cast<unsigned>(x);
237 serialize(str, value);
238 }
239
240 std::ostream& operator<<(std::ostream& out, ModelId id);
241
242 enum class SensorId : unsigned
243 {
244 UNKNOWN = 0,
245 CCD_5345,
246 CCD_CANON_4400F,
247 CCD_CANON_5600F,
248 CCD_CANON_8400F,
249 CCD_CANON_8600F,
250 CCD_DP665,
251 CCD_DP685,
252 CCD_DSMOBILE600,
253 CCD_DOCKETPORT_487,
254 CCD_G4050,
255 CCD_HP2300,
256 CCD_HP2400,
257 CCD_HP3670,
258 CCD_HP_N6310,
259 CCD_HP_4850C,
260 CCD_IMG101,
261 CCD_KVSS080,
262 CCD_PLUSTEK_OPTICBOOK_3800,
263 CCD_PLUSTEK_OPTICFILM_7200,
264 CCD_PLUSTEK_OPTICFILM_7200I,
265 CCD_PLUSTEK_OPTICFILM_7300,
266 CCD_PLUSTEK_OPTICFILM_7400,
267 CCD_PLUSTEK_OPTICFILM_7500I,
268 CCD_PLUSTEK_OPTICFILM_8200I,
269 CCD_PLUSTEK_OPTICPRO_3600,
270 CCD_ROADWARRIOR,
271 CCD_ST12, // SONY ILX548: 5340 Pixel ???
272 CCD_ST24, // SONY ILX569: 10680 Pixel ???
273 CCD_UMAX,
274 CCD_XP300,
275 CIS_CANON_LIDE_35,
276 CIS_CANON_LIDE_60,
277 CIS_CANON_LIDE_80,
278 CIS_CANON_LIDE_90,
279 CIS_CANON_LIDE_100,
280 CIS_CANON_LIDE_110,
281 CIS_CANON_LIDE_120,
282 CIS_CANON_LIDE_200,
283 CIS_CANON_LIDE_210,
284 CIS_CANON_LIDE_220,
285 CIS_CANON_LIDE_700F,
286 CIS_XP200,
287 };
288
serialize(std::istream & str,SensorId & x)289 inline void serialize(std::istream& str, SensorId& x)
290 {
291 unsigned value;
292 serialize(str, value);
293 x = static_cast<SensorId>(value);
294 }
295
serialize(std::ostream & str,SensorId & x)296 inline void serialize(std::ostream& str, SensorId& x)
297 {
298 unsigned value = static_cast<unsigned>(x);
299 serialize(str, value);
300 }
301
302 std::ostream& operator<<(std::ostream& out, SensorId id);
303
304
305 enum class AdcId : unsigned
306 {
307 UNKNOWN = 0,
308 AD_XP200,
309 CANON_LIDE_35,
310 CANON_LIDE_80,
311 CANON_LIDE_90,
312 CANON_LIDE_110,
313 CANON_LIDE_120,
314 CANON_LIDE_200,
315 CANON_LIDE_700F,
316 CANON_4400F,
317 CANON_5600F,
318 CANON_8400F,
319 CANON_8600F,
320 G4050,
321 IMG101,
322 KVSS080,
323 PLUSTEK_OPTICBOOK_3800,
324 PLUSTEK_OPTICFILM_7200,
325 PLUSTEK_OPTICFILM_7200I,
326 PLUSTEK_OPTICFILM_7300,
327 PLUSTEK_OPTICFILM_7400,
328 PLUSTEK_OPTICFILM_7500I,
329 PLUSTEK_OPTICFILM_8200I,
330 PLUSTEK_OPTICPRO_3600,
331 WOLFSON_5345,
332 WOLFSON_DSM600,
333 WOLFSON_HP2300,
334 WOLFSON_HP2400,
335 WOLFSON_HP3670,
336 WOLFSON_ST12,
337 WOLFSON_ST24,
338 WOLFSON_UMAX,
339 WOLFSON_XP300,
340 };
341
serialize(std::istream & str,AdcId & x)342 inline void serialize(std::istream& str, AdcId& x)
343 {
344 unsigned value;
345 serialize(str, value);
346 x = static_cast<AdcId>(value);
347 }
348
serialize(std::ostream & str,AdcId & x)349 inline void serialize(std::ostream& str, AdcId& x)
350 {
351 unsigned value = static_cast<unsigned>(x);
352 serialize(str, value);
353 }
354
355 std::ostream& operator<<(std::ostream& out, AdcId id);
356
357 enum class GpioId : unsigned
358 {
359 UNKNOWN = 0,
360 CANON_LIDE_35,
361 CANON_LIDE_80,
362 CANON_LIDE_90,
363 CANON_LIDE_110,
364 CANON_LIDE_120,
365 CANON_LIDE_200,
366 CANON_LIDE_210,
367 CANON_LIDE_700F,
368 CANON_4400F,
369 CANON_5600F,
370 CANON_8400F,
371 CANON_8600F,
372 DP665,
373 DP685,
374 G4050,
375 HP2300,
376 HP2400,
377 HP3670,
378 HP_N6310,
379 IMG101,
380 KVSS080,
381 MD_5345,
382 PLUSTEK_OPTICBOOK_3800,
383 PLUSTEK_OPTICFILM_7200,
384 PLUSTEK_OPTICFILM_7200I,
385 PLUSTEK_OPTICFILM_7300,
386 PLUSTEK_OPTICFILM_7400,
387 PLUSTEK_OPTICFILM_7500I,
388 PLUSTEK_OPTICFILM_8200I,
389 PLUSTEK_OPTICPRO_3600,
390 ST12,
391 ST24,
392 UMAX,
393 XP200,
394 XP300,
395 };
396
397 std::ostream& operator<<(std::ostream& out, GpioId id);
398
399 enum class MotorId : unsigned
400 {
401 UNKNOWN = 0,
402 CANON_LIDE_100,
403 CANON_LIDE_110,
404 CANON_LIDE_120,
405 CANON_LIDE_200,
406 CANON_LIDE_210,
407 CANON_LIDE_35,
408 CANON_LIDE_60,
409 CANON_LIDE_700,
410 CANON_LIDE_80,
411 CANON_LIDE_90,
412 CANON_4400F,
413 CANON_5600F,
414 CANON_8400F,
415 CANON_8600F,
416 DP665,
417 DSMOBILE_600,
418 G4050,
419 HP2300,
420 HP2400,
421 HP3670,
422 IMG101,
423 KVSS080,
424 MD_5345,
425 PLUSTEK_OPTICBOOK_3800,
426 PLUSTEK_OPTICFILM_7200,
427 PLUSTEK_OPTICFILM_7200I,
428 PLUSTEK_OPTICFILM_7300,
429 PLUSTEK_OPTICFILM_7400,
430 PLUSTEK_OPTICFILM_7500I,
431 PLUSTEK_OPTICFILM_8200I,
432 PLUSTEK_OPTICPRO_3600,
433 ROADWARRIOR,
434 ST24,
435 UMAX,
436 XP200,
437 XP300,
438 };
439
440 std::ostream& operator<<(std::ostream& out, MotorId id);
441
442 enum class StepType : unsigned
443 {
444 FULL = 0,
445 HALF = 1,
446 QUARTER = 2,
447 EIGHTH = 3,
448 };
449
450 std::ostream& operator<<(std::ostream& out, StepType type);
451
452 inline bool operator<(StepType lhs, StepType rhs)
453 {
454 return static_cast<unsigned>(lhs) < static_cast<unsigned>(rhs);
455 }
456 inline bool operator<=(StepType lhs, StepType rhs)
457 {
458 return static_cast<unsigned>(lhs) <= static_cast<unsigned>(rhs);
459 }
460 inline bool operator>(StepType lhs, StepType rhs)
461 {
462 return static_cast<unsigned>(lhs) > static_cast<unsigned>(rhs);
463 }
464 inline bool operator>=(StepType lhs, StepType rhs)
465 {
466 return static_cast<unsigned>(lhs) >= static_cast<unsigned>(rhs);
467 }
468
469 enum class AsicType : unsigned
470 {
471 UNKNOWN = 0,
472 GL646,
473 GL841,
474 GL842,
475 GL843,
476 GL845,
477 GL846,
478 GL847,
479 GL124,
480 };
481
482
483 enum class ModelFlag : unsigned
484 {
485 // no flags
486 NONE = 0,
487
488 // scanner is not tested, print a warning as it's likely it won't work
489 UNTESTED = 1 << 0,
490
491 // use 14-bit gamma table instead of 12-bit
492 GAMMA_14BIT = 1 << 1,
493
494 // perform lamp warmup
495 WARMUP = 1 << 4,
496
497 // whether to disable offset and gain calibration
498 DISABLE_ADC_CALIBRATION = 1 << 5,
499
500 // whether to disable exposure calibration (this currently is only done on CIS
501 // scanners)
502 DISABLE_EXPOSURE_CALIBRATION = 1 << 6,
503
504 // whether to disable shading calibration completely
505 DISABLE_SHADING_CALIBRATION = 1 << 7,
506
507 // do dark calibration
508 DARK_CALIBRATION = 1 << 8,
509
510 // host-side calibration uses a complete scan
511 HOST_SIDE_CALIBRATION_COMPLETE_SCAN = 1 << 9,
512
513 // whether scanner must wait for the head while parking
514 MUST_WAIT = 1 << 10,
515
516 // use zeroes for dark calibration
517 USE_CONSTANT_FOR_DARK_CALIBRATION = 1 << 11,
518
519 // do dark and white calibration in one run
520 DARK_WHITE_CALIBRATION = 1 << 12,
521
522 // allow custom gamma tables
523 CUSTOM_GAMMA = 1 << 13,
524
525 // disable fast feeding mode on this scanner
526 DISABLE_FAST_FEEDING = 1 << 14,
527
528 // the scanner uses multi-segment sensors that must be handled during calibration
529 SIS_SENSOR = 1 << 16,
530
531 // the head must be reparked between shading scans
532 SHADING_REPARK = 1 << 18,
533
534 // the scanner outputs inverted pixel data
535 INVERT_PIXEL_DATA = 1 << 19,
536
537 // the scanner outputs 16-bit data that is byte-inverted
538 SWAP_16BIT_DATA = 1 << 20,
539
540 // the scanner has transparency, but it's implemented using only one motor
541 UTA_NO_SECONDARY_MOTOR = 1 << 21,
542
543 // the scanner has transparency, but it's implemented using only one lamp
544 TA_NO_SECONDARY_LAMP = 1 << 22,
545 };
546
547 inline ModelFlag operator|(ModelFlag left, ModelFlag right)
548 {
549 return static_cast<ModelFlag>(static_cast<unsigned>(left) | static_cast<unsigned>(right));
550 }
551
552 inline ModelFlag& operator|=(ModelFlag& left, ModelFlag right)
553 {
554 left = left | right;
555 return left;
556 }
557
558 inline ModelFlag operator&(ModelFlag left, ModelFlag right)
559 {
560 return static_cast<ModelFlag>(static_cast<unsigned>(left) & static_cast<unsigned>(right));
561 }
562
has_flag(ModelFlag flags,ModelFlag which)563 inline bool has_flag(ModelFlag flags, ModelFlag which)
564 {
565 return (flags & which) == which;
566 }
567
568
569 enum class ScanFlag : unsigned
570 {
571 NONE = 0,
572 SINGLE_LINE = 1 << 0,
573 DISABLE_SHADING = 1 << 1,
574 DISABLE_GAMMA = 1 << 2,
575 DISABLE_BUFFER_FULL_MOVE = 1 << 3,
576
577 // if this flag is set the sensor will always be handled ignoring staggering of multiple
578 // sensors to achieve high resolution.
579 IGNORE_STAGGER_OFFSET = 1 << 4,
580
581 // if this flag is set the sensor will always be handled as if the components that scan
582 // different colors are at the same position.
583 IGNORE_COLOR_OFFSET = 1 << 5,
584
585 DISABLE_LAMP = 1 << 6,
586 CALIBRATION = 1 << 7,
587 FEEDING = 1 << 8,
588 USE_XPA = 1 << 9,
589 ENABLE_LEDADD = 1 << 10,
590 REVERSE = 1 << 12,
591
592 // the scanner should return head to home position automatically after scan.
593 AUTO_GO_HOME = 1 << 13,
594 };
595
596 inline ScanFlag operator|(ScanFlag left, ScanFlag right)
597 {
598 return static_cast<ScanFlag>(static_cast<unsigned>(left) | static_cast<unsigned>(right));
599 }
600
601 inline ScanFlag& operator|=(ScanFlag& left, ScanFlag right)
602 {
603 left = left | right;
604 return left;
605 }
606
607 inline ScanFlag operator&(ScanFlag left, ScanFlag right)
608 {
609 return static_cast<ScanFlag>(static_cast<unsigned>(left) & static_cast<unsigned>(right));
610 }
611
has_flag(ScanFlag flags,ScanFlag which)612 inline bool has_flag(ScanFlag flags, ScanFlag which)
613 {
614 return (flags & which) == which;
615 }
616
serialize(std::istream & str,ScanFlag & x)617 inline void serialize(std::istream& str, ScanFlag& x)
618 {
619 unsigned value;
620 serialize(str, value);
621 x = static_cast<ScanFlag>(value);
622 }
623
serialize(std::ostream & str,ScanFlag & x)624 inline void serialize(std::ostream& str, ScanFlag& x)
625 {
626 unsigned value = static_cast<unsigned>(x);
627 serialize(str, value);
628 }
629
630 std::ostream& operator<<(std::ostream& out, ScanFlag flags);
631
632
633 enum class Direction : unsigned
634 {
635 FORWARD = 0,
636 BACKWARD = 1
637 };
638
639 enum class MotorMode : unsigned
640 {
641 PRIMARY = 0,
642 PRIMARY_AND_SECONDARY,
643 SECONDARY,
644 };
645
646 } // namespace genesys
647
648 #endif // BACKEND_GENESYS_ENUMS_H
649