From df0fccf899d13269bd24952da30e17543f38dd78 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:37:57 +0300 Subject: [PATCH 01/12] genesys: Fix incorrect handling of start position on gl843 --- backend/genesys/gl843.cpp | 9 --------- backend/genesys/low.cpp | 6 +++--- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/backend/genesys/gl843.cpp b/backend/genesys/gl843.cpp index 2ae985449..333950321 100644 --- a/backend/genesys/gl843.cpp +++ b/backend/genesys/gl843.cpp @@ -1188,15 +1188,6 @@ ScanSession CommandSetGl843::calculate_scan_session(const Genesys_Device* dev, } start = start + settings.tl_x; - if ((dev->model->model_id == ModelId::CANON_4400F && - settings.scan_method == ScanMethod::TRANSPARENCY) || - dev->model->model_id == ModelId::CANON_8400F || - dev->model->model_id == ModelId::CANON_8600F) - { - // FIXME: this is probably just an artifact of a bug elsewhere - start /= sensor.get_ccd_size_divisor_for_dpi(settings.xres); - } - start = static_cast((start * settings.xres) / MM_PER_INCH); ScanSession session; diff --git a/backend/genesys/low.cpp b/backend/genesys/low.cpp index a68a7ee47..afd15480b 100644 --- a/backend/genesys/low.cpp +++ b/backend/genesys/low.cpp @@ -831,12 +831,12 @@ void compute_session_pixel_offsets(const Genesys_Device* dev, ScanSession& s, s.pixel_startx += s.output_startx * sensor.optical_res / s.params.xres; s.pixel_endx = s.pixel_startx + s.optical_pixels * s.ccd_size_divisor; - } else if (dev->model->asic_type == AsicType::GL841) { + } else if (dev->model->asic_type == AsicType::GL841 || + dev->model->asic_type == AsicType::GL843) { s.pixel_startx = (s.output_startx * s.optical_resolution) / s.params.xres; s.pixel_endx = s.pixel_startx + s.optical_pixels; - } else if (dev->model->asic_type == AsicType::GL843 || - dev->model->asic_type == AsicType::GL845 || + } else if (dev->model->asic_type == AsicType::GL845 || dev->model->asic_type == AsicType::GL846 || dev->model->asic_type == AsicType::GL847 || dev->model->asic_type == AsicType::GL124) From 664c07c01a4502546ac89211211dcb8261c8877f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:37:58 +0300 Subject: [PATCH 02/12] genesys: Add a way to configure shading pixel offset --- backend/genesys/sensor.cpp | 1 + backend/genesys/sensor.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/backend/genesys/sensor.cpp b/backend/genesys/sensor.cpp index 73c968316..a74fb69e9 100644 --- a/backend/genesys/sensor.cpp +++ b/backend/genesys/sensor.cpp @@ -129,6 +129,7 @@ std::ostream& operator<<(std::ostream& out, const Genesys_Sensor& sensor) << " register_dpiset: " << sensor.register_dpiset << '\n' << " ccd_size_divisor: " << sensor.ccd_size_divisor << '\n' << " shading_factor: " << sensor.shading_factor << '\n' + << " shading_pixel_offset: " << sensor.shading_pixel_offset << '\n' << " pixel_count_ratio: " << sensor.pixel_count_ratio << '\n' << " output_pixel_offset: " << sensor.output_pixel_offset << '\n' << " black_pixels: " << sensor.black_pixels << '\n' diff --git a/backend/genesys/sensor.h b/backend/genesys/sensor.h index e3dc11ace..c44c1ae6b 100644 --- a/backend/genesys/sensor.h +++ b/backend/genesys/sensor.h @@ -286,6 +286,9 @@ struct Genesys_Sensor { // How many real pixels correspond to one shading pixel that is sent to the scanner unsigned shading_factor = 1; + // How many pixels the shading data is offset from the acquired data + int shading_pixel_offset = 0; + // This defines the ratio between logical pixel coordinates and the pixel coordinates sent to // the scanner. Ratio pixel_count_ratio = Ratio{1, 1}; @@ -365,6 +368,7 @@ struct Genesys_Sensor { shading_resolution == other.shading_resolution && ccd_size_divisor == other.ccd_size_divisor && shading_factor == other.shading_factor && + shading_pixel_offset == other.shading_pixel_offset && pixel_count_ratio == other.pixel_count_ratio && output_pixel_offset == other.output_pixel_offset && black_pixels == other.black_pixels && @@ -394,6 +398,7 @@ void serialize(Stream& str, Genesys_Sensor& x) serialize(str, x.shading_resolution); serialize(str, x.ccd_size_divisor); serialize(str, x.shading_factor); + serialize(str, x.shading_pixel_offset); serialize(str, x.output_pixel_offset); serialize(str, x.pixel_count_ratio); serialize(str, x.black_pixels); From 4b796205254c0b41370e806b07990117d1ea4444 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:37:59 +0300 Subject: [PATCH 03/12] genesys: Fix shading resolution on 8400F 400dpi --- backend/genesys/tables_sensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/genesys/tables_sensor.cpp b/backend/genesys/tables_sensor.cpp index 6cdd41b69..fe3faa310 100644 --- a/backend/genesys/tables_sensor.cpp +++ b/backend/genesys/tables_sensor.cpp @@ -2127,7 +2127,7 @@ void genesys_init_sensor_tables() for (auto method : setting.methods) {for (auto resolution : setting.resolutions.values()) { sensor.resolutions = { resolution }; - sensor.shading_resolution = std::max(800u, resolution); + sensor.shading_resolution = resolution; sensor.register_dpiset = setting.register_dpiset; sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.exposure_lperiod = setting.exposure_lperiod; From 6fea625ad6030e78218f089ff344a93baec4efaf Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:38:00 +0300 Subject: [PATCH 04/12] genesys: Support custom shading offset on gl843 --- backend/genesys/gl843.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/genesys/gl843.cpp b/backend/genesys/gl843.cpp index 333950321..8dd9e4792 100644 --- a/backend/genesys/gl843.cpp +++ b/backend/genesys/gl843.cpp @@ -1964,7 +1964,7 @@ void CommandSetGl843::send_shading_data(Genesys_Device* dev, const Genesys_Senso uint8_t *buffer; int count; - unsigned offset = 0; + int offset = 0; unsigned length = size; if (dev->reg.get8(REG_0x01) & REG_0x01_SHDAREA) { @@ -1974,9 +1974,13 @@ void CommandSetGl843::send_shading_data(Genesys_Device* dev, const Genesys_Senso length = dev->session.output_pixels * sensor.shading_resolution / dev->session.params.xres; + offset += sensor.shading_pixel_offset; + // 16 bit words, 2 words per color, 3 color channels length *= 2 * 2 * 3; offset *= 2 * 2 * 3; + } else { + offset += sensor.shading_pixel_offset * 2 * 2 * 3; } dev->interface->record_key_value("shading_offset", std::to_string(offset)); @@ -1990,6 +1994,11 @@ void CommandSetGl843::send_shading_data(Genesys_Device* dev, const Genesys_Senso /* copy regular shading data to the expected layout */ buffer = final_data.data(); count = 0; + if (offset < 0) { + count += (-offset); + length -= (-offset); + offset = 0; + } /* loop over calibration data */ for (i = 0; i < length; i++) From 82b42862abfb8f0b2473198486c416fe2aef9d25 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:38:01 +0300 Subject: [PATCH 05/12] genesys: Fix calibration on 8400F --- backend/genesys/tables_sensor.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/backend/genesys/tables_sensor.cpp b/backend/genesys/tables_sensor.cpp index fe3faa310..5864a296a 100644 --- a/backend/genesys/tables_sensor.cpp +++ b/backend/genesys/tables_sensor.cpp @@ -2006,13 +2006,14 @@ void genesys_init_sensor_tables() Ratio pixel_count_ratio; int exposure_lperiod; unsigned output_pixel_offset; + int shading_pixel_offset; std::vector methods; GenesysRegisterSettingSet extra_custom_regs; GenesysRegisterSettingSet custom_fe_regs; }; CustomSensorSettings custom_settings[] = { - { { 400 }, 2400, Ratio{1, 4}, 7200, 2, { ScanMethod::FLATBED }, { + { { 400 }, 2400, Ratio{1, 4}, 7200, 2, 0, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, @@ -2024,7 +2025,7 @@ void genesys_init_sensor_tables() { 0x80, 0x2a }, }, {} }, - { { 800 }, 4800, Ratio{1, 4}, 7200, 5, { ScanMethod::FLATBED }, { + { { 800 }, 4800, Ratio{1, 4}, 7200, 5, 13, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, @@ -2036,7 +2037,7 @@ void genesys_init_sensor_tables() { 0x80, 0x20 }, }, {} }, - { { 1600 }, 4800, Ratio{1, 2}, 14400, 10, { ScanMethod::FLATBED }, { + { { 1600 }, 4800, Ratio{1, 2}, 14400, 10, 8, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x11 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa1 }, { 0x52, 0x0b }, { 0x53, 0x0e }, { 0x54, 0x11 }, { 0x55, 0x02 }, @@ -2050,7 +2051,7 @@ void genesys_init_sensor_tables() { 0x03, 0x1f }, } }, - { { 3200 }, 4800, Ratio{1, 1}, 28800, 20, { ScanMethod::FLATBED }, { + { { 3200 }, 4800, Ratio{1, 1}, 28800, 20, -2, { ScanMethod::FLATBED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x84 }, { 0x1e, 0xa1 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, @@ -2064,8 +2065,8 @@ void genesys_init_sensor_tables() { 0x03, 0x1f }, }, }, - { { 400 }, 2400, Ratio{1, 4}, 14400, 2, { ScanMethod::TRANSPARENCY, - ScanMethod::TRANSPARENCY_INFRARED }, { + { { 400 }, 2400, Ratio{1, 4}, 14400, 2, 0, { ScanMethod::TRANSPARENCY, + ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, @@ -2077,8 +2078,8 @@ void genesys_init_sensor_tables() { 0x80, 0x20 }, }, {} }, - { { 800 }, 4800, Ratio{1, 4}, 14400, 5, { ScanMethod::TRANSPARENCY, - ScanMethod::TRANSPARENCY_INFRARED }, { + { { 800 }, 4800, Ratio{1, 4}, 14400, 5, 13, { ScanMethod::TRANSPARENCY, + ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x13 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0d }, { 0x53, 0x10 }, { 0x54, 0x01 }, { 0x55, 0x04 }, @@ -2090,8 +2091,8 @@ void genesys_init_sensor_tables() { 0x80, 0x20 }, }, {} }, - { { 1600 }, 4800, Ratio{1, 2}, 28800, 10, { ScanMethod::TRANSPARENCY, - ScanMethod::TRANSPARENCY_INFRARED }, { + { { 1600 }, 4800, Ratio{1, 2}, 28800, 10, 8, { ScanMethod::TRANSPARENCY, + ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x11 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x0b }, { 0x53, 0x0e }, { 0x54, 0x11 }, { 0x55, 0x02 }, @@ -2105,8 +2106,8 @@ void genesys_init_sensor_tables() { 0x03, 0x1f }, }, }, - { { 3200 }, 4800, Ratio{1, 1}, 28800, 20, { ScanMethod::TRANSPARENCY, - ScanMethod::TRANSPARENCY_INFRARED }, { + { { 3200 }, 4800, Ratio{1, 1}, 28800, 20, 10, { ScanMethod::TRANSPARENCY, + ScanMethod::TRANSPARENCY_INFRARED }, { { 0x16, 0x33 }, { 0x17, 0x0c }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x20 }, { 0x1d, 0x84 }, { 0x1e, 0xa0 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b }, @@ -2132,6 +2133,7 @@ void genesys_init_sensor_tables() sensor.pixel_count_ratio = setting.pixel_count_ratio; sensor.exposure_lperiod = setting.exposure_lperiod; sensor.output_pixel_offset = setting.output_pixel_offset; + sensor.shading_pixel_offset = setting.shading_pixel_offset; sensor.method = method; sensor.custom_regs = setting.extra_custom_regs; sensor.custom_fe_regs = setting.custom_fe_regs; From f03b7ad29f4d6d7d4b15ab3e7d9addf22eb06d80 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:38:02 +0300 Subject: [PATCH 06/12] genesys: Fix alignment of transparency scans of different dpi on 8600F --- backend/genesys/tables_sensor.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/genesys/tables_sensor.cpp b/backend/genesys/tables_sensor.cpp index 5864a296a..926219e8e 100644 --- a/backend/genesys/tables_sensor.cpp +++ b/backend/genesys/tables_sensor.cpp @@ -2216,7 +2216,7 @@ void genesys_init_sensor_tables() }, {}, }, - { { 300 }, 1200, 45000, 1, { ScanMethod::TRANSPARENCY, + { { 300 }, 1200, 45000, 6, { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { { 0x0c, 0x00 }, { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, @@ -2232,7 +2232,7 @@ void genesys_init_sensor_tables() }, {}, }, - { { 600 }, 2400, 45000, 2, { ScanMethod::TRANSPARENCY, + { { 600 }, 2400, 45000, 11, { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { { 0x0c, 0x00 }, { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, @@ -2248,7 +2248,7 @@ void genesys_init_sensor_tables() }, {}, }, - { { 1200 }, 4800, 45000, 5, { ScanMethod::TRANSPARENCY, + { { 1200 }, 4800, 45000, 23, { ScanMethod::TRANSPARENCY, ScanMethod::TRANSPARENCY_INFRARED }, { { 0x0c, 0x00 }, { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, @@ -2280,8 +2280,8 @@ void genesys_init_sensor_tables() }, {}, }, - { { 4800 }, 4800, 45000, 20, { ScanMethod::TRANSPARENCY, - ScanMethod::TRANSPARENCY_INFRARED }, { + { { 4800 }, 4800, 45000, 285, { ScanMethod::TRANSPARENCY, + ScanMethod::TRANSPARENCY_INFRARED }, { { 0x0c, 0x00 }, { 0x16, 0x13 }, { 0x17, 0x15 }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x61 }, { 0x1d, 0x75 }, From aec867d1e8edc47c726453b40d349d1eeeb6356b Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:38:03 +0300 Subject: [PATCH 07/12] genesys: Support negative output_pixel_offset --- backend/genesys/low.cpp | 6 ++- backend/genesys/sensor.h | 2 +- backend/genesys/tables_sensor.cpp | 64 +++++++++++++++---------------- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/backend/genesys/low.cpp b/backend/genesys/low.cpp index afd15480b..0eb09a209 100644 --- a/backend/genesys/low.cpp +++ b/backend/genesys/low.cpp @@ -955,7 +955,11 @@ void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Se // after all adjustments on the optical pixels have been made, compute the number of pixels // to retrieve from the chip s.output_pixels = (s.optical_pixels * s.output_resolution) / s.optical_resolution; - s.output_startx = s.params.startx + sensor.output_pixel_offset; + + if (static_cast(s.params.startx) + sensor.output_pixel_offset < 0) + throw SaneException("Invalid sensor.output_pixel_offset"); + s.output_startx = static_cast( + static_cast(s.params.startx) + sensor.output_pixel_offset); s.num_staggered_lines = 0; if (!has_flag(s.params.flags, ScanFlag::IGNORE_STAGGER_OFFSET)) diff --git a/backend/genesys/sensor.h b/backend/genesys/sensor.h index c44c1ae6b..32f11adaf 100644 --- a/backend/genesys/sensor.h +++ b/backend/genesys/sensor.h @@ -294,7 +294,7 @@ struct Genesys_Sensor { Ratio pixel_count_ratio = Ratio{1, 1}; // The offset in pixels in terms of scan resolution that needs to be applied to scan position. - unsigned output_pixel_offset = 0; + int output_pixel_offset = 0; int black_pixels = 0; // value of the dummy register diff --git a/backend/genesys/tables_sensor.cpp b/backend/genesys/tables_sensor.cpp index 926219e8e..6755c8b1c 100644 --- a/backend/genesys/tables_sensor.cpp +++ b/backend/genesys/tables_sensor.cpp @@ -118,7 +118,7 @@ void genesys_init_sensor_tables() { ValueFilterAny resolutions; unsigned register_dpiset; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -160,7 +160,7 @@ void genesys_init_sensor_tables() struct CustomSensorSettings { ValueFilterAny resolutions; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -202,7 +202,7 @@ void genesys_init_sensor_tables() { ValueFilterAny resolutions; unsigned register_dpiset; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -250,7 +250,7 @@ void genesys_init_sensor_tables() unsigned exposure_lperiod; unsigned ccd_size_divisor; Ratio pixel_count_ratio; - unsigned output_pixel_offset; + int output_pixel_offset; GenesysRegisterSettingSet custom_regs; }; @@ -378,7 +378,7 @@ void genesys_init_sensor_tables() unsigned register_dpiset; unsigned exposure_lperiod; Ratio pixel_count_ratio; - unsigned output_pixel_offset; + int output_pixel_offset; GenesysRegisterSettingSet custom_regs; }; @@ -479,7 +479,7 @@ void genesys_init_sensor_tables() unsigned exposure_lperiod; unsigned ccd_size_divisor; Ratio pixel_count_ratio; - unsigned output_pixel_offset; + int output_pixel_offset; GenesysRegisterSettingSet custom_regs; }; @@ -574,7 +574,7 @@ void genesys_init_sensor_tables() unsigned register_dpihw; unsigned register_dpiset; unsigned shading_resolution; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -630,7 +630,7 @@ void genesys_init_sensor_tables() std::vector channels; unsigned exposure_lperiod; SensorExposure exposure; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -685,7 +685,7 @@ void genesys_init_sensor_tables() unsigned register_dpiset; unsigned exposure_lperiod; Ratio pixel_count_ratio; - unsigned output_pixel_offset; + int output_pixel_offset; GenesysRegisterSettingSet custom_regs; }; @@ -805,7 +805,7 @@ void genesys_init_sensor_tables() { ValueFilterAny resolutions; unsigned register_dpiset; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -861,7 +861,7 @@ void genesys_init_sensor_tables() { ValueFilterAny resolutions; unsigned register_dpiset; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -918,7 +918,7 @@ void genesys_init_sensor_tables() { ValueFilterAny resolutions; unsigned register_dpiset; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -974,7 +974,7 @@ void genesys_init_sensor_tables() { ValueFilterAny resolutions; unsigned register_dpiset; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -1030,7 +1030,7 @@ void genesys_init_sensor_tables() { ValueFilterAny resolutions; unsigned register_dpiset; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -1087,7 +1087,7 @@ void genesys_init_sensor_tables() { ValueFilterAny resolutions; unsigned register_dpiset; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -1125,7 +1125,7 @@ void genesys_init_sensor_tables() SensorExposure exposure; Ratio pixel_count_ratio; unsigned shading_factor; - unsigned output_pixel_offset; + int output_pixel_offset; unsigned segment_size; std::vector segment_order; GenesysRegisterSettingSet custom_regs; @@ -1286,7 +1286,7 @@ void genesys_init_sensor_tables() SensorExposure exposure; Ratio pixel_count_ratio; unsigned shading_factor; - unsigned output_pixel_offset; + int output_pixel_offset; unsigned segment_size; std::vector segment_order; GenesysRegisterSettingSet custom_regs; @@ -1431,7 +1431,7 @@ void genesys_init_sensor_tables() SensorExposure exposure; Ratio pixel_count_ratio; unsigned shading_factor; - unsigned output_pixel_offset; + int output_pixel_offset; unsigned segment_size; std::vector segment_order; GenesysRegisterSettingSet custom_regs; @@ -1589,7 +1589,7 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; unsigned register_dpiset; Ratio pixel_count_ratio; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -1632,7 +1632,7 @@ void genesys_init_sensor_tables() int exposure_lperiod; ScanMethod method; Ratio pixel_count_ratio; - unsigned output_pixel_offset; + int output_pixel_offset; GenesysRegisterSettingSet extra_custom_regs; }; @@ -1759,7 +1759,7 @@ void genesys_init_sensor_tables() int exposure_lperiod; ScanMethod method; Ratio pixel_count_ratio; - unsigned output_pixel_offset; + int output_pixel_offset; GenesysRegisterSettingSet extra_custom_regs; }; @@ -1880,7 +1880,7 @@ void genesys_init_sensor_tables() unsigned register_dpiset; int exposure_lperiod; bool use_host_side_calib; - unsigned output_pixel_offset; + int output_pixel_offset; std::vector methods; GenesysRegisterSettingSet extra_custom_regs; GenesysRegisterSettingSet extra_custom_fe_regs; @@ -2005,7 +2005,7 @@ void genesys_init_sensor_tables() unsigned register_dpiset; Ratio pixel_count_ratio; int exposure_lperiod; - unsigned output_pixel_offset; + int output_pixel_offset; int shading_pixel_offset; std::vector methods; GenesysRegisterSettingSet extra_custom_regs; @@ -2164,7 +2164,7 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; unsigned register_dpiset; int exposure_lperiod; - unsigned output_pixel_offset; + int output_pixel_offset; std::vector methods; GenesysRegisterSettingSet extra_custom_regs; GenesysRegisterSettingSet custom_fe_regs; @@ -2354,7 +2354,7 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; unsigned register_dpihw; unsigned shading_factor; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -3146,7 +3146,7 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; unsigned register_dpihw; unsigned register_dpiset; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -3219,7 +3219,7 @@ void genesys_init_sensor_tables() unsigned ccd_size_divisor; unsigned shading_resolution; Ratio pixel_count_ratio; - unsigned output_pixel_offset; + int output_pixel_offset; unsigned exposure_lperiod; unsigned register_dpiset; GenesysRegisterSettingSet custom_fe_regs; @@ -3307,7 +3307,7 @@ void genesys_init_sensor_tables() unsigned ccd_size_divisor; unsigned shading_resolution; Ratio pixel_count_ratio; - unsigned output_pixel_offset; + int output_pixel_offset; unsigned register_dpiset; }; @@ -3362,7 +3362,7 @@ void genesys_init_sensor_tables() { ValueFilterAny resolutions; unsigned register_dpiset; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -3432,7 +3432,7 @@ void genesys_init_sensor_tables() unsigned ccd_size_divisor; unsigned shading_resolution; Ratio pixel_count_ratio; - unsigned output_pixel_offset; + int output_pixel_offset; unsigned exposure_lperiod; unsigned register_dpiset; }; @@ -3495,7 +3495,7 @@ void genesys_init_sensor_tables() ValueFilterAny resolutions; ScanMethod method; unsigned register_dpiset; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { @@ -3669,7 +3669,7 @@ void genesys_init_sensor_tables() unsigned register_dpiset; unsigned shading_resolution; unsigned shading_factor; - unsigned output_pixel_offset; + int output_pixel_offset; }; CustomSensorSettings custom_settings[] = { From b788f2de8f948aff02d13043d7801ff1d7efa9d9 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:38:04 +0300 Subject: [PATCH 08/12] genesys: Remove startup position hack on 8600F 4800dpi scans --- backend/genesys/genesys.cpp | 3 --- backend/genesys/tables_sensor.cpp | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/backend/genesys/genesys.cpp b/backend/genesys/genesys.cpp index 451bfc7f5..69b8db41b 100644 --- a/backend/genesys/genesys.cpp +++ b/backend/genesys/genesys.cpp @@ -1343,9 +1343,6 @@ bool should_calibrate_only_active_area(const Genesys_Device& dev, float get_model_x_offset_ta(const Genesys_Device& dev, const Genesys_Settings& settings) { - if (dev.model->model_id == ModelId::CANON_8600F && settings.xres == 4800) { - return 85.0f; - } if (dev.model->model_id == ModelId::CANON_4400F && settings.xres == 4800) { return dev.model->x_offset_ta - 10.0; } diff --git a/backend/genesys/tables_sensor.cpp b/backend/genesys/tables_sensor.cpp index 6755c8b1c..11119ab5a 100644 --- a/backend/genesys/tables_sensor.cpp +++ b/backend/genesys/tables_sensor.cpp @@ -2280,8 +2280,8 @@ void genesys_init_sensor_tables() }, {}, }, - { { 4800 }, 4800, 45000, 285, { ScanMethod::TRANSPARENCY, - ScanMethod::TRANSPARENCY_INFRARED }, { + { { 4800 }, 4800, 45000, -1982, { ScanMethod::TRANSPARENCY, + ScanMethod::TRANSPARENCY_INFRARED }, { { 0x0c, 0x00 }, { 0x16, 0x13 }, { 0x17, 0x15 }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x61 }, { 0x1d, 0x75 }, From ea781b6b07956b0aa26cb190674d9e20fd85ec8d Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:38:05 +0300 Subject: [PATCH 09/12] genesys: Improve head positioning during calibration on 8600F TA scans --- backend/genesys/gl843.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/genesys/gl843.cpp b/backend/genesys/gl843.cpp index 8dd9e4792..969e5b61b 100644 --- a/backend/genesys/gl843.cpp +++ b/backend/genesys/gl843.cpp @@ -1489,6 +1489,12 @@ void CommandSetGl843::init_regs_for_shading(Genesys_Device* dev, const Genesys_S // note: move_to_ta() function has already been called and the sensor is at the // transparency adapter move = static_cast(dev->model->y_offset_calib_white_ta - dev->model->y_offset_sensor_to_ta); + if (dev->model->model_id == ModelId::CANON_8600F && resolution == 2400) { + move /= 2; + } + if (dev->model->model_id == ModelId::CANON_8600F && resolution == 4800) { + move /= 4; + } flags |= ScanFlag::USE_XPA; } else { move = static_cast(dev->model->y_offset_calib_white); From 60da130402d8616d18244b32dc13390e05e882e0 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:38:06 +0300 Subject: [PATCH 10/12] genesys: Fix Y scan area offset on 4400F --- backend/genesys/tables_model.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/genesys/tables_model.cpp b/backend/genesys/tables_model.cpp index 838ab8c73..6af192a9b 100644 --- a/backend/genesys/tables_model.cpp +++ b/backend/genesys/tables_model.cpp @@ -430,7 +430,7 @@ void genesys_init_usb_device_tables() model.bpp_color_values = { 8, 16 }; model.x_offset = 6.0; - model.y_offset = 12.00; + model.y_offset = 10.00; model.x_size = 215.9; model.y_size = 297.0; From 1125cf338a11991b7e6b6284ea90f5fb1bcbdd3c Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:38:07 +0300 Subject: [PATCH 11/12] genesys: Update pixel start offsets on 4400F --- backend/genesys/low.cpp | 7 +------ backend/genesys/tables_sensor.cpp | 6 +++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/backend/genesys/low.cpp b/backend/genesys/low.cpp index 0eb09a209..96ab0de77 100644 --- a/backend/genesys/low.cpp +++ b/backend/genesys/low.cpp @@ -1225,14 +1225,9 @@ void build_image_pipeline(Genesys_Device* dev, const Genesys_Sensor& sensor, !has_flag(dev->model->flags, ModelFlag::NO_CALIBRATION) && !has_flag(session.params.flags, ScanFlag::DISABLE_SHADING)) { - unsigned pixel_shift = session.params.startx; - if (dev->model->model_id == ModelId::CANON_4400F) { - pixel_shift = - session.params.startx * sensor.optical_res / dev->calib_session.params.xres; - } dev->pipeline.push_node(dev->dark_average_data, dev->white_average_data, - pixel_shift * + session.params.startx * dev->calib_session.params.channels); if (DBG_LEVEL >= DBG_io2) { diff --git a/backend/genesys/tables_sensor.cpp b/backend/genesys/tables_sensor.cpp index 11119ab5a..e2b574fb8 100644 --- a/backend/genesys/tables_sensor.cpp +++ b/backend/genesys/tables_sensor.cpp @@ -1887,7 +1887,7 @@ void genesys_init_sensor_tables() }; CustomSensorSettings custom_settings[] = { - { { 300 }, 1200, 11640, false, 1, { ScanMethod::FLATBED }, { + { { 300 }, 1200, 11640, false, 197, { ScanMethod::FLATBED }, { { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x6b }, { 0x52, 0x0a }, { 0x53, 0x0d }, { 0x54, 0x00 }, { 0x55, 0x03 }, @@ -1899,7 +1899,7 @@ void genesys_init_sensor_tables() { 0x9e, 0x2d }, }, {} }, - { { 600 }, 2400, 11640, false, 2, { ScanMethod::FLATBED }, { + { { 600 }, 2400, 11640, false, 392, { ScanMethod::FLATBED }, { { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x6b }, { 0x52, 0x0a }, { 0x53, 0x0d }, { 0x54, 0x00 }, { 0x55, 0x03 }, @@ -1911,7 +1911,7 @@ void genesys_init_sensor_tables() { 0x9e, 0x2d }, }, {} }, - { { 1200 }, 4800, 11640, false, 5, { ScanMethod::FLATBED }, { + { { 1200 }, 4800, 11640, false, 794, { ScanMethod::FLATBED }, { { 0x16, 0x13 }, { 0x17, 0x0a }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x00 }, { 0x1d, 0x6b }, { 0x52, 0x0a }, { 0x53, 0x0d }, { 0x54, 0x00 }, { 0x55, 0x03 }, From eec083f46a1e7ccc63441642096d2b35c238ede7 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 13 Apr 2020 07:38:08 +0300 Subject: [PATCH 12/12] genesys: Remove startup position hack on 4400F 4800dpi scans --- backend/genesys/genesys.cpp | 10 +--------- backend/genesys/gl124.cpp | 2 +- backend/genesys/gl646.cpp | 2 +- backend/genesys/gl841.cpp | 2 +- backend/genesys/gl843.cpp | 6 +++--- backend/genesys/gl846.cpp | 2 +- backend/genesys/gl847.cpp | 2 +- backend/genesys/low.cpp | 3 +-- backend/genesys/low.h | 5 +---- backend/genesys/tables_sensor.cpp | 2 +- 10 files changed, 12 insertions(+), 24 deletions(-) diff --git a/backend/genesys/genesys.cpp b/backend/genesys/genesys.cpp index 69b8db41b..d89640733 100644 --- a/backend/genesys/genesys.cpp +++ b/backend/genesys/genesys.cpp @@ -1341,14 +1341,6 @@ bool should_calibrate_only_active_area(const Genesys_Device& dev, return false; } -float get_model_x_offset_ta(const Genesys_Device& dev, const Genesys_Settings& settings) -{ - if (dev.model->model_id == ModelId::CANON_4400F && settings.xres == 4800) { - return dev.model->x_offset_ta - 10.0; - } - return dev.model->x_offset_ta; -} - void scanner_offset_calibration(Genesys_Device& dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) { @@ -1411,7 +1403,7 @@ void scanner_offset_calibration(Genesys_Device& dev, const Genesys_Sensor& senso black_pixels = calib_sensor->black_pixels / factor; if (should_calibrate_only_active_area(dev, dev.settings)) { - float offset = get_model_x_offset_ta(dev, dev.settings); + float offset = dev.model->x_offset_ta; offset /= calib_sensor->get_ccd_size_divisor_for_dpi(resolution); start_pixel = static_cast((offset * resolution) / MM_PER_INCH); diff --git a/backend/genesys/gl124.cpp b/backend/genesys/gl124.cpp index 0d8ce9cb8..865a38665 100644 --- a/backend/genesys/gl124.cpp +++ b/backend/genesys/gl124.cpp @@ -801,7 +801,7 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens dev->line_count = 0; - build_image_pipeline(dev, sensor, session); + build_image_pipeline(dev, session); // MAXWD is expressed in 2 words unit diff --git a/backend/genesys/gl646.cpp b/backend/genesys/gl646.cpp index 1d46c258f..ef560cd34 100644 --- a/backend/genesys/gl646.cpp +++ b/backend/genesys/gl646.cpp @@ -515,7 +515,7 @@ void CommandSetGl646::init_regs_for_scan_session(Genesys_Device* dev, const Gene dev->read_buffer.clear(); dev->read_buffer.alloc(session.buffer_size_read); - build_image_pipeline(dev, sensor, session); + build_image_pipeline(dev, session); dev->read_active = true; diff --git a/backend/genesys/gl841.cpp b/backend/genesys/gl841.cpp index 6124242e0..7e0ee625c 100644 --- a/backend/genesys/gl841.cpp +++ b/backend/genesys/gl841.cpp @@ -1369,7 +1369,7 @@ dummy \ scanned lines dev->read_buffer.clear(); dev->read_buffer.alloc(session.buffer_size_read); - build_image_pipeline(dev, sensor, session); + build_image_pipeline(dev, session); dev->read_active = true; diff --git a/backend/genesys/gl843.cpp b/backend/genesys/gl843.cpp index 969e5b61b..a80017998 100644 --- a/backend/genesys/gl843.cpp +++ b/backend/genesys/gl843.cpp @@ -1136,7 +1136,7 @@ void CommandSetGl843::init_regs_for_scan_session(Genesys_Device* dev, const Gene dev->read_buffer.clear(); dev->read_buffer.alloc(session.buffer_size_read); - build_image_pipeline(dev, sensor, session); + build_image_pipeline(dev, session); dev->read_active = true; @@ -1182,7 +1182,7 @@ ScanSession CommandSetGl843::calculate_scan_session(const Genesys_Device* dev, if (settings.scan_method==ScanMethod::TRANSPARENCY || settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) { - start = get_model_x_offset_ta(*dev, settings); + start = dev->model->x_offset_ta; } else { start = dev->model->x_offset; } @@ -1465,7 +1465,7 @@ void CommandSetGl843::init_regs_for_shading(Genesys_Device* dev, const Genesys_S unsigned calib_pixels_offset = 0; if (should_calibrate_only_active_area(*dev, dev->settings)) { - float offset = get_model_x_offset_ta(*dev, dev->settings); + float offset = dev->model->x_offset_ta; // FIXME: we should use resolution here offset = static_cast((offset * dev->settings.xres) / MM_PER_INCH); diff --git a/backend/genesys/gl846.cpp b/backend/genesys/gl846.cpp index b935e476a..e5c3f4133 100644 --- a/backend/genesys/gl846.cpp +++ b/backend/genesys/gl846.cpp @@ -709,7 +709,7 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens reg->set16(REG_STRPIXEL, session.pixel_startx); reg->set16(REG_ENDPIXEL, session.pixel_endx); - build_image_pipeline(dev, sensor, session); + build_image_pipeline(dev, session); /* MAXWD is expressed in 4 words unit */ // BUG: we shouldn't multiply by channels here diff --git a/backend/genesys/gl847.cpp b/backend/genesys/gl847.cpp index 7ca7c4b28..7933b2552 100644 --- a/backend/genesys/gl847.cpp +++ b/backend/genesys/gl847.cpp @@ -610,7 +610,7 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens reg->set16(REG_STRPIXEL, session.pixel_startx); reg->set16(REG_ENDPIXEL, session.pixel_endx); - build_image_pipeline(dev, sensor, session); + build_image_pipeline(dev, session); /* MAXWD is expressed in 4 words unit */ // BUG: we shouldn't multiply by channels here diff --git a/backend/genesys/low.cpp b/backend/genesys/low.cpp index 96ab0de77..2625c4a15 100644 --- a/backend/genesys/low.cpp +++ b/backend/genesys/low.cpp @@ -1115,8 +1115,7 @@ static std::size_t get_usb_buffer_read_size(AsicType asic, const ScanSession& se } } -void build_image_pipeline(Genesys_Device* dev, const Genesys_Sensor& sensor, - const ScanSession& session) +void build_image_pipeline(Genesys_Device* dev, const ScanSession& session) { static unsigned s_pipeline_index = 0; diff --git a/backend/genesys/low.h b/backend/genesys/low.h index 155da0d0a..0443bb9a9 100644 --- a/backend/genesys/low.h +++ b/backend/genesys/low.h @@ -329,8 +329,6 @@ void scanner_search_strip(Genesys_Device& dev, bool forward, bool black); bool should_calibrate_only_active_area(const Genesys_Device& dev, const Genesys_Settings& settings); -float get_model_x_offset_ta(const Genesys_Device& dev, const Genesys_Settings& settings); - void scanner_offset_calibration(Genesys_Device& dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs); @@ -436,8 +434,7 @@ extern void sanei_genesys_generate_gamma_buffer(Genesys_Device* dev, void compute_session(const Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& sensor); -void build_image_pipeline(Genesys_Device* dev, const Genesys_Sensor& sensor, - const ScanSession& session); +void build_image_pipeline(Genesys_Device* dev, const ScanSession& session); std::uint8_t compute_frontend_gain(float value, float target_value, FrontendType frontend_type); diff --git a/backend/genesys/tables_sensor.cpp b/backend/genesys/tables_sensor.cpp index e2b574fb8..8ae87a54f 100644 --- a/backend/genesys/tables_sensor.cpp +++ b/backend/genesys/tables_sensor.cpp @@ -1949,7 +1949,7 @@ void genesys_init_sensor_tables() { 0x03, 0x1f }, } }, - { { 4800 }, 4800, 33300, true, 20, { ScanMethod::TRANSPARENCY }, { + { { 4800 }, 4800, 33300, true, -2063, { ScanMethod::TRANSPARENCY }, { { 0x16, 0x13 }, { 0x17, 0x15 }, { 0x18, 0x10 }, { 0x19, 0x2a }, { 0x1a, 0x30 }, { 0x1b, 0x00 }, { 0x1c, 0x61 }, { 0x1d, 0x75 }, { 0x52, 0x02 }, { 0x53, 0x05 }, { 0x54, 0x08 }, { 0x55, 0x0b },