1 /* @file plustek-pp_scandata.h 2 * @brief here we define the ScanData structure... 3 * and a lot of register settings 4 * 5 * based on sources acquired from Plustek Inc. 6 * Copyright (C) 1998 Plustek Inc. 7 * Copyright (C) 2000-2013 Gerhard Jaeger <gerhard@gjaeger.de> 8 * also based on the work done by Rick Bronson <rick@efn.org> 9 *............................................................................. 10 * History: 11 * 0.30 - initial version 12 * 0.31 - no changes 13 * 0.32 - added fWarmupNeeded to struct ScanData 14 * - removed function FillDataToColorTable from struct ScanData 15 * - removed dwLampDelay from struct ScanData 16 * 0.33 - cosmetic changes 17 * - removed PositionLamp from structure 18 * - added dwLastPortMode to struct ScanData 19 * 0.34 - removed WaitBack() function from pScanData structure 20 * - removed wStayMaxStep from pScanData structure 21 * 0.35 - removed SetInitialGainRAM from pScanData structure 22 * - changed ModelStr list 23 * 0.36 - added some defines for the ASIC 96001 (model 4800) 24 * - added wDither to DataInfo structure 25 * - removed dwPreferSize from struct ScannerCaps 26 * - cleanup 27 * - moved all stuff that is used by the backend and the driver 28 * to plustek-share.h which is in the backend directory 29 * - added ModelOverride parameter to struct 30 * - added strcut pardevice to struct 31 * 0.37 - added bIODelay for SPP/BIDI port operations 32 * - added ReadData to struct 33 * - added ProcDirDef 34 * - added ButtonCount 35 * - removed RegisterToScanner from struct 36 * - removed MaxDpiByInterpolation from struct 37 * 0.38 - added function PutToIdleMode() to struct 38 * - added function Calibration() to struct 39 * - changed interface of the ReInitAsic() function 40 * - major changes: moved a lot of stuff to hwdefs.h 41 * - added IO, Device, Shade, Scan and Bufs to struct 42 * 0.39 - added forceMode to struct 43 * - added f97003, b97003DarkR, b97003DarkB, b97003DarkG to struct 44 * 0.40 - no changes 45 * 0.41 - no changes 46 * 0.42 - no changes 47 * 0.43 - changed type of XYRatio from double to long 48 * - cleanup 49 * 0.44 - changes as Long defaults now to int32_t 50 * . 51 * <hr> 52 * This file is part of the SANE package. 53 * 54 * This program is free software; you can redistribute it and/or 55 * modify it under the terms of the GNU General Public License as 56 * published by the Free Software Foundation; either version 2 of the 57 * License, or (at your option) any later version. 58 * 59 * This program is distributed in the hope that it will be useful, but 60 * WITHOUT ANY WARRANTY; without even the implied warranty of 61 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 62 * General Public License for more details. 63 * 64 * You should have received a copy of the GNU General Public License 65 * along with this program. If not, see <https://www.gnu.org/licenses/>. 66 * 67 * As a special exception, the authors of SANE give permission for 68 * additional uses of the libraries contained in this release of SANE. 69 * 70 * The exception is that, if you link a SANE library with other files 71 * to produce an executable, this does not by itself cause the 72 * resulting executable to be covered by the GNU General Public 73 * License. Your use of that executable is in no way restricted on 74 * account of linking the SANE library code into it. 75 * 76 * This exception does not, however, invalidate any other reasons why 77 * the executable file might be covered by the GNU General Public 78 * License. 79 * 80 * If you submit changes to SANE to the maintainers to be included in 81 * a subsequent release, you agree by submitting the changes that 82 * those changes may be distributed with this exception intact. 83 * 84 * If you write modifications of your own for SANE, it is your choice 85 * whether to permit this exception to apply to your modifications. 86 * If you do not wish that, delete this exception notice. 87 * <hr> 88 */ 89 #ifndef __SCANDATA_H__ 90 #define __SCANDATA_H__ 91 92 /* 93 *Directory information for the /proc interface 94 */ 95 typedef struct { 96 struct proc_dir_entry *entry; /* Directory /proc/pt_drv/X */ 97 struct proc_dir_entry *info; /* .../info */ 98 struct proc_dir_entry *buttons[_MAX_BTNS]; /* .../buttons */ 99 } ProcDirDef, *pProcDirDef; 100 101 /* 102 * here we have some structs internally used 103 */ 104 typedef struct { 105 ULong dwVxdFlag; 106 ULong dwScanFlag; 107 108 /* 109 * CHECK: why there are dups ? 110 */ 111 ULong dwAppLinesPerArea; 112 ULong dwAppPixelsPerLine; 113 ULong dwAppPhyBytesPerLine; 114 ULong dwAppBytesPerLine; 115 ULong dwAsicPixelsPerPlane; 116 ULong dwAsicBytesPerPlane; 117 ULong dwAsicBytesPerLine; 118 CropRect crImage; 119 XY xyAppDpi; 120 XY xyPhyDpi; 121 pUChar pCurrentBuffer; 122 UShort wPhyDataType; 123 UShort wAppDataType; 124 UShort wYSum; 125 126 short siBrightness; 127 128 /* CHANGE added these vars for scaling 129 */ 130 Long XYRatio; 131 ULong dwPhysBytesPerLine; 132 133 /* 134 * CHANGE added this for selecting dither method 135 */ 136 UShort wDither; 137 138 } DataInfo, *pDataInfo; 139 140 141 /* 142 * here it is, the great structure 143 */ 144 typedef struct scandata 145 { 146 int pardev; /* parport handle in user-space */ 147 148 /* 149 * device control 150 */ 151 ULong devno; 152 int lampoff; 153 int warmup; 154 int lOffonEnd; 155 156 /* 157 * CHECK for controlling the ECP-mode (not used now) 158 */ 159 #if 0 160 Byte bOldECR; 161 Bool fECPReadWriteTest; 162 Bool fSkipEcpFlag; 163 Bool fECPFlag; 164 Bool fECPtoEPP; 165 Bool fECRFIFO; 166 #endif 167 168 /* 169 * the following stuff gets changed on a per model basis 170 */ 171 UShort ModelOverride; /* for non-auto detection stuff */ 172 173 UShort Offset70; /* CHECK: --> to Device */ 174 UShort BufferSizeBase; /* --> to Device */ 175 UShort BufferSizePerModel; /* --> to Device */ 176 UShort TimePerLine; /* --> to Device */ 177 178 /* 179 * scanner properties 180 */ 181 RegData AsicReg; /* here we have the 98001/3 register set */ 182 Reg96 Asic96Reg; /* here we hold the 96001/3 specific regs */ 183 184 LensInfo LensInf; 185 ScannerCaps sCaps; 186 ULong dwScannerSize; 187 Byte bCurrentSpeed; 188 pUChar pbMapRed; 189 pUChar pbMapGreen; 190 pUChar pbMapBlue; 191 192 ULong TotalBufferRequire; 193 ULong BufferForColorRunTable; 194 UShort PhysicalDpi; 195 UShort RdPix; /* for ASIC 96003 devices */ 196 197 Byte a_bMapTable[4096 * 3]; /* pre 98001 was 256 * 3 */ 198 Byte a_nbNewAdrPointer[_SCANSTATE_BYTES]; 199 200 /* 201 * for P9600x ASIC based scanners 202 */ 203 Bool fColorMoreRedFlag; 204 Bool fColorMoreBlueFlag; 205 Bool fSonyCCD; 206 Bool f97003; 207 Byte AsicRedColor; 208 Byte AsicGreenColor; 209 Byte RedDataReady; 210 Byte GreenDataReady; 211 Byte b1stColorByte; 212 Byte b1stColor; 213 Byte b1stMask; 214 Byte b2ndColorByte; 215 Byte b2ndColor; 216 Byte b2ndMask; 217 Byte b3rdColorByte; 218 Byte b3rdColor; 219 Byte b3rdMask; 220 Byte b1stLinesOffset; 221 Byte b2ndLinesOffset; 222 Byte bLampOn; 223 Byte bExtraAdd; 224 Byte bFifoCount; 225 Byte bMinReadFifo; 226 Byte FullStep; 227 Byte StepMask; 228 Byte MotorOn; 229 Byte MotorFreeRun; 230 Byte IgnorePF; 231 Byte bMotorStepTableNo; 232 233 /* for ASIC 97003... */ 234 Byte b97003DarkR; 235 Byte b97003DarkG; 236 Byte b97003DarkB; 237 238 /* CHECK: to Scan!!!! */ 239 pUChar pGetBufR; /* NOTE: these aren't actually Red/Green buffer */ 240 pUChar pGetBufG; /* pointers but instead are used */ 241 pUChar pPutBufR; /* generically to point to the first 2 */ 242 pUChar pPutBufG; /* color buffers as temp storage */ 243 244 pUChar pCurrentColorRunTable; 245 UShort a_wGrayInitTime[3]; 246 UShort a_wColorInitTime[3]; 247 UShort BackwardSteps; 248 UShort wLinesPer64kTime; 249 UShort ShadingBufferSize; 250 UShort ShadingBankSize; 251 UShort ShadingBankRed; 252 UShort ShadingBankGreen; 253 UShort ShadingBankBlue; 254 UShort ShadingScanLineBlks; 255 UShort ShadingScanLineLen; 256 UShort wOverBlue; 257 UShort FBKScanLineBlks; 258 UShort FBKScanLineLenBase; 259 UShort FBKScanLineLen; 260 UShort OneScanLineLen; 261 262 /* 263 * the DAC part - to Shade !!! 264 */ 265 UShort wsDACCompareHighRed, wsDACCompareLowRed; 266 UShort wsDACCompareHighGreen, wsDACCompareLowGreen; 267 UShort wsDACCompareHighBlue, wsDACCompareLowBlue; 268 UShort wsDACOffsetRed, wsDACOffsetGreen, wsDACOffsetBlue; 269 Byte bsPreRedDAC, bsPreGreenDAC, bsPreBlueDAC; 270 Byte bRedDAC, bGreenDAC, bBlueDAC; 271 Byte bRedGainIndex, bGreenGainIndex, bBlueGainIndex; 272 273 /* 274 * for image description 275 */ 276 DataInfo DataInf; 277 Bool fReshaded; 278 ULong dwDitherIndex; 279 Bool fDoFilter, fFilterFirstLine; 280 ULong dwDivFilter; 281 ULong dwMul; 282 Byte bOffsetFilter; 283 ULong dwLinesFilter; 284 pUChar pFilterBuf, pEndBuf; 285 pUChar pGet1, pGet2, pGet3; 286 287 Byte bSetScanModeFlag; /* see Section 5 - Scanmodes --> ps->Shade.bIntermediate*/ 288 289 /* 290 * some admin vals (they used to be global vars in the original driver) 291 */ 292 Bool fScanningStatus; 293 Byte bLastLampStatus; 294 Bool fWarmupNeeded; 295 ULong dwOffset70; 296 ULong dwMaxReadFifoData; 297 298 /* 299 * 300 */ 301 pUChar pColorRunTable; 302 pUChar pPrescan16; 303 pUChar pPrescan8; 304 UShort BufferForDataRead1; 305 ULong BufferFor1stColor; 306 ULong BufferFor2ndColor; 307 pUChar driverbuf; 308 pUChar pEndBufR; 309 pUChar pEndBufG; 310 pUChar pProcessingBuf; 311 312 /* 313 * formerly used as global vars in ioproc.c, now in genericio.c 314 */ 315 pUChar pScanBuffer1; 316 pUChar pScanBuffer2; 317 318 pModeTypeVar lpEppColorHomePos; 319 pModeTypeVar lpEppColorExposure; 320 pModeTypeVar lpBppColorHomePos; 321 pModeTypeVar lpSppColorHomePos; 322 UShort wMinCmpDpi; 323 pModeTypeVar a_ColorSettings; 324 pDiffModeVar a_tabDiffParam; 325 326 Byte bSpeed48; 327 Byte bSpeed32; 328 Byte bSpeed24; 329 Byte bSpeed16; 330 Byte bSpeed12; 331 Byte bSpeed8; 332 Byte bSpeed6; 333 Byte bSpeed4; 334 Byte bSpeed3; 335 Byte bSpeed2; 336 Byte bSpeed1; 337 338 Byte bHpMotor; 339 Byte bStepSpeed; 340 ULong dwFullStateSpeed; 341 342 /* 343 * reference to globals from motor.c 344 */ 345 Bool fHalfStepTableFlag; 346 Bool fFullLength; 347 Byte bMoveDataOutFlag; 348 Byte bExtraMotorCtrl; 349 Byte bFastMoveFlag; 350 Byte bOldStateCount; 351 Byte bMotorSpeedData; 352 Byte bCurrentLineCount; 353 Byte bNewGap; 354 Byte bNewCurrentLineCountGap; 355 UShort wMaxMoveStep; 356 ULong dwScanStateCount; 357 ULong dwColorRunIndex; 358 pByte a_bColorByteTable; 359 pUChar pScanState; 360 pUShort a_wMoveStepTable; 361 362 /* 363 * for shading - dac.c 364 * CHECK: move to ps->Shade 365 */ 366 Byte bShadingTimeFlag; 367 ULong dwShadow, dwShadowCh; 368 ULong dwHilight, dwHilightCh; 369 ULong dwShadingLen, dwShadingPixels; 370 pUShort pwShadow; 371 372 /* 373 * from transform.c 374 */ 375 Byte bRedHigh, bGreenHigh, bBlueHigh; 376 UShort wPosAdjustX; 377 UShort wNegAdjustX; 378 UShort wReduceRedFactor; 379 UShort wReduceGreenFactor; 380 UShort wReduceBlueFactor; 381 ULong dwOffsetNegative; 382 383 /* 384 * reference to globals from map.c 385 */ 386 #define _DITHERSIZE 64 387 Byte a_bDitherPattern[_DITHERSIZE]; 388 Short wBrightness; 389 Short wContrast; 390 UShort wInitialStep; 391 ULong dwSizeMustProcess; 392 393 /* 394 * here we have pointers to the functions to call 395 */ 396 Bool (*OpenScanPath) (pScanData); 397 void (*CloseScanPath) (pScanData); 398 int (*ReadWriteTest) (pScanData); 399 void (*PutToIdleMode) (pScanData); 400 int (*Calibration) (pScanData); 401 void (*SetupScannerVariables) (pScanData); 402 int (*SetupScanSettings) (pScanData, pScanInfo pInf ); 403 void (*GetImageInfo) (pScanData, pImgDef pInf ); 404 Bool (*WaitForShading) (pScanData); 405 void (*WaitForPositionY) (pScanData); 406 void (*InitialSetCurrentSpeed) (pScanData); 407 Bool (*GotoShadingPosition) (pScanData); 408 void (*SetupScanningCondition) (pScanData); 409 void (*SetMotorSpeed) (pScanData,Byte bSpeed,Bool fSetRunState); 410 void (*FillRunNewAdrPointer) (pScanData); 411 void (*SetupMotorRunTable) (pScanData); 412 void (*PauseColorMotorRunStates) (pScanData); 413 void (*UpdateDataCurrentReadLine)(pScanData); 414 Bool (*ReadOneImageLine) (pScanData); 415 416 /* used only by ASIC9800x Part of the driver ! */ 417 void (*ReInitAsic) (pScanData, Bool shading); 418 419 /* value used to read nibble's */ 420 Byte CtrlReadHighNibble; 421 Byte CtrlReadLowNibble; 422 423 /* 424 * asic register offset values 425 */ 426 Byte RegSwitchBus; 427 Byte RegEPPEnable; 428 Byte RegECPEnable; 429 Byte RegReadDataMode; 430 Byte RegWriteDataMode; 431 Byte RegInitDataFifo; 432 Byte RegForceStep; 433 Byte RegInitScanState; 434 Byte RegRefreshScanState; 435 Byte RegThresholdGapControl; 436 Byte RegADCAddress; 437 Byte RegADCData; 438 Byte RegADCPixelOffset; 439 Byte RegADCSerialOutStr; 440 Byte RegResetConfig; 441 Byte RegLensPosition; 442 Byte RegStatus; 443 Byte RegWaitStateInsert; 444 Byte RegFifoOffset; 445 Byte RegRFifoOffset; 446 Byte RegGFifoOffset; 447 Byte RegBFifoOffset; 448 Byte RegBitDepth; 449 Byte RegStepControl; 450 Byte RegMotor0Control; 451 Byte RegXStepTime; 452 Byte RegGetScanState; 453 Byte RegAsicID; 454 Byte RegReadIOBufBus; 455 Byte RegMemoryLow; 456 Byte RegMemoryHigh; 457 Byte RegModeControl; 458 Byte RegLineControl; 459 Byte RegScanControl; 460 Byte RegMotorControl; 461 #define _MotorDirForward 0x01 /* go forward */ 462 #define _MotorOn 0x02 /* turn on motor */ 463 #define _MotorIgnorePF 0x04 /* motor rolling don't care */ 464 /* paper define flag */ 465 #define _MotorFreeRun 0x80 /*ScanState count don't stop */ 466 /* Following bits (bit 3 & 4 are depended on StatusPort */ 467 /* bit-7:MotorType when it is 1: */ 468 #define _Motor1FullStep 0x08 /* bit 4 is ignored */ 469 /* When it is 0: */ 470 #define _Motor0FullStepWeak 0 /* Full step (driving weak) */ 471 #define _Motor0HalfStep 0x10 /* 1/2 step */ 472 #define _Motor0QuarterStep 0x08 /* 1/4 step */ 473 #define _Motor0FullStepStrong 0x18 /* Full step (driving strong)*/ 474 #define _MotorStepMask 0xe7 475 /* for 96001 */ 476 #define _MotorFullStep96001 0x02 477 #define _MotorOn96001 0x04 478 #define _MotorIgnorePF96001 0x08 479 480 Byte RegConfiguration; 481 Byte RegModelControl; 482 Byte RegModel1Control; 483 Byte RegMemAccessControl; 484 #define _MemBanks 64 /* the number of banks, 5 ls bits */ 485 #define _MemBankMask (_MemBanks - 1) 486 #define _MemBankSize1k 0 487 #define _MemBankSize2k 0x40 488 #define _MemBankSize4k 0x80 489 #define _MemBankSize8k 0xc0 490 /* 96001 specific */ 491 #define _MemBankSize2k96001 0x00 492 #define _MemBankSize4k96001 0x40 493 #define _MemBankSize8k96001 0x80 494 495 Byte RegDpiLow; 496 Byte RegDpiHigh; 497 Byte RegScanPosLow; 498 Byte RegScanPosHigh; 499 Byte RegWidthPixelsLow; 500 Byte RegWidthPixelsHigh; 501 Byte RegThresholdLow; 502 Byte RegThresholdHigh; 503 Byte RegThresholdControl; 504 Byte RegWatchDogControl; 505 #define _WDOnIntervalMask 0x0f /* WD * 8192 scan lines to turn 506 off Lamp */ 507 #define _WDMotorLongInterval 0x40 /* short = 8192 lines time 508 long = 32768 lines time */ 509 #define _WDEnable 0x80 510 Byte RegModelControl2; 511 #define _Model2ChannelSlct 0 512 #define _Model2ChannelMult 0x01 /* bit on/off accords to JONES */ 513 #define _Model2CCSInvert 0x02 514 #define _Model2DirectOutPort 0x04 515 #define _Model2PipeLineDelayN 0x08 516 #define _Model2ShiftGapTiming10 0x10 517 #define _Model2BtnKeyPassThrough 0x20 518 Byte RegRedDCAdjust; 519 Byte RegGreenDCAdjust; 520 Byte RegBlueDCAdjust; 521 Byte RegRedChShadingOffset; 522 Byte RegGreenChShadingOffset; 523 Byte RegBlueChShadingOffset; 524 Byte RegRedChDarkOffset; 525 Byte RegGreenChDarkOffset; 526 Byte RegBlueChDarkOffset; 527 Byte RegWriteIOBusDecode1; 528 Byte RegWriteIOBusDecode2; 529 Byte RegScanStateControl; 530 #define _ScanStateEvenMask 0x0f 531 #define _ScanStateOddMask 0xf0 532 Byte RegRedChEvenOffset; 533 Byte RegGreenChEvenOffset; 534 Byte RegBlueChEvenOffset; 535 Byte RegRedChOddOffset; 536 Byte RegGreenChOddOffset; 537 Byte RegBlueChOddOffset; 538 Byte RegRedGainOutDirect; 539 Byte RegGreenGainOutDirect; 540 Byte RegBlueGainOutDirect; 541 Byte RegLedControl; 542 #define _LedCmdActEnable 0x04 543 #define _LedMotorActEnable 0x08 544 #define _LedClrChActEnable 0x10 /* Color Channel Action */ 545 #define _LedLightOnActEnable 0x20 546 #define _LedHostTurnOnEnable 0x40 547 #define _LedActControl 0x80 548 Byte RegShadingCorrectCtrl; 549 #define _ShadingRCorrectX1 0 550 #define _ShadingRCorrectX2 0x01 551 #define _ShadingRCorrectX3 0x02 552 #define _ShadingRCorrectX4 0x03 553 #define _ShadingGCorrectX1 0 554 #define _ShadingGCorrectX2 0x04 555 #define _ShadingGCorrectX3 0x08 556 #define _ShadingGCorrectX4 0x0c 557 #define _ShadingBCorrectX1 0 558 #define _ShadingBCorrectX2 0x10 559 #define _ShadingBCorrectX3 0x20 560 #define _ShadingBCorrectX4 0x30 561 Byte RegScanStateBegin; 562 Byte RegRedChDarkOffsetLow; 563 Byte RegRedChDarkOffsetHigh; 564 Byte RegGreenChDarkOffsetLow; 565 Byte RegGreenChDarkOffsetHigh; 566 Byte RegBlueChDarkOffsetLow; 567 Byte RegBlueChDarkOffsetHigh; 568 Byte RegResetPulse0; 569 Byte RegResetPulse1; 570 Byte RegCCDClampTiming0; 571 Byte RegCCDClampTiming1; 572 Byte RegVSMPTiming0; 573 Byte RegVSMPTiming1; 574 Byte RegCCDQ1Timing0; 575 Byte RegCCDQ1Timing1; 576 Byte RegCCDQ1Timing2; 577 Byte RegCCDQ1Timing3; 578 Byte RegCCDQ2Timing0; 579 Byte RegCCDQ2Timing1; 580 Byte RegCCDQ2Timing2; 581 Byte RegCCDQ2Timing3; 582 Byte RegADCclockTiming0; 583 Byte RegADCclockTiming1; 584 Byte RegADCclockTiming2; 585 Byte RegADCclockTiming3; 586 Byte RegADCDVTiming0; 587 Byte RegADCDVTiming1; 588 Byte RegADCDVTiming2; 589 Byte RegADCDVTiming3; 590 Byte RegScanStateEnd; 591 592 /* ASIC 98003 specific*/ 593 Byte RegFifoFullLength0; 594 Byte RegFifoFullLength1; 595 Byte RegFifoFullLength2; 596 597 Byte RegMotorTotalStep0; 598 Byte RegMotorTotalStep1; 599 Byte RegMotorFreeRunCount0; 600 Byte RegMotorFreeRunCount1; 601 Byte RegScanControl1; 602 Byte RegMotorFreeRunTrigger; 603 604 Byte RegResetMTSC; 605 606 Byte RegMotor1Control; 607 Byte RegMotor2Control; 608 Byte RegMotorDriverType; 609 Byte RegStatus2; 610 Byte RegExtendedLineControl; 611 Byte RegExtendedXStep; 612 613 Byte RegPllPredivider; 614 Byte RegPllMaindivider; 615 Byte RegPllPostdivider; 616 Byte RegClockSelector; 617 Byte RegTestMode; 618 619 /* CHECK: subject to change */ 620 IODef IO; 621 DeviceDef Device; 622 ShadingDef Shade; 623 ScanDef Scan; 624 BufferDef Bufs; 625 626 } ScanData; 627 628 #endif /* guard __SCANDATA_H__ */ 629 630 /* END PLUTSEK-PP_SCANDATA.H ................................................*/ 631