kopia lustrzana https://gitlab.com/sane-project/backends
				
				
				
			copyright updates and some changes concerning the CanoScan lamp calibration.
							rodzic
							
								
									7d3ec3869c
								
							
						
					
					
						commit
						c9d48fcdeb
					
				| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
 *  @brief The interface functions to the USB driver stuff.
 | 
			
		||||
 *
 | 
			
		||||
 * Based on sources acquired from Plustek Inc.<br>
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * - 0.40 - starting version of the USB support
 | 
			
		||||
| 
						 | 
				
			
			@ -211,6 +211,16 @@ static void usb_initDev( pPlustek_Device dev, int idx, int handle, int vendor )
 | 
			
		|||
	if( dev->adj.negShadingY >= 0 )
 | 
			
		||||
		dev->usbDev.Caps.Negative.ShadingOriginY = dev->adj.negShadingY;
 | 
			
		||||
 | 
			
		||||
	/* adjust the gamma settings... */
 | 
			
		||||
	if( dev->adj.rgamma == 1.0 )
 | 
			
		||||
		dev->adj.rgamma = dev->usbDev.HwSetting.gamma;
 | 
			
		||||
	if( dev->adj.ggamma == 1.0 )
 | 
			
		||||
		dev->adj.ggamma = dev->usbDev.HwSetting.gamma;
 | 
			
		||||
	if( dev->adj.bgamma == 1.0 )
 | 
			
		||||
		dev->adj.bgamma = dev->usbDev.HwSetting.gamma;
 | 
			
		||||
	if( dev->adj.graygamma == 1.0 )
 | 
			
		||||
		dev->adj.graygamma = dev->usbDev.HwSetting.gamma;
 | 
			
		||||
 | 
			
		||||
	/* the following you normally get from the registry...
 | 
			
		||||
	 */
 | 
			
		||||
	bMaxITA = 0;     /* Maximum integration time adjust */
 | 
			
		||||
