~ubuntu-branches/ubuntu/saucy/sane-backends/saucy

« back to all changes in this revision

Viewing changes to backend/genesys_gl124.h

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2011-02-14 14:28:56 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110214142856-6gxjetg88q9zctid
Tags: 1.0.22-0ubuntu1
* New upstream release
* debian/control:
  - Use standards version 3.9.1
* debian/patches/allow_dll.d_symlinks.patch:
* debian/patches/fix_epson2_cancel.patch:
* debian/patches/fix_epson2_commands.patch:
* debian/patches/fix_xerox_mfp_color_mode.patch:
* debian/patches/genesys_disable_raw_data_log.patch:
* debian/patches/no_translations.patch:
* debian/patches/saned_exit_avahi_process.patch:
* debian/patches/scsi_perfection_2450.patch:
* debian/patches/scsi_scanjet_4c.patch:
* debian/patches/xerox_mfp_new_ids.patch:
  - Applied upstream
* debian/watch:
  - Dropped, the URL is not consistent between releases

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* sane - Scanner Access Now Easy.
 
2
 
 
3
   Copyright (C) 2010 St�phane Voltz <stef.dev@free.fr>
 
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, write to the Free Software
 
19
   Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 
20
   MA 02111-1307, USA.
 
21
   
 
22
   As a special exception, the authors of SANE give permission for
 
23
   additional uses of the libraries contained in this release of SANE.
 
24
   
 
25
   The exception is that, if you link a SANE library with other files
 
26
   to produce an executable, this does not by itself cause the
 
27
   resulting executable to be covered by the GNU General Public
 
28
   License.  Your use of that executable is in no way restricted on
 
29
   account of linking the SANE library code into it.
 
30
   
 
31
   This exception does not, however, invalidate any other reasons why
 
32
   the executable file might be covered by the GNU General Public
 
33
   License.
 
34
   
 
35
   If you submit changes to SANE to the maintainers to be included in
 
36
   a subsequent release, you agree by submitting the changes that
 
37
   those changes may be distributed with this exception intact.
 
38
 
 
39
   If you write modifications of your own for SANE, it is your choice
 
40
   whether to permit this exception to apply to your modifications.
 
41
   If you do not wish that, delete this exception notice. 
 
42
*/
 
43
#include "../include/sane/config.h"
 
44
 
 
45
#include <errno.h>
 
46
#include <string.h>
 
47
#include <stdlib.h>
 
48
#include <unistd.h>
 
49
#include <math.h>
 
50
 
 
51
#include "../include/sane/sane.h"
 
52
#include "../include/sane/sanei.h"
 
53
#include "../include/sane/saneopts.h"
 
54
 
 
55
#ifndef HACK
 
56
#undef BACKEND_NAME
 
57
#define BACKEND_NAME genesys_gl124
 
58
#endif
 
59
 
 
60
#include "../include/sane/sanei_backend.h"
 
61
#include "../include/sane/sanei_config.h"
 
62
#include "../include/sane/sanei_usb.h"
 
63
 
 
64
#include "../include/_stdint.h"
 
65
#include "genesys.h"
 
66
 
 
67
#define REG01           0x01
 
68
#define REG01_CISSET    0x80
 
69
#define REG01_DOGENB    0x40
 
70
#define REG01_DVDSET    0x20
 
71
#define REG01_STAGGER   0x10
 
72
#define REG01_COMPENB   0x08
 
73
#define REG01_TRUEGRAY  0x04
 
74
#define REG01_SHDAREA   0x02
 
75
#define REG01_SCAN      0x01
 
76
 
 
77
#define REG02           0x02
 
78
#define REG02_NOTHOME   0x80
 
79
#define REG02_ACDCDIS   0x40
 
80
#define REG02_AGOHOME   0x20
 
81
#define REG02_MTRPWR    0x10
 
82
#define REG02_FASTFED   0x08
 
83
#define REG02_MTRREV    0x04
 
84
#define REG02_HOMENEG   0x02
 
85
#define REG02_LONGCURV  0x01
 
86
 
 
87
#define REG03           0x03
 
88
#define REG03_LAMPDOG   0x80
 
89
#define REG03_AVEENB    0x40
 
90
#define REG03_XPASEL    0x20
 
91
#define REG03_LAMPPWR   0x10
 
92
#define REG03_LAMPTIM   0x0f
 
93
 
 
94
#define REG04           0x04
 
95
#define REG04_LINEART   0x80
 
96
#define REG04_BITSET    0x40
 
97
#define REG04_FILTER    0x30
 
98
#define REG04_AFEMOD    0x07
 
99
 
 
100
#define REG05           0x05
 
101
#define REG05_DPIHW     0xc0
 
102
#define REG05_DPIHW_600 0x00
 
103
#define REG05_DPIHW_1200        0x40
 
104
#define REG05_DPIHW_2400        0x80
 
105
#define REG05_DPIHW_4800        0xc0
 
106
#define REG05_MTLLAMP   0x30
 
107
#define REG05_GMMENB    0x08
 
108
#define REG05_ENB20M    0x04
 
