[Hp5400backend-cvs-update] hp5400/hp5400 hp5400.c,1.19,1.20 hp5400.h,1.8,1.9
Status: Alpha
Brought to you by:
soumarmt
From: <kl...@us...> - 2003-03-10 11:16:51
|
Update of /cvsroot/hp5400backend/hp5400/hp5400 In directory sc8-pr-cvs1:/tmp/cvs-serv700 Modified Files: hp5400.c hp5400.h Log Message: - Tell CircBufferInit the total transfer size, so it knows how far it is. - Remove hack for getting extra lines for colour offset. Don't need it. - Check if read from scanner fails and clear scan if necessary. Index: hp5400.c =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/hp5400.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** hp5400.c 7 Mar 2003 22:42:08 -0000 1.19 --- hp5400.c 10 Mar 2003 11:16:40 -0000 1.20 *************** *** 286,290 **** /* Bytes per line is the number of pixels. The actual bytes is one more */ void CircBufferInit(int iHandle, TDataPipe *p, int iBytesPerLine, ! int bpp, int iMisAlignment, int blksize) { p->buffersize = max(BUFFER_SIZE, 3 * blksize); --- 286,290 ---- /* Bytes per line is the number of pixels. The actual bytes is one more */ void CircBufferInit(int iHandle, TDataPipe *p, int iBytesPerLine, ! int bpp, int iMisAlignment, int blksize, int iTransferSize ) { p->buffersize = max(BUFFER_SIZE, 3 * blksize); *************** *** 323,326 **** --- 323,327 ---- p->blksize = blksize; + p->transfersize = iTransferSize; #ifdef IMAGE_DEBUG *************** *** 336,340 **** ! void CircBufferGetLine(int iHandle, TDataPipe *p, void *pabLine ) { int i; --- 337,341 ---- ! int CircBufferGetLine(int iHandle, TDataPipe *p, void *pabLine ) { int i; *************** *** 371,379 **** while( p->bufstart + maxoff >= p->bufend ) /* Not enough data in buffer */ { unsigned short cmd[4] = { 0, 0, p->blksize, 0 }; assert( (p->bufend + p->blksize) <= p->buffersize ); ! hp5400_bulk_read_block( iHandle, CMD_INITBULK3, cmd, sizeof(cmd), p->buffer + p->bufend, p->blksize ); #ifdef IMAGE_DEBUG fwrite( p->buffer + p->bufend, p->blksize, 1, temp ); --- 372,389 ---- while( p->bufstart + maxoff >= p->bufend ) /* Not enough data in buffer */ { + int res; unsigned short cmd[4] = { 0, 0, p->blksize, 0 }; assert( (p->bufend + p->blksize) <= p->buffersize ); ! DBG( DBG_MSG, "Reading block, %d bytes remain\n", p->transfersize ); ! p->transfersize -= p->blksize; ! ! res = hp5400_bulk_read_block( iHandle, CMD_INITBULK3, cmd, sizeof(cmd), p->buffer + p->bufend, p->blksize ); ! if( res != p->blksize ) ! { ! DBG(DBG_ERR, "*** ERROR: Read returned %d. FATAL.", res ); ! return -1; ! } #ifdef IMAGE_DEBUG fwrite( p->buffer + p->bufend, p->blksize, 1, temp ); *************** *** 437,441 **** } ! return; } --- 447,451 ---- } ! return 0; } *************** *** 872,877 **** * difference is 4 lines */ ! req.leny = htons( pParams->iHeight + 4 ); /* = 0.42cm */ ! req.flags1 = htons( (scantype == SCAN_TYPE_CALIBRATION)?0x0000:0x0080 ); req.flags2 = htons( (scantype == SCAN_TYPE_CALIBRATION)?0x0010: --- 882,887 ---- * difference is 4 lines */ ! req.leny = htons( pParams->iHeight ); /* = 0.42cm */ ! req.flags1 = htons( (scantype == SCAN_TYPE_CALIBRATION)?0x0000:0x0080 ); req.flags2 = htons( (scantype == SCAN_TYPE_CALIBRATION)?0x0010: *************** *** 887,896 **** /* SetDefaultGamma( pHWParams->iXferHandle ); ** Must be done by caller */ ret = InitScan2( scantype, &req, pHWParams, &res, pParams->iColourOffset, 0x40 ); /* Pass the results back to the parent */ - /* Hide the extra lines we're scanning */ pParams->iBytesPerLine = htonl( res.xsize ); ! pParams->iLines = htons( res.ysize ) - pParams->iColourOffset*2; return ret; /* 0 is good, -1 is bad */ --- 897,910 ---- /* SetDefaultGamma( pHWParams->iXferHandle ); ** Must be done by caller */ + DBG( DBG_MSG, "Calibration complete\n" ); ret = InitScan2( scantype, &req, pHWParams, &res, pParams->iColourOffset, 0x40 ); + DBG( DBG_MSG, "InitScan2 returned %d\n", ret ); + /* Pass the results back to the parent */ pParams->iBytesPerLine = htonl( res.xsize ); ! ! /* Hide the extra lines we're scanning */ ! pParams->iLines = htons( res.ysize ); return ret; /* 0 is good, -1 is bad */ *************** *** 913,916 **** --- 927,931 ---- if( scantype != SCAN_TYPE_CALIBRATION ) { + DBG( DBG_MSG, "Off(%d,%d) : Len(%d,%d)\n", htons( req->offx ), htons( req->offy ), htons( req->lenx ), htons( req->leny ) ); /* Yes, all the htons() is silly but we want this check as late as possible */ if( htons( req->offx ) > 0x09F8 ) req->offx = htons( 0x09F8 ); *************** *** 1040,1044 **** bpp = 2; ! CircBufferInit( pHWParams->iXferHandle, &pHWParams->pipe, htonl(res.xsize), bpp, iColourOffset, 0xF000 ); } --- 1055,1059 ---- bpp = 2; ! CircBufferInit( pHWParams->iXferHandle, &pHWParams->pipe, htonl(res.xsize), bpp, iColourOffset, 0xF000, htonl(res.transfersize)+3*htons(res.ysize) ); } Index: hp5400.h =================================================================== RCS file: /cvsroot/hp5400backend/hp5400/hp5400/hp5400.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** hp5400.h 6 Mar 2003 10:26:42 -0000 1.8 --- hp5400.h 10 Mar 2003 11:16:41 -0000 1.9 *************** *** 58,61 **** --- 58,62 ---- int bpp; /* Bytes per pixel per colour (1 or 2) */ int linelength, pixels; /* Bytes per line from scanner */ + int transfersize; /* Number of bytes to transfer resulting image */ int blksize; /* Size of blocks to pull from scanner */ int buffersize; /* Size of the buffer */ *************** *** 114,119 **** void CircBufferInit(int iHandle, TDataPipe *p, int iBytesPerLine, ! int bpp, int iMisAlignment, int blksize); ! void CircBufferGetLine(int iHandle, TDataPipe *p, void *pabLine ); void CircBufferExit(TDataPipe *p); --- 115,120 ---- void CircBufferInit(int iHandle, TDataPipe *p, int iBytesPerLine, ! int bpp, int iMisAlignment, int blksize, int iTransferSize ); ! int CircBufferGetLine(int iHandle, TDataPipe *p, void *pabLine ); void CircBufferExit(TDataPipe *p); |