| 
						 | 
				
			
			@ -641,7 +651,7 @@ static int usbDev_open( Plustek_Device *dev )
 | 
			
		|||
 | 
			
		||||
		if( 0x400 == vendor ) {
 | 
			
		||||
			if((dev->adj.mov < 0) || (dev->adj.mov > 1)) {
 | 
			
		||||
				DBG( _DBG_INFO, "BearPaw MOV ot of range: %d\n", dev->adj.mov );
 | 
			
		||||
				DBG(_DBG_INFO, "BearPaw MOV out of range: %d\n", dev->adj.mov);
 | 
			
		||||
				dev->adj.mov = 0;
 | 
			
		||||
			}
 | 
			
		||||
			sprintf( devStr, "%s-%d", dev->usbId, dev->adj.mov );
 | 
			
		||||
| 
						 | 
				
			
			@ -673,10 +683,10 @@ static int usbDev_open( Plustek_Device *dev )
 | 
			
		|||
 */
 | 
			
		||||
static int usbDev_close( Plustek_Device *dev )
 | 
			
		||||
{
 | 
			
		||||
    DBG( _DBG_INFO, "usbDev_close()\n" );
 | 
			
		||||
	DBG( _DBG_INFO, "usbDev_close()\n" );
 | 
			
		||||
	sanei_usb_close( dev->fd );
 | 
			
		||||
	dev->fd = -1;
 | 
			
		||||
    return 0;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** convert the stuff
 | 
			
		||||
| 
						 | 
				
			
			@ -687,7 +697,7 @@ static int usbDev_getCaps( Plustek_Device *dev )
 | 
			
		|||
 | 
			
		||||
	DBG( _DBG_INFO, "usbDev_getCaps()\n" );
 | 
			
		||||
 | 
			
		||||
	dev->caps.dwFlag = (SFLAG_SCANNERDEV + SFLAG_FLATBED + SFLAG_CUSTOM_GAMMA);
 | 
			
		||||
	dev->caps.dwFlag = 0;
 | 
			
		||||
 | 
			
		||||
	if(((DEVCAPSFLAG_Positive == scaps->wFlags)  &&
 | 
			
		||||
	    (DEVCAPSFLAG_Negative == scaps->wFlags)) ||
 | 
			
		||||
| 
						 | 
				
			
			@ -697,7 +707,7 @@ static int usbDev_getCaps( Plustek_Device *dev )
 | 
			
		|||
 | 
			
		||||
	dev->caps.wMaxExtentX = scaps->Normal.Size.x;
 | 
			
		||||
	dev->caps.wMaxExtentY = scaps->Normal.Size.y;
 | 
			
		||||
    return 0;
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** usbDev_getCropInfo
 | 
			
		||||
| 
						 | 
				
			
			@ -709,7 +719,7 @@ static int usbDev_getCropInfo( Plustek_Device *dev, pCropInfo ci )
 | 
			
		|||
 | 
			
		||||
	DBG( _DBG_INFO, "usbDev_getCropInfo()\n" );
 | 
			
		||||
 | 
			
		||||
    _VAR_NOT_USED(dev);
 | 
			
		||||
	_VAR_NOT_USED(dev);
 | 
			
		||||
 | 
			
		||||
	usb_GetImageInfo( &ci->ImgDef, &size );
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -744,19 +754,19 @@ static int usbDev_setMap( Plustek_Device *dev, SANE_Word *map,
 | 
			
		|||
			a_bMap[i]            = (SANE_Byte)map[i];
 | 
			
		||||
			a_bMap[length +i]    = (SANE_Byte)map[i];
 | 
			
		||||
			a_bMap[(length*2)+i] = (SANE_Byte)map[i];
 | 
			
		||||
		}			
 | 
			
		||||
	
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	} else {
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
		idx = 0;
 | 
			
		||||
		if( channel == _MAP_GREEN )
 | 
			
		||||
			idx = 1;
 | 
			
		||||
		if( channel == _MAP_BLUE )
 | 
			
		||||
			idx = 2;
 | 
			
		||||
			
 | 
			
		||||
 | 
			
		||||
		for( i = 0; i < length; i++ ) {
 | 
			
		||||
			a_bMap[(length * idx)+i] = (SANE_Byte)map[i];
 | 
			
		||||
		}			
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
 *  @brief Main defines for the USB devices.
 | 
			
		||||
 *
 | 
			
		||||
 * Based on sources acquired from Plustek Inc.<br>
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * - 0.40 - starting version of the USB support
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,8 @@
 | 
			
		|||
 *        - removed _WAF_FIX_GAIN and _WAF_FIX_OFS
 | 
			
		||||
 *        - added skipCoarseCalib to ScanDef
 | 
			
		||||
 *        - added additional defines for cis and epson-ccd sensor
 | 
			
		||||
 * - 0.47 - no changes
 | 
			
		||||
 * - 0.47 - cleanup work
 | 
			
		||||
 *        - added gamma to struct HWDefault
 | 
			
		||||
 * .
 | 
			
		||||
 * <hr>
 | 
			
		||||
 * This file is part of the SANE package.
 | 
			
		||||
| 
						 | 
				
			
			@ -368,26 +369,24 @@ typedef struct
 | 
			
		|||
 */
 | 
			
		||||
typedef struct HWDefault
 | 
			
		||||
{
 | 
			
		||||
	double				dMaxMotorSpeed;			/* Inches/second, max. scan speed */
 | 
			
		||||
	double				dMaxMoveSpeed;			/* Inches/second, max. move speed */
 | 
			
		||||
	double				dIntegrationTimeLowLamp;
 | 
			
		||||
	double				dIntegrationTimeHighLamp;
 | 
			
		||||
	u_short				wMotorDpi;				/* Full step DPI */
 | 
			
		||||
	u_short				wDRAMSize;				/* in KB         */
 | 
			
		||||
	double				dMinIntegrationTimeLowres;
 | 
			
		||||
												/* in ms.        */
 | 
			
		||||
	double				dMinIntegrationTimeHighres;
 | 
			
		||||
												/* in ms.        */
 | 
			
		||||
	u_short				wGreenPWMDutyCycleLow;
 | 
			
		||||
	u_short				wGreenPWMDutyCycleHigh;
 | 
			
		||||
	double              dMaxMotorSpeed;    /* Inches/second, max. scan speed */
 | 
			
		||||
	double              dMaxMoveSpeed;     /* Inches/second, max. move speed */
 | 
			
		||||
	double              dIntegrationTimeLowLamp;
 | 
			
		||||
	double              dIntegrationTimeHighLamp;
 | 
			
		||||
	u_short             wMotorDpi;                      /* Full step DPI */
 | 
			
		||||
	u_short             wDRAMSize;                      /* in KB         */
 | 
			
		||||
	double              dMinIntegrationTimeLowres;      /*in ms.     */
 | 
			
		||||
	double              dMinIntegrationTimeHighres;     /* in ms.    */
 | 
			
		||||
	u_short             wGreenPWMDutyCycleLow;
 | 
			
		||||
	u_short             wGreenPWMDutyCycleHigh;
 | 
			
		||||
	/* Registers */
 | 
			
		||||
	u_char				bSensorConfiguration;	/* 0x0b */
 | 
			
		||||
	u_char              bSensorConfiguration;	/* 0x0b */
 | 
			
		||||
	/* Sensor control settings */
 | 
			
		||||
	u_char				bReg_0x0c;
 | 
			
		||||
	u_char				bReg_0x0d;
 | 
			
		||||
	u_char				bReg_0x0e;
 | 
			
		||||
	u_char				bReg_0x0f_Mono [10];	/* 0x0f to 0x18 */
 | 
			
		||||
	u_char				bReg_0x0f_Color [10];	/* 0x0f to 0x18 */
 | 
			
		||||
	u_char              bReg_0x0c;
 | 
			
		||||
	u_char              bReg_0x0d;
 | 
			
		||||
	u_char              bReg_0x0e;
 | 
			
		||||
	u_char              bReg_0x0f_Mono [10];	/* 0x0f to 0x18 */
 | 
			
		||||
	u_char              bReg_0x0f_Color [10];	/* 0x0f to 0x18 */
 | 
			
		||||
 | 
			
		||||
	/* color mode settings */	
 | 
			
		||||
	u_char              bReg_0x26;
 | 
			
		||||
| 
						 | 
				
			
			@ -404,46 +403,46 @@ typedef struct HWDefault
 | 
			
		|||
	 * format, you have to pay your attention when you
 | 
			
		||||
	 * write this value to register.
 | 
			
		||||
	 */
 | 
			
		||||
	u_short				StepperPhaseCorrection;	
 | 
			
		||||
	u_short             StepperPhaseCorrection;	
 | 
			
		||||
	
 | 
			
		||||
	/* Sensor Pixel Configuration
 | 
			
		||||
	 * Actually, the wActivePixelsStart will be set to 0 for shading purpose.
 | 
			
		||||
     * We have to keep these values to adjust the origins when user does the
 | 
			
		||||
     * scan. These settings are based on optic resolution.
 | 
			
		||||
     */
 | 
			
		||||
	u_char				bOpticBlackStart;		/* 0x1c        */
 | 
			
		||||
	u_char				bOpticBlackEnd;			/* 0x1d        */
 | 
			
		||||
	u_short				wActivePixelsStart;		/* 0x1e & 0x1f */
 | 
			
		||||
	u_short				wLineEnd;				/* 0x20 & 0x21 */
 | 
			
		||||
	u_char              bOpticBlackStart;       /* 0x1c        */
 | 
			
		||||
	u_char              bOpticBlackEnd;         /* 0x1d        */
 | 
			
		||||
	u_short             wActivePixelsStart;     /* 0x1e & 0x1f */
 | 
			
		||||
	u_short             wLineEnd;               /* 0x20 & 0x21 */
 | 
			
		||||
	
 | 
			
		||||
	/* illumination settings (runtime) */
 | 
			
		||||
	u_short             red_lamp_on;			/* 0x2c & 0x2d */
 | 
			
		||||
	u_short             red_lamp_off;			/* 0x2e & 0x2f */
 | 
			
		||||
	u_short             green_lamp_on;			/* 0x30 & 0x31 */
 | 
			
		||||
	u_short             green_lamp_off;			/* 0x32 & 0x33 */
 | 
			
		||||
	u_short             blue_lamp_on;			/* 0x34 & 0x35 */
 | 
			
		||||
	u_short             blue_lamp_off;			/* 0x36 & 0x37 */
 | 
			
		||||
	u_short             red_lamp_on;            /* 0x2c & 0x2d */
 | 
			
		||||
	u_short             red_lamp_off;           /* 0x2e & 0x2f */
 | 
			
		||||
	u_short             green_lamp_on;          /* 0x30 & 0x31 */
 | 
			
		||||
	u_short             green_lamp_off;         /* 0x32 & 0x33 */
 | 
			
		||||
	u_short             blue_lamp_on;           /* 0x34 & 0x35 */
 | 
			
		||||
	u_short             blue_lamp_off;          /* 0x36 & 0x37 */
 | 
			
		||||
	
 | 
			
		||||
	/* Misc */
 | 
			
		||||
	u_char				bReg_0x45;
 | 
			
		||||
	u_short				wStepsAfterPaperSensor2;/* 0x4c & 0x4d */
 | 
			
		||||
	u_char              bReg_0x45;
 | 
			
		||||
	u_short             wStepsAfterPaperSensor2;/* 0x4c & 0x4d */
 | 
			
		||||
	u_char              bStepsToReverse;        /* 0x50        */
 | 
			
		||||
	u_char				bReg_0x51;
 | 
			
		||||
	u_char				bReg_0x54;
 | 
			
		||||
	u_char				bReg_0x55;
 | 
			
		||||
	u_char				bReg_0x56;
 | 
			
		||||
	u_char				bReg_0x57;
 | 
			
		||||
	u_char				bReg_0x58;
 | 
			
		||||
	u_char				bReg_0x59;
 | 
			
		||||
	u_char				bReg_0x5a;
 | 
			
		||||
	u_char				bReg_0x5b;
 | 
			
		||||
	u_char				bReg_0x5c;
 | 
			
		||||
	u_char				bReg_0x5d;
 | 
			
		||||
	u_char				bReg_0x5e;
 | 
			
		||||
	u_char              bReg_0x51;
 | 
			
		||||
	u_char              bReg_0x54;
 | 
			
		||||
	u_char              bReg_0x55;
 | 
			
		||||
	u_char              bReg_0x56;
 | 
			
		||||
	u_char              bReg_0x57;
 | 
			
		||||
	u_char              bReg_0x58;
 | 
			
		||||
	u_char              bReg_0x59;
 | 
			
		||||
	u_char              bReg_0x5a;
 | 
			
		||||
	u_char              bReg_0x5b;
 | 
			
		||||
	u_char              bReg_0x5c;
 | 
			
		||||
	u_char              bReg_0x5d;
 | 
			
		||||
	u_char              bReg_0x5e;
 | 
			
		||||
	
 | 
			
		||||
	eChipDef            chip;           /* chiptype               */
 | 
			
		||||
    eModelDef			motorModel; 	/* to identify used motor */
 | 
			
		||||
 | 
			
		||||
	eModelDef           motorModel;     /* to identify used motor */
 | 
			
		||||
	double              gamma;          /* gamma setting          */
 | 
			
		||||
} HWDef, *pHWDef;
 | 
			
		||||
 | 
			
		||||
/** device description during runtime
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
 *  @brief Calibration routines for CanoScan CIS devices.
 | 
			
		||||
 *
 | 
			
		||||
 * Based on sources acquired from Plustek Inc.<br>
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de><br>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de><br>
 | 
			
		||||
 * Large parts Copyright (C) 2003 Christopher Montgomery <monty@xiph.org>
 | 
			
		||||
 *
 | 
			
		||||
 * Montys' comment:
 | 
			
		||||
| 
						 | 
				
			
			@ -35,6 +35,8 @@
 | 
			
		|||
 *         - added the usage of the swGain and swOffset values, to allow
 | 
			
		||||
 *           tweaking the calibration results on a sensor base
 | 
			
		||||
 * - 0.47  - moved usb_HostSwap() to plustek_usbhw.c
 | 
			
		||||
 *         - fixed problem in cano_AdjustLightsource(), so that it won't
 | 
			
		||||
 *           stop too early.
 | 
			
		||||
 * 
 | 
			
		||||
 * This file is part of the SANE package.
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -164,9 +166,12 @@ static int cano_LampOnAfterCalibration( pPlustek_Device dev )
 | 
			
		|||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** function to adjust the...
 | 
			
		||||
 * returns 0 if the value is fine, 1, if we need to adjust and 2 if we ran
 | 
			
		||||
 * against a limit...
 | 
			
		||||
/** function to adjust the CIS lamp-off setting for a given channel.
 | 
			
		||||
 * @param min - pointer to the ON point of the CIS-channel
 | 
			
		||||
 * @param max - pointer to the max OFF point of the CIS-channel
 | 
			
		||||
 * @param off - pointer to the current OFF point of the CIS-channel
 | 
			
		||||
 * @param val - current value to check
 | 
			
		||||
 * @return returns 0 if the value is fine, 1, if we need to adjust 
 | 
			
		||||
 */
 | 
			
		||||
static int cano_adjLampSetting( u_short *min,
 | 
			
		||||
                                u_short *max, u_short *off, u_short val )
 | 
			
		||||
| 
						 | 
				
			
			@ -176,28 +181,31 @@ static int cano_adjLampSetting( u_short *min,
 | 
			
		|||
	/* perfect value, no need to adjust
 | 
			
		||||
	 * val ¤ [53440..61440] is perfect
 | 
			
		||||
	 */  
 | 
			
		||||
	if((val < IDEAL_GainNormal) && (val > (IDEAL_GainNormal-8000)))
 | 
			
		||||
	if((val < (IDEAL_GainNormal-6000)) && (val > (IDEAL_GainNormal-8000)))
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	if(val > (IDEAL_GainNormal-4000)) {
 | 
			
		||||
	if(val > (IDEAL_GainNormal-6000)) {
 | 
			
		||||
 | 
			
		||||
		DBG(_DBG_INFO2, "TOO BRIGHT --> reduce\n" );
 | 
			
		||||
		DBG(_DBG_INFO2, "* TOO BRIGHT --> reduce\n" );
 | 
			
		||||
		*max   = newoff;
 | 
			
		||||
		*off = ((newoff + *min)>>1);
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
	} else {
 | 
			
		||||
 | 
			
		||||
		u_short bisect = (newoff + *max)>>1;
 | 
			
		||||
		u_short twice  =  newoff*2;
 | 
			
		||||
 | 
			
		||||
		DBG(_DBG_INFO2, "TOO DARK --> up\n" );
 | 
			
		||||
		DBG(_DBG_INFO2, "* TOO DARK --> up\n" );
 | 
			
		||||
		*min = newoff;
 | 
			
		||||
		*off = twice<bisect?twice:bisect;
 | 
			
		||||
 | 
			
		||||
		/* as we have already set the maximum value, there's no need
 | 
			
		||||
		 * for this channel to recalibrate.
 | 
			
		||||
		 */
 | 
			
		||||
		if( *off > 0x3FFF ) {
 | 
			
		||||
			DBG( _DBG_INFO2, "lamp off limited (0x%04x --> 0x3FFF)\n", *off );
 | 
			
		||||
			DBG( _DBG_INFO2, "* lamp off limited (0x%04x --> 0x3FFF)\n", *off);
 | 
			
		||||
			*off = 0x3FFF;
 | 
			
		||||
			return 2;
 | 
			
		||||
			return 0;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -215,10 +223,11 @@ static int cano_adjLampSetting( u_short *min,
 | 
			
		|||
 * where the lamp_off parameter is adjustable; I'd make it more general, 
 | 
			
		||||
 * but I only have the CIS hardware to test.
 | 
			
		||||
 */
 | 
			
		||||
static int cano_AdjustLightsource( pPlustek_Device dev)
 | 
			
		||||
static int cano_AdjustLightsource( pPlustek_Device dev )
 | 
			
		||||
{
 | 
			
		||||
	char         tmp[40];
 | 
			
		||||
	int          i, adj, warmup_limit, limit;
 | 
			
		||||
	int          i;
 | 
			
		||||
	int          res_r, res_g, res_b;
 | 
			
		||||
	u_long       dw, dwR, dwG, dwB, dwDiv, dwLoop1, dwLoop2;
 | 
			
		||||
	RGBUShortDef max_rgb, min_rgb, tmp_rgb;
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			@ -254,11 +263,11 @@ static int cano_AdjustLightsource( pPlustek_Device dev)
 | 
			
		|||
													300UL / scaps->OpticDpi.x);
 | 
			
		||||
	m_ScanParam.bCalibration = PARAM_Gain;
 | 
			
		||||
  
 | 
			
		||||
	DBG( _DBG_INFO2, "Coarse Calibration Strip:\n" );
 | 
			
		||||
	DBG( _DBG_INFO2, "Lines    = %lu\n", m_ScanParam.Size.dwLines  );
 | 
			
		||||
	DBG( _DBG_INFO2, "Pixels   = %lu\n", m_ScanParam.Size.dwPixels );
 | 
			
		||||
	DBG( _DBG_INFO2, "Bytes    = %lu\n", m_ScanParam.Size.dwBytes  );
 | 
			
		||||
	DBG( _DBG_INFO2, "Origin.X = %u\n",  m_ScanParam.Origin.x );
 | 
			
		||||
	DBG( _DBG_INFO2, "* Coarse Calibration Strip:\n" );
 | 
			
		||||
	DBG( _DBG_INFO2, "* Lines    = %lu\n", m_ScanParam.Size.dwLines  );
 | 
			
		||||
	DBG( _DBG_INFO2, "* Pixels   = %lu\n", m_ScanParam.Size.dwPixels );
 | 
			
		||||
	DBG( _DBG_INFO2, "* Bytes    = %lu\n", m_ScanParam.Size.dwBytes  );
 | 
			
		||||
	DBG( _DBG_INFO2, "* Origin.X = %u\n",  m_ScanParam.Origin.x );
 | 
			
		||||
 | 
			
		||||
	max_rgb.Red   = max_rgb.Green = max_rgb.Blue = 0xffff;
 | 
			
		||||
	min_rgb.Red   = hw->red_lamp_on;
 | 
			
		||||
| 
						 | 
				
			
			@ -273,14 +282,14 @@ static int cano_AdjustLightsource( pPlustek_Device dev)
 | 
			
		|||
		}
 | 
			
		||||
    
 | 
			
		||||
		if(	!usb_ScanBegin( dev, SANE_FALSE) ||
 | 
			
		||||
			!usb_ScanReadImage( dev, pScanBuffer, m_ScanParam.Size.dwPhyBytes ) ||
 | 
			
		||||
			!usb_ScanReadImage( dev,pScanBuffer,m_ScanParam.Size.dwPhyBytes ) ||
 | 
			
		||||
			!usb_ScanEnd( dev )) {
 | 
			
		||||
				DBG( _DBG_ERROR, "cano_AdjustLightsource() failed\n" );
 | 
			
		||||
				DBG( _DBG_ERROR, "* cano_AdjustLightsource() failed\n" );
 | 
			
		||||
				return SANE_FALSE;
 | 
			
		||||
		}
 | 
			
		||||
    
 | 
			
		||||
		DBG( _DBG_INFO2, "PhyBytes  = %lu\n",  m_ScanParam.Size.dwPhyBytes  );
 | 
			
		||||
		DBG( _DBG_INFO2, "PhyPixels = %lu\n",  m_ScanParam.Size.dwPhyPixels );
 | 
			
		||||
		DBG( _DBG_INFO2, "* PhyBytes  = %lu\n",  m_ScanParam.Size.dwPhyBytes );
 | 
			
		||||
		DBG( _DBG_INFO2, "* PhyPixels = %lu\n",  m_ScanParam.Size.dwPhyPixels);
 | 
			
		||||
    
 | 
			
		||||
		sprintf( tmp, "coarse-lamp-%u.raw", i );
 | 
			
		||||
    
 | 
			
		||||
| 
						 | 
				
			
			@ -297,7 +306,6 @@ static int cano_AdjustLightsource( pPlustek_Device dev)
 | 
			
		|||
    
 | 
			
		||||
		dwDiv   = 10;
 | 
			
		||||
		dwLoop1 = m_ScanParam.Size.dwPhyPixels/dwDiv;
 | 
			
		||||
		adj     = 0;
 | 
			
		||||
      
 | 
			
		||||
		tmp_rgb.Red = tmp_rgb.Green = tmp_rgb.Blue = 0;
 | 
			
		||||
      
 | 
			
		||||
| 
						 | 
				
			
			@ -352,66 +360,57 @@ static int cano_AdjustLightsource( pPlustek_Device dev)
 | 
			
		|||
		DBG(_DBG_INFO2, "CUR(R,G,B)= 0x%04x(%u), 0x%04x(%u), 0x%04x(%u)\n",
 | 
			
		||||
			 				tmp_rgb.Red, tmp_rgb.Red, tmp_rgb.Green,
 | 
			
		||||
							 tmp_rgb.Green, tmp_rgb.Blue, tmp_rgb.Blue );
 | 
			
		||||
		res_r = 0;
 | 
			
		||||
		res_g = 0;
 | 
			
		||||
		res_b = 0;
 | 
			
		||||
      
 | 
			
		||||
		/* bisect */
 | 
			
		||||
		adj          = 0;
 | 
			
		||||
		warmup_limit = 2;
 | 
			
		||||
		limit        = 2;
 | 
			
		||||
 | 
			
		||||
		if( m_ScanParam.bDataType == SCANDATATYPE_Color ) {
 | 
			
		||||
			adj += cano_adjLampSetting( &min_rgb.Red, &max_rgb.Red,
 | 
			
		||||
			res_r = cano_adjLampSetting( &min_rgb.Red, &max_rgb.Red,
 | 
			
		||||
											  &hw->red_lamp_off, tmp_rgb.Red );
 | 
			
		||||
			adj += cano_adjLampSetting( &min_rgb.Blue, &max_rgb.Blue,
 | 
			
		||||
			res_b = cano_adjLampSetting( &min_rgb.Blue, &max_rgb.Blue,
 | 
			
		||||
											 &hw->blue_lamp_off,tmp_rgb.Blue );
 | 
			
		||||
			warmup_limit = 6;
 | 
			
		||||
			limit        = 10;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		adj += cano_adjLampSetting( &min_rgb.Green, &max_rgb.Green,
 | 
			
		||||
		res_g = cano_adjLampSetting( &min_rgb.Green, &max_rgb.Green,
 | 
			
		||||
										  &hw->green_lamp_off, tmp_rgb.Green );
 | 
			
		||||
		if( 0 == adj )
 | 
			
		||||
 | 
			
		||||
		/* nothing adjusted, so stop here */
 | 
			
		||||
		if((res_r == 0) && (res_g == 0) && (res_b == 0))
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		/* it might be, that we need some warmup, if every adjustment
 | 
			
		||||
		 * rans agaist the limit (cano_adjLampSetting returns 2!
 | 
			
		||||
		 * allow at least 10 loops... */
 | 
			
		||||
		if( adj == warmup_limit ) {
 | 
			
		||||
			if( i >= limit ) {
 | 
			
		||||
				DBG(_DBG_INFO, "10 times limit reached, still too dark!!!\n" );
 | 
			
		||||
				break;
 | 
			
		||||
			} else {
 | 
			
		||||
				DBG(_DBG_INFO2, "CIS-Warmup, 1s!!!\n" );
 | 
			
		||||
				sleep( 1 );
 | 
			
		||||
			}
 | 
			
		||||
		/* now decide what to do:
 | 
			
		||||
		 * if we were too bright, we have to rerun the loop in any
 | 
			
		||||
		 * case
 | 
			
		||||
		 * if we're too dark, we should rerun it too, but we can
 | 
			
		||||
		 * compensate that using higher gain values later
 | 
			
		||||
		 */
 | 
			
		||||
		if( i >= 10 ) {
 | 
			
		||||
			DBG(_DBG_INFO, "* 10 times limit reached, still too dark!!!\n");
 | 
			
		||||
			break;
 | 
			
		||||
		} else {
 | 
			
		||||
 | 
			
		||||
			/* not all channels ran against the limit... */
 | 
			
		||||
			if((adj % 2) == 0 ) {
 | 
			
		||||
				DBG( _DBG_INFO2,
 | 
			
		||||
					"Still %u channel(s) too dark, but proceeding\n", adj/2 );
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
			DBG(_DBG_INFO2, "* CIS-Warmup, 1s!!!\n" );
 | 
			
		||||
			sleep( 1 );
 | 
			
		||||
		}
 | 
			
		||||
			
 | 
			
		||||
 | 
			
		||||
		usb_AdjustLamps(dev);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	DBG( _DBG_INFO2, "red_lamp_on    = %u\n", hw->red_lamp_on  );
 | 
			
		||||
	DBG( _DBG_INFO2, "red_lamp_off   = %u\n", hw->red_lamp_off );
 | 
			
		||||
	DBG( _DBG_INFO2, "green_lamp_on  = %u\n", hw->green_lamp_on  );
 | 
			
		||||
	DBG( _DBG_INFO2, "green_lamp_off = %u\n", hw->green_lamp_off );
 | 
			
		||||
	DBG( _DBG_INFO2, "blue_lamp_on   = %u\n", hw->blue_lamp_on   );
 | 
			
		||||
	DBG( _DBG_INFO2, "blue_lamp_off  = %u\n", hw->blue_lamp_off  );
 | 
			
		||||
	DBG( _DBG_INFO2, "* red_lamp_on    = %u\n", hw->red_lamp_on  );
 | 
			
		||||
	DBG( _DBG_INFO2, "* red_lamp_off   = %u\n", hw->red_lamp_off );
 | 
			
		||||
	DBG( _DBG_INFO2, "* green_lamp_on  = %u\n", hw->green_lamp_on  );
 | 
			
		||||
	DBG( _DBG_INFO2, "* green_lamp_off = %u\n", hw->green_lamp_off );
 | 
			
		||||
	DBG( _DBG_INFO2, "* blue_lamp_on   = %u\n", hw->blue_lamp_on   );
 | 
			
		||||
	DBG( _DBG_INFO2, "* blue_lamp_off  = %u\n", hw->blue_lamp_off  );
 | 
			
		||||
    
 | 
			
		||||
	DBG( _DBG_INFO2, "cano_AdjustLightsource() done.\n" );
 | 
			
		||||
 | 
			
		||||
	return SANE_TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 */
 | 
			
		||||
static int cano_adjGainSetting( u_char *min, u_char *max, 
 | 
			
		||||
								u_char *gain,u_long val )
 | 
			
		||||
static int
 | 
			
		||||
cano_adjGainSetting( u_char *min, u_char *max, u_char *gain,u_long val )
 | 
			
		||||
{
 | 
			
		||||
	u_long newgain = *gain;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -595,17 +594,17 @@ static int cano_GetNewOffset( u_long *val, int channel, signed char *low,
 | 
			
		|||
							  signed char *now, signed char *high )
 | 
			
		||||
{
 | 
			
		||||
	/* if we're too black, we're likely off the low end */
 | 
			
		||||
	if(val[channel]<=16) {
 | 
			
		||||
		low[channel]=now[channel];
 | 
			
		||||
		now[channel]=(now[channel]+high[channel])/2;
 | 
			
		||||
	if( val[channel] <= 16 ) {
 | 
			
		||||
		low[channel] =  now[channel];
 | 
			
		||||
		now[channel] = (now[channel]+high[channel])/2;
 | 
			
		||||
 | 
			
		||||
		a_bRegs[0x38+channel]= (now[channel]&0x3f);
 | 
			
		||||
 | 
			
		||||
		if(low[channel]+1>=high[channel])
 | 
			
		||||
		if( low[channel]+1 >= high[channel] )
 | 
			
		||||
			return 0;
 | 
			
		||||
		return 1;
 | 
			
		||||
		
 | 
			
		||||
	} else if (val[channel]>=2048) {
 | 
			
		||||
	} else if ( val[channel]>=2048 ) {
 | 
			
		||||
		high[channel]=now[channel];
 | 
			
		||||
		now[channel]=(now[channel]+low[channel])/2;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -793,7 +792,7 @@ static SANE_Bool cano_AdjustDarkShading( pPlustek_Device dev )
 | 
			
		|||
	pHWDef       hw       = &dev->usbDev.HwSetting;
 | 
			
		||||
	u_short     *bufp;
 | 
			
		||||
	unsigned int i, j;
 | 
			
		||||
	int          step, stepW;
 | 
			
		||||
	int          step, stepW, val;
 | 
			
		||||
	u_long       red, green, blue, gray;
 | 
			
		||||
  
 | 
			
		||||
	DBG( _DBG_INFO2, "cano_AdjustDarkShading()\n" );
 | 
			
		||||
| 
						 | 
				
			
			@ -802,9 +801,11 @@ static SANE_Bool cano_AdjustDarkShading( pPlustek_Device dev )
 | 
			
		|||
   
 | 
			
		||||
	m_ScanParam = scanning->sParam;
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
	if( m_ScanParam.PhyDpi.x > 75)
 | 
			
		||||
		m_ScanParam.Size.dwLines = 64;
 | 
			
		||||
	else
 | 
			
		||||
#endif
 | 
			
		||||
		m_ScanParam.Size.dwLines = 32;
 | 
			
		||||
 | 
			
		||||
	m_ScanParam.Origin.y  = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -867,9 +868,26 @@ static SANE_Bool cano_AdjustDarkShading( pPlustek_Device dev )
 | 
			
		|||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			a_wDarkShading[i]         = red/m_ScanParam.Size.dwPhyLines   + pParam->swOffset[0];
 | 
			
		||||
			a_wDarkShading[i+stepW]   = green/m_ScanParam.Size.dwPhyLines + pParam->swOffset[1];
 | 
			
		||||
			a_wDarkShading[i+stepW*2] = blue/m_ScanParam.Size.dwPhyLines  + pParam->swOffset[2];
 | 
			
		||||
			val = ((int)(red/m_ScanParam.Size.dwPhyLines) + pParam->swOffset[0]);
 | 
			
		||||
			if( val < 0 ) {
 | 
			
		||||
				DBG( _DBG_INFO, "val < 0!!!!\n" );
 | 
			
		||||
				val = 0;
 | 
			
		||||
			}
 | 
			
		||||
			a_wDarkShading[i] = (u_short)val;
 | 
			
		||||
 | 
			
		||||
			val = ((int)(green/m_ScanParam.Size.dwPhyLines) + pParam->swOffset[1]);
 | 
			
		||||
			if( val < 0 ) {
 | 
			
		||||
				DBG( _DBG_INFO, "val < 0!!!!\n" );
 | 
			
		||||
				val = 0;
 | 
			
		||||
			}
 | 
			
		||||
			a_wDarkShading[i+stepW] = (u_short)val;
 | 
			
		||||
 | 
			
		||||
			val = ((int)(blue/m_ScanParam.Size.dwPhyLines) + pParam->swOffset[2]);
 | 
			
		||||
			if( val < 0 ) {
 | 
			
		||||
				DBG( _DBG_INFO, "val < 0!!!!\n" );
 | 
			
		||||
				val = 0;
 | 
			
		||||
			}
 | 
			
		||||
			a_wDarkShading[i+stepW*2] = (u_short)val;
 | 
			
		||||
		}
 | 
			
		||||
    
 | 
			
		||||
		if(usb_HostSwap())
 | 
			
		||||
| 
						 | 
				
			
			@ -891,10 +909,10 @@ static SANE_Bool cano_AdjustDarkShading( pPlustek_Device dev )
 | 
			
		|||
		if(usb_HostSwap())
 | 
			
		||||
			usb_Swap(a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2 );
 | 
			
		||||
			
 | 
			
		||||
		memcpy( a_wDarkShading+ m_ScanParam.Size.dwPhyPixels * 2,
 | 
			
		||||
				   			a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2);
 | 
			
		||||
		memcpy(a_wDarkShading+ m_ScanParam.Size.dwPhyPixels * 4,
 | 
			
		||||
							a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2);
 | 
			
		||||
		memcpy( a_wDarkShading + m_ScanParam.Size.dwPhyPixels * 2,
 | 
			
		||||
		        a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2);
 | 
			
		||||
		memcpy( a_wDarkShading + m_ScanParam.Size.dwPhyPixels * 4,
 | 
			
		||||
		        a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2);
 | 
			
		||||
	}
 | 
			
		||||
    
 | 
			
		||||
	DBG( _DBG_INFO2, "cano_AdjustDarkShading() done\n" );
 | 
			
		||||
| 
						 | 
				
			
			@ -922,9 +940,11 @@ static SANE_Bool cano_AdjustWhiteShading( pPlustek_Device dev )
 | 
			
		|||
		return SANE_FALSE;
 | 
			
		||||
 | 
			
		||||
	m_ScanParam = scanning->sParam;
 | 
			
		||||
#if 0
 | 
			
		||||
	if( m_ScanParam.PhyDpi.x > 75)
 | 
			
		||||
		m_ScanParam.Size.dwLines = 64;
 | 
			
		||||
	else
 | 
			
		||||
#endif
 | 
			
		||||
		m_ScanParam.Size.dwLines = 32;
 | 
			
		||||
 | 
			
		||||
	m_ScanParam.Origin.y  = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@
 | 
			
		|||
/** @file plustek-usbcalfile.c
 | 
			
		||||
 *  @brief Functions for saving/restoring calibration settings
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * - 0.46 - first version
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
 *  @brief Here we have our USB device definitions.
 | 
			
		||||
 *
 | 
			
		||||
 * Based on sources acquired from Plustek Inc.<br>
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * - 0.40 - starting version of the USB support
 | 
			
		||||
| 
						 | 
				
			
			@ -643,17 +643,17 @@ static DCapsDef Cap0x04A9_0x2207 =
 | 
			
		|||
 */
 | 
			
		||||
static DCapsDef Cap0x04A9_0x220D =
 | 
			
		||||
{
 | 
			
		||||
 	{{ 0, 110}, 35, 10, {2550, 3508}, {75, 75}, COLOR_GRAY16 },
 | 
			
		||||
 	{{ 0,   0},  0,  0, {0, 0}, { 0, 0 }, 0 },
 | 
			
		||||
 	{{ 0,   0},  0,  0, {0, 0}, { 0, 0 }, 0 },
 | 
			
		||||
 	{{ 0,   0},  0,  0, {0, 0}, { 0, 0 }, 0 },
 | 
			
		||||
 	{600, 600},
 | 
			
		||||
 	0,
 | 
			
		||||
 	SENSORORDER_rgb,
 | 
			
		||||
 	8,			        /* sensor distance                         */
 | 
			
		||||
 	3,		      	    /* number of buttons                       */
 | 
			
		||||
 	kCIS670,            
 | 
			
		||||
 	0,                  /* not used here...                        */
 | 
			
		||||
	{{ 0, 110}, 35, 10, {2550, 3508}, {75, 75}, COLOR_GRAY16 },
 | 
			
		||||
	{{ 0,   0},  0,  0, {0, 0}, { 0, 0 }, 0 },
 | 
			
		||||
	{{ 0,   0},  0,  0, {0, 0}, { 0, 0 }, 0 },
 | 
			
		||||
	{{ 0,   0},  0,  0, {0, 0}, { 0, 0 }, 0 },
 | 
			
		||||
	{600, 600},
 | 
			
		||||
	0,
 | 
			
		||||
	SENSORORDER_rgb,
 | 
			
		||||
	8,                  /* sensor distance                         */
 | 
			
		||||
	3,                  /* number of buttons                       */
 | 
			
		||||
	kCIS670,            
 | 
			
		||||
	0,                  /* not used here...                        */
 | 
			
		||||
	_WAF_MISC_IO_LAMPS | _WAF_BLACKFINE, _NO_MIO
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -739,7 +739,8 @@ static HWDef Hw0x07B3_0x0017_0 =
 | 
			
		|||
	0,		        /* bReg_0x5d                                */
 | 
			
		||||
	0,		        /* bReg_0x5e                                */
 | 
			
		||||
	_LM9832,        /* chip type                                */
 | 
			
		||||
	MODEL_KaoHsiung /* motorModel                               */
 | 
			
		||||
	MODEL_KaoHsiung,/* motorModel                               */
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Genius ColorPage-HR6 V2 and ColorPage-HR6X
 | 
			
		||||
| 
						 | 
				
			
			@ -783,7 +784,8 @@ static HWDef Hw0x07B3_0x0007_0 =
 | 
			
		|||
	0x0d, 0x88, 0x28, 0x3b,
 | 
			
		||||
	0, 0, 0,	
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_HuaLien
 | 
			
		||||
	MODEL_HuaLien,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** unknown
 | 
			
		||||
| 
						 | 
				
			
			@ -827,7 +829,8 @@ static HWDef Hw0x07B3_0x0007_2 =
 | 
			
		|||
	0x0d, 0x88, 0x28, 0x3b,
 | 
			
		||||
	0, 0, 0,
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_Tokyo600
 | 
			
		||||
	MODEL_Tokyo600,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Genius ColorPage-HR7 and ColorPage-HR7LE
 | 
			
		||||
| 
						 | 
				
			
			@ -871,7 +874,8 @@ static HWDef Hw0x07B3_0x0007_4 =
 | 
			
		|||
	0x0d, 0x88, 0x28, 0x3b,
 | 
			
		||||
	0, 0, 0,
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_HuaLien
 | 
			
		||||
	MODEL_HuaLien,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Genius ColorPage-HR6A
 | 
			
		||||
| 
						 | 
				
			
			@ -915,7 +919,8 @@ static HWDef Hw0x07B3_0x000F_0 =
 | 
			
		|||
	0x05, 0x88,	0x08, 0x3b,
 | 
			
		||||
	0, 0, 0,
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_HuaLien
 | 
			
		||||
	MODEL_HuaLien,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** U12 and U24
 | 
			
		||||
| 
						 | 
				
			
			@ -959,7 +964,8 @@ static HWDef Hw0x07B3_0x0013_0 =
 | 
			
		|||
	0x0d, 0x22,	0x82, 0x88,
 | 
			
		||||
	0, 0, 0,
 | 
			
		||||
	_LM9831,
 | 
			
		||||
	MODEL_KaoHsiung
 | 
			
		||||
	MODEL_KaoHsiung,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** unknown
 | 
			
		||||
| 
						 | 
				
			
			@ -1003,7 +1009,8 @@ static HWDef Hw0x07B3_0x0013_4 =
 | 
			
		|||
	0x0d, 0x22,	0x82, 0x88,
 | 
			
		||||
	0, 0, 0,
 | 
			
		||||
	_LM9831,
 | 
			
		||||
	MODEL_KaoHsiung
 | 
			
		||||
	MODEL_KaoHsiung,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** unknown
 | 
			
		||||
| 
						 | 
				
			
			@ -1047,7 +1054,8 @@ static HWDef Hw0x07B3_0x000F_4 =
 | 
			
		|||
	0x05, 0x88, 0x08, 0x3b,
 | 
			
		||||
	0, 0, 0,
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_HuaLien
 | 
			
		||||
	MODEL_HuaLien,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** unknown
 | 
			
		||||
| 
						 | 
				
			
			@ -1091,7 +1099,8 @@ static HWDef Hw0x07B3_0x0016_4 =
 | 
			
		|||
	0x0d, 0x22,	0x82, 0x88,
 | 
			
		||||
	0, 0, 0,
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_KaoHsiung
 | 
			
		||||
	MODEL_KaoHsiung,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Plustek OpticPro UT24 and others...
 | 
			
		||||
| 
						 | 
				
			
			@ -1135,7 +1144,8 @@ static HWDef Hw0x07B3_0x0017_4 =
 | 
			
		|||
	0x0d, 0x22, 0x82, 0x88,	
 | 
			
		||||
	0, 0, 0,
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_KaoHsiung
 | 
			
		||||
	MODEL_KaoHsiung,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** unknown
 | 
			
		||||
| 
						 | 
				
			
			@ -1179,7 +1189,8 @@ static HWDef Hw0x07B3_0x0017_1 =
 | 
			
		|||
	0x0d, 0x22,	0x82, 0x88,
 | 
			
		||||
	0, 0, 0,
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_KaoHsiung
 | 
			
		||||
	MODEL_KaoHsiung,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** unknown
 | 
			
		||||
| 
						 | 
				
			
			@ -1223,7 +1234,8 @@ static HWDef Hw0x07B3_0x0012_0 =
 | 
			
		|||
	0x0d, 0x22, 0x82, 0x88,	
 | 
			
		||||
	0, 0, 0,		
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_KaoHsiung
 | 
			
		||||
	MODEL_KaoHsiung,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** unknown
 | 
			
		||||
| 
						 | 
				
			
			@ -1267,7 +1279,8 @@ static HWDef Hw0x07B3_0x0017_2 =
 | 
			
		|||
	0x0d, 0x22,	0x82, 0x88,	
 | 
			
		||||
	0, 0, 0,		
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_KaoHsiung
 | 
			
		||||
	MODEL_KaoHsiung,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** unknown
 | 
			
		||||
| 
						 | 
				
			
			@ -1311,7 +1324,8 @@ static HWDef Hw0x07B3_0x0017_3 =
 | 
			
		|||
	0x0d, 0x22,	0x82, 0x88,	
 | 
			
		||||
	0, 0, 0,		
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_KaoHsiung
 | 
			
		||||
	MODEL_KaoHsiung,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** HP Scanjet 2100C
 | 
			
		||||
| 
						 | 
				
			
			@ -1378,7 +1392,8 @@ static HWDef Hw0x03F0_0x0505 =
 | 
			
		|||
	0,		/* bReg_0x5d                                */
 | 
			
		||||
	0,		/* bReg_0x5e                                */
 | 
			
		||||
	_LM9831,                /* chiptype                 */
 | 
			
		||||
	MODEL_HP                /* motorModel               */
 | 
			
		||||
	MODEL_HP,               /* motorModel               */
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** HP Scanjet 2200C */
 | 
			
		||||
| 
						 | 
				
			
			@ -1444,7 +1459,8 @@ static HWDef Hw0x03F0_0x0605 =
 | 
			
		|||
	0,		/* bReg_0x5d                            	    */
 | 
			
		||||
	0,		/* bReg_0x5e                                	*/
 | 
			
		||||
	_LM9832,                /* chiptype                		*/
 | 
			
		||||
	MODEL_HP                /* motorModel               	*/
 | 
			
		||||
	MODEL_HP,               /* motorModel               	*/
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Mustek BearPaw 1200 */
 | 
			
		||||
| 
						 | 
				
			
			@ -1501,7 +1517,8 @@ static HWDef Hw0x0400_0x1000_0 =
 | 
			
		|||
	0,      /* ok test mode ADC Output CODE LSB (reg 0x5d)  */
 | 
			
		||||
	0,      /* ok test mode (reg 0x5e)                      */
 | 
			
		||||
	_LM9831,
 | 
			
		||||
	MODEL_MUSTEK600
 | 
			
		||||
	MODEL_MUSTEK600,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Mustek BearPaw 1200 (LM9832) */
 | 
			
		||||
| 
						 | 
				
			
			@ -1558,7 +1575,8 @@ static HWDef Hw0x0400_0x1001_1 =
 | 
			
		|||
	0,      /* ok test mode ADC Output CODE LSB (reg 0x5d)  */
 | 
			
		||||
	0,      /* ok test mode (reg 0x5e)                      */
 | 
			
		||||
	_LM9832,
 | 
			
		||||
	MODEL_MUSTEK600
 | 
			
		||||
	MODEL_MUSTEK600,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** BearPaw 2400 */
 | 
			
		||||
| 
						 | 
				
			
			@ -1620,7 +1638,8 @@ static HWDef Hw0x0400_0x1001_0 =
 | 
			
		|||
    0x46,	/* misc I/O 0x5b                   				*/
 | 
			
		||||
    0, 0, 0,/* test registers, set to 0 (0x5c, 0x5d, 0x5e)	*/
 | 
			
		||||
	_LM9832,
 | 
			
		||||
    MODEL_MUSTEK1200
 | 
			
		||||
    MODEL_MUSTEK1200,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** EPSON Perfection/Photo 1250 */
 | 
			
		||||
| 
						 | 
				
			
			@ -1684,7 +1703,8 @@ static HWDef Hw0x04B8_0x010F =
 | 
			
		|||
    0,      /* ok test mode ADC Output CODE LSB (reg 0x5d)  */
 | 
			
		||||
    0,      /* ok test mode (reg 0x5e)                      */
 | 
			
		||||
	_LM9832,
 | 
			
		||||
    MODEL_EPSON
 | 
			
		||||
    MODEL_EPSON,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** EPSON Perfection/Photo 1260 */
 | 
			
		||||
| 
						 | 
				
			
			@ -1748,7 +1768,8 @@ static HWDef Hw0x04B8_0x011D =
 | 
			
		|||
    0,      /* ok test mode ADC Output CODE LSB (reg 0x5d)  */
 | 
			
		||||
    0,      /* ok test mode (reg 0x5e)                      */
 | 
			
		||||
	_LM9832,
 | 
			
		||||
    MODEL_EPSON
 | 
			
		||||
    MODEL_EPSON,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Umax 3400/3450 */
 | 
			
		||||
| 
						 | 
				
			
			@ -1813,7 +1834,8 @@ static HWDef Hw0x1606_0x0060 =
 | 
			
		|||
    0,      /* test mode ADC Output CODE LSB (reg 0x5d)  */
 | 
			
		||||
    0,      /* test mode (reg 0x5e)                      */
 | 
			
		||||
    _LM9832, /* might be LM9831 on UMAX 3450! */
 | 
			
		||||
	MODEL_UMAX
 | 
			
		||||
	MODEL_UMAX,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Umax 5400 */
 | 
			
		||||
| 
						 | 
				
			
			@ -1878,7 +1900,8 @@ static HWDef Hw0x1606_0x0160 =
 | 
			
		|||
    0,      /* test mode ADC Output CODE LSB (reg 0x5d)  */
 | 
			
		||||
    0,      /* test mode (reg 0x5e)                      */
 | 
			
		||||
    _LM9832,
 | 
			
		||||
	MODEL_UMAX1200
 | 
			
		||||
	MODEL_UMAX1200,
 | 
			
		||||
	1.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Canon 650/656 */
 | 
			
		||||
| 
						 | 
				
			
			@ -1945,7 +1968,8 @@ static HWDef Hw0x04A9_0x2206 =
 | 
			
		|||
    0,      /* test mode ADC Output CODE LSB (reg 0x5d)       */
 | 
			
		||||
    0,      /* test mode (reg 0x5e)                           */
 | 
			
		||||
    _LM9832,
 | 
			
		||||
	MODEL_CANON600
 | 
			
		||||
	MODEL_CANON600,
 | 
			
		||||
	2.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Canon N1220U */
 | 
			
		||||
| 
						 | 
				
			
			@ -2011,7 +2035,8 @@ static HWDef Hw0x04A9_0x2207 =
 | 
			
		|||
    0,      /* test mode ADC Output CODE LSB (reg 0x5d)       */
 | 
			
		||||
    0,      /* test mode (reg 0x5e)                           */
 | 
			
		||||
    _LM9832,
 | 
			
		||||
    MODEL_CANON1200
 | 
			
		||||
    MODEL_CANON1200,
 | 
			
		||||
	2.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Canon 670/676/LiDE20 */
 | 
			
		||||
| 
						 | 
				
			
			@ -2078,7 +2103,8 @@ static HWDef Hw0x04A9_0x220D =
 | 
			
		|||
    0,      /* test mode ADC Output CODE LSB (reg 0x5d)       */
 | 
			
		||||
    0,      /* test mode (reg 0x5e)                           */
 | 
			
		||||
    _LM9833,
 | 
			
		||||
	MODEL_CANON600
 | 
			
		||||
	MODEL_CANON600,
 | 
			
		||||
	2.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/** Canon N1240U */
 | 
			
		||||
| 
						 | 
				
			
			@ -2145,7 +2171,8 @@ static HWDef Hw0x04A9_0x220E =
 | 
			
		|||
    0,      /* test mode ADC Output CODE LSB (reg 0x5d)       */
 | 
			
		||||
    0,      /* test mode (reg 0x5e)                           */
 | 
			
		||||
    _LM9833,
 | 
			
		||||
    MODEL_CANON1200
 | 
			
		||||
    MODEL_CANON1200,
 | 
			
		||||
	2.0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/******************** all available combinations *****************************/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
 *  @brief Functions to control the scanner hardware.
 | 
			
		||||
 *
 | 
			
		||||
 * Based on sources acquired from Plustek Inc.<br>
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * - 0.40 - starting version of the USB support
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
 *  @brief Image processing functions for copying and scaling image lines.
 | 
			
		||||
 *
 | 
			
		||||
 * Based on sources acquired from Plustek Inc.<br>
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * - 0.40 - starting version of the USB support
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
 *  @brief Some I/O stuff.
 | 
			
		||||
 *
 | 
			
		||||
 * Based on sources acquired from Plustek Inc.<br>
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * History:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
 *  @brief Creating and manipulating lookup tables.
 | 
			
		||||
 *
 | 
			
		||||
 * Based on sources acquired from Plustek Inc.<br>
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * - 0.40 - starting version of the USB support
 | 
			
		||||
| 
						 | 
				
			
			@ -17,7 +17,7 @@
 | 
			
		|||
 * - 0.44 - map inversion for negatatives now only upon user request
 | 
			
		||||
 * - 0.45 - no changes
 | 
			
		||||
 * - 0.46 - no changes
 | 
			
		||||
 * - 0.47 - no changes
 | 
			
		||||
 * - 0.47 - cleanup work
 | 
			
		||||
 * .
 | 
			
		||||
 * <hr>
 | 
			
		||||
 * This file is part of the SANE package.
 | 
			
		||||
| 
						 | 
				
			
			@ -64,8 +64,7 @@
 | 
			
		|||
 | 
			
		||||
static SANE_Byte a_bMap[_MAP_SIZE * 3];
 | 
			
		||||
 | 
			
		||||
/*.............................................................................
 | 
			
		||||
 * adjust acording to brightness and contrast
 | 
			
		||||
/** adjust acording to brightness and contrast
 | 
			
		||||
 */
 | 
			
		||||
static void usb_MapAdjust( pPlustek_Device dev )
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -74,25 +73,23 @@ static void usb_MapAdjust( pPlustek_Device dev )
 | 
			
		|||
	
 | 
			
		||||
	tabLen = _MAP_SIZE;
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * adjust brightness (b) and contrast (c) using the function:
 | 
			
		||||
	/* adjust brightness (b) and contrast (c) using the function:
 | 
			
		||||
	 *
 | 
			
		||||
	 * s(x,y) = (s(x,y) + b) * c
 | 
			
		||||
	 * b = [-127, 127]
 | 
			
		||||
	 * c = [0,2]
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * scale brightness and contrast...
 | 
			
		||||
	 */
 | 
			
		||||
	b = ((double)dev->scanning.sParam.brightness * 192.0)/100.0;
 | 
			
		||||
	c = ((double)dev->scanning.sParam.contrast   + 100.0)/100.0;
 | 
			
		||||
 | 
			
		||||
	DBG( _DBG_INFO, "brightness   = %i -> %i\n",
 | 
			
		||||
					dev->scanning.sParam.brightness, (u_char)b);
 | 
			
		||||
	DBG( _DBG_INFO, "contrast*100 = %i -> %i\n",
 | 
			
		||||
					dev->scanning.sParam.contrast, (int)(c*100));
 | 
			
		||||
	DBG( _DBG_INFO, "* brightness = %i -> %i\n",
 | 
			
		||||
	                dev->scanning.sParam.brightness, (u_char)b);
 | 
			
		||||
	DBG( _DBG_INFO, "* contrast   = %i -> %.3f\n",
 | 
			
		||||
	                dev->scanning.sParam.contrast, c);
 | 
			
		||||
 | 
			
		||||
	if( dev->scanning.sParam.brightness == 0 && dev->scanning.sParam.contrast )
 | 
			
		||||
		return;
 | 
			
		||||
	                
 | 
			
		||||
	for( i = 0; i < tabLen; i++ ) {
 | 
			
		||||
 | 
			
		||||
		tmp = ((double)(a_bMap[i] + b)) * c;
 | 
			
		||||
| 
						 | 
				
			
			@ -112,17 +109,16 @@ static void usb_MapAdjust( pPlustek_Device dev )
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*.............................................................................
 | 
			
		||||
 *
 | 
			
		||||
/**
 | 
			
		||||
 */
 | 
			
		||||
static SANE_Bool usb_MapDownload( pPlustek_Device dev, u_char bDataType )
 | 
			
		||||
{
 | 
			
		||||
    pScanDef  scanning = &dev->scanning;
 | 
			
		||||
	pScanDef  scanning = &dev->scanning;
 | 
			
		||||
	pDCapsDef sc       = &dev->usbDev.Caps;
 | 
			
		||||
 | 
			
		||||
	int       color, maxColor;			/* loop counters             */
 | 
			
		||||
	int       color, maxColor;
 | 
			
		||||
	int       i, iThreshold;
 | 
			
		||||
	SANE_Byte value;					/* value transmitted to port */
 | 
			
		||||
	SANE_Byte value;
 | 
			
		||||
	SANE_Bool fInverse = 0;
 | 
			
		||||
	
 | 
			
		||||
	DBG( _DBG_INFO, "usb_MapDownload()\n" );
 | 
			
		||||
| 
						 | 
				
			
			@ -132,7 +128,7 @@ static SANE_Bool usb_MapDownload( pPlustek_Device dev, u_char bDataType )
 | 
			
		|||
	/* do the brightness and contrast adjustment ... */			
 | 
			
		||||
	if( scanning->sParam.bDataType != SCANDATATYPE_BW )	
 | 
			
		||||
		usb_MapAdjust( dev );
 | 
			
		||||
			
 | 
			
		||||
 | 
			
		||||
	if( !usbio_WriteReg( dev->fd, 7, 0))
 | 
			
		||||
		return SANE_FALSE;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -175,7 +171,7 @@ static SANE_Bool usb_MapDownload( pPlustek_Device dev, u_char bDataType )
 | 
			
		|||
			if(iThreshold > (int)_MAP_SIZE)
 | 
			
		||||
				iThreshold = _MAP_SIZE;
 | 
			
		||||
	
 | 
			
		||||
			DBG(_DBG_INFO, "Threshold is at %u siThresh=%i\n",
 | 
			
		||||
			DBG(_DBG_INFO, "* Threshold is at %u siThresh=%i\n",
 | 
			
		||||
								iThreshold, scanning->sParam.siThreshold );
 | 
			
		||||
 | 
			
		||||
			for(i = 0; i < iThreshold; i++)
 | 
			
		||||
| 
						 | 
				
			
			@ -185,7 +181,7 @@ static SANE_Bool usb_MapDownload( pPlustek_Device dev, u_char bDataType )
 | 
			
		|||
				a_bMap[color*_MAP_SIZE + i] = 255;
 | 
			
		||||
 | 
			
		||||
			fInverse = 1;
 | 
			
		||||
			
 | 
			
		||||
 | 
			
		||||
		} else {
 | 
			
		||||
			fInverse = 0;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -206,7 +202,7 @@ static SANE_Bool usb_MapDownload( pPlustek_Device dev, u_char bDataType )
 | 
			
		|||
			u_char  map[_MAP_SIZE];
 | 
			
		||||
			u_char *pMap = a_bMap+color*_MAP_SIZE;
 | 
			
		||||
			
 | 
			
		||||
			DBG( _DBG_INFO, "Inverting Map\n" );
 | 
			
		||||
			DBG( _DBG_INFO, "* Inverting Map\n" );
 | 
			
		||||
			
 | 
			
		||||
			for( i = 0; i < (int)_MAP_SIZE; i++, pMap++ )
 | 
			
		||||
				map[i] = ~*pMap;
 | 
			
		||||
| 
						 | 
				
			
			@ -214,6 +210,7 @@ static SANE_Bool usb_MapDownload( pPlustek_Device dev, u_char bDataType )
 | 
			
		|||
			sanei_lm983x_write( dev->fd,  0x06, map, _MAP_SIZE, SANE_FALSE );
 | 
			
		||||
			
 | 
			
		||||
		} else {
 | 
			
		||||
			DBG( _DBG_INFO, "* downloading map %u...\n", color );
 | 
			
		||||
			sanei_lm983x_write( dev->fd,  0x06, a_bMap+color*_MAP_SIZE,
 | 
			
		||||
								 _MAP_SIZE, SANE_FALSE );
 | 
			
		||||
		}								
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
 *  @brief Scanning...
 | 
			
		||||
 *
 | 
			
		||||
 * Based on sources acquired from Plustek Inc.<br>
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * - 0.40 - starting version of the USB support
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
 *  @brief Calibration routines.
 | 
			
		||||
 *
 | 
			
		||||
 * Based on sources acquired from Plustek Inc.<br>
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * - 0.40 - starting version of the USB support
 | 
			
		||||
| 
						 | 
				
			
			@ -351,10 +351,11 @@ static void usb_GetSoftwareOffsetGain( pPlustek_Device dev )
 | 
			
		|||
	case kNEC8861:
 | 
			
		||||
		DBG( _DBG_INFO2, "kNEC8861 adjustments\n" );
 | 
			
		||||
		break;
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
	case kCIS650:
 | 
			
		||||
	case kCIS670:
 | 
			
		||||
	case kCIS1220:
 | 
			
		||||
 | 
			
		||||
		DBG( _DBG_INFO2, "kCIS adjustments\n" );
 | 
			
		||||
		if(pParam->bDataType == SCANDATATYPE_Color) {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -367,7 +368,6 @@ static void usb_GetSoftwareOffsetGain( pPlustek_Device dev )
 | 
			
		|||
			pParam->swOffset[2] = 1000;
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
		
 | 
			
		||||
	case kCIS1240:
 | 
			
		||||
		DBG( _DBG_INFO2, "kCIS1240 adjustments\n" );
 | 
			
		||||
		if(pParam->bDataType == SCANDATATYPE_Color) {
 | 
			
		||||
| 
						 | 
				
			
			@ -381,7 +381,8 @@ static void usb_GetSoftwareOffsetGain( pPlustek_Device dev )
 | 
			
		|||
			pParam->swOffset[2] = 0; /*1000;*/
 | 
			
		||||
		}
 | 
			
		||||
		break;
 | 
			
		||||
		
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	case kNEC3799:
 | 
			
		||||
		DBG( _DBG_INFO2, "kNEC3799 adjustments\n" );
 | 
			
		||||
		if( sCaps->bPCB == 2 ) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,7 @@
 | 
			
		|||
 * Original code taken from sane-0.71<br>
 | 
			
		||||
 * Copyright (C) 1997 Hypercore Software Design, Ltd.<br>
 | 
			
		||||
 * Also based on the work done by Rick Bronson<br>
 | 
			
		||||
 * Copyright (C) 2000-2003 Gerhard Jaeger <gerhard@gjaeger.de><br>
 | 
			
		||||
 * Copyright (C) 2000-2004 Gerhard Jaeger <gerhard@gjaeger.de><br>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * - 0.30 - initial version
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +20,7 @@
 | 
			
		|||
 * - 0.33 - no changes
 | 
			
		||||
 * - 0.34 - moved some definitions and typedefs to plustek.h
 | 
			
		||||
 * - 0.35 - removed Y-correction for 12000P model<br>
 | 
			
		||||
 *        -  getting Y-size of scan area from driver
 | 
			
		||||
 *        - getting Y-size of scan area from driver
 | 
			
		||||
 * - 0.36 - disabled Dropout, as this does currently not work<br>
 | 
			
		||||
 *        - enabled Halftone selection only for Halftone-mode<br>
 | 
			
		||||
 *        - made the cancel button work by using a child process during read<br>
 | 
			
		||||
| 
						 | 
				
			
			@ -141,7 +141,7 @@
 | 
			
		|||
#include "../include/sane/sanei.h"
 | 
			
		||||
#include "../include/sane/saneopts.h"
 | 
			
		||||
 | 
			
		||||
#define BACKEND_VERSION "0.47-2"
 | 
			
		||||
#define BACKEND_VERSION "0.47-5"
 | 
			
		||||
#define BACKEND_NAME    plustek
 | 
			
		||||
#include "../include/sane/sanei_backend.h"
 | 
			
		||||
#include "../include/sane/sanei_config.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -283,7 +283,7 @@ static SANE_Status drvclose( Plustek_Device *dev )
 | 
			
		|||
{
 | 
			
		||||
	if( dev->fd >= 0 ) {
 | 
			
		||||
 | 
			
		||||
	    DBG( _DBG_INFO, "drvclose()\n" );
 | 
			
		||||
		DBG( _DBG_INFO, "drvclose()\n" );
 | 
			
		||||
 | 
			
		||||
		if( 0 != tsecs ) {
 | 
			
		||||
			DBG( _DBG_INFO, "TIME END 1: %lus\n", time(NULL)-tsecs);
 | 
			
		||||
| 
						 | 
				
			
			@ -309,7 +309,7 @@ static pModeParam getModeList( Plustek_Scanner *scanner )
 | 
			
		|||
	 */
 | 
			
		||||
	if( 0 != scanner->val[OPT_EXT_MODE].w ) {
 | 
			
		||||
		mp = &mp[_TPAModeSupportMin];
 | 
			
		||||
	}		
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return mp;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -514,19 +514,16 @@ static SANE_Status do_cancel( Plustek_Scanner *scanner, SANE_Bool closepipe  )
 | 
			
		|||
 */
 | 
			
		||||
static SANE_Status limitResolution( Plustek_Device *dev )
 | 
			
		||||
{
 | 
			
		||||
	dev->dpi_range.min = _DEF_DPI;
 | 
			
		||||
 	if( dev->dpi_range.min < _DEF_DPI )
 | 
			
		||||
		dev->dpi_range.min = _DEF_DPI;
 | 
			
		||||
 | 
			
		||||
	dev->dpi_range.min   = _DEF_DPI;
 | 
			
		||||
	dev->dpi_range.max   = dev->usbDev.Caps.OpticDpi.x * 2;
 | 
			
		||||
	dev->dpi_range.quant = 0;
 | 
			
		||||
	dev->x_range.min 	 = 0;
 | 
			
		||||
	dev->x_range.max 	 = SANE_FIX(dev->max_x);
 | 
			
		||||
	dev->x_range.quant 	 = 0;
 | 
			
		||||
	dev->y_range.min 	 = 0;
 | 
			
		||||
	dev->y_range.max 	 = SANE_FIX(dev->max_y);
 | 
			
		||||
	dev->y_range.quant 	 = 0;
 | 
			
		||||
	
 | 
			
		||||
	dev->x_range.min     = 0;
 | 
			
		||||
	dev->x_range.max     = SANE_FIX(dev->max_x);
 | 
			
		||||
	dev->x_range.quant   = 0;
 | 
			
		||||
	dev->y_range.min     = 0;
 | 
			
		||||
	dev->y_range.max     = SANE_FIX(dev->max_y);
 | 
			
		||||
	dev->y_range.quant   = 0;
 | 
			
		||||
 | 
			
		||||
	return SANE_STATUS_GOOD;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -540,46 +537,41 @@ static SANE_Status initGammaSettings( Plustek_Scanner *s )
 | 
			
		|||
	int    i, j, val;
 | 
			
		||||
	double gamma;
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
     * this setting is common to the ASIC98001/3 and
 | 
			
		||||
     * LM9831/2/3 based devices
 | 
			
		||||
     * older parallelport devices use 256 entries
 | 
			
		||||
     */
 | 
			
		||||
	s->gamma_length      = 4096;
 | 
			
		||||
  	s->gamma_range.min   = 0;
 | 
			
		||||
  	s->gamma_range.max   = 255;
 | 
			
		||||
  	s->gamma_range.quant = 0;
 | 
			
		||||
	s->gamma_range.min   = 0;
 | 
			
		||||
	s->gamma_range.max   = 255;
 | 
			
		||||
	s->gamma_range.quant = 0;
 | 
			
		||||
 | 
			
		||||
	DBG( _DBG_INFO, "Presetting Gamma tables (len=%u)\n", s->gamma_length );
 | 
			
		||||
 | 
			
		||||
	/* preset the gamma maps
 | 
			
		||||
	 */
 | 
			
		||||
	for( i = 0; i < 4; i++ ) {
 | 
			
		||||
 | 
			
		||||
  	DBG( _DBG_INFO, "Presetting Gamma tables (len=%u)\n", s->gamma_length );
 | 
			
		||||
  	DBG( _DBG_INFO, "----------------------------------\n" );
 | 
			
		||||
  	
 | 
			
		||||
  	/*
 | 
			
		||||
  	 * preset the gamma maps
 | 
			
		||||
  	 */
 | 
			
		||||
  	for( i = 0; i < 4; i++ ) {
 | 
			
		||||
			
 | 
			
		||||
		switch( i ) {
 | 
			
		||||
			case 1:  gamma = s->hw->adj.rgamma;    break;
 | 
			
		||||
			case 2:  gamma = s->hw->adj.ggamma;    break;
 | 
			
		||||
			case 3:  gamma = s->hw->adj.bgamma;    break;
 | 
			
		||||
			default: gamma = s->hw->adj.graygamma; break;
 | 
			
		||||
		}			
 | 
			
		||||
  	
 | 
			
		||||
		}
 | 
			
		||||
		DBG( _DBG_INFO, "* Channel[%u], gamma %.3f\n", i, gamma );
 | 
			
		||||
 | 
			
		||||
		for( j = 0; j < s->gamma_length; j++ ) {
 | 
			
		||||
		
 | 
			
		||||
 | 
			
		||||
			val = (s->gamma_range.max *
 | 
			
		||||
					    pow((double) j / ((double)s->gamma_length - 1.0),
 | 
			
		||||
						1.0 / gamma ));
 | 
			
		||||
			
 | 
			
		||||
 | 
			
		||||
			if( val > s->gamma_range.max )
 | 
			
		||||
				val = s->gamma_range.max;
 | 
			
		||||
												
 | 
			
		||||
			s->gamma_table[i][j] = val;					
 | 
			
		||||
		}			
 | 
			
		||||
	}			
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
			s->gamma_table[i][j] = val;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	DBG( _DBG_INFO, "----------------------------------\n" );
 | 
			
		||||
 | 
			
		||||
	return SANE_STATUS_GOOD;
 | 
			
		||||
}  	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** Check the gamma vectors we got back and limit if necessary
 | 
			
		||||
 * @param  s - pointer to the scanner specific structure
 | 
			
		||||
| 
						 | 
				
			
			@ -588,14 +580,15 @@ static SANE_Status initGammaSettings( Plustek_Scanner *s )
 | 
			
		|||
static void checkGammaSettings( Plustek_Scanner *s )
 | 
			
		||||
{
 | 
			
		||||
	int i, j;
 | 
			
		||||
  	
 | 
			
		||||
  	for( i = 0; i < 4 ; i++ ) {
 | 
			
		||||
 | 
			
		||||
	DBG( _DBG_INFO, "Maps changed...\n" );
 | 
			
		||||
	for( i = 0; i < 4 ; i++ ) {
 | 
			
		||||
		for( j = 0; j < s->gamma_length; j++ ) {
 | 
			
		||||
			if( s->gamma_table[i][j] > s->gamma_range.max ) {
 | 
			
		||||
				s->gamma_table[i][j] = s->gamma_range.max;
 | 
			
		||||
			}
 | 
			
		||||
		}	
 | 
			
		||||
	}	
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** initialize the options for the backend according to the device we have
 | 
			
		||||
| 
						 | 
				
			
			@ -609,7 +602,7 @@ static SANE_Status init_options( Plustek_Scanner *s )
 | 
			
		|||
	for( i = 0; i < NUM_OPTIONS; ++i ) {
 | 
			
		||||
		s->opt[i].size = sizeof (SANE_Word);
 | 
			
		||||
		s->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT;
 | 
			
		||||
    }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	s->opt[OPT_NUM_OPTS].name  = SANE_NAME_NUM_OPTIONS;
 | 
			
		||||
	s->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS;
 | 
			
		||||
| 
						 | 
				
			
			@ -646,7 +639,7 @@ static SANE_Status init_options( Plustek_Scanner *s )
 | 
			
		|||
	s->opt[OPT_EXT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST;
 | 
			
		||||
	s->opt[OPT_EXT_MODE].constraint.string_list = ext_mode_list;
 | 
			
		||||
	s->val[OPT_EXT_MODE].w = 0; /* Normal */
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	/* brightness */
 | 
			
		||||
	s->opt[OPT_BRIGHTNESS].name  = SANE_NAME_BRIGHTNESS;
 | 
			
		||||
	s->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS;
 | 
			
		||||
| 
						 | 
				
			
			@ -679,11 +672,11 @@ static SANE_Status init_options( Plustek_Scanner *s )
 | 
			
		|||
	s->val[OPT_RESOLUTION].w = s->hw->dpi_range.min;
 | 
			
		||||
 | 
			
		||||
	/* custom-gamma table */
 | 
			
		||||
  	s->opt[OPT_CUSTOM_GAMMA].name  = SANE_NAME_CUSTOM_GAMMA;
 | 
			
		||||
  	s->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA;
 | 
			
		||||
  	s->opt[OPT_CUSTOM_GAMMA].desc  = SANE_DESC_CUSTOM_GAMMA;
 | 
			
		||||
  	s->opt[OPT_CUSTOM_GAMMA].type  = SANE_TYPE_BOOL;
 | 
			
		||||
  	s->val[OPT_CUSTOM_GAMMA].w     = SANE_FALSE;
 | 
			
		||||
	s->opt[OPT_CUSTOM_GAMMA].name  = SANE_NAME_CUSTOM_GAMMA;
 | 
			
		||||
	s->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA;
 | 
			
		||||
	s->opt[OPT_CUSTOM_GAMMA].desc  = SANE_DESC_CUSTOM_GAMMA;
 | 
			
		||||
	s->opt[OPT_CUSTOM_GAMMA].type  = SANE_TYPE_BOOL;
 | 
			
		||||
	s->val[OPT_CUSTOM_GAMMA].w     = SANE_FALSE;
 | 
			
		||||
 | 
			
		||||
	/* preview */
 | 
			
		||||
	s->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW;
 | 
			
		||||
| 
						 | 
				
			
			@ -803,11 +796,6 @@ static SANE_Status init_options( Plustek_Scanner *s )
 | 
			
		|||
		s->opt[OPT_EXT_MODE].cap |= SANE_CAP_INACTIVE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
  	/* disable custom gamma, if not supported by the driver... */
 | 
			
		||||
	if( 0 == (s->hw->caps.dwFlag & SFLAG_CUSTOM_GAMMA)) {
 | 
			
		||||
	  	s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE;
 | 
			
		||||
	}  		
 | 
			
		||||
 | 
			
		||||
	return SANE_STATUS_GOOD;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -995,7 +983,7 @@ static SANE_Status attach( const char *dev_name, pCnfDef cnf,
 | 
			
		|||
	/* allocate some memory for the device */
 | 
			
		||||
	dev = malloc( sizeof (*dev));
 | 
			
		||||
	if( NULL == dev )
 | 
			
		||||
    	return SANE_STATUS_NO_MEM;
 | 
			
		||||
		return SANE_STATUS_NO_MEM;
 | 
			
		||||
 | 
			
		||||
	/* assign all the stuff we need fo this device... */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1043,9 +1031,7 @@ static SANE_Status attach( const char *dev_name, pCnfDef cnf,
 | 
			
		|||
	return SANE_STATUS_INVAL;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * go ahead and open the scanner device
 | 
			
		||||
	 */
 | 
			
		||||
	/* go ahead and open the scanner device */
 | 
			
		||||
	handle = usbDev_open( dev );
 | 
			
		||||
	if( handle < 0 ) {
 | 
			
		||||
		DBG( _DBG_ERROR,"open failed: %d\n", handle );
 | 
			
		||||
| 
						 | 
				
			
			@ -1069,10 +1055,10 @@ static SANE_Status attach( const char *dev_name, pCnfDef cnf,
 | 
			
		|||
    	dev->sane.model = dev->usbDev.ModelStr;
 | 
			
		||||
	else
 | 
			
		||||
#endif
 | 
			
		||||
    	dev->sane.model = "USB-Device";
 | 
			
		||||
   	
 | 
			
		||||
   	DBG( _DBG_INFO, "Vendor : %s\n",      dev->sane.vendor  );
 | 
			
		||||
   	DBG( _DBG_INFO, "Model  : %s\n",      dev->sane.model   );
 | 
			
		||||
		dev->sane.model = "USB-Device";
 | 
			
		||||
 | 
			
		||||
	DBG( _DBG_INFO, "Vendor : %s\n",      dev->sane.vendor  );
 | 
			
		||||
	DBG( _DBG_INFO, "Model  : %s\n",      dev->sane.model   );
 | 
			
		||||
	DBG( _DBG_INFO, "Flags  : 0x%08lx\n", dev->caps.dwFlag  );
 | 
			
		||||
 | 
			
		||||
	dev->max_x = dev->caps.wMaxExtentX*MM_PER_INCH/_MEASURE_BASE;
 | 
			
		||||
| 
						 | 
				
			
			@ -1082,8 +1068,8 @@ static SANE_Status attach( const char *dev_name, pCnfDef cnf,
 | 
			
		|||
	 * one more to avoid a buffer overflow, then allocate it...
 | 
			
		||||
	 */
 | 
			
		||||
	dev->res_list = (SANE_Int *)
 | 
			
		||||
					calloc((((dev->usbDev.Caps.OpticDpi.x*16)-_DEF_DPI)/25+1),
 | 
			
		||||
						sizeof (SANE_Int));  
 | 
			
		||||
	                 calloc((((dev->usbDev.Caps.OpticDpi.x*16)-_DEF_DPI)/25+1),
 | 
			
		||||
	                 sizeof (SANE_Int));  
 | 
			
		||||
 | 
			
		||||
	if (NULL == dev->res_list) {
 | 
			
		||||
		DBG( _DBG_ERROR, "alloc fail, resolution problem\n" );
 | 
			
		||||
| 
						 | 
				
			
			@ -1091,9 +1077,9 @@ static SANE_Status attach( const char *dev_name, pCnfDef cnf,
 | 
			
		|||
		return SANE_STATUS_INVAL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    /* build up the resolution table */
 | 
			
		||||
	/* build up the resolution table */
 | 
			
		||||
	dev->res_list_size = 0;
 | 
			
		||||
	for( cntr = _DEF_DPI; cntr <= (dev->usbDev.Caps.OpticDpi.x*16); cntr += 25 ) {
 | 
			
		||||
	for(cntr = _DEF_DPI; cntr <= (dev->usbDev.Caps.OpticDpi.x*16); cntr += 25){
 | 
			
		||||
		dev->res_list_size++;
 | 
			
		||||
		dev->res_list[dev->res_list_size - 1] = (SANE_Int)cntr;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -1110,7 +1096,7 @@ static SANE_Status attach( const char *dev_name, pCnfDef cnf,
 | 
			
		|||
	first_dev = dev;
 | 
			
		||||
 | 
			
		||||
	if (devp)
 | 
			
		||||
    	*devp = dev;
 | 
			
		||||
		*devp = dev;
 | 
			
		||||
 | 
			
		||||
	return SANE_STATUS_GOOD;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1508,12 +1494,25 @@ SANE_Status sane_control_option( SANE_Handle handle, SANE_Int option,
 | 
			
		|||
	
 | 
			
		||||
	  		/* word array options: */
 | 
			
		||||
	  		case OPT_GAMMA_VECTOR:
 | 
			
		||||
			case OPT_GAMMA_VECTOR_R:
 | 
			
		||||
			case OPT_GAMMA_VECTOR_G:
 | 
			
		||||
			case OPT_GAMMA_VECTOR_B:
 | 
			
		||||
				DBG( _DBG_INFO, "Reading MASTER gamma.\n" );
 | 
			
		||||
				memcpy( value, s->val[option].wa, s->opt[option].size );
 | 
			
		||||
				break;
 | 
			
		||||
								
 | 
			
		||||
 | 
			
		||||
			case OPT_GAMMA_VECTOR_R:
 | 
			
		||||
				DBG( _DBG_INFO, "Reading RED gamma.\n" );
 | 
			
		||||
				memcpy( value, s->val[option].wa, s->opt[option].size );
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			case OPT_GAMMA_VECTOR_G:
 | 
			
		||||
				DBG( _DBG_INFO, "Reading GREEN gamma.\n" );
 | 
			
		||||
				memcpy( value, s->val[option].wa, s->opt[option].size );
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			case OPT_GAMMA_VECTOR_B:
 | 
			
		||||
				DBG( _DBG_INFO, "Reading BLUE gamma.\n" );
 | 
			
		||||
				memcpy( value, s->val[option].wa, s->opt[option].size );
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			default:
 | 
			
		||||
				return SANE_STATUS_INVAL;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			@ -1575,9 +1574,9 @@ SANE_Status sane_control_option( SANE_Handle handle, SANE_Int option,
 | 
			
		|||
	    			break;
 | 
			
		||||
				
 | 
			
		||||
				case OPT_CUSTOM_GAMMA:
 | 
			
		||||
    				s->val[option].w = *(SANE_Word *)value;
 | 
			
		||||
					s->val[option].w = *(SANE_Word *)value;
 | 
			
		||||
	    			if( NULL != info )
 | 
			
		||||
    					*info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS;
 | 
			
		||||
						*info |= SANE_INFO_RELOAD_PARAMS | SANE_INFO_RELOAD_OPTIONS;
 | 
			
		||||
 | 
			
		||||
					mp       = getModeList( s );
 | 
			
		||||
					scanmode = mp[s->val[OPT_MODE].w].scanmode;
 | 
			
		||||
| 
						 | 
				
			
			@ -1587,8 +1586,8 @@ SANE_Status sane_control_option( SANE_Handle handle, SANE_Int option,
 | 
			
		|||
				    s->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE;
 | 
			
		||||
				    s->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE;
 | 
			
		||||
					    					    					
 | 
			
		||||
    				if( SANE_TRUE == s->val[option].w ) {
 | 
			
		||||
    				
 | 
			
		||||
					if( SANE_TRUE == s->val[option].w ) {
 | 
			
		||||
						DBG( _DBG_INFO, "Using custom gamma settings.\n" );
 | 
			
		||||
    					if((scanmode == COLOR_256GRAY) ||
 | 
			
		||||
						   (scanmode == COLOR_GRAY16)) {
 | 
			
		||||
						    s->opt[OPT_GAMMA_VECTOR].cap &= ~SANE_CAP_INACTIVE;
 | 
			
		||||
| 
						 | 
				
			
			@ -1596,10 +1595,10 @@ SANE_Status sane_control_option( SANE_Handle handle, SANE_Int option,
 | 
			
		|||
						    s->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE;
 | 
			
		||||
						    s->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE;
 | 
			
		||||
						    s->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE;
 | 
			
		||||
						}		
 | 
			
		||||
										
 | 
			
		||||
    				} else {
 | 
			
		||||
	
 | 
			
		||||
						}
 | 
			
		||||
					} else {
 | 
			
		||||
 | 
			
		||||
						DBG( _DBG_INFO, "NOT using custom gamma settings.\n" );
 | 
			
		||||
						initGammaSettings( s );
 | 
			
		||||
    				
 | 
			
		||||
    					if((scanmode == COLOR_256GRAY) ||
 | 
			
		||||
| 
						 | 
				
			
			@ -1707,9 +1706,31 @@ SANE_Status sane_control_option( SANE_Handle handle, SANE_Int option,
 | 
			
		|||
		    		break;
 | 
			
		||||
	            }
 | 
			
		||||
				case OPT_GAMMA_VECTOR:
 | 
			
		||||
					DBG( _DBG_INFO, "Setting MASTER gamma.\n" );
 | 
			
		||||
					memcpy( s->val[option].wa, value, s->opt[option].size );
 | 
			
		||||
					checkGammaSettings(s);
 | 
			
		||||
	    			if( NULL != info )
 | 
			
		||||
		    			*info |= SANE_INFO_RELOAD_PARAMS;
 | 
			
		||||
					break;
 | 
			
		||||
 | 
			
		||||
				case OPT_GAMMA_VECTOR_R:
 | 
			
		||||
					DBG( _DBG_INFO, "Setting RED gamma.\n" );
 | 
			
		||||
					memcpy( s->val[option].wa, value, s->opt[option].size );
 | 
			
		||||
					checkGammaSettings(s);
 | 
			
		||||
	    			if( NULL != info )
 | 
			
		||||
		    			*info |= SANE_INFO_RELOAD_PARAMS;
 | 
			
		||||
					break;
 | 
			
		||||
 | 
			
		||||
				case OPT_GAMMA_VECTOR_G:
 | 
			
		||||
					DBG( _DBG_INFO, "Setting GREEN gamma.\n" );
 | 
			
		||||
					memcpy( s->val[option].wa, value, s->opt[option].size );
 | 
			
		||||
					checkGammaSettings(s);
 | 
			
		||||
	    			if( NULL != info )
 | 
			
		||||
		    			*info |= SANE_INFO_RELOAD_PARAMS;
 | 
			
		||||
					break;
 | 
			
		||||
 | 
			
		||||
				case OPT_GAMMA_VECTOR_B:
 | 
			
		||||
					DBG( _DBG_INFO, "Setting BLUE gamma.\n" );
 | 
			
		||||
					memcpy( s->val[option].wa, value, s->opt[option].size );
 | 
			
		||||
					checkGammaSettings(s);
 | 
			
		||||
	    			if( NULL != info )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,7 @@
 | 
			
		|||
 *
 | 
			
		||||
 * original code taken from sane-0.71<br>
 | 
			
		||||
 * Copyright (C) 1997 Hypercore Software Design, Ltd.<br>
 | 
			
		||||
 * Copyright (C) 2001-2003 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
 | 
			
		||||
 *
 | 
			
		||||
 * History:
 | 
			
		||||
 * - 0.30 - initial version
 | 
			
		||||
| 
						 | 
				
			
			@ -122,20 +122,18 @@
 | 
			
		|||
 | 
			
		||||
/** image sizes for normal, transparent and negative modes
 | 
			
		||||
 */
 | 
			
		||||
#define _TPAPageWidth		500U
 | 
			
		||||
#define _TPAPageHeight		510U
 | 
			
		||||
#define _TPAMinDpi		    150
 | 
			
		||||
#define _TPAModeSupportMin	COLOR_TRUE24
 | 
			
		||||
#define _TPAPageWidth       500U
 | 
			
		||||
#define _TPAPageHeight      510U
 | 
			
		||||
#define _TPAMinDpi          150
 | 
			
		||||
#define _TPAModeSupportMin  COLOR_TRUE24
 | 
			
		||||
 | 
			
		||||
#define _NegativePageWidth  460UL
 | 
			
		||||
#define _NegativePageHeight 350UL
 | 
			
		||||
 | 
			
		||||
#define _NORMAL_X		216.0
 | 
			
		||||
#define _NORMAL_Y		297.0
 | 
			
		||||
#define _TP_X			((double)_TPAPageWidth/300.0 * MM_PER_INCH)
 | 
			
		||||
#define _TP_Y			((double)_TPAPageHeight/300.0 * MM_PER_INCH)
 | 
			
		||||
#define _NEG_X			((double)_NegativePageWidth/300.0 * MM_PER_INCH)
 | 
			
		||||
#define _NEG_Y			((double)_NegativePageHeight/300.0 * MM_PER_INCH)
 | 
			
		||||
#define _TP_X   ((double)_TPAPageWidth/300.0 * MM_PER_INCH)
 | 
			
		||||
#define _TP_Y   ((double)_TPAPageHeight/300.0 * MM_PER_INCH)
 | 
			
		||||
#define _NEG_X  ((double)_NegativePageWidth/300.0 * MM_PER_INCH)
 | 
			
		||||
#define _NEG_Y  ((double)_NegativePageHeight/300.0 * MM_PER_INCH)
 | 
			
		||||
 | 
			
		||||
/** scan modes
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			@ -149,17 +147,10 @@
 | 
			
		|||
 */
 | 
			
		||||
#define _MAX_ID_LEN	20
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 */
 | 
			
		||||
#define SFLAG_SCANNERDEV        0x00000002  /* is scannerdevice             */
 | 
			
		||||
#define SFLAG_FLATBED           0x00000004  /* is flatbed scanner           */
 | 
			
		||||
 | 
			
		||||
#define SFLAG_ADF		    	0x00000010  /* Automatic document feeder    */
 | 
			
		||||
#define SFLAG_TPA       	    0x00000080	/* has transparency	adapter     */
 | 
			
		||||
#define SFLAG_BUTTONOPT         0x00000100  /* has buttons                  */
 | 
			
		||||
 | 
			
		||||
#define SFLAG_CUSTOM_GAMMA		0x00000200  /* driver supports custom gamma */
 | 
			
		||||
#define SFLAG_ADF   0x00000010  /* Automatic document feeder    */
 | 
			
		||||
#define SFLAG_TPA   0x00000080  /* has transparency adapter     */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue