1 /* @file plustek-pp_p12ccd.c
2 * @brief here we have the whole code to initialize the CCD and DAC stuff
3 *
4 * based on sources acquired from Plustek Inc.
5 * Copyright (C) 2000 Plustek Inc.
6 * Copyright (C) 2001-2004 Gerhard Jaeger <gerhard@gjaeger.de>
7 *
8 * History:
9 * - 0.38 - initial version
10 * - 0.39 - using now fnDarkOffsetWolfson3797 instead of fnDarkOffsetWolfson3799
11 * This should provide a better picture quality on the GENIUS Colorpage
12 * Vivid V2
13 * - 0.40 - no changes
14 * - 0.41 - no changes
15 * - 0.42 - changed include names
16 * - 0.43 - no changes
17 * .
18 * <hr>
19 * This file is part of the SANE package.
20 *
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License as
23 * published by the Free Software Foundation; either version 2 of the
24 * License, or (at your option) any later version.
25 *
26 * This program is distributed in the hope that it will be useful, but
27 * WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * General Public License for more details.
30 *
31 * You should have received a copy of the GNU General Public License
32 * along with this program. If not, see <https://www.gnu.org/licenses/>.
33 *
34 * As a special exception, the authors of SANE give permission for
35 * additional uses of the libraries contained in this release of SANE.
36 *
37 * The exception is that, if you link a SANE library with other files
38 * to produce an executable, this does not by itself cause the
39 * resulting executable to be covered by the GNU General Public
40 * License. Your use of that executable is in no way restricted on
41 * account of linking the SANE library code into it.
42 *
43 * This exception does not, however, invalidate any other reasons why
44 * the executable file might be covered by the GNU General Public
45 * License.
46 *
47 * If you submit changes to SANE to the maintainers to be included in
48 * a subsequent release, you agree by submitting the changes that
49 * those changes may be distributed with this exception intact.
50 *
51 * If you write modifications of your own for SANE, it is your choice
52 * whether to permit this exception to apply to your modifications.
53 * If you do not wish that, delete this exception notice.
54 * <hr>
55 */
56 #include "plustek-pp_scan.h"
57
58 /*************************** some definitions ********************************/
59
60 #define _REFLECTION 0
61 #define _TRANSPARENCY 1
62 #define _NEGATIVE 2
63
64 #define _NUM_OF_CCDREGS_W8143 25
65 #define _NUM_OF_DACREGS_W8143 10
66
67 #define _NUM_OF_CCDREGS_S1224 29
68 #define _NUM_OF_DACREGS_S1224 7
69
70 #define _NUM_OF_CCDREGS_S8531 29
71 #define _NUM_OF_DACREGS_S8531 9
72
73 #define _NUM_OF_CCDREGS_Max _NUM_OF_CCDREGS_S1224
74 #define _NUM_OF_DACREGS_Max _NUM_OF_DACREGS_W8143
75
76
77 /*************************** some local vars *********************************/
78
79 static pFnVoid p12ccdInitFunc = NULL;
80
81 static RegDef W3797CCDParams[4][_NUM_OF_CCDREGS_W8143] = {
82 {
83 {0x2c, 0x02}, {0x39, 0x2a}, {0x3a, 0x0a}, {0x3b, 0x37},
84 {0x3c, 0x16}, {0x41, 0x0e}, {0x42, 0x90}, {0x43, 0x01},
85 {0x44, 0x27}, {0x45, 0x27}, {0x46, 0x01}, {0x47, 0x03},
86 {0x48, 0x27}, {0x49, 0x2f}, {0x4a, 0x09}, {0x4b, 0x03},
87 {0x4c, 0x07}, {0x4d, 0x06}, {0x4e, 0x06}, {0x67, 0x00},
88 {0x50, 0x08}, {0x51, 0x0e}, {0x52, 0x0c}, {0x53, 0x0b},
89 {0xf0, 0x00}
90 }, {
91 {0x2c, 0x02}, {0x39, 0x3d}, {0x3a, 0x04}, {0x3b, 0x46},
92 {0x3c, 0x06}, {0x41, 0x1f}, {0x42, 0x8c}, {0x43, 0x01},
93 {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf2}, {0x47, 0x02},
94 {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x00},
95 {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x0e}, {0x67, 0x00},
96 {0x50, 0x01}, {0x51, 0x06}, {0x52, 0x09}, {0x53, 0x0b},
97 {0xf0, 0x00}
98 }, {
99 {0x2c, 0x00}, {0x39, 0x16}, {0x3a, 0x03}, {0x3b, 0x1f},
100 {0x3c, 0x07}, {0x41, 0x04}, {0x42, 0x1e}, {0x43, 0x01},
101 {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x02},
102 {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xf9}, {0x4b, 0x04},
103 {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x03}, {0x67, 0x00},
104 {0x50, 0x06}, {0x51, 0x03}, {0x52, 0x09}, {0x53, 0x0b},
105 {0xf0, 0x00}
106 }, {
107 {0x2c, 0x02}, {0x39, 0x18}, {0x3a, 0x04}, {0x3b, 0x1d},
108 {0x3c, 0x03}, {0x41, 0x0c}, {0x42, 0x84}, {0x43, 0x03},
109 {0x44, 0x0a}, {0x45, 0x08}, {0x46, 0xfa}, {0x47, 0x04},
110 {0x48, 0x0a}, {0x49, 0x08}, {0x4a, 0xf2}, {0x4b, 0x02},
111 {0x4c, 0x03}, {0x4d, 0x02}, {0x4e, 0x0e}, {0x67, 0x00},
112 {0x50, 0x00}, {0x51, 0x09}, {0x52, 0x03}, {0x53, 0x03},
113 {0xf0, 0x00}
114 }
115 };
116
117 static RegDef W3799CCDParams[4][_NUM_OF_CCDREGS_W8143] = {
118 {
119 {0x2c, 0x02}, {0x39, 0x2c}, {0x3a, 0x05}, {0x3b, 0x3c},
120 {0x3c, 0x0e}, {0x41, 0x0e}, {0x42, 0x90}, {0x43, 0x01},
121 {0x44, 0x27}, {0x45, 0x27}, {0x46, 0x01}, {0x47, 0x02},
122 {0x48, 0x27}, {0x49, 0x2f}, {0x4a, 0x09}, {0x4b, 0x05},
123 {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x06}, {0x67, 0x00},
124 {0x50, 0x08}, {0x51, 0x0d}, {0x52, 0x0c}, {0x53, 0x0b},
125 {0xf0, 0x00}
126 }, {
127 {0x2c, 0x02}, {0x39, 0x3d}, {0x3a, 0x04}, {0x3b, 0x46},
128 {0x3c, 0x06}, {0x41, 0x1f}, {0x42, 0x8c}, {0x43, 0x01},
129 {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf2}, {0x47, 0x01},
130 {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x00},
131 {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x0e}, {0x67, 0x00},
132 {0x50, 0x01}, {0x51, 0x06}, {0x52, 0x12}, {0x53, 0x0b},
133 {0xf0, 0x00}
134 }, {
135 {0x2c, 0x00}, {0x39, 0x16}, {0x3a, 0x02}, {0x3b, 0x1a},
136 {0x3c, 0x05}, {0x41, 0x04}, {0x42, 0x1e}, {0x43, 0x01},
137 {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x01},
138 {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xf9}, {0x4b, 0x04},
139 {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x03}, {0x67, 0x00},
140 {0x50, 0x06}, {0x51, 0x03}, {0x52, 0x09}, {0x53, 0x0b},
141 {0xf0, 0x00}
142 }, {
143 {0x2c, 0x02}, {0x39, 0x18}, {0x3a, 0x04}, {0x3b, 0x1d},
144 {0x3c, 0x03}, {0x41, 0x0c}, {0x42, 0x84}, {0x43, 0x03},
145 {0x44, 0x0a}, {0x45, 0x08}, {0x46, 0xfa}, {0x47, 0x03},
146 {0x48, 0x0a}, {0x49, 0x08}, {0x4a, 0xf2}, {0x4b, 0x02},
147 {0x4c, 0x03}, {0x4d, 0x02}, {0x4e, 0x0e}, {0x67, 0x00},
148 {0x50, 0x00}, {0x51, 0x09}, {0x52, 0x03}, {0x53, 0x03},
149 {0xf0, 0x00}
150 }
151 };
152
153 /* Genius ColorPage Vivid III */
154 static RegDef W548CCDParams[4][_NUM_OF_CCDREGS_W8143] = {
155 {
156 {0x2c, 0x02}, {0x39, 0x2c}, {0x3a, 0x05}, {0x3b, 0x3c},
157 {0x3c, 0x0e}, {0x41, 0x0e}, {0x42, 0x90}, {0x43, 0x01},
158 {0x44, 0x27}, {0x45, 0x27}, {0x46, 0x01}, {0x47, 0x02},
159 {0x48, 0x27}, {0x49, 0x2f}, {0x4a, 0x09}, {0x4b, 0x05},
160 {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x06}, {0x67, 0x00},
161 {0x50, 0x08}, {0x51, 0x0d}, {0x52, 0x0c}, {0x53, 0x0b},
162 {0xf0, 0x00}
163 }, {
164 {0x2c, 0x02}, {0x39, 0x3d}, {0x3a, 0x04}, {0x3b, 0x46},
165 {0x3c, 0x06}, {0x41, 0x1f}, {0x42, 0x8c}, {0x43, 0x01},
166 {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf2}, {0x47, 0x01},
167 {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x00},
168 {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x0e}, {0x67, 0x00},
169 {0x50, 0x01}, {0x51, 0x06}, {0x52, 0x12}, {0x53, 0x0b},
170 {0xf0, 0x00}
171 }, {
172 {0x2c, 0x00}, {0x39, 0x16}, {0x3a, 0x02}, {0x3b, 0x1a},
173 {0x3c, 0x05}, {0x41, 0x04}, {0x42, 0x1e}, {0x43, 0x01},
174 {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x01},
175 {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xf9}, {0x4b, 0x04},
176 {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x03}, {0x67, 0x00},
177 {0x50, 0x06}, {0x51, 0x03}, {0x52, 0x09}, {0x53, 0x0b},
178 {0xf0, 0x00}
179 }, {
180 {0x2c, 0x02}, {0x39, 0x18}, {0x3a, 0x04}, {0x3b, 0x1d},
181 {0x3c, 0x03}, {0x41, 0x0c}, {0x42, 0x84}, {0x43, 0x03},
182 {0x44, 0x0a}, {0x45, 0x08}, {0x46, 0xfa}, {0x47, 0x03},
183 {0x48, 0x0a}, {0x49, 0x08}, {0x4a, 0xf2}, {0x4b, 0x02},
184 {0x4c, 0x03}, {0x4d, 0x02}, {0x4e, 0x0e}, {0x67, 0x00},
185 {0x50, 0x00}, {0x51, 0x09}, {0x52, 0x03}, {0x53, 0x03},
186 {0xf0, 0x00}
187 }
188 };
189
190 static RegDef S3797CCDParams[4][_NUM_OF_CCDREGS_S1224] = {
191 {
192 {0x2c, 0x00}, {0x39, 0x2a}, {0x3a, 0x0a}, {0x3b, 0x37},
193 {0x3c, 0x16}, {0x41, 0x2c}, {0x42, 0x9f}, {0x43, 0x01},
194 {0x44, 0x27}, {0x45, 0x27}, {0x46, 0x01}, {0x47, 0x03},
195 {0x48, 0x27}, {0x49, 0x27}, {0x4a, 0x09}, {0x4b, 0x0b},
196 {0x4c, 0x06}, {0x4d, 0x06}, {0x4e, 0x0b}, {0x50, 0x13},
197 {0x51, 0x06}, {0x52, 0x06}, {0x53, 0x0b}, {0x67, 0x00},
198 {0x6f, 0x20}, {0x70, 0x06}, {0x60, 0x07}, {0x61, 0x9f},
199 {0x65, 0x01}
200 }, {
201 {0x2c, 0x00}, {0x39, 0x3d}, {0x3a, 0x06}, {0x3b, 0x46},
202 {0x3c, 0x06}, {0x41, 0x3d}, {0x42, 0x92}, {0x43, 0x01},
203 {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf2}, {0x47, 0x02},
204 {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x1b},
205 {0x4c, 0x06}, {0x4d, 0x06}, {0x4e, 0x0b}, {0x50, 0x23},
206 {0x51, 0x06}, {0x52, 0x06}, {0x53, 0x0b}, {0x67, 0x00},
207 {0x6f, 0x30}, {0x70, 0x06}, {0x60, 0x17}, {0x61, 0x9f},
208 {0x65, 0x01}
209 }, {
210 {0x2c, 0x02}, {0x39, 0x16}, {0x3a, 0x03}, {0x3b, 0x1f},
211 {0x3c, 0x07}, {0x41, 0x1c}, {0x42, 0x99}, {0x43, 0x01},
212 {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x02},
213 {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x09},
214 {0x4c, 0x13}, {0x4d, 0x14}, {0x4e, 0x09}, {0x50, 0x09},
215 {0x51, 0x14}, {0x52, 0x13}, {0x53, 0x01}, {0x67, 0x00},
216 {0x6f, 0xff}, {0x70, 0x7f}, {0x60, 0x04}, {0x61, 0x8f},
217 {0x65, 0x01}
218 }, {
219 {0x2c, 0x02}, {0x39, 0x16}, {0x3a, 0x03}, {0x3b, 0x1f},
220 {0x3c, 0x07}, {0x41, 0x1c}, {0x42, 0x99}, {0x43, 0x01},
221 {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x02},
222 {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x09},
223 {0x4c, 0x13}, {0x4d, 0x14}, {0x4e, 0x09}, {0x50, 0x09},
224 {0x51, 0x14}, {0x52, 0x13}, {0x53, 0x01}, {0x67, 0x00},
225 {0x6f, 0xff}, {0x70, 0x7f}, {0x60, 0x04}, {0x61, 0x8f},
226 {0x65, 0x01}
227 }
228 };
229
230 static RegDef S3799CCDParams[4][_NUM_OF_CCDREGS_S1224] = {
231 {
232 {0x2c, 0x00}, {0x39, 0x2a}, {0x3a, 0x0a}, {0x3b, 0x37},
233 {0x3c, 0x16}, {0x41, 0x2c}, {0x42, 0x8f}, {0x43, 0x01},
234 {0x44, 0x27}, {0x45, 0x27}, {0x46, 0x01}, {0x47, 0x01},
235 {0x48, 0x27}, {0x49, 0x27}, {0x4a, 0x09}, {0x4b, 0x0b},
236 {0x4c, 0x06}, {0x4d, 0x06}, {0x4e, 0x0b}, {0x50, 0x13},
237 {0x51, 0x06}, {0x52, 0x06}, {0x53, 0x0b}, {0x67, 0x00},
238 {0x6f, 0x20}, {0x70, 0x06}, {0x60, 0x07}, {0x61, 0x9f},
239 {0x65, 0x01}
240 }, {
241 {0x2c, 0x00}, {0x39, 0x3d}, {0x3a, 0x06}, {0x3b, 0x46},
242 {0x3c, 0x06}, {0x41, 0x3d}, {0x42, 0x92}, {0x43, 0x01},
243 {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf2}, {0x47, 0x01},
244 {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x1b},
245 {0x4c, 0x06}, {0x4d, 0x06}, {0x4e, 0x0b}, {0x50, 0x23},
246 {0x51, 0x06}, {0x52, 0x06}, {0x53, 0x0b}, {0x67, 0x00},
247 {0x6f, 0x30}, {0x70, 0x06}, {0x60, 0x17}, {0x61, 0x9f},
248 {0x65, 0x01}
249 }, {
250 {0x2c, 0x02}, {0x39, 0x16}, {0x3a, 0x03}, {0x3b, 0x1f},
251 {0x3c, 0x07}, {0x41, 0x1c}, {0x42, 0x99}, {0x43, 0x01},
252 {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x01},
253 {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x09},
254 {0x4c, 0x13}, {0x4d, 0x14}, {0x4e, 0x09}, {0x50, 0x09},
255 {0x51, 0x14}, {0x52, 0x13}, {0x53, 0x01}, {0x67, 0x00},
256 {0x6f, 0xff}, {0x70, 0x7f}, {0x60, 0x04}, {0x61, 0x8f},
257 {0x65, 0x01}
258 }, {
259 {0x2c, 0x00}, {0x39, 0x16}, {0x3a, 0x03}, {0x3b, 0x1f},
260 {0x3c, 0x07}, {0x41, 0x1c}, {0x42, 0x99}, {0x43, 0x03},
261 {0x44, 0x0a}, {0x45, 0x08}, {0x46, 0xfa}, {0x47, 0x03},
262 {0x48, 0x0a}, {0x49, 0x08}, {0x4a, 0xf2}, {0x4b, 0x02},
263 {0x4c, 0x03}, {0x4d, 0x02}, {0x4e, 0x0e}, {0x50, 0x00},
264 {0x51, 0x09}, {0x52, 0x03}, {0x53, 0x03}, {0x67, 0x00},
265 {0x6f, 0xff}, {0x70, 0x7f}, {0x60, 0x04}, {0x61, 0x8f},
266 {0x65, 0x01}
267 }
268 };
269
270 static RegDef WolfsonDAC8143[_NUM_OF_DACREGS_W8143] = {
271 {0x01, 0x01}, {0x02, 0x04}, {0x03, 0x42}, {0x05, 0x10}, {0x20, 0xd0},
272 {0x21, 0xd0}, {0x22, 0xd0}, {0x24, 0x00}, {0x25, 0x00}, {0x26, 0x00}
273 };
274
275 static RegDef SamsungDAC8531[_NUM_OF_DACREGS_S8531] = {
276 {0x00, 0x51}, {0x02, 0x01}, {0x01, 0x80},
277 {0x00, 0x55}, {0x02, 0x01}, {0x01, 0x80},
278 {0x00, 0x59}, {0x02, 0x01}, {0x01, 0x80}
279 };
280
281 static RegDef SamsungDAC1224[_NUM_OF_DACREGS_S1224] ={
282 {0x00, 0x00}, {0x01, 0x80}, {0x02, 0x80},
283 {0x03, 0x80}, {0x04, 0x06}, {0x05, 0x06}, {0x06, 0x06}
284 };
285
286 static DACTblDef ShadingVar3797[3] = {
287 {
288 {{99, 100, 94}}, {{0x30, 0x30, 0x30}},
289 {{0x20, 0x20, 0x20}}, {{0x04, 0x00, 0x00}}, {{0xcc, 0xcc, 0xcc}}, 0
290 }, {
291 {{100, 90, 100}}, {{0x30, 0x30, 0x30}},
292 {{0x20, 0x20, 0x20}}, {{0x10, 0x10, 0x10}}, {{0xcc, 0xcc, 0xcc}}, 0
293 }, {
294 {{90, 90, 90}}, {{0x30, 0x30, 0x30}}, {{0x20, 0x20, 0x20}},
295 {{0x10, 0x10, 0x10}}, {{0x80, 0x80, 0x80}}, 0
296 }
297 };
298
299 static DACTblDef ShadingVar3799[3] = {
300 {
301 {{100, 97, 92}}, {{0x90, 0xe0, 0x80}},
302 {{0x70, 0xc0, 0x60}}, {{0x90, 0x34, 0x3c}}, {{0x80, 0x80, 0x80}}, 0
303 }, {
304 {{75, 75, 75}}, {{0x30, 0x30, 0x30}},
305 {{0x10, 0x10, 0x10}}, {{0x20, 0x20, 0x20}}, {{0x80, 0x80, 0x80}}, 0
306 }, {
307 {{80, 75, 64}}, {{0x30, 0x30, 0x30}},
308 {{0x20, 0x20, 0x20}}, {{0x10, 0x10, 0x10}}, {{0x80, 0x80, 0x80}}, 0
309 }
310 };
311
312 /* Genius ColorPage Vivid III */
313 static DACTblDef ShadingVar548[3] = {
314 {
315 {{100, 97, 92}}, {{0x90, 0xe0, 0x80}},
316 {{0x70, 0xc0, 0x60}}, {{0x90, 0x34, 0x3c}}, {{0x80, 0x80, 0x80}}, 0
317 }, {
318 {{75, 75, 75}}, {{0x30, 0x30, 0x30}},
319 {{0x10, 0x10, 0x10}}, {{0x20, 0x20, 0x20}}, {{0x80, 0x80, 0x80}}, 0
320 }, {
321 {{80, 75, 64}}, {{0x30, 0x30, 0x30}},
322 {{0x20, 0x20, 0x20}}, {{0x10, 0x10, 0x10}}, {{0x80, 0x80, 0x80}}, 0
323 }
324 };
325
326 static DACTblDef ShadingVar3777[3] = {
327 {
328 {{100, 100, 100}}, {{0x90, 0xe0, 0x80}},
329 {{0x70, 0xc0, 0x60}}, {{0x90, 0x34, 0x3c}}, {{0x80, 0x80, 0x80}}, 0
330 }, {
331 {{75, 75, 75}}, {{0x30, 0x30, 0x30}},
332 {{0x10, 0x10, 0x10}}, {{0x20, 0x20, 0x20}}, {{0x80, 0x80, 0x80}}, 0
333 }, {
334 {{80, 75, 64}}, {{0x30, 0x30, 0x30}},
335 {{0x20, 0x20, 0x20}}, {{0x10, 0x10, 0x10}}, {{0x80, 0x80, 0x80}}, 0
336 }
337 };
338
339 /*************************** local functions *********************************/
340
341 /*.............................................................................
342 *
343 */
fnCCDInitWolfson3797( pScanData ps )344 static void fnCCDInitWolfson3797( pScanData ps )
345 {
346 if( ps->Shade.bIntermediate & _ScanMode_Mono )
347 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0xcc;
348 else
349 if (ps->Shade.bIntermediate & _ScanMode_AverageOut)
350 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x68;
351 else
352 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0xa0;
353
354 if((ps->Shade.bIntermediate & _ScanMode_AverageOut) ||
355 (ps->DataInf.dwScanFlag & SCANDEF_Negative))
356 WolfsonDAC8143[3].bParam = 0x12;
357 else
358 WolfsonDAC8143[3].bParam = 0x10;
359 }
360
361 /*.............................................................................
362 *
363 */
fnCCDInitSamsung3797( pScanData ps )364 static void fnCCDInitSamsung3797( pScanData ps )
365 {
366 if(!(ps->DataInf.dwScanFlag & SCANDEF_TPA)) {
367
368 if (!(ps->Shade.bIntermediate & _ScanMode_AverageOut)) {
369
370 if( ps->Device.bPCBID == _OPTICWORKS2000 ) {
371 ps->Shade.pCcdDac->GainResize.Colors.Red = 102;
372 ps->Shade.pCcdDac->GainResize.Colors.Green = 102;
373 ps->Shade.pCcdDac->GainResize.Colors.Blue = 97;
374 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x40;
375 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x40;
376 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x40;
377 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x48;
378 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x40;
379 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x40;
380 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x38;
381 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x30;
382 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x30;
383 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x48;
384 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x38;
385 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x40;
386 } else {
387 ps->Shade.pCcdDac->GainResize.Colors.Red = 99;
388 ps->Shade.pCcdDac->GainResize.Colors.Green = 101;
389 ps->Shade.pCcdDac->GainResize.Colors.Blue = 94;
390 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x40;
391 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x40;
392 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x40;
393 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x30;
394 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
395 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
396 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x20;
397 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x20;
398 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x20;
399 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x04;
400 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x00;
401 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x00;
402 }
403 } else {
404 if( ps->Device.bPCBID == _OPTICWORKS2000 ) {
405 ps->Shade.pCcdDac->GainResize.Colors.Red = 100;
406 ps->Shade.pCcdDac->GainResize.Colors.Green = 100;
407 ps->Shade.pCcdDac->GainResize.Colors.Blue = 96;
408 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x30;
409 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x30;
410 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x30;
411 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x48;
412 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x48;
413 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x48;
414 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x38;
415 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x38;
416 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x38;
417 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x48;
418 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x48;
419 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x48;
420 } else {
421 ps->Shade.pCcdDac->GainResize.Colors.Red = 100; /* 98 */
422 ps->Shade.pCcdDac->GainResize.Colors.Green = 103; /* 106 */
423 ps->Shade.pCcdDac->GainResize.Colors.Blue = 96; /* 96 */
424 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x20;
425 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x10;
426 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x10;
427 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x110;
428 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x1f0;
429 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x190;
430 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x100;
431 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x1e0;
432 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x180;
433 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x20;
434 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x10;
435 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x20;
436 }
437 }
438 }
439 }
440
441 /*.............................................................................
442 *
443 */
fnCCDInitWolfson3799( pScanData ps )444 static void fnCCDInitWolfson3799( pScanData ps )
445 {
446 if(!(ps->DataInf.dwScanFlag & SCANDEF_Negative)) {
447
448 if (!(ps->Shade.bIntermediate & _ScanMode_AverageOut)) {
449
450 ps->Shade.pCcdDac->GainResize.Colors.Red = 103;
451 ps->Shade.pCcdDac->GainResize.Colors.Green = 102;
452 ps->Shade.pCcdDac->GainResize.Colors.Blue = 99;
453 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0xc8;
454 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0xc8;
455 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0xc8;
456 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x48;
457 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
458 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
459 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x40;
460 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
461 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
462 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x48;
463 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x18;
464 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x2c;
465 } else {
466 ps->Shade.pCcdDac->GainResize.Colors.Red = 100;
467 ps->Shade.pCcdDac->GainResize.Colors.Green = 98;
468 ps->Shade.pCcdDac->GainResize.Colors.Blue = 95;
469 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0xd0;
470 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0xd0;
471 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0xd0;
472 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x30;
473 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
474 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
475 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x28;
476 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
477 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
478 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x0;
479 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x0;
480 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x0;
481 }
482 } else {
483 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x80;
484 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x80;
485 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x80;
486 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x28;
487 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x28;
488 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x28;
489 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x20;
490 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x20;
491 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x20;
492 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = -0x38;
493 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = -0x108;
494 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = -0x1c8;
495 }
496 }
497
498 /*.............................................................................
499 * Genius ColorPage VIVID III
500 */
fnCCDInitWolfson548( pScanData ps )501 static void fnCCDInitWolfson548( pScanData ps )
502 {
503 if (!(ps->Shade.bIntermediate & _ScanMode_AverageOut)) {
504
505 ps->Shade.pCcdDac->GainResize.Colors.Red = 103;
506 ps->Shade.pCcdDac->GainResize.Colors.Green = 102;
507 ps->Shade.pCcdDac->GainResize.Colors.Blue = 99;
508 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0xc8;
509 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0xc8;
510 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0xc8;
511 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x48;
512 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
513 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
514 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x40;
515 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
516 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
517 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x48;
518 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x18;
519 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x2c;
520
521 } else {
522 ps->Shade.pCcdDac->GainResize.Colors.Red = 100;
523 ps->Shade.pCcdDac->GainResize.Colors.Green = 98;
524 ps->Shade.pCcdDac->GainResize.Colors.Blue = 95;
525 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0xd0;
526 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0xd0;
527 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0xd0;
528 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x30;
529 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
530 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
531 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x28;
532 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
533 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
534 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x0;
535 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x0;
536 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x0;
537 }
538 }
539
540 /*.............................................................................
541 *
542 */
fnCCDInitSamsung3777( pScanData ps )543 static void fnCCDInitSamsung3777( pScanData ps )
544 {
545 if(!(ps->DataInf.dwScanFlag & SCANDEF_Negative)) {
546
547 if (!(ps->Shade.bIntermediate & _ScanMode_AverageOut)) {
548
549 ps->Shade.pCcdDac->GainResize.Colors.Red = 109;
550 ps->Shade.pCcdDac->GainResize.Colors.Green = 108;
551 ps->Shade.pCcdDac->GainResize.Colors.Blue = 105;
552 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x4a;
553 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x4a;
554 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x4a;
555 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x3c;
556 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x38;
557 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x38;
558 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x28;
559 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x2c;
560 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
561 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x30;
562 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x30;
563 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x3C;
564 } else {
565 ps->Shade.pCcdDac->GainResize.Colors.Red = 108;
566 ps->Shade.pCcdDac->GainResize.Colors.Green = 107;
567 ps->Shade.pCcdDac->GainResize.Colors.Blue = 104;
568 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x50;
569 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x50;
570 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x50;
571 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x40;
572 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x40;
573 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x40;
574 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x30;
575 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x30;
576 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x30;
577 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x20;
578 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x20;
579 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x20;
580 }
581 } else {
582 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x80;
583 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x80;
584 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x80;
585 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x28;
586 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x28;
587 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x28;
588 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x20;
589 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x20;
590 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x20;
591 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = -0x38;
592 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = -0x108;
593 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = -0x1c8;
594 }
595 }
596
597 /*.............................................................................
598 *
599 */
fnCCDInitSamsung3799( pScanData ps )600 static void fnCCDInitSamsung3799( pScanData ps )
601 {
602 if(!(ps->DataInf.dwScanFlag & SCANDEF_TPA)) {
603
604 if (!(ps->Shade.bIntermediate & _ScanMode_AverageOut)) {
605
606 if( ps->Device.bPCBID == _SCANNER2Button ) {
607 ps->Shade.pCcdDac->GainResize.Colors.Red = 109;
608 ps->Shade.pCcdDac->GainResize.Colors.Green = 109;
609 ps->Shade.pCcdDac->GainResize.Colors.Blue = 105;
610 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x68;
611 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x68;
612 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x68;
613 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x30;
614 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
615 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
616 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x28;
617 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
618 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
619 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x24; /* 0 */
620 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x20; /* 0 */
621 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x1c; /* 0 */
622 } else {
623 ps->Shade.pCcdDac->GainResize.Colors.Red = 98;
624 ps->Shade.pCcdDac->GainResize.Colors.Green = 97;
625 ps->Shade.pCcdDac->GainResize.Colors.Blue = 92;
626 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x90;
627 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x90;
628 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x90;
629 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0xc0; /* 0x90 */
630 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0xc0; /* 0xe0 */
631 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0xc0; /* 0x80 */
632 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0xb0; /* 0x70 */
633 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0xb0; /* 0xc0 */
634 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0xb0; /* 0x60 */
635 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x24; /* 0x90 */
636 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x00; /* 0x34 */
637 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x0c; /* 0x3c */
638 }
639 } else {
640 if( ps->Device.bPCBID == _SCANNER2Button ) {
641 ps->Shade.pCcdDac->GainResize.Colors.Red = 107;
642 ps->Shade.pCcdDac->GainResize.Colors.Green = 106;
643 ps->Shade.pCcdDac->GainResize.Colors.Blue = 103;
644 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x48;
645 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x48;
646 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x48;
647 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x30;
648 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
649 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
650 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x28;
651 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
652 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
653 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x28; /* 0 */
654 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x18; /* 0 */
655 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x20; /* 0 */
656 } else {
657 ps->Shade.pCcdDac->GainResize.Colors.Red = 104;
658 ps->Shade.pCcdDac->GainResize.Colors.Green = 107;
659 ps->Shade.pCcdDac->GainResize.Colors.Blue = 99;
660 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x30; /* 0x80 */
661 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x30;
662 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x30; /* 0x0a0 */
663 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x150; /* 0x170 */
664 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x130; /* 0x90 */
665 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x110; /* 0x130 */
666 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x140; /* 0x150 */
667 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x120; /* 0x70 */
668 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x100; /* 0x120 */
669 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0xF0; /* 0x90 */
670 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0xD4; /* 0x50 */
671 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0xCC; /* 0x60 */
672 }
673 }
674 }
675 }
676
677 /*.............................................................................
678 *
679 */
fnCCDInitESIC3799( pScanData ps )680 static void fnCCDInitESIC3799( pScanData ps )
681 {
682 if(!(ps->DataInf.dwScanFlag & SCANDEF_Negative)) {
683
684 if (!(ps->Shade.bIntermediate & _ScanMode_AverageOut)) {
685
686 ps->Shade.pCcdDac->GainResize.Colors.Red = 100;
687 ps->Shade.pCcdDac->GainResize.Colors.Green = 99;
688 ps->Shade.pCcdDac->GainResize.Colors.Blue = 94;
689 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0xc8;
690 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0xc8;
691 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0xc8;
692 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x58;
693 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x38;
694 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x48;
695 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x48;
696 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
697 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x38;
698 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x58;
699 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0x38;
700 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0x48;
701 } else {
702 ps->Shade.pCcdDac->GainResize.Colors.Red = 100;
703 ps->Shade.pCcdDac->GainResize.Colors.Green = 98;
704 ps->Shade.pCcdDac->GainResize.Colors.Blue = 93;
705 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0xd0;
706 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0xd0;
707 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0xd0;
708 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x108;
709 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0xf8;
710 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0xc8;
711 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x100;
712 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0xf0;
713 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0xc0;
714 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = 0x108;
715 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = 0xf8;
716 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = 0xc8;
717 }
718 } else {
719 ps->Shade.pCcdDac->DarkDAC.Colors.Red = 0x80;
720 ps->Shade.pCcdDac->DarkDAC.Colors.Green = 0x80;
721 ps->Shade.pCcdDac->DarkDAC.Colors.Blue = 0x80;
722 ps->Shade.pCcdDac->DarkCmpHi.Colors.Red = 0x28;
723 ps->Shade.pCcdDac->DarkCmpHi.Colors.Green = 0x28;
724 ps->Shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x28;
725 ps->Shade.pCcdDac->DarkCmpLo.Colors.Red = 0x20;
726 ps->Shade.pCcdDac->DarkCmpLo.Colors.Green = 0x20;
727 ps->Shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x20;
728 ps->Shade.pCcdDac->DarkOffSub.Colors.Red = -0x38;
729 ps->Shade.pCcdDac->DarkOffSub.Colors.Green = -0x38;
730 ps->Shade.pCcdDac->DarkOffSub.Colors.Blue = -0x38;
731 }
732 }
733
734 /*.............................................................................
735 *
736 */
fnDarkOffsetWolfson3797( pScanData ps, pDACTblDef pDacTbl, ULong dwCh )737 static void fnDarkOffsetWolfson3797( pScanData ps, pDACTblDef pDacTbl, ULong dwCh )
738 {
739 if(( ps->Shade.DarkOffset.wColors[dwCh] -=
740 pDacTbl->DarkOffSub.wColors[dwCh]) > 0xfff ) {
741 ps->Shade.DarkOffset.wColors[dwCh] = 0;
742 }
743 }
744
745 /*.............................................................................
746 * this function was defined in the original sources, but never used...
747 */
748 #if 0
749 static void fnDarkOffsetWolfson3799( pScanData ps, pDACTblDef pDacTbl, ULong dwCh )
750 {
751 if( ps->Shade.DarkOffset.wColors[dwCh] > pDacTbl->DarkOffSub.wColors[dwCh])
752 ps->Shade.DarkOffset.wColors[dwCh] -= pDacTbl->DarkOffSub.wColors[dwCh];
753 else
754 ps->Shade.DarkOffset.wColors[dwCh] = 0;
755 }
756 #endif
757
758 /*.............................................................................
759 *
760 */
fnDarkOffsetSamsung3777( pScanData ps, pDACTblDef pDacTbl, ULong dwCh )761 static void fnDarkOffsetSamsung3777( pScanData ps, pDACTblDef pDacTbl, ULong dwCh )
762 {
763 ps->Shade.DarkOffset.wColors[dwCh] += pDacTbl->DarkOffSub.wColors [dwCh];
764 }
765
766 /*.............................................................................
767 *
768 */
fnDarkOffsetSamsung3797( pScanData ps, pDACTblDef pDacTbl, ULong dwCh )769 static void fnDarkOffsetSamsung3797( pScanData ps, pDACTblDef pDacTbl, ULong dwCh )
770 {
771 if( ps->Shade.DarkOffset.wColors[dwCh] > pDacTbl->DarkOffSub.wColors[dwCh] )
772 ps->Shade.DarkOffset.wColors[dwCh] -= pDacTbl->DarkOffSub.wColors[dwCh];
773 else
774 ps->Shade.DarkOffset.wColors[dwCh] = 0;
775 }
776
777 /*.............................................................................
778 *
779 */
fnDarkOffsetSamsung3799( pScanData ps, pDACTblDef pDacTbl, ULong dwCh )780 static void fnDarkOffsetSamsung3799( pScanData ps, pDACTblDef pDacTbl, ULong dwCh )
781 {
782 if( ps->Shade.DarkOffset.wColors[dwCh] > pDacTbl->DarkOffSub.wColors[dwCh])
783 ps->Shade.DarkOffset.wColors[dwCh] -= pDacTbl->DarkOffSub.wColors[dwCh];
784 else
785 ps->Shade.DarkOffset.wColors[dwCh] = 0;
786 }
787
788 /*.............................................................................
789 *
790 */
fnDACDarkWolfson( pScanData ps, pDACTblDef pDacTbl, ULong dwCh, UShort wDarkest )791 static void fnDACDarkWolfson( pScanData ps, pDACTblDef pDacTbl,
792 ULong dwCh, UShort wDarkest )
793 {
794 UShort w;
795
796 w = ps->Shade.DarkDAC.bColors[dwCh];
797
798 if (wDarkest > pDacTbl->DarkCmpHi.wColors[dwCh] ) {
799
800 wDarkest -= pDacTbl->DarkCmpHi.wColors[dwCh];
801 if (wDarkest > ps->Shade.wDarkLevels)
802 w += (UShort)wDarkest / ps->Shade.wDarkLevels;
803 else
804 w++;
805
806 if (w > 0xff)
807 w = 0xff;
808
809 if(w != (UShort)ps->Shade.DarkDAC.bColors[dwCh] ) {
810 ps->Shade.DarkDAC.bColors[dwCh] = (Byte)w;
811 ps->Shade.fStop = _FALSE;
812 }
813 } else
814 if((wDarkest < pDacTbl->DarkCmpLo.wColors[dwCh]) &&
815 ps->Shade.DarkDAC.bColors[dwCh]) {
816 if (wDarkest)
817 w = (UShort)ps->Shade.DarkDAC.bColors[dwCh] - 2U;
818 else
819 w = (UShort)ps->Shade.DarkDAC.bColors[dwCh] - ps->Shade.wDarkLevels;
820
821 if ((short) w < 0)
822 w = 0;
823 if (w != (UShort)ps->Shade.DarkDAC.bColors[dwCh] ) {
824 ps->Shade.DarkDAC.bColors [dwCh] = (Byte)w;
825 ps->Shade.fStop = _FALSE;
826 }
827 }
828 }
829
830 /*.............................................................................
831 *
832 */
fnDACDarkSamsung( pScanData ps, pDACTblDef pDacTbl, ULong dwCh, UShort wDarkest )833 static void fnDACDarkSamsung( pScanData ps, pDACTblDef pDacTbl,
834 ULong dwCh, UShort wDarkest )
835 {
836 UShort w;
837
838 if( wDarkest > pDacTbl->DarkCmpHi.wColors[dwCh] ) {
839
840 wDarkest -= pDacTbl->DarkCmpHi.wColors [dwCh];
841 if (wDarkest > ps->Shade.wDarkLevels)
842 w = (UShort)ps->Shade.DarkDAC.bColors[dwCh] -
843 wDarkest / ps->Shade.wDarkLevels;
844 else
845 w = (UShort)ps->Shade.DarkDAC.bColors[dwCh] - 1U;
846
847 if((short) w < 0)
848 w = 0;
849
850 if(w != (UShort)ps->Shade.DarkDAC.bColors[dwCh]) {
851 ps->Shade.DarkDAC.bColors [dwCh] = (Byte)w;
852 ps->Shade.fStop = _FALSE;
853 }
854 } else
855 if((wDarkest < pDacTbl->DarkCmpLo.wColors[dwCh]) &&
856 ps->Shade.DarkDAC.bColors[dwCh]) {
857 if (wDarkest)
858 w = (UShort)ps->Shade.DarkDAC.bColors[dwCh] + 2U;
859 else
860 w = ps->Shade.wDarkLevels + (UShort)ps->Shade.DarkDAC.bColors [dwCh];
861
862 if (w > 0xff)
863 w = 0xff;
864
865 if(w != (UShort)ps->Shade.DarkDAC.bColors[dwCh]) {
866 ps->Shade.DarkDAC.bColors[dwCh] = (Byte)w;
867 ps->Shade.fStop = _FALSE;
868 }
869 }
870 }
871
872 /************************ exported functions *********************************/
873
874 /*.............................................................................
875 * according to detected CCD and DAC, we set their correct init values
876 * and functions
877 */
P12InitCCDandDAC( pScanData ps, Bool shading )878 _LOC void P12InitCCDandDAC( pScanData ps, Bool shading )
879 {
880 UShort w;
881 pDACTblDef pDAC_CCD;
882
883 /* some presets */
884 ps->Device.f0_8_16 = _FALSE;
885
886 switch( ps->Device.bDACType ) {
887
888 case _DA_WOLFSON8143:
889
890 DBG( DBG_LOW, "WOLFSON 8143\n" );
891 switch( ps->Device.bCCDID ) {
892
893 case _CCD_3797:
894 DBG( DBG_LOW, "CCD-3797\n" );
895 pDAC_CCD = ShadingVar3797;
896 p12ccdInitFunc = fnCCDInitWolfson3797;
897 ps->Device.fnDarkOffset = fnDarkOffsetWolfson3797;
898 ps->Device.fnDACDark = fnDACDarkWolfson;
899 ps->Device.pCCDRegisters = (pRegDef)W3797CCDParams;
900 break;
901
902 case _CCD_548:
903 DBG( DBG_LOW, "CCD-548\n" );
904 pDAC_CCD = ShadingVar548;
905 p12ccdInitFunc = fnCCDInitWolfson548;
906 ps->Device.fnDarkOffset = fnDarkOffsetWolfson3797;
907 ps->Device.fnDACDark = fnDACDarkWolfson;
908 ps->Device.pCCDRegisters = (pRegDef)W548CCDParams;
909 break;
910
911
912 default:
913 DBG( DBG_LOW, "CCD-3799\n" );
914 pDAC_CCD = ShadingVar3799;
915 p12ccdInitFunc = fnCCDInitWolfson3799;
916 /* CHECK: org was to fnDarkOffsetWolfson3797 */
917 ps->Device.fnDarkOffset = fnDarkOffsetWolfson3797;
918 ps->Device.fnDACDark = fnDACDarkWolfson;
919 ps->Device.pCCDRegisters = (pRegDef)W3799CCDParams;
920 }
921
922 ps->Device.wNumCCDRegs = _NUM_OF_CCDREGS_W8143;
923 ps->Device.wNumDACRegs = _NUM_OF_DACREGS_W8143;
924 ps->Device.pDACRegisters = WolfsonDAC8143;
925 ps->Device.RegDACOffset.Red = 0x20;
926 ps->Device.RegDACOffset.Green = 0x21;
927 ps->Device.RegDACOffset.Blue = 0x22;
928 ps->Device.RegDACGain.Red = 0x28;
929 ps->Device.RegDACGain.Green = 0x29;
930 ps->Device.RegDACGain.Blue = 0x2a;
931
932 if( ps->Shade.bIntermediate & _ScanMode_AverageOut ) {
933 ps->Shade.bUniGain = 1;
934 ps->Shade.bGainDouble = 1;
935 } else {
936 ps->Shade.bUniGain = 2;
937 ps->Shade.bGainDouble = 4;
938 }
939 ps->Shade.bMinGain = 1;
940 ps->Shade.bMaxGain = 0x1f;
941 ps->Shade.wDarkLevels = 10;
942
943 if( ps->Shade.bIntermediate == _ScanMode_Color )
944 WolfsonDAC8143[2].bParam = 0x52;
945 else
946 WolfsonDAC8143[2].bParam = 0x42;
947
948 if (ps->Shade.bIntermediate == _ScanMode_Mono )
949 WolfsonDAC8143 [0].bParam = 7;
950 else
951 WolfsonDAC8143 [0].bParam = 3;
952
953 break;
954
955 case _DA_SAMSUNG1224:
956
957 DBG( DBG_LOW, "Samsung 1224\n" );
958
959 switch(ps->Device.bCCDID )
960 {
961 case _CCD_3797:
962 DBG( DBG_LOW, "CCD-3797\n" );
963 pDAC_CCD = ShadingVar3797;
964 p12ccdInitFunc = fnCCDInitSamsung3797;
965 ps->Device.fnDarkOffset = fnDarkOffsetSamsung3797;
966 ps->Device.fnDACDark = fnDACDarkSamsung;
967 ps->Device.pCCDRegisters = (pRegDef)S3797CCDParams;
968 break;
969
970 default:
971 DBG( DBG_LOW, "CCD-3799\n" );
972 pDAC_CCD = ShadingVar3799;
973 p12ccdInitFunc = fnCCDInitSamsung3799;
974 ps->Device.fnDarkOffset = fnDarkOffsetSamsung3799;
975 ps->Device.fnDACDark = fnDACDarkSamsung;
976 ps->Device.pCCDRegisters = (pRegDef)S3799CCDParams;
977 }
978 ps->Device.wNumCCDRegs = _NUM_OF_CCDREGS_S1224;
979 ps->Device.wNumDACRegs = _NUM_OF_DACREGS_S1224;
980 ps->Device.pDACRegisters = SamsungDAC1224;
981 ps->Device.RegDACOffset.Red = 1;
982 ps->Device.RegDACOffset.Green = 2;
983 ps->Device.RegDACOffset.Blue = 3;
984 ps->Device.RegDACGain.Red = 4;
985 ps->Device.RegDACGain.Green = 5;
986 ps->Device.RegDACGain.Blue = 6;
987 ps->Shade.bGainDouble = 6;
988 ps->Shade.bUniGain = 7;
989 ps->Shade.bMinGain = 0;
990 ps->Shade.bMaxGain = 0x1f;
991 ps->Shade.wDarkLevels = 10;
992
993 if( ps->Shade.bIntermediate & _ScanMode_Mono )
994 SamsungDAC1224[0].bParam = 0x57;
995 else
996 SamsungDAC1224[0].bParam = 0x51;
997 break;
998
999 case _DA_ESIC:
1000
1001 DBG( DBG_LOW, "ESIC\n" );
1002
1003 switch( ps->Device.bCCDID ) {
1004
1005 case _CCD_3797:
1006 DBG( DBG_LOW, "CCD-3797\n" );
1007 pDAC_CCD = ShadingVar3797;
1008 p12ccdInitFunc = fnCCDInitWolfson3797;
1009 ps->Device.fnDarkOffset = fnDarkOffsetWolfson3797;
1010 ps->Device.fnDACDark = fnDACDarkWolfson;
1011 ps->Device.pCCDRegisters = (pRegDef)W3797CCDParams;
1012 break;
1013
1014 default:
1015 DBG( DBG_LOW, "CCD-3799\n" );
1016 pDAC_CCD = ShadingVar3799;
1017 p12ccdInitFunc = fnCCDInitESIC3799;
1018 ps->Device.fnDarkOffset = fnDarkOffsetWolfson3797;
1019 ps->Device.fnDACDark = fnDACDarkWolfson;
1020 ps->Device.pCCDRegisters = (pRegDef)W3799CCDParams;
1021 }
1022
1023 ps->Device.wNumCCDRegs = _NUM_OF_CCDREGS_W8143;
1024 ps->Device.wNumDACRegs = _NUM_OF_DACREGS_W8143;
1025 ps->Device.pDACRegisters = WolfsonDAC8143;
1026 ps->Device.RegDACOffset.Red = 0x20;
1027 ps->Device.RegDACOffset.Green = 0x21;
1028 ps->Device.RegDACOffset.Blue = 0x22;
1029 ps->Device.RegDACGain.Red = 0x28;
1030 ps->Device.RegDACGain.Green = 0x29;
1031 ps->Device.RegDACGain.Blue = 0x2a;
1032
1033 if( ps->Shade.bIntermediate & _ScanMode_AverageOut ) {
1034 ps->Shade.bUniGain = 1;
1035 ps->Shade.bGainDouble = 1;
1036 } else {
1037 ps->Shade.bUniGain = 2;
1038 ps->Shade.bGainDouble = 4;
1039 }
1040 ps->Shade.bMinGain = 1;
1041 ps->Shade.bMaxGain = 0x1f;
1042 ps->Shade.wDarkLevels = 10;
1043
1044 if( ps->Shade.bIntermediate == _ScanMode_Color )
1045 WolfsonDAC8143 [2].bParam = 0x52;
1046 else
1047 WolfsonDAC8143 [2].bParam = 0x42;
1048
1049 if(ps->Shade.bIntermediate == _ScanMode_Mono )
1050 WolfsonDAC8143[0].bParam = 7;
1051 else
1052 WolfsonDAC8143[0].bParam = 3;
1053 break;
1054
1055 /* _DA_SAMSUNG8531 */
1056 default:
1057
1058 DBG( DBG_LOW, "SAMSUNG 8531\n" );
1059 switch( ps->Device.bCCDID ) {
1060
1061 case _CCD_3797:
1062 DBG( DBG_LOW, "CCD-3797\n" );
1063 pDAC_CCD = ShadingVar3797;
1064 p12ccdInitFunc = fnCCDInitSamsung3797;
1065 ps->Device.fnDarkOffset = fnDarkOffsetSamsung3797;
1066 ps->Device.fnDACDark = fnDACDarkSamsung;
1067 ps->Device.pCCDRegisters = (pRegDef)S3797CCDParams;
1068 break;
1069
1070 case _CCD_3777:
1071 DBG( DBG_LOW, "CCD-3777\n" );
1072 pDAC_CCD = ShadingVar3777;
1073 p12ccdInitFunc = fnCCDInitSamsung3777;
1074 ps->Device.fnDarkOffset = fnDarkOffsetSamsung3777;
1075 ps->Device.fnDACDark = fnDACDarkSamsung;
1076 ps->Device.pCCDRegisters = (pRegDef)S3797CCDParams;
1077 ps->Device.f0_8_16 = _TRUE;
1078 break;
1079
1080 default:
1081 DBG( DBG_LOW, "CCD-3799\n" );
1082 pDAC_CCD = ShadingVar3799;
1083 p12ccdInitFunc = fnCCDInitSamsung3799;
1084 ps->Device.fnDarkOffset = fnDarkOffsetSamsung3799;
1085 ps->Device.fnDACDark = fnDACDarkSamsung;
1086 ps->Device.pCCDRegisters = (pRegDef)S3799CCDParams;
1087 }
1088
1089 ps->Device.wNumCCDRegs = _NUM_OF_CCDREGS_S8531;
1090 ps->Device.wNumDACRegs = _NUM_OF_DACREGS_S8531;
1091 ps->Device.pDACRegisters = SamsungDAC8531;
1092 ps->Device.RegDACOffset.Red =
1093 ps->Device.RegDACOffset.Green =
1094 ps->Device.RegDACOffset.Blue = 1;
1095 ps->Device.RegDACGain.Red =
1096 ps->Device.RegDACGain.Green =
1097 ps->Device.RegDACGain.Blue = 2;
1098 ps->Shade.bGainDouble = 6;
1099 ps->Shade.bMinGain = 1;
1100 ps->Shade.bMaxGain = 0x1f;
1101 if( ps->DataInf.dwScanFlag & SCANDEF_TPA )
1102 ps->Shade.bUniGain = 2;
1103 else
1104 ps->Shade.bUniGain = 7;
1105
1106 ps->Shade.wDarkLevels = 10;
1107
1108 if( ps->Shade.bIntermediate & _ScanMode_Mono ) {
1109 SamsungDAC8531[0].bParam = 0x57;
1110 SamsungDAC8531[3].bParam = 0x57;
1111 SamsungDAC8531[6].bParam = 0x57;
1112 } else {
1113 SamsungDAC8531[0].bParam = 0x51;
1114 SamsungDAC8531[3].bParam = 0x55;
1115 SamsungDAC8531[6].bParam = 0x59;
1116 }
1117 }
1118
1119 if( shading ) {
1120
1121 if( !(ps->DataInf.dwScanFlag & SCANDEF_TPA))
1122 ps->Shade.pCcdDac = &pDAC_CCD[_REFLECTION];
1123 else {
1124 if( ps->DataInf.dwScanFlag & SCANDEF_Transparency )
1125 ps->Shade.pCcdDac = &pDAC_CCD[_TRANSPARENCY];
1126 else
1127 ps->Shade.pCcdDac = &pDAC_CCD[_NEGATIVE];
1128 }
1129 } else
1130 ps->Shade.pCcdDac = &pDAC_CCD[_REFLECTION];
1131
1132 /* as we now have the correct init function, call it */
1133 p12ccdInitFunc( ps );
1134
1135 DBG( DBG_IO, "Programming DAC (%u regs)\n", ps->Device.wNumDACRegs );
1136
1137 for(w = 0; w < ps->Device.wNumDACRegs; w++ ) {
1138
1139 DBG( DBG_IO, "[0x%02x] = 0x%02x\n", ps->Device.pDACRegisters[w].bReg,
1140 ps->Device.pDACRegisters[w].bParam );
1141
1142 IODataRegisterToDAC( ps, ps->Device.pDACRegisters[w].bReg,
1143 ps->Device.pDACRegisters[w].bParam );
1144 }
1145 }
1146
1147 /* END PLUSTEK-PP_P12CCD.C ..................................................*/
1148