Removed obsolete _WAF_BLACKFINE.

LiDE20 does not seem to have a reliable black calibration area, so the
devices now will switch off the lamp for dark calibration.
Fixed line statistics and added calibration data output.
Bumped build number.
merge-requests/1/head
Gerhard Jaeger 2005-08-19 11:55:10 +00:00
rodzic f6bea76bae
commit f512d113f2
6 zmienionych plików z 141 dodań i 112 usunięć

Wyświetl plik

@ -38,6 +38,7 @@
* - added CRYSTAL_FREQ * - added CRYSTAL_FREQ
* - added IPCDef * - added IPCDef
* - 0.50 - cleanup * - 0.50 - cleanup
* - removed obsolete _WAF_BLACKFINE
* . * .
* <hr> * <hr>
* This file is part of the SANE package. * This file is part of the SANE package.

Wyświetl plik

@ -136,8 +136,8 @@ static int cano_PrepareToReadBlackCal( Plustek_Device *dev )
if( strip_state != 2 ) { if( strip_state != 2 ) {
/* /*
* if we have dark shading strip, there's no need to switch * if we have a dark shading strip, there's no need to switch
* the lamp off * the lamp off, leave in on a go to that strip
*/ */
if( dev->usbDev.pSource->DarkShadOrgY >= 0 ) { if( dev->usbDev.pSource->DarkShadOrgY >= 0 ) {
@ -680,6 +680,7 @@ static int cano_AdjustOffset( Plustek_Device *dev )
{ {
char tmp[40]; char tmp[40];
int i, adj; int i, adj;
u_short r, g, b;
u_long dw, dwPixels; u_long dw, dwPixels;
u_long dwSum[3]; u_long dwSum[3];
@ -759,17 +760,20 @@ static int cano_AdjustOffset( Plustek_Device *dev )
if( hw->bReg_0x26 & _ONE_CH_COLOR ) { if( hw->bReg_0x26 & _ONE_CH_COLOR ) {
dwSum[0] += ((u_short*)scanbuf)[dw]; r = ((u_short*)scanbuf)[dw];
dwSum[1] += ((u_short*) g = ((u_short*)scanbuf)[dw+m_ScanParam.Size.dwPhyPixels+1];
scanbuf)[dw+m_ScanParam.Size.dwPhyPixels+1]; b = ((u_short*)scanbuf)[dw+(m_ScanParam.Size.dwPhyPixels+1)*2];
dwSum[2] += ((u_short*)
scanbuf)[dw+(m_ScanParam.Size.dwPhyPixels+1)*2];
} else { } else {
dwSum[0] += ((RGBUShortDef*)scanbuf)[dw].Red; r = ((RGBUShortDef*)scanbuf)[dw].Red;
dwSum[1] += ((RGBUShortDef*)scanbuf)[dw].Green; g = ((RGBUShortDef*)scanbuf)[dw].Green;
dwSum[2] += ((RGBUShortDef*)scanbuf)[dw].Blue; b = ((RGBUShortDef*)scanbuf)[dw].Blue;
} }
dwSum[0] += r;
dwSum[1] += g;
dwSum[2] += b;
} }
DBG( _DBG_INFO2, "RedSum = %lu, ave = %lu\n", DBG( _DBG_INFO2, "RedSum = %lu, ave = %lu\n",
@ -801,7 +805,7 @@ static int cano_AdjustOffset( Plustek_Device *dev )
for( dw = 0; dw < dwPixels; dw++ ) for( dw = 0; dw < dwPixels; dw++ )
dwSum[0] += ((u_short*)scanbuf)[dw]; dwSum[0] += ((u_short*)scanbuf)[dw];
dwSum [0] /= dwPixels; dwSum[0] /= dwPixels;
DBG( _DBG_INFO2, "Sum=%lu, ave=%lu\n", dwSum[0],dwSum[0]/dwPixels); DBG( _DBG_INFO2, "Sum=%lu, ave=%lu\n", dwSum[0],dwSum[0]/dwPixels);
adj = cano_GetNewOffset( dev, dwSum, 0, low, now, high ); adj = cano_GetNewOffset( dev, dwSum, 0, low, now, high );
@ -951,9 +955,6 @@ static SANE_Bool cano_AdjustDarkShading( Plustek_Device *dev )
a_wDarkShading[i+stepW*2] = (u_short)val; a_wDarkShading[i+stepW*2] = (u_short)val;
} }
if(usb_HostSwap())
usb_Swap(a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2 * 3 );
} else { } else {
step = m_ScanParam.Size.dwPhyPixels + 1; step = m_ScanParam.Size.dwPhyPixels + 1;
@ -967,8 +968,6 @@ static SANE_Bool cano_AdjustDarkShading( Plustek_Device *dev )
} }
a_wDarkShading[i]= gray/j + param->swOffset[0]; a_wDarkShading[i]= gray/j + param->swOffset[0];
} }
if(usb_HostSwap())
usb_Swap(a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2 );
memcpy( a_wDarkShading + m_ScanParam.Size.dwPhyPixels * 2, memcpy( a_wDarkShading + m_ScanParam.Size.dwPhyPixels * 2,
a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2); a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2);
@ -976,6 +975,9 @@ static SANE_Bool cano_AdjustDarkShading( Plustek_Device *dev )
a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2); a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2);
} }
if(usb_HostSwap())
usb_Swap(a_wDarkShading, m_ScanParam.Size.dwPhyPixels * 2 * 3 );
usb_line_statistics( "Dark", a_wDarkShading, m_ScanParam.Size.dwPhyPixels, usb_line_statistics( "Dark", a_wDarkShading, m_ScanParam.Size.dwPhyPixels,
scan->sParam.bDataType == SCANDATATYPE_Color?1:0); scan->sParam.bDataType == SCANDATATYPE_Color?1:0);

