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
* - added CRYSTAL_FREQ
* - added IPCDef
* - 0.50 - cleanup
* .
* <hr>
* This file is part of the SANE package.
@ -117,56 +118,56 @@ typedef struct {
u_char Red;
u_char Green;
u_char Blue;
} RGBByteDef, *pRGBByteDef;
} RGBByteDef;
typedef struct {
u_short Red;
u_short Green;
u_short Blue;
} RGBUShortDef, *pRGBUShortDef;
} RGBUShortDef;
typedef struct {
u_long Red;
u_long Green;
u_long Blue;
} RGBULongDef, *pRGBULongDef;
} RGBULongDef;
typedef struct {
u_char a_bColor[3];
} ColorByteDef, *pColorByteDef;
} ColorByteDef;
typedef struct {
u_char bHi;
u_char bLo;
} HiLoDef, *pHiLoDef;
} HiLoDef;
typedef union {
HiLoDef HiLo[3];
u_short Colors[3];
} ColorWordDef, *pColorWordDef;
u_short Colors[3];
} ColorWordDef;
typedef union {
HiLoDef HiLo;
u_short Mono;
} MonoWordDef, *pMonoWordDef;
HiLoDef HiLo;
u_short Mono;
} MonoWordDef;
typedef union {
u_char *pb;
u_short *pw;
pMonoWordDef pmw;
pColorByteDef pcb;
pColorWordDef pcw;
pRGBByteDef pb_rgb;
pRGBUShortDef pw_rgb;
pHiLoDef philo;
MonoWordDef *pmw;
ColorByteDef *pcb;
ColorWordDef *pcw;
RGBByteDef *pb_rgb;
RGBUShortDef *pw_rgb;
HiLoDef *philo;
} AnyPtr, *pAnyPtr;
} AnyPtr;
typedef struct {
unsigned short x;
unsigned short y;
} XY, *pXY;
} XY;
#define _VAR_NOT_USED(x) ((x)=(x))
@ -330,8 +331,8 @@ enum SCANFLAG
typedef struct Origins
{
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 */
} OrgDef, *pOrgDef;
long lUp; /* How many pix to move the scanning or up, in optic res */
} OrgDef;
typedef struct SrcAttr
{
@ -345,7 +346,7 @@ typedef struct SrcAttr
XY MinDpi; /**< Minimum dpi supported for scanning */
u_char bMinDataType; /**< Minimum data type supports */
} SrcAttrDef, *pSrcAttrDef;
} SrcAttrDef;
typedef struct DevCaps
{
@ -365,7 +366,7 @@ typedef struct DevCaps
/* _WORKAROUNDS */
u_long lamp; /**< for lamp: loword: normal, hiword: tpa */
} DCapsDef, *pDCapsDef;
} DCapsDef;
/**
* for keeping intial illumination settings
@ -381,7 +382,7 @@ typedef struct
u_short blue_lamp_on;
u_short blue_lamp_off;
} IllumiDef, *pIllumiDef;
} IllumiDef;
/** basic register settings
@ -400,7 +401,7 @@ typedef struct HWDefault
u_short wGreenPWMDutyCycleLow;
u_short wGreenPWMDutyCycleHigh;
/* Registers */
u_char bSensorConfiguration; /* 0x0b */
u_char bSensorConfiguration; /* 0x0b */
/* Sensor control settings */
u_char bReg_0x0c;
u_char bReg_0x0d;
@ -418,13 +419,13 @@ typedef struct HWDefault
/* initial illumination settings */
IllumiDef illu_mono;
IllumiDef illu_color;
/* 0x1a & 0x1b, remember the u_char order is not Intel
* format, you have to pay your attention when you
* write this value to register.
*/
u_short StepperPhaseCorrection;
/* Sensor Pixel Configuration
* Actually, the wActivePixelsStart will be set to 0 for shading purpose.
* We have to keep these values to adjust the origins when user does the
@ -434,7 +435,7 @@ typedef struct HWDefault
u_char bOpticBlackEnd; /* 0x1d */
u_short wActivePixelsStart; /* 0x1e & 0x1f */
u_short wLineEnd; /* 0x20 & 0x21 */
/* illumination settings (runtime) */
u_short red_lamp_on; /* 0x2c & 0x2d */
u_short red_lamp_off; /* 0x2e & 0x2f */
@ -442,7 +443,7 @@ typedef struct HWDefault
u_short green_lamp_off; /* 0x32 & 0x33 */
u_short blue_lamp_on; /* 0x34 & 0x35 */
u_short blue_lamp_off; /* 0x36 & 0x37 */
/* Misc */
u_char bReg_0x45;
u_short wStepsAfterPaperSensor2;/* 0x4c & 0x4d */
@ -459,11 +460,11 @@ typedef struct HWDefault
u_char bReg_0x5c;
u_char bReg_0x5d;
u_char bReg_0x5e;
eChipDef chip; /* chiptype */
eModelDef motorModel; /* to identify used motor */
double gamma; /* gamma setting */
} HWDef, *pHWDef;
} HWDef;
/** device description during runtime
*/
@ -474,7 +475,7 @@ typedef struct DeviceDef
int product; /**< product ID */
DCapsDef Caps; /**< pointer to the attribute of current dev */
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. */
OrgDef Normal; /**< Reflection - Pix to adjust scanning orgs */
OrgDef Positive; /**< Pos film - Pix to adjust scanning orgs */
@ -488,17 +489,17 @@ typedef struct DeviceDef
SANE_Bool fLastScanIsAdf;/**< */
u_char a_bRegs[0x80]; /**< our global register file */
} DeviceDef, *pDeviceDef;
} DeviceDef;
typedef struct Settings
{
char *pIDString;
pDCapsDef pDevCaps;
pHWDef pHwDef;
char *pIDString;
DCapsDef *pDevCaps;
HWDef *pHwDef;
char *pModelString;
} SetDef, *pSetDef;
} SetDef;
/**
*/
@ -517,7 +518,7 @@ typedef struct
/* request dpi (CCD lines distance) */
u_long dwTotalBytes; /**< Total bytes per scan */
} WinInfo, *pWinInfo;
} WinInfo;
/**
*/
@ -554,7 +555,7 @@ typedef struct
int swOffset[3]; /**< for calibration adjustment */
int swGain[3]; /**< for calibration adjustment */
} ScanParam, *pScanParam;
} ScanParam;
struct Plustek_Device;
@ -605,7 +606,7 @@ typedef struct ScanDef
u_char bLinesToSkip; /**< how many lines to skip at start */
} ScanDef, *pScanDef;
} ScanDef;
/** max number of different colck settings */
@ -619,7 +620,7 @@ typedef struct
u_char pwm_duty; /**< PWM duty cycles */
u_char scan_lines_per_line; /**< lines to scan to obtain 1 real line
will be used in 16bit color modes only */
} MDef, *pMDef;
} MDef;
/** 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_16[_MAX_CLK]; /**< MCLK settings for gray (16bit) scan */
} ClkMotorDef, *pClkMotorDef;
} ClkMotorDef;
/** for transferring some info between child and parent after calibration
*/

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -29,6 +29,7 @@
* - added usb_BWScaleFromColor() and usb_BWDuplicateFromColor
* - cleanup
* - 0.49 - a_bRegs is now part of the device structure
* - 0.50 - cleanup
* .
* <hr>
* 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 )
{
u_long dw;
pScanDef scan = &dev->scanning;
ScanDef *scan = &dev->scanning;
if((scan->sParam.bSource == SOURCE_Negative ||
scan->sParam.bSource == SOURCE_Transparency) &&
@ -229,7 +230,7 @@ static void usb_AverageColorWord( Plustek_Device *dev )
{
u_char ls = 2;
u_long dw;
pScanDef scan = &dev->scanning;
ScanDef *scan = &dev->scanning;
if((scan->sParam.bSource == SOURCE_Negative ||
scan->sParam.bSource == SOURCE_Transparency) &&
@ -268,7 +269,7 @@ static void usb_AverageColorWord( Plustek_Device *dev )
static void usb_AverageGrayByte( Plustek_Device *dev )
{
u_long dw;
pScanDef scan = &dev->scanning;
ScanDef *scan = &dev->scanning;
if((scan->sParam.bSource == SOURCE_Negative ||
scan->sParam.bSource == SOURCE_Transparency) &&
@ -285,7 +286,7 @@ static void usb_AverageGrayByte( Plustek_Device *dev )
static void usb_AverageGrayWord( Plustek_Device *dev )
{
u_long dw;
pScanDef scan = &dev->scanning;
ScanDef *scan = &dev->scanning;
if((scan->sParam.bSource == SOURCE_Negative ||
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) {
if( swap ) {
tmp = *((pHiLoDef)&scan->Red.pw[dw]);
tmp = *((HiLoDef*)&scan->Red.pw[dw]);
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;
tmp = *((pHiLoDef)&scan->Blue.pw[dw]);
tmp = *((HiLoDef*)&scan->Blue.pw[dw]);
scan->UserBuf.pw_rgb[pixels].Blue = _HILO2WORD(tmp) >> ls;
} else {
@ -721,7 +722,7 @@ static void usb_GrayDuplicatePseudo16( Plustek_Device *dev )
*/
static void usb_BWDuplicate( Plustek_Device *dev )
{
pScanDef scan = &dev->scanning;
ScanDef *scan = &dev->scanning;
if(scan->sParam.bSource == SOURCE_ADF)
{
@ -1126,13 +1127,13 @@ static void usb_ColorScale16_2( Plustek_Device *dev )
if( swap ) {
tmp = *((pHiLoDef)&scan->Red.pw[bitsput]);
tmp = *((HiLoDef*)&scan->Red.pw[bitsput]);
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;
tmp = *((pHiLoDef)&scan->Blue.pw[bitsput]);
tmp = *((HiLoDef*)&scan->Blue.pw[bitsput]);
scan->UserBuf.pw_rgb[pixels].Blue = _HILO2WORD(tmp) >> ls;
} else {

Wyświetl plik

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

Wyświetl plik

@ -27,6 +27,7 @@
* - 0.49 - a_bRegs is now part of the device structure
* - using now PhyDpi.y as selector for the motor MCLK range
* - changed usb_MapDownload prototype
* - 0.50 - cleanup
* .
* <hr>
* This file is part of the SANE package.
@ -79,7 +80,7 @@ static SANE_Bool m_fAutoPark;
static SANE_Bool m_fFirst;
static double m_dHDPIDivider;
static double m_dMCLKDivider;
static pScanParam m_pParam;
static ScanParam *m_pParam;
static u_char m_bLineRateColor;
static u_char m_bCM;
static u_char m_bIntTimeAdjust;
@ -103,7 +104,6 @@ static u_long usb_min( u_long val1, u_long val2 )
{
if( val1 > val2 )
return val2;
return val1;
}
@ -116,7 +116,6 @@ static u_long usb_max( u_long val1, u_long val2 )
{
if( val1 > val2 )
return val1;
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 )
{
u_short res;
pScanDef scanning = &dev->scanning;
pDCapsDef scaps = &dev->usbDev.Caps;
ScanDef *scanning = &dev->scanning;
DCapsDef *scaps = &dev->usbDev.Caps;
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 &&
scanning->sParam.bDataType != SCANDATATYPE_Color &&
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);
DBG( _DBG_INFO2, "* XDPI=%u, HDPI=%.3f\n", res, m_dHDPIDivider );
return res;
}
@ -210,17 +207,17 @@ static u_short usb_SetAsicDpiX( Plustek_Device *dev, u_short xdpi )
*/
static u_short usb_SetAsicDpiY( Plustek_Device *dev, u_short ydpi )
{
pScanDef scanning = &dev->scanning;
pDCapsDef sCaps = &dev->usbDev.Caps;
pHWDef hw = &dev->usbDev.HwSetting;
ScanDef *scanning = &dev->scanning;
DCapsDef *sCaps = &dev->usbDev.Caps;
HWDef *hw = &dev->usbDev.HwSetting;
u_short wMinDpi, wDpi;
u_short wMinDpi, wDpi;
if(0 != sCaps->bSensorDistance )
wMinDpi = sCaps->OpticDpi.y / sCaps->bSensorDistance;
else
wMinDpi = 75;
/* Here we might have to check against the MinDpi value ! */
wDpi = (ydpi + wMinDpi - 1) / wMinDpi * wMinDpi;
@ -260,14 +257,12 @@ static u_short usb_SetAsicDpiY( Plustek_Device *dev, u_short ydpi )
* @param pParam - pointer to the current scan parameters
* @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;
/*
* Set pixel packing, data mode and AFE operation
*/
/* Set pixel packing, data mode and AFE operation */
switch( pParam->bDataType ) {
case SCANDATATYPE_Color:
m_bCM = 3;
@ -318,12 +313,12 @@ static void usb_SetColorAndBits( Plustek_Device *dev, pScanParam pParam )
* @param pParam - pointer to the current scan parameters
* @return - Nothing
*/
static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam )
static void usb_GetScanRect( Plustek_Device *dev, ScanParam *pParam )
{
u_short wDataPixelStart, wLineEnd;
pDCapsDef sCaps = &dev->usbDev.Caps;
pHWDef hw = &dev->usbDev.HwSetting;
DCapsDef *sCaps = &dev->usbDev.Caps;
HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs;
/* 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 */
pParam->Size.dwPhyPixels =
(pParam->Size.dwValidPixels + 15UL) & 0xfffffff0UL;
(pParam->Size.dwValidPixels + 15UL) & 0xfffffff0UL;
pParam->Size.dwPhyBytes = pParam->Size.dwPhyPixels / 8UL + 2UL;
}
else if (pParam->bBitDepth == 8)
{
/* Pixels should be times of 2 */
pParam->Size.dwPhyPixels =
(pParam->Size.dwValidPixels + 1UL) & 0xfffffffeUL;
(pParam->Size.dwValidPixels + 1UL) & 0xfffffffeUL;
pParam->Size.dwPhyBytes =
pParam->Size.dwPhyPixels * pParam->bChannels + 2UL;
pParam->Size.dwPhyPixels * pParam->bChannels + 2UL;
if((hw->bReg_0x26 & _ONE_CH_COLOR) &&
(pParam->bDataType == SCANDATATYPE_Color)) {
(pParam->bDataType == SCANDATATYPE_Color)) {
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.dwPhyBytes =
pParam->Size.dwPhyPixels * 2 * pParam->bChannels + 2UL;
pParam->Size.dwPhyPixels * 2 * pParam->bChannels + 2UL;
if((hw->bReg_0x26 & _ONE_CH_COLOR) &&
(pParam->bDataType == SCANDATATYPE_Color)) {
(pParam->bDataType == SCANDATATYPE_Color)) {
pParam->Size.dwPhyBytes *= 3;
}
}
/* Compute data start pixel */
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
*/
@ -388,8 +383,8 @@ static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam )
#if 0
if(ScanInf.m_fADF) {
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
wDataPixelStart += hw->wActivePixelsStart;
}
@ -470,7 +465,7 @@ static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam )
*/
if (pParam->bDataType != SCANDATATYPE_Color)
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);
@ -479,7 +474,8 @@ static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam )
if( hw->motorModel == MODEL_HuaLien && sCaps->OpticDpi.x == 600)
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[0x4b] = _LOBYTE( pParam->Origin.y );
@ -487,11 +483,11 @@ static void usb_GetScanRect( Plustek_Device *dev, pScanParam pParam )
/** 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;
double mclkdiv = pParam->dMCLK;
pHWDef hw = &dev->usbDev.HwSetting;
HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs;
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 hfcnt; /* half speed count reg 51 b0..1 */
int strev; /* steps to reverse reg 50 */
int dpd; /* calculated dpd reg 52:53 */
int st; /* step size reg 46:47 */
int strev; /* steps to reverse reg 50 */
int dpd; /* calculated dpd reg 52:53 */
int st; /* step size reg 46:47 */
pHWDef hw = &dev->usbDev.HwSetting;
HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs;
qtcnt = (regs[0x51] & 0x30) >> 4; /* quarter speed count */
hfcnt = (regs[0x51] & 0xc0) >> 6; /* half speed count */
qtcnt = (regs[0x51] & 0x30) >> 4; /* quarter speed count */
hfcnt = (regs[0x51] & 0xc0) >> 6; /* half speed count */
if( _LM9831 == hw->chip )
strev = regs[0x50] & 0x3f; /* steps to reverse */
strev = regs[0x50] & 0x3f; /* steps to reverse */
else /* LM9832/3 */
{
if (qtcnt == 3)
qtcnt = 8;
if (hfcnt == 3)
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)
dpd = 0;
else
{
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 );
dpd = m_wLineLength * m_bLineRateColor - dpd;
}
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",
m_wLineLength, m_bLineRateColor, qtcnt, hfcnt );
m_wLineLength, m_bLineRateColor, qtcnt, hfcnt );
regs[0x51] |= (u_char)((dpd >> 16) & 0x03);
regs[0x52] = (u_char)(dpd >> 8);
@ -574,7 +570,7 @@ static int usb_GetMCLKDiv( Plustek_Device *dev )
if ((regs[0x26] & 7) == 0)
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:
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
* 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 dMaxMCLKDivider;
pDCapsDef sCaps = &dev->usbDev.Caps;
pHWDef hw = &dev->usbDev.HwSetting;
DCapsDef *sCaps = &dev->usbDev.Caps;
HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs;
DBG( _DBG_INFO, "usb_GetMCLKDivider()\n" );
@ -662,8 +658,8 @@ static double usb_GetMCLKDivider( Plustek_Device *dev, pScanParam pParam )
if( pParam->bBitDepth > 8 ) {
while( pParam->Size.dwPhyBytes >
(m_dMCLKDivider * m_bCM * m_wLineLength / 6 * 9 / 10) *
(1 + m_bIntTimeAdjust)) {
(m_dMCLKDivider * m_bCM * m_wLineLength / 6 * 9 / 10) *
(1 + m_bIntTimeAdjust)) {
m_bIntTimeAdjust++;
}
@ -694,7 +690,7 @@ static double usb_GetMCLKDivider( Plustek_Device *dev, pScanParam pParam )
if( m_bIntTimeAdjust != 0 ) {
m_wStepSize = (u_short)((u_long) m_wStepSize *
(m_bIntTimeAdjust + 1) / m_bIntTimeAdjust);
(m_bIntTimeAdjust + 1) / m_bIntTimeAdjust);
if( 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
* high lamp PWM, use equation 4
*/
* high lamp PWM, use equation 4
*/
dMaxIntegrationTime = hw->dIntegrationTimeHighLamp;
dMaxMCLKDivider = (double)CRYSTAL_FREQ * dMaxIntegrationTime /
(1000 * 8 * m_bCM * m_wLineLength);
(1000 * 8 * m_bCM * m_wLineLength);
/* Determine lamp PWM setting */
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
*/
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;
/* Compute step size using equation 1 */
if (m_bIntTimeAdjust != 0) {
m_wStepSize = (u_short)(((u_long) pParam->PhyDpi.y * m_wLineLength *
m_bLineRateColor * (m_bIntTimeAdjust + 1)) /
(4 * hw->wMotorDpi * m_bIntTimeAdjust));
m_bLineRateColor * (m_bIntTimeAdjust + 1)) /
(4 * hw->wMotorDpi * m_bIntTimeAdjust));
} else {
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)
@ -765,7 +761,7 @@ static void usb_GetStepSize( Plustek_Device *dev, pScanParam pParam )
static void usb_GetLineLength( Plustek_Device *dev )
{
/* [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
* again to get all new value after ITA was changed? If this routine
* never call again, maybe we remove all factor with ITA here.
@ -777,34 +773,34 @@ static void usb_GetLineLength( Plustek_Device *dev )
int dur; /* pulse duration reg 0e b0..3 */
int ntr; /* number of tr pulses reg 0d b7 */
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 tp; /* tpspd or 1 if tpsel=0 */
int b; /* if ctmode=0, (ntr+1)*((2*gbnd)+dur+1), otherwise 1 */
int tradj; /* ITA */
int en_tradj;
pHWDef hw = &dev->usbDev.HwSetting;
HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs;
tpspd = (regs[0x0a] & 0x0c) >> 2; /* turbo/preview mode speed */
tpsel = regs[0x0a] & 3; /* turbo/preview mode select */
tpspd = (regs[0x0a] & 0x0c) >> 2; /* turbo/preview mode speed */
tpsel = regs[0x0a] & 3; /* turbo/preview mode select */
gbnd = (regs[0x0e] & 0xf0) >> 4; /* TR fi1 guardband duration */
dur = (regs[0x0e] & 0xf); /* TR pulse duration */
gbnd = (regs[0x0e] & 0xf0) >> 4; /* TR fi1 guardband 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;
ctmode = (regs[0x0b] >> 3) & 3; /* cis tr timing mode */
ctmode = (regs[0x0b] >> 3) & 3; /* cis tr timing mode */
m_bLineRateColor = 1;
if (afeop == 1 || afeop == 5) /* if 3 channel line or 1 channel mode b */
m_bLineRateColor = 3;
m_bLineRateColor = 3;
/* according to turbo/preview mode to set value */
if( tpsel == 0 ) {
@ -867,13 +863,13 @@ static void usb_GetLineLength( Plustek_Device *dev )
/** usb_GetMotorParam
* registers 0x56, 0x57
*/
static void usb_GetMotorParam( Plustek_Device *dev, pScanParam pParam )
static void usb_GetMotorParam( Plustek_Device *dev, ScanParam *pParam )
{
int idx, i;
pClkMotorDef clk;
pMDef md;
pDCapsDef sCaps = &dev->usbDev.Caps;
pHWDef hw = &dev->usbDev.HwSetting;
ClkMotorDef *clk;
MDef *md;
DCapsDef *sCaps = &dev->usbDev.Caps;
HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs;
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;
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;
pHWDef hw = &dev->usbDev.HwSetting;
HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs;
scaler = 1;
@ -1078,9 +1074,9 @@ static void usb_GetPauseLimit( Plustek_Device *dev, pScanParam pParam )
/** 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->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
*/
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];
pScanParam pdParam = &dev->scanning.sParam;
pHWDef hw = &dev->usbDev.HwSetting;
ScanParam *pdParam = &dev->scanning.sParam;
HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs;
m_pParam = pParam;
@ -1207,8 +1203,8 @@ static SANE_Bool usb_SetScanParameters( Plustek_Device *dev, pScanParam pParam )
usb_GetScanLinesAndSize( dev, pParam );
/* 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 );
/* For ADF .... */
@ -1248,16 +1244,17 @@ static SANE_Bool usb_SetScanParameters( Plustek_Device *dev, pScanParam pParam )
memset( &regs[0x03], 0, 3 );
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) {
u_short scansteps = (u_short)ceil((double)(pParam->Size.dwPhyLines + 10)*
hw->wMotorDpi / pParam->PhyDpi.y);
DBG( _DBG_INFO, "* Scansteps=%u (%lu*%u/%u)\n", scansteps,
pParam->Size.dwPhyLines, hw->wMotorDpi, pParam->PhyDpi.y );
#if 1
regs[0x4c] = _HIBYTE(scansteps);
regs[0x4d] = _LOBYTE(scansteps);
#endif
}
/* set the merlin registers */
@ -1279,8 +1276,8 @@ static SANE_Bool usb_ScanBegin( Plustek_Device *dev, SANE_Bool auto_park )
{
u_char value;
u_short inches;
pHWDef hw = &dev->usbDev.HwSetting;
pDCapsDef sc = &dev->usbDev.Caps;
HWDef *hw = &dev->usbDev.HwSetting;
DCapsDef *sc = &dev->usbDev.Caps;
u_char *regs = dev->usbDev.a_bRegs;
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 */
if(( m_pParam->bCalibration == PARAM_Scan &&
!usb_MapDownload( dev )) ||
!usb_DownloadShadingData( dev, m_pParam->bCalibration ))
if(( m_pParam->bCalibration == PARAM_Scan && !usb_MapDownload( dev )) ||
!usb_DownloadShadingData( dev, m_pParam->bCalibration )) {
return SANE_FALSE;
}
/* Move chassis and start to read image data */
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
* 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" );
@ -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;
ScanParam *pParam = &dev->scanning.sParam;

Wyświetl plik

@ -55,6 +55,7 @@
* - 0.49 - added typedef struct DevList
* - added button stuff
* - added transferRate to struct Plustek_Device
* - 0.50 - cleanup
* .
* <hr>
* 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_TLY 1.5 /* 0..29.6 mm */
#define _DEFAULT_NEG_BRX 37.5 /* 0..38.9 mm */
#define _DEFAULT_NEG_BRY 25.5 /* 0..29.6 mm */
#define _DEFAULT_NEG_BRX 37.5 /* 0..38.9 mm */
#define _DEFAULT_NEG_BRY 25.5 /* 0..29.6 mm */
/** image sizes for normal, transparent and negative modes
*/
@ -231,7 +232,7 @@ enum {
OPT_OVR_GREEN_LOFF,
OPT_OVR_BLUE_LOFF,
OPT_BUTTON_GROUP,
OPT_BUTTON_0,
OPT_BUTTON_0,
OPT_BUTTON_1,
OPT_BUTTON_2,
OPT_BUTTON_3,
@ -265,10 +266,10 @@ typedef struct {
perhaps other Canon scanners require the
alternate autocalibration as well */
/* AFE adjustemnts, gain and offset */
int rgain;
int rgain;
int ggain;
int bgain;
int rofs;
int rofs;
int gofs;
int bofs;
@ -291,40 +292,40 @@ typedef struct {
double graygamma;
} AdjDef, *pAdjDef;
} AdjDef;
typedef struct {
unsigned short x;
unsigned short y;
unsigned short cx;
unsigned short cy;
} CropRect, *pCropRect;
} CropRect;
typedef struct image {
unsigned long dwFlag;
CropRect crArea;
XY xyDpi;
unsigned short wDataType;
} ImgDef, *pImgDef;
unsigned long dwFlag;
CropRect crArea;
XY xyDpi;
unsigned short wDataType;
} ImgDef;
typedef struct {
unsigned long dwPixelsPerLine;
unsigned long dwBytesPerLine;
unsigned long dwLinesPerArea;
ImgDef ImgDef;
} CropInfo, *pCropInfo;
} CropInfo;
typedef struct {
ImgDef ImgDef;
short siBrightness;
short siContrast;
} ScanInfo, *pScanInfo;
} ScanInfo;
typedef struct {
unsigned long dwFlag;
unsigned short wMaxExtentX; /**< scanarea width */
unsigned short wMaxExtentY; /**< scanarea height */
} ScannerCaps, *pScannerCaps;
} ScannerCaps;
typedef struct Plustek_Device
{
@ -355,7 +356,7 @@ typedef struct Plustek_Device
struct itimerval saveSettings; /* for lamp timer */
#endif
} Plustek_Device, *pPlustek_Device;
} Plustek_Device;
#ifndef SANE_OPTION
/* for compatibility with older versions */
@ -390,7 +391,7 @@ typedef struct Plustek_Scanner
SANE_Option_Descriptor opt[NUM_OPTIONS];
} Plustek_Scanner, *pPlustek_Scanner;
} Plustek_Scanner;
/** for collecting configuration info...
*/
@ -402,7 +403,7 @@ typedef struct {
/* contains the stuff to adjust... */
AdjDef adj;
} CnfDef, *pCnfDef;
} CnfDef;
/** for supported device list
*/