diff --git a/ChangeLog b/ChangeLog index b09f636cc..21b10f8b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-10-22 Eddy De Greef + + * backend/mustek_pp_cis.c backend/mustek_pp_cis.h + doc/sane-mustek_pp.man: Added an optional engine_delay parameter + to work around potential engine instability problems for CIS models. + 2005-10-21 Gerhard Jaeger * doc/plustek/Plustek-USB.changes: Update. diff --git a/backend/mustek_pp_cis.c b/backend/mustek_pp_cis.c index 1565450e4..c6d229bfa 100644 --- a/backend/mustek_pp_cis.c +++ b/backend/mustek_pp_cis.c @@ -95,6 +95,9 @@ #include #include #include +#ifdef HAVE_SYS_SELECT_H +# include +#endif #include "../include/sane/sane.h" #include "../include/sane/sanei_pa4s2.h" #define DEBUG_DECLARE_ONLY @@ -1089,8 +1092,19 @@ cis_config_ccd (Mustek_PP_CIS_dev * dev) static SANE_Bool cis_wait_motor_stable (Mustek_PP_CIS_dev * dev) { - return Mustek_PP_1015_wait_bit (dev, MA1015R_MOTOR, MA1015B_MOTOR_STABLE, - SANE_FALSE, 0); + static struct timeval timeoutVal; + SANE_Bool ret = + Mustek_PP_1015_wait_bit (dev, MA1015R_MOTOR, MA1015B_MOTOR_STABLE, + SANE_FALSE, 0); +#ifdef HAVE_SYS_SELECT_H + if (dev->engine_delay > 0) + { + timeoutVal.tv_sec = 0; + timeoutVal.tv_usec = dev->engine_delay*1000; + select(0, NULL, NULL, NULL, &timeoutVal); + } +#endif + return ret; } static void @@ -1998,8 +2012,7 @@ cis_measure_delay(Mustek_PP_CIS_dev * dev) static void cis_motor_control (Mustek_PP_CIS_dev * dev, u_char control) { - Mustek_PP_1015_wait_bit(dev, MA1015R_MOTOR, MA1015B_MOTOR_STABLE, - SANE_FALSE, 0); + cis_wait_motor_stable (dev); Mustek_PP_1015_write_reg(dev, MA1015W_MOTOR_CONTROL, control); } @@ -2126,7 +2139,7 @@ cis_calibrate (Mustek_PP_CIS_dev * dev) { Mustek_PP_1015_write_reg_val (dev, 0x7B); } - Mustek_PP_1015_wait_bit(dev, MA1015R_MOTOR, MA1015B_MOTOR_STABLE, SANE_FALSE, 0); + cis_wait_motor_stable (dev); } Mustek_PP_1015_write_reg_stop(dev); @@ -2383,6 +2396,7 @@ void cis_drv_setup (SANE_Handle hndl) cisdev->fast_skip = SANE_TRUE; cisdev->bw_limit = 127; cisdev->calib_mode = SANE_FALSE; + cisdev->engine_delay = 0; if (cisdev->model == MUSTEK_PP_CIS600) { cisdev->top_skip = MUSTEK_PP_CIS_600CP_DEFAULT_SKIP; @@ -2459,7 +2473,7 @@ SANE_Status cis_drv_config(SANE_Handle hndl, SANE_String_Const optname, value = atoi(optval); if (value < 0 || value > 255) { - DBG (1, "cis_drv_config: valu for option bw out of range: " + DBG (1, "cis_drv_config: value for option bw out of range: " "%d < 0 or %d > 255\n", value, value); return SANE_STATUS_INVAL; } @@ -2475,6 +2489,22 @@ SANE_Status cis_drv_config(SANE_Handle hndl, SANE_String_Const optname, DBG (3, "cis_drv_config: using calibration mode\n"); cisdev->calib_mode = SANE_TRUE; } + else if (!strcmp(optname, "engine_delay")) + { + if (!optval) + { + DBG (1, "cis_drv_config: missing value for option engine_delay\n"); + return SANE_STATUS_INVAL; + } + value = atoi(optval); + if (value < 0 || value > 100) /* 100 ms is already pretty slow */ + { + DBG (1, "cis_drv_config: value for option engine_delay out of range: " + "%d < 0 or %d > 100\n", value, value); + return SANE_STATUS_INVAL; + } + cisdev->engine_delay = value; + } else { DBG (1, "cis_drv_config: unknown options %s\n", optname); diff --git a/backend/mustek_pp_cis.h b/backend/mustek_pp_cis.h index 641fedce6..47e717085 100644 --- a/backend/mustek_pp_cis.h +++ b/backend/mustek_pp_cis.h @@ -226,6 +226,8 @@ typedef struct Mustek_PP_CIS_dev SANE_Byte bw_limit; /* Run in calibration mode ? (default: no) */ SANE_Bool calib_mode; + /* Extra delay between engine commands (ms). Default: zero. */ + SANE_Int engine_delay; /* temporary buffer for 1 line (of one color) */ SANE_Byte *tmpbuf; diff --git a/doc/sane-mustek_pp.man b/doc/sane-mustek_pp.man index 7a2d9bfbd..77bcae2a1 100644 --- a/doc/sane-mustek_pp.man +++ b/doc/sane-mustek_pp.man @@ -65,13 +65,15 @@ Targa Funline TS6EP 600 CP yes Trust Easy Connect 9600+ 600 CP yes +Cybercom + 9352 1200 CP yes (***) .fi .ft R .RE .PP .HP -(*) Calibration problems existed with earlier version of +(*) Calibration problems existed with earlier version of this driver. They seem to be solved now. .HP (**) Problems have been reported in the past for the @@ -81,6 +83,9 @@ the current version of the driver still has these problems. .br .B IF YOU HEAR LOUD CLICKING NOISES, IMMEDIATELY UNPLUG THE SCANNER ! (This holds for any type of scanner). +.HP +(***) Possibly, the engine_delay parameter has to be set to 1 ms +for accurate engine movements. .PP @@ -275,6 +280,32 @@ no models for which these inaccuracy problems are known to occur. By default, fast skipping is used. .PP Example: option slow_skip +.HP +.B engine_delay +Under normal circumstances, it is sufficient for the driver to wait for the +scanner signaling that the engine is stable, before a new engine command can +be transmitted. In rare cases, certain scanners and/or parallel port chipsets +appear to prevent reliable detection of the engine state. As a result, engine +commands are transmitted too soon and the movement of the scanner head becomes +unreliable. Inaccuracies ranging up to 10 cm over the whole vertical scan +range have been reported. To work around this problem, the engine_delay option +can be set. If it is set, the driver waits an additional amount of time after +every engine command, equal to the engine_delay parameter, expressed in +milliseconds. It practice an engine_delay of 1 ms is usually sufficient. The +maximum delay is 100 ms. +.br +Note that every additional ms of delay can add up to 14 seconds to the total +scanning time (highest resolution), so an as small as possible value is +prefered. +.br +Default value: 0 +.br +Minimum: 0 +.br +Maximum: 100 +.br +.PP +Example: option engine_delay 1 .PP .RE .TP