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
21 #define DEBUG_DECLARE_ONLY
22
23 #include "sensor.h"
24 #include "utilities.h"
25 #include <iomanip>
26
27 namespace genesys {
28
operator <<(std::ostream& out, const StaggerConfig& config)29 std::ostream& operator<<(std::ostream& out, const StaggerConfig& config)
30 {
31 if (config.shifts().empty()) {
32 out << "StaggerConfig{}";
33 return out;
34 }
35
36 out << "StaggerConfig{ " << config.shifts().front();
37 for (auto it = std::next(config.shifts().begin()); it != config.shifts().end(); ++it) {
38 out << ", " << *it;
39 }
40 out << " }";
41 return out;
42 }
43
operator <<(std::ostream& out, const FrontendType& type)44 std::ostream& operator<<(std::ostream& out, const FrontendType& type)
45 {
46 switch (type) {
47 case FrontendType::UNKNOWN: out << "UNKNOWN"; break;
48 case FrontendType::WOLFSON: out << "WOLFSON"; break;
49 case FrontendType::ANALOG_DEVICES: out << "ANALOG_DEVICES"; break;
50 case FrontendType::CANON_LIDE_80: out << "CANON_LIDE_80"; break;
51 case FrontendType::WOLFSON_GL841: out << "WOLFSON_GL841"; break;
52 case FrontendType::WOLFSON_GL846: out << "WOLFSON_GL846"; break;
53 case FrontendType::ANALOG_DEVICES_GL847: out << "ANALOG_DEVICES_GL847"; break;
54 case FrontendType::WOLFSON_GL124: out << "WOLFSON_GL124"; break;
55 default: out << "(unknown value)";
56 }
57 return out;
58 }
59
operator <<(std::ostream& out, const GenesysFrontendLayout& layout)60 std::ostream& operator<<(std::ostream& out, const GenesysFrontendLayout& layout)
61 {
62 StreamStateSaver state_saver{out};
63
64 out << "GenesysFrontendLayout{\n"
65 << " type: " << layout.type << '\n'
66 << std::hex
67 << " offset_addr[0]: " << layout.offset_addr[0] << '\n'
68 << " offset_addr[1]: " << layout.offset_addr[1] << '\n'
69 << " offset_addr[2]: " << layout.offset_addr[2] << '\n'
70 << " gain_addr[0]: " << layout.gain_addr[0] << '\n'
71 << " gain_addr[1]: " << layout.gain_addr[1] << '\n'
72 << " gain_addr[2]: " << layout.gain_addr[2] << '\n'
73 << '}';
74 return out;
75 }
76
operator <<(std::ostream& out, const Genesys_Frontend& frontend)77 std::ostream& operator<<(std::ostream& out, const Genesys_Frontend& frontend)
78 {
79 StreamStateSaver state_saver{out};
80
81 out << "Genesys_Frontend{\n"
82 << " id: " << frontend.id << '\n'
83 << " regs: " << format_indent_braced_list(4, frontend.regs) << '\n'
84 << std::hex
85 << " reg2[0]: " << frontend.reg2[0] << '\n'
86 << " reg2[1]: " << frontend.reg2[1] << '\n'
87 << " reg2[2]: " << frontend.reg2[2] << '\n'
88 << " layout: " << format_indent_braced_list(4, frontend.layout) << '\n'
89 << '}';
90 return out;
91 }
92
operator <<(std::ostream& out, const SensorExposure& exposure)93 std::ostream& operator<<(std::ostream& out, const SensorExposure& exposure)
94 {
95 out << "SensorExposure{\n"
96 << " red: " << exposure.red << '\n'
97 << " green: " << exposure.green << '\n'
98 << " blue: " << exposure.blue << '\n'
99 << '}';
100 return out;
101 }
102
operator <<(std::ostream& out, const Genesys_Sensor& sensor)103 std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor)
104 {
105 out << "Genesys_Sensor{\n"
106 << " sensor_id: " << static_cast<unsigned>(sensor.sensor_id) << '\n'
107 << " full_resolution: " << sensor.full_resolution << '\n'
108 << " optical_resolution: " << sensor.get_optical_resolution() << '\n'
109 << " resolutions: " << format_indent_braced_list(4, sensor.resolutions) << '\n'
110 << " channels: " << format_vector_unsigned(4, sensor.channels) << '\n'
111 << " method: " << sensor.method << '\n'
112 << " register_dpihw: " << sensor.register_dpihw << '\n'
113 << " register_dpiset: " << sensor.register_dpiset << '\n'
114 << " shading_factor: " << sensor.shading_factor << '\n'
115 << " shading_pixel_offset: " << sensor.shading_pixel_offset << '\n'
116 << " pixel_count_ratio: " << sensor.pixel_count_ratio << '\n'
117 << " output_pixel_offset: " << sensor.output_pixel_offset << '\n'
118 << " black_pixels: " << sensor.black_pixels << '\n'
119 << " dummy_pixel: " << sensor.dummy_pixel << '\n'
120 << " fau_gain_white_ref: " << sensor.fau_gain_white_ref << '\n'
121 << " gain_white_ref: " << sensor.gain_white_ref << '\n'
122 << " exposure: " << format_indent_braced_list(4, sensor.exposure) << '\n'
123 << " exposure_lperiod: " << sensor.exposure_lperiod << '\n'
124 << " segment_size: " << sensor.segment_size << '\n'
125 << " segment_order: "
126 << format_indent_braced_list(4, format_vector_unsigned(4, sensor.segment_order)) << '\n'
127 << " stagger_x: " << sensor.stagger_x << '\n'
128 << " stagger_y: " << sensor.stagger_y << '\n'
129 << " use_host_side_calib: " << sensor.use_host_side_calib << '\n'
130 << " custom_regs: " << format_indent_braced_list(4, sensor.custom_regs) << '\n'
131 << " custom_fe_regs: " << format_indent_braced_list(4, sensor.custom_fe_regs) << '\n'
132 << " gamma.red: " << sensor.gamma[0] << '\n'
133 << " gamma.green: " << sensor.gamma[1] << '\n'
134 << " gamma.blue: " << sensor.gamma[2] << '\n'
135 << "}";
136 return out;
137 }
138
139 } // namespace genesys
140