Tizen 2.1 base
[platform/upstream/hplip.git] / scan / sane / pml.h
1 /************************************************************************************\
2
3   pml.h - HP SANE backend for multi-function peripherals (libsane-hpaio)
4
5   (c) 2001-2005 Copyright Hewlett-Packard Development Company, LP
6
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:
13
14   The above copyright notice and this permission notice shall be included in all
15   copies or substantial portions of the Software.
16
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.
23
24   Contributing Author(s): David Paschal, Don Welch, David Suffield
25
26 \************************************************************************************/
27
28 #if !defined(_PML_H)
29 #define _PML_H
30
31 #include "sane.h"
32
33 #define PML_MAX_OID_VALUES 2
34 #define PML_MAX_VALUE_LEN       1023
35 #define PML_MAX_OID_LEN     128
36 #define PML_MAX_DATALEN     4096
37
38 #define PML_TYPE_MASK           0xFC
39 #define PML_TYPE_OBJECT_IDENTIFIER      0x00
40 #define PML_TYPE_ENUMERATION        0x04
41 #define PML_TYPE_SIGNED_INTEGER     0x08
42 #define PML_TYPE_REAL           0x0C
43 #define PML_TYPE_STRING         0x10
44 #define PML_TYPE_BINARY         0x14
45 #define PML_TYPE_ERROR_CODE     0x18
46 #define PML_TYPE_NULL_VALUE     0x1C
47 #define PML_TYPE_COLLECTION     0x20
48
49 #define PML_SYMSET_0E               0x000E
50 #define PML_SYMSET_ISO_8859_2_LATIN_2       0x004E
51 #define PML_SYMSET_ISO_8859_9_LATIN_5       0x00AE
52 #define PML_SYMSET_KANA8                0x010B
53 #define PML_SYMSET_ROMAN8               0x0115
54 #define PML_SYMSET_ISO_8859_5_LATIN_CYRILLIC    0x014E
55 #define PML_SYMSET_US_UNICODE           0x024E
56 #define PML_SYMSET_UTF8_UNICODE         0xFDE8
57
58 #define PML_OK                  0x00
59 #define PML_OK_END_OF_SUPPORTED_OBJECTS     0x01
60 #define PML_OK_NEAREST_LEGAL_VALUE_SUBSTITUTED  0x02
61 #define PML_ERROR                   0x80
62 #define PML_ERROR_UNKNOWN_REQUEST           0x80
63 #define PML_ERROR_BUFFER_OVERFLOW           0x81
64 #define PML_ERROR_COMMAND_EXECUTION_ERROR       0x82
65 #define PML_ERROR_UNKNOWN_OBJECT_IDENTIFIER 0x83
66 #define PML_ERROR_OBJECT_DOES_NOT_SUPPORT_REQUESTED_ACTION  0x84
67 #define PML_ERROR_INVALID_OR_UNSUPPORTED_VALUE  0x85
68 #define PML_ERROR_PAST_END_OF_SUPPORTED_OBJECTS 0x86
69 #define PML_ERROR_ACTION_CAN_NOT_BE_PERFORMED_NOW   0x87
70 #define PML_ERROR_SYNTAX_ERROR          0x88
71
72 struct PmlValue_s
73 {
74         int     type;
75         int     len;
76         char    value[ PML_MAX_VALUE_LEN + 1 ];  // null terminated
77 }; // PmlValue_s, * PmlValue_t;
78
79 typedef struct PmlValue_s * PmlValue_t;
80
81 //extern hpaioScanner_t;
82
83
84 struct PmlObject_s
85 {
86         //struct hpaioScanner_s *          dev;
87         struct PmlObject_s *          prev;
88         struct PmlObject_s *          next;
89         char                    oid[ PML_MAX_OID_LEN + 1 ];  /* ascii, null terminated */
90         int                     indexOfLastValue;
91         int                     numberOfValidValues;
92         struct PmlValue_s       value[ PML_MAX_OID_VALUES ];
93         int                     status;
94 }; // , * PmlObject_t;
95
96 typedef struct PmlObject_s * PmlObject_t;
97
98 #include "hpaio.h"
99
100 #define PML_REQUEST_GET        0x00
101 #define PML_REQUEST_GETNEXT    0x01
102 #define PML_REQUEST_SET        0x04
103 #define PML_REQUEST_TRAP_ENABLE    0x05
104 #define PML_REQUEST_TRAP_DISABLE   0x06
105 #define PML_REQUEST_TRAP       0x07
106 #define PML_COMMAND_MASK       0x7F
107 #define PML_COMMAND_REPLY      0x80
108 #define PML_SELECT_POLL_TIMEOUT       1
109 #define PML_UPLOAD_TIMEOUT        45
110 #define PML_START_SCAN_WAIT_ACTIVE_MAX_RETRIES    40
111 #define PML_START_SCAN_WAIT_ACTIVE_DELAY    1
112 #define PML_MAX_WIDTH_INCHES    9
113 #define PML_MAX_HEIGHT_INCHES 15
114
115 #define PML_SCANNER_STATUS_UNKNOWN_ERROR  0x01
116 #define PML_SCANNER_STATUS_INVALID_MEDIA_SIZE 0x02
117 #define PML_SCANNER_STATUS_FEEDER_OPEN    0x04
118 #define PML_SCANNER_STATUS_FEEDER_JAM   0x08
119 #define PML_SCANNER_STATUS_FEEDER_EMPTY   0x10
120
121 #define PML_DATA_TYPE_LINEART   1
122 #define PML_DATA_TYPE_GRAYSCALE   8
123 #define PML_DATA_TYPE_COLOR   24
124
125 #define PML_CONTRAST_MIN    0
126 #define PML_CONTRAST_MAX    100
127 #define PML_CONTRAST_DEFAULT    50
128
129 #define PML_COMPRESSION_NONE    1
130 #define PML_COMPRESSION_DEFAULT   2
131 #define PML_COMPRESSION_MH    3
132 #define PML_COMPRESSION_MR    4
133 #define PML_COMPRESSION_MMR   5
134 #define PML_COMPRESSION_JPEG    6
135
136 #define PML_MODHW_ADF     1
137
138 #define PML_UPLOAD_STATE_IDLE   1
139 #define PML_UPLOAD_STATE_START    2
140 #define PML_UPLOAD_STATE_ACTIVE   3
141 #define PML_UPLOAD_STATE_ABORTED  4
142 #define PML_UPLOAD_STATE_DONE   5
143 #define PML_UPLOAD_STATE_NEWPAGE  6
144
145 #define PML_UPLOAD_ERROR_SCANNER_JAM    207
146 #define PML_UPLOAD_ERROR_MLC_CHANNEL_CLOSED 208
147 #define PML_UPLOAD_ERROR_STOPPED_BY_HOST  209
148 #define PML_UPLOAD_ERROR_STOP_KEY_PRESSED 210
149 #define PML_UPLOAD_ERROR_NO_DOC_IN_ADF    211
150 #define PML_UPLOAD_ERROR_COVER_OPEN   213
151 #define PML_UPLOAD_ERROR_DOC_LOADED   214
152 #define PML_UPLOAD_ERROR_DEVICE_BUSY    216
153
154 #define PML_SUPPFUNC_DUPLEX   0x00000008
155
156 struct PmlResolution
157 {
158         unsigned char   x[4];
159         unsigned char   y[4];
160 } __attribute__(( packed));
161
162 int __attribute__ ((visibility ("hidden"))) PmlSetID(PmlObject_t obj, char * oid);
163 int __attribute__ ((visibility ("hidden"))) PmlSetValue(PmlObject_t obj, int type, char * value, int len);
164 int __attribute__ ((visibility ("hidden"))) PmlSetIntegerValue(PmlObject_t obj, int type, int value);
165 int __attribute__ ((visibility ("hidden"))) PmlGetValue(PmlObject_t obj, int * pType, char * buffer, int maxlen);
166 int __attribute__ ((visibility ("hidden"))) PmlGetStringValue(PmlObject_t obj, int * pSymbolSet, char * buffer, int maxlen);
167 int __attribute__ ((visibility ("hidden"))) PmlGetIntegerValue(PmlObject_t obj, int * pType, int * pValue);
168 int __attribute__ ((visibility ("hidden"))) PmlRequestSet(int deviceid, int channelid, PmlObject_t obj);
169 int __attribute__ ((visibility ("hidden"))) PmlRequestSetRetry(int deviceid, int channelid, PmlObject_t obj, int count, int delay);
170 int __attribute__ ((visibility ("hidden"))) PmlRequestGet(int deviceid, int channelid, PmlObject_t obj);
171
172 /*
173  * Phase 2 rewrite. des
174  */
175 struct hpaioScanner_s;
176
177 int __attribute__ ((visibility ("hidden"))) pml_start(struct hpaioScanner_s *hpaio);
178 int __attribute__ ((visibility ("hidden"))) pml_read(struct hpaioScanner_s *hpaio, SANE_Byte *data, SANE_Int maxLength, SANE_Int *pLength);
179 int __attribute__ ((visibility ("hidden"))) pml_cancel(struct hpaioScanner_s *hpaio);
180
181 #endif // _PML_H