From 1c3ec28ab8951afe07f2b61d53eae56239ea9a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Voltz?= Date: Wed, 17 Jul 2013 21:24:57 +0200 Subject: [PATCH] improve below 600 dpi scan speed and quality for lide 210 - add half ccd mode for lide 210 --- backend/genesys.c | 7 +- backend/genesys_devices.c | 8 +- backend/genesys_gl124.c | 171 +++++++++++++++++++++++++------------- backend/genesys_gl124.h | 52 +++++++----- backend/genesys_low.c | 15 ++++ 5 files changed, 163 insertions(+), 90 deletions(-) diff --git a/backend/genesys.c b/backend/genesys.c index b771dfc22..082f5f33c 100644 --- a/backend/genesys.c +++ b/backend/genesys.c @@ -3115,8 +3115,7 @@ genesys_restore_calibration (Genesys_Device * dev) * matching one */ for (cache = dev->calibration_cache; cache; cache = cache->next) { - status = dev->model->cmd_set->is_compatible_calibration (dev, cache, - SANE_FALSE); + status = dev->model->cmd_set->is_compatible_calibration (dev, cache, SANE_FALSE); /* SANE_STATUS_GOOD, a matching cache has been found * so we use it to populate calibration data */ @@ -7053,9 +7052,7 @@ get_option_value (Genesys_Scanner * s, int option, void *val) for (cache = s->dev->calibration_cache; cache; cache = cache->next) { if (s->dev->model-> - cmd_set->is_compatible_calibration (s->dev, cache, - SANE_FALSE) == - SANE_STATUS_GOOD) + cmd_set->is_compatible_calibration (s->dev, cache, SANE_FALSE) == SANE_STATUS_GOOD) { *(SANE_Bool *) val = SANE_FALSE; } diff --git a/backend/genesys_devices.c b/backend/genesys_devices.c index d7960ff10..0a691bbb6 100644 --- a/backend/genesys_devices.c +++ b/backend/genesys_devices.c @@ -1826,9 +1826,9 @@ static Genesys_Model canon_lide_210_model = { {16, 8, 0}, /* possible depths in color mode */ SANE_FIX (2.2), /* Start of scan area in mm (x) */ - SANE_FIX (9.0), /* Start of scan area in mm (y) */ + SANE_FIX (8.7), /* Start of scan area in mm (y) */ SANE_FIX (216.70), /* Size of scan area in mm (x) */ - SANE_FIX (300.0), /* Size of scan area in mm (y) */ + SANE_FIX (297.5), /* Size of scan area in mm (y) */ SANE_FIX (0.0), /* Start of white strip in mm (y) */ SANE_FIX (0.0), /* Start of black mark in mm (x) */ @@ -1858,9 +1858,11 @@ static Genesys_Model canon_lide_210_model = { GENESYS_FLAG_SKIP_WARMUP | GENESYS_FLAG_OFFSET_CALIBRATION | GENESYS_FLAG_DARK_CALIBRATION + | GENESYS_FLAG_HALF_CCD_MODE + | GENESYS_FLAG_SHADING_REPARK | GENESYS_FLAG_CUSTOM_GAMMA, GENESYS_HAS_SCAN_SW | GENESYS_HAS_COPY_SW | GENESYS_HAS_EMAIL_SW | GENESYS_HAS_FILE_SW | GENESYS_HAS_EXTRA_SW, - 50, + 60, 400 }; diff --git a/backend/genesys_gl124.c b/backend/genesys_gl124.c index 566ed187e..77a916f4b 100644 --- a/backend/genesys_gl124.c +++ b/backend/genesys_gl124.c @@ -251,9 +251,10 @@ gl124_test_motor_flag_bit (SANE_Byte val) * profile is at a specific dpihw. Use LiDE 110 table by default. * @param sensor_type sensor id * @param dpi hardware dpi for the scan + * @param half_ccd flag to signal half ccd mode * @return a pointer to a Sensor_Profile struct */ -static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi) +static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi, int half_ccd) { unsigned int i; int idx; @@ -263,13 +264,16 @@ static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi) while(iflags & GENESYS_FLAG_HALF_CCD_MODE)) + { + return SANE_TRUE; + } + return SANE_FALSE; +} + /** @brief set all registers to default values . * This function is called only once at the beginning and * fills register startup values for registers reused across scans. @@ -862,6 +883,11 @@ gl124_set_fe (Genesys_Device * dev, uint8_t set) RIE (sanei_genesys_read_register (dev, REG0A, &val)); + if(dev->usb_mode<0) + { + val=3<>REG0AS_SIFSEL) { @@ -884,12 +910,15 @@ gl124_set_fe (Genesys_Device * dev, uint8_t set) /**@brief compute exposure to use * compute the sensor exposure based on target resolution + * @param dev pointer to device description + * @param xres sensor's required resolution + * @param half_ccd flag for half ccd mode */ -static int gl124_compute_exposure(Genesys_Device *dev, int xres) +static int gl124_compute_exposure(Genesys_Device *dev, int xres, int half_ccd) { Sensor_Profile *sensor; - sensor=get_sensor_profile(dev->model->ccd_type, xres); + sensor=get_sensor_profile(dev->model->ccd_type, xres, half_ccd); return sensor->exposure; } @@ -934,6 +963,7 @@ gl124_init_motor_regs_scan (Genesys_Device * dev, Genesys_Register_Set *r; uint32_t z1, z2; float yres; + unsigned int linesel; DBGSTART; DBG (DBG_info, "gl124_init_motor_regs_scan : scan_exposure_time=%d, " @@ -967,8 +997,9 @@ gl124_init_motor_regs_scan (Genesys_Device * dev, { yres=300; } - scan_dummy=dev->line_interp; + linesel=dev->line_interp; dev->line_interp=0; + DBG (DBG_io2, "%s: linesel=%d\n", __FUNCTION__, linesel); sanei_genesys_set_triple(reg,REG_LINCNT,lincnt); DBG (DBG_io, "%s: lincnt=%d\n", __FUNCTION__, lincnt); @@ -1074,7 +1105,7 @@ gl124_init_motor_regs_scan (Genesys_Device * dev, /* LINESEL */ r = sanei_genesys_get_address (reg, REG1D); - r->value = (r->value & ~REG1D_LINESEL) | scan_dummy; + r->value = (r->value & ~REG1D_LINESEL) | linesel; r = sanei_genesys_get_address (reg, REGA0); r->value = (scan_step_type << REGA0S_STEPSEL) | (scan_step_type << REGA0S_FSTPSEL); @@ -1092,9 +1123,10 @@ gl124_init_motor_regs_scan (Genesys_Device * dev, * @param dev device to set up * @param regs register set to modify * @param dpi resolution of the sensor during scan + * @param half_ccd flag for half ccd mode * */ static void -gl124_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs, int dpi) +gl124_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs, int dpi, int half_ccd) { Genesys_Register_Set *r; int i; @@ -1121,7 +1153,7 @@ gl124_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs, int dpi) /* set EXPDUMMY and CKxMAP */ dpihw=sanei_genesys_compute_dpihw(dev,dpi); - sensor=get_sensor_profile(dev->model->ccd_type, dpihw); + sensor=get_sensor_profile(dev->model->ccd_type, dpihw, half_ccd); r = sanei_genesys_get_address (regs, 0x18); if (r) @@ -1235,7 +1267,7 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __FUNCTION__, dpihw, factor); /* sensor parameters */ - gl124_setup_sensor (dev, reg, dpihw); + gl124_setup_sensor (dev, reg, dpihw, half_ccd); dpiset = used_res * cksel; /* start and end coordinate in optical dpi coordinates */ @@ -1344,8 +1376,16 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, else r->value |= REG05_GMMENB; - sanei_genesys_set_double(reg,REG_DPISET,dpiset); - DBG (DBG_io2, "%s: dpiset used=%d\n", __FUNCTION__, dpiset); + if(half_ccd) + { + sanei_genesys_set_double(reg,REG_DPISET,dpiset*2); + DBG (DBG_io2, "%s: dpiset used=%d\n", __FUNCTION__, dpiset*2); + } + else + { + sanei_genesys_set_double(reg,REG_DPISET,dpiset); + DBG (DBG_io2, "%s: dpiset used=%d\n", __FUNCTION__, dpiset); + } r = sanei_genesys_get_address (reg, REG06); r->value |= REG06_GAIN4; @@ -1355,12 +1395,14 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, segnb = r->value & 0x0f; sanei_genesys_set_triple(reg,REG_STRPIXEL,startx/segnb); + DBG (DBG_io2, "%s: strpixel used=%d\n", __FUNCTION__, startx/segnb); sanei_genesys_get_triple(reg,REG_SEGCNT,&segcnt); if(endx/segnb==segcnt) { endx=0; } sanei_genesys_set_triple(reg,REG_ENDPIXEL,endx/segnb); + DBG (DBG_io2, "%s: endpixel used=%d\n", __FUNCTION__, endx/segnb); /* words(16bit) before gamma, conversion to 8 bit or lineart */ words_per_line = (used_pixels * dpiset) / dpihw; @@ -1388,7 +1430,7 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, else { /* line interpolation, we are scanning at higher - * motor dpi then discard lines to match taget + * motor dpi then discard lines to match target * resolution, so lincnt has to be updated */ dev->line_interp = 300/dpiset-1; @@ -1400,7 +1442,7 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, DBG (DBG_io2, "%s: dev->bpl =%lu\n", __FUNCTION__, (unsigned long)dev->bpl); DBG (DBG_io2, "%s: dev->len =%lu\n", __FUNCTION__, (unsigned long)dev->len); DBG (DBG_io2, "%s: dev->dist =%lu\n", __FUNCTION__, (unsigned long)dev->dist); - DBG (DBG_io2, "%s: dev->line_interp=%lu\n", __FUNCTION__, (unsigned long)dev->dist); + DBG (DBG_io2, "%s: dev->line_interp=%lu\n", __FUNCTION__, (unsigned long)dev->line_interp); words_per_line *= channels; dev->wpl = words_per_line; @@ -1475,21 +1517,13 @@ gl124_init_scan_regs (Genesys_Device * dev, "Flags : %x\n\n", xres, yres, lines, pixels, startx, starty, depth, channels, flags); - /* we have 2 domains for ccd: xres below or above half ccd max dpi */ - if (dev->sensor.optical_res < 2 * xres || - !(dev->model->flags & GENESYS_FLAG_HALF_CCD_MODE)) - { - half_ccd = SANE_FALSE; - } - else - { - half_ccd = SANE_TRUE; - } + half_ccd=compute_half_ccd(dev->model, xres); /* optical_res */ optical_res = dev->sensor.optical_res; if (half_ccd) optical_res /= 2; + DBG (DBG_info, "%s: optical_res=%d\n", __FUNCTION__, optical_res); /* stagger */ if ((!half_ccd) && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) @@ -1550,7 +1584,7 @@ gl124_init_scan_regs (Genesys_Device * dev, } else { - exposure_time = gl124_compute_exposure (dev, used_res); + exposure_time = gl124_compute_exposure (dev, used_res, half_ccd); scan_step_type = gl124_compute_step_type(dev, exposure_time); } @@ -1711,11 +1745,11 @@ gl124_calculate_current_setup (Genesys_Device * dev) unsigned int lincnt; int exposure_time; int stagger; + SANE_Bool half_ccd; int max_shift, dpihw; Sensor_Profile *sensor; - SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */ int optical_res; DBG (DBG_info, @@ -1752,6 +1786,7 @@ gl124_calculate_current_setup (Genesys_Device * dev) pixels = dev->settings.pixels; lines = dev->settings.lines; + half_ccd=compute_half_ccd(dev->model, xres); DBG (DBG_info, "gl124_calculate_current_setup settings:\n" @@ -1759,33 +1794,12 @@ gl124_calculate_current_setup (Genesys_Device * dev) "Lines : %g\n" "PPL : %g\n" "Startpos : %g\n" + "Half ccd : %d\n" "Depth/Channels: %u/%u\n\n", - xres, yres, lines, pixels, startx, depth, channels); - -/* half_ccd */ - /* we have 2 domains for ccd: xres below or above half ccd max dpi */ - if ((dev->sensor.optical_res < 2 * xres) || - !(dev->model->flags & GENESYS_FLAG_HALF_CCD_MODE)) - { - half_ccd = SANE_FALSE; - } - else - { - half_ccd = SANE_TRUE; - } - + xres, yres, lines, pixels, startx, depth, half_ccd, channels); /* optical_res */ optical_res = dev->sensor.optical_res; - if (half_ccd) - optical_res /= 2; - - /* stagger */ - if ((!half_ccd) && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) - stagger = (4 * yres) / dev->motor.base_ydpi; - else - stagger = 0; - DBG (DBG_info, "%s: stagger=%d lines\n", __FUNCTION__, stagger); if(xres<=optical_res) used_res = xres; @@ -1801,16 +1815,25 @@ gl124_calculate_current_setup (Genesys_Device * dev) DBG (DBG_info, "%s: used_pixels=%d\n", __FUNCTION__, used_pixels); /* exposure */ - exposure_time = gl124_compute_exposure (dev, xres); + exposure_time = gl124_compute_exposure (dev, xres, half_ccd); DBG (DBG_info, "%s : exposure_time=%d pixels\n", __FUNCTION__, exposure_time); /* max_shift */ max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0); - + + /* compute hw dpi for sensor */ dpihw=sanei_genesys_compute_dpihw(dev,used_res); - sensor=get_sensor_profile(dev->model->ccd_type, dpihw); + + sensor=get_sensor_profile(dev->model->ccd_type, dpihw, half_ccd); dev->segnb=sensor->reg98 & 0x0f; + /* stagger */ + if ((!half_ccd) && (dev->model->flags & GENESYS_FLAG_STAGGERED_LINE)) + stagger = (4 * yres) / dev->motor.base_ydpi; + else + stagger = 0; + DBG (DBG_info, "%s: stagger=%d lines\n", __FUNCTION__, stagger); + /* lincnt */ lincnt = lines + max_shift + stagger; @@ -2131,6 +2154,12 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) DBG (DBG_proc, "gl124_slow_back_home (wait_until_home = %d)\n", wait_until_home); + if(dev->usb_mode<0) + { + DBGCOMPLETED; + return SANE_STATUS_GOOD; + } + /* post scan gpio : without that HOMSNR is unreliable */ gl124_homsnr_gpio(dev); @@ -2177,7 +2206,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* TODO add scan_mode to the API */ scan_mode= dev->settings.scan_mode; - dev->settings.scan_mode=SCAN_MODE_LINEART; + dev->settings.scan_mode=SCAN_MODE_GRAY; gl124_init_scan_regs (dev, local_reg, resolution, @@ -2538,9 +2567,16 @@ gl124_init_regs_for_shading (Genesys_Device * dev) { dev->calib_lines *= 2; } - factor=dev->sensor.optical_res/dpihw; resolution=dpihw; + + /* if half CCD mode, use half resolution */ + if(compute_half_ccd(dev->model, dev->settings.xres)==SANE_TRUE) + { + resolution /= 2; + dev->calib_lines /= 2; + } dev->calib_resolution = resolution; + factor=dev->sensor.optical_res/resolution; dev->calib_pixels = dev->sensor.sensor_pixels/factor; /* distance to move to reach white target at high resolution */ @@ -2691,6 +2727,10 @@ gl124_init_regs_for_scan (Genesys_Device * dev) /* start */ start = SANE_UNFIX (dev->model->x_offset); start += dev->settings.tl_x; + if(compute_half_ccd(dev->model, dev->settings.xres)==SANE_TRUE) + { + start /=2; + } start = (start * dev->sensor.optical_res) / MM_PER_INCH; flags = 0; @@ -2933,7 +2973,8 @@ gl124_led_calibration (Genesys_Device * dev) { int num_pixels; int total_size; - int used_res; + int resolution; + int dpihw; uint8_t *line; int i, j; SANE_Status status = SANE_STATUS_GOOD; @@ -2945,6 +2986,7 @@ gl124_led_calibration (Genesys_Device * dev) uint16_t exp[3],target; Sensor_Profile *sensor; SANE_Bool acceptable; + SANE_Bool half_ccd; DBGSTART; @@ -2954,9 +2996,18 @@ gl124_led_calibration (Genesys_Device * dev) /* offset calibration is always done in 16 bit depth color mode */ channels = 3; depth=16; - used_res=sanei_genesys_compute_dpihw(dev,dev->settings.xres); - sensor=get_sensor_profile(dev->model->ccd_type, used_res); - num_pixels = (dev->sensor.sensor_pixels*used_res)/dev->sensor.optical_res; + dpihw=sanei_genesys_compute_dpihw(dev, dev->settings.xres); + half_ccd=compute_half_ccd(dev->model, dev->settings.xres); + if(half_ccd==SANE_TRUE) + { + resolution = dpihw/2; + } + else + { + resolution = dpihw; + } + sensor=get_sensor_profile(dev->model->ccd_type, dpihw, half_ccd); + num_pixels = (dev->sensor.sensor_pixels*resolution)/dev->sensor.optical_res; /* initial calibration reg values */ memcpy (dev->calib_reg, dev->reg, GENESYS_GL124_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -2964,8 +3015,8 @@ gl124_led_calibration (Genesys_Device * dev) /* set up for the calibration scan */ status = gl124_init_scan_regs (dev, dev->calib_reg, - used_res, - used_res, + resolution, + resolution, 0, 0, num_pixels, diff --git a/backend/genesys_gl124.h b/backend/genesys_gl124.h index 8541b0338..7c48809ff 100644 --- a/backend/genesys_gl124.h +++ b/backend/genesys_gl124.h @@ -565,11 +565,15 @@ static Memory_layout layouts[]={ /** @brief structure for sensor settings * this structure describes the sensor settings to use for a given - * exposure. + * exposure. Data settings are identified by + * - sensor id + * - sensor hardware dpi + * - half ccd mode */ typedef struct { int sensor_type; /**> sensor id */ int dpi; /**> maximum dpi for which data are valid */ + int half_ccd; /**> half ccd mode */ int exposure; /**> exposure */ int ck1map; /**> CK1MAP */ int ck3map; /**> CK2MAP */ @@ -596,28 +600,28 @@ static size_t order_0213[]={0,2,1,3}; * database of sensor profiles */ static Sensor_Profile sensors[]={ - {CIS_CANONLIDE110, 300, 5359, 0x1e, 0x9f, 0x55, 5168, 154, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21}, - {CIS_CANONLIDE110, 600, 5360, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21}, - {CIS_CANONLIDE110, 1200, 10528, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, order_01 , 0x00, 0x08, 0x20, 0x22}, - {CIS_CANONLIDE110, 2400, 20864, 0x1e, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, order_0213, 0x00, 0x06, 0x20, 0x24}, - {CIS_CANONLIDE210, 300, 5359, 0x1e, 0x9f, 0x55, 5168, 154, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21}, - {CIS_CANONLIDE210, 600, 5360, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21}, - {CIS_CANONLIDE210, 1200, 10528, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, order_01 , 0x00, 0x08, 0x20, 0x22}, - {CIS_CANONLIDE210, 2400, 20864, 0x1e, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, order_0213, 0x00, 0x06, 0x20, 0x24}, + {CIS_CANONLIDE110, 300, 0, 5359, 0x1e, 0x9f, 0x55, 5168, 154, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21}, + {CIS_CANONLIDE110, 600, 0, 5360, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21}, + {CIS_CANONLIDE110, 1200, 0, 10528, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, order_01 , 0x00, 0x08, 0x20, 0x22}, + {CIS_CANONLIDE110, 2400, 0, 20864, 0x1e, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, order_0213, 0x00, 0x06, 0x20, 0x24}, + {CIS_CANONLIDE210, 600, 1, 2768, 0x1e, 0x9f, 0x55, 2584, 154, 101, 388, 574, 393, NULL , 0x00, 0x0c, 0x20, 0x21}, + {CIS_CANONLIDE210, 600, 0, 5360, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, NULL , 0x00, 0x0a, 0x20, 0x21}, + {CIS_CANONLIDE210, 1200, 0, 10528, 0x1e, 0x9f, 0x55, 5168, 163, 101, 388, 574, 393, order_01 , 0x00, 0x08, 0x20, 0x22}, + {CIS_CANONLIDE210, 2400, 0, 20864, 0x1e, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, order_0213, 0x00, 0x06, 0x20, 0x24}, }; #define MOVE_DPI 200 #define MOVE_EXPOSURE 2304 -static uint32_t lide110_max[] = { 62496, 31296,0}; -static uint32_t lide110_slow[] = { 62496, 7896,0}; +static uint32_t lide110_max[] = { 62496, 31296, 0}; +static uint32_t lide110_slow[] = { 62496, 7896, 0}; static uint32_t lide110_alt[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2051, 1432, 1372, 1323, 1280, 1246, 1216, 1188, 1163, 1142, 1121, 1101, 1084, 1068, 1051, 1036, 1020, 1007, 995, 983, 971, 959, 949, 938, 929, 917, 908, 900, 891, 882, 874, 866, 857, 849, 843, 835, 829, 821, 816, 808, 802, 795, 789, 784, 778, 773, 765, 760, 755, 749, 744, 739, 734, 731, 726, 721, 716, 711, 707, 702, 698, 693, 690, 685, 682, 677, 672, 669, 665, 662, 657, 654, 650, 647, 644, 639, 637, 632, 629, 626, 622, 619, 617, 614, 610, 607, 604, 601, 599, 595, 592, 589, 587, 584, 581, 579, 576, 572, 570, 567, 564, 562, 559, 557, 554, 552, 549, 547, 544, 542, 539, 538, 536, 533, 531, 529, 526, 524, 522, 519, 518, 516, 513, 511, 509, 506, 505, 503, 501, 498, 497, 495, 493, 491, 490, 487, 485, 483, 482, 480, 477, 476, 474, 472, 470, 469, 467, 465, 464, 462, 460, 458, 456, 455, 453, 451, 450, 448, 447, 445, 444, 442, 440, 439, 437, 436, 434, 433, 431, 430, 428, 427, 425, 423, 422, 420, 419, 417, 417, 415, 414, 413, 411, 410, 408, 407, 405, 404, 402, 401, 400, 399, 398, 396, 395, 393, 392, 391, 390, 389, 387, 386, 385, 383, 382, 381, 380, 379, 377, 376, 375, 374, 373, 371, 370, 369, 368, 367, 366, 364, 363, 363, 361, 360, 359, 358, 357, 356, 355, 353, 352, 352, 350, 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, 335, 335, 0}; -static uint32_t lide110_ok[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343,2343,2343,2051,1961,1901,1852,1809,1775,1745,1717,1692,1671,1650,1630,1613,1597,1580,1565,1549,1536,1524,1512,1500,1488,1478,1467,1458,1446,1437,1429,1420,1411,1403,1395,1386,1378,1372,1364,1358,1350,1345,1337,1331,1324,1318,1313,1307,1302,1294,1289,1284,1278,1273,1268,1263,1260,1255,1250,1245,1240,1236,1231,1227,1222,1219,1214,1211,1206,1201,1198,1194,1191,1186,1183,1179,1176,1173,1168,1166,1161,1158,1155,1151,1148,1146,1143,1139,1136,1133,1130,1128,1124,1121,1118,1116,1113,1110,1108,1105,1101,1099,1096,1093,1091,1088,1086,1083,1081,1078,1076,1073,1071,1068,1067,1065,1062,1060,1058,1055,1053,1051,1048,1047,1045,1042,1040,1038,1035,1034,1032,1030,1027,1026,1024,1022,1020,1019,1016,1014,1012,1011,1009,1006,1005,1003,1001,999,998,996,994,993,991,989,987,985,984,982,980,979,977,976,974,973,971,969,968,966,965,963,962,960,959,957,956,954,952,951,949,948,946,946,944,943,942,940,939,937,936,934,933,931,930,929,928,927,925,924,922,921,920,919,918,916,915,914,912,911,910,909,908,906,905,904,903,902,900,899,898,897,896,895,893,892,892,890,889,888,887,886,885,884,882,881,881,879,878,877,876,875,874,873,872,871,870,869,868,867,864,864, 0}; -static uint32_t lide210_max[] = { 62496, 31296,0}; -static uint32_t lide210_slow[] = { 62496, 7896,0}; -static uint32_t lide210_alt[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2051, 1432, 1372, 1323, 1280, 1246, 1216, 1188, 1163, 1142, 1121, 1101, 1084, 1068, 1051, 1036, 1020, 1007, 995, 983, 971, 959, 949, 938, 929, 917, 908, 900, 891, 882, 874, 866, 857, 849, 843, 835, 829, 821, 816, 808, 802, 795, 789, 784, 778, 773, 765, 760, 755, 749, 744, 739, 734, 731, 726, 721, 716, 711, 707, 702, 698, 693, 690, 685, 682, 677, 672, 669, 665, 662, 657, 654, 650, 647, 644, 639, 637, 632, 629, 626, 622, 619, 617, 614, 610, 607, 604, 601, 599, 595, 592, 589, 587, 584, 581, 579, 576, 572, 570, 567, 564, 562, 559, 557, 554, 552, 549, 547, 544, 542, 539, 538, 536, 533, 531, 529, 526, 524, 522, 519, 518, 516, 513, 511, 509, 506, 505, 503, 501, 498, 497, 495, 493, 491, 490, 487, 485, 483, 482, 480, 477, 476, 474, 472, 470, 469, 467, 465, 464, 462, 460, 458, 456, 455, 453, 451, 450, 448, 447, 445, 444, 442, 440, 439, 437, 436, 434, 433, 431, 430, 428, 427, 425, 423, 422, 420, 419, 417, 417, 415, 414, 413, 411, 410, 408, 407, 405, 404, 402, 401, 400, 399, 398, 396, 395, 393, 392, 391, 390, 389, 387, 386, 385, 383, 382, 381, 380, 379, 377, 376, 375, 374, 373, 371, 370, 369, 368, 367, 366, 364, 363, 363, 361, 360, 359, 358, 357, 356, 355, 353, 352, 352, 350, 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, 335, 335, 0}; -static uint32_t lide210_ok[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343,2343,2343,2051,1961,1901,1852,1809,1775,1745,1717,1692,1671,1650,1630,1613,1597,1580,1565,1549,1536,1524,1512,1500,1488,1478,1467,1458,1446,1437,1429,1420,1411,1403,1395,1386,1378,1372,1364,1358,1350,1345,1337,1331,1324,1318,1313,1307,1302,1294,1289,1284,1278,1273,1268,1263,1260,1255,1250,1245,1240,1236,1231,1227,1222,1219,1214,1211,1206,1201,1198,1194,1191,1186,1183,1179,1176,1173,1168,1166,1161,1158,1155,1151,1148,1146,1143,1139,1136,1133,1130,1128,1124,1121,1118,1116,1113,1110,1108,1105,1101,1099,1096,1093,1091,1088,1086,1083,1081,1078,1076,1073,1071,1068,1067,1065,1062,1060,1058,1055,1053,1051,1048,1047,1045,1042,1040,1038,1035,1034,1032,1030,1027,1026,1024,1022,1020,1019,1016,1014,1012,1011,1009,1006,1005,1003,1001,999,998,996,994,993,991,989,987,985,984,982,980,979,977,976,974,973,971,969,968,966,965,963,962,960,959,957,956,954,952,951,949,948,946,946,944,943,942,940,939,937,936,934,933,931,930,929,928,927,925,924,922,921,920,919,918,916,915,914,912,911,910,909,908,906,905,904,903,902,900,899,898,897,896,895,893,892,892,890,889,888,887,886,885,884,882,881,881,879,878,877,876,875,874,873,872,871,870,869,868,867,864,864, 0}; + +static uint32_t lide210_max[] = { 62496, 31296, 0}; +static uint32_t lide210_slow[] = { 62496, 7896, 0}; +static uint32_t lide210_fast[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2051, 1432, 1372, 1323, 1280, 1246, 1216, 1188, 1163, 1142, 1121, 1101, 1084, 1068, 1051, 1036, 1020, 1007, 995, 983, 971, 959, 949, 938, 929, 917, 908, 900, 891, 882, 874, 866, 857, 849, 843, 835, 829, 821, 816, 808, 802, 795, 789, 784, 778, 773, 765, 760, 755, 749, 744, 739, 734, 731, 726, 721, 716, 711, 707, 702, 698, 693, 690, 685, 682, 677, 672, 669, 665, 662, 657, 654, 650, 647, 644, 639, 637, 632, 629, 626, 622, 619, 617, 614, 610, 607, 604, 601, 599, 595, 592, 589, 587, 584, 581, 579, 576, 572, 570, 567, 564, 562, 559, 557, 554, 552, 549, 547, 544, 542, 539, 538, 536, 533, 531, 529, 526, 524, 522, 519, 518, 516, 513, 511, 509, 506, 505, 503, 501, 498, 497, 495, 493, 491, 490, 487, 485, 483, 482, 480, 477, 476, 474, 472, 470, 469, 467, 465, 464, 462, 460, 458, 456, 455, 453, 451, 450, 448, 447, 445, 444, 442, 440, 439, 437, 436, 434, 433, 431, 430, 428, 427, 425, 423, 422, 420, 419, 417, 417, 415, 414, 413, 411, 410, 408, 407, 405, 404, 402, 401, 400, 399, 398, 396, 395, 393, 392, 391, 390, 389, 387, 386, 385, 383, 382, 381, 380, 379, 377, 376, 375, 374, 373, 371, 370, 369, 368, 367, 366, 364, 363, 363, 361, 360, 359, 358, 357, 356, 355, 353, 352, 352, 350, 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, 335, 335, 0}; +static uint32_t lide210_ok[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2051, 1961, 1901, 1852, 1809, 1775, 1745, 1717, 1692, 1671, 1650, 1630, 1613, 1597,1580,1565,1549,1536,1524,1512,1500,1488,1478,1467,1458,1446,1437,1429,1420,1411,1403,1395,1386,1378,1372,1364,1358,1350,1345,1337,1331,1324,1318,1313,1307,1302,1294,1289,1284,1278,1273,1268,1263,1260,1255,1250,1245,1240,1236,1231,1227,1222,1219,1214,1211,1206,1201,1198,1194,1191,1186,1183,1179,1176,1173,1168,1166,1161,1158,1155,1151,1148,1146,1143,1139,1136,1133,1130,1128,1124,1121,1118,1116,1113,1110,1108,1105,1101,1099,1096,1093,1091,1088,1086,1083,1081,1078,1076,1073,1071,1068,1067,1065,1062,1060,1058,1055,1053,1051,1048,1047,1045,1042,1040,1038,1035,1034,1032,1030,1027,1026,1024,1022,1020,1019,1016,1014,1012,1011,1009,1006,1005,1003,1001,999,998,996,994,993,991,989,987,985,984,982,980,979,977,976,974,973,971,969,968,966,965,963,962,960,959,957,956,954,952,951,949,948,946,946,944,943,942,940,939,937,936,934,933,931,930,929,928,927,925,924,922,921,920,919,918,916,915,914,912,911,910,909,908,906,905,904,903,902,900,899,898,897,896,895,893,892,892,890,889,888,887,886,885,884,882,881,881,879,878,877,876,875,874,873,872,871,870,869,868,867,864,864, 0}; /** * database of motor profiles @@ -626,16 +630,14 @@ static uint32_t lide210_ok[] = { 62496, 2343, 2343, 2343, 2343, 2343, 2343,234 /* NEXT LPERIOD=PREVIOUS*2-192 */ static Motor_Profile motors[]={ - {MOTOR_CANONLIDE110, 2304, 0, lide110_ok}, {MOTOR_CANONLIDE110, 5359, 0, lide110_alt}, {MOTOR_CANONLIDE110, 5360, 1, lide110_alt}, {MOTOR_CANONLIDE110, 10528, 1, lide110_slow}, {MOTOR_CANONLIDE110, 20864, 2, lide110_max}, - {MOTOR_CANONLIDE210, 2304, 0, lide110_ok}, - {MOTOR_CANONLIDE210, 5359, 0, lide110_alt}, - {MOTOR_CANONLIDE210, 5360, 1, lide110_alt}, - {MOTOR_CANONLIDE210, 10528, 1, lide110_slow}, - {MOTOR_CANONLIDE210, 20864, 2, lide110_max}, + {MOTOR_CANONLIDE210, 2768, 0, lide210_fast}, + {MOTOR_CANONLIDE210, 5360, 0, lide210_ok}, + {MOTOR_CANONLIDE210, 10528, 1, lide210_slow}, + {MOTOR_CANONLIDE210, 20864, 2, lide210_max}, {0, 0, 0, NULL}, }; /* *INDENT-ON* */ @@ -690,4 +692,10 @@ static #endif SANE_Status gl124_feed (Genesys_Device * dev, unsigned int steps); +#ifndef UNIT_TESTING +static +#endif +SANE_Status +gl124_stop_action (Genesys_Device * dev); + /* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */ diff --git a/backend/genesys_low.c b/backend/genesys_low.c index 8b762605c..344a95704 100644 --- a/backend/genesys_low.c +++ b/backend/genesys_low.c @@ -610,6 +610,14 @@ sanei_genesys_fe_write_data (Genesys_Device * dev, uint8_t addr, SANE_Status sanei_genesys_get_status (Genesys_Device * dev, uint8_t * status) { +#ifdef UNIT_TESTING + if(dev->usb_mode<0) + { + *status=0; + return SANE_STATUS_GOOD; + } +#endif + if(dev->model->asic_type==GENESYS_GL124) return sanei_genesys_read_hregister(dev, 0x101, status); return sanei_genesys_read_register (dev, 0x41, status); @@ -1718,6 +1726,13 @@ sanei_genesys_is_compatible_calibration (Genesys_Device * dev, resolution=sanei_genesys_compute_dpihw(dev,dev->settings.xres); compatible = (resolution == ((int) sanei_genesys_compute_dpihw(dev,cache->used_setup.xres))); } + if (dev->current_setup.half_ccd != cache->used_setup.half_ccd) + { + DBG (DBG_io, + "sanei_genesys_is_compatible_calibration: half_ccd=%d, used=%d\n", + dev->current_setup.half_ccd, cache->used_setup.half_ccd); + compatible = 0; + } if (dev->current_setup.scan_method != cache->used_setup.scan_method) { DBG (DBG_io,