1 /* sane - Scanner Access Now Easy.
2 
3    Copyright (C) 2000 Mustek.
4    Originally maintained by Tom Wang <tom.wang@mustek.com.tw>
5 
6    Copyright (C) 2001, 2002 by Henning Meier-Geinitz.
7 
8    This file is part of the SANE package.
9 
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2 of the
13    License, or (at your option) any later version.
14 
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19 
20    You should have received a copy of the GNU General Public License
21    along with this program.  If not, see <https://www.gnu.org/licenses/>.
22 
23    As a special exception, the authors of SANE give permission for
24    additional uses of the libraries contained in this release of SANE.
25 
26    The exception is that, if you link a SANE library with other files
27    to produce an executable, this does not by itself cause the
28    resulting executable to be covered by the GNU General Public
29    License.  Your use of that executable is in no way restricted on
30    account of linking the SANE library code into it.
31 
32    This exception does not, however, invalidate any other reasons why
33    the executable file might be covered by the GNU General Public
34    License.
35 
36    If you submit changes to SANE to the maintainers to be included in
37    a subsequent release, you agree by submitting the changes that
38    those changes may be distributed with this exception intact.
39 
40    If you write modifications of your own for SANE, it is your choice
41    whether to permit this exception to apply to your modifications.
42    If you do not wish that, delete this exception notice.
43 
44    This file implements a SANE backend for Mustek 1200UB and similar
45    USB flatbed scanners.  */
46 
47 #ifndef mustek_usb_mid_h
48 #define mustek_usb_mid_h
49 
50 #include "mustek_usb_low.h"
51 #include "../include/sane/sane.h"
52 
53 /* ---------------------------------- macros ------------------------------ */
54 
55 
56 /* ---------------- sensor NEC 600 CCD function declarations -------------- */
57 
58 static SANE_Status usb_mid_n600_prepare_rgb (ma1017 * chip, SANE_Word dpi);
59 
60 static SANE_Status usb_mid_n600_prepare_mono (ma1017 * chip, SANE_Word dpi);
61 
62 static SANE_Status usb_mid_n600_prepare_rgb_600_dpi (ma1017 * chip);
63 
64 static SANE_Status usb_mid_n600_prepare_rgb_400_dpi (ma1017 * chip);
65 
66 static SANE_Status usb_mid_n600_prepare_rgb_300_dpi (ma1017 * chip);
67 
68 static SANE_Status usb_mid_n600_prepare_rgb_200_dpi (ma1017 * chip);
69 
70 static SANE_Status usb_mid_n600_prepare_rgb_100_dpi (ma1017 * chip);
71 
72 static SANE_Status usb_mid_n600_prepare_rgb_50_dpi (ma1017 * chip);
73 
74 static SANE_Status usb_mid_n600_prepare_mono_600_dpi (ma1017 * chip);
75 
76 static SANE_Status usb_mid_n600_prepare_mono_400_dpi (ma1017 * chip);
77 
78 static SANE_Status usb_mid_n600_prepare_mono_300_dpi (ma1017 * chip);
79 
80 static SANE_Status usb_mid_n600_prepare_mono_200_dpi (ma1017 * chip);
81 
82 static SANE_Status usb_mid_n600_prepare_mono_100_dpi (ma1017 * chip);
83 
84 static SANE_Status usb_mid_n600_prepare_mono_50_dpi (ma1017 * chip);
85 
86 /* ----------------- sensor 600 CIS function declarations ----------------- */
87 
88 static SANE_Status usb_mid_c600_prepare_rgb (ma1017 * chip, SANE_Word dpi);
89 
90 static SANE_Status usb_mid_c600_prepare_mono (ma1017 * chip, SANE_Word dpi);
91 
92 static SANE_Status usb_mid_c600_prepare_rgb_600_dpi (ma1017 * chip);
93 
94 static SANE_Status usb_mid_c600_prepare_rgb_400_dpi (ma1017 * chip);
95 
96 static SANE_Status usb_mid_c600_prepare_rgb_300_dpi (ma1017 * chip);
97 
98 static SANE_Status usb_mid_c600_prepare_rgb_200_dpi (ma1017 * chip);
99 
100 static SANE_Status usb_mid_c600_prepare_rgb_150_dpi (ma1017 * chip);
101 
102 static SANE_Status usb_mid_c600_prepare_rgb_100_dpi (ma1017 * chip);
103 
104 static SANE_Status usb_mid_c600_prepare_rgb_50_dpi (ma1017 * chip);
105 
106 static SANE_Status usb_mid_c600_prepare_mono_600_dpi (ma1017 * chip);
107 
108 static SANE_Status usb_mid_c600_prepare_mono_400_dpi (ma1017 * chip);
109 
110 static SANE_Status usb_mid_c600_prepare_mono_300_dpi (ma1017 * chip);
111 
112 static SANE_Status usb_mid_c600_prepare_mono_200_dpi (ma1017 * chip);
113 
114 static SANE_Status usb_mid_c600_prepare_mono_150_dpi (ma1017 * chip);
115 
116 static SANE_Status usb_mid_c600_prepare_mono_100_dpi (ma1017 * chip);
117 
118 static SANE_Status usb_mid_c600_prepare_mono_50_dpi (ma1017 * chip);
119 
120 /* -------------- sensor 300/600 CIS function declarations ---------------- */
121 
122 static SANE_Status usb_mid_c300600_prepare_rgb (ma1017 * chip, SANE_Word dpi);
123 
124 static SANE_Status
125 usb_mid_c300600_prepare_mono (ma1017 * chip, SANE_Word dpi);
126 
127 static SANE_Status usb_mid_c300600_prepare_rgb_600_dpi (ma1017 * chip);
128 
129 static SANE_Status usb_mid_c300600_prepare_rgb_400_dpi (ma1017 * chip);
130 
131 static SANE_Status usb_mid_c300600_prepare_rgb_300_dpi (ma1017 * chip);
132 
133 static SANE_Status usb_mid_c300600_prepare_rgb_200_dpi (ma1017 * chip);
134 
135 static SANE_Status usb_mid_c300600_prepare_rgb_150_dpi (ma1017 * chip);
136 
137 static SANE_Status usb_mid_c300600_prepare_rgb_100_dpi (ma1017 * chip);
138 
139 static SANE_Status usb_mid_c300600_prepare_rgb_50_dpi (ma1017 * chip);
140 
141 static SANE_Status usb_mid_c300600_prepare_mono_600_dpi (ma1017 * chip);
142 
143 static SANE_Status usb_mid_c300600_prepare_mono_400_dpi (ma1017 * chip);
144 
145 static SANE_Status usb_mid_c300600_prepare_mono_300_dpi (ma1017 * chip);
146 
147 static SANE_Status usb_mid_c300600_prepare_mono_200_dpi (ma1017 * chip);
148 
149 static SANE_Status usb_mid_c300600_prepare_mono_150_dpi (ma1017 * chip);
150 
151 static SANE_Status usb_mid_c300600_prepare_mono_100_dpi (ma1017 * chip);
152 
153 static SANE_Status usb_mid_c300600_prepare_mono_50_dpi (ma1017 * chip);
154 
155 /* ----------------- sensor 300 CIS function declarations ----------------- */
156 
157 static SANE_Status usb_mid_c300_prepare_rgb (ma1017 * chip, SANE_Word dpi);
158 
159 static SANE_Status usb_mid_c300_prepare_mono (ma1017 * chip, SANE_Word dpi);
160 
161 static SANE_Status usb_mid_c300_prepare_rgb_300_dpi (ma1017 * chip);
162 
163 static SANE_Status usb_mid_c300_prepare_rgb_200_dpi (ma1017 * chip);
164 
165 static SANE_Status usb_mid_c300_prepare_rgb_150_dpi (ma1017 * chip);
166 
167 static SANE_Status usb_mid_c300_prepare_rgb_100_dpi (ma1017 * chip);
168 
169 static SANE_Status usb_mid_c300_prepare_rgb_50_dpi (ma1017 * chip);
170 
171 static SANE_Status usb_mid_c300_prepare_mono_300_dpi (ma1017 * chip);
172 
173 static SANE_Status usb_mid_c300_prepare_mono_200_dpi (ma1017 * chip);
174 
175 static SANE_Status usb_mid_c300_prepare_mono_150_dpi (ma1017 * chip);
176 
177 static SANE_Status usb_mid_c300_prepare_mono_100_dpi (ma1017 * chip);
178 
179 static SANE_Status usb_mid_c300_prepare_mono_50_dpi (ma1017 * chip);
180 
181 /* --------------------- sensor function declarations -------------------- */
182 
183 static SANE_Bool usb_mid_sensor_is600_mode (ma1017 * chip, SANE_Word dpi);
184 
185 static SANE_Status usb_mid_sensor_prepare_rgb (ma1017 * chip, SANE_Word dpi);
186 
187 static SANE_Status usb_mid_sensor_prepare_mono (ma1017 * chip, SANE_Word dpi);
188 
189 static SANE_Status
190 usb_mid_sensor_get_dpi (ma1017 * chip, SANE_Word wanted_dpi, SANE_Word * dpi);
191 
192 /* ------------------- motor 1200 function declarations ------------------ */
193 
194 static SANE_Status usb_mid_motor1200_prepare_rgb_1200_dpi (ma1017 * chip);
195 
196 static SANE_Status usb_mid_motor1200_prepare_rgb_400_dpi (ma1017 * chip);
197 
198 static SANE_Status usb_mid_motor1200_prepare_rgb_600_dpi (ma1017 * chip);
199 
200 static SANE_Status usb_mid_motor1200_prepare_rgb_200_dpi (ma1017 * chip);
201 
202 static SANE_Status usb_mid_motor1200_prepare_rgb_300_dpi (ma1017 * chip);
203 
204 static SANE_Status usb_mid_motor1200_prepare_rgb_150_dpi (ma1017 * chip);
205 
206 static SANE_Status usb_mid_motor1200_prepare_rgb_100_dpi (ma1017 * chip);
207 
208 static SANE_Status usb_mid_motor1200_prepare_rgb_50_dpi (ma1017 * chip);
209 
210 static SANE_Status usb_mid_motor1200_prepare_mono_1200_dpi (ma1017 * chip);
211 
212 static SANE_Status usb_mid_motor1200_prepare_mono_400_dpi (ma1017 * chip);
213 
214 static SANE_Status usb_mid_motor1200_prepare_mono_600_dpi (ma1017 * chip);
215 
216 static SANE_Status usb_mid_motor1200_prepare_mono_200_dpi (ma1017 * chip);
217 
218 static SANE_Status usb_mid_motor1200_prepare_mono_300_dpi (ma1017 * chip);
219 
220 static SANE_Status usb_mid_motor1200_prepare_mono_150_dpi (ma1017 * chip);
221 
222 static SANE_Status usb_mid_motor1200_prepare_mono_100_dpi (ma1017 * chip);
223 
224 static SANE_Status usb_mid_motor1200_prepare_mono_50_dpi (ma1017 * chip);
225 
226 static SANE_Status usb_mid_motor1200_prepare_rgb_half_300_dpi (ma1017 * chip);
227 
228 static SANE_Status
229 usb_mid_motor1200_prepare_rgb_bi_full_300_dpi (ma1017 * chip);
230 
231 static SANE_Status
232 usb_mid_motor1200_prepare_rgb_bi_full_x2300_dpi (ma1017 * chip);
233 
234 static SANE_Status
235 usb_mid_motor1200_prepare_mono_half_300_dpi (ma1017 * chip);
236 
237 static SANE_Status
238 usb_mid_motor1200_prepare_mono_bi_full_300_dpi (ma1017 * chip);
239 
240 static SANE_Status
241 usb_mid_motor1200_prepare_mono_bi_full_x2300_dpi (ma1017 * chip);
242 
243 static SANE_Status
244 usb_mid_motor1200_prepare_rgb (ma1017 * chip, SANE_Word dpi);
245 
246 static SANE_Status
247 usb_mid_motor1200_prepare_mono (ma1017 * chip, SANE_Word dpi);
248 
249 static SANE_Status
250 usb_mid_motor1200_prepare_calibrate_rgb (ma1017 * chip, SANE_Word dpi);
251 
252 static SANE_Status
253 usb_mid_motor1200_prepare_calibrate_mono (ma1017 * chip, SANE_Word dpi);
254 
255 static SANE_Status
256 usb_mid_motor1200_prepare_step (ma1017 * chip, SANE_Word step_count);
257 
258 static SANE_Status usb_mid_motor1200_prepare_home (ma1017 * chip);
259 
260 static SANE_Status
261 usb_mid_motor1200_prepare_adjust (ma1017 * chip, Channel channel);
262 
263 static SANE_Word usb_mid_motor1200_rgb_capability (SANE_Word dpi);
264 
265 static SANE_Word usb_mid_motor1200_mono_capability (SANE_Word dpi);
266 
267 /* ---------------600 dpi motor function declarations --------------------- */
268 
269 static SANE_Status usb_mid_motor600_prepare_rgb_600_dpi (ma1017 * chip);
270 
271 static SANE_Status usb_mid_motor600_prepare_rgb_200_dpi (ma1017 * chip);
272 
273 static SANE_Status usb_mid_motor600_prepare_rgb_300_dpi (ma1017 * chip);
274 
275 static SANE_Status usb_mid_motor600_prepare_rgb_150_dpi (ma1017 * chip);
276 
277 static SANE_Status usb_mid_motor600_prepare_rgb_100_dpi (ma1017 * chip);
278 
279 static SANE_Status usb_mid_motor600_prepare_rgb_50_dpi (ma1017 * chip);
280 
281 static SANE_Status usb_mid_motor600_prepare_mono_600_dpi (ma1017 * chip);
282 
283 static SANE_Status usb_mid_motor600_prepare_mono_200_dpi (ma1017 * chip);
284 
285 static SANE_Status usb_mid_motor600_prepare_mono_300_dpi (ma1017 * chip);
286 
287 static SANE_Status usb_mid_motor600_prepare_mono_150_dpi (ma1017 * chip);
288 
289 static SANE_Status usb_mid_motor600_prepare_mono_100_dpi (ma1017 * chip);
290 
291 static SANE_Status usb_mid_motor600_prepare_mono_50_dpi (ma1017 * chip);
292 
293 static SANE_Status usb_mid_motor600_prepare_rgb_half_300_dpi (ma1017 * chip);
294 
295 static SANE_Status
296 usb_mid_motor600_prepare_rgb_bi_full_300_dpi (ma1017 * chip);
297 
298 static SANE_Status usb_mid_motor600_prepare_mono_half_300_dpi (ma1017 * chip);
299 
300 static SANE_Status
301 usb_mid_motor600_prepare_mono_bi_full_300_dpi (ma1017 * chip);
302 
303 static SANE_Status
304 usb_mid_motor600_prepare_rgb (ma1017 * chip, SANE_Word dpi);
305 
306 static SANE_Status
307 usb_mid_motor600_prepare_mono (ma1017 * chip, SANE_Word dpi);
308 
309 static SANE_Status
310 usb_mid_motor600_prepare_calibrate_rgb (ma1017 * chip, SANE_Word dpi);
311 
312 static SANE_Status
313 usb_mid_motor600_prepare_calibrate_mono (ma1017 * chip, SANE_Word dpi);
314 
315 static SANE_Status
316 usb_mid_motor600_prepare_step (ma1017 * chip, SANE_Word step_count);
317 
318 static SANE_Status usb_mid_motor600_prepare_home (ma1017 * chip);
319 
320 static SANE_Status
321 usb_mid_motor600_prepare_adjust (ma1017 * chip, Channel channel);
322 
323 static SANE_Word usb_mid_motor600_rgb_capability (SANE_Word dpi);
324 
325 static SANE_Word usb_mid_motor600_mono_capability (SANE_Word dpi);
326 
327 /* ------------------ motor function declarations ------------------------ */
328 
329 static SANE_Status usb_mid_motor_prepare_home (ma1017 * chip);
330 
331 static SANE_Status usb_mid_motor_prepare_rgb (ma1017 * chip, SANE_Word dpi);
332 
333 static SANE_Status usb_mid_motor_prepare_mono (ma1017 * chip, SANE_Word dpi);
334 
335 static SANE_Status
336 usb_mid_motor_prepare_adjust (ma1017 * chip, Channel channel);
337 
338 static SANE_Status
339 usb_mid_motor_prepare_calibrate_rgb (ma1017 * chip, SANE_Word dpi);
340 
341 static SANE_Status
342 usb_mid_motor_prepare_calibrate_mono (ma1017 * chip, SANE_Word dpi);
343 
344 static SANE_Status
345 usb_mid_motor_prepare_step (ma1017 * chip, SANE_Word step_count);
346 
347 static SANE_Word usb_mid_motor_rgb_capability (ma1017 * chip, SANE_Word dpi);
348 
349 static SANE_Word usb_mid_motor_mono_capability (ma1017 * chip, SANE_Word dpi);
350 
351 static SANE_Status
352 usb_mid_motor_get_dpi (ma1017 * chip, SANE_Word wanted_dpi, SANE_Word * dpi);
353 
354 /* --------------------- frontend function declarations ------------------- */
355 
356 
357 static SANE_Status
358 usb_mid_front_set_front_end_mode (ma1017 * chip, SANE_Byte mode);
359 
360 static SANE_Status usb_mid_front_enable (ma1017 * chip, SANE_Bool is_enable);
361 
362 static SANE_Status
363 usb_mid_front_set_top_reference (ma1017 * chip, SANE_Byte top);
364 
365 static SANE_Status
366 usb_mid_front_set_red_offset (ma1017 * chip, SANE_Byte offset);
367 
368 static SANE_Status
369 usb_mid_front_set_green_offset (ma1017 * chip, SANE_Byte offset);
370 
371 static SANE_Status
372 usb_mid_front_set_blue_offset (ma1017 * chip, SANE_Byte offset);
373 
374 static SANE_Status usb_mid_front_set_red_pga (ma1017 * chip, SANE_Byte pga);
375 
376 static SANE_Status usb_mid_front_set_green_pga (ma1017 * chip, SANE_Byte pga);
377 
378 static SANE_Status usb_mid_front_set_blue_pga (ma1017 * chip, SANE_Byte pga);
379 
380 static SANE_Status usb_mid_front_set_rgb_signal (ma1017 * chip);
381 
382 #if 0
383 /* CCD */
384 static SANE_Word usb_mid_frontend_max_offset_index (ma1017 * chip);
385 #define OFFSET_TABLE_SIZE 256
386 #endif
387 
388 #endif /* mustek_usb_mid_h */
389