1 /* sane - Scanner Access Now Easy.
2
3 Copyright (C) 2002 Frank Zago (sane at zago dot net)
4
5 This file is part of the SANE package.
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>.
19
20 As a special exception, the authors of SANE give permission for
21 additional uses of the libraries contained in this release of SANE.
22
23 The exception is that, if you link a SANE library with other files
24 to produce an executable, this does not by itself cause the
25 resulting executable to be covered by the GNU General Public
26 License. Your use of that executable is in no way restricted on
27 account of linking the SANE library code into it.
28
29 This exception does not, however, invalidate any other reasons why
30 the executable file might be covered by the GNU General Public
31 License.
32
33 If you submit changes to SANE to the maintainers to be included in
34 a subsequent release, you agree by submitting the changes that
35 those changes may be distributed with this exception intact.
36
37 If you write modifications of your own for SANE, it is your choice
38 whether to permit this exception to apply to your modifications.
39 If you do not wish that, delete this exception notice.
40 */
41
42 /* Commands supported by the scanner. */
43 #define SCSI_TEST_UNIT_READY 0x00
44 #define SCSI_INQUIRY 0x12
45 #define SCSI_SCAN 0x1b
46 #define SCSI_SET_WINDOW 0x24
47 #define SCSI_READ_10 0x28
48 #define SCSI_SEND_10 0x2a
49 #define SCSI_REQUEST_SENSE 0x03
50 #define SCSI_GET_DATA_BUFFER_STATUS 0x34
51
52 typedef struct
53 {
54 unsigned char data[16];
55 int len;
56 }
57 CDB;
58
59
60 /* Set a specific bit depending on a boolean.
61 * MKSCSI_BIT(TRUE, 3) will generate 0x08. */
62 #define MKSCSI_BIT(bit, pos) ((bit)? 1<<(pos): 0)
63
64 /* Set a value in a range of bits.
65 * MKSCSI_I2B(5, 3, 5) will generate 0x28 */
66 #define MKSCSI_I2B(bits, pos_b, pos_e) ((bits) << (pos_b) & ((1<<((pos_e)-(pos_b)+1))-1))
67
68 /* Store an integer in 2, 3 or 4 byte in an array. */
69 #define Ito16(val, buf) { \
70 ((unsigned char *)buf)[0] = ((val) >> 8) & 0xff; \
71 ((unsigned char *)buf)[1] = ((val) >> 0) & 0xff; \
72 }
73
74 #define Ito24(val, buf) { \
75 ((unsigned char *)buf)[0] = ((val) >> 16) & 0xff; \
76 ((unsigned char *)buf)[1] = ((val) >> 8) & 0xff; \
77 ((unsigned char *)buf)[2] = ((val) >> 0) & 0xff; \
78 }
79
80 #define Ito32(val, buf) { \
81 ((unsigned char *)buf)[0] = ((val) >> 24) & 0xff; \
82 ((unsigned char *)buf)[1] = ((val) >> 16) & 0xff; \
83 ((unsigned char *)buf)[2] = ((val) >> 8) & 0xff; \
84 ((unsigned char *)buf)[3] = ((val) >> 0) & 0xff; \
85 }
86
87 #define MKSCSI_GET_DATA_BUFFER_STATUS(cdb, wait, buflen) \
88 cdb.data[0] = SCSI_GET_DATA_BUFFER_STATUS; \
89 cdb.data[1] = MKSCSI_BIT(wait, 0); \
90 cdb.data[2] = 0; \
91 cdb.data[3] = 0; \
92 cdb.data[4] = 0; \
93 cdb.data[5] = 0; \
94 cdb.data[6] = 0; \
95 cdb.data[7] = (((buflen) >> 8) & 0xff); \
96 cdb.data[8] = (((buflen) >> 0) & 0xff); \
97 cdb.data[9] = 0; \
98 cdb.len = 10;
99
100 #define MKSCSI_INQUIRY(cdb, buflen) \
101 cdb.data[0] = SCSI_INQUIRY; \
102 cdb.data[1] = 0; \
103 cdb.data[2] = 0; \
104 cdb.data[3] = 0; \
105 cdb.data[4] = buflen; \
106 cdb.data[5] = 0; \
107 cdb.len = 6;
108
109 #define MKSCSI_SCAN(cdb) \
110 cdb.data[0] = SCSI_SCAN; \
111 cdb.data[1] = 0; \
112 cdb.data[2] = 0; \
113 cdb.data[3] = 0; \
114 cdb.data[4] = 0; \
115 cdb.data[5] = 0; \
116 cdb.len = 6;
117
118 #define MKSCSI_SEND_10(cdb, dtc, dtq, buflen) \
119 cdb.data[0] = SCSI_SEND_10; \
120 cdb.data[1] = 0; \
121 cdb.data[2] = (dtc); \
122 cdb.data[3] = 0; \
123 cdb.data[4] = (((dtq) >> 8) & 0xff); \
124 cdb.data[5] = (((dtq) >> 0) & 0xff); \
125 cdb.data[6] = (((buflen) >> 16) & 0xff); \
126 cdb.data[7] = (((buflen) >> 8) & 0xff); \
127 cdb.data[8] = (((buflen) >> 0) & 0xff); \
128 cdb.data[9] = 0; \
129 cdb.len = 10;
130
131 #define MKSCSI_SET_WINDOW(cdb, buflen) \
132 cdb.data[0] = SCSI_SET_WINDOW; \
133 cdb.data[1] = 0; \
134 cdb.data[2] = 0; \
135 cdb.data[3] = 0; \
136 cdb.data[4] = 0; \
137 cdb.data[5] = 0; \
138 cdb.data[6] = (((buflen) >> 16) & 0xff); \
139 cdb.data[7] = (((buflen) >> 8) & 0xff); \
140 cdb.data[8] = (((buflen) >> 0) & 0xff); \
141 cdb.data[9] = 0; \
142 cdb.len = 10;
143
144 #define MKSCSI_READ_10(cdb, dtc, dtq, buflen) \
145 cdb.data[0] = SCSI_READ_10; \
146 cdb.data[1] = 0; \
147 cdb.data[2] = (dtc); \
148 cdb.data[3] = 0; \
149 cdb.data[4] = (((dtq) >> 8) & 0xff); \
150 cdb.data[5] = (((dtq) >> 0) & 0xff); \
151 cdb.data[6] = (((buflen) >> 16) & 0xff); \
152 cdb.data[7] = (((buflen) >> 8) & 0xff); \
153 cdb.data[8] = (((buflen) >> 0) & 0xff); \
154 cdb.data[9] = 0; \
155 cdb.len = 10;
156
157 #define MKSCSI_REQUEST_SENSE(cdb, buflen) \
158 cdb.data[0] = SCSI_REQUEST_SENSE; \
159 cdb.data[1] = 0; \
160 cdb.data[2] = 0; \
161 cdb.data[3] = 0; \
162 cdb.data[4] = (buflen); \
163 cdb.data[5] = 0; \
164 cdb.len = 6;
165
166 #define MKSCSI_TEST_UNIT_READY(cdb) \
167 cdb.data[0] = SCSI_TEST_UNIT_READY; \
168 cdb.data[1] = 0; \
169 cdb.data[2] = 0; \
170 cdb.data[3] = 0; \
171 cdb.data[4] = 0; \
172 cdb.data[5] = 0; \
173 cdb.len = 6;
174
175 /*--------------------------------------------------------------------------*/
176
177 static int
getbitfield(unsigned char *pageaddr, int mask, int shift)178 getbitfield (unsigned char *pageaddr, int mask, int shift)
179 {
180 return ((*pageaddr >> shift) & mask);
181 }
182
183 /* defines for request sense return block */
184 #define get_RS_information_valid(b) getbitfield(b + 0x00, 1, 7)
185 #define get_RS_error_code(b) getbitfield(b + 0x00, 0x7f, 0)
186 #define get_RS_filemark(b) getbitfield(b + 0x02, 1, 7)
187 #define get_RS_EOM(b) getbitfield(b + 0x02, 1, 6)
188 #define get_RS_ILI(b) getbitfield(b + 0x02, 1, 5)
189 #define get_RS_sense_key(b) getbitfield(b + 0x02, 0x0f, 0)
190 #define get_RS_information(b) getnbyte(b+0x03, 4)
191 #define get_RS_additional_length(b) b[0x07]
192 #define get_RS_ASC(b) b[0x0c]
193 #define get_RS_ASCQ(b) b[0x0d]
194 #define get_RS_SKSV(b) getbitfield(b+0x0f,1,7)
195
196 /*--------------------------------------------------------------------------*/
197
198 #define mmToIlu(mm) (((mm) * dev->x_resolution) / MM_PER_INCH)
199 #define iluToMm(ilu) (((ilu) * MM_PER_INCH) / dev->x_resolution)
200
201 /*--------------------------------------------------------------------------*/
202
203 #define GAMMA_LENGTH 0x100 /* number of value per color */
204
205 /*--------------------------------------------------------------------------*/
206
207 enum Leo_Option
208 {
209 /* Must come first */
210 OPT_NUM_OPTS = 0,
211
212 OPT_MODE_GROUP,
213 OPT_MODE, /* scanner modes */
214 OPT_RESOLUTION, /* X and Y resolution */
215
216 OPT_GEOMETRY_GROUP,
217 OPT_TL_X, /* upper left X */
218 OPT_TL_Y, /* upper left Y */
219 OPT_BR_X, /* bottom right X */
220 OPT_BR_Y, /* bottom right Y */
221
222 OPT_ENHANCEMENT_GROUP,
223 OPT_CUSTOM_GAMMA, /* Use the custom gamma tables */
224 OPT_GAMMA_VECTOR_R, /* Custom Red gamma table */
225 OPT_GAMMA_VECTOR_G, /* Custom Green Gamma table */
226 OPT_GAMMA_VECTOR_B, /* Custom Blue Gamma table */
227 OPT_GAMMA_VECTOR_GRAY, /* Custom Gray Gamma table */
228 OPT_HALFTONE_PATTERN, /* Halftone pattern */
229
230 OPT_PREVIEW, /* preview mode */
231
232 /* must come last: */
233 OPT_NUM_OPTIONS
234 };
235
236 /*--------------------------------------------------------------------------*/
237
238 /*
239 * Scanner supported by this backend.
240 */
241 struct scanners_supported
242 {
243 int scsi_type;
244 char scsi_vendor[9];
245 char scsi_product[17];
246
247 const char *real_vendor;
248 const char *real_product;
249 };
250
251 /*--------------------------------------------------------------------------*/
252
253 #define BLACK_WHITE_STR SANE_VALUE_SCAN_MODE_LINEART
254 #define GRAY_STR SANE_VALUE_SCAN_MODE_GRAY
255 #define COLOR_STR SANE_VALUE_SCAN_MODE_COLOR
256
257 /*--------------------------------------------------------------------------*/
258
259 /* Define a scanner occurrence. */
260 typedef struct Leo_Scanner
261 {
262 struct Leo_Scanner *next;
263 SANE_Device sane;
264
265 char *devicename;
266 int sfd; /* device handle */
267
268 /* Infos from inquiry. */
269 char scsi_type;
270 char scsi_vendor[9];
271 char scsi_product[17];
272 char scsi_version[5];
273
274 SANE_Range res_range;
275
276 int x_resolution_max; /* maximum X dpi */
277 int y_resolution_max; /* maximum Y dpi */
278
279 /* SCSI handling */
280 size_t buffer_size; /* size of the buffer */
281 SANE_Byte *buffer; /* for SCSI transfer. */
282
283
284 /* Scanner infos. */
285 const struct scanners_supported *def; /* default options for that scanner */
286
287 /* Scanning handling. */
288 int scanning; /* TRUE if a scan is running. */
289 int x_resolution; /* X resolution in DPI */
290 int y_resolution; /* Y resolution in DPI */
291 int x_tl; /* X top left */
292 int y_tl; /* Y top left */
293 int x_br; /* X bottom right */
294 int y_br; /* Y bottom right */
295 int width; /* width of the scan area in mm */
296 int length; /* length of the scan area in mm */
297 int pass; /* current pass number */
298
299 enum
300 {
301 LEO_BW,
302 LEO_HALFTONE,
303 LEO_GRAYSCALE,
304 LEO_COLOR
305 }
306 scan_mode;
307
308 int depth; /* depth per color */
309
310 size_t bytes_left; /* number of bytes left to give to the backend */
311
312 size_t real_bytes_left; /* number of bytes left the scanner will return. */
313
314 SANE_Byte *image; /* keep the raw image here */
315 size_t image_size; /* allocated size of image */
316 size_t image_begin; /* first significant byte in image */
317 size_t image_end; /* first free byte in image */
318
319 SANE_Parameters params;
320
321 /* Options */
322 SANE_Option_Descriptor opt[OPT_NUM_OPTIONS];
323 Option_Value val[OPT_NUM_OPTIONS];
324
325 /* Gamma table. 1 array per colour. */
326 SANE_Word gamma_R[GAMMA_LENGTH];
327 SANE_Word gamma_G[GAMMA_LENGTH];
328 SANE_Word gamma_B[GAMMA_LENGTH];
329 SANE_Word gamma_GRAY[GAMMA_LENGTH];
330 }
331 Leo_Scanner;
332
333 /*--------------------------------------------------------------------------*/
334
335 /* Debug levels.
336 * Should be common to all backends. */
337
338 #define DBG_error0 0
339 #define DBG_error 1
340 #define DBG_sense 2
341 #define DBG_warning 3
342 #define DBG_inquiry 4
343 #define DBG_info 5
344 #define DBG_info2 6
345 #define DBG_proc 7
346 #define DBG_read 8
347 #define DBG_sane_init 10
348 #define DBG_sane_proc 11
349 #define DBG_sane_info 12
350 #define DBG_sane_option 13
351
352 /*--------------------------------------------------------------------------*/
353
354 /* 32 bits from an array to an integer (eg ntohl). */
355 #define B32TOI(buf) \
356 ((((unsigned char *)buf)[0] << 24) | \
357 (((unsigned char *)buf)[1] << 16) | \
358 (((unsigned char *)buf)[2] << 8) | \
359 (((unsigned char *)buf)[3] << 0))
360
361 #define B24TOI(buf) \
362 ((((unsigned char *)buf)[0] << 16) | \
363 (((unsigned char *)buf)[1] << 8) | \
364 (((unsigned char *)buf)[2] << 0))
365
366 #define B16TOI(buf) \
367 ((((unsigned char *)buf)[0] << 8) | \
368 (((unsigned char *)buf)[1] << 0))
369
370 /*--------------------------------------------------------------------------*/
371
372 /* Downloadable halftone patterns */
373 typedef unsigned char halftone_pattern_t[256];
374
375 static const halftone_pattern_t haltfone_pattern_diamond = {
376 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x19, 0x61, 0xD8, 0xF0, 0xE0, 0x60, 0x20,
377 0x00, 0x19, 0x61, 0xD8,
378 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40,
379 0x38, 0x58, 0x80, 0xB8,
380 0x30, 0x50, 0x98, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x98, 0xB0,
381 0xC8, 0xA8, 0x90, 0x48,
382 0x08, 0x10, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x10, 0x70, 0xD0,
383 0xF8, 0xE8, 0x68, 0x28,
384 0x00, 0x18, 0x78, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x18, 0x78, 0xD8,
385 0xF0, 0xE0, 0x60, 0x20,
386 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8,
387 0xC0, 0xA0, 0x88, 0x40,
388 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x9B, 0xB0, 0xC8, 0xA8, 0x90, 0x48,
389 0x30, 0x50, 0x9B, 0xB0,
390 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x18, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28,
391 0x08, 0x18, 0x70, 0xD0,
392 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x19, 0x61, 0xD8, 0xF0, 0xE0, 0x60, 0x20,
393 0x00, 0x19, 0x61, 0xD8,
394 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40,
395 0x38, 0x58, 0x80, 0xB8,
396 0x30, 0x50, 0x98, 0xB0, 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x98, 0xB0,
397 0xC8, 0xA8, 0x90, 0x48,
398 0x08, 0x10, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x10, 0x70, 0xD0,
399 0xF8, 0xE8, 0x68, 0x28,
400 0x00, 0x18, 0x78, 0xD8, 0xF0, 0xE0, 0x60, 0x20, 0x00, 0x18, 0x78, 0xD8,
401 0xF0, 0xE0, 0x60, 0x20,
402 0x38, 0x58, 0x80, 0xB8, 0xC0, 0xA0, 0x88, 0x40, 0x38, 0x58, 0x80, 0xB8,
403 0xC0, 0xA0, 0x88, 0x40,
404 0xC8, 0xA8, 0x90, 0x48, 0x30, 0x50, 0x9B, 0xB0, 0xC8, 0xA8, 0x90, 0x48,
405 0x30, 0x50, 0x9B, 0xB0,
406 0xF8, 0xE8, 0x68, 0x28, 0x08, 0x18, 0x70, 0xD0, 0xF8, 0xE8, 0x68, 0x28,
407 0x08, 0x18, 0x70, 0xD0
408 };
409
410 static const halftone_pattern_t haltfone_pattern_8x8_Coarse_Fatting = {
411 0x12, 0x3A, 0xD2, 0xEA, 0xE2, 0xB6, 0x52, 0x1A, 0x12, 0x3A, 0xD2, 0xEA,
412 0xE2, 0xB6, 0x52, 0x1A,
413 0x42, 0x6A, 0x9A, 0xCA, 0xC2, 0x92, 0x72, 0x4A, 0x42, 0x6A, 0x9A, 0xCA,
414 0xC2, 0x92, 0x72, 0x4A,
415 0xAE, 0x8E, 0x7E, 0x26, 0x2E, 0x66, 0x86, 0xA6, 0xAE, 0x8E, 0x7E, 0x26,
416 0x2E, 0x66, 0x86, 0xA6,
417 0xFA, 0xBA, 0x5E, 0x06, 0x0E, 0x36, 0xDE, 0xF6, 0xFA, 0xBA, 0x5E, 0x06,
418 0x0E, 0x36, 0xDE, 0xF6,
419 0xE6, 0xBE, 0x56, 0x1E, 0x16, 0x3E, 0xD6, 0xEE, 0xE6, 0xBE, 0x56, 0x1E,
420 0x16,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, 0xDA, 0xF2,
442 0xFE, 0xB2, 0x5A, 0x02
443 };
444
445 static const halftone_pattern_t haltfone_pattern_8x8_Fine_Fatting = {
446 0x02, 0x22, 0x92, 0xB2, 0x0A, 0x2A, 0x9A, 0xBA, 0x02, 0x22, 0x92, 0xB2,
447 0x0A, 0x2A, 0x9A, 0xBA,
448 0x42, 0x62, 0xD2, 0xF2, 0x4A, 0x6A, 0xDA, 0xFA, 0x42, 0x62, 0xD2, 0xF2,
449 0x4A, 0x6A, 0xDA, 0xFA,
450 0x82, 0xA2, 0x12, 0x32, 0x8A, 0xAA, 0x1A, 0x3A, 0x82, 0xA2, 0x12, 0x32,
451 0x8A, 0xAA, 0x1A, 0x3A,
452 0xC2, 0xE2, 0x52, 0x72, 0xCA, 0xEA, 0x5A, 0x7A, 0xC2, 0xE2, 0x52, 0x72,
453 0xCA, 0xEA, 0x5A, 0x7A,
454 0x0E, 0x2E, 0x9E, 0xBE, 0x06, 0x26, 0x96, 0xB6, 0x0E, 0x2E, 0x9E, 0xBE,
455 0x06, 0x26, 0x96, 0xB6,
456 0x4C, 0x6E, 0xDE, 0xFE, 0x46, 0x66, 0xD6, 0xF6, 0x4C, 0x6E, 0xDE, 0xFE,
457 0x46, 0x66, 0xD6, 0xF6,
458 0x8E, 0xAE, 0x1E, 0x3E, 0x86, 0xA6, 0x16, 0x36, 0x8E, 0xAE, 0x1E, 0x3E,
459 0x86, 0xA6, 0x16, 0x36,
460 0xCE, 0xEE, 0x60, 0x7E, 0xC6, 0xE6, 0x56, 0x76, 0xCE, 0xEE, 0x60, 0x7E,
461 0xC6, 0xE6, 0x56, 0x76,
462 0x02, 0x22, 0x92, 0xB2, 0x0A, 0x2A, 0x9A, 0xBA, 0x02, 0x22, 0x92, 0xB2,
463 0x0A, 0x2A, 0x9A, 0xBA,
464 0x42, 0x62, 0xD2, 0xF2, 0x4A, 0x6A, 0xDA, 0xFA, 0x42, 0x62, 0xD2, 0xF2,
465 0x4A, 0x6A, 0xDA, 0xFA,
466 0x82, 0xA2, 0x12, 0x32, 0x8A, 0xAA, 0x1A, 0x3A, 0x82, 0xA2, 0x12, 0x32,
467 0x8A, 0xAA, 0x1A, 0x3A,
468 0xC2, 0xE2, 0x52, 0x72, 0xCA, 0xEA, 0x5A, 0x7A, 0xC2, 0xE2, 0x52, 0x72,
469 0xCA, 0xEA, 0x5A, 0x7A,
470 0x0E, 0x2E, 0x9E, 0xBE, 0x06, 0x26, 0x96, 0xB6, 0x0E, 0x2E, 0x9E, 0xBE,
471 0x06, 0x26, 0x96, 0xB6,
472 0x4C, 0x6E, 0xDE, 0xFE, 0x46, 0x66, 0xD6, 0xF6, 0x4C, 0x6E, 0xDE, 0xFE,
473 0x46, 0x66, 0xD6, 0xF6,
474 0x8E, 0xAE, 0x1E, 0x3E, 0x86, 0xA6, 0x16, 0x36, 0x8E, 0xAE, 0x1E, 0x3E,
475 0x86, 0xA6, 0x16, 0x36,
476 0xCE, 0xEE, 0x60, 0x7E, 0xC6, 0xE6, 0x56, 0x76, 0xCE, 0xEE, 0x60, 0x7E,
477 0xC6, 0xE6, 0x56, 0x76
478 };
479
480 static const halftone_pattern_t haltfone_pattern_8x8_Bayer = {
481 0xF2, 0x42, 0x82, 0xC2, 0xFA, 0x4A, 0x8A, 0xCA, 0xF2, 0x42, 0x82, 0xC2,
482 0xFA, 0x4A, 0x8A, 0xCA,
483 0xB2, 0x02, 0x12, 0x52, 0xBA, 0x0A, 0x1A, 0x5A, 0xB2, 0x02, 0x12, 0x52,
484 0xBA, 0x0A, 0x1A, 0x5A,
485 0x72, 0x32, 0x22, 0x92, 0x7A, 0x3A, 0x2A, 0x9A, 0x72, 0x32, 0x22, 0x92,
486 0x7A, 0x3A, 0x2A, 0x9A,
487 0xE2, 0xA2, 0x62, 0xD2, 0xEA, 0xAA, 0x6A, 0xDA, 0xE2, 0xA2, 0x62, 0xD2,
488 0xEA, 0xAA, 0x6A, 0xDA,
489 0xFE, 0x4E, 0x8E, 0xCE, 0xF6, 0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E, 0x6E, 0xDE, 0xE6, 0xA6, 0x66, 0xD6, 0xEE, 0xAE, 0x6E, 0xDE,
512 0xE6, 0xA6, 0x66, 0xD6
513 };
514
515 static const halftone_pattern_t haltfone_pattern_8x8_Vertical_Line = {
516 0x02, 0x42, 0x82, 0xC4, 0x0A, 0x4C, 0x8A, 0xCA, 0x02, 0x42, 0x82, 0xC4,
517 0x0A, 0x4C, 0x8A, 0xCA,
518 0x12, 0x52, 0x92, 0xD2, 0x1A, 0x5A, 0x9A, 0xDA, 0x12, 0x52, 0x92, 0xD2,
519 0x1A, 0x5A, 0x9A, 0xDA,
520 0x22, 0x62, 0xA2, 0xE2, 0x2A, 0x6A, 0xAA, 0xEA, 0x22, 0x62, 0xA2, 0xE2,
521 0x2A, 0x6A, 0xAA, 0xEA,
522 0x32, 0x72, 0xB2, 0xF2, 0x3A, 0x7A, 0xBA, 0xFA, 0x32, 0x72, 0xB2, 0xF2,
523 0x3A, 0x7A, 0xBA, 0xFA,
524 0x0E, 0x4E, 0x8E, 0xCE, 0x06, 0x46, 0x86, 0xC6, 0x0E, 0x4E, 0x8E, 0xCE,
525 0x06, 0x46, 0x86, 0xC6,
526 0x1E, 0x5E, 0x9E, 0xDE, 0x16, 0x56, 0x96, 0xD6, 0x1E, 0x5E, 0x9E, 0xDE,
527 0x16, 0x56, 0x96, 0xD6,
528 0x2E, 0x6E, 0xAE, 0xEE, 0x26, 0x66, 0xA6, 0xE6, 0x2E, 0x6E, 0xAE, 0xEE,
529 0x26, 0x66, 0xA6, 0xE6,
530 0x3E, 0x7E, 0xBE, 0xFE, 0x36, 0x76, 0xB6, 0xF6, 0x3E, 0x7E, 0xBE, 0xFE,
531 0x36, 0x76, 0xB6, 0xF6,
532 0x02, 0x42, 0x82, 0xC4, 0x0A, 0x4C, 0x8A, 0xCA, 0x02, 0x42, 0x82, 0xC4,
533 0x0A, 0x4C, 0x8A, 0xCA,
534 0x12, 0x52, 0x92, 0xD2, 0x1A, 0x5A, 0x9A, 0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