merge-requests/1/head
Gerhard Jaeger 2005-08-15 14:55:24 +00:00
rodzic b3d68531d4
commit 3290aae207
7 zmienionych plików z 190 dodań i 187 usunięć

Wyświetl plik

@ -37,6 +37,7 @@
* to struct DeviceDef * to struct DeviceDef
* - added CRYSTAL_FREQ * - added CRYSTAL_FREQ
* - added IPCDef * - added IPCDef
* - 0.50 - cleanup
* . * .
* <hr> * <hr>
* This file is part of the SANE package. * This file is part of the SANE package.
@ -117,56 +118,56 @@ typedef struct {
u_char Red; u_char Red;
u_char Green; u_char Green;
u_char Blue; u_char Blue;
} RGBByteDef, *pRGBByteDef; } RGBByteDef;
typedef struct { typedef struct {
u_short Red; u_short Red;
u_short Green; u_short Green;
u_short Blue; u_short Blue;
} RGBUShortDef, *pRGBUShortDef; } RGBUShortDef;
typedef struct { typedef struct {
u_long Red; u_long Red;
u_long Green; u_long Green;
u_long Blue; u_long Blue;
} RGBULongDef, *pRGBULongDef; } RGBULongDef;
typedef struct { typedef struct {
u_char a_bColor[3]; u_char a_bColor[3];
} ColorByteDef, *pColorByteDef; } ColorByteDef;
typedef struct { typedef struct {
u_char bHi; u_char bHi;
u_char bLo; u_char bLo;
} HiLoDef, *pHiLoDef; } HiLoDef;
typedef union { typedef union {
HiLoDef HiLo[3]; HiLoDef HiLo[3];
u_short Colors[3]; u_short Colors[3];
} ColorWordDef, *pColorWordDef; } ColorWordDef;
typedef union { typedef union {
HiLoDef HiLo; HiLoDef HiLo;
u_short Mono; u_short Mono;
} MonoWordDef, *pMonoWordDef; } MonoWordDef;
typedef union { typedef union {
u_char *pb; u_char *pb;
u_short *pw; u_short *pw;
pMonoWordDef pmw; MonoWordDef *pmw;
pColorByteDef pcb; ColorByteDef *pcb;
pColorWordDef pcw; ColorWordDef *pcw;
pRGBByteDef pb_rgb; RGBByteDef *pb_rgb;
pRGBUShortDef pw_rgb; RGBUShortDef *pw_rgb;
pHiLoDef philo; HiLoDef *philo;
} AnyPtr, *pAnyPtr; } AnyPtr;
typedef struct { typedef struct {
unsigned short x; unsigned short x;
unsigned short y; unsigned short y;
} XY, *pXY; } XY;
#define _VAR_NOT_USED(x) ((x)=(x)) #define _VAR_NOT_USED(x) ((x)=(x))
@ -330,8 +331,8 @@ enum SCANFLAG
typedef struct Origins typedef struct Origins
{ {
long lLeft; /* How many pix to move the scanning org left, in optic res */ long lLeft; /* How many pix to move the scanning org left, in optic res */
long lUp; /* How many pix to move the scanning or up, in optic res */ long lUp; /* How many pix to move the scanning or up, in optic res */
} OrgDef, *pOrgDef; } OrgDef;
typedef struct SrcAttr typedef struct SrcAttr
{ {
@ -345,7 +346,7 @@ typedef struct SrcAttr
XY MinDpi; /**< Minimum dpi supported for scanning */ XY MinDpi; /**< Minimum dpi supported for scanning */
u_char bMinDataType; /**< Minimum data type supports */ u_char bMinDataType; /**< Minimum data type supports */
} SrcAttrDef, *pSrcAttrDef; } SrcAttrDef;
typedef struct DevCaps typedef struct DevCaps
{ {
@ -365,7 +366,7 @@ typedef struct DevCaps
/* _WORKAROUNDS */ /* _WORKAROUNDS */
u_long lamp; /**< for lamp: loword: normal, hiword: tpa */ u_long lamp; /**< for lamp: loword: normal, hiword: tpa */
} DCapsDef, *pDCapsDef; } DCapsDef;
/** /**
* for keeping intial illumination settings * for keeping intial illumination settings
@ -381,7 +382,7 @@ typedef struct
u_short blue_lamp_on; u_short blue_lamp_on;
u_short blue_lamp_off; u_short blue_lamp_off;
} IllumiDef, *pIllumiDef; } IllumiDef;
/** basic register settings /** basic register settings
@ -400,7 +401,7 @@ typedef struct HWDefault
u_short wGreenPWMDutyCycleLow; u_short wGreenPWMDutyCycleLow;
u_short wGreenPWMDutyCycleHigh; u_short wGreenPWMDutyCycleHigh;
/* Registers */ /* Registers */
u_char bSensorConfiguration; /* 0x0b */ u_char bSensorConfiguration; /* 0x0b */
/* Sensor control settings */ /* Sensor control settings */
u_char bReg_0x0c; u_char bReg_0x0c;
u_char bReg_0x0d; u_char bReg_0x0d;
@ -463,7 +464,7 @@ typedef struct HWDefault
eChipDef chip; /* chiptype */ eChipDef chip; /* chiptype */
eModelDef motorModel; /* to identify used motor */ eModelDef motorModel; /* to identify used motor */
double gamma; /* gamma setting */ double gamma; /* gamma setting */
} HWDef, *pHWDef; } HWDef;
/** device description during runtime /** device description during runtime
*/ */
@ -474,7 +475,7 @@ typedef struct DeviceDef
int product; /**< product ID */ int product; /**< product ID */
DCapsDef Caps; /**< pointer to the attribute of current dev */ DCapsDef Caps; /**< pointer to the attribute of current dev */
HWDef HwSetting; /**< Pointer to the characteristics of device */ HWDef HwSetting; /**< Pointer to the characteristics of device */
pSrcAttrDef pSource; /**< Scanning src, it's equal to Caps.Normal */ SrcAttrDef *pSource; /**< Scanning src, it's equal to Caps.Normal */
/**< on the source that the user specified. */ /**< on the source that the user specified. */
OrgDef Normal; /**< Reflection - Pix to adjust scanning orgs */ OrgDef Normal; /**< Reflection - Pix to adjust scanning orgs */
OrgDef Positive; /**< Pos film - Pix to adjust scanning orgs */ OrgDef Positive; /**< Pos film - Pix to adjust scanning orgs */
@ -488,17 +489,17 @@ typedef struct DeviceDef
SANE_Bool fLastScanIsAdf;/**< */ SANE_Bool fLastScanIsAdf;/**< */
u_char a_bRegs[0x80]; /**< our global register file */ u_char a_bRegs[0x80]; /**< our global register file */
} DeviceDef, *pDeviceDef; } DeviceDef;
typedef struct Settings typedef struct Settings
{ {
char *pIDString; char *pIDString;
pDCapsDef pDevCaps; DCapsDef *pDevCaps;
pHWDef pHwDef; HWDef *pHwDef;
char *pModelString; char *pModelString;
} SetDef, *pSetDef; } SetDef;
/** /**
*/ */
@ -517,7 +518,7 @@ typedef struct
/* request dpi (CCD lines distance) */ /* request dpi (CCD lines distance) */
u_long dwTotalBytes; /**< Total bytes per scan */ u_long dwTotalBytes; /**< Total bytes per scan */
} WinInfo, *pWinInfo; } WinInfo;
/** /**
*/ */
@ -554,7 +555,7 @@ typedef struct
int swOffset[3]; /**< for calibration adjustment */ int swOffset[3]; /**< for calibration adjustment */
int swGain[3]; /**< for calibration adjustment */ int swGain[3]; /**< for calibration adjustment */
} ScanParam, *pScanParam; } ScanParam;
struct Plustek_Device; struct Plustek_Device;
@ -605,7 +606,7 @@ typedef struct ScanDef
u_char bLinesToSkip; /**< how many lines to skip at start */ u_char bLinesToSkip; /**< how many lines to skip at start */
} ScanDef, *pScanDef; } ScanDef;
/** max number of different colck settings */ /** max number of different colck settings */
@ -619,7 +620,7 @@ typedef struct
u_char pwm_duty; /**< PWM duty cycles */ u_char pwm_duty; /**< PWM duty cycles */
u_char scan_lines_per_line; /**< lines to scan to obtain 1 real line u_char scan_lines_per_line; /**< lines to scan to obtain 1 real line
will be used in 16bit color modes only */ will be used in 16bit color modes only */
} MDef, *pMDef; } MDef;
/** according to the CCD and motor, we provide various settings /** according to the CCD and motor, we provide various settings
*/ */
@ -645,7 +646,7 @@ typedef struct {
double gray_mclk_8[_MAX_CLK]; /**< MCLK settings for gray scan */ double gray_mclk_8[_MAX_CLK]; /**< MCLK settings for gray scan */
double gray_mclk_16[_MAX_CLK]; /**< MCLK settings for gray (16bit) scan */ double gray_mclk_16[_MAX_CLK]; /**< MCLK settings for gray (16bit) scan */
} ClkMotorDef, *pClkMotorDef; } ClkMotorDef;
/** for transferring some info between child and parent after calibration /** for transferring some info between child and parent after calibration
*/ */

