From 6ca11bfd719fdf6e08fd5c8711356af0f9bca97d Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 24 Aug 2019 10:13:41 +0300 Subject: [PATCH 1/4] genesys: Always dump session after computing it --- backend/genesys_gl124.cc | 8 +++----- backend/genesys_gl646.cc | 4 +++- backend/genesys_gl841.cc | 8 +++----- backend/genesys_gl843.cc | 8 +++----- backend/genesys_gl846.cc | 8 +++----- backend/genesys_gl847.cc | 8 +++----- 6 files changed, 18 insertions(+), 26 deletions(-) diff --git a/backend/genesys_gl124.cc b/backend/genesys_gl124.cc index 0a49f3080..1d70b30d6 100644 --- a/backend/genesys_gl124.cc +++ b/backend/genesys_gl124.cc @@ -1050,6 +1050,9 @@ static void gl124_compute_session(Genesys_Device* dev, ScanSession& s, s.enable_ledadd = (s.params.channels == 1 && dev->model->is_cis && dev->settings.true_gray); s.computed = true; + + DBG(DBG_info, "%s ", __func__); + debug_dump(DBG_info, s); } /** set up registers for an actual scan @@ -1076,8 +1079,6 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens int max_shift; size_t requested_buffer_size, read_buffer_size; - debug_dump(DBG_info, session.params); - DBG (DBG_info, "%s: optical_res=%d\n", __func__, session.optical_resolution); /* stagger */ @@ -1252,9 +1253,6 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso gl124_compute_session(dev, session, sensor); - DBG(DBG_info, "%s ", __func__); - debug_dump(DBG_info, session.params); - used_res = session.params.xres; /* compute scan parameters values */ diff --git a/backend/genesys_gl646.cc b/backend/genesys_gl646.cc index a6837dcea..6b4bc8209 100644 --- a/backend/genesys_gl646.cc +++ b/backend/genesys_gl646.cc @@ -297,6 +297,9 @@ static void gl646_compute_session(Genesys_Device* dev, ScanSession& s, compute_session(dev, s, sensor); s.computed = true; + + DBG(DBG_info, "%s ", __func__); + debug_dump(DBG_info, s); } /** @@ -323,7 +326,6 @@ static void gl646_setup_registers(Genesys_Device* dev, session.assert_computed(); debug_dump(DBG_info, sensor); - debug_dump(DBG_info, session); int resolution = session.params.xres; uint32_t move = session.params.starty; diff --git a/backend/genesys_gl841.cc b/backend/genesys_gl841.cc index 77ef1d43d..f940f9add 100644 --- a/backend/genesys_gl841.cc +++ b/backend/genesys_gl841.cc @@ -1738,6 +1738,9 @@ static void gl841_compute_session(Genesys_Device* dev, ScanSession& s, compute_session(dev, s, sensor); s.computed = true; + + DBG(DBG_info, "%s ", __func__); + debug_dump(DBG_info, s); } static void gl841_assert_supported_resolution(const ScanSession& session) @@ -1774,8 +1777,6 @@ static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens int max_shift; size_t requested_buffer_size, read_buffer_size; - debug_dump(DBG_info, session.params); - /* results: @@ -2051,9 +2052,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se gl841_compute_session(dev, session, sensor); - DBG(DBG_info, "%s ", __func__); - debug_dump(DBG_info, session.params); - /* stagger */ if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) { diff --git a/backend/genesys_gl843.cc b/backend/genesys_gl843.cc index b9ddc930e..d724c1a0b 100644 --- a/backend/genesys_gl843.cc +++ b/backend/genesys_gl843.cc @@ -1229,6 +1229,9 @@ static void gl843_compute_session(Genesys_Device* dev, ScanSession& s, } s.computed = true; + + DBG(DBG_info, "%s ", __func__); + debug_dump(DBG_info, s); } // set up registers for an actual scan this function sets up the scanner to scan in normal or single @@ -1247,8 +1250,6 @@ static void gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens int scan_step_type = 1; size_t requested_buffer_size, read_buffer_size; - debug_dump(DBG_info, session.params); - DBG(DBG_info, "%s : stagger=%d lines\n", __func__, session.num_staggered_lines); /* we enable true gray for cis scanners only, and just when doing @@ -1427,9 +1428,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor gl843_compute_session(dev, session, sensor); - DBG(DBG_info, "%s ", __func__); - debug_dump(DBG_info, session.params); - /* stagger */ if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) { stagger = (4 * session.params.yres) / dev->motor.base_ydpi; diff --git a/backend/genesys_gl846.cc b/backend/genesys_gl846.cc index ef7669e16..42a0ce378 100644 --- a/backend/genesys_gl846.cc +++ b/backend/genesys_gl846.cc @@ -937,6 +937,9 @@ static void gl846_compute_session(Genesys_Device* dev, ScanSession& s, s.enable_ledadd = (s.params.channels == 1 && dev->model->is_cis && dev->settings.true_gray); s.computed = true; + + DBG(DBG_info, "%s ", __func__); + debug_dump(DBG_info, s); } // set up registers for an actual scan this function sets up the scanner to scan in normal or single @@ -961,8 +964,6 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens int max_shift; size_t requested_buffer_size, read_buffer_size; - debug_dump(DBG_info, session.params); - /* stagger */ if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) { stagger = (4 * session.params.yres) / dev->motor.base_ydpi; @@ -1146,9 +1147,6 @@ gl846_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor gl846_compute_session(dev, session, sensor); - DBG(DBG_info, "%s ", __func__); - debug_dump(DBG_info, session.params); - if (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE) { stagger = (4 * session.params.yres) / dev->motor.base_ydpi; } else { diff --git a/backend/genesys_gl847.cc b/backend/genesys_gl847.cc index 98b8b8a71..77a8f569a 100644 --- a/backend/genesys_gl847.cc +++ b/backend/genesys_gl847.cc @@ -956,6 +956,9 @@ static void gl847_compute_session(Genesys_Device* dev, ScanSession& s, compute_session(dev, s, sensor); s.computed = true; + + DBG(DBG_info, "%s ", __func__); + debug_dump(DBG_info, s); } // set up registers for an actual scan this function sets up the scanner to scan in normal or single @@ -980,8 +983,6 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens int max_shift; size_t requested_buffer_size, read_buffer_size; - debug_dump(DBG_info, session.params); - /* stagger */ if (session.ccd_size_divisor == 1 && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) { stagger = (4 * session.params.yres) / dev->motor.base_ydpi; @@ -1164,9 +1165,6 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor gl847_compute_session(dev, session, sensor); - DBG(DBG_info, "%s ", __func__); - debug_dump(DBG_info, session.params); - /* optical_res */ optical_res = sensor.optical_res; From 48251cf8b22dec638861cd8832bbf1fe0d1e38bc Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 24 Aug 2019 10:13:42 +0300 Subject: [PATCH 2/4] genesys: Simplify start pixel computation on gl841 --- backend/genesys_gl841.cc | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/backend/genesys_gl841.cc b/backend/genesys_gl841.cc index f940f9add..2cbe03216 100644 --- a/backend/genesys_gl841.cc +++ b/backend/genesys_gl841.cc @@ -1824,10 +1824,9 @@ independent of our calculated values: /* compute scan parameters values */ /* pixels are allways given at half or full CCD optical resolution */ /* use detected left margin and fixed value */ - start = ((sensor.CCD_start_xoffset + session.params.startx) * used_res) / sensor.optical_res; + start = ((sensor.CCD_start_xoffset + session.params.startx) * session.optical_resolution) + / sensor.optical_res; - // needs to be aligned for used_res - start = (start * session.optical_resolution) / used_res; start += sensor.dummy_pixel + 1; @@ -2067,10 +2066,7 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se /* compute scan parameters values */ /* pixels are allways given at half or full CCD optical resolution */ /* use detected left margin and fixed value */ - start = ((sensor.CCD_start_xoffset + session.params.startx) * used_res) / sensor.optical_res; - - // needs to be aligned for used_res - start = (start * session.optical_resolution) / used_res; + start = ((sensor.CCD_start_xoffset + session.params.startx) * session.optical_resolution) / sensor.optical_res; start += sensor.dummy_pixel + 1; From ba3013b1aae35b57e35dc38c4027e182f2fb519f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 24 Aug 2019 10:13:43 +0300 Subject: [PATCH 3/4] genesys: Handle full sensor scans on gl841 consistently to other chips --- backend/genesys_gl841.cc | 147 ++++++++++++++++++++++++--------------- backend/genesys_low.h | 1 - 2 files changed, 89 insertions(+), 59 deletions(-) diff --git a/backend/genesys_gl841.cc b/backend/genesys_gl841.cc index 2cbe03216..2ed126477 100644 --- a/backend/genesys_gl841.cc +++ b/backend/genesys_gl841.cc @@ -1814,11 +1814,8 @@ independent of our calculated values: } DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger); - if (session.params.flags & SCAN_FLAG_USE_OPTICAL_RES) { - used_res = session.optical_resolution; - } else { - used_res = session.params.xres; - } + used_res = session.params.xres; + gl841_assert_supported_resolution(session); /* compute scan parameters values */ @@ -2943,12 +2940,20 @@ static void gl841_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso dev->calib_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, + dev->settings.scan_method); + + dev->calib_pixels = calib_sensor.sensor_pixels / factor; + ScanSession session; - session.params.xres = dev->settings.xres; + session.params.xres = resolution; session.params.yres = ydpi; session.params.startx = 0; session.params.starty = starty; - session.params.pixels = (sensor.sensor_pixels * dev->settings.xres) / sensor.optical_res; + session.params.pixels = dev->calib_pixels; session.params.lines = dev->calib_lines; session.params.depth = 16; session.params.channels = dev->calib_channels; @@ -2957,14 +2962,12 @@ static void gl841_init_regs_for_shading(Genesys_Device* dev, const Genesys_Senso session.params.color_filter = dev->settings.color_filter; session.params.flags = SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_GAMMA | - SCAN_FLAG_USE_OPTICAL_RES | /*SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE |*/ SCAN_FLAG_IGNORE_LINE_DISTANCE; - gl841_compute_session(dev, session, sensor); + gl841_compute_session(dev, session, calib_sensor); - gl841_init_scan_regs(dev, sensor, ®s, session); + gl841_init_scan_regs(dev, calib_sensor, ®s, session); - dev->calib_pixels = dev->current_setup.pixels; dev->scanhead_position_in_steps += dev->calib_lines + starty; dev->write_registers(regs); @@ -3127,12 +3130,20 @@ static SensorExposure gl841_led_calibration(Genesys_Device* dev, const Genesys_S /* offset calibration is always done in color mode */ channels = 3; + unsigned resolution = sensor.get_logical_hwdpi(dev->settings.xres); + unsigned factor = sensor.optical_res / resolution; + + const auto& calib_sensor_base = sanei_genesys_find_sensor(dev, resolution, channels, + dev->settings.scan_method); + + num_pixels = calib_sensor_base.sensor_pixels / factor; + ScanSession session; - session.params.xres = dev->settings.xres; + session.params.xres = resolution; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; - session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res; + session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 16; session.params.channels = channels; @@ -3142,15 +3153,13 @@ static SensorExposure gl841_led_calibration(Genesys_Device* dev, const Genesys_S session.params.flags = SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_GAMMA | SCAN_FLAG_SINGLE_LINE | - SCAN_FLAG_IGNORE_LINE_DISTANCE | - SCAN_FLAG_USE_OPTICAL_RES; - gl841_compute_session(dev, session, sensor); + SCAN_FLAG_IGNORE_LINE_DISTANCE; + gl841_compute_session(dev, session, calib_sensor_base); - gl841_init_scan_regs(dev, sensor, ®s, session); + gl841_init_scan_regs(dev, calib_sensor_base, ®s, session); dev->write_registers(regs); - num_pixels = dev->current_setup.pixels; total_size = num_pixels * channels * 2 * 1; /* colors * bytes_per_color * scan lines */ @@ -3174,7 +3183,7 @@ static SensorExposure gl841_led_calibration(Genesys_Device* dev, const Genesys_S max_exposure=((exp[0]+exp[1]+exp[2])/3)*2; target=sensor.gain_white_ref*256; - auto calib_sensor = sensor; + auto calib_sensor = calib_sensor_base; do { calib_sensor.exposure.red = exp[0]; @@ -3325,12 +3334,20 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& return; } + 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, 3, + dev->settings.scan_method); + + num_pixels = calib_sensor.sensor_pixels / factor; + ScanSession session; - session.params.xres = dev->settings.xres; + session.params.xres = resolution; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; - session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res; + session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 8; session.params.channels = 3; @@ -3340,13 +3357,11 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& session.params.flags = SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_GAMMA | SCAN_FLAG_SINGLE_LINE | - SCAN_FLAG_IGNORE_LINE_DISTANCE | - SCAN_FLAG_USE_OPTICAL_RES; - gl841_compute_session(dev, session, sensor); + SCAN_FLAG_IGNORE_LINE_DISTANCE; + gl841_compute_session(dev, session, calib_sensor); - gl841_init_scan_regs(dev, sensor, ®s, session); + gl841_init_scan_regs(dev, calib_sensor, ®s, session); - num_pixels = dev->current_setup.pixels; total_size = num_pixels * 3 * 2 * 1; std::vector line(total_size); @@ -3369,8 +3384,8 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& /* scan line */ DBG(DBG_info, "%s: starting line reading\n", __func__); dev->write_registers(regs); - gl841_set_fe(dev, sensor, AFE_SET); - gl841_begin_scan(dev, sensor, ®s, SANE_TRUE); + gl841_set_fe(dev, calib_sensor, AFE_SET); + gl841_begin_scan(dev, calib_sensor, ®s, SANE_TRUE); sanei_genesys_read_data_from_scanner(dev, line.data(), total_size); gl841_stop_action (dev); if (DBG_LEVEL >= DBG_data) { @@ -3443,12 +3458,20 @@ static void gl841_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& /* offset calibration is always done in color mode */ channels = 3; + 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, channels, + dev->settings.scan_method); + + num_pixels = calib_sensor.sensor_pixels / factor; + ScanSession session; - session.params.xres = dev->settings.xres; + session.params.xres = resolution; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; - session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res; + session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 16; session.params.channels = channels; @@ -3459,13 +3482,10 @@ static void gl841_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& SCAN_FLAG_DISABLE_GAMMA | SCAN_FLAG_SINGLE_LINE | SCAN_FLAG_IGNORE_LINE_DISTANCE | - SCAN_FLAG_USE_OPTICAL_RES | SCAN_FLAG_DISABLE_LAMP; - gl841_compute_session(dev, session, sensor); + gl841_compute_session(dev, session, calib_sensor); - gl841_init_scan_regs(dev, sensor, ®s, session); - - num_pixels = dev->current_setup.pixels; + gl841_init_scan_regs(dev, calib_sensor, ®s, session); total_size = num_pixels * channels * 2 * 1; /* colors * bytes_per_color * scan lines */ @@ -3511,10 +3531,10 @@ static void gl841_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& dev->frontend.set_offset(j, off[j]); } - gl841_set_fe(dev, sensor, AFE_SET); + gl841_set_fe(dev, calib_sensor, AFE_SET); DBG(DBG_info, "%s: starting first line reading\n", __func__); - gl841_begin_scan(dev, sensor, ®s, SANE_TRUE); + gl841_begin_scan(dev, calib_sensor, ®s, SANE_TRUE); sanei_genesys_read_data_from_scanner(dev, first_line.data(), total_size); @@ -3618,11 +3638,11 @@ static void gl841_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& dev->frontend.set_offset(j, off[j]); } - gl841_set_fe(dev, sensor, AFE_SET); + gl841_set_fe(dev, calib_sensor, AFE_SET); DBG(DBG_info, "%s: starting second line reading\n", __func__); dev->write_registers(regs); - gl841_begin_scan(dev, sensor, ®s, SANE_TRUE); + gl841_begin_scan(dev, calib_sensor, ®s, SANE_TRUE); sanei_genesys_read_data_from_scanner(dev, second_line.data(), total_size); if (DBG_LEVEL >= DBG_data) { @@ -3804,12 +3824,20 @@ static void gl841_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen /* coarse gain calibration is allways done in color mode */ channels = 3; + 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, channels, + dev->settings.scan_method); + + num_pixels = calib_sensor.sensor_pixels / factor; + ScanSession session; - session.params.xres = dev->settings.xres; + session.params.xres = resolution; session.params.yres = dev->settings.yres; session.params.startx = 0; session.params.starty = 0; - session.params.pixels = (sensor.sensor_pixels*dev->settings.xres) / sensor.optical_res; + session.params.pixels = num_pixels; session.params.lines = lines; session.params.depth = 16; session.params.channels = channels; @@ -3819,21 +3847,18 @@ static void gl841_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen session.params.flags = SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_GAMMA | SCAN_FLAG_SINGLE_LINE | - SCAN_FLAG_IGNORE_LINE_DISTANCE | - SCAN_FLAG_USE_OPTICAL_RES; - gl841_compute_session(dev, session, sensor); + SCAN_FLAG_IGNORE_LINE_DISTANCE; + gl841_compute_session(dev, session, calib_sensor); - gl841_init_scan_regs(dev, sensor, ®s, session); + gl841_init_scan_regs(dev, calib_sensor, ®s, session); dev->write_registers(regs); - num_pixels = dev->current_setup.pixels; - total_size = num_pixels * channels * 2 * lines; /* colors * bytes_per_color * scan lines */ std::vector line(total_size); - gl841_begin_scan(dev, sensor, ®s, SANE_TRUE); + gl841_begin_scan(dev, calib_sensor, ®s, SANE_TRUE); sanei_genesys_read_data_from_scanner(dev, line.data(), total_size); if (DBG_LEVEL >= DBG_data) @@ -3969,8 +3994,7 @@ static void gl841_init_regs_for_warmup(Genesys_Device* dev, const Genesys_Sensor session.params.flags = SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_GAMMA | SCAN_FLAG_SINGLE_LINE | - SCAN_FLAG_IGNORE_LINE_DISTANCE | - SCAN_FLAG_USE_OPTICAL_RES; + SCAN_FLAG_IGNORE_LINE_DISTANCE; gl841_compute_session(dev, session, sensor); gl841_init_scan_regs(dev, sensor, local_reg, session); @@ -4109,12 +4133,20 @@ static void gl841_init(Genesys_Device* dev) Genesys_Register_Set& regs = dev->calib_reg; regs = dev->reg; + unsigned resolution = sensor.get_logical_hwdpi(300); + unsigned factor = sensor.optical_res / resolution; + + const auto& calib_sensor = sanei_genesys_find_sensor(dev, resolution, 3, + dev->settings.scan_method); + + unsigned num_pixels = 16 / factor; + ScanSession session; - session.params.xres = 300; + session.params.xres = resolution; session.params.yres = 300; session.params.startx = 0; session.params.starty = 0; - session.params.pixels = (16 * 300) / sensor.optical_res; + session.params.pixels = num_pixels; session.params.lines = 1; session.params.depth = 16; session.params.channels = 3; @@ -4124,20 +4156,19 @@ static void gl841_init(Genesys_Device* dev) session.params.flags = SCAN_FLAG_DISABLE_SHADING | SCAN_FLAG_DISABLE_GAMMA | SCAN_FLAG_SINGLE_LINE | - SCAN_FLAG_IGNORE_LINE_DISTANCE | - SCAN_FLAG_USE_OPTICAL_RES; - gl841_compute_session(dev, session, sensor); + SCAN_FLAG_IGNORE_LINE_DISTANCE; + gl841_compute_session(dev, session, calib_sensor); - gl841_init_scan_regs(dev, sensor, ®s, session); + gl841_init_scan_regs(dev, calib_sensor, ®s, session); dev->write_registers(regs); - size = dev->current_setup.pixels * 3 * 2 * 1; /* colors * bytes_per_color * scan lines */ + size = num_pixels * 3 * 2 * 1; // colors * bytes_per_color * scan lines std::vector line(size); DBG(DBG_info, "%s: starting dummy data reading\n", __func__); - gl841_begin_scan(dev, sensor, ®s, SANE_TRUE); + gl841_begin_scan(dev, calib_sensor, ®s, SANE_TRUE); sanei_usb_set_timeout(1000);/* 1 second*/ diff --git a/backend/genesys_low.h b/backend/genesys_low.h index 0f0739d95..5b46e4918 100644 --- a/backend/genesys_low.h +++ b/backend/genesys_low.h @@ -372,7 +372,6 @@ extern Motor_Profile gl124_motor_profiles[]; #define SCAN_FLAG_DISABLE_GAMMA 0x004 #define SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE 0x008 #define SCAN_FLAG_IGNORE_LINE_DISTANCE 0x010 -#define SCAN_FLAG_USE_OPTICAL_RES 0x020 #define SCAN_FLAG_DISABLE_LAMP 0x040 #define SCAN_FLAG_DYNAMIC_LINEART 0x080 #define SCAN_FLAG_CALIBRATION 0x100 From 2757475dd99863eeb5e59ea38333c362bfd26604 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 24 Aug 2019 10:13:44 +0300 Subject: [PATCH 4/4] genesys: Use session.params.xres directly where possible --- backend/genesys_gl124.cc | 22 +++++++++------------- backend/genesys_gl841.cc | 19 +++++++------------ backend/genesys_gl843.cc | 6 ++---- backend/genesys_gl846.cc | 12 +++++------- backend/genesys_gl847.cc | 12 +++++------- 5 files changed, 28 insertions(+), 43 deletions(-) diff --git a/backend/genesys_gl124.cc b/backend/genesys_gl124.cc index 1d70b30d6..845a5ccec 100644 --- a/backend/genesys_gl124.cc +++ b/backend/genesys_gl124.cc @@ -1089,8 +1089,6 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens } DBG (DBG_info, "gl124_init_scan_regs : stagger=%d lines\n", stagger); - unsigned used_res = session.params.xres; - /* compute scan parameters values */ /* pixels are allways given at full optical resolution */ /* use detected left margin and fixed value */ @@ -1113,7 +1111,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens } else { - exposure_time = get_sensor_profile(sensor, used_res, + exposure_time = get_sensor_profile(sensor, session.params.xres, session.ccd_size_divisor).exposure_lperiod; scan_step_type = sanei_genesys_compute_step_type(gl124_motor_profiles, dev->model->motor_type, exposure_time); @@ -1134,7 +1132,8 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens */ // now _LOGICAL_ optical values used are known, setup registers - gl124_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, used_res, start, + gl124_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres, + start, session.optical_pixels, session.params.channels, session.params.depth, session.ccd_size_divisor, session.params.color_filter); @@ -1164,7 +1163,7 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens /*** prepares data reordering ***/ /* words_per_line */ - bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution; + bytes_per_line = (session.optical_pixels * session.params.xres) / session.optical_resolution; bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8; /* since we don't have sheetfed scanners to handle, @@ -1194,11 +1193,11 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens dev->read_active = SANE_TRUE; dev->session = session; - dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution; + dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution; DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure_time; - dev->current_setup.xres = used_res; + dev->current_setup.xres = session.params.xres; dev->current_setup.ccd_size_divisor = session.ccd_size_divisor; dev->current_setup.stagger = stagger; dev->current_setup.max_shift = max_shift + stagger; @@ -1221,7 +1220,6 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso { int start; - int used_res; unsigned int lincnt; int exposure_time; int stagger; @@ -1253,8 +1251,6 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso gl124_compute_session(dev, session, sensor); - used_res = session.params.xres; - /* compute scan parameters values */ /* pixels are allways given at half or full CCD optical resolution */ /* use detected left margin and fixed value */ @@ -1270,7 +1266,7 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso session.params.yres, 0); // compute hw dpi for sensor - dpihw = sensor.get_register_hwdpi(used_res); + dpihw = sensor.get_register_hwdpi(session.params.xres); const SensorProfile& sensor_profile = get_sensor_profile(sensor, dpihw, session.ccd_size_divisor); @@ -1287,11 +1283,11 @@ gl124_calculate_current_setup (Genesys_Device * dev, const Genesys_Sensor& senso lincnt = session.params.lines + max_shift + stagger; dev->session = session; - dev->current_setup.pixels = (session.optical_pixels * used_res) / sensor.optical_res; + dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / sensor.optical_res; DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure_time; - dev->current_setup.xres = used_res; + dev->current_setup.xres = session.params.xres; dev->current_setup.ccd_size_divisor = session.ccd_size_divisor; dev->current_setup.stagger = stagger; dev->current_setup.max_shift = max_shift + stagger; diff --git a/backend/genesys_gl841.cc b/backend/genesys_gl841.cc index 2ed126477..2d9ecf9dd 100644 --- a/backend/genesys_gl841.cc +++ b/backend/genesys_gl841.cc @@ -1762,7 +1762,6 @@ static void gl841_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens DBG_HELPER(dbg); session.assert_computed(); - int used_res; int start; int bytes_per_line; int move; @@ -1814,8 +1813,6 @@ independent of our calculated values: } DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger); - used_res = session.params.xres; - gl841_assert_supported_resolution(session); /* compute scan parameters values */ @@ -1836,7 +1833,7 @@ independent of our calculated values: * scan, where shading data needs to be align */ if((dev->reg.find_reg(0x01).value & REG01_SHDAREA) != 0) { - avg = session.optical_resolution / used_res; + avg = session.optical_resolution / session.params.xres; start=(start/avg)*avg; } @@ -1898,7 +1895,7 @@ dummy \ scanned lines session.params.flags |= SCAN_FLAG_DISABLE_GAMMA; } - gl841_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, used_res, start, + gl841_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres, start, session.optical_pixels, session.params.channels, session.params.depth, session.ccd_size_divisor, session.params.color_filter); @@ -1941,7 +1938,7 @@ dummy \ scanned lines /*** prepares data reordering ***/ /* words_per_line */ - bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution; + bytes_per_line = (session.optical_pixels * session.params.xres) / session.optical_resolution; bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8; requested_buffer_size = 8 * bytes_per_line; @@ -1971,10 +1968,10 @@ dummy \ scanned lines dev->read_active = SANE_TRUE; dev->session = session; - dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution; + dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution; dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure_time; - dev->current_setup.xres = used_res; + dev->current_setup.xres = session.params.xres; dev->current_setup.ccd_size_divisor = session.ccd_size_divisor; dev->current_setup.stagger = stagger; dev->current_setup.max_shift = max_shift + stagger; @@ -2011,7 +2008,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se { int start; - int used_res; unsigned int lincnt; int exposure_time; int stagger; @@ -2057,7 +2053,6 @@ static void gl841_calculate_current_setup(Genesys_Device * dev, const Genesys_Se } DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger); - used_res = session.params.xres; gl841_assert_supported_resolution(session); /* compute scan parameters values */ @@ -2122,10 +2117,10 @@ dummy \ scanned lines lincnt = session.params.lines + max_shift + stagger; dev->session = session; - dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution; + dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution; dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure_time; - dev->current_setup.xres = used_res; + dev->current_setup.xres = session.params.xres; dev->current_setup.ccd_size_divisor = session.ccd_size_divisor; dev->current_setup.stagger = stagger; dev->current_setup.max_shift = max_shift + stagger; diff --git a/backend/genesys_gl843.cc b/backend/genesys_gl843.cc index d724c1a0b..f5a08f789 100644 --- a/backend/genesys_gl843.cc +++ b/backend/genesys_gl843.cc @@ -1436,8 +1436,6 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor } DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger); - int used_res = session.params.xres; - /* compute scan parameters values */ /* pixels are allways given at half or full CCD optical resolution */ /* use detected left margin and fixed value */ @@ -1468,11 +1466,11 @@ gl843_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor lincnt = session.params.lines + max_shift + stagger; dev->session = session; - dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution; + dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution; DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure; - dev->current_setup.xres = used_res; + dev->current_setup.xres = session.params.xres; dev->current_setup.ccd_size_divisor = session.ccd_size_divisor; dev->current_setup.stagger = stagger; dev->current_setup.max_shift = max_shift + stagger; diff --git a/backend/genesys_gl846.cc b/backend/genesys_gl846.cc index 42a0ce378..9938dfbf4 100644 --- a/backend/genesys_gl846.cc +++ b/backend/genesys_gl846.cc @@ -972,8 +972,6 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens } DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger); - unsigned used_res = session.params.xres; - /* compute scan parameters values */ /* pixels are allways given at full optical resolution */ /* use detected left margin and fixed value */ @@ -998,7 +996,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens slope_dpi = slope_dpi * (1 + dummy); - exposure_time = get_sensor_profile(sensor, used_res).exposure_lperiod; + exposure_time = get_sensor_profile(sensor, session.params.xres).exposure_lperiod; scan_step_type = sanei_genesys_compute_step_type(gl846_motor_profiles, dev->model->motor_type, exposure_time); @@ -1015,7 +1013,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens /* we enable true gray for cis scanners only, and just when doing * scan since color calibration is OK for this mode */ - gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, used_res, start, + gl846_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres, start, session.optical_pixels, session.params.channels, session.params.depth, session.params.color_filter); @@ -1046,7 +1044,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens /*** prepares data reordering ***/ /* words_per_line */ - bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution; + bytes_per_line = (session.optical_pixels * session.params.xres) / session.optical_resolution; bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8; requested_buffer_size = 8 * bytes_per_line; @@ -1073,10 +1071,10 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens dev->read_active = SANE_TRUE; dev->session = session; - dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution; + dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution; dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure_time; - dev->current_setup.xres = used_res; + dev->current_setup.xres = session.params.xres; dev->current_setup.ccd_size_divisor = session.ccd_size_divisor; dev->current_setup.stagger = stagger; dev->current_setup.max_shift = max_shift + stagger; diff --git a/backend/genesys_gl847.cc b/backend/genesys_gl847.cc index 77a8f569a..1b3b7ed6f 100644 --- a/backend/genesys_gl847.cc +++ b/backend/genesys_gl847.cc @@ -991,8 +991,6 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens } DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger); - unsigned used_res = session.params.xres; - /* compute scan parameters values */ /* pixels are allways given at full optical resolution */ /* use detected left margin and fixed value */ @@ -1017,7 +1015,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens slope_dpi = slope_dpi * (1 + dummy); - exposure_time = get_sensor_profile(sensor, used_res).exposure_lperiod; + exposure_time = get_sensor_profile(sensor, session.params.xres).exposure_lperiod; scan_step_type = sanei_genesys_compute_step_type(gl847_motor_profiles, dev->model->motor_type, exposure_time); @@ -1034,7 +1032,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens /* we enable true gray for cis scanners only, and just when doing * scan since color calibration is OK for this mode */ - gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, used_res, start, + gl847_init_optical_regs_scan(dev, sensor, reg, exposure_time, session, session.params.xres, start, session.optical_pixels, session.params.channels, session.params.depth, session.params.color_filter); @@ -1063,7 +1061,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens /*** prepares data reordering ***/ /* words_per_line */ - bytes_per_line = (session.optical_pixels * used_res) / session.optical_resolution; + bytes_per_line = (session.optical_pixels * session.params.xres) / session.optical_resolution; bytes_per_line = (bytes_per_line * session.params.channels * session.params.depth) / 8; requested_buffer_size = 8 * bytes_per_line; @@ -1090,10 +1088,10 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens dev->read_active = SANE_TRUE; dev->session = session; - dev->current_setup.pixels = (session.optical_pixels * used_res) / session.optical_resolution; + dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / session.optical_resolution; dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure_time; - dev->current_setup.xres = used_res; + dev->current_setup.xres = session.params.xres; dev->current_setup.ccd_size_divisor = session.ccd_size_divisor; dev->current_setup.stagger = stagger; dev->current_setup.max_shift = max_shift + stagger;