1 /* sane - Scanner Access Now Easy.
2 
3    Copyright (C) 2010-2013 Stéphane Voltz <stef.dev@free.fr>
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 #ifndef BACKEND_GENESYS_GL847_H
22 #define BACKEND_GENESYS_GL847_H
23 
24 #include "genesys.h"
25 #include "command_set_common.h"
26 
27 namespace genesys {
28 namespace gl847 {
29 
30 class CommandSetGl847 : public CommandSetCommon
31 {
32 public:
33     ~CommandSetGl847() override = default;
34 
35     bool needs_home_before_init_regs_for_scan(Genesys_Device* dev) const override;
36 
37     void init(Genesys_Device* dev) const override;
38 
39     void init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor,
40                               Genesys_Register_Set* regs) const override;
41 
42     void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
43                                Genesys_Register_Set& regs) const override;
44 
45     void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor,
46                                     Genesys_Register_Set* reg,
47                                     const ScanSession& session) const override;
48 
49     void set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, std::uint8_t set) const override;
50     void set_powersaving(Genesys_Device* dev, int delay) const override;
51     void save_power(Genesys_Device* dev, bool enable) const override;
52 
53     void begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
54                     Genesys_Register_Set* regs, bool start_motor) const override;
55 
56     void end_scan(Genesys_Device* dev, Genesys_Register_Set* regs, bool check_stop) const override;
57 
58     void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override;
59 
60     void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
61                             Genesys_Register_Set& regs) const override;
62 
63     void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
64                                  Genesys_Register_Set& regs, int dpi) const override;
65 
66     SensorExposure led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
67                                    Genesys_Register_Set& regs) const override;
68 
69     void wait_for_motor_stop(Genesys_Device* dev) const override;
70 
71     void move_back_home(Genesys_Device* dev, bool wait_until_home) const override;
72 
73     void update_hardware_sensors(struct Genesys_Scanner* s) const override;
74 
75     void update_home_sensor_gpio(Genesys_Device& dev) const override;
76 
77     void load_document(Genesys_Device* dev) const override;
78 
79     void detect_document_end(Genesys_Device* dev) const override;
80 
81     void eject_document(Genesys_Device* dev) const override;
82 
83     void send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, std::uint8_t* data,
84                            int size) const override;
85 
86     ScanSession calculate_scan_session(const Genesys_Device* dev,
87                                        const Genesys_Sensor& sensor,
88                                        const Genesys_Settings& settings) const override;
89 
90     void asic_boot(Genesys_Device* dev, bool cold) const override;
91 };
92 
93 enum SlopeTable
94 {
95     SCAN_TABLE = 0, // table 1 at 0x4000
96     BACKTRACK_TABLE = 1, // table 2 at 0x4800
97     STOP_TABLE = 2, // table 3 at 0x5000
98     FAST_TABLE = 3, // table 4 at 0x5800
99     HOME_TABLE = 4, // table 5 at 0x6000
100 };
101 
102 } // namespace gl847
103 } // namespace genesys
104 
105 #endif // BACKEND_GENESYS_GL847_H
106