From 21254ad9297faca43a0ae5a083edd97a9da8ba08 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Thu, 12 Sep 2019 18:21:16 +0300 Subject: [PATCH] genesys: Use Sensor::optical_res directly where possible --- backend/genesys.cc | 8 +++----- backend/genesys_gl124.cc | 25 +++++++++---------------- backend/genesys_gl843.cc | 9 +++------ backend/genesys_gl846.cc | 21 ++++++++------------- backend/genesys_gl847.cc | 28 +++++++++------------------- 5 files changed, 32 insertions(+), 59 deletions(-) diff --git a/backend/genesys.cc b/backend/genesys.cc index 9ef9353de..5144bb911 100644 --- a/backend/genesys.cc +++ b/backend/genesys.cc @@ -2945,7 +2945,6 @@ static void genesys_sheetfed_calibration(Genesys_Device* dev, Genesys_Sensor& se { DBG_HELPER(dbg); SANE_Bool forward = SANE_TRUE; - int xres; if (dev->cmd_set->search_strip == nullptr) { throw SaneException(SANE_STATUS_UNSUPPORTED, "no strip searching function available"); @@ -2956,7 +2955,6 @@ static void genesys_sheetfed_calibration(Genesys_Device* dev, Genesys_Sensor& se /* led, offset and gain calibration are influenced by scan * settings. So we set it to sensor resolution */ - xres = sensor.optical_res; dev->settings.xres = sensor.optical_res; /* XP200 needs to calibrate a full and half sensor's resolution */ if (dev->model->ccd_type == CIS_XP200 @@ -2985,7 +2983,7 @@ static void genesys_sheetfed_calibration(Genesys_Device* dev, Genesys_Sensor& se /* since all the registers are set up correctly, just use them */ - dev->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, xres); + dev->cmd_set->coarse_gain_calibration(dev, sensor, dev->calib_reg, sensor.optical_res); } else /* since we have 2 gain calibration proc, skip second if first one was @@ -3066,8 +3064,8 @@ static void genesys_sheetfed_calibration(Genesys_Device* dev, Genesys_Sensor& se // and finally eject calibration sheet dev->cmd_set->eject_document(dev); - /* resotre settings */ - dev->settings.xres = xres; + // restore settings + dev->settings.xres = sensor.optical_res; } /** diff --git a/backend/genesys_gl124.cc b/backend/genesys_gl124.cc index d97136a48..efdaa8885 100644 --- a/backend/genesys_gl124.cc +++ b/backend/genesys_gl124.cc @@ -2313,7 +2313,7 @@ static void gl124_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& DBG_HELPER(dbg); unsigned int channels, bpp; int pass = 0, avg, total_size; - int topavg, bottomavg, resolution, lines; + int topavg, bottomavg, lines; int top, bottom, black_pixels, pixels; // no gain nor offset for TI AFE @@ -2325,17 +2325,16 @@ static void gl124_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& /* offset calibration is always done in color mode */ channels = 3; - resolution=sensor.optical_res; dev->calib_pixels = sensor.sensor_pixels; lines=1; bpp=8; - pixels= (sensor.sensor_pixels*resolution) / sensor.optical_res; - black_pixels = (sensor.black_pixels * resolution) / sensor.optical_res; + pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res; + black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res; DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); ScanSession session; - session.params.xres = resolution; - session.params.yres = resolution; + session.params.xres = sensor.optical_res; + session.params.yres = sensor.optical_res; session.params.startx = 0; session.params.starty = 0; session.params.pixels = pixels; @@ -2466,7 +2465,6 @@ static void gl124_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen int max[3]; float gain[3],coeff; int val, code, lines; - int resolution; int bpp; // no gain nor offset for TI AFE @@ -2482,21 +2480,16 @@ static void gl124_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen if(dev->settings.xressettings.scan_method); - num_pixels = - (calib_sensor.sensor_pixels * used_res) / calib_sensor.optical_res; + num_pixels = (calib_sensor.sensor_pixels * calib_sensor.optical_res) / calib_sensor.optical_res; /* initial calibration reg values */ regs = dev->reg; ScanSession session; - session.params.xres = used_res; + session.params.xres = calib_sensor.sensor_pixels; session.params.yres = dev->motor.base_ydpi; session.params.startx = 0; session.params.starty = 0; diff --git a/backend/genesys_gl846.cc b/backend/genesys_gl846.cc index eacd57563..6459950c1 100644 --- a/backend/genesys_gl846.cc +++ b/backend/genesys_gl846.cc @@ -2399,7 +2399,7 @@ static void gl846_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& DBG_HELPER(dbg); unsigned int channels, bpp; int pass = 0, avg, total_size; - int topavg, bottomavg, resolution, lines; + int topavg, bottomavg, lines; int top, bottom, black_pixels, pixels; // no gain nor offset for AKM AFE @@ -2411,17 +2411,16 @@ static void gl846_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& /* offset calibration is always done in color mode */ channels = 3; - resolution=sensor.optical_res; dev->calib_pixels = sensor.sensor_pixels; lines=1; bpp=8; - pixels= (sensor.sensor_pixels*resolution) / sensor.optical_res; - black_pixels = (sensor.black_pixels * resolution) / sensor.optical_res; + pixels = (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res; + black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res; DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); ScanSession session; - session.params.xres = resolution; - session.params.yres = resolution; + session.params.xres = sensor.optical_res; + session.params.yres = sensor.optical_res; session.params.startx = 0; session.params.starty = 0; session.params.pixels = pixels; @@ -2542,7 +2541,6 @@ static void gl846_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen int max[3]; float gain[3],coeff; int val, code, lines; - int resolution; int bpp; DBG(DBG_proc, "%s: dpi = %d\n", __func__, dpi); @@ -2561,21 +2559,18 @@ static void gl846_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen if(dev->settings.xressettings); @@ -1153,9 +1151,6 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor gl847_compute_session(dev, session, sensor); - /* optical_res */ - optical_res = sensor.optical_res; - /* compute scan parameters values */ /* pixels are allways given at half or full CCD optical resolution */ /* use detected left margin and fixed value */ @@ -1182,7 +1177,7 @@ gl847_calculate_current_setup(Genesys_Device * dev, const Genesys_Sensor& sensor lincnt = session.params.lines + max_shift + session.num_staggered_lines; dev->session = session; - dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / optical_res; + dev->current_setup.pixels = (session.optical_pixels * session.params.xres) / sensor.optical_res; dev->current_setup.lines = lincnt; dev->current_setup.exposure_time = exposure_time; dev->current_setup.xres = session.params.xres; @@ -2498,7 +2493,7 @@ static void gl847_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& DBG_HELPER(dbg); unsigned int channels, bpp; int pass = 0, avg, total_size; - int topavg, bottomavg, resolution, lines; + int topavg, bottomavg, lines; int top, bottom, black_pixels, pixels; // no gain nor offset for AKM AFE @@ -2510,17 +2505,16 @@ static void gl847_offset_calibration(Genesys_Device* dev, const Genesys_Sensor& /* offset calibration is always done in color mode */ channels = 3; - resolution=sensor.optical_res; dev->calib_pixels = sensor.sensor_pixels; lines=1; bpp=8; - pixels= (sensor.sensor_pixels*resolution) / sensor.optical_res; - black_pixels = (sensor.black_pixels * resolution) / sensor.optical_res; + pixels= (sensor.sensor_pixels * sensor.optical_res) / sensor.optical_res; + black_pixels = (sensor.black_pixels * sensor.optical_res) / sensor.optical_res; DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); ScanSession session; - session.params.xres = resolution; - session.params.yres = resolution; + session.params.xres = sensor.optical_res; + session.params.yres = sensor.optical_res; session.params.startx = 0; session.params.starty = 0; session.params.pixels = pixels; @@ -2641,7 +2635,6 @@ static void gl847_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen int max[3]; float gain[3],coeff; int val, code, lines; - int resolution; int bpp; // no gain nor offset for AKM AFE @@ -2658,21 +2651,18 @@ static void gl847_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen if(dev->settings.xres