diff --git a/backend/genesys/calibration.h b/backend/genesys/calibration.h index 894df335a..81d94eaf6 100644 --- a/backend/genesys/calibration.h +++ b/backend/genesys/calibration.h @@ -64,7 +64,6 @@ struct Genesys_Calibration_Cache Genesys_Sensor sensor; ScanSession session; - size_t calib_channels = 0; size_t average_size = 0; std::vector white_average_data; std::vector dark_average_data; @@ -76,7 +75,6 @@ struct Genesys_Calibration_Cache frontend == other.frontend && sensor == other.sensor && session == other.session && - calib_channels == other.calib_channels && average_size == other.average_size && white_average_data == other.white_average_data && dark_average_data == other.dark_average_data; @@ -95,7 +93,6 @@ void serialize(Stream& str, Genesys_Calibration_Cache& x) serialize(str, x.sensor); serialize_newline(str); serialize(str, x.session); - serialize(str, x.calib_channels); serialize(str, x.average_size); serialize_newline(str); serialize(str, x.white_average_data); diff --git a/backend/genesys/device.cpp b/backend/genesys/device.cpp index 17d43338f..967cd4e2e 100644 --- a/backend/genesys/device.cpp +++ b/backend/genesys/device.cpp @@ -240,7 +240,6 @@ std::ostream& operator<<(std::ostream& out, const Genesys_Device& dev) << static_cast(dev.control[5]) << '\n' << std::dec << " average_size: " << dev.average_size << '\n' << " calib_lines: " << dev.calib_lines << '\n' - << " calib_channels: " << dev.calib_channels << '\n' << " calib_total_bytes_to_read: " << dev.calib_total_bytes_to_read << '\n' << " calib_session: " << format_indent_braced_list(4, dev.calib_session) << '\n' << " gamma_override_tables[0].size(): " << dev.gamma_override_tables[0].size() << '\n' diff --git a/backend/genesys/device.h b/backend/genesys/device.h index 80197270b..9690f6b4c 100644 --- a/backend/genesys/device.h +++ b/backend/genesys/device.h @@ -271,7 +271,6 @@ struct Genesys_Device size_t average_size = 0; // number of lines used during shading calibration size_t calib_lines = 0; - size_t calib_channels = 0; // bytes to read from USB when calibrating. If 0, this is not set size_t calib_total_bytes_to_read = 0; diff --git a/backend/genesys/genesys.cpp b/backend/genesys/genesys.cpp index aa4f7f84d..589982876 100644 --- a/backend/genesys/genesys.cpp +++ b/backend/genesys/genesys.cpp @@ -1667,14 +1667,13 @@ static void genesys_shading_calibration_impl(Genesys_Device* dev, const Genesys_ size_t size; uint32_t pixels_per_line; - uint8_t channels; if (dev->model->asic_type == AsicType::GL843) { pixels_per_line = dev->calib_session.output_pixels; } else { pixels_per_line = dev->calib_session.params.pixels; } - channels = dev->calib_channels; + unsigned channels = dev->calib_session.params.channels; unsigned out_pixels_per_line = pixels_per_line + dev->calib_session.params.startx; @@ -1792,7 +1791,6 @@ static void genesys_dummy_dark_shading(Genesys_Device* dev, const Genesys_Sensor { DBG_HELPER(dbg); uint32_t pixels_per_line; - uint8_t channels; uint32_t skip, xend; int dummy1, dummy2, dummy3; /* dummy black average per channel */ @@ -1802,7 +1800,7 @@ static void genesys_dummy_dark_shading(Genesys_Device* dev, const Genesys_Sensor pixels_per_line = dev->calib_session.params.pixels; } - channels = dev->calib_channels; + unsigned channels = dev->calib_session.params.channels; unsigned out_pixels_per_line = pixels_per_line + dev->calib_session.params.startx; @@ -1921,7 +1919,6 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev, size_t size; uint32_t pixels_per_line; - uint8_t channels; unsigned int x; uint32_t dark, white, dark_sum, white_sum, dark_count, white_count, col, dif; @@ -1932,7 +1929,7 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev, pixels_per_line = dev->calib_session.params.pixels; } - channels = dev->calib_channels; + unsigned channels = dev->calib_session.params.channels; unsigned out_pixels_per_line = pixels_per_line + dev->calib_session.params.startx; @@ -2539,7 +2536,6 @@ static void genesys_send_shading_coefficient(Genesys_Device* dev, const Genesys_ } uint32_t pixels_per_line; - uint8_t channels; int o; unsigned int length; /**> number of shading calibration data words */ unsigned int factor; @@ -2551,7 +2547,7 @@ static void genesys_send_shading_coefficient(Genesys_Device* dev, const Genesys_ pixels_per_line = dev->calib_session.params.pixels + dev->calib_session.params.startx; } - channels = dev->calib_channels; + unsigned channels = dev->calib_session.params.channels; /* we always build data for three channels, even for gray * we make the shading data such that each color channel data line is contiguous @@ -2592,6 +2588,11 @@ static void genesys_send_shading_coefficient(Genesys_Device* dev, const Genesys_ // contains 16bit words in little endian std::vector shading_data(length, 0); + if (!dev->calib_session.computed) { + genesys_send_offset_and_shading(dev, sensor, shading_data.data(), length); + return; + } + /* TARGET/(Wn-Dn) = white gain -> ~1.xxx then it is multiplied by 0x2000 or 0x4000 to give an integer Wn = white average for column n @@ -2846,7 +2847,6 @@ genesys_restore_calibration(Genesys_Device * dev, Genesys_Sensor& sensor) dev->calib_session = cache.session; dev->average_size = cache.average_size; - dev->calib_channels = cache.calib_channels; dev->dark_average_data = cache.dark_average_data; dev->white_average_data = cache.white_average_data; @@ -2901,7 +2901,6 @@ static void genesys_save_calibration(Genesys_Device* dev, const Genesys_Sensor& found_cache_it->sensor = sensor; found_cache_it->session = dev->calib_session; - found_cache_it->calib_channels = dev->calib_channels; #ifdef HAVE_SYS_TIME_H gettimeofday(&time, nullptr); @@ -4709,7 +4708,7 @@ static void probe_genesys_devices() of Genesys_Calibration_Cache as is. */ static const char* CALIBRATION_IDENT = "sane_genesys"; -static const int CALIBRATION_VERSION = 24; +static const int CALIBRATION_VERSION = 25; bool read_calibration(std::istream& str, Genesys_Device::Calibration& calibration, const std::string& path) diff --git a/backend/genesys/gl124.cpp b/backend/genesys/gl124.cpp index 95bdfe156..fe03283b6 100644 --- a/backend/genesys/gl124.cpp +++ b/backend/genesys/gl124.cpp @@ -1178,7 +1178,7 @@ void CommandSetGl124::init_regs_for_shading(Genesys_Device* dev, const Genesys_S DBG_HELPER(dbg); int move, resolution, dpihw, factor; - dev->calib_channels = 3; + unsigned channels = 3; dev->calib_lines = dev->model->shading_lines; dpihw = sensor.get_register_hwdpi(dev->settings.xres); if(dpihw>=2400) @@ -1192,8 +1192,7 @@ void CommandSetGl124::init_regs_for_shading(Genesys_Device* dev, const Genesys_S resolution /= ccd_size_divisor; dev->calib_lines /= ccd_size_divisor; // reducing just because we reduced the resolution - const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, - dev->calib_channels, + const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); dev->calib_total_bytes_to_read = 0; factor = calib_sensor.optical_res / resolution; @@ -1214,7 +1213,7 @@ void CommandSetGl124::init_regs_for_shading(Genesys_Device* dev, const Genesys_S session.params.pixels = calib_sensor.sensor_pixels / factor; session.params.lines = dev->calib_lines; session.params.depth = 16; - session.params.channels = dev->calib_channels; + session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = ColorFilter::RED; diff --git a/backend/genesys/gl646.cpp b/backend/genesys/gl646.cpp index 5ce900243..5305523ed 100644 --- a/backend/genesys/gl646.cpp +++ b/backend/genesys/gl646.cpp @@ -1708,12 +1708,6 @@ void CommandSetGl646::init_regs_for_shading(Genesys_Device* dev, const Genesys_S dev->calib_session = setup_for_scan(dev, calib_sensor, &dev->reg, settings, true, false, false, false); - /* used when sending shading calibration data */ - dev->calib_channels = dev->session.params.channels; - if (!dev->model->is_cis) { - dev->calib_channels = 3; - } - /* no shading */ dev->reg.find_reg(0x01).value &= ~REG_0x01_DVDSET; dev->reg.find_reg(0x02).value |= REG_0x02_ACDCDIS; /* ease backtracking */ diff --git a/backend/genesys/gl841.cpp b/backend/genesys/gl841.cpp index 8159bf1a0..a3ae43686 100644 --- a/backend/genesys/gl841.cpp +++ b/backend/genesys/gl841.cpp @@ -2455,13 +2455,13 @@ void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_S starty = 70; } - dev->calib_channels = 3; + unsigned channels = 3; dev->calib_lines = dev->model->shading_lines; unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres); unsigned factor = sensor.optical_res / resolution; - const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, dev->calib_channels, + const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); ScanSession session; @@ -2472,7 +2472,7 @@ void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_S session.params.pixels = calib_sensor.sensor_pixels / factor; session.params.lines = dev->calib_lines; session.params.depth = 16; - session.params.channels = dev->calib_channels; + session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; diff --git a/backend/genesys/gl843.cpp b/backend/genesys/gl843.cpp index a75f56da2..b6690190d 100644 --- a/backend/genesys/gl843.cpp +++ b/backend/genesys/gl843.cpp @@ -1698,7 +1698,6 @@ void CommandSetGl843::init_regs_for_shading(Genesys_Device* dev, const Genesys_S DBG_HELPER(dbg); int move, resolution, dpihw, factor; - dev->calib_channels = 3; if (dev->settings.scan_method == ScanMethod::TRANSPARENCY || dev->settings.scan_method == ScanMethod::TRANSPARENCY_INFRARED) @@ -1712,7 +1711,8 @@ void CommandSetGl843::init_regs_for_shading(Genesys_Device* dev, const Genesys_S factor=sensor.optical_res/dpihw; resolution=dpihw; - const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, dev->calib_channels, + unsigned channels = 3; + const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); unsigned calib_pixels = 0; @@ -1760,7 +1760,7 @@ void CommandSetGl843::init_regs_for_shading(Genesys_Device* dev, const Genesys_S session.params.pixels = calib_pixels; session.params.lines = dev->calib_lines; session.params.depth = 16; - session.params.channels = dev->calib_channels; + session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = dev->settings.scan_mode; session.params.color_filter = dev->settings.color_filter; diff --git a/backend/genesys/gl846.cpp b/backend/genesys/gl846.cpp index d699aacfd..5e8c32b1c 100644 --- a/backend/genesys/gl846.cpp +++ b/backend/genesys/gl846.cpp @@ -958,12 +958,10 @@ void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_S DBG_HELPER(dbg); float move; - dev->calib_channels = 3; - + unsigned channels = 3; unsigned resolution = sensor.get_register_hwdpi(dev->settings.xres); - const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, - dev->calib_channels, + const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); dev->calib_total_bytes_to_read = 0; dev->calib_lines = dev->model->shading_lines; @@ -991,7 +989,7 @@ void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_S session.params.pixels = calib_pixels; session.params.lines = dev->calib_lines; session.params.depth = 16; - session.params.channels = dev->calib_channels; + session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; diff --git a/backend/genesys/gl847.cpp b/backend/genesys/gl847.cpp index 4a5b9f39e..c77f82743 100644 --- a/backend/genesys/gl847.cpp +++ b/backend/genesys/gl847.cpp @@ -965,12 +965,11 @@ void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_S { DBG_HELPER(dbg); - dev->calib_channels = 3; + unsigned channels = 3; unsigned resolution = sensor.get_register_hwdpi(dev->settings.xres); - const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, - dev->calib_channels, + const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, channels, dev->settings.scan_method); dev->calib_total_bytes_to_read = 0; @@ -992,7 +991,7 @@ void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_S session.params.pixels = calib_pixels; session.params.lines = dev->calib_lines; session.params.depth = 16; - session.params.channels = dev->calib_channels; + session.params.channels = channels; session.params.scan_method = dev->settings.scan_method; session.params.scan_mode = ScanColorMode::COLOR_SINGLE_PASS; session.params.color_filter = dev->settings.color_filter; diff --git a/testsuite/backend/genesys/tests_calibration.cpp b/testsuite/backend/genesys/tests_calibration.cpp index 6f00707a5..82417ee9f 100644 --- a/testsuite/backend/genesys/tests_calibration.cpp +++ b/testsuite/backend/genesys/tests_calibration.cpp @@ -104,7 +104,6 @@ Genesys_Calibration_Cache create_fake_calibration_entry() sensor.gamma = {1.0, 1.0, 1.0}; calib.sensor = sensor; - calib.calib_channels = 3; calib.average_size = 7; calib.white_average_data = { 8, 7, 6, 5, 4, 3, 2 }; calib.dark_average_data = { 6, 5, 4, 3, 2, 18, 12 };