Lines Matching refs:ps

110 static UShort imageGetPhysDPI( pScanData ps, pImgDef pImgInf, Bool fDpiX )
112 if( _IS_ASIC98(ps->sCaps.AsicID)) {
116 if (pImgInf->xyDpi.x > ps->LensInf.rDpiX.wPhyMax)
117 return ps->LensInf.rDpiX.wPhyMax;
122 if (pImgInf->xyDpi.y > ps->LensInf.rDpiY.wPhyMax)
123 return ps->LensInf.rDpiY.wPhyMax;
132 if (pImgInf->xyDpi.x > ps->LensInf.rDpiX.wPhyMax)
133 return ps->LensInf.rDpiX.wPhyMax;
137 if (pImgInf->xyDpi.x > (ps->LensInf.rDpiX.wPhyMax * 2))
138 return (ps->LensInf.rDpiX.wPhyMax * 2);
145 if (pImgInf->xyDpi.y > (ps->LensInf.rDpiY.wPhyMax / 2))
146 return (ps->LensInf.rDpiY.wPhyMax / 2);
150 if (pImgInf->xyDpi.y > ps->LensInf.rDpiY.wPhyMax)
151 return ps->LensInf.rDpiY.wPhyMax;
163 static Bool fnEveryLines( pScanData ps )
165 _VAR_NOT_USED( ps );
169 static Bool fnSampleLines( pScanData ps )
171 ps->DataInf.wYSum += ps->DataInf.xyAppDpi.y;
173 if( ps->DataInf.wYSum >= ps->DataInf.xyPhyDpi.y ) {
175 ps->DataInf.wYSum -= ps->DataInf.xyPhyDpi.y;
182 static Bool fnSamplePreview( pScanData ps )
184 ps->DataInf.wYSum += wPreviewScanned;
185 if( ps->DataInf.wYSum >= 150 ) {
187 ps->DataInf.wYSum -= 150;
198 static Bool fnReadToDriver( pScanData ps )
200 ps->AsicReg.RD_ModeControl = _ModeFifoBSel;
201 IOReadScannerImageData( ps, ps->Scan.BufPut.blue.bp,
202 ps->DataInf.dwAsicBytesPerPlane );
204 ps->AsicReg.RD_ModeControl = _ModeFifoGSel;
205 IOReadScannerImageData( ps, ps->Scan.BufPut.green.bp,
206 ps->DataInf.dwAsicBytesPerPlane );
208 if( ps->Scan.gd_gk.wGreenKeep )
209 ps->Scan.gd_gk.wGreenKeep--;
211 ps->Scan.BufPut.green.bp += ps->DataInf.dwAsicBytesPerPlane;
213 if( ps->Scan.BufPut.green.bp >= ps->Scan.BufEnd.green.bp )
214 ps->Scan.BufPut.green.bp = ps->Scan.BufBegin.green.bp;
217 ps->AsicReg.RD_ModeControl = _ModeFifoRSel;
218 IOReadScannerImageData( ps, ps->Scan.BufPut.red.bp,
219 ps->DataInf.dwAsicBytesPerPlane );
221 ps->Scan.BufPut.red.bp += ps->DataInf.dwAsicBytesPerPlane;
222 if( ps->Scan.BufPut.red.bp >= ps->Scan.BufEnd.red.bp )
223 ps->Scan.BufPut.red.bp = ps->Scan.BufBegin.red.bp;
225 if( ps->Scan.bd_rk.wRedKeep ) {
226 ps->Scan.bd_rk.wRedKeep--;
231 ps->Scan.BufData.green.bp = ps->Scan.BufGet.green.bp;
233 if( ps->DataInf.dwScanFlag & SCANDEF_ColorBGROrder ) {
234 ps->Scan.BufData.red.bp = ps->Scan.BufGet.blue.bp;
235 ps->Scan.BufData.blue.bp = ps->Scan.BufGet.red.bp;
237 ps->Scan.BufData.red.bp = ps->Scan.BufGet.red.bp;
238 ps->Scan.BufData.blue.bp = ps->Scan.BufGet.blue.bp;
241 ps->Scan.BufGet.red.bp += ps->DataInf.dwAsicBytesPerPlane;
242 ps->Scan.BufGet.green.bp += ps->DataInf.dwAsicBytesPerPlane;
244 if( ps->Scan.BufGet.red.bp >= ps->Scan.BufEnd.red.bp )
245 ps->Scan.BufGet.red.bp = ps->Scan.BufBegin.red.bp;
247 if( ps->Scan.BufGet.green.bp >= ps->Scan.BufEnd.green.bp )
248 ps->Scan.BufGet.green.bp = ps->Scan.BufBegin.green.bp;
254 static Bool fnReadOutScanner( pScanData ps )
256 if( ps->Scan.bd_rk.wBlueDiscard ) {
258 ps->Scan.bd_rk.wBlueDiscard--;
259 ps->AsicReg.RD_ModeControl = _ModeFifoBSel;
261 IOReadScannerImageData( ps, ps->Bufs.b1.pReadBuf,
262 ps->DataInf.dwAsicBytesPerPlane );
264 if( ps->Scan.gd_gk.wGreenDiscard ) {
265 ps->Scan.gd_gk.wGreenDiscard--;
267 ps->AsicReg.RD_ModeControl = _ModeFifoGSel;
268 IOReadScannerImageData( ps, ps->Bufs.b1.pReadBuf,
269 ps->DataInf.dwAsicBytesPerPlane);
274 IOReadColorData( ps, ps->Bufs.b1.pReadBuf,
275 ps->DataInf.dwAsicBytesPerPlane );
282 static void fnP96GrayDirect( pScanData ps, pVoid pBuf, pVoid pImg, ULong bl )
290 *dest = ps->pbMapRed [*src];
300 static void fnDataDirect( pScanData ps, pVoid pBuf, pVoid pImg, ULong bl )
302 _VAR_NOT_USED( ps );
309 static void fnHalftoneDirect0( pScanData ps, pVoid pb, pVoid pImg, ULong bL )
317 pDither = &ps->a_bDitherPattern[ps->dwDitherIndex];
330 ps->dwDitherIndex = (ps->dwDitherIndex + 8) & 0x3f;
335 static void fnHalftoneDirect1( pScanData ps, pVoid pb, pVoid pImg, ULong bL )
341 _VAR_NOT_USED( ps );
362 static void fnP98ColorDirect( pScanData ps, pVoid pb, pVoid pImg, ULong bL )
370 for ( bL = ps->DataInf.dwAsicPixelsPerPlane; bL; bL--, src++, dest++) {
373 dest->Green = src[ps->DataInf.dwAsicPixelsPerPlane];
374 dest->Blue = src[ps->DataInf.dwAsicPixelsPerPlane*2];
378 static void fnP96ColorDirect( pScanData ps, pVoid pb, pVoid pImg, ULong bL )
386 for ( bL = ps->DataInf.dwAsicPixelsPerPlane; bL; bL--, dest++, src++) {
388 dest->Red =ps->pbMapRed[*src];
389 dest->Green=ps->pbMapGreen[src[ps->DataInf.dwAsicPixelsPerPlane]];
390 dest->Blue =ps->pbMapBlue[src[ps->DataInf.dwAsicPixelsPerPlane*2]];
397 static void fnP98Color48( pScanData ps, pVoid pb, pVoid pImg, ULong bL )
408 for ( i = ps->DataInf.dwAsicPixelsPerPlane; i; i--, src++, dest++) {
411 dest->Green = src[ps->DataInf.dwAsicPixelsPerPlane];
412 dest->Blue = src[ps->DataInf.dwAsicPixelsPerPlane * 2];
418 static int imageP98SetupScanSettings( pScanData ps, pScanInfo pInf )
424 ps->DataInf.dwScanFlag = pInf->ImgDef.dwFlag;
425 ps->DataInf.dwVxdFlag = 0;
426 ps->DataInf.crImage = pInf->ImgDef.crArea;
434 ps->DataInf.crImage.x <<= 1;
436 ps->DataInf.xyAppDpi = pInf->ImgDef.xyDpi;
437 ps->DataInf.siBrightness = pInf->siBrightness;
438 ps->DataInf.wDither = pInf->wDither;
439 ps->DataInf.wAppDataType = pInf->ImgDef.wDataType;
441 ps->GetImageInfo( ps, &pInf->ImgDef );
443 if (ps->DataInf.dwVxdFlag & _VF_DATATOUSERBUFFER) {
444 ps->Scan.DataProcess = fnDataDirect;
446 if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle) {
447 ps->Scan.lBufferAdjust = -(Long)ps->DataInf.dwAppBytesPerLine;
449 ps->Scan.lBufferAdjust = (Long)ps->DataInf.dwAppBytesPerLine;
454 ps->DataInf.crImage.x, ps->DataInf.crImage.y,
455 ps->DataInf.crImage.cx, ps->DataInf.crImage.cy );
474 if( ps->DataInf.wPhyDataType != COLOR_BW ) {/* if not line art */
475 ps->wBrightness = pInf->siBrightness; /* use internal tables for */
476 ps->wContrast = pInf->siContrast; /* brightness and contrast */
485 if (ps->DataInf.siBrightness < 0) {
487 (255 - _DEF_BW_THRESHOLD) * ps->DataInf.siBrightness /127);
490 _DEF_BW_THRESHOLD * ps->DataInf.siBrightness /127);
492 ps->AsicReg.RD_ThresholdControl = brightness;
496 if( ps->DataInf.siBrightness >= 0 ) {
498 ps->DataInf.siBrightness) / 127 + _DEF_BW_THRESHOLD);
501 ps->DataInf.siBrightness) / 127 + _DEF_BW_THRESHOLD);
506 if( _ASIC_IS_98003 == ps->sCaps.AsicID ) {
507 ps->AsicReg.RD_ThresholdControl = brightness;
511 ps->DataInf.pCurrentBuffer = ps->pScanBuffer1;
518 static void imageP98DoCopyBuffer( pScanData ps, pUChar pImage )
520 memcpy( ps->pFilterBuf, pImage, ps->DataInf.dwAsicBytesPerPlane );
522 ps->pFilterBuf += 5120;
523 if (ps->pFilterBuf >= ps->pEndBuf)
524 ps->pFilterBuf = ps->pProcessingBuf;
529 static Bool imageP98CopyToFilterBuffer( pScanData ps, pUChar pImage )
531 if (ps->fDoFilter) {
533 if (ps->fFilterFirstLine) {
535 imageP98DoCopyBuffer( ps, pImage );
536 imageP98DoCopyBuffer( ps, pImage );
537 ps->dwLinesFilter--;
541 imageP98DoCopyBuffer( ps, pImage );
542 if ((ps->dwLinesFilter--) == 0)
543 imageP98DoCopyBuffer( ps, pImage);
551 static void imageP98UnSharpCompare( pScanData ps, Byte Center,
558 if (b > ps->bOffsetFilter) {
561 ps->dwDivFilter--;
567 static void imageP98DoFilter( pScanData ps, pUChar pPut )
572 if (ps->fDoFilter && (ps->DataInf.xyAppDpi.x) >= 600UL) {
575 for (dw = 0; dw < ps->DataInf.dwAsicBytesPerPlane - 2; dw++, pPut++) {
577 ps->dwDivFilter = ps->dwMul;
579 dwNewValue = ((ULong)ps->pGet2[dw+1]) * ps->dwMul;
580 imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet1[dw], &dwNewValue);
581 imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet1[dw+1], &dwNewValue);
582 imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet1[dw+2], &dwNewValue);
583 imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet2[dw], &dwNewValue);
584 imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet2[dw+2], &dwNewValue);
585 imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet3[dw], &dwNewValue);
586 imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet3[dw+1], &dwNewValue);
587 imageP98UnSharpCompare( ps, ps->pGet2[dw+1], ps->pGet3[dw+2], &dwNewValue);
590 if((dwNewValue /= ps->dwDivFilter) < 255) {
599 pPut = ps->pGet1;
600 ps->pGet1 = ps->pGet2;
601 ps->pGet2 = ps->pGet3;
602 ps->pGet3 = pPut;
608 static Bool imageP98DataIsReady( pScanData ps )
612 ps->Scan.fMotorBackward = _FALSE;
613 ps->bMoveDataOutFlag = _DataAfterRefreshState;
615 b = (ps->DataInf.wPhyDataType >= COLOR_TRUE24) ?
619 ps->dwColorRunIndex ++;
621 if(ps->pColorRunTable[ps->dwColorRunIndex] & b)
627 ps->AsicReg.RD_ModeControl = _ModeFifoGSel;
628 IOReadScannerImageData( ps, ps->DataInf.pCurrentBuffer,
629 ps->DataInf.dwAsicBytesPerPlane );
631 imageP98CopyToFilterBuffer( ps, ps->DataInf.pCurrentBuffer );
635 if( ps->DataInf.dwScanFlag & SCANDEF_ColorBGROrder ) {
637 ps->AsicReg.RD_ModeControl = _ModeFifoRSel;
638 IOReadScannerImageData( ps, ps->pScanBuffer1 +
639 ps->DataInf.dwAsicBytesPerPlane * 2,
640 ps->DataInf.dwAsicBytesPerPlane );
642 ps->AsicReg.RD_ModeControl = _ModeFifoGSel;
643 IOReadScannerImageData( ps, ps->pScanBuffer1 +
644 ps->DataInf.dwAsicBytesPerPlane,
645 ps->DataInf.dwAsicBytesPerPlane );
647 ps->AsicReg.RD_ModeControl = _ModeFifoBSel;
648 IOReadScannerImageData( ps, ps->pScanBuffer1,
649 ps->DataInf.dwAsicBytesPerPlane );
652 IOReadColorData( ps, ps->pScanBuffer1,
653 ps->DataInf.dwAsicBytesPerPlane );
657 if (ps->fFilterFirstLine) {
658 ps->fFilterFirstLine = _FALSE;
662 imageP98DoFilter( ps, ps->DataInf.pCurrentBuffer );
664 (*ps->Scan.DataProcess)( ps, ps->Scan.bp.pMonoBuf,
665 ps->DataInf.pCurrentBuffer,
666 ps->DataInf.dwAppPhyBytesPerLine );
673 static Bool imageP98001ReadOneImageLine( pScanData ps )
681 ps->Scan.bNowScanState = IOGetScanState( ps, _FALSE );
682 dwFifoCounter = IOReadFifoLength( ps );
684 if (!(ps->Scan.bNowScanState & _SCANSTATE_STOP) &&
685 (dwFifoCounter < ps->dwMaxReadFifoData)) {
687 if( ps->Scan.bOldScanState != ps->Scan.bNowScanState )
688 ps->UpdateDataCurrentReadLine( ps );
690 if( dwFifoCounter >= ps->Scan.dwMinReadFifo )
691 return imageP98DataIsReady( ps );
695 if (dwFifoCounter >= ps->dwSizeMustProcess)
696 return imageP98DataIsReady( ps );
698 ps->UpdateDataCurrentReadLine( ps );
700 if( dwFifoCounter >= ps->Scan.dwMinReadFifo )
701 return imageP98DataIsReady( ps );
709 MotorToHomePosition(ps);
717 static void imageP98GetInfo( pScanData ps, pImgDef pImgInf )
721 ps->DataInf.xyPhyDpi.x = imageGetPhysDPI( ps, pImgInf, _TRUE );
722 ps->DataInf.xyPhyDpi.y = imageGetPhysDPI( ps, pImgInf, _FALSE );
725 ps->DataInf.xyPhyDpi.x, ps->DataInf.xyPhyDpi.y );
733 ps->DataInf.XYRatio = 1000 * ps->DataInf.xyPhyDpi.y/ps->DataInf.xyPhyDpi.x;
735 pImgInf->xyDpi.x, pImgInf->xyDpi.y, ps->DataInf.XYRatio );
737 ps->DataInf.dwAppLinesPerArea = (ULong)pImgInf->crArea.cy *
740 ps->DataInf.dwAppPixelsPerLine = (ULong)pImgInf->crArea.cx *
743 ps->DataInf.dwPhysBytesPerLine = (ULong)pImgInf->crArea.cx *
744 ps->DataInf.xyPhyDpi.x / _MEASURE_BASE;
747 ps->DataInf.dwAsicPixelsPerPlane = (ps->DataInf.dwAppPixelsPerLine+7UL)&
749 ps->DataInf.dwAppPhyBytesPerLine =
750 ps->DataInf.dwAppBytesPerLine =
751 ps->DataInf.dwAsicBytesPerLine =
752 ps->DataInf.dwAsicBytesPerPlane = ps->DataInf.dwAsicPixelsPerPlane>>3;
754 ps->DataInf.dwAsicBytesPerPlane =
755 ps->DataInf.dwAsicPixelsPerPlane = ps->DataInf.dwAppPixelsPerLine;
759 ps->DataInf.dwAsicBytesPerPlane *= 2;
765 ps->DataInf.dwVxdFlag |= _VF_DATATOUSERBUFFER;
766 ps->DataInf.wPhyDataType = COLOR_BW;
767 ps->Shade.bIntermediate = _ScanMode_Mono;
771 if( ps->DataInf.wDither == 2 ) {
772 ps->Scan.DataProcess = fnHalftoneDirect1;
774 ps->Scan.DataProcess = fnHalftoneDirect0;
779 ps->DataInf.dwAsicBytesPerPlane =
780 ps->DataInf.dwAsicPixelsPerPlane = ps->DataInf.dwAppPixelsPerLine;
781 ps->DataInf.wPhyDataType = COLOR_256GRAY;
782 ps->Shade.bIntermediate = _ScanMode_Mono;
786 ps->DataInf.dwVxdFlag |= _VF_DATATOUSERBUFFER;
787 ps->DataInf.dwAsicBytesPerLine =
788 ps->DataInf.dwAppPhyBytesPerLine = ps->DataInf.dwAppPixelsPerLine;
789 ps->DataInf.wPhyDataType = COLOR_256GRAY;
790 ps->Shade.bIntermediate = _ScanMode_Mono;
794 ps->Scan.DataProcess = fnP98ColorDirect;
795 ps->DataInf.dwAsicBytesPerLine =
796 ps->DataInf.dwAppPhyBytesPerLine = ps->DataInf.dwAppPixelsPerLine * 3;
797 ps->DataInf.wPhyDataType = COLOR_TRUE24;
798 ps->Shade.bIntermediate = _ScanMode_Color;
802 ps->Scan.DataProcess = fnP98Color48;
803 ps->DataInf.dwAsicBytesPerLine =
804 ps->DataInf.dwAppPhyBytesPerLine = ps->DataInf.dwAppPixelsPerLine * 6;
805 ps->DataInf.wPhyDataType = COLOR_TRUE48;
806 ps->Shade.bIntermediate = _ScanMode_Color;
812 ps->DataInf.dwAppBytesPerLine = (ps->DataInf.dwAppPhyBytesPerLine + 3) &
816 ps->DataInf.dwAppBytesPerLine = (ps->DataInf.dwAppPhyBytesPerLine + 1) &
819 ps->DataInf.dwAppBytesPerLine = ps->DataInf.dwAppPhyBytesPerLine;
823 DBG( DBG_LOW, "AppLinesPerArea = %u\n", ps->DataInf.dwAppLinesPerArea );
824 DBG( DBG_LOW, "AppPixelsPerLine = %u\n", ps->DataInf.dwAppPixelsPerLine );
825 DBG( DBG_LOW, "AppPhyBytesPerLine = %u\n", ps->DataInf.dwAppPhyBytesPerLine );
826 DBG( DBG_LOW, "AppBytesPerLine = %u\n", ps->DataInf.dwAppBytesPerLine );
827 DBG( DBG_LOW, "AsicPixelsPerPlane = %u\n", ps->DataInf.dwAsicPixelsPerPlane );
828 DBG( DBG_LOW, "AsicBytesPerPlane = %u\n", ps->DataInf.dwAsicBytesPerPlane );
829 DBG( DBG_LOW, "AsicBytesPerLine = %u\n", ps->DataInf.dwAsicBytesPerLine );
830 DBG( DBG_LOW, "Physical Bytes = %u\n", ps->DataInf.dwPhysBytesPerLine );
835 static void imageP96GetInfo( pScanData ps, pImgDef pImgInf )
839 ps->DataInf.xyPhyDpi.x = imageGetPhysDPI( ps, pImgInf, _TRUE );
840 ps->DataInf.xyPhyDpi.y = imageGetPhysDPI( ps, pImgInf, _FALSE );
843 ps->DataInf.xyPhyDpi.x, ps->DataInf.xyPhyDpi.y );
851 ps->DataInf.XYRatio = 1000 * ps->DataInf.xyPhyDpi.y/ps->DataInf.xyPhyDpi.x;
853 pImgInf->xyDpi.x, pImgInf->xyDpi.y, ps->DataInf.XYRatio );
855 ps->DataInf.dwAppLinesPerArea = (ULong)pImgInf->crArea.cy *
857 ps->DataInf.dwAsicBytesPerPlane =
858 ps->DataInf.dwAsicPixelsPerPlane = (ULong)ps->DataInf.xyPhyDpi.x *
861 ps->DataInf.dwAppPixelsPerLine = (ULong)pImgInf->crArea.cx *
864 ps->DataInf.dwPhysBytesPerLine = (ULong)pImgInf->crArea.cx *
865 ps->DataInf.xyPhyDpi.x / _MEASURE_BASE;
867 ps->DataInf.wPhyDataType = ps->DataInf.wAppDataType;
872 ps->DataInf.dwAsicBytesPerPlane =
873 (ps->DataInf.dwAsicPixelsPerPlane + 7) >> 3;
874 ps->DataInf.dwAppPhyBytesPerLine =
875 (ps->DataInf.dwAppPixelsPerLine + 7) >> 3;
876 ps->DataInf.dwVxdFlag |= _VF_DATATOUSERBUFFER;
877 ps->Scan.DataProcess = fnDataDirect;
881 ps->DataInf.dwAppPhyBytesPerLine =
882 (ps->DataInf.dwAsicPixelsPerPlane + 7) >> 3;
883 if( ps->DataInf.wDither == 2 ) {
884 ps->Scan.DataProcess = fnHalftoneDirect1;
886 ps->Scan.DataProcess = fnHalftoneDirect0;
888 ps->DataInf.wPhyDataType = COLOR_256GRAY;
892 ps->DataInf.dwAppPhyBytesPerLine = ps->DataInf.dwAppPixelsPerLine;
893 ps->Scan.DataProcess = fnP96GrayDirect;
898 ps->Scan.DataProcess = fnP98ColorDirect;
900 ps->Scan.DataProcess = fnP96ColorDirect;
902 ps->DataInf.dwAppPhyBytesPerLine = ps->DataInf.dwAppPixelsPerLine * 3;
906 ps->DataInf.dwAppBytesPerLine =
907 (ps->DataInf.dwAppPhyBytesPerLine + 3) & 0xfffffffc;
910 ps->DataInf.dwAppBytesPerLine =
911 (ps->DataInf.dwAppPhyBytesPerLine + 1) & 0xfffffffe;
913 ps->DataInf.dwAppBytesPerLine = ps->DataInf.dwAppPhyBytesPerLine;
917 if (ps->DataInf.wPhyDataType == COLOR_TRUE24)
918 ps->DataInf.dwAsicBytesPerLine = ps->DataInf.dwAsicBytesPerPlane * 3;
920 ps->DataInf.dwAsicBytesPerLine = ps->DataInf.dwAsicBytesPerPlane;
925 DBG( DBG_LOW, "AppLinesPerArea = %u\n", ps->DataInf.dwAppLinesPerArea );
926 DBG( DBG_LOW, "AppPixelsPerLine = %u\n", ps->DataInf.dwAppPixelsPerLine );
927 DBG( DBG_LOW, "AppPhyBytesPerLine = %u\n", ps->DataInf.dwAppPhyBytesPerLine );
928 DBG( DBG_LOW, "AppBytesPerLine = %u\n", ps->DataInf.dwAppBytesPerLine );
929 DBG( DBG_LOW, "AsicPixelsPerPlane = %u\n", ps->DataInf.dwAsicPixelsPerPlane );
930 DBG( DBG_LOW, "AsicBytesPerPlane = %u\n", ps->DataInf.dwAsicBytesPerPlane );
931 DBG( DBG_LOW, "AsicBytesPerLine = %u\n", ps->DataInf.dwAsicBytesPerLine );
932 DBG( DBG_LOW, "Physical Bytes = %u\n", ps->DataInf.dwPhysBytesPerLine );
937 static Bool imageP96ReadOneImageLine( pScanData ps )
946 bFifoCount = IODataRegisterFromScanner( ps, ps->RegFifoOffset );
948 /* CHECK ps->bMoveDataOutFlag will never be set to _DataFromStopState !!!*/
950 if ((bFifoCount < ps->bMinReadFifo) &&
951 (ps->bMoveDataOutFlag == _DataFromStopState)) {
953 bData = IOGetScanState( ps, _FALSE);
956 if (bData < ps->bCurrentLineCount)
958 if ((bData - ps->bCurrentLineCount) < _SCANSTATE_BYTES)
962 ps->bMoveDataOutFlag = _DataAfterRefreshState;
968 // if( ps->bMoveDataOutFlag != _DataFromStopState )
969 // ps->UpdateDataCurrentReadLine( ps );
971 if( bFifoCount >= ps->bMinReadFifo ) {
974 for (; !(*ps->pCurrentColorRunTable &
975 (ps->RedDataReady | ps->GreenDataReady | _BLUE_DATA_READY));
976 ps->pCurrentColorRunTable++);
979 if( ps->pCurrentColorRunTable >
980 (ps->pColorRunTable+ps->BufferForColorRunTable))
984 if (ps->DataInf.wPhyDataType == COLOR_TRUE24) {
989 if (*ps->pCurrentColorRunTable & ps->b1stColor) {
990 *ps->pCurrentColorRunTable &= ps->b1stMask;
991 IOReadScannerImageData (ps, ps->pPutBufR,
992 ps->DataInf.dwAsicBytesPerPlane);
993 ps->pPutBufR += ps->BufferSizePerModel;
994 if (ps->pPutBufR == ps->pEndBufR)
995 ps->pPutBufR = ps->pPrescan16;
997 if (*ps->pCurrentColorRunTable & ps->b2ndColor) {
998 *ps->pCurrentColorRunTable &= ps->b2ndMask;
999 IOReadScannerImageData( ps, ps->pPutBufG,
1000 ps->DataInf.dwAsicBytesPerPlane);
1001 ps->pPutBufG += ps->BufferSizePerModel;
1002 if (ps->pPutBufG == ps->pEndBufG)
1003 ps->pPutBufG = ps->pPrescan8;
1005 *ps->pCurrentColorRunTable &= ps->b3rdMask;
1006 ps->pCurrentColorRunTable++; /* processed this step */
1015 if (ps->b3rdColor & ps->GreenDataReady) {
1017 IOReadScannerImageData (ps,
1018 ps->DataInf.pCurrentBuffer +
1019 ps->DataInf.dwAsicBytesPerPlane,
1020 ps->DataInf.dwAsicBytesPerPlane);
1023 if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle) {
1025 IOReadScannerImageData (ps,
1026 ps->DataInf.pCurrentBuffer,
1027 ps->DataInf.dwAsicBytesPerPlane);
1030 IOReadScannerImageData (ps, ps->DataInf.pCurrentBuffer +
1031 ps->DataInf.dwAsicBytesPerPlane * 2,
1032 ps->DataInf.dwAsicBytesPerPlane);
1037 if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle) {
1039 memcpy( ps->DataInf.pCurrentBuffer +
1040 ps->DataInf.dwAsicBytesPerPlane * 2,
1041 ps->pGetBufR, ps->DataInf.dwAsicBytesPerPlane);
1044 memcpy( ps->DataInf.pCurrentBuffer,
1045 ps->pGetBufR, ps->DataInf.dwAsicBytesPerPlane );
1048 if (ps->b2ndColor & ps->GreenDataReady) {
1050 memcpy( ps->DataInf.pCurrentBuffer +
1051 ps->DataInf.dwAsicBytesPerPlane,
1052 ps->pGetBufG, ps->DataInf.dwAsicBytesPerPlane);
1055 if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle) {
1057 memcpy( ps->DataInf.pCurrentBuffer,
1058 ps->pGetBufG,
1059 ps->DataInf.dwAsicBytesPerPlane);
1062 memcpy( ps->DataInf.pCurrentBuffer +
1063 ps->DataInf.dwAsicBytesPerPlane * 2,
1064 ps->pGetBufG,
1065 ps->DataInf.dwAsicBytesPerPlane );
1070 ps->pGetBufR += ps->BufferSizePerModel;
1071 ps->pGetBufG += ps->BufferSizePerModel;
1072 if (ps->pGetBufR == ps->pEndBufR)
1073 ps->pGetBufR = ps->pPrescan16;
1075 if (ps->pGetBufG == ps->pEndBufG)
1076 ps->pGetBufG = ps->pPrescan8;
1087 *ps->pCurrentColorRunTable &= 0xf0; /* leave high nibble for debug */
1088 ps->pCurrentColorRunTable++; /* this step has been processed */
1089 IOReadScannerImageData( ps, ps->DataInf.pCurrentBuffer,
1090 ps->DataInf.dwAsicBytesPerPlane );
1098 if( ps->bMoveDataOutFlag != _DataFromStopState )
1099 ps->UpdateDataCurrentReadLine( ps );
1104 (*ps->Scan.DataProcess)( ps, ps->Scan.bp.pMonoBuf,
1105 ps->DataInf.pCurrentBuffer,
1106 ps->DataInf.dwAppPhyBytesPerLine );
1111 MotorToHomePosition(ps);
1118 static int imageP96SetupScanSettings( pScanData ps, pScanInfo pInf )
1122 ps->DataInf.dwVxdFlag = 0;
1124 ps->DataInf.dwVxdFlag |= _VF_BUILDMAP;
1126 ps->DataInf.dwScanFlag = pInf->ImgDef.dwFlag;
1128 ps->DataInf.crImage = pInf->ImgDef.crArea;
1131 ps->DataInf.crImage.x *= ps->PhysicalDpi / _MEASURE_BASE;
1132 ps->DataInf.crImage.cx *= ps->PhysicalDpi / _MEASURE_BASE;
1134 if( ps->DataInf.dwScanFlag & SCANDEF_TPA ) {
1135 ps->DataInf.crImage.x += _Transparency48OriginOffsetX;
1136 ps->DataInf.crImage.y += _Transparency48OriginOffsetY;
1139 ps->DataInf.xyAppDpi = pInf->ImgDef.xyDpi;
1140 ps->DataInf.wAppDataType = pInf->ImgDef.wDataType;
1141 ps->DataInf.wDither = pInf->wDither;
1143 ps->GetImageInfo( ps, &pInf->ImgDef );
1146 if (ps->DataInf.wPhyDataType != COLOR_BW) { /* if not line art */
1147 ps->wBrightness = pInf->siBrightness; /* use internal tables for */
1148 ps->wContrast = pInf->siContrast; /* brightness and contrast */
1152 ps->DataInf.siBrightness = pInf->siBrightness;
1154 if (ps->DataInf.dwScanFlag & SCANDEF_BmpStyle)
1155 ps->Scan.lBufferAdjust = -(Long)ps->DataInf.dwAppBytesPerLine;
1157 ps->Scan.lBufferAdjust = (Long)ps->DataInf.dwAppBytesPerLine;
1159 if (ps->DataInf.siBrightness < 0)
1160 ps->DataInf.siBrightness = 255 - (_DEF_BW_THRESHOLD *
1161 ps->DataInf.siBrightness / 127 + _DEF_BW_THRESHOLD);
1163 ps->DataInf.siBrightness = 255 - ((255 - _DEF_BW_THRESHOLD) *
1164 ps->DataInf.siBrightness / 127 + _DEF_BW_THRESHOLD);
1166 ps->AsicReg.RD_ThresholdControl = (Byte)ps->DataInf.siBrightness;
1168 ps->DataInf.pCurrentBuffer = ps->pScanBuffer1;
1175 static Bool imageP98003DataIsReady( pScanData ps )
1179 if( ps->Scan.bDiscardAll ) {
1180 ps->Scan.bDiscardAll--;
1182 if( ps->DataInf.wPhyDataType <= COLOR_256GRAY ) {
1183 ps->AsicReg.RD_ModeControl = _ModeFifoGSel;
1184 IOReadScannerImageData( ps, ps->Bufs.b1.pReadBuf,
1185 ps->DataInf.dwAsicBytesPerPlane );
1187 IOReadColorData( ps, ps->Bufs.b1.pReadBuf,
1188 ps->DataInf.dwAsicBytesPerPlane );
1193 if( ps->DataInf.wPhyDataType <= COLOR_256GRAY ) {
1195 ps->AsicReg.RD_ModeControl = _ModeFifoGSel;
1196 pb = ps->Scan.bp.pMonoBuf;
1199 if( ps->DataInf.wAppDataType == COLOR_HALFTONE )
1200 pb = ps->Scan.BufPut.red.bp;
1202 IOReadScannerImageData( ps, pb, ps->DataInf.dwAsicBytesPerPlane );
1205 if( !ps->Scan.DataRead( ps )) {
1210 if( ps->Scan.DoSample( ps )) {
1212 if( ps->Scan.dwLinesToRead == 1 &&
1213 !(IOGetScanState( ps, _TRUE ) & _SCANSTATE_STOP))
1214 IORegisterToScanner( ps, ps->RegRefreshScanState );
1217 if( fnDataDirect != ps->Scan.DataProcess ) {
1218 (*ps->Scan.DataProcess)(ps, (pVoid)(ps->Scan.bp.pMonoBuf ),
1219 (pVoid)(ps->Scan.BufPut.red.bp),
1220 ps->DataInf.dwAppPhyBytesPerLine);
1230 static Bool imageP98003ReadOneImageLine( pScanData ps )
1239 state = IOGetScanState( ps, _TRUE );
1240 ps->Scan.bNowScanState = (state & _SCANSTATE_MASK);
1244 MotorP98003ModuleForwardBackward( ps );
1246 if( IOReadFifoLength( ps ) >= ps->Scan.dwMinReadFifo )
1247 if( imageP98003DataIsReady( ps ))
1251 ps->Scan.bModuleState = _MotorInNormalState;
1252 b = ps->Scan.bNowScanState - ps->Scan.bOldScanState;
1257 if( b >= ps->Scan.bRefresh ) {
1258 IORegisterToScanner( ps, ps->RegRefreshScanState );
1260 ps->Scan.bOldScanState = IOGetScanState( ps, _TRUE );
1261 ps->Scan.bOldScanState &= _SCANSTATE_MASK;
1264 if( IOReadFifoLength( ps ) >= ps->Scan.dwMaxReadFifo ) {
1265 if( imageP98003DataIsReady( ps ))
1269 b = ps->Scan.bNowScanState - ps->Scan.bOldScanState;
1274 if( b >= ps->Scan.bRefresh ) {
1275 IORegisterToScanner( ps, ps->RegRefreshScanState );
1277 ps->Scan.bOldScanState = IOGetScanState( ps, _TRUE );
1278 ps->Scan.bOldScanState &= _SCANSTATE_MASK;
1281 if( IOReadFifoLength( ps ) >= ps->Scan.dwMinReadFifo ) {
1282 if( imageP98003DataIsReady( ps ))
1293 MotorToHomePosition(ps);
1301 static void imageP98003SetupScanStateVariables( pScanData ps, ULong index )
1305 ps->Scan.dpiIdx = index;
1307 if(!(ps->DataInf.dwScanFlag & SCANDEF_TPA)) {
1309 if(((ps->IO.portMode == _PORT_BIDI) ||
1310 (ps->IO.portMode == _PORT_SPP)) &&
1311 (ps->DataInf.wPhyDataType > COLOR_TRUE24) &&
1312 (ps->DataInf.xyAppDpi.y >= 600)) {
1314 ps->Shade.wExposure = nmlScan[ps->IO.portMode][index].exposureTime;
1315 ps->Shade.wXStep = nmlScan[ps->IO.portMode][index].xStepTime;
1317 ps->Shade.wExposure = nmlScan[_PORT_EPP][index].exposureTime;
1318 ps->Shade.wXStep = nmlScan[_PORT_EPP][index].xStepTime;
1321 if( ps->Shade.bIntermediate & _ScanMode_AverageOut ) {
1322 ps->Shade.wExposure >>= 1;
1323 ps->Shade.wXStep >>= 1;
1326 if( ps->DataInf.dwScanFlag & SCANDEF_Transparency ) {
1327 ps->Shade.wExposure = posScan[index].exposureTime;
1328 ps->Shade.wXStep = posScan[index].xStepTime;
1330 ps->Shade.wExposure = ps->Scan.negScan[index].exposureTime;
1331 ps->Shade.wXStep = ps->Scan.negScan[index].xStepTime;
1335 ps->Scan.dwInterlace = 0;
1336 ps->Scan.dwInterval = 1;
1338 if( ps->DataInf.wPhyDataType == COLOR_BW )
1339 var.dwValue = xferSpeed[ps->IO.portMode].thresholdBW;
1341 if( ps->DataInf.wPhyDataType == COLOR_256GRAY )
1342 var.dwValue = xferSpeed[ps->IO.portMode].thresholdGray;
1344 var.dwValue = xferSpeed[ps->IO.portMode].thresholdColor;
1348 if((ps->DataInf.xyAppDpi.y >= 300) && var.dwValue &&
1349 (ps->DataInf.dwAsicBytesPerPlane <= var.dwValue)) {
1350 ps->Scan.dwInterval <<= 1;
1353 if( var.dwValue && ps->DataInf.dwAsicBytesPerPlane > var.dwValue ) {
1354 if((var.dwValue << 1) > ps->DataInf.dwAsicBytesPerPlane)
1355 ps->Scan.dwInterval <<= 1;
1357 if((var.dwValue << 2) > ps->DataInf.dwAsicBytesPerPlane)
1358 ps->Scan.dwInterval <<= 2;
1360 ps->Scan.dwInterval <<= 3;
1364 if(((ps->IO.portMode == _PORT_BIDI) ||
1365 (ps->IO.portMode == _PORT_SPP)) &&
1366 (ps->DataInf.wPhyDataType > COLOR_TRUE24) &&
1367 (ps->DataInf.xyAppDpi.y >= 600)) {
1368 ps->Scan.dwInterval <<= 1;
1371 if( ps->DataInf.wPhyDataType >= COLOR_TRUE24 ) {
1373 if( ps->DataInf.xyPhyDpi.y > 75U ) {
1374 if( ps->Device.f0_8_16 ) {
1375 ps->Scan.gd_gk.wGreenDiscard = ps->DataInf.xyPhyDpi.y / 75U;
1377 ps->Scan.gd_gk.wGreenDiscard = ps->DataInf.xyPhyDpi.y / 150U;
1380 ps->Scan.gd_gk.wGreenDiscard = 1;
1383 ps->Scan.bd_rk.wBlueDiscard = ps->Scan.gd_gk.wGreenDiscard << 1;
1385 ps->Scan.bd_rk.wBlueDiscard = ps->Scan.gd_gk.wGreenDiscard = 0;
1391 static int imageP98003SetupScanSettings( pScanData ps, pScanInfo pInf )
1396 imageP98SetupScanSettings( ps, pInf );
1398 if( !(ps->DataInf.dwScanFlag & SCANDEF_TPA )) {
1400 ps->Scan.dwScanOrigin = ps->Device.lUpNormal * 4 + _RFT_SCANNING_ORG;
1402 } else if( ps->DataInf.dwScanFlag & SCANDEF_Transparency) {
1404 ps->Scan.dwScanOrigin = ps->Device.lUpPositive * 4 +
1407 ps->Scan.dwScanOrigin = ps->Device.lUpNegative * 4 +
1410 ps->Scan.dwScanOrigin += ps->Device.dwModelOriginY;
1413 if( ps->DataInf.xyAppDpi.y <= 75 ) {
1415 if( ps->DataInf.dwVxdFlag & _VF_PREVIEW ) {
1417 ps->Scan.bDiscardAll = 0;
1418 ps->DataInf.xyPhyDpi.y = 150;
1419 ps->Shade.bIntermediate |= _ScanMode_AverageOut;
1420 imageP98003SetupScanStateVariables( ps, 1 );
1421 ps->Scan.gd_gk.wGreenDiscard = 0;
1423 if( ps->DataInf.xyAppDpi.y >= 38 )
1424 ps->Scan.bd_rk.wBlueDiscard = 1;
1426 ps->Scan.bd_rk.wBlueDiscard = 0;
1428 if( ps->DataInf.wPhyDataType >= COLOR_256GRAY ) {
1429 ps->Shade.wXStep = 6;
1430 ps->Shade.wExposure = 8 * ps->Shade.wXStep;
1433 if(!(ps->DataInf.dwScanFlag & SCANDEF_TPA) &&
1434 (ps->DataInf.xyAppDpi.y <= 50) &&
1435 (ps->DataInf.wPhyDataType >= COLOR_TRUE24)) {
1436 ps->Shade.bIntermediate |= _ScanMode_AverageOut;
1439 if((ps->DataInf.wPhyDataType<COLOR_TRUE24) || ps->Device.f0_8_16 ||
1440 (ps->Shade.bIntermediate & _ScanMode_AverageOut)) {
1442 ps->Scan.bDiscardAll = 1;
1443 ps->DataInf.xyPhyDpi.y = 75;
1444 imageP98003SetupScanStateVariables( ps, 0 );
1446 ps->Scan.bDiscardAll = 2;
1447 ps->DataInf.xyPhyDpi.y = 150;
1448 imageP98003SetupScanStateVariables( ps, 1 );
1452 if( ps->DataInf.xyAppDpi.y <= 150 ) {
1454 ps->Scan.bDiscardAll = 2;
1455 ps->DataInf.xyPhyDpi.y = 150;
1456 imageP98003SetupScanStateVariables( ps, 1 );
1458 } else if( ps->DataInf.xyAppDpi.y <= 300 ) {
1460 ps->Scan.bDiscardAll = 4;
1461 ps->DataInf.xyPhyDpi.y = 300;
1462 imageP98003SetupScanStateVariables( ps, 2 );
1464 } else if( ps->DataInf.xyAppDpi.y <= 600 ) {
1466 ps->Scan.bDiscardAll = 8;
1467 ps->DataInf.xyPhyDpi.y = 600;
1468 imageP98003SetupScanStateVariables( ps, 3 );
1472 ps->Scan.bDiscardAll = 16;
1473 ps->DataInf.xyPhyDpi.y = 1200;
1474 imageP98003SetupScanStateVariables( ps, 4 );
1479 if( ps->DataInf.xyAppDpi.y == ps->DataInf.xyPhyDpi.y ) {
1481 ps->Scan.DoSample = fnEveryLines;
1483 if( ps->DataInf.dwVxdFlag & _VF_PREVIEW ) {
1486 ps->Scan.DoSample = fnSamplePreview;
1487 ps->DataInf.wYSum = 150;
1489 if( ps->DataInf.xyAppDpi.y >= 38 )
1490 wPreviewScanned = ps->DataInf.xyAppDpi.y * 2;
1491 else if( ps->DataInf.xyAppDpi.y >= 19 )
1492 wPreviewScanned = ps->DataInf.xyAppDpi.y * 4;
1494 wPreviewScanned = ps->DataInf.xyAppDpi.y * 8;
1498 ps->DataInf.xyPhyDpi.y, ps->DataInf.xyAppDpi.y );
1499 ps->Scan.DoSample = fnSampleLines;
1500 ps->DataInf.wYSum = ps->DataInf.xyPhyDpi.y - ps->DataInf.xyAppDpi.y;
1507 ps->Scan.p48BitBuf.pb = NULL;
1509 if( ps->DataInf.wPhyDataType >= COLOR_TRUE24 ) {
1514 ps->DataInf.dwAsicBytesPerPlane - ps->Scan.bd_rk.wRedKeep;
1516 ps->DataInf.dwAsicBytesPerPlane - ps->Scan.gd_gk.wGreenKeep;
1520 b = (ULong)(ps->Scan.bd_rk.wRedKeep +
1521 ps->Scan.gd_gk.wGreenKeep + 2U) *
1522 ps->DataInf.dwAsicBytesPerPlane;
1525 b, ps->TotalBufferRequire );
1527 if( b > ps->TotalBufferRequire )
1530 ps->Scan.p48BitBuf.pb = ps->Bufs.b1.pReadBuf;
1534 if( ps->Scan.p48BitBuf.pb ){
1535 ps->Scan.DataRead = fnReadToDriver;
1536 ps->Scan.BufGet.red.bp =
1537 ps->Scan.BufPut.red.bp =
1538 ps->Scan.BufBegin.red.bp = ps->Scan.p48BitBuf.pb;
1539 ps->Scan.BufEnd.red.bp =
1540 ps->Scan.BufBegin.green.bp =
1541 ps->Scan.BufGet.green.bp =
1542 ps->Scan.BufPut.green.bp = ps->Scan.p48BitBuf.pb +
1543 ps->DataInf.dwAsicBytesPerLine *
1544 (ps->Scan.bd_rk.wRedKeep + 1U);
1546 ps->Scan.BufEnd.green.bp = ps->Scan.BufBegin.green.bp +
1547 ps->DataInf.dwAsicBytesPerLine *
1548 (ps->Scan.gd_gk.wGreenKeep + 1U);
1549 ps->Scan.BufPut.blue.bp =
1550 ps->Scan.BufGet.blue.bp = ps->Bufs.b1.pReadBuf +
1551 ps->DataInf.dwAsicBytesPerLine * 2;
1553 ps->Scan.DataRead = fnReadOutScanner;
1554 ps->Scan.BufPut.red.bp = ps->Bufs.b1.pReadBuf;
1555 ps->Scan.BufData.green.bp =
1556 ps->Scan.BufPut.green.bp = ps->Scan.BufPut.red.bp +
1557 ps->DataInf.dwAsicBytesPerLine;
1558 ps->Scan.BufPut.blue.bp = ps->Scan.BufPut.green.bp +
1559 ps->DataInf.dwAsicBytesPerLine;
1561 if( ps->DataInf.dwScanFlag & SCANDEF_ColorBGROrder ) {
1562 ps->Scan.BufData.red.bp = ps->Scan.BufPut.blue.bp;
1563 ps->Scan.BufData.blue.bp = ps->Scan.BufPut.red.bp;
1565 ps->Scan.BufData.red.bp = ps->Scan.BufPut.red.bp;
1566 ps->Scan.BufData.blue.bp = ps->Scan.BufPut.blue.bp;
1571 if( ps->DataInf.dwScanFlag & SCANDEF_Transparency) {
1582 ps->Shade.wExposure = posScan[ps->Scan.dpiIdx].exposureTime;
1583 ps->Shade.wXStep = posScan[ps->Scan.dpiIdx].xStepTime;
1585 else if( ps->DataInf.dwScanFlag & SCANDEF_Negative) {
1586 ps->Scan.negScan[1].exposureTime = 96;
1587 ps->Scan.negScan[1].xStepTime = 12;
1588 ps->Scan.negScan[2].exposureTime = 96;
1589 ps->Scan.negScan[2].xStepTime = 24;
1590 ps->Scan.negScan[3].exposureTime = 96;
1591 ps->Scan.negScan[3].xStepTime = 48;
1592 ps->Scan.negScan[4].exposureTime = 96;
1593 ps->Scan.negScan[4].xStepTime = 96;
1596 ps->Shade.wExposure = ps->Scan.negScan[ps->Scan.dpiIdx].exposureTime;
1597 ps->Shade.wXStep = ps->Scan.negScan[ps->Scan.dpiIdx].xStepTime;
1607 _LOC int ImageInitialize( pScanData ps )
1611 if( NULL == ps )
1614 ps->Scan.dpiIdx = 0;
1615 ps->Scan.negScan = negScan;
1620 if( _ASIC_IS_98001 == ps->sCaps.AsicID ) {
1622 ps->GetImageInfo = imageP98GetInfo;
1623 ps->SetupScanSettings = imageP98SetupScanSettings;
1624 ps->ReadOneImageLine = imageP98001ReadOneImageLine;
1626 } else if( _ASIC_IS_98003 == ps->sCaps.AsicID ) {
1628 ps->GetImageInfo = imageP98GetInfo;
1629 ps->SetupScanSettings = imageP98003SetupScanSettings;
1630 ps->ReadOneImageLine = imageP98003ReadOneImageLine;
1632 } else if( _IS_ASIC96(ps->sCaps.AsicID)) {
1634 ps->GetImageInfo = imageP96GetInfo;
1635 ps->SetupScanSettings = imageP96SetupScanSettings;
1636 ps->ReadOneImageLine = imageP96ReadOneImageLine;