109
#define REG05_MTLBASE   0x03
 
110
 
 
111
#define REG06           0x06
 
112
#define REG06_SCANMOD   0xe0
 
113
#define REG06S_SCANMOD  5
 
114
#define REG06_PWRBIT    0x10
 
115
#define REG06_GAIN4     0x08
 
116
#define REG06_OPTEST    0x07
 
117
 
 
118
#define REG07_LAMPSIM   0x80
 
119
 
 
120
#define REG08_DRAM2X    0x80
 
121
#define REG08_MPENB     0x20
 
122
#define REG08_CIS_LINE  0x10
 
123
#define REG08_IR2_ENB   0x08
 
124
#define REG08_IR1_ENB   0x04
 
125
#define REG08_ENB24M    0x01
 
126
 
 
127
#define REG09_MCNTSET   0xc0
 
128
#define REG09_EVEN1ST   0x20
 
129
#define REG09_BLINE1ST  0x10
 
130
#define REG09_BACKSCAN  0x08
 
131
#define REG09_OUTINV    0x04
 
132
#define REG09_SHORTTG   0x02
 
133
 
 
134
#define REG09S_MCNTSET  6
 
135
#define REG09S_CLKSET   4
 
136
 
 
137
#define REG0A           0x0a
 
138
#define REG0A_SIFSEL    0xc0
 
139
#define REG0AS_SIFSEL   6
 
140
#define REG0A_SHEETFED  0x20
 
141
#define REG0A_LPWMEN    0x10
 
142
 
 
143
#define REG0B           0x0b
 
144
#define REG0B_DRAMSEL   0x07
 
145
#define REG0B_16M       0x01
 
146
#define REG0B_64M       0x02
 
147
#define REG0B_128M      0x03
 
148
#define REG0B_256M      0x04
 
149
#define REG0B_512M      0x05
 
150
#define REG0B_1G        0x06
 
151
#define REG0B_ENBDRAM   0x08
 
152
#define REG0B_RFHDIS    0x10
 
153
#define REG0B_CLKSET    0xe0
 
154
#define REG0B_24MHZ     0x00
 
155
#define REG0B_30MHZ     0x20
 
156
#define REG0B_40MHZ     0x40
 
157
#define REG0B_48MHZ     0x60
 
158
#define REG0B_60MHZ     0x80
 
159
 
 
160
#define REG0D           0x0d
 
161
#define REG0D_MTRP_RDY  0x80
 
162
#define REG0D_FULLSTP   0x10
 
163
#define REG0D_CLRMCNT   0x04
 
164
#define REG0D_CLRDOCJM  0x02
 
165
#define REG0D_CLRLNCNT  0x01
 
166
 
 
167
#define REG0F           0x0f
 
168
 
 
169
#define REG16_CTRLHI    0x80
 
170
#define REG16_TOSHIBA   0x40
 
171
#define REG16_TGINV     0x20
 
172
#define REG16_CK1INV    0x10
 
173
#define REG16_CK2INV    0x08
 
174
#define REG16_CTRLINV   0x04
 
175
#define REG16_CKDIS     0x02
 
176
#define REG16_CTRLDIS   0x01
 
177
 
 
178
#define REG17_TGMODE    0xc0
 
179
#define REG17_SNRSYN    0x0f
 
180
 
 
181
#define REG18           0x18
 
182
#define REG18_CNSET     0x80
 
183
#define REG18_DCKSEL    0x60
 
184
#define REG18_CKTOGGLE  0x10
 
185
#define REG18_CKDELAY   0x0c
 
186
#define REG18_CKSEL     0x03
 
187
 
 
188
#define REG1A_SW2SET    0x80
 
189
#define REG1A_SW1SET    0x40
 
190
#define REG1A_MANUAL3   0x02
 
191
#define REG1A_MANUAL1   0x01
 
192
#define REG1A_CK4INV    0x08
 
193
#define REG1A_CK3INV    0x04
 
194
#define REG1A_LINECLP   0x02
 
195
 
 
196
#define REG1C_TBTIME    0x07
 
197
 
 
198
#define REG1D           0x1d
 
199
#define REG1D_CK4LOW    0x80
 
200
#define REG1D_CK3LOW    0x40
 
201
#define REG1D_CK1LOW    0x20
 
202
#define REG1D_LINESEL   0x1f
 
203
#define REG1DS_LINESEL  0
 
204
 
 
205
#define REG1E           0x1e
 
206
#define REG1E_WDTIME    0xf0
 
207
#define REG1ES_WDTIME   4
 
208
#define REG1E_WDTIME    0xf0
 
209
 
 
210
#define REG30           0x30
 
211
#define REG31           0x31
 
212
#define REG32           0x32
 
213
#define REG33           0x33
 
214
#define REG34           0x34
 
215
#define REG35           0x35
 
216
#define REG36           0x36
 
217
#define REG37           0x37
 
218
#define REG38           0x38
 
219
#define REG39           0x39
 
220
 
 
221
#define REG80           0x80
 
222
#define REG81           0x81
 
