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    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 #include "genesys.h"
43 #include "command_set_common.h"
44 
45 #ifndef BACKEND_GENESYS_GL843_H
46 #define BACKEND_GENESYS_GL843_H
47 
48 namespace genesys {
49 namespace gl843 {
50 
51 class CommandSetGl843 : public CommandSetCommon
52 {
53 public:
54     ~CommandSetGl843() override = default;
55 
56     bool needs_home_before_init_regs_for_scan(Genesys_Device* dev) const override;
57 
58     void init(Genesys_Device* dev) const override;
59 
60     void init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor,
61                               Genesys_Register_Set* regs) const override;
62 
63     void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
64                                Genesys_Register_Set& regs) const override;
65 
66     void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor,
67                                     Genesys_Register_Set* reg,
68                                     const ScanSession& session) const override;
69 
70     void set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const override;
71     void set_powersaving(Genesys_Device* dev, int delay) const override;
72     void save_power(Genesys_Device* dev, bool enable) const override;
73 
74     void begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
75                     Genesys_Register_Set* regs, bool start_motor) const override;
76 
77     void end_scan(Genesys_Device* dev, Genesys_Register_Set* regs, bool check_stop) const override;
78 
79     void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override;
80 
81     void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
82                             Genesys_Register_Set& regs) const override;
83 
84     void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
85                                  Genesys_Register_Set& regs, int dpi) const override;
86 
87     SensorExposure led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
88                                    Genesys_Register_Set& regs) const override;
89 
90     void wait_for_motor_stop(Genesys_Device* dev) const override;
91 
92     void move_back_home(Genesys_Device* dev, bool wait_until_home) const override;
93 
94     void update_hardware_sensors(struct Genesys_Scanner* s) const override;
95 
96     void update_home_sensor_gpio(Genesys_Device& dev) const override;
97 
98     void load_document(Genesys_Device* dev) const override;
99 
100     void detect_document_end(Genesys_Device* dev) const override;
101 
102     void eject_document(Genesys_Device* dev) const override;
103 
104     void send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t* data,
105                            int size) const override;
106 
107     ScanSession calculate_scan_session(const Genesys_Device* dev,
108                                        const Genesys_Sensor& sensor,
109                                        const Genesys_Settings& settings) const override;
110 
111     void asic_boot(Genesys_Device* dev, bool cold) const override;
112 };
113 
114 enum SlopeTable
115 {
116     SCAN_TABLE = 0, // table 1 at 0x4000
117     BACKTRACK_TABLE = 1, // table 2 at 0x4800
118     STOP_TABLE = 2, // table 3 at 0x5000
119     FAST_TABLE = 3, // table 4 at 0x5800
120     HOME_TABLE = 4, // table 5 at 0x6000
121 };
122 
123 } // namespace gl843
124 } // namespace genesys
125 
126 #endif // BACKEND_GENESYS_GL843_H
127