From eb6ae1fb787e6dde1f1ea27486fb00211049932e Mon Sep 17 00:00:00 2001 From: Gerhard Jaeger Date: Sun, 14 Apr 2002 13:38:04 +0000 Subject: [PATCH] Fixed OS/2 compilation problems, minor fixes, fixes interfernce with other USB devices, added CANON N650U stuff --- backend/plustek-devs.c | 131 +++++++++++++++++++++++++++++++---- backend/plustek-share.h | 35 ++++++++++ backend/plustek-usb.c | 33 +++++++++ backend/plustek-usb.h | 18 ++--- backend/plustek-usbhw.c | 38 +++++----- backend/plustek-usbio.c | 3 +- backend/plustek-usbscan.c | 81 +++++++++++++--------- backend/plustek-usbshading.c | 33 ++++----- backend/plustek.c | 8 ++- backend/plustek.h | 2 +- 10 files changed, 278 insertions(+), 104 deletions(-) diff --git a/backend/plustek-devs.c b/backend/plustek-devs.c index 656dac8ea..1aa04a390 100644 --- a/backend/plustek-devs.c +++ b/backend/plustek-devs.c @@ -19,6 +19,7 @@ * added UMAX 3400 entries * added HP2100 settings according to Craig Smoothey * added LM9832 based U24 + * added CANON650 entry *............................................................................. * * This file is part of the SANE package. @@ -617,6 +618,24 @@ static DCapsDef Cap0x1606_0x0060_0 = _WAF_MISC_IO3_LAMP /* use miscio 3 for lamp switching */ }; +/* Canon N650U/N656U + */ +static DCapsDef Cap0x04A9_0x2206_0 = +{ + {{ 0, 165}, 0, {2550, 3510 - 165}, {100, 100}, COLOR_BW }, + {{ 0, 0}, 0, {0, 0}, { 0, 0 }, 0 }, + {{ 0, 0}, 0, {0, 0}, { 0, 0 }, 0 }, + {{ 0, 0}, 0, {0, 0}, { 0, 0 }, 0 }, + {600, 600}, + 0, + SENSORORDER_bgr, + 8, /* sensor distance */ + 4, /* number of buttons */ + kNEC8861, /* use default settings during calibration */ + 0, /* not used here... */ + _WAF_NONE +}; + /******************* additional Hardware descriptions ************************/ static HWDef Hw0x07B3_0x0017_0 = @@ -628,8 +647,8 @@ static HWDef Hw0x07B3_0x0017_0 = 300, /* wMotorDpi (Full step DPI) */ /* 100, // wStartY (The top scanning origin in Full Steps) */ 512, /* wRAMSize (KB) */ - 4, /* wMinIntegrationTimeLowres (ms) */ - 5, /* wMinIntegrationTimeHighres (ms) */ + 4, /* dMinIntegrationTimeLowres (ms) */ + 5, /* dMinIntegrationTimeHighres (ms) */ 3000, /* wGreenPWMDutyCycleLow */ 4095, /* wGreenPWMDutyCycleHigh */ 0x02, /* bSensorConfiguration (0x0b) */ @@ -643,7 +662,9 @@ static HWDef Hw0x07B3_0x0017_0 = _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0, /* bReg 0x27 color mode */ - + + 1, /* bReg 0x29 illumination mode */ + 1, /* StepperPhaseCorrection (0x1a & 0x1b) */ 14, /* 15, bOpticBlackStart (0x1c) */ 62, /* 60, bOpticBlackEnd (0x1d) */ @@ -689,6 +710,7 @@ static HWDef Hw0x07B3_0x0007_0 = {5, 23, 1, 3, 0, 0, 0, 6, 10, 22}, _GREEN_CH, 0, + 1, 1, 14, 62, @@ -727,6 +749,7 @@ static HWDef Hw0x07B3_0x0007_2 = _GREEN_CH, 0, 1, + 1, 16, 64, 152, @@ -764,6 +787,7 @@ static HWDef Hw0x07B3_0x0007_4 = _GREEN_CH, 0, 1, + 1, 13, 62, 304, @@ -801,6 +825,7 @@ static HWDef Hw0x07B3_0x000F_0 = _GREEN_CH, 0, 1, + 1, 14, 62, 110, @@ -838,6 +863,7 @@ static HWDef Hw0x07B3_0x0013_0 = _GREEN_CH, 0, 1, + 1, 14, 62, 110, @@ -875,6 +901,7 @@ static HWDef Hw0x07B3_0x0013_4 = _GREEN_CH, 0, 1, + 1, 13, 62, 320, @@ -912,6 +939,7 @@ static HWDef Hw0x07B3_0x000F_4 = _GREEN_CH, 0, 1, + 1, 13, 62, 304, @@ -949,6 +977,7 @@ static HWDef Hw0x07B3_0x0016_4 = _GREEN_CH, 0, 1, + 1, 13, 62, 320, @@ -989,6 +1018,7 @@ static HWDef Hw0x07B3_0x0017_4 = _GREEN_CH, 0, 1, + 1, 13, 62, 320, @@ -1026,6 +1056,7 @@ static HWDef Hw0x07B3_0x0017_1 = _GREEN_CH, 0, 1, + 1, 15, 60, 110, @@ -1063,6 +1094,7 @@ static HWDef Hw0x07B3_0x0012_0 = _GREEN_CH, 0, 1, + 1, 14, 62, 110, @@ -1100,6 +1132,7 @@ static HWDef Hw0x07B3_0x0017_2 = _GREEN_CH, 0, 1, + 1, 16, 64, 110, @@ -1137,6 +1170,7 @@ static HWDef Hw0x07B3_0x0017_3 = _GREEN_CH, 0, 1, + 1, 14, 62, 110, @@ -1169,8 +1203,8 @@ static HWDef Hw0x03F0_0x0505 = 9, /* wIntegrationTimeHighLamp */ 600, /* ok wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ - 4, /* wMinIntegrationTimeLowres (ms) */ - 5, /* wMinIntegrationTimeHighres (ms) */ + 4, /* dMinIntegrationTimeLowres (ms) */ + 5, /* dMinIntegrationTimeHighres (ms) */ 3000, /* wGreenPWMDutyCycleLow */ 4095, /* wGreenPWMDutyCycleHigh */ 0x02, /* bSensorConfiguration (0x0b) */ @@ -1184,6 +1218,7 @@ static HWDef Hw0x03F0_0x0505 = _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0, /* bReg 0x27 color mode */ + 1, /* bReg 0x29 illumination mode */ 1, /* StepperPhaseCorrection (0x1a & 0x1b) */ 14, /* 15,= bOpticBlackStart (0x1c) */ @@ -1226,8 +1261,8 @@ static HWDef Hw0x03F0_0x0605 = 12, /* wIntegrationTimeHighLamp */ 600, /* ok wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ - 9, /* wMinIntegrationTimeLowres (ms) */ - 9, /* wMinIntegrationTimeHighres (ms) */ + 9, /* dMinIntegrationTimeLowres (ms) */ + 9, /* dMinIntegrationTimeHighres (ms) */ 0, /* wGreenPWMDutyCycleLow */ 0, /* wGreenPWMDutyCycleHigh */ 0x02, /* bSensorConfiguration (0x0b) */ @@ -1241,6 +1276,8 @@ static HWDef Hw0x03F0_0x0605 = _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0, /* bReg 0x27 color mode */ + + 1, /* bReg 0x29 illumination mode */ 1, /* StepperPhaseCorrection (0x1a & 0x1b) */ 14, /* 15,= bOpticBlackStart (0x1c) */ @@ -1283,8 +1320,8 @@ static HWDef Hw0x0400_0x1000_0 = 12, /* ok wIntegrationTimeHighLamp */ 600, /* ok wMotorDpi (Full step DPI) */ 512, /* ok wRAMSize (KB) */ - 9, /* ok wMinIntegrationTimeLowres (ms) */ - 9, /* ok wMinIntegrationTimeHighres (ms) */ + 9, /* ok dMinIntegrationTimeLowres (ms) */ + 9, /* ok dMinIntegrationTimeHighres (ms) */ 1169, /* ok wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 1169, /* ok wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ 0x02, /* ok bSensorConfiguration (0x0b) */ @@ -1297,6 +1334,7 @@ static HWDef Hw0x0400_0x1000_0 = /* ok color (reg 0x0f to 0x18) */ _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0, /* bReg 0x27 color mode */ + 1, /* bReg 0x29 illumination mode */ 257, /* ok StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0x0e, /* ok bOpticBlackStart (reg 0x1c) */ 0x1d, /* ok bOpticBlackEnd (reg 0x1d) */ @@ -1341,6 +1379,7 @@ static HWDef Hw0x0400_0x1001_0 = _GREEN_CH, 0, 1, + 1, 16, 64, 152, @@ -1373,8 +1412,8 @@ static HWDef Hw0x04B8_0x010F_0 = 12, /* wIntegrationTimeHighLamp */ 600, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ - 4, /* wMinIntegrationTimeLowres (ms) */ - 5, /* wMinIntegrationTimeHighres (ms) */ + 4, /* dMinIntegrationTimeLowres (ms) */ + 5, /* dMinIntegrationTimeHighres (ms) */ 3000, /* ok wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 4095, /* ok wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ @@ -1390,6 +1429,7 @@ static HWDef Hw0x04B8_0x010F_0 = /* ok color (reg 0x0f to 0x18) */ _GREEN_CH, /* ok bReg_0x26 color mode - bits 4 and 5 */ 0x40, /* ok bReg 0x27 color mode */ + 3, /* bReg 0x29 illumination mode */ 1, /* ok StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0x00, /* ok bOpticBlackStart (reg 0x1c) */ @@ -1433,8 +1473,8 @@ static HWDef Hw0x1606_0x0060_0 = 9, /* wIntegrationTimeHighLamp */ 600, /* wMotorDpi (Full step DPI) */ 512, /* wRAMSize (KB) */ - 8, /* wMinIntegrationTimeLowres (ms) */ - 8, /* wMinIntegrationTimeHighres (ms) */ + 8, /* dMinIntegrationTimeLowres (ms) */ + 8, /* dMinIntegrationTimeHighres (ms) */ 4095, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ 4095, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ @@ -1450,6 +1490,7 @@ static HWDef Hw0x1606_0x0060_0 = /* color (reg 0x0f to 0x18) */ _GREEN_CH, /* bReg_0x26 color mode - bits 4 and 5 */ 0x40, /* bReg 0x27 color mode */ + 1, /* bReg 0x29 illumination mode */ 1, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ 0x2f, /* bOpticBlackStart (reg 0x1c) */ @@ -1484,6 +1525,69 @@ static HWDef Hw0x1606_0x0060_0 = MODEL_NOPLUSTEK }; +/* Canon 650 */ +static HWDef Hw0x04A9_0x2206_0 = +{ + 0.7, /* dMaxMotorSpeed (Max_Speed) */ + 0.7, /* dMaxMoveSpeed (Max_Speed) */ + 100, /* wIntegrationTimeLowLamp */ + 100, /* wIntegrationTimeHighLamp */ + 600, /* wMotorDpi (Full step DPI) */ + 512, /* wRAMSize (KB) */ + 3.75, /* dMinIntegrationTimeLowres (ms) */ + 5.75, /* dMinIntegrationTimeHighres (ms) */ + 4095, /* wGreenPWMDutyCycleLow (reg 0x2a + 0x2b) */ + 4095, /* wGreenPWMDutyCycleHigh (reg 0x2a + 0x2b) */ + + 0x15, /* bSensorConfiguration (0x0b) */ + 0x4c, /* sensor control settings (reg 0x0c) */ + 0x2f, /* sensor control settings (reg 0x0d) */ + 0x00, /* sensor control settings (reg 0x0e) */ + + {0x00, 0x03, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x07, 0x03}, + /* mono (reg 0x0f to 0x18) */ + + {0x00, 0x00, 0x04, 0x05, 0x06, 0x07, 0x00, 0x00, 0x00, 0x05}, + /* color (reg 0x0f to 0x18) */ + + (_BLUE_CH | 0x05), /* bReg_0x26 color mode */ + + 0x00, /* bReg 0x27 color mode */ + 2, /* bReg 0x29 illumination mode */ + + 5, /* StepperPhaseCorrection (reg 0x1a + 0x1b) */ + 1, /* bOpticBlackStart (reg 0x1c) */ + 52, /* bOpticBlackEnd (reg 0x1d) */ + 110, /* ? wActivePixelsStart (reg 0x1e + 0x1f) */ + 5469, /* wLineEnd (reg 0x20 + 0x21) */ + + 100, /* red lamp on (reg 0x2c + 0x2d) */ + 5100, /* red lamp off (reg 0x2e + 0x2f) */ + 100, /* green lamp on (reg 0x30 + 0x31) */ + 3100, /* green lamp off (reg 0x32 + 0x33) */ + 100, /* blue lamp on (reg 0x34 + 0x35) */ + 2100, /* blue lamp off (reg 0x36 + 0x37) */ + + 3, /* stepper motor control (reg 0x45) */ + 0, /* wStepsAfterPaperSensor2 (reg 0x4c + 0x4d) */ + 0xfc, /* acceleration profile (reg 0x51) */ + 0, /* lines to process (reg 0x54) */ + 0x17, /* kickstart (reg 0x55) */ + 0x08, /* pwm freq (reg 0x56) */ + 0x1f, /* pwm duty cycle (reg 0x57) */ + + 0x05, /* Paper sense (reg 0x58) */ + + 0x24, /* misc io12 (reg 0x59) */ + 0x12, /* misc io34 (reg 0x5a) */ + 0x11, /* misc io56 (reg 0x5b) */ + 0, /* test mode ADC Output CODE MSB (reg 0x5c) */ + 0, /* test mode ADC Output CODE LSB (reg 0x5d) */ + 0, /* test mode (reg 0x5e) */ + _LM9832, + MODEL_NOPLUSTEK +}; + /******************** all available combinations *****************************/ /* @@ -1539,6 +1643,7 @@ static SetDef Settings[] = {"0x1606-0x0060", &Cap0x1606_0x0060_0, &Hw0x1606_0x0060_0, "UMAX 3400" }, /* CANON... */ + {"0x04A9-0x2206", &Cap0x04A9_0x2206_0, &Hw0x04A9_0x2206_0, "N650U/N656U" }, /* {"0x04A9-0x220D", ,, "N670U" }, */ /* Please add other devices here... diff --git a/backend/plustek-share.h b/backend/plustek-share.h index c1f71d9bb..92cc5a72f 100644 --- a/backend/plustek-share.h +++ b/backend/plustek-share.h @@ -21,6 +21,7 @@ * added adjustment stuff * 0.42 - added FLAG_CUSTOM_GAMMA and _MAP_ definitions * changed IOCTL interface to allow downloadable MAPS + * added error codes * *............................................................................. * @@ -494,6 +495,40 @@ typedef struct { #define _MAP_BLUE 2 #define _MAP_MASTER 3 +/* + * generic error codes... + */ +#define _OK 0 + +#define _FIRST_ERR -9000 + +#define _E_INIT (_FIRST_ERR-1) /* already initialized */ +#define _E_NOT_INIT (_FIRST_ERR-2) /* not initialized */ +#define _E_NULLPTR (_FIRST_ERR-3) /* internal NULL-PTR detected */ +#define _E_ALLOC (_FIRST_ERR-4) /* error allocating memory */ +#define _E_TIMEOUT (_FIRST_ERR-5) /* signals a timeout condition */ +#define _E_INVALID (_FIRST_ERR-6) /* invalid parameter detected */ +#define _E_INTERNAL (_FIRST_ERR-7) /* internal error */ +#define _E_BUSY (_FIRST_ERR-8) /* device is already in use */ +#define _E_ABORT (_FIRST_ERR-9) /* operation aborted */ +#define _E_LOCK (_FIRST_ERR-10) /* canīt lock resource */ +#define _E_NOSUPP (_FIRST_ERR-11) /* feature or device not supported */ +#define _E_NORESOURCE (_FIRST_ERR-12) /* out of memo, resource busy... */ +#define _E_VERSION (_FIRST_ERR-19) /* version conflict */ +#define _E_NO_DEV (_FIRST_ERR-20) /* device does not exist */ +#define _E_NO_CONN (_FIRST_ERR-21) /* nothing connected */ +#define _E_PORTSEARCH (_FIRST_ERR-22) /* parport_enumerate failed */ +#define _E_NO_PORT (_FIRST_ERR-23) /* requested port does not exist */ +#define _E_REGISTER (_FIRST_ERR-24) /* cannot register this device */ +#define _E_SEQUENCE (_FIRST_ERR-30) /* caller sequence does not match */ +#define _E_NO_ASIC (_FIRST_ERR-31) /* canīt detect ASIC */ + +#define _E_LAMP_NOT_IN_POS (_FIRST_ERR-40) +#define _E_LAMP_NOT_STABLE (_FIRST_ERR-41) +#define _E_NODATA (_FIRST_ERR-42) +#define _E_BUFFER_TOO_SMALL (_FIRST_ERR-43) +#define _E_DATAREAD (_FIRST_ERR-44) + /* * stuff needed for user space stuff */ diff --git a/backend/plustek-usb.c b/backend/plustek-usb.c index 7c847f47d..11608c24e 100644 --- a/backend/plustek-usb.c +++ b/backend/plustek-usb.c @@ -13,6 +13,8 @@ * added Canon to the manufacturer list * 0.42 - added warmup stuff * added setmap function + * changed detection stuff, so we first check whether + * the vendor and product Ids match with the ones in our list * *............................................................................. * @@ -264,6 +266,27 @@ static void usbDev_shutdown( Plustek_Device *dev ) usb_StopLampTimer( dev ); } +/** + * This function checks wether a device, described by a given + * string(vendor and product ID), is support by this backend or not + * + * @param usbIdStr - sting consisting out of product and vendor ID + * format: "0xVVVVx0xPPPP" VVVV = Vendor ID, PPP = Product ID + * @returns; SANE_TRUE if supported, SANE_FALSE if not + */ +static SANE_Bool usb_IsDeviceInList( char *usbIdStr ) +{ + int i; + + for( i = 0; NULL != Settings[i].pIDString; i++ ) { + + if( 0 == strncmp( Settings[i].pIDString, usbIdStr, 13 )) + return SANE_TRUE; + } + + return SANE_FALSE; +} + /*............................................................................. * */ @@ -329,6 +352,16 @@ static int usbDev_open( const char *dev_name, void *misc ) DBG( _DBG_INFO, "... using the specified: 0x%04x\n", vendor ); } + /* + * before accessing the scanner, check if supported! + */ + if( !usb_IsDeviceInList( dev->usbId )) { + DBG( _DBG_ERROR, "Device >%s<, is not supported!\n", dev->usbId ); + sanei_usb_close( handle ); + return -1; + } + + if( SANE_STATUS_GOOD != usbio_DetectLM983x( handle, &version )) { sanei_usb_close( handle ); return -1; diff --git a/backend/plustek-usb.h b/backend/plustek-usb.h index 4f44049ce..816ccbaac 100644 --- a/backend/plustek-usb.h +++ b/backend/plustek-usb.h @@ -34,8 +34,6 @@ #ifndef __PLUSTEK_USB_H__ #define __PLUSTEK_USB_H__ -typedef int Bool; - /* CCD ID (PCB ID): total 3 bits */ #define kNEC3799 0 #define kSONY518 1 @@ -290,6 +288,9 @@ typedef struct HWDefault u_char bReg_0x26; u_char bReg_0x27; + /* illumination mode reg 0x29 */ + u_char bReg_0x29; + /* 0x1a & 0x1b, remember the u_char order is not Intel * format, you have to pay your attention when you * write this value to register. @@ -441,7 +442,7 @@ typedef struct ScanDef /* * from calibration... */ - Bool fCalibrated; + SANE_Bool fCalibrated; /* * the other stuff... @@ -489,17 +490,6 @@ typedef struct ScanDef } ScanDef, *pScanDef; - -/*** some error codes... ****/ - -#define _E_LAMP_NOT_IN_POS -9600 -#define _E_LAMP_NOT_STABLE -9601 -#define _E_INTERNAL -9610 -#define _E_ALLOC -9611 -#define _E_NODATA -9620 -#define _E_BUFFER_TOO_SMALL -9621 -#define _E_DATAREAD -9630 - #endif /* guard __PLUSTEK_USB_H__ */ /* END PLUSTEK-USB.H ........................................................*/ diff --git a/backend/plustek-usbhw.c b/backend/plustek-usbhw.c index 816558fa4..6b199129b 100644 --- a/backend/plustek-usbhw.c +++ b/backend/plustek-usbhw.c @@ -67,14 +67,14 @@ static u_long dwCrystalFrequency = 48000000UL; -static Bool fModuleFirstHome; /* HEINER: this has to be initialized */ -static Bool fLastScanIsAdf; -static u_char a_bRegs[0x80]; +static SANE_Bool fModuleFirstHome; /* HEINER: this has to be initialized */ +static SANE_Bool fLastScanIsAdf; +static u_char a_bRegs[0x80]; /*............................................................................. * */ -static Bool usb_MotorOn( int handle, Bool fOn ) +static SANE_Bool usb_MotorOn( int handle, SANE_Bool fOn ) { if( fOn ) a_bRegs[0x45] |= 0x10; @@ -89,7 +89,7 @@ static Bool usb_MotorOn( int handle, Bool fOn ) /*............................................................................. * */ -static Bool usb_IsScannerReady( pPlustek_Device dev ) +static SANE_Bool usb_IsScannerReady( pPlustek_Device dev ) { u_char value; double len; @@ -137,7 +137,7 @@ static Bool usb_IsScannerReady( pPlustek_Device dev ) /*............................................................................. * */ -static Bool usb_SensorAdf( int handle ) +static SANE_Bool usb_SensorAdf( int handle ) { u_char value; @@ -149,7 +149,7 @@ static Bool usb_SensorAdf( int handle ) /*............................................................................. * */ -static Bool usb_SensorPaper( int handle ) +static SANE_Bool usb_SensorPaper( int handle ) { u_char value; @@ -165,7 +165,8 @@ static Bool usb_SensorPaper( int handle ) * to repeatly move the module around the scanner and * 0 means forever. */ -static Bool usb_ModuleMove(pPlustek_Device dev, u_char bAction, u_long dwStep) +static SANE_Bool usb_ModuleMove( pPlustek_Device dev, + u_char bAction, u_long dwStep ) { SANE_Status res; u_char bReg2, reg7; @@ -358,7 +359,7 @@ static Bool usb_ModuleMove(pPlustek_Device dev, u_char bAction, u_long dwStep) /*............................................................................. * */ -static Bool usb_ModuleToHome( pPlustek_Device dev, Bool fWait ) +static SANE_Bool usb_ModuleToHome( pPlustek_Device dev, SANE_Bool fWait ) { u_char value; pDCapsDef scaps = &dev->usbDev.Caps; @@ -531,7 +532,7 @@ static Bool usb_ModuleToHome( pPlustek_Device dev, Bool fWait ) /*............................................................................. * */ -static Bool usb_MotorSelect( pPlustek_Device dev, Bool fADF ) +static SANE_Bool usb_MotorSelect( pPlustek_Device dev, SANE_Bool fADF ) { pDCapsDef sCaps = &dev->usbDev.Caps; pHWDef hw = &dev->usbDev.HwSetting; @@ -617,7 +618,7 @@ static int usb_GetLampStatus( pPlustek_Device dev ) /*............................................................................. * */ -static void usb_LedOn( pPlustek_Device dev, Bool fOn ) +static void usb_LedOn( pPlustek_Device dev, SANE_Bool fOn ) { u_char value; @@ -641,7 +642,8 @@ static void usb_LedOn( pPlustek_Device dev, Bool fOn ) /*............................................................................. * */ -static Bool usb_LampOn( pPlustek_Device dev, Bool fOn, Bool fResetTimer ) +static SANE_Bool usb_LampOn( pPlustek_Device dev, + SANE_Bool fOn, SANE_Bool fResetTimer ) { pScanDef scanning = &dev->scanning; pDCapsDef sc = &dev->usbDev.Caps; @@ -679,23 +681,21 @@ static Bool usb_LampOn( pPlustek_Device dev, Bool fOn, Bool fResetTimer ) /* * EPSON specific stuff */ + a_bRegs[0x29] = hw->bReg_0x29; + if(_WAF_MISC_IO6_LAMP==(_WAF_MISC_IO6_LAMP & sc->workaroundFlag)) { - a_bRegs[0x29] = 3; /* mode 3 */ a_bRegs[0x5b] = 0x94; usbio_WriteReg( dev->fd, 0x5b, a_bRegs[0x5b] ); } else if(_WAF_MISC_IO3_LAMP == (_WAF_MISC_IO3_LAMP & sc->workaroundFlag)) { - a_bRegs[0x29] = 1; /* mode 1 */ a_bRegs[0x5a] |= 0x08; usbio_WriteReg( dev->fd, 0x5a, a_bRegs[0x5a] ); } else { - a_bRegs[0x29] = 1; /* mode 1 */ - if( lampId == DEV_LampReflection ) { a_bRegs[0x2e] = 16383 / 256; a_bRegs[0x2f] = 16383 % 256; @@ -751,26 +751,24 @@ static Bool usb_LampOn( pPlustek_Device dev, Bool fOn, Bool fResetTimer ) memset( &a_bRegs[0x29], 0, 0x37-0x29+1 ); + a_bRegs[0x29] = hw->bReg_0x29; + /* * EPSON specific stuff */ if(_WAF_MISC_IO6_LAMP==(_WAF_MISC_IO6_LAMP & sc->workaroundFlag)) { - a_bRegs[0x29] = 3; /* mode 3 */ a_bRegs[0x5b] = 0x14; usbio_WriteReg( dev->fd, 0x5b, a_bRegs[0x5b] ); } else if( _WAF_MISC_IO3_LAMP == (_WAF_MISC_IO3_LAMP & sc->workaroundFlag)) { - a_bRegs[0x29] = 1; /* mode 1 */ a_bRegs[0x5a] &= ~0x08; usbio_WriteReg( dev->fd, 0x5a, a_bRegs[0x5a] ); } else { - a_bRegs[0x29] = 1; /* mode 1 */ - if( iStatusChange & DEV_LampReflection ) { a_bRegs[0x2e] = 16383 / 256; a_bRegs[0x2f] = 16383 % 256; diff --git a/backend/plustek-usbio.c b/backend/plustek-usbio.c index 2e156d0dd..11a3a6ddc 100644 --- a/backend/plustek-usbio.c +++ b/backend/plustek-usbio.c @@ -78,7 +78,8 @@ * @param value - * @return */ -static Bool usbio_WriteReg( SANE_Int handle, SANE_Byte reg, SANE_Byte value ) +static SANE_Bool usbio_WriteReg( SANE_Int handle, + SANE_Byte reg, SANE_Byte value ) { int i; SANE_Byte data; diff --git a/backend/plustek-usbscan.c b/backend/plustek-usbscan.c index cb78f98c5..30f860b4c 100644 --- a/backend/plustek-usbscan.c +++ b/backend/plustek-usbscan.c @@ -10,7 +10,7 @@ * History: * 0.40 - starting version of the USB support * 0.41 - minor fixes - * 0.42 - no changes + * 0.42 - added some stuff for CIS devices * *............................................................................. * @@ -55,13 +55,10 @@ /** @file plustek-usbscan.c */ - -#include - static u_char bMaxITA; -static Bool m_fAutoPark; -static Bool m_fFirst; +static SANE_Bool m_fAutoPark; +static SANE_Bool m_fFirst; static double m_dHDPIDivider; static double m_dMCLKDivider; static pScanParam m_pParam; @@ -74,12 +71,16 @@ static u_short m_wLineLength; static u_short m_wStepSize; static u_long m_dwPauseLimit; -static Bool m_fStart = SANE_FALSE; - - -static Bool usb_DownloadShadingData( pPlustek_Device, u_char ); +static SANE_Bool m_fStart = SANE_FALSE; +/* Prototype... */ +static SANE_Bool usb_DownloadShadingData( pPlustek_Device, u_char ); +/** + * @param val1 - + * @param val2 - + * @return + */ static u_long usb_min( u_long val1, u_long val2 ) { if( val1 > val2 ) @@ -88,6 +89,11 @@ static u_long usb_min( u_long val1, u_long val2 ) return val1; } +/** + * @param val1 - + * @param val2 - + * @return + */ static u_long usb_max( u_long val1, u_long val2 ) { if( val1 > val2 ) @@ -870,39 +876,45 @@ static void usb_GetLineLength( pPlustek_Device dev ) tp++; } - /* We are CCD scanner, ctmode should be 0 */ - b = (ntr + 1) * ((2*gbnd) + dur + 1); - b += (1 - ntr) * en_tradj; + b = 1; + if( ctmode == 0 ) { /* CCD mode scanner*/ + + b = (ntr + 1) * ((2 * gbnd) + dur + 1); + b += (1 - ntr) * en_tradj; + } + if( ctmode == 2 ) /* CIS mode scanner */ + b = 3; + tr = m_bLineRateColor * (hw->wLineEnd + tp * (b + 3 - ntr)); - if (tradj == 0) - { - if (ctmode == 0) + if( tradj == 0 ) { + if( ctmode == 0 ) tr += m_bLineRateColor; - } - else - { + } else { + int le_phi, num_byteclk, num_mclkf, tr_fast_pix, extra_pix; - + /* Line color or gray mode */ - if (afeop != 0) - { - le_phi = (tradj + 1) / 2 + 1 + 6; - num_byteclk = ((le_phi + 8 * hw->wLineEnd + 8 * b + 4) / (8 * tradj)) + 1; - num_mclkf = 8 * tradj * num_byteclk; + if( afeop != 0 ) { + + le_phi = (tradj + 1) / 2 + 1 + 6; + num_byteclk = ((le_phi + 8 * hw->wLineEnd + 8 * b + 4) / + (8 * tradj)) + 1; + num_mclkf = 8 * tradj * num_byteclk; tr_fast_pix = num_byteclk; - extra_pix = (num_mclkf - le_phi) % 8; + extra_pix = (num_mclkf - le_phi) % 8; } else /* 3 channel pixel rate color */ { - le_phi = (tradj + 1) / 2 + 1 + 10 + 12; + le_phi = (tradj + 1) / 2 + 1 + 10 + 12; num_byteclk = ((le_phi + 3 * 8 * hw->wLineEnd + 3 * 8 * b + 3 * 4) / (3 * 8 * tradj)) + 1; - num_mclkf = 3 * 8 * tradj * num_byteclk; + num_mclkf = 3 * 8 * tradj * num_byteclk; tr_fast_pix = num_byteclk; - extra_pix = (num_mclkf - le_phi) % (3 * 8); + extra_pix = (num_mclkf - le_phi) % (3 * 8); } + tr = b + hw->wLineEnd + 4 + tr_fast_pix; if (extra_pix == 0) tr++; @@ -1105,7 +1117,7 @@ static void usb_GetScanLinesAndSize( pPlustek_Device dev, pScanParam pParam ) /*............................................................................. * */ -static Bool usb_SetScanParameters( pPlustek_Device dev, pScanParam pParam ) +static SANE_Bool usb_SetScanParameters( pPlustek_Device dev, pScanParam pParam ) { static u_char reg8, reg38[6], reg48[2]; @@ -1254,7 +1266,7 @@ static Bool usb_SetScanParameters( pPlustek_Device dev, pScanParam pParam ) /*............................................................................. * */ -static Bool usb_ScanBegin( pPlustek_Device dev, Bool fAutoPark ) +static SANE_Bool usb_ScanBegin( pPlustek_Device dev, SANE_Bool fAutoPark ) { u_char value; @@ -1327,7 +1339,7 @@ static Bool usb_ScanBegin( pPlustek_Device dev, Bool fAutoPark ) /*............................................................................. * */ -static Bool usb_ScanEnd( pPlustek_Device dev ) +static SANE_Bool usb_ScanEnd( pPlustek_Device dev ) { u_char value; @@ -1357,7 +1369,7 @@ static Bool usb_ScanEnd( pPlustek_Device dev ) /*............................................................................. * */ -static Bool usb_IsDataAvailableInDRAM( pPlustek_Device dev ) +static SANE_Bool usb_IsDataAvailableInDRAM( pPlustek_Device dev ) { /* Compute polling timeout * Height (Inches) / MaxScanSpeed (Inches/Second) = Seconds to move the @@ -1410,7 +1422,8 @@ static Bool usb_IsDataAvailableInDRAM( pPlustek_Device dev ) /*............................................................................. * */ -static Bool usb_ScanReadImage( pPlustek_Device dev, void *pBuf, u_long dwSize ) +static SANE_Bool usb_ScanReadImage( pPlustek_Device dev, + void *pBuf, u_long dwSize ) { static u_long dwBytes = 0; SANE_Status res; diff --git a/backend/plustek-usbshading.c b/backend/plustek-usbshading.c index 37f230f1f..1d25ce28b 100644 --- a/backend/plustek-usbshading.c +++ b/backend/plustek-usbshading.c @@ -88,8 +88,8 @@ static u_short m_wShadow = 0; /* check the windows registry... */ /*............................................................................. * */ -static Bool usb_SetDarkShading( int fd, u_char channel, - void *lpCoeff, u_short wCount ) +static SANE_Bool usb_SetDarkShading( int fd, u_char channel, + void *lpCoeff, u_short wCount ) { int res; @@ -125,8 +125,8 @@ static Bool usb_SetDarkShading( int fd, u_char channel, /*............................................................................. * */ -static Bool usb_SetWhiteShading( int fd, u_char channel, - void *lpData, u_short wCount ) +static SANE_Bool usb_SetWhiteShading( int fd, u_char channel, + void *lpData, u_short wCount ) { int res; @@ -408,13 +408,13 @@ static u_char usb_GetNewGain( u_short wMax ) /*............................................................................. * */ -static Bool usb_AdjustGain( pPlustek_Device dev, int fNegative ) +static SANE_Bool usb_AdjustGain( pPlustek_Device dev, int fNegative ) { pScanDef scanning = &dev->scanning; pDCapsDef scaps = &dev->usbDev.Caps; pHWDef hw = &dev->usbDev.HwSetting; u_long dw; - Bool fRepeatITA = SANE_TRUE; + SANE_Bool fRepeatITA = SANE_TRUE; if( usb_IsEscPressed()) return SANE_FALSE; @@ -626,7 +626,7 @@ static void usb_GetNewOffset( u_long *pdwSum, u_long *pdwDiff, char *pcOffset, /*............................................................................. * */ -static Bool usb_AdjustOffset( pPlustek_Device dev ) +static SANE_Bool usb_AdjustOffset( pPlustek_Device dev ) { char cAdjust = 16; char cOffset[3]; @@ -793,7 +793,7 @@ static void usb_GetDarkShading( pPlustek_Device dev, u_short *pwDest, /*............................................................................. * */ -static Bool usb_AdjustDarkShading( pPlustek_Device dev ) +static SANE_Bool usb_AdjustDarkShading( pPlustek_Device dev ) { pScanDef scanning = &dev->scanning; pDCapsDef scaps = &dev->usbDev.Caps; @@ -837,19 +837,17 @@ static Bool usb_AdjustDarkShading( pPlustek_Device dev ) (!usb_ScanReadImage(dev,pScanBuffer,m_ScanParam.Size.dwPhyBytes)) || (!usb_ScanEnd( dev ))) { + a_bRegs[0x29] = hw->bReg_0x29; + if(_WAF_MISC_IO6_LAMP==(_WAF_MISC_IO6_LAMP & scaps->workaroundFlag)) { - a_bRegs[0x29] = 3; a_bRegs[0x5b] = 0x94; usbio_WriteReg( dev->fd, 0x5b, a_bRegs[0x5b] ); } else if( _WAF_MISC_IO3_LAMP == (_WAF_MISC_IO3_LAMP & scaps->workaroundFlag)) { - a_bRegs[0x29] = 3; a_bRegs[0x5a] |= 0x08; usbio_WriteReg( dev->fd, 0x5a, a_bRegs[0x5a] ); - } else { - a_bRegs[0x29] = 1; } usbio_WriteReg( dev->fd, 0x29, a_bRegs[0x29] ); @@ -860,20 +858,17 @@ static Bool usb_AdjustDarkShading( pPlustek_Device dev ) /* * set illumination mode to 1 or 3 on EPSON */ + a_bRegs[0x29] = hw->bReg_0x29; + if( _WAF_MISC_IO6_LAMP == (_WAF_MISC_IO6_LAMP & scaps->workaroundFlag)) { - a_bRegs[0x29] = 3; a_bRegs[0x5b] = 0x94; usbio_WriteReg( dev->fd, 0x5b, a_bRegs[0x5b] ); } else if( _WAF_MISC_IO3_LAMP == (_WAF_MISC_IO3_LAMP & scaps->workaroundFlag)) { - a_bRegs[0x29] = 3; a_bRegs[0x5a] |= 0x08; usbio_WriteReg( dev->fd, 0x5a, a_bRegs[0x5a] ); - - } else { - a_bRegs[0x29] = 1; } if( !usbio_WriteReg( dev->fd, 0x29, a_bRegs[0x29])) { @@ -915,7 +910,7 @@ static Bool usb_AdjustDarkShading( pPlustek_Device dev ) /*............................................................................. * */ -static Bool usb_AdjustWhiteShading( pPlustek_Device dev ) +static SANE_Bool usb_AdjustWhiteShading( pPlustek_Device dev ) { pScanDef scanning = &dev->scanning; pDCapsDef scaps = &dev->usbDev.Caps; @@ -1632,7 +1627,7 @@ static int usb_DoCalibration( pPlustek_Device dev ) /*............................................................................. * */ -static Bool usb_DownloadShadingData( pPlustek_Device dev, u_char bJobID ) +static SANE_Bool usb_DownloadShadingData( pPlustek_Device dev, u_char bJobID ) { pHWDef hw = &dev->usbDev.HwSetting; diff --git a/backend/plustek.c b/backend/plustek.c index 972f2e1e2..b9c27cb62 100644 --- a/backend/plustek.c +++ b/backend/plustek.c @@ -48,6 +48,7 @@ * fixed a problem with the "size-sliders" * fixed a bug that causes segfault when using the autodetection for USB * devices + * added OS/2 switch to disable the USB stuff for OS/2 * *............................................................................. * @@ -105,6 +106,7 @@ #include #include #include +#include #include #include @@ -119,8 +121,10 @@ #include "sane/sanei_backend.h" #include "sane/sanei_config.h" -/* might be used to disable all USB stuff */ -#define _PLUSTEK_USB +/* might be used to disable all USB stuff - esp. for OS/2 */ +#ifndef HAVE_OS2_H +# define _PLUSTEK_USB +#endif #include "plustek-share.h" #ifdef _PLUSTEK_USB diff --git a/backend/plustek.h b/backend/plustek.h index a84a93441..9a02adf2e 100644 --- a/backend/plustek.h +++ b/backend/plustek.h @@ -168,7 +168,6 @@ typedef struct Plustek_Device SANE_Int res_list_size; /* resolution values */ ScannerCaps caps; /* caps reported by the driver */ AdjDef adj; /* for driver adjustment */ - struct itimerval saveSettings; /* for lamp timer */ /**************************** USB-stuff **********************************/ char usbId[_MAX_ID_LEN];/* to keep Vendor and product */ @@ -177,6 +176,7 @@ typedef struct Plustek_Device ScanDef scanning; /* here we hold all stuff for */ /* the USB-scanner */ DeviceDef usbDev; + struct itimerval saveSettings; /* for lamp timer */ #endif /*