223
 
 
224
#define REGA0           0xa0
 
225
#define REGA0_FSTPSEL   0x28
 
226
#define REGA0S_FSTPSEL  3
 
227
#define REGA0_STEPSEL   0x03
 
228
#define REGA0S_STEPSEL  0
 
229
 
 
230
#define REGA1           0xa1
 
231
#define REGA2           0xa2
 
232
#define REGA3           0xa3
 
233
#define REGA4           0xa4
 
234
#define REGA5           0xa5
 
235
#define REGA6           0xa6
 
236
#define REGA7           0xa7
 
237
#define REGA8           0xa8
 
238
#define REGA9           0xa9
 
239
#define REGAA           0xaa
 
240
#define REGAB           0xab
 
241
#define REGAC           0xac
 
242
#define REGAD           0xad
 
243
#define REGAE           0xae
 
244
#define REGAF           0xaf
 
245
#define REGB0           0xb0
 
246
#define REGB1           0xb1
 
247
 
 
248
#define REGB2           0xb2
 
249
#define REGB2_Z1MOD     0x1f
 
250
#define REGB3           0xb3
 
251
#define REGB3_Z1MOD     0xff
 
252
#define REGB4           0xb4
 
253
#define REGB4_Z1MOD     0xff
 
254
 
 
255
#define REGB5           0xb5
 
256
#define REGB5_Z2MOD     0x1f
 
257
#define REGB6           0xb6
 
258
#define REGB6_Z2MOD     0xff
 
259
#define REGB7           0xb7
 
260
#define REGB7_Z2MOD     0xff
 
261
 
 
262
#define REG100          0
 
263
#define REG100_DOCSNR   0x80
 
264
#define REG100_ADFSNR   0x40
 
265
#define REG100_COVERSNR 0x20
 
266
#define REG100_CHKVER   0x10
 
267
#define REG100_DOCJAM   0x08
 
268
#define REG100_HISPDFLG 0x04
 
269
#define REG100_MOTMFLG  0x02
 
270
#define REG100_DATAENB  0x01
 
271
 
 
272
#define REG114          0x14
 
273
#define REG115          0x15
 
274
 
 
275
#define SCAN_TABLE      0       /* table 1 at 0x4000 */
 
276
#define BACKTRACK_TABLE 1       /* table 2 at 0x4800 */
 
277
#define STOP_TABLE      2       /* table 3 at 0x5000 */
 
278
#define FAST_TABLE      3       /* table 4 at 0x5800 */
 
279
#define HOME_TABLE      4       /* table 5 at 0x6000 */
 
280
 
 
281
#define REG_LINCNT      0x25
 
282
#define REG_MAXWD       0x28
 
283
#define REG_DPISET      0x2c
 
284
#define REG_FEEDL       0x3d
 
285
#define REG_CK1MAP      0x74
 
286
#define REG_CK3MAP      0x77
 
287
#define REG_CK4MAP      0x7a
 
288
#define REG_LPERIOD     0x7d
 
289
#define REG_DUMMY       0x80
 
290
#define REG_STRPIXEL    0x82
 
291
#define REG_ENDPIXEL    0x85
 
292
#define REG_EXPDMY      0x88
 
293
#define REG_EXPR        0x8a
 
294
#define REG_EXPG        0x8d
 
295
#define REG_EXPB        0x90
 
296
#define REG_SEGCNT      0x93
 
297
#define REG_TG0CNT      0x96
 
298
#define REG_SCANFED     0xa2
 
299
#define REG_STEPNO      0xa4
 
300
#define REG_FWDSTEP     0xa6
 
301
#define REG_BWDSTEP     0xa8
 
302
#define REG_FASTNO      0xaa
 
303
#define REG_FSHDEC      0xac
 
304
#define REG_FMOVNO      0xae
 
305
#define REG_FMOVDEC     0xb0
 
306
#define REG_Z1MOD       0xb2
 
307
#define REG_Z2MOD       0xb5
 
308
 
 
309
#define SCAN_FLAG_SINGLE_LINE              0x001
 
310
#define SCAN_FLAG_DISABLE_SHADING          0x002
 
311
#define SCAN_FLAG_DISABLE_GAMMA            0x004
 
312
#define SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE 0x008
 
313
#define SCAN_FLAG_IGNORE_LINE_DISTANCE     0x010
 
314
#define SCAN_FLAG_USE_OPTICAL_RES          0x020
 
315
#define SCAN_FLAG_DISABLE_LAMP             0x040
 
316
#define SCAN_FLAG_DYNAMIC_LINEART          0x080
 
317
#define SCAN_FLAG_CALIBRATION              0x100
 
318
#define SCAN_FLAG_FEEDING                  0x200
 
319
 
 
320
/**
 
321
 * writable scanner registers */
 
322
enum
 
