1141cc406Sopenharmony_ci/* @file u12-ccd.c
2141cc406Sopenharmony_ci * @brief here we have the whole code to initialize the CCD and DAC stuff
3141cc406Sopenharmony_ci *
4141cc406Sopenharmony_ci * based on sources acquired from Plustek Inc.
5141cc406Sopenharmony_ci * Copyright (c) 2003-2004 Gerhard Jaeger <gerhard@gjaeger.de>
6141cc406Sopenharmony_ci *
7141cc406Sopenharmony_ci * History:
8141cc406Sopenharmony_ci * - 0.01 - initial version
9141cc406Sopenharmony_ci * - 0.02 - no changes
10141cc406Sopenharmony_ci * .
11141cc406Sopenharmony_ci * <hr>
12141cc406Sopenharmony_ci * This file is part of the SANE package.
13141cc406Sopenharmony_ci *
14141cc406Sopenharmony_ci * This program is free software; you can redistribute it and/or
15141cc406Sopenharmony_ci * modify it under the terms of the GNU General Public License as
16141cc406Sopenharmony_ci * published by the Free Software Foundation; either version 2 of the
17141cc406Sopenharmony_ci * License, or (at your option) any later version.
18141cc406Sopenharmony_ci *
19141cc406Sopenharmony_ci * This program is distributed in the hope that it will be useful, but
20141cc406Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of
21141cc406Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22141cc406Sopenharmony_ci * General Public License for more details.
23141cc406Sopenharmony_ci *
24141cc406Sopenharmony_ci * You should have received a copy of the GNU General Public License
25141cc406Sopenharmony_ci * along with this program.  If not, see <https://www.gnu.org/licenses/>.
26141cc406Sopenharmony_ci *
27141cc406Sopenharmony_ci * As a special exception, the authors of SANE give permission for
28141cc406Sopenharmony_ci * additional uses of the libraries contained in this release of SANE.
29141cc406Sopenharmony_ci *
30141cc406Sopenharmony_ci * The exception is that, if you link a SANE library with other files
31141cc406Sopenharmony_ci * to produce an executable, this does not by itself cause the
32141cc406Sopenharmony_ci * resulting executable to be covered by the GNU General Public
33141cc406Sopenharmony_ci * License.  Your use of that executable is in no way restricted on
34141cc406Sopenharmony_ci * account of linking the SANE library code into it.
35141cc406Sopenharmony_ci *
36141cc406Sopenharmony_ci * This exception does not, however, invalidate any other reasons why
37141cc406Sopenharmony_ci * the executable file might be covered by the GNU General Public
38141cc406Sopenharmony_ci * License.
39141cc406Sopenharmony_ci *
40141cc406Sopenharmony_ci * If you submit changes to SANE to the maintainers to be included in
41141cc406Sopenharmony_ci * a subsequent release, you agree by submitting the changes that
42141cc406Sopenharmony_ci * those changes may be distributed with this exception intact.
43141cc406Sopenharmony_ci *
44141cc406Sopenharmony_ci * If you write modifications of your own for SANE, it is your choice
45141cc406Sopenharmony_ci * whether to permit this exception to apply to your modifications.
46141cc406Sopenharmony_ci * If you do not wish that, delete this exception notice.
47141cc406Sopenharmony_ci * <hr>
48141cc406Sopenharmony_ci */
49141cc406Sopenharmony_ci
50141cc406Sopenharmony_ci/*************************** some definitions ********************************/
51141cc406Sopenharmony_ci
52141cc406Sopenharmony_ci#define _REFLECTION     0
53141cc406Sopenharmony_ci#define _TRANSPARENCY   1
54141cc406Sopenharmony_ci#define _NEGATIVE       2
55141cc406Sopenharmony_ci
56141cc406Sopenharmony_ci#define _NUM_OF_CCDREGS_W8143    25
57141cc406Sopenharmony_ci#define _NUM_OF_DACREGS_W8143    10
58141cc406Sopenharmony_ci
59141cc406Sopenharmony_ci#define _NUM_OF_CCDREGS_S1224    29
60141cc406Sopenharmony_ci#define _NUM_OF_DACREGS_S1224    7
61141cc406Sopenharmony_ci
62141cc406Sopenharmony_ci#define _NUM_OF_CCDREGS_S8531    29
63141cc406Sopenharmony_ci#define _NUM_OF_DACREGS_S8531    9
64141cc406Sopenharmony_ci
65141cc406Sopenharmony_ci/*************************** some local vars *********************************/
66141cc406Sopenharmony_ci
67141cc406Sopenharmony_cistatic pFnVoid u12ccd_InitFunc = NULL;
68141cc406Sopenharmony_ci
69141cc406Sopenharmony_cistatic RegDef W3797CCDParams[4][_NUM_OF_CCDREGS_W8143] = {
70141cc406Sopenharmony_ci    {
71141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x2a}, {0x3a, 0x0a}, {0x3b, 0x37},
72141cc406Sopenharmony_ci        {0x3c, 0x16}, {0x41, 0x0e}, {0x42, 0x90}, {0x43, 0x01},
73141cc406Sopenharmony_ci        {0x44, 0x27}, {0x45, 0x27}, {0x46, 0x01}, {0x47, 0x03},
74141cc406Sopenharmony_ci        {0x48, 0x27}, {0x49, 0x2f}, {0x4a, 0x09}, {0x4b, 0x03},
75141cc406Sopenharmony_ci        {0x4c, 0x07}, {0x4d, 0x06}, {0x4e, 0x06}, {0x67, 0x00},
76141cc406Sopenharmony_ci        {0x50, 0x08}, {0x51, 0x0e}, {0x52, 0x0c}, {0x53, 0x0b},
77141cc406Sopenharmony_ci        {0xf0, 0x00}
78141cc406Sopenharmony_ci    }, {
79141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x3d}, {0x3a, 0x04}, {0x3b, 0x46},
80141cc406Sopenharmony_ci        {0x3c, 0x06}, {0x41, 0x1f}, {0x42, 0x8c}, {0x43, 0x01},
81141cc406Sopenharmony_ci        {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf2}, {0x47, 0x02},
82141cc406Sopenharmony_ci        {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x00},
83141cc406Sopenharmony_ci        {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x0e}, {0x67, 0x00},
84141cc406Sopenharmony_ci        {0x50, 0x01}, {0x51, 0x06}, {0x52, 0x09}, {0x53, 0x0b},
85141cc406Sopenharmony_ci        {0xf0, 0x00}
86141cc406Sopenharmony_ci    }, {
87141cc406Sopenharmony_ci        {0x2c, 0x00}, {0x39, 0x16}, {0x3a, 0x03}, {0x3b, 0x1f},
88141cc406Sopenharmony_ci        {0x3c, 0x07}, {0x41, 0x04}, {0x42, 0x1e}, {0x43, 0x01},
89141cc406Sopenharmony_ci        {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x02},
90141cc406Sopenharmony_ci        {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xf9}, {0x4b, 0x04},
91141cc406Sopenharmony_ci        {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x03}, {0x67, 0x00},
92141cc406Sopenharmony_ci        {0x50, 0x06}, {0x51, 0x03}, {0x52, 0x09}, {0x53, 0x0b},
93141cc406Sopenharmony_ci        {0xf0, 0x00}
94141cc406Sopenharmony_ci    }, {
95141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x18}, {0x3a, 0x04}, {0x3b, 0x1d},
96141cc406Sopenharmony_ci        {0x3c, 0x03}, {0x41, 0x0c}, {0x42, 0x84}, {0x43, 0x03},
97141cc406Sopenharmony_ci        {0x44, 0x0a}, {0x45, 0x08}, {0x46, 0xfa}, {0x47, 0x04},
98141cc406Sopenharmony_ci        {0x48, 0x0a}, {0x49, 0x08}, {0x4a, 0xf2}, {0x4b, 0x02},
99141cc406Sopenharmony_ci        {0x4c, 0x03}, {0x4d, 0x02}, {0x4e, 0x0e}, {0x67, 0x00},
100141cc406Sopenharmony_ci        {0x50, 0x00}, {0x51, 0x09}, {0x52, 0x03}, {0x53, 0x03},
101141cc406Sopenharmony_ci        {0xf0, 0x00}
102141cc406Sopenharmony_ci    }
103141cc406Sopenharmony_ci};
104141cc406Sopenharmony_ci
105141cc406Sopenharmony_cistatic RegDef W3799CCDParams[4][_NUM_OF_CCDREGS_W8143] = {
106141cc406Sopenharmony_ci    {
107141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x2c}, {0x3a, 0x05}, {0x3b, 0x3c},
108141cc406Sopenharmony_ci        {0x3c, 0x0e}, {0x41, 0x0e}, {0x42, 0x90}, {0x43, 0x01},
109141cc406Sopenharmony_ci        {0x44, 0x27}, {0x45, 0x27}, {0x46, 0x01}, {0x47, 0x02},
110141cc406Sopenharmony_ci        {0x48, 0x27}, {0x49, 0x2f}, {0x4a, 0x09}, {0x4b, 0x05},
111141cc406Sopenharmony_ci        {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x06}, {0x67, 0x00},
112141cc406Sopenharmony_ci        {0x50, 0x08}, {0x51, 0x0d}, {0x52, 0x0c}, {0x53, 0x0b},
113141cc406Sopenharmony_ci        {0xf0, 0x00}
114141cc406Sopenharmony_ci    }, {
115141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x3d}, {0x3a, 0x04}, {0x3b, 0x46},
116141cc406Sopenharmony_ci        {0x3c, 0x06}, {0x41, 0x1f}, {0x42, 0x8c}, {0x43, 0x01},
117141cc406Sopenharmony_ci        {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf2}, {0x47, 0x01},
118141cc406Sopenharmony_ci        {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x00},
119141cc406Sopenharmony_ci        {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x0e}, {0x67, 0x00},
120141cc406Sopenharmony_ci        {0x50, 0x01}, {0x51, 0x06}, {0x52, 0x12}, {0x53, 0x0b},
121141cc406Sopenharmony_ci        {0xf0, 0x00}
122141cc406Sopenharmony_ci    }, {
123141cc406Sopenharmony_ci        {0x2c, 0x00}, {0x39, 0x16}, {0x3a, 0x02}, {0x3b, 0x1a},
124141cc406Sopenharmony_ci        {0x3c, 0x05}, {0x41, 0x04}, {0x42, 0x1e}, {0x43, 0x01},
125141cc406Sopenharmony_ci        {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x01},
126141cc406Sopenharmony_ci        {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xf9}, {0x4b, 0x04},
127141cc406Sopenharmony_ci        {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x03}, {0x67, 0x00},
128141cc406Sopenharmony_ci        {0x50, 0x06}, {0x51, 0x03}, {0x52, 0x09}, {0x53, 0x0b},
129141cc406Sopenharmony_ci        {0xf0, 0x00}
130141cc406Sopenharmony_ci    }, {
131141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x18}, {0x3a, 0x04}, {0x3b, 0x1d},
132141cc406Sopenharmony_ci        {0x3c, 0x03}, {0x41, 0x0c}, {0x42, 0x84}, {0x43, 0x03},
133141cc406Sopenharmony_ci        {0x44, 0x0a}, {0x45, 0x08}, {0x46, 0xfa}, {0x47, 0x03},
134141cc406Sopenharmony_ci        {0x48, 0x0a}, {0x49, 0x08}, {0x4a, 0xf2}, {0x4b, 0x02},
135141cc406Sopenharmony_ci        {0x4c, 0x03}, {0x4d, 0x02}, {0x4e, 0x0e}, {0x67, 0x00},
136141cc406Sopenharmony_ci        {0x50, 0x00}, {0x51, 0x09}, {0x52, 0x03}, {0x53, 0x03},
137141cc406Sopenharmony_ci        {0xf0, 0x00}
138141cc406Sopenharmony_ci    }
139141cc406Sopenharmony_ci};
140141cc406Sopenharmony_ci
141141cc406Sopenharmony_ci/* Genius ColorPage Vivid III */
142141cc406Sopenharmony_cistatic RegDef W548CCDParams[4][_NUM_OF_CCDREGS_W8143] = {
143141cc406Sopenharmony_ci    {
144141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x2c}, {0x3a, 0x05}, {0x3b, 0x3c},
145141cc406Sopenharmony_ci        {0x3c, 0x0e}, {0x41, 0x0e}, {0x42, 0x90}, {0x43, 0x01},
146141cc406Sopenharmony_ci        {0x44, 0x27}, {0x45, 0x27}, {0x46, 0x01}, {0x47, 0x02},
147141cc406Sopenharmony_ci        {0x48, 0x27}, {0x49, 0x2f}, {0x4a, 0x09}, {0x4b, 0x05},
148141cc406Sopenharmony_ci        {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x06}, {0x67, 0x00},
149141cc406Sopenharmony_ci        {0x50, 0x08}, {0x51, 0x0d}, {0x52, 0x0c}, {0x53, 0x0b},
150141cc406Sopenharmony_ci        {0xf0, 0x00}
151141cc406Sopenharmony_ci    }, {
152141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x3d}, {0x3a, 0x04}, {0x3b, 0x46},
153141cc406Sopenharmony_ci        {0x3c, 0x06}, {0x41, 0x1f}, {0x42, 0x8c}, {0x43, 0x01},
154141cc406Sopenharmony_ci        {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf2}, {0x47, 0x01},
155141cc406Sopenharmony_ci        {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x00},
156141cc406Sopenharmony_ci        {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x0e}, {0x67, 0x00},
157141cc406Sopenharmony_ci        {0x50, 0x01}, {0x51, 0x06}, {0x52, 0x12}, {0x53, 0x0b},
158141cc406Sopenharmony_ci        {0xf0, 0x00}
159141cc406Sopenharmony_ci    }, {
160141cc406Sopenharmony_ci        {0x2c, 0x00}, {0x39, 0x16}, {0x3a, 0x02}, {0x3b, 0x1a},
161141cc406Sopenharmony_ci        {0x3c, 0x05}, {0x41, 0x04}, {0x42, 0x1e}, {0x43, 0x01},
162141cc406Sopenharmony_ci        {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x01},
163141cc406Sopenharmony_ci        {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xf9}, {0x4b, 0x04},
164141cc406Sopenharmony_ci        {0x4c, 0x07}, {0x4d, 0x05}, {0x4e, 0x03}, {0x67, 0x00},
165141cc406Sopenharmony_ci        {0x50, 0x06}, {0x51, 0x03}, {0x52, 0x09}, {0x53, 0x0b},
166141cc406Sopenharmony_ci        {0xf0, 0x00}
167141cc406Sopenharmony_ci    }, {
168141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x18}, {0x3a, 0x04}, {0x3b, 0x1d},
169141cc406Sopenharmony_ci        {0x3c, 0x03}, {0x41, 0x0c}, {0x42, 0x84}, {0x43, 0x03},
170141cc406Sopenharmony_ci        {0x44, 0x0a}, {0x45, 0x08}, {0x46, 0xfa}, {0x47, 0x03},
171141cc406Sopenharmony_ci        {0x48, 0x0a}, {0x49, 0x08}, {0x4a, 0xf2}, {0x4b, 0x02},
172141cc406Sopenharmony_ci        {0x4c, 0x03}, {0x4d, 0x02}, {0x4e, 0x0e}, {0x67, 0x00},
173141cc406Sopenharmony_ci        {0x50, 0x00}, {0x51, 0x09}, {0x52, 0x03}, {0x53, 0x03},
174141cc406Sopenharmony_ci        {0xf0, 0x00}
175141cc406Sopenharmony_ci    }
176141cc406Sopenharmony_ci};
177141cc406Sopenharmony_ci
178141cc406Sopenharmony_cistatic RegDef S3797CCDParams[4][_NUM_OF_CCDREGS_S1224] = {
179141cc406Sopenharmony_ci    {
180141cc406Sopenharmony_ci        {0x2c, 0x00}, {0x39, 0x2a}, {0x3a, 0x0a}, {0x3b, 0x37},
181141cc406Sopenharmony_ci        {0x3c, 0x16}, {0x41, 0x2c}, {0x42, 0x9f}, {0x43, 0x01},
182141cc406Sopenharmony_ci        {0x44, 0x27}, {0x45, 0x27}, {0x46, 0x01}, {0x47, 0x03},
183141cc406Sopenharmony_ci        {0x48, 0x27}, {0x49, 0x27}, {0x4a, 0x09}, {0x4b, 0x0b},
184141cc406Sopenharmony_ci        {0x4c, 0x06}, {0x4d, 0x06}, {0x4e, 0x0b}, {0x50, 0x13},
185141cc406Sopenharmony_ci        {0x51, 0x06}, {0x52, 0x06}, {0x53, 0x0b}, {0x67, 0x00},
186141cc406Sopenharmony_ci        {0x6f, 0x20}, {0x70, 0x06}, {0x60, 0x07}, {0x61, 0x9f},
187141cc406Sopenharmony_ci        {0x65, 0x01}
188141cc406Sopenharmony_ci    }, {
189141cc406Sopenharmony_ci        {0x2c, 0x00}, {0x39, 0x3d}, {0x3a, 0x06}, {0x3b, 0x46},
190141cc406Sopenharmony_ci        {0x3c, 0x06}, {0x41, 0x3d}, {0x42, 0x92}, {0x43, 0x01},
191141cc406Sopenharmony_ci        {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf2}, {0x47, 0x02},
192141cc406Sopenharmony_ci        {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x1b},
193141cc406Sopenharmony_ci        {0x4c, 0x06}, {0x4d, 0x06}, {0x4e, 0x0b}, {0x50, 0x23},
194141cc406Sopenharmony_ci        {0x51, 0x06}, {0x52, 0x06}, {0x53, 0x0b}, {0x67, 0x00},
195141cc406Sopenharmony_ci        {0x6f, 0x30}, {0x70, 0x06}, {0x60, 0x17}, {0x61, 0x9f},
196141cc406Sopenharmony_ci        {0x65, 0x01}
197141cc406Sopenharmony_ci    }, {
198141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x16}, {0x3a, 0x03}, {0x3b, 0x1f},
199141cc406Sopenharmony_ci        {0x3c, 0x07}, {0x41, 0x1c}, {0x42, 0x99}, {0x43, 0x01},
200141cc406Sopenharmony_ci        {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x02},
201141cc406Sopenharmony_ci        {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x09},
202141cc406Sopenharmony_ci        {0x4c, 0x13}, {0x4d, 0x14}, {0x4e, 0x09}, {0x50, 0x09},
203141cc406Sopenharmony_ci        {0x51, 0x14}, {0x52, 0x13}, {0x53, 0x01}, {0x67, 0x00},
204141cc406Sopenharmony_ci        {0x6f, 0xff}, {0x70, 0x7f}, {0x60, 0x04}, {0x61, 0x8f},
205141cc406Sopenharmony_ci        {0x65, 0x01}
206141cc406Sopenharmony_ci    }, {
207141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x16}, {0x3a, 0x03}, {0x3b, 0x1f},
208141cc406Sopenharmony_ci        {0x3c, 0x07}, {0x41, 0x1c}, {0x42, 0x99}, {0x43, 0x01},
209141cc406Sopenharmony_ci        {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x02},
210141cc406Sopenharmony_ci        {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x09},
211141cc406Sopenharmony_ci        {0x4c, 0x13}, {0x4d, 0x14}, {0x4e, 0x09}, {0x50, 0x09},
212141cc406Sopenharmony_ci        {0x51, 0x14}, {0x52, 0x13}, {0x53, 0x01}, {0x67, 0x00},
213141cc406Sopenharmony_ci        {0x6f, 0xff}, {0x70, 0x7f}, {0x60, 0x04}, {0x61, 0x8f},
214141cc406Sopenharmony_ci        {0x65, 0x01}
215141cc406Sopenharmony_ci    }
216141cc406Sopenharmony_ci};
217141cc406Sopenharmony_ci
218141cc406Sopenharmony_cistatic RegDef S3799CCDParams[4][_NUM_OF_CCDREGS_S1224] = {
219141cc406Sopenharmony_ci    {
220141cc406Sopenharmony_ci        {0x2c, 0x00}, {0x39, 0x2a}, {0x3a, 0x0a}, {0x3b, 0x37},
221141cc406Sopenharmony_ci        {0x3c, 0x16}, {0x41, 0x2c}, {0x42, 0x8f}, {0x43, 0x01},
222141cc406Sopenharmony_ci	    {0x44, 0x27}, {0x45, 0x27}, {0x46, 0x01}, {0x47, 0x01},
223141cc406Sopenharmony_ci	    {0x48, 0x27}, {0x49, 0x27}, {0x4a, 0x09}, {0x4b, 0x0b},
224141cc406Sopenharmony_ci	    {0x4c, 0x06}, {0x4d, 0x06}, {0x4e, 0x0b}, {0x50, 0x13},
225141cc406Sopenharmony_ci	    {0x51, 0x06}, {0x52, 0x06}, {0x53, 0x0b}, {0x67, 0x00},
226141cc406Sopenharmony_ci	    {0x6f, 0x20}, {0x70, 0x06}, {0x60, 0x07}, {0x61, 0x9f},
227141cc406Sopenharmony_ci	    {0x65, 0x01}
228141cc406Sopenharmony_ci    }, {
229141cc406Sopenharmony_ci        {0x2c, 0x00}, {0x39, 0x3d}, {0x3a, 0x06}, {0x3b, 0x46},
230141cc406Sopenharmony_ci	    {0x3c, 0x06}, {0x41, 0x3d}, {0x42, 0x92}, {0x43, 0x01},
231141cc406Sopenharmony_ci	    {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf2}, {0x47, 0x01},
232141cc406Sopenharmony_ci	    {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x1b},
233141cc406Sopenharmony_ci	    {0x4c, 0x06}, {0x4d, 0x06}, {0x4e, 0x0b}, {0x50, 0x23},
234141cc406Sopenharmony_ci	    {0x51, 0x06}, {0x52, 0x06}, {0x53, 0x0b}, {0x67, 0x00},
235141cc406Sopenharmony_ci	    {0x6f, 0x30}, {0x70, 0x06}, {0x60, 0x17}, {0x61, 0x9f},
236141cc406Sopenharmony_ci	    {0x65, 0x01}
237141cc406Sopenharmony_ci    }, {
238141cc406Sopenharmony_ci        {0x2c, 0x02}, {0x39, 0x16}, {0x3a, 0x03}, {0x3b, 0x1f},
239141cc406Sopenharmony_ci	    {0x3c, 0x07}, {0x41, 0x1c}, {0x42, 0x99}, {0x43, 0x01},
240141cc406Sopenharmony_ci	    {0x44, 0x13}, {0x45, 0x13}, {0x46, 0xf1}, {0x47, 0x01},
241141cc406Sopenharmony_ci	    {0x48, 0x13}, {0x49, 0x13}, {0x4a, 0xfa}, {0x4b, 0x09},
242141cc406Sopenharmony_ci	    {0x4c, 0x13}, {0x4d, 0x14}, {0x4e, 0x09}, {0x50, 0x09},
243141cc406Sopenharmony_ci	    {0x51, 0x14}, {0x52, 0x13}, {0x53, 0x01}, {0x67, 0x00},
244141cc406Sopenharmony_ci	    {0x6f, 0xff}, {0x70, 0x7f}, {0x60, 0x04}, {0x61, 0x8f},
245141cc406Sopenharmony_ci	    {0x65, 0x01}
246141cc406Sopenharmony_ci    }, {
247141cc406Sopenharmony_ci        {0x2c, 0x00}, {0x39, 0x16}, {0x3a, 0x03}, {0x3b, 0x1f},
248141cc406Sopenharmony_ci	    {0x3c, 0x07}, {0x41, 0x1c}, {0x42, 0x99}, {0x43, 0x03},
249141cc406Sopenharmony_ci	    {0x44, 0x0a}, {0x45, 0x08}, {0x46, 0xfa}, {0x47, 0x03},
250141cc406Sopenharmony_ci	    {0x48, 0x0a}, {0x49, 0x08}, {0x4a, 0xf2}, {0x4b, 0x02},
251141cc406Sopenharmony_ci	    {0x4c, 0x03}, {0x4d, 0x02}, {0x4e, 0x0e}, {0x50, 0x00},
252141cc406Sopenharmony_ci	    {0x51, 0x09}, {0x52, 0x03}, {0x53, 0x03}, {0x67, 0x00},
253141cc406Sopenharmony_ci	    {0x6f, 0xff}, {0x70, 0x7f}, {0x60, 0x04}, {0x61, 0x8f},
254141cc406Sopenharmony_ci	    {0x65, 0x01}
255141cc406Sopenharmony_ci    }
256141cc406Sopenharmony_ci};
257141cc406Sopenharmony_ci
258141cc406Sopenharmony_cistatic RegDef WolfsonDAC8143[_NUM_OF_DACREGS_W8143] = {
259141cc406Sopenharmony_ci    {0x01, 0x01}, {0x02, 0x04}, {0x03, 0x42}, {0x05, 0x10}, {0x20, 0xd0},
260141cc406Sopenharmony_ci    {0x21, 0xd0}, {0x22, 0xd0}, {0x24, 0x00}, {0x25, 0x00},	{0x26, 0x00}
261141cc406Sopenharmony_ci};
262141cc406Sopenharmony_ci
263141cc406Sopenharmony_cistatic RegDef SamsungDAC8531[_NUM_OF_DACREGS_S8531] = {
264141cc406Sopenharmony_ci    {0x00, 0x51}, {0x02, 0x01}, {0x01, 0x80},
265141cc406Sopenharmony_ci    {0x00, 0x55}, {0x02, 0x01}, {0x01, 0x80},
266141cc406Sopenharmony_ci    {0x00, 0x59}, {0x02, 0x01}, {0x01, 0x80}
267141cc406Sopenharmony_ci};
268141cc406Sopenharmony_ci
269141cc406Sopenharmony_cistatic RegDef SamsungDAC1224[_NUM_OF_DACREGS_S1224] ={
270141cc406Sopenharmony_ci    {0x00, 0x00}, {0x01, 0x80}, {0x02, 0x80},
271141cc406Sopenharmony_ci    {0x03, 0x80}, {0x04, 0x06}, {0x05, 0x06}, {0x06, 0x06}
272141cc406Sopenharmony_ci};
273141cc406Sopenharmony_ci
274141cc406Sopenharmony_cistatic ShadingVarDef ShadingVar3797[3] = {
275141cc406Sopenharmony_ci    {
276141cc406Sopenharmony_ci        {{99, 100, 94}}, {{0x30, 0x30, 0x30}},
277141cc406Sopenharmony_ci        {{0x20, 0x20, 0x20}}, {{0x04, 0x00, 0x00}}, {{0xcc, 0xcc, 0xcc}}, 0
278141cc406Sopenharmony_ci    }, {
279141cc406Sopenharmony_ci        {{100, 90, 100}}, {{0x30, 0x30, 0x30}},
280141cc406Sopenharmony_ci        {{0x20, 0x20, 0x20}}, {{0x10, 0x10, 0x10}}, {{0xcc, 0xcc, 0xcc}}, 0
281141cc406Sopenharmony_ci    }, {
282141cc406Sopenharmony_ci        {{90, 90, 90}}, {{0x30, 0x30, 0x30}}, {{0x20, 0x20, 0x20}},
283141cc406Sopenharmony_ci        {{0x10, 0x10, 0x10}}, {{0x80, 0x80, 0x80}}, 0
284141cc406Sopenharmony_ci    }
285141cc406Sopenharmony_ci};
286141cc406Sopenharmony_ci
287141cc406Sopenharmony_cistatic ShadingVarDef ShadingVar3799[3] = {
288141cc406Sopenharmony_ci    {
289141cc406Sopenharmony_ci        {{100, 97, 92}}, {{0x90, 0xe0, 0x80}},
290141cc406Sopenharmony_ci        {{0x70, 0xc0, 0x60}}, {{0x90, 0x34, 0x3c}}, {{0x80, 0x80, 0x80}}, 0
291141cc406Sopenharmony_ci    }, {
292141cc406Sopenharmony_ci        {{75, 75, 75}}, {{0x30, 0x30, 0x30}},
293141cc406Sopenharmony_ci        {{0x10, 0x10, 0x10}}, {{0x20, 0x20, 0x20}}, {{0x80, 0x80, 0x80}}, 0
294141cc406Sopenharmony_ci    }, {
295141cc406Sopenharmony_ci        {{80, 75, 64}}, {{0x30, 0x30, 0x30}},
296141cc406Sopenharmony_ci        {{0x20, 0x20, 0x20}}, {{0x10, 0x10, 0x10}}, {{0x80, 0x80, 0x80}}, 0
297141cc406Sopenharmony_ci    }
298141cc406Sopenharmony_ci};
299141cc406Sopenharmony_ci
300141cc406Sopenharmony_ci/* Genius ColorPage Vivid III */
301141cc406Sopenharmony_cistatic ShadingVarDef ShadingVar548[3] = {
302141cc406Sopenharmony_ci    {
303141cc406Sopenharmony_ci        {{100, 97, 92}}, {{0x90, 0xe0, 0x80}},
304141cc406Sopenharmony_ci        {{0x70, 0xc0, 0x60}}, {{0x90, 0x34, 0x3c}}, {{0x80, 0x80, 0x80}}, 0
305141cc406Sopenharmony_ci    }, {
306141cc406Sopenharmony_ci        {{75, 75, 75}}, {{0x30, 0x30, 0x30}},
307141cc406Sopenharmony_ci        {{0x10, 0x10, 0x10}}, {{0x20, 0x20, 0x20}}, {{0x80, 0x80, 0x80}}, 0
308141cc406Sopenharmony_ci    }, {
309141cc406Sopenharmony_ci        {{80, 75, 64}}, {{0x30, 0x30, 0x30}},
310141cc406Sopenharmony_ci        {{0x20, 0x20, 0x20}}, {{0x10, 0x10, 0x10}}, {{0x80, 0x80, 0x80}}, 0
311141cc406Sopenharmony_ci    }
312141cc406Sopenharmony_ci};
313141cc406Sopenharmony_ci
314141cc406Sopenharmony_cistatic ShadingVarDef ShadingVar3777[3] = {
315141cc406Sopenharmony_ci    {
316141cc406Sopenharmony_ci        {{100, 100, 100}}, {{0x90, 0xe0, 0x80}},
317141cc406Sopenharmony_ci        {{0x70, 0xc0, 0x60}}, {{0x90, 0x34, 0x3c}}, {{0x80, 0x80, 0x80}}, 0
318141cc406Sopenharmony_ci    }, {
319141cc406Sopenharmony_ci        {{75, 75, 75}}, {{0x30, 0x30, 0x30}},
320141cc406Sopenharmony_ci        {{0x10, 0x10, 0x10}}, {{0x20, 0x20, 0x20}}, {{0x80, 0x80, 0x80}}, 0
321141cc406Sopenharmony_ci    }, {
322141cc406Sopenharmony_ci        {{80, 75, 64}}, {{0x30, 0x30, 0x30}},
323141cc406Sopenharmony_ci        {{0x20, 0x20, 0x20}}, {{0x10, 0x10, 0x10}}, {{0x80, 0x80, 0x80}}, 0
324141cc406Sopenharmony_ci    }
325141cc406Sopenharmony_ci};
326141cc406Sopenharmony_ci
327141cc406Sopenharmony_ci/*************************** local functions *********************************/
328141cc406Sopenharmony_ci
329141cc406Sopenharmony_ci/**
330141cc406Sopenharmony_ci */
331141cc406Sopenharmony_cistatic void fnCCDInitWolfson3797( U12_Device *dev )
332141cc406Sopenharmony_ci{
333141cc406Sopenharmony_ci	if( dev->shade.intermediate & _ScanMode_Mono )
334141cc406Sopenharmony_ci		dev->shade.pCcdDac->DarkDAC.Colors.Green = 0xcc;
335141cc406Sopenharmony_ci	else
336141cc406Sopenharmony_ci		if( dev->shade.intermediate & _ScanMode_AverageOut)
337141cc406Sopenharmony_ci			dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x68;
338141cc406Sopenharmony_ci		else
339141cc406Sopenharmony_ci			dev->shade.pCcdDac->DarkDAC.Colors.Green = 0xa0;
340141cc406Sopenharmony_ci
341141cc406Sopenharmony_ci	if((dev->shade.intermediate & _ScanMode_AverageOut) ||
342141cc406Sopenharmony_ci		                       (dev->DataInf.dwScanFlag & _SCANDEF_Negative)) {
343141cc406Sopenharmony_ci		WolfsonDAC8143[3].val = 0x12;
344141cc406Sopenharmony_ci	} else {
345141cc406Sopenharmony_ci		WolfsonDAC8143[3].val = 0x10;
346141cc406Sopenharmony_ci	}
347141cc406Sopenharmony_ci}
348141cc406Sopenharmony_ci
349141cc406Sopenharmony_ci/**
350141cc406Sopenharmony_ci */
351141cc406Sopenharmony_cistatic void fnCCDInitSamsung3797( U12_Device *dev )
352141cc406Sopenharmony_ci{
353141cc406Sopenharmony_ci	if(!(dev->DataInf.dwScanFlag & _SCANDEF_TPA)) {
354141cc406Sopenharmony_ci
355141cc406Sopenharmony_ci		if (!(dev->shade.intermediate & _ScanMode_AverageOut)) {
356141cc406Sopenharmony_ci
357141cc406Sopenharmony_ci			if( dev->PCBID == _OPTICWORKS2000 ) {
358141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Red = 102;
359141cc406Sopenharmony_ci	        	dev->shade.pCcdDac->GainResize.Colors.Green = 102;
360141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Blue = 97;
361141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x40;
362141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x40;
363141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x40;
364141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x48;
365141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x40;
366141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x40;
367141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x38;
368141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x30;
369141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x30;
370141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x48;
371141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x38;
372141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x40;
373141cc406Sopenharmony_ci	        } else {
374141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Red = 99;
375141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Green = 101;
376141cc406Sopenharmony_ci		        dev->shade.pCcdDac->GainResize.Colors.Blue = 94;
377141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x40;
378141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x40;
379141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x40;
380141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x30;
381141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
382141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
383141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x20;
384141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x20;
385141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x20;
386141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x04;
387141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x00;
388141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x00;
389141cc406Sopenharmony_ci	        }
390141cc406Sopenharmony_ci    	} else {
391141cc406Sopenharmony_ci            if( dev->PCBID == _OPTICWORKS2000 ) {
392141cc406Sopenharmony_ci    	    	dev->shade.pCcdDac->GainResize.Colors.Red = 100;
393141cc406Sopenharmony_ci    	    	dev->shade.pCcdDac->GainResize.Colors.Green = 100;
394141cc406Sopenharmony_ci	    	    dev->shade.pCcdDac->GainResize.Colors.Blue = 96;
395141cc406Sopenharmony_ci    	    	dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x30;
396141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x30;
397141cc406Sopenharmony_ci	        	dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x30;
398141cc406Sopenharmony_ci    	    	dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x48;
399141cc406Sopenharmony_ci    	    	dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x48;
400141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x48;
401141cc406Sopenharmony_ci	        	dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x38;
402141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x38;
403141cc406Sopenharmony_ci	        	dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x38;
404141cc406Sopenharmony_ci    		    dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x48;
405141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x48;
406141cc406Sopenharmony_ci    	    	dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x48;
407141cc406Sopenharmony_ci	        } else {
408141cc406Sopenharmony_ci    	    	dev->shade.pCcdDac->GainResize.Colors.Red = 100;   /*  98 */
409141cc406Sopenharmony_ci    	    	dev->shade.pCcdDac->GainResize.Colors.Green = 103; /* 106 */
410141cc406Sopenharmony_ci	    	    dev->shade.pCcdDac->GainResize.Colors.Blue = 96;	  /*  96 */
411141cc406Sopenharmony_ci    	    	dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x20;
412141cc406Sopenharmony_ci	    	    dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x10;
413141cc406Sopenharmony_ci    		    dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x10;
414141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x110;
415141cc406Sopenharmony_ci	        	dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x1f0;
416141cc406Sopenharmony_ci    		    dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x190;
417141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x100;
418141cc406Sopenharmony_ci	        	dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x1e0;
419141cc406Sopenharmony_ci    		    dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x180;
420141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x20;
421141cc406Sopenharmony_ci	        	dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x10;
422141cc406Sopenharmony_ci    		    dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x20;
423141cc406Sopenharmony_ci	        }
424141cc406Sopenharmony_ci       	}
425141cc406Sopenharmony_ci    }
426141cc406Sopenharmony_ci}
427141cc406Sopenharmony_ci
428141cc406Sopenharmony_ci/**
429141cc406Sopenharmony_ci */
430141cc406Sopenharmony_cistatic void fnCCDInitWolfson3799( U12_Device *dev )
431141cc406Sopenharmony_ci{
432141cc406Sopenharmony_ci    if(!(dev->DataInf.dwScanFlag & _SCANDEF_Negative)) {
433141cc406Sopenharmony_ci
434141cc406Sopenharmony_ci        if (!(dev->shade.intermediate & _ScanMode_AverageOut)) {
435141cc406Sopenharmony_ci
436141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->GainResize.Colors.Red = 103;
437141cc406Sopenharmony_ci	        dev->shade.pCcdDac->GainResize.Colors.Green = 102;
438141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->GainResize.Colors.Blue = 99;
439141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkDAC.Colors.Red = 0xc8;
440141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkDAC.Colors.Green = 0xc8;
441141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0xc8;
442141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x48;
443141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
444141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
445141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x40;
446141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
447141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
448141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x48;
449141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x18;
450141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x2c;
451141cc406Sopenharmony_ci    	} else {
452141cc406Sopenharmony_ci	        dev->shade.pCcdDac->GainResize.Colors.Red = 100;
453141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->GainResize.Colors.Green = 98;
454141cc406Sopenharmony_ci	        dev->shade.pCcdDac->GainResize.Colors.Blue = 95;
455141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkDAC.Colors.Red = 0xd0;
456141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkDAC.Colors.Green = 0xd0;
457141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0xd0;
458141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x30;
459141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
460141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
461141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x28;
462141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
463141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
464141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x0;
465141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x0;
466141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x0;
467141cc406Sopenharmony_ci    	}
468141cc406Sopenharmony_ci    } else {
469141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x80;
470141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x80;
471141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x80;
472141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x28;
473141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x28;
474141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x28;
475141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x20;
476141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x20;
477141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x20;
478141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkOffSub.Colors.Red = -0x38;
479141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkOffSub.Colors.Green = -0x108;
480141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkOffSub.Colors.Blue = -0x1c8;
481141cc406Sopenharmony_ci    }
482141cc406Sopenharmony_ci}
483141cc406Sopenharmony_ci
484141cc406Sopenharmony_ci/**
485141cc406Sopenharmony_ci */
486141cc406Sopenharmony_cistatic void fnCCDInitWolfson548( U12_Device *dev )
487141cc406Sopenharmony_ci{
488141cc406Sopenharmony_ci    if (!(dev->shade.intermediate & _ScanMode_AverageOut)) {
489141cc406Sopenharmony_ci
490141cc406Sopenharmony_ci 	    dev->shade.pCcdDac->GainResize.Colors.Red   = 103;
491141cc406Sopenharmony_ci        dev->shade.pCcdDac->GainResize.Colors.Green = 102;
492141cc406Sopenharmony_ci   	    dev->shade.pCcdDac->GainResize.Colors.Blue  = 99;
493141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkDAC.Colors.Red      = 0xc8;
494141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkDAC.Colors.Green    = 0xc8;
495141cc406Sopenharmony_ci   	    dev->shade.pCcdDac->DarkDAC.Colors.Blue     = 0xc8;
496141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkCmpHi.Colors.Red    = 0x48;
497141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkCmpHi.Colors.Green  = 0x30;
498141cc406Sopenharmony_ci   	    dev->shade.pCcdDac->DarkCmpHi.Colors.Blue   = 0x30;
499141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkCmpLo.Colors.Red    = 0x40;
500141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkCmpLo.Colors.Green  = 0x28;
501141cc406Sopenharmony_ci   	    dev->shade.pCcdDac->DarkCmpLo.Colors.Blue   = 0x28;
502141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkOffSub.Colors.Red   = 0x48;
503141cc406Sopenharmony_ci   	    dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x18;
504141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkOffSub.Colors.Blue  = 0x2c;
505141cc406Sopenharmony_ci
506141cc406Sopenharmony_ci   	} else {
507141cc406Sopenharmony_ci        dev->shade.pCcdDac->GainResize.Colors.Red   = 100;
508141cc406Sopenharmony_ci   	    dev->shade.pCcdDac->GainResize.Colors.Green = 98;
509141cc406Sopenharmony_ci        dev->shade.pCcdDac->GainResize.Colors.Blue  = 95;
510141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkDAC.Colors.Red      = 0xd0;
511141cc406Sopenharmony_ci   	    dev->shade.pCcdDac->DarkDAC.Colors.Green    = 0xd0;
512141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkDAC.Colors.Blue     = 0xd0;
513141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkCmpHi.Colors.Red    = 0x30;
514141cc406Sopenharmony_ci   	    dev->shade.pCcdDac->DarkCmpHi.Colors.Green  = 0x30;
515141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkCmpHi.Colors.Blue   = 0x30;
516141cc406Sopenharmony_ci   	    dev->shade.pCcdDac->DarkCmpLo.Colors.Red    = 0x28;
517141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkCmpLo.Colors.Green  = 0x28;
518141cc406Sopenharmony_ci   	    dev->shade.pCcdDac->DarkCmpLo.Colors.Blue   = 0x28;
519141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkOffSub.Colors.Red   = 0x0;
520141cc406Sopenharmony_ci   	    dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x0;
521141cc406Sopenharmony_ci        dev->shade.pCcdDac->DarkOffSub.Colors.Blue  = 0x0;
522141cc406Sopenharmony_ci   	}
523141cc406Sopenharmony_ci}
524141cc406Sopenharmony_ci
525141cc406Sopenharmony_ci/**
526141cc406Sopenharmony_ci */
527141cc406Sopenharmony_cistatic void fnCCDInitSamsung3777( U12_Device *dev )
528141cc406Sopenharmony_ci{
529141cc406Sopenharmony_ci    if(!(dev->DataInf.dwScanFlag & _SCANDEF_Negative)) {
530141cc406Sopenharmony_ci
531141cc406Sopenharmony_ci        if (!(dev->shade.intermediate & _ScanMode_AverageOut)) {
532141cc406Sopenharmony_ci
533141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->GainResize.Colors.Red = 109;
534141cc406Sopenharmony_ci	        dev->shade.pCcdDac->GainResize.Colors.Green = 108;
535141cc406Sopenharmony_ci	        dev->shade.pCcdDac->GainResize.Colors.Blue = 105;
536141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x4a;
537141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x4a;
538141cc406Sopenharmony_ci            dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x4a;
539141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x3c;
540141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x38;
541141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x38;
542141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x28;
543141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x2c;
544141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
545141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x30;
546141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x30;
547141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x3C;
548141cc406Sopenharmony_ci    	} else {
549141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->GainResize.Colors.Red = 108;
550141cc406Sopenharmony_ci	        dev->shade.pCcdDac->GainResize.Colors.Green = 107;
551141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->GainResize.Colors.Blue = 104;
552141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x50;
553141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x50;
554141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x50;
555141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x40;
556141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x40;
557141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x40;
558141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x30;
559141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x30;
560141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x30;
561141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x20;
562141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x20;
563141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x20;
564141cc406Sopenharmony_ci	    }
565141cc406Sopenharmony_ci    } else {
566141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x80;
567141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x80;
568141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x80;
569141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x28;
570141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x28;
571141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x28;
572141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x20;
573141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x20;
574141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x20;
575141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkOffSub.Colors.Red = -0x38;
576141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkOffSub.Colors.Green = -0x108;
577141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkOffSub.Colors.Blue = -0x1c8;
578141cc406Sopenharmony_ci    }
579141cc406Sopenharmony_ci}
580141cc406Sopenharmony_ci
581141cc406Sopenharmony_ci/**
582141cc406Sopenharmony_ci */
583141cc406Sopenharmony_cistatic void fnCCDInitSamsung3799( U12_Device *dev )
584141cc406Sopenharmony_ci{
585141cc406Sopenharmony_ci    if(!(dev->DataInf.dwScanFlag & _SCANDEF_TPA)) {
586141cc406Sopenharmony_ci
587141cc406Sopenharmony_ci        if (!(dev->shade.intermediate & _ScanMode_AverageOut)) {
588141cc406Sopenharmony_ci
589141cc406Sopenharmony_ci    	    if( dev->PCBID == _SCANNER2Button ) {
590141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Red = 109;
591141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Green = 109;
592141cc406Sopenharmony_ci		        dev->shade.pCcdDac->GainResize.Colors.Blue = 105;
593141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x68;
594141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x68;
595141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x68;
596141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x30;
597141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
598141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
599141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x28;
600141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
601141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
602141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x24;    /* 0 */
603141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x20;  /* 0 */
604141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x1c;   /* 0 */
605141cc406Sopenharmony_ci    	    } else {
606141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Red = 98;
607141cc406Sopenharmony_ci		        dev->shade.pCcdDac->GainResize.Colors.Green = 97;
608141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Blue = 92;
609141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x90;
610141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x90;
611141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x90;
612141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0xc0;	    /* 0x90 */
613141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0xc0;   /* 0xe0 */
614141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0xc0;    /* 0x80 */
615141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0xb0;	    /* 0x70 */
616141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0xb0;   /* 0xc0 */
617141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0xb0;    /* 0x60 */
618141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x24;    /* 0x90 */
619141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x00;	/* 0x34 */
620141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x0c;	/* 0x3c */
621141cc406Sopenharmony_ci	        }
622141cc406Sopenharmony_ci    	} else {
623141cc406Sopenharmony_ci    	    if( dev->PCBID == _SCANNER2Button ) {
624141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Red = 107;
625141cc406Sopenharmony_ci		        dev->shade.pCcdDac->GainResize.Colors.Green = 106;
626141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Blue = 103;
627141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x48;
628141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x48;
629141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x48;
630141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x30;
631141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x30;
632141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x30;
633141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x28;
634141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
635141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x28;
636141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x28;    /* 0 */
637141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x18;  /* 0 */
638141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x20;   /* 0 */
639141cc406Sopenharmony_ci	        } else {
640141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Red = 104;
641141cc406Sopenharmony_ci		        dev->shade.pCcdDac->GainResize.Colors.Green = 107;
642141cc406Sopenharmony_ci        		dev->shade.pCcdDac->GainResize.Colors.Blue = 99;
643141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x30;	    /* 0x80 */
644141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x30;
645141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x30;	    /* 0x0a0 */
646141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x150;    /* 0x170 */
647141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x130;  /* 0x90  */
648141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x110;   /* 0x130 */
649141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x140;    /* 0x150 */
650141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x120;  /* 0x70  */
651141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x100;   /* 0x120 */
652141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0xF0;    /* 0x90  */
653141cc406Sopenharmony_ci		        dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0xD4;  /* 0x50  */
654141cc406Sopenharmony_ci        		dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0xCC;   /* 0x60  */
655141cc406Sopenharmony_ci	        }
656141cc406Sopenharmony_ci        }
657141cc406Sopenharmony_ci    }
658141cc406Sopenharmony_ci}
659141cc406Sopenharmony_ci
660141cc406Sopenharmony_ci/**
661141cc406Sopenharmony_ci */
662141cc406Sopenharmony_cistatic void fnCCDInitESIC3799( U12_Device *dev )
663141cc406Sopenharmony_ci{
664141cc406Sopenharmony_ci    if(!(dev->DataInf.dwScanFlag & _SCANDEF_Negative)) {
665141cc406Sopenharmony_ci
666141cc406Sopenharmony_ci        if (!(dev->shade.intermediate & _ScanMode_AverageOut)) {
667141cc406Sopenharmony_ci
668141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->GainResize.Colors.Red = 100;
669141cc406Sopenharmony_ci	        dev->shade.pCcdDac->GainResize.Colors.Green = 99;
670141cc406Sopenharmony_ci	        dev->shade.pCcdDac->GainResize.Colors.Blue = 94;
671141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkDAC.Colors.Red = 0xc8;
672141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkDAC.Colors.Green = 0xc8;
673141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0xc8;
674141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x58;
675141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x38;
676141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x48;
677141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x48;
678141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x28;
679141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x38;
680141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x58;
681141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0x38;
682141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0x48;
683141cc406Sopenharmony_ci    	} else {
684141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->GainResize.Colors.Red = 100;
685141cc406Sopenharmony_ci	        dev->shade.pCcdDac->GainResize.Colors.Green = 98;
686141cc406Sopenharmony_ci	        dev->shade.pCcdDac->GainResize.Colors.Blue = 93;
687141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkDAC.Colors.Red = 0xd0;
688141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkDAC.Colors.Green = 0xd0;
689141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0xd0;
690141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x108;
691141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0xf8;
692141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0xc8;
693141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x100;
694141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0xf0;
695141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0xc0;
696141cc406Sopenharmony_ci    	    dev->shade.pCcdDac->DarkOffSub.Colors.Red = 0x108;
697141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Green = 0xf8;
698141cc406Sopenharmony_ci	        dev->shade.pCcdDac->DarkOffSub.Colors.Blue = 0xc8;
699141cc406Sopenharmony_ci    	}
700141cc406Sopenharmony_ci    } else {
701141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkDAC.Colors.Red = 0x80;
702141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkDAC.Colors.Green = 0x80;
703141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkDAC.Colors.Blue = 0x80;
704141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkCmpHi.Colors.Red = 0x28;
705141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkCmpHi.Colors.Green = 0x28;
706141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkCmpHi.Colors.Blue = 0x28;
707141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkCmpLo.Colors.Red = 0x20;
708141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkCmpLo.Colors.Green = 0x20;
709141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkCmpLo.Colors.Blue = 0x20;
710141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkOffSub.Colors.Red = -0x38;
711141cc406Sopenharmony_ci    	dev->shade.pCcdDac->DarkOffSub.Colors.Green = -0x38;
712141cc406Sopenharmony_ci	    dev->shade.pCcdDac->DarkOffSub.Colors.Blue = -0x38;
713141cc406Sopenharmony_ci    }
714141cc406Sopenharmony_ci}
715141cc406Sopenharmony_ci
716141cc406Sopenharmony_ci/**
717141cc406Sopenharmony_ci */
718141cc406Sopenharmony_cistatic void
719141cc406Sopenharmony_cifnDarkOffsetWolfson3797( U12_Device *dev, ShadingVarDef *sTbl, u_long dwCh )
720141cc406Sopenharmony_ci{
721141cc406Sopenharmony_ci	if(( dev->shade.DarkOffset.wColors[dwCh] -=
722141cc406Sopenharmony_ci                sTbl->DarkOffSub.wColors[dwCh]) > 0xfff ) {
723141cc406Sopenharmony_ci		dev->shade.DarkOffset.wColors[dwCh] = 0;
724141cc406Sopenharmony_ci	}
725141cc406Sopenharmony_ci}
726141cc406Sopenharmony_ci
727141cc406Sopenharmony_ci/**
728141cc406Sopenharmony_ci */
729141cc406Sopenharmony_cistatic void
730141cc406Sopenharmony_cifnDarkOffsetSamsung3777( U12_Device *dev, ShadingVarDef *sTbl, u_long dwCh )
731141cc406Sopenharmony_ci{
732141cc406Sopenharmony_ci	dev->shade.DarkOffset.wColors[dwCh] += sTbl->DarkOffSub.wColors [dwCh];
733141cc406Sopenharmony_ci}
734141cc406Sopenharmony_ci
735141cc406Sopenharmony_ci/**
736141cc406Sopenharmony_ci */
737141cc406Sopenharmony_cistatic void
738141cc406Sopenharmony_cifnDarkOffsetSamsung3797( U12_Device *dev, ShadingVarDef *sTbl, u_long dwCh )
739141cc406Sopenharmony_ci{
740141cc406Sopenharmony_ci	if( dev->shade.DarkOffset.wColors[dwCh] > sTbl->DarkOffSub.wColors[dwCh] )
741141cc406Sopenharmony_ci		dev->shade.DarkOffset.wColors[dwCh] -= sTbl->DarkOffSub.wColors[dwCh];
742141cc406Sopenharmony_ci	else
743141cc406Sopenharmony_ci		dev->shade.DarkOffset.wColors[dwCh] = 0;
744141cc406Sopenharmony_ci}
745141cc406Sopenharmony_ci
746141cc406Sopenharmony_ci/**
747141cc406Sopenharmony_ci */
748141cc406Sopenharmony_cistatic void
749141cc406Sopenharmony_cifnDarkOffsetSamsung3799( U12_Device *dev, ShadingVarDef *sTbl, u_long dwCh )
750141cc406Sopenharmony_ci{
751141cc406Sopenharmony_ci	if( dev->shade.DarkOffset.wColors[dwCh] > sTbl->DarkOffSub.wColors[dwCh])
752141cc406Sopenharmony_ci		dev->shade.DarkOffset.wColors[dwCh] -= sTbl->DarkOffSub.wColors[dwCh];
753141cc406Sopenharmony_ci	else
754141cc406Sopenharmony_ci		dev->shade.DarkOffset.wColors[dwCh] = 0;
755141cc406Sopenharmony_ci}
756141cc406Sopenharmony_ci
757141cc406Sopenharmony_ci/**
758141cc406Sopenharmony_ci */
759141cc406Sopenharmony_cistatic void fnDACDarkWolfson( U12_Device *dev, ShadingVarDef *sTbl,
760141cc406Sopenharmony_ci                              u_long dwCh, u_short wDarkest )
761141cc406Sopenharmony_ci{
762141cc406Sopenharmony_ci	u_short w = dev->shade.DarkDAC.bColors[dwCh];
763141cc406Sopenharmony_ci
764141cc406Sopenharmony_ci	if( wDarkest > sTbl->DarkCmpHi.wColors[dwCh] ) {
765141cc406Sopenharmony_ci
766141cc406Sopenharmony_ci		wDarkest -= sTbl->DarkCmpHi.wColors[dwCh];
767141cc406Sopenharmony_ci		if( wDarkest > dev->shade.wDarkLevels)
768141cc406Sopenharmony_ci	        w += (u_short)wDarkest / dev->shade.wDarkLevels;
769141cc406Sopenharmony_ci		else
770141cc406Sopenharmony_ci			w++;
771141cc406Sopenharmony_ci
772141cc406Sopenharmony_ci		if (w > 0xff)
773141cc406Sopenharmony_ci			w = 0xff;
774141cc406Sopenharmony_ci
775141cc406Sopenharmony_ci		if(w != (u_short)dev->shade.DarkDAC.bColors[dwCh] ) {
776141cc406Sopenharmony_ci			dev->shade.DarkDAC.bColors[dwCh] = (SANE_Byte)w;
777141cc406Sopenharmony_ci			dev->shade.fStop                 = SANE_FALSE;
778141cc406Sopenharmony_ci		}
779141cc406Sopenharmony_ci	} else {
780141cc406Sopenharmony_ci		if((wDarkest < sTbl->DarkCmpLo.wColors[dwCh]) &&
781141cc406Sopenharmony_ci                                	        dev->shade.DarkDAC.bColors[dwCh]) {
782141cc406Sopenharmony_ci			if( wDarkest )
783141cc406Sopenharmony_ci				w = (u_short)dev->shade.DarkDAC.bColors[dwCh] - 2U;
784141cc406Sopenharmony_ci			else
785141cc406Sopenharmony_ci				w = (u_short)dev->shade.DarkDAC.bColors[dwCh] - dev->shade.wDarkLevels;
786141cc406Sopenharmony_ci
787141cc406Sopenharmony_ci			if ((short) w < 0)
788141cc406Sopenharmony_ci				w = 0;
789141cc406Sopenharmony_ci
790141cc406Sopenharmony_ci			if( w != (u_short)dev->shade.DarkDAC.bColors[dwCh] ) {
791141cc406Sopenharmony_ci				dev->shade.DarkDAC.bColors [dwCh] = (SANE_Byte)w;
792141cc406Sopenharmony_ci				dev->shade.fStop                  = SANE_FALSE;
793141cc406Sopenharmony_ci			}
794141cc406Sopenharmony_ci		}
795141cc406Sopenharmony_ci	}
796141cc406Sopenharmony_ci}
797141cc406Sopenharmony_ci
798141cc406Sopenharmony_ci/**
799141cc406Sopenharmony_ci */
800141cc406Sopenharmony_cistatic void fnDACDarkSamsung( U12_Device *dev, ShadingVarDef *sTbl,
801141cc406Sopenharmony_ci                              u_long dwCh, u_short wDarkest )
802141cc406Sopenharmony_ci{
803141cc406Sopenharmony_ci	u_short w;
804141cc406Sopenharmony_ci
805141cc406Sopenharmony_ci	if( wDarkest > sTbl->DarkCmpHi.wColors[dwCh] ) {
806141cc406Sopenharmony_ci
807141cc406Sopenharmony_ci		wDarkest -= sTbl->DarkCmpHi.wColors[dwCh];
808141cc406Sopenharmony_ci		if( wDarkest > dev->shade.wDarkLevels )
809141cc406Sopenharmony_ci			w = (u_short)dev->shade.DarkDAC.bColors[dwCh] -
810141cc406Sopenharmony_ci	                                        wDarkest / dev->shade.wDarkLevels;
811141cc406Sopenharmony_ci		else
812141cc406Sopenharmony_ci			w = (u_short)dev->shade.DarkDAC.bColors[dwCh] - 1U;
813141cc406Sopenharmony_ci
814141cc406Sopenharmony_ci		if((short) w < 0)
815141cc406Sopenharmony_ci			w = 0;
816141cc406Sopenharmony_ci
817141cc406Sopenharmony_ci		if(w != (u_short)dev->shade.DarkDAC.bColors[dwCh]) {
818141cc406Sopenharmony_ci			dev->shade.DarkDAC.bColors [dwCh] = (SANE_Byte)w;
819141cc406Sopenharmony_ci	        dev->shade.fStop                  = SANE_FALSE;
820141cc406Sopenharmony_ci		}
821141cc406Sopenharmony_ci	} else {
822141cc406Sopenharmony_ci		if((wDarkest < sTbl->DarkCmpLo.wColors[dwCh]) &&
823141cc406Sopenharmony_ci		                                    dev->shade.DarkDAC.bColors[dwCh]) {
824141cc406Sopenharmony_ci			if( wDarkest )
825141cc406Sopenharmony_ci				w = (u_short)dev->shade.DarkDAC.bColors[dwCh] + 2U;
826141cc406Sopenharmony_ci			else
827141cc406Sopenharmony_ci				w = dev->shade.wDarkLevels + (u_short)dev->shade.DarkDAC.bColors[dwCh];
828141cc406Sopenharmony_ci
829141cc406Sopenharmony_ci			if (w > 0xff)
830141cc406Sopenharmony_ci				w = 0xff;
831141cc406Sopenharmony_ci
832141cc406Sopenharmony_ci			if(w != (u_short)dev->shade.DarkDAC.bColors[dwCh]) {
833141cc406Sopenharmony_ci				dev->shade.DarkDAC.bColors[dwCh] = (SANE_Byte)w;
834141cc406Sopenharmony_ci				dev->shade.fStop                 = SANE_FALSE;
835141cc406Sopenharmony_ci			}
836141cc406Sopenharmony_ci		}
837141cc406Sopenharmony_ci	}
838141cc406Sopenharmony_ci}
839141cc406Sopenharmony_ci
840141cc406Sopenharmony_ci/************************ exported functions *********************************/
841141cc406Sopenharmony_ci
842141cc406Sopenharmony_ci/** according to detected CCD and DAC, we set their correct init values
843141cc406Sopenharmony_ci *  and functions
844141cc406Sopenharmony_ci */
845141cc406Sopenharmony_cistatic void u12ccd_InitCCDandDAC( U12_Device *dev, SANE_Bool shading )
846141cc406Sopenharmony_ci{
847141cc406Sopenharmony_ci	u_short        w;
848141cc406Sopenharmony_ci	ShadingVarDef *pDAC_CCD;
849141cc406Sopenharmony_ci
850141cc406Sopenharmony_ci	DBG( _DBG_INFO, "CCD & DAC init\n" );
851141cc406Sopenharmony_ci
852141cc406Sopenharmony_ci	/* some presets */
853141cc406Sopenharmony_ci	dev->f0_8_16 = SANE_FALSE;
854141cc406Sopenharmony_ci
855141cc406Sopenharmony_ci	switch( dev->DACType ) {
856141cc406Sopenharmony_ci
857141cc406Sopenharmony_ci	case _DA_WOLFSON8143:
858141cc406Sopenharmony_ci
859141cc406Sopenharmony_ci		DBG( _DBG_INFO, "* DAC: WOLFSON 8143\n" );
860141cc406Sopenharmony_ci		switch( dev->CCDID ) {
861141cc406Sopenharmony_ci
862141cc406Sopenharmony_ci		case _CCD_3797:
863141cc406Sopenharmony_ci			DBG( _DBG_INFO, "* CCD-3797\n" );
864141cc406Sopenharmony_ci			pDAC_CCD          = ShadingVar3797;
865141cc406Sopenharmony_ci			u12ccd_InitFunc   = fnCCDInitWolfson3797;
866141cc406Sopenharmony_ci			dev->fnDarkOffset = fnDarkOffsetWolfson3797;
867141cc406Sopenharmony_ci			dev->fnDACDark    = fnDACDarkWolfson;
868141cc406Sopenharmony_ci			dev->CCDRegs      = (RegDef*)W3797CCDParams;
869141cc406Sopenharmony_ci			break;
870141cc406Sopenharmony_ci
871141cc406Sopenharmony_ci		case _CCD_548:
872141cc406Sopenharmony_ci			DBG( _DBG_INFO, "* CCD-548\n" );
873141cc406Sopenharmony_ci			pDAC_CCD          = ShadingVar548;
874141cc406Sopenharmony_ci			u12ccd_InitFunc   = fnCCDInitWolfson548;
875141cc406Sopenharmony_ci			dev->fnDarkOffset = fnDarkOffsetWolfson3797;
876141cc406Sopenharmony_ci			dev->fnDACDark    = fnDACDarkWolfson;
877141cc406Sopenharmony_ci			dev->CCDRegs      = (RegDef*)W548CCDParams;
878141cc406Sopenharmony_ci			break;
879141cc406Sopenharmony_ci
880141cc406Sopenharmony_ci
881141cc406Sopenharmony_ci		default:
882141cc406Sopenharmony_ci			DBG( _DBG_INFO, "* CCD-3799\n" );
883141cc406Sopenharmony_ci			pDAC_CCD          = ShadingVar3799;
884141cc406Sopenharmony_ci			u12ccd_InitFunc   = fnCCDInitWolfson3799;
885141cc406Sopenharmony_ci/* CHECK: org was to  fnDarkOffsetWolfson3797 */
886141cc406Sopenharmony_ci			dev->fnDarkOffset = fnDarkOffsetWolfson3797;
887141cc406Sopenharmony_ci			dev->fnDACDark    = fnDACDarkWolfson;
888141cc406Sopenharmony_ci			dev->CCDRegs      = (RegDef*)W3799CCDParams;
889141cc406Sopenharmony_ci		}
890141cc406Sopenharmony_ci
891141cc406Sopenharmony_ci		dev->numCCDRegs         = _NUM_OF_CCDREGS_W8143;
892141cc406Sopenharmony_ci		dev->numDACRegs         = _NUM_OF_DACREGS_W8143;
893141cc406Sopenharmony_ci		dev->DACRegs            = WolfsonDAC8143;
894141cc406Sopenharmony_ci		dev->RegDACOffset.Red   = 0x20;
895141cc406Sopenharmony_ci		dev->RegDACOffset.Green = 0x21;
896141cc406Sopenharmony_ci		dev->RegDACOffset.Blue  = 0x22;
897141cc406Sopenharmony_ci		dev->RegDACGain.Red     = 0x28;
898141cc406Sopenharmony_ci		dev->RegDACGain.Green   = 0x29;
899141cc406Sopenharmony_ci		dev->RegDACGain.Blue    = 0x2a;
900141cc406Sopenharmony_ci
901141cc406Sopenharmony_ci		if( dev->shade.intermediate & _ScanMode_AverageOut ) {
902141cc406Sopenharmony_ci			dev->shade.bUniGain    = 1;
903141cc406Sopenharmony_ci			dev->shade.bGainDouble = 1;
904141cc406Sopenharmony_ci		} else {
905141cc406Sopenharmony_ci			dev->shade.bUniGain    = 2;
906141cc406Sopenharmony_ci			dev->shade.bGainDouble = 4;
907141cc406Sopenharmony_ci		}
908141cc406Sopenharmony_ci		dev->shade.bMinGain    = 1;
909141cc406Sopenharmony_ci		dev->shade.bMaxGain    = 0x1f;
910141cc406Sopenharmony_ci		dev->shade.wDarkLevels = 10;
911141cc406Sopenharmony_ci
912141cc406Sopenharmony_ci		if( dev->shade.intermediate == _ScanMode_Color )
913141cc406Sopenharmony_ci			WolfsonDAC8143[2].val = 0x52;
914141cc406Sopenharmony_ci		else
915141cc406Sopenharmony_ci			WolfsonDAC8143[2].val = 0x42;
916141cc406Sopenharmony_ci
917141cc406Sopenharmony_ci		if (dev->shade.intermediate == _ScanMode_Mono )
918141cc406Sopenharmony_ci			WolfsonDAC8143[0].val = 7;
919141cc406Sopenharmony_ci		else
920141cc406Sopenharmony_ci			WolfsonDAC8143[0].val = 3;
921141cc406Sopenharmony_ci		break;
922141cc406Sopenharmony_ci
923141cc406Sopenharmony_ci	case _DA_SAMSUNG1224:
924141cc406Sopenharmony_ci		DBG( _DBG_INFO, "* DAC: Samsung 1224\n" );
925141cc406Sopenharmony_ci
926141cc406Sopenharmony_ci		switch( dev->CCDID ) {
927141cc406Sopenharmony_ci
928141cc406Sopenharmony_ci		case _CCD_3797:
929141cc406Sopenharmony_ci			DBG( _DBG_INFO, "* CCD-3797\n" );
930141cc406Sopenharmony_ci			pDAC_CCD          = ShadingVar3797;
931141cc406Sopenharmony_ci			u12ccd_InitFunc   = fnCCDInitSamsung3797;
932141cc406Sopenharmony_ci			dev->fnDarkOffset = fnDarkOffsetSamsung3797;
933141cc406Sopenharmony_ci			dev->fnDACDark    = fnDACDarkSamsung;
934141cc406Sopenharmony_ci			dev->CCDRegs      = (RegDef*)S3797CCDParams;
935141cc406Sopenharmony_ci			break;
936141cc406Sopenharmony_ci
937141cc406Sopenharmony_ci		default:
938141cc406Sopenharmony_ci			DBG( _DBG_INFO, "* CCD-3799\n" );
939141cc406Sopenharmony_ci			pDAC_CCD          = ShadingVar3799;
940141cc406Sopenharmony_ci			u12ccd_InitFunc   = fnCCDInitSamsung3799;
941141cc406Sopenharmony_ci			dev->fnDarkOffset = fnDarkOffsetSamsung3799;
942141cc406Sopenharmony_ci			dev->fnDACDark    = fnDACDarkSamsung;
943141cc406Sopenharmony_ci			dev->CCDRegs      = (RegDef*)S3799CCDParams;
944141cc406Sopenharmony_ci		}
945141cc406Sopenharmony_ci		dev->numCCDRegs         = _NUM_OF_CCDREGS_S1224;
946141cc406Sopenharmony_ci		dev->numDACRegs         = _NUM_OF_DACREGS_S1224;
947141cc406Sopenharmony_ci		dev->DACRegs            = SamsungDAC1224;
948141cc406Sopenharmony_ci		dev->RegDACOffset.Red   = 1;
949141cc406Sopenharmony_ci		dev->RegDACOffset.Green = 2;
950141cc406Sopenharmony_ci		dev->RegDACOffset.Blue  = 3;
951141cc406Sopenharmony_ci		dev->RegDACGain.Red     = 4;
952141cc406Sopenharmony_ci		dev->RegDACGain.Green   = 5;
953141cc406Sopenharmony_ci		dev->RegDACGain.Blue    = 6;
954141cc406Sopenharmony_ci		dev->shade.bGainDouble  = 6;
955141cc406Sopenharmony_ci		dev->shade.bUniGain     = 7;
956141cc406Sopenharmony_ci		dev->shade.bMinGain     = 0;
957141cc406Sopenharmony_ci		dev->shade.bMaxGain     = 0x1f;
958141cc406Sopenharmony_ci		dev->shade.wDarkLevels  = 10;
959141cc406Sopenharmony_ci
960141cc406Sopenharmony_ci		if( dev->shade.intermediate & _ScanMode_Mono )
961141cc406Sopenharmony_ci			SamsungDAC1224[0].val = 0x57;
962141cc406Sopenharmony_ci		else
963141cc406Sopenharmony_ci			SamsungDAC1224[0].val = 0x51;
964141cc406Sopenharmony_ci		break;
965141cc406Sopenharmony_ci
966141cc406Sopenharmony_ci	case _DA_ESIC:
967141cc406Sopenharmony_ci		DBG( _DBG_INFO, "* DAC: ESIC\n" );
968141cc406Sopenharmony_ci
969141cc406Sopenharmony_ci		switch( dev->CCDID ) {
970141cc406Sopenharmony_ci
971141cc406Sopenharmony_ci		case _CCD_3797:
972141cc406Sopenharmony_ci			DBG( _DBG_INFO, "* CCD-3797\n" );
973141cc406Sopenharmony_ci			pDAC_CCD          = ShadingVar3797;
974141cc406Sopenharmony_ci			u12ccd_InitFunc   = fnCCDInitWolfson3797;
975141cc406Sopenharmony_ci			dev->fnDarkOffset = fnDarkOffsetWolfson3797;
976141cc406Sopenharmony_ci			dev->fnDACDark    = fnDACDarkWolfson;
977141cc406Sopenharmony_ci			dev->CCDRegs      = (RegDef*)W3797CCDParams;
978141cc406Sopenharmony_ci			break;
979141cc406Sopenharmony_ci
980141cc406Sopenharmony_ci		default:
981141cc406Sopenharmony_ci			DBG( _DBG_INFO, "* CCD-3799\n" );
982141cc406Sopenharmony_ci			pDAC_CCD          = ShadingVar3799;
983141cc406Sopenharmony_ci			u12ccd_InitFunc   = fnCCDInitESIC3799;
984141cc406Sopenharmony_ci			dev->fnDarkOffset = fnDarkOffsetWolfson3797;
985141cc406Sopenharmony_ci			dev->fnDACDark    = fnDACDarkWolfson;
986141cc406Sopenharmony_ci			dev->CCDRegs      = (RegDef*)W3799CCDParams;
987141cc406Sopenharmony_ci		}
988141cc406Sopenharmony_ci
989141cc406Sopenharmony_ci		dev->numCCDRegs         = _NUM_OF_CCDREGS_W8143;
990141cc406Sopenharmony_ci		dev->numDACRegs         = _NUM_OF_DACREGS_W8143;
991141cc406Sopenharmony_ci		dev->DACRegs            = WolfsonDAC8143;
992141cc406Sopenharmony_ci		dev->RegDACOffset.Red   = 0x20;
993141cc406Sopenharmony_ci		dev->RegDACOffset.Green = 0x21;
994141cc406Sopenharmony_ci		dev->RegDACOffset.Blue  = 0x22;
995141cc406Sopenharmony_ci		dev->RegDACGain.Red     = 0x28;
996141cc406Sopenharmony_ci		dev->RegDACGain.Green   = 0x29;
997141cc406Sopenharmony_ci		dev->RegDACGain.Blue    = 0x2a;
998141cc406Sopenharmony_ci
999141cc406Sopenharmony_ci		if( dev->shade.intermediate & _ScanMode_AverageOut ) {
1000141cc406Sopenharmony_ci			dev->shade.bUniGain    = 1;
1001141cc406Sopenharmony_ci			dev->shade.bGainDouble = 1;
1002141cc406Sopenharmony_ci		} else {
1003141cc406Sopenharmony_ci			dev->shade.bUniGain    = 2;
1004141cc406Sopenharmony_ci			dev->shade.bGainDouble = 4;
1005141cc406Sopenharmony_ci		}
1006141cc406Sopenharmony_ci		dev->shade.bMinGain    = 1;
1007141cc406Sopenharmony_ci		dev->shade.bMaxGain    = 0x1f;
1008141cc406Sopenharmony_ci		dev->shade.wDarkLevels = 10;
1009141cc406Sopenharmony_ci
1010141cc406Sopenharmony_ci		if( dev->shade.intermediate == _ScanMode_Color )
1011141cc406Sopenharmony_ci			WolfsonDAC8143[2].val = 0x52;
1012141cc406Sopenharmony_ci		else
1013141cc406Sopenharmony_ci			WolfsonDAC8143[2].val = 0x42;
1014141cc406Sopenharmony_ci
1015141cc406Sopenharmony_ci		if(dev->shade.intermediate == _ScanMode_Mono )
1016141cc406Sopenharmony_ci			WolfsonDAC8143[0].val = 7;
1017141cc406Sopenharmony_ci		else
1018141cc406Sopenharmony_ci			WolfsonDAC8143[0].val = 3;
1019141cc406Sopenharmony_ci		break;
1020141cc406Sopenharmony_ci
1021141cc406Sopenharmony_ci	default:
1022141cc406Sopenharmony_ci
1023141cc406Sopenharmony_ci		DBG( _DBG_INFO, "* DAC: SAMSUNG 8531\n" );
1024141cc406Sopenharmony_ci		switch( dev->CCDID ) {
1025141cc406Sopenharmony_ci
1026141cc406Sopenharmony_ci		case _CCD_3797:
1027141cc406Sopenharmony_ci			DBG( _DBG_INFO, "* CCD-3797\n" );
1028141cc406Sopenharmony_ci			pDAC_CCD          = ShadingVar3797;
1029141cc406Sopenharmony_ci			u12ccd_InitFunc   = fnCCDInitSamsung3797;
1030141cc406Sopenharmony_ci			dev->fnDarkOffset = fnDarkOffsetSamsung3797;
1031141cc406Sopenharmony_ci			dev->fnDACDark    = fnDACDarkSamsung;
1032141cc406Sopenharmony_ci			dev->CCDRegs      = (RegDef*)S3797CCDParams;
1033141cc406Sopenharmony_ci			break;
1034141cc406Sopenharmony_ci
1035141cc406Sopenharmony_ci		case _CCD_3777:
1036141cc406Sopenharmony_ci			DBG( _DBG_INFO, "* CCD-3777\n" );
1037141cc406Sopenharmony_ci			pDAC_CCD          = ShadingVar3777;
1038141cc406Sopenharmony_ci			u12ccd_InitFunc   = fnCCDInitSamsung3777;
1039141cc406Sopenharmony_ci			dev->fnDarkOffset = fnDarkOffsetSamsung3777;
1040141cc406Sopenharmony_ci			dev->fnDACDark    = fnDACDarkSamsung;
1041141cc406Sopenharmony_ci			dev->CCDRegs      = (RegDef*)S3797CCDParams;
1042141cc406Sopenharmony_ci			dev->f0_8_16      = SANE_TRUE;
1043141cc406Sopenharmony_ci			break;
1044141cc406Sopenharmony_ci
1045141cc406Sopenharmony_ci		default:
1046141cc406Sopenharmony_ci			DBG( _DBG_INFO, "* CCD-3799\n" );
1047141cc406Sopenharmony_ci			pDAC_CCD          = ShadingVar3799;
1048141cc406Sopenharmony_ci			u12ccd_InitFunc   = fnCCDInitSamsung3799;
1049141cc406Sopenharmony_ci			dev->fnDarkOffset = fnDarkOffsetSamsung3799;
1050141cc406Sopenharmony_ci			dev->fnDACDark    = fnDACDarkSamsung;
1051141cc406Sopenharmony_ci			dev->CCDRegs      = (RegDef*)S3799CCDParams;
1052141cc406Sopenharmony_ci		}
1053141cc406Sopenharmony_ci
1054141cc406Sopenharmony_ci		dev->numCCDRegs         = _NUM_OF_CCDREGS_S8531;
1055141cc406Sopenharmony_ci		dev->numDACRegs         = _NUM_OF_DACREGS_S8531;
1056141cc406Sopenharmony_ci		dev->DACRegs            = SamsungDAC8531;
1057141cc406Sopenharmony_ci		dev->RegDACOffset.Red   = 1;
1058141cc406Sopenharmony_ci		dev->RegDACOffset.Green = 1;
1059141cc406Sopenharmony_ci		dev->RegDACOffset.Blue  = 1;
1060141cc406Sopenharmony_ci		dev->RegDACGain.Red     = 2;
1061141cc406Sopenharmony_ci		dev->RegDACGain.Green   = 2;
1062141cc406Sopenharmony_ci		dev->RegDACGain.Blue    = 2;
1063141cc406Sopenharmony_ci		dev->shade.bGainDouble  = 6;
1064141cc406Sopenharmony_ci		dev->shade.bMinGain     = 1;
1065141cc406Sopenharmony_ci		dev->shade.bMaxGain     = 0x1f;
1066141cc406Sopenharmony_ci		if( dev->DataInf.dwScanFlag & _SCANDEF_TPA )
1067141cc406Sopenharmony_ci			dev->shade.bUniGain = 2;
1068141cc406Sopenharmony_ci		else
1069141cc406Sopenharmony_ci			dev->shade.bUniGain = 7;
1070141cc406Sopenharmony_ci
1071141cc406Sopenharmony_ci		dev->shade.wDarkLevels = 10;
1072141cc406Sopenharmony_ci
1073141cc406Sopenharmony_ci		if( dev->shade.intermediate & _ScanMode_Mono ) {
1074141cc406Sopenharmony_ci			SamsungDAC8531[0].val = 0x57;
1075141cc406Sopenharmony_ci			SamsungDAC8531[3].val = 0x57;
1076141cc406Sopenharmony_ci			SamsungDAC8531[6].val = 0x57;
1077141cc406Sopenharmony_ci		} else {
1078141cc406Sopenharmony_ci			SamsungDAC8531[0].val = 0x51;
1079141cc406Sopenharmony_ci			SamsungDAC8531[3].val = 0x55;
1080141cc406Sopenharmony_ci			SamsungDAC8531[6].val = 0x59;
1081141cc406Sopenharmony_ci		}
1082141cc406Sopenharmony_ci	}
1083141cc406Sopenharmony_ci
1084141cc406Sopenharmony_ci	if( shading ) {
1085141cc406Sopenharmony_ci
1086141cc406Sopenharmony_ci		if( !(dev->DataInf.dwScanFlag & _SCANDEF_TPA))
1087141cc406Sopenharmony_ci			dev->shade.pCcdDac = &pDAC_CCD[_REFLECTION];
1088141cc406Sopenharmony_ci		else {
1089141cc406Sopenharmony_ci			if( dev->DataInf.dwScanFlag & _SCANDEF_Transparency )
1090141cc406Sopenharmony_ci				dev->shade.pCcdDac = &pDAC_CCD[_TRANSPARENCY];
1091141cc406Sopenharmony_ci			else
1092141cc406Sopenharmony_ci				dev->shade.pCcdDac = &pDAC_CCD[_NEGATIVE];
1093141cc406Sopenharmony_ci		}
1094141cc406Sopenharmony_ci	} else {
1095141cc406Sopenharmony_ci		dev->shade.pCcdDac = &pDAC_CCD[_REFLECTION];
1096141cc406Sopenharmony_ci	}
1097141cc406Sopenharmony_ci
1098141cc406Sopenharmony_ci	/* as we now have the correct init function, call it */
1099141cc406Sopenharmony_ci	u12ccd_InitFunc( dev );
1100141cc406Sopenharmony_ci
1101141cc406Sopenharmony_ci	DBG( _DBG_INFO, "* Programming DAC (%u regs)\n", dev->numDACRegs );
1102141cc406Sopenharmony_ci
1103141cc406Sopenharmony_ci	for( w = 0; w < dev->numDACRegs; w++ ) {
1104141cc406Sopenharmony_ci
1105141cc406Sopenharmony_ci		DBG( _DBG_INFO, "* [0x%02x] = 0x%02x\n", dev->DACRegs[w].reg,
1106141cc406Sopenharmony_ci		                                         dev->DACRegs[w].val );
1107141cc406Sopenharmony_ci#if 0
1108141cc406Sopenharmony_ci		u12io_DataRegisterToDAC( dev, dev->DACRegs[w].reg,
1109141cc406Sopenharmony_ci		                              dev->DACRegs[w].val );
1110141cc406Sopenharmony_ci#else
1111141cc406Sopenharmony_ci		u12io_DataToRegister( dev, REG_ADCADDR, dev->DACRegs[w].reg );
1112141cc406Sopenharmony_ci		u12io_DataToRegister( dev, REG_ADCDATA, dev->DACRegs[w].val );
1113141cc406Sopenharmony_ci		u12io_DataToRegister( dev, REG_ADCSERIALOUT, dev->DACRegs[w].val );
1114141cc406Sopenharmony_ci#endif
1115141cc406Sopenharmony_ci	}
1116141cc406Sopenharmony_ci	DBG( _DBG_INFO, "CCD & DAC init done.\n" );
1117141cc406Sopenharmony_ci}
1118141cc406Sopenharmony_ci
1119141cc406Sopenharmony_ci/* END U12-CCD.C ............................................................*/
1120