kopia lustrzana https://gitlab.com/sane-project/backends
Refactoring of Asic_SetWindow.
rodzic
93a79af5d3
commit
82a40d5dca
Plik diff jest za duży
Load Diff
|
@ -65,6 +65,17 @@
|
|||
#define BYTE3(x) (SANE_Byte)(((unsigned int)(x) >> 24) & 0xff)
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STATUS_GOOD = 0,
|
||||
STATUS_CANCELLED,
|
||||
STATUS_EOF,
|
||||
STATUS_DEVICE_BUSY,
|
||||
STATUS_INVAL,
|
||||
STATUS_MEM_ERROR,
|
||||
STATUS_IO_ERROR
|
||||
} STATUS;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FS_ATTACHED = 1,
|
||||
|
@ -85,6 +96,44 @@ typedef enum
|
|||
LS_NEGATIVE = 4
|
||||
} LIGHTSOURCE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SANE_Byte ReadWrite;
|
||||
SANE_Byte IsOnChipGamma;
|
||||
unsigned int StartAddress; /* only lower 3 bytes used */
|
||||
unsigned int RwSize; /* unit: byte; must be a multiple of 2 (?) */
|
||||
SANE_Byte *BufferPtr;
|
||||
} LLF_RAMACCESS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SANE_Byte MoveType;
|
||||
SANE_Byte MotorDriverIs3967;
|
||||
SANE_Byte MotorCurrent;
|
||||
} LLF_MOTOR_CURRENT_AND_PHASE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short StartSpeed;
|
||||
unsigned short EndSpeed;
|
||||
unsigned short AccStepBeforeScan;
|
||||
SANE_Byte DecStepAfterScan;
|
||||
unsigned short * lpMotorTable;
|
||||
} LLF_CALCULATEMOTORTABLE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SANE_Byte ActionMode; /* see ACTION_MODE constants defined above */
|
||||
SANE_Byte ActionType; /* see ACTION_TYPE constants defined above */
|
||||
unsigned short FixMoveSpeed;
|
||||
unsigned int FixMoveSteps; /* only lower 3 bytes used */
|
||||
unsigned short AccStep; /* max. value = 511 */
|
||||
SANE_Byte DecStep;
|
||||
|
||||
unsigned short wScanAccSteps;
|
||||
SANE_Byte bScanDecSteps;
|
||||
} LLF_MOTORMOVE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* AFE */
|
||||
|
@ -132,7 +181,6 @@ typedef struct
|
|||
SANE_Bool DirectionB;
|
||||
} ADConverter;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int fd; /* file descriptor of scanner */
|
||||
|
@ -151,17 +199,6 @@ typedef struct
|
|||
unsigned short * lpShadingTable;
|
||||
} Asic, *PAsic;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
STATUS_GOOD = 0,
|
||||
STATUS_CANCELLED,
|
||||
STATUS_EOF,
|
||||
STATUS_DEVICE_BUSY,
|
||||
STATUS_INVAL,
|
||||
STATUS_MEM_ERROR,
|
||||
STATUS_IO_ERROR
|
||||
} STATUS;
|
||||
|
||||
|
||||
/* debug levels */
|
||||
#define DBG_CRIT 0 /* critical errors that should be printed even
|
||||
|
@ -180,8 +217,8 @@ typedef enum
|
|||
#define DMA_BLOCK_SIZE (32 * 1024)
|
||||
|
||||
#define DRAM_TEST_SIZE 64
|
||||
#define DRAM_1Mx16_SIZE (1024*1024) /* unit: word */
|
||||
#define PackAreaStartAddress ((DRAM_1Mx16_SIZE/4)*3)
|
||||
#define DRAM_1Mx16_SIZE (1024 * 1024)
|
||||
#define PackAreaStartAddress ((DRAM_1Mx16_SIZE / 4) * 3)
|
||||
|
||||
#define ACTION_MODE_ACCDEC_MOVE 0
|
||||
#define ACTION_MODE_UNIFORM_SPEED_MOVE 1
|
||||
|
@ -205,11 +242,10 @@ typedef enum
|
|||
|
||||
#define WaitBufferOneLineSize 11000*6
|
||||
|
||||
#define ShadingTableSize(x) (((x + 10)*6) + ( ((x + 10)*6)/240)*16)
|
||||
#define ACC_DEC_STEP_TABLE_SIZE (512) /* unit: word */
|
||||
#define NUM_OF_ACC_DEC_STEP_TABLE (8) /* unit: word */
|
||||
#define TABLE_BASE_SIZE (1024*2*2*2*2) /* unit: word */
|
||||
#define TABLE_OFFSET_BASE (14) /* unit: word */
|
||||
#define ShadingTableSize(x) (((x + 10) * 6) + (((x + 10) * 6) / 240) * 16)
|
||||
#define MOTOR_TABLE_SIZE (512 * 8)
|
||||
#define TABLE_OFFSET_BASE 14
|
||||
#define TABLE_BASE_SIZE (1 << TABLE_OFFSET_BASE)
|
||||
#define LAMP0_PWM_DEFAULT 255
|
||||
#define LAMP1_PWM_DEFAULT 255
|
||||
|
||||
|
@ -934,122 +970,38 @@ typedef enum
|
|||
#define ES01_2CF_VALID_PIXEL_PARAMETER_OF_SEGMENT16 0x2CF
|
||||
|
||||
|
||||
static STATUS OpenScanChip (PAsic chip);
|
||||
static STATUS CloseScanChip (PAsic chip);
|
||||
static STATUS SafeInitialChip (PAsic chip);
|
||||
static STATUS DRAM_Test (PAsic chip);
|
||||
static void SetLineTimeAndExposure (PAsic chip);
|
||||
static void CCDTiming (PAsic chip);
|
||||
static STATUS IsCarriageHome (PAsic chip, SANE_Bool * LampHome);
|
||||
static STATUS WaitCarriageHome (PAsic chip);
|
||||
static void InitTiming (PAsic chip);
|
||||
static STATUS GetChipStatus (PAsic chip, SANE_Byte Selector, SANE_Byte * ChipStatus);
|
||||
static STATUS SetAFEGainOffset (PAsic chip);
|
||||
static void SetLEDTime (PAsic chip);
|
||||
static void SetScanMode (PAsic chip, SANE_Byte bScanBits);
|
||||
static void SetPackAddress (PAsic chip, unsigned short wWidth,
|
||||
unsigned short wX, double XRatioAdderDouble,
|
||||
double XRatioTypeDouble, SANE_Byte bClearPulseWidth,
|
||||
unsigned short * pValidPixelNumber);
|
||||
static void SetExtraSetting (PAsic chip, unsigned short wXResolution,
|
||||
unsigned short wCCD_PixelNumber,
|
||||
SANE_Bool bypassShading);
|
||||
|
||||
static STATUS WriteIOControl (PAsic chip, unsigned short wValue,
|
||||
unsigned short wIndex, unsigned short wLength,
|
||||
SANE_Byte * lpbuf);
|
||||
static STATUS ReadIOControl (PAsic chip, unsigned short wValue,
|
||||
unsigned short wIndex, unsigned short wLength,
|
||||
SANE_Byte * lpbuf);
|
||||
static STATUS Mustek_ClearFIFO (PAsic chip);
|
||||
static STATUS SwitchBank (PAsic chip, unsigned short reg);
|
||||
static STATUS Mustek_SendData (PAsic chip, unsigned short reg, SANE_Byte data);
|
||||
static STATUS Mustek_SendData2Byte (PAsic chip, unsigned short reg, SANE_Byte data);
|
||||
static STATUS Mustek_ReceiveData (PAsic chip, SANE_Byte * reg);
|
||||
static STATUS Mustek_WriteAddressLineForRegister (PAsic chip, SANE_Byte x);
|
||||
static STATUS WriteIOControl (PAsic chip, unsigned short wValue, unsigned short wIndex,
|
||||
unsigned short wLength, SANE_Byte * lpbuf);
|
||||
static STATUS ReadIOControl (PAsic chip, unsigned short wValue, unsigned short wIndex,
|
||||
unsigned short wLength, SANE_Byte * lpbuf);
|
||||
static STATUS Mustek_DMARead (PAsic chip, unsigned int size, SANE_Byte * lpdata);
|
||||
static STATUS Mustek_DMAWrite (PAsic chip, unsigned int size, SANE_Byte * lpdata);
|
||||
static STATUS Mustek_ClearFIFO (PAsic chip);
|
||||
static STATUS SetRWSize (PAsic chip, SANE_Byte ReadWrite, unsigned int size);
|
||||
static STATUS SwitchBank (PAsic chip, unsigned short reg);
|
||||
static STATUS Mustek_DMARead (PAsic chip, unsigned int size,
|
||||
SANE_Byte * lpData);
|
||||
static STATUS Mustek_DMAWrite (PAsic chip, unsigned int size,
|
||||
SANE_Byte * lpData);
|
||||
static STATUS Mustek_SendData2Byte (PAsic chip, unsigned short reg,
|
||||
SANE_Byte data);
|
||||
|
||||
static STATUS Asic_Open (PAsic chip);
|
||||
static STATUS Asic_Close (PAsic chip);
|
||||
static void Asic_Initialize (PAsic chip);
|
||||
static STATUS Asic_SetWindow (PAsic chip,
|
||||
SANE_Byte bScanType, SANE_Byte bScanBits,
|
||||
unsigned short wXResolution,
|
||||
unsigned short wYResolution,
|
||||
unsigned short wX, unsigned short wY,
|
||||
unsigned short wWidth, unsigned short wLength);
|
||||
static STATUS Asic_TurnLamp (PAsic chip, SANE_Bool isLampOn);
|
||||
static STATUS Asic_TurnTA (PAsic chip, SANE_Bool isTAOn);
|
||||
static void Asic_ResetADParameters (PAsic chip, LIGHTSOURCE lsLightSource);
|
||||
static STATUS Asic_ScanStart (PAsic chip);
|
||||
static STATUS Asic_ScanStop (PAsic chip);
|
||||
static STATUS Asic_ReadImage (PAsic chip, SANE_Byte * pBuffer, unsigned short LinesCount);
|
||||
|
||||
#if SANE_UNUSED
|
||||
static STATUS Asic_CheckFunctionKey (PAsic chip, SANE_Byte * key);
|
||||
#endif
|
||||
static STATUS Asic_IsTAConnected (PAsic chip, SANE_Bool *hasTA);
|
||||
|
||||
/* called by AdjustAD and FindTopLeft */
|
||||
static STATUS Asic_ReadCalibrationData (PAsic chip, SANE_Byte * pBuffer,
|
||||
unsigned int dwXferBytes, SANE_Byte bScanBits);
|
||||
|
||||
static STATUS Asic_MotorMove (PAsic chip, SANE_Bool isForward, unsigned int dwTotalSteps);
|
||||
static STATUS Asic_CarriageHome (PAsic chip);
|
||||
static STATUS Asic_SetShadingTable (PAsic chip, unsigned short * lpWhiteShading,
|
||||
unsigned short * lpDarkShading,
|
||||
unsigned short wXResolution, unsigned short wWidth);
|
||||
static STATUS Asic_WaitUnitReady (PAsic chip);
|
||||
|
||||
|
||||
/* ---------------------- ASIC motor defines -------------------------- */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SANE_Byte ReadWrite;
|
||||
SANE_Byte IsOnChipGamma;
|
||||
unsigned int StartAddress; /* only lower 3 bytes used */
|
||||
unsigned int RwSize; /* unit: byte; must be a multiple of 2 (?) */
|
||||
SANE_Byte *BufferPtr;
|
||||
} LLF_RAMACCESS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SANE_Byte MoveType;
|
||||
SANE_Byte MotorDriverIs3967;
|
||||
SANE_Byte MotorCurrent;
|
||||
} LLF_MOTOR_CURRENT_AND_PHASE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short StartSpeed;
|
||||
unsigned short EndSpeed;
|
||||
unsigned short AccStepBeforeScan;
|
||||
SANE_Byte DecStepAfterScan;
|
||||
unsigned short * lpMotorTable;
|
||||
} LLF_CALCULATEMOTORTABLE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SANE_Byte ActionMode; /* see ACTION_MODE constants defined above */
|
||||
SANE_Byte ActionType; /* see ACTION_TYPE constants defined above */
|
||||
unsigned short FixMoveSpeed;
|
||||
unsigned int FixMoveSteps; /* only lower 3 bytes used */
|
||||
unsigned short AccStep; /* max. value = 511 */
|
||||
SANE_Byte DecStep;
|
||||
|
||||
unsigned short wScanAccSteps;
|
||||
SANE_Byte bScanDecSteps;
|
||||
} LLF_MOTORMOVE;
|
||||
|
||||
|
||||
static void CalculateScanMotorTable (LLF_CALCULATEMOTORTABLE *
|
||||
lpCalculateMotorTable);
|
||||
static void CalculateMoveMotorTable (LLF_CALCULATEMOTORTABLE *
|
||||
lpCalculateMotorTable);
|
||||
static STATUS LLFSetRamAddress (PAsic chip, unsigned int dwStartAddr,
|
||||
unsigned int dwEndAddr,
|
||||
SANE_Byte byAccessTarget);
|
||||
static STATUS LLFRamAccess (PAsic chip, LLF_RAMACCESS * RamAccess);
|
||||
static void LLFSetMotorCurrentAndPhase (PAsic chip,
|
||||
LLF_MOTOR_CURRENT_AND_PHASE *
|
||||
MotorCurrentAndPhase);
|
||||
static STATUS LLFSetMotorTable (PAsic chip, unsigned int dwTableBaseAddr,
|
||||
unsigned short *MotorTablePtr);
|
||||
static STATUS LLFSetShadingTable (PAsic chip, unsigned int dwTableBaseAddr,
|
||||
unsigned int dwTableSize,
|
||||
unsigned short *ShadingTablePtr);
|
||||
static STATUS LLFMotorMove (PAsic chip, LLF_MOTORMOVE * LLF_MotorMove);
|
||||
static void SetMotorStepTable (PAsic chip, LLF_MOTORMOVE * MotorStepsTable,
|
||||
unsigned short wStartY,
|
||||
unsigned int dwScanImageSteps,
|
||||
|
@ -1057,13 +1009,70 @@ static void SetMotorStepTable (PAsic chip, LLF_MOTORMOVE * MotorStepsTable,
|
|||
static void SetMotorStepTableForCalibration (PAsic chip,
|
||||
LLF_MOTORMOVE * MotorStepsTable,
|
||||
unsigned int dwScanImageSteps);
|
||||
static STATUS LLFSetMotorTable (PAsic chip, unsigned short *MotorTablePtr);
|
||||
static void CalculateScanMotorTable (LLF_CALCULATEMOTORTABLE *
|
||||
lpCalculateMotorTable);
|
||||
static void CalculateMoveMotorTable (LLF_CALCULATEMOTORTABLE *
|
||||
lpCalculateMotorTable);
|
||||
static SANE_Byte CalculateMotorCurrent (unsigned short dwMotorSpeed);
|
||||
static STATUS LLFMotorMove (PAsic chip, LLF_MOTORMOVE * LLF_MotorMove);
|
||||
static STATUS LLFSetRamAddress (PAsic chip, unsigned int dwStartAddr,
|
||||
unsigned int dwEndAddr,
|
||||
SANE_Byte byAccessTarget);
|
||||
static STATUS LLFRamAccess (PAsic chip, LLF_RAMACCESS * RamAccess);
|
||||
static STATUS MotorBackHome (PAsic chip);
|
||||
|
||||
static void InitTiming (PAsic chip);
|
||||
static STATUS OpenScanChip (PAsic chip);
|
||||
static STATUS CloseScanChip (PAsic chip);
|
||||
static STATUS PrepareScanChip (PAsic chip);
|
||||
static STATUS SafeInitialChip (PAsic chip);
|
||||
static STATUS DRAM_Test (PAsic chip);
|
||||
static STATUS GetChipStatus (PAsic chip, SANE_Byte Selector,
|
||||
SANE_Byte * ChipStatus);
|
||||
static STATUS IsCarriageHome (PAsic chip, SANE_Bool * LampHome);
|
||||
static STATUS WaitCarriageHome (PAsic chip);
|
||||
static STATUS WaitUnitReady (PAsic chip);
|
||||
|
||||
static void SetCCDTiming (PAsic chip);
|
||||
static void SetLineTimeAndExposure (PAsic chip);
|
||||
static void SetLEDTime (PAsic chip);
|
||||
static void SetAFEGainOffset (PAsic chip);
|
||||
static void SetScanMode (PAsic chip, SANE_Byte bScanBits);
|
||||
static void SetPackAddress (PAsic chip, unsigned short wWidth,
|
||||
unsigned short wX, double XRatioAdderDouble,
|
||||
double XRatioTypeDouble, SANE_Byte bClearPulseWidth,
|
||||
unsigned short * pValidPixelNumber);
|
||||
static void SetExtraSettings (PAsic chip, unsigned short wXResolution,
|
||||
unsigned short wCCD_PixelNumber,
|
||||
SANE_Bool bypassShading);
|
||||
|
||||
static STATUS Asic_Open (PAsic chip);
|
||||
static STATUS Asic_Close (PAsic chip);
|
||||
static void Asic_Initialize (PAsic chip);
|
||||
static STATUS Asic_TurnLamp (PAsic chip, SANE_Bool isLampOn);
|
||||
static STATUS Asic_TurnTA (PAsic chip, SANE_Bool isTAOn);
|
||||
static STATUS Asic_SetWindow (PAsic chip,
|
||||
SANE_Byte bScanType, SANE_Byte bScanBits,
|
||||
unsigned short wXResolution,
|
||||
unsigned short wYResolution,
|
||||
unsigned short wX, unsigned short wY,
|
||||
unsigned short wWidth, unsigned short wLength);
|
||||
static void Asic_ResetADParameters (PAsic chip, LIGHTSOURCE lsLightSource);
|
||||
static STATUS Asic_ScanStart (PAsic chip);
|
||||
static STATUS Asic_ScanStop (PAsic chip);
|
||||
static STATUS Asic_ReadImage (PAsic chip, SANE_Byte * pBuffer,
|
||||
unsigned short LinesCount);
|
||||
#if SANE_UNUSED
|
||||
static STATUS Asic_CheckFunctionKey (PAsic chip, SANE_Byte * key);
|
||||
#endif
|
||||
static STATUS Asic_IsTAConnected (PAsic chip, SANE_Bool *hasTA);
|
||||
|
||||
/* called by AdjustAD and FindTopLeft */
|
||||
static STATUS Asic_ReadCalibrationData (PAsic chip, SANE_Byte * pBuffer,
|
||||
unsigned int dwXferBytes,
|
||||
SANE_Byte bScanBits);
|
||||
|
||||
static STATUS Asic_MotorMove (PAsic chip, SANE_Bool isForward,
|
||||
unsigned int dwTotalSteps);
|
||||
static STATUS Asic_CarriageHome (PAsic chip);
|
||||
static STATUS Asic_SetShadingTable (PAsic chip, unsigned short * lpWhiteShading,
|
||||
unsigned short * lpDarkShading,
|
||||
unsigned short wXResolution,
|
||||
unsigned short wWidth);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -231,13 +231,6 @@ MustScanner_BackHome (void)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (STATUS_GOOD != Asic_WaitUnitReady (&g_chip))
|
||||
{
|
||||
DBG (DBG_FUNC,
|
||||
"MustScanner_BackHome: Asic_WaitUnitReady return error\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Asic_Close (&g_chip);
|
||||
|
||||
DBG (DBG_FUNC, "MustScanner_BackHome: leave MustScanner_BackHome\n");
|
||||
|
@ -254,12 +247,6 @@ MustScanner_Prepare (SCANSOURCE ssScanSource)
|
|||
DBG (DBG_FUNC, "MustScanner_Prepare: Asic_Open return error\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (STATUS_GOOD != Asic_WaitUnitReady (&g_chip))
|
||||
{
|
||||
DBG (DBG_FUNC,
|
||||
"MustScanner_Prepare: Asic_WaitUnitReady return error\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (SS_Reflective == ssScanSource)
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue