1 /************************************************************************************\
3 hpaio.h - HP SANE backend for multi-function peripherals (libsane-hpaio)
5 (c) 2001-2006 Copyright Hewlett-Packard Development Company, LP
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11 of the Software, and to permit persons to whom the Software is furnished to do
12 so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 Contributing Authors: David Paschal, Don Welch, David Suffield
26 \************************************************************************************/
28 #if !defined( __HPAIO_H__ )
38 /************************************************************************************/
40 #define MAX_DEVICE 64 /* Max devices. */
42 #define LEN_BUFFER 17408 /* 16384 + 1024, clj28xx used 16396 */
43 #define LEN_DEVICE_ID_STRING 4096
44 #define LEN_STRING_OPTION_VALUE 20
45 #define LEN_MODEL_RESPONSE 20
47 #define PAD_VALUE_LINEART 0
48 #define PAD_VALUE_GRAYSCALE_COLOR -1
53 OPTION_NUM_OPTIONS = 0,
57 OPTION_SCAN_RESOLUTION,
61 OPTION_JPEG_COMPRESSION_FACTOR,
67 OPTION_LENGTH_MEASUREMENT,
75 //#define STR_SCAN_MODE_LINEART "Lineart"
76 //#define STR_SCAN_MODE_GRAYSCALE "Grayscale"
77 //#define STR_SCAN_MODE_COLOR "Color"
79 enum hpaioScanMode_e { SCAN_MODE_FIRST = 0,
80 SCAN_MODE_LINEART = 0,
86 #define COMPRESSION_NONE 0x01
87 #define COMPRESSION_MH 0x02
88 #define COMPRESSION_MR 0x04
89 #define COMPRESSION_MMR 0x08
90 #define COMPRESSION_JPEG 0x10
92 #define ADF_MODE_AUTO 0x01 /* flatbed or ADF */
93 #define ADF_MODE_FLATBED 0x02 /* flatbed only */
94 #define ADF_MODE_ADF 0x04 /* ADF only */
96 #define LENGTH_MEASUREMENT_UNKNOWN 0
97 #define LENGTH_MEASUREMENT_UNLIMITED 1
98 #define LENGTH_MEASUREMENT_APPROXIMATE 2
99 #define LENGTH_MEASUREMENT_PADDED 3
100 #define LENGTH_MEASUREMENT_EXACT 4
102 struct hpaioScanner_s
104 char *tag; /* handle identifier */
106 HPMUD_DEVICE deviceid;
107 HPMUD_CHANNEL scan_channelid;
108 HPMUD_CHANNEL cmd_channelid;
110 struct hpaioScanner_s * prev;
111 struct hpaioScanner_s * next;
113 SANE_Device saneDevice; /* "vendor", "model" dynamically allocated. */
114 SANE_Parameters prescanParameters;
115 SANE_Parameters scanParameters;
117 struct PmlObject_s * firstPmlObject;
118 struct PmlObject_s * lastPmlObject;
120 enum { SCANNER_TYPE_SCL, SCANNER_TYPE_PML } scannerType;
121 int decipixelsPerInch;
123 /* These are bitfields of COMPRESSION_* values. */
124 int supportsScanMode[SCAN_MODE_LAST];
125 SANE_String_Const scanModeList[MAX_LIST_SIZE];
126 enum hpaioScanMode_e currentScanMode, effectiveScanMode;
128 SANE_Range resolutionRange;
129 SANE_Int resolutionList[MAX_LIST_SIZE];
130 SANE_Int lineartResolutionList[MAX_LIST_SIZE]; /* 300 dpi. */
131 SANE_Int currentResolution, effectiveResolution;
133 SANE_Range contrastRange;
134 SANE_Int defaultContrast, currentContrast;
136 SANE_String_Const compressionList[MAX_LIST_SIZE];
137 int defaultCompression[SCAN_MODE_LAST];
138 SANE_Int currentCompression; /* One of the COMPRESSION_* values. */
140 SANE_Range jpegCompressionFactorRange;
141 SANE_Int defaultJpegCompressionFactor;
142 SANE_Int currentJpegCompressionFactor;
144 SANE_Bool currentBatchScan;
146 int alreadyPreAdvancedDocument;
147 int alreadyPostAdvancedDocument;
148 int noDocsConditionPending;
150 int supportedAdfModes;
151 SANE_String_Const adfModeList[MAX_LIST_SIZE];
153 int currentPageNumber;
156 SANE_Bool currentDuplex;
157 int currentSideNumber;
159 SANE_Int currentLengthMeasurement;
160 SANE_String_Const lengthMeasurementList[MAX_LIST_SIZE];
162 SANE_Range tlxRange, tlyRange, brxRange, bryRange;
163 SANE_Fixed currentTlx, currentTly, currentBrx, currentBry;
164 SANE_Fixed effectiveTlx,
169 SANE_Option_Descriptor option[OPTION_LAST];
176 unsigned char inBuffer[LEN_BUFFER]; /* mfpdtf block buffer */
178 int bufferBytesRemaining;
179 int totalBytesRemaining;
181 int BlockSize; /* mfpdtf block size, including fixed header */
182 int BlockIndex; /* record index in mfpdtf block */
183 int RecordSize; /* record size, does not include header */
184 int RecordIndex; /* data index in record */
186 int mfpdtf_timeout_cnt;
187 int pml_timeout_cnt; /* pml done timeout count */
191 int upload_state; /* last pml upload state */
192 int user_cancel; /* user cancelled operation */
196 char compat1150[LEN_MODEL_RESPONSE + 1];
197 char compatPost1150[LEN_MODEL_RESPONSE + 1];
202 int maxXExtent, maxYExtent;
204 int flatbedCapability, adfCapability;
205 int minResAdf, maxResAdf;
207 PmlObject_t objSupportedFunctions;
212 PmlObject_t objScannerStatus,
219 objCompressionFactor,
223 objSharpeningCoefficient,
224 objNeutralClipThresholds,
230 char scanToken[ PML_MAX_VALUE_LEN ];
231 char zeroScanToken[ PML_MAX_VALUE_LEN ];
236 int dontResetBeforeNextNonBatchPage;
237 int startNextBatchPageEarly;
238 int flatbedCapability;
240 int alreadyRestarted;
242 int previousUploadState;
246 typedef struct hpaioScanner_s * hpaioScanner_t;
247 typedef struct hpaioScanner_s HPAIO_RECORD;
249 #define UNDEFINED_MODEL(hpaio) (!hpaio->saneDevice.model)
251 #define _SET_DEFAULT_MODEL(hpaio,s,len) \
253 if (UNDEFINED_MODEL(hpaio)) { \
254 hpaio->saneDevice.model=malloc(len+1); \
255 memcpy((char *)hpaio->saneDevice.model,s,len); \
256 ((char *)hpaio->saneDevice.model)[len]=0; \
259 #define SET_DEFAULT_MODEL(hpaio,s) _SET_DEFAULT_MODEL(hpaio,s,strlen(s))
261 #define FIX_GEOMETRY(low,high,min,max) \
263 if (high<low) high=low; \
273 SANE_Status __attribute__ ((visibility ("hidden"))) hpaioScannerToSaneStatus( hpaioScanner_t hpaio );
274 SANE_Status __attribute__ ((visibility ("hidden"))) hpaioScannerToSaneError( hpaioScanner_t hpaio );
275 void sane_hpaio_cancel(SANE_Handle handle);