From 4c0f63052b6c91b51c9ef2d57ffccb62ec6c6fa7 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 14 Dec 2019 09:12:28 +0200 Subject: [PATCH] genesys: Add a way to configure per-sensor stagger config --- backend/genesys/genesys.cpp | 2 +- backend/genesys/sensor.cpp | 10 +++++++ backend/genesys/sensor.h | 52 +++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/backend/genesys/genesys.cpp b/backend/genesys/genesys.cpp index 1ee61c875..7603d58d8 100644 --- a/backend/genesys/genesys.cpp +++ b/backend/genesys/genesys.cpp @@ -4715,7 +4715,7 @@ static void probe_genesys_devices() of Genesys_Calibration_Cache as is. */ static const char* CALIBRATION_IDENT = "sane_genesys"; -static const int CALIBRATION_VERSION = 20; +static const int CALIBRATION_VERSION = 21; bool read_calibration(std::istream& str, Genesys_Device::Calibration& calibration, const std::string& path) diff --git a/backend/genesys/sensor.cpp b/backend/genesys/sensor.cpp index 3fdcd836d..e54af654d 100644 --- a/backend/genesys/sensor.cpp +++ b/backend/genesys/sensor.cpp @@ -49,6 +49,15 @@ namespace genesys { +std::ostream& operator<<(std::ostream& out, const StaggerConfig& config) +{ + out << "StaggerConfig{\n" + << " min_resolution: " << config.min_resolution() << '\n' + << " lines_at_min: " << config.lines_at_min() << '\n' + << "}"; + return out; +} + std::ostream& operator<<(std::ostream& out, const FrontendType& type) { switch (type) { @@ -137,6 +146,7 @@ std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor) << " segment_size: " << sensor.segment_size << '\n' << " segment_order: " << format_indent_braced_list(4, format_vector_unsigned(4, sensor.segment_order)) << '\n' + << " stagger_config: " << format_indent_braced_list(4, sensor.stagger_config) << '\n' << " custom_base_regs: " << format_indent_braced_list(4, sensor.custom_base_regs) << '\n' << " custom_regs: " << format_indent_braced_list(4, sensor.custom_regs) << '\n' << " custom_fe_regs: " << format_indent_braced_list(4, sensor.custom_fe_regs) << '\n' diff --git a/backend/genesys/sensor.h b/backend/genesys/sensor.h index 5c117a549..e70728e66 100644 --- a/backend/genesys/sensor.h +++ b/backend/genesys/sensor.h @@ -67,6 +67,51 @@ struct AssignableArray : public std::array { } }; + +class StaggerConfig +{ +public: + StaggerConfig() = default; + StaggerConfig(unsigned min_resolution, unsigned lines_at_min) : + min_resolution_{min_resolution}, + lines_at_min_{lines_at_min} + { + } + + unsigned stagger_at_resolution(unsigned xresolution, unsigned yresolution) const + { + if (min_resolution_ == 0 || xresolution < min_resolution_) + return 0; + return yresolution / min_resolution_ * lines_at_min_; + } + + unsigned min_resolution() const { return min_resolution_; } + unsigned lines_at_min() const { return lines_at_min_; } + + bool operator==(const StaggerConfig& other) const + { + return min_resolution_ == other.min_resolution_ && + lines_at_min_ == other.lines_at_min_; + } + +private: + unsigned min_resolution_ = 0; + unsigned lines_at_min_ = 0; + + template + friend void serialize(Stream& str, StaggerConfig& x); +}; + +template +void serialize(Stream& str, StaggerConfig& x) +{ + serialize(str, x.min_resolution_); + serialize(str, x.lines_at_min_); +} + +std::ostream& operator<<(std::ostream& out, const StaggerConfig& config); + + enum class FrontendType : unsigned { UNKNOWN, @@ -310,6 +355,10 @@ struct Genesys_Sensor { // only on gl843 std::vector segment_order; + // some CCDs use two arrays of pixels for double resolution. On such CCDs when scanning at + // high-enough resolution, every other pixel column is shifted + StaggerConfig stagger_config; + GenesysRegisterSettingSet custom_base_regs; // gl646-specific GenesysRegisterSettingSet custom_regs; GenesysRegisterSettingSet custom_fe_regs; @@ -370,6 +419,7 @@ struct Genesys_Sensor { exposure_lperiod == other.exposure_lperiod && segment_size == other.segment_size && segment_order == other.segment_order && + stagger_config == other.stagger_config && custom_base_regs == other.custom_base_regs && custom_regs == other.custom_regs && custom_fe_regs == other.custom_fe_regs && @@ -401,6 +451,8 @@ void serialize(Stream& str, Genesys_Sensor& x) serialize_newline(str); serialize(str, x.segment_order); serialize_newline(str); + serialize(str, x.stagger_config); + serialize_newline(str); serialize(str, x.custom_base_regs); serialize_newline(str); serialize(str, x.custom_regs);