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 #ifdef __KERNEL__ 147 UInt flags; /* as follows: */ 148 #define _PTDRV_INITALIZED 0x00000001 149 #define _PTDRV_OPEN 0x00000002 150 151 struct pardevice *pardev; /* for accessing parport... */ 152 struct parport *pp; 153 ProcDirDef procDir; 154 #else 155 int pardev; /* parport handle in user-space */ 156 #endif 157 158 /* 159 * device control 160 */ 161 ULong devno; 162 int lampoff; 163 int warmup; 164 int lOffonEnd; 165 166 /* 167 * CHECK for controlling the ECP-mode (not used now) 168 */ 169 #if 0 170 Byte bOldECR; 171 Bool fECPReadWriteTest; 172 Bool fSkipEcpFlag; 173 Bool fECPFlag; 174 Bool fECPtoEPP; 175 Bool fECRFIFO; 176 #endif 177 178 /* 179 * the following stuff gets changed on a per model basis 180 */ 181 UShort ModelOverride; /* for non-auto detection stuff */ 182 183 UShort Offset70; /* CHECK: --> to Device */ 184 UShort BufferSizeBase; /* --> to Device */ 185 UShort BufferSizePerModel; /* --> to Device */ 186 UShort TimePerLine; /* --> to Device */ 187 188 /* 189 * scanner properties 190 */ 191 RegData AsicReg; /* here we have the 98001/3 register set */ 192 Reg96 Asic96Reg; /* here we hold the 96001/3 specific regs */ 193 194 LensInfo LensInf; 195 ScannerCaps sCaps; 196 ULong dwScannerSize; 197 Byte bCurrentSpeed; 198 pUChar pbMapRed; 199 pUChar pbMapGreen; 200 pUChar pbMapBlue; 201 202 ULong TotalBufferRequire; 203 ULong BufferForColorRunTable; 204 UShort PhysicalDpi; 205 UShort RdPix; /* for ASIC 96003 devices */ 206 207 Byte a_bMapTable[4096 * 3]; /* pre 98001 was 256 * 3 */ 208 Byte a_nbNewAdrPointer[_SCANSTATE_BYTES]; 209 210 /* 211 * for P9600x ASIC based scanners 212 */ 213 Bool fColorMoreRedFlag; 214 Bool fColorMoreBlueFlag; 215 Bool fSonyCCD; 216 Bool f97003; 217 Byte AsicRedColor; 218 Byte AsicGreenColor; 219 Byte RedDataReady; 220 Byte GreenDataReady; 221 Byte b1stColorByte; 222 Byte b1stColor; 223 Byte b1stMask; 224 Byte b2ndColorByte; 225 Byte b2ndColor; 226 Byte b2ndMask; 227 Byte b3rdColorByte; 228 Byte b3rdColor; 229 Byte b3rdMask; 230 Byte b1stLinesOffset; 231 Byte b2ndLinesOffset; 232 Byte bLampOn; 233 Byte bExtraAdd; 234 Byte bFifoCount; 235 Byte bMinReadFifo; 236 Byte FullStep; 237 Byte StepMask; 238 Byte MotorOn; 239 Byte MotorFreeRun; 240 Byte IgnorePF; 241 Byte bMotorStepTableNo; 242 243 /* for ASIC 97003... */ 244 Byte b97003DarkR; 245 Byte b97003DarkG; 246 Byte b97003DarkB; 247 248 /* CHECK: to Scan!!!! */ 249 pUChar pGetBufR; /* NOTE: these aren't actually Red/Green buffer */ 250 pUChar pGetBufG; /* pointers but instead are used */ 251 pUChar pPutBufR; /* generically to point to the first 2 */ 252 pUChar pPutBufG; /* color buffers as temp storage */ 253 254 pUChar pCurrentColorRunTable; 255 UShort a_wGrayInitTime[3]; 256 UShort a_wColorInitTime[3]; 257 UShort BackwardSteps; 258 UShort wLinesPer64kTime; 259 UShort ShadingBufferSize; 260 UShort ShadingBankSize; 261 UShort ShadingBankRed; 262 UShort ShadingBankGreen; 263 UShort ShadingBankBlue; 264 UShort ShadingScanLineBlks; 265 UShort ShadingScanLineLen; 266 UShort wOverBlue; 267 UShort FBKScanLineBlks; 268 UShort FBKScanLineLenBase; 269 UShort FBKScanLineLen; 270 UShort OneScanLineLen; 271 272 /* 273 * the DAC part - to Shade !!! 274 */ 275 UShort wsDACCompareHighRed, wsDACCompareLowRed; 276 UShort wsDACCompareHighGreen, wsDACCompareLowGreen; 277 UShort wsDACCompareHighBlue, wsDACCompareLowBlue; 278 UShort wsDACOffsetRed, wsDACOffsetGreen, wsDACOffsetBlue; 279 Byte bsPreRedDAC, bsPreGreenDAC, bsPreBlueDAC; 280 Byte bRedDAC, bGreenDAC, bBlueDAC; 281 Byte bRedGainIndex, bGreenGainIndex, bBlueGainIndex; 282 283 /* 284 * for image description 285 */ 286 DataInfo DataInf; 287 Bool fReshaded; 288 ULong dwDitherIndex; 289 Bool fDoFilter, fFilterFirstLine; 290 ULong dwDivFilter; 291 ULong dwMul; 292 Byte bOffsetFilter; 293 ULong dwLinesFilter; 294 pUChar pFilterBuf, pEndBuf; 295 pUChar pGet1, pGet2, pGet3; 296 297 Byte bSetScanModeFlag; /* see Section 5 - Scanmodes --> ps->Shade.bIntermediate*/ 298 299 /* 300 * some admin vals (they used to be global vars in the original driver) 301 */ 302 Bool fScanningStatus; 303 Byte bLastLampStatus; 304 Bool fWarmupNeeded; 305 ULong dwOffset70; 306 ULong dwMaxReadFifoData; 307 308 /* 309 * 310 */ 311 pUChar pColorRunTable; 312 pUChar pPrescan16; 313 pUChar pPrescan8; 314 UShort BufferForDataRead1; 315 ULong BufferFor1stColor; 316 ULong BufferFor2ndColor; 317 pUChar driverbuf; 318 pUChar pEndBufR; 319 pUChar pEndBufG; 320 pUChar pProcessingBuf; 321 322 /* 323 * formerly used as global vars in ioproc.c, now in genericio.c 324 */ 325 pUChar pScanBuffer1; 326 pUChar pScanBuffer2; 327 328 pModeTypeVar lpEppColorHomePos; 329 pModeTypeVar lpEppColorExposure; 330 pModeTypeVar lpBppColorHomePos; 331 pModeTypeVar lpSppColorHomePos; 332 UShort wMinCmpDpi; 333 pModeTypeVar a_ColorSettings; 334 pDiffModeVar a_tabDiffParam; 335 336 Byte bSpeed48; 337 Byte bSpeed32; 338 Byte bSpeed24; 339 Byte bSpeed16; 340 Byte bSpeed12; 341 Byte bSpeed8; 342 Byte bSpeed6; 343 Byte bSpeed4; 344 Byte bSpeed3; 345 Byte bSpeed2; 346 Byte bSpeed1; 347 348 Byte bHpMotor; 349 Byte bStepSpeed; 350 ULong dwFullStateSpeed; 351 352 /* 353 * reference to globals from motor.c 354 */ 355 Bool fHalfStepTableFlag; 356 Bool fFullLength; 357 Byte bMoveDataOutFlag; 358 Byte bExtraMotorCtrl; 359 Byte bFastMoveFlag; 360 Byte bOldStateCount; 361 Byte bMotorSpeedData; 362 Byte bCurrentLineCount; 363 Byte bNewGap; 364 Byte bNewCurrentLineCountGap; 365 UShort wMaxMoveStep; 366 ULong dwScanStateCount; 367 ULong dwColorRunIndex; 368 pByte a_bColorByteTable; 369 pUChar pScanState; 370 pUShort a_wMoveStepTable; 371 372 /* 373 * for shading - dac.c 374 * CHECK: move to ps->Shade 375 */ 376 Byte bShadingTimeFlag; 377 ULong dwShadow, dwShadowCh; 378 ULong dwHilight, dwHilightCh; 379 ULong dwShadingLen, dwShadingPixels; 380 pUShort pwShadow; 381 382 /* 383 * from transform.c 384 */ 385 Byte bRedHigh, bGreenHigh, bBlueHigh; 386 UShort wPosAdjustX; 387 UShort wNegAdjustX; 388 UShort wReduceRedFactor; 389 UShort wReduceGreenFactor; 390 UShort wReduceBlueFactor; 391 ULong dwOffsetNegative; 392 393 /* 394 * reference to globals from map.c 395 */ 396 #define _DITHERSIZE 64 397 Byte a_bDitherPattern[_DITHERSIZE]; 398 Short wBrightness; 399 Short wContrast; 400 UShort wInitialStep; 401 ULong dwSizeMustProcess; 402 403 /* 404 * here we have pointers to the functions to call 405 */ 406 Bool (*OpenScanPath) (pScanData); 407 void (*CloseScanPath) (pScanData); 408 int (*ReadWriteTest) (pScanData); 409 void (*PutToIdleMode) (pScanData); 410 int (*Calibration) (pScanData); 411 void (*SetupScannerVariables) (pScanData); 412 int (*SetupScanSettings) (pScanData, pScanInfo pInf ); 413 void (*GetImageInfo) (pScanData, pImgDef pInf ); 414 Bool (*WaitForShading) (pScanData); 415 void (*WaitForPositionY) (pScanData); 416 void (*InitialSetCurrentSpeed) (pScanData); 417 Bool (*GotoShadingPosition) (pScanData); 418 void (*SetupScanningCondition) (pScanData); 419 void (*SetMotorSpeed) (pScanData,Byte bSpeed,Bool fSetRunState); 420 void (*FillRunNewAdrPointer) (pScanData); 421 void (*SetupMotorRunTable) (pScanData); 422 void (*PauseColorMotorRunStates) (pScanData); 423 void (*UpdateDataCurrentReadLine)(pScanData); 424 Bool (*ReadOneImageLine) (pScanData); 425 426 /* used only by ASIC9800x Part of the driver ! */ 427 void (*ReInitAsic) (pScanData, Bool shading); 428 429 /* value used to read nibble's */ 430 Byte CtrlReadHighNibble; 431 Byte CtrlReadLowNibble; 432 433 /* 434 * asic register offset values 435 */ 436 Byte RegSwitchBus; 437 Byte RegEPPEnable; 438 Byte RegECPEnable; 439 Byte RegReadDataMode; 440 Byte RegWriteDataMode; 441 Byte RegInitDataFifo; 442 Byte RegForceStep; 443 Byte RegInitScanState; 444 Byte RegRefreshScanState; 445 Byte RegThresholdGapControl; 446 Byte RegADCAddress; 447 Byte RegADCData; 448 Byte RegADCPixelOffset; 449 Byte RegADCSerialOutStr; 450 Byte RegResetConfig; 451 Byte RegLensPosition; 452 Byte RegStatus; 453 Byte RegWaitStateInsert; 454 Byte RegFifoOffset; 455 Byte RegRFifoOffset; 456 Byte RegGFifoOffset; 457 Byte RegBFifoOffset; 458 Byte RegBitDepth; 459 Byte RegStepControl; 460 Byte RegMotor0Control; 461 Byte RegXStepTime; 462 Byte RegGetScanState; 463 Byte RegAsicID; 464 Byte RegReadIOBufBus; 465 Byte RegMemoryLow; 466 Byte RegMemoryHigh; 467 Byte RegModeControl; 468 Byte RegLineControl; 469 Byte RegScanControl; 470 Byte RegMotorControl; 471 #define _MotorDirForward 0x01 /* go forward */ 472 #define _MotorOn 0x02 /* turn on motor */ 473 #define _MotorIgnorePF 0x04 /* motor rolling don't care */ 474 /* paper define flag */ 475 #define _MotorFreeRun 0x80 /*ScanState count don't stop */ 476 /* Following bits (bit 3 & 4 are depended on StatusPort */ 477 /* bit-7:MotorType when it is 1: */ 478 #define _Motor1FullStep 0x08 /* bit 4 is ignored */ 479 /* When it is 0: */ 480 #define _Motor0FullStepWeak 0 /* Full step (driving weak) */ 481 #define _Motor0HalfStep 0x10 /* 1/2 step */ 482 #define _Motor0QuarterStep 0x08 /* 1/4 step */ 483 #define _Motor0FullStepStrong 0x18 /* Full step (driving strong)*/ 484 #define _MotorStepMask 0xe7 485 /* for 96001 */ 486 #define _MotorFullStep96001 0x02 487 #define _MotorOn96001 0x04 488 #define _MotorIgnorePF96001 0x08 489 490 Byte RegConfiguration; 491 Byte RegModelControl; 492 Byte RegModel1Control; 493 Byte RegMemAccessControl; 494 #define _MemBanks 64 /* the number of banks, 5 ls bits */ 495 #define _MemBankMask (_MemBanks - 1) 496 #define _MemBankSize1k 0 497 #define _MemBankSize2k 0x40 498 #define _MemBankSize4k 0x80 499 #define _MemBankSize8k 0xc0 500 /* 96001 specific */ 501 #define _MemBankSize2k96001 0x00 502 #define _MemBankSize4k96001 0x40 503 #define _MemBankSize8k96001 0x80 504 505 Byte RegDpiLow; 506 Byte RegDpiHigh; 507 Byte RegScanPosLow; 508 Byte RegScanPosHigh; 509 Byte RegWidthPixelsLow; 510 Byte RegWidthPixelsHigh; 511 Byte RegThresholdLow; 512 Byte RegThresholdHigh; 513 Byte RegThresholdControl; 514 Byte RegWatchDogControl; 515 #define _WDOnIntervalMask 0x0f /* WD * 8192 scan lines to turn 516 off Lamp */ 517 #define _WDMotorLongInterval 0x40 /* short = 8192 lines time 518 long = 32768 lines time */ 519 #define _WDEnable 0x80 520 Byte RegModelControl2; 521 #define _Model2ChannelSlct 0 522 #define _Model2ChannelMult 0x01 /* bit on/off accords to JONES */ 523 #define _Model2CCSInvert 0x02 524 #define _Model2DirectOutPort 0x04 525 #define _Model2PipeLineDelayN 0x08 526 #define _Model2ShiftGapTiming10 0x10 527 #define _Model2BtnKeyPassThrough 0x20 528 Byte RegRedDCAdjust; 529 Byte RegGreenDCAdjust; 530 Byte RegBlueDCAdjust; 531 Byte RegRedChShadingOffset; 532 Byte RegGreenChShadingOffset; 533 Byte RegBlueChShadingOffset; 534 Byte RegRedChDarkOffset; 535 Byte RegGreenChDarkOffset; 536 Byte RegBlueChDarkOffset; 537 Byte RegWriteIOBusDecode1; 538 Byte RegWriteIOBusDecode2; 539 Byte RegScanStateControl; 540 #define _ScanStateEvenMask 0x0f 541 #define _ScanStateOddMask 0xf0 542 Byte RegRedChEvenOffset; 543 Byte RegGreenChEvenOffset; 544 Byte RegBlueChEvenOffset; 545 Byte RegRedChOddOffset; 546 Byte RegGreenChOddOffset; 547 Byte RegBlueChOddOffset; 548 Byte RegRedGainOutDirect; 549 Byte RegGreenGainOutDirect; 550 Byte RegBlueGainOutDirect; 551 Byte RegLedControl; 552 #define _LedCmdActEnable 0x04 553 #define _LedMotorActEnable 0x08 554 #define _LedClrChActEnable 0x10 /* Color Channel Action */ 555 #define _LedLightOnActEnable 0x20 556 #define _LedHostTurnOnEnable 0x40 557 #define _LedActControl 0x80 558 Byte RegShadingCorrectCtrl; 559 #define _ShadingRCorrectX1 0 560 #define _ShadingRCorrectX2 0x01 561 #define _ShadingRCorrectX3 0x02 562 #define _ShadingRCorrectX4 0x03 563 #define _ShadingGCorrectX1 0 564 #define _ShadingGCorrectX2 0x04 565 #define _ShadingGCorrectX3 0x08 566 #define _ShadingGCorrectX4 0x0c 567 #define _ShadingBCorrectX1 0 568 #define _ShadingBCorrectX2 0x10 569 #define _ShadingBCorrectX3 0x20 570 #define _ShadingBCorrectX4 0x30 571 Byte RegScanStateBegin; 572 Byte RegRedChDarkOffsetLow; 573 Byte RegRedChDarkOffsetHigh; 574 Byte RegGreenChDarkOffsetLow; 575 Byte RegGreenChDarkOffsetHigh; 576 Byte RegBlueChDarkOffsetLow; 577 Byte RegBlueChDarkOffsetHigh; 578 Byte RegResetPulse0; 579 Byte RegResetPulse1; 580 Byte RegCCDClampTiming0; 581 Byte RegCCDClampTiming1; 582 Byte RegVSMPTiming0; 583 Byte RegVSMPTiming1; 584 Byte RegCCDQ1Timing0; 585 Byte RegCCDQ1Timing1; 586 Byte RegCCDQ1Timing2; 587 Byte RegCCDQ1Timing3; 588 Byte RegCCDQ2Timing0; 589 Byte RegCCDQ2Timing1; 590 Byte RegCCDQ2Timing2; 591 Byte RegCCDQ2Timing3; 592 Byte RegADCclockTiming0; 593 Byte RegADCclockTiming1; 594 Byte RegADCclockTiming2; 595 Byte RegADCclockTiming3; 596 Byte RegADCDVTiming0; 597 Byte RegADCDVTiming1; 598 Byte RegADCDVTiming2; 599 Byte RegADCDVTiming3; 600 Byte RegScanStateEnd; 601 602 /* ASIC 98003 specific*/ 603 Byte RegFifoFullLength0; 604 Byte RegFifoFullLength1; 605 Byte RegFifoFullLength2; 606 607 Byte RegMotorTotalStep0; 608 Byte RegMotorTotalStep1; 609 Byte RegMotorFreeRunCount0; 610 Byte RegMotorFreeRunCount1; 611 Byte RegScanControl1; 612 Byte RegMotorFreeRunTrigger; 613 614 Byte RegResetMTSC; 615 616 Byte RegMotor1Control; 617 Byte RegMotor2Control; 618 Byte RegMotorDriverType; 619 Byte RegStatus2; 620 Byte RegExtendedLineControl; 621 Byte RegExtendedXStep; 622 623 Byte RegPllPredivider; 624 Byte RegPllMaindivider; 625 Byte RegPllPostdivider; 626 Byte RegClockSelector; 627 Byte RegTestMode; 628 629 /* CHECK: subject to change */ 630 IODef IO; 631 DeviceDef Device; 632 ShadingDef Shade; 633 ScanDef Scan; 634 BufferDef Bufs; 635 636 } ScanData; 637 638 #endif /* guard __SCANDATA_H__ */ 639 640 /* END PLUTSEK-PP_SCANDATA.H ................................................*/ 641