323
{
 
324
  reg_0x01 = 0,
 
325
  reg_0x02,
 
326
  reg_0x03,
 
327
  reg_0x04,
 
328
  reg_0x05,
 
329
  reg_0x06,
 
330
  reg_0x07,
 
331
  reg_0x08,
 
332
  reg_0x09,
 
333
  reg_0x0a,
 
334
  reg_0x0b,
 
335
  reg_0x0c,
 
336
  reg_0x11,
 
337
  reg_0x12,
 
338
  reg_0x13,
 
339
  reg_0x14,
 
340
  reg_0x15,
 
341
  reg_0x16,
 
342
  reg_0x17,
 
343
  reg_0x18,
 
344
  reg_0x19,
 
345
  reg_0x1a,
 
346
  reg_0x1b,
 
347
  reg_0x1c,
 
348
  reg_0x1d,
 
349
  reg_0x1e,
 
350
  reg_0x1f,
 
351
  reg_0x20,
 
352
  reg_0x21,
 
353
  reg_0x22,
 
354
  reg_0x23,
 
355
  reg_0x24,
 
356
  reg_0x25,
 
357
  reg_0x26,
 
358
  reg_0x27,
 
359
  reg_0x28,
 
360
  reg_0x29,
 
361
  reg_0x2a,
 
362
  reg_0x2b,
 
363
  reg_0x2c,
 
364
  reg_0x2d,
 
365
  reg_0x3b,
 
366
  reg_0x3c,
 
367
  reg_0x3d,
 
368
  reg_0x3e,
 
369
  reg_0x3f,
 
370
  reg_0x40,
 
371
  reg_0x41,
 
372
  reg_0x42,
 
373
  reg_0x43,
 
374
  reg_0x44,
 
375
  reg_0x45,
 
376
  reg_0x46,
 
377
  reg_0x47,
 
378
  reg_0x48,
 
379
  reg_0x49,
 
380
  reg_0x4f,
 
381
  reg_0x52,
 
382
  reg_0x53,
 
383
  reg_0x54,
 
384
  reg_0x55,
 
385
  reg_0x56,
 
386
  reg_0x57,
 
387
  reg_0x58,
 
388
  reg_0x59,
 
389
  reg_0x5a,
 
390
  reg_0x5b,
 
391
  reg_0x5c,
 
392
  reg_0x5f,
 
393
  reg_0x60,
 
394
  reg_0x61,
 
395
  reg_0x62,
 
396
  reg_0x63,
 
397
  reg_0x64,
 
398
  reg_0x65,
 
399
  reg_0x66,
 
400
  reg_0x67,
 
401
  reg_0x68,
 
402
  reg_0x69,
 
403
  reg_0x6a,
 
404
  reg_0x6b,
 
405
  reg_0x6c,
 
406
  reg_0x6d,
 
407
  reg_0x6e,
 
408
  reg_0x6f,
 
409
  reg_0x70,
 
410
  reg_0x71,
 
411
  reg_0x72,
 
412
  reg_0x73,
 
413
  reg_0x74,
 
414
  reg_0x75,
 
415
  reg_0x76,
 
416
  reg_0x77,
 
417
  reg_0x78,
 
418
  reg_0x79,
 
419
  reg_0x7a,
 
420
  reg_0x7b,
 
421
  reg_0x7c,
 
422
  reg_0x7d,
 
423
  reg_0x7e,
 
424
  reg_0x7f,
 
425
  reg_0x80,
 
426
  reg_0x81,
 
427
  reg_0x82,
 
428
  reg_0x83,
 
429
  reg_0x84,
 
430
  reg_0x85,
 
431
  reg_0x86,
 
432
  reg_0x87,
 
433
  reg_0x88,
 
434
  reg_0x89,
 
435
  reg_0x8a,
 
436
  reg_0x8b,
 
437
  reg_0x8c,
 
438
  reg_0x8d,
 
439
  reg_0x8e,
 
440
  reg_0x8f,
 
441
  reg_0x90,
 
442
  reg_0x91,
 
443
  reg_0x92,
 
444
  reg_0x93,
 
445
  reg_0x94,
 
446
  reg_0x95,
 
447
  reg_0x96,
 
448
  reg_0x97,
 
449
  reg_0x98,
 
450
  reg_0x99,
 
451
  reg_0x9a,
 
452
  reg_0x9b,
 
453
  reg_0x9c,
 
454
  reg_0x9d,
 
455
  reg_0x9e,
 
456
  reg_0x9f,
 
457
  reg_0xa0,
 
458
  reg_0xa1,
 
459
  reg_0xa2,
 
460
  reg_0xa3,
 
461
  reg_0xa4,
 
462
  reg_0xa5,
 
463
  reg_0xa6,
 
464
  reg_0xa7,
 
465
  reg_0xa8,
 
466
  reg_0xa9,
 
467
  reg_0xaa,
 
468
  reg_0xab,
 
469
  reg_0xac,
 
470
  reg_0xad,
 
471
  reg_0xae,
 
472
  reg_0xaf,
 
473
  reg_0xb0,
 
474
  reg_0xb1,
 
475
  reg_0xb2,
 
476
  reg_0xb3,
 
477
  reg_0xb4,
 
478
  reg_0xb5,
 
479
  reg_0xb6,
 
480
  reg_0xb7,
 
481
  reg_0xb8,
 
482
  reg_0xbb,
 
483
  reg_0xbc,
 
484
  reg_0xbd,
 
485
  reg_0xbe,
 
486
  reg_0xc3,
 
487
  reg_0xc4,
 
488
  reg_0xc5,
 
489
  reg_0xc6,
 
490
  reg_0xc7,
 
491
  reg_0xc8,
 
492
  reg_0xc9,
 
493
  reg_0xca,
 
494
  reg_0xcb,
 
495
  reg_0xcc,
 
496
  reg_0xcd,
 
497
  reg_0xce,
 
498
  reg_0xd0,
 
499
  reg_0xd1,
 
500
  reg_0xd2,
 
501
  reg_0xd3,
 
502
  reg_0xd4,
 
503
  reg_0xd5,
 
504
  reg_0xd6,
 
505
  reg_0xd7,
 
506
  reg_0xd8,
 
507
  reg_0xd9,
 
508
  reg_0xe0,
 
509
  reg_0xe1,
 
510
  reg_0xe2,
 
511
  reg_0xe3,
 
512
  reg_0xe4,
 
513
  reg_0xe5,
 
514
  reg_0xe6,
 
515
  reg_0xe7,
 
516
  reg_0xe8,
 
517
  reg_0xe9,
 
518
  reg_0xea,
 
519
  reg_0xeb,
 
520
  reg_0xec,
 
521
  reg_0xed,
 
522
  reg_0xee,
 
523
  reg_0xef,
 
524
  reg_0xf0,
 
525
  reg_0xf1,
 
526
  reg_0xf2,
 
527
  reg_0xf3,
 
528
  reg_0xf4,
 
529
  reg_0xf5,
 
530
  reg_0xf6,
 
531
  reg_0xf7,
 
532
  reg_0xf8,
 
533
  reg_0xf9,
 
534
  reg_0xfa,
 
535
  reg_0xfb,
 
536
  reg_0xfc,
 
537
  reg_0xff,
 
538
  GENESYS_GL124_MAX_REGS
 
539
};
 
