From 511969ded07d8f6e55fd20a13cc3c296422215b0 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 22 Feb 2020 10:28:15 +0200 Subject: [PATCH 1/5] genesys: Remove dead code on gl841 --- backend/genesys/gl841.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/backend/genesys/gl841.cpp b/backend/genesys/gl841.cpp index ca52ecf57..6dafd1ad7 100644 --- a/backend/genesys/gl841.cpp +++ b/backend/genesys/gl841.cpp @@ -1614,15 +1614,7 @@ ScanSession CommandSetGl841::calculate_scan_session(const Genesys_Device* dev, float y_offset_calib; mm_to_steps()=motor dpi / 2.54 / 10=motor dpi / MM_PER_INCH */ - - // if scanner uses ModelFlag::SEARCH_START y_offset is - // relative from origin, else, it is from parking position - float move = 0.0f; - if (has_flag(dev->model->flags, ModelFlag::SEARCH_START)) { - move += dev->model->y_offset_calib_white; - } - - move += dev->model->y_offset; + float move = dev->model->y_offset; move += dev->settings.tl_y; int move_dpi = dev->motor.base_ydpi; From 5f8129b2d006a8ea9e7aa39da5b807bea8b25639 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 22 Feb 2020 10:28:16 +0200 Subject: [PATCH 2/5] genesys: Disable SEARCH_START on gl646 scanners --- backend/genesys/tables_model.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/backend/genesys/tables_model.cpp b/backend/genesys/tables_model.cpp index 7189f5292..f8a3fb276 100644 --- a/backend/genesys/tables_model.cpp +++ b/backend/genesys/tables_model.cpp @@ -1179,7 +1179,7 @@ void genesys_init_usb_device_tables() model.bpp_color_values = { 8, 16 }; model.x_offset = 2.0; - model.y_offset = 7.5; + model.y_offset = 7.5; // FIXME: incorrect, needs updating model.x_size = 215.9; model.y_size = 295.0; @@ -1203,7 +1203,6 @@ void genesys_init_usb_device_tables() model.motor_id = MotorId::HP2300; model.flags = ModelFlag::GAMMA_14BIT | ModelFlag::SKIP_WARMUP | - ModelFlag::SEARCH_START | ModelFlag::DARK_CALIBRATION | ModelFlag::CUSTOM_GAMMA; model.buttons = GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW; @@ -1434,7 +1433,7 @@ void genesys_init_usb_device_tables() model.bpp_color_values = { 8, 16 }; model.x_offset = 3.5; - model.y_offset = 7.5; + model.y_offset = 7.5; // FIXME: incorrect, needs updating model.x_size = 218.0; model.y_size = 299.0; @@ -1459,8 +1458,7 @@ void genesys_init_usb_device_tables() model.motor_id = MotorId::ST24; model.flags = ModelFlag::UNTESTED | ModelFlag::GAMMA_14BIT | - ModelFlag::CUSTOM_GAMMA | - ModelFlag::SEARCH_START; + ModelFlag::CUSTOM_GAMMA; model.buttons = GENESYS_HAS_NO_BUTTONS; model.search_lines = 200; @@ -1485,12 +1483,12 @@ void genesys_init_usb_device_tables() model.bpp_color_values = { 8, 16 }; model.x_offset = 0.30; - model.y_offset = 0.80; + model.y_offset = 4.0; // FIXME: incorrect, needs updating model.x_size = 220.0; model.y_size = 296.4; model.y_offset_calib_white = 0.00; - model.y_size_calib_mm = 3.0; // FIXME: the y_offset is most likely incorrect + model.y_size_calib_mm = 3.0; model.x_offset_calib_black = 0.00; model.post_scan = 0.0; @@ -1508,7 +1506,6 @@ void genesys_init_usb_device_tables() model.gpio_id = GpioId::MD_5345; model.motor_id = MotorId::MD_5345; model.flags = ModelFlag::GAMMA_14BIT | - ModelFlag::SEARCH_START | ModelFlag::DARK_CALIBRATION | ModelFlag::SHADING_NO_MOVE | ModelFlag::CUSTOM_GAMMA; @@ -2049,7 +2046,7 @@ void genesys_init_usb_device_tables() model.bpp_color_values = { 8, 16 }; model.x_offset = 4.00; - model.y_offset = 0.80; + model.y_offset = 5.0; // FIXME: incorrect, needs updating model.x_size = 215.9; model.y_size = 296.4; @@ -2072,7 +2069,6 @@ void genesys_init_usb_device_tables() model.gpio_id = GpioId::MD_5345; model.motor_id = MotorId::MD_5345; model.flags = ModelFlag::GAMMA_14BIT | - ModelFlag::SEARCH_START | ModelFlag::DARK_CALIBRATION | ModelFlag::CUSTOM_GAMMA; model.buttons = GENESYS_HAS_COPY_SW | @@ -2104,7 +2100,7 @@ void genesys_init_usb_device_tables() model.bpp_color_values = { 8, 16 }; model.x_offset = 4.00; - model.y_offset = 0.80; + model.y_offset = 5.0; // FIXME: incorrect, needs updating model.x_size = 215.9; model.y_size = 296.4; @@ -2127,7 +2123,6 @@ void genesys_init_usb_device_tables() model.gpio_id = GpioId::MD_5345; model.motor_id = MotorId::MD_5345; model.flags = ModelFlag::GAMMA_14BIT | - ModelFlag::SEARCH_START | ModelFlag::DARK_CALIBRATION | ModelFlag::CUSTOM_GAMMA; model.buttons = GENESYS_HAS_COPY_SW | From 2cf05553c017e6ddef48fbd292d7a63ed927ed77 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 22 Feb 2020 10:28:17 +0200 Subject: [PATCH 3/5] genesys: Remove no longer used code related to start position search --- backend/genesys/command_set.h | 1 - backend/genesys/enums.h | 3 - backend/genesys/genesys.cpp | 193 +--------------------------------- backend/genesys/gl124.cpp | 70 ------------ backend/genesys/gl124.h | 2 - backend/genesys/gl646.cpp | 70 ------------ backend/genesys/gl646.h | 2 - backend/genesys/gl841.cpp | 74 ------------- backend/genesys/gl841.h | 2 - backend/genesys/gl843.cpp | 74 ------------- backend/genesys/gl843.h | 2 - backend/genesys/gl846.cpp | 75 ------------- backend/genesys/gl846.h | 2 - backend/genesys/gl847.cpp | 73 ------------- backend/genesys/gl847.h | 2 - backend/genesys/low.h | 4 - 16 files changed, 3 insertions(+), 646 deletions(-) diff --git a/backend/genesys/command_set.h b/backend/genesys/command_set.h index d0ba2563d..41c072ef0 100644 --- a/backend/genesys/command_set.h +++ b/backend/genesys/command_set.h @@ -97,7 +97,6 @@ public: */ virtual void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const = 0; - virtual void search_start_position(Genesys_Device* dev) const = 0; virtual void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const = 0; virtual void coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, diff --git a/backend/genesys/enums.h b/backend/genesys/enums.h index 98e0101bb..a6ba174f3 100644 --- a/backend/genesys/enums.h +++ b/backend/genesys/enums.h @@ -445,9 +445,6 @@ enum class ModelFlag : unsigned // skip lamp warmup (genesys_warmup()) SKIP_WARMUP = 1 << 4, - // search start point befor scanning - SEARCH_START = 1 << 6, - // repark head and check for lock by moving without scanning REPARK = 1 << 7, diff --git a/backend/genesys/genesys.cpp b/backend/genesys/genesys.cpp index 83502b4c6..5a3550a9b 100644 --- a/backend/genesys/genesys.cpp +++ b/backend/genesys/genesys.cpp @@ -529,179 +529,6 @@ void sanei_genesys_init_shading_data(Genesys_Device* dev, const Genesys_Sensor& pixels_per_line * 4 * channels); } - -// Find the position of the reference point: takes gray level 8 bits data and find -// first CCD usable pixel and top of scanning area -void sanei_genesys_search_reference_point(Genesys_Device* dev, Genesys_Sensor& sensor, - const uint8_t* src_data, int start_pixel, int dpi, - int width, int height) -{ - DBG_HELPER(dbg); - int x, y; - int current, left, top = 0; - int size, count; - int level = 80; /* edge threshold level */ - - // sanity check - if ((width < 3) || (height < 3)) { - throw SaneException("invalid width or height"); - } - - /* transformed image data */ - size = width * height; - std::vector image2(size, 0); - std::vector image(size, 0); - - /* laplace filter to denoise picture */ - std::memcpy(image2.data(), src_data, size); - std::memcpy(image.data(), src_data, size); // to initialize unprocessed part of the image buffer - - for (y = 1; y < height - 1; y++) { - for (x = 1; x < width - 1; x++) { - image[y * width + x] = - (image2[(y - 1) * width + x + 1] + 2 * image2[(y - 1) * width + x] + - image2[(y - 1) * width + x - 1] + 2 * image2[y * width + x + 1] + - 4 * image2[y * width + x] + 2 * image2[y * width + x - 1] + - image2[(y + 1) * width + x + 1] + 2 * image2[(y + 1) * width + x] + - image2[(y + 1) * width + x - 1]) / 16; - } - } - - image2 = image; - if (DBG_LEVEL >= DBG_data) - sanei_genesys_write_pnm_file("gl_laplace.pnm", image.data(), 8, 1, width, height); - - /* apply X direction sobel filter - -1 0 1 - -2 0 2 - -1 0 1 - and finds threshold level - */ - level = 0; - for (y = 2; y < height - 2; y++) { - for (x = 2; x < width - 2; x++) { - current = image2[(y - 1) * width + x + 1] - image2[(y - 1) * width + x - 1] + - 2 * image2[y * width + x + 1] - 2 * image2[y * width + x - 1] + - image2[(y + 1) * width + x + 1] - image2[(y + 1) * width + x - 1]; - if (current < 0) - current = -current; - if (current > 255) - current = 255; - image[y * width + x] = current; - if (current > level) - level = current; - } - } - if (DBG_LEVEL >= DBG_data) - sanei_genesys_write_pnm_file("gl_xsobel.pnm", image.data(), 8, 1, width, height); - - /* set up detection level */ - level = level / 3; - - /* find left black margin first - todo: search top before left - we average the result of N searches */ - left = 0; - count = 0; - for (y = 2; y < 11; y++) - { - x = 8; - while ((x < width / 2) && (image[y * width + x] < level)) - { - image[y * width + x] = 255; - x++; - } - count++; - left += x; - } - if (DBG_LEVEL >= DBG_data) - sanei_genesys_write_pnm_file("gl_detected-xsobel.pnm", image.data(), 8, 1, width, height); - left = left / count; - - // turn it in CCD pixel at full sensor optical resolution - sensor.ccd_start_xoffset = start_pixel + (left * sensor.optical_res) / dpi; - - /* find top edge by detecting black strip */ - /* apply Y direction sobel filter - -1 -2 -1 - 0 0 0 - 1 2 1 - */ - level = 0; - for (y = 2; y < height - 2; y++) { - for (x = 2; x < width - 2; x++) { - current = -image2[(y - 1) * width + x + 1] - 2 * image2[(y - 1) * width + x] - - image2[(y - 1) * width + x - 1] + image2[(y + 1) * width + x + 1] + - 2 * image2[(y + 1) * width + x] + image2[(y + 1) * width + x - 1]; - if (current < 0) - current = -current; - if (current > 255) - current = 255; - image[y * width + x] = current; - if (current > level) - level = current; - } - } - if (DBG_LEVEL >= DBG_data) - sanei_genesys_write_pnm_file("gl_ysobel.pnm", image.data(), 8, 1, width, height); - - /* set up detection level */ - level = level / 3; - - /* search top of horizontal black stripe : TODO yet another flag */ - if (dev->model->sensor_id == SensorId::CCD_5345 - && dev->model->motor_id == MotorId::MD_5345) - { - top = 0; - count = 0; - for (x = width / 2; x < width - 1; x++) - { - y = 2; - while ((y < height) && (image[x + y * width] < level)) - { - image[y * width + x] = 255; - y++; - } - count++; - top += y; - } - if (DBG_LEVEL >= DBG_data) - sanei_genesys_write_pnm_file("gl_detected-ysobel.pnm", image.data(), 8, 1, width, height); - top = top / count; - - /* bottom of black stripe is of fixed witdh, this hardcoded value - * will be moved into device struct if more such values are needed */ - top += 10; - dev->model->y_offset_calib_white = (top * MM_PER_INCH) / dpi; - DBG(DBG_info, "%s: black stripe y_offset = %f mm \n", __func__, - dev->model->y_offset_calib_white); - } - - /* find white corner in dark area : TODO yet another flag */ - if ((dev->model->sensor_id == SensorId::CCD_HP2300 && dev->model->motor_id == MotorId::HP2300) || - (dev->model->sensor_id == SensorId::CCD_HP2400 && dev->model->motor_id == MotorId::HP2400) || - (dev->model->sensor_id == SensorId::CCD_HP3670 && dev->model->motor_id == MotorId::HP3670)) - { - top = 0; - count = 0; - for (x = 10; x < 60; x++) - { - y = 2; - while ((y < height) && (image[x + y * width] < level)) - y++; - top += y; - count++; - } - top = top / count; - dev->model->y_offset_calib_white = (top * MM_PER_INCH) / dpi; - DBG(DBG_info, "%s: white corner y_offset = %f mm\n", __func__, - dev->model->y_offset_calib_white); - } - - DBG(DBG_proc, "%s: ccd_start_xoffset = %d, left = %d, top = %d\n", __func__, - sensor.ccd_start_xoffset, left, top); -} - namespace gl124 { void gl124_setup_scan_gpio(Genesys_Device* dev, int resolution); } // namespace gl124 @@ -2945,23 +2772,9 @@ static void genesys_start_scan(Genesys_Device* dev, bool lamp_off) /* set top left x and y values by scanning the internals if flatbed scanners */ if (!dev->model->is_sheetfed) { - /* do the geometry detection only once */ - if (has_flag(dev->model->flags, ModelFlag::SEARCH_START) && - (dev->model->y_offset_calib_white == 0)) - { - dev->cmd_set->search_start_position (dev); - - dev->parking = false; - dev->cmd_set->move_back_home(dev, true); - } - else - { - /* Go home */ - /* TODO: check we can drop this since we cannot have the - scanner's head wandering here */ - dev->parking = false; - dev->cmd_set->move_back_home(dev, true); - } + // TODO: check we can drop this since we cannot have the scanner's head wandering here + dev->parking = false; + dev->cmd_set->move_back_home(dev, true); } /* move to calibration area for transparency adapter */ diff --git a/backend/genesys/gl124.cpp b/backend/genesys/gl124.cpp index f8bf6a952..555df9577 100644 --- a/backend/genesys/gl124.cpp +++ b/backend/genesys/gl124.cpp @@ -1064,76 +1064,6 @@ void CommandSetGl124::move_back_home(Genesys_Device* dev, bool wait_until_home) scanner_move_back_home(*dev, wait_until_home); } -// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi -// from very top of scanner -void CommandSetGl124::search_start_position(Genesys_Device* dev) const -{ - DBG_HELPER(dbg); - Genesys_Register_Set local_reg = dev->reg; - - int pixels = 600; - int dpi = 300; - - /* sets for a 200 lines * 600 pixels */ - /* normal scan with no shading */ - - // FIXME: the current approach of doing search only for one resolution does not work on scanners - // whith employ different sensors with potentially different settings. - const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, ScanMethod::FLATBED); - - ScanSession session; - session.params.xres = dpi; - session.params.yres = dpi; - session.params.startx = 0; - session.params.starty = 0; /*we should give a small offset here~60 steps */ - session.params.pixels = 600; - session.params.lines = dev->model->search_lines; - session.params.depth = 8; - session.params.channels = 1; - session.params.scan_method = dev->settings.scan_method; - session.params.scan_mode = ScanColorMode::GRAY; - session.params.color_filter = ColorFilter::GREEN; - session.params.flags = ScanFlag::DISABLE_SHADING | - ScanFlag::DISABLE_GAMMA | - ScanFlag::DISABLE_BUFFER_FULL_MOVE; - compute_session(dev, session, sensor); - - init_regs_for_scan_session(dev, sensor, &local_reg, session); - - // send to scanner - dev->interface->write_registers(local_reg); - - begin_scan(dev, sensor, &local_reg, true); - - if (is_testing_mode()) { - dev->interface->test_checkpoint("search_start_position"); - end_scan(dev, &local_reg, true); - dev->reg = local_reg; - return; - } - - wait_until_buffer_non_empty(dev); - - // now we're on target, we can read data - auto image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes); - - if (DBG_LEVEL >= DBG_data) { - sanei_genesys_write_pnm_file("gl124_search_position.pnm", image); - } - - end_scan(dev, &local_reg, true); - - /* update regs to copy ASIC internal state */ - dev->reg = local_reg; - - for (auto& sensor_update : - sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) - { - sanei_genesys_search_reference_point(dev, sensor_update, image.get_row_ptr(0), 0, dpi, pixels, - dev->model->search_lines); - } -} - // init registers for shading calibration shading calibration is done at dpihw void CommandSetGl124::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const diff --git a/backend/genesys/gl124.h b/backend/genesys/gl124.h index 562800407..67b35e292 100644 --- a/backend/genesys/gl124.h +++ b/backend/genesys/gl124.h @@ -146,8 +146,6 @@ public: void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; - void search_start_position(Genesys_Device* dev) const override; - void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; diff --git a/backend/genesys/gl646.cpp b/backend/genesys/gl646.cpp index 6d25991ad..7b9cd8208 100644 --- a/backend/genesys/gl646.cpp +++ b/backend/genesys/gl646.cpp @@ -1574,76 +1574,6 @@ void CommandSetGl646::move_back_home(Genesys_Device* dev, bool wait_until_home) DBG(DBG_info, "%s: scanhead is still moving\n", __func__); } -/** - * Automatically set top-left edge of the scan area by scanning an - * area at 300 dpi from very top of scanner - * @param dev device stucture describing the scanner - */ -void CommandSetGl646::search_start_position(Genesys_Device* dev) const -{ - DBG_HELPER(dbg); - Genesys_Settings settings; - unsigned int resolution, x, y; - - /* we scan at 300 dpi */ - resolution = get_closest_resolution(dev->model->sensor_id, 300, 1); - - // FIXME: the current approach of doing search only for one resolution does not work on scanners - // whith employ different sensors with potentially different settings. - const auto& sensor = sanei_genesys_find_sensor(dev, resolution, 1, - dev->model->default_method); - - /* fill settings for a gray level scan */ - settings.scan_method = dev->model->default_method; - settings.scan_mode = ScanColorMode::GRAY; - settings.xres = resolution; - settings.yres = resolution; - settings.tl_x = 0; - settings.tl_y = 0; - settings.pixels = 600; - settings.requested_pixels = settings.pixels; - settings.lines = dev->model->search_lines; - settings.depth = 8; - settings.color_filter = ColorFilter::RED; - - settings.disable_interpolation = 0; - settings.threshold = 0; - - // scan the desired area - std::vector data; - simple_scan(dev, sensor, settings, true, true, false, data, "search_start_position"); - - // handle stagger case : reorder gray data and thus loose some lines - auto staggered_lines = dev->session.num_staggered_lines; - if (staggered_lines > 0) { - DBG(DBG_proc, "%s: 'un-staggering'\n", __func__); - for (y = 0; y < settings.lines - staggered_lines; y++) { - /* one point out of 2 is 'unaligned' */ - for (x = 0; x < settings.pixels; x += 2) - { - data[y * settings.pixels + x] = data[(y + staggered_lines) * settings.pixels + x]; - } - } - /* correct line number */ - settings.lines -= staggered_lines; - } - - if (DBG_LEVEL >= DBG_data) - { - sanei_genesys_write_pnm_file("gl646_search_position.pnm", data.data(), settings.depth, 1, - settings.pixels, settings.lines); - } - - // now search reference points on the data - for (auto& sensor_update : - sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) - { - sanei_genesys_search_reference_point(dev, sensor_update, data.data(), 0, - resolution, settings.pixels, settings.lines); - } -} - - /** * init registers for shading calibration * we assume that scanner's head is on an area suiting shading calibration. diff --git a/backend/genesys/gl646.h b/backend/genesys/gl646.h index e5db0b65b..6c442b04a 100644 --- a/backend/genesys/gl646.h +++ b/backend/genesys/gl646.h @@ -470,8 +470,6 @@ public: void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; - void search_start_position(Genesys_Device* dev) const override; - void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; diff --git a/backend/genesys/gl841.cpp b/backend/genesys/gl841.cpp index 6dafd1ad7..b1fe8eb10 100644 --- a/backend/genesys/gl841.cpp +++ b/backend/genesys/gl841.cpp @@ -2216,78 +2216,6 @@ void CommandSetGl841::move_back_home(Genesys_Device* dev, bool wait_until_home) DBG(DBG_info, "%s: scanhead is still moving\n", __func__); } -// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi -// from very top of scanner -void CommandSetGl841::search_start_position(Genesys_Device* dev) const -{ - DBG_HELPER(dbg); - Genesys_Register_Set local_reg; - - int pixels = 600; - int dpi = 300; - - local_reg = dev->reg; - - /* sets for a 200 lines * 600 pixels */ - /* normal scan with no shading */ - - // FIXME: the current approach of doing search only for one resolution does not work on scanners - // whith employ different sensors with potentially different settings. - const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method); - - ScanSession session; - session.params.xres = dpi; - session.params.yres = dpi; - session.params.startx = 0; - session.params.starty = 0; /*we should give a small offset here~60 steps*/ - session.params.pixels = 600; - session.params.lines = dev->model->search_lines; - session.params.depth = 8; - session.params.channels = 1; - session.params.scan_method = dev->settings.scan_method; - session.params.scan_mode = ScanColorMode::GRAY; - session.params.color_filter = ColorFilter::GREEN; - session.params.flags = ScanFlag::DISABLE_SHADING | - ScanFlag::DISABLE_GAMMA | - ScanFlag::DISABLE_BUFFER_FULL_MOVE; - compute_session(dev, session, sensor); - - init_regs_for_scan_session(dev, sensor, &local_reg, session); - - // send to scanner - dev->interface->write_registers(local_reg); - - dev->cmd_set->begin_scan(dev, sensor, &local_reg, true); - - if (is_testing_mode()) { - dev->interface->test_checkpoint("search_start_position"); - dev->cmd_set->end_scan(dev, &local_reg, true); - dev->reg = local_reg; - return; - } - - wait_until_buffer_non_empty(dev); - - // now we're on target, we can read data - auto image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes); - - if (DBG_LEVEL >= DBG_data) { - sanei_genesys_write_pnm_file("gl841_search_position.pnm", image); - } - - dev->cmd_set->end_scan(dev, &local_reg, true); - - /* update regs to copy ASIC internal state */ - dev->reg = local_reg; - - for (auto& sensor_update : - sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) - { - sanei_genesys_search_reference_point(dev, sensor_update, image.get_row_ptr(0), 0, dpi, - pixels, dev->model->search_lines); - } -} - // init registers for shading calibration void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const @@ -2683,8 +2611,6 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& /* this function does the offset calibration by scanning one line of the calibration area below scanner's top. There is a black margin and the remaining is white. - sanei_genesys_search_start() must have been called so that the offsets and margins - are allready known. this function expects the slider to be where? */ diff --git a/backend/genesys/gl841.h b/backend/genesys/gl841.h index de9cc5431..cee9f000b 100644 --- a/backend/genesys/gl841.h +++ b/backend/genesys/gl841.h @@ -84,8 +84,6 @@ public: void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; - void search_start_position(Genesys_Device* dev) const override; - void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; diff --git a/backend/genesys/gl843.cpp b/backend/genesys/gl843.cpp index b9899c9dc..2dd408443 100644 --- a/backend/genesys/gl843.cpp +++ b/backend/genesys/gl843.cpp @@ -1481,80 +1481,6 @@ void CommandSetGl843::move_back_home(Genesys_Device* dev, bool wait_until_home) scanner_move_back_home(*dev, wait_until_home); } -// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi -// from very top of scanner -void CommandSetGl843::search_start_position(Genesys_Device* dev) const -{ - DBG_HELPER(dbg); - Genesys_Register_Set local_reg; - - int pixels = 600; - int dpi = 300; - - local_reg = dev->reg; - - /* sets for a 200 lines * 600 pixels */ - /* normal scan with no shading */ - - // FIXME: the current approach of doing search only for one resolution does not work on scanners - // whith employ different sensors with potentially different settings. - const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method); - - ScanSession session; - session.params.xres = dpi; - session.params.yres = dpi; - session.params.startx = 0; - session.params.starty = 0; // we should give a small offset here - ~60 steps - session.params.pixels = 600; - session.params.lines = dev->model->search_lines; - session.params.depth = 8; - session.params.channels = 1; - session.params.scan_method = dev->settings.scan_method; - session.params.scan_mode = ScanColorMode::GRAY; - session.params.color_filter = ColorFilter::GREEN; - session.params.flags = ScanFlag::DISABLE_SHADING | - ScanFlag::DISABLE_GAMMA | - ScanFlag::DISABLE_BUFFER_FULL_MOVE; - compute_session(dev, session, sensor); - - init_regs_for_scan_session(dev, sensor, &local_reg, session); - - // send to scanner - dev->interface->write_registers(local_reg); - - dev->cmd_set->begin_scan(dev, sensor, &local_reg, true); - - if (is_testing_mode()) { - dev->interface->test_checkpoint("search_start_position"); - end_scan(dev, &local_reg, true); - dev->reg = local_reg; - return; - } - - wait_until_buffer_non_empty(dev); - - // now we're on target, we can read data - Image image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes_raw); - - scanner_stop_action_no_move(*dev, local_reg); - - if (DBG_LEVEL >= DBG_data) { - sanei_genesys_write_pnm_file("gl843_search_position.pnm", image); - } - - dev->cmd_set->end_scan(dev, &local_reg, true); - - /* update regs to copy ASIC internal state */ - dev->reg = local_reg; - - for (auto& sensor_update : - sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) - { - sanei_genesys_search_reference_point(dev, sensor_update, image.get_row_ptr(0), 0, dpi, - pixels, dev->model->search_lines); - } -} - static bool should_calibrate_only_active_area(const Genesys_Device& dev, const Genesys_Settings& settings) { diff --git a/backend/genesys/gl843.h b/backend/genesys/gl843.h index fdbcc0243..b01356468 100644 --- a/backend/genesys/gl843.h +++ b/backend/genesys/gl843.h @@ -84,8 +84,6 @@ public: void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; - void search_start_position(Genesys_Device* dev) const override; - void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; diff --git a/backend/genesys/gl846.cpp b/backend/genesys/gl846.cpp index 5278ed1db..c17bb5fb7 100644 --- a/backend/genesys/gl846.cpp +++ b/backend/genesys/gl846.cpp @@ -834,81 +834,6 @@ void CommandSetGl846::move_back_home(Genesys_Device* dev, bool wait_until_home) scanner_move_back_home(*dev, wait_until_home); } -// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi -// from very top of scanner -void CommandSetGl846::search_start_position(Genesys_Device* dev) const -{ - DBG_HELPER(dbg); - Genesys_Register_Set local_reg; - - int pixels = 600; - int dpi = 300; - - local_reg = dev->reg; - - /* sets for a 200 lines * 600 pixels */ - /* normal scan with no shading */ - - // FIXME: the current approach of doing search only for one resolution does not work on scanners - // whith employ different sensors with potentially different settings. - const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method); - - ScanSession session; - session.params.xres = dpi; - session.params.yres = dpi; - session.params.startx = 0; - session.params.starty = 0; /*we should give a small offset here~60 steps */ - session.params.pixels = 600; - session.params.lines = dev->model->search_lines; - session.params.depth = 8; - session.params.channels = 1; - session.params.scan_method = dev->settings.scan_method; - session.params.scan_mode = ScanColorMode::GRAY; - session.params.color_filter = ColorFilter::GREEN; - session.params.flags = ScanFlag::DISABLE_SHADING | - ScanFlag::DISABLE_GAMMA | - ScanFlag::IGNORE_STAGGER_OFFSET | - ScanFlag::IGNORE_COLOR_OFFSET; - compute_session(dev, session, sensor); - - init_regs_for_scan_session(dev, sensor, &local_reg, session); - - // send to scanner - dev->interface->write_registers(local_reg); - - begin_scan(dev, sensor, &local_reg, true); - - if (is_testing_mode()) { - dev->interface->test_checkpoint("search_start_position"); - end_scan(dev, &local_reg, true); - dev->reg = local_reg; - return; - } - - wait_until_buffer_non_empty(dev); - - // now we're on target, we can read data - auto image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes); - - if (DBG_LEVEL >= DBG_data) { - sanei_genesys_write_pnm_file("gl846_search_position.pnm", image); - } - - end_scan(dev, &local_reg, true); - - /* update regs to copy ASIC internal state */ - dev->reg = local_reg; - - // TODO: find out where sanei_genesys_search_reference_point stores information, - // and use that correctly - for (auto& sensor_update : - sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) - { - sanei_genesys_search_reference_point(dev, sensor_update, image.get_row_ptr(0), 0, dpi, - pixels, dev->model->search_lines); - } -} - // init registers for shading calibration void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const diff --git a/backend/genesys/gl846.h b/backend/genesys/gl846.h index 3b4a5eafe..38697618a 100644 --- a/backend/genesys/gl846.h +++ b/backend/genesys/gl846.h @@ -159,8 +159,6 @@ public: void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; - void search_start_position(Genesys_Device* dev) const override; - void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; diff --git a/backend/genesys/gl847.cpp b/backend/genesys/gl847.cpp index cbf34b3c5..1053e8efa 100644 --- a/backend/genesys/gl847.cpp +++ b/backend/genesys/gl847.cpp @@ -842,79 +842,6 @@ void CommandSetGl847::move_back_home(Genesys_Device* dev, bool wait_until_home) scanner_move_back_home(*dev, wait_until_home); } -// Automatically set top-left edge of the scan area by scanning a 200x200 pixels area at 600 dpi -// from very top of scanner -void CommandSetGl847::search_start_position(Genesys_Device* dev) const -{ - DBG_HELPER(dbg); - Genesys_Register_Set local_reg; - - int pixels = 600; - int dpi = 300; - - local_reg = dev->reg; - - /* sets for a 200 lines * 600 pixels */ - /* normal scan with no shading */ - - // FIXME: the current approach of doing search only for one resolution does not work on scanners - // whith employ different sensors with potentially different settings. - const auto& sensor = sanei_genesys_find_sensor(dev, dpi, 1, dev->model->default_method); - - ScanSession session; - session.params.xres = dpi; - session.params.yres = dpi; - session.params.startx = 0; - session.params.starty = 0; /*we should give a small offset here~60 steps */ - session.params.pixels = 600; - session.params.lines = dev->model->search_lines; - session.params.depth = 8; - session.params.channels = 1; - session.params.scan_method = dev->settings.scan_method; - session.params.scan_mode = ScanColorMode::GRAY; - session.params.color_filter = ColorFilter::GREEN; - session.params.flags = ScanFlag::DISABLE_SHADING | - ScanFlag::DISABLE_GAMMA; - compute_session(dev, session, sensor); - - init_regs_for_scan_session(dev, sensor, &local_reg, session); - - // send to scanner - dev->interface->write_registers(local_reg); - - begin_scan(dev, sensor, &local_reg, true); - - if (is_testing_mode()) { - dev->interface->test_checkpoint("search_start_position"); - end_scan(dev, &local_reg, true); - dev->reg = local_reg; - return; - } - - wait_until_buffer_non_empty(dev); - - // now we're on target, we can read data - auto image = read_unshuffled_image_from_scanner(dev, session, session.output_total_bytes); - - if (DBG_LEVEL >= DBG_data) { - sanei_genesys_write_pnm_file("gl847_search_position.pnm", image); - } - - end_scan(dev, &local_reg, true); - - /* update regs to copy ASIC internal state */ - dev->reg = local_reg; - - // TODO: find out where sanei_genesys_search_reference_point stores information, - // and use that correctly - for (auto& sensor_update : - sanei_genesys_find_sensors_all_for_write(dev, dev->model->default_method)) - { - sanei_genesys_search_reference_point(dev, sensor_update, image.get_row_ptr(0), 0, dpi, - pixels, dev->model->search_lines); - } -} - // init registers for shading calibration void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const diff --git a/backend/genesys/gl847.h b/backend/genesys/gl847.h index e12b610c2..86062fd8d 100644 --- a/backend/genesys/gl847.h +++ b/backend/genesys/gl847.h @@ -147,8 +147,6 @@ public: void send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& sensor) const override; - void search_start_position(Genesys_Device* dev) const override; - void offset_calibration(Genesys_Device* dev, const Genesys_Sensor& sensor, Genesys_Register_Set& regs) const override; diff --git a/backend/genesys/low.h b/backend/genesys/low.h index 8ee4cc5da..15203cb1f 100644 --- a/backend/genesys/low.h +++ b/backend/genesys/low.h @@ -286,10 +286,6 @@ void sanei_genesys_send_gamma_table(Genesys_Device* dev, const Genesys_Sensor& s extern void sanei_genesys_stop_motor(Genesys_Device* dev); -extern void sanei_genesys_search_reference_point(Genesys_Device* dev, Genesys_Sensor& sensor, - const uint8_t* src_data, int start_pixel, int dpi, - int width, int height); - // moves the scan head by the specified steps at the motor base dpi void scanner_move(Genesys_Device& dev, ScanMethod scan_method, unsigned steps, Direction direction); From 6653ec0ae65eda268033d40287f6f7e0084f1c8b Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 22 Feb 2020 10:28:18 +0200 Subject: [PATCH 4/5] genesys: Remove support for shading calibration without moving --- backend/genesys/enums.h | 3 --- backend/genesys/genesys.cpp | 15 ++------------- backend/genesys/tables_model.cpp | 3 +-- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/backend/genesys/enums.h b/backend/genesys/enums.h index a6ba174f3..ddcfc11a5 100644 --- a/backend/genesys/enums.h +++ b/backend/genesys/enums.h @@ -466,9 +466,6 @@ enum class ModelFlag : unsigned // the scanner uses multi-segment sensors that must be handled during calibration SIS_SENSOR = 1 << 16, - // the scanner does not move sensor during scanner calibration - SHADING_NO_MOVE = 1 << 17, - // the head must be reparked between shading scans SHADING_REPARK = 1 << 18, diff --git a/backend/genesys/genesys.cpp b/backend/genesys/genesys.cpp index 5a3550a9b..af871d675 100644 --- a/backend/genesys/genesys.cpp +++ b/backend/genesys/genesys.cpp @@ -1163,20 +1163,14 @@ static void genesys_shading_calibration_impl(Genesys_Device* dev, const Genesys_ std::vector calibration_data(size / 2); - bool motor = true; - if (has_flag(dev->model->flags, ModelFlag::SHADING_NO_MOVE)) { - motor = false; - } - // turn off motor and lamp power for flatbed scanners, but not for sheetfed scanners // because they have a calibration sheet with a sufficient black strip if (is_dark && !dev->model->is_sheetfed) { sanei_genesys_set_lamp_power(dev, sensor, local_reg, false); - sanei_genesys_set_motor_power(local_reg, motor); } else { sanei_genesys_set_lamp_power(dev, sensor, local_reg, true); - sanei_genesys_set_motor_power(local_reg, motor); } + sanei_genesys_set_motor_power(local_reg, true); dev->interface->write_registers(local_reg); @@ -1411,14 +1405,9 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev, std::vector calibration_data(size); - bool motor = true; - if (has_flag(dev->model->flags, ModelFlag::SHADING_NO_MOVE)) { - motor = false; - } - // turn on motor and lamp power sanei_genesys_set_lamp_power(dev, sensor, local_reg, true); - sanei_genesys_set_motor_power(local_reg, motor); + sanei_genesys_set_motor_power(local_reg, true); dev->interface->write_registers(local_reg); diff --git a/backend/genesys/tables_model.cpp b/backend/genesys/tables_model.cpp index f8a3fb276..a3f67cdad 100644 --- a/backend/genesys/tables_model.cpp +++ b/backend/genesys/tables_model.cpp @@ -1488,7 +1488,7 @@ void genesys_init_usb_device_tables() model.y_size = 296.4; model.y_offset_calib_white = 0.00; - model.y_size_calib_mm = 3.0; + model.y_size_calib_mm = 2.0; model.x_offset_calib_black = 0.00; model.post_scan = 0.0; @@ -1507,7 +1507,6 @@ void genesys_init_usb_device_tables() model.motor_id = MotorId::MD_5345; model.flags = ModelFlag::GAMMA_14BIT | ModelFlag::DARK_CALIBRATION | - ModelFlag::SHADING_NO_MOVE | ModelFlag::CUSTOM_GAMMA; model.buttons = GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | From 793703c93e29f672c97e1a6e8b32bae9eea06f86 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 22 Feb 2020 10:28:19 +0200 Subject: [PATCH 5/5] genesys: Update scan geometry on ScanJet 2300 --- backend/genesys/tables_model.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/genesys/tables_model.cpp b/backend/genesys/tables_model.cpp index a3f67cdad..1b1ec9c2b 100644 --- a/backend/genesys/tables_model.cpp +++ b/backend/genesys/tables_model.cpp @@ -1178,8 +1178,8 @@ void genesys_init_usb_device_tables() model.bpp_gray_values = { 8, 16 }; model.bpp_color_values = { 8, 16 }; - model.x_offset = 2.0; - model.y_offset = 7.5; // FIXME: incorrect, needs updating + model.x_offset = 6.5; + model.y_offset = 8; model.x_size = 215.9; model.y_size = 295.0;