1 /*............................................................................. 2 * Project : SANE library for Plustek flatbed scanners. 3 *............................................................................. 4 */ 5 6 /** @file plustek-usb.h 7 * @brief Main defines for the USB devices. 8 * 9 * Based on sources acquired from Plustek Inc.<br> 10 * Copyright (C) 2001-2013 Gerhard Jaeger <gerhard@gjaeger.de> 11 * 12 * History: 13 * - 0.40 - starting version of the USB support 14 * - 0.41 - added workaround flag to struct DevCaps 15 * - 0.42 - added MODEL_NOPLUSTEK 16 * - replaced fLM9831 by chip (valid entries: _LM9831, _LM9832, _LM9833) 17 * - added _WAF_MISC_IO3_LAMP for UMAX 3400 18 * - 0.43 - added _WAF_MISC_IOx_LAMP (x=1,2,4,5) 19 * - added CLKDef 20 * - 0.44 - added vendor and product ID to struct DeviceDef 21 * - added _WAF_BYPASS_CALIBRATION 22 * - added _WAF_INV_NEGATIVE_MAP 23 * - 0.45 - added _WAF_SKIP_FINE for skipping fine calibration 24 * - added _WAF_SKIP_WHITEFINE for skipping fine white calibration 25 * - added MCLK setting for 16 bit modes 26 * - added _WAF_FIX_GAIN and _WAF_FIX_OFS 27 * - 0.46 - added UMAX1200 for 5400 model 28 * - removed _WAF_FIX_GAIN and _WAF_FIX_OFS 29 * - added skipCoarseCalib to ScanDef 30 * - added additional defines for cis and epson-ccd sensor 31 * - 0.47 - cleanup work 32 * - added gamma to struct HWDefault 33 * - 0.48 - added DEVCAPSFLAG_LargeTPA 34 * - added _WAF_BIN_FROM_COLOR and _WAF_GRAY_FROM_COLOR 35 * - added dHighSpeed to struct HwDefault 36 * - 0.49 - added a_bRegs, fModFirstHome and fLastScanIsAdf 37 * to struct DeviceDef 38 * - added CRYSTAL_FREQ 39 * - added IPCDef 40 * - 0.50 - cleanup 41 * - removed obsolete _WAF_BLACKFINE 42 * - added MODEL_CANON_LIDE25 43 * - 0.51 - added _WAF_MISC_IO_BUTTONS plus _BUTTON stuff 44 * - added _WAF_USE_ALT_DESC 45 * - added DEVCAPSFLAG_SheetFed 46 * - added dpi_thresh and lineend to motor structure 47 * - 0.52 - added MODEL_QSCAN 48 * - added MODEL_QSCAN_A6 (thanks to Hiroshi Miura) 49 * - changed DCapsDef, lamp -> misc_io 50 * - bPCB is now ushort to be "missused" by non Plustek 51 * devices (as threshold for resetting sensor order) 52 * - added _WAF_LOFF_ON_START and _WAF_ONLY_8BIT 53 * - added MODEL_TSCAN_A4 54 * - added attribute packed for data access structs 55 * - added _WAF_INC_DARKTGT 56 * . 57 * <hr> 58 * This file is part of the SANE package. 59 * 60 * This program is free software; you can redistribute it and/or 61 * modify it under the terms of the GNU General Public License as 62 * published by the Free Software Foundation; either version 2 of the 63 * License, or (at your option) any later version. 64 * 65 * This program is distributed in the hope that it will be useful, but 66 * WITHOUT ANY WARRANTY; without even the implied warranty of 67 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 68 * General Public License for more details. 69 * 70 * You should have received a copy of the GNU General Public License 71 * along with this program. If not, see <https://www.gnu.org/licenses/>. 72 * 73 * As a special exception, the authors of SANE give permission for 74 * additional uses of the libraries contained in this release of SANE. 75 * 76 * The exception is that, if you link a SANE library with other files 77 * to produce an executable, this does not by itself cause the 78 * resulting executable to be covered by the GNU General Public 79 * License. Your use of that executable is in no way restricted on 80 * account of linking the SANE library code into it. 81 * 82 * This exception does not, however, invalidate any other reasons why 83 * the executable file might be covered by the GNU General Public 84 * License. 85 * 86 * If you submit changes to SANE to the maintainers to be included in 87 * a subsequent release, you agree by submitting the changes that 88 * those changes may be distributed with this exception intact. 89 * 90 * If you write modifications of your own for SANE, it is your choice 91 * whether to permit this exception to apply to your modifications. 92 * If you do not wish that, delete this exception notice. 93 * <hr> 94 */ 95 #ifndef __PLUSTEK_USB_H__ 96 #define __PLUSTEK_USB_H__ 97 98 /** CCD ID (PCB ID): total 3 bits (on Plustek devices) */ 99 #define kNEC3799 0 100 #define kSONY518 1 101 #define kSONY548 2 102 #define kNEC8861 3 103 #define kNEC3778 4 104 #define kNECSLIM 5 105 #define kCIS650 6 106 #define kCIS670 7 107 #define kCIS1220 8 108 #define kCIS1240 9 109 #define kEPSON 10 110 111 /** 48MHz Quartz */ 112 #define CRYSTAL_FREQ 48000000UL 113 114 /*********************************** plustek_types.h!!! ************************/ 115 116 /* makes trouble with gcc3 117 #define _SWAP(x,y) (x)^=(y)^=(x)^=(y) 118 */ 119 #define _SWAP(x,y) { (x)^=(y); (x)^=((y)^=(x));} 120 121 #define _LOWORD(x) ((u_short)(x & 0xffff)) 122 #define _HIWORD(x) ((u_short)(x >> 16)) 123 #define _LOBYTE(x) ((u_char)((x) & 0xFF)) 124 #define _HIBYTE(x) ((u_char)((x) >> 8)) 125 126 #define _HILO2WORD(x) ((u_short)x.bHi * 256U + x.bLo) 127 #define _LOHI2WORD(x) ((u_short)x.bLo * 256U + x.bHi) 128 129 #define _PHILO2WORD(x) ((u_short)x->bHi * 256U + x->bLo) 130 #define _PLOHI2WORD(x) ((u_short)x->bLo * 256U + x->bHi) 131 132 #define PACKED8 __attribute__ ((packed,aligned(1))) 133 #define PACKED16 __attribute__ ((packed,aligned(2))) 134 135 /* useful for RGB-values */ 136 typedef struct { 137 u_char Red; 138 u_char Green; 139 u_char Blue; 140 } PACKED8 RGBByteDef; 141 142 typedef struct { 143 u_short Red; 144 u_short Green; 145 u_short Blue; 146 } PACKED16 RGBUShortDef; 147 148 typedef struct { 149 u_long Red; 150 u_long Green; 151 u_long Blue; 152 } RGBULongDef; 153 154 typedef struct { 155 u_char a_bColor[3]; 156 } PACKED8 ColorByteDef; 157 158 typedef struct { 159 u_char bHi; 160 u_char bLo; 161 } PACKED8 HiLoDef; 162 163 typedef union { 164 HiLoDef HiLo[3]; 165 u_short Colors[3]; 166 } PACKED16 ColorWordDef; 167 168 typedef union { 169 HiLoDef HiLo; 170 u_short Mono; 171 } PACKED16 MonoWordDef; 172 173 typedef union { 174 175 u_char *pb; 176 u_short *pw; 177 MonoWordDef *pmw; 178 ColorByteDef *pcb; 179 ColorWordDef *pcw; 180 RGBByteDef *pb_rgb; 181 RGBUShortDef *pw_rgb; 182 HiLoDef *philo; 183 184 } __attribute__ ((aligned(4))) AnyPtr; 185 186 typedef struct { 187 unsigned short x; 188 unsigned short y; 189 } XY; 190 191 #define _VAR_NOT_USED(x) ((x)=(x)) 192 193 /*****************************************************************************/ 194 195 #define IDEAL_GainNormal 0xf000UL /* 240 */ 196 #define IDEAL_GainPositive 0xfe00UL /* 254 */ 197 #define IDEAL_Offset 0x1000UL /* 20 */ 198 199 #define GAIN_Target 65535UL 200 201 /** Chip-types */ 202 typedef enum _CHIPSET 203 { 204 _LM9831, 205 _LM9832, 206 _LM9833 207 } eChipDef; 208 209 /** ScanParam.bCalibration */ 210 enum _SHADINGID 211 { 212 PARAM_Scan, 213 PARAM_Gain, 214 PARAM_DarkShading, 215 PARAM_WhiteShading, 216 PARAM_Offset 217 }; 218 219 /** ScanParam.bDataType */ 220 enum _SCANDATATYPE 221 { 222 SCANDATATYPE_BW, 223 SCANDATATYPE_Gray, 224 SCANDATATYPE_Color 225 }; 226 227 /** DCapsDef.bSensorColor */ 228 enum _SENSORCOLOR 229 { 230 SENSORORDER_rgb, 231 SENSORORDER_rbg, 232 SENSORORDER_gbr, 233 SENSORORDER_grb, 234 SENSORORDER_brg, 235 SENSORORDER_bgr 236 }; 237 238 /** DCapsDef.wFlags */ 239 enum _DEVCAPSFLAG 240 { 241 DEVCAPSFLAG_Normal = 0x0001, 242 DEVCAPSFLAG_Positive = 0x0002, 243 DEVCAPSFLAG_Negative = 0x0004, 244 DEVCAPSFLAG_TPA = 0x0006, 245 DEVCAPSFLAG_Adf = 0x0008, 246 DEVCAPSFLAG_LargeTPA = 0x0010, 247 DEVCAPSFLAG_SheetFed = 0x0020 248 }; 249 250 /** to allow some workarounds */ 251 enum _WORKAROUNDS 252 { 253 _WAF_NONE = 0x00000000, /* no fix anywhere needed */ 254 _WAF_BSHIFT7_BUG = 0x00000001, /* to fix U12 bug in 14bit mode */ 255 _WAF_MISC_IO_LAMPS = 0x00000002, /* special lamp switching */ 256 _WAF_BLACKFINE = 0x00000004, /* use black calibration strip */ 257 _WAF_BYPASS_CALIBRATION = 0x00000008, /* no calibration,use linear gamma */ 258 _WAF_INV_NEGATIVE_MAP = 0x00000010, /* the backend does the neg. stuff */ 259 _WAF_SKIP_FINE = 0x00000020, /* skip the fine calbration */ 260 _WAF_SKIP_WHITEFINE = 0x00000040, /* skip the fine white calbration */ 261 _WAF_BIN_FROM_COLOR = 0x00000080, /* generate binary & gray images */ 262 _WAF_GRAY_FROM_COLOR = 0x00000100, /* from color scans */ 263 _WAF_MISC_IO_BUTTONS = 0x00000200, /* special handling for buttons */ 264 _WAF_USE_ALT_DESC = 0x00000400, /* use alternate manufacturer */ 265 _WAF_RESET_SO_TO_RGB = 0x00000800, /* set sensororder to RGB(CIS only)*/ 266 _WAF_LOFF_ON_START = 0x00001000, /* switch lamp off before scanning */ 267 _WAF_ONLY_8BIT = 0x00002000, /* scanner allows only 8 bit modes */ 268 _WAF_INC_DARKTGT = 0x00004000 /* allow tgt darklevel adjustment */ 269 }; 270 271 /** for lamps connected to the misc I/O pins*/ 272 enum _LAMPS 273 { 274 _NO_MIO = 0, 275 _MIO1 = 0x0001, 276 _MIO2 = 0x0002, 277 _MIO3 = 0x0004, 278 _MIO4 = 0x0008, 279 _MIO5 = 0x0010, 280 _MIO6 = 0x0020 281 }; 282 283 #define _PSENSE_SHIFT 24 284 #define _PSENSE_MASK 0xFF000000 285 #define _BUTTON_SHIFT 16 286 #define _BUTTON_MASK 0xFF0000 287 #define _TPA_SHIFT 8 288 #define _TPA_MASK 0xFF00 289 290 enum _BUTTONS 291 { 292 _NO_BUTTON = 0, 293 _PORT0 = ((_MIO1 | _MIO2) << _BUTTON_SHIFT), 294 _PORT1 = ((_MIO3 | _MIO4) << _BUTTON_SHIFT), 295 _PORT2 = ((_MIO5 | _MIO6) << _BUTTON_SHIFT) 296 }; 297 298 #define _PS_INP1 (0x01 << _PSENSE_SHIFT) 299 #define _PS_INP2 (0x02 << _PSENSE_SHIFT) 300 #define _PS_INP_MIO1 (_MIO1 << (_PSENSE_SHIFT+2)) 301 #define _PS_INP_MIO2 (_MIO2 << (_PSENSE_SHIFT+2)) 302 #define _PS_INP_MIO3 (_MIO3 << (_PSENSE_SHIFT+2)) 303 #define _PS_INP_MIO4 (_MIO4 << (_PSENSE_SHIFT+2)) 304 #define _PS_INP_MIO5 (_MIO5 << (_PSENSE_SHIFT+2)) 305 #define _PS_INP_MIO6 (_MIO6 << (_PSENSE_SHIFT+2)) 306 307 /** for encoding a misc I/O register as TPA */ 308 #define _TPA(register) ((u_long)(register << _TPA_SHIFT)) 309 310 /** Mask to check for available TPA */ 311 #define _HAS_TPA(flag) (flag & _TPA_MASK) 312 313 /** Get the TPA misc I/O register */ 314 #define _GET_TPALAMP(flag) ((flag >> _TPA_SHIFT) & 0xFF) 315 316 /** Get the Papersense port*/ 317 #define _GET_PAPERSENSE_PORT(flag) ((flag >> _PSENSE_SHIFT) & 0xFF) 318 319 /** motor types */ 320 typedef enum 321 { 322 MODEL_KaoHsiung = 0, 323 MODEL_HuaLien, 324 MODEL_Tokyo600, 325 MODEL_EPSON, /**< for EPSON1250/1260 */ 326 MODEL_MUSTEK600, /**< for BearPaw 1200 */ 327 MODEL_MUSTEK1200, /**< for BearPaw 2400 */ 328 MODEL_HP, /**< for HP2x00 */ 329 MODEL_CANON600 , /**< for CanoScan 600dpi models */ 330 MODEL_CANON1200, /**< for Canon 1200dpi models */ 331 MODEL_CANONCCD1200, /**< for Canon CCD 1200dpi models */ 332 MODEL_CANON_LIDE25, /**< for CanoScan LiDE25 */ 333 MODEL_UMAX, /**< for UMAX 3400/3450 */ 334 MODEL_UMAX1200, /**< for UMAX 5400 */ 335 MODEL_TSCAN, /**< for Syscan TravelScan A6 */ 336 MODEL_TSCAN_A4, /**< for Syscan TravelScan A4 */ 337 MODEL_QSCAN, /**< for PandP Q-Scan A4 */ 338 MODEL_QSCAN_A6, /**< for PandP Q-Scan A6 */ 339 MODEL_LAST 340 } eModelDef; 341 342 /** to distinguish between Plustek and other devices */ 343 #define _IS_PLUSTEKMOTOR(x) (x<=MODEL_Tokyo600) 344 345 /** Generic usage */ 346 enum _CHANNEL 347 { 348 CHANNEL_red, 349 CHANNEL_green, 350 CHANNEL_blue, 351 CHANNEL_rgb 352 }; 353 354 /** motor movement */ 355 enum MODULEMOVE 356 { 357 MOVE_Forward, 358 MOVE_Backward, 359 MOVE_Both, 360 MOVE_ToPaperSensor, 361 MOVE_EjectAllPapers, 362 MOVE_SkipPaperSensor, 363 MOVE_ToShading 364 }; 365 366 /** SCANDEF.dwFlags */ 367 enum SCANFLAG 368 { 369 SCANDEF_Transparency = 0x00000100, /* Scanning from transparency*/ 370 SCANDEF_Negative = 0x00000200, /* Scanning from negative */ 371 SCANDEF_QualityScan = 0x00000400, /* Scanning in quality mode */ 372 SCANDEF_ContinuousScan = 0x00001000, 373 SCANDEF_Adf = 0x00002000, /* Scan from ADF tray */ 374 375 SCANFLAG_bgr = 0x00004000, 376 SCANFLAG_BottomUp = 0x00008000, 377 SCANFLAG_DWORDBoundary = 0x00020000, 378 SCANFLAG_RightAlign = 0x00040000, 379 SCANFLAG_StillModule = 0x00080000, 380 SCANFLAG_Pseudo48 = 0x08000000, 381 SCANFLAG_SampleY = 0x04000000, 382 SCANFLAG_Calibration = 0x10000000, 383 SCANFLAG_Scanning = 0x20020000, 384 SCANFLAG_StartScan = 0x40000000 385 }; 386 387 typedef struct Origins 388 { 389 long lLeft; /* How many pix to move the scanning org left, in optic res */ 390 long lUp; /* How many pix to move the scanning or up, in optic res */ 391 } OrgDef; 392 393 typedef struct SrcAttr 394 { 395 XY DataOrigin; /**< The origin x is from visible pixel not CCD */ 396 /* pixel 0, in 300 DPI base. */ 397 /* The origin y is from visible top */ 398 /* (glass area), in 300 DPI */ 399 short ShadingOriginY; /**< The origin y is from top of scanner body */ 400 short DarkShadOrgY; /**< if the device has a dark calibration strip */ 401 XY Size; /**< Scanning width/height, in 300 DPI base. */ 402 XY MinDpi; /**< Minimum dpi supported for scanning */ 403 404 } SrcAttrDef; 405 406 typedef struct DevCaps 407 { 408 SrcAttrDef Normal; /**< Reflection */ 409 SrcAttrDef Positive; /**< Positive film */ 410 SrcAttrDef Negative; /**< Negative film */ 411 SrcAttrDef Adf; /**< Adf device */ 412 XY OpticDpi; /**< Maximum DPI */ 413 u_short wFlags; /**< Flag to indicate what kinds of elements */ 414 /* are available */ 415 u_char bSensorOrder; /**< CCD color sequences, see _SENSORORDER */ 416 u_char bSensorDistance; /**< CCD Color distance */ 417 u_char bButtons; /**< Number of buttons */ 418 u_char bCCD; /**< CCD ID */ 419 u_short bPCB; /**< PCB ID/or threshold (only CIS) */ 420 u_long workaroundFlag; /**< Flag to allow special work arounds, see */ 421 /* _WORKAROUNDS */ 422 u_long misc_io; /**< for lamp, papersense and buttons */ 423 424 } DCapsDef; 425 426 /** 427 * for keeping initial illumination settings 428 */ 429 typedef struct 430 { 431 u_char mode; 432 433 u_short red_lamp_on; 434 u_short red_lamp_off; 435 u_short green_lamp_on; 436 u_short green_lamp_off; 437 u_short blue_lamp_on; 438 u_short blue_lamp_off; 439 440 } IllumiDef; 441 442 443 /** basic register settings 444 */ 445 typedef struct HWDefault 446 { 447 double dMaxMotorSpeed; /* Inches/second, max. scan speed */ 448 double dMaxMoveSpeed; /* Inches/second, max. move speed */ 449 double dHighSpeed; /* for speeding up the sensor */ 450 double dIntegrationTimeLowLamp; 451 double dIntegrationTimeHighLamp; 452 u_short wMotorDpi; /* Full step DPI */ 453 u_short wDRAMSize; /* in KB */ 454 double dMinIntegrationTimeLowres; /*in ms. */ 455 double dMinIntegrationTimeHighres; /* in ms. */ 456 u_short wGreenPWMDutyCycleLow; 457 u_short wGreenPWMDutyCycleHigh; 458 /* Registers */ 459 u_char bSensorConfiguration; /* 0x0b */ 460 /* Sensor control settings */ 461 u_char bReg_0x0c; 462 u_char bReg_0x0d; 463 u_char bReg_0x0e; 464 u_char bReg_0x0f_Mono [10]; /* 0x0f to 0x18 */ 465 u_char bReg_0x0f_Color [10]; /* 0x0f to 0x18 */ 466 467 /* color mode settings */ 468 u_char bReg_0x26; 469 u_char bReg_0x27; 470 471 /* illumination mode reg 0x29 (runtime) */ 472 u_char bReg_0x29; 473 474 /* initial illumination settings */ 475 IllumiDef illu_mono; 476 IllumiDef illu_color; 477 478 /* 0x1a & 0x1b, remember the u_char order is not Intel 479 * format, you have to pay your attention when you 480 * write this value to register. 481 */ 482 u_short StepperPhaseCorrection; 483 484 /* Sensor Pixel Configuration 485 * Actually, the wActivePixelsStart will be set to 0 for shading purpose. 486 * We have to keep these values to adjust the origins when user does the 487 * scan. These settings are based on optic resolution. 488 */ 489 u_char bOpticBlackStart; /* 0x1c */ 490 u_char bOpticBlackEnd; /* 0x1d */ 491 u_short wActivePixelsStart; /* 0x1e & 0x1f */ 492 u_short wLineEnd; /* 0x20 & 0x21 */ 493 494 /* illumination settings (runtime) */ 495 u_short red_lamp_on; /* 0x2c & 0x2d */ 496 u_short red_lamp_off; /* 0x2e & 0x2f */ 497 u_short green_lamp_on; /* 0x30 & 0x31 */ 498 u_short green_lamp_off; /* 0x32 & 0x33 */ 499 u_short blue_lamp_on; /* 0x34 & 0x35 */ 500 u_short blue_lamp_off; /* 0x36 & 0x37 */ 501 502 /* Misc */ 503 u_char bReg_0x45; 504 u_short wStepsAfterPaperSensor2;/* 0x4c & 0x4d */ 505 u_char bStepsToReverse; /* 0x50 */ 506 u_char bReg_0x51; 507 u_char bReg_0x54; 508 u_char bReg_0x55; 509 u_char bReg_0x56; 510 u_char bReg_0x57; 511 u_char bReg_0x58; 512 u_char bReg_0x59; 513 u_char bReg_0x5a; 514 u_char bReg_0x5b; 515 u_char bReg_0x5c; 516 u_char bReg_0x5d; 517 u_char bReg_0x5e; 518 519 eChipDef chip; /* chiptype */ 520 eModelDef motorModel; /* to identify used motor */ 521 double gamma; /* default gamma setting */ 522 } HWDef; 523 524 /** device description during runtime 525 */ 526 typedef struct DeviceDef 527 { 528 char* ModelStr; /**< pointer to our model string */ 529 int vendor; /**< vendor ID */ 530 int product; /**< product ID */ 531 DCapsDef Caps; /**< pointer to the attribute of current dev */ 532 HWDef HwSetting; /**< Pointer to the characteristics of device */ 533 SrcAttrDef *pSource; /**< Scanning src, it's equal to Caps.Normal */ 534 /**< on the source that the user specified. */ 535 OrgDef Normal; /**< Reflection - Pix to adjust scanning orgs */ 536 OrgDef Positive; /**< Pos film - Pix to adjust scanning orgs */ 537 OrgDef Negative; /**< Neg film - Pix to adjust scanning orgs */ 538 OrgDef Adf; /**< Adf - Pixels to adjust scanning origins */ 539 u_long dwTicksLampOn; /**< The ticks when lamp turns on */ 540 u_long dwLampOnPeriod;/**< How many seconds to keep lamp on */ 541 SANE_Bool bLampOffOnEnd; /**< switch lamp off on end or keep cur. state*/ 542 int currentLamp; /**< The lamp ID of the currently used lamp */ 543 SANE_Bool fModFirstHome; /**< */ 544 SANE_Bool fLastScanIsAdf;/**< */ 545 u_char a_bRegs[0x80]; /**< our global register file */ 546 547 } DeviceDef; 548 549 550 typedef struct Settings 551 { 552 char *pIDString; 553 DCapsDef *pDevCaps; 554 HWDef *pHwDef; 555 char *pModelString; 556 557 } SetDef; 558 559 /** 560 */ 561 typedef struct 562 { 563 /** User Information */ 564 u_long dwBytes; /**< bytes per line */ 565 u_long dwPixels; /**< pixels per line */ 566 u_long dwLines; /**< lines */ 567 568 /** Driver Info */ 569 u_long dwValidPixels; /**< only valid pixels, not incl. pad pix(B/W,Gray)*/ 570 u_long dwPhyPixels; /**< include pad pixels for ASIC (B/W, Gray) */ 571 u_long dwPhyBytes; /**< bytes to read from ASIC */ 572 u_long dwPhyLines; /**< should include the extra lines accord to the */ 573 /* request dpi (CCD lines distance) */ 574 u_long dwTotalBytes; /**< Total bytes per scan */ 575 576 } WinInfo; 577 578 /** 579 */ 580 typedef struct 581 { 582 /* OUTPUT - Driver returned area. All are based on physical 583 * scanning conditions. */ 584 WinInfo Size; /* i/p: 585 * dwPixels, dwBytes(without u_long boundary factor) 586 * dwLines in user specified dpi 587 * o/p: 588 * dwPhyPixels, dwPhyBytes, dwPhyLines 589 * so after called, caller have to change it */ 590 XY PhyDpi; /* Driver DPI */ 591 592 /* INPUT - User info. All sizes and coordinates are specified in the 593 * unit based on 300 DPI */ 594 XY UserDpi; /**< User specified DPI */ 595 XY Origin; /**< Scanning origin in optic dpi */ 596 double dMCLK; /**< for positive & negative & Adf */ 597 short brightness; 598 short contrast; 599 u_char bSource; /**< Reflection/Positive/Negative/Adf(SOURCE_xxx)*/ 600 u_char bDataType; /**< Bw, Gray or Color (see _SCANDATATYPE) */ 601 u_char bBitDepth; /**< 1/8/14 */ 602 u_char bChannels; /**< Color or Gray */ 603 u_char bCalibration; /**< 1 or 2: the origin.x is from CCD pixel 0 and 604 * the origin.y is from Top of scanner. 605 * In this case, the WININFO.dwPhyLines 606 * will not included the extra lines for 607 * color distance factor. 608 * 0: normal scan, the both directions have to 609 * add the distance */ 610 int swOffset[3]; /**< for calibration adjustment */ 611 int swGain[3]; /**< for calibration adjustment */ 612 613 } ScanParam; 614 615 struct Plustek_Device; 616 617 /** structure to hold all necessary buffer information for current scan 618 */ 619 typedef struct ScanDef 620 { 621 SANE_Bool fCalibrated; /**< calibrated or not */ 622 SANE_Bool skipCoarseCalib;/**< skip coarse calibration or not */ 623 u_long dwFlag; /**< scan attributes */ 624 625 ScanParam sParam; /**< all we need to scan */ 626 627 AnyPtr UserBuf; /**< pointer to the user buffer */ 628 u_long dwLinesUser; /**< Number of lines of user buffer */ 629 u_long dwBytesLine; /**< Bytes per line of user buffer. */ 630 u_long dwLinesToProcess; 631 632 /** Image processing routine according to the scan mode */ 633 void (*pfnProcess)(struct Plustek_Device*); 634 635 u_long* pScanBuffer; /**< our scan buffer */ 636 637 u_long dwLinesPerScanBufs; 638 u_long dwNumberOfScanBufs; 639 u_long dwLinesScanBuf; 640 641 u_char* pbScanBufBegin; 642 u_char* pbScanBufEnd; 643 u_char* pbGetDataBuf; 644 u_long dwBytesScanBuf; 645 u_long dwLinesDiscard; 646 647 u_long dwRedShift; 648 u_long dwGreenShift; 649 u_long dwBlueShift; 650 651 AnyPtr Green; 652 AnyPtr Red; 653 AnyPtr Blue; 654 655 long lBufAdjust; /**< bytes to adjust buffer pointer */ 656 /* after a image line processed */ 657 u_short wSumY; /**< for line sampling */ 658 659 u_char bLineDistance; /**< Color offset in specific dpi y */ 660 int fGrayFromColor; /**< channel to use for gray mode */ 661 662 u_char bLinesToSkip; /**< how many lines to skip at start */ 663 664 } ScanDef; 665 666 667 /** max number of different colck settings */ 668 #define _MAX_CLK 10 669 670 /** structure to hold PWN settings 671 */ 672 typedef struct 673 { 674 u_char pwm; /**< PWM */ 675 u_char pwm_duty; /**< PWM duty cycles */ 676 u_char scan_lines_per_line; /**< lines to scan to obtain 1 real line 677 will be used in 16bit color modes only */ 678 } MDef; 679 680 /** according to the CCD and motor, we provide various settings 681 */ 682 typedef struct { 683 684 eModelDef motorModel; /**< the motor ID */ 685 686 u_char pwm_fast; /**< PWM during fast movement */ 687 u_char pwm_duty_fast; /**< PWM duty during fast movement */ 688 u_char mclk_fast; /**< MCLK during fast movement */ 689 690 u_short dpi_thresh; 691 u_short lineend; 692 693 /** 694 * here we define some ranges for better supporting 695 * non-Plustek devices with it's different hardware 696 * we can set the MCLK and the motor PWM stuff for color 697 * and gray modes (8bit and 14/16bit modes) 698 * 0 1 2 3 4 5 6 7 8 9 699 * <= 75 <=100 <=150 <=200 <=300 <=400 <=600 <= 800 <=1200 <=2400DPI 700 */ 701 MDef motor_sets[_MAX_CLK]; /**< motor PWM settings during scan */ 702 double color_mclk_8[_MAX_CLK]; /**< MCLK settings for color scan */ 703 double color_mclk_16[_MAX_CLK]; /**< MCLK settings for color (16bit) scan*/ 704 double gray_mclk_8[_MAX_CLK]; /**< MCLK settings for gray scan */ 705 double gray_mclk_16[_MAX_CLK]; /**< MCLK settings for gray (16bit) scan */ 706 707 } ClkMotorDef; 708 709 /** for transferring some info between child and parent after calibration 710 */ 711 #define _MAX_SHAD 0x4000 712 #define _SHADING_BUF (_MAX_SHAD*3) /**< max size of the shading buffer */ 713 714 typedef struct { 715 u_long transferRate; 716 } IPCDef; 717 718 #endif /* guard __PLUSTEK_USB_H__ */ 719 720 /* END PLUSTEK-USB.H ........................................................*/ 721