Wyświetl plik

@ -13,6 +13,7 @@
* - 0.47 - no changes * - 0.47 - no changes
* - 0.48 - no changes * - 0.48 - no changes
* - 0.49 - a_bRegs is now part of the device structure * - 0.49 - a_bRegs is now part of the device structure
* - 0.50 - cleanup
* . * .
* <hr> * <hr>
* This file is part of the SANE package. * This file is part of the SANE package.
@ -205,11 +206,11 @@ static void usb_RestoreCalData( Plustek_Device *dev, CalData *cal )
/** /**
*/ */
static void usb_CreatePrefix( pPlustek_Device dev, char *pfx ) static void usb_CreatePrefix( Plustek_Device *dev, char *pfx )
{ {
char bd[5]; char bd[5];
pScanDef scanning = &dev->scanning; ScanDef *scanning = &dev->scanning;
pScanParam param = &scanning->sParam; ScanParam *param = &scanning->sParam;
switch( scanning->sParam.bSource ) { switch( scanning->sParam.bSource ) {
@ -332,7 +333,7 @@ static void usb_PrepCalData( Plustek_Device *dev, CalData *cal )
/** function to save/update the calibration data /** function to save/update the calibration data
*/ */
static void usb_SaveCalData( pPlustek_Device dev ) static void usb_SaveCalData( Plustek_Device *dev )
{ {
char pfx[20]; char pfx[20];
char tmp[1024]; char tmp[1024];
@ -341,7 +342,7 @@ static void usb_SaveCalData( pPlustek_Device dev )
u_short version; u_short version;
FILE *fp; FILE *fp;
CalData cal; CalData cal;
pScanDef scanning = &dev->scanning; ScanDef *scanning = &dev->scanning;
DBG( _DBG_INFO, "usb_SaveCalData()\n" ); DBG( _DBG_INFO, "usb_SaveCalData()\n" );
@ -362,14 +363,14 @@ static void usb_SaveCalData( pPlustek_Device dev )
usb_CreatePrefix( dev, pfx ); usb_CreatePrefix( dev, pfx );
sprintf( set_tmp, "%s%u,%u,%u,%u,%u,%u," sprintf( set_tmp, "%s%u,%u,%u,%u,%u,%u,"
"%lu,%lu,%lu,%lu,%lu,%lu,%lu\n", pfx, "%lu,%lu,%lu,%lu,%lu,%lu,%lu\n", pfx,
cal.red_gain, cal.red_offs, cal.red_gain, cal.red_offs,
cal.green_gain, cal.green_offs, cal.green_gain, cal.green_offs,
cal.blue_gain, cal.blue_offs, cal.blue_gain, cal.blue_offs,
cal.light.red_light_on, cal.light.red_light_off, cal.light.red_light_on, cal.light.red_light_off,
cal.light.green_light_on, cal.light.green_light_off, cal.light.green_light_on, cal.light.green_light_off,
cal.light.blue_light_on, cal.light.blue_light_off, cal.light.blue_light_on, cal.light.blue_light_off,
cal.light.green_pwm_duty ); cal.light.green_pwm_duty );
/* read complete old file if compatible... */ /* read complete old file if compatible... */
other_tmp = NULL; other_tmp = NULL;

Wyświetl plik

@ -51,6 +51,7 @@
* - cleanup * - cleanup
* - 0.49 - tweaked motor settings for EPSON and CANON1200 * - 0.49 - tweaked motor settings for EPSON and CANON1200
* - added support for CanoScan LiDE25 * - added support for CanoScan LiDE25
* - 0.50 - cleanup
* . * .
* <hr> * <hr>
* This file is part of the SANE package. * This file is part of the SANE package.
@ -240,7 +241,7 @@ static DCapsDef Cap0x07B3_0x0005_4 =
{1200, 1200}, {1200, 1200},
0, 0,
SENSORORDER_rgb, SENSORORDER_rgb,
12, 5, kNEC3778, 0x05, _WAF_NONE, _NO_MIO 12, 5, kNEC3778, 0x05, _WAF_NONE, _NO_MIO
}; };
/* Plustek Model: ???, Genius ColorPage HR6A /* Plustek Model: ???, Genius ColorPage HR6A

Wyświetl plik

@ -29,6 +29,7 @@
* - added usb_BWScaleFromColor() and usb_BWDuplicateFromColor * - added usb_BWScaleFromColor() and usb_BWDuplicateFromColor
* - cleanup * - cleanup
* - 0.49 - a_bRegs is now part of the device structure * - 0.49 - a_bRegs is now part of the device structure
* - 0.50 - cleanup
* . * .
* <hr> * <hr>
* This file is part of the SANE package. * This file is part of the SANE package.
@ -200,7 +201,7 @@ static void usb_ReverseBitStream( u_char *pSrc, u_char *pTar, int iPixels,
static void usb_AverageColorByte( Plustek_Device *dev ) static void usb_AverageColorByte( Plustek_Device *dev )
{ {
u_long dw; u_long dw;
pScanDef scan = &dev->scanning; ScanDef *scan = &dev->scanning;
if((scan->sParam.bSource == SOURCE_Negative || if((scan->sParam.bSource == SOURCE_Negative ||
scan->sParam.bSource == SOURCE_Transparency) && scan->sParam.bSource == SOURCE_Transparency) &&
@ -229,7 +230,7 @@ static void usb_AverageColorWord( Plustek_Device *dev )
{ {
u_char ls = 2; u_char ls = 2;
u_long dw; u_long dw;
pScanDef scan = &dev->scanning; ScanDef *scan = &dev->scanning;
if((scan->sParam.bSource == SOURCE_Negative || if((scan->sParam.bSource == SOURCE_Negative ||
scan->sParam.bSource == SOURCE_Transparency) && scan->sParam.bSource == SOURCE_Transparency) &&
@ -268,7 +269,7 @@ static void usb_AverageColorWord( Plustek_Device *dev )
static void usb_AverageGrayByte( Plustek_Device *dev ) static void usb_AverageGrayByte( Plustek_Device *dev )
{ {
u_long dw; u_long dw;
pScanDef scan = &dev->scanning; ScanDef *scan = &dev->scanning;
if((scan->sParam.bSource == SOURCE_Negative || if((scan->sParam.bSource == SOURCE_Negative ||
scan->sParam.bSource == SOURCE_Transparency) && scan->sParam.bSource == SOURCE_Transparency) &&
@ -285,7 +286,7 @@ static void usb_AverageGrayByte( Plustek_Device *dev )
static void usb_AverageGrayWord( Plustek_Device *dev ) static void usb_AverageGrayWord( Plustek_Device *dev )
{ {
u_long dw; u_long dw;
pScanDef scan = &dev->scanning; ScanDef *scan = &dev->scanning;
if((scan->sParam.bSource == SOURCE_Negative || if((scan->sParam.bSource == SOURCE_Negative ||
scan->sParam.bSource == SOURCE_Transparency) && scan->sParam.bSource == SOURCE_Transparency) &&
@ -442,13 +443,13 @@ static void usb_ColorDuplicate16_2( Plustek_Device *dev )
for( dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) { for( dw = 0; dw < scan->sParam.Size.dwPixels; dw++, pixels += next) {
if( swap ) { if( swap ) {
tmp = *((pHiLoDef)&scan->Red.pw[dw]); tmp = *((HiLoDef*)&scan->Red.pw[dw]);
scan->UserBuf.pw_rgb[pixels].Red = _HILO2WORD(tmp) >> ls; scan->UserBuf.pw_rgb[pixels].Red = _HILO2WORD(tmp) >> ls;
tmp = *((pHiLoDef)&scan->Green.pw[dw]); tmp = *((HiLoDef*)&scan->Green.pw[dw]);
scan->UserBuf.pw_rgb[pixels].Green = _HILO2WORD(tmp) >> ls; scan->UserBuf.pw_rgb[pixels].Green = _HILO2WORD(tmp) >> ls;
tmp = *((pHiLoDef)&scan->Blue.pw[dw]); tmp = *((HiLoDef*)&scan->Blue.pw[dw]);
scan->UserBuf.pw_rgb[pixels].Blue = _HILO2WORD(tmp) >> ls; scan->UserBuf.pw_rgb[pixels].Blue = _HILO2WORD(tmp) >> ls;
} else { } else {
@ -721,7 +722,7 @@ static void usb_GrayDuplicatePseudo16( Plustek_Device *dev )
*/ */
static void usb_BWDuplicate( Plustek_Device *dev ) static void usb_BWDuplicate( Plustek_Device *dev )
{ {
pScanDef scan = &dev->scanning; ScanDef *scan = &dev->scanning;
if(scan->sParam.bSource == SOURCE_ADF) if(scan->sParam.bSource == SOURCE_ADF)
{ {
@ -1126,13 +1127,13 @@ static void usb_ColorScale16_2( Plustek_Device *dev )
if( swap ) { if( swap ) {
tmp = *((pHiLoDef)&scan->Red.pw[bitsput]); tmp = *((HiLoDef*)&scan->Red.pw[bitsput]);
scan->UserBuf.pw_rgb[pixels].Red = _HILO2WORD(tmp) >> ls; scan->UserBuf.pw_rgb[pixels].Red = _HILO2WORD(tmp) >> ls;
tmp = *((pHiLoDef)&scan->Green.pw[bitsput]); tmp = *((HiLoDef*)&scan->Green.pw[bitsput]);
scan->UserBuf.pw_rgb[pixels].Green = _HILO2WORD(tmp) >> ls; scan->UserBuf.pw_rgb[pixels].Green = _HILO2WORD(tmp) >> ls;
tmp = *((pHiLoDef)&scan->Blue.pw[bitsput]); tmp = *((HiLoDef*)&scan->Blue.pw[bitsput]);
scan->UserBuf.pw_rgb[pixels].Blue = _HILO2WORD(tmp) >> ls; scan->UserBuf.pw_rgb[pixels].Blue = _HILO2WORD(tmp) >> ls;
} else { } else {

Wyświetl plik

@ -20,6 +20,7 @@
* - 0.47 - cleanup work * - 0.47 - cleanup work
* - 0.48 - added support for binary from color scans * - 0.48 - added support for binary from color scans
* - 0.49 - changed usb_MapDownload * - 0.49 - changed usb_MapDownload
* - 0.50 - cleanup
* . * .
* <hr> * <hr>
* This file is part of the SANE package. * This file is part of the SANE package.
@ -115,8 +116,8 @@ static void usb_MapAdjust( Plustek_Device *dev )
*/ */
static SANE_Bool usb_MapDownload( Plustek_Device *dev ) static SANE_Bool usb_MapDownload( Plustek_Device *dev )
{ {
pScanDef scanning = &dev->scanning; ScanDef *scanning = &dev->scanning;
pDCapsDef sc = &dev->usbDev.Caps; DCapsDef *sc = &dev->usbDev.Caps;
int color; int color;
int i, threshold; int i, threshold;
@ -194,8 +195,8 @@ static SANE_Bool usb_MapDownload( Plustek_Device *dev )
} else { } else {
DBG( _DBG_INFO, "* downloading map %u...\n", color ); DBG( _DBG_INFO, "* downloading map %u...\n", color );
sanei_lm983x_write( dev->fd, 0x06, a_bMap+color*_MAP_SIZE, sanei_lm983x_write( dev->fd, 0x06, a_bMap+color*_MAP_SIZE,
_MAP_SIZE, SANE_FALSE ); _MAP_SIZE, SANE_FALSE );
} }
} /* for each color */ } /* for each color */

Wyświetl plik

@ -27,6 +27,7 @@
* - 0.49 - a_bRegs is now part of the device structure * - 0.49 - a_bRegs is now part of the device structure
* - using now PhyDpi.y as selector for the motor MCLK range * - using now PhyDpi.y as selector for the motor MCLK range
* - changed usb_MapDownload prototype * - changed usb_MapDownload prototype
* - 0.50 - cleanup
* . * .
* <hr> * <hr>
* This file is part of the SANE package. * This file is part of the SANE package.
@ -79,7 +80,7 @@ static SANE_Bool m_fAutoPark;
static SANE_Bool m_fFirst; static SANE_Bool m_fFirst;
static double m_dHDPIDivider; static double m_dHDPIDivider;
static double m_dMCLKDivider; static double m_dMCLKDivider;
static pScanParam m_pParam; static ScanParam *m_pParam;
static u_char m_bLineRateColor; static u_char m_bLineRateColor;
static u_char m_bCM; static u_char m_bCM;
static u_char m_bIntTimeAdjust; static u_char m_bIntTimeAdjust;
@ -103,7 +104,6 @@ static u_long usb_min( u_long val1, u_long val2 )
{ {
if( val1 > val2 ) if( val1 > val2 )
return val2; return val2;
return val1; return val1;
} }
@ -116,7 +116,6 @@ static u_long usb_max( u_long val1, u_long val2 )
{ {
if( val1 > val2 ) if( val1 > val2 )
return val1; return val1;
return val2; return val2;
} }
@ -132,13 +131,12 @@ static u_long usb_max( u_long val1, u_long val2 )
static u_short usb_SetAsicDpiX( Plustek_Device *dev, u_short xdpi ) static u_short usb_SetAsicDpiX( Plustek_Device *dev, u_short xdpi )
{ {
u_short res; u_short res;
pScanDef scanning = &dev->scanning; ScanDef *scanning = &dev->scanning;
pDCapsDef scaps = &dev->usbDev.Caps; DCapsDef *scaps = &dev->usbDev.Caps;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
/* /* limit xdpi to lower value for certain devices...
* limit xdpi to lower value for certain devices... */
*/
if( scaps->OpticDpi.x == 1200 && if( scaps->OpticDpi.x == 1200 &&
scanning->sParam.bDataType != SCANDATATYPE_Color && scanning->sParam.bDataType != SCANDATATYPE_Color &&
xdpi < 150 && xdpi < 150 &&
@ -198,7 +196,6 @@ static u_short usb_SetAsicDpiX( Plustek_Device *dev, u_short xdpi )
res = (u_short)((double)scaps->OpticDpi.x / m_dHDPIDivider); res = (u_short)((double)scaps->OpticDpi.x / m_dHDPIDivider);
DBG( _DBG_INFO2, "* XDPI=%u, HDPI=%.3f\n", res, m_dHDPIDivider ); DBG( _DBG_INFO2, "* XDPI=%u, HDPI=%.3f\n", res, m_dHDPIDivider );
return res; return res;
} }
@ -210,11 +207,11 @@ static u_short usb_SetAsicDpiX( Plustek_Device *dev, u_short xdpi )
*/ */
static u_short usb_SetAsicDpiY( Plustek_Device *dev, u_short ydpi ) static u_short usb_SetAsicDpiY( Plustek_Device *dev, u_short ydpi )
{ {
pScanDef scanning = &dev->scanning; ScanDef *scanning = &dev->scanning;
pDCapsDef sCaps = &dev->usbDev.Caps; DCapsDef *sCaps = &dev->usbDev.Caps;
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_short wMinDpi, wDpi; u_short wMinDpi, wDpi;
if(0 != sCaps->bSensorDistance ) if(0 != sCaps->bSensorDistance )
wMinDpi = sCaps->OpticDpi.y / sCaps->bSensorDistance; wMinDpi = sCaps->OpticDpi.y / sCaps->bSensorDistance;
@ -260,14 +257,12 @@ static u_short usb_SetAsicDpiY( Plustek_Device *dev, u_short ydpi )
* @param pParam - pointer to the current scan parameters * @param pParam - pointer to the current scan parameters
* @return - Nothing * @return - Nothing
*/ */
static void usb_SetColorAndBits( Plustek_Device *dev, pScanParam pParam ) static void usb_SetColorAndBits( Plustek_Device *dev, ScanParam *pParam )
{ {
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
/* /* Set pixel packing, data mode and AFE operation */
* Set pixel packing, data mode and AFE operation
*/
switch( pParam->bDataType ) { switch( pParam->bDataType ) {
case SCANDATATYPE_Color: case SCANDATATYPE_Color:
m_bCM = 3; m_bCM = 3;
@ -318,12 +313,12 @@ static void usb_SetColorAndBits( Plustek_Device *dev, pScanParam pParam )
* @param pParam - pointer to the current scan parameters * @param pParam - pointer to the current scan parameters
* @return - Nothing * @return - Nothing
*/ */
static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam ) static void usb_GetScanRect( Plustek_Device *dev, ScanParam *pParam )
{ {
u_short wDataPixelStart, wLineEnd; u_short wDataPixelStart, wLineEnd;
pDCapsDef sCaps = &dev->usbDev.Caps; DCapsDef *sCaps = &dev->usbDev.Caps;
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
/* Convert pixels to physical dpi based */ /* Convert pixels to physical dpi based */
@ -348,19 +343,19 @@ static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam )
{ {
/* Pixels should be times of 16 */ /* Pixels should be times of 16 */
pParam->Size.dwPhyPixels = pParam->Size.dwPhyPixels =
(pParam->Size.dwValidPixels + 15UL) & 0xfffffff0UL; (pParam->Size.dwValidPixels + 15UL) & 0xfffffff0UL;
pParam->Size.dwPhyBytes = pParam->Size.dwPhyPixels / 8UL + 2UL; pParam->Size.dwPhyBytes = pParam->Size.dwPhyPixels / 8UL + 2UL;
} }
else if (pParam->bBitDepth == 8) else if (pParam->bBitDepth == 8)
{ {
/* Pixels should be times of 2 */ /* Pixels should be times of 2 */
pParam->Size.dwPhyPixels = pParam->Size.dwPhyPixels =
(pParam->Size.dwValidPixels + 1UL) & 0xfffffffeUL; (pParam->Size.dwValidPixels + 1UL) & 0xfffffffeUL;
pParam->Size.dwPhyBytes = pParam->Size.dwPhyBytes =
pParam->Size.dwPhyPixels * pParam->bChannels + 2UL; pParam->Size.dwPhyPixels * pParam->bChannels + 2UL;
if((hw->bReg_0x26 & _ONE_CH_COLOR) && if((hw->bReg_0x26 & _ONE_CH_COLOR) &&
(pParam->bDataType == SCANDATATYPE_Color)) { (pParam->bDataType == SCANDATATYPE_Color)) {
pParam->Size.dwPhyBytes *= 3; pParam->Size.dwPhyBytes *= 3;
} }
} }
@ -368,17 +363,17 @@ static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam )
{ {
pParam->Size.dwPhyPixels = pParam->Size.dwValidPixels; pParam->Size.dwPhyPixels = pParam->Size.dwValidPixels;
pParam->Size.dwPhyBytes = pParam->Size.dwPhyBytes =
pParam->Size.dwPhyPixels * 2 * pParam->bChannels + 2UL; pParam->Size.dwPhyPixels * 2 * pParam->bChannels + 2UL;
if((hw->bReg_0x26 & _ONE_CH_COLOR) && if((hw->bReg_0x26 & _ONE_CH_COLOR) &&
(pParam->bDataType == SCANDATATYPE_Color)) { (pParam->bDataType == SCANDATATYPE_Color)) {
pParam->Size.dwPhyBytes *= 3; pParam->Size.dwPhyBytes *= 3;
} }
} }
/* Compute data start pixel */ /* Compute data start pixel */
wDataPixelStart = (u_short)((u_long)pParam->Origin.x * wDataPixelStart = (u_short)((u_long)pParam->Origin.x *
sCaps->OpticDpi.x / 300UL); sCaps->OpticDpi.x / 300UL);
/* during the calibration steps, we read the entire CCD data /* during the calibration steps, we read the entire CCD data
*/ */
@ -388,7 +383,7 @@ static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam )
#if 0 #if 0
if(ScanInf.m_fADF) { if(ScanInf.m_fADF) {
wDataPixelStart = 2550 * sCaps->OpticDpi.x / 300UL - wDataPixelStart = 2550 * sCaps->OpticDpi.x / 300UL -
(u_short)(m_dHDPIDivider * pParam->Size.dwValidPixels + 0.5); (u_short)(m_dHDPIDivider * pParam->Size.dwValidPixels + 0.5);
} }
#endif #endif
wDataPixelStart += hw->wActivePixelsStart; wDataPixelStart += hw->wActivePixelsStart;
@ -470,7 +465,7 @@ static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam )
*/ */
if (pParam->bDataType != SCANDATATYPE_Color) if (pParam->bDataType != SCANDATATYPE_Color)
pParam->Origin.y += (u_long)(300UL * pParam->Origin.y += (u_long)(300UL *
sCaps->bSensorDistance / sCaps->OpticDpi.y); sCaps->bSensorDistance / sCaps->OpticDpi.y);
} }
pParam->Origin.y=(u_short)((u_long)pParam->Origin.y * hw->wMotorDpi/300UL); pParam->Origin.y=(u_short)((u_long)pParam->Origin.y * hw->wMotorDpi/300UL);
@ -479,7 +474,8 @@ static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam )
if( hw->motorModel == MODEL_HuaLien && sCaps->OpticDpi.x == 600) if( hw->motorModel == MODEL_HuaLien && sCaps->OpticDpi.x == 600)
pParam->Origin.y = pParam->Origin.y * 297 / 298; pParam->Origin.y = pParam->Origin.y * 297 / 298;
DBG(_DBG_INFO2,"* Full Steps to Skip at Start = 0x%04x\n",pParam->Origin.y); DBG(_DBG_INFO2,"* Full Steps to Skip at Start = 0x%04x\n",
pParam->Origin.y);
regs[0x4a] = _HIBYTE( pParam->Origin.y ); regs[0x4a] = _HIBYTE( pParam->Origin.y );
regs[0x4b] = _LOBYTE( pParam->Origin.y ); regs[0x4b] = _LOBYTE( pParam->Origin.y );
@ -487,11 +483,11 @@ static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam )
/** preset scan stepsize and fastfeed stepsize /** preset scan stepsize and fastfeed stepsize
*/ */
static void usb_PresetStepSize( Plustek_Device *dev, pScanParam pParam ) static void usb_PresetStepSize( Plustek_Device *dev, ScanParam *pParam )
{ {
u_short ssize; u_short ssize;
double mclkdiv = pParam->dMCLK; double mclkdiv = pParam->dMCLK;
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
ssize = (u_short)((double)CRYSTAL_FREQ / ( mclkdiv * 8.0 * ssize = (u_short)((double)CRYSTAL_FREQ / ( mclkdiv * 8.0 *
@ -511,43 +507,43 @@ static void usb_GetDPD( Plustek_Device *dev )
{ {
int qtcnt; /* quarter speed count count reg 51 b2..3 */ int qtcnt; /* quarter speed count count reg 51 b2..3 */
int hfcnt; /* half speed count reg 51 b0..1 */ int hfcnt; /* half speed count reg 51 b0..1 */
int strev; /* steps to reverse reg 50 */ int strev; /* steps to reverse reg 50 */
int dpd; /* calculated dpd reg 52:53 */ int dpd; /* calculated dpd reg 52:53 */
int st; /* step size reg 46:47 */ int st; /* step size reg 46:47 */
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
qtcnt = (regs[0x51] & 0x30) >> 4; /* quarter speed count */ qtcnt = (regs[0x51] & 0x30) >> 4; /* quarter speed count */
hfcnt = (regs[0x51] & 0xc0) >> 6; /* half speed count */ hfcnt = (regs[0x51] & 0xc0) >> 6; /* half speed count */
if( _LM9831 == hw->chip ) if( _LM9831 == hw->chip )
strev = regs[0x50] & 0x3f; /* steps to reverse */ strev = regs[0x50] & 0x3f; /* steps to reverse */
else /* LM9832/3 */ else /* LM9832/3 */
{ {
if (qtcnt == 3) if (qtcnt == 3)
qtcnt = 8; qtcnt = 8;
if (hfcnt == 3) if (hfcnt == 3)
hfcnt = 8; hfcnt = 8;
strev = regs[0x50]; /* steps to reverse */ strev = regs[0x50]; /* steps to reverse */
} }
st = regs[0x46] * 256 + regs[0x47]; /* scan step size */ st = regs[0x46] * 256 + regs[0x47]; /* scan step size */
if (m_wLineLength == 0) if (m_wLineLength == 0)
dpd = 0; dpd = 0;
else else
{ {
dpd = (((qtcnt * 4) + (hfcnt * 2) + strev) * 4 * st) % dpd = (((qtcnt * 4) + (hfcnt * 2) + strev) * 4 * st) %
(m_wLineLength * m_bLineRateColor); (m_wLineLength * m_bLineRateColor);
DBG( _DBG_INFO2, "* DPD =%u (0x%04x)\n", dpd, dpd ); DBG( _DBG_INFO2, "* DPD =%u (0x%04x)\n", dpd, dpd );
dpd = m_wLineLength * m_bLineRateColor - dpd; dpd = m_wLineLength * m_bLineRateColor - dpd;
} }
DBG( _DBG_INFO2, "* DPD =%u (0x%04x), step size=%u, steps2rev=%u\n", DBG( _DBG_INFO2, "* DPD =%u (0x%04x), step size=%u, steps2rev=%u\n",
dpd, dpd, st, strev); dpd, dpd, st, strev);
DBG( _DBG_INFO2, "* llen=%u, lineRateColor=%u, qtcnt=%u, hfcnt=%u\n", DBG( _DBG_INFO2, "* llen=%u, lineRateColor=%u, qtcnt=%u, hfcnt=%u\n",
m_wLineLength, m_bLineRateColor, qtcnt, hfcnt ); m_wLineLength, m_bLineRateColor, qtcnt, hfcnt );
regs[0x51] |= (u_char)((dpd >> 16) & 0x03); regs[0x51] |= (u_char)((dpd >> 16) & 0x03);
regs[0x52] = (u_char)(dpd >> 8); regs[0x52] = (u_char)(dpd >> 8);
@ -574,7 +570,7 @@ static int usb_GetMCLKDiv( Plustek_Device *dev )
if ((regs[0x26] & 7) == 0) if ((regs[0x26] & 7) == 0)
r = 24; /* pixel rate */ r = 24; /* pixel rate */
/*use high or low res min integration time */ /* use high or low res min integration time */
min_int_time = ((regs[0x9]&7) > 2 ? hw->dMinIntegrationTimeLowres: min_int_time = ((regs[0x9]&7) > 2 ? hw->dMinIntegrationTimeLowres:
hw->dMinIntegrationTimeHighres); hw->dMinIntegrationTimeHighres);
@ -631,13 +627,13 @@ static int usb_GetMCLKDiv( Plustek_Device *dev )
* at least we give the master clock divider and adjust the step size * at least we give the master clock divider and adjust the step size
* and integration time (for 14/16 bit modes) * and integration time (for 14/16 bit modes)
*/ */
static double usb_GetMCLKDivider( Plustek_Device *dev, pScanParam pParam ) static double usb_GetMCLKDivider( Plustek_Device *dev, ScanParam *pParam )
{ {
double dMaxIntegrationTime; double dMaxIntegrationTime;
double dMaxMCLKDivider; double dMaxMCLKDivider;
pDCapsDef sCaps = &dev->usbDev.Caps; DCapsDef *sCaps = &dev->usbDev.Caps;
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
DBG( _DBG_INFO, "usb_GetMCLKDivider()\n" ); DBG( _DBG_INFO, "usb_GetMCLKDivider()\n" );
@ -662,8 +658,8 @@ static double usb_GetMCLKDivider( Plustek_Device *dev, pScanParam pParam )
if( pParam->bBitDepth > 8 ) { if( pParam->bBitDepth > 8 ) {
while( pParam->Size.dwPhyBytes > while( pParam->Size.dwPhyBytes >
(m_dMCLKDivider * m_bCM * m_wLineLength / 6 * 9 / 10) * (m_dMCLKDivider * m_bCM * m_wLineLength / 6 * 9 / 10) *
(1 + m_bIntTimeAdjust)) { (1 + m_bIntTimeAdjust)) {
m_bIntTimeAdjust++; m_bIntTimeAdjust++;
} }
@ -694,7 +690,7 @@ static double usb_GetMCLKDivider( Plustek_Device *dev, pScanParam pParam )
if( m_bIntTimeAdjust != 0 ) { if( m_bIntTimeAdjust != 0 ) {
m_wStepSize = (u_short)((u_long) m_wStepSize * m_wStepSize = (u_short)((u_long) m_wStepSize *
(m_bIntTimeAdjust + 1) / m_bIntTimeAdjust); (m_bIntTimeAdjust + 1) / m_bIntTimeAdjust);
if( m_wStepSize < 2 ) if( m_wStepSize < 2 )
m_wStepSize = 2; m_wStepSize = 2;
@ -707,11 +703,11 @@ static double usb_GetMCLKDivider( Plustek_Device *dev, pScanParam pParam )
} }
/* Compute maximum MCLK divider base on maximum integration time for /* Compute maximum MCLK divider base on maximum integration time for
* high lamp PWM, use equation 4 * high lamp PWM, use equation 4
*/ */
dMaxIntegrationTime = hw->dIntegrationTimeHighLamp; dMaxIntegrationTime = hw->dIntegrationTimeHighLamp;
dMaxMCLKDivider = (double)CRYSTAL_FREQ * dMaxIntegrationTime / dMaxMCLKDivider = (double)CRYSTAL_FREQ * dMaxIntegrationTime /
(1000 * 8 * m_bCM * m_wLineLength); (1000 * 8 * m_bCM * m_wLineLength);
/* Determine lamp PWM setting */ /* Determine lamp PWM setting */
if( m_dMCLKDivider > dMaxMCLKDivider ) { if( m_dMCLKDivider > dMaxMCLKDivider ) {
@ -733,19 +729,19 @@ static double usb_GetMCLKDivider( Plustek_Device *dev, pScanParam pParam )
/** calculate the step size of each scan step /** calculate the step size of each scan step
*/ */
static void usb_GetStepSize( Plustek_Device *dev, pScanParam pParam ) static void usb_GetStepSize( Plustek_Device *dev, ScanParam *pParam )
{ {
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
/* Compute step size using equation 1 */ /* Compute step size using equation 1 */
if (m_bIntTimeAdjust != 0) { if (m_bIntTimeAdjust != 0) {
m_wStepSize = (u_short)(((u_long) pParam->PhyDpi.y * m_wLineLength * m_wStepSize = (u_short)(((u_long) pParam->PhyDpi.y * m_wLineLength *
m_bLineRateColor * (m_bIntTimeAdjust + 1)) / m_bLineRateColor * (m_bIntTimeAdjust + 1)) /
(4 * hw->wMotorDpi * m_bIntTimeAdjust)); (4 * hw->wMotorDpi * m_bIntTimeAdjust));
} else { } else {
m_wStepSize = (u_short)(((u_long) pParam->PhyDpi.y * m_wLineLength * m_wStepSize = (u_short)(((u_long) pParam->PhyDpi.y * m_wLineLength *
m_bLineRateColor) / (4 * hw->wMotorDpi)); m_bLineRateColor) / (4 * hw->wMotorDpi));
} }
if (m_wStepSize < 2) if (m_wStepSize < 2)
@ -765,7 +761,7 @@ static void usb_GetStepSize( Plustek_Device *dev, pScanParam pParam )
static void usb_GetLineLength( Plustek_Device *dev ) static void usb_GetLineLength( Plustek_Device *dev )
{ {
/* [note] /* [note]
* The ITA in this moment is always 0, it will be changed later when we * The ITA in this moment is always 0, it will be changed later when we
* calculate MCLK. This is very strange why this routine will not call * calculate MCLK. This is very strange why this routine will not call
* again to get all new value after ITA was changed? If this routine * again to get all new value after ITA was changed? If this routine
* never call again, maybe we remove all factor with ITA here. * never call again, maybe we remove all factor with ITA here.
@ -777,30 +773,30 @@ static void usb_GetLineLength( Plustek_Device *dev )
int dur; /* pulse duration reg 0e b0..3 */ int dur; /* pulse duration reg 0e b0..3 */
int ntr; /* number of tr pulses reg 0d b7 */ int ntr; /* number of tr pulses reg 0d b7 */
int afeop; /* scan mode, 0=pixel rate, 1=line rate, */ int afeop; /* scan mode, 0=pixel rate, 1=line rate, */
/* 4=1 channel mode a, 5=1 channel mode b, reg 26 b0..2 */ /* 4=1 channel mode a, 5=1 channel mode b, reg 26 b0..2 */
int ctmode; /* CIS tr timing mode reg 19 b0..1 */ int ctmode; /* CIS tr timing mode reg 19 b0..1 */
int tp; /* tpspd or 1 if tpsel=0 */ int tp; /* tpspd or 1 if tpsel=0 */
int b; /* if ctmode=0, (ntr+1)*((2*gbnd)+dur+1), otherwise 1 */ int b; /* if ctmode=0, (ntr+1)*((2*gbnd)+dur+1), otherwise 1 */
int tradj; /* ITA */ int tradj; /* ITA */
int en_tradj; int en_tradj;
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
tpspd = (regs[0x0a] & 0x0c) >> 2; /* turbo/preview mode speed */ tpspd = (regs[0x0a] & 0x0c) >> 2; /* turbo/preview mode speed */
tpsel = regs[0x0a] & 3; /* turbo/preview mode select */ tpsel = regs[0x0a] & 3; /* turbo/preview mode select */
gbnd = (regs[0x0e] & 0xf0) >> 4; /* TR fi1 guardband duration */ gbnd = (regs[0x0e] & 0xf0) >> 4; /* TR fi1 guardband duration */
dur = (regs[0x0e] & 0xf); /* TR pulse duration */ dur = (regs[0x0e] & 0xf); /* TR pulse duration */
ntr = regs[0x0d] / 128; /* number of tr pulses */ ntr = regs[0x0d] / 128; /* number of tr pulses */
afeop = regs[0x26] & 7; /* afe op - 3 channel or 1 channel */ afeop = regs[0x26] & 7; /* afe op - 3 channel or 1 channel */
tradj = regs[0x19] & 0x7f; /* integration time adjust */ tradj = regs[0x19] & 0x7f; /* integration time adjust */
en_tradj = (tradj) ? 1 : 0; en_tradj = (tradj) ? 1 : 0;
ctmode = (regs[0x0b] >> 3) & 3; /* cis tr timing mode */ ctmode = (regs[0x0b] >> 3) & 3; /* cis tr timing mode */
m_bLineRateColor = 1; m_bLineRateColor = 1;
if (afeop == 1 || afeop == 5) /* if 3 channel line or 1 channel mode b */ if (afeop == 1 || afeop == 5) /* if 3 channel line or 1 channel mode b */
@ -867,13 +863,13 @@ static void usb_GetLineLength( Plustek_Device *dev )
/** usb_GetMotorParam /** usb_GetMotorParam
* registers 0x56, 0x57 * registers 0x56, 0x57
*/ */
static void usb_GetMotorParam( Plustek_Device *dev, pScanParam pParam ) static void usb_GetMotorParam( Plustek_Device *dev, ScanParam *pParam )
{ {
int idx, i; int idx, i;
pClkMotorDef clk; ClkMotorDef *clk;
pMDef md; MDef *md;
pDCapsDef sCaps = &dev->usbDev.Caps; DCapsDef *sCaps = &dev->usbDev.Caps;
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
if( !_IS_PLUSTEKMOTOR(hw->motorModel)) { if( !_IS_PLUSTEKMOTOR(hw->motorModel)) {
@ -904,7 +900,7 @@ static void usb_GetMotorParam( Plustek_Device *dev, pScanParam pParam )
regs[0x44] = md[idx].scan_lines_per_line; regs[0x44] = md[idx].scan_lines_per_line;
DBG( _DBG_INFO2, "* Line Skipping : 0x43=0x%02x, 0x44=0x%02x\n", DBG( _DBG_INFO2, "* Line Skipping : 0x43=0x%02x, 0x44=0x%02x\n",
regs[0x43], regs[0x44] ); regs[0x43], regs[0x44] );
} }
} }
@ -1018,10 +1014,10 @@ static void usb_GetMotorParam( Plustek_Device *dev, pScanParam pParam )
/** /**
*/ */
static void usb_GetPauseLimit( Plustek_Device *dev, pScanParam pParam ) static void usb_GetPauseLimit( Plustek_Device *dev, ScanParam *pParam )
{ {
int coeffsize, scaler; int coeffsize, scaler;
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
scaler = 1; scaler = 1;
@ -1078,9 +1074,9 @@ static void usb_GetPauseLimit( Plustek_Device *dev, pScanParam pParam )
/** usb_GetScanLinesAndSize /** usb_GetScanLinesAndSize
*/ */
static void usb_GetScanLinesAndSize( Plustek_Device *dev, pScanParam pParam ) static void usb_GetScanLinesAndSize( Plustek_Device *dev, ScanParam *pParam )
{ {
pDCapsDef sCaps = &dev->usbDev.Caps; DCapsDef *sCaps = &dev->usbDev.Caps;
pParam->Size.dwPhyLines = (u_long)ceil((double) pParam->Size.dwLines * pParam->Size.dwPhyLines = (u_long)ceil((double) pParam->Size.dwLines *
pParam->PhyDpi.y / pParam->UserDpi.y); pParam->PhyDpi.y / pParam->UserDpi.y);
@ -1104,12 +1100,12 @@ static void usb_GetScanLinesAndSize( Plustek_Device *dev, pScanParam pParam )
/** function to preset/reset the merlin registers /** function to preset/reset the merlin registers
*/ */
static SANE_Bool usb_SetScanParameters( Plustek_Device *dev, pScanParam pParam ) static SANE_Bool usb_SetScanParameters( Plustek_Device *dev, ScanParam *pParam )
{ {
static u_char reg8, reg38[6], reg48[2]; static u_char reg8, reg38[6], reg48[2];
pScanParam pdParam = &dev->scanning.sParam; ScanParam *pdParam = &dev->scanning.sParam;
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
m_pParam = pParam; m_pParam = pParam;
@ -1207,8 +1203,8 @@ static SANE_Bool usb_SetScanParameters( Plustek_Device *dev, pScanParam pParam )
usb_GetScanLinesAndSize( dev, pParam ); usb_GetScanLinesAndSize( dev, pParam );
/* Pause limit should be bounded by total bytes to read /* Pause limit should be bounded by total bytes to read
* so that the chassis will not move too far. * so that the chassis will not move too far.
*/ */
usb_GetPauseLimit( dev, pParam ); usb_GetPauseLimit( dev, pParam );
/* For ADF .... */ /* For ADF .... */
@ -1248,16 +1244,17 @@ static SANE_Bool usb_SetScanParameters( Plustek_Device *dev, pScanParam pParam )
memset( &regs[0x03], 0, 3 ); memset( &regs[0x03], 0, 3 );
memset( &regs[0x5f], 0, 0x7f-0x5f+1 ); memset( &regs[0x5f], 0, 0x7f-0x5f+1 );
/* we limit the possible scansteps to avoid, that the sensors bumps
* against the scanbed
*/
if(pParam->bCalibration == PARAM_Scan && pParam->bSource != SOURCE_ADF) { if(pParam->bCalibration == PARAM_Scan && pParam->bSource != SOURCE_ADF) {
u_short scansteps = (u_short)ceil((double)(pParam->Size.dwPhyLines + 10)* u_short scansteps = (u_short)ceil((double)(pParam->Size.dwPhyLines + 10)*
hw->wMotorDpi / pParam->PhyDpi.y); hw->wMotorDpi / pParam->PhyDpi.y);
DBG( _DBG_INFO, "* Scansteps=%u (%lu*%u/%u)\n", scansteps, DBG( _DBG_INFO, "* Scansteps=%u (%lu*%u/%u)\n", scansteps,
pParam->Size.dwPhyLines, hw->wMotorDpi, pParam->PhyDpi.y ); pParam->Size.dwPhyLines, hw->wMotorDpi, pParam->PhyDpi.y );
#if 1
regs[0x4c] = _HIBYTE(scansteps); regs[0x4c] = _HIBYTE(scansteps);
regs[0x4d] = _LOBYTE(scansteps); regs[0x4d] = _LOBYTE(scansteps);
#endif
} }
/* set the merlin registers */ /* set the merlin registers */
@ -1279,8 +1276,8 @@ static SANE_Bool usb_ScanBegin( Plustek_Device *dev, SANE_Bool auto_park )
{ {
u_char value; u_char value;
u_short inches; u_short inches;
pHWDef hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
pDCapsDef sc = &dev->usbDev.Caps; DCapsDef *sc = &dev->usbDev.Caps;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;
DBG( _DBG_INFO, "usb_ScanBegin()\n" ); DBG( _DBG_INFO, "usb_ScanBegin()\n" );
@ -1328,10 +1325,10 @@ static SANE_Bool usb_ScanBegin( Plustek_Device *dev, SANE_Bool auto_park )
} }
/* Download map & Shading data */ /* Download map & Shading data */
if(( m_pParam->bCalibration == PARAM_Scan && if(( m_pParam->bCalibration == PARAM_Scan && !usb_MapDownload( dev )) ||
!usb_MapDownload( dev )) || !usb_DownloadShadingData( dev, m_pParam->bCalibration )) {
!usb_DownloadShadingData( dev, m_pParam->bCalibration ))
return SANE_FALSE; return SANE_FALSE;
}
/* Move chassis and start to read image data */ /* Move chassis and start to read image data */
if (!usbio_WriteReg( dev->fd, 0x07, 3 )) if (!usbio_WriteReg( dev->fd, 0x07, 3 ))
@ -1525,7 +1522,7 @@ static SANE_Bool usb_ScanReadImage( Plustek_Device *dev,
/** calculate the number of pixels per line and lines out of a given /** calculate the number of pixels per line and lines out of a given
* crop-area. The size of the area is given on a 300dpi base! * crop-area. The size of the area is given on a 300dpi base!
*/ */
static void usb_GetImageInfo( Plustek_Device *dev, pImgDef pInfo, pWinInfo pSize ) static void usb_GetImageInfo( Plustek_Device *dev, ImgDef *pInfo, WinInfo *pSize )
{ {
DBG( _DBG_INFO, "usb_GetImageInfo()\n" ); DBG( _DBG_INFO, "usb_GetImageInfo()\n" );
@ -1566,7 +1563,7 @@ static void usb_GetImageInfo( Plustek_Device *dev, pImgDef pInfo, pWinInfo pSize
/** /**
*/ */
static void usb_SaveImageInfo( Plustek_Device *dev, pImgDef pInfo ) static void usb_SaveImageInfo( Plustek_Device *dev, ImgDef *pInfo )
{ {
HWDef *hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
ScanParam *pParam = &dev->scanning.sParam; ScanParam *pParam = &dev->scanning.sParam;

Wyświetl plik

@ -55,6 +55,7 @@
* - 0.49 - added typedef struct DevList * - 0.49 - added typedef struct DevList
* - added button stuff * - added button stuff
* - added transferRate to struct Plustek_Device * - added transferRate to struct Plustek_Device
* - 0.50 - cleanup
* . * .
* <hr> * <hr>
* This file is part of the SANE package. * This file is part of the SANE package.
@ -127,8 +128,8 @@
#define _DEFAULT_NEG_TLX 1.5 /* 0..38.9 mm */ #define _DEFAULT_NEG_TLX 1.5 /* 0..38.9 mm */
#define _DEFAULT_NEG_TLY 1.5 /* 0..29.6 mm */ #define _DEFAULT_NEG_TLY 1.5 /* 0..29.6 mm */
#define _DEFAULT_NEG_BRX 37.5 /* 0..38.9 mm */ #define _DEFAULT_NEG_BRX 37.5 /* 0..38.9 mm */
#define _DEFAULT_NEG_BRY 25.5 /* 0..29.6 mm */ #define _DEFAULT_NEG_BRY 25.5 /* 0..29.6 mm */
/** image sizes for normal, transparent and negative modes /** image sizes for normal, transparent and negative modes
*/ */
@ -291,40 +292,40 @@ typedef struct {
double graygamma; double graygamma;
} AdjDef, *pAdjDef; } AdjDef;
typedef struct { typedef struct {
unsigned short x; unsigned short x;
unsigned short y; unsigned short y;
unsigned short cx; unsigned short cx;
unsigned short cy; unsigned short cy;
} CropRect, *pCropRect; } CropRect;
typedef struct image { typedef struct image {
unsigned long dwFlag; unsigned long dwFlag;
CropRect crArea; CropRect crArea;
XY xyDpi; XY xyDpi;
unsigned short wDataType; unsigned short wDataType;
} ImgDef, *pImgDef; } ImgDef;
typedef struct { typedef struct {
unsigned long dwPixelsPerLine; unsigned long dwPixelsPerLine;
unsigned long dwBytesPerLine; unsigned long dwBytesPerLine;
unsigned long dwLinesPerArea; unsigned long dwLinesPerArea;
ImgDef ImgDef; ImgDef ImgDef;
} CropInfo, *pCropInfo; } CropInfo;
typedef struct { typedef struct {
ImgDef ImgDef; ImgDef ImgDef;
short siBrightness; short siBrightness;
short siContrast; short siContrast;
} ScanInfo, *pScanInfo; } ScanInfo;
typedef struct { typedef struct {
unsigned long dwFlag; unsigned long dwFlag;
unsigned short wMaxExtentX; /**< scanarea width */ unsigned short wMaxExtentX; /**< scanarea width */
unsigned short wMaxExtentY; /**< scanarea height */ unsigned short wMaxExtentY; /**< scanarea height */
} ScannerCaps, *pScannerCaps; } ScannerCaps;
typedef struct Plustek_Device typedef struct Plustek_Device
{ {
@ -355,7 +356,7 @@ typedef struct Plustek_Device
struct itimerval saveSettings; /* for lamp timer */ struct itimerval saveSettings; /* for lamp timer */
#endif #endif
} Plustek_Device, *pPlustek_Device; } Plustek_Device;
#ifndef SANE_OPTION #ifndef SANE_OPTION
/* for compatibility with older versions */ /* for compatibility with older versions */
@ -390,7 +391,7 @@ typedef struct Plustek_Scanner
SANE_Option_Descriptor opt[NUM_OPTIONS]; SANE_Option_Descriptor opt[NUM_OPTIONS];
} Plustek_Scanner, *pPlustek_Scanner; } Plustek_Scanner;
/** for collecting configuration info... /** for collecting configuration info...
*/ */
@ -402,7 +403,7 @@ typedef struct {
/* contains the stuff to adjust... */ /* contains the stuff to adjust... */
AdjDef adj; AdjDef adj;
} CnfDef, *pCnfDef; } CnfDef;
/** for supported device list /** for supported device list
*/ */