Wyświetl plik

@ -52,6 +52,9 @@
* - 0.49 - tweaked motor settings for EPSON and CANON1200 * - 0.49 - tweaked motor settings for EPSON and CANON1200
* - added support for CanoScan LiDE25 * - added support for CanoScan LiDE25
* - 0.50 - cleanup * - 0.50 - cleanup
* - removed obsolete _WAF_BLACKFINE
* - LiDE20 does not seem to have a reliable black calibration area
* so the devices now will switch off the lamp for dark calibration
* . * .
* <hr> * <hr>
* This file is part of the SANE package. * This file is part of the SANE package.
@ -628,7 +631,7 @@ static DCapsDef Cap0x04A9_0x2206 =
1, /* number of buttons */ 1, /* number of buttons */
kCIS650, /* use default settings during calibration */ kCIS650, /* use default settings during calibration */
0, /* not used here... */ 0, /* not used here... */
_WAF_MISC_IO_LAMPS | _WAF_BLACKFINE, _NO_MIO _WAF_MISC_IO_LAMPS, _NO_MIO
}; };
/* Canon N1220U /* Canon N1220U
@ -646,7 +649,7 @@ static DCapsDef Cap0x04A9_0x2207 =
1, /* number of buttons */ 1, /* number of buttons */
kCIS1220, /* use default settings during calibration */ kCIS1220, /* use default settings during calibration */
0, /* not used here... */ 0, /* not used here... */
_WAF_MISC_IO_LAMPS | _WAF_BLACKFINE, _NO_MIO _WAF_MISC_IO_LAMPS, _NO_MIO
}; };
/* Canon D660U /* Canon D660U
@ -672,7 +675,7 @@ static DCapsDef Cap0x04A9_0x2208 =
*/ */
static DCapsDef Cap0x04A9_0x220D = static DCapsDef Cap0x04A9_0x220D =
{ {
{{ 0, 110}, 35, 10, {2550, 3508}, {75, 75}, COLOR_GRAY16 }, {{ 0, 110}, 35, -1, {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 }, {{ 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 },
@ -683,7 +686,7 @@ static DCapsDef Cap0x04A9_0x220D =
3, /* number of buttons */ 3, /* number of buttons */
kCIS670, kCIS670,
0, /* not used here... */ 0, /* not used here... */
_WAF_MISC_IO_LAMPS | _WAF_BLACKFINE, _NO_MIO _WAF_MISC_IO_LAMPS, _NO_MIO
}; };
/* Canon N1240U/LiDE30 /* Canon N1240U/LiDE30
@ -701,7 +704,7 @@ static DCapsDef Cap0x04A9_0x220E =
3, /* number of buttons */ 3, /* number of buttons */
kCIS1240, /* use default settings during calibration */ kCIS1240, /* use default settings during calibration */
0, /* not used here... */ 0, /* not used here... */
_WAF_MISC_IO_LAMPS | _WAF_BLACKFINE, _NO_MIO _WAF_MISC_IO_LAMPS, _NO_MIO
}; };
/* Canon LiDE25 /* Canon LiDE25
@ -719,7 +722,7 @@ static DCapsDef Cap0x04A9_0x2220 =
3, /* number of buttons */ 3, /* number of buttons */
kCIS1240, /* use default settings during calibration */ kCIS1240, /* use default settings during calibration */
0, /* not used here... */ 0, /* not used here... */
_WAF_MISC_IO_LAMPS | _WAF_BLACKFINE, _NO_MIO _WAF_MISC_IO_LAMPS, _NO_MIO
}; };
/******************* additional Hardware descriptions ************************/ /******************* additional Hardware descriptions ************************/

