From ad1067ad03b4a043372ce6c2ec6408448e65e4ff Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 13 Sep 2019 10:52:35 +0300 Subject: [PATCH] genesys: Add support for segmented sensors on gl843 --- backend/genesys.cc | 2 +- backend/genesys_gl843.cc | 5 +++++ backend/genesys_low.cc | 10 +++++++++- backend/genesys_sensor.h | 22 ++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/backend/genesys.cc b/backend/genesys.cc index d0d88bd60..60d1ba046 100644 --- a/backend/genesys.cc +++ b/backend/genesys.cc @@ -5178,7 +5178,7 @@ probe_genesys_devices (void) of Genesys_Calibration_Cache as is. */ static const char* CALIBRATION_IDENT = "sane_genesys"; -static const int CALIBRATION_VERSION = 8; +static const int CALIBRATION_VERSION = 9; bool read_calibration(std::istream& str, Genesys_Device::Calibration& calibration, const std::string& path) diff --git a/backend/genesys_gl843.cc b/backend/genesys_gl843.cc index f1855ad65..7d3f7b11a 100644 --- a/backend/genesys_gl843.cc +++ b/backend/genesys_gl843.cc @@ -200,6 +200,8 @@ static void gl843_setup_sensor(Genesys_Device* dev, const Genesys_Sensor& sensor if (!(dev->model->flags & GENESYS_FLAG_FULL_HWDPI_MODE)) { regs->set8(0x7d, 0x90); } + + dev->segment_order = sensor.segment_order; } @@ -1299,6 +1301,9 @@ static void gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens dev->out_buffer.clear(); dev->out_buffer.alloc(session.buffer_size_out); + dev->oe_buffer.clear(); + dev->oe_buffer.alloc(session.output_line_bytes_raw * 2); + dev->read_bytes_left_after_deseg = session.output_line_bytes * session.output_line_count; DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, diff --git a/backend/genesys_low.cc b/backend/genesys_low.cc index c7369ea2c..765cc0884 100644 --- a/backend/genesys_low.cc +++ b/backend/genesys_low.cc @@ -1322,6 +1322,8 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& s.segment_count = 1; if (dev->model->flags & GENESYS_FLAG_SIS_SENSOR || dev->model->asic_type == AsicType::GL124) { s.segment_count = sensor_profile->get_segment_count(); + } else { + s.segment_count = sensor.get_segment_count(); } s.optical_pixels_raw = s.optical_pixels; @@ -1363,8 +1365,14 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& s.conseq_pixel_dist_bytes = s.output_line_bytes_raw / s.segment_count; } + if (dev->model->asic_type == AsicType::GL843) { + s.conseq_pixel_dist_bytes = s.output_line_bytes_raw / s.segment_count; + } + s.output_segment_pixel_group_count = 0; - if (dev->model->asic_type == AsicType::GL124) { + if (dev->model->asic_type == AsicType::GL124 || + dev->model->asic_type == AsicType::GL843) + { s.output_segment_pixel_group_count = s.output_line_bytes_raw / s.segment_count; } if (dev->model->asic_type == AsicType::GL845 || diff --git a/backend/genesys_sensor.h b/backend/genesys_sensor.h index 9bcc07258..ce7ce6f22 100644 --- a/backend/genesys_sensor.h +++ b/backend/genesys_sensor.h @@ -303,6 +303,15 @@ struct Genesys_Sensor { int exposure_lperiod = -1; + // the number of pixels in a single segment. + // only on gl843 + unsigned segment_size = 0; + + // the order of the segments, if any, for the sensor. If the sensor is not segmented or uses + // only single segment, this array can be empty + // only on gl843 + std::vector segment_order; + GenesysRegisterSettingSet custom_base_regs; // gl646-specific GenesysRegisterSettingSet custom_regs; GenesysRegisterSettingSet custom_fe_regs; @@ -341,6 +350,13 @@ struct Genesys_Sensor { return std::find(channels.begin(), channels.end(), count) != channels.end(); } + unsigned get_segment_count() const + { + if (segment_order.size() < 2) + return 1; + return segment_order.size(); + } + bool operator==(const Genesys_Sensor& other) const { return sensor_id == other.sensor_id && @@ -356,6 +372,8 @@ struct Genesys_Sensor { gain_white_ref == other.gain_white_ref && exposure == other.exposure && exposure_lperiod == other.exposure_lperiod && + segment_size == other.segment_size && + segment_order == other.segment_order && custom_base_regs == other.custom_base_regs && custom_regs == other.custom_regs && custom_fe_regs == other.custom_fe_regs && @@ -384,6 +402,10 @@ void serialize(Stream& str, Genesys_Sensor& x) serialize(str, x.exposure.red); serialize(str, x.exposure_lperiod); serialize_newline(str); + serialize(str, x.segment_size); + serialize_newline(str); + serialize(str, x.segment_order); + serialize_newline(str); serialize(str, x.custom_base_regs); serialize_newline(str); serialize(str, x.custom_regs);