1 /** @file u12.h 2 * @brief Definitions for the backend. 3 * 4 * Copyright (c) 2003-2004 Gerhard Jaeger <gerhard@gjaeger.de> 5 * 6 * History: 7 * - 0.01 - initial version 8 * - 0.02 - added scaling variables to struct u12d 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_H__ 49 #define __U12_H__ 50 51 #ifndef SANE_OPTION 52 /* for compatibility with older versions */ 53 typedef union 54 { 55 SANE_Word w; 56 SANE_Word *wa; /* word array */ 57 SANE_String s; 58 } Option_Value; 59 #endif 60 61 /************************ some definitions ***********************************/ 62 63 #define U12_CONFIG_FILE "u12.conf" 64 65 #ifndef PATH_MAX 66 # define PATH_MAX 1024 67 #endif 68 69 #define _MM_PER_INCH 25.4 70 #define _MEASURE_BASE 300UL 71 #define _DEF_DPI 50 72 73 /** the default image 74 */ 75 #define _DEFAULT_TLX 0 76 #define _DEFAULT_TLY 0 77 #define _DEFAULT_BRX 126 78 #define _DEFAULT_BRY 76 79 80 #define _DEFAULT_TP_TLX 3.5 81 #define _DEFAULT_TP_TLY 10.5 82 #define _DEFAULT_TP_BRX 38.5 83 #define _DEFAULT_TP_BRY 33.5 84 85 #define _DEFAULT_NEG_TLX 1.5 86 #define _DEFAULT_NEG_TLY 1.5 87 #define _DEFAULT_NEG_BRX 37.5 88 #define _DEFAULT_NEG_BRY 25.5 89 90 /** image sizes for normal, transparent and negative modes 91 */ 92 #define _TPAPageWidth 500U 93 #define _TPAPageHeight 510U 94 #define _TPAMinDpi 150 95 #define _TPAModeSupportMin COLOR_TRUE24 96 97 #define _NegativePageWidth 460UL 98 #define _NegativePageHeight 350UL 99 100 #define _TP_X ((double)_TPAPageWidth/300.0 * _MM_PER_INCH) 101 #define _TP_Y ((double)_TPAPageHeight/300.0 * _MM_PER_INCH) 102 #define _NEG_X ((double)_NegativePageWidth/300.0 * _MM_PER_INCH) 103 #define _NEG_Y ((double)_NegativePageHeight/300.0 * _MM_PER_INCH) 104 105 /** scan modes 106 */ 107 #define COLOR_BW 0 108 #define COLOR_256GRAY 1 109 #define COLOR_TRUE24 2 110 #define COLOR_TRUE42 3 111 112 #define _VAR_NOT_USED(x) ((x)=(x)) 113 114 115 /** usb id buffer 116 */ 117 #define _MAX_ID_LEN 20 118 119 /** Scanmodes 120 */ 121 #define _ScanMode_Color 0 122 #define _ScanMode_AverageOut 1 /* CCD averaged 2 pixels value for output*/ 123 #define _ScanMode_Mono 2 /* not color mode */ 124 125 /** Scansource + additional flags 126 */ 127 #define _SCANDEF_PREVIEW 0x00000001 128 #define _SCANDEF_Transparency 0x00000100 129 #define _SCANDEF_Negative 0x00000200 130 #define _SCANDEF_TPA (_SCANDEF_Transparency | _SCANDEF_Negative) 131 #define _SCANDEF_SCANNING 0x8000000 132 133 /** for Gamma tables 134 */ 135 #define _MAP_RED 0 136 #define _MAP_GREEN 1 137 #define _MAP_BLUE 2 138 #define _MAP_MASTER 3 139 140 /** the ASIC modes */ 141 #define _PP_MODE_SPP 0 142 #define _PP_MODE_EPP 1 143 144 /************************ some structures ************************************/ 145 146 enum { 147 OPT_NUM_OPTS = 0, 148 OPT_MODE_GROUP, 149 #ifdef ALL_MODES 150 OPT_MODE, 151 OPT_EXT_MODE, 152 #endif 153 OPT_RESOLUTION, 154 OPT_PREVIEW, 155 OPT_GEOMETRY_GROUP, 156 OPT_TL_X, 157 OPT_TL_Y, 158 OPT_BR_X, 159 OPT_BR_Y, 160 OPT_ENHANCEMENT_GROUP, 161 OPT_BRIGHTNESS, 162 OPT_CONTRAST, 163 OPT_CUSTOM_GAMMA, 164 OPT_GAMMA_VECTOR, 165 OPT_GAMMA_VECTOR_R, 166 OPT_GAMMA_VECTOR_G, 167 OPT_GAMMA_VECTOR_B, 168 NUM_OPTIONS 169 }; 170 171 /** for adjusting the scanner settings 172 */ 173 typedef struct { 174 int lampOff; 175 int lampOffOnEnd; 176 int warmup; 177 178 /* for adjusting the default gamma settings */ 179 double rgamma; 180 double ggamma; 181 double bgamma; 182 double graygamma; 183 184 /* for adjusting scan-area */ 185 long upNormal; 186 long upPositive; 187 long upNegative; 188 long leftNormal; 189 190 } AdjDef, *pAdjDef; 191 192 /** for holding basic capabilities 193 */ 194 typedef struct { 195 unsigned short scanAreaX; 196 unsigned short scanAreaY; 197 unsigned long flag; 198 #if 0 199 RANGE rDataType; /* available scan modes */ 200 unsigned short wMaxExtentX; /* scanarea width */ 201 unsigned short wMaxExtentY; /* scanarea height */ 202 #endif 203 } ScannerCaps, *pScannerCaps; 204 205 206 /** for defining the scanmodes 207 */ 208 typedef const struct mode_param 209 { 210 int color; 211 int depth; 212 int scanmode; 213 } ModeParam, *pModeParam; 214 215 /** Here we hold all device specific data 216 */ 217 typedef struct u12d 218 { 219 SANE_Bool initialized; /* device already initialized? */ 220 struct u12d *next; /* pointer to next dev in list */ 221 int fd; /* device handle */ 222 int mode; 223 char *name; /* (to avoid compiler warnings!)*/ 224 SANE_Device sane; /* info struct */ 225 226 /* scan-area settings */ 227 SANE_Int max_x; /* max XY-extension of the scan-*/ 228 SANE_Int max_y; /* area */ 229 SANE_Range x_range; /* x-range of the scan-area */ 230 SANE_Range y_range; /* y-range of the scan-area */ 231 232 /* resolution settings */ 233 SANE_Int dpi_max_x; /* */ 234 SANE_Int dpi_max_y; /* */ 235 SANE_Range dpi_range; /* resolution range */ 236 237 SANE_Int *res_list; /* to hold the available phys. */ 238 SANE_Int res_list_size; /* resolution values */ 239 ScannerCaps caps; /* caps reported by the driver */ 240 AdjDef adj; /* for driver adjustment */ 241 242 char usbId[_MAX_ID_LEN];/* to keep Vendor and product */ 243 /* ID string (from conf) file */ 244 /* our gamma tables */ 245 SANE_Word gamma_table[4][4096]; 246 SANE_Range gamma_range; 247 int gamma_length; 248 249 /* the shading section */ 250 pFnDACOffs fnDarkOffset; /**< ... */ 251 ShadingDef shade; /**< shading parameters */ 252 253 /* */ 254 SANE_Byte PCBID; /**< which version of the PCB */ 255 256 /* motor control section */ 257 SANE_Byte MotorID; /**< the type of the motor drivers */ 258 SANE_Byte MotorPower; /**< how to drive the motor */ 259 SANE_Bool f2003; 260 SANE_Byte XStepMono; 261 SANE_Byte XStepColor; 262 SANE_Byte XStepBack; 263 SANE_Bool f0_8_16; 264 SANE_Byte scanStates[_SCANSTATE_BYTES]; 265 266 /* CCD section */ 267 SANE_Byte CCDID; /**< what CCD do we have */ 268 RegDef *CCDRegs; /**< pointer to the register descr */ 269 u_short numCCDRegs; /**< number of values to write */ 270 271 /* DAC section */ 272 SANE_Byte DACType; /**< what DAC do we have */ 273 RegDef *DACRegs; /**< pointer to DAC reg descr. */ 274 u_short numDACRegs; /**< number of values to write */ 275 pFnDACDark fnDACDark; /**< */ 276 RGBByteDef RegDACOffset; 277 RGBByteDef RegDACGain; 278 279 ShadowRegs regs; /**< for holding ASIC register values */ 280 DataInfo DataInf; /**< all static info about the current scan */ 281 ScanInfo scan; /**< buffer and motor management during scan */ 282 BufferDef bufs; 283 void *scaleBuf; /**< buffer for line scaling */ 284 int scaleStep; /**< step size for line scaling */ 285 int scaleIzoom; /**< factor for line scaling */ 286 287 u_long ModelOriginY; 288 SANE_Byte ModelCtrl; 289 290 SANE_Bool Tpa; /**< do we have a TPA */ 291 SANE_Byte Buttons; /**< number of buttons */ 292 293 /* lamp control section */ 294 SANE_Bool warmupNeeded; 295 SANE_Byte lastLampStatus; /**< for keeping the lamp status */ 296 297 #ifdef HAVE_SETITIMER 298 struct itimerval saveSettings; /**< for lamp timer */ 299 #endif 300 } U12_Device; 301 302 typedef struct u12s 303 { 304 struct u12s *next; 305 SANE_Pid reader_pid; /* process id of reader */ 306 SANE_Status exit_code; /* status of the reader process */ 307 int r_pipe; /* pipe to reader process */ 308 int w_pipe; /* pipe from reader process */ 309 unsigned long bytes_read; /* number of bytes currently read*/ 310 U12_Device *hw; /* pointer to current device */ 311 Option_Value val[NUM_OPTIONS]; 312 SANE_Byte *buf; /* the image buffer */ 313 SANE_Bool scanning; /* TRUE during scan-process */ 314 SANE_Parameters params; /* for keeping the parameter */ 315 316 SANE_Option_Descriptor opt[NUM_OPTIONS]; 317 318 } U12_Scanner; 319 320 /** for collecting configuration info... 321 */ 322 typedef struct { 323 324 char devName[PATH_MAX]; 325 char usbId[_MAX_ID_LEN]; 326 327 /* contains the stuff to adjust... */ 328 AdjDef adj; 329 330 } CnfDef, *pCnfDef; 331 332 #endif /* guard __U12_H__ */ 333 334 /* END U12.H ................................................................*/ 335