Wyświetl plik

@ -1104,6 +1104,7 @@ static SANE_Bool usb_SetScanParameters( Plustek_Device *dev, ScanParam *pParam )
{ {
static u_char reg8, reg38[6], reg48[2]; static u_char reg8, reg38[6], reg48[2];
ScanDef *scan = &dev->scanning;
ScanParam *pdParam = &dev->scanning.sParam; ScanParam *pdParam = &dev->scanning.sParam;
HWDef *hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
u_char *regs = dev->usbDev.a_bRegs; u_char *regs = dev->usbDev.a_bRegs;

Wyświetl plik

@ -29,6 +29,7 @@
* - 0.49 - a_bRegs is now part of the device structure * - 0.49 - a_bRegs is now part of the device structure
* - using now PhyDpi.y as selector for the motor MCLK range * - using now PhyDpi.y as selector for the motor MCLK range
* - 0.50 - readded kCIS670 to add 5% extra to LiDE20 fine calibration * - 0.50 - readded kCIS670 to add 5% extra to LiDE20 fine calibration
* - fixed line statistics and added data output
* . * .
* <hr> * <hr>
* This file is part of the SANE package. * This file is part of the SANE package.
@ -100,40 +101,49 @@ static u_long m_dwIdealGain;
static double dMCLK, dExpect, dMax; static double dMCLK, dExpect, dMax;
static double dMCLK_ADF; static double dMCLK_ADF;
/** /** do some statistics...
*/ */
static void usb_line_statistics( char *cmt, u_short* buf, static void usb_line_statistics( char *cmt, u_short* buf,
u_long dim_x, SANE_Bool color ) u_long dim_x, SANE_Bool color )
{ {
int i, end; char fn[50];
int i, channel;
u_long dw, imad, imid, alld, cld, cud; u_long dw, imad, imid, alld, cld, cud;
u_short mid, mad, aved, lbd, ubd, tmp; u_short mid, mad, aved, lbd, ubd, tmp;
MonoWordDef *pvd, *pvd2; MonoWordDef *pvd, *pvd2;
FILE *fp;
SANE_Bool swap = usb_HostSwap();
pvd = pvd2 = (MonoWordDef*)buf; pvd = pvd2 = (MonoWordDef*)buf;
if( color ) if( color )
end = 3; channel = 3;
else else
end = 1; channel = 1;
for( i = 0; i < end; i++ ) { for( i = 0; i < channel; i++ ) {
mid = 0xFFFF; mid = 0xFFFF;
mad = 0; mad = 0;
imid = 0; imid = 0;
imad = 0; imad = 0;
alld = 0; alld = 0;
cld = 0;
cud = 0;
fp = NULL;
if( DBG_LEVEL >= _DBG_DCALDATA ) {
sprintf( fn, "%scal%u.dat", cmt, i );
fp = fopen( fn, "w+b" );
if( fp == NULL )
DBG( _DBG_ERROR, "Could not open %s\n", fn );
}
/* do the standard min/max stuff */
for( dw = 0; dw < dim_x; pvd++, dw++ ) { for( dw = 0; dw < dim_x; pvd++, dw++ ) {
#ifdef SWAP_FINE if( swap )
tmp = pvd->Mono;
#else
tmp = _LOBYTE(pvd->Mono) * 256 + _HIBYTE(pvd->Mono); tmp = _LOBYTE(pvd->Mono) * 256 + _HIBYTE(pvd->Mono);
#endif else
tmp = pvd->Mono;
if( tmp > mad ) { if( tmp > mad ) {
mad = tmp; mad = tmp;
@ -145,32 +155,39 @@ static void usb_line_statistics( char *cmt, u_short* buf,
imid = dw; imid = dw;
} }
if( fp )
fprintf(fp, "%u\n", tmp );
alld += tmp; alld += tmp;
} }
if( fp )
fclose(fp);
/* calculate average and 5% limit */
aved = (u_short)(alld/dim_x); aved = (u_short)(alld/dim_x);
lbd = aved - 0.05*aved; lbd = aved - 0.05*aved;
ubd = aved + 0.05*aved; ubd = aved + 0.05*aved;
cld = 0;
cud = 0;
/* find the number of values beyond the 5% limits */
for( dw = 0; dw < dim_x; pvd2++, dw++ ) { for( dw = 0; dw < dim_x; pvd2++, dw++ ) {
#ifdef SWAP_FINE if( swap )
tmp = pvd2->Mono;
#else
tmp = _LOBYTE(pvd2->Mono) * 256 + _HIBYTE(pvd2->Mono); tmp = _LOBYTE(pvd2->Mono) * 256 + _HIBYTE(pvd2->Mono);
#endif else
tmp = pvd2->Mono;
if( tmp > ubd ) { if( tmp > ubd ) cud++;
cud++; if( tmp < lbd ) cld++;
} else if( tmp < lbd ) {
cld++;
}
} }
DBG( _DBG_INFO2, "Color[%u] (%s) : " DBG( _DBG_INFO2, "Color[%u] (%s): %lu pixels "
"min=%u(%lu) max=%u(%lu) ave=%u\n", "min=%u(%lu) max=%u(%lu) ave=%u\n",
i, cmt, mid, imid, mad, imad, aved); i, cmt, dim_x, mid, imid, mad, imad, aved);
DBG( _DBG_INFO2, "5%%: %u (%lu), %u (%lu)\n", lbd, cld,ubd,cud); DBG( _DBG_INFO2, "5%%: low@%u (count=%lu), upper@%u (count=%lu)\n",
lbd, cld, ubd, cud);
} }
} }
@ -1386,9 +1403,8 @@ static SANE_Bool usb_AdjustOffset( Plustek_Device *dev )
/** this function tries to find out some suitable values for the dark /** this function tries to find out some suitable values for the dark
* fine calibration. If the device owns a black calibration strip * fine calibration. If the device owns a black calibration strip
* (never saw one yet - _WAF_BLACKFINE is set then), the data is simply * the data is simply copied. If not, then the white strip is read
* copied. If not, then the white strip is read with the lamp switched * with the lamp switched off...
* off...
*/ */
static void usb_GetDarkShading( Plustek_Device *dev, u_short *pwDest, static void usb_GetDarkShading( Plustek_Device *dev, u_short *pwDest,
HiLoDef *pSrce, u_long dwPixels, HiLoDef *pSrce, u_long dwPixels,
@ -1399,8 +1415,8 @@ static void usb_GetDarkShading( Plustek_Device *dev, u_short *pwDest,
DCapsDef *scaps = &dev->usbDev.Caps; DCapsDef *scaps = &dev->usbDev.Caps;
HWDef *hw = &dev->usbDev.HwSetting; HWDef *hw = &dev->usbDev.HwSetting;
if( scaps->workaroundFlag & _WAF_BLACKFINE ) if( dev->usbDev.pSource->DarkShadOrgY >= 0 ) {
{
u_short w; u_short w;
int wtmp; int wtmp;
@ -1564,8 +1580,7 @@ static SANE_Bool usb_AdjustDarkShading( Plustek_Device *dev )
m_ScanParam.Size.dwBytes *= 3; m_ScanParam.Size.dwBytes *= 3;
} }
/* /* if we have dark shading strip, there's no need to switch
* if we have dark shading strip, there's no need to switch
* the lamp off * the lamp off
*/ */
if( dev->usbDev.pSource->DarkShadOrgY >= 0 ) { if( dev->usbDev.pSource->DarkShadOrgY >= 0 ) {
@ -1587,7 +1602,6 @@ static SANE_Bool usb_AdjustDarkShading( Plustek_Device *dev )
(!usb_ScanEnd( dev ))) { (!usb_ScanEnd( dev ))) {
/* on error, reset the lamp settings*/ /* on error, reset the lamp settings*/
regs[0x29] = hw->bReg_0x29; regs[0x29] = hw->bReg_0x29;
usb_switchLamp( dev, SANE_TRUE ); usb_switchLamp( dev, SANE_TRUE );
usbio_WriteReg( dev->fd, 0x29, regs[0x29] ); usbio_WriteReg( dev->fd, 0x29, regs[0x29] );
@ -1596,8 +1610,7 @@ static SANE_Bool usb_AdjustDarkShading( Plustek_Device *dev )
return SANE_FALSE; return SANE_FALSE;
} }
/* /* set illumination mode and switch lamp on again
* set illumination mode and switch lamp on again
*/ */
regs[0x29] = hw->bReg_0x29; regs[0x29] = hw->bReg_0x29;
usb_switchLamp( dev, SANE_TRUE ); usb_switchLamp( dev, SANE_TRUE );
@ -2052,8 +2065,8 @@ static SANE_Bool usb_AdjustWhiteShading( Plustek_Device *dev )
for( i = 0; i < 3; i++ ) { for( i = 0; i < 3; i++ ) {
for( dw = m_ScanParam.Size.dwPhyPixels; for(dw=m_ScanParam.Size.dwPhyPixels; dw; dw--,pValue++,pdw++) {
dw; dw--, pValue++, pdw++) {
*pdw = *pdw * 1000 / ((shading_lines - hilight - shadow) * *pdw = *pdw * 1000 / ((shading_lines - hilight - shadow) *
scan->sParam.swGain[i]); scan->sParam.swGain[i]);
if(*pdw > 65535U) if(*pdw > 65535U)
@ -2075,6 +2088,8 @@ static SANE_Bool usb_AdjustWhiteShading( Plustek_Device *dev )
} else { } else {
for( dw = m_ScanParam.Size.dwPhyPixels*3; dw; dw--,pValue++,pdw++) for( dw = m_ScanParam.Size.dwPhyPixels*3; dw; dw--,pValue++,pdw++)
pValue->Mono=(u_short)(*pdw/(shading_lines-hilight-shadow)); pValue->Mono=(u_short)(*pdw/(shading_lines-hilight-shadow));
/* swapping will be done later in usb_ResizeWhiteShading() */
} }
} else { } else {
@ -2159,12 +2174,15 @@ static SANE_Bool usb_AdjustWhiteShading( Plustek_Device *dev )
for( dw = 0; dw < m_ScanParam.Size.dwPhyPixels; dw++ ) { for( dw = 0; dw < m_ScanParam.Size.dwPhyPixels; dw++ ) {
pValue[dw].Mono = (u_short)(pdw[dw] / pValue[dw].Mono = (u_short)(pdw[dw] /
(shading_lines - hilight - shadow)); (shading_lines - hilight - shadow));
/* swapping will be done later... */
/* swapping will be done later in usb_ResizeWhiteShading() */
} }
} }
} }
if( scan->sParam.bSource != SOURCE_Negative ) {
usb_line_statistics( "White", a_wWhiteShading, m_ScanParam.Size.dwPhyPixels, usb_line_statistics( "White", a_wWhiteShading, m_ScanParam.Size.dwPhyPixels,
scan->sParam.bDataType == SCANDATATYPE_Color?1:0); scan->sParam.bDataType == SCANDATATYPE_Color?1:0);
}
return SANE_TRUE; return SANE_TRUE;
} }
@ -2629,14 +2647,14 @@ static int usb_DoCalibration( Plustek_Device *dev )
DBG( _DBG_INFO, "GainGreen = %u\n", regs[0x3c] ); DBG( _DBG_INFO, "GainGreen = %u\n", regs[0x3c] );
DBG( _DBG_INFO, "GainBlue = %u\n", regs[0x3d] ); DBG( _DBG_INFO, "GainBlue = %u\n", regs[0x3d] );
#if 0 #if 0
if( !usb_ModuleMove( dev, MOVE_Backward, if( !usb_ModuleMove( dev, MOVE_Backward,
dev->usbDev.pSource->DataOrigin.y + dev->usbDev.pSource->DataOrigin.y +
dev->usbDev.pSource->Size.y / 2 - dev->usbDev.pSource->Size.y / 2 -
dev->usbDev.pSource->ShadingOriginY)) { dev->usbDev.pSource->ShadingOriginY)) {
return _E_LAMP_NOT_IN_POS; return _E_LAMP_NOT_IN_POS;
} }
#endif #endif
regs[0x45] &= ~0x10; regs[0x45] &= ~0x10;
regs[0x3b] = regs[0x3c] = regs[0x3d] = 1; regs[0x3b] = regs[0x3c] = regs[0x3d] = 1;
@ -2679,6 +2697,8 @@ static int usb_DoCalibration( Plustek_Device *dev )
m_ScanParam.Size.dwPhyPixels*2, m_ScanParam.Size.dwPhyPixels*2,
scanning->sParam.swGain[2]); scanning->sParam.swGain[2]);
} }
usb_line_statistics( "White", a_wWhiteShading,
m_ScanParam.Size.dwPhyPixels, SANE_TRUE);
break; break;
case SOURCE_ADF: case SOURCE_ADF:

