[Hp5400backend-cvs-update] hp5400/hp5400 sane-hp5400.c,1.12,1.13 hp5400.c,1.12,1.13 hp5400.h,1.6,1.7
Status: Alpha
Brought to you by:
soumarmt
From: <sou...@us...> - 2003-03-06 09:59:29
|
Update of /cvsroot/hp5400backend/hp5400/hp5400 In directory sc8-pr-cvs1:/tmp/cvs-serv25408 Modified Files: sane-hp5400.c hp5400.c hp5400.h Log Message: changed the calibration size so that it works with 1200 dpi. 2400 dpi scan params are broken so 2400 is disabled. Index: sane-hp5400.c =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/sane-hp5400.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** sane-hp5400.c 5 Mar 2003 12:33:15 -0000 1.12 --- sane-hp5400.c 6 Mar 2003 09:59:25 -0000 1.13 *************** *** 23,26 **** --- 23,27 ---- */ + /* SANE interface for hp54xx scanners. Prototype. *************** *** 77,81 **** #define NUM_GAMMA_ENTRIES 65536 - #define NUM_CAL_ENTRIES (2690 * 3 * 2) /* 16140 */ /* Device filename for USB access */ --- 78,81 ---- *************** *** 132,137 **** SANE_Int *aGammaTableB; /* a 16-to-16 bit color lookup table */ - SANE_Int *aCalibrationTable; /* 2690 sets of (minR,minG,minB,maxR,maxG,maxB) */ - int fScanning; /* TRUE if actively scanning */ int fCanceled; --- 132,135 ---- *************** *** 152,156 **** --- 150,158 ---- /* option constraints */ static const SANE_Range rangeGammaTable = {0, 65535, 1}; + #ifdef SUPPORT_2400_DPI static const SANE_Int setResolutions[] = {6, 75, 150, 300, 600, 1200, 2400}; + #else + static const SANE_Int setResolutions[] = {5, 75, 150, 300, 600, 1200}; + #endif static const SANE_Range rangeXmm = {0, 220, 1}; static const SANE_Range rangeYmm = {0, 300, 1}; *************** *** 692,712 **** s->aValues[n].w = *(SANE_Word*)pVal; /* Not needed anymore - + s->aValues[optOffsetY].w; */ break; - /* Not needed anymore - case optOffsetX: - s->aValues[optTLX].w += *(SANE_Word*)pVal - s->aValues[optOffsetX].w; - s->aValues[optBRX].w += *(SANE_Word*)pVal - s->aValues[optOffsetX].w; - s->aValues[optOffsetX].w = *(SANE_Word*)pVal; - break; - - case optOffsetY: - s->aValues[optTLY].w += *(SANE_Word*)pVal - s->aValues[optOffsetY].w; - s->aValues[optBRY].w += *(SANE_Word*)pVal - s->aValues[optOffsetY].w; - s->aValues[optOffsetY].w = *(SANE_Word*)pVal; - break; - */ case optDPI: info |= SANE_INFO_RELOAD_PARAMS; s->ScanParams.iLines = 0; /* Forget actual image settings */ ! s->aValues[n].w = *(SANE_Word*)pVal; break; --- 694,705 ---- s->aValues[n].w = *(SANE_Word*)pVal; /* Not needed anymore - + s->aValues[optOffsetY].w; */ break; case optDPI: info |= SANE_INFO_RELOAD_PARAMS; s->ScanParams.iLines = 0; /* Forget actual image settings */ ! #ifdef SUPPORT_2400_DPI ! (s->aValues[n].w) = *(SANE_Word*)pVal; ! #else ! (s->aValues[n].w) = min(1200, *(SANE_Word*)pVal); ! #endif break; Index: hp5400.c =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/hp5400.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** hp5400.c 2 Mar 2003 03:03:27 -0000 1.12 --- hp5400.c 6 Mar 2003 09:59:25 -0000 1.13 *************** *** 176,209 **** } ! int SetCalibration( int iHandle, unsigned int *low_vals[3], unsigned int *high_vals[3] ) { char cmd[8]; ! int i; ! struct CalPixel { short highr, highg, highb; short lowr, lowg, lowb; }; struct CalBlock { ! struct CalPixel pixels[42]; char pad[8]; } __attribute__((packed)); ! struct CalBlock *calinfo; - - /* We need 2690 CalPixels. A CalBlock is 512 bytes and has 42 CalPixels. - * 2690/42 = 64 rem 2, so we need 65 blocks */ - calinfo = malloc( 64 * 512 + 24 ); /* 0x8018 */ ! bzero( calinfo, 0x8018 ); ! for( i=0; i<2690; i++ ) ! { ! struct CalPixel *pixel = & calinfo[ i / 42 ].pixels[ i % 42 ]; ! /* This is obviously not quite right. The values on * the right are approximatly what windows sends */ pixel->highr = (high_vals[0][i] > 0x4000) ? 1000000000 / high_vals[0][i] : 0; /* 0x6700 */ pixel->highg = (high_vals[1][i] > 0x4000) ? 1000000000 / high_vals[1][i] : 0; /* 0x5e00 */ pixel->highb = (high_vals[2][i] > 0x4000) ? 1000000000 / high_vals[2][i] : 0; /* 0x6000 */ ! pixel->lowr = low_vals[0][i]; /* 0x0530 */ pixel->lowg = low_vals[1][i]; /* 0x0530 */ --- 176,219 ---- } ! #define CALPIXBYBLOCK 42 ! ! int SetCalibration( int iHandle, int numPixels, unsigned int *low_vals[3], unsigned int *high_vals[3], int dpi) { char cmd[8]; ! int i, j; ! struct CalPixel { short highr, highg, highb; short lowr, lowg, lowb; }; struct CalBlock { ! struct CalPixel pixels[CALPIXBYBLOCK]; char pad[8]; } __attribute__((packed)); ! struct CalBlock *calinfo; ! /** ! we did scan test at 300 dpi, so we don't have all the needed pixels. ! To fill the gap, we loop ! */ ! int numLoop = max(1, dpi / 300); ! int calBlockSize = CALPIXBYBLOCK * (6 * sizeof(short)) + 8 * sizeof(char); /* = sizeof(calBlock) */ ! int numCalBlock = ( ( numPixels / CALPIXBYBLOCK ) + ((numPixels % CALPIXBYBLOCK != 0) ? 1 : 0 )); ! int calSize = numLoop * calBlockSize * numCalBlock; ! calinfo = malloc( calSize ); ! bzero( calinfo, calSize ); ! ! // for( j=0; j< numPixels * numLoop ; j++ ) { ! for( j=0; j< numLoop * numCalBlock * CALPIXBYBLOCK ; j++ ) { ! struct CalPixel *pixel = & calinfo[ j / CALPIXBYBLOCK ].pixels[ j % CALPIXBYBLOCK ]; ! i = j % numPixels; ! ! /* This is obviously not quite right. The values on * the right are approximatly what windows sends */ pixel->highr = (high_vals[0][i] > 0x4000) ? 1000000000 / high_vals[0][i] : 0; /* 0x6700 */ pixel->highg = (high_vals[1][i] > 0x4000) ? 1000000000 / high_vals[1][i] : 0; /* 0x5e00 */ pixel->highb = (high_vals[2][i] > 0x4000) ? 1000000000 / high_vals[2][i] : 0; /* 0x6000 */ ! pixel->lowr = low_vals[0][i]; /* 0x0530 */ pixel->lowg = low_vals[1][i]; /* 0x0530 */ *************** *** 211,218 **** } ! cmd[0] = 0x00; cmd[1] = 0x80; cmd[2] = 0x18; cmd[3] = 0x00; cmd[4] = 0x54; cmd[5] = 0x02; cmd[6] = 0x80; cmd[7] = 0x00; ! ! hp5400_bulk_command_write( iHandle, 0xE603, cmd, 8, 0x8018, 0x8018, (void*)calinfo ); free( calinfo ); --- 221,231 ---- } ! cmd[0] = 0xff & (calSize >> 16); ! cmd[1] = 0xff & (calSize >> 8); ! cmd[2] = 0xff & (calSize >> 0); ! cmd[3] = 0x00; cmd[4] = 0x54; cmd[5] = 0x02; cmd[6] = 0x80; cmd[7] = 0x00; ! ! hp5400_bulk_command_write( iHandle, 0xE603, cmd, 8, calSize, calSize, (void*)calinfo ); free( calinfo ); *************** *** 594,598 **** } ! int Calibrate( int iHandle ) { struct ScanRequest req; --- 607,611 ---- } ! int Calibrate( int iHandle, int dpi ) { struct ScanRequest req; *************** *** 607,611 **** /* The first calibration scan. Finds maximum of each CCD */ bzero( &req, sizeof(req) ); ! req.x1 = 0x08; req.dpix = htons( 300 ); /* = 300 dpi */ --- 620,624 ---- /* The first calibration scan. Finds maximum of each CCD */ bzero( &req, sizeof(req) ); ! req.x1 = 0x08; req.dpix = htons( 300 ); /* = 300 dpi */ *************** *** 719,723 **** #endif ! SetCalibration( iHandle, low_array, high_array ); return 0; --- 732,736 ---- #endif ! SetCalibration( iHandle, 2690, low_array, high_array, dpi ); return 0; *************** *** 761,765 **** req.gamma[2] = htons( 100 ); ! Calibrate( iHandle ); SetDefaultGamma( iHandle ); --- 774,778 ---- req.gamma[2] = htons( 100 ); ! Calibrate( iHandle, params ->iDpi ); SetDefaultGamma( iHandle ); *************** *** 866,870 **** req.gamma[2] = htons( 100 ); ! Calibrate( pHWParams->iXferHandle ); /* SetDefaultGamma( pHWParams->iXferHandle ); ** Must be done by caller */ --- 879,883 ---- req.gamma[2] = htons( 100 ); ! Calibrate( pHWParams->iXferHandle, pParams ->iDpi ); /* SetDefaultGamma( pHWParams->iXferHandle ); ** Must be done by caller */ Index: hp5400.h =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/hp5400.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** hp5400.h 2 Mar 2003 03:03:27 -0000 1.6 --- hp5400.h 6 Mar 2003 09:59:25 -0000 1.7 *************** *** 35,39 **** #include "hp5400_xfer.h" /* for EScannerModel */ - #define HW_PIXELS 2690 /* number of pixels supported by hardware */ #define HW_DPI 300 /* horizontal resolution of hardware */ #define HW_LPI 300 /* vertical resolution of hardware */ --- 35,38 ---- |