1141cc406Sopenharmony_ci/** @file plustek-pp.h 2141cc406Sopenharmony_ci * @brief Definitions for the backend. 3141cc406Sopenharmony_ci * 4141cc406Sopenharmony_ci * Based on Kazuhiro Sasayama previous 5141cc406Sopenharmony_ci * Work on plustek.[ch] file from the SANE package.<br> 6141cc406Sopenharmony_ci * 7141cc406Sopenharmony_ci * original code taken from sane-0.71<br> 8141cc406Sopenharmony_ci * Copyright (C) 1997 Hypercore Software Design, Ltd.<br> 9141cc406Sopenharmony_ci * Copyright (C) 2001-2013 Gerhard Jaeger <gerhard@gjaeger.de> 10141cc406Sopenharmony_ci * 11141cc406Sopenharmony_ci * History: 12141cc406Sopenharmony_ci * - 0.01 - initial version 13141cc406Sopenharmony_ci * - 0.43 - bumped up version to reflect the former module code version 14141cc406Sopenharmony_ci * - removed Version from ScannerCaps 15141cc406Sopenharmony_ci * - added _E_FAULT 16141cc406Sopenharmony_ci * - 0.44 - fix UL issues, as Long types default to int32_t now 17141cc406Sopenharmony_ci * . 18141cc406Sopenharmony_ci * <hr> 19141cc406Sopenharmony_ci * This file is part of the SANE package. 20141cc406Sopenharmony_ci * 21141cc406Sopenharmony_ci * This program is free software; you can redistribute it and/or 22141cc406Sopenharmony_ci * modify it under the terms of the GNU General Public License as 23141cc406Sopenharmony_ci * published by the Free Software Foundation; either version 2 of the 24141cc406Sopenharmony_ci * License, or (at your option) any later version. 25141cc406Sopenharmony_ci * 26141cc406Sopenharmony_ci * This program is distributed in the hope that it will be useful, but 27141cc406Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of 28141cc406Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29141cc406Sopenharmony_ci * General Public License for more details. 30141cc406Sopenharmony_ci * 31141cc406Sopenharmony_ci * You should have received a copy of the GNU General Public License 32141cc406Sopenharmony_ci * along with this program. If not, see <https://www.gnu.org/licenses/>. 33141cc406Sopenharmony_ci * 34141cc406Sopenharmony_ci * As a special exception, the authors of SANE give permission for 35141cc406Sopenharmony_ci * additional uses of the libraries contained in this release of SANE. 36141cc406Sopenharmony_ci * 37141cc406Sopenharmony_ci * The exception is that, if you link a SANE library with other files 38141cc406Sopenharmony_ci * to produce an executable, this does not by itself cause the 39141cc406Sopenharmony_ci * resulting executable to be covered by the GNU General Public 40141cc406Sopenharmony_ci * License. Your use of that executable is in no way restricted on 41141cc406Sopenharmony_ci * account of linking the SANE library code into it. 42141cc406Sopenharmony_ci * 43141cc406Sopenharmony_ci * This exception does not, however, invalidate any other reasons why 44141cc406Sopenharmony_ci * the executable file might be covered by the GNU General Public 45141cc406Sopenharmony_ci * License. 46141cc406Sopenharmony_ci * 47141cc406Sopenharmony_ci * If you submit changes to SANE to the maintainers to be included in 48141cc406Sopenharmony_ci * a subsequent release, you agree by submitting the changes that 49141cc406Sopenharmony_ci * those changes may be distributed with this exception intact. 50141cc406Sopenharmony_ci * 51141cc406Sopenharmony_ci * If you write modifications of your own for SANE, it is your choice 52141cc406Sopenharmony_ci * whether to permit this exception to apply to your modifications. 53141cc406Sopenharmony_ci * If you do not wish that, delete this exception notice. 54141cc406Sopenharmony_ci * <hr> 55141cc406Sopenharmony_ci */ 56141cc406Sopenharmony_ci#ifndef __PLUSTEKPP_H__ 57141cc406Sopenharmony_ci#define __PLUSTEKPP_H__ 58141cc406Sopenharmony_ci 59141cc406Sopenharmony_ci/*............................................................................. 60141cc406Sopenharmony_ci * the structures for driver communication 61141cc406Sopenharmony_ci */ 62141cc406Sopenharmony_citypedef struct { 63141cc406Sopenharmony_ci unsigned short x; 64141cc406Sopenharmony_ci unsigned short y; 65141cc406Sopenharmony_ci} XY, *pXY; 66141cc406Sopenharmony_ci 67141cc406Sopenharmony_citypedef struct { 68141cc406Sopenharmony_ci unsigned short x; 69141cc406Sopenharmony_ci unsigned short y; 70141cc406Sopenharmony_ci unsigned short cx; 71141cc406Sopenharmony_ci unsigned short cy; 72141cc406Sopenharmony_ci} CropRect, *pCropRect; 73141cc406Sopenharmony_ci 74141cc406Sopenharmony_citypedef struct image { 75141cc406Sopenharmony_ci unsigned long dwFlag; 76141cc406Sopenharmony_ci CropRect crArea; 77141cc406Sopenharmony_ci XY xyDpi; 78141cc406Sopenharmony_ci unsigned short wDataType; 79141cc406Sopenharmony_ci} ImgDef, *pImgDef; 80141cc406Sopenharmony_ci 81141cc406Sopenharmony_citypedef struct { 82141cc406Sopenharmony_ci unsigned long dwPixelsPerLine; 83141cc406Sopenharmony_ci unsigned long dwBytesPerLine; 84141cc406Sopenharmony_ci unsigned long dwLinesPerArea; 85141cc406Sopenharmony_ci struct image ImgDef; 86141cc406Sopenharmony_ci} CropInfo, *pCropInfo; 87141cc406Sopenharmony_ci 88141cc406Sopenharmony_ci/** definition of gamma maps 89141cc406Sopenharmony_ci */ 90141cc406Sopenharmony_citypedef struct { 91141cc406Sopenharmony_ci int len; /**< gamma table len */ 92141cc406Sopenharmony_ci int depth; /**< entry bit depth */ 93141cc406Sopenharmony_ci int map_id; /**< what map */ 94141cc406Sopenharmony_ci void *map; /**< pointer for map */ 95141cc406Sopenharmony_ci} MapDef, *pMapDef; 96141cc406Sopenharmony_ci 97141cc406Sopenharmony_ci/** for offset stuff 98141cc406Sopenharmony_ci */ 99141cc406Sopenharmony_citypedef struct { 100141cc406Sopenharmony_ci int x; 101141cc406Sopenharmony_ci int y; 102141cc406Sopenharmony_ci} OffsDef, *pOffsDef; 103141cc406Sopenharmony_ci 104141cc406Sopenharmony_ci/** useful for description tables 105141cc406Sopenharmony_ci */ 106141cc406Sopenharmony_citypedef struct { 107141cc406Sopenharmony_ci int id; 108141cc406Sopenharmony_ci char *desc; 109141cc406Sopenharmony_ci} TabDef, *pTabDef; 110141cc406Sopenharmony_ci 111141cc406Sopenharmony_ci/** for defining the scanmodes 112141cc406Sopenharmony_ci */ 113141cc406Sopenharmony_citypedef const struct mode_param 114141cc406Sopenharmony_ci{ 115141cc406Sopenharmony_ci int color; 116141cc406Sopenharmony_ci int depth; 117141cc406Sopenharmony_ci int scanmode; 118141cc406Sopenharmony_ci} ModeParam, *pModeParam; 119141cc406Sopenharmony_ci 120141cc406Sopenharmony_ci/** 121141cc406Sopenharmony_ci */ 122141cc406Sopenharmony_ci#define SFLAG_ADF 0x00000010 /* Automatic document feeder */ 123141cc406Sopenharmony_ci#define SFLAG_MFP 0x00000020 /* MF-Keypad support */ 124141cc406Sopenharmony_ci#define SFLAG_SheetFed 0x00000040 /* Sheetfed support */ 125141cc406Sopenharmony_ci#define SFLAG_TPA 0x00000080 /* has transparency adapter */ 126141cc406Sopenharmony_ci#define SFLAG_CUSTOM_GAMMA 0x00000200 /* driver supports custom gamma */ 127141cc406Sopenharmony_ci 128141cc406Sopenharmony_ci/** 129141cc406Sopenharmony_ci */ 130141cc406Sopenharmony_ci#define SCANDEF_Inverse 0x00000001 131141cc406Sopenharmony_ci#define SCANDEF_UnlimitLength 0x00000002 132141cc406Sopenharmony_ci#define SCANDEF_StopWhenPaperOut 0x00000004 133141cc406Sopenharmony_ci#define SCANDEF_BoundaryDWORD 0x00000008 134141cc406Sopenharmony_ci#define SCANDEF_ColorBGROrder 0x00000010 135141cc406Sopenharmony_ci#define SCANDEF_BmpStyle 0x00000020 136141cc406Sopenharmony_ci#define SCANDEF_BoundaryWORD 0x00000040 137141cc406Sopenharmony_ci#define SCANDEF_NoMap 0x00000080 /* specified this flag will */ 138141cc406Sopenharmony_ci /* cause system ignores the */ 139141cc406Sopenharmony_ci /* siBrightness & siContrast */ 140141cc406Sopenharmony_ci#define SCANDEF_Transparency 0x00000100 /* Scanning from transparency*/ 141141cc406Sopenharmony_ci#define SCANDEF_Negative 0x00000200 /* Scanning from negative */ 142141cc406Sopenharmony_ci#define SCANDEF_QualityScan 0x00000400 /* Scanning in quality mode */ 143141cc406Sopenharmony_ci#define SCANDEF_BuildBwMap 0x00000800 /* Set default map */ 144141cc406Sopenharmony_ci#define SCANDEF_ContinuousScan 0x00001000 145141cc406Sopenharmony_ci#define SCANDEF_DontBackModule 0x00002000 /* module will not back to */ 146141cc406Sopenharmony_ci /* home after image scanned */ 147141cc406Sopenharmony_ci#define SCANDEF_RightAlign 0x00008000 /* 12-bit */ 148141cc406Sopenharmony_ci 149141cc406Sopenharmony_ci#define SCANDEF_TPA (SCANDEF_Transparency | SCANDEF_Negative) 150141cc406Sopenharmony_ci 151141cc406Sopenharmony_ci#define SCANDEF_Adf 0x00020000 /* Scan from ADF tray */ 152141cc406Sopenharmony_ci 153141cc406Sopenharmony_ci/* these values will be combined with ScannerInfo.dwFlag */ 154141cc406Sopenharmony_ci#define _SCANNER_SCANNING 0x8000000 155141cc406Sopenharmony_ci#define _SCANNER_PAPEROUT 0x4000000 156141cc406Sopenharmony_ci 157141cc406Sopenharmony_ci/* for GetLensInformation */ 158141cc406Sopenharmony_ci#if 0 159141cc406Sopenharmony_ci#define SOURCE_Reflection 0 160141cc406Sopenharmony_ci#define SOURCE_Transparency 1 161141cc406Sopenharmony_ci#define SOURCE_Negative 2 162141cc406Sopenharmony_ci#define SOURCE_ADF 3 163141cc406Sopenharmony_ci#endif 164141cc406Sopenharmony_ci 165141cc406Sopenharmony_ci/****************************************************************************** 166141cc406Sopenharmony_ci * Section 6 - additional definitions 167141cc406Sopenharmony_ci */ 168141cc406Sopenharmony_ci 169141cc406Sopenharmony_ci/* scan modes */ 170141cc406Sopenharmony_ci#define COLOR_BW 0 171141cc406Sopenharmony_ci#define COLOR_HALFTONE 1 172141cc406Sopenharmony_ci#define COLOR_256GRAY 2 173141cc406Sopenharmony_ci#define COLOR_TRUE24 3 174141cc406Sopenharmony_ci#define COLOR_TRUE32 4 175141cc406Sopenharmony_ci#define COLOR_TRUE48 4 /* not sure if this should be the same as 32 */ 176141cc406Sopenharmony_ci#define COLOR_TRUE36 5 177141cc406Sopenharmony_ci 178141cc406Sopenharmony_ci/* We don't support halftone mode now --> Plustek statement for USB */ 179141cc406Sopenharmony_ci#define COLOR_GRAY16 6 180141cc406Sopenharmony_ci 181141cc406Sopenharmony_ci#define _MEASURE_BASE 300UL 182141cc406Sopenharmony_ci 183141cc406Sopenharmony_ci/** transparency/negative mode set ranges 184141cc406Sopenharmony_ci */ 185141cc406Sopenharmony_ci#define _TPAPageWidth 500U /* org. was 450 = 38.1 mm */ 186141cc406Sopenharmony_ci#define _TPAPageHeight 510U /* org. was 460 = 38.9 mm */ 187141cc406Sopenharmony_ci#define _TPAModeSupportMin COLOR_TRUE24 188141cc406Sopenharmony_ci#define _TPAModeSupportMax COLOR_TRUE48 189141cc406Sopenharmony_ci#define _TPAModeSupportDef COLOR_TRUE24 190141cc406Sopenharmony_ci#define _TPAMinDpi 150 191141cc406Sopenharmony_ci 192141cc406Sopenharmony_ci#define _NegativePageWidth 460U /* 38.9 mm */ 193141cc406Sopenharmony_ci#define _NegativePageHeight 350U /* 29.6 mm */ 194141cc406Sopenharmony_ci 195141cc406Sopenharmony_ci#define _DEF_DPI 50 196141cc406Sopenharmony_ci 197141cc406Sopenharmony_ci/* 198141cc406Sopenharmony_ci * additional shared stuff between user-world and kernel mode 199141cc406Sopenharmony_ci */ 200141cc406Sopenharmony_ci#define _VAR_NOT_USED(x) ((x)=(x)) 201141cc406Sopenharmony_ci 202141cc406Sopenharmony_ci/* 203141cc406Sopenharmony_ci * for Gamma tables 204141cc406Sopenharmony_ci */ 205141cc406Sopenharmony_ci#define _MAP_RED 0 206141cc406Sopenharmony_ci#define _MAP_GREEN 1 207141cc406Sopenharmony_ci#define _MAP_BLUE 2 208141cc406Sopenharmony_ci#define _MAP_MASTER 3 209141cc406Sopenharmony_ci 210141cc406Sopenharmony_ci/* 211141cc406Sopenharmony_ci * generic error codes... 212141cc406Sopenharmony_ci */ 213141cc406Sopenharmony_ci#define _OK 0 214141cc406Sopenharmony_ci 215141cc406Sopenharmony_ci#define _FIRST_ERR -9000 216141cc406Sopenharmony_ci 217141cc406Sopenharmony_ci#define _E_INIT (_FIRST_ERR-1) /* already initialized */ 218141cc406Sopenharmony_ci#define _E_NOT_INIT (_FIRST_ERR-2) /* not initialized */ 219141cc406Sopenharmony_ci#define _E_NULLPTR (_FIRST_ERR-3) /* internal NULL-PTR detected */ 220141cc406Sopenharmony_ci#define _E_ALLOC (_FIRST_ERR-4) /* error allocating memory */ 221141cc406Sopenharmony_ci#define _E_TIMEOUT (_FIRST_ERR-5) /* signals a timeout condition */ 222141cc406Sopenharmony_ci#define _E_INVALID (_FIRST_ERR-6) /* invalid parameter detected */ 223141cc406Sopenharmony_ci#define _E_INTERNAL (_FIRST_ERR-7) /* internal error */ 224141cc406Sopenharmony_ci#define _E_BUSY (_FIRST_ERR-8) /* device is already in use */ 225141cc406Sopenharmony_ci#define _E_ABORT (_FIRST_ERR-9) /* operation aborted */ 226141cc406Sopenharmony_ci#define _E_LOCK (_FIRST_ERR-10) /* can't lock resource */ 227141cc406Sopenharmony_ci#define _E_NOSUPP (_FIRST_ERR-11) /* feature or device not supported */ 228141cc406Sopenharmony_ci#define _E_NORESOURCE (_FIRST_ERR-12) /* out of memo, resource busy... */ 229141cc406Sopenharmony_ci#define _E_VERSION (_FIRST_ERR-19) /* version conflict */ 230141cc406Sopenharmony_ci#define _E_NO_DEV (_FIRST_ERR-20) /* device does not exist */ 231141cc406Sopenharmony_ci#define _E_NO_CONN (_FIRST_ERR-21) /* nothing connected */ 232141cc406Sopenharmony_ci#define _E_PORTSEARCH (_FIRST_ERR-22) /* parport_enumerate failed */ 233141cc406Sopenharmony_ci#define _E_NO_PORT (_FIRST_ERR-23) /* requested port does not exist */ 234141cc406Sopenharmony_ci#define _E_REGISTER (_FIRST_ERR-24) /* cannot register this device */ 235141cc406Sopenharmony_ci#define _E_SEQUENCE (_FIRST_ERR-30) /* caller sequence does not match */ 236141cc406Sopenharmony_ci#define _E_NO_ASIC (_FIRST_ERR-31) /* can't detect ASIC */ 237141cc406Sopenharmony_ci 238141cc406Sopenharmony_ci# define _E_FAULT (_E_INTERNAL) /* should never happen in userspace */ 239141cc406Sopenharmony_ci 240141cc406Sopenharmony_ci#define _E_LAMP_NOT_IN_POS (_FIRST_ERR-40) 241141cc406Sopenharmony_ci#define _E_LAMP_NOT_STABLE (_FIRST_ERR-41) 242141cc406Sopenharmony_ci#define _E_NODATA (_FIRST_ERR-42) 243141cc406Sopenharmony_ci#define _E_BUFFER_TOO_SMALL (_FIRST_ERR-43) 244141cc406Sopenharmony_ci#define _E_DATAREAD (_FIRST_ERR-44) 245141cc406Sopenharmony_ci 246141cc406Sopenharmony_ci 247141cc406Sopenharmony_ci/************************ some definitions ***********************************/ 248141cc406Sopenharmony_ci 249141cc406Sopenharmony_ci/* NOTE: needs to be kept in sync with table below */ 250141cc406Sopenharmony_ci#define MODELSTR static char *ModelStr[] = { \ 251141cc406Sopenharmony_ci "unknown", \ 252141cc406Sopenharmony_ci "Primax 4800", \ 253141cc406Sopenharmony_ci "Primax 4800 Direct", \ 254141cc406Sopenharmony_ci "Primax 4800 Direct 30Bit", \ 255141cc406Sopenharmony_ci "Primax 9600 Direct 30Bit", \ 256141cc406Sopenharmony_ci "4800P", \ 257141cc406Sopenharmony_ci "4830P", \ 258141cc406Sopenharmony_ci "600P/6000P", \ 259141cc406Sopenharmony_ci "4831P", \ 260141cc406Sopenharmony_ci "9630P", \ 261141cc406Sopenharmony_ci "9630PL", \ 262141cc406Sopenharmony_ci "9636P", \ 263141cc406Sopenharmony_ci "A3I", \ 264141cc406Sopenharmony_ci "12000P/96000P", \ 265141cc406Sopenharmony_ci "9636P+/Turbo", \ 266141cc406Sopenharmony_ci "9636T/12000T", \ 267141cc406Sopenharmony_ci "P8", \ 268141cc406Sopenharmony_ci "P12", \ 269141cc406Sopenharmony_ci "PT12", \ 270141cc406Sopenharmony_ci "Genius Colorpage Vivid III V2", \ 271141cc406Sopenharmony_ci "USB-Device" \ 272141cc406Sopenharmony_ci} 273141cc406Sopenharmony_ci 274141cc406Sopenharmony_ci/* the models */ 275141cc406Sopenharmony_ci#define MODEL_OP_UNKNOWN 0 /* unknown */ 276141cc406Sopenharmony_ci#define MODEL_PMX_4800 1 /* Primax Colorado 4800 like OP 4800 */ 277141cc406Sopenharmony_ci#define MODEL_PMX_4800D 2 /* Primax Compact 4800 Direct, OP 600 R->G, G->R */ 278141cc406Sopenharmony_ci#define MODEL_PMX_4800D3 3 /* Primax Compact 4800 Direct 30 */ 279141cc406Sopenharmony_ci#define MODEL_PMX_9600D3 4 /* Primax Compact 9600 Direct 30 */ 280141cc406Sopenharmony_ci#define MODEL_OP_4800P 5 /* 32k, 96001 ASIC, 24 bit, 300x600, 8.5x11.69 */ 281141cc406Sopenharmony_ci#define MODEL_OP_4830P 6 /* 32k, 96003 ASIC, 30 bit, 300x600, 8.5x11.69 */ 282141cc406Sopenharmony_ci#define MODEL_OP_600P 7 /* 32k, 96003 ASIC, 30 bit, 300x600, 8.5x11.69 */ 283141cc406Sopenharmony_ci#define MODEL_OP_4831P 8 /* 128k, 96003 ASIC, 30 bit, 300x600, 8.5x11.69 */ 284141cc406Sopenharmony_ci#define MODEL_OP_9630P 9 /* 128k, 96003 ASIC, 30 bit, 600x1200, 8.5x11.69 */ 285141cc406Sopenharmony_ci#define MODEL_OP_9630PL 10 /* 128k, 96003 ASIC, 30 bit, 600x1200, 8.5x14 */ 286141cc406Sopenharmony_ci#define MODEL_OP_9636P 11 /* 512k, 98001 ASIC, 36 bit, 600x1200, 8.5x11.69 */ 287141cc406Sopenharmony_ci#define MODEL_OP_A3I 12 /* 128k, 96003 ASIC, 30 bit, 400x800, 11.69x17 */ 288141cc406Sopenharmony_ci#define MODEL_OP_12000P 13 /* 128k, 96003 ASIC, 30 bit, 600x1200, 8.5x11.69 */ 289141cc406Sopenharmony_ci#define MODEL_OP_9636PP 14 /* 512k, 98001 ASIC, 36 bit, 600x1200, 8.5x11.69 */ 290141cc406Sopenharmony_ci#define MODEL_OP_9636T 15 /* like OP_9636PP + transparency */ 291141cc406Sopenharmony_ci#define MODEL_OP_P8 16 /* 512k, 98003 ASIC, 36 bit, 300x600, 8.5x11.69 */ 292141cc406Sopenharmony_ci#define MODEL_OP_P12 17 /* 512k, 98003 ASIC, 36 bit, 600x1200, 8.5x11.69 */ 293141cc406Sopenharmony_ci#define MODEL_OP_PT12 18 /* like OP_P12 + transparency */ 294141cc406Sopenharmony_ci#define MODEL_GEN_CPV2 19 /* Genius Colorpage Vivid III V2, ASIC 98003 */ 295141cc406Sopenharmony_ci#define MODEL_UNKNOWN 20 /* not known/supported */ 296141cc406Sopenharmony_ci 297141cc406Sopenharmony_ci#define _NO_BASE 0xFFFF 298141cc406Sopenharmony_ci 299141cc406Sopenharmony_ci/******************** from former plustek-share.h ***************************/ 300141cc406Sopenharmony_ci 301141cc406Sopenharmony_ci/* 302141cc406Sopenharmony_ci * for other OS than Linux, we might have to define the _IO macros 303141cc406Sopenharmony_ci */ 304141cc406Sopenharmony_ci#ifndef _IOC 305141cc406Sopenharmony_ci#define _IOC(dir,type,nr,size) \ 306141cc406Sopenharmony_ci (((dir) << 30) | \ 307141cc406Sopenharmony_ci ((type) << 8) | \ 308141cc406Sopenharmony_ci ((nr) << 0) | \ 309141cc406Sopenharmony_ci ((size) << 16)) 310141cc406Sopenharmony_ci#endif 311141cc406Sopenharmony_ci 312141cc406Sopenharmony_ci#ifndef _IOC_DIR 313141cc406Sopenharmony_ci#define _IOC_DIR(cmd) (((cmd) >> 30) & 0x3) 314141cc406Sopenharmony_ci#endif 315141cc406Sopenharmony_ci 316141cc406Sopenharmony_ci#ifndef _IOC_SIZE 317141cc406Sopenharmony_ci#define _IOC_SIZE(cmd) (((cmd) >> 16) & 0x3FFF) 318141cc406Sopenharmony_ci#endif 319141cc406Sopenharmony_ci 320141cc406Sopenharmony_ci#ifndef _IOC_WRITE 321141cc406Sopenharmony_ci#define _IOC_WRITE 1U 322141cc406Sopenharmony_ci#endif 323141cc406Sopenharmony_ci 324141cc406Sopenharmony_ci#ifndef _IO 325141cc406Sopenharmony_ci#define _IO(type,nr) _IOC(0U,(type),(nr),0) 326141cc406Sopenharmony_ci#endif 327141cc406Sopenharmony_ci 328141cc406Sopenharmony_ci#ifndef _IOR 329141cc406Sopenharmony_ci#define _IOR(type,nr,size) _IOC(2U,(type),(nr),((UInt)sizeof(size))) 330141cc406Sopenharmony_ci#endif 331141cc406Sopenharmony_ci 332141cc406Sopenharmony_ci#ifndef _IOW 333141cc406Sopenharmony_ci#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),((UInt)sizeof(size))) 334141cc406Sopenharmony_ci#endif 335141cc406Sopenharmony_ci 336141cc406Sopenharmony_ci#ifndef _IOWR 337141cc406Sopenharmony_ci#define _IOWR(type,nr,size) _IOC(3U,(type),(nr),((UInt)sizeof(size))) 338141cc406Sopenharmony_ci#endif 339141cc406Sopenharmony_ci 340141cc406Sopenharmony_ci/*............................................................................. 341141cc406Sopenharmony_ci * the ioctl interface 342141cc406Sopenharmony_ci */ 343141cc406Sopenharmony_ci#define _PTDRV_OPEN_DEVICE _IOW('x', 1, unsigned short)/* open */ 344141cc406Sopenharmony_ci#define _PTDRV_GET_CAPABILITIES _IOR('x', 2, ScannerCaps) /* get caps */ 345141cc406Sopenharmony_ci#define _PTDRV_GET_LENSINFO _IOR('x', 3, LensInfo) /* get lenscaps */ 346141cc406Sopenharmony_ci#define _PTDRV_PUT_IMAGEINFO _IOW('x', 4, ImgDef) /* put image info*/ 347141cc406Sopenharmony_ci#define _PTDRV_GET_CROPINFO _IOR('x', 5, CropInfo) /* get crop */ 348141cc406Sopenharmony_ci#define _PTDRV_SET_ENV _IOWR('x',6, ScanInfo) /* set env. */ 349141cc406Sopenharmony_ci#define _PTDRV_START_SCAN _IOR('x', 7, StartScan) /* start scan */ 350141cc406Sopenharmony_ci#define _PTDRV_STOP_SCAN _IOWR('x', 8, short) /* stop scan */ 351141cc406Sopenharmony_ci#define _PTDRV_CLOSE_DEVICE _IO('x', 9) /* close */ 352141cc406Sopenharmony_ci#define _PTDRV_ACTION_BUTTON _IOR('x', 10, unsigned char)/* rd act. button*/ 353141cc406Sopenharmony_ci#define _PTDRV_ADJUST _IOR('x', 11, AdjDef) /* adjust driver */ 354141cc406Sopenharmony_ci#define _PTDRV_SETMAP _IOR('x', 12, MapDef) /* download gamma*/ 355141cc406Sopenharmony_ci 356141cc406Sopenharmony_ci/* 357141cc406Sopenharmony_ci * this version MUST match the one inside the driver to make sure, that 358141cc406Sopenharmony_ci * both sides use the same structures. This version changes each time 359141cc406Sopenharmony_ci * the ioctl interface changes 360141cc406Sopenharmony_ci */ 361141cc406Sopenharmony_ci#define _PTDRV_COMPAT_IOCTL_VERSION 0x0102 362141cc406Sopenharmony_ci#define _PTDRV_IOCTL_VERSION 0x0104 363141cc406Sopenharmony_ci 364141cc406Sopenharmony_ci/** for adjusting the parport stuff 365141cc406Sopenharmony_ci */ 366141cc406Sopenharmony_citypedef struct { 367141cc406Sopenharmony_ci int lampOff; 368141cc406Sopenharmony_ci int lampOffOnEnd; 369141cc406Sopenharmony_ci int warmup; 370141cc406Sopenharmony_ci int enableTpa; 371141cc406Sopenharmony_ci 372141cc406Sopenharmony_ci OffsDef pos; /* for adjusting normal scan area */ 373141cc406Sopenharmony_ci OffsDef tpa; /* for adjusting transparency scan area */ 374141cc406Sopenharmony_ci OffsDef neg; /* for adjusting negative scan area */ 375141cc406Sopenharmony_ci 376141cc406Sopenharmony_ci /* for adjusting the default gamma settings */ 377141cc406Sopenharmony_ci double rgamma; 378141cc406Sopenharmony_ci double ggamma; 379141cc406Sopenharmony_ci double bgamma; 380141cc406Sopenharmony_ci 381141cc406Sopenharmony_ci double graygamma; 382141cc406Sopenharmony_ci 383141cc406Sopenharmony_ci} PPAdjDef, *pPPAdjDef; 384141cc406Sopenharmony_ci 385141cc406Sopenharmony_ci/** for adjusting the scanner settings 386141cc406Sopenharmony_ci */ 387141cc406Sopenharmony_citypedef struct { 388141cc406Sopenharmony_ci 389141cc406Sopenharmony_ci int direct_io; 390141cc406Sopenharmony_ci int mov; 391141cc406Sopenharmony_ci 392141cc406Sopenharmony_ci int lampOff; 393141cc406Sopenharmony_ci int lampOffOnEnd; 394141cc406Sopenharmony_ci int warmup; 395141cc406Sopenharmony_ci 396141cc406Sopenharmony_ci OffsDef pos; /* for adjusting normal scan area */ 397141cc406Sopenharmony_ci OffsDef tpa; /* for adjusting transparency scan area */ 398141cc406Sopenharmony_ci OffsDef neg; /* for adjusting negative scan area */ 399141cc406Sopenharmony_ci 400141cc406Sopenharmony_ci /* for adjusting the default gamma settings */ 401141cc406Sopenharmony_ci double rgamma; 402141cc406Sopenharmony_ci double ggamma; 403141cc406Sopenharmony_ci double bgamma; 404141cc406Sopenharmony_ci 405141cc406Sopenharmony_ci double graygamma; 406141cc406Sopenharmony_ci 407141cc406Sopenharmony_ci} AdjDef, *pAdjDef; 408141cc406Sopenharmony_ci 409141cc406Sopenharmony_citypedef struct { 410141cc406Sopenharmony_ci unsigned long dwFlag; /* refer to SECTION (1.2) */ 411141cc406Sopenharmony_ci unsigned long dwBytesPerLine; 412141cc406Sopenharmony_ci unsigned long dwLinesPerScan; 413141cc406Sopenharmony_ci} StartScan, *pStartScan; 414141cc406Sopenharmony_ci 415141cc406Sopenharmony_citypedef struct { 416141cc406Sopenharmony_ci unsigned short wMin; /* minimum value */ 417141cc406Sopenharmony_ci unsigned short wDef; /* default value */ 418141cc406Sopenharmony_ci unsigned short wMax; /* software maximum value */ 419141cc406Sopenharmony_ci unsigned short wPhyMax; /* hardware maximum value (for DPI only)*/ 420141cc406Sopenharmony_ci} RANGE, *PRANGE; 421141cc406Sopenharmony_ci 422141cc406Sopenharmony_citypedef struct { 423141cc406Sopenharmony_ci RANGE rDataType; /* available scan modes */ 424141cc406Sopenharmony_ci unsigned long dwFlag; /* refer to SECTION (1.2) */ 425141cc406Sopenharmony_ci unsigned short wIOBase; /* refer to SECTION (1.3) */ 426141cc406Sopenharmony_ci unsigned short wMaxExtentX; /* scanarea width */ 427141cc406Sopenharmony_ci unsigned short wMaxExtentY; /* scanarea height */ 428141cc406Sopenharmony_ci unsigned short AsicID; /* copy of RegAsicID */ 429141cc406Sopenharmony_ci unsigned short Model; /* model as best we can determine */ 430141cc406Sopenharmony_ci} ScannerCaps, *pScannerCaps; 431141cc406Sopenharmony_ci 432141cc406Sopenharmony_citypedef struct { 433141cc406Sopenharmony_ci RANGE rDpiX; 434141cc406Sopenharmony_ci RANGE rDpiY; 435141cc406Sopenharmony_ci RANGE rExtentX; 436141cc406Sopenharmony_ci RANGE rExtentY; 437141cc406Sopenharmony_ci unsigned short wBeginX; /* offset from left */ 438141cc406Sopenharmony_ci unsigned short wBeginY; /* offset from top */ 439141cc406Sopenharmony_ci} LensInfo, *pLensInfo; 440141cc406Sopenharmony_ci 441141cc406Sopenharmony_citypedef struct { 442141cc406Sopenharmony_ci unsigned char* pDither; 443141cc406Sopenharmony_ci void* pMap; 444141cc406Sopenharmony_ci ImgDef ImgDef; 445141cc406Sopenharmony_ci unsigned short wMapType; /* refer to SECTION (3.2) */ 446141cc406Sopenharmony_ci unsigned short wDither; /* refer to SECTION (3.3) */ 447141cc406Sopenharmony_ci short siBrightness; /* refer to SECTION (3.5) */ 448141cc406Sopenharmony_ci short siContrast; /* refer to SECTION (3.6) */ 449141cc406Sopenharmony_ci} ScanInfo, *pScanInfo; 450141cc406Sopenharmony_ci 451141cc406Sopenharmony_ci 452141cc406Sopenharmony_ci/* IDs the ASIC returns */ 453141cc406Sopenharmony_ci#define _ASIC_IS_96001 0x0f /* value for 96001 */ 454141cc406Sopenharmony_ci#define _ASIC_IS_96003 0x10 /* value for 96003 */ 455141cc406Sopenharmony_ci#define _ASIC_IS_98001 0x81 /* value for 98001 */ 456141cc406Sopenharmony_ci#define _ASIC_IS_98003 0x83 /* value for 98003 */ 457141cc406Sopenharmony_ci 458141cc406Sopenharmony_ci#define _Transparency48OriginOffsetX 375 459141cc406Sopenharmony_ci#define _Transparency48OriginOffsetY 780 460141cc406Sopenharmony_ci 461141cc406Sopenharmony_ci#define _Transparency96OriginOffsetX 0x03DB /* org. was 0x0430 */ 462141cc406Sopenharmony_ci#define _Negative96OriginOffsetX 0x03F3 /* org. was 0x0428 */ 463141cc406Sopenharmony_ci 464141cc406Sopenharmony_ci/** Scanmodes 465141cc406Sopenharmony_ci */ 466141cc406Sopenharmony_ci#define _ScanMode_Color 0 467141cc406Sopenharmony_ci#define _ScanMode_AverageOut 1 /* CCD averaged 2 pixels value for output*/ 468141cc406Sopenharmony_ci#define _ScanMode_Mono 2 /* not color mode */ 469141cc406Sopenharmony_ci 470141cc406Sopenharmony_ci#define PLUSTEK_CONFIG_FILE "plustek_pp.conf" 471141cc406Sopenharmony_ci 472141cc406Sopenharmony_ci#ifndef PATH_MAX 473141cc406Sopenharmony_ci# define PATH_MAX 1024 474141cc406Sopenharmony_ci#endif 475141cc406Sopenharmony_ci 476141cc406Sopenharmony_ci/* 477141cc406Sopenharmony_ci * the default image size 478141cc406Sopenharmony_ci */ 479141cc406Sopenharmony_ci#define _DEFAULT_TLX 0 /* 0..216 mm */ 480141cc406Sopenharmony_ci#define _DEFAULT_TLY 0 /* 0..297 mm */ 481141cc406Sopenharmony_ci#define _DEFAULT_BRX 126 /* 0..216 mm*/ 482141cc406Sopenharmony_ci#define _DEFAULT_BRY 76.21 /* 0..297 mm */ 483141cc406Sopenharmony_ci 484141cc406Sopenharmony_ci#define _DEFAULT_TP_TLX 3.5 /* 0..42.3 mm */ 485141cc406Sopenharmony_ci#define _DEFAULT_TP_TLY 10.5 /* 0..43.1 mm */ 486141cc406Sopenharmony_ci#define _DEFAULT_TP_BRX 38.5 /* 0..42.3 mm */ 487141cc406Sopenharmony_ci#define _DEFAULT_TP_BRY 33.5 /* 0..43.1 mm */ 488141cc406Sopenharmony_ci 489141cc406Sopenharmony_ci#define _DEFAULT_NEG_TLX 1.5 /* 0..38.9 mm */ 490141cc406Sopenharmony_ci#define _DEFAULT_NEG_TLY 1.5 /* 0..29.6 mm */ 491141cc406Sopenharmony_ci#define _DEFAULT_NEG_BRX 37.5 /* 0..38.9 mm */ 492141cc406Sopenharmony_ci#define _DEFAULT_NEG_BRY 25.5 /* 0..29.6 mm */ 493141cc406Sopenharmony_ci 494141cc406Sopenharmony_ci/** image sizes for normal, transparent and negative modes 495141cc406Sopenharmony_ci */ 496141cc406Sopenharmony_ci#define _TP_X ((double)_TPAPageWidth/300.0 * MM_PER_INCH) 497141cc406Sopenharmony_ci#define _TP_Y ((double)_TPAPageHeight/300.0 * MM_PER_INCH) 498141cc406Sopenharmony_ci#define _NEG_X ((double)_NegativePageWidth/300.0 * MM_PER_INCH) 499141cc406Sopenharmony_ci#define _NEG_Y ((double)_NegativePageHeight/300.0 * MM_PER_INCH) 500141cc406Sopenharmony_ci 501141cc406Sopenharmony_ci/************************ some structures ************************************/ 502141cc406Sopenharmony_ci 503141cc406Sopenharmony_cienum { 504141cc406Sopenharmony_ci OPT_NUM_OPTS = 0, 505141cc406Sopenharmony_ci OPT_MODE_GROUP, 506141cc406Sopenharmony_ci OPT_MODE, 507141cc406Sopenharmony_ci OPT_EXT_MODE, 508141cc406Sopenharmony_ci OPT_RESOLUTION, 509141cc406Sopenharmony_ci OPT_PREVIEW, 510141cc406Sopenharmony_ci OPT_GEOMETRY_GROUP, 511141cc406Sopenharmony_ci OPT_TL_X, 512141cc406Sopenharmony_ci OPT_TL_Y, 513141cc406Sopenharmony_ci OPT_BR_X, 514141cc406Sopenharmony_ci OPT_BR_Y, 515141cc406Sopenharmony_ci OPT_ENHANCEMENT_GROUP, 516141cc406Sopenharmony_ci OPT_HALFTONE, 517141cc406Sopenharmony_ci OPT_BRIGHTNESS, 518141cc406Sopenharmony_ci OPT_CONTRAST, 519141cc406Sopenharmony_ci OPT_CUSTOM_GAMMA, 520141cc406Sopenharmony_ci OPT_GAMMA_VECTOR, 521141cc406Sopenharmony_ci OPT_GAMMA_VECTOR_R, 522141cc406Sopenharmony_ci OPT_GAMMA_VECTOR_G, 523141cc406Sopenharmony_ci OPT_GAMMA_VECTOR_B, 524141cc406Sopenharmony_ci NUM_OPTIONS 525141cc406Sopenharmony_ci}; 526141cc406Sopenharmony_ci 527141cc406Sopenharmony_ci/** for compatibility to version 0x0102 drivers 528141cc406Sopenharmony_ci */ 529141cc406Sopenharmony_citypedef struct { 530141cc406Sopenharmony_ci 531141cc406Sopenharmony_ci int lampOff; 532141cc406Sopenharmony_ci int lampOffOnEnd; 533141cc406Sopenharmony_ci int warmup; 534141cc406Sopenharmony_ci 535141cc406Sopenharmony_ci OffsDef pos; /* for adjusting normal scan area */ 536141cc406Sopenharmony_ci OffsDef tpa; /* for adjusting transparency scan area */ 537141cc406Sopenharmony_ci OffsDef neg; /* for adjusting negative scan area */ 538141cc406Sopenharmony_ci 539141cc406Sopenharmony_ci} CompatAdjDef, *pCompatAdjDef; 540141cc406Sopenharmony_ci 541141cc406Sopenharmony_ci/** 542141cc406Sopenharmony_ci */ 543141cc406Sopenharmony_citypedef struct Plustek_Device 544141cc406Sopenharmony_ci{ 545141cc406Sopenharmony_ci SANE_Int initialized; /* device already initialized? */ 546141cc406Sopenharmony_ci struct Plustek_Device *next; /* pointer to next dev in list */ 547141cc406Sopenharmony_ci int fd; /* device handle */ 548141cc406Sopenharmony_ci char *name; /* (to avoid compiler warnings!)*/ 549141cc406Sopenharmony_ci SANE_Device sane; /* info struct */ 550141cc406Sopenharmony_ci SANE_Int max_x; /* max XY-extension of the scan-*/ 551141cc406Sopenharmony_ci SANE_Int max_y; /* area */ 552141cc406Sopenharmony_ci SANE_Range dpi_range; /* resolution range */ 553141cc406Sopenharmony_ci SANE_Range x_range; /* x-range of the scan-area */ 554141cc406Sopenharmony_ci SANE_Range y_range; /* y-range of the scan-area */ 555141cc406Sopenharmony_ci SANE_Int *res_list; /* to hold the available phys. */ 556141cc406Sopenharmony_ci SANE_Int res_list_size; /* resolution values */ 557141cc406Sopenharmony_ci ScannerCaps caps; /* caps reported by the driver */ 558141cc406Sopenharmony_ci AdjDef adj; /* for driver adjustment */ 559141cc406Sopenharmony_ci 560141cc406Sopenharmony_ci /* 561141cc406Sopenharmony_ci * each device we support may need other access functions... 562141cc406Sopenharmony_ci */ 563141cc406Sopenharmony_ci int (*open) ( const char*, void* ); 564141cc406Sopenharmony_ci int (*close) ( struct Plustek_Device* ); 565141cc406Sopenharmony_ci void (*shutdown) ( struct Plustek_Device* ); 566141cc406Sopenharmony_ci int (*getCaps) ( struct Plustek_Device* ); 567141cc406Sopenharmony_ci int (*getLensInfo)( struct Plustek_Device*, pLensInfo ); 568141cc406Sopenharmony_ci int (*getCropInfo)( struct Plustek_Device*, pCropInfo ); 569141cc406Sopenharmony_ci int (*putImgInfo) ( struct Plustek_Device*, pImgDef ); 570141cc406Sopenharmony_ci int (*setScanEnv) ( struct Plustek_Device*, pScanInfo ); 571141cc406Sopenharmony_ci int (*setMap) ( struct Plustek_Device*, SANE_Word*, 572141cc406Sopenharmony_ci SANE_Word, SANE_Word ); 573141cc406Sopenharmony_ci int (*startScan) ( struct Plustek_Device*, pStartScan ); 574141cc406Sopenharmony_ci int (*stopScan) ( struct Plustek_Device*, short* ); 575141cc406Sopenharmony_ci int (*readImage) ( struct Plustek_Device*, SANE_Byte*, unsigned long ); 576141cc406Sopenharmony_ci 577141cc406Sopenharmony_ci int (*prepare) ( struct Plustek_Device*, SANE_Byte* ); 578141cc406Sopenharmony_ci int (*readLine) ( struct Plustek_Device* ); 579141cc406Sopenharmony_ci 580141cc406Sopenharmony_ci} Plustek_Device, *pPlustek_Device; 581141cc406Sopenharmony_ci 582141cc406Sopenharmony_ci#ifndef SANE_OPTION 583141cc406Sopenharmony_ci/* for compatibility with older versions */ 584141cc406Sopenharmony_citypedef union 585141cc406Sopenharmony_ci{ 586141cc406Sopenharmony_ci SANE_Word w; 587141cc406Sopenharmony_ci SANE_Word *wa; /* word array */ 588141cc406Sopenharmony_ci SANE_String s; 589141cc406Sopenharmony_ci} Option_Value; 590141cc406Sopenharmony_ci#endif 591141cc406Sopenharmony_ci 592141cc406Sopenharmony_citypedef struct Plustek_Scanner 593141cc406Sopenharmony_ci{ 594141cc406Sopenharmony_ci struct Plustek_Scanner *next; 595141cc406Sopenharmony_ci SANE_Pid reader_pid; /* process id of reader */ 596141cc406Sopenharmony_ci SANE_Status exit_code; /* status of the reader process */ 597141cc406Sopenharmony_ci int r_pipe; /* pipe to reader process */ 598141cc406Sopenharmony_ci int w_pipe; /* pipe from reader process */ 599141cc406Sopenharmony_ci unsigned long bytes_read; /* number of bytes currently read*/ 600141cc406Sopenharmony_ci Plustek_Device *hw; /* pointer to current device */ 601141cc406Sopenharmony_ci Option_Value val[NUM_OPTIONS]; 602141cc406Sopenharmony_ci SANE_Byte *buf; /* the image buffer */ 603141cc406Sopenharmony_ci SANE_Bool scanning; /* TRUE during scan-process */ 604141cc406Sopenharmony_ci SANE_Parameters params; /* for keeping the parameter */ 605141cc406Sopenharmony_ci 606141cc406Sopenharmony_ci /************************** gamma tables *********************************/ 607141cc406Sopenharmony_ci 608141cc406Sopenharmony_ci SANE_Word gamma_table[4][4096]; 609141cc406Sopenharmony_ci SANE_Range gamma_range; 610141cc406Sopenharmony_ci int gamma_length; 611141cc406Sopenharmony_ci 612141cc406Sopenharmony_ci SANE_Option_Descriptor opt[NUM_OPTIONS]; 613141cc406Sopenharmony_ci 614141cc406Sopenharmony_ci} Plustek_Scanner, *pPlustek_Scanner; 615141cc406Sopenharmony_ci 616141cc406Sopenharmony_ci/** for collecting configuration info... 617141cc406Sopenharmony_ci */ 618141cc406Sopenharmony_citypedef struct { 619141cc406Sopenharmony_ci 620141cc406Sopenharmony_ci char devName[PATH_MAX]; 621141cc406Sopenharmony_ci 622141cc406Sopenharmony_ci /* contains the stuff to adjust... */ 623141cc406Sopenharmony_ci AdjDef adj; 624141cc406Sopenharmony_ci 625141cc406Sopenharmony_ci} CnfDef, *pCnfDef; 626141cc406Sopenharmony_ci 627141cc406Sopenharmony_ci#endif /* guard __PLUSTEKPP_H__ */ 628141cc406Sopenharmony_ci 629141cc406Sopenharmony_ci/* END PLUSTEK-PP.H .........................................................*/ 630