From d6261ec5dfe0ce8f649e2e34045463104fbfe48a Mon Sep 17 00:00:00 2001 From: Gerhard Jaeger Date: Tue, 10 Jul 2007 09:01:54 +0000 Subject: [PATCH] Added flag to allow only 1- and 8-bit scanmodes. The Q-Scan does not seem to support 14-bit modes. --- backend/plustek-usb.h | 5 +++-- backend/plustek-usbdevs.c | 2 +- backend/plustek.c | 30 +++++++++++++++++++++++------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/backend/plustek-usb.h b/backend/plustek-usb.h index b98beb8a7..bd90a1f9f 100644 --- a/backend/plustek-usb.h +++ b/backend/plustek-usb.h @@ -48,7 +48,7 @@ * - changed DCapsDef, lamp -> misc_io * - bPCB is now ushort to be "missused" by non Plustek * devices (as threshhold for resetting sensor order) - * - added _WAF_LOFF_ON_START + * - added _WAF_LOFF_ON_START and _WAF_ONLY_8BIT * . *
* This file is part of the SANE package. @@ -255,7 +255,8 @@ enum _WORKAROUNDS _WAF_MISC_IO_BUTTONS = 0x00000200, /* special handling for buttons */ _WAF_USE_ALT_DESC = 0x00000400, /* use alternate manufacturer */ _WAF_RESET_SO_TO_RGB = 0x00000800, /* set sensororder to RGB(CIS only)*/ - _WAF_LOFF_ON_START = 0x00001000 /* switch lamp off before scanning */ + _WAF_LOFF_ON_START = 0x00001000, /* switch lamp off before scanning */ + _WAF_ONLY_8BIT = 0x00002000 /* scanner allows only 8 bit modes */ }; /** for lamps connected to the misc I/O pins*/ diff --git a/backend/plustek-usbdevs.c b/backend/plustek-usbdevs.c index 03aea896e..5c306846b 100644 --- a/backend/plustek-usbdevs.c +++ b/backend/plustek-usbdevs.c @@ -772,7 +772,7 @@ static DCapsDef Cap0x0A53_0x1000 = 0, /* number of buttons */ kNEC8861, /* use default settings during calibration */ 200, /* threshold for resetting sensor-order */ - (_WAF_MISC_IO_LAMPS | _WAF_RESET_SO_TO_RGB), + (_WAF_MISC_IO_LAMPS | _WAF_RESET_SO_TO_RGB | _WAF_ONLY_8BIT), _PS_INP1 }; diff --git a/backend/plustek.c b/backend/plustek.c index 55a80dd96..b9caa36d9 100644 --- a/backend/plustek.c +++ b/backend/plustek.c @@ -158,7 +158,7 @@ #include "../include/sane/sanei.h" #include "../include/sane/saneopts.h" -#define BACKEND_VERSION "0.52-1" +#define BACKEND_VERSION "0.52-2" #define BACKEND_NAME plustek #include "../include/sane/sanei_access.h" @@ -694,8 +694,9 @@ static SANE_Status init_options( Plustek_Scanner *s ) { int i; - Plustek_Device *dev = s->hw; - AdjDef *adj = &dev->adj; + Plustek_Device *dev = s->hw; + AdjDef *adj = &dev->adj; + DCapsDef *caps = &dev->usbDev.Caps; memset(s->opt, 0, sizeof(s->opt)); @@ -743,6 +744,9 @@ init_options( Plustek_Scanner *s ) s->opt[OPT_BIT_DEPTH].constraint.word_list = bpp_lm9832_list; s->val[OPT_BIT_DEPTH].w = 8; + if (caps->workaroundFlag & _WAF_ONLY_8BIT) + _DISABLE(OPT_BIT_DEPTH); + /* scan source */ s->opt[OPT_EXT_MODE].name = SANE_NAME_SCAN_SOURCE; s->opt[OPT_EXT_MODE].title = SANE_TITLE_SCAN_SOURCE; @@ -1778,6 +1782,14 @@ do_calibration( void *args ) for ( ; scanmode < 5; scanmode++ ) { + if (caps->workaroundFlag & _WAF_ONLY_8BIT) { + + if ((modes[scanmode] == COLOR_GRAY16) || + (modes[scanmode] == COLOR_TRUE48)) { + continue; + } + } + dev->scanning.dwFlag |= SCANFLAG_Calibration; if (SANE_STATUS_GOOD == local_sane_start(s, modes[scanmode])) { @@ -1812,9 +1824,10 @@ SANE_Status sane_control_option( SANE_Handle handle, SANE_Int option, SANE_Action action, void *value, SANE_Int *info ) { - Plustek_Scanner *s = (Plustek_Scanner *)handle; - Plustek_Device *dev = s->hw; - AdjDef *adj = &dev->adj; + Plustek_Scanner *s = (Plustek_Scanner *)handle; + Plustek_Device *dev = s->hw; + AdjDef *adj = &dev->adj; + DCapsDef *caps = &dev->usbDev.Caps; SANE_Status status; const SANE_String_Const *optval; int scanmode; @@ -2135,12 +2148,15 @@ sane_control_option( SANE_Handle handle, SANE_Int option, _ENABLE(OPT_CONTRAST); _ENABLE(OPT_BIT_DEPTH); _ENABLE(OPT_CUSTOM_GAMMA); - if( scanmode == COLOR_BW ) { + if (scanmode == COLOR_BW) { _DISABLE(OPT_CONTRAST); _DISABLE(OPT_CUSTOM_GAMMA); _DISABLE(OPT_BIT_DEPTH); } + if (caps->workaroundFlag & _WAF_ONLY_8BIT) + _DISABLE(OPT_BIT_DEPTH); + _DISABLE(OPT_GAMMA_VECTOR); _DISABLE(OPT_GAMMA_VECTOR_R); _DISABLE(OPT_GAMMA_VECTOR_G);