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_SCANNER_INTERFACE_H 43 #define BACKEND_GENESYS_SCANNER_INTERFACE_H 44 45 #include "fwd.h" 46 #include <cstddef> 47 #include <cstdint> 48 #include <string> 49 #include <vector> 50 51 namespace genesys { 52 53 // Represents an interface through which all low level operations are performed. 54 class ScannerInterface 55 { 56 public: 57 58 virtual ~ScannerInterface(); 59 60 virtual bool is_mock() const = 0; 61 62 virtual std::uint8_t read_register(std::uint16_t address) = 0; 63 virtual void write_register(std::uint16_t address, std::uint8_t value) = 0; 64 virtual void write_registers(const Genesys_Register_Set& regs) = 0; 65 66 virtual void write_0x8c(std::uint8_t index, std::uint8_t value) = 0; 67 virtual void bulk_read_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) = 0; 68 virtual void bulk_write_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) = 0; 69 70 // GL646, GL841, GL843 have different ways to write to RAM and to gamma tables 71 virtual void write_buffer(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, 72 std::size_t size) = 0; 73 74 virtual void write_gamma(std::uint8_t type, std::uint32_t addr, std::uint8_t* data, 75 std::size_t size) = 0; 76 77 // GL845, GL846, GL847 and GL124 have a uniform way to write to RAM tables 78 virtual void write_ahb(std::uint32_t addr, std::uint32_t size, std::uint8_t* data) = 0; 79 80 virtual std::uint16_t read_fe_register(std::uint8_t address) = 0; 81 virtual void write_fe_register(std::uint8_t address, std::uint16_t value) = 0; 82 83 virtual IUsbDevice& get_usb_device() = 0; 84 85 // sleeps the specified number of microseconds. Will not sleep if testing mode is enabled. 86 virtual void sleep_us(unsigned microseconds) = 0; 87 sleep_ms(unsigned milliseconds)88 void sleep_ms(unsigned milliseconds) 89 { 90 sleep_us(milliseconds * 1000); 91 } 92 93 virtual void record_progress_message(const char* msg) = 0; 94 95 virtual void record_slope_table(unsigned table_nr, const std::vector<std::uint16_t>& steps) = 0; 96 97 virtual void record_key_value(const std::string& key, const std::string& value) = 0; 98 99 virtual void test_checkpoint(const std::string& name) = 0; 100 }; 101 102 } // namespace genesys 103 104 #endif 105