1 /** @file u12-scanner.h 2 * @brief Definitions for the devices. 3 * 4 * Copyright (c) 2003-2004 Gerhard Jaeger <gerhard@gjaeger.de> 5 * 6 * History: 7 * - 0.01 - initial version 8 * - 0.02 - removed useless stuff 9 * . 10 * <hr> 11 * This file is part of the SANE package. 12 * 13 * This program is free software; you can redistribute it and/or 14 * modify it under the terms of the GNU General Public License as 15 * published by the Free Software Foundation; either version 2 of the 16 * License, or (at your option) any later version. 17 * 18 * This program is distributed in the hope that it will be useful, but 19 * WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program. If not, see <https://www.gnu.org/licenses/>. 25 * 26 * As a special exception, the authors of SANE give permission for 27 * additional uses of the libraries contained in this release of SANE. 28 * 29 * The exception is that, if you link a SANE library with other files 30 * to produce an executable, this does not by itself cause the 31 * resulting executable to be covered by the GNU General Public 32 * License. Your use of that executable is in no way restricted on 33 * account of linking the SANE library code into it. 34 * 35 * This exception does not, however, invalidate any other reasons why 36 * the executable file might be covered by the GNU General Public 37 * License. 38 * 39 * If you submit changes to SANE to the maintainers to be included in 40 * a subsequent release, you agree by submitting the changes that 41 * those changes may be distributed with this exception intact. 42 * 43 * If you write modifications of your own for SANE, it is your choice 44 * whether to permit this exception to apply to your modifications. 45 * If you do not wish that, delete this exception notice. 46 * <hr> 47 */ 48 #ifndef __U12_SCANNER_H__ 49 #define __U12_SCANNER_H__ 50 51 /* definitions for the timer functions 52 */ 53 typedef double TimerDef; 54 #define _MSECOND 1000 /* based on 1 us */ 55 #define _SECOND (1000*_MSECOND) 56 57 #if 1 58 #define _DO_UDELAY(usecs) u12io_udelay(usecs) 59 #define _DODELAY(msecs) u12io_udelay(1000*msecs) 60 /*{ int i; for( i = msecs; i--; ) _DO_UDELAY(1000); }*/ 61 #else 62 #define _DODELAY(msecs) 63 #endif 64 65 /* ModuleStates */ 66 #define _MotorInNormalState 0 67 #define _MotorGoBackward 1 68 #define _MotorInStopState 2 69 #define _MotorAdvancing 3 70 #define _MotorAdvanced 4 71 72 73 /** some function types 74 */ 75 typedef struct u12d *pU12_Device; 76 typedef struct svd *pShadingVarDef; 77 typedef void (*pFnVoid)(pU12_Device); 78 typedef void (*pFnDACOffs)(pU12_Device, pShadingVarDef, u_long); 79 typedef void (*pFnDACDark)(pU12_Device, pShadingVarDef, u_long, u_short); 80 typedef void (*pFnDataProcess)(pU12_Device, void*, void*, u_long); 81 typedef SANE_Bool (*pFnBool)(pU12_Device); 82 83 84 /* useful for RGB-values */ 85 typedef struct { 86 SANE_Byte Red; 87 SANE_Byte Green; 88 SANE_Byte Blue; 89 } RGBByteDef; 90 91 typedef struct { 92 u_short Red; 93 u_short Green; 94 u_short Blue; 95 } RGBUShortDef; 96 97 typedef struct { 98 u_long Red; 99 u_long Green; 100 u_long Blue; 101 } RGBULongDef; 102 103 typedef union { 104 RGBByteDef Colors; 105 SANE_Byte bColors[3]; 106 } ColorByte; 107 108 typedef union { 109 RGBUShortDef Colors; 110 u_short wColors[3]; 111 } ColorWord; 112 113 typedef union { 114 SANE_Byte *pb; 115 u_short *pw; 116 u_long *pdw; 117 RGBUShortDef *pusrgb; 118 RGBULongDef *pulrgb; 119 RGBByteDef *pbrgb; 120 } DataPointer; 121 122 typedef struct 123 { 124 union { 125 SANE_Byte *bp; 126 u_short *usp; 127 u_long *ulp; 128 } red; 129 union { 130 SANE_Byte *bp; 131 u_short *usp; 132 u_long *ulp; 133 } green; 134 union { 135 SANE_Byte *bp; 136 u_short *usp; 137 u_long *ulp; 138 } blue; 139 140 } RBGPtrDef; 141 142 typedef struct { 143 SANE_Byte b1st; 144 SANE_Byte b2nd; 145 } WordVal; 146 147 typedef struct { 148 WordVal w1st; 149 WordVal w2nd; 150 } DWordVal; 151 152 153 typedef union { 154 WordVal wOverlap; 155 DWordVal dwOverlap; 156 u_long dwValue; 157 u_short wValue; 158 SANE_Byte bValue; 159 } DataType; 160 161 typedef struct { 162 u_short exposureTime; 163 u_short xStepTime; 164 } ExpXStepDef; 165 166 typedef struct { 167 SANE_Byte reg; 168 SANE_Byte val; 169 } RegDef; 170 171 /** for defining a point 172 */ 173 typedef struct { 174 u_short x; 175 u_short y; 176 } XY; 177 178 /** for defining a crop area, all is 300DPI based 179 */ 180 typedef struct { 181 u_short x; /**< x-pos of top-left corner */ 182 u_short y; /**< y-pos of top-left corner */ 183 u_short cx; /**< width */ 184 u_short cy; /**< height */ 185 } CropRect; 186 187 /** for defining an image 188 */ 189 typedef struct { 190 u_long dwFlag; /**< i.e. image source */ 191 CropRect crArea; /**< the image size and position */ 192 XY xyDpi; /**< the resolution */ 193 u_short wDataType; /**< and the data type */ 194 } ImgDef; 195 196 /** 197 */ 198 typedef struct { 199 u_long dwPixelsPerLine; 200 u_long dwBytesPerLine; 201 u_long dwLinesPerArea; 202 ImgDef image; 203 } CropInfo; 204 205 /** all we need for a scan 206 */ 207 typedef struct 208 { 209 u_long dwScanFlag; 210 double xyRatio; /**< for scaling */ 211 u_short wYSum; 212 213 XY xyPhyDpi; /**< physical resolution of a scan */ 214 u_long dwPhysBytesPerLine; 215 u_long wPhyDataType; /**< how the scanner should scan */ 216 217 u_long dwAsicPixelsPerPlane; 218 u_long dwAsicBytesPerPlane; 219 u_long dwAsicBytesPerLine; 220 221 XY xyAppDpi; 222 u_long dwAppLinesPerArea; 223 u_long dwAppPixelsPerLine; 224 u_long dwAppPhyBytesPerLine; 225 u_long dwAppBytesPerLine; 226 u_short wAppDataType; 227 228 short siBrightness; 229 short siContrast; 230 231 CropRect crImage; 232 } DataInfo; 233 234 /** this will be our global "overkill" structure 235 */ 236 typedef struct 237 { 238 pFnDataProcess DataProcess; /* to convert RGB buffers to RGB pixels */ 239 pFnBool DoSample; 240 pFnBool DataRead; /* function to get data from scanner */ 241 242 long lBufferAdjust; 243 u_long dwScanOrigin; /* where to start the scan */ 244 u_long negBegin; /* used while scanning in TPA modes */ 245 u_long posBegin; 246 SANE_Byte bDiscardAll; 247 248 union { 249 u_short wGreenDiscard; 250 u_short wGreenKeep; 251 } gd_gk; 252 union { 253 u_short wBlueDiscard; 254 u_short wRedKeep; 255 } bd_rk; 256 257 u_long dpiIdx; /* index to get/set values in the table */ 258 ExpXStepDef *negScan; /* reference to exposure/xtep table */ 259 260 DataPointer p48BitBuf; /* for handling 48-bit data */ 261 RBGPtrDef BufBegin; /* for reading/writing the scan-data */ 262 RBGPtrDef BufEnd; 263 RBGPtrDef BufGet; 264 RBGPtrDef BufData; 265 RBGPtrDef BufPut; 266 267 /* motor movement stuff */ 268 u_long dwInterval; 269 SANE_Bool refreshState; 270 SANE_Bool motorBackward; 271 SANE_Byte oldScanState; 272 SANE_Byte bRefresh; 273 SANE_Byte bModuleState; 274 SANE_Byte bNowScanState; 275 276 /* internal FIFO management */ 277 u_long dwMinReadFifo; 278 u_long dwMaxReadFifo; 279 SANE_Byte bFifoSelect; /* defines which FIFO to use */ 280 281 } ScanInfo; 282 283 /** structure for accessing one buffer in various ways... 284 */ 285 typedef struct 286 { 287 union { 288 SANE_Byte *pReadBuf; 289 SANE_Byte *pShadingMap; 290 u_short *pShadingRam; 291 DataPointer Buf; 292 } b1; 293 294 union { 295 SANE_Byte *pSumBuf; 296 RGBUShortDef *pSumRGB; 297 } b2; 298 299 DataPointer TpaBuf; 300 } BufferDef; 301 302 #endif /* guard __U12_SCANNER_H__ */ 303 304 /* END U12-SCANNER.H ........................................................*/ 305