540
 
 
541
#define SETREG(adr,val) {dev->reg[reg_##adr].address=adr;dev->reg[reg_##adr].value=val;}
 
542
 
 
543
#define SLOPE_TABLE_SIZE 1024
 
544
 
 
545
typedef struct
 
546
{
 
547
  uint8_t r31;
 
548
  uint8_t r32;
 
549
  uint8_t r33;
 
550
  uint8_t r34;
 
551
  uint8_t r35;
 
552
  uint8_t r36;
 
553
  uint8_t r38;
 
554
} Gpio_layout;
 
555
 
 
556
/** @brief gpio layout
 
557
 * describes initial gpio settings for a given model
 
558
 */
 
559
static Gpio_layout gpios[]={
 
560
        /* LiDE 110 */
 
561
        { /*    0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38 */
 
562
                0x9f, 0x59, 0x01, 0x80, 0x5f, 0x01, 0x00
 
563
        },
 
564
        /* LiDE 210 */
 
565
        { 
 
566
                0x9f, 0x59, 0x01, 0x80, 0x5f, 0x01, 0x00
 
567
        },
 
568
};
 
569
 
 
570
typedef struct
 
571
{
 
572
  uint8_t rd0;
 
573
  uint8_t rd1;
 
574
  uint8_t rd2;
 
575
  uint8_t re0;
 
576
  uint8_t re1;
 
577
  uint8_t re2;
 
578
  uint8_t re3;
 
579
  uint8_t re4;
 
580
  uint8_t re5;
 
581
  uint8_t re6;
 
582
  uint8_t re7;
 
583
} Memory_layout;
 
584
 
 
585
static Memory_layout layouts[]={
 
586
        /* LIDE 110 */
 
587
        {
 
588
                0x0a, 0x15, 0x20,
 
589
                0x00, 0xac, 0x08, 0x55, 0x08, 0x56, 0x0f, 0xff
 
590
        },
 
591
        /* LIDE 210 */
 
592
        {
 
593
                0x0a, 0x1f, 0x34,
 
594
                0x01, 0x24, 0x08, 0x91, 0x08, 0x92, 0x0f, 0xff
 
595
        }
 
596
};
 
597
 
 
598
/** @brief structure for sensor settings
 
599
 * this structure describes the sensor settings to use for a given
 
600
 * exposure.
 
601
 */
 
602
typedef struct {
 
603
  int sensor_type;      /**> sensor id */
 
604
  int dpi;              /**> maximum dpi for which data are valid */
 
605
  int exposure;         /**> exposure */
 
606
  int ck1map;           /**> CK1MAP */
 
607
  int ck3map;           /**> CK2MAP */
 
608
  int ck4map;           /**> CK3MAP */
 
609
  int segcnt;           /**> SEGCNT */
 
610
  int tg0cnt;           /**> TG0CNT */
 
611
  int expdummy;         /**> exposure dummy */
 
612
  int expr;             /**> initial red exposure */
 
613
  int expg;             /**> initial green exposure */
 
614
  int expb;             /**> initial blue exposure */
 
615
  uint8_t reg18;        /**> register 0x18 value */
 
616
  uint8_t reg20;        /**> register 0x20 value */
 
617
  uint8_t reg61;        /**> register 0x61 value */
 
618
  uint8_t reg98;        /**> register 0x98 value */
 
619
} Sensor_Profile;
 
