1 /* --------------------------------------------------------------------------------------------------------- */
2
3 /* umax-scsidef.h: scsi-definiton header file for UMAX scanner driver.
4
5 Copyright (C) 1996-1997 Michael K. Johnson
6 Copyright (C) 1997-2002 Oliver Rauch
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>.
20
21 As a special exception, the authors of SANE give permission for
22 additional uses of the libraries contained in this release of SANE.
23
24 The exception is that, if you link a SANE library with other files
25 to produce an executable, this does not by itself cause the
26 resulting executable to be covered by the GNU General Public
27 License. Your use of that executable is in no way restricted on
28 account of linking the SANE library code into it.
29
30 This exception does not, however, invalidate any other reasons why
31 the executable file might be covered by the GNU General Public
32 License.
33
34 If you submit changes to SANE to the maintainers to be included in
35 a subsequent release, you agree by submitting the changes that
36 those changes may be distributed with this exception intact.
37
38 If you write modifications of your own for SANE, it is your choice
39 whether to permit this exception to apply to your modifications.
40 If you do not wish that, delete this exception notice.
41 */
42
43 /* --------------------------------------------------------------------------------------------------------- */
44
45
46 #ifndef UMAX_SCSIDEF_H
47 #define UMAX_SCSIDEF_H
48
49 #include "umax.h"
50
51
52 /* --------------------------------------------------------------------------------------------------------- */
53
54 /* I'm using functions derived from Eric Youngdale's scsiinfo
55 * program here for dealing with parts of SCSI commands.
56 */
57
setbitfield(unsigned char * pageaddr,int mask,int shift,int val)58 static inline void setbitfield(unsigned char * pageaddr, int mask, int shift, int val) \
59 { *pageaddr = (*pageaddr & ~(mask << shift)) | ((val & mask) << shift); }
60
resetbitfield(unsigned char * pageaddr,int mask,int shift,int val)61 static inline void resetbitfield(unsigned char * pageaddr, int mask, int shift, int val) \
62 { *pageaddr = (*pageaddr & ~(mask << shift)) | (((!val) & mask) << shift); }
63
getbitfield(unsigned char * pageaddr,int mask,int shift)64 static inline int getbitfield(unsigned char * pageaddr, int mask, int shift) \
65 { return ((*pageaddr >> shift) & mask); }
66
67 /* ------------------------------------------------------------------------- */
68
getnbyte(unsigned char * pnt,int nbytes)69 static inline int getnbyte(unsigned char * pnt, int nbytes) \
70 {
71 unsigned int result = 0;
72 int i;
73
74 for(i=0; i<nbytes; i++)
75 result = (result << 8) | (pnt[i] & 0xff);
76 return result;
77 }
78
79 /* ------------------------------------------------------------------------- */
80
putnbyte(unsigned char * pnt,unsigned int value,unsigned int nbytes)81 static inline void putnbyte(unsigned char * pnt, unsigned int value, unsigned int nbytes) \
82 {
83 int i;
84
85 for(i=nbytes-1; i>= 0; i--) \
86 {
87 pnt[i] = value & 0xff;
88 value = value >> 8;
89 }
90 }
91
92
93 /* --------------------------------------------------------------------------------------------------------- */
94
95
96 /* Not all of these are defined in scsi.h, so we'll make sure
97 * we agree about them here...
98 */
99 #define TEST_UNIT_READY 0x00
100 #define REQUEST_SENSE 0x03
101 #define INQUIRY 0x12
102 #define RESERVE_UNIT 0x16
103 #define RELEASE_UNIT 0x17
104 #define SCAN 0x1B
105 #define SET_WINDOW 0x24
106 #define READ 0x28
107 #define SEND 0x2A
108 #define OBJECT_POSITION 0x31
109 #define GET_DATA_BUFFER_STATUS 0x34
110 #undef WRITE_BUFFER /* correct write_buffer for scanner */
111 #define WRITE_BUFFER 0x3B
112 #define GET_LAMP_STATUS 0x5E
113 #define SET_LAMP_STATUS 0x5F
114
115 /* --------------------------------------------------------------------------------------------------------- */
116
117
118 #define STD_WDB_LEN 0x28 /* wdb_len if nothing is set by inquiry */
119
120
121 /* --------------------------------------------------------------------------------------------------------- */
122
123
124 /* SCSI commands */
125
126 typedef struct
127 {
128 unsigned char *cmd;
129 size_t size;
130 } scsiblk;
131
132
133 /* --------------------------------------------------------------------------------------------------------- */
134
135
136 #define set_inquiry_return_size(icb,val) icb[0x04]=val
137 static unsigned char inquiryC[] = { INQUIRY, 0x00, 0x02, 0x00, 0xff, 0x00 };
138 static scsiblk inquiry = { inquiryC, sizeof(inquiryC) };
139
140
141 /* --------------------------------------------------------------------------------------------------------- */
142
143
144 #define get_inquiry_periph_qual(in) getbitfield(in, 0x07, 5)
145 # define IN_periph_qual_lun 0x00
146 # define IN_periph_qual_nolun 0x03
147 #define get_inquiry_periph_devtype(in) getbitfield(in, 0x1f, 0)
148 # define IN_periph_devtype_scanner 0x06
149 # define IN_periph_devtype_unknown 0x1f
150
151 #define get_inquiry_rmb(in) getbitfield(in + 0x01, 0x01, 7)
152 #define get_inquiry_0x01_bit6(in) getbitfield(in + 0x01, 0x01, 6)
153 #define get_inquiry_0x01_bit5(in) getbitfield(in + 0x01, 0x01, 5)
154 #define get_inquiry_CBHS(in) getbitfield(in + 0x01, 0x03, 3)
155 #define set_inquiry_CBHS(in, val) setbitfield(in + 0x01, 0x03, 3, val)
156 # define IN_CBHS_50 0x00
157 # define IN_CBHS_255 0x01
158 # define IN_CBHS_auto 0x02
159 #define get_inquiry_translamp(in) getbitfield(in + 0x01, 0x01, 2)
160 #define get_inquiry_transavail(in) getbitfield(in + 0x01, 0x01, 1)
161 #define get_inquiry_scanmode(in) getbitfield(in + 0x01, 0x01, 0)
162 # define IN_flatbed 0x00
163 # define IN_adf 0x01
164
165 #define get_inquiry_iso_version(in) getbitfield(in + 0x02, 0x03, 6)
166 #define get_inquiry_ecma_version(in) getbitfield(in + 0x02, 0x07, 3)
167 #define get_inquiry_ansi_version(in) getbitfield(in + 0x02, 0x07, 0)
168
169 #define get_inquiry_aenc(in) getbitfield(in + 0x03, 0x01, 7)
170 #define get_inquiry_tmiop(in) getbitfield(in + 0x03, 0x01, 6)
171 #define get_inquiry_0x03_bit5(in) getbitfield(in + 0x03, 0x01, 5)
172 #define get_inquiry_0x03_bit4(in) getbitfield(in + 0x03, 0x01, 4)
173 #define get_inquiry_response_format(in) getbitfield(in + 0x03, 0x0f, 0)
174 # define IN_recognized 0x02
175
176 #define get_inquiry_additional_length(in) in[0x04]
177 #define set_inquiry_length(out,n) out[0x04]=n-5
178
179 #define get_inquiry_0x05(in) in[0x05]
180 #define get_inquiry_0x06(in) in[0x06]
181
182 #define get_inquiry_scsi_byte(in) in[0x07]
183 #define get_inquiry_scsi_reladr(in) getbitfield(in + 0x07, 0x01, 7)
184 #define get_inquiry_scsi_wbus32(in) getbitfield(in + 0x07, 0x01, 6)
185 #define get_inquiry_scsi_wbus16(in) getbitfield(in + 0x07, 0x01, 5)
186 #define get_inquiry_scsi_sync(in) getbitfield(in + 0x07, 0x01, 4)
187 #define get_inquiry_scsi_linked(in) getbitfield(in + 0x07, 0x01, 3)
188 #define get_inquiry_scsi_R(in) getbitfield(in + 0x07, 0x01, 2)
189 #define get_inquiry_scsi_cmdqueue(in) getbitfield(in + 0x07, 0x01, 1)
190 #define get_inquiry_scsi_sftre(in) getbitfield(in + 0x07, 0x01, 0)
191
192 #define get_inquiry_vendor(in, buf) strncpy(buf, in + 0x08, 0x08)
193 #define get_inquiry_product(in, buf) strncpy(buf, in + 0x10, 0x010)
194 #define get_inquiry_version(in, buf) strncpy(buf, in + 0x20, 0x04)
195
196 #define set_inquiry_fw_quality(in, val) setbitfield(in + 0x24, 1, 0, val)
197 #define get_inquiry_fw_quality(in) getbitfield(in + 0x24, 1, 0)
198 #define get_inquiry_fw_fast_preview(in) getbitfield(in + 0x24, 1, 1)
199 #define get_inquiry_fw_shadow_comp(in) getbitfield(in + 0x24, 1, 2)
200 #define get_inquiry_fw_reselection(in) getbitfield(in + 0x24, 1, 3)
201 #define get_inquiry_fw_lamp_int_cont(in) getbitfield(in + 0x24, 1, 4)
202 #define get_inquiry_fw_batch_scan(in) getbitfield(in + 0x24, 1, 5)
203 #define get_inquiry_fw_calibration(in) getbitfield(in + 0x24, 1, 6)
204 #define get_inquiry_fw_adjust_exposure_tf(in) getbitfield(in + 0x24, 1, 7)
205
206 #define get_inquiry_exposure_time_step_unit(in) in[0x25]
207 #define get_inquiry_exposure_time_max(in) getnbyte(in + 0x26, 2)
208 #define get_inquiry_exposure_time_lhg_min(in) in[0x2a]
209 #define get_inquiry_exposure_time_color_min(in) in[0x2b]
210 #define get_inquiry_exposure_time_lh_def_fb(in) in[0x2c]
211 #define get_inquiry_exposure_time_lh_def_uta(in) in[0x2d]
212 #define get_inquiry_exposure_time_gray_def_fb(in) in[0x2e]
213 #define get_inquiry_exposure_time_gray_def_uta(in) in[0x2f]
214 #define get_inquiry_exposure_time_def_r_fb(in) in[0x30]
215 #define get_inquiry_exposure_time_def_g_fb(in) in[0x31]
216 #define get_inquiry_exposure_time_def_b_fb(in) in[0x32]
217 #define get_inquiry_exposure_time_def_r_uta(in) in[0x33]
218 #define get_inquiry_exposure_time_def_g_uta(in) in[0x34]
219 #define get_inquiry_exposure_time_def_b_uta(in) in[0x35]
220
221 #define get_inquiry_0x36(in) in[0x36]
222 #define get_inquiry_0x37(in) in[0x37]
223
224 /* bytes 0x38 - 0x5f reserved by SCSI */
225
226 #define get_inquiry_sc_feature_byte0(in) in[0x60]
227 #define get_inquiry_sc_three_pass_color(in) getbitfield(in + 0x60, 1, 0)
228 #define get_inquiry_sc_one_pass_color(in) getbitfield(in + 0x60, 1, 1)
229 #define get_inquiry_sc_lineart(in) getbitfield(in + 0x60, 1, 2)
230 #define get_inquiry_sc_halftone(in) getbitfield(in + 0x60, 1, 3)
231 #define get_inquiry_sc_gray(in) getbitfield(in + 0x60, 1, 4)
232 #define get_inquiry_sc_color(in) getbitfield(in + 0x60, 1, 5)
233 #define get_inquiry_sc_uta(in) getbitfield(in + 0x60, 1, 6)
234 #define get_inquiry_sc_adf(in) getbitfield(in + 0x60, 1, 7)
235
236 #define set_inquiry_sc_three_pass_color(in,val) setbitfield(in + 0x60, 1, 0, val)
237 #define set_inquiry_sc_one_pass_color(in,val) setbitfield(in + 0x60, 1, 1, val)
238 #define set_inquiry_sc_lineart(in,val) setbitfield(in + 0x60, 1, 2, val)
239 #define set_inquiry_sc_halftone(in,val) setbitfield(in + 0x60, 1, 3, val)
240 #define set_inquiry_sc_gray(in,val) setbitfield(in + 0x60, 1, 4, val)
241 #define set_inquiry_sc_color(in,val) setbitfield(in + 0x60, 1, 5, val)
242 #define set_inquiry_sc_uta(in,val) setbitfield(in + 0x60, 1, 6, val)
243 #define set_inquiry_sc_adf(in,val) setbitfield(in + 0x60, 1, 7, val)
244
245 #define get_inquiry_sc_feature_byte1(in) in[0x61]
246 #define get_inquiry_sc_double_res(in) getbitfield(in + 0x61, 1, 0)
247 #define get_inquiry_sc_high_byte_first(in) getbitfield(in + 0x61, 1, 1)
248 #define get_inquiry_sc_bi_image_reverse(in) getbitfield(in + 0x61, 1, 2)
249 #define get_inquiry_sc_multi_image_reverse(in) getbitfield(in + 0x61, 1, 3)
250 #define get_inquiry_sc_no_shadow(in) getbitfield(in + 0x61, 1, 4)
251 #define get_inquiry_sc_no_highlight(in) getbitfield(in + 0x61, 1, 5)
252 #define get_inquiry_sc_downloadable_fw(in) getbitfield(in + 0x61, 1, 6)
253 #define get_inquiry_sc_paper_length_14(in) getbitfield(in + 0x61, 1, 7)
254
255 #define get_inquiry_sc_feature_byte2(in) in[0x62]
256 #define get_inquiry_sc_uploadable_shade(in) getbitfield(in + 0x62, 1, 0)
257 #define get_inquiry_fw_support_color(in) getbitfield(in + 0x62, 1, 1)
258 #define get_inquiry_analog_gamma(in) getbitfield(in + 0x62, 1, 2)
259 #define get_inquiry_xy_coordinate_base(in) getbitfield(in + 0x62, 1, 3)
260 #define get_inquiry_lineart_order(in) getbitfield(in + 0x62, 1, 4)
261 #define get_inquiry_start_density(in) getbitfield(in + 0x62, 1, 5)
262 #define get_inquiry_hw_x_scaling(in) getbitfield(in + 0x62, 1, 6)
263 #define get_inquiry_hw_y_scaling(in) getbitfield(in + 0x62, 1, 7)
264
265 #define get_inquiry_sc_feature_byte3(in) in[0x63]
266 #define get_inquiry_ADF_no_paper(in) getbitfield(in + 0x63, 1, 0)
267 #define get_inquiry_ADF_cover_open(in) getbitfield(in + 0x63, 1, 1)
268 #define get_inquiry_ADF_paper_jam(in) getbitfield(in + 0x63, 1, 2)
269 #define get_inquiry_0x63_bit3(in) getbitfield(in + 0x63, 1, 3)
270 #define get_inquiry_0x63_bit4(in) getbitfield(in + 0x63, 1, 4)
271 #define get_inquiry_lens_cal_in_doc_pos(in) getbitfield(in + 0x63, 1, 5)
272 #define get_inquiry_manual_focus(in) getbitfield(in + 0x63, 1, 6)
273 #define get_inquiry_sel_uta_lens_cal_pos(in) getbitfield(in + 0x63, 1, 7)
274
275 #define get_inquiry_gamma_download_available(in) getbitfield(in + 0x64, 1, 7)
276 #define get_inquiry_0x64_bit6(in) getbitfield(in + 0x64, 1, 6)
277 #define get_inquiry_gamma_type_2(in) getbitfield(in + 0x64, 1, 5)
278 #define get_inquiry_0x64_bit4(in) getbitfield(in + 0x64, 1, 4)
279 #define get_inquiry_0x64_bit3(in) getbitfield(in + 0x64, 1, 3)
280 #define get_inquiry_0x64_bit2(in) getbitfield(in + 0x64, 1, 2)
281 #define get_inquiry_gamma_lines(in) getbitfield(in + 0x64, 0x03, 0)
282 # define IN_3_pass 0x01
283 # define IN_3_line 0x03
284
285 #define get_inquiry_0x65(in) in[0x65]
286
287 #define get_inquiry_gib(in) in[0x66]
288 #define get_inquiry_gib_8bpp(in) getbitfield(in + 0x66, 1, 0)
289 #define get_inquiry_gib_9bpp(in) getbitfield(in + 0x66, 1, 1)
290 #define get_inquiry_gib_10bpp(in) getbitfield(in + 0x66, 1, 2)
291 #define get_inquiry_gib_12bpp(in) getbitfield(in + 0x66, 1, 3)
292 #define get_inquiry_gib_14bpp(in) getbitfield(in + 0x66, 1, 4)
293 #define get_inquiry_gib_16bpp(in) getbitfield(in + 0x66, 1, 5)
294 #define get_inquiry_0x66_bit6(in) getbitfield(in + 0x66, 1, 6)
295 #define get_inquiry_0x66_bit7(in) getbitfield(in + 0x66, 1, 7)
296 # define IN_gib_8bpp 0x01
297 # define IN_gib_10bpp 0x04
298
299 #define get_inquiry_0x67(in) in[0x67]
300
301 #define get_inquiry_gob(in) in[0x68]
302 #define get_inquiry_gob_8bpp(in) getbitfield(in + 0x68, 1, 0)
303 #define get_inquiry_gob_9bpp(in) getbitfield(in + 0x68, 1, 1)
304 #define get_inquiry_gob_10bpp(in) getbitfield(in + 0x68, 1, 2)
305 #define get_inquiry_gob_12bpp(in) getbitfield(in + 0x68, 1, 3)
306 #define get_inquiry_gob_14bpp(in) getbitfield(in + 0x68, 1, 4)
307 #define get_inquiry_gob_16bpp(in) getbitfield(in + 0x68, 1, 5)
308 #define get_inquiry_0x68_bit6(in) getbitfield(in + 0x68, 1, 6)
309 #define get_inquiry_0x68_bit7(in) getbitfield(in + 0x68, 1, 7)
310 # define IN_gob_8bpp 0x01
311 # define IN_gob_10bpp 0x04
312
313 #define get_inquiry_hda(in) getbitfield(in + 0x69, 0x01, 7)
314 #define get_inquiry_max_halftone_matrix(in) getbitfield(in + 0x69, 0x7f, 0)
315 #define get_inquiry_halftones_supported(in) in[0x6a]
316 #define get_inquiry_halftones_2x2(in) getbitfield(in + 0x6a, 1, 0)
317 #define get_inquiry_halftones_4x4(in) getbitfield(in + 0x6a, 1, 1)
318 #define get_inquiry_halftones_6x6(in) getbitfield(in + 0x6a, 1, 2)
319 #define get_inquiry_halftones_8x8(in) getbitfield(in + 0x6a, 1, 3)
320 #define get_inquiry_halftones_12x12(in) getbitfield(in + 0x6a, 1, 5)
321 # define IN_halftone_2x2 0x01
322 # define IN_halftone_4x4 0x02
323 # define IN_halftone_6x6 0x04
324 # define IN_halftone_8x8 0x08
325 # define IN_halftone_12x12 0x20
326
327 #define get_inquiry_0x6b(in) in[0x6b]
328 #define get_inquiry_0x6c(in) in[0x6c]
329
330 #define get_inquiry_colorseq(in) getbitfield(in + 0x6d, 0x07, 5)
331 # define IN_color_sequence_RGB 0x00
332 # define IN_color_sequence_RBG 0x01
333 # define IN_color_sequence_GBR 0x02
334 # define IN_color_sequence_GRB 0x03
335 # define IN_color_sequence_BRG 0x04
336 # define IN_color_sequence_BGR 0x05
337 # define IN_color_sequence_all 0x07
338 #define get_inquiry_color_order(in) getbitfield(in + 0x6d, 0x1f, 0)
339 #define set_inquiry_color_order(in,val) setbitfield(in + 0x6d, 0x1f, 0, val)
340 #define get_inquiry_color_order_pixel(in) getbitfield(in + 0x6d, 1, 0)
341 #define get_inquiry_color_order_line_no_ccd(in) getbitfield(in + 0x6d, 1, 1)
342 #define get_inquiry_color_order_plane(in) getbitfield(in + 0x6d, 1, 2)
343 #define get_inquiry_color_order_line_w_ccd(in) getbitfield(in + 0x6d, 1, 3)
344 #define get_inquiry_color_order_reserved(in) getbitfield(in + 0x6d, 1, 4)
345 # define IN_color_ordering_pixel 0x01
346 # define IN_color_ordering_line_no_ccd 0x02
347 # define IN_color_ordering_plane 0x04
348 # define IN_color_ordering_line_w_ccd 0x08
349
350 #define get_inquiry_max_vidmem(in) getnbyte(in + 0x6e, 4)
351
352 #define get_inquiry_0x72(in) in[0x72]
353 #define get_inquiry_max_opt_res(in) in[0x73]
354 #define get_inquiry_max_x_res(in) in[0x74]
355 #define get_inquiry_max_y_res(in) in[0x75]
356 #define get_inquiry_fb_max_scan_width(in) getnbyte(in + 0x76, 2)
357 #define get_inquiry_fb_max_scan_length(in) getnbyte(in + 0x78, 2)
358 #define get_inquiry_uta_x_original_point(in) getnbyte(in + 0x7a, 2)
359 #define get_inquiry_uta_y_original_point(in) getnbyte(in + 0x7c, 2)
360 #define get_inquiry_uta_max_scan_width(in) getnbyte(in + 0x7e, 2)
361 #define get_inquiry_uta_max_scan_length(in) getnbyte(in + 0x80, 2)
362
363 #define get_inquiry_0x82(in) in[0x82]
364
365 #define get_inquiry_dor_max_opt_res(in) in[0x83]
366 #define get_inquiry_dor_max_x_res(in) in[0x84]
367 #define get_inquiry_dor_max_y_res(in) in[0x85]
368
369 #define get_inquiry_dor_x_original_point(in) getnbyte(in + 0x86, 2)
370 #define get_inquiry_dor_y_original_point(in) getnbyte(in + 0x88, 2)
371 #define get_inquiry_dor_max_scan_width(in) getnbyte(in + 0x8a, 2)
372 #define get_inquiry_dor_max_scan_length(in) getnbyte(in + 0x8c, 2)
373
374 #define get_inquiry_0x8e(in) in[0x8e]
375
376 #define get_inquiry_last_calibration_lamp_density(in) in[0x8f]
377 # define IN_min_lamp_density 0x01
378 # define IN_max_lamp_density 0xff
379
380 #define get_inquiry_0x90(in) in[0x90]
381
382 #define get_inquiry_lamp_warmup_maximum_time(in) in[0x91]
383 #define get_inquiry_wdb_length(in) getnbyte(in + 0x92, 2)
384 #define get_inquiry_optical_resolution_residue(in) in[0x94]
385 #define get_inquiry_x_resolution_residue(in) in[0x95]
386 #define get_inquiry_y_resolution_residue(in) in[0x96]
387 #define get_inquiry_analog_gamma_table(in) in[0x97]
388
389 #define get_inquiry_0x98(in) in[0x98]
390 #define get_inquiry_0x99(in) in[0x99]
391
392 #define get_inquiry_max_calibration_data_lines(in) in[0x9a]
393 #define get_inquiry_fb_uta_line_arrangement_mode(in) in[0x9b]
394 #define get_inquiry_adf_line_arrangement_mode(in) in[0x9c]
395 #define get_inquiry_CCD_line_distance(in) in[0x9d]
396
397 #define set_inquiry_max_calibration_data_lines(out,val) out[0x9a]=val
398 #define set_inquiry_fb_uta_line_arrangement_mode(out,val) out[0x9b]=val
399 #define set_inquiry_adf_line_arrangement_mode(out,val) out[0x9c]=val
400 #define set_inquiry_CCD_line_distance(out,val) out[0x9d]=val
401
402 #define get_inquiry_0x9e(in) in[0x9e]
403
404 #define get_inquiry_dor_optical_resolution_residue(in) in[0xa0]
405 #define get_inquiry_dor_x_resolution_residue(in) in[0xa1]
406 #define get_inquiry_dor_y_resolution_residue(in) in[0xa2]
407
408
409 /* --------------------------------------------------------------------------------------------------------- */
410
411 /* although the command is defined with 6 bytes length in the doc, 10 bytes seems to be the correct length */
412 static unsigned char get_lamp_statusC[] = { GET_LAMP_STATUS, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
413
414 static scsiblk get_lamp_status = { get_lamp_statusC,sizeof(get_lamp_statusC) };
415 #define get_lamp_status_lamp_on(in) getbitfield(in, 1, 0)
416
417
418 /* --------------------------------------------------------------------------------------------------------- */
419
420
421 /* although the command is defined with 6 bytes length in the doc, 10 bytes seems to be the correct length */
422 static unsigned char set_lamp_statusC[] = { SET_LAMP_STATUS, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
423
424 static scsiblk set_lamp_status = { set_lamp_statusC,sizeof(set_lamp_statusC) };
425 #define set_lamp_status_lamp_on(in,val) setbitfield(in + 0x03, 1, 7, val)
426
427
428 /* --------------------------------------------------------------------------------------------------------- */
429
430
431 static unsigned char test_unit_readyC[] = { TEST_UNIT_READY, 0x00, 0x00, 0x00, 0x00, 0x00 };
432
433 static scsiblk test_unit_ready = { test_unit_readyC,sizeof(test_unit_readyC) };
434
435
436 /* --------------------------------------------------------------------------------------------------------- */
437
438
439 static unsigned char reserve_unitC[] = { RESERVE_UNIT, 0x00, 0x00, 0x00, 0x00, 0x00 };
440
441 static scsiblk reserve_unit = { reserve_unitC, sizeof(reserve_unitC) };
442
443
444 /* --------------------------------------------------------------------------------------------------------- */
445
446
447 static unsigned char release_unitC[] = { RELEASE_UNIT, 0x00, 0x00, 0x00, 0x00, 0x00 };
448
449 static scsiblk release_unit = { release_unitC, sizeof(release_unitC) };
450
451
452 /* --------------------------------------------------------------------------------------------------------- */
453
454
455 static unsigned char set_windowC[] =
456 {
457 SET_WINDOW, 0x00, /* opcode, lun */
458 0x00, 0x00, 0x00, 0x00, /* reserved */
459 0x00, 0x00, 0x00, /* transfer length; needs to be set */
460 0x00 /* control byte */
461 };
462
463 #define set_SW_xferlen(sb, len) putnbyte(sb + 0x06, len, 3)
464
465 static scsiblk set_window = { set_windowC, sizeof(set_windowC) };
466
467
468 /* --------------------------------------------------------------------------------------------------------- */
469
470
471 static unsigned char window_parameter_data_blockC[] =
472 {
473 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* reserved */
474 0x00, 0x00 /* Window Descriptor Length, value must be set by SHORT_WDB define */
475 };
476
477 #define set_WPDB_wdblen(sb, len) putnbyte(sb + 0x06, len, 2)
478
479
480 static scsiblk window_parameter_data_block =
481 { window_parameter_data_blockC, sizeof(window_parameter_data_blockC) };
482
483
484 /* --------------------------------------------------------------------------------------------------------- */
485
486
487 static unsigned char window_descriptor_blockC[] =
488 {
489 #define max_WDB_size 0xff
490 #define used_WDB_size 0x53
491
492 /* 0x00 */ 0x00, /* Window Identifier */
493 #define set_WD_wid(sb, val) sb[0] = val
494 # define WD_wid_bw 0x00
495 # define WD_wid_red 0x01
496 # define WD_wid_green 0x02
497 # define WD_wid_blue 0x03
498 # define WD_wid_all 0x00
499 /* 0x01 */ 0x00, /* reserved, AUTO */
500 #define set_WD_auto(sb, val) setbitfield(sb + 0x01, 1, 0, val)
501
502 /* 0x02 */ 0x00, 0x00, /* X Resolution in dpi */
503 #define set_WD_Xres(sb, val) putnbyte(sb + 0x02, val, 2)
504
505 /* 0x04 */ 0x00, 0x00, /* Y Resolution in dpi */
506 #define set_WD_Yres(sb, val) putnbyte(sb + 0x04, val, 2)
507
508 /* 0x06 */ 0x00, 0x00, 0x00, 0x00, /* Upper Left X in 1200pt/inch */
509 #define set_WD_ULX(sb, val) putnbyte(sb + 0x06, val, 4)
510
511 /* 0x0a */ 0x00, 0x00, 0x00, 0x00, /* Upper Left Y in 1200pt/inch */
512 #define set_WD_ULY(sb, val) putnbyte(sb + 0x0a, val, 4)
513
514 /* 0x0e */ 0x00, 0x00, 0x00, 0x00, /* Width 1200pt/inch */
515 #define set_WD_width(sb, val) putnbyte(sb + 0x0e, val, 4)
516
517 /* 0x12 */ 0x00, 0x00, 0x00, 0x00, /* Length 1200pt/inch */
518 #define set_WD_length(sb, val) putnbyte(sb + 0x12, val, 4)
519
520 /* 0x16 */ 0xff, /* Brightness */
521 #define set_WD_brightness(sb, val) sb[0x16] = val
522
523 /* 0x17 */ 0x80, /* Threshold */
524 #define set_WD_threshold(sb, val) sb[0x17] = val
525
526 /* 0x18 */ 0x80, /* Contrast */
527 #define set_WD_contrast(sb, val) sb[0x18] = val
528
529 /* 0x19 */ 0x05, /* Image Composition */
530 #define set_WD_composition(sb, val) sb[0x19] = val
531 # define WD_comp_lineart 0x00
532 # define WD_comp_dithered 0x01
533 # define WD_comp_gray 0x02
534 # define WD_comp_gray 0x02
535 # define WD_comp_rgb_bilevel 0x03
536 # define WD_comp_rgb_dithered 0x04
537 # define WD_comp_rgb_full 0x05
538
539 /* 0x1a */ 0x08, /* Bits/Pixel */
540 #define set_WD_bitsperpixel(sb, val) sb[0x1a] = val
541 # define WD_bits_1 0x01
542 # define WD_bits_8 0x08
543 # define WD_bits_10 0x0a
544
545 /* 0x1b */ 0x00, 0x03, /* Halftone pattern */
546 #define set_WD_halftone(sb, val) putnbyte(sb + 0x1b, val, 2)
547 # define WD_halftone_download 0x00
548 # define WD_halftone_12x12_1 0x01
549 # define WD_halftone_12x12_2 0x02
550 # define WD_halftone_8x8_1 0x03
551 # define WD_halftone_8x8_2 0x04
552 # define WD_halftone_8x8_3 0x05
553 # define WD_halftone_8x8_4 0x06
554 # define WD_halftone_8x8_5 0x07
555 # define WD_halftone_6x6_1 0x08
556 # define WD_halftone_6x6_2 0x09
557 # define WD_halftone_6x6_3 0x0a
558 # define WD_halftone_4x4_1 0x0b
559 # define WD_halftone_4x4_2 0x0c
560 # define WD_halftone_4x4_3 0x0d
561 # define WD_halftone_2x2_1 0x0e
562 # define WD_halftone_2x2_2 0x0f
563
564 /* 0x1d */ 0x03, /* RIF, reserved, padding type */
565 #define set_WD_RIF(sb, val) setbitfield(sb + 0x1d, 1, 7, val)
566 #define set_WD_padding_type(sb,val) setbitfield(sb + 0x1d, 0x07, 0, val)
567 # define WD_padding_byte 0x03
568 # define WD_padding_word 0x07
569
570 /* 0x1e */ 0x00, 0x00, /* Bit Ordering (0 = left to right;) */
571 /* 0x20 */ 0x00, /* Compression Type (reserved) */
572 /* 0x21 */ 0x00, /* Compr. Argument (reserved) */
573 /* 0x22 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Reserved */
574 /* 0x28 */ 0x01, /* Speed */
575 #define set_WD_speed(sb, val) sb[0x28] = val
576 # define WD_speed_fastsmear 0x81
577 # define WD_speed_slowsmear 0x82
578 # define WD_speed_fastclear 0x01
579 # define WD_speed_slowclear 0x02
580 # define WD_speed_speedbit 0x03
581 # define WD_speed_smearbit 0x80
582 # define WD_speed_fast 0x01
583 # define WD_speed_slow 0x02
584 # define WD_speed_smear 0x80
585
586 /* 0x29 */ 0x00, /* Select Color */
587 #define set_WD_select_color(sb,val) setbitfield(sb+0x29, 0x07, 5, val)
588 # define WD_color_gray 0x00
589 # define WD_color_red 0x04
590 # define WD_color_green 0x02
591 # define WD_color_blue 0x01
592
593 /* 0x2a */ 0xff, /* Highlight */
594 #define set_WD_highlight(sb, val) sb[0x2a] = val
595
596 /* 0x2b */ 0x00, /* Shadow */
597 #define set_WD_shadow(sb, val) sb[0x2b] = val
598
599 /* 0x2c */ 0x00, 0x00, /* Paper Length */
600 #define set_WD_paperlength(sb, val) putnbyte(sb + 0x2c, val, 2)
601
602 /* 0x2e */ 0x0f, /* Gamma Function */
603 #define set_WD_gamma(sb, val) sb[0x2e] = val
604 # define WD_gamma_download 0x00
605 # define WD_gamma_builtin1 0x01
606 # define WD_gamma_builtin2 0x02
607 # define WD_gamma_builtin3 0x03
608 # define WD_gamma_builtin4 0x04
609 # define WD_gamma_normal 0x0f
610
611 /* 0x2f */ 0x11, /* Scan Module */
612 #define set_WD_module(sb, val) sb[0x2f] = val
613 # define WD_module_flatbed 0x11
614 # define WD_module_transparency 0xff
615
616 /* 0x30 */ 0x01, /* HBT, DOR, reserved, RMIF, CBHS Type */
617 /* CBHS = Contrast, Brightness, Highlight, Shadow */
618 #define set_WD_CBHS(sb, val) setbitfield(sb + 0x30, 1, 0, val)
619 # define WD_CBHS_50 0
620 # define WD_CBHS_255 1
621 #define set_WD_FF(sb, val) setbitfield(sb + 0x30, 1, 1, val) /* FF = Fix Focus position */
622 #define set_WD_RMIF(sb, val) setbitfield(sb + 0x30, 1, 2, val) /* Reverse Multil Image Frmt */
623 #define set_WD_FDC(sb, val) setbitfield(sb + 0x30, 1, 3, val) /* document calibration */
624 #define set_WD_PF(sb, val) setbitfield(sb + 0x30, 1, 4, val) /* PF pre focus */
625 #define set_WD_LCL(sb, val) setbitfield(sb + 0x30, 1, 5, val) /* LCL (focus position) */
626 #define set_WD_DOR(sb, val) setbitfield(sb + 0x30, 1, 6, val) /* Double Optical Resolution */
627 #define set_WD_HBT(sb, val) setbitfield(sb + 0x30, 1, 7, val) /* High Byte Transfer */
628 # define WD_HBT_HBF 0x00
629 # define WD_HBT_LBF 0x01
630
631 /* 0x31 */ 0x00, 0x00, /* scan exposure level */
632 #define set_WD_scan_exposure_level(sb, val) putnbyte(sb+0x31, val, 2)
633
634 /* 0x33 */ 0x00, 0x00, /* calibration exposure level */
635 #define set_WD_calibration_exposure_level(sb, val) putnbyte(sb+0x33, val, 2)
636
637 /* 0x35 */ 0x00, /* reserved */
638 /* 0x36 */ 0x00, /* reserved */
639 /* 0x37 */ 0x00, /* reserved */
640 /* 0x38 */ 0x00, /* reserved (For Autoexposure) */
641
642 /* 0x39 */ 0x00, /* BS, reserved, Calibration Mode */
643 #define set_WD_batch(sb, val) setbitfield(sb + 0x39, 1, 7, val)
644 #define set_WD_MF(sb, val) setbitfield(sb + 0x39, 1, 6, val) /* manual focus */
645 #define set_WD_line_arrangement(sb, val) setbitfield(sb + 0x39, 1, 5, val)
646 # define WD_line_arrengement_by_driver 0x01
647 # define WD_line_arrengement_by_fw 0x00
648 #define set_WD_warmup(sb, val) setbitfield(sb + 0x39, 1, 4, val)
649 #define set_WD_calibration(sb, val) setbitfield(sb + 0x39, 0x0f, 0, val)
650 # define WD_calibration_image 0x00
651 # define WD_calibration_lineart 0x0f
652 # define WD_calibration_dither 0x0e
653 # define WD_calibration_gray 0x0d
654 # define WD_calibration_rgb 0x0a
655 # define WD_calibration_ignore 0x09
656
657 /* 0x3a */ 0x01, /* Color Sequence, Color Ordering Support */
658 #define set_WD_color_sequence(sb,val) setbitfield(sb+0x3a,0x07,5, val)
659 # define WD_color_sequence_RGB 0x00
660 # define WD_color_sequence_RBG 0x01
661 # define WD_color_sequence_GBR 0x02
662 # define WD_color_sequence_GRB 0x03
663 # define WD_color_sequence_BRG 0x04
664 # define WD_color_sequence_BGR 0x05
665
666 #define set_WD_color_ordering(sb,val) setbitfield(sb+0x3a,0x1f,0, val)
667 # define WD_color_ordering_pixel 0x01
668 # define WD_color_ordering_line_no_ccd 0x02
669 # define WD_color_ordering_plane 0x04
670 # define WD_color_ordering_line_w_ccd 0x08
671
672 /* 0x3b */ 0x00, /* analog gamma code (set to 1.0) */
673 #define set_WD_analog_gamma(sb, gamma) sb[0x3b] = gamma /* see analog_gamma_table */
674
675 /* 0x3c */ 0x00, /* Reserved */
676
677 /* 0x3d */ 0x00, /* Next Calibration Lamp Density */
678 #define set_WD_lamp_c_density(sb, val) sb[0x3d] = val
679 # define WD_lamp_c_density_auto 0x00
680 # define WD_lamp_c_density_min 0x01
681 # define WD_lamp_c_density_max 0xff
682
683 /* 0x3e */ 0x00, /* Reserved */
684
685 /* 0x3f */ 0x00, /* Next Scan Lamp Density */
686 #define set_WD_lamp_s_density(sb, val) sb[0x3f] = val
687 # define WD_lamp_s_density_auto 0x00
688 # define WD_lamp_s_density_min 0x01
689 # define WD_lamp_s_density_max 0xff
690
691 /* 0x40 */ 0x00, 0x00, 0x00, 0x00, /* Next Upper Left Y in 1200 dpt/inch */
692 #define set_WD_next_upper_left(sb, val) putnbyte(sb + 0x40, val, 4)
693
694 /* 0x44 */ 0x00, 0x00, 0x00, 0x00, /* Pixel Count */
695 #define set_WD_pixel_count(sb, val) putnbyte(sb + 0x44, val, 4)
696
697 /* 0x48 */ 0x00, 0x00, 0x00, 0x00, /* Line Count */
698 #define set_WD_line_count(sb, val) putnbyte(sb + 0x48, val, 4)
699
700 /* 0x4c */ 4, 176, /* x coordinate base 1200 (pts/inch) */
701 #define set_WD_x_coordinate_base(sb, val) putnbyte(sb + 0x4c, val, 2)
702
703 /* 0x4e */ 4, 176, /* y coordinate base 1200 (pts/inch) */
704 #define set_WD_y_coordinate_base(sb, val) putnbyte(sb + 0x4e, val, 2)
705
706 /* 0x50 */ 0x00, /* reserved */
707
708 /* 0x51 */ 0x00, /* driver calibration need image data lines */
709 #define set_WD_calibration_data_lines(sb, val) sb[0x51] = val
710
711 /* 0x52 */ 0x00 /* start density */
712 #define set_WD_start_density(sb, val) sb[0x52] = val
713
714 /* if somone adds here anything, please change used_WDB_size in this file !! */
715 };
716
717
718 static scsiblk window_descriptor_block = { window_descriptor_blockC, sizeof(window_descriptor_blockC) };
719
720
721 /* --------------------------------------------------------------------------------------------------------- */
722
723
724 #define set_WDB_length(length) (window_descriptor_block.size = (length))
725
726 #define WPDB_OFF(b) (b + set_window.size)
727
728 #define WDB_OFF(b, n) (b + set_window.size + \
729 window_parameter_data_block.size + \
730 ( window_descriptor_block.size * (n - 1) ) )
731
732 #define set_WPDB_wdbnum(sb,n) set_WPDB_wdblen(sb,window_descriptor_block.size*n)
733
734
735 /* --------------------------------------------------------------------------------------------------------- */
736
737
738 static unsigned char scanC[] = { SCAN, 0x00, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00 };
739
740 static scsiblk scan = { scanC, sizeof(scanC) - 3 };
741 #define set_SC_xfer_length(sb, val) sb[0x04] = val
742 #define set_SC_quality(sb, val) setbitfield(sb + 0x05, 1, 5, val)
743 #define set_SC_adf(sb, val) setbitfield(sb + 0x05, 1, 6, val)
744 #define set_SC_preview(sb, val) setbitfield(sb + 0x05, 1, 7, val)
745 #define set_SC_wid(sb, n, val) sb[0x05 + n] = val
746
747
748 /* --------------------------------------------------------------------------------------------------------- */
749
750
751 /* sread instead of read because read is a libc primitive */
752 static unsigned char sreadC[] = { READ, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
753
754 static scsiblk sread = { sreadC, sizeof(sreadC) };
755
756 #define set_R_datatype_code(sb, val) sb[0x02] = val
757 # define R_datatype_imagedata 0x00
758 # define R_datatype_vendorspecific 0x01
759 # define R_datatype_halftone 0x02
760 # define R_datatype_gamma 0x03
761 # define R_datatype_shading 0x80
762 # define R_datatype_gain 0x81
763
764 #define set_R_datatype_qual_winid(sb, val) sb[0x05] = val
765 #define set_R_xfer_length(sb, val) putnbyte(sb + 0x06, val, 3)
766
767
768 /* --------------------------------------------------------------------------------------------------------- */
769
770
771 static unsigned char sendC[] = { SEND, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
772
773 static scsiblk send = { sendC, sizeof(sendC) };
774
775 #define set_S_datatype_code(sb, val) sb[0x02] = val
776 # define S_datatype_imagedata 0x00
777 # define S_datatype_vendorspecific 0x01
778 # define S_datatype_halftone 0x02
779 # define S_datatype_gamma 0x03
780 # define S_datatype_shading 0x80
781 # define S_datatype_gain 0x81
782
783 #define set_S_datatype_qual_winid(sb, val) sb[0x05] = val
784
785 #define set_S_xfer_length(sb, val) putnbyte(sb + 0x06, val, 3)
786 # define S_xfer_length_gamma(l) ((l * (1024 + 1)) + 1)
787 # define S_xfer_length_1line 0x0402
788 # define S_xfer_length_2line 0x0803
789 # define S_xfer_length_3line 0x0c04
790
791 /* FIXME: add Type 0 download curve format */
792 /* FIXME: add Type 1 download curve format */
793
794
795 static unsigned char gamma_DCF0C[] = { 0x00 };
796 static scsiblk gamma_DCF0 = { gamma_DCF0C, sizeof(gamma_DCF0C) };
797 #define set_DCF0_gamma_color(dc,col,val) dc[1 + (1025 * col)] = val
798 # define DCF0_gamma_color_gray 0
799 # define DCF0_gamma_color_red 1
800 # define DCF0_gamma_color_green 2
801 # define DCF0_gamma_color_blue 3
802
803 #define set_DCF0_gamma_lines(dc,val) setbitfield(dc + 0x00, 3, 0, val)
804 # define DCF0_gamma_one_line 1
805 # define DCF0_gamma_three_lines 3
806
807
808 static unsigned char gamma_DCF1C[] = { 0x00, 0x00 };
809 static scsiblk gamma_DCF1 = { gamma_DCF1C, sizeof(gamma_DCF1C) };
810 #define set_DCF1_gamma_color(dc,val) dc[1] = val
811 # define DCF1_gamma_color_gray 0
812 # define DCF1_gamma_color_red 1
813 # define DCF1_gamma_color_green 2
814 # define DCF1_gamma_color_blue 3
815
816
817 static unsigned char gamma_DCF2C[] = { 0x21, 0x00, 0x01, 0x00, 0x01, 0x00 };
818 static scsiblk gamma_DCF2 = { gamma_DCF2C, sizeof(gamma_DCF2C) };
819
820 #define set_DCF2_gamma_color(dc,val) setbitfield(dc + 0x00, 3, 2, val)
821 # define DCF2_gamma_color_gray 0
822 # define DCF2_gamma_color_red 1
823 # define DCF2_gamma_color_green 2
824 # define DCF2_gamma_color_blue 3
825
826 #define set_DCF2_gamma_lines(dc,val) setbitfield(dc + 0x00, 3, 0, val)
827 # define DCF2_gamma_one_line 1
828 # define DCF2_gamma_three_lines 3
829
830 #define set_DCF2_gamma_input_bits(dc,val) dc[0x02]=val
831 #define set_DCF2_gamma_output_bits(dc,val) dc[0x04]=val
832 # define DCF2_gamma_8_bits 1
833 # define DCF2_gamma_10_bits 4
834
835
836 /* --------------------------------------------------------------------------------------------------------- */
837
838
839 static unsigned char object_positionC[] =
840 { OBJECT_POSITION, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
841
842 static scsiblk object_position = { object_positionC, sizeof(object_positionC) };
843
844
845 /* --------------------------------------------------------------------------------------------------------- */
846
847
848 #ifndef UMAX_HIDE_UNUSED
849 static unsigned char get_data_buffer_statusC[] =
850 {
851 GET_DATA_BUFFER_STATUS, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00 };
852
853 #define set_GDBS_wait(sb, val) setbitfield(sb + 0x01, 1, 0, val)
854 #define set_GDBS_len(sb, nwins) putnbyte(sb + 0x07, (4 + (nwins * 8)), 2)
855
856 static scsiblk get_data_buffer_status = { get_data_buffer_statusC, sizeof(get_data_buffer_statusC) };
857
858 /* DBS is Data Buffer Status, the header that is returned */
859 #define get_DBS_data_buffer_status_length(sb) getnbyte(sb, 3)
860 #define get_DBSD_block_bit(sb) getbitfield(sb + 3, 1, 0)
861
862 /* DBSD are the Data Buffer Status Descriptors, the records that
863 * are returned following the DBS header. */
864 /* order is the number of the DBSD, from 1 to (length/8) */
865 #define get_DBSD_winid(sb, order) sb[4 + ((order - 1) * 8)]
866 #define get_DBSD_available_data_buffer(sb,order) getnbyte(sb+4+((order-1)*8)+2,3)
867 #define get_DBSD_filled_data_buffer(sb,order) getnbyte(sb+4+((order-1)*8)+5,3)
868
869 #define gdbs_return_block_size 12
870 #endif
871
872
873 /* --------------------------------------------------------------------------------------------------------- */
874
875
876 #ifndef UMAX_HIDE_UNUSED
877 static unsigned char write_bufferC[] =
878 { WRITE_BUFFER, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
879
880 static scsiblk write_buffer = { write_bufferC, sizeof(write_bufferC) };
881 #endif
882
883
884 /* --------------------------------------------------------------------------------------------------------- */
885
886
887 static double analog_gamma_table[16]={1.0000, 1.0434, 1.0887, 1.1361, \
888 1.1859, 1.2382, 1.2933, 1.3516, \
889 1.4134, 1.4792, 1.5495, 1.6251, \
890 1.7067, 1.7954, 1.8926, 2.0000 };
891
892
893 /* --------------------------------------------------------------------------------------------------------- */
894
895
896 static unsigned char request_senseC[] = { REQUEST_SENSE, 0x00, 0x00, 0x00, 0x00, 0x00 };
897 #define set_RS_allocation_length(sb,val) sb[0x04]=val
898 #define set_RS_LUN(sb,val) setbitfield(sb + 0x01, 7, 5) /* ??? */
899
900 static scsiblk request_sense = { request_senseC, sizeof(request_senseC) };
901
902 /* defines for request sense return block */
903 #define get_RS_information_valid(b) getbitfield(b + 0x00, 1, 7)
904 #define get_RS_error_code(b) getbitfield(b + 0x00, 0x7f, 0)
905 #define get_RS_filemark(b) getbitfield(b + 0x02, 1, 7)
906 #define get_RS_EOM(b) getbitfield(b + 0x02, 1, 6)
907 #define get_RS_ILI(b) getbitfield(b + 0x02, 1, 5)
908 #define get_RS_sense_key(b) getbitfield(b + 0x02, 0x0f, 0)
909 #define get_RS_information(b) getnbyte(b+0x03, 4)
910 #define get_RS_additional_length(b) b[0x07]
911 #define get_RS_ASC(b) b[0x0c]
912 #define get_RS_ASCQ(b) b[0x0d]
913 #define get_RS_SKSV(b) getbitfield(b+0x0f,1,7) /* valid */
914 #define get_RS_CD(b) getbitfield(b+0x0f,1,6) /* 1=CDB */
915 #define get_RS_field_pointer(b) getnbyte(b+0x10, 2)
916
917 #define get_RS_additional_sense(b) getnbyte(b+0x12, 2)
918 #define get_RS_asb_dim_light(b) getbitfield(b+0x12,1,7)
919 #define get_RS_asb_no_light(b) getbitfield(b+0x12,1,6)
920 #define get_RS_asb_sensor_motor(b) getbitfield(b+0x12,1,5)
921 #define get_RS_asb_too_light(b) getbitfield(b+0x12,1,4)
922 #define get_RS_asb_calibration(b) getbitfield(b+0x12,1,3)
923 #define get_RS_asb_rom(b) getbitfield(b+0x12,1,2)
924 #define get_RS_asb_ram(b) getbitfield(b+0x12,1,1)
925 #define get_RS_asb_cpu(b) getbitfield(b+0x12,1,0)
926 #define get_RS_asb_scsi(b) getbitfield(b+0x13,1,7)
927 #define get_RS_asb_timer(b) getbitfield(b+0x13,1,6)
928 #define get_RS_asb_filter_motor(b) getbitfield(b+0x13,1,5)
929 #define get_RS_asb_dc_adjust(b) getbitfield(b+0x13,1,1)
930 #define get_RS_asb_uta_sensor(b) getbitfield(b+0x13,1,0)
931
932 #define get_RS_scanner_error_code(b) b[0x15]
933 #define get_RS_SCC_condition_code(b) b[0x17]
934 #define get_RS_SCC_calibration_bytesperline(b) getnbyte(b+0x18, 4)
935 #define get_RS_SCC_calibration_lines(b) getnbyte(b+0x1c, 2)
936 #define get_RS_SCC_calibration_bytespp(b) b[0x1e]
937
938 #define rs_return_block_size 0x1f
939
940
941 /* --------------------------------------------------------------------------------------------------------- */
942
943
944 static char *cbhs_str[] = { "0-50","0-255", "0-255 autoexposure", "reserved" };
945
946 static char *scanmode_str[] = { "flatbed (FB)", "automatic document feeder (ADF)" };
947
948 static char *gamma_lines_str[]= { "reserved",
949 "one line (gray), three pass (color) download",
950 "reserved",
951 "one line (gray), three lines (color) download" };
952
953 static char *color_sequence_str[]= { "R->G->B","R->B->G",
954 "G->B->R","G->R->B",
955 "B->R->G","B->G->R",
956 "reserved","all supported"};
957
958
959 /* --------------------------------------------------------------------------------------------------------- */
960
961
962 static char *sense_str[] = {"NO SENSE",
963 "RECOVERED ERROR",
964 "NOT READY",
965 "MEDIUM ERROR",
966 "HARDWARE ERROR",
967 "ILLEGAL REQUEST",
968 "UNIT ATTENTION",
969 "DATA PROTECT",
970 "BLANK CHECK",
971 "VENDOR SPECIFIC",
972 "COPY ABORTED",
973 "ABORTED COMMAND",
974 "EQUAL",
975 "VOLUME OVERFLOW",
976 "MISCOMPARE",
977 "??? - SENSE 0FH" };
978
979 /* --------------------------------------------------------------------------------------------------------- */
980
981
982 static char *scanner_error_str[] =
983 {"no error", /* 0 */
984 "CPU error",
985 "err 2",
986 "err 3",
987 "ROM error",
988 "err 5",
989 "err 6",
990 "err 7",
991 "err 8",
992 "err 9",
993 "buffer error", /* 10 */
994 "system buffer error",
995 "shading buffer error",
996 "video buffer error",
997 "stack buffer error",
998 "control buffer error",
999 "gamma buffer error",
1000 "err 17",
1001 "err 18",
1002 "err 19",
1003 "lamp error", /* 20 */
1004 "dark error",
1005 "dim error",
1006 "light error",
1007 "lamp adjust control error (by darken)",
1008 "err 25",
1009 "err 26",
1010 "err 27",
1011 "err 28",
1012 "err 29",
1013 "calibration error", /* 30 */
1014 "dc offset error",
1015 "gain error",
1016 "auto focus error",
1017 "err 34",
1018 "err 35",
1019 "err 36",
1020 "err 37",
1021 "err 38",
1022 "err 39",
1023 "scsi error", /* 40 */
1024 "err 41",
1025 "asic error",
1026 "timer error",
1027 "ccd error",
1028 "err 45",
1029 "err 46",
1030 "err 47",
1031 "err 48",
1032 "err 49",
1033 "uta error", /* 50 */
1034 "uta home or motor sensor error",
1035 "err 52",
1036 "err 53",
1037 "err 54",
1038 "err 55",
1039 "err 56",
1040 "err 57",
1041 "err 58",
1042 "err 59",
1043 "adf error", /* 60 */
1044 "adf paper jam",
1045 "adf no paper",
1046 "adf cover open",
1047 "err 64",
1048 "err 65",
1049 "err 66",
1050 "err 67",
1051 "err 68",
1052 "err 69",
1053 "fb sensor error", /* 70 */
1054 "fb home or motor sensor error",
1055 "fb filter or motor sensor error",
1056 "fb lens or motor sensor error"
1057 "first line position error (LER error, vertical)",
1058 "first pixel position error (SER error, horizontal)",
1059 "first pixel position error for lens 2 (SER2 error, horizontal)",
1060 "err 77",
1061 "err 78",
1062 "err 79",
1063 "err", /* 80 */
1064 "err",
1065 "err",
1066 "err",
1067 "err",
1068 "err",
1069 "err",
1070 "err",
1071 "err",
1072 "err",
1073 "err", /* 90 */
1074 "err",
1075 "err",
1076 "err",
1077 "err",
1078 "err",
1079 "err",
1080 "err",
1081 "err",
1082 "err" /* 99 */
1083 };
1084
1085
1086 /* --------------------------------------------------------------------------------------------------------- */
1087
1088
1089 #endif
1090