kopia lustrzana https://gitlab.com/sane-project/backends
				
				
				
			Remove information-less comments, break long lines, fix indentation.
							rodzic
							
								
									fa8101e05e
								
							
						
					
					
						commit
						db37c13bb3
					
				| 
						 | 
					@ -50,13 +50,13 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "mustek_usb2_asic.h"
 | 
					#include "mustek_usb2_asic.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ---------------------- low level asic functions -------------------------- */
 | 
					/* ---------------------- low level ASIC functions -------------------------- */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static SANE_Byte RegisterBankStatus = -1;
 | 
					static SANE_Byte RegisterBankStatus = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static STATUS
 | 
					static STATUS
 | 
				
			||||||
WriteIOControl (PAsic chip, unsigned short wValue, unsigned short wIndex, unsigned short wLength,
 | 
					WriteIOControl (PAsic chip, unsigned short wValue, unsigned short wIndex,
 | 
				
			||||||
		SANE_Byte * lpbuf)
 | 
							unsigned short wLength, SANE_Byte * lpbuf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  STATUS status = STATUS_GOOD;
 | 
					  STATUS status = STATUS_GOOD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,8 +73,8 @@ WriteIOControl (PAsic chip, unsigned short wValue, unsigned short wIndex, unsign
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static STATUS
 | 
					static STATUS
 | 
				
			||||||
ReadIOControl (PAsic chip, unsigned short wValue, unsigned short wIndex, unsigned short wLength,
 | 
					ReadIOControl (PAsic chip, unsigned short wValue, unsigned short wIndex,
 | 
				
			||||||
	       SANE_Byte * lpbuf)
 | 
						       unsigned short wLength, SANE_Byte * lpbuf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  STATUS status = STATUS_GOOD;
 | 
					  STATUS status = STATUS_GOOD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -215,7 +215,7 @@ SetRWSize (PAsic chip, SANE_Byte ReadWrite, unsigned int size)
 | 
				
			||||||
  DBG (DBG_ASIC, "SetRWSize: Enter\n");
 | 
					  DBG (DBG_ASIC, "SetRWSize: Enter\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (ReadWrite == 0)
 | 
					  if (ReadWrite == 0)
 | 
				
			||||||
    {				/*write */
 | 
					    {				/* write */
 | 
				
			||||||
      status = Mustek_SendData (chip, 0x7C, (SANE_Byte) (size));
 | 
					      status = Mustek_SendData (chip, 0x7C, (SANE_Byte) (size));
 | 
				
			||||||
      if (status != STATUS_GOOD)
 | 
					      if (status != STATUS_GOOD)
 | 
				
			||||||
	return status;
 | 
						return status;
 | 
				
			||||||
| 
						 | 
					@ -422,7 +422,7 @@ Mustek_SendData2Byte (PAsic chip, unsigned short reg, SANE_Byte data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ---------------------- asic motor functions ----------------------------- */
 | 
					/* ---------------------- ASIC motor functions ----------------------------- */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static STATUS
 | 
					static STATUS
 | 
				
			||||||
LLFRamAccess (PAsic chip, LLF_RAMACCESS * RamAccess)
 | 
					LLFRamAccess (PAsic chip, LLF_RAMACCESS * RamAccess)
 | 
				
			||||||
| 
						 | 
					@ -447,7 +447,7 @@ LLFRamAccess (PAsic chip, LLF_RAMACCESS * RamAccess)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      Mustek_SendData (chip, ES01_A1_HostStartAddr8_15,
 | 
					      Mustek_SendData (chip, ES01_A1_HostStartAddr8_15,
 | 
				
			||||||
		       HIBYTE (RamAccess->
 | 
							       HIBYTE (RamAccess->
 | 
				
			||||||
			       LoStartAddress) | ES01_ACCESS_PRE_GAMMA);
 | 
								       LoStartAddress) | ACCESS_PRE_GAMMA_ES01);
 | 
				
			||||||
      Mustek_SendData (chip, ES01_A2_HostStartAddr16_21,
 | 
					      Mustek_SendData (chip, ES01_A2_HostStartAddr16_21,
 | 
				
			||||||
		       LOBYTE (RamAccess->HiStartAddress) | ACCESS_GAMMA_RAM);
 | 
							       LOBYTE (RamAccess->HiStartAddress) | ACCESS_GAMMA_RAM);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -470,8 +470,9 @@ LLFRamAccess (PAsic chip, LLF_RAMACCESS * RamAccess)
 | 
				
			||||||
  Mustek_ClearFIFO (chip);
 | 
					  Mustek_ClearFIFO (chip);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (RamAccess->ReadWrite == WRITE_RAM)
 | 
					  if (RamAccess->ReadWrite == WRITE_RAM)
 | 
				
			||||||
    {				/* Write RAM */
 | 
					    {				/* write RAM */
 | 
				
			||||||
      Mustek_DMAWrite (chip, RamAccess->RwSize, RamAccess->BufferPtr);	/* size must be even */
 | 
					      /* size must be even */
 | 
				
			||||||
 | 
					      Mustek_DMAWrite (chip, RamAccess->RwSize, RamAccess->BufferPtr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      /* steal read 2 byte */
 | 
					      /* steal read 2 byte */
 | 
				
			||||||
      usleep (20000);
 | 
					      usleep (20000);
 | 
				
			||||||
| 
						 | 
					@ -482,8 +483,9 @@ LLFRamAccess (PAsic chip, LLF_RAMACCESS * RamAccess)
 | 
				
			||||||
      DBG (DBG_ASIC, "end steal 2 byte!\n");
 | 
					      DBG (DBG_ASIC, "end steal 2 byte!\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    {				/* Read RAM */
 | 
					    {				/* read RAM */
 | 
				
			||||||
      Mustek_DMARead (chip, RamAccess->RwSize, RamAccess->BufferPtr);	/* size must be even */
 | 
					      /* size must be even */
 | 
				
			||||||
 | 
					      Mustek_DMARead (chip, RamAccess->RwSize, RamAccess->BufferPtr);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_ASIC, "LLFRamAccess: Exit\n");
 | 
					  DBG (DBG_ASIC, "LLFRamAccess: Exit\n");
 | 
				
			||||||
| 
						 | 
					@ -548,7 +550,7 @@ LLFSetMotorCurrentAndPhase (PAsic chip,
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      if (MotorCurrentAndPhase->MoveType == _4_TABLE_SPACE_FOR_FULL_STEP)
 | 
					      if (MotorCurrentAndPhase->MoveType == _4_TABLE_SPACE_FOR_FULL_STEP)
 | 
				
			||||||
	{			/* Full Step */
 | 
						{			/* full step */
 | 
				
			||||||
	  Mustek_SendData (chip, ES01_AB_PWM_CURRENT_CONTROL, 0x00);
 | 
						  Mustek_SendData (chip, ES01_AB_PWM_CURRENT_CONTROL, 0x00);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  /* 1 */
 | 
						  /* 1 */
 | 
				
			||||||
| 
						 | 
					@ -585,7 +587,7 @@ LLFSetMotorCurrentAndPhase (PAsic chip,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
      else if (MotorCurrentAndPhase->MoveType ==
 | 
					      else if (MotorCurrentAndPhase->MoveType ==
 | 
				
			||||||
	       _8_TABLE_SPACE_FOR_1_DIV_2_STEP)
 | 
						       _8_TABLE_SPACE_FOR_1_DIV_2_STEP)
 | 
				
			||||||
	{			/* Half Step */
 | 
						{			/* half step */
 | 
				
			||||||
	  Mustek_SendData (chip, ES01_AB_PWM_CURRENT_CONTROL, 0x01);
 | 
						  Mustek_SendData (chip, ES01_AB_PWM_CURRENT_CONTROL, 0x01);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  /* 1 */
 | 
						  /* 1 */
 | 
				
			||||||
| 
						 | 
					@ -1568,7 +1570,7 @@ LLFSetMotorTable (PAsic chip, LLF_SETMOTORTABLE * LLF_SetMotorTable)
 | 
				
			||||||
      RamAccess.HiStartAddress |= LLF_SetMotorTable->MotorTableAddress;
 | 
					      RamAccess.HiStartAddress |= LLF_SetMotorTable->MotorTableAddress;
 | 
				
			||||||
      RamAccess.HiStartAddress >>= (16 - TABLE_OFFSET_BASE);
 | 
					      RamAccess.HiStartAddress >>= (16 - TABLE_OFFSET_BASE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      RamAccess.RwSize = 512 * 2 * 8;	/* BYTE */
 | 
					      RamAccess.RwSize = 512 * 2 * 8;	/* unit: byte */
 | 
				
			||||||
      RamAccess.BufferPtr = (SANE_Byte *) LLF_SetMotorTable->MotorTablePtr;
 | 
					      RamAccess.BufferPtr = (SANE_Byte *) LLF_SetMotorTable->MotorTablePtr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      LLFRamAccess (chip, &RamAccess);
 | 
					      LLFRamAccess (chip, &RamAccess);
 | 
				
			||||||
| 
						 | 
					@ -1612,7 +1614,7 @@ LLFMotorMove (PAsic chip, LLF_MOTORMOVE * LLF_MotorMove)
 | 
				
			||||||
  Mustek_SendData (chip, ES01_C2_ChannelBlueExpEndPixelLSB, LOBYTE (101));
 | 
					  Mustek_SendData (chip, ES01_C2_ChannelBlueExpEndPixelLSB, LOBYTE (101));
 | 
				
			||||||
  Mustek_SendData (chip, ES01_C3_ChannelBlueExpEndPixelMSB, HIBYTE (101));
 | 
					  Mustek_SendData (chip, ES01_C3_ChannelBlueExpEndPixelMSB, HIBYTE (101));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* set motor accelerate steps, MAX 511 steps */
 | 
					  /* set motor accelerate steps, max. 511 steps */
 | 
				
			||||||
  Mustek_SendData (chip, ES01_E0_MotorAccStep0_7,
 | 
					  Mustek_SendData (chip, ES01_E0_MotorAccStep0_7,
 | 
				
			||||||
		   LOBYTE (LLF_MotorMove->AccStep));
 | 
							   LOBYTE (LLF_MotorMove->AccStep));
 | 
				
			||||||
  Mustek_SendData (chip, ES01_E1_MotorAccStep8_8,
 | 
					  Mustek_SendData (chip, ES01_E1_MotorAccStep8_8,
 | 
				
			||||||
| 
						 | 
					@ -1626,7 +1628,7 @@ LLFMotorMove (PAsic chip, LLF_MOTORMOVE * LLF_MotorMove)
 | 
				
			||||||
  Mustek_SendData (chip, ES01_E4_MotorStepOfMaxSpeed16_19, 0);
 | 
					  Mustek_SendData (chip, ES01_E4_MotorStepOfMaxSpeed16_19, 0);
 | 
				
			||||||
  DBG (DBG_ASIC, "FixMoveSteps=%d\n", LLF_MotorMove->FixMoveSteps);
 | 
					  DBG (DBG_ASIC, "FixMoveSteps=%d\n", LLF_MotorMove->FixMoveSteps);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* set motor decelerate steps, MAX 255 steps */
 | 
					  /* set motor decelerate steps, max. 255 steps */
 | 
				
			||||||
  Mustek_SendData (chip, ES01_E5_MotorDecStep, LLF_MotorMove->DecStep);
 | 
					  Mustek_SendData (chip, ES01_E5_MotorDecStep, LLF_MotorMove->DecStep);
 | 
				
			||||||
  DBG (DBG_ASIC, "DecStep=%d\n", LLF_MotorMove->DecStep);
 | 
					  DBG (DBG_ASIC, "DecStep=%d\n", LLF_MotorMove->DecStep);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1639,7 +1641,7 @@ LLFMotorMove (PAsic chip, LLF_MOTORMOVE * LLF_MotorMove)
 | 
				
			||||||
		   HIBYTE (LLF_MotorMove->FixMoveSpeed));
 | 
							   HIBYTE (LLF_MotorMove->FixMoveSpeed));
 | 
				
			||||||
  DBG (DBG_ASIC, "FixMoveSpeed=%d\n", LLF_MotorMove->FixMoveSpeed);
 | 
					  DBG (DBG_ASIC, "FixMoveSpeed=%d\n", LLF_MotorMove->FixMoveSpeed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Set motor type */
 | 
					  /* set motor type */
 | 
				
			||||||
  Mustek_SendData (chip, ES01_A6_MotorOption, LLF_MotorMove->MotorSelect |
 | 
					  Mustek_SendData (chip, ES01_A6_MotorOption, LLF_MotorMove->MotorSelect |
 | 
				
			||||||
		   LLF_MotorMove->HomeSensorSelect | LLF_MotorMove->
 | 
							   LLF_MotorMove->HomeSensorSelect | LLF_MotorMove->
 | 
				
			||||||
		   MotorMoveUnit);
 | 
							   MotorMoveUnit);
 | 
				
			||||||
| 
						 | 
					@ -1649,7 +1651,7 @@ LLFMotorMove (PAsic chip, LLF_MOTORMOVE * LLF_MotorMove)
 | 
				
			||||||
		   LLF_MotorMove->MotorSpeedUnit | LLF_MotorMove->
 | 
							   LLF_MotorMove->MotorSpeedUnit | LLF_MotorMove->
 | 
				
			||||||
		   MotorSyncUnit);
 | 
							   MotorSyncUnit);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Set action register */
 | 
					  /* set action register */
 | 
				
			||||||
  if (LLF_MotorMove->ActionType == ACTION_TYPE_BACKTOHOME)
 | 
					  if (LLF_MotorMove->ActionType == ACTION_TYPE_BACKTOHOME)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      DBG (DBG_ASIC, "ACTION_TYPE_BACKTOHOME\n");
 | 
					      DBG (DBG_ASIC, "ACTION_TYPE_BACKTOHOME\n");
 | 
				
			||||||
| 
						 | 
					@ -1682,7 +1684,7 @@ LLFMotorMove (PAsic chip, LLF_MOTORMOVE * LLF_MotorMove)
 | 
				
			||||||
		   0x27 | LLF_MotorMove->Lamp0PwmFreq | LLF_MotorMove->
 | 
							   0x27 | LLF_MotorMove->Lamp0PwmFreq | LLF_MotorMove->
 | 
				
			||||||
		   Lamp1PwmFreq);
 | 
							   Lamp1PwmFreq);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Set number of movement steps with fixed speed */
 | 
					  /* set number of movement steps with fixed speed */
 | 
				
			||||||
  Mustek_SendData (chip, ES01_E2_MotorStepOfMaxSpeed0_7,
 | 
					  Mustek_SendData (chip, ES01_E2_MotorStepOfMaxSpeed0_7,
 | 
				
			||||||
		   LOBYTE (motor_steps));
 | 
							   LOBYTE (motor_steps));
 | 
				
			||||||
  Mustek_SendData (chip, ES01_E3_MotorStepOfMaxSpeed8_15,
 | 
					  Mustek_SendData (chip, ES01_E3_MotorStepOfMaxSpeed8_15,
 | 
				
			||||||
| 
						 | 
					@ -1719,8 +1721,9 @@ LLFMotorMove (PAsic chip, LLF_MOTORMOVE * LLF_MotorMove)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static STATUS
 | 
					static STATUS
 | 
				
			||||||
SetMotorStepTable (PAsic chip, LLF_MOTORMOVE * MotorStepsTable, unsigned short wStartY,
 | 
					SetMotorStepTable (PAsic chip, LLF_MOTORMOVE * MotorStepsTable,
 | 
				
			||||||
		   unsigned int dwScanImageSteps, unsigned short wYResolution)
 | 
							   unsigned short wStartY, unsigned int dwScanImageSteps,
 | 
				
			||||||
 | 
							   unsigned short wYResolution)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  STATUS status = STATUS_GOOD;
 | 
					  STATUS status = STATUS_GOOD;
 | 
				
			||||||
  unsigned short wAccSteps = 511;
 | 
					  unsigned short wAccSteps = 511;
 | 
				
			||||||
| 
						 | 
					@ -1765,7 +1768,8 @@ SetMotorStepTable (PAsic chip, LLF_MOTORMOVE * MotorStepsTable, unsigned short w
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (wStartY < (wAccSteps + wForwardSteps + bDecSteps + wScanAccSteps))	/* not including T0,T1 steps */
 | 
					  /* not including T0,T1 steps */
 | 
				
			||||||
 | 
					  if (wStartY < (wAccSteps + wForwardSteps + bDecSteps + wScanAccSteps))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      wAccSteps = 1;
 | 
					      wAccSteps = 1;
 | 
				
			||||||
      bDecSteps = 1;
 | 
					      bDecSteps = 1;
 | 
				
			||||||
| 
						 | 
					@ -1872,7 +1876,7 @@ CalculateMotorTable (LLF_CALCULATEMOTORTABLE * lpCalculateMotorTable)
 | 
				
			||||||
  bScanDecSteps = lpCalculateMotorTable->DecStepAfterScan;
 | 
					  bScanDecSteps = lpCalculateMotorTable->DecStepAfterScan;
 | 
				
			||||||
  lpMotorTable = lpCalculateMotorTable->lpMotorTable;
 | 
					  lpMotorTable = lpCalculateMotorTable->lpMotorTable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Motor T0 & T6 acc table */
 | 
					  /* motor T0 & T6 acc table */
 | 
				
			||||||
  for (i = 0; i < 512; i++)
 | 
					  for (i = 0; i < 512; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      y = 6000 - 3500;
 | 
					      y = 6000 - 3500;
 | 
				
			||||||
| 
						 | 
					@ -1882,7 +1886,7 @@ CalculateMotorTable (LLF_CALCULATEMOTORTABLE * lpCalculateMotorTable)
 | 
				
			||||||
      lpMotorTable[i + 512 * 6] = (unsigned short) y;	/* T6 */
 | 
					      lpMotorTable[i + 512 * 6] = (unsigned short) y;	/* T6 */
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Motor T1 & T7 dec table */
 | 
					  /* motor T1 & T7 dec table */
 | 
				
			||||||
  for (i = 0; i < 256; i++)
 | 
					  for (i = 0; i < 256; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      y = 6000 - 3500;
 | 
					      y = 6000 - 3500;
 | 
				
			||||||
| 
						 | 
					@ -1945,7 +1949,8 @@ LLFCalculateMotorTable (LLF_CALCULATEMOTORTABLE * LLF_CalculateMotorTable)
 | 
				
			||||||
  for (i = 0; i < 512; i++)
 | 
					  for (i = 0; i < 512; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      /* before scan acc table */
 | 
					      /* before scan acc table */
 | 
				
			||||||
      y = (wStartSpeed - wEndSpeed) * pow (0.09, (M_PI_2 * i) / 512) + wEndSpeed;
 | 
					      y = (wStartSpeed - wEndSpeed) *
 | 
				
			||||||
 | 
					        pow (0.09, (M_PI_2 * i) / 512) + wEndSpeed;
 | 
				
			||||||
      lpMotorTable[i] = (unsigned short) y;
 | 
					      lpMotorTable[i] = (unsigned short) y;
 | 
				
			||||||
      lpMotorTable[i + 512 * 2] = (unsigned short) y;
 | 
					      lpMotorTable[i + 512 * 2] = (unsigned short) y;
 | 
				
			||||||
      lpMotorTable[i + 512 * 4] = (unsigned short) y;
 | 
					      lpMotorTable[i + 512 * 4] = (unsigned short) y;
 | 
				
			||||||
| 
						 | 
					@ -1954,7 +1959,8 @@ LLFCalculateMotorTable (LLF_CALCULATEMOTORTABLE * LLF_CalculateMotorTable)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (i = 0; i < 256; i++)
 | 
					  for (i = 0; i < 256; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      y = wStartSpeed - (wStartSpeed - wEndSpeed) * pow (0.3, (M_PI_2 * i) / 256);
 | 
					      y = wStartSpeed - (wStartSpeed - wEndSpeed) *
 | 
				
			||||||
 | 
					        pow (0.3, (M_PI_2 * i) / 256);
 | 
				
			||||||
      lpMotorTable[i + 512] = (unsigned short) y;
 | 
					      lpMotorTable[i + 512] = (unsigned short) y;
 | 
				
			||||||
      lpMotorTable[i + 512 * 3] = (unsigned short) y;
 | 
					      lpMotorTable[i + 512 * 3] = (unsigned short) y;
 | 
				
			||||||
      lpMotorTable[i + 512 * 5] = (unsigned short) y;
 | 
					      lpMotorTable[i + 512 * 5] = (unsigned short) y;
 | 
				
			||||||
| 
						 | 
					@ -1963,8 +1969,10 @@ LLFCalculateMotorTable (LLF_CALCULATEMOTORTABLE * LLF_CalculateMotorTable)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (i = 0; i < wScanAccSteps; i++)
 | 
					  for (i = 0; i < wScanAccSteps; i++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      y = (wStartSpeed - wEndSpeed) * (pow (0.09, (M_PI_2 * i) / wScanAccSteps) -
 | 
					      y = (wStartSpeed - wEndSpeed) *
 | 
				
			||||||
         pow (0.09, (M_PI_2 * (wScanAccSteps - 1)) / wScanAccSteps)) + wEndSpeed;
 | 
					        (pow (0.09, (M_PI_2 * i) / wScanAccSteps) -
 | 
				
			||||||
 | 
					         pow (0.09, (M_PI_2 * (wScanAccSteps - 1)) / wScanAccSteps)) +
 | 
				
			||||||
 | 
					        wEndSpeed;
 | 
				
			||||||
      lpMotorTable[i + 512 * 2] = (unsigned short) y;
 | 
					      lpMotorTable[i + 512 * 2] = (unsigned short) y;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2046,7 +2054,7 @@ MotorBackHome (PAsic chip, SANE_Byte WaitOrNoWait)
 | 
				
			||||||
  LLFSetMotorTable (chip, &LLF_SetMotorTable);
 | 
					  LLFSetMotorTable (chip, &LLF_SetMotorTable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  MotorMove.MotorSelect = MOTOR_0_ENABLE | MOTOR_1_DISABLE;
 | 
					  MotorMove.MotorSelect = MOTOR_0_ENABLE | MOTOR_1_DISABLE;
 | 
				
			||||||
  MotorMove.MotorMoveUnit = ES03_TABLE_DEFINE;
 | 
					  MotorMove.MotorMoveUnit = TABLE_DEFINE_ES03;
 | 
				
			||||||
  MotorMove.MotorSpeedUnit = SPEED_UNIT_1_PIXEL_TIME;
 | 
					  MotorMove.MotorSpeedUnit = SPEED_UNIT_1_PIXEL_TIME;
 | 
				
			||||||
  MotorMove.MotorSyncUnit = MOTOR_SYNC_UNIT_1_PIXEL_TIME;
 | 
					  MotorMove.MotorSyncUnit = MOTOR_SYNC_UNIT_1_PIXEL_TIME;
 | 
				
			||||||
  MotorMove.HomeSensorSelect = HOME_SENSOR_0_ENABLE;
 | 
					  MotorMove.HomeSensorSelect = HOME_SENSOR_0_ENABLE;
 | 
				
			||||||
| 
						 | 
					@ -2098,7 +2106,7 @@ LLFSetRamAddress (PAsic chip, unsigned int dwStartAddr, unsigned int dwEndAddr,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* ---------------------- medium level asic functions ---------------------- */
 | 
					/* ---------------------- medium level ASIC functions ---------------------- */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static STATUS
 | 
					static STATUS
 | 
				
			||||||
InitTiming (PAsic chip)
 | 
					InitTiming (PAsic chip)
 | 
				
			||||||
| 
						 | 
					@ -2115,7 +2123,7 @@ InitTiming (PAsic chip)
 | 
				
			||||||
  chip->Timing.AFE_ChannelD_LatchPos = 1546;
 | 
					  chip->Timing.AFE_ChannelD_LatchPos = 1546;
 | 
				
			||||||
  chip->Timing.AFE_Secondary_FF_LatchPos = 12;
 | 
					  chip->Timing.AFE_Secondary_FF_LatchPos = 12;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Sensor */
 | 
					  /* sensor */
 | 
				
			||||||
  chip->Timing.CCD_DummyCycleTiming = 0;
 | 
					  chip->Timing.CCD_DummyCycleTiming = 0;
 | 
				
			||||||
  chip->Timing.PHTG_PulseWidth = 12;
 | 
					  chip->Timing.PHTG_PulseWidth = 12;
 | 
				
			||||||
  chip->Timing.PHTG_WaitWidth = 1;
 | 
					  chip->Timing.PHTG_WaitWidth = 1;
 | 
				
			||||||
| 
						 | 
					@ -2128,7 +2136,7 @@ InitTiming (PAsic chip)
 | 
				
			||||||
  chip->Timing.ChannelB_StartPixel = 100;
 | 
					  chip->Timing.ChannelB_StartPixel = 100;
 | 
				
			||||||
  chip->Timing.ChannelB_EndPixel = 200;
 | 
					  chip->Timing.ChannelB_EndPixel = 200;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* 1200dpi Timing */
 | 
					  /* 1200 dpi Timing */
 | 
				
			||||||
  chip->Timing.CCD_PH2_Timing_1200 = 1048320;
 | 
					  chip->Timing.CCD_PH2_Timing_1200 = 1048320;
 | 
				
			||||||
  chip->Timing.CCD_PHRS_Timing_1200 = 983040;
 | 
					  chip->Timing.CCD_PHRS_Timing_1200 = 983040;
 | 
				
			||||||
  chip->Timing.CCD_PHCP_Timing_1200 = 61440;
 | 
					  chip->Timing.CCD_PHCP_Timing_1200 = 61440;
 | 
				
			||||||
| 
						 | 
					@ -2136,7 +2144,7 @@ InitTiming (PAsic chip)
 | 
				
			||||||
  chip->Timing.DE_CCD_SETUP_REGISTER_1200 = 32;
 | 
					  chip->Timing.DE_CCD_SETUP_REGISTER_1200 = 32;
 | 
				
			||||||
  chip->Timing.wCCDPixelNumber_1200 = 11250;
 | 
					  chip->Timing.wCCDPixelNumber_1200 = 11250;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* 600dpi Timing */
 | 
					  /* 600 dpi Timing */
 | 
				
			||||||
  chip->Timing.CCD_PH2_Timing_600 = 1048320;
 | 
					  chip->Timing.CCD_PH2_Timing_600 = 1048320;
 | 
				
			||||||
  chip->Timing.CCD_PHRS_Timing_600 = 983040;
 | 
					  chip->Timing.CCD_PHRS_Timing_600 = 983040;
 | 
				
			||||||
  chip->Timing.CCD_PHCP_Timing_600 = 61440;
 | 
					  chip->Timing.CCD_PHCP_Timing_600 = 61440;
 | 
				
			||||||
| 
						 | 
					@ -2389,7 +2397,7 @@ CCDTiming (PAsic chip)
 | 
				
			||||||
  unsigned int dwPH1, dwPH2, dwPHRS, dwPHCP;
 | 
					  unsigned int dwPH1, dwPH2, dwPHRS, dwPHCP;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_ASIC, "CCDTiming: Enter\n");
 | 
					  DBG (DBG_ASIC, "CCDTiming: Enter\n");
 | 
				
			||||||
  DBG (DBG_ASIC, "Dpi=%d\n", chip->Dpi);
 | 
					  DBG (DBG_ASIC, "dpi=%d\n", chip->Dpi);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (chip->firmwarestate < FS_OPENED)
 | 
					  if (chip->firmwarestate < FS_OPENED)
 | 
				
			||||||
    OpenScanChip (chip);
 | 
					    OpenScanChip (chip);
 | 
				
			||||||
| 
						 | 
					@ -2473,7 +2481,7 @@ CCDTiming (PAsic chip)
 | 
				
			||||||
  Mustek_SendData (chip, ES01_1D6_PH1_TIMING_ADJ_B2, (SANE_Byte) (dwPH1 >> 16));
 | 
					  Mustek_SendData (chip, ES01_1D6_PH1_TIMING_ADJ_B2, (SANE_Byte) (dwPH1 >> 16));
 | 
				
			||||||
  Mustek_SendData (chip, ES01_1D7_PH1_TIMING_ADJ_B3, (SANE_Byte) (dwPH1 >> 24));
 | 
					  Mustek_SendData (chip, ES01_1D7_PH1_TIMING_ADJ_B3, (SANE_Byte) (dwPH1 >> 24));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* set ccd ph1 ph2 rs cp */
 | 
					  /* set CCD ph1 ph2 rs cp */
 | 
				
			||||||
  Mustek_SendData (chip, ES01_D0_PH1_0, 0);
 | 
					  Mustek_SendData (chip, ES01_D0_PH1_0, 0);
 | 
				
			||||||
  Mustek_SendData (chip, ES01_D1_PH2_0, 4);
 | 
					  Mustek_SendData (chip, ES01_D1_PH2_0, 4);
 | 
				
			||||||
  Mustek_SendData (chip, ES01_D4_PHRS_0, 0);
 | 
					  Mustek_SendData (chip, ES01_D4_PHRS_0, 0);
 | 
				
			||||||
| 
						 | 
					@ -2557,14 +2565,14 @@ SetAFEGainOffset (PAsic chip)
 | 
				
			||||||
  DBG (DBG_ASIC, "SetAFEGainOffset: Enter\n");
 | 
					  DBG (DBG_ASIC, "SetAFEGainOffset: Enter\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (chip->AD.DirectionR)
 | 
					  if (chip->AD.DirectionR)
 | 
				
			||||||
    {				/* Negative */
 | 
					    {				/* negative */
 | 
				
			||||||
      Mustek_SendData (chip, ES01_60_AFE_AUTO_GAIN_OFFSET_RED_LB,
 | 
					      Mustek_SendData (chip, ES01_60_AFE_AUTO_GAIN_OFFSET_RED_LB,
 | 
				
			||||||
		       (chip->AD.GainR << 1) | 0x01);
 | 
							       (chip->AD.GainR << 1) | 0x01);
 | 
				
			||||||
      Mustek_SendData (chip, ES01_61_AFE_AUTO_GAIN_OFFSET_RED_HB,
 | 
					      Mustek_SendData (chip, ES01_61_AFE_AUTO_GAIN_OFFSET_RED_HB,
 | 
				
			||||||
		       chip->AD.OffsetR);
 | 
							       chip->AD.OffsetR);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    {				/* Positive */
 | 
					    {				/* positive */
 | 
				
			||||||
      Mustek_SendData (chip, ES01_60_AFE_AUTO_GAIN_OFFSET_RED_LB,
 | 
					      Mustek_SendData (chip, ES01_60_AFE_AUTO_GAIN_OFFSET_RED_LB,
 | 
				
			||||||
		       (chip->AD.GainR << 1));
 | 
							       (chip->AD.GainR << 1));
 | 
				
			||||||
      Mustek_SendData (chip, ES01_61_AFE_AUTO_GAIN_OFFSET_RED_HB,
 | 
					      Mustek_SendData (chip, ES01_61_AFE_AUTO_GAIN_OFFSET_RED_HB,
 | 
				
			||||||
| 
						 | 
					@ -2667,7 +2675,7 @@ SetAFEGainOffset (PAsic chip)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Mustek_SendData (chip, ES01_2A0_AFE_GAIN_OFFSET_CONTROL, 0x00);
 | 
					  Mustek_SendData (chip, ES01_2A0_AFE_GAIN_OFFSET_CONTROL, 0x00);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Set to AFE */
 | 
					  /* set to AFE */
 | 
				
			||||||
  Mustek_SendData (chip, ES01_04_ADAFEPGACH1, chip->AD.GainR);
 | 
					  Mustek_SendData (chip, ES01_04_ADAFEPGACH1, chip->AD.GainR);
 | 
				
			||||||
  Mustek_SendData (chip, ES01_06_ADAFEPGACH2, chip->AD.GainG);
 | 
					  Mustek_SendData (chip, ES01_06_ADAFEPGACH2, chip->AD.GainG);
 | 
				
			||||||
  Mustek_SendData (chip, ES01_08_ADAFEPGACH3, chip->AD.GainB);
 | 
					  Mustek_SendData (chip, ES01_08_ADAFEPGACH3, chip->AD.GainB);
 | 
				
			||||||
| 
						 | 
					@ -2698,7 +2706,7 @@ SetAFEGainOffset (PAsic chip)
 | 
				
			||||||
		   SCAN_BACK_TRACKING_DISABLE |
 | 
							   SCAN_BACK_TRACKING_DISABLE |
 | 
				
			||||||
		   INVERT_MOTOR_DIRECTION_DISABLE |
 | 
							   INVERT_MOTOR_DIRECTION_DISABLE |
 | 
				
			||||||
		   UNIFORM_MOTOR_AND_SCAN_SPEED_ENABLE |
 | 
							   UNIFORM_MOTOR_AND_SCAN_SPEED_ENABLE |
 | 
				
			||||||
		   ES01_STATIC_SCAN_DISABLE | MOTOR_TEST_LOOP_DISABLE);
 | 
							   STATIC_SCAN_DISABLE_ES01 | MOTOR_TEST_LOOP_DISABLE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Mustek_SendData (chip, ES01_9A_AFEControl,
 | 
					  Mustek_SendData (chip, ES01_9A_AFEControl,
 | 
				
			||||||
		   AD9826_AFE | AUTO_CHANGE_AFE_GAIN_OFFSET_DISABLE);
 | 
							   AD9826_AFE | AUTO_CHANGE_AFE_GAIN_OFFSET_DISABLE);
 | 
				
			||||||
| 
						 | 
					@ -2754,7 +2762,7 @@ SetScanMode (PAsic chip, SANE_Byte bScanBits)
 | 
				
			||||||
  SANE_Byte temp_f5_register = 0;
 | 
					  SANE_Byte temp_f5_register = 0;
 | 
				
			||||||
  SANE_Byte GrayBWChannel;
 | 
					  SANE_Byte GrayBWChannel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_ASIC, "SetScanMode(): Enter. Set f5 register\n");
 | 
					  DBG (DBG_ASIC, "SetScanMode(): Enter. Set F5 register\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (bScanBits >= 24)
 | 
					  if (bScanBits >= 24)
 | 
				
			||||||
    temp_f5_register |= COLOR_ES02;
 | 
					    temp_f5_register |= COLOR_ES02;
 | 
				
			||||||
| 
						 | 
					@ -2792,7 +2800,8 @@ SetScanMode (PAsic chip, SANE_Byte bScanBits)
 | 
				
			||||||
static STATUS
 | 
					static STATUS
 | 
				
			||||||
SetPackAddress (PAsic chip, unsigned short wWidth, unsigned short wX,
 | 
					SetPackAddress (PAsic chip, unsigned short wWidth, unsigned short wX,
 | 
				
			||||||
		double XRatioAdderDouble, double XRatioTypeDouble,
 | 
							double XRatioAdderDouble, double XRatioTypeDouble,
 | 
				
			||||||
		SANE_Byte byClear_Pulse_Width, unsigned short * PValidPixelNumber)
 | 
							SANE_Byte byClear_Pulse_Width,
 | 
				
			||||||
 | 
							unsigned short * PValidPixelNumber)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  STATUS status = STATUS_GOOD;
 | 
					  STATUS status = STATUS_GOOD;
 | 
				
			||||||
  unsigned short ValidPixelNumber;
 | 
					  unsigned short ValidPixelNumber;
 | 
				
			||||||
| 
						 | 
					@ -2905,7 +2914,7 @@ SetPackAddress (PAsic chip, unsigned short wWidth, unsigned short wX,
 | 
				
			||||||
  Mustek_SendData (chip, ES01_CF_TG_B_CONTROL, 0x3C);
 | 
					  Mustek_SendData (chip, ES01_CF_TG_B_CONTROL, 0x3C);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Set pack area address */
 | 
					  /* set pack area address */
 | 
				
			||||||
  DBG (DBG_ASIC, "PackAreaStartAddress=%d\n", PackAreaStartAddress);
 | 
					  DBG (DBG_ASIC, "PackAreaStartAddress=%d\n", PackAreaStartAddress);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Mustek_SendData (chip, ES01_16D_EXPOSURE_CYCLE1_SEGMENT1_START_ADDR_BYTE0,
 | 
					  Mustek_SendData (chip, ES01_16D_EXPOSURE_CYCLE1_SEGMENT1_START_ADDR_BYTE0,
 | 
				
			||||||
| 
						 | 
					@ -2933,7 +2942,7 @@ SetPackAddress (PAsic chip, unsigned short wWidth, unsigned short wX,
 | 
				
			||||||
  DBG (DBG_ASIC, "Set Invalid Pixel ok\n");
 | 
					  DBG (DBG_ASIC, "Set Invalid Pixel ok\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Set pack start address */
 | 
					  /* set pack start address */
 | 
				
			||||||
  Mustek_SendData (chip, ES01_19E_PACK_AREA_R_START_ADDR_BYTE0,
 | 
					  Mustek_SendData (chip, ES01_19E_PACK_AREA_R_START_ADDR_BYTE0,
 | 
				
			||||||
		   (SANE_Byte) (PackAreaStartAddress));
 | 
							   (SANE_Byte) (PackAreaStartAddress));
 | 
				
			||||||
  Mustek_SendData (chip, ES01_19F_PACK_AREA_R_START_ADDR_BYTE1,
 | 
					  Mustek_SendData (chip, ES01_19F_PACK_AREA_R_START_ADDR_BYTE1,
 | 
				
			||||||
| 
						 | 
					@ -2961,7 +2970,7 @@ SetPackAddress (PAsic chip, unsigned short wWidth, unsigned short wX,
 | 
				
			||||||
		   (SANE_Byte) ((PackAreaStartAddress +
 | 
							   (SANE_Byte) ((PackAreaStartAddress +
 | 
				
			||||||
			    (ValidPixelNumber * 4)) >> 16));
 | 
								    (ValidPixelNumber * 4)) >> 16));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Set pack end address */
 | 
					  /* set pack end address */
 | 
				
			||||||
  Mustek_SendData (chip, ES01_1A7_PACK_AREA_R_END_ADDR_BYTE0,
 | 
					  Mustek_SendData (chip, ES01_1A7_PACK_AREA_R_END_ADDR_BYTE0,
 | 
				
			||||||
		   (SANE_Byte) ((PackAreaStartAddress +
 | 
							   (SANE_Byte) ((PackAreaStartAddress +
 | 
				
			||||||
			    (ValidPixelNumber * 2 - 1))));
 | 
								    (ValidPixelNumber * 2 - 1))));
 | 
				
			||||||
| 
						 | 
					@ -3004,8 +3013,8 @@ SetPackAddress (PAsic chip, unsigned short wWidth, unsigned short wX,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static STATUS
 | 
					static STATUS
 | 
				
			||||||
SetExtraSetting (PAsic chip, unsigned short wXResolution, unsigned short wCCD_PixelNumber,
 | 
					SetExtraSetting (PAsic chip, unsigned short wXResolution,
 | 
				
			||||||
		 SANE_Bool isCalibrate)
 | 
							 unsigned short wCCD_PixelNumber, SANE_Bool isCalibrate)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  STATUS status = STATUS_GOOD;
 | 
					  STATUS status = STATUS_GOOD;
 | 
				
			||||||
  SANE_Byte temp_ff_register = 0;
 | 
					  SANE_Byte temp_ff_register = 0;
 | 
				
			||||||
| 
						 | 
					@ -3347,7 +3356,8 @@ Asic_Initialize (PAsic chip)
 | 
				
			||||||
static STATUS
 | 
					static STATUS
 | 
				
			||||||
Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
 | 
					Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
 | 
				
			||||||
		unsigned short wXResolution, unsigned short wYResolution,
 | 
							unsigned short wXResolution, unsigned short wYResolution,
 | 
				
			||||||
		unsigned short wX, unsigned short wY, unsigned short wWidth, unsigned short wLength)
 | 
							unsigned short wX, unsigned short wY, unsigned short wWidth,
 | 
				
			||||||
 | 
							unsigned short wLength)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  STATUS status = STATUS_GOOD;
 | 
					  STATUS status = STATUS_GOOD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3386,8 +3396,8 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
 | 
				
			||||||
  unsigned short wFullBank;
 | 
					  unsigned short wFullBank;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_ASIC, "Asic_SetWindow: Enter\n");
 | 
					  DBG (DBG_ASIC, "Asic_SetWindow: Enter\n");
 | 
				
			||||||
  DBG (DBG_ASIC,
 | 
					  DBG (DBG_ASIC, "bScanBits=%d,wXResolution=%d,wYResolution=%d,wX=%d,wY=%d," \
 | 
				
			||||||
       "bScanBits=%d,wXResolution=%d,wYResolution=%d,wX=%d,wY=%d,wWidth=%d,wLength=%d\n",
 | 
					                 "wWidth=%d,wLength=%d\n",
 | 
				
			||||||
       bScanBits, wXResolution, wYResolution, wX, wY, wWidth, wLength);
 | 
					       bScanBits, wXResolution, wYResolution, wX, wY, wWidth, wLength);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (lpMotorStepsTable == NULL)
 | 
					  if (lpMotorStepsTable == NULL)
 | 
				
			||||||
| 
						 | 
					@ -3515,14 +3525,14 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
 | 
				
			||||||
  if (chip->lsLightSource == LS_REFLECTIVE)
 | 
					  if (chip->lsLightSource == LS_REFLECTIVE)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      if (wXResolution > (SENSOR_DPI / 2))
 | 
					      if (wXResolution > (SENSOR_DPI / 2))
 | 
				
			||||||
	{			/* full ccd resolution 1200dpi */
 | 
						{			/* full CCD resolution 1200 dpi */
 | 
				
			||||||
	  wThinkCCDResolution = SENSOR_DPI;
 | 
						  wThinkCCDResolution = SENSOR_DPI;
 | 
				
			||||||
	  Mustek_SendData (chip, ES01_98_GPIOControl8_15, 0x01);
 | 
						  Mustek_SendData (chip, ES01_98_GPIOControl8_15, 0x01);
 | 
				
			||||||
	  Mustek_SendData (chip, ES01_96_GPIOValue8_15, 0x01);
 | 
						  Mustek_SendData (chip, ES01_96_GPIOValue8_15, 0x01);
 | 
				
			||||||
	  wCCD_PixelNumber = chip->Timing.wCCDPixelNumber_1200;
 | 
						  wCCD_PixelNumber = chip->Timing.wCCDPixelNumber_1200;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
	{			/* 600dpi */
 | 
						{			/* 600 dpi */
 | 
				
			||||||
	  wThinkCCDResolution = SENSOR_DPI / 2;
 | 
						  wThinkCCDResolution = SENSOR_DPI / 2;
 | 
				
			||||||
	  Mustek_SendData (chip, ES01_98_GPIOControl8_15, 0x01);
 | 
						  Mustek_SendData (chip, ES01_98_GPIOControl8_15, 0x01);
 | 
				
			||||||
	  Mustek_SendData (chip, ES01_96_GPIOValue8_15, 0x00);
 | 
						  Mustek_SendData (chip, ES01_96_GPIOValue8_15, 0x00);
 | 
				
			||||||
| 
						 | 
					@ -3573,7 +3583,7 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
 | 
				
			||||||
  /* calculate X ratio */
 | 
					  /* calculate X ratio */
 | 
				
			||||||
  XRatioTypeDouble = wXResolution;
 | 
					  XRatioTypeDouble = wXResolution;
 | 
				
			||||||
  XRatioTypeDouble /= wThinkCCDResolution;
 | 
					  XRatioTypeDouble /= wThinkCCDResolution;
 | 
				
			||||||
  XRatioTypeWord = (unsigned short) (XRatioTypeDouble * 32768);	/* 32768 = 2^15 */
 | 
					  XRatioTypeWord = (unsigned short) (XRatioTypeDouble * 32768);  /* x 2^15 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  XRatioAdderDouble = (double) (XRatioTypeWord) / 32768;
 | 
					  XRatioAdderDouble = (double) (XRatioTypeWord) / 32768;
 | 
				
			||||||
  XRatioAdderDouble = 1 / XRatioAdderDouble;
 | 
					  XRatioAdderDouble = 1 / XRatioAdderDouble;
 | 
				
			||||||
| 
						 | 
					@ -3587,7 +3597,7 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
 | 
				
			||||||
  /* SetMotorType */
 | 
					  /* SetMotorType */
 | 
				
			||||||
  Mustek_SendData (chip, ES01_A6_MotorOption, MOTOR_0_ENABLE |
 | 
					  Mustek_SendData (chip, ES01_A6_MotorOption, MOTOR_0_ENABLE |
 | 
				
			||||||
		   MOTOR_1_DISABLE |
 | 
							   MOTOR_1_DISABLE |
 | 
				
			||||||
		   HOME_SENSOR_0_ENABLE | ES03_TABLE_DEFINE);
 | 
							   HOME_SENSOR_0_ENABLE | TABLE_DEFINE_ES03);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Mustek_SendData (chip, ES01_F6_MotorControl1, SPEED_UNIT_1_PIXEL_TIME |
 | 
					  Mustek_SendData (chip, ES01_F6_MotorControl1, SPEED_UNIT_1_PIXEL_TIME |
 | 
				
			||||||
		   MOTOR_SYNC_UNIT_1_PIXEL_TIME);
 | 
							   MOTOR_SYNC_UNIT_1_PIXEL_TIME);
 | 
				
			||||||
| 
						 | 
					@ -3625,10 +3635,10 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
 | 
				
			||||||
  /* set white shading int and dec */
 | 
					  /* set white shading int and dec */
 | 
				
			||||||
  if (chip->lsLightSource == LS_REFLECTIVE)
 | 
					  if (chip->lsLightSource == LS_REFLECTIVE)
 | 
				
			||||||
    Mustek_SendData (chip, ES01_F8_WHITE_SHADING_DATA_FORMAT,
 | 
					    Mustek_SendData (chip, ES01_F8_WHITE_SHADING_DATA_FORMAT,
 | 
				
			||||||
		     ES01_SHADING_3_INT_13_DEC);
 | 
							     SHADING_3_INT_13_DEC_ES01);
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    Mustek_SendData (chip, ES01_F8_WHITE_SHADING_DATA_FORMAT,
 | 
					    Mustek_SendData (chip, ES01_F8_WHITE_SHADING_DATA_FORMAT,
 | 
				
			||||||
		     ES01_SHADING_4_INT_12_DEC);
 | 
							     SHADING_4_INT_12_DEC_ES01);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  SetPackAddress (chip, wWidth, wX, XRatioAdderDouble,
 | 
					  SetPackAddress (chip, wWidth, wX, XRatioAdderDouble,
 | 
				
			||||||
		  XRatioTypeDouble, 0, &ValidPixelNumber);
 | 
							  XRatioTypeDouble, 0, &ValidPixelNumber);
 | 
				
			||||||
| 
						 | 
					@ -3650,7 +3660,9 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
 | 
				
			||||||
  EndSpeed =
 | 
					  EndSpeed =
 | 
				
			||||||
    (unsigned short) ((dwLinePixelReport * wYResolution / Total_MotorDPI) /
 | 
					    (unsigned short) ((dwLinePixelReport * wYResolution / Total_MotorDPI) /
 | 
				
			||||||
	    wMultiMotorStep);
 | 
						    wMultiMotorStep);
 | 
				
			||||||
  SetMotorStepTable (chip, lpMotorStepsTable, wY, dwTotalLineTheBufferNeed * Total_MotorDPI / wYResolution * wMultiMotorStep, wYResolution);	/*modified by Chester 92/04/08 */
 | 
					  SetMotorStepTable (chip, lpMotorStepsTable, wY, dwTotalLineTheBufferNeed *
 | 
				
			||||||
 | 
					                       Total_MotorDPI / wYResolution * wMultiMotorStep,
 | 
				
			||||||
 | 
					                     wYResolution);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (EndSpeed >= 20000)
 | 
					  if (EndSpeed >= 20000)
 | 
				
			||||||
| 
						 | 
					@ -3667,7 +3679,7 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
 | 
				
			||||||
		   isScanBackTracking |
 | 
							   isScanBackTracking |
 | 
				
			||||||
		   INVERT_MOTOR_DIRECTION_DISABLE |
 | 
							   INVERT_MOTOR_DIRECTION_DISABLE |
 | 
				
			||||||
		   isUniformSpeedToScan |
 | 
							   isUniformSpeedToScan |
 | 
				
			||||||
		   ES01_STATIC_SCAN_DISABLE | MOTOR_TEST_LOOP_DISABLE);
 | 
							   STATIC_SCAN_DISABLE_ES01 | MOTOR_TEST_LOOP_DISABLE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (EndSpeed > 8000)
 | 
					  if (EndSpeed > 8000)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
| 
						 | 
					@ -3707,8 +3719,8 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
 | 
				
			||||||
  SetMotorCurrent (EndSpeed, &CurrentPhase);
 | 
					  SetMotorCurrent (EndSpeed, &CurrentPhase);
 | 
				
			||||||
  LLFSetMotorCurrentAndPhase (chip, &CurrentPhase);
 | 
					  LLFSetMotorCurrentAndPhase (chip, &CurrentPhase);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_ASIC,
 | 
					  DBG (DBG_ASIC, "EndSpeed = %d, BytesCountPerRow=%d, MotorCurrentTable=%d, " \
 | 
				
			||||||
       "EndSpeed = %d, BytesCountPerRow=%d, MotorCurrentTable=%d, LinePixelReport=%d\n",
 | 
					                 "LinePixelReport=%d\n",
 | 
				
			||||||
       EndSpeed, chip->dwBytesCountPerRow, CurrentPhase.MotorCurrentTableA[0],
 | 
					       EndSpeed, chip->dwBytesCountPerRow, CurrentPhase.MotorCurrentTableA[0],
 | 
				
			||||||
       dwLinePixelReport);
 | 
					       dwLinePixelReport);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3759,7 +3771,7 @@ Asic_SetWindow (PAsic chip, SANE_Byte bScanBits,
 | 
				
			||||||
  RamAccess.BufferPtr = (SANE_Byte *) chip->lpShadingTable;
 | 
					  RamAccess.BufferPtr = (SANE_Byte *) chip->lpShadingTable;
 | 
				
			||||||
  LLFRamAccess (chip, &RamAccess);
 | 
					  LLFRamAccess (chip, &RamAccess);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* tell scan chip the shading table address, unit is 2^15 bytes (2^14 words) */
 | 
					  /* tell scan chip the shading table address, unit is 2^15 bytes */
 | 
				
			||||||
  Mustek_SendData (chip, ES01_9B_ShadingTableAddrA14_A21,
 | 
					  Mustek_SendData (chip, ES01_9B_ShadingTableAddrA14_A21,
 | 
				
			||||||
		   (SANE_Byte) (dwShadingTableAddr >> TABLE_OFFSET_BASE));
 | 
							   (SANE_Byte) (dwShadingTableAddr >> TABLE_OFFSET_BASE));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4037,8 +4049,8 @@ Asic_ReadCalibrationData (PAsic chip, void * pBuffer,
 | 
				
			||||||
      pCalBuffer = (SANE_Byte *) malloc (dwXferBytes);
 | 
					      pCalBuffer = (SANE_Byte *) malloc (dwXferBytes);
 | 
				
			||||||
      if (pCalBuffer == NULL)
 | 
					      if (pCalBuffer == NULL)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	  DBG (DBG_ERR, 
 | 
						  DBG (DBG_ERR, "Asic_ReadCalibrationData: Can't malloc bCalBuffer " \
 | 
				
			||||||
		   "Asic_ReadCalibrationData: Can't malloc bCalBuffer memory\n");
 | 
						                "memory\n");
 | 
				
			||||||
	  return STATUS_MEM_ERROR;
 | 
						  return STATUS_MEM_ERROR;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4054,10 +4066,10 @@ Asic_ReadCalibrationData (PAsic chip, void * pBuffer,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      dwXferBytes /= 3;
 | 
					      dwXferBytes /= 3;
 | 
				
			||||||
      for (i = 0; i < dwXferBytes; i++)
 | 
					      for (i = 0; i < dwXferBytes; i++)
 | 
				
			||||||
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	  *((SANE_Byte *) pBuffer + i) = *(pCalBuffer + i * 3);
 | 
						  *((SANE_Byte *) pBuffer + i) = *(pCalBuffer + i * 3);
 | 
				
			||||||
	  *((SANE_Byte *) pBuffer + dwXferBytes + i) = *(pCalBuffer + i * 3 + 1);
 | 
						  *((SANE_Byte *) pBuffer + dwXferBytes + i) =
 | 
				
			||||||
 | 
						    *(pCalBuffer + i * 3 + 1);
 | 
				
			||||||
	  *((SANE_Byte *) pBuffer + dwXferBytes * 2 + i) =
 | 
						  *((SANE_Byte *) pBuffer + dwXferBytes * 2 + i) =
 | 
				
			||||||
	    *(pCalBuffer + i * 3 + 2);
 | 
						    *(pCalBuffer + i * 3 + 2);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -4134,7 +4146,7 @@ Asic_MotorMove (PAsic chip, SANE_Bool isForward, unsigned int dwTotalSteps)
 | 
				
			||||||
  free (NormalMoveMotorTable);
 | 
					  free (NormalMoveMotorTable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  MotorMove.MotorSelect = MOTOR_0_ENABLE | MOTOR_1_DISABLE;
 | 
					  MotorMove.MotorSelect = MOTOR_0_ENABLE | MOTOR_1_DISABLE;
 | 
				
			||||||
  MotorMove.MotorMoveUnit = ES03_TABLE_DEFINE;
 | 
					  MotorMove.MotorMoveUnit = TABLE_DEFINE_ES03;
 | 
				
			||||||
  MotorMove.MotorSpeedUnit = SPEED_UNIT_1_PIXEL_TIME;
 | 
					  MotorMove.MotorSpeedUnit = SPEED_UNIT_1_PIXEL_TIME;
 | 
				
			||||||
  MotorMove.MotorSyncUnit = MOTOR_SYNC_UNIT_1_PIXEL_TIME;
 | 
					  MotorMove.MotorSyncUnit = MOTOR_SYNC_UNIT_1_PIXEL_TIME;
 | 
				
			||||||
  MotorMove.HomeSensorSelect = HOME_SENSOR_0_ENABLE;
 | 
					  MotorMove.HomeSensorSelect = HOME_SENSOR_0_ENABLE;
 | 
				
			||||||
| 
						 | 
					@ -4209,11 +4221,13 @@ Asic_SetShadingTable (PAsic chip, unsigned short * lpWhiteShading,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* Clear old shading table, if present.
 | 
					  /* Clear old shading table, if present.
 | 
				
			||||||
     First 4 and last 5 elements of shading table cannot be used. */
 | 
					     First 4 and last 5 elements of shading table cannot be used. */
 | 
				
			||||||
  wShadingTableSize = (ShadingTableSize (wValidPixelNumber)) * sizeof (unsigned short);
 | 
					  wShadingTableSize = (ShadingTableSize (wValidPixelNumber)) *
 | 
				
			||||||
 | 
					    sizeof (unsigned short);
 | 
				
			||||||
  if (chip->lpShadingTable != NULL)
 | 
					  if (chip->lpShadingTable != NULL)
 | 
				
			||||||
    free (chip->lpShadingTable);
 | 
					    free (chip->lpShadingTable);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_ASIC, "Allocating a new shading table, size=%d byte\n", wShadingTableSize);
 | 
					  DBG (DBG_ASIC, "Allocating a new shading table, size=%d byte\n",
 | 
				
			||||||
 | 
					       wShadingTableSize);
 | 
				
			||||||
  chip->lpShadingTable = (SANE_Byte *) malloc (wShadingTableSize);
 | 
					  chip->lpShadingTable = (SANE_Byte *) malloc (wShadingTableSize);
 | 
				
			||||||
  if (chip->lpShadingTable == NULL)
 | 
					  if (chip->lpShadingTable == NULL)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
| 
						 | 
					@ -4310,8 +4324,9 @@ Asic_WaitCarriageHome (PAsic chip)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static STATUS
 | 
					static STATUS
 | 
				
			||||||
Asic_SetCalibrate (PAsic chip, SANE_Byte bScanBits, unsigned short wXResolution,
 | 
					Asic_SetCalibrate (PAsic chip, SANE_Byte bScanBits, unsigned short wXResolution,
 | 
				
			||||||
		   unsigned short wYResolution, unsigned short wX, unsigned short wY,
 | 
							   unsigned short wYResolution, unsigned short wX,
 | 
				
			||||||
		   unsigned short wWidth, unsigned short wLength, SANE_Bool isShading)
 | 
							   unsigned short wY, unsigned short wWidth,
 | 
				
			||||||
 | 
							   unsigned short wLength, SANE_Bool isShading)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  STATUS status = STATUS_GOOD;
 | 
					  STATUS status = STATUS_GOOD;
 | 
				
			||||||
  unsigned short ValidPixelNumber;
 | 
					  unsigned short ValidPixelNumber;
 | 
				
			||||||
| 
						 | 
					@ -4355,8 +4370,8 @@ Asic_SetCalibrate (PAsic chip, SANE_Byte bScanBits, unsigned short wXResolution,
 | 
				
			||||||
  unsigned short wFullBank;
 | 
					  unsigned short wFullBank;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_ASIC, "Asic_SetCalibrate: Enter\n");
 | 
					  DBG (DBG_ASIC, "Asic_SetCalibrate: Enter\n");
 | 
				
			||||||
  DBG (DBG_ASIC,
 | 
					  DBG (DBG_ASIC, "bScanBits=%d,wXResolution=%d, wYResolution=%d, wX=%d, " \
 | 
				
			||||||
       "bScanBits=%d,wXResolution=%d, wYResolution=%d,	wX=%d, wY=%d, wWidth=%d, wLength=%d\n",
 | 
					       "wY=%d, wWidth=%d, wLength=%d\n",
 | 
				
			||||||
       bScanBits, wXResolution, wYResolution, wX, wY, wWidth, wLength);
 | 
					       bScanBits, wXResolution, wYResolution, wX, wY, wWidth, wLength);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (lpMotorTable == NULL)
 | 
					  if (lpMotorTable == NULL)
 | 
				
			||||||
| 
						 | 
					@ -4518,13 +4533,13 @@ Asic_SetCalibrate (PAsic chip, SANE_Byte bScanBits, unsigned short wXResolution,
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      Mustek_SendData (chip, ES01_A6_MotorOption, MOTOR_0_ENABLE |
 | 
					      Mustek_SendData (chip, ES01_A6_MotorOption, MOTOR_0_ENABLE |
 | 
				
			||||||
		       MOTOR_1_DISABLE |
 | 
							       MOTOR_1_DISABLE |
 | 
				
			||||||
		       HOME_SENSOR_0_ENABLE | ES03_TABLE_DEFINE);
 | 
							       HOME_SENSOR_0_ENABLE | TABLE_DEFINE_ES03);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      Mustek_SendData (chip, ES01_A6_MotorOption, MOTOR_0_DISABLE |
 | 
					      Mustek_SendData (chip, ES01_A6_MotorOption, MOTOR_0_DISABLE |
 | 
				
			||||||
		       MOTOR_1_DISABLE |
 | 
							       MOTOR_1_DISABLE |
 | 
				
			||||||
		       HOME_SENSOR_0_ENABLE | ES03_TABLE_DEFINE);
 | 
							       HOME_SENSOR_0_ENABLE | TABLE_DEFINE_ES03);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  DBG (DBG_ASIC, "isMotorMove=%d\n", chip->isMotorMove);
 | 
					  DBG (DBG_ASIC, "isMotorMove=%d\n", chip->isMotorMove);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4599,8 +4614,8 @@ Asic_SetCalibrate (PAsic chip, SANE_Byte bScanBits, unsigned short wXResolution,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  SetScanMode (chip, bScanBits);
 | 
					  SetScanMode (chip, bScanBits);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_ASIC,
 | 
					  DBG (DBG_ASIC, "isMotorMoveToFirstLine=%d,isUniformSpeedToScan=%d," \
 | 
				
			||||||
       "isMotorMoveToFirstLine=%d,isUniformSpeedToScan=%d,isScanBackTracking=%d\n",
 | 
					                 "isScanBackTracking=%d\n",
 | 
				
			||||||
       isMotorMoveToFirstLine, isUniformSpeedToScan, isScanBackTracking);
 | 
					       isMotorMoveToFirstLine, isUniformSpeedToScan, isScanBackTracking);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4610,14 +4625,14 @@ Asic_SetCalibrate (PAsic chip, SANE_Byte bScanBits, unsigned short wXResolution,
 | 
				
			||||||
		   isScanBackTracking |
 | 
							   isScanBackTracking |
 | 
				
			||||||
		   INVERT_MOTOR_DIRECTION_DISABLE |
 | 
							   INVERT_MOTOR_DIRECTION_DISABLE |
 | 
				
			||||||
		   isUniformSpeedToScan |
 | 
							   isUniformSpeedToScan |
 | 
				
			||||||
		   ES01_STATIC_SCAN_DISABLE | MOTOR_TEST_LOOP_DISABLE);
 | 
							   STATIC_SCAN_DISABLE_ES01 | MOTOR_TEST_LOOP_DISABLE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (chip->lsLightSource == LS_REFLECTIVE)
 | 
					  if (chip->lsLightSource == LS_REFLECTIVE)
 | 
				
			||||||
    Mustek_SendData (chip, ES01_F8_WHITE_SHADING_DATA_FORMAT,
 | 
					    Mustek_SendData (chip, ES01_F8_WHITE_SHADING_DATA_FORMAT,
 | 
				
			||||||
		     ES01_SHADING_3_INT_13_DEC);
 | 
							     SHADING_3_INT_13_DEC_ES01);
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    Mustek_SendData (chip, ES01_F8_WHITE_SHADING_DATA_FORMAT,
 | 
					    Mustek_SendData (chip, ES01_F8_WHITE_SHADING_DATA_FORMAT,
 | 
				
			||||||
		     ES01_SHADING_4_INT_12_DEC);
 | 
							     SHADING_4_INT_12_DEC_ES01);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  SetPackAddress (chip, wWidth, wX, XRatioAdderDouble,
 | 
					  SetPackAddress (chip, wWidth, wX, XRatioAdderDouble,
 | 
				
			||||||
		  XRatioTypeDouble, byClear_Pulse_Width, &ValidPixelNumber);
 | 
							  XRatioTypeDouble, byClear_Pulse_Width, &ValidPixelNumber);
 | 
				
			||||||
| 
						 | 
					@ -4637,7 +4652,8 @@ Asic_SetCalibrate (PAsic chip, SANE_Byte bScanBits, unsigned short wXResolution,
 | 
				
			||||||
      DBG (DBG_ASIC, "Motor Time overflow!\n");
 | 
					      DBG (DBG_ASIC, "Motor Time overflow!\n");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  EndSpeed = (unsigned short) (dwLinePixelReport / (wNowMotorDPI / wYResolution));
 | 
					  EndSpeed = (unsigned short) (dwLinePixelReport /
 | 
				
			||||||
 | 
					    (wNowMotorDPI / wYResolution));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (wXResolution > 600)
 | 
					  if (wXResolution > 600)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											
												Plik diff jest za duży
												Load Diff
											
										
									
								
							| 
						 | 
					@ -48,14 +48,12 @@
 | 
				
			||||||
#include <pthread.h>		/* HOLD */
 | 
					#include <pthread.h>		/* HOLD */
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* local header files */
 | 
					 | 
				
			||||||
#include "mustek_usb2_asic.c"
 | 
					#include "mustek_usb2_asic.c"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "mustek_usb2_high.h"
 | 
					#include "mustek_usb2_high.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*global variable HOLD: these should go to scanner structure */
 | 
					/* HOLD: these global variables should go to scanner structure */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*base type*/
 | 
					 | 
				
			||||||
static SANE_Bool g_bOpened;
 | 
					static SANE_Bool g_bOpened;
 | 
				
			||||||
static SANE_Bool g_bPrepared;
 | 
					static SANE_Bool g_bPrepared;
 | 
				
			||||||
static SANE_Bool g_isCanceled;
 | 
					static SANE_Bool g_isCanceled;
 | 
				
			||||||
| 
						 | 
					@ -75,7 +73,7 @@ static unsigned short g_XDpi;
 | 
				
			||||||
static unsigned short g_YDpi;
 | 
					static unsigned short g_YDpi;
 | 
				
			||||||
static unsigned short g_SWWidth;
 | 
					static unsigned short g_SWWidth;
 | 
				
			||||||
static unsigned short g_SWHeight;
 | 
					static unsigned short g_SWHeight;
 | 
				
			||||||
static unsigned short g_wPixelDistance;		/*even & odd sensor problem */
 | 
					static unsigned short g_wPixelDistance;		/* even & odd sensor problem */
 | 
				
			||||||
static unsigned short g_wLineDistance;
 | 
					static unsigned short g_wLineDistance;
 | 
				
			||||||
static unsigned short g_wScanLinesPerBlock;
 | 
					static unsigned short g_wScanLinesPerBlock;
 | 
				
			||||||
static unsigned short g_wLineartThreshold;
 | 
					static unsigned short g_wLineartThreshold;
 | 
				
			||||||
| 
						 | 
					@ -95,7 +93,6 @@ static unsigned short *g_pGammaTable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static pthread_t g_threadid_readimage;
 | 
					static pthread_t g_threadid_readimage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*user define type*/
 | 
					 | 
				
			||||||
static COLORMODE g_ScanMode;
 | 
					static COLORMODE g_ScanMode;
 | 
				
			||||||
static TARGETIMAGE g_tiTarget;
 | 
					static TARGETIMAGE g_tiTarget;
 | 
				
			||||||
static SCANTYPE g_ScanType = ST_Reflective;
 | 
					static SCANTYPE g_ScanType = ST_Reflective;
 | 
				
			||||||
| 
						 | 
					@ -114,7 +111,7 @@ static unsigned short g_wStartPosition;
 | 
				
			||||||
static pthread_mutex_t g_scannedLinesMutex = PTHREAD_MUTEX_INITIALIZER;
 | 
					static pthread_mutex_t g_scannedLinesMutex = PTHREAD_MUTEX_INITIALIZER;
 | 
				
			||||||
static pthread_mutex_t g_readyLinesMutex = PTHREAD_MUTEX_INITIALIZER;
 | 
					static pthread_mutex_t g_readyLinesMutex = PTHREAD_MUTEX_INITIALIZER;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*for modify the last point*/
 | 
					/* for modifying the last point */
 | 
				
			||||||
static SANE_Byte * g_lpBefLineImageData = NULL;
 | 
					static SANE_Byte * g_lpBefLineImageData = NULL;
 | 
				
			||||||
static SANE_Bool g_bIsFirstReadBefData = TRUE;
 | 
					static SANE_Bool g_bIsFirstReadBefData = TRUE;
 | 
				
			||||||
static unsigned int g_dwAlreadyGetLines = 0;
 | 
					static unsigned int g_dwAlreadyGetLines = 0;
 | 
				
			||||||
| 
						 | 
					@ -128,15 +125,13 @@ static void ModifyLinePoint (SANE_Byte * lpImageData,
 | 
				
			||||||
			     SANE_Byte * lpImageDataBefore,
 | 
								     SANE_Byte * lpImageDataBefore,
 | 
				
			||||||
			     unsigned int dwBytesPerLine,
 | 
								     unsigned int dwBytesPerLine,
 | 
				
			||||||
			     unsigned int dwLinesCount,
 | 
								     unsigned int dwLinesCount,
 | 
				
			||||||
			     unsigned short wPixDistance, unsigned short wModPtCount);
 | 
								     unsigned short wPixDistance,
 | 
				
			||||||
 | 
								     unsigned short wModPtCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "mustek_usb2_reflective.c"
 | 
					#include "mustek_usb2_reflective.c"
 | 
				
			||||||
#include "mustek_usb2_transparent.c"
 | 
					#include "mustek_usb2_transparent.c"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					
 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if initialize the scanner success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_Init (void)
 | 
					MustScanner_Init (void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -178,11 +173,6 @@ MustScanner_Init (void)
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	check the scanner connect status
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if scanner's status is OK, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_GetScannerState (void)
 | 
					MustScanner_GetScannerState (void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -196,14 +186,6 @@ MustScanner_GetScannerState (void)
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Turn the lamp on or off
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	isLampOn: turn the lamp on or off
 | 
					 | 
				
			||||||
	isTALampOn: turn the TA lamp on or off
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if operation success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_PowerControl (SANE_Bool isLampOn, SANE_Bool isTALampOn)
 | 
					MustScanner_PowerControl (SANE_Bool isLampOn, SANE_Bool isTALampOn)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -246,11 +228,6 @@ MustScanner_PowerControl (SANE_Bool isLampOn, SANE_Bool isTALampOn)
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Turn the carriage home
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if the operation success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_BackHome (void)
 | 
					MustScanner_BackHome (void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -282,13 +259,6 @@ MustScanner_BackHome (void)
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	prepare the scan image
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	ssScanSource: the scan source
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if operation is success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_Prepare (SCANSOURCE ssScanSource)
 | 
					MustScanner_Prepare (SCANSOURCE ssScanSource)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -363,19 +333,9 @@ MustScanner_Prepare (SCANSOURCE ssScanSource)
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Filter the data
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	pSort: the sort data
 | 
					 | 
				
			||||||
	TotalCount: the total count 
 | 
					 | 
				
			||||||
	LowCount: the low count
 | 
					 | 
				
			||||||
	HighCount: the upper count
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	the data of Filter 	
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static unsigned short
 | 
					static unsigned short
 | 
				
			||||||
MustScanner_FiltLower (unsigned short * pSort, unsigned short TotalCount, unsigned short LowCount,
 | 
					MustScanner_FiltLower (unsigned short * pSort, unsigned short TotalCount,
 | 
				
			||||||
		       unsigned short HighCount)
 | 
							       unsigned short LowCount, unsigned short HighCount)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  unsigned short Bound = TotalCount - 1;
 | 
					  unsigned short Bound = TotalCount - 1;
 | 
				
			||||||
  unsigned short LeftCount = HighCount - LowCount;
 | 
					  unsigned short LeftCount = HighCount - LowCount;
 | 
				
			||||||
| 
						 | 
					@ -402,15 +362,6 @@ MustScanner_FiltLower (unsigned short * pSort, unsigned short TotalCount, unsign
 | 
				
			||||||
  return (unsigned short) (Sum / LeftCount);
 | 
					  return (unsigned short) (Sum / LeftCount);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Repair line when single CCD and color is 48bit
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	lpLine: point to image be repaired
 | 
					 | 
				
			||||||
	isOrderInvert: RGB or BGR
 | 
					 | 
				
			||||||
	wLinesCount: how many line be repaired
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if the operation is success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_GetRgb48BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					MustScanner_GetRgb48BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
			     unsigned short * wLinesCount)
 | 
								     unsigned short * wLinesCount)
 | 
				
			||||||
| 
						 | 
					@ -425,7 +376,7 @@ MustScanner_GetRgb48BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
  unsigned short wBTempData;
 | 
					  unsigned short wBTempData;
 | 
				
			||||||
  unsigned short i;
 | 
					  unsigned short i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine: call in \n");
 | 
					  DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine: call in\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  g_isCanceled = FALSE;
 | 
					  g_isCanceled = FALSE;
 | 
				
			||||||
  g_isScanning = TRUE;
 | 
					  g_isScanning = TRUE;
 | 
				
			||||||
| 
						 | 
					@ -582,7 +533,7 @@ MustScanner_GetRgb48BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
	      DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine: thread exit\n");
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine: thread exit\n");
 | 
				
			||||||
	      break;
 | 
						      break;
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
	}			/*end for */
 | 
						}			/* end for */
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  *wLinesCount = TotalXferLines;
 | 
					  *wLinesCount = TotalXferLines;
 | 
				
			||||||
| 
						 | 
					@ -593,15 +544,6 @@ MustScanner_GetRgb48BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Repair line when double CCD and color is 48bit
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	lpLine: point to image be repaired
 | 
					 | 
				
			||||||
	isOrderInvert: RGB or BGR
 | 
					 | 
				
			||||||
	wLinesCount: how many line be repaired
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if the operation is success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_GetRgb48BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					MustScanner_GetRgb48BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
				    unsigned short * wLinesCount)
 | 
									    unsigned short * wLinesCount)
 | 
				
			||||||
| 
						 | 
					@ -1028,20 +970,11 @@ MustScanner_GetRgb48BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
  *wLinesCount = TotalXferLines;
 | 
					  *wLinesCount = TotalXferLines;
 | 
				
			||||||
  g_isScanning = FALSE;
 | 
					  g_isScanning = FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_FUNC,
 | 
					  DBG (DBG_FUNC, "MustScanner_GetRgb48BitLine1200DPI: " \
 | 
				
			||||||
       "MustScanner_GetRgb48BitLine1200DPI: leave MustScanner_GetRgb48BitLine1200DPI\n");
 | 
					                 "leave MustScanner_GetRgb48BitLine1200DPI\n");
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Repair line when single CCD and color is 24bit
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	lpLine: point to image be repaired
 | 
					 | 
				
			||||||
	isOrderInvert: RGB or BGR
 | 
					 | 
				
			||||||
	wLinesCount: how many line be repaired
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if the operation is success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
			     unsigned short * wLinesCount)
 | 
								     unsigned short * wLinesCount)
 | 
				
			||||||
| 
						 | 
					@ -1132,9 +1065,12 @@ MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
		  byBlue = (byBlue + bNextPixel) >> 1;
 | 
							  byBlue = (byBlue + bNextPixel) >> 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef ENABLE_GAMMA
 | 
					#ifdef ENABLE_GAMMA
 | 
				
			||||||
		  tempR = (unsigned short) ((byRed << 4) | QBET4 (byBlue, byGreen));
 | 
							  tempR = (unsigned short) ((byRed << 4) |
 | 
				
			||||||
		  tempG = (unsigned short) ((byGreen << 4) | QBET4 (byRed, byBlue));
 | 
							    QBET4 (byBlue, byGreen));
 | 
				
			||||||
		  tempB = (unsigned short) ((byBlue << 4) | QBET4 (byGreen, byRed));
 | 
							  tempG = (unsigned short) ((byGreen << 4) |
 | 
				
			||||||
 | 
							    QBET4 (byRed, byBlue));
 | 
				
			||||||
 | 
							  tempB = (unsigned short) ((byBlue << 4) |
 | 
				
			||||||
 | 
							    QBET4 (byGreen, byRed));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		  *(lpLine + i * 3 + 0) =
 | 
							  *(lpLine + i * 3 + 0) =
 | 
				
			||||||
		    (unsigned char) (*(g_pGammaTable + tempR));
 | 
							    (unsigned char) (*(g_pGammaTable + tempR));
 | 
				
			||||||
| 
						 | 
					@ -1154,11 +1090,11 @@ MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
	      lpLine += g_SWBytesPerRow;
 | 
						      lpLine += g_SWBytesPerRow;
 | 
				
			||||||
	      AddReadyLines ();
 | 
						      AddReadyLines ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine: g_dwTotalTotalXferLines=%d,g_SWHeight=%d\n",
 | 
						           "g_dwTotalTotalXferLines=%d,g_SWHeight=%d\n",
 | 
				
			||||||
		   g_dwTotalTotalXferLines, g_SWHeight);
 | 
							   g_dwTotalTotalXferLines, g_SWHeight);
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine: g_SWBytesPerRow=%d\n",
 | 
						           "g_SWBytesPerRow=%d\n",
 | 
				
			||||||
		   g_SWBytesPerRow);
 | 
							   g_SWBytesPerRow);
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
	  if (g_isCanceled)
 | 
						  if (g_isCanceled)
 | 
				
			||||||
| 
						 | 
					@ -1202,7 +1138,8 @@ MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
		  byRed =
 | 
							  byRed =
 | 
				
			||||||
		    *(g_lpReadImageHead + wRLinePos * g_BytesPerRow + i * 3 +
 | 
							    *(g_lpReadImageHead + wRLinePos * g_BytesPerRow + i * 3 +
 | 
				
			||||||
		      0);
 | 
							      0);
 | 
				
			||||||
		  bNextPixel = *(g_lpReadImageHead + wRLinePos * g_BytesPerRow + (i + 1) * 3 + 0);	/*R-channel */
 | 
							  bNextPixel = *(g_lpReadImageHead + wRLinePos * g_BytesPerRow +
 | 
				
			||||||
 | 
							    (i + 1) * 3 + 0);	/* R channel */
 | 
				
			||||||
		  byRed = (byRed + bNextPixel) >> 1;
 | 
							  byRed = (byRed + bNextPixel) >> 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		  DBG (DBG_FUNC,
 | 
							  DBG (DBG_FUNC,
 | 
				
			||||||
| 
						 | 
					@ -1211,7 +1148,8 @@ MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
		  byGreen =
 | 
							  byGreen =
 | 
				
			||||||
		    *(g_lpReadImageHead + wGLinePos * g_BytesPerRow + i * 3 +
 | 
							    *(g_lpReadImageHead + wGLinePos * g_BytesPerRow + i * 3 +
 | 
				
			||||||
		      1);
 | 
							      1);
 | 
				
			||||||
		  bNextPixel = *(g_lpReadImageHead + wGLinePos * g_BytesPerRow + (i + 1) * 3 + 1);	/*G-channel */
 | 
							  bNextPixel = *(g_lpReadImageHead + wGLinePos * g_BytesPerRow +
 | 
				
			||||||
 | 
							    (i + 1) * 3 + 1);	/* G channel */
 | 
				
			||||||
		  byGreen = (byGreen + bNextPixel) >> 1;
 | 
							  byGreen = (byGreen + bNextPixel) >> 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		  DBG (DBG_FUNC,
 | 
							  DBG (DBG_FUNC,
 | 
				
			||||||
| 
						 | 
					@ -1220,7 +1158,8 @@ MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
		  byBlue =
 | 
							  byBlue =
 | 
				
			||||||
		    *(g_lpReadImageHead + wBLinePos * g_BytesPerRow + i * 3 +
 | 
							    *(g_lpReadImageHead + wBLinePos * g_BytesPerRow + i * 3 +
 | 
				
			||||||
		      2);
 | 
							      2);
 | 
				
			||||||
		  bNextPixel = *(g_lpReadImageHead + wBLinePos * g_BytesPerRow + (i + 1) * 3 + 2);	/*B-channel */
 | 
							  bNextPixel = *(g_lpReadImageHead + wBLinePos * g_BytesPerRow +
 | 
				
			||||||
 | 
							    (i + 1) * 3 + 2);	/* B channel */
 | 
				
			||||||
		  byBlue = (byBlue + bNextPixel) >> 1;
 | 
							  byBlue = (byBlue + bNextPixel) >> 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1255,11 +1194,11 @@ MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
	      lpLine += g_SWBytesPerRow;
 | 
						      lpLine += g_SWBytesPerRow;
 | 
				
			||||||
	      AddReadyLines ();
 | 
						      AddReadyLines ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine: g_dwTotalTotalXferLines=%d,g_SWHeight=%d\n",
 | 
						           "g_dwTotalTotalXferLines=%d,g_SWHeight=%d\n",
 | 
				
			||||||
		   g_dwTotalTotalXferLines, g_SWHeight);
 | 
							   g_dwTotalTotalXferLines, g_SWHeight);
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine: g_SWBytesPerRow=%d\n",
 | 
						           "g_SWBytesPerRow=%d\n",
 | 
				
			||||||
		   g_SWBytesPerRow);
 | 
							   g_SWBytesPerRow);
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
	  if (g_isCanceled)
 | 
						  if (g_isCanceled)
 | 
				
			||||||
| 
						 | 
					@ -1270,7 +1209,7 @@ MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	      break;
 | 
						      break;
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
	}			/*end for */
 | 
						}			/* end for */
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  *wLinesCount = TotalXferLines;
 | 
					  *wLinesCount = TotalXferLines;
 | 
				
			||||||
| 
						 | 
					@ -1281,15 +1220,6 @@ MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Repair line when double CCD and color is 24bit
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	lpLine: point to image be repaired
 | 
					 | 
				
			||||||
	isOrderInvert: RGB or BGR
 | 
					 | 
				
			||||||
	wLinesCount: how many line be repaired
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if the operation is success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
				    unsigned short * wLinesCount)
 | 
									    unsigned short * wLinesCount)
 | 
				
			||||||
| 
						 | 
					@ -1332,11 +1262,11 @@ MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	  if (g_dwTotalTotalXferLines >= g_SWHeight)
 | 
						  if (g_dwTotalTotalXferLines >= g_SWHeight)
 | 
				
			||||||
	    {
 | 
						    {
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine1200DPI: g_dwTotalTotalXferLines=%d\n",
 | 
						           "g_dwTotalTotalXferLines=%d\n",
 | 
				
			||||||
		   g_dwTotalTotalXferLines);
 | 
							   g_dwTotalTotalXferLines);
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine1200DPI: g_Height=%d\n",
 | 
						           "g_Height=%d\n",
 | 
				
			||||||
		   g_Height);
 | 
							   g_Height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	      pthread_cancel (g_threadid_readimage);
 | 
						      pthread_cancel (g_threadid_readimage);
 | 
				
			||||||
| 
						 | 
					@ -1395,19 +1325,22 @@ MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
		      byRed =
 | 
							      byRed =
 | 
				
			||||||
			*(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow +
 | 
								*(g_lpReadImageHead + wRLinePosOdd * g_BytesPerRow +
 | 
				
			||||||
			  i * 3 + 0);
 | 
								  i * 3 + 0);
 | 
				
			||||||
		      bNextPixel = *(g_lpReadImageHead + wRLinePosEven * g_BytesPerRow + (i + 1) * 3 + 0);	/*R-channel */
 | 
							      bNextPixel = *(g_lpReadImageHead + wRLinePosEven *
 | 
				
			||||||
 | 
							        g_BytesPerRow + (i + 1) * 3 + 0);	/* R channel */
 | 
				
			||||||
		      byRed = (byRed + bNextPixel) >> 1;
 | 
							      byRed = (byRed + bNextPixel) >> 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		      byGreen =
 | 
							      byGreen =
 | 
				
			||||||
			*(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow +
 | 
								*(g_lpReadImageHead + wGLinePosOdd * g_BytesPerRow +
 | 
				
			||||||
			  i * 3 + 1);
 | 
								  i * 3 + 1);
 | 
				
			||||||
		      bNextPixel = *(g_lpReadImageHead + wGLinePosEven * g_BytesPerRow + (i + 1) * 3 + 1);	/*G-channel */
 | 
							      bNextPixel = *(g_lpReadImageHead + wGLinePosEven *
 | 
				
			||||||
 | 
							        g_BytesPerRow + (i + 1) * 3 + 1);	/* G channel */
 | 
				
			||||||
		      byGreen = (byGreen + bNextPixel) >> 1;
 | 
							      byGreen = (byGreen + bNextPixel) >> 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		      byBlue =
 | 
							      byBlue =
 | 
				
			||||||
			*(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow +
 | 
								*(g_lpReadImageHead + wBLinePosOdd * g_BytesPerRow +
 | 
				
			||||||
			  i * 3 + 2);
 | 
								  i * 3 + 2);
 | 
				
			||||||
		      bNextPixel = *(g_lpReadImageHead + wBLinePosEven * g_BytesPerRow + (i + 1) * 3 + 2);	/*B-channel */
 | 
							      bNextPixel = *(g_lpReadImageHead + wBLinePosEven *
 | 
				
			||||||
 | 
							        g_BytesPerRow + (i + 1) * 3 + 2);	/* B channel */
 | 
				
			||||||
		      byBlue = (byBlue + bNextPixel) >> 1;
 | 
							      byBlue = (byBlue + bNextPixel) >> 1;
 | 
				
			||||||
#ifdef ENABLE_GAMMA
 | 
					#ifdef ENABLE_GAMMA
 | 
				
			||||||
		      *(lpLine + i * 3 + 0) =
 | 
							      *(lpLine + i * 3 + 0) =
 | 
				
			||||||
| 
						 | 
					@ -1491,11 +1424,11 @@ MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
	      lpLine += g_SWBytesPerRow;
 | 
						      lpLine += g_SWBytesPerRow;
 | 
				
			||||||
	      AddReadyLines ();
 | 
						      AddReadyLines ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine1200DPI: g_dwTotalTotalXferLines=%d\n",
 | 
						           "g_dwTotalTotalXferLines=%d\n",
 | 
				
			||||||
		   g_dwTotalTotalXferLines);
 | 
							   g_dwTotalTotalXferLines);
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine1200DPI: g_Height=%d\n",
 | 
						           "g_Height=%d\n",
 | 
				
			||||||
		   g_Height);
 | 
							   g_Height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
| 
						 | 
					@ -1518,11 +1451,11 @@ MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	  if (g_dwTotalTotalXferLines >= g_SWHeight)
 | 
						  if (g_dwTotalTotalXferLines >= g_SWHeight)
 | 
				
			||||||
	    {
 | 
						    {
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine1200DPI: g_dwTotalTotalXferLines=%d\n",
 | 
						           "g_dwTotalTotalXferLines=%d\n",
 | 
				
			||||||
		   g_dwTotalTotalXferLines);
 | 
							   g_dwTotalTotalXferLines);
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine1200DPI: g_Height=%d\n",
 | 
						           "g_Height=%d\n",
 | 
				
			||||||
		   g_Height);
 | 
							   g_Height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	      pthread_cancel (g_threadid_readimage);
 | 
						      pthread_cancel (g_threadid_readimage);
 | 
				
			||||||
| 
						 | 
					@ -1680,11 +1613,11 @@ MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
	      lpLine += g_SWBytesPerRow;
 | 
						      lpLine += g_SWBytesPerRow;
 | 
				
			||||||
	      AddReadyLines ();
 | 
						      AddReadyLines ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine1200DPI: g_dwTotalTotalXferLines=%d\n",
 | 
						           "g_dwTotalTotalXferLines=%d\n",
 | 
				
			||||||
		   g_dwTotalTotalXferLines);
 | 
							   g_dwTotalTotalXferLines);
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: " \
 | 
				
			||||||
		   "MustScanner_GetRgb24BitLine1200DPI: g_Height=%d\n",
 | 
						           "g_Height=%d\n",
 | 
				
			||||||
		   g_Height);
 | 
							   g_Height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
| 
						 | 
					@ -1704,20 +1637,11 @@ MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
  *wLinesCount = TotalXferLines;
 | 
					  *wLinesCount = TotalXferLines;
 | 
				
			||||||
  g_isScanning = FALSE;
 | 
					  g_isScanning = FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_FUNC,
 | 
					  DBG (DBG_FUNC, "MustScanner_GetRgb24BitLine1200DPI: " \
 | 
				
			||||||
       "MustScanner_GetRgb24BitLine1200DPI: leave MustScanner_GetRgb24BitLine1200DPI\n");
 | 
					    "leave MustScanner_GetRgb24BitLine1200DPI\n");
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Repair line when single CCD and color is 16bit
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	lpLine: point to image be repaired
 | 
					 | 
				
			||||||
	isOrderInvert: RGB or BGR
 | 
					 | 
				
			||||||
	wLinesCount: how many line be repaired
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if the operation is success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_GetMono16BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					MustScanner_GetMono16BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
			      unsigned short * wLinesCount)
 | 
								      unsigned short * wLinesCount)
 | 
				
			||||||
| 
						 | 
					@ -1799,17 +1723,9 @@ MustScanner_GetMono16BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Repair line when double CCD and color is 16bit
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	lpLine: point to image be repaired
 | 
					 | 
				
			||||||
	isOrderInvert: RGB or BGR
 | 
					 | 
				
			||||||
	wLinesCount: how many line be repaired
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if the operation is success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_GetMono16BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					MustScanner_GetMono16BitLine1200DPI (SANE_Byte * lpLine,
 | 
				
			||||||
 | 
									     SANE_Bool isOrderInvert,
 | 
				
			||||||
				     unsigned short * wLinesCount)
 | 
									     unsigned short * wLinesCount)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  unsigned short wWantedTotalLines;
 | 
					  unsigned short wWantedTotalLines;
 | 
				
			||||||
| 
						 | 
					@ -1940,7 +1856,7 @@ MustScanner_GetMono16BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert
 | 
				
			||||||
  *wLinesCount = TotalXferLines;
 | 
					  *wLinesCount = TotalXferLines;
 | 
				
			||||||
  g_isScanning = FALSE;
 | 
					  g_isScanning = FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /*for modify the last point */
 | 
					  /* modify the last point */
 | 
				
			||||||
  if (g_bIsFirstReadBefData)
 | 
					  if (g_bIsFirstReadBefData)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      g_lpBefLineImageData = (SANE_Byte *) malloc (g_SWBytesPerRow);
 | 
					      g_lpBefLineImageData = (SANE_Byte *) malloc (g_SWBytesPerRow);
 | 
				
			||||||
| 
						 | 
					@ -1970,20 +1886,11 @@ MustScanner_GetMono16BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert
 | 
				
			||||||
      g_bIsFirstReadBefData = TRUE;
 | 
					      g_bIsFirstReadBefData = TRUE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_FUNC,
 | 
					  DBG (DBG_FUNC, "MustScanner_GetMono16BitLine1200DPI: " \
 | 
				
			||||||
       "MustScanner_GetMono16BitLine1200DPI: leave MustScanner_GetMono16BitLine1200DPI\n");
 | 
					    "leave MustScanner_GetMono16BitLine1200DPI\n");
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Repair line when single CCD and color is 8bit
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	lpLine: point to image be repaired
 | 
					 | 
				
			||||||
	isOrderInvert: RGB or BGR
 | 
					 | 
				
			||||||
	wLinesCount: how many line be repaired
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if the operation is success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_GetMono8BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					MustScanner_GetMono8BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
			     unsigned short * wLinesCount)
 | 
								     unsigned short * wLinesCount)
 | 
				
			||||||
| 
						 | 
					@ -2061,15 +1968,6 @@ MustScanner_GetMono8BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Repair line when double CCD and color is 8bit
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	lpLine: point to image be repaired
 | 
					 | 
				
			||||||
	isOrderInvert: RGB or BGR
 | 
					 | 
				
			||||||
	wLinesCount: how many line be repaired
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if the operation is success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_GetMono8BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					MustScanner_GetMono8BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
				    unsigned short * wLinesCount)
 | 
									    unsigned short * wLinesCount)
 | 
				
			||||||
| 
						 | 
					@ -2184,7 +2082,7 @@ MustScanner_GetMono8BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
  *wLinesCount = TotalXferLines;
 | 
					  *wLinesCount = TotalXferLines;
 | 
				
			||||||
  g_isScanning = FALSE;
 | 
					  g_isScanning = FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /*for modify the last point */
 | 
					  /* modify the last point */
 | 
				
			||||||
  if (g_bIsFirstReadBefData)
 | 
					  if (g_bIsFirstReadBefData)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      g_lpBefLineImageData = (SANE_Byte *) malloc (g_SWBytesPerRow);
 | 
					      g_lpBefLineImageData = (SANE_Byte *) malloc (g_SWBytesPerRow);
 | 
				
			||||||
| 
						 | 
					@ -2214,20 +2112,11 @@ MustScanner_GetMono8BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
      g_bIsFirstReadBefData = TRUE;
 | 
					      g_bIsFirstReadBefData = TRUE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_FUNC,
 | 
					  DBG (DBG_FUNC, "MustScanner_GetMono8BitLine1200DPI: " \
 | 
				
			||||||
       "MustScanner_GetMono8BitLine1200DPI: leave MustScanner_GetMono8BitLine1200DPI\n");
 | 
					    "leave MustScanner_GetMono8BitLine1200DPI\n");
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Repair line when single CCD and color is 1bit
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	lpLine: point to image be repaired
 | 
					 | 
				
			||||||
	isOrderInvert: RGB or BGR
 | 
					 | 
				
			||||||
	wLinesCount: how many line be repaired
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if the operation is success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_GetMono1BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					MustScanner_GetMono1BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
			     unsigned short * wLinesCount)
 | 
								     unsigned short * wLinesCount)
 | 
				
			||||||
| 
						 | 
					@ -2305,15 +2194,6 @@ MustScanner_GetMono1BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Repair line when double CCD and color is 1bit
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	lpLine: point to image be repaired
 | 
					 | 
				
			||||||
	isOrderInvert: RGB or BGR
 | 
					 | 
				
			||||||
	wLinesCount: how many line be repaired
 | 
					 | 
				
			||||||
Return value: 
 | 
					 | 
				
			||||||
	TRUE if the operation is success, FALSE otherwise
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Bool
 | 
					static SANE_Bool
 | 
				
			||||||
MustScanner_GetMono1BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					MustScanner_GetMono1BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
				    unsigned short * wLinesCount)
 | 
									    unsigned short * wLinesCount)
 | 
				
			||||||
| 
						 | 
					@ -2407,21 +2287,16 @@ MustScanner_GetMono1BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  break;
 | 
						  break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
    }				/*end for */
 | 
					    }				/* end for */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  *wLinesCount = TotalXferLines;
 | 
					  *wLinesCount = TotalXferLines;
 | 
				
			||||||
  g_isScanning = FALSE;
 | 
					  g_isScanning = FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_FUNC,
 | 
					  DBG (DBG_FUNC, "MustScanner_GetMono1BitLine1200DPI: " \
 | 
				
			||||||
       "MustScanner_GetMono1BitLine1200DPI: leave MustScanner_GetMono1BitLine1200DPI\n");
 | 
					    "leave MustScanner_GetMono1BitLine1200DPI\n");
 | 
				
			||||||
  return TRUE;
 | 
					  return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	prepare calculate Max and Min value	
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	wResolution: the scan resolution
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
MustScanner_PrepareCalculateMaxMin (unsigned short wResolution)
 | 
					MustScanner_PrepareCalculateMaxMin (unsigned short wResolution)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -2435,7 +2310,8 @@ MustScanner_PrepareCalculateMaxMin (unsigned short wResolution)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	  g_nPowerNum = 3;
 | 
						  g_nPowerNum = 3;
 | 
				
			||||||
	  g_nSecLength = 8;	/* 2^nPowerNum */
 | 
						  g_nSecLength = 8;	/* 2^nPowerNum */
 | 
				
			||||||
	  g_nDarkSecLength = g_wDarkCalWidth / 2;	/* Dark has at least 2 sections */
 | 
						  /* Dark has at least 2 sections */
 | 
				
			||||||
 | 
						  g_nDarkSecLength = g_wDarkCalWidth / 2;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
| 
						 | 
					@ -2447,7 +2323,7 @@ MustScanner_PrepareCalculateMaxMin (unsigned short wResolution)
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      g_nPowerNum = 6;
 | 
					      g_nPowerNum = 6;
 | 
				
			||||||
      g_nSecLength = 64;	/*2^nPowerNum */
 | 
					      g_nSecLength = 64;	/* 2^nPowerNum */
 | 
				
			||||||
      g_wCalWidth = 10240;
 | 
					      g_wCalWidth = 10240;
 | 
				
			||||||
      g_nDarkSecLength = g_wDarkCalWidth / 5;
 | 
					      g_nDarkSecLength = g_wDarkCalWidth / 5;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -2461,24 +2337,17 @@ MustScanner_PrepareCalculateMaxMin (unsigned short wResolution)
 | 
				
			||||||
  g_wCalWidth -= g_wStartPosition;
 | 
					  g_wCalWidth -= g_wStartPosition;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* start of find Max value */
 | 
					  /* start of find max value */
 | 
				
			||||||
  g_nSecNum = (int) (g_wCalWidth / g_nSecLength);
 | 
					  g_nSecNum = (int) (g_wCalWidth / g_nSecLength);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* start of fin min value */
 | 
					  /* start of find min value */
 | 
				
			||||||
  g_nDarkSecNum = (int) (g_wDarkCalWidth / g_nDarkSecLength);
 | 
					  g_nDarkSecNum = (int) (g_wDarkCalWidth / g_nDarkSecLength);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	calculate the Max and Min value
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	pBuffer: the image data
 | 
					 | 
				
			||||||
	lpMaxValue: the max value
 | 
					 | 
				
			||||||
	lpMinValue: the min value
 | 
					 | 
				
			||||||
	wResolution: the scan resolution
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
MustScanner_CalculateMaxMin (SANE_Byte * pBuffer, unsigned short * lpMaxValue,
 | 
					MustScanner_CalculateMaxMin (SANE_Byte * pBuffer, unsigned short * lpMaxValue,
 | 
				
			||||||
			     unsigned short * lpMinValue, unsigned short wResolution)
 | 
								     unsigned short * lpMinValue,
 | 
				
			||||||
 | 
								     unsigned short wResolution)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  unsigned short *wSecData = NULL, *wDarkSecData = NULL;
 | 
					  unsigned short *wSecData = NULL, *wDarkSecData = NULL;
 | 
				
			||||||
  int i, j;
 | 
					  int i, j;
 | 
				
			||||||
| 
						 | 
					@ -2512,7 +2381,8 @@ MustScanner_CalculateMaxMin (SANE_Byte * pBuffer, unsigned short * lpMaxValue,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  free (wSecData);
 | 
					  free (wSecData);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  wDarkSecData = (unsigned short *) malloc (sizeof (unsigned short) * g_nDarkSecNum);
 | 
					  wDarkSecData = (unsigned short *) malloc (sizeof (unsigned short) *
 | 
				
			||||||
 | 
					    g_nDarkSecNum);
 | 
				
			||||||
  if (wDarkSecData == NULL)
 | 
					  if (wDarkSecData == NULL)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
| 
						 | 
					@ -2541,9 +2411,6 @@ MustScanner_CalculateMaxMin (SANE_Byte * pBuffer, unsigned short * lpMaxValue,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Read the data from scanner
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static void *
 | 
					static void *
 | 
				
			||||||
MustScanner_ReadDataFromScanner (void * dummy)
 | 
					MustScanner_ReadDataFromScanner (void * dummy)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -2581,13 +2448,13 @@ MustScanner_ReadDataFromScanner (void * dummy)
 | 
				
			||||||
	  if (STATUS_GOOD !=
 | 
						  if (STATUS_GOOD !=
 | 
				
			||||||
	      Asic_ReadImage (&g_chip, lpReadImage, wScanLinesThisBlock))
 | 
						      Asic_ReadImage (&g_chip, lpReadImage, wScanLinesThisBlock))
 | 
				
			||||||
	    {
 | 
						    {
 | 
				
			||||||
	      DBG (DBG_FUNC,
 | 
						      DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: Asic_ReadImage" \
 | 
				
			||||||
		   "MustScanner_ReadDataFromScanner:Asic_ReadImage return error\n");
 | 
						        " return error\n");
 | 
				
			||||||
	      DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner:thread exit\n");
 | 
						      DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: thread exit\n");
 | 
				
			||||||
	      return NULL;
 | 
						      return NULL;
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  /*has read in memroy Buffer */
 | 
						  /* has read in memory buffer */
 | 
				
			||||||
	  wReadImageLines += wScanLinesThisBlock;
 | 
						  wReadImageLines += wScanLinesThisBlock;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  AddScannedLines (wScanLinesThisBlock);
 | 
						  AddScannedLines (wScanLinesThisBlock);
 | 
				
			||||||
| 
						 | 
					@ -2596,7 +2463,7 @@ MustScanner_ReadDataFromScanner (void * dummy)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  lpReadImage += wScanLinesThisBlock * g_BytesPerRow;
 | 
						  lpReadImage += wScanLinesThisBlock * g_BytesPerRow;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  /*Buffer is full */
 | 
						  /* buffer is full */
 | 
				
			||||||
	  if (wReadImageLines >= wMaxScanLines)
 | 
						  if (wReadImageLines >= wMaxScanLines)
 | 
				
			||||||
	    {
 | 
						    {
 | 
				
			||||||
	      lpReadImage = g_lpReadImageHead;
 | 
						      lpReadImage = g_lpReadImageHead;
 | 
				
			||||||
| 
						 | 
					@ -2621,14 +2488,11 @@ MustScanner_ReadDataFromScanner (void * dummy)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: Read image ok\n");
 | 
					  DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: Read image ok\n");
 | 
				
			||||||
  DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: thread exit\n");
 | 
					  DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: thread exit\n");
 | 
				
			||||||
  DBG (DBG_FUNC,
 | 
					  DBG (DBG_FUNC, "MustScanner_ReadDataFromScanner: " \
 | 
				
			||||||
       "MustScanner_ReadDataFromScanner: leave MustScanner_ReadDataFromScanner\n");
 | 
					    "leave MustScanner_ReadDataFromScanner\n");
 | 
				
			||||||
  return NULL;
 | 
					  return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	get the lines of scanned
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static unsigned int
 | 
					static unsigned int
 | 
				
			||||||
GetScannedLines (void)
 | 
					GetScannedLines (void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -2641,9 +2505,6 @@ GetScannedLines (void)
 | 
				
			||||||
  return dwScannedLines;
 | 
					  return dwScannedLines;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	get lines which pass to superstratum
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static unsigned int
 | 
					static unsigned int
 | 
				
			||||||
GetReadyLines (void)
 | 
					GetReadyLines (void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -2656,11 +2517,6 @@ GetReadyLines (void)
 | 
				
			||||||
  return dwReadyLines;
 | 
					  return dwReadyLines;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	add the scanned total lines
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	wAddLines: add the lines
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
AddScannedLines (unsigned short wAddLines)
 | 
					AddScannedLines (unsigned short wAddLines)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -2671,9 +2527,6 @@ AddScannedLines (unsigned short wAddLines)
 | 
				
			||||||
  pthread_mutex_unlock (&g_scannedLinesMutex);
 | 
					  pthread_mutex_unlock (&g_scannedLinesMutex);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	add the ready lines
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
AddReadyLines (void)
 | 
					AddReadyLines (void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -2682,21 +2535,10 @@ AddReadyLines (void)
 | 
				
			||||||
  pthread_mutex_unlock (&g_readyLinesMutex);
 | 
					  pthread_mutex_unlock (&g_readyLinesMutex);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	modify the point
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	lpImageData: the data of image
 | 
					 | 
				
			||||||
	lpImageDataBefore: the data of before line image
 | 
					 | 
				
			||||||
	dwBytesPerLine: the bytes of per line
 | 
					 | 
				
			||||||
	dwLinesCount: the line count
 | 
					 | 
				
			||||||
	wPixDistance: the pixel distance
 | 
					 | 
				
			||||||
	wModPtCount: the modify point count
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
ModifyLinePoint (SANE_Byte * lpImageData,
 | 
					ModifyLinePoint (SANE_Byte * lpImageData, SANE_Byte * lpImageDataBefore,
 | 
				
			||||||
		 SANE_Byte * lpImageDataBefore,
 | 
							 unsigned int dwBytesPerLine, unsigned int dwLinesCount,
 | 
				
			||||||
		 unsigned int dwBytesPerLine,
 | 
							 unsigned short wPixDistance, unsigned short wModPtCount)
 | 
				
			||||||
		 unsigned int dwLinesCount, unsigned short wPixDistance, unsigned short wModPtCount)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  unsigned short i = 0;
 | 
					  unsigned short i = 0;
 | 
				
			||||||
  unsigned short j = 0;
 | 
					  unsigned short j = 0;
 | 
				
			||||||
| 
						 | 
					@ -2706,11 +2548,11 @@ ModifyLinePoint (SANE_Byte * lpImageData,
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      for (j = 0; j < wPixDistance; j++)
 | 
					      for (j = 0; j < wPixDistance; j++)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	  /*modify the first line */
 | 
						  /* modify the first line */
 | 
				
			||||||
	  *(lpImageData + (dwWidth - i) * wPixDistance + j) =
 | 
						  *(lpImageData + (dwWidth - i) * wPixDistance + j) =
 | 
				
			||||||
	    (*(lpImageData + (dwWidth - i - 1) * wPixDistance + j) +
 | 
						    (*(lpImageData + (dwWidth - i - 1) * wPixDistance + j) +
 | 
				
			||||||
	     *(lpImageDataBefore + (dwWidth - i) * wPixDistance + j)) / 2;
 | 
						     *(lpImageDataBefore + (dwWidth - i) * wPixDistance + j)) / 2;
 | 
				
			||||||
	  /*modify other lines */
 | 
						  /* modify other lines */
 | 
				
			||||||
	  for (wLines = 1; wLines < dwLinesCount; wLines++)
 | 
						  for (wLines = 1; wLines < dwLinesCount; wLines++)
 | 
				
			||||||
	    {
 | 
						    {
 | 
				
			||||||
	      unsigned int dwBytesBefor = (wLines - 1) * dwBytesPerLine;
 | 
						      unsigned int dwBytesBefor = (wLines - 1) * dwBytesPerLine;
 | 
				
			||||||
| 
						 | 
					@ -2726,14 +2568,6 @@ ModifyLinePoint (SANE_Byte * lpImageData,
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**********************************************************************
 | 
					 | 
				
			||||||
	Modifiy the image data	
 | 
					 | 
				
			||||||
Parameters:
 | 
					 | 
				
			||||||
	A: the input the image data
 | 
					 | 
				
			||||||
	B: the input the iamge data
 | 
					 | 
				
			||||||
Return value:
 | 
					 | 
				
			||||||
	the modified data
 | 
					 | 
				
			||||||
***********************************************************************/
 | 
					 | 
				
			||||||
static SANE_Byte
 | 
					static SANE_Byte
 | 
				
			||||||
QBET4 (SANE_Byte A, SANE_Byte B)
 | 
					QBET4 (SANE_Byte A, SANE_Byte B)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,15 +48,11 @@
 | 
				
			||||||
#ifndef MUSTEK_USB2_HIGH_H
 | 
					#ifndef MUSTEK_USB2_HIGH_H
 | 
				
			||||||
#define MUSTEK_USB2_HIGH_H
 | 
					#define MUSTEK_USB2_HIGH_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* const use in structures*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*scan source*/
 | 
					 | 
				
			||||||
typedef SANE_Byte SCANSOURCE;
 | 
					typedef SANE_Byte SCANSOURCE;
 | 
				
			||||||
#define SS_Reflective	0x00
 | 
					#define SS_Reflective	0x00
 | 
				
			||||||
#define SS_Positive		0x01
 | 
					#define SS_Positive		0x01
 | 
				
			||||||
#define SS_Negative		0x02
 | 
					#define SS_Negative		0x02
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*RGB order*/
 | 
					 | 
				
			||||||
typedef unsigned short RGBORDER;
 | 
					typedef unsigned short RGBORDER;
 | 
				
			||||||
#define RO_RGB 0x00
 | 
					#define RO_RGB 0x00
 | 
				
			||||||
#define RO_BGR 0x01
 | 
					#define RO_BGR 0x01
 | 
				
			||||||
| 
						 | 
					@ -78,7 +74,6 @@ typedef enum
 | 
				
			||||||
  CM_GRAY8ext = 20
 | 
					  CM_GRAY8ext = 20
 | 
				
			||||||
} COLORMODE;
 | 
					} COLORMODE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* structures use in parameters of export function*/
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct
 | 
					typedef struct
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -99,7 +94,7 @@ typedef struct
 | 
				
			||||||
  FRAME fmArea;
 | 
					  FRAME fmArea;
 | 
				
			||||||
  unsigned short wTargetDPI;
 | 
					  unsigned short wTargetDPI;
 | 
				
			||||||
  COLORMODE cmColorMode;
 | 
					  COLORMODE cmColorMode;
 | 
				
			||||||
  unsigned short wLinearThreshold;	/*threshold for Line art mode */
 | 
					  unsigned short wLinearThreshold;	/* threshold for line art mode */
 | 
				
			||||||
  SCANSOURCE ssScanSource;
 | 
					  SCANSOURCE ssScanSource;
 | 
				
			||||||
  unsigned short * pGammaTable;
 | 
					  unsigned short * pGammaTable;
 | 
				
			||||||
} SETPARAMETERS, *LPSETPARAMETERS;
 | 
					} SETPARAMETERS, *LPSETPARAMETERS;
 | 
				
			||||||
| 
						 | 
					@ -137,31 +132,29 @@ typedef struct
 | 
				
			||||||
} SUGGESTSETTING, *PSUGGESTSETTING;
 | 
					} SUGGESTSETTING, *PSUGGESTSETTING;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*Macro define*/
 | 
					#define R_GAIN                          0
 | 
				
			||||||
 | 
					 | 
				
			||||||
#define R_GAIN							0
 | 
					 | 
				
			||||||
#define G_GAIN                          0
 | 
					#define G_GAIN                          0
 | 
				
			||||||
#define B_GAIN                          0
 | 
					#define B_GAIN                          0
 | 
				
			||||||
#define R_DIRECTION                     0
 | 
					#define R_DIRECTION                     0
 | 
				
			||||||
#define G_DIRECTION                     0
 | 
					#define G_DIRECTION                     0
 | 
				
			||||||
#define B_DIRECTION                     0
 | 
					#define B_DIRECTION                     0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* use for adjust AD's offset*/
 | 
					/* used for adjusting the AD offset */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* for Reflective*/
 | 
					/* for Reflective */
 | 
				
			||||||
#define REFL_WHITE_MAX_LEVEL			220
 | 
					#define REFL_WHITE_MAX_LEVEL            220
 | 
				
			||||||
#define REFL_WHITE_MIN_LEVEL			210
 | 
					#define REFL_WHITE_MIN_LEVEL            210
 | 
				
			||||||
#define REFL_MAX_LEVEL_RANGE            210
 | 
					#define REFL_MAX_LEVEL_RANGE            210
 | 
				
			||||||
#define REFL_MIN_LEVEL_RANGE            190
 | 
					#define REFL_MIN_LEVEL_RANGE            190
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*for Transparent*/
 | 
					/* for Transparent */
 | 
				
			||||||
#define TRAN_WHITE_MAX_LEVEL            220
 | 
					#define TRAN_WHITE_MAX_LEVEL            220
 | 
				
			||||||
#define TRAN_WHITE_MIN_LEVEL            210
 | 
					#define TRAN_WHITE_MIN_LEVEL            210
 | 
				
			||||||
#define TRAN_MAX_LEVEL_RANGE            210
 | 
					#define TRAN_MAX_LEVEL_RANGE            210
 | 
				
			||||||
#define TRAN_MIN_LEVEL_RANGE            190
 | 
					#define TRAN_MIN_LEVEL_RANGE            190
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* in 600 dpi*/
 | 
					/* 600 dpi */
 | 
				
			||||||
#define FIND_LEFT_TOP_WIDTH_IN_DIP          512
 | 
					#define FIND_LEFT_TOP_WIDTH_IN_DIP          512
 | 
				
			||||||
#define FIND_LEFT_TOP_HEIGHT_IN_DIP         180
 | 
					#define FIND_LEFT_TOP_HEIGHT_IN_DIP         180
 | 
				
			||||||
#define FIND_LEFT_TOP_CALIBRATE_RESOLUTION  600
 | 
					#define FIND_LEFT_TOP_CALIBRATE_RESOLUTION  600
 | 
				
			||||||
| 
						 | 
					@ -169,56 +162,58 @@ typedef struct
 | 
				
			||||||
#define TA_FIND_LEFT_TOP_WIDTH_IN_DIP       2668
 | 
					#define TA_FIND_LEFT_TOP_WIDTH_IN_DIP       2668
 | 
				
			||||||
#define TA_FIND_LEFT_TOP_HEIGHT_IN_DIP      300
 | 
					#define TA_FIND_LEFT_TOP_HEIGHT_IN_DIP      300
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*must be 8x*/
 | 
					/* must be a multiple of 8 */
 | 
				
			||||||
#define LINE_CALIBRATION__16BITS_HEIGHT				40
 | 
					#define LINE_CALIBRATION__16BITS_HEIGHT     40
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* the length from block bar to start Calibration position*/
 | 
					/* the length from block bar to start calibration position */
 | 
				
			||||||
#define BEFORE_SCANNING_MOTOR_FORWARD_PIXEL 40
 | 
					#define BEFORE_SCANNING_MOTOR_FORWARD_PIXEL 40
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define TRAN_START_POS					4550
 | 
					#define TRAN_START_POS                      4550
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* in 300dpi*/
 | 
					/* 300 dpi */
 | 
				
			||||||
#define MAX_SCANNING_WIDTH               2550	/*just for A4 */
 | 
					#define MAX_SCANNING_WIDTH                  2550	/* just for A4 */
 | 
				
			||||||
#define MAX_SCANNING_HEIGHT              3540	/*just for A4 */
 | 
					#define MAX_SCANNING_HEIGHT                 3540	/* just for A4 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*enable gamma*/
 | 
					 | 
				
			||||||
#define ENABLE_GAMMA
 | 
					#define ENABLE_GAMMA
 | 
				
			||||||
 | 
					 | 
				
			||||||
/*save debug image*/
 | 
					 | 
				
			||||||
/*#define DEBUG_SAVE_IMAGE*/
 | 
					/*#define DEBUG_SAVE_IMAGE*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static SANE_Bool MustScanner_Init (void);
 | 
					static SANE_Bool MustScanner_Init (void);
 | 
				
			||||||
static SANE_Bool MustScanner_GetScannerState (void);
 | 
					static SANE_Bool MustScanner_GetScannerState (void);
 | 
				
			||||||
static SANE_Bool MustScanner_PowerControl (SANE_Bool isLampOn, SANE_Bool isTALampOn);
 | 
					static SANE_Bool MustScanner_PowerControl (SANE_Bool isLampOn,
 | 
				
			||||||
 | 
										   SANE_Bool isTALampOn);
 | 
				
			||||||
static SANE_Bool MustScanner_BackHome (void);
 | 
					static SANE_Bool MustScanner_BackHome (void);
 | 
				
			||||||
static SANE_Bool MustScanner_Prepare (SCANSOURCE ssScanSource);
 | 
					static SANE_Bool MustScanner_Prepare (SCANSOURCE ssScanSource);
 | 
				
			||||||
static unsigned short MustScanner_FiltLower (unsigned short * pSort, unsigned short TotalCount, unsigned short LowCount,
 | 
					static unsigned short MustScanner_FiltLower (unsigned short * pSort,
 | 
				
			||||||
				   unsigned short HighCount);
 | 
										     unsigned short TotalCount,
 | 
				
			||||||
static SANE_Bool MustScanner_GetRgb48BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
										     unsigned short LowCount,
 | 
				
			||||||
					 unsigned short * wLinesCount);
 | 
										     unsigned short HighCount);
 | 
				
			||||||
static SANE_Bool MustScanner_GetRgb48BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					static SANE_Bool MustScanner_GetRgb48BitLine (SANE_Byte * lpLine,
 | 
				
			||||||
						unsigned short * wLinesCount);
 | 
						SANE_Bool isOrderInvert, unsigned short * wLinesCount);
 | 
				
			||||||
static SANE_Bool MustScanner_GetRgb24BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					static SANE_Bool MustScanner_GetRgb48BitLine1200DPI (SANE_Byte * lpLine,
 | 
				
			||||||
					 unsigned short * wLinesCount);
 | 
						SANE_Bool isOrderInvert, unsigned short * wLinesCount);
 | 
				
			||||||
static SANE_Bool MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					static SANE_Bool MustScanner_GetRgb24BitLine (SANE_Byte * lpLine,
 | 
				
			||||||
						unsigned short * wLinesCount);
 | 
						SANE_Bool isOrderInvert, unsigned short * wLinesCount);
 | 
				
			||||||
static SANE_Bool MustScanner_GetMono16BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					static SANE_Bool MustScanner_GetRgb24BitLine1200DPI (SANE_Byte * lpLine,
 | 
				
			||||||
					  unsigned short * wLinesCount);
 | 
						SANE_Bool isOrderInvert, unsigned short * wLinesCount);
 | 
				
			||||||
static SANE_Bool MustScanner_GetMono16BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					static SANE_Bool MustScanner_GetMono16BitLine (SANE_Byte * lpLine,
 | 
				
			||||||
						 unsigned short * wLinesCount);
 | 
						SANE_Bool isOrderInvert, unsigned short * wLinesCount);
 | 
				
			||||||
static SANE_Bool MustScanner_GetMono8BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					static SANE_Bool MustScanner_GetMono16BitLine1200DPI (SANE_Byte * lpLine,
 | 
				
			||||||
					 unsigned short * wLinesCount);
 | 
						SANE_Bool isOrderInvert, unsigned short * wLinesCount);
 | 
				
			||||||
static SANE_Bool MustScanner_GetMono8BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					static SANE_Bool MustScanner_GetMono8BitLine (SANE_Byte * lpLine,
 | 
				
			||||||
						unsigned short * wLinesCount);
 | 
						SANE_Bool isOrderInvert, unsigned short * wLinesCount);
 | 
				
			||||||
static SANE_Bool MustScanner_GetMono1BitLine (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					static SANE_Bool MustScanner_GetMono8BitLine1200DPI (SANE_Byte * lpLine,
 | 
				
			||||||
					 unsigned short * wLinesCount);
 | 
						SANE_Bool isOrderInvert, unsigned short * wLinesCount);
 | 
				
			||||||
static SANE_Bool MustScanner_GetMono1BitLine1200DPI (SANE_Byte * lpLine, SANE_Bool isOrderInvert,
 | 
					static SANE_Bool MustScanner_GetMono1BitLine (SANE_Byte * lpLine,
 | 
				
			||||||
						unsigned short * wLinesCount);
 | 
						SANE_Bool isOrderInvert, unsigned short * wLinesCount);
 | 
				
			||||||
 | 
					static SANE_Bool MustScanner_GetMono1BitLine1200DPI (SANE_Byte * lpLine,
 | 
				
			||||||
 | 
						SANE_Bool isOrderInvert, unsigned short * wLinesCount);
 | 
				
			||||||
static void *MustScanner_ReadDataFromScanner (void * dummy);
 | 
					static void *MustScanner_ReadDataFromScanner (void * dummy);
 | 
				
			||||||
static void MustScanner_PrepareCalculateMaxMin (unsigned short wResolution);
 | 
					static void MustScanner_PrepareCalculateMaxMin (unsigned short wResolution);
 | 
				
			||||||
static void MustScanner_CalculateMaxMin (SANE_Byte * pBuffer, unsigned short * lpMaxValue,
 | 
					static void MustScanner_CalculateMaxMin (SANE_Byte * pBuffer,
 | 
				
			||||||
					 unsigned short * lpMinValue, unsigned short wResolution);
 | 
										 unsigned short * lpMaxValue,
 | 
				
			||||||
 | 
										 unsigned short * lpMinValue,
 | 
				
			||||||
 | 
										 unsigned short wResolution);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Ładowanie…
	
		Reference in New Issue