620
 
 
621
/**
 
622
 * database of sensor profiles
 
623
 */
 
624
static Sensor_Profile sensors[]={
 
625
        {CIS_CANONLIDE110,  300,  5359, 0x1e, 0x9f, 0x55, 5168, 154,  101,  388,  574,  393, 0x00, 0x0a, 0x20, 0x21},
 
626
        {CIS_CANONLIDE110,  600,  5360, 0x1e, 0x9f, 0x55, 5168, 163,  101,  388,  574,  393, 0x00, 0x0a, 0x20, 0x21},
 
627
        {CIS_CANONLIDE110, 1200, 10528, 0x1e, 0x9f, 0x55, 5168, 163,  101,  388,  574,  393, 0x00, 0x08, 0x20, 0x22},
 
628
        {CIS_CANONLIDE110, 2400, 20864, 0x1e, 0x9f, 0x55, 5168, 163, 4679, 6839, 8401, 6859, 0x00, 0x06, 0x20, 0x24},
 
629
        /* {CIS_CANONLIDE110,  200,  2304, 0x1e, 0x9f, 0x55, 5168, 154,  101,  388,  574,  393, 0x00, 0x0a, 0x20, 0x21}, */
 
630
};
 
631
 
 
632
 
 
633
#define MOVE_DPI 200
 
634
#define MOVE_EXPOSURE 2304
 
635
 
 
636
/**
 
637
 * structure for motor database
 
638
 */
 
639
typedef struct {
 
640
        int motor_type;  /**> motor id */
 
641
        int exposure;    /**> exposure for the slope table */
 
642
        int step_type;   /**> default step type for given exposure */
 
643
        uint16_t *table; /**> slope table at full step */
 
644
} Motor_Profile;
 
645
 
 
646
/*
 
647
static uint16_t lide110_ok[]   = { 62496, 2343, 2343, 2343, 2343, 2343, 2343,2343,2343,2051,1961,1901,1852,1809,1775,1745,1717,1692,1671,1650,1630,1613,1597,1580,1565,1549,1536,1524,1512,1500,1488,1478,1467,1458,1446,1437,1429,1420,1411,1403,1395,1386,1378,1372,1364,1358,1350,1345,1337,1331,1324,1318,1313,1307,1302,1294,1289,1284,1278,1273,1268,1263,1260,1255,1250,1245,1240,1236,1231,1227,1222,1219,1214,1211,1206,1201,1198,1194,1191,1186,1183,1179,1176,1173,1168,1166,1161,1158,1155,1151,1148,1146,1143,1139,1136,1133,1130,1128,1124,1121,1118,1116,1113,1110,1108,1105,1101,1099,1096,1093,1091,1088,1086,1083,1081,1078,1076,1073,1071,1068,1067,1065,1062,1060,1058,1055,1053,1051,1048,1047,1045,1042,1040,1038,1035,1034,1032,1030,1027,1026,1024,1022,1020,1019,1016,1014,1012,1011,1009,1006,1005,1003,1001,999,998,996,994,993,991,989,987,985,984,982,980,979,977,976,974,973,971,969,968,966,965,963,962,960,959,957,956,954,952,951,949,948,946,946,944,943,942,940,939,937,936,934,933,931,930,929,928,927,925,924,922,921,920,919,918,916,915,914,912,911,910,909,908,906,905,904,903,902,900,899,898,897,896,895,893,892,892,890,889,888,887,886,885,884,882,881,881,879,878,877,876,875,874,873,872,871,870,869,868,867,864,864, 0};
 
648
static uint16_t lide110_max[]  = { 62496, 31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,31296,0};
 
649
static uint16_t lide110_slow[] = { 62496, 7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,7896,0};
 
650
*/
 
651
static uint16_t lide110_max[]  = { 62496, 31296,0};
 
652
static uint16_t lide110_slow[] = { 62496, 7896,0};
 
