From c536f3cf7094a597fe389cfdb1acf2c7753522f2 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 18 May 2019 14:56:12 +0300 Subject: [PATCH] genesys: Fix calibration size calculation for 8600F The current approach of marking the scanner as GENESYS_FLAG_FULL_HWDPI_MODE is counter-productive, because only the register value is always full DPI, the actual resolution is different. For now, let's just work around this by having a special case for the scanner. --- backend/genesys_gl843.cc | 19 +++++++++++++++---- backend/genesys_low.cc | 23 +++++++++++++++++++++++ backend/genesys_low.h | 3 +++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/backend/genesys_gl843.cc b/backend/genesys_gl843.cc index 0f2b70d37..815a7682f 100644 --- a/backend/genesys_gl843.cc +++ b/backend/genesys_gl843.cc @@ -2999,7 +2999,7 @@ gl843_init_regs_for_shading (Genesys_Device * dev) dev->calib_lines = dev->model->shading_ta_lines; else dev->calib_lines = dev->model->shading_lines; - dpihw=sanei_genesys_compute_dpihw(dev,dev->settings.xres); + dpihw=sanei_genesys_compute_dpihw_calibration(dev,dev->settings.xres); factor=dev->sensor.optical_res/dpihw; resolution=dpihw; @@ -3455,7 +3455,7 @@ gl843_offset_calibration (Genesys_Device * dev) bpp = 8; /* compute divider factor to compute final pixels number */ - dpihw = sanei_genesys_compute_dpihw (dev, dev->settings.xres); + dpihw = sanei_genesys_compute_dpihw_calibration (dev, dev->settings.xres); factor = dev->sensor.optical_res / dpihw; resolution = dpihw; @@ -3663,7 +3663,7 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, int dpi) int bpp; DBG(DBG_proc, "%s: dpi = %d\n", __func__, dpi); - dpihw=sanei_genesys_compute_dpihw(dev, dpi); + dpihw=sanei_genesys_compute_dpihw_calibration(dev, dpi); factor=dev->sensor.optical_res/dpihw; /* coarse gain calibration is always done in color mode */ @@ -3848,7 +3848,8 @@ gl843_init_regs_for_warmup (Genesys_Device * dev, /* setup scan */ *channels=3; resolution=600; - dpihw=sanei_genesys_compute_dpihw(dev, resolution); + dpihw=sanei_genesys_compute_dpihw_calibration(dev, resolution); + resolution=dpihw; factor=dev->sensor.optical_res/dpihw; num_pixels=dev->sensor.sensor_pixels/(factor*2); *total_size = num_pixels * 3 * 1; @@ -4415,6 +4416,16 @@ gl843_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) strpixel*=tgtime; endpixel*=tgtime; + if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F && dev->current_setup.half_ccd) + { + int optical_res = dev->sensor.optical_res / 4; + int dpiset_real = dpiset / 4; + int half_ccd_factor = optical_res / + sanei_genesys_compute_dpihw_calibration(dev, dpiset_real); + strpixel /= half_ccd_factor; + endpixel /= half_ccd_factor; + } + /* 16 bit words, 2 words per color, 3 color channels */ offset=(strpixel-startx)*2*2*3; length=(endpixel-strpixel)*2*2*3; diff --git a/backend/genesys_low.cc b/backend/genesys_low.cc index 81e32e5b3..0b6266cc4 100644 --- a/backend/genesys_low.cc +++ b/backend/genesys_low.cc @@ -1787,6 +1787,29 @@ int sanei_genesys_compute_dpihw(Genesys_Device *dev, int xres) return dev->sensor.optical_res; } +// sanei_genesys_compute_dpihw returns the dpihw that is written to register. +// However the number of pixels depends on half_ccd mode +int sanei_genesys_compute_dpihw_calibration(Genesys_Device *dev, int xres) +{ + if (dev->model->model_id == MODEL_CANON_CANOSCAN_8600F) + { + // real resolution is half of the "official" resolution - half_ccd mode + int hwres = dev->sensor.optical_res / 4; + + if (xres <= hwres / 4) + { + return hwres / 4; + } + if (xres <= hwres / 2) + { + return hwres / 2; + } + return hwres; + } + + return sanei_genesys_compute_dpihw(dev, xres); +} + /** @brief motor profile * search for the database of motor profiles and get the best one. Each * profile is at full step and at a reference exposure. Use first entry diff --git a/backend/genesys_low.h b/backend/genesys_low.h index 84239e2d9..6ed4e6481 100644 --- a/backend/genesys_low.h +++ b/backend/genesys_low.h @@ -1267,6 +1267,9 @@ sanei_genesys_asic_init(Genesys_Device *dev, SANE_Bool cold); extern int sanei_genesys_compute_dpihw(Genesys_Device *dev, int xres); +extern +int sanei_genesys_compute_dpihw_calibration(Genesys_Device *dev, int xres); + extern Motor_Profile *sanei_genesys_get_motor_profile(Motor_Profile *motors, int motor_type, int exposure);