kopia lustrzana https://gitlab.com/sane-project/backends
build 3 of sm3600
rodzic
d0b503198d
commit
44682ed3d4
|
@ -41,6 +41,7 @@
|
|||
This file implements a dynamic linking based SANE meta backend. It
|
||||
allows managing an arbitrary number of SANE backends by using
|
||||
dynamic linking to load backends on demand. */
|
||||
|
||||
/* ======================================================================
|
||||
|
||||
Userspace scan tool for the Microtek 3600 scanner
|
||||
|
@ -142,7 +143,8 @@ StartScanColor()
|
|||
====================================================================== */
|
||||
|
||||
/* Parameter are in resolution units! */
|
||||
static TState StartScanColor(TInstance *this)
|
||||
__SM3600EXPORT__
|
||||
TState StartScanColor(TInstance *this)
|
||||
{
|
||||
|
||||
/* live could be easy: Simple calculate a window, start the scan,
|
||||
|
@ -188,8 +190,9 @@ static TState StartScanColor(TInstance *this)
|
|||
{
|
||||
unsigned char uchRegs[]={
|
||||
0xFC /*!!R_SPOS!!*/, 0x00 /*R_SPOSH*/, 0x24 /*!!0x03!!*/,
|
||||
0xB0 /*!!R_SWID!!*/, 0xC4 /*!!R_SWIDH!!*/, 0x06 /*!!R_STPS!!*/,
|
||||
0x00 /*!!R_STPSH!!*/, 0xFF /*!!0x08!!*/, 0xFF /*!!0x09!!*/,
|
||||
0xB0 /*!!R_SWID!!*/, 0xC4 /*!!R_SWIDH!!*/,
|
||||
1,0,
|
||||
0xFF /*!!0x08!!*/, 0xFF /*!!0x09!!*/,
|
||||
0x22 /*!!R_LEN!!*/, 0x07 /*!!R_LENH!!*/, 0x6D /*0x0C*/,
|
||||
0x70 /*0x0D*/, 0x69 /*0x0E*/, 0xD0 /*0x0F*/,
|
||||
0x00 /*0x10*/, 0x00 /*0x11*/, 0x42 /*!!0x12!!*/,
|
||||
|
@ -264,7 +267,7 @@ static TState StartScanColor(TInstance *this)
|
|||
|
||||
/* setup gamma tables */
|
||||
RegWrite(this,0x41,1,0x03); /* gamma, RGB */
|
||||
RegWrite(this,0x40,1,0x18); /* offset FIFO 8*3 KB spared */
|
||||
RegWrite(this,0x40,1,0x28); /* offset FIFO 8*3 (GAMMA)+16 KB(gain) spared */
|
||||
/*
|
||||
hey, surprise: Although the color lines are sent in a strange order,
|
||||
the gamma tables are mapped constantly to the sensors (i.e. RGB)
|
||||
|
@ -274,6 +277,23 @@ static TState StartScanColor(TInstance *this)
|
|||
UploadGammaTable(this,0x4000,this->agammaB);
|
||||
INST_ASSERT();
|
||||
|
||||
#ifndef SM3600_NO_GAIN_CORRECTION
|
||||
RegWrite(this,0x3D,1,0x0F | 0x80); /* 10XXXXXX : one offset table */
|
||||
RegWrite(this,0x3F,1,0x18); /* 16KB gain at 0x06000 */
|
||||
{
|
||||
unsigned short uwGain[8192];
|
||||
int i,iOff;
|
||||
|
||||
/*
|
||||
Oopsi: correction data starts at the left of the scanning window!
|
||||
*/
|
||||
iOff=this->param.x/2+this->calibration.xMargin;
|
||||
for (i=iOff; i<MAX_PIXEL_PER_SCANLINE; i++)
|
||||
uwGain[i-iOff]=this->calibration.achStripeY[i]<<4;
|
||||
for (i=0; i<0x4000; i+=0x1000)
|
||||
MemWriteArray(this,(0x6000+i)>>1,0x1000,(unsigned char*)&uwGain[i>>1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* enough for 1/100 inch sensor distance */
|
||||
this->state.cBacklog=1+2*this->state.ySensorSkew;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
This file implements a dynamic linking based SANE meta backend. It
|
||||
allows managing an arbitrary number of SANE backends by using
|
||||
dynamic linking to load backends on demand. */
|
||||
|
||||
/* ======================================================================
|
||||
|
||||
Userspace scan tool for the Microtek 3600 scanner
|
||||
|
@ -310,7 +311,8 @@ StartScanGray()
|
|||
|
||||
====================================================================== */
|
||||
|
||||
static TState StartScanGray(TInstance *this)
|
||||
__SM3600EXPORT__
|
||||
TState StartScanGray(TInstance *this)
|
||||
{
|
||||
unsigned char *puchRegs;
|
||||
int i;
|
||||
|
@ -343,11 +345,30 @@ static TState StartScanGray(TInstance *this)
|
|||
this->param.x/2+this->calibration.xMargin); INST_ASSERT();
|
||||
RegWrite(this,R_SLEN, 2, this->state.cyWindow); INST_ASSERT();
|
||||
RegWrite(this,R_SWID, 2, this->state.cxWindow); INST_ASSERT();
|
||||
RegWrite(this,R_STPS, 2, 0); INST_ASSERT();
|
||||
|
||||
/* upload gamma table */
|
||||
RegWrite(this,0x41,1,0x01); /* gamma, gray */
|
||||
RegWrite(this,0x40,1,0x08); /* offset FIFO 8 KB spared */
|
||||
UploadGammaTable(this,0,this->agammaGray); INST_ASSERT();
|
||||
RegWrite(this,0x40,1,0x20); /* FIFO at 0x08000 */
|
||||
UploadGammaTable(this,0,this->agammaY); INST_ASSERT();
|
||||
|
||||
#ifndef SM3600_NO_GAIN_CORRECTION
|
||||
RegWrite(this,0x3D,1,0x0F | 0x80); /* 10XXXXXX : one offset table */
|
||||
RegWrite(this,0x3F,1,0x08); /* 16KB gain at 0x02000 */
|
||||
{
|
||||
unsigned short uwGain[8192];
|
||||
int i,iOff;
|
||||
|
||||
/*
|
||||
Oopsi: correction data starts at the left of the scanning window!
|
||||
*/
|
||||
iOff=this->param.x/2+this->calibration.xMargin;
|
||||
for (i=iOff; i<MAX_PIXEL_PER_SCANLINE; i++)
|
||||
uwGain[i-iOff]=this->calibration.achStripeY[i]<<4;
|
||||
for (i=0; i<0x4000; i+=0x1000)
|
||||
MemWriteArray(this,(0x2000+i)>>1,0x1000,(unsigned char*)&uwGain[i>>1]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* for halftone dithering we need one history line */
|
||||
this->state.pchBuf=malloc(USB_CHUNK_SIZE);
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
This file implements a dynamic linking based SANE meta backend. It
|
||||
allows managing an arbitrary number of SANE backends by using
|
||||
dynamic linking to load backends on demand. */
|
||||
|
||||
/* ======================================================================
|
||||
|
||||
Userspace scan tool for the Microtek 3600 scanner
|
||||
|
@ -53,26 +54,56 @@ slider movement
|
|||
|
||||
#include "sm3600-scantool.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/* tuning constants for DoOriginate */
|
||||
#define CCH_BONSAI 60
|
||||
#define MAX_PIXEL_PER_SCANLINE 5100
|
||||
#define BLACK_HOLE_GRAY 30
|
||||
#define CHASSIS_GRAY_LEVEL 100
|
||||
#define BLACK_BED_LEVEL 10
|
||||
|
||||
/* **********************************************************************
|
||||
|
||||
DoOriginate()
|
||||
|
||||
*shall* one time move the slider safely back to its origin.
|
||||
No idea, hoiw to achieve this, for now...
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
typedef enum { ltHome, ltUnknown, ltBed, ltError } TLineType;
|
||||
|
||||
#define INST_ASSERT2() { if (this->nErrorState) return ltError; }
|
||||
|
||||
static unsigned char auchRegsSingleLine[]={
|
||||
0x00 /*0x01*/, 0x00 /*0x02*/, 0x3F /*0x03*/,
|
||||
0xB4 /*!!0x04!!*/, 0x14 /*!!0x05!!*/, 0,0,
|
||||
0x00 /*0x08*/, 0x3F /*!!0x09!!*/,
|
||||
1,0,
|
||||
0x6D /*0x0C*/,
|
||||
0x70 /*0x0D*/, 0x69 /*0x0E*/, 0xD0 /*0x0F*/,
|
||||
0x00 /*0x10*/, 0x00 /*0x11*/, 0x40 /*0x12*/,
|
||||
0x15 /*0x13*/, 0x80 /*0x14*/, 0x2A /*0x15*/,
|
||||
0xC0 /*0x16*/, 0x40 /*0x17*/, 0xC0 /*0x18*/,
|
||||
0x40 /*0x19*/, 0xFF /*0x1A*/, 0x01 /*0x1B*/,
|
||||
0x88 /*0x1C*/, 0x40 /*0x1D*/, 0x4C /*0x1E*/,
|
||||
0x50 /*0x1F*/, 0x00 /*0x20*/, 0x0C /*0x21*/,
|
||||
0x21 /*0x22*/, 0xF0 /*0x23*/, 0x40 /*0x24*/,
|
||||
0x00 /*0x25*/, 0x0A /*0x26*/, 0xF0 /*0x27*/,
|
||||
0x00 /*0x28*/, 0x00 /*0x29*/, 0x4E /*0x2A*/,
|
||||
0xF0 /*0x2B*/, 0x00 /*0x2C*/, 0x00 /*0x2D*/,
|
||||
0x4E /*0x2E*/, 0x88 /*R_CCAL*/, 0x88 /*R_CCAL2*/,
|
||||
0x84 /*R_CCAL3*/, 0xEA /*R_LEN*/, 0x24 /*R_LENH*/,
|
||||
0x63 /*0x34*/, 0x29 /*0x35*/, 0x00 /*0x36*/,
|
||||
0x00 /*0x37*/, 0x00 /*0x38*/, 0x00 /*0x39*/,
|
||||
0x00 /*0x3A*/, 0x00 /*0x3B*/, 0xFF /*0x3C*/,
|
||||
0x0F /*0x3D*/, 0x00 /*0x3E*/, 0x00 /*0x3F*/,
|
||||
0x01 /*0x40*/, 0x00 /*0x41*/, 0x00 /*R_CSTAT*/,
|
||||
0x03 /*R_SPD*/, 0x01 /*0x44*/, 0x00 /*0x45*/,
|
||||
0x59 /*!!R_CTL!!*/, 0xC0 /*0x47*/, 0x40 /*0x48*/,
|
||||
0x96 /*!!0x49!!*/, 0xD8 /*0x4A*/ };
|
||||
|
||||
/* ======================================================================
|
||||
|
||||
GetLineType()
|
||||
|
||||
Reads a scan line at the actual position and classifies it as
|
||||
"on the flatbed area" or "at home position" or "elsewhere".
|
||||
This can be used to calculate the proper stepping width
|
||||
|
||||
====================================================================== */
|
||||
|
||||
static TLineType GetLineType(TInstance *this)
|
||||
{
|
||||
unsigned char achLine[CCH_BONSAI+1];
|
||||
|
@ -83,43 +114,14 @@ static TLineType GetLineType(TInstance *this)
|
|||
TBool bHolesOk;
|
||||
int lMedian;
|
||||
bHolesOk=false;
|
||||
{
|
||||
unsigned char uchRegs2495[]={
|
||||
0x00 /*0x01*/, 0x00 /*0x02*/, 0x3F /*0x03*/,
|
||||
0xEC /*!!0x04!!*/, 0x13 /*!!0x05!!*/, 0,0,
|
||||
0x00 /*0x08*/, 0x3F /*!!0x09!!*/,
|
||||
1,0,
|
||||
0x6D /*0x0C*/,
|
||||
0x70 /*0x0D*/, 0x69 /*0x0E*/, 0xD0 /*0x0F*/,
|
||||
0x00 /*0x10*/, 0x00 /*0x11*/, 0x40 /*0x12*/,
|
||||
0x15 /*0x13*/, 0x80 /*0x14*/, 0x2A /*0x15*/,
|
||||
0xC0 /*0x16*/, 0x40 /*0x17*/, 0xC0 /*0x18*/,
|
||||
0x40 /*0x19*/, 0xFF /*0x1A*/, 0x01 /*0x1B*/,
|
||||
0x88 /*0x1C*/, 0x40 /*0x1D*/, 0x4C /*0x1E*/,
|
||||
0x50 /*0x1F*/, 0x00 /*0x20*/, 0x0C /*0x21*/,
|
||||
0x21 /*0x22*/, 0xF0 /*0x23*/, 0x40 /*0x24*/,
|
||||
0x00 /*0x25*/, 0x0A /*0x26*/, 0xF0 /*0x27*/,
|
||||
0x00 /*0x28*/, 0x00 /*0x29*/, 0x4E /*0x2A*/,
|
||||
0xF0 /*0x2B*/, 0x00 /*0x2C*/, 0x00 /*0x2D*/,
|
||||
0x4E /*0x2E*/, 0x88 /*R_CCAL*/, 0x88 /*R_CCAL2*/,
|
||||
0x84 /*R_CCAL3*/, 0xEA /*R_LEN*/, 0x24 /*R_LENH*/,
|
||||
0x63 /*0x34*/, 0x29 /*0x35*/, 0x00 /*0x36*/,
|
||||
0x00 /*0x37*/, 0x00 /*0x38*/, 0x00 /*0x39*/,
|
||||
0x00 /*0x3A*/, 0x00 /*0x3B*/, 0xFF /*0x3C*/,
|
||||
0x0F /*0x3D*/, 0x00 /*0x3E*/, 0x00 /*0x3F*/,
|
||||
0x01 /*0x40*/, 0x00 /*0x41*/, 0x00 /*R_CSTAT*/,
|
||||
0x03 /*R_SPD*/, 0x01 /*0x44*/, 0x00 /*0x45*/,
|
||||
0x59 /*!!R_CTL!!*/, 0xC0 /*0x47*/, 0x40 /*0x48*/,
|
||||
0x96 /*!!0x49!!*/, 0xD8 /*0x4A*/ };
|
||||
RegWriteArray(this,R_ALL, 74, uchRegs2495);
|
||||
} /* #2495[062.5] */
|
||||
RegWriteArray(this,R_ALL, 74, auchRegsSingleLine);
|
||||
INST_ASSERT2();
|
||||
/* dprintf(DEBUG_SCAN,"originate-%d...",iStripe); */
|
||||
RegWrite(this,R_CTL, 1, 0x59); /* #2496[062.5] */
|
||||
RegWrite(this,R_CTL, 1, 0xD9); /* #2497[062.5] */
|
||||
i=WaitWhileScanning(this,5); if (i) return i;
|
||||
|
||||
cchBulk=5100;
|
||||
cchBulk=MAX_PIXEL_PER_SCANLINE;
|
||||
/*
|
||||
cchBulk=RegRead(this,R_STAT, 2);
|
||||
if (cchBulk!=MAX_PIXEL_PER_SCANLINE)
|
||||
|
@ -180,6 +182,8 @@ static TLineType GetLineType(TInstance *this)
|
|||
else
|
||||
bHolesOk=false;
|
||||
lMedian=lSum/cchBulk;
|
||||
/* this is *definitly* dirty style. We should pass the information
|
||||
by other means... */
|
||||
if (bHolesOk)
|
||||
{
|
||||
this->calibration.xMargin=axHoles[0]-480; /* left bed corner */
|
||||
|
@ -197,7 +201,73 @@ static TLineType GetLineType(TInstance *this)
|
|||
return ltUnknown;
|
||||
}
|
||||
|
||||
static TState DoOriginate(TInstance *this, TBool bStepOut)
|
||||
/* **********************************************************************
|
||||
|
||||
DoCalibration
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
#define INST_ASSERT_CALIB() { if (this->nErrorState) \
|
||||
{ free(pulSum); return ltError; } }
|
||||
|
||||
__SM3600EXPORT__
|
||||
TState DoCalibration(TInstance *this)
|
||||
{
|
||||
long *pulSum;
|
||||
int iLine,i;
|
||||
TState rc;
|
||||
if (this->calibration.bCalibrated)
|
||||
return SANE_STATUS_GOOD;
|
||||
DoJog(this,220);
|
||||
/* scan a gray line at 600 DPI */
|
||||
if (!this->calibration.achStripeY)
|
||||
{
|
||||
this->calibration.achStripeY=calloc(1,MAX_PIXEL_PER_SCANLINE);
|
||||
if (!this->calibration.achStripeY)
|
||||
return SetError(this,SANE_STATUS_NO_MEM,"no memory for calib Y");
|
||||
}
|
||||
pulSum=calloc(MAX_PIXEL_PER_SCANLINE,sizeof(long));
|
||||
if (!pulSum) return SetError(this,SANE_STATUS_NO_MEM,"no memory for calib sum");
|
||||
for (iLine=0; iLine<10; iLine++)
|
||||
{
|
||||
dprintf(DEBUG_CALIB,"calibrating %i...",iLine);
|
||||
RegWriteArray(this,R_ALL, 74, auchRegsSingleLine);
|
||||
INST_ASSERT_CALIB();
|
||||
RegWrite(this,R_CTL, 1, 0x59); /* #2496[062.5] */
|
||||
RegWrite(this,R_CTL, 1, 0xD9); /* #2497[062.5] */
|
||||
rc=WaitWhileScanning(this,5); if (rc) { free(pulSum); return rc; }
|
||||
if (BulkReadBuffer(this,this->calibration.achStripeY,
|
||||
MAX_PIXEL_PER_SCANLINE)
|
||||
!=MAX_PIXEL_PER_SCANLINE)
|
||||
{
|
||||
free(pulSum);
|
||||
return SetError(this,SANE_STATUS_IO_ERROR,"truncated bulk");
|
||||
}
|
||||
for (i=0; i<MAX_PIXEL_PER_SCANLINE; i++)
|
||||
pulSum[i]+=(long)this->calibration.achStripeY[i]*
|
||||
(long)this->calibration.achStripeY[i];
|
||||
}
|
||||
for (i=0; i<MAX_PIXEL_PER_SCANLINE; i++)
|
||||
this->calibration.achStripeY[i]=(unsigned char)(int)sqrt(pulSum[i]/10);
|
||||
free(pulSum);
|
||||
/* scan a color line at 600 DPI */
|
||||
DoJog(this,-220-10);
|
||||
INST_ASSERT();
|
||||
this->calibration.bCalibrated=true;
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
/* **********************************************************************
|
||||
|
||||
DoOriginate()
|
||||
|
||||
*shall* one time move the slider safely back to its origin.
|
||||
No idea, hoiw to achieve this, for now...
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
__SM3600EXPORT__
|
||||
TState DoOriginate(TInstance *this, TBool bStepOut)
|
||||
{
|
||||
TLineType lt;
|
||||
if (this->bVerbose)
|
||||
|
@ -207,7 +277,7 @@ static TState DoOriginate(TInstance *this, TBool bStepOut)
|
|||
lt=GetLineType(this);
|
||||
/* if we are already at home, fine. If not, first jump a bit forward */
|
||||
DBG(DEBUG_JUNK,"lt1=%d\n",(int)lt);
|
||||
if (lt!=ltHome && bStepOut) DoJog(this,200);
|
||||
if (lt!=ltHome && bStepOut) DoJog(this,150);
|
||||
while (lt!=ltHome && !this->state.bCanceled)
|
||||
{
|
||||
lt=GetLineType(this);
|
||||
|
@ -217,12 +287,14 @@ static TState DoOriginate(TInstance *this, TBool bStepOut)
|
|||
{
|
||||
case ltHome: continue;
|
||||
case ltBed: DoJog(this,-240); break; /* worst case: 1 cm */
|
||||
default: DoJog(this,-24); break; /* 1 mm */
|
||||
default: DoJog(this,-15); break; /* 0.X mm */
|
||||
}
|
||||
}
|
||||
DoJog(this,1); INST_ASSERT(); /* Correction for 1 check line */
|
||||
DBG(DEBUG_JUNK,"lt3=%d\n",(int)lt);
|
||||
return (this->state.bCanceled ? SANE_STATUS_CANCELLED : SANE_STATUS_GOOD);
|
||||
if (this->state.bCanceled)
|
||||
return SANE_STATUS_CANCELLED;
|
||||
return DoCalibration(this);
|
||||
}
|
||||
|
||||
/* **********************************************************************
|
||||
|
@ -233,7 +305,8 @@ The distance is given in 600 DPI.
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState DoJog(TInstance *this, int nDistance)
|
||||
__SM3600EXPORT__
|
||||
TState DoJog(TInstance *this, int nDistance)
|
||||
{
|
||||
int cSteps;
|
||||
int nSpeed,nRest;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
This file implements a dynamic linking based SANE meta backend. It
|
||||
allows managing an arbitrary number of SANE backends by using
|
||||
dynamic linking to load backends on demand. */
|
||||
|
||||
/* ======================================================================
|
||||
|
||||
Userspace scan tool for the Microtek 3600 scanner
|
||||
|
@ -65,7 +66,8 @@ Replay the first initialisation block (no slider movement).
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState DoInit(TInstance *this)
|
||||
__SM3600EXPORT__
|
||||
TState DoInit(TInstance *this)
|
||||
{
|
||||
unsigned char uchRegs2466[]={
|
||||
0x00 /*0x01*/, 0x00 /*0x02*/, 0x3F /*0x03*/,
|
||||
|
@ -105,7 +107,8 @@ Resets Scanner after CANCEL in current scan job.
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState DoReset(TInstance *this)
|
||||
__SM3600EXPORT__
|
||||
TState DoReset(TInstance *this)
|
||||
{
|
||||
RegWrite(this,0x43, 1, 0x03); /* #1533[038.1] */
|
||||
RegWrite(this,0x43, 1, 0x03); /* #1534[038.1] */
|
||||
|
@ -165,7 +168,8 @@ NOTE: Semantics changed: 0 on success, -1 else
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState WaitWhileBusy(TInstance *this, int cSecs)
|
||||
__SM3600EXPORT__
|
||||
TState WaitWhileBusy(TInstance *this, int cSecs)
|
||||
{
|
||||
int cTimeOut=cSecs*10;
|
||||
int value;
|
||||
|
@ -188,7 +192,8 @@ NOTE: Semantics changed: 0 on success, -1 else
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState WaitWhileScanning(TInstance *this, int cSecs)
|
||||
__SM3600EXPORT__
|
||||
TState WaitWhileScanning(TInstance *this, int cSecs)
|
||||
{
|
||||
int cTimeOut=cSecs*10;
|
||||
int value;
|
||||
|
@ -203,6 +208,8 @@ static TState WaitWhileScanning(TInstance *this, int cSecs)
|
|||
return SetError(this,SANE_STATUS_IO_ERROR,"Timeout while waiting for CSTAT");
|
||||
}
|
||||
|
||||
#ifdef INSANE_VERSION
|
||||
|
||||
/* **********************************************************************
|
||||
|
||||
DoLampSwitch(nRegister)
|
||||
|
@ -212,21 +219,13 @@ DoLampSwitch(nRegister)
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState DoLampSwitch(TInstance *this, int nPattern)
|
||||
__SM3600EXPORT__
|
||||
TState DoLampSwitch(TInstance *this, int nPattern)
|
||||
{
|
||||
return RegWrite(this, R_LMP, 1, nPattern);
|
||||
}
|
||||
|
||||
/* **********************************************************************
|
||||
|
||||
DoCalibration
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
static TState DoCalibration(TInstance *this)
|
||||
{
|
||||
return WaitWhileBusy(this,1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* **********************************************************************
|
||||
|
||||
|
@ -234,7 +233,8 @@ UploadGammaTable()
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState UploadGammaTable(TInstance *this, int iByteAddress, SANE_Int *pnGamma)
|
||||
__SM3600EXPORT__
|
||||
TState UploadGammaTable(TInstance *this, int iByteAddress, SANE_Int *pnGamma)
|
||||
{
|
||||
unsigned char *puchGamma;
|
||||
TState rc;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
This file implements a dynamic linking based SANE meta backend. It
|
||||
allows managing an arbitrary number of SANE backends by using
|
||||
dynamic linking to load backends on demand. */
|
||||
|
||||
#ifndef SCANTOOL_H
|
||||
#define SCANTOOL_H
|
||||
|
||||
|
@ -67,6 +68,9 @@
|
|||
|
||||
#ifdef INSANE_VERSION
|
||||
|
||||
/* make real exports */
|
||||
#define __SM3600EXPORT__
|
||||
|
||||
typedef enum { SANE_STATUS_GOOD,
|
||||
SANE_STATUS_CANCELLED,
|
||||
SANE_STATUS_UNSUPPORTED,
|
||||
|
@ -118,7 +122,9 @@ GLOBAL char *szScanFile;
|
|||
|
||||
GLOBAL TInstance devInstance;
|
||||
|
||||
#endif
|
||||
/* ====================================================================== */
|
||||
|
||||
#endif /* INSANE_VERSION */
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
This file implements a dynamic linking based SANE meta backend. It
|
||||
allows managing an arbitrary number of SANE backends by using
|
||||
dynamic linking to load backends on demand. */
|
||||
|
||||
/* ======================================================================
|
||||
|
||||
Userspace scan tool for the Microtek 3600 scanner
|
||||
|
@ -106,7 +107,8 @@ RegWriteArray(iRegister, cb, unsigned char uchValues)
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState RegWrite(TInstance *this, int iRegister, int cb, unsigned long ulValue)
|
||||
__SM3600EXPORT__
|
||||
TState RegWrite(TInstance *this, int iRegister, int cb, unsigned long ulValue)
|
||||
{
|
||||
char *pchBuffer;
|
||||
int i;
|
||||
|
@ -141,7 +143,8 @@ static TState RegWrite(TInstance *this, int iRegister, int cb, unsigned long ulV
|
|||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
static TState RegWriteArray(TInstance *this, int iRegister, int cb, unsigned char *pchBuffer)
|
||||
__SM3600EXPORT__
|
||||
TState RegWriteArray(TInstance *this, int iRegister, int cb, unsigned char *pchBuffer)
|
||||
{
|
||||
int i;
|
||||
INST_ASSERT();
|
||||
|
@ -164,7 +167,8 @@ MemWriteArray(iAddress, cb, ulValue)
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState MemWriteArray(TInstance *this, int iAddress,
|
||||
__SM3600EXPORT__
|
||||
TState MemWriteArray(TInstance *this, int iAddress,
|
||||
int cb, unsigned char *pchBuffer)
|
||||
{
|
||||
int i;
|
||||
|
@ -188,7 +192,10 @@ MemReadArray(iRegister, cb, ulValue)
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState MemReadArray(TInstance *this, int iAddress, int cb, unsigned char *pchBuffer)
|
||||
#ifdef INSANE_VERSION
|
||||
|
||||
__SM3600EXPORT__
|
||||
TState MemReadArray(TInstance *this, int iAddress, int cb, unsigned char *pchBuffer)
|
||||
{
|
||||
int i;
|
||||
INST_ASSERT();
|
||||
|
@ -211,7 +218,8 @@ RegCheck(iRegister, cb, ulValue)
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState RegCheck(TInstance *this, int iRegister, int cch, unsigned long ulValue)
|
||||
__SM3600EXPORT__
|
||||
TState RegCheck(TInstance *this, int iRegister, int cch, unsigned long ulValue)
|
||||
{
|
||||
char *pchBuffer,*pchTransfer;
|
||||
int i,rcCode;
|
||||
|
@ -270,7 +278,8 @@ cchRead=BulkRead(fh,cchBulk)
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static int BulkRead(TInstance *this, FILE *fhOut, unsigned int cchBulk)
|
||||
__SM3600EXPORT__
|
||||
int BulkRead(TInstance *this, FILE *fhOut, unsigned int cchBulk)
|
||||
{
|
||||
int cchRead,rc;
|
||||
char *pchBuffer;
|
||||
|
@ -321,13 +330,16 @@ static int BulkRead(TInstance *this, FILE *fhOut, unsigned int cchBulk)
|
|||
return rc ? -1 : cchRead;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* **********************************************************************
|
||||
|
||||
cchRead=BulkReadBuffer(puchBuffer, cchBulk)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
static int BulkReadBuffer(TInstance *this,
|
||||
__SM3600EXPORT__
|
||||
int BulkReadBuffer(TInstance *this,
|
||||
unsigned char *puchBufferOut,
|
||||
unsigned int cchBulk)
|
||||
{
|
||||
|
@ -380,7 +392,8 @@ Read register in big endian (INTEL-) format.
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static unsigned int RegRead(TInstance *this, int iRegister, int cch)
|
||||
__SM3600EXPORT__
|
||||
unsigned int RegRead(TInstance *this, int iRegister, int cch)
|
||||
{
|
||||
char *pchTransfer;
|
||||
int i;
|
||||
|
|
|
@ -68,7 +68,8 @@ void DBG(int nLevel, const char *szFormat, ...)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void debug_printf(unsigned long ulType, const char *szFormat, ...)
|
||||
__SM3600EXPORT__
|
||||
void debug_printf(unsigned long ulType, const char *szFormat, ...)
|
||||
{
|
||||
va_list ap;
|
||||
if ((ulDebugMask & ulType)!=ulType) return;
|
||||
|
@ -90,7 +91,8 @@ being global) and the user gets a nice panic screen :-)
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static int SetError(TInstance *this, int nError, const char *szFormat, ...)
|
||||
__SM3600EXPORT__
|
||||
int SetError(TInstance *this, int nError, const char *szFormat, ...)
|
||||
{
|
||||
va_list ap;
|
||||
if (this->nErrorState) return 0; /* do not overwrite error state */
|
||||
|
@ -107,13 +109,16 @@ static int SetError(TInstance *this, int nError, const char *szFormat, ...)
|
|||
return nError;
|
||||
}
|
||||
|
||||
#ifdef INSANE_VERSION
|
||||
|
||||
/* **********************************************************************
|
||||
|
||||
DumpBuffer(fh,pch,cch)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
static void DumpBuffer(FILE *fh, const char *pch, int cch)
|
||||
__SM3600EXPORT__
|
||||
void DumpBuffer(FILE *fh, const char *pch, int cch)
|
||||
{
|
||||
int i=0;
|
||||
while (i<cch)
|
||||
|
@ -129,6 +134,8 @@ static void DumpBuffer(FILE *fh, const char *pch, int cch)
|
|||
fprintf(fh,"\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* **********************************************************************
|
||||
|
||||
FixExposure()
|
||||
|
@ -138,7 +145,8 @@ augmenting the result around the middle value of 128.
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static void FixExposure(unsigned char *pchBuf,
|
||||
__SM3600EXPORT__
|
||||
void FixExposure(unsigned char *pchBuf,
|
||||
int cchBulk,
|
||||
int nBrightness,
|
||||
int nContrast)
|
||||
|
@ -166,7 +174,8 @@ Frees all dynamical memory for scan buffering.
|
|||
|
||||
********************************************************************** */
|
||||
|
||||
static TState FreeState(TInstance *this, TState nReturn)
|
||||
__SM3600EXPORT__
|
||||
TState FreeState(TInstance *this, TState nReturn)
|
||||
{
|
||||
if (this->state.ppchLines)
|
||||
{
|
||||
|
@ -192,7 +201,8 @@ EndScan()
|
|||
|
||||
====================================================================== */
|
||||
|
||||
static TState EndScan(TInstance *this)
|
||||
__SM3600EXPORT__
|
||||
TState EndScan(TInstance *this)
|
||||
{
|
||||
if (!this->state.bScanning) return SANE_STATUS_GOOD;
|
||||
/* move slider back to start */
|
||||
|
@ -208,7 +218,8 @@ TState CancelScan(TInstance *this)
|
|||
|
||||
====================================================================== */
|
||||
|
||||
static TState CancelScan(TInstance *this)
|
||||
__SM3600EXPORT__
|
||||
TState CancelScan(TInstance *this)
|
||||
{
|
||||
TBool bCanceled;
|
||||
DBG(DEBUG_INFO,"CancelScan() called\n");
|
||||
|
@ -239,7 +250,8 @@ ReadChunk()
|
|||
|
||||
====================================================================== */
|
||||
|
||||
static TState ReadChunk(TInstance *this, unsigned char *achOut,
|
||||
__SM3600EXPORT__
|
||||
TState ReadChunk(TInstance *this, unsigned char *achOut,
|
||||
int cchMax, int *pcchRead)
|
||||
{
|
||||
/* have we to copy more than we have? */
|
||||
|
@ -298,7 +310,8 @@ GetAreaSize()
|
|||
|
||||
====================================================================== */
|
||||
|
||||
static void GetAreaSize(TInstance *this)
|
||||
__SM3600EXPORT__
|
||||
void GetAreaSize(TInstance *this)
|
||||
{
|
||||
/* this->state.cxPixel : pixels, we *want* (after interpolation)
|
||||
this->state.cxMax : pixels, we *need* (before interpolation) */
|
||||
|
@ -320,18 +333,47 @@ static void GetAreaSize(TInstance *this)
|
|||
|
||||
/* ======================================================================
|
||||
|
||||
ResetCalibration()
|
||||
|
||||
Free calibration data. The Instance can be safely released afterwards.
|
||||
|
||||
====================================================================== */
|
||||
|
||||
__SM3600EXPORT__
|
||||
void ResetCalibration(TInstance *this)
|
||||
{
|
||||
if (this->calibration.achStripeY)
|
||||
free(this->calibration.achStripeY);
|
||||
if (this->calibration.achStripeR)
|
||||
free(this->calibration.achStripeR);
|
||||
if (this->calibration.achStripeG)
|
||||
free(this->calibration.achStripeG);
|
||||
if (this->calibration.achStripeB)
|
||||
free(this->calibration.achStripeB);
|
||||
/* reset all handles, pointers, flags */
|
||||
memset(&(this->calibration),0,sizeof(this->calibration));
|
||||
this->calibration.xMargin=200;
|
||||
this->calibration.yMargin=0x019D;
|
||||
this->calibration.nHoleGray=10;
|
||||
this->calibration.rgbBias=0x888884;
|
||||
this->calibration.nBarGray=0xC0;
|
||||
}
|
||||
|
||||
/* ======================================================================
|
||||
|
||||
InitGammaTables()
|
||||
|
||||
Init gammy tables and gain tables within controller memory.
|
||||
|
||||
====================================================================== */
|
||||
|
||||
static TState InitGammaTables(TInstance *this)
|
||||
__SM3600EXPORT__
|
||||
TState InitGammaTables(TInstance *this)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<4096; i++)
|
||||
{
|
||||
this->agammaGray[i]=i;
|
||||
this->agammaY[i]=i;
|
||||
this->agammaR[i]=i;
|
||||
this->agammaG[i]=i;
|
||||
this->agammaB[i]=i;
|
||||
|
@ -351,7 +393,8 @@ Top level caller for scantool.
|
|||
|
||||
#define APP_CHUNK_SIZE 8192
|
||||
|
||||
static TState DoScanFile(TInstance *this)
|
||||
__SM3600EXPORT__
|
||||
TState DoScanFile(TInstance *this)
|
||||
{
|
||||
int cx,cy;
|
||||
long lcchRead;
|
||||
|
|
|
@ -61,7 +61,7 @@ Start: 2.4.2001
|
|||
|
||||
#include <usb.h>
|
||||
|
||||
#define BUILD 1
|
||||
#define BUILD 3
|
||||
|
||||
#ifndef BACKEND_NAME
|
||||
#define BACKEND_NAME sm3600
|
||||
|
@ -71,15 +71,18 @@ Start: 2.4.2001
|
|||
#define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
#include "../include/sane/sane.h"
|
||||
#include "../include/sane/config.h"
|
||||
#include "../include/sane/sanei.h"
|
||||
#include "../include/sane/sanei_backend.h"
|
||||
#include "../include/sane/sanei_config.h"
|
||||
#include "../include/sane/saneopts.h"
|
||||
#include "sane/sane.h"
|
||||
#include "sane/config.h"
|
||||
#include "sane/sanei.h"
|
||||
#include "sane/sanei_backend.h"
|
||||
#include "sane/sanei_config.h"
|
||||
#include "sane/saneopts.h"
|
||||
|
||||
/* prevent inclusion of scantool.h */
|
||||
#define SCANTOOL_H
|
||||
/* make no real function export, since we include the modules */
|
||||
#define __SM3600EXPORT__ static
|
||||
|
||||
|
||||
#include "sm3600.h"
|
||||
|
||||
|
@ -110,7 +113,7 @@ typedef enum { optCount,
|
|||
optPreview, optGrayPreview,
|
||||
optGroupGeometry,optTLX, optTLY, optBRX, optBRY,
|
||||
optGroupEnhancement,
|
||||
optGammaGray, optGammaR,optGammaG,optGammaB,
|
||||
optGammaY, optGammaR,optGammaG,optGammaB,
|
||||
optLast } TOptionIndex;
|
||||
|
||||
static const SANE_String_Const aScanModes[]= { "color", "gray", "lineart",
|
||||
|
@ -135,7 +138,7 @@ static const SANE_Range rangeGamma = { 0, 4095, 1 };
|
|||
|
||||
static const SANE_Int setResolutions[] = { 5, 75,100,200,300,600 };
|
||||
|
||||
static SANE_Status
|
||||
SANE_Status
|
||||
InitOptions(TInstance *this)
|
||||
{
|
||||
TOptionIndex iOpt;
|
||||
|
@ -158,7 +161,7 @@ InitOptions(TInstance *this)
|
|||
static char *achDescXY[]= {
|
||||
SANE_DESC_SCAN_TL_X, SANE_DESC_SCAN_TL_Y,
|
||||
SANE_DESC_SCAN_BR_X, SANE_DESC_SCAN_BR_Y };
|
||||
static double afFullBed[] = { 20.0,30.0, 50.0, 80.0 }; /* TODO: calculate exactly! */
|
||||
static double afFullBed[] = { 22.0,30.0, 50.0, 80.0 }; /* TODO: calculate exactly! */
|
||||
static const SANE_Range *aRangesXY[] = { &rangeXmm,&rangeYmm,&rangeXmm,&rangeYmm };
|
||||
SANE_Option_Descriptor *pdesc;
|
||||
TOptionValue *pval;
|
||||
|
@ -266,7 +269,7 @@ InitOptions(TInstance *this)
|
|||
pdesc->constraint_type=SANE_CONSTRAINT_NONE;
|
||||
pdesc->cap = SANE_CAP_ADVANCED;
|
||||
break;
|
||||
case optGammaGray:
|
||||
case optGammaY:
|
||||
pdesc->name = SANE_NAME_GAMMA_VECTOR;
|
||||
pdesc->title = SANE_TITLE_GAMMA_VECTOR;
|
||||
pdesc->desc = SANE_DESC_GAMMA_VECTOR;
|
||||
|
@ -275,7 +278,7 @@ InitOptions(TInstance *this)
|
|||
pdesc->size = 4096*sizeof(SANE_Int);
|
||||
pdesc->constraint_type = SANE_CONSTRAINT_RANGE;
|
||||
pdesc->constraint.range = &rangeGamma;
|
||||
pval->wa = this->agammaGray;
|
||||
pval->wa = this->agammaY;
|
||||
break;
|
||||
case optGammaR:
|
||||
pdesc->name = SANE_NAME_GAMMA_VECTOR_R;
|
||||
|
@ -351,7 +354,9 @@ sane_init (SANE_Int *version_code, SANE_Auth_Callback authCB)
|
|||
|
||||
DBG_INIT();
|
||||
|
||||
DBG(DEBUG_VERBOSE,"SM3600 init (authCB %s NULL)\n", authCB ? "!=" : "=");
|
||||
authCB++; /* compiler */
|
||||
|
||||
DBG(DEBUG_VERBOSE,"SM3600 init\n");
|
||||
if (version_code)
|
||||
{
|
||||
*version_code = SANE_VERSION_CODE (V_MAJOR, V_MINOR, BUILD);
|
||||
|
@ -396,6 +401,8 @@ sane_init (SANE_Int *version_code, SANE_Auth_Callback authCB)
|
|||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
||||
static const SANE_Device ** devlist = 0; /* only pseudo-statical */
|
||||
|
||||
void
|
||||
sane_exit (void)
|
||||
{
|
||||
|
@ -412,20 +419,20 @@ sane_exit (void)
|
|||
free ((void *) dev->sane.name);
|
||||
free (dev);
|
||||
}
|
||||
if (devlist) free(devlist);
|
||||
devlist=NULL;
|
||||
}
|
||||
|
||||
SANE_Status
|
||||
sane_get_devices (const SANE_Device *** device_list,
|
||||
SANE_Bool local_only)
|
||||
{
|
||||
static const SANE_Device ** devlist = 0;
|
||||
TDevice *dev;
|
||||
int i;
|
||||
|
||||
local_only = TRUE; /* Avoid compile warning */
|
||||
|
||||
if (devlist)
|
||||
free (devlist);
|
||||
if (devlist) free (devlist);
|
||||
|
||||
devlist = malloc ((num_devices + 1) * sizeof (devlist[0]));
|
||||
if (!devlist)
|
||||
|
@ -460,8 +467,10 @@ sane_open (SANE_String_Const devicename, SANE_Handle *handle)
|
|||
return SANE_STATUS_INVAL;
|
||||
this = (TInstance*) calloc(1,sizeof(TInstance));
|
||||
if (!this) return SANE_STATUS_NO_MEM;
|
||||
|
||||
*handle = (SANE_Handle)this;
|
||||
|
||||
|
||||
ResetCalibration(this); /* do not release memory */
|
||||
this->pNext=pinstFirst; /* register open handle */
|
||||
pinstFirst=this;
|
||||
/* open and prepare USB scanner handle */
|
||||
|
@ -474,13 +483,7 @@ sane_open (SANE_String_Const devicename, SANE_Handle *handle)
|
|||
if (usb_set_configuration(this->hScanner, 1))
|
||||
return SetError(this,SANE_STATUS_IO_ERROR, "cannot set USB config 1");
|
||||
|
||||
this->calibration.xMargin=200;
|
||||
this->calibration.yMargin=0x019D;
|
||||
this->calibration.nHoleGray=10;
|
||||
this->calibration.rgbBias=0x888884;
|
||||
this->calibration.nBarGray=0xC0;
|
||||
this->quality=fast;
|
||||
|
||||
return InitOptions(this);
|
||||
}
|
||||
|
||||
|
@ -497,6 +500,7 @@ sane_close (SANE_Handle handle)
|
|||
usb_close(this->hScanner);
|
||||
this->hScanner=NULL;
|
||||
}
|
||||
ResetCalibration(this); /* release calibration data */
|
||||
/* unlink active device entry */
|
||||
pParent=NULL;
|
||||
for (p=pinstFirst; p; p=p->pNext)
|
||||
|
@ -574,7 +578,7 @@ sane_control_option (SANE_Handle handle, SANE_Int iOpt,
|
|||
case optMode:
|
||||
strcpy(pVal,this->aoptVal[iOpt].s);
|
||||
break;
|
||||
case optGammaGray:
|
||||
case optGammaY:
|
||||
case optGammaR:
|
||||
case optGammaG:
|
||||
case optGammaB:
|
||||
|
@ -612,7 +616,7 @@ sane_control_option (SANE_Handle handle, SANE_Int iOpt,
|
|||
| SANE_INFO_RELOAD_OPTIONS;
|
||||
strcpy(this->aoptVal[iOpt].s,pVal);
|
||||
break;
|
||||
case optGammaGray:
|
||||
case optGammaY:
|
||||
case optGammaR: case optGammaG: case optGammaB:
|
||||
DBG(DEBUG_INFO,"setting gamma #%d\n",iOpt);
|
||||
memcpy(this->aoptVal[iOpt].wa, pVal, this->aoptDesc[iOpt].size);
|
||||
|
@ -696,6 +700,7 @@ sane_start (SANE_Handle handle)
|
|||
if (this->state.bScanning) return SANE_STATUS_DEVICE_BUSY;
|
||||
rc=SetupInternalParameters(this);
|
||||
this->state.bCanceled=false;
|
||||
if (!rc) rc=DoInit(this); /* oopsi, we should initalise :-) */
|
||||
if (!rc) rc=DoOriginate(this,true);
|
||||
if (!rc) rc=DoJog(this,this->calibration.yMargin);
|
||||
if (rc) return rc;
|
||||
|
@ -766,9 +771,7 @@ sane_cancel (SANE_Handle handle)
|
|||
SANE_Status
|
||||
sane_set_io_mode(SANE_Handle h, SANE_Bool m)
|
||||
{
|
||||
SANE_Handle h_tmp;
|
||||
|
||||
h_tmp = h;
|
||||
h++;
|
||||
if (m==SANE_TRUE) /* no non-blocking-mode */
|
||||
return SANE_STATUS_UNSUPPORTED;
|
||||
return SANE_STATUS_GOOD;
|
||||
|
@ -777,11 +780,6 @@ sane_set_io_mode(SANE_Handle h, SANE_Bool m)
|
|||
SANE_Status
|
||||
sane_get_select_fd(SANE_Handle handle, SANE_Int *fd)
|
||||
{
|
||||
SANE_Handle handle_tmp;
|
||||
SANE_Int *fd_tmp;
|
||||
|
||||
handle_tmp = handle;
|
||||
fd_tmp = fd;
|
||||
|
||||
handle++; fd++;
|
||||
return SANE_STATUS_UNSUPPORTED; /* we have no file IO */
|
||||
}
|
||||
|
|
105
backend/sm3600.h
105
backend/sm3600.h
|
@ -66,6 +66,7 @@ Start: 2.4.2001
|
|||
#define DEBUG_REPLAY 0x0014
|
||||
#define DEBUG_BUFFER 0x0018
|
||||
#define DEBUG_SIGNALS 0x0020
|
||||
#define DEBUG_CALIB 0x0040
|
||||
|
||||
#define DEBUG_CRITICAL 1
|
||||
#define DEBUG_VERBOSE 2
|
||||
|
@ -76,6 +77,8 @@ Start: 2.4.2001
|
|||
|
||||
#define SCANNER_VENDOR 0x05DA
|
||||
|
||||
#define MAX_PIXEL_PER_SCANLINE 5300
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
typedef enum { false, true } TBool;
|
||||
|
@ -83,11 +86,16 @@ typedef enum { false, true } TBool;
|
|||
typedef SANE_Status TState;
|
||||
|
||||
typedef struct {
|
||||
TBool bCalibrated;
|
||||
int xMargin; /* in 1/600 inch */
|
||||
int yMargin; /* in 1/600 inch */
|
||||
unsigned char nHoleGray;
|
||||
unsigned char nBarGray;
|
||||
long rgbBias;
|
||||
unsigned char *achStripeY;
|
||||
unsigned char *achStripeR;
|
||||
unsigned char *achStripeG;
|
||||
unsigned char *achStripeB;
|
||||
} TCalibration;
|
||||
|
||||
typedef struct {
|
||||
|
@ -164,7 +172,7 @@ typedef struct TInstance {
|
|||
SANE_Option_Descriptor aoptDesc[NUM_OPTIONS];
|
||||
TOptionValue aoptVal[NUM_OPTIONS];
|
||||
#endif
|
||||
SANE_Int agammaGray[4096];
|
||||
SANE_Int agammaY[4096];
|
||||
SANE_Int agammaR[4096];
|
||||
SANE_Int agammaG[4096];
|
||||
SANE_Int agammaB[4096];
|
||||
|
@ -196,6 +204,8 @@ typedef struct TInstance {
|
|||
|
||||
/* ====================================================================== */
|
||||
|
||||
/* note: The first register has address 0x01 */
|
||||
|
||||
#define R_ALL 0x01
|
||||
|
||||
/* have to become an enumeration */
|
||||
|
@ -234,55 +244,60 @@ typedef enum { none, hpos, hposH, hres } TRegIndex;
|
|||
/* ====================================================================== */
|
||||
#define USB_CHUNK_SIZE 0x8000
|
||||
|
||||
/* scanutil.c */
|
||||
static int SetError(TInstance *this, int nError, const char *szFormat, ...);
|
||||
static void debug_printf(unsigned long ulType, const char *szFormat, ...);
|
||||
static void DumpBuffer(FILE *fh, const char *pch, int cch);
|
||||
static void FixExposure(unsigned char *pchBuf,
|
||||
int cchBulk,
|
||||
int nBrightness,
|
||||
int nContrast);
|
||||
static TState FreeState(TInstance *this, TState nReturn);
|
||||
static TState EndScan(TInstance *this);
|
||||
static TState ReadChunk(TInstance *this, unsigned char *achOut,
|
||||
int cchMax, int *pcchRead);
|
||||
static TState DoScanFile(TInstance *this);
|
||||
static void GetAreaSize(TInstance *this);
|
||||
static TState InitGammaTables(TInstance *this);
|
||||
static TState CancelScan(TInstance *this);
|
||||
/* sm3600-scanutil.c */
|
||||
__SM3600EXPORT__ int SetError(TInstance *this, int nError, const char *szFormat, ...);
|
||||
__SM3600EXPORT__ void debug_printf(unsigned long ulType, const char *szFormat, ...);
|
||||
__SM3600EXPORT__ void FixExposure(unsigned char *pchBuf,
|
||||
int cchBulk,
|
||||
int nBrightness,
|
||||
int nContrast);
|
||||
__SM3600EXPORT__ TState FreeState(TInstance *this, TState nReturn);
|
||||
__SM3600EXPORT__ TState EndScan(TInstance *this);
|
||||
__SM3600EXPORT__ TState ReadChunk(TInstance *this, unsigned char *achOut,
|
||||
int cchMax, int *pcchRead);
|
||||
#ifdef INSANE_VERSION
|
||||
__SM3600EXPORT__ void DumpBuffer(FILE *fh, const char *pch, int cch);
|
||||
__SM3600EXPORT__ TState DoScanFile(TInstance *this);
|
||||
#endif
|
||||
|
||||
/* scanmtek.c */
|
||||
__SM3600EXPORT__ void GetAreaSize(TInstance *this);
|
||||
__SM3600EXPORT__ void ResetCalibration(TInstance *this);
|
||||
|
||||
__SM3600EXPORT__ TState InitGammaTables(TInstance *this);
|
||||
__SM3600EXPORT__ TState CancelScan(TInstance *this);
|
||||
|
||||
/* sm3600-scanmtek.c */
|
||||
extern unsigned short aidProduct[];
|
||||
static TState DoInit(TInstance *this);
|
||||
static TState DoReset(TInstance *this);
|
||||
static TState WaitWhileBusy(TInstance *this,int cSecs);
|
||||
static TState WaitWhileScanning(TInstance *this,int cSecs);
|
||||
static TState DoJog(TInstance *this,int nDistance);
|
||||
static TState DoLampSwitch(TInstance *this,int nPattern);
|
||||
static TState DoCalibration(TInstance *this);
|
||||
static TState UploadGammaTable(TInstance *this, int iByteAddress, SANE_Int *pnGamma);
|
||||
__SM3600EXPORT__ TState DoInit(TInstance *this);
|
||||
__SM3600EXPORT__ TState DoReset(TInstance *this);
|
||||
__SM3600EXPORT__ TState WaitWhileBusy(TInstance *this,int cSecs);
|
||||
__SM3600EXPORT__ TState WaitWhileScanning(TInstance *this,int cSecs);
|
||||
#ifdef INSANE_VERSION
|
||||
__SM3600EXPORT__ TState DoLampSwitch(TInstance *this,int nPattern);
|
||||
#endif
|
||||
__SM3600EXPORT__ TState DoCalibration(TInstance *this);
|
||||
__SM3600EXPORT__ TState UploadGammaTable(TInstance *this, int iByteAddress, SANE_Int *pnGamma);
|
||||
|
||||
/* scanusb.c */
|
||||
static TState RegWrite(TInstance *this,int iRegister, int cb, unsigned long ulValue);
|
||||
static TState RegWriteArray(TInstance *this,int iRegister, int cb,
|
||||
unsigned char *pchBuffer);
|
||||
static TState RegCheck(TInstance *this,int iRegister, int cch, unsigned long ulValue);
|
||||
static int BulkRead(TInstance *this,FILE *fhOut, unsigned int cchBulk);
|
||||
static int BulkReadBuffer(TInstance *this,unsigned char *puchBufferOut,
|
||||
unsigned int cchBulk); /* gives count */
|
||||
static unsigned int RegRead(TInstance *this,int iRegister, int cch);
|
||||
static TState MemReadArray(TInstance *this, int iAddress, int cb,
|
||||
unsigned char *pchBuffer);
|
||||
static TState MemWriteArray(TInstance *this, int iAddress, int cb,
|
||||
unsigned char *pchBuffer);
|
||||
/* sm3600-scanusb.c */
|
||||
__SM3600EXPORT__ TState RegWrite(TInstance *this,int iRegister, int cb, unsigned long ulValue);
|
||||
__SM3600EXPORT__ TState RegWriteArray(TInstance *this,int iRegister, int cb, unsigned char *pchBuffer);
|
||||
#ifdef INSANE_VERSIONx
|
||||
__SM3600EXPORT__ TState RegCheck(TInstance *this,int iRegister, int cch, unsigned long ulValue);
|
||||
__SM3600EXPORT__ int BulkRead(TInstance *this,FILE *fhOut, unsigned int cchBulk);
|
||||
__SM3600EXPORT__ TState MemReadArray(TInstance *this, int iAddress, int cb, unsigned char *pchBuffer);
|
||||
#endif
|
||||
__SM3600EXPORT__ int BulkReadBuffer(TInstance *this,unsigned char *puchBufferOut, unsigned int cchBulk); /* gives count */
|
||||
__SM3600EXPORT__ unsigned int RegRead(TInstance *this,int iRegister, int cch);
|
||||
__SM3600EXPORT__ TState MemWriteArray(TInstance *this, int iAddress, int cb, unsigned char *pchBuffer);
|
||||
|
||||
/* gray.c */
|
||||
static TState StartScanGray(TInstance *this);
|
||||
/* color.c */
|
||||
static TState StartScanColor(TInstance *this);
|
||||
/* sm3600-gray.c */
|
||||
__SM3600EXPORT__ TState StartScanGray(TInstance *this);
|
||||
/* sm3600-color.c */
|
||||
__SM3600EXPORT__ TState StartScanColor(TInstance *this);
|
||||
|
||||
/* homerun.c */
|
||||
static TState DoOriginate(TInstance *this, TBool bStepOut);
|
||||
/* sm3600-homerun.c */
|
||||
__SM3600EXPORT__ TState DoOriginate(TInstance *this, TBool bStepOut);
|
||||
__SM3600EXPORT__ TState DoJog(TInstance *this,int nDistance);
|
||||
|
||||
/* ====================================================================== */
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ library implements a SANE (Scanner Access Now Easy) backend that
|
|||
provides access to some Microtek scanners with the Toshiba M011 custom
|
||||
USB chip. This backend should be considered alpha.
|
||||
.PP
|
||||
There exists a backend for Microtek scanners with SCSI command set.
|
||||
There exist a backends for Microtek scanners with SCSI command set.
|
||||
Refer to sane-microtek(5) and sane-microtek2(5) for details.
|
||||
.PP
|
||||
At present, the following
|
||||
|
|
Ładowanie…
Reference in New Issue