653
static uint16_t lide110_alt[]   = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2051, 1432, 1372, 1323, 1280, 1246, 1216, 1188, 1163, 1142, 1121, 1101, 1084, 1068, 1051, 1036, 1020, 1007, 995, 983, 971, 959, 949, 938, 929, 917, 908, 900, 891, 882, 874, 866, 857, 849, 843, 835, 829, 821, 816, 808, 802, 795, 789, 784, 778, 773, 765, 760, 755, 749, 744, 739, 734, 731, 726, 721, 716, 711, 707, 702, 698, 693, 690, 685, 682, 677, 672, 669, 665, 662, 657, 654, 650, 647, 644, 639, 637, 632, 629, 626, 622, 619, 617, 614, 610, 607, 604, 601, 599, 595, 592, 589, 587, 584, 581, 579, 576, 572, 570, 567, 564, 562, 559, 557, 554, 552, 549, 547, 544, 542, 539, 538, 536, 533, 531, 529, 526, 524, 522, 519, 518, 516, 513, 511, 509, 506, 505, 503, 501, 498, 497, 495, 493, 491, 490, 487, 485, 483, 482, 480, 477, 476, 474, 472, 470, 469, 467, 465, 464, 462, 460, 458, 456, 455, 453, 451, 450, 448, 447, 445, 444, 442, 440, 439, 437, 436, 434, 433, 431, 430, 428, 427, 425, 423, 422, 420, 419, 417, 417, 415, 414, 413, 411, 410, 408, 407, 405, 404, 402, 401, 400, 399, 398, 396, 395, 393, 392, 391, 390, 389, 387, 386, 385, 383, 382, 381, 380, 379, 377, 376, 375, 374, 373, 371, 370, 369, 368, 367, 366, 364, 363, 363, 361, 360, 359, 358, 357, 356, 355, 353, 352, 352, 350, 349, 348, 347, 346, 345, 344, 343, 342, 341, 340, 339, 338, 335, 335, 0};
 
654
static uint16_t lide110_ok[]   = { 62496, 2343, 2343, 2343, 2343, 2343, 2343,2343,2343,2051,1961,1901,1852,1809,1775,1745,1717,1692,1671,1650,1630,1613,1597,1580,1565,1549,1536,1524,1512,1500,1488,1478,1467,1458,1446,1437,1429,1420,1411,1403,1395,1386,1378,1372,1364,1358,1350,1345,1337,1331,1324,1318,1313,1307,1302,1294,1289,1284,1278,1273,1268,1263,1260,1255,1250,1245,1240,1236,1231,1227,1222,1219,1214,1211,1206,1201,1198,1194,1191,1186,1183,1179,1176,1173,1168,1166,1161,1158,1155,1151,1148,1146,1143,1139,1136,1133,1130,1128,1124,1121,1118,1116,1113,1110,1108,1105,1101,1099,1096,1093,1091,1088,1086,1083,1081,1078,1076,1073,1071,1068,1067,1065,1062,1060,1058,1055,1053,1051,1048,1047,1045,1042,1040,1038,1035,1034,1032,1030,1027,1026,1024,1022,1020,1019,1016,1014,1012,1011,1009,1006,1005,1003,1001,999,998,996,994,993,991,989,987,985,984,982,980,979,977,976,974,973,971,969,968,966,965,963,962,960,959,957,956,954,952,951,949,948,946,946,944,943,942,940,939,937,936,934,933,931,930,929,928,927,925,924,922,921,920,919,918,916,915,914,912,911,910,909,908,906,905,904,903,902,900,899,898,897,896,895,893,892,892,890,889,888,887,886,885,884,882,881,881,879,878,877,876,875,874,873,872,871,870,869,868,867,864,864, 0};
 
655
/*
 
656
static uint16_t lide110_x2[]   = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2343, 2051, 1948, 1877, 1817, 1764, 1720, 1680, 1643, 1609, 1580, 1550, 1522, 1498, 1474, 1450, 1427, 1405, 1385, 1366, 1348, 1329, 1311, 1295, 1278, 1263, 1246, 1231, 1218, 1204, 1189, 1176, 1163, 1150, 1137, 1126, 1114, 1103, 1091, 1081, 1069, 1059, 1048, 1038, 1029, 1019, 1010, 999, 990, 981, 972, 964, 955, 947, 940, 932, 924, 916, 908, 901, 893, 886, 878, 872, 864, 858, 851, 843, 838, 831, 825, 818, 812, 806, 801, 795, 788, 784, 777, 771, 766, 760, 755, 751, 746, 740, 735, 730, 725, 721, 715, 710, 706, 701, 697, 692, 688, 684, 678, 674, 670, 666, 662, 657, 654, 649, 646, 641, 638, 634, 630, 626, 623, 619, 615, 612, 609, 605, 601, 598, 594, 591, 588, 584, 581, 578, 574, 572, 568, 565, 562, 559, 556, 553, 550, 548, 544, 541, 538, 536, 533, 530, 527, 525, 522, 519, 517, 514, 511, 509, 506, 504, 501, 498, 496, 494, 491, 489, 486, 484, 482, 480, 477, 475, 473, 470, 469, 466, 464, 462, 460, 457, 456, 453, 451, 449, 447, 445, 443, 441, 439, 437, 436, 433, 432, 429, 428, 426, 424, 422, 420, 418, 417, 415, 413, 411, 409, 408, 406, 405, 403, 401, 399, 398, 396, 394, 393, 391, 390, 388, 386, 385, 383, 382, 380, 379, 377, 376, 374, 373, 371, 370, 369, 367, 366, 364, 363, 361, 360, 359, 357, 356, 355, 353, 352, 350, 349, 348, 347, 345, 344, 343, 341, 340, 339, 338, 336, 335, 0};
 
657
static uint16_t lide110_new[]  = { 62496, 2343, 2343, 2343, 2343, 2343, 2343, 2343,2343, 2051, 1961, 1901, 1852, 1809, 1775, 1745, 1717, 1692, 1671, 1650, 1634, 1544, 1484, 1435, 1392, 1358, 1328, 1300, 1275, 1254, 1233, 1213, 1196, 1180, 1163, 1148, 1132, 1119, 1107, 1095, 1083, 1071, 1061, 1050, 1041, 1029, 1020, 1012, 1003, 994, 986, 978, 969, 961, 955, 947, 941, 933, 928, 920, 914, 907, 901, 896, 890, 885, 877, 872, 867, 861, 856, 851, 846, 843, 838, 833, 828, 823, 819, 814, 810, 805, 802, 797, 794, 789, 784, 781, 777, 774, 769, 766, 762, 759, 756, 751, 749, 744, 741, 738, 734, 731, 729, 726, 722, 719, 716, 713, 711, 707, 704, 701, 699, 696, 693, 691, 688, 684, 682, 679, 676, 674, 671, 669, 666, 664, 661, 659, 656, 654, 651, 650, 648, 645, 643, 641, 638, 636, 634, 631, 630, 628, 625, 623, 621, 618, 617, 615, 613, 610, 609, 607, 605, 603, 602, 599, 597, 595, 594, 592, 589, 588, 586, 584, 582, 581, 579, 577, 576, 574, 572, 570, 568, 567, 565, 563, 562, 560, 559, 557, 556, 554, 552, 551, 549, 548, 546, 545, 543, 542, 540, 539, 537, 535, 534, 532, 531, 529, 529, 527, 526, 525, 523, 522, 520, 519, 517, 516, 514, 513, 512, 511, 510, 508, 507, 505, 504, 503, 502, 501, 499, 498, 497, 495, 494, 493, 492, 491, 489, 488, 487, 486, 485, 483, 482, 481, 480, 479, 478, 476, 475, 475, 473, 472, 471, 470, 469, 468, 467, 465, 464, 464, 462, 461, 460, 459, 458, 457, 456, 455, 454, 453, 452, 451, 450, 447, 447, 0 };
 
658
*/
 
