1141cc406Sopenharmony_ci/* sane - Scanner Access Now Easy.
2141cc406Sopenharmony_ci
3141cc406Sopenharmony_ci   Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt>
4141cc406Sopenharmony_ci
5141cc406Sopenharmony_ci   This file is part of the SANE package.
6141cc406Sopenharmony_ci
7141cc406Sopenharmony_ci   This program is free software; you can redistribute it and/or
8141cc406Sopenharmony_ci   modify it under the terms of the GNU General Public License as
9141cc406Sopenharmony_ci   published by the Free Software Foundation; either version 2 of the
10141cc406Sopenharmony_ci   License, or (at your option) any later version.
11141cc406Sopenharmony_ci
12141cc406Sopenharmony_ci   This program is distributed in the hope that it will be useful, but
13141cc406Sopenharmony_ci   WITHOUT ANY WARRANTY; without even the implied warranty of
14141cc406Sopenharmony_ci   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15141cc406Sopenharmony_ci   General Public License for more details.
16141cc406Sopenharmony_ci
17141cc406Sopenharmony_ci   You should have received a copy of the GNU General Public License
18141cc406Sopenharmony_ci   along with this program.  If not, see <https://www.gnu.org/licenses/>.
19141cc406Sopenharmony_ci*/
20141cc406Sopenharmony_ci
21141cc406Sopenharmony_ci#ifndef BACKEND_GENESYS_COMMAND_SET_H
22141cc406Sopenharmony_ci#define BACKEND_GENESYS_COMMAND_SET_H
23141cc406Sopenharmony_ci
24141cc406Sopenharmony_ci#include "device.h"
25141cc406Sopenharmony_ci#include "fwd.h"
26141cc406Sopenharmony_ci#include <cstdint>
27141cc406Sopenharmony_ci
28141cc406Sopenharmony_cinamespace genesys {
29141cc406Sopenharmony_ci
30141cc406Sopenharmony_ci
31141cc406Sopenharmony_ci/** Scanner command set description.
32141cc406Sopenharmony_ci
33141cc406Sopenharmony_ci    This description contains parts which are common to all scanners with the
34141cc406Sopenharmony_ci    same command set, but may have different optical resolution and other
35141cc406Sopenharmony_ci    parameters.
36141cc406Sopenharmony_ci */
37141cc406Sopenharmony_ciclass CommandSet
38141cc406Sopenharmony_ci{
39141cc406Sopenharmony_cipublic:
40141cc406Sopenharmony_ci    virtual ~CommandSet() = default;
41141cc406Sopenharmony_ci
42141cc406Sopenharmony_ci    virtual bool needs_home_before_init_regs_for_scan(Genesys_Device* dev) const = 0;
43141cc406Sopenharmony_ci
44141cc406Sopenharmony_ci    virtual void init(Genesys_Device* dev) const = 0;
45141cc406Sopenharmony_ci
46141cc406Sopenharmony_ci    virtual void init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor& sensor,
47141cc406Sopenharmony_ci                                      Genesys_Register_Set* regs) const = 0;
48141cc406Sopenharmony_ci
49141cc406Sopenharmony_ci    virtual void init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
50141cc406Sopenharmony_ci                                       Genesys_Register_Set& regs) const = 0;
51141cc406Sopenharmony_ci
52141cc406Sopenharmony_ci    /** Set up registers for a scan. Similar to init_regs_for_scan except that the session is
53141cc406Sopenharmony_ci        already computed from the session
54141cc406Sopenharmony_ci    */
55141cc406Sopenharmony_ci    virtual void init_regs_for_scan_session(Genesys_Device* dev, const Genesys_Sensor& sensor,
56141cc406Sopenharmony_ci                                            Genesys_Register_Set* reg,
57141cc406Sopenharmony_ci                                            const ScanSession& session) const= 0;
58141cc406Sopenharmony_ci
59141cc406Sopenharmony_ci    virtual void set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, std::uint8_t set) const = 0;
60141cc406Sopenharmony_ci    virtual void set_powersaving(Genesys_Device* dev, int delay) const = 0;
61141cc406Sopenharmony_ci    virtual void save_power(Genesys_Device* dev, bool enable) const = 0;
62141cc406Sopenharmony_ci
63141cc406Sopenharmony_ci    virtual void begin_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
64141cc406Sopenharmony_ci                            Genesys_Register_Set* regs, bool start_motor) const = 0;
65141cc406Sopenharmony_ci    virtual void end_scan(Genesys_Device* dev, Genesys_Register_Set* regs,
66141cc406Sopenharmony_ci                          bool check_stop) const = 0;
67141cc406Sopenharmony_ci
68141cc406Sopenharmony_ci
69141cc406Sopenharmony_ci    /**
70141cc406Sopenharmony_ci     * Send gamma tables to ASIC
71141cc406Sopenharmony_ci     */
72141cc406Sopenharmony_ci    virtual void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const = 0;
73141cc406Sopenharmony_ci
74141cc406Sopenharmony_ci    virtual void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
75141cc406Sopenharmony_ci                                    Genesys_Register_Set& regs) const = 0;
76141cc406Sopenharmony_ci    virtual void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
77141cc406Sopenharmony_ci                                         Genesys_Register_Set& regs, int dpi) const = 0;
78141cc406Sopenharmony_ci    virtual SensorExposure led_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor,
79141cc406Sopenharmony_ci                                           Genesys_Register_Set& regs) const = 0;
80141cc406Sopenharmony_ci
81141cc406Sopenharmony_ci    virtual void wait_for_motor_stop(Genesys_Device* dev) const = 0;
82141cc406Sopenharmony_ci    virtual void move_back_home(Genesys_Device* dev, bool wait_until_home) const = 0;
83141cc406Sopenharmony_ci
84141cc406Sopenharmony_ci    // Updates hardware sensor information in Genesys_Scanner.val[].
85141cc406Sopenharmony_ci    virtual void update_hardware_sensors(struct Genesys_Scanner* s) const = 0;
86141cc406Sopenharmony_ci
87141cc406Sopenharmony_ci    /** Needed on some chipsets before reading the status of the home sensor as the sensor may be
88141cc406Sopenharmony_ci        controlled by additional GPIO registers.
89141cc406Sopenharmony_ci    */
90141cc406Sopenharmony_ci    virtual void update_home_sensor_gpio(Genesys_Device& dev) const = 0;
91141cc406Sopenharmony_ci
92141cc406Sopenharmony_ci    // functions for sheetfed scanners
93141cc406Sopenharmony_ci
94141cc406Sopenharmony_ci    // load document into scanner
95141cc406Sopenharmony_ci    virtual void load_document(Genesys_Device* dev) const = 0;
96141cc406Sopenharmony_ci
97141cc406Sopenharmony_ci    /** Detects is the scanned document has left scanner. In this case it updates the amount of
98141cc406Sopenharmony_ci        data to read and set up flags in the dev struct
99141cc406Sopenharmony_ci     */
100141cc406Sopenharmony_ci    virtual void detect_document_end(Genesys_Device* dev) const = 0;
101141cc406Sopenharmony_ci
102141cc406Sopenharmony_ci    /// eject document from scanner
103141cc406Sopenharmony_ci    virtual void eject_document(Genesys_Device* dev) const = 0;
104141cc406Sopenharmony_ci
105141cc406Sopenharmony_ci    /// write shading data calibration to ASIC
106141cc406Sopenharmony_ci    virtual void send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor,
107141cc406Sopenharmony_ci                                   std::uint8_t* data, int size) const = 0;
108141cc406Sopenharmony_ci
109141cc406Sopenharmony_ci    virtual bool has_send_shading_data() const
110141cc406Sopenharmony_ci    {
111141cc406Sopenharmony_ci        return true;
112141cc406Sopenharmony_ci    }
113141cc406Sopenharmony_ci
114141cc406Sopenharmony_ci    /// calculate an instance of ScanSession for scanning with the given settings
115141cc406Sopenharmony_ci    virtual ScanSession calculate_scan_session(const Genesys_Device* dev,
116141cc406Sopenharmony_ci                                               const Genesys_Sensor& sensor,
117141cc406Sopenharmony_ci                                               const Genesys_Settings& settings) const = 0;
118141cc406Sopenharmony_ci
119141cc406Sopenharmony_ci    /// cold boot init function
120141cc406Sopenharmony_ci    virtual void asic_boot(Genesys_Device* dev, bool cold) const = 0;
121141cc406Sopenharmony_ci
122141cc406Sopenharmony_ci    /// checks if specific scan head is at home position
123141cc406Sopenharmony_ci    virtual bool is_head_home(Genesys_Device& dev, ScanHeadId scan_head) const = 0;
124141cc406Sopenharmony_ci
125141cc406Sopenharmony_ci    /// enables or disables XPA slider motor
126141cc406Sopenharmony_ci    virtual void set_xpa_lamp_power(Genesys_Device& dev, bool set) const = 0;
127141cc406Sopenharmony_ci
128141cc406Sopenharmony_ci    /// enables or disables XPA slider motor
129141cc406Sopenharmony_ci    virtual void set_motor_mode(Genesys_Device& dev, Genesys_Register_Set& regs,
130141cc406Sopenharmony_ci                                MotorMode mode) const = 0;
131141cc406Sopenharmony_ci};
132141cc406Sopenharmony_ci
133141cc406Sopenharmony_ci} // namespace genesys
134141cc406Sopenharmony_ci
135141cc406Sopenharmony_ci#endif // BACKEND_GENESYS_COMMAND_SET_H
136