Wyświetl plik

@ -77,6 +77,7 @@
* - moved AFE stuff to enhanced options * - moved AFE stuff to enhanced options
* - 0.50 - cleanup * - 0.50 - cleanup
* - activated IPC stuff * - activated IPC stuff
* - added _DBG_DCALDATA for fine calibration data logging
*. *.
* <hr> * <hr>
* This file is part of the SANE package. * This file is part of the SANE package.
@ -152,7 +153,7 @@
#include "../include/sane/sanei.h" #include "../include/sane/sanei.h"
#include "../include/sane/saneopts.h" #include "../include/sane/saneopts.h"
#define BACKEND_VERSION "0.50-1" #define BACKEND_VERSION "0.50-2"
#define BACKEND_NAME plustek #define BACKEND_NAME plustek
#include "../include/sane/sanei_access.h" #include "../include/sane/sanei_access.h"
@ -175,6 +176,7 @@
#define _DBG_SANE_INIT 10 #define _DBG_SANE_INIT 10
#define _DBG_INFO2 15 #define _DBG_INFO2 15
#define _DBG_DREGS 20 #define _DBG_DREGS 20
#define _DBG_DCALDATA 22
#define _DBG_DPIC 25 #define _DBG_DPIC 25
#define _DBG_READ 30 #define _DBG_READ 30