summaryrefslogtreecommitdiff
path: root/backend/apple.h
blob: 9e144349441b8d083272d809aa305bf7a235d31a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/* sane - Scanner Access Now Easy.

   Copyright (C) 1998 Milon Firikis based on David Mosberger-Tang previous
   Work on mustek.c file from the SANE package.

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston,
   MA 02111-1307, USA.

   As a special exception, the authors of SANE give permission for
   additional uses of the libraries contained in this release of SANE.

   The exception is that, if you link a SANE library with other files
   to produce an executable, this does not by itself cause the
   resulting executable to be covered by the GNU General Public
   License.  Your use of that executable is in no way restricted on
   account of linking the SANE library code into it.

   This exception does not, however, invalidate any other reasons why
   the executable file might be covered by the GNU General Public
   License.

   If you submit changes to SANE to the maintainers to be included in
   a subsequent release, you agree by submitting the changes that
   those changes may be distributed with this exception intact.

   If you write modifications of your own for SANE, it is your choice
   whether to permit this exception to apply to your modifications.
   If you do not wish that, delete this exception notice.  */
#ifndef apple_h
#define apple_h

#include <sys/types.h>


/*
Warning: if you uncomment the next line you 'll get
zero functionality. All the scanner specific function
such as sane_read, attach and the others will return
without doing  anything. This way you can run the backend
without an attached scanner just to see if it gets
its control variables in a proper way.

TODO: This could be a nice thing to do as a sane config
option at runtime. This way one can debug the gui-ipc
part of the backend without actually has the scanner.

*/

#if 0
#define NEUTRALIZE_BACKEND
#define APPLE_MODEL_SELECT APPLESCANNER
#endif
#undef CALIBRATION_FUNCTIONALITY
#undef RESERVE_RELEASE_HACK

#ifdef RESERVE_RELEASE_HACK
/* Also Try these with zero */
#define CONTROLLER_SCSI_ID 7
#define SETTHIRDPARTY 0x10
#endif


#define ERROR_MESSAGE	1
#define USER_MESSAGE	5
#define FLOW_CONTROL	50
#define VARIABLE_CONTROL 70
#define DEBUG_SPECIAL	100
#define IO_MESSAGE	110
#define INNER_LOOP	120


/* mode values: */
enum Apple_Modes
  {
  APPLE_MODE_LINEART=0,
  APPLE_MODE_HALFTONE,
  APPLE_MODE_GRAY,
  APPLE_MODE_BICOLOR,
  EMPTY_DONT_USE_IT,
  APPLE_MODE_COLOR
  };
  
enum Apple_Option
  {
    OPT_NUM_OPTS = 0,

    OPT_HWDETECT_GROUP,
    OPT_MODEL,

    OPT_MODE_GROUP,
    OPT_MODE,
    OPT_RESOLUTION,
    OPT_PREVIEW,

    OPT_GEOMETRY_GROUP,
    OPT_TL_X,			/* top-left x */
    OPT_TL_Y,			/* top-left y */
    OPT_BR_X,			/* bottom-right x */
    OPT_BR_Y,			/* bottom-right y */


    OPT_ENHANCEMENT_GROUP,
    /* COMMON				*/
    OPT_BRIGHTNESS,
    OPT_CONTRAST,
    OPT_THRESHOLD,
    
    /* AppleScanner only		*/
    OPT_GRAYMAP,
    OPT_AUTOBACKGROUND,
    OPT_AUTOBACKGROUND_THRESHOLD,

    /* AppleScanner & OneScanner	*/
    OPT_HALFTONE_PATTERN,
    OPT_HALFTONE_FILE,

    /* ColorOneScanner Only		*/
    OPT_VOLT_REF,
    OPT_VOLT_REF_TOP,
    OPT_VOLT_REF_BOTTOM,

    /* misc : advanced			*/
    OPT_MISC_GROUP,

    /* all				*/
    OPT_LAMP,

    /* AppleScanner Only		*/
    OPT_WAIT,

    /* OneScanner only			*/
    OPT_CALIBRATE,
    OPT_SPEED,

    /* OneScanner && ColorOneScanner	*/
    OPT_LED,
    OPT_CCD,
    
    /* ColorOneScanner only		*/

    OPT_MTF_CIRCUIT,
    OPT_ICP,
    OPT_POLARITY,

    /* color group : advanced		*/

    OPT_COLOR_GROUP,


#ifdef CALIBRATION_FUNCTIONALITY

    /* OneScanner			*/
    OPT_CALIBRATION_VECTOR,

    /* ColorOneScanner			*/

    OPT_CALIBRATION_VECTOR_RED,
    OPT_CALIBRATION_VECTOR_GREEN,
    OPT_CALIBRATION_VECTOR_BLUE,
#endif


    /* OneScanner && ColorOneScanner	*/
    OPT_DOWNLOAD_CALIBRATION_VECTOR,

    /* ColorOneScanner			*/

    OPT_CUSTOM_CCT,
    OPT_CCT,
    OPT_DOWNLOAD_CCT,

    OPT_CUSTOM_GAMMA,

    OPT_GAMMA_VECTOR_R,
    OPT_GAMMA_VECTOR_G,
    OPT_GAMMA_VECTOR_B,

    OPT_DOWNLOAD_GAMMA,
    OPT_COLOR_SENSOR,

    /* must come last: */
    NUM_OPTIONS
  };


/* This is a hack to get fast the model of the Attached Scanner	*/
/* But it Works well and I am not considering in "fix" it	*/
enum SCANNERMODEL
  {
    OPT_NUM_SCANNERS = 0,

    APPLESCANNER, ONESCANNER, COLORONESCANNER,
    NUM_SCANNERS
  };

typedef struct Apple_Device
  {
    struct Apple_Device *next;
    SANE_Int ScannerModel;
    SANE_Device sane;
    SANE_Range dpi_range;
    SANE_Range x_range;
    SANE_Range y_range;
    SANE_Int MaxWidth;
    SANE_Int MaxHeight;
    unsigned flags;
  }
Apple_Device;

typedef struct Apple_Scanner
  {
    /* all the state needed to define a scan request: */
    struct Apple_Scanner *next;

    SANE_Option_Descriptor opt[NUM_OPTIONS];
    Option_Value val[NUM_OPTIONS];

    /* First we put here all the scan variables */

    /* These are needed for converting back and forth the scan area */

    SANE_Int bpp;	/* The actual bpp, before scaling */

    double ulx;
    double uly;
    double wx;
    double wy;
    SANE_Int ULx;
    SANE_Int ULy;
    SANE_Int Width;
    SANE_Int Height;

/*
TODO: Initialize this beasts with malloc instead of statically allocation.
*/
    SANE_Int calibration_vector[2550];
    SANE_Int calibration_vector_red[2700];
    SANE_Int calibration_vector_green[2700];
    SANE_Int calibration_vector_blue[2700];
    SANE_Fixed cct3x3[9];
    SANE_Int gamma_table[3][256];
    SANE_Int halftone_pattern[64];

    SANE_Bool scanning;
    SANE_Bool AbortedByUser;
 
    int pass;			/* pass number */
    SANE_Parameters params;

    int fd;			/* SCSI filedescriptor */

    /* scanner dependent/low-level state: */
    Apple_Device *hw;

  }
Apple_Scanner;

#endif /* apple_h */