Tizen 2.1 base
[platform/upstream/hplip.git] / scan / sane / scl.h
1 /************************************************************************************\
2
3   scl.h - HP SANE backend for multi-function peripherals (libsane-hpaio)
4
5   (c) 2001-2006 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 Authors: David Paschal, Don Welch, David Suffield 
25
26 \************************************************************************************/
27
28 #if !defined( __SCL_H__ )
29 #define __SCL_H__ 
30
31 #include "sane.h"
32
33 #define SCL_SEND_COMMAND_START_TIMEOUT      0
34 #define SCL_SEND_COMMAND_CONTINUE_TIMEOUT   2
35 #define SCL_INQUIRE_START_TIMEOUT     30
36 #define SCL_INQUIRE_CONTINUE_TIMEOUT      5
37 #define SCL_DEVICE_LOCK_TIMEOUT       0
38 #define SCL_PREPARE_SCAN_DEVICE_LOCK_MAX_RETRIES  4
39 #define SCL_PREPARE_SCAN_DEVICE_LOCK_DELAY    1
40 #define SCL_CMD(a,b) ( (('*'-'!'+1)<<10) + (((a)-'`'+1)<<5) + ((b)-'@'+1) )
41 #define SCL_CMD_PUNC(x)    ((((x)>>10)&0x1F)+'!'-1)
42 #define SCL_CMD_LETTER1(x) ((((x)>> 5)&0x1F)+'`'-1)
43 #define SCL_CMD_LETTER2(x) (( (x)     &0x1F)+'@'-1)
44
45 #define SCL_af          (hpaio->scl.decipixelChar)
46 #define SCL_CHAR_DECIPOINTS     'a'
47 #define SCL_CHAR_DEVPIXELS      'f'
48
49 #define SCL_CMD_RESET       SCL_CMD('z','E') /* No param! */
50 #define SCL_CMD_CLEAR_ERROR_STACK   SCL_CMD('o','E') /* No param! */
51 #define SCL_CMD_INQUIRE_PRESENT_VALUE   SCL_CMD('s','R')
52 #define SCL_CMD_INQUIRE_MINIMUM_VALUE   SCL_CMD('s','L')
53 #define SCL_CMD_INQUIRE_MAXIMUM_VALUE   SCL_CMD('s','H')
54 #define SCL_CMD_INQUIRE_DEVICE_PARAMETER  SCL_CMD('s','E')
55
56 #define SCL_CMD_SET_OUTPUT_DATA_TYPE    SCL_CMD('a','T')
57 #define SCL_CMD_SET_DATA_WIDTH      SCL_CMD('a','G')
58 #define SCL_CMD_SET_MFPDTF      SCL_CMD('m','S') /* No inq! */
59 #define SCL_CMD_SET_COMPRESSION     SCL_CMD('a','C') /* No inq! */
60 #define SCL_CMD_SET_JPEG_COMPRESSION_FACTOR SCL_CMD('m','Q') /* No inq! */
61 #define SCL_CMD_SET_X_RESOLUTION    SCL_CMD('a','R')
62 #define SCL_CMD_SET_Y_RESOLUTION    SCL_CMD('a','S')
63 #define SCL_CMD_SET_X_POSITION      SCL_CMD(SCL_af,'X')
64 #define SCL_CMD_SET_Y_POSITION      SCL_CMD(SCL_af,'Y')
65 #define SCL_CMD_SET_X_EXTENT      SCL_CMD(SCL_af,'P')
66 #define SCL_CMD_SET_Y_EXTENT      SCL_CMD(SCL_af,'Q')
67 #define SCL_CMD_SET_DOWNLOAD_TYPE   SCL_CMD('a','D')
68 #define SCL_CMD_DOWNLOAD_BINARY_DATA    SCL_CMD('a','W')
69 #define SCL_CMD_SET_CCD_RESOLUTION    SCL_CMD('m','R')
70 #define SCL_CMD_CHANGE_DOCUMENT     SCL_CMD('u','X')
71 #define SCL_CMD_UNLOAD_DOCUMENT     SCL_CMD('u','U')
72 #define SCL_CMD_CHANGE_DOCUMENT_BACKGROUND  SCL_CMD('u','Y')
73 #define SCL_CMD_SCAN_WINDOW     SCL_CMD('f','S')
74 #define SCL_CMD_SET_DEVICE_LOCK     SCL_CMD('f','H')
75 #define SCL_CMD_SET_DEVICE_LOCK_TIMEOUT   SCL_CMD('f','I')
76
77 #if 0
78 #define SCL_CMD_SET_PRESCAN     SCL_CMD('m','B')
79 #define SCL_CMD_SET_NUMBER_OF_IMAGES_FOUND  SCL_CMD('m','P')
80 #define SCL_CMD_SET_SHARPENING      SCL_CMD('a','N')
81 #endif
82
83 /* Pseudo-commands for inquiring flatbed- and ADF-specific min/max values: */
84 #define SCL_PSEUDO_FLATBED_X_RESOLUTION   (SCL_CMD_SET_X_RESOLUTION+1000)
85 #define SCL_PSEUDO_FLATBED_Y_RESOLUTION   (SCL_CMD_SET_Y_RESOLUTION+1000)
86 #define SCL_PSEUDO_FLATBED_Y_EXTENT   (SCL_CMD_SET_Y_EXTENT    +1000)
87 #define SCL_PSEUDO_ADF_X_RESOLUTION   (SCL_CMD_SET_X_RESOLUTION+2000)
88 #define SCL_PSEUDO_ADF_Y_RESOLUTION   (SCL_CMD_SET_Y_RESOLUTION+2000)
89 #define SCL_PSEUDO_ADF_Y_EXTENT     (SCL_CMD_SET_Y_EXTENT    +2000)
90
91 #define SCL_DATA_TYPE_LINEART   0
92 #define SCL_DATA_TYPE_GRAYSCALE   4
93 #define SCL_DATA_TYPE_COLOR   5
94
95 #define SCL_DATA_WIDTH_LINEART    1
96 #define SCL_DATA_WIDTH_GRAYSCALE  8 /* or 10, 12, 14, 16? */
97 #define SCL_DATA_WIDTH_COLOR    24  /* or 30, 36, 42, 48? */
98
99 #define SCL_MFPDTF_OFF      0
100 #define SCL_MFPDTF_ON     2
101
102 #define SCL_COMPRESSION_NONE    0
103 #define SCL_COMPRESSION_JPEG    2
104
105 #define SCL_MIN_Y_RES_1150    50  /* 42 is absolute minimum. */
106 #define SCL_MAX_RES_1150_1170   300
107
108 #define SCL_DOWNLOAD_TYPE_COLORMAP  15
109
110 #define SCL_DEVICE_LOCK_RELEASED  0
111 #define SCL_DEVICE_LOCK_SET   1
112 #define SCL_DEVICE_LOCK_TIMEOUT   0
113
114 #define SCL_CHANGE_DOC_SIMPLEX    0
115 #define SCL_CHANGE_DOC_DUPLEX   2
116 #define SCL_CHANGE_DOC_DUPLEX_SIDE  12
117
118
119 #define SCL_INQ_HP_MODEL_11     18
120 #define SCL_INQ_HP_MODEL_12     19
121 #define SCL_INQ_ADF_FEED_STATUS     23
122 #define SCL_INQ_ADF_CAPABILITY      24
123 #define SCL_INQ_ADF_DOCUMENT_LOADED   25
124 #define SCL_INQ_ADF_READY_TO_UNLOAD   27
125 #define SCL_INQ_MAX_ERROR_STACK     256 /* always 1 */
126 #define SCL_INQ_CURRENT_ERROR_STACK   257 /* 0 or 1 errors */
127 #define SCL_INQ_CURRENT_ERROR     259 /* error number */
128 #define SCL_INQ_SESSION_ID      505
129 #define SCL_INQ_BULB_WARM_UP_STATUS   506
130 #define SCL_INQ_PIXELS_PER_SCAN_LINE    1024
131 #define SCL_INQ_BYTES_PER_SCAN_LINE   1025
132 #define SCL_INQ_NUMBER_OF_SCAN_LINES    1026
133 #define SCL_INQ_ADF_READY_TO_LOAD   1027
134 #define SCL_INQ_DEVICE_PIXELS_PER_INCH    1028  /* 300 */
135 #if 0
136 #define SCL_INQ_NATIVE_OPTICAL_RESOLUTION 1029
137 #endif
138
139 #define SCL_ADF_FEED_STATUS_OK      0
140 #define SCL_ADF_FEED_STATUS_BUSY    1000
141 #define SCL_ADF_FEED_STATUS_PAPER_JAM   1024
142 #define SCL_ADF_FEED_STATUS_ORIGINAL_ON_GLASS 1027
143 #define SCL_ADF_FEED_STATUS_PORTRAIT_FEED 1028
144
145
146 #define SCL_ERROR_COMMAND_FORMAT_ERROR    0
147 #define SCL_ERROR_UNRECOGNIZED_COMMAND    1
148 #define SCL_ERROR_PARAMETER_ERROR   2
149 #define SCL_ERROR_ILLEGAL_WINDOW    3
150 #define SCL_ERROR_SCALING_ERROR     4
151 #define SCL_ERROR_DITHER_ID_ERROR   5
152 #define SCL_ERROR_TONE_MAP_ID_ERROR   6
153 #define SCL_ERROR_LAMP_ERROR      7
154 #define SCL_ERROR_MATRIX_ID_ERROR   8
155 #define SCL_ERROR_CAL_STRIP_PARAM_ERROR   9
156 #define SCL_ERROR_GROSS_CALIBRATION_ERROR 10
157 #define SCL_ERROR_NO_MEMORY     500
158 #define SCL_ERROR_SCANNER_HEAD_LOCKED   501
159 #define SCL_ERROR_CANCELLED     502
160 #define SCL_ERROR_PEN_DOOR_OPEN     503
161 #define SCL_ERROR_ADF_PAPER_JAM     1024
162 #define SCL_ERROR_HOME_POSITION_MISSING   1025
163 #define SCL_ERROR_PAPER_NOT_LOADED    1026
164 #define SCL_ERROR_ORIGINAL_ON_GLASS   1027
165
166 #define SCL_COMPAT_1150     0x0001  /* model 11 "5300A", 12 null */
167 #define SCL_COMPAT_1170     0x0002  /* model 12 "5400A" */
168 #define SCL_COMPAT_R_SERIES   0x0004  /* model 12 "5500A" */
169 #define SCL_COMPAT_G_SERIES   0x0008  /* model 12 "5600A" */
170 #define SCL_COMPAT_K_SERIES   0x0010  /* model 12 "5700A" */
171 #define SCL_COMPAT_D_SERIES   0x0020  /* model 12 "5800A" */
172 #define SCL_COMPAT_6100_SERIES    0x0040  /* model 12 "5900A" */
173 #define SCL_COMPAT_OFFICEJET    0x1000  /* model 11 not null */
174 #define SCL_COMPAT_POST_1150    0x2000  /* model 12 not null */
175
176 //#define LEN_SCL_BUFFER 1024
177 #define LEN_SCL_BUFFER    256 /* Increase if reading binary data. */
178
179 SANE_Status  __attribute__ ((visibility ("hidden"))) SclSendCommand(int deviceid, int channelid, int cmd, int param);
180 SANE_Status __attribute__ ((visibility ("hidden"))) SclInquire(int deviceid, int channelid, int cmd, int param, int *pValue, char *buffer, int maxlen);
181
182 /*
183  * Phase 2 partial rewrite. des 9/26/07
184  */
185
186 /* Note ESC = 0x1b = '\e' . */
187 #define SCL_QUERY_DUPLEX_SUPPORTED "\e*s13500E"            /* 1 = device can support duplex */
188 #define SCL_QUERY_DUPLEX_VERT_FLIP_SUPPORTED "\e*s13501E"  /* duplex can flip vertical (they all should) */
189 #define SCL_QUERY_DUPLEX_HORZ_FLIP_SUPPORTED "\e*s13502E"  /* duplex can flip horizontal (they all should) */
190
191 #define SCL_SET_DUPLEX "\e*d%dD13505R"                  /* 1 = duplex is requested, 0 otherwise */
192 #define SCL_SET_DUPLEX_VERT_FLIP "\e*d%dV13506R"        /* 1 = vertical flip is requested, 0 otherwise */
193 #define SCL_SET_DUPLEX_HORZ_FLIP "\e*d%dH13507R"        /* 1 = horizontal flip is requested, 0 otherwise */
194 #define SCL_SET_DUPLEX_ORIENTATION "\e*a%d13507R"       /* 0 = no change, 1 = needs vert flip, 2 = vert and horz flip */
195
196 struct hpaioScanner_s;
197
198 SANE_Status __attribute__ ((visibility ("hidden"))) scl_send_cmd(struct hpaioScanner_s *hpaio, const char *buf, int size);
199 SANE_Status __attribute__ ((visibility ("hidden"))) scl_query_int(struct hpaioScanner_s *hpaio, const char *buf, int size, int *result);
200
201 #endif
202