659
 
 
660
/**
 
661
 * database of motor profiles
 
662
 */
 
663
 
 
664
/* *INDENT-OFF* */
 
665
 
 
666
/* NEXT LPERIOD=PREVIOUS*2-192 */
 
667
static Motor_Profile motors[]={
 
668
        {MOTOR_CANONLIDE110,  2304, 0, lide110_ok},
 
669
        {MOTOR_CANONLIDE110,  5359, 0, lide110_alt},
 
670
        {MOTOR_CANONLIDE110,  5360, 1, lide110_alt},
 
671
        {MOTOR_CANONLIDE110, 10528, 1, lide110_slow},
 
672
        {MOTOR_CANONLIDE110, 20864, 2, lide110_max},
 
673
};
 
674
/* *INDENT-ON* */
 
675
 
 
676
#ifndef UNIT_TESTING
 
677
static
 
678
#endif
 
679
  SANE_Status gl124_init_scan_regs (Genesys_Device * dev,
 
680
                      Genesys_Register_Set * reg,
 
681
                      float xres,       /*dpi */
 
682
                      float yres,       /*dpi */
 
683
                      float startx,     /*optical_res, from dummy_pixel+1 */
 
684
                      float starty,     /*base_ydpi, from home! */
 
685
                      float pixels,
 
686
                      float lines,
 
687
                      unsigned int depth,
 
688
                      unsigned int channels,
 
689
                      int color_filter, unsigned int flags);
 
690
#ifndef UNIT_TESTING
 
691
static
 
692
#endif
 
693
  SANE_Status
 
694
gl124_bulk_write_register (Genesys_Device * dev, Genesys_Register_Set * reg, size_t elems);
 
695
#ifndef UNIT_TESTING
 
696
static
 
697
#endif
 
698
  SANE_Status gl124_start_action (Genesys_Device * dev);
 
699
#ifndef UNIT_TESTING
 
700
static
 
701
#endif
 
702
  SANE_Status
 
703
gl124_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
 
704
                  SANE_Bool start_motor);
 
705
#ifndef UNIT_TESTING
 
706
static
 
707
#endif
 
708
  SANE_Status
 
709
gl124_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg,
 
710
                SANE_Bool check_stop);
 
711
#ifndef UNIT_TESTING
 
712
static
 
713
#endif
 
714
  SANE_Status
 
715
gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home);
 
716
#ifndef UNIT_TESTING
 
717
static
 
718
#endif
 
719
SANE_Status gl124_init (Genesys_Device * dev);
 
720
#ifndef UNIT_TESTING
 
721
static
 
722
#endif
 
723
SANE_Status gl124_send_shading_data (Genesys_Device * dev, uint8_t * data, int size);
 
724
 
 
725
#ifndef UNIT_TESTING
 
726
static
 
727
#endif
 
728
SANE_Status gl124_feed (Genesys_Device * dev, unsigned int steps);
 
729
 
 
730
/* vim: set sw=2 cino=>2se-1sn-1s{s^-1st0(0u